PluginProbe
bBlocks – Essential Gutenberg Blocks & Patterns Collection / 2.1.8
bBlocks – Essential Gutenberg Blocks & Patterns Collection v2.1.8
2.1.8 2.1.7 2.1.6 2.1.5 2.1.4 2.1.3 2.1.2 2.1.1 2.1.0 2.0.43 2.0.42 2.0.41 2.0.40 2.0.39 2.0.38 trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.5.1 1.5.2 1.5.3 All 108 releases
← All changes | build/template-library.js +2 -1 2.1.2 → 2.1.8 View file →
@@ -1 +1,2 @@
1 -(()=>{"use strict";var e={n:s=>{var a=s&&s.__esModule?()=>s.default:()=>s;return e.d(a,{a}),a},d:(s,a)=>{for(var t in a)e.o(a,t)&&!e.o(s,t)&&Object.defineProperty(s,t,{enumerable:!0,get:a[t]})},o:(e,s)=>Object.prototype.hasOwnProperty.call(e,s)};const s=window.wp.data,a=window.wp.domReady;var t=e.n(a);const l=window.ReactDOM,r=window.React,o=window.wp.i18n,n=window.wp.components,c=window.ReactJSXRuntime,i=({main:e,mainLoading:s,setTemplates:a,type:t,category:l,setCategory:i,access:d,setAccess:m,accessCounts:p,setPageNumber:u,setSearch:h})=>{const b=(0,r.useMemo)((()=>(()=>{let e;return(...s)=>{clearTimeout(e),e=setTimeout((()=>{(e=>{h(e),u(1),a([])})(...s)}),600)}})()),[]),g=e=>b(e.target.value),{"patterns-category":x=[],"pages-category":w=[]}=e||{},j="pages"===t?w:x,v=p,y=(e?.type||[]).find((e=>e.name===t))?.count,f=(j||[]).find((e=>"pro"===e.name))?.count??0,_=Number.isFinite(y)?y-f:void 0,N=v?v.all:y,C=v?v.free:_,S=v?v.pro:f,L="pro"===d?S:"free"===d?C:N,k=e=>{if(v){const s=v.categories?.[e];if(!s)return;return"pro"===d?s.pro:"free"===d?s.free:s.total}return"all"===d?(j||[]).find((s=>s.name===e))?.count:void 0},P=(j||[]).filter((e=>"free"!==e.name&&"pro"!==e.name)),T=[{label:(0,o.__)("All","b-blocks"),name:"all"},...P],B=[{name:"all",label:(0,o.__)("All","b-blocks")},{name:"free",label:(0,o.__)("Free","b-blocks")},{name:"pro",label:(0,o.__)("Pro","b-blocks")}];return(0,c.jsxs)("aside",{className:"modalBodySidebar",children:[(0,c.jsxs)("div",{className:"modalBodySidebarSearch",children:[(0,c.jsx)("svg",{onClick:g,xmlns:"http://www.w3.org/2000/svg",height:"16",width:"16",viewBox:"0 0 512 512",children:(0,c.jsx)("path",{d:"M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z"})}),(0,c.jsx)("input",{type:"text",placeholder:(0,o.__)("Search templates…","b-blocks"),onChange:g})]}),(0,c.jsx)("div",{className:"modalBodySidebarAccess",children:B.map((({name:e,label:s})=>(0,c.jsxs)("button",{className:`is-${e} ${d===e?"active":""}`,onClick:()=>(e=>{const s=d===e?"all":e;m(s),"all"===l&&"pro"===d!=("pro"===s)&&(u(1),a([]))})(e),"aria-pressed":d===e,children:[(0,c.jsx)("span",{className:"tick","aria-hidden":"true"}),(0,c.jsx)("span",{children:s})]},e)))}),(0,c.jsx)("div",{className:"modalBodySidebarHeading",children:(0,o.__)("Categories","b-blocks")}),(0,c.jsx)("div",{className:"modalBodySidebarCategories",children:s?(0,c.jsx)("div",{className:"bPlPlaceCenter",children:(0,c.jsx)(n.Spinner,{className:"bPlSpinner"})}):T.map((({name:e,label:s},t)=>{return(0,c.jsxs)("button",{className:e===l?"active":"",onClick:()=>(e=>{i(e),u(1),a([])})(e),children:[(0,c.jsx)("span",{className:"catLabel",dangerouslySetInnerHTML:{__html:s}}),(r="all"===e?L:k(e),Number.isFinite(r)&&r>0?(0,c.jsx)("span",{className:"catCount",children:r}):null)]},t);var r}))})]})},d=window.wp.blockEditor,m=window.wp.blocks,p=(0,c.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"12",viewBox:"0 0 384 512",children:(0,c.jsx)("path",{d:"M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"})}),u=(0,c.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"11",width:"11",viewBox:"0 0 512 512",fill:"currentColor",children:(0,c.jsx)("path",{d:"M352 0c-12.9 0-24.6 7.8-29.6 19.8s-2.2 25.7 6.9 34.9L370.7 96 201.4 265.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L416 141.3l41.4 41.4c9.2 9.2 22.9 11.9 34.9 6.9s19.8-16.6 19.8-29.6V32c0-17.7-14.3-32-32-32H352zM80 32C35.8 32 0 67.8 0 112V432c0 44.2 35.8 80 80 80H400c44.2 0 80-35.8 80-80V320c0-17.7-14.3-32-32-32s-32 14.3-32 32V432c0 8.8-7.2 16-16 16H80c-8.8 0-16-7.2-16-16V112c0-8.8 7.2-16 16-16H192c17.7 0 32-14.3 32-32s-14.3-32-32-32H80z"})}),h=`${location.origin}/wp-admin/admin.php?page=b-blocks#/pricing`,b=(location.origin,e=>Array.isArray(e.category)&&e.category.includes("pro")),g=({isPremium:e,type:s,setShow:a,mainLoading:t,templates:l,templatesLoading:i,access:p="all",children:g})=>{const[x,w]=(0,r.useState)(!1),[j,v]=(0,r.useState)(!1),y=window.bBlocksCursorDataConfig?.nonce,f=(l||[]).filter((e=>"pro"===p?b(e):"free"!==p||!b(e)));return(0,r.useEffect)((()=>{i?setTimeout((()=>{v(!0)}),1e3):v(!1)}),[i]),(0,c.jsx)("div",{className:"modalBodyTemplates",children:l?.length?(0,c.jsxs)(c.Fragment,{children:[f.length?(0,c.jsx)("div",{className:"grid columns-3 columns-tablet-1 columns-mobile-1",children:f.map(((t,l)=>{const{ID:r,original_content:i,category:p,thumbnail:b}=t,g=p?.includes("pro"),j=e||!g,v=j?{onClick:()=>{w(r),wp.ajax.post("bblocks_template_import",{_wpnonce:y,original_content:i}).done((e=>{if(w(!1),e){const s=e.replaceAll('\\"','"').replaceAll("\\\\u003cbr\\\\u003e","<br/>").replaceAll("\\\\u003cstrong\\\\u003e","<strong>").replaceAll("\\\\u003c/strong\\\\u003e","</strong>").replaceAll("\\\\u003cem\\\\u003e","<em>").replaceAll("\\\\u003c/em\\\\u003e","</em>");try{const e=(0,m.parse)(s);wp.data.dispatch("core/block-editor").insertBlocks(e),a(!1)}catch(e){console.error(e)}}})).fail((e=>{console.error(e),w(!1)}))}}:{href:h,target:"_blank",rel:"noreferrer"};return(0,c.jsxs)("div",{className:"modalBodyTemplateItem "+("pages"===s?"isPages":""),children:[(0,c.jsxs)("div",{className:"modalBodyTemplateItemPreviewWrap",children:[g&&(0,c.jsx)("span",{className:"modalBodyTemplateItemProBadge",children:(0,o.__)("Pro","b-blocks")}),(0,c.jsxs)("div",{className:"modalBodyTemplateItemPreview",children:[b&&(0,c.jsx)("img",{src:b,alt:t.title,className:"modalBodyTemplateItemPreviewImg"}),!b&&(0,c.jsx)(d.BlockPreview,{blocks:(0,m.parse)(i),viewportWidth:1600})]}),(0,c.jsxs)("div",{className:"modalBodyTemplateItemButton",children:[(0,c.jsx)("a",{className:x===r?"disabled":"",...v,children:j?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",children:(0,c.jsx)("path",{d:"M256 80c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 144L48 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l144 0 0 144c0 17.7 14.3 32 32 32s32-14.3 32-32l0-144 144 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-144 0 0-144z"})}),"Import"]}):(0,c.jsxs)(c.Fragment,{children:["Get Pro",u]})}),x===r&&(0,c.jsx)(n.Spinner,{className:"bPlSpinner"})]})]}),t.title&&(0,c.jsx)("div",{className:"modalBodyTemplateItemTitle",dangerouslySetInnerHTML:{__html:t.title}})]},l)}))}):(0,c.jsx)("div",{className:"modalBodyTemplateNotFound",children:"pro"===p?(0,o.__)("No Pro templates on this page. Try “Load More”.","b-blocks"):(0,o.__)("No Free templates on this page. Try “Load More”.","b-blocks")}),g]}):(0,c.jsx)(c.Fragment,{children:t||j?(0,c.jsx)("div",{className:"bPlPlaceCenter",children:(0,c.jsx)(n.Spinner,{className:"bPlSpinner"})}):(0,c.jsx)("div",{className:"modalBodyTemplateNotFound",children:(0,o.__)("No templates found.","b-blocks")})})})},x=e=>{const{isPremium:s,show:a,setShow:t,setTemplates:l,totalCount:d,templatesLoading:m,setType:u,setCategory:h,pageNumber:b,setPageNumber:x}=e,w=(0,r.useRef)();return(0,r.useEffect)((()=>{let e=e=>{w.current?.contains(e.target)||t(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}})),(0,c.jsx)("div",{className:"templateLibraryModalWrap",style:{visibility:a?"visible":"hidden"},children:(0,c.jsxs)("div",{ref:w,style:{marginTop:a?"0":"50px",transition:"margin 0.5s ease-out"},className:"modalContainer",children:[(0,c.jsxs)("header",{className:"modalHeader",children:[(0,c.jsxs)("div",{className:"modalHeaderLogo",children:[(0,c.jsx)("img",{src:"https://ps.w.org/b-blocks/assets/icon-128x128.png?rev=3342212",alt:"bBlocks"})," bBlocks"]}),(0,c.jsx)("div",{className:"modalHeaderTypes",children:(0,c.jsx)(n.TabPanel,{className:"bPlTabPanel bPlAutoTab",activeClass:"activeTab",initialTabName:"pages",tabs:[{name:"pages",title:(0,o.__)("Pages","b-blocks")},{name:"patterns",title:(0,o.__)("Patterns","b-blocks")}],onSelect:e=>{u(e),h("all"),x(1),l([])},children:()=>(0,c.jsx)(c.Fragment,{})})}),(0,c.jsx)("div",{onClick:()=>t(!1),className:"modalHeaderClose",children:p})]}),a&&(0,c.jsxs)("div",{className:"modalBody",children:[(0,c.jsx)(i,{...e}),(0,c.jsx)(g,{...e,setShow:t,isPremium:s,children:(0,c.jsx)("div",{className:"modalBodyBottom",children:m?(0,c.jsx)("div",{className:"bPlPlaceCenter",children:(0,c.jsx)(n.Spinner,{className:"bPlSpinner"})}):9*b<d&&(0,c.jsx)("button",{className:"modalBodyTemplateLoadMore libraryBtn active",onClick:()=>x((e=>e+1)),children:"Load More"})})})]})]})})},w=(e,s={},a=!0)=>{const[t,l]=(0,r.useState)(!1),[o,n]=(0,r.useState)(!1),[c,i]=(0,r.useState)(null),[d,m]=(0,r.useState)(null);if(!wp.ajax)return void console.error("Please use wp-util as a dependency");const p=(a={})=>{l(!0),n(!1),i(null),wp.ajax.post(e,{...s,...a}).done((e=>{l(!1),m(e)})).fail((e=>{l(!1),n(!0),i(e)}))},u=(e={})=>{p(e)};return(0,r.useEffect)((()=>{a&&p(s)}),[]),{data:d,saveData:u,refetch:u,isLoading:t,isError:o,error:c}},j=(0,c.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 43 43",fill:"none",children:[(0,c.jsxs)("g",{clipPath:"url(#clip0_1877_1771)",children:[(0,c.jsx)("rect",{width:"43",height:"43",rx:"15",fill:"url(#paint0_linear_1877_1771)"}),(0,c.jsx)("path",{d:"M24.2285 40.5754C21.8801 38.2139 19.3932 35.7203 16.8931 33.2071L19.9671 30.265C19.9209 30.1528 19.9209 30.1462 19.8747 30.0341H11.1541C10.2107 30.0341 9.43896 29.2689 9.43896 28.319V15.1984C9.43896 14.4464 10.0458 13.8395 10.7979 13.8395H19.9803L16.7348 10.7589L24.3736 3.14648L34.2487 13.0216C35.0205 13.7934 35.0205 15.0533 34.2487 15.8185L28.1798 21.8016C30.2577 23.8597 32.2763 25.8651 34.2553 27.8242C35.0271 28.5894 35.0205 29.8296 34.2553 30.5948L24.2285 40.5754ZM20.1914 14.11V29.5394C22.7706 26.9799 25.3631 24.4006 27.9357 21.8478C25.3961 19.3147 22.8234 16.742 20.1914 14.11Z",fill:"white"})]}),(0,c.jsxs)("defs",{children:[(0,c.jsxs)("linearGradient",{id:"paint0_linear_1877_1771",x1:"-4.31905",y1:"30.2033",x2:"31.8123",y2:"30.2033",gradientUnits:"userSpaceOnUse",children:[(0,c.jsx)("stop",{stopColor:"#A997F7"}),(0,c.jsx)("stop",{offset:"1",stopColor:"#8C74FD"})]}),(0,c.jsx)("clipPath",{id:"clip0_1877_1771",children:(0,c.jsx)("rect",{width:"43",height:"43",fill:"white"})})]})]}),v=()=>{const[e,s]=(0,r.useState)(!1),[a,t]=(0,r.useState)("pages"),[l,n]=(0,r.useState)("all"),[i,d]=(0,r.useState)("all"),[m,p]=(0,r.useState)(1),[u,h]=(0,r.useState)(""),[b,g]=(0,r.useState)([]),v=window.bBlocksCursorDataConfig?.nonce,y="all"!==l?l:"pro"===i?"pro":"all",{main:f,isLoading:_}=((e,s)=>{const{data:a=null,saveData:t,refetch:l,isLoading:o}=w("bblocks_templates_main",{_wpnonce:e},!1);(0,r.useEffect)((()=>{l()}),[e]),(0,r.useEffect)((()=>{t({type:s})}),[s]);const[n,c]=(0,r.useState)([]);return(0,r.useEffect)((()=>{a&&c(a)}),[a]),{main:n,isLoading:o}})(v,a),{templates:N,totalCount:C,refetchTemplates:S,isLoading:L}=((e,s="patterns",a="all",t=1,l="")=>{const o=l.split(" ").join(","),{data:n=null,saveData:c,refetch:i,isLoading:d}=w("bblocks_templates",{_wpnonce:e,type:s,category:a,pageNumber:t,search:o},!1);(0,r.useEffect)((()=>{i()}),[e]);const[m,p]=(0,r.useState)([]),[u,h]=(0,r.useState)([]);return(0,r.useEffect)((()=>{t&&c({type:s,category:a,pageNumber:t,search:o})}),[s,a,t,l]),(0,r.useEffect)((()=>{n&&(p(n?.patterns||[]),h(parseInt(n?.count)||0))}),[n]),{templates:m,totalCount:u,refetchTemplates:c,isLoading:d}})(v,a,y,m,u),k=((e,s,a)=>{const[t,l]=(0,r.useState)(null);return(0,r.useEffect)((()=>{if(!a||!e)return;let t=!1;return l(null),wp.ajax.post("bblocks_template_counts",{_wpnonce:e,type:s}).done((e=>{t||l(e)})).fail((e=>console.error(e))),()=>{t=!0}}),[e,s,a]),t})(v,a,e),P=bBlocksPremiumChecker;return(0,r.useEffect)((()=>{g([...b,...N])}),[N]),(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)("button",{className:"templateLibraryButton",onClick:()=>s(!0),children:[j,(0,o.__)("Template Library","b-blocks")]}),(0,c.jsx)(x,{isPremium:P,show:e,setShow:s,main:f,mainLoading:_,templates:b,setTemplates:g,totalCount:C,templatesLoading:L,type:a,refetchTemplates:S,setType:t,category:l,setCategory:n,access:i,setAccess:d,accessCounts:k,pageNumber:m,setPageNumber:p,search:u,setSearch:h})]})};t()((()=>{const e=document.createElement("div");e.classList.add("bBlocksTemplateLibraryWrap"),(0,l.createRoot)(e).render((0,c.jsx)(v,{})),(0,s.subscribe)((()=>{setTimeout((()=>{const s=document.querySelector(".edit-post-header-toolbar");s&&(s.querySelector(".bBlocksTemplateLibraryWrap")||s.appendChild(e))}),1)}))}))})();
1 +(()=>{"use strict";var e={n:s=>{var a=s&&s.__esModule?()=>s.default:()=>s;return e.d(a,{a}),a},d:(s,a)=>{for(var t in a)e.o(a,t)&&!e.o(s,t)&&Object.defineProperty(s,t,{enumerable:!0,get:a[t]})},o:(e,s)=>Object.prototype.hasOwnProperty.call(e,s)};const s=window.wp.data,a=window.wp.domReady;var t=e.n(a);const l=window.ReactDOM,r=window.React,o=window.wp.i18n,n=window.wp.components,c=window.ReactJSXRuntime,i=({main:e,mainLoading:s,setTemplates:a,type:t,category:l,setCategory:i,access:d,setAccess:m,accessCounts:p,setPageNumber:u,setSearch:h})=>{const b=(0,r.useMemo)((()=>(()=>{let e;return(...s)=>{clearTimeout(e),e=setTimeout((()=>{(e=>{h(e),u(1),a([])})(...s)}),600)}})()),[]),g=e=>b(e.target.value),{"patterns-category":x=[],"pages-category":w=[]}=e||{},j="pages"===t?w:x,v=p,y=(e?.type||[]).find((e=>e.name===t))?.count,f=(j||[]).find((e=>"pro"===e.name))?.count??0,_=Number.isFinite(y)?y-f:void 0,N=v?v.all:y,C=v?v.free:_,S=v?v.pro:f,L="pro"===d?S:"free"===d?C:N,k=e=>{if(v){const s=v.categories?.[e];if(!s)return;return"pro"===d?s.pro:"free"===d?s.free:s.total}return"all"===d?(j||[]).find((s=>s.name===e))?.count:void 0},P=(j||[]).filter((e=>"free"!==e.name&&"pro"!==e.name)),T=[{label:(0,o.__)("All","b-blocks"),name:"all"},...P],B=[{name:"all",label:(0,o.__)("All","b-blocks")},{name:"free",label:(0,o.__)("Free","b-blocks")},{name:"pro",label:(0,o.__)("Pro","b-blocks")}];return(0,c.jsxs)("aside",{className:"modalBodySidebar",children:[(0,c.jsxs)("div",{className:"modalBodySidebarSearch",children:[(0,c.jsx)("svg",{onClick:g,xmlns:"http://www.w3.org/2000/svg",height:"16",width:"16",viewBox:"0 0 512 512",children:(0,c.jsx)("path",{d:"M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z"})}),(0,c.jsx)("input",{type:"text",placeholder:(0,o.__)("Search templates…","b-blocks"),onChange:g})]}),(0,c.jsx)("div",{className:"modalBodySidebarAccess",children:B.map((({name:e,label:s})=>(0,c.jsxs)("button",{className:`is-${e} ${d===e?"active":""}`,onClick:()=>(e=>{const s=d===e?"all":e;m(s),"all"===l&&"pro"===d!=("pro"===s)&&(u(1),a([]))})(e),"aria-pressed":d===e,children:[(0,c.jsx)("span",{className:"tick","aria-hidden":"true"}),(0,c.jsx)("span",{children:s})]},e)))}),(0,c.jsx)("div",{className:"modalBodySidebarHeading",children:(0,o.__)("Categories","b-blocks")}),(0,c.jsx)("div",{className:"modalBodySidebarCategories",children:s?(0,c.jsx)("div",{className:"bPlPlaceCenter",children:(0,c.jsx)(n.Spinner,{className:"bPlSpinner"})}):T.map((({name:e,label:s},t)=>{return(0,c.jsxs)("button",{className:e===l?"active":"",onClick:()=>(e=>{i(e),u(1),a([])})(e),children:[(0,c.jsx)("span",{className:"catLabel",dangerouslySetInnerHTML:{__html:s}}),(r="all"===e?L:k(e),Number.isFinite(r)&&r>0?(0,c.jsx)("span",{className:"catCount",children:r}):null)]},t);var r}))})]})},d=window.wp.blockEditor,m=window.wp.blocks,p=(0,c.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"12",viewBox:"0 0 384 512",children:(0,c.jsx)("path",{d:"M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"})}),u=(0,c.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"11",width:"11",viewBox:"0 0 512 512",fill:"currentColor",children:(0,c.jsx)("path",{d:"M352 0c-12.9 0-24.6 7.8-29.6 19.8s-2.2 25.7 6.9 34.9L370.7 96 201.4 265.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L416 141.3l41.4 41.4c9.2 9.2 22.9 11.9 34.9 6.9s19.8-16.6 19.8-29.6V32c0-17.7-14.3-32-32-32H352zM80 32C35.8 32 0 67.8 0 112V432c0 44.2 35.8 80 80 80H400c44.2 0 80-35.8 80-80V320c0-17.7-14.3-32-32-32s-32 14.3-32 32V432c0 8.8-7.2 16-16 16H80c-8.8 0-16-7.2-16-16V112c0-8.8 7.2-16 16-16H192c17.7 0 32-14.3 32-32s-14.3-32-32-32H80z"})}),h=`${location.origin}/wp-admin/admin.php?page=b-blocks#/pricing`,b=(location.origin,e=>Array.isArray(e.category)&&e.category.includes("pro")),g=({isPremium:e,type:s,setShow:a,mainLoading:t,templates:l,templatesLoading:i,access:p="all",children:g})=>{const[x,w]=(0,r.useState)(!1),[j,v]=(0,r.useState)(!1),y=window.bBlocksCursorDataConfig?.nonce,f=(l||[]).filter((e=>"pro"===p?b(e):"free"!==p||!b(e)));return(0,r.useEffect)((()=>{i?setTimeout((()=>{v(!0)}),1e3):v(!1)}),[i]),(0,c.jsx)("div",{className:"modalBodyTemplates",children:l?.length?(0,c.jsxs)(c.Fragment,{children:[f.length?(0,c.jsx)("div",{className:"grid columns-3 columns-tablet-1 columns-mobile-1",children:f.map(((t,l)=>{const{ID:r,original_content:i,category:p,thumbnail:b}=t,g=p?.includes("pro"),j=e||!g,v=j?{onClick:()=>{w(r),wp.ajax.post("bblocks_template_import",{_wpnonce:y,original_content:i}).done((e=>{if(w(!1),e){const s=e.replaceAll('\\"','"').replaceAll("\\\\u003cbr\\\\u003e","<br/>").replaceAll("\\\\u003cstrong\\\\u003e","<strong>").replaceAll("\\\\u003c/strong\\\\u003e","</strong>").replaceAll("\\\\u003cem\\\\u003e","<em>").replaceAll("\\\\u003c/em\\\\u003e","</em>");try{const e=(0,m.parse)(s);wp.data.dispatch("core/block-editor").insertBlocks(e),a(!1)}catch(e){console.error(e)}}})).fail((e=>{console.error(e),w(!1)}))}}:{href:h,target:"_blank",rel:"noreferrer"};return(0,c.jsxs)("div",{className:"modalBodyTemplateItem "+("pages"===s?"isPages":""),children:[(0,c.jsxs)("div",{className:"modalBodyTemplateItemPreviewWrap",children:[g&&(0,c.jsx)("span",{className:"modalBodyTemplateItemProBadge",children:(0,o.__)("Pro","b-blocks")}),(0,c.jsxs)("div",{className:"modalBodyTemplateItemPreview",children:[b&&(0,c.jsx)("img",{src:b,alt:t.title,className:"modalBodyTemplateItemPreviewImg"}),!b&&(0,c.jsx)(d.BlockPreview,{blocks:(0,m.parse)(i),viewportWidth:1600})]}),(0,c.jsxs)("div",{className:"modalBodyTemplateItemButton",children:[(0,c.jsx)("a",{className:x===r?"disabled":"",...v,children:j?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",children:(0,c.jsx)("path",{d:"M256 80c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 144L48 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l144 0 0 144c0 17.7 14.3 32 32 32s32-14.3 32-32l0-144 144 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-144 0 0-144z"})}),"Import"]}):(0,c.jsxs)(c.Fragment,{children:["Get Pro",u]})}),x===r&&(0,c.jsx)(n.Spinner,{className:"bPlSpinner"})]})]}),t.title&&(0,c.jsx)("div",{className:"modalBodyTemplateItemTitle",dangerouslySetInnerHTML:{__html:t.title}})]},l)}))}):(0,c.jsx)("div",{className:"modalBodyTemplateNotFound",children:"pro"===p?(0,o.__)("No Pro templates on this page. Try “Load More”.","b-blocks"):(0,o.__)("No Free templates on this page. Try “Load More”.","b-blocks")}),g]}):(0,c.jsx)(c.Fragment,{children:t||j?(0,c.jsx)("div",{className:"bPlPlaceCenter",children:(0,c.jsx)(n.Spinner,{className:"bPlSpinner"})}):(0,c.jsx)("div",{className:"modalBodyTemplateNotFound",children:(0,o.__)("No templates found.","b-blocks")})})})},x=e=>{const{isPremium:s,show:a,setShow:t,setTemplates:l,totalCount:d,templatesLoading:m,setType:u,setCategory:h,pageNumber:b,setPageNumber:x}=e,w=(0,r.useRef)();return(0,r.useEffect)((()=>{let e=e=>{w.current?.contains(e.target)||t(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}})),(0,c.jsx)("div",{className:"templateLibraryModalWrap",style:{visibility:a?"visible":"hidden"},children:(0,c.jsxs)("div",{ref:w,style:{marginTop:a?"0":"50px",transition:"margin 0.5s ease-out"},className:"modalContainer",children:[(0,c.jsxs)("header",{className:"modalHeader",children:[(0,c.jsxs)("div",{className:"modalHeaderLogo",children:[(0,c.jsx)("img",{src:"https://ps.w.org/b-blocks/assets/icon-128x128.png?rev=3342212",alt:"bBlocks"})," bBlocks"]}),(0,c.jsx)("div",{className:"modalHeaderTypes",children:(0,c.jsx)(n.TabPanel,{className:"bPlTabPanel bPlAutoTab",activeClass:"activeTab",
2 +initialTabName:"pages",tabs:[{name:"pages",title:(0,o.__)("Pages","b-blocks")},{name:"patterns",title:(0,o.__)("Patterns","b-blocks")}],onSelect:e=>{u(e),h("all"),x(1),l([])},children:()=>(0,c.jsx)(c.Fragment,{})})}),(0,c.jsx)("div",{onClick:()=>t(!1),className:"modalHeaderClose",children:p})]}),a&&(0,c.jsxs)("div",{className:"modalBody",children:[(0,c.jsx)(i,{...e}),(0,c.jsx)(g,{...e,setShow:t,isPremium:s,children:(0,c.jsx)("div",{className:"modalBodyBottom",children:m?(0,c.jsx)("div",{className:"bPlPlaceCenter",children:(0,c.jsx)(n.Spinner,{className:"bPlSpinner"})}):9*b<d&&(0,c.jsx)("button",{className:"modalBodyTemplateLoadMore libraryBtn active",onClick:()=>x((e=>e+1)),children:"Load More"})})})]})]})})},w=(e,s={},a=!0)=>{const[t,l]=(0,r.useState)(!1),[o,n]=(0,r.useState)(!1),[c,i]=(0,r.useState)(null),[d,m]=(0,r.useState)(null);if(!wp.ajax)return void console.error("Please use wp-util as a dependency");const p=(a={})=>{l(!0),n(!1),i(null),wp.ajax.post(e,{...s,...a}).done((e=>{l(!1),m(e)})).fail((e=>{l(!1),n(!0),i(e)}))},u=(e={})=>{p(e)};return(0,r.useEffect)((()=>{a&&p(s)}),[]),{data:d,saveData:u,refetch:u,isLoading:t,isError:o,error:c}},j=(0,c.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 43 43",fill:"none",children:[(0,c.jsxs)("g",{clipPath:"url(#clip0_1877_1771)",children:[(0,c.jsx)("rect",{width:"43",height:"43",rx:"15",fill:"url(#paint0_linear_1877_1771)"}),(0,c.jsx)("path",{d:"M24.2285 40.5754C21.8801 38.2139 19.3932 35.7203 16.8931 33.2071L19.9671 30.265C19.9209 30.1528 19.9209 30.1462 19.8747 30.0341H11.1541C10.2107 30.0341 9.43896 29.2689 9.43896 28.319V15.1984C9.43896 14.4464 10.0458 13.8395 10.7979 13.8395H19.9803L16.7348 10.7589L24.3736 3.14648L34.2487 13.0216C35.0205 13.7934 35.0205 15.0533 34.2487 15.8185L28.1798 21.8016C30.2577 23.8597 32.2763 25.8651 34.2553 27.8242C35.0271 28.5894 35.0205 29.8296 34.2553 30.5948L24.2285 40.5754ZM20.1914 14.11V29.5394C22.7706 26.9799 25.3631 24.4006 27.9357 21.8478C25.3961 19.3147 22.8234 16.742 20.1914 14.11Z",fill:"white"})]}),(0,c.jsxs)("defs",{children:[(0,c.jsxs)("linearGradient",{id:"paint0_linear_1877_1771",x1:"-4.31905",y1:"30.2033",x2:"31.8123",y2:"30.2033",gradientUnits:"userSpaceOnUse",children:[(0,c.jsx)("stop",{stopColor:"#A997F7"}),(0,c.jsx)("stop",{offset:"1",stopColor:"#8C74FD"})]}),(0,c.jsx)("clipPath",{id:"clip0_1877_1771",children:(0,c.jsx)("rect",{width:"43",height:"43",fill:"white"})})]})]}),v=()=>{const[e,s]=(0,r.useState)(!1),[a,t]=(0,r.useState)("pages"),[l,n]=(0,r.useState)("all"),[i,d]=(0,r.useState)("all"),[m,p]=(0,r.useState)(1),[u,h]=(0,r.useState)(""),[b,g]=(0,r.useState)([]),v=window.bBlocksCursorDataConfig?.nonce,y="all"!==l?l:"pro"===i?"pro":"all",{main:f,isLoading:_}=((e,s)=>{const{data:a=null,saveData:t,refetch:l,isLoading:o}=w("bblocks_templates_main",{_wpnonce:e},!1);(0,r.useEffect)((()=>{l()}),[e]),(0,r.useEffect)((()=>{t({type:s})}),[s]);const[n,c]=(0,r.useState)([]);return(0,r.useEffect)((()=>{a&&c(a)}),[a]),{main:n,isLoading:o}})(v,a),{templates:N,totalCount:C,refetchTemplates:S,isLoading:L}=((e,s="patterns",a="all",t=1,l="")=>{const o=l.split(" ").join(","),{data:n=null,saveData:c,refetch:i,isLoading:d}=w("bblocks_templates",{_wpnonce:e,type:s,category:a,pageNumber:t,search:o},!1);(0,r.useEffect)((()=>{i()}),[e]);const[m,p]=(0,r.useState)([]),[u,h]=(0,r.useState)([]);return(0,r.useEffect)((()=>{t&&c({type:s,category:a,pageNumber:t,search:o})}),[s,a,t,l]),(0,r.useEffect)((()=>{n&&(p(n?.patterns||[]),h(parseInt(n?.count)||0))}),[n]),{templates:m,totalCount:u,refetchTemplates:c,isLoading:d}})(v,a,y,m,u),k=((e,s,a)=>{const[t,l]=(0,r.useState)(null);return(0,r.useEffect)((()=>{if(!a||!e)return;let t=!1;return l(null),wp.ajax.post("bblocks_template_counts",{_wpnonce:e,type:s}).done((e=>{t||l(e)})).fail((e=>console.error(e))),()=>{t=!0}}),[e,s,a]),t})(v,a,e),P=bBlocksPremiumChecker;return(0,r.useEffect)((()=>{g([...b,...N])}),[N]),(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)("button",{className:"templateLibraryButton",onClick:()=>s(!0),children:[j,(0,o.__)("Template Library","b-blocks")]}),(0,c.jsx)(x,{isPremium:P,show:e,setShow:s,main:f,mainLoading:_,templates:b,setTemplates:g,totalCount:C,templatesLoading:L,type:a,refetchTemplates:S,setType:t,category:l,setCategory:n,access:i,setAccess:d,accessCounts:k,pageNumber:m,setPageNumber:p,search:u,setSearch:h})]})};t()((()=>{const e=document.createElement("div");e.classList.add("bBlocksTemplateLibraryWrap"),(0,l.createRoot)(e).render((0,c.jsx)(v,{})),(0,s.subscribe)((()=>{setTimeout((()=>{const s=document.querySelector(".edit-post-header-toolbar");s&&(s.querySelector(".bBlocksTemplateLibraryWrap")||s.appendChild(e))}),1)}))}))})();