0x1998 - MANAGER
Düzenlenen Dosya: extendify-library-46b68847bd85f90eb8b6.js
"use strict";(globalThis.webpackChunkextendify=globalThis.webpackChunkextendify||[]).push([[573],{9952(e,t,n){var a=n(7723),r=n(790);const s=(e=(0,a.__)("Extendify Logo","extendify-local"))=>(0,r.jsxs)("svg",{fill:"none",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsx)("title",{children:e}),(0,r.jsx)("path",{clipRule:"evenodd",d:"m13.505 4h3.3044c.936 0 1.2747.10161 1.6171.29127.3424.19042.6102.46965.7934.82489.1831.356.2801.70824.2801 1.6814v3.43584c0 .9731-.0977 1.3254-.2801 1.6814-.1832.356-.4517.6344-.7934.8248-.153.0852-.3057.1552-.5112.2054v2.7344c0 1.503-.151 2.047-.4327 2.5968-.2828.5498-.6976.9799-1.2252 1.274-.5288.294-1.052.4498-2.4975.4498h-5.10341c-1.44549 0-1.96869-.1569-2.49747-.4498-.52878-.2941-.94242-.7254-1.22526-1.274-.28284-.5487-.43376-1.0938-.43376-2.5968v-5.3051c0-1.50301.15092-2.04701.43264-2.59682.28284-.54981.6976-.98106 1.22638-1.27514.52767-.29293 1.05198-.44985 2.49747-.44985h2.18511c.041-.44652.1265-.69015.2522-.93557.1832-.356.4517-.63523.7941-.82565.3417-.18966.6812-.29127 1.6171-.29127zm-1.6984 2.18698c0-.63769.4973-1.15464 1.1106-1.15464h4.4793c.6133 0 1.1106.51695 1.1106 1.15464v4.65692c0 .6377-.4973 1.1547-1.1106 1.1547h-4.4793c-.6133 0-1.1106-.517-1.1106-1.1547z",fill:"currentColor",fillRule:"evenodd"})]});var o=n(1621),i=n(7134);const l=e=>({open:!1,setOpen:t=>e({open:t}),missingCSSVars:[],addMissingCSSVar:t=>e(e=>e.missingCSSVars.includes(t)?e:{missingCSSVars:[...e.missingCSSVars,t]})}),c=(0,o.vt)((0,i.lt)(l,{name:"Extendify Library Globals"}),l);var d=n(1077),m=n(319);const p=()=>{const{setOpen:e}=c(),{incrementActivity:t}=(0,d.e)(),n=()=>{window.dispatchEvent(new CustomEvent("extendify-hc:minimize")),e(!0),t("library-button-click")};return(0,r.jsxs)("div",{role:"button",tabIndex:0,onClick:n,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||n()},className:"components-button has-icon is-primary h-8 min-w-0 cursor-pointer px-2 xs:h-9 sm:ml-2 xl:pr-3",children:[(0,r.jsx)(m.A,{icon:s((0,a.__)("Design Library","extendify-local")),size:24}),(0,r.jsx)("span",{className:"ml-1 hidden xl:inline",children:(0,a.__)("Design Library","extendify-local")})]})};var u=n(8971),y=n(1455),x=n.n(y),f=n(6087);const w={"--wp--preset--spacing--30":"clamp(1.5rem, 5vw, 2rem)","--wp--preset--spacing--40":"clamp(1.8rem, 1.8rem + ((1vw - 0.48rem) * 2.885), 3rem)","--wp--preset--spacing--50":"clamp(2.5rem, 8vw, 4rem)","--wp--preset--spacing--60":"clamp(2.5rem, 8vw, 6rem)","--wp--preset--spacing--70":"clamp(3.75rem, 10vw, 7rem)","--wp--preset--spacing--80":"clamp(5rem, 5.25rem + ((1vw - 0.48rem) * 9.096), 8rem)"},g=(e,t=[])=>Array.from(t).some(t=>!!t.style&&Array.from(t.style).some(t=>t?.includes(e)));var h=n(8468);const b=new WeakMap;var v=n(4715),j=n(4997),S=n(6942),_=n.n(S);const k=({insertPattern:e,code:t})=>{const[n,s]=(0,f.useState)(!1),o=(0,f.useRef)(),i=(0,f.useMemo)(()=>(0,j.rawHandler)({HTML:C(t)}),[t]),{ready:l}=(({container:e,onIFrameLoaded:t,ready:n,loadDelay:a})=>{const r=(()=>{const e=(0,f.useRef)(!1);return(0,f.useEffect)(()=>(e.current=!0,()=>{e.current=!1})),e})(),[s,o]=(0,f.useState)(0),[i,l]=(0,f.useState)(null),[d,m]=(0,f.useState)(!1),p=(0,f.useRef)(!1),{addMissingCSSVar:u}=c(),y=(0,f.useCallback)(e=>{if(!e?.contentDocument)return;const t=getComputedStyle(e.contentDocument.documentElement),n=e.contentDocument.styleSheets;for(const a in w)t.getPropertyValue(a)||Array.from(n).filter(e=>{try{return e.cssRules}catch(e){return!1}}).some(e=>g(a,e.cssRules))||(u(a),e.contentDocument.documentElement.style.setProperty(a,w[a]))},[u]),x=(0,f.useCallback)(async(e,t)=>{if(e.getBoundingClientRect().top<t.getBoundingClientRect().top)return;p.current=!0;let n=t.querySelector('[style*="scale"]')?.style?.transform?.match(/scale\((.*?)\)/)?.[1];n=n?parseFloat(n):null;const a=t.offsetHeight/(n??1);e.style.setProperty("max-height",`${a}px`,"important");const r=e.contentDocument.querySelectorAll(".wp-block-cover");for(const e of r)b.has(e)||b.set(e,e.style.minHeight),e.style.minHeight=b.get(e);t.offsetHeight,await new Promise(e=>requestAnimationFrame(e)),await new Promise(e=>requestAnimationFrame(e));for(const t of r){if(!e.contentDocument?.defaultView)return;const n=parseFloat(e.contentDocument.defaultView.getComputedStyle(t).height);t.offsetHeight,t.style.minHeight=n>500?"500px":`${n}px`}e.style.setProperty("max-height","none","important"),p.current=!1},[]);return(0,f.useEffect)(()=>{if(!n)return;const a=setTimeout(()=>{if(i)return;const n=e?.querySelector("iframe[title]");if(!n)return o(e=>e+1);l(n),requestAnimationFrame(()=>t(n,e))},100);return()=>clearTimeout(a)},[i,n,s,e,t]),(0,f.useEffect)(()=>{if(m(!1),!i?.contentDocument)return;const t={attributes:!1,childList:!0,subtree:!0};requestAnimationFrame(()=>n(i,e));const n=(0,h.debounce)(async()=>{r.current&&!p.current&&(s.disconnect(),await x(i,e),"extendable"!==window.extSharedData.themeSlug&&await y(i,e),setTimeout(()=>m(!0),a),r.current&&s.observe(i.contentDocument,t))},300),s=new MutationObserver(n);return s.observe(i.contentDocument,t),()=>{n.cancel(),s?.disconnect()}},[i,e,r,n,x,y,a]),{loading:!i,ready:d}})({container:o.current,ready:n,onIFrameLoaded:()=>{},loadDelay:50});return(0,f.useEffect)(()=>s(!0),[]),(0,r.jsx)("button",{ref:o,type:"button","aria-label":(0,a.__)("Insert Pattern","extendify-local"),className:_()("library-pattern relative z-10 m-0 mb-8 inline-block w-full border bg-transparent p-0 focus:shadow-xs focus:outline-hidden focus:ring-wp focus:ring-design-main focus:ring-offset-2 focus:ring-offset-[#FAFAFA]",{"border-transparent opacity-0":!l,"border-gray-400 opacity-100":l}),onClick:()=>e(i),children:(0,r.jsx)(v.BlockPreview,{blocks:i,live:!1,viewportWidth:1400,additionalStyles:[{css:'.rich-text [data-rich-text-placeholder]:after { content: "" }'}]})})},C=e=>e.replace(/(https?:\/\/\S+\?w=\d+)/gi,"$1&q=10&auto=format,compress&fm=avif");var N=n(8969),P=n(3041);const L=e=>fetch(e).then(e=>e.json());var E=n(6427),D=n(5692),A=n(9594);const I=({insertPattern:e,category:t})=>{const{data:n,isLoading:s,setSize:o}=(e=>{const t={category:void 0,wpVersion:window.extSharedData.wpVersion,lang:window.extSharedData.wpLanguage||null,showLocalizedCopy:window.extSharedData.showLocalizedCopy||null,...e},{data:n,error:a,isLoading:r,isValidating:s,mutate:o,size:i,setSize:l}=(0,P.Ay)((e,n)=>{if(!t.category)return null;if(n&&!n.length)return null;const a=new URLSearchParams({page:e+1});return Object.entries(t).filter(([,e])=>void 0!==e).forEach(([e,t])=>{a.append(e,t)}),`${N.zL}/api/patterns?${a.toString()}`},L,{initialSize:2,revalidateFirstPage:!1,revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1});return{data:n,error:a,isLoading:r,isValidating:s,mutate:o,size:i,setSize:l}})({category:t}),[i,l]=(0,f.useState)(!0),[c,d]=(0,D.Wx)(),m=n?.at(-1)?.length<9;return(0,f.useEffect)(()=>{if(s)return l(!0);const e=setTimeout(()=>{l(!1)},750);return()=>clearTimeout(e)},[s]),(0,f.useEffect)(()=>{d&&!s&&o(e=>e+1)},[d,s,o]),s||!n?.length?(0,r.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-center",children:[(0,r.jsx)(E.Spinner,{}),(0,r.jsx)("span",{className:"sr-only",children:(0,a.__)("Loading Patterns...","extendify-local")})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(A.A,{breakpointCols:{default:3,1600:2,1e3:1,783:2,600:1},columnClassName:"",className:"relative flex w-full gap-6 p-8 pt-2",children:n.map(t=>t.map(({id:t,code:n,patternReplacementCode:a})=>(0,r.jsx)(k,{insertPattern:e,code:a??n},t)))}),i?(0,r.jsxs)("div",{className:"absolute inset-0 z-0 flex flex-col items-center justify-center text-center",children:[(0,r.jsx)(E.Spinner,{}),(0,r.jsx)("span",{className:"sr-only",children:(0,a.__)("Loading Patterns...","extendify-local")})]}):null,i||m?null:(0,r.jsxs)("div",{ref:c,className:"mb-6 mt-6 flex w-full justify-center md:mt-2",children:[(0,r.jsx)(E.Spinner,{}),(0,r.jsx)("span",{className:"sr-only",children:(0,a.__)("Loading more patterns...","extendify-local")})]})]})};var O=n(4225);const F=async()=>{const e=new URLSearchParams({wpVersion:window.extSharedData.wpVersion||null,lang:window.extSharedData.wpLanguage||null});return await fetch(`${N.zL}/api/categories?${e.toString()}`).then(e=>e.json())},R=(0,o.vt)((0,i.Zr)(e=>({categories:[],setCategories:t=>e({categories:t})}),{name:`extendify-library-cache-${window.extSharedData.siteId}`}));var z=n(6528);const B="/extendify/v1/library/settings",$={getItem:async()=>await x()({path:B}),setItem:async(e,t)=>await x()({path:B,method:"POST",data:{state:t}})},T={category:"",totalImports:0},V=(0,z.N)(window.extLibraryData.siteInfo),H=(0,o.vt)((0,i.Zr)(e=>({...T,...V?.state??{},setCategory:t=>e({category:t}),incrementImports:()=>e(e=>({totalImports:Number(e.totalImports)+1}))}),{name:"extendify_library_site_data",storage:(0,i.KU)(()=>$),skipHydration:!0})),q=()=>{const{category:e,setCategory:t}=H(),{data:n,isLoading:s,errorCount:o}=(()=>{const[e,t]=(0,f.useState)(0),n=window.extSharedData?.wpLanguage??"en_US",{data:a,error:r,isLoading:s}=(0,O.A)(`categories-${n}`,F,{onError:()=>t(e=>e+1),onSuccess:()=>t(0)});return{data:a,errorCount:e>1?e:r?1:0,isLoading:s}})(),{categories:i,setCategories:l}=R();return(0,f.useEffect)(()=>{s||o||l(n)},[n,s,l,o]),(0,f.useEffect)(()=>{i?.length&&!e&&t("all")},[e,t,i]),(0,r.jsx)(E.PanelBody,{title:(0,a.__)("Design Type","extendify-local"),className:"ext-type-control p-0 border-0 [&_.components-panel\\_\\_body-title]:-mx-5 [&_.components-panel\\_\\_body-title]:mt-0 [&_.components-panel\\_\\_body-title]:mb-0.5",initialOpen:!0,children:(0,r.jsx)(E.PanelRow,{children:(0,r.jsx)(U,{categories:i,errorCount:o,current:e,setCurrent:t})})})},U=({categories:e,errorCount:t,current:n,setCurrent:s})=>{const o=e=>_()("text-sm w-full text-left rtl:text-right px-3 py-1 mb-0.5 block rounded",{"bg-design-main text-design-text":n===e,"bg-transparent text-gray-900 hover:bg-gray-100":n!==e});return e?.length?(0,r.jsxs)("ul",{className:"m-0 -mt-1.5 max-h-half w-full overflow-y-auto rounded-b border border-gray-300 px-1 py-2",children:[(0,r.jsx)("li",{className:"m-0 p-0",children:(0,r.jsx)("button",{type:"button",id:"extendify-library-category-all",onClick:()=>s("all"),className:o("all"),children:(0,a.__)("All","extendify-local")})}),e.map(({slug:e,id:t,name:n})=>(0,r.jsx)("li",{className:"m-0 p-0",children:(0,r.jsx)("button",{type:"button",id:`extendify-library-category-${e}`,onClick:()=>s(e),className:o(e),children:n})},t))]}):t>1?(0,r.jsxs)("div",{className:"-mt-1 flex w-full flex-col items-center justify-center gap-2 border-t border-gray-300 p-2",children:[(0,r.jsx)("span",{children:(0,a.__)("Retrying...","extendify-local")}),(0,r.jsx)(E.Spinner,{})]}):(0,r.jsxs)("div",{className:"-mt-1 flex w-full justify-center border-t border-gray-300 p-2",children:[(0,r.jsx)("span",{className:"sr-only",children:(0,a.__)("Fetching...","extendify-local")}),(0,r.jsx)(E.Spinner,{})]})},{partnerLogo:M,partnerName:G}=window.extSharedData,K=()=>(0,r.jsxs)("div",{className:"hidden flex-shrink-0 flex-col gap-6 md:flex md:w-80",children:[M?(0,r.jsx)("div",{className:"flex justify-center bg-banner-main p-6 py-0",children:(0,r.jsx)("div",{className:"flex h-20 w-40 items-center justify-center py-3",children:(0,r.jsx)("img",{className:"max-h-full max-w-full",src:M,alt:G})})}):(0,r.jsx)("div",{className:"-mb-5 hidden px-5 py-3 text-extendify-black sm:flex sm:pt-5",children:(0,r.jsx)(m.A,{icon:s(),size:40})}),(0,r.jsx)("div",{className:"flex flex-col gap-4 overflow-y-auto pb-16",children:(0,r.jsx)("div",{id:"extendify-library-category-control","data-test":"category-control",className:"hidden flex-col overflow-x-hidden px-4 md:flex",children:(0,r.jsx)(q,{})})})]}),W=({onClose:e})=>(0,r.jsx)("button",{className:"block h-6 w-6 bg-transparent p-px text-inherit outline-hidden focus:shadow-none focus:ring-wp focus:ring-design-main",type:"button",onClick:e,"data-test":"modal-close-button","aria-label":(0,a.__)("Close","extendify-local"),children:(0,r.jsxs)("svg",{style:{fill:"currentColor"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[(0,r.jsx)("title",{children:(0,a.__)("Close","extendify-local")}),(0,r.jsx)("path",{d:"M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"})]})}),X=({openOnNewPage:e,updateUserOption:t,onClose:n})=>(0,r.jsxs)("div",{className:"mb-2 flex h-16 flex-shrink-0 items-center justify-end gap-6 px-8",children:[(0,r.jsxs)("label",{className:"mt-4 flex items-center gap-2",htmlFor:"extendify-open-on-new-pages",title:(0,a.sprintf)( // translators: %s: Extendify Library term // translators: %s: Extendify Library term (0,a.__)("Toggle %s on new pages","extendify-local"),"Extendify Library"),children:[(0,r.jsx)("input",{id:"extendify-open-on-new-pages",className:"m-0 rounded-xs border border-solid border-gray-900",type:"checkbox",checked:e,onChange:e=>t("openOnNewPage",e.target.checked)}),(0,r.jsx)("span",{children:(0,a.__)("Open for new pages","extendify-local")})]}),(0,r.jsx)("div",{className:"mt-4",children:(0,r.jsx)(W,{onClose:n})})]}),Z={getItem:async()=>await x()({path:"/wp/v2/users/me"}),setItem:async(e,t)=>await x()({path:"/wp/v2/users/me",method:"PUT",data:{extendify_library_user:t}})},J=(0,o.vt)((0,i.Zr)((e,t)=>({openOnNewPage:!0,updateUserOption:(n,a)=>{Object.keys(t()).includes(n)&&e({[n]:a})},...(0,z.N)(window.extLibraryData.userInfo)?.state??{}}),{name:"extendify_library_user",storage:(0,i.KU)(()=>Z),partialize:e=>({...e,ready:!1}),skipHydration:!0}));var Q=n(7143);var Y=n(8845);const ee=window?.location?.pathname?.includes("post-new.php"),te=()=>{const{incrementActivity:e}=(0,d.e)(),{open:t,setOpen:n}=c(),{updateUserOption:s,openOnNewPage:o}=J(),{category:i,incrementImports:l}=H(),{createNotice:m}=(0,Q.dispatch)("core/notices"),p=(0,f.useRef)(!1),y=()=>n(!1);return(0,f.useLayoutEffect)(()=>{if(!t&&!p.current)return p.current=!0,o&&ee?(window.dispatchEvent(new CustomEvent("extendify-hc:minimize")),e("library-auto-open"),void n(!0)):void(new URLSearchParams(window.location.search).has("ext-open")&&(n(!0),e("library-search-param-auto-open")))},[o,n,e,t]),(0,f.useEffect)(()=>{const e=new URLSearchParams(window.location.search);e.has("ext-close")&&(n(!1),e.delete("ext-close"),window.history.replaceState({},"",`${window.location.pathname}?${e.toString()}`))},[n,e]),(0,f.useEffect)(()=>{const e=()=>n(!0),t=()=>n(!1);return window.addEventListener("extendify::open-library",e),window.addEventListener("extendify::close-library",t),()=>{window.removeEventListener("extendify::open-library",e),window.removeEventListener("extendify::close-library",t)}},[n,t]),(0,f.useEffect)(()=>{t&&(0,Q.select)("core/edit-post").isFeatureActive("welcomeGuide")&&(0,Q.dispatch)("core/edit-post").toggleFeature("welcomeGuide")},[t]),t?(0,r.jsx)(u.lG,{className:"extendify-library extendify-library-modal",open:t,static:!0,onClose:()=>{},children:(0,r.jsxs)("div",{className:"absolute mx-auto h-full w-full md:p-8 inset-0",children:[(0,r.jsx)("div",{className:"fixed inset-0 bg-black/30",style:{backdropFilter:"blur(2px)"},"aria-hidden":"true"}),(0,r.jsxs)(Y.P.div,{initial:{y:30,opacity:0},animate:{y:0,opacity:1},exit:{y:0,opacity:0},transition:{duration:.3},className:"relative mx-auto h-full w-full max-w-[1600px] bg-white shadow-2xl sm:flex sm:overflow-hidden",children:[(0,r.jsx)(u.lG.Title,{className:"sr-only",children:(0,a.__)("Design Patterns","extendify-local")}),(0,r.jsx)(K,{}),(0,r.jsxs)("div",{className:"relative flex w-full flex-col bg-[#FAFAFA]",children:[(0,r.jsx)(X,{openOnNewPage:o,updateUserOption:s,onClose:y}),(0,r.jsx)("div",{id:"extendify-library-patterns-list",className:"grow overflow-y-auto",children:(0,r.jsx)(I,{insertPattern:async e=>{await(async e=>{const{insertBlocks:t,replaceBlock:n}=(0,Q.dispatch)("core/block-editor"),{getSelectedBlock:a,getBlockHierarchyRootClientId:r,getBlockIndex:s,getGlobalBlockCount:o,getBlockParents:i,getBlock:l,getBlocks:d}=(0,Q.select)("core/block-editor"),m=(0,Q.select)("core/preferences").get("core","renderingModes")||{},p=(0,Q.select)("core").getCurrentTheme()?.stylesheet,u="template-locked"===m?.[p]?.page,{set:y}=(0,Q.dispatch)("core/preferences"),f=e=>y("core","renderingModes",{...m,[p]:{...m[p]||{},page:e}});let{clientId:g,name:h,attributes:b}=a()||{};if(g&&u){const e=i(g).map(e=>l(e)).filter(Boolean),t=e.findIndex(e=>"core/post-content"===e?.name),n=s(-1!==t&&e[t+1]?.clientId||g);f("post-only"),await new Promise(e=>requestAnimationFrame(e));const a=d()[n];({clientId:g,name:h,attributes:b}=a||{})}const v=g?r(g):"",j=(v?s(v):o())+1,{missingCSSVars:S}=c.getState();S.forEach(e=>{document?.documentElement?.style?.setProperty(e,w[e]),document.querySelector('iframe[name="editor-canvas"]')?.contentDocument?.documentElement?.style?.setProperty(e,w[e])}),S.length&&(async e=>{const t=window.extSharedData.globalStylesPostID,{styles:n,settings:a}=await x()({path:`/wp/v2/global-styles/${t}`});if(!(e=e.filter(e=>!n?.css?.includes(`${e}:`))).length)return;const r=`${e.reduce((e,t)=>e+`${t}: ${w[t]};\n`,":root {\n")}\n}`;x()({path:`/wp/v2/global-styles/${t}`,method:"PATCH",data:{id:t,settings:a,styles:{...n,css:(n?.css??"")+(n?.css?"\n":"")+r}}})})(S);try{return u&&!g&&(f("post-only"),await new Promise(e=>requestAnimationFrame(e))),"core/paragraph"===h&&""===b?.content?.text?await n(g,e):await t(e,j)}finally{u&&f("template-locked")}})(e),l(),y(),m("info",(0,a.__)("Pattern added","extendify-local"),{isDismissible:!0,type:"snackbar"}),await(async()=>await x()({path:"/extendify/v1/library/settings/single",method:"POST",data:{key:"extendify_check_for_image_imports",value:!0}}))()},category:i})})]})]},"library-modal")]})}):null};var ne=n(7828);(0,n(4009).H)().then(()=>{const e="extendify-library-btn",t="extendify-library";if(document.getElementById(e))return;const n=document.createElement("div"),a=Object.assign(n,{id:e,className:t});(0,ne.X)((0,r.jsx)(p,{}),a),setTimeout(()=>{document.querySelector(".editor-document-tools")?.after(a)},300);const s="extendify-library-modal";if(document.getElementById(s))return;const o=document.createElement("div"),i=Object.assign(o,{id:s,className:t});document.body.append(i),(0,ne.X)((0,r.jsx)(te,{}),i)})},1609(e){e.exports=window.React},5795(e){e.exports=window.ReactDOM},790(e){e.exports=window.ReactJSXRuntime},8468(e){e.exports=window.lodash},1455(e){e.exports=window.wp.apiFetch},4715(e){e.exports=window.wp.blockEditor},4997(e){e.exports=window.wp.blocks},6427(e){e.exports=window.wp.components},7143(e){e.exports=window.wp.data},6087(e){e.exports=window.wp.element},7723(e){e.exports=window.wp.i18n}},e=>{e.O(0,[65,223],()=>e(e.s=9952)),e.O()}]);
geri dön