0x1998 - MANAGER
Düzenlenen Dosya: extendify-agent-9d1c6defa5e8b1930355.js
(globalThis.webpackChunkextendify=globalThis.webpackChunkextendify||[]).push([[671],{969(e,t,n){"use strict";var o=n(8459),s=n(1621),r=n(7134);const a={x:window.innerWidth-410-20,y:window.innerHeight-600,width:410,height:600},i=(0,s.vt)()((0,r.Zr)((0,r.lt)(e=>({...a,setSize:(t,n)=>e({width:t,height:n}),setPosition:(t,n)=>e({x:t,y:n}),resetPosition:()=>e({...a,y:window.innerHeight-600})}),{name:"Extendify Agent Position"}),{name:`extendify-agent-position-${window.extSharedData.siteId}`}));var l=n(8443);const c=(0,s.vt)()((0,r.Zr)((0,r.lt)((e,t)=>({retryAfter:void 0,open:!0,minimized:!1,mode:window.extAgentData.agentPosition,queuedTour:null,scratch:{},isMobile:window.innerWidth<768,setIsMobile:n=>{t().isMobile!==n&&e({isMobile:n})},queueTourForRedirect:t=>e({queuedTour:t}),clearQueuedTour:()=>e({queuedTour:null}),setOpen:t=>{t||(i.getState().resetPosition(),window.dispatchEvent(new CustomEvent("extendify-agent:cancel-workflow"))),e({open:t})},setMinimized:n=>{t().minimized!==n&&e({minimized:n})},toggleOpen:()=>e(e=>(e.open||i.getState().resetPosition(),{open:!e.open})),updateRetryAfter:t=>e({retryAfter:t}),isChatAvailable:()=>{const{retryAfter:n}=t();if(!n)return!0;const o=(0,l.isInTheFuture)(new Date(Number(n)));return o||e({retryAfter:void 0}),!o},setScratch:(t,n)=>e(e=>({scratch:{...e.scratch,[t]:n}})),getScratch:e=>t().scratch[e]||null,deleteScratch:t=>e(e=>{const{[t]:n,...o}=e.scratch;return{scratch:o}})}),{name:"Extendify Agent Global"}),{name:`extendify-agent-global-${window.extSharedData.siteId}`,merge:(e,t)=>{const n=!!window.extAgentData?.startOnboarding||(e?.open??t.open);return{...t,...e,open:n}},partialize:e=>{const{mode:t,isMobile:n,...o}=e;return{...o}}}));var d=n(3410),u=n(9333),m=n(8969),p=n(1994);const g=()=>{const{x:e,y:t,width:n,height:o}=c.getState();return{userAgent:window?.navigator?.userAgent,vendor:window?.navigator?.vendor||"unknown",platform:window?.navigator?.userAgentData?.platform||window?.navigator?.platform||"unknown",mobile:window?.navigator?.userAgentData?.mobile,width:window.innerWidth,height:window.innerHeight,screenHeight:window.screen.height,screenWidth:window.screen.width,orientation:window.screen.orientation?.type,touchSupport:"ontouchstart"in window||navigator.maxTouchPoints>0,agentUI:{x:e,y:t,width:n,height:o}}},f=async({tool:e,inputs:t})=>{if(!u.Y[e])throw new Error(`Tool ${e} not found`);return await u.Y[e](t)},h=({error:e,sessionId:t,caller:n,additional:o={}})=>{if(!0===Boolean(p.m?.devbuild))return;const s={message:e.response?.statusText?e.response?.statusText||e.response.message||"Unknown error":"string"==typeof e?e:e?.message||"Unknown error",name:e?.name};return fetch(`${m.AY}/api/agent/digest`,{method:"POST",keepalive:!0,headers:{"Content-Type":"application/json"},body:JSON.stringify({...p.m,phpVersion:window.extSharedData?.phpVersion,sessionId:t,error:s,browser:{userAgent:window.navigator?.userAgent,vendor:window.navigator?.vendor,platform:window.navigator?.platform,width:window.innerWidth,height:window.innerHeight,touchSupport:"ontouchstart"in window||navigator.maxTouchPoints>0},caller:n,...o,extra:g()})}).catch(()=>{})},x=({action:e,sessionId:t,value:n={}})=>fetch(`${m.AY}/api/agent/activities`,{keepalive:!0,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...p.m,action:e,sessionId:t,value:n})});var y=n(6087);const w=e=>{const[t]=(0,y.useState)(()=>{const t=document.getElementById(e);return t||Object.assign(document.createElement("div"),{className:"extendify-agent",id:e})});return(0,y.useEffect)(()=>(document.getElementById("extendify-agent-main").prepend(t),()=>t.remove()),[t]),t};var b=n(1455),v=n.n(b),k=n(7723),j=n(319),_=n(2023),S=n(3832),C=n(8845),L=n(790);const T=["[data-extendify-agent-block-id]","[data-extendify-part-block-id]",".wp-block-navigation"].join(", "),E=["wp-block-video","wp-block-spacer","wp-block-post-*"],N="data-extendify-agent-block-selected",A="extendify-agent-highlighter-mode",P=({busy:e=!1})=>{const[t,n]=(0,y.useState)(null),o=w("extendify-agent-dom-mount"),s=(0,y.useRef)(null),r=(0,y.useRef)(null),{getWorkflowsByFeature:a,block:i,setBlock:l,setBlockCode:c}=(0,d.Y)(),u=a({requires:["block"]})?.length>0,m=(0,y.useCallback)(()=>{l(null),n(null),r.current=null,document.querySelector(A)?.classList.remove(A),document.querySelector(`[${N}]`)?.removeAttribute(N)},[l,n]);if((0,y.useEffect)(()=>{if(!i?.id)return;const e=new AbortController,t=window.extAgentData?.context?.postId;if(!t)return;const n={postId:String(t),blockId:String(i.id)},o={current:!0};return(async()=>{const t=await v()({path:(0,S.addQueryArgs)("extendify/v1/agent/get-block-code",n),signal:e.signal}).catch(()=>({}));t.block&&o.current&&!e.signal.aborted&&c(t.block)})(),()=>{e.abort(),o.current=!1}},[c,i]),(0,y.useEffect)(()=>{const e=()=>{n(null),r.current=null};return window.addEventListener("extendify-agent:remove-block-highlight",e),()=>window.removeEventListener("extendify-agent:remove-block-highlight",e)},[]),(0,y.useEffect)(()=>{if(e||i)return;if(!o||!u)return n(null);const t=e=>{s.current||(s.current=requestAnimationFrame(()=>{s.current=null;const t=e.target;if(!t)return n(null);const o=t.closest(T);if(!o)return n(null);const a=E.map(e=>e.replace("*",".*")).join("|"),i=new RegExp(`^(${a})$`);if(Array.from(o.classList).some(e=>i.test(e)))return n(null);const l=Array.from(o.querySelectorAll(T)).filter(e=>!E.some(t=>e.classList.contains(t))).length;if(l>50)return n(null);r.current=o;const c=o.getBoundingClientRect();if(c.width<=0||c.height<=0)return n(null);const{top:d,left:u,width:m,height:p}=c;n({top:d,left:u,width:m,height:p})}))};return window.addEventListener("mousemove",t,{passive:!0}),()=>{window.removeEventListener("mousemove",t),s.current&&cancelAnimationFrame(s.current)}},[e,o,u,i]),(0,y.useEffect)(()=>{const e=()=>{if(!r.current)return;const{top:e,left:t,width:o,height:s}=r.current.getBoundingClientRect();n({top:e,left:t,width:o,height:s})};return window.addEventListener("scroll",e,{passive:!0}),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e),window.removeEventListener("resize",e)}},[r]),(0,y.useEffect)(()=>{if(!u||e)return;const n=n=>{if(!t||e)return;if(n.target.closest("#extendify-agent-chat"))return;const o=document.elementsFromPoint(n.clientX,n.clientY)||[];if(!o[0])return;n.preventDefault(),n.stopPropagation();const s=o[0].closest(T);if(!s&&!i)return;const r=s?.hasAttribute(N);if(i&&!r)return m();if(i&&r)return;s.setAttribute(N,!0),document.querySelector("#extendify-agent-chat-textarea")?.focus();const a=s.closest("[data-extendify-part]"),c={id:s.getAttribute("data-extendify-agent-block-id"),target:"data-extendify-agent-block-id",hasNav:Boolean(s.querySelector(".wp-block-navigation"))||s.classList.contains("wp-block-navigation"),hasSiteTitle:s.classList.contains("wp-block-site-title")||Boolean(s.querySelector(".wp-block-site-title")),hasSiteLogo:s.classList.contains("wp-block-site-logo")||Boolean(s.querySelector(".wp-block-site-logo")),hasLinks:Boolean(s.querySelector("a"))||"A"===s.tagName,hasImages:Boolean(s.querySelector(".wp-block-image"))||s.classList.contains("wp-block-image")||Boolean(s.querySelector("img")),hasText:/\S/.test((s.textContent||"").replace(/\u200B/g,""))};a&&(c.id=a.getAttribute("data-extendify-part-block-id"),c.target="data-extendify-part-block-id",c.template=a.getAttribute("data-extendify-part")),l(c)};return window.addEventListener("click",n,{capture:!0}),()=>window.removeEventListener("click",n,{capture:!0})},[u,l,t,m,i,e]),(0,y.useEffect)(()=>{if(!r.current)return;const e=new ResizeObserver(()=>{if(!r.current)return;const{top:e,left:t,width:o,height:s}=r.current.getBoundingClientRect();n({top:e,left:t,width:o,height:s})});return e.observe(r.current),()=>{e.disconnect()}},[r.current]),(0,y.useEffect)(()=>{if(!u)return;const e=document.querySelector(".wp-site-blocks");return e?(e.classList.add("extendify-agent-highlighter-mode"),()=>e.classList.remove("extendify-agent-highlighter-mode")):void 0},[u]),(0,y.useEffect)(()=>{if(!e)return;const t=document.querySelector(".wp-site-blocks");return t?(t.classList.add("extendify-agent-busy"),()=>t.classList.remove("extendify-agent-busy")):void 0},[e]),!u||!t||!o)return null;const{top:p,left:g,width:f,height:h}=t,x={x:g,y:p,width:f,height:h,opacity:1};return(0,y.createPortal)((0,L.jsxs)(L.Fragment,{children:[i&&!e?(0,L.jsxs)("div",{role:"button",className:"fixed z-9 h-6 w-6 -translate-y-3.5 cursor-pointer select-none flex items-center justify-center rounded-full text-center font-bold ring-1 ring-black",tabIndex:0,onClick:()=>l(null),onKeyDown:()=>l(null),style:{top:p,left:f/2+g-12,backgroundColor:"var(--wp--preset--color--primary, red)",color:"var(--wp--preset--color--background, white)"},children:[(0,L.jsx)(j.A,{className:"pointer-events-none fill-current leading-none",icon:_.A,size:18}),(0,L.jsx)("span",{className:"sr-only",children:(0,k.__)("Remove highlight","extendify-local")})]}):null,(0,L.jsx)(C.P.div,{initial:!1,"aria-hidden":!0,animate:x,transition:{type:"spring",stiffness:700,damping:40,mass:.25},className:"fixed z-8 mix-blend-hard-light outline-dashed outline-4",style:{top:0,left:0,willChange:"transform,width,height,opacity",outlineColor:"var(--wp--preset--color--primary, red)",pointerEvents:i&&!e?"auto":"none"}})]}),o)};var I=n(6748),R=n(6221);const D=({children:e})=>{const[t,n]=(0,y.useState)(null),o=w("extendify-agent-mount"),{open:s,setOpen:r}=c(),a=(0,y.useCallback)(e=>requestAnimationFrame(()=>n(e)),[]);return(({el:e,open:t,initialPosition:n,onDragEnd:o})=>{const s=(0,y.useRef)({x:0,y:0}),r=(0,y.useRef)(null),a=(0,y.useRef)({x:n.x,y:n.y});(0,y.useLayoutEffect)(()=>{if(!e)return;const t=requestAnimationFrame(()=>{e.style.setProperty("left",`${n.x}px`,"important"),e.style.setProperty("top",`${n.y}px`,"important")});return()=>cancelAnimationFrame(t)},[e,n]),(0,y.useLayoutEffect)(()=>{if(!e||!t)return;const n=window.innerWidth-e.offsetWidth,o=window.innerHeight-e.offsetHeight,s=parseFloat(e.style.left)||0,r=parseFloat(e.style.top)||0,a=(0,I.qE)(s,0,n),i=(0,I.qE)(r,0,o);s===a&&r===i||(e.style.setProperty("left",`${a}px`,"important"),e.style.setProperty("top",`${i}px`,"important"))},[e,t]),(0,y.useLayoutEffect)(()=>{const i=document.getElementById("wpwrap")||document.querySelector(".wp-site-blocks");if(!e||!t||!i)return;const l=e.querySelector("[data-extendify-agent-handle]");if(!(l instanceof HTMLElement))return;e.style.setProperty("left",`${n.x}px`,"important"),e.style.setProperty("top",`${n.y}px`,"important");const c=t=>{t.preventDefault(),t.stopPropagation(),i.style.pointerEvents="none",null===r.current&&(r.current=t.pointerId,l.setPointerCapture(t.pointerId),s.current={x:t.clientX-e.offsetLeft,y:t.clientY-e.offsetTop},document.addEventListener("pointermove",d),document.addEventListener("pointerup",u))},d=t=>{const n=window.innerWidth-l.offsetWidth,o=window.innerHeight-l.offsetHeight,r=(0,I.qE)(t.clientX-s.current.x,0,n),i=(0,I.qE)(t.clientY-s.current.y,0,o);e.style.setProperty("left",`${r}px`,"important"),e.style.setProperty("top",`${i}px`,"important"),a.current={x:r,y:i}},u=e=>{i.style.pointerEvents="auto",r.current===e.pointerId&&(r.current=null,l.releasePointerCapture(e.pointerId),document.removeEventListener("pointermove",d),document.removeEventListener("pointerup",u),o(a.current.x,a.current.y))},m=()=>u(new PointerEvent("pointerup")),p=e=>(e.preventDefault(),e.stopPropagation(),!1);return l.addEventListener("pointerdown",c),l.addEventListener("contextmenu",p),l.addEventListener("blur",m),()=>{l.removeEventListener("pointerdown",c),l.removeEventListener("blur",m),l.removeEventListener("contextmenu",p),document.removeEventListener("pointermove",d),document.removeEventListener("pointerup",u),i.style.pointerEvents="auto",null!==r.current&&(l.releasePointerCapture(r.current),r.current=null)}},[e,t,n.x,n.y,o])})({el:t,open:s,initialPosition:i.getState(),onDragEnd:(e,t)=>{i.getState().setPosition(e,t),window.dispatchEvent(new CustomEvent("extendify-agent:drag-end",{detail:{x:e,y:t}}))}}),(({el:e,open:t,initialSize:n,onResizeEnd:o,minWidth:s=250,minHeight:r=400,maxWidth:a=500,maxHeight:i=window.innerHeight})=>{const l=(0,y.useRef)({x:0,y:0,width:0,height:0}),c=(0,y.useRef)(null);(0,y.useLayoutEffect)(()=>{const d=document.getElementById("wpwrap")||document.querySelector(".wp-site-blocks");if(!e||!t||!d)return;e.style.width=`${n.width}px`,e.style.height=`${n.height}px`;const u=e.querySelector("[data-extendify-agent-resize]");if(!(u instanceof HTMLElement))return;const m=t=>{t.preventDefault(),t.stopPropagation(),d.style.pointerEvents="none",null===c.current&&(c.current=t.pointerId,u.setPointerCapture(t.pointerId),l.current={x:t.clientX,y:t.clientY,width:e.offsetWidth,height:e.offsetHeight},document.addEventListener("pointermove",p),document.addEventListener("pointerup",g))},p=t=>{const n=e.getBoundingClientRect(),o=Math.min(a,window.innerWidth-n.left),c=Math.min(i,window.innerHeight-n.top),d=(0,I.qE)(l.current.width+(t.clientX-l.current.x),s,o),u=(0,I.qE)(l.current.height+(t.clientY-l.current.y),r,c);e.style.width=`${d}px`,e.style.height=`${u}px`},g=t=>{if(d.style.pointerEvents="auto",c.current!==t.pointerId)return;c.current=null,u.releasePointerCapture(t.pointerId),document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",g);const n=e.getBoundingClientRect(),m=Math.min(a,window.innerWidth-n.left),f=Math.min(i,window.innerHeight-n.top),h=(0,I.qE)(l.current.width+(t.clientX-l.current.x),s,m),x=(0,I.qE)(l.current.height+(t.clientY-l.current.y),r,f);o(h,x)};return u.addEventListener("pointerdown",m),()=>{u.removeEventListener("pointerdown",m),document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",g),d.style.pointerEvents="auto",null!==c.current&&(u.releasePointerCapture(c.current),c.current=null)}},[e,t,n.width,n.height,o,s,r,a,i])})({el:t,open:s,initialSize:i.getState(),onResizeEnd:(e,t)=>{i.setState({width:e,height:t}),window.dispatchEvent(new CustomEvent("extendify-agent:resize-end",{detail:{width:e,height:t}}))}}),(0,y.useEffect)(()=>{if(!t||!s)return;const e=new IntersectionObserver(e=>{e[0].isIntersecting||r(!1)});return e.observe(t),()=>e.disconnect()},[t,s,r]),o&&s?(0,y.createPortal)((0,L.jsx)(R.N,{children:(0,L.jsxs)(C.P.div,{id:"extendify-agent-popout-modal",initial:{opacity:0},animate:{opacity:1},exit:{y:0,opacity:0},transition:{duration:.4,delay:.1},className:"fixed bottom-0 right-0 z-higher flex max-h-full max-w-full flex-col rounded-lg border border-solid border-gray-300 bg-white shadow-2xl-flipped rtl:left-0 rtl:right-auto",ref:a,children:[(0,L.jsxs)("div",{className:"group flex shrink-0 items-center justify-between overflow-hidden rounded-t-[calc(0.5rem-1px)] bg-banner-main text-banner-text",children:[(0,L.jsxs)("div",{"data-extendify-agent-handle":!0,draggable:!0,className:"flex h-full grow cursor-grab active:cursor-grabbing select-none items-center justify-between gap-1 p-0 py-3",children:[(0,L.jsx)("div",{className:"flex h-5 px-4 max-w-36 overflow-hidden",children:(0,L.jsx)("img",{className:"max-h-full max-w-full object-contain",src:window.extSharedData.partnerLogo,alt:window.extSharedData.partnerName})}),(0,L.jsx)("div",{className:"opacity-0 transition-opacity duration-300 group-hover:opacity-100",children:(0,L.jsx)($,{})})]}),(0,L.jsxs)("button",{type:"button",className:"relative z-10 flex h-full items-center rounded-none border-0 bg-banner-main py-3 pe-4 ps-2 text-banner-text outline-hidden ring-design-main focus:shadow-none focus:outline-hidden focus-visible:outline-design-main",onClick:()=>{r(!1),window.dispatchEvent(new CustomEvent("extendify-agent:closed-button"))},children:[(0,L.jsx)(j.A,{className:"pointer-events-none fill-current leading-none",icon:_.A,size:18}),(0,L.jsx)("span",{className:"sr-only",children:(0,k.__)("Close window","extendify-local")})]})]}),e,(0,L.jsx)("div",{"data-extendify-agent-resize":!0,className:"absolute -bottom-2 -right-2 z-high h-6 w-6 group",children:(0,L.jsx)("div",{className:"h-6 w-6 cursor-se-resize group-active:cursor-nwse-resize"})})]},"agent-popout-modal")}),o):null},$=e=>(0,L.jsxs)("div",{style:{userSelect:"none"},className:"relative flex",...e,children:[(0,L.jsx)(j.A,{className:"pointer-events-none text-banner-text",icon:(0,L.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24",className:"pointer-events-none","aria-hidden":"true",focusable:"false",children:(0,L.jsx)("path",{fill:"currentColor",d:"M8 7h2V5H8v2zm0 6h2v-2H8v2zm0 6h2v-2H8v2zm6-14v2h2V5h-2zm0 8h2v-2h-2v2zm0 6h2v-2h-2v2z"})}),size:24}),(0,L.jsx)("span",{className:"sr-only",children:(0,k.__)("Drag to move","extendify-local")})]});var M=n(9383);const q=({children:e})=>{const t=w("extendify-agent-mount"),{minimized:n,setMinimized:o}=c();return(0,y.useEffect)(()=>{if(t&&!n)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[t,n]),t?(0,y.createPortal)((0,L.jsxs)("div",{className:"fixed inset-0 z-max-1 items-center justify-center "+(n?"hidden":"flex"),"aria-hidden":n?"true":"false",children:[(0,L.jsx)("div",{className:"pointer-events-none absolute inset-0 bg-black/70"}),(0,L.jsx)(R.N,{children:(0,L.jsxs)(C.P.div,{id:"extendify-agent-popout-modal",initial:{opacity:0},animate:{opacity:1},exit:{y:0,opacity:0},transition:{duration:.4,delay:.1},className:"fixed bottom-[2vh] z-high flex h-full max-h-[80vh] w-full max-w-[90vw] flex-col rounded-lg border border-solid border-gray-600 bg-white shadow-2xl-flipped rtl:left-0 rtl:right-auto",children:[(0,L.jsxs)("div",{className:"group flex shrink-0 items-center justify-between overflow-hidden rounded-t-[calc(0.5rem-1px)] bg-banner-main text-banner-text",children:[(0,L.jsx)("div",{className:"flex h-full grow items-center justify-between gap-1 p-0 py-3",children:(0,L.jsx)("div",{className:"flex h-5 px-4 max-w-36 overflow-hidden",children:(0,L.jsx)("img",{className:"max-h-full max-w-full object-contain",src:window.extSharedData.partnerLogo,alt:window.extSharedData.partnerName})})}),(0,L.jsxs)("button",{type:"button",className:"relative z-10 flex h-full items-center rounded-none border-0 bg-banner-main py-3 pe-4 ps-2 text-banner-text outline-hidden ring-design-main focus:shadow-none focus:outline-hidden focus-visible:outline-design-main",onClick:()=>o(!0),children:[(0,L.jsx)(j.A,{className:"pointer-events-none fill-current leading-none",icon:M.A,size:24}),(0,L.jsx)("span",{className:"sr-only",children:(0,k.__)("Minimize window","extendify-local")})]})]}),e]},"agent-popout-modal")})]}),t):null};var B=n(8757),F=n(2868),O=n(1987),H=n(1916),z=n(284),W=n(781);const U=()=>{const e=w("extendify-agent-border-frame-mount"),t=(0,y.useRef)(null),n=(0,y.useRef)(null),[o,s]=(0,y.useState)(null);return(0,y.useEffect)(()=>{o&&n.current&&n.current.focus()},[o]),(0,y.useEffect)(()=>{const n=n=>{t.current.contains(n.target)||e?.contains(n.target)||s(null)};return window.addEventListener("click",n),()=>window.removeEventListener("click",n)},[e]),e?(0,L.jsxs)(L.Fragment,{children:[(0,y.createPortal)(o?(0,L.jsx)(R.N,{children:(0,L.jsx)(Y,{position:o,onClose:()=>{s(null),t.current?.focus()},firstItemRef:n})}):null,e),(0,L.jsxs)("button",{ref:t,type:"button",className:"relative z-10 flex justify-center h-6 w-6 items-center border-0 bg-banner-main text-banner-text outline-hidden ring-design-main focus:shadow-none focus:outline-hidden focus-visible:outline-design-main focus:ring-2 hover:opacity-80 rounded-sm",onClick:()=>{if(o)return s(null);const e=t.current.getBoundingClientRect();s({top:e.bottom+4,right:window.innerWidth-e.right,left:e.left})},"aria-expanded":o?"true":"false","aria-haspopup":"true",children:[(0,L.jsx)(j.A,{className:"pointer-events-none fill-current leading-none",icon:W.A,size:18}),(0,L.jsx)("span",{className:"sr-only",children:(0,k.__)("View more options","extendify-local")})]})]}):null},V=[{name:H.default.example.text,available:H.default.available,icon:H.default.icon},{name:z.default.example.text,available:z.default.available,icon:z.default.icon},{name:O.default.example.text,available:O.default.available,icon:O.default.icon},{name:B.default.example.text,available:B.default.available,icon:B.default.icon},...(0,I.U$)()?[{name:F.default.example.text,available:F.default.available,onSelect:F.default.onSelect,icon:F.default.icon}]:[]],Y=({position:e,onClose:t,firstItemRef:n})=>((0,y.useEffect)(()=>{const e=e=>{"Escape"===e.key&&(e.preventDefault(),t())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t]),(0,L.jsx)(C.P.div,{className:"fixed w-fit whitespace-nowrap rounded-md bg-white shadow-xl py-2 z-max flex flex-col items-start justify-center gap-1 focus:outline-none border border-gray-300",style:{top:e.top,...(0,k.isRTL)()?{left:e.left}:{right:e.right}},initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.2},onKeyDown:e=>{if(e.stopPropagation(),e.preventDefault(),"Escape"===e.key)return t();const o=document.activeElement;return"ArrowDown"===e.key||"Tab"===e.key&&!e.shiftKey?o.nextSibling?o.nextSibling.focus():n.current.focus():"ArrowUp"===e.key||"Tab"===e.key&&e.shiftKey?o.previousSibling?o.previousSibling.focus():o.parentNode.lastChild.focus():"Enter"===e.key?o.click():void 0},children:V.filter(({available:e})=>e()).map(({name:e,icon:o},s)=>(0,L.jsxs)("button",{type:"button",className:"w-full inline-flex gap-0.5 items-center px-4 py-2 text-sm text-gray-900 text-left hover:bg-gray-100 focus:ring-2 focus:ring-design-main focus:outline-none capitalize",ref:0===s?n:null,role:"menuitem",onClick:()=>{window.dispatchEvent(new CustomEvent("extendify-agent:chat-submit",{detail:{message:e}})),t()},children:[o?(0,L.jsx)(j.A,{icon:o}):null,e]},e))})),Z=384,G=({children:e})=>{const t=w("extendify-agent-sidebar-mount"),n=w("extendify-agent-border-frame-mount"),{open:o,setOpen:s}=c();if(X(o),(0,y.useEffect)(()=>{o||t?.contains(document.activeElement)&&document.activeElement?.blur()},[o]),!t)return null;const r={open:{top:8,right:8,bottom:8,left:Z,boxShadow:"#e0e0e0 0px 0px 0px 9999px",borderRadius:"1rem"},closed:{inset:0,boxShadow:"0 0 0 0 #fff",borderRadius:0}},a=n?(0,y.createPortal)((0,L.jsxs)("div",{className:"fixed inset-0 pointer-events-none z-high",children:[(0,L.jsx)(C.P.div,{className:"absolute overflow-hidden",initial:!1,animate:o?"open":"closed",variants:r,transition:{duration:.3,ease:"easeInOut"}}),(0,L.jsx)(C.P.div,{className:"absolute rounded-2xl shadow-xl",style:{top:8,right:8,bottom:8,left:Z},initial:!1,animate:{opacity:o?1:0},transition:{duration:.15,delay:o?.3:0}})]}),n):null,i=t?(0,y.createPortal)((0,L.jsx)(C.P.div,{style:{width:Z},className:" fixed top-0 bottom-0 left-0 w-96 flex-col z-higher border-transparent border-8",id:"extendify-agent-sidebar",initial:!1,inert:o?void 0:"",animate:{x:o?0:-384},transition:{duration:.3,ease:"easeInOut"},children:(0,L.jsxs)("div",{className:"h-full flex flex-col shadow-lg rounded-2xl overflow-hidden bg-white",children:[(0,L.jsxs)("div",{className:"group flex shrink-0 items-center justify-between overflow-hidden bg-banner-main text-banner-text",children:[(0,L.jsx)("div",{className:"flex h-full grow items-center justify-between gap-1 p-0 py-2.5",children:(0,L.jsx)("div",{className:"flex h-5 px-4 max-w-36 overflow-hidden",children:(0,L.jsx)("img",{className:"max-h-full max-w-full object-contain",src:window.extSharedData.partnerLogo,alt:window.extSharedData.partnerName})})}),(0,L.jsxs)("div",{className:"flex gap-1 h-full items-center p-2",children:[(0,L.jsx)(U,{}),(0,L.jsxs)("button",{type:"button",className:"relative z-10 flex justify-center h-6 w-6 items-center border-0 bg-banner-main text-banner-text outline-hidden ring-design-main focus:shadow-none focus:outline-hidden focus-visible:outline-design-main focus:ring-2 hover:opacity-80 rounded-sm",onClick:()=>{s(!1),window.dispatchEvent(new CustomEvent("extendify-agent:closed-button"))},children:[(0,L.jsx)(j.A,{className:"pointer-events-none fill-current leading-none",icon:_.A,size:18}),(0,L.jsx)("span",{className:"sr-only",children:(0,k.__)("Close window","extendify-local")})]})]})]}),o?e:null]})}),t):null;return(0,L.jsxs)(L.Fragment,{children:[a,i]})},X=e=>{const t=e=>e.map(e=>`${e} 300ms ease-in-out`).join(", "),n=(0,y.useRef)(!0);(0,y.useEffect)(()=>{const o=document.querySelector(".wp-site-blocks"),s=document.querySelector("#wpadminbar"),r=()=>{if(o)if(e){const e=window.innerWidth,t=(e-Z)/e;Object.assign(o.style,{transformOrigin:"top left",transform:`translateX(384px) scale(${t})`,height:"100vh"}),document.body.style.overflowX="hidden"}else Object.assign(o.style,{transformOrigin:"top left",transform:"translateX(0) scale(1)",height:""}),document.body.style.overflowX=""};n.current?n.current=!1:(o&&(o.style.transition=t(["transform"])),s&&(s.style.transition=t(["margin-left","margin-top","margin-right","border-radius","max-width"])));const a=requestAnimationFrame(()=>{const t=e?"8px":"0px",n=e?"384px":"0px";r(),s&&Object.assign(s.style,{marginTop:t,marginRight:t,marginBottom:"0px",marginLeft:n,borderRadius:e?"8px 8px 0 0":"0",maxWidth:e?"calc(100% - 392px)":"100%"})});return window.addEventListener("resize",r),()=>{cancelAnimationFrame(a),window.removeEventListener("resize",r),document.body.style.overflowX="",o&&Object.assign(o.style,{transition:"",transform:"",transformOrigin:"",height:""}),s&&Object.assign(s.style,{transition:"",marginTop:"",marginRight:"",marginBottom:"",marginLeft:"",borderRadius:"",maxWidth:""})}},[e])},K=({busy:e,children:t})=>{const{setIsMobile:n,isMobile:o,mode:s}=c(),{domToolEnabled:r,block:a,setBlock:i,setDomToolEnabled:l}=(0,d.Y)();return(0,y.useEffect)(()=>{o&&a&&i(null)},[o,n,a,i]),(0,y.useEffect)(()=>{let e;const t=()=>{clearTimeout(e),e=window.setTimeout(()=>{n(window.innerWidth<783)},10)};return window.addEventListener("resize",t),()=>{clearTimeout(e),window.removeEventListener("resize",t)}},[n]),(0,y.useEffect)(()=>{const e=e=>{if("Escape"===e.key&&r){if(window.dispatchEvent(new CustomEvent("extendify-agent:cancel-workflow")),a)return i(null);l(!1)}};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},[r,a,i,l]),o?(0,L.jsx)(q,{children:(0,L.jsx)("div",{id:"extendify-agent-chat",className:"flex min-h-0 flex-1 grow flex-col font-sans",children:t})}):"docked-left"===s?(0,L.jsxs)(G,{children:[(0,L.jsx)("div",{id:"extendify-agent-chat",className:"flex min-h-0 flex-1 grow flex-col font-sans",children:t}),r&&(0,L.jsx)(P,{busy:e})]}):(0,L.jsxs)(D,{children:[(0,L.jsx)("div",{id:"extendify-agent-chat",className:"flex min-h-0 flex-1 grow flex-col font-sans",children:t}),r&&(0,L.jsx)(P,{busy:e})]})},Q=(0,L.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,L.jsx)("title",{children:(0,k.__)("Magic Icon","extendify-local")}),(0,L.jsx)("path",{d:"M17.0909 9.81818L18 7.81818L20 6.90909L18 6L17.0909 4L16.1818 6L14.1818 6.90909L16.1818 7.81818L17.0909 9.81818Z",fill:"currentColor"}),(0,L.jsx)("path",{d:"M17.0909 14.1818L16.1818 16.1818L14.1818 17.0909L16.1818 18L17.0909 20L18 18L20 17.0909L18 16.1818L17.0909 14.1818Z",fill:"currentColor"}),(0,L.jsx)("path",{d:"M11.6364 10.1818L9.81818 6.18182L8 10.1818L4 12L8 13.8182L9.81818 17.8182L11.6364 13.8182L15.6364 12L11.6364 10.1818ZM10.5382 12.72L9.81818 14.3055L9.09818 12.72L7.51273 12L9.09818 11.28L9.81818 9.69455L10.5382 11.28L12.1236 12L10.5382 12.72Z",fill:"currentColor"})]}),J=(0,L.jsxs)(C.P.svg,{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",overflow:"visible",xmlns:"http://www.w3.org/2000/svg",initial:"hidden",animate:"visible",children:[(0,L.jsx)("title",{children:(0,k.__)("Magic Sparkle Animation","extendify-local")}),(0,L.jsx)(C.P.path,{d:"M17.0909 9.81818L18 7.81818L20 6.90909L18 6L17.0909 4L16.1818 6L14.1818 6.90909L16.1818 7.81818L17.0909 9.81818Z",fill:"currentColor",variants:{hidden:{scale:1,opacity:.8},visible:{scale:[1,1.05,1],opacity:[1,.7,1],transition:{repeat:3,duration:1.2,delay:.2}}}}),(0,L.jsx)(C.P.path,{d:"M17.0909 14.1818L16.1818 16.1818L14.1818 17.0909L16.1818 18L17.0909 20L18 18L20 17.0909L18 16.1818L17.0909 14.1818Z",fill:"currentColor",variants:{hidden:{scale:1,opacity:.8},visible:{scale:[1,1.05,1],opacity:[1,.7,1],transition:{repeat:3,duration:1.2,delay:.6}}}}),(0,L.jsx)(C.P.path,{d:"M11.6364 10.1818L9.81818 6.18182L8 10.1818L4 12L8 13.8182L9.81818 17.8182L11.6364 13.8182L15.6364 12L11.6364 10.1818ZM10.5382 12.72L9.81818 14.3055L9.09818 12.72L7.51273 12L9.09818 11.28L9.81818 9.69455L10.5382 11.28L12.1236 12L10.5382 12.72Z",fill:"currentColor",variants:{hidden:{scale:1,opacity:.9},visible:{scale:[1,1.03,1],opacity:[1,.8,1],transition:{repeat:3,duration:1.2,delay:.4}}}}),(0,L.jsx)(C.P.circle,{cx:"6",cy:"6",r:"1.7",fill:"currentColor",initial:{opacity:0,scale:.5},animate:{opacity:[0,1,0],scale:[.5,1,.5]},transition:{repeat:2,duration:2,delay:1.7}}),(0,L.jsx)(C.P.circle,{cx:"20",cy:"4",r:"1",fill:"currentColor",initial:{opacity:0,scale:.5},animate:{opacity:[0,1,0],scale:[.5,1,.5]},transition:{repeat:3,duration:1.4,delay:.8}}),(0,L.jsx)(C.P.circle,{cx:"4",cy:"20",r:"0.7",fill:"currentColor",initial:{opacity:0,scale:.5},animate:{opacity:[0,1,0],scale:[.5,1,.5]},transition:{repeat:3,duration:1.2,delay:1.4}})]}),ee=(0,L.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:[(0,L.jsx)("title",{children:(0,k.__)("Thumb Down Icon","extendify-local")}),(0,L.jsx)("path",{d:"M14.1818 5H7.63636C7.03273 5 6.51636 5.36364 6.29818 5.88727L4.10182 11.0145C4.03636 11.1818 4 11.3564 4 11.5455V13C4 13.8 4.65455 14.4545 5.45455 14.4545H10.0436L9.35273 17.7782L9.33091 18.0109C9.33091 18.3091 9.45455 18.5855 9.65091 18.7818L10.4218 19.5455L15.2145 14.7527C15.4764 14.4909 15.6364 14.1273 15.6364 13.7273V6.45455C15.6364 5.65455 14.9818 5 14.1818 5ZM14.1818 13.7273L11.0255 16.8836L12 13H5.45455V11.5455L7.63636 6.45455H14.1818V13.7273ZM17.0909 5H20V13.7273H17.0909V5Z"})]}),te=(0,L.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:[(0,L.jsx)("title",{children:(0,k.__)("Thumb Up Icon","extendify-local")}),(0,L.jsx)("path",{d:"M9.81818 19.5455H16.3636C16.9673 19.5455 17.4836 19.1818 17.7018 18.6582L19.8982 13.5309C19.9636 13.3636 20 13.1891 20 13V11.5455C20 10.7455 19.3455 10.0909 18.5455 10.0909H13.9564L14.6473 6.76727L14.6691 6.53455C14.6691 6.23636 14.5455 5.96 14.3491 5.76364L13.5782 5L8.78545 9.79273C8.52364 10.0545 8.36364 10.4182 8.36364 10.8182V18.0909C8.36364 18.8909 9.01818 19.5455 9.81818 19.5455ZM9.81818 10.8182L12.9745 7.66182L12 11.5455H18.5455V13L16.3636 18.0909H9.81818V10.8182ZM4 10.8182H6.90909V19.5455H4V10.8182Z"})]}),ne=(0,L.jsxs)("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:[(0,L.jsx)("title",{children:(0,k.__)("Sparkle Icon","extendify-local")}),(0,L.jsx)("path",{d:"M16.4545 10.0909L17.25 8.34091L19 7.54545L17.25 6.75L16.4545 5L15.6591 6.75L13.9091 7.54545L15.6591 8.34091L16.4545 10.0909Z"}),(0,L.jsx)("path",{d:"M16.4545 13.9091L15.6591 15.6591L13.9091 16.4545L15.6591 17.25L16.4545 19L17.25 17.25L19 16.4545L17.25 15.6591L16.4545 13.9091Z"}),(0,L.jsx)("path",{d:"M11.6818 10.4091L10.0909 6.90909L8.5 10.4091L5 12L8.5 13.5909L10.0909 17.0909L11.6818 13.5909L15.1818 12L11.6818 10.4091ZM10.7209 12.63L10.0909 14.0173L9.46091 12.63L8.07364 12L9.46091 11.37L10.0909 9.98273L10.7209 11.37L12.1082 12L10.7209 12.63Z"})]}),oe=(0,L.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,L.jsx)("title",{children:(0,k.__)("Tool Select Icon","extendify-local")}),(0,L.jsx)("path",{d:"M5 9V6C5 5.44772 5.44772 5 6 5H9",stroke:"currentColor",strokeWidth:"1.5"}),(0,L.jsx)("path",{d:"M17.9799 16.1255C17.9 16.1483 17.8203 16.1708 17.742 16.1958C17.3245 16.3292 16.8439 16.5227 16.4734 16.8175C16.1305 17.0903 15.8256 17.4777 15.5793 17.8342C15.5307 17.9046 15.4826 17.9763 15.4353 18.0489L14.3938 13.9163L17.9799 16.1255Z",stroke:"currentColor",strokeWidth:"2"}),(0,L.jsx)("path",{d:"M15 5L18 5C18.5523 5 19 5.44772 19 6L19 9",stroke:"currentColor",strokeWidth:"1.5"}),(0,L.jsx)("path",{d:"M9 19L6 19C5.44772 19 5 18.5523 5 18L5 15",stroke:"currentColor",strokeWidth:"1.5"})]}),se=(0,L.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,L.jsx)("title",{children:(0,k.__)("Selected Content Icon","extendify-local")}),(0,L.jsx)("path",{d:"M5 9V6C5 5.44772 5.44772 5 6 5H9",stroke:"currentColor",strokeWidth:"1.5"}),(0,L.jsx)("path",{d:"M19 15L19 18C19 18.5523 18.5523 19 18 19L15 19",stroke:"currentColor",strokeWidth:"1.5"}),(0,L.jsx)("path",{d:"M15 5L18 5C18.5523 5 19 5.44772 19 6L19 9",stroke:"currentColor",strokeWidth:"1.5"}),(0,L.jsx)("path",{d:"M9 19L6 19C5.44772 19 5 18.5523 5 18L5 15",stroke:"currentColor",strokeWidth:"1.5"}),(0,L.jsx)("path",{d:"M15 9H9V10.0588H15V9ZM9 11.4706H15V12.5294H9V11.4706ZM15 13.9412H9V15H15V13.9412Z",fill:"currentColor"})]}),re=(0,L.jsxs)("svg",{height:"14",viewBox:"0 0 16 16",width:"14",style:{color:"currentcolor"},children:[(0,L.jsx)("title",{children:(0,k.__)("Cancel","extendify-local")}),(0,L.jsx)("path",{clipRule:"evenodd",d:"M3 3H13V13H3V3Z",fill:"currentColor",fillRule:"evenodd"})]});var ae=n(1037),ie=n(6942),le=n.n(ie);const ce=({disabled:e=!1})=>{const{getWorkflowsByFeature:t,domToolEnabled:n,setDomToolEnabled:o}=(0,d.Y)();return t({requires:["block"]})?.length>0?(0,L.jsx)("div",{className:"flex items-center",children:(0,L.jsxs)("button",{type:"button",disabled:e,className:le()("m-0 flex items-center rounded-sm border-0 px-1 py-0.5 leading-none disabled:opacity-50 text-gray-900",{"bg-gray-300":n,"bg-gray-100 text-gray-900":!n,"hover:bg-gray-200":!e}),onClick:()=>{window.dispatchEvent(new CustomEvent("extendify-agent:cancel-workflow")),o(!n)},children:[(0,L.jsx)(j.A,{size:24,icon:oe}),(0,L.jsx)("span",{className:"px-1 text-sm font-medium",children:(0,k.__)("Select","extendify-local")}),n&&(0,L.jsx)(j.A,{size:20,icon:ae.A,className:"fill-current"})]})}):null};var de=n(4794);const ue=({disabled:e,handleSubmit:t})=>{const n=(0,y.useRef)(null),[o,s]=(0,y.useState)(""),[r,a]=(0,y.useState)([]),i=(0,y.useRef)(!1),[l,u]=(0,y.useState)(null),{getWorkflowsByFeature:m,block:p}=(0,d.Y)(),{isMobile:g}=c(),f=m({requires:["block"]})?.length>0&&!g,h=o.trim().length>1500,x=(0,y.useCallback)(()=>{if(!n.current)return;n.current.style.height="auto";const e=.55*n.current.closest("#extendify-agent-chat").offsetHeight,t=Math.min(e,n.current.scrollHeight);n.current.style.height=`${p&&t<60?60:t}px`},[p]);(0,y.useLayoutEffect)(()=>(window.addEventListener("extendify-agent:resize-end",x),x(),()=>window.removeEventListener("extendify-agent:resize-end",x)),[x]),(0,y.useEffect)(()=>{const e=({detail:e})=>{a(t=>t?.at(-1)===e.message?t:[...t,e.message]),u(null)};return window.addEventListener("extendify-agent:chat-submit",e),()=>window.removeEventListener("extendify-agent:chat-submit",e)},[]),(0,y.useEffect)(()=>{x()},[o,x]),(0,y.useEffect)(()=>{const e=Array.from(document.querySelectorAll('#extendify-agent-chat-scroll-area > [data-agent-message-role="user"]'))?.map(e=>e.textContent||""),t=e.filter((e,t,n)=>0===t||e!==n[t-1]);a(t)},[]);const w=(0,y.useCallback)(e=>{e?.preventDefault(),o.trim()&&!h&&(t(o.trim()),a(e=>e?.at(-1)===o?e:[...e,o]),u(null),s(""),requestAnimationFrame(()=>{i.current=!1,x(),n.current?.focus()}))},[o,t,x,h]),b=(0,y.useCallback)(e=>{if("Enter"===e.key&&!e.shiftKey&&!e.nativeEvent.isComposing)return e.preventDefault(),void(h||w());if(!i.current){if("ArrowUp"===e.key){if(!r.length)return;if(e.shiftKey||e.ctrlKey||e.altKey||e.metaKey)return;return u(e=>{const t=null===e?r.length-1:Math.max(e-1,0);return s(r[t]),t}),void e.preventDefault()}if("ArrowDown"===e.key){if(null===l)return;if(e.shiftKey||e.ctrlKey||e.altKey||e.metaKey)return;return u(e=>{if(null===e)return null;const t=e+1;return t>=r.length?(s(""),null):(s(r[t]),t)}),void e.preventDefault()}i.current=!0}},[r,l,w,h]),v=(0,y.useCallback)(e=>{e.stopPropagation(),window.dispatchEvent(new CustomEvent("extendify-agent:cancel-workflow"))},[]);return(0,L.jsxs)("form",{onSubmit:w,onClick:()=>n.current?.focus(),className:le()("relative flex w-full flex-col rounded-sm border border-gray-300 focus-within:outline-design-main focus:rounded-sm focus:border-design-main focus:ring-design-main",{"bg-gray-300":e,"bg-gray-50":!e}),children:[(0,L.jsx)("textarea",{ref:n,id:"extendify-agent-chat-textarea",disabled:e,className:le()("flex max-h-[calc(75dvh)] min-h-16 w-full resize-none overflow-y-auto bg-transparent px-2 pb-4 pt-2.5 text-base placeholder:text-gray-700 focus:shadow-none focus:outline-hidden disabled:opacity-50 md:text-sm border-none text-gray-900"),placeholder:p?(0,k.__)("What do you want to change in the selected content?","extendify-local"):(0,k.__)("Ask anything","extendify-local"),rows:"1",autoFocus:!0,value:o,onChange:e=>{s(e.target.value),u(null),x()},onKeyDown:b}),(0,L.jsxs)("div",{className:"flex justify-between gap-4 px-2 pb-2",children:[f?(0,L.jsx)(ce,{disabled:e}):null,(0,L.jsxs)("div",{className:"ms-auto flex items-center gap-2",children:[(0,L.jsx)("span",{className:le()("text-xs font-medium",h?"text-red-600":"invisible"),role:"alert",children:h&&(0,k.__)("Message too long","extendify-local")}),(0,L.jsx)(me,{disabled:e,noInput:0===o.trim().length,overLimit:h,handleCancel:v})]})]})]})},me=({disabled:e,noInput:t,overLimit:n,handleCancel:o})=>e?(0,L.jsxs)("button",{type:"button",onClick:o,className:"inline-flex h-fit items-center justify-center gap-2 whitespace-nowrap rounded-full border-0 bg-design-main p-1 text-sm font-medium text-white transition-colors focus-visible:ring-design-main disabled:opacity-20",children:[(0,L.jsx)(j.A,{fill:"currentColor",icon:re,size:18}),(0,L.jsx)("span",{className:"sr-only",children:(0,k.__)("Cancel","extendify-local")})]}):(0,L.jsxs)("button",{type:"submit",className:"inline-flex h-fit items-center justify-center gap-2 whitespace-nowrap rounded-full border-0 bg-design-main p-0.5 text-sm font-medium text-white transition-colors focus-visible:ring-design-main disabled:opacity-20",disabled:e||t||n,children:[(0,L.jsx)(j.A,{fill:"currentColor",icon:de.A,size:24}),(0,L.jsx)("span",{className:"sr-only",children:(0,k.__)("Send message","extendify-local")})]});var pe=n(2344);const ge=window.extSharedData?.homeUrl,fe={a:({href:e,children:t})=>{const n=(e=>{try{const t=new URL(ge),n=new URL(e);return t.hostname!==n.hostname}catch{return!1}})(e);return(0,L.jsxs)("a",{href:e,...n&&{target:"_blank",rel:"noopener noreferrer"},children:[t,n&&(0,L.jsx)(j.A,{icon:pe.A,size:18,className:"ml-0.5 inline"})]})}};var he=n(8334);const xe=({words:e,delay:t=.4,duration:n=.25})=>{const o=e.every(e=>1===e.length);return(0,L.jsx)(R.N,{children:e.map((e,s)=>(0,L.jsx)(C.P.span,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0},transition:{duration:n,delay:s*t},children:o?e:(0,L.jsx)(he.oz,{components:fe,children:e})},s))})};var ye=n(2619);(0,ye.addFilter)("extendify.ai-agent-suggestion-tours","extendify/ai-agent-extra-tours",e=>window.extSharedData?.showAIPageCreation?{...e,"post-new.php?post_type=page":"page-creator-tour"}:e);const we=(0,ye.applyFilters)("extendify.ai-agent-suggestion-tours",{"plugin-install.php":"plugin-install-tour","plugins.php":"plugin-management-tour","post-new.php?post_type=page":"page-editor-tour","post-new.php?post_type=post":"library-tour","users.php":"users-screen-tour","admin.php?page=extendify-assist":"site-assistant-tour"});var be=n(9035),ve=n(7806),ke=n(8537),je=n(5974),_e=n(4891),Se=n(1450),Ce=n(974);const Le=Object.values(be.A),Te=window.extAgentData.agentContext?.availableAdminPages||[],Ee=Object.fromEntries(Te.map(e=>[e,{label:(0,k.__)("Take me there","extendify-local"),tour:Le.find(t=>t.id===we[e])??null}]))||{},Ne={agent1:je.A,agent2:_e.A,agent3:Se.A,agent4:Ce.A},Ae=({message:e,animate:t})=>{const{content:n,role:o,pageSuggestion:s,agent:r,sessionId:a="not-set"}=e.details,i=/```[\s\S]*?```/.test(n)?[(0,ke.decodeEntities)(n??"")]:(0,ke.decodeEntities)(n??"").split(/\n{2,}/),l=Object.keys(Ee).find(e=>s?.startsWith(e)),c=Ee[l]||{};return(0,L.jsxs)("div",{"data-agent-message-role":o,className:"flex w-full items-start gap-2.5 p-2",children:[(0,L.jsx)("div",{className:"w-7 shrink-0",children:r?.avatar?(0,L.jsx)("img",{className:"mt-px",src:r.avatar,alt:r.name}):(0,L.jsx)(j.A,{className:"-mt-0.5 fill-gray-900",icon:Ne[r?.id]??Q,size:28})}),(0,L.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-4",children:[(0,L.jsx)("div",{className:"extendify-agent-markdown w-full",children:t?(0,L.jsx)(xe,{words:i,delay:.1,duration:.35}):(0,L.jsx)(he.oz,{children:(0,ke.decodeEntities)(n)})}),c?.label?(0,L.jsx)("div",{children:(0,L.jsx)("a",{onClick:()=>{x({sessionId:a,action:"take_me_there_click",value:{pageSuggestion:s}})},href:`${window.extSharedData.adminUrl}${s}`,className:"rounded-sm border border-design-main bg-design-main p-2 text-sm text-white no-underline hover:opacity-90",children:c.label})}):null,c?.tour&&(0,L.jsx)("div",{children:(0,L.jsx)(ve.L,{tour:c.tour})})]})]})},Pe=({status:e,animate:t})=>{const{type:n,label:o}=e.details,[s,r]=(0,y.useState)(),[a,i]=(0,y.useState)(0),l=(0,y.useMemo)(()=>({"calling-agent":(0,k.__)("Thinking...","extendify-local"),"agent-working":[(0,k.__)("Working on it...","extendify-local"),(0,k.__)("Interpreting message...","extendify-local"),(0,k.__)("Formulating a response...","extendify-local"),(0,k.__)("Reviewing logic...","extendify-local")],"workflow-tool-processing":(0,k.__)("Processing...","extendify-local"),"tool-started":o||(0,k.__)("Gathering data...","extendify-local"),"tool-completed":o||(0,k.__)("Analyzing...","extendify-local"),"tool-canceled":o||(0,k.__)("Canceled","extendify-local"),"workflow-canceled":o||(0,k.__)("Canceled","extendify-local"),"credits-exhausted":(0,k.__)("Usage limit reached","extendify-local"),"credits-restored":(0,k.__)("Usage limit restored","extendify-local")}),[o]),c=["calling-agent","agent-working","tool-started"].includes(n);return(0,y.useEffect)(()=>{if(!Array.isArray(l[n]))return void r(l[n]);r(l[n][a]);const e=setTimeout(()=>{r(null),i(e=>(e+1)%l[n].length)},5e3);return()=>{r(null),clearTimeout(e)}},[n,l,s,a]),"workflow-tool-completed"===n?(0,L.jsx)(Ie,{label:o}):"workflow-canceled"===n?(0,L.jsx)(Re,{label:o}):s?(0,L.jsx)("div",{className:le()("p-2 text-center text-xs italic text-gray-700",{"status-animation":c}),children:t?(0,L.jsx)(xe,{words:(0,ke.decodeEntities)(s).split(""),delay:.02}):(0,ke.decodeEntities)(s)}):null},Ie=({label:e})=>(0,L.jsxs)("div",{className:"flex w-full items-start gap-2.5 p-2",children:[(0,L.jsx)("div",{className:"w-7 shrink-0"}),(0,L.jsx)("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:(0,L.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border border-wp-alert-green bg-wp-alert-green/20 p-3 text-green-900",children:[(0,L.jsx)("div",{className:"h-6 w-6 leading-none",children:(0,L.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"size-6",children:[(0,L.jsx)("title",{children:(0,k.__)("Success icon","extendify-local")}),(0,L.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"})]})}),(0,L.jsx)("div",{className:"text-sm",children:(0,ke.decodeEntities)(e)||(0,k.__)("Workflow completed successfully","extendify-local")})]})})]}),Re=({label:e})=>(0,L.jsxs)("div",{className:"flex w-full items-start gap-2.5 p-2",children:[(0,L.jsx)("div",{className:"w-7 shrink-0"}),(0,L.jsx)("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:(0,L.jsx)("div",{className:"flex items-center gap-2 rounded-lg border border-gray-300 bg-gray-50 p-3 text-gray-700",children:(0,L.jsx)("div",{className:"text-sm",children:(0,ke.decodeEntities)(e)||(0,k.__)("Workflow was canceled","extendify-local")})})})]}),De=({message:e})=>{const{content:t,role:n}=e.details;return(0,L.jsx)("div",{"data-agent-message-role":n,className:"flex w-full flex-col items-end p-2",children:(0,L.jsx)("div",{className:"max-w-[80%] rounded-xl bg-gray-100 p-1.5 px-2.5 text-gray-900",children:(0,ke.decodeEntities)(t)})})},$e=({children:e})=>(0,L.jsx)("div",{className:"mb-4 ml-10 mr-2 min-w-0 flex-1 flex-col gap-1 rtl:ml-2 rtl:mr-10 rtl:flex",children:(0,L.jsxs)("div",{className:"flex gap-2 rounded-lg border border-wp-alert-red bg-wp-alert-red/10 p-3 text-red-800",children:[(0,L.jsx)("div",{children:(0,L.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"size-6",children:[(0,L.jsx)("title",{children:(0,k.__)("Error icon","extendify-local")}),(0,L.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z"})]})}),(0,L.jsx)("div",{className:"text-sm",children:e})]})}),Me=({message:e})=>{const t=u.L.find(t=>t.id===e.details.id)?.whenFinished?.component;return t?(0,L.jsx)(t,{...e.details}):(0,L.jsx)(qe,{})},qe=()=>(0,L.jsx)($e,{children:(0,L.jsxs)("div",{className:"text-sm",children:[(0,L.jsx)("div",{className:"font-semibold",children:(0,k.__)("Component not available","extendify-local")}),(0,L.jsx)("div",{className:"",children: // translators: This is for when a component doesn't exist // translators: This is for when a component doesn't exist (0,k.__)("It may have been removed or is not available for your account.","extendify-local")})]})}),Be=window.extAgentData?.suggestions||[],Fe=(0,s.vt)()((0,r.Zr)((0,r.lt)((e,t)=>({suggestions:Be,addSuggestions:t=>{const n=(Array.isArray(t)?t:[]).filter(e=>e.workflowId&&e.label).map(e=>({workflowId:e.workflowId,message:e.label,icon:e.icon??"sparkle",source:e.source??"workflow",available:e.available,addedAt:Date.now(),seenAt:null,clickedAt:null}));0!==n.length&&e(e=>{const t=new Set(n.map(e=>e.message)),o=e.suggestions.filter(e=>!t.has(e.message));return{suggestions:[...n,...o]}})},getNextSuggestions:({exclude:e=[]}={})=>{const n=new Set(e.map(e=>e.workflowId)),{suggestions:o}=t();return o.filter(e=>!n.has(e.workflowId)).filter(e=>t().isAvailable(e)).toSorted((e,t)=>(e.seenAt??0)-(t.seenAt??0)).toSorted((e,t)=>(e.seenAt?1:0)-(t.seenAt?1:0)).toSorted((e,t)=>[e.source,t.source].includes("plugin")?0:(t.addedAt??0)-(e.addedAt??0)).toSorted((e,t)=>("plugin"===e.source?1:0)-("plugin"===t.source?1:0))},getSuggestions:({slice:e=3,exclude:n=[]}={})=>{const o=t().getNextSuggestions({exclude:n}).slice(0,e);return t().markAsSeen(o),o},isAvailable:e=>{const{context:t,abilities:n}=window.extAgentData??{},{context:o,abilities:s}=e.available??{};return!(s&&!s.every(e=>n?.[e]))&&(!o||(Array.isArray(o)?o.every(e=>t?.[e]):Object.entries(o).every(([e,n])=>t?.[e]===n)))},markAsSeen:t=>{const n=new Set(t.map(e=>e.message));e(e=>({suggestions:e.suggestions.map(e=>e.seenAt||!n.has(e.message)?e:{...e,seenAt:Date.now()})}))},markAsClicked:t=>e(e=>({suggestions:e.suggestions.map(e=>e.message!==t.message?e:{...e,clickedAt:Date.now()})}))}),{name:"Extendify Agent Suggestions",enabled:window.extSharedData.devbuild}),{name:`extendify-agent-suggestions-${window.extSharedData.siteId}`,merge:(e,t)=>{const n=e?.suggestions??[];return{...t,suggestions:Be.map(e=>{const t=n.find(t=>t.id===e.id);return{...e,seenAt:t?.seenAt,clickedAt:t?.clickedAt}})}}}));var Oe=n(6568),He=n(5506),ze=n(2041),We=n(3725),Ue=n(34),Ve=n(1844),Ye=n(1709),Ze=n(5367);const Ge={styles:_e.A,edit:Se.A,help:Oe.A,video:He.A,sparkle:ne,drafts:ze.A,published:We.A,typography:Ue.A,pencil:Se.A,siteLogo:Ve.A,swatch:Ye.A},Xe=({suggestions:e})=>{const{markAsClicked:t,isAvailable:n,getSuggestions:o}=Fe(),[s,r]=(0,y.useState)(e),a=e=>{window.dispatchEvent(new CustomEvent("extendify-agent:chat-submit",{detail:{message:e.message}})),t(e)};return e?(0,L.jsxs)(L.Fragment,{children:[s.map(e=>n(e)?(0,L.jsx)(Ke,{suggestion:e,handleSubmit:a},e.message):null),(0,L.jsx)(Qe,{handleShowMore:()=>{const e=o({slice:6,exclude:s});r(t=>[...t,...e])}})]}):null},Ke=({suggestion:e,handleSubmit:t})=>{const n=Ge[e?.icon]??Ge.sparkle;return(0,L.jsxs)("button",{type:"button",className:"group flex items-center justify-between rounded-sm bg-transparent px-1 py-1 text-left text-sm not-italic text-gray-900 transition-colors duration-100 hover:bg-gray-100 focus:outline-hidden focus:ring-2 focus:ring-design-main",onClick:()=>t(e),children:[(0,L.jsxs)("div",{className:"flex items-center gap-1.5 leading-none",children:[(0,L.jsx)("span",{className:"h-5 w-5 shrink-0 self-start fill-gray-700",children:n}),(0,L.jsx)("span",{className:"leading-5",children:e.message})]}),(0,L.jsx)("span",{className:"inline-block h-5 w-5 fill-gray-700 leading-none opacity-0 transition-opacity duration-100 group-hover:opacity-100 rtl:scale-x-[-1]",children:Ze.A})]})},Qe=({handleShowMore:e})=>{const[t,n]=(0,y.useState)(!1);return t?null:(0,L.jsxs)("button",{type:"button",className:"group flex w-full items-center gap-3 rounded-sm bg-transparent px-1 py-1 text-xs not-italic text-gray-800 transition-colors duration-100 hover:text-gray-900 focus:outline-hidden group",onClick:()=>{e(),n(!0)},children:[(0,L.jsx)("span",{className:"h-px flex-1 bg-gray-200"}),(0,L.jsx)("span",{className:"group-hover:underline group-focus:ring-2 group-focus:ring-design-main",children:(0,k.__)("Show more","extendify-local")}),(0,L.jsx)("span",{className:"h-px flex-1 bg-gray-200"})]})},Je=({answerId:e})=>{const[t,n]=(0,y.useState)(void 0);return(0,y.useEffect)(()=>{e&&void 0!==t&&(({answerId:e,rating:t})=>{fetch(`${m.AY}/api/agent/rate-workflow`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({answerId:e,rating:t})}).catch(n=>h({caller:"rateAnswer",error:n,extra:{answerId:e,rating:t}}))})({answerId:e,rating:t})},[t,e]),(0,L.jsx)("div",{className:"flex items-center justify-end",children:(0,L.jsxs)("div",{className:"flex items-center gap-px rounded-xl border border-gray-400 bg-gray-50 px-2 text-right",children:[(0,L.jsx)("button",{type:"button","aria-pressed":1===t,"aria-live":"polite",onClick:()=>n(e=>1===e?0:1),"aria-label":1===t?(0,k.__)("Remove rating","extendify-local"):(0,k.__)("Rate that this answer was helpful","extendify-local"),className:le()("m-0 h-6 border-0 bg-transparent p-0 hover:text-design-main",{"text-design-main":1===t,"text-gray-600":1!==t}),children:(0,L.jsx)(j.A,{className:"fill-current",icon:te})}),(0,L.jsx)("button",{type:"button","aria-pressed":-1===t,"aria-live":"polite",onClick:()=>n(e=>-1===e?0:-1),"aria-label":-1===t?(0,k.__)("Remove rating","extendify-local"):(0,k.__)("Rate that this answer was not helpful","extendify-local"),className:le()("m-0 h-6 border-0 bg-transparent p-0 hover:text-design-main",{"text-design-main":-1===t,"text-gray-600":-1!==t}),children:(0,L.jsx)(j.A,{className:"fill-current",icon:ee})})]})})},et=({message:e})=>{const{answerId:t,suggestions:n}=e.details;return(0,L.jsxs)("div",{className:"flex flex-col gap-px p-2 text-center text-xs italic",children:[t&&(0,L.jsx)(Je,{answerId:t}),n?.length>0?(0,L.jsxs)("div",{className:"relative mb-4 ml-9 mr-2 mt-4 flex flex-col gap-0.5 border-t border-gray-300 p-0 pt-4 text-sm text-gray-800 rtl:ml-2 rtl:mr-9",children:[(0,L.jsx)("p",{className:"m-0 mb-2 p-0 px-2 text-left text-sm not-italic text-gray-900 rtl:text-right",children:(0,k.__)("What's next? Would you like to do something else?","extendify-local")}),(0,L.jsx)(Xe,{suggestions:n})]}):null]})};var tt=n(1573);const nt=({canScrollDown:e,onClick:t})=>(0,L.jsx)("div",{className:"pointer-events-none sticky bottom-1 flex h-8 items-center justify-center",children:(0,L.jsx)(R.N,{children:e?(0,L.jsxs)(C.P.button,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2,exit:{duration:0}},onClick:t,type:"button",className:"pointer-events-auto flex h-fit items-center justify-center gap-2 whitespace-nowrap rounded-full border border-gray-500 bg-white/90 p-1 text-sm font-medium text-design-main shadow-lg transition-colors hover:bg-gray-100 focus-visible:ring-design-main disabled:pointer-events-none",children:[(0,L.jsx)(j.A,{fill:"currentColor",icon:tt.A,size:20}),(0,L.jsx)("span",{className:"sr-only",children:(0,k.__)("Scroll down","extendify-local")})]},"scroll-down"):null})});var ot=n(1609);const st=({children:e,...t})=>{const n=(0,ot.useRef)(null),o=(0,ot.useRef)(!1);return(0,ot.useEffect)(()=>{if(!n.current||o.current)return;const e=n.current,t=e.getBoundingClientRect(),s=window.innerHeight||document.documentElement.clientHeight,r=t.height,a=Math.max(t.top,0),i=Math.min(t.bottom,s);Math.max(0,i-a)/r>=.5||(e.scrollIntoView({behavior:"smooth",block:"end"}),o.current=!0)},[]),(0,L.jsx)("div",{ref:n,...t,children:e})},rt=()=>{const{open:e}=c(),{messages:t}=(0,o.L)(),{getWorkflow:n}=(0,d.Y)(),s=n(),r=(()=>{const{whenFinishedToolProps:e,setWhenFinishedToolProps:t,getWorkflow:n}=(0,d.Y)(),o=(0,y.useCallback)((t={})=>{if(!e)return;const o=n();x({sessionId:o?.sessionId,action:"workflow_tool_event",value:{trigger:"confirm",workflow:o?.id}}),window.dispatchEvent(new CustomEvent("extendify-agent:workflow-confirm",{detail:{...t,whenFinishedToolProps:e}}))},[e,n]),s=(0,y.useCallback)(()=>{if(!e)return;const t=n();x({sessionId:t?.sessionId,action:"workflow_tool_event",value:{trigger:"cancel",workflow:t?.id}}),window.dispatchEvent(new CustomEvent("extendify-agent:workflow-cancel",{detail:{whenFinishedToolProps:e}}))},[e,n]),r=(0,y.useCallback)(()=>{if(!e)return;t(null);const o=n();x({sessionId:o?.sessionId,action:"workflow_tool_event",value:{trigger:"retry",workflow:o?.id}}),window.dispatchEvent(new CustomEvent("extendify-agent:workflow-retry",{detail:{whenFinishedToolProps:e}}))},[e,t,n]),a=(0,y.useCallback)(()=>{if(!e)return;const t=Array.from(document.querySelectorAll("#extendify-agent-chat-scroll-area div:last-child"))?.at(-1);t?.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]);return(0,y.useMemo)(()=>e?{...e,onConfirm:o,onCancel:s,onRetry:r,onLoad:a}:null,[e,o,s,r,a])})(),a=s?.whenFinished?.component,[i,l]=(0,y.useState)(!1),u=(0,y.useRef)(null),m=(0,y.useRef)(!0),[p,g]=(0,y.useState)(!1),f="user"===t.filter(({type:e})=>"status"!==e).at(-1)?.details?.role;return(0,y.useEffect)(()=>{if(!u.current||!e)return;if(!m.current)return;m.current=!1;const t=u.current.querySelector("#extendify-agent-chat-scroll-area > :last-child");let n;const o=requestAnimationFrame(()=>{n=requestAnimationFrame(()=>{t?.scrollIntoView({behavior:"auto",block:"start"}),g(!0)})});return()=>{cancelAnimationFrame(o),cancelAnimationFrame(n),m.current=!0,g(!1)}},[e]),(0,y.useEffect)(()=>{if(!u.current)return;if(!f)return;const e=u.current,t=e.querySelectorAll('[data-agent-message-role="user"]'),n=t[t.length-1];if(!n||t.length<2)return;const o=e.querySelector("#extendify-agent-chat-scroll-area"),s=n.getBoundingClientRect(),r=Array.from(o.children).reduce((e,t)=>e+t.offsetHeight,0)+e.clientHeight-s.height;o.style.minHeight=`${r}px`,n.scrollIntoView({behavior:"smooth",block:"start"})},[f,t]),(0,y.useLayoutEffect)(()=>{const e=u.current;if(!e)return;const t=e.querySelector("#extendify-agent-chat-scroll-area > :last-child");if(!t)return;if(e.scrollTop+e.clientHeight>=e.scrollHeight-4)return l(!1);const n=new IntersectionObserver(([t])=>e.querySelector("#extendify-agent-chat-scroll-area > :last-child")?e.scrollTop+e.clientHeight>=e.scrollHeight-4?l(!1):void l(!t.isIntersecting):l(!1),{root:e,threshold:.1});return n.observe(t),()=>n.disconnect()},[t]),(0,L.jsxs)("div",{ref:u,style:{overscrollBehavior:"contain"},className:"relative grow overflow-y-auto overflow-x-hidden p-1 pb-0 text-sm text-gray-900 md:p-2",children:[(0,L.jsxs)("div",{id:"extendify-agent-chat-scroll-area",className:p?"":"invisible pointer-events-none",children:[t.map(e=>{const n=t.at(-1)?.id===e.id,o=m.current;if("user"===e.details?.role)return(0,L.jsx)(De,{message:e},e.id);if("assistant"===e.details?.role)return(0,L.jsx)(Ae,{animate:!o,message:e},e.id);if("workflow"===e.type)return(0,L.jsx)(et,{message:e},e.id);if("workflow-component"===e.type)return(0,L.jsx)(Me,{message:e},e.id);if("status"===e.type&&(n||["workflow-tool-completed","workflow-canceled"].includes(e.details?.type))){const t="error"===e.details?.type;return(0,L.jsx)(Pe,{animate:!t,status:e},e.id)}return null}),!s?.needsRedirect?.()&&r?.id&&a?(0,L.jsx)(st,{children:(0,y.createElement)(a,r)}):null,s?.needsRedirect?.()?(0,L.jsx)(s.redirectComponent,{}):null]}),(0,L.jsx)(nt,{canScrollDown:i,onClick:()=>{if(!u.current)return;const e=u.current.querySelector("#extendify-agent-chat-scroll-area > :last-child");e&&e.scrollIntoView({behavior:"smooth",block:"start"})}})]})};var at=n(8482);const it=({onReady:e})=>{const{retryAfter:t,isChatAvailable:n}=c(),[o,s]=(0,y.useState)(null);if((0,y.useEffect)(()=>{if(!t)return;const o=setInterval(()=>{n()&&e(),s(()=>(0,l.humanTimeDiff)(new Date(Number(t)+45e3),new Date))},1e3);return()=>clearInterval(o)},[n,t,e]),t&&o)return(0,L.jsxs)("div",{className:"flex gap-2 rounded-lg bg-gray-100 p-3 text-sm text-gray-900",children:[(0,L.jsx)(j.A,{icon:at.A,className:"flex-none"}),(0,L.jsx)("div",{className:"grow",children:(0,L.jsx)("div",{children:(0,k.sprintf)( // translators: %s is a human-readable time difference, e.g. "2 hours from now" // translators: %s is a human-readable time difference, e.g. "2 hours from now" (0,k.__)("You have reached your daily messages limit. Your limit will reset in %s.","extendify-local"),o)})})]})},lt=({busy:e})=>{const{setBlock:t}=(0,d.Y)();return(0,L.jsxs)("div",{className:"flex w-fit items-center justify-start gap-1 rounded-sm border border-gray-500 bg-gray-100 p-1 text-sm text-gray-900",children:[(0,L.jsxs)("div",{className:"flex items-center gap-1",children:[(0,L.jsx)(j.A,{icon:se}),(0,L.jsx)("div",{children:(0,k.__)("Selected content","extendify-local")})]}),(0,L.jsxs)("button",{type:"button",disabled:e,className:"flex h-full items-center rounded-none border-0 bg-transparent outline-hidden ring-design-main focus:shadow-none focus:outline-hidden focus-visible:outline-design-main",onClick:()=>t(null),children:[(0,L.jsx)(j.A,{className:"pointer-events-none fill-current leading-none",icon:_.A,size:18}),(0,L.jsx)("span",{className:"sr-only",children:(0,k.__)("Remove","extendify-local")})]})]})},{pluginRecommendations:ct=[]}=window?.extAgentData?.agentContext||{},{adminUrl:dt,homeUrl:ut}=window?.extSharedData||{},mt=window.extSharedData.devbuild;let pt=new AbortController;const{postId:gt}=window?.extAgentData?.context||{},ft=()=>{const{addMessage:e,popMessage:t}=(0,o.L)(),{mergeWorkflowData:n,getWorkflow:s,getWorkflowByExample:r,workflowData:a,setWorkflow:i,addWorkflowResult:l,setWhenFinishedToolProps:u,whenFinishedToolProps:w,getAvailableWorkflows:b,block:j,setBlock:_}=(0,d.Y)(),S=b().map(e=>e.id),{open:C,setOpen:T,updateRetryAfter:E,isChatAvailable:N}=c();(({postId:e,enabled:t})=>{(0,y.useEffect)(()=>{if(!e||!t)return;let n;const o=async()=>{await v()({path:"/extendify/v1/agent/lock-post",method:"POST",data:{postId:e}}).catch(()=>{}),n=setTimeout(o,12e4)};return o(),()=>clearTimeout(n)},[e,t])})({postId:gt,enabled:!!C});const[A,P]=(0,y.useState)(!0),I=(0,y.useRef)(!1),R=(0,y.useRef)(!1),D=(0,y.useRef)(!1),[$,M]=(0,y.useState)(!1),[q,B]=(0,y.useState)(0),F=s(),O=(0,y.useMemo)(()=>N(),[N]),{addSuggestions:H,getSuggestions:z}=Fe(),W=(0,y.useCallback)(()=>{P(!0),I.current=!1,M(!1),pt=new AbortController,j&&_(null),window.dispatchEvent(new Event("extendify-agent:remove-block-highlight"));const e=Array.from(document.querySelectorAll("#extendify-agent-chat-scroll-area div:last-child"))?.at(-1);e?.scrollIntoView({behavior:"smooth",block:"nearest"}),e?.scrollBy({top:-5,behavior:"smooth"})},[_,j]),U=(0,y.useCallback)(async(t={})=>{e("status",{type:"calling-agent"});const n=await(async({workflows:e,options:t})=>{const{failedWorkflows:n,context:s}=window.extAgentData,r=n??new Set,a=e.filter(e=>!r.has(e.id)),{workflowHistory:i,block:l}=d.Y.getState(),c=o.L.getState().getMessagesForAI(),u=o.L.getState().getLastAssistantMessage(),f=await fetch(`${m.AY}/api/agent/find-agent`,{method:"POST",headers:{"Content-Type":"application/json"},signal:t?.signal,body:JSON.stringify({...p.m,workflows:a,previousAgentName:i.at(0)?.agentName,previousWorkflow:{lastMessage:u?.details?.content,sessionId:u?.details?.sessionId,...i?.at(0)},context:s,agentContext:window.extAgentData.agentContext,messages:c.slice(-5),hasBlock:Boolean(l),blockDetails:l,...t,extra:g()})});if(!f.ok){h({caller:"pick-workflow",error:{name:f.statusText,messages:f.statusMessage}});const e=new Error("Bad response from server");throw e.response=f,e}return await f.json()})({workflows:S,options:{signal:pt.signal,...t}}).catch(async t=>{if(mt&&console.error(t),429===t?.response?.status)return E(t?.response?.headers?.get("Retry-After")),P(!1),void e("status",{type:"credits-exhausted"});P(!0),"Workflow aborted"!==t?(await new Promise(e=>setTimeout(e,1e3)),e("message",{role:"assistant", // translators: This message is shown when the AI agent fails to find a suitable workflow. content:(0,k.__)("Something went wrong while trying to start this request. Please try again.","extendify-local"),error:!0})):e("status",{type:"workflow-canceled"})});if(!n)return;const{workflow:s,reply:r}=n;s?.id&&i(s),r&&e("message",{role:"assistant",content:r,agent:s?.agent}),s?.id||P(!0)},[e,E,i,S]),V=(0,y.useCallback)(async t=>{M(!1),I.current=!1,e("message",{role:"user",content:t});const o=r(t);if(o?.example?.agentResponse)return Y(o);P(!1);const s=F?.needsRedirect?.(),l=w?.id,c=s||l;if(c&&i(null),F&&!c){const e=a||{};return i({...F}),void n(e)}await U().catch(e=>mt&&console.error(e))},[e,U,n,w,i,F,a,b]),Y=(0,y.useCallback)(async t=>{const n=t.example?.agentResponse;W(),n&&(i(t),P(!1),I.current=!0,await new Promise(e=>setTimeout(e,750)),e("message",{role:"assistant",content:n.reply}),u({...n?.whenFinishedTool,agentResponse:n}),x({sessionId:t?.sessionId,action:"workflow_tool_bypass",value:{workflow:t?.id}}))},[]);(0,y.useEffect)(()=>{const t=({detail:e})=>{e?.message&&V(e.message)},n=()=>{pt.abort("Workflow aborted"),W(),F?.id&&(i(null),e("status",{type:"workflow-canceled"}))};return window.addEventListener("extendify-agent:cancel-workflow",n),window.addEventListener("extendify-agent:chat-submit",t),()=>{window.removeEventListener("extendify-agent:cancel-workflow",n),window.removeEventListener("extendify-agent:chat-submit",t)}},[V,W,i,e,F]),(0,y.useEffect)(()=>{const n=async({detail:t})=>{if(R.current)return;u(null),e("status",{type:"workflow-tool-processing"}),R.current=!0;const{data:n,whenFinishedToolProps:o,shouldRefreshPage:s,redirectUrl:r}=t??{},{status:a,whenFinishedTool:c,answerId:d,redirectTo:m}=o?.agentResponse||{},{id:p,labels:g}=c||{},x=await(f?.({tool:p,inputs:n}).catch(e=>{const{sessionId:t}=F||{};return h({caller:`when-finished: ${p}`,sessionId:t,error:e}),mt&&console.error(e),{error:e.message}}));if(R.current=!1,l({answerId:d,agentName:F?.agent?.name,status:a,errorMsg:x?.error,language:F?.language}),x?.error)return await new Promise(e=>setTimeout(e,1e3)),e("message",{role:"assistant", // translators: This message is shown when the AI agent fails to confirm an action. content:(0,k.__)("Sorry, something went wrong attempting to call the tool. Please try again.","extendify-local"),error:!0}),i(null),void W();e("status",{label:g?.confirm,type:"workflow-tool-completed"}),H(o.agentResponse?.recommendations),e("workflow",{status:"completed",agent:F.agent,answerId:d,suggestions:z()}),i(null);const y=((e,t={})=>{if("plugin-setup"===e?.type){const e=ct.find(({slug:e})=>e===t.pluginSlug);return e?(e=>{try{return new URL(e.replace("{{ADMIN_URL}}",dt).replace("{{HOME_URL}}",ut)).toString()}catch(e){return console.error(e),""}})(e.redirectTo):""}return""})(m,o?.inputs);return(y||r||s)&&await new Promise(e=>setTimeout(e,1e3)),y?window.location.assign(y):r?window.location.assign(r):s?window.location.reload():void W()},o=({detail:t})=>{if(R.current)return;const{answerId:n,whenFinishedTool:o}=t.whenFinishedToolProps?.agentResponse||{};e("status",{type:"workflow-canceled",label:o?.labels?.cancel}),e("workflow",{status:"canceled",agent:F.agent,answerId:n,suggestions:z()}),l({answerId:n,status:"canceled",agentName:F?.agent?.name,language:F?.language}),i(null),W()},s=()=>{t(),M(!1),I.current=!1,D.current=!0,B(e=>e+1)};return window.addEventListener("extendify-agent:workflow-confirm",n),window.addEventListener("extendify-agent:workflow-cancel",o),window.addEventListener("extendify-agent:workflow-retry",s),()=>{window.removeEventListener("extendify-agent:workflow-confirm",n),window.removeEventListener("extendify-agent:workflow-cancel",o),window.removeEventListener("extendify-agent:workflow-retry",s)}},[e,t,W,l,i,F,z,H]),(0,y.useEffect)(()=>{const e=()=>T(!1),t=()=>T(!0);return window.addEventListener("extendify-agent:close",e),window.addEventListener("extendify-agent:open",t),()=>{window.removeEventListener("extendify-agent:close",e),window.removeEventListener("extendify-agent:open",t)}},[T]),(0,y.useEffect)(()=>{if($||!C||!F?.id)return;const t=F?.startingPage!==window.location.href,s=!j&&F?.requires?.includes("block");if(F?.cancelOnPageChange&&t||s)return e("workflow",{status:"canceled",agent:F.agent,suggestions:z()}),i(null),void W();w?.id||(F?.needsRedirect?.()?W():(async()=>{if(I.current)return;if(R.current)return;P(!1),I.current=!0,e("status",{type:"agent-working"});const t=await(async({workflow:e,workflowData:t,options:n})=>{const s=o.L.getState().getMessagesForAI(),r=await fetch(`${m.AY}/api/agent/handle-workflow`,{method:"POST",headers:{"Content-Type":"application/json"},signal:n?.signal,body:JSON.stringify({...p.m,workflow:e,workflowData:t,messages:s,context:window.extAgentData.context,agentContext:window.extAgentData.agentContext,retry:n?.retry||!1,extra:g()})});if(!r.ok)throw new Error("Bad response from server");return await r.json()})({workflow:F,workflowData:a,options:{signal:pt.signal,retry:D.current}}).catch(t=>{if("Workflow aborted"===t)return e("status",{type:"workflow-canceled"}),i(null),void W();const{sessionId:n}=F||{};return h({caller:"handle-workflow",sessionId:n,error:t}),mt&&console.error(t),{error:t.message}});if(D.current&&(D.current=!1),!t)return;const{status:s,answerId:r,sessionId:c}=t;if(l({answerId:r,status:s,errorMsg:t?.error,agentName:F?.agent?.name,language:F?.language}),C){if(t.error)throw window.extAgentData.failedWorkflows=window.extAgentData.failedWorkflows||new Set,window.extAgentData.failedWorkflows.add(F.id),new Error(`Error handling workflow: ${t.error}`);if(t.reply&&e("message",{role:"assistant",content:t.reply,followup:!!t.tool,pageSuggestion:t.pageSuggestion,agent:F.agent,sessionId:F?.sessionId}),t.whenFinishedTool?.id){u({...t.whenFinishedTool,agentResponse:t});const{id:n,inputs:o,static:s}=t.whenFinishedTool;return void(s&&(e("workflow-component",{id:n,status:"completed",inputs:o}),H(t.recommendations),i(null),e("workflow",{status:"completed",agent:F.agent,answerId:r,suggestions:z()}),W()))}if("in-progress"!==t.status){const{recommendations:n,status:o}=t,s="completed"===o;return n&&H(n),i(null),W(),void e("workflow",{status:s?"completed":"canceled",agent:F.agent,answerId:r,suggestions:z()})}if(c&&c!==F.sessionId&&i({...F,sessionId:c}),n(t.inputs),t.tool){const{id:o,inputs:s,labels:r}=t.tool;e("status",{label:r?.started,type:"tool-started"});const a=await Promise.all([f({tool:o,inputs:s}),new Promise(e=>setTimeout(e,3e3))]).then(([e])=>e).catch(e=>{const{sessionId:t}=F||{};throw h({caller:`in-progress: ${o}`,sessionId:t,error:e}),mt&&console.error(e),e});return e("status",{label:r?.confirm,type:"tool-completed"}),await new Promise(e=>setTimeout(e,1e3)),n(a),M(!1),I.current=!1,void B(e=>e+1)}P(!0),M(!0)}})().catch(async t=>{const{sessionId:n}=F||{};h({caller:"main-loop",sessionId:n,error:t}),mt&&console.error(t),i(null),W(),await new Promise(e=>setTimeout(e,1e3)),e("message",{role:"assistant", // translators: This message is shown when the AI agent encounters a general error. content:(0,k.__)("Sorry, something went wrong. I tried but wasn't able to do this request. Please try again.","extendify-local"),error:!0})}))},[q,W,l,C,F,a,e,i,I,$,n,A,w,u,j,H,z]),(0,y.useEffect)(()=>{A&&document.querySelector("#extendify-agent-chat-textarea")?.focus()},[A]);const Z=!A||!O||F?.id;return(0,L.jsx)(K,{busy:Z,children:(0,L.jsxs)("div",{className:"relative z-50 flex h-full flex-col justify-between overflow-auto",children:[(0,L.jsx)(rt,{redirectComponent:F?.needsRedirect?.()?F.redirectComponent:null}),(0,L.jsxs)("div",{children:[(0,L.jsxs)("div",{className:"relative flex flex-col px-4 pb-2 pt-2.5 shadow-lg-flipped",children:[j?(0,L.jsx)(lt,{busy:Z,blockId:j.id}):null,(0,L.jsx)(it,{onReady:()=>{W(),e("status",{type:"credits-restored"})}})]}),(0,L.jsx)("div",{className:"p-4 pb-2 pt-0",children:(0,L.jsx)(ue,{disabled:!A||!O,handleSubmit:V})}),(0,L.jsx)("div",{className:"text-pretty px-4 pb-2 text-center text-xss leading-none text-banner-text/60",children:(0,k.__)("AI Agent can make mistakes. Check changes before saving.","extendify-local")})]})]})})};var ht=n(7828),xt=n(365),yt=n(8490),wt=n.n(yt),bt=n(6427);const vt="floating"!==window.extAgentData.agentPosition,kt=()=>{const{toggleOpen:e,open:t,isMobile:n}=c();return n?null:(0,L.jsxs)(C.P.button,{type:"button",initial:!1,animate:{width:vt&&t?0:"auto",opacity:vt&&t?0:100},transition:{width:{duration:.3,ease:"easeInOut"},opacity:{duration:.1,ease:"easeInOut"}},className:le()("items-center justify-center gap-0.5 h-full border-0 leading-extra-tight text-white md:inline-flex whitespace-nowrap hover:opacity-80",{"opacity-60":t&&!vt},{"mr-1 rtl:ml-1 rtl:mr-0":t&&vt},{"py-0.5 px-1.5 bg-design-main text-design-text":!vt||vt&&!t}),onClick:()=>e(),"aria-label":(0,k.__)("Open Agent","extendify-local"),children:[(0,L.jsx)(bt.Icon,{className:"shrink-0",icon:Q,width:20,height:20}),(0,L.jsx)("span",{className:"px-1 leading-none",children:(0,k.__)("AI Agent","extendify-local")})]})};var jt=n(1152);const _t=()=>{const{isMobile:e,minimized:t,setMinimized:n}=c(),o=(0,y.useRef)(null);return(0,y.useEffect)(()=>{e&&!t&&document.body.style.setProperty("--extendify-agent-mobile-btn-height",`${o.current?.offsetHeight}px`)},[e,t]),(0,y.useEffect)(()=>{if(e)return document.body.classList.add("extendify-agent-mobile-btn-open"),()=>{document.body.classList.remove("extendify-agent-mobile-btn-open")}},[e]),e&&t?(0,L.jsxs)("button",{ref:o,type:"button",className:"m-0 flex w-full items-center justify-between gap-2 bg-gray-900 px-4 py-3 font-sans text-white shadow-[0_-1px_0_0_rgba(255,255,255,0.05)]",onClick:()=>n(!1),"aria-label":(0,k.__)("Open Agent","extendify-local"),children:[(0,L.jsxs)("div",{className:"flex gap-3",children:[(0,L.jsx)("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-wp-theme-main",children:(0,L.jsx)(j.A,{icon:Q,size:24})}),(0,L.jsxs)("div",{className:"text-left text-sm rtl:text-right",children:[(0,L.jsx)("div",{className:"font-semibold",children:(0,k.__)("AI Agent","extendify-local")}),(0,L.jsx)("div",{className:"text-gray-600",children:(0,k.__)("How can we help you today?","extendify-local")})]})]}),(0,L.jsx)(j.A,{className:"fill-white",icon:jt.A,size:24})]}):null},St=()=>{const{toggleOpen:e,open:t,isMobile:n}=c(),[o,s]=(0,y.useState)(!1),[r,a]=(0,y.useState)(!1),i=(0,y.useRef)(!1);return(0,y.useEffect)(()=>{if(!i.current)return void(i.current=!0);if(t||n)return;s(!0),a(!0);const e=setTimeout(()=>{s(!1)},1500),o=setTimeout(()=>{a(!1)},5e3);return()=>{clearTimeout(e),clearTimeout(o)}},[t,n]),n?null:(0,L.jsx)(bt.Button,{variant:"primary",icon:r?J:Q,iconPosition:"left",className:"is-compact has-text relative z-10",onClick:()=>{t&&s(!0),e()},"aria-label":(0,k.__)("Open Agent","extendify-local"),children:(0,L.jsx)("span",{className:le()("px-1 leading-none",{"extendify-gradient-animation":o}),children:(0,k.__)("AI Agent","extendify-local")})})};var Ct=n(2279);wt()(()=>{if((0,xt.Zz)())return;const e="wp-admin-bar-extendify-agent-btn";if(document.getElementById(e))return;const t=Object.assign(document.createElement("li"),{className:"extendify-agent",id:e});t.style.height="1.75rem",t.style.marginInlineEnd="4px";const n="floating"===window.extAgentData.agentPosition?"#wp-admin-bar-my-account":"#wp-admin-bar-wp-logo";document.querySelector(n)?.before(t),(0,ht.X)((0,L.jsx)(kt,{}),t)}),wt()(()=>{if((0,xt.Zz)())return;const e="extendify-agent-mobile-btn";if(document.getElementById(e))return;const t=Object.assign(document.createElement("div"),{className:"extendify-agent",id:e});t.style.position="sticky",t.style.top="calc(100% - var(--extendify-agent-mobile-btn-height))",t.style.bottom="0",t.style.zIndex="99999",document.body.appendChild(t),(0,ht.X)((0,L.jsx)(_t,{}),t)}),(0,Ct.registerPlugin)("extendify-agent-buttons",{render:()=>(0,L.jsx)(Lt,{})});const Lt=()=>((0,y.useEffect)(()=>{if((0,xt.Zz)())return;const e="extendify-agent-editor-btn";if(document.getElementById(e))return;const t=Object.assign(document.createElement("span"),{className:"extendify-agent",id:e});setTimeout(()=>{document.getElementById(e)||(document.querySelector('[aria-controls="edit-post:document"]')?.after(t),document.querySelector('[aria-controls="edit-site:template"]')?.after(t),(0,ht.X)((0,L.jsx)(St,{}),t))},300)},[]),null);var Tt=n(5295),Et=n(8971);const Nt=e=>{const{top:t,right:n,bottom:o,left:s,width:r,height:a,x:i,y:l}=e.getBoundingClientRect();return{top:t,right:n,bottom:o,left:s,width:r,height:a,x:i,y:l}},At=()=>{const e=(0,y.useRef)(),{currentTour:t,currentStep:n,startTour:o,closeCurrentTour:s,getStepData:r,onTourPage:a}=(0,Tt.n)(),{settings:i}=t||{},{image:l,title:d,text:u,attachTo:m,events:p,options:g}=r(n),{queueTourForRedirect:f,queuedTour:h,clearQueuedTour:x,isMobile:w}=c(),{element:b,frame:v,offset:S,position:T,hook:E,boxPadding:N}=m||{},A=(0,y.useMemo)(()=>"function"==typeof b?b():b,[b]),P=(0,y.useMemo)(()=>"function"==typeof v?v():v,[v]),I=(0,y.useMemo)(()=>"function"==typeof S?S():S,[S]),D=(0,y.useMemo)(()=>"function"==typeof E?E():E,[E]),$=(0,y.useRef)(),M=(0,y.useRef)(!1),[q,B]=(0,y.useState)(null),[F,O]=(0,y.useState)(!1),[H,z]=(0,y.useState)(!1),[W,U]=(0,y.useState)(null),[V,Y]=(0,y.useState)({x:void 0,y:void 0,...I}),Z=(0,y.useCallback)((e,t)=>{Y(20===e?{x:e,y:t}:{x:e,y:t,...I})},[I]),G=(0,y.useCallback)(()=>{const t=D?.split(" ")||[];return{x:t.includes("right")?e.current?.offsetWidth:0,y:t.includes("bottom")?e.current?.offsetHeight:0}},[D]),X=(0,y.useCallback)(()=>{if(!q)return;const t=P?document.querySelector(P)?.contentDocument??document:document,n=Nt(t.querySelector(A)??q);if(t!==document){const e=Nt(t.defaultView.frameElement);n.x+=e.x,n.left+=e.x,n.right+=e.x,n.y+=e.y,n.top+=e.y,n.bottom+=e.y}if(window.innerWidth<=960)return void s("closed-resize");if(void 0===T?.x)return Z(void 0,void 0),U(null),void z(!1);const o=Math.max(20,n?.[T.x]-G().x),r=Math.max(20,n?.[T.y]-G().y),a=e.current;Z(Math.min(o,window.innerWidth-(a?.offsetWidth??0)-20),Math.min(r,window.innerHeight-(a?.offsetHeight??0)-20)),U(n)},[q,T,G,Z,P,A,s]);if((0,y.useLayoutEffect)(()=>{i?.startFrom&&(a()||(O(!0),f(t.id),s("redirected"),window.location.assign(i?.startFrom[0]),window.location.href.split("#")[0]===i.startFrom[0].split("#")[0]&&window.location.reload()))},[i?.startFrom,t,f,s,a]),(0,y.useEffect)(()=>{n&&document.querySelectorAll("[inert]").forEach(e=>{e?.removeAttribute("inert")})},[n]),(0,y.useEffect)(()=>{const e=e=>{const{tourSlug:t}=e.detail;be.A[t]&&requestAnimationFrame(()=>{o(be.A[t])})};return window.addEventListener("extendify-assist:start-tour",e),()=>{window.removeEventListener("extendify-assist:start-tour",e)}},[o]),(0,y.useLayoutEffect)(()=>{if(F)return;const e=h;let t=0;if(!e||!be.A[e])return x();const n=()=>{requestAnimationFrame(()=>{o(be.A[e])}),x()};return addEventListener("load",n),"complete"===document.readyState&&(t=requestAnimationFrame(n)),()=>{cancelAnimationFrame(t),removeEventListener("load",n)}},[o,h,x,F]),(0,y.useEffect)(()=>{if(!A)return;const e=(P?document.querySelector(P)?.contentDocument??document:document).querySelector(A)??document.querySelector(A);return e?(B(e),()=>B(null)):void 0},[P,A]),(0,y.useLayoutEffect)(()=>{if(q&&!F)return z(!0),X(),addEventListener("resize",X),g?.allowPointerEvents||(q.style.pointerEvents="none"),()=>{removeEventListener("resize",X),q.style.pointerEvents="auto"}},[F,q,X,g]),(0,y.useEffect)(()=>{M.current||n&&(M.current=!0)},[n]),(0,y.useEffect)(()=>{if(void 0===n||!q)return;p?.onAttach?.(q);let e=0;const t=requestAnimationFrame(()=>{q.scrollIntoView({block:"center"}),X(),e=requestAnimationFrame(X)});return $?.current?.focus(),()=>{p?.onDetach?.(q),cancelAnimationFrame(t),cancelAnimationFrame(e)}},[n,p,q,X,$]),(0,y.useLayoutEffect)(()=>{if(i?.allowOverflow)return document.documentElement.classList.add("ext-force-overflow-auto"),()=>{document.documentElement.classList.remove("ext-force-overflow-auto")}},[i]),!H||w)return null;const K=Rt(W,N);return(0,L.jsx)(R.N,{children:Boolean(t)&&(0,L.jsxs)(Et.lG,{as:C.P.div,static:!0,initialFocus:$,className:"extendify-agent",open:Boolean(t),onClose:()=>{},children:[(0,L.jsx)("div",{className:"relative z-max",children:(0,L.jsxs)(C.P.div,{ref:e,animate:{opacity:1,...V},initial:{opacity:0,...V},onAnimationComplete:()=>{X()},transition:{duration:M.current?.5:0,ease:"easeInOut"},className:"fixed left-0 top-0 z-20 flex max-w-xs flex-col bg-transparent shadow-2xl sm:overflow-hidden",style:{minWidth:i?.minBoxWidth??"325px"},children:[(0,L.jsx)("button",{type:"button","data-test":"close-tour",className:"absolute right-0 top-0 z-20 m-2 flex h-6 w-6 items-center justify-center rounded-full border-0 bg-white p-0 leading-none outline-hidden ring-1 ring-gray-200 focus:shadow-none focus:ring-wp focus:ring-design-main rtl:left-0 rtl:right-auto",onClick:()=>s("closed-manually"),"aria-label":(0,k.__)("Close Modal","extendify-local"),children:(0,L.jsx)(j.A,{icon:_.A,className:"h-4 w-4 fill-current"})}),(0,L.jsx)(Et.lG.Title,{className:"sr-only",children:t?.title??(0,k.__)("Tour","extendify-local")}),l&&(0,L.jsx)("div",{className:"w-full p-6",style:{minHeight:150,background:"linear-gradient(58.72deg, #485563 7.71%, #29323C 92.87%)"},children:(0,L.jsx)("img",{src:l,className:"block w-full",alt:d})}),(0,L.jsxs)("div",{className:"relative m-0 bg-white p-6 pt-0 text-left rtl:text-right",children:[d&&(0,L.jsx)("h2",{className:"mb-2 text-xl font-medium",children:d}),u&&(0,L.jsx)("p",{className:"mb-6",children:u}),(0,L.jsx)(It,{initialFocus:$})]})]})}),g?.allowPointerEvents||(0,L.jsx)("div",{"aria-hidden":!0,className:"fixed inset-0 z-max-1"}),Boolean(t)&&void 0!==W?.left&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(C.P.div,{initial:{opacity:0,clipPath:"polygon(0px 0px, 100% 0px, 100% 100%, 0px 100%, 0 0)"},animate:{opacity:1,clipPath:`polygon(0px 0px, 100% 0px, 100% 100%, 0px 100%, 0 0, ${K.left}px 0, ${K.left}px ${K?.bottom}px, ${K?.right}px ${K.bottom}px, ${K.right}px ${K.top}px, ${K.left}px ${K.top}px)`},transition:{duration:M.current?.5:0,ease:"easeInOut"},className:"fixed inset-0 z-max-1 hidden bg-black/70 lg:block","aria-hidden":"true"}),(0,L.jsx)(Pt,{rectWithPadding:K,finishedStepOne:M})]})]})})},Pt=({rectWithPadding:e,finishedStepOne:t})=>{const[n,o]=(0,y.useState)(!1);return(0,L.jsx)(C.P.div,{initial:{...e??{}},animate:{...e??{}},transition:{duration:t.current?.5:0,ease:"easeInOut"},onAnimationStart:()=>o(!1),onAnimationComplete:()=>o(!0),className:le()("fixed inset-0 z-high hidden border-2 lg:block",{"border-transparent":!n,"border-design-main":n,"inset-y-auto right-0":(0,k.isRTL)()}),"aria-hidden":"true"})},It=({initialFocus:e})=>{const{goToStep:t,completeCurrentTour:n,currentStep:o,preparingStep:s,getStepData:r,hasNextStep:a,nextStep:i,hasPreviousStep:l,prevStep:c,currentTour:d}=(0,Tt.n)(),{options:u={}}=r(o),{hideBackButton:m=!1}=u,{steps:p,settings:g}=d||{};return(0,L.jsxs)("div",{id:"extendify-tour-navigation",className:"flex w-full items-center justify-between",children:[(0,L.jsx)("div",{className:"flex flex-1 justify-start rtl:flex-none",children:(0,L.jsx)(R.N,{children:l()&&!m&&(0,L.jsx)(C.P.div,{initial:{opacity:0},animate:{opacity:1},children:(0,L.jsxs)("button",{type:"button",className:"flex h-8 items-center justify-center gap-2 rounded-xs bg-transparent p-0 text-gray-900 ring-design-main hover:bg-transparent focus:outline-hidden focus:ring-wp focus:ring-offset-1 focus:ring-offset-white disabled:opacity-60",onClick:c,disabled:s>-1,children:[s<o&&(0,L.jsx)(bt.Spinner,{className:"m-0 h-4 text-design-main"}),(0,L.jsx)("span",{children:(0,k.__)("Back","extendify-local")})]})})})}),p?.length>2&&!g?.hideDotsNav?(0,L.jsx)("nav",{"aria-label":(0,k.__)("Tour Steps","extendify-local"),className:"flex flex-1 -translate-x-3 items-center justify-center gap-1",children:p.map((e,n)=>(0,L.jsx)("div",{children:(0,L.jsx)("button",{type:"button","aria-label":(0,k.sprintf)( // translators: %1$s is the current step, %2$s is the total number of steps // translators: %1$s is the current step, %2$s is the total number of steps (0,k.__)("%1$s of %2$s","extendify-local"),n+1,p.length),"aria-current":n===o,className:"m-0 block h-2.5 w-2.5 rounded-full p-0 ring-offset-1 ring-offset-white focus:outline-hidden focus:ring-wp focus:ring-design-main "+(n===o?"bg-design-main":"bg-gray-300"),onClick:()=>t(n),disabled:s>-1})},n))}):null,(0,L.jsx)("div",{className:"flex flex-1 justify-end rtl:flex-none",children:a()?(0,L.jsxs)(bt.Button,{ref:e,id:"agent-tour-next-button","data-test":"agent-tour-next-button",onClick:i,disabled:s>-1,className:"flex gap-2 bg-design-main text-design-text focus:text-design-text disabled:opacity-60",variant:"primary",children:[s>o&&(0,L.jsx)(bt.Spinner,{className:"m-0 h-4 text-design-main"}),(0,L.jsx)("span",{children:(0,k.__)("Next","extendify-local")})]}):(0,L.jsx)(bt.Button,{id:"agent-tour-next-button","data-test":"agent-tour-next-button",onClick:()=>{n()},className:"bg-design-main",variant:"primary",children:(0,k.__)("Done","extendify-local")})})]})},Rt=(e,t)=>({top:e.top-(t?.top??0),left:e.left-(t?.left??0),right:e.right+(t?.right??0),bottom:e.bottom+(t?.bottom??0),width:e.width+(t?.left??0)+(t?.right??0),height:e.height+(t?.top??0)+(t?.bottom??0),x:e.x-(t?.left??0),y:e.y-(t?.top??0)});var Dt=n(4685);let $t=null;const Mt=e=>{const{count:t=1,defaults:n,shots:o}=e,s=(()=>{if($t)return $t;const e=document.createElement("canvas");return e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.height="100%",e.style.pointerEvents="none",e.style.zIndex=Number.MAX_SAFE_INTEGER,document.body.appendChild(e),$t=Dt.A.create(e,{disableForReducedMotion:!0,resize:!0}),$t})();o.forEach(({ratio:e=1,...o})=>{s({...n??{},...o??{},particleCount:Math.floor(t*e),zIndex:Number.MAX_SAFE_INTEGER})})};wt()(()=>{const e="extendify-agent-tour";if(document.getElementById(e))return;const t=Object.assign(document.createElement("div"),{className:"extendify-agent-tour",id:e});(0,ht.X)((0,L.jsx)(At,{}),t);const n=document.getElementById("wpwrap")||document.querySelector(".wp-site-blocks");if((0,xt.Zz)()||document.querySelector("body.iframe")||!n)return;const o="extendify-agent-main";if(document.getElementById(o))return;const s=Object.assign(document.createElement("div"),{className:"extendify-agent",id:o});document.body.appendChild(s),(0,ht.X)((0,L.jsx)(ft,{}),s),window.extAgentData?.startOnboarding&&requestAnimationFrame(()=>{(()=>{const e={count:200,defaults:{origin:{y:.7,x:0}},shots:[{ratio:.25,spread:26,startVelocity:55},{ratio:.2,spread:60},{ratio:.35,spread:100,decay:.91,scalar:.8},{ratio:.1,spread:120,startVelocity:25,decay:.92,scalar:1.2},{ratio:.1,spread:120,startVelocity:45}]};Mt(e),Mt({...e,defaults:{origin:{y:.7,x:1}}})})()})})},4972(e,t,n){"use strict";n.d(t,{G:()=>y});var o=n(8377),s=n(4078),r=n(1455),a=n.n(r),i=n(3162),l=n(6427),c=n(3582),d=n(7143),u=n(6087),m=n(7723),p=n(6480),g=n(6942),f=n.n(g),h=n(790);const x=["image"],y=({type:e,onSave:t,onCancel:n,onSelect:r,title:g,actionLabel:y})=>{const[b,v]=(0,u.useState)(!1),[k,j]=(0,u.useState)(!1),[_,S]=(0,u.useState)(null),[C,L]=(0,u.useState)(null),T=C||_,E=(0,d.useSelect)(e=>e(c.store).getEntityRecord("postType","attachment",T),[T]),{mediaWidth:N,mediaHeight:A,mediaSourceUrl:P}=(0,s.B)(E);(0,u.useEffect)(()=>((0,o.q)(),()=>(0,o.P)()),[]),(0,u.useEffect)(()=>{const t=new AbortController;var n;return v(!0),(n=t.signal,a()({path:"/wp/v2/settings",signal:n})).then(t=>{t[e]&&S(Number(t[e]))}).finally(()=>v(!1)),()=>t.abort()},[e]);const I=e=>{e.id!==T&&(L(e.id),r?.(e))},R=e=>{(0,p.uploadMedia)({allowedTypes:x,filesList:e,onFileChange([e]){(0,i.isBlobURL)(e?.url)?v(!0):(I(e),v(!1))},onError(e){console.error({message:e})}})};return(0,h.jsx)("div",{className:"extendify-shared",children:(0,h.jsxs)(w,{children:[(0,h.jsx)(p.MediaUpload,{title:g,onSelect:I,allowedTypes:x,value:T,modalClass:"",render:({open:e})=>(0,h.jsxs)("div",{className:"relative block",children:[(0,h.jsxs)(l.Button,{className:"editor-post-featured-image__toggle extendify-assist-upload-logo relative m-0 flex h-48 w-full min-w-full justify-center border-0 bg-gray-100 p-0 text-center text-gray-900 hover:bg-gray-300 hover:text-current",onClick:e,"aria-label":T?(0,m.__)("Edit or update the image","extendify-local"):null,"aria-describedby":T?`image-${T}-describedby`:null,children:[T&&E&&!b&&(0,h.jsx)(l.ResponsiveWrapper,{naturalWidth:N,naturalHeight:A,isInline:!0,children:(0,h.jsx)("img",{className:"inset-0 m-auto block h-auto max-h-48 w-auto max-w-96",src:P,alt:""})}),b&&(0,h.jsx)(l.Spinner,{}),!T&&!b&&(y||(0,h.jsx)("div",{className:"flex flex-col",children:y}))]}),(0,h.jsx)(l.DropZone,{className:"absolute inset-0 h-full w-full",onFilesDrop:R,label:(0,m.__)("Drop images to upload","extendify-local")})]})}),(0,h.jsx)("div",{className:"mt-6",children:(0,h.jsxs)("div",{className:"flex gap-2",children:[(0,h.jsx)("button",{type:"button",onClick:()=>{L(null),S(null),n()},className:f()("w-full rounded-sm border border-gray-300 bg-white p-2 text-sm text-gray-800 hover:bg-gray-50",{"cursor-not-allowed":k}),disabled:k,children:(0,m.__)("Cancel","extendify-local")}),!C&&(0,h.jsx)(p.MediaUpload,{title:g,onSelect:I,allowedTypes:x,modalClass:"image__media-modal",render:({open:e})=>(0,h.jsx)("button",{type:"button",onClick:e,className:"w-full rounded-sm border border-design-main bg-design-main p-2 text-sm text-white hover:bg-gray-800",children:(0,m.__)("Open Media Library","extendify-local")})}),C&&(0,h.jsx)("button",{type:"button",onClick:async()=>{j(!0);try{await(t?.({imageId:C}))}catch(e){console.error(e)}finally{j(!1)}},className:f()("flex items-center justify-center w-full rounded-sm border border-design-main bg-design-main p-2 text-sm text-white hover:bg-gray-800",{"cursor-not-allowed":k}),disabled:k,children:k?(0,h.jsx)(l.Spinner,{className:"m-0"}):(0,m.__)("Save","extendify-local")})]})})]})})},w=({fallback:e=null,children:t})=>{const{checkingPermissions:n,hasUploadPermissions:o}=(0,d.useSelect)(e=>{const t=e("core");return{hasUploadPermissions:t.canUser("read","media"),checkingPermissions:!t.hasFinishedResolution("canUser",["read","media"])}});return(0,h.jsxs)(h.Fragment,{children:[n&&(0,h.jsx)(l.Spinner,{}),!n&&o?t:e]})}},4224(e,t,n){"use strict";n.d(t,{U:()=>c});var o=n(6748),s=n(6087);const r="block-style-variation-styles-inline-css",a='iframe[name="editor-canvas"]',i=".editor-styles-wrapper",l=()=>{const e=document.querySelector(a);return e?.contentDocument||document},c=({css:e,slug:t})=>{const n=(0,s.useRef)(null),[c,d]=(0,s.useState)(null),u=(0,o.rQ)();return(0,s.useEffect)(()=>{if(!e||u||!t)return;const o=document.getElementById(r);o&&(n.current||(n.current=o.innerHTML),o.innerHTML=((e,t)=>e.replaceAll(t,"natural-1"))(e,t))},[e,t,u]),(0,s.useEffect)(()=>{if(!e||!c||!u)return;const n=c.getElementById(r),o=document.querySelector(a);let s=e.replaceAll(":root",o?":root":i).replaceAll(t,"natural-1").replace(/:where\(([^)]+)\)/g,":where($1):not(.ext-vibe-container, .ext-vibe-container *)");o||(s=s.replace("body{",`${i}{`).replace(/(h[1-6](?:\s*,\s*h[1-6])*)\s*\{/g,`${i} $1{`)),n.innerHTML=s},[e,t,c,u]),(0,s.useEffect)(()=>{if(c)return;const e=setTimeout(()=>{if(c)return;const e=l();if(!e||!e.body)return;const t=e.createElement("style");t.id=r,e.body.appendChild(t),d(e)},300);return()=>clearTimeout(e)},[c]),{undoChange:(0,s.useCallback)(()=>{const e=document.getElementById(r);if(e&&n.current&&(e.innerHTML=n.current),!u)return;const t=l();t?.getElementById(r)?.remove()},[u])}}},3634(e,t,n){"use strict";n.d(t,{e:()=>i});var o=n(6939),s=n(1455),r=n.n(s),a=n(4225);const i=()=>{const{data:e,error:t,isLoading:n}=(0,a.A)({key:"site-vibes-variations",themeSlug:window.extAgentData.context.themeSlug},l);return{data:e,error:t,isLoading:n}},l=async()=>{const e=await r()({path:"/wp/v2/global-styles/themes/extendable?context=edit"}),t=e?.styles;if(!t?.blocks)return null;const n=await r()({path:"/extendify/v1/launch/options?option=extendify_siteStyle"}),s=n?.data?.vibe;return{vibes:c(t),css:{...o},currentVibe:s||"natural-1"}},c=e=>{if(!e?.blocks)return[];const t=new Set,{blocks:n}=e;for(const e of Object.values(n))if(e?.variations)for(const n of Object.keys(e.variations)){if(!n.startsWith("ext-preset--"))continue;const e=n.split("--");if(e.length>=4){const n=e[2];n&&t.add(n)}}return Array.from(t).map(e=>({name:d(e),slug:e}))},d=e=>e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")},2441(e,t,n){"use strict";n.d(t,{b:()=>m});var o=n(1548),s=n(7584),r=n(4997),a=n(7143),i=n(6087);const l="global-styles-inline-css",c=window.location.pathname,d=new URLSearchParams(window.location.search),u=c.includes("/wp-admin/post.php")&&"edit"===d.get("action"),m=({css:e,duotoneTheme:t})=>{const n=(0,i.useRef)(null),c=(0,i.useRef)(null),[d,m]=(0,i.useState)(null);(0,i.useEffect)(()=>{if(!e||u)return;const t=document.getElementById(l);t&&(n.current||(n.current=t.innerHTML),t.innerHTML=e)},[e]),(0,i.useEffect)(()=>{if(!e||!d||!u)return;const t=d.getElementById(l),n=document.querySelector('iframe[name="editor-canvas"]');t.innerHTML=e.replaceAll(":root",n?":root":".editor-styles-wrapper")},[e,d]),(0,i.useEffect)(()=>{if(d)return;const e=setTimeout(()=>{if(d)return;const e=document.querySelector('iframe[name="editor-canvas"]'),t=e?.contentDocument||document;if(!t||!t.body)return;const n=t.createElement("style");n.id=l,t.body.appendChild(n),m(t)},300);return()=>clearTimeout(e)},[d]);const p=(0,a.useSelect)(e=>{let t=e("core/block-editor")?.getBlocks?.()??[];if(t.find(e=>"core/template-part"===e.name)){const{getEditedPostContent:n}=e("core/editor");t=(0,r.parse)(n(),{})}return(0,o.w)(t)},[]);return(0,i.useEffect)(()=>{t&&(c.current&&(c.current(),c.current=null),c.current=(0,s.T)({duotoneTheme:t,dynamicDuotone:p}))},[e,t,p]),{undoChange:(0,i.useCallback)(()=>{c.current&&(c.current(),c.current=null);const e=document.getElementById(l);if(e&&n.current&&(e.innerHTML=n.current),!u)return;const t=document.querySelector('iframe[name="editor-canvas"]'),o=t?.contentDocument||document;o?.getElementById(l)?.remove()},[])}}},286(e,t,n){"use strict";n.d(t,{L:()=>s});var o=n(4997);const s=(e,t)=>{const n=(0,o.rawHandler)({HTML:e.previousContent}),s=new DOMParser,r=n=>n.map(n=>{if(["core/image","core/cover"].includes(n.name)){const o={...n.attributes},r=e.url.includes("unsplash.com")?e.url.split("?")[0]:e.url,a=o.id===e.imageId,i=o.url.startsWith(r);if(!a&&!i)return{...n,attributes:o};o.url=t.source_url||t.url,o.id=t.id,o.className&&(o.className=o.className.split(" ").filter(e=>"extendify-image-import"!==e).join(" "));const l=s.parseFromString(o.originalContent||n.originalContent||"","text/html"),c=l.querySelector("img");if(!c)return{...n,attributes:o};c.setAttribute("src",t.source_url||t.url);const d=c.className.split(" ").filter(t=>t!==`wp-image-${e.imageId}`);return d.push(`wp-image-${t.id}`),c.className=d.join(" "),o.originalContent=l.body.innerHTML,{...n,attributes:o}}if(["core/media-text"].includes(n.name)){const o={...n.attributes},s=e.url.includes("unsplash.com")?e.url.split("?")[0]:e.url,r=o?.mediaId===e.imageId,a=o?.mediaLink?.startsWith(s),i=o?.mediaUrl?.startsWith(s);return r||a||i?(o.mediaLink=t.source_url||t.url,o.mediaUrl=t.source_url||t.url,o.mediaId=t.id,o.className&&(o.className=o.className.split(" ").filter(e=>"extendify-image-import"!==e).join(" ")),{...n,attributes:o}):{...n,attributes:o}}return n.innerBlocks&&n.innerBlocks.length>0?{...n,innerBlocks:r(n.innerBlocks)}:n}),a=r(n);return(0,o.serialize)(a)}},5713(e,t,n){"use strict";n.d(t,{E:()=>s,u:()=>r});var o=n(7143);const s=()=>{const e=(0,o.select)("core/preferences").get("core","renderingModes")||{},t=(0,o.select)("core").getCurrentTheme()?.stylesheet;return e?.[t]?.page},r=async e=>{const t=(0,o.select)("core/preferences").get("core","renderingModes")||{},n=(0,o.select)("core").getCurrentTheme()?.stylesheet;return(0,o.dispatch)("core/preferences").set("core","renderingModes",{...t,[n]:{...t[n]||{},page:e}}),await new Promise(e=>requestAnimationFrame(e))}},8377(e,t,n){"use strict";n.d(t,{P:()=>i,q:()=>a});const o="media-views-important",s=e=>{const t=[];return[...e].forEach(e=>{switch(e.type){case CSSRule.STYLE_RULE:t.push(r(e));break;case CSSRule.MEDIA_RULE:t.push(`@media ${e.conditionText} {`),s(e.cssRules,t),t.push("}");break;default:t.push(e.cssText)}}),t},r=e=>{const t=[...e.style].map(t=>`${t}: ${e.style.getPropertyValue(t)} !important`);return`${e.selectorText} { ${t.join("; ")}; }`},a=()=>{if(document.getElementById(o))return;const e=(()=>{const e=document.getElementById("media-views-css");if(!e)return null;const t=s(e.sheet?.cssRules);return t?.length?`\n\t\t\tdiv:has(> .media-modal) {z-index: 999999 !important}\n\t\t\t.media-frame {\n\t\t\t\th1, h2, h3, h4, h5, h6 {\n\t\t\t\t\tfont-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif !important;\n\t\t\t\t\tcolor: #1d2327 !important;\n\t\t\t\t}\n\n\t\t\t\t.uploader-inline-content {\n\t\t\t\t\tcolor: #1d2327 !important;\n\t\t\t\t}\n\n\t\t\t\t.media-sidebar {\n\t\t\t\t\tcolor: #646970 !important;\n\t\t\t\t}\n\n\t\t\t\t.media-search-input-label,\n\t\t\t\t.load-more-count {\n\t\t\t\t\tcolor: #3c434a !important;\n\t\t\t\t}\n\t\t\t}\n\t\t ${t.join("\n")}`:null})();if(!e)return;const t=document.createElement("style");t.id=o,t.textContent=e,document.head.appendChild(t)},i=()=>{const e=document.getElementById(o);e&&e.remove()}},1548(e,t,n){"use strict";n.d(t,{w:()=>o});const o=e=>{const t=new Map,n=new Set,o=e=>{if(e&&e.length)for(const r of e){if("core/image"!==r.name){o(r.innerBlocks||[]);continue}const e=r.attributes?.url||"";if(!e||!e.startsWith("data:image/svg+xml;")||n.has(r.clientId)){o(r.innerBlocks||[]);continue}const a=r.attributes?.style?.color?.duotone,i=a?.startsWith("var:preset|duotone|")?a.slice(19):null,l=s(r.clientId,e)?.filter(Boolean);i&&l.length&&!t.has(i)&&l.forEach(e=>{t.set(e,i)}),n.add(r.clientId),o(r.innerBlocks||[])}};return o(e),Object.fromEntries(t)},s=(e,t)=>{const n=document.querySelector('iframe[name="editor-canvas"]')?.contentDocument||document;if(!n)return[];const o=n.querySelector(`[data-block="${e}"]`);if(o?.classList){const e=[];for(const t of o.classList)t.startsWith("wp-duotone-")&&e.push(t);if(e.length)return e}const s=n.querySelectorAll(`img[src="${t}"]`),r=[];for(const e of s){const t=e.closest("figure[data-block]");if(t?.classList)for(const e of t.classList)e.startsWith("wp-duotone-")&&r.push(e)}return r}},7584(e,t,n){"use strict";n.d(t,{T:()=>a});var o=n(3640);const s=()=>document.querySelector('iframe[name="editor-canvas"]')?.contentDocument||document,r=["feFuncR","feFuncG","feFuncB"],a=(()=>{const e=new Map;return({duotoneTheme:t,dynamicDuotone:n})=>{const a=[],i=s();if(i.querySelectorAll('[id^="wp-duotone-"]').forEach(i=>{const l=i.id.replace("wp-duotone-","");((t,n,a)=>{let i="";Number.isNaN(Number(t))||(i=t,t=a?.[`wp-duotone-${i}`]);const l=n?.find(e=>e.slug===t)?.colors;if(!l||2!==l.length)return!1;const c=s(),d=`wp-duotone-${i||t}`,u=c.querySelector(`svg#${d}`)||c.querySelector(`filter#${d}`);if(!u)return!1;if(!e.has(i||t)){const n={tableValues:{},cssProperty:getComputedStyle(c.documentElement).getPropertyValue(`--wp--preset--duotone--${i||t}`)};r.forEach(e=>{const t=u.querySelector(e);t&&(n.tableValues[e]=t.getAttribute("tableValues"))}),e.set(i||t,n)}const[m,p]=l.map(e=>{const{r:t,g:n,b:s}=(0,o.Mj)(e).toRgb();return{r:t/255,g:n/255,b:s/255}});return r.forEach((e,t)=>{const n=["r","g","b"][t],o=u.querySelector(e);o&&o.setAttribute("tableValues",`${m[n]} ${p[n]}`)}),c.documentElement.style.setProperty(`--wp--preset--duotone--${i||t}`,`url(#${d})`),!0})(l,t,n)&&a.push(l)}),a.length>0){let e=i.getElementById("extendify-duotone-overrides");e||(e=i.createElement("style"),e.id="extendify-duotone-overrides",i.head.appendChild(e)),e.textContent=a.map(e=>`.wp-duotone-${e} img { filter: url(#wp-duotone-${e}) !important; }`).join("\n")}return a.length>0?()=>{const t=s();a.forEach(n=>{const o=e.get(n);if(!o)return;const s=`wp-duotone-${n}`,a=t.querySelector(`svg#${s}`)||t.querySelector(`filter#${s}`);a&&(r.forEach(e=>{const t=a.querySelector(e);t&&null!==o.tableValues[e]&&(o.tableValues[e]?t.setAttribute("tableValues",o.tableValues[e]):t.removeAttribute("tableValues"))}),o.cssProperty?t.documentElement.style.setProperty(`--wp--preset--duotone--${n}`,o.cssProperty):t.documentElement.style.removeProperty(`--wp--preset--duotone--${n}`))}),t.getElementById("extendify-duotone-overrides")?.remove()}:null}})()},6748(e,t,n){"use strict";n.d(t,{M4:()=>s,U$:()=>a,qE:()=>o,rQ:()=>r});const o=(e,t,n)=>Math.max(t,Math.min(e,n)),s=()=>Date.now().toString(36)+Math.random().toString(36).slice(2),r=()=>{const e=window.location.pathname,t=new URLSearchParams(window.location.search);return e.includes("/wp-admin/post.php")&&"edit"===t.get("action")},a=()=>{const{useAgentOnboarding:e}=window.extSharedData,{context:t}=window.extAgentData;return t?.isFrontPage&&e}},9395(e,t,n){"use strict";n.d(t,{D:()=>r,o:()=>a});var o=n(1455),s=n.n(o);const r=async(e,t)=>{await s()({path:"/extendify/v1/agent/options",method:"post",data:{option:e,value:t}})},a=e=>{const t=new URLSearchParams({option:String(e)});return s()({path:`/extendify/v1/agent/options?${t.toString()}`,method:"GET"})}},8459(e,t,n){"use strict";n.d(t,{L:()=>p});var o=n(6748),s=n(1455),r=n.n(s),a=n(7723),i=n(1621),l=n(7134);const{chatHistory:c}=window.extAgentData,d=[{id:1,type:"message",details:{role:"assistant", // translators: this is the initial message in the agent chat, welcoming the user. Keep it short and friendly and follow the same markdown format and emoji. content:(0,o.U$)()?(0,a.__)("#### Your site is ready 🎉\nWant to explore other website designs?","extendify-local"):(0,a.__)("#### Your site is ready 🎉\nWant to explore other site colors?","extendify-local")}}],u="/extendify/v1/agent/chat-events",m={getItem:async()=>await r()({path:u}),setItem:async(e,t)=>await r()({path:u,method:"POST",data:{state:t}})},p=(0,i.vt)()((0,l.Zr)((0,l.lt)((e,t)=>({messages:c?.length?c.toReversed():d,getMessagesForAI:()=>{const e=[];let n=!1;for(const{type:o,details:s}of t().messages.toReversed()){const t=["completed","canceled"].includes(s.status)||["status"].includes(o)&&"workflow-canceled"===s.type;if("workflow"===o&&t)break;if("workflow-component"===o&&t)break;"message"===o&&"user"===s.role&&(n=!0),("message"!==o||n)&&"message"===o&&e.push(s)}return e.toReversed()},getLastAssistantMessage:()=>t()?.messages?.findLast(e=>"message"===e.type&&"assistant"===e.details?.role),hasMessages:()=>t().messages.length>0,addMessage:(t,n)=>{const s=(0,o.M4)();return e(e=>{const o=Math.max(0,e.messages.length-149),r={id:s,type:t,details:n};return{messages:[...e.messages.toSpliced(0,o),r]}}),s},popMessage:()=>{e(e=>({messages:e.messages?.slice(0,-1)||[]}))},clearMessages:()=>e({messages:[]})}),{name:"Extendify Agent Chat"}),{name:`extendify-agent-chat-${window.extSharedData.siteId}`,storage:(0,l.KU)(()=>m),skipHydration:!0}))},5295(e,t,n){"use strict";n.d(t,{n:()=>u});var o=n(6528),s=n(1455),r=n.n(s),a=n(1621),i=n(7134);const l={currentTour:null,currentStep:void 0,preparingStep:void 0,progress:[],...(0,o.N)(window.extAgentData.userData.tourData)?.state??{}},c="/extendify/v1/help-center/tour-data",d={getItem:async()=>await r()({path:c}),setItem:async(e,t)=>await r()({path:c,method:"POST",data:{state:t}})},u=(0,a.vt)((0,i.Zr)((0,i.lt)((e,t)=>({...l,startTour:async n=>{const{trackTourProgress:o,updateProgress:s,getStepData:r,onTourPage:a}=t();a(n?.settings?.startFrom)&&(window.dispatchEvent(new CustomEvent("extendify-agent:close")),await(n?.onStart?.(n)),n.steps=n.steps?.filter(e=>e?.showOnlyIf?.()||void 0===e?.showOnlyIf?.())||[],await(r(0,n)?.events?.beforeAttach?.(n))),e({currentTour:n,currentStep:0,preparingStep:void 0});const i=o(n.id);s(i.id,{openedCount:Number(i.openedCount)+1,lastAction:"started"})},onTourPage:(e=null)=>{const n=window.location.href;if(e?.includes(n))return!0;const{currentTour:o}=t();return o?.settings?.startFrom?.includes(n)},completeCurrentTour:async()=>{const{currentTour:n,wasCompleted:o,findTourProgress:s,updateProgress:r}=t(),a=s(n?.id);a?.id&&(o(a.id)||r(a.id,{completedAt:(new Date).toISOString(),lastAction:"completed"}),r(a.id,{completedCount:Number(a.completedCount)+1,lastAction:"completed"}),await(n?.onDetach?.()),await(n?.onFinish?.()),e({currentTour:null,currentStep:void 0}),window.dispatchEvent(new CustomEvent("extendify-agent:open")))},closeCurrentTour:async n=>{const{currentTour:o,findTourProgress:s,updateProgress:r}=t(),a=s(o?.id);if(!a?.id)return;const i={};return["redirected"].includes(n)?r(a?.id,{lastAction:n}):["closed-by-caught-error"].includes(n)?r(a?.id,{lastAction:n,errored:!0}):("closed-manually"===n&&(i.closedManuallyCount=Number(a.closedManuallyCount)+1),await(o?.onDetach?.()),await(o?.onFinish?.()),r(a?.id,{lastAction:n,...i}),e({currentTour:null,currentStep:void 0,preparingStep:void 0}),void window.dispatchEvent(new CustomEvent("extendify-agent:open")))},findTourProgress:e=>t().progress.find(t=>t.id===e),wasCompleted:e=>t().findTourProgress(e)?.completedAt,wasOpened:e=>Number(t().findTourProgress(e)?.openedCount??0)>0,isSeen:e=>t().findTourProgress(e)?.firstSeenAt,trackTourProgress:n=>{const{findTourProgress:o}=t();return o(n)||e(e=>({progress:[...e.progress,{id:n,firstSeenAt:(new Date).toISOString(),updatedAt:(new Date).toISOString(),completedAt:null,lastAction:"init",currentStep:0,openedCount:0,closedManuallyCount:0,completedCount:0,errored:!1}]})),o(n)},updateProgress:(t,n)=>{const o=n?.lastAction??"unknown";e(e=>({progress:e.progress.map(e=>e.id===t?{...e,...n,lastAction:o,updatedAt:(new Date).toISOString()}:e)}))},getStepData:(e,n=t().currentTour)=>n?.steps?.[e]??{},hasNextStep:()=>!!t().currentTour&&Number(t().currentStep)<t().currentTour.steps.length-1,nextStep:async()=>{const{currentTour:e,goToStep:n,updateProgress:o,currentStep:s}=t(),r=Number(s)+1;await n(r),o(e.id,{currentStep:r,lastAction:"next"})},hasPreviousStep:()=>!!t().currentTour&&Number(t().currentStep)>0,prevStep:async()=>{const{currentTour:e,goToStep:n,updateProgress:o,currentStep:s}=t(),r=s-1;await n(r),o(e.id,{currentStep:r,lastAction:"prev"})},goToStep:async n=>{const{currentTour:o,updateProgress:s,closeCurrentTour:r,getStepData:a}=t(),i=o;if(n<0||n>i.steps.length-1)return void r("closed-by-caught-error");s(i.id,{currentStep:n,lastAction:`go-to-step-${n}`});const l=a(n)?.events;l?.beforeAttach&&(e(()=>({preparingStep:n})),await Promise.allSettled([l.beforeAttach?.(i),new Promise(e=>setTimeout(e,300))]),e(()=>({preparingStep:void 0}))),e(()=>({currentStep:n}))}}),{name:"Extendify Tour Progress"}),{name:"extendify-help-center-tour-progress",storage:(0,i.KU)(()=>d),skipHydration:!0,partialize:e=>{const{currentTour:t,currentStep:n,preparingStep:o,...s}=e;return s}}))},3410(e,t,n){"use strict";n.d(t,{Y:()=>h});var o=n(6748),s=n(2868),r=n(284),a=n(9333),i=n(365),l=n(1455),c=n.n(l),d=n(1621),u=n(7134);const m=0===window.extAgentData.chatHistory?.length,p=(0,o.U$)()?s.default.example?.agentResponse:r.default.example?.agentResponse,g={...p.whenFinishedTool,agentResponse:p},f=new Intl.Collator(void 0,{sensitivity:"base",usage:"search"}),h=(0,d.vt)()((0,u.Zr)((0,u.lt)((e,t)=>({workflow:null,whenFinishedToolProps:null,block:null,setBlock:t=>e({block:t,blockCode:null}),blockCode:null,setBlockCode:t=>e({blockCode:t}),domToolEnabled:!1,setDomToolEnabled:n=>{t().block||e({domToolEnabled:n})},getWorkflow:()=>{const e=t().workflow,n=e?.templateId||e?.id,o=a.L.find(({id:e})=>e===n);return o?.id?{...(0,i.$N)(e,o||{}),id:e?.id}:e||null},getWorkflowByExample:e=>{const t=a.L.find(({example:t})=>0===f.compare(t?.text,e));return t?.id?t:null},getAvailableWorkflows:()=>{const e=a.L.filter(({available:e})=>e()),n=e.filter(({requires:e})=>e?.includes("block"));return t().block?n:e.filter(({id:e})=>!n.some(t=>t.id===e))},getWorkflowsByFeature:({requires:e}={})=>e?a.L.filter(({available:t,requires:n})=>t()&&(!e||n?.some(t=>e.includes(t)))):a.L.filter(({available:e})=>e()),workflowData:null,workflowHistory:window.extAgentData?.workflowHistory||[],addWorkflowResult:n=>{const o=t().workflow?.id;"completed"===n.status&&e(e=>{const t=Math.max(0,e.workflowHistory.length-10);return{workflowHistory:[{workflowId:o,...n},...e.workflowHistory.toSpliced(0,t)]}}),o&&c()({method:"POST",keepalive:!0,path:"/extendify/v1/agent/workflows",data:{workflowId:o,...n}})},mergeWorkflowData:t=>{e(e=>e.workflowData?{workflowData:{...e.workflowData,...t}}:{workflowData:t})},setWorkflow:n=>e({workflow:n?{...n,startingPage:window.location.href}:null,workflowData:t().blockCode?{previousContent:t().blockCode}:null,whenFinishedToolProps:null}),setWhenFinishedToolProps:t=>e({whenFinishedToolProps:t})}),{name:"Extendify Agent Workflows"}),{name:`extendify-agent-workflows-${window.extSharedData.siteId}`,merge:(e,t)=>m?{...t,...e,workflow:(0,o.U$)()?s.default:r.default,whenFinishedToolProps:g}:{...t,...e},partialize:e=>{const{block:t,workflowHistory:n,...o}=e;return{...o}}}))},9035(e,t,n){"use strict";n.d(t,{A:()=>b});const o=e=>new Promise(t=>{const n=setInterval(()=>{document.querySelector(e)&&(clearInterval(n),t())},50)}),s=e=>new Promise(t=>{const n=setInterval(()=>{document.querySelector(e)||(clearInterval(n),t())},50)});var r=n(7723);const a={id:"library-tour",title:(0,r.__)("Design Library","extendify-local"),message:(0,r.__)("Tour the design library","extendify-local"),settings:{allowOverflow:!0,hideDotsNav:!0,startFrom:[window.extSharedData?.showAIPageCreation?window.extSharedData.adminUrl+"post-new.php?post_type=page&ext-page-creator-close=1":window.extSharedData.adminUrl+"post-new.php?post_type=page&ext-close=1",`${window.extSharedData.adminUrl}post-new.php?post_type=page`]},onStart:async()=>{await o("#extendify-library-btn"),document.querySelector(`[aria-label="${(0,r.__)("Settings")}"].is-pressed`)?.click()},steps:[{title:(0,r.__)("Open the Pattern Library","extendify-local"),text:(0,r.__)("The Extendify pattern library can be opened by clicking the button to the left.","extendify-local"),attachTo:{element:'#extendify-library-btn [role="button"]',offset:{marginTop:0,marginLeft:(0,r.isRTL)()?-15:15},position:{x:(0,r.isRTL)()?"left":"right",y:"top"},hook:(0,r.isRTL)()?"top right":"top left"},events:{beforeAttach:()=>{}}},{title:(0,r.__)("Filter Patterns","extendify-local"),text:(0,r.__)("Click on any pattern category to refine the selection.","extendify-local"),attachTo:{element:"#extendify-library-category-control",position:{x:(0,r.isRTL)()?"left":"right",y:"top"},hook:(0,r.isRTL)()?"top right":"top left"},options:{allowPointerEvents:!0},events:{beforeAttach:async()=>(dispatchEvent(new CustomEvent("extendify::open-library")),await o("#extendify-library-category-control"))}},{title:(0,r.__)("Select a Pattern","extendify-local"),text:(0,r.__)("Simply select any pattern you wish to insert into a page by clicking on it.","extendify-local"),attachTo:{element:"#extendify-library-patterns-list",position:{x:(0,r.isRTL)()?"right":"left",y:"top"},hook:(0,r.isRTL)()?"top right":"top left"},events:{beforeAttach:async()=>{await o("#extendify-library-patterns-list")}}},{title:(0,r.__)("View the Inserted Pattern","extendify-local"),text:(0,r.__)("The selected pattern has been inserted into the page.","extendify-local"),attachTo:{element:".wp-block-group:last-child",frame:'iframe[name="editor-canvas"]',offset:{marginTop:15,marginLeft:0},position:{x:(0,r.isRTL)()?"left":"right",y:"top"},hook:(0,r.isRTL)()?"top left":"top right"},events:{beforeAttach:async()=>(document.querySelector("#extendify-library-patterns-list .library-pattern")?.click(),await s("#extendify-library-patterns-list"))},options:{hideBackButton:!0}}]},i={id:"page-creator-tour",title:(0,r.__)("AI Page Generator","extendify-local"),message:(0,r.__)("Learn about the AI Page Generator","extendify-local"),settings:{allowOverflow:!0,hideDotsNav:!0,startFrom:[window.extSharedData?.showAIPageCreation?`${window.extSharedData.adminUrl}post-new.php?post_type=page&ext-page-creator-close=1`:`${window.extSharedData.adminUrl}post-new.php?post_type=page&ext-close=1`,`${window.extSharedData.adminUrl}post-new.php?post_type=page`]},onStart:async()=>{await o('#extendify-page-creator-btn [role="button"]'),document.querySelector(`[aria-label="${(0,r.__)("Settings")}"].is-pressed`)?.click()},steps:[{title:(0,r.__)("AI Page Generator","extendify-local"),text:(0,r.__)("Press here to get started with your AI Page Generator.","extendify-local"),attachTo:{element:'#extendify-page-creator-btn [role="button"]',offset:{marginTop:0,marginLeft:(0,r.isRTL)()?-15:15},position:{x:(0,r.isRTL)()?"left":"right",y:"top"},hook:(0,r.isRTL)()?"top right":"top left"},events:{beforeAttach:async()=>{await o('#extendify-page-creator-btn [role="button"]')}}},{title:(0,r.__)("Page description","extendify-local"),text:(0,r.__)("Write a description of the page you want to create. Be as detailed as you like. We will create a page based on this description.","extendify-local"),attachTo:{element:"#extendify-page-creator-page-description",position:{x:(0,r.isRTL)()?"left":"right",y:"top"},hook:(0,r.isRTL)()?"top right":"top left"},options:{allowPointerEvents:!0},events:{beforeAttach:async()=>(dispatchEvent(new CustomEvent("extendify::open-page-creator")),await o("#extendify-page-creator-page-description"))}},{title:(0,r.__)("Site description","extendify-local"),text:(0,r.__)("If needed, update your site description here. We use this to add additional context about your website.","extendify-local"),attachTo:{element:"#extendify-page-creator-site-description",offset:{marginTop:-15,marginLeft:0},position:{x:(0,r.isRTL)()?"left":"right",y:"top"},hook:(0,r.isRTL)()?"bottom left":"bottom right"},events:{beforeAttach:async()=>{await o("#extendify-page-creator-site-description")}}},{title:(0,r.__)("Generate your page","extendify-local"),text:(0,r.__)("When ready, press here to generate your page.","extendify-local"),attachTo:{element:"#extendify-page-creator-generate-btn",offset:{marginTop:-15,marginLeft:0},position:{x:(0,r.isRTL)()?"left":"right",y:"top"},hook:(0,r.isRTL)()?"bottom left":"bottom right"},events:{beforeAttach:()=>{}},options:{hideBackButton:!0}}]};var l=n(4997);const c=()=>!!document.querySelector('iframe[name="editor-canvas"]'),d=e=>13!==e.keyCode??e.preventDefault(),u=(e="")=>`.edit-post-header-toolbar__inserter-toggle${e}, .editor-document-tools__inserter-toggle${e}`,m={id:"page-editor-tour",title:(0,r.__)("Page editor","extendify-local"),message:(0,r.__)("Tour the page editor","extendify-local"),settings:{allowOverflow:!0,startFrom:[window.extSharedData?.showAIPageCreation?`${window.extSharedData.adminUrl}post-new.php?post_type=page&ext-page-creator-close=1`:`${window.extSharedData.adminUrl}post-new.php?post_type=page&ext-close=1`,`${window.extSharedData.adminUrl}post-new.php?post_type=page`]},steps:[{title:(0,r.__)("Add a Block","extendify-local"),text:(0,r.__)("Click the plus to open the block inserter.","extendify-local"),attachTo:{element:u(),offset:{marginTop:15,marginLeft:0},position:{x:(0,r.isRTL)()?"right":"left",y:"bottom"},hook:(0,r.isRTL)()?"top right":"top left"},events:{beforeAttach:async()=>await o(u())}},{title:(0,r.__)("Block Inserter","extendify-local"),text:(0,r.__)("Add a block by clicking or dragging it onto the page.","extendify-local"),attachTo:{element:".block-editor-inserter__menu",offset:{marginTop:0,marginLeft:(0,r.isRTL)()?-15:15},position:{x:(0,r.isRTL)()?"left":"right",y:"top"},hook:(0,r.isRTL)()?"top right":"top left"},events:{beforeAttach:async()=>(document.querySelector(u(":not(.is-pressed)"))?.click(),await o(".block-editor-tabbed-sidebar")),onAttach:()=>{const e=document.querySelector(u());p.observe(e,{attributes:!0}),window.addEventListener("keydown",d)},onDetach:async()=>{p.disconnect(),window.removeEventListener("keydown",d),document.querySelector(u(".is-pressed"))?.click(),await s(".block-editor-inserter__block-list")}}},{title:(0,r.__)("Page Title","extendify-local"),text:(0,r.__)("Edit the page title by clicking it. Note: The title may or may not show up on the published page, depending on the page template used.","extendify-local"),attachTo:{element:()=>c()?'iframe[name="editor-canvas"]':".wp-block-post-title",offset:()=>({marginTop:c()?15:0,marginLeft:(0,r.isRTL)()?c()?15:-15:c()?-15:15}),position:{x:(0,r.isRTL)()?"left":"right",y:"top"},hook:()=>(0,r.isRTL)()?c()?"top left":"top right":c()?"top right":"top left"},events:{beforeAttach:async()=>{await window.wp.data.dispatch("core/editor").editPost({title:"Sample Post"})}}},{title:(0,r.__)("Blocks","extendify-local"),text:(0,r.__)("Each block will show up on the page and can be edited by clicking on it.","extendify-local"),attachTo:{element:()=>c()?'iframe[name="editor-canvas"]':".wp-block-post-content > p",offset:()=>({marginTop:c()?15:0,marginLeft:(0,r.isRTL)()?c()?15:-15:c()?-15:15}),position:{x:(0,r.isRTL)()?"left":"right",y:"top"},hook:()=>(0,r.isRTL)()?c()?"top left":"top right":c()?"top right":"top left"},events:{beforeAttach:async()=>{if(await window.wp.data.select("core/block-editor").getBlockCount()>0)return;const e=(0,l.createBlock)("core/paragraph",{content:(0,r.__)("This is a sample paragraph block. It can be several sentences long and will span multiple rows. You can add as many blocks as you'd like to the page.","extendify-local")});return await window.wp.data.dispatch("core/block-editor").insertBlock(e),c()?await window.wp.data.dispatch("core/block-editor").flashBlock(e.clientId):null}}},{title:(0,r.__)("Page and Block Settings","extendify-local"),text:(0,r.__)("Select either page or block to change the settings for the entire page or the block that is selected.","extendify-local"),attachTo:{element:".interface-interface-skeleton__sidebar",offset:{marginTop:0,marginLeft:(0,r.isRTL)()?15:-15},position:{x:(0,r.isRTL)()?"right":"left",y:"top"},hook:(0,r.isRTL)()?"top left":"top right"},events:{beforeAttach:async()=>{const e=document.querySelector(`[aria-label="${(0,r.__)("Settings")}"]:not(.is-pressed)`);e?e?.click():document.querySelector('[aria-label="Settings"]:not(.is-pressed)')?.click(),await o(".interface-interface-skeleton__sidebar"),document.querySelector('.edit-post-sidebar__panel-tab,[data-tab-id="edit-post/document"]')?.click(),await o(".editor-post-status"),document.querySelector(".edit-post-post-status button")?.click()}}},{title:(0,r.__)("Preview","extendify-local"),text:(0,r.__)("Click preview to view how your changes look on the front end of your site.","extendify-local"),attachTo:{element:".block-editor-post-preview__button-toggle,.editor-preview-dropdown__toggle",offset:{marginTop:0,marginLeft:(0,r.isRTL)()?15:-15},position:{x:(0,r.isRTL)()?"right":"left",y:"top"},hook:(0,r.isRTL)()?"top left":"top right"},events:{}},{title:(0,r.__)("Publish or Save","extendify-local"),text:(0,r.__)("Click publish or update to save the changes you have made to the page and make them live on the site.","extendify-local"),attachTo:{element:".editor-post-publish-button__button",offset:{marginTop:15},position:{x:(0,r.isRTL)()?"left":"right",y:"bottom"},hook:(0,r.isRTL)()?"top left":"top right"},events:{}}]},p=new MutationObserver(()=>{document.querySelector(u(":not(.is-pressed)"))?.click()}),g={id:"plugin-install-tour",title:(0,r.__)("Installing a plugin","extendify-local"),message:(0,r.__)("See how to install a plugin","extendify-local"),settings:{allowOverflow:!1,startFrom:[`${window.extSharedData.adminUrl}plugin-install.php`]},onStart:()=>{document.body.classList.contains("folded")&&document.querySelector("#menu-plugins").classList.add("opensub")},steps:[{title:(0,r.__)("Add New plugin menu","extendify-local"),text:(0,r.__)("Click here to access the Add Plugins page.","extendify-local"),attachTo:{element:'#menu-plugins .wp-submenu a[href="plugin-install.php"]',offset:{marginTop:0,marginLeft:(0,r.isRTL)()?-15:15},position:{x:(0,r.isRTL)()?"left":"right",y:"top"},hook:(0,r.isRTL)()?"top right":"top left"},events:{onDetach:()=>{document.body.classList.contains("folded")&&document.querySelector("#menu-plugins").classList.remove("opensub")}}},{title:(0,r.__)("Search","extendify-local"),text:(0,r.__)("Search for a plugin by name or functionality.","extendify-local"),attachTo:{element:".search-form.search-plugins",offset:{marginTop:5,marginLeft:(0,r.isRTL)()?350:-350},boxPadding:{top:-5,bottom:3,left:5,right:5},position:{x:(0,r.isRTL)()?"right":"left",y:"top"},hook:(0,r.isRTL)()?"top right":"top left"},events:{}},{title:(0,r.__)("Plugin details","extendify-local"),text:(0,r.__)("See important information about each plugin.","extendify-local"),attachTo:{element:"#the-list .plugin-card:first-child .plugin-card-bottom",offset:{marginTop:0,marginLeft:(0,r.isRTL)()?-15:15},position:{x:(0,r.isRTL)()?"left":"right",y:"bottom"},hook:(0,r.isRTL)()?"bottom right":"bottom left"},events:{}},{title:(0,r.__)("Install now","extendify-local"),text:(0,r.__)("Install the plugin. Then, press this button again to activate the plugin.","extendify-local"),attachTo:{element:"#the-list .plugin-card:first-child .install-now",offset:{marginTop:-5,marginLeft:(0,r.isRTL)()?-15:15},boxPadding:{top:5,bottom:5,left:5,right:5},position:{x:(0,r.isRTL)()?"left":"right",y:"top"},hook:(0,r.isRTL)()?"top right":"top left"},events:{}},{title:(0,r.__)("Upload Plugin","extendify-local"),text:(0,r.__)("If you have a plugin from an external source, you can upload it directly here.","extendify-local"),attachTo:{element:".upload-view-toggle",offset:{marginTop:-5,marginLeft:(0,r.isRTL)()?-15:15},boxPadding:{top:5,bottom:5,left:5,right:5},position:{x:(0,r.isRTL)()?"left":"right",y:"top"},hook:(0,r.isRTL)()?"top right":"top left"},events:{}}]},f={id:"plugin-management-tour",title:(0,r.__)("Plugin management","extendify-local"),message:(0,r.__)("Learn how to manage plugins","extendify-local"),settings:{allowOverflow:!1,startFrom:[`${window.extSharedData.adminUrl}plugins.php`]},onStart:()=>{document.body.classList.contains("folded")&&document.querySelector("#menu-plugins").classList.add("opensub")},steps:[{title:(0,r.__)("Installed Plugins menu","extendify-local"),text:(0,r.__)("Click this menu to see and manage the plugins you have installed.","extendify-local"),attachTo:{element:"#menu-plugins ul > li:nth-child(2)",offset:{marginTop:0,marginLeft:(0,r.isRTL)()?-15:15},position:{x:(0,r.isRTL)()?"left":"right",y:"top"},hook:(0,r.isRTL)()?"top right":"top left"},events:{onDetach:()=>{document.body.classList.contains("folded")&&document.querySelector("#menu-plugins").classList.remove("opensub")}}},{title:(0,r.__)("Installed plugins","extendify-local"),text:(0,r.__)("See all plugins installed on your site. This includes plugins that are active and deactivated.","extendify-local"),attachTo:{element:"tbody#the-list > tr:nth-child(1)",offset:{marginTop:15,marginLeft:0},position:{x:(0,r.isRTL)()?"left":"right",y:"bottom"},hook:(0,r.isRTL)()?"top left":"top right"},events:{}},{title:(0,r.__)("Deactivate/activate option","extendify-local"),text:(0,r.__)("Under each plugin you can activate or deactivate it.","extendify-local"),attachTo:{element:"tbody#the-list > tr:nth-child(1) > td.plugin-title",offset:{marginTop:0,marginLeft:(0,r.isRTL)()?-15:15},position:{x:(0,r.isRTL)()?"left":"right",y:"top"},hook:(0,r.isRTL)()?"top right":"top left"},events:{}},{title:(0,r.__)("Add another","extendify-local"),text:(0,r.__)("Click here to add another plugin to your site.","extendify-local"),attachTo:{element:"a.page-title-action",offset:{marginTop:-5,marginLeft:(0,r.isRTL)()?-15:15},boxPadding:{top:5,bottom:5,left:5,right:5},position:{x:(0,r.isRTL)()?"left":"right",y:"top"},hook:(0,r.isRTL)()?"top right":"top left"},events:{}}]},h={id:"site-assistant-tour",title:(0,r.__)("Site Assistant","extendify-local"),message:(0,r.__)("Tour the Site Assistant","extendify-local"),settings:{allowOverflow:!1,startFrom:[`${window.extSharedData.adminUrl}admin.php?page=extendify-assist#dashboard`]},steps:[{title:(0,r.__)("Tasks","extendify-local"),text:(0,r.__)("Now that you've created your starter site, make it your own with these follow up tasks.","extendify-local"),showOnlyIf:()=>document.getElementById("assist-tasks-module"),attachTo:{element:"#assist-tasks-module",offset:{marginTop:window.innerWidth<=1151?-15:2,marginLeft:window.innerWidth<=1151?-25:15},position:{x:(0,r.isRTL)()?"left":"right",y:"top"},hook:(0,r.isRTL)()?"top right":"top left"},events:{}},{title:(0,r.__)("Quick Links","extendify-local"),text:(0,r.__)("Easily access some of the most common items in WordPress with these quick links.","extendify-local"),attachTo:{element:"#assist-quick-links-module",offset:{marginTop:window.innerWidth<=1151?-15:2,marginLeft:window.innerWidth<=1151?-25:15},position:{x:(0,r.isRTL)()?"left":"right",y:"top"},hook:(0,r.isRTL)()?"top right":"top left"},events:{onAttach:()=>{}}},{title:(0,r.__)("Website Tools & Plugins","extendify-local"),text:(0,r.__)("See our personalized recommendations for you that will help you accomplish your goals.","extendify-local"),showOnlyIf:()=>document.querySelector("#assist-recommendations-module"),attachTo:{element:"#assist-recommendations-module",offset:{marginTop:window.innerWidth<=1151?-15:2,marginLeft:window.innerWidth<=1151?-25:15},position:{x:(0,r.isRTL)()?"left":"right",y:"top"},hook:(0,r.isRTL)()?"top right":"top left"},events:{}},{title:(0,r.__)("Visit your site","extendify-local"),text:(0,r.__)("You can always visit your site by clicking this button.","extendify-local"),attachTo:{element:"#assist-menu-bar",offset:{marginTop:20,marginLeft:(0,r.isRTL)()?5:-5},position:{x:(0,r.isRTL)()?"right":"left",y:"bottom"},hook:(0,r.isRTL)()?"top right":"top left",boxPadding:{top:5,bottom:5,left:5,right:5}},events:{}},{title:(0,r.__)("Site Assistant","extendify-local"),text:(0,r.__)("Come back to the Site Assistant any time by clicking the menu item.","extendify-local"),attachTo:{element:"#toplevel_page_extendify-assist",offset:{marginTop:0,marginLeft:(0,r.isRTL)()?-15:15},position:{x:(0,r.isRTL)()?"left":"right",y:"top"},hook:(0,r.isRTL)()?"top right":"top left"},events:{onAttach:()=>{document.body.classList.contains("folded")&&(document.body.classList.remove("folded"),document.body.classList.add("temp-open"))},onDetach:()=>{document.body.classList.contains("temp-open")&&(document.body.classList.remove("temp-open"),document.body.classList.add("folded"))}}}]},x={id:"users-screen-tour",title:(0,r.__)("Users screen","extendify-local"),message:(0,r.__)("Tour the Users screen","extendify-local"),settings:{allowOverflow:!0,startFrom:[`${window.extSharedData.adminUrl}users.php`]},onStart:()=>{document.body.classList.contains("folded")&&document.querySelector("#menu-users").classList.add("opensub")},steps:[{title:(0,r.__)("All Users menu","extendify-local"),text:(0,r.__)("Click here to view and manage the users on your site.","extendify-local"),attachTo:{element:"#menu-users ul > li:nth-child(2)",offset:{marginTop:0,marginLeft:(0,r.isRTL)()?-15:15},position:{x:(0,r.isRTL)()?"left":"right",y:"top"},hook:(0,r.isRTL)()?"top right":"top left"},events:{onDetach:()=>{document.body.classList.contains("folded")&&document.querySelector("#menu-users").classList.remove("opensub")}}},{title:(0,r.__)("Users","extendify-local"),text:(0,r.__)("See all of your users, including admin users in this table.","extendify-local"),attachTo:{element:"tbody#the-list > tr:nth-child(1)",offset:{marginTop:15,marginLeft:0},position:{x:(0,r.isRTL)()?"left":"right",y:"bottom"},hook:(0,r.isRTL)()?"top left":"top right"},events:{}},{title:(0,r.__)("Edit user information","extendify-local"),text:(0,r.__)("Click the edit button to change the user's role, manage their account, or change their profile information.","extendify-local"),attachTo:{element:"tbody#the-list > tr:nth-child(1) > td.username",offset:{marginTop:0,marginLeft:(0,r.isRTL)()?-15:15},position:{x:(0,r.isRTL)()?"left":"right",y:"top"},hook:(0,r.isRTL)()?"top right":"top left"},events:{onAttach:()=>{document.querySelector("tbody#the-list > tr:nth-child(1) > td.username .row-actions").style.left="0"},onDetach:()=>{document.querySelector("tbody#the-list > tr:nth-child(1) > td.username .row-actions").style.left="-9999em"}}},{title:(0,r.__)("Search for users","extendify-local"),text:(0,r.__)("Use the search bar to find a particular user.","extendify-local"),attachTo:{element:"p.search-box",offset:{marginTop:-5,marginLeft:(0,r.isRTL)()?15:-15},boxPadding:{top:5,bottom:5,left:5,right:5},position:{x:(0,r.isRTL)()?"right":"left",y:"top"},hook:(0,r.isRTL)()?"top left":"top right"},events:{}},{title:(0,r.__)("Add a new user","extendify-local"),text:(0,r.__)("Click the Add New button to add a new user to your site.","extendify-local"),attachTo:{element:".page-title-action",offset:{marginTop:-5,marginLeft:(0,r.isRTL)()?-15:15},boxPadding:{top:5,bottom:5,left:5,right:5},position:{x:(0,r.isRTL)()?"left":"right",y:"top"},hook:(0,r.isRTL)()?"top right":"top left"},events:{}}]};var y=n(2619);const w={"plugin-install-tour":g,"plugin-management-tour":f,"page-editor-tour":m,"library-tour":a,"users-screen-tour":x,"site-assistant-tour":h};(0,y.addFilter)("extendify.tours","extendify/extra-tours",e=>window.extSharedData?.showAIPageCreation?{...e,"page-creator-tour":i}:e);const b=(0,y.applyFilters)("extendify.tours",w)},6097(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>y});const o=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=(e,t)=>{if(!e)return[];const n=new RegExp(`^(${o(t)}.*)--(\\d+)$`,"i"),s=[],r=new Set,a=[e,...e.querySelectorAll(`[class*="${t}"]`)];for(const e of a)for(const t of e.classList){const e=t.match(n);if(!e)continue;const o=e[1],a=Number(e[2]);r.has(a)||(r.add(a),s.push({prefix:o,number:a}))}return s},r=(e,t)=>{const n=document.createElement("div");return n.innerHTML=e,s(n,t)},a=(e,t,n)=>{if(!n||!n.size)return e;const s=document.createElement("div");s.innerHTML=e;const r=new RegExp(`^${o(t)}.*--(\\d+)$`,"i"),a=s.querySelectorAll(`[class*="${t}"]`);for(const e of a){const o=Array.from(e.classList);let s=!1;for(const[e,t]of o.entries()){const a=t.match(r);if(!a)continue;const i=Number(a[1]);if(!n.has(i))continue;const l=n.get(i),c=t.replace(/--(\d+)$/,`--${l}`);c!==t&&(o[e]=c,s=!0)}o.includes(t)||(o.push(t),s=!0),s&&(e.className=o.join(" "))}return s.innerHTML};var i=n(3410),l=n(1455),c=n.n(l),d=n(6087),u=n(7723),m=n(790);const p=["is-style-ext-preset","is-style-outline"],g=({children:e})=>(0,m.jsx)("div",{className:"mb-4 ml-10 mr-2 flex flex-col rounded-lg border border-gray-300 bg-gray-50 rtl:ml-2 rtl:mr-10",children:e}),f=({children:e})=>(0,m.jsx)("div",{className:"rounded-lg border-b border-gray-300 bg-white",children:(0,m.jsx)("div",{className:"p-3",children:e})}),{context:h,abilities:x}=window.extAgentData,y={available:()=>x?.canEditPosts&&!h?.adminPage&&h?.postId&&!h?.isBlogPage&&h?.isBlockTheme&&document.querySelector(".wp-site-blocks"),id:"block-general",requires:["block"],whenFinished:{component:({inputs:e,onConfirm:t,onCancel:n,onRetry:o})=>{const{block:l}=(0,i.Y)(),[h,x]=(0,d.useState)(!0),y=(0,d.useRef)(null),w=(0,d.useCallback)(()=>{const e=document.querySelector("[data-extendify-temp-replacement]");y.current&&(e?.parentNode?.insertBefore(y.current,e),y.current=null),e&&e.remove()},[]),b=(0,d.useRef)(!1);(0,d.useEffect)(()=>()=>{b.current||w()},[]);const v=(0,d.useCallback)(()=>{w(),o()},[w,o]);return(0,d.useEffect)(()=>{c()({path:"/extendify/v1/agent/get-block-html",method:"POST",data:{blockCode:e.newContent}}).then(({content:e})=>{window.dispatchEvent(new Event("extendify-agent:remove-block-highlight"));const t=document.querySelector(`[data-extendify-agent-block-id="${l.id}"]`);if(!t&&!y.current)return n();if(y.current)return;y.current=t;const o=((e,t,n)=>{let o=e;for(const e of n){const n=s(t,e),i=r(o,e);if(!n.length||!i.length)continue;const l=new Map;for(const{prefix:e,number:t}of n)l.has(e)||l.set(e,[]),l.get(e).push(t);const c=new Map;for(const{prefix:e,number:t}of i)c.has(e)||c.set(e,[]),c.get(e).push(t);const d=new Map;for(const[e,t]of c){const n=l.get(e);if(!n)continue;const o=Math.min(t.length,n.length);for(const[e,s]of t.entries()){if(e>=o)break;s!==n[e]&&d.set(s,n[e])}}d.size&&(o=a(o,e,d))}return o})(e,t.cloneNode(!0),p),i=document.createElement("template");i.innerHTML=o||'<div style="display:none"></div>';const c=i.content.firstElementChild;if(!c)return n();const d=/^has-([\w-]+-)?(background-color|color|font-size|gradient-background)$|^has-background$|^has-text-color$/,u=new Set(c.classList);t.classList.forEach(e=>{u.has(e)||d.test(e)||c.classList.add(e)}),c.setAttribute("data-extendify-temp-replacement",!0);for(const e of[c,...c.querySelectorAll(".ext-animate--on")])e.classList.remove("ext-animate--on");t.parentNode.insertBefore(c,t.nextSibling),t.parentNode?.removeChild(t),x(!1)})},[l,e,n]),h?(0,m.jsx)(g,{children:(0,m.jsx)(f,{children:(0,u.__)("Loading...","extendify-local")})}):(0,m.jsxs)(g,{children:[(0,m.jsx)(f,{children:(0,m.jsx)("p",{className:"m-0 p-0 text-sm text-gray-900",children:(0,u.__)("The agent has made the changes in the browser. Please review and confirm.","extendify-local")})}),(0,m.jsxs)("div",{className:"flex flex-wrap justify-start gap-2 p-3",children:[(0,m.jsx)("button",{type:"button",className:"flex-1 rounded-sm border border-gray-500 bg-white p-2 text-sm text-gray-900",onClick:n,children:(0,u.__)("Cancel","extendify-local")}),(0,m.jsx)("button",{type:"button",className:"flex-1 rounded-sm border border-gray-500 bg-white p-2 text-sm text-gray-900",onClick:v,children:(0,u.__)("Try Again","extendify-local")}),(0,m.jsx)("button",{type:"button",className:"flex-1 rounded-sm border border-design-main bg-design-main p-2 text-sm text-white",onClick:async()=>{b.current=!0,await t({data:e,shouldRefreshPage:!0})},children:(0,u.__)("Save","extendify-local")})]})]})}}}},8446(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>b});var o=n(286),s=n(8459),r=n(3410),a=n(6935),i=n(9324),l=n(4866),c=n(9363),d=n(4997),u=n(6427),m=n(8443),p=n(6087),g=n(7723),f=n(790);const h=({children:e})=>(0,f.jsx)("div",{className:"mb-4 ml-10 mr-2 flex flex-col rounded-lg border border-gray-300 bg-gray-50 rtl:ml-2 rtl:mr-10",children:e}),x=({children:e})=>(0,f.jsx)("div",{className:"rounded-lg border-b border-gray-300 bg-white",children:(0,f.jsx)("div",{className:"p-3",children:e})}),{context:y,abilities:w}=window.extAgentData,b={available:()=>w?.canEditPosts&&w?.canUploadMedia&&!y?.adminPage&&y?.postId&&!y?.isBlogPage&&y?.isBlockTheme&&document.querySelector(".wp-site-blocks"),id:"block-generate-image",requires:["block"],whenFinished:{component:({inputs:e,onConfirm:t,onCancel:n,onRetry:y})=>{const[w,b]=(0,p.useState)(null),[v,k]=(0,p.useState)(!1),[j,_]=(0,p.useState)(null),[S,C]=(0,p.useState)(0),[L,T]=(0,p.useState)(!1),{imageCredits:E,updateImageCredits:N,subtractOneCredit:A,resetImageCredits:P}=(0,l.C)(),{addMessage:I,messages:R}=(0,s.L)(),{block:D}=(0,r.Y)(),$=0===Number(E.remaining),M=(0,p.useRef)(!1),q=(0,p.useRef)(!1),B=(0,p.useCallback)(()=>{if(!w)return!1;const t=document.querySelector(`[data-extendify-agent-block-id="${D?.id}"] img[src="${CSS.escape(w)}"]`);return!!t&&(t.src=e.url.replaceAll(",","%2C"),!0)},[D?.id,w,e.url]);(0,p.useEffect)(()=>{if(w)return()=>{q.current||B()}},[w]);const F=(0,p.useCallback)(()=>{B(),y()},[y,B]);return(0,p.useEffect)(()=>{0===(0,d.getBlockTypes)().length&&(0,c.registerCoreBlocks)()},[]),(0,p.useEffect)(()=>{w||$||M.current||(M.current=!0,k(!0),A(),(async()=>{try{const{imageCredits:n,images:o}=await(0,a.Fz)({prompt:e.prompt});N(n);const s=o?.[0]?.url;if(!s)throw new Error((0,g.__)("No image returned","extendify-local"));await(t=s,new Promise((e,n)=>{const o=new Image;o.onload=()=>e(t),o.onerror=n,o.src=t})),b(s)}catch(e){_(e?.message||(0,g.__)("An unknown error occurred.","extendify-local")),e?.imageCredits&&N(e.imageCredits),M.current=!1}finally{k(!1)}var t})())},[e.prompt,w,$,A,N]),(0,p.useEffect)(()=>{const e=()=>{C(e=>e+1),E.refresh&&(new Date(Number(E.refresh))>new Date||P())};0===S&&e();const t=setTimeout(e,1e3);return()=>clearTimeout(t)},[E,P,S]),(0,p.useEffect)(()=>{if(!w)return;const t=document.querySelector(`[data-extendify-agent-block-id="${D?.id}"] img[src="${CSS.escape(e.url.replaceAll(",","%2C"))}"]`);t&&(t.srcset="",t.src=w)},[w,e.url,D?.id]),(0,p.useEffect)(()=>{if(!j)return;const e=setTimeout(()=>n(),100),t=(0,g.sprintf)( // translators: A chat message shown to the user // translators: A chat message shown to the user (0,g.__)("Error generating image: %s","extendify-local"),j),o=R.at(-1)?.details?.content;return t===o||I("message",{role:"assistant",content:t,error:!0}),()=>clearTimeout(e)},[j,n,I,R]),(0,p.useEffect)(()=>{if(!$||v||w)return;const e=setTimeout(()=>n(),1500),t=(0,g.sprintf)((0,g.__)("It looks like you've run out of credits. They'll refresh in %s, so check back then.","extendify-local"),(0,m.humanTimeDiff)(new Date(Number(E.refresh)))),o=R.at(-1)?.details?.content;if(t===o)return()=>clearTimeout(e);const s=setTimeout(()=>{I("message",{role:"assistant",content:t,error:!0})},1e3);return()=>{clearTimeout(e),clearTimeout(s)}},[$,v,w,n,I,R,E.refresh]),j||!w&&$&&!v?null:v?(0,f.jsx)(h,{children:(0,f.jsx)(x,{children:(0,f.jsxs)("p",{className:"m-0 p-0 flex gap-0.5 items-center text-sm text-gray-900",children:[(0,f.jsx)(u.Spinner,{className:"my-0 h-4 w-4"}),(0,f.jsx)("span",{children:(0,g.__)("Generating image...","extendify-local")})]})})}):(0,f.jsxs)(h,{children:[(0,f.jsx)(x,{children:(0,f.jsx)("p",{className:"m-0 p-0 text-sm text-gray-900",children:(0,g.__)("Image generated successfully!","extendify-local")})}),(0,f.jsxs)("div",{className:"flex justify-start gap-2 p-3",children:[(0,f.jsx)("button",{type:"button",className:"flex-1 rounded-sm border border-gray-500 bg-white p-2 text-sm text-gray-900",onClick:n,children:(0,g.__)("Cancel","extendify-local")}),(0,f.jsx)("button",{type:"button",className:"flex-1 rounded-sm border border-gray-500 bg-white p-2 text-sm text-gray-900 disabled:opacity-50",onClick:F,disabled:L||$,children:(0,g.__)("Try Again","extendify-local")}),(0,f.jsx)("button",{type:"button",className:"flex-1 rounded border border-design-main bg-design-main p-2 text-sm text-white disabled:opacity-50",disabled:L,onClick:async()=>{if(!L){q.current=!0,T(!0);try{const n=await(0,i.GV)(null,w,"ai-generated");await t({data:{previousContent:e.previousContent,newContent:(0,o.L)(e,n)},shouldRefreshPage:!0})}catch(e){q.current=!1,T(!1),_(e?.message||(0,g.__)("Failed to save image","extendify-local"))}}},children:L?(0,g.__)("Saving...","extendify-local"):(0,g.__)("Save","extendify-local")})]}),(0,f.jsx)("div",{className:"text-pretty px-4 pb-2 text-center text-xss leading-none text-gray-700",children:(0,g.sprintf)( // translators: %1$s is the number of credits remaining, %2$s is the total credits // translators: %1$s is the number of credits remaining, %2$s is the total credits (0,g.__)("You have %1$s of %2$s daily image credits remaining.","extendify-local"),E.remaining,E.total)})]})}}}},1598(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>r});var o=n(1455),s=n.n(o);const r=async({previousContent:e,newContent:t})=>{const{postType:n,postId:o}=window.extAgentData.context,r=await s()({path:`/wp/v2/types/${encodeURIComponent(n)}`}),a=r?.rest_base||`${n}s`,i=(await s()({path:`/wp/v2/${a}/${o}?context=edit`})).content.raw.replace(e,t);await s()({path:`/wp/v2/${a}/${o}`,method:"POST",data:{content:i}})}},2853(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>a});var o=n(3410),s=n(1455),r=n.n(s);const a=async()=>{const{block:e}=o.Y.getState(),{postId:t}=window.extAgentData.context,n=await r()({path:`/extendify/v1/agent/get-block-code?postId=${t}&blockId=${e.id}`});return{previousContent:n?.block??""}}},1256(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>r});var o=n(1455),s=n.n(o);const r=async({previousContent:e,newContent:t})=>{const{postType:n,postId:o}=window.extAgentData.context,r=await s()({path:`/wp/v2/types/${encodeURIComponent(n)}`}),a=r?.rest_base||`${n}s`,i=(await s()({path:`/wp/v2/${a}/${o}?context=edit`})).content.raw.replace(e,t);await s()({path:`/wp/v2/${a}/${o}`,method:"POST",data:{content:i}})}},2628(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>r});var o=n(1455),s=n.n(o);const r=async({previousContent:e,newContent:t})=>{const{postType:n,postId:o}=window.extAgentData.context,r=await s()({path:`/wp/v2/types/${encodeURIComponent(n)}`}),a=r?.rest_base||`${n}s`,i=(await s()({path:`/wp/v2/${a}/${o}?context=edit`})).content.raw.replace(e,t);await s()({path:`/wp/v2/${a}/${o}`,method:"POST",data:{content:i}})}},8998(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>r});var o=n(1455),s=n.n(o);const r=async({imageId:e})=>{await s()({path:"/wp/v2/settings",method:"POST",data:{site_logo:e}})}},7882(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>a});var o=n(3944);const{context:s,abilities:r}=window.extAgentData,a={available:()=>r?.canUploadMedia&&!s?.adminPage&&s?.postId&&!s?.isBlogPage&&s?.isBlockTheme&&document.querySelector(".wp-site-blocks"),id:"block-update-logo",requires:["block"],whenFinished:{component:o.N}}},1804(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>y});var o=n(286),s=n(8377),r=n(3410),a=n(9363),i=n(4997),l=n(6087),c=n(7723),d=n(6480),u=n(790);const m=(0,c.__)("Open Media Library","extendify-local"),p=({children:e})=>(0,u.jsx)("div",{className:"mb-4 ml-10 mr-2 flex flex-col rounded-lg border border-gray-300 bg-gray-50 rtl:ml-2 rtl:mr-10",children:e}),g=({children:e})=>(0,u.jsx)("div",{className:"rounded-lg border-b border-gray-300 bg-white",children:(0,u.jsx)("div",{className:"p-3",children:e})}),f=({handleConfirm:e,handleCancel:t})=>(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(g,{children:(0,u.jsx)("p",{className:"m-0 p-0 text-sm text-gray-900",children:(0,c.__)("The agent has made the changes in the browser. Please review and confirm.","extendify-local")})}),(0,u.jsxs)("div",{className:"flex flex-wrap justify-start gap-2 p-3",children:[(0,u.jsx)("button",{type:"button",className:"flex-1 rounded-sm border border-gray-500 bg-white p-2 text-sm text-gray-900",onClick:t,children:(0,c.__)("Cancel","extendify-local")}),(0,u.jsx)("button",{type:"button",className:"flex-1 rounded-sm border border-design-main bg-design-main p-2 text-sm text-white",onClick:e,children:(0,c.__)("Save","extendify-local")})]})]}),{context:h,abilities:x}=window.extAgentData,y={available:()=>x?.canEditPosts&&x?.canUploadMedia&&!h?.adminPage&&h?.postId&&!h?.isBlogPage&&h?.isBlockTheme&&document.querySelector(".wp-site-blocks"),id:"block-upload-image",requires:["block"],whenFinished:{component:({inputs:e,onConfirm:t,onCancel:n})=>{const[h,x]=(0,l.useState)(!1),[y,w]=(0,l.useState)(null),{block:b}=(0,r.Y)(),v=(0,l.useCallback)(()=>{if(!y)return;const t=document.querySelector(`[data-extendify-agent-block-id="${b?.id}"] > img[src="${CSS.escape(y.url)}"]`);t&&(t.src=e.url.replaceAll(",","%2C"))},[b?.id,y,e.url]),k=(0,l.useRef)(!1);(0,l.useEffect)(()=>{if(y)return()=>{k.current||v()}},[y]);return(0,l.useEffect)(()=>{0===(0,i.getBlockTypes)().length&&(0,a.registerCoreBlocks)()},[]),(0,l.useEffect)(()=>{const e=document.createElement("style");return e.textContent=".media-modal {\n\t\t\tz-index: 999999 !important;\n\t\t}",document.head.appendChild(e),()=>e.remove()},[]),(0,l.useEffect)(()=>((0,s.q)(),()=>(0,s.P)()),[]),h?(0,u.jsx)(p,{children:(0,u.jsx)(f,{handleConfirm:async()=>{y&&(k.current=!0,await t({data:{previousContent:e.previousContent,newContent:(0,o.L)(e,y)},shouldRefreshPage:!0}))},handleCancel:n})}):(0,u.jsxs)(p,{children:[(0,u.jsx)(g,{children:(0,u.jsx)("p",{className:"m-0 p-0 text-sm text-gray-900",children:(0,c.sprintf)((0,c.__)('The agent has requested the media library. Press "%s" to upload or select an image.',"extendify-local"),m)})}),(0,u.jsxs)("div",{className:"flex justify-start gap-2 p-3",children:[(0,u.jsx)("button",{type:"button",className:"w-full rounded-sm border border-gray-500 bg-white p-2 text-sm text-gray-900",onClick:n,children:(0,c.__)("Cancel","extendify-local")}),(0,u.jsx)(d.MediaUpload,{title:(0,c.__)("Select or Upload Image","extendify-local"),onSelect:t=>{const n=document.querySelector(`[data-extendify-agent-block-id="${b?.id}"] img[src="${CSS.escape(e.url.replaceAll(",","%2C"))}"]`);n&&(n.srcset="",n.src=t.url,x(!0),w(t))},allowedTypes:["image"],modalClass:"image__media-modal",render:({open:e})=>(0,u.jsx)("button",{type:"button",className:"w-full rounded-sm border border-design-main bg-design-main p-2 text-sm text-white",onClick:e,children:m})})]})]})}}}},439(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>c});var o=n(6087),s=n(7723),r=n(790);const{homeUrl:a}=window.extSharedData||{},{context:i,abilities:l}=window.extAgentData,c={available:()=>!["page","post"].includes(i?.adminPage)&&i.isBlockTheme&&l.canEditPosts,id:"create-page",whenFinished:{component:({inputs:e,onConfirm:t})=>{const n=(0,o.useCallback)(()=>{const n=e.postId?`${a}/?page_id=${e.postId}`:"";t({redirectUrl:n})},[e.postId,t]);return(0,r.jsxs)("div",{className:"mb-4 ml-10 mr-2 flex flex-col rounded-lg border border-gray-300 bg-gray-50 rtl:ml-2 rtl:mr-10",children:[(0,r.jsx)("div",{className:"rounded-lg border-b border-gray-300 bg-white",children:(0,r.jsx)("div",{className:"p-3",children:(0,r.jsx)("p",{className:"m-0 p-0 text-sm text-gray-900",children:(0,s.__)("The agent has finished creating your page. Press take me there to visit your new page or dismiss to remove this notice.","extendify-local")})})}),(0,r.jsxs)("div",{className:"flex justify-start gap-2 p-3",children:[(0,r.jsx)("button",{type:"button",className:"w-full rounded-sm border border-gray-500 bg-white p-2 text-sm text-gray-900",onClick:t,children:(0,s.__)("Dismiss","extendify-local")}),(0,r.jsx)("button",{type:"button",className:"w-full rounded-sm border border-design-main bg-design-main p-2 text-sm text-white",onClick:n,children:(0,s.__)("Take me there","extendify-local")})]})]})}}}},1352(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>a});var o=n(6087);const{abilities:s,context:r}=window.extAgentData,a={available:()=>s?.canEditPost&&r?.usingBlockEditor&&r?.adminPage&&r?.postId,id:"edit-post-strings-editor",whenFinished:{component:({inputs:e,onConfirm:t})=>((0,o.useEffect)(()=>{const n=requestAnimationFrame(()=>{t({data:e})});return()=>cancelAnimationFrame(n)},[e,t]),null)}}},1429(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>c});var o=n(6087),s=n(7723),r=n(790);const a=e=>{const t=document.getElementById("extendify-agent-chat"),n=e=>t?.contains(e),o=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT,null,!1);let s=o.nextNode();for(;s;){const t=s;if(s=o.nextNode(),!n(t.parentNode))for(const{original:n,updated:o}of e??[]){const e=t.nodeValue??"";e.includes(n)&&(t.nodeValue=e.split(n).join(o))}}["alt","title","aria-label","href","data-id"].forEach(t=>{document.querySelectorAll(`[${t}]`).forEach(o=>{if(!n(o))for(const{original:n,updated:s}of e??[]){const e=o.getAttribute(t);e?.includes(n)&&o.setAttribute(t,e.split(n).join(s))}})})},{context:i,abilities:l}=window.extAgentData,c={available:()=>l?.canEditPosts&&!i?.adminPage&&i?.postId&&!i?.isBlogPage&&i.usingBlockEditor,id:"edit-post-strings",whenFinished:{component:({inputs:e,onConfirm:t,onCancel:n,onRetry:i})=>{const l=(0,o.useCallback)(()=>{const t=(e.replacements||[]).map(({original:e,updated:t})=>({original:t,updated:e}));a(t)},[e]),c=(0,o.useRef)(!1);(0,o.useEffect)(()=>()=>{c.current||l()},[]);const d=(0,o.useCallback)(()=>{l(),i()},[l,i]);return(0,o.useEffect)(()=>{a(e.replacements)},[e.replacements]),(0,r.jsxs)("div",{className:"mb-4 ml-10 mr-2 flex flex-col rounded-lg border border-gray-300 bg-gray-50 rtl:ml-2 rtl:mr-10",children:[(0,r.jsx)("div",{className:"rounded-lg border-b border-gray-300 bg-white",children:(0,r.jsx)("div",{className:"p-3",children:(0,r.jsx)("p",{className:"m-0 p-0 text-sm text-gray-900",children:(0,s.__)("The agent has made the changes in the browser. Please review and confirm.","extendify-local")})})}),(0,r.jsxs)("div",{className:"flex flex-wrap justify-start gap-2 p-3",children:[(0,r.jsx)("button",{type:"button",className:"flex-1 rounded-sm border border-gray-500 bg-white p-2 text-sm text-gray-900",onClick:n,children:(0,s.__)("Cancel","extendify-local")}),(0,r.jsx)("button",{type:"button",className:"flex-1 rounded-sm border border-gray-500 bg-white p-2 text-sm text-gray-900",onClick:d,children:(0,s.__)("Try Again","extendify-local")}),(0,r.jsx)("button",{type:"button",className:"flex-1 rounded-sm border border-design-main bg-design-main p-2 text-sm text-white",onClick:()=>{c.current=!0,t({data:e})},children:(0,s.__)("Save","extendify-local")})]})]})}}}},8942(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>k});var o=n(9246),s=n(8579),r=n(6572),a=n(9130),i=n(202),l=n(6727),c=n(7828),d=n(8512),u=n(1455),m=n.n(u),p=n(9363),g=n(4997),f=n(7143),h=n(3656),x=n(6087),y=n(790);const{pageTitlePattern:w}=window.extPageCreator??{},b=({pageDescription:e,onComplete:t})=>{const{page:n,loading:o}=(0,s.f)(),{setDescription:c}=(0,a.C)(),{editPost:d}=(0,f.useDispatch)(h.store),[u,m]=(0,x.useState)([]),y=(0,x.useRef)(!1),{theme:b,templates:k}=(0,f.useSelect)(e=>{const t=e("core"),n=t.getCurrentTheme();return{theme:n,templates:t.getEntityRecords("postType","wp_template",{per_page:-1,context:"edit",theme:n?.stylesheet})}},[]);return(0,x.useEffect)(()=>{0===(0,g.getBlockTypes)().length&&(0,p.registerCoreBlocks)()},[]),(0,x.useEffect)(()=>{c(e)},[e,c]),(0,x.useEffect)(()=>{!n&&o||y.current||(y.current=!0,(async()=>{await(0,l.D)(w);const e=await(0,r.d)(n?.patterns);await(0,i.Y)({patterns:e}),m(e)})())},[o,n,m]),(0,x.useEffect)(()=>{if(!u?.length||!y.current)return;if(!b||!Array.isArray(k))return;const e="extendable"===b.textdomain&&k.some(e=>"page-with-title"===e.slug),o=setTimeout(async()=>{const o=await v({hasPageWithTitle:e,patterns:u,title:n.title});t(o)},3e4);return()=>clearTimeout(o)},[u,d,n,b,k,t]),null},v=async({hasPageWithTitle:e,patterns:t,title:n})=>{const s=(e?t.filter(e=>!e.patternTypes?.includes("page-title")):t).map(({code:e,...t})=>({...t,code:e.replace(/href="#extendify-([^"]+)"/g,'href="#"')})),r=s.map(({code:e})=>e).join(""),a=(0,g.rawHandler)({HTML:r}),i=[],l=new Set;for(const[e,t]of a.entries()){const n=s[e].patternTypes?.[0],r=(0,g.serialize)(t),{slug:a}=Object.values(d.Q).find(({alias:e})=>e.includes(n))||{};!l.has(a)&&a?(l.add(a),i.push((0,o.f)(r,a))):i.push(r)}const c={title:n,status:"draft",content:i.join(""),template:e?"page-with-title":"no-title-sticky-header",meta:{made_with_extendify_launch:!0}};return await m()({path:"/wp/v2/pages",method:"POST",data:c})},k=async({pageDescription:e})=>{if(!e||0===e.trim().length)throw new Error("Page description cannot be empty");const t=await(e=>new Promise((t,n)=>{const o=document.createElement("div");o.style.display="none",document.body.appendChild(o);let s=!1;const r=()=>{o.parentNode&&o.remove()};try{(0,c.X)((0,y.jsx)(b,{onComplete:e=>{(e=>{s||(s=!0,r(),e?t(e):n(new Error("Something went wrong while creating the page")))})(e)},pageDescription:e}),o)}catch(e){r(),n(e)}}))(e);if(!t?.id)throw new Error("Page creation failed");return{postId:Number(t.id)}}},3571(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>a});var o=n(1455),s=n.n(o);const r={page:"pages",post:"posts"},a=async({postId:e,postType:t})=>{const n=r[t]||t;return{post_status:(await s()({path:`/wp/v2/${n}/${e}?context=view`})).status}}},5261(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>r});var o=n(5713),s=n(7143);const r=async()=>{const e=(0,o.E)();"template-locked"===e&&await(0,o.u)("post-only");const t=(0,s.select)("core/block-editor").getBlocks(),n=(0,s.select)("core/editor").getEditedPostAttribute("title"),r=l([n,...a(t)]);return"template-locked"===e&&(0,o.u)("template-locked"),{post_strings:r}},a=e=>e.flatMap(e=>[...["content","caption","alt","title","value"].map(t=>"string"==typeof e?.attributes?.[t]?e.attributes[t].trim():null).map(()=>"string"==typeof e?.attributes?.text?.text?e.attributes.text.text.trim():null).filter(Boolean),...e.originalContent?[c(e.originalContent),...d(e.originalContent)].filter(Boolean):[],...a(e.innerBlocks||[])]),i=e=>new Set(e.filter(Boolean)),l=e=>[...i(e)],c=e=>e.replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim(),d=e=>{const t=[],n=e.match(/alt="([^"]*)"/);n?.[1]&&t.push(n[1].trim());const o=e.match(/title="([^"]*)"/);return o?.[1]&&t.push(o[1].trim()),t}},1557(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>a});var o=n(1455),s=n.n(o);const r=window.wp.blockSerializationDefaultParser,a=async({postId:e,postType:t})=>{const n="page"===t?"pages":"posts",o=await s()({path:`/wp/v2/${n}/${e}?context=edit`}),a=(0,r.parse)(o.content.raw),i=[o.title.raw,...u(a)],c=[...new Set([...document.querySelectorAll("[data-extendify-part-slug]")].map(e=>e.dataset.extendifyPartSlug))];if(!c.length)return{post_strings:l(i),parts_used:[]};let d=[];try{d=await s()({path:"/wp/v2/template-parts?per_page=100&context=edit"})}catch{try{await new Promise(e=>setTimeout(e,1e3)),d=await s()({path:"/wp/v2/template-parts?per_page=100&context=edit"})}catch{}}const m=d.filter(e=>c.includes(e.slug)).map(e=>{const t=(0,r.parse)(e.content.raw);return i.push(...u(t)),{id:e.id,area:e.area}});return{post_strings:l(i),parts_used:m}},i=e=>new Set(e.filter(Boolean)),l=e=>[...i(e)],c=e=>e.replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim(),d=e=>{const t=[],n=e.match(/alt="([^"]*)"/);n?.[1]&&t.push(n[1].trim());const o=e.match(/title="([^"]*)"/);return o?.[1]&&t.push(o[1].trim()),t},u=e=>e&&0!==e.length?e.flatMap(e=>[...e.innerContent?e.innerContent.filter(Boolean).flatMap(e=>[c(e),...d(e)]).filter(Boolean):[],...["content","caption","alt","title","value"].map(t=>"string"==typeof e.attrs?.[t]?e.attrs[t].trim():null).filter(Boolean),...u(e.innerBlocks||[])]):[]},9982(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>a});var o=n(1455),s=n.n(o);const r={page:"pages",post:"posts"},a=async({postId:e,postType:t,updatedStatus:n})=>{const o=r[t]||t;return await s()({path:`/wp/v2/${o}/${e}?context=edit`,method:"POST",data:{status:n}})}},5092(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>a});var o=n(5713),s=n(4997),r=n(7143);const a=async({replacements:e})=>{const t=(0,o.E)();"template-locked"===t&&await(0,o.u)("post-only");const n=(0,r.select)("core/editor").getEditedPostAttribute("title"),s=i(n,e);(0,r.dispatch)("core/editor").editPost({title:s}),(0,r.select)("core/block-editor").getBlocks().flatMap(t=>l(t,e)).forEach(({clientId:e,block:t})=>{(0,r.dispatch)("core/block-editor").replaceBlock(e,t)}),"template-locked"===t&&(0,o.u)("template-locked")},i=(e,t)=>t.filter(e=>""!==e.original).reduce((e,{original:t,updated:n})=>e.split(t).join(n),e),l=(e,t)=>{const n=[],o={...e.attributes};let r=!1;if(["content","caption","alt","title","value","text"].forEach(e=>{const n=o[e],s=n&&"function"==typeof n.toString?n.toString():n;if("string"==typeof s){const n=i(s,t);n!==s&&(o[e]=n,r=!0)}}),r){const t=(0,s.createBlock)(e.name,o,e.innerBlocks);n.push({clientId:e.clientId,block:t})}return e.innerBlocks.forEach(e=>{n.push(...l(e,t))}),n}},6636(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>r});var o=n(1455),s=n.n(o);const r=async({postId:e,postType:t,replacements:n})=>{const o="page"===t?"pages":"posts",r=await s()({path:`/wp/v2/${o}/${e}?context=edit`});let a=r.content.raw,i=r.title.raw;const l=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");for(const{original:e,updated:t}of n){const n=new RegExp(l(e),"g");a=a.replace(n,t),i=i.split(e).join(t)}const c=await s()({path:`/wp/v2/${o}/${e}`,method:"POST",data:{content:a,title:i}}),d=[...new Set([...document.querySelectorAll("[data-extendify-part-slug]")].map(e=>e.dataset.extendifyPartSlug))];if(d.length>0)try{const e=(await s()({path:"/wp/v2/template-parts?per_page=100&context=edit"})).filter(e=>d.includes(e.slug));for(const t of e){let e=t.content.raw,o=!1;for(const{original:t,updated:s}of n){const n=new RegExp(l(t),"g");n.test(e)&&(e=e.replace(n,s),o=!0)}o&&await s()({path:`/wp/v2/template-parts/${t.id}`,method:"POST",data:{content:e}})}}catch{}return c}},9133(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>o});const o=()=>({success:!0})},1755(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>c});var o=n(6087),s=n(7723),r=n(790);const a={draft:(0,s.__)("Draft"),publish:(0,s.__)("Published")},{context:i,abilities:l}=window.extAgentData,c={available:()=>l?.canEditPosts&&!i?.adminPage&&i?.postId,id:"update-post-status",whenFinished:{component:({inputs:e,onConfirm:t,onCancel:n})=>{const i=(0,o.useCallback)(()=>{n()},[n]);return(0,r.jsxs)("div",{className:"mb-4 ml-10 mr-2 flex flex-col rounded-lg border border-gray-300 bg-gray-50 rtl:ml-2 rtl:mr-10",children:[(0,r.jsx)("div",{className:"rounded-lg border-b border-gray-300 bg-white",children:(0,r.jsx)("div",{className:"p-3",children:(0,r.jsx)("p",{className:"m-0 p-0 text-sm text-gray-900",children:(0,s.sprintf)( // translators: %1$s is the current page or post status, and %2$s is the updated page or post status. // translators: %1$s is the current page or post status, and %2$s is the updated page or post status. (0,s.__)('Status will change from "%s" to "%s", please confirm to save.',"extendify-local"),a[e.postStatus],a[e.updatedStatus])})})}),(0,r.jsxs)("div",{className:"flex justify-start gap-2 p-3",children:[(0,r.jsx)("button",{type:"button",className:"w-full rounded-sm border border-gray-500 bg-white p-2 text-sm text-gray-900",onClick:i,children:(0,s.__)("Cancel","extendify-local")}),(0,r.jsx)("button",{type:"button",className:"w-full rounded-sm border border-design-main bg-design-main p-2 text-sm text-white",onClick:()=>{window?.extAgentData?.context&&(window.extAgentData.context.postStatus=e.updatedStatus),t({data:e})},children:(0,s.__)("Confirm","extendify-local")})]})]})}}}},3364(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>s});var o=n(8969);const s=async({query:e})=>{const t={documentation:"No relevant documentation found"},n=new URLSearchParams({search:e}),s=await fetch(`${o.XQ}/api/posts?${n.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"}}).catch(()=>({ok:!1}));if(!s.ok)return t;const r=await s.json();if(!r?.[0]?.slug)return t;const a=await fetch(`${o.XQ}/api/posts/${r?.[0]?.slug}`,{method:"GET",headers:{"Content-Type":"application/json"}}).catch(()=>({ok:!1}));if(!a.ok)return t;const i=await a.json();return i?.content?{documentation:i.content}:t}},7806(e,t,n){"use strict";n.d(t,{L:()=>d,e:()=>c});var o=n(5295),s=n(9035),r=n(319),a=n(5506),i=n(790);const l=Object.values(s.A),c=({onConfirm:e})=>{if(0!==l.length)return(0,i.jsxs)("div",{className:"flex w-full items-start gap-2.5 p-2",children:[(0,i.jsx)("div",{className:"w-7 flex-shrink-0"}),(0,i.jsx)("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:l.map(t=>(0,i.jsx)(d,{tour:t,onClick:()=>{e?.()}},t.id))})]})},d=({tour:e,onClick:t})=>{const{startTour:n}=(0,o.n)();return(0,i.jsxs)("div",{className:"group relative flex items-center",children:[(0,i.jsx)("div",{className:"pointer-events-none absolute inset-0 rounded-sm opacity-10 transition-opacity duration-100 group-hover:bg-design-main"}),(0,i.jsxs)("button",{type:"button",className:"flex w-full items-center gap-2 rounded-sm border border-gray-300 bg-transparent p-3 text-left text-sm leading-none text-gray-900 focus:outline-hidden focus:ring-wp focus:ring-design-main group-hover:ring-wp group-hover:ring-design-main",onClick:()=>{n(e),t?.()},children:[(0,i.jsx)(r.A,{icon:a.A,className:"h-6 w-6 fill-gray-700 leading-none"}),e.message]})]})}},5749(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>o});const o={available:()=>!0,id:"list-tours",whenFinished:{component:n(7806).e}}},7275(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>f});var o=n(6935),s=n(9324),r=n(6087),a=n(7723),i=n(319),l=n(2344),c=n(790);const d=({onClick:e})=>(0,c.jsx)("button",{type:"button",className:"w-full rounded-sm border border-gray-500 bg-white p-2 text-sm text-gray-900",onClick:e,children:(0,a.__)("Cancel","extendify-local")}),u=({onClick:e,text:t})=>(0,c.jsx)("button",{type:"button",className:"w-full rounded-sm border border-design-main bg-design-main p-2 text-sm text-white",onClick:e,children:t}),m=({children:e})=>(0,c.jsx)("div",{className:"mb-4 ml-10 mr-2 flex flex-col rounded-lg border border-gray-300 bg-gray-50 rtl:ml-2 rtl:mr-10",children:e}),p=({children:e})=>(0,c.jsx)("div",{className:"rounded-lg border-b border-gray-300 bg-white",children:(0,c.jsx)("div",{className:"p-3",children:e})}),{abilities:g}=window.extAgentData,f={available:()=>g.canInstallPlugins&&g.canActivatePlugins,id:"recommend-plugins",whenFinished:{component:({inputs:e,onConfirm:t,onCancel:n})=>{const[g,f]=(0,r.useState)("idle"),h=()=>{f("installing")};return(0,r.useEffect)(()=>{if(!e.alreadyInstalled)return;const t=requestAnimationFrame(()=>{n?.()});return()=>cancelAnimationFrame(t)},[e,n]),(0,r.useEffect)(()=>{let n=!1;return(async()=>{if("installing"!==g){if("activating"===g){try{await(0,s.Bf)(e.pluginSlug)}catch{try{await new Promise(e=>setTimeout(e,500)),await(0,s.Bf)(e.pluginSlug)}catch{return void(n||f("error"))}}if(n)return;try{await(0,o.yB)({slug:e.pluginSlug,source:"ai-agent-recommendation"}),await new Promise(e=>{const{adminUrl:t}=window.extSharedData,n=Object.assign(document.createElement("iframe"),{title:"Admin Loader",src:t,style:"display: none;",sandbox:"allow-same-origin allow-scripts allow-forms",onload:()=>{document.body.removeChild(n),e()}});document.body.appendChild(n)}),n||t({shouldRefreshPage:!0})}catch{n||f("error")}}}else try{if(await(0,s.xZ)(e.pluginSlug),n)return;f("activating")}catch(e){if(n)return;if("folder_exists"===e?.code)return void f("activating");f("error")}})(),()=>{n=!0}},[g,t,e]),"error"===g?(0,c.jsxs)(m,{children:[(0,c.jsx)(p,{children:(0,c.jsx)("p",{className:"m-0 p-0 text-sm text-gray-900",children:(0,a.__)("There was an error installing the plugin. You may try again","extendify-local")})}),(0,c.jsxs)("div",{className:"flex justify-start gap-2 p-3",children:[(0,c.jsx)(d,{onClick:n}),(0,c.jsx)(u,{onClick:h,text:(0,a.__)("Try Again","extendify-local")})]})]}):["installing","activating"].includes(g)?(0,c.jsx)(m,{children:(0,c.jsx)(p,{children:(0,c.jsx)("p",{className:"m-0 p-0 text-sm text-gray-900",children:"installing"===g?(0,a.__)("Installing plugin...","extendify-local"):(0,a.__)("Activating plugin...","extendify-local")})})}):(0,c.jsxs)(m,{children:[(0,c.jsx)(p,{children:(0,c.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,c.jsx)("p",{className:"m-0 p-0 text-sm text-gray-900",children:(0,a.__)("The agent is requesting to install and activate a plugin.","extendify-local")}),(0,c.jsxs)("div",{className:"flex-col gap-1",children:[e.pluginName&&(0,c.jsx)("div",{className:"flex-1 font-bold",children:e.pluginName}),(0,c.jsxs)("a",{className:"text-xs flex flex-1 items-end text-gray-900 hover:text-gray-900 hover:decoration-solid",href:`https://wordpress.org/plugins/${e.pluginSlug}`,target:"_blank",rel:"noopener noreferrer",children:[(0,c.jsx)("span",{dangerouslySetInnerHTML:{__html:(0,a.sprintf)( // translators: %1$s and %2$s are HTML tags. %1$s opens a span with screen-reader-only text, and %2$s closes that span. // translators: %1$s and %2$s are HTML tags. %1$s opens a span with screen-reader-only text, and %2$s closes that span. (0,a.__)("Plugin Details %1$s(opens in a new tab)%2$s","extendify-local"),'<span class="sr-only">',"</span>")}}),(0,c.jsx)(i.A,{className:"ml-1 inline-block",icon:l.A,size:18})]})]})]})}),(0,c.jsxs)("div",{className:"flex justify-start gap-2 p-3",children:[(0,c.jsx)(d,{onClick:n}),(0,c.jsx)(u,{onClick:h,text:(0,a.__)("Install Plugin","extendify-local")})]})]})}}}},4679(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>o});const o=()=>null},8402(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>s});const o=["short_description","description","sections","tested","requires","rating","ratings","downloaded","downloadlink","last_updated","added","tags","versions","contributors","banners","icons","compatibility"].map(e=>`request[fields][${e}]=0`).join("&"),s=async({query:e})=>{const t=`https://api.wordpress.org/plugins/info/1.2/?action=query_plugins&request[search]=${encodeURIComponent(e)}&request[per_page]=1&${o}`;try{const e=await fetch(t);if(!e.ok)return{pluginSearchResult:null};const n=await e.json(),o=n?.plugins?.[0];return o?.slug?{pluginSearchResult:{slug:o.slug,name:o.name}}:{pluginSearchResult:null}}catch{return{pluginSearchResult:null}}}},9586(e,t,n){"use strict";n.r(t),n.d(t,{allowedSettings:()=>i,default:()=>l});var o=n(6087),s=n(7723),r=n(790);const{abilities:a}=window.extAgentData,i=["posts_per_page","use_smilies","start_of_week","time_format","date_format","title","description"],l={available:()=>a?.canEditSettings,id:"edit-wp-setting",whenFinished:{component:({inputs:e,onConfirm:t,onCancel:n})=>{const a=(0,o.useRef)(null),i=(0,o.useRef)(""),l=(0,o.useCallback)(()=>{a.current&&(a.current.textContent=i.current)},[]),c=(0,o.useRef)(!1);return(0,o.useEffect)(()=>()=>{c.current||l()},[]),(0,o.useEffect)(()=>{const t=document.querySelector(".wp-block-site-title");if(!a.current&&t&&(a.current=t,i.current=t.textContent??""),!e)return;const{settingName:n,newSettingValue:o}=e;"title"===n&&a.current&&(a.current.textContent=o)},[e,a]),(0,r.jsxs)("div",{className:"mb-4 ml-10 mr-2 flex flex-col rounded-lg border border-gray-300 bg-gray-50 rtl:ml-2 rtl:mr-10",children:[(0,r.jsx)("div",{className:"rounded-lg border-b border-gray-300 bg-white",children:(0,r.jsx)("div",{className:"p-3",children:(0,r.jsx)("p",{className:"m-0 p-0 text-sm text-gray-900",children:(0,s.__)("Apply this setting change?","extendify-local")})})}),(0,r.jsxs)("div",{className:"flex justify-start gap-2 p-3",children:[(0,r.jsx)("button",{type:"button",className:"w-full rounded-sm border border-gray-500 bg-white p-2 text-sm text-gray-900",onClick:n,children:(0,s.__)("Cancel","extendify-local")}),(0,r.jsx)("button",{type:"button",className:"w-full rounded-sm border border-design-main bg-design-main p-2 text-sm text-white",onClick:()=>{c.current=!0,t({data:e,shouldRefreshPage:!0})},children:(0,s.__)("Confirm","extendify-local")})]})]})}}}},3508(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>i});var o=n(9586),s=n(1455),r=n.n(s),a=n(7723);const i=async({settingName:e})=>{if(!o.allowedSettings.includes(e))throw new Error("Setting not allowed");return{oldSettingValue:(await r()({path:"/wp/v2/settings?context=edit"}))[e]|| // translators: No value found message for when a WP setting has no value. // translators: No value found message for when a WP setting has no value. (0,a.__)("No value found","extendify-local")}}},8795(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>a});var o=n(9586),s=n(1455),r=n.n(s);const a=async({settingName:e,newSettingValue:t})=>{if(!o.allowedSettings.includes(e))throw new Error("Setting not allowed");return await r()({path:"/wp/v2/settings?context=edit",method:"POST",data:{[e]:t}})}},2130(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>d});var o=n(1455),s=n.n(o),r=n(6087),a=n(7723),i=n(790);const{abilities:l,context:c}=window.extAgentData,d={available:()=>l?.canEditPost&&c?.usingBlockEditor&&!c?.adminPage&&["post","page"].includes(c.postType)&&window.document.querySelectorAll("nav[data-extendify-menu-id]").length>0&&c?.postId,id:"add-post-to-menu",whenFinished:{component:({inputs:e,onConfirm:t,onCancel:n})=>{const[o,l]=(0,r.useState)(""),{replacements:c,id:d}=e??{},u=(0,r.useCallback)(()=>{const e=document.querySelector(`[data-extendify-menu-id="${d}"]`);e&&o&&(e.innerHTML=o)},[d,o]),m=(0,r.useRef)(!1);return(0,r.useEffect)(()=>{if(o)return()=>{m.current||u()}},[o]),(0,r.useEffect)(()=>{const e=document.querySelector(`[data-extendify-menu-id="${d}"]`);if(!e)return;l(e.innerHTML);const t=new AbortController;return(async()=>{try{const n=await s()({method:"POST",path:"/extendify/v1/agent/render-navigation",data:{content:c?.[0]?.updated},signal:t.signal});e&&n&&(e.innerHTML=n)}catch(e){if("AbortError"===e.name)throw e;console.error("Failed to render navigation:",e)}})(),()=>t.abort()},[c,d,l]),(0,i.jsxs)("div",{className:"mb-4 ml-10 mr-2 flex flex-col rounded-lg border border-gray-300 bg-gray-50 rtl:ml-2 rtl:mr-10",children:[(0,i.jsx)("div",{className:"rounded-lg border-b border-gray-300 bg-white",children:(0,i.jsx)("div",{className:"p-3",children:(0,i.jsx)("p",{className:"m-0 p-0 text-sm text-gray-900",children:(0,a.__)("The agent has made the changes in the browser. Please review and confirm.","extendify-local")})})}),(0,i.jsxs)("div",{className:"flex justify-start gap-2 p-3",children:[(0,i.jsx)("button",{type:"button",className:"w-full rounded-sm border border-gray-500 bg-white p-2 text-sm text-gray-900",onClick:n,children:(0,a.__)("Cancel","extendify-local")}),(0,i.jsx)("button",{type:"button",className:"w-full rounded-sm border border-design-main bg-design-main p-2 text-sm text-white",onClick:()=>{m.current=!0,t({data:e})},children:(0,a.__)("Save","extendify-local")})]})]})}}}},8757(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>b});var o=n(9395),s=n(6427),r=n(6087),a=n(7723),i=n(6101),l=n(6656),c=n(8972),d=n(6039),u=n(319),m=n(6942),p=n.n(m),g=n(790);const f=[{ // translators: Animation style where the element gradually appears by transitioning from transparent to visible. Translate as a simple, non-technical description of the visual effect (e.g., 'appear', 'show up') suitable for non-technical users. name:(0,a._x)("Fade In","animation type","extendify-local"),slug:"fade",icon:i.A},{ // translators: Animation style where the element appears while moving upward. Translate as a simple, non-technical description of the motion (e.g., 'appear from below', 'rise into view') suitable for non-technical users. name:(0,a._x)("Fade Up","animation type","extendify-local"),slug:"fade-up",icon:l.A},{ // translators: Animation style where the element appears by scaling from small to its full size. Translate as a simple, non-technical description of the effect (e.g., 'zoom in', 'get closer') suitable for non-technical users. If the target language commonly uses the English term 'zoom', it's acceptable to keep it. name:(0,a._x)("Zoom In","animation type","extendify-local"),slug:"zoom-in",icon:c.A},{ // translators: None refers to 'no animation'. Apply the correct grammatical gender/form that agrees with the word for 'animation' in the target language. name:(0,a._x)("None","animation type","extendify-local"),slug:"none",icon:d.A}],h=[{ // translators: "Slow" refers to a slower speed at which the animation effect occurs. This is an option in a list of animation speeds. name:(0,a._x)("Slow","animation speed","extendify-local"),slug:"slow"},{ // translators: "Medium" refers to a moderate speed at which the animation effect occurs. This is an option in a list of animation speeds. name:(0,a._x)("Medium","animation speed","extendify-local"),slug:"medium"},{ // translators: "Fast" refers to a quicker speed at which the animation effect occurs. This is an option in a list of animation speeds. name:(0,a._x)("Fast","animation speed","extendify-local"),slug:"fast"}],x=({name:e,selected:t,icon:n,onClick:o})=>(0,g.jsxs)("button",{type:"button",className:p()("relative h-full w-full rounded-lg border p-2 text-sm text-left flex flex-col gap-4 font-medium hover:bg-gray-100",{"border-gray-900 bg-gray-100":t,"border-gray-300 bg-gray-50":!t}),onClick:o,children:[(0,g.jsx)(u.A,{icon:n,className:"h-6 w-6"}),e,t&&(0,g.jsx)("div",{className:"absolute top-1 right-1 h-3.5 w-3.5 flex items-center justify-center rounded-full bg-design-main text-center text-xss text-white leading-none",children:(0,g.jsx)("span",{children:"✓"})})]});var y=n(1709);const{abilities:w}=window.extAgentData,b={available:()=>w?.canEditSettings&&window.ExtendableAnimations,id:"change-animation",whenFinished:{component:({onConfirm:e,onCancel:t,onLoad:n})=>{const i=(0,r.useRef)({}),[l,c]=(0,r.useState)(null),[d,u]=(0,r.useState)(0),[m,p]=(0,r.useState)(null),[y,w]=(0,r.useState)(!0),b=(0,r.useCallback)(()=>{d&&(window.ExtendableAnimations?.setType(i.current.type),window.ExtendableAnimations?.setSpeed(i.current.speed))},[d]),v=(0,r.useRef)(!1),k=(0,r.useRef)(b);return k.current=b,(0,r.useEffect)(()=>()=>{v.current||k.current()},[]),(0,r.useEffect)(()=>{d&&(window.ExtendableAnimations.setType(l),window.ExtendableAnimations.setSpeed(m))},[m,l,d]),(0,r.useEffect)(()=>{y||n()},[y,n]),(0,r.useEffect)(()=>{y&&(0,o.o)("extendify_animation_settings").then((e={})=>{i.current={type:"none",speed:"medium",...e||{}},c(i.current.type),p(i.current.speed),w(!1)})},[]),y?(0,g.jsx)("div",{className:"min-h-24 p-2 text-center text-sm",children: // translators: This is a status message. 'Loading' is a verb — the app is currently loading the animation options. It is not referring to 'loading animation' as a compound noun. // translators: This is a status message. 'Loading' is a verb — the app is currently loading the animation options. It is not referring to 'loading animation' as a compound noun. (0,a.__)("Loading animation options...","extendify-local")}):(0,g.jsxs)("div",{className:"mb-4 ml-10 mr-2 flex flex-col rounded-lg border border-gray-300 bg-gray-50 rtl:ml-2 rtl:mr-10",children:[(0,g.jsxs)("div",{className:"rounded-lg p-3 border-b border-gray-300 bg-white",children:[(0,g.jsx)("div",{className:"text-xs uppercase mb-3 text-gray-700 font-medium",children:(0,a._x)("Type","animation type","extendify-local")}),(0,g.jsx)("div",{className:"grid gap-2 mb-6 grid-cols-2 auto-rows-fr",children:f.map(({name:e,slug:t,icon:n})=>(0,g.jsx)(x,{name:e,icon:n,selected:l===t,onClick:()=>{u(e=>e+1),c(t)}},t))}),(0,g.jsx)("div",{className:"text-xs uppercase mb-1 text-gray-700 font-medium",children:(0,a._x)("Speed","animation speed","extendify-local")}),(0,g.jsx)(s.__experimentalToggleGroupControl,{className:"border-gray-300 rounded-sm m-0 before:rounded-sm focus-within:border-gray-900",__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,isBlock:!0,value:m,onChange:e=>{u(e=>e+1),p(e)},children:h.map(({name:e,slug:t})=>(0,g.jsx)(s.__experimentalToggleGroupControlOption,{label:e,value:t},t))})]}),(0,g.jsxs)("div",{className:"flex justify-start gap-2 p-3",children:[(0,g.jsx)("button",{type:"button",className:"w-full rounded-sm border border-gray-500 bg-white p-2 text-sm text-gray-900",onClick:t,children:(0,a.__)("Cancel","extendify-local")}),(0,g.jsx)("button",{type:"button",className:"w-full rounded-sm border border-design-main bg-design-main p-2 text-sm text-white",disabled:!l||!m||y,onClick:()=>{l&&m&&!y&&(v.current=!0,e({data:{type:l,speed:m}}))},children:(0,a.__)("Save","extendify-local")})]})]})}},example:{ // translators: "site animation" refers to the animation style for the current site. text:(0,a.__)("Change website animation","extendify-local"),agentResponse:{ // translators: This message show above a UI where the user can select a different animation for their site. reply:(0,a.__)("Below you can select a different animation for your site.","extendify-local"),whenFinishedTool:{id:"update-animation",labels:{confirm:(0,a.__)("Updated the website animation","extendify-local"),cancel:(0,a.__)("Canceled the website animation update","extendify-local")}}}},icon:y.A}},2868(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>T});var o=n(7723),s=n(7611),r=n(4224),a=n(3634),i=n(2441),l=n(6087);const c=Math.max(window.innerWidth,1400),d=e=>{if(!e)return null;const t=["ext-animate","ext-animate--on"],n=e.cloneNode(!0);return n.classList.remove(...t),n.querySelectorAll(t.map(e=>`.${e}`).join(", ")).forEach(e=>{e.classList.remove(...t)}),n};var u=n(6942),m=n.n(u),p=n(3640),g=n(790);const f=Math.max(window.innerWidth,1400),h=(document.querySelector("header")?.offsetHeight??0)+(document.querySelector(".ext-hero-section")?.offsetHeight??0)||window.innerHeight,x=({renderedHtml:e,styles:t,isSelected:n,onClick:s})=>{const r=(0,l.useRef)(null),{containerRef:a,scale:i,contentHeight:u,handleIframeLoad:x}=(()=>{const e=(0,l.useRef)(null),t=(0,l.useRef)(null),[n,o]=(0,l.useState)(1),[s,r]=(0,l.useState)(null);return(0,l.useLayoutEffect)(()=>{const n=e.current;if(!n)return;const s=new ResizeObserver(([e])=>{o(e.contentRect.width/c)});return s.observe(n),()=>{s.disconnect(),t.current?.disconnect()}},[]),{containerRef:e,scale:n,contentHeight:s,handleIframeLoad:e=>{const n=e.target.contentDocument;if(!n?.body)return;const o=()=>{const e=n.body.scrollHeight;e&&r(e)};o(),t.current?.disconnect();const s=new ResizeObserver(o);s.observe(n.body),t.current=s}}})(),y=(0,l.useMemo)(()=>((e,t)=>{const n=document.documentElement.cloneNode(!0),o=n.querySelector("head"),s=n.querySelector("body");n.querySelectorAll("script").forEach(e=>{e.remove()}),n.querySelector("#block-style-variation-styles-inline-css")?.remove(),n.querySelector("#wp-block-library-inline-css")?.remove(),n.querySelector("#admin-bar-inline-css")?.remove(),o.appendChild(document.createElement("style")).textContent=[t?.colorAndFontsVariations??"",t?.vibes??"",t?.blockSupportsCss??""].join("\n"),(t?.linkStyles??[]).forEach(e=>{if(n.querySelector(`link[href="${e}"]`))return;const t=document.createElement("link");t.rel="stylesheet",t.href=e,o.appendChild(t)});const r=(e=>{const t=new Map((e??[]).map(e=>[e.slug,e]));return[...document.querySelectorAll('svg:has(filter[id^="wp-duotone"])')].map(e=>{const n=e.cloneNode(!0);return n.querySelectorAll('filter[id^="wp-duotone"]').forEach(e=>{const n=t.get(e.id.replace("wp-duotone-",""));if(!n?.colors||2!==n.colors.length)return;const[o,s]=n.colors.map(e=>{const{r:t,g:n,b:o}=(0,p.Mj)(e).toRgb();return{r:t/255,g:n/255,b:o/255}});["feFuncR","feFuncG","feFuncB"].forEach((t,n)=>{const r=["r","g","b"][n];e.querySelector(t)?.setAttribute("tableValues",`${o[r]} ${s[r]}`)})}),n})})(t?.duotoneTheme),a=d(document.querySelector("header"))?.outerHTML??"";var i;return s.innerHTML=`${a}${i=e,i.replace(/(https?:\/\/\S+\?w=\d+)/gi,"$1&q=10&auto=format,compress&fm=avif")}`,r.forEach(e=>{s.appendChild(e)}),`<!DOCTYPE html>${n.outerHTML}`})(e,t),[e,t?.linkStyles,t?.colorAndFontsVariations,t?.duotoneTheme,t?.vibes,t?.blockSupportsCss]);return(0,g.jsx)("button",{ref:a,type:"button",style:{height:(u??h)*i+"px"},className:m()("relative w-full cursor-pointer overflow-hidden rounded-md border shadow-md",{"border-design-main ring-wp ring-design-main":n,"border-gray-400":!n}),onClick:s,onKeyDown:e=>"Enter"===e.key&&s(),children:(0,g.jsx)("div",{className:"overflow-hidden",style:{width:f,transform:`scale(${i})`,transformOrigin:"top left"},children:(0,g.jsx)("iframe",{ref:r,title:(0,o.__)("Preview site design","extendify-local"),onLoad:x,srcDoc:y,style:{width:"100%",height:Math.max(u??h,h),border:0,pointerEvents:"none",display:"block",overflow:"hidden"}})})})};var y=n(1455),w=n.n(y),b=n(9363),v=n(4997),k=n(6427),j=n(7143);const{context:_}=window.extAgentData,S=_?.adminPage,{context:C,abilities:L}=window.extAgentData,T={available:()=>L?.canEditThemes&&!C?.adminPage&&C?.postId&&!C?.isBlogPage&&C?.isBlockTheme,id:"change-site-design",whenFinished:{component:({onConfirm:e,onCancel:t})=>{const[n,s]=(0,l.useState)(5),[c,u]=(0,l.useState)(!1),[p,f]=(0,l.useState)(!1),[h,y]=(0,l.useState)(),[C,L]=(0,l.useState)(),[T,E]=(0,l.useState)(),[N,A]=(0,l.useState)(),[P,I]=(0,l.useState)(),[R,D]=(0,l.useState)(),[$,M]=(0,l.useState)(),[q,B]=(0,l.useState)(),{updateSettings:F}=(0,j.useDispatch)("core/block-editor"),O=(0,l.useRef)([]),{undoChange:H}=(0,i.b)({css:!S&&R?.css,duotoneTheme:!S&&R?.settings?.color?.duotone?.theme}),{undoChange:z}=(0,r.U)({css:!S&&q?.css,slug:!S&&q?.slug}),{data:W,isLoading:U}=(0,a.e)(),V=(0,l.useMemo)(()=>{if(U)return null;const e=Object.entries(W.css).filter(([e])=>e!==W.currentVibe).map(([e,t])=>({slug:e,css:t?.replaceAll(e,"natural-1")})).sort(()=>Math.random()-.5);return[...e,...e.slice(0,3)]},[W,U]);(0,l.useEffect)(()=>{window.scrollTo({top:0,behavior:"smooth"});const e=document.querySelector(".ext-hero-section"),t=document.getElementById("block-style-variation-styles-inline-css");e&&A(d(e).outerHTML),t&&I(t.textContent)},[]),(0,l.useEffect)(()=>{u(!0);const e=document.querySelector(".ext-hero-section"),t=e?.querySelector("h1")?.textContent??null,n=e?.querySelector("p")?.textContent??null,o=e?.querySelector(".wp-block-button__link")??null,s=[...e?.querySelectorAll("img")??[]].filter(e=>!e.src.includes(".svg")&&!e.src.includes("data:image/svg+xml")).map(e=>{try{const t=new URL(e.src);return t.origin+t.pathname}catch{return e.src}});w()({path:"/extendify/v1/agent/site-design-variations",method:"POST",data:{title:t,images:s,description:n,cta:{label:o?.textContent,link:o?.href}}}).then(e=>{y(e?.patterns?.flat()??[]),L([...e?.colorAndFontsVariations??[]].sort(()=>Math.random()-.5)),E(e?.blockEditorSettings)}).finally(()=>{u(!1)})},[]),(0,l.useEffect)(()=>{T&&F(T)},[T,F]);const Y=(0,l.useMemo)(()=>({id:"current",isCurrent:!0,renderedHtml:N}),[N]);(0,l.useEffect)(()=>{Y&&M(Y)},[Y]);const Z=h?.slice(0,n),G=n<h?.length,X=()=>{(()=>{document.querySelector(".ext-hero-section-preview")?.remove();const e=document.querySelector(".ext-hero-section");e&&(e.style.display="block")})(),H(),z(),O.current.forEach(e=>{e.remove()}),O.current=[]};return c||U?(0,g.jsx)("div",{className:"flex justify-center flex-col gap-1",children:(0,g.jsx)(k.Spinner,{})}):(0,g.jsxs)("div",{className:"mb-4 ml-10 mr-2 flex flex-col rounded-lg border border-gray-300 bg-gray-50 rtl:ml-2 rtl:mr-10",children:[(0,g.jsx)("div",{className:"rounded-lg border-b border-gray-300 bg-white",children:(0,g.jsxs)("div",{className:"flex flex-col gap-4 p-3",children:[N&&(0,g.jsx)(x,{renderedHtml:N,isSelected:"current"===$?.id,styles:{vibes:P},onClick:()=>{M(Y),D(null),B(null),X()}}),Z?.map((e,t)=>(0,g.jsx)(x,{renderedHtml:e.renderedHtml,isSelected:$?.id===e.id,styles:{linkStyles:e.linkStyles,colorAndFontsVariations:C[t].css,duotoneTheme:C[t]?.settings?.color?.duotone?.theme,vibes:V[t]?.css,blockSupportsCss:e.blockSupportsCss},onClick:()=>{if(M(e),D(C[t]),B(V[t]),!S){const t=e.blockSupportsCss;if(t){let e=document.getElementById("ext-block-supports-css");e||(e=document.createElement("style"),e.id="ext-block-supports-css",document.head.appendChild(e)),e.textContent=t}n=e.linkStyles,O.current.forEach(e=>{e.remove()}),O.current=[],(n??[]).forEach(e=>{if(document.querySelector(`link[href="${e}"]`))return;const t=document.createElement("link");t.rel="stylesheet",t.href=e,document.head.appendChild(t),O.current.push(t)}),(e=>{document.querySelector(".ext-hero-section-preview")?.remove();const t=document.querySelector(".ext-hero-section");t&&(t.style.display="none");const n=document.querySelector(".entry-content")??document.querySelector("main");if(!n)return;n.insertAdjacentHTML("afterbegin",e);const o=[...document.querySelectorAll(".ext-hero-section")].find(e=>"none"!==e.style.display);o?.classList.add("ext-hero-section-preview")})(e.renderedHtml)}var n}},e.id)),G&&(0,g.jsx)("button",{type:"button",className:m()("w-full rounded-sm border border-gray-300 bg-white p-2 text-sm text-gray-800",{"hover:bg-gray-50":!p}),onClick:()=>s(e=>e+5),disabled:p,children:(0,o.__)("Load more","extendify-local")})]})}),(0,g.jsxs)("div",{className:"flex justify-start gap-2 p-3",children:[(0,g.jsx)("button",{type:"button",className:m()("w-full rounded-sm border border-gray-300 bg-white p-2 text-sm text-gray-800",{"hover:bg-gray-50":!p}),onClick:()=>{X(),t()},disabled:p,children:(0,o.__)("Cancel","extendify-local")}),(0,g.jsx)("button",{type:"button",className:m()("w-full rounded-sm border border-design-main bg-design-main p-2 text-sm text-white",{"cursor-not-allowed":!$||p,"hover:bg-gray-800":!p}),disabled:!$||p,onClick:async()=>{if(!$)return;if($.isCurrent)return void e({data:{postId:_?.postId},shouldRefreshPage:!1});if(!q||!R)return;const t=_?.postId;try{const n=await w()({path:`/wp/v2/pages/${t}?context=edit`});0===(0,v.getBlockTypes)().length&&(0,b.registerCoreBlocks)();const o=(0,v.parse)(n.content.raw);let s=!1;const r=(0,v.serialize)(o.map(e=>s||!e.attributes.className.split(" ").includes("ext-hero-section")?e:(s=!0,(0,v.parse)($.code)?.[0]||e)));e({data:{updatedPageBlocks:r,postId:t,vibeSlug:q.slug,colorAndFontsVariation:R},shouldRefreshPage:!0})}catch(e){console.log(e)}finally{f(!1)}},children:p?(0,g.jsx)(k.Spinner,{className:"m-0"}):(0,o.__)("Save","extendify-local")})]})]})}},example:{text:(0,o.__)("Change website design","extendify-local"),agentResponse:{ // translators: This message show above a UI where the user can select a different site design. reply:(0,o.__)("Below you can select a different design for your website.","extendify-local"),recommendations:[{id:"change-theme-colors",icon:"styles",label:(0,o.__)("Change website colors","extendify-local"),workflowId:"change-theme-variation",available:{context:["hasThemeVariations"]}},{id:"change-site-title",icon:"edit",label:(0,o.__)("Change website title","extendify-local"),workflowId:"edit-wp-setting",available:{abilities:["canEditSettings"]}},{id:"change-website-logo",icon:"siteLogo",label:(0,o.__)("Change website logo","extendify-local"),workflowId:"update-logo",available:{abilities:["canEditSettings","canUploadMedia"]}}],whenFinishedTool:{id:"change-site-design",labels:{confirm:(0,o.__)("Updated the website design","extendify-local"),cancel:(0,o.__)("Canceled the website design update","extendify-local")}}}},icon:s.A}},1987(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>p});var o=n(3372),s=n(4224),r=n(3634),a=n(8459),i=n(6087),l=n(7723),c=n(790),d=n(9703);const{context:u,abilities:m}=window.extAgentData,p={available:()=>m?.canEditThemes&&u?.hasThemeVariations&&u?.isUsingVibes,needsRedirect:()=>!Number(u?.postId||0),redirectComponent:()=>(0,o.r)( // translators: "site style" refers to the structural aesthetic style for the site. // translators: "site style" refers to the structural aesthetic style for the site. (0,l.__)("Hey there! It looks like you are trying to change your site style, but you are not on a page where we can do that.","extendify-local")),id:"change-site-vibes",whenFinished:{component:({onConfirm:e,onCancel:t,onLoad:n})=>{const{data:o,isLoading:d}=(0,r.e)(),{vibes:u,css:m}=o||{},[p,g]=(0,i.useState)(null),f=p?m[p]:"",{undoChange:h}=(0,s.U)({css:f,slug:p}),x=!u||0===u.length,y=(0,i.useRef)(!1);(0,i.useEffect)(()=>()=>{y.current||h()},[]);const w=(0,i.useMemo)(()=>u?[...u].sort(()=>Math.random()-.5):[],[u]),{addMessage:b,messages:v}=(0,a.L)();return(0,i.useEffect)(()=>{d||n()},[d,n]),(0,i.useEffect)(()=>{if(d||!x)return;const e=setTimeout(()=>t(),100),n=(0,l.__)("We were unable to find any website style for your theme.","extendify-local"),o=v.at(-1)?.details?.content; // translators: "site style" refers to the structural aesthetic style for the site. return n===o||b("message",{role:"assistant",content:n,error:!0}),()=>clearTimeout(e)},[b,t,x,v,d]),d?(0,c.jsx)("div",{className:"min-h-24 p-2 text-center text-sm",children: // translators: "site style" refers to the structural aesthetic style for the site. // translators: "site style" refers to the structural aesthetic style for the site. (0,l.__)("Loading website style options...","extendify-local")}):x?null:(0,c.jsxs)("div",{className:"mb-4 ml-10 mr-2 flex flex-col rounded-lg border border-gray-300 bg-gray-50 rtl:ml-2 rtl:mr-10",children:[(0,c.jsx)("div",{className:"rounded-lg border-b border-gray-400 bg-white",children:(0,c.jsx)("div",{className:"grid gap-3 p-4 grid-cols-2",children:w?.slice(0,10).map(({slug:e},t)=>(0,c.jsxs)(i.Fragment,{children:[(0,c.jsx)("style",{children:m[e]?.replaceAll(":root",".ext-vibe-container")?.replaceAll("is-style-ext-preset--","preview-is-style-ext-preset--")}),(0,c.jsx)("button",{"aria-label":(0,l.sprintf)((0,l.__)("Style %s","extendify-local"),t+1),"aria-pressed":p===e,type:"button",className:"ext-vibe-container aspect-square relative flex w-full appearance-none items-stretch justify-center overflow-hidden rounded-sm border border-gray-300 bg-none p-0 text-sm shadow-lg focus:outline-none focus:ring-2 focus:ring-design-main focus:ring-offset-1 "+(p===e?"ring-2 ring-design-main":""),onClick:()=>g(e),children:(0,c.jsx)("div",{className:`wp-block-group w-full h-full preview-is-style-ext-preset--group--${e}--section has-background-background-color has-background p-4`,children:(0,c.jsx)("div",{className:`wp-block-group has-tertiary-background-color has-background w-full h-full flex items-center justify-center bg-design-tertiary rtl:space-x-reverse preview-is-style-ext-preset--group--${e}--item-card-1--align-center p-0`,children:(0,c.jsx)("img",{src:"https://images.extendify-cdn.com/agents/style-selector-preview.jpg",alt:(0,l.sprintf)((0,l.__)("Style %s","extendify-local"),t+1),draggable:"false",loading:"lazy",width:96,height:96,className:"w-full h-full object-cover pointer-events-none"})})})})]},e))})}),(0,c.jsxs)("div",{className:"flex justify-start gap-2 p-3",children:[(0,c.jsx)("button",{type:"button",className:"w-full rounded-sm border border-gray-500 bg-white p-2 text-sm text-gray-900",onClick:t,children:(0,l.__)("Cancel","extendify-local")}),(0,c.jsx)("button",{type:"button",className:"w-full rounded-sm border border-design-main bg-design-main p-2 text-sm text-white",disabled:!p,onClick:()=>{p&&(y.current=!0,e({data:{selectedVibe:p},shouldRefreshPage:!0}))},children:(0,l.__)("Save","extendify-local")})]})]})}},example:{ // translators: "site style" refers to the structural aesthetic style for the site. text:(0,l.__)("Change website style","extendify-local"),agentResponse:{ // translators: This message show above a UI where the user can select a different site style variation for their theme. reply:(0,l.__)("Below you can select a different site style variation for your theme.","extendify-local"),whenFinishedTool:{id:"update-site-vibes",labels:{confirm:(0,l.__)("Updated the website style","extendify-local"),cancel:(0,l.__)("Canceled the website style update","extendify-local")}}}},icon:d.A}},1916(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>S});var o=n(3372),s=n(1548),r=n(7584),a=n(1455),i=n.n(a),l=n(4997),c=n(7143),d=n(6087);const u="global-styles-inline-css",m=window.location.pathname,p=new URLSearchParams(window.location.search),g=m.includes("/wp-admin/post.php")&&"edit"===p.get("action"),{globalStylesPostID:f}=window.extSharedData;var h=n(7723),x=n(4225);const y=async()=>{const e=window.location.pathname,t=new URLSearchParams(window.location.search),n=e.includes("/wp-admin/post.php")&&"edit"===t.get("action"),o=await i()({method:"GET",path:"/extendify/v1/agent/theme-fonts-variations"+(n?"":"?includeLayoutStyles")});if(!o||!Array.isArray(o))throw new Error((0,h.__)("Failed to fetch theme font variations.","extendify-local"));return{variations:o.reduce((e,t)=>(e.some(e=>e.title===t.title)||e.push(t),e),[])}};var w=n(8459),b=n(790);const v=e=>e?.typography?.fontFamily&&e?.elements?.heading?.typography?.fontFamily?{normal:e.typography.fontFamily,heading:e.elements.heading.typography.fontFamily||e.typography.fontFamily}:e?.typography?.fontFamily?{normal:e.typography.fontFamily,heading:e.typography.fontFamily}:void 0;var k=n(34);const{context:j,abilities:_}=window.extAgentData,S={available:()=>_?.canEditThemes&&j?.hasThemeVariations,needsRedirect:()=>!Number(j?.postId||0),redirectComponent:()=>(0,o.r)((0,h.__)("Hey there! It looks like you are trying to change your theme fonts, but you are not on a page where we can do that.","extendify-local")),id:"change-theme-fonts-variation",whenFinished:{component:({onConfirm:e,onCancel:t,onLoad:n})=>{const[o,a]=(0,d.useState)(""),[m,p]=(0,d.useState)(null),{undoChange:k}=(({css:e})=>{const t=(0,d.useRef)(null),n=(0,d.useRef)(null),[o,a]=(0,d.useState)(null),[m,p]=(0,d.useState)(null);(0,d.useEffect)(()=>{i()({path:`/wp/v2/global-styles/${f}?context=edit`}).then(e=>{const t=e?.settings?.color?.duotone?.theme;p(t)})},[e]),(0,d.useEffect)(()=>{if(!e||g)return;const n=document.getElementById(u);n&&(t.current||(t.current=n.innerHTML),n.innerHTML=e)},[e]),(0,d.useEffect)(()=>{if(!e||!o||!g)return;const t=o.getElementById(u),n=document.querySelector('iframe[name="editor-canvas"]');t.innerHTML=e.replaceAll(":root",n?":root":".editor-styles-wrapper"),n||(t.innerHTML=t.innerHTML.replace("body{",".editor-styles-wrapper{").replace(/(h[1-6](?:\s*,\s*h[1-6])*)\s*\{/g,".editor-styles-wrapper $1{"))},[e,o]),(0,d.useEffect)(()=>{if(o)return;const e=setTimeout(()=>{if(o)return;const e=document.querySelector('iframe[name="editor-canvas"]'),t=e?.contentDocument||document;if(!t||!t.body)return;const n=t.createElement("style");n.id=u,t.body.appendChild(n),a(t)},300);return()=>clearTimeout(e)},[o]);const h=(0,c.useSelect)(e=>{let t=e("core/block-editor")?.getBlocks?.()??[];if(t.find(e=>"core/template-part"===e.name)){const{getEditedPostContent:n}=e("core/editor");t=(0,l.parse)(n(),{})}return(0,s.w)(t)},[]);return(0,d.useEffect)(()=>{m&&(n.current&&(n.current(),n.current=null),n.current=(0,r.T)({duotoneTheme:m,dynamicDuotone:h}))},[e,m,h]),{undoChange:(0,d.useCallback)(()=>{n.current&&(n.current(),n.current=null);const e=document.getElementById(u);if(e&&t.current&&(e.innerHTML=t.current),!g)return;const o=document.querySelector('iframe[name="editor-canvas"]'),s=o?.contentDocument||document;s?.getElementById(u)?.remove()},[])}})({css:o}),{variations:j,isLoading:_}=(()=>{const{data:e,error:t,isLoading:n}=(0,x.A)({key:"theme-fonts-variations",themeSlug:window.extAgentData.context.themeSlug},y);return{variations:e?.variations,error:t,isLoading:n}})(),S=(0,d.useRef)(!1);(0,d.useEffect)(()=>()=>{S.current||k()},[]);const C=!j||0===j.length,L=(0,d.useMemo)(()=>j?j.sort(()=>Math.random()-.5):[],[j]),{addMessage:T,messages:E}=(0,w.L)();return(0,d.useEffect)(()=>{_||n()},[_,n]),(0,d.useEffect)(()=>{if(_||!C)return;const e=setTimeout(()=>t(),100),n=(0,h.__)("We were unable to find any variations for your theme","extendify-local"),o=E.at(-1)?.details?.content; // translators: A chat message shown to the user return n===o||T("message",{role:"assistant",content:n,error:!0}),()=>clearTimeout(e)},[T,t,C,E,_]),_?(0,b.jsx)("div",{className:"min-h-24 p-2 text-center text-sm",children:(0,h.__)("Loading font variations...","extendify-local")}):C?null:(0,b.jsxs)("div",{className:"mb-4 ml-10 mr-2 flex flex-col rounded-lg border border-gray-300 bg-gray-50 rtl:ml-2 rtl:mr-10",children:[(0,b.jsx)("div",{className:"rounded-lg border-b border-gray-300 bg-white",children:(0,b.jsx)("div",{className:"grid grid-cols-2 gap-2 p-3",children:L?.slice(0,10)?.map(({title:e,css:t,styles:n})=>(0,b.jsx)("button",{"aria-label":e,type:"button",style:{fontFamily:v(n)?.normal},className:"relative flex w-full items-center justify-center overflow-hidden rounded-lg border border-gray-300 bg-none p-2 text-center text-sm "+(m===e?"ring ring-design-main ring-wp":""),onClick:()=>{p(e),a(t)},children:(0,b.jsxs)("div",{className:"max-w-fit content-stretch items-center justify-center rounded-lg text-2xl rtl:space-x-reverse",children:[(0,b.jsx)("span",{style:{fontFamily:v(n)?.heading},children:"A"}),(0,b.jsx)("span",{style:{fontFamily:v(n)?.normal},children:"a"})]})},e))})}),(0,b.jsxs)("div",{className:"flex justify-start gap-2 p-3",children:[(0,b.jsx)("button",{type:"button",className:"w-full rounded-sm border border-gray-500 bg-white p-2 text-sm text-gray-900",onClick:t,children:(0,h.__)("Cancel","extendify-local")}),(0,b.jsx)("button",{type:"button",className:"w-full rounded-sm border border-design-main bg-design-main p-2 text-sm text-white",disabled:!m,onClick:()=>{m&&(S.current=!0,e({data:{variation:j.find(e=>e.title===m)},shouldRefreshPage:!0}))},children:(0,h.__)("Save","extendify-local")})]})]})}},example:{ // translators: "theme fonts" refers to the font variation for the current theme. text:(0,h.__)("Change website fonts","extendify-local"),agentResponse:{ // translators: This message show above a UI where the user can select a different font variation for their theme. reply:(0,h.__)("Below you can select a different font variation for your theme.","extendify-local"),whenFinishedTool:{id:"update-theme-fonts-variation",labels:{confirm:(0,h.__)("Updated the theme fonts","extendify-local"),cancel:(0,h.__)("Canceled the theme fonts update","extendify-local")}}}},icon:k.A}},284(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>x});var o=n(7723),s=n(790),r=n(1455),a=n.n(r),i=n(4225);const l=async()=>{const e=window.location.pathname,t=new URLSearchParams(window.location.search),n=e.includes("/wp-admin/post.php")&&"edit"===t.get("action"),s=await a()({method:"GET",path:"/extendify/v1/agent/theme-variations"+(n?"":"?includeLayoutStyles")});if(!s||!Array.isArray(s))throw new Error((0,o.__)("Failed to fetch theme variations.","extendify-local"));return{variations:s.reduce((e,t)=>(e.some(e=>e.title===t.title)||e.push(t),e),[])}};var c=n(2441),d=n(8459),u=n(6087);const m=(e,t)=>e?.color?.palette?.theme.find(e=>e.slug===t)?.color,p=e=>e?.color?.palette?.theme?.filter(e=>"background"!==e.slug)?.reduce((e,t)=>(e.push(t.color),e),[]);var g=n(6230);const{context:f,abilities:h}=window.extAgentData,x={available:()=>h?.canEditThemes&&f?.hasThemeVariations,needsRedirect:()=>!Number(f?.postId||0),redirectComponent:()=>(0,s.jsxs)("div",{className:"mb-4 ml-10 mr-2 flex flex-col rounded-lg border border-gray-300 bg-gray-50 rtl:ml-2 rtl:mr-10",children:[(0,s.jsx)("div",{className:"rounded-lg border-b border-gray-300 bg-white p-3",children:(0,s.jsx)("p",{className:"m-0 p-0 text-sm text-gray-900",children:(0,o.__)("Hey there! It looks like you are trying to change your theme colors, but you are not on a page where we can do that.","extendify-local")})}),(0,s.jsxs)("div",{className:"m-0 p-3 text-sm text-gray-900",children:[(0,o.__)("Suggestion:","extendify-local")," ",(0,s.jsx)("a",{href:`${window.extSharedData.homeUrl}`,children:(0,o.__)("Home page","extendify-local")})]})]}),id:"change-theme-variation",whenFinished:{component:({onConfirm:e,onCancel:t,onLoad:n})=>{const[r,a]=(0,u.useState)(""),[g,f]=(0,u.useState)(null),[h,x]=(0,u.useState)(null),{undoChange:y}=(0,c.b)({css:r,duotoneTheme:h}),w=(0,u.useRef)(!1);(0,u.useEffect)(()=>()=>{w.current||y()},[]);const{variations:b,isLoading:v}=(()=>{const{data:e,error:t,isLoading:n}=(0,i.A)({key:"theme-variations",themeSlug:window.extAgentData.context.themeSlug},l);return{variations:e?.variations,error:t,isLoading:n}})(),k=!b||0===b.length,{addMessage:j,messages:_}=(0,d.L)(),S=(0,u.useMemo)(()=>b?b.sort(()=>Math.random()-.5):[],[b]);return(0,u.useEffect)(()=>{v||n()},[v,n]),(0,u.useEffect)(()=>{if(v||!k)return;const e=setTimeout(()=>t(),100),n=(0,o.__)("We were unable to find any colors for your theme","extendify-local"),s=_.at(-1)?.details?.content; // translators: A chat message shown to the user return n===s||j("message",{role:"assistant",content:n,error:!0}),()=>clearTimeout(e)},[j,t,k,_,v]),v?(0,s.jsx)("div",{className:"min-h-24 p-2 text-center text-sm",children:(0,o.__)("Loading available colors...","extendify-local")}):k?null:(0,s.jsxs)("div",{className:"mb-4 ml-10 mr-2 flex flex-col rounded-lg border border-gray-300 bg-gray-50 rtl:ml-2 rtl:mr-10",children:[(0,s.jsx)("div",{className:"rounded-lg border-b border-gray-300 bg-white",children:(0,s.jsx)("div",{className:"grid grid-cols-2 gap-2 p-3",children:S?.slice(0,10)?.map(({title:e,css:t,settings:n})=>(0,s.jsx)("button",{style:{backgroundColor:m(n,"background")},type:"button",className:"relative flex w-full items-center justify-center overflow-hidden rounded-lg border border-gray-300 bg-none p-2 text-center text-sm "+(g===e?"ring ring-design-main ring-wp":""),onClick:()=>{f(e),a(t),x(n?.color?.duotone?.theme)},children:(0,s.jsx)("div",{className:"flex max-w-fit items-center justify-center -space-x-4 rounded-lg rtl:space-x-reverse",children:p(n)?.map((t,n)=>(0,s.jsx)("div",{style:{backgroundColor:t},className:"size-6 shrink-0 overflow-visible rounded-full border border-white md:size-7"},e+t+n))})},e))})}),(0,s.jsxs)("div",{className:"flex justify-start gap-2 p-3",children:[(0,s.jsx)("button",{type:"button",className:"w-full rounded-sm border border-gray-500 bg-white p-2 text-sm text-gray-900",onClick:t,children:(0,o.__)("Cancel","extendify-local")}),(0,s.jsx)("button",{type:"button",className:"w-full rounded-sm border border-design-main bg-design-main p-2 text-sm text-white",disabled:!g,onClick:()=>{if(!g)return;const n=b.find(e=>e.title===g);if(!n){ // translators: A chat message shown to the user when their selected color variation cannot be applied const e=(0,o.__)("We were unable to apply your selected colors. Please try again.","extendify-local");return j("message",{role:"assistant",content:e,error:!0}),void t()}w.current=!0,e({data:{variation:n},shouldRefreshPage:!0})},children:(0,o.__)("Save","extendify-local")})]})]})}},example:{ // translators: "theme colors" refers to the color palette variation for the current theme. text:(0,o.__)("Change website colors","extendify-local"),agentResponse:{ // translators: This message show above a UI where the user can select a different color variation for their theme. reply:(0,o.__)("Below you can select a different color variation for your theme.","extendify-local"),whenFinishedTool:{id:"update-theme-variation",labels:{confirm:(0,o.__)("Updated the theme color","extendify-local"),cancel:(0,o.__)("Canceled the theme color update","extendify-local")}}}},icon:g.A}},3372(e,t,n){"use strict";n.d(t,{r:()=>r});var o=n(7723),s=n(790);const r=e=>(0,s.jsxs)("div",{className:"mb-4 ml-10 mr-2 flex flex-col rounded-lg border border-gray-300 bg-gray-50 rtl:ml-2 rtl:mr-10",children:[(0,s.jsx)("div",{className:"rounded-lg border-b border-gray-300 bg-white p-3",children:(0,s.jsx)("p",{className:"m-0 p-0 text-sm text-gray-900",children:e})}),(0,s.jsxs)("div",{className:"m-0 p-3 text-sm text-gray-900",children:[(0,o.__)("Suggestion:","extendify-local")," ",(0,s.jsx)("a",{href:`${window.extSharedData.homeUrl}`,children:(0,o.__)("Home page","extendify-local")})]})]})},3944(e,t,n){"use strict";n.d(t,{N:()=>c});var o=n(4972),s=n(3410),r=n(6087),a=n(7723),i=n(790);const l=(e,t)=>{document.querySelectorAll(".wp-block-site-logo img")?.forEach(n=>{n.srcset="",n.src=e,n.style.filter=t??""})},c=({onConfirm:e,onCancel:t})=>{const{block:n}=(0,s.Y)(),[c,u]=(0,r.useState)();(0,r.useEffect)(()=>{u(document.querySelector(".wp-block-site-logo img")?.src??null)},[n]);const m=(0,r.useCallback)(()=>{c&&l(c)},[c]),p=(0,r.useRef)(!1);return(0,r.useEffect)(()=>{if(c)return()=>{p.current||m()}},[c]),(0,r.useEffect)(()=>{const e=document.createElement("style");return e.textContent=".media-modal {\n\t\t\tz-index: 999999 !important;\n\t\t}",document.head.appendChild(e),()=>e.remove()},[]),(0,i.jsx)(d,{children:(0,i.jsx)("div",{className:"relative p-3",children:(0,i.jsx)(o.G,{type:"site_logo",title:(0,a.__)("Site logo","extendify-local"),actionLabel:(0,a.__)("Set site logo","extendify-local"),onSave:async({imageId:t})=>{p.current=!0,await e({data:{imageId:t},shouldRefreshPage:!window.extAgentData?.context?.adminPage})},onCancel:t,onSelect:e=>{l(e.url,"none")}})})})},d=({children:e})=>(0,i.jsx)("div",{className:"mb-4 ml-10 mr-2 flex flex-col rounded-lg border border-gray-300 bg-gray-50 rtl:ml-2 rtl:mr-10",children:e})},770(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>p});var o=n(2441),s=n(8459),r=n(6087),a=n(7723),i=n(790);const l=e=>{const t={};return e.forEach(({slug:e,color:n})=>{t[e]=n}),t},c=e=>{const t=["base","background","bg"];for(const n of t)if(e[n])return e[n];return"#ffffff"},d=window.extAgentData?.context?.themePresets?.duotone||[],u=window.extAgentData?.context?.themePresets?.colors||{},{abilities:m}=window.extAgentData,p={available:()=>m?.canEditThemes,id:"generate-color-palette",whenFinished:{component:({inputs:e,onConfirm:t,onCancel:n,onRetry:m})=>{const[p,g]=(0,r.useState)(null),[f,h]=(0,r.useState)(""),[x,y]=(0,r.useState)(null),{addMessage:w,messages:b}=(0,s.L)(),v=e?.palettes,k=(0,r.useMemo)(()=>v?.map(({name:e,colors:t})=>({name:e,colors:l(t),colorsArray:t}))||[],[v]),j=!v?.length||0===k.length,{undoChange:_}=(0,o.b)({css:f,duotoneTheme:x}),S=(0,r.useRef)(!1);return(0,r.useEffect)(()=>()=>{S.current||_()},[]),(0,r.useEffect)(()=>{if(!j)return;const e=setTimeout(()=>n(),100),t=(0,a.__)("We were unable to generate color palettes. Please try again.","extendify-local"),o=b.at(-1)?.details?.content;return t===o||w("message",{role:"assistant",content:t,error:!0}),()=>clearTimeout(e)},[w,n,j,b]),j?null:(0,i.jsxs)("div",{className:"mb-4 ml-10 mr-2 flex flex-col rounded-lg border border-gray-300 bg-gray-50 rtl:ml-2 rtl:mr-10",children:[(0,i.jsx)("div",{className:"rounded-lg border-b border-gray-300 bg-white",children:(0,i.jsx)("div",{className:"grid grid-cols-2 gap-2 p-3",children:k.map(({name:e,colors:t,colorsArray:n})=>(0,i.jsx)("button",{type:"button",style:{backgroundColor:c(t)},className:"relative flex w-full items-center justify-center overflow-hidden rounded-lg border border-gray-300 p-2 text-center text-sm "+(p===e?"ring ring-design-main ring-wp":""),onClick:()=>{g(e),h((e=>{const t=document.getElementById("global-styles-inline-css");if(!t)return"";let n=t.innerHTML;return Object.entries(e).forEach(([e,t])=>{const o=new RegExp(`(--wp--preset--color--${e}\\s*:\\s*)([^;]+)(;)`,"g");n=n.replace(o,`$1${t}$3`)}),n})(t)),y((e=>{if(!d.length)return null;const t=[];for(const n of d){const{slug:o,colors:s}=n;if(!s||2!==s.length)continue;const r=s.map(t=>{const n=Object.entries(u).find(([,e])=>e.toLowerCase()===t.toLowerCase())?.[0];return n&&e[n]?e[n]:t});t.push({slug:o,colors:r})}return t.length>0?t:null})(t))},children:(0,i.jsx)("div",{className:"flex max-w-fit items-center justify-center -space-x-4 rounded-lg rtl:space-x-reverse",children:n.filter(({slug:e})=>"background"!==e).map(({slug:e,color:t})=>(0,i.jsx)("div",{style:{backgroundColor:t},className:"size-6 shrink-0 overflow-visible rounded-full border border-white md:size-7"},e))})},e))})}),(0,i.jsxs)("div",{className:"flex justify-start gap-2 p-3",children:[(0,i.jsx)("button",{type:"button",className:"w-full rounded-sm border border-gray-500 bg-white p-2 text-sm text-gray-900",onClick:n,children:(0,a.__)("Cancel","extendify-local")}),(0,i.jsx)("button",{type:"button",className:"w-full rounded-sm border border-gray-500 bg-white p-2 text-sm text-gray-900",onClick:()=>{_(),m()},children:(0,a.__)("Try Again","extendify-local")}),(0,i.jsx)("button",{type:"button",className:"w-full rounded-sm border border-design-main bg-design-main p-2 text-sm text-white",disabled:!p,onClick:()=>{if(!p)return;S.current=!0;const e=k.find(e=>e.name===p);t({data:{palette:{name:e.name,colors:e.colorsArray.map(({slug:e,color:t})=>({slug:e,color:t,name:e}))},duotone:x},shouldRefreshPage:!0})},children:(0,a.__)("Save","extendify-local")})]})]})}}}},5572(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>r});var o=n(1455),s=n.n(o);const r=async({updatedPageBlocks:e,postId:t})=>{e&&await s()({path:`/wp/v2/pages/${t}`,method:"POST",data:{content:e}})}},956(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>c});var o=n(5572),s=n(8922),r=n(365),a=n(1455),i=n.n(a);const{globalStylesPostID:l}=window.extSharedData,c=async({updatedPageBlocks:e,postId:t,vibeSlug:n,colorAndFontsVariation:a})=>{e&&n&&a&&await Promise.all([(0,o.default)({updatedPageBlocks:e,postId:t}),(async()=>{await(0,s.default)({selectedVibe:n}),await(async({variation:e})=>{const t=await i()({path:"/extendify/v1/agent/block-style-variations"}),n=Object.keys(t).reduce((e,n)=>(e[n]={variations:t[n]},e),{}),o=(0,r.$N)(e,{styles:{blocks:n}});return i()({method:"POST",path:`/wp/v2/global-styles/${l}`,data:{id:l,...o}})})({variation:a})})()])}},3712(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>a});var o=n(1455),s=n.n(o);const r={page:"pages",post:"posts"},a=async({postId:e,postType:t})=>{const n=Array.from(window.document?.querySelectorAll("nav[data-extendify-menu-id]")??[]).map(e=>e.dataset.extendifyMenuId).filter(Boolean),o=n.length>0?await s()({method:"POST",path:"/extendify/v1/agent/site-navigation",data:{only:n.join(",")}}).catch(()=>[]):[];if(window.extAgentData?.context&&"draft"!==window.extAgentData?.context?.postStatus){let n=window.wp?.data?.select("core")?.getEntityRecord("postType",t,e)?.link;if(!n&&r[t]){const o=await s()({path:`/wp/v2/${r[t]}/${e}`}).catch(console.error);n=o?.link}n&&window.extAgentData?.context&&(window.extAgentData.context.postUrl=n)}return{navigations:o}}},6783(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>a});var o=n(1455),s=n.n(o);const r=window.extSharedData.globalStylesPostID,a=async({palette:e,duotone:t})=>{const n=await s()({path:`/wp/v2/global-styles/${r}`}),o=await s()({path:"/extendify/v1/agent/block-style-variations"}),a=Object.keys(o).reduce((e,t)=>(e[t]={...n.styles?.blocks?.[t],variations:o[t]},e),{}),i=e.colors.map(({slug:e,color:t,name:n})=>({slug:e,color:t,name:n})),l={...n.settings?.color,palette:{...n.settings?.color?.palette,theme:i}};return t&&(l.duotone={...n.settings?.color?.duotone,theme:t}),s()({method:"POST",path:`/wp/v2/global-styles/${r}`,data:{id:r,settings:{...n.settings,color:l},styles:{...n.styles,blocks:{...n.styles?.blocks,...a}}}})}},7303(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>s});var o=n(9395);const s=({type:e,speed:t})=>(0,o.D)("extendify_animation_settings",{type:e,speed:t})},3230(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>r});var o=n(1455),s=n.n(o);const r=async({imageId:e})=>{await s()({path:"/wp/v2/settings",method:"POST",data:{site_logo:e}})}},443(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>r});var o=n(1455),s=n.n(o);const r=async({id:e,replacements:t})=>await s()({path:`/wp/v2/navigation/${e}`,method:"POST",data:{content:t?.[0]?.updated}})},8350(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>r});var o=n(1455),s=n.n(o);const r=async({imageId:e})=>{await s()({path:"/wp/v2/settings",method:"POST",data:{site_icon:e}})}},8922(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>i});var o=n(1455),s=n.n(o);const r=window.extSharedData?.globalStylesPostID,a=window.extAgentData?.context?.themeSlug,i=async({selectedVibe:e})=>{if(e&&"string"==typeof e&&""!==e.trim())try{const{styles:t}=await s()({path:`/wp/v2/global-styles/${r}?context=edit`}),{styles:n}=await s()({path:`/wp/v2/global-styles/themes/${a}?context=edit`}),o={};for(const[t,s]of Object.entries(n.blocks)){if(!s?.variations){o[t]=s;continue}const{variations:n,...r}=s;o[t]={...r,variations:c(n,e)}}await Promise.all([s()({path:`wp/v2/global-styles/${r}`,method:"POST",data:{styles:{...t,blocks:o}}}),l(e)])}catch(e){throw new Error(`Vibe update failed: ${e?.response?.data?.message||e?.message||"Unknown error"}`)}},l=async e=>{const{data:t}=await s()({path:"/extendify/v1/launch/options?option=extendify_siteStyle"}),n={...t&&"object"==typeof t&&!Array.isArray(t)?t:{},vibe:e};return await s()({path:"/extendify/v1/launch/options",method:"POST",data:{option:"extendify_siteStyle",value:n}})},c=(e,t)=>{const n={};for(const[o,s]of Object.entries(e)){if(!o.includes("--natural-1--")){n[o]=s;continue}const r=e[o.replace("--natural-1--",`--${t}--`)];n[o]=r||s}return n}},1299(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>o.default});var o=n(6590)},4664(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>o.default});var o=n(6590)},6590(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>i});var o=n(365),s=n(1455),r=n.n(s);const{globalStylesPostID:a}=window.extSharedData,i=async({variation:e})=>{const t=await r()({path:`/wp/v2/global-styles/${a}?context=edit`}),n=await r()({path:"/extendify/v1/agent/block-style-variations"}),s=Object.keys(n).reduce((e,t)=>(e[t]={variations:n[t]},e),{}),i=(0,o.$N)(t,e,{styles:{blocks:s}});return r()({method:"POST",path:`/wp/v2/global-styles/${a}`,data:{id:a,...i}})}},18(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>r});var o=n(3944);const{abilities:s}=window.extAgentData,r={available:()=>s?.canEditSettings&&s?.canUploadMedia,id:"update-logo",whenFinished:{component:o.N}}},8147(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>d});var o=n(4972),s=n(6087),r=n(7723),a=n(790);const i=e=>{document.querySelectorAll('link[rel*="icon"]')?.forEach(t=>{t.href=e})},l=({children:e})=>(0,a.jsx)("div",{className:"mb-4 ml-10 mr-2 flex flex-col rounded-lg border border-gray-300 bg-gray-50 rtl:ml-2 rtl:mr-10",children:e}),{abilities:c}=window.extAgentData,d={available:()=>c?.canEditSettings&&c?.canUploadMedia,id:"update-site-icon",whenFinished:{component:({onConfirm:e,onCancel:t})=>{const[n,c]=(0,s.useState)();(0,s.useEffect)(()=>{c(document.querySelector('link[rel="icon"]')?.href??null)},[]);const d=(0,s.useCallback)(()=>{n&&i(n)},[n]),u=(0,s.useRef)(!1);return(0,s.useEffect)(()=>{if(n)return()=>{u.current||d()}},[n]),(0,s.useEffect)(()=>{const e=document.createElement("style");return e.textContent=".media-modal {\n\t\t\tz-index: 999999 !important;\n\t\t}",document.head.appendChild(e),()=>e.remove()},[]),(0,a.jsx)(l,{children:(0,a.jsx)("div",{className:"relative p-3",children:(0,a.jsx)(o.G,{type:"site_icon",title:(0,r.__)("Site icon","extendify-local"),actionLabel:(0,r.__)("Set site icon","extendify-local"),onSave:async({imageId:t})=>{u.current=!0,await e({data:{imageId:t},shouldRefreshPage:!0})},onCancel:t,onSelect:e=>{i(e.url)}})})})}}}},9333(e,t,n){"use strict";n.d(t,{L:()=>s,Y:()=>a});const o=n(1528),s=o.keys().filter(e=>"./workflows.js"!==e).map(e=>o(e).default||o(e)),r=n(205),a=r.keys().reduce((e,t)=>(e[t.split("/").pop().replace(".js","")]=r(t).default||r(t),e),{})},1528(e,t,n){var o={"./block-selector/block-general.js":6097,"./block-selector/generate-image.js":8446,"./block-selector/update-block-logo.js":7882,"./block-selector/upload-image.js":1804,"./content/create-page.js":439,"./content/edit-post-strings-editor.js":1352,"./content/edit-post-strings.js":1429,"./content/update-post-status.js":1755,"./misc/get-list-of-tours.js":5749,"./plugins/recommend-plugin.js":7275,"./settings/edit-wp-setting.js":9586,"./theme/add-post-to-menu.js":2130,"./theme/change-animation.js":8757,"./theme/change-site-design.js":2868,"./theme/change-site-vibes.js":1987,"./theme/change-theme-fonts-variation.js":1916,"./theme/change-theme-variation.js":284,"./theme/generate-color-palette.js":770,"./theme/update-logo.js":18,"./theme/update-site-icon.js":8147};function s(e){var t=r(e);return n(t)}function r(e){if(!n.o(o,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return o[e]}s.keys=function(){return Object.keys(o)},s.resolve=r,e.exports=s,s.id=1528},205(e,t,n){var o={"./block-selector/tools/generate-block-image.js":1598,"./block-selector/tools/get-block-content.js":2853,"./block-selector/tools/update-block-content.js":1256,"./block-selector/tools/update-block-image.js":2628,"./block-selector/tools/update-block-logo.js":8998,"./content/tools/generate-page.js":8942,"./content/tools/get-post-status.js":3571,"./content/tools/get-post-strings-editor.js":5261,"./content/tools/get-post-strings.js":1557,"./content/tools/update-post-status.js":9982,"./content/tools/update-post-strings-editor.js":5092,"./content/tools/update-post-strings.js":6636,"./content/tools/view-created-page.js":9133,"./extermal/tools/search-wp-docs.js":3364,"./plugins/tools/install-plugin.js":4679,"./plugins/tools/search-wordpress-plugin.js":8402,"./settings/tools/get-wp-setting.js":3508,"./settings/tools/update-wp-setting.js":8795,"./theme/tools/change-hero-section.js":5572,"./theme/tools/change-site-design.js":956,"./theme/tools/get-menu-items.js":3712,"./theme/tools/select-generated-palette.js":6783,"./theme/tools/update-animation.js":7303,"./theme/tools/update-logo.js":3230,"./theme/tools/update-menu-items.js":443,"./theme/tools/update-site-icon.js":8350,"./theme/tools/update-site-vibes.js":8922,"./theme/tools/update-theme-fonts-variation.js":1299,"./theme/tools/update-theme-variation.js":4664,"./theme/tools/update-variation.js":6590};function s(e){var t=r(e);return n(t)}function r(e){if(!n.o(o,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return o[e]}s.keys=function(){return Object.keys(o)},s.resolve=r,e.exports=s,s.id=205},1609(e){"use strict";e.exports=window.React},5795(e){"use strict";e.exports=window.ReactDOM},790(e){"use strict";e.exports=window.ReactJSXRuntime},1455(e){"use strict";e.exports=window.wp.apiFetch},3162(e){"use strict";e.exports=window.wp.blob},5259(e){"use strict";e.exports=window.wp.blockDirectory},9363(e){"use strict";e.exports=window.wp.blockLibrary},4997(e){"use strict";e.exports=window.wp.blocks},6427(e){"use strict";e.exports=window.wp.components},3582(e){"use strict";e.exports=window.wp.coreData},7143(e){"use strict";e.exports=window.wp.data},8443(e){"use strict";e.exports=window.wp.date},8490(e){"use strict";e.exports=window.wp.domReady},3656(e){"use strict";e.exports=window.wp.editor},6087(e){"use strict";e.exports=window.wp.element},2619(e){"use strict";e.exports=window.wp.hooks},8537(e){"use strict";e.exports=window.wp.htmlEntities},7723(e){"use strict";e.exports=window.wp.i18n},6480(e){"use strict";e.exports=window.wp.mediaUtils},2279(e){"use strict";e.exports=window.wp.plugins},5573(e){"use strict";e.exports=window.wp.primitives},3832(e){"use strict";e.exports=window.wp.url}},e=>{e.O(0,[65,223],()=>e(e.s=969)),e.O()}]);
geri dön