@avocadostudio-ai/cli 0.21.0 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/editor-dist/assets/{Editor-EPSED64A-DUoQgoCB.js → Editor-EPSED64A-DuMyE1CS.js} +1 -1
- package/editor-dist/assets/{PuckPrototypeRoute-Dy8cRpYT.js → PuckPrototypeRoute-CDznIHdj.js} +4 -4
- package/editor-dist/assets/{Render-CU35UAWV-R7N77mO8.js → Render-CU35UAWV-l5eEyH3s.js} +1 -1
- package/editor-dist/assets/{chunk-2CNEFIQP-D5n3lxWg.js → chunk-2CNEFIQP-CZj9IXVd.js} +1 -1
- package/editor-dist/assets/{full-N67EAB2Q-bKNQn5Nt.js → full-N67EAB2Q-2O5UCDBF.js} +1 -1
- package/editor-dist/assets/index-B4BtpbEJ.css +1 -0
- package/editor-dist/assets/{index-7hzlydvn.js → index-BKjz-l77.js} +2 -2
- package/editor-dist/assets/{index-DjaU3d0c.js → index-C1Ix2O6_.js} +1 -1
- package/editor-dist/assets/{index-CFC-ZLtj.js → index-CrWf8-W0.js} +1 -1
- package/editor-dist/assets/{loaded-F37CNCVG-BW-PLczL.js → loaded-F37CNCVG-Ci-7gFgb.js} +1 -1
- package/editor-dist/assets/{loaded-H325ZSK5-DP_9DPVo.js → loaded-H325ZSK5-Dj5n0ymb.js} +1 -1
- package/editor-dist/assets/{loaded-MIY725CK-LL_Kab8v.js → loaded-MIY725CK-sWEml5x3.js} +1 -1
- package/editor-dist/index.html +2 -2
- package/package.json +2 -2
- package/editor-dist/assets/index-JeTqIXoj.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PuckPrototypeRoute-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PuckPrototypeRoute-CDznIHdj.js","assets/PuckPrototypeRoute-C6wLHzni.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
var CB=Object.defineProperty;var EB=(e,t,n)=>t in e?CB(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ee=(e,t,n)=>EB(e,typeof t!="symbol"?t+"":t,n);function _B(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in e)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();function Bd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var dx={exports:{}},Hf={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -746,7 +746,7 @@ ${n.innerHTML}
|
|
|
746
746
|
`);return}},parse:{}}}}}),Hxe=un.create({name:"heading"}),Vxe=Hxe.extend({addStorage(){return{markdown:{serialize:Ko.nodes.heading,parse:{}}}}}),qxe=un.create({name:"horizontalRule"}),Kxe=qxe.extend({addStorage(){return{markdown:{serialize:Ko.nodes.horizontal_rule,parse:{}}}}}),Gxe=un.create({name:"image"}),Wxe=Gxe.extend({addStorage(){return{markdown:{serialize:Ko.nodes.image,parse:{}}}}}),Zxe=un.create({name:"listItem"}),Yxe=Zxe.extend({addStorage(){return{markdown:{serialize:Ko.nodes.list_item,parse:{}}}}}),Jxe=un.create({name:"orderedList"});function Xxe(e,t,n){let r=0;for(;n-r>0&&t.child(n-r-1).type.name===e.type.name;r++);return r}const Qxe=Jxe.extend({addStorage(){return{markdown:{serialize(e,t,n,r){const i=t.attrs.start||1,s=String(i+t.childCount-1).length,o=e.repeat(" ",s+2),u=Xxe(t,n,r)%2?") ":". ";e.renderList(t,o,d=>{const f=String(i+d);return e.repeat(" ",s-f.length)+f+u})},parse:{}}}}}),eve=un.create({name:"paragraph"}),tve=eve.extend({addStorage(){return{markdown:{serialize:Ko.nodes.paragraph,parse:{}}}}});function ok(e){var t,n;return(t=e==null||(n=e.content)===null||n===void 0?void 0:n.content)!==null&&t!==void 0?t:[]}const nve=un.create({name:"table"}),rve=nve.extend({addStorage(){return{markdown:{serialize(e,t,n){if(!ive(t)){ly.storage.markdown.serialize.call(this,e,t,n);return}e.inTable=!0,t.forEach((r,i,s)=>{if(e.write("| "),r.forEach((o,a,u)=>{u&&e.write(" | ");const d=o.firstChild;d.textContent.trim()&&e.renderInline(d)}),e.write(" |"),e.ensureNewLine(),!s){const o=Array.from({length:r.childCount}).map(()=>"---").join(" | ");e.write(`| ${o} |`),e.ensureNewLine()}}),e.closeBlock(t),e.inTable=!1},parse:{}}}}});function eR(e){return e.attrs.colspan>1||e.attrs.rowspan>1}function ive(e){const t=ok(e),n=t[0],r=t.slice(1);return!(ok(n).some(i=>i.type.name!=="tableHeader"||eR(i)||i.childCount>1)||r.some(i=>ok(i).some(s=>s.type.name==="tableHeader"||eR(s)||s.childCount>1)))}const sve=un.create({name:"taskItem"}),ove=sve.extend({addStorage(){return{markdown:{serialize(e,t){const n=t.attrs.checked?"[x]":"[ ]";e.write(`${n} `),e.renderContent(t)},parse:{updateDOM(e){[...e.querySelectorAll(".task-list-item")].forEach(t=>{const n=t.querySelector("input");t.setAttribute("data-type","taskItem"),n&&(t.setAttribute("data-checked",n.checked),n.remove())})}}}}}}),ave=un.create({name:"taskList"}),lve=ave.extend({addStorage(){return{markdown:{serialize:UL.storage.markdown.serialize,parse:{setup(e){e.use(Cxe)},updateDOM(e){[...e.querySelectorAll(".contains-task-list")].forEach(t=>{t.setAttribute("data-type","taskList")})}}}}}}),uve=un.create({name:"text"}),cve=uve.extend({addStorage(){return{markdown:{serialize(e,t){e.text(Rxe(t.text))},parse:{}}}}}),dve=xi.create({name:"bold"}),fve=dve.extend({addStorage(){return{markdown:{serialize:Ko.marks.strong,parse:{}}}}}),hve=xi.create({name:"code"}),pve=hve.extend({addStorage(){return{markdown:{serialize:Ko.marks.code,parse:{}}}}}),mve=xi.create({name:"italic"}),gve=mve.extend({addStorage(){return{markdown:{serialize:Ko.marks.em,parse:{}}}}}),bve=xi.create({name:"link"}),yve=bve.extend({addStorage(){return{markdown:{serialize:Ko.marks.link,parse:{}}}}}),xve=xi.create({name:"strike"}),vve=xve.extend({addStorage(){return{markdown:{serialize:{open:"~~",close:"~~",expelEnclosingWhitespace:!0},parse:{}}}}}),kve=[Lxe,UL,$xe,HL,Vxe,Kxe,ly,Wxe,Yxe,Qxe,tve,rve,ove,lve,cve,fve,pve,$L,gve,yve,vve];function fb(e){var t,n;const r=(t=e.storage)===null||t===void 0?void 0:t.markdown,i=(n=kve.find(s=>s.name===e.name))===null||n===void 0?void 0:n.storage.markdown;return r||i?{...i,...r}:null}class Sve{constructor(t){db(this,"editor",null),this.editor=t}serialize(t){const n=new Dxe(this.nodes,this.marks,{hardBreakNodeName:HL.name});return n.renderContent(t),n.out}get nodes(){var t;return{...Object.fromEntries(Object.keys(this.editor.schema.nodes).map(n=>[n,this.serializeNode(ly)])),...Object.fromEntries((t=this.editor.extensionManager.extensions.filter(n=>n.type==="node"&&this.serializeNode(n)).map(n=>[n.name,this.serializeNode(n)]))!==null&&t!==void 0?t:[])}}get marks(){var t;return{...Object.fromEntries(Object.keys(this.editor.schema.marks).map(n=>[n,this.serializeMark($L)])),...Object.fromEntries((t=this.editor.extensionManager.extensions.filter(n=>n.type==="mark"&&this.serializeMark(n)).map(n=>[n.name,this.serializeMark(n)]))!==null&&t!==void 0?t:[])}}serializeNode(t){var n;return(n=fb(t))===null||n===void 0||(n=n.serialize)===null||n===void 0?void 0:n.bind({editor:this.editor,options:t.options})}serializeMark(t){var n;const r=(n=fb(t))===null||n===void 0?void 0:n.serialize;return r?{...r,open:typeof r.open=="function"?r.open.bind({editor:this.editor,options:t.options}):r.open,close:typeof r.close=="function"?r.close.bind({editor:this.editor,options:t.options}):r.close}:null}}class wve{constructor(t,n){db(this,"editor",null),db(this,"md",null);let{html:r,linkify:i,breaks:s}=n;this.editor=t,this.md=this.withPatchedRenderer(Gi({html:r,linkify:i,breaks:s}))}parse(t){let{inline:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(typeof t=="string"){this.editor.extensionManager.extensions.forEach(s=>{var o;return(o=fb(s))===null||o===void 0||(o=o.parse)===null||o===void 0||(o=o.setup)===null||o===void 0?void 0:o.call({editor:this.editor,options:s.options},this.md)});const r=this.md.render(t),i=pC(r);return this.editor.extensionManager.extensions.forEach(s=>{var o;return(o=fb(s))===null||o===void 0||(o=o.parse)===null||o===void 0||(o=o.updateDOM)===null||o===void 0?void 0:o.call({editor:this.editor,options:s.options},i)}),this.normalizeDOM(i,{inline:n,content:t}),i.innerHTML}return t}normalizeDOM(t,n){let{inline:r,content:i}=n;return this.normalizeBlocks(t),t.querySelectorAll("*").forEach(s=>{var o;((o=s.nextSibling)===null||o===void 0?void 0:o.nodeType)===Node.TEXT_NODE&&!s.closest("pre")&&(s.nextSibling.textContent=s.nextSibling.textContent.replace(/^\n/,""))}),r&&this.normalizeInline(t,i),t}normalizeBlocks(t){const r=Object.values(this.editor.schema.nodes).filter(i=>i.isBlock).map(i=>{var s;return(s=i.spec.parseDOM)===null||s===void 0?void 0:s.map(o=>o.tag)}).flat().filter(Boolean).join(",");r&&[...t.querySelectorAll(r)].forEach(i=>{i.parentElement.matches("p")&&jxe(i)})}normalizeInline(t,n){var r;if((r=t.firstElementChild)!==null&&r!==void 0&&r.matches("p")){var i,s,o,a;const u=t.firstElementChild,{nextElementSibling:d}=u,f=(i=(s=n.match(/^\s+/))===null||s===void 0?void 0:s[0])!==null&&i!==void 0?i:"",m=d?"":(o=(a=n.match(/\s+$/))===null||a===void 0?void 0:a[0])!==null&&o!==void 0?o:"";if(n.match(/^\n\n/)){u.innerHTML=`${u.innerHTML}${m}`;return}Ixe(u),t.innerHTML=`${f}${t.innerHTML}${m}`}}withPatchedRenderer(t){const n=r=>function(){const i=r(...arguments);return i===`
|
|
747
747
|
`?i:i[i.length-1]===`
|
|
748
748
|
`?i.slice(0,-1):i};return t.renderer.rules.hardbreak=n(t.renderer.rules.hardbreak),t.renderer.rules.softbreak=n(t.renderer.rules.softbreak),t.renderer.rules.fence=n(t.renderer.rules.fence),t.renderer.rules.code_block=n(t.renderer.rules.code_block),t.renderer.renderToken=n(t.renderer.renderToken.bind(t.renderer)),t}}const Cve=Pn.create({name:"markdownClipboard",addOptions(){return{transformPastedText:!1,transformCopiedText:!1}},addProseMirrorPlugins(){return[new Qn({key:new Ar("markdownClipboard"),props:{clipboardTextParser:(e,t,n)=>{if(n||!this.options.transformPastedText)return null;const r=this.editor.storage.markdown.parser.parse(e,{inline:!0});return Sa.fromSchema(this.editor.schema).parseSlice(pC(r),{preserveWhitespace:!0,context:t})},clipboardTextSerializer:e=>this.options.transformCopiedText?this.editor.storage.markdown.serializer.serialize(e.content):null}})]}}),Eve=Pn.create({name:"markdown",priority:50,addOptions(){return{html:!0,tightLists:!0,tightListClass:"tight",bulletListMarker:"-",linkify:!1,breaks:!1,transformPastedText:!1,transformCopiedText:!1}},addCommands(){const e=kz.Commands.config.addCommands();return{setContent:(t,n)=>r=>e.setContent(r.editor.storage.markdown.parser.parse(t),n)(r),insertContentAt:(t,n,r)=>i=>e.insertContentAt(t,i.editor.storage.markdown.parser.parse(n,{inline:!0}),r)(i)}},onBeforeCreate(){this.editor.storage.markdown={options:{...this.options},parser:new wve(this.editor,this.options),serializer:new Sve(this.editor),getMarkdown:()=>this.editor.storage.markdown.serializer.serialize(this.editor.state.doc)},this.editor.options.initialContent=this.editor.options.content,this.editor.options.content=this.editor.storage.markdown.parser.parse(this.editor.options.content)},onCreate(){this.editor.options.content=this.editor.options.initialContent,delete this.editor.options.initialContent},addStorage(){return{}},addExtensions(){return[Txe.configure({tight:this.options.tightLists,tightClass:this.options.tightListClass}),Cve.configure({transformPastedText:this.options.transformPastedText,transformCopiedText:this.options.transformCopiedText})]}}),VL=Jz.extend({addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),anchor:{default:null},uuid:{default:null},linktype:{default:null}}}}).configure({openOnClick:!1}),qL=xi.create({name:"textStyle",addAttributes(){return{color:{default:null}}},parseHTML(){return[{tag:"span",getAttrs:e=>{var t;return(t=e.style)!=null&&t.color?{}:!1}}]},renderHTML({HTMLAttributes:e}){return["span",Zn(e),0]}}),KL=Pn.create({name:"avocadoBlockKeys",addGlobalAttributes(){return[{types:["paragraph","heading","bulletList","orderedList","listItem","blockquote","codeBlock"],attributes:{_key:{default:null,rendered:!1}}}]}});function _ve(e){if(e&&typeof e=="object"){const t=e;for(const n of["_type","nodeType","type"])if(typeof t[n]=="string")return t[n]}return"Embedded content"}const Tve=un.create({name:"avocadoUnknownBlock",group:"block",atom:!0,selectable:!0,draggable:!0,addAttributes(){return{data:{default:null,rendered:!1},_key:{default:null,rendered:!1}}},parseHTML(){return[{tag:"div[data-avocado-unknown-block]"}]},renderHTML({node:e,HTMLAttributes:t}){return["div",Zn(t,{"data-avocado-unknown-block":"",class:"rte-unknown-block"}),_ve(e.attrs.data)]}}),GL=xi.create({name:"avocadoUnknownHtml",addAttributes(){return{tag:{default:"span",rendered:!1},attributes:{default:null,rendered:!1}}},parseHTML(){return[{tag:"span[data-avocado-unknown-html]"}]},renderHTML({HTMLAttributes:e}){return["span",Zn(e,{"data-avocado-unknown-html":"",class:"rte-unknown-html"}),0]}}),WL=un.create({name:"avocadoUnknownInline",group:"inline",inline:!0,atom:!0,selectable:!0,addAttributes(){return{data:{default:null,rendered:!1}}},parseHTML(){return[{tag:"span[data-avocado-unknown-inline]"}]},renderHTML({HTMLAttributes:e}){return["span",Zn(e,{"data-avocado-unknown-inline":"",class:"rte-unknown-inline"})]}}),ZL=Pn.create({name:"avocadoHtmlAttributes",addGlobalAttributes(){return[{types:["paragraph","heading","bulletList","orderedList","listItem","blockquote","codeBlock","horizontalRule","bold","italic","strike","code"],attributes:{htmlAttributes:{default:null,rendered:!1}}}]}}),Ave=[sC.configure({heading:{levels:[1,2,3,4,5,6]},link:!1}),VL,qL,KL,ZL,Tve,WL,GL],Nve=un.create({name:"doc",topNode:!0,content:"paragraph"}),Mve=[sC.configure({document:!1,heading:!1,bulletList:!1,orderedList:!1,listItem:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,link:!1}),Nve,VL,qL,KL,ZL,WL,GL],Dve=new Set(["bold","italic","strike","code","underline","link","textStyle","avocadoUnknownHtml"]);function Rve(e){return xi.create({name:e,parseHTML(){return[{tag:`span[data-decorator="${e}"]`}]},renderHTML(){return["span",{"data-decorator":e,class:"rte-decorator"},0]}})}function jve(e=[],t={}){const n=new Set(Dve),r=[];for(const s of e){const o=s==null?void 0:s.name;typeof o!="string"||o.length===0||n.has(o)||(n.add(o),r.push(Rve(o)))}const i=t.inline?Mve:Ave;return r.length>0?[...i,...r]:i}const tR=340,Ive=340,Ove=Dq().map(e=>`.${e}`).join(",");function Pve(e){return e==null||!Number.isFinite(e)||e<=0?"":e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function zve(e){var i;const t=(i=e.contentType)==null?void 0:i.split("/").pop(),n=e.path.split(".").pop(),r=t&&t!=="octet-stream"?t:n;return r&&r.length<=5?r.toUpperCase():""}function Lve({anchorRef:e,initialValue:t,canUpload:n,onCommit:r,onCancel:i}){const{t:s}=Nn(),o=ce(O=>O.availablePages),a=ce(O=>O.availableFiles),u=ce(O=>O.filesStatus),d=ce(O=>O.setAvailableFiles),f=ce(O=>O.setFilesStatus);E.useEffect(()=>{b2()},[]);const[m,g]=E.useState(null);E.useLayoutEffect(()=>{const O=()=>{var $;const U=($=e.current)==null?void 0:$.getBoundingClientRect();if(!U)return;const le=window.innerHeight-U.bottom>=tR?U.bottom+6:Math.max(8,U.top-tR-6),I=Math.min(Math.max(8,U.left),Math.max(8,window.innerWidth-Ive-8));g({top:le,left:I})};return O(),window.addEventListener("resize",O),window.addEventListener("scroll",O,!0),()=>{window.removeEventListener("resize",O),window.removeEventListener("scroll",O,!0)}},[e]);const[y,x]=E.useState(t),[v,S]=E.useState(!1),[w,T]=E.useState(null),[A,M]=E.useState(!1),j=E.useRef(null),D=E.useRef(null),P=E.useRef(null);E.useEffect(()=>{var O,U;(O=j.current)==null||O.focus(),(U=j.current)==null||U.select()},[]),E.useEffect(()=>{const O=U=>{var le,I;const Q=U.target;(le=P.current)!=null&&le.contains(Q)||(I=e.current)!=null&&I.contains(Q)||i()};return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[e,i]);const R=y.trim(),B=fw(R,o,a),{pages:F,files:q}=E.useMemo(()=>vj(R,{pages:o,files:a,limit:6,browseFiles:!0}),[o,a,R]),W=B.kind==="file"&&u==="loading",K=B.kind==="file"&&u==="unavailable",Y=O=>r(O),V=async O=>{S(!0),T(null);try{const U=await oce(O),Q={path:U.url??"",...U.name?{name:U.name}:{},...U.contentType?{contentType:U.contentType}:{},...U.size!=null?{size:U.size}:{}};if(Q.path){d([...(a??[]).filter(le=>le.path!==Q.path),Q]),f("ready"),Y(Q.path);return}T(s("linkPicker.uploadNoUrl"))}catch(U){T(U instanceof Error?U.message:String(U))}finally{S(!1)}};return m?qd.createPortal(p.jsxs("div",{ref:P,className:`link-picker${A?" is-dropping":""}`,role:"dialog","aria-label":s("linkPicker.title"),style:{top:m.top,left:m.left},onDragOver:n?O=>{O.dataTransfer.types.includes("Files")&&(O.preventDefault(),O.dataTransfer.dropEffect="copy",M(!0))}:void 0,onDragLeave:n?O=>{O.currentTarget.contains(O.relatedTarget)||M(!1)}:void 0,onDrop:n?O=>{var Q;O.preventDefault(),M(!1);const U=(Q=O.dataTransfer.files)==null?void 0:Q[0];U&&V(U)}:void 0,children:[A?p.jsxs("div",{className:"link-picker-drop","aria-hidden":"true",children:[p.jsx(Hg,{size:16})," ",s("linkPicker.dropHere")]}):null,p.jsxs("div",{className:"link-picker-head",children:[p.jsx("span",{className:"link-picker-title",children:s("linkPicker.title")}),p.jsx("button",{type:"button",className:"link-picker-close",onClick:i,"aria-label":s("common.cancel"),children:p.jsx(xs,{size:13,"aria-hidden":"true"})})]}),p.jsx("input",{ref:j,type:"text",className:"link-picker-input",placeholder:s("linkPicker.placeholder"),value:y,title:y,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",onChange:O=>x(O.target.value),onKeyDown:O=>{O.key==="Escape"&&(O.stopPropagation(),i()),O.key==="Enter"&&(O.preventDefault(),Y(R))}}),R!==""&&B.missing===!0?p.jsxs("div",{className:"link-picker-warn",children:[p.jsx(mb,{size:11,"aria-hidden":"true"})," ",s(B.kind==="file"?"linkPicker.noFile":"linkPicker.noPage")]}):null,K?p.jsx("div",{className:"link-picker-note",children:s("linkPicker.filesUnavailable",{orchestrator:Be})}):null,p.jsxs("div",{className:"link-picker-list",role:"listbox",children:[F.map(O=>{var U;return p.jsxs("button",{type:"button",role:"option","aria-selected":((U=B.page)==null?void 0:U.slug)===O.slug,className:"link-picker-option",onMouseDown:Q=>Q.preventDefault(),onClick:()=>Y(O.path??O.slug),children:[p.jsx(hb,{size:12,"aria-hidden":"true"}),p.jsx("span",{className:"link-picker-option-title",children:O.title||O.slug}),p.jsx("span",{className:"link-picker-option-path",title:O.path??O.slug,children:O.path??O.slug})]},`p:${O.slug}`)}),q.map(O=>{var U;return p.jsxs("button",{type:"button",role:"option","aria-selected":((U=B.file)==null?void 0:U.path)===O.path,className:"link-picker-option",onMouseDown:Q=>Q.preventDefault(),title:O.path,onClick:()=>Y(O.path),children:[p.jsx(pb,{size:12,"aria-hidden":"true"}),p.jsx("span",{className:"link-picker-option-title",children:O.name??O.path.split("/").pop()}),p.jsx("span",{className:"link-picker-option-meta",children:[zve(O),Pve(O.size)].filter(Boolean).join(" · ")})]},`f:${O.path}`)}),W&&q.length===0?p.jsxs("div",{className:"link-picker-empty",children:[p.jsx(pk,{size:12,className:"link-picker-spin","aria-hidden":"true"})," ",s("linkPicker.loadingFiles")]}):null,!W&&F.length===0&&q.length===0?p.jsx("div",{className:"link-picker-empty",children:B.kind==="external"?p.jsxs(p.Fragment,{children:[p.jsx(Ug,{size:12,"aria-hidden":"true"})," ",s("linkPicker.externalHint")]}):B.kind==="email"?s("linkPicker.emailHint"):B.kind==="phone"?s("linkPicker.phoneHint"):B.kind==="anchor"?s("linkPicker.anchorHint"):s("linkPicker.noMatches")}):null]}),w?p.jsx("div",{className:"link-picker-warn",children:w}):null,p.jsxs("div",{className:"link-picker-foot",children:[n?p.jsxs(p.Fragment,{children:[p.jsx("input",{ref:D,type:"file",hidden:!0,accept:Ove,onChange:O=>{var Q;const U=(Q=O.target.files)==null?void 0:Q[0];O.target.value="",U&&V(U)}}),p.jsxs("button",{type:"button",className:"link-picker-upload",disabled:v,title:s("linkPicker.uploadHint"),onClick:()=>{var O;return(O=D.current)==null?void 0:O.click()},children:[v?p.jsx(pk,{size:12,className:"link-picker-spin","aria-hidden":"true"}):p.jsx(Hg,{size:12,"aria-hidden":"true"})," ",s(v?"linkPicker.uploading":"linkPicker.upload")]})]}):p.jsx("span",{}),p.jsxs("div",{className:"link-picker-actions",children:[t!==""?p.jsx("button",{type:"button",className:"link-picker-remove",onClick:()=>Y(""),children:s("linkPicker.remove")}):null,p.jsx("button",{type:"button",className:"link-picker-apply",onClick:()=>Y(R),children:s("linkPicker.apply")})]})]})]}),document.body):null}const ba=14,Bve=[sC.configure({heading:{levels:[2,3,4,5,6]},link:!1,underline:!1}),Jz.configure({openOnClick:!1}),Eve.configure({html:!1,transformPastedText:!0,transformCopiedText:!0})];function Fve(e){var n,r;const t=(r=(n=e.storage.markdown)==null?void 0:n.getMarkdown)==null?void 0:r.call(n);return typeof t=="string"?t:""}function To({active:e,onClick:t,title:n,className:r,children:i}){return p.jsx("button",{type:"button",className:`rte-toolbar-btn${e?" is-active":""}${r?` ${r}`:""}`,onClick:t,title:n,onMouseDown:s=>s.preventDefault(),children:i})}function YL({editor:e,trailing:t,decorators:n,inline:r}){const[i,s]=E.useState(!1),o=E.useRef(null),a=ce(f=>f.canUploadFiles),u=e.getAttributes("link").href??"",d=E.useCallback(f=>{if(s(!1),f===""){e.chain().focus().extendMarkRange("link").unsetLink().run();return}e.chain().focus().extendMarkRange("link").setLink({href:f}).run()},[e]);return p.jsxs("div",{className:`rte-toolbar${t?" rte-toolbar--with-trailing":""}`,children:[p.jsx(To,{active:e.isActive("bold"),onClick:()=>e.chain().focus().toggleBold().run(),title:"Bold",children:p.jsx(n9,{size:ba})}),p.jsx(To,{active:e.isActive("italic"),onClick:()=>e.chain().focus().toggleItalic().run(),title:"Italic",children:p.jsx(V9,{size:ba})}),p.jsx(To,{active:e.isActive("strike"),onClick:()=>e.chain().focus().toggleStrike().run(),title:"Strikethrough",children:p.jsx(CF,{size:ba})}),!r&&p.jsx("span",{className:"rte-toolbar-sep"}),!r&&p.jsx(To,{active:e.isActive("heading",{level:2}),onClick:()=>e.chain().focus().toggleHeading({level:2}).run(),title:"Heading 2",children:p.jsx(R9,{size:ba})}),!r&&p.jsx(To,{active:e.isActive("heading",{level:3}),onClick:()=>e.chain().focus().toggleHeading({level:3}).run(),title:"Heading 3",children:p.jsx(P9,{size:ba})}),!r&&p.jsx(To,{active:e.isActive("heading",{level:4}),onClick:()=>e.chain().focus().toggleHeading({level:4}).run(),title:"Heading 4",children:p.jsx(I9,{size:ba})}),!r&&p.jsx("span",{className:"rte-toolbar-sep"}),!r&&p.jsx(To,{active:e.isActive("bulletList"),onClick:()=>e.chain().focus().toggleBulletList().run(),title:"Bullet list",children:p.jsx(Z9,{size:ba})}),!r&&p.jsx(To,{active:e.isActive("orderedList"),onClick:()=>e.chain().focus().toggleOrderedList().run(),title:"Ordered list",children:p.jsx(G9,{size:ba})}),p.jsx("span",{className:"rte-toolbar-sep"}),p.jsxs("span",{className:"rte-link-anchor",ref:o,children:[p.jsx(To,{active:e.isActive("link"),onClick:()=>s(f=>!f),title:"Link",children:p.jsx(pR,{size:ba})}),i?p.jsx(Lve,{anchorRef:o,initialValue:u,canUpload:a,onCommit:d,onCancel:()=>s(!1)}):null]}),(n??[]).map(f=>p.jsx(To,{className:"rte-toolbar-btn--tag",active:e.isActive(f.name),onClick:()=>e.chain().focus().toggleMark(f.name).run(),title:f.title??f.name,children:f.title??f.name},f.name)),t?p.jsx("div",{className:"rte-toolbar-trailing",children:t}):null]})}function $ve({value:e,onChange:t,onFocus:n,onBlur:r,trailing:i}){const s=E.useRef(!1),o=E.useRef(e),a=zz({extensions:Bve,content:xA(e),onUpdate:({editor:u})=>{if(s.current)return;const d=Fve(u);o.current=d,t(d)},onFocus:()=>n==null?void 0:n(),onBlur:()=>r==null?void 0:r()});return E.useEffect(()=>{if(!a||a.isDestroyed||e===o.current)return;o.current=e,s.current=!0;const{from:u,to:d}=a.state.selection;a.commands.setContent(xA(e));const f=a.state.doc.content.size,m=Math.min(u,f),g=Math.min(d,f);try{a.commands.setTextSelection({from:m,to:g})}catch{}s.current=!1},[e,a]),a?p.jsxs("div",{className:"rte-wrap",children:[p.jsx(YL,{editor:a,trailing:i}),p.jsx(K2,{editor:a,className:"rte-content"})]}):null}function JL({value:e,onChange:t,onFocus:n,onBlur:r,decorators:i,inline:s}){const o=E.useRef(!1),a=E.useRef(JSON.stringify(e)),u=`${s?"inline":"block"}:${(i??[]).map(m=>m.name).join(",")}`,d=E.useMemo(()=>jve(i??[],{inline:s}),[u]),f=zz({extensions:d,content:e,onUpdate:({editor:m})=>{if(o.current)return;const g=m.getJSON();a.current=JSON.stringify(g),t(g)},onFocus:()=>n==null?void 0:n(),onBlur:()=>r==null?void 0:r()},[u]);return E.useEffect(()=>{if(!f||f.isDestroyed)return;const m=JSON.stringify(e);if(m===a.current)return;a.current=m,o.current=!0;const{from:g,to:y}=f.state.selection;f.commands.setContent(e);const x=f.state.doc.content.size;try{f.commands.setTextSelection({from:Math.min(g,x),to:Math.min(y,x)})}catch{}o.current=!1},[e,f]),f?p.jsxs("div",{className:`rte-wrap${s?" rte-wrap--inline":""}`,children:[p.jsx(YL,{editor:f,decorators:i,inline:s}),p.jsx(K2,{editor:f,className:"rte-content"})]}):null}const nR=new Set(["text","richtext","imageAlt"]),Uve=()=>{};function mC(e,t){const n=E.useRef(null),r=E.useRef(void 0);return E.useEffect(()=>{if(!e||!t||t!==e){r.current=t;return}if(r.current===t)return;const i=r.current;r.current=t;const s=n.current;if(!s)return;s.scrollIntoView({behavior:"smooth",block:"nearest"}),s.classList.add("property-field--flash");const o=setTimeout(()=>s.classList.remove("property-field--flash"),1800);return()=>{clearTimeout(o),s.classList.remove("property-field--flash"),r.current=i}},[e,t]),n}const Hve=Kn.memo(function({style:t,blockId:n,blockType:r,props:i,status:s,failure:o,failedSlug:a,failedOrigin:u,onRetry:d,onFieldChange:f,onImageClick:m,onAiAssist:g,slug:y,pageName:x,navLabel:v,onNavLabelChange:S,pageMeta:w,onPageMetaChange:T,onDeselectBlock:A,onPageAiAssist:M,onAiQuickAction:j,onPageAiQuickAction:D,aiLoading:P,aiLoadingPath:R,onAddListItem:B,onRemoveListItem:F,highlightPath:q,manifestByType:W,siteOrigin:K,onClose:Y}){const V=ce(xe=>xe.activeBlockId),O=ce(xe=>xe.activeBlockType),U=ce(xe=>xe.slug),Q=ce(xe=>xe.isLoading),le=ce(xe=>xe.activeEditablePath),I=n??V,$=r??O,X=y??U,z=P??Q,Z=R??le,oe=q??le,{t:ee}=Nn(),ne=Y?p.jsx("button",{type:"button",className:"property-panel-context-close",onClick:Y,"aria-label":ee("propertyPanel.close"),title:ee("propertyPanel.close"),children:p.jsx(xs,{size:16})}):null,Ae=p.jsxs("div",{className:"property-panel-context property-panel-context--page",children:[p.jsxs("svg",{className:"property-panel-context-icon",viewBox:"0 0 16 16",width:"16",height:"16",fill:"none","aria-hidden":"true",children:[p.jsx("path",{d:"M3.5 1.5h6L13 5v9a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5v-12a.5.5 0 0 1 .5-.5Z",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"}),p.jsx("path",{d:"M9.5 1.5V5h3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})]}),p.jsx("div",{className:"property-panel-context-text",children:p.jsx("span",{className:"property-panel-context-breadcrumb",children:p.jsx("span",{className:"property-panel-context-breadcrumb-current",children:ee("propertyPanel.page")})})}),ne]});if(!I||!$)return p.jsxs("div",{className:"property-panel",style:t,children:[Ae,p.jsxs("div",{className:"property-panel-fields",children:[X&&X!=="/"&&S?p.jsx(tke,{slug:X,navLabel:v??"",onNavLabelChange:S,onAiAssist:M,onAiQuickAction:D,aiLoading:z,fieldShimmer:z===!0&&Z==="Nav label"}):null,X&&T?p.jsx(nke,{pageMeta:w??{},onPageMetaChange:T,onAiAssist:M,onAiQuickAction:D,aiLoading:z,aiLoadingPath:Z}):null]})]});const _e=Au(),Oe=W==null?void 0:W.get($),he=Oe?Eq(Oe,_e[$]):_e[$];return he?p.jsxs("div",{className:"property-panel",style:t,children:[p.jsxs("div",{className:"property-panel-context property-panel-context--component",children:[p.jsxs("svg",{className:"property-panel-context-icon",viewBox:"0 0 16 16",width:"16",height:"16",fill:"none","aria-hidden":"true",children:[p.jsx("rect",{x:"1.5",y:"1.5",width:"5",height:"5",rx:"1",stroke:"currentColor",strokeWidth:"1.2"}),p.jsx("rect",{x:"9.5",y:"1.5",width:"5",height:"5",rx:"1",stroke:"currentColor",strokeWidth:"1.2"}),p.jsx("rect",{x:"1.5",y:"9.5",width:"5",height:"5",rx:"1",stroke:"currentColor",strokeWidth:"1.2"}),p.jsx("rect",{x:"9.5",y:"9.5",width:"5",height:"5",rx:"1",stroke:"currentColor",strokeWidth:"1.2"})]}),p.jsx("div",{className:"property-panel-context-text",children:p.jsxs("span",{className:"property-panel-context-breadcrumb",children:[p.jsx("button",{type:"button",className:"property-panel-context-breadcrumb-link",onClick:A,children:ee("propertyPanel.page")}),p.jsx("span",{className:"property-panel-context-breadcrumb-sep","aria-hidden":"true",children:"›"}),p.jsx("span",{className:"property-panel-context-breadcrumb-current",children:he.displayName})]})}),ne]}),(s==="loading"||s==="idle"&&!i)&&!i?p.jsx("div",{className:"property-panel-empty",children:ee("propertyPanel.loading")}):s==="error"?p.jsx(Vve,{failure:o??"unreachable",slug:a??X,origin:u,onRetry:d}):i?p.jsxs("div",{className:"property-panel-fields",children:[Object.keys(he.fields).length>0?p.jsx(uy,{id:`block:${$}:fields`,title:ee("propertyPanel.content"),count:Object.keys(he.fields).length,children:XL(Object.entries(he.fields),i,"",$,f,m,g,j,z,Z,oe,K)}):null,he.listFields?Object.entries(he.listFields).map(([xe,Pe])=>{const ie=Array.isArray(i[xe])?i[xe]:[];return p.jsx(Jve,{listKey:xe,listField:Pe,items:ie,blockType:$,onFieldChange:f,onImageClick:m,onAiAssist:g,onAiQuickAction:j,aiLoading:z,aiLoadingPath:Z,highlightPath:oe,onAddItem:B?()=>B(xe):void 0,onRemoveItem:F?qe=>F(xe,qe):void 0,siteOrigin:K},xe)}):null]}):null]}):p.jsxs("div",{className:"property-panel",style:t,children:[Ae,p.jsxs("div",{className:"property-panel-empty",children:[ee("propertyPanel.unknownBlock"),": ",$]})]})});function uy({id:e,title:t,count:n,headerExtra:r,children:i}){const[s,o]=m6(e);return p.jsxs("div",{className:`property-section${s?" is-collapsed":""}`,children:[p.jsxs("div",{className:"property-section-header",children:[p.jsxs("button",{type:"button",className:"property-section-toggle",onClick:o,"aria-expanded":!s,children:[p.jsx("span",{className:"property-section-chevron","aria-hidden":"true"}),p.jsx("span",{className:"property-section-title",children:t}),typeof n=="number"?p.jsx("span",{className:"property-section-count",children:n}):null]}),r]}),s?null:p.jsx("div",{className:"property-section-body",children:i})]})}function Vve({failure:e,slug:t,origin:n,onRetry:r}){const{t:i}=Nn(),s=i(e==="blockMissing"?"propertyPanel.loadFailedMissing":e==="pageMissing"?"propertyPanel.loadFailedNoPage":"propertyPanel.loadFailed"),o=i(e==="blockMissing"?"propertyPanel.loadFailedMissingHint":e==="pageMissing"?"propertyPanel.loadFailedNoPageHint":"propertyPanel.loadFailedUnreachableHint");return p.jsxs("div",{className:"property-panel-empty",children:[s,p.jsx("div",{className:"sites-form-hint",style:{marginTop:8},children:o}),e!=="unreachable"||n?p.jsxs("div",{className:"sites-form-hint",style:{marginTop:8},children:[p.jsx("code",{children:t}),n?p.jsxs(p.Fragment,{children:[" · ",p.jsx("code",{children:n})]}):null]}):null,r?p.jsx("button",{type:"button",className:"property-panel-retry",onClick:r,style:{marginTop:12},children:i("propertyPanel.retry")}):null]})}function rR(e,t){return!!(e==="imageUrl"&&t==="imageAlt"||e==="src"&&t==="alt"||e.endsWith(".src")&&t===e.replace(/\.src$/,".alt"))}function iR(e){try{const n=new URL(e,"http://localhost").pathname.split("/").pop()||"";return n.length>30?n.slice(0,27)+"...":n||"(image)"}catch{return e.length>30?e.slice(0,27)+"...":e||"(empty)"}}function XL(e,t,n,r,i,s,o,a,u,d,f,m){const g=new Set,y=new Set,x=new Set(e.map(([S])=>S));for(let S=0;S<e.length;S++){const[w,T]=e[S];if(T.kind==="image")for(const[A,M]of e)M.kind==="imageAlt"&&rR(w,A)&&g.add(A);if(T.kind==="link"||T.kind==="file"){const A=bA(w);x.has(A)&&y.add(A)}}const v=[];for(const[S,w]of e)if(!w.internal&&!g.has(S)&&!y.has(S))if(w.kind==="stringList"){const T=t[S];v.push(p.jsx(Zve,{label:w.label??S,values:Array.isArray(T)?T.map(A=>A==null?"":String(A)):[],basePath:n+S,onFieldChange:i},S))}else if(w.kind==="imageList"){const T=t[S];v.push(p.jsx(Yve,{label:w.label??S,rows:Array.isArray(T)?T:[],basePath:n+S,blockType:r,siteOrigin:m,onFieldChange:i,onImageClick:s},S))}else if(w.kind==="image"){const T=e.find(([j,D])=>D.kind==="imageAlt"&&rR(S,j)),A=T==null?void 0:T[0],M=A?t[A]==null?"":String(t[A]):void 0;v.push(p.jsx(e8,{label:w.label??S,blockType:r,imageUrl:t[S]==null?"":String(t[S]),altText:M,onChangeClick:()=>s==null?void 0:s(n+S,t[S]==null?"":String(t[S])),onRemove:()=>{i(n+S,""),A&&i(n+A,"")},onAltCommit:A?j=>i(n+A,j):void 0,onAltAiAssist:A&&o?()=>o(n+A,"Alt text","imageAlt",M??""):void 0,onAltAiQuickAction:A&&a?j=>a(n+A,"Alt text","imageAlt",M??"",j):void 0,fieldPath:n+S,...A?{altFieldPath:n+A}:{},highlightPath:f,aiLoading:u,fieldShimmer:u===!0&&A!=null&&d===n+A,siteOrigin:m},S))}else if(w.kind==="link"||w.kind==="file"){const T=bA(S),A=y.has(T);v.push(p.jsx(Gve,{label:w.label??S,required:w.required,value:t[S]==null?"":String(t[S]),newTab:A?t[T]===!0:void 0,onCommit:M=>i(n+S,M),onNewTabCommit:A?M=>i(n+T,M):void 0,fieldPath:n+S,highlightPath:f,siteOrigin:m},S))}else v.push(p.jsx(eke,{fieldKey:S,field:w,value:t[S],blockType:r,onCommit:T=>i(n+S,T),onAiAssist:nR.has(w.kind)&&o?()=>o(n+S,w.label??S,w.kind,t[S]==null?"":String(t[S])):void 0,onAiQuickAction:nR.has(w.kind)&&a?T=>a(n+S,w.label??S,w.kind,t[S]==null?"":String(t[S]),T):void 0,aiLoading:u,fieldShimmer:u===!0&&d===n+S,highlightPath:f,fieldPath:n+S},S));return v}const qve={empty:pR,page:hb,file:pb,external:Ug,email:X9,phone:aF,anchor:M9},Kve=8;function ak(e){var n;const t=(n=e.title)==null?void 0:n.trim();return t&&t.length>0?t:e.slug}function Gve({label:e,required:t,value:n,newTab:r,onCommit:i,onNewTabCommit:s,fieldPath:o,highlightPath:a,siteOrigin:u}){const{t:d}=Nn(),f=ce(U=>U.availablePages),m=ce(U=>U.availableFiles),g=a!=null&&a===o,y=mC(g?a:void 0,a),[x,v]=E.useState(!1),[S,w]=E.useState(n),[T,A]=E.useState(!1),M=E.useRef(null),{debouncedCommit:j,flushCommit:D}=Yd(i,400),P=T?S:n,R=fw(n,f,m),B=qve[R.kind],F=R.kind==="external"?Bq(n,u):void 0,{pages:q,files:W}=E.useMemo(()=>vj(T?S:"",{pages:f,files:m,limit:Kve}),[f,m,S,T]),K=E.useMemo(()=>T?void 0:Lq(n,f),[n,f,T]);E.useEffect(()=>{if(!x)return;const U=Q=>{var le;(le=M.current)!=null&&le.contains(Q.target)||v(!1)};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[x]);const Y=U=>{const Q=U.path??U.slug;w(Q),D(),i(Q),v(!1)},V=U=>{w(U.path),D(),i(U.path),v(!1)},O=s!=null&&R.kind==="external";return p.jsxs("div",{className:`property-field${g?" is-targeted":""}`,ref:y,children:[p.jsx("div",{className:"property-field-label",children:p.jsxs("span",{children:[e,t&&p.jsx("span",{className:"property-field-required",children:"*"})]})}),p.jsxs("div",{className:"property-field-link",ref:M,children:[p.jsxs("div",{className:"property-field-link-input-wrap",children:[p.jsx(B,{size:13,className:"property-field-link-icon","aria-hidden":"true"}),p.jsx("input",{type:"text",className:"property-field-input property-field-link-input",placeholder:d("propertyPanel.linkPlaceholder"),value:P,onFocus:()=>{b2(),w(n),A(!0),v(!0)},onChange:U=>{w(U.target.value),v(!0),j(U.target.value)},onBlur:()=>{A(!1),D()},onKeyDown:U=>{if(U.key==="Escape"&&x&&(U.stopPropagation(),v(!1)),U.key==="Enter"&&x){const Q=q[0];Q&&S.trim()!==""&&S!==n?(U.preventDefault(),Y(Q)):v(!1)}}}),p.jsx("button",{type:"button",className:"property-field-link-toggle","aria-label":d("propertyPanel.linkBrowsePages"),"aria-expanded":x,onClick:()=>v(U=>!U),children:p.jsx(Ma,{size:13,"aria-hidden":"true"})})]}),!T&&R.kind==="page"&&R.page?p.jsx("div",{className:"property-field-link-note",children:ak(R.page)}):null,!T&&R.kind==="file"&&R.file?p.jsx("div",{className:"property-field-link-note",children:R.file.name??iR(R.file.path)}):null,R.missing===!0?p.jsxs("div",{className:"property-field-link-note property-field-link-note--warn",children:[p.jsx(mb,{size:11,"aria-hidden":"true"})," ",d(R.kind==="file"?"propertyPanel.linkNoFile":"propertyPanel.linkNoPage")]}):null,K?p.jsx("button",{type:"button",className:"property-field-link-convert",onClick:()=>{const U=K.path??K.slug;w(U),i(U)},children:d("propertyPanel.linkDidYouMean",{page:ak(K)})}):null,F?p.jsx("button",{type:"button",className:"property-field-link-convert",onClick:()=>{w(F),i(F)},children:d("propertyPanel.linkUseInternal",{path:F})}):null,O?p.jsxs("label",{className:"property-field-link-newtab",children:[p.jsx("input",{type:"checkbox",checked:r===!0,onChange:U=>s==null?void 0:s(U.target.checked)}),p.jsx("span",{children:d("propertyPanel.linkNewTab")})]}):null,x?p.jsxs("div",{className:"property-field-link-menu",role:"listbox",children:[q.map(U=>{var Q,le;return p.jsxs("button",{type:"button",role:"option","aria-selected":((Q=R.page)==null?void 0:Q.slug)===U.slug,className:`property-field-link-option${((le=R.page)==null?void 0:le.slug)===U.slug?" is-current":""}`,onMouseDown:I=>I.preventDefault(),onClick:()=>Y(U),children:[p.jsx(hb,{size:12,"aria-hidden":"true"}),p.jsx("span",{className:"property-field-link-option-title",children:ak(U)}),p.jsx("span",{className:"property-field-link-option-slug",children:U.path??U.slug})]},U.slug)}),W.map(U=>{var Q,le;return p.jsxs("button",{type:"button",role:"option","aria-selected":((Q=R.file)==null?void 0:Q.path)===U.path,className:`property-field-link-option${((le=R.file)==null?void 0:le.path)===U.path?" is-current":""}`,onMouseDown:I=>I.preventDefault(),onClick:()=>V(U),children:[p.jsx(pb,{size:12,"aria-hidden":"true"}),p.jsx("span",{className:"property-field-link-option-title",children:U.name??iR(U.path)}),p.jsx("span",{className:"property-field-link-option-slug",children:U.path})]},U.path)}),q.length===0&&W.length===0?p.jsx("div",{className:"property-field-link-empty",children:d("propertyPanel.linkNoMatches")}):null]}):null]})]})}function fp({onClick:e,fieldKind:t,fieldLabel:n,blockType:r,currentValue:i,onQuickAction:s,onCustomPrompt:o,aiLoading:a,variant:u="overlay"}){const[d,f]=E.useState(null);if(ce(x=>x.plannerBadgeState)==="demo")return null;const g=x=>{s&&t&&n&&r!==void 0?f(x.currentTarget.getBoundingClientRect()):e()},y=u==="toolbar"?"rte-toolbar-ai-btn":"property-field-ai-btn";return p.jsxs(p.Fragment,{children:[p.jsx("button",{type:"button",className:`${y}${a?` ${y}--loading`:""}`,onClick:g,onMouseDown:x=>x.preventDefault(),title:"AI suggestions",children:a?p.jsx(zh,{size:14,"aria-hidden":"true"}):p.jsx(mR,{size:14,"aria-hidden":"true"})}),d&&t&&n&&r!==void 0&&p.jsx(Wve,{anchorRect:d,fieldKind:t,fieldLabel:n,blockType:r,currentValue:i??"",aiLoading:a,onSelect:x=>{f(null),s==null||s(x)},onCustomPrompt:()=>{f(null),(o??e)()},onDismiss:()=>f(null)})]})}function Wve({anchorRect:e,fieldKind:t,fieldLabel:n,blockType:r,currentValue:i,aiLoading:s,onSelect:o,onCustomPrompt:a,onDismiss:u}){const d=zce(t,n,r,i),m=window.innerHeight-e.bottom<160,g=m?void 0:e.bottom+4,y=m?window.innerHeight-e.top+4:void 0,x=window.innerWidth-e.right;return E.useEffect(()=>{const v=S=>{S.key==="Escape"&&u()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[u]),p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"ai-quick-actions-backdrop",onClick:u}),p.jsxs("div",{className:"ai-quick-actions-menu",style:{top:g,bottom:y,right:x},children:[d.map(v=>p.jsxs("button",{type:"button",className:"ai-quick-actions-item",disabled:s,onClick:()=>o(v),children:[p.jsx(mR,{size:12,"aria-hidden":"true"}),v]},v)),p.jsx("div",{className:"ai-quick-actions-divider"}),p.jsxs("button",{type:"button",className:"ai-quick-actions-item ai-quick-actions-item--custom",onClick:a,children:[p.jsx(sF,{size:12,"aria-hidden":"true"}),"Custom prompt..."]})]})]})}function QL(e,t){return!e||!t||/^https?:\/\//i.test(e)?e:e.startsWith("/")?`${t}${e}`:e}function Zve({label:e,values:t,basePath:n,onFieldChange:r}){const{t:i}=Nn();return p.jsxs("div",{className:"property-field property-field--list",children:[p.jsx("div",{className:"property-field-label",children:p.jsx("span",{children:e})}),p.jsx("div",{className:"property-list-rows",children:t.map((s,o)=>p.jsxs("div",{className:"property-list-row",children:[p.jsx("input",{className:"property-field-input",value:s,onChange:a=>r(`${n}[${o}]`,a.target.value)}),p.jsx("button",{type:"button",className:"property-list-item-remove-btn",title:i("propertyPanel.removeItem"),onClick:()=>r(n,t.filter((a,u)=>u!==o)),children:"×"})]},`${n}-${o}`))}),p.jsx("button",{type:"button",className:"property-list-add-btn",onClick:()=>r(n,[...t,""]),children:i("propertyPanel.addItem")})]})}function Yve({label:e,rows:t,basePath:n,blockType:r,siteOrigin:i,onFieldChange:s,onImageClick:o}){const{t:a}=Nn(),u=t.find(m=>m&&typeof m=="object")??{},d=["url","imageUrl","src","image"].find(m=>m in u)??"url",f=["alt","imageAlt","image_alt"].find(m=>m in u)??"alt";return p.jsxs("div",{className:"property-field property-field--list",children:[p.jsx("div",{className:"property-field-label",children:p.jsx("span",{children:e})}),p.jsx("div",{className:"property-list-rows",children:t.map((m,g)=>{const y=`${n}[${g}]`,x=(m==null?void 0:m[d])==null?"":String(m[d]),v=(m==null?void 0:m[f])==null?"":String(m[f]);return p.jsx(e8,{label:`${e} ${g+1}`,blockType:r,imageUrl:x,altText:v,fieldPath:`${y}.${d}`,altFieldPath:`${y}.${f}`,onChangeClick:()=>o==null?void 0:o(`${y}.${d}`,x),onRemove:()=>s(n,t.filter((S,w)=>w!==g)),onAltCommit:S=>s(`${y}.${f}`,S),siteOrigin:i},y)})}),p.jsx("button",{type:"button",className:"property-list-add-btn",onClick:()=>s(n,[...t,{[d]:"",[f]:""}]),children:a("propertyPanel.addItem")})]})}function e8({label:e,blockType:t,imageUrl:n,altText:r,fieldPath:i,altFieldPath:s,highlightPath:o,onChangeClick:a,onRemove:u,onAltCommit:d,onAltAiAssist:f,onAltAiQuickAction:m,aiLoading:g,fieldShimmer:y,siteOrigin:x}){const{t:v}=Nn(),S=o&&(o===i||o===s),w=mC(S?o:void 0,o),T=S&&o===s,A=`property-field${S?" is-targeted":""}`,[M,j]=E.useState(r??""),[D,P]=E.useState(!1),[R,B]=E.useState(!1),F=D?M:r??"",{debouncedCommit:q,flushCommit:W}=Yd(d??Uve,400);return p.jsxs("div",{className:A,ref:w,children:[p.jsx("div",{className:"property-field-label",children:p.jsx("span",{children:e})}),p.jsxs("div",{className:"property-field-image-widget",children:[n&&!R?p.jsxs("div",{className:"property-field-image-preview",children:[p.jsx("img",{className:"property-field-image-thumb",src:QL(n,x),alt:"",onError:()=>B(!0)}),p.jsxs("div",{className:"property-field-image-actions",children:[p.jsxs("button",{type:"button",className:"property-field-image-change",onClick:a,children:[p.jsx(pF,{size:13})," ",v("propertyPanel.change")]}),u?p.jsxs("button",{type:"button",className:"property-field-image-remove",onClick:u,children:[p.jsx(ew,{size:13})," ",v("propertyPanel.remove")]}):null]})]}):p.jsxs("button",{type:"button",className:"property-field-image-empty",onClick:a,children:[p.jsx(L9,{size:18,"aria-hidden":"true"}),p.jsx("span",{children:v("propertyPanel.chooseImage")})]}),d!==void 0&&p.jsxs("div",{className:"property-field-image-alt-group",children:[p.jsx("div",{className:"property-field-image-alt-label",children:p.jsx("span",{children:v("propertyPanel.altText")})}),p.jsxs("div",{className:`property-field-input-wrap${y?" property-field-input-wrap--ai-loading":""}`,children:[p.jsx("input",{type:"text",className:`property-field-image-alt${T?" is-targeted":""}`,placeholder:v("propertyPanel.altPlaceholder"),value:F,onFocus:()=>{j(r??""),P(!0)},onChange:K=>{j(K.target.value),q(K.target.value)},onBlur:()=>{P(!1),W()}}),f?p.jsx(fp,{onClick:f,fieldKind:"imageAlt",fieldLabel:v("propertyPanel.altText"),blockType:t??"",currentValue:r??"",onQuickAction:m,onCustomPrompt:f,aiLoading:y}):null]})]})]})]})}function Jve({listKey:e,listField:t,items:n,blockType:r,onFieldChange:i,onImageClick:s,onAiAssist:o,onAiQuickAction:a,aiLoading:u,aiLoadingPath:d,highlightPath:f,onAddItem:m,onRemoveItem:g,siteOrigin:y}){const[x,v]=E.useState(null),S=t.label??e;return E.useEffect(()=>{if(!f)return;const w=`${e}[`;if(!f.startsWith(w))return;const T=f.slice(w.length),A=T.indexOf("]");if(A<0)return;const M=Number(T.slice(0,A));!Number.isNaN(M)&&M>=0&&M<n.length&&v(M)},[f,e,n.length]),p.jsxs(uy,{id:`list:${r}:${e}`,title:S,count:n.length,children:[n.map((w,T)=>{const A=x===T,{fields:M,discriminantValue:j}=_q(t,w),D=Object.keys(M).find(W=>M[W].kind==="image"),P=D&&w[D]!=null?String(w[D]):"",B=Tq(M,w,T,{...t.discriminator?{discriminator:t.discriminator}:{}}).label,F=j?`[${j}] ${B}`:B,q=F.length>40?F.slice(0,40)+"...":F;return p.jsxs("div",{className:"property-list-item",children:[p.jsxs("button",{type:"button",className:`property-list-item-toggle ${A?"is-expanded":""}`,onClick:()=>v(A?null:T),children:[p.jsx("span",{className:"property-list-item-chevron","aria-hidden":"true"}),P?p.jsx("img",{className:"property-list-item-thumb",src:QL(P,y),alt:"",loading:"lazy"}):null,p.jsx("span",{className:"property-list-item-preview",children:q})]}),A?p.jsxs("div",{className:"property-list-item-fields",children:[XL(Object.entries(M),w,`${e}[${T}].`,r,i,s,o,a,u,d,f,y),g?p.jsxs("button",{type:"button",className:"property-list-item-remove-btn",onClick:()=>g(T),children:[p.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:p.jsx("path",{d:"M2.5 4h11M6 4V2.5h4V4M5 4l.5 9h5l.5-9M6.5 6.5v4M9.5 6.5v4"})}),"Remove item"]}):null]}):null]},T)}),m?p.jsxs("button",{type:"button",className:"property-list-add-btn",onClick:m,children:[p.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round","aria-hidden":"true",children:p.jsx("path",{d:"M8 3v10M3 8h10"})}),"Add"]}):null]})}const Xve={h1:"H1 — Page title",h2:"H2 — Section",h3:"H3 — Subsection",h4:"H4",h5:"H5",h6:"H6"};function Qve({value:e,onCommit:t,onFocus:n,onBlur:r,inline:i}){const s=E.useRef(null),[o,a]=E.useState(()=>kA(e)),{debouncedCommit:u,flushCommit:d}=Yd(t,400);return E.useEffect(()=>{e!==s.current&&(s.current=null,a(kA(e)))},[e]),p.jsx(JL,{value:o,onChange:f=>{a(f);const m=cK(f);s.current=m,u(m)},onFocus:n,onBlur:()=>{d(),r==null||r()},inline:i})}function eke({fieldKey:e,field:t,value:n,blockType:r,onCommit:i,onAiAssist:s,onAiQuickAction:o,aiLoading:a,fieldShimmer:u,highlightPath:d,fieldPath:f}){const m=Lce(n),g=m?m.text:n==null?"":String(n),[y,x]=E.useState(g),[v,S]=E.useState(!1),{debouncedCommit:w,flushCommit:T}=Yd(i,400),A=mC(f,d),M=`property-field${f&&f===d?" is-targeted":""}`,j=v?y:g,D=t.label??e,P=()=>{x(g),S(!0)},R=()=>{S(!1),T()};if(t.kind==="reference"){const W=UV(n,t.referenceLabelKey);return p.jsxs("div",{className:M,ref:A,children:[p.jsx("div",{className:"property-field-label",children:p.jsx("span",{children:D})}),p.jsxs("div",{className:"property-field-reference",title:W?`${W} — managed in the CMS`:"No reference set",children:[p.jsx("span",{className:"property-field-reference-target",children:W||"(not set)"}),p.jsx("span",{className:"property-field-reference-note",children:"CMS"})]})]})}if(m)return p.jsxs("div",{className:M,ref:A,children:[p.jsx("div",{className:"property-field-label",children:p.jsxs("span",{children:[D,t.required&&p.jsx("span",{className:"property-field-required",children:"*"})]})}),p.jsx("div",{className:"property-field-input-wrap",children:p.jsx("textarea",{className:"property-field-textarea",rows:Math.min(8,Math.max(3,g.split(`
|
|
749
|
-
`).length)),readOnly:!m.editable,value:j,onFocus:m.editable?P:void 0,onBlur:m.editable?R:void 0,onChange:m.editable?W=>{x(W.target.value),w(Bce(W.target.value))}:void 0})})]});if(t.kind==="headingLevel"){const W=(r&&lj[r])??"h2",K=g&&/^h[1-6]$/.test(g)?g:"";return p.jsxs("div",{className:"property-field",children:[p.jsx("div",{className:"property-field-label",children:p.jsx("span",{children:D})}),p.jsxs("select",{className:"property-field-input property-field-select",value:K,onChange:Y=>i(Y.target.value),children:[p.jsxs("option",{value:"",children:["Auto (",W.toUpperCase(),")"]}),["h1","h2","h3","h4","h5","h6"].map(Y=>p.jsx("option",{value:Y,children:Xve[Y]},Y))]})]})}if(t.kind==="image")return p.jsxs("div",{className:"property-field",children:[p.jsx("div",{className:"property-field-label",children:p.jsx("span",{children:D})}),p.jsx("div",{className:"property-field-image-url",title:g,children:g||"(empty)"})]});if(t.kind==="enum"&&t.options){const W=t.options.includes(g);return p.jsxs("div",{className:M,ref:A,children:[p.jsx("div",{className:"property-field-label",children:p.jsx("span",{children:D})}),p.jsxs("select",{className:"property-field-input property-field-select",value:g,onChange:K=>i(K.target.value),children:[!W&&p.jsx("option",{value:g,children:g||"—"}),t.options.map(K=>p.jsx("option",{value:K,children:K},K))]})]})}if(t.kind==="boolean"){const W=g==="true"||g==="1";return p.jsx("div",{className:`${M} property-field--inline`,ref:A,children:p.jsxs("div",{className:"property-field-label",children:[p.jsxs("span",{children:[D,t.required&&p.jsx("span",{className:"property-field-required",children:"*"})]}),p.jsx("button",{type:"button",role:"switch","aria-checked":W,"aria-label":D,className:`property-field-switch${W?" is-on":""}`,onClick:()=>i(W?"false":"true"),children:p.jsx("span",{className:"property-field-switch-knob","aria-hidden":"true"})})]})})}if(t.kind==="color")return p.jsxs("div",{className:"property-field",children:[p.jsx("div",{className:"property-field-label",children:p.jsx("span",{children:D})}),p.jsx("input",{type:"color",className:"property-field-color",value:g||"#000000",onChange:W=>i(W.target.value)})]});if(t.kind==="html")return p.jsxs("div",{className:M,ref:A,children:[p.jsx("div",{className:"property-field-label",children:p.jsxs("span",{children:[D,t.required&&p.jsx("span",{className:"property-field-required",children:"*"})]})}),p.jsx("div",{className:"property-field-input-wrap",children:p.jsx(Qve,{value:g,onCommit:W=>i(W),onFocus:P,onBlur:R,inline:t.inline})})]});if(t.kind==="richtext")return n!==null&&typeof n=="object"?p.jsxs("div",{className:M,ref:A,children:[p.jsx("div",{className:"property-field-label",children:p.jsxs("span",{children:[D,t.required&&p.jsx("span",{className:"property-field-required",children:"*"})]})}),p.jsx("div",{className:"property-field-input-wrap",children:p.jsx(JL,{value:n,onChange:W=>w(W),onFocus:P,onBlur:R,decorators:t.decorators,inline:t.inline})})]}):p.jsxs("div",{className:M,ref:A,children:[p.jsx("div",{className:"property-field-label",children:p.jsxs("span",{children:[D,t.required&&p.jsx("span",{className:"property-field-required",children:"*"})]})}),p.jsx("div",{className:`property-field-input-wrap${u?" property-field-input-wrap--ai-loading":""}`,children:p.jsx($ve,{value:g,onChange:W=>{x(W),w(W)},onFocus:P,onBlur:R,trailing:s?p.jsx(fp,{variant:"toolbar",onClick:s,fieldKind:t.kind,fieldLabel:t.label??e,blockType:r??"",currentValue:g,onQuickAction:o,onCustomPrompt:s,aiLoading:u}):null})})]});const B=t.multiline===!0,F=t.kind==="number"?"number":t.kind==="url"?"url":"text",q={value:j,onFocus:P,onChange:W=>{x(W.target.value),w(W.target.value)},onBlur:R};return p.jsxs("div",{className:M,ref:A,children:[p.jsx("div",{className:"property-field-label",children:p.jsxs("span",{children:[D,t.required&&p.jsx("span",{className:"property-field-required",children:"*"})]})}),p.jsxs("div",{className:`property-field-input-wrap${u?" property-field-input-wrap--ai-loading":""}`,children:[B?p.jsx("textarea",{className:"property-field-textarea",rows:3,...q}):p.jsx("input",{type:F,className:"property-field-input",...q}),s?p.jsx(fp,{onClick:s,fieldKind:t.kind,fieldLabel:t.label??e,blockType:r??"",currentValue:g,onQuickAction:o,onCustomPrompt:s,aiLoading:u}):null]})]})}function tke({slug:e,navLabel:t,onNavLabelChange:n,onAiAssist:r,onAiQuickAction:i,aiLoading:s,fieldShimmer:o}){const{t:a}=Nn(),[u,d]=E.useState(t),[f,m]=E.useState(!1),g=f?u:t,{debouncedCommit:y,flushCommit:x}=Yd(v=>n(e,v),400);return p.jsx(uy,{id:"page:nav",title:a("propertyPanel.navigation"),count:1,children:p.jsxs("div",{className:"property-field",children:[p.jsx("div",{className:"property-field-label",children:p.jsx("span",{children:a("propertyPanel.navLabel")})}),p.jsxs("div",{className:`property-field-input-wrap${o?" property-field-input-wrap--ai-loading":""}`,children:[p.jsx("input",{type:"text",className:"property-field-input",placeholder:a("propertyPanel.navPlaceholder"),value:g,onFocus:()=>{d(t),m(!0)},onChange:v=>{d(v.target.value),y(v.target.value)},onBlur:()=>{m(!1),x()}}),r?p.jsx(fp,{onClick:()=>r("Nav label","text",t),fieldKind:"text",fieldLabel:"Nav label",blockType:"Page",currentValue:t,onQuickAction:i?v=>i("Nav label","text",t,v):void 0,onCustomPrompt:()=>r("Nav label","text",t),aiLoading:o}):null]})]})})}function nke({pageMeta:e,onPageMetaChange:t,onAiAssist:n,onAiQuickAction:r,aiLoading:i,aiLoadingPath:s}){const{t:o}=Nn();return p.jsxs(uy,{id:"page:seo",title:o("propertyPanel.seo"),count:3,children:[p.jsx(lk,{label:o("propertyPanel.seoTitle"),fieldKind:"text",blockType:"Page",value:e.title??"",placeholder:o("propertyPanel.seoTitlePlaceholder"),multiline:!0,autosizeRows:{min:2,max:2},recommendedMax:60,onCommit:a=>t("title",a),onAiAssist:n?()=>n("SEO title","text",e.title??""):void 0,onAiQuickAction:r?a=>r("SEO title","text",e.title??"",a):void 0,aiLoading:i,fieldShimmer:i===!0&&s==="SEO title"}),p.jsx(lk,{label:o("propertyPanel.metaDescription"),fieldKind:"richtext",blockType:"Page",value:e.description??"",placeholder:o("propertyPanel.metaDescPlaceholder"),multiline:!0,autosizeRows:{min:3,max:6},recommendedMax:160,onCommit:a=>t("description",a),onAiAssist:n?()=>n("Meta description","richtext",e.description??""):void 0,onAiQuickAction:r?a=>r("Meta description","richtext",e.description??"",a):void 0,aiLoading:i,fieldShimmer:i===!0&&s==="Meta description"}),p.jsx(lk,{label:o("propertyPanel.ogImage"),fieldKind:"url",blockType:"Page",value:e.ogImage??"",placeholder:"https://...",onCommit:a=>t("ogImage",a)})]})}function lk({label:e,fieldKind:t,blockType:n,value:r,placeholder:i,multiline:s,autosizeRows:o,recommendedMax:a,onCommit:u,onAiAssist:d,onAiQuickAction:f,aiLoading:m,fieldShimmer:g}){const[y,x]=E.useState(r),[v,S]=E.useState(!1),w=E.useRef(null),T=v?y:r,{debouncedCommit:A,flushCommit:M}=Yd(u,400),j=s===!0&&o!=null,D=E.useCallback(()=>{if(!j||!w.current||!o)return;const B=w.current,F=getComputedStyle(B),q=Number.parseFloat(F.lineHeight),W=Number.parseFloat(F.fontSize)||15,K=Number.isFinite(q)?q:W*1.2,Y=(Number.parseFloat(F.paddingTop)||0)+(Number.parseFloat(F.paddingBottom)||0),V=(Number.parseFloat(F.borderTopWidth)||0)+(Number.parseFloat(F.borderBottomWidth)||0),O=o.min*K+Y+V,U=o.max*K+Y+V;B.style.height="0px";const Q=B.scrollHeight,le=Math.max(O,Math.min(U,Q));B.style.height=`${le}px`,B.style.overflowY=Q>U?"auto":"hidden"},[j,o]);E.useLayoutEffect(()=>{D()},[D,T,v,r]),E.useEffect(()=>{if(!j)return;const B=()=>D();return window.addEventListener("resize",B),()=>window.removeEventListener("resize",B)},[j,D]);const P={placeholder:i,value:T,onFocus:()=>{x(r),S(!0)},onChange:B=>{x(B.target.value),A(B.target.value)},onBlur:()=>{S(!1),M()}},R=(v?y:r).length;return p.jsxs("div",{className:"property-field",children:[p.jsx("div",{className:"property-field-label",children:p.jsx("span",{children:e})}),p.jsxs("div",{className:`property-field-input-wrap${g?" property-field-input-wrap--ai-loading":""}`,children:[s?p.jsx("textarea",{ref:j?w:void 0,className:`property-field-textarea${j?" property-field-textarea--autosize":""}`,rows:(o==null?void 0:o.min)??3,...P}):p.jsx("input",{type:"text",className:"property-field-input",...P}),d?p.jsx(fp,{onClick:d,fieldKind:t,fieldLabel:e,blockType:n,currentValue:v?y:r,onQuickAction:f,onCustomPrompt:d,aiLoading:g}):null]}),a!=null&&p.jsxs("span",{className:`property-field-char-count${R>a?" property-field-char-count--over":""}`,children:[R," / ",a]})]})}class uk extends E.Component{constructor(){super(...arguments);Ee(this,"state",{error:null});Ee(this,"reset",()=>{var n,r;(r=(n=this.props).onReset)==null||r.call(n),this.setState({error:null})})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,r){var i,s;console.error("[editor] Uncaught error in component tree:",n,r.componentStack),(s=(i=this.props).onError)==null||s.call(i,n,r)}render(){return this.state.error?p.jsxs("div",{style:this.props.style,className:"flex flex-col items-center justify-center gap-3 p-6 text-center text-sm text-muted-foreground h-full",children:[p.jsx("p",{className:"font-medium text-foreground",children:this.props.fallbackLabel??"Something went wrong"}),p.jsx("p",{className:"max-w-xs opacity-70 text-xs",children:this.state.error.message}),p.jsx("button",{type:"button",onClick:this.reset,className:"rounded-md border px-3 py-1.5 text-xs hover:bg-accent transition-colors",children:"Try again"})]}):this.props.children}}function rke({siteId:e,orchestratorUrl:t,hostedIds:n,siteOwnOrchestrator:r}){const{t:i}=Nn(),s=()=>{yce(e),window.location.href=xce(window.location.href)},o=()=>{r&&(bce(e,r),window.location.reload())};return r?p.jsxs("div",{className:"orchestrator-mismatch",role:"alert",children:[p.jsxs("div",{className:"orchestrator-mismatch-body",children:[p.jsx("strong",{children:i("orchestratorMismatch.ownTitle")}),p.jsx("span",{children:i("orchestratorMismatch.ownDetail",{orchestrator:t,siteOrchestrator:r})})]}),p.jsx("button",{type:"button",className:"orchestrator-mismatch-action",onClick:o,children:i("orchestratorMismatch.useSiteOwn")})]}):p.jsxs("div",{className:"orchestrator-mismatch",role:"alert",children:[p.jsxs("div",{className:"orchestrator-mismatch-body",children:[p.jsx("strong",{children:i("orchestratorMismatch.title")}),p.jsx("span",{children:n.length>0?i("orchestratorMismatch.detailHosts",{orchestrator:t,hosted:n.join(", ")}):i("orchestratorMismatch.detail",{orchestrator:t})})]}),p.jsx("button",{type:"button",className:"orchestrator-mismatch-action",onClick:s,children:i("orchestratorMismatch.useDefault")})]})}const Ng=3e3;function ike(e){const[t,n]=E.useState({status:"loading",blocks:[],manifest:null});E.useEffect(()=>{let i=!0,s=null;const o=async()=>{try{const u=await fetch(`${e||Vd}/api/editor/blocks`);if(!u.ok){if(!i)return;n({status:"degraded",blocks:[],manifest:null,reason:`Manifest endpoint returned ${u.status}`}),s=setTimeout(()=>{i&&o()},Ng);return}const d=await u.json(),f=dj.safeParse(d);if(!f.success){if(!i)return;n({status:"degraded",blocks:[],manifest:null,reason:"Manifest response shape is invalid"}),s=setTimeout(()=>{i&&o()},Ng);return}const m=mj(f.data.blocks);if(m){if(!i)return;n({status:"degraded",blocks:[],manifest:null,reason:m}),s=setTimeout(()=>{i&&o()},Ng);return}if(!i)return;n({status:"ready",blocks:f.data.blocks,version:f.data.version,manifest:f.data})}catch(a){if(!i)return;n({status:"degraded",blocks:[],manifest:null,reason:a instanceof Error?a.message:"Manifest fetch failed"}),s=setTimeout(()=>{i&&o()},Ng)}};return o(),()=>{i=!1,s&&clearTimeout(s)}},[e]);const r=E.useMemo(()=>{const i=new Map;for(const s of t.blocks)i.set(s.type,s);return i},[t.blocks]);return{...t,byType:r,siteCapabilities:{allowStructuralEdits:t.status==="ready",manifestStatus:t.status,reason:t.reason,manifestVersion:t.version,blockCount:t.blocks.length,checkedAt:new Date().toISOString()},allowStructuralEdits:t.status==="ready"}}function ske(e){const[t,n]=E.useState(void 0);return E.useEffect(()=>{if(Hk)return;let r=!1;return gce(e).then(i=>{r||!i||i.replace(/\/+$/,"")!==Be.replace(/\/+$/,"")&&n(i)}),()=>{r=!0}},[e]),t}function oke(e){const t=e==null?void 0:e.trim().toLowerCase();return t?t==="text"?"text":t==="legacy"||t==="sparkle"||t==="dots"||t==="sparkle-dots"?"legacy":null:null}function ake(){const e=oke(Ii().VITE_STREAMING_INDICATOR_STYLE);return e||"text"}const WS={active:!1,scope:"block",blockId:"",editablePath:""},lke="__page__";function uke(e){var t;for(let n=e.length-1;n>=0;n--)if(e[n].role==="user")return((t=e[n-1])==null?void 0:t.fieldAiContext)??null;return null}function cke(e){const{streamScope:t,fieldContext:n,focusBlockId:r,activeBlockId:i,activeEditablePath:s}=e;if(n)return n.blockId===lke?WS:{active:!0,scope:"block",blockId:n.blockId,editablePath:n.fieldPath};if(t==="pending")return WS;if(t&&t.scope!=="block")return{active:!0,scope:"page",blockId:r??"",editablePath:""};const o=r??((t==null?void 0:t.blockId)||null)??i;return o?{active:!0,scope:"block",blockId:o,editablePath:o===i?s??"":""}:{active:!0,scope:"page",blockId:"",editablePath:""}}const dke=/^[a-z]{2}(?:-[a-z0-9]{2,8})?$/i,Il="default",fke=2;let sh;function hke(e){if(!dke.test(e))return!1;if(sh===void 0)try{sh=new Intl.DisplayNames(["en"],{type:"language",fallback:"none"})}catch{sh=null}if(!sh)return!1;try{return typeof sh.of(e)=="string"}catch{return!1}}function cy(e){return e.split("/").filter(Boolean)}function tc(e){const t=cy(e);return t.length===0?"/":`/${t.join("/")}`}function pke(e){const t={},n=[];for(const u of e){const d=cy(u)[0];if(d&&hke(d)){const f=d.toLowerCase();(t[f]||(t[f]=[])).push(u)}else n.push(u)}const r=Object.keys(t).sort();if(r.length<2)return null;const i=new Map;for(const u of r)for(const d of new Set(t[u].map(f=>gC(f,u))))i.set(d,(i.get(d)??0)+1);if(![...i.values()].some(u=>u>=2))return null;const o=n.filter(u=>i.has(tc(u))).length>=fke,a=o?[]:n;o&&(t[Il]=n,r.unshift(Il));for(const u of r){const d=u===Il?"/":`/${u}`;t[u].sort((f,m)=>f===d?-1:m===d?1:0)}return{locales:r,byLocale:t,shared:a}}function t8(e,t){var i;const n=(i=cy(e)[0])==null?void 0:i.toLowerCase();if(n&&t.byLocale[n])return n;const r=t.byLocale[Il];return r!=null&&r.some(s=>tc(s)===tc(e))?Il:void 0}function gC(e,t){var i;if(!t||t===Il)return tc(e);const n=cy(e);if(((i=n[0])==null?void 0:i.toLowerCase())!==t.toLowerCase())return tc(e);const r=n.slice(1);return r.length===0?"/":`/${r.join("/")}`}function mke(e,t){return`${G4(gC(e,t))} (${e})`}function gke(e,t,n){const r=n.byLocale[t];if(!r||r.length===0)return e;const i=gC(e,t8(e,n)),s=t===Il?i:i==="/"?`/${t}`:`/${t}${i}`;return r.find(a=>tc(a)===tc(s))??r[0]}function bke(e){try{const t=new Intl.DisplayNames([e],{type:"language"}).of(e);if(t&&t.toLowerCase()!==e.toLowerCase())return t.charAt(0).toUpperCase()+t.slice(1)}catch{}return e.toUpperCase()}const sR=ake(),yke=!1,xke=dd||yke,vke=wG(),kke=E.lazy(()=>WB(()=>import("./PuckPrototypeRoute-Dy8cRpYT.js").then(e=>e.P),__vite__mapDeps([0,1])).then(e=>({default:e.PuckPrototypeRoute}))),Ske=new Set(["/editor/puck","/editor/puck/"]),wke=3e4,n8="site-reachable-v1:",Cke=5e3;function r8(e){if(typeof sessionStorage>"u")return null;try{const t=sessionStorage.getItem(n8+e);if(!t)return null;const n=JSON.parse(t);return Date.now()-n.ts>wke?null:n.ok}catch{return null}}function oR(e,t){if(!(typeof sessionStorage>"u"))try{sessionStorage.setItem(n8+e,JSON.stringify({ok:t,ts:Date.now()}))}catch{}}function Eke({name:e,origin:t,statusClass:n,active:r,dimmed:i,onSelect:s}){const o=t.replace(/^https?:\/\//,"");return p.jsxs("button",{type:"button",role:"menuitem",className:`site-switcher-item${r?" is-active":""}${i?" is-dimmed":""}`,onClick:s,title:t,children:[p.jsx("span",{className:`site-switcher-item-dot site-switcher-item-dot-${n}`,"aria-hidden":"true"}),p.jsxs("span",{className:"site-switcher-item-body",children:[p.jsx("span",{className:"site-switcher-item-name",children:e}),p.jsx("span",{className:"site-switcher-item-origin",children:o})]}),r?p.jsx(Fd,{size:12,"aria-hidden":"true"}):null]})}function aR(e){if(typeof sessionStorage>"u")return null;const t=new Set;let n=!1;for(const r of e){const i=r8(r);i!==null&&(n=!0,i&&t.add(r))}return n?t:null}function _ke(e,t){if(e===t)return!0;if(!e||!t||e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Tke(){const e=typeof window<"u"?window.location.pathname:"/",t=e==="/"||e==="/editor"||e==="/editor/",n=Ske.has(e),r=e==="/sites"||e==="/sites/";ce(d=>d.chatDarkMode);const i=ce(d=>d.setChatDarkMode),s=E.useMemo(()=>Pw(),[]),o=E.useMemo(()=>n6(),[]),a=E.useRef(!1);a.current||(a.current=!0,$G({sessionId:s,siteId:o}));const u=kce(o,s);return E.useEffect(()=>{if(typeof window>"u")return;const d=window.matchMedia("(prefers-color-scheme: dark)"),f=m=>{gw()===null&&i(m.matches,{persist:!1})};return d.addEventListener("change",f),()=>d.removeEventListener("change",f)},[i]),n?p.jsx(E.Suspense,{fallback:p.jsx("div",{style:{height:"100vh",display:"grid",placeItems:"center"},children:"Loading prototype…"}),children:p.jsx(kke,{})}):r?p.jsx(ON,{sites:u,session:s}):t?p.jsx(Nke,{sites:u}):p.jsx(ON,{sites:u,session:s})}function Ake(e){return e.split(".").map(t=>{const n=t.match(/^([a-zA-Z_]+)\[(\d+)\]$/);return n?`${lR(n[1])} ${Number(n[2])+1}`:lR(t)}).join(" · ")}function lR(e){const n=e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\s*url\s*$/i,"").trim();return n?n.charAt(0).toUpperCase()+n.slice(1):e}function Nke({sites:e}){var uf,cf,fc;const{t}=Nn(),n=Ui(),r=Hi(),i=ce(_=>_.chatDarkMode),s=ce(_=>_.chatThemePreference),o=ce(_=>_.setChatThemePreference),{activeSiteConfig:a}=e,u=E.useMemo(()=>Pu(a),[a]),d=ike(u),f=typeof window<"u"?window.location.origin:"http://localhost:4100",m=ske(u),g=e.siteHosting==="notHosted"||m!=null,y=ce(_=>_.slug),x=ce(_=>_.setSlug),v=ce(_=>_.availableSlugs);ce(_=>_.setAvailableSlugs);const S=ce(_=>_.isLoadingSlugs),w=ce(_=>_.modelKey),T=ce(_=>_.setModelKey),A=ce(_=>_.provider),M=ce(_=>_.setProvider),j=ce(_=>_.availableProviders),D=ce(_=>_.setAvailableProviders),[P,R]=E.useState(""),B=ce(_=>_.activeBlockId),F=ce(_=>_.activeBlockType),q=ce(_=>_.activeEditablePath),W=_=>ce.getState().setActiveBlock(_),K=_=>{const G=ce.getState();G.setActiveBlock(G.activeBlockId,_)},Y=(_,G)=>ce.getState().setActiveBlock(_,G),V=ce(_=>_.setActiveEditablePath),O=ce(_=>_.useStreaming),U=ce(_=>_.setUseStreaming),Q=ce(_=>_.autoScrollTrackingEnabled),le=ce(_=>_.setAutoScrollTrackingEnabled),I=ce(_=>_.autoOpenPropertiesEnabled),$=ce(_=>_.setAutoOpenPropertiesEnabled),[X,z]=E.useState(!1),[Z,oe]=E.useState(vke),ee=E.useCallback(_=>{oe(_);try{window.localStorage.setItem(Ek,_?"1":"0")}catch{}},[]),ne=E.useMemo(()=>!dd||new URLSearchParams(window.location.search).has("dev"),[]),Ae=ne&&Z,[_e,Oe]=E.useState(!1),[he,xe]=E.useState(0),Pe=E.useCallback(()=>xe(_=>_+1),[]),ie=ce(_=>_.showSettingsModal),qe=ce(_=>_.setShowSettingsModal),Ke=ce(_=>_.showDebugDetails),bt=ce(_=>_.setShowDebugDetails),qt=ce(_=>_.composerHeight),Ct=ce(_=>_.setComposerHeight),at=ce(_=>_.addBlockPicker),Et=ce(_=>_.setAddBlockPicker),Ye=ce(_=>_.addBlockSearch),At=ce(_=>_.setAddBlockSearch),vt=ce(_=>_.isAddingBlock),lt=ce(_=>_.setIsAddingBlock),fe=ce(_=>_.copiedDebugEntryId),Te=ce(_=>_.setCopiedDebugEntryId),Fe=ce(_=>_.feedbackNoteEntryId),nt=ce(_=>_.setFeedbackNoteEntryId),Dt=ce(_=>_.feedbackNoteText),cn=ce(_=>_.setFeedbackNoteText),Nr=ce(_=>_.selectedVariationId),xn=ce(_=>_.setSelectedVariationId),Rt=ce(_=>_.imagePickerTarget),zn=ce(_=>_.setImagePickerTarget),tn=Rt!==null,Mr=ce(_=>_.backendFeatures),Dr=ce(_=>_.setBackendFeatures),ve=ce(_=>_.setBackendSite),$e=ce(_=>_.selectionModeEnabled),ge=ce(_=>_.setSelectionModeEnabled),je=ce(_=>_.anchorRect),Le=ce(_=>_.setAnchorRect),ze=ce(_=>_.anchoredExpanded),tt=ce(_=>_.setAnchoredExpanded),Ve=ce(_=>_.activeTab),ht=ce(_=>_.setActiveTab),[Ft,Wt]=E.useState(!1),[vn,Ln]=E.useState(!1),rr=E.useRef(null);E.useEffect(()=>{if(!vn)return;const _=se=>{rr.current&&!rr.current.contains(se.target)&&Ln(!1)},G=se=>{se.key==="Escape"&&Ln(!1)};return document.addEventListener("mousedown",_),document.addEventListener("keydown",G),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",G)}},[vn]);const[Yi,Js]=E.useState(()=>aR(e.siteList.map(_=>_.id))),Gr=E.useCallback(_=>{Js(G=>_ke(G,_)?G:_)},[]);E.useEffect(()=>{if(!vn)return;Gr(aR(e.siteList.map(se=>se.id)));let _=!0;return(async()=>{let se=!0;const Ce=await Promise.all(e.siteList.map(async Me=>{const Ue=r8(Me.id);if(Ue!==null)return{id:Me.id,ok:Ue};se=!1;const et=Pu(Me);try{const dn=await fetch(`${et}/api/editor/blocks?siteId=${encodeURIComponent(Me.id)}`,{signal:AbortSignal.timeout(2500)});return oR(Me.id,dn.ok),{id:Me.id,ok:dn.ok}}catch{return oR(Me.id,!1),{id:Me.id,ok:!1}}}));_&&!se&&Gr(new Set(Ce.filter(Me=>Me.ok).map(Me=>Me.id)))})(),()=>{_=!1}},[vn,e.siteList,Gr]);const Wr=E.useMemo(()=>{const _=Yi===null;return e.siteList.map(G=>{const se=_||G.id===r||Yi.has(G.id);return{site:G,origin:Pu(G),online:se,probing:_}}).sort((G,se)=>G.site.id===r?-1:se.site.id===r?1:G.online!==se.online?G.online?-1:1:G.site.name.localeCompare(se.site.name))},[Yi,e.siteList,r]),{onlineEntries:Xs,activeEntry:Rr}=E.useMemo(()=>({onlineEntries:Wr.filter(_=>_.online),activeEntry:Wr.find(_=>_.site.id===r)}),[Wr,r]),Pt=E.useRef(null),Bn=E.useRef(null),zr=E.useRef(!0),ws=E.useRef(!1),Cs=E.useRef(null),vi=E.useRef(void 0),gr=E.useRef(!1),Ji=E.useRef(null),Xi=E.useRef(!1),ai=E.useRef(0),li=E.useRef(null),Fn=E.useRef(null),on=ce(_=>_.chatWidth),jt=ce(_=>_.setChatWidth),Es=ce(_=>_.propsWidth),Zr=ce(_=>_.setPropsWidth),br=E.useRef(null),Yr=E.useRef(null),[Qi,Go]=E.useState(1),_s=E.useRef(null),Wo=E.useRef(null),es=E.useRef(!1),ts=E.useRef(null),ui=E.useRef(!1);E.useEffect(()=>{if(!ui.current&&!(S||v.length===0)){if(y!=="/"||v.includes("/")){ui.current=!0;return}ui.current=!0,gr.current=!1,x(v[0])}},[v,S,y,x]);const ir=E.useMemo(()=>{const _=Array.from(new Set([...v,y].filter(Boolean)));return _.includes("/")?["/",..._.filter(G=>G!=="/")]:_},[v,y]),er=E.useMemo(()=>pke(ir),[ir]),ci=er?t8(y,er)??er.locales[0]:void 0,Qs=E.useMemo(()=>!er||!ci?ir:er.byLocale[ci]??[],[er,ci,ir]),Zo=E.useMemo(()=>{if(!d.allowStructuralEdits)return[];if(d.blocks.length>0)return d.blocks.map(G=>({type:G.type,label:G.displayName??G.type,category:"content"})).sort((G,se)=>G.label.localeCompare(se.label));const _=Au();return[...xk].map(G=>{var se,Ce;return{type:G,label:((se=_[G])==null?void 0:se.displayName)??G,category:((Ce=_[G])==null?void 0:Ce.category)??"content"}}).sort((G,se)=>G.label.localeCompare(se.label))},[d.allowStructuralEdits,d.blocks]),yo=E.useMemo(()=>{const _=Ye.trim().toLowerCase(),G=_?Zo.filter(Me=>Me.label.toLowerCase().includes(_)||Me.type.toLowerCase().includes(_)):Zo,se=new Map;for(const Me of G){const Ue=Me.category||"content",et=se.get(Ue);et?et.push(Me):se.set(Ue,[Me])}const Ce=["content","layout","conversion","navigation","media"];return[...se.entries()].sort((Me,Ue)=>{const et=Ce.indexOf(Me[0]),dn=Ce.indexOf(Ue[0]),or=et===-1?Number.MAX_SAFE_INTEGER:et,Cn=dn===-1?Number.MAX_SAFE_INTEGER:dn;return or!==Cn?or-Cn:Me[0].localeCompare(Ue[0])}).map(([Me,Ue])=>({category:Me,options:Ue}))},[Ye,Zo]),eo=()=>{const _=Date.now();_-ai.current<1200||(ai.current=_,Ge.pushAssistantFromResult({status:"needs_clarification",summary:t("streamError.structuralDisabled"),changes:TP(d.reason)}))},yr=E.useRef(()=>{}),xr=E.useCallback(_=>{ce.getState().slug!==_&&(Xi.current=!0,x(_))},[x]),Ia=E.useMemo(()=>({onBlockClicked:(_,G,se,Ce,Me,Ue)=>{xr(_),Y(G,se),V(Ce),Le(G?Ue:null);const et=ce.getState();G?et.autoOpenPropertiesEnabled&&et.setActiveTab("properties"):et.setActiveTab("chat")},onRouteChanged:_=>{ce.getState().slug!==_&&Y(void 0,void 0),xr(_),V(void 0),Le(null),Oi.current("setSelectionMode",{enabled:ce.getState().selectionModeEnabled}),yr.current(_)},onBlockReordered:(_,G,se)=>{if(!d.allowStructuralEdits){eo();return}_!==y&&xr(_),V(void 0),Ge.reorderBlock(_,G,se)},onBlockDeleteRequested:(_,G)=>{if(!d.allowStructuralEdits){eo();return}_!==y&&xr(_),V(void 0),Ge.deleteBlock(_,G)},onBlockAddRequested:(_,G)=>{if(!d.allowStructuralEdits){eo();return}_!==y&&xr(_),!(!G.afterBlockId&&!G.beforeBlockId)&&Et({slug:_,afterBlockId:G.afterBlockId,beforeBlockId:G.beforeBlockId})},onListItemAddRequested:(_,G,se,Ce,Me)=>{if(!d.allowStructuralEdits){eo();return}_!==y&&xr(_),V(void 0),Ge.addListItem(_,G,se,Ce,Me)},onListItemRemoveRequested:(_,G,se,Ce,Me)=>{if(!d.allowStructuralEdits){eo();return}_!==y&&xr(_),V(void 0),Ge.removeListItem(_,G,se,Ce,Me)},onListItemMoveRequested:(_,G,se,Ce,Me,Ue)=>{if(!d.allowStructuralEdits){eo();return}_!==y&&xr(_),V(void 0),Ge.moveListItem(_,G,se,Ce,Me,Ue)},onOpenImagePicker:(_,G,se,Ce,Me)=>{zn({slug:_,blockId:G,editablePath:se,currentUrl:Ce,blockType:Me??(G===B?F:void 0)})},onEditBlockRequested:(_,G)=>{tt(!0)},onInlineTextCommitted:(_,G,se,Ce)=>{_!==y&&xr(_),se&&V(se),Ge.inlineEditCommit(_,G,se,Ce)},onIframeScrolled:()=>{Le(null),ce.getState().isLoading&&ce.getState().setAutoScrollSuppressed(!0)}}),[d.allowStructuralEdits,xr,y]),Oa=E.useCallback(async()=>{var _;try{const G=`${Be}/draft/pages?session=${encodeURIComponent(n)}&siteId=${encodeURIComponent(r)}&slug=${encodeURIComponent(y)}`,se=await fetch(G,{cache:"no-store"});if(!se.ok)return;const Me=((await se.json()).blocks??[]).find(Ue=>Ue.type==="Hero");if(!Me)return;Y(Me.id,Me.type),zn({slug:y,blockId:Me.id,editablePath:"imageUrl",currentUrl:typeof((_=Me.props)==null?void 0:_.imageUrl)=="string"?Me.props.imageUrl:void 0,blockType:Me.type})}catch{}},[n,r,y,zn]),Zt=Sce(y,Ia,u),Oi=E.useRef(Zt.postToSite);E.useEffect(()=>{Oi.current=Zt.postToSite},[Zt.postToSite]);const to=E.useCallback(_=>{const G=_??!$e;ge(G),Zt.postToSite("setSelectionMode",{enabled:G})},[$e,Zt]);E.useEffect(()=>{const _=G=>{G.key==="Escape"&&$e&&to(!1)};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[$e,to]),E.useEffect(()=>{if(Ve!=="history"&&Ve!=="health")return;const _=G=>{G.key==="Escape"&&ce.getState().setActiveTab("chat")};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[Ve]);const ki=E.useCallback((_,G)=>{(_==="draftUpdated"||_==="liveDraft")&&Pe(),Zt.postToSite(_,G)},[Zt,Pe]),no=E.useCallback((_,G,se,Ce,Me)=>(Pe(),Zt.postPatchToSite(_,G,se,Ce,Me)),[Zt,Pe]),Ge=Ace({activeSiteConfig:a,siteRegistryChecked:e.siteRegistryChecked,postToSite:ki,postPatchToSite:no,componentManifest:d.manifest,siteCapabilities:d.siteCapabilities,allowStructuralEdits:d.allowStructuralEdits,getBlockDefaultProps:_=>{var G;return((G=d.byType.get(_))==null?void 0:G.defaultProps)??null},onApplied:()=>{var _;(_=vi.current)==null||_.call(vi)},agentModeEnabled:Mr.agentMode??!1}),Ts=ce(_=>_.chatLog),xo=ce(_=>_.chatAttachments),Ql=ce(_=>_.setChatAttachments),jn=ce(_=>_.isLoading),fr=ce(_=>_.streamStatus),Si=ce(_=>_.streamingText),eu=ce(_=>_.streamingChanges),vo=ce(_=>_.streamSteps),ro=ce(_=>_.streamTokenCount),ns=ce(_=>_.latestStreamFocusBlockId),wi=ce(_=>_.streamScope),Lr=ce(_=>_.imageProgress),As=ce(_=>_.plannerBadgeState),[Yo,ft]=E.useState(!1),kt=ce(_=>_.setPlannerBadgeState),Se=ce(_=>_.pendingPlanId),St=ce(_=>_.variationModal),jr=ce(_=>_.isApplyingVariation),Ci=ce(_=>_.setVariationModal),di=ce(_=>_.continuationChainId),Br=ce(_=>_.fieldDraftDebugEnabled),it=ce(_=>_.setFieldDraftDebugEnabled),gt=ce(_=>_.fieldDraftDebug);E.useEffect(()=>{t6.has(r)||(T("balanced"),Ge.clearChat())},[r]);function Qt(_){var G,se;typeof _.navigateToSlug=="string"&&_.navigateToSlug.length>0&&_.navigateToSlug!==y&&x(_.navigateToSlug),typeof _.canUndo=="boolean"&&((G=Ge.setCanUndoServer)==null||G.call(Ge,_.canUndo)),typeof _.canRedo=="boolean"&&((se=Ge.setCanRedoServer)==null||se.call(Ge,_.canRedo)),Zt.postToSite("draftUpdated",{focusBlockId:null}),Pe()}async function kn(_){Wt(!0);try{const se=await(await fetch(`${Be}/history/restore`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({session:n,siteId:r,targetVersion:_})})).json();se.status==="applied"&&Qt(se)}catch{}finally{Wt(!1)}}const hn=Dce(n,r,u,he),_t=Mce(n,r,jn,Ge.pushAssistantFromResult,u,()=>{Zt.postToSite("draftUpdated",{focusBlockId:null}),hn.markPublished()}),Sn=hn.summary?hn.summary.total>0:!0,Ir=Rce(),wn=Ve==="properties"&&Ge.hasBootstrapped,$n=Oce(n,r,y,B,wn),Ns=Pce(n,r,y,wn);E.useEffect(()=>{!B||F||!$n.blockType||K($n.blockType)},[B,F,$n.blockType]);const sr=qee(n,r,!!n),Pa=Kee(sr.findings),ko=g6(2),tu=E.useRef(null),za=E.useCallback((_,G,se)=>{Y(_,G),V(se),Le(null),ce.getState().selectionModeEnabled||(ce.getState().setSelectionModeEnabled(!0),Oi.current("setSelectionMode",{enabled:!0})),Oi.current("highlightBlock",{blockId:_,editablePath:se??null,scrollIntoView:!0})},[]),cc=E.useCallback(_=>{const G=tu.current;!G||G.slug!==_||(tu.current=null,!(G.expiresAt!==void 0&&Date.now()>G.expiresAt)&&za(G.blockId,G.blockType,G.path))},[za]);E.useEffect(()=>{if(!tu.current)return;const _=setTimeout(()=>cc(y),400);return()=>clearTimeout(_)},[y,cc]),E.useEffect(()=>{yr.current=cc},[cc]);const dy=E.useCallback((_,G,se,Ce)=>{if(!G){_!==ce.getState().slug&&x(_),Y(void 0,void 0),V(void 0),ht("properties");return}if(_!==ce.getState().slug){tu.current={slug:_,blockId:G,blockType:se,path:Ce},x(_),ht("properties");return}ht("properties"),tu.current={slug:_,blockId:G,...se?{blockType:se}:{},...Ce?{path:Ce}:{},expiresAt:Date.now()+Cke},za(G,se,Ce)},[za]);vi.current=()=>{$n.refetch(),Ns.refetch(),Pe()};const[Dp,fy]=E.useState(()=>Vk(y,{session:n,siteId:r,editorOrigin:f},u)),[hy,Qd]=E.useState(!1);E.useEffect(()=>{Qd(!1)},[Dp]),E.useEffect(()=>{Ji.current!==u&&(Ji.current=u,gr.current=!1);const _={session:n,siteId:r,editorOrigin:f};if(Xi.current){Xi.current=!1;return}if(t0&&gr.current){Zt.postToSite("navigate",{href:qk(y,_)});return}const G=Vk(y,_,u);fy(se=>se===G?se:G)},[u,f,n,r,y]);const Rp=E.useMemo(()=>{var se;const _=(se=a.vercelProductionUrl)==null?void 0:se.trim(),G=_&&/^https?:\/\//i.test(_)?_:u;try{const Ce=new URL(G);return Ce.origin===u?wee(y,{},u):(Ce.pathname=y==="/"?"/":y,Ce.search="",Ce.hash="",Ce.toString())}catch{return}},[a.vercelProductionUrl,u,y]),jp=E.useMemo(()=>u?`${u}${qk(y,{session:n,siteId:r,editorOrigin:f,immersive:"1"})}`:void 0,[u,f,n,r,y]);E.useEffect(()=>{let _=!0;const G=async()=>{const Ce=[`${Be}/status/planner`];Be.includes("localhost")&&Ce.push(`${Be.replace("localhost","127.0.0.1")}/status/planner`);try{for(const Me of Ce){const Ue=await fetch(Me);if(!Ue.ok)continue;const et=await Ue.json();if(!_)return;if(et.features&&Dr(et.features),et.site&&ve(et.site),Array.isArray(et.availableProviders)&&et.availableProviders.length>0&&(D(et.availableProviders),(!et.availableProviders.includes(A)||A!=="anthropic"&&et.availableProviders.includes("anthropic"))&&M(et.availableProviders.includes("anthropic")?"anthropic":et.availableProviders[0])),typeof et.keyFilePath=="string"&&et.keyFilePath.length>0&&ce.getState().setKeyFilePath(et.keyFilePath),et.plannerSource==="openai"||et.plannerSource==="anthropic"||et.plannerSource==="gemini"||et.plannerSource==="demo"){kt(et.plannerSource);return}}_&&kt("error")}catch{_&&kt("error")}};G();const se=window.setInterval(()=>{G()},1e4);return()=>{_=!1,window.clearInterval(se)}},[]);const Ip=E.useRef(0),Op=E.useRef(0);E.useEffect(()=>{const _=Bn.current;if(!_)return;const G=()=>{const se=Math.abs(_.scrollHeight-_.scrollTop-_.clientHeight)<2||_.scrollHeight<=_.clientHeight;!se&&_.scrollTop<Ip.current?zr.current=!1:se&&(zr.current=!0),Ip.current=_.scrollTop};return _.addEventListener("scroll",G,{passive:!0}),()=>{_.removeEventListener("scroll",G)}},[]),E.useEffect(()=>{const _=Bn.current;if(!_||!(Ts.length>0||!!fr||!!Si))return;const se=Ts.reduce((dn,or)=>or.role==="user"?dn+1:dn,0);se>Op.current&&(zr.current=!0),Op.current=se;const Ce=!ws.current,Me=Ts.some(dn=>dn.role==="user");if(Ce&&!Me&&!fr&&!Si){ws.current=!0,zr.current=!1;return}if(!Ce&&!zr.current)return;const et=window.requestAnimationFrame(()=>{_.scrollTop=_.scrollHeight,zr.current=!0,ws.current=!0});return()=>window.cancelAnimationFrame(et)},[Ts.length,fr,Si,vo.length,eu.length]),E.useEffect(()=>{Zt.postToSite("setNestedLabelsVisibility",{visible:X})},[X]),E.useEffect(()=>{const _=Oi.current;if(!jn){es.current&&_("aiFieldLoading",WS),Wo.current=null,es.current=!1,ts.current=null;return}ts.current||(ts.current={fieldContext:uke(ce.getState().chatLog)});const G=cke({streamScope:wi,fieldContext:ts.current.fieldContext,focusBlockId:ns,activeBlockId:B,activeEditablePath:q});!G.active&&!es.current||(_("aiFieldLoading",G),Wo.current=G,es.current=G.active)},[jn,wi,ns,B,q]),E.useEffect(()=>{if(!jn)return;const _=window.setInterval(()=>{const G=Wo.current;G!=null&&G.active&&Oi.current("aiFieldLoading",G)},1200);return()=>window.clearInterval(_)},[jn]),E.useEffect(()=>{B&&Zt.postToSite("highlightBlock",{blockId:B,editablePath:q??null})},[B,q]),E.useEffect(()=>{Ge.clearFieldAiContext()},[B]),E.useEffect(()=>{B||Le(null)},[B]),E.useEffect(()=>{tt(!1)},[je]),E.useEffect(()=>{const _=()=>Le(null);return window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[]);const ef=PG(),La=E.useMemo(()=>{if(!ef||!je||!$e||!B||typeof window>"u"||window.innerWidth<=1040)return null;const _=Zt.iframeRef.current;if(!_)return null;const G=_.getBoundingClientRect(),se=380,Ce=36,Me=26,Ue=8,et=G.top+je.top*Qi;if(et+je.height*Qi<G.top||et>G.bottom)return null;const or=et+Ue-(Ce-Me)/2;let Cn=G.left+(je.left+je.width)*Qi-Ce-Ue;return Cn=Math.max(G.left+Ue,Math.min(Cn,G.right-Ce-Ue)),{top:or,left:Cn,width:se}},[je,$e,B,Zt.iframeRef,Qi]);E.useEffect(()=>{La&&ze&&requestAnimationFrame(()=>{var _,G;(G=(_=_s.current)==null?void 0:_.querySelector("textarea"))==null||G.focus()})},[!!La,ze]);const py=E.useCallback((_,G,se,Ce)=>{var or;if(!B||!F)return;const Ue=((or=Au()[F])==null?void 0:or.displayName)??F;V(_);const et=hS(se,G,F,Ce),dn={id:`field-ai-${Date.now()}`,role:"assistant",text:`Editing: ${Ue} → ${G}`,fieldAiContext:{blockId:B,blockType:F,fieldPath:_,fieldLabel:G,blockDisplayName:Ue},suggestions:et};Ge.setFieldAiContext(dn)},[B,F]),my=E.useCallback((_,G,se)=>{const Ce=hS(G,_,"Page",se),Me={id:`field-ai-${Date.now()}`,role:"assistant",text:`Editing: Page → ${_}`,fieldAiContext:{blockId:"__page__",blockType:"__page__",fieldPath:_,fieldLabel:_,blockDisplayName:"Page"},suggestions:Ce};Ge.setFieldAiContext(Me)},[]),Pp=E.useCallback((_,G,se,Ce,Me)=>{var or;if(!B||!F)return;const et=((or=Au()[F])==null?void 0:or.displayName)??F;V(_);const dn={id:`field-ai-${Date.now()}`,role:"assistant",text:`Editing: ${et} → ${G}`,fieldAiContext:{blockId:B,blockType:F,fieldPath:_,fieldLabel:G,blockDisplayName:et}};Ge.setFieldAiContext(dn),Ge.submitChat(Me)},[B,F]),gy=E.useCallback((_,G,se,Ce)=>{V(_);const Me={id:`field-ai-${Date.now()}`,role:"assistant",text:`Editing: Page → ${_}`,fieldAiContext:{blockId:"__page__",blockType:"__page__",fieldPath:_,fieldLabel:_,blockDisplayName:"Page"}};Ge.setFieldAiContext(Me),Ge.submitChat(Ce)},[]);E.useEffect(()=>{Ge.refreshRouteSlugs()},[n,r,e.siteRegistryChecked]);const tf=_=>{const se=Pt.current,Ce=Bn.current;if(!se||!Ce)return Math.max(56,_);const Me=120,Ue=10,et=Ce.offsetTop,dn=Math.max(56,se.clientHeight-et-Ue-Me);return Math.min(dn,Math.max(56,_))},by=E.useCallback(_=>{Ct(G=>{const se=tf(_);return se===G?G:se})},[]);E.useEffect(()=>{const _=se=>{const Ce=li.current;if(Ce){const Ue=se.clientY-Ce.y,et=tf(Ce.composerHeight-Ue);Ct(et)}const Me=Fn.current;if(Me){const Ue=se.clientX-Me.x;Me.target==="chat"?jt(Ak(Me.width+Ue)):Zr(Nk(Me.width-Ue))}},G=()=>{const se=!!Fn.current;li.current=null,Fn.current=null,document.body.style.userSelect="",se&&document.body.classList.remove("panel-resizing")};return window.addEventListener("pointermove",_),window.addEventListener("pointerup",G),()=>{window.removeEventListener("pointermove",_),window.removeEventListener("pointerup",G),document.body.style.userSelect="",document.body.classList.remove("panel-resizing")}},[]),E.useEffect(()=>{const _=()=>{Ct(G=>tf(G)),jt(G=>G&&Ak(G)),Zr(G=>G&&Nk(G))};return window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[jt,Zr]),E.useEffect(()=>{if(!St)return;const _=G=>{G.key==="Escape"&&!jr&&Ci(null)};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[St,jr]),E.useEffect(()=>{St!=null&&St.options.length?xn(St.options[0].id):xn(null)},[St]),E.useEffect(()=>{at||At("")},[at]),E.useEffect(()=>{if(!at)return;const _=G=>{G.key==="Escape"&&!vt&&Et(null)};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[at,vt]);const nf=fr?/failed|error/i.test(fr):!1,[zp,Lp]=E.useState(0),yy=Lr==null?void 0:Lr.stage;E.useEffect(()=>{if(Lp(0),!jn)return;const _=window.setInterval(()=>Lp(G=>G+1),1e3);return()=>window.clearInterval(_)},[jn,fr,yy]);const Bp=jn&&!nf&&zp>=5?` · ${zp}s`:"",xy=(Lr?Lr.stage:fr??(ro>0?t("stream.shapingUpdate"):t("stream.gettingReady")))+Bp,dc=(Lr?Lr.stage:fr??(ro>0?t("stream.updating"):t("stream.thinking")))+Bp,Ei=(fr==null?void 0:fr.match(/reconnecting(?:\s+agent\s+stream)?(?:\s+\((\d+)\/(\d+)\))?/i))??null,Fp=Ei!=null&&Ei[1]?Number(Ei[1]):null,rf=Ei!=null&&Ei[2]?Number(Ei[2]):null,nu=Ei?Fp&&rf?`Reconnect ${Fp}/${rf}`:"Reconnecting":null,sf=`field_draft ${gt.eventsPerSecond}/s · chars ${gt.charsPerSecond}/s · lag ${gt.typingLagChars}`,$p={"--composer-height":`${qt}px`},So=Ve==="properties",Ms=Ve==="history",of=Ve==="health",Up=E.useCallback(()=>{W(void 0),K(void 0),ht("chat")},[]);E.useLayoutEffect(()=>{const _=Yr.current,G=Zt.iframeRef.current;if(!_||!G)return;const se=Ue=>{var rs;if(Ue?G.classList.remove("preview-iframe-no-transition"):G.classList.add("preview-iframe-no-transition"),!So){G.style.removeProperty("width"),G.style.removeProperty("height"),G.style.removeProperty("transform"),Go(Ds=>Ds===1?Ds:1);return}const et=_.offsetWidth,dn=((rs=br.current)==null?void 0:rs.offsetWidth)??0;if(et<=0||dn<=0)return;const or=et+dn,Cn=et/or;G.style.width=`${or}px`,G.style.height=`${100/Cn}%`,G.style.transform=`scale(${Cn})`,Go(Ds=>Math.abs(Ds-Cn)<5e-4?Ds:Cn)};se(!0);const Ce=new ResizeObserver(()=>se(!1)),Me=window.setTimeout(()=>{Ce.observe(_);const Ue=br.current;Ue&&Ce.observe(Ue)},240);return()=>{window.clearTimeout(Me),G.classList.remove("preview-iframe-no-transition"),Ce.disconnect()}},[So,Zt.iframeRef]);const vy={...on?{"--chat-width":`${on}px`}:{},...Es?{"--props-width":`${Es}px`}:{}},af=Ts.some(_=>_.role==="user"),lf=E.useCallback(_=>{const G=[];_.text&&G.push(_.text),_.status&&!_.canUndo&&_.status!=="needs_clarification"&&_.status!=="plan_ready"&&G.push(`status: ${_.status}`);const se=(_.changes??[]).filter(Ce=>!W4(_.text,Ce));if(se.length>0&&G.push(`changes: ${se.join(`
|
|
749
|
+
`).length)),readOnly:!m.editable,value:j,onFocus:m.editable?P:void 0,onBlur:m.editable?R:void 0,onChange:m.editable?W=>{x(W.target.value),w(Bce(W.target.value))}:void 0})})]});if(t.kind==="headingLevel"){const W=(r&&lj[r])??"h2",K=g&&/^h[1-6]$/.test(g)?g:"";return p.jsxs("div",{className:"property-field",children:[p.jsx("div",{className:"property-field-label",children:p.jsx("span",{children:D})}),p.jsxs("select",{className:"property-field-input property-field-select",value:K,onChange:Y=>i(Y.target.value),children:[p.jsxs("option",{value:"",children:["Auto (",W.toUpperCase(),")"]}),["h1","h2","h3","h4","h5","h6"].map(Y=>p.jsx("option",{value:Y,children:Xve[Y]},Y))]})]})}if(t.kind==="image")return p.jsxs("div",{className:"property-field",children:[p.jsx("div",{className:"property-field-label",children:p.jsx("span",{children:D})}),p.jsx("div",{className:"property-field-image-url",title:g,children:g||"(empty)"})]});if(t.kind==="enum"&&t.options){const W=t.options.includes(g);return p.jsxs("div",{className:M,ref:A,children:[p.jsx("div",{className:"property-field-label",children:p.jsx("span",{children:D})}),p.jsxs("select",{className:"property-field-input property-field-select",value:g,onChange:K=>i(K.target.value),children:[!W&&p.jsx("option",{value:g,children:g||"—"}),t.options.map(K=>p.jsx("option",{value:K,children:K},K))]})]})}if(t.kind==="boolean"){const W=g==="true"||g==="1";return p.jsx("div",{className:`${M} property-field--inline`,ref:A,children:p.jsxs("div",{className:"property-field-label",children:[p.jsxs("span",{children:[D,t.required&&p.jsx("span",{className:"property-field-required",children:"*"})]}),p.jsx("button",{type:"button",role:"switch","aria-checked":W,"aria-label":D,className:`property-field-switch${W?" is-on":""}`,onClick:()=>i(W?"false":"true"),children:p.jsx("span",{className:"property-field-switch-knob","aria-hidden":"true"})})]})})}if(t.kind==="color")return p.jsxs("div",{className:"property-field",children:[p.jsx("div",{className:"property-field-label",children:p.jsx("span",{children:D})}),p.jsx("input",{type:"color",className:"property-field-color",value:g||"#000000",onChange:W=>i(W.target.value)})]});if(t.kind==="html")return p.jsxs("div",{className:M,ref:A,children:[p.jsx("div",{className:"property-field-label",children:p.jsxs("span",{children:[D,t.required&&p.jsx("span",{className:"property-field-required",children:"*"})]})}),p.jsx("div",{className:"property-field-input-wrap",children:p.jsx(Qve,{value:g,onCommit:W=>i(W),onFocus:P,onBlur:R,inline:t.inline})})]});if(t.kind==="richtext")return n!==null&&typeof n=="object"?p.jsxs("div",{className:M,ref:A,children:[p.jsx("div",{className:"property-field-label",children:p.jsxs("span",{children:[D,t.required&&p.jsx("span",{className:"property-field-required",children:"*"})]})}),p.jsx("div",{className:"property-field-input-wrap",children:p.jsx(JL,{value:n,onChange:W=>w(W),onFocus:P,onBlur:R,decorators:t.decorators,inline:t.inline})})]}):p.jsxs("div",{className:M,ref:A,children:[p.jsx("div",{className:"property-field-label",children:p.jsxs("span",{children:[D,t.required&&p.jsx("span",{className:"property-field-required",children:"*"})]})}),p.jsx("div",{className:`property-field-input-wrap${u?" property-field-input-wrap--ai-loading":""}`,children:p.jsx($ve,{value:g,onChange:W=>{x(W),w(W)},onFocus:P,onBlur:R,trailing:s?p.jsx(fp,{variant:"toolbar",onClick:s,fieldKind:t.kind,fieldLabel:t.label??e,blockType:r??"",currentValue:g,onQuickAction:o,onCustomPrompt:s,aiLoading:u}):null})})]});const B=t.multiline===!0,F=t.kind==="number"?"number":t.kind==="url"?"url":"text",q={value:j,onFocus:P,onChange:W=>{x(W.target.value),w(W.target.value)},onBlur:R};return p.jsxs("div",{className:M,ref:A,children:[p.jsx("div",{className:"property-field-label",children:p.jsxs("span",{children:[D,t.required&&p.jsx("span",{className:"property-field-required",children:"*"})]})}),p.jsxs("div",{className:`property-field-input-wrap${u?" property-field-input-wrap--ai-loading":""}`,children:[B?p.jsx("textarea",{className:"property-field-textarea",rows:3,...q}):p.jsx("input",{type:F,className:"property-field-input",...q}),s?p.jsx(fp,{onClick:s,fieldKind:t.kind,fieldLabel:t.label??e,blockType:r??"",currentValue:g,onQuickAction:o,onCustomPrompt:s,aiLoading:u}):null]})]})}function tke({slug:e,navLabel:t,onNavLabelChange:n,onAiAssist:r,onAiQuickAction:i,aiLoading:s,fieldShimmer:o}){const{t:a}=Nn(),[u,d]=E.useState(t),[f,m]=E.useState(!1),g=f?u:t,{debouncedCommit:y,flushCommit:x}=Yd(v=>n(e,v),400);return p.jsx(uy,{id:"page:nav",title:a("propertyPanel.navigation"),count:1,children:p.jsxs("div",{className:"property-field",children:[p.jsx("div",{className:"property-field-label",children:p.jsx("span",{children:a("propertyPanel.navLabel")})}),p.jsxs("div",{className:`property-field-input-wrap${o?" property-field-input-wrap--ai-loading":""}`,children:[p.jsx("input",{type:"text",className:"property-field-input",placeholder:a("propertyPanel.navPlaceholder"),value:g,onFocus:()=>{d(t),m(!0)},onChange:v=>{d(v.target.value),y(v.target.value)},onBlur:()=>{m(!1),x()}}),r?p.jsx(fp,{onClick:()=>r("Nav label","text",t),fieldKind:"text",fieldLabel:"Nav label",blockType:"Page",currentValue:t,onQuickAction:i?v=>i("Nav label","text",t,v):void 0,onCustomPrompt:()=>r("Nav label","text",t),aiLoading:o}):null]})]})})}function nke({pageMeta:e,onPageMetaChange:t,onAiAssist:n,onAiQuickAction:r,aiLoading:i,aiLoadingPath:s}){const{t:o}=Nn();return p.jsxs(uy,{id:"page:seo",title:o("propertyPanel.seo"),count:3,children:[p.jsx(lk,{label:o("propertyPanel.seoTitle"),fieldKind:"text",blockType:"Page",value:e.title??"",placeholder:o("propertyPanel.seoTitlePlaceholder"),multiline:!0,autosizeRows:{min:2,max:2},recommendedMax:60,onCommit:a=>t("title",a),onAiAssist:n?()=>n("SEO title","text",e.title??""):void 0,onAiQuickAction:r?a=>r("SEO title","text",e.title??"",a):void 0,aiLoading:i,fieldShimmer:i===!0&&s==="SEO title"}),p.jsx(lk,{label:o("propertyPanel.metaDescription"),fieldKind:"richtext",blockType:"Page",value:e.description??"",placeholder:o("propertyPanel.metaDescPlaceholder"),multiline:!0,autosizeRows:{min:3,max:6},recommendedMax:160,onCommit:a=>t("description",a),onAiAssist:n?()=>n("Meta description","richtext",e.description??""):void 0,onAiQuickAction:r?a=>r("Meta description","richtext",e.description??"",a):void 0,aiLoading:i,fieldShimmer:i===!0&&s==="Meta description"}),p.jsx(lk,{label:o("propertyPanel.ogImage"),fieldKind:"url",blockType:"Page",value:e.ogImage??"",placeholder:"https://...",onCommit:a=>t("ogImage",a)})]})}function lk({label:e,fieldKind:t,blockType:n,value:r,placeholder:i,multiline:s,autosizeRows:o,recommendedMax:a,onCommit:u,onAiAssist:d,onAiQuickAction:f,aiLoading:m,fieldShimmer:g}){const[y,x]=E.useState(r),[v,S]=E.useState(!1),w=E.useRef(null),T=v?y:r,{debouncedCommit:A,flushCommit:M}=Yd(u,400),j=s===!0&&o!=null,D=E.useCallback(()=>{if(!j||!w.current||!o)return;const B=w.current,F=getComputedStyle(B),q=Number.parseFloat(F.lineHeight),W=Number.parseFloat(F.fontSize)||15,K=Number.isFinite(q)?q:W*1.2,Y=(Number.parseFloat(F.paddingTop)||0)+(Number.parseFloat(F.paddingBottom)||0),V=(Number.parseFloat(F.borderTopWidth)||0)+(Number.parseFloat(F.borderBottomWidth)||0),O=o.min*K+Y+V,U=o.max*K+Y+V;B.style.height="0px";const Q=B.scrollHeight,le=Math.max(O,Math.min(U,Q));B.style.height=`${le}px`,B.style.overflowY=Q>U?"auto":"hidden"},[j,o]);E.useLayoutEffect(()=>{D()},[D,T,v,r]),E.useEffect(()=>{if(!j)return;const B=()=>D();return window.addEventListener("resize",B),()=>window.removeEventListener("resize",B)},[j,D]);const P={placeholder:i,value:T,onFocus:()=>{x(r),S(!0)},onChange:B=>{x(B.target.value),A(B.target.value)},onBlur:()=>{S(!1),M()}},R=(v?y:r).length;return p.jsxs("div",{className:"property-field",children:[p.jsx("div",{className:"property-field-label",children:p.jsx("span",{children:e})}),p.jsxs("div",{className:`property-field-input-wrap${g?" property-field-input-wrap--ai-loading":""}`,children:[s?p.jsx("textarea",{ref:j?w:void 0,className:`property-field-textarea${j?" property-field-textarea--autosize":""}`,rows:(o==null?void 0:o.min)??3,...P}):p.jsx("input",{type:"text",className:"property-field-input",...P}),d?p.jsx(fp,{onClick:d,fieldKind:t,fieldLabel:e,blockType:n,currentValue:v?y:r,onQuickAction:f,onCustomPrompt:d,aiLoading:g}):null]}),a!=null&&p.jsxs("span",{className:`property-field-char-count${R>a?" property-field-char-count--over":""}`,children:[R," / ",a]})]})}class uk extends E.Component{constructor(){super(...arguments);Ee(this,"state",{error:null});Ee(this,"reset",()=>{var n,r;(r=(n=this.props).onReset)==null||r.call(n),this.setState({error:null})})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,r){var i,s;console.error("[editor] Uncaught error in component tree:",n,r.componentStack),(s=(i=this.props).onError)==null||s.call(i,n,r)}render(){return this.state.error?p.jsxs("div",{style:this.props.style,className:"flex flex-col items-center justify-center gap-3 p-6 text-center text-sm text-muted-foreground h-full",children:[p.jsx("p",{className:"font-medium text-foreground",children:this.props.fallbackLabel??"Something went wrong"}),p.jsx("p",{className:"max-w-xs opacity-70 text-xs",children:this.state.error.message}),p.jsx("button",{type:"button",onClick:this.reset,className:"rounded-md border px-3 py-1.5 text-xs hover:bg-accent transition-colors",children:"Try again"})]}):this.props.children}}function rke({siteId:e,orchestratorUrl:t,hostedIds:n,siteOwnOrchestrator:r}){const{t:i}=Nn(),s=()=>{yce(e),window.location.href=xce(window.location.href)},o=()=>{r&&(bce(e,r),window.location.reload())};return r?p.jsxs("div",{className:"orchestrator-mismatch",role:"alert",children:[p.jsxs("div",{className:"orchestrator-mismatch-body",children:[p.jsx("strong",{children:i("orchestratorMismatch.ownTitle")}),p.jsx("span",{children:i("orchestratorMismatch.ownDetail",{orchestrator:t,siteOrchestrator:r})})]}),p.jsx("button",{type:"button",className:"orchestrator-mismatch-action",onClick:o,children:i("orchestratorMismatch.useSiteOwn")})]}):p.jsxs("div",{className:"orchestrator-mismatch",role:"alert",children:[p.jsxs("div",{className:"orchestrator-mismatch-body",children:[p.jsx("strong",{children:i("orchestratorMismatch.title")}),p.jsx("span",{children:n.length>0?i("orchestratorMismatch.detailHosts",{orchestrator:t,hosted:n.join(", ")}):i("orchestratorMismatch.detail",{orchestrator:t})})]}),p.jsx("button",{type:"button",className:"orchestrator-mismatch-action",onClick:s,children:i("orchestratorMismatch.useDefault")})]})}const Ng=3e3;function ike(e){const[t,n]=E.useState({status:"loading",blocks:[],manifest:null});E.useEffect(()=>{let i=!0,s=null;const o=async()=>{try{const u=await fetch(`${e||Vd}/api/editor/blocks`);if(!u.ok){if(!i)return;n({status:"degraded",blocks:[],manifest:null,reason:`Manifest endpoint returned ${u.status}`}),s=setTimeout(()=>{i&&o()},Ng);return}const d=await u.json(),f=dj.safeParse(d);if(!f.success){if(!i)return;n({status:"degraded",blocks:[],manifest:null,reason:"Manifest response shape is invalid"}),s=setTimeout(()=>{i&&o()},Ng);return}const m=mj(f.data.blocks);if(m){if(!i)return;n({status:"degraded",blocks:[],manifest:null,reason:m}),s=setTimeout(()=>{i&&o()},Ng);return}if(!i)return;n({status:"ready",blocks:f.data.blocks,version:f.data.version,manifest:f.data})}catch(a){if(!i)return;n({status:"degraded",blocks:[],manifest:null,reason:a instanceof Error?a.message:"Manifest fetch failed"}),s=setTimeout(()=>{i&&o()},Ng)}};return o(),()=>{i=!1,s&&clearTimeout(s)}},[e]);const r=E.useMemo(()=>{const i=new Map;for(const s of t.blocks)i.set(s.type,s);return i},[t.blocks]);return{...t,byType:r,siteCapabilities:{allowStructuralEdits:t.status==="ready",manifestStatus:t.status,reason:t.reason,manifestVersion:t.version,blockCount:t.blocks.length,checkedAt:new Date().toISOString()},allowStructuralEdits:t.status==="ready"}}function ske(e){const[t,n]=E.useState(void 0);return E.useEffect(()=>{if(Hk)return;let r=!1;return gce(e).then(i=>{r||!i||i.replace(/\/+$/,"")!==Be.replace(/\/+$/,"")&&n(i)}),()=>{r=!0}},[e]),t}function oke(e){const t=e==null?void 0:e.trim().toLowerCase();return t?t==="text"?"text":t==="legacy"||t==="sparkle"||t==="dots"||t==="sparkle-dots"?"legacy":null:null}function ake(){const e=oke(Ii().VITE_STREAMING_INDICATOR_STYLE);return e||"text"}const WS={active:!1,scope:"block",blockId:"",editablePath:""},lke="__page__";function uke(e){var t;for(let n=e.length-1;n>=0;n--)if(e[n].role==="user")return((t=e[n-1])==null?void 0:t.fieldAiContext)??null;return null}function cke(e){const{streamScope:t,fieldContext:n,focusBlockId:r,activeBlockId:i,activeEditablePath:s}=e;if(n)return n.blockId===lke?WS:{active:!0,scope:"block",blockId:n.blockId,editablePath:n.fieldPath};if(t==="pending")return WS;if(t&&t.scope!=="block")return{active:!0,scope:"page",blockId:r??"",editablePath:""};const o=r??((t==null?void 0:t.blockId)||null)??i;return o?{active:!0,scope:"block",blockId:o,editablePath:o===i?s??"":""}:{active:!0,scope:"page",blockId:"",editablePath:""}}const dke=/^[a-z]{2}(?:-[a-z0-9]{2,8})?$/i,Il="default",fke=2;let sh;function hke(e){if(!dke.test(e))return!1;if(sh===void 0)try{sh=new Intl.DisplayNames(["en"],{type:"language",fallback:"none"})}catch{sh=null}if(!sh)return!1;try{return typeof sh.of(e)=="string"}catch{return!1}}function cy(e){return e.split("/").filter(Boolean)}function tc(e){const t=cy(e);return t.length===0?"/":`/${t.join("/")}`}function pke(e){const t={},n=[];for(const u of e){const d=cy(u)[0];if(d&&hke(d)){const f=d.toLowerCase();(t[f]||(t[f]=[])).push(u)}else n.push(u)}const r=Object.keys(t).sort();if(r.length<2)return null;const i=new Map;for(const u of r)for(const d of new Set(t[u].map(f=>gC(f,u))))i.set(d,(i.get(d)??0)+1);if(![...i.values()].some(u=>u>=2))return null;const o=n.filter(u=>i.has(tc(u))).length>=fke,a=o?[]:n;o&&(t[Il]=n,r.unshift(Il));for(const u of r){const d=u===Il?"/":`/${u}`;t[u].sort((f,m)=>f===d?-1:m===d?1:0)}return{locales:r,byLocale:t,shared:a}}function t8(e,t){var i;const n=(i=cy(e)[0])==null?void 0:i.toLowerCase();if(n&&t.byLocale[n])return n;const r=t.byLocale[Il];return r!=null&&r.some(s=>tc(s)===tc(e))?Il:void 0}function gC(e,t){var i;if(!t||t===Il)return tc(e);const n=cy(e);if(((i=n[0])==null?void 0:i.toLowerCase())!==t.toLowerCase())return tc(e);const r=n.slice(1);return r.length===0?"/":`/${r.join("/")}`}function mke(e,t){return`${G4(gC(e,t))} (${e})`}function gke(e,t,n){const r=n.byLocale[t];if(!r||r.length===0)return e;const i=gC(e,t8(e,n)),s=t===Il?i:i==="/"?`/${t}`:`/${t}${i}`;return r.find(a=>tc(a)===tc(s))??r[0]}function bke(e){try{const t=new Intl.DisplayNames([e],{type:"language"}).of(e);if(t&&t.toLowerCase()!==e.toLowerCase())return t.charAt(0).toUpperCase()+t.slice(1)}catch{}return e.toUpperCase()}const sR=ake(),yke=!1,xke=dd||yke,vke=wG(),kke=E.lazy(()=>WB(()=>import("./PuckPrototypeRoute-CDznIHdj.js").then(e=>e.P),__vite__mapDeps([0,1])).then(e=>({default:e.PuckPrototypeRoute}))),Ske=new Set(["/editor/puck","/editor/puck/"]),wke=3e4,n8="site-reachable-v1:",Cke=5e3;function r8(e){if(typeof sessionStorage>"u")return null;try{const t=sessionStorage.getItem(n8+e);if(!t)return null;const n=JSON.parse(t);return Date.now()-n.ts>wke?null:n.ok}catch{return null}}function oR(e,t){if(!(typeof sessionStorage>"u"))try{sessionStorage.setItem(n8+e,JSON.stringify({ok:t,ts:Date.now()}))}catch{}}function Eke({name:e,origin:t,statusClass:n,active:r,dimmed:i,onSelect:s}){const o=t.replace(/^https?:\/\//,"");return p.jsxs("button",{type:"button",role:"menuitem",className:`site-switcher-item${r?" is-active":""}${i?" is-dimmed":""}`,onClick:s,title:t,children:[p.jsx("span",{className:`site-switcher-item-dot site-switcher-item-dot-${n}`,"aria-hidden":"true"}),p.jsxs("span",{className:"site-switcher-item-body",children:[p.jsx("span",{className:"site-switcher-item-name",children:e}),p.jsx("span",{className:"site-switcher-item-origin",children:o})]}),r?p.jsx(Fd,{size:12,"aria-hidden":"true"}):null]})}function aR(e){if(typeof sessionStorage>"u")return null;const t=new Set;let n=!1;for(const r of e){const i=r8(r);i!==null&&(n=!0,i&&t.add(r))}return n?t:null}function _ke(e,t){if(e===t)return!0;if(!e||!t||e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Tke(){const e=typeof window<"u"?window.location.pathname:"/",t=e==="/"||e==="/editor"||e==="/editor/",n=Ske.has(e),r=e==="/sites"||e==="/sites/";ce(d=>d.chatDarkMode);const i=ce(d=>d.setChatDarkMode),s=E.useMemo(()=>Pw(),[]),o=E.useMemo(()=>n6(),[]),a=E.useRef(!1);a.current||(a.current=!0,$G({sessionId:s,siteId:o}));const u=kce(o,s);return E.useEffect(()=>{if(typeof window>"u")return;const d=window.matchMedia("(prefers-color-scheme: dark)"),f=m=>{gw()===null&&i(m.matches,{persist:!1})};return d.addEventListener("change",f),()=>d.removeEventListener("change",f)},[i]),n?p.jsx(E.Suspense,{fallback:p.jsx("div",{style:{height:"100dvh",display:"grid",placeItems:"center"},children:"Loading prototype…"}),children:p.jsx(kke,{})}):r?p.jsx(ON,{sites:u,session:s}):t?p.jsx(Nke,{sites:u}):p.jsx(ON,{sites:u,session:s})}function Ake(e){return e.split(".").map(t=>{const n=t.match(/^([a-zA-Z_]+)\[(\d+)\]$/);return n?`${lR(n[1])} ${Number(n[2])+1}`:lR(t)}).join(" · ")}function lR(e){const n=e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\s*url\s*$/i,"").trim();return n?n.charAt(0).toUpperCase()+n.slice(1):e}function Nke({sites:e}){var uf,cf,fc;const{t}=Nn(),n=Ui(),r=Hi(),i=ce(_=>_.chatDarkMode),s=ce(_=>_.chatThemePreference),o=ce(_=>_.setChatThemePreference),{activeSiteConfig:a}=e,u=E.useMemo(()=>Pu(a),[a]),d=ike(u),f=typeof window<"u"?window.location.origin:"http://localhost:4100",m=ske(u),g=e.siteHosting==="notHosted"||m!=null,y=ce(_=>_.slug),x=ce(_=>_.setSlug),v=ce(_=>_.availableSlugs);ce(_=>_.setAvailableSlugs);const S=ce(_=>_.isLoadingSlugs),w=ce(_=>_.modelKey),T=ce(_=>_.setModelKey),A=ce(_=>_.provider),M=ce(_=>_.setProvider),j=ce(_=>_.availableProviders),D=ce(_=>_.setAvailableProviders),[P,R]=E.useState(""),B=ce(_=>_.activeBlockId),F=ce(_=>_.activeBlockType),q=ce(_=>_.activeEditablePath),W=_=>ce.getState().setActiveBlock(_),K=_=>{const G=ce.getState();G.setActiveBlock(G.activeBlockId,_)},Y=(_,G)=>ce.getState().setActiveBlock(_,G),V=ce(_=>_.setActiveEditablePath),O=ce(_=>_.useStreaming),U=ce(_=>_.setUseStreaming),Q=ce(_=>_.autoScrollTrackingEnabled),le=ce(_=>_.setAutoScrollTrackingEnabled),I=ce(_=>_.autoOpenPropertiesEnabled),$=ce(_=>_.setAutoOpenPropertiesEnabled),[X,z]=E.useState(!1),[Z,oe]=E.useState(vke),ee=E.useCallback(_=>{oe(_);try{window.localStorage.setItem(Ek,_?"1":"0")}catch{}},[]),ne=E.useMemo(()=>!dd||new URLSearchParams(window.location.search).has("dev"),[]),Ae=ne&&Z,[_e,Oe]=E.useState(!1),[he,xe]=E.useState(0),Pe=E.useCallback(()=>xe(_=>_+1),[]),ie=ce(_=>_.showSettingsModal),qe=ce(_=>_.setShowSettingsModal),Ke=ce(_=>_.showDebugDetails),bt=ce(_=>_.setShowDebugDetails),qt=ce(_=>_.composerHeight),Ct=ce(_=>_.setComposerHeight),at=ce(_=>_.addBlockPicker),Et=ce(_=>_.setAddBlockPicker),Ye=ce(_=>_.addBlockSearch),At=ce(_=>_.setAddBlockSearch),vt=ce(_=>_.isAddingBlock),lt=ce(_=>_.setIsAddingBlock),fe=ce(_=>_.copiedDebugEntryId),Te=ce(_=>_.setCopiedDebugEntryId),Fe=ce(_=>_.feedbackNoteEntryId),nt=ce(_=>_.setFeedbackNoteEntryId),Dt=ce(_=>_.feedbackNoteText),cn=ce(_=>_.setFeedbackNoteText),Nr=ce(_=>_.selectedVariationId),xn=ce(_=>_.setSelectedVariationId),Rt=ce(_=>_.imagePickerTarget),zn=ce(_=>_.setImagePickerTarget),tn=Rt!==null,Mr=ce(_=>_.backendFeatures),Dr=ce(_=>_.setBackendFeatures),ve=ce(_=>_.setBackendSite),$e=ce(_=>_.selectionModeEnabled),ge=ce(_=>_.setSelectionModeEnabled),je=ce(_=>_.anchorRect),Le=ce(_=>_.setAnchorRect),ze=ce(_=>_.anchoredExpanded),tt=ce(_=>_.setAnchoredExpanded),Ve=ce(_=>_.activeTab),ht=ce(_=>_.setActiveTab),[Ft,Wt]=E.useState(!1),[vn,Ln]=E.useState(!1),rr=E.useRef(null);E.useEffect(()=>{if(!vn)return;const _=se=>{rr.current&&!rr.current.contains(se.target)&&Ln(!1)},G=se=>{se.key==="Escape"&&Ln(!1)};return document.addEventListener("mousedown",_),document.addEventListener("keydown",G),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",G)}},[vn]);const[Yi,Js]=E.useState(()=>aR(e.siteList.map(_=>_.id))),Gr=E.useCallback(_=>{Js(G=>_ke(G,_)?G:_)},[]);E.useEffect(()=>{if(!vn)return;Gr(aR(e.siteList.map(se=>se.id)));let _=!0;return(async()=>{let se=!0;const Ce=await Promise.all(e.siteList.map(async Me=>{const Ue=r8(Me.id);if(Ue!==null)return{id:Me.id,ok:Ue};se=!1;const et=Pu(Me);try{const dn=await fetch(`${et}/api/editor/blocks?siteId=${encodeURIComponent(Me.id)}`,{signal:AbortSignal.timeout(2500)});return oR(Me.id,dn.ok),{id:Me.id,ok:dn.ok}}catch{return oR(Me.id,!1),{id:Me.id,ok:!1}}}));_&&!se&&Gr(new Set(Ce.filter(Me=>Me.ok).map(Me=>Me.id)))})(),()=>{_=!1}},[vn,e.siteList,Gr]);const Wr=E.useMemo(()=>{const _=Yi===null;return e.siteList.map(G=>{const se=_||G.id===r||Yi.has(G.id);return{site:G,origin:Pu(G),online:se,probing:_}}).sort((G,se)=>G.site.id===r?-1:se.site.id===r?1:G.online!==se.online?G.online?-1:1:G.site.name.localeCompare(se.site.name))},[Yi,e.siteList,r]),{onlineEntries:Xs,activeEntry:Rr}=E.useMemo(()=>({onlineEntries:Wr.filter(_=>_.online),activeEntry:Wr.find(_=>_.site.id===r)}),[Wr,r]),Pt=E.useRef(null),Bn=E.useRef(null),zr=E.useRef(!0),ws=E.useRef(!1),Cs=E.useRef(null),vi=E.useRef(void 0),gr=E.useRef(!1),Ji=E.useRef(null),Xi=E.useRef(!1),ai=E.useRef(0),li=E.useRef(null),Fn=E.useRef(null),on=ce(_=>_.chatWidth),jt=ce(_=>_.setChatWidth),Es=ce(_=>_.propsWidth),Zr=ce(_=>_.setPropsWidth),br=E.useRef(null),Yr=E.useRef(null),[Qi,Go]=E.useState(1),_s=E.useRef(null),Wo=E.useRef(null),es=E.useRef(!1),ts=E.useRef(null),ui=E.useRef(!1);E.useEffect(()=>{if(!ui.current&&!(S||v.length===0)){if(y!=="/"||v.includes("/")){ui.current=!0;return}ui.current=!0,gr.current=!1,x(v[0])}},[v,S,y,x]);const ir=E.useMemo(()=>{const _=Array.from(new Set([...v,y].filter(Boolean)));return _.includes("/")?["/",..._.filter(G=>G!=="/")]:_},[v,y]),er=E.useMemo(()=>pke(ir),[ir]),ci=er?t8(y,er)??er.locales[0]:void 0,Qs=E.useMemo(()=>!er||!ci?ir:er.byLocale[ci]??[],[er,ci,ir]),Zo=E.useMemo(()=>{if(!d.allowStructuralEdits)return[];if(d.blocks.length>0)return d.blocks.map(G=>({type:G.type,label:G.displayName??G.type,category:"content"})).sort((G,se)=>G.label.localeCompare(se.label));const _=Au();return[...xk].map(G=>{var se,Ce;return{type:G,label:((se=_[G])==null?void 0:se.displayName)??G,category:((Ce=_[G])==null?void 0:Ce.category)??"content"}}).sort((G,se)=>G.label.localeCompare(se.label))},[d.allowStructuralEdits,d.blocks]),yo=E.useMemo(()=>{const _=Ye.trim().toLowerCase(),G=_?Zo.filter(Me=>Me.label.toLowerCase().includes(_)||Me.type.toLowerCase().includes(_)):Zo,se=new Map;for(const Me of G){const Ue=Me.category||"content",et=se.get(Ue);et?et.push(Me):se.set(Ue,[Me])}const Ce=["content","layout","conversion","navigation","media"];return[...se.entries()].sort((Me,Ue)=>{const et=Ce.indexOf(Me[0]),dn=Ce.indexOf(Ue[0]),or=et===-1?Number.MAX_SAFE_INTEGER:et,Cn=dn===-1?Number.MAX_SAFE_INTEGER:dn;return or!==Cn?or-Cn:Me[0].localeCompare(Ue[0])}).map(([Me,Ue])=>({category:Me,options:Ue}))},[Ye,Zo]),eo=()=>{const _=Date.now();_-ai.current<1200||(ai.current=_,Ge.pushAssistantFromResult({status:"needs_clarification",summary:t("streamError.structuralDisabled"),changes:TP(d.reason)}))},yr=E.useRef(()=>{}),xr=E.useCallback(_=>{ce.getState().slug!==_&&(Xi.current=!0,x(_))},[x]),Ia=E.useMemo(()=>({onBlockClicked:(_,G,se,Ce,Me,Ue)=>{xr(_),Y(G,se),V(Ce),Le(G?Ue:null);const et=ce.getState();G?et.autoOpenPropertiesEnabled&&et.setActiveTab("properties"):et.setActiveTab("chat")},onRouteChanged:_=>{ce.getState().slug!==_&&Y(void 0,void 0),xr(_),V(void 0),Le(null),Oi.current("setSelectionMode",{enabled:ce.getState().selectionModeEnabled}),yr.current(_)},onBlockReordered:(_,G,se)=>{if(!d.allowStructuralEdits){eo();return}_!==y&&xr(_),V(void 0),Ge.reorderBlock(_,G,se)},onBlockDeleteRequested:(_,G)=>{if(!d.allowStructuralEdits){eo();return}_!==y&&xr(_),V(void 0),Ge.deleteBlock(_,G)},onBlockAddRequested:(_,G)=>{if(!d.allowStructuralEdits){eo();return}_!==y&&xr(_),!(!G.afterBlockId&&!G.beforeBlockId)&&Et({slug:_,afterBlockId:G.afterBlockId,beforeBlockId:G.beforeBlockId})},onListItemAddRequested:(_,G,se,Ce,Me)=>{if(!d.allowStructuralEdits){eo();return}_!==y&&xr(_),V(void 0),Ge.addListItem(_,G,se,Ce,Me)},onListItemRemoveRequested:(_,G,se,Ce,Me)=>{if(!d.allowStructuralEdits){eo();return}_!==y&&xr(_),V(void 0),Ge.removeListItem(_,G,se,Ce,Me)},onListItemMoveRequested:(_,G,se,Ce,Me,Ue)=>{if(!d.allowStructuralEdits){eo();return}_!==y&&xr(_),V(void 0),Ge.moveListItem(_,G,se,Ce,Me,Ue)},onOpenImagePicker:(_,G,se,Ce,Me)=>{zn({slug:_,blockId:G,editablePath:se,currentUrl:Ce,blockType:Me??(G===B?F:void 0)})},onEditBlockRequested:(_,G)=>{tt(!0)},onInlineTextCommitted:(_,G,se,Ce)=>{_!==y&&xr(_),se&&V(se),Ge.inlineEditCommit(_,G,se,Ce)},onIframeScrolled:()=>{Le(null),ce.getState().isLoading&&ce.getState().setAutoScrollSuppressed(!0)}}),[d.allowStructuralEdits,xr,y]),Oa=E.useCallback(async()=>{var _;try{const G=`${Be}/draft/pages?session=${encodeURIComponent(n)}&siteId=${encodeURIComponent(r)}&slug=${encodeURIComponent(y)}`,se=await fetch(G,{cache:"no-store"});if(!se.ok)return;const Me=((await se.json()).blocks??[]).find(Ue=>Ue.type==="Hero");if(!Me)return;Y(Me.id,Me.type),zn({slug:y,blockId:Me.id,editablePath:"imageUrl",currentUrl:typeof((_=Me.props)==null?void 0:_.imageUrl)=="string"?Me.props.imageUrl:void 0,blockType:Me.type})}catch{}},[n,r,y,zn]),Zt=Sce(y,Ia,u),Oi=E.useRef(Zt.postToSite);E.useEffect(()=>{Oi.current=Zt.postToSite},[Zt.postToSite]);const to=E.useCallback(_=>{const G=_??!$e;ge(G),Zt.postToSite("setSelectionMode",{enabled:G})},[$e,Zt]);E.useEffect(()=>{const _=G=>{G.key==="Escape"&&$e&&to(!1)};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[$e,to]),E.useEffect(()=>{if(Ve!=="history"&&Ve!=="health")return;const _=G=>{G.key==="Escape"&&ce.getState().setActiveTab("chat")};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[Ve]);const ki=E.useCallback((_,G)=>{(_==="draftUpdated"||_==="liveDraft")&&Pe(),Zt.postToSite(_,G)},[Zt,Pe]),no=E.useCallback((_,G,se,Ce,Me)=>(Pe(),Zt.postPatchToSite(_,G,se,Ce,Me)),[Zt,Pe]),Ge=Ace({activeSiteConfig:a,siteRegistryChecked:e.siteRegistryChecked,postToSite:ki,postPatchToSite:no,componentManifest:d.manifest,siteCapabilities:d.siteCapabilities,allowStructuralEdits:d.allowStructuralEdits,getBlockDefaultProps:_=>{var G;return((G=d.byType.get(_))==null?void 0:G.defaultProps)??null},onApplied:()=>{var _;(_=vi.current)==null||_.call(vi)},agentModeEnabled:Mr.agentMode??!1}),Ts=ce(_=>_.chatLog),xo=ce(_=>_.chatAttachments),Ql=ce(_=>_.setChatAttachments),jn=ce(_=>_.isLoading),fr=ce(_=>_.streamStatus),Si=ce(_=>_.streamingText),eu=ce(_=>_.streamingChanges),vo=ce(_=>_.streamSteps),ro=ce(_=>_.streamTokenCount),ns=ce(_=>_.latestStreamFocusBlockId),wi=ce(_=>_.streamScope),Lr=ce(_=>_.imageProgress),As=ce(_=>_.plannerBadgeState),[Yo,ft]=E.useState(!1),kt=ce(_=>_.setPlannerBadgeState),Se=ce(_=>_.pendingPlanId),St=ce(_=>_.variationModal),jr=ce(_=>_.isApplyingVariation),Ci=ce(_=>_.setVariationModal),di=ce(_=>_.continuationChainId),Br=ce(_=>_.fieldDraftDebugEnabled),it=ce(_=>_.setFieldDraftDebugEnabled),gt=ce(_=>_.fieldDraftDebug);E.useEffect(()=>{t6.has(r)||(T("balanced"),Ge.clearChat())},[r]);function Qt(_){var G,se;typeof _.navigateToSlug=="string"&&_.navigateToSlug.length>0&&_.navigateToSlug!==y&&x(_.navigateToSlug),typeof _.canUndo=="boolean"&&((G=Ge.setCanUndoServer)==null||G.call(Ge,_.canUndo)),typeof _.canRedo=="boolean"&&((se=Ge.setCanRedoServer)==null||se.call(Ge,_.canRedo)),Zt.postToSite("draftUpdated",{focusBlockId:null}),Pe()}async function kn(_){Wt(!0);try{const se=await(await fetch(`${Be}/history/restore`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({session:n,siteId:r,targetVersion:_})})).json();se.status==="applied"&&Qt(se)}catch{}finally{Wt(!1)}}const hn=Dce(n,r,u,he),_t=Mce(n,r,jn,Ge.pushAssistantFromResult,u,()=>{Zt.postToSite("draftUpdated",{focusBlockId:null}),hn.markPublished()}),Sn=hn.summary?hn.summary.total>0:!0,Ir=Rce(),wn=Ve==="properties"&&Ge.hasBootstrapped,$n=Oce(n,r,y,B,wn),Ns=Pce(n,r,y,wn);E.useEffect(()=>{!B||F||!$n.blockType||K($n.blockType)},[B,F,$n.blockType]);const sr=qee(n,r,!!n),Pa=Kee(sr.findings),ko=g6(2),tu=E.useRef(null),za=E.useCallback((_,G,se)=>{Y(_,G),V(se),Le(null),ce.getState().selectionModeEnabled||(ce.getState().setSelectionModeEnabled(!0),Oi.current("setSelectionMode",{enabled:!0})),Oi.current("highlightBlock",{blockId:_,editablePath:se??null,scrollIntoView:!0})},[]),cc=E.useCallback(_=>{const G=tu.current;!G||G.slug!==_||(tu.current=null,!(G.expiresAt!==void 0&&Date.now()>G.expiresAt)&&za(G.blockId,G.blockType,G.path))},[za]);E.useEffect(()=>{if(!tu.current)return;const _=setTimeout(()=>cc(y),400);return()=>clearTimeout(_)},[y,cc]),E.useEffect(()=>{yr.current=cc},[cc]);const dy=E.useCallback((_,G,se,Ce)=>{if(!G){_!==ce.getState().slug&&x(_),Y(void 0,void 0),V(void 0),ht("properties");return}if(_!==ce.getState().slug){tu.current={slug:_,blockId:G,blockType:se,path:Ce},x(_),ht("properties");return}ht("properties"),tu.current={slug:_,blockId:G,...se?{blockType:se}:{},...Ce?{path:Ce}:{},expiresAt:Date.now()+Cke},za(G,se,Ce)},[za]);vi.current=()=>{$n.refetch(),Ns.refetch(),Pe()};const[Dp,fy]=E.useState(()=>Vk(y,{session:n,siteId:r,editorOrigin:f},u)),[hy,Qd]=E.useState(!1);E.useEffect(()=>{Qd(!1)},[Dp]),E.useEffect(()=>{Ji.current!==u&&(Ji.current=u,gr.current=!1);const _={session:n,siteId:r,editorOrigin:f};if(Xi.current){Xi.current=!1;return}if(t0&&gr.current){Zt.postToSite("navigate",{href:qk(y,_)});return}const G=Vk(y,_,u);fy(se=>se===G?se:G)},[u,f,n,r,y]);const Rp=E.useMemo(()=>{var se;const _=(se=a.vercelProductionUrl)==null?void 0:se.trim(),G=_&&/^https?:\/\//i.test(_)?_:u;try{const Ce=new URL(G);return Ce.origin===u?wee(y,{},u):(Ce.pathname=y==="/"?"/":y,Ce.search="",Ce.hash="",Ce.toString())}catch{return}},[a.vercelProductionUrl,u,y]),jp=E.useMemo(()=>u?`${u}${qk(y,{session:n,siteId:r,editorOrigin:f,immersive:"1"})}`:void 0,[u,f,n,r,y]);E.useEffect(()=>{let _=!0;const G=async()=>{const Ce=[`${Be}/status/planner`];Be.includes("localhost")&&Ce.push(`${Be.replace("localhost","127.0.0.1")}/status/planner`);try{for(const Me of Ce){const Ue=await fetch(Me);if(!Ue.ok)continue;const et=await Ue.json();if(!_)return;if(et.features&&Dr(et.features),et.site&&ve(et.site),Array.isArray(et.availableProviders)&&et.availableProviders.length>0&&(D(et.availableProviders),(!et.availableProviders.includes(A)||A!=="anthropic"&&et.availableProviders.includes("anthropic"))&&M(et.availableProviders.includes("anthropic")?"anthropic":et.availableProviders[0])),typeof et.keyFilePath=="string"&&et.keyFilePath.length>0&&ce.getState().setKeyFilePath(et.keyFilePath),et.plannerSource==="openai"||et.plannerSource==="anthropic"||et.plannerSource==="gemini"||et.plannerSource==="demo"){kt(et.plannerSource);return}}_&&kt("error")}catch{_&&kt("error")}};G();const se=window.setInterval(()=>{G()},1e4);return()=>{_=!1,window.clearInterval(se)}},[]);const Ip=E.useRef(0),Op=E.useRef(0);E.useEffect(()=>{const _=Bn.current;if(!_)return;const G=()=>{const se=Math.abs(_.scrollHeight-_.scrollTop-_.clientHeight)<2||_.scrollHeight<=_.clientHeight;!se&&_.scrollTop<Ip.current?zr.current=!1:se&&(zr.current=!0),Ip.current=_.scrollTop};return _.addEventListener("scroll",G,{passive:!0}),()=>{_.removeEventListener("scroll",G)}},[]),E.useEffect(()=>{const _=Bn.current;if(!_||!(Ts.length>0||!!fr||!!Si))return;const se=Ts.reduce((dn,or)=>or.role==="user"?dn+1:dn,0);se>Op.current&&(zr.current=!0),Op.current=se;const Ce=!ws.current,Me=Ts.some(dn=>dn.role==="user");if(Ce&&!Me&&!fr&&!Si){ws.current=!0,zr.current=!1;return}if(!Ce&&!zr.current)return;const et=window.requestAnimationFrame(()=>{_.scrollTop=_.scrollHeight,zr.current=!0,ws.current=!0});return()=>window.cancelAnimationFrame(et)},[Ts.length,fr,Si,vo.length,eu.length]),E.useEffect(()=>{Zt.postToSite("setNestedLabelsVisibility",{visible:X})},[X]),E.useEffect(()=>{const _=Oi.current;if(!jn){es.current&&_("aiFieldLoading",WS),Wo.current=null,es.current=!1,ts.current=null;return}ts.current||(ts.current={fieldContext:uke(ce.getState().chatLog)});const G=cke({streamScope:wi,fieldContext:ts.current.fieldContext,focusBlockId:ns,activeBlockId:B,activeEditablePath:q});!G.active&&!es.current||(_("aiFieldLoading",G),Wo.current=G,es.current=G.active)},[jn,wi,ns,B,q]),E.useEffect(()=>{if(!jn)return;const _=window.setInterval(()=>{const G=Wo.current;G!=null&&G.active&&Oi.current("aiFieldLoading",G)},1200);return()=>window.clearInterval(_)},[jn]),E.useEffect(()=>{B&&Zt.postToSite("highlightBlock",{blockId:B,editablePath:q??null})},[B,q]),E.useEffect(()=>{Ge.clearFieldAiContext()},[B]),E.useEffect(()=>{B||Le(null)},[B]),E.useEffect(()=>{tt(!1)},[je]),E.useEffect(()=>{const _=()=>Le(null);return window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[]);const ef=PG(),La=E.useMemo(()=>{if(!ef||!je||!$e||!B||typeof window>"u"||window.innerWidth<=1040)return null;const _=Zt.iframeRef.current;if(!_)return null;const G=_.getBoundingClientRect(),se=380,Ce=36,Me=26,Ue=8,et=G.top+je.top*Qi;if(et+je.height*Qi<G.top||et>G.bottom)return null;const or=et+Ue-(Ce-Me)/2;let Cn=G.left+(je.left+je.width)*Qi-Ce-Ue;return Cn=Math.max(G.left+Ue,Math.min(Cn,G.right-Ce-Ue)),{top:or,left:Cn,width:se}},[je,$e,B,Zt.iframeRef,Qi]);E.useEffect(()=>{La&&ze&&requestAnimationFrame(()=>{var _,G;(G=(_=_s.current)==null?void 0:_.querySelector("textarea"))==null||G.focus()})},[!!La,ze]);const py=E.useCallback((_,G,se,Ce)=>{var or;if(!B||!F)return;const Ue=((or=Au()[F])==null?void 0:or.displayName)??F;V(_);const et=hS(se,G,F,Ce),dn={id:`field-ai-${Date.now()}`,role:"assistant",text:`Editing: ${Ue} → ${G}`,fieldAiContext:{blockId:B,blockType:F,fieldPath:_,fieldLabel:G,blockDisplayName:Ue},suggestions:et};Ge.setFieldAiContext(dn)},[B,F]),my=E.useCallback((_,G,se)=>{const Ce=hS(G,_,"Page",se),Me={id:`field-ai-${Date.now()}`,role:"assistant",text:`Editing: Page → ${_}`,fieldAiContext:{blockId:"__page__",blockType:"__page__",fieldPath:_,fieldLabel:_,blockDisplayName:"Page"},suggestions:Ce};Ge.setFieldAiContext(Me)},[]),Pp=E.useCallback((_,G,se,Ce,Me)=>{var or;if(!B||!F)return;const et=((or=Au()[F])==null?void 0:or.displayName)??F;V(_);const dn={id:`field-ai-${Date.now()}`,role:"assistant",text:`Editing: ${et} → ${G}`,fieldAiContext:{blockId:B,blockType:F,fieldPath:_,fieldLabel:G,blockDisplayName:et}};Ge.setFieldAiContext(dn),Ge.submitChat(Me)},[B,F]),gy=E.useCallback((_,G,se,Ce)=>{V(_);const Me={id:`field-ai-${Date.now()}`,role:"assistant",text:`Editing: Page → ${_}`,fieldAiContext:{blockId:"__page__",blockType:"__page__",fieldPath:_,fieldLabel:_,blockDisplayName:"Page"}};Ge.setFieldAiContext(Me),Ge.submitChat(Ce)},[]);E.useEffect(()=>{Ge.refreshRouteSlugs()},[n,r,e.siteRegistryChecked]);const tf=_=>{const se=Pt.current,Ce=Bn.current;if(!se||!Ce)return Math.max(56,_);const Me=120,Ue=10,et=Ce.offsetTop,dn=Math.max(56,se.clientHeight-et-Ue-Me);return Math.min(dn,Math.max(56,_))},by=E.useCallback(_=>{Ct(G=>{const se=tf(_);return se===G?G:se})},[]);E.useEffect(()=>{const _=se=>{const Ce=li.current;if(Ce){const Ue=se.clientY-Ce.y,et=tf(Ce.composerHeight-Ue);Ct(et)}const Me=Fn.current;if(Me){const Ue=se.clientX-Me.x;Me.target==="chat"?jt(Ak(Me.width+Ue)):Zr(Nk(Me.width-Ue))}},G=()=>{const se=!!Fn.current;li.current=null,Fn.current=null,document.body.style.userSelect="",se&&document.body.classList.remove("panel-resizing")};return window.addEventListener("pointermove",_),window.addEventListener("pointerup",G),()=>{window.removeEventListener("pointermove",_),window.removeEventListener("pointerup",G),document.body.style.userSelect="",document.body.classList.remove("panel-resizing")}},[]),E.useEffect(()=>{const _=()=>{Ct(G=>tf(G)),jt(G=>G&&Ak(G)),Zr(G=>G&&Nk(G))};return window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[jt,Zr]),E.useEffect(()=>{if(!St)return;const _=G=>{G.key==="Escape"&&!jr&&Ci(null)};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[St,jr]),E.useEffect(()=>{St!=null&&St.options.length?xn(St.options[0].id):xn(null)},[St]),E.useEffect(()=>{at||At("")},[at]),E.useEffect(()=>{if(!at)return;const _=G=>{G.key==="Escape"&&!vt&&Et(null)};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[at,vt]);const nf=fr?/failed|error/i.test(fr):!1,[zp,Lp]=E.useState(0),yy=Lr==null?void 0:Lr.stage;E.useEffect(()=>{if(Lp(0),!jn)return;const _=window.setInterval(()=>Lp(G=>G+1),1e3);return()=>window.clearInterval(_)},[jn,fr,yy]);const Bp=jn&&!nf&&zp>=5?` · ${zp}s`:"",xy=(Lr?Lr.stage:fr??(ro>0?t("stream.shapingUpdate"):t("stream.gettingReady")))+Bp,dc=(Lr?Lr.stage:fr??(ro>0?t("stream.updating"):t("stream.thinking")))+Bp,Ei=(fr==null?void 0:fr.match(/reconnecting(?:\s+agent\s+stream)?(?:\s+\((\d+)\/(\d+)\))?/i))??null,Fp=Ei!=null&&Ei[1]?Number(Ei[1]):null,rf=Ei!=null&&Ei[2]?Number(Ei[2]):null,nu=Ei?Fp&&rf?`Reconnect ${Fp}/${rf}`:"Reconnecting":null,sf=`field_draft ${gt.eventsPerSecond}/s · chars ${gt.charsPerSecond}/s · lag ${gt.typingLagChars}`,$p={"--composer-height":`${qt}px`},So=Ve==="properties",Ms=Ve==="history",of=Ve==="health",Up=E.useCallback(()=>{W(void 0),K(void 0),ht("chat")},[]);E.useLayoutEffect(()=>{const _=Yr.current,G=Zt.iframeRef.current;if(!_||!G)return;const se=Ue=>{var rs;if(Ue?G.classList.remove("preview-iframe-no-transition"):G.classList.add("preview-iframe-no-transition"),!So){G.style.removeProperty("width"),G.style.removeProperty("height"),G.style.removeProperty("transform"),Go(Ds=>Ds===1?Ds:1);return}const et=_.offsetWidth,dn=((rs=br.current)==null?void 0:rs.offsetWidth)??0;if(et<=0||dn<=0)return;const or=et+dn,Cn=et/or;G.style.width=`${or}px`,G.style.height=`${100/Cn}%`,G.style.transform=`scale(${Cn})`,Go(Ds=>Math.abs(Ds-Cn)<5e-4?Ds:Cn)};se(!0);const Ce=new ResizeObserver(()=>se(!1)),Me=window.setTimeout(()=>{Ce.observe(_);const Ue=br.current;Ue&&Ce.observe(Ue)},240);return()=>{window.clearTimeout(Me),G.classList.remove("preview-iframe-no-transition"),Ce.disconnect()}},[So,Zt.iframeRef]);const vy={...on?{"--chat-width":`${on}px`}:{},...Es?{"--props-width":`${Es}px`}:{}},af=Ts.some(_=>_.role==="user"),lf=E.useCallback(_=>{const G=[];_.text&&G.push(_.text),_.status&&!_.canUndo&&_.status!=="needs_clarification"&&_.status!=="plan_ready"&&G.push(`status: ${_.status}`);const se=(_.changes??[]).filter(Ce=>!W4(_.text,Ce));if(se.length>0&&G.push(`changes: ${se.join(`
|
|
750
750
|
`)}`),(_.errors??[]).length>0&&G.push(`errors: ${(_.errors??[]).join(`
|
|
751
751
|
`)}`),_.debug){if(G.push(""),G.push("Debug"),_.debug.traceId&&G.push(`traceId: ${_.debug.traceId}`),_.debug.promptHash&&G.push(`promptHash: ${_.debug.promptHash}`),_.debug.outcome&&G.push(`outcome: ${_.debug.outcome}`),_.debug.reasonCategory&&G.push(`reason: ${_.debug.reasonCategory}`),_.debug.reason&&_.debug.reason!==_.debug.reasonCategory&&G.push(`reasonDetail: ${_.debug.reason}`),_.debug.intent&&G.push(`intent: ${_.debug.intent}`),_.debug.plannerTier&&G.push(`plannerTier: ${_.debug.plannerTier}`),_.debug.modelUsed&&G.push(`model: ${_.debug.modelUsed}${_.debug.plannerSource?` (${_.debug.plannerSource})`:""}`),typeof _.debug.planningAttempts=="number"&&_.debug.planningAttempts>1&&G.push(`planningAttempts: ${_.debug.planningAttempts}`),typeof _.debug.opCount=="number"&&G.push(`opCount: ${_.debug.opCount}`),Array.isArray(_.debug.skippedOps)&&_.debug.skippedOps.length>0){const Me=_.debug.skippedOps.map(Ue=>`[${Ue.index}] ${Ue.op} ${Ue.pageSlug??""}${Ue.blockId?"#"+Ue.blockId:""}: ${Ue.reason}`).join(", ");G.push(`skippedOps: ${Me}`)}else typeof _.debug.skippedOpCount=="number"&&_.debug.skippedOpCount>0&&G.push(`skippedOps: ${_.debug.skippedOpCount}`);if(Array.isArray(_.debug.opTypes)&&_.debug.opTypes.length>0&&G.push(`ops: ${_.debug.opTypes.join(", ")}`),typeof _.debug.totalTokens=="number"&&G.push(`tokens: in:${_.debug.inputTokens??"?"} out:${_.debug.outputTokens??"?"} total:${_.debug.totalTokens}`),typeof _.debug.estimatedUsd=="number"&&G.push(`cost: $${_.debug.estimatedUsd.toFixed(4)}`),Array.isArray(_.debug.timeline)&&_.debug.timeline.length>0){const Me=_.debug.timeline.map(Ue=>`${Ue.stage}:${Ue.atMs}ms`).join(" -> ");G.push(`timeline: ${Me}`)}_.debug.promptExcerpt&&G.push(`prompt: ${_.debug.promptExcerpt}`);const Ce=[];_.debug.currentPage&&Ce.push(`page: ${_.debug.currentPage}`),_.debug.siteId&&Ce.push(`site: ${_.debug.siteId}`),_.debug.activeBlockId&&Ce.push(`block: ${_.debug.activeBlockId}`),_.debug.activeEditablePath&&Ce.push(`path: ${_.debug.activeEditablePath}`),Ce.length>0&&G.push(`context: ${Ce.join(", ")}`)}return G.join(`
|
|
752
752
|
`)},[]),ru=E.useCallback(async _=>{const G=lf(_);if(G.trim())try{await navigator.clipboard.writeText(G),Te(_.id),window.setTimeout(()=>{ce.getState().copiedDebugEntryId===_.id&&Te(null)},1400)}catch{}},[lf]),iu=E.useCallback(_=>{var se;if(!_.debug)return t("chat.expandDetails");const G=[];if(_.debug.outcome&&G.push(_.debug.outcome.replace(/_/g," ")),typeof _.debug.opCount=="number"){const Ce=_.debug.opCount;G.push(`${Ce} op${Ce===1?"":"s"}`)}if(_.debug.intent&&G.push(`intent: ${_.debug.intent.replace(/_/g," ")}`),_.debug.plannerTier&&G.push(_.debug.plannerTier.replace(/_/g," ")),Array.isArray(_.debug.timeline)&&_.debug.timeline.length>0){const Ce=(se=_.debug.timeline[_.debug.timeline.length-1])==null?void 0:se.atMs;typeof Ce=="number"&&G.push(`${Ce}ms`)}return G.join(" · ")||t("chat.expandDetails")},[t]),ky=sr.findings.length,su=p.jsxs("div",{className:"chat-header-slug-actions",ref:ko.containerRef,role:"toolbar","aria-label":t("header.pageTools"),onKeyDown:ko.onKeyDown,children:[p.jsx("button",{type:"button",className:`chat-header-icon-btn${So?" is-active":""}`,"aria-label":t("tabs.properties"),"data-tooltip":t("tabs.properties"),"aria-pressed":So,onClick:()=>{So?Up():(W(void 0),K(void 0),ht("properties"))},...ko.itemProps(0),children:p.jsx(vF,{size:14,"aria-hidden":"true"})}),p.jsx("button",{type:"button",className:`chat-header-icon-btn${Ms?" is-active":""}`,"aria-label":t("history.tooltip"),"data-tooltip":t("history.tooltip"),"aria-pressed":Ms,onClick:()=>ht(Ms?"chat":"history"),...ko.itemProps(1),children:p.jsx(h9,{size:14,"aria-hidden":"true"})})]});return p.jsxs("div",{className:`layout${So?" layout--props-open":""}${g?" layout--banner":""}`,style:vy,children:[g?p.jsx(rke,{siteId:r,orchestratorUrl:Be,hostedIds:e.hostedSiteIds??[],...e.siteHosting==="notHosted"?{}:{siteOwnOrchestrator:m}}):null,p.jsxs("aside",{className:"chat-panel",ref:Pt,style:$p,children:[p.jsxs("header",{className:"chat-header",children:[p.jsxs("div",{className:"chat-header-top",children:[p.jsxs("div",{className:"chat-header-site-name",ref:rr,children:[e.siteList.length>1?p.jsxs("button",{type:"button",className:`site-switcher-trigger${vn?" is-open":""}`,onClick:()=>Ln(_=>!_),"aria-expanded":vn,"aria-haspopup":"menu",children:[p.jsx("span",{className:`site-switcher-item-dot site-switcher-item-dot-${Rr!=null&&Rr.probing?"probing":Rr!=null&&Rr.online?"online":"offline"}`,"aria-hidden":"true"}),p.jsx("span",{className:"site-switcher-trigger-label",children:a.name}),p.jsx(Ma,{size:12,className:`site-switcher-chevron${vn?" is-open":""}`,"aria-hidden":"true"})]}):p.jsx("span",{className:"site-switcher-trigger-label",children:a.name}),vn&&p.jsxs("div",{className:"site-switcher-dropdown",role:"menu","aria-label":t("header.allSites"),children:[p.jsxs("div",{className:"site-switcher-header",children:[p.jsx("span",{children:t("header.allSites")}),p.jsxs("a",{href:"/sites",className:"site-switcher-add-link",onClick:()=>Ln(!1),children:["+ ",t("sites.addSite")]})]}),p.jsx("div",{className:"site-switcher-list",children:Xs.map(_=>p.jsx(Eke,{name:_.site.name,origin:_.origin,statusClass:_.probing?"probing":"online",active:_.site.id===r,onSelect:()=>{_.site.id!==r&&e.openEditorForSite(_.site.id),Ln(!1)}},_.site.id))}),p.jsxs("div",{className:"site-switcher-actions",role:"group",children:[p.jsxs("button",{type:"button",role:"menuitem",className:"site-switcher-action",onClick:()=>{Ln(!1),e.setConfigSiteId(r)},children:[p.jsx(yF,{size:14,"aria-hidden":"true"}),p.jsx("span",{children:t("header.siteSettings")})]}),Ge.siteHasCmsContent!==!1&&p.jsxs("button",{type:"button",role:"menuitem",className:"site-switcher-action",title:t("header.syncFromSiteTitle"),disabled:jn,onClick:async()=>{Ln(!1);const _=await Ge.syncFromSite();_.ok&&_.count>0?Ge.pushAssistantFromResult({status:"applied",summary:_.count===1?t("header.syncedPage"):t("header.syncedPages",{count:_.count}),changes:[]}):_.ok||Ge.pushAssistantFromResult({status:"error",summary:_.reason==="network"?t("header.syncFailedNetwork"):t("header.syncFailedEmpty"),changes:[]})},children:[p.jsx(XS,{size:14,"aria-hidden":"true"}),p.jsx("span",{children:t("header.syncFromSite")})]})]}),p.jsxs("a",{href:"/sites",className:"site-switcher-footer",onClick:()=>Ln(!1),children:[t("header.viewAllSites"),p.jsx(Ug,{size:11,"aria-hidden":"true"})]})]})]}),p.jsxs("div",{className:"chat-header-right",children:[d.status==="degraded"?p.jsx("span",{className:"planner-badge",title:d.reason??"Components unavailable",children:t("header.limited")}):null,!dd&&(Sn||_t.publishInProgress)?p.jsxs("button",{type:"button",className:"publish-preview-btn",onClick:()=>Oe(!0),disabled:jn||_t.isPublishing,title:hn.summary&&hn.summary.total>0?t("header.unpublishedTooltip",{count:String(hn.summary.total)}):void 0,children:[_t.publishInProgress?p.jsx("span",{className:"publish-spinner","aria-hidden":"true"}):null,_t.publishInProgress?t("header.publishing"):t("header.publish"),hn.summary&&hn.summary.total>0?p.jsx("span",{className:"publish-preview-badge","aria-hidden":"true",children:hn.summary.total}):null]}):null,!dd&&_t.publishStatus?p.jsxs(p.Fragment,{children:[_t.publishStatus.inspectUrl?p.jsx("a",{className:"publish-view-link",href:_t.publishStatus.inspectUrl,target:"_blank",rel:"noreferrer",children:t("header.viewDeploy")}):null,Rp?p.jsx("a",{className:"live-site-icon-btn",href:Rp,target:"_blank",rel:"noreferrer","aria-label":t("header.openLiveSite"),title:t("header.openLiveSite"),children:p.jsx(Ug,{size:16,"aria-hidden":"true"})}):null]}):null]})]}),er&&ci?p.jsxs("div",{className:"chat-header-lang-row",children:[p.jsx("label",{className:"chat-header-lang",children:p.jsx("select",{value:ci,"aria-label":t("header.language"),title:t("header.language"),onChange:_=>x(gke(y,_.target.value,er)),disabled:S,children:er.locales.map(_=>p.jsx("option",{value:_,children:_===Il?t("header.defaultLanguage"):bke(_)},_))})}),su]}):null,p.jsxs("div",{className:"chat-header-slug-row",children:[p.jsx("label",{className:"chat-header-slug",children:p.jsx("select",{value:y,"aria-label":t("header.page"),onChange:_=>x(_.target.value||"/"),disabled:S,children:er&&ci?p.jsxs(p.Fragment,{children:[Qs.map(_=>p.jsx("option",{value:_,children:mke(_,ci)},_)),er.shared.length>0?p.jsx("optgroup",{label:t("header.pagesWithoutLanguage"),children:er.shared.map(_=>p.jsx("option",{value:_,children:Fx(_)},_))}):null]}):ir.map(_=>p.jsx("option",{value:_,children:Fx(_)},_))})}),er&&ci?null:su]})]}),p.jsxs("div",{className:"chat-thread-region",children:[mw?p.jsxs("div",{className:"demo-banner",role:"note","aria-label":"Demo mode notice",children:[p.jsx("div",{className:"demo-banner-title",children:t("demo.bannerTitle")}),p.jsx("div",{className:"demo-banner-body",children:t("demo.bannerBody")}),p.jsxs("div",{className:"demo-banner-examples",children:[p.jsx("button",{type:"button",className:"demo-banner-example",disabled:jn,onClick:()=>void Ge.submitChat(t("demo.tryExample1")),children:t("demo.tryExample1")}),p.jsx("button",{type:"button",className:"demo-banner-example",disabled:jn,onClick:()=>void Ge.submitChat(t("demo.tryExample2")),children:t("demo.tryExample2")}),p.jsx("button",{type:"button",className:"demo-banner-example",disabled:jn,onClick:()=>void Ge.submitChat(t("demo.tryExample3")),children:t("demo.tryExample3")})]})]}):null,p.jsx(uk,{fallbackLabel:"Chat unavailable — try refreshing",onReset:()=>window.location.reload(),children:p.jsx(Cee,{ref:Bn,className:"chat-thread",streamStatusLabel:dc,undoInFlightEntryId:Ge.undoInFlightEntryId,onSuggestionClick:(_,G)=>void Ge.submitChat(_,void 0,{clickedSuggestionId:G}),onUndo:_=>void Ge.applyUndoHistory(_),undoLabel:t("chat.undo"),undoneLabel:t("chat.undone"),appliedDraftLabel:t("chat.appliedDraft"),keepLabel:t("chat.keep"),revertLabel:t("chat.revert"),revertedLabel:t("chat.reverted"),keptLabel:t("chat.kept"),renderEntryExtras:_=>{var G;return p.jsxs(p.Fragment,{children:[_.variations&&Array.isArray(_.variations.options)&&_.variations.options.length>0?p.jsx("div",{className:"msg-variations",children:_.variations.options.map((se,Ce)=>p.jsxs("button",{type:"button",className:"msg-variation-card",disabled:jn,onClick:async()=>{const Me=_.variations;try{(await fetch(`${Be}/ops`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({session:n,siteId:r,ops:[{op:"update_props",pageSlug:Me.pageSlug,blockId:Me.blockId,patch:se.patch}]})})).ok&&(Zt.postToSite("draftUpdated",{focusBlockId:Me.blockId}),Pe(),Ge.pushAssistantFromResult({status:"applied",summary:`Applied variation: ${se.title}`,changes:[se.summary]}))}catch{}},children:[p.jsx("div",{className:"msg-variation-preview-wrap",children:p.jsx(CN,{block:{id:_.variations.blockId,type:_.variations.blockType,props:{..._.variations.baseProps,...se.patch}},virtualWidth:1280})}),p.jsxs("div",{className:"msg-variation-meta",children:[p.jsx("span",{className:"msg-variation-badge",children:String.fromCharCode(65+Ce)}),p.jsxs("div",{className:"msg-variation-content",children:[p.jsx("span",{className:"msg-variation-title",children:se.title}),p.jsx("span",{className:"msg-variation-summary",children:se.summary})]})]})]},se.id??`${_.id}-v-${Ce}`))}):null,_.status==="plan_ready"&&_.pendingPlanId?p.jsxs("div",{className:"msg-plan-actions",children:[_.planPreview?p.jsx(loe,{preview:_.planPreview}):null,_.destructiveReasons&&_.destructiveReasons.length>0?p.jsx("div",{className:"msg-destructive-warning",role:"alert",children:_.destructiveReasons.map((se,Ce)=>p.jsxs("div",{className:"msg-destructive-warning-line",children:["⚠ ",se]},Ce))}):null,(()=>{var dn;const se=_.pendingPlanId,Ce=jn||Se!==se,Me=!!(_.destructiveReasons&&_.destructiveReasons.length>0),Ue=((dn=_.planPreview)==null?void 0:dn.diff.pages.filter(or=>or.status==="removed").length)??0,et=Ue===1?t("plan.deletePage"):Ue>1?t("plan.deletePages",{count:Ue}):t(Me?"plan.applyDestructive":"plan.apply");return p.jsxs("div",{className:"msg-plan-btn-row",children:[p.jsx("button",{type:"button",className:`primary-btn msg-plan-btn${Me?" is-destructive":""}`,onClick:()=>void Ge.approvePendingPlan(se),disabled:Ce,children:et}),p.jsx("button",{type:"button",className:"secondary-btn msg-plan-btn",onClick:()=>void Ge.stopPendingPlan(se),disabled:Ce,children:t("plan.discard")})]})})()]}):null,_.imageSwap?(()=>{const se=_.imageSwap,Ce=/^image$/i.test((se.fieldLabel??"").trim()),Me=se.fieldLabel&&!(se.blockDisplayName&&Ce),Ue=se.blockDisplayName??(Me?se.fieldLabel:null),et=se.blockDisplayName&&Me?se.fieldLabel:null;return p.jsxs("button",{type:"button",className:"msg-image-swap-card",onClick:()=>{zn({slug:se.slug,blockId:se.blockId,editablePath:se.editablePath,currentUrl:se.imageUrl,blockType:B===se.blockId?F:void 0})},title:t("ops.imageSwap.pickAnother"),children:[p.jsx("img",{src:se.imageUrl,alt:se.altText??""}),p.jsxs("div",{className:"msg-image-swap-meta",children:[Ue?p.jsx("span",{className:"msg-image-swap-block",children:Ue}):null,et?p.jsx("span",{className:"msg-image-swap-field",children:et}):null,p.jsx("span",{className:"msg-image-swap-action",children:t("ops.imageSwap.pickAnother")})]})]})})():null,_.continuation?p.jsx("div",{className:"msg-plan-actions",children:p.jsxs("button",{type:"button",className:"primary-btn msg-plan-btn",onClick:()=>void Ge.continueChain(_.continuation.chainId),disabled:jn||di!==_.continuation.chainId,children:["Continue: ",_.continuation.nextStepLabel," (",_.continuation.currentStep," of ",_.continuation.totalSteps,")"]})}):null,(()=>{if(_.wasUndone)return null;const se=(_.mentionedSlugs??[]).filter(Ce=>Ce!==y);return se.length===0?null:p.jsx("div",{className:"msg-suggestions msg-page-links",children:se.map((Ce,Me)=>p.jsxs("button",{type:"button",className:"msg-suggestion msg-page-link",onClick:()=>{x(Ce)},disabled:jn,children:["Open ",Ce]},`${_.id}-route-${Me}`))})})(),(_.errors??[]).length>0?p.jsx("ul",{className:"msg-errors",children:(G=_.errors)==null?void 0:G.map((se,Ce)=>p.jsx("li",{children:se},Ce))}):null,Ke&&_.role==="assistant"&&_.debug?p.jsxs("div",{className:"msg-debug-shell",children:[p.jsxs("details",{className:"msg-debug-details",children:[p.jsxs("summary",{className:"msg-debug-summary",children:[p.jsxs("span",{className:"msg-debug-summary-left",children:[p.jsx("span",{className:"msg-debug-title",children:"Debug"}),p.jsx("span",{className:"msg-debug-summary-text",children:iu(_)})]}),p.jsx("span",{className:"msg-debug-chevron","aria-hidden":"true"})]}),p.jsx("div",{className:"msg-debug",children:p.jsxs("ul",{children:[_.debug.traceId?p.jsxs("li",{children:["traceId: ",_.debug.traceId]}):null,_.debug.promptHash?p.jsxs("li",{children:["promptHash: ",_.debug.promptHash]}):null,_.debug.outcome?p.jsxs("li",{children:["outcome: ",_.debug.outcome]}):null,_.debug.reasonCategory?p.jsxs("li",{children:["reason: ",_.debug.reasonCategory]}):null,_.debug.reason&&_.debug.reason!==_.debug.reasonCategory?p.jsxs("li",{children:["reasonDetail: ",_.debug.reason]}):null,_.debug.intent?p.jsxs("li",{children:["intent: ",_.debug.intent]}):null,_.debug.plannerTier?p.jsxs("li",{children:["plannerTier: ",_.debug.plannerTier]}):null,_.debug.modelUsed?p.jsxs("li",{children:["model: ",_.debug.modelUsed,_.debug.plannerSource?` (${_.debug.plannerSource})`:""]}):null,typeof _.debug.planningAttempts=="number"&&_.debug.planningAttempts>1?p.jsxs("li",{children:["planningAttempts: ",_.debug.planningAttempts]}):null,typeof _.debug.opCount=="number"?p.jsxs("li",{children:["opCount: ",_.debug.opCount]}):null,Array.isArray(_.debug.skippedOps)&&_.debug.skippedOps.length>0?p.jsxs("li",{children:["skippedOps: ",_.debug.skippedOps.map(se=>`[${se.index}] ${se.op} ${se.pageSlug??""}${se.blockId?"#"+se.blockId:""}: ${se.reason}`).join(", ")]}):typeof _.debug.skippedOpCount=="number"&&_.debug.skippedOpCount>0?p.jsxs("li",{children:["skippedOps: ",_.debug.skippedOpCount]}):null,Array.isArray(_.debug.opTypes)&&_.debug.opTypes.length>0?p.jsxs("li",{children:["ops: ",_.debug.opTypes.join(", ")]}):null,typeof _.debug.totalTokens=="number"?p.jsxs("li",{children:["tokens: in:",_.debug.inputTokens??"?"," out:",_.debug.outputTokens??"?"," total:",_.debug.totalTokens]}):null,typeof _.debug.estimatedUsd=="number"?p.jsxs("li",{children:["cost: $",_.debug.estimatedUsd.toFixed(4)]}):null,Array.isArray(_.debug.timeline)&&_.debug.timeline.length>0?p.jsxs("li",{children:["timeline: ",_.debug.timeline.map(se=>`${se.stage}:${se.atMs}ms`).join(" -> ")]}):null,_.debug.promptExcerpt?p.jsxs("li",{children:["prompt: ",_.debug.promptExcerpt]}):null,_.debug.currentPage||_.debug.siteId||_.debug.activeBlockId||_.debug.activeEditablePath?p.jsxs("li",{children:["context: ",[_.debug.currentPage?`page: ${_.debug.currentPage}`:null,_.debug.siteId?`site: ${_.debug.siteId}`:null,_.debug.activeBlockId?`block: ${_.debug.activeBlockId}`:null,_.debug.activeEditablePath?`path: ${_.debug.activeEditablePath}`:null].filter(Boolean).join(", ")]}):null]})})]}),p.jsx("button",{type:"button",className:"msg-debug-copy-btn",onClick:()=>void ru(_),"aria-label":fe===_.id?t("chat.copied"):t("chat.copyDebug"),title:fe===_.id?t("chat.copied"):t("chat.copy"),children:fe===_.id?p.jsx(Fd,{"aria-hidden":"true",size:14}):p.jsx(JS,{"aria-hidden":"true",size:14})})]}):null]})},renderEntryActions:(_,G)=>{var se,Ce,Me;return G&&_.role==="assistant"&&((se=_.debug)!=null&&se.traceId)&&_.id!=="welcome"?p.jsxs(p.Fragment,{children:[p.jsx("button",{type:"button",className:`msg-feedback-btn ${((Ce=_.feedback)==null?void 0:Ce.rating)==="up"?"msg-feedback-btn--active":""}`,onClick:()=>{_.feedback||Ge.submitFeedback(_.id,"up")},disabled:!!_.feedback,title:t("chat.goodResponse"),children:p.jsx(AF,{"aria-hidden":"true",size:13})}),p.jsx("button",{type:"button",className:`msg-feedback-btn ${((Me=_.feedback)==null?void 0:Me.rating)==="down"?"msg-feedback-btn--active":""}`,onClick:()=>{_.feedback||(nt(Fe===_.id?null:_.id),cn(""))},disabled:!!_.feedback,title:t("chat.badResponse"),children:p.jsx(_F,{"aria-hidden":"true",size:13})}),_.feedback?p.jsxs("span",{className:"msg-feedback-label",children:[_.feedback.rating==="up"?t("chat.feedbackThanks"):t("chat.feedbackNoted"),_.feedback.note?` — "${_.feedback.note}"`:""]}):null,Fe===_.id&&!_.feedback?p.jsxs("form",{className:"msg-feedback-note-form",onSubmit:Ue=>{Ue.preventDefault(),Ge.submitFeedback(_.id,"down",Dt||void 0),nt(null),cn("")},children:[p.jsx("input",{className:"msg-feedback-note-input",placeholder:t("chat.feedbackPlaceholder"),value:Dt,onChange:Ue=>cn(Ue.target.value),autoFocus:!0}),p.jsx("button",{type:"submit",className:"msg-feedback-note-submit",children:t("chat.feedbackSend")})]}):null]}):null},renderStreamingExtras:()=>p.jsxs(p.Fragment,{children:[nu?p.jsx("span",{className:"stream-reconnect-badge stream-reconnect-badge-inline",title:fr??void 0,children:nu}):null,Ke&&Br?p.jsx("div",{className:"streaming-debug-inline",children:sf}):null]}),renderStreamStatusFallback:()=>p.jsxs("div",{className:`streaming-pill ${nf?"is-error":"is-active"} ${sR==="text"?"is-text":"is-legacy"}`,children:[sR==="text"?p.jsx("span",{className:"streaming-pill-status streaming-pill-status-text",children:dc}):p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"streaming-pill-title",children:p.jsx("span",{className:"streaming-pill-sparkle",children:"✦"})}),p.jsx("span",{className:"streaming-pill-status",children:xy}),nf?null:p.jsxs("span",{className:"streaming-dots","aria-hidden":"true",children:[p.jsx("i",{}),p.jsx("i",{}),p.jsx("i",{})]})]}),nu?p.jsx("span",{className:"stream-reconnect-badge",title:fr??void 0,children:nu}):null,Lr?p.jsx("div",{className:"image-gen-progress",children:p.jsx("div",{className:"image-gen-progress-fill",style:{width:`${Lr.percent}%`}})}):null,ns?p.jsx("button",{type:"button",className:"streaming-jump-btn",onClick:()=>Zt.postToSite("highlightBlock",{blockId:ns,editablePath:null,scrollIntoView:!0}),children:"Jump to latest change"}):null,Ke&&Br?p.jsx("div",{className:"streaming-debug-inline",children:sf}):null]})})})]}),p.jsx("div",{ref:Cs,className:"composer-splitter",role:"separator","aria-orientation":"horizontal","aria-label":t("resize.inputPanel"),onPointerDown:_=>{li.current={y:_.clientY,composerHeight:qt},document.body.style.userSelect="none"}}),As==="demo"?p.jsx(toe,{collapsed:Yo,onToggle:()=>ft(_=>!_)}):null,p.jsx(Eee,{className:"composer",message:P,isLoading:jn,hasUserEntry:af,onMessageChange:R,onSubmit:_=>{R(""),Ge.submitChat(_,P)},onTranscribeAudio:Ir.transcribeAudio,onUploadAttachment:Ir.uploadAttachment,attachments:xo,onAttachmentsChange:Ql,onCancel:Ge.cancelChat,onAutoHeightChange:by,selectionModeEnabled:$e,onToggleSelectionMode:()=>to(),canUndoServer:Ge.canUndoServer,canRedoServer:Ge.canRedoServer,onGlobalUndo:()=>void Ge.applyGlobalUndo(),onGlobalRedo:()=>void Ge.applyGlobalRedo(),undoTooltip:t("chat.undoTooltip"),redoTooltip:t("chat.redoTooltip"),contextChip:B&&F?{label:t("chatInput.editingBlock",{block:((uf=Au()[F])==null?void 0:uf.displayName)??F}),clearLabel:t("chatInput.clearSelection"),onClear:()=>{W(void 0),K(void 0)}}:null})]}),p.jsx("div",{className:"panel-splitter",role:"separator","aria-orientation":"vertical","aria-label":t("resize.chatPanel"),onPointerDown:_=>{const G=Pt.current;G&&(Fn.current={x:_.clientX,width:G.offsetWidth,target:"chat"},document.body.style.userSelect="none",document.body.classList.add("panel-resizing"))}}),p.jsx("div",{className:"preview",children:p.jsxs("div",{className:"preview-canvas",ref:Yr,children:[p.jsx(Jee,{t,issueCount:ky,issueSeverity:Pa,issuesOpen:of,onOpenIssues:()=>ht(of?"chat":"health"),...jp?{immersiveUrl:jp}:{},...ne?{onOpenSettings:()=>qe(!0)}:{}}),hy?null:p.jsx("div",{className:"preview-loading",role:"status","aria-label":t("preview.loading"),children:p.jsx("span",{className:"preview-loading-spinner","aria-hidden":"true"})}),p.jsx("iframe",{ref:Zt.iframeRef,title:t("preview.title"),src:Dp,style:{colorScheme:"light dark"},onLoad:()=>{Qd(!0),t0&&!gr.current&&(gr.current=!0,Ji.current=u),Zt.postToSite("setNestedLabelsVisibility",{visible:X})}})]})}),So?p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"panel-splitter panel-splitter--props",role:"separator","aria-orientation":"vertical","aria-label":t("resize.chatPanel"),onPointerDown:_=>{const G=br.current;G&&(Fn.current={x:_.clientX,width:G.offsetWidth,target:"props"},document.body.style.userSelect="none",document.body.classList.add("panel-resizing"))}}),p.jsx("aside",{className:"props-panel",ref:br,children:p.jsx(uk,{fallbackLabel:"Properties panel unavailable — try refreshing",children:p.jsx(Hve,{props:$n.props,status:$n.status,failure:$n.failure,failedSlug:$n.failedSlug,failedOrigin:$n.failedOrigin,onRetry:$n.retry,pageName:Fx(y),onDeselectBlock:()=>{W(void 0),K(void 0)},onClose:Up,navLabel:((cf=e.headerConfig.navLabels)==null?void 0:cf[y])??"",onNavLabelChange:(_,G)=>{e.updateHeaderConfig({navLabels:{[_]:G}}),Zt.postToSite("draftUpdated",{}),Pe()},pageMeta:Ns.meta,onPageMetaChange:(_,G)=>{const se={...Ns.meta,[_]:G};Ns.setMeta(se),(async()=>{try{const Ce=await fetch(`${Be}/ops`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({session:n,siteId:r,ops:[{op:"update_page_meta",pageSlug:y,patch:{[_]:G}}]})}),Me=await Ce.json();if(!Ce.ok||Me.status!=="applied"){Ns.refetch();return}Zt.postToSite("draftUpdated",{}),Pe()}catch{Ns.refetch()}})()},onFieldChange:async(_,G)=>{await Ge.inlineEditCommit(y,B,_,G,{silent:!0}),$n.refetch()},onImageClick:(_,G)=>{B&&zn({slug:y,blockId:B,editablePath:_,currentUrl:G,blockType:F})},onAiAssist:py,onPageAiAssist:my,onAiQuickAction:Pp,onPageAiQuickAction:gy,onAddListItem:B&&F?_=>{Ge.addListItem(y,B,F,_).then(()=>$n.refetch())}:void 0,onRemoveListItem:B&&F?(_,G)=>{Ge.removeListItem(y,B,F,_,G).then(()=>$n.refetch())}:void 0,manifestByType:d.byType,siteOrigin:u})})})]}):null,of?p.jsx("div",{className:"history-drawer-backdrop",onClick:()=>ht("chat"),children:p.jsx("aside",{className:"history-drawer",role:"dialog","aria-label":t("health.title"),onClick:_=>_.stopPropagation(),children:p.jsx(uk,{children:p.jsx(Uee,{findings:sr.findings,isLoading:sr.isLoading,isRunning:sr.isRunning,error:sr.error,durable:sr.durable,onRun:()=>void sr.run(),onDismiss:_=>void sr.setStatus(_,"dismissed"),onSnooze:_=>void sr.setStatus(_,"snoozed"),onGoTo:dy,onClose:()=>ht("chat")})})})}):null,Ms?p.jsx("div",{className:"history-drawer-backdrop",onClick:()=>ht("chat"),children:p.jsx("aside",{className:"history-drawer",role:"dialog","aria-label":t("history.title"),onClick:_=>_.stopPropagation(),children:p.jsx(Iee,{session:n,siteId:r,slug:y,visible:Ms,onRestore:kn,isRestoring:Ft,onDiscarded:Qt,onClose:()=>ht("chat")})})}):null,La&&ze?p.jsx("div",{ref:_s,className:"composer--anchored is-expanded",style:{top:La.top,left:La.left,width:La.width},children:p.jsx(zj,{message:P,isLoading:jn,hasUserEntry:af,onMessageChange:R,onSubmit:_=>{R(""),Ge.submitChat(_,P)},onTranscribeAudio:Ir.transcribeAudio,onUploadAttachment:Ir.uploadAttachment,attachments:xo,onAttachmentsChange:Ql,onCancel:Ge.cancelChat,onAutoHeightChange:()=>{},compact:!0})}):null,St?(()=>{const _=St,G=_.options.find(se=>se.id===Nr)??null;return p.jsx("div",{className:"variation-modal-backdrop",onClick:()=>{jr||Ci(null)},children:p.jsxs("div",{className:"variation-modal",role:"dialog","aria-modal":"true","aria-label":t("variation.title"),onClick:se=>se.stopPropagation(),children:[p.jsxs("div",{className:"variation-modal-header",children:[p.jsx("h2",{children:"Choose a Variation"}),p.jsx("button",{type:"button",className:"settings-close-btn","aria-label":t("variation.close"),onClick:()=>Ci(null),disabled:jr,children:"×"})]}),p.jsx("div",{className:"variation-modal-body",children:_.options.map((se,Ce)=>p.jsxs("article",{className:`variation-card${se.id===Nr?" is-selected":""}`,onClick:()=>xn(se.id),children:[p.jsxs("div",{className:"variation-card-preview-wrap",children:[p.jsx("span",{className:"variation-card-badge",children:String.fromCharCode(65+Ce)}),p.jsx(CN,{virtualWidth:CG.desktop,block:{id:_.blockId,type:_.blockType,props:zG(_.baseProps,se.patch)}}),se.imagePending?p.jsxs("div",{className:"variation-card-image-pending","aria-live":"polite",children:[p.jsx("span",{className:"variation-card-image-pending-spinner","aria-hidden":"true"}),p.jsx("span",{className:"variation-card-image-pending-label",children:"Generating image…"})]}):null]}),p.jsx("h3",{className:"variation-card-title",children:se.title}),p.jsx("p",{className:"variation-card-summary",children:se.summary})]},se.id))}),p.jsx("div",{className:"variation-modal-footer",children:p.jsx("button",{type:"button",className:"publish-preview-btn variation-apply-btn",onClick:()=>{G&&Ge.applyVariation(G)},disabled:jr||!G,children:jr?t("variation.applying"):t("variation.apply",{title:(G==null?void 0:G.title)??""})})})]})})})():null,at?p.jsx("div",{className:"add-block-modal-backdrop",onClick:()=>{vt||Et(null)},children:p.jsxs("div",{className:"add-block-modal",role:"dialog","aria-modal":"true","aria-label":t("addBlock.title"),onClick:_=>_.stopPropagation(),children:[p.jsxs("div",{className:"add-block-modal-header",children:[p.jsx("h2",{children:"Add block"}),p.jsx("p",{children:at.beforeBlockId&&!at.afterBlockId?t("addBlock.insertAbove"):t("addBlock.insertBelow")}),p.jsx("button",{type:"button",className:"settings-close-btn","aria-label":t("addBlock.close"),onClick:()=>Et(null),disabled:vt,children:"×"})]}),p.jsxs("div",{className:"add-block-modal-body",children:[p.jsx("label",{className:"add-block-search",children:p.jsx("input",{type:"search",value:Ye,onChange:_=>At(_.target.value),placeholder:t("addBlock.searchPlaceholder"),disabled:vt})}),yo.length===0?p.jsx("p",{className:"add-block-empty",children:"No block types match your search."}):p.jsx("div",{className:"add-block-flat-list",children:yo.flatMap(_=>_.options).map(_=>p.jsxs("button",{type:"button",className:"add-block-option",disabled:vt,onClick:async()=>{var Ce;if(!at||vt)return;lt(!0);const G=(Ce=d.byType.get(_.type))==null?void 0:Ce.defaultProps,se=await Ge.addBlockAfter(at.slug,at.afterBlockId,_.type,at.beforeBlockId,G);lt(!1),se&&Et(null)},children:[p.jsx("span",{className:"add-block-option-label",children:_.label}),p.jsx("span",{className:"add-block-option-actions","aria-hidden":"true",children:p.jsx("span",{className:"add-block-option-plus",children:"+"})})]},_.type))})]})]})}):null,p.jsx(Pse,{open:ie,onOpenChange:qe,useStreaming:O,onStreamingChange:U,showNestedLabels:X,onNestedLabelsChange:z,chatDarkMode:i,chatThemePreference:s,onChatThemePreferenceChange:o,showDebugDetails:Ke,onDebugDetailsChange:bt,fieldDraftDebugEnabled:Br,onFieldDraftDebugChange:it,autoScrollTrackingEnabled:Q,onAutoScrollTrackingChange:le,autoOpenPropertiesEnabled:I,onAutoOpenPropertiesChange:$,provider:A,modelKey:w,availableProviders:j,onModelChange:(_,G)=>{M(_),T(G)},onClearChat:Ge.clearChat,agentModeEnabled:Mr.agentMode??!1,showDevOptions:Ae,onShowDevOptionsChange:ne?ee:void 0}),p.jsx(eoe,{open:_e,onOpenChange:Oe,onConfirm:_=>void _t.publishSite(_),chatLog:Ts,isPublishing:_t.isPublishing,session:n,siteId:r,siteOrigin:u}),p.jsx(MO,{sites:e,onPreviewRefresh:()=>{Zt.postToSite("draftUpdated",{}),Pe()}}),p.jsx(cce,{open:tn,features:{...Mr,googleDrive:Mr.googleDrive||!!((fc=a.gdriveFolderId)!=null&&fc.trim())},currentUrl:Rt==null?void 0:Rt.currentUrl,gdriveFolderId:a.gdriveFolderId,cmsMedia:a.cmsMedia,siteOrigin:u,onClose:()=>zn(null),onSelect:(_,G)=>{var mc;if(!Rt)return;const{slug:se,blockId:Ce,editablePath:Me,currentUrl:Ue,blockType:et}=Rt,dn=WF(Me),or=Me.match(/^([a-zA-Z_]+)\[(\d+)\]\.(.+)$/),Cn=dn!==Me?dn.match(/^([a-zA-Z_]+)\[(\d+)\]\.(.+)$/):null;let rs,Ds;if(or){const[,is,ss,gc]=or,Ba={[gc]:_};Cn&&(Ba[Cn[3]]=G),rs=[{op:"update_item",pageSlug:se,blockId:Ce,listKey:is,index:Number(ss),patch:Ba}],Ds=`${is}[${ss}].${gc}`}else{const is={[Me]:_};dn!==Me&&(is[dn]=G),rs=[{op:"update_props",pageSlug:se,blockId:Ce,patch:is}],Ds=Me}const hc=et??(Ce===B?F:void 0)??(Ce===B&&$n.blockType?$n.blockType:void 0),Hp=hc?((mc=Au()[hc])==null?void 0:mc.displayName)??hc:void 0,pc={imageUrl:_,previousUrl:Ue,altText:G,slug:se,blockId:Ce,editablePath:Me,blockDisplayName:Hp,fieldLabel:Ake(Ds)};(async()=>{try{const is=await fetch(`${Be}/ops`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(Us({session:n,siteId:r,ops:rs},d.manifest))}),ss=await is.json();is.ok&&ss.status==="applied"?(Zt.postToSite("draftUpdated",{focusBlockId:Ce}),Pe(),Ge.pushAssistantFromResult({status:"applied",summary:t("ops.changedImage")},{canUndo:!0,imageSwap:pc}),$n.refetch()):(console.error("[ImagePicker] ops failed:",is.status,ss.error,ss.details??"","ops:",JSON.stringify(rs)),Ge.pushAssistantFromResult({status:"error",summary:t("ops.imageChangeFailed")},{imageSwap:{...pc,imageUrl:Ue??_}}))}catch(is){console.error("[ImagePicker] ops failed:",is),Ge.pushAssistantFromResult({status:"error",summary:t("ops.imageChangeFailed")},{imageSwap:{...pc,imageUrl:Ue??_}})}})()}}),xke?p.jsx(Mee,{onTry:_=>void Ge.submitChat(_),onAction:_=>{_==="heroImage"&&Oa()}}):null]})}const Mg=Be,ck={position:"fixed",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"#0a0a0a",fontFamily:"system-ui, sans-serif",zIndex:99999},dk={display:"flex",flexDirection:"column",gap:12,width:320,padding:32,borderRadius:12,background:"#18181b",border:"1px solid #27272a"},fk={padding:"10px 16px",borderRadius:8,border:"none",background:"#3b82f6",color:"#fff",fontSize:14,fontWeight:500,cursor:"pointer"};function Mke({children:e}){const{t}=Nn(),[n,r]=E.useState("checking"),[i,s]=E.useState(""),[o,a]=E.useState(!1),[u,d]=E.useState(""),[f,m]=E.useState(!1),[g,y]=E.useState(0),v=Math.min(15e3,1500*2**Math.max(0,g-1));E.useEffect(()=>{let w=!0;return r("checking"),fetch(`${Mg}/auth/status`).then(T=>{if(!T.ok)throw new Error(`auth/status ${T.status}`);return T.json()}).then(T=>{if(w){if(T.mode==="closed"){ug(),d(typeof T.reason=="string"?T.reason:""),r("closed");return}if(!T.gateEnabled)ug(),r("open");else{const A=!!localStorage.getItem(aS),M=s2().length>0;r(A&&M?"open":"locked")}}}).catch(()=>{w&&r("unreachable")}),()=>{w=!1}},[g]),E.useEffect(()=>{if(n!=="unreachable")return;const w=setTimeout(()=>y(T=>T+1),v);return()=>clearTimeout(w)},[n,g,v]);const S=async w=>{w.preventDefault(),m(!0),a(!1);try{const T=await fetch(`${Mg}/auth/verify`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:i.trim()})}),A=await T.json().catch(()=>({}));T.ok?(localStorage.setItem(aS,"1"),lae(A.accessToken??""),r("open")):(ug(),a(!0))}catch{ug(),a(!0)}m(!1)};return n==="checking"?null:n==="open"?p.jsx(p.Fragment,{children:e}):n==="closed"?p.jsx("div",{style:ck,children:p.jsxs("div",{style:{...dk,width:420},children:[p.jsx("h2",{style:{margin:0,color:"#fafafa",fontSize:18},children:t("password.closedTitle")}),p.jsx("p",{style:{margin:0,color:"#a1a1aa",fontSize:13,lineHeight:1.5},children:u||t("password.closedBody")}),p.jsx("p",{style:{margin:0,color:"#a1a1aa",fontSize:13,lineHeight:1.5},children:t("password.closedFix")}),p.jsxs("code",{style:{color:"#71717a",fontSize:12,wordBreak:"break-all"},children:[Mg,"/auth/status"]}),p.jsx("button",{type:"button",onClick:()=>y(w=>w+1),style:fk,children:t("password.retry")})]})}):n==="unreachable"?p.jsx("div",{style:ck,children:p.jsxs("div",{style:{...dk,width:380},children:[p.jsx("h2",{style:{margin:0,color:"#fafafa",fontSize:18},children:t("password.unreachableTitle")}),p.jsx("p",{style:{margin:0,color:"#a1a1aa",fontSize:13,lineHeight:1.5},children:t("password.unreachableBody")}),p.jsxs("code",{style:{color:"#71717a",fontSize:12,wordBreak:"break-all"},children:[Mg,"/auth/status"]}),p.jsx("button",{type:"button",onClick:()=>y(w=>w+1),style:fk,children:t("password.retry")}),p.jsx("p",{style:{margin:0,color:"#71717a",fontSize:12},"aria-live":"polite",children:t("password.retryingIn",{seconds:String(Math.round(v/1e3))})})]})}):p.jsx("div",{style:ck,children:p.jsxs("form",{onSubmit:S,style:dk,children:[p.jsx("h2",{style:{margin:0,color:"#fafafa",fontSize:18},children:t("password.title")}),p.jsx("input",{type:"password",value:i,onChange:w=>s(w.target.value),placeholder:t("password.placeholder"),autoFocus:!0,style:{padding:"10px 12px",borderRadius:8,border:o?"1px solid #ef4444":"1px solid #3f3f46",background:"#09090b",color:"#fafafa",fontSize:14,outline:"none"}}),o&&p.jsx("span",{style:{color:"#ef4444",fontSize:13},children:t("password.incorrect")}),p.jsx("button",{type:"submit",disabled:f||!i.trim(),style:{...fk,opacity:f||!i.trim()?.5:1},children:t(f?"password.checking":"password.continue")})]})})}dae();OB.createRoot(document.getElementById("root")).render(p.jsx(E.StrictMode,{children:p.jsxs(FF,{children:[p.jsx(Mke,{children:p.jsx(Tke,{})}),p.jsx(qB,{})]})}));export{jke as $,qre as A,Oke as B,Kre as C,Lw as D,Au as E,Bw as F,dF as G,q4 as H,xp as I,Rce as J,Eee as K,cce as L,Be as M,Kh as N,n6 as O,bn as P,Fx as Q,Vre as R,Loe as S,Vd as T,RF as U,Iee as V,_b as W,NG as X,AG as Y,o6 as Z,WB as _,hd as a,Uk as a0,ce as a1,Ace as a2,Mce as a3,Sa as a4,Ml as a5,lc as a6,Qn as a7,Ar as a8,xt as a9,f5 as aA,Vb as aB,Ode as aC,Pde as aD,Bde as aE,g5 as aF,Jde as aG,p5 as aH,ys as aI,c5 as aJ,h5 as aK,Hde as aL,Kde as aM,qde as aN,yM as aO,efe as aP,wa as aQ,He as aR,Gde as aS,Wde as aT,Hr as aU,qr as aV,Ot as aa,dt as ab,D0e as ac,vD as ad,tC as ae,Zz as af,tI as ag,jge as ah,Mge as ai,b6 as aj,k2 as ak,Yl as al,y2 as am,i5 as an,ld as ao,Q5 as ap,Vhe as aq,co as ar,Ne as as,Jd as at,m5 as au,w2 as av,Fde as aw,zde as ax,Lde as ay,l5 as az,Wn as b,ot as c,sn as d,Tb as e,Fw as f,bI as g,j6 as h,$w as i,p as j,vp as k,Ed as l,C6 as m,Gre as n,Kn as o,Bd as p,HF as q,E as r,kR as s,qF as t,n0 as u,qd as v,$F as w,Cq as x,Sj as y,kj as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as u,r as o,ag as l,ah as b,ai as C,j as a,aj as E}from"./index-
|
|
1
|
+
import{o as u,r as o,ag as l,ah as b,ai as C,j as a,aj as E}from"./index-BKjz-l77.js";import{v as S}from"./index-CrWf8-W0.js";var g=(...n)=>t=>{n.forEach(r=>{typeof r=="function"?r(t):r&&(r.current=t)})},w=({contentComponent:n})=>{const t=l.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot);return a.jsx(a.Fragment,{children:Object.values(t)})};function y(){const n=new Set;let t={};return{subscribe(r){return n.add(r),()=>{n.delete(r)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(r,e){t={...t,[r]:E.createPortal(e.reactElement,e.element,r)},n.forEach(i=>i())},removeRenderer(r){const e={...t};delete e[r],t=e,n.forEach(i=>i())}}}var x=class extends u.Component{constructor(n){var t;super(n),this.editorContentRef=u.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((t=n.editor)!=null&&t.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var n;const t=this.props.editor;if(t&&!t.isDestroyed&&((n=t.view.dom)!=null&&n.parentNode)){if(t.contentComponent)return;const r=this.editorContentRef.current;r.append(...t.view.dom.parentNode.childNodes),t.setOptions({element:r}),t.contentComponent=y(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(e=>e.hasContentComponentInitialized?e:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var n;const t=this.props.editor;if(t){this.initialized=!1,t.isDestroyed||t.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),t.contentComponent=null;try{if(!((n=t.view.dom)!=null&&n.parentNode))return;const r=document.createElement("div");r.append(...t.view.dom.parentNode.childNodes),t.setOptions({element:r})}catch{}}}render(){const{editor:n,innerRef:t,...r}=this.props;return a.jsxs(a.Fragment,{children:[a.jsx("div",{ref:g(t,this.editorContentRef),...r}),(n==null?void 0:n.contentComponent)&&a.jsx(w,{contentComponent:n.contentComponent})]})}},D=o.forwardRef((n,t)=>{const r=u.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return u.createElement(x,{key:r,innerRef:t,...n})}),R=u.memo(D),T=typeof window<"u"?o.useLayoutEffect:o.useEffect,_=class{constructor(n){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=n,this.lastSnapshot={editor:n,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(n){return this.subscribers.add(n),()=>{this.subscribers.delete(n)}}watch(n){if(this.editor=n,this.editor){const t=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},r=this.editor;return r.on("transaction",t),()=>{r.off("transaction",t)}}}};function N(n){var t;const[r]=o.useState(()=>new _(n.editor)),e=b.useSyncExternalStoreWithSelector(r.subscribe,r.getSnapshot,r.getServerSnapshot,n.selector,(t=n.equalityFn)!=null?t:C);return T(()=>r.watch(n.editor),[n.editor,r]),o.useDebugValue(e),e}var I=!1,d=typeof window>"u",M=d||!!(typeof window<"u"&&window.next),j=class p{constructor(t){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=t,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(t){this.editor=t,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(r=>r())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?d||M?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const t={...this.options.current,onBeforeCreate:(...e)=>{var i,s;return(s=(i=this.options.current).onBeforeCreate)==null?void 0:s.call(i,...e)},onBlur:(...e)=>{var i,s;return(s=(i=this.options.current).onBlur)==null?void 0:s.call(i,...e)},onCreate:(...e)=>{var i,s;return(s=(i=this.options.current).onCreate)==null?void 0:s.call(i,...e)},onDestroy:(...e)=>{var i,s;return(s=(i=this.options.current).onDestroy)==null?void 0:s.call(i,...e)},onFocus:(...e)=>{var i,s;return(s=(i=this.options.current).onFocus)==null?void 0:s.call(i,...e)},onSelectionUpdate:(...e)=>{var i,s;return(s=(i=this.options.current).onSelectionUpdate)==null?void 0:s.call(i,...e)},onTransaction:(...e)=>{var i,s;return(s=(i=this.options.current).onTransaction)==null?void 0:s.call(i,...e)},onUpdate:(...e)=>{var i,s;return(s=(i=this.options.current).onUpdate)==null?void 0:s.call(i,...e)},onContentError:(...e)=>{var i,s;return(s=(i=this.options.current).onContentError)==null?void 0:s.call(i,...e)},onDrop:(...e)=>{var i,s;return(s=(i=this.options.current).onDrop)==null?void 0:s.call(i,...e)},onPaste:(...e)=>{var i,s;return(s=(i=this.options.current).onPaste)==null?void 0:s.call(i,...e)},onDelete:(...e)=>{var i,s;return(s=(i=this.options.current).onDelete)==null?void 0:s.call(i,...e)}};return new S(t)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(t){return this.subscriptions.add(t),()=>{this.subscriptions.delete(t)}}static compareOptions(t,r){return Object.keys(t).every(e=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(e)?!0:e==="extensions"&&t.extensions&&r.extensions?t.extensions.length!==r.extensions.length?!1:t.extensions.every((i,s)=>{var h;return i===((h=r.extensions)==null?void 0:h[s])}):t[e]===r[e])}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&t.length===0?p.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(t){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=t;return}if(this.previousDeps.length===t.length&&this.previousDeps.every((e,i)=>e===t[i]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=t}scheduleDestroy(){const t=this.instanceId,r=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===t){r&&r.setOptions(this.options.current);return}r&&!r.isDestroyed&&(r.destroy(),this.instanceId===t&&this.setEditor(null))},1)}};function z(n={},t=[]){const r=o.useRef(n);r.current=n;const[e]=o.useState(()=>new j(r)),i=l.useSyncExternalStore(e.subscribe,e.getEditor,e.getServerSnapshot);return o.useDebugValue(i),o.useEffect(e.onRender(t)),N({editor:i,selector:({transactionNumber:s})=>n.shouldRerenderOnTransaction===!1||n.shouldRerenderOnTransaction===void 0?null:n.immediatelyRender&&s===0?0:s+1}),i}var f=o.createContext({editor:null});f.Consumer;var O=o.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),V=()=>o.useContext(O);u.forwardRef((n,t)=>{const{onDragStart:r}=V(),e=n.as||"div";return a.jsx(e,{...n,ref:t,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...n.style}})});u.createContext({markViewContentRef:()=>{}});var c=o.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});c.displayName="TiptapContext";var P=()=>o.useContext(c);function v({editor:n,instance:t,children:r}){const e=n??t;if(!e)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const i=o.useMemo(()=>({editor:e}),[e]),s=o.useMemo(()=>({editor:e}),[e]);return a.jsx(f.Provider,{value:s,children:a.jsx(c.Provider,{value:i,children:r})})}v.displayName="Tiptap";function m({...n}){const{editor:t}=P();return a.jsx(R,{editor:t,...n})}m.displayName="Tiptap.Content";Object.assign(v,{Content:m});export{R as E,N as a,z as u};
|