File "extendify-agent-6b892f5f41d245b47e2f.js"

Full Path: /home/fresvfqn/waterdamagerestorationandrepairsmithtown.com/wp-content/plugins/extendify/public/build/extendify-agent-6b892f5f41d245b47e2f.js
File size: 111.96 KB
MIME-type: text/plain
Charset: utf-8

(globalThis.webpackChunkextendify=globalThis.webpackChunkextendify||[]).push([[671],{205:(e,t,n)=>{var o={"./content/tools/get-post-strings-editor.js":5261,"./content/tools/get-post-strings.js":1557,"./content/tools/update-post-strings-editor.js":5092,"./content/tools/update-post-strings.js":6636,"./dom-highlighter/tools/get-block-content.js":3610,"./dom-highlighter/tools/update-block-content.js":9845,"./extermal/tools/search-wp-docs.js":3364,"./extermal/tools/update-theme-variation.js":8009,"./settings/tools/get-wp-setting.js":3508,"./settings/tools/update-wp-setting.js":8795};function i(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]}i.keys=function(){return Object.keys(o)},i.resolve=r,e.exports=i,i.id=205},790:e=>{"use strict";e.exports=window.ReactJSXRuntime},1352:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>s});var o=n(6087);const{abilities:i,context:r}=window.extAgentData,s={available:()=>i?.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),i=n(7723),r=n(790);const s=e=>{const t=document.getElementById("extendify-agent-chat"),n=e=>t&&t.contains(e),o=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT,null,!1);let i;for(;i=o.nextNode();)n(i.parentNode)||e?.forEach((({original:e,updated:t})=>{i.nodeValue.includes(e)&&(i.nodeValue=i.nodeValue.split(e).join(t))}));["alt","title","aria-label"].forEach((t=>{document.querySelectorAll(`[${t}]`).forEach((o=>{n(o)||e?.forEach((({original:e,updated:n})=>{const i=o.getAttribute(t);i&&i.includes(e)&&o.setAttribute(t,i.split(e).join(n))}))}))}))},{context:a,abilities:l}=window.extAgentData,c={available:()=>l?.canEditPosts&&!a?.adminPage&&a?.postId&&!a?.isBlogPage&&a.usingBlockEditor,id:"edit-post-strings",whenFinished:{component:({inputs:e,onConfirm:t,onCancel:n})=>{const a=(0,o.useCallback)((()=>{const t=(e.replacements||[]).map((({original:e,updated:t})=>({original:t,updated:e})));n(),s(t)}),[e,n]);return(0,o.useEffect)((()=>{s(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,i.__)("The agent has made the changes in the browser. Please review and confirm.","extendify-local")})})}),(0,r.jsxs)("div",{className:"flex items-center justify-start gap-2 p-3",children:[(0,r.jsx)("button",{type:"button",className:"w-full rounded border border-gray-300 bg-white p-2 text-sm text-gray-700",onClick:a,children:(0,i.__)("Cancel","extendify-local")}),(0,r.jsx)("button",{type:"button",className:"w-full rounded border border-design-main bg-design-main p-2 text-sm text-white",onClick:()=>{t({data:e})},children:(0,i.__)("Save","extendify-local")})]})]})}}}},1455:e=>{"use strict";e.exports=window.wp.apiFetch},1518:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>h});var o=n(1455),i=n.n(o),r=n(6087),s=n(7723),a=n(3410),l=n(790);const c=["is-style-outline"],d=({children:e})=>(0,l.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}),u=({children:e})=>(0,l.jsx)("div",{className:"rounded-lg border-b border-gray-300 bg-white",children:(0,l.jsx)("div",{className:"p-3",children:e})}),p=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),f=(e,t)=>{if(!e)return[];const n=new RegExp(`^${p(t)}--(\\d+)$`,"i"),o=[],i=new Set,r=[e,...e.querySelectorAll(`[class*="${t}--"]`)];for(const e of r)for(const t of e.classList){const e=t.match(n);if(e){const t=Number(e[1]);i.has(t)||(i.add(t),o.push(t))}}return o},{context:m,abilities:g}=window.extAgentData,h={available:()=>g?.canEditPosts&&!m?.adminPage&&m?.postId&&!m?.isBlogPage&&m?.isBlockTheme&&document.querySelector(".wp-site-blocks"),id:"edit-block-content",requires:["block"],whenFinished:{component:({inputs:e,onConfirm:t,onCancel:n})=>{const{block:o}=(0,a.Y)(),[m,g]=(0,r.useState)(!0),h=(0,r.useCallback)((()=>{const e=document.querySelector("[data-extendify-temp-replacement]");e&&e.remove();const t=document.querySelector(`[data-extendify-agent-block-id="${o}"]`);t&&(t.style.display=""),n()}),[n,o]);return(0,r.useEffect)((()=>{i()({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="${o}"]`);if(!t)return;const n=((e,t,n)=>{let o=e;return n.forEach((e=>{const n=f(t,e),i=((e,t)=>{const n=document.createElement("div");return n.innerHTML=e,f(n,t)})(o,e);if(!n.length||!i.length)return;const r=Math.min(n.length,i.length),s=new Map;for(let e=0;e<r;e++)s.set(i[e],n[e]);o=((e,t,n)=>{if(!n||!n.size)return e;const o=document.createElement("div");o.innerHTML=e;const i=new RegExp(`^${p(t)}--(\\d+)$`,"i"),r=t;return o.querySelectorAll(`[class*="${t}--"]`).forEach((e=>{const o=Array.from(e.classList);let s=!1;for(let e=0;e<o.length;e++){const r=o[e].match(i);if(!r)continue;const a=Number(r[1]);if(n.has(a)){const i=n.get(a),r=`${t}--${i}`;r!==o[e]&&(o[e]=r,s=!0)}}o.includes(r)||(o.push(r),s=!0),s&&(e.className=o.join(" "))})),o.innerHTML})(o,e,s)})),o})(e,t.cloneNode(!0),c);t.style.display="none";const i=document.createElement("template");i.innerHTML=n;const r=i.content.firstElementChild;r&&(r.setAttribute("data-extendify-temp-replacement",!0),t.parentNode.insertBefore(r,t.nextSibling),g(!1))}))}),[o,e]),m?(0,l.jsx)(d,{children:(0,l.jsx)(u,{children:(0,s.__)("Loading...","extendify-local")})}):(0,l.jsxs)(d,{children:[(0,l.jsx)(u,{children:(0,l.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,l.jsxs)("div",{className:"flex items-center justify-start gap-2 p-3",children:[(0,l.jsx)("button",{type:"button",className:"w-full rounded border border-gray-300 bg-white p-2 text-sm text-gray-700",onClick:h,children:(0,s.__)("Cancel","extendify-local")}),(0,l.jsx)("button",{type:"button",className:"w-full rounded border border-design-main bg-design-main p-2 text-sm text-white",onClick:()=>{t({data:e})},children:(0,s.__)("Save","extendify-local")})]})]})}}}},1528:(e,t,n)=>{var o={"./content/edit-post-strings-editor.js":1352,"./content/edit-post-strings.js":1429,"./dom-highlighter/edit-block-content.js":1518,"./misc/get-list-of-tours.js":5749,"./settings/edit-wp-setting.js":9586,"./theme/change-theme-variation.js":6905};function i(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]}i.keys=function(){return Object.keys(o)},i.resolve=r,e.exports=i,i.id=1528},1557:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>s});var o=n(1455),i=n.n(o);const r=window.wp.blockSerializationDefaultParser,s=async({postId:e,postType:t})=>{const n="page"===t?"pages":"posts",o=await i()({path:`/wp/v2/${n}/${e}?context=edit`}),s=(0,r.parse)(o.content.raw);return{post_strings:l([o.title.raw,...u(s)])}},a=e=>new Set(e.filter(Boolean)),l=e=>[...a(e)],c=e=>e.replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim(),d=e=>{const t=[],n=e.match(/alt="([^"]*)"/);n&&n[1]&&t.push(n[1].trim());const o=e.match(/title="([^"]*)"/);return o&&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||[])])):[]},1609:e=>{"use strict";e.exports=window.React},2094:(e,t,n)=>{"use strict";var o=n(8490),i=n.n(o),r=n(7828),s=n(365),a=n(6087),l=n(7723),c=n(6427),d=n(7677),u=n(4707),p=n(6942),f=n.n(p),m=n(9179);const g=e=>{const[t,n]=(0,a.useState)(null);return(0,a.useEffect)((()=>{let t=document.getElementById(e);return t||(t=Object.assign(document.createElement("div"),{className:"extendify-agent"}),t.id=e,document.getElementById("extendify-agent-main").prepend(t)),n(t),()=>t.remove()}),[e]),t};var h=n(3410),x=n(790);['[class^="wp-block-"]','[class*=" wp-block-"]'].map((e=>`main.wp-block-group ${e}`)).join(", ");var y=n(6221);const w=(e,t,n)=>Math.max(t,Math.min(e,n)),b=window.wp.date;var v=n(1621),k=n(7134);const j={x:100,y:window.innerHeight-510,width:390,height:510},_=(0,v.vt)()((0,k.Zr)((0,k.lt)(((e,t)=>({retryAfter:void 0,open:!0,seenToolTips:[],showSuggestions:!0,mode:"floating",...j,queuedTour:null,scratch:{},isMobile:window.innerWidth<768,setIsMobile:t=>e({isMobile:t}),queueTourForRedirect:t=>e({queuedTour:t}),clearQueuedTour:()=>e({queuedTour:null}),setOpen:n=>{n||t().resetPosition(),e({open:n})},setShowSuggestions:t=>e({showSuggestions:t}),toggleOpen:()=>e((e=>(e.open||t().resetPosition(),{open:!e.open}))),setSize:(t,n)=>e({width:t,height:n}),setPosition:(t,n)=>e({x:t,y:n}),resetPosition:()=>e({...j,y:window.innerHeight-510}),setSeenToolTip:t=>e((e=>e.seenToolTips.includes(t)?e:{seenToolTips:[...e.seenToolTips,t]})),updateRetryAfter:t=>e({retryAfter:t}),isChatAvailable:()=>{const{retryAfter:n}=t();if(!n)return!0;const o=(0,b.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}`,partialize:e=>{const{showSuggestions:t,isMobile:n,...o}=e;return{...o}}})),L=({children:e})=>{const[t,n]=(0,a.useState)(null),o=g("extendify-agent-mount"),{open:i,x:r,y:s,width:p,height:f,setOpen:h,setSize:b,setPosition:v}=_(),k=(0,a.useCallback)((e=>requestAnimationFrame((()=>n(e)))),[]);return(({el:e,open:t,initialPosition:n,onDragEnd:o})=>{const i=(0,a.useRef)({x:0,y:0}),r=(0,a.useRef)(null),s=(0,a.useRef)({x:n.x,y:n.y});(0,a.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,a.useLayoutEffect)((()=>{if(!e||!t)return;const n=window.innerWidth-e.offsetWidth,o=window.innerHeight-e.offsetHeight,i=parseFloat(e.style.left)||0,r=parseFloat(e.style.top)||0,s=w(i,0,n),a=w(r,0,o);i===s&&r===a||(e.style.setProperty("left",`${s}px`,"important"),e.style.setProperty("top",`${a}px`,"important"))}),[e,t]),(0,a.useLayoutEffect)((()=>{const a=document.getElementById("wpwrap")||document.querySelector(".wp-site-blocks");if(!e||!t||!a)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(),a.style.pointerEvents="none",null===r.current&&(r.current=t.pointerId,l.setPointerCapture(t.pointerId),i.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=w(t.clientX-i.current.x,0,n),a=w(t.clientY-i.current.y,0,o);e.style.setProperty("left",`${r}px`,"important"),e.style.setProperty("top",`${a}px`,"important"),s.current={x:r,y:a}},u=e=>{a.style.pointerEvents="auto",r.current===e.pointerId&&(r.current=null,l.releasePointerCapture(e.pointerId),document.removeEventListener("pointermove",d),document.removeEventListener("pointerup",u),o(s.current.x,s.current.y))},p=()=>u(new PointerEvent("pointerup")),f=e=>(e.preventDefault(),e.stopPropagation(),!1);return l.addEventListener("pointerdown",c),l.addEventListener("contextmenu",f),l.addEventListener("blur",p),()=>{l.removeEventListener("pointerdown",c),l.removeEventListener("blur",p),l.removeEventListener("contextmenu",f),document.removeEventListener("pointermove",d),document.removeEventListener("pointerup",u),a.style.pointerEvents="auto",null!==r.current&&(l.releasePointerCapture(r.current),r.current=null)}}),[e,t,n.x,n.y,o])})({el:t,open:i,initialPosition:{x:r,y:s},onDragEnd:(e,t)=>{v(e,t),window.dispatchEvent(new CustomEvent("extendify-agent:drag-end",{detail:{x:e,y:t}}))}}),(({el:e,open:t,initialSize:n,onResizeEnd:o,minWidth:i=250,minHeight:r=400,maxWidth:s=500,maxHeight:l=window.innerHeight})=>{const c=(0,a.useRef)({x:0,y:0,width:0,height:0}),d=(0,a.useRef)(null);(0,a.useLayoutEffect)((()=>{const a=document.getElementById("wpwrap")||document.querySelector(".wp-site-blocks");if(!e||!t||!a)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 p=t=>{t.preventDefault(),t.stopPropagation(),a.style.pointerEvents="none",null===d.current&&(d.current=t.pointerId,u.setPointerCapture(t.pointerId),c.current={x:t.clientX,y:t.clientY,width:e.offsetWidth,height:e.offsetHeight},document.addEventListener("pointermove",f),document.addEventListener("pointerup",m))},f=t=>{const n=e.getBoundingClientRect(),o=Math.min(s,window.innerWidth-n.left),a=Math.min(l,window.innerHeight-n.top),d=w(c.current.width+(t.clientX-c.current.x),i,o),u=w(c.current.height+(t.clientY-c.current.y),r,a);e.style.width=`${d}px`,e.style.height=`${u}px`},m=t=>{if(a.style.pointerEvents="auto",d.current!==t.pointerId)return;d.current=null,u.releasePointerCapture(t.pointerId),document.removeEventListener("pointermove",f),document.removeEventListener("pointerup",m);const n=e.getBoundingClientRect(),p=Math.min(s,window.innerWidth-n.left),g=Math.min(l,window.innerHeight-n.top),h=w(c.current.width+(t.clientX-c.current.x),i,p),x=w(c.current.height+(t.clientY-c.current.y),r,g);o(h,x)};return u.addEventListener("pointerdown",p),()=>{u.removeEventListener("pointerdown",p),document.removeEventListener("pointermove",f),document.removeEventListener("pointerup",m),a.style.pointerEvents="auto",null!==d.current&&(u.releasePointerCapture(d.current),d.current=null)}}),[e,t,n.width,n.height,o,i,r,s,l])})({el:t,open:i,initialSize:{width:p,height:f},onResizeEnd:(e,t)=>{b(e,t),window.dispatchEvent(new CustomEvent("extendify-agent:resize-end",{detail:{width:e,height:t}}))}}),(0,a.useEffect)((()=>{if(!t||!i)return;const e=new IntersectionObserver((e=>{e[0].isIntersecting||h(!1)}));return e.observe(t),()=>e.disconnect()}),[t,i,h]),o&&i?(0,a.createPortal)((0,x.jsx)(y.N,{children:(0,x.jsx)(m.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",style:{top:r,left:s,width:p,height:f},ref:k,children:(0,x.jsxs)(x.Fragment,{children:[(0,x.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,x.jsxs)("div",{"data-extendify-agent-handle":!0,draggable:!0,className:"flex h-full flex-grow cursor-grab select-none items-center justify-between gap-1 p-0 py-3",children:[(0,x.jsxs)("div",{className:"flex h-5 justify-center gap-2 px-4 rtl:after:-right-0",children:[(0,x.jsx)("div",{className:"flex h-5 max-w-[9rem] overflow-hidden",children:(0,x.jsx)("img",{className:"max-h-full max-w-full object-contain",src:window.extSharedData.partnerLogo,alt:window.extSharedData.partnerName})}),(0,x.jsx)("div",{className:"flex items-center rounded-lg bg-banner-text px-2 font-sans text-xs leading-none text-banner-main",children:(0,l._x)("beta","Feature in beta status","extendify-local")})]}),(0,x.jsx)("div",{className:"opacity-0 transition-opacity duration-300 group-hover:opacity-100",children:(0,x.jsx)(T,{})})]}),(0,x.jsx)(c.Tooltip,{text:(0,l.__)("Close window","extendify-local"),children:(0,x.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-none ring-design-main focus:shadow-none focus:outline-none focus-visible:outline-design-main",onClick:()=>{h(!1),window.dispatchEvent(new CustomEvent("extendify-agent:closed-button"))},children:[(0,x.jsx)(d.A,{className:"pointer-events-none fill-current leading-none",icon:u.A,size:18}),(0,x.jsx)("span",{className:"sr-only",children:(0,l.__)("Close window","extendify-local")})]})})]}),e,(0,x.jsx)("div",{"data-extendify-agent-resize":!0,className:"absolute -bottom-2 -right-2 z-high h-6 w-6",children:(0,x.jsx)("div",{className:"h-6 w-6 cursor-se-resize"})})]})},"agent-popout-modal")}),o):null},T=e=>(0,x.jsxs)("div",{style:{userSelect:"none"},className:"relative flex",...e,children:[(0,x.jsx)(d.A,{className:"pointer-events-none text-banner-text",icon:(0,x.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,x.jsx)("path",{fill:"currentColor",d:"M8 7h2V5H8v2zm0 6h2v-2H8v2zm0 6h2v-2H8v2zm6-14v2h2V5h-2zm0 8h2v-2h-2v2zm0 6h2v-2h-2v2z"})}),size:24}),(0,x.jsx)("span",{className:"sr-only",children:(0,l.__)("Drag to move","extendify-local")})]}),S=({children:e})=>{const t=g("extendify-agent-mount"),{open:n,setOpen:o}=_();return(0,a.useEffect)((()=>{if(t&&n)return document.body.style.overflow="hidden",()=>document.body.style.overflow=""}),[n,t]),t&&n?(0,a.createPortal)((0,x.jsxs)("div",{className:"fixed inset-0 z-max-1 flex items-center justify-center",children:[(0,x.jsx)("div",{className:"pointer-events-none absolute inset-0 bg-black/70"}),(0,x.jsx)(y.N,{children:(0,x.jsxs)(m.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,x.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,x.jsx)("div",{className:"flex h-full flex-grow items-center justify-between gap-1 p-0 py-3",children:(0,x.jsxs)("div",{className:"flex h-5 justify-center gap-2 px-4 rtl:after:-right-0",children:[(0,x.jsx)("div",{className:"flex h-5 max-w-[9rem] overflow-hidden",children:(0,x.jsx)("img",{className:"max-h-full max-w-full object-contain",src:window.extSharedData.partnerLogo,alt:window.extSharedData.partnerName})}),(0,x.jsx)("div",{className:"flex items-center rounded-lg bg-banner-text px-2 font-sans text-xs leading-none text-banner-main",children:(0,l._x)("beta","Feature in beta status","extendify-local")})]})}),(0,x.jsx)(c.Tooltip,{text:(0,l.__)("Close window","extendify-local"),children:(0,x.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-none ring-design-main focus:shadow-none focus:outline-none focus-visible:outline-design-main",onClick:()=>o(!1),children:[(0,x.jsx)(d.A,{className:"pointer-events-none fill-current leading-none",icon:u.A,size:18}),(0,x.jsx)("span",{className:"sr-only",children:(0,l.__)("Close window","extendify-local")})]})})]}),e]},"agent-popout-modal")})]}),t):null},N=({busy:e,children:t})=>{const{setIsMobile:n,isMobile:o}=_();return(0,a.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]),o?(0,x.jsx)(S,{children:(0,x.jsx)("div",{id:"extendify-agent-chat",className:"flex min-h-0 flex-1 flex-grow flex-col font-sans",children:t})}):(0,x.jsxs)(L,{children:[(0,x.jsx)("div",{id:"extendify-agent-chat",className:"flex min-h-0 flex-1 flex-grow flex-col font-sans",children:t}),!1]})};var E=n(8969),A=n(1455),C=n.n(A);const{chatHistory:P}=window.extAgentData,R="/extendify/v1/agent/chat-events",I={getItem:async()=>await C()({path:R}),setItem:async(e,t)=>await C()({path:R,method:"POST",data:{state:t}})},D=(0,v.vt)()((0,k.Zr)((0,k.lt)(((e,t)=>({messagesRaw:(P||[]).toReversed(),messages:P?.length?P.filter((e=>!["agent-working","calling-agent","tool-started"].includes(e.details?.type)&&!["workflow"].includes(e.type))).toReversed():[],seenAgents:[],getMessagesForChat:()=>{const e=[];let n=!1;for(const o of t().messagesRaw.toReversed()){const t=["completed","canceled"].includes(o.details.status);if("workflow"===o.type&&t)break;if("workflow-component"===o.type&&t)break;"message"===o.type&&"user"===o.details.role&&(n=!0),("message"!==o.type||n)&&"message"===o.type&&e.push(o.details)}return e.toReversed()},hasMessages:()=>t().messages.length>0,addMessage:(n,o)=>{const i=Date.now().toString(36)+Math.random().toString(36).slice(2);if(o?.agent?.name&&!t().seenAgents.includes(o.agent.name)){o.firstSeen=!0;const t=e=>new Set([...e.seenAgents,o.agent.name]);e((e=>({seenAgents:[...t(e)]})))}return e((e=>{const t=Math.max(0,e.messages.length-149),r={id:i,type:n,details:o};return{messages:[...e.messages.toSpliced(0,t),r],messagesRaw:[...e.messagesRaw.toSpliced(0,t),r]}})),i},clearMessages:()=>e({messages:[]})})),{name:"Extendify Agent Chat"}),{name:"extendify-agent-chat",storage:(0,k.KU)((()=>I)),skipHydration:!0}));var M=n(9333);const $={...Object.fromEntries(Object.entries(window.extSharedData).filter((([e])=>["partnerId","devbuild","version","siteId","wpLanguage","wpVersion","siteProfile"].includes(e))))},q=async({tool:e,inputs:t})=>{if(!M.Y[e])throw new Error(`Tool ${e} not found`);return await M.Y[e](t)},B=({error:e,sessionId:t,caller:n,extra:o={}})=>{if(!0===Boolean($?.devbuild))return;const i={message:e.response&&e.response.statusText?e.response?.statusText||e.response.message||"Unknown error":"string"==typeof e?e:e?.message||"Unknown error",name:e?.name};return fetch(`${E.AY}/api/agent/digest`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...$,phpVersion:window.extSharedData?.phpVersion,sessionId:t,error:i,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})}).catch((()=>{}))};var F=n(642);const O=({disabled:e,handleSubmit:t})=>{const n=(0,a.useRef)(null),[o,i]=(0,a.useState)(""),[r,s]=(0,a.useState)(!1),[c,u]=(0,a.useState)([]),p=(0,a.useRef)(!1),[m,g]=(0,a.useState)(null),h=(0,a.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+2);s(t>80),n.current.style.height=`${t}px`}),[]);(0,a.useLayoutEffect)((()=>(window.addEventListener("extendify-agent:resize-end",h),h(),()=>window.removeEventListener("extendify-agent:resize-end",h))),[h]),(0,a.useEffect)((()=>{const e=({detail:e})=>{u((t=>t?.at(-1)===e.message?t:[...t,e.message])),g(null)};return window.addEventListener("extendify-agent:chat-submit",e),()=>window.removeEventListener("extendify-agent:chat-submit",e)}),[]),(0,a.useEffect)((()=>{h()}),[o,h]),(0,a.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]));u(t)}),[]);const y=(0,a.useCallback)((e=>{e?.preventDefault(),o.trim()&&(t(o),u((e=>e?.at(-1)===o?e:[...e,o])),g(null),i(""),requestAnimationFrame((()=>{p.current=!1,h(),n.current?.focus()})))}),[o,t,h]),w=(0,a.useCallback)((e=>{if("Enter"===e.key&&!e.shiftKey&&!e.nativeEvent.isComposing)return e.preventDefault(),void y();if(!p.current){if("ArrowUp"===e.key){if(!c.length)return;if(e.shiftKey||e.ctrlKey||e.altKey||e.metaKey)return;return g((e=>{const t=null===e?c.length-1:Math.max(e-1,0);return i(c[t]),t})),void e.preventDefault()}if("ArrowDown"===e.key){if(null===m)return;if(e.shiftKey||e.ctrlKey||e.altKey||e.metaKey)return;return g((e=>{if(null===e)return null;const t=e+1;return t>=c.length?(i(""),null):(i(c[t]),t)})),void e.preventDefault()}p.current=!0}}),[c,m,y]);return(0,x.jsxs)("form",{onSubmit:y,className:"relative flex w-full flex-col gap-4 p-4 pb-2 pt-0",children:[(0,x.jsx)("textarea",{ref:n,id:"extendify-agent-chat-textarea",disabled:e,className:f()("flex max-h-[calc(75dvh)] min-h-10 w-full resize-none overflow-hidden rounded border border-gray-300 px-3 py-[9px] text-base placeholder:text-gray-700 focus-within:outline-design-main focus:rounded focus:border-design-main focus:ring-design-main disabled:opacity-50 md:text-sm",{"bg-gray-300":e,"bg-gray-50":!e,"pr-6":!r}),placeholder:(0,l.__)("Ask anything","extendify-local"),rows:"1",autoFocus:!0,value:o,onChange:e=>{i(e.target.value),g(null),h()},onKeyDown:w}),(0,x.jsx)("div",{className:"absolute bottom-[1.125rem] right-6 flex flex-row justify-end md:bottom-4 rtl:left-6 rtl:right-auto",children:(0,x.jsxs)("button",{type:"submit",className:"inline-flex h-fit items-center justify-center gap-2 whitespace-nowrap rounded-full border bg-design-main p-0.5 text-sm font-medium text-white transition-colors focus-visible:ring-design-main disabled:opacity-20",disabled:e||0===o.trim().length,children:[(0,x.jsx)(d.A,{fill:"currentColor",icon:F.A,size:18}),(0,x.jsx)("span",{className:"sr-only",children:(0,l.__)("Send message","extendify-local")})]})})]})};var z=n(7783);const W=({canScrollDown:e,onClick:t})=>(0,x.jsx)("div",{className:"pointer-events-none sticky bottom-1 flex h-8 items-center justify-center",children:(0,x.jsx)(y.N,{children:e?(0,x.jsxs)(m.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,x.jsx)(d.A,{fill:"currentColor",icon:z.A,size:20}),(0,x.jsx)("span",{className:"sr-only",children:(0,l.__)("Scroll down","extendify-local")})]},"scroll-down"):null})});var H=n(1609);const V=({children:e,...t})=>{const n=(0,H.useRef)(null),o=(0,H.useRef)(!1);return(0,H.useEffect)((()=>{if(!n.current||o.current)return;const e=n.current,t=e.getBoundingClientRect(),i=window.innerHeight||document.documentElement.clientHeight,r=t.height,s=Math.max(t.top,0),a=Math.min(t.bottom,i);Math.max(0,a-s)/r>=.5||(e.scrollIntoView({behavior:"smooth",block:"end"}),o.current=!0)}),[t]),(0,x.jsx)("div",{ref:n,...t,children:e})};var U=n(8537),Z=n(9148),Y=n(7589),K=n(998),X=n(684),G=n(8334);const J=({words:e,delay:t=.4,duration:n=.25})=>{const o=e.every((e=>1===e.length));return(0,x.jsx)(y.N,{children:e.map(((e,i)=>(0,x.jsx)(m.P.span,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0},transition:{duration:n,delay:i*t},children:o?e:(0,x.jsx)(G.oz,{children:e})},i)))})},Q=(0,x.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,x.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,x.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,x.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"})]}),ee=(0,x.jsxs)(m.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,x.jsx)(m.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,x.jsx)(m.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,x.jsx)(m.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,x.jsx)(m.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,x.jsx)(m.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,x.jsx)(m.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}})]}),te=(0,x.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,x.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"})}),ne=(0,x.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,x.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"})}),oe=(0,x.jsxs)("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:[(0,x.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,x.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,x.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"})]});var ie=n(2619);(0,ie.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 re=(0,ie.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 se=n(9035),ae=n(7806);const le=Object.values(se.A),ce=window.extAgentData.agentContext?.availableAdminPages||[],de=Object.fromEntries(ce.map((e=>{var t;return[e,{label:(0,l.__)("Take me there","extendify-local"),tour:null!==(t=le.find((t=>t.id===re[e])))&&void 0!==t?t:null}]})))||{},ue={agent1:Z.A,agent2:Y.A,agent3:K.A,agent4:X.A},pe=({message:e,animate:t})=>{var n,o;const{content:i,role:r,pageSuggestion:s,agent:a}=e.details,u=/```[\s\S]*?```/.test(i)?[(0,U.decodeEntities)(i)]:(0,U.decodeEntities)(i).split(/\n{2,}/),p=Object.keys(de).find((e=>s?.startsWith(e))),f=de[p]||{};return(0,x.jsxs)("div",{"data-agent-message-role":r,className:"flex w-full items-start gap-2.5 p-2",children:[(0,x.jsx)("div",{className:"w-7 flex-shrink-0",children:(0,x.jsx)(c.Tooltip,{text:null!==(n=a?.name)&&void 0!==n?n:(0,l.__)("Agent","extendify-local"),placement:"top",children:a?.avatar?(0,x.jsx)("img",{className:"mt-px",src:a.avatar,alt:a.name}):(0,x.jsx)(d.A,{className:"-mt-0.5 fill-gray-900",icon:null!==(o=ue[a?.id])&&void 0!==o?o:Q,size:28})})}),(0,x.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-4",children:[(0,x.jsx)("div",{className:"extendify-agent-markdown w-full",children:t?(0,x.jsx)(J,{words:u,delay:.1,duration:.35}):(0,x.jsx)(G.oz,{children:(0,U.decodeEntities)(i)})}),f?.label?(0,x.jsx)("div",{children:(0,x.jsx)("a",{href:`${window.extSharedData.adminUrl}${s}`,className:"rounded border border-design-main bg-design-main p-2 text-sm text-white no-underline hover:opacity-90",children:f.label})}):null,f?.tour&&(0,x.jsx)("div",{children:(0,x.jsx)(ae.L,{tour:f.tour})})]})]})};var fe=n(3670);const me=({status:e,animate:t})=>{const{type:n,label:o}=e.details,i={"calling-agent":(0,l.__)("Thinking...","extendify-local"),"agent-working":(0,l.__)("Working on it...","extendify-local"),"tool-started":o||(0,l.__)("Gathering data...","extendify-local"),"tool-completed":o||(0,l.__)("Analyzing...","extendify-local"),"tool-canceled":o||(0,l.__)("Canceled","extendify-local"),"workflow-tool-canceled":o||(0,l.__)("Canceled","extendify-local"),"credits-exhausted":(0,l.__)("Usage limit reached","extendify-local"),"credits-restored":(0,l.__)("Usage limit restored","extendify-local")},r=["calling-agent","agent-working","tool-started"].includes(n);if("error"===n)return(0,x.jsx)(fe.K,{children:(0,x.jsxs)("div",{className:"text-sm",children:[(0,x.jsx)("div",{className:"font-semibold",children:(0,l.__)("Something went wrong","extendify-local")}),(0,x.jsx)("div",{className:"",children:(0,l.__)("An unexpected error occurred while processing your request.","extendify-local")})]})});if("workflow-tool-completed"===n)return(0,x.jsx)(ge,{label:o});const s=i[n];return s?(0,x.jsx)("div",{className:f()("p-2 text-center text-xs italic text-gray-700",{"status-animation":r}),children:t?(0,x.jsx)(J,{words:s.split(""),delay:.02}):s}):null},ge=({label:e})=>(0,x.jsxs)("div",{className:"flex w-full items-start gap-2.5 p-2",children:[(0,x.jsx)("div",{className:"w-7 flex-shrink-0"}),(0,x.jsx)("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:(0,x.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,x.jsx)("div",{className:"h-6 w-6 leading-none",children:(0,x.jsx)("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,x.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,x.jsx)("div",{className:"text-sm",children:e||(0,l.__)("Workflow completed successfully","extendify-local")})]})})]}),he=({message:e})=>{const{content:t,role:n}=e.details;return(0,x.jsx)("div",{"data-agent-message-role":n,className:"flex w-full flex-col items-end p-2",children:(0,x.jsx)("div",{className:"max-w-[80%] rounded-xl bg-gray-100 p-1.5 px-2.5 text-gray-900",children:(0,U.decodeEntities)(t)})})},xe=({message:e})=>{const t=M.L.find((t=>t.id===e.details.id))?.whenFinished?.component;return t?(0,x.jsx)(t,{...e.details}):(0,x.jsx)(ye,{})},ye=()=>(0,x.jsx)(fe.K,{children:(0,x.jsxs)("div",{className:"text-sm",children:[(0,x.jsx)("div",{className:"font-semibold",children:(0,l.__)("Component not available","extendify-local")}),(0,x.jsx)("div",{className:"",children:(0,l.__)(
// translators: This is for when a component doesn't exist
"It may have been removed or is not available for your account.","extendify-local")})]})});var we=n(3803),be=n(8176),ve=n(2043),ke=n(6655),je=n(5295);const{suggestions:_e}=window.extAgentData,Le=Object.values(se.A).filter((({settings:{startFrom:e}})=>!e||e.includes(window.location.href))),Te=Le?.length?Le[Math.floor(Math.random()*Le.length)]:void 0,Se=Te?.message&&(_e.length<3||Math.random()<.3),Ne={styles:Y.A,edit:we.A,help:be.A,video:ve.A,sparkle:oe},Ee=_e.filter((e=>!!e?.feature)),Ae=_e.filter((e=>!e?.feature)),Ce=()=>{const{startTour:e}=(0,je.n)(),[t,n]=(0,a.useState)(Ae);(0,a.useEffect)((()=>{n((e=>e.toSorted((()=>Math.random()-.5))))}),[]);const o=e=>{window.dispatchEvent(new CustomEvent("extendify-agent:chat-submit",{detail:{message:e}}))};return(0,x.jsxs)(x.Fragment,{children:[Se?(0,x.jsx)(Pe,{suggestion:{...Te,icon:"video"},handleSubmit:()=>e(Te)},Te.message):null,[...Ee,...t].slice(0,Se?2:3).map((e=>(0,x.jsx)(Pe,{suggestion:e,handleSubmit:o},e.message)))]})},Pe=({suggestion:e,handleSubmit:t})=>{var n;const o=null!==(n=Ne[e?.icon])&&void 0!==n?n:Ne.sparkle;return(0,x.jsxs)("button",{type:"button",className:"group flex items-center justify-between rounded bg-transparent px-1 py-1 text-left text-sm text-gray-900 transition-colors duration-100 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-design-main",onClick:()=>t(e.message),children:[(0,x.jsxs)("div",{className:"flex items-center gap-1.5 leading-none",children:[(0,x.jsx)("span",{className:"h-5 w-5 flex-shrink-0 self-start fill-gray-700",children:o}),(0,x.jsx)("span",{className:"leading-5",children:e.message})]}),(0,x.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:ke.A})]})},Re=({answerId:e})=>{const[t,n]=(0,a.useState)(void 0);return(0,a.useEffect)((()=>{e&&void 0!==t&&(({answerId:e,rating:t})=>{fetch(`${E.AY}/api/agent/rate-workflow`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({answerId:e,rating:t})}).catch((n=>B({caller:"rateAnswer",error:n,extra:{answerId:e,rating:t}})))})({answerId:e,rating:t})}),[t,e]),(0,x.jsx)("div",{className:"flex items-center justify-end",children:(0,x.jsxs)("div",{className:"flex items-center gap-px rounded-xl border border-gray-400 bg-gray-50 px-2 text-right",children:[(0,x.jsx)("button",{type:"button","aria-pressed":1===t,"aria-live":"polite",onClick:()=>n((e=>1===e?0:1)),"aria-label":1===t?(0,l.__)("Remove rating","extendify-local"):(0,l.__)("Rate that this answer was helpful","extendify-local"),className:f()("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,x.jsx)(d.A,{className:"fill-current",icon:ne})}),(0,x.jsx)("button",{type:"button","aria-pressed":-1===t,"aria-live":"polite",onClick:()=>n((e=>-1===e?0:-1)),"aria-label":-1===t?(0,l.__)("Remove rating","extendify-local"):(0,l.__)("Rate that this answer was not helpful","extendify-local"),className:f()("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,x.jsx)(d.A,{className:"fill-current",icon:te})})]})})},Ie=({message:e})=>{const{status:t,answerId:n}=e.details;return(0,x.jsxs)("div",{className:"flex flex-col gap-px p-2 text-center text-xs italic",children:[n&&(0,x.jsx)(Re,{answerId:n}),["completed","canceled"].includes(t)?(0,x.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,x.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,l.__)("What's next? Would you like to do something else?","extendify-local")}),(0,x.jsx)(Ce,{})]}):null]})},De=()=>{const{open:e}=_(),{messages:t}=D(),{getWhenFinishedToolProps:n,getWorkflow:o}=(0,h.Y)(),i=o(),r=n(),s=i?.whenFinished?.component,[l,c]=(0,a.useState)(!1),d=(0,a.useRef)(null),u=(0,a.useRef)(!0),p="user"===t.filter((({type:e})=>"status"!==e)).at(-1)?.details?.role;return(0,a.useEffect)((()=>{if(d.current&&e&&u.current)return u.current=!1,d.current.scrollTo({top:d.current.scrollHeight}),()=>{u.current=!0}}),[e]),(0,a.useEffect)((()=>{if(!d.current)return;if(!p)return;const e=d.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"),i=n.getBoundingClientRect(),r=Array.from(o.children).reduce(((e,t)=>e+t.offsetHeight),0)+e.clientHeight-i.height;o.style.minHeight=`${r}px`,n.scrollIntoView({behavior:"smooth",block:"start"})}),[p,t]),(0,a.useEffect)((()=>{if(!d.current)return;const e=d.current,t=e.querySelector("#extendify-agent-chat-scroll-area > :last-child");if(!t)return;const n=new IntersectionObserver((([t])=>{const n=e.getBoundingClientRect(),o=t.boundingClientRect.bottom>n.bottom;c(!t.isIntersecting&&o)}),{root:e});return n.observe(t),()=>n.disconnect()}),[t]),(0,x.jsxs)("div",{ref:d,style:{overscrollBehavior:"contain"},className:"relative flex-grow overflow-y-auto overflow-x-hidden p-1 pb-0 text-sm text-gray-900 md:p-2",children:[(0,x.jsxs)("div",{id:"extendify-agent-chat-scroll-area",children:[t.map((e=>{const n=t.at(-1)?.id===e.id,o=u.current;if("user"===e.details?.role)return(0,x.jsx)(he,{message:e},e.id);if("assistant"===e.details?.role)return(0,x.jsx)(pe,{animate:!o,message:e},e.id);if("workflow"===e.type)return(0,x.jsx)(Ie,{message:e},e.id);if("workflow-component"===e.type)return(0,x.jsx)(xe,{message:e},e.id);if("status"===e.type&&(n||["workflow-tool-completed","workflow-tool-canceled"].includes(e.details?.type))){const t="error"===e.details?.type;return(0,x.jsx)(me,{animate:!t,status:e},e.id)}return null})),!i?.needsRedirect?.()&&r?.id&&s?(0,x.jsx)(V,{children:(0,a.createElement)(s,r)}):null,i?.needsRedirect?.()?(0,x.jsx)(i.redirectComponent,{}):null]}),(0,x.jsx)(W,{canScrollDown:l,onClick:()=>{if(!d.current)return;const e=d.current.querySelector("#extendify-agent-chat-scroll-area > :last-child");e&&e.scrollIntoView({behavior:"smooth",block:"start"})}})]})};var Me=n(6104);const $e=({busy:e})=>{const{setBlock:t}=(0,h.Y)();return(0,x.jsxs)("div",{className:"flex items-center justify-between gap-1 text-sm text-gray-900",children:[(0,x.jsxs)("div",{className:"flex items-center gap-1",children:[(0,x.jsx)(d.A,{icon:Me.A}),(0,x.jsx)("div",{children:(0,l.__)("Content selected","extendify")})]}),(0,x.jsx)(c.Tooltip,{text:(0,l.__)("Remove","extendify-local"),children:(0,x.jsxs)("button",{type:"button",disabled:e,className:"flex h-full items-center rounded-none border-0 bg-transparent outline-none ring-design-main focus:shadow-none focus:outline-none focus-visible:outline-design-main",onClick:()=>t(null),children:[(0,x.jsx)(d.A,{className:"pointer-events-none fill-current leading-none",icon:u.A,size:18}),(0,x.jsx)("span",{className:"sr-only",children:(0,l.__)("Remove","extendify-local")})]})})]})},qe=window.extSharedData.launchCompletedAt;let Be=!1;try{const e=new Date(qe),t=new Date;t.setDate(t.getDate()-1),Be=e<t}catch(Oe){}const Fe=()=>(0,x.jsxs)("div",{className:"relative flex h-full flex-col border-t border-solid border-gray-300",children:[(0,x.jsx)("div",{className:"relative mx-2 flex flex-grow items-end overflow-y-auto overflow-x-hidden px-2 text-gray-900",children:(0,x.jsxs)("div",{className:"flex flex-col gap-1",children:[Be?null:(0,x.jsxs)("div",{className:"text-2xl font-semibold text-gray-700",children:[(0,l.__)("Site is live!","extendify-local")," 🎉"]}),(0,x.jsx)("div",{className:"mb-2 text-2xl font-semibold",children:(0,l.__)("Your expert AI team is here","extendify-local")}),(0,x.jsx)("div",{className:"text-md text-base text-gray-900",children:(0,l.__)("Your team of site experts — designers, developers, and marketers — ready to help from content to layouts. Tell us what you need or pick a task to start.","extendify-local")})]})}),(0,x.jsx)("div",{className:"relative my-2 flex flex-col gap-0.5 p-2",children:(0,x.jsx)(Ce,{})})]});var Oe=n(3889);const ze=({onReady:e})=>{const{retryAfter:t,isChatAvailable:n}=_(),[o,i]=(0,a.useState)(null);if((0,a.useEffect)((()=>{if(!t)return;const o=setInterval((()=>{n()&&e(),i((()=>(0,b.humanTimeDiff)(new Date(Number(t)+45e3),new Date)))}),1e3);return()=>clearInterval(o)}),[n,t,e]),t&&o)return(0,x.jsxs)("div",{className:"flex gap-2 rounded-lg bg-gray-100 p-3 text-sm text-gray-900",children:[(0,x.jsx)(d.A,{icon:Oe.A,className:"flex-none"}),(0,x.jsx)("div",{className:"grow",children:(0,x.jsx)("div",{children:(0,l.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,l.__)("You have reached your daily messages limit. Your limit will reset in %s.","extendify-local"),o)})})]})},We=window.extSharedData.devbuild,He=()=>{const{hasMessages:e,addMessage:t}=D(),{mergeWorkflowData:n,getWorkflow:o,workflowData:i,setWorkflow:r,addWorkflowResult:s,setWhenFinishedToolProps:c,whenFinishedToolProps:d,getAvailableWorkflows:u,block:p,setBlock:f}=(0,h.Y)(),m=u().map((e=>e.id)),{open:g,setOpen:y,showSuggestions:w,setShowSuggestions:b,updateRetryAfter:v,isChatAvailable:k}=_(),[j,L]=(0,a.useState)(!0),T=(0,a.useRef)(!1),S=(0,a.useRef)(!1),[A,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(0),I=o(),M=(0,a.useMemo)((()=>k()),[k]),F=(0,a.useCallback)((()=>{L(!0),T.current=!1,C(!1),p&&f(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"})}),[f,p]),z=(0,a.useCallback)((async(e={})=>{t("status",{type:"calling-agent"});const n=await(async({workflows:e,options:t})=>{const{failedWorkflows:n,context:o}=window.extAgentData,i=null!=n?n:new Set,r=e.filter((e=>!i.has(e.id))),s=h.Y.getState().workflowHistory,a=D.getState().getMessagesForChat(),l=await fetch(`${E.AY}/api/agent/find-agent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...$,workflows:r,workflowHistory:s.filter(Boolean).slice(0,5).filter((e=>e.summary)).map((e=>e.summary)),previousAgentName:s.at(0)?.agentName,context:o,agentContext:window.extAgentData.agentContext,messages:a.slice(-5),...t})}).catch((e=>B({caller:"pick-workflow",error:e})));if(!l.ok){const e=new Error("Bad response from server");throw e.response=l,e}return await l.json()})({workflows:m,options:e}).catch((e=>{if(We&&console.error(e),429===e?.response?.status)return v(e?.response?.headers?.get("Retry-After")),L(!1),void t("status",{type:"credits-exhausted"});t("status",{type:"error"}),L(!0)}));if(!n)return;const{workflow:o,reply:i}=n;o?.id&&r(o),i&&t("message",{role:"assistant",content:i,agent:o?.agent}),o?.id||L(!0)}),[t,v,r,m]),W=(0,a.useCallback)((async e=>{if(b(!1),C(!1),T.current=!1,t("message",{role:"user",content:e}),L(!1),I?.needsRedirect?.()&&r(null),I&&!I?.needsRedirect?.()){const e=i||{};return r({...I}),void n(e)}await z().catch((e=>We&&console.error(e)))}),[t,z,n,r,I,i,b]);(0,a.useEffect)((()=>{const e=({detail:e})=>{e?.message&&W(e.message)};return window.addEventListener("extendify-agent:chat-submit",e),()=>window.removeEventListener("extendify-agent:chat-submit",e)}),[W]),(0,a.useEffect)((()=>{const e=async({detail:e})=>{if(S.current)return;S.current=!0;const{data:n,whenFinishedToolProps:o}=null!=e?e:{},{summary:i,status:a,whenFinishedTool:l,answerId:c}=o.agentResponse,{id:d,labels:u}=l||{},p=await(q?.({tool:d,inputs:n}).catch((e=>{const{sessionId:t}=I||{};return B({caller:`when-finished: ${d}`,sessionId:t,error:e}),We&&console.error(e),{error:e.message}})));if(S.current=!1,s({answerId:c,agentName:I?.agent?.name,summary:i,status:a,errorMsg:p?.error}),p?.error)return t("status",{type:"error"}),r(null),void F();t("status",{label:u?.confirm,type:"workflow-tool-completed"}),t("workflow",{status:"completed",agent:I.agent,answerId:c}),r(null),F()},n=({detail:e})=>{if(S.current)return;const{summary:n,whenFinishedTool:o,answerId:i}=e.whenFinishedToolProps.agentResponse;t("workflow",{status:"canceled",agent:I.agent,answerId:i}),s({answerId:i,summary:n,status:"canceled",agentName:I?.agent?.name}),r(null),F(),t("status",{label:o?.labels?.cancel,type:"workflow-tool-canceled"})};return window.addEventListener("extendify-agent:workflow-confirm",e),window.addEventListener("extendify-agent:workflow-cancel",n),()=>{window.removeEventListener("extendify-agent:workflow-confirm",e),window.removeEventListener("extendify-agent:workflow-cancel",n)}}),[t,F,s,r,I]),(0,a.useEffect)((()=>{const e=()=>y(!1),t=()=>y(!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)}}),[y]),(0,a.useEffect)((()=>{if(A||!g||!I?.id)return;const e=I?.startingPage!==window.location.href,o=!p&&I?.requires?.includes("block");if(I?.cancelOnPageChange&&e||o)return t("workflow",{status:"canceled",agent:I.agent}),r(null),void F();d?.id||(I?.needsRedirect?.()?F():(async()=>{if(T.current)return;L(!1),b(!1),T.current=!0,t("status",{type:"agent-working"});const e=await(async({workflow:e,workflowData:t})=>{const n=D.getState().getMessagesForChat(),o=await fetch(`${E.AY}/api/agent/handle-workflow`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...$,workflow:e,workflowData:t,messages:n,context:window.extAgentData.context,agentContext:window.extAgentData.agentContext})}).catch((e=>{throw e}));if(!o.ok)throw new Error("Bad response from server");return await o.json()})({workflow:I,workflowData:i}).catch((e=>{const{sessionId:t}=I||{};return B({caller:"handle-workflow",sessionId:t,error:e}),We&&console.error(e),{error:e.message}})),{summary:o,status:a,answerId:l}=e;if(s({answerId:l,summary:o,status:a,errorMsg:e?.error,agentName:I?.agent?.name}),g){if(e.error)throw window.extAgentData.failedWorkflows=window.extAgentData.failedWorkflows||new Set,window.extAgentData.failedWorkflows.add(I.id),new Error(`Error handling workflow: ${e.error}`);if(e.reply&&t("message",{role:"assistant",content:e.reply,followup:!!e.tool,pageSuggestion:e.pageSuggestion,agent:I.agent}),e.whenFinishedTool?.id){c({...e.whenFinishedTool,agentResponse:e});const{id:n,inputs:o,static:i}=e.whenFinishedTool;i&&(t("workflow-component",{id:n,status:"completed",inputs:o}),r(null),t("workflow",{status:"completed",agent:I.agent,answerId:l}),F())}else{if("handoff"===e.status){const e=I.id;return r(null),F(),void await z({handoff:e})}if("completed"===e.status)return r(null),F(),void t("workflow",{status:"completed",agent:I.agent,answerId:l});if("canceled"===e.status)return r(null),F(),void t("workflow",{status:"canceled",agent:I.agent,answerId:l});if(n(e.inputs),e.tool){const{id:o,inputs:i,labels:r}=e.tool;t("status",{label:r?.started,type:"tool-started"});const s=await Promise.all([q({tool:o,inputs:i}),new Promise((e=>setTimeout(e,3e3)))]).then((([e])=>e)).catch((e=>{const{sessionId:t}=I||{};throw B({caller:`in-progress: ${o}`,sessionId:t,error:e}),We&&console.error(e),e}));return t("status",{label:r?.confirm,type:"tool-completed"}),await new Promise((e=>setTimeout(e,1e3))),n(s),C(!1),T.current=!1,void R((e=>e+1))}L(!0),C(!0)}}})().catch((e=>{const{sessionId:n}=I||{};B({caller:"main-loop",sessionId:n,error:e}),We&&console.error(e),r(null),F(),t("status",{type:"error"})})))}),[P,F,s,g,I,i,t,r,T,A,n,j,z,b,d,c,p]),(0,a.useEffect)((()=>{j&&document.querySelector("#extendify-agent-chat-textarea")?.focus()}),[j]);const H=!e(),V=!I?.id&&!H&&M&&w&&!p,U=!j||!M||I?.id;return(0,x.jsx)(N,{busy:U,children:(0,x.jsxs)("div",{className:"relative z-50 flex h-full flex-col overflow-auto border-t border-solid border-gray-300",children:[H?(0,x.jsx)("div",{className:"h-full",style:{backgroundImage:"linear-gradient( to bottom, #f0f0f0 0%, #fff 60%,  #fff 100%)"},children:(0,x.jsx)(Fe,{})}):(0,x.jsx)(De,{redirectComponent:I?.needsRedirect?.()?I.redirectComponent:null}),(0,x.jsxs)("div",{children:[(0,x.jsxs)("div",{className:"relative flex flex-col px-3 pb-2 pt-2.5 shadow-lg-flipped",children:[V?(0,x.jsx)(Ce,{}):null,p?(0,x.jsx)($e,{busy:U,blockId:p}):null,(0,x.jsx)(ze,{onReady:()=>{F(),b(!0),t("status",{type:"credits-restored"})}})]}),(0,x.jsx)(O,{disabled:!j||!M,handleSubmit:W}),(0,x.jsx)("div",{className:"text-pretty px-4 pb-2 text-center text-xss leading-none text-gray-600",children:(0,l.__)("AI Agent can make mistakes. Check changes before saving.","extendify-local")})]})]})})};var Ve=n(2279);const Ue=()=>{const{toggleOpen:e,open:t,isMobile:n}=_(),[o,i]=(0,a.useState)(!1),[r,s]=(0,a.useState)(!1),d=(0,a.useRef)(!1);return(0,a.useEffect)((()=>{if(!d.current)return void(d.current=!0);if(t||n)return;i(!0),s(!0);const e=setTimeout((()=>{i(!1)}),1500),o=setTimeout((()=>{s(!1)}),5e3);return()=>{clearTimeout(e),clearTimeout(o)}}),[t,n]),n?null:(0,x.jsxs)("button",{type:"button",className:f()("m-1 items-center justify-center rounded-sm border-0 bg-wp-theme-main p-0.5 px-1.5 leading-extra-tight text-white ring-offset-[#1D2327] focus:outline-none focus:ring-wp focus:ring-wp-theme-main focus:ring-offset-1 md:inline-flex",{"opacity-60":t}),onClick:()=>{t&&i(!0),e()},"aria-label":(0,l.__)("Open Agent","extendify-local"),children:[(0,x.jsx)(c.Icon,{icon:r?ee:Q,width:20,height:20,className:f()("fill-design-text",{"scale-x-[-1]":(0,l.isRTL)()})}),(0,x.jsx)("span",{className:f()("px-1 leading-none",{"extendify-gradient-animation":o}),children:(0,l.__)("AI Agent","extendify-local")})]})};var Ze=n(3756);const Ye=()=>{const{toggleOpen:e,open:t,isMobile:n}=_(),o=(0,a.useRef)(null);return(0,a.useEffect)((()=>{n&&!t&&document.body.style.setProperty("--extendify-agent-mobile-btn-height",`${o.current?.offsetHeight}px`)}),[n,t]),(0,a.useEffect)((()=>{if(n)return document.body.classList.add("extendify-agent-mobile-btn-open"),()=>{document.body.classList.remove("extendify-agent-mobile-btn-open")}}),[n]),!n||t?null:(0,x.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:e,"aria-label":(0,l.__)("Open Agent","extendify-local"),children:[(0,x.jsxs)("div",{className:"flex gap-3",children:[(0,x.jsx)("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-wp-theme-main",children:(0,x.jsx)(d.A,{icon:Q,size:24})}),(0,x.jsxs)("div",{className:"text-left text-sm rtl:text-right",children:[(0,x.jsx)("div",{className:"font-semibold",children:(0,l.__)("AI Agent","extendify-local")}),(0,x.jsx)("div",{className:"text-gray-600",children:(0,l.__)("How can we help you today?","extendify-local")})]})]}),(0,x.jsx)(d.A,{className:"fill-white",icon:Ze.A,size:24})]})},Ke=()=>{const{toggleOpen:e,open:t,isMobile:n}=_(),[o,i]=(0,a.useState)(!1),[r,s]=(0,a.useState)(!1),d=(0,a.useRef)(!1);return(0,a.useEffect)((()=>{if(!d.current)return void(d.current=!0);if(t||n)return;i(!0),s(!0);const e=setTimeout((()=>{i(!1)}),1500),o=setTimeout((()=>{s(!1)}),5e3);return()=>{clearTimeout(e),clearTimeout(o)}}),[t,n]),n?null:(0,x.jsx)(c.Button,{variant:"primary",icon:r?ee:Q,iconPosition:"left",className:"is-compact has-text relative z-10",onClick:()=>{t&&i(!0),e()},"aria-label":(0,l.__)("Open Agent","extendify-local"),children:(0,x.jsx)("span",{className:f()("px-1 leading-none",{"extendify-gradient-animation":o}),children:(0,l.__)("AI Agent","extendify-local")})})};i()((()=>{if((0,s.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",document.querySelector("#wp-admin-bar-my-account")?.before(t),(0,r.X)((0,x.jsx)(Ue,{}),t)})),i()((()=>{if((0,s.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="9999",document.body.appendChild(t),(0,r.X)((0,x.jsx)(Ye,{}),t)})),(0,Ve.registerPlugin)("extendify-agent-buttons",{render:()=>(0,x.jsx)(Xe,{})});const Xe=()=>((0,a.useEffect)((()=>{if((0,s.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});requestAnimationFrame((()=>{requestAnimationFrame((()=>{document.getElementById(e)||(document.querySelector('[aria-controls="edit-post:document"]')?.after(t),document.querySelector('[aria-controls="edit-site:template"]')?.after(t),(0,r.X)((0,x.jsx)(Ke,{}),t))}))}))}),[]),null);var Ge=n(8971);const Je=e=>{const{top:t,right:n,bottom:o,left:i,width:r,height:s,x:a,y:l}=e.getBoundingClientRect();return{top:t,right:n,bottom:o,left:i,width:r,height:s,x:a,y:l}},Qe=()=>{var e,t;const n=(0,a.useRef)(),{currentTour:o,currentStep:i,startTour:r,closeCurrentTour:s,getStepData:c,onTourPage:p}=(0,je.n)(),{settings:f}=o||{},{image:g,title:h,text:w,attachTo:b,events:v,options:k}=c(i),{queueTourForRedirect:j,queuedTour:L,clearQueuedTour:T,isMobile:S}=_(),{element:N,frame:E,offset:A,position:C,hook:P,boxPadding:R}=b||{},I=(0,a.useMemo)((()=>"function"==typeof N?N():N),[N]),D=(0,a.useMemo)((()=>"function"==typeof E?E():E),[E]),M=(0,a.useMemo)((()=>"function"==typeof A?A():A),[A]),$=(0,a.useMemo)((()=>"function"==typeof P?P():P),[P]),q=(0,a.useRef)(),B=(0,a.useRef)(!1),[F,O]=(0,a.useState)(null),[z,W]=(0,a.useState)(!1),[H,V]=(0,a.useState)(!1),[U,Z]=(0,a.useState)(null),[Y,K]=(0,a.useState)({x:void 0,y:void 0,...M}),X=(0,a.useCallback)(((e,t)=>{K(20===e?{x:e,y:t}:{x:e,y:t,...M})}),[M]),G=(0,a.useCallback)((()=>{const e=$?.split(" ")||[];return{x:e.includes("right")?n.current?.offsetWidth:0,y:e.includes("bottom")?n.current?.offsetHeight:0}}),[$]),J=(0,a.useCallback)((()=>{var e,t,o,i;if(!F)return;const r=D&&null!==(e=document.querySelector(D)?.contentDocument)&&void 0!==e?e:document,a=Je(null!==(t=r.querySelector(I))&&void 0!==t?t:F);if(r!==document){const e=Je(r.defaultView.frameElement);a.x+=e.x,a.left+=e.x,a.right+=e.x,a.y+=e.y,a.top+=e.y,a.bottom+=e.y}if(window.innerWidth<=960)return void s("closed-resize");if(void 0===C?.x)return X(void 0,void 0),Z(null),void V(!1);const l=Math.max(20,a?.[C.x]-G().x),c=Math.max(20,a?.[C.y]-G().y),d=n.current;X(Math.min(l,window.innerWidth-(null!==(o=d?.offsetWidth)&&void 0!==o?o:0)-20),Math.min(c,window.innerHeight-(null!==(i=d?.offsetHeight)&&void 0!==i?i:0)-20)),Z(a)}),[F,C,G,X,D,I,s]);if((0,a.useLayoutEffect)((()=>{f?.startFrom&&(p()||(W(!0),j(o.id),s("redirected"),window.location.assign(f?.startFrom[0]),window.location.href.split("#")[0]===f.startFrom[0].split("#")[0]&&window.location.reload()))}),[f?.startFrom,o,j,s,p]),(0,a.useEffect)((()=>{i&&document.querySelectorAll("[inert]").forEach((e=>e?.removeAttribute("inert")))}),[i]),(0,a.useEffect)((()=>{const e=e=>{const{tourSlug:t}=e.detail;se.A[t]&&requestAnimationFrame((()=>{r(se.A[t])}))};return window.addEventListener("extendify-assist:start-tour",e),()=>{window.removeEventListener("extendify-assist:start-tour",e)}}),[r]),(0,a.useLayoutEffect)((()=>{if(z)return;const e=L;let t=0;if(!e||!se.A[e])return T();const n=()=>{requestAnimationFrame((()=>{r(se.A[e])})),T()};return addEventListener("load",n),"complete"===document.readyState&&(t=requestAnimationFrame(n)),()=>{cancelAnimationFrame(t),removeEventListener("load",n)}}),[r,L,T,z]),(0,a.useEffect)((()=>{var e,t;if(!I)return;const n=null!==(t=(D&&null!==(e=document.querySelector(D)?.contentDocument)&&void 0!==e?e:document).querySelector(I))&&void 0!==t?t:document.querySelector(I);return n?(O(n),()=>O(null)):void 0}),[D,I]),(0,a.useLayoutEffect)((()=>{if(F&&!z)return V(!0),J(),addEventListener("resize",J),k?.allowPointerEvents||(F.style.pointerEvents="none"),()=>{removeEventListener("resize",J),F.style.pointerEvents="auto"}}),[z,F,J,k]),(0,a.useEffect)((()=>{B.current||i&&(B.current=!0)}),[i]),(0,a.useEffect)((()=>{if(void 0===i||!F)return;v?.onAttach?.(F);let e=0;const t=requestAnimationFrame((()=>{F.scrollIntoView({block:"center"}),J(),e=requestAnimationFrame(J)}));return q?.current?.focus(),()=>{v?.onDetach?.(F),cancelAnimationFrame(t),cancelAnimationFrame(e)}}),[i,v,F,J,q]),(0,a.useLayoutEffect)((()=>{if(f?.allowOverflow)return document.documentElement.classList.add("ext-force-overflow-auto"),()=>{document.documentElement.classList.remove("ext-force-overflow-auto")}}),[f]),!H||S)return null;const Q=nt(U,R);return(0,x.jsx)(x.Fragment,{children:(0,x.jsx)(y.N,{children:Boolean(o)&&(0,x.jsxs)(Ge.lG,{as:m.P.div,static:!0,initialFocus:q,className:"extendify-agent",open:Boolean(o),onClose:()=>{},children:[(0,x.jsx)("div",{className:"relative z-max",children:(0,x.jsxs)(m.P.div,{ref:n,animate:{opacity:1,...Y},initial:{opacity:0,...Y},onAnimationComplete:()=>{J()},transition:{duration:B.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:null!==(e=f?.minBoxWidth)&&void 0!==e?e:"325px"},children:[(0,x.jsx)("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-none 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,l.__)("Close Modal","extendify-local"),children:(0,x.jsx)(d.A,{icon:u.A,className:"h-4 w-4 fill-current"})}),(0,x.jsx)(Ge.lG.Title,{className:"sr-only",children:null!==(t=o?.title)&&void 0!==t?t:(0,l.__)("Tour","extendify-local")}),g&&(0,x.jsx)("div",{className:"w-full p-6",style:{minHeight:150,background:"linear-gradient(58.72deg, #485563 7.71%, #29323C 92.87%)"},children:(0,x.jsx)("img",{src:g,className:"block w-full",alt:h})}),(0,x.jsxs)("div",{className:"relative m-0 bg-white p-6 pt-0 text-left rtl:text-right",children:[h&&(0,x.jsx)("h2",{className:"mb-2 text-xl font-medium",children:h}),w&&(0,x.jsx)("p",{className:"mb-6",children:w}),(0,x.jsx)(tt,{initialFocus:q})]})]})}),k?.allowPointerEvents||(0,x.jsx)("div",{"aria-hidden":!0,className:"fixed inset-0 z-max-1"}),Boolean(o)&&void 0!==U?.left&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(m.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, ${Q.left}px 0, ${Q.left}px ${Q?.bottom}px, ${Q?.right}px ${Q.bottom}px, ${Q.right}px ${Q.top}px, ${Q.left}px ${Q.top}px)`},transition:{duration:B.current?.5:0,ease:"easeInOut"},className:"fixed inset-0 z-max-1 hidden bg-black/70 lg:block","aria-hidden":"true"}),(0,x.jsx)(et,{rectWithPadding:Q,finishedStepOne:B})]})]})})})},et=({rectWithPadding:e,finishedStepOne:t})=>{const[n,o]=(0,a.useState)(!1);return(0,x.jsx)(m.P.div,{initial:{...null!=e?e:{}},animate:{...null!=e?e:{}},transition:{duration:t.current?.5:0,ease:"easeInOut"},onAnimationStart:()=>o(!1),onAnimationComplete:()=>o(!0),className:f()("fixed inset-0 z-high hidden border-2 lg:block",{"border-transparent":!n,"border-design-main":n,"inset-y-auto right-0":(0,l.isRTL)()}),"aria-hidden":"true"})},tt=({initialFocus:e})=>{const{goToStep:t,completeCurrentTour:n,currentStep:o,preparingStep:i,getStepData:r,hasNextStep:s,nextStep:a,hasPreviousStep:d,prevStep:u,currentTour:p}=(0,je.n)(),{options:f={}}=r(o),{hideBackButton:g=!1}=f,{steps:h,settings:w}=p||{};return(0,x.jsxs)("div",{id:"extendify-tour-navigation",className:"flex w-full items-center justify-between",children:[(0,x.jsx)("div",{className:"flex flex-1 justify-start rtl:flex-none",children:(0,x.jsx)(y.N,{children:d()&&!g&&(0,x.jsx)(m.P.div,{initial:{opacity:0},animate:{opacity:1},children:(0,x.jsxs)("button",{className:"flex h-8 items-center justify-center gap-2 rounded-sm bg-transparent p-0 text-gray-900 ring-design-main hover:bg-transparent focus:outline-none focus:ring-wp focus:ring-offset-1 focus:ring-offset-white disabled:opacity-60",onClick:u,disabled:i>-1,children:[i<o&&(0,x.jsx)(c.Spinner,{className:"m-0 h-4 text-design-main"}),(0,x.jsx)("span",{children:(0,l.__)("Back","extendify-local")})]})})})}),h?.length>2&&!w?.hideDotsNav?(0,x.jsx)("nav",{role:"navigation","aria-label":(0,l.__)("Tour Steps","extendify-local"),className:"flex flex-1 -translate-x-3 items-center justify-center gap-1",children:h.map(((e,n)=>(0,x.jsx)("div",{children:(0,x.jsx)("button",{"aria-label":(0,l.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,l.__)("%1$s of %2$s","extendify-local"),n+1,h.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-none focus:ring-wp focus:ring-design-main "+(n===o?"bg-design-main":"bg-gray-300"),onClick:()=>t(n),disabled:i>-1})},n)))}):null,(0,x.jsx)("div",{className:"flex flex-1 justify-end rtl:flex-none",children:s()?(0,x.jsxs)(c.Button,{ref:e,id:"agent-tour-next-button","data-test":"agent-tour-next-button",onClick:a,disabled:i>-1,className:"flex gap-2 bg-design-main text-design-text focus:text-design-text disabled:opacity-60",variant:"primary",children:[i>o&&(0,x.jsx)(c.Spinner,{className:"m-0 h-4 text-design-main"}),(0,x.jsx)("span",{children:(0,l.__)("Next","extendify-local")})]}):(0,x.jsx)(c.Button,{id:"agent-tour-next-button","data-test":"agent-tour-next-button",onClick:()=>{n()},className:"bg-design-main",variant:"primary",children:(0,l.__)("Done","extendify-local")})})]})},nt=(e,t)=>{var n,o,i,r,s,a,l,c,d,u;return{top:e.top-(null!==(n=t?.top)&&void 0!==n?n:0),left:e.left-(null!==(o=t?.left)&&void 0!==o?o:0),right:e.right+(null!==(i=t?.right)&&void 0!==i?i:0),bottom:e.bottom+(null!==(r=t?.bottom)&&void 0!==r?r:0),width:e.width+(null!==(s=t?.left)&&void 0!==s?s:0)+(null!==(a=t?.right)&&void 0!==a?a:0),height:e.height+(null!==(l=t?.top)&&void 0!==l?l:0)+(null!==(c=t?.bottom)&&void 0!==c?c:0),x:e.x-(null!==(d=t?.left)&&void 0!==d?d:0),y:e.y-(null!==(u=t?.top)&&void 0!==u?u:0)}},ot=({children:e,title:t,name:n,onClose:o,anchors:i=[]})=>{const{seenToolTips:r,setSeenToolTip:s,isMobile:d}=_(),[p,f]=(0,a.useState)(!1),[m,g]=(0,a.useState)(0),[h,y]=(0,a.useState)(0),[w,b]=(0,a.useState)(0),v=()=>{f(!1),s(n),o?.()};if((0,a.useLayoutEffect)((()=>{const e=i.map((e=>document.querySelector(e))).find(Boolean);if(!e||!p||d)return;const t=document.querySelector(".interface-interface-skeleton__secondary-sidebar, .interface-interface-skeleton__sidebar"),n=t?.style.zIndex;t&&(t.style.zIndex=20);const o=e.style.outline;e.style.outline="99999px solid rgba(0, 0, 0, 0.4)";const r=e.getBoundingClientRect(),s=r.left+r.width/2,a=r.top+r.height;return b(r.width),g(s),y(a),()=>{e.style.outline=o,t&&(t.style.zIndex=n)}}),[i,p,d]),(0,a.useEffect)((()=>{if(r.includes(n)||d)return;const e=()=>{const e=i.map((e=>document.querySelector(e))).find(Boolean);e&&e&&(e.offsetWidth||e.offsetHeight||e.getClientRects().length)&&f(!0)};return window.addEventListener("extendify-agent:closed-button",e),()=>{window.removeEventListener("extendify-agent:closed-button",e)}}),[f,r,n,i,d]),p&&!d)return(0,x.jsx)(Ge.lG,{static:!0,className:"extendify-agent",open:p,onClose:v,children:(0,x.jsxs)("div",{className:"relative z-max",children:[(0,x.jsx)("div",{onClick:v,"aria-hidden":!0,role:"presentation",className:"fixed inset-0 z-10 h-screen w-screen bg-transparent"}),(0,x.jsxs)("div",{className:"fixed z-20 flex min-w-80 max-w-xs flex-col rounded-lg bg-transparent shadow-2xl",style:{top:`${h+20}px`,left:(0,l.isRTL)()?`${m+100}px`:m-100+"px",transform:"translate(-50%, 0)"},children:[(0,x.jsx)("div",{style:{insetInlineEnd:w/2-5+"px"},className:"absolute top-[-12px] h-0 w-0 transform border-b-[12px] border-l-[10px] border-r-[10px] border-transparent border-b-wp-theme-main"}),(0,x.jsx)("button",{type:"button","data-test":"close-tooltip",className:"ring-none focus:ring-none absolute right-0 top-0 z-20 m-2 flex h-6 w-6 items-center justify-center border-0 bg-wp-theme-main p-0 leading-none text-design-text outline-none focus:shadow-none rtl:left-0 rtl:right-auto",onClick:v,"aria-label":(0,l.__)("Close ToolTip","extendify-local"),children:(0,x.jsx)(c.Icon,{icon:u.A,className:"h-4 w-4 fill-current"})}),(0,x.jsx)(Ge.L3,{className:"sr-only",children:t}),(0,x.jsx)("div",{className:"text-md relative m-0 rounded-lg bg-wp-theme-main p-6 pt-8 text-left font-sans leading-7 text-design-text rtl:text-right",children:e})]})]})})},it=()=>(0,x.jsxs)(ot,{name:"reopen",title:(0,l.__)("Tooltip pointing to the agent button","extendify-local"),anchors:["#extendify-agent-editor-btn > button","#wp-admin-bar-extendify-agent-btn"],children:[(0,x.jsx)("div",{className:"mb-1 text-base font-semibold",children:(0,l.__)("Need help again?","extendify-local")}),(0,x.jsx)("div",{className:"text-base",children:(0,l.__)("You can always access your AI Agent if you need help with anything on your site.","extendify-local")})]});i()((()=>{const e=document.getElementById("wpwrap")||document.querySelector(".wp-site-blocks");if((0,s.Zz)()||window!==window.top||!e)return;const t="extendify-agent-main";if(document.getElementById(t))return;const n=Object.assign(document.createElement("div"),{className:"extendify-agent",id:t});document.body.appendChild(n),(0,r.X)((0,x.jsx)(He,{}),n);const o="extendify-agent-tour";if(document.getElementById(o))return;const i=Object.assign(document.createElement("div"),{className:"extendify-agent-tour",id:o});(0,r.X)((0,x.jsx)(Qe,{}),i);const a=Object.assign(document.createElement("div"),{id:"extendify-agent-modal-tooltip"});document.body.appendChild(a),(0,r.X)((0,x.jsx)(it,{}),a)}))},2279:e=>{"use strict";e.exports=window.wp.plugins},2619:e=>{"use strict";e.exports=window.wp.hooks},3364:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>i});var o=n(8969);const i=async({query:e})=>{const t={documentation:"No relevant documentation found"},n=new URLSearchParams({search:e}),i=await fetch(`${o.XQ}/api/posts?${n.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"}}).catch((()=>({ok:!1})));if(!i.ok)return t;const r=await i.json();if(!r?.[0]?.slug)return t;const s=await fetch(`${o.XQ}/api/posts/${r?.[0]?.slug}`,{method:"GET",headers:{"Content-Type":"application/json"}}).catch((()=>({ok:!1})));if(!s.ok)return t;const a=await s.json();return a?.content?{documentation:a.content}:t}},3410:(e,t,n)=>{"use strict";n.d(t,{Y:()=>c});var o=n(1455),i=n.n(o),r=n(365),s=n(1621),a=n(7134),l=n(9333);const c=(0,s.vt)()((0,a.Zr)((0,a.lt)(((e,t)=>({workflow:null,block:null,setBlock:t=>e({block:t}),getWorkflow:()=>{const e=t().workflow,n=l.L.find((t=>t.id===e?.id));return(0,r.$N)(e,n||{})},getAvailableWorkflows:()=>{let e=l.L.filter((({available:e})=>e()));const 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?l.L.filter((({available:t,requires:n})=>t()&&(!e||n?.some((t=>e.includes(t)))))):l.L.filter((({available:e})=>e())),workflowData:null,workflowHistory:window.extAgentData?.workflowHistory||[],whenFinishedToolProps:null,getWhenFinishedToolProps:()=>{const{whenFinishedToolProps:e}=t();return e?{...e,onConfirm:(t={})=>{window.dispatchEvent(new CustomEvent("extendify-agent:workflow-confirm",{detail:{...t,whenFinishedToolProps:e}}))},onCancel:()=>{window.dispatchEvent(new CustomEvent("extendify-agent:workflow-cancel",{detail:{whenFinishedToolProps:e}}))}}:null},addWorkflowResult:async n=>{e((e=>{const t=Math.max(0,e.workflowHistory.length-10);return{workflowHistory:[n,...e.workflowHistory.toSpliced(0,t)]}})),await i()({method:"POST",path:"/extendify/v1/agent/workflows",data:{workflowId:t().workflow.id,...n}})},mergeWorkflowData:t=>{e((e=>e.workflowData?{workflowData:{...e.workflowData,...t}}:{workflowData:t}))},setWorkflow:t=>e({workflow:t?{...t,startingPage:window.location.href}:null,workflowData:null,whenFinishedToolProps:null}),setWhenFinishedToolProps:t=>e({whenFinishedToolProps:t})})),{name:"Extendify Agent Workflows"}),{name:`extendify-agent-workflows-${window.extSharedData.siteId}`,partialize:e=>{const{block:t,...n}=e;return{...n}}}))},3508:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>s});var o=n(1455),i=n.n(o),r=n(9586);const s=async({settingName:e})=>{if(!r.allowedSettings.includes(e))throw new Error("Setting not allowed");return{oldSettingValue:(await i()({path:"/wp/v2/settings?context=edit"}))[e]}}},3610:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>s});var o=n(1455),i=n.n(o),r=n(3410);const s=async()=>{var e;const{block:t}=r.Y.getState(),{postId:n}=window.extAgentData.context,o=await i()({path:`/extendify/v1/agent/get-block-code?postId=${n}&blockId=${t}`});return{previousContent:null!==(e=o?.block)&&void 0!==e?e:""}}},3670:(e,t,n)=>{"use strict";n.d(t,{K:()=>i});var o=n(790);const i=({children:e})=>(0,o.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,o.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,o.jsx)("div",{children:(0,o.jsx)("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,o.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,o.jsx)("div",{className:"text-sm",children:e})]})})},4997:e=>{"use strict";e.exports=window.wp.blocks},5092:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>s});var o=n(4997),i=n(7143),r=n(5713);const s=async({replacements:e})=>{const t=(0,r.E)();"template-locked"===t&&await(0,r.u)("post-only");const n=(0,i.select)("core/editor").getEditedPostAttribute("title"),o=a(n,e);(0,i.dispatch)("core/editor").editPost({title:o}),(0,i.select)("core/block-editor").getBlocks().flatMap((t=>l(t,e))).forEach((({clientId:e,block:t})=>{(0,i.dispatch)("core/block-editor").replaceBlock(e,t)})),"template-locked"===t&&(0,r.u)("template-locked")},a=(e,t)=>t.filter((e=>""!==e.original)).reduce(((e,{original:t,updated:n})=>e.split(t).join(n)),e),l=(e,t)=>{const n=[],i={...e.attributes};let r=!1;if(["content","caption","alt","title","value","text"].forEach((e=>{const n=i[e],o=n&&"function"==typeof n.toString?n.toString():n;if("string"==typeof o){const n=a(o,t);n!==o&&(i[e]=n,r=!0)}})),r){const t=(0,o.createBlock)(e.name,i,e.innerBlocks);n.push({clientId:e.clientId,block:t})}return e.innerBlocks.forEach((e=>{n.push(...l(e,t))})),n}},5261:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>r});var o=n(7143),i=n(5713);const r=async()=>{const e=(0,i.E)();"template-locked"===e&&await(0,i.u)("post-only");const t=(0,o.select)("core/block-editor").getBlocks(),n=(0,o.select)("core/editor").getEditedPostAttribute("title"),r=l([n,...s(t)]);return"template-locked"===e&&(0,i.u)("template-locked"),{post_strings:r}},s=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):[],...s(e.innerBlocks||[])])),a=e=>new Set(e.filter(Boolean)),l=e=>[...a(e)],c=e=>e.replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim(),d=e=>{const t=[],n=e.match(/alt="([^"]*)"/);n&&n[1]&&t.push(n[1].trim());const o=e.match(/title="([^"]*)"/);return o&&o[1]&&t.push(o[1].trim()),t}},5295:(e,t,n)=>{"use strict";n.d(t,{n:()=>p});var o,i=n(1455),r=n.n(i),s=n(6528),a=n(1621),l=n(7134);const c={currentTour:null,currentStep:void 0,preparingStep:void 0,progress:[],...null!==(o=(0,s.N)(window.extAgentData.userData.tourData)?.state)&&void 0!==o?o:{}},d="/extendify/v1/help-center/tour-data",u={getItem:async()=>await r()({path:d}),setItem:async(e,t)=>await r()({path:d,method:"POST",data:{state:t}})},p=(0,a.vt)((0,l.Zr)((0,l.lt)(((e,t)=>({...c,startTour:async n=>{const{trackTourProgress:o,updateProgress:i,getStepData:r,onTourPage:s}=t();s(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 a=o(n.id);i(a.id,{openedCount:Number(a.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:i,updateProgress:r}=t(),s=i(n?.id);s?.id&&(o(s.id)||r(s.id,{completedAt:(new Date).toISOString(),lastAction:"completed"}),r(s.id,{completedCount:Number(s.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:i,updateProgress:r}=t(),s=i(o?.id);if(!s?.id)return;const a={};return["redirected"].includes(n)?r(s?.id,{lastAction:n}):["closed-by-caught-error"].includes(n)?r(s?.id,{lastAction:n,errored:!0}):("closed-manually"===n&&(a.closedManuallyCount=Number(s.closedManuallyCount)+1),await(o?.onDetach?.()),await(o?.onFinish?.()),r(s?.id,{lastAction:n,...a}),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=>{var n;return Number(null!==(n=t().findTourProgress(e)?.openedCount)&&void 0!==n?n: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)=>{var o;const i=null!==(o=n?.lastAction)&&void 0!==o?o:"unknown";e((e=>({progress:e.progress.map((e=>e.id===t?{...e,...n,lastAction:i,updatedAt:(new Date).toISOString()}:e))})))},getStepData:(e,n=t().currentTour)=>{var o;return null!==(o=n?.steps?.[e])&&void 0!==o?o:{}},hasNextStep:()=>!!t().currentTour&&Number(t().currentStep)<t().currentTour.steps.length-1,nextStep:async()=>{const{currentTour:e,goToStep:n,updateProgress:o,currentStep:i}=t(),r=Number(i)+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:i}=t(),r=i-1;await n(r),o(e.id,{currentStep:r,lastAction:"prev"})},goToStep:async n=>{const{currentTour:o,updateProgress:i,closeCurrentTour:r,getStepData:s}=t(),a=o;if(n<0||n>a.steps.length-1)return void r("closed-by-caught-error");i(a.id,{currentStep:n,lastAction:`go-to-step-${n}`});const l=s(n)?.events;l?.beforeAttach&&(e((()=>({preparingStep:n}))),await Promise.allSettled([l.beforeAttach?.(a),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,l.KU)((()=>u)),skipHydration:!0,partialize:e=>{const{currentTour:t,currentStep:n,preparingStep:o,...i}=e;return i}}))},5573:e=>{"use strict";e.exports=window.wp.primitives},5713:(e,t,n)=>{"use strict";n.d(t,{E:()=>i,u:()=>r});var o=n(7143);const i=()=>{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)))}},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}}},5795:e=>{"use strict";e.exports=window.ReactDOM},6087:e=>{"use strict";e.exports=window.wp.element},6427:e=>{"use strict";e.exports=window.wp.components},6636:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>r});var o=n(1455),i=n.n(o);const r=async({postId:e,postType:t,replacements:n})=>{const o="page"===t?"pages":"posts",r=await i()({path:`/wp/v2/${o}/${e}?context=edit`});let s=r.content.raw,a=r.title.raw;for(const{original:e,updated:t}of n){const n=new RegExp(e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g");s=s.replace(n,t),a=a.split(e).join(t)}return await i()({path:`/wp/v2/${o}/${e}`,method:"POST",data:{content:s,title:a}})}},6905:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>N});var o=n(7723),i=n(790),r=n(6427),s=n(6087),a=n(3670),l=n(1455),c=n.n(l),d=n(4225);const u=async()=>{const e=window.location.pathname,t=new URLSearchParams(window.location.search),n=e.includes("/wp-admin/post.php")&&"edit"===t.get("action"),i=await c()({method:"GET",path:"/extendify/v1/agent/theme-variations"+(n?"":"?includeLayoutStyles")});if(!i||!Array.isArray(i))throw new Error((0,o.__)("Failed to fetch theme variations.","extendify-local"));return{variations:i.reduce(((e,t)=>(e.some((e=>e.title===t.title))||e.push(t),e)),[])}};var p=n(4997),f=n(7143);const m=document.querySelector('iframe[name="editor-canvas"]')?.contentDocument||document,g=(e,t)=>{if(!m)return[];const n=m.querySelector(`[data-block="${e}"]`);if(n&&n.classList){const e=[];for(const t of n.classList)t.startsWith("wp-duotone-")&&e.push(t);if(e.length)return e}const o=m.querySelectorAll(`img[src="${t}"]`),i=[];for(const e of o){const t=e.closest("figure[data-block]");if(t&&t.classList)for(const e of t.classList)e.startsWith("wp-duotone-")&&i.push(e)}return i};var h=n(3640);const x=document.querySelector('iframe[name="editor-canvas"]')?.contentDocument||document,y=["feFuncR","feFuncG","feFuncB"],w=(()=>{let e=new Map;return({duotoneTheme:t,dynamicDuotone:n})=>{const o=[];return x.querySelectorAll('[id^="wp-duotone-"]').forEach((i=>{const r=i.id.replace("wp-duotone-","");((t,n,o)=>{let i="";isNaN(t)||(i=t,t=o?.[`wp-duotone-${i}`]);const r=n?.find((e=>e.slug===t))?.colors;if(!r||2!==r.length)return!1;const s=x.querySelector(`#wp-duotone-${i}`)||x.querySelector(`#wp-duotone-${t}`);if(!s)return!1;if(!e.has(i||t)){const n={tableValues:{},cssProperty:getComputedStyle(x.documentElement).getPropertyValue(`--wp--preset--duotone--${i||t}`)};y.forEach((e=>{const t=s.querySelector(e);t&&(n.tableValues[e]=t.getAttribute("tableValues"))})),e.set(i||t,n)}const[a,l]=r.map((e=>{const{r:t,g:n,b:o}=(0,h.Mj)(e).toRgb();return{r:t/255,g:n/255,b:o/255}}));return y.forEach(((e,t)=>{const n=["r","g","b"][t],o=s.querySelector(e);o&&o.setAttribute("tableValues",`${a[n]} ${l[n]}`)})),x.documentElement.style.setProperty(`--wp--preset--duotone--${i||t}`,`url(#wp-duotone-${i||t})`),!0})(r,t,n)&&o.push(r)})),o.length>0?()=>{o.forEach((t=>{const n=e.get(t);if(!n)return;const o=x.querySelector(`#wp-duotone-${t}`);o&&(y.forEach((e=>{const t=o.querySelector(e);t&&null!==n.tableValues[e]&&(n.tableValues[e]?t.setAttribute("tableValues",n.tableValues[e]):t.removeAttribute("tableValues"))})),n.cssProperty?x.documentElement.style.setProperty(`--wp--preset--duotone--${t}`,n.cssProperty):x.documentElement.style.removeProperty(`--wp--preset--duotone--${t}`))}))}:null}})(),b="global-styles-inline-css",v=window.location.pathname,k=new URLSearchParams(window.location.search),j=v.includes("/wp-admin/post.php")&&"edit"===k.get("action"),_=(e,t)=>e?.color?.palette?.theme.find((e=>e.slug===t))?.color,L=e=>e?.color?.palette?.theme?.filter((e=>"background"!==e.slug))?.reduce(((e,t)=>(e.push(t.color),e)),[]),{context:T,abilities:S}=window.extAgentData,N={available:()=>S?.canEditThemes&&T?.hasThemeVariations,needsRedirect:()=>!Number(T?.postId||0),redirectComponent:()=>(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 p-3",children:(0,i.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,i.jsxs)("div",{className:"m-0 p-3 text-sm text-gray-900",children:[(0,o.__)("Suggestion:","extendify-local")," ",(0,i.jsx)("a",{href:`${window.extSharedData.homeUrl}`,children:(0,o.__)("Home page","extendify-local")})]})]}),id:"change-theme-variation",whenFinished:{component:({onConfirm:e,onCancel:t})=>{const[n,l]=(0,s.useState)(""),[c,m]=(0,s.useState)(null),[h,x]=(0,s.useState)(null),{undoChange:y}=(({css:e,duotoneTheme:t})=>{const n=(0,s.useRef)(null),o=(0,s.useRef)(null),[i,r]=(0,s.useState)(null);(0,s.useEffect)((()=>{if(!e||j)return;const t=document.getElementById(b);t&&(n.current||(n.current=t.innerHTML),t.innerHTML=e)}),[e]),(0,s.useEffect)((()=>{if(!e||!i||!j)return;const t=i.getElementById(b),n=document.querySelector('iframe[name="editor-canvas"]');t.innerHTML=e.replaceAll(":root",n?":root":".editor-styles-wrapper")}),[e,i]),(0,s.useEffect)((()=>{if(i)return;const e=setTimeout((()=>{if(i)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=b,t.body.appendChild(n),r(t)}),300);return()=>clearTimeout(e)}),[i]);const a=(0,f.useSelect)((e=>{var t;let n=null!==(t=e("core/block-editor")?.getBlocks?.())&&void 0!==t?t:[];if(n.find((e=>"core/template-part"===e.name))){const{getEditedPostContent:t}=e("core/editor");n=(0,p.parse)(t(),{})}return(e=>{const t=new Map,n=new Set,o=e=>{if(e&&e.length)for(const i of e){if("core/image"!==i.name){o(i.innerBlocks||[]);continue}const e=i.attributes?.url||"";if(!e||!e.startsWith("data:image/svg+xml;")||n.has(i.clientId)){o(i.innerBlocks||[]);continue}const r=i.attributes?.style?.color?.duotone,s=r?.startsWith("var:preset|duotone|")?r.slice(19):null,a=g(i.clientId,e)?.filter(Boolean);s&&a.length&&!t.has(s)&&a.forEach((e=>t.set(e,s))),n.add(i.clientId),o(i.innerBlocks||[])}};return o(e),Object.fromEntries(t)})(n)}),[]);return(0,s.useEffect)((()=>{t&&(o.current&&(o.current(),o.current=null),o.current=w({duotoneTheme:t,dynamicDuotone:a}))}),[t,a]),{undoChange:()=>{o.current&&(o.current(),o.current=null);const e=document.getElementById(b);if(e&&n.current&&(e.innerHTML=n.current),!j)return;const t=document.querySelector('iframe[name="editor-canvas"]'),i=t?.contentDocument||document;i?.getElementById(b)?.remove()}}})({css:n,duotoneTheme:h}),{variations:v,isLoading:k}=(()=>{const{data:e,error:t,isLoading:n}=(0,d.A)({key:"theme-variations",themeSlug:window.extAgentData.context.themeSlug},u);return{variations:e?.variations,error:t,isLoading:n}})(),T=!v||0===v.length,S=(0,s.useMemo)((()=>v?v.sort((()=>Math.random()-.5)):[]),[v]);return k?(0,i.jsx)("div",{className:"min-h-24 p-2 text-center text-sm",children:(0,o.__)("Loading variations...","extendify-local")}):T?(0,i.jsxs)(a.K,{children:[(0,i.jsx)("div",{className:"font-semibold",children:(0,o.__)("No variations found","extendify-local")}),(0,i.jsx)("div",{className:"",children:(0,o.__)("We were unable to find any variations for your theme.","extendify-local")})]}):(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:S?.slice(0,10)?.map((({title:e,css:t,settings:n})=>(0,i.jsx)(r.Tooltip,{text:e,placement:"top",children:(0,i.jsx)("button",{style:{backgroundColor:_(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 "+(c===e?"ring-wp ring-design-main":""),onClick:()=>{m(e),l(t),x(n?.color?.duotone?.theme)},children:(0,i.jsx)("div",{className:"flex max-w-fit items-center justify-center -space-x-4 rounded-lg rtl:space-x-reverse",children:L(n)?.map(((t,n)=>(0,i.jsx)("div",{style:{backgroundColor:t},className:"size-6 flex-shrink-0 overflow-visible rounded-full border border-white md:size-7"},e+t+n)))})})},e)))})}),(0,i.jsxs)("div",{className:"flex items-center justify-start gap-2 p-3",children:[(0,i.jsx)("button",{type:"button",className:"w-full rounded border border-gray-300 bg-white p-2 text-sm text-gray-700",onClick:()=>{y(),t()},children:(0,o.__)("Cancel","extendify-local")}),(0,i.jsx)("button",{type:"button",className:"w-full rounded border border-design-main bg-design-main p-2 text-sm text-white",disabled:!c,onClick:()=>{c&&e({data:{variation:v.find((e=>e.title===c))}})},children:(0,o.__)("Save","extendify-local")})]})]})}}}},7143:e=>{"use strict";e.exports=window.wp.data},7723:e=>{"use strict";e.exports=window.wp.i18n},7806:(e,t,n)=>{"use strict";n.d(t,{L:()=>d,e:()=>c});var o=n(7677),i=n(2043),r=n(5295),s=n(9035),a=n(790);const l=Object.values(s.A),c=({onConfirm:e})=>{if(0!==l.length)return(0,a.jsxs)("div",{className:"flex w-full items-start gap-2.5 p-2",children:[(0,a.jsx)("div",{className:"w-7 flex-shrink-0"}),(0,a.jsx)("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:l.map((t=>(0,a.jsx)(d,{tour:t,onClick:()=>{e?.()}},t.id)))})]})},d=({tour:e,onClick:t})=>{const{startTour:n}=(0,r.n)();return(0,a.jsxs)("div",{className:"group relative flex items-center",children:[(0,a.jsx)("div",{className:"pointer-events-none absolute inset-0 rounded opacity-10 transition-opacity duration-100 group-hover:bg-design-main"}),(0,a.jsxs)("button",{type:"button",className:"flex w-full items-center gap-2 rounded border border-gray-300 bg-transparent p-3 text-left text-sm leading-none text-gray-900 focus:outline-none focus:ring-wp focus:ring-design-main group-hover:ring-wp group-hover:ring-design-main",onClick:()=>{n(e),t?.()},children:[(0,a.jsx)(o.A,{icon:i.A,className:"h-6 w-6 fill-gray-700 leading-none"}),e.message]})]})}},8009:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>s});var o=n(1455),i=n.n(o);const r=window.extSharedData.globalStylesPostID,s=({variation:e})=>i()({method:"POST",path:`/wp/v2/global-styles/${r}`,data:{id:r,settings:e.settings,styles:e.styles}})},8490:e=>{"use strict";e.exports=window.wp.domReady},8537:e=>{"use strict";e.exports=window.wp.htmlEntities},8795:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>s});var o=n(1455),i=n.n(o),r=n(9586);const s=async({settingName:e,newSettingValue:t})=>{if(!r.allowedSettings.includes(e))throw new Error("Setting not allowed");return await i()({path:"/wp/v2/settings?context=edit",method:"POST",data:{[e]:t}})}},9035:(e,t,n)=>{"use strict";n.d(t,{A:()=>w});var o=n(2619),i=n(7723);const r=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)})),a={id:"library-tour",title:(0,i.__)("Design Library","extendify-local"),message:(0,i.__)("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 r("#extendify-library-btn"),document.querySelector(`[aria-label="${(0,i.__)("Settings")}"].is-pressed`)?.click()},steps:[{title:(0,i.__)("Open the Pattern Library","extendify-local"),text:(0,i.__)("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,i.isRTL)()?-15:15},position:{x:(0,i.isRTL)()?"left":"right",y:"top"},hook:(0,i.isRTL)()?"top right":"top left"},events:{beforeAttach:()=>{}}},{title:(0,i.__)("Filter Patterns","extendify-local"),text:(0,i.__)("Click on any pattern category to refine the selection.","extendify-local"),attachTo:{element:"#extendify-library-category-control",position:{x:(0,i.isRTL)()?"left":"right",y:"top"},hook:(0,i.isRTL)()?"top right":"top left"},options:{allowPointerEvents:!0},events:{beforeAttach:async()=>(dispatchEvent(new CustomEvent("extendify::open-library")),await r("#extendify-library-category-control"))}},{title:(0,i.__)("Select a Pattern","extendify-local"),text:(0,i.__)("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,i.isRTL)()?"right":"left",y:"top"},hook:(0,i.isRTL)()?"top right":"top left"},events:{beforeAttach:async()=>{await r("#extendify-library-patterns-list")}}},{title:(0,i.__)("View the Inserted Pattern","extendify-local"),text:(0,i.__)("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,i.isRTL)()?"left":"right",y:"top"},hook:(0,i.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}}]},l={id:"page-creator-tour",title:(0,i.__)("AI Page Generator","extendify-local"),message:(0,i.__)("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 r('#extendify-page-creator-btn [role="button"]'),document.querySelector(`[aria-label="${(0,i.__)("Settings")}"].is-pressed`)?.click()},steps:[{title:(0,i.__)("AI Page Generator","extendify-local"),text:(0,i.__)("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,i.isRTL)()?-15:15},position:{x:(0,i.isRTL)()?"left":"right",y:"top"},hook:(0,i.isRTL)()?"top right":"top left"},events:{beforeAttach:async()=>{await r('#extendify-page-creator-btn [role="button"]')}}},{title:(0,i.__)("Page description","extendify-local"),text:(0,i.__)("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,i.isRTL)()?"left":"right",y:"top"},hook:(0,i.isRTL)()?"top right":"top left"},options:{allowPointerEvents:!0},events:{beforeAttach:async()=>(dispatchEvent(new CustomEvent("extendify::open-page-creator")),await r("#extendify-page-creator-page-description"))}},{title:(0,i.__)("Site description","extendify-local"),text:(0,i.__)("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,i.isRTL)()?"left":"right",y:"top"},hook:(0,i.isRTL)()?"bottom left":"bottom right"},events:{beforeAttach:async()=>{await r("#extendify-page-creator-site-description")}}},{title:(0,i.__)("Generate your page","extendify-local"),text:(0,i.__)("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,i.isRTL)()?"left":"right",y:"top"},hook:(0,i.isRTL)()?"bottom left":"bottom right"},events:{beforeAttach:()=>{}},options:{hideBackButton:!0}}]};var c=n(4997);const d=()=>!!document.querySelector('iframe[name="editor-canvas"]'),u=e=>{var t;return null!==(t=13!==e.keyCode)&&void 0!==t?t:e.preventDefault()},p=(e="")=>`.edit-post-header-toolbar__inserter-toggle${e}, .editor-document-tools__inserter-toggle${e}`,f={id:"page-editor-tour",title:(0,i.__)("Page editor","extendify-local"),message:(0,i.__)("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,i.__)("Add a Block","extendify-local"),text:(0,i.__)("Click the plus to open the block inserter.","extendify-local"),attachTo:{element:p(),offset:{marginTop:15,marginLeft:0},position:{x:(0,i.isRTL)()?"right":"left",y:"bottom"},hook:(0,i.isRTL)()?"top right":"top left"},events:{beforeAttach:async()=>await r(p())}},{title:(0,i.__)("Block Inserter","extendify-local"),text:(0,i.__)("Add a block by clicking or dragging it onto the page.","extendify-local"),attachTo:{element:".block-editor-inserter__menu",offset:{marginTop:0,marginLeft:(0,i.isRTL)()?-15:15},position:{x:(0,i.isRTL)()?"left":"right",y:"top"},hook:(0,i.isRTL)()?"top right":"top left"},events:{beforeAttach:async()=>(document.querySelector(p(":not(.is-pressed)"))?.click(),await r(".block-editor-tabbed-sidebar")),onAttach:()=>{const e=document.querySelector(p());m.observe(e,{attributes:!0}),window.addEventListener("keydown",u)},onDetach:async()=>{m.disconnect(),window.removeEventListener("keydown",u),document.querySelector(p(".is-pressed"))?.click(),await s(".block-editor-inserter__block-list")}}},{title:(0,i.__)("Page Title","extendify-local"),text:(0,i.__)("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:()=>d()?'iframe[name="editor-canvas"]':".wp-block-post-title",offset:()=>({marginTop:d()?15:0,marginLeft:(0,i.isRTL)()?d()?15:-15:d()?-15:15}),position:{x:(0,i.isRTL)()?"left":"right",y:"top"},hook:()=>(0,i.isRTL)()?d()?"top left":"top right":d()?"top right":"top left"},events:{beforeAttach:async()=>{await window.wp.data.dispatch("core/editor").editPost({title:"Sample Post"})}}},{title:(0,i.__)("Blocks","extendify-local"),text:(0,i.__)("Each block will show up on the page and can be edited by clicking on it.","extendify-local"),attachTo:{element:()=>d()?'iframe[name="editor-canvas"]':".wp-block-post-content > p",offset:()=>({marginTop:d()?15:0,marginLeft:(0,i.isRTL)()?d()?15:-15:d()?-15:15}),position:{x:(0,i.isRTL)()?"left":"right",y:"top"},hook:()=>(0,i.isRTL)()?d()?"top left":"top right":d()?"top right":"top left"},events:{beforeAttach:async()=>{if(await window.wp.data.select("core/block-editor").getBlockCount()>0)return;const e=(0,c.createBlock)("core/paragraph",{content:(0,i.__)("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),d()?await window.wp.data.dispatch("core/block-editor").flashBlock(e.clientId):null}}},{title:(0,i.__)("Page and Block Settings","extendify-local"),text:(0,i.__)("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,i.isRTL)()?15:-15},position:{x:(0,i.isRTL)()?"right":"left",y:"top"},hook:(0,i.isRTL)()?"top left":"top right"},events:{beforeAttach:async()=>{const e=document.querySelector(`[aria-label="${(0,i.__)("Settings")}"]:not(.is-pressed)`);e?e?.click():document.querySelector('[aria-label="Settings"]:not(.is-pressed)')?.click(),await r(".interface-interface-skeleton__sidebar"),document.querySelector('.edit-post-sidebar__panel-tab,[data-tab-id="edit-post/document"]')?.click(),await r(".editor-post-status"),document.querySelector(".edit-post-post-status button")?.click()}}},{title:(0,i.__)("Preview","extendify-local"),text:(0,i.__)("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,i.isRTL)()?15:-15},position:{x:(0,i.isRTL)()?"right":"left",y:"top"},hook:(0,i.isRTL)()?"top left":"top right"},events:{}},{title:(0,i.__)("Publish or Save","extendify-local"),text:(0,i.__)("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,i.isRTL)()?"left":"right",y:"bottom"},hook:(0,i.isRTL)()?"top left":"top right"},events:{}}]},m=new MutationObserver((()=>{document.querySelector(p(":not(.is-pressed)"))?.click()})),g={id:"plugin-install-tour",title:(0,i.__)("Installing a plugin","extendify-local"),message:(0,i.__)("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,i.__)("Add New plugin menu","extendify-local"),text:(0,i.__)("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,i.isRTL)()?-15:15},position:{x:(0,i.isRTL)()?"left":"right",y:"top"},hook:(0,i.isRTL)()?"top right":"top left"},events:{onDetach:()=>{document.body.classList.contains("folded")&&document.querySelector("#menu-plugins").classList.remove("opensub")}}},{title:(0,i.__)("Search","extendify-local"),text:(0,i.__)("Search for a plugin by name or functionality.","extendify-local"),attachTo:{element:".search-form.search-plugins",offset:{marginTop:5,marginLeft:(0,i.isRTL)()?350:-350},boxPadding:{top:-5,bottom:3,left:5,right:5},position:{x:(0,i.isRTL)()?"right":"left",y:"top"},hook:(0,i.isRTL)()?"top right":"top left"},events:{}},{title:(0,i.__)("Plugin details","extendify-local"),text:(0,i.__)("See important information about each plugin.","extendify-local"),attachTo:{element:"#the-list .plugin-card:first-child .plugin-card-bottom",offset:{marginTop:0,marginLeft:(0,i.isRTL)()?-15:15},position:{x:(0,i.isRTL)()?"left":"right",y:"bottom"},hook:(0,i.isRTL)()?"bottom right":"bottom left"},events:{}},{title:(0,i.__)("Install now","extendify-local"),text:(0,i.__)("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,i.isRTL)()?-15:15},boxPadding:{top:5,bottom:5,left:5,right:5},position:{x:(0,i.isRTL)()?"left":"right",y:"top"},hook:(0,i.isRTL)()?"top right":"top left"},events:{}},{title:(0,i.__)("Upload Plugin","extendify-local"),text:(0,i.__)("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,i.isRTL)()?-15:15},boxPadding:{top:5,bottom:5,left:5,right:5},position:{x:(0,i.isRTL)()?"left":"right",y:"top"},hook:(0,i.isRTL)()?"top right":"top left"},events:{}}]},h={id:"plugin-management-tour",title:(0,i.__)("Plugin management","extendify-local"),message:(0,i.__)("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,i.__)("Installed Plugins menu","extendify-local"),text:(0,i.__)("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,i.isRTL)()?-15:15},position:{x:(0,i.isRTL)()?"left":"right",y:"top"},hook:(0,i.isRTL)()?"top right":"top left"},events:{onDetach:()=>{document.body.classList.contains("folded")&&document.querySelector("#menu-plugins").classList.remove("opensub")}}},{title:(0,i.__)("Installed plugins","extendify-local"),text:(0,i.__)("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,i.isRTL)()?"left":"right",y:"bottom"},hook:(0,i.isRTL)()?"top left":"top right"},events:{}},{title:(0,i.__)("Deactivate/activate option","extendify-local"),text:(0,i.__)("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,i.isRTL)()?-15:15},position:{x:(0,i.isRTL)()?"left":"right",y:"top"},hook:(0,i.isRTL)()?"top right":"top left"},events:{}},{title:(0,i.__)("Add another","extendify-local"),text:(0,i.__)("Click here to add another plugin to your site.","extendify-local"),attachTo:{element:"a.page-title-action",offset:{marginTop:-5,marginLeft:(0,i.isRTL)()?-15:15},boxPadding:{top:5,bottom:5,left:5,right:5},position:{x:(0,i.isRTL)()?"left":"right",y:"top"},hook:(0,i.isRTL)()?"top right":"top left"},events:{}}]},x={id:"site-assistant-tour",title:(0,i.__)("Site Assistant","extendify-local"),message:(0,i.__)("Tour the Site Assistant","extendify-local"),settings:{allowOverflow:!1,startFrom:[`${window.extSharedData.adminUrl}admin.php?page=extendify-assist#dashboard`]},steps:[{title:(0,i.__)("Tasks","extendify-local"),text:(0,i.__)("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,i.isRTL)()?"left":"right",y:"top"},hook:(0,i.isRTL)()?"top right":"top left"},events:{}},{title:(0,i.__)("Quick Links","extendify-local"),text:(0,i.__)("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,i.isRTL)()?"left":"right",y:"top"},hook:(0,i.isRTL)()?"top right":"top left"},events:{onAttach:()=>{}}},{title:(0,i.__)("Website Tools & Plugins","extendify-local"),text:(0,i.__)("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,i.isRTL)()?"left":"right",y:"top"},hook:(0,i.isRTL)()?"top right":"top left"},events:{}},{title:(0,i.__)("Visit your site","extendify-local"),text:(0,i.__)("You can always visit your site by clicking this button.","extendify-local"),attachTo:{element:"#assist-menu-bar",offset:{marginTop:20,marginLeft:(0,i.isRTL)()?5:-5},position:{x:(0,i.isRTL)()?"right":"left",y:"bottom"},hook:(0,i.isRTL)()?"top right":"top left",boxPadding:{top:5,bottom:5,left:5,right:5}},events:{}},{title:(0,i.__)("Site Assistant","extendify-local"),text:(0,i.__)("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,i.isRTL)()?-15:15},position:{x:(0,i.isRTL)()?"left":"right",y:"top"},hook:(0,i.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"))}}}]},y={"plugin-install-tour":g,"plugin-management-tour":h,"page-editor-tour":f,"library-tour":a,"users-screen-tour":{id:"users-screen-tour",title:(0,i.__)("Users screen","extendify-local"),message:(0,i.__)("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,i.__)("All Users menu","extendify-local"),text:(0,i.__)("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,i.isRTL)()?-15:15},position:{x:(0,i.isRTL)()?"left":"right",y:"top"},hook:(0,i.isRTL)()?"top right":"top left"},events:{onDetach:()=>{document.body.classList.contains("folded")&&document.querySelector("#menu-users").classList.remove("opensub")}}},{title:(0,i.__)("Users","extendify-local"),text:(0,i.__)("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,i.isRTL)()?"left":"right",y:"bottom"},hook:(0,i.isRTL)()?"top left":"top right"},events:{}},{title:(0,i.__)("Edit user information","extendify-local"),text:(0,i.__)("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,i.isRTL)()?-15:15},position:{x:(0,i.isRTL)()?"left":"right",y:"top"},hook:(0,i.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,i.__)("Search for users","extendify-local"),text:(0,i.__)("Use the search bar to find a particular user.","extendify-local"),attachTo:{element:"p.search-box",offset:{marginTop:-5,marginLeft:(0,i.isRTL)()?15:-15},boxPadding:{top:5,bottom:5,left:5,right:5},position:{x:(0,i.isRTL)()?"right":"left",y:"top"},hook:(0,i.isRTL)()?"top left":"top right"},events:{}},{title:(0,i.__)("Add a new user","extendify-local"),text:(0,i.__)("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,i.isRTL)()?-15:15},boxPadding:{top:5,bottom:5,left:5,right:5},position:{x:(0,i.isRTL)()?"left":"right",y:"top"},hook:(0,i.isRTL)()?"top right":"top left"},events:{}}]},"site-assistant-tour":x};(0,o.addFilter)("extendify.tours","extendify/extra-tours",(e=>window.extSharedData?.showAIPageCreation?{...e,"page-creator-tour":l}:e));const w=(0,o.applyFilters)("extendify.tours",y)},9333:(e,t,n)=>{"use strict";n.d(t,{L:()=>i,Y:()=>s});const o=n(1528),i=o.keys().filter((e=>"./workflows.js"!==e)).map((e=>o(e).default||o(e))),r=n(205),s=r.keys().reduce(((e,t)=>(e[t.split("/").pop().replace(".js","")]=r(t).default||r(t),e)),{})},9586:(e,t,n)=>{"use strict";n.r(t),n.d(t,{allowedSettings:()=>s,default:()=>a});var o=n(7723),i=n(790);const{abilities:r}=window.extAgentData,s=["posts_per_page","use_smilies","start_of_week","time_format","date_format","title","description"],a={available:()=>r?.canEditSettings,id:"edit-wp-setting",whenFinished:{component:({inputs:e,onConfirm:t,onCancel:n})=>(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,o.sprintf)(
// translators: 1: setting name, 2: new setting value
// translators: 1: setting name, 2: new setting value
(0,o.__)('The AI Agent wants to change the setting "%1$s" to "%2$s". Please confirm.',"extendify-local"),e.settingName,e.newSettingValue)})})}),(0,i.jsxs)("div",{className:"flex items-center justify-start gap-2 p-3",children:[(0,i.jsx)("button",{type:"button",className:"w-full rounded border border-gray-300 bg-white p-2 text-sm text-gray-700",onClick:n,children:(0,o.__)("Cancel","extendify-local")}),(0,i.jsx)("button",{type:"button",className:"w-full rounded border border-design-main bg-design-main p-2 text-sm text-white",onClick:()=>{t({data:e})},children:(0,o.__)("Confirm","extendify-local")})]})]})}}},9845:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>r});var o=n(1455),i=n.n(o);const r=async({previousContent:e,newContent:t})=>{const{postType:n,postId:o}=window.extAgentData.context,r=await i()({path:`/wp/v2/types/${encodeURIComponent(n)}`}),s=r?.rest_base||`${n}s`,a=(await i()({path:`/wp/v2/${s}/${o}?context=edit`})).content.raw.replace(e,t);await i()({path:`/wp/v2/${s}/${o}`,method:"POST",data:{content:a}})}}},e=>{e.O(0,[65,223],(()=>e(e.s=2094))),e.O()}]);