@1agh/maude 1.4.0 → 1.4.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.
@@ -5680,10 +5680,10 @@ ${B.block}`:V,F=[],M=new Map;for await(let A of J.prompt(N,X(),K,Q?.(),Y?.(),Z?.
5680
5680
 
5681
5681
  > Maude ${p.app.maudeVersion} · ${p.app.platform} ${p.app.arch} · ${p.app.surface}
5682
5682
  > Local report bundle: \`${e?.dir??".design/_reports/"}\` (attach its files here)`),s=`${dU0}?title=${c}&body=${K0}&labels=report`;if(G8())try{await LV(s)}catch{window.open(s,"_blank","noopener")}else window.open(s,"_blank","noopener");k({fallbackDir:e?.dir??null}),W("done")}catch{$("Saving the local bundle failed too — please file the issue by hand.")}}let h=G.trim().length>0;return z("div",{className:"st-scrim",onClick:m,"data-testid":"report-bug-dialog",children:D("div",{className:"st-dialog rb-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"rb-title",onClick:(p)=>p.stopPropagation(),children:[D("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",id:"rb-title",children:"Report a bug"}),z("button",{type:"button",className:"st-iconbtn",onClick:m,"aria-label":"Close",children:"×"})]}),D("div",{className:"st-dialog-bd rb-body",children:[Y==="describe"&&D(Q0,{children:[z("label",{className:"rb-label",htmlFor:"rb-desc",children:"What happened? What did you expect instead?"}),z("textarea",{id:"rb-desc",className:"textarea","data-testid":"report-bug-description",rows:5,autoFocus:!0,value:G,onChange:(p)=>Z(p.target.value),placeholder:"e.g. Clicking Export → PNG shows a spinner forever…"}),z("p",{className:"rb-hint",children:"Next you'll see exactly what gets attached — nothing is sent until you approve it."}),D("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:m,children:"Cancel"}),z("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-preview",disabled:!h,onClick:()=>W("preview"),children:"Review & attach"})]})]}),Y==="preview"&&D(Q0,{children:[D("div",{className:"rb-section",children:[D("div",{className:"rb-section-hd",children:[D("span",{children:["Screenshots (",U.length,")"]}),D("span",{className:"rb-hd-actions",children:[U.length<qE&&z("button",{type:"button",className:"rb-link","data-testid":"report-bug-attach",onClick:x,children:"Attach screenshot…"}),U.length>0&&z("button",{type:"button",className:`rb-link${w?" is-on":""}`,"data-testid":"report-bug-redact",onClick:()=>O((p)=>!p),children:w?"Done redacting":"Redact…"})]})]}),D("p",{className:"rb-hint",children:["Maude captures its own window and the active artboard for you. The window shot is a fresh render, so anything mid-flight — an open menu, a stuck spinner — won't be in it: grab that yourself (",cU0(H?.app?.platform),") and attach or paste (⌘V) it here."]}),A&&z("p",{className:"rb-hint","data-testid":"report-bug-shell-pending",children:"Capturing the Maude window…"}),U.length===0&&!A?D("p",{className:"rb-hint",children:["No screenshot attached yet — up to ",qE,"."]}):D(Q0,{children:[w&&z("p",{className:"rb-hint",children:"Drag over anything private — it ships as solid black."}),z("div",{className:"rb-shots",children:U.map((p,v)=>z(nU0,{shot:p,redacting:w,onRects:(r)=>V((e)=>e.map((c,K0)=>K0===v?{...c,rects:r}:c)),onRemove:()=>{URL.revokeObjectURL(p.url),V((r)=>r.filter((e,c)=>c!==v))}},p.url))})]})]}),D("div",{className:"rb-section",children:[z("div",{className:"rb-section-hd",children:z("span",{children:"Included with the report"})}),D("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:!0,disabled:!0}),D("span",{children:["Maude ",H?.app?.maudeVersion??"…"," · ",H?.app?.platform??"…"," ",H?.app?.arch??""," · ",G8()?"desktop app":"browser"]})]}),Q&&D("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.activeCanvas,onChange:(p)=>M({...F,activeCanvas:p.target.checked})}),D("span",{children:["Active canvas path — ",z("code",{children:Q})]})]}),H?.context?.projectName&&D("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.projectName,onChange:(p)=>M({...F,projectName:p.target.checked})}),D("span",{children:["Project name — ",z("code",{children:H.context.projectName})]})]}),H?.logs?.serverLogTail?D("label",{className:"rb-check",children:[z("input",{type:"checkbox","data-testid":"report-bug-consent-logs",checked:F.logTail,onChange:(p)=>M({...F,logTail:p.target.checked})}),D("span",{children:["Recent server log (",H.logs.serverLogTail.split(`
5683
- `).length," lines, paths & secrets scrubbed)",H?.process?` + server memory (${Math.round(H.process.rssBytes/1048576)} MB)`:""," ","—"," ",D("details",{className:"rb-details",children:[z("summary",{children:"view"}),z("pre",{className:"rb-log",children:H.logs.serverLogTail})]})]})]}):null,G8()&&B.length>0&&D("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.crashLogs,onChange:(p)=>M({...F,crashLogs:p.target.checked})}),D("span",{children:["Crash logs (",B.length,") — ",z("code",{children:B.map((p)=>p.name).join(", ")})]})]})]}),D("p",{className:"rb-hint",children:["Your description and the system info above become a"," ",z("strong",{children:"public GitHub issue"}),"; screenshots and logs go to a private repository only maintainers can open."]}),D("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("describe"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-send",onClick:a,children:"Send report"})]})]}),Y==="sending"&&z("p",{className:"rb-hint",children:"Sending your report…"}),Y==="done"&&D(Q0,{children:[I?.issueUrl?D("p",{children:["Thank you — your report is filed as"," ",D("button",{type:"button",className:"rb-link","data-testid":"report-bug-issue-link",onClick:()=>{if(G8())LV(I.issueUrl).catch(()=>navigator.clipboard?.writeText(I.issueUrl));else window.open(I.issueUrl,"_blank","noopener")},children:["report #",I.issueNumber]})," ","on the public Maude issue tracker. Screenshots and logs stay in a private repository only maintainers can open — the issue links to them."]}):D("p",{children:["The bundle is saved locally",I?.fallbackDir?D(Q0,{children:[" ","at ",z("code",{children:I.fallbackDir})]}):null," ","and a prefilled GitHub issue was opened — attach the bundle files there."]}),z("footer",{className:"rb-actions",children:z("button",{type:"button",className:"st-btn rb-primary",onClick:m,children:"Done"})})]}),Y==="fallback"&&D(Q0,{children:[z("p",{className:"rb-error","data-testid":"report-bug-error",children:R}),z("p",{className:"rb-hint",children:"You can save the report locally instead and file it on GitHub yourself — the prefilled issue carries the text; screenshots stay on this machine unless you attach them by hand."}),D("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("preview"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary",onClick:f,children:"Save locally & open GitHub"})]})]})]})]})})}var TJ=j9(s9(),1);function Am(J){if(typeof J!=="string")return null;let X=J.match(/^(\d+)\.(\d+)\.(\d+)/);return X?[Number(X[1]),Number(X[2]),Number(X[3])]:null}function _m(J,X){let Q=Am(J),Y=Am(X);if(!Q)return!1;if(!Y)return!0;for(let W=0;W<3;W++)if(Q[W]!==Y[W])return Q[W]>Y[W];return!1}function wm(J,X){if(!Array.isArray(J))return[];return J.filter((Q)=>Q&&(Q.version==null||_m(Q.version,X)))}function Em(J,X){let Q=X;if(Array.isArray(J)){for(let Y of J)if(Y&&Y.version&&_m(Y.version,Q))Q=Y.version}return Q}var BE="mdcc-whatsnew-seen",NE="mdcc-whatsnew-toast-dismissed";function rU0(J){return typeof J==="string"&&/^https?:\/\//i.test(J)}function aU0(J){try{let X=localStorage.getItem(BE);if(X)return X;localStorage.setItem(BE,J)}catch{}return J}function sU0(){try{return localStorage.getItem(NE)}catch{return null}}function Pm(J){let[X,Q]=TJ.useState([]),[Y,W]=TJ.useState(J),[G,Z]=TJ.useState(()=>aU0(J)),[H,K]=TJ.useState(()=>sU0()),[U,V]=TJ.useState(!1);TJ.useEffect(()=>{let O=!1,I=()=>{fetch("/_api/whats-new").then(($)=>$.json()).then(($)=>{if(O)return;if(Q(Array.isArray($?.entries)?$.entries:[]),typeof $?.version==="string")W($.version)}).catch(()=>{})};I();let k=()=>I(),R=()=>{if(document.visibilityState==="visible")I()};return window.addEventListener("focus",k),document.addEventListener("visibilitychange",R),()=>{O=!0,window.removeEventListener("focus",k),document.removeEventListener("visibilitychange",R)}},[]);let B=wm(X,G),N=B.length>0&&H!==Y&&!U,F=B[0]??null,M=TJ.useCallback(()=>{let O=Em(X,Y);Z(O),K(Y);try{localStorage.setItem(BE,O),localStorage.setItem(NE,Y)}catch{}},[X,Y]),A=TJ.useCallback(()=>{K(Y);try{localStorage.setItem(NE,Y)}catch{}},[Y]),E=TJ.useCallback(()=>V(!0),[]),w=TJ.useCallback(()=>{V(!1),M()},[M]);return{entries:X,unseen:B,feedVersion:Y,panelOpen:U,openPanel:E,closePanel:w,showToast:N,toastEntry:F,dismissToast:A,markAllSeen:M}}function Im({wn:J}){let X=`whats-new-${J.feedVersion}`;return TJ.useEffect(()=>{if(!J.showToast||!J.toastEntry){$W(X);return}PQ({id:X,group:"whats-new",kind:"info",duration:1e4,title:`What's new${J.toastEntry.version?` · v${J.toastEntry.version}`:""} — ${J.toastEntry.title}`,description:J.toastEntry.summary,action:{label:J.unseen.length>1?`See all (${J.unseen.length})`:"Details",onClick:J.openPanel},onDismiss:J.dismissToast})},[X,J.showToast,J.toastEntry,J.unseen.length,J.openPanel,J.dismissToast]),TJ.useEffect(()=>()=>$W(X),[X]),null}function Tm({wn:J,onStartTour:X}){let{panelOpen:Q,closePanel:Y}=J;if(TJ.useEffect(()=>{if(!Q)return;function G(Z){if(Z.key==="Escape")Y()}return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[Q,Y]),!Q)return null;let W=new Set(J.unseen.map((G)=>G.id));return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)Y()},children:D("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[D("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"mdcc-wn-title",children:"✦ What’s new in maude"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:Y,children:"×"})]}),z("div",{className:"mdcc-wn-panel__body",children:J.entries.length===0?z("p",{className:"mdcc-wn-empty",children:"Nothing new yet."}):z("ul",{className:"mdcc-wn-list",children:J.entries.map((G)=>D("li",{className:"mdcc-wn-item"+(W.has(G.id)?" is-unseen":""),children:[D("div",{className:"mdcc-wn-item__hd",children:[z("span",{className:"mdcc-wn-kind mdcc-wn-kind--"+G.kind,children:G.kind}),z("span",{className:"mdcc-wn-item__title",children:G.title}),z("span",{className:"mdcc-wn-item__ver",children:G.version?`v${G.version}`:"next"})]}),z("p",{className:"mdcc-wn-item__summary",children:G.summary}),rU0(G.learnMore)&&z("a",{className:"mdcc-wn-item__more",href:G.learnMore,target:"_blank",rel:"noreferrer",children:"Learn more →"}),X&&Array.isArray(G.tour)&&G.tour.length>0&&z("button",{type:"button",className:"mdcc-wn-item__tour",onClick:()=>{Y(),X(G.tour)},children:"▶ Take tour"})]},G.id))})})]})})}var K7=({as:J,size:X=14})=>z(J,{size:X,strokeWidth:1.75,style:{display:"block"}}),x90="mdcc-usage-tour-seen",h90="mdcc-collab-tour-seen",r9="__system__",M80="mdcc-theme",g90="mdcc-show-hidden",m90="mdcc-sections-expanded",u90="maude-cp-mode",p90="mdcc-sidebar-open",l90="mdcc-minimap-visible",d90="mdcc-zoomctl-visible",c90="mdcc-annotations-visible";var ZF0=30000;function HF0(J){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(J)}).catch(()=>{})}catch{}}var Wk=[{id:"tree",label:"Files"},{id:"layers",label:"Layers"},{id:"inspector",label:"Inspector"},{id:"comments",label:"Comments"},{id:"changes",label:"Changes"},{id:"sync",label:"Sync"},{id:"assistant",label:"Assistant"}],sK={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",sync:"right",assistant:"right"},i90="mdcc-panel-sides",o90="mdcc-layers-mode";function n90({side:J,width:X,open:Q,ids:Y,activeId:W,onPick:G,children:Z,labels:H=null}){return D("div",{className:"st-dockslot st-dockslot--"+J+(Q?"":" is-collapsed"),style:{width:Q?X:0,flexBasis:Q?X:0},children:[Q&&Y.length>1&&z("div",{className:"st-docktabs",role:"tablist","aria-label":J+" panels",children:Y.map((K)=>z("button",{type:"button",role:"tab","data-testid":`dock-tab-${K}`,"aria-selected":W===K,className:"st-docktab"+(W===K?" is-active":""),onClick:()=>G(K),children:H?.[K]||(Wk.find((U)=>U.id===K)||{}).label||K},K))}),Z]})}var yQ=/\.(tsx|html?)$/i,zF0=[[/\.md$/i,"markdown"],[/\.(css|json|txt|ya?ml)$/i,"text"],[/\.(svg|png|jpe?g|gif|webp|avif)$/i,"image"],[/\.(mp4|webm|mov)$/i,"video"],[/\.(mp3|wav|ogg|m4a)$/i,"audio"],[/\.(woff2?|ttf|otf)$/i,"font"]];function BL(J){for(let[X,Q]of zF0)if(X.test(J))return Q;return null}function Bq(J){return J.replace(/^\.[^/]+\//,"").replace(yQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}function KF0(J){let X=[];return function Q(Y){for(let W of Y||[])X.push(W?.id??""),Q(W?.children)}(J),X.join(",")}var Gk="1.4.0";function YL(J,X){let Q=()=>{try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(J,{body:X})}catch{}};if(G8()){O7("send_notification",{title:J,body:X}).catch(Q);return}Q()}function UF0(){if(typeof window>"u")return"dark";try{let J=localStorage.getItem(M80);if(J==="light"||J==="dark")return J}catch{}return"dark"}function IH(J,X){if(typeof window>"u")return X;try{let Q=localStorage.getItem(J);if(Q==="1")return!0;if(Q==="0")return!1}catch{}return X}function Jk(J,X){if(typeof window>"u")return X;try{let Q=localStorage.getItem(J);return Q?JSON.parse(Q):X}catch{return X}}function VF0(J){if(J.kind==="runtime")return!1;if(J.label==="Design system")return!1;return!0}function Y4(J){return J.split("/").pop()}function f9(J,X=!1,Q){PQ({title:J,kind:X?"success":"error",action:Q})}var r90="maude-mode-hint-seen";function ZL(J=!1){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(r90)==="1")return}catch{return}if(ZL.active)return;ZL.active=!0;let X=()=>{ZL.active=!1;try{localStorage.setItem(r90,"1")}catch{}document.removeEventListener("keydown",Q,!0)},Q=(Y)=>{if((Y.key==="v"||Y.key==="V")&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey)$W("mode-hint"),X()};if(J)document.addEventListener("keydown",Q,!0);PQ({id:"mode-hint",title:J?"Your mock is live":"You’re in Edit",description:J?"Click things to try it. Press V to select & inspect.":"Click selects, like Figma. Switch to Preview in the toolbar to use the live mock.",onDismiss:X})}function VY(J){return J.replace(yQ,"")}function qF0(J){return J.replace(yQ,"")}function BF0(J){let X=new Map;for(let G of J){if(!yQ.test(G.name))continue;let Z=qF0(G.name);if(!X.has(Z)||/\.tsx$/i.test(G.name))X.set(Z,G)}let Q=new Map,Y=[];for(let G of J){if(yQ.test(G.name))continue;let Z=null;for(let H of X.keys()){if(G.name===H)continue;if(G.name.startsWith(`${H}.`)){if(!Z||H.length>Z.length)Z=H}}if(Z){let H=Q.get(Z)||[];H.push(G),Q.set(Z,H)}else Y.push(G)}let W=[];for(let[G,Z]of X){let H=(Q.get(G)||[]).sort((K,U)=>K.name.localeCompare(U.name));W.push({primary:Z,sidecars:H,orphan:!1})}return W.sort((G,Z)=>G.primary.name.localeCompare(Z.primary.name)),Y.sort((G,Z)=>G.name.localeCompare(Z.name)),{canvases:W,orphans:Y.map((G)=>({primary:G,sidecars:[],orphan:!0}))}}function NF0(J,X,Q){let Y={};for(let W of Q||[]){let Z=(W.startsWith(X)?W.slice(X.length).replace(/^\/+/,""):W).split("/").filter(Boolean),H=Y;for(let K of Z)H=H[K]=H[K]||{};H._files=H._files||[]}for(let W of J){let Z=(W.startsWith(X)?W.slice(X.length).replace(/^\/+/,""):W).split("/"),H=Y;for(let K=0;K<Z.length;K++){let U=Z[K];if(K===Z.length-1)H._files=H._files||[],H._files.push({name:U,path:W});else H[U]=H[U]||{},H=H[U]}}return Y}function O80(J,X){if(!X)return J;let Q=X.toLowerCase(),Y={},W=!1,G=Object.keys(J).filter((Z)=>Z!=="_files");for(let Z of G){let H=O80(J[Z],X);if(H)Y[Z]=H,W=!0}if(J._files){let Z=J._files.filter((H)=>H.name.toLowerCase().includes(Q)||H.path.toLowerCase().includes(Q));if(Z.length)Y._files=Z,W=!0}return W?Y:null}function HL(J){return(J||[]).filter((X)=>X.status!=="resolved").length}function FF0(J){if(!J)return"";let X=new Date(J).getTime();if(!X)return"";let Q=Math.max(0,Math.floor((Date.now()-X)/1000));if(Q<60)return Q+"s";let Y=Math.floor(Q/60);if(Y<60)return Y+"m";let W=Math.floor(Y/60);if(W<24)return W+"h";let G=Math.floor(W/24);if(G<7)return G+"d";return new Date(J).toLocaleDateString()}function A80(J){let X=0,Q=0,Y=0;for(let W of Object.values(J||{}))for(let G of W||[])if(X++,G.status==="resolved")Y++;else Q++;return{all:X,open:Q,resolved:Y}}function KL({d:J,size:X=14,color:Q}){return z("svg",{width:X,height:X,viewBox:"0 0 24 24",fill:"none",stroke:Q||"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{flex:"none"},children:z("path",{d:J})})}var LF0={"chevron-down":z("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":z("polyline",{points:"6 3.5 10.5 8 6 12.5"}),file:D(Q0,{children:[z("path",{d:"M4 2h5l3 3v9H4z"}),z("polyline",{points:"9 2 9 5 12 5"})]}),folder:z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),"folder-plus":D(Q0,{children:[z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),z("path",{d:"M8 7.5v3.5M6.25 9.25h3.5"})]}),lock:D(Q0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015 0v2"})]}),unlock:D(Q0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015-.7"})]}),search:D(Q0,{children:[z("circle",{cx:"7",cy:"7",r:"4"}),z("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:D(Q0,{children:[z("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),z("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),check:z("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),x:D(Q0,{children:[z("line",{x1:"4.3",y1:"4.3",x2:"11.7",y2:"11.7"}),z("line",{x1:"11.7",y1:"4.3",x2:"4.3",y2:"11.7"})]}),sun:D(Q0,{children:[z("circle",{cx:"8",cy:"8",r:"2.6"}),z("line",{x1:"8",y1:"1.5",x2:"8",y2:"3"}),z("line",{x1:"8",y1:"13",x2:"8",y2:"14.5"}),z("line",{x1:"1.5",y1:"8",x2:"3",y2:"8"}),z("line",{x1:"13",y1:"8",x2:"14.5",y2:"8"}),z("line",{x1:"3.4",y1:"3.4",x2:"4.4",y2:"4.4"}),z("line",{x1:"11.6",y1:"11.6",x2:"12.6",y2:"12.6"}),z("line",{x1:"12.6",y1:"3.4",x2:"11.6",y2:"4.4"}),z("line",{x1:"4.4",y1:"11.6",x2:"3.4",y2:"12.6"})]}),moon:z("path",{d:"M12.5 9.6A5 5 0 1 1 7 3a4 4 0 0 0 5.5 6.6z"}),sparkle:z("path",{d:"M8 1.8l1.4 4.8L14 8l-4.6 1.4L8 14.2l-1.4-4.8L2 8l4.6-1.4z",fill:"currentColor",stroke:"none"}),megaphone:D(Q0,{children:[z("path",{d:"M2 6.7 11 4v8L2 9.3z"}),z("path",{d:"M11 5.2a2.4 2.4 0 0 1 0 5.6"}),z("path",{d:"M4.3 9.5v2.3a1.2 1.2 0 0 0 2.4 0v-1.7"})]}),bug:D(Q0,{children:[z("circle",{cx:"8",cy:"9",r:"3.6"}),z("circle",{cx:"8",cy:"4.4",r:"1.3"}),z("path",{d:"M6.2 3.4 5.2 2M9.8 3.4l1-1.4"}),z("path",{d:"M4.6 7.6H2.2M4.6 9H2.2M4.6 10.6H2.5M11.4 7.6h2.4M11.4 9h2.4M11.4 10.6h2.3"})]}),"panel-left":D(Q0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("line",{x1:"6.4",y1:"3",x2:"6.4",y2:"13"})]}),resolve:D(Q0,{children:[z("circle",{cx:"8",cy:"8",r:"5.6"}),z("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:D(Q0,{children:[z("path",{d:"M3.2 8a5 5 0 1 1 1.4 3.5"}),z("polyline",{points:"3.2 11.4 3.2 8 6.6 8"})]}),layers:D(Q0,{children:[z("polygon",{points:"8 2.2 13.8 5.5 8 8.8 2.2 5.5"}),z("polyline",{points:"2.2 9 8 12.3 13.8 9"})]}),box:z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.2"}),type:D(Q0,{children:[z("polyline",{points:"4 4 12 4"}),z("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:D(Q0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"3"}),z("line",{x1:"6",y1:"8",x2:"10",y2:"8"})]}),input:D(Q0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"1.2"}),z("line",{x1:"5",y1:"8",x2:"5",y2:"8"})]}),link:D(Q0,{children:[z("path",{d:"M6.5 9.5a2.5 2.5 0 0 1 0-3.5l1.5-1.5a2.5 2.5 0 0 1 3.5 3.5l-1 1"}),z("path",{d:"M9.5 6.5a2.5 2.5 0 0 1 0 3.5l-1.5 1.5a2.5 2.5 0 0 1-3.5-3.5l1-1"})]}),list:D(Q0,{children:[z("line",{x1:"6",y1:"4.5",x2:"13",y2:"4.5"}),z("line",{x1:"6",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6",y1:"11.5",x2:"13",y2:"11.5"}),z("circle",{cx:"3.2",cy:"4.5",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"8",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"11.5",r:"0.8",fill:"currentColor"})]}),eye:D(Q0,{children:[z("path",{d:"M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z"}),z("circle",{cx:"8",cy:"8",r:"2"})]}),eyedropper:D(Q0,{children:[z("path",{d:"M11 2.6a1.7 1.7 0 0 1 2.4 2.4l-1.2 1.2-2.4-2.4z"}),z("path",{d:"M9.5 4.6 4 10.1V12h1.9l5.5-5.5"})]}),"p-corner":z("path",{d:"M3.5 12.5V7a3.5 3.5 0 0 1 3.5-3.5h5.5"}),"p-opacity":D(Q0,{children:[z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.5"}),z("path",{d:"M3 8h10M8 3v10",strokeWidth:"0.9",opacity:"0.55"})]}),"p-lineheight":D(Q0,{children:[z("line",{x1:"6.5",y1:"4",x2:"13",y2:"4"}),z("line",{x1:"6.5",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6.5",y1:"12",x2:"13",y2:"12"}),z("path",{d:"M3.2 4.6 3.2 11.4M2 6 3.2 4.5 4.4 6M2 10 3.2 11.5 4.4 10"})]}),"p-letterspacing":D(Q0,{children:[z("path",{d:"M3 4v8M13 4v8"}),z("path",{d:"M6 11.5 8 5l2 6.5M6.7 9.3h2.6",strokeWidth:"1.1"})]}),"p-gap":D(Q0,{children:[z("rect",{x:"2",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("rect",{x:"10.4",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("path",{d:"M6.8 8h2.4M7.4 6.9 6.4 8l1 1.1M8.6 6.9 9.6 8l-1 1.1",strokeWidth:"1"})]}),"p-border":z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"}),"p-size":D(Q0,{children:[z("path",{d:"M3 13 6.6 3l3.6 10"}),z("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":D(Q0,{children:[z("path",{d:"M6.3 4A6.7 6.7 0 0 1 8 3.5C12 3.5 14.5 8 14.5 8a12 12 0 0 1-2 2.4M4.4 5.3A12 12 0 0 0 1.5 8S4 12.5 8 12.5a6.5 6.5 0 0 0 2.1-.35"}),z("line",{x1:"2.5",y1:"2.5",x2:"13.5",y2:"13.5"})]}),sliders:D(Q0,{children:[z("line",{x1:"3",y1:"5",x2:"13",y2:"5"}),z("circle",{cx:"6",cy:"5",r:"1.7",fill:"currentColor"}),z("line",{x1:"3",y1:"11",x2:"13",y2:"11"}),z("circle",{cx:"10",cy:"11",r:"1.7",fill:"currentColor"})]}),code:D(Q0,{children:[z("polyline",{points:"6 5 3 8 6 11"}),z("polyline",{points:"10 5 13 8 10 11"})]}),download:D(Q0,{children:[z("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),z("polyline",{points:"4.5 7 8 10.5 11.5 7"}),z("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),reload:D(Q0,{children:[z("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),z("path",{d:"M14 2v3.33h-3.33"})]}),help:D(Q0,{children:[z("circle",{cx:"8",cy:"8",r:"6"}),z("path",{d:"M6.3 6.2a1.8 1.8 0 1 1 2.3 1.9c-.5.2-.6.5-.6 1v.3"}),z("line",{x1:"8",y1:"11.4",x2:"8",y2:"11.5"})]}),image:D(Q0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("circle",{cx:"6",cy:"6.3",r:"1.1"}),z("path",{d:"M3 12l3-2.8 2.2 1.8 2.4-3L13.5 12"})]}),vector:D(Q0,{children:[z("path",{d:"M3.6 11.2C6 5 10 5 12.4 11.2"}),z("rect",{x:"1.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"11.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"6.7",y:"2.6",width:"2.6",height:"2.6",rx:"0.4"})]}),presentation:D(Q0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"7.4",rx:"1"}),z("line",{x1:"8",y1:"10.4",x2:"8",y2:"13"}),z("line",{x1:"5.6",y1:"13.4",x2:"10.4",y2:"13.4"})]}),archive:D(Q0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"3",rx:"0.8"}),z("path",{d:"M3.6 6v6.2a1 1 0 0 0 1 1h6.8a1 1 0 0 0 1-1V6"}),z("line",{x1:"6.6",y1:"8.8",x2:"9.4",y2:"8.8"})]}),external:D(Q0,{children:[z("path",{d:"M11 8.5V12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h3.5"}),z("polyline",{points:"9.5 3 13 3 13 6.5"}),z("line",{x1:"13",y1:"3",x2:"7.6",y2:"8.4"})]}),share:D(Q0,{children:[z("circle",{cx:"4",cy:"8",r:"1.9"}),z("circle",{cx:"11.6",cy:"3.6",r:"1.9"}),z("circle",{cx:"11.6",cy:"12.4",r:"1.9"}),z("line",{x1:"5.7",y1:"7",x2:"9.9",y2:"4.6"}),z("line",{x1:"5.7",y1:"9",x2:"9.9",y2:"11.4"})]}),pen:D(Q0,{children:[z("path",{d:"M3 13l.8-3L10.6 3.2a1.1 1.1 0 0 1 1.6 0l.6.6a1.1 1.1 0 0 1 0 1.6L6 12.2z"}),z("line",{x1:"9.6",y1:"4.2",x2:"11.8",y2:"6.4"})]}),square:z("rect",{x:"3.5",y:"3.5",width:"9",height:"9",rx:"1"})};function DF0({open:J,onClose:X,actions:Q}){let[Y,W]=u.useState(""),[G,Z]=u.useState(0),H=u.useRef(null);u.useEffect(()=>{if(J)W(""),Z(0)},[J]),u.useEffect(()=>{H.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[G]);let K=u.useMemo(()=>{let V=Y.trim().toLowerCase();if(!V)return Q;return Q.filter((B)=>B.label.toLowerCase().includes(V)||B.group&&B.group.toLowerCase().includes(V))},[Y,Q]);if(u.useEffect(()=>{if(G>=K.length)Z(0)},[K.length,G]),!J)return null;let U=(V)=>{X(),V.run()};return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(V)=>{if(V.target===V.currentTarget)X()},children:D("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[D("div",{className:"st-pal-search",children:[z(T8,{name:"search",size:18}),z("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(V)=>W(V.target.value),onKeyDown:(V)=>{if(V.key==="Escape")V.preventDefault(),X();else if(V.key==="ArrowDown")V.preventDefault(),Z((B)=>Math.min(K.length-1,B+1));else if(V.key==="ArrowUp")V.preventDefault(),Z((B)=>Math.max(0,B-1));else if(V.key==="Enter"){if(V.preventDefault(),K[G])U(K[G])}}}),z(CJ,{children:"⌘K"})]}),z("div",{className:"st-pal-list",ref:H,children:K.length===0?z("div",{className:"st-pal-empty",children:"No matching command."}):K.map((V,B)=>{let N=V.group&&(B===0||K[B-1].group!==V.group)?z("div",{className:"st-pal-group",children:V.group},"g-"+V.group):null;return D(Q0,{children:[N,D("button",{type:"button",className:"st-pal-item"+(B===G?" is-active":""),onMouseEnter:()=>Z(B),onClick:()=>U(V),children:[z("span",{className:"st-pal-icon",children:z(T8,{name:V.icon,size:15})}),z("span",{className:"st-pal-label",children:V.label}),V.kbd?z("span",{className:"st-pal-kbd",children:z(CJ,{children:V.kbd})}):null]})]},V.id)})})]})})}function T8({name:J,size:X=16,className:Q}){return z("svg",{className:Q,width:X,height:X,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:LF0[J]})}function MF0(J){if(!J||typeof J!=="string")return"?";let X=J.trim().split(/[\s._-]+/).filter(Boolean);if(!X.length)return"?";if(X.length===1)return X[0].slice(0,2).toUpperCase();return((X[0][0]||"")+(X[X.length-1][0]||"")).toUpperCase()||"?"}function a90({initials:J,hue:X,title:Q,pulse:Y}){return z("span",{className:"st-avatar"+(Y?" is-pulsing":""),style:{"--av-hue":X},"data-tip":Q,"aria-label":Q,children:J})}function CJ({children:J}){return z("span",{className:"kbd",children:J})}function s90(J,{min:X,max:Q,def:Y}){let W=u.useCallback((K)=>Math.min(Q,Math.max(X,K)),[X,Q]),[G,Z]=u.useState(()=>{try{let K=parseInt(localStorage.getItem(J)||"",10);return Number.isFinite(K)?W(K):Y}catch{return Y}});u.useEffect(()=>{try{localStorage.setItem(J,String(G))}catch{}},[J,G]);let H=u.useCallback((K)=>Z((U)=>W(typeof K==="function"?K(U):K)),[W]);return{w:G,setW:H,min:X,max:Q,def:Y}}function t90({label:J,size:X,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:K,def:U}=X,V=W==="rtl"?-1:1;return z("div",{className:"st-grip"+(Y?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":J,"aria-valuemin":H,"aria-valuemax":K,"aria-valuenow":Math.round(G),onPointerDown:Q,onDoubleClick:()=>Z(U),onKeyDown:(B)=>{let N=B.shiftKey?24:8;if(B.key==="ArrowRight")B.preventDefault(),Z((F)=>F+N*V);else if(B.key==="ArrowLeft")B.preventDefault(),Z((F)=>F-N*V);else if(B.key==="Home")B.preventDefault(),Z(H);else if(B.key==="End")B.preventDefault(),Z(K)},children:D("svg",{className:"st-grip-dots",viewBox:"0 0 6 18","aria-hidden":"true",children:[z("circle",{cx:"3",cy:"3",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"9",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"15",r:"1.1",fill:"currentColor"})]})})}var Xk=[{id:"png",label:"PNG",sub:"raster · 2×",icon:"image",format:"png",options:{scale:2}},{id:"pdf",label:"PDF",sub:"vector · print",icon:"file",format:"pdf"},{id:"svg",label:"SVG",sub:"per artboard",icon:"vector",format:"svg"},{id:"html",label:"HTML",sub:"self-contained",icon:"code",format:"html"},{id:"pptx",label:"PPTX",sub:"slides",icon:"presentation",format:"pptx"},{id:"mp4",label:"MP4",sub:"video · H.264",icon:"presentation",format:"mp4",temporal:!0},{id:"gif",label:"GIF",sub:"animated",icon:"image",format:"gif",temporal:!0},{id:"canva",label:"Canva",sub:"handoff bundle",icon:"external",format:"canva"},{id:"zip",label:"ZIP",sub:"project bundle",icon:"archive",format:"zip"},{id:"shadcn",label:"AI handoff",sub:"production drop",icon:"sparkle",handoff:!0}],e90={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},OF0=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],Kq=[{id:"1x",label:"1× (native)",kind:"scale",value:1},{id:"2x",label:"2× (retina)",kind:"scale",value:2},{id:"3x",label:"3× (max)",kind:"scale",value:3},{id:"dpi150",label:"150 dpi",kind:"dpi",value:150},{id:"dpi300",label:"300 dpi (print)",kind:"dpi",value:300},{id:"dpi600",label:"600 dpi (high-res print)",kind:"dpi",value:600}],AF0="2x",J80=[{id:"auto",label:"Auto (1×)",value:void 0},{id:"dpi150",label:"150 dpi",value:150},{id:"dpi300",label:"300 dpi (print)",value:300},{id:"dpi600",label:"600 dpi (high-res print)",value:600}],_F0="auto",X80=[{id:"keep",label:"Keep selectable (default)",description:"Text stays selectable and searchable. You are warned if a font came out unprintable."},{id:"embed",label:"Verify fonts embedded",description:"Same file, but the export fails instead of shipping a font a print shop would reject."},{id:"outline",label:"Convert to outlines (print-safe)",description:"Every glyph becomes a vector path — no fonts left to break. Text is no longer selectable "+"and the file can grow a lot. Needs Ghostscript installed locally; cloud workspaces have it."}],wF0="keep",EF0={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",avif:"image/avif",svg:"image/svg+xml",mp4:"video/mp4",mov:"video/quicktime",webm:"video/webm",m4v:"video/mp4",ogg:"video/ogg",mp3:"audio/mpeg",wav:"audio/wav",m4a:"audio/mp4",aac:"audio/aac",flac:"audio/flac",oga:"audio/ogg",opus:"audio/opus"};function PF0(J){let X=String(J||"").split(".").pop()?.toLowerCase();return EF0[X]||"application/octet-stream"}function IF0({designRel:J,onPick:X,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[Z,H]=u.useState(null),[K,U]=u.useState(!1),[V,B]=u.useState(null),[N,F]=u.useState(()=>new Set),[M,A]=u.useState({}),[E,w]=u.useState(W?"artboard":"annotation");u.useEffect(()=>{let f=!0;return fetch("/_api/assets").then((h)=>h.json()).then((h)=>{if(!f)return;let p=h.ok?h.assets:[];H(p),A((v)=>{let r={...v};for(let e of p)r[e.path]=e.kind;return r})}).catch(()=>f&&H([])),()=>{f=!1}},[]),u.useEffect(()=>{let f=(h)=>{if(h.key==="Escape")h.stopPropagation(),Q()};return window.addEventListener("keydown",f,!0),()=>window.removeEventListener("keydown",f,!0)},[Q]);let O=Array.from(N).some((f)=>(M[f]||"image")!=="image"),I=!W||O,k=!W?"No artboard on this canvas":O?"Video/audio can only be added as annotations":"";u.useEffect(()=>{if(I&&E==="artboard")w("annotation")},[I,E]);let R=(f)=>{F((h)=>{let p=new Set(h);if(p.has(f))p.delete(f);else p.add(f);return p})},$=async(f)=>{let h=await fetch("/_api/asset",{method:"POST",headers:{"content-type":f.type||"application/octet-stream"},body:f}),p=await h.json().catch(()=>({}));if(h.ok&&p.path)return{ok:!0,path:p.path};return{ok:!1,error:p.error||`upload failed (HTTP ${h.status})`}},C=async(f)=>{if(!f)return;U(!0),B(null);let h=await $(f);if(U(!1),h.ok)X(h.path);else B(h.error)},j=(f)=>{if(typeof f==="string"&&f.startsWith("video/"))return"video";if(typeof f==="string"&&f.startsWith("audio/"))return"audio";return"image"},x=async(f)=>{if(!f.length)return;U(!0),B(null);let h=await Promise.all(f.map((r)=>$(r).then((e)=>({...e,file:r}))));U(!1);let p=h.filter((r)=>r.ok),v=h.length-p.length;if(v>0)B(`${v} of ${h.length} uploads failed`);if(p.length)A((r)=>{let e={...r};for(let c of p)e[c.path]=j(c.file.type);return e}),F((r)=>{let e=new Set(r);for(let c of p)e.add(c.path);return e})},m=async()=>{U(!0),B(null);try{if(Y){let p=(await Kh()||[]).map((v)=>new File([new Uint8Array(v.bytes)],v.name,{type:PF0(v.name)}));if(U(!1),p.length)await x(p);return}let f=await lZ();if(f?.bytes){await C(new Blob([new Uint8Array(f.bytes)]));return}}catch(f){B(f?.message||"open failed")}U(!1)},d=()=>{if(G8()){m();return}let f=document.createElement("input");if(f.type="file",f.accept="image/*,video/*",Y)f.multiple=!0;f.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(f);let h=()=>{if(f.isConnected)f.remove()};window.addEventListener("focus",()=>setTimeout(h,300),{once:!0}),f.addEventListener("change",()=>{let p=f.files?Array.from(f.files):[];if(h(),!p.length)return;if(Y)x(p);else C(p[0])}),f.click()},a=(f)=>`/${J}/${f}`;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(f)=>{if(f.target===f.currentTarget)Q()},children:D("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[D("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Choose media"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:Q,children:z(T8,{name:"x",size:15})})]}),D("div",{className:"st-dialog-bd",children:[D("div",{className:"st-ap-toolbar",children:[z("button",{type:"button",className:"st-btn",onClick:d,disabled:K,children:K?"Uploading…":"Upload…"}),V&&z("span",{className:"st-ap-err",children:V})]}),z("div",{className:"st-ap-grid",children:Z==null?z("div",{className:"st-ap-empty",children:"Loading…"}):Z.length===0?z("div",{className:"st-ap-empty",children:"No assets yet — upload one."}):Z.map((f)=>{let h=Y&&N.has(f.path);return D("button",{type:"button",className:"st-ap-cell","data-selected":h?"true":void 0,"aria-pressed":Y?h:void 0,title:`${f.name} · ${Math.max(1,Math.round(f.size/1024))} KB`,onClick:()=>Y?R(f.path):X(f.path),children:[Y&&z("span",{className:"st-ap-check","aria-hidden":"true",children:h?z(T8,{name:"check",size:12}):null}),f.kind==="video"?z("video",{className:"st-ap-thumb",src:a(f.path),muted:!0,playsInline:!0}):z("img",{className:"st-ap-thumb",src:a(f.path),alt:f.name,loading:"lazy"}),z("span",{className:"st-ap-name",children:f.name})]},f.path)})})]}),Y&&N.size>0&&D("div",{className:"st-dialog-ft st-ap-confirm",children:[D("span",{className:"st-ap-count",children:[N.size," selected"]}),D("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":E==="artboard",disabled:I,onClick:()=>w("artboard"),children:"Add to artboard"}),z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":E==="annotation",onClick:()=>w("annotation"),children:"Add as annotation"})]}),I&&z("span",{className:"st-ap-dest-note",children:k}),z("span",{className:"st-ap-confirm-spacer"}),z("button",{type:"button",className:"btn btn--ghost",onClick:Q,children:"Cancel"}),z("button",{type:"button",className:"btn btn--primary",onClick:()=>G?.(Array.from(N),E),children:"Insert"})]})]})})}function UL(J,X){let Q=URL.createObjectURL(X),Y=document.createElement("a");Y.href=Q,Y.download=J||"export",document.body.appendChild(Y),Y.click(),Y.remove(),setTimeout(()=>URL.revokeObjectURL(Q),1e4)}function TF0({mode:J,initialScope:X,activePath:Q,hasComps:Y=!1,comps:W=[],activeArtboardId:G=null,selection:Z=null,exportLane:H="local",onBrowserCapture:K=null,onClose:U}){let V=u.useCallback((I0)=>H==="none"&&!I0.handoff&&I0.format!=="zip"&&!xb.has(I0.format)||H!=="local"&&I0.format==="canva",[H]),[B,N]=u.useState(J==="handoff"?"shadcn":"png"),[F,M]=u.useState(()=>X&&Tb("png",X)?X:AO("png")),[A,E]=u.useState(2),[w,O]=u.useState(AF0),[I,k]=u.useState(!0),[R,$]=u.useState(!1),[C,j]=u.useState(!1),[x,m]=u.useState(!1),[d,a]=u.useState(_F0),[f,h]=u.useState(wF0),[p,v]=u.useState(!0),[r,e]=u.useState(!1),[c,K0]=u.useState(null),[s,z0]=u.useState([]),o=Xk.find((I0)=>I0.id===B)||Xk[0],q0=o.handoff?[]:_O(o.format),Z0=900,k0=3600,a0=TK(W,gw(W,{artboardId:G})),s0=a0?.durationInFrames||0,t0=a0?.fps||30,E9=o.temporal&&s0>900,a9=o.temporal&&s0>3600;u.useEffect(()=>{if(q0.length&&!q0.includes(F))M(AO(o.format))},[q0,F,o.format]),u.useEffect(()=>{if(H!=="remote")return;fetch("/_api/export-warmup").catch(()=>{})},[H]);let F9=u.useCallback(()=>{fetch("/_api/export-history").then((I0)=>I0.json()).then((I0)=>z0(Array.isArray(I0?.history)?I0.history.slice(0,6):[])).catch(()=>{})},[]);u.useEffect(()=>{F9()},[F9]),u.useEffect(()=>{function I0(w0){if(w0.key==="Escape")w0.preventDefault(),U()}return window.addEventListener("keydown",I0),()=>window.removeEventListener("keydown",I0)},[U]);async function T9(){if(o.handoff){let W9=`/design:handoff ${Q&&Q!==r9?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(W9)}catch{}K0({ok:!0,msg:`Copied: ${W9} — run it in Claude Code.`});return}if(V(o)){K0({ok:!1,msg:"This format needs the render service, which this workspace doesn’t have configured."});return}e(!0),K0(null);let I0=o.temporal?{scale:A}:{};if(o.format==="png"){let C0=Kq.find((W9)=>W9.id===w)||Kq[1];if(C0.kind==="dpi")I0.dpi=C0.value;else I0.scale=C0.value}if(o.format==="mp4"||o.format==="webm")I0.audio=p;if(a9)I0.maxFrames=s0;if(o.format==="pdf"){I0.pdfPrint={includeBleed:I,marks:{crop:C,registration:x}};let C0=J80.find((W9)=>W9.id===d)?.value;if(C0!==void 0)I0.dpi=C0;if(f!=="keep")I0.text=f}if(G)I0.artboardId=G;if(Z?.selector)I0.selection=Z;if(Q&&Q!==r9)I0.canvasFile=Q;if($U.has(o.format)&&a2({exportLane:H,format:o.format,scope:F,artboardId:I0.artboardId})&&typeof K==="function")try{let C0=RO(I0);K0({ok:!0,msg:"Capturing…"});let W9=await K({format:o.format,artboardIds:[I0.artboardId],scale:C0,onProgress:(x9,S9)=>K0({ok:!0,msg:`Capturing ${x9}/${S9}…`})}),H9=await kO(W9,o.format);for(let x9 of H9)UL(x9.name,x9.blob);for(let x9 of H9)await CO({format:o.format,scope:F,filename:x9.name});e(!1),K0({ok:!0,msg:`Saved ${H9.map((x9)=>x9.name).join(", ")} to your downloads.`});return}catch(C0){if(H!=="remote"){K0({ok:!1,msg:`Capture failed: ${C0&&C0.message||C0}`}),e(!1);return}}if(a2({exportLane:H,format:o.format,scope:F})&&o.format==="pptx"&&typeof K==="function")try{K0({ok:!0,msg:"Capturing artboards…"});let C0=Q&&Q!==r9?Y4(Q).replace(/\.[^.]+$/,""):"export",{filename:W9,blob:H9}=await TO({capture:K,name:C0,onProgress:(x9,S9)=>K0({ok:!0,msg:`Capturing ${x9}/${S9}…`}),onAssemble:()=>K0({ok:!0,msg:"Assembling deck…"})});UL(W9,H9),await CO({format:o.format,scope:F,filename:W9}),e(!1),K0({ok:!0,msg:`Saved ${W9} to your downloads.`});return}catch(C0){if(H!=="remote"){K0({ok:!1,msg:`Deck export failed: ${C0&&C0.message||C0}`}),e(!1);return}}if(H==="none"&&$U.has(o.format)){K0({ok:!1,msg:"Without the render service this workspace exports PNG/SVG of the active artboard only — switch Scope to “Active artboard”, or ask your admin to add maude-render."}),e(!1);return}try{let C0=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:o.format,scope:F,options:I0})});if(!C0.ok){K0({ok:!1,msg:await C0.text()||`Export failed (${C0.status})`}),e(!1);return}U()}catch(C0){K0({ok:!1,msg:C0&&C0.message?C0.message:String(C0)}),e(!1)}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(I0)=>{if(I0.target===I0.currentTarget)U()},children:D("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[D("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Export & handoff"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:U,children:z(T8,{name:"x",size:15})})]}),D("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:Q&&Q!==r9?`Format · ${VY(Y4(Q))}`:"Format"}),z("div",{className:"st-fmt-grid",children:Xk.filter((I0)=>!I0.temporal||Y).map((I0)=>D("button",{type:"button","data-testid":`export-format-${I0.id}`,className:"st-fmt"+(I0.id===B?" is-on":""),disabled:V(I0),title:V(I0)?"Needs the render service — not configured on this workspace":void 0,onClick:()=>{N(I0.id),K0(null)},children:[z(T8,{name:I0.icon,size:16}),z("span",{className:"st-fmt-name",children:I0.label}),z("span",{className:"st-fmt-sub",children:I0.sub})]},I0.id))}),H==="none"&&D("div",{className:"st-dialog-note","data-testid":"export-lane-note",children:["PNG and SVG of the active artboard — and the PPTX deck — export right here in your browser; ZIP and AI handoff work too. PDF, video and other multi-artboard exports need the render service, which this workspace doesn't have configured — use the desktop app, or ask your admin to add the ",z("code",{children:" maude-render"})," service (see the self-hosting docs)."]}),!o.handoff&&D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-scope",children:"Scope"}),z("select",{id:"st-export-scope","data-testid":"export-scope",className:"st-select",value:F,onChange:(I0)=>M(I0.target.value),children:q0.map((I0)=>z("option",{value:I0,children:e90[I0]},I0))})]}),!o.handoff&&o.format==="png"&&D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-size",children:"Resolution"}),z("select",{id:"st-export-size",className:"st-select",value:w,onChange:(I0)=>O(I0.target.value),children:Kq.map((I0)=>z("option",{value:I0.id,children:I0.label},I0.id))})]}),!o.handoff&&o.format==="png"&&z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let I0=Kq.find((C0)=>C0.id===w)||Kq[1],w0=I0.kind==="dpi"?I0.value/96:I0.value;return`${I0.label} ≈ ${Math.round(1440*w0)}×${Math.round(900*w0)} for a 1440×900 artboard.`})()}),!o.handoff&&o.temporal&&D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-temporal-size",children:"Resolution"}),z("select",{id:"st-export-temporal-size",className:"st-select",value:A,onChange:(I0)=>E(Number(I0.target.value)),children:OF0.map((I0)=>z("option",{value:I0.value,children:I0.label},I0.value))})]}),!o.handoff&&o.temporal&&D("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[A,"× the artboard's native resolution (e.g. 960×540 → ",960*A,"×",540*A,")."]}),E9&&D("div",{className:"st-mono st-export-long-notice","data-testid":"export-long-comp-notice",style:{fontSize:11,color:"var(--accent)",lineHeight:1.5},children:["⚠ Long comp: ",s0," frames (≈",Math.round(s0/t0),"s).",a9?` Exceeds the default ${"3600"}-frame export cap — exporting raises the cap to the full length for this run.`:""," ","If the fast renderer falls back to frame-by-frame capture this can take several minutes; 2× resolution (≈720–1080p) is recommended for memory headroom."]}),!o.handoff&&o.format==="pdf"&&D(Q0,{children:[D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-dpi",children:"Image quality"}),z("select",{id:"st-export-pdf-dpi",className:"st-select",value:d,onChange:(I0)=>a(I0.target.value),children:J80.map((I0)=>z("option",{value:I0.id,children:I0.label},I0.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:"The page stays vector; this only sets the capture density for raster content on it (dropped photos, large-format art)."}),D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-text",children:"Text"}),z("select",{id:"st-export-pdf-text",className:"st-select","data-testid":"export-pdf-text",value:f,onChange:(I0)=>h(I0.target.value),children:X80.map((I0)=>z("option",{value:I0.id,children:I0.label},I0.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:X80.find((I0)=>I0.id===f)?.description}),z("div",{className:"st-dialog-row",children:D("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-bleed",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-pdf-bleed",type:"checkbox",checked:I,onChange:(I0)=>k(I0.target.checked)}),"Include bleed"]})}),z("div",{className:"st-dialog-row",children:D("button",{type:"button",className:"st-dialog-lbl",style:{background:"none",border:0,padding:0,cursor:"pointer"},onClick:()=>$((I0)=>!I0),"aria-expanded":R,children:[R?"▾":"▸"," Marks"]})}),R&&D("div",{style:{padding:"0 12px 4px",display:"flex",flexDirection:"column",gap:6},children:[D("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:C,onChange:(I0)=>j(I0.target.checked)}),"Crop marks"]}),D("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:x,onChange:(I0)=>m(I0.target.checked)}),"Registration marks"]})]}),D("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:["Bleed and marks apply to print (",z("code",{children:'kind="print"'}),") artboards only.",F==="canvas-as-separate"?" One PDF page per artboard.":""]})]}),!o.handoff&&(o.format==="mp4"||o.format==="webm")&&z("div",{className:"st-dialog-row",children:D("label",{className:"st-dialog-lbl",htmlFor:"st-export-audio",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-audio",type:"checkbox",checked:p,onChange:(I0)=>v(I0.target.checked)}),"Export with audio"]})}),o.handoff&&D("div",{className:"callout callout--info",style:{fontSize:12},children:["Hands the active canvas off to production. Copies"," ",z("span",{className:"st-mono",children:"/design:handoff <path>"})," — run it in Claude Code to emit a ready-to-drop production component next to the canvas."]}),c&&z("div",{className:"callout "+(c.ok?"callout--success":"callout--error"),style:{fontSize:12},"data-testid":"export-status","data-ok":c.ok?"1":"0",children:c.msg}),s.length>0&&D("div",{className:"st-export-recent","data-testid":"export-recent",children:[z("div",{className:"st-rp-hd",children:"Recent"}),s.map((I0,w0)=>D("div",{className:"st-export-recent-row",children:[D("span",{children:[String(I0.format||"").toUpperCase()," ·"," ",e90[I0.scope]||I0.scope]}),z("span",{className:"st-mono",children:I0.filename})]},w0))]})]}),D("div",{className:"st-dialog-ft",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:U,children:"Cancel"}),D("button",{type:"button",className:"btn btn--primary","data-testid":"export-submit",disabled:r,onClick:T9,children:[z(T8,{name:"download",size:14}),o.handoff?"Copy handoff command":r?"Exporting…":`Export ${o.label}`]})]})]})})}var NL=12,FL=16;function kF0({name:J,depth:X,defaultOpen:Q,children:Y,dirPath:W,drag:G,menu:Z}){let[H,K]=u.useState(Q),U=G?G.dropProps(W,!0,()=>K(!0)):{},V=G?.overDir===W,B=G?G.dragProps(W,!0):{},N=G?.draggedPath===W,F=G?.busyPath===W,M=D("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${Bq(W)}`,"aria-expanded":H,"aria-dropeffect":G?"move":void 0,"aria-busy":F||void 0,tabIndex:-1,className:"st-row"+(V?" is-drop-target":"")+(N?" is-dragging":"")+(F?" is-busy":""),style:{paddingLeft:NL+X*FL+"px"},onClick:()=>K((A)=>!A),onContextMenu:Z?(A)=>Z.openAt(A,{kind:"dir",dirPath:W}):void 0,...B,...U,children:[z("span",{className:"st-row-glyph",children:z(T8,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:J})]});return D(Q0,{children:[Z?D("div",{className:"st-row-wrap",role:"none",children:[M,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${Bq(W)}`,title:`Folder actions — ${J}`,"aria-label":`Folder actions for ${J}`,"aria-haspopup":"menu",onClick:(A)=>Z.openAt(A,{kind:"dir",dirPath:W}),children:z(KL,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})})]}):M,H&&Y]})}function RF0({name:J,dsName:X,depth:Q,defaultOpen:Y,active:W,onOpenSystem:G,children:Z}){let[H,K]=u.useState(Y);return D(Q0,{children:[D("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:NL+Q*FL+"px"},role:"treeitem","aria-expanded":H,children:[z("button",{type:"button",className:"st-ds-chev",onClick:()=>K((U)=>!U),"aria-label":H?"Collapse design system":"Expand design system",title:H?"Collapse":"Expand",children:z(T8,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),D("button",{type:"button",className:"st-ds-open",onClick:()=>G(X),"aria-label":`Open ${X} design system view`,title:"Open the design system view",children:[z("span",{className:"st-row-glyph",children:z(T8,{name:"folder",size:13})}),z("span",{className:"st-row-name",children:J})]})]}),H&&Z]})}function VL({file:J,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,onDelete:G,openCount:Z,depth:H,kind:K,sidecar:U,dirty:V,experimentalKind:B,drag:N,menu:F}){let M=J.path===X||J.path===Q,A=yQ.test(J.name),E=!A&&K!=="runtime"?BL(J.name):null,w=!A&&!E,O=A?VY(J.name):J.name,I=A&&typeof G==="function"&&K!=="runtime",k=A&&!U&&K!=="runtime"&&typeof N<"u",R=k?N.dragProps(J.path,!0):{},$=N?.draggedPath===J.path,C=N?.busyPath===J.path,j=k&&typeof F<"u",x=!A&&!!E&&!U&&typeof F<"u",m=typeof F<"u"&&K!=="runtime",d=J.path.split("/").slice(0,-1).join("/"),a=A?"canvas-row-"+J.path.replace(/^\.[^/]+\//,"").replace(yQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,f=D("button",{type:"button",role:"treeitem","data-testid":a??(x?`file-row-${Bq(J.path)}`:void 0),"aria-selected":M,"aria-disabled":w?"true":void 0,"aria-busy":C||void 0,tabIndex:M?0:-1,className:"st-row"+(M?" is-sel":"")+(K==="runtime"?" is-muted":"")+($?" is-dragging":"")+(C?" is-busy":""),style:{paddingLeft:NL+H*FL+"px"},title:J.path+(Z?` — ${Z} open`:w?" (file index only)":""),onClick:()=>{if(A)Y(J.path);else if(E)W?.(J.path)},onContextMenu:m?(h)=>F.openAt(h,{kind:"file",path:J.path,dir:d,canMove:j||x,supporting:x,name:J.name}):void 0,...R,children:[z("span",{className:"st-row-glyph",children:z(T8,{name:"file",size:13})}),z("span",{className:"st-row-name",children:O}),B==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),B==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),V&&z("span",{className:"st-git-badge","data-kind":V,title:`Unsaved (${V})`,"aria-label":`Unsaved, ${V}`,children:V}),Z>0&&z("span",{className:"st-row-badge",children:Z})]});if(!I&&!m)return f;return D("div",{className:"st-row-wrap",role:"none",children:[f,m&&z("button",{type:"button",className:"st-row-menu-btn"+(I?" has-delete-sibling":""),"data-testid":`tree-row-menu-${Bq(J.path)}`,title:`Actions for ${O}`,"aria-label":`Actions for ${O}`,"aria-haspopup":"menu",onClick:(h)=>F.openAt(h,{kind:"file",path:J.path,dir:d,canMove:j||x,supporting:x,name:J.name}),children:z(KL,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})}),I&&z("button",{type:"button",className:"st-row-del",title:`Delete ${O}`,"aria-label":`Delete canvas ${O}`,onClick:(h)=>{h.stopPropagation(),G(J.path,O)},children:z(KL,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})}function CF0({primary:J,sidecars:X,depth:Q,kind:Y,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,showHidden:V,forceOpen:B,dirtyByPath:N,experimentalKind:F,drag:M,menu:A}){let E=N?.get(J.path),w=X.length>0,[O,I]=u.useState(!1),k=B||O,R=J.path===W;if(!(w&&V))return z(VL,{file:J,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,depth:Q,kind:Y,dirty:E,experimentalKind:F,drag:M,menu:A});let C=typeof M<"u",j=C?M.dragProps(J.path,!0):{},x=M?.draggedPath===J.path,m=M?.busyPath===J.path,d=C&&typeof A<"u",a=typeof A<"u"&&Y!=="runtime",f=J.path.split("/").slice(0,-1).join("/"),h=D("button",{type:"button",role:"treeitem","aria-selected":R,"aria-expanded":k,"aria-busy":m||void 0,tabIndex:R?0:-1,className:"st-row st-canvas-row"+(R?" is-sel":"")+(x?" is-dragging":"")+(m?" is-busy":""),style:{paddingLeft:NL+Q*FL+"px"},title:J.path,onClick:(p)=>{if(p.target.closest(".st-canvas-chev")){I((v)=>!v);return}Z(J.path)},onContextMenu:a?(p)=>A.openAt(p,{kind:"file",path:J.path,dir:f,canMove:d}):void 0,...j,children:[z("span",{className:"st-row-glyph st-canvas-chev",onClick:(p)=>{p.stopPropagation(),I((v)=>!v)},children:z(T8,{name:"chevron-right",className:"st-chev"+(k?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:VY(J.name)}),F==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),F==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),E&&z("span",{className:"st-git-badge","data-kind":E,title:`Unsaved (${E})`,"aria-label":`Unsaved, ${E}`,children:E}),U>0&&z("span",{className:"st-row-badge",children:U})]});return D(Q0,{children:[a?D("div",{className:"st-row-wrap",role:"none",children:[h,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${Bq(J.path)}`,title:`Actions for ${VY(J.name)}`,"aria-label":`Actions for ${VY(J.name)}`,"aria-haspopup":"menu",onClick:(p)=>A.openAt(p,{kind:"file",path:J.path,dir:f,canMove:d}),children:z(KL,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})})]}):h,k&&X.map((p)=>z(VL,{file:p,menu:A,activePath:W,previewPath:G,onOpen:Z,onPreview:H,openCount:0,depth:Q+1,kind:Y,sidecar:!0},p.path))]})}function _80({node:J,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z=1,kind:H,showHidden:K,search:U,dsFolders:V,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:M,canvasKinds:A,dirPath:E="",drag:w,menu:O}){let I=Object.keys(J).filter((d)=>d!=="_files").sort(),k=J._files||[],{canvases:R,orphans:$}=u.useMemo(()=>BF0(k),[k]),{mediaOrphans:C,metaOrphans:j}=u.useMemo(()=>{let d=[],a=[];for(let f of $){let h=BL(f.primary.name);(h==="image"||h==="video"||h==="audio"||h==="font"?d:a).push(f)}return{mediaOrphans:d,metaOrphans:a}},[$]),x=!!(U&&U.trim()),m=u.useMemo(()=>{if(!V||Z!==1)return null;let d=new Map;for(let a of V)d.set(a.folder,a);return d},[V,Z]);return D(Q0,{children:[R.map((d)=>{let a=x&&d.sidecars.some((f)=>{let h=U.toLowerCase();return f.name.toLowerCase().includes(h)||f.path.toLowerCase().includes(h)});return z(CF0,{primary:d.primary,sidecars:d.sidecars,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,onDelete:F,openCount:HL(G[d.primary.path]),depth:Z,kind:H,showHidden:K,forceOpen:a,dirtyByPath:M,experimentalKind:A?.[d.primary.path],drag:w,menu:O},d.primary.path)}),C.map((d)=>z(VL,{file:d.primary,menu:O,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,openCount:HL(G[d.primary.path]),depth:Z,kind:H},d.primary.path)),K&&j.map((d)=>z(VL,{file:d.primary,menu:O,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,openCount:HL(G[d.primary.path]),depth:Z,kind:H},d.primary.path)),I.map((d)=>{let a=m?.get(d),f=E?`${E}/${d}`:d,h=z(_80,{node:J[d],activePath:X,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z+1,kind:H,showHidden:K,search:U,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:M,canvasKinds:A,dirPath:f,drag:w,menu:O});if(a&&N)return z(RF0,{name:d,dsName:a.name,depth:Z,defaultOpen:!0,active:X===r9&&a.name===B,onOpenSystem:N,children:h},d);return z(kF0,{name:d,depth:Z,defaultOpen:!0,dirPath:f,drag:w,menu:w?O:void 0,children:h},d)})]})}var WL={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function $F0(J){if(J.kind==="project")return WL.project;if(J.kind==="runtime")return WL.runtime;if(J.label==="Design system")return WL.ds;if(J.label==="UI kit")return WL.canvas;return{title:J.label.toUpperCase(),pillFromCount:!0}}function SF0({readOnly:J=!1,cloud:X,groups:Q,activePath:Y,previewPath:W,activeDsName:G,onOpen:Z,onPreview:H,onOpenSystem:K,wsConnected:U,search:V,setSearch:B,commentsByFile:N,showHidden:F,sectionsExpanded:M,onToggleSection:A,onNewBoard:E,onDeleteBoard:w,onRefresh:O,refreshing:I,collapsed:k,onCollapse:R,width:$,resizing:C,dirtyByPath:j,project:x,gitBranch:m,remoteSync:d,onGetLatest:a,canvasKinds:f,onMoveCanvas:h,onNewFolder:p,onDeleteFolder:v,onRenameFolder:r,onRenameCanvas:e,onDuplicateCanvas:c,onDeleteFile:K0,syncStatus:s,onLinkedHub:z0,onLocalProject:o,onOpenLinkedFile:q0,filesReady:Z0,onShare:k0,savingIsManaged:a0=!1}){let s0=u.useMemo(()=>{if(!V)return Q;return Q.map((b0)=>({...b0,tree:O80(b0.tree,V),filtered:!!V}))},[Q,V]),t0=ub(h),E9=gb(),a9=u.useMemo(()=>{let b0=[];for(let X9 of Q){if(X9.label==="Design system"||X9.kind!=="canvas")continue;let q9=X9.fullPath.replace(/^\.[^/]+\//,"")||X9.fullPath;b0.push({path:X9.fullPath,label:q9});for(let l0 of X9.dirs||[])b0.push({path:l0,label:l0.replace(/^\.[^/]+\//,"")})}return b0},[Q]),F9=E9.state?.extra,T9=F9?.kind==="file"?[{id:"share",label:"Share…",onSelect:()=>{E9.close(),k0(F9.path)}},...e&&/\.tsx$/i.test(F9.path)?[{id:"rename-canvas",label:"Rename…",onSelect:()=>{E9.close();let b0=VY(F9.path.split("/").pop()),X9=window.prompt("Rename canvas to:",b0);if(X9?.trim()&&X9.trim()!==b0)e(F9.path,X9.trim())}}]:[],...c&&/\.tsx$/i.test(F9.path)?[{id:"duplicate-canvas",label:"Duplicate",onSelect:()=>{E9.close(),c(F9.path)}}]:[],...F9.supporting&&e?[{id:"rename-file",label:"Rename…",onSelect:()=>{E9.close();let b0=F9.name??F9.path.split("/").pop(),X9=b0.includes(".")?b0.slice(b0.lastIndexOf(".")):"",q9=X9?b0.slice(0,-X9.length):b0,l0=window.prompt(`Rename ${b0} to:`,q9);if(l0?.trim()&&l0.trim()!==q9)e(F9.path,l0.trim())}}]:[],...F9.canMove?[{id:"move-to",label:"Move to…",onSelect:()=>E9.showMoveTo()}]:[],...F9.supporting&&K0?[{id:"delete-file",label:"Delete",destructive:!0,onSelect:()=>{E9.close(),K0(F9.path,F9.name??F9.path.split("/").pop())}}]:[]]:F9?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{E9.close();let b0=window.prompt("New folder name:");if(b0?.trim())p(F9.dirPath,b0.trim())}},{id:"rename-folder",label:"Rename folder",onSelect:()=>{E9.close();let b0=F9.dirPath.split("/").pop(),X9=window.prompt("Rename folder to:",b0);if(X9?.trim()&&X9.trim()!==b0)r(F9.dirPath,X9.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{E9.close(),v(F9.dirPath,F9.dirPath.split("/").pop())}}]:[],I0=F9?.kind==="file"||F9?.kind==="supporting"?a9.filter((b0)=>b0.path!==F9.dir):[],[w0,C0]=u.useState(!1),[W9,H9]=u.useState("board"),[x9,S9]=u.useState(""),[O8,v0]=u.useState(""),[$9,w8]=u.useState(!1),L9=u.useMemo(()=>Q.find((b0)=>b0.kind==="canvas"&&b0.label!=="Design system")?.fullPath,[Q]),V0=u.useCallback(async()=>{let b0=x9.trim();if(!b0||$9)return;if(w8(!0),v0(""),W9==="folder"){if(!L9){w8(!1),v0("no canvas group to create a folder in");return}let q9=await p(L9,b0);if(w8(!1),q9?.ok)C0(!1),S9("");else v0(q9?.error||"could not create folder");return}let X9=await E(b0);if(w8(!1),X9?.ok)C0(!1),S9("");else v0(X9?.error||"could not create board")},[x9,$9,E,p,W9,L9]),J9=u.useMemo(()=>{let b0=0;for(let X9 of Q)for(let q9 of X9.paths||[])if(yQ.test(q9))b0++;return b0},[Q]),r0=u.useMemo(()=>{let b0=0;for(let X9 of s0)for(let q9 of X9.paths||[])if(yQ.test(q9))b0++;return b0},[s0]);return D("nav",{className:"st-sidebar"+(k?" is-collapsed":"")+(C?" is-resizing":""),style:k||!$?void 0:{width:$,flexBasis:$},"aria-label":"Files","data-tour":"sidebar",children:[D("div",{className:"st-sb-hd",children:[z("span",{className:"st-sb-title",children:"Files"}),D("div",{className:"st-sb-hd-actions",children:[!J&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":w0&&W9==="board",onClick:()=>{v0(""),H9("board"),C0((b0)=>W9==="board"?!b0:!0)},children:z(T8,{name:"plus",size:15})}),!J&&L9&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":w0&&W9==="folder",onClick:()=>{v0(""),H9("folder"),C0((b0)=>W9==="folder"?!b0:!0)},children:z(T8,{name:"folder-plus",size:15})}),O&&z("button",{type:"button",className:"st-iconbtn st-refresh"+(I?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":I||void 0,disabled:I,onClick:()=>O(),children:z(T8,{name:"reload",size:15})}),D("span",{className:"st-live","data-tip":U?"live · file index synced":"reconnecting…",children:[z("span",{className:"st-live-dot"+(U?" is-connected":""),"aria-hidden":"true"}),r0," / ",J9]}),R&&z("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:R,children:z(T8,{name:"panel-left",size:15})})]})]}),w0?D("div",{className:"st-newboard",children:[z("input",{type:"text",autoFocus:!0,placeholder:W9==="folder"?"folder name…":"brief board name…",value:x9,maxLength:60,disabled:$9,"aria-label":W9==="folder"?"New folder name":"New brief board name",onChange:(b0)=>S9(b0.target.value),onKeyDown:(b0)=>{if(b0.key==="Enter")b0.preventDefault(),V0();else if(b0.key==="Escape")b0.preventDefault(),C0(!1),S9(""),v0("")}}),z("button",{type:"button",className:"st-newboard-go",disabled:$9||!x9.trim(),"data-tip":"Create · Enter","aria-label":W9==="folder"?"Create folder":"Create brief board",onClick:V0,children:$9?"…":"↵"})]}):null,O8?z("div",{className:"st-newboard-err",role:"alert",children:O8}):null,z("div",{className:"st-search",children:D("div",{className:"st-search-box",children:[z(T8,{name:"search",size:13}),z("input",{type:"search","data-testid":"canvas-search",placeholder:"Search canvases…",value:V,onChange:(b0)=>B(b0.target.value),onKeyDown:(b0)=>{if(b0.key==="Escape")if(b0.preventDefault(),V)B("");else b0.currentTarget.blur()},"aria-label":"Filter files"}),V?z("button",{className:"st-search-clear",onClick:()=>B(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):z(CJ,{children:"/"})]})}),z("div",{className:"st-tree",role:"tree","aria-label":"Project file tree","data-testid":"canvas-list",children:s0.map((b0)=>{if(!F&&!V&&b0.kind==="runtime")return null;let X9=$F0(b0),q9=(b0.paths||[]).filter((e0)=>yQ.test(e0)).length,l0=X9.pill||(X9.pillFromDsCount?String(b0.dsFolders?.length||0):null)||(X9.pillFromCount?String(q9||b0.paths?.length||0):null),d0=b0.tree&&Object.keys(b0.tree).length>0,h0=b0.label==="Design system",y0=b0.kind==="project";if(!F&&!V&&y0&&q9===0)return null;let B9=VF0(b0),D9=M[b0.label],N0=!!V||(D9===void 0?B9:D9),o0=!h0&&b0.kind==="canvas"&&!J,h9=o0?t0.dropProps(b0.fullPath,!0):{},g9=t0.overDir===b0.fullPath;return D("div",{className:"st-tree-section",children:[D("button",{type:"button",className:"st-tree-sec-hd"+(g9?" is-drop-target":""),"data-testid":`tree-section-${b0.label.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,onClick:()=>A(b0.label,B9),"aria-expanded":N0,"aria-dropeffect":o0?"move":void 0,title:N0?"Collapse section":"Expand section",...h9,children:[z(T8,{name:"chevron-right",className:"st-chev"+(N0?" is-open":""),size:13}),z("span",{className:"st-sec-name",children:X9.title}),l0&&z("span",{className:"st-pill",children:l0})]}),N0&&(d0?z(_80,{node:b0.tree,activePath:Y,previewPath:W,onOpen:Z,onPreview:H,commentsByFile:N,depth:1,kind:b0.kind,showHidden:F,search:V,dsFolders:b0.dsFolders,activeDsName:G,onOpenSystem:h0?K:void 0,onDelete:h0||J?void 0:w,dirtyByPath:j,canvasKinds:f,dirPath:b0.fullPath,drag:!h0&&b0.kind==="canvas"&&!J?t0:void 0,menu:E9}):z("div",{className:"st-tree-empty",children:V?"No matches.":"Empty."}))]},b0.label)})}),z(mb,{state:E9.state,onClose:E9.close,rootItems:T9,destinations:I0,onPickDestination:(b0)=>h(F9.path,b0)}),z(YE,{project:x,liveBranch:m,remoteSync:d,onGetLatest:a,projectOnly:a0}),X===null?z(ww,{syncStatus:s,onLinkedHub:z0,onLocalProject:o,onOpenFile:q0,filesReady:Z0}):null,z(kw,{})]})}function bF0({shown:J,onExpand:X,onSearch:Q}){return z("div",{className:"st-rail"+(J?" is-shown":""),children:D("div",{className:"st-rail-inner",children:[z("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:X,children:z(T8,{name:"panel-left",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:z(T8,{name:"search",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:X,children:z(T8,{name:"folder",size:15})})]})})}function yF0({open:J,onClose:X,onStartTour:Q}){if(u.useEffect(()=>{if(!J)return;function Y(W){if(W.key==="Escape")X()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[J,X]),!J)return null;return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)X()},children:D("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[D("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),D("span",{className:"sku",children:["MAUDE-DEV-SRV / v",Gk]}),Q&&z("button",{type:"button",className:"mdcc-tour__back",style:{marginLeft:"auto"},onClick:Q,children:"▶ Take the tour"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:X,children:"×"})]}),D("div",{className:"help-modal-body",children:[D("details",{open:!0,children:[z("summary",{children:"Canvas selection & tools"}),D("ul",{children:[D("li",{children:[z("kbd",{children:"V"})," ",z("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),D("li",{children:[z("kbd",{children:"H"})," ",z("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),D("li",{children:[z("kbd",{children:"C"})," ",z("span",{children:"comment tool — hover paints, click drops a pin"})]}),D("li",{children:[z("kbd",{children:"⌘"})," + hover ",z("span",{children:"preview deepest element under cursor"})]}),D("li",{children:[z("kbd",{children:"⌘"})," + click ",z("span",{children:"select that element (replace)"})]}),D("li",{children:[z("kbd",{children:"⌘⇧"})," + click ",z("span",{children:"add deepest to selection (multi)"})]}),D("li",{children:["right-click ",z("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),D("li",{children:[z("kbd",{children:"Esc"})," in canvas ",z("span",{children:"clear selection + close menu"})]})]})]}),D("details",{children:[z("summary",{children:"Annotation tools"}),D("ul",{children:[D("li",{children:[z("kbd",{children:"B"})," ",z("span",{children:"pen — freehand stroke"})]}),D("li",{children:[z("kbd",{children:"R"})," ",z("span",{children:"rectangle — drag to define corners"})]}),D("li",{children:[z("kbd",{children:"O"})," ",z("span",{children:"ellipse — drag from center outward"})]}),D("li",{children:[z("kbd",{children:"A"})," ",z("span",{children:"arrow — drag tail → tip"})]}),D("li",{children:[z("kbd",{children:"E"})," ",z("span",{children:"eraser — click or drag over strokes to remove"})]}),D("li",{children:[z("kbd",{children:"V"})," + click stroke ",z("span",{children:"select annotation (Shift+click to multi)"})]}),D("li",{children:[z("kbd",{children:"V"})," + drag empty ",z("span",{children:"marquee-select strokes that overlap"})]}),D("li",{children:["double-click rect/ellipse ",z("span",{children:"add text inside the shape"})]}),D("li",{children:["arrow keys ",z("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),D("li",{children:[z("kbd",{children:"Backspace"})," ",z("span",{children:"delete selected annotations"})]}),D("li",{children:[z("kbd",{children:"⇧P"})," ",z("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),D("details",{children:[z("summary",{children:"Canvas & panels"}),D("ul",{children:[D("li",{children:["click in tree ",z("span",{children:"open canvas (replaces the active one)"})]}),D("li",{children:["File ▸ Close canvas ",z("span",{children:"clear the stage"})]}),D("li",{children:[z("kbd",{children:"⌘R"})," ",z("span",{children:"reload canvas"})]}),D("li",{children:[z("kbd",{children:"/"})," ",z("span",{children:"focus search"})]}),D("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"comments panel"})]}),D("li",{children:[z("kbd",{children:"⌘⇧I"})," ",z("span",{children:"inspector"})]}),D("li",{children:[z("kbd",{children:"?"})," ",z("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),D("details",{children:[z("summary",{children:"Slash commands"}),D("ul",{className:"cmds",children:[D("li",{children:[D("code",{children:['/design:edit "',z("i",{children:"feedback"}),'"']}),z("span",{children:"edit + 4-iter multi-axis loop"})]}),D("li",{children:[D("code",{children:['/design:edit "',z("i",{children:"…"}),'" --perfect']}),z("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),D("li",{children:[D("code",{children:['/design:edit "',z("i",{children:"…"}),'" --no-critic']}),z("span",{children:"raw edit, skip loop"})]}),D("li",{children:[D("code",{children:['/design:edit "',z("i",{children:"…"}),'" --opt-out=',z("i",{children:"scope"})]}),z("span",{children:"override DS scope (palette/aesthetic/full)"})]}),D("li",{children:[D("code",{children:['/design:new "',z("i",{children:"Name"}),'" "',z("i",{children:"brief"}),'"']}),z("span",{children:"scaffold canvas"})]}),D("li",{children:[D("code",{children:['/design:new "',z("i",{children:"…"}),'" --opt-out=aesthetic']}),z("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),D("li",{children:[z("code",{children:"/design:critic"}),z("span",{children:"review panel (routed)"})]}),D("li",{children:[z("code",{children:"/design:critic --all"}),z("span",{children:"10-critic sweep"})]}),D("li",{children:[z("code",{children:"/design:critic --agent signature-moment-critic"}),z("span",{children:"aspiration axis only"})]}),D("li",{children:[z("code",{children:"/design:rollback"}),z("span",{children:"undo last edit"})]}),D("li",{children:[z("code",{children:"/design:screenshot"}),z("span",{children:"capture canvas"})]}),D("li",{children:[z("code",{children:"/design:setup-docs"}),z("span",{children:"refresh README + INDEX"})]}),D("li",{children:[z("code",{children:"/design:handoff"}),z("span",{children:"migrate to apps/"})]})]})]}),D("details",{children:[z("summary",{children:"Opt-out scope"}),D("ul",{children:[D("li",{children:[z("strong",{children:"palette"})," ",z("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),D("li",{children:[z("strong",{children:"aesthetic"})," ",z("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),D("li",{children:[z("strong",{children:"full"})," ",z("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),D("li",{children:[z("em",{children:"A11y enforced at every scope"})," ",z("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),D("li",{children:["Persisted on canvas's ",z("code",{children:".meta.json"})," ",z("code",{children:"opt_out_scope"})," field — subsequent ",z("code",{children:"/design:edit"})," iterations inherit."]}),z("li",{children:'Inferred from brief ("modern", "vibrant", "off-system") with one-shot AskUserQuestion before iter-1 critics fire.'})]})]}),D("details",{children:[z("summary",{children:"Auto-critic loop"}),D("ul",{children:[D("li",{children:[z("strong",{children:"Default"})," ",z("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),D("li",{children:[z("strong",{children:"--perfect"})," ",z("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),D("li",{children:[z("strong",{children:"--perfect --all"})," ",z("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),D("li",{children:["Exit: ",z("code",{children:"solid"})," · ",z("code",{children:"stable-but-bland"})," · ",z("code",{children:"max-reached"})," ","· ",z("code",{children:"divergent"})]}),D("li",{children:[z("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),D("li",{children:["When ",z("code",{children:"opt_out_scope ∈ {aesthetic, full}"}),": iter-1 checkpoint fires — pick (a) run loop, (b) skip auto-loop and review iter 1, (c) a11y-only check."]})]})]}),D("details",{children:[z("summary",{children:"Pin-to-element flow"}),D("ol",{children:[z("li",{children:"Open a canvas"}),D("li",{children:[z("kbd",{children:"⌘"}),"+click element"]}),z("li",{children:"Status bar shows ● selector"}),D("li",{children:["Run"," ",D("code",{children:['/design:edit "',z("i",{children:"change just this"}),'"']})]}),D("li",{children:["Reload iframe (",z("kbd",{children:"⌘R"}),")"]})]})]}),D("details",{children:[z("summary",{children:"Comments"}),D("ol",{children:[D("li",{children:[z("kbd",{children:"⌘"}),"+click element, then ",z("kbd",{children:"⌘C"})," ",z("span",{children:"or ⌘⇧+click"})]}),z("li",{children:"Numbered pin appears on canvas"}),D("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"opens panel — All / Open / Resolved"})]}),D("li",{children:["Click row in panel ",z("span",{children:"jumps to that file + pin"})]}),D("li",{children:["Claude reads ",z("code",{children:"_comments/<slug>.json"})," on next ",z("code",{children:"/design"})]})]})]})]})]})})}var Qk=[{id:"canvas",label:"Canvas",items:[{label:"Command palette",kbd:"⌘ K"},{label:"New brief board",kbd:"N"},{label:"Export…",kbd:"⇧ ⌘ E"},{label:"Handoff to production",kbd:"⇧ ⌘ H"},{label:"Reload canvas",kbd:"⌘ R"},{label:"Search files",kbd:"/",alt:"⌘ F"}]},{id:"tools",label:"Tools · canvas focus",items:[{label:"Move · Hand · Comment",kbd:"V",alt:"H / C"},{label:"Pen · Highlighter · Eraser",kbd:"B",alt:"I / E"},{label:"Shape · Arrow",kbd:"R",alt:"A"},{label:"Sticky · Text · Section",kbd:"N",alt:"T / ⇧S"},{label:"Undo / redo",kbd:"⌘ Z",alt:"⇧ ⌘ Z"}]},{id:"selection",label:"Selection & zoom",items:[{label:"Select element",kbd:"⌘ click"},{label:"Add to selection",kbd:"⌘ ⇧ click"},{label:"Preview deepest",kbd:"⌘ hover"},{label:"Deselect · close menu",kbd:"Esc"},{label:"Zoom in / out",kbd:"⌘ +",alt:"⌘ −"},{label:"Fit · actual size",kbd:"⌘ 0",alt:"⌘ 1"}]},{id:"view",label:"View",items:[{label:"Project tree",kbd:"T"},{label:"Design system view",kbd:"S"},{label:"Inspector",kbd:"⌘ ⇧ I"},{label:"Comments sidebar",kbd:"⌘ ⇧ M"},{label:"Annotations",kbd:"⇧ P"},{label:"Hidden files",kbd:"H"},{label:"This cheat sheet · help",kbd:"?",alt:"F1"}]}];function jF0({kbd:J,alt:X}){let Q=(Y,W)=>z("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>z(CJ,{children:G},`${G}-${Z}`))},W);return D("span",{className:"so-combos",children:[Q(J,"main"),X?X.split(" / ").map((Y)=>D(Q0,{children:[z("span",{className:"so-or",children:"/"}),Q(Y,Y)]},Y)):null]})}function vF0({open:J,onClose:X}){if(u.useEffect(()=>{if(!J)return;function Y(W){if(W.key==="Escape")W.preventDefault(),X()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[J,X]),!J)return null;let Q=Qk.reduce((Y,W)=>Y+W.items.length,0);return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)X()},children:D("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[D("div",{className:"so-overlay-hd",children:[z("span",{className:"so-title",children:"Keyboard shortcuts"}),D("span",{className:"so-trigger",children:["press ",z(CJ,{children:"?"})," to open"]})]}),z("div",{className:"so-columns",children:Qk.map((Y)=>D("section",{className:"so-section so-section--"+Y.id,children:[z("h3",{className:"so-section-hd",children:Y.label}),z("dl",{className:"so-list",children:Y.items.map((W)=>D("div",{className:"so-pair",children:[z("dt",{children:W.label}),z("dd",{children:z(jF0,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),D("div",{className:"so-overlay-ft",children:[D("span",{children:["close with ",z(CJ,{children:"Esc"})]}),D("span",{className:"so-count",children:[Q," bindings · ",Qk.length," groups"]})]})]})})}var fF0=["File","Edit","View","Selection","Tools","Help"];function w80(J){u.useEffect(()=>{function X(Y){if(Y.key==="Escape")J()}function Q(Y){if(!Y.target.closest(".st-dropdown, .st-menu"))J()}return window.addEventListener("keydown",X),window.addEventListener("mousedown",Q),()=>{window.removeEventListener("keydown",X),window.removeEventListener("mousedown",Q)}},[J])}function xF0({panels:J,onToggle:X,onClose:Q,onZoom:Y,hasCanvas:W}){return w80(Q),D("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[z("div",{className:"st-dd-hd",children:"Panels"}),J.map((G)=>D("button",{type:"button",role:"menuitem",className:"st-dd-item"+(G.checked?" is-on":""),"aria-disabled":G.disabled?"true":void 0,title:G.hint||void 0,onClick:()=>{if(G.disabled){if(G.href)window.open(G.href,"_blank","noopener,noreferrer"),Q();return}X(G.id),Q()},children:[D("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check",children:G.checked?z(T8,{name:"check",size:13}):null}),z("span",{children:G.label}),G.phase?z("span",{className:"st-dd-phase",children:G.phase}):null]}),G.shortcut?z(CJ,{children:G.shortcut}):null]},G.id)),z("div",{className:"st-dd-sep"}),z("div",{className:"st-dd-hd",children:"Zoom"}),[{op:"in",label:"Zoom In",shortcut:"⌘ +"},{op:"out",label:"Zoom Out",shortcut:"⌘ −"},{op:"fit",label:"Fit to Screen",shortcut:"⌘ 0"},{op:"actual",label:"Actual Size · 100 %",shortcut:"⌘ 1"}].map((G)=>D("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":W?void 0:"true",onClick:()=>{if(!W)return;Y?.(G.op),Q()},children:[D("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:G.label})]}),z(CJ,{children:G.shortcut})]},G.label))]})}function J1({label:J,left:X,header:Q,items:Y,onAction:W,onClose:G}){return w80(G),D("div",{className:"st-dropdown",role:"menu","aria-label":J,style:{left:X},children:[Q?z("div",{className:"st-dd-hd",children:Q}):null,Y.map((Z,H)=>Z.sep?z("div",{className:"st-dd-sep"},"s"+H):D("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":Z.disabled?"true":void 0,onClick:()=>{if(Z.disabled)return;W(Z.id),G()},children:[D("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:Z.label})]}),Z.shortcut?z(CJ,{children:Z.shortcut}):null]},Z.id))]})}function hF0({onAction:J,onClose:X}){return z(J1,{label:"Help",left:320,onAction:J,onClose:X,items:[{id:"shortcuts",label:"Keyboard shortcuts",shortcut:"?"},{id:"help",label:"Help · commands & flows",shortcut:"F1"},{id:"report-bug",label:"Report a bug…"},{sep:!0},{id:"tour",label:"Take the tour"},{id:"watch-intro",label:"Watch the intro"},...G8()?[{id:"collab-tour",label:"How sharing works"}]:[],...G8()?[{id:"quick-setup",label:"Quick setup"}]:[],...G8()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function gF0({onAction:J,onClose:X,readOnly:Q=!1}){return z(J1,{label:"Selection",left:214,onAction:J,onClose:X,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},...Q?[]:[{id:"select-all-annotations",label:"Select all annotations",shortcut:"⌘ ⇧ A"}]]})}function mF0({onAction:J,onClose:X,readOnly:Q=!1}){let Y=[{id:"browse",label:"Browse (interact)",shortcut:""},{id:"move",label:"Select",shortcut:"V"},{id:"hand",label:"Hand",shortcut:"H"},...Q?[]:[{id:"comment",label:"Comment",shortcut:"C"},{id:"pen",label:"Pen",shortcut:"B"},{id:"rect",label:"Rect",shortcut:"R"},{id:"ellipse",label:"Ellipse",shortcut:"O"},{id:"sticky",label:"Sticky",shortcut:"N"},{id:"arrow",label:"Arrow",shortcut:"A"},{id:"text",label:"Text",shortcut:"T"},{id:"eraser",label:"Eraser",shortcut:"E"}]];return z(J1,{label:"Tools",left:290,header:"Tool palette",onAction:J,onClose:X,items:Y})}function uF0({onAction:J,onClose:X,hasCanvas:Q,hasSharePath:Y,readOnly:W=!1}){return z(J1,{label:"File",left:40,onAction:J,onClose:X,items:W?[{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"share",label:"Share link…",disabled:!Y},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!Q},{id:"close",label:"Close canvas",disabled:!Q}]:[{id:"new",label:"New canvas…",shortcut:"N"},{id:"assemble",label:"Assemble dropped clips → video",disabled:!Q},{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"share",label:"Share link…",disabled:!Y},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"generate",label:"Generate with AI…"},{id:"settings",label:"Settings…",shortcut:"⌘,"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!Q},{id:"close",label:"Close canvas",disabled:!Q}]})}function pF0({onAction:J,onClose:X,hasCanvas:Q,readOnly:Y=!1}){if(Y)return z(J1,{label:"Edit",left:90,onAction:J,onClose:X,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"}]});return z(J1,{label:"Edit",left:90,onAction:J,onClose:X,items:[{id:"undo",label:"Undo",shortcut:"⌘Z"},{id:"redo",label:"Redo",shortcut:"⇧⌘Z"},{sep:!0},{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},{id:"select-all-annotations",label:"Select all annotations",shortcut:"⇧⌘A"},...Q?[{sep:!0},{id:"new-artboard:desktop",label:"New artboard: Desktop"},{id:"new-artboard:laptop",label:"New artboard: Laptop"},{id:"new-artboard:tablet",label:"New artboard: Tablet"},{id:"new-artboard:mobile",label:"New artboard: Mobile"},{id:"new-artboard:print-a4",label:"New artboard: A4 (print)"},{id:"new-artboard:print-letter",label:"New artboard: Letter (print)"}]:[]]})}function lF0({activePath:J,sharePath:X,onShare:Q,project:Y,cloud:W,tabsCount:G,openMenu:Z,setOpenMenu:H,commentsPanelOpen:K,onToggleComments:U,changesOpen:V,changesCount:B,onToggleChanges:N,onOpenSystem:F,sidebarOpen:M,onToggleSidebar:A,showHidden:E,onToggleShowHidden:w,onOpenHelp:O,onOpenShortcuts:I,onReportBug:k,onStartTour:R,onStartCollabTour:$,annotationsVisible:C,onToggleAnnotations:j,minimapVisible:x,onToggleMinimap:m,zoomCtlVisible:d,onToggleZoomCtl:a,presentMode:f,onTogglePresent:h,printGuidesVisible:p,onTogglePrintGuides:v,postToActiveCanvas:r,onOpenWhatsNew:e,onOpenReadiness:c,onOpenQuickSetup:K0,onWatchIntro:s,whatsNewCount:z0,exportCenter:o,artboardCount:q0=0,presence:Z0=null,inspectorOpen:k0,inspectorTab:a0,onToggleInspector:s0,autoOpenInspector:t0,onToggleAutoOpenInspector:E9,onOpenLayers:a9,timelineOpen:F9,onToggleTimeline:T9,hasComps:I0=!1,assistantOpen:w0,onToggleAssistant:C0,assistantBusy:W9,assistantUnseen:H9,onNewCanvas:x9,onAssembleVideo:S9,onOpenExport:O8,onOpenSettings:v0,onOpenGenerate:$9,onReload:w8,onCloseCanvas:L9,onInsertArtboard:V0,readOnly:J9=!1}){let r0=J===r9,b0=r0?"SYSTEM":J?"CANVAS":"IDLE",X9=r0?z("b",{children:"design system"}):J?D(Q0,{children:[J.split("/").slice(0,-1).join("/"),"/",z("b",{children:VY(Y4(J))})]}):z("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),q9=new Set(W?["autoopen"]:["assistant","autoopen"]),l0=[{id:"tree",label:"Project Tree",shortcut:"T",checked:M,disabled:!1},{id:"changes",label:W?"History":B>0?`Changes · ${B} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:V,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:K,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:E,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:k0&&a0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:k0,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!t0,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:I0?"video":void 0,checked:F9,disabled:!1},...G8()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:w0,disabled:!1}]:W?[{id:"assistant",label:"Assistant — in the desktop app",shortcut:"",checked:!1,disabled:!0,href:"https://maude.sh/download",hint:"The agent runs on your own Claude subscription, on your own machine."}]:[],{id:"annotate",label:"Annotations",shortcut:"⇧ P",checked:C,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:x,disabled:!J||r0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:d,disabled:!J||r0},{id:"present",label:"Presentation Mode",shortcut:"",checked:f,disabled:!J||r0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:p,disabled:!J||r0}].filter((y0)=>!J9||!q9.has(y0.id)),d0=["file","edit","view","selection","tools","help"];function h0(y0){if(d0.includes(y0))H(Z===y0?null:y0)}return u.useEffect(()=>{if(!Z||!d0.includes(Z))return;let y0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function B9(D9){let N0=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!N0.length)return;let o0=N0.indexOf(document.activeElement);if(D9.key==="ArrowDown")D9.preventDefault(),N0[(o0+1)%N0.length].focus();else if(D9.key==="ArrowUp")D9.preventDefault(),N0[(o0-1+N0.length)%N0.length].focus();else if(D9.key==="Home")D9.preventDefault(),N0[0].focus();else if(D9.key==="End")D9.preventDefault(),N0[N0.length-1].focus();else if(D9.key==="ArrowRight"||D9.key==="ArrowLeft"){D9.preventDefault();let h9=D9.key==="ArrowRight"?1:-1,g9=d0.indexOf(Z);H(d0[(g9+h9+d0.length)%d0.length])}else if(D9.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",B9),()=>{clearTimeout(y0),window.removeEventListener("keydown",B9)}},[Z,H]),D("header",{className:"st-menubar",role:"menubar","aria-label":"Application menubar","data-testid":"menubar",children:[D("span",{className:"st-brand","data-tour":"brand",children:[z("span",{className:"st-brand-mark",children:z("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),z("span",{className:"st-brand-name",children:"maude"})]}),W?D("span",{className:"st-cloudback","data-testid":"cloud-back",children:[W.dashboardUrl?z("a",{className:"st-cloudback-link",href:W.dashboardUrl,title:"Back to your projects",children:"← Dashboard"}):null,W.projectName?z("span",{className:"st-cloudback-project","data-testid":"cloud-project-name",children:W.projectName}):null]}):null,z("nav",{className:"st-menus","aria-label":"Application menus","data-tour":"menus",children:fF0.map((y0)=>{let B9=y0.toLowerCase(),D9=d0.includes(B9),N0=D9||B9==="help",o0=Z===B9;return z("button",{type:"button",className:"st-menu",role:"menuitem","data-testid":`menu-${B9}`,"data-tour":B9==="help"?"help":void 0,"aria-haspopup":D9?"menu":void 0,"aria-expanded":D9?o0:void 0,onClick:()=>h0(B9),onMouseEnter:()=>{if(Z!==null&&D9)H(B9)},children:y0},B9)})}),Z==="file"&&z(uF0,{readOnly:J9,hasCanvas:!!J,hasSharePath:!!X,onAction:(y0)=>{if(y0==="new")x9?.();else if(y0==="assemble")S9?.();else if(y0==="export")O8?.("export");else if(y0==="share")document.querySelector('[data-testid="menu-file"]')?.focus(),Q?.();else if(y0==="handoff")O8?.("handoff");else if(y0==="generate")$9?.();else if(y0==="settings")v0?.();else if(y0==="reload")w8?.();else if(y0==="close")L9?.()},onClose:()=>H(null)}),Z==="edit"&&z(pF0,{readOnly:J9,hasCanvas:!!J&&!r0,onAction:(y0)=>{if(y0==="undo")r({dgn:"undo"});else if(y0==="redo")r({dgn:"redo"});else if(y0==="deselect-all")r({dgn:"selection-clear"});else if(y0==="select-all-annotations")r({dgn:"annotation-select-all"});else if(y0.startsWith("new-artboard:"))V0?.(y0.slice(13))},onClose:()=>H(null)}),Z==="view"&&z(xF0,{panels:l0,onToggle:(y0)=>{if(y0==="tree")A();else if(y0==="changes")N();else if(y0==="comments")U();else if(y0==="hidden")w();else if(y0==="annotate")j();else if(y0==="inspector")s0();else if(y0==="autoopen")E9?.();else if(y0==="timeline")T9?.();else if(y0==="assistant")C0?.();else if(y0==="layers")a9?.();else if(y0==="minimap")m?.();else if(y0==="zoomctl")a?.();else if(y0==="present")h?.();else if(y0==="print-guides")v?.()},onZoom:(y0)=>r({dgn:"zoom",op:y0}),hasCanvas:!!J&&!r0,onClose:()=>H(null)}),Z==="selection"&&z(gF0,{readOnly:J9,onAction:(y0)=>{if(y0==="deselect-all")r({dgn:"selection-clear"});else if(y0==="select-all-annotations")r({dgn:"annotation-select-all"})},onClose:()=>H(null)}),Z==="tools"&&z(mF0,{readOnly:J9,onAction:(y0)=>r({dgn:"tool-set",tool:y0}),onClose:()=>H(null)}),Z==="help"&&z(hF0,{onAction:(y0)=>{if(y0==="shortcuts")I?.();else if(y0==="help")O?.();else if(y0==="report-bug")k?.();else if(y0==="tour")R?.();else if(y0==="collab-tour")$?.();else if(y0==="quick-setup")K0?.();else if(y0==="readiness")c?.();else if(y0==="whatsnew")e?.();else if(y0==="watch-intro")s?.()},onClose:()=>H(null)}),D("div",{className:"st-mb-right","data-tour":"status",children:[Z0?z("div",{className:"st-presence",children:Z0}):null,J9&&z("span",{className:"st-stamp st-stamp--viewonly","data-testid":"view-only-stamp","data-tip":W?.user?`${W.user} is a viewer on this project — you can browse, comment and export where available. Ask a project owner for edit access, or sign out if that is not the account you meant to use.`:"Your role in this project is viewer — you can browse, comment when available, and export where available. Ask a project owner for edit access.",children:"VIEW ONLY"}),W?.user?D("span",{className:"st-cloudwho","data-testid":"cloud-account",children:[z("span",{className:"st-cloudwho-email",title:W.role?`Signed in as ${W.user} — ${W.role}`:W.user,children:W.user}),z("form",{method:"post",action:"/auth/browser/signout",className:"st-cloudwho-form",children:z("button",{type:"submit",className:"st-cloudwho-out","data-testid":"cloud-signout",title:"Sign out of this project",children:"Sign out"})})]}):null,G8()&&!J9&&z("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":w0?"true":"false","data-busy":W9?"true":"false","data-unseen":H9?"true":"false","aria-label":`Assistant${W9?" — working":H9?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:C0,children:z(T8,{name:"sparkle",size:15})}),z("button",{type:"button",className:"st-mb-icon st-share-btn","data-testid":"share-btn","data-tip":X?"Share link":"Open a canvas to share it","aria-label":"Share link",disabled:!X,onClick:Q,children:z(T8,{name:"share",size:15})}),o&&z(Bm,{center:o}),z("button",{type:"button",className:"st-reportbug","data-testid":"report-bug-toggle","aria-label":"Report a bug","data-tip":"Report a bug",onClick:k,children:z(T8,{name:"bug",size:15})}),z("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":z0>0?"true":"false","aria-label":`What's new${z0>0?` — ${z0} unseen`:""}`,"data-tip":"What's new",onClick:e,children:z(T8,{name:"megaphone",size:15})}),z("span",{className:"st-stamp",children:b0}),z("span",{className:"st-mb-file",title:J||"",children:X9}),z("span",{className:"st-mb-sep"}),D("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[z("span",{className:"st-dot",style:{background:"var(--accent)"}}),q0," ARTBOARDS"]}),z("span",{className:"st-mb-sep"}),z("span",{className:"st-mb-proj",children:Y||"maude"})]})]})}function dF0({tabs:J,activePath:X,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:K,onIframeLoad:U,canvasError:V,canvasReloadNonce:B,onRetryCanvasLoad:N,loadedPath:F,showQuickSetup:M,onStartQuickSetup:A,previewPath:E}){let w=u.useRef(null);u.useEffect(()=>{if(E)w.current?.focus()},[E]);let O=u.useRef(new Map),I=new Set(J.map(($)=>$.path));for(let[$,C]of O.current)if(!I.has(C.path))O.current.delete($);let k=($)=>{let C=EZ($,{...H,canvasToken:void 0}),j=`${$}#${B}|${C}`,x=O.current.get(j);if(!x)x={path:$,src:EZ($,H)},O.current.set(j,x);return x.src},R=V&&V.path===X?"error":X&&X!==r9&&F===X?"ready":K&&K===X?"loading":"idle";return D("div",{className:"viewport st-stage","data-tour":"viewport","data-canvas-state":R,children:[E&&z("div",{ref:w,className:"st-file-preview-overlay",role:"region","aria-label":`Preview: ${$V(Y4(E))}`,tabIndex:0,children:z(Eg,{path:E,kind:BL(Y4(E))})}),J.length===0&&!E&&D("div",{className:"st-empty",children:[D("div",{className:"st-empty-brand",children:[z("span",{className:"st-brand-mark",children:z("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),z("span",{className:"st-empty-wm",children:"maude"}),D("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(Z||"MAUDE").toUpperCase()," / v",Gk," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),z("div",{className:"st-empty-title",children:"Nothing open yet"}),D("div",{className:"st-empty-body",children:["← Pick a screen from the list on the left, or open ",z("strong",{children:"Design system"})," above it to see your colors, type, and components.",z("br",{}),z("br",{}),z("strong",{children:"To select something on the canvas:"})," hold ",z(CJ,{children:"⌘"})," and hover to preview an element, click to select it — ",z(CJ,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",G8()?D(Q0,{children:[z("br",{}),z("br",{}),"Claude can see whatever's selected when you ask for a change in the Assistant panel, so pointing is often faster than describing it."]}):null]}),M&&z("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:A,children:"Start quick setup"})]}),J.map(($)=>{if($.path===r9)return z("div",{className:"system-view"+($.path===X?" active":""),children:z(tF0,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},$.path);return z("iframe",{ref:(C)=>Q($.path,C),src:k($.path),className:$.path===X?"active":"","data-path":$.path,"data-testid":$.path===X?"canvas-frame":void 0,onLoad:()=>U?.($.path),...H?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},`${$.path}#${B}`)}),K&&K===X&&z("div",{className:"st-canvas-loading","aria-hidden":"true",children:D("div",{className:"st-skel-card",children:[z("div",{className:"st-skel-cap st-mono",children:"compiling canvas…"}),z("span",{className:"skel st-skel-thumb"}),z("span",{className:"skel st-skel-line",style:{width:"72%"}}),z("span",{className:"skel st-skel-line",style:{width:"46%"}})]})}),V&&V.path===X&&z("div",{className:"st-canvas-error",role:"alert","data-testid":"canvas-load-error",children:D("div",{className:"st-canvas-error-card",children:[z("div",{className:"st-canvas-error-title",children:V.kind==="server"?"Maude's server isn't responding":"This canvas didn't finish loading"}),z("div",{className:"st-canvas-error-body",children:V.kind==="server"?z(Q0,{children:"The canvas couldn't be reached. This usually means Maude's server restarted underneath this window — your files on disk are untouched."}):D(Q0,{children:["The server is up, but"," ",z("code",{children:$V(Y4(V.path))})," ","never finished compiling. Its own error, if it has one, is in the canvas frame."]})}),z("button",{type:"button",className:"btn btn--primary","data-testid":"canvas-load-retry",onClick:()=>N?.(V.path),children:"Reload canvas"})]})})]})}var cF0=["color","space","radius","shadow","leading","weight","motion","font","other"],iF0={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function oF0(J){return J==="color"}function nF0({tokens:J,tokenGroups:X,tokensPath:Q}){if(!J||J.length===0)return D("section",{className:"sv-section sv-section-tokens",children:[D("h2",{children:["tokens",z("span",{className:"sv-h-num",children:"0"})]}),z("div",{className:"sv-empty",children:D("p",{children:["No tokens parsed from"," ",Q?z("code",{children:Q}):"the configured tokens file",". Does the file exist and contain CSS custom properties (",z("code",{children:"--name: value;"}),")?"]})})]});let Y=X||{},W=Array.from(new Set([...cF0,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return z(Q0,{children:W.map((G)=>{let Z=Y[G],H=oF0(G);return D("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[D("h2",{children:["tokens · ",iF0[G]||G,z("span",{className:"sv-h-num",children:Z.length})]}),z("div",{className:"sv-tokens-ladder",children:Z.map((K)=>D("div",{className:"sv-tok-cell",children:[H?z("div",{className:"sv-tok-swatch",style:{background:K.value}}):null,D("div",{className:"sv-tok-meta",children:[z("code",{className:"sv-tok-name",children:K.name}),z("span",{className:"sv-tok-value",children:K.value||"—"})]})]},K.name+"|"+K.value))})]},G)})})}function rF0(J,X){let Q=J.name.match(/^--(?:type|fs|text)-(.+)$/);if(!Q)return null;let Y=Q[1];return(X||[]).find((W)=>/^--(?:lh|leading|line-height)-/.test(W.name)&&W.name.endsWith("-"+Y))?.value??null}function aF0(J){if(!J?.length)return;let X=["body","sans","display","text","family"];for(let Q of X){let Y=J.find((W)=>W.name.includes(Q));if(Y)return Y.value}return J[0].value}function sF0({tokenGroups:J}){let X=J?.fontsize||[];if(X.length===0)return null;let Q=J?.leading||[],Y=aF0(J?.font);return D("section",{className:"sv-section sv-section-type",children:[D("h2",{children:["type · ladder",z("span",{className:"sv-h-num",children:X.length})]}),z("div",{className:"sv-type-list",children:X.map((W)=>{let G=rF0(W,Q),Z={fontSize:W.value};if(G)Z.lineHeight=G;if(Y)Z.fontFamily=Y;return D("div",{className:"sv-type-row",children:[z("code",{className:"sv-type-tok",children:W.name}),z("span",{className:"sv-type-sample",style:Z,children:"The catalog is the system."})]},W.name)})})]})}function tF0({data:J,onOpen:X,cfg:Q,onSelectDs:Y}){if(!J)return z("div",{className:"sv-empty",children:z("p",{children:"Loading design system…"})});let{previewGallery:W,uiKitsGallery:G,systemDir:Z,tokens:H,tokenGroups:K,tokensPath:U,ds:V,availableDesignSystems:B}=J,N=(!W||!W.length)&&(!G||!G.length),F=Array.isArray(B)&&B.length>1,M=V?.name??B?.[0]?.name??"";return D("div",{className:"sv",children:[D("header",{className:"sv-header",children:[z("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),z("span",{className:"sv-title",children:"design system view"}),F?D("label",{className:"sv-ds-picker",children:[z("span",{className:"sv-ds-picker-label",children:"DS"}),z("select",{value:M,onChange:(A)=>Y&&Y(A.target.value),children:B.map((A)=>z("option",{value:A.name,children:A.name},A.name))})]}):null,z("span",{className:"sv-loc",children:z("code",{children:Z})})]}),V?.description?z("p",{className:"sv-ds-description",children:V.description}):null,z(nF0,{tokens:H,tokenGroups:K,tokensPath:U}),z(sF0,{tokenGroups:K}),N?z("div",{className:"sv-empty",children:D("p",{children:["No ",z("code",{children:"preview/"})," or ",z("code",{children:"ui_kits/"})," folders found under"," ",z("code",{children:Z}),"."]})}):D(Q0,{children:[z(Q80,{title:"preview",items:W,onOpen:X,kind:"preview",cfg:Q}),z(Q80,{title:"ui kits",items:G,onOpen:X,kind:"ui_kits",cfg:Q})]})]})}function Q80({title:J,items:X,onOpen:Q,kind:Y,cfg:W}){if(!X||X.length===0)return null;return D("section",{className:"sv-section",children:[D("h2",{children:[J," ",z("span",{className:"sv-count",children:X.length})]}),z("div",{className:"sv-previews sv-previews-"+Y,children:X.map((G)=>D("article",{className:"sv-preview-card",onClick:()=>Q(G.path),children:[z("div",{className:"sv-preview-frame",children:z("iframe",{src:EZ(G.path,W,{thumbnail:!0}),title:G.label,scrolling:"no",...W?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),D("div",{className:"sv-preview-foot",children:[z("strong",{children:G.label}),z("code",{children:G.path})]})]},G.path))})]})}function eF0({activePath:J,selected:X,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,syncProject:K,syncOpen:U=!1,onOpenSync:V,changesCount:B=0,unpushed:N=0,savingIsManaged:F=!1,changesOpen:M=!1,onOpenChanges:A,version:E}){let w=J===r9,O=X&&X.selector?X.selector+(X.text?` — "${X.text.slice(0,60)}"`:""):"",I=X&&X.dom_path?X.dom_path.join(" > "):X?X.selector:"",k=W==="dark"?"light":"dark",R=(()=>{let C=oz(H,{project:K});if(!C)return null;let j=C.names.length?` (${C.names.join(", ")})`:"";return{online:C.online,label:C.label,title:`${C.title}${j}${C.next?` — ${C.next}`:""}`}})(),$=R&&D(Q0,{children:[z("span",{className:"st-sb-sync-dot"+(R.online?" is-online":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:"hub sync"}),z("span",{className:"val",title:R.title,children:R.label})]});return D("footer",{className:"st-statusbar",role:"contentinfo","data-testid":"statusbar",children:[D("span",{className:"st-sb-slot st-sb-active",role:"group","aria-label":"Active file",children:[z("span",{className:"lead","aria-hidden":"true"}),z("span",{className:"lbl",children:"active"}),z("span",{className:"val",title:J||"",children:w?"▦ design system":J||"—"})]}),J&&X&&X.selector&&!w&&D("span",{className:"st-sb-slot st-sb-sel",role:"group","aria-label":"Selected element",children:[z("span",{className:"lbl",children:"selected"}),z("span",{className:"val",title:I,children:O}),z("button",{type:"button",className:"st-sb-sel-clear",onClick:Z,"data-tip":"Clear · Esc inside iframe","data-tip-pos":"top","aria-label":"Clear selection",children:"×"})]}),D("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[z("span",{className:"lbl",children:"comments"}),D("span",{className:"val",children:[Y," open"]})]}),A&&D("button",{type:"button",className:"st-sb-slot st-sb-changes"+(M?" is-open":"")+(B>0?" has-changes":N>0?" has-unpushed":""),onClick:A,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":M,children:[z("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),z("span",{className:"lbl",children:"changes"}),z("span",{className:"val",children:F?"cloud saving":B>0?`${B} unsaved`:N>0?`${N} to publish`:"all saved"})]}),z("span",{className:"st-sb-spacer"}),D("span",{className:"st-sb-slot",role:"group","aria-label":"Connection",children:[z("span",{className:"st-live-dot"+(Q?" is-connected":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:Q?"live":"reconnecting"})]}),R&&(V?z("button",{type:"button",className:"st-sb-slot st-sb-sync st-sb-sync--btn"+(U?" is-open":""),onClick:V,"data-testid":"open-sync","data-tip":"Open Sync panel","data-tip-pos":"top","aria-label":"Open Sync panel","aria-pressed":U,children:$}):z("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:$})),E&&z("span",{className:"st-sb-slot st-sb-version",role:"group","aria-label":"Maude version",children:D("span",{className:"val","data-testid":"statusbar-version",children:["v",E]})}),D("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${k} theme`,"data-tip-pos":"top","aria-label":`Switch to ${k} theme`,children:[z(T8,{name:W==="dark"?"sun":"moon",size:13}),k]})]})}function JL0({commentsByFile:J,filter:X,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:K,width:U,resizing:V}){let B=A80(J),N=Object.keys(J||{}).sort(),F=[];for(let M of N){let A=J[M]||[],E=A.filter((O)=>{if(X==="open")return O.status!=="resolved";if(X==="resolved")return O.status==="resolved";return!0});if(E.length===0)continue;let w=A.filter((O)=>O.selector);F.push({file:M,comments:E.map((O)=>({...O,n:w.findIndex((I)=>I.id===O.id)+1}))})}return D("aside",{className:"st-rpanel"+(V?" is-resizing":""),style:U?{width:U,flexBasis:U}:void 0,"aria-label":"Comments",children:[z("div",{className:"st-rp-tabs st-rp-tabs--filters",children:D("div",{className:"st-cm-filters",role:"tablist",children:[D("button",{type:"button",className:"st-cm-filter"+(X==="all"?" is-active":""),role:"tab","data-testid":"comment-filter-all","aria-selected":X==="all",onClick:()=>Q("all"),children:["All · ",B.all]}),D("button",{type:"button",className:"st-cm-filter"+(X==="open"?" is-active":""),role:"tab","data-testid":"comment-filter-open","aria-selected":X==="open",onClick:()=>Q("open"),children:["Open · ",B.open]}),D("button",{type:"button",className:"st-cm-filter"+(X==="resolved"?" is-active":""),role:"tab","data-testid":"comment-filter-resolved","aria-selected":X==="resolved",onClick:()=>Q("resolved"),children:["Resolved · ",B.resolved]})]})}),z("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:F.length===0?D("div",{className:"st-rp-empty",children:[D("p",{children:["No comments ",X!=="all"?`with status “${X}”`:"yet","."]}),D("p",{children:["Open a canvas, hold ",z(CJ,{children:"⌘"})," and click an element, then press ",z(CJ,{children:"C"})," — or hold ",z(CJ,{children:"⌘⇧"})," and click directly."]})]}):F.map((M)=>D(Q0,{children:[D("button",{type:"button",className:"st-cm-group-hd",onClick:()=>G(M.file,null),title:M.file,children:[z("span",{children:VY(Y4(M.file))}),z("span",{className:"st-mono",children:M.comments.length})]}),M.comments.map((A)=>D("div",{"data-testid":`comment-item-${A.id}`,className:"st-comment"+(A.status==="resolved"?" is-resolved":"")+(A.id===W?" is-active":""),onClick:()=>G(M.file,A.id),children:[D("div",{className:"st-comment-hd",children:[z("span",{className:"st-pin st-pin--inline",children:A.n||"·"}),z("span",{className:"st-comment-time",children:FF0(A.created)})]}),z("div",{className:"st-comment-txt",children:A.text}),D("div",{className:"st-comment-foot",children:[z("span",{className:"st-comment-sel",title:(A.dom_path||[]).join(" > "),children:A.selector||"—"}),Z&&H&&K?D("span",{className:"st-mini-act",children:[A.status==="resolved"?z("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(E)=>{E.stopPropagation(),H(A.id)},children:z(T8,{name:"reopen",size:14})}):z("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(E)=>{E.stopPropagation(),Z(A.id)},children:z(T8,{name:"resolve",size:14})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(E)=>{E.stopPropagation(),K(A.id)},children:z(T8,{name:"x",size:14})})]}):null]})]},A.id))]},M.file))})]})}var XL0={owner:"You own this project — edit, invite and export.",member:"You can edit this project, comment and export.",viewer:"You can look at this project, comment and download it, but not change it."};function QL0({cloud:J}){let X=J?.role||null,[Q,Y]=u.useState(!1);if(!X||Q)return null;let W=`maude-cloud-role-seen:${X}`,G=!1;try{G=localStorage.getItem(W)==="1"}catch{}if(G)return null;let Z=XL0[X];if(!Z)return null;return D("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info","data-testid":"cloud-role-banner",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:Z}),z("button",{type:"button",className:"btn btn--ghost btn--sm","data-testid":"cloud-role-banner-dismiss",onClick:()=>{Y(!0);try{localStorage.setItem(W,"1")}catch{}},children:"Got it"})]})}function YL0({update:J,onDismiss:X}){let[Q,Y]=u.useState(!1);if(!J)return null;let W=J.version?` (v${J.version})`:"";return D("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),D("span",{children:["Maude updated",W," · restart to apply"]}),z("button",{type:"button",className:"btn btn--primary btn--sm",disabled:Q,onClick:()=>{Y(!0),Vh().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X,children:"Later"})]})}function WL0({status:J}){let[X,Q]=u.useState(null);if(!J||J.linked===!1)return null;if(J.notSyncable)return null;let{state:Y,queuedOps:W,flash:G,conflicts:Z}=J,H=G==="synced",K=Y==="offline"||Y==="offline-long",U=J.docs?.rejected??0,V=Array.isArray(Z)?[...Z].reverse().find((M)=>M.kind==="cold-start-diverged"):null;if(!K&&!H&&!V&&U===0)return null;let B,N,F;if(H)B="success",N="Synced with hub",F=`${Y}:flash`;else if(K){let M=Z&&Z.length>0?` (${Z.length} conflict notice(s))`:"";if(Y==="offline-long")B="error",N=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${M}`;else B="warn",N=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${M}`;F=`${Y}:offline`}else if(V){if(V.snapshotFailed)B="error",N=`Diverged on ${V.slug}: kept local — the history snapshot FAILED, so the overwrite was refused. Check disk space / .design/_history write access.`;else B="warn",N=`Diverged on ${V.slug}: kept the ${V.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${V.slug}`;F=`diverged:${V.slug}:${V.at}`}else B="warn",N=`${U} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,F=`rejected:${U}`;if(X===F)return null;return D("div",{role:"status","aria-live":"polite",className:`st-banner st-banner--${B}`,children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:N}),z("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(F),children:"×"})]})}var GL0=["block","inline-block","flex","inline-flex","grid","inline","none"],Y80=["px","%","fr","em","auto","min-content","max-content"];var ZL0=["auto","stretch","flex-start","center","flex-end","baseline"];var W80=["300","400","500","600","700","800"],Uq=(J,X)=>J&&Object.hasOwn(J,"previous")?J.previous:X,G80=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],Z80=["none","solid","dashed","dotted","double"],H80=["px","rem","em","%","vw","vh","auto"],z80=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),Yk={"font-size":{node:z(K7,{as:bV,size:12})},"line-height":{node:z(K7,{as:gV,size:12})},"letter-spacing":{node:z(K7,{as:nV,size:12})},gap:{node:z(K7,{as:PK,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:z(K7,{as:eV,size:12})},"border-width":{node:z(K7,{as:oV,size:12})}};var K80=["static","relative","absolute","fixed","sticky"],HL0=["normal","italic","oblique"],U80=["none","uppercase","lowercase","capitalize"];var V80=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],zL0=["fill","contain","cover","none","scale-down"];var q80=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],B80=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],bQ={desktop:{label:"Desktop",width:1440,height:1024},laptop:{label:"Laptop",width:1280,height:800},tablet:{label:"Tablet",width:834,height:1194},mobile:{label:"Mobile",width:390,height:844}},tK=null;function qL(J){if(!J)return"";if(/^#[0-9a-f]{6}$/i.test(J))return J.toLowerCase();try{if(!tK)tK=document.createElement("canvas").getContext("2d");if(!tK)return"";tK.fillStyle="#000000",tK.fillStyle=J;let X=tK.fillStyle;if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();let Q=X.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(Q)return`#${[Q[1],Q[2],Q[3]].map((Y)=>Number(Y).toString(16).padStart(2,"0")).join("")}`}catch{}return""}var UY=(J)=>Math.min(1,Math.max(0,J));function GL(J){let X=/^#?([0-9a-f]{6})$/i.exec(J||"");if(!X)return{r:0,g:0,b:0};let Q=Number.parseInt(X[1],16);return{r:Q>>16&255,g:Q>>8&255,b:Q&255}}function Vq({r:J,g:X,b:Q}){return`#${[J,X,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function qq({r:J,g:X,b:Q}){J/=255,X/=255,Q/=255;let Y=Math.max(J,X,Q),W=Math.min(J,X,Q),G=Y-W,Z=0;if(G){if(Y===J)Z=(X-Q)/G%6;else if(Y===X)Z=(Q-J)/G+2;else Z=(J-X)/G+4;if(Z*=60,Z<0)Z+=360}return{h:Z,s:Y?G/Y:0,v:Y}}function eK({h:J,s:X,v:Q}){let Y=Q*X,W=Y*(1-Math.abs(J/60%2-1)),G=Q-Y,Z=0,H=0,K=0;if(J<60)[Z,H,K]=[Y,W,0];else if(J<120)[Z,H,K]=[W,Y,0];else if(J<180)[Z,H,K]=[0,Y,W];else if(J<240)[Z,H,K]=[0,W,Y];else if(J<300)[Z,H,K]=[W,0,Y];else[Z,H,K]=[Y,0,W];return{r:(Z+G)*255,g:(H+G)*255,b:(K+G)*255}}function U7(J){if(!J)return"";let X=/^(-?\d*\.?\d+)px$/.exec(J);return X?`${Math.round(Number.parseFloat(X[1]))}px`:J}function Q4(J){if(!J)return{n:"",unit:"px"};let X=J.trim(),Q=/^(-?\d*\.?\d+)\s*(px|rem|em|%|vw|vh)?$/.exec(X);if(Q)return{n:Q[1],unit:Q[2]||"px"};if(X==="auto")return{n:"",unit:"auto"};return{n:X,unit:""}}function N80(J,X){if(!J||Array.isArray(J)||Array.isArray(X)||!X)return J;if(!J.id&&!X.id){let Q=(Y)=>typeof Y.selector==="string"&&Y.selector.startsWith("[data-dc-screen=");if(Q(J)&&Q(X)&&J.selector===X.selector&&J.file===X.file)return{...J,authored:J.authored??X.authored,computed:J.computed??X.computed,customStyles:J.customStyles??X.customStyles,attrs:J.attrs??X.attrs,artboardId:J.artboardId??X.artboardId,worldW:J.worldW??X.worldW,worldH:J.worldH??X.worldH};return J}if(!J.id||J.id!==X.id)return J;return{...J,authored:J.authored??X.authored,computed:J.computed??X.computed,customStyles:J.customStyles??X.customStyles,attrs:J.attrs??X.attrs,photoKind:J.photoKind??X.photoKind,photoAsset:J.photoAsset??X.photoAsset}}function E80(J,X){return(J?X?.canvasDesignSystems?.[J]:null)||X?.defaultDesignSystem||X?.designSystems?.[0]?.name||null}function KL0(J){let X={};for(let Z of J.matchAll(/(--[a-z0-9-]+)\s*:\s*([^;}]+)/gi))if(!(Z[1]in X))X[Z[1]]=Z[2].trim();let Q={};for(let Z of Object.keys(X)){let H=X[Z],K=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(H);Q[Z]=K&&X[K[1]]?X[K[1]]:H}let Y=Object.keys(X),W=(Z)=>Y.filter((H)=>Z.test(H)),G=(Z)=>/^(#[0-9a-f]{3,8}|rgba?\(|hsla?\(|oklch\(|oklab\(|lab\(|lch\(|hwb\(|color\()/i.test(Z)||/^(transparent|currentcolor|white|black|red|green|blue|gray|grey|orange|yellow|purple|pink|cyan|magenta|teal|navy|maroon|olive|lime|aqua|silver|gold)$/i.test(Z);return{color:Y.filter((Z)=>G(Q[Z])),space:W(/^--space-/),radius:W(/^--radius-/),type:W(/^--type-/),shadow:W(/^--shadow-/),lh:W(/^--lh-/),vals:Q}}function P80(J,X,Q){let Y=J?.designSystems||[],W=Y.map((H)=>`${H.name}:${H.tokensCssRel}`).join("|"),[G,Z]=u.useState([]);return u.useEffect(()=>{if(!Y.length)return;let H=!1;return Promise.all(Y.map(async(K)=>{if(!K.tokensCssRel)return null;try{let U=await fetch(`/${X}/${K.tokensCssRel}`),V=U.ok?await U.text():"";return{name:K.name,...KL0(V)}}catch{return null}})).then((K)=>{if(H)return;let U=K.filter(Boolean);U.sort((V,B)=>V.name===Q?-1:B.name===Q?1:0),Z(U)}),()=>{H=!0}},[W,X,Q]),G}function I80({seed:J,label:X,onApply:Q}){let[Y,W]=u.useState(()=>qq(GL(J||"#000000"))),G=u.useRef(Y);G.current=Y;let Z=u.useRef(null),H=u.useRef(null),K=u.useRef(J);u.useEffect(()=>{if(J&&J!==K.current)K.current=J,W(qq(GL(J)))},[J]);let U=Vq(eK(Y)),V=(O)=>{O.preventDefault();let I=Z.current?.getBoundingClientRect();if(!I)return;let k=G.current.h,R=(C)=>{W({h:k,s:UY((C.clientX-I.left)/I.width),v:UY(1-(C.clientY-I.top)/I.height)})};R(O);let $=()=>{document.removeEventListener("pointermove",R),document.removeEventListener("pointerup",$),Q(Vq(eK(G.current)))};document.addEventListener("pointermove",R),document.addEventListener("pointerup",$)},B=(O)=>{O.preventDefault();let I=H.current?.getBoundingClientRect();if(!I)return;let{s:k,v:R}=G.current,$=(j)=>{W({h:UY((j.clientX-I.left)/I.width)*360,s:k,v:R})};$(O);let C=()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",C),Q(Vq(eK(G.current)))};document.addEventListener("pointermove",$),document.addEventListener("pointerup",C)},N=(O)=>{let I={...G.current,...O};W(I),Q(Vq(eK(I)))},F=(O)=>{let I=O.shiftKey?0.1:0.02,R={ArrowLeft:[-I,0],ArrowRight:[I,0],ArrowUp:[0,I],ArrowDown:[0,-I]}[O.key];if(!R)return;O.preventDefault(),N({s:UY(G.current.s+R[0]),v:UY(G.current.v+R[1])})},M=(O)=>{let I=O.shiftKey?20:2,R={ArrowLeft:-I,ArrowRight:I}[O.key];if(R==null)return;O.preventDefault(),N({h:Math.min(360,Math.max(0,G.current.h+R))})},A=async()=>{try{let O=window.EyeDropper;if(!O)return;let I=await new O().open();if(I?.sRGBHex)W(qq(GL(I.sRGBHex))),Q(I.sRGBHex)}catch{}},E=eK(Y),w=(O)=>{let I={...E,...O},k=qq({r:UY(I.r/255)*255,g:UY(I.g/255)*255,b:UY(I.b/255)*255});W(k),Q(Vq(eK(k)))};return D("div",{className:"st-cp-cpick",children:[D("div",{className:"st-cp-cpick-hexrow",children:[z("span",{className:"st-cp-cpick-hexsw",style:{background:U}}),z("input",{className:"st-cp-cpick-hex",type:"text",value:U,"aria-label":X?`${X} hex value`:"hex value",onChange:(O)=>{let I=O.target.value;if(/^#?[0-9a-f]{6}$/i.test(I))W(qq(GL(I)))},onKeyDown:(O)=>{if(O.key==="Enter")Q(O.currentTarget.value)},onBlur:(O)=>Q(O.currentTarget.value),onFocus:(O)=>O.currentTarget.select()})]}),D("button",{type:"button",ref:Z,className:"st-cp-cpick-sv","aria-label":X?`${X} saturation and value`:"saturation and value",style:{background:`hsl(${Y.h} 100% 50%)`},onPointerDown:V,onKeyDown:F,children:[z("span",{className:"st-cp-cpick-svwhite"}),z("span",{className:"st-cp-cpick-svblack"}),z("span",{className:"st-cp-cpick-knob",style:{left:`${Y.s*100}%`,top:`${(1-Y.v)*100}%`,background:U}})]}),D("div",{className:"st-cp-cpick-controls",children:[window.EyeDropper?z("button",{type:"button",className:"st-cp-cpick-eye","aria-label":"pick from screen",title:"eyedropper",onClick:A,children:z(T8,{name:"eyedropper",size:14})}):null,z("span",{className:"st-cp-cpick-preview",style:{background:U},"aria-hidden":"true"}),z("button",{type:"button",ref:H,className:"st-cp-cpick-hue","aria-label":X?`${X} hue`:"hue",onPointerDown:B,onKeyDown:M,children:z("span",{className:"st-cp-cpick-huethumb",style:{left:`${Y.h/360*100}%`}})})]}),z("div",{className:"st-cp-cpick-rgb",children:["r","g","b"].map((O)=>D("label",{className:"st-cp-cpick-rgbf",children:[z("input",{"aria-label":O.toUpperCase(),value:Math.round(E[O]),onChange:(I)=>w({[O]:UY((Number.parseFloat(I.target.value)||0)/255)*255}),onFocus:(I)=>I.currentTarget.select()}),z("span",{children:O.toUpperCase()})]},O))})]})}function zL({kind:J,groups:X,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:K}){let[U,V]=u.useState(!1),[B,N]=u.useState(null),[F,M]=u.useState("custom"),[A,E]=u.useState(""),w=u.useRef(null),O=u.useRef(null),I=typeof Q==="string"&&/var\(\s*--/.test(Q),k=(e)=>Q===`var(${e})`,R=(e)=>e.replace(/^--/,"").replace(/-/g," "),$=X||[],C=$.reduce((e,c)=>e+(c.names?.length||0),0),j=$.length>1,x=A.trim().toLowerCase(),m=!x?$:$.map((e)=>({...e,names:(e.names||[]).filter((c)=>R(c).toLowerCase().includes(x)||c.toLowerCase().includes(x)||(e.vals?.[c]||"").toLowerCase().includes(x))})).filter((e)=>e.names.length);u.useEffect(()=>{if(!U){E("");return}let e=()=>{let z0=w.current?.getBoundingClientRect();if(!z0)return;let o=224,q0=300,Z0=Math.min(z0.right-o,window.innerWidth-o-8);if(Z0<8)Z0=8;let a0=window.innerHeight-z0.bottom>q0+8?z0.bottom+4:Math.max(8,z0.top-q0-4);N({left:Z0,top:a0,width:o,maxHeight:q0})};e();let c=(z0)=>{if(O.current?.contains(z0.target)||w.current?.contains(z0.target))return;V(!1)},K0=(z0)=>{if(z0.key==="Escape")V(!1)},s=(z0)=>{if(O.current?.contains(z0.target))return;e()};return document.addEventListener("pointerdown",c,!0),document.addEventListener("keydown",K0),window.addEventListener("resize",e),document.addEventListener("scroll",s,!0),()=>{document.removeEventListener("pointerdown",c,!0),document.removeEventListener("keydown",K0),window.removeEventListener("resize",e),document.removeEventListener("scroll",s,!0)}},[U]),u.useEffect(()=>{if(!U||!B||!O.current)return;let e=O.current.getBoundingClientRect(),c=B.left-e.left,K0=B.top-e.top;if(Math.abs(c)>0.5||Math.abs(K0)>0.5)N((s)=>s?{...s,left:s.left+c,top:s.top+K0}:s)},[U,B]);let d=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,a=(e,c,K0)=>{if(H&&e&&e!==H&&K0&&!d.test(K0))Y(K0);else Y(`var(${c})`);V(!1)},f=(e)=>{let c=(e||"").trim();if(c)Y(c)},h=D("div",{className:"st-cp-pop-search",children:[z(T8,{name:"search",size:12}),z("input",{value:A,onChange:(e)=>E(e.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),p=(e)=>e.map((c)=>D("div",{className:"st-cp-pop-group",children:[j?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((K0)=>D("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${k(K0)?" is-on":""}`,onClick:()=>a(c.ds,K0,c.vals?.[K0]),children:[z("span",{className:"st-cp-pop-cswatch",style:{background:c.vals?.[K0]||"transparent"},"aria-hidden":"true"}),z("span",{className:"st-cp-pop-name",children:R(K0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[K0]||""})]},`${c.ds}:${K0}`))})]},c.ds)),v=(e)=>e.map((c)=>D("div",{className:"st-cp-pop-group",children:[j?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((K0)=>D("button",{type:"button",className:`st-cp-pop-row${k(K0)?" is-on":""}`,onClick:()=>a(c.ds,K0,c.vals?.[K0]),children:[z("span",{className:"st-cp-pop-name",children:R(K0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[K0]||""})]},`${c.ds}:${K0}`))})]},c.ds)),r=z("div",{className:"st-cp-pop-empty",children:"No match"});return D(Q0,{children:[G!==void 0?z("button",{type:"button",ref:w,className:`${K||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${I&&!K?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>V((e)=>!e),children:z("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):z("button",{type:"button",ref:w,className:`st-cp-tokbtn${I?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>V((e)=>!e),children:z("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),U&&B?L80.createPortal(z("div",{ref:O,className:"maude st-cp-pop","data-theme":typeof document<"u"&&document.documentElement.getAttribute("data-theme")||"dark",role:"dialog","aria-label":W||"design tokens",style:{left:B.left,top:B.top,width:B.width,maxHeight:B.maxHeight},children:J==="color"?D(Q0,{children:[D("div",{className:"st-cp-poptabs",role:"tablist",children:[z("button",{type:"button",role:"tab","aria-selected":F==="custom",className:`st-cp-poptab${F==="custom"?" is-active":""}`,onClick:()=>M("custom"),children:"Custom"}),z("button",{type:"button",role:"tab","aria-selected":F==="vars",className:`st-cp-poptab${F==="vars"?" is-active":""}`,onClick:()=>M("vars"),children:"Variables"})]}),F==="custom"?z(I80,{seed:Z||qL(Q)||"#000000",onApply:f}):!C?z("div",{className:"st-cp-pop-empty",children:"No color tokens"}):D(Q0,{children:[h,m.length?p(m):r]})]}):!C?z("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):D(Q0,{children:[h,m.length?v(m):r]})}),document.body):null]})}function F80({label:J,tracks:X,editable:Q,onChange:Y}){let W=(K,U)=>{let V=X[K];Y(X.map((B,N)=>N===K?CU.has(U)?{value:0,unit:U}:{value:V.value||1,unit:U}:B))},G=(K,U)=>{Y(X.map((V,B)=>B===K?{...V,value:U}:V))},Z=()=>Y([...X,{value:1,unit:"fr"}]),H=(K)=>Y(X.filter((U,V)=>V!==K));return D("div",{className:"st-cp-gridtracks",children:[D("div",{className:"st-cp-gridtracks-hd",children:[z("span",{className:"st-cp-gridtracks-label",children:J}),z("button",{type:"button",className:"st-btn st-cp-gridtracks-add",disabled:!Q,onClick:Z,children:"+ Track"})]}),X.length===0?D("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",J.toLowerCase(),"."]}):X.map((K,U)=>{let V=CU.has(K.unit);return D("div",{className:"st-cp-gridtrack-row",children:[V?z(cW,{value:K.unit,ariaLabel:`${J} track ${U+1}`,options:Y80.map((B)=>({value:B,label:B})),onChange:(B)=>W(U,B)}):z(zJ,{value:K.value,min:K.unit==="fr"?0.1:0,step:K.unit==="fr"?0.1:1,ariaLabel:`${J} track ${U+1} value`,lead:String(U+1),unitSlot:z(mN,{value:K.unit,units:Y80,ariaLabel:`${J} track ${U+1} unit`,onChange:(B)=>W(U,B)}),onCommit:(B)=>G(U,B)}),z("button",{type:"button",className:"st-btn st-cp-gridtrack-remove","aria-label":`remove ${J} track ${U+1}`,disabled:!Q||X.length<=1,onClick:()=>H(U),children:"×"})]},U)})]})}function UL0({el:J,cfg:X,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let K=!!J.id,U=J.computed||{},[V,B]=u.useState({a:{},c:{},t:{}});u.useEffect(()=>{B({a:{},c:{},t:{}})},[J.id,J.authored,J.customStyles,J.attrs]);let N=(t,M0)=>{let _0={...t||{}};for(let[f0,Y9]of Object.entries(M0))if(Y9===null)delete _0[f0];else _0[f0]=Y9;return _0},F=N(J.authored,V.a),M=N(J.customStyles,V.c),A=N(J.attrs,V.t),E=(t,M0)=>B((_0)=>({..._0,a:{..._0.a,[t]:M0}})),w=(t,M0)=>B((_0)=>({..._0,c:{..._0.c,[t]:M0}})),O=(t,M0)=>B((_0)=>({..._0,t:{..._0.t,[t]:M0}})),I=(X?.designRel||X?.designRoot||".design").replace(/^\/+|\/+$/g,""),k=E80(J.file,X),R=P80(X,I,k),$=(t)=>R.map((M0)=>({ds:M0.name,names:M0[t]||[],vals:M0.vals})).filter((M0)=>M0.names.length),[C,j]=u.useState({}),[x,m]=u.useState({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),d=Object.keys(M).length>0||Object.keys(A).length>0;u.useEffect(()=>{if(d)m((t)=>t.Advanced?t:{...t,Advanced:!0})},[J.id,d]);let a=(F.position||U7(U.position)||"static")!=="static";u.useEffect(()=>{if(a)m((t)=>t["d:Position"]?t:{...t,"d:Position":!0})},[J.id,a]);let f=H,[h,p]=u.useState({});async function v(t,M0,_0){j((f0)=>({...f0,[_0]:"saving"}));try{let f0=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(M0)}),Y9=await f0.json().catch(()=>({}));return j((m9)=>({...m9,[_0]:!f0.ok||!Y9.ok?`err:${Y9&&Y9.error||`HTTP ${f0.status}`}`:"saved"})),f0.ok?Y9:null}catch(f0){return j((Y9)=>({...Y9,[_0]:`err:${f0&&f0.message?f0.message:String(f0)}`})),null}}let r=u.useRef(Promise.resolve()),e=(t,M0,_0,f0,Y9,m9,e9)=>{r.current=r.current.then(async()=>{let y9=await v(t,M0,_0);if(!y9?.ok)return;let W8=Object.hasOwn(y9,"previous")?y9.previous:m9;if((W8??null)===(e9??null))return;K0(f0,Y9,W8,e9)})},c=(t,M0)=>{if(!Q||!J.id)return;Q({id:J.id,artboardId:J.artboardId??null,index:J.index??0,prop:t,value:M0})},K0=(t,M0,_0,f0)=>{Y?.({op:t,canvas:J.file,id:J.id,key:M0,before:_0==null||_0===""?null:_0,after:f0==null||f0===""?null:f0})},s=(t,M0)=>{let _0=(M0||"").trim();if(!K||!_0)return;let f0=F[t]??null;if(_0===(f0??"").trim())return;c(t,_0),E(t,_0),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,value:_0},t,"css",t,f0,_0)},z0=(t,M0)=>{let _0=(M0||"").trim(),f0=t.trim();if(!K||!f0||!_0)return;let Y9=M[f0]??null;c(f0,_0),w(f0,_0),e("/_api/edit-css",{canvas:J.file,id:J.id,property:f0,value:_0},f0,"css",f0,Y9,_0)},o=(t,M0)=>{let _0=(t||"").trim(),f0=(M0||"").trim();if(!K||!_0||!f0)return;let Y9=A[_0]??null;O(_0,f0),e("/_api/edit-attr",{canvas:J.file,id:J.id,attr:_0,value:f0},`@${_0}`,"attr",_0,Y9,f0)},q0=(t)=>{if(!K)return;let M0=F[t]??null;c(t,null),E(t,null),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,reset:!0},t,"css",t,M0,null)},Z0=(t)=>{if(!K)return;let M0=M[t]??null;c(t,null),w(t,null),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,reset:!0},t,"css",t,M0,null)},k0=(t)=>{if(!K)return;let M0=A[t]??null;O(t,null),e("/_api/edit-attr",{canvas:J.file,id:J.id,attr:t,reset:!0},`@${t}`,"attr",t,M0,null)},a0={display:J.parentDisplay,flexDirection:J.parentFlexDirection},s0=(t,M0)=>{if(!K)return;let _0=Math.round((t==="width"?J.bounds?.w:J.bounds?.h)||0),f0=Sb(t,M0,a0,_0);for(let Y9 of f0.reset)if(F[Y9])q0(Y9);for(let[Y9,m9]of f0.set)s(Y9,m9)},t0=J.parentDisplay==="flex"||J.parentDisplay==="inline-flex",E9=(t)=>{let M0=$b(t,F,U,a0);return D("div",{className:"st-cp-moderow",children:[z("span",{className:"st-cp-modelabel",children:t==="width"?"Width sizing":"Height sizing"}),z("div",{className:"st-cp-modeseg",role:"group","aria-label":`${t} sizing mode`,children:z(uN,{value:M0,ariaLabel:`${t} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(_0)=>s0(t,_0)})})]},`mode-${t}`)},a9=["flex-start","center","flex-end"],F9=["flex-start","center","flex-end"],T9=["t","c","b"],I0=["l","c","r"],w0=()=>{let t=!(F["flex-direction"]||U7(U["flex-direction"])||"row").startsWith("column"),M0=Math.max(0,a9.indexOf(F["justify-content"]||U7(U["justify-content"])||"flex-start")),_0=F["align-items"]||U7(U["align-items"])||"stretch",f0=_0==="stretch"?1:Math.max(0,F9.indexOf(_0)),[Y9,m9]=t?[M0,f0]:[f0,M0];return T9[m9]+I0[Y9]},C0=(t)=>{let M0=T9.indexOf(t[0]),_0=I0.indexOf(t[1]),f0=!(F["flex-direction"]||U7(U["flex-direction"])||"row").startsWith("column"),[Y9,m9]=f0?[_0,M0]:[M0,_0];s("justify-content",a9[Y9]),s("align-items",F9[m9])},W9=(t)=>{if(!(t.metaKey||t.ctrlKey)||t.altKey)return;let M0=t.key.toLowerCase();if(M0==="z")t.preventDefault(),G?.(t.shiftKey?"redo":"undo");else if(M0==="y")t.preventDefault(),G?.("redo")},H9=(t)=>{let M0=F[t];if(!M0)return"inherit";return/var\(\s*--/.test(M0)?"bound":"raw"};if(!K)return D("div",{className:"st-cp",children:[z("div",{className:"st-cp-id",children:z("span",{className:"st-cp-idtag",children:J.tag||"element"})}),D("div",{className:"st-css-disabled",children:["This selection has no stable element id (a legacy canvas, or a non-element target). Edit it with ",z("code",{children:"/design:edit"}),"."]})]});let x9={bound:"token-bound",raw:"raw override",inherit:"inherited"},S9=(t)=>z("span",{className:`st-cp-prov st-cp-prov--${t}`,role:"img","aria-label":x9[t]}),O8=(t,M0)=>{let _0=M0??H9(t),f0=C[t],Y9=typeof f0==="string"&&f0.startsWith("err:")?f0.slice(4):"",m9=Y9?" is-err":f0==="saved"?" is-saved":f0==="saving"?" is-saving":"",e9=!!F[t],y9=Y9?`error: ${Y9}`:e9?`${x9[_0]} · double-click to reset`:x9[_0];return z("button",{type:"button",className:`st-cp-prov st-cp-prov--${_0}${m9}${e9?" is-resettable":""}`,"aria-label":y9,title:y9,tabIndex:e9?0:-1,onDoubleClick:e9?()=>q0(t):void 0,onKeyDown:e9?(W8)=>{if(W8.key==="Backspace"||W8.key==="Delete")W8.preventDefault(),q0(t)}:void 0})},v0=(t,M0,_0,f0)=>{let Y9=_0===void 0&&!F[t],m9=f0??t;return D("div",{className:`st-cp-row${Y9?" is-unset":""}`,children:[O8(t,_0),z("label",{className:"st-cp-label",title:m9,children:m9}),z("div",{className:"st-cp-ctl",children:M0})]},t)},$9={Layout:["display","flex-direction","flex-wrap","align-items","justify-content","gap"],Grid:["grid-template-columns","grid-template-rows"],"Grid item":["grid-column","grid-row"],Position:["position","top","right","bottom","left","z-index"],Typography:["font-family","color","font-size","font-weight","line-height","letter-spacing","text-align","font-style","text-transform","text-decoration","white-space"],Spacing:["margin-top","margin-right","margin-bottom","margin-left","padding-top","padding-right","padding-bottom","padding-left"],Size:["width","height","min-width","min-height","max-width","max-height","overflow","flex-grow","flex-shrink","flex-basis","align-self"],Media:["object-fit","aspect-ratio","object-position"],Appearance:["background-color","border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius","border-width","border-style","border-color","box-shadow","filter","mix-blend-mode","opacity","transform","transform-origin"]},w8=(t)=>{($9[t]||[]).forEach((M0)=>{if(F[M0])q0(M0)})},L9=(t,M0)=>{let _0=($9[t]||[]).some((f0)=>F[f0]);return D("section",{className:"st-cp-sec",children:[D("div",{className:"st-cp-sechd-row",children:[D("button",{type:"button",className:"st-cp-sechd","data-testid":`inspector-section-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,"aria-expanded":!!x[t],onClick:()=>m((f0)=>({...f0,[t]:!f0[t]})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:x[t]?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${_0?"":" is-quiet"}`,"aria-label":`reset ${t} section to original`,title:`reset ${t}`,disabled:!_0,onClick:()=>w8(t),children:z(K7,{as:oZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${x[t]?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:M0})})]},t)},V0=(t,M0,_0,f0=!0)=>{let Y9=`d:${t}`,m9=x[Y9]===void 0?f0:x[Y9],e9=M0.some((y9)=>F[y9]);return D("section",{className:"st-cp-sec",children:[D("div",{className:"st-cp-sechd-row",children:[D("button",{type:"button",className:"st-cp-sechd","aria-expanded":m9,onClick:()=>m((y9)=>({...y9,[Y9]:!m9})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:m9?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${e9?"":" is-quiet"}`,"aria-label":`reset ${t} to original`,title:`reset ${t}`,disabled:!e9,onClick:()=>M0.forEach((y9)=>{if(F[y9])q0(y9)}),children:z(K7,{as:oZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${m9?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:_0})})]},Y9)},J9=(t)=>z("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!h[t],"aria-label":h[t]?`${t} — fewer options`:`${t} — more options`,title:h[t]?"fewer":"more",onClick:()=>p((M0)=>({...M0,[t]:!M0[t]})),children:h[t]?"▴":"···"}),r0=(t,M0)=>D("select",{className:"st-cp-nsel","aria-label":t,value:M0.includes(F[t])?F[t]:"",onChange:(_0)=>s(t,_0.target.value),children:[z("option",{value:"",disabled:!0,children:U7(U[t])||"—"}),M0.map((_0)=>z("option",{value:_0,children:_0},_0))]}),b0=(t)=>$(t).flatMap((M0)=>(M0.names||[]).map((_0)=>({name:_0,value:M0.vals?.[_0]||""}))),X9=(t,M0)=>z(xw,{value:F[t]||U7(U[t])||M0[0].value,ariaLabel:t,options:M0,onChange:(_0)=>s(t,_0)}),q9=(t,M0,_0={})=>{let f0=Q4(F[t]??""),Y9=z80.has(t),m9=F[t]??"",e9=typeof m9==="string"&&/var\(\s*--/.test(m9),y9=Y9?"":f0.unit&&f0.unit!=="auto"?f0.unit:"px",W8=Number.parseFloat(Q4(U7(U[t])??"").n)||0,k8=f0.n!==""&&f0.n!=null?Number.parseFloat(f0.n)||0:W8,e8=Yk[t];return z(pN,{value:e9?m9:k8,tokens:b0(M0),ariaLabel:t,min:_0.min??0,lead:e8?e8.node??e8.t:void 0,unitSlot:Y9?null:z(mN,{units:H80,value:f0.unit||"px",ariaLabel:`${t} unit`,onChange:(J7)=>s(t,J7==="auto"?"auto":`${f0.n||"0"}${J7}`)}),onChange:(J7)=>s(t,typeof J7==="string"?J7:Y9?`${J7}`:`${J7}${y9}`)})},l0=()=>{let t=(Y9)=>Number.parseFloat(Q4(F[Y9]??F["border-radius"]??U7(U[Y9])??U7(U["border-radius"])??"0").n)||0,M0={tl:t("border-top-left-radius"),tr:t("border-top-right-radius"),bl:t("border-bottom-left-radius"),br:t("border-bottom-right-radius")},_0=(Y9)=>{if(Y9.tl===Y9.tr&&Y9.tr===Y9.bl&&Y9.bl===Y9.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((e9)=>{if(F[e9])q0(e9)}),s("border-radius",`${Y9.tl}px`);else s("border-top-left-radius",`${Y9.tl}px`),s("border-top-right-radius",`${Y9.tr}px`),s("border-bottom-left-radius",`${Y9.bl}px`),s("border-bottom-right-radius",`${Y9.br}px`)},f0=Yk["border-radius"];return z(yg,{corners:M0,lead:f0?f0.node??f0.t:void 0,onCorners:_0})},d0=()=>D("div",{className:"st-cp-border",children:[Q8("border-width",null,{fixedUnit:"px"}),D("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:Z80.includes(F["border-style"])?F["border-style"]:"",onChange:(t)=>s("border-style",t.target.value),children:[z("option",{value:"",disabled:!0,children:"style"}),Z80.map((t)=>z("option",{value:t,children:t},t))]}),z(zL,{kind:"color",groups:$("color"),current:F["border-color"],activeDs:k,swatchBg:U["border-color"]||F["border-color"]||"",seedHex:qL(U["border-color"]||F["border-color"])||"#000000",onPick:(t)=>s("border-color",t),label:"border colour"})]}),h0=()=>{let t=F.transform||U7(U.transform)||"",M0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(t),_0=((M0?Number.parseFloat(M0[1]):0)%360+360)%360,f0=(Y9)=>{let m9=(Y9%360+360)%360,e9=(F.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();s("transform",`${e9?`${e9} `:""}rotate(${m9}deg)`.trim())};return D("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[z(Sg,{value:_0,onChange:f0}),z(zJ,{value:_0,min:0,max:360,ariaLabel:"rotation",lead:z(K7,{as:oZ}),steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:f0})]})},y0=()=>{let t=F.filter||U7(U.filter)||"",M0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(t),_0=M0?Number.parseFloat(M0[1]):0;return z(zJ,{value:_0,min:0,ariaLabel:"filter blur",unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(Y9)=>{let m9=(F.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();s("filter",Y9>0?`${m9?`${m9} `:""}blur(${Y9}px)`.trim():m9||"none")}})},B9=()=>{let t=F.opacity,M0=t!=null&&t!==""?Number.parseFloat(t):Number.parseFloat(U7(U.opacity))||1,_0=Math.round((Number.isNaN(M0)?1:M0)*100);return z(mX,{value:_0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(f0)=>c("opacity",String(f0/100)),onCommit:(f0)=>s("opacity",String(f0/100))},`opacity:${t??""}`)},D9=()=>{let t=Number.parseInt(F["font-weight"]||U7(U["font-weight"])||"400",10)>=600,M0=(F["font-style"]||U7(U["font-style"]))==="italic",_0=/underline/.test(F["text-decoration"]||U7(U["text-decoration"])||"");return z(Cg,{value:{b:t,i:M0,u:_0},ariaLabel:"text style",options:[{value:"b",node:z(K7,{as:mV}),label:"Bold"},{value:"i",node:z(K7,{as:cV}),label:"Italic"},{value:"u",node:z(K7,{as:Q3}),label:"Underline"}],onToggle:(f0)=>{if(f0==="b")s("font-weight",t?"400":"700");else if(f0==="i")s("font-style",M0?"normal":"italic");else s("text-decoration",_0?"none":"underline")}})},N0=[{value:"row",node:z(K7,{as:vW}),label:"Row"},{value:"column",node:z(K7,{as:fW}),label:"Column"}],o0=[{value:"flex-start",node:z(K7,{as:vV}),label:"Start"},{value:"center",node:z(K7,{as:yV}),label:"Center"},{value:"flex-end",node:z(K7,{as:jV}),label:"End"},{value:"space-between",node:z(K7,{as:PK}),label:"Space between"}],h9=[{value:"flex-start",node:z(K7,{as:hV}),label:"Start"},{value:"center",node:z(K7,{as:fV}),label:"Center"},{value:"flex-end",node:z(K7,{as:xV}),label:"End"},{value:"stretch",node:z(K7,{as:J3}),label:"Stretch"}],g9=[{value:"left",node:z(K7,{as:tQ}),label:"Left"},{value:"center",node:z(K7,{as:gW}),label:"Center"},{value:"right",node:z(K7,{as:mW}),label:"Right"},{value:"justify",node:z(K7,{as:uW}),label:"Justify"}],e0=[{value:"visible",node:z(K7,{as:iZ}),label:"Visible"},{value:"hidden",node:z(K7,{as:nZ}),label:"Hidden"},{value:"scroll",node:z(K7,{as:sV}),label:"Scroll"}],a7=(t,M0)=>{let _0=$(M0);return _0.length?z(zL,{kind:"value",groups:_0,current:F[t],activeDs:k,onPick:(f0)=>s(t,f0),label:`${t} design token`}):null},F8=(t)=>{let M0=t.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===M0)M0.select()})},v7=(t,M0)=>{if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return!1;t.preventDefault();let _0=t.shiftKey?10:1,f0=t.key==="ArrowUp"?1:-1,Y9=(Number.parseFloat(t.currentTarget.value)||0)+f0*_0;return t.currentTarget.value=String(Y9),M0(Y9),!0},I9=(t)=>z("input",{className:"st-cp-fin","aria-label":t,defaultValue:F[t]??"",placeholder:U7(U[t])||"—",onFocus:F8,onKeyDown:(M0)=>{if(M0.key==="Enter")M0.currentTarget.blur()},onBlur:(M0)=>s(t,M0.currentTarget.value)},`${t}:${F[t]??""}`),Q8=(t,M0,_0={})=>{let f0=Q4(F[t]??""),Y9=z80.has(t),m9=Y9?"":_0.fixedUnit||(f0.unit&&f0.unit!=="auto"?f0.unit:"px"),e9=Yk[t],y9=Number.parseFloat(Q4(U7(U[t])??"").n)||0,W8=f0.n!==""&&f0.n!=null?Number.parseFloat(f0.n)||0:y9;return D(Q0,{children:[z(zJ,{value:W8,min:_0.min??0,step:1,ariaLabel:t,lead:e9?e9.node??e9.t:void 0,onCommit:(k8)=>s(t,Y9?`${k8}`:`${k8}${m9}`),unitSlot:Y9||_0.fixedUnit?null:z(mN,{units:H80,value:f0.unit||"px",ariaLabel:`${t} unit`,onChange:(k8)=>s(t,k8==="auto"?"auto":`${f0.n||"0"}${k8}`)})},`${t}:${F[t]??""}`),a7(t,M0)]})},c9=(t)=>{let M0=U[t]||F[t]||"",_0=F[t]??"",f0=typeof _0==="string"&&/var\(\s*--/.test(_0),Y9=f0?_0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):_0;return z(W3,{swatch:z(zL,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:$("color"),current:F[t],activeDs:k,swatchBg:M0,seedHex:qL(U[t]||F[t])||"#000000",onPick:(m9)=>s(t,m9),label:`${t} colour`}),displayValue:Y9,bound:f0,ariaLabel:t,onValue:(m9)=>s(t,m9)})},O0=(t,M0)=>{let _0=null,f0=M0.unitless?"":"px",Y9=(y9)=>M0.unitless?`${y9}`:`${y9}${f0}`,m9=(y9,W8,k8)=>{for(let e8 of W8??[t])k8(e8,Y9(y9))},e9=fw({getBase:()=>_0?.value??"0",min:M0.min??0,step:1,sides:M0.sides,onInput:(y9,W8)=>{if(_0)_0.value=String(y9);if(W8){let k8=_0?.closest(".st-cp-box");for(let e8 of W8){if(e8===t)continue;let J7=k8?.querySelector(`.st-cp-boxv[aria-label="${e8}"]`);if(J7)J7.value=String(y9)}}m9(y9,W8,c)},onCommit:(y9,W8)=>m9(y9,W8,s)});return{onPointerDown:(y9)=>{_0=y9.currentTarget,e9(y9)}}},K9=(t,M0)=>{let _0=F[t],f0=_0!=null&&_0!==""?Q4(_0).n||_0:Q4(U7(U[t])??"").n||"0",Y9=!_0||_0==="0"||_0==="0px"||_0==="auto",m9=t.split("-").pop(),e9=m9==="top"||m9==="bottom"?[`${M0}-top`,`${M0}-bottom`]:[`${M0}-left`,`${M0}-right`],y9=[`${M0}-top`,`${M0}-right`,`${M0}-bottom`,`${M0}-left`];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${M0[0]}${t.split("-").pop()[0]}${Y9?" is-zero":""}`,"aria-label":t,defaultValue:f0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...O0(t,{sides:{pair:e9,all:y9}}),onFocus:F8,onKeyDown:(W8)=>{if(v7(W8,(k8)=>s(t,`${k8}px`)))return;if(W8.key==="Enter")W8.currentTarget.blur()},onBlur:(W8)=>{let k8=W8.currentTarget.value.trim();if(!k8)return;let e8=/[a-z%]/i.test(k8)?k8:`${k8}px`;s(t,e8)}},`${t}:${_0??""}`)},C9=(t)=>{let M0=F[t],_0=M0!=null&&M0!==""&&M0!=="auto"?Q4(M0).n||M0:Q4(U7(U[t])??"").n||"",f0=!M0||M0==="auto"||M0==="0"||M0==="0px",Y9=t==="top"||t==="bottom"?["top","bottom"]:["left","right"],m9=["top","right","bottom","left"];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${t[0]}${f0?" is-zero":""}`,"aria-label":t,defaultValue:_0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...O0(t,{sides:{pair:Y9,all:m9},min:-1/0}),onFocus:F8,onKeyDown:(e9)=>{if(v7(e9,(y9)=>s(t,`${y9}px`)))return;if(e9.key==="Enter")e9.currentTarget.blur()},onBlur:(e9)=>{let y9=e9.currentTarget.value.trim();if(!y9)return;let W8=/[a-z%]/i.test(y9)?y9:`${y9}px`;s(t,W8)}},`${t}:${M0??""}`)},V8=Object.entries(M),x8=Object.entries(A),i8=()=>{let t=(J.tag||"").toLowerCase(),_0=t==="img"||t==="video"||t==="picture"||t==="svg"||t==="canvas"||!!F["object-fit"]||!!F["object-position"]||!!F["aspect-ratio"],f0=(t==="img"||t==="video")&&!!J.attrs?.src&&!!W;return{showMedia:_0,canReplace:f0}},h8=(t)=>D(Q0,{children:[t&&z("div",{className:"st-cp-mediabtn",children:z("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>W(J),children:"Replace…"})}),v0("object-fit",r0("object-fit",zL0)),v0("object-position",I9("object-position")),v0("aspect-ratio",D("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:B80.includes(F["aspect-ratio"])?F["aspect-ratio"]:"",onChange:(M0)=>{let _0=M0.target.value;if(s("aspect-ratio",_0),_0&&_0!=="auto"&&F.height)q0("height")},children:[z("option",{value:"",disabled:!0,children:U7(U["aspect-ratio"])||"—"}),B80.map((M0)=>z("option",{value:M0,children:M0},M0))]}))]});return D("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:W9,children:[D("div",{className:"st-cp-id",children:[D("span",{className:"st-cp-idtag",children:[J.tag||"element",J.classes?D("span",{className:"st-cp-idcls",children:[".",J.classes.split(/\s+/)[0]]}):null]}),z("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:z(xw,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:z(K7,{as:jW,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:z(K7,{as:pW,size:12}),label:"Designer — Figma vocabulary"}],onChange:f})})]}),Z==="designer"?D(Q0,{children:[V0("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let t=(F.display||U7(U.display)||"").trim();return t==="flex"||t==="inline-flex"?D(Q0,{children:[v0("flex-direction",X9("flex-direction",N0),void 0,"Direction"),v0("align-items",z($g,{value:w0(),onChange:C0,ariaLabel:"auto-layout alignment"}),H9("align-items"),"Alignment"),v0("gap",q9("gap","space"),void 0,"Gap"),D("div",{className:"st-cp-modes",children:[E9("width"),E9("height")]}),D("div",{className:"st-cp-box","aria-label":"padding",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[S9(H9("padding-top")),"padding"]}),K9("padding-top","padding"),K9("padding-right","padding"),K9("padding-bottom","padding"),K9("padding-left","padding")]}),z("div",{className:"st-cp-clustermore-row",children:J9("Auto layout")}),h["Auto layout"]?v0("flex-wrap",z(a5,{checked:/^wrap/.test(F["flex-wrap"]||U7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(_0)=>s("flex-wrap",_0?"wrap":"nowrap")}),H9("flex-wrap"),"Wrap"):null]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>s("display","flex"),children:"+ Auto layout (flex)"})})()),V0("Size",["width","height","min-width","max-width","min-height","max-height"],D(Q0,{children:[v0("width",Q8("width"),void 0,"Width"),v0("height",Q8("height"),void 0,"Height"),z("div",{className:"st-cp-clustermore-row",children:J9("Size")}),h.Size?D(Q0,{children:[v0("min-width",Q8("min-width"),void 0,"Min width"),v0("max-width",Q8("max-width"),void 0,"Max width"),v0("min-height",Q8("min-height"),void 0,"Min height"),v0("max-height",Q8("max-height"),void 0,"Max height")]}):null]})),V0("Position",["position","top","right","bottom","left","z-index"],D(Q0,{children:[v0("position",r0("position",K80),void 0,"Position"),D("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[S9(H9("top")),"inset"]}),C9("top"),C9("right"),C9("bottom"),C9("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||U7(U.position)||"static"})]}),(F.position||U7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,z("div",{className:"st-cp-clustermore-row",children:J9("Position")}),h.Position?v0("z-index",Q8("z-index"),void 0,"Layer order"):null]}),!1),V0("Fill",["background-color"],v0("background-color",c9("background-color"),void 0,"Fill")),V0("Stroke",["border-width","border-style","border-color"],v0("border",d0(),H9("border-width"),"Stroke")),V0("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],v0("border-radius",l0(),H9("border-radius"),"Corner radius")),V0("Effects",["box-shadow","filter","mix-blend-mode"],D(Q0,{children:[v0("box-shadow",a7("box-shadow","shadow")||I9("box-shadow"),void 0,"Shadow"),v0("filter",y0(),H9("filter"),"Blur"),v0("mix-blend-mode",r0("mix-blend-mode",q80),void 0,"Blend")]})),V0("Opacity",["opacity"],v0("opacity",B9(),void 0,"Opacity")),V0("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],D(Q0,{children:[v0("font-family",r0("font-family",G80),void 0,"Font"),v0("color",c9("color"),void 0,"Color"),v0("font-size",q9("font-size","type"),void 0,"Size"),v0("font-weight",r0("font-weight",W80),void 0,"Weight"),v0("line-height",Q8("line-height","lh"),void 0,"Line height"),v0("text-align",X9("text-align",g9),void 0,"Align"),z("div",{className:"st-cp-clustermore-row",children:J9("Text")}),h.Text?D(Q0,{children:[v0("letter-spacing",Q8("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),v0("font-style",r0("font-style",HL0),void 0,"Style"),v0("text-transform",r0("text-transform",U80),void 0,"Case"),v0("white-space",r0("white-space",V80),void 0,"Whitespace")]}):null]})),V0("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],D("div",{className:"st-cp-box","aria-label":"margin",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[S9(H9("margin-top")),"margin"]}),K9("margin-top","margin"),K9("margin-right","margin"),K9("margin-bottom","margin"),K9("margin-left","margin")]})),(()=>{let{showMedia:t,canReplace:M0}=i8();return t?V0("Media",["object-fit","object-position","aspect-ratio"],h8(M0)):null})()]}):D(Q0,{children:[L9("Layout",(()=>{let t=(F.display||U7(U.display)||"").trim(),M0=t==="flex"||t==="inline-flex",_0=t==="grid"||t==="inline-grid";return D(Q0,{children:[v0("display",r0("display",GL0)),M0?D(Q0,{children:[v0("flex-direction",X9("flex-direction",N0)),v0("flex-wrap",z(a5,{checked:/^wrap/.test(F["flex-wrap"]||U7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(f0)=>s("flex-wrap",f0?"wrap":"nowrap")}),H9("flex-wrap"))]}):null,M0||_0?D(Q0,{children:[v0("align-items",X9("align-items",h9)),v0("justify-content",X9("justify-content",o0)),v0("gap",q9("gap","space"))]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>s("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let t=(F.display||U7(U.display)||"").trim();if(!(t==="grid"||t==="inline-grid"))return null;let _0=F["grid-template-columns"]||"",f0=F["grid-template-rows"]||"",Y9=wO(_0),m9=wO(f0),e9=Y9.length>0||!_0.trim(),y9=m9.length>0||!f0.trim();return L9("Grid",D(Q0,{children:[e9?z(F80,{label:"Columns",tracks:Y9,editable:K,onChange:(W8)=>s("grid-template-columns",EO(W8))}):D("div",{className:"st-cp-note",children:["Columns use ",z("code",{children:_0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),y9?z(F80,{label:"Rows",tracks:m9,editable:K,onChange:(W8)=>s("grid-template-rows",EO(W8))}):D("div",{className:"st-cp-note",children:["Rows use ",z("code",{children:f0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),L9("Position",D(Q0,{children:[v0("position",r0("position",K80)),D("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[S9(H9("top")),"inset"]}),C9("top"),C9("right"),C9("bottom"),C9("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||U7(U.position)||"static"})]}),(F.position||U7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,v0("z-index",Q8("z-index"))]})),(J.parentDisplay==="grid"||J.parentDisplay==="inline-grid")&&L9("Grid item",D(Q0,{children:[D("div",{className:"st-cp-note",children:["Manual cell placement — ",z("code",{children:"start / end"})," or ",z("code",{children:"start / span N"}),"."]}),v0("grid-column",I9("grid-column")),v0("grid-row",I9("grid-row"))]})),L9("Typography",D(Q0,{children:[v0("font-family",r0("font-family",G80)),v0("color",c9("color")),v0("font-size",q9("font-size","type")),v0("font-weight",r0("font-weight",W80)),v0("line-height",Q8("line-height","lh")),v0("letter-spacing",Q8("letter-spacing",null,{min:-1/0})),v0("text-align",X9("text-align",g9)),v0("font-style",D9(),H9("font-style")),v0("text-transform",r0("text-transform",U80)),v0("white-space",r0("white-space",V80))]})),L9("Spacing",z(Q0,{children:D("div",{className:"st-cp-box","aria-label":"margin and padding",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[S9(H9("margin-top")),"margin"]}),K9("margin-top","margin"),K9("margin-right","margin"),K9("margin-bottom","margin"),K9("margin-left","margin"),D("div",{className:"st-cp-boxpad",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[S9(H9("padding-top")),"padding"]}),K9("padding-top","padding"),K9("padding-right","padding"),K9("padding-bottom","padding"),K9("padding-left","padding"),D("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(F.width)||J.bounds?.w||0)," × ",Math.round(Number.parseFloat(F.height)||J.bounds?.h||0)]})]})]})})),L9("Size",D(Q0,{children:[D("div",{className:"st-cp-modes",children:[E9("width"),E9("height")]}),v0("width",Q8("width")),v0("height",Q8("height")),v0("min-width",Q8("min-width")),v0("max-width",Q8("max-width")),v0("min-height",Q8("min-height")),v0("max-height",Q8("max-height")),v0("overflow",X9("overflow",e0)),t0?D(Q0,{children:[z("div",{className:"st-cp-subhd",children:"In flex parent"}),v0("align-self",r0("align-self",ZL0)),v0("flex-grow",Q8("flex-grow",null,{unitless:!0})),v0("flex-shrink",Q8("flex-shrink",null,{unitless:!0})),v0("flex-basis",Q8("flex-basis"))]}):null]})),(()=>{let{showMedia:t,canReplace:M0}=i8();return t?L9("Media",h8(M0)):null})(),L9("Appearance",D(Q0,{children:[v0("background-color",c9("background-color")),v0("border-radius",l0(),H9("border-radius")),v0("border",d0(),H9("border-width")),v0("box-shadow",a7("box-shadow","shadow")||I9("box-shadow")),v0("filter",y0(),H9("filter")),v0("mix-blend-mode",r0("mix-blend-mode",q80)),v0("opacity",B9()),v0("rotation",h0(),H9("transform")),v0("transform",I9("transform")),v0("transform-origin",I9("transform-origin"))]})),(()=>{let t=Object.entries(C).find(([,M0])=>typeof M0==="string"&&M0.startsWith("err:"));return t?D("div",{className:"st-cp-save is-err",role:"status",children:[z(T8,{name:"x",size:12}),t[0],": ",t[1].slice(4)]}):null})(),L9("Advanced",D("div",{className:"st-cp-advbody",children:[V8.length?D(Q0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),V8.map(([t,M0])=>D("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`custom property ${t} name`}),z("input",{className:"st-cp-fin",defaultValue:M0,"aria-label":`${t} value`,onKeyDown:(_0)=>{if(_0.key==="Enter")_0.currentTarget.blur()},onBlur:(_0)=>z0(t,_0.currentTarget.value)},`cs:${t}:${M0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>Z0(t),children:z(T8,{name:"x",size:11})})]},`cs:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add CSS property"}),z(VL0,{commit:z0}),z("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),x8.length?D(Q0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),x8.map(([t,M0])=>D("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`attribute ${t} name`}),z("input",{className:"st-cp-fin",defaultValue:M0,"aria-label":`${t} value`,onKeyDown:(_0)=>{if(_0.key==="Enter")_0.currentTarget.blur()},onBlur:(_0)=>o(t,_0.currentTarget.value)},`at:${t}:${M0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>k0(t),children:z(T8,{name:"x",size:11})})]},`at:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),z(qL0,{commit:o})]}))]}),D("div",{className:"st-cp-legend",children:[D("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),D("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),D("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},J.id)}function VL0({commit:J}){let[X,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(X.trim()&&Y.trim())J(X.trim(),Y),Q(""),W("")};return D("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom property name",placeholder:"property",value:X,onChange:(Z)=>Q(Z.target.value)}),z("input",{className:"st-cp-fin","aria-label":"custom property value",placeholder:"value",value:Y,onChange:(Z)=>W(Z.target.value),onKeyDown:(Z)=>{if(Z.key==="Enter")G()},onBlur:G})]})}function qL0({commit:J}){let[X,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(X.trim()&&Y.trim())J(X.trim(),Y),Q(""),W("")};return D("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom attribute name",placeholder:"data-…",value:X,onChange:(Z)=>Q(Z.target.value)}),z("input",{className:"st-cp-fin","aria-label":"custom attribute value",placeholder:"value",value:Y,onChange:(Z)=>W(Z.target.value),onKeyDown:(Z)=>{if(Z.key==="Enter")G()},onBlur:G})]})}var BL0={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function NL0(J,X,Q,Y){if(!Array.isArray(J)||X===Q)return J;let W=JSON.parse(JSON.stringify(J)),G=null,Z=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===X)return G=K[U],K.splice(U,1),!0;if(K[U].children&&Z(K[U].children))return!0}return!1};if(Z(W),!G)return J;let H=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===Q){if(Y==="inside-start"||Y==="inside-end")if(K[U].children=K[U].children||[],Y==="inside-start")K[U].children.unshift(G);else K[U].children.push(G);else K.splice(Y==="before"?U:U+1,0,G);return!0}if(K[U].children&&H(K[U].children))return!0}return!1};return H(W)?W:J}var FL0=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function T80({node:J,depth:X,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:V,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:M,onToggleLock:A,onRename:E}){let w=`${J.id}:${J.index}`,O=J.children&&J.children.length>0,I=W.has(w),k=!!J.synthetic,R=!k&&F?F[J.id]:null,$=!k&&!!M?.has(w),[C,j]=u.useState(!1),[x,m]=u.useState(""),d=!k&&J.id===Q&&(Y==null||J.index===Y),a=G?.has(w)?G.get(w):!!J.hidden,f=!!V&&!k&&!$,h=()=>{j(!1);let r=x.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!r||r===(J.dcElement??""))return;E?.(J,r)},p=N?.key===w,v=p?{transform:`translate(${N.dx}px, ${N.dy}px)`,opacity:0.9,zIndex:20,position:"relative",pointerEvents:"none",cursor:"grabbing",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.28)"}:null;return D(Q0,{children:[D("div",{className:"st-layer st-layer--row"+(d?" is-sel":"")+(a?" is-hidden":"")+(k?" is-group":"")+(R?" is-instance":"")+($?" is-locked":""),style:{paddingLeft:6+X*14,...v},role:"treeitem","aria-selected":k?void 0:d,"aria-expanded":O?!I:void 0,"aria-grabbed":f?p:void 0,tabIndex:0,title:k?`${J.tag} · group (unstamped wrapper)`:`${J.tag} · ${J.type}${E?" · F2 to rename":""}`,"data-layer-key":w,onClick:()=>k?O&&Z(w):H(J),onMouseEnter:()=>!k&&K(J),onMouseLeave:()=>K(null),onPointerDown:f?(r)=>B(r,J,w):void 0,onKeyDown:(r)=>{if(r.key==="Enter"||r.key===" ")if(r.preventDefault(),k)O&&Z(w);else H(J);else if(r.key==="F2"&&E&&!k)r.preventDefault(),m(J.dcElement||J.label||""),j(!0)},children:[O?z("button",{type:"button",className:"st-layer-caret","aria-label":I?"Expand":"Collapse",onClick:(r)=>{r.stopPropagation(),Z(w)},children:I?"▸":"▾"}):z("span",{className:"st-layer-caret","aria-hidden":"true"}),R?z("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:R.root?"◆":"◇"}):z(T8,{name:BL0[J.type]||"box",size:12,className:"st-layer-ticon"}),C?z("input",{className:"st-layer-rename",value:x,autoFocus:!0,"aria-label":`Rename ${J.label}`,onFocus:(r)=>r.target.select(),onChange:(r)=>m(r.target.value),onClick:(r)=>r.stopPropagation(),onPointerDown:(r)=>r.stopPropagation(),onBlur:h,onKeyDown:(r)=>{if(r.stopPropagation(),r.key==="Enter")h();else if(r.key==="Escape")j(!1)}}):z("span",{className:"st-layer-label",onDoubleClick:E&&!k?(r)=>{r.stopPropagation(),m(J.dcElement||J.label||""),j(!0)}:void 0,children:J.label}),z("span",{className:"st-layer-type",children:R?R.component:J.type}),A&&!k?z("button",{type:"button",className:"st-layer-lock","aria-label":$?`Unlock ${J.label}`:`Lock ${J.label}`,"aria-pressed":$,title:$?"Unlock":"Lock",onClick:(r)=>{r.stopPropagation(),A(w)},children:z(T8,{name:$?"lock":"unlock",size:12})}):null,U&&!k?z("button",{type:"button",className:"st-layer-eye","aria-label":a?`Show ${J.label}`:`Hide ${J.label}`,"aria-pressed":a,title:a?"Show":"Hide",onClick:(r)=>{r.stopPropagation(),U(J)},children:z(T8,{name:a?"eye-off":"eye",size:13})}):null]}),O&&!I?J.children.map((r,e)=>z(T80,{node:r,depth:X+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:V,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:M,onToggleLock:A,onRename:E},`${r.id}:${r.index}`)):null]})}function LL0({el:J}){let X=J?.computed||{},Q=J?.authored||{},Y=(U)=>{let V=Q[U];if(V&&/var\(\s*--/.test(V))return V.replace(/^var\(\s*|\s*\)$/g,"");return X[U]||V||""},W=(U,V)=>{let B=X[V]||Q[V];if(!B)return null;return D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:U}),D("div",{className:"st-swatch-row",children:[z("span",{className:"st-insp-swatch",style:{background:B},"aria-hidden":"true"}),z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Y(V)})]})]},U)},G=X["border-radius"]&&X["border-radius"]!=="0px",Z=G?Q4(X["border-radius"]).n||X["border-radius"]:null,H=X["font-size"]||X["font-weight"]?[X["font-size"],X["font-weight"]].filter(Boolean).join(" / "):null;if(!(X["background-color"]||X.color||G||H))return null;return D(Q0,{children:[G?D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Radius"}),D("div",{className:"st-insp-fields",children:[D("span",{className:"st-fmini",style:{flex:"0 0 auto",maxWidth:84},children:[z("span",{className:"st-mtag",children:"r"}),z("input",{value:Z,readOnly:!0,"aria-label":"border radius"})]}),z("span",{className:"st-insp-unit",children:"px"})]})]}):null,W("Fill","background-color"),W("Text","color"),H?D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Font"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:H})})]}):null]})}function k80(J){if(J.artboardId)return J.artboardId;let X=/^\[data-dc-screen="([^"]+)"\]$/.exec(J.selector||"");return X?X[1]:null}var DL0=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],ML0=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function OL0({el:J,cfg:X,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let K=k80(J),U=(X?.designRel||X?.designRoot||".design").replace(/^\/+|\/+$/g,""),V=E80(J.file,X),B=P80(X,U,V),N=(v)=>B.map((r)=>({ds:r.name,names:r[v]||[],vals:r.vals})).filter((r)=>r.names.length),F=(v)=>N(v).flatMap((r)=>(r.names||[]).map((e)=>({name:e,value:r.vals?.[e]||""}))),M=(v)=>{let r=/^var\(\s*(--[\w-]+)\s*\)$/.exec(v||"");if(!r)return v||"";for(let e of B){let c=e.vals?.[r[1]];if(c)return c}return""},A=Number.isFinite(J.worldW)?J.worldW:Number.isFinite(J.bounds?.w)?J.bounds.w:null,E=Number.isFinite(J.worldH)?J.worldH:Number.isFinite(J.bounds?.h)?J.bounds.h:null,w=(v,r)=>{if(!K)return;let e=Number.isFinite(v)&&v>0?Math.round(v):void 0,c=Number.isFinite(r)&&r>0?Math.round(r):void 0;if(e==null&&c==null)return;Q?.(K,e,c)},O=Object.entries(bQ).find(([,v])=>v.width===A&&v.height===E)?.[0],I=Object.entries(bQ).find(([,v])=>v.width===A)?.[0],k=J.attrs?.["data-dc-fixed"]==="true",R=J.attrs?.["data-dc-bg"]??"",$=J.attrs?.["data-dc-padding"]??"",C=J.attrs?.["data-dc-layout"]??"",j=J.attrs?.["data-dc-gap"]??"",x=J.attrs?.["data-dc-kind"]||"digital",m=null;try{m=J.attrs?.["data-dc-print"]?JSON.parse(J.attrs["data-dc-print"]):null}catch{}let d=(v)=>{if(!K)return;let r=null;if(v==="print"&&!m){let e={paper:"a4"};try{let c=r2(e);if(c)r={defaults:e,widthPx:c.widthPx,heightPx:c.heightPx}}catch{}}if(G?.(K,v==="digital"?null:v,r),v==="web"&&k)Y?.(K,!1,void 0)},a=(v)=>{if(!K)return;let r={paper:"a4",...m,...v},e;try{e=r2(r)}catch{return}Q?.(K,e.widthPx,e.heightPx),Z?.(K,r)},f=(v,r)=>{if(!K)return;let e=Number.isFinite(r)?r:E,c=v&&Number.isFinite(e)?Math.round(e):void 0;Y?.(K,v,c)},h=(v)=>{let r=kb(k,v);if(r.kind==="resize")w(null,r.height);else if(r.kind==="promote-to-fixed")f(!0,r.height)},p=(v)=>{if(!K)return;W?.(K,v)};return D("section",{className:"st-cp-sec",children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Artboard"})}),D("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[z(zJ,{value:A??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(v)=>w(v,null)}),z(zJ,{value:E??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:k,onCommit:h})]}),z("div",{style:{padding:"0 12px 8px"},children:x==="print"?D("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:m?.paper??"",onChange:(v)=>a({paper:v.currentTarget.value}),children:[z("option",{value:"",disabled:!0,children:"Paper size…"}),n2.map((v)=>D("option",{value:v.id,children:[v.label," — ",v.width,"×",v.height,v.unit]},v.id))]}):x==="web"?D("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:I??"",onChange:(v)=>{let r=bQ[v.currentTarget.value];if(r)w(r.width,null)},children:[z("option",{value:"",disabled:!0,children:I?`${bQ[I].label} — ≤ ${bQ[I].width}px`:"Breakpoint…"}),Object.entries(bQ).map(([v,r])=>D("option",{value:v,children:[r.label," — ≤ ",r.width,"px breakpoint"]},v))]}):D("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:O??"",onChange:(v)=>{let r=bQ[v.currentTarget.value];if(r)w(r.width,r.height)},children:[z("option",{value:"",disabled:!0,children:O?bQ[O].label:"Preset size…"}),Object.entries(bQ).map(([v,r])=>D("option",{value:v,children:[r.label," — ",r.width,"×",r.height]},v))]})}),z("div",{style:{padding:"0 12px 8px"},children:z(uN,{value:k?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(v)=>f(v==="fixed")})}),z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Kind"})}),z("div",{style:{padding:"0 12px 8px"},children:z(cW,{value:x,ariaLabel:"artboard kind",options:ML0.map(([v,r])=>({value:v,label:r})),onChange:d})}),x!=="print"&&K&&H?z("div",{style:{padding:"0 12px 8px"},children:D("select",{className:"st-cp-nsel","aria-label":"duplicate artboard at breakpoint width",value:"",onChange:(v)=>{let r=bQ[v.currentTarget.value];if(r)H(K,r.width);v.currentTarget.value=""},children:[z("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(bQ).map(([v,r])=>D("option",{value:v,children:[r.label," — ",r.width,"px"]},v))]})}):null,x==="print"?D(Q0,{children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Print"})}),z("div",{style:{padding:"0 12px 8px"},children:z(uN,{value:m?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(v)=>a({orientation:v})})}),z("div",{style:{padding:"0 12px 8px"},children:z(zJ,{value:Number.isFinite(m?.bleedMm)?m.bleedMm:3,min:0,step:0.5,ariaLabel:"bleed, millimeters",lead:"B",steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"mm"}),onCommit:(v)=>a({bleedMm:v})})})]}):null,z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Style"})}),D("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let v=M(R),r=/var\(\s*--/.test(R),e=r?R.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):R;return z(W3,{swatch:z(zL,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:N("color"),current:R,activeDs:V,swatchBg:v,seedHex:qL(v)||"#000000",onPick:(c)=>p({background:c||null}),label:"artboard background colour"}),displayValue:e,bound:r,ariaLabel:"artboard background",onValue:(c)=>p({background:(c||"").trim()||null})})})(),z(cW,{value:C,ariaLabel:"artboard body layout",options:DL0.map(([v,r])=>({value:v,label:r})),onChange:(v)=>p({layout:v||null})}),D("div",{style:{display:"flex",gap:8},children:[z(pN,{value:/^var\(/.test($)?$:Number.parseFloat($)||0,tokens:F("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(v)=>p({padding:typeof v==="string"?v:v>0?v:null})}),z(pN,{value:/^var\(/.test(j)?j:Number.parseFloat(j)||0,tokens:F("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(v)=>p({gap:typeof v==="string"?v:v>0?v:null})})]})]})]})}var Zk=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,AL0=new RegExp(Zk.source,"gi");function _L0(J){if(!J||Array.isArray(J))return null;if(J.photoAsset)return J.photoAsset;let X=J.html||"";if((J.tag||"").toLowerCase()!=="img"){let W=[...new Set(X.match(AL0)||[])],G=[...new Set([...X.matchAll(/data-photo-asset="([^"]+)"/g)].map((Z)=>Z[1]))];if(G.length===1)return G[0];if(G.length===0&&W.length===1&&/<img/i.test(X))return W[0];return null}let Q=/data-photo-asset="([^"]+)"/.exec(X);if(Q)return Q[1];let Y=Zk.exec(`${J.attrs?.src||""} ${X}`);return Y?Y[0]:null}function wL0({testId:J,selected:X,onClose:Q,layersTree:Y,componentMap:W,lockedKeys:G,onToggleLock:Z,onDetachInstance:H,canvasFile:K,onSelectLayer:U,onHoverLayer:V,onReorderLayer:B,layersBusyRef:N,cfg:F,onOptimistic:M,onRecordEdit:A,onReplaceMedia:E,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:I,onSetArtboardKind:k,onSetArtboardPrint:R,onDuplicateArtboard:$,onUndoRedo:C,editScope:j,tab:x,onTabChange:m,width:d,resizing:a,photoSel:f,photoRev:h,onPhotoEdit:p,onPhotoRemoveBackground:v,onPhotoRecordEdit:r,onPhotoUndoRedo:e,layersOnly:c=!1,hideLayersTab:K0=!1,cpMode:s,onSetCpMode:z0}){let[o,q0]=u.useState("inspect"),Z0=c?"layers":x??o,k0=(l0)=>{q0(l0),m?.(l0)},[a0,s0]=u.useState(()=>new Set),[t0,E9]=u.useState(()=>new Map);u.useEffect(()=>{let l0=Array.isArray(X)?X[0]:X,d0=l0?.id;if(!d0||!Y?.nodes)return;let h0=l0.index,y0=null,B9=[];if(function D9(N0,o0){for(let h9 of N0||[]){let g9=`${h9.id}:${h9.index}`;if(!h9.synthetic&&h9.id===d0&&(h0==null||h9.index===h0))return y0=g9,B9.push(...o0),!0;if(h9.children&&h9.children.length&&D9(h9.children,[...o0,g9]))return!0}return!1}(Y.nodes,[]),!y0)return;if(B9.length)s0((D9)=>{let N0=!1,o0=new Set(D9);for(let h9 of B9)if(o0.delete(h9))N0=!0;return N0?o0:D9});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${y0}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[X,Y]);let a9=(l0)=>{let d0=`${l0.id}:${l0.index}`;return t0.has(d0)?t0.get(d0):!!l0.hidden},[F9,T9]=u.useState(null),[I0,w0]=u.useState(""),C0=(l0,d0)=>{if(!K||!l0?.id)return;fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:K,id:l0.id,attr:"data-dc-element",value:d0})}).then((h0)=>h0.json().catch(()=>({}))).then((h0)=>{if(!h0.ok)return;A?.({op:"attr",canvas:K,id:l0.id,key:"data-dc-element",before:l0.dcElement??null,after:d0})}).catch(()=>{})},W9=B?(l0,d0,h0)=>{if(N?.current)return;if(l0?.synthetic||d0?.synthetic)return;let y0=h0==="before"?`before ${d0.label}`:h0==="after"?`after ${d0.label}`:`into ${d0.label}`;w0(`Moved ${l0.label} ${y0}`),B(l0.id,d0.id,h0,{idIndex:l0.index,refIndex:d0.index})}:void 0,H9=()=>{let l0=[];return function d0(h0,y0,B9){(h0||[]).forEach((D9,N0)=>{if(l0.push({node:D9,depth:y0,parentNode:B9,siblings:h0,pos:N0}),D9.children&&D9.children.length&&!a0.has(`${D9.id}:${D9.index}`))d0(D9.children,y0+1,D9)})}(Y?.nodes,0,null),l0},x9=(l0)=>{if(l0.key!=="ArrowUp"&&l0.key!=="ArrowDown")return;if(!L9)return;let d0=H9(),h0=d0.findIndex((N0)=>N0.node.id===L9.id&&N0.node.index===L9.index);if(h0<0)return;let y0=l0.key==="ArrowDown"?1:-1,B9=d0[h0];if(!l0.altKey){let N0=d0[h0+y0];if(N0)l0.preventDefault(),U?.(N0.node);return}if(!W9||!Array.isArray(B9.siblings))return;l0.preventDefault();let D9=(N0)=>N0&&N0.children&&N0.children.length&&!a0.has(`${N0.id}:${N0.index}`);if(!l0.shiftKey){if(y0<0&&B9.pos>0)W9(B9.node,B9.siblings[B9.pos-1],"before");else if(y0>0&&B9.pos<B9.siblings.length-1)W9(B9.node,B9.siblings[B9.pos+1],"after");return}if(y0>0){let N0=B9.siblings[B9.pos+1];if(N0)W9(B9.node,N0,D9(N0)?"inside-start":"after");else if(B9.parentNode)W9(B9.node,B9.parentNode,"after")}else{let N0=B9.siblings[B9.pos-1];if(N0)W9(B9.node,N0,D9(N0)?"inside-end":"before");else if(B9.parentNode)W9(B9.node,B9.parentNode,"before")}},S9=u.useRef(null),O8=u.useRef(null),v0=(l0,d0,h0)=>{if(!W9||l0.button!==0||l0.metaKey||l0.ctrlKey||l0.shiftKey||l0.altKey)return;if(N?.current)return;let{clientX:y0,clientY:B9}=l0,D9=new Set([h0]);(function c9(O0){(O0.children||[]).forEach((K9)=>{D9.add(`${K9.id}:${K9.index}`),c9(K9)})})(d0);let N0=14,o0=6,h9=[];(function c9(O0,K9){(O0||[]).forEach((C9)=>{let V8=`${C9.id}:${C9.index}`;if(h9.push({node:C9,key:V8,id:C9.id,depth:K9,tag:C9.tag}),C9.children&&C9.children.length&&!a0.has(V8))c9(C9.children,K9+1)})})(Y?.nodes,0);let g9=new Map(h9.map((c9)=>[c9.key,c9])),e0=!1,a7=(c9)=>{if(!e0){if(Math.hypot(c9.clientX-y0,c9.clientY-B9)<4)return;e0=!0}let O0=c9.clientX-y0,K9=c9.clientY-B9,C9=null,V8=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((i8)=>({rect:i8.getBoundingClientRect(),it:g9.get(i8.getAttribute("data-layer-key"))})).filter((i8)=>i8.it&&i8.it.key!==h0);if(V8.length){let i8=V8[0].rect.left,h8=V8[0].rect.right,t=V8.length;for(let e8=0;e8<V8.length;e8++)if(c9.clientY<V8[e8].rect.top+V8[e8].rect.height/2){t=e8;break}let M0=V8[t-1]?.it||null,_0=V8[t]?.it||null,f0=Math.round((c9.clientX-i8-o0)/N0),Y9=M0?M0.depth+(FL0.has(M0.tag)?0:1):0,m9=_0?_0.depth:0,e9=Math.max(m9,Math.min(f0,Y9)),y9=null,W8="before",k8=0;if(!M0){if(_0)y9=_0,W8="before",k8=_0.depth}else if(e9>M0.depth)y9=M0,W8="inside-start",k8=M0.depth+1;else if(e9===M0.depth)y9=M0,W8="after",k8=M0.depth;else{for(let e8=t-1;e8>=0;e8--)if(V8[e8].it.depth===e9){y9=V8[e8].it;break}if(!y9)y9=M0;W8="after",k8=e9}if(y9&&y9.key!==h0&&!D9.has(y9.key)){let e8=M0?V8[t-1].rect.bottom:V8[0].rect.top,J7=i8+o0+k8*N0;C9={refId:y9.id,position:W8,node:y9.node,y:e8,left:J7,w:Math.max(24,h8-J7)}}}let x8={key:h0,node:d0,dx:O0,dy:K9,target:C9};S9.current=x8,T9(x8)},F8=()=>{window.removeEventListener("pointermove",a7),window.removeEventListener("pointerup",I9),window.removeEventListener("keydown",Q8,!0)},v7=()=>{let c9=(O0)=>{O0.preventDefault(),O0.stopImmediatePropagation(),document.removeEventListener("click",c9,!0)};document.addEventListener("click",c9,!0),setTimeout(()=>document.removeEventListener("click",c9,!0),300)},I9=()=>{F8();let c9=S9.current;if(S9.current=null,T9(null),e0&&c9?.target)v7(),W9(c9.node,c9.target.node,c9.target.position)},Q8=(c9)=>{if(c9.key!=="Escape")return;if(c9.preventDefault(),c9.stopImmediatePropagation(),F8(),S9.current=null,T9(null),e0)v7()};window.addEventListener("pointermove",a7),window.addEventListener("pointerup",I9),window.addEventListener("keydown",Q8,!0)},$9=(l0)=>s0((d0)=>{let h0=new Set(d0);if(h0.has(l0))h0.delete(l0);else h0.add(l0);return h0}),w8=(l0)=>{let d0=`${l0.id}:${l0.index}`,h0=a9(l0),y0=!h0;if(E9((B9)=>new Map(B9).set(d0,y0)),M?.({id:l0.id,artboardId:Y?.artboardId??null,index:l0.index,prop:"display",value:y0?"none":null}),!K||!l0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(y0?{canvas:K,id:l0.id,property:"display",value:"none"}:{canvas:K,id:l0.id,property:"display",reset:!0})}).catch(()=>{}),A?.({op:"css",canvas:K,id:l0.id,key:"display",before:h0?"none":null,after:y0?"none":null})},L9=Array.isArray(X)?X[0]:X,V0=f?{asset:f.asset,kind:"annotation-image"}:(()=>{let l0=_L0(L9);return l0?{asset:l0,kind:"artboard-img"}:null})(),J9=V0?.kind==="annotation-image",r0=(l0)=>{if(!(l0.metaKey||l0.ctrlKey)||l0.altKey)return;let d0=l0.key.toLowerCase();if(d0==="z")l0.preventDefault(),e?.(l0.shiftKey?"redo":"undo");else if(d0==="y")l0.preventDefault(),e?.("redo")},b0=J9?"photo":Z0==="photo"&&!V0?"css":Z0,X9=(l0,d0,h0)=>D("button",{type:"button",className:"st-rp-tab"+(b0===l0?" is-active":""),onClick:()=>k0(l0),children:[z(T8,{name:h0,size:14}),d0]}),q9=L9?.bounds||null;return D("aside",{className:"st-rpanel"+(a?" is-resizing":""),style:d?{width:d,flexBasis:d}:void 0,"aria-label":"Inspector","data-tour":"inspector","data-testid":J,children:[D("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:c?{display:"none"}:void 0,children:[J9?X9("photo","Photo","image"):D(Q0,{children:[X9("inspect","Inspect","sliders"),!K0&&X9("layers","Layers","layers"),X9("css","CSS","code"),V0?X9("photo","Photo","image"):null]}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:Q,children:z(T8,{name:"x",size:14})})]}),L9?.id&&!(Array.isArray(X)&&X.length>1)&&j?D("div",{className:`st-scope st-scope--${j.scope}`,title:j.scope==="shared"?`Editing this element's style changes ${j.affects} place${j.affects===1?"":"s"}${j.componentName?` (component ${j.componentName})`:""}. Move/resize a whole instance to keep it local.`:"This edit affects only this element.",children:[z("span",{className:"st-scope-dot","aria-hidden":"true"}),j.scope==="shared"?`Shared${j.componentName?` · ${j.componentName}`:""} · edits ${j.affects} place${j.affects===1?"":"s"}`:"Local · this element only",j.scope==="shared"&&H?z("button",{type:"button",className:"st-scope-detach",title:"Clone this component for this instance only — edits stop affecting the other places",onClick:()=>H(L9.id,L9.index),children:"Detach"}):null]}):null,z("div",{className:"st-rp-body",children:b0==="photo"&&V0?z("div",{onKeyDown:r0,children:z(Ym,{asset:V0.asset,ColorPicker:I80,StIcon:T8,onEdit:(l0)=>p?.(V0.asset,l0),onRemoveBackground:v,onRecordEdit:(l0,d0)=>r?.(V0.asset,l0,d0)},`${V0.asset}:${h??0}`)}):!L9&&!(b0==="layers"&&Y?.nodes?.length)?z("div",{className:"st-rp-empty",children:D("p",{children:["Press ",z(CJ,{children:"V"}),", then click an element to select it — or ",z(CJ,{children:"⌘"}),"-click straight from Browse."]})}):L9&&b0==="inspect"?D(Q0,{children:[z("div",{className:"st-rp-hd",children:L9.selector||L9.tag||"element"}),D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Pos"}),D("div",{className:"st-insp-fields",children:[D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"X"}),z("input",{value:q9?Math.round(q9.x):"—",readOnly:!0,"aria-label":"x position"})]}),D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"Y"}),z("input",{value:q9?Math.round(q9.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Size"}),D("div",{className:"st-insp-fields",children:[D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"W"}),z("input",{value:q9?Math.round(q9.w):"—",readOnly:!0,"aria-label":"width"})]}),D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"H"}),z("input",{value:q9?Math.round(q9.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Tag"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:L9.tag||"—"})})]}),L9.classes?D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Class"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:L9.classes})})]}):null,z(LL0,{el:L9})]}):b0==="layers"?D(Q0,{children:[D("div",{className:"st-rp-hd",children:["Layers",Y?.nodes?.length?"":" · ancestry"]}),Y?.nodes?.length?D(Q0,{children:[W9?z("div",{className:"st-rp-hint","aria-hidden":"true",children:"Drag or ↑/↓ select · Alt+↑/↓ move · Alt+Shift+↑/↓ move across"}):null,z("div",{role:"tree","aria-label":"Artboard layers",tabIndex:0,ref:O8,onKeyDown:x9,children:Y.nodes.map((l0,d0)=>z(T80,{node:l0,depth:0,selectedId:L9?.id,selectedIndex:L9?.index,collapsed:a0,hiddenOverride:t0,onToggle:$9,onSelect:(h0)=>{U?.(h0),O8.current?.focus()},onHover:(h0)=>V?.(h0),onToggleVisibility:w8,onReorder:W9,onRowPointerDown:v0,dragState:F9,componentMap:W,lockedKeys:G,onToggleLock:Z,onRename:C0},`${l0.id}:${l0.index}`))}),F9?.target?z("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:F9.target.left,top:F9.target.y-1,width:F9.target.w}}):null,z("div",{className:"sr-only",role:"status","aria-live":"polite",children:I0})]}):L9&&Array.isArray(L9.dom_path)&&L9.dom_path.length?L9.dom_path.map((l0,d0)=>D("div",{className:"st-layer"+(d0===L9.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+d0*12},children:[z(T8,{name:"square",size:13}),l0]},d0)):z("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!L9.id&&k80(L9)?z(OL0,{el:L9,cfg:F,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:I,onSetArtboardKind:k,onSetArtboardPrint:R,onDuplicateArtboard:$}):z(UL0,{el:L9,cfg:F,onOptimistic:M,onRecordEdit:A,onReplaceMedia:E,onUndoRedo:C,mode:s,onSetMode:z0})})]})}function EL0(){let[J,X]=u.useState([]),[Q,Y]=u.useState(!1),W=u.useRef("push"),G=u.useRef(null),[Z,H]=u.useState("Design"),[K,U]=u.useState([]),[V,B]=u.useState(null),[N,F]=u.useState(null),M=u.useCallback((b)=>{W.current="push",F(b)},[]),[A,E]=u.useState(null),w=u.useRef(null);u.useEffect(()=>{w.current=A},[A]);let[O,I]=u.useState(null);u.useEffect(()=>{let b=Array.isArray(A)?A.length===1?A[0]:null:A,S=b&&typeof b.id==="string"?b.id:null;if(!S||!V){I(null);return}let i=new AbortController,X0=new URLSearchParams({canvas:V,id:S});return fetch(`/_api/edit-scope?${X0}`,{signal:i.signal}).then((H0)=>H0.ok?H0.json():null).then((H0)=>{if(H0?.ok)I(H0)}).catch(()=>{}),()=>i.abort()},[A,V]);let k=u.useRef(0),R=u.useRef([]),$=u.useCallback((b)=>{if(!b?.id||!b.file)return;for(let S of R.current)clearTimeout(S);R.current=[50,450,1200,2500,5000].map((S)=>setTimeout(()=>{let i=w.current,X0=Array.isArray(i)?i[0]:i;if(!X0||X0.id!==b.id||X0.file!==b.file)return;let H0=i9.current.get(b.file);if(!H0?.contentWindow)return;try{H0.contentWindow.postMessage({dgn:"select-by-id",id:b.id,artboardId:b.artboardId??null,index:b.index??0},"*")}catch{}},S))},[]),C=u.useRef([]),j=u.useCallback((b,S)=>{if(!b||!S)return;for(let i of C.current)clearTimeout(i);C.current=[50,450,1200,2500,5000].map((i)=>setTimeout(()=>{let X0=w.current,H0=Array.isArray(X0)?X0[0]:X0;if(!H0||H0.artboardId!==b||H0.file!==S)return;let F0=i9.current.get(S);if(!F0?.contentWindow)return;try{F0.contentWindow.postMessage({dgn:"select-by-id",artboardId:b},"*")}catch{}},i))},[]),x=u.useRef(null),m=u.useRef(null),d=u.useRef(null);d.current=(b,S,i)=>{let X0=x.current;if(!X0||!X0.movedId)return;if(X0.staleSig!=null&&S===X0.staleSig)return;if(!function A0(l){return(l||[]).some((D0)=>D0.id===X0.movedId||A0(D0.children))}(b))return;x.current=null;let F0=V?i9.current.get(V)?.contentWindow:null;if(F0)try{F0.postMessage({dgn:"select-by-id",id:X0.movedId,artboardId:i,index:0},"*")}catch{}};let a=u.useRef(null),f=u.useRef(null),h=u.useRef(null),p=u.useRef(!1),v=u.useRef(null),[r,e]=u.useState(null),[c,K0]=u.useState(null),s=u.useRef({canvas:null,at:0});u.useEffect(()=>{if(!V||!r)return;let b=Date.now(),S=s.current;if(S.canvas===V&&b-S.at<1500)return;s.current={canvas:V,at:b},fetch(`/_api/component-map?canvas=${encodeURIComponent(V)}`).then((i)=>i.json()).then((i)=>{if(i?.ok&&i.map&&typeof i.map==="object")K0(i.map);else K0(null)}).catch(()=>K0(null))},[V,r]);let[z0,o]=u.useState(!1),[q0,Z0]=u.useState(null),[k0,a0]=u.useState(null),s0=u.useRef(null);u.useEffect(()=>{let b=k0?.files?.progress;if(!b)return;let S=s0.current;if(s0.current=b.phase,S===null||S===b.phase)return;if(b.phase==="converged"&&(S==="seeding"||S==="paused"))YL("Project synced",`${b.delivered} files are up to date.`);else if(b.phase==="blocked"){let i=(b.blocked??[]).reduce((X0,H0)=>X0+H0.count,0);YL("Sync needs a decision",`${i} file${i===1?"":"s"} could not be sent. Open the Sync panel for the reason.`)}},[k0?.files?.progress]),u.useEffect(()=>{if(typeof document>"u")return;let b=k0?.files?.progress,S=document.title.replace(/\s+—\s+syncing\s+\d+\/\d+$/,"");if(b&&(b.phase==="seeding"||b.phase==="paused")&&b.tracked>0)document.title=`${S} — syncing ${b.delivered}/${b.tracked}`;else document.title=S;return},[k0?.files?.progress]);let[t0,E9]=u.useState(null),[a9,F9]=u.useState(null),[T9,I0]=u.useState(null),[w0,C0]=u.useState(null),[W9,H9]=u.useState(!1),[x9,S9]=u.useState(!1),[O8,v0]=u.useState(null),[$9,w8]=u.useState(""),[L9,V0]=u.useState(null),[J9,r0]=u.useState(null),b0=u.useRef(null),[X9,q9]=u.useState(null),[l0,d0]=u.useState(0),[h0,y0]=u.useState(null),B9=s90("maude-sb-w",{min:200,max:420,def:252}),D9=s90("maude-rp-w",{min:260,max:480,def:304}),[N0,o0]=u.useState(null),h9=u.useRef(null);u.useEffect(()=>{if(!N0)return;let b=(i)=>{let X0=h9.current?.getBoundingClientRect();if(!X0)return;if(N0==="sb")B9.setW(i.clientX-X0.left);else D9.setW(X0.right-i.clientX)},S=()=>o0(null);return window.addEventListener("pointermove",b),window.addEventListener("pointerup",S),()=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",S)}},[N0,B9.setW,D9.setW]);let g9=u.useCallback((b)=>{clearTimeout(b0.current),b0.current=setTimeout(()=>{r0((S)=>S===b?null:S)},2500)},[]),[e0,a7]=u.useState({designRel:".design",cloud:void 0});u.useEffect(()=>{if(!J9)return;let b=J9,S=setTimeout(async()=>{let i="compile";try{if(!(await fetch(`${e0?.canvasOrigin||""}/_health`,{cache:"no-store"})).ok)i="server"}catch{i="server"}q9({path:b,kind:i}),r0((X0)=>X0===b?null:X0)},15000);return()=>clearTimeout(S)},[J9,e0?.canvasOrigin]);let F8=!!e0.cloud,v7=!e0.cloud&&!!t0?.credentialed,I9=F8||v7,Q8=I9?0:T9?.files?.length||0,c9=u.useRef(I9);c9.current=I9;let O0=!!e0.readOnly,K9=u.useCallback(()=>{fetch("/_config").then((b)=>b.json()).then((b)=>{let S=(b.designRoot||".design").replace(/^\/+|\/+$/g,"");a7((i)=>({...i,designRel:S,tokensCssRel:b.tokensCssRel,designSystems:b.designSystems,canvasOrigin:b.canvasOrigin,readOnly:!!b.readOnly,canvasToken:b.canvasToken,version:b.version,cloud:b.cloud??null,exportLane:b.exportLane}))}).catch(()=>{})},[]);u.useEffect(()=>{K9()},[K9]),u.useEffect(()=>{let b=!1;return fetch("/_sync-status").then((S)=>S.json()).then((S)=>{if(b||!S||S.linked===!1)return;a0(S)}).catch(()=>{}),()=>{b=!0}},[]),u.useEffect(()=>{if(I9){I0(null);return}let b=!1;return fetch("/_api/git/status").then((S)=>S.json()).then((S)=>{if(!b&&S)I0(S)}).catch(()=>{}),()=>{b=!0}},[I9]);let[C9,V8]=u.useState({}),[x8,i8]=u.useState(null),[h8,t]=u.useState(!1),[M0,_0]=u.useState("open"),[f0,Y9]=u.useState(UF0),[m9,e9]=u.useState(()=>{return Jk(u90,"advanced")==="designer"?"designer":"advanced"});u.useEffect(()=>{try{localStorage.setItem(u90,JSON.stringify(m9))}catch{}},[m9]);let[y9,W8]=u.useState(null),[k8,e8]=u.useState(()=>IH(p90,!0)),[J7,D5]=u.useState(()=>IH(g90,!1)),[rX,BJ]=u.useState(()=>Jk(m90,{})),[iJ,oJ]=u.useState(!1),[e7,W4]=u.useState(!1);u.useEffect(()=>{if(!G8())return;let b=Xh(()=>W4(!0));return()=>{b.then((S)=>S()).catch(()=>{})}},[]);let[R7,FX]=u.useState(!1),[j8,qY]=u.useState(!1),[p7,jQ]=u.useState(!1),[HG,f7]=u.useState(!1),[BY,LX]=u.useState(!1),{report:V7}=bw(G8()),[nJ,l8]=u.useState(!1),[q7,z6]=u.useState(!1),[$J,vQ]=u.useState(null),[M5,P6]=u.useState(null),[G4,O5]=u.useState(!1),[zG,SJ]=u.useState(!1),[bJ,rJ]=u.useState(!1),[fQ,Z4]=u.useState(!1),[NJ,H4]=u.useState(()=>Jk(i90,sK)),[n,W0]=u.useState(()=>{try{let b=localStorage.getItem(o90);if(b==="separate"||b==="in-inspector")return b}catch{}return"separate"}),[L0,j0]=u.useState(!1),[E0,z9]=u.useState([]),[O9,Z8]=u.useState(0),[L8,I6]=u.useState(!1),[A5,s6]=u.useState(!1),[FJ,xQ]=u.useState(!1),[TH,KG]=u.useState(1),[yJ,C7]=u.useState(216),[R8,DX]=u.useState(null),[K6,t9]=u.useState([]),[J6,x6]=u.useState([]),[MX,_5]=u.useState([]),[aX,kH]=u.useState(0),OX=u.useRef(0);u.useEffect(()=>{OX.current=O9},[O9]);let[X6,RH]=u.useState(null),AX=u.useRef(null);u.useEffect(()=>{AX.current=X6},[X6]);let T6=u.useMemo(()=>gw(E0,{artboardId:[X6,R8],total:aX}),[E0,X6,R8,aX]),sX=u.useRef(null);u.useEffect(()=>{sX.current=T6},[T6]);let NY=u.useMemo(()=>TK(E0,T6)?.fps||30,[E0,T6]),[CH,FY]=u.useState(null),[LY,X1]=u.useState(0),LJ=u.useCallback((b,S)=>{if(/concurrent edit|changed since it was read/i.test(S||""))f9("Timeline changed — reloaded, try again."),X1((i)=>i+1);else f9(`${b}: ${S||"failed"}`)},[]),[_X,UG]=u.useState(!1),[Q1,$H]=u.useState(!1),[Y1,VG]=u.useState(!1),qG=u.useRef(_X);u.useEffect(()=>{if(qG.current=_X,_X){VG(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[_X]);let SH=u.useCallback(()=>{if(!qG.current||document.hidden)VG(!0),YL("Claude finished","Your assistant turn is ready in Maude.")},[]),bH=u.useRef(0),DY=u.useCallback(()=>{if(!qG.current||document.hidden){VG(!0);let b=Date.now();if(b-bH.current<ZF0)return;bH.current=b,YL("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[hQ,tX]=u.useState("inspect"),[BG,MY]=u.useState(null),w5=u.useRef({undo:[],redo:[]}),[NG,FG]=u.useState(0),[U6,LG]=u.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),OY=u.useRef(U6);u.useEffect(()=>{OY.current=U6;try{localStorage.setItem("maude-auto-open-inspector",U6?"1":"0")}catch{}},[U6]);let yH=u.useRef(!1);u.useEffect(()=>{yH.current=bJ||h8||W9||x9||_X},[bJ,h8,W9,x9,_X]);let DG=u.useRef({open:{},side:sK});DG.current={open:{tree:k8,layers:fQ,inspector:bJ,comments:h8,changes:W9,sync:x9,assistant:_X},side:NJ};let z4=u.useCallback((b,S)=>{if(b==="tree")e8(S);else if(b==="layers")Z4(S);else if(b==="inspector")rJ(S);else if(b==="comments")t(S);else if(b==="changes")H9(S);else if(b==="sync")S9(S);else if(b==="assistant")UG(S)},[]),MG=u.useCallback((b)=>DG.current.side?.[b]||sK[b],[]),k6=u.useCallback((b)=>{let S=MG(b);z4(b,!0);for(let i of Wk)if(i.id!==b&&MG(i.id)===S)z4(i.id,!1)},[z4,MG]),wX=u.useCallback((b)=>{if(DG.current.open?.[b])z4(b,!1);else k6(b)},[k6,z4]),eX=k6,h6=wX,OG=u.useCallback((b)=>{if(!OY.current)return;if(O0)return;if(!b||!b.id)return;if(yH.current)return;eX("inspector"),tX("css")},[eX,O0]),AY=u.useCallback(()=>j0((b)=>!b),[]),E5=Pm(Gk),K4=zm({enabled:e0.cloud===null||e0.exportLane==="remote"}),[jH,W1]=u.useState(!1),[vH,JQ]=u.useState(!1);u.useEffect(()=>{if(!G8())return;let b=!0;return Gh().then((S)=>{if(!b)return;if(W1(!!S),!S&&!IH(h90,!1))JQ(!0)}).catch(()=>{}),()=>{b=!1}},[]);let DJ=u.useCallback(()=>{JQ(!1);try{localStorage.setItem(h90,"1")}catch{}},[]),[AG,fH]=u.useState(null);u.useEffect(()=>{if(!G8())return;let b;return Uh((S)=>fH(S&&typeof S==="object"?S:{})).then((S)=>{b=S}).catch(()=>{}),()=>{try{b?.()}catch{}}},[]);let[U4,P5]=u.useState(null),[I5,_G]=u.useState(()=>!IH(x90,!1)),EX=u.useCallback((b)=>{P5(Array.isArray(b)&&b.length?b:null)},[]),wG={setup:(b)=>{if(!b)return;if((b.canvas||b.requireSelection)&&K.length===0)k6("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [role="treeitem"]')?.click()}catch{}},80);if(b.inspector||b.tab||b.requireSelection)eX("inspector");if(b.tab)tX(b.tab);if(b.changes)eX("changes")}},V4=u.useCallback(()=>{_G(!1);try{localStorage.setItem(x90,"1")}catch{}},[]),[XQ,_Y]=u.useState(()=>IH(c90,!0)),[xH,EG]=u.useState(!1),[QQ,wY]=u.useState(()=>IH(l90,!1)),[g6,U0]=u.useState(()=>IH(d90,!1)),[jJ,q4]=u.useState(!1),[PG,aJ]=u.useState(!1),[l7,sJ]=u.useState(0),[gQ,IG]=u.useState(null),[TG,EY]=u.useState(!1),mQ=u.useRef(null),T5=u.useRef(null),i9=u.useRef(new Map);u.useEffect(()=>{if(!e0?.canvasToken)return;let b=!1,S=null,i=0,X0=(A0)=>{clearTimeout(S);let l=jb(A0);i=Date.now()+l,S=setTimeout(H0,l)};async function H0(){let A0=null;try{let D0=await fetch("/_config",{cache:"no-store",credentials:"same-origin"});if(D0.ok)A0=(await D0.json())?.canvasToken}catch{}if(b)return;if(typeof A0!=="string"||!A0){clearTimeout(S),i=Date.now()+30000,S=setTimeout(H0,30000);return}yb(A0);let l=null;try{l=new URL(e0.canvasOrigin,location.href).origin}catch{}if(l)for(let D0 of i9.current.values())try{D0.contentWindow?.postMessage({dgn:"canvas-cap",t:A0},l)}catch{}X0(A0)}X0(e0.canvasToken);let F0=()=>{if(document.visibilityState==="visible"&&Date.now()>=i)H0()};return document.addEventListener("visibilitychange",F0),()=>{b=!0,clearTimeout(S),document.removeEventListener("visibilitychange",F0)}},[e0?.canvasToken,e0?.canvasOrigin]);let T0=u.useCallback((b)=>{let S=V?i9.current.get(V):null;if(!S||!S.contentWindow)return;try{S.contentWindow.postMessage(b,"*")}catch{}},[V]),tJ=u.useRef(0),k5=u.useCallback(({format:b,artboardIds:S=null,scale:i=1,onProgress:X0,timeoutMs:H0=120000})=>new Promise((F0,A0)=>{let l=V?i9.current.get(V):null;if(!l||!l.contentWindow){A0(Error("no active canvas to capture"));return}let D0=l.contentWindow;tJ.current+=1;let P0=`cap-${Date.now().toString(36)}-${tJ.current}`,i0=!1,_9=(w7,d8)=>{if(i0)return;i0=!0,window.removeEventListener("message",A9),clearTimeout(q6),w7(d8)},A9=(w7)=>{if(w7.source!==D0)return;let d8=w7.data;if(!d8||d8.id!==P0)return;if(d8.dgn==="export-capture-progress")X0?.(d8.current,d8.total);else if(d8.dgn==="export-capture-done")_9(F0,Array.isArray(d8.items)?d8.items:[]);else if(d8.dgn==="export-capture-error")_9(A0,Error(d8.message||"capture failed"))},q6=setTimeout(()=>_9(A0,Error("capture timed out — the canvas did not answer")),H0);window.addEventListener("message",A9);try{D0.postMessage({dgn:"export-capture",id:P0,format:b,artboardIds:S,scale:i},"*")}catch(w7){_9(A0,w7)}}),[V]),Q9=u.useCallback((b,S)=>T0({dgn:"photo-preview",asset:b,edit:S}),[T0]),B4=u.useCallback((b,S,i)=>{w5.current.undo.push({asset:b,before:S,after:i}),w5.current.redo.length=0},[]),G9=u.useCallback((b)=>{let S=b?w5.current.redo:w5.current.undo;if(!S.length)return!1;let i=S.pop();(b?w5.current.undo:w5.current.redo).push(i);let X0=(b?i.after:i.before)||{};return Q9(i.asset,X0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(i.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(X0)}).catch(()=>{}),FG((H0)=>H0+1),!0},[Q9]),kG=u.useCallback(async(b)=>{T0({dgn:"photo-busy",asset:b,busy:!0});try{let S=await fetch(`/${b.replace(/^\/+/,"")}`);if(!S.ok)return null;let i=await S.blob(),{removeBackground:X0}=await Promise.resolve().then(() => (f90(),v90)),H0=await X0(i),F0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":H0.type||"image/png"},body:H0}),A0=await F0.json().catch(()=>({}));if(F0.ok&&A0.path)return{maskAsset:A0.path};return null}catch(S){return console.error("[photo] background removal failed",S),null}finally{T0({dgn:"photo-busy",asset:b,busy:!1})}},[T0]);u.useEffect(()=>{let b=(X0)=>Array.from(X0.dataTransfer?.types??[]).includes("Files"),S=(X0)=>{if(b(X0))X0.preventDefault()},i=(X0)=>{if(b(X0))X0.preventDefault()};return document.addEventListener("dragover",S),document.addEventListener("drop",i),()=>{document.removeEventListener("dragover",S),document.removeEventListener("drop",i)}},[]);let Q6=u.useRef({});Q6.current={open:L0,comps:E0,frame:O9,total:aX,playing:L8,compId:T6,muted:FJ,loop:A5,sequences:K6,post:T0,canvas:V};let uQ=u.useRef({undo:[],redo:[]}),Y6=u.useCallback((b,S,i)=>{if(typeof S!=="number")return;if(uQ.current.undo.push({canvas:b,seq:S,label:i}),uQ.current.redo=[],uQ.current.undo.length>50)uQ.current.undo.shift()},[]),RG=u.useCallback((b)=>{let S=uQ.current,i=b==="undo"?S.undo:S.redo,X0=b==="undo"?S.redo:S.undo,H0=Q6.current.canvas,F0=-1;for(let l=i.length-1;l>=0;l--)if(i[l].canvas===H0){F0=l;break}if(F0<0){f9(b==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let A0=i[F0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:A0.canvas,seq:A0.seq,dir:b})}).then((l)=>l.json().catch(()=>({}))).then((l)=>{if(i.splice(F0,1),l?.ok)X0.push(A0),f9(`${b==="undo"?"Undid":"Redid"}: ${A0.label}`,!0);else f9(`${b==="undo"?"Undo":"Redo"} skipped: ${l?.error||"failed"}`)}).catch(()=>f9(`${b==="undo"?"Undo":"Redo"} failed: network error`))},[]),R6=u.useCallback((b,S)=>{let i=b?.ok&&Array.isArray(b.clips)?b.clips.filter((X0)=>X0.kind==="sequence"):[];if(S==null)return null;if(typeof S==="object")return(S.stableId?i.find((X0)=>X0.stableId===S.stableId):null)||(Number.isInteger(S.index)?i[S.index]:null)||null;if(typeof S==="string")return i.find((X0)=>X0.stableId===S)||null;return i[S]||null},[]),R5=u.useCallback((b)=>{let S=Q6.current.canvas;if(!S||S===r9)return;let i=AX.current||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(S)}${i?`&artboardId=${encodeURIComponent(i)}`:""}`;fetch(X0).then((H0)=>H0.json().catch(()=>({}))).then((H0)=>{let F0=R6(H0,b);if(!F0?.stableId)return null;return fetch("/_api/remove-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:S,artboardId:i,stableId:F0.stableId,contentHash:F0.contentHash})})}).then((H0)=>H0?H0.json():null).then((H0)=>{if(H0&&!H0.ok)console.warn("[remove-clip]",H0.error||"failed"),LJ("Remove refused",H0.error);else if(H0?.ok){if(f9("Clip removed.",!0),H0.seq!=null)Y6(S,H0.seq,"remove clip");FY(null)}}).catch(()=>f9("Remove failed: network error"))},[R6,Y6]),C5=u.useCallback((b,S,i)=>{let X0=Q6.current.canvas;if(!X0||X0===r9)return;let H0=AX.current||void 0,F0=`/_api/comp-clips?canvas=${encodeURIComponent(X0)}${H0?`&artboardId=${encodeURIComponent(H0)}`:""}`;fetch(F0).then((A0)=>A0.json().catch(()=>({}))).then((A0)=>{let l=A0?.ok&&Array.isArray(A0.clips)?A0.clips:[],D0=b?.transition?l.find((P0)=>P0.kind==="transition"&&P0.stableId===b.stableId)||null:R6(A0,b);if(!D0?.stableId)return null;return fetch("/_api/clip-edit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:X0,artboardId:H0,stableId:D0.stableId,contentHash:D0.contentHash,verb:S,...i})})}).then((A0)=>A0?A0.json():null).then((A0)=>{if(A0&&!A0.ok)console.warn("[clip-edit]",S,A0.error||"failed"),LJ(`${S} refused`,A0.error);else if(A0?.ok){let l={speed:"set speed","trim-in":"trim in-point",audio:"clip audio","detach-audio":"detach audio",framing:"crop clip",grade:"grade clip",transition:"edit transition",split:"split clip","insert-transition":"add transition","remove-transition":"remove transition","set-text":"edit text","to-overlay":"move to overlay layer","to-storyline":"move to storyline","layer-order":"reorder layers"};if(f9(`Applied: ${l[S]||S}.`,!0),A0.seq!=null)Y6(X0,A0.seq,l[S]||S)}}).catch(()=>f9(`${S} failed: network error`))},[R6,Y6,LJ]),[$5,PY]=u.useState(null),YQ=u.useCallback((b,S="")=>new Promise((i)=>{PY({title:b,value:S,resolve:i})}),[]),pQ=u.useCallback((b)=>{PY((S)=>{return S?.resolve?.(b),null})},[]),IY=u.useCallback((b,S)=>{let i=Q6.current.canvas;if(!i||i===r9||!S||!String(S).trim())return;$7({type:"comments-add",payload:{file:i,text:String(S).trim(),selector:"",dom_path:[],tag:"",classes:"",bounds:null,html_excerpt:"",timeline:b}}),f9("Comment added.",!0)},[]);Q6.current.selected=CH,Q6.current.setSelected=FY,Q6.current.removeClip=R5,Q6.current.clipVerb=C5,Q6.current.addComment=IY,Q6.current.askText=YQ,u.useEffect(()=>{let b=(S)=>{let i=Q6.current;if(!i.open||!i.comps?.length)return;let X0=S.target,H0=X0?.tagName;if(H0==="INPUT"&&X0?.type!=="range")return;if(H0==="TEXTAREA"||H0==="SELECT"||X0?.isContentEditable)return;let F0=TK(i.comps,i.compId)?.fps||30,A0=Math.max(1,i.total),l=(P0)=>{let i0=Math.max(0,Math.min(A0-1,Math.round(P0)));Z8(i0),I6(!1),i.post({dgn:"timeline-seek",frame:i0,id:i.compId})},D0=()=>{let P0=new Set([0,A0-1]);for(let i0 of i.sequences||[]){P0.add(i0.from);for(let _9 of i0.keyframes||[])P0.add(_9.from),P0.add(_9.to)}return[...P0].filter((i0)=>i0>=0&&i0<A0).sort((i0,_9)=>i0-_9)};if((S.metaKey||S.ctrlKey)&&(S.key==="z"||S.key==="Z")){S.preventDefault(),RG(S.shiftKey?"redo":"undo");return}if(S.key==="Escape"){if(i.selected!=null)S.preventDefault(),i.setSelected?.(null);return}if((S.key==="Delete"||S.key==="Backspace")&&i.selected!=null){S.preventDefault(),i.removeClip?.({stableId:i.selected});return}if((S.metaKey||S.ctrlKey)&&(S.key==="b"||S.key==="B")){S.preventDefault();let P0=i.selected!=null?{stableId:i.selected}:null;if(!P0){let i0=i.sequences||[],_9=i0.find((A9)=>A9.series&&i.frame>=A9.from&&i.frame<A9.from+A9.duration)||i0.find((A9)=>i.frame>=A9.from&&i.frame<A9.from+A9.duration);if(_9?.stableId)P0={stableId:_9.stableId}}if(P0)i.clipVerb?.(P0,"split",{atFrame:i.frame});else f9("Nothing under the playhead to split.");return}if(S.key===" "||S.code==="Space")if(S.preventDefault(),i.playing)I6(!1),i.post({dgn:"timeline-pause",id:i.compId});else I6(!0),i.post({dgn:"timeline-mute",muted:i.muted,id:i.compId}),i.post({dgn:"timeline-loop",loop:i.loop,id:i.compId}),i.post({dgn:"timeline-play",id:i.compId});else if(S.key==="ArrowRight")S.preventDefault(),l(i.frame+(S.shiftKey?F0:1));else if(S.key==="ArrowLeft")S.preventDefault(),l(i.frame-(S.shiftKey?F0:1));else if(S.key==="Home")S.preventDefault(),l(0);else if(S.key==="End")S.preventDefault(),l(A0-1);else if(S.key==="."){S.preventDefault();let P0=D0().find((i0)=>i0>i.frame);if(P0!=null)l(P0)}else if(S.key===","){S.preventDefault();let P0=D0().reverse().find((i0)=>i0<i.frame);if(P0!=null)l(P0)}};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[]),u.useEffect(()=>{z9([]),Z8(0),I6(!1),FY(null),RH(null);let b=setTimeout(()=>T0({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(b)},[V,T0]);let[lQ,TY]=u.useState(""),[kY,N4]=u.useState([]),[CG,RY]=u.useState([]);u.useEffect(()=>{if(!L0||E0.length===0||!V||V===r9){TY(""),N4([]);return}let b=!0;return fetch(`/_api/canvas-source?file=${encodeURIComponent(V)}`).then((S)=>S.ok?S.json():null).then((S)=>{if(b&&S?.ok&&typeof S.source==="string")TY(S.source)}).catch(()=>{}),()=>{b=!1}},[L0,E0,V,LY]),u.useEffect(()=>{if(!L0||!V||V===r9||!lQ){N4([]),RY([]);return}let b=!0,S=X6||void 0,i=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${S?`&artboardId=${encodeURIComponent(S)}`:""}`;return fetch(i).then((X0)=>X0.ok?X0.json():null).then((X0)=>{if(!b)return;let H0=X0?.ok&&Array.isArray(X0.clips)?X0.clips:[];N4(H0.filter((F0)=>F0.kind==="sequence")),RY(H0.filter((F0)=>F0.kind==="transition"))}).catch(()=>{}),()=>{b=!1}},[L0,V,lQ,X6,LY]),u.useEffect(()=>{if(!lQ){t9([]),x6([]),_5([]),kH(0);return}let b=R8??A?.artboardId??null,i=(b&&E0.find((F0)=>F0.artboardId===b||F0.id===b)||E0[0])?.durationInFrames||0,X0=sg(lQ,i,b);RH(X0.artboardId??b??null);let H0=X0.sequences.map((F0,A0)=>{let l=kY[A0];if(!l)return F0;return{...F0,stableId:l.stableId,contentHash:l.contentHash,mediaProps:l.mediaProps??null,placeholder:l.placeholder??null,mediaTag:l.mediaTag??F0.mediaTag,mediaSrc:l.mediaSrc??F0.mediaSrc,replaceable:!!(l.mediaCdId||l.mediaArrayRef),layers:Array.isArray(l.layers)?l.layers:[],hidden:!!l.hidden}});t9(H0),x6(X0.audio||[]),_5(X0.transitions||[]),kH(X0.total)},[lQ,kY,A,E0,R8]);let CY=u.useCallback(()=>{_Y((b)=>{let S=!b,i=V?i9.current.get(V):null;if(i&&i.contentWindow)try{i.contentWindow.postMessage({dgn:"view-annotations",visible:S},"*")}catch{}return S})},[V]),MJ=u.useCallback((b)=>{for(let S of i9.current.values())try{S.contentWindow.postMessage({dgn:"view-chrome",...b},"*")}catch{}},[]),$Y=u.useCallback(()=>{wY((b)=>{let S=!b;return MJ({minimap:S}),S})},[MJ]),SY=u.useCallback(()=>{U0((b)=>{let S=!b;return MJ({zoom:S}),S})},[MJ]),$G=u.useCallback(()=>{q4((b)=>{let S=!b;return MJ({present:S}),S})},[MJ]),F4=u.useCallback(()=>{q4(!1),MJ({present:!1})},[MJ]),SG=u.useCallback(()=>{if(!V||V===r9)return;aJ((b)=>{let S=!b;return T0({dgn:"view-chrome",print:S}),fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:V,patch:{overlays:{print:S}}})}).catch(()=>{}),S})},[V,T0]);u.useEffect(()=>{let b=!1;return fetch("/_api/git-user").then((S)=>S.json()).then((S)=>{if(b)return;let i=S&&typeof S.name==="string"?S.name.trim():"";if(i)IG(i)}).catch(()=>{}),()=>{b=!0}},[]),u.useEffect(()=>{if(!V||V===r9){sJ(0),aJ(!1);return}let b=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(V)).then((S)=>S.json()).then((S)=>{if(b)return;let i=Array.isArray(S?.artboards)?S.artboards.length:0;sJ(i),aJ(S?.overlays?.print===!0),D4(new Set(Array.isArray(S?.locked)?S.locked:[]))}).catch(()=>{if(!b)sJ(0),aJ(!1),D4(new Set)}),()=>{b=!0}},[V]),u.useEffect(()=>{if(!V||V===r9||!R8)return;let b=setTimeout(()=>{T0({dgn:"request-layers",artboardId:R8})},250);return()=>clearTimeout(b)},[V,R8,T0]);let[L4,D4]=u.useState(()=>new Set),bG=u.useCallback((b)=>{if(!V||V===r9)return;D4((S)=>{let i=new Set(S);if(i.has(b))i.delete(b);else i.add(b);let X0=[...i];return fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:V,patch:{locked:X0}})}).catch(()=>{}),T0({dgn:"locked-set",locked:X0}),i})},[V,T0]);u.useEffect(()=>{if(!V||V===r9)return;T0({dgn:"locked-set",locked:[...L4]})},[L4,V,T0]),u.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",f0),localStorage.setItem(M80,f0)}catch{}for(let b of i9.current.values())try{b.contentWindow.postMessage({dgn:"theme",theme:f0},"*")}catch{}},[f0]),u.useEffect(()=>{try{localStorage.setItem(p90,k8?"1":"0")}catch{}},[k8]),u.useEffect(()=>{try{localStorage.setItem(g90,J7?"1":"0")}catch{}},[J7]),u.useEffect(()=>{try{localStorage.setItem(m90,JSON.stringify(rX))}catch{}},[rX]),u.useEffect(()=>{try{localStorage.setItem(l90,QQ?"1":"0")}catch{}},[QQ]),u.useEffect(()=>{try{localStorage.setItem(d90,g6?"1":"0")}catch{}},[g6]),u.useEffect(()=>{try{localStorage.setItem(c90,XQ?"1":"0")}catch{}},[XQ]),u.useEffect(()=>{let b=!1;return fetch("/_api/ui-prefs").then((S)=>S.ok?S.json():Promise.reject(Error(`HTTP ${S.status}`))).then((S)=>{if(b||!S||typeof S!=="object")return;if(S.theme==="light"||S.theme==="dark")Y9(S.theme);if(typeof S.minimap==="boolean")wY(S.minimap);if(typeof S.zoom==="boolean")U0(S.zoom);if(typeof S.annotations==="boolean")_Y(S.annotations);if(typeof S.autoOpenInspector==="boolean")LG(S.autoOpenInspector);if(S.panelSides&&typeof S.panelSides==="object")H4({...sK,...S.panelSides});if(S.layersMode==="separate"||S.layersMode==="in-inspector")W0(S.layersMode)}).catch(()=>{}).finally(()=>{if(!b)EG(!0)}),()=>{b=!0}},[]),u.useEffect(()=>{if(!xH)return;HF0({theme:f0,minimap:QQ,zoom:g6,annotations:XQ,autoOpenInspector:U6,panelSides:NJ,layersMode:n})},[xH,f0,QQ,g6,XQ,U6,NJ,n]),u.useEffect(()=>{try{localStorage.setItem(i90,JSON.stringify(NJ))}catch{}},[NJ]),u.useEffect(()=>{try{localStorage.setItem(o90,n)}catch{}},[n]);let yG=u.useCallback((b,S)=>{BJ((i)=>{let X0=i[b],H0=X0===void 0?S:X0;return{...i,[b]:!H0}})},[]),M4=u.useCallback(()=>{Y9((b)=>b==="dark"?"light":"dark")},[]),O4=u.useRef(null),y8=u.useCallback(()=>O4.current?.reload()??Promise.resolve(),[]);u.useEffect(()=>{let b=fb({read:async(S)=>{let i=await fetch("/_index-data",{signal:S,cache:"no-store"});if(!i.ok)throw Object.assign(Error(`Project index request failed: ${i.status}`),{status:i.status});let X0=await i.json(),H0=X0.groups.map((F0)=>({...F0,tree:NF0(F0.paths,F0.stripPrefix,F0.dirs)}));return{data:X0,built:H0}},apply:({data:S,built:i})=>{H(S.project||"Design"),X(i),Y(!0),a7((X0)=>({...X0,canvasDesignSystems:S.canvasDesignSystems??{},canvasKinds:S.canvasKinds??{}}))},onError:(S)=>console.error("failed to load tree",S)});return O4.current=b,y8(),()=>{O4.current=null,b.dispose()}},[y8]);let WQ=u.useCallback(async(b)=>{try{let S=b?`/_system-data?ds=${encodeURIComponent(b)}`:"/_system-data",i=await fetch(S);if(!i.ok){console.error("failed to load system-data",i.status);return}let X0=await i.json();if(!b&&X0?.defaultDesignSystem&&!X0.ds){V0(X0);let H0=await fetch(`/_system-data?ds=${encodeURIComponent(X0.defaultDesignSystem)}`);if(H0.ok)V0(await H0.json());return}V0(X0)}catch(S){console.error("failed to load system-data",S)}},[]),bY=u.useCallback(async()=>{try{let S=await(await fetch("/_comments-all")).json();V8(S||{})}catch(b){console.error("failed to load comments",b)}},[]);u.useEffect(()=>{bY()},[bY]);let yY=u.useRef(()=>{});u.useEffect(()=>{let b=null,S=!1;function i(){let X0=location.protocol==="https:"?"wss:":"ws:",H0=new WebSocket(X0+"//"+location.host+"/_ws");T5.current=H0,H0.addEventListener("open",()=>{if(o(!0),S)K9();S=!0,clearInterval(b),b=setInterval(()=>{if(H0.readyState===WebSocket.OPEN)H0.send('{"type":"ping"}')},25000)}),H0.addEventListener("close",()=>{o(!1),clearInterval(b),setTimeout(i,1000)}),H0.addEventListener("error",()=>{}),H0.addEventListener("message",(F0)=>{try{let A0=JSON.parse(F0.data);if(A0.type==="snapshot"&&A0.state)E((l)=>N80(A0.state.selected,l));else if(A0.type==="selected"){if(Date.now()-k.current<2000)return;let l=A0.selected,D0=Array.isArray(l)?l[0]:l,P0=w.current,i0=Array.isArray(P0)?P0[0]:P0;if(E((_9)=>N80(l,_9)),D0?.id&&D0.file&&(!i0||i0.id!==D0.id||i0.file!==D0.file))$(D0)}else if(A0.type==="comments"&&typeof A0.file==="string")V8((l)=>({...l,[A0.file]:A0.comments||[]}));else if(A0.type==="ai-activity"&&typeof A0.file==="string"){if(EY(!0),mQ.current)clearTimeout(mQ.current);mQ.current=setTimeout(()=>EY(!1),8000);for(let l of i9.current.values())try{l.contentWindow.postMessage({dgn:"ai-activity",file:A0.file,entry:A0.entry},"*")}catch{}}else if(A0.type==="export:job"&&A0.payload)K4.upsert(A0.payload);else if(A0.type==="sync:status"&&A0.payload)a0(A0.payload);else if(A0.type==="canvas-list-update")y8(),yY.current(A0.payload);else if(A0.type==="config-updated")K9();else if(A0.type==="acp-focus"){if(G8())eX("assistant")}else if(A0.type==="git-status"&&A0.payload){if(!c9.current)I0(A0.payload)}else if(A0.type==="git-lifecycle"&&A0.payload){Z0(A0.payload);for(let l of i9.current.values())try{l.contentWindow.postMessage({dgn:"git-lifecycle",payload:A0.payload},"*")}catch{}}}catch{}})}return i(),()=>{if(clearInterval(b),T5.current)T5.current.close()}},[y8,K9]);function $7(b){let S=T5.current;try{if(S&&S.readyState===1)S.send(JSON.stringify(b))}catch{}}let OJ=u.useCallback(async()=>{if(c9.current)return;try{let b=await fetch("/_api/git/status");if(b.ok)I0(await b.json())}catch{}},[]),vJ=u.useCallback(async()=>{if(c9.current)return;try{let b=await fetch("/_api/git/status?remote=1");if(!b.ok)return;let S=await b.json();if(S&&S.repo!==!1)C0({remoteAhead:!!S.remoteAhead,behind:S.behind||0})}catch{}},[]),AJ=u.useCallback(async(b,S)=>{try{let i=await fetch(b,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(S||{})}),X0=await i.json().catch(()=>({}));return{ok:i.ok,...X0}}catch(i){return{ok:!1,error:"Network error — is the project still open?"}}},[]),jG=u.useCallback(async(b,S)=>{let i=await AJ("/_api/git/commit",{message:b,files:S});if(i.ok)await OJ();return i},[AJ,OJ]),jY=u.useCallback(async(b)=>{let S=await AJ("/_api/git/discard",{files:b});if(S.ok)await OJ();return S},[AJ,OJ]),vG=u.useCallback(async()=>{let b=await AJ("/_api/git/push",{});if(b.ok)await OJ(),vJ();return b},[AJ,OJ,vJ]),vY=u.useCallback(async()=>{let b=await AJ("/_api/git/pull",{});if(b.ok)await OJ(),vJ();if(b.conflict&&Array.isArray(b.files)&&b.files.length)v0({file:b.files[0],conflict:!0});return b},[AJ,OJ,vJ]),fG=u.useCallback(async(b)=>{let S=await AJ("/_api/git/resolve",{choice:b});if(S.ok)await OJ(),vJ();return S},[AJ,OJ,vJ]),fY=u.useCallback(async(b)=>{try{let S="/_api/git/log?limit=40"+(b?`&path=${encodeURIComponent(b)}`:""),i=await fetch(S);if(!i.ok)return[];return(await i.json()).entries||[]}catch{return[]}},[]),[xG,hG]=u.useState(null),gG=u.useCallback(async(b)=>{try{let S="/_api/cloud/history?limit=40"+(b?`&path=${encodeURIComponent(b)}`:""),i=await fetch(S);if(!i.ok)return null;let X0=await i.json();if(!X0?.ok)return null;return hG({branch:X0.branch??null,project:X0.project??null,hubHost:X0.hubHost??null}),X0.entries||[]}catch{return null}},[]),[mG,uG]=u.useState(!1),pG=u.useCallback(async(b)=>{try{let S="/_api/project/history?limit=40"+(b?`&path=${encodeURIComponent(b)}`:""),i=await fetch(S);if(!i.ok)return"legacy";let X0=await i.json();if(!X0?.ok)return X0?.reason==="legacy"?"legacy":null;return(X0.history||[]).map((H0)=>{let F0=b?"":(H0.canvases||[]).map((A0)=>A0.split("/").pop()).join(", ");return{sha:`r${H0.revision}`,message:[H0.label||H0.kind,F0].filter(Boolean).join(" · "),author:H0.actor,date:new Date(H0.committedAt).toISOString(),accepted:{revision:H0.revision,actionId:H0.actionId,mine:!!H0.mine,undo:H0.kind==="undo"||H0.kind==="redo"}}})}catch{return null}},[]),lG=u.useMemo(()=>{let b={modified:"M",added:"A",deleted:"D",untracked:"U"},S=new Map;if(I9)return S;for(let i of T9?.files||[])S.set(i.path,b[i.status]);return S},[T9,I9]);u.useEffect(()=>{if(I9){C0(null);return}if(T9?.repo===!1)return;vJ();let b=setInterval(vJ,W9?60000:120000);return()=>clearInterval(b)},[I9,T9?.repo,W9,vJ]);let V6=u.useCallback((b)=>{if(W.current="push",i8(null),F(null),b===V)return;if(U((S)=>{for(let i of S)if(i.path!==b)i9.current.delete(i.path);return[{path:b}]}),B(b),q9(null),y0(null),b!==r9)r0(b)},[V]),A4=u.useCallback((b,S="push")=>{let i=J.flatMap((X0)=>X0.paths||[]).find((X0)=>CW(X0,e0.designRel)===b);if(i&&yQ.test(i))V6(i);else if(i&&BL(Y4(i)))M(i);else U([]),B(null),F(null),PQ({title:"Not here yet",description:`${b} is not in this project (not synced yet?)`,kind:"info"});W.current=S},[J,e0.designRel,V6,M]),hH=u.useRef(!1);u.useEffect(()=>{if(!Q||e0.cloud===void 0||hH.current)return;hH.current=!0;let b=PV(location,e0.designRel);if(b)A4(b,"none")},[Q,e0.cloud,e0.designRel,A4]),u.useEffect(()=>{if(!Q||e0.cloud===void 0)return;let b=()=>{let S=PV(location,e0.designRel);if(S)A4(S,"none");else W.current="none",U([]),B(null),F(null)};return window.addEventListener("popstate",b),()=>window.removeEventListener("popstate",b)},[Q,e0.cloud,e0.designRel,A4]),u.useEffect(()=>{let b=N||(V===r9?null:V);if(b===G.current)return;G.current=b;let S=CW(b,e0.designRel);if(W.current!=="none"&&PV(location,e0.designRel)!==S)history[S?"pushState":"replaceState"](S?{open:S}:null,"",nh(location,S));W.current="push"},[V,N,e0.designRel]);let xY=N||(V===r9?null:V),dG=e0.cloud?"cloud":G8()?"native":"local",gH=(b)=>th({rel:CW(b,e0.designRel),shell:dG,location,linkedHubUrl:t0?.url,project:e0.cloud?Z:a9,localUrl:location.origin}),mH=(b=xY)=>{let S=CW(b,e0.designRel);if(S)vQ({path:b,rel:S,label:Y4(b)})},G1=u.useCallback((b)=>{if(q9(null),y0(null),K9(),d0((S)=>S+1),b&&b!==r9)r0(b)},[K9]),cG=u.useRef(!1);u.useEffect(()=>{if(cG.current)return;if(!e0.cloud)return;if(new URLSearchParams(location.search).has("open")){cG.current=!0;return}if(K.length>0)return;if(!J.length)return;let b=null;for(let S of J){for(let i of S.paths||[]){if(!yQ.test(i))continue;if(/(^|\/)system\//.test(i))continue;b=i;break}if(b)break}if(!b)return;cG.current=!0,V6(b)},[e0.cloud,J,K.length,V6]);let S5=u.useCallback((b)=>{let S=typeof b==="string"?b:void 0;if(S)WQ(S);else if(!L9)WQ();V6(r9)},[L9,WQ,V6]);u.useEffect(()=>{$7({type:"tabs",tabs:K.map((b)=>b.path).filter((b)=>b!==r9)})},[K]),u.useEffect(()=>{if(V&&V!==r9)$7({type:"active",file:V});else if(V===r9)$7({type:"active",file:""});else $7({type:"active",file:""})},[V]);let hY=u.useCallback((b)=>{U((S)=>{let i=S.findIndex((H0)=>H0.path===b);if(i<0)return S;let X0=S.filter((H0)=>H0.path!==b);if(b===V)if(X0.length===0)B(null);else B(X0[Math.max(0,i-1)].path);return X0}),i9.current.delete(b),r0((S)=>S===b?null:S)},[V]);yY.current=(b)=>{if(!b?.rel)return;let S=(e0?.designRel||e0?.designRoot||".design").replace(/^\/+|\/+$/g,""),i=`${S}/${b.rel}`;if(b.action==="removed")hY(i);else if(b.action==="moved"&&b.fromRel){let X0=`${S}/${b.fromRel}`;U((H0)=>H0.map((F0)=>F0.path===X0?{...F0,path:i}:F0)),B((H0)=>H0===X0?i:H0),r0((H0)=>H0===X0?null:H0),i9.current.delete(X0)}};let dQ=u.useCallback(()=>{if(!V||V===r9){if(V===r9)WQ();return}let b=i9.current.get(V);if(b)b.src=b.src},[V,WQ]),uH=u.useCallback(()=>y8(),[y8]),[Z1,pH]=u.useState(!1),iG=u.useRef(!1),oG=u.useCallback(async()=>{if(iG.current)return;iG.current=!0,pH(!0);try{await Promise.all([y8(),new Promise((b)=>setTimeout(b,550))])}finally{iG.current=!1,pH(!1)}},[y8]);u.useEffect(()=>{let b=null,S=()=>{if(b)clearTimeout(b);b=setTimeout(()=>{b=null,uH()},150)};return window.addEventListener("focus",S),()=>{if(window.removeEventListener("focus",S),b)clearTimeout(b)}},[uH]);let H1=u.useCallback(async(b)=>{try{let S=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b,kind:"brief-board"})}),i=await S.json().catch(()=>({}));if(!S.ok||!i.ok)return{ok:!1,error:i.error||`create failed (${S.status})`};return await y8(),V6(i.file),{ok:!0,file:i.file}}catch(S){return{ok:!1,error:S instanceof Error?S.message:"network error"}}},[y8,V6]),lH=u.useCallback(async()=>{let b=await YQ("New video name");if(!b)return;let i=(await YQ("Size — 1920x1080 (landscape), 1080x1920 (portrait), 1080x1080 (square), or custom WxH","1920x1080")||"1920x1080").toLowerCase().match(/(\d{2,5})\s*[x×]\s*(\d{2,5})/),X0=i?Number(i[1]):1920,H0=i?Number(i[2]):1080,F0=Math.max(1,Math.min(60,Number(await YQ("Frames per second","30"))||30));try{let A0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b,kind:"video-comp",clips:[],fps:F0,width:X0,height:H0})}),l=await A0.json().catch(()=>({}));if(!A0.ok||!l.ok){f9(`New video failed: ${l.error||`error ${A0.status}`}`);return}await y8(),V6(l.file),j0(!0),f9("New video created — drop clips on the timeline to start the cut.",!0)}catch(A0){f9(`New video failed: ${A0 instanceof Error?A0.message:"network error"}`)}},[y8,V6,YQ]),z1=u.useCallback(async()=>{if(!V||V===r9)return;try{let b=await fetch(`/_api/annotations?file=${encodeURIComponent(V)}`),S=b.ok?await b.text():"",i=[];if(S){let l=new DOMParser().parseFromString(S,"image/svg+xml");for(let D0 of l.querySelectorAll('[data-tool="mediaref"]')){let P0=D0.getAttribute("data-src");if(!P0)continue;i.push({src:P0,mediaKind:D0.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(i.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let H0=`${VY(Y4(V)).replace(/\.tsx$/i,"")} Video`,F0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:H0,kind:"video-comp",clips:i})}),A0=await F0.json().catch(()=>({}));if(!F0.ok||!A0.ok){window.alert(`Assemble failed: ${A0.error||`error ${F0.status}`}`);return}await y8(),V6(A0.file)}catch(b){window.alert(`Assemble failed: ${b instanceof Error?b.message:"network error"}`)}},[V,y8,V6]),nG=u.useCallback(({accept:b,resolveTarget:S})=>{let i=V,X0=X6||void 0,H0=document.createElement("input");H0.type="file",H0.accept=b,H0.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(H0);let F0=()=>{if(H0.isConnected)H0.remove()};window.addEventListener("focus",()=>setTimeout(F0,300),{once:!0}),H0.addEventListener("change",()=>{let A0=H0.files?.[0];if(F0(),!A0)return;let l=`/_api/comp-clips?canvas=${encodeURIComponent(i)}${X0?`&artboardId=${encodeURIComponent(X0)}`:""}`;fetch(l).then((D0)=>D0.json().catch(()=>({}))).then((D0)=>{let P0=S(D0);if(!P0)return f9("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":A0.type||"application/octet-stream"},body:A0}).then((i0)=>i0.json().catch(()=>({}))).then((i0)=>{if(!i0?.path)return f9(`Upload failed: ${i0?.error||"unknown error"}`),null;if(P0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:i,arrayName:P0.arrayRef.arrayName,index:P0.arrayRef.index,field:P0.arrayRef.field,value:i0.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:i,id:P0.cdId,attr:"src",value:i0.path})})})}).then((D0)=>D0?D0.json():null).then((D0)=>{if(D0&&!D0.ok)f9(`Replace refused: ${D0.error||"failed"}`);else if(D0&&D0.ok){if(f9("Media replaced.",!0),D0.seq!=null)Y6(i,D0.seq,"replace media")}}).catch(()=>f9("Replace failed: network error"))}),H0.click()},[V,X6,Y6]),K1=u.useCallback(async(b,S)=>{if(!window.confirm(`Move “${S}” to trash?
5683
+ `).length," lines, paths & secrets scrubbed)",H?.process?` + server memory (${Math.round(H.process.rssBytes/1048576)} MB)`:""," ","—"," ",D("details",{className:"rb-details",children:[z("summary",{children:"view"}),z("pre",{className:"rb-log",children:H.logs.serverLogTail})]})]})]}):null,G8()&&B.length>0&&D("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.crashLogs,onChange:(p)=>M({...F,crashLogs:p.target.checked})}),D("span",{children:["Crash logs (",B.length,") — ",z("code",{children:B.map((p)=>p.name).join(", ")})]})]})]}),D("p",{className:"rb-hint",children:["Your description and the system info above become a"," ",z("strong",{children:"public GitHub issue"}),"; screenshots and logs go to a private repository only maintainers can open."]}),D("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("describe"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-send",onClick:a,children:"Send report"})]})]}),Y==="sending"&&z("p",{className:"rb-hint",children:"Sending your report…"}),Y==="done"&&D(Q0,{children:[I?.issueUrl?D("p",{children:["Thank you — your report is filed as"," ",D("button",{type:"button",className:"rb-link","data-testid":"report-bug-issue-link",onClick:()=>{if(G8())LV(I.issueUrl).catch(()=>navigator.clipboard?.writeText(I.issueUrl));else window.open(I.issueUrl,"_blank","noopener")},children:["report #",I.issueNumber]})," ","on the public Maude issue tracker. Screenshots and logs stay in a private repository only maintainers can open — the issue links to them."]}):D("p",{children:["The bundle is saved locally",I?.fallbackDir?D(Q0,{children:[" ","at ",z("code",{children:I.fallbackDir})]}):null," ","and a prefilled GitHub issue was opened — attach the bundle files there."]}),z("footer",{className:"rb-actions",children:z("button",{type:"button",className:"st-btn rb-primary",onClick:m,children:"Done"})})]}),Y==="fallback"&&D(Q0,{children:[z("p",{className:"rb-error","data-testid":"report-bug-error",children:R}),z("p",{className:"rb-hint",children:"You can save the report locally instead and file it on GitHub yourself — the prefilled issue carries the text; screenshots stay on this machine unless you attach them by hand."}),D("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("preview"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary",onClick:f,children:"Save locally & open GitHub"})]})]})]})]})})}var TJ=j9(s9(),1);function Am(J){if(typeof J!=="string")return null;let X=J.match(/^(\d+)\.(\d+)\.(\d+)/);return X?[Number(X[1]),Number(X[2]),Number(X[3])]:null}function _m(J,X){let Q=Am(J),Y=Am(X);if(!Q)return!1;if(!Y)return!0;for(let W=0;W<3;W++)if(Q[W]!==Y[W])return Q[W]>Y[W];return!1}function wm(J,X){if(!Array.isArray(J))return[];return J.filter((Q)=>Q&&(Q.version==null||_m(Q.version,X)))}function Em(J,X){let Q=X;if(Array.isArray(J)){for(let Y of J)if(Y&&Y.version&&_m(Y.version,Q))Q=Y.version}return Q}var BE="mdcc-whatsnew-seen",NE="mdcc-whatsnew-toast-dismissed";function rU0(J){return typeof J==="string"&&/^https?:\/\//i.test(J)}function aU0(J){try{let X=localStorage.getItem(BE);if(X)return X;localStorage.setItem(BE,J)}catch{}return J}function sU0(){try{return localStorage.getItem(NE)}catch{return null}}function Pm(J){let[X,Q]=TJ.useState([]),[Y,W]=TJ.useState(J),[G,Z]=TJ.useState(()=>aU0(J)),[H,K]=TJ.useState(()=>sU0()),[U,V]=TJ.useState(!1);TJ.useEffect(()=>{let O=!1,I=()=>{fetch("/_api/whats-new").then(($)=>$.json()).then(($)=>{if(O)return;if(Q(Array.isArray($?.entries)?$.entries:[]),typeof $?.version==="string")W($.version)}).catch(()=>{})};I();let k=()=>I(),R=()=>{if(document.visibilityState==="visible")I()};return window.addEventListener("focus",k),document.addEventListener("visibilitychange",R),()=>{O=!0,window.removeEventListener("focus",k),document.removeEventListener("visibilitychange",R)}},[]);let B=wm(X,G),N=B.length>0&&H!==Y&&!U,F=B[0]??null,M=TJ.useCallback(()=>{let O=Em(X,Y);Z(O),K(Y);try{localStorage.setItem(BE,O),localStorage.setItem(NE,Y)}catch{}},[X,Y]),A=TJ.useCallback(()=>{K(Y);try{localStorage.setItem(NE,Y)}catch{}},[Y]),E=TJ.useCallback(()=>V(!0),[]),w=TJ.useCallback(()=>{V(!1),M()},[M]);return{entries:X,unseen:B,feedVersion:Y,panelOpen:U,openPanel:E,closePanel:w,showToast:N,toastEntry:F,dismissToast:A,markAllSeen:M}}function Im({wn:J}){let X=`whats-new-${J.feedVersion}`;return TJ.useEffect(()=>{if(!J.showToast||!J.toastEntry){$W(X);return}PQ({id:X,group:"whats-new",kind:"info",duration:1e4,title:`What's new${J.toastEntry.version?` · v${J.toastEntry.version}`:""} — ${J.toastEntry.title}`,description:J.toastEntry.summary,action:{label:J.unseen.length>1?`See all (${J.unseen.length})`:"Details",onClick:J.openPanel},onDismiss:J.dismissToast})},[X,J.showToast,J.toastEntry,J.unseen.length,J.openPanel,J.dismissToast]),TJ.useEffect(()=>()=>$W(X),[X]),null}function Tm({wn:J,onStartTour:X}){let{panelOpen:Q,closePanel:Y}=J;if(TJ.useEffect(()=>{if(!Q)return;function G(Z){if(Z.key==="Escape")Y()}return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[Q,Y]),!Q)return null;let W=new Set(J.unseen.map((G)=>G.id));return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)Y()},children:D("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[D("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"mdcc-wn-title",children:"✦ What’s new in maude"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:Y,children:"×"})]}),z("div",{className:"mdcc-wn-panel__body",children:J.entries.length===0?z("p",{className:"mdcc-wn-empty",children:"Nothing new yet."}):z("ul",{className:"mdcc-wn-list",children:J.entries.map((G)=>D("li",{className:"mdcc-wn-item"+(W.has(G.id)?" is-unseen":""),children:[D("div",{className:"mdcc-wn-item__hd",children:[z("span",{className:"mdcc-wn-kind mdcc-wn-kind--"+G.kind,children:G.kind}),z("span",{className:"mdcc-wn-item__title",children:G.title}),z("span",{className:"mdcc-wn-item__ver",children:G.version?`v${G.version}`:"next"})]}),z("p",{className:"mdcc-wn-item__summary",children:G.summary}),rU0(G.learnMore)&&z("a",{className:"mdcc-wn-item__more",href:G.learnMore,target:"_blank",rel:"noreferrer",children:"Learn more →"}),X&&Array.isArray(G.tour)&&G.tour.length>0&&z("button",{type:"button",className:"mdcc-wn-item__tour",onClick:()=>{Y(),X(G.tour)},children:"▶ Take tour"})]},G.id))})})]})})}var K7=({as:J,size:X=14})=>z(J,{size:X,strokeWidth:1.75,style:{display:"block"}}),x90="mdcc-usage-tour-seen",h90="mdcc-collab-tour-seen",r9="__system__",M80="mdcc-theme",g90="mdcc-show-hidden",m90="mdcc-sections-expanded",u90="maude-cp-mode",p90="mdcc-sidebar-open",l90="mdcc-minimap-visible",d90="mdcc-zoomctl-visible",c90="mdcc-annotations-visible";var ZF0=30000;function HF0(J){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(J)}).catch(()=>{})}catch{}}var Wk=[{id:"tree",label:"Files"},{id:"layers",label:"Layers"},{id:"inspector",label:"Inspector"},{id:"comments",label:"Comments"},{id:"changes",label:"Changes"},{id:"sync",label:"Sync"},{id:"assistant",label:"Assistant"}],sK={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",sync:"right",assistant:"right"},i90="mdcc-panel-sides",o90="mdcc-layers-mode";function n90({side:J,width:X,open:Q,ids:Y,activeId:W,onPick:G,children:Z,labels:H=null}){return D("div",{className:"st-dockslot st-dockslot--"+J+(Q?"":" is-collapsed"),style:{width:Q?X:0,flexBasis:Q?X:0},children:[Q&&Y.length>1&&z("div",{className:"st-docktabs",role:"tablist","aria-label":J+" panels",children:Y.map((K)=>z("button",{type:"button",role:"tab","data-testid":`dock-tab-${K}`,"aria-selected":W===K,className:"st-docktab"+(W===K?" is-active":""),onClick:()=>G(K),children:H?.[K]||(Wk.find((U)=>U.id===K)||{}).label||K},K))}),Z]})}var yQ=/\.(tsx|html?)$/i,zF0=[[/\.md$/i,"markdown"],[/\.(css|json|txt|ya?ml)$/i,"text"],[/\.(svg|png|jpe?g|gif|webp|avif)$/i,"image"],[/\.(mp4|webm|mov)$/i,"video"],[/\.(mp3|wav|ogg|m4a)$/i,"audio"],[/\.(woff2?|ttf|otf)$/i,"font"]];function BL(J){for(let[X,Q]of zF0)if(X.test(J))return Q;return null}function Bq(J){return J.replace(/^\.[^/]+\//,"").replace(yQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}function KF0(J){let X=[];return function Q(Y){for(let W of Y||[])X.push(W?.id??""),Q(W?.children)}(J),X.join(",")}var Gk="1.4.1";function YL(J,X){let Q=()=>{try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(J,{body:X})}catch{}};if(G8()){O7("send_notification",{title:J,body:X}).catch(Q);return}Q()}function UF0(){if(typeof window>"u")return"dark";try{let J=localStorage.getItem(M80);if(J==="light"||J==="dark")return J}catch{}return"dark"}function IH(J,X){if(typeof window>"u")return X;try{let Q=localStorage.getItem(J);if(Q==="1")return!0;if(Q==="0")return!1}catch{}return X}function Jk(J,X){if(typeof window>"u")return X;try{let Q=localStorage.getItem(J);return Q?JSON.parse(Q):X}catch{return X}}function VF0(J){if(J.kind==="runtime")return!1;if(J.label==="Design system")return!1;return!0}function Y4(J){return J.split("/").pop()}function f9(J,X=!1,Q){PQ({title:J,kind:X?"success":"error",action:Q})}var r90="maude-mode-hint-seen";function ZL(J=!1){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(r90)==="1")return}catch{return}if(ZL.active)return;ZL.active=!0;let X=()=>{ZL.active=!1;try{localStorage.setItem(r90,"1")}catch{}document.removeEventListener("keydown",Q,!0)},Q=(Y)=>{if((Y.key==="v"||Y.key==="V")&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey)$W("mode-hint"),X()};if(J)document.addEventListener("keydown",Q,!0);PQ({id:"mode-hint",title:J?"Your mock is live":"You’re in Edit",description:J?"Click things to try it. Press V to select & inspect.":"Click selects, like Figma. Switch to Preview in the toolbar to use the live mock.",onDismiss:X})}function VY(J){return J.replace(yQ,"")}function qF0(J){return J.replace(yQ,"")}function BF0(J){let X=new Map;for(let G of J){if(!yQ.test(G.name))continue;let Z=qF0(G.name);if(!X.has(Z)||/\.tsx$/i.test(G.name))X.set(Z,G)}let Q=new Map,Y=[];for(let G of J){if(yQ.test(G.name))continue;let Z=null;for(let H of X.keys()){if(G.name===H)continue;if(G.name.startsWith(`${H}.`)){if(!Z||H.length>Z.length)Z=H}}if(Z){let H=Q.get(Z)||[];H.push(G),Q.set(Z,H)}else Y.push(G)}let W=[];for(let[G,Z]of X){let H=(Q.get(G)||[]).sort((K,U)=>K.name.localeCompare(U.name));W.push({primary:Z,sidecars:H,orphan:!1})}return W.sort((G,Z)=>G.primary.name.localeCompare(Z.primary.name)),Y.sort((G,Z)=>G.name.localeCompare(Z.name)),{canvases:W,orphans:Y.map((G)=>({primary:G,sidecars:[],orphan:!0}))}}function NF0(J,X,Q){let Y={};for(let W of Q||[]){let Z=(W.startsWith(X)?W.slice(X.length).replace(/^\/+/,""):W).split("/").filter(Boolean),H=Y;for(let K of Z)H=H[K]=H[K]||{};H._files=H._files||[]}for(let W of J){let Z=(W.startsWith(X)?W.slice(X.length).replace(/^\/+/,""):W).split("/"),H=Y;for(let K=0;K<Z.length;K++){let U=Z[K];if(K===Z.length-1)H._files=H._files||[],H._files.push({name:U,path:W});else H[U]=H[U]||{},H=H[U]}}return Y}function O80(J,X){if(!X)return J;let Q=X.toLowerCase(),Y={},W=!1,G=Object.keys(J).filter((Z)=>Z!=="_files");for(let Z of G){let H=O80(J[Z],X);if(H)Y[Z]=H,W=!0}if(J._files){let Z=J._files.filter((H)=>H.name.toLowerCase().includes(Q)||H.path.toLowerCase().includes(Q));if(Z.length)Y._files=Z,W=!0}return W?Y:null}function HL(J){return(J||[]).filter((X)=>X.status!=="resolved").length}function FF0(J){if(!J)return"";let X=new Date(J).getTime();if(!X)return"";let Q=Math.max(0,Math.floor((Date.now()-X)/1000));if(Q<60)return Q+"s";let Y=Math.floor(Q/60);if(Y<60)return Y+"m";let W=Math.floor(Y/60);if(W<24)return W+"h";let G=Math.floor(W/24);if(G<7)return G+"d";return new Date(J).toLocaleDateString()}function A80(J){let X=0,Q=0,Y=0;for(let W of Object.values(J||{}))for(let G of W||[])if(X++,G.status==="resolved")Y++;else Q++;return{all:X,open:Q,resolved:Y}}function KL({d:J,size:X=14,color:Q}){return z("svg",{width:X,height:X,viewBox:"0 0 24 24",fill:"none",stroke:Q||"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{flex:"none"},children:z("path",{d:J})})}var LF0={"chevron-down":z("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":z("polyline",{points:"6 3.5 10.5 8 6 12.5"}),file:D(Q0,{children:[z("path",{d:"M4 2h5l3 3v9H4z"}),z("polyline",{points:"9 2 9 5 12 5"})]}),folder:z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),"folder-plus":D(Q0,{children:[z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),z("path",{d:"M8 7.5v3.5M6.25 9.25h3.5"})]}),lock:D(Q0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015 0v2"})]}),unlock:D(Q0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015-.7"})]}),search:D(Q0,{children:[z("circle",{cx:"7",cy:"7",r:"4"}),z("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:D(Q0,{children:[z("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),z("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),check:z("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),x:D(Q0,{children:[z("line",{x1:"4.3",y1:"4.3",x2:"11.7",y2:"11.7"}),z("line",{x1:"11.7",y1:"4.3",x2:"4.3",y2:"11.7"})]}),sun:D(Q0,{children:[z("circle",{cx:"8",cy:"8",r:"2.6"}),z("line",{x1:"8",y1:"1.5",x2:"8",y2:"3"}),z("line",{x1:"8",y1:"13",x2:"8",y2:"14.5"}),z("line",{x1:"1.5",y1:"8",x2:"3",y2:"8"}),z("line",{x1:"13",y1:"8",x2:"14.5",y2:"8"}),z("line",{x1:"3.4",y1:"3.4",x2:"4.4",y2:"4.4"}),z("line",{x1:"11.6",y1:"11.6",x2:"12.6",y2:"12.6"}),z("line",{x1:"12.6",y1:"3.4",x2:"11.6",y2:"4.4"}),z("line",{x1:"4.4",y1:"11.6",x2:"3.4",y2:"12.6"})]}),moon:z("path",{d:"M12.5 9.6A5 5 0 1 1 7 3a4 4 0 0 0 5.5 6.6z"}),sparkle:z("path",{d:"M8 1.8l1.4 4.8L14 8l-4.6 1.4L8 14.2l-1.4-4.8L2 8l4.6-1.4z",fill:"currentColor",stroke:"none"}),megaphone:D(Q0,{children:[z("path",{d:"M2 6.7 11 4v8L2 9.3z"}),z("path",{d:"M11 5.2a2.4 2.4 0 0 1 0 5.6"}),z("path",{d:"M4.3 9.5v2.3a1.2 1.2 0 0 0 2.4 0v-1.7"})]}),bug:D(Q0,{children:[z("circle",{cx:"8",cy:"9",r:"3.6"}),z("circle",{cx:"8",cy:"4.4",r:"1.3"}),z("path",{d:"M6.2 3.4 5.2 2M9.8 3.4l1-1.4"}),z("path",{d:"M4.6 7.6H2.2M4.6 9H2.2M4.6 10.6H2.5M11.4 7.6h2.4M11.4 9h2.4M11.4 10.6h2.3"})]}),"panel-left":D(Q0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("line",{x1:"6.4",y1:"3",x2:"6.4",y2:"13"})]}),resolve:D(Q0,{children:[z("circle",{cx:"8",cy:"8",r:"5.6"}),z("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:D(Q0,{children:[z("path",{d:"M3.2 8a5 5 0 1 1 1.4 3.5"}),z("polyline",{points:"3.2 11.4 3.2 8 6.6 8"})]}),layers:D(Q0,{children:[z("polygon",{points:"8 2.2 13.8 5.5 8 8.8 2.2 5.5"}),z("polyline",{points:"2.2 9 8 12.3 13.8 9"})]}),box:z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.2"}),type:D(Q0,{children:[z("polyline",{points:"4 4 12 4"}),z("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:D(Q0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"3"}),z("line",{x1:"6",y1:"8",x2:"10",y2:"8"})]}),input:D(Q0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"1.2"}),z("line",{x1:"5",y1:"8",x2:"5",y2:"8"})]}),link:D(Q0,{children:[z("path",{d:"M6.5 9.5a2.5 2.5 0 0 1 0-3.5l1.5-1.5a2.5 2.5 0 0 1 3.5 3.5l-1 1"}),z("path",{d:"M9.5 6.5a2.5 2.5 0 0 1 0 3.5l-1.5 1.5a2.5 2.5 0 0 1-3.5-3.5l1-1"})]}),list:D(Q0,{children:[z("line",{x1:"6",y1:"4.5",x2:"13",y2:"4.5"}),z("line",{x1:"6",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6",y1:"11.5",x2:"13",y2:"11.5"}),z("circle",{cx:"3.2",cy:"4.5",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"8",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"11.5",r:"0.8",fill:"currentColor"})]}),eye:D(Q0,{children:[z("path",{d:"M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z"}),z("circle",{cx:"8",cy:"8",r:"2"})]}),eyedropper:D(Q0,{children:[z("path",{d:"M11 2.6a1.7 1.7 0 0 1 2.4 2.4l-1.2 1.2-2.4-2.4z"}),z("path",{d:"M9.5 4.6 4 10.1V12h1.9l5.5-5.5"})]}),"p-corner":z("path",{d:"M3.5 12.5V7a3.5 3.5 0 0 1 3.5-3.5h5.5"}),"p-opacity":D(Q0,{children:[z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.5"}),z("path",{d:"M3 8h10M8 3v10",strokeWidth:"0.9",opacity:"0.55"})]}),"p-lineheight":D(Q0,{children:[z("line",{x1:"6.5",y1:"4",x2:"13",y2:"4"}),z("line",{x1:"6.5",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6.5",y1:"12",x2:"13",y2:"12"}),z("path",{d:"M3.2 4.6 3.2 11.4M2 6 3.2 4.5 4.4 6M2 10 3.2 11.5 4.4 10"})]}),"p-letterspacing":D(Q0,{children:[z("path",{d:"M3 4v8M13 4v8"}),z("path",{d:"M6 11.5 8 5l2 6.5M6.7 9.3h2.6",strokeWidth:"1.1"})]}),"p-gap":D(Q0,{children:[z("rect",{x:"2",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("rect",{x:"10.4",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("path",{d:"M6.8 8h2.4M7.4 6.9 6.4 8l1 1.1M8.6 6.9 9.6 8l-1 1.1",strokeWidth:"1"})]}),"p-border":z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"}),"p-size":D(Q0,{children:[z("path",{d:"M3 13 6.6 3l3.6 10"}),z("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":D(Q0,{children:[z("path",{d:"M6.3 4A6.7 6.7 0 0 1 8 3.5C12 3.5 14.5 8 14.5 8a12 12 0 0 1-2 2.4M4.4 5.3A12 12 0 0 0 1.5 8S4 12.5 8 12.5a6.5 6.5 0 0 0 2.1-.35"}),z("line",{x1:"2.5",y1:"2.5",x2:"13.5",y2:"13.5"})]}),sliders:D(Q0,{children:[z("line",{x1:"3",y1:"5",x2:"13",y2:"5"}),z("circle",{cx:"6",cy:"5",r:"1.7",fill:"currentColor"}),z("line",{x1:"3",y1:"11",x2:"13",y2:"11"}),z("circle",{cx:"10",cy:"11",r:"1.7",fill:"currentColor"})]}),code:D(Q0,{children:[z("polyline",{points:"6 5 3 8 6 11"}),z("polyline",{points:"10 5 13 8 10 11"})]}),download:D(Q0,{children:[z("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),z("polyline",{points:"4.5 7 8 10.5 11.5 7"}),z("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),reload:D(Q0,{children:[z("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),z("path",{d:"M14 2v3.33h-3.33"})]}),help:D(Q0,{children:[z("circle",{cx:"8",cy:"8",r:"6"}),z("path",{d:"M6.3 6.2a1.8 1.8 0 1 1 2.3 1.9c-.5.2-.6.5-.6 1v.3"}),z("line",{x1:"8",y1:"11.4",x2:"8",y2:"11.5"})]}),image:D(Q0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("circle",{cx:"6",cy:"6.3",r:"1.1"}),z("path",{d:"M3 12l3-2.8 2.2 1.8 2.4-3L13.5 12"})]}),vector:D(Q0,{children:[z("path",{d:"M3.6 11.2C6 5 10 5 12.4 11.2"}),z("rect",{x:"1.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"11.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"6.7",y:"2.6",width:"2.6",height:"2.6",rx:"0.4"})]}),presentation:D(Q0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"7.4",rx:"1"}),z("line",{x1:"8",y1:"10.4",x2:"8",y2:"13"}),z("line",{x1:"5.6",y1:"13.4",x2:"10.4",y2:"13.4"})]}),archive:D(Q0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"3",rx:"0.8"}),z("path",{d:"M3.6 6v6.2a1 1 0 0 0 1 1h6.8a1 1 0 0 0 1-1V6"}),z("line",{x1:"6.6",y1:"8.8",x2:"9.4",y2:"8.8"})]}),external:D(Q0,{children:[z("path",{d:"M11 8.5V12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h3.5"}),z("polyline",{points:"9.5 3 13 3 13 6.5"}),z("line",{x1:"13",y1:"3",x2:"7.6",y2:"8.4"})]}),share:D(Q0,{children:[z("circle",{cx:"4",cy:"8",r:"1.9"}),z("circle",{cx:"11.6",cy:"3.6",r:"1.9"}),z("circle",{cx:"11.6",cy:"12.4",r:"1.9"}),z("line",{x1:"5.7",y1:"7",x2:"9.9",y2:"4.6"}),z("line",{x1:"5.7",y1:"9",x2:"9.9",y2:"11.4"})]}),pen:D(Q0,{children:[z("path",{d:"M3 13l.8-3L10.6 3.2a1.1 1.1 0 0 1 1.6 0l.6.6a1.1 1.1 0 0 1 0 1.6L6 12.2z"}),z("line",{x1:"9.6",y1:"4.2",x2:"11.8",y2:"6.4"})]}),square:z("rect",{x:"3.5",y:"3.5",width:"9",height:"9",rx:"1"})};function DF0({open:J,onClose:X,actions:Q}){let[Y,W]=u.useState(""),[G,Z]=u.useState(0),H=u.useRef(null);u.useEffect(()=>{if(J)W(""),Z(0)},[J]),u.useEffect(()=>{H.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[G]);let K=u.useMemo(()=>{let V=Y.trim().toLowerCase();if(!V)return Q;return Q.filter((B)=>B.label.toLowerCase().includes(V)||B.group&&B.group.toLowerCase().includes(V))},[Y,Q]);if(u.useEffect(()=>{if(G>=K.length)Z(0)},[K.length,G]),!J)return null;let U=(V)=>{X(),V.run()};return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(V)=>{if(V.target===V.currentTarget)X()},children:D("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[D("div",{className:"st-pal-search",children:[z(T8,{name:"search",size:18}),z("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(V)=>W(V.target.value),onKeyDown:(V)=>{if(V.key==="Escape")V.preventDefault(),X();else if(V.key==="ArrowDown")V.preventDefault(),Z((B)=>Math.min(K.length-1,B+1));else if(V.key==="ArrowUp")V.preventDefault(),Z((B)=>Math.max(0,B-1));else if(V.key==="Enter"){if(V.preventDefault(),K[G])U(K[G])}}}),z(CJ,{children:"⌘K"})]}),z("div",{className:"st-pal-list",ref:H,children:K.length===0?z("div",{className:"st-pal-empty",children:"No matching command."}):K.map((V,B)=>{let N=V.group&&(B===0||K[B-1].group!==V.group)?z("div",{className:"st-pal-group",children:V.group},"g-"+V.group):null;return D(Q0,{children:[N,D("button",{type:"button",className:"st-pal-item"+(B===G?" is-active":""),onMouseEnter:()=>Z(B),onClick:()=>U(V),children:[z("span",{className:"st-pal-icon",children:z(T8,{name:V.icon,size:15})}),z("span",{className:"st-pal-label",children:V.label}),V.kbd?z("span",{className:"st-pal-kbd",children:z(CJ,{children:V.kbd})}):null]})]},V.id)})})]})})}function T8({name:J,size:X=16,className:Q}){return z("svg",{className:Q,width:X,height:X,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:LF0[J]})}function MF0(J){if(!J||typeof J!=="string")return"?";let X=J.trim().split(/[\s._-]+/).filter(Boolean);if(!X.length)return"?";if(X.length===1)return X[0].slice(0,2).toUpperCase();return((X[0][0]||"")+(X[X.length-1][0]||"")).toUpperCase()||"?"}function a90({initials:J,hue:X,title:Q,pulse:Y}){return z("span",{className:"st-avatar"+(Y?" is-pulsing":""),style:{"--av-hue":X},"data-tip":Q,"aria-label":Q,children:J})}function CJ({children:J}){return z("span",{className:"kbd",children:J})}function s90(J,{min:X,max:Q,def:Y}){let W=u.useCallback((K)=>Math.min(Q,Math.max(X,K)),[X,Q]),[G,Z]=u.useState(()=>{try{let K=parseInt(localStorage.getItem(J)||"",10);return Number.isFinite(K)?W(K):Y}catch{return Y}});u.useEffect(()=>{try{localStorage.setItem(J,String(G))}catch{}},[J,G]);let H=u.useCallback((K)=>Z((U)=>W(typeof K==="function"?K(U):K)),[W]);return{w:G,setW:H,min:X,max:Q,def:Y}}function t90({label:J,size:X,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:K,def:U}=X,V=W==="rtl"?-1:1;return z("div",{className:"st-grip"+(Y?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":J,"aria-valuemin":H,"aria-valuemax":K,"aria-valuenow":Math.round(G),onPointerDown:Q,onDoubleClick:()=>Z(U),onKeyDown:(B)=>{let N=B.shiftKey?24:8;if(B.key==="ArrowRight")B.preventDefault(),Z((F)=>F+N*V);else if(B.key==="ArrowLeft")B.preventDefault(),Z((F)=>F-N*V);else if(B.key==="Home")B.preventDefault(),Z(H);else if(B.key==="End")B.preventDefault(),Z(K)},children:D("svg",{className:"st-grip-dots",viewBox:"0 0 6 18","aria-hidden":"true",children:[z("circle",{cx:"3",cy:"3",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"9",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"15",r:"1.1",fill:"currentColor"})]})})}var Xk=[{id:"png",label:"PNG",sub:"raster · 2×",icon:"image",format:"png",options:{scale:2}},{id:"pdf",label:"PDF",sub:"vector · print",icon:"file",format:"pdf"},{id:"svg",label:"SVG",sub:"per artboard",icon:"vector",format:"svg"},{id:"html",label:"HTML",sub:"self-contained",icon:"code",format:"html"},{id:"pptx",label:"PPTX",sub:"slides",icon:"presentation",format:"pptx"},{id:"mp4",label:"MP4",sub:"video · H.264",icon:"presentation",format:"mp4",temporal:!0},{id:"gif",label:"GIF",sub:"animated",icon:"image",format:"gif",temporal:!0},{id:"canva",label:"Canva",sub:"handoff bundle",icon:"external",format:"canva"},{id:"zip",label:"ZIP",sub:"project bundle",icon:"archive",format:"zip"},{id:"shadcn",label:"AI handoff",sub:"production drop",icon:"sparkle",handoff:!0}],e90={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},OF0=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],Kq=[{id:"1x",label:"1× (native)",kind:"scale",value:1},{id:"2x",label:"2× (retina)",kind:"scale",value:2},{id:"3x",label:"3× (max)",kind:"scale",value:3},{id:"dpi150",label:"150 dpi",kind:"dpi",value:150},{id:"dpi300",label:"300 dpi (print)",kind:"dpi",value:300},{id:"dpi600",label:"600 dpi (high-res print)",kind:"dpi",value:600}],AF0="2x",J80=[{id:"auto",label:"Auto (1×)",value:void 0},{id:"dpi150",label:"150 dpi",value:150},{id:"dpi300",label:"300 dpi (print)",value:300},{id:"dpi600",label:"600 dpi (high-res print)",value:600}],_F0="auto",X80=[{id:"keep",label:"Keep selectable (default)",description:"Text stays selectable and searchable. You are warned if a font came out unprintable."},{id:"embed",label:"Verify fonts embedded",description:"Same file, but the export fails instead of shipping a font a print shop would reject."},{id:"outline",label:"Convert to outlines (print-safe)",description:"Every glyph becomes a vector path — no fonts left to break. Text is no longer selectable "+"and the file can grow a lot. Needs Ghostscript installed locally; cloud workspaces have it."}],wF0="keep",EF0={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",avif:"image/avif",svg:"image/svg+xml",mp4:"video/mp4",mov:"video/quicktime",webm:"video/webm",m4v:"video/mp4",ogg:"video/ogg",mp3:"audio/mpeg",wav:"audio/wav",m4a:"audio/mp4",aac:"audio/aac",flac:"audio/flac",oga:"audio/ogg",opus:"audio/opus"};function PF0(J){let X=String(J||"").split(".").pop()?.toLowerCase();return EF0[X]||"application/octet-stream"}function IF0({designRel:J,onPick:X,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[Z,H]=u.useState(null),[K,U]=u.useState(!1),[V,B]=u.useState(null),[N,F]=u.useState(()=>new Set),[M,A]=u.useState({}),[E,w]=u.useState(W?"artboard":"annotation");u.useEffect(()=>{let f=!0;return fetch("/_api/assets").then((h)=>h.json()).then((h)=>{if(!f)return;let p=h.ok?h.assets:[];H(p),A((v)=>{let r={...v};for(let e of p)r[e.path]=e.kind;return r})}).catch(()=>f&&H([])),()=>{f=!1}},[]),u.useEffect(()=>{let f=(h)=>{if(h.key==="Escape")h.stopPropagation(),Q()};return window.addEventListener("keydown",f,!0),()=>window.removeEventListener("keydown",f,!0)},[Q]);let O=Array.from(N).some((f)=>(M[f]||"image")!=="image"),I=!W||O,k=!W?"No artboard on this canvas":O?"Video/audio can only be added as annotations":"";u.useEffect(()=>{if(I&&E==="artboard")w("annotation")},[I,E]);let R=(f)=>{F((h)=>{let p=new Set(h);if(p.has(f))p.delete(f);else p.add(f);return p})},$=async(f)=>{let h=await fetch("/_api/asset",{method:"POST",headers:{"content-type":f.type||"application/octet-stream"},body:f}),p=await h.json().catch(()=>({}));if(h.ok&&p.path)return{ok:!0,path:p.path};return{ok:!1,error:p.error||`upload failed (HTTP ${h.status})`}},C=async(f)=>{if(!f)return;U(!0),B(null);let h=await $(f);if(U(!1),h.ok)X(h.path);else B(h.error)},j=(f)=>{if(typeof f==="string"&&f.startsWith("video/"))return"video";if(typeof f==="string"&&f.startsWith("audio/"))return"audio";return"image"},x=async(f)=>{if(!f.length)return;U(!0),B(null);let h=await Promise.all(f.map((r)=>$(r).then((e)=>({...e,file:r}))));U(!1);let p=h.filter((r)=>r.ok),v=h.length-p.length;if(v>0)B(`${v} of ${h.length} uploads failed`);if(p.length)A((r)=>{let e={...r};for(let c of p)e[c.path]=j(c.file.type);return e}),F((r)=>{let e=new Set(r);for(let c of p)e.add(c.path);return e})},m=async()=>{U(!0),B(null);try{if(Y){let p=(await Kh()||[]).map((v)=>new File([new Uint8Array(v.bytes)],v.name,{type:PF0(v.name)}));if(U(!1),p.length)await x(p);return}let f=await lZ();if(f?.bytes){await C(new Blob([new Uint8Array(f.bytes)]));return}}catch(f){B(f?.message||"open failed")}U(!1)},d=()=>{if(G8()){m();return}let f=document.createElement("input");if(f.type="file",f.accept="image/*,video/*",Y)f.multiple=!0;f.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(f);let h=()=>{if(f.isConnected)f.remove()};window.addEventListener("focus",()=>setTimeout(h,300),{once:!0}),f.addEventListener("change",()=>{let p=f.files?Array.from(f.files):[];if(h(),!p.length)return;if(Y)x(p);else C(p[0])}),f.click()},a=(f)=>`/${J}/${f}`;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(f)=>{if(f.target===f.currentTarget)Q()},children:D("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[D("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Choose media"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:Q,children:z(T8,{name:"x",size:15})})]}),D("div",{className:"st-dialog-bd",children:[D("div",{className:"st-ap-toolbar",children:[z("button",{type:"button",className:"st-btn",onClick:d,disabled:K,children:K?"Uploading…":"Upload…"}),V&&z("span",{className:"st-ap-err",children:V})]}),z("div",{className:"st-ap-grid",children:Z==null?z("div",{className:"st-ap-empty",children:"Loading…"}):Z.length===0?z("div",{className:"st-ap-empty",children:"No assets yet — upload one."}):Z.map((f)=>{let h=Y&&N.has(f.path);return D("button",{type:"button",className:"st-ap-cell","data-selected":h?"true":void 0,"aria-pressed":Y?h:void 0,title:`${f.name} · ${Math.max(1,Math.round(f.size/1024))} KB`,onClick:()=>Y?R(f.path):X(f.path),children:[Y&&z("span",{className:"st-ap-check","aria-hidden":"true",children:h?z(T8,{name:"check",size:12}):null}),f.kind==="video"?z("video",{className:"st-ap-thumb",src:a(f.path),muted:!0,playsInline:!0}):z("img",{className:"st-ap-thumb",src:a(f.path),alt:f.name,loading:"lazy"}),z("span",{className:"st-ap-name",children:f.name})]},f.path)})})]}),Y&&N.size>0&&D("div",{className:"st-dialog-ft st-ap-confirm",children:[D("span",{className:"st-ap-count",children:[N.size," selected"]}),D("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":E==="artboard",disabled:I,onClick:()=>w("artboard"),children:"Add to artboard"}),z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":E==="annotation",onClick:()=>w("annotation"),children:"Add as annotation"})]}),I&&z("span",{className:"st-ap-dest-note",children:k}),z("span",{className:"st-ap-confirm-spacer"}),z("button",{type:"button",className:"btn btn--ghost",onClick:Q,children:"Cancel"}),z("button",{type:"button",className:"btn btn--primary",onClick:()=>G?.(Array.from(N),E),children:"Insert"})]})]})})}function UL(J,X){let Q=URL.createObjectURL(X),Y=document.createElement("a");Y.href=Q,Y.download=J||"export",document.body.appendChild(Y),Y.click(),Y.remove(),setTimeout(()=>URL.revokeObjectURL(Q),1e4)}function TF0({mode:J,initialScope:X,activePath:Q,hasComps:Y=!1,comps:W=[],activeArtboardId:G=null,selection:Z=null,exportLane:H="local",onBrowserCapture:K=null,onClose:U}){let V=u.useCallback((I0)=>H==="none"&&!I0.handoff&&I0.format!=="zip"&&!xb.has(I0.format)||H!=="local"&&I0.format==="canva",[H]),[B,N]=u.useState(J==="handoff"?"shadcn":"png"),[F,M]=u.useState(()=>X&&Tb("png",X)?X:AO("png")),[A,E]=u.useState(2),[w,O]=u.useState(AF0),[I,k]=u.useState(!0),[R,$]=u.useState(!1),[C,j]=u.useState(!1),[x,m]=u.useState(!1),[d,a]=u.useState(_F0),[f,h]=u.useState(wF0),[p,v]=u.useState(!0),[r,e]=u.useState(!1),[c,K0]=u.useState(null),[s,z0]=u.useState([]),o=Xk.find((I0)=>I0.id===B)||Xk[0],q0=o.handoff?[]:_O(o.format),Z0=900,k0=3600,a0=TK(W,gw(W,{artboardId:G})),s0=a0?.durationInFrames||0,t0=a0?.fps||30,E9=o.temporal&&s0>900,a9=o.temporal&&s0>3600;u.useEffect(()=>{if(q0.length&&!q0.includes(F))M(AO(o.format))},[q0,F,o.format]),u.useEffect(()=>{if(H!=="remote")return;fetch("/_api/export-warmup").catch(()=>{})},[H]);let F9=u.useCallback(()=>{fetch("/_api/export-history").then((I0)=>I0.json()).then((I0)=>z0(Array.isArray(I0?.history)?I0.history.slice(0,6):[])).catch(()=>{})},[]);u.useEffect(()=>{F9()},[F9]),u.useEffect(()=>{function I0(w0){if(w0.key==="Escape")w0.preventDefault(),U()}return window.addEventListener("keydown",I0),()=>window.removeEventListener("keydown",I0)},[U]);async function T9(){if(o.handoff){let W9=`/design:handoff ${Q&&Q!==r9?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(W9)}catch{}K0({ok:!0,msg:`Copied: ${W9} — run it in Claude Code.`});return}if(V(o)){K0({ok:!1,msg:"This format needs the render service, which this workspace doesn’t have configured."});return}e(!0),K0(null);let I0=o.temporal?{scale:A}:{};if(o.format==="png"){let C0=Kq.find((W9)=>W9.id===w)||Kq[1];if(C0.kind==="dpi")I0.dpi=C0.value;else I0.scale=C0.value}if(o.format==="mp4"||o.format==="webm")I0.audio=p;if(a9)I0.maxFrames=s0;if(o.format==="pdf"){I0.pdfPrint={includeBleed:I,marks:{crop:C,registration:x}};let C0=J80.find((W9)=>W9.id===d)?.value;if(C0!==void 0)I0.dpi=C0;if(f!=="keep")I0.text=f}if(G)I0.artboardId=G;if(Z?.selector)I0.selection=Z;if(Q&&Q!==r9)I0.canvasFile=Q;if($U.has(o.format)&&a2({exportLane:H,format:o.format,scope:F,artboardId:I0.artboardId})&&typeof K==="function")try{let C0=RO(I0);K0({ok:!0,msg:"Capturing…"});let W9=await K({format:o.format,artboardIds:[I0.artboardId],scale:C0,onProgress:(x9,S9)=>K0({ok:!0,msg:`Capturing ${x9}/${S9}…`})}),H9=await kO(W9,o.format);for(let x9 of H9)UL(x9.name,x9.blob);for(let x9 of H9)await CO({format:o.format,scope:F,filename:x9.name});e(!1),K0({ok:!0,msg:`Saved ${H9.map((x9)=>x9.name).join(", ")} to your downloads.`});return}catch(C0){if(H!=="remote"){K0({ok:!1,msg:`Capture failed: ${C0&&C0.message||C0}`}),e(!1);return}}if(a2({exportLane:H,format:o.format,scope:F})&&o.format==="pptx"&&typeof K==="function")try{K0({ok:!0,msg:"Capturing artboards…"});let C0=Q&&Q!==r9?Y4(Q).replace(/\.[^.]+$/,""):"export",{filename:W9,blob:H9}=await TO({capture:K,name:C0,onProgress:(x9,S9)=>K0({ok:!0,msg:`Capturing ${x9}/${S9}…`}),onAssemble:()=>K0({ok:!0,msg:"Assembling deck…"})});UL(W9,H9),await CO({format:o.format,scope:F,filename:W9}),e(!1),K0({ok:!0,msg:`Saved ${W9} to your downloads.`});return}catch(C0){if(H!=="remote"){K0({ok:!1,msg:`Deck export failed: ${C0&&C0.message||C0}`}),e(!1);return}}if(H==="none"&&$U.has(o.format)){K0({ok:!1,msg:"Without the render service this workspace exports PNG/SVG of the active artboard only — switch Scope to “Active artboard”, or ask your admin to add maude-render."}),e(!1);return}try{let C0=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:o.format,scope:F,options:I0})});if(!C0.ok){K0({ok:!1,msg:await C0.text()||`Export failed (${C0.status})`}),e(!1);return}U()}catch(C0){K0({ok:!1,msg:C0&&C0.message?C0.message:String(C0)}),e(!1)}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(I0)=>{if(I0.target===I0.currentTarget)U()},children:D("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[D("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Export & handoff"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:U,children:z(T8,{name:"x",size:15})})]}),D("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:Q&&Q!==r9?`Format · ${VY(Y4(Q))}`:"Format"}),z("div",{className:"st-fmt-grid",children:Xk.filter((I0)=>!I0.temporal||Y).map((I0)=>D("button",{type:"button","data-testid":`export-format-${I0.id}`,className:"st-fmt"+(I0.id===B?" is-on":""),disabled:V(I0),title:V(I0)?"Needs the render service — not configured on this workspace":void 0,onClick:()=>{N(I0.id),K0(null)},children:[z(T8,{name:I0.icon,size:16}),z("span",{className:"st-fmt-name",children:I0.label}),z("span",{className:"st-fmt-sub",children:I0.sub})]},I0.id))}),H==="none"&&D("div",{className:"st-dialog-note","data-testid":"export-lane-note",children:["PNG and SVG of the active artboard — and the PPTX deck — export right here in your browser; ZIP and AI handoff work too. PDF, video and other multi-artboard exports need the render service, which this workspace doesn't have configured — use the desktop app, or ask your admin to add the ",z("code",{children:" maude-render"})," service (see the self-hosting docs)."]}),!o.handoff&&D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-scope",children:"Scope"}),z("select",{id:"st-export-scope","data-testid":"export-scope",className:"st-select",value:F,onChange:(I0)=>M(I0.target.value),children:q0.map((I0)=>z("option",{value:I0,children:e90[I0]},I0))})]}),!o.handoff&&o.format==="png"&&D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-size",children:"Resolution"}),z("select",{id:"st-export-size",className:"st-select",value:w,onChange:(I0)=>O(I0.target.value),children:Kq.map((I0)=>z("option",{value:I0.id,children:I0.label},I0.id))})]}),!o.handoff&&o.format==="png"&&z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let I0=Kq.find((C0)=>C0.id===w)||Kq[1],w0=I0.kind==="dpi"?I0.value/96:I0.value;return`${I0.label} ≈ ${Math.round(1440*w0)}×${Math.round(900*w0)} for a 1440×900 artboard.`})()}),!o.handoff&&o.temporal&&D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-temporal-size",children:"Resolution"}),z("select",{id:"st-export-temporal-size",className:"st-select",value:A,onChange:(I0)=>E(Number(I0.target.value)),children:OF0.map((I0)=>z("option",{value:I0.value,children:I0.label},I0.value))})]}),!o.handoff&&o.temporal&&D("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[A,"× the artboard's native resolution (e.g. 960×540 → ",960*A,"×",540*A,")."]}),E9&&D("div",{className:"st-mono st-export-long-notice","data-testid":"export-long-comp-notice",style:{fontSize:11,color:"var(--accent)",lineHeight:1.5},children:["⚠ Long comp: ",s0," frames (≈",Math.round(s0/t0),"s).",a9?` Exceeds the default ${"3600"}-frame export cap — exporting raises the cap to the full length for this run.`:""," ","If the fast renderer falls back to frame-by-frame capture this can take several minutes; 2× resolution (≈720–1080p) is recommended for memory headroom."]}),!o.handoff&&o.format==="pdf"&&D(Q0,{children:[D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-dpi",children:"Image quality"}),z("select",{id:"st-export-pdf-dpi",className:"st-select",value:d,onChange:(I0)=>a(I0.target.value),children:J80.map((I0)=>z("option",{value:I0.id,children:I0.label},I0.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:"The page stays vector; this only sets the capture density for raster content on it (dropped photos, large-format art)."}),D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-text",children:"Text"}),z("select",{id:"st-export-pdf-text",className:"st-select","data-testid":"export-pdf-text",value:f,onChange:(I0)=>h(I0.target.value),children:X80.map((I0)=>z("option",{value:I0.id,children:I0.label},I0.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:X80.find((I0)=>I0.id===f)?.description}),z("div",{className:"st-dialog-row",children:D("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-bleed",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-pdf-bleed",type:"checkbox",checked:I,onChange:(I0)=>k(I0.target.checked)}),"Include bleed"]})}),z("div",{className:"st-dialog-row",children:D("button",{type:"button",className:"st-dialog-lbl",style:{background:"none",border:0,padding:0,cursor:"pointer"},onClick:()=>$((I0)=>!I0),"aria-expanded":R,children:[R?"▾":"▸"," Marks"]})}),R&&D("div",{style:{padding:"0 12px 4px",display:"flex",flexDirection:"column",gap:6},children:[D("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:C,onChange:(I0)=>j(I0.target.checked)}),"Crop marks"]}),D("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:x,onChange:(I0)=>m(I0.target.checked)}),"Registration marks"]})]}),D("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:["Bleed and marks apply to print (",z("code",{children:'kind="print"'}),") artboards only.",F==="canvas-as-separate"?" One PDF page per artboard.":""]})]}),!o.handoff&&(o.format==="mp4"||o.format==="webm")&&z("div",{className:"st-dialog-row",children:D("label",{className:"st-dialog-lbl",htmlFor:"st-export-audio",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-audio",type:"checkbox",checked:p,onChange:(I0)=>v(I0.target.checked)}),"Export with audio"]})}),o.handoff&&D("div",{className:"callout callout--info",style:{fontSize:12},children:["Hands the active canvas off to production. Copies"," ",z("span",{className:"st-mono",children:"/design:handoff <path>"})," — run it in Claude Code to emit a ready-to-drop production component next to the canvas."]}),c&&z("div",{className:"callout "+(c.ok?"callout--success":"callout--error"),style:{fontSize:12},"data-testid":"export-status","data-ok":c.ok?"1":"0",children:c.msg}),s.length>0&&D("div",{className:"st-export-recent","data-testid":"export-recent",children:[z("div",{className:"st-rp-hd",children:"Recent"}),s.map((I0,w0)=>D("div",{className:"st-export-recent-row",children:[D("span",{children:[String(I0.format||"").toUpperCase()," ·"," ",e90[I0.scope]||I0.scope]}),z("span",{className:"st-mono",children:I0.filename})]},w0))]})]}),D("div",{className:"st-dialog-ft",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:U,children:"Cancel"}),D("button",{type:"button",className:"btn btn--primary","data-testid":"export-submit",disabled:r,onClick:T9,children:[z(T8,{name:"download",size:14}),o.handoff?"Copy handoff command":r?"Exporting…":`Export ${o.label}`]})]})]})})}var NL=12,FL=16;function kF0({name:J,depth:X,defaultOpen:Q,children:Y,dirPath:W,drag:G,menu:Z}){let[H,K]=u.useState(Q),U=G?G.dropProps(W,!0,()=>K(!0)):{},V=G?.overDir===W,B=G?G.dragProps(W,!0):{},N=G?.draggedPath===W,F=G?.busyPath===W,M=D("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${Bq(W)}`,"aria-expanded":H,"aria-dropeffect":G?"move":void 0,"aria-busy":F||void 0,tabIndex:-1,className:"st-row"+(V?" is-drop-target":"")+(N?" is-dragging":"")+(F?" is-busy":""),style:{paddingLeft:NL+X*FL+"px"},onClick:()=>K((A)=>!A),onContextMenu:Z?(A)=>Z.openAt(A,{kind:"dir",dirPath:W}):void 0,...B,...U,children:[z("span",{className:"st-row-glyph",children:z(T8,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:J})]});return D(Q0,{children:[Z?D("div",{className:"st-row-wrap",role:"none",children:[M,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${Bq(W)}`,title:`Folder actions — ${J}`,"aria-label":`Folder actions for ${J}`,"aria-haspopup":"menu",onClick:(A)=>Z.openAt(A,{kind:"dir",dirPath:W}),children:z(KL,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})})]}):M,H&&Y]})}function RF0({name:J,dsName:X,depth:Q,defaultOpen:Y,active:W,onOpenSystem:G,children:Z}){let[H,K]=u.useState(Y);return D(Q0,{children:[D("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:NL+Q*FL+"px"},role:"treeitem","aria-expanded":H,children:[z("button",{type:"button",className:"st-ds-chev",onClick:()=>K((U)=>!U),"aria-label":H?"Collapse design system":"Expand design system",title:H?"Collapse":"Expand",children:z(T8,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),D("button",{type:"button",className:"st-ds-open",onClick:()=>G(X),"aria-label":`Open ${X} design system view`,title:"Open the design system view",children:[z("span",{className:"st-row-glyph",children:z(T8,{name:"folder",size:13})}),z("span",{className:"st-row-name",children:J})]})]}),H&&Z]})}function VL({file:J,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,onDelete:G,openCount:Z,depth:H,kind:K,sidecar:U,dirty:V,experimentalKind:B,drag:N,menu:F}){let M=J.path===X||J.path===Q,A=yQ.test(J.name),E=!A&&K!=="runtime"?BL(J.name):null,w=!A&&!E,O=A?VY(J.name):J.name,I=A&&typeof G==="function"&&K!=="runtime",k=A&&!U&&K!=="runtime"&&typeof N<"u",R=k?N.dragProps(J.path,!0):{},$=N?.draggedPath===J.path,C=N?.busyPath===J.path,j=k&&typeof F<"u",x=!A&&!!E&&!U&&typeof F<"u",m=typeof F<"u"&&K!=="runtime",d=J.path.split("/").slice(0,-1).join("/"),a=A?"canvas-row-"+J.path.replace(/^\.[^/]+\//,"").replace(yQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,f=D("button",{type:"button",role:"treeitem","data-testid":a??(x?`file-row-${Bq(J.path)}`:void 0),"aria-selected":M,"aria-disabled":w?"true":void 0,"aria-busy":C||void 0,tabIndex:M?0:-1,className:"st-row"+(M?" is-sel":"")+(K==="runtime"?" is-muted":"")+($?" is-dragging":"")+(C?" is-busy":""),style:{paddingLeft:NL+H*FL+"px"},title:J.path+(Z?` — ${Z} open`:w?" (file index only)":""),onClick:()=>{if(A)Y(J.path);else if(E)W?.(J.path)},onContextMenu:m?(h)=>F.openAt(h,{kind:"file",path:J.path,dir:d,canMove:j||x,supporting:x,name:J.name}):void 0,...R,children:[z("span",{className:"st-row-glyph",children:z(T8,{name:"file",size:13})}),z("span",{className:"st-row-name",children:O}),B==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),B==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),V&&z("span",{className:"st-git-badge","data-kind":V,title:`Unsaved (${V})`,"aria-label":`Unsaved, ${V}`,children:V}),Z>0&&z("span",{className:"st-row-badge",children:Z})]});if(!I&&!m)return f;return D("div",{className:"st-row-wrap",role:"none",children:[f,m&&z("button",{type:"button",className:"st-row-menu-btn"+(I?" has-delete-sibling":""),"data-testid":`tree-row-menu-${Bq(J.path)}`,title:`Actions for ${O}`,"aria-label":`Actions for ${O}`,"aria-haspopup":"menu",onClick:(h)=>F.openAt(h,{kind:"file",path:J.path,dir:d,canMove:j||x,supporting:x,name:J.name}),children:z(KL,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})}),I&&z("button",{type:"button",className:"st-row-del",title:`Delete ${O}`,"aria-label":`Delete canvas ${O}`,onClick:(h)=>{h.stopPropagation(),G(J.path,O)},children:z(KL,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})}function CF0({primary:J,sidecars:X,depth:Q,kind:Y,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,showHidden:V,forceOpen:B,dirtyByPath:N,experimentalKind:F,drag:M,menu:A}){let E=N?.get(J.path),w=X.length>0,[O,I]=u.useState(!1),k=B||O,R=J.path===W;if(!(w&&V))return z(VL,{file:J,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,depth:Q,kind:Y,dirty:E,experimentalKind:F,drag:M,menu:A});let C=typeof M<"u",j=C?M.dragProps(J.path,!0):{},x=M?.draggedPath===J.path,m=M?.busyPath===J.path,d=C&&typeof A<"u",a=typeof A<"u"&&Y!=="runtime",f=J.path.split("/").slice(0,-1).join("/"),h=D("button",{type:"button",role:"treeitem","aria-selected":R,"aria-expanded":k,"aria-busy":m||void 0,tabIndex:R?0:-1,className:"st-row st-canvas-row"+(R?" is-sel":"")+(x?" is-dragging":"")+(m?" is-busy":""),style:{paddingLeft:NL+Q*FL+"px"},title:J.path,onClick:(p)=>{if(p.target.closest(".st-canvas-chev")){I((v)=>!v);return}Z(J.path)},onContextMenu:a?(p)=>A.openAt(p,{kind:"file",path:J.path,dir:f,canMove:d}):void 0,...j,children:[z("span",{className:"st-row-glyph st-canvas-chev",onClick:(p)=>{p.stopPropagation(),I((v)=>!v)},children:z(T8,{name:"chevron-right",className:"st-chev"+(k?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:VY(J.name)}),F==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),F==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),E&&z("span",{className:"st-git-badge","data-kind":E,title:`Unsaved (${E})`,"aria-label":`Unsaved, ${E}`,children:E}),U>0&&z("span",{className:"st-row-badge",children:U})]});return D(Q0,{children:[a?D("div",{className:"st-row-wrap",role:"none",children:[h,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${Bq(J.path)}`,title:`Actions for ${VY(J.name)}`,"aria-label":`Actions for ${VY(J.name)}`,"aria-haspopup":"menu",onClick:(p)=>A.openAt(p,{kind:"file",path:J.path,dir:f,canMove:d}),children:z(KL,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})})]}):h,k&&X.map((p)=>z(VL,{file:p,menu:A,activePath:W,previewPath:G,onOpen:Z,onPreview:H,openCount:0,depth:Q+1,kind:Y,sidecar:!0},p.path))]})}function _80({node:J,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z=1,kind:H,showHidden:K,search:U,dsFolders:V,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:M,canvasKinds:A,dirPath:E="",drag:w,menu:O}){let I=Object.keys(J).filter((d)=>d!=="_files").sort(),k=J._files||[],{canvases:R,orphans:$}=u.useMemo(()=>BF0(k),[k]),{mediaOrphans:C,metaOrphans:j}=u.useMemo(()=>{let d=[],a=[];for(let f of $){let h=BL(f.primary.name);(h==="image"||h==="video"||h==="audio"||h==="font"?d:a).push(f)}return{mediaOrphans:d,metaOrphans:a}},[$]),x=!!(U&&U.trim()),m=u.useMemo(()=>{if(!V||Z!==1)return null;let d=new Map;for(let a of V)d.set(a.folder,a);return d},[V,Z]);return D(Q0,{children:[R.map((d)=>{let a=x&&d.sidecars.some((f)=>{let h=U.toLowerCase();return f.name.toLowerCase().includes(h)||f.path.toLowerCase().includes(h)});return z(CF0,{primary:d.primary,sidecars:d.sidecars,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,onDelete:F,openCount:HL(G[d.primary.path]),depth:Z,kind:H,showHidden:K,forceOpen:a,dirtyByPath:M,experimentalKind:A?.[d.primary.path],drag:w,menu:O},d.primary.path)}),C.map((d)=>z(VL,{file:d.primary,menu:O,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,openCount:HL(G[d.primary.path]),depth:Z,kind:H},d.primary.path)),K&&j.map((d)=>z(VL,{file:d.primary,menu:O,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,openCount:HL(G[d.primary.path]),depth:Z,kind:H},d.primary.path)),I.map((d)=>{let a=m?.get(d),f=E?`${E}/${d}`:d,h=z(_80,{node:J[d],activePath:X,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z+1,kind:H,showHidden:K,search:U,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:M,canvasKinds:A,dirPath:f,drag:w,menu:O});if(a&&N)return z(RF0,{name:d,dsName:a.name,depth:Z,defaultOpen:!0,active:X===r9&&a.name===B,onOpenSystem:N,children:h},d);return z(kF0,{name:d,depth:Z,defaultOpen:!0,dirPath:f,drag:w,menu:w?O:void 0,children:h},d)})]})}var WL={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function $F0(J){if(J.kind==="project")return WL.project;if(J.kind==="runtime")return WL.runtime;if(J.label==="Design system")return WL.ds;if(J.label==="UI kit")return WL.canvas;return{title:J.label.toUpperCase(),pillFromCount:!0}}function SF0({readOnly:J=!1,cloud:X,groups:Q,activePath:Y,previewPath:W,activeDsName:G,onOpen:Z,onPreview:H,onOpenSystem:K,wsConnected:U,search:V,setSearch:B,commentsByFile:N,showHidden:F,sectionsExpanded:M,onToggleSection:A,onNewBoard:E,onDeleteBoard:w,onRefresh:O,refreshing:I,collapsed:k,onCollapse:R,width:$,resizing:C,dirtyByPath:j,project:x,gitBranch:m,remoteSync:d,onGetLatest:a,canvasKinds:f,onMoveCanvas:h,onNewFolder:p,onDeleteFolder:v,onRenameFolder:r,onRenameCanvas:e,onDuplicateCanvas:c,onDeleteFile:K0,syncStatus:s,onLinkedHub:z0,onLocalProject:o,onOpenLinkedFile:q0,filesReady:Z0,onShare:k0,savingIsManaged:a0=!1}){let s0=u.useMemo(()=>{if(!V)return Q;return Q.map((b0)=>({...b0,tree:O80(b0.tree,V),filtered:!!V}))},[Q,V]),t0=ub(h),E9=gb(),a9=u.useMemo(()=>{let b0=[];for(let X9 of Q){if(X9.label==="Design system"||X9.kind!=="canvas")continue;let q9=X9.fullPath.replace(/^\.[^/]+\//,"")||X9.fullPath;b0.push({path:X9.fullPath,label:q9});for(let l0 of X9.dirs||[])b0.push({path:l0,label:l0.replace(/^\.[^/]+\//,"")})}return b0},[Q]),F9=E9.state?.extra,T9=F9?.kind==="file"?[{id:"share",label:"Share…",onSelect:()=>{E9.close(),k0(F9.path)}},...e&&/\.tsx$/i.test(F9.path)?[{id:"rename-canvas",label:"Rename…",onSelect:()=>{E9.close();let b0=VY(F9.path.split("/").pop()),X9=window.prompt("Rename canvas to:",b0);if(X9?.trim()&&X9.trim()!==b0)e(F9.path,X9.trim())}}]:[],...c&&/\.tsx$/i.test(F9.path)?[{id:"duplicate-canvas",label:"Duplicate",onSelect:()=>{E9.close(),c(F9.path)}}]:[],...F9.supporting&&e?[{id:"rename-file",label:"Rename…",onSelect:()=>{E9.close();let b0=F9.name??F9.path.split("/").pop(),X9=b0.includes(".")?b0.slice(b0.lastIndexOf(".")):"",q9=X9?b0.slice(0,-X9.length):b0,l0=window.prompt(`Rename ${b0} to:`,q9);if(l0?.trim()&&l0.trim()!==q9)e(F9.path,l0.trim())}}]:[],...F9.canMove?[{id:"move-to",label:"Move to…",onSelect:()=>E9.showMoveTo()}]:[],...F9.supporting&&K0?[{id:"delete-file",label:"Delete",destructive:!0,onSelect:()=>{E9.close(),K0(F9.path,F9.name??F9.path.split("/").pop())}}]:[]]:F9?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{E9.close();let b0=window.prompt("New folder name:");if(b0?.trim())p(F9.dirPath,b0.trim())}},{id:"rename-folder",label:"Rename folder",onSelect:()=>{E9.close();let b0=F9.dirPath.split("/").pop(),X9=window.prompt("Rename folder to:",b0);if(X9?.trim()&&X9.trim()!==b0)r(F9.dirPath,X9.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{E9.close(),v(F9.dirPath,F9.dirPath.split("/").pop())}}]:[],I0=F9?.kind==="file"||F9?.kind==="supporting"?a9.filter((b0)=>b0.path!==F9.dir):[],[w0,C0]=u.useState(!1),[W9,H9]=u.useState("board"),[x9,S9]=u.useState(""),[O8,v0]=u.useState(""),[$9,w8]=u.useState(!1),L9=u.useMemo(()=>Q.find((b0)=>b0.kind==="canvas"&&b0.label!=="Design system")?.fullPath,[Q]),V0=u.useCallback(async()=>{let b0=x9.trim();if(!b0||$9)return;if(w8(!0),v0(""),W9==="folder"){if(!L9){w8(!1),v0("no canvas group to create a folder in");return}let q9=await p(L9,b0);if(w8(!1),q9?.ok)C0(!1),S9("");else v0(q9?.error||"could not create folder");return}let X9=await E(b0);if(w8(!1),X9?.ok)C0(!1),S9("");else v0(X9?.error||"could not create board")},[x9,$9,E,p,W9,L9]),J9=u.useMemo(()=>{let b0=0;for(let X9 of Q)for(let q9 of X9.paths||[])if(yQ.test(q9))b0++;return b0},[Q]),r0=u.useMemo(()=>{let b0=0;for(let X9 of s0)for(let q9 of X9.paths||[])if(yQ.test(q9))b0++;return b0},[s0]);return D("nav",{className:"st-sidebar"+(k?" is-collapsed":"")+(C?" is-resizing":""),style:k||!$?void 0:{width:$,flexBasis:$},"aria-label":"Files","data-tour":"sidebar",children:[D("div",{className:"st-sb-hd",children:[z("span",{className:"st-sb-title",children:"Files"}),D("div",{className:"st-sb-hd-actions",children:[!J&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":w0&&W9==="board",onClick:()=>{v0(""),H9("board"),C0((b0)=>W9==="board"?!b0:!0)},children:z(T8,{name:"plus",size:15})}),!J&&L9&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":w0&&W9==="folder",onClick:()=>{v0(""),H9("folder"),C0((b0)=>W9==="folder"?!b0:!0)},children:z(T8,{name:"folder-plus",size:15})}),O&&z("button",{type:"button",className:"st-iconbtn st-refresh"+(I?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":I||void 0,disabled:I,onClick:()=>O(),children:z(T8,{name:"reload",size:15})}),D("span",{className:"st-live","data-tip":U?"live · file index synced":"reconnecting…",children:[z("span",{className:"st-live-dot"+(U?" is-connected":""),"aria-hidden":"true"}),r0," / ",J9]}),R&&z("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:R,children:z(T8,{name:"panel-left",size:15})})]})]}),w0?D("div",{className:"st-newboard",children:[z("input",{type:"text",autoFocus:!0,placeholder:W9==="folder"?"folder name…":"brief board name…",value:x9,maxLength:60,disabled:$9,"aria-label":W9==="folder"?"New folder name":"New brief board name",onChange:(b0)=>S9(b0.target.value),onKeyDown:(b0)=>{if(b0.key==="Enter")b0.preventDefault(),V0();else if(b0.key==="Escape")b0.preventDefault(),C0(!1),S9(""),v0("")}}),z("button",{type:"button",className:"st-newboard-go",disabled:$9||!x9.trim(),"data-tip":"Create · Enter","aria-label":W9==="folder"?"Create folder":"Create brief board",onClick:V0,children:$9?"…":"↵"})]}):null,O8?z("div",{className:"st-newboard-err",role:"alert",children:O8}):null,z("div",{className:"st-search",children:D("div",{className:"st-search-box",children:[z(T8,{name:"search",size:13}),z("input",{type:"search","data-testid":"canvas-search",placeholder:"Search canvases…",value:V,onChange:(b0)=>B(b0.target.value),onKeyDown:(b0)=>{if(b0.key==="Escape")if(b0.preventDefault(),V)B("");else b0.currentTarget.blur()},"aria-label":"Filter files"}),V?z("button",{className:"st-search-clear",onClick:()=>B(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):z(CJ,{children:"/"})]})}),z("div",{className:"st-tree",role:"tree","aria-label":"Project file tree","data-testid":"canvas-list",children:s0.map((b0)=>{if(!F&&!V&&b0.kind==="runtime")return null;let X9=$F0(b0),q9=(b0.paths||[]).filter((e0)=>yQ.test(e0)).length,l0=X9.pill||(X9.pillFromDsCount?String(b0.dsFolders?.length||0):null)||(X9.pillFromCount?String(q9||b0.paths?.length||0):null),d0=b0.tree&&Object.keys(b0.tree).length>0,h0=b0.label==="Design system",y0=b0.kind==="project";if(!F&&!V&&y0&&q9===0)return null;let B9=VF0(b0),D9=M[b0.label],N0=!!V||(D9===void 0?B9:D9),o0=!h0&&b0.kind==="canvas"&&!J,h9=o0?t0.dropProps(b0.fullPath,!0):{},g9=t0.overDir===b0.fullPath;return D("div",{className:"st-tree-section",children:[D("button",{type:"button",className:"st-tree-sec-hd"+(g9?" is-drop-target":""),"data-testid":`tree-section-${b0.label.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,onClick:()=>A(b0.label,B9),"aria-expanded":N0,"aria-dropeffect":o0?"move":void 0,title:N0?"Collapse section":"Expand section",...h9,children:[z(T8,{name:"chevron-right",className:"st-chev"+(N0?" is-open":""),size:13}),z("span",{className:"st-sec-name",children:X9.title}),l0&&z("span",{className:"st-pill",children:l0})]}),N0&&(d0?z(_80,{node:b0.tree,activePath:Y,previewPath:W,onOpen:Z,onPreview:H,commentsByFile:N,depth:1,kind:b0.kind,showHidden:F,search:V,dsFolders:b0.dsFolders,activeDsName:G,onOpenSystem:h0?K:void 0,onDelete:h0||J?void 0:w,dirtyByPath:j,canvasKinds:f,dirPath:b0.fullPath,drag:!h0&&b0.kind==="canvas"&&!J?t0:void 0,menu:E9}):z("div",{className:"st-tree-empty",children:V?"No matches.":"Empty."}))]},b0.label)})}),z(mb,{state:E9.state,onClose:E9.close,rootItems:T9,destinations:I0,onPickDestination:(b0)=>h(F9.path,b0)}),z(YE,{project:x,liveBranch:m,remoteSync:d,onGetLatest:a,projectOnly:a0}),X===null?z(ww,{syncStatus:s,onLinkedHub:z0,onLocalProject:o,onOpenFile:q0,filesReady:Z0}):null,z(kw,{})]})}function bF0({shown:J,onExpand:X,onSearch:Q}){return z("div",{className:"st-rail"+(J?" is-shown":""),children:D("div",{className:"st-rail-inner",children:[z("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:X,children:z(T8,{name:"panel-left",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:z(T8,{name:"search",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:X,children:z(T8,{name:"folder",size:15})})]})})}function yF0({open:J,onClose:X,onStartTour:Q}){if(u.useEffect(()=>{if(!J)return;function Y(W){if(W.key==="Escape")X()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[J,X]),!J)return null;return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)X()},children:D("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[D("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),D("span",{className:"sku",children:["MAUDE-DEV-SRV / v",Gk]}),Q&&z("button",{type:"button",className:"mdcc-tour__back",style:{marginLeft:"auto"},onClick:Q,children:"▶ Take the tour"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:X,children:"×"})]}),D("div",{className:"help-modal-body",children:[D("details",{open:!0,children:[z("summary",{children:"Canvas selection & tools"}),D("ul",{children:[D("li",{children:[z("kbd",{children:"V"})," ",z("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),D("li",{children:[z("kbd",{children:"H"})," ",z("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),D("li",{children:[z("kbd",{children:"C"})," ",z("span",{children:"comment tool — hover paints, click drops a pin"})]}),D("li",{children:[z("kbd",{children:"⌘"})," + hover ",z("span",{children:"preview deepest element under cursor"})]}),D("li",{children:[z("kbd",{children:"⌘"})," + click ",z("span",{children:"select that element (replace)"})]}),D("li",{children:[z("kbd",{children:"⌘⇧"})," + click ",z("span",{children:"add deepest to selection (multi)"})]}),D("li",{children:["right-click ",z("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),D("li",{children:[z("kbd",{children:"Esc"})," in canvas ",z("span",{children:"clear selection + close menu"})]})]})]}),D("details",{children:[z("summary",{children:"Annotation tools"}),D("ul",{children:[D("li",{children:[z("kbd",{children:"B"})," ",z("span",{children:"pen — freehand stroke"})]}),D("li",{children:[z("kbd",{children:"R"})," ",z("span",{children:"rectangle — drag to define corners"})]}),D("li",{children:[z("kbd",{children:"O"})," ",z("span",{children:"ellipse — drag from center outward"})]}),D("li",{children:[z("kbd",{children:"A"})," ",z("span",{children:"arrow — drag tail → tip"})]}),D("li",{children:[z("kbd",{children:"E"})," ",z("span",{children:"eraser — click or drag over strokes to remove"})]}),D("li",{children:[z("kbd",{children:"V"})," + click stroke ",z("span",{children:"select annotation (Shift+click to multi)"})]}),D("li",{children:[z("kbd",{children:"V"})," + drag empty ",z("span",{children:"marquee-select strokes that overlap"})]}),D("li",{children:["double-click rect/ellipse ",z("span",{children:"add text inside the shape"})]}),D("li",{children:["arrow keys ",z("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),D("li",{children:[z("kbd",{children:"Backspace"})," ",z("span",{children:"delete selected annotations"})]}),D("li",{children:[z("kbd",{children:"⇧P"})," ",z("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),D("details",{children:[z("summary",{children:"Canvas & panels"}),D("ul",{children:[D("li",{children:["click in tree ",z("span",{children:"open canvas (replaces the active one)"})]}),D("li",{children:["File ▸ Close canvas ",z("span",{children:"clear the stage"})]}),D("li",{children:[z("kbd",{children:"⌘R"})," ",z("span",{children:"reload canvas"})]}),D("li",{children:[z("kbd",{children:"/"})," ",z("span",{children:"focus search"})]}),D("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"comments panel"})]}),D("li",{children:[z("kbd",{children:"⌘⇧I"})," ",z("span",{children:"inspector"})]}),D("li",{children:[z("kbd",{children:"?"})," ",z("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),D("details",{children:[z("summary",{children:"Slash commands"}),D("ul",{className:"cmds",children:[D("li",{children:[D("code",{children:['/design:edit "',z("i",{children:"feedback"}),'"']}),z("span",{children:"edit + 4-iter multi-axis loop"})]}),D("li",{children:[D("code",{children:['/design:edit "',z("i",{children:"…"}),'" --perfect']}),z("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),D("li",{children:[D("code",{children:['/design:edit "',z("i",{children:"…"}),'" --no-critic']}),z("span",{children:"raw edit, skip loop"})]}),D("li",{children:[D("code",{children:['/design:edit "',z("i",{children:"…"}),'" --opt-out=',z("i",{children:"scope"})]}),z("span",{children:"override DS scope (palette/aesthetic/full)"})]}),D("li",{children:[D("code",{children:['/design:new "',z("i",{children:"Name"}),'" "',z("i",{children:"brief"}),'"']}),z("span",{children:"scaffold canvas"})]}),D("li",{children:[D("code",{children:['/design:new "',z("i",{children:"…"}),'" --opt-out=aesthetic']}),z("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),D("li",{children:[z("code",{children:"/design:critic"}),z("span",{children:"review panel (routed)"})]}),D("li",{children:[z("code",{children:"/design:critic --all"}),z("span",{children:"10-critic sweep"})]}),D("li",{children:[z("code",{children:"/design:critic --agent signature-moment-critic"}),z("span",{children:"aspiration axis only"})]}),D("li",{children:[z("code",{children:"/design:rollback"}),z("span",{children:"undo last edit"})]}),D("li",{children:[z("code",{children:"/design:screenshot"}),z("span",{children:"capture canvas"})]}),D("li",{children:[z("code",{children:"/design:setup-docs"}),z("span",{children:"refresh README + INDEX"})]}),D("li",{children:[z("code",{children:"/design:handoff"}),z("span",{children:"migrate to apps/"})]})]})]}),D("details",{children:[z("summary",{children:"Opt-out scope"}),D("ul",{children:[D("li",{children:[z("strong",{children:"palette"})," ",z("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),D("li",{children:[z("strong",{children:"aesthetic"})," ",z("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),D("li",{children:[z("strong",{children:"full"})," ",z("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),D("li",{children:[z("em",{children:"A11y enforced at every scope"})," ",z("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),D("li",{children:["Persisted on canvas's ",z("code",{children:".meta.json"})," ",z("code",{children:"opt_out_scope"})," field — subsequent ",z("code",{children:"/design:edit"})," iterations inherit."]}),z("li",{children:'Inferred from brief ("modern", "vibrant", "off-system") with one-shot AskUserQuestion before iter-1 critics fire.'})]})]}),D("details",{children:[z("summary",{children:"Auto-critic loop"}),D("ul",{children:[D("li",{children:[z("strong",{children:"Default"})," ",z("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),D("li",{children:[z("strong",{children:"--perfect"})," ",z("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),D("li",{children:[z("strong",{children:"--perfect --all"})," ",z("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),D("li",{children:["Exit: ",z("code",{children:"solid"})," · ",z("code",{children:"stable-but-bland"})," · ",z("code",{children:"max-reached"})," ","· ",z("code",{children:"divergent"})]}),D("li",{children:[z("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),D("li",{children:["When ",z("code",{children:"opt_out_scope ∈ {aesthetic, full}"}),": iter-1 checkpoint fires — pick (a) run loop, (b) skip auto-loop and review iter 1, (c) a11y-only check."]})]})]}),D("details",{children:[z("summary",{children:"Pin-to-element flow"}),D("ol",{children:[z("li",{children:"Open a canvas"}),D("li",{children:[z("kbd",{children:"⌘"}),"+click element"]}),z("li",{children:"Status bar shows ● selector"}),D("li",{children:["Run"," ",D("code",{children:['/design:edit "',z("i",{children:"change just this"}),'"']})]}),D("li",{children:["Reload iframe (",z("kbd",{children:"⌘R"}),")"]})]})]}),D("details",{children:[z("summary",{children:"Comments"}),D("ol",{children:[D("li",{children:[z("kbd",{children:"⌘"}),"+click element, then ",z("kbd",{children:"⌘C"})," ",z("span",{children:"or ⌘⇧+click"})]}),z("li",{children:"Numbered pin appears on canvas"}),D("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"opens panel — All / Open / Resolved"})]}),D("li",{children:["Click row in panel ",z("span",{children:"jumps to that file + pin"})]}),D("li",{children:["Claude reads ",z("code",{children:"_comments/<slug>.json"})," on next ",z("code",{children:"/design"})]})]})]})]})]})})}var Qk=[{id:"canvas",label:"Canvas",items:[{label:"Command palette",kbd:"⌘ K"},{label:"New brief board",kbd:"N"},{label:"Export…",kbd:"⇧ ⌘ E"},{label:"Handoff to production",kbd:"⇧ ⌘ H"},{label:"Reload canvas",kbd:"⌘ R"},{label:"Search files",kbd:"/",alt:"⌘ F"}]},{id:"tools",label:"Tools · canvas focus",items:[{label:"Move · Hand · Comment",kbd:"V",alt:"H / C"},{label:"Pen · Highlighter · Eraser",kbd:"B",alt:"I / E"},{label:"Shape · Arrow",kbd:"R",alt:"A"},{label:"Sticky · Text · Section",kbd:"N",alt:"T / ⇧S"},{label:"Undo / redo",kbd:"⌘ Z",alt:"⇧ ⌘ Z"}]},{id:"selection",label:"Selection & zoom",items:[{label:"Select element",kbd:"⌘ click"},{label:"Add to selection",kbd:"⌘ ⇧ click"},{label:"Preview deepest",kbd:"⌘ hover"},{label:"Deselect · close menu",kbd:"Esc"},{label:"Zoom in / out",kbd:"⌘ +",alt:"⌘ −"},{label:"Fit · actual size",kbd:"⌘ 0",alt:"⌘ 1"}]},{id:"view",label:"View",items:[{label:"Project tree",kbd:"T"},{label:"Design system view",kbd:"S"},{label:"Inspector",kbd:"⌘ ⇧ I"},{label:"Comments sidebar",kbd:"⌘ ⇧ M"},{label:"Annotations",kbd:"⇧ P"},{label:"Hidden files",kbd:"H"},{label:"This cheat sheet · help",kbd:"?",alt:"F1"}]}];function jF0({kbd:J,alt:X}){let Q=(Y,W)=>z("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>z(CJ,{children:G},`${G}-${Z}`))},W);return D("span",{className:"so-combos",children:[Q(J,"main"),X?X.split(" / ").map((Y)=>D(Q0,{children:[z("span",{className:"so-or",children:"/"}),Q(Y,Y)]},Y)):null]})}function vF0({open:J,onClose:X}){if(u.useEffect(()=>{if(!J)return;function Y(W){if(W.key==="Escape")W.preventDefault(),X()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[J,X]),!J)return null;let Q=Qk.reduce((Y,W)=>Y+W.items.length,0);return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)X()},children:D("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[D("div",{className:"so-overlay-hd",children:[z("span",{className:"so-title",children:"Keyboard shortcuts"}),D("span",{className:"so-trigger",children:["press ",z(CJ,{children:"?"})," to open"]})]}),z("div",{className:"so-columns",children:Qk.map((Y)=>D("section",{className:"so-section so-section--"+Y.id,children:[z("h3",{className:"so-section-hd",children:Y.label}),z("dl",{className:"so-list",children:Y.items.map((W)=>D("div",{className:"so-pair",children:[z("dt",{children:W.label}),z("dd",{children:z(jF0,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),D("div",{className:"so-overlay-ft",children:[D("span",{children:["close with ",z(CJ,{children:"Esc"})]}),D("span",{className:"so-count",children:[Q," bindings · ",Qk.length," groups"]})]})]})})}var fF0=["File","Edit","View","Selection","Tools","Help"];function w80(J){u.useEffect(()=>{function X(Y){if(Y.key==="Escape")J()}function Q(Y){if(!Y.target.closest(".st-dropdown, .st-menu"))J()}return window.addEventListener("keydown",X),window.addEventListener("mousedown",Q),()=>{window.removeEventListener("keydown",X),window.removeEventListener("mousedown",Q)}},[J])}function xF0({panels:J,onToggle:X,onClose:Q,onZoom:Y,hasCanvas:W}){return w80(Q),D("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[z("div",{className:"st-dd-hd",children:"Panels"}),J.map((G)=>D("button",{type:"button",role:"menuitem",className:"st-dd-item"+(G.checked?" is-on":""),"aria-disabled":G.disabled?"true":void 0,title:G.hint||void 0,onClick:()=>{if(G.disabled){if(G.href)window.open(G.href,"_blank","noopener,noreferrer"),Q();return}X(G.id),Q()},children:[D("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check",children:G.checked?z(T8,{name:"check",size:13}):null}),z("span",{children:G.label}),G.phase?z("span",{className:"st-dd-phase",children:G.phase}):null]}),G.shortcut?z(CJ,{children:G.shortcut}):null]},G.id)),z("div",{className:"st-dd-sep"}),z("div",{className:"st-dd-hd",children:"Zoom"}),[{op:"in",label:"Zoom In",shortcut:"⌘ +"},{op:"out",label:"Zoom Out",shortcut:"⌘ −"},{op:"fit",label:"Fit to Screen",shortcut:"⌘ 0"},{op:"actual",label:"Actual Size · 100 %",shortcut:"⌘ 1"}].map((G)=>D("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":W?void 0:"true",onClick:()=>{if(!W)return;Y?.(G.op),Q()},children:[D("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:G.label})]}),z(CJ,{children:G.shortcut})]},G.label))]})}function J1({label:J,left:X,header:Q,items:Y,onAction:W,onClose:G}){return w80(G),D("div",{className:"st-dropdown",role:"menu","aria-label":J,style:{left:X},children:[Q?z("div",{className:"st-dd-hd",children:Q}):null,Y.map((Z,H)=>Z.sep?z("div",{className:"st-dd-sep"},"s"+H):D("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":Z.disabled?"true":void 0,onClick:()=>{if(Z.disabled)return;W(Z.id),G()},children:[D("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:Z.label})]}),Z.shortcut?z(CJ,{children:Z.shortcut}):null]},Z.id))]})}function hF0({onAction:J,onClose:X}){return z(J1,{label:"Help",left:320,onAction:J,onClose:X,items:[{id:"shortcuts",label:"Keyboard shortcuts",shortcut:"?"},{id:"help",label:"Help · commands & flows",shortcut:"F1"},{id:"report-bug",label:"Report a bug…"},{sep:!0},{id:"tour",label:"Take the tour"},{id:"watch-intro",label:"Watch the intro"},...G8()?[{id:"collab-tour",label:"How sharing works"}]:[],...G8()?[{id:"quick-setup",label:"Quick setup"}]:[],...G8()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function gF0({onAction:J,onClose:X,readOnly:Q=!1}){return z(J1,{label:"Selection",left:214,onAction:J,onClose:X,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},...Q?[]:[{id:"select-all-annotations",label:"Select all annotations",shortcut:"⌘ ⇧ A"}]]})}function mF0({onAction:J,onClose:X,readOnly:Q=!1}){let Y=[{id:"browse",label:"Browse (interact)",shortcut:""},{id:"move",label:"Select",shortcut:"V"},{id:"hand",label:"Hand",shortcut:"H"},...Q?[]:[{id:"comment",label:"Comment",shortcut:"C"},{id:"pen",label:"Pen",shortcut:"B"},{id:"rect",label:"Rect",shortcut:"R"},{id:"ellipse",label:"Ellipse",shortcut:"O"},{id:"sticky",label:"Sticky",shortcut:"N"},{id:"arrow",label:"Arrow",shortcut:"A"},{id:"text",label:"Text",shortcut:"T"},{id:"eraser",label:"Eraser",shortcut:"E"}]];return z(J1,{label:"Tools",left:290,header:"Tool palette",onAction:J,onClose:X,items:Y})}function uF0({onAction:J,onClose:X,hasCanvas:Q,hasSharePath:Y,readOnly:W=!1}){return z(J1,{label:"File",left:40,onAction:J,onClose:X,items:W?[{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"share",label:"Share link…",disabled:!Y},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!Q},{id:"close",label:"Close canvas",disabled:!Q}]:[{id:"new",label:"New canvas…",shortcut:"N"},{id:"assemble",label:"Assemble dropped clips → video",disabled:!Q},{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"share",label:"Share link…",disabled:!Y},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"generate",label:"Generate with AI…"},{id:"settings",label:"Settings…",shortcut:"⌘,"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!Q},{id:"close",label:"Close canvas",disabled:!Q}]})}function pF0({onAction:J,onClose:X,hasCanvas:Q,readOnly:Y=!1}){if(Y)return z(J1,{label:"Edit",left:90,onAction:J,onClose:X,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"}]});return z(J1,{label:"Edit",left:90,onAction:J,onClose:X,items:[{id:"undo",label:"Undo",shortcut:"⌘Z"},{id:"redo",label:"Redo",shortcut:"⇧⌘Z"},{sep:!0},{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},{id:"select-all-annotations",label:"Select all annotations",shortcut:"⇧⌘A"},...Q?[{sep:!0},{id:"new-artboard:desktop",label:"New artboard: Desktop"},{id:"new-artboard:laptop",label:"New artboard: Laptop"},{id:"new-artboard:tablet",label:"New artboard: Tablet"},{id:"new-artboard:mobile",label:"New artboard: Mobile"},{id:"new-artboard:print-a4",label:"New artboard: A4 (print)"},{id:"new-artboard:print-letter",label:"New artboard: Letter (print)"}]:[]]})}function lF0({activePath:J,sharePath:X,onShare:Q,project:Y,cloud:W,tabsCount:G,openMenu:Z,setOpenMenu:H,commentsPanelOpen:K,onToggleComments:U,changesOpen:V,changesCount:B,onToggleChanges:N,onOpenSystem:F,sidebarOpen:M,onToggleSidebar:A,showHidden:E,onToggleShowHidden:w,onOpenHelp:O,onOpenShortcuts:I,onReportBug:k,onStartTour:R,onStartCollabTour:$,annotationsVisible:C,onToggleAnnotations:j,minimapVisible:x,onToggleMinimap:m,zoomCtlVisible:d,onToggleZoomCtl:a,presentMode:f,onTogglePresent:h,printGuidesVisible:p,onTogglePrintGuides:v,postToActiveCanvas:r,onOpenWhatsNew:e,onOpenReadiness:c,onOpenQuickSetup:K0,onWatchIntro:s,whatsNewCount:z0,exportCenter:o,artboardCount:q0=0,presence:Z0=null,inspectorOpen:k0,inspectorTab:a0,onToggleInspector:s0,autoOpenInspector:t0,onToggleAutoOpenInspector:E9,onOpenLayers:a9,timelineOpen:F9,onToggleTimeline:T9,hasComps:I0=!1,assistantOpen:w0,onToggleAssistant:C0,assistantBusy:W9,assistantUnseen:H9,onNewCanvas:x9,onAssembleVideo:S9,onOpenExport:O8,onOpenSettings:v0,onOpenGenerate:$9,onReload:w8,onCloseCanvas:L9,onInsertArtboard:V0,readOnly:J9=!1}){let r0=J===r9,b0=r0?"SYSTEM":J?"CANVAS":"IDLE",X9=r0?z("b",{children:"design system"}):J?D(Q0,{children:[J.split("/").slice(0,-1).join("/"),"/",z("b",{children:VY(Y4(J))})]}):z("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),q9=new Set(W?["autoopen"]:["assistant","autoopen"]),l0=[{id:"tree",label:"Project Tree",shortcut:"T",checked:M,disabled:!1},{id:"changes",label:W?"History":B>0?`Changes · ${B} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:V,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:K,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:E,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:k0&&a0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:k0,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!t0,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:I0?"video":void 0,checked:F9,disabled:!1},...G8()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:w0,disabled:!1}]:W?[{id:"assistant",label:"Assistant — in the desktop app",shortcut:"",checked:!1,disabled:!0,href:"https://maude.sh/download",hint:"The agent runs on your own Claude subscription, on your own machine."}]:[],{id:"annotate",label:"Annotations",shortcut:"⇧ P",checked:C,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:x,disabled:!J||r0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:d,disabled:!J||r0},{id:"present",label:"Presentation Mode",shortcut:"",checked:f,disabled:!J||r0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:p,disabled:!J||r0}].filter((y0)=>!J9||!q9.has(y0.id)),d0=["file","edit","view","selection","tools","help"];function h0(y0){if(d0.includes(y0))H(Z===y0?null:y0)}return u.useEffect(()=>{if(!Z||!d0.includes(Z))return;let y0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function B9(D9){let N0=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!N0.length)return;let o0=N0.indexOf(document.activeElement);if(D9.key==="ArrowDown")D9.preventDefault(),N0[(o0+1)%N0.length].focus();else if(D9.key==="ArrowUp")D9.preventDefault(),N0[(o0-1+N0.length)%N0.length].focus();else if(D9.key==="Home")D9.preventDefault(),N0[0].focus();else if(D9.key==="End")D9.preventDefault(),N0[N0.length-1].focus();else if(D9.key==="ArrowRight"||D9.key==="ArrowLeft"){D9.preventDefault();let h9=D9.key==="ArrowRight"?1:-1,g9=d0.indexOf(Z);H(d0[(g9+h9+d0.length)%d0.length])}else if(D9.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",B9),()=>{clearTimeout(y0),window.removeEventListener("keydown",B9)}},[Z,H]),D("header",{className:"st-menubar",role:"menubar","aria-label":"Application menubar","data-testid":"menubar",children:[D("span",{className:"st-brand","data-tour":"brand",children:[z("span",{className:"st-brand-mark",children:z("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),z("span",{className:"st-brand-name",children:"maude"})]}),W?D("span",{className:"st-cloudback","data-testid":"cloud-back",children:[W.dashboardUrl?z("a",{className:"st-cloudback-link",href:W.dashboardUrl,title:"Back to your projects",children:"← Dashboard"}):null,W.projectName?z("span",{className:"st-cloudback-project","data-testid":"cloud-project-name",children:W.projectName}):null]}):null,z("nav",{className:"st-menus","aria-label":"Application menus","data-tour":"menus",children:fF0.map((y0)=>{let B9=y0.toLowerCase(),D9=d0.includes(B9),N0=D9||B9==="help",o0=Z===B9;return z("button",{type:"button",className:"st-menu",role:"menuitem","data-testid":`menu-${B9}`,"data-tour":B9==="help"?"help":void 0,"aria-haspopup":D9?"menu":void 0,"aria-expanded":D9?o0:void 0,onClick:()=>h0(B9),onMouseEnter:()=>{if(Z!==null&&D9)H(B9)},children:y0},B9)})}),Z==="file"&&z(uF0,{readOnly:J9,hasCanvas:!!J,hasSharePath:!!X,onAction:(y0)=>{if(y0==="new")x9?.();else if(y0==="assemble")S9?.();else if(y0==="export")O8?.("export");else if(y0==="share")document.querySelector('[data-testid="menu-file"]')?.focus(),Q?.();else if(y0==="handoff")O8?.("handoff");else if(y0==="generate")$9?.();else if(y0==="settings")v0?.();else if(y0==="reload")w8?.();else if(y0==="close")L9?.()},onClose:()=>H(null)}),Z==="edit"&&z(pF0,{readOnly:J9,hasCanvas:!!J&&!r0,onAction:(y0)=>{if(y0==="undo")r({dgn:"undo"});else if(y0==="redo")r({dgn:"redo"});else if(y0==="deselect-all")r({dgn:"selection-clear"});else if(y0==="select-all-annotations")r({dgn:"annotation-select-all"});else if(y0.startsWith("new-artboard:"))V0?.(y0.slice(13))},onClose:()=>H(null)}),Z==="view"&&z(xF0,{panels:l0,onToggle:(y0)=>{if(y0==="tree")A();else if(y0==="changes")N();else if(y0==="comments")U();else if(y0==="hidden")w();else if(y0==="annotate")j();else if(y0==="inspector")s0();else if(y0==="autoopen")E9?.();else if(y0==="timeline")T9?.();else if(y0==="assistant")C0?.();else if(y0==="layers")a9?.();else if(y0==="minimap")m?.();else if(y0==="zoomctl")a?.();else if(y0==="present")h?.();else if(y0==="print-guides")v?.()},onZoom:(y0)=>r({dgn:"zoom",op:y0}),hasCanvas:!!J&&!r0,onClose:()=>H(null)}),Z==="selection"&&z(gF0,{readOnly:J9,onAction:(y0)=>{if(y0==="deselect-all")r({dgn:"selection-clear"});else if(y0==="select-all-annotations")r({dgn:"annotation-select-all"})},onClose:()=>H(null)}),Z==="tools"&&z(mF0,{readOnly:J9,onAction:(y0)=>r({dgn:"tool-set",tool:y0}),onClose:()=>H(null)}),Z==="help"&&z(hF0,{onAction:(y0)=>{if(y0==="shortcuts")I?.();else if(y0==="help")O?.();else if(y0==="report-bug")k?.();else if(y0==="tour")R?.();else if(y0==="collab-tour")$?.();else if(y0==="quick-setup")K0?.();else if(y0==="readiness")c?.();else if(y0==="whatsnew")e?.();else if(y0==="watch-intro")s?.()},onClose:()=>H(null)}),D("div",{className:"st-mb-right","data-tour":"status",children:[Z0?z("div",{className:"st-presence",children:Z0}):null,J9&&z("span",{className:"st-stamp st-stamp--viewonly","data-testid":"view-only-stamp","data-tip":W?.user?`${W.user} is a viewer on this project — you can browse, comment and export where available. Ask a project owner for edit access, or sign out if that is not the account you meant to use.`:"Your role in this project is viewer — you can browse, comment when available, and export where available. Ask a project owner for edit access.",children:"VIEW ONLY"}),W?.user?D("span",{className:"st-cloudwho","data-testid":"cloud-account",children:[z("span",{className:"st-cloudwho-email",title:W.role?`Signed in as ${W.user} — ${W.role}`:W.user,children:W.user}),z("form",{method:"post",action:"/auth/browser/signout",className:"st-cloudwho-form",children:z("button",{type:"submit",className:"st-cloudwho-out","data-testid":"cloud-signout",title:"Sign out of this project",children:"Sign out"})})]}):null,G8()&&!J9&&z("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":w0?"true":"false","data-busy":W9?"true":"false","data-unseen":H9?"true":"false","aria-label":`Assistant${W9?" — working":H9?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:C0,children:z(T8,{name:"sparkle",size:15})}),z("button",{type:"button",className:"st-mb-icon st-share-btn","data-testid":"share-btn","data-tip":X?"Share link":"Open a canvas to share it","aria-label":"Share link",disabled:!X,onClick:Q,children:z(T8,{name:"share",size:15})}),o&&z(Bm,{center:o}),z("button",{type:"button",className:"st-reportbug","data-testid":"report-bug-toggle","aria-label":"Report a bug","data-tip":"Report a bug",onClick:k,children:z(T8,{name:"bug",size:15})}),z("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":z0>0?"true":"false","aria-label":`What's new${z0>0?` — ${z0} unseen`:""}`,"data-tip":"What's new",onClick:e,children:z(T8,{name:"megaphone",size:15})}),z("span",{className:"st-stamp",children:b0}),z("span",{className:"st-mb-file",title:J||"",children:X9}),z("span",{className:"st-mb-sep"}),D("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[z("span",{className:"st-dot",style:{background:"var(--accent)"}}),q0," ARTBOARDS"]}),z("span",{className:"st-mb-sep"}),z("span",{className:"st-mb-proj",children:Y||"maude"})]})]})}function dF0({tabs:J,activePath:X,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:K,onIframeLoad:U,canvasError:V,canvasReloadNonce:B,onRetryCanvasLoad:N,loadedPath:F,showQuickSetup:M,onStartQuickSetup:A,previewPath:E}){let w=u.useRef(null);u.useEffect(()=>{if(E)w.current?.focus()},[E]);let O=u.useRef(new Map),I=new Set(J.map(($)=>$.path));for(let[$,C]of O.current)if(!I.has(C.path))O.current.delete($);let k=($)=>{let C=EZ($,{...H,canvasToken:void 0}),j=`${$}#${B}|${C}`,x=O.current.get(j);if(!x)x={path:$,src:EZ($,H)},O.current.set(j,x);return x.src},R=V&&V.path===X?"error":X&&X!==r9&&F===X?"ready":K&&K===X?"loading":"idle";return D("div",{className:"viewport st-stage","data-tour":"viewport","data-canvas-state":R,children:[E&&z("div",{ref:w,className:"st-file-preview-overlay",role:"region","aria-label":`Preview: ${$V(Y4(E))}`,tabIndex:0,children:z(Eg,{path:E,kind:BL(Y4(E))})}),J.length===0&&!E&&D("div",{className:"st-empty",children:[D("div",{className:"st-empty-brand",children:[z("span",{className:"st-brand-mark",children:z("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),z("span",{className:"st-empty-wm",children:"maude"}),D("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(Z||"MAUDE").toUpperCase()," / v",Gk," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),z("div",{className:"st-empty-title",children:"Nothing open yet"}),D("div",{className:"st-empty-body",children:["← Pick a screen from the list on the left, or open ",z("strong",{children:"Design system"})," above it to see your colors, type, and components.",z("br",{}),z("br",{}),z("strong",{children:"To select something on the canvas:"})," hold ",z(CJ,{children:"⌘"})," and hover to preview an element, click to select it — ",z(CJ,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",G8()?D(Q0,{children:[z("br",{}),z("br",{}),"Claude can see whatever's selected when you ask for a change in the Assistant panel, so pointing is often faster than describing it."]}):null]}),M&&z("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:A,children:"Start quick setup"})]}),J.map(($)=>{if($.path===r9)return z("div",{className:"system-view"+($.path===X?" active":""),children:z(tF0,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},$.path);return z("iframe",{ref:(C)=>Q($.path,C),src:k($.path),className:$.path===X?"active":"","data-path":$.path,"data-testid":$.path===X?"canvas-frame":void 0,onLoad:()=>U?.($.path),...H?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},`${$.path}#${B}`)}),K&&K===X&&z("div",{className:"st-canvas-loading","aria-hidden":"true",children:D("div",{className:"st-skel-card",children:[z("div",{className:"st-skel-cap st-mono",children:"compiling canvas…"}),z("span",{className:"skel st-skel-thumb"}),z("span",{className:"skel st-skel-line",style:{width:"72%"}}),z("span",{className:"skel st-skel-line",style:{width:"46%"}})]})}),V&&V.path===X&&z("div",{className:"st-canvas-error",role:"alert","data-testid":"canvas-load-error",children:D("div",{className:"st-canvas-error-card",children:[z("div",{className:"st-canvas-error-title",children:V.kind==="server"?"Maude's server isn't responding":"This canvas didn't finish loading"}),z("div",{className:"st-canvas-error-body",children:V.kind==="server"?z(Q0,{children:"The canvas couldn't be reached. This usually means Maude's server restarted underneath this window — your files on disk are untouched."}):D(Q0,{children:["The server is up, but"," ",z("code",{children:$V(Y4(V.path))})," ","never finished compiling. Its own error, if it has one, is in the canvas frame."]})}),z("button",{type:"button",className:"btn btn--primary","data-testid":"canvas-load-retry",onClick:()=>N?.(V.path),children:"Reload canvas"})]})})]})}var cF0=["color","space","radius","shadow","leading","weight","motion","font","other"],iF0={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function oF0(J){return J==="color"}function nF0({tokens:J,tokenGroups:X,tokensPath:Q}){if(!J||J.length===0)return D("section",{className:"sv-section sv-section-tokens",children:[D("h2",{children:["tokens",z("span",{className:"sv-h-num",children:"0"})]}),z("div",{className:"sv-empty",children:D("p",{children:["No tokens parsed from"," ",Q?z("code",{children:Q}):"the configured tokens file",". Does the file exist and contain CSS custom properties (",z("code",{children:"--name: value;"}),")?"]})})]});let Y=X||{},W=Array.from(new Set([...cF0,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return z(Q0,{children:W.map((G)=>{let Z=Y[G],H=oF0(G);return D("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[D("h2",{children:["tokens · ",iF0[G]||G,z("span",{className:"sv-h-num",children:Z.length})]}),z("div",{className:"sv-tokens-ladder",children:Z.map((K)=>D("div",{className:"sv-tok-cell",children:[H?z("div",{className:"sv-tok-swatch",style:{background:K.value}}):null,D("div",{className:"sv-tok-meta",children:[z("code",{className:"sv-tok-name",children:K.name}),z("span",{className:"sv-tok-value",children:K.value||"—"})]})]},K.name+"|"+K.value))})]},G)})})}function rF0(J,X){let Q=J.name.match(/^--(?:type|fs|text)-(.+)$/);if(!Q)return null;let Y=Q[1];return(X||[]).find((W)=>/^--(?:lh|leading|line-height)-/.test(W.name)&&W.name.endsWith("-"+Y))?.value??null}function aF0(J){if(!J?.length)return;let X=["body","sans","display","text","family"];for(let Q of X){let Y=J.find((W)=>W.name.includes(Q));if(Y)return Y.value}return J[0].value}function sF0({tokenGroups:J}){let X=J?.fontsize||[];if(X.length===0)return null;let Q=J?.leading||[],Y=aF0(J?.font);return D("section",{className:"sv-section sv-section-type",children:[D("h2",{children:["type · ladder",z("span",{className:"sv-h-num",children:X.length})]}),z("div",{className:"sv-type-list",children:X.map((W)=>{let G=rF0(W,Q),Z={fontSize:W.value};if(G)Z.lineHeight=G;if(Y)Z.fontFamily=Y;return D("div",{className:"sv-type-row",children:[z("code",{className:"sv-type-tok",children:W.name}),z("span",{className:"sv-type-sample",style:Z,children:"The catalog is the system."})]},W.name)})})]})}function tF0({data:J,onOpen:X,cfg:Q,onSelectDs:Y}){if(!J)return z("div",{className:"sv-empty",children:z("p",{children:"Loading design system…"})});let{previewGallery:W,uiKitsGallery:G,systemDir:Z,tokens:H,tokenGroups:K,tokensPath:U,ds:V,availableDesignSystems:B}=J,N=(!W||!W.length)&&(!G||!G.length),F=Array.isArray(B)&&B.length>1,M=V?.name??B?.[0]?.name??"";return D("div",{className:"sv",children:[D("header",{className:"sv-header",children:[z("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),z("span",{className:"sv-title",children:"design system view"}),F?D("label",{className:"sv-ds-picker",children:[z("span",{className:"sv-ds-picker-label",children:"DS"}),z("select",{value:M,onChange:(A)=>Y&&Y(A.target.value),children:B.map((A)=>z("option",{value:A.name,children:A.name},A.name))})]}):null,z("span",{className:"sv-loc",children:z("code",{children:Z})})]}),V?.description?z("p",{className:"sv-ds-description",children:V.description}):null,z(nF0,{tokens:H,tokenGroups:K,tokensPath:U}),z(sF0,{tokenGroups:K}),N?z("div",{className:"sv-empty",children:D("p",{children:["No ",z("code",{children:"preview/"})," or ",z("code",{children:"ui_kits/"})," folders found under"," ",z("code",{children:Z}),"."]})}):D(Q0,{children:[z(Q80,{title:"preview",items:W,onOpen:X,kind:"preview",cfg:Q}),z(Q80,{title:"ui kits",items:G,onOpen:X,kind:"ui_kits",cfg:Q})]})]})}function Q80({title:J,items:X,onOpen:Q,kind:Y,cfg:W}){if(!X||X.length===0)return null;return D("section",{className:"sv-section",children:[D("h2",{children:[J," ",z("span",{className:"sv-count",children:X.length})]}),z("div",{className:"sv-previews sv-previews-"+Y,children:X.map((G)=>D("article",{className:"sv-preview-card",onClick:()=>Q(G.path),children:[z("div",{className:"sv-preview-frame",children:z("iframe",{src:EZ(G.path,W,{thumbnail:!0}),title:G.label,scrolling:"no",...W?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),D("div",{className:"sv-preview-foot",children:[z("strong",{children:G.label}),z("code",{children:G.path})]})]},G.path))})]})}function eF0({activePath:J,selected:X,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,syncProject:K,syncOpen:U=!1,onOpenSync:V,changesCount:B=0,unpushed:N=0,savingIsManaged:F=!1,changesOpen:M=!1,onOpenChanges:A,version:E}){let w=J===r9,O=X&&X.selector?X.selector+(X.text?` — "${X.text.slice(0,60)}"`:""):"",I=X&&X.dom_path?X.dom_path.join(" > "):X?X.selector:"",k=W==="dark"?"light":"dark",R=(()=>{let C=oz(H,{project:K});if(!C)return null;let j=C.names.length?` (${C.names.join(", ")})`:"";return{online:C.online,label:C.label,title:`${C.title}${j}${C.next?` — ${C.next}`:""}`}})(),$=R&&D(Q0,{children:[z("span",{className:"st-sb-sync-dot"+(R.online?" is-online":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:"hub sync"}),z("span",{className:"val",title:R.title,children:R.label})]});return D("footer",{className:"st-statusbar",role:"contentinfo","data-testid":"statusbar",children:[D("span",{className:"st-sb-slot st-sb-active",role:"group","aria-label":"Active file",children:[z("span",{className:"lead","aria-hidden":"true"}),z("span",{className:"lbl",children:"active"}),z("span",{className:"val",title:J||"",children:w?"▦ design system":J||"—"})]}),J&&X&&X.selector&&!w&&D("span",{className:"st-sb-slot st-sb-sel",role:"group","aria-label":"Selected element",children:[z("span",{className:"lbl",children:"selected"}),z("span",{className:"val",title:I,children:O}),z("button",{type:"button",className:"st-sb-sel-clear",onClick:Z,"data-tip":"Clear · Esc inside iframe","data-tip-pos":"top","aria-label":"Clear selection",children:"×"})]}),D("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[z("span",{className:"lbl",children:"comments"}),D("span",{className:"val",children:[Y," open"]})]}),A&&D("button",{type:"button",className:"st-sb-slot st-sb-changes"+(M?" is-open":"")+(B>0?" has-changes":N>0?" has-unpushed":""),onClick:A,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":M,children:[z("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),z("span",{className:"lbl",children:"changes"}),z("span",{className:"val",children:F?"cloud saving":B>0?`${B} unsaved`:N>0?`${N} to publish`:"all saved"})]}),z("span",{className:"st-sb-spacer"}),D("span",{className:"st-sb-slot",role:"group","aria-label":"Connection",children:[z("span",{className:"st-live-dot"+(Q?" is-connected":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:Q?"live":"reconnecting"})]}),R&&(V?z("button",{type:"button",className:"st-sb-slot st-sb-sync st-sb-sync--btn"+(U?" is-open":""),onClick:V,"data-testid":"open-sync","data-tip":"Open Sync panel","data-tip-pos":"top","aria-label":"Open Sync panel","aria-pressed":U,children:$}):z("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:$})),E&&z("span",{className:"st-sb-slot st-sb-version",role:"group","aria-label":"Maude version",children:D("span",{className:"val","data-testid":"statusbar-version",children:["v",E]})}),D("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${k} theme`,"data-tip-pos":"top","aria-label":`Switch to ${k} theme`,children:[z(T8,{name:W==="dark"?"sun":"moon",size:13}),k]})]})}function JL0({commentsByFile:J,filter:X,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:K,width:U,resizing:V}){let B=A80(J),N=Object.keys(J||{}).sort(),F=[];for(let M of N){let A=J[M]||[],E=A.filter((O)=>{if(X==="open")return O.status!=="resolved";if(X==="resolved")return O.status==="resolved";return!0});if(E.length===0)continue;let w=A.filter((O)=>O.selector);F.push({file:M,comments:E.map((O)=>({...O,n:w.findIndex((I)=>I.id===O.id)+1}))})}return D("aside",{className:"st-rpanel"+(V?" is-resizing":""),style:U?{width:U,flexBasis:U}:void 0,"aria-label":"Comments",children:[z("div",{className:"st-rp-tabs st-rp-tabs--filters",children:D("div",{className:"st-cm-filters",role:"tablist",children:[D("button",{type:"button",className:"st-cm-filter"+(X==="all"?" is-active":""),role:"tab","data-testid":"comment-filter-all","aria-selected":X==="all",onClick:()=>Q("all"),children:["All · ",B.all]}),D("button",{type:"button",className:"st-cm-filter"+(X==="open"?" is-active":""),role:"tab","data-testid":"comment-filter-open","aria-selected":X==="open",onClick:()=>Q("open"),children:["Open · ",B.open]}),D("button",{type:"button",className:"st-cm-filter"+(X==="resolved"?" is-active":""),role:"tab","data-testid":"comment-filter-resolved","aria-selected":X==="resolved",onClick:()=>Q("resolved"),children:["Resolved · ",B.resolved]})]})}),z("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:F.length===0?D("div",{className:"st-rp-empty",children:[D("p",{children:["No comments ",X!=="all"?`with status “${X}”`:"yet","."]}),D("p",{children:["Open a canvas, hold ",z(CJ,{children:"⌘"})," and click an element, then press ",z(CJ,{children:"C"})," — or hold ",z(CJ,{children:"⌘⇧"})," and click directly."]})]}):F.map((M)=>D(Q0,{children:[D("button",{type:"button",className:"st-cm-group-hd",onClick:()=>G(M.file,null),title:M.file,children:[z("span",{children:VY(Y4(M.file))}),z("span",{className:"st-mono",children:M.comments.length})]}),M.comments.map((A)=>D("div",{"data-testid":`comment-item-${A.id}`,className:"st-comment"+(A.status==="resolved"?" is-resolved":"")+(A.id===W?" is-active":""),onClick:()=>G(M.file,A.id),children:[D("div",{className:"st-comment-hd",children:[z("span",{className:"st-pin st-pin--inline",children:A.n||"·"}),z("span",{className:"st-comment-time",children:FF0(A.created)})]}),z("div",{className:"st-comment-txt",children:A.text}),D("div",{className:"st-comment-foot",children:[z("span",{className:"st-comment-sel",title:(A.dom_path||[]).join(" > "),children:A.selector||"—"}),Z&&H&&K?D("span",{className:"st-mini-act",children:[A.status==="resolved"?z("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(E)=>{E.stopPropagation(),H(A.id)},children:z(T8,{name:"reopen",size:14})}):z("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(E)=>{E.stopPropagation(),Z(A.id)},children:z(T8,{name:"resolve",size:14})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(E)=>{E.stopPropagation(),K(A.id)},children:z(T8,{name:"x",size:14})})]}):null]})]},A.id))]},M.file))})]})}var XL0={owner:"You own this project — edit, invite and export.",member:"You can edit this project, comment and export.",viewer:"You can look at this project, comment and download it, but not change it."};function QL0({cloud:J}){let X=J?.role||null,[Q,Y]=u.useState(!1);if(!X||Q)return null;let W=`maude-cloud-role-seen:${X}`,G=!1;try{G=localStorage.getItem(W)==="1"}catch{}if(G)return null;let Z=XL0[X];if(!Z)return null;return D("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info","data-testid":"cloud-role-banner",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:Z}),z("button",{type:"button",className:"btn btn--ghost btn--sm","data-testid":"cloud-role-banner-dismiss",onClick:()=>{Y(!0);try{localStorage.setItem(W,"1")}catch{}},children:"Got it"})]})}function YL0({update:J,onDismiss:X}){let[Q,Y]=u.useState(!1);if(!J)return null;let W=J.version?` (v${J.version})`:"";return D("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),D("span",{children:["Maude updated",W," · restart to apply"]}),z("button",{type:"button",className:"btn btn--primary btn--sm",disabled:Q,onClick:()=>{Y(!0),Vh().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X,children:"Later"})]})}function WL0({status:J}){let[X,Q]=u.useState(null);if(!J||J.linked===!1)return null;if(J.notSyncable)return null;let{state:Y,queuedOps:W,flash:G,conflicts:Z}=J,H=G==="synced",K=Y==="offline"||Y==="offline-long",U=J.docs?.rejected??0,V=Array.isArray(Z)?[...Z].reverse().find((M)=>M.kind==="cold-start-diverged"):null;if(!K&&!H&&!V&&U===0)return null;let B,N,F;if(H)B="success",N="Synced with hub",F=`${Y}:flash`;else if(K){let M=Z&&Z.length>0?` (${Z.length} conflict notice(s))`:"";if(Y==="offline-long")B="error",N=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${M}`;else B="warn",N=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${M}`;F=`${Y}:offline`}else if(V){if(V.snapshotFailed)B="error",N=`Diverged on ${V.slug}: kept local — the history snapshot FAILED, so the overwrite was refused. Check disk space / .design/_history write access.`;else B="warn",N=`Diverged on ${V.slug}: kept the ${V.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${V.slug}`;F=`diverged:${V.slug}:${V.at}`}else B="warn",N=`${U} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,F=`rejected:${U}`;if(X===F)return null;return D("div",{role:"status","aria-live":"polite",className:`st-banner st-banner--${B}`,children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:N}),z("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(F),children:"×"})]})}var GL0=["block","inline-block","flex","inline-flex","grid","inline","none"],Y80=["px","%","fr","em","auto","min-content","max-content"];var ZL0=["auto","stretch","flex-start","center","flex-end","baseline"];var W80=["300","400","500","600","700","800"],Uq=(J,X)=>J&&Object.hasOwn(J,"previous")?J.previous:X,G80=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],Z80=["none","solid","dashed","dotted","double"],H80=["px","rem","em","%","vw","vh","auto"],z80=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),Yk={"font-size":{node:z(K7,{as:bV,size:12})},"line-height":{node:z(K7,{as:gV,size:12})},"letter-spacing":{node:z(K7,{as:nV,size:12})},gap:{node:z(K7,{as:PK,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:z(K7,{as:eV,size:12})},"border-width":{node:z(K7,{as:oV,size:12})}};var K80=["static","relative","absolute","fixed","sticky"],HL0=["normal","italic","oblique"],U80=["none","uppercase","lowercase","capitalize"];var V80=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],zL0=["fill","contain","cover","none","scale-down"];var q80=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],B80=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],bQ={desktop:{label:"Desktop",width:1440,height:1024},laptop:{label:"Laptop",width:1280,height:800},tablet:{label:"Tablet",width:834,height:1194},mobile:{label:"Mobile",width:390,height:844}},tK=null;function qL(J){if(!J)return"";if(/^#[0-9a-f]{6}$/i.test(J))return J.toLowerCase();try{if(!tK)tK=document.createElement("canvas").getContext("2d");if(!tK)return"";tK.fillStyle="#000000",tK.fillStyle=J;let X=tK.fillStyle;if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();let Q=X.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(Q)return`#${[Q[1],Q[2],Q[3]].map((Y)=>Number(Y).toString(16).padStart(2,"0")).join("")}`}catch{}return""}var UY=(J)=>Math.min(1,Math.max(0,J));function GL(J){let X=/^#?([0-9a-f]{6})$/i.exec(J||"");if(!X)return{r:0,g:0,b:0};let Q=Number.parseInt(X[1],16);return{r:Q>>16&255,g:Q>>8&255,b:Q&255}}function Vq({r:J,g:X,b:Q}){return`#${[J,X,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function qq({r:J,g:X,b:Q}){J/=255,X/=255,Q/=255;let Y=Math.max(J,X,Q),W=Math.min(J,X,Q),G=Y-W,Z=0;if(G){if(Y===J)Z=(X-Q)/G%6;else if(Y===X)Z=(Q-J)/G+2;else Z=(J-X)/G+4;if(Z*=60,Z<0)Z+=360}return{h:Z,s:Y?G/Y:0,v:Y}}function eK({h:J,s:X,v:Q}){let Y=Q*X,W=Y*(1-Math.abs(J/60%2-1)),G=Q-Y,Z=0,H=0,K=0;if(J<60)[Z,H,K]=[Y,W,0];else if(J<120)[Z,H,K]=[W,Y,0];else if(J<180)[Z,H,K]=[0,Y,W];else if(J<240)[Z,H,K]=[0,W,Y];else if(J<300)[Z,H,K]=[W,0,Y];else[Z,H,K]=[Y,0,W];return{r:(Z+G)*255,g:(H+G)*255,b:(K+G)*255}}function U7(J){if(!J)return"";let X=/^(-?\d*\.?\d+)px$/.exec(J);return X?`${Math.round(Number.parseFloat(X[1]))}px`:J}function Q4(J){if(!J)return{n:"",unit:"px"};let X=J.trim(),Q=/^(-?\d*\.?\d+)\s*(px|rem|em|%|vw|vh)?$/.exec(X);if(Q)return{n:Q[1],unit:Q[2]||"px"};if(X==="auto")return{n:"",unit:"auto"};return{n:X,unit:""}}function N80(J,X){if(!J||Array.isArray(J)||Array.isArray(X)||!X)return J;if(!J.id&&!X.id){let Q=(Y)=>typeof Y.selector==="string"&&Y.selector.startsWith("[data-dc-screen=");if(Q(J)&&Q(X)&&J.selector===X.selector&&J.file===X.file)return{...J,authored:J.authored??X.authored,computed:J.computed??X.computed,customStyles:J.customStyles??X.customStyles,attrs:J.attrs??X.attrs,artboardId:J.artboardId??X.artboardId,worldW:J.worldW??X.worldW,worldH:J.worldH??X.worldH};return J}if(!J.id||J.id!==X.id)return J;return{...J,authored:J.authored??X.authored,computed:J.computed??X.computed,customStyles:J.customStyles??X.customStyles,attrs:J.attrs??X.attrs,photoKind:J.photoKind??X.photoKind,photoAsset:J.photoAsset??X.photoAsset}}function E80(J,X){return(J?X?.canvasDesignSystems?.[J]:null)||X?.defaultDesignSystem||X?.designSystems?.[0]?.name||null}function KL0(J){let X={};for(let Z of J.matchAll(/(--[a-z0-9-]+)\s*:\s*([^;}]+)/gi))if(!(Z[1]in X))X[Z[1]]=Z[2].trim();let Q={};for(let Z of Object.keys(X)){let H=X[Z],K=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(H);Q[Z]=K&&X[K[1]]?X[K[1]]:H}let Y=Object.keys(X),W=(Z)=>Y.filter((H)=>Z.test(H)),G=(Z)=>/^(#[0-9a-f]{3,8}|rgba?\(|hsla?\(|oklch\(|oklab\(|lab\(|lch\(|hwb\(|color\()/i.test(Z)||/^(transparent|currentcolor|white|black|red|green|blue|gray|grey|orange|yellow|purple|pink|cyan|magenta|teal|navy|maroon|olive|lime|aqua|silver|gold)$/i.test(Z);return{color:Y.filter((Z)=>G(Q[Z])),space:W(/^--space-/),radius:W(/^--radius-/),type:W(/^--type-/),shadow:W(/^--shadow-/),lh:W(/^--lh-/),vals:Q}}function P80(J,X,Q){let Y=J?.designSystems||[],W=Y.map((H)=>`${H.name}:${H.tokensCssRel}`).join("|"),[G,Z]=u.useState([]);return u.useEffect(()=>{if(!Y.length)return;let H=!1;return Promise.all(Y.map(async(K)=>{if(!K.tokensCssRel)return null;try{let U=await fetch(`/${X}/${K.tokensCssRel}`),V=U.ok?await U.text():"";return{name:K.name,...KL0(V)}}catch{return null}})).then((K)=>{if(H)return;let U=K.filter(Boolean);U.sort((V,B)=>V.name===Q?-1:B.name===Q?1:0),Z(U)}),()=>{H=!0}},[W,X,Q]),G}function I80({seed:J,label:X,onApply:Q}){let[Y,W]=u.useState(()=>qq(GL(J||"#000000"))),G=u.useRef(Y);G.current=Y;let Z=u.useRef(null),H=u.useRef(null),K=u.useRef(J);u.useEffect(()=>{if(J&&J!==K.current)K.current=J,W(qq(GL(J)))},[J]);let U=Vq(eK(Y)),V=(O)=>{O.preventDefault();let I=Z.current?.getBoundingClientRect();if(!I)return;let k=G.current.h,R=(C)=>{W({h:k,s:UY((C.clientX-I.left)/I.width),v:UY(1-(C.clientY-I.top)/I.height)})};R(O);let $=()=>{document.removeEventListener("pointermove",R),document.removeEventListener("pointerup",$),Q(Vq(eK(G.current)))};document.addEventListener("pointermove",R),document.addEventListener("pointerup",$)},B=(O)=>{O.preventDefault();let I=H.current?.getBoundingClientRect();if(!I)return;let{s:k,v:R}=G.current,$=(j)=>{W({h:UY((j.clientX-I.left)/I.width)*360,s:k,v:R})};$(O);let C=()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",C),Q(Vq(eK(G.current)))};document.addEventListener("pointermove",$),document.addEventListener("pointerup",C)},N=(O)=>{let I={...G.current,...O};W(I),Q(Vq(eK(I)))},F=(O)=>{let I=O.shiftKey?0.1:0.02,R={ArrowLeft:[-I,0],ArrowRight:[I,0],ArrowUp:[0,I],ArrowDown:[0,-I]}[O.key];if(!R)return;O.preventDefault(),N({s:UY(G.current.s+R[0]),v:UY(G.current.v+R[1])})},M=(O)=>{let I=O.shiftKey?20:2,R={ArrowLeft:-I,ArrowRight:I}[O.key];if(R==null)return;O.preventDefault(),N({h:Math.min(360,Math.max(0,G.current.h+R))})},A=async()=>{try{let O=window.EyeDropper;if(!O)return;let I=await new O().open();if(I?.sRGBHex)W(qq(GL(I.sRGBHex))),Q(I.sRGBHex)}catch{}},E=eK(Y),w=(O)=>{let I={...E,...O},k=qq({r:UY(I.r/255)*255,g:UY(I.g/255)*255,b:UY(I.b/255)*255});W(k),Q(Vq(eK(k)))};return D("div",{className:"st-cp-cpick",children:[D("div",{className:"st-cp-cpick-hexrow",children:[z("span",{className:"st-cp-cpick-hexsw",style:{background:U}}),z("input",{className:"st-cp-cpick-hex",type:"text",value:U,"aria-label":X?`${X} hex value`:"hex value",onChange:(O)=>{let I=O.target.value;if(/^#?[0-9a-f]{6}$/i.test(I))W(qq(GL(I)))},onKeyDown:(O)=>{if(O.key==="Enter")Q(O.currentTarget.value)},onBlur:(O)=>Q(O.currentTarget.value),onFocus:(O)=>O.currentTarget.select()})]}),D("button",{type:"button",ref:Z,className:"st-cp-cpick-sv","aria-label":X?`${X} saturation and value`:"saturation and value",style:{background:`hsl(${Y.h} 100% 50%)`},onPointerDown:V,onKeyDown:F,children:[z("span",{className:"st-cp-cpick-svwhite"}),z("span",{className:"st-cp-cpick-svblack"}),z("span",{className:"st-cp-cpick-knob",style:{left:`${Y.s*100}%`,top:`${(1-Y.v)*100}%`,background:U}})]}),D("div",{className:"st-cp-cpick-controls",children:[window.EyeDropper?z("button",{type:"button",className:"st-cp-cpick-eye","aria-label":"pick from screen",title:"eyedropper",onClick:A,children:z(T8,{name:"eyedropper",size:14})}):null,z("span",{className:"st-cp-cpick-preview",style:{background:U},"aria-hidden":"true"}),z("button",{type:"button",ref:H,className:"st-cp-cpick-hue","aria-label":X?`${X} hue`:"hue",onPointerDown:B,onKeyDown:M,children:z("span",{className:"st-cp-cpick-huethumb",style:{left:`${Y.h/360*100}%`}})})]}),z("div",{className:"st-cp-cpick-rgb",children:["r","g","b"].map((O)=>D("label",{className:"st-cp-cpick-rgbf",children:[z("input",{"aria-label":O.toUpperCase(),value:Math.round(E[O]),onChange:(I)=>w({[O]:UY((Number.parseFloat(I.target.value)||0)/255)*255}),onFocus:(I)=>I.currentTarget.select()}),z("span",{children:O.toUpperCase()})]},O))})]})}function zL({kind:J,groups:X,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:K}){let[U,V]=u.useState(!1),[B,N]=u.useState(null),[F,M]=u.useState("custom"),[A,E]=u.useState(""),w=u.useRef(null),O=u.useRef(null),I=typeof Q==="string"&&/var\(\s*--/.test(Q),k=(e)=>Q===`var(${e})`,R=(e)=>e.replace(/^--/,"").replace(/-/g," "),$=X||[],C=$.reduce((e,c)=>e+(c.names?.length||0),0),j=$.length>1,x=A.trim().toLowerCase(),m=!x?$:$.map((e)=>({...e,names:(e.names||[]).filter((c)=>R(c).toLowerCase().includes(x)||c.toLowerCase().includes(x)||(e.vals?.[c]||"").toLowerCase().includes(x))})).filter((e)=>e.names.length);u.useEffect(()=>{if(!U){E("");return}let e=()=>{let z0=w.current?.getBoundingClientRect();if(!z0)return;let o=224,q0=300,Z0=Math.min(z0.right-o,window.innerWidth-o-8);if(Z0<8)Z0=8;let a0=window.innerHeight-z0.bottom>q0+8?z0.bottom+4:Math.max(8,z0.top-q0-4);N({left:Z0,top:a0,width:o,maxHeight:q0})};e();let c=(z0)=>{if(O.current?.contains(z0.target)||w.current?.contains(z0.target))return;V(!1)},K0=(z0)=>{if(z0.key==="Escape")V(!1)},s=(z0)=>{if(O.current?.contains(z0.target))return;e()};return document.addEventListener("pointerdown",c,!0),document.addEventListener("keydown",K0),window.addEventListener("resize",e),document.addEventListener("scroll",s,!0),()=>{document.removeEventListener("pointerdown",c,!0),document.removeEventListener("keydown",K0),window.removeEventListener("resize",e),document.removeEventListener("scroll",s,!0)}},[U]),u.useEffect(()=>{if(!U||!B||!O.current)return;let e=O.current.getBoundingClientRect(),c=B.left-e.left,K0=B.top-e.top;if(Math.abs(c)>0.5||Math.abs(K0)>0.5)N((s)=>s?{...s,left:s.left+c,top:s.top+K0}:s)},[U,B]);let d=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,a=(e,c,K0)=>{if(H&&e&&e!==H&&K0&&!d.test(K0))Y(K0);else Y(`var(${c})`);V(!1)},f=(e)=>{let c=(e||"").trim();if(c)Y(c)},h=D("div",{className:"st-cp-pop-search",children:[z(T8,{name:"search",size:12}),z("input",{value:A,onChange:(e)=>E(e.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),p=(e)=>e.map((c)=>D("div",{className:"st-cp-pop-group",children:[j?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((K0)=>D("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${k(K0)?" is-on":""}`,onClick:()=>a(c.ds,K0,c.vals?.[K0]),children:[z("span",{className:"st-cp-pop-cswatch",style:{background:c.vals?.[K0]||"transparent"},"aria-hidden":"true"}),z("span",{className:"st-cp-pop-name",children:R(K0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[K0]||""})]},`${c.ds}:${K0}`))})]},c.ds)),v=(e)=>e.map((c)=>D("div",{className:"st-cp-pop-group",children:[j?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((K0)=>D("button",{type:"button",className:`st-cp-pop-row${k(K0)?" is-on":""}`,onClick:()=>a(c.ds,K0,c.vals?.[K0]),children:[z("span",{className:"st-cp-pop-name",children:R(K0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[K0]||""})]},`${c.ds}:${K0}`))})]},c.ds)),r=z("div",{className:"st-cp-pop-empty",children:"No match"});return D(Q0,{children:[G!==void 0?z("button",{type:"button",ref:w,className:`${K||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${I&&!K?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>V((e)=>!e),children:z("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):z("button",{type:"button",ref:w,className:`st-cp-tokbtn${I?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>V((e)=>!e),children:z("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),U&&B?L80.createPortal(z("div",{ref:O,className:"maude st-cp-pop","data-theme":typeof document<"u"&&document.documentElement.getAttribute("data-theme")||"dark",role:"dialog","aria-label":W||"design tokens",style:{left:B.left,top:B.top,width:B.width,maxHeight:B.maxHeight},children:J==="color"?D(Q0,{children:[D("div",{className:"st-cp-poptabs",role:"tablist",children:[z("button",{type:"button",role:"tab","aria-selected":F==="custom",className:`st-cp-poptab${F==="custom"?" is-active":""}`,onClick:()=>M("custom"),children:"Custom"}),z("button",{type:"button",role:"tab","aria-selected":F==="vars",className:`st-cp-poptab${F==="vars"?" is-active":""}`,onClick:()=>M("vars"),children:"Variables"})]}),F==="custom"?z(I80,{seed:Z||qL(Q)||"#000000",onApply:f}):!C?z("div",{className:"st-cp-pop-empty",children:"No color tokens"}):D(Q0,{children:[h,m.length?p(m):r]})]}):!C?z("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):D(Q0,{children:[h,m.length?v(m):r]})}),document.body):null]})}function F80({label:J,tracks:X,editable:Q,onChange:Y}){let W=(K,U)=>{let V=X[K];Y(X.map((B,N)=>N===K?CU.has(U)?{value:0,unit:U}:{value:V.value||1,unit:U}:B))},G=(K,U)=>{Y(X.map((V,B)=>B===K?{...V,value:U}:V))},Z=()=>Y([...X,{value:1,unit:"fr"}]),H=(K)=>Y(X.filter((U,V)=>V!==K));return D("div",{className:"st-cp-gridtracks",children:[D("div",{className:"st-cp-gridtracks-hd",children:[z("span",{className:"st-cp-gridtracks-label",children:J}),z("button",{type:"button",className:"st-btn st-cp-gridtracks-add",disabled:!Q,onClick:Z,children:"+ Track"})]}),X.length===0?D("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",J.toLowerCase(),"."]}):X.map((K,U)=>{let V=CU.has(K.unit);return D("div",{className:"st-cp-gridtrack-row",children:[V?z(cW,{value:K.unit,ariaLabel:`${J} track ${U+1}`,options:Y80.map((B)=>({value:B,label:B})),onChange:(B)=>W(U,B)}):z(zJ,{value:K.value,min:K.unit==="fr"?0.1:0,step:K.unit==="fr"?0.1:1,ariaLabel:`${J} track ${U+1} value`,lead:String(U+1),unitSlot:z(mN,{value:K.unit,units:Y80,ariaLabel:`${J} track ${U+1} unit`,onChange:(B)=>W(U,B)}),onCommit:(B)=>G(U,B)}),z("button",{type:"button",className:"st-btn st-cp-gridtrack-remove","aria-label":`remove ${J} track ${U+1}`,disabled:!Q||X.length<=1,onClick:()=>H(U),children:"×"})]},U)})]})}function UL0({el:J,cfg:X,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let K=!!J.id,U=J.computed||{},[V,B]=u.useState({a:{},c:{},t:{}});u.useEffect(()=>{B({a:{},c:{},t:{}})},[J.id,J.authored,J.customStyles,J.attrs]);let N=(t,M0)=>{let _0={...t||{}};for(let[f0,Y9]of Object.entries(M0))if(Y9===null)delete _0[f0];else _0[f0]=Y9;return _0},F=N(J.authored,V.a),M=N(J.customStyles,V.c),A=N(J.attrs,V.t),E=(t,M0)=>B((_0)=>({..._0,a:{..._0.a,[t]:M0}})),w=(t,M0)=>B((_0)=>({..._0,c:{..._0.c,[t]:M0}})),O=(t,M0)=>B((_0)=>({..._0,t:{..._0.t,[t]:M0}})),I=(X?.designRel||X?.designRoot||".design").replace(/^\/+|\/+$/g,""),k=E80(J.file,X),R=P80(X,I,k),$=(t)=>R.map((M0)=>({ds:M0.name,names:M0[t]||[],vals:M0.vals})).filter((M0)=>M0.names.length),[C,j]=u.useState({}),[x,m]=u.useState({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),d=Object.keys(M).length>0||Object.keys(A).length>0;u.useEffect(()=>{if(d)m((t)=>t.Advanced?t:{...t,Advanced:!0})},[J.id,d]);let a=(F.position||U7(U.position)||"static")!=="static";u.useEffect(()=>{if(a)m((t)=>t["d:Position"]?t:{...t,"d:Position":!0})},[J.id,a]);let f=H,[h,p]=u.useState({});async function v(t,M0,_0){j((f0)=>({...f0,[_0]:"saving"}));try{let f0=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(M0)}),Y9=await f0.json().catch(()=>({}));return j((m9)=>({...m9,[_0]:!f0.ok||!Y9.ok?`err:${Y9&&Y9.error||`HTTP ${f0.status}`}`:"saved"})),f0.ok?Y9:null}catch(f0){return j((Y9)=>({...Y9,[_0]:`err:${f0&&f0.message?f0.message:String(f0)}`})),null}}let r=u.useRef(Promise.resolve()),e=(t,M0,_0,f0,Y9,m9,e9)=>{r.current=r.current.then(async()=>{let y9=await v(t,M0,_0);if(!y9?.ok)return;let W8=Object.hasOwn(y9,"previous")?y9.previous:m9;if((W8??null)===(e9??null))return;K0(f0,Y9,W8,e9)})},c=(t,M0)=>{if(!Q||!J.id)return;Q({id:J.id,artboardId:J.artboardId??null,index:J.index??0,prop:t,value:M0})},K0=(t,M0,_0,f0)=>{Y?.({op:t,canvas:J.file,id:J.id,key:M0,before:_0==null||_0===""?null:_0,after:f0==null||f0===""?null:f0})},s=(t,M0)=>{let _0=(M0||"").trim();if(!K||!_0)return;let f0=F[t]??null;if(_0===(f0??"").trim())return;c(t,_0),E(t,_0),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,value:_0},t,"css",t,f0,_0)},z0=(t,M0)=>{let _0=(M0||"").trim(),f0=t.trim();if(!K||!f0||!_0)return;let Y9=M[f0]??null;c(f0,_0),w(f0,_0),e("/_api/edit-css",{canvas:J.file,id:J.id,property:f0,value:_0},f0,"css",f0,Y9,_0)},o=(t,M0)=>{let _0=(t||"").trim(),f0=(M0||"").trim();if(!K||!_0||!f0)return;let Y9=A[_0]??null;O(_0,f0),e("/_api/edit-attr",{canvas:J.file,id:J.id,attr:_0,value:f0},`@${_0}`,"attr",_0,Y9,f0)},q0=(t)=>{if(!K)return;let M0=F[t]??null;c(t,null),E(t,null),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,reset:!0},t,"css",t,M0,null)},Z0=(t)=>{if(!K)return;let M0=M[t]??null;c(t,null),w(t,null),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,reset:!0},t,"css",t,M0,null)},k0=(t)=>{if(!K)return;let M0=A[t]??null;O(t,null),e("/_api/edit-attr",{canvas:J.file,id:J.id,attr:t,reset:!0},`@${t}`,"attr",t,M0,null)},a0={display:J.parentDisplay,flexDirection:J.parentFlexDirection},s0=(t,M0)=>{if(!K)return;let _0=Math.round((t==="width"?J.bounds?.w:J.bounds?.h)||0),f0=Sb(t,M0,a0,_0);for(let Y9 of f0.reset)if(F[Y9])q0(Y9);for(let[Y9,m9]of f0.set)s(Y9,m9)},t0=J.parentDisplay==="flex"||J.parentDisplay==="inline-flex",E9=(t)=>{let M0=$b(t,F,U,a0);return D("div",{className:"st-cp-moderow",children:[z("span",{className:"st-cp-modelabel",children:t==="width"?"Width sizing":"Height sizing"}),z("div",{className:"st-cp-modeseg",role:"group","aria-label":`${t} sizing mode`,children:z(uN,{value:M0,ariaLabel:`${t} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(_0)=>s0(t,_0)})})]},`mode-${t}`)},a9=["flex-start","center","flex-end"],F9=["flex-start","center","flex-end"],T9=["t","c","b"],I0=["l","c","r"],w0=()=>{let t=!(F["flex-direction"]||U7(U["flex-direction"])||"row").startsWith("column"),M0=Math.max(0,a9.indexOf(F["justify-content"]||U7(U["justify-content"])||"flex-start")),_0=F["align-items"]||U7(U["align-items"])||"stretch",f0=_0==="stretch"?1:Math.max(0,F9.indexOf(_0)),[Y9,m9]=t?[M0,f0]:[f0,M0];return T9[m9]+I0[Y9]},C0=(t)=>{let M0=T9.indexOf(t[0]),_0=I0.indexOf(t[1]),f0=!(F["flex-direction"]||U7(U["flex-direction"])||"row").startsWith("column"),[Y9,m9]=f0?[_0,M0]:[M0,_0];s("justify-content",a9[Y9]),s("align-items",F9[m9])},W9=(t)=>{if(!(t.metaKey||t.ctrlKey)||t.altKey)return;let M0=t.key.toLowerCase();if(M0==="z")t.preventDefault(),G?.(t.shiftKey?"redo":"undo");else if(M0==="y")t.preventDefault(),G?.("redo")},H9=(t)=>{let M0=F[t];if(!M0)return"inherit";return/var\(\s*--/.test(M0)?"bound":"raw"};if(!K)return D("div",{className:"st-cp",children:[z("div",{className:"st-cp-id",children:z("span",{className:"st-cp-idtag",children:J.tag||"element"})}),D("div",{className:"st-css-disabled",children:["This selection has no stable element id (a legacy canvas, or a non-element target). Edit it with ",z("code",{children:"/design:edit"}),"."]})]});let x9={bound:"token-bound",raw:"raw override",inherit:"inherited"},S9=(t)=>z("span",{className:`st-cp-prov st-cp-prov--${t}`,role:"img","aria-label":x9[t]}),O8=(t,M0)=>{let _0=M0??H9(t),f0=C[t],Y9=typeof f0==="string"&&f0.startsWith("err:")?f0.slice(4):"",m9=Y9?" is-err":f0==="saved"?" is-saved":f0==="saving"?" is-saving":"",e9=!!F[t],y9=Y9?`error: ${Y9}`:e9?`${x9[_0]} · double-click to reset`:x9[_0];return z("button",{type:"button",className:`st-cp-prov st-cp-prov--${_0}${m9}${e9?" is-resettable":""}`,"aria-label":y9,title:y9,tabIndex:e9?0:-1,onDoubleClick:e9?()=>q0(t):void 0,onKeyDown:e9?(W8)=>{if(W8.key==="Backspace"||W8.key==="Delete")W8.preventDefault(),q0(t)}:void 0})},v0=(t,M0,_0,f0)=>{let Y9=_0===void 0&&!F[t],m9=f0??t;return D("div",{className:`st-cp-row${Y9?" is-unset":""}`,children:[O8(t,_0),z("label",{className:"st-cp-label",title:m9,children:m9}),z("div",{className:"st-cp-ctl",children:M0})]},t)},$9={Layout:["display","flex-direction","flex-wrap","align-items","justify-content","gap"],Grid:["grid-template-columns","grid-template-rows"],"Grid item":["grid-column","grid-row"],Position:["position","top","right","bottom","left","z-index"],Typography:["font-family","color","font-size","font-weight","line-height","letter-spacing","text-align","font-style","text-transform","text-decoration","white-space"],Spacing:["margin-top","margin-right","margin-bottom","margin-left","padding-top","padding-right","padding-bottom","padding-left"],Size:["width","height","min-width","min-height","max-width","max-height","overflow","flex-grow","flex-shrink","flex-basis","align-self"],Media:["object-fit","aspect-ratio","object-position"],Appearance:["background-color","border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius","border-width","border-style","border-color","box-shadow","filter","mix-blend-mode","opacity","transform","transform-origin"]},w8=(t)=>{($9[t]||[]).forEach((M0)=>{if(F[M0])q0(M0)})},L9=(t,M0)=>{let _0=($9[t]||[]).some((f0)=>F[f0]);return D("section",{className:"st-cp-sec",children:[D("div",{className:"st-cp-sechd-row",children:[D("button",{type:"button",className:"st-cp-sechd","data-testid":`inspector-section-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,"aria-expanded":!!x[t],onClick:()=>m((f0)=>({...f0,[t]:!f0[t]})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:x[t]?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${_0?"":" is-quiet"}`,"aria-label":`reset ${t} section to original`,title:`reset ${t}`,disabled:!_0,onClick:()=>w8(t),children:z(K7,{as:oZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${x[t]?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:M0})})]},t)},V0=(t,M0,_0,f0=!0)=>{let Y9=`d:${t}`,m9=x[Y9]===void 0?f0:x[Y9],e9=M0.some((y9)=>F[y9]);return D("section",{className:"st-cp-sec",children:[D("div",{className:"st-cp-sechd-row",children:[D("button",{type:"button",className:"st-cp-sechd","aria-expanded":m9,onClick:()=>m((y9)=>({...y9,[Y9]:!m9})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:m9?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${e9?"":" is-quiet"}`,"aria-label":`reset ${t} to original`,title:`reset ${t}`,disabled:!e9,onClick:()=>M0.forEach((y9)=>{if(F[y9])q0(y9)}),children:z(K7,{as:oZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${m9?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:_0})})]},Y9)},J9=(t)=>z("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!h[t],"aria-label":h[t]?`${t} — fewer options`:`${t} — more options`,title:h[t]?"fewer":"more",onClick:()=>p((M0)=>({...M0,[t]:!M0[t]})),children:h[t]?"▴":"···"}),r0=(t,M0)=>D("select",{className:"st-cp-nsel","aria-label":t,value:M0.includes(F[t])?F[t]:"",onChange:(_0)=>s(t,_0.target.value),children:[z("option",{value:"",disabled:!0,children:U7(U[t])||"—"}),M0.map((_0)=>z("option",{value:_0,children:_0},_0))]}),b0=(t)=>$(t).flatMap((M0)=>(M0.names||[]).map((_0)=>({name:_0,value:M0.vals?.[_0]||""}))),X9=(t,M0)=>z(xw,{value:F[t]||U7(U[t])||M0[0].value,ariaLabel:t,options:M0,onChange:(_0)=>s(t,_0)}),q9=(t,M0,_0={})=>{let f0=Q4(F[t]??""),Y9=z80.has(t),m9=F[t]??"",e9=typeof m9==="string"&&/var\(\s*--/.test(m9),y9=Y9?"":f0.unit&&f0.unit!=="auto"?f0.unit:"px",W8=Number.parseFloat(Q4(U7(U[t])??"").n)||0,k8=f0.n!==""&&f0.n!=null?Number.parseFloat(f0.n)||0:W8,e8=Yk[t];return z(pN,{value:e9?m9:k8,tokens:b0(M0),ariaLabel:t,min:_0.min??0,lead:e8?e8.node??e8.t:void 0,unitSlot:Y9?null:z(mN,{units:H80,value:f0.unit||"px",ariaLabel:`${t} unit`,onChange:(J7)=>s(t,J7==="auto"?"auto":`${f0.n||"0"}${J7}`)}),onChange:(J7)=>s(t,typeof J7==="string"?J7:Y9?`${J7}`:`${J7}${y9}`)})},l0=()=>{let t=(Y9)=>Number.parseFloat(Q4(F[Y9]??F["border-radius"]??U7(U[Y9])??U7(U["border-radius"])??"0").n)||0,M0={tl:t("border-top-left-radius"),tr:t("border-top-right-radius"),bl:t("border-bottom-left-radius"),br:t("border-bottom-right-radius")},_0=(Y9)=>{if(Y9.tl===Y9.tr&&Y9.tr===Y9.bl&&Y9.bl===Y9.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((e9)=>{if(F[e9])q0(e9)}),s("border-radius",`${Y9.tl}px`);else s("border-top-left-radius",`${Y9.tl}px`),s("border-top-right-radius",`${Y9.tr}px`),s("border-bottom-left-radius",`${Y9.bl}px`),s("border-bottom-right-radius",`${Y9.br}px`)},f0=Yk["border-radius"];return z(yg,{corners:M0,lead:f0?f0.node??f0.t:void 0,onCorners:_0})},d0=()=>D("div",{className:"st-cp-border",children:[Q8("border-width",null,{fixedUnit:"px"}),D("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:Z80.includes(F["border-style"])?F["border-style"]:"",onChange:(t)=>s("border-style",t.target.value),children:[z("option",{value:"",disabled:!0,children:"style"}),Z80.map((t)=>z("option",{value:t,children:t},t))]}),z(zL,{kind:"color",groups:$("color"),current:F["border-color"],activeDs:k,swatchBg:U["border-color"]||F["border-color"]||"",seedHex:qL(U["border-color"]||F["border-color"])||"#000000",onPick:(t)=>s("border-color",t),label:"border colour"})]}),h0=()=>{let t=F.transform||U7(U.transform)||"",M0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(t),_0=((M0?Number.parseFloat(M0[1]):0)%360+360)%360,f0=(Y9)=>{let m9=(Y9%360+360)%360,e9=(F.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();s("transform",`${e9?`${e9} `:""}rotate(${m9}deg)`.trim())};return D("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[z(Sg,{value:_0,onChange:f0}),z(zJ,{value:_0,min:0,max:360,ariaLabel:"rotation",lead:z(K7,{as:oZ}),steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:f0})]})},y0=()=>{let t=F.filter||U7(U.filter)||"",M0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(t),_0=M0?Number.parseFloat(M0[1]):0;return z(zJ,{value:_0,min:0,ariaLabel:"filter blur",unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(Y9)=>{let m9=(F.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();s("filter",Y9>0?`${m9?`${m9} `:""}blur(${Y9}px)`.trim():m9||"none")}})},B9=()=>{let t=F.opacity,M0=t!=null&&t!==""?Number.parseFloat(t):Number.parseFloat(U7(U.opacity))||1,_0=Math.round((Number.isNaN(M0)?1:M0)*100);return z(mX,{value:_0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(f0)=>c("opacity",String(f0/100)),onCommit:(f0)=>s("opacity",String(f0/100))},`opacity:${t??""}`)},D9=()=>{let t=Number.parseInt(F["font-weight"]||U7(U["font-weight"])||"400",10)>=600,M0=(F["font-style"]||U7(U["font-style"]))==="italic",_0=/underline/.test(F["text-decoration"]||U7(U["text-decoration"])||"");return z(Cg,{value:{b:t,i:M0,u:_0},ariaLabel:"text style",options:[{value:"b",node:z(K7,{as:mV}),label:"Bold"},{value:"i",node:z(K7,{as:cV}),label:"Italic"},{value:"u",node:z(K7,{as:Q3}),label:"Underline"}],onToggle:(f0)=>{if(f0==="b")s("font-weight",t?"400":"700");else if(f0==="i")s("font-style",M0?"normal":"italic");else s("text-decoration",_0?"none":"underline")}})},N0=[{value:"row",node:z(K7,{as:vW}),label:"Row"},{value:"column",node:z(K7,{as:fW}),label:"Column"}],o0=[{value:"flex-start",node:z(K7,{as:vV}),label:"Start"},{value:"center",node:z(K7,{as:yV}),label:"Center"},{value:"flex-end",node:z(K7,{as:jV}),label:"End"},{value:"space-between",node:z(K7,{as:PK}),label:"Space between"}],h9=[{value:"flex-start",node:z(K7,{as:hV}),label:"Start"},{value:"center",node:z(K7,{as:fV}),label:"Center"},{value:"flex-end",node:z(K7,{as:xV}),label:"End"},{value:"stretch",node:z(K7,{as:J3}),label:"Stretch"}],g9=[{value:"left",node:z(K7,{as:tQ}),label:"Left"},{value:"center",node:z(K7,{as:gW}),label:"Center"},{value:"right",node:z(K7,{as:mW}),label:"Right"},{value:"justify",node:z(K7,{as:uW}),label:"Justify"}],e0=[{value:"visible",node:z(K7,{as:iZ}),label:"Visible"},{value:"hidden",node:z(K7,{as:nZ}),label:"Hidden"},{value:"scroll",node:z(K7,{as:sV}),label:"Scroll"}],a7=(t,M0)=>{let _0=$(M0);return _0.length?z(zL,{kind:"value",groups:_0,current:F[t],activeDs:k,onPick:(f0)=>s(t,f0),label:`${t} design token`}):null},F8=(t)=>{let M0=t.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===M0)M0.select()})},v7=(t,M0)=>{if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return!1;t.preventDefault();let _0=t.shiftKey?10:1,f0=t.key==="ArrowUp"?1:-1,Y9=(Number.parseFloat(t.currentTarget.value)||0)+f0*_0;return t.currentTarget.value=String(Y9),M0(Y9),!0},I9=(t)=>z("input",{className:"st-cp-fin","aria-label":t,defaultValue:F[t]??"",placeholder:U7(U[t])||"—",onFocus:F8,onKeyDown:(M0)=>{if(M0.key==="Enter")M0.currentTarget.blur()},onBlur:(M0)=>s(t,M0.currentTarget.value)},`${t}:${F[t]??""}`),Q8=(t,M0,_0={})=>{let f0=Q4(F[t]??""),Y9=z80.has(t),m9=Y9?"":_0.fixedUnit||(f0.unit&&f0.unit!=="auto"?f0.unit:"px"),e9=Yk[t],y9=Number.parseFloat(Q4(U7(U[t])??"").n)||0,W8=f0.n!==""&&f0.n!=null?Number.parseFloat(f0.n)||0:y9;return D(Q0,{children:[z(zJ,{value:W8,min:_0.min??0,step:1,ariaLabel:t,lead:e9?e9.node??e9.t:void 0,onCommit:(k8)=>s(t,Y9?`${k8}`:`${k8}${m9}`),unitSlot:Y9||_0.fixedUnit?null:z(mN,{units:H80,value:f0.unit||"px",ariaLabel:`${t} unit`,onChange:(k8)=>s(t,k8==="auto"?"auto":`${f0.n||"0"}${k8}`)})},`${t}:${F[t]??""}`),a7(t,M0)]})},c9=(t)=>{let M0=U[t]||F[t]||"",_0=F[t]??"",f0=typeof _0==="string"&&/var\(\s*--/.test(_0),Y9=f0?_0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):_0;return z(W3,{swatch:z(zL,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:$("color"),current:F[t],activeDs:k,swatchBg:M0,seedHex:qL(U[t]||F[t])||"#000000",onPick:(m9)=>s(t,m9),label:`${t} colour`}),displayValue:Y9,bound:f0,ariaLabel:t,onValue:(m9)=>s(t,m9)})},O0=(t,M0)=>{let _0=null,f0=M0.unitless?"":"px",Y9=(y9)=>M0.unitless?`${y9}`:`${y9}${f0}`,m9=(y9,W8,k8)=>{for(let e8 of W8??[t])k8(e8,Y9(y9))},e9=fw({getBase:()=>_0?.value??"0",min:M0.min??0,step:1,sides:M0.sides,onInput:(y9,W8)=>{if(_0)_0.value=String(y9);if(W8){let k8=_0?.closest(".st-cp-box");for(let e8 of W8){if(e8===t)continue;let J7=k8?.querySelector(`.st-cp-boxv[aria-label="${e8}"]`);if(J7)J7.value=String(y9)}}m9(y9,W8,c)},onCommit:(y9,W8)=>m9(y9,W8,s)});return{onPointerDown:(y9)=>{_0=y9.currentTarget,e9(y9)}}},K9=(t,M0)=>{let _0=F[t],f0=_0!=null&&_0!==""?Q4(_0).n||_0:Q4(U7(U[t])??"").n||"0",Y9=!_0||_0==="0"||_0==="0px"||_0==="auto",m9=t.split("-").pop(),e9=m9==="top"||m9==="bottom"?[`${M0}-top`,`${M0}-bottom`]:[`${M0}-left`,`${M0}-right`],y9=[`${M0}-top`,`${M0}-right`,`${M0}-bottom`,`${M0}-left`];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${M0[0]}${t.split("-").pop()[0]}${Y9?" is-zero":""}`,"aria-label":t,defaultValue:f0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...O0(t,{sides:{pair:e9,all:y9}}),onFocus:F8,onKeyDown:(W8)=>{if(v7(W8,(k8)=>s(t,`${k8}px`)))return;if(W8.key==="Enter")W8.currentTarget.blur()},onBlur:(W8)=>{let k8=W8.currentTarget.value.trim();if(!k8)return;let e8=/[a-z%]/i.test(k8)?k8:`${k8}px`;s(t,e8)}},`${t}:${_0??""}`)},C9=(t)=>{let M0=F[t],_0=M0!=null&&M0!==""&&M0!=="auto"?Q4(M0).n||M0:Q4(U7(U[t])??"").n||"",f0=!M0||M0==="auto"||M0==="0"||M0==="0px",Y9=t==="top"||t==="bottom"?["top","bottom"]:["left","right"],m9=["top","right","bottom","left"];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${t[0]}${f0?" is-zero":""}`,"aria-label":t,defaultValue:_0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...O0(t,{sides:{pair:Y9,all:m9},min:-1/0}),onFocus:F8,onKeyDown:(e9)=>{if(v7(e9,(y9)=>s(t,`${y9}px`)))return;if(e9.key==="Enter")e9.currentTarget.blur()},onBlur:(e9)=>{let y9=e9.currentTarget.value.trim();if(!y9)return;let W8=/[a-z%]/i.test(y9)?y9:`${y9}px`;s(t,W8)}},`${t}:${M0??""}`)},V8=Object.entries(M),x8=Object.entries(A),i8=()=>{let t=(J.tag||"").toLowerCase(),_0=t==="img"||t==="video"||t==="picture"||t==="svg"||t==="canvas"||!!F["object-fit"]||!!F["object-position"]||!!F["aspect-ratio"],f0=(t==="img"||t==="video")&&!!J.attrs?.src&&!!W;return{showMedia:_0,canReplace:f0}},h8=(t)=>D(Q0,{children:[t&&z("div",{className:"st-cp-mediabtn",children:z("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>W(J),children:"Replace…"})}),v0("object-fit",r0("object-fit",zL0)),v0("object-position",I9("object-position")),v0("aspect-ratio",D("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:B80.includes(F["aspect-ratio"])?F["aspect-ratio"]:"",onChange:(M0)=>{let _0=M0.target.value;if(s("aspect-ratio",_0),_0&&_0!=="auto"&&F.height)q0("height")},children:[z("option",{value:"",disabled:!0,children:U7(U["aspect-ratio"])||"—"}),B80.map((M0)=>z("option",{value:M0,children:M0},M0))]}))]});return D("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:W9,children:[D("div",{className:"st-cp-id",children:[D("span",{className:"st-cp-idtag",children:[J.tag||"element",J.classes?D("span",{className:"st-cp-idcls",children:[".",J.classes.split(/\s+/)[0]]}):null]}),z("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:z(xw,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:z(K7,{as:jW,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:z(K7,{as:pW,size:12}),label:"Designer — Figma vocabulary"}],onChange:f})})]}),Z==="designer"?D(Q0,{children:[V0("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let t=(F.display||U7(U.display)||"").trim();return t==="flex"||t==="inline-flex"?D(Q0,{children:[v0("flex-direction",X9("flex-direction",N0),void 0,"Direction"),v0("align-items",z($g,{value:w0(),onChange:C0,ariaLabel:"auto-layout alignment"}),H9("align-items"),"Alignment"),v0("gap",q9("gap","space"),void 0,"Gap"),D("div",{className:"st-cp-modes",children:[E9("width"),E9("height")]}),D("div",{className:"st-cp-box","aria-label":"padding",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[S9(H9("padding-top")),"padding"]}),K9("padding-top","padding"),K9("padding-right","padding"),K9("padding-bottom","padding"),K9("padding-left","padding")]}),z("div",{className:"st-cp-clustermore-row",children:J9("Auto layout")}),h["Auto layout"]?v0("flex-wrap",z(a5,{checked:/^wrap/.test(F["flex-wrap"]||U7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(_0)=>s("flex-wrap",_0?"wrap":"nowrap")}),H9("flex-wrap"),"Wrap"):null]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>s("display","flex"),children:"+ Auto layout (flex)"})})()),V0("Size",["width","height","min-width","max-width","min-height","max-height"],D(Q0,{children:[v0("width",Q8("width"),void 0,"Width"),v0("height",Q8("height"),void 0,"Height"),z("div",{className:"st-cp-clustermore-row",children:J9("Size")}),h.Size?D(Q0,{children:[v0("min-width",Q8("min-width"),void 0,"Min width"),v0("max-width",Q8("max-width"),void 0,"Max width"),v0("min-height",Q8("min-height"),void 0,"Min height"),v0("max-height",Q8("max-height"),void 0,"Max height")]}):null]})),V0("Position",["position","top","right","bottom","left","z-index"],D(Q0,{children:[v0("position",r0("position",K80),void 0,"Position"),D("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[S9(H9("top")),"inset"]}),C9("top"),C9("right"),C9("bottom"),C9("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||U7(U.position)||"static"})]}),(F.position||U7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,z("div",{className:"st-cp-clustermore-row",children:J9("Position")}),h.Position?v0("z-index",Q8("z-index"),void 0,"Layer order"):null]}),!1),V0("Fill",["background-color"],v0("background-color",c9("background-color"),void 0,"Fill")),V0("Stroke",["border-width","border-style","border-color"],v0("border",d0(),H9("border-width"),"Stroke")),V0("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],v0("border-radius",l0(),H9("border-radius"),"Corner radius")),V0("Effects",["box-shadow","filter","mix-blend-mode"],D(Q0,{children:[v0("box-shadow",a7("box-shadow","shadow")||I9("box-shadow"),void 0,"Shadow"),v0("filter",y0(),H9("filter"),"Blur"),v0("mix-blend-mode",r0("mix-blend-mode",q80),void 0,"Blend")]})),V0("Opacity",["opacity"],v0("opacity",B9(),void 0,"Opacity")),V0("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],D(Q0,{children:[v0("font-family",r0("font-family",G80),void 0,"Font"),v0("color",c9("color"),void 0,"Color"),v0("font-size",q9("font-size","type"),void 0,"Size"),v0("font-weight",r0("font-weight",W80),void 0,"Weight"),v0("line-height",Q8("line-height","lh"),void 0,"Line height"),v0("text-align",X9("text-align",g9),void 0,"Align"),z("div",{className:"st-cp-clustermore-row",children:J9("Text")}),h.Text?D(Q0,{children:[v0("letter-spacing",Q8("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),v0("font-style",r0("font-style",HL0),void 0,"Style"),v0("text-transform",r0("text-transform",U80),void 0,"Case"),v0("white-space",r0("white-space",V80),void 0,"Whitespace")]}):null]})),V0("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],D("div",{className:"st-cp-box","aria-label":"margin",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[S9(H9("margin-top")),"margin"]}),K9("margin-top","margin"),K9("margin-right","margin"),K9("margin-bottom","margin"),K9("margin-left","margin")]})),(()=>{let{showMedia:t,canReplace:M0}=i8();return t?V0("Media",["object-fit","object-position","aspect-ratio"],h8(M0)):null})()]}):D(Q0,{children:[L9("Layout",(()=>{let t=(F.display||U7(U.display)||"").trim(),M0=t==="flex"||t==="inline-flex",_0=t==="grid"||t==="inline-grid";return D(Q0,{children:[v0("display",r0("display",GL0)),M0?D(Q0,{children:[v0("flex-direction",X9("flex-direction",N0)),v0("flex-wrap",z(a5,{checked:/^wrap/.test(F["flex-wrap"]||U7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(f0)=>s("flex-wrap",f0?"wrap":"nowrap")}),H9("flex-wrap"))]}):null,M0||_0?D(Q0,{children:[v0("align-items",X9("align-items",h9)),v0("justify-content",X9("justify-content",o0)),v0("gap",q9("gap","space"))]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>s("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let t=(F.display||U7(U.display)||"").trim();if(!(t==="grid"||t==="inline-grid"))return null;let _0=F["grid-template-columns"]||"",f0=F["grid-template-rows"]||"",Y9=wO(_0),m9=wO(f0),e9=Y9.length>0||!_0.trim(),y9=m9.length>0||!f0.trim();return L9("Grid",D(Q0,{children:[e9?z(F80,{label:"Columns",tracks:Y9,editable:K,onChange:(W8)=>s("grid-template-columns",EO(W8))}):D("div",{className:"st-cp-note",children:["Columns use ",z("code",{children:_0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),y9?z(F80,{label:"Rows",tracks:m9,editable:K,onChange:(W8)=>s("grid-template-rows",EO(W8))}):D("div",{className:"st-cp-note",children:["Rows use ",z("code",{children:f0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),L9("Position",D(Q0,{children:[v0("position",r0("position",K80)),D("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[S9(H9("top")),"inset"]}),C9("top"),C9("right"),C9("bottom"),C9("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||U7(U.position)||"static"})]}),(F.position||U7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,v0("z-index",Q8("z-index"))]})),(J.parentDisplay==="grid"||J.parentDisplay==="inline-grid")&&L9("Grid item",D(Q0,{children:[D("div",{className:"st-cp-note",children:["Manual cell placement — ",z("code",{children:"start / end"})," or ",z("code",{children:"start / span N"}),"."]}),v0("grid-column",I9("grid-column")),v0("grid-row",I9("grid-row"))]})),L9("Typography",D(Q0,{children:[v0("font-family",r0("font-family",G80)),v0("color",c9("color")),v0("font-size",q9("font-size","type")),v0("font-weight",r0("font-weight",W80)),v0("line-height",Q8("line-height","lh")),v0("letter-spacing",Q8("letter-spacing",null,{min:-1/0})),v0("text-align",X9("text-align",g9)),v0("font-style",D9(),H9("font-style")),v0("text-transform",r0("text-transform",U80)),v0("white-space",r0("white-space",V80))]})),L9("Spacing",z(Q0,{children:D("div",{className:"st-cp-box","aria-label":"margin and padding",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[S9(H9("margin-top")),"margin"]}),K9("margin-top","margin"),K9("margin-right","margin"),K9("margin-bottom","margin"),K9("margin-left","margin"),D("div",{className:"st-cp-boxpad",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[S9(H9("padding-top")),"padding"]}),K9("padding-top","padding"),K9("padding-right","padding"),K9("padding-bottom","padding"),K9("padding-left","padding"),D("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(F.width)||J.bounds?.w||0)," × ",Math.round(Number.parseFloat(F.height)||J.bounds?.h||0)]})]})]})})),L9("Size",D(Q0,{children:[D("div",{className:"st-cp-modes",children:[E9("width"),E9("height")]}),v0("width",Q8("width")),v0("height",Q8("height")),v0("min-width",Q8("min-width")),v0("max-width",Q8("max-width")),v0("min-height",Q8("min-height")),v0("max-height",Q8("max-height")),v0("overflow",X9("overflow",e0)),t0?D(Q0,{children:[z("div",{className:"st-cp-subhd",children:"In flex parent"}),v0("align-self",r0("align-self",ZL0)),v0("flex-grow",Q8("flex-grow",null,{unitless:!0})),v0("flex-shrink",Q8("flex-shrink",null,{unitless:!0})),v0("flex-basis",Q8("flex-basis"))]}):null]})),(()=>{let{showMedia:t,canReplace:M0}=i8();return t?L9("Media",h8(M0)):null})(),L9("Appearance",D(Q0,{children:[v0("background-color",c9("background-color")),v0("border-radius",l0(),H9("border-radius")),v0("border",d0(),H9("border-width")),v0("box-shadow",a7("box-shadow","shadow")||I9("box-shadow")),v0("filter",y0(),H9("filter")),v0("mix-blend-mode",r0("mix-blend-mode",q80)),v0("opacity",B9()),v0("rotation",h0(),H9("transform")),v0("transform",I9("transform")),v0("transform-origin",I9("transform-origin"))]})),(()=>{let t=Object.entries(C).find(([,M0])=>typeof M0==="string"&&M0.startsWith("err:"));return t?D("div",{className:"st-cp-save is-err",role:"status",children:[z(T8,{name:"x",size:12}),t[0],": ",t[1].slice(4)]}):null})(),L9("Advanced",D("div",{className:"st-cp-advbody",children:[V8.length?D(Q0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),V8.map(([t,M0])=>D("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`custom property ${t} name`}),z("input",{className:"st-cp-fin",defaultValue:M0,"aria-label":`${t} value`,onKeyDown:(_0)=>{if(_0.key==="Enter")_0.currentTarget.blur()},onBlur:(_0)=>z0(t,_0.currentTarget.value)},`cs:${t}:${M0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>Z0(t),children:z(T8,{name:"x",size:11})})]},`cs:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add CSS property"}),z(VL0,{commit:z0}),z("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),x8.length?D(Q0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),x8.map(([t,M0])=>D("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`attribute ${t} name`}),z("input",{className:"st-cp-fin",defaultValue:M0,"aria-label":`${t} value`,onKeyDown:(_0)=>{if(_0.key==="Enter")_0.currentTarget.blur()},onBlur:(_0)=>o(t,_0.currentTarget.value)},`at:${t}:${M0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>k0(t),children:z(T8,{name:"x",size:11})})]},`at:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),z(qL0,{commit:o})]}))]}),D("div",{className:"st-cp-legend",children:[D("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),D("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),D("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},J.id)}function VL0({commit:J}){let[X,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(X.trim()&&Y.trim())J(X.trim(),Y),Q(""),W("")};return D("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom property name",placeholder:"property",value:X,onChange:(Z)=>Q(Z.target.value)}),z("input",{className:"st-cp-fin","aria-label":"custom property value",placeholder:"value",value:Y,onChange:(Z)=>W(Z.target.value),onKeyDown:(Z)=>{if(Z.key==="Enter")G()},onBlur:G})]})}function qL0({commit:J}){let[X,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(X.trim()&&Y.trim())J(X.trim(),Y),Q(""),W("")};return D("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom attribute name",placeholder:"data-…",value:X,onChange:(Z)=>Q(Z.target.value)}),z("input",{className:"st-cp-fin","aria-label":"custom attribute value",placeholder:"value",value:Y,onChange:(Z)=>W(Z.target.value),onKeyDown:(Z)=>{if(Z.key==="Enter")G()},onBlur:G})]})}var BL0={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function NL0(J,X,Q,Y){if(!Array.isArray(J)||X===Q)return J;let W=JSON.parse(JSON.stringify(J)),G=null,Z=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===X)return G=K[U],K.splice(U,1),!0;if(K[U].children&&Z(K[U].children))return!0}return!1};if(Z(W),!G)return J;let H=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===Q){if(Y==="inside-start"||Y==="inside-end")if(K[U].children=K[U].children||[],Y==="inside-start")K[U].children.unshift(G);else K[U].children.push(G);else K.splice(Y==="before"?U:U+1,0,G);return!0}if(K[U].children&&H(K[U].children))return!0}return!1};return H(W)?W:J}var FL0=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function T80({node:J,depth:X,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:V,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:M,onToggleLock:A,onRename:E}){let w=`${J.id}:${J.index}`,O=J.children&&J.children.length>0,I=W.has(w),k=!!J.synthetic,R=!k&&F?F[J.id]:null,$=!k&&!!M?.has(w),[C,j]=u.useState(!1),[x,m]=u.useState(""),d=!k&&J.id===Q&&(Y==null||J.index===Y),a=G?.has(w)?G.get(w):!!J.hidden,f=!!V&&!k&&!$,h=()=>{j(!1);let r=x.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!r||r===(J.dcElement??""))return;E?.(J,r)},p=N?.key===w,v=p?{transform:`translate(${N.dx}px, ${N.dy}px)`,opacity:0.9,zIndex:20,position:"relative",pointerEvents:"none",cursor:"grabbing",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.28)"}:null;return D(Q0,{children:[D("div",{className:"st-layer st-layer--row"+(d?" is-sel":"")+(a?" is-hidden":"")+(k?" is-group":"")+(R?" is-instance":"")+($?" is-locked":""),style:{paddingLeft:6+X*14,...v},role:"treeitem","aria-selected":k?void 0:d,"aria-expanded":O?!I:void 0,"aria-grabbed":f?p:void 0,tabIndex:0,title:k?`${J.tag} · group (unstamped wrapper)`:`${J.tag} · ${J.type}${E?" · F2 to rename":""}`,"data-layer-key":w,onClick:()=>k?O&&Z(w):H(J),onMouseEnter:()=>!k&&K(J),onMouseLeave:()=>K(null),onPointerDown:f?(r)=>B(r,J,w):void 0,onKeyDown:(r)=>{if(r.key==="Enter"||r.key===" ")if(r.preventDefault(),k)O&&Z(w);else H(J);else if(r.key==="F2"&&E&&!k)r.preventDefault(),m(J.dcElement||J.label||""),j(!0)},children:[O?z("button",{type:"button",className:"st-layer-caret","aria-label":I?"Expand":"Collapse",onClick:(r)=>{r.stopPropagation(),Z(w)},children:I?"▸":"▾"}):z("span",{className:"st-layer-caret","aria-hidden":"true"}),R?z("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:R.root?"◆":"◇"}):z(T8,{name:BL0[J.type]||"box",size:12,className:"st-layer-ticon"}),C?z("input",{className:"st-layer-rename",value:x,autoFocus:!0,"aria-label":`Rename ${J.label}`,onFocus:(r)=>r.target.select(),onChange:(r)=>m(r.target.value),onClick:(r)=>r.stopPropagation(),onPointerDown:(r)=>r.stopPropagation(),onBlur:h,onKeyDown:(r)=>{if(r.stopPropagation(),r.key==="Enter")h();else if(r.key==="Escape")j(!1)}}):z("span",{className:"st-layer-label",onDoubleClick:E&&!k?(r)=>{r.stopPropagation(),m(J.dcElement||J.label||""),j(!0)}:void 0,children:J.label}),z("span",{className:"st-layer-type",children:R?R.component:J.type}),A&&!k?z("button",{type:"button",className:"st-layer-lock","aria-label":$?`Unlock ${J.label}`:`Lock ${J.label}`,"aria-pressed":$,title:$?"Unlock":"Lock",onClick:(r)=>{r.stopPropagation(),A(w)},children:z(T8,{name:$?"lock":"unlock",size:12})}):null,U&&!k?z("button",{type:"button",className:"st-layer-eye","aria-label":a?`Show ${J.label}`:`Hide ${J.label}`,"aria-pressed":a,title:a?"Show":"Hide",onClick:(r)=>{r.stopPropagation(),U(J)},children:z(T8,{name:a?"eye-off":"eye",size:13})}):null]}),O&&!I?J.children.map((r,e)=>z(T80,{node:r,depth:X+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:V,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:M,onToggleLock:A,onRename:E},`${r.id}:${r.index}`)):null]})}function LL0({el:J}){let X=J?.computed||{},Q=J?.authored||{},Y=(U)=>{let V=Q[U];if(V&&/var\(\s*--/.test(V))return V.replace(/^var\(\s*|\s*\)$/g,"");return X[U]||V||""},W=(U,V)=>{let B=X[V]||Q[V];if(!B)return null;return D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:U}),D("div",{className:"st-swatch-row",children:[z("span",{className:"st-insp-swatch",style:{background:B},"aria-hidden":"true"}),z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Y(V)})]})]},U)},G=X["border-radius"]&&X["border-radius"]!=="0px",Z=G?Q4(X["border-radius"]).n||X["border-radius"]:null,H=X["font-size"]||X["font-weight"]?[X["font-size"],X["font-weight"]].filter(Boolean).join(" / "):null;if(!(X["background-color"]||X.color||G||H))return null;return D(Q0,{children:[G?D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Radius"}),D("div",{className:"st-insp-fields",children:[D("span",{className:"st-fmini",style:{flex:"0 0 auto",maxWidth:84},children:[z("span",{className:"st-mtag",children:"r"}),z("input",{value:Z,readOnly:!0,"aria-label":"border radius"})]}),z("span",{className:"st-insp-unit",children:"px"})]})]}):null,W("Fill","background-color"),W("Text","color"),H?D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Font"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:H})})]}):null]})}function k80(J){if(J.artboardId)return J.artboardId;let X=/^\[data-dc-screen="([^"]+)"\]$/.exec(J.selector||"");return X?X[1]:null}var DL0=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],ML0=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function OL0({el:J,cfg:X,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let K=k80(J),U=(X?.designRel||X?.designRoot||".design").replace(/^\/+|\/+$/g,""),V=E80(J.file,X),B=P80(X,U,V),N=(v)=>B.map((r)=>({ds:r.name,names:r[v]||[],vals:r.vals})).filter((r)=>r.names.length),F=(v)=>N(v).flatMap((r)=>(r.names||[]).map((e)=>({name:e,value:r.vals?.[e]||""}))),M=(v)=>{let r=/^var\(\s*(--[\w-]+)\s*\)$/.exec(v||"");if(!r)return v||"";for(let e of B){let c=e.vals?.[r[1]];if(c)return c}return""},A=Number.isFinite(J.worldW)?J.worldW:Number.isFinite(J.bounds?.w)?J.bounds.w:null,E=Number.isFinite(J.worldH)?J.worldH:Number.isFinite(J.bounds?.h)?J.bounds.h:null,w=(v,r)=>{if(!K)return;let e=Number.isFinite(v)&&v>0?Math.round(v):void 0,c=Number.isFinite(r)&&r>0?Math.round(r):void 0;if(e==null&&c==null)return;Q?.(K,e,c)},O=Object.entries(bQ).find(([,v])=>v.width===A&&v.height===E)?.[0],I=Object.entries(bQ).find(([,v])=>v.width===A)?.[0],k=J.attrs?.["data-dc-fixed"]==="true",R=J.attrs?.["data-dc-bg"]??"",$=J.attrs?.["data-dc-padding"]??"",C=J.attrs?.["data-dc-layout"]??"",j=J.attrs?.["data-dc-gap"]??"",x=J.attrs?.["data-dc-kind"]||"digital",m=null;try{m=J.attrs?.["data-dc-print"]?JSON.parse(J.attrs["data-dc-print"]):null}catch{}let d=(v)=>{if(!K)return;let r=null;if(v==="print"&&!m){let e={paper:"a4"};try{let c=r2(e);if(c)r={defaults:e,widthPx:c.widthPx,heightPx:c.heightPx}}catch{}}if(G?.(K,v==="digital"?null:v,r),v==="web"&&k)Y?.(K,!1,void 0)},a=(v)=>{if(!K)return;let r={paper:"a4",...m,...v},e;try{e=r2(r)}catch{return}Q?.(K,e.widthPx,e.heightPx),Z?.(K,r)},f=(v,r)=>{if(!K)return;let e=Number.isFinite(r)?r:E,c=v&&Number.isFinite(e)?Math.round(e):void 0;Y?.(K,v,c)},h=(v)=>{let r=kb(k,v);if(r.kind==="resize")w(null,r.height);else if(r.kind==="promote-to-fixed")f(!0,r.height)},p=(v)=>{if(!K)return;W?.(K,v)};return D("section",{className:"st-cp-sec",children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Artboard"})}),D("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[z(zJ,{value:A??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(v)=>w(v,null)}),z(zJ,{value:E??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:k,onCommit:h})]}),z("div",{style:{padding:"0 12px 8px"},children:x==="print"?D("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:m?.paper??"",onChange:(v)=>a({paper:v.currentTarget.value}),children:[z("option",{value:"",disabled:!0,children:"Paper size…"}),n2.map((v)=>D("option",{value:v.id,children:[v.label," — ",v.width,"×",v.height,v.unit]},v.id))]}):x==="web"?D("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:I??"",onChange:(v)=>{let r=bQ[v.currentTarget.value];if(r)w(r.width,null)},children:[z("option",{value:"",disabled:!0,children:I?`${bQ[I].label} — ≤ ${bQ[I].width}px`:"Breakpoint…"}),Object.entries(bQ).map(([v,r])=>D("option",{value:v,children:[r.label," — ≤ ",r.width,"px breakpoint"]},v))]}):D("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:O??"",onChange:(v)=>{let r=bQ[v.currentTarget.value];if(r)w(r.width,r.height)},children:[z("option",{value:"",disabled:!0,children:O?bQ[O].label:"Preset size…"}),Object.entries(bQ).map(([v,r])=>D("option",{value:v,children:[r.label," — ",r.width,"×",r.height]},v))]})}),z("div",{style:{padding:"0 12px 8px"},children:z(uN,{value:k?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(v)=>f(v==="fixed")})}),z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Kind"})}),z("div",{style:{padding:"0 12px 8px"},children:z(cW,{value:x,ariaLabel:"artboard kind",options:ML0.map(([v,r])=>({value:v,label:r})),onChange:d})}),x!=="print"&&K&&H?z("div",{style:{padding:"0 12px 8px"},children:D("select",{className:"st-cp-nsel","aria-label":"duplicate artboard at breakpoint width",value:"",onChange:(v)=>{let r=bQ[v.currentTarget.value];if(r)H(K,r.width);v.currentTarget.value=""},children:[z("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(bQ).map(([v,r])=>D("option",{value:v,children:[r.label," — ",r.width,"px"]},v))]})}):null,x==="print"?D(Q0,{children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Print"})}),z("div",{style:{padding:"0 12px 8px"},children:z(uN,{value:m?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(v)=>a({orientation:v})})}),z("div",{style:{padding:"0 12px 8px"},children:z(zJ,{value:Number.isFinite(m?.bleedMm)?m.bleedMm:3,min:0,step:0.5,ariaLabel:"bleed, millimeters",lead:"B",steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"mm"}),onCommit:(v)=>a({bleedMm:v})})})]}):null,z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Style"})}),D("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let v=M(R),r=/var\(\s*--/.test(R),e=r?R.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):R;return z(W3,{swatch:z(zL,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:N("color"),current:R,activeDs:V,swatchBg:v,seedHex:qL(v)||"#000000",onPick:(c)=>p({background:c||null}),label:"artboard background colour"}),displayValue:e,bound:r,ariaLabel:"artboard background",onValue:(c)=>p({background:(c||"").trim()||null})})})(),z(cW,{value:C,ariaLabel:"artboard body layout",options:DL0.map(([v,r])=>({value:v,label:r})),onChange:(v)=>p({layout:v||null})}),D("div",{style:{display:"flex",gap:8},children:[z(pN,{value:/^var\(/.test($)?$:Number.parseFloat($)||0,tokens:F("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(v)=>p({padding:typeof v==="string"?v:v>0?v:null})}),z(pN,{value:/^var\(/.test(j)?j:Number.parseFloat(j)||0,tokens:F("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(v)=>p({gap:typeof v==="string"?v:v>0?v:null})})]})]})]})}var Zk=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,AL0=new RegExp(Zk.source,"gi");function _L0(J){if(!J||Array.isArray(J))return null;if(J.photoAsset)return J.photoAsset;let X=J.html||"";if((J.tag||"").toLowerCase()!=="img"){let W=[...new Set(X.match(AL0)||[])],G=[...new Set([...X.matchAll(/data-photo-asset="([^"]+)"/g)].map((Z)=>Z[1]))];if(G.length===1)return G[0];if(G.length===0&&W.length===1&&/<img/i.test(X))return W[0];return null}let Q=/data-photo-asset="([^"]+)"/.exec(X);if(Q)return Q[1];let Y=Zk.exec(`${J.attrs?.src||""} ${X}`);return Y?Y[0]:null}function wL0({testId:J,selected:X,onClose:Q,layersTree:Y,componentMap:W,lockedKeys:G,onToggleLock:Z,onDetachInstance:H,canvasFile:K,onSelectLayer:U,onHoverLayer:V,onReorderLayer:B,layersBusyRef:N,cfg:F,onOptimistic:M,onRecordEdit:A,onReplaceMedia:E,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:I,onSetArtboardKind:k,onSetArtboardPrint:R,onDuplicateArtboard:$,onUndoRedo:C,editScope:j,tab:x,onTabChange:m,width:d,resizing:a,photoSel:f,photoRev:h,onPhotoEdit:p,onPhotoRemoveBackground:v,onPhotoRecordEdit:r,onPhotoUndoRedo:e,layersOnly:c=!1,hideLayersTab:K0=!1,cpMode:s,onSetCpMode:z0}){let[o,q0]=u.useState("inspect"),Z0=c?"layers":x??o,k0=(l0)=>{q0(l0),m?.(l0)},[a0,s0]=u.useState(()=>new Set),[t0,E9]=u.useState(()=>new Map);u.useEffect(()=>{let l0=Array.isArray(X)?X[0]:X,d0=l0?.id;if(!d0||!Y?.nodes)return;let h0=l0.index,y0=null,B9=[];if(function D9(N0,o0){for(let h9 of N0||[]){let g9=`${h9.id}:${h9.index}`;if(!h9.synthetic&&h9.id===d0&&(h0==null||h9.index===h0))return y0=g9,B9.push(...o0),!0;if(h9.children&&h9.children.length&&D9(h9.children,[...o0,g9]))return!0}return!1}(Y.nodes,[]),!y0)return;if(B9.length)s0((D9)=>{let N0=!1,o0=new Set(D9);for(let h9 of B9)if(o0.delete(h9))N0=!0;return N0?o0:D9});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${y0}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[X,Y]);let a9=(l0)=>{let d0=`${l0.id}:${l0.index}`;return t0.has(d0)?t0.get(d0):!!l0.hidden},[F9,T9]=u.useState(null),[I0,w0]=u.useState(""),C0=(l0,d0)=>{if(!K||!l0?.id)return;fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:K,id:l0.id,attr:"data-dc-element",value:d0})}).then((h0)=>h0.json().catch(()=>({}))).then((h0)=>{if(!h0.ok)return;A?.({op:"attr",canvas:K,id:l0.id,key:"data-dc-element",before:l0.dcElement??null,after:d0})}).catch(()=>{})},W9=B?(l0,d0,h0)=>{if(N?.current)return;if(l0?.synthetic||d0?.synthetic)return;let y0=h0==="before"?`before ${d0.label}`:h0==="after"?`after ${d0.label}`:`into ${d0.label}`;w0(`Moved ${l0.label} ${y0}`),B(l0.id,d0.id,h0,{idIndex:l0.index,refIndex:d0.index})}:void 0,H9=()=>{let l0=[];return function d0(h0,y0,B9){(h0||[]).forEach((D9,N0)=>{if(l0.push({node:D9,depth:y0,parentNode:B9,siblings:h0,pos:N0}),D9.children&&D9.children.length&&!a0.has(`${D9.id}:${D9.index}`))d0(D9.children,y0+1,D9)})}(Y?.nodes,0,null),l0},x9=(l0)=>{if(l0.key!=="ArrowUp"&&l0.key!=="ArrowDown")return;if(!L9)return;let d0=H9(),h0=d0.findIndex((N0)=>N0.node.id===L9.id&&N0.node.index===L9.index);if(h0<0)return;let y0=l0.key==="ArrowDown"?1:-1,B9=d0[h0];if(!l0.altKey){let N0=d0[h0+y0];if(N0)l0.preventDefault(),U?.(N0.node);return}if(!W9||!Array.isArray(B9.siblings))return;l0.preventDefault();let D9=(N0)=>N0&&N0.children&&N0.children.length&&!a0.has(`${N0.id}:${N0.index}`);if(!l0.shiftKey){if(y0<0&&B9.pos>0)W9(B9.node,B9.siblings[B9.pos-1],"before");else if(y0>0&&B9.pos<B9.siblings.length-1)W9(B9.node,B9.siblings[B9.pos+1],"after");return}if(y0>0){let N0=B9.siblings[B9.pos+1];if(N0)W9(B9.node,N0,D9(N0)?"inside-start":"after");else if(B9.parentNode)W9(B9.node,B9.parentNode,"after")}else{let N0=B9.siblings[B9.pos-1];if(N0)W9(B9.node,N0,D9(N0)?"inside-end":"before");else if(B9.parentNode)W9(B9.node,B9.parentNode,"before")}},S9=u.useRef(null),O8=u.useRef(null),v0=(l0,d0,h0)=>{if(!W9||l0.button!==0||l0.metaKey||l0.ctrlKey||l0.shiftKey||l0.altKey)return;if(N?.current)return;let{clientX:y0,clientY:B9}=l0,D9=new Set([h0]);(function c9(O0){(O0.children||[]).forEach((K9)=>{D9.add(`${K9.id}:${K9.index}`),c9(K9)})})(d0);let N0=14,o0=6,h9=[];(function c9(O0,K9){(O0||[]).forEach((C9)=>{let V8=`${C9.id}:${C9.index}`;if(h9.push({node:C9,key:V8,id:C9.id,depth:K9,tag:C9.tag}),C9.children&&C9.children.length&&!a0.has(V8))c9(C9.children,K9+1)})})(Y?.nodes,0);let g9=new Map(h9.map((c9)=>[c9.key,c9])),e0=!1,a7=(c9)=>{if(!e0){if(Math.hypot(c9.clientX-y0,c9.clientY-B9)<4)return;e0=!0}let O0=c9.clientX-y0,K9=c9.clientY-B9,C9=null,V8=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((i8)=>({rect:i8.getBoundingClientRect(),it:g9.get(i8.getAttribute("data-layer-key"))})).filter((i8)=>i8.it&&i8.it.key!==h0);if(V8.length){let i8=V8[0].rect.left,h8=V8[0].rect.right,t=V8.length;for(let e8=0;e8<V8.length;e8++)if(c9.clientY<V8[e8].rect.top+V8[e8].rect.height/2){t=e8;break}let M0=V8[t-1]?.it||null,_0=V8[t]?.it||null,f0=Math.round((c9.clientX-i8-o0)/N0),Y9=M0?M0.depth+(FL0.has(M0.tag)?0:1):0,m9=_0?_0.depth:0,e9=Math.max(m9,Math.min(f0,Y9)),y9=null,W8="before",k8=0;if(!M0){if(_0)y9=_0,W8="before",k8=_0.depth}else if(e9>M0.depth)y9=M0,W8="inside-start",k8=M0.depth+1;else if(e9===M0.depth)y9=M0,W8="after",k8=M0.depth;else{for(let e8=t-1;e8>=0;e8--)if(V8[e8].it.depth===e9){y9=V8[e8].it;break}if(!y9)y9=M0;W8="after",k8=e9}if(y9&&y9.key!==h0&&!D9.has(y9.key)){let e8=M0?V8[t-1].rect.bottom:V8[0].rect.top,J7=i8+o0+k8*N0;C9={refId:y9.id,position:W8,node:y9.node,y:e8,left:J7,w:Math.max(24,h8-J7)}}}let x8={key:h0,node:d0,dx:O0,dy:K9,target:C9};S9.current=x8,T9(x8)},F8=()=>{window.removeEventListener("pointermove",a7),window.removeEventListener("pointerup",I9),window.removeEventListener("keydown",Q8,!0)},v7=()=>{let c9=(O0)=>{O0.preventDefault(),O0.stopImmediatePropagation(),document.removeEventListener("click",c9,!0)};document.addEventListener("click",c9,!0),setTimeout(()=>document.removeEventListener("click",c9,!0),300)},I9=()=>{F8();let c9=S9.current;if(S9.current=null,T9(null),e0&&c9?.target)v7(),W9(c9.node,c9.target.node,c9.target.position)},Q8=(c9)=>{if(c9.key!=="Escape")return;if(c9.preventDefault(),c9.stopImmediatePropagation(),F8(),S9.current=null,T9(null),e0)v7()};window.addEventListener("pointermove",a7),window.addEventListener("pointerup",I9),window.addEventListener("keydown",Q8,!0)},$9=(l0)=>s0((d0)=>{let h0=new Set(d0);if(h0.has(l0))h0.delete(l0);else h0.add(l0);return h0}),w8=(l0)=>{let d0=`${l0.id}:${l0.index}`,h0=a9(l0),y0=!h0;if(E9((B9)=>new Map(B9).set(d0,y0)),M?.({id:l0.id,artboardId:Y?.artboardId??null,index:l0.index,prop:"display",value:y0?"none":null}),!K||!l0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(y0?{canvas:K,id:l0.id,property:"display",value:"none"}:{canvas:K,id:l0.id,property:"display",reset:!0})}).catch(()=>{}),A?.({op:"css",canvas:K,id:l0.id,key:"display",before:h0?"none":null,after:y0?"none":null})},L9=Array.isArray(X)?X[0]:X,V0=f?{asset:f.asset,kind:"annotation-image"}:(()=>{let l0=_L0(L9);return l0?{asset:l0,kind:"artboard-img"}:null})(),J9=V0?.kind==="annotation-image",r0=(l0)=>{if(!(l0.metaKey||l0.ctrlKey)||l0.altKey)return;let d0=l0.key.toLowerCase();if(d0==="z")l0.preventDefault(),e?.(l0.shiftKey?"redo":"undo");else if(d0==="y")l0.preventDefault(),e?.("redo")},b0=J9?"photo":Z0==="photo"&&!V0?"css":Z0,X9=(l0,d0,h0)=>D("button",{type:"button",className:"st-rp-tab"+(b0===l0?" is-active":""),onClick:()=>k0(l0),children:[z(T8,{name:h0,size:14}),d0]}),q9=L9?.bounds||null;return D("aside",{className:"st-rpanel"+(a?" is-resizing":""),style:d?{width:d,flexBasis:d}:void 0,"aria-label":"Inspector","data-tour":"inspector","data-testid":J,children:[D("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:c?{display:"none"}:void 0,children:[J9?X9("photo","Photo","image"):D(Q0,{children:[X9("inspect","Inspect","sliders"),!K0&&X9("layers","Layers","layers"),X9("css","CSS","code"),V0?X9("photo","Photo","image"):null]}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:Q,children:z(T8,{name:"x",size:14})})]}),L9?.id&&!(Array.isArray(X)&&X.length>1)&&j?D("div",{className:`st-scope st-scope--${j.scope}`,title:j.scope==="shared"?`Editing this element's style changes ${j.affects} place${j.affects===1?"":"s"}${j.componentName?` (component ${j.componentName})`:""}. Move/resize a whole instance to keep it local.`:"This edit affects only this element.",children:[z("span",{className:"st-scope-dot","aria-hidden":"true"}),j.scope==="shared"?`Shared${j.componentName?` · ${j.componentName}`:""} · edits ${j.affects} place${j.affects===1?"":"s"}`:"Local · this element only",j.scope==="shared"&&H?z("button",{type:"button",className:"st-scope-detach",title:"Clone this component for this instance only — edits stop affecting the other places",onClick:()=>H(L9.id,L9.index),children:"Detach"}):null]}):null,z("div",{className:"st-rp-body",children:b0==="photo"&&V0?z("div",{onKeyDown:r0,children:z(Ym,{asset:V0.asset,ColorPicker:I80,StIcon:T8,onEdit:(l0)=>p?.(V0.asset,l0),onRemoveBackground:v,onRecordEdit:(l0,d0)=>r?.(V0.asset,l0,d0)},`${V0.asset}:${h??0}`)}):!L9&&!(b0==="layers"&&Y?.nodes?.length)?z("div",{className:"st-rp-empty",children:D("p",{children:["Press ",z(CJ,{children:"V"}),", then click an element to select it — or ",z(CJ,{children:"⌘"}),"-click straight from Browse."]})}):L9&&b0==="inspect"?D(Q0,{children:[z("div",{className:"st-rp-hd",children:L9.selector||L9.tag||"element"}),D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Pos"}),D("div",{className:"st-insp-fields",children:[D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"X"}),z("input",{value:q9?Math.round(q9.x):"—",readOnly:!0,"aria-label":"x position"})]}),D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"Y"}),z("input",{value:q9?Math.round(q9.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Size"}),D("div",{className:"st-insp-fields",children:[D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"W"}),z("input",{value:q9?Math.round(q9.w):"—",readOnly:!0,"aria-label":"width"})]}),D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"H"}),z("input",{value:q9?Math.round(q9.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Tag"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:L9.tag||"—"})})]}),L9.classes?D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Class"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:L9.classes})})]}):null,z(LL0,{el:L9})]}):b0==="layers"?D(Q0,{children:[D("div",{className:"st-rp-hd",children:["Layers",Y?.nodes?.length?"":" · ancestry"]}),Y?.nodes?.length?D(Q0,{children:[W9?z("div",{className:"st-rp-hint","aria-hidden":"true",children:"Drag or ↑/↓ select · Alt+↑/↓ move · Alt+Shift+↑/↓ move across"}):null,z("div",{role:"tree","aria-label":"Artboard layers",tabIndex:0,ref:O8,onKeyDown:x9,children:Y.nodes.map((l0,d0)=>z(T80,{node:l0,depth:0,selectedId:L9?.id,selectedIndex:L9?.index,collapsed:a0,hiddenOverride:t0,onToggle:$9,onSelect:(h0)=>{U?.(h0),O8.current?.focus()},onHover:(h0)=>V?.(h0),onToggleVisibility:w8,onReorder:W9,onRowPointerDown:v0,dragState:F9,componentMap:W,lockedKeys:G,onToggleLock:Z,onRename:C0},`${l0.id}:${l0.index}`))}),F9?.target?z("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:F9.target.left,top:F9.target.y-1,width:F9.target.w}}):null,z("div",{className:"sr-only",role:"status","aria-live":"polite",children:I0})]}):L9&&Array.isArray(L9.dom_path)&&L9.dom_path.length?L9.dom_path.map((l0,d0)=>D("div",{className:"st-layer"+(d0===L9.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+d0*12},children:[z(T8,{name:"square",size:13}),l0]},d0)):z("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!L9.id&&k80(L9)?z(OL0,{el:L9,cfg:F,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:I,onSetArtboardKind:k,onSetArtboardPrint:R,onDuplicateArtboard:$}):z(UL0,{el:L9,cfg:F,onOptimistic:M,onRecordEdit:A,onReplaceMedia:E,onUndoRedo:C,mode:s,onSetMode:z0})})]})}function EL0(){let[J,X]=u.useState([]),[Q,Y]=u.useState(!1),W=u.useRef("push"),G=u.useRef(null),[Z,H]=u.useState("Design"),[K,U]=u.useState([]),[V,B]=u.useState(null),[N,F]=u.useState(null),M=u.useCallback((b)=>{W.current="push",F(b)},[]),[A,E]=u.useState(null),w=u.useRef(null);u.useEffect(()=>{w.current=A},[A]);let[O,I]=u.useState(null);u.useEffect(()=>{let b=Array.isArray(A)?A.length===1?A[0]:null:A,S=b&&typeof b.id==="string"?b.id:null;if(!S||!V){I(null);return}let i=new AbortController,X0=new URLSearchParams({canvas:V,id:S});return fetch(`/_api/edit-scope?${X0}`,{signal:i.signal}).then((H0)=>H0.ok?H0.json():null).then((H0)=>{if(H0?.ok)I(H0)}).catch(()=>{}),()=>i.abort()},[A,V]);let k=u.useRef(0),R=u.useRef([]),$=u.useCallback((b)=>{if(!b?.id||!b.file)return;for(let S of R.current)clearTimeout(S);R.current=[50,450,1200,2500,5000].map((S)=>setTimeout(()=>{let i=w.current,X0=Array.isArray(i)?i[0]:i;if(!X0||X0.id!==b.id||X0.file!==b.file)return;let H0=i9.current.get(b.file);if(!H0?.contentWindow)return;try{H0.contentWindow.postMessage({dgn:"select-by-id",id:b.id,artboardId:b.artboardId??null,index:b.index??0},"*")}catch{}},S))},[]),C=u.useRef([]),j=u.useCallback((b,S)=>{if(!b||!S)return;for(let i of C.current)clearTimeout(i);C.current=[50,450,1200,2500,5000].map((i)=>setTimeout(()=>{let X0=w.current,H0=Array.isArray(X0)?X0[0]:X0;if(!H0||H0.artboardId!==b||H0.file!==S)return;let F0=i9.current.get(S);if(!F0?.contentWindow)return;try{F0.contentWindow.postMessage({dgn:"select-by-id",artboardId:b},"*")}catch{}},i))},[]),x=u.useRef(null),m=u.useRef(null),d=u.useRef(null);d.current=(b,S,i)=>{let X0=x.current;if(!X0||!X0.movedId)return;if(X0.staleSig!=null&&S===X0.staleSig)return;if(!function A0(l){return(l||[]).some((D0)=>D0.id===X0.movedId||A0(D0.children))}(b))return;x.current=null;let F0=V?i9.current.get(V)?.contentWindow:null;if(F0)try{F0.postMessage({dgn:"select-by-id",id:X0.movedId,artboardId:i,index:0},"*")}catch{}};let a=u.useRef(null),f=u.useRef(null),h=u.useRef(null),p=u.useRef(!1),v=u.useRef(null),[r,e]=u.useState(null),[c,K0]=u.useState(null),s=u.useRef({canvas:null,at:0});u.useEffect(()=>{if(!V||!r)return;let b=Date.now(),S=s.current;if(S.canvas===V&&b-S.at<1500)return;s.current={canvas:V,at:b},fetch(`/_api/component-map?canvas=${encodeURIComponent(V)}`).then((i)=>i.json()).then((i)=>{if(i?.ok&&i.map&&typeof i.map==="object")K0(i.map);else K0(null)}).catch(()=>K0(null))},[V,r]);let[z0,o]=u.useState(!1),[q0,Z0]=u.useState(null),[k0,a0]=u.useState(null),s0=u.useRef(null);u.useEffect(()=>{let b=k0?.files?.progress;if(!b)return;let S=s0.current;if(s0.current=b.phase,S===null||S===b.phase)return;if(b.phase==="converged"&&(S==="seeding"||S==="paused"))YL("Project synced",`${b.delivered} files are up to date.`);else if(b.phase==="blocked"){let i=(b.blocked??[]).reduce((X0,H0)=>X0+H0.count,0);YL("Sync needs a decision",`${i} file${i===1?"":"s"} could not be sent. Open the Sync panel for the reason.`)}},[k0?.files?.progress]),u.useEffect(()=>{if(typeof document>"u")return;let b=k0?.files?.progress,S=document.title.replace(/\s+—\s+syncing\s+\d+\/\d+$/,"");if(b&&(b.phase==="seeding"||b.phase==="paused")&&b.tracked>0)document.title=`${S} — syncing ${b.delivered}/${b.tracked}`;else document.title=S;return},[k0?.files?.progress]);let[t0,E9]=u.useState(null),[a9,F9]=u.useState(null),[T9,I0]=u.useState(null),[w0,C0]=u.useState(null),[W9,H9]=u.useState(!1),[x9,S9]=u.useState(!1),[O8,v0]=u.useState(null),[$9,w8]=u.useState(""),[L9,V0]=u.useState(null),[J9,r0]=u.useState(null),b0=u.useRef(null),[X9,q9]=u.useState(null),[l0,d0]=u.useState(0),[h0,y0]=u.useState(null),B9=s90("maude-sb-w",{min:200,max:420,def:252}),D9=s90("maude-rp-w",{min:260,max:480,def:304}),[N0,o0]=u.useState(null),h9=u.useRef(null);u.useEffect(()=>{if(!N0)return;let b=(i)=>{let X0=h9.current?.getBoundingClientRect();if(!X0)return;if(N0==="sb")B9.setW(i.clientX-X0.left);else D9.setW(X0.right-i.clientX)},S=()=>o0(null);return window.addEventListener("pointermove",b),window.addEventListener("pointerup",S),()=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",S)}},[N0,B9.setW,D9.setW]);let g9=u.useCallback((b)=>{clearTimeout(b0.current),b0.current=setTimeout(()=>{r0((S)=>S===b?null:S)},2500)},[]),[e0,a7]=u.useState({designRel:".design",cloud:void 0});u.useEffect(()=>{if(!J9)return;let b=J9,S=setTimeout(async()=>{let i="compile";try{if(!(await fetch(`${e0?.canvasOrigin||""}/_health`,{cache:"no-store"})).ok)i="server"}catch{i="server"}q9({path:b,kind:i}),r0((X0)=>X0===b?null:X0)},15000);return()=>clearTimeout(S)},[J9,e0?.canvasOrigin]);let F8=!!e0.cloud,v7=!e0.cloud&&!!t0?.credentialed,I9=F8||v7,Q8=I9?0:T9?.files?.length||0,c9=u.useRef(I9);c9.current=I9;let O0=!!e0.readOnly,K9=u.useCallback(()=>{fetch("/_config").then((b)=>b.json()).then((b)=>{let S=(b.designRoot||".design").replace(/^\/+|\/+$/g,"");a7((i)=>({...i,designRel:S,tokensCssRel:b.tokensCssRel,designSystems:b.designSystems,canvasOrigin:b.canvasOrigin,readOnly:!!b.readOnly,canvasToken:b.canvasToken,version:b.version,cloud:b.cloud??null,exportLane:b.exportLane}))}).catch(()=>{})},[]);u.useEffect(()=>{K9()},[K9]),u.useEffect(()=>{let b=!1;return fetch("/_sync-status").then((S)=>S.json()).then((S)=>{if(b||!S||S.linked===!1)return;a0(S)}).catch(()=>{}),()=>{b=!0}},[]),u.useEffect(()=>{if(I9){I0(null);return}let b=!1;return fetch("/_api/git/status").then((S)=>S.json()).then((S)=>{if(!b&&S)I0(S)}).catch(()=>{}),()=>{b=!0}},[I9]);let[C9,V8]=u.useState({}),[x8,i8]=u.useState(null),[h8,t]=u.useState(!1),[M0,_0]=u.useState("open"),[f0,Y9]=u.useState(UF0),[m9,e9]=u.useState(()=>{return Jk(u90,"advanced")==="designer"?"designer":"advanced"});u.useEffect(()=>{try{localStorage.setItem(u90,JSON.stringify(m9))}catch{}},[m9]);let[y9,W8]=u.useState(null),[k8,e8]=u.useState(()=>IH(p90,!0)),[J7,D5]=u.useState(()=>IH(g90,!1)),[rX,BJ]=u.useState(()=>Jk(m90,{})),[iJ,oJ]=u.useState(!1),[e7,W4]=u.useState(!1);u.useEffect(()=>{if(!G8())return;let b=Xh(()=>W4(!0));return()=>{b.then((S)=>S()).catch(()=>{})}},[]);let[R7,FX]=u.useState(!1),[j8,qY]=u.useState(!1),[p7,jQ]=u.useState(!1),[HG,f7]=u.useState(!1),[BY,LX]=u.useState(!1),{report:V7}=bw(G8()),[nJ,l8]=u.useState(!1),[q7,z6]=u.useState(!1),[$J,vQ]=u.useState(null),[M5,P6]=u.useState(null),[G4,O5]=u.useState(!1),[zG,SJ]=u.useState(!1),[bJ,rJ]=u.useState(!1),[fQ,Z4]=u.useState(!1),[NJ,H4]=u.useState(()=>Jk(i90,sK)),[n,W0]=u.useState(()=>{try{let b=localStorage.getItem(o90);if(b==="separate"||b==="in-inspector")return b}catch{}return"separate"}),[L0,j0]=u.useState(!1),[E0,z9]=u.useState([]),[O9,Z8]=u.useState(0),[L8,I6]=u.useState(!1),[A5,s6]=u.useState(!1),[FJ,xQ]=u.useState(!1),[TH,KG]=u.useState(1),[yJ,C7]=u.useState(216),[R8,DX]=u.useState(null),[K6,t9]=u.useState([]),[J6,x6]=u.useState([]),[MX,_5]=u.useState([]),[aX,kH]=u.useState(0),OX=u.useRef(0);u.useEffect(()=>{OX.current=O9},[O9]);let[X6,RH]=u.useState(null),AX=u.useRef(null);u.useEffect(()=>{AX.current=X6},[X6]);let T6=u.useMemo(()=>gw(E0,{artboardId:[X6,R8],total:aX}),[E0,X6,R8,aX]),sX=u.useRef(null);u.useEffect(()=>{sX.current=T6},[T6]);let NY=u.useMemo(()=>TK(E0,T6)?.fps||30,[E0,T6]),[CH,FY]=u.useState(null),[LY,X1]=u.useState(0),LJ=u.useCallback((b,S)=>{if(/concurrent edit|changed since it was read/i.test(S||""))f9("Timeline changed — reloaded, try again."),X1((i)=>i+1);else f9(`${b}: ${S||"failed"}`)},[]),[_X,UG]=u.useState(!1),[Q1,$H]=u.useState(!1),[Y1,VG]=u.useState(!1),qG=u.useRef(_X);u.useEffect(()=>{if(qG.current=_X,_X){VG(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[_X]);let SH=u.useCallback(()=>{if(!qG.current||document.hidden)VG(!0),YL("Claude finished","Your assistant turn is ready in Maude.")},[]),bH=u.useRef(0),DY=u.useCallback(()=>{if(!qG.current||document.hidden){VG(!0);let b=Date.now();if(b-bH.current<ZF0)return;bH.current=b,YL("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[hQ,tX]=u.useState("inspect"),[BG,MY]=u.useState(null),w5=u.useRef({undo:[],redo:[]}),[NG,FG]=u.useState(0),[U6,LG]=u.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),OY=u.useRef(U6);u.useEffect(()=>{OY.current=U6;try{localStorage.setItem("maude-auto-open-inspector",U6?"1":"0")}catch{}},[U6]);let yH=u.useRef(!1);u.useEffect(()=>{yH.current=bJ||h8||W9||x9||_X},[bJ,h8,W9,x9,_X]);let DG=u.useRef({open:{},side:sK});DG.current={open:{tree:k8,layers:fQ,inspector:bJ,comments:h8,changes:W9,sync:x9,assistant:_X},side:NJ};let z4=u.useCallback((b,S)=>{if(b==="tree")e8(S);else if(b==="layers")Z4(S);else if(b==="inspector")rJ(S);else if(b==="comments")t(S);else if(b==="changes")H9(S);else if(b==="sync")S9(S);else if(b==="assistant")UG(S)},[]),MG=u.useCallback((b)=>DG.current.side?.[b]||sK[b],[]),k6=u.useCallback((b)=>{let S=MG(b);z4(b,!0);for(let i of Wk)if(i.id!==b&&MG(i.id)===S)z4(i.id,!1)},[z4,MG]),wX=u.useCallback((b)=>{if(DG.current.open?.[b])z4(b,!1);else k6(b)},[k6,z4]),eX=k6,h6=wX,OG=u.useCallback((b)=>{if(!OY.current)return;if(O0)return;if(!b||!b.id)return;if(yH.current)return;eX("inspector"),tX("css")},[eX,O0]),AY=u.useCallback(()=>j0((b)=>!b),[]),E5=Pm(Gk),K4=zm({enabled:e0.cloud===null||e0.exportLane==="remote"}),[jH,W1]=u.useState(!1),[vH,JQ]=u.useState(!1);u.useEffect(()=>{if(!G8())return;let b=!0;return Gh().then((S)=>{if(!b)return;if(W1(!!S),!S&&!IH(h90,!1))JQ(!0)}).catch(()=>{}),()=>{b=!1}},[]);let DJ=u.useCallback(()=>{JQ(!1);try{localStorage.setItem(h90,"1")}catch{}},[]),[AG,fH]=u.useState(null);u.useEffect(()=>{if(!G8())return;let b;return Uh((S)=>fH(S&&typeof S==="object"?S:{})).then((S)=>{b=S}).catch(()=>{}),()=>{try{b?.()}catch{}}},[]);let[U4,P5]=u.useState(null),[I5,_G]=u.useState(()=>!IH(x90,!1)),EX=u.useCallback((b)=>{P5(Array.isArray(b)&&b.length?b:null)},[]),wG={setup:(b)=>{if(!b)return;if((b.canvas||b.requireSelection)&&K.length===0)k6("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [role="treeitem"]')?.click()}catch{}},80);if(b.inspector||b.tab||b.requireSelection)eX("inspector");if(b.tab)tX(b.tab);if(b.changes)eX("changes")}},V4=u.useCallback(()=>{_G(!1);try{localStorage.setItem(x90,"1")}catch{}},[]),[XQ,_Y]=u.useState(()=>IH(c90,!0)),[xH,EG]=u.useState(!1),[QQ,wY]=u.useState(()=>IH(l90,!1)),[g6,U0]=u.useState(()=>IH(d90,!1)),[jJ,q4]=u.useState(!1),[PG,aJ]=u.useState(!1),[l7,sJ]=u.useState(0),[gQ,IG]=u.useState(null),[TG,EY]=u.useState(!1),mQ=u.useRef(null),T5=u.useRef(null),i9=u.useRef(new Map);u.useEffect(()=>{if(!e0?.canvasToken)return;let b=!1,S=null,i=0,X0=(A0)=>{clearTimeout(S);let l=jb(A0);i=Date.now()+l,S=setTimeout(H0,l)};async function H0(){let A0=null;try{let D0=await fetch("/_config",{cache:"no-store",credentials:"same-origin"});if(D0.ok)A0=(await D0.json())?.canvasToken}catch{}if(b)return;if(typeof A0!=="string"||!A0){clearTimeout(S),i=Date.now()+30000,S=setTimeout(H0,30000);return}yb(A0);let l=null;try{l=new URL(e0.canvasOrigin,location.href).origin}catch{}if(l)for(let D0 of i9.current.values())try{D0.contentWindow?.postMessage({dgn:"canvas-cap",t:A0},l)}catch{}X0(A0)}X0(e0.canvasToken);let F0=()=>{if(document.visibilityState==="visible"&&Date.now()>=i)H0()};return document.addEventListener("visibilitychange",F0),()=>{b=!0,clearTimeout(S),document.removeEventListener("visibilitychange",F0)}},[e0?.canvasToken,e0?.canvasOrigin]);let T0=u.useCallback((b)=>{let S=V?i9.current.get(V):null;if(!S||!S.contentWindow)return;try{S.contentWindow.postMessage(b,"*")}catch{}},[V]),tJ=u.useRef(0),k5=u.useCallback(({format:b,artboardIds:S=null,scale:i=1,onProgress:X0,timeoutMs:H0=120000})=>new Promise((F0,A0)=>{let l=V?i9.current.get(V):null;if(!l||!l.contentWindow){A0(Error("no active canvas to capture"));return}let D0=l.contentWindow;tJ.current+=1;let P0=`cap-${Date.now().toString(36)}-${tJ.current}`,i0=!1,_9=(w7,d8)=>{if(i0)return;i0=!0,window.removeEventListener("message",A9),clearTimeout(q6),w7(d8)},A9=(w7)=>{if(w7.source!==D0)return;let d8=w7.data;if(!d8||d8.id!==P0)return;if(d8.dgn==="export-capture-progress")X0?.(d8.current,d8.total);else if(d8.dgn==="export-capture-done")_9(F0,Array.isArray(d8.items)?d8.items:[]);else if(d8.dgn==="export-capture-error")_9(A0,Error(d8.message||"capture failed"))},q6=setTimeout(()=>_9(A0,Error("capture timed out — the canvas did not answer")),H0);window.addEventListener("message",A9);try{D0.postMessage({dgn:"export-capture",id:P0,format:b,artboardIds:S,scale:i},"*")}catch(w7){_9(A0,w7)}}),[V]),Q9=u.useCallback((b,S)=>T0({dgn:"photo-preview",asset:b,edit:S}),[T0]),B4=u.useCallback((b,S,i)=>{w5.current.undo.push({asset:b,before:S,after:i}),w5.current.redo.length=0},[]),G9=u.useCallback((b)=>{let S=b?w5.current.redo:w5.current.undo;if(!S.length)return!1;let i=S.pop();(b?w5.current.undo:w5.current.redo).push(i);let X0=(b?i.after:i.before)||{};return Q9(i.asset,X0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(i.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(X0)}).catch(()=>{}),FG((H0)=>H0+1),!0},[Q9]),kG=u.useCallback(async(b)=>{T0({dgn:"photo-busy",asset:b,busy:!0});try{let S=await fetch(`/${b.replace(/^\/+/,"")}`);if(!S.ok)return null;let i=await S.blob(),{removeBackground:X0}=await Promise.resolve().then(() => (f90(),v90)),H0=await X0(i),F0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":H0.type||"image/png"},body:H0}),A0=await F0.json().catch(()=>({}));if(F0.ok&&A0.path)return{maskAsset:A0.path};return null}catch(S){return console.error("[photo] background removal failed",S),null}finally{T0({dgn:"photo-busy",asset:b,busy:!1})}},[T0]);u.useEffect(()=>{let b=(X0)=>Array.from(X0.dataTransfer?.types??[]).includes("Files"),S=(X0)=>{if(b(X0))X0.preventDefault()},i=(X0)=>{if(b(X0))X0.preventDefault()};return document.addEventListener("dragover",S),document.addEventListener("drop",i),()=>{document.removeEventListener("dragover",S),document.removeEventListener("drop",i)}},[]);let Q6=u.useRef({});Q6.current={open:L0,comps:E0,frame:O9,total:aX,playing:L8,compId:T6,muted:FJ,loop:A5,sequences:K6,post:T0,canvas:V};let uQ=u.useRef({undo:[],redo:[]}),Y6=u.useCallback((b,S,i)=>{if(typeof S!=="number")return;if(uQ.current.undo.push({canvas:b,seq:S,label:i}),uQ.current.redo=[],uQ.current.undo.length>50)uQ.current.undo.shift()},[]),RG=u.useCallback((b)=>{let S=uQ.current,i=b==="undo"?S.undo:S.redo,X0=b==="undo"?S.redo:S.undo,H0=Q6.current.canvas,F0=-1;for(let l=i.length-1;l>=0;l--)if(i[l].canvas===H0){F0=l;break}if(F0<0){f9(b==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let A0=i[F0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:A0.canvas,seq:A0.seq,dir:b})}).then((l)=>l.json().catch(()=>({}))).then((l)=>{if(i.splice(F0,1),l?.ok)X0.push(A0),f9(`${b==="undo"?"Undid":"Redid"}: ${A0.label}`,!0);else f9(`${b==="undo"?"Undo":"Redo"} skipped: ${l?.error||"failed"}`)}).catch(()=>f9(`${b==="undo"?"Undo":"Redo"} failed: network error`))},[]),R6=u.useCallback((b,S)=>{let i=b?.ok&&Array.isArray(b.clips)?b.clips.filter((X0)=>X0.kind==="sequence"):[];if(S==null)return null;if(typeof S==="object")return(S.stableId?i.find((X0)=>X0.stableId===S.stableId):null)||(Number.isInteger(S.index)?i[S.index]:null)||null;if(typeof S==="string")return i.find((X0)=>X0.stableId===S)||null;return i[S]||null},[]),R5=u.useCallback((b)=>{let S=Q6.current.canvas;if(!S||S===r9)return;let i=AX.current||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(S)}${i?`&artboardId=${encodeURIComponent(i)}`:""}`;fetch(X0).then((H0)=>H0.json().catch(()=>({}))).then((H0)=>{let F0=R6(H0,b);if(!F0?.stableId)return null;return fetch("/_api/remove-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:S,artboardId:i,stableId:F0.stableId,contentHash:F0.contentHash})})}).then((H0)=>H0?H0.json():null).then((H0)=>{if(H0&&!H0.ok)console.warn("[remove-clip]",H0.error||"failed"),LJ("Remove refused",H0.error);else if(H0?.ok){if(f9("Clip removed.",!0),H0.seq!=null)Y6(S,H0.seq,"remove clip");FY(null)}}).catch(()=>f9("Remove failed: network error"))},[R6,Y6]),C5=u.useCallback((b,S,i)=>{let X0=Q6.current.canvas;if(!X0||X0===r9)return;let H0=AX.current||void 0,F0=`/_api/comp-clips?canvas=${encodeURIComponent(X0)}${H0?`&artboardId=${encodeURIComponent(H0)}`:""}`;fetch(F0).then((A0)=>A0.json().catch(()=>({}))).then((A0)=>{let l=A0?.ok&&Array.isArray(A0.clips)?A0.clips:[],D0=b?.transition?l.find((P0)=>P0.kind==="transition"&&P0.stableId===b.stableId)||null:R6(A0,b);if(!D0?.stableId)return null;return fetch("/_api/clip-edit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:X0,artboardId:H0,stableId:D0.stableId,contentHash:D0.contentHash,verb:S,...i})})}).then((A0)=>A0?A0.json():null).then((A0)=>{if(A0&&!A0.ok)console.warn("[clip-edit]",S,A0.error||"failed"),LJ(`${S} refused`,A0.error);else if(A0?.ok){let l={speed:"set speed","trim-in":"trim in-point",audio:"clip audio","detach-audio":"detach audio",framing:"crop clip",grade:"grade clip",transition:"edit transition",split:"split clip","insert-transition":"add transition","remove-transition":"remove transition","set-text":"edit text","to-overlay":"move to overlay layer","to-storyline":"move to storyline","layer-order":"reorder layers"};if(f9(`Applied: ${l[S]||S}.`,!0),A0.seq!=null)Y6(X0,A0.seq,l[S]||S)}}).catch(()=>f9(`${S} failed: network error`))},[R6,Y6,LJ]),[$5,PY]=u.useState(null),YQ=u.useCallback((b,S="")=>new Promise((i)=>{PY({title:b,value:S,resolve:i})}),[]),pQ=u.useCallback((b)=>{PY((S)=>{return S?.resolve?.(b),null})},[]),IY=u.useCallback((b,S)=>{let i=Q6.current.canvas;if(!i||i===r9||!S||!String(S).trim())return;$7({type:"comments-add",payload:{file:i,text:String(S).trim(),selector:"",dom_path:[],tag:"",classes:"",bounds:null,html_excerpt:"",timeline:b}}),f9("Comment added.",!0)},[]);Q6.current.selected=CH,Q6.current.setSelected=FY,Q6.current.removeClip=R5,Q6.current.clipVerb=C5,Q6.current.addComment=IY,Q6.current.askText=YQ,u.useEffect(()=>{let b=(S)=>{let i=Q6.current;if(!i.open||!i.comps?.length)return;let X0=S.target,H0=X0?.tagName;if(H0==="INPUT"&&X0?.type!=="range")return;if(H0==="TEXTAREA"||H0==="SELECT"||X0?.isContentEditable)return;let F0=TK(i.comps,i.compId)?.fps||30,A0=Math.max(1,i.total),l=(P0)=>{let i0=Math.max(0,Math.min(A0-1,Math.round(P0)));Z8(i0),I6(!1),i.post({dgn:"timeline-seek",frame:i0,id:i.compId})},D0=()=>{let P0=new Set([0,A0-1]);for(let i0 of i.sequences||[]){P0.add(i0.from);for(let _9 of i0.keyframes||[])P0.add(_9.from),P0.add(_9.to)}return[...P0].filter((i0)=>i0>=0&&i0<A0).sort((i0,_9)=>i0-_9)};if((S.metaKey||S.ctrlKey)&&(S.key==="z"||S.key==="Z")){S.preventDefault(),RG(S.shiftKey?"redo":"undo");return}if(S.key==="Escape"){if(i.selected!=null)S.preventDefault(),i.setSelected?.(null);return}if((S.key==="Delete"||S.key==="Backspace")&&i.selected!=null){S.preventDefault(),i.removeClip?.({stableId:i.selected});return}if((S.metaKey||S.ctrlKey)&&(S.key==="b"||S.key==="B")){S.preventDefault();let P0=i.selected!=null?{stableId:i.selected}:null;if(!P0){let i0=i.sequences||[],_9=i0.find((A9)=>A9.series&&i.frame>=A9.from&&i.frame<A9.from+A9.duration)||i0.find((A9)=>i.frame>=A9.from&&i.frame<A9.from+A9.duration);if(_9?.stableId)P0={stableId:_9.stableId}}if(P0)i.clipVerb?.(P0,"split",{atFrame:i.frame});else f9("Nothing under the playhead to split.");return}if(S.key===" "||S.code==="Space")if(S.preventDefault(),i.playing)I6(!1),i.post({dgn:"timeline-pause",id:i.compId});else I6(!0),i.post({dgn:"timeline-mute",muted:i.muted,id:i.compId}),i.post({dgn:"timeline-loop",loop:i.loop,id:i.compId}),i.post({dgn:"timeline-play",id:i.compId});else if(S.key==="ArrowRight")S.preventDefault(),l(i.frame+(S.shiftKey?F0:1));else if(S.key==="ArrowLeft")S.preventDefault(),l(i.frame-(S.shiftKey?F0:1));else if(S.key==="Home")S.preventDefault(),l(0);else if(S.key==="End")S.preventDefault(),l(A0-1);else if(S.key==="."){S.preventDefault();let P0=D0().find((i0)=>i0>i.frame);if(P0!=null)l(P0)}else if(S.key===","){S.preventDefault();let P0=D0().reverse().find((i0)=>i0<i.frame);if(P0!=null)l(P0)}};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[]),u.useEffect(()=>{z9([]),Z8(0),I6(!1),FY(null),RH(null);let b=setTimeout(()=>T0({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(b)},[V,T0]);let[lQ,TY]=u.useState(""),[kY,N4]=u.useState([]),[CG,RY]=u.useState([]);u.useEffect(()=>{if(!L0||E0.length===0||!V||V===r9){TY(""),N4([]);return}let b=!0;return fetch(`/_api/canvas-source?file=${encodeURIComponent(V)}`).then((S)=>S.ok?S.json():null).then((S)=>{if(b&&S?.ok&&typeof S.source==="string")TY(S.source)}).catch(()=>{}),()=>{b=!1}},[L0,E0,V,LY]),u.useEffect(()=>{if(!L0||!V||V===r9||!lQ){N4([]),RY([]);return}let b=!0,S=X6||void 0,i=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${S?`&artboardId=${encodeURIComponent(S)}`:""}`;return fetch(i).then((X0)=>X0.ok?X0.json():null).then((X0)=>{if(!b)return;let H0=X0?.ok&&Array.isArray(X0.clips)?X0.clips:[];N4(H0.filter((F0)=>F0.kind==="sequence")),RY(H0.filter((F0)=>F0.kind==="transition"))}).catch(()=>{}),()=>{b=!1}},[L0,V,lQ,X6,LY]),u.useEffect(()=>{if(!lQ){t9([]),x6([]),_5([]),kH(0);return}let b=R8??A?.artboardId??null,i=(b&&E0.find((F0)=>F0.artboardId===b||F0.id===b)||E0[0])?.durationInFrames||0,X0=sg(lQ,i,b);RH(X0.artboardId??b??null);let H0=X0.sequences.map((F0,A0)=>{let l=kY[A0];if(!l)return F0;return{...F0,stableId:l.stableId,contentHash:l.contentHash,mediaProps:l.mediaProps??null,placeholder:l.placeholder??null,mediaTag:l.mediaTag??F0.mediaTag,mediaSrc:l.mediaSrc??F0.mediaSrc,replaceable:!!(l.mediaCdId||l.mediaArrayRef),layers:Array.isArray(l.layers)?l.layers:[],hidden:!!l.hidden}});t9(H0),x6(X0.audio||[]),_5(X0.transitions||[]),kH(X0.total)},[lQ,kY,A,E0,R8]);let CY=u.useCallback(()=>{_Y((b)=>{let S=!b,i=V?i9.current.get(V):null;if(i&&i.contentWindow)try{i.contentWindow.postMessage({dgn:"view-annotations",visible:S},"*")}catch{}return S})},[V]),MJ=u.useCallback((b)=>{for(let S of i9.current.values())try{S.contentWindow.postMessage({dgn:"view-chrome",...b},"*")}catch{}},[]),$Y=u.useCallback(()=>{wY((b)=>{let S=!b;return MJ({minimap:S}),S})},[MJ]),SY=u.useCallback(()=>{U0((b)=>{let S=!b;return MJ({zoom:S}),S})},[MJ]),$G=u.useCallback(()=>{q4((b)=>{let S=!b;return MJ({present:S}),S})},[MJ]),F4=u.useCallback(()=>{q4(!1),MJ({present:!1})},[MJ]),SG=u.useCallback(()=>{if(!V||V===r9)return;aJ((b)=>{let S=!b;return T0({dgn:"view-chrome",print:S}),fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:V,patch:{overlays:{print:S}}})}).catch(()=>{}),S})},[V,T0]);u.useEffect(()=>{let b=!1;return fetch("/_api/git-user").then((S)=>S.json()).then((S)=>{if(b)return;let i=S&&typeof S.name==="string"?S.name.trim():"";if(i)IG(i)}).catch(()=>{}),()=>{b=!0}},[]),u.useEffect(()=>{if(!V||V===r9){sJ(0),aJ(!1);return}let b=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(V)).then((S)=>S.json()).then((S)=>{if(b)return;let i=Array.isArray(S?.artboards)?S.artboards.length:0;sJ(i),aJ(S?.overlays?.print===!0),D4(new Set(Array.isArray(S?.locked)?S.locked:[]))}).catch(()=>{if(!b)sJ(0),aJ(!1),D4(new Set)}),()=>{b=!0}},[V]),u.useEffect(()=>{if(!V||V===r9||!R8)return;let b=setTimeout(()=>{T0({dgn:"request-layers",artboardId:R8})},250);return()=>clearTimeout(b)},[V,R8,T0]);let[L4,D4]=u.useState(()=>new Set),bG=u.useCallback((b)=>{if(!V||V===r9)return;D4((S)=>{let i=new Set(S);if(i.has(b))i.delete(b);else i.add(b);let X0=[...i];return fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:V,patch:{locked:X0}})}).catch(()=>{}),T0({dgn:"locked-set",locked:X0}),i})},[V,T0]);u.useEffect(()=>{if(!V||V===r9)return;T0({dgn:"locked-set",locked:[...L4]})},[L4,V,T0]),u.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",f0),localStorage.setItem(M80,f0)}catch{}for(let b of i9.current.values())try{b.contentWindow.postMessage({dgn:"theme",theme:f0},"*")}catch{}},[f0]),u.useEffect(()=>{try{localStorage.setItem(p90,k8?"1":"0")}catch{}},[k8]),u.useEffect(()=>{try{localStorage.setItem(g90,J7?"1":"0")}catch{}},[J7]),u.useEffect(()=>{try{localStorage.setItem(m90,JSON.stringify(rX))}catch{}},[rX]),u.useEffect(()=>{try{localStorage.setItem(l90,QQ?"1":"0")}catch{}},[QQ]),u.useEffect(()=>{try{localStorage.setItem(d90,g6?"1":"0")}catch{}},[g6]),u.useEffect(()=>{try{localStorage.setItem(c90,XQ?"1":"0")}catch{}},[XQ]),u.useEffect(()=>{let b=!1;return fetch("/_api/ui-prefs").then((S)=>S.ok?S.json():Promise.reject(Error(`HTTP ${S.status}`))).then((S)=>{if(b||!S||typeof S!=="object")return;if(S.theme==="light"||S.theme==="dark")Y9(S.theme);if(typeof S.minimap==="boolean")wY(S.minimap);if(typeof S.zoom==="boolean")U0(S.zoom);if(typeof S.annotations==="boolean")_Y(S.annotations);if(typeof S.autoOpenInspector==="boolean")LG(S.autoOpenInspector);if(S.panelSides&&typeof S.panelSides==="object")H4({...sK,...S.panelSides});if(S.layersMode==="separate"||S.layersMode==="in-inspector")W0(S.layersMode)}).catch(()=>{}).finally(()=>{if(!b)EG(!0)}),()=>{b=!0}},[]),u.useEffect(()=>{if(!xH)return;HF0({theme:f0,minimap:QQ,zoom:g6,annotations:XQ,autoOpenInspector:U6,panelSides:NJ,layersMode:n})},[xH,f0,QQ,g6,XQ,U6,NJ,n]),u.useEffect(()=>{try{localStorage.setItem(i90,JSON.stringify(NJ))}catch{}},[NJ]),u.useEffect(()=>{try{localStorage.setItem(o90,n)}catch{}},[n]);let yG=u.useCallback((b,S)=>{BJ((i)=>{let X0=i[b],H0=X0===void 0?S:X0;return{...i,[b]:!H0}})},[]),M4=u.useCallback(()=>{Y9((b)=>b==="dark"?"light":"dark")},[]),O4=u.useRef(null),y8=u.useCallback(()=>O4.current?.reload()??Promise.resolve(),[]);u.useEffect(()=>{let b=fb({read:async(S)=>{let i=await fetch("/_index-data",{signal:S,cache:"no-store"});if(!i.ok)throw Object.assign(Error(`Project index request failed: ${i.status}`),{status:i.status});let X0=await i.json(),H0=X0.groups.map((F0)=>({...F0,tree:NF0(F0.paths,F0.stripPrefix,F0.dirs)}));return{data:X0,built:H0}},apply:({data:S,built:i})=>{H(S.project||"Design"),X(i),Y(!0),a7((X0)=>({...X0,canvasDesignSystems:S.canvasDesignSystems??{},canvasKinds:S.canvasKinds??{}}))},onError:(S)=>console.error("failed to load tree",S)});return O4.current=b,y8(),()=>{O4.current=null,b.dispose()}},[y8]);let WQ=u.useCallback(async(b)=>{try{let S=b?`/_system-data?ds=${encodeURIComponent(b)}`:"/_system-data",i=await fetch(S);if(!i.ok){console.error("failed to load system-data",i.status);return}let X0=await i.json();if(!b&&X0?.defaultDesignSystem&&!X0.ds){V0(X0);let H0=await fetch(`/_system-data?ds=${encodeURIComponent(X0.defaultDesignSystem)}`);if(H0.ok)V0(await H0.json());return}V0(X0)}catch(S){console.error("failed to load system-data",S)}},[]),bY=u.useCallback(async()=>{try{let S=await(await fetch("/_comments-all")).json();V8(S||{})}catch(b){console.error("failed to load comments",b)}},[]);u.useEffect(()=>{bY()},[bY]);let yY=u.useRef(()=>{});u.useEffect(()=>{let b=null,S=!1;function i(){let X0=location.protocol==="https:"?"wss:":"ws:",H0=new WebSocket(X0+"//"+location.host+"/_ws");T5.current=H0,H0.addEventListener("open",()=>{if(o(!0),S)K9();S=!0,clearInterval(b),b=setInterval(()=>{if(H0.readyState===WebSocket.OPEN)H0.send('{"type":"ping"}')},25000)}),H0.addEventListener("close",()=>{o(!1),clearInterval(b),setTimeout(i,1000)}),H0.addEventListener("error",()=>{}),H0.addEventListener("message",(F0)=>{try{let A0=JSON.parse(F0.data);if(A0.type==="snapshot"&&A0.state)E((l)=>N80(A0.state.selected,l));else if(A0.type==="selected"){if(Date.now()-k.current<2000)return;let l=A0.selected,D0=Array.isArray(l)?l[0]:l,P0=w.current,i0=Array.isArray(P0)?P0[0]:P0;if(E((_9)=>N80(l,_9)),D0?.id&&D0.file&&(!i0||i0.id!==D0.id||i0.file!==D0.file))$(D0)}else if(A0.type==="comments"&&typeof A0.file==="string")V8((l)=>({...l,[A0.file]:A0.comments||[]}));else if(A0.type==="ai-activity"&&typeof A0.file==="string"){if(EY(!0),mQ.current)clearTimeout(mQ.current);mQ.current=setTimeout(()=>EY(!1),8000);for(let l of i9.current.values())try{l.contentWindow.postMessage({dgn:"ai-activity",file:A0.file,entry:A0.entry},"*")}catch{}}else if(A0.type==="export:job"&&A0.payload)K4.upsert(A0.payload);else if(A0.type==="sync:status"&&A0.payload)a0(A0.payload);else if(A0.type==="canvas-list-update")y8(),yY.current(A0.payload);else if(A0.type==="config-updated")K9();else if(A0.type==="acp-focus"){if(G8())eX("assistant")}else if(A0.type==="git-status"&&A0.payload){if(!c9.current)I0(A0.payload)}else if(A0.type==="git-lifecycle"&&A0.payload){Z0(A0.payload);for(let l of i9.current.values())try{l.contentWindow.postMessage({dgn:"git-lifecycle",payload:A0.payload},"*")}catch{}}}catch{}})}return i(),()=>{if(clearInterval(b),T5.current)T5.current.close()}},[y8,K9]);function $7(b){let S=T5.current;try{if(S&&S.readyState===1)S.send(JSON.stringify(b))}catch{}}let OJ=u.useCallback(async()=>{if(c9.current)return;try{let b=await fetch("/_api/git/status");if(b.ok)I0(await b.json())}catch{}},[]),vJ=u.useCallback(async()=>{if(c9.current)return;try{let b=await fetch("/_api/git/status?remote=1");if(!b.ok)return;let S=await b.json();if(S&&S.repo!==!1)C0({remoteAhead:!!S.remoteAhead,behind:S.behind||0})}catch{}},[]),AJ=u.useCallback(async(b,S)=>{try{let i=await fetch(b,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(S||{})}),X0=await i.json().catch(()=>({}));return{ok:i.ok,...X0}}catch(i){return{ok:!1,error:"Network error — is the project still open?"}}},[]),jG=u.useCallback(async(b,S)=>{let i=await AJ("/_api/git/commit",{message:b,files:S});if(i.ok)await OJ();return i},[AJ,OJ]),jY=u.useCallback(async(b)=>{let S=await AJ("/_api/git/discard",{files:b});if(S.ok)await OJ();return S},[AJ,OJ]),vG=u.useCallback(async()=>{let b=await AJ("/_api/git/push",{});if(b.ok)await OJ(),vJ();return b},[AJ,OJ,vJ]),vY=u.useCallback(async()=>{let b=await AJ("/_api/git/pull",{});if(b.ok)await OJ(),vJ();if(b.conflict&&Array.isArray(b.files)&&b.files.length)v0({file:b.files[0],conflict:!0});return b},[AJ,OJ,vJ]),fG=u.useCallback(async(b)=>{let S=await AJ("/_api/git/resolve",{choice:b});if(S.ok)await OJ(),vJ();return S},[AJ,OJ,vJ]),fY=u.useCallback(async(b)=>{try{let S="/_api/git/log?limit=40"+(b?`&path=${encodeURIComponent(b)}`:""),i=await fetch(S);if(!i.ok)return[];return(await i.json()).entries||[]}catch{return[]}},[]),[xG,hG]=u.useState(null),gG=u.useCallback(async(b)=>{try{let S="/_api/cloud/history?limit=40"+(b?`&path=${encodeURIComponent(b)}`:""),i=await fetch(S);if(!i.ok)return null;let X0=await i.json();if(!X0?.ok)return null;return hG({branch:X0.branch??null,project:X0.project??null,hubHost:X0.hubHost??null}),X0.entries||[]}catch{return null}},[]),[mG,uG]=u.useState(!1),pG=u.useCallback(async(b)=>{try{let S="/_api/project/history?limit=40"+(b?`&path=${encodeURIComponent(b)}`:""),i=await fetch(S);if(!i.ok)return"legacy";let X0=await i.json();if(!X0?.ok)return X0?.reason==="legacy"?"legacy":null;return(X0.history||[]).map((H0)=>{let F0=b?"":(H0.canvases||[]).map((A0)=>A0.split("/").pop()).join(", ");return{sha:`r${H0.revision}`,message:[H0.label||H0.kind,F0].filter(Boolean).join(" · "),author:H0.actor,date:new Date(H0.committedAt).toISOString(),accepted:{revision:H0.revision,actionId:H0.actionId,mine:!!H0.mine,undo:H0.kind==="undo"||H0.kind==="redo"}}})}catch{return null}},[]),lG=u.useMemo(()=>{let b={modified:"M",added:"A",deleted:"D",untracked:"U"},S=new Map;if(I9)return S;for(let i of T9?.files||[])S.set(i.path,b[i.status]);return S},[T9,I9]);u.useEffect(()=>{if(I9){C0(null);return}if(T9?.repo===!1)return;vJ();let b=setInterval(vJ,W9?60000:120000);return()=>clearInterval(b)},[I9,T9?.repo,W9,vJ]);let V6=u.useCallback((b)=>{if(W.current="push",i8(null),F(null),b===V)return;if(U((S)=>{for(let i of S)if(i.path!==b)i9.current.delete(i.path);return[{path:b}]}),B(b),q9(null),y0(null),b!==r9)r0(b)},[V]),A4=u.useCallback((b,S="push")=>{let i=J.flatMap((X0)=>X0.paths||[]).find((X0)=>CW(X0,e0.designRel)===b);if(i&&yQ.test(i))V6(i);else if(i&&BL(Y4(i)))M(i);else U([]),B(null),F(null),PQ({title:"Not here yet",description:`${b} is not in this project (not synced yet?)`,kind:"info"});W.current=S},[J,e0.designRel,V6,M]),hH=u.useRef(!1);u.useEffect(()=>{if(!Q||e0.cloud===void 0||hH.current)return;hH.current=!0;let b=PV(location,e0.designRel);if(b)A4(b,"none")},[Q,e0.cloud,e0.designRel,A4]),u.useEffect(()=>{if(!Q||e0.cloud===void 0)return;let b=()=>{let S=PV(location,e0.designRel);if(S)A4(S,"none");else W.current="none",U([]),B(null),F(null)};return window.addEventListener("popstate",b),()=>window.removeEventListener("popstate",b)},[Q,e0.cloud,e0.designRel,A4]),u.useEffect(()=>{let b=N||(V===r9?null:V);if(b===G.current)return;G.current=b;let S=CW(b,e0.designRel);if(W.current!=="none"&&PV(location,e0.designRel)!==S)history[S?"pushState":"replaceState"](S?{open:S}:null,"",nh(location,S));W.current="push"},[V,N,e0.designRel]);let xY=N||(V===r9?null:V),dG=e0.cloud?"cloud":G8()?"native":"local",gH=(b)=>th({rel:CW(b,e0.designRel),shell:dG,location,linkedHubUrl:t0?.url,project:e0.cloud?Z:a9,localUrl:location.origin}),mH=(b=xY)=>{let S=CW(b,e0.designRel);if(S)vQ({path:b,rel:S,label:Y4(b)})},G1=u.useCallback((b)=>{if(q9(null),y0(null),K9(),d0((S)=>S+1),b&&b!==r9)r0(b)},[K9]),cG=u.useRef(!1);u.useEffect(()=>{if(cG.current)return;if(!e0.cloud)return;if(new URLSearchParams(location.search).has("open")){cG.current=!0;return}if(K.length>0)return;if(!J.length)return;let b=null;for(let S of J){for(let i of S.paths||[]){if(!yQ.test(i))continue;if(/(^|\/)system\//.test(i))continue;b=i;break}if(b)break}if(!b)return;cG.current=!0,V6(b)},[e0.cloud,J,K.length,V6]);let S5=u.useCallback((b)=>{let S=typeof b==="string"?b:void 0;if(S)WQ(S);else if(!L9)WQ();V6(r9)},[L9,WQ,V6]);u.useEffect(()=>{$7({type:"tabs",tabs:K.map((b)=>b.path).filter((b)=>b!==r9)})},[K]),u.useEffect(()=>{if(V&&V!==r9)$7({type:"active",file:V});else if(V===r9)$7({type:"active",file:""});else $7({type:"active",file:""})},[V]);let hY=u.useCallback((b)=>{U((S)=>{let i=S.findIndex((H0)=>H0.path===b);if(i<0)return S;let X0=S.filter((H0)=>H0.path!==b);if(b===V)if(X0.length===0)B(null);else B(X0[Math.max(0,i-1)].path);return X0}),i9.current.delete(b),r0((S)=>S===b?null:S)},[V]);yY.current=(b)=>{if(!b?.rel)return;let S=(e0?.designRel||e0?.designRoot||".design").replace(/^\/+|\/+$/g,""),i=`${S}/${b.rel}`;if(b.action==="removed")hY(i);else if(b.action==="moved"&&b.fromRel){let X0=`${S}/${b.fromRel}`;U((H0)=>H0.map((F0)=>F0.path===X0?{...F0,path:i}:F0)),B((H0)=>H0===X0?i:H0),r0((H0)=>H0===X0?null:H0),i9.current.delete(X0)}};let dQ=u.useCallback(()=>{if(!V||V===r9){if(V===r9)WQ();return}let b=i9.current.get(V);if(b)b.src=b.src},[V,WQ]),uH=u.useCallback(()=>y8(),[y8]),[Z1,pH]=u.useState(!1),iG=u.useRef(!1),oG=u.useCallback(async()=>{if(iG.current)return;iG.current=!0,pH(!0);try{await Promise.all([y8(),new Promise((b)=>setTimeout(b,550))])}finally{iG.current=!1,pH(!1)}},[y8]);u.useEffect(()=>{let b=null,S=()=>{if(b)clearTimeout(b);b=setTimeout(()=>{b=null,uH()},150)};return window.addEventListener("focus",S),()=>{if(window.removeEventListener("focus",S),b)clearTimeout(b)}},[uH]);let H1=u.useCallback(async(b)=>{try{let S=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b,kind:"brief-board"})}),i=await S.json().catch(()=>({}));if(!S.ok||!i.ok)return{ok:!1,error:i.error||`create failed (${S.status})`};return await y8(),V6(i.file),{ok:!0,file:i.file}}catch(S){return{ok:!1,error:S instanceof Error?S.message:"network error"}}},[y8,V6]),lH=u.useCallback(async()=>{let b=await YQ("New video name");if(!b)return;let i=(await YQ("Size — 1920x1080 (landscape), 1080x1920 (portrait), 1080x1080 (square), or custom WxH","1920x1080")||"1920x1080").toLowerCase().match(/(\d{2,5})\s*[x×]\s*(\d{2,5})/),X0=i?Number(i[1]):1920,H0=i?Number(i[2]):1080,F0=Math.max(1,Math.min(60,Number(await YQ("Frames per second","30"))||30));try{let A0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b,kind:"video-comp",clips:[],fps:F0,width:X0,height:H0})}),l=await A0.json().catch(()=>({}));if(!A0.ok||!l.ok){f9(`New video failed: ${l.error||`error ${A0.status}`}`);return}await y8(),V6(l.file),j0(!0),f9("New video created — drop clips on the timeline to start the cut.",!0)}catch(A0){f9(`New video failed: ${A0 instanceof Error?A0.message:"network error"}`)}},[y8,V6,YQ]),z1=u.useCallback(async()=>{if(!V||V===r9)return;try{let b=await fetch(`/_api/annotations?file=${encodeURIComponent(V)}`),S=b.ok?await b.text():"",i=[];if(S){let l=new DOMParser().parseFromString(S,"image/svg+xml");for(let D0 of l.querySelectorAll('[data-tool="mediaref"]')){let P0=D0.getAttribute("data-src");if(!P0)continue;i.push({src:P0,mediaKind:D0.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(i.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let H0=`${VY(Y4(V)).replace(/\.tsx$/i,"")} Video`,F0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:H0,kind:"video-comp",clips:i})}),A0=await F0.json().catch(()=>({}));if(!F0.ok||!A0.ok){window.alert(`Assemble failed: ${A0.error||`error ${F0.status}`}`);return}await y8(),V6(A0.file)}catch(b){window.alert(`Assemble failed: ${b instanceof Error?b.message:"network error"}`)}},[V,y8,V6]),nG=u.useCallback(({accept:b,resolveTarget:S})=>{let i=V,X0=X6||void 0,H0=document.createElement("input");H0.type="file",H0.accept=b,H0.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(H0);let F0=()=>{if(H0.isConnected)H0.remove()};window.addEventListener("focus",()=>setTimeout(F0,300),{once:!0}),H0.addEventListener("change",()=>{let A0=H0.files?.[0];if(F0(),!A0)return;let l=`/_api/comp-clips?canvas=${encodeURIComponent(i)}${X0?`&artboardId=${encodeURIComponent(X0)}`:""}`;fetch(l).then((D0)=>D0.json().catch(()=>({}))).then((D0)=>{let P0=S(D0);if(!P0)return f9("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":A0.type||"application/octet-stream"},body:A0}).then((i0)=>i0.json().catch(()=>({}))).then((i0)=>{if(!i0?.path)return f9(`Upload failed: ${i0?.error||"unknown error"}`),null;if(P0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:i,arrayName:P0.arrayRef.arrayName,index:P0.arrayRef.index,field:P0.arrayRef.field,value:i0.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:i,id:P0.cdId,attr:"src",value:i0.path})})})}).then((D0)=>D0?D0.json():null).then((D0)=>{if(D0&&!D0.ok)f9(`Replace refused: ${D0.error||"failed"}`);else if(D0&&D0.ok){if(f9("Media replaced.",!0),D0.seq!=null)Y6(i,D0.seq,"replace media")}}).catch(()=>f9("Replace failed: network error"))}),H0.click()},[V,X6,Y6]),K1=u.useCallback(async(b,S)=>{if(!window.confirm(`Move “${S}” to trash?
5684
5684
 
5685
5685
  Its annotations, history and comments move with it. `+"You can restore it from .design/_trash/."))return;try{let X0=await fetch(`/_api/canvas?file=${encodeURIComponent(b)}`,{method:"DELETE"}),H0=await X0.json().catch(()=>({}));if(!X0.ok||!H0.ok){window.alert(`Could not delete: ${H0.error||`error ${X0.status}`}`);return}if(await y8(),V===b)U([]),B(null)}catch(X0){window.alert(`Delete failed: ${X0 instanceof Error?X0.message:"network error"}`)}},[y8,V]),U1=u.useCallback(async function b(S,i){try{let X0=await fetch("/_api/fs-move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:S,toDir:i})}),H0=await X0.json().catch(()=>({}));if(!X0.ok||!H0.ok)return f9(`Could not move: ${H0.error||`error ${X0.status}`}`),{ok:!1,error:H0.error};let F0=(e0?.designRel||e0?.designRoot||".design").replace(/^\/+|\/+$/g,""),A0=`${F0}/${H0.fromRel}`,l=`${F0}/${H0.toRel}`;await y8(),U((P0)=>P0.map((i0)=>i0.path===A0?{path:l}:i0)),B((P0)=>P0===A0?l:P0);let D0=A0.split("/").slice(0,-1).join("/");return f9(`Moved to ${H0.toRel.split("/").slice(0,-1).join("/")||"."}`,!0,{label:"Undo",onClick:()=>{b(l,D0)}}),{ok:!0}}catch(X0){return f9(`Move failed: ${X0 instanceof Error?X0.message:"network error"}`),{ok:!1,error:"network error"}}},[y8,e0]),V1=u.useCallback(async(b,S)=>{try{let i=await fetch("/_api/fs-mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parent:b,name:S})}),X0=await i.json().catch(()=>({}));if(!i.ok||!X0.ok){let H0=X0.error||`error ${i.status}`;return f9(`Could not create folder: ${H0}`),{ok:!1,error:H0}}return await y8(),{ok:!0,dir:X0.dir}}catch(i){let X0=i instanceof Error?i.message:"network error";return f9(`Create folder failed: ${X0}`),{ok:!1,error:X0}}},[y8]),q1=u.useCallback(async(b,S)=>{if(!window.confirm(`Delete folder "${S}"?
5686
5686
 
5687
5687
  Every canvas inside moves to trash (recoverable from .design/_trash/); any empty subfolders are removed.`))return;try{let X0=await fetch(`/_api/canvas?file=${encodeURIComponent(b)}`,{method:"DELETE"}),H0=await X0.json().catch(()=>({}));if(!X0.ok||!H0.ok){f9(`Could not delete folder: ${H0.error||`error ${X0.status}`}`);return}await y8()}catch(X0){f9(`Delete folder failed: ${X0 instanceof Error?X0.message:"network error"}`)}},[y8]),B1=u.useCallback(async(b,S)=>{let i=b.split("/").slice(0,-1).join("/");try{let X0=await fetch("/_api/fs-move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:b,toDir:i,toName:S})}),H0=await X0.json().catch(()=>({}));if(!X0.ok||!H0.ok){f9(`Could not rename folder: ${H0.error||`error ${X0.status}`}`);return}await y8()}catch(X0){f9(`Rename failed: ${X0 instanceof Error?X0.message:"network error"}`)}},[y8]),N1=u.useCallback(async(b,S)=>{try{let i=await fetch("/_api/fs-move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:b,toName:S})}),X0=await i.json().catch(()=>({}));if(!i.ok||!X0.ok){f9(`Could not rename: ${X0.error||`error ${i.status}`}`);return}let H0=(e0?.designRel||e0?.designRoot||".design").replace(/^\/+|\/+$/g,""),F0=`${H0}/${X0.fromRel}`,A0=`${H0}/${X0.toRel}`;await y8(),U((l)=>l.map((D0)=>D0.path===F0?{path:A0}:D0)),B((l)=>l===F0?A0:l)}catch(i){f9(`Rename failed: ${i instanceof Error?i.message:"network error"}`)}},[y8,e0]),F1=u.useCallback(async(b)=>{try{let S=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({duplicateOf:b})}),i=await S.json().catch(()=>({}));if(!S.ok||!i.ok){f9(`Could not duplicate: ${i.error||`error ${S.status}`}`);return}await y8(),f9(`Duplicated as ${i.rel.split("/").pop().replace(/\.tsx$/i,"")}`,!0)}catch(S){f9(`Duplicate failed: ${S instanceof Error?S.message:"network error"}`)}},[y8]),L1=u.useCallback(async(b,S)=>{if(!window.confirm(`Move “${S}” to trash?
5688
5688
 
5689
- You can restore it from .design/_trash/.`))return;try{let i=await fetch(`/_api/canvas?file=${encodeURIComponent(b)}`,{method:"DELETE"}),X0=await i.json().catch(()=>({}));if(!i.ok||!X0.ok){f9(`Could not delete: ${X0.error||`error ${i.status}`}`);return}await y8()}catch(i){f9(`Delete failed: ${i instanceof Error?i.message:"network error"}`)}},[y8]),D1=u.useCallback(()=>{if($7({type:"clear-select"}),E(null),V&&V!==r9){let b=i9.current.get(V);if(b&&b.contentWindow)try{b.contentWindow.postMessage({dgn:"force-clear"},"*")}catch{}}},[V]);u.useEffect(()=>{if(!V||V===r9)return;let b=i9.current.get(V);if(!b||!b.contentWindow)return;let S=jJ?[]:C9[V]||[];try{b.contentWindow.postMessage({dgn:"comments-set",comments:S},"*")}catch{}},[V,C9,jJ]),u.useEffect(()=>{let b=(F0)=>!!V&&(C9[V]||[]).some((A0)=>A0&&A0.id===F0);function S(F0){let A0=e0?.canvasOrigin||window.location.origin;if(F0.origin!==A0)return;let l=F0.data;if(!l||typeof l!=="object"||!l.dgn)return;if(l.dgn==="canvas-notice"){let D0=V&&V!==r9?i9.current.get(V)?.contentWindow:null,P0=Zm(F0,A0,D0);if(P0)zg(P0.title,P0.kind);return}if(l.dgn==="tool-cursor"){if(l.tool==="browse"){document.body.style.cursor="";let P0=document.getElementById("dc-app-cursor");if(P0)P0.textContent="";ZL(O0);return}let D0=Pb(l.tool);if(D0){document.body.style.cursor=D0;let P0=document.getElementById("dc-app-cursor");if(!P0)P0=document.createElement("style"),P0.id="dc-app-cursor",document.head.appendChild(P0);P0.textContent=`* { cursor: ${D0} !important; }`}return}if(l.dgn==="select"||l.dgn==="select-set"||l.dgn==="clear-select"||l.dgn==="edit-text"||l.dgn==="apply-edit"){let D0=V&&V!==r9?i9.current.get(V)?.contentWindow:null;if(F0.source!==D0)return}if(l.dgn==="select"&&l.selection)MY(null),k.current=Date.now(),$7({type:"select",selection:l.selection}),E(l.selection),OG(l.selection);else if(l.dgn==="select-set"){MY(null),k.current=Date.now();let D0=l.selection;if(D0==null)$7({type:"clear-select"}),E(null);else if(Array.isArray(D0)){let P0=D0[0]??null;if(P0)$7({type:"select",selection:P0});if(E(P0),D0.length===1)OG(P0)}else $7({type:"select",selection:D0}),E(D0),OG(D0)}else if(l.dgn==="clear-select")MY(null),k.current=Date.now(),$7({type:"clear-select"}),E(null);else if(l.dgn==="edit-text"&&l.id){let D0=F0.source,P0=(i0)=>{try{D0?.postMessage({dgn:"edit-reverted",op:"text",id:l.id,reason:i0},"*")}catch{}};fetch("/_api/edit-text",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:l.file,id:l.id,text:l.text??"",...typeof l.occurrence==="number"?{occurrence:l.occurrence}:{},...typeof l.before==="string"?{before:l.before}:{}})}).then((i0)=>i0.json().catch(()=>({}))).then((i0)=>{if(!i0.ok)P0(i0.error||"this element can't be edited inline")}).catch(()=>P0("network error"))}else if(l.dgn==="apply-edit"&&l.id&&(l.op==="css"||l.op==="text"||l.op==="attr")){let D0=vb(l);if(!D0)return;let P0=F0.source,i0=(A9)=>{if(typeof l.requestId!=="string")return;try{P0?.postMessage({dgn:"apply-edit-result",requestId:l.requestId,...A9},"*")}catch{}},_9=typeof l.value==="string"?l.value:null;m6.current=m6.current.catch(()=>{}).then(()=>fetch(D0.url,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(D0.body)}).then((A9)=>A9.json().catch(()=>({}))).then((A9)=>{if(A9.ok){if(D0.op==="css")PX({id:l.id,prop:l.key,value:_9});i0({ok:!0});return}console.warn("[apply-edit]",D0.op,A9.error||"failed"),i0({ok:!1,error:A9.error||"failed",conflict:A9.conflict===!0})}).catch(()=>i0({ok:!1,error:"network error"})))}else if(l.dgn==="layers-tree"){e({artboardId:l.artboardId,nodes:Array.isArray(l.tree)?l.tree:[]});let D0=KF0(l.tree);if(m.current={tree:l.tree,sig:D0,artboardId:l.artboardId??null},p.current=!1,v.current)clearTimeout(v.current),v.current=null;d.current?.(l.tree,D0,l.artboardId??null)}else if(l.dgn==="reorder-revert"){let D0=V?i9.current.get(V)?.contentWindow:null,P0=typeof l.seq==="number"&&(l.dir==="undo"||l.dir==="redo");if(F0.source===D0&&P0&&V){if(p.current=!0,v.current)clearTimeout(v.current);v.current=setTimeout(()=>{p.current=!1,v.current=null},700),fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,seq:l.seq,dir:l.dir})}).then((i0)=>i0.json().catch(()=>({}))).then((i0)=>{if(!i0.ok)console.warn("[reorder-revert]",i0.error||"failed")}).catch(()=>{})}}else if(l.dgn==="reorder-request"){let D0=V?i9.current.get(V)?.contentWindow:null,P0=typeof l.id==="string"&&typeof l.refId==="string"&&(l.position==="before"||l.position==="after"||l.position==="inside-start"||l.position==="inside-end");if(F0.source===D0&&P0)a.current?.(l.id,l.refId,l.position,{idIndex:Number.isInteger(l.idIndex)?l.idIndex:void 0,refIndex:Number.isInteger(l.refIndex)?l.refIndex:void 0})}else if(l.dgn==="reposition-request"){let D0=V?i9.current.get(V)?.contentWindow:null,P0=typeof l.id==="string"&&Number.isFinite(l.left)&&Number.isFinite(l.top)&&Number.isFinite(l.beforeLeft)&&Number.isFinite(l.beforeTop);if(F0.source===D0&&P0)f.current?.(l.id,l.left,l.top,l.beforeLeft,l.beforeTop,Number.isInteger(l.idIndex)?l.idIndex:void 0)}else if(l.dgn==="resize-request"){let D0=V?i9.current.get(V)?.contentWindow:null,P0=typeof l.id==="string"&&l.patch&&typeof l.patch==="object";if(F0.source===D0&&P0)h.current?.(l.id,l.patch,l.before,Number.isInteger(l.idIndex)?l.idIndex:void 0)}else if(l.dgn==="delete-request"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof l.id==="string")JX.current?.(l.id,Number.isInteger(l.idIndex)?l.idIndex:void 0)}else if(l.dgn==="duplicate-request"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof l.id==="string")Vk.current?.(l.id,Number.isInteger(l.idIndex)?l.idIndex:void 0)}else if(l.dgn==="copy-style"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0)Bk.current?.()}else if(l.dgn==="paste-style"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof l.id==="string")Nk.current?.(l.id)}else if(l.dgn==="insert-request"){let D0=V?i9.current.get(V)?.contentWindow:null,P0=typeof l.refId==="string",i0=typeof l.artboardId==="string",_9=l.position==="before"||l.position==="after"||l.position==="inside-start"||l.position==="inside-end",A9=P0!==i0&&(l.kind==="div"||l.kind==="text"||l.kind==="image")&&_9&&(!i0||l.position==="inside-start"||l.position==="inside-end");if(F0.source===D0&&A9)Hk.current?.(l.refId,l.position,l.kind,{artboardId:i0?l.artboardId:void 0,src:typeof l.src==="string"?l.src:void 0,refIndex:Number.isInteger(l.refIndex)?l.refIndex:void 0})}else if(l.dgn==="insert-image-request"){let D0=V?i9.current.get(V)?.contentWindow:null,P0=typeof l.refId==="string",i0=typeof l.artboardId==="string",_9=!P0&&!i0,A9=(P0!==i0||_9)&&(_9||l.position==="before"||l.position==="after"||l.position==="inside-start"||l.position==="inside-end")&&(!i0||l.position==="inside-start"||l.position==="inside-end");if(F0.source===D0&&A9)Nq.current?.({purpose:"insert-image",canvas:V,refId:l.refId,artboardId:i0?l.artboardId:void 0,position:_9?void 0:l.position,refIndex:Number.isInteger(l.refIndex)?l.refIndex:void 0,multiple:!0,hasArtboardAnchor:!_9})}else if(l.dgn==="replace-media-request"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof l.id==="string")Nq.current?.({purpose:"replace-src",canvas:V,id:l.id,before:typeof l.before==="string"?l.before:null})}else if(l.dgn==="convert-to-absolute-request"){let D0=V?i9.current.get(V)?.contentWindow:null,P0=Array.isArray(l.containers)&&l.containers.length>0,i0=typeof l.containerId==="string"&&Array.isArray(l.children)&&l.children.length>0;if(F0.source===D0&&(P0||i0)){let _9=P0?l.containers.reduce((A9,q6)=>A9+(Array.isArray(q6?.children)?q6.children.length:0),0):l.children.length;aG.current?.("/_api/convert-to-absolute",P0?{allowShared:l.allowShared===!0,containers:l.containers,...Array.isArray(l.dissolve)&&l.dissolve.length>0?{dissolve:l.dissolve}:{}}:{containerId:l.containerId,containerSetRelative:l.containerSetRelative===!0,allowShared:l.allowShared===!0,children:l.children},{label:"convert to absolute",onOk:()=>{T0({dgn:"selection-clear"}),T0({dgn:"op-toast",message:`Converted ${_9} element${_9===1?"":"s"} to absolute — press V and drag them freely (⌘Z to undo).`})},onFail:(A9)=>T0({dgn:"op-toast",message:`Convert failed: ${A9?.error||"unknown error"}`})})}}else if(l.dgn==="replace-annotation-media-request"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof l.id==="string")Nq.current?.({purpose:"replace-annotation-media",canvas:V,id:l.id,before:typeof l.before==="string"?l.before:null})}else if(l.dgn==="edit-annotation-photo-request"){let D0=V?i9.current.get(V)?.contentWindow:null,P0=Zk.exec(typeof l.asset==="string"?l.asset:"")?.[0]||null;if(F0.source===D0&&typeof l.id==="string"&&P0)MY({asset:P0,strokeId:l.id}),eX("inspector"),tX("photo")}else if(l.dgn==="open-sticker-picker"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0)Fk.current?.({canvas:V})}else if(l.dgn==="insert-artboard-request"){let D0=V?i9.current.get(V)?.contentWindow:null,P0=typeof l.id==="string"&&Number.isFinite(l.width)&&Number.isFinite(l.height);if(F0.source===D0&&P0)zk.current?.({id:l.id,label:typeof l.label==="string"?l.label:l.id,width:l.width,height:l.height})}else if(l.dgn==="resize-artboard-request"){let D0=V?i9.current.get(V)?.contentWindow:null,P0=typeof l.artboardId==="string"&&(Number.isFinite(l.width)||Number.isFinite(l.height));if(F0.source===D0&&P0)Kk.current?.(l.artboardId,Number.isFinite(l.width)?l.width:void 0,Number.isFinite(l.height)?l.height:void 0)}else if(l.dgn==="delete-artboard-request"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof l.artboardId==="string")Uk.current?.(l.artboardId)}else if(l.dgn==="rename-artboard-request"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof l.artboardId==="string"&&typeof l.label==="string"&&l.label.trim())aG.current?.("/_api/set-artboard-label",{artboardId:l.artboardId,label:l.label.slice(0,80)},{label:"rename artboard"})}else if(l.dgn==="set-artboard-kind-request"){let D0=V?i9.current.get(V)?.contentWindow:null,P0=l.kind===null||typeof l.kind==="string";if(F0.source===D0&&typeof l.artboardId==="string"&&P0)c0.current?.(l.artboardId,l.kind)}else if(l.dgn==="duplicate-artboard-request"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof l.artboardId==="string"&&Number.isFinite(l.width))qk.current?.(l.artboardId,l.width)}else if(l.dgn==="open-inspector"){if(eX("inspector"),typeof l.tab==="string")tX(l.tab)}else if(l.dgn==="present-enter"){let D0=V?i9.current.get(V)?.contentWindow:null,P0=!!document.querySelector('[role="dialog"][aria-modal="true"]');if(F0.source===D0&&!P0&&!jJ)q4(!0),MJ({present:!0})}else if(l.dgn==="comment-compose"&&l.selection)E(l.selection);else if(l.dgn==="comment-submit"&&l.payload&&typeof l.payload.text==="string"){let D0=l.payload,P0=String(D0.text).trim(),i0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===i0&&P0&&V&&V!==r9)$7({type:"comments-add",payload:{file:V,selector:D0.selector,index:D0.index,dom_path:D0.dom_path,tag:D0.tag,classes:D0.classes,bounds:D0.bounds,html_excerpt:D0.html_excerpt,text:P0}})}else if(l.dgn==="comment-patch"&&l.id&&l.patch&&typeof l.patch==="object"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0&&b(l.id))$7({type:"comments-patch",id:l.id,patch:l.patch})}else if(l.dgn==="comment-delete"&&l.id){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0&&b(l.id))$7({type:"comments-delete",id:l.id}),i8((P0)=>P0===l.id?null:P0)}else if(l.dgn==="comment-click"&&l.id)i8(l.id);else if(l.dgn==="artboards"&&typeof l.count==="number"){let D0=Math.round(l.count);if(Number.isFinite(D0)&&D0>=0&&D0<=999)sJ(D0)}else if(l.dgn==="active-artboard"){let D0=V&&V!==r9?i9.current.get(V)?.contentWindow:null;if(F0.source!==D0)return;DX(dN(l.id))}else if(l.dgn==="timeline-comps"&&Array.isArray(l.comps)){let D0=V&&V!==r9?i9.current.get(V)?.contentWindow:null;if(F0.source!==D0)return;let P0=l.comps.filter((A9)=>A9&&typeof A9.id==="string").slice(0,32).map((A9)=>({id:String(A9.id).slice(0,120),fps:Math.max(1,Math.min(120,Math.round(Number(A9.fps)||30))),durationInFrames:Math.max(1,Math.min(1e6,Math.round(Number(A9.durationInFrames)||1))),width:Math.max(1,Math.round(Number(A9.width)||0)),height:Math.max(1,Math.round(Number(A9.height)||0)),artboardId:dN(A9.artboardId),artboardLabel:dN(A9.artboardLabel)}));z9(P0);let i0=sX.current;if(i0&&P0.some((A9)=>A9.id===i0)&&OX.current>0)T0({dgn:"timeline-seek",frame:OX.current,id:i0})}else if(l.dgn==="timeline-frame"&&typeof l.frame==="number"){let D0=V&&V!==r9?i9.current.get(V)?.contentWindow:null;if(F0.source!==D0)return;if(l.id&&sX.current&&l.id!==sX.current)return;if(Number.isFinite(l.frame))Z8(Math.max(0,Math.round(l.frame)))}else if(l.dgn==="timeline-ended"){let D0=V&&V!==r9?i9.current.get(V)?.contentWindow:null;if(F0.source!==D0)return;if(l.id&&sX.current&&l.id!==sX.current)return;I6(!1)}else if(l.dgn==="toggle-palette")z6((D0)=>!D0);else if(l.dgn==="shell-shortcut"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0){if(l.id==="reload")dQ();else if(l.id==="inspector")h6("inspector");else if(l.id==="assistant"&&G8())h6("assistant");else if(l.id==="comments")h6("comments");else if(l.id==="changes")h6("changes");else if(l.id==="timeline")AY();else if(l.id==="export")P6({mode:"export"});else if(l.id==="handoff")P6({mode:"handoff"})}}else if(l.dgn==="open-export"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0)P6({mode:"export",scope:l.detail&&typeof l.detail.scope==="string"?l.detail.scope:void 0})}else if(l.dgn==="open-timeline-request"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0){if(typeof l.artboardId==="string")DX(l.artboardId.slice(0,120));j0(!0)}}else if(l.dgn==="loaded"&&l.file){r0((i0)=>i0===l.file?null:i0),y0(l.file),q9((i0)=>i0&&i0.path===l.file?null:i0);let D0=jJ?[]:C9[l.file]||[],P0=[...i9.current.entries()].find(([i0])=>i0===l.file)?.[1];if(P0&&P0.contentWindow){try{P0.contentWindow.postMessage({dgn:"comments-set",comments:D0},"*")}catch{}try{P0.contentWindow.postMessage({dgn:"theme",theme:f0},"*")}catch{}try{P0.contentWindow.postMessage({dgn:"view-chrome",minimap:QQ,zoom:g6,present:jJ},"*")}catch{}if(x8&&D0.some((_9)=>_9.id===x8))try{P0.contentWindow.postMessage({dgn:"comment-focus",id:x8},"*")}catch{}let i0=x.current;if(i0&&i0.file===l.file){x.current=null;try{P0.contentWindow.postMessage({dgn:"request-layers",artboardId:i0.artboardId??null},"*")}catch{}if(i0.movedId)try{P0.contentWindow.postMessage({dgn:"select-by-id",id:i0.movedId,artboardId:i0.artboardId??null,index:0},"*")}catch{}}else{let _9=w.current,A9=Array.isArray(_9)?_9[0]:_9;if(A9&&A9.id&&A9.file===l.file)$(A9)}}}else if(l.dgn==="export-request"&&l.id&&l.payload){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source!==D0)return;X0(F0.source,l.id,l.payload)}else if(l.dgn==="export-history-request"&&l.id)H0(F0.source,l.id)}let i=e0?.canvasOrigin||window.location.origin;async function X0(F0,A0,l){if(l?.options&&V&&V!==r9)l.options.canvasFile=V;let D0=(_9)=>{try{if(F0)F0.postMessage({dgn:"export-result",id:A0,..._9},i)}catch{}},P0=l?.options||{};if(a2({exportLane:e0.exportLane||"local",format:l?.format,scope:l?.scope,artboardId:P0.artboardId}))try{if(l.format==="pptx"){let{filename:_9,blob:A9}=await TO({capture:k5,name:V?V.replace(/^.*\//,"").replace(/\.[^.]+$/,""):"export"});UL(_9,A9)}else{let _9=RO(P0),A9=await k5({format:l.format,artboardIds:[P0.artboardId],scale:_9}),q6=await kO(A9,l.format);for(let w7 of q6)UL(w7.name,w7.blob)}D0({ok:!0,browser:!0});return}catch{if(e0.exportLane!=="remote"){D0({ok:!1,error:"Capturing in the browser failed and this workspace has no render service to fall back to — try again, or ask your admin to add maude-render."});return}}if(e0.exportLane==="none"&&l?.format!=="zip"){D0({ok:!1,error:"This format needs the render service, which this workspace doesn’t have configured. PNG/SVG of the active artboard and the PPTX deck export straight from the browser; ZIP works too. For the rest use the desktop app or ask your admin to add maude-render."});return}try{let _9=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(l)});if(!_9.ok){D0({ok:!1,error:await _9.text()||String(_9.status)});return}let{jobId:A9}=await _9.json();D0({ok:!0,jobId:A9})}catch(_9){D0({ok:!1,error:_9&&_9.message?_9.message:String(_9)})}}async function H0(F0,A0){let l=[];try{let D0=await fetch("/_api/export-history");if(D0.ok){let P0=await D0.json();if(Array.isArray(P0.history))l=P0.history}}catch{}try{if(F0)F0.postMessage({dgn:"export-history-result",id:A0,history:l},i)}catch{}}return window.addEventListener("message",S),()=>window.removeEventListener("message",S)},[C9,x8,e0,f0,dQ,jJ,QQ,g6,MJ,V,T0,k5]);let M1=u.useCallback(()=>{if(!V||V===r9)return;let b=i9.current.get(V);if(b&&b.contentWindow)try{b.contentWindow.postMessage({dgn:"force-clear"},"*")}catch{}},[V]),PX=u.useCallback((b)=>{if(!V||V===r9)return;let S=i9.current.get(V);if(S&&S.contentWindow)try{S.contentWindow.postMessage({dgn:"apply-style",...b},"*")}catch{}},[V]),eJ=u.useCallback((b)=>{if(!V||V===r9||!b)return;let S=i9.current.get(V);if(S&&S.contentWindow)try{S.contentWindow.postMessage({dgn:"record-edit",payload:b},"*")}catch{}},[V]),m6=u.useRef(Promise.resolve()),rG=u.useCallback((b,S,i,X0)=>{let H0=Number.isInteger(X0?.idIndex)?X0.idIndex:void 0,F0=Number.isInteger(X0?.refIndex)?X0.refIndex:void 0;if(!b||!S)return;if(b===S&&(H0??0)===(F0??0))return;let A0=w.current,l=Array.isArray(A0)?A0[0]:A0,D0=V;if(!D0)return;let P0=V,i0=r?.artboardId??l?.artboardId??null;if(e((_9)=>_9?{..._9,nodes:NL0(_9.nodes,b,S,i)}:_9),p.current=!0,v.current)clearTimeout(v.current);v.current=setTimeout(()=>{p.current=!1,v.current=null},700),m6.current=m6.current.catch(()=>{}).then(()=>fetch("/_api/reorder",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:D0,id:b,refId:S,position:i,idIndex:H0,refIndex:F0})}).then((_9)=>_9.json().catch(()=>({}))).then((_9)=>{if(!_9.ok){if(console.warn("[reorder]",_9.error||"failed"),T0({dgn:"reorder-failed"}),T0({dgn:"request-layers",artboardId:i0}),p.current=!1,v.current)clearTimeout(v.current),v.current=null;return}if(x.current={file:P0,movedId:_9.movedId||null,artboardId:i0},typeof _9.seq==="number")T0({dgn:"record-edit",payload:{op:"reorder",canvas:D0,seq:_9.seq,label:"move element"}})}).catch(()=>{}))},[V,r,T0]);u.useEffect(()=>{a.current=rG},[rG]);let dH=u.useCallback((b,S,i,X0,H0,F0)=>{if(!b||!V)return;let A0=V,l=Number.isInteger(F0)?F0:void 0;PX({id:b,prop:"left",value:`${S}px`}),PX({id:b,prop:"top",value:`${i}px`});let D0=null,P0=(i0,_9)=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:A0,id:b,property:i0,value:`${_9}px`,idIndex:l})}).then((A9)=>A9.json().catch(()=>({})));m6.current=m6.current.catch(()=>{}).then(()=>P0("left",S)).then((i0)=>{if(!i0.ok)throw Error(i0.error||"left write failed");return D0=i0,P0("top",i)}).then((i0)=>{if(!i0.ok)throw Error(i0.error||"top write failed");eJ({op:"css",canvas:A0,id:b,key:"left",before:Uq(D0,`${X0}px`),after:`${S}px`}),eJ({op:"css",canvas:A0,id:b,key:"top",before:Uq(i0,`${H0}px`),after:`${i}px`})}).catch((i0)=>{console.warn("[reposition]",i0?.message||i0),T0({dgn:"reposition-failed"})})},[V,T0,eJ,PX]);u.useEffect(()=>{f.current=dH},[dH]);let cH=u.useCallback((b,S,i,X0)=>{if(!b||!V||!S||typeof S!=="object")return;let H0=V,F0=i&&typeof i==="object"?i:{},A0=Number.isInteger(X0)?X0:void 0,l=["width","height","left","top","transform","padding-top","padding-right","padding-bottom","padding-left","gap","grid-template-columns","grid-template-rows"].filter((d8)=>typeof S[d8]==="string"&&S[d8]);if(!l.length)return;let D0=w.current,P0=Array.isArray(D0)?D0.length===1?D0[0]:null:D0,i0=P0&&P0.id===b?P0.artboardId??null:null,_9=P0&&P0.id===b?P0.index??0:0;for(let d8 of l)PX({id:b,artboardId:i0,index:_9,prop:d8,value:S[d8]});let A9=(d8,_J)=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:H0,id:b,property:d8,value:_J,idIndex:A0})}).then((eG)=>eG.json().catch(()=>({}))),q6={},w7=m6.current.catch(()=>{});for(let d8 of l)w7=w7.then((_J)=>{if(_J&&_J.ok===!1)throw Error(_J.error||`${d8} write failed`);return A9(d8,S[d8]).then((eG)=>{return q6[d8]=eG,eG})});m6.current=w7.then((d8)=>{if(d8&&d8.ok===!1)throw Error(d8.error||"resize write failed");for(let _J of l)eJ({op:"css",canvas:H0,id:b,key:_J,before:Uq(q6[_J],F0[_J]??null),after:S[_J]});$({id:b,file:H0,artboardId:i0,index:_9})}).catch((d8)=>{console.warn("[resize]",d8?.message||d8),T0({dgn:"resize-failed"})})},[V,T0,eJ,PX,$]);u.useEffect(()=>{h.current=cH},[cH]);let aG=u.useRef(null),Y7=u.useCallback((b,S,{label:i,onOk:X0,onFail:H0}={})=>{if(!V)return;let F0=V,A0=H0??((l)=>T0({dgn:"op-toast",message:`Couldn't ${i||"apply the edit"}${l?.error?` — ${l.error}`:""}.`}));m6.current=m6.current.catch(()=>{}).then(()=>fetch(b,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...S,canvas:F0})}).then((l)=>l.json().catch(()=>({}))).then((l)=>{if(!l.ok){console.warn(`[${b}]`,l.error||"failed"),A0?.(l);return}if(typeof l.seq==="number")T0({dgn:"record-edit",payload:{op:"reorder",canvas:F0,seq:l.seq,label:i||"edit"}});X0?.(l,F0)}).catch((l)=>A0?.({error:l?.message})))},[V,T0]);u.useEffect(()=>{aG.current=Y7},[Y7]);let iH=u.useCallback((b,S)=>{Y7("/_api/delete-element",{id:b,idIndex:Number.isInteger(S)?S:void 0},{label:"delete element",onOk:()=>T0({dgn:"selection-clear"})})},[Y7,T0]),GQ=u.useCallback((b,S,i,X0={})=>{let H0=m.current?.sig??null;Y7("/_api/insert-element",{refId:b,artboardId:typeof X0.artboardId==="string"?X0.artboardId:void 0,position:S,kind:i,src:typeof X0.src==="string"?X0.src:void 0,refIndex:Number.isInteger(X0.refIndex)?X0.refIndex:void 0},{label:`insert ${i}`,onOk:(F0,A0)=>{if(!F0.newId)return;x.current={file:A0,movedId:F0.newId,artboardId:null,staleSig:H0};let l=m.current;if(l)d.current?.(l.tree,l.sig,l.artboardId)}})},[Y7]),O1=u.useCallback((b)=>{if(typeof b!=="string"||!b)return!1;if(!V)return!1;let S=w.current?.artboardId??R8??null;if(!S)return!1;return GQ(void 0,"inside-end","image",{artboardId:S,src:b}),!0},[V,R8,GQ]),A1=u.useCallback((b,S)=>{Y7("/_api/detach-component",{id:b,idIndex:Number.isInteger(S)?S:void 0},{label:"detach instance",onOk:(i)=>{T0({dgn:"selection-clear"}),T0({dgn:"op-toast",message:`Detached — this instance is now ${i.detachedName||"its own component"}; edits stay local (⌘Z to undo).`})},onFail:(i)=>T0({dgn:"op-toast",message:`Detach failed: ${i?.error||"unknown error"}`})})},[Y7,T0]),oH=u.useCallback((b,S)=>{let i=m.current?.sig??null;Y7("/_api/duplicate-element",{id:b,idIndex:Number.isInteger(S)?S:void 0},{label:"duplicate element",onOk:(X0,H0)=>{if(!X0.newId)return;x.current={file:H0,movedId:X0.newId,artboardId:null,staleSig:i};let F0=m.current;if(F0)d.current?.(F0.tree,F0.sig,F0.artboardId)}})},[Y7]),nH=u.useRef(null),q=u.useMemo(()=>new Set(["position","top","right","bottom","left","inset","width","height","min-width","max-width","min-height","max-height","margin","margin-top","margin-right","margin-bottom","margin-left"]),[]),L=u.useCallback(()=>{let b=w.current,S=Array.isArray(b)?b.length===1?b[0]:null:b;if(!S)return;let i={};for(let[X0,H0]of Object.entries(S.authored||{}))if(!q.has(X0))i[X0]=H0;for(let[X0,H0]of Object.entries(S.customStyles||{}))if(!q.has(X0))i[X0]=H0;nH.current=Object.keys(i).length?i:null},[q]),_=u.useCallback((b)=>{let S=V,i=nH.current;if(!S||!b||!i)return;let X0=Object.entries(i),H0=m6.current.catch(()=>{});for(let[F0,A0]of X0)PX({id:b,prop:F0,value:A0}),H0=H0.then(()=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:S,id:b,property:F0,value:A0})}).then((l)=>l.json().catch(()=>({}))).then((l)=>{if(l.ok)eJ({op:"css",canvas:S,id:b,key:F0,before:Uq(l,null),after:A0})}).catch(()=>{}));m6.current=H0},[V,PX,eJ]),P=u.useCallback(({id:b,label:S,width:i,height:X0})=>{Y7("/_api/insert-artboard",{id:b,label:S,width:i,height:X0},{label:"insert artboard"})},[Y7]),T=u.useCallback((b,S,i)=>{Y7("/_api/resize-artboard",{artboardId:b,width:S,height:i},{label:"resize artboard",onFail:()=>T0({dgn:"resize-artboard-failed"}),onOk:()=>j(b,V)})},[Y7,T0,j,V]),y=u.useCallback((b)=>{Y7("/_api/delete-artboard",{artboardId:b},{label:"delete artboard"})},[Y7]),g=u.useCallback((b,S)=>{Y7("/_api/duplicate-artboard",{artboardId:b,width:S},{label:"duplicate artboard at width"})},[Y7]),J0=u.useCallback((b,S,i)=>{Y7("/_api/set-artboard-hug",{artboardId:b,fixed:S,freezeHeight:i},{label:S?"pin artboard height":"hug artboard height",onOk:()=>j(b,V)})},[Y7,j,V]),G0=u.useCallback((b,S)=>{Y7("/_api/set-artboard-style",{artboardId:b,...S},{label:"artboard style",onOk:()=>j(b,V)})},[Y7,j,V]),B0=u.useRef(null),R0=u.useCallback((b,S)=>{Y7("/_api/set-artboard-kind",{artboardId:b,kind:S},{label:"artboard kind",onOk:()=>j(b,V)});let i=B0.current;if(S==="print"&&i&&i.artboardId===b)B0.current=null,Y7("/_api/resize-artboard",{artboardId:b,width:i.widthPx,height:i.heightPx},{label:"artboard size"}),Y7("/_api/set-artboard-print",{artboardId:b,print:i.defaults},{label:"artboard print"})},[Y7,j,V]),c0=u.useRef(null);u.useEffect(()=>{c0.current=R0},[R0]);let Z9=u.useCallback((b,S,i)=>{if(S==="print"||S==null||S==="digital"){if(i)B0.current={artboardId:b,...i};T0({dgn:"freeze-and-set-kind",artboardId:b,kind:S==="digital"?null:S,ask:!0});return}R0(b,S)},[R0,T0]),X8=u.useCallback((b,S)=>{Y7("/_api/set-artboard-print",{artboardId:b,print:S},{label:"artboard print",onOk:()=>j(b,V)})},[Y7,j,V]),_7=u.useCallback((b)=>{let S=`s${Math.random().toString(36).slice(2,8)}`;if(b.startsWith("print-")){let X0=b.slice(6),H0;try{H0=r2({paper:X0})}catch{return}let F0=n2.find((A0)=>A0.id===X0);P({id:S,label:F0?F0.label:X0.toUpperCase(),width:H0.widthPx,height:H0.heightPx}),Z9(S,"print"),X8(S,{paper:X0});return}let i=bQ[b];if(!i)return;P({id:S,label:i.label,width:i.width,height:i.height})},[P,Z9,X8]),JX=u.useRef(null),Hk=u.useRef(null),zk=u.useRef(null),Kk=u.useRef(null),Uk=u.useRef(null),R80=u.useRef(null),Vk=u.useRef(null),qk=u.useRef(null),Bk=u.useRef(null),Nk=u.useRef(null);u.useEffect(()=>{JX.current=iH,Hk.current=GQ,zk.current=P,Kk.current=T,Uk.current=y,R80.current=Z9,Vk.current=oH,qk.current=g,Bk.current=L,Nk.current=_},[iH,GQ,P,T,y,Z9,oH,g,L,_]),u.useEffect(()=>{let b=(S)=>{if(S.key!=="Backspace"&&S.key!=="Delete")return;if(S.metaKey||S.ctrlKey||S.altKey)return;let i=S.target;if(i&&(i.tagName==="INPUT"||i.tagName==="TEXTAREA"||i.tagName==="SELECT"||i.isContentEditable))return;if(S.preventDefault(),!V||V===r9)return;let H0=Array.isArray(A)?A.length===1?A[0]:null:A;if(H0?.artboardId&&!H0.id)y(H0.artboardId)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[V,A,y]);let[sG,_1]=u.useState(null),Nq=u.useRef(null);u.useEffect(()=>{Nq.current=(b)=>_1(b)},[]);let[LL,DL]=u.useState(null),Fk=u.useRef(null);u.useEffect(()=>{Fk.current=(b)=>DL(b)},[]);let C80=u.useCallback((b)=>{let S=sG;if(_1(null),!S||!b)return;if(S.canvas&&S.canvas!==V){console.warn("[asset-picker] active canvas changed since request — aborting");return}if(S.purpose==="insert-image"){GQ(S.refId,S.position||"after","image",{artboardId:S.artboardId,src:b,refIndex:S.refIndex});return}if(S.purpose==="replace-src"){let i=V;if(!i||!S.id)return;m6.current=m6.current.catch(()=>{}).then(()=>fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:i,id:S.id,attr:"src",value:b})}).then((X0)=>X0.json().catch(()=>({}))).then((X0)=>{if(X0.ok)eJ({op:"attr",canvas:i,id:S.id,key:"src",before:Uq(X0,S.before??null),after:b});else console.warn("[replace-src]",X0.error||"failed")}).catch(()=>{}));return}if(S.purpose==="replace-annotation-media")T0({dgn:"replace-annotation-media",id:S.id,path:b})},[sG,GQ,V,eJ,T0]),$80=u.useCallback((b,S)=>{let i=sG;if(_1(null),!i||!Array.isArray(b)||!b.length)return;if(i.canvas&&i.canvas!==V){console.warn("[asset-picker] active canvas changed since request — aborting");return}if(S==="artboard"){let X0=w.current?.artboardId??R8??null;if(!X0)return;for(let H0 of b)GQ(void 0,"inside-end","image",{artboardId:X0,src:H0});return}T0({dgn:"insert-annotation-media",paths:b})},[sG,V,GQ,R8,T0]),S80=u.useCallback(async(b)=>{let S=LL;if(DL(null),!S||!b?.url)return;if(S.canvas&&S.canvas!==V){console.warn("[sticker-picker] active canvas changed since request — aborting");return}try{let i=await fetch(b.url).then((F0)=>F0.ok?F0.blob():Promise.reject(Error(`HTTP ${F0.status}`))),X0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":i.type||"image/png"},body:i}),H0=await X0.json().catch(()=>({}));if(!X0.ok||!H0.path){console.warn("[sticker-picker]",H0.error||`upload failed (HTTP ${X0.status})`);return}T0({dgn:"insert-sticker",path:H0.path})}catch{console.warn("[sticker-picker] could not load or upload that sticker")}},[LL,V,T0]),b80=u.useCallback((b)=>{if(!b?.id)return;_1({purpose:"replace-src",canvas:V,id:b.id,before:b.attrs?.src??null})},[V]),y80=u.useCallback((b)=>{$7({type:"comments-patch",id:b,patch:{status:"resolved"}})},[]),j80=u.useCallback((b)=>{$7({type:"comments-patch",id:b,patch:{status:"open"}})},[]),v80=u.useCallback((b)=>{$7({type:"comments-delete",id:b}),i8((S)=>S===b?null:S)},[]),f80=u.useCallback((b,S)=>{if(b&&b!==V)U((X0)=>X0.find((H0)=>H0.path===b)?X0:[...X0,{path:b}]),B(b);if(S==null){i8(null);return}i8(S);let i=()=>{let X0=i9.current.get(b);if(X0&&X0.contentWindow)try{X0.contentWindow.postMessage({dgn:"comment-focus",id:S},"*")}catch{}};i(),setTimeout(i,200)},[V]);u.useEffect(()=>{function b(S){let i=S.metaKey||S.ctrlKey,X0=["INPUT","TEXTAREA"].includes(document.activeElement?.tagName)||document.activeElement?.isContentEditable,H0=document.activeElement?.tagName==="IFRAME";if(jJ&&S.key==="Escape"){S.preventDefault(),F4();return}if(i&&(S.key==="k"||S.key==="K")){S.preventDefault(),z6((F0)=>!F0);return}if(i&&!S.altKey&&(S.key==="z"||S.key==="Z"||S.key==="y"||S.key==="Y")){if(!X0&&!H0&&V&&V!==r9){if((S.key==="z"||S.key==="Z")&&Q6.current.open&&Q6.current.comps?.length)return;let F0=S.key==="y"||S.key==="Y"||S.shiftKey;if(hQ==="photo"&&G9(F0)){S.preventDefault();return}S.preventDefault(),T0({dgn:F0?"redo":"undo"});return}}if(i&&S.shiftKey&&(S.key==="r"||S.key==="R")){S.preventDefault(),oG();return}if(i&&(S.key==="r"||S.key==="R")){S.preventDefault(),dQ();return}if(i&&S.shiftKey&&(S.key==="m"||S.key==="M")){S.preventDefault(),h6("comments");return}if(i&&S.shiftKey&&(S.key==="g"||S.key==="G")){S.preventDefault(),h6("changes");return}if(i&&S.shiftKey&&(S.key==="i"||S.key==="I")){S.preventDefault(),h6("inspector");return}if(i&&S.shiftKey&&(S.key==="a"||S.key==="A")&&G8()){if(S.preventDefault(),!O0)h6("assistant");return}if(i&&S.shiftKey&&(S.key==="e"||S.key==="E")){S.preventDefault(),P6({mode:"export"});return}if(i&&S.shiftKey&&(S.key==="h"||S.key==="H")){S.preventDefault(),P6({mode:"handoff"});return}if(i&&!S.shiftKey&&!S.altKey&&S.key===","){if(S.preventDefault(),!O0)O5(!0);return}if(i&&S.shiftKey&&(S.key==="t"||S.key==="T")){S.preventDefault(),AY();return}if(i&&!S.shiftKey&&!S.altKey&&(S.key==="c"||S.key==="C")){if(A&&A.selector&&V&&V!==r9&&!X0&&console&&console.warn)console.warn("Cmd+C comment-drop deprecated — press C inside the canvas to enter Comment tool, then click the element.")}if(X0)return;if(S.key==="/"){S.preventDefault();let F0=document.querySelector(".st-search input");if(F0)F0.focus();return}if(i&&(S.key==="f"||S.key==="F")){if(S.preventDefault(),!k8)k6("tree");setTimeout(()=>{let F0=document.querySelector(".st-search input");if(F0)F0.focus()},0);return}if(H0){if(S.key!=="Escape")return}if(S.key==="t"||S.key==="T"){if(S.shiftKey||i)return;S.preventDefault(),wX("tree");return}if(S.key==="h"||S.key==="H"){if(S.shiftKey||i)return;S.preventDefault(),D5((F0)=>!F0);return}if((S.key==="s"||S.key==="S")&&!i&&!S.shiftKey){if(S.preventDefault(),V===r9)hY(r9);else S5();return}if((S.key==="n"||S.key==="N")&&!i&&!S.shiftKey){S.preventDefault(),k6("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60);return}if(S.key==="?"){S.preventDefault(),l8((F0)=>!F0);return}if(S.key==="F1"){S.preventDefault(),oJ(!0);return}if(S.key==="Escape"){if(x8){i8(null);return}}}return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[dQ,oG,A,V,x8,k8,S5,hY,M1,jJ,F4,AY,hQ,G9,O0]);let x80=u.useCallback((b,S)=>{if(S)i9.current.set(b,S)},[]),h80=A80(C9).open,g80=u.useCallback((b)=>{let S=b.target;if(S&&(S.tagName==="INPUT"||S.tagName==="TEXTAREA"||S.isContentEditable))return;b.preventDefault()},[]),m80=u.useMemo(()=>[{id:"new",group:"Canvas",label:"New canvas…",icon:"plus",kbd:"N",run:()=>{k6("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60)}},{id:"new-video",group:"Canvas",label:"New video…",icon:"plus",run:()=>lH()},{id:"export",group:"Canvas",label:"Export…",icon:"download",kbd:"⇧⌘E",run:()=>P6({mode:"export"})},{id:"share-link",group:"Canvas",label:"Copy share link",icon:"link",run:()=>{let b=gH(xY),S=b.web??b.app??b.local;if(S)TV(S)}},{id:"handoff",group:"Canvas",label:"Handoff to production",icon:"external",kbd:"⇧⌘H",run:()=>P6({mode:"handoff"})},{id:"generate",group:"Canvas",label:"Generate with AI…",icon:"sparkle",run:()=>SJ(!0)},{id:"settings",group:"Canvas",label:"Settings…",icon:"sliders",kbd:"⌘,",run:()=>O5(!0)},{id:"system",group:"View",label:"Open design system view",icon:"sliders",kbd:"S",run:()=>S5()},{id:"comments",group:"View",label:"Toggle comments panel",icon:"resolve",kbd:"⌘⇧M",run:()=>h6("comments")},{id:"inspector",group:"View",label:"Open inspector",icon:"sliders",kbd:"⌘⇧I",run:()=>eX("inspector")},{id:"reload",group:"View",label:"Reload active canvas",icon:"reload",kbd:"⌘R",run:()=>dQ()},{id:"draw",group:"Tools",label:"Draw a mark with the SVG agent",icon:"pen",run:()=>{try{navigator.clipboard?.writeText("/design:draw ")}catch{}}},{id:"theme",group:"Tools",label:"Toggle light / dark theme",icon:"sun",run:()=>M4()},{id:"whatsnew",group:"Help",label:"What's new in maude",icon:"sparkle",run:()=>E5.openPanel()},{id:"shortcuts",group:"Help",label:"Keyboard shortcuts",icon:"help",kbd:"?",run:()=>l8(!0)},{id:"help",group:"Help",label:"Help · commands & flows",icon:"help",kbd:"F1",run:()=>oJ(!0)},{id:"report-bug",group:"Help",label:"Report a bug…",icon:"help",run:()=>W4(!0)}],[S5,M4,dQ,E5,lH,xY,dG,t0,a9,e0.designRel]),u80=(b)=>{if(O0&&b==="assistant")return!1;if(b==="sync")return!!k0;return b==="assistant"?G8():b==="layers"?n==="separate":!0},Lk=(b)=>Wk.filter((S)=>u80(S.id)&&(NJ[S.id]||sK[S.id])===b).map((S)=>S.id),Dk={tree:k8,layers:fQ,inspector:bJ,comments:h8,changes:W9,sync:x9,assistant:_X},Mk=e0.cloud?{changes:"History"}:null,Ok=Lk("left"),Ak=Lk("right"),_4=Ok.find((b)=>Dk[b])||null,gY=Ak.find((b)=>Dk[b])||null,_k=G8()&&!O0&&(NJ.assistant||"right")==="left",wk=G8()&&!O0&&(NJ.assistant||"right")==="right",tG=(b)=>(NJ[b]||sK[b])==="left"?N0==="sb":N0==="rp",w1=V&&V!==r9&&/\.(tsx|html)$/i.test(V)?V:null,Ek=w1?HL(C9[w1]):0,Pk=(b)=>{if(b==="tree")return z(SF0,{cloud:e0.cloud,readOnly:O0,groups:J,activePath:V,previewPath:N,activeDsName:V===r9?L9?.ds?.name??null:null,onOpen:V6,onPreview:M,onOpenLinkedFile:A4,filesReady:Q,onShare:mH,onOpenSystem:S5,wsConnected:z0,search:$9,setSearch:w8,commentsByFile:C9,showHidden:J7,sectionsExpanded:rX,onToggleSection:yG,onNewBoard:H1,onDeleteBoard:K1,onMoveCanvas:U1,onNewFolder:V1,onDeleteFolder:q1,onRenameFolder:B1,onRenameCanvas:N1,onDuplicateCanvas:F1,onDeleteFile:L1,onRefresh:oG,refreshing:Z1,collapsed:!1,onCollapse:()=>wX("tree"),resizing:tG("tree"),dirtyByPath:lG,project:Z,gitBranch:T9?.branch,remoteSync:w0,onGetLatest:vY,canvasKinds:e0?.canvasKinds,syncStatus:k0,onLinkedHub:E9,onLocalProject:F9,savingIsManaged:I9});if(b==="changes")return z(Hw,{status:T9&&w0?{...T9,...w0}:T9,project:Z,readOnly:!G8()||O0,historyOnly:F8,cloudManaged:v7,resizing:tG("changes"),onClose:()=>H9(!1),onCommit:jG,onDiscard:jY,onPublish:vG,onGetLatest:vY,loadLog:async(S)=>{let i=await pG(S);if(uG(i!=="legacy"),i!=="legacy")return i;return(v7?gG:fY)(S)},historySource:mG?"project":v7?"cloud":"local",onRestoreVersion:async(S)=>{let i=await fetch("/_api/project/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:V,revision:S})}).catch(()=>null);return!!(i?await i.json().catch(()=>null):null)?.ok},onUndoAction:F8?void 0:async(S)=>{let i=await fetch("/_api/project/undo",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionId:S})}).catch(()=>null);return!!(i?await i.json().catch(()=>null):null)?.ok},cloudHistory:xG,onOpenCanvas:(S)=>V6(S),onOpenDiff:(S)=>v0({file:S,beforeSha:"HEAD",conflict:!1}),activeCanvas:w1,onPreviewVersion:(S)=>v0({file:V,beforeSha:S,conflict:!1}),designRel:(e0?.designRel||e0?.designRoot||".design").replace(/^\/+|\/+$/g,"")});if(b==="sync")return z(Iw,{status:k0,project:e0?.cloud?.projectName||Z,cloud:e0?.cloud??null,groupPaths:(J||[]).map((S)=>S.path).filter(Boolean),resizing:tG("sync"),onClose:()=>S9(!1)});if(b==="inspector"||b==="layers")return z(wL0,{testId:b==="layers"?"layers-panel":"inspector-panel",layersOnly:b==="layers",hideLayersTab:n==="separate",cpMode:m9,onSetCpMode:e9,selected:A,cfg:e0,tab:b==="layers"?"layers":hQ,onTabChange:tX,onClose:()=>b==="layers"?Z4(!1):rJ(!1),onOptimistic:PX,onRecordEdit:eJ,onReplaceMedia:b80,onResizeArtboard:T,onSetArtboardHug:J0,onSetArtboardStyle:G0,onSetArtboardKind:Z9,onSetArtboardPrint:X8,onDuplicateArtboard:g,editScope:O,onUndoRedo:(S)=>T0({dgn:S}),photoSel:BG,photoRev:NG,onPhotoEdit:Q9,onPhotoRemoveBackground:kG,onPhotoRecordEdit:B4,onPhotoUndoRedo:(S)=>G9(S==="redo"),layersTree:r,componentMap:c,lockedKeys:L4,onToggleLock:bG,onDetachInstance:A1,canvasFile:V,onSelectLayer:(S)=>T0({dgn:"select-by-id",id:S.id,artboardId:r?.artboardId,index:S.index}),onHoverLayer:(S)=>T0({dgn:"highlight",id:S?S.id:null,artboardId:r?.artboardId,index:S?S.index:0}),onReorderLayer:rG,layersBusyRef:p,resizing:tG(b)});if(b==="comments")return z(JL0,{commentsByFile:C9,filter:M0,setFilter:_0,activePath:V,focusedId:x8,onJump:f80,onResolve:O0?void 0:y80,onReopen:O0?void 0:j80,onDelete:O0?void 0:v80,resizing:tG("comments")});return null};return D("div",{className:"maude"+(jJ?" is-present":""),"data-theme":f0,onContextMenu:g80,children:[jH&&z(Cw,{}),z(QL0,{cloud:e0.cloud}),z(YL0,{update:AG,onDismiss:()=>fH(null)}),z(WL0,{status:k0}),!jH&&z(Kw,{status:k0,cloud:e0.cloud}),z(Kg,{paused:!!I5||!!U4,hiddenGroups:K4.panelOpen?["exports"]:[]}),z(Im,{wn:E5}),z(Nm,{center:K4}),q0&&D("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:"Repo state changed — reload to sync?"}),z("button",{type:"button",className:"btn btn--primary btn--sm",onClick:()=>{try{window.location.reload()}catch{}},children:"Reload"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:()=>Z0(null),children:"Dismiss"})]}),D("div",{className:"st-shell",children:[z(lF0,{sharePath:xY,onShare:()=>mH(),readOnly:O0,cloud:e0.cloud,activePath:V,project:Z,tabsCount:K.length,openMenu:y9,setOpenMenu:W8,commentsPanelOpen:h8,onToggleComments:()=>h6("comments"),changesOpen:W9,changesCount:Q8,onToggleChanges:()=>h6("changes"),onOpenSystem:S5,sidebarOpen:k8,onToggleSidebar:()=>wX("tree"),showHidden:J7,onToggleShowHidden:()=>D5((b)=>!b),onOpenHelp:()=>oJ(!0),onOpenShortcuts:()=>l8(!0),onReportBug:()=>W4(!0),onStartTour:()=>EX(sN),onStartCollabTour:()=>EX(KE),annotationsVisible:XQ,onToggleAnnotations:CY,minimapVisible:QQ,onToggleMinimap:$Y,zoomCtlVisible:g6,onToggleZoomCtl:SY,presentMode:jJ,onTogglePresent:$G,printGuidesVisible:PG,onTogglePrintGuides:SG,postToActiveCanvas:T0,onOpenReadiness:()=>FX(!0),onOpenQuickSetup:()=>jQ(!0),onWatchIntro:()=>qY(!0),onOpenWhatsNew:E5.openPanel,whatsNewCount:E5.unseen.length,exportCenter:K4,artboardCount:l7,inspectorOpen:bJ,inspectorTab:hQ,onToggleInspector:()=>h6("inspector"),autoOpenInspector:U6,onToggleAutoOpenInspector:()=>LG((b)=>!b),onInsertArtboard:_7,timelineOpen:L0,onToggleTimeline:AY,hasComps:E0.length>0,assistantOpen:_X,onToggleAssistant:()=>h6("assistant"),assistantBusy:Q1,assistantUnseen:Y1,onOpenLayers:()=>{if(n==="separate")wX("layers");else if(bJ&&hQ==="layers")rJ(!1);else tX("layers"),k6("inspector")},onNewCanvas:()=>{k6("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60)},onAssembleVideo:z1,onOpenExport:(b)=>P6({mode:b}),onOpenSettings:()=>O5(!0),onOpenGenerate:()=>SJ(!0),onReload:dQ,onCloseCanvas:()=>V&&hY(V),presence:D(Q0,{children:[z(a90,{initials:MF0(gQ||"you"),hue:"var(--accent)",title:gQ?`${gQ} (you)`:"You"}),TG&&z(a90,{initials:"C",hue:"var(--presence-agent)",title:"Claude · editing",pulse:!0})]})}),D("div",{className:"st-body"+(N0?" is-resizing":""),ref:h9,children:[z(bF0,{shown:!_4,onExpand:()=>k6("tree"),onSearch:()=>{k6("tree"),setTimeout(()=>document.querySelector(".st-search input")?.focus(),60)}}),(_4||_k)&&D(n90,{side:"left",width:B9.w,open:!!_4,ids:Ok,activeId:_4,onPick:wX,labels:Mk,children:[_k&&z(PN,{hidden:_4!=="assistant",activeCanvas:w1,selected:A,openComments:Ek,designRel:(e0?.designRel||e0?.designRoot||".design").replace(/^\/+|\/+$/g,""),resizing:tG("assistant"),onClose:()=>UG(!1),onBusyChange:$H,onFinished:SH,onPermissionRequest:DY,onElicitationRequest:DY}),_4&&_4!=="assistant"&&Pk(_4)]}),_4&&z(t90,{label:"Resize left panel",size:B9,active:N0==="sb",onPointerDown:(b)=>{b.preventDefault(),b.currentTarget.setPointerCapture?.(b.pointerId),o0("sb")}}),z("div",{className:"main",children:z(dF0,{tabs:K,activePath:V,registerIframe:x80,systemData:L9,onOpenFromSystem:V6,onSelectDs:WQ,project:Z,cfg:e0,loadingPath:J9,onIframeLoad:g9,canvasError:X9,canvasReloadNonce:l0,onRetryCanvasLoad:G1,loadedPath:h0,showQuickSetup:G8()&&!O0&&!!V7&&!V7.ready,onStartQuickSetup:()=>jQ(!0),previewPath:N})}),gY&&z(t90,{label:"Resize right panel",dir:"rtl",size:D9,active:N0==="rp",onPointerDown:(b)=>{b.preventDefault(),b.currentTarget.setPointerCapture?.(b.pointerId),o0("rp")}}),(gY||wk)&&D(n90,{side:"right",width:D9.w,open:!!gY,ids:Ak,activeId:gY,onPick:wX,labels:Mk,children:[wk&&z(PN,{hidden:gY!=="assistant",activeCanvas:w1,selected:A,openComments:Ek,designRel:(e0?.designRel||e0?.designRoot||".design").replace(/^\/+|\/+$/g,""),resizing:tG("assistant"),onClose:()=>UG(!1),onBusyChange:$H,onFinished:SH,onPermissionRequest:DY,onElicitationRequest:DY}),gY&&gY!=="assistant"&&Pk(gY)]})]}),L0&&z(aw,{comps:E0,compId:T6,sequences:K6,audio:J6,transitions:MX,total:aX,frame:O9,playing:L8,loop:A5,onSeek:(b)=>{Z8(b),I6(!1),T0({dgn:"timeline-seek",frame:b,id:T6})},onPlay:()=>{I6(!0),T0({dgn:"timeline-mute",muted:FJ,id:T6}),T0({dgn:"timeline-loop",loop:A5,id:T6}),T0({dgn:"timeline-play",id:T6})},onPause:()=>{I6(!1),T0({dgn:"timeline-pause",id:T6})},onToggleLoop:()=>s6((b)=>{let S=!b;return T0({dgn:"timeline-loop",loop:S,id:T6}),S}),muted:FJ,onToggleMute:()=>{xQ((b)=>{let S=!b;return T0({dgn:"timeline-mute",muted:S,id:T6}),S})},volume:TH,onVolume:(b)=>{if(KG(b),b>0&&FJ)xQ(!1),T0({dgn:"timeline-mute",muted:!1,id:T6});T0({dgn:"timeline-volume",volume:b,id:T6})},onRetime:(b,S)=>{if(!V||V===r9)return;let i=X6||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${i?`&artboardId=${encodeURIComponent(i)}`:""}`;fetch(X0).then((H0)=>H0.json().catch(()=>({}))).then((H0)=>{let F0=R6(H0,b),A0=b&&typeof b==="object"?b.index:b,l=F0?.stableId?{canvas:V,artboardId:i,stableId:F0.stableId,contentHash:F0.contentHash,...S}:{canvas:V,index:A0,...S};return fetch("/_api/retime-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(l)})}).then((H0)=>H0.json()).then((H0)=>{if(!H0?.ok)console.warn("[retime]",H0?.error||"failed"),LJ("Retime refused",H0?.error);else if(f9(S.from!=null?"Clip moved.":"Clip trimmed.",!0),H0?.seq!=null)Y6(V,H0.seq,S.from!=null?"move clip":"trim clip")}).catch(()=>{})},onRemove:R5,onReplace:(b)=>{if(!V||V===r9)return;nG({accept:"video/*,image/*",resolveTarget:(S)=>{let i=R6(S,b);if(i?.mediaArrayRef)return{arrayRef:i.mediaArrayRef};if(i?.mediaCdId)return{cdId:i.mediaCdId};return null}})},onReplaceAudio:(b)=>{if(!V||V===r9)return;nG({accept:"audio/*",resolveTarget:(S)=>{let i=S?.ok&&Array.isArray(S.media)?S.media.filter((X0)=>X0.tag==="Audio"):[];return i[b]?.cdId?{cdId:i[b].cdId}:null}})},onReplaceLayer:(b,S)=>{if(!V||V===r9)return;let i=b&&typeof b==="object"?b.index:b,X0=K6[i]?.layers?.[S]?.kind==="audio"?"audio/*":K6[i]?.layers?.[S]?.kind==="image"?"image/*":"video/*";nG({accept:X0,resolveTarget:(H0)=>{let F0=R6(H0,b)?.layers?.[S];if(F0?.mediaArrayRef)return{arrayRef:F0.mediaArrayRef};if(F0?.mediaCdId)return{cdId:F0.mediaCdId};return null}})},onReorder:(b,S)=>{if(!V||V===r9)return;let i=X6||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${i?`&artboardId=${encodeURIComponent(i)}`:""}`;fetch(X0).then((H0)=>H0.json().catch(()=>({}))).then((H0)=>{let F0=H0?.ok&&Array.isArray(H0.clips)?H0.clips.filter((_9)=>_9.kind==="sequence"):[],A0=R6(H0,b),l=A0?F0.indexOf(A0):-1,D0=S==="forward"?l+1:l-1,P0=l>=0?F0[D0]||null:null,i0=S==="forward"?"after":"before";if(!A0?.stableId||!P0?.stableId)return null;return fetch("/_api/reorder-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:i,stableId:A0.stableId,contentHash:A0.contentHash,refStableId:P0.stableId,refContentHash:P0.contentHash,position:i0})})}).then((H0)=>H0?H0.json():null).then((H0)=>{if(H0&&!H0.ok)console.warn("[reorder-clip]",H0.error||"failed"),LJ("Reorder refused",H0.error);else if(H0?.seq!=null)Y6(V,H0.seq,"reorder clip")}).catch(()=>{})},onToggleHide:(b)=>{if(!V||V===r9)return;let S=X6||void 0,i=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${S?`&artboardId=${encodeURIComponent(S)}`:""}`;fetch(i).then((X0)=>X0.json().catch(()=>({}))).then((X0)=>{let H0=R6(X0,b);if(!H0?.stableId)return null;return fetch("/_api/toggle-hide",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:S,stableId:H0.stableId,contentHash:H0.contentHash})})}).then((X0)=>X0?X0.json():null).then((X0)=>{if(X0&&!X0.ok)LJ("Hide refused",X0.error);else if(X0&&X0.ok){if(f9(X0.hidden?"Clip hidden.":"Clip shown.",!0),X0.seq!=null)Y6(V,X0.seq,X0.hidden?"hide clip":"show clip")}}).catch(()=>f9("Hide failed: network error"))},onReorderMove:(b,S,i)=>{if(!V||V===r9)return;let X0=X6||void 0,H0=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${X0?`&artboardId=${encodeURIComponent(X0)}`:""}`;fetch(H0).then((F0)=>F0.json().catch(()=>({}))).then((F0)=>{let A0=R6(F0,b),l=R6(F0,S);if(!A0?.stableId||!l?.stableId)return null;return fetch("/_api/reorder-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:X0,stableId:A0.stableId,contentHash:A0.contentHash,refStableId:l.stableId,refContentHash:l.contentHash,position:i,mode:"move"})})}).then((F0)=>F0?F0.json():null).then((F0)=>{if(F0&&!F0.ok)console.warn("[reorder-move]",F0.error||"failed"),LJ("Reorder refused",F0.error);else if(F0?.ok){if(f9("Clip moved.",!0),F0.seq!=null)Y6(V,F0.seq,"move clip")}}).catch(()=>f9("Reorder failed: network error"))},onDropMedia:(b,S)=>{if(!V||V===r9)return;let i=X6||void 0,X0=NY,H0=V,F0=(Array.isArray(b)?b:[b]).filter(Boolean);(async()=>{if(!E0.length){let l=[];for(let P0 of F0){let i0=P0.type.startsWith("audio/")?"audio":P0.type.startsWith("video/")?"video":null;if(!i0)continue;try{let _9=await fetch("/_api/asset",{method:"POST",headers:{"Content-Type":P0.type||"application/octet-stream"},body:P0}),A9=await _9.json().catch(()=>({}));if(A9?.path)l.push({src:A9.path,mediaKind:i0});else f9(`Upload failed: ${A9?.error||`HTTP ${_9.status}`}`)}catch{f9("Upload failed: network error")}}if(!l.length){f9("No video/audio files in the drop — nothing to cut.");return}let D0=!1;for(let P0 of l){let i0=await lw(P0.src).catch(()=>null),_9={canvas:H0,lane:P0.mediaKind==="audio"&&D0?"audio":"storyline",durationInFrames:G3(X0,i0),mediaTag:P0.mediaKind==="audio"?"Audio":"Video",src:P0.src};if(_9.lane==="audio")_9.from=0;let A9=await fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(_9)}).catch(()=>null),q6=A9?await A9.json().catch(()=>null):null;if(q6?.ok){if(D0=!0,q6.seq!=null)Y6(H0,q6.seq,"add clip")}else if(!D0)break;else LJ("Insert refused",q6?.error)}if(D0){f9("Artboard upgraded to a video comp — clips added to the storyline.",!0);return}for(let P0=0;P0<8;P0+=1){let i0=P0===0?"New Cut":`New Cut ${P0+1}`,_9=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:i0,kind:"video-comp",clips:l})}).catch(()=>null),A9=_9?await _9.json().catch(()=>({})):{};if(_9?.status===409)continue;if(!_9?.ok||!A9.ok){f9(`New cut failed: ${A9.error||"create refused"}`);return}await y8(),V6(A9.file),f9(`Started a new cut from ${l.length} clip${l.length>1?"s":""}.`,!0);return}f9('New cut failed: too many "New Cut" canvases — rename some.');return}let A0=S?.lane==="storyline"?S.index:void 0;for(let l of F0){let D0=l.type.startsWith("video/")?"Video":l.type.startsWith("audio/")?"Audio":l.type.startsWith("image/")?"Img":null;if(!D0)continue;let P0;try{P0=await(await fetch("/_api/asset",{method:"POST",headers:{"Content-Type":l.type||"application/octet-stream"},body:l})).json().catch(()=>({}))}catch{P0=null}if(!P0?.path){f9(`Upload failed: ${P0?.error||"server unreachable — retry in a moment"}`);continue}let i0=D0==="Audio",_9=D0==="Video"?await lw(P0.path).catch(()=>null):null,A9={canvas:H0,artboardId:i,mediaTag:D0,src:P0.path};if(S&&(i0||S.lane==="audio"))A9.lane="audio",A9.from=Math.max(0,S.frame??0),A9.durationInFrames=Math.max(X0,aX-A9.from);else if(S?.lane==="storyline"&&!i0){if(A9.lane="storyline",A0!=null)A9.index=A0,A0+=1;A9.durationInFrames=G3(X0,_9)}else if(S?.lane==="overlay"&&!i0){if((K6||[]).length===0)A9.lane="storyline";else A9.lane="overlay",A9.from=Math.max(0,S.frame??0);A9.durationInFrames=G3(X0,_9)}else if(!i0)A9.lane="storyline",A9.durationInFrames=G3(X0,_9);else A9.lane="audio",A9.from=0,A9.durationInFrames=Math.max(X0,aX);try{let w7=await(await fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(A9)})).json().catch(()=>null);if(w7&&!w7.ok)console.warn("[insert-clip]",w7.error||"failed"),LJ("Insert refused",w7.error);else if(w7?.ok){if(f9("Clip added to the timeline.",!0),w7.seq!=null)Y6(H0,w7.seq,"add clip")}}catch{f9("Insert failed: network error")}}})()},height:yJ,onResize:C7,onClose:()=>j0(!1),selectedClipId:CH,onSelect:FY,transitionClips:CG,onClipVerb:C5,comments:(C9[V]||[]).filter((b)=>b&&b.timeline),promptText:YQ,onAddComment:IY,onResolveComment:(b)=>$7({type:"comments-patch",id:b,patch:{status:"resolved"}}),onDeleteComment:(b)=>$7({type:"comments-delete",id:b}),onSplitAtPlayhead:()=>{let b=Q6.current,S=b.selected!=null?{stableId:b.selected}:null;if(!S){let i=b.sequences||[],X0=i.find((H0)=>H0.series&&b.frame>=H0.from&&b.frame<H0.from+H0.duration)||i.find((H0)=>b.frame>=H0.from&&b.frame<H0.from+H0.duration);if(X0?.stableId)S={stableId:X0.stableId}}if(S)C5(S,"split",{atFrame:b.frame});else f9("Nothing under the playhead to split.")},onAddTitle:(b)=>{if(!V||V===r9)return;Promise.resolve("Title").then((S)=>{if(!S)return;fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:X6||void 0,lane:"overlay",from:b,durationInFrames:Math.round(NY*3),mediaTag:"Title",src:S})}).then((X0)=>X0.json().catch(()=>null)).then((X0)=>{if(X0&&!X0.ok)LJ("Title refused",X0.error);else if(X0?.ok){if(f9("Title added.",!0),X0.seq!=null)Y6(V,X0.seq,"add title")}}).catch(()=>f9("Title failed: network error"))})},onAddAiClip:()=>{if(!V||V===r9)return;(async()=>{fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:X6||void 0,lane:"storyline",durationInFrames:Math.round(NY*5),placeholder:{prompt:"Describe this shot — double-click to edit",kind:"veo"}})}).then((X0)=>X0.json().catch(()=>null)).then((X0)=>{if(X0&&!X0.ok)LJ("AI clip refused",X0.error);else if(X0?.ok){if(f9("AI placeholder added — double-click its text to write the prompt, then right-click → Generate ✨.",!0),X0.seq!=null)Y6(V,X0.seq,"add AI placeholder")}}).catch(()=>f9("AI clip failed: network error"))})()},onGeneratePlaceholder:(b)=>{if(!V||V===r9)return;let S=V,i=X6||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(S)}${i?`&artboardId=${encodeURIComponent(i)}`:""}`;fetch(X0).then((H0)=>H0.json().catch(()=>({}))).then((H0)=>{let F0=R6(H0,b),A0=F0?.placeholder;if(!F0?.stableId||!A0?.prompt){f9("No AI placeholder prompt on this clip.");return}let l=A0.kind==="image"?"image":"video",D0=A0.kind==="motion"?`Clean, minimal motion-graphics animation (flat shapes, smooth easing): ${A0.prompt}`:A0.prompt;fetch("/_api/generate-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({provider:"gemini",modality:l,prompt:D0})}).then(async(P0)=>P0.ok?P0.json():Promise.reject(Error(await P0.text()))).then((P0)=>{let i0=P0?.id;if(!i0)throw Error("no job id");f9(`Generating ${A0.kind}… (runs in the background)`,!0);let _9=F0.stableId,A9=()=>{fetch("/_api/generate-jobs").then((q6)=>q6.json().catch(()=>({}))).then((q6)=>{let w7=(q6?.jobs||[]).find((_J)=>_J.id===i0);if(!w7||w7.status==="failed"){f9(`Generation failed: ${w7?.error||"job lost"}`);return}if(w7.status!=="done"){setTimeout(A9,4000);return}let d8=w7.assets?.[0];if(!d8){f9("Generation finished but produced no asset.");return}fetch(X0).then((_J)=>_J.json().catch(()=>({}))).then((_J)=>{let eG=R6(_J,{stableId:_9});if(!eG?.stableId){f9("Placeholder clip is gone — generated asset kept in assets/.");return}C5({stableId:eG.stableId},"resolve-placeholder",{src:d8,mediaKind:l==="image"?"image":"video"})})}).catch(()=>setTimeout(A9,6000))};setTimeout(A9,3000)}).catch((P0)=>f9(`Generate failed: ${P0?.message||"provider error"} — is a Gemini key set in Settings?`))}).catch(()=>f9("Generate failed: network error"))},onAddImage:(b)=>{if(!V||V===r9)return;let S=(X0,H0)=>{let F0=NY;fetch("/_api/asset",{method:"POST",headers:{"Content-Type":H0||"application/octet-stream"},body:X0}).then((A0)=>A0.json().catch(()=>({}))).then((A0)=>{if(!A0?.path)return f9(`Upload failed: ${A0?.error||"unknown error"}`),null;return fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:X6||void 0,lane:"overlay",from:b,durationInFrames:Math.round(F0*3),mediaTag:"Img",src:A0.path})})}).then((A0)=>A0?A0.json():null).then((A0)=>{if(A0&&!A0.ok)LJ("Image refused",A0.error);else if(A0?.ok){if(f9("Image overlay added.",!0),A0.seq!=null)Y6(V,A0.seq,"add image overlay")}}).catch(()=>f9("Image failed: network error"))};if(G8()){lZ().then((X0)=>{if(X0?.bytes)S(new Blob([new Uint8Array(X0.bytes)]),"")}).catch((X0)=>f9(`Image pick failed: ${X0?.message||"dialog error"}`));return}let i=document.createElement("input");i.type="file",i.accept="image/*",i.addEventListener("change",()=>{let X0=i.files?.[0];if(X0)S(X0,X0.type)}),i.click()},resolveMediaUrl:(b)=>`/${(e0?.designRel||e0?.designRoot||".design").replace(/^\/+|\/+$/g,"")}/${b}`}),z(eF0,{activePath:V,selected:A,wsConnected:z0,openCount:h80,theme:f0,onToggleTheme:M4,onClearSelected:D1,syncStatus:k0,syncProject:e0?.cloud?.projectName||Z,syncOpen:x9,onOpenSync:k0?()=>h6("sync"):void 0,changesCount:Q8,unpushed:I9?0:T9?.unpushed||0,savingIsManaged:I9,changesOpen:W9,onOpenChanges:T9?.repo?()=>H9(!0):void 0,version:e0?.version})]}),jJ&&D("button",{type:"button",className:"st-present-exit",onClick:F4,"aria-label":"Exit presentation mode",title:"Exit presentation mode (Esc)",children:[z("svg",{viewBox:"0 0 16 16",width:"13",height:"13",fill:"none","aria-hidden":"true",children:z("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})}),z("span",{children:"Exit presentation"}),z("kbd",{className:"st-present-exit-kbd",children:"Esc"})]}),z(DF0,{open:q7,onClose:()=>z6(!1),actions:m80}),$5&&z("div",{className:"st-scrim",role:"presentation",onMouseDown:(b)=>{if(b.target===b.currentTarget)pQ(null)},children:D("div",{className:"st-dialog st-prompt",role:"dialog","aria-modal":"true","aria-label":$5.title,children:[z("div",{className:"st-dialog-hd",children:z("span",{className:"st-dialog-title",children:$5.title})}),D("div",{className:"st-dialog-bd",children:[z("input",{className:"st-input","data-testid":"shell-prompt-input",autoFocus:!0,defaultValue:$5.value,onKeyDown:(b)=>{if(b.stopPropagation(),b.key==="Enter")pQ(b.currentTarget.value);else if(b.key==="Escape")pQ(null)}}),D("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:10},children:[z("button",{type:"button",className:"tlci-btn",onClick:()=>pQ(null),children:"Cancel"}),z("button",{type:"button",className:"tlci-btn","data-testid":"shell-prompt-ok",onClick:(b)=>pQ(b.currentTarget.closest(".st-dialog")?.querySelector("input")?.value??""),children:"OK"})]})]})]})}),$J&&z(Ug,{target:$J,links:gH($J.path),shell:dG,onClose:()=>vQ(null),Icon:T8}),M5&&z(TF0,{mode:M5.mode,initialScope:M5.scope,activePath:V,hasComps:E0.length>0,comps:E0,activeArtboardId:A?.artboardId??R8??null,selection:A?.selector?{selector:A.selector,file:A.file}:null,exportLane:e0.exportLane||"local",onBrowserCapture:k5,onClose:()=>P6(null)}),G4&&z(WE,{cloud:e0.cloud,onClose:()=>O5(!1),initialTab:typeof G4==="string"?G4:void 0,theme:f0,onSetTheme:Y9,cpMode:m9,onSetCpMode:e9,minimapVisible:QQ,onToggleMinimap:$Y,zoomCtlVisible:g6,onToggleZoomCtl:SY,annotationsVisible:XQ,onToggleAnnotations:CY,autoOpenInspector:U6,onToggleAutoOpenInspector:()=>LG((b)=>!b),hasCanvas:!!V&&V!==r9,panelSide:NJ,onSetPanelSide:(b,S)=>H4((i)=>({...i,[b]:S})),layersMode:n,onSetLayersMode:(b)=>{if(W0(b),b!=="separate")Z4(!1)}}),zG&&z(tw,{onClose:()=>SJ(!1),onInsert:O1}),sG&&z(IF0,{designRel:(e0?.designRel||e0?.designRoot||".design").replace(/^\/+|\/+$/g,""),onPick:C80,onClose:()=>_1(null),multiple:!!sG.multiple,hasArtboardAnchor:!!sG.hasArtboardAnchor,onPickMany:$80}),LL&&z(GE,{onPick:S80,onClose:()=>DL(null)}),O8&&z(Zw,{target:O8,cfg:e0,loadLog:fY,onClose:()=>v0(null),onRestore:async(b)=>{let S=await jY([b]);if(S?.ok)v0(null);else window.alert(S?.error||"Could not restore that version. Try again.")},onResolve:async(b)=>{let S=await fG(b);if(S.ok)v0(null);else window.alert(S.error||"Could not finish the merge. Get the latest again, then retry.")}}),z(vF0,{open:nJ,onClose:()=>l8(!1)}),z(yF0,{open:iJ,onClose:()=>oJ(!1),onStartTour:()=>{oJ(!1),EX(sN)}}),z(Om,{open:e7,activeCanvas:V,onClose:()=>W4(!1)}),z(Tm,{wn:E5,onStartTour:EX}),z(Fm,{center:K4}),z(Mh,{open:R7,onClose:()=>FX(!1)}),z(RV,{open:j8,onClose:()=>qY(!1)}),z(yw,{open:p7,onClose:()=>jQ(!1),onStartTour:()=>EX(Gm),onBringBrand:()=>f7(!0),onImportFigma:()=>LX(!0)}),z($w,{open:HG,onClose:()=>f7(!1)}),BY&&z(Sw,{onClose:()=>LX(!1),onImported:()=>y8()}),I5&&!U4&&!vH&&D("div",{className:"mdcc-tour-nudge",role:"status","aria-live":"polite",children:[z("div",{className:"mdcc-tour-nudge__body",children:"New here? Take a 60-second tour of the canvas browser."}),z("button",{type:"button",className:"mdcc-tour-nudge__cta",onClick:()=>{V4(),EX(sN)},children:"Start"}),z("button",{type:"button",className:"mdcc-tour-nudge__skip","aria-label":"Dismiss",onClick:V4,children:"×"})]}),vH&&!U4&&D("div",{className:"mdcc-tour-nudge",role:"status","aria-live":"polite",children:[z("div",{className:"mdcc-tour-nudge__body",children:"New to working with a team? See how saving & sharing works — 60 seconds."}),z("button",{type:"button",className:"mdcc-tour-nudge__cta",onClick:()=>{DJ(),EX(KE)},children:"Start"}),z("button",{type:"button",className:"mdcc-tour-nudge__skip","aria-label":"Dismiss",onClick:DJ,children:"×"})]}),z(Wm,{steps:U4??[],open:!!U4,onClose:()=>P5(null),onComplete:V4,bus:wG,hasSelection:!!A,hasCanvas:K.length>0})]})}D80.createRoot(document.getElementById("root")).render(z(EL0,{}));
5689
+ You can restore it from .design/_trash/.`))return;try{let i=await fetch(`/_api/canvas?file=${encodeURIComponent(b)}`,{method:"DELETE"}),X0=await i.json().catch(()=>({}));if(!i.ok||!X0.ok){f9(`Could not delete: ${X0.error||`error ${i.status}`}`);return}await y8()}catch(i){f9(`Delete failed: ${i instanceof Error?i.message:"network error"}`)}},[y8]),D1=u.useCallback(()=>{if($7({type:"clear-select"}),E(null),V&&V!==r9){let b=i9.current.get(V);if(b&&b.contentWindow)try{b.contentWindow.postMessage({dgn:"force-clear"},"*")}catch{}}},[V]);u.useEffect(()=>{if(!V||V===r9)return;let b=i9.current.get(V);if(!b||!b.contentWindow)return;let S=jJ?[]:C9[V]||[];try{b.contentWindow.postMessage({dgn:"comments-set",comments:S},"*")}catch{}},[V,C9,jJ]),u.useEffect(()=>{let b=(F0)=>!!V&&(C9[V]||[]).some((A0)=>A0&&A0.id===F0);function S(F0){let A0=e0?.canvasOrigin||window.location.origin;if(F0.origin!==A0)return;let l=F0.data;if(!l||typeof l!=="object"||!l.dgn)return;if(l.dgn==="canvas-notice"){let D0=V&&V!==r9?i9.current.get(V)?.contentWindow:null,P0=Zm(F0,A0,D0);if(P0)zg(P0.title,P0.kind);return}if(l.dgn==="tool-cursor"){if(l.tool==="browse"){document.body.style.cursor="";let P0=document.getElementById("dc-app-cursor");if(P0)P0.textContent="";ZL(O0);return}let D0=Pb(l.tool);if(D0){document.body.style.cursor=D0;let P0=document.getElementById("dc-app-cursor");if(!P0)P0=document.createElement("style"),P0.id="dc-app-cursor",document.head.appendChild(P0);P0.textContent=`* { cursor: ${D0} !important; }`}return}if(l.dgn==="select"||l.dgn==="select-set"||l.dgn==="clear-select"||l.dgn==="edit-text"||l.dgn==="apply-edit"){let D0=V&&V!==r9?i9.current.get(V)?.contentWindow:null;if(F0.source!==D0)return}if(l.dgn==="select"&&l.selection)MY(null),k.current=Date.now(),$7({type:"select",selection:l.selection}),E(l.selection),OG(l.selection);else if(l.dgn==="select-set"){MY(null),k.current=Date.now();let D0=l.selection;if(D0==null)$7({type:"clear-select"}),E(null);else if(Array.isArray(D0)){let P0=D0[0]??null;if(P0)$7({type:"select",selection:P0});if(E(P0),D0.length===1)OG(P0)}else $7({type:"select",selection:D0}),E(D0),OG(D0)}else if(l.dgn==="clear-select")MY(null),k.current=Date.now(),$7({type:"clear-select"}),E(null);else if(l.dgn==="edit-text"&&l.id){let D0=F0.source,P0=(i0)=>{try{D0?.postMessage({dgn:"edit-reverted",op:"text",id:l.id,reason:i0},"*")}catch{}};fetch("/_api/edit-text",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:l.file,id:l.id,text:l.text??"",...typeof l.occurrence==="number"?{occurrence:l.occurrence}:{},...typeof l.before==="string"?{before:l.before}:{}})}).then((i0)=>i0.json().catch(()=>({}))).then((i0)=>{if(!i0.ok)P0(i0.error||"this element can't be edited inline")}).catch(()=>P0("network error"))}else if(l.dgn==="apply-edit"&&l.id&&(l.op==="css"||l.op==="text"||l.op==="attr")){let D0=vb(l);if(!D0)return;let P0=F0.source,i0=(A9)=>{if(typeof l.requestId!=="string")return;try{P0?.postMessage({dgn:"apply-edit-result",requestId:l.requestId,...A9},"*")}catch{}},_9=typeof l.value==="string"?l.value:null;m6.current=m6.current.catch(()=>{}).then(()=>fetch(D0.url,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(D0.body)}).then((A9)=>A9.json().catch(()=>({}))).then((A9)=>{if(A9.ok){if(D0.op==="css")PX({id:l.id,prop:l.key,value:_9});i0({ok:!0});return}console.warn("[apply-edit]",D0.op,A9.error||"failed"),i0({ok:!1,error:A9.error||"failed",conflict:A9.conflict===!0})}).catch(()=>i0({ok:!1,error:"network error"})))}else if(l.dgn==="layers-tree"){e({artboardId:l.artboardId,nodes:Array.isArray(l.tree)?l.tree:[]});let D0=KF0(l.tree);if(m.current={tree:l.tree,sig:D0,artboardId:l.artboardId??null},p.current=!1,v.current)clearTimeout(v.current),v.current=null;d.current?.(l.tree,D0,l.artboardId??null)}else if(l.dgn==="reorder-revert"){let D0=V?i9.current.get(V)?.contentWindow:null,P0=typeof l.seq==="number"&&(l.dir==="undo"||l.dir==="redo");if(F0.source===D0&&P0&&V){if(p.current=!0,v.current)clearTimeout(v.current);v.current=setTimeout(()=>{p.current=!1,v.current=null},700),fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,seq:l.seq,dir:l.dir})}).then((i0)=>i0.json().catch(()=>({}))).then((i0)=>{if(!i0.ok)console.warn("[reorder-revert]",i0.error||"failed")}).catch(()=>{})}}else if(l.dgn==="reorder-request"){let D0=V?i9.current.get(V)?.contentWindow:null,P0=typeof l.id==="string"&&typeof l.refId==="string"&&(l.position==="before"||l.position==="after"||l.position==="inside-start"||l.position==="inside-end");if(F0.source===D0&&P0)a.current?.(l.id,l.refId,l.position,{idIndex:Number.isInteger(l.idIndex)?l.idIndex:void 0,refIndex:Number.isInteger(l.refIndex)?l.refIndex:void 0})}else if(l.dgn==="reposition-request"){let D0=V?i9.current.get(V)?.contentWindow:null,P0=typeof l.id==="string"&&Number.isFinite(l.left)&&Number.isFinite(l.top)&&Number.isFinite(l.beforeLeft)&&Number.isFinite(l.beforeTop);if(F0.source===D0&&P0)f.current?.(l.id,l.left,l.top,l.beforeLeft,l.beforeTop,Number.isInteger(l.idIndex)?l.idIndex:void 0)}else if(l.dgn==="resize-request"){let D0=V?i9.current.get(V)?.contentWindow:null,P0=typeof l.id==="string"&&l.patch&&typeof l.patch==="object";if(F0.source===D0&&P0)h.current?.(l.id,l.patch,l.before,Number.isInteger(l.idIndex)?l.idIndex:void 0)}else if(l.dgn==="delete-request"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof l.id==="string")JX.current?.(l.id,Number.isInteger(l.idIndex)?l.idIndex:void 0)}else if(l.dgn==="duplicate-request"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof l.id==="string")Vk.current?.(l.id,Number.isInteger(l.idIndex)?l.idIndex:void 0)}else if(l.dgn==="copy-style"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0)Bk.current?.()}else if(l.dgn==="paste-style"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof l.id==="string")Nk.current?.(l.id)}else if(l.dgn==="insert-request"){let D0=V?i9.current.get(V)?.contentWindow:null,P0=typeof l.refId==="string",i0=typeof l.artboardId==="string",_9=l.position==="before"||l.position==="after"||l.position==="inside-start"||l.position==="inside-end",A9=P0!==i0&&(l.kind==="div"||l.kind==="text"||l.kind==="image")&&_9&&(!i0||l.position==="inside-start"||l.position==="inside-end");if(F0.source===D0&&A9)Hk.current?.(l.refId,l.position,l.kind,{artboardId:i0?l.artboardId:void 0,src:typeof l.src==="string"?l.src:void 0,refIndex:Number.isInteger(l.refIndex)?l.refIndex:void 0})}else if(l.dgn==="insert-image-request"){let D0=V?i9.current.get(V)?.contentWindow:null,P0=typeof l.refId==="string",i0=typeof l.artboardId==="string",_9=!P0&&!i0,A9=(P0!==i0||_9)&&(_9||l.position==="before"||l.position==="after"||l.position==="inside-start"||l.position==="inside-end")&&(!i0||l.position==="inside-start"||l.position==="inside-end");if(F0.source===D0&&A9)Nq.current?.({purpose:"insert-image",canvas:V,refId:l.refId,artboardId:i0?l.artboardId:void 0,position:_9?void 0:l.position,refIndex:Number.isInteger(l.refIndex)?l.refIndex:void 0,multiple:!0,hasArtboardAnchor:!_9})}else if(l.dgn==="replace-media-request"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof l.id==="string")Nq.current?.({purpose:"replace-src",canvas:V,id:l.id,before:typeof l.before==="string"?l.before:null})}else if(l.dgn==="convert-to-absolute-request"){let D0=V?i9.current.get(V)?.contentWindow:null,P0=Array.isArray(l.containers)&&l.containers.length>0,i0=typeof l.containerId==="string"&&Array.isArray(l.children)&&l.children.length>0;if(F0.source===D0&&(P0||i0)){let _9=P0?l.containers.reduce((A9,q6)=>A9+(Array.isArray(q6?.children)?q6.children.length:0),0):l.children.length;aG.current?.("/_api/convert-to-absolute",P0?{allowShared:l.allowShared===!0,containers:l.containers,...Array.isArray(l.dissolve)&&l.dissolve.length>0?{dissolve:l.dissolve}:{}}:{containerId:l.containerId,containerSetRelative:l.containerSetRelative===!0,allowShared:l.allowShared===!0,children:l.children},{label:"convert to absolute",onOk:()=>{T0({dgn:"selection-clear"}),T0({dgn:"op-toast",message:`Converted ${_9} element${_9===1?"":"s"} to absolute — press V and drag them freely (⌘Z to undo).`})},onFail:(A9)=>T0({dgn:"op-toast",message:`Convert failed: ${A9?.error||"unknown error"}`})})}}else if(l.dgn==="replace-annotation-media-request"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof l.id==="string")Nq.current?.({purpose:"replace-annotation-media",canvas:V,id:l.id,before:typeof l.before==="string"?l.before:null})}else if(l.dgn==="edit-annotation-photo-request"){let D0=V?i9.current.get(V)?.contentWindow:null,P0=Zk.exec(typeof l.asset==="string"?l.asset:"")?.[0]||null;if(F0.source===D0&&typeof l.id==="string"&&P0)MY({asset:P0,strokeId:l.id}),eX("inspector"),tX("photo")}else if(l.dgn==="open-sticker-picker"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0)Fk.current?.({canvas:V})}else if(l.dgn==="insert-artboard-request"){let D0=V?i9.current.get(V)?.contentWindow:null,P0=typeof l.id==="string"&&Number.isFinite(l.width)&&Number.isFinite(l.height);if(F0.source===D0&&P0)zk.current?.({id:l.id,label:typeof l.label==="string"?l.label:l.id,width:l.width,height:l.height})}else if(l.dgn==="resize-artboard-request"){let D0=V?i9.current.get(V)?.contentWindow:null,P0=typeof l.artboardId==="string"&&(Number.isFinite(l.width)||Number.isFinite(l.height));if(F0.source===D0&&P0)Kk.current?.(l.artboardId,Number.isFinite(l.width)?l.width:void 0,Number.isFinite(l.height)?l.height:void 0)}else if(l.dgn==="delete-artboard-request"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof l.artboardId==="string")Uk.current?.(l.artboardId)}else if(l.dgn==="rename-artboard-request"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof l.artboardId==="string"&&typeof l.label==="string"&&l.label.trim())aG.current?.("/_api/set-artboard-label",{artboardId:l.artboardId,label:l.label.slice(0,80)},{label:"rename artboard"})}else if(l.dgn==="set-artboard-kind-request"){let D0=V?i9.current.get(V)?.contentWindow:null,P0=l.kind===null||typeof l.kind==="string";if(F0.source===D0&&typeof l.artboardId==="string"&&P0)c0.current?.(l.artboardId,l.kind)}else if(l.dgn==="duplicate-artboard-request"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof l.artboardId==="string"&&Number.isFinite(l.width))qk.current?.(l.artboardId,l.width)}else if(l.dgn==="open-inspector"){if(eX("inspector"),typeof l.tab==="string")tX(l.tab)}else if(l.dgn==="present-enter"){let D0=V?i9.current.get(V)?.contentWindow:null,P0=!!document.querySelector('[role="dialog"][aria-modal="true"]');if(F0.source===D0&&!P0&&!jJ)q4(!0),MJ({present:!0})}else if(l.dgn==="comment-compose"&&l.selection)E(l.selection);else if(l.dgn==="comment-submit"&&l.payload&&typeof l.payload.text==="string"){let D0=l.payload,P0=String(D0.text).trim(),i0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===i0&&P0&&V&&V!==r9)$7({type:"comments-add",payload:{file:V,selector:D0.selector,index:D0.index,dom_path:D0.dom_path,tag:D0.tag,classes:D0.classes,bounds:D0.bounds,html_excerpt:D0.html_excerpt,text:P0}})}else if(l.dgn==="comment-patch"&&l.id&&l.patch&&typeof l.patch==="object"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0&&b(l.id))$7({type:"comments-patch",id:l.id,patch:l.patch})}else if(l.dgn==="comment-delete"&&l.id){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0&&b(l.id))$7({type:"comments-delete",id:l.id}),i8((P0)=>P0===l.id?null:P0)}else if(l.dgn==="comment-click"&&l.id)i8(l.id);else if(l.dgn==="artboards"&&typeof l.count==="number"){let D0=Math.round(l.count);if(Number.isFinite(D0)&&D0>=0&&D0<=999)sJ(D0)}else if(l.dgn==="active-artboard"){let D0=V&&V!==r9?i9.current.get(V)?.contentWindow:null;if(F0.source!==D0)return;DX(dN(l.id))}else if(l.dgn==="timeline-comps"&&Array.isArray(l.comps)){let D0=V&&V!==r9?i9.current.get(V)?.contentWindow:null;if(F0.source!==D0)return;let P0=l.comps.filter((A9)=>A9&&typeof A9.id==="string").slice(0,32).map((A9)=>({id:String(A9.id).slice(0,120),fps:Math.max(1,Math.min(120,Math.round(Number(A9.fps)||30))),durationInFrames:Math.max(1,Math.min(1e6,Math.round(Number(A9.durationInFrames)||1))),width:Math.max(1,Math.round(Number(A9.width)||0)),height:Math.max(1,Math.round(Number(A9.height)||0)),artboardId:dN(A9.artboardId),artboardLabel:dN(A9.artboardLabel)}));z9(P0);let i0=sX.current;if(i0&&P0.some((A9)=>A9.id===i0)&&OX.current>0)T0({dgn:"timeline-seek",frame:OX.current,id:i0})}else if(l.dgn==="timeline-frame"&&typeof l.frame==="number"){let D0=V&&V!==r9?i9.current.get(V)?.contentWindow:null;if(F0.source!==D0)return;if(l.id&&sX.current&&l.id!==sX.current)return;if(Number.isFinite(l.frame))Z8(Math.max(0,Math.round(l.frame)))}else if(l.dgn==="timeline-ended"){let D0=V&&V!==r9?i9.current.get(V)?.contentWindow:null;if(F0.source!==D0)return;if(l.id&&sX.current&&l.id!==sX.current)return;I6(!1)}else if(l.dgn==="toggle-palette")z6((D0)=>!D0);else if(l.dgn==="shell-shortcut"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0){if(l.id==="reload")dQ();else if(l.id==="inspector")h6("inspector");else if(l.id==="assistant"&&G8())h6("assistant");else if(l.id==="comments")h6("comments");else if(l.id==="changes")h6("changes");else if(l.id==="timeline")AY();else if(l.id==="export")P6({mode:"export"});else if(l.id==="handoff")P6({mode:"handoff"})}}else if(l.dgn==="open-export"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0)P6({mode:"export",scope:l.detail&&typeof l.detail.scope==="string"?l.detail.scope:void 0})}else if(l.dgn==="open-timeline-request"){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source===D0){if(typeof l.artboardId==="string")DX(l.artboardId.slice(0,120));j0(!0)}}else if(l.dgn==="loaded"&&l.file){r0((i0)=>i0===l.file?null:i0),y0(l.file),q9((i0)=>i0&&i0.path===l.file?null:i0);let D0=jJ?[]:C9[l.file]||[],P0=[...i9.current.entries()].find(([i0])=>i0===l.file)?.[1];if(P0&&P0.contentWindow){try{P0.contentWindow.postMessage({dgn:"comments-set",comments:D0},"*")}catch{}try{P0.contentWindow.postMessage({dgn:"theme",theme:f0},"*")}catch{}try{P0.contentWindow.postMessage({dgn:"view-chrome",minimap:QQ,zoom:g6,present:jJ},"*")}catch{}if(x8&&D0.some((_9)=>_9.id===x8))try{P0.contentWindow.postMessage({dgn:"comment-focus",id:x8},"*")}catch{}let i0=x.current;if(i0&&i0.file===l.file){x.current=null;try{P0.contentWindow.postMessage({dgn:"request-layers",artboardId:i0.artboardId??null},"*")}catch{}if(i0.movedId)try{P0.contentWindow.postMessage({dgn:"select-by-id",id:i0.movedId,artboardId:i0.artboardId??null,index:0},"*")}catch{}}else{let _9=w.current,A9=Array.isArray(_9)?_9[0]:_9;if(A9&&A9.id&&A9.file===l.file)$(A9)}}}else if(l.dgn==="export-request"&&l.id&&l.payload){let D0=V?i9.current.get(V)?.contentWindow:null;if(F0.source!==D0)return;X0(F0.source,l.id,l.payload)}else if(l.dgn==="export-history-request"&&l.id)H0(F0.source,l.id)}let i=e0?.canvasOrigin||window.location.origin;async function X0(F0,A0,l){if(l?.options&&V&&V!==r9)l.options.canvasFile=V;let D0=(_9)=>{try{if(F0)F0.postMessage({dgn:"export-result",id:A0,..._9},i)}catch{}},P0=l?.options||{};if(a2({exportLane:e0.exportLane||"local",format:l?.format,scope:l?.scope,artboardId:P0.artboardId}))try{if(l.format==="pptx"){let{filename:_9,blob:A9}=await TO({capture:k5,name:V?V.replace(/^.*\//,"").replace(/\.[^.]+$/,""):"export"});UL(_9,A9)}else{let _9=RO(P0),A9=await k5({format:l.format,artboardIds:[P0.artboardId],scale:_9}),q6=await kO(A9,l.format);for(let w7 of q6)UL(w7.name,w7.blob)}D0({ok:!0,browser:!0});return}catch{if(e0.exportLane!=="remote"){D0({ok:!1,error:"Capturing in the browser failed and this workspace has no render service to fall back to — try again, or ask your admin to add maude-render."});return}}if(e0.exportLane==="none"&&l?.format!=="zip"){D0({ok:!1,error:"This format needs the render service, which this workspace doesn’t have configured. PNG/SVG of the active artboard and the PPTX deck export straight from the browser; ZIP works too. For the rest use the desktop app or ask your admin to add maude-render."});return}try{let _9=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(l)});if(!_9.ok){D0({ok:!1,error:await _9.text()||String(_9.status)});return}let{jobId:A9}=await _9.json();D0({ok:!0,jobId:A9})}catch(_9){D0({ok:!1,error:_9&&_9.message?_9.message:String(_9)})}}async function H0(F0,A0){let l=[];try{let D0=await fetch("/_api/export-history");if(D0.ok){let P0=await D0.json();if(Array.isArray(P0.history))l=P0.history}}catch{}try{if(F0)F0.postMessage({dgn:"export-history-result",id:A0,history:l},i)}catch{}}return window.addEventListener("message",S),()=>window.removeEventListener("message",S)},[C9,x8,e0,f0,dQ,jJ,QQ,g6,MJ,V,T0,k5]);let M1=u.useCallback(()=>{if(!V||V===r9)return;let b=i9.current.get(V);if(b&&b.contentWindow)try{b.contentWindow.postMessage({dgn:"force-clear"},"*")}catch{}},[V]),PX=u.useCallback((b)=>{if(!V||V===r9)return;let S=i9.current.get(V);if(S&&S.contentWindow)try{S.contentWindow.postMessage({dgn:"apply-style",...b},"*")}catch{}},[V]),eJ=u.useCallback((b)=>{if(!V||V===r9||!b)return;let S=i9.current.get(V);if(S&&S.contentWindow)try{S.contentWindow.postMessage({dgn:"record-edit",payload:b},"*")}catch{}},[V]),m6=u.useRef(Promise.resolve()),rG=u.useCallback((b,S,i,X0)=>{let H0=Number.isInteger(X0?.idIndex)?X0.idIndex:void 0,F0=Number.isInteger(X0?.refIndex)?X0.refIndex:void 0;if(!b||!S)return;if(b===S&&(H0??0)===(F0??0))return;let A0=w.current,l=Array.isArray(A0)?A0[0]:A0,D0=V;if(!D0)return;let P0=V,i0=r?.artboardId??l?.artboardId??null;if(e((_9)=>_9?{..._9,nodes:NL0(_9.nodes,b,S,i)}:_9),p.current=!0,v.current)clearTimeout(v.current);v.current=setTimeout(()=>{p.current=!1,v.current=null},700),m6.current=m6.current.catch(()=>{}).then(()=>fetch("/_api/reorder",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:D0,id:b,refId:S,position:i,idIndex:H0,refIndex:F0})}).then((_9)=>_9.json().catch(()=>({}))).then((_9)=>{if(!_9.ok){if(console.warn("[reorder]",_9.error||"failed"),T0({dgn:"reorder-failed"}),T0({dgn:"request-layers",artboardId:i0}),p.current=!1,v.current)clearTimeout(v.current),v.current=null;return}if(x.current={file:P0,movedId:_9.movedId||null,artboardId:i0},typeof _9.seq==="number")T0({dgn:"record-edit",payload:{op:"reorder",canvas:D0,seq:_9.seq,label:"move element"}})}).catch(()=>{}))},[V,r,T0]);u.useEffect(()=>{a.current=rG},[rG]);let dH=u.useCallback((b,S,i,X0,H0,F0)=>{if(!b||!V)return;let A0=V,l=Number.isInteger(F0)?F0:void 0;PX({id:b,prop:"left",value:`${S}px`}),PX({id:b,prop:"top",value:`${i}px`});let D0=null,P0=(i0,_9)=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:A0,id:b,property:i0,value:`${_9}px`,idIndex:l})}).then((A9)=>A9.json().catch(()=>({})));m6.current=m6.current.catch(()=>{}).then(()=>P0("left",S)).then((i0)=>{if(!i0.ok)throw Error(i0.error||"left write failed");return D0=i0,P0("top",i)}).then((i0)=>{if(!i0.ok)throw Error(i0.error||"top write failed");eJ({op:"css",canvas:A0,id:b,key:"left",before:Uq(D0,`${X0}px`),after:`${S}px`}),eJ({op:"css",canvas:A0,id:b,key:"top",before:Uq(i0,`${H0}px`),after:`${i}px`})}).catch((i0)=>{console.warn("[reposition]",i0?.message||i0),T0({dgn:"reposition-failed"})})},[V,T0,eJ,PX]);u.useEffect(()=>{f.current=dH},[dH]);let cH=u.useCallback((b,S,i,X0)=>{if(!b||!V||!S||typeof S!=="object")return;let H0=V,F0=i&&typeof i==="object"?i:{},A0=Number.isInteger(X0)?X0:void 0,l=["width","height","left","top","transform","padding-top","padding-right","padding-bottom","padding-left","gap","grid-template-columns","grid-template-rows"].filter((d8)=>typeof S[d8]==="string"&&S[d8]);if(!l.length)return;let D0=w.current,P0=Array.isArray(D0)?D0.length===1?D0[0]:null:D0,i0=P0&&P0.id===b?P0.artboardId??null:null,_9=P0&&P0.id===b?P0.index??0:0;for(let d8 of l)PX({id:b,artboardId:i0,index:_9,prop:d8,value:S[d8]});let A9=(d8,_J)=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:H0,id:b,property:d8,value:_J,idIndex:A0})}).then((eG)=>eG.json().catch(()=>({}))),q6={},w7=m6.current.catch(()=>{});for(let d8 of l)w7=w7.then((_J)=>{if(_J&&_J.ok===!1)throw Error(_J.error||`${d8} write failed`);return A9(d8,S[d8]).then((eG)=>{return q6[d8]=eG,eG})});m6.current=w7.then((d8)=>{if(d8&&d8.ok===!1)throw Error(d8.error||"resize write failed");for(let _J of l)eJ({op:"css",canvas:H0,id:b,key:_J,before:Uq(q6[_J],F0[_J]??null),after:S[_J]});$({id:b,file:H0,artboardId:i0,index:_9})}).catch((d8)=>{console.warn("[resize]",d8?.message||d8),T0({dgn:"resize-failed"})})},[V,T0,eJ,PX,$]);u.useEffect(()=>{h.current=cH},[cH]);let aG=u.useRef(null),Y7=u.useCallback((b,S,{label:i,onOk:X0,onFail:H0}={})=>{if(!V)return;let F0=V,A0=H0??((l)=>T0({dgn:"op-toast",message:`Couldn't ${i||"apply the edit"}${l?.error?` — ${l.error}`:""}.`}));m6.current=m6.current.catch(()=>{}).then(()=>fetch(b,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...S,canvas:F0})}).then((l)=>l.json().catch(()=>({}))).then((l)=>{if(!l.ok){console.warn(`[${b}]`,l.error||"failed"),A0?.(l);return}if(typeof l.seq==="number")T0({dgn:"record-edit",payload:{op:"reorder",canvas:F0,seq:l.seq,label:i||"edit"}});X0?.(l,F0)}).catch((l)=>A0?.({error:l?.message})))},[V,T0]);u.useEffect(()=>{aG.current=Y7},[Y7]);let iH=u.useCallback((b,S)=>{Y7("/_api/delete-element",{id:b,idIndex:Number.isInteger(S)?S:void 0},{label:"delete element",onOk:()=>T0({dgn:"selection-clear"})})},[Y7,T0]),GQ=u.useCallback((b,S,i,X0={})=>{let H0=m.current?.sig??null;Y7("/_api/insert-element",{refId:b,artboardId:typeof X0.artboardId==="string"?X0.artboardId:void 0,position:S,kind:i,src:typeof X0.src==="string"?X0.src:void 0,refIndex:Number.isInteger(X0.refIndex)?X0.refIndex:void 0},{label:`insert ${i}`,onOk:(F0,A0)=>{if(!F0.newId)return;x.current={file:A0,movedId:F0.newId,artboardId:null,staleSig:H0};let l=m.current;if(l)d.current?.(l.tree,l.sig,l.artboardId)}})},[Y7]),O1=u.useCallback((b)=>{if(typeof b!=="string"||!b)return!1;if(!V)return!1;let S=w.current?.artboardId??R8??null;if(!S)return!1;return GQ(void 0,"inside-end","image",{artboardId:S,src:b}),!0},[V,R8,GQ]),A1=u.useCallback((b,S)=>{Y7("/_api/detach-component",{id:b,idIndex:Number.isInteger(S)?S:void 0},{label:"detach instance",onOk:(i)=>{T0({dgn:"selection-clear"}),T0({dgn:"op-toast",message:`Detached — this instance is now ${i.detachedName||"its own component"}; edits stay local (⌘Z to undo).`})},onFail:(i)=>T0({dgn:"op-toast",message:`Detach failed: ${i?.error||"unknown error"}`})})},[Y7,T0]),oH=u.useCallback((b,S)=>{let i=m.current?.sig??null;Y7("/_api/duplicate-element",{id:b,idIndex:Number.isInteger(S)?S:void 0},{label:"duplicate element",onOk:(X0,H0)=>{if(!X0.newId)return;x.current={file:H0,movedId:X0.newId,artboardId:null,staleSig:i};let F0=m.current;if(F0)d.current?.(F0.tree,F0.sig,F0.artboardId)}})},[Y7]),nH=u.useRef(null),q=u.useMemo(()=>new Set(["position","top","right","bottom","left","inset","width","height","min-width","max-width","min-height","max-height","margin","margin-top","margin-right","margin-bottom","margin-left"]),[]),L=u.useCallback(()=>{let b=w.current,S=Array.isArray(b)?b.length===1?b[0]:null:b;if(!S)return;let i={};for(let[X0,H0]of Object.entries(S.authored||{}))if(!q.has(X0))i[X0]=H0;for(let[X0,H0]of Object.entries(S.customStyles||{}))if(!q.has(X0))i[X0]=H0;nH.current=Object.keys(i).length?i:null},[q]),_=u.useCallback((b)=>{let S=V,i=nH.current;if(!S||!b||!i)return;let X0=Object.entries(i),H0=m6.current.catch(()=>{});for(let[F0,A0]of X0)PX({id:b,prop:F0,value:A0}),H0=H0.then(()=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:S,id:b,property:F0,value:A0})}).then((l)=>l.json().catch(()=>({}))).then((l)=>{if(l.ok)eJ({op:"css",canvas:S,id:b,key:F0,before:Uq(l,null),after:A0})}).catch(()=>{}));m6.current=H0},[V,PX,eJ]),P=u.useCallback(({id:b,label:S,width:i,height:X0})=>{Y7("/_api/insert-artboard",{id:b,label:S,width:i,height:X0},{label:"insert artboard"})},[Y7]),T=u.useCallback((b,S,i)=>{Y7("/_api/resize-artboard",{artboardId:b,width:S,height:i},{label:"resize artboard",onFail:()=>T0({dgn:"resize-artboard-failed"}),onOk:()=>j(b,V)})},[Y7,T0,j,V]),y=u.useCallback((b)=>{Y7("/_api/delete-artboard",{artboardId:b},{label:"delete artboard"})},[Y7]),g=u.useCallback((b,S)=>{Y7("/_api/duplicate-artboard",{artboardId:b,width:S},{label:"duplicate artboard at width"})},[Y7]),J0=u.useCallback((b,S,i)=>{Y7("/_api/set-artboard-hug",{artboardId:b,fixed:S,freezeHeight:i},{label:S?"pin artboard height":"hug artboard height",onOk:()=>j(b,V)})},[Y7,j,V]),G0=u.useCallback((b,S)=>{Y7("/_api/set-artboard-style",{artboardId:b,...S},{label:"artboard style",onOk:()=>j(b,V)})},[Y7,j,V]),B0=u.useRef(null),R0=u.useCallback((b,S)=>{Y7("/_api/set-artboard-kind",{artboardId:b,kind:S},{label:"artboard kind",onOk:()=>j(b,V)});let i=B0.current;if(S==="print"&&i&&i.artboardId===b)B0.current=null,Y7("/_api/resize-artboard",{artboardId:b,width:i.widthPx,height:i.heightPx},{label:"artboard size"}),Y7("/_api/set-artboard-print",{artboardId:b,print:i.defaults},{label:"artboard print"})},[Y7,j,V]),c0=u.useRef(null);u.useEffect(()=>{c0.current=R0},[R0]);let Z9=u.useCallback((b,S,i)=>{if(S==="print"||S==null||S==="digital"){if(i)B0.current={artboardId:b,...i};T0({dgn:"freeze-and-set-kind",artboardId:b,kind:S==="digital"?null:S,ask:!0});return}R0(b,S)},[R0,T0]),X8=u.useCallback((b,S)=>{Y7("/_api/set-artboard-print",{artboardId:b,print:S},{label:"artboard print",onOk:()=>j(b,V)})},[Y7,j,V]),_7=u.useCallback((b)=>{let S=`s${Math.random().toString(36).slice(2,8)}`;if(b.startsWith("print-")){let X0=b.slice(6),H0;try{H0=r2({paper:X0})}catch{return}let F0=n2.find((A0)=>A0.id===X0);P({id:S,label:F0?F0.label:X0.toUpperCase(),width:H0.widthPx,height:H0.heightPx}),Z9(S,"print"),X8(S,{paper:X0});return}let i=bQ[b];if(!i)return;P({id:S,label:i.label,width:i.width,height:i.height})},[P,Z9,X8]),JX=u.useRef(null),Hk=u.useRef(null),zk=u.useRef(null),Kk=u.useRef(null),Uk=u.useRef(null),R80=u.useRef(null),Vk=u.useRef(null),qk=u.useRef(null),Bk=u.useRef(null),Nk=u.useRef(null);u.useEffect(()=>{JX.current=iH,Hk.current=GQ,zk.current=P,Kk.current=T,Uk.current=y,R80.current=Z9,Vk.current=oH,qk.current=g,Bk.current=L,Nk.current=_},[iH,GQ,P,T,y,Z9,oH,g,L,_]),u.useEffect(()=>{let b=(S)=>{if(S.key!=="Backspace"&&S.key!=="Delete")return;if(S.metaKey||S.ctrlKey||S.altKey)return;let i=S.target;if(i&&(i.tagName==="INPUT"||i.tagName==="TEXTAREA"||i.tagName==="SELECT"||i.isContentEditable))return;if(S.preventDefault(),!V||V===r9)return;let H0=Array.isArray(A)?A.length===1?A[0]:null:A;if(H0?.artboardId&&!H0.id)y(H0.artboardId)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[V,A,y]);let[sG,_1]=u.useState(null),Nq=u.useRef(null);u.useEffect(()=>{Nq.current=(b)=>_1(b)},[]);let[LL,DL]=u.useState(null),Fk=u.useRef(null);u.useEffect(()=>{Fk.current=(b)=>DL(b)},[]);let C80=u.useCallback((b)=>{let S=sG;if(_1(null),!S||!b)return;if(S.canvas&&S.canvas!==V){console.warn("[asset-picker] active canvas changed since request — aborting");return}if(S.purpose==="insert-image"){GQ(S.refId,S.position||"after","image",{artboardId:S.artboardId,src:b,refIndex:S.refIndex});return}if(S.purpose==="replace-src"){let i=V;if(!i||!S.id)return;m6.current=m6.current.catch(()=>{}).then(()=>fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:i,id:S.id,attr:"src",value:b})}).then((X0)=>X0.json().catch(()=>({}))).then((X0)=>{if(X0.ok)eJ({op:"attr",canvas:i,id:S.id,key:"src",before:Uq(X0,S.before??null),after:b});else console.warn("[replace-src]",X0.error||"failed")}).catch(()=>{}));return}if(S.purpose==="replace-annotation-media")T0({dgn:"replace-annotation-media",id:S.id,path:b})},[sG,GQ,V,eJ,T0]),$80=u.useCallback((b,S)=>{let i=sG;if(_1(null),!i||!Array.isArray(b)||!b.length)return;if(i.canvas&&i.canvas!==V){console.warn("[asset-picker] active canvas changed since request — aborting");return}if(S==="artboard"){let X0=w.current?.artboardId??R8??null;if(!X0)return;for(let H0 of b)GQ(void 0,"inside-end","image",{artboardId:X0,src:H0});return}T0({dgn:"insert-annotation-media",paths:b})},[sG,V,GQ,R8,T0]),S80=u.useCallback(async(b)=>{let S=LL;if(DL(null),!S||!b?.url)return;if(S.canvas&&S.canvas!==V){console.warn("[sticker-picker] active canvas changed since request — aborting");return}try{let i=await fetch(b.url).then((F0)=>F0.ok?F0.blob():Promise.reject(Error(`HTTP ${F0.status}`))),X0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":i.type||"image/png"},body:i}),H0=await X0.json().catch(()=>({}));if(!X0.ok||!H0.path){console.warn("[sticker-picker]",H0.error||`upload failed (HTTP ${X0.status})`);return}T0({dgn:"insert-sticker",path:H0.path})}catch{console.warn("[sticker-picker] could not load or upload that sticker")}},[LL,V,T0]),b80=u.useCallback((b)=>{if(!b?.id)return;_1({purpose:"replace-src",canvas:V,id:b.id,before:b.attrs?.src??null})},[V]),y80=u.useCallback((b)=>{$7({type:"comments-patch",id:b,patch:{status:"resolved"}})},[]),j80=u.useCallback((b)=>{$7({type:"comments-patch",id:b,patch:{status:"open"}})},[]),v80=u.useCallback((b)=>{$7({type:"comments-delete",id:b}),i8((S)=>S===b?null:S)},[]),f80=u.useCallback((b,S)=>{if(b&&b!==V)U((X0)=>X0.find((H0)=>H0.path===b)?X0:[...X0,{path:b}]),B(b);if(S==null){i8(null);return}i8(S);let i=()=>{let X0=i9.current.get(b);if(X0&&X0.contentWindow)try{X0.contentWindow.postMessage({dgn:"comment-focus",id:S},"*")}catch{}};i(),setTimeout(i,200)},[V]);u.useEffect(()=>{function b(S){let i=S.metaKey||S.ctrlKey,X0=["INPUT","TEXTAREA"].includes(document.activeElement?.tagName)||document.activeElement?.isContentEditable,H0=document.activeElement?.tagName==="IFRAME";if(jJ&&S.key==="Escape"){S.preventDefault(),F4();return}if(i&&(S.key==="k"||S.key==="K")){S.preventDefault(),z6((F0)=>!F0);return}if(i&&!S.altKey&&(S.key==="z"||S.key==="Z"||S.key==="y"||S.key==="Y")){if(!X0&&!H0&&V&&V!==r9){if((S.key==="z"||S.key==="Z")&&Q6.current.open&&Q6.current.comps?.length)return;let F0=S.key==="y"||S.key==="Y"||S.shiftKey;if(hQ==="photo"&&G9(F0)){S.preventDefault();return}S.preventDefault(),T0({dgn:F0?"redo":"undo"});return}}if(i&&S.shiftKey&&(S.key==="r"||S.key==="R")){S.preventDefault(),oG();return}if(i&&(S.key==="r"||S.key==="R")){S.preventDefault(),dQ();return}if(i&&S.shiftKey&&(S.key==="m"||S.key==="M")){S.preventDefault(),h6("comments");return}if(i&&S.shiftKey&&(S.key==="g"||S.key==="G")){S.preventDefault(),h6("changes");return}if(i&&S.shiftKey&&(S.key==="i"||S.key==="I")){S.preventDefault(),h6("inspector");return}if(i&&S.shiftKey&&(S.key==="a"||S.key==="A")&&G8()){if(S.preventDefault(),!O0)h6("assistant");return}if(i&&S.shiftKey&&(S.key==="e"||S.key==="E")){S.preventDefault(),P6({mode:"export"});return}if(i&&S.shiftKey&&(S.key==="h"||S.key==="H")){S.preventDefault(),P6({mode:"handoff"});return}if(i&&!S.shiftKey&&!S.altKey&&S.key===","){if(S.preventDefault(),!O0)O5(!0);return}if(i&&S.shiftKey&&(S.key==="t"||S.key==="T")){S.preventDefault(),AY();return}if(i&&!S.shiftKey&&!S.altKey&&(S.key==="c"||S.key==="C")){if(A&&A.selector&&V&&V!==r9&&!X0&&console&&console.warn)console.warn("Cmd+C comment-drop deprecated — press C inside the canvas to enter Comment tool, then click the element.")}if(X0)return;if(S.key==="/"){S.preventDefault();let F0=document.querySelector(".st-search input");if(F0)F0.focus();return}if(i&&(S.key==="f"||S.key==="F")){if(S.preventDefault(),!k8)k6("tree");setTimeout(()=>{let F0=document.querySelector(".st-search input");if(F0)F0.focus()},0);return}if(H0){if(S.key!=="Escape")return}if(S.key==="t"||S.key==="T"){if(S.shiftKey||i)return;S.preventDefault(),wX("tree");return}if(S.key==="h"||S.key==="H"){if(S.shiftKey||i)return;S.preventDefault(),D5((F0)=>!F0);return}if((S.key==="s"||S.key==="S")&&!i&&!S.shiftKey){if(S.preventDefault(),V===r9)hY(r9);else S5();return}if((S.key==="n"||S.key==="N")&&!i&&!S.shiftKey){S.preventDefault(),k6("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60);return}if(S.key==="?"){S.preventDefault(),l8((F0)=>!F0);return}if(S.key==="F1"){S.preventDefault(),oJ(!0);return}if(S.key==="Escape"){if(x8){i8(null);return}}}return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[dQ,oG,A,V,x8,k8,S5,hY,M1,jJ,F4,AY,hQ,G9,O0]);let x80=u.useCallback((b,S)=>{if(S)i9.current.set(b,S)},[]),h80=A80(C9).open,g80=u.useCallback((b)=>{let S=b.target;if(S&&(S.tagName==="INPUT"||S.tagName==="TEXTAREA"||S.isContentEditable))return;b.preventDefault()},[]),m80=u.useMemo(()=>[{id:"new",group:"Canvas",label:"New canvas…",icon:"plus",kbd:"N",run:()=>{k6("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60)}},{id:"new-video",group:"Canvas",label:"New video…",icon:"plus",run:()=>lH()},{id:"export",group:"Canvas",label:"Export…",icon:"download",kbd:"⇧⌘E",run:()=>P6({mode:"export"})},{id:"share-link",group:"Canvas",label:"Copy share link",icon:"link",run:()=>{let b=gH(xY),S=b.web??b.app??b.local;if(S)TV(S)}},{id:"handoff",group:"Canvas",label:"Handoff to production",icon:"external",kbd:"⇧⌘H",run:()=>P6({mode:"handoff"})},{id:"generate",group:"Canvas",label:"Generate with AI…",icon:"sparkle",run:()=>SJ(!0)},{id:"settings",group:"Canvas",label:"Settings…",icon:"sliders",kbd:"⌘,",run:()=>O5(!0)},{id:"system",group:"View",label:"Open design system view",icon:"sliders",kbd:"S",run:()=>S5()},{id:"comments",group:"View",label:"Toggle comments panel",icon:"resolve",kbd:"⌘⇧M",run:()=>h6("comments")},{id:"inspector",group:"View",label:"Open inspector",icon:"sliders",kbd:"⌘⇧I",run:()=>eX("inspector")},{id:"reload",group:"View",label:"Reload active canvas",icon:"reload",kbd:"⌘R",run:()=>dQ()},{id:"draw",group:"Tools",label:"Draw a mark with the SVG agent",icon:"pen",run:()=>{try{navigator.clipboard?.writeText("/design:draw ")}catch{}}},{id:"theme",group:"Tools",label:"Toggle light / dark theme",icon:"sun",run:()=>M4()},{id:"whatsnew",group:"Help",label:"What's new in maude",icon:"sparkle",run:()=>E5.openPanel()},{id:"shortcuts",group:"Help",label:"Keyboard shortcuts",icon:"help",kbd:"?",run:()=>l8(!0)},{id:"help",group:"Help",label:"Help · commands & flows",icon:"help",kbd:"F1",run:()=>oJ(!0)},{id:"report-bug",group:"Help",label:"Report a bug…",icon:"help",run:()=>W4(!0)}],[S5,M4,dQ,E5,lH,xY,dG,t0,a9,e0.designRel]),u80=(b)=>{if(O0&&b==="assistant")return!1;if(b==="sync")return!!k0;return b==="assistant"?G8():b==="layers"?n==="separate":!0},Lk=(b)=>Wk.filter((S)=>u80(S.id)&&(NJ[S.id]||sK[S.id])===b).map((S)=>S.id),Dk={tree:k8,layers:fQ,inspector:bJ,comments:h8,changes:W9,sync:x9,assistant:_X},Mk=e0.cloud?{changes:"History"}:null,Ok=Lk("left"),Ak=Lk("right"),_4=Ok.find((b)=>Dk[b])||null,gY=Ak.find((b)=>Dk[b])||null,_k=G8()&&!O0&&(NJ.assistant||"right")==="left",wk=G8()&&!O0&&(NJ.assistant||"right")==="right",tG=(b)=>(NJ[b]||sK[b])==="left"?N0==="sb":N0==="rp",w1=V&&V!==r9&&/\.(tsx|html)$/i.test(V)?V:null,Ek=w1?HL(C9[w1]):0,Pk=(b)=>{if(b==="tree")return z(SF0,{cloud:e0.cloud,readOnly:O0,groups:J,activePath:V,previewPath:N,activeDsName:V===r9?L9?.ds?.name??null:null,onOpen:V6,onPreview:M,onOpenLinkedFile:A4,filesReady:Q,onShare:mH,onOpenSystem:S5,wsConnected:z0,search:$9,setSearch:w8,commentsByFile:C9,showHidden:J7,sectionsExpanded:rX,onToggleSection:yG,onNewBoard:H1,onDeleteBoard:K1,onMoveCanvas:U1,onNewFolder:V1,onDeleteFolder:q1,onRenameFolder:B1,onRenameCanvas:N1,onDuplicateCanvas:F1,onDeleteFile:L1,onRefresh:oG,refreshing:Z1,collapsed:!1,onCollapse:()=>wX("tree"),resizing:tG("tree"),dirtyByPath:lG,project:Z,gitBranch:T9?.branch,remoteSync:w0,onGetLatest:vY,canvasKinds:e0?.canvasKinds,syncStatus:k0,onLinkedHub:E9,onLocalProject:F9,savingIsManaged:I9});if(b==="changes")return z(Hw,{status:T9&&w0?{...T9,...w0}:T9,project:Z,readOnly:!G8()||O0,historyOnly:F8,cloudManaged:v7,resizing:tG("changes"),onClose:()=>H9(!1),onCommit:jG,onDiscard:jY,onPublish:vG,onGetLatest:vY,loadLog:async(S)=>{let i=await pG(S);if(uG(i!=="legacy"),i!=="legacy")return i;return(v7?gG:fY)(S)},historySource:mG?"project":v7?"cloud":"local",onRestoreVersion:async(S)=>{let i=await fetch("/_api/project/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:V,revision:S})}).catch(()=>null);return!!(i?await i.json().catch(()=>null):null)?.ok},onUndoAction:F8?void 0:async(S)=>{let i=await fetch("/_api/project/undo",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionId:S})}).catch(()=>null);return!!(i?await i.json().catch(()=>null):null)?.ok},cloudHistory:xG,onOpenCanvas:(S)=>V6(S),onOpenDiff:(S)=>v0({file:S,beforeSha:"HEAD",conflict:!1}),activeCanvas:w1,onPreviewVersion:(S)=>v0({file:V,beforeSha:S,conflict:!1}),designRel:(e0?.designRel||e0?.designRoot||".design").replace(/^\/+|\/+$/g,"")});if(b==="sync")return z(Iw,{status:k0,project:e0?.cloud?.projectName||Z,cloud:e0?.cloud??null,groupPaths:(J||[]).map((S)=>S.path).filter(Boolean),resizing:tG("sync"),onClose:()=>S9(!1)});if(b==="inspector"||b==="layers")return z(wL0,{testId:b==="layers"?"layers-panel":"inspector-panel",layersOnly:b==="layers",hideLayersTab:n==="separate",cpMode:m9,onSetCpMode:e9,selected:A,cfg:e0,tab:b==="layers"?"layers":hQ,onTabChange:tX,onClose:()=>b==="layers"?Z4(!1):rJ(!1),onOptimistic:PX,onRecordEdit:eJ,onReplaceMedia:b80,onResizeArtboard:T,onSetArtboardHug:J0,onSetArtboardStyle:G0,onSetArtboardKind:Z9,onSetArtboardPrint:X8,onDuplicateArtboard:g,editScope:O,onUndoRedo:(S)=>T0({dgn:S}),photoSel:BG,photoRev:NG,onPhotoEdit:Q9,onPhotoRemoveBackground:kG,onPhotoRecordEdit:B4,onPhotoUndoRedo:(S)=>G9(S==="redo"),layersTree:r,componentMap:c,lockedKeys:L4,onToggleLock:bG,onDetachInstance:A1,canvasFile:V,onSelectLayer:(S)=>T0({dgn:"select-by-id",id:S.id,artboardId:r?.artboardId,index:S.index}),onHoverLayer:(S)=>T0({dgn:"highlight",id:S?S.id:null,artboardId:r?.artboardId,index:S?S.index:0}),onReorderLayer:rG,layersBusyRef:p,resizing:tG(b)});if(b==="comments")return z(JL0,{commentsByFile:C9,filter:M0,setFilter:_0,activePath:V,focusedId:x8,onJump:f80,onResolve:O0?void 0:y80,onReopen:O0?void 0:j80,onDelete:O0?void 0:v80,resizing:tG("comments")});return null};return D("div",{className:"maude"+(jJ?" is-present":""),"data-theme":f0,onContextMenu:g80,children:[jH&&z(Cw,{}),z(QL0,{cloud:e0.cloud}),z(YL0,{update:AG,onDismiss:()=>fH(null)}),z(WL0,{status:k0}),!jH&&z(Kw,{status:k0,cloud:e0.cloud}),z(Kg,{paused:!!I5||!!U4,hiddenGroups:K4.panelOpen?["exports"]:[]}),z(Im,{wn:E5}),z(Nm,{center:K4}),q0&&D("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:"Repo state changed — reload to sync?"}),z("button",{type:"button",className:"btn btn--primary btn--sm",onClick:()=>{try{window.location.reload()}catch{}},children:"Reload"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:()=>Z0(null),children:"Dismiss"})]}),D("div",{className:"st-shell",children:[z(lF0,{sharePath:xY,onShare:()=>mH(),readOnly:O0,cloud:e0.cloud,activePath:V,project:Z,tabsCount:K.length,openMenu:y9,setOpenMenu:W8,commentsPanelOpen:h8,onToggleComments:()=>h6("comments"),changesOpen:W9,changesCount:Q8,onToggleChanges:()=>h6("changes"),onOpenSystem:S5,sidebarOpen:k8,onToggleSidebar:()=>wX("tree"),showHidden:J7,onToggleShowHidden:()=>D5((b)=>!b),onOpenHelp:()=>oJ(!0),onOpenShortcuts:()=>l8(!0),onReportBug:()=>W4(!0),onStartTour:()=>EX(sN),onStartCollabTour:()=>EX(KE),annotationsVisible:XQ,onToggleAnnotations:CY,minimapVisible:QQ,onToggleMinimap:$Y,zoomCtlVisible:g6,onToggleZoomCtl:SY,presentMode:jJ,onTogglePresent:$G,printGuidesVisible:PG,onTogglePrintGuides:SG,postToActiveCanvas:T0,onOpenReadiness:()=>FX(!0),onOpenQuickSetup:()=>jQ(!0),onWatchIntro:()=>qY(!0),onOpenWhatsNew:E5.openPanel,whatsNewCount:E5.unseen.length,exportCenter:K4,artboardCount:l7,inspectorOpen:bJ,inspectorTab:hQ,onToggleInspector:()=>h6("inspector"),autoOpenInspector:U6,onToggleAutoOpenInspector:()=>LG((b)=>!b),onInsertArtboard:_7,timelineOpen:L0,onToggleTimeline:AY,hasComps:E0.length>0,assistantOpen:_X,onToggleAssistant:()=>h6("assistant"),assistantBusy:Q1,assistantUnseen:Y1,onOpenLayers:()=>{if(n==="separate")wX("layers");else if(bJ&&hQ==="layers")rJ(!1);else tX("layers"),k6("inspector")},onNewCanvas:()=>{k6("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60)},onAssembleVideo:z1,onOpenExport:(b)=>P6({mode:b}),onOpenSettings:()=>O5(!0),onOpenGenerate:()=>SJ(!0),onReload:dQ,onCloseCanvas:()=>V&&hY(V),presence:D(Q0,{children:[z(a90,{initials:MF0(gQ||"you"),hue:"var(--accent)",title:gQ?`${gQ} (you)`:"You"}),TG&&z(a90,{initials:"C",hue:"var(--presence-agent)",title:"Claude · editing",pulse:!0})]})}),D("div",{className:"st-body"+(N0?" is-resizing":""),ref:h9,children:[z(bF0,{shown:!_4,onExpand:()=>k6("tree"),onSearch:()=>{k6("tree"),setTimeout(()=>document.querySelector(".st-search input")?.focus(),60)}}),(_4||_k)&&D(n90,{side:"left",width:B9.w,open:!!_4,ids:Ok,activeId:_4,onPick:wX,labels:Mk,children:[_k&&z(PN,{hidden:_4!=="assistant",activeCanvas:w1,selected:A,openComments:Ek,designRel:(e0?.designRel||e0?.designRoot||".design").replace(/^\/+|\/+$/g,""),resizing:tG("assistant"),onClose:()=>UG(!1),onBusyChange:$H,onFinished:SH,onPermissionRequest:DY,onElicitationRequest:DY}),_4&&_4!=="assistant"&&Pk(_4)]}),_4&&z(t90,{label:"Resize left panel",size:B9,active:N0==="sb",onPointerDown:(b)=>{b.preventDefault(),b.currentTarget.setPointerCapture?.(b.pointerId),o0("sb")}}),z("div",{className:"main",children:z(dF0,{tabs:K,activePath:V,registerIframe:x80,systemData:L9,onOpenFromSystem:V6,onSelectDs:WQ,project:Z,cfg:e0,loadingPath:J9,onIframeLoad:g9,canvasError:X9,canvasReloadNonce:l0,onRetryCanvasLoad:G1,loadedPath:h0,showQuickSetup:G8()&&!O0&&!!V7&&!V7.ready,onStartQuickSetup:()=>jQ(!0),previewPath:N})}),gY&&z(t90,{label:"Resize right panel",dir:"rtl",size:D9,active:N0==="rp",onPointerDown:(b)=>{b.preventDefault(),b.currentTarget.setPointerCapture?.(b.pointerId),o0("rp")}}),(gY||wk)&&D(n90,{side:"right",width:D9.w,open:!!gY,ids:Ak,activeId:gY,onPick:wX,labels:Mk,children:[wk&&z(PN,{hidden:gY!=="assistant",activeCanvas:w1,selected:A,openComments:Ek,designRel:(e0?.designRel||e0?.designRoot||".design").replace(/^\/+|\/+$/g,""),resizing:tG("assistant"),onClose:()=>UG(!1),onBusyChange:$H,onFinished:SH,onPermissionRequest:DY,onElicitationRequest:DY}),gY&&gY!=="assistant"&&Pk(gY)]})]}),L0&&z(aw,{comps:E0,compId:T6,sequences:K6,audio:J6,transitions:MX,total:aX,frame:O9,playing:L8,loop:A5,onSeek:(b)=>{Z8(b),I6(!1),T0({dgn:"timeline-seek",frame:b,id:T6})},onPlay:()=>{I6(!0),T0({dgn:"timeline-mute",muted:FJ,id:T6}),T0({dgn:"timeline-loop",loop:A5,id:T6}),T0({dgn:"timeline-play",id:T6})},onPause:()=>{I6(!1),T0({dgn:"timeline-pause",id:T6})},onToggleLoop:()=>s6((b)=>{let S=!b;return T0({dgn:"timeline-loop",loop:S,id:T6}),S}),muted:FJ,onToggleMute:()=>{xQ((b)=>{let S=!b;return T0({dgn:"timeline-mute",muted:S,id:T6}),S})},volume:TH,onVolume:(b)=>{if(KG(b),b>0&&FJ)xQ(!1),T0({dgn:"timeline-mute",muted:!1,id:T6});T0({dgn:"timeline-volume",volume:b,id:T6})},onRetime:(b,S)=>{if(!V||V===r9)return;let i=X6||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${i?`&artboardId=${encodeURIComponent(i)}`:""}`;fetch(X0).then((H0)=>H0.json().catch(()=>({}))).then((H0)=>{let F0=R6(H0,b),A0=b&&typeof b==="object"?b.index:b,l=F0?.stableId?{canvas:V,artboardId:i,stableId:F0.stableId,contentHash:F0.contentHash,...S}:{canvas:V,index:A0,...S};return fetch("/_api/retime-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(l)})}).then((H0)=>H0.json()).then((H0)=>{if(!H0?.ok)console.warn("[retime]",H0?.error||"failed"),LJ("Retime refused",H0?.error);else if(f9(S.from!=null?"Clip moved.":"Clip trimmed.",!0),H0?.seq!=null)Y6(V,H0.seq,S.from!=null?"move clip":"trim clip")}).catch(()=>{})},onRemove:R5,onReplace:(b)=>{if(!V||V===r9)return;nG({accept:"video/*,image/*",resolveTarget:(S)=>{let i=R6(S,b);if(i?.mediaArrayRef)return{arrayRef:i.mediaArrayRef};if(i?.mediaCdId)return{cdId:i.mediaCdId};return null}})},onReplaceAudio:(b)=>{if(!V||V===r9)return;nG({accept:"audio/*",resolveTarget:(S)=>{let i=S?.ok&&Array.isArray(S.media)?S.media.filter((X0)=>X0.tag==="Audio"):[];return i[b]?.cdId?{cdId:i[b].cdId}:null}})},onReplaceLayer:(b,S)=>{if(!V||V===r9)return;let i=b&&typeof b==="object"?b.index:b,X0=K6[i]?.layers?.[S]?.kind==="audio"?"audio/*":K6[i]?.layers?.[S]?.kind==="image"?"image/*":"video/*";nG({accept:X0,resolveTarget:(H0)=>{let F0=R6(H0,b)?.layers?.[S];if(F0?.mediaArrayRef)return{arrayRef:F0.mediaArrayRef};if(F0?.mediaCdId)return{cdId:F0.mediaCdId};return null}})},onReorder:(b,S)=>{if(!V||V===r9)return;let i=X6||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${i?`&artboardId=${encodeURIComponent(i)}`:""}`;fetch(X0).then((H0)=>H0.json().catch(()=>({}))).then((H0)=>{let F0=H0?.ok&&Array.isArray(H0.clips)?H0.clips.filter((_9)=>_9.kind==="sequence"):[],A0=R6(H0,b),l=A0?F0.indexOf(A0):-1,D0=S==="forward"?l+1:l-1,P0=l>=0?F0[D0]||null:null,i0=S==="forward"?"after":"before";if(!A0?.stableId||!P0?.stableId)return null;return fetch("/_api/reorder-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:i,stableId:A0.stableId,contentHash:A0.contentHash,refStableId:P0.stableId,refContentHash:P0.contentHash,position:i0})})}).then((H0)=>H0?H0.json():null).then((H0)=>{if(H0&&!H0.ok)console.warn("[reorder-clip]",H0.error||"failed"),LJ("Reorder refused",H0.error);else if(H0?.seq!=null)Y6(V,H0.seq,"reorder clip")}).catch(()=>{})},onToggleHide:(b)=>{if(!V||V===r9)return;let S=X6||void 0,i=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${S?`&artboardId=${encodeURIComponent(S)}`:""}`;fetch(i).then((X0)=>X0.json().catch(()=>({}))).then((X0)=>{let H0=R6(X0,b);if(!H0?.stableId)return null;return fetch("/_api/toggle-hide",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:S,stableId:H0.stableId,contentHash:H0.contentHash})})}).then((X0)=>X0?X0.json():null).then((X0)=>{if(X0&&!X0.ok)LJ("Hide refused",X0.error);else if(X0&&X0.ok){if(f9(X0.hidden?"Clip hidden.":"Clip shown.",!0),X0.seq!=null)Y6(V,X0.seq,X0.hidden?"hide clip":"show clip")}}).catch(()=>f9("Hide failed: network error"))},onReorderMove:(b,S,i)=>{if(!V||V===r9)return;let X0=X6||void 0,H0=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${X0?`&artboardId=${encodeURIComponent(X0)}`:""}`;fetch(H0).then((F0)=>F0.json().catch(()=>({}))).then((F0)=>{let A0=R6(F0,b),l=R6(F0,S);if(!A0?.stableId||!l?.stableId)return null;return fetch("/_api/reorder-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:X0,stableId:A0.stableId,contentHash:A0.contentHash,refStableId:l.stableId,refContentHash:l.contentHash,position:i,mode:"move"})})}).then((F0)=>F0?F0.json():null).then((F0)=>{if(F0&&!F0.ok)console.warn("[reorder-move]",F0.error||"failed"),LJ("Reorder refused",F0.error);else if(F0?.ok){if(f9("Clip moved.",!0),F0.seq!=null)Y6(V,F0.seq,"move clip")}}).catch(()=>f9("Reorder failed: network error"))},onDropMedia:(b,S)=>{if(!V||V===r9)return;let i=X6||void 0,X0=NY,H0=V,F0=(Array.isArray(b)?b:[b]).filter(Boolean);(async()=>{if(!E0.length){let l=[];for(let P0 of F0){let i0=P0.type.startsWith("audio/")?"audio":P0.type.startsWith("video/")?"video":null;if(!i0)continue;try{let _9=await fetch("/_api/asset",{method:"POST",headers:{"Content-Type":P0.type||"application/octet-stream"},body:P0}),A9=await _9.json().catch(()=>({}));if(A9?.path)l.push({src:A9.path,mediaKind:i0});else f9(`Upload failed: ${A9?.error||`HTTP ${_9.status}`}`)}catch{f9("Upload failed: network error")}}if(!l.length){f9("No video/audio files in the drop — nothing to cut.");return}let D0=!1;for(let P0 of l){let i0=await lw(P0.src).catch(()=>null),_9={canvas:H0,lane:P0.mediaKind==="audio"&&D0?"audio":"storyline",durationInFrames:G3(X0,i0),mediaTag:P0.mediaKind==="audio"?"Audio":"Video",src:P0.src};if(_9.lane==="audio")_9.from=0;let A9=await fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(_9)}).catch(()=>null),q6=A9?await A9.json().catch(()=>null):null;if(q6?.ok){if(D0=!0,q6.seq!=null)Y6(H0,q6.seq,"add clip")}else if(!D0)break;else LJ("Insert refused",q6?.error)}if(D0){f9("Artboard upgraded to a video comp — clips added to the storyline.",!0);return}for(let P0=0;P0<8;P0+=1){let i0=P0===0?"New Cut":`New Cut ${P0+1}`,_9=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:i0,kind:"video-comp",clips:l})}).catch(()=>null),A9=_9?await _9.json().catch(()=>({})):{};if(_9?.status===409)continue;if(!_9?.ok||!A9.ok){f9(`New cut failed: ${A9.error||"create refused"}`);return}await y8(),V6(A9.file),f9(`Started a new cut from ${l.length} clip${l.length>1?"s":""}.`,!0);return}f9('New cut failed: too many "New Cut" canvases — rename some.');return}let A0=S?.lane==="storyline"?S.index:void 0;for(let l of F0){let D0=l.type.startsWith("video/")?"Video":l.type.startsWith("audio/")?"Audio":l.type.startsWith("image/")?"Img":null;if(!D0)continue;let P0;try{P0=await(await fetch("/_api/asset",{method:"POST",headers:{"Content-Type":l.type||"application/octet-stream"},body:l})).json().catch(()=>({}))}catch{P0=null}if(!P0?.path){f9(`Upload failed: ${P0?.error||"server unreachable — retry in a moment"}`);continue}let i0=D0==="Audio",_9=D0==="Video"?await lw(P0.path).catch(()=>null):null,A9={canvas:H0,artboardId:i,mediaTag:D0,src:P0.path};if(S&&(i0||S.lane==="audio"))A9.lane="audio",A9.from=Math.max(0,S.frame??0),A9.durationInFrames=Math.max(X0,aX-A9.from);else if(S?.lane==="storyline"&&!i0){if(A9.lane="storyline",A0!=null)A9.index=A0,A0+=1;A9.durationInFrames=G3(X0,_9)}else if(S?.lane==="overlay"&&!i0){if((K6||[]).length===0)A9.lane="storyline";else A9.lane="overlay",A9.from=Math.max(0,S.frame??0);A9.durationInFrames=G3(X0,_9)}else if(!i0)A9.lane="storyline",A9.durationInFrames=G3(X0,_9);else A9.lane="audio",A9.from=0,A9.durationInFrames=Math.max(X0,aX);try{let w7=await(await fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(A9)})).json().catch(()=>null);if(w7&&!w7.ok)console.warn("[insert-clip]",w7.error||"failed"),LJ("Insert refused",w7.error);else if(w7?.ok){if(f9("Clip added to the timeline.",!0),w7.seq!=null)Y6(H0,w7.seq,"add clip")}}catch{f9("Insert failed: network error")}}})()},height:yJ,onResize:C7,onClose:()=>j0(!1),selectedClipId:CH,onSelect:FY,transitionClips:CG,onClipVerb:C5,comments:(C9[V]||[]).filter((b)=>b&&b.timeline),promptText:YQ,onAddComment:IY,onResolveComment:(b)=>$7({type:"comments-patch",id:b,patch:{status:"resolved"}}),onDeleteComment:(b)=>$7({type:"comments-delete",id:b}),onSplitAtPlayhead:()=>{let b=Q6.current,S=b.selected!=null?{stableId:b.selected}:null;if(!S){let i=b.sequences||[],X0=i.find((H0)=>H0.series&&b.frame>=H0.from&&b.frame<H0.from+H0.duration)||i.find((H0)=>b.frame>=H0.from&&b.frame<H0.from+H0.duration);if(X0?.stableId)S={stableId:X0.stableId}}if(S)C5(S,"split",{atFrame:b.frame});else f9("Nothing under the playhead to split.")},onAddTitle:(b)=>{if(!V||V===r9)return;Promise.resolve("Title").then((S)=>{if(!S)return;fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:X6||void 0,lane:"overlay",from:b,durationInFrames:Math.round(NY*3),mediaTag:"Title",src:S})}).then((X0)=>X0.json().catch(()=>null)).then((X0)=>{if(X0&&!X0.ok)LJ("Title refused",X0.error);else if(X0?.ok){if(f9("Title added.",!0),X0.seq!=null)Y6(V,X0.seq,"add title")}}).catch(()=>f9("Title failed: network error"))})},onAddAiClip:()=>{if(!V||V===r9)return;(async()=>{fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:X6||void 0,lane:"storyline",durationInFrames:Math.round(NY*5),placeholder:{prompt:"Describe this shot — double-click to edit",kind:"veo"}})}).then((X0)=>X0.json().catch(()=>null)).then((X0)=>{if(X0&&!X0.ok)LJ("AI clip refused",X0.error);else if(X0?.ok){if(f9("AI placeholder added — double-click its text to write the prompt, then right-click → Generate ✨.",!0),X0.seq!=null)Y6(V,X0.seq,"add AI placeholder")}}).catch(()=>f9("AI clip failed: network error"))})()},onGeneratePlaceholder:(b)=>{if(!V||V===r9)return;let S=V,i=X6||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(S)}${i?`&artboardId=${encodeURIComponent(i)}`:""}`;fetch(X0).then((H0)=>H0.json().catch(()=>({}))).then((H0)=>{let F0=R6(H0,b),A0=F0?.placeholder;if(!F0?.stableId||!A0?.prompt){f9("No AI placeholder prompt on this clip.");return}let l=A0.kind==="image"?"image":"video",D0=A0.kind==="motion"?`Clean, minimal motion-graphics animation (flat shapes, smooth easing): ${A0.prompt}`:A0.prompt;fetch("/_api/generate-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({provider:"gemini",modality:l,prompt:D0})}).then(async(P0)=>P0.ok?P0.json():Promise.reject(Error(await P0.text()))).then((P0)=>{let i0=P0?.id;if(!i0)throw Error("no job id");f9(`Generating ${A0.kind}… (runs in the background)`,!0);let _9=F0.stableId,A9=()=>{fetch("/_api/generate-jobs").then((q6)=>q6.json().catch(()=>({}))).then((q6)=>{let w7=(q6?.jobs||[]).find((_J)=>_J.id===i0);if(!w7||w7.status==="failed"){f9(`Generation failed: ${w7?.error||"job lost"}`);return}if(w7.status!=="done"){setTimeout(A9,4000);return}let d8=w7.assets?.[0];if(!d8){f9("Generation finished but produced no asset.");return}fetch(X0).then((_J)=>_J.json().catch(()=>({}))).then((_J)=>{let eG=R6(_J,{stableId:_9});if(!eG?.stableId){f9("Placeholder clip is gone — generated asset kept in assets/.");return}C5({stableId:eG.stableId},"resolve-placeholder",{src:d8,mediaKind:l==="image"?"image":"video"})})}).catch(()=>setTimeout(A9,6000))};setTimeout(A9,3000)}).catch((P0)=>f9(`Generate failed: ${P0?.message||"provider error"} — is a Gemini key set in Settings?`))}).catch(()=>f9("Generate failed: network error"))},onAddImage:(b)=>{if(!V||V===r9)return;let S=(X0,H0)=>{let F0=NY;fetch("/_api/asset",{method:"POST",headers:{"Content-Type":H0||"application/octet-stream"},body:X0}).then((A0)=>A0.json().catch(()=>({}))).then((A0)=>{if(!A0?.path)return f9(`Upload failed: ${A0?.error||"unknown error"}`),null;return fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:X6||void 0,lane:"overlay",from:b,durationInFrames:Math.round(F0*3),mediaTag:"Img",src:A0.path})})}).then((A0)=>A0?A0.json():null).then((A0)=>{if(A0&&!A0.ok)LJ("Image refused",A0.error);else if(A0?.ok){if(f9("Image overlay added.",!0),A0.seq!=null)Y6(V,A0.seq,"add image overlay")}}).catch(()=>f9("Image failed: network error"))};if(G8()){lZ().then((X0)=>{if(X0?.bytes)S(new Blob([new Uint8Array(X0.bytes)]),"")}).catch((X0)=>f9(`Image pick failed: ${X0?.message||"dialog error"}`));return}let i=document.createElement("input");i.type="file",i.accept="image/*",i.addEventListener("change",()=>{let X0=i.files?.[0];if(X0)S(X0,X0.type)}),i.click()},resolveMediaUrl:(b)=>`/${(e0?.designRel||e0?.designRoot||".design").replace(/^\/+|\/+$/g,"")}/${b}`}),z(eF0,{activePath:V,selected:A,wsConnected:z0,openCount:h80,theme:f0,onToggleTheme:M4,onClearSelected:D1,syncStatus:k0,syncProject:e0?.cloud?.projectName||Z,syncOpen:x9,onOpenSync:k0?()=>h6("sync"):void 0,changesCount:Q8,unpushed:I9?0:T9?.unpushed||0,savingIsManaged:I9,changesOpen:W9,onOpenChanges:T9?.repo||I9?()=>H9(!0):void 0,version:e0?.version})]}),jJ&&D("button",{type:"button",className:"st-present-exit",onClick:F4,"aria-label":"Exit presentation mode",title:"Exit presentation mode (Esc)",children:[z("svg",{viewBox:"0 0 16 16",width:"13",height:"13",fill:"none","aria-hidden":"true",children:z("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})}),z("span",{children:"Exit presentation"}),z("kbd",{className:"st-present-exit-kbd",children:"Esc"})]}),z(DF0,{open:q7,onClose:()=>z6(!1),actions:m80}),$5&&z("div",{className:"st-scrim",role:"presentation",onMouseDown:(b)=>{if(b.target===b.currentTarget)pQ(null)},children:D("div",{className:"st-dialog st-prompt",role:"dialog","aria-modal":"true","aria-label":$5.title,children:[z("div",{className:"st-dialog-hd",children:z("span",{className:"st-dialog-title",children:$5.title})}),D("div",{className:"st-dialog-bd",children:[z("input",{className:"st-input","data-testid":"shell-prompt-input",autoFocus:!0,defaultValue:$5.value,onKeyDown:(b)=>{if(b.stopPropagation(),b.key==="Enter")pQ(b.currentTarget.value);else if(b.key==="Escape")pQ(null)}}),D("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:10},children:[z("button",{type:"button",className:"tlci-btn",onClick:()=>pQ(null),children:"Cancel"}),z("button",{type:"button",className:"tlci-btn","data-testid":"shell-prompt-ok",onClick:(b)=>pQ(b.currentTarget.closest(".st-dialog")?.querySelector("input")?.value??""),children:"OK"})]})]})]})}),$J&&z(Ug,{target:$J,links:gH($J.path),shell:dG,onClose:()=>vQ(null),Icon:T8}),M5&&z(TF0,{mode:M5.mode,initialScope:M5.scope,activePath:V,hasComps:E0.length>0,comps:E0,activeArtboardId:A?.artboardId??R8??null,selection:A?.selector?{selector:A.selector,file:A.file}:null,exportLane:e0.exportLane||"local",onBrowserCapture:k5,onClose:()=>P6(null)}),G4&&z(WE,{cloud:e0.cloud,onClose:()=>O5(!1),initialTab:typeof G4==="string"?G4:void 0,theme:f0,onSetTheme:Y9,cpMode:m9,onSetCpMode:e9,minimapVisible:QQ,onToggleMinimap:$Y,zoomCtlVisible:g6,onToggleZoomCtl:SY,annotationsVisible:XQ,onToggleAnnotations:CY,autoOpenInspector:U6,onToggleAutoOpenInspector:()=>LG((b)=>!b),hasCanvas:!!V&&V!==r9,panelSide:NJ,onSetPanelSide:(b,S)=>H4((i)=>({...i,[b]:S})),layersMode:n,onSetLayersMode:(b)=>{if(W0(b),b!=="separate")Z4(!1)}}),zG&&z(tw,{onClose:()=>SJ(!1),onInsert:O1}),sG&&z(IF0,{designRel:(e0?.designRel||e0?.designRoot||".design").replace(/^\/+|\/+$/g,""),onPick:C80,onClose:()=>_1(null),multiple:!!sG.multiple,hasArtboardAnchor:!!sG.hasArtboardAnchor,onPickMany:$80}),LL&&z(GE,{onPick:S80,onClose:()=>DL(null)}),O8&&z(Zw,{target:O8,cfg:e0,loadLog:fY,onClose:()=>v0(null),onRestore:async(b)=>{let S=await jY([b]);if(S?.ok)v0(null);else window.alert(S?.error||"Could not restore that version. Try again.")},onResolve:async(b)=>{let S=await fG(b);if(S.ok)v0(null);else window.alert(S.error||"Could not finish the merge. Get the latest again, then retry.")}}),z(vF0,{open:nJ,onClose:()=>l8(!1)}),z(yF0,{open:iJ,onClose:()=>oJ(!1),onStartTour:()=>{oJ(!1),EX(sN)}}),z(Om,{open:e7,activeCanvas:V,onClose:()=>W4(!1)}),z(Tm,{wn:E5,onStartTour:EX}),z(Fm,{center:K4}),z(Mh,{open:R7,onClose:()=>FX(!1)}),z(RV,{open:j8,onClose:()=>qY(!1)}),z(yw,{open:p7,onClose:()=>jQ(!1),onStartTour:()=>EX(Gm),onBringBrand:()=>f7(!0),onImportFigma:()=>LX(!0)}),z($w,{open:HG,onClose:()=>f7(!1)}),BY&&z(Sw,{onClose:()=>LX(!1),onImported:()=>y8()}),I5&&!U4&&!vH&&D("div",{className:"mdcc-tour-nudge",role:"status","aria-live":"polite",children:[z("div",{className:"mdcc-tour-nudge__body",children:"New here? Take a 60-second tour of the canvas browser."}),z("button",{type:"button",className:"mdcc-tour-nudge__cta",onClick:()=>{V4(),EX(sN)},children:"Start"}),z("button",{type:"button",className:"mdcc-tour-nudge__skip","aria-label":"Dismiss",onClick:V4,children:"×"})]}),vH&&!U4&&D("div",{className:"mdcc-tour-nudge",role:"status","aria-live":"polite",children:[z("div",{className:"mdcc-tour-nudge__body",children:"New to working with a team? See how saving & sharing works — 60 seconds."}),z("button",{type:"button",className:"mdcc-tour-nudge__cta",onClick:()=>{DJ(),EX(KE)},children:"Start"}),z("button",{type:"button",className:"mdcc-tour-nudge__skip","aria-label":"Dismiss",onClick:DJ,children:"×"})]}),z(Wm,{steps:U4??[],open:!!U4,onClose:()=>P5(null),onComplete:V4,bus:wG,hasSelection:!!A,hasCanvas:K.length>0})]})}D80.createRoot(document.getElementById("root")).render(z(EL0,{}));