|
1
|
|
-(()=>{"use strict";var e={5338:(e,t,a)=>{var l=a(5795);t.H=l.createRoot,l.hydrateRoot},5795:e=>{e.exports=window.ReactDOM}},t={};function a(l){var c=t[l];if(void 0!==c)return c.exports;var r=t[l]={exports:{}};return e[l](r,r.exports,a),r.exports}a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var l in t)a.o(t,l)&&!a.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);const l=window.React,c=window.wp.data,r=window.wp.domReady;var n=a.n(r),s=a(5338);const o=window.wp.i18n,m=window.wp.components,i=({main:e,mainLoading:t,setTemplates:a,type:c,category:r,setCategory:n,setPageNumber:s,search:o,setSearch:i})=>{var h;const d=(0,l.useMemo)((()=>(()=>{let e;return(...t)=>{clearTimeout(e),e=setTimeout((()=>{(e=>{i(e),s(1),a([])})(...t)}),600)}})()),[o]),p=e=>{const t=e.target.value;d(t)},{"patterns-category":w=[],"pages-category":v=[],type:g=[]}=e||{},u="pages"===c?v:w,E=[{label:"All",name:"all",count:null!==(h=g?.find((e=>e.name===c))?.count)&&void 0!==h?h:0},...u?.filter((e=>"pro"!==e.name))];return(0,l.createElement)("aside",{className:"modalBodySidebar"},(0,l.createElement)("div",{className:"modalBodySidebarSearch"},(0,l.createElement)("input",{type:"text",placeholder:"Search",onChange:p}),(0,l.createElement)("svg",{onClick:p,xmlns:"http://www.w3.org/2000/svg",height:"16",width:"16",viewBox:"0 0 512 512"},(0,l.createElement)("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,l.createElement)("ui",{className:"modalBodySidebarCategories"},t?(0,l.createElement)("div",{className:"bPlPlaceCenter"},(0,l.createElement)(m.Spinner,{className:"bPlSpinner"})):E?.map((({name:e,label:t,count:c},o)=>(0,l.createElement)("li",{onClick:()=>{n(e),s(1),a([])},className:"libraryBtn "+(e===r?"active":""),key:o},(0,l.createElement)("span",{dangerouslySetInnerHTML:{__html:t}}),(0,l.createElement)("span",null,"(",c||0,")"))))))},h=window.wp.blockEditor,d=window.wp.blocks,p=(0,l.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"12",viewBox:"0 0 384 512"},(0,l.createElement)("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"})),w=(0,l.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"11",width:"11",viewBox:"0 0 512 512",fill:"currentColor"},(0,l.createElement)("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"})),v=`${location.origin}/wp-admin/admin.php?page=b-blocks#/pricing`,g=({isPremium:e,type:t,setShow:a,mainLoading:c,templates:r,templatesLoading:n,children:s})=>{const[o,i]=(0,l.useState)(!1),[p,g]=(0,l.useState)(!1),u=window.bBlocksCursorDataConfig?.nonce;return(0,l.useEffect)((()=>{n?setTimeout((()=>{g(!0)}),1e3):g(!1)}),[n]),(0,l.createElement)("div",{className:"modalBodyTemplates"},r?.length?(0,l.createElement)(l.Fragment,null,(0,l.createElement)("div",{className:"grid columns-3 columns-tablet-1 columns-mobile-1"},r.map(((c,r)=>{const{ID:n,original_content:s,category:p,thumbnail:g}=c,E=p?.includes("pro"),f=e||!E,b=f?{onClick:()=>{i(n),wp.ajax.post("bblocks_template_import",{_wpnonce:u,original_content:s}).done((e=>{if(i(!1),e){const t=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,d.parse)(t);wp.data.dispatch("core/block-editor").insertBlocks(e),a(!1)}catch(e){console.error(e)}}})).fail((e=>{console.error(e),i(!1)}))}}:{href:v,target:"_blank",rel:"noreferrer"};return(0,l.createElement)("div",{className:"modalBodyTemplateItem "+("pages"===t?"isPages":""),key:r},(0,l.createElement)("div",{className:"modalBodyTemplateItemPreviewWrap"},(0,l.createElement)("div",{className:"modalBodyTemplateItemPreview"},g&&(0,l.createElement)("img",{src:g,alt:c.name,className:"modalBodyTemplateItemPreviewImg"}),!g&&(0,l.createElement)(h.BlockPreview,{blocks:(0,d.parse)(s),viewportWidth:1600})),(0,l.createElement)("div",{className:"modalBodyTemplateItemButton"},(0,l.createElement)("a",{className:o===n?"disabled":"",...b},f?(0,l.createElement)(l.Fragment,null,(0,l.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512"},(0,l.createElement)("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,l.createElement)(l.Fragment,null,"Get Pro",w)),o===n&&(0,l.createElement)(m.Spinner,{className:"bPlSpinner"}))))}))),s):(0,l.createElement)(l.Fragment,null,c||p?(0,l.createElement)("div",{className:"bPlPlaceCenter"},(0,l.createElement)(m.Spinner,{className:"bPlSpinner"})):(0,l.createElement)("div",{className:"bPlPlaceCenter modalBodyTemplateNotFound"},"No Templates Found!!")))},u="#146EF5",E=(0,l.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 43 43",fill:"none"},(0,l.createElement)("g",{clipPath:"url(#clip0_1877_1771)"},(0,l.createElement)("rect",{width:"43",height:"43",rx:"15",fill:"url(#paint0_linear_1877_1771)"}),(0,l.createElement)("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,l.createElement)("defs",null,(0,l.createElement)("linearGradient",{id:"paint0_linear_1877_1771",x1:"-4.31905",y1:"30.2033",x2:"31.8123",y2:"30.2033",gradientUnits:"userSpaceOnUse"},(0,l.createElement)("stop",{stopColor:"#A997F7"}),(0,l.createElement)("stop",{offset:"1",stopColor:"#8C74FD"})),(0,l.createElement)("clipPath",{id:"clip0_1877_1771"},(0,l.createElement)("rect",{width:"43",height:"43",fill:"white"})))),f=((0,l.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24"},(0,l.createElement)("path",{fill:u,d:"M18 8H6c-1.1 0-2 .9-2 2v4c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-4c0-1.1-.9-2-2-2zm.5 6c0 .3-.2.5-.5.5H6c-.3 0-.5-.2-.5-.5v-4c0-.3.2-.5.5-.5h12c.3 0 .5.2.5.5v4zM4 4v1.5h16V4H4zm0 16h16v-1.5H4V20z"})),(0,l.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20"},(0,l.createElement)("path",{fill:u,d:"M4 9h12v2H4V9z"})),(0,l.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20"},(0,l.createElement)("path",{fill:u,d:"M18.33 3.57s.27-.8-.31-1.36c-.53-.52-1.22-.24-1.22-.24-.61.3-5.76 3.47-7.67 5.57-.86.96-2.06 3.79-1.09 4.82.92.98 3.96-.17 4.79-1 2.06-2.06 5.21-7.17 5.5-7.79zM1.4 17.65c2.37-1.56 1.46-3.41 3.23-4.64.93-.65 2.22-.62 3.08.29.63.67.8 2.57-.16 3.46-1.57 1.45-4 1.55-6.15.89z"})),(0,l.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20"},(0,l.createElement)("path",{fill:u,d:"M16.89 1.2l1.41 1.41c.39.39.39 1.02 0 1.41L14 8.33V18H3V3h10.67l1.8-1.8c.4-.39 1.03-.4 1.42 0zm-5.66 8.48l5.37-5.36-1.42-1.42-5.36 5.37-.71 2.12z"})),(0,l.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 16 16"},(0,l.createElement)("path",{fill:u,d:"M0 5v6h16v-6h-16zM15 10h-14v-4h14v4z"}),(0,l.createElement)("path",{fill:u,d:"M2 7h7v2h-7v-2z"})),(0,l.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24"},(0,l.createElement)("path",{fill:u,d:"m22.25 0h-20.5c-.965 0-1.75.785-1.75 1.75v2.5c0 .965.785 1.75 1.75 1.75h20.5c.965 0 1.75-.785 1.75-1.75v-2.5c0-.965-.785-1.75-1.75-1.75z"}),(0,l.createElement)("path",{fill:u,d:"m1.75 15h7.5c.965 0 1.75-.785 1.75-1.75v-3.5c0-.965-.785-1.75-1.75-1.75h-7.5c-.965 0-1.75.785-1.75 1.75v3.5c0 .965.785 1.75 1.75 1.75z"}),(0,l.createElement)("path",{fill:u,d:"m1.75 24h7.5c.965 0 1.75-.785 1.75-1.75v-3.5c0-.965-.785-1.75-1.75-1.75h-7.5c-.965 0-1.75.785-1.75 1.75v3.5c0 .965.785 1.75 1.75 1.75z"}),(0,l.createElement)("path",{fill:u,d:"m22.25 8h-7.5c-.965 0-1.75.785-1.75 1.75v3.5c0 .965.785 1.75 1.75 1.75h7.5c.965 0 1.75-.785 1.75-1.75v-3.5c0-.965-.785-1.75-1.75-1.75z"}),(0,l.createElement)("path",{fill:u,d:"m22.25 17h-7.5c-.965 0-1.75.785-1.75 1.75v3.5c0 .965.785 1.75 1.75 1.75h7.5c.965 0 1.75-.785 1.75-1.75v-3.5c0-.965-.785-1.75-1.75-1.75z"})),(0,l.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 408.328 408.328"},(0,l.createElement)("path",{fill:u,d:"M146.545,67.478V32.185c0-17.638-14.357-31.989-32.001-31.989H32.001C14.357,0.195,0,14.547,0,32.185v343.959 c0,17.638,14.357,31.989,32.001,31.989h344.326c17.644,0,32.001-14.352,32.001-31.989V68.338L146.545,67.478z M371.751,371.569 H36.57V98.081h335.188v273.488H371.751z M268.171,59.215l-98.062-0.006V35.465c0-11.804,9.605-21.402,21.409-21.402h55.245 c11.798,0,21.409,9.599,21.409,21.402V59.215z M395.525,59.215l-98.06-0.006V35.465c0-11.804,9.599-21.402,21.408-21.402h55.242 c11.798,0,21.409,9.599,21.409,21.402V59.215z"})),(0,l.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 16 16"},(0,l.createElement)("path",{fill:u,d:"M0 4v11h16v-14h-16v3zM14 2h1v1h-1v-1zM1 4h14v10h-14v-10z"}),(0,l.createElement)("path",{fill:u,d:"M3 6h2v1h-2v-1z"}),(0,l.createElement)("path",{fill:u,d:"M6 6h7v1h-7v-1z"}),(0,l.createElement)("path",{fill:u,d:"M3 8h2v1h-2v-1z"}),(0,l.createElement)("path",{fill:u,d:"M6 8h7v1h-7v-1z"}),(0,l.createElement)("path",{fill:u,d:"M3 10h2v1h-2v-1z"}),(0,l.createElement)("path",{fill:u,d:"M6 10h7v1h-7v-1z"})),(0,l.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 438.536 438.536"},(0,l.createElement)("path",{fill:u,d:"M414.41,24.123C398.333,8.042,378.963,0,356.315,0H82.228C59.58,0,40.21,8.042,24.126,24.123 C8.045,40.207,0.003,59.576,0.003,82.225v274.084c0,22.647,8.042,42.018,24.123,58.102c16.084,16.084,35.454,24.126,58.102,24.126 h274.084c22.648,0,42.018-8.042,58.095-24.126c16.084-16.084,24.126-35.454,24.126-58.102V82.225 C438.532,59.576,430.49,40.204,414.41,24.123z M365.449,356.309c0,2.471-0.903,4.613-2.714,6.42s-3.949,2.711-6.42,2.711H82.228 c-2.474,0-4.615-0.904-6.423-2.711s-2.712-3.949-2.712-6.42V82.221c0-2.474,0.903-4.615,2.712-6.423 c1.809-1.805,3.949-2.712,6.423-2.712h274.084c2.478,0,4.62,0.903,6.427,2.712c1.808,1.809,2.704,3.949,2.704,6.423v274.088 H365.449z"}),(0,l.createElement)("path",{fill:u,d:"M310.636,146.174H127.914c-7.616,0-13.041,3.335-16.274,9.995c-3.427,6.661-2.952,12.94,1.425,18.842l91.365,127.905 c3.612,5.141,8.563,7.707,14.843,7.707c6.285,0,11.234-2.566,14.84-7.707l91.365-127.905c4.38-5.902,4.853-12.181,1.423-18.842 C323.671,149.509,318.243,146.178,310.636,146.174z"})),(0,l.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 16 16"},(0,l.createElement)("path",{fill:u,d:"M0 4v8h16v-8h-16zM15 11h-14v-4h14v4z"}),(0,l.createElement)("path",{fill:u,d:"M0 0h16v3h-16v-3z"}),(0,l.createElement)("path",{fill:u,d:"M0 13h16v3h-16v-3z"})),(0,l.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 512 512"},(0,l.createElement)("path",{fill:u,d:"M255,394.948H80c-44.112,0-80-35.888-80-80v-118c0-44.112,35.888-80,80-80h175c11.046,0,20,8.954,20,20s-8.954,20-20,20H80 c-22.056,0-40,17.944-40,40v118c0,22.056,17.944,40,40,40h175c11.046,0,20,8.954,20,20S266.046,394.948,255,394.948z M432,116.948 h-18c-11.046,0-20,8.954-20,20s8.954,20,20,20h18c22.056,0,40,17.944,40,40v118c0,22.056-17.944,40-40,40h-18 c-11.046,0-20,8.954-20,20s8.954,20,20,20h18c44.112,0,80-35.888,80-80v-118C512,152.835,476.112,116.948,432,116.948z M414,472 c-33.084,0-60-26.916-60-60V100c0-33.084,26.916-60,60-60c11.046,0,20-8.954,20-20s-8.954-20-20-20 c-32.676,0-61.74,15.755-80,40.066C315.74,15.755,286.676,0,254,0c-11.046,0-20,8.954-20,20s8.954,20,20,20 c33.084,0,60,26.916,60,60v312c0,33.084-26.916,60-60,60c-11.046,0-20,8.954-20,20s8.954,20,20,20c32.676,0,61.74-15.755,80-40.066 C352.26,496.245,381.324,512,414,512c11.046,0,20-8.954,20-20S425.046,472,414,472z"})),(0,l.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 469.75 469.75"},(0,l.createElement)("path",{fill:u,d:"M11.136,104.22c1.132,0.374,2.366,0.635,3.771,0.635c144.39,0.15,288.761,5.509,433.133,1.445 c1.884-0.054,3.529-0.475,4.936-1.166c3.271-0.972,6.195-3.286,7.647-7.317c0.057-0.15,0.092-0.31,0.147-0.462 c0.843-1.594,1.412-3.389,1.671-5.293c3.666-11.819,5.81-23.991,7.257-36.295c0.208-1.772-0.209-3.44-0.98-4.961 c-1.285-4.283-4.804-7.86-10.567-8.033c-147.703-4.466-295.604-8.439-443.244,0c-0.465,0.023-0.869,0.132-1.3,0.198 c-4.436,0.073-8.617,2.554-9.838,8.279C0.81,65.122-0.871,79.129,0.464,93.299C1.079,99.835,5.992,103.476,11.136,104.22z M24.582,65.412c139.185-7.45,278.598-4.164,417.841-0.005c-0.67,5.987-1.366,11.966-2.066,17.946 c-139.056,3.603-278.108-1.231-417.168-1.56C23.277,76.306,23.734,70.857,24.582,65.412z"}),(0,l.createElement)("path",{fill:u,d:"M364.258,266.763c3.361-3.321,4.682-8.312,1.138-13.462c-0.519-0.751-1.092-1.437-1.62-2.179 c-0.016-0.015-0.021-0.04-0.035-0.056c-34.627-49.394-80.974-86.447-129.537-121.488c-1.701-1.229-3.385-1.869-5.007-2.102 c-3.166-2.209-7.312-2.6-11.524,0.604c-48.418,36.846-87.407,82.598-111.779,138.657c-2.731,6.276-0.068,12.167,4.233,15.498 c2.615,2.58,6.292,4.169,10.748,3.539l48.624-6.951c-1.082,32.382-2.168,62.667-3.271,108.217 c-0.365,0.975-0.645,2.021-0.718,3.214c-0.556,8.917-1.145,17.829-1.707,26.746c-2.267,7.2,1.171,15.884,10.628,14.843 c38.263-4.205,76.482-5.738,114.958-4.479c1.401,0.045,2.631-0.168,3.778-0.488c6.327,0.493,12.908-3.285,12.649-11.455 c-1.382-42.569-2.793-99.392-4.215-141.955c17.813-1.143,35.622-2.103,53.481-2.188 C359.323,271.252,362.354,269.394,364.258,266.763z M289.393,250.367c-6.804,0.457-10.587,5.448-11.339,10.755 c-0.406,1.249-0.655,2.61-0.604,4.174c1.377,41.269,2.742,96.797,4.083,138.061c-25.466-0.579-50.833,0.152-76.188,1.976 c0.488-1.128,0.825-2.377,0.899-3.814c3.286-65.825,1.815-79.719,1.732-145.596c-0.005-6.602-5.05-9.938-10.167-10.044 c-1.102-0.31-2.308-0.478-3.702-0.355c-12.652,1.066-25.334,1.554-38.006,2.219c19.771-34.144,44.798-64.152,74.826-90.197 c0.198-0.173,0.328-0.365,0.51-0.541c36.704,26.883,72.026,55.447,100.402,90.962 C317.688,248.539,303.541,249.421,289.393,250.367z"})),(0,l.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 14.707 14.707"},(0,l.createElement)("rect",{x:"6.275",y:"0",width:"2.158",height:"14.707"})),(0,l.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 357 357"},(0,l.createElement)("path",{d:"M357,204H0v-51h357V204z"})),e=>{const{isPremium:t,show:a,setShow:c,setTemplates:r,totalCount:n,templatesLoading:s,setType:h,setCategory:d,pageNumber:w,setPageNumber:v}=e,u=(0,l.useRef)();return(0,l.useEffect)((()=>{let e=e=>{u.current?.contains(e.target)||c(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}})),(0,l.createElement)("div",{className:"templateLibraryModalWrap",style:{visibility:a?"visible":"hidden"}},(0,l.createElement)("div",{ref:u,style:{marginTop:a?"0":"50px",transition:"margin 0.5s ease-out"},className:"modalContainer"},(0,l.createElement)("header",{className:"modalHeader"},(0,l.createElement)("div",{className:"modalHeaderLogo"},E," bBlocks"),(0,l.createElement)("div",{className:"modalHeaderTypes"},(0,l.createElement)(m.TabPanel,{className:"bPlTabPanel bPlAutoTab",activeClass:"activeTab",initialTabName:"pages",tabs:[{name:"pages",title:(0,o.__)("Page Templates","b-blocks")},{name:"patterns",title:(0,o.__)("Patterns","b-blocks")}],onSelect:e=>{h(e),d("all"),v(1),r([])}},(()=>(0,l.createElement)(l.Fragment,null)))),(0,l.createElement)("div",{onClick:()=>c(!1),className:"modalHeaderClose"},p)),a&&(0,l.createElement)("div",{className:"modalBody"},(0,l.createElement)(i,{...e}),(0,l.createElement)(g,{...e,setShow:c,isPremium:t},(0,l.createElement)("div",{className:"modalBodyBottom"},s?(0,l.createElement)("div",{className:"bPlPlaceCenter"},(0,l.createElement)(m.Spinner,{className:"bPlSpinner"})):9*w<n&&(0,l.createElement)("button",{className:"modalBodyTemplateLoadMore libraryBtn active",onClick:()=>v((e=>e+1))},"Load More"))))))}),b=(e,t={},a=!0)=>{const[c,r]=(0,l.useState)(!1),[n,s]=(0,l.useState)(!1),[o,m]=(0,l.useState)(null),[i,h]=(0,l.useState)(null);if(!wp.ajax)return void console.error("Please use wp-util as a dependency");const d=(a={})=>{r(!0),s(!1),m(null),wp.ajax.post(e,{...t,...a}).done((e=>{r(!1),h(e)})).fail((e=>{r(!1),s(!0),m(e)}))},p=(e={})=>{d(e)};return(0,l.useEffect)((()=>{a&&d(t)}),[]),{data:i,saveData:p,refetch:p,isLoading:c,isError:n,error:o}},y=()=>{const[e,t]=(0,l.useState)(!1),[a,c]=(0,l.useState)("pages"),[r,n]=(0,l.useState)("all"),[s,m]=(0,l.useState)(1),[i,h]=(0,l.useState)(""),[d,p]=(0,l.useState)([]),w=window.bBlocksCursorDataConfig?.nonce,{main:v,isLoading:g}=((e,t)=>{const{data:a=null,saveData:c,refetch:r,isLoading:n}=b("bblocks_templates_main",{_wpnonce:e},!1);(0,l.useEffect)((()=>{r()}),[e]),(0,l.useEffect)((()=>{c({type:t})}),[t]);const[s,o]=(0,l.useState)([]);return(0,l.useEffect)((()=>{a&&o(a)}),[a]),{main:s,isLoading:n}})(w,a),{templates:u,totalCount:y,refetchTemplates:C,isLoading:x}=((e,t="patterns",a="all",c=1,r="")=>{const n=r.split(" ").join(","),{data:s=null,saveData:o,refetch:m,isLoading:i,error:h}=b("bblocks_templates",{_wpnonce:e,type:t,category:a,pageNumber:c,search:n},!1);(0,l.useEffect)((()=>{m()}),[e]);const[d,p]=(0,l.useState)([]),[w,v]=(0,l.useState)([]);return(0,l.useEffect)((()=>{c&&o({type:t,category:a,pageNumber:c,search:n})}),[t,a,c,r]),(0,l.useEffect)((()=>{s&&(p(s?.patterns||[]),v(parseInt(s?.count)||0))}),[s]),{templates:d,totalCount:w,refetchTemplates:o,isLoading:i,error:h}})(w,a,r,s,i),M=bBlocksPremiumChecker;return(0,l.useEffect)((()=>{p([...d,...u])}),[u]),(0,l.createElement)(l.Fragment,null,(0,l.createElement)("button",{className:"templateLibraryButton",onClick:()=>t(!0)},E,(0,o.__)("Template Library","b-blocks")),(0,l.createElement)(f,{isPremium:M,show:e,setShow:t,main:v,mainLoading:g,templates:d,setTemplates:p,totalCount:y,templatesLoading:x,type:a,refetchTemplates:C,setType:c,category:r,setCategory:n,pageNumber:s,setPageNumber:m,search:i,setSearch:h}))};n()((()=>{const e=document.createElement("div");e.classList.add("bBlocksTemplateLibraryWrap"),(0,s.H)(e).render((0,l.createElement)(y,null)),(0,c.subscribe)((()=>{setTimeout((()=>{const t=document.querySelector(".edit-post-header-toolbar");t&&(t.querySelector(".bBlocksTemplateLibraryWrap")||t.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",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)}))}))})(); |