@1agh/maude 0.60.4 → 0.60.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/studio/api.ts +54 -5
- package/apps/studio/build.ts +10 -0
- package/apps/studio/canvas-lib.tsx +16 -3
- package/apps/studio/canvas-shell.tsx +34 -39
- package/apps/studio/dist/client.bundle.js +1 -1
- package/apps/studio/dist/comment-mount.js +2 -2
- package/apps/studio/dom-selection.ts +67 -0
- package/apps/studio/input-router.tsx +26 -2
- package/apps/studio/sync/agent.ts +64 -13
- package/apps/studio/sync/codec.ts +47 -0
- package/apps/studio/sync/cold-start.ts +96 -0
- package/apps/studio/sync/migrate-seed.ts +52 -7
- package/apps/studio/sync/projection.ts +10 -1
- package/apps/studio/test/canvas-meta-api.test.ts +114 -3
- package/apps/studio/test/canvas-zoom-floor.test.ts +73 -0
- package/apps/studio/test/dom-selection.test.ts +69 -1
- package/apps/studio/test/input-router.test.ts +69 -0
- package/apps/studio/test/sync-annotations-cold-start.test.ts +302 -0
- package/apps/studio/whats-new.json +18 -0
- package/package.json +8 -8
|
@@ -5650,7 +5650,7 @@ ${B.block}`:q,F=[],D=new Map;for await(let _ of X.prompt(N,J(),K,Q?.(),Y?.(),Z?.
|
|
|
5650
5650
|
|
|
5651
5651
|
> Maude ${p.app.maudeVersion} · ${p.app.platform} ${p.app.arch} · ${p.app.surface}
|
|
5652
5652
|
> Local report bundle: \`${n?.dir??".design/_reports/"}\` (attach its files here)`),X0=`${Uz0}?title=${c}&body=${U0}&labels=report`;if(X9())try{await uU(X0)}catch{window.open(X0,"_blank","noopener")}else window.open(X0,"_blank","noopener");I({fallbackDir:n?.dir??null}),W("done")}catch{$("Saving the local bundle failed too — please file the issue by hand.")}}let m=G.trim().length>0;return z("div",{className:"st-scrim",onClick:h,"data-testid":"report-bug-dialog",children:M("div",{className:"st-dialog rb-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"rb-title",onClick:(p)=>p.stopPropagation(),children:[M("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:h,"aria-label":"Close",children:"×"})]}),M("div",{className:"st-dialog-bd rb-body",children:[Y==="describe"&&M(G0,{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."}),M("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:h,children:"Cancel"}),z("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-preview",disabled:!m,onClick:()=>W("preview"),children:"Review & attach"})]})]}),Y==="preview"&&M(G0,{children:[M("div",{className:"rb-section",children:[M("div",{className:"rb-section-hd",children:[M("span",{children:["Screenshots (",U.length,")"]}),M("span",{className:"rb-hd-actions",children:[U.length<rA&&z("button",{type:"button",className:"rb-link","data-testid":"report-bug-attach",onClick:v,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…"})]})]}),M("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 (",Vz0(H?.app?.platform),") and attach or paste (⌘V) it here."]}),_&&z("p",{className:"rb-hint","data-testid":"report-bug-shell-pending",children:"Capturing the Maude window…"}),U.length===0&&!_?M("p",{className:"rb-hint",children:["No screenshot attached yet — up to ",rA,"."]}):M(G0,{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,f)=>z(Nz0,{shot:p,redacting:w,onRects:(s)=>q((n)=>n.map((c,U0)=>U0===f?{...c,rects:s}:c)),onRemove:()=>{URL.revokeObjectURL(p.url),q((s)=>s.filter((n,c)=>c!==f))}},p.url))})]})]}),M("div",{className:"rb-section",children:[z("div",{className:"rb-section-hd",children:z("span",{children:"Included with the report"})}),M("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:!0,disabled:!0}),M("span",{children:["Maude ",H?.app?.maudeVersion??"…"," · ",H?.app?.platform??"…"," ",H?.app?.arch??""," · ",X9()?"desktop app":"browser"]})]}),Q&&M("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.activeCanvas,onChange:(p)=>D({...F,activeCanvas:p.target.checked})}),M("span",{children:["Active canvas path — ",z("code",{children:Q})]})]}),H?.context?.projectName&&M("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.projectName,onChange:(p)=>D({...F,projectName:p.target.checked})}),M("span",{children:["Project name — ",z("code",{children:H.context.projectName})]})]}),H?.logs?.serverLogTail?M("label",{className:"rb-check",children:[z("input",{type:"checkbox","data-testid":"report-bug-consent-logs",checked:F.logTail,onChange:(p)=>D({...F,logTail:p.target.checked})}),M("span",{children:["Recent server log (",H.logs.serverLogTail.split(`
|
|
5653
|
-
`).length," lines, paths & secrets scrubbed) —"," ",M("details",{className:"rb-details",children:[z("summary",{children:"view"}),z("pre",{className:"rb-log",children:H.logs.serverLogTail})]})]})]}):null,X9()&&B.length>0&&M("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.crashLogs,onChange:(p)=>D({...F,crashLogs:p.target.checked})}),M("span",{children:["Crash logs (",B.length,") — ",z("code",{children:B.map((p)=>p.name).join(", ")})]})]})]}),M("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."]}),M("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:o,children:"Send report"})]})]}),Y==="sending"&&z("p",{className:"rb-hint",children:"Sending your report…"}),Y==="done"&&M(G0,{children:[P?.issueUrl?M("p",{children:["Thank you — your report is filed as"," ",M("button",{type:"button",className:"rb-link","data-testid":"report-bug-issue-link",onClick:()=>{if(X9())uU(P.issueUrl).catch(()=>navigator.clipboard?.writeText(P.issueUrl));else window.open(P.issueUrl,"_blank","noopener")},children:["report #",P.issueNumber]})," ","on the public Maude issue tracker. Screenshots and logs stay in a private repository only maintainers can open — the issue links to them."]}):M("p",{children:["The bundle is saved locally",P?.fallbackDir?M(G0,{children:[" ","at ",z("code",{children:P.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:h,children:"Done"})})]}),Y==="fallback"&&M(G0,{children:[z("p",{className:"rb-error","data-testid":"report-bug-error",children:k}),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."}),M("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:x,children:"Save locally & open GitHub"})]})]})]})]})})}var ZJ=v8(p8(),1);function qx(X){if(typeof X!=="string")return null;let J=X.match(/^(\d+)\.(\d+)\.(\d+)/);return J?[Number(J[1]),Number(J[2]),Number(J[3])]:null}function Bx(X,J){let Q=qx(X),Y=qx(J);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 Nx(X,J){if(!Array.isArray(X))return[];return X.filter((Q)=>Q&&(Q.version==null||Bx(Q.version,J)))}function Fx(X,J){let Q=J;if(Array.isArray(X)){for(let Y of X)if(Y&&Y.version&&Bx(Y.version,Q))Q=Y.version}return Q}var aA="mdcc-whatsnew-seen",sA="mdcc-whatsnew-toast-dismissed";function Fz0(X){return typeof X==="string"&&/^https?:\/\//i.test(X)}function Lz0(X){try{let J=localStorage.getItem(aA);if(J)return J;localStorage.setItem(aA,X)}catch{}return X}function Dz0(){try{return localStorage.getItem(sA)}catch{return null}}function Lx(X){let[J,Q]=ZJ.useState([]),[Y,W]=ZJ.useState(X),[G,Z]=ZJ.useState(()=>Lz0(X)),[H,K]=ZJ.useState(()=>Dz0()),[U,q]=ZJ.useState(!1);ZJ.useEffect(()=>{let O=!1,P=()=>{fetch("/_api/whats-new").then(($)=>$.json()).then(($)=>{if(O)return;if(Q(Array.isArray($?.entries)?$.entries:[]),typeof $?.version==="string")W($.version)}).catch(()=>{})};P();let I=()=>P(),k=()=>{if(document.visibilityState==="visible")P()};return window.addEventListener("focus",I),document.addEventListener("visibilitychange",k),()=>{O=!0,window.removeEventListener("focus",I),document.removeEventListener("visibilitychange",k)}},[]);let B=Nx(J,G),N=B.length>0&&H!==Y&&!U,F=B[0]??null,D=ZJ.useCallback(()=>{let O=Fx(J,Y);Z(O),K(Y);try{localStorage.setItem(aA,O),localStorage.setItem(sA,Y)}catch{}},[J,Y]),_=ZJ.useCallback(()=>{K(Y);try{localStorage.setItem(sA,Y)}catch{}},[Y]),R=ZJ.useCallback(()=>q(!0),[]),w=ZJ.useCallback(()=>{q(!1),D()},[D]);return{entries:J,unseen:B,feedVersion:Y,panelOpen:U,openPanel:R,closePanel:w,showToast:N,toastEntry:F,dismissToast:_,markAllSeen:D}}function Dx({wn:X}){if(!X.showToast||!X.toastEntry)return null;let J=X.toastEntry,Q=X.unseen.length;return M("div",{className:"st-toast",role:"status","aria-live":"polite",children:[z("button",{type:"button",className:"st-toast-close","aria-label":"Dismiss",onClick:X.dismissToast,children:"×"}),M("div",{className:"st-toast-hd",children:[z("span",{"aria-hidden":"true",children:"✦"}),"What's new",J.version?` · v${J.version}`:""]}),z("div",{className:"st-toast-title",children:J.title}),z("div",{className:"st-toast-txt",children:J.summary}),M("div",{className:"st-toast-actions",children:[z("button",{type:"button",className:"btn btn--primary btn--sm",onClick:X.openPanel,children:Q>1?`See all (${Q})`:"Details"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X.dismissToast,children:"Dismiss"})]})]})}function Ox({wn:X,onStartTour:J}){let{panelOpen:Q,closePanel:Y}=X;if(ZJ.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(X.unseen.map((G)=>G.id));return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)Y()},children:M("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[M("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:X.entries.length===0?z("p",{className:"mdcc-wn-empty",children:"Nothing new yet."}):z("ul",{className:"mdcc-wn-list",children:X.entries.map((G)=>M("li",{className:"mdcc-wn-item"+(W.has(G.id)?" is-unseen":""),children:[M("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}),Fz0(G.learnMore)&&z("a",{className:"mdcc-wn-item__more",href:G.learnMore,target:"_blank",rel:"noreferrer",children:"Learn more →"}),J&&Array.isArray(G.tour)&&G.tour.length>0&&z("button",{type:"button",className:"mdcc-wn-item__tour",onClick:()=>{Y(),J(G.tour)},children:"▶ Take tour"})]},G.id))})})]})})}var Y7=({as:X,size:J=14})=>z(X,{size:J,strokeWidth:1.75,style:{display:"block"}}),Ce="mdcc-usage-tour-seen",$e="mdcc-collab-tour-seen",d8="__system__",K00="mdcc-theme",Se="mdcc-show-hidden",be="mdcc-sections-expanded",ye="maude-cp-mode",je="mdcc-sidebar-open",fe="mdcc-minimap-visible",ve="mdcc-zoomctl-visible",he="mdcc-annotations-visible";var Tq0=30000;function Iq0(X){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(X)}).catch(()=>{})}catch{}}var lR=[{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"}],wK={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",sync:"right",assistant:"right"},xe="mdcc-panel-sides",ge="mdcc-layers-mode";function me({side:X,width:J,open:Q,ids:Y,activeId:W,onPick:G,children:Z,labels:H=null}){return M("div",{className:"st-dockslot st-dockslot--"+X+(Q?"":" is-collapsed"),style:{width:Q?J:0,flexBasis:Q?J:0},children:[Q&&Y.length>1&&z("div",{className:"st-docktabs",role:"tablist","aria-label":X+" panels",children:Y.map((K)=>z("button",{type:"button",role:"tab","aria-selected":W===K,className:"st-docktab"+(W===K?" is-active":""),onClick:()=>G(K),children:H?.[K]||(lR.find((U)=>U.id===K)||{}).label||K},K))}),Z]})}var JQ=/\.(tsx|html?)$/i,kq0=[[/\.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 pR(X){for(let[J,Q]of kq0)if(J.test(X))return Q;return null}function LF(X){return X.replace(/^\.[^/]+\//,"").replace(JQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}var dR="0.60.4";function ue(X,J){let Q=()=>{try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(X,{body:J})}catch{}};if(X9()){S7("send_notification",{title:X,body:J}).catch(Q);return}Q()}function Cq0(){if(typeof window>"u")return"dark";try{let X=localStorage.getItem(K00);if(X==="light"||X==="dark")return X}catch{}return"dark"}function sZ(X,J){if(typeof window>"u")return J;try{let Q=localStorage.getItem(X);if(Q==="1")return!0;if(Q==="0")return!1}catch{}return J}function hR(X,J){if(typeof window>"u")return J;try{let Q=localStorage.getItem(X);return Q?JSON.parse(Q):J}catch{return J}}function $q0(X){if(X.kind==="runtime")return!1;if(X.label==="Design system")return!1;return!0}function RK(X){return X.split("/").pop()}function x8(X,J=!1,Q){if(typeof document>"u")return;let Y=document.getElementById("st-op-toast");if(!Y)Y=document.createElement("div"),Y.id="st-op-toast",Y.setAttribute("role","status"),Y.style.cssText="position:fixed;left:50%;bottom:64px;transform:translateX(-50%);z-index:80;display:flex;align-items:center;gap:10px;max-width:440px;padding:8px 14px;border-radius:8px;font:12px/1.45 var(--font-mono,monospace);box-shadow:0 8px 28px rgba(0,0,0,.34);pointer-events:none;opacity:0;transition:opacity 140ms ease;",document.body.appendChild(Y);Y.style.background=J?"#1d3524":"#3a1d1d",Y.style.color=J?"#b7e4c0":"#f1b8b8",Y.textContent="";let W=document.createElement("span");if(W.textContent=X,Y.appendChild(W),Q){let G=document.createElement("button");G.type="button",G.textContent=Q.label,G.style.cssText="pointer-events:auto;background:none;border:0;text-decoration:underline;color:inherit;font:inherit;cursor:pointer;padding:0;",G.onclick=()=>{Q.onClick(),Y.style.opacity="0",Y.style.pointerEvents="none"},Y.appendChild(G)}Y.style.opacity="1",Y.style.pointerEvents=Q?"auto":"none",clearTimeout(x8._t),x8._t=setTimeout(()=>{Y.style.opacity="0",Y.style.pointerEvents="none"},Q?6000:3200)}var le="maude-browse-hint-seen";function Sq0(X=!1){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(le)==="1")return}catch{return}if(document.getElementById("st-browse-hint"))return;let J=document.createElement("div");J.id="st-browse-hint",J.setAttribute("role","status"),J.style.cssText="position:fixed;left:50%;bottom:64px;transform:translateX(-50%);z-index:81;display:flex;align-items:center;gap:10px;max-width:520px;padding:10px 14px;border-radius:10px;font:12px/1.5 var(--font-ui,system-ui,sans-serif);background:var(--surface-2,#1b1e24);color:var(--text-1,#e7eaf0);border:1px solid var(--border-1,#333a45);box-shadow:0 10px 34px rgba(0,0,0,.42);opacity:0;transition:opacity 160ms ease;",J.innerHTML="<span>Your mock is <strong>live</strong> — click things to try it. "+'Press <kbd style="padding:1px 6px;border-radius:5px;border:1px solid var(--border-1,#333a45);background:var(--surface-3,#262b33);font-family:var(--font-mono,monospace)">V</kbd> '+(X?"to select & inspect.</span>":"to select & edit like Figma.</span>")+'<button type="button" aria-label="Dismiss" style="background:none;border:none;color:inherit;'+'cursor:pointer;font-size:15px;line-height:1;opacity:.65;padding:2px">×</button>';let Q=()=>{try{localStorage.setItem(le,"1")}catch{}J.style.opacity="0",setTimeout(()=>J.remove(),200),document.removeEventListener("keydown",Y,!0)},Y=(W)=>{if((W.key==="v"||W.key==="V")&&!W.metaKey&&!W.ctrlKey&&!W.altKey)Q()};J.querySelector("button")?.addEventListener("click",Q),document.addEventListener("keydown",Y,!0),document.body.appendChild(J),requestAnimationFrame(()=>{J.style.opacity="1"}),setTimeout(Q,9000)}function gW(X){return X.replace(JQ,"")}function bq0(X){return X.replace(JQ,"")}function yq0(X){let J=new Map;for(let G of X){if(!JQ.test(G.name))continue;let Z=bq0(G.name);if(!J.has(Z)||/\.tsx$/i.test(G.name))J.set(Z,G)}let Q=new Map,Y=[];for(let G of X){if(JQ.test(G.name))continue;let Z=null;for(let H of J.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 J){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 jq0(X,J,Q){let Y={};for(let W of Q||[]){let Z=(W.startsWith(J)?W.slice(J.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 X){let Z=(W.startsWith(J)?W.slice(J.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 U00(X,J){if(!J)return X;let Q=J.toLowerCase(),Y={},W=!1,G=Object.keys(X).filter((Z)=>Z!=="_files");for(let Z of G){let H=U00(X[Z],J);if(H)Y[Z]=H,W=!0}if(X._files){let Z=X._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 NF(X){return(X||[]).filter((J)=>J.status!=="resolved").length}function fq0(X){if(!X)return"";let J=new Date(X).getTime();if(!J)return"";let Q=Math.max(0,Math.floor((Date.now()-J)/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(X).toLocaleDateString()}function V00(X){let J=0,Q=0,Y=0;for(let W of Object.values(X||{}))for(let G of W||[])if(J++,G.status==="resolved")Y++;else Q++;return{all:J,open:Q,resolved:Y}}function DF({d:X,size:J=14,color:Q}){return z("svg",{width:J,height:J,viewBox:"0 0 24 24",fill:"none",stroke:Q||"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{flex:"none"},children:z("path",{d:X})})}var vq0={"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:M(G0,{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":M(G0,{children:[z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),z("path",{d:"M8 7.5v3.5M6.25 9.25h3.5"})]}),lock:M(G0,{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:M(G0,{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:M(G0,{children:[z("circle",{cx:"7",cy:"7",r:"4"}),z("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:M(G0,{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:M(G0,{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:M(G0,{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:M(G0,{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:M(G0,{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":M(G0,{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:M(G0,{children:[z("circle",{cx:"8",cy:"8",r:"5.6"}),z("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:M(G0,{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:M(G0,{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:M(G0,{children:[z("polyline",{points:"4 4 12 4"}),z("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:M(G0,{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:M(G0,{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:M(G0,{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:M(G0,{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:M(G0,{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:M(G0,{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":M(G0,{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":M(G0,{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":M(G0,{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":M(G0,{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":M(G0,{children:[z("path",{d:"M3 13 6.6 3l3.6 10"}),z("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":M(G0,{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:M(G0,{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:M(G0,{children:[z("polyline",{points:"6 5 3 8 6 11"}),z("polyline",{points:"10 5 13 8 10 11"})]}),download:M(G0,{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:M(G0,{children:[z("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),z("path",{d:"M14 2v3.33h-3.33"})]}),help:M(G0,{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:M(G0,{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:M(G0,{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:M(G0,{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:M(G0,{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:M(G0,{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:M(G0,{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:M(G0,{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 hq0({open:X,onClose:J,actions:Q}){let[Y,W]=u.useState(""),[G,Z]=u.useState(0),H=u.useRef(null);u.useEffect(()=>{if(X)W(""),Z(0)},[X]),u.useEffect(()=>{H.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[G]);let K=u.useMemo(()=>{let q=Y.trim().toLowerCase();if(!q)return Q;return Q.filter((B)=>B.label.toLowerCase().includes(q)||B.group&&B.group.toLowerCase().includes(q))},[Y,Q]);if(u.useEffect(()=>{if(G>=K.length)Z(0)},[K.length,G]),!X)return null;let U=(q)=>{J(),q.run()};return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(q)=>{if(q.target===q.currentTarget)J()},children:M("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[M("div",{className:"st-pal-search",children:[z(A9,{name:"search",size:18}),z("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(q)=>W(q.target.value),onKeyDown:(q)=>{if(q.key==="Escape")q.preventDefault(),J();else if(q.key==="ArrowDown")q.preventDefault(),Z((B)=>Math.min(K.length-1,B+1));else if(q.key==="ArrowUp")q.preventDefault(),Z((B)=>Math.max(0,B-1));else if(q.key==="Enter"){if(q.preventDefault(),K[G])U(K[G])}}}),z(MX,{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((q,B)=>{let N=q.group&&(B===0||K[B-1].group!==q.group)?z("div",{className:"st-pal-group",children:q.group},"g-"+q.group):null;return M(G0,{children:[N,M("button",{type:"button",className:"st-pal-item"+(B===G?" is-active":""),onMouseEnter:()=>Z(B),onClick:()=>U(q),children:[z("span",{className:"st-pal-icon",children:z(A9,{name:q.icon,size:15})}),z("span",{className:"st-pal-label",children:q.label}),q.kbd?z("span",{className:"st-pal-kbd",children:z(MX,{children:q.kbd})}):null]})]},q.id)})})]})})}function A9({name:X,size:J=16,className:Q}){return z("svg",{className:Q,width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:vq0[X]})}function xq0(X){if(!X||typeof X!=="string")return"?";let J=X.trim().split(/[\s._-]+/).filter(Boolean);if(!J.length)return"?";if(J.length===1)return J[0].slice(0,2).toUpperCase();return((J[0][0]||"")+(J[J.length-1][0]||"")).toUpperCase()||"?"}function pe({initials:X,hue:J,title:Q,pulse:Y}){return z("span",{className:"st-avatar"+(Y?" is-pulsing":""),style:{"--av-hue":J},"data-tip":Q,"aria-label":Q,children:X})}function MX({children:X}){return z("span",{className:"kbd",children:X})}function de(X,{min:J,max:Q,def:Y}){let W=u.useCallback((K)=>Math.min(Q,Math.max(J,K)),[J,Q]),[G,Z]=u.useState(()=>{try{let K=parseInt(localStorage.getItem(X)||"",10);return Number.isFinite(K)?W(K):Y}catch{return Y}});u.useEffect(()=>{try{localStorage.setItem(X,String(G))}catch{}},[X,G]);let H=u.useCallback((K)=>Z((U)=>W(typeof K==="function"?K(U):K)),[W]);return{w:G,setW:H,min:J,max:Q,def:Y}}function ce({label:X,size:J,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:K,def:U}=J,q=W==="rtl"?-1:1;return z("div",{className:"st-grip"+(Y?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":X,"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*q);else if(B.key==="ArrowLeft")B.preventDefault(),Z((F)=>F-N*q);else if(B.key==="Home")B.preventDefault(),Z(H);else if(B.key==="End")B.preventDefault(),Z(K)},children:M("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 xR=[{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}],gR={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},gq0={png:["selection","artboard","canvas-as-separate"],pdf:["selection","artboard","canvas-as-separate"],svg:["selection","artboard","canvas-as-separate"],html:["artboard","canvas-as-separate"],pptx:["canvas-as-separate"],mp4:["artboard"],gif:["artboard"],webm:["artboard"],canva:["canvas-as-separate"],zip:["project-raw"]},mq0=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],I3=[{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}],uq0="2x",ie=[{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}],lq0="auto",pq0={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 dq0(X){let J=String(X||"").split(".").pop()?.toLowerCase();return pq0[J]||"application/octet-stream"}function cq0({designRel:X,onPick:J,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[Z,H]=u.useState(null),[K,U]=u.useState(!1),[q,B]=u.useState(null),[N,F]=u.useState(()=>new Set),[D,_]=u.useState({}),[R,w]=u.useState(W?"artboard":"annotation");u.useEffect(()=>{let x=!0;return fetch("/_api/assets").then((m)=>m.json()).then((m)=>{if(!x)return;let p=m.ok?m.assets:[];H(p),_((f)=>{let s={...f};for(let n of p)s[n.path]=n.kind;return s})}).catch(()=>x&&H([])),()=>{x=!1}},[]),u.useEffect(()=>{let x=(m)=>{if(m.key==="Escape")m.stopPropagation(),Q()};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[Q]);let O=Array.from(N).some((x)=>(D[x]||"image")!=="image"),P=!W||O,I=!W?"No artboard on this canvas":O?"Video/audio can only be added as annotations":"";u.useEffect(()=>{if(P&&R==="artboard")w("annotation")},[P,R]);let k=(x)=>{F((m)=>{let p=new Set(m);if(p.has(x))p.delete(x);else p.add(x);return p})},$=async(x)=>{let m=await fetch("/_api/asset",{method:"POST",headers:{"content-type":x.type||"application/octet-stream"},body:x}),p=await m.json().catch(()=>({}));if(m.ok&&p.path)return{ok:!0,path:p.path};return{ok:!1,error:p.error||`upload failed (HTTP ${m.status})`}},C=async(x)=>{if(!x)return;U(!0),B(null);let m=await $(x);if(U(!1),m.ok)J(m.path);else B(m.error)},y=(x)=>{if(typeof x==="string"&&x.startsWith("video/"))return"video";if(typeof x==="string"&&x.startsWith("audio/"))return"audio";return"image"},v=async(x)=>{if(!x.length)return;U(!0),B(null);let m=await Promise.all(x.map((s)=>$(s).then((n)=>({...n,file:s}))));U(!1);let p=m.filter((s)=>s.ok),f=m.length-p.length;if(f>0)B(`${f} of ${m.length} uploads failed`);if(p.length)_((s)=>{let n={...s};for(let c of p)n[c.path]=y(c.file.type);return n}),F((s)=>{let n=new Set(s);for(let c of p)n.add(c.path);return n})},h=async()=>{U(!0),B(null);try{if(Y){let p=(await Iv()||[]).map((f)=>new File([new Uint8Array(f.bytes)],f.name,{type:dq0(f.name)}));if(U(!1),p.length)await v(p);return}let x=await FZ();if(x?.bytes){await C(new Blob([new Uint8Array(x.bytes)]));return}}catch(x){B(x?.message||"open failed")}U(!1)},l=()=>{if(X9()){h();return}let x=document.createElement("input");if(x.type="file",x.accept="image/*,video/*",Y)x.multiple=!0;x.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(x);let m=()=>{if(x.isConnected)x.remove()};window.addEventListener("focus",()=>setTimeout(m,300),{once:!0}),x.addEventListener("change",()=>{let p=x.files?Array.from(x.files):[];if(m(),!p.length)return;if(Y)v(p);else C(p[0])}),x.click()},o=(x)=>`/${X}/${x}`;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(x)=>{if(x.target===x.currentTarget)Q()},children:M("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[M("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(A9,{name:"x",size:15})})]}),M("div",{className:"st-dialog-bd",children:[M("div",{className:"st-ap-toolbar",children:[z("button",{type:"button",className:"st-btn",onClick:l,disabled:K,children:K?"Uploading…":"Upload…"}),q&&z("span",{className:"st-ap-err",children:q})]}),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((x)=>{let m=Y&&N.has(x.path);return M("button",{type:"button",className:"st-ap-cell","data-selected":m?"true":void 0,"aria-pressed":Y?m:void 0,title:`${x.name} · ${Math.max(1,Math.round(x.size/1024))} KB`,onClick:()=>Y?k(x.path):J(x.path),children:[Y&&z("span",{className:"st-ap-check","aria-hidden":"true",children:m?z(A9,{name:"check",size:12}):null}),x.kind==="video"?z("video",{className:"st-ap-thumb",src:o(x.path),muted:!0,playsInline:!0}):z("img",{className:"st-ap-thumb",src:o(x.path),alt:x.name,loading:"lazy"}),z("span",{className:"st-ap-name",children:x.name})]},x.path)})})]}),Y&&N.size>0&&M("div",{className:"st-dialog-ft st-ap-confirm",children:[M("span",{className:"st-ap-count",children:[N.size," selected"]}),M("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":R==="artboard",disabled:P,onClick:()=>w("artboard"),children:"Add to artboard"}),z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":R==="annotation",onClick:()=>w("annotation"),children:"Add as annotation"})]}),P&&z("span",{className:"st-ap-dest-note",children:I}),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),R),children:"Insert"})]})]})})}function iq0({mode:X,initialScope:J,activePath:Q,hasComps:Y=!1,comps:W=[],activeArtboardId:G=null,selection:Z=null,onClose:H}){let[K,U]=u.useState(X==="handoff"?"shadcn":"png"),[q,B]=u.useState(J&&gR[J]?J:"artboard"),[N,F]=u.useState(2),[D,_]=u.useState(uq0),[R,w]=u.useState(!0),[O,P]=u.useState(!1),[I,k]=u.useState(!1),[$,C]=u.useState(!1),[y,v]=u.useState(lq0),[h,l]=u.useState(!0),[o,x]=u.useState(!1),[m,p]=u.useState(null),[f,s]=u.useState([]),n=xR.find(($0)=>$0.id===K)||xR[0],c=n.handoff?[]:gq0[n.format]||["artboard"],U0=900,X0=3600,H0=sz(W,PA(W,{artboardId:G})),r=H0?.durationInFrames||0,D0=H0?.fps||30,z0=n.temporal&&r>900,l0=n.temporal&&r>3600;u.useEffect(()=>{if(c.length&&!c.includes(q))B(c[0])},[c,q]);let X8=u.useCallback(()=>{fetch("/_api/export-history").then(($0)=>$0.json()).then(($0)=>s(Array.isArray($0?.history)?$0.history.slice(0,6):[])).catch(()=>{})},[]);u.useEffect(()=>{X8()},[X8]),u.useEffect(()=>{function $0(O0){if(O0.key==="Escape")O0.preventDefault(),H()}return window.addEventListener("keydown",$0),()=>window.removeEventListener("keydown",$0)},[H]);async function d0(){if(n.handoff){let i0=`/design:handoff ${Q&&Q!==d8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(i0)}catch{}p({ok:!0,msg:`Copied: ${i0} — run it in Claude Code.`});return}x(!0),p(null);let $0=n.temporal?{scale:N}:{};if(n.format==="png"){let O0=I3.find((i0)=>i0.id===D)||I3[1];if(O0.kind==="dpi")$0.dpi=O0.value;else $0.scale=O0.value}if(n.format==="mp4"||n.format==="webm")$0.audio=h;if(l0)$0.maxFrames=r;if(n.format==="pdf"){$0.pdfPrint={includeBleed:R,marks:{crop:I,registration:$}};let O0=ie.find((i0)=>i0.id===y)?.value;if(O0!==void 0)$0.dpi=O0}if(G)$0.artboardId=G;if(Z?.selector)$0.selection=Z;try{let O0=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:n.format,scope:q,options:$0})});if(!O0.ok){p({ok:!1,msg:await O0.text()||`Export failed (${O0.status})`}),x(!1);return}H()}catch(O0){p({ok:!1,msg:O0&&O0.message?O0.message:String(O0)}),x(!1)}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:($0)=>{if($0.target===$0.currentTarget)H()},children:M("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[M("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:H,children:z(A9,{name:"x",size:15})})]}),M("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:Q&&Q!==d8?`Format · ${gW(RK(Q))}`:"Format"}),z("div",{className:"st-fmt-grid",children:xR.filter(($0)=>!$0.temporal||Y).map(($0)=>M("button",{type:"button",className:"st-fmt"+($0.id===K?" is-on":""),onClick:()=>{U($0.id),p(null)},children:[z(A9,{name:$0.icon,size:16}),z("span",{className:"st-fmt-name",children:$0.label}),z("span",{className:"st-fmt-sub",children:$0.sub})]},$0.id))}),!n.handoff&&M("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-scope",children:"Scope"}),z("select",{id:"st-export-scope",className:"st-select",value:q,onChange:($0)=>B($0.target.value),children:c.map(($0)=>z("option",{value:$0,children:gR[$0]},$0))})]}),!n.handoff&&n.format==="png"&&M("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:D,onChange:($0)=>_($0.target.value),children:I3.map(($0)=>z("option",{value:$0.id,children:$0.label},$0.id))})]}),!n.handoff&&n.format==="png"&&z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let $0=I3.find((i0)=>i0.id===D)||I3[1],O0=$0.kind==="dpi"?$0.value/96:$0.value;return`${$0.label} ≈ ${Math.round(1440*O0)}×${Math.round(900*O0)} for a 1440×900 artboard.`})()}),!n.handoff&&n.temporal&&M("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:N,onChange:($0)=>F(Number($0.target.value)),children:mq0.map(($0)=>z("option",{value:$0.value,children:$0.label},$0.value))})]}),!n.handoff&&n.temporal&&M("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[N,"× the artboard's native resolution (e.g. 960×540 → ",960*N,"×",540*N,")."]}),z0&&M("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: ",r," frames (≈",Math.round(r/D0),"s).",l0?` 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."]}),!n.handoff&&n.format==="pdf"&&M(G0,{children:[M("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:y,onChange:($0)=>v($0.target.value),children:ie.map(($0)=>z("option",{value:$0.id,children:$0.label},$0.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)."}),z("div",{className:"st-dialog-row",children:M("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:R,onChange:($0)=>w($0.target.checked)}),"Include bleed"]})}),z("div",{className:"st-dialog-row",children:M("button",{type:"button",className:"st-dialog-lbl",style:{background:"none",border:0,padding:0,cursor:"pointer"},onClick:()=>P(($0)=>!$0),"aria-expanded":O,children:[O?"▾":"▸"," Marks"]})}),O&&M("div",{style:{padding:"0 12px 4px",display:"flex",flexDirection:"column",gap:6},children:[M("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:I,onChange:($0)=>k($0.target.checked)}),"Crop marks"]}),M("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:$,onChange:($0)=>C($0.target.checked)}),"Registration marks"]})]}),M("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.",q==="canvas-as-separate"?" One PDF page per artboard.":""]})]}),!n.handoff&&(n.format==="mp4"||n.format==="webm")&&z("div",{className:"st-dialog-row",children:M("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:h,onChange:($0)=>l($0.target.checked)}),"Export with audio"]})}),n.handoff&&M("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."]}),m&&z("div",{className:"callout "+(m.ok?"callout--success":"callout--error"),style:{fontSize:12},children:m.msg}),f.length>0&&M("div",{className:"st-export-recent",children:[z("div",{className:"st-rp-hd",children:"Recent"}),f.map(($0,O0)=>M("div",{className:"st-export-recent-row",children:[M("span",{children:[String($0.format||"").toUpperCase()," ·"," ",gR[$0.scope]||$0.scope]}),z("span",{className:"st-mono",children:$0.filename})]},O0))]})]}),M("div",{className:"st-dialog-ft",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:H,children:"Cancel"}),M("button",{type:"button",className:"btn btn--primary",disabled:o,onClick:d0,children:[z(A9,{name:"download",size:14}),n.handoff?"Copy handoff command":o?"Exporting…":`Export ${n.label}`]})]})]})})}var _F=12,AF=16;function oq0({name:X,depth:J,defaultOpen:Q,children:Y,dirPath:W,drag:G,menu:Z}){let[H,K]=u.useState(Q),U=G?G.dropProps(W,!0,()=>K(!0)):{},q=G?.overDir===W,B=G?G.dragProps(W,!0):{},N=G?.draggedPath===W,F=G?.busyPath===W,D=M("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${LF(W)}`,"aria-expanded":H,"aria-dropeffect":G?"move":void 0,"aria-busy":F||void 0,tabIndex:-1,className:"st-row"+(q?" is-drop-target":"")+(N?" is-dragging":"")+(F?" is-busy":""),style:{paddingLeft:_F+J*AF+"px"},onClick:()=>K((_)=>!_),onContextMenu:Z?(_)=>Z.openAt(_,{kind:"dir",dirPath:W}):void 0,...B,...U,children:[z("span",{className:"st-row-glyph",children:z(A9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:X})]});return M(G0,{children:[Z?M("div",{className:"st-row-wrap",role:"none",children:[D,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${LF(W)}`,title:`Folder actions — ${X}`,"aria-label":`Folder actions for ${X}`,"aria-haspopup":"menu",onClick:(_)=>Z.openAt(_,{kind:"dir",dirPath:W}),children:z(DF,{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})})]}):D,H&&Y]})}function nq0({name:X,dsName:J,depth:Q,defaultOpen:Y,active:W,onOpenSystem:G,children:Z}){let[H,K]=u.useState(Y);return M(G0,{children:[M("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:_F+Q*AF+"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(A9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),M("button",{type:"button",className:"st-ds-open",onClick:()=>G(J),"aria-label":`Open ${J} design system view`,title:"Open the design system view",children:[z("span",{className:"st-row-glyph",children:z(A9,{name:"folder",size:13})}),z("span",{className:"st-row-name",children:X})]})]}),H&&Z]})}function OF({file:X,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,onDelete:G,openCount:Z,depth:H,kind:K,sidecar:U,dirty:q,experimentalKind:B,drag:N,menu:F}){let D=X.path===J||X.path===Q,_=JQ.test(X.name),R=!_&&K!=="runtime"?pR(X.name):null,w=!_&&!R,O=_?gW(X.name):X.name,P=_&&typeof G==="function"&&K!=="runtime",I=_&&!U&&K!=="runtime"&&typeof N<"u",k=I?N.dragProps(X.path,!0):{},$=N?.draggedPath===X.path,C=N?.busyPath===X.path,y=I&&typeof F<"u",v=X.path.split("/").slice(0,-1).join("/"),h=_?"canvas-row-"+X.path.replace(/^\.[^/]+\//,"").replace(JQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,l=M("button",{type:"button",role:"treeitem","data-testid":h,"aria-selected":D,"aria-disabled":w?"true":void 0,"aria-busy":C||void 0,tabIndex:D?0:-1,className:"st-row"+(D?" is-sel":"")+(K==="runtime"?" is-muted":"")+($?" is-dragging":"")+(C?" is-busy":""),style:{paddingLeft:_F+H*AF+"px"},title:X.path+(Z?` — ${Z} open`:w?" (file index only)":""),onClick:()=>{if(_)Y(X.path);else if(R)W?.(X.path)},onContextMenu:y?(o)=>F.openAt(o,{kind:"file",path:X.path,dir:v}):void 0,...k,children:[z("span",{className:"st-row-glyph",children:z(A9,{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"}),q&&z("span",{className:"st-git-badge","data-kind":q,title:`Unsaved (${q})`,"aria-label":`Unsaved, ${q}`,children:q}),Z>0&&z("span",{className:"st-row-badge",children:Z})]});if(!P&&!y)return l;return M("div",{className:"st-row-wrap",role:"none",children:[l,y&&z("button",{type:"button",className:"st-row-menu-btn"+(P?" has-delete-sibling":""),"data-testid":`tree-row-menu-${LF(X.path)}`,title:`Move ${O}…`,"aria-label":`Actions for ${O}`,"aria-haspopup":"menu",onClick:(o)=>F.openAt(o,{kind:"file",path:X.path,dir:v}),children:z(DF,{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})}),P&&z("button",{type:"button",className:"st-row-del",title:`Delete ${O}`,"aria-label":`Delete canvas ${O}`,onClick:(o)=>{o.stopPropagation(),G(X.path,O)},children:z(DF,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})}function rq0({primary:X,sidecars:J,depth:Q,kind:Y,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,showHidden:q,forceOpen:B,dirtyByPath:N,experimentalKind:F,drag:D,menu:_}){let R=N?.get(X.path),w=J.length>0,[O,P]=u.useState(!1),I=B||O,k=X.path===W;if(!(w&&q))return z(OF,{file:X,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,depth:Q,kind:Y,dirty:R,experimentalKind:F,drag:D,menu:_});let C=typeof D<"u",y=C?D.dragProps(X.path,!0):{},v=D?.draggedPath===X.path,h=D?.busyPath===X.path,l=C&&typeof _<"u",o=X.path.split("/").slice(0,-1).join("/"),x=M("button",{type:"button",role:"treeitem","aria-selected":k,"aria-expanded":I,"aria-busy":h||void 0,tabIndex:k?0:-1,className:"st-row st-canvas-row"+(k?" is-sel":"")+(v?" is-dragging":"")+(h?" is-busy":""),style:{paddingLeft:_F+Q*AF+"px"},title:X.path,onClick:(m)=>{if(m.target.closest(".st-canvas-chev")){P((p)=>!p);return}Z(X.path)},onContextMenu:l?(m)=>_.openAt(m,{kind:"file",path:X.path,dir:o}):void 0,...y,children:[z("span",{className:"st-row-glyph st-canvas-chev",onClick:(m)=>{m.stopPropagation(),P((p)=>!p)},children:z(A9,{name:"chevron-right",className:"st-chev"+(I?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:gW(X.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"}),R&&z("span",{className:"st-git-badge","data-kind":R,title:`Unsaved (${R})`,"aria-label":`Unsaved, ${R}`,children:R}),U>0&&z("span",{className:"st-row-badge",children:U})]});return M(G0,{children:[l?M("div",{className:"st-row-wrap",role:"none",children:[x,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${LF(X.path)}`,title:`Move ${gW(X.name)}…`,"aria-label":`Actions for ${gW(X.name)}`,"aria-haspopup":"menu",onClick:(m)=>_.openAt(m,{kind:"file",path:X.path,dir:o}),children:z(DF,{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})})]}):x,I&&J.map((m)=>z(OF,{file:m,activePath:W,previewPath:G,onOpen:Z,onPreview:H,openCount:0,depth:Q+1,kind:Y,sidecar:!0},m.path))]})}function q00({node:X,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z=1,kind:H,showHidden:K,search:U,dsFolders:q,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:D,canvasKinds:_,dirPath:R="",drag:w,menu:O}){let P=Object.keys(X).filter((l)=>l!=="_files").sort(),I=X._files||[],{canvases:k,orphans:$}=u.useMemo(()=>yq0(I),[I]),{mediaOrphans:C,metaOrphans:y}=u.useMemo(()=>{let l=[],o=[];for(let x of $){let m=pR(x.primary.name);(m==="image"||m==="video"||m==="audio"||m==="font"?l:o).push(x)}return{mediaOrphans:l,metaOrphans:o}},[$]),v=!!(U&&U.trim()),h=u.useMemo(()=>{if(!q||Z!==1)return null;let l=new Map;for(let o of q)l.set(o.folder,o);return l},[q,Z]);return M(G0,{children:[k.map((l)=>{let o=v&&l.sidecars.some((x)=>{let m=U.toLowerCase();return x.name.toLowerCase().includes(m)||x.path.toLowerCase().includes(m)});return z(rq0,{primary:l.primary,sidecars:l.sidecars,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,onDelete:F,openCount:NF(G[l.primary.path]),depth:Z,kind:H,showHidden:K,forceOpen:o,dirtyByPath:D,experimentalKind:_?.[l.primary.path],drag:w,menu:O},l.primary.path)}),C.map((l)=>z(OF,{file:l.primary,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,openCount:NF(G[l.primary.path]),depth:Z,kind:H},l.primary.path)),K&&y.map((l)=>z(OF,{file:l.primary,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,openCount:NF(G[l.primary.path]),depth:Z,kind:H},l.primary.path)),P.map((l)=>{let o=h?.get(l),x=R?`${R}/${l}`:l,m=z(q00,{node:X[l],activePath:J,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z+1,kind:H,showHidden:K,search:U,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:D,canvasKinds:_,dirPath:x,drag:w,menu:O});if(o&&N)return z(nq0,{name:l,dsName:o.name,depth:Z,defaultOpen:!0,active:J===d8&&o.name===B,onOpenSystem:N,children:m},l);return z(oq0,{name:l,depth:Z,defaultOpen:!0,dirPath:x,drag:w,menu:O,children:m},l)})]})}var qF={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function aq0(X){if(X.kind==="project")return qF.project;if(X.kind==="runtime")return qF.runtime;if(X.label==="Design system")return qF.ds;if(X.label==="UI kit")return qF.canvas;return{title:X.label.toUpperCase(),pillFromCount:!0}}function sq0({readOnly:X=!1,cloud:J,groups:Q,activePath:Y,previewPath:W,activeDsName:G,onOpen:Z,onPreview:H,onOpenSystem:K,wsConnected:U,search:q,setSearch:B,commentsByFile:N,showHidden:F,sectionsExpanded:D,onToggleSection:_,onNewBoard:R,onDeleteBoard:w,onRefresh:O,refreshing:P,collapsed:I,onCollapse:k,width:$,resizing:C,dirtyByPath:y,project:v,gitBranch:h,remoteSync:l,onGetLatest:o,canvasKinds:x,onMoveCanvas:m,onNewFolder:p,onDeleteFolder:f,syncStatus:s,onLinkedHub:n}){let c=u.useMemo(()=>{if(!q)return Q;return Q.map((M0)=>({...M0,tree:U00(M0.tree,q),filtered:!!q}))},[Q,q]),U0=GS(m),X0=YS(),H0=u.useMemo(()=>{let M0=[];for(let j8 of Q){if(j8.label==="Design system"||j8.kind!=="canvas")continue;let L9=j8.fullPath.replace(/^\.[^/]+\//,"")||j8.fullPath;M0.push({path:j8.fullPath,label:L9});for(let U8 of j8.dirs||[])M0.push({path:U8,label:U8.replace(/^\.[^/]+\//,"")})}return M0},[Q]),r=X0.state?.extra,D0=r?.kind==="file"?[{id:"move-to",label:"Move to…",onSelect:()=>X0.showMoveTo()}]:r?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{X0.close();let M0=window.prompt("New folder name:");if(M0?.trim())p(r.dirPath,M0.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{X0.close(),f(r.dirPath,r.dirPath.split("/").pop())}}]:[],z0=r?.kind==="file"?H0.filter((M0)=>M0.path!==r.dir):[],[l0,X8]=u.useState(!1),[d0,$0]=u.useState("board"),[O0,i0]=u.useState(""),[c8,z8]=u.useState(""),[Q9,L8]=u.useState(!1),W8=u.useMemo(()=>Q.find((M0)=>M0.kind==="canvas"&&M0.label!=="Design system")?.fullPath,[Q]),b8=u.useCallback(async()=>{let M0=O0.trim();if(!M0||Q9)return;if(L8(!0),z8(""),d0==="folder"){if(!W8){L8(!1),z8("no canvas group to create a folder in");return}let L9=await p(W8,M0);if(L8(!1),L9?.ok)X8(!1),i0("");else z8(L9?.error||"could not create folder");return}let j8=await R(M0);if(L8(!1),j8?.ok)X8(!1),i0("");else z8(j8?.error||"could not create board")},[O0,Q9,R,p,d0,W8]),i8=u.useMemo(()=>{let M0=0;for(let j8 of Q)for(let L9 of j8.paths||[])if(JQ.test(L9))M0++;return M0},[Q]),p9=u.useMemo(()=>{let M0=0;for(let j8 of c)for(let L9 of j8.paths||[])if(JQ.test(L9))M0++;return M0},[c]);return M("nav",{className:"st-sidebar"+(I?" is-collapsed":"")+(C?" is-resizing":""),style:I||!$?void 0:{width:$,flexBasis:$},"aria-label":"Files","data-tour":"sidebar",children:[M("div",{className:"st-sb-hd",children:[z("span",{className:"st-sb-title",children:"Files"}),M("div",{className:"st-sb-hd-actions",children:[!X&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":l0&&d0==="board",onClick:()=>{z8(""),$0("board"),X8((M0)=>d0==="board"?!M0:!0)},children:z(A9,{name:"plus",size:15})}),!X&&W8&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":l0&&d0==="folder",onClick:()=>{z8(""),$0("folder"),X8((M0)=>d0==="folder"?!M0:!0)},children:z(A9,{name:"folder-plus",size:15})}),O&&z("button",{type:"button",className:"st-iconbtn st-refresh"+(P?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":P||void 0,disabled:P,onClick:()=>O(),children:z(A9,{name:"reload",size:15})}),M("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"}),p9," / ",i8]}),k&&z("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:k,children:z(A9,{name:"panel-left",size:15})})]})]}),l0?M("div",{className:"st-newboard",children:[z("input",{type:"text",autoFocus:!0,placeholder:d0==="folder"?"folder name…":"brief board name…",value:O0,maxLength:60,disabled:Q9,"aria-label":d0==="folder"?"New folder name":"New brief board name",onChange:(M0)=>i0(M0.target.value),onKeyDown:(M0)=>{if(M0.key==="Enter")M0.preventDefault(),b8();else if(M0.key==="Escape")M0.preventDefault(),X8(!1),i0(""),z8("")}}),z("button",{type:"button",className:"st-newboard-go",disabled:Q9||!O0.trim(),"data-tip":"Create · Enter","aria-label":d0==="folder"?"Create folder":"Create brief board",onClick:b8,children:Q9?"…":"↵"})]}):null,c8?z("div",{className:"st-newboard-err",role:"alert",children:c8}):null,z("div",{className:"st-search",children:M("div",{className:"st-search-box",children:[z(A9,{name:"search",size:13}),z("input",{type:"search","data-testid":"canvas-search",placeholder:"Search canvases…",value:q,onChange:(M0)=>B(M0.target.value),onKeyDown:(M0)=>{if(M0.key==="Escape")if(M0.preventDefault(),q)B("");else M0.currentTarget.blur()},"aria-label":"Filter files"}),q?z("button",{className:"st-search-clear",onClick:()=>B(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):z(MX,{children:"/"})]})}),z("div",{className:"st-tree",role:"tree","aria-label":"Project file tree","data-testid":"canvas-list",children:c.map((M0)=>{if(!F&&!q&&M0.kind==="runtime")return null;let j8=aq0(M0),L9=(M0.paths||[]).filter((w0)=>JQ.test(w0)).length,U8=j8.pill||(j8.pillFromDsCount?String(M0.dsFolders?.length||0):null)||(j8.pillFromCount?String(L9||M0.paths?.length||0):null),D9=M0.tree&&Object.keys(M0.tree).length>0,y0=M0.label==="Design system",Z0=M0.kind==="project";if(!F&&!q&&Z0&&L9===0)return null;let S0=$q0(M0),c0=D[M0.label],q8=!!q||(c0===void 0?S0:c0),N8=!y0&&M0.kind==="canvas"&&!X,H8=N8?U0.dropProps(M0.fullPath,!0):{},m0=U0.overDir===M0.fullPath;return M("div",{className:"st-tree-section",children:[M("button",{type:"button",className:"st-tree-sec-hd"+(m0?" is-drop-target":""),onClick:()=>_(M0.label,S0),"aria-expanded":q8,"aria-dropeffect":N8?"move":void 0,title:q8?"Collapse section":"Expand section",...H8,children:[z(A9,{name:"chevron-right",className:"st-chev"+(q8?" is-open":""),size:13}),z("span",{className:"st-sec-name",children:j8.title}),U8&&z("span",{className:"st-pill",children:U8})]}),q8&&(D9?z(q00,{node:M0.tree,activePath:Y,previewPath:W,onOpen:Z,onPreview:H,commentsByFile:N,depth:1,kind:M0.kind,showHidden:F,search:q,dsFolders:M0.dsFolders,activeDsName:G,onOpenSystem:y0?K:void 0,onDelete:y0||X?void 0:w,dirtyByPath:y,canvasKinds:x,dirPath:M0.fullPath,drag:!y0&&M0.kind==="canvas"&&!X?U0:void 0,menu:!y0&&M0.kind==="canvas"&&!X?X0:void 0}):z("div",{className:"st-tree-empty",children:q?"No matches.":"Empty."}))]},M0.label)})}),z(WS,{state:X0.state,onClose:X0.close,rootItems:D0,destinations:z0,onPickDestination:(M0)=>m(r.path,M0)}),z(mA,{project:v,liveBranch:h,remoteSync:l,onGetLatest:o}),J===null?z(UA,{syncStatus:s,onLinkedHub:n}):null,z(qA,{})]})}function tq0({shown:X,onExpand:J,onSearch:Q}){return z("div",{className:"st-rail"+(X?" is-shown":""),children:M("div",{className:"st-rail-inner",children:[z("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:J,children:z(A9,{name:"panel-left",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:z(A9,{name:"search",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:J,children:z(A9,{name:"folder",size:15})})]})})}function eq0({open:X,onClose:J,onStartTour:Q}){if(u.useEffect(()=>{if(!X)return;function Y(W){if(W.key==="Escape")J()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[X,J]),!X)return null;return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:M("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[M("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),M("span",{className:"sku",children:["MAUDE-DEV-SRV / v",dR]}),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:J,children:"×"})]}),M("div",{className:"help-modal-body",children:[M("details",{open:!0,children:[z("summary",{children:"Canvas selection & tools"}),M("ul",{children:[M("li",{children:[z("kbd",{children:"V"})," ",z("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),M("li",{children:[z("kbd",{children:"H"})," ",z("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),M("li",{children:[z("kbd",{children:"C"})," ",z("span",{children:"comment tool — hover paints, click drops a pin"})]}),M("li",{children:[z("kbd",{children:"⌘"})," + hover ",z("span",{children:"preview deepest element under cursor"})]}),M("li",{children:[z("kbd",{children:"⌘"})," + click ",z("span",{children:"select that element (replace)"})]}),M("li",{children:[z("kbd",{children:"⌘⇧"})," + click ",z("span",{children:"add deepest to selection (multi)"})]}),M("li",{children:["right-click ",z("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),M("li",{children:[z("kbd",{children:"Esc"})," in canvas ",z("span",{children:"clear selection + close menu"})]})]})]}),M("details",{children:[z("summary",{children:"Annotation tools"}),M("ul",{children:[M("li",{children:[z("kbd",{children:"B"})," ",z("span",{children:"pen — freehand stroke"})]}),M("li",{children:[z("kbd",{children:"R"})," ",z("span",{children:"rectangle — drag to define corners"})]}),M("li",{children:[z("kbd",{children:"O"})," ",z("span",{children:"ellipse — drag from center outward"})]}),M("li",{children:[z("kbd",{children:"A"})," ",z("span",{children:"arrow — drag tail → tip"})]}),M("li",{children:[z("kbd",{children:"E"})," ",z("span",{children:"eraser — click or drag over strokes to remove"})]}),M("li",{children:[z("kbd",{children:"V"})," + click stroke ",z("span",{children:"select annotation (Shift+click to multi)"})]}),M("li",{children:[z("kbd",{children:"V"})," + drag empty ",z("span",{children:"marquee-select strokes that overlap"})]}),M("li",{children:["double-click rect/ellipse ",z("span",{children:"add text inside the shape"})]}),M("li",{children:["arrow keys ",z("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),M("li",{children:[z("kbd",{children:"Backspace"})," ",z("span",{children:"delete selected annotations"})]}),M("li",{children:[z("kbd",{children:"⇧P"})," ",z("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),M("details",{children:[z("summary",{children:"Canvas & panels"}),M("ul",{children:[M("li",{children:["click in tree ",z("span",{children:"open canvas (replaces the active one)"})]}),M("li",{children:["File ▸ Close canvas ",z("span",{children:"clear the stage"})]}),M("li",{children:[z("kbd",{children:"⌘R"})," ",z("span",{children:"reload canvas"})]}),M("li",{children:[z("kbd",{children:"/"})," ",z("span",{children:"focus search"})]}),M("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"comments panel"})]}),M("li",{children:[z("kbd",{children:"⌘⇧I"})," ",z("span",{children:"inspector"})]}),M("li",{children:[z("kbd",{children:"?"})," ",z("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),M("details",{children:[z("summary",{children:"Slash commands"}),M("ul",{className:"cmds",children:[M("li",{children:[M("code",{children:['/design:edit "',z("i",{children:"feedback"}),'"']}),z("span",{children:"edit + 4-iter multi-axis loop"})]}),M("li",{children:[M("code",{children:['/design:edit "',z("i",{children:"…"}),'" --perfect']}),z("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),M("li",{children:[M("code",{children:['/design:edit "',z("i",{children:"…"}),'" --no-critic']}),z("span",{children:"raw edit, skip loop"})]}),M("li",{children:[M("code",{children:['/design:edit "',z("i",{children:"…"}),'" --opt-out=',z("i",{children:"scope"})]}),z("span",{children:"override DS scope (palette/aesthetic/full)"})]}),M("li",{children:[M("code",{children:['/design:new "',z("i",{children:"Name"}),'" "',z("i",{children:"brief"}),'"']}),z("span",{children:"scaffold canvas"})]}),M("li",{children:[M("code",{children:['/design:new "',z("i",{children:"…"}),'" --opt-out=aesthetic']}),z("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),M("li",{children:[z("code",{children:"/design:critic"}),z("span",{children:"review panel (routed)"})]}),M("li",{children:[z("code",{children:"/design:critic --all"}),z("span",{children:"10-critic sweep"})]}),M("li",{children:[z("code",{children:"/design:critic --agent signature-moment-critic"}),z("span",{children:"aspiration axis only"})]}),M("li",{children:[z("code",{children:"/design:rollback"}),z("span",{children:"undo last edit"})]}),M("li",{children:[z("code",{children:"/design:screenshot"}),z("span",{children:"capture canvas"})]}),M("li",{children:[z("code",{children:"/design:setup-docs"}),z("span",{children:"refresh README + INDEX"})]}),M("li",{children:[z("code",{children:"/design:handoff"}),z("span",{children:"migrate to apps/"})]})]})]}),M("details",{children:[z("summary",{children:"Opt-out scope"}),M("ul",{children:[M("li",{children:[z("strong",{children:"palette"})," ",z("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),M("li",{children:[z("strong",{children:"aesthetic"})," ",z("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),M("li",{children:[z("strong",{children:"full"})," ",z("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),M("li",{children:[z("em",{children:"A11y enforced at every scope"})," ",z("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),M("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.'})]})]}),M("details",{children:[z("summary",{children:"Auto-critic loop"}),M("ul",{children:[M("li",{children:[z("strong",{children:"Default"})," ",z("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),M("li",{children:[z("strong",{children:"--perfect"})," ",z("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),M("li",{children:[z("strong",{children:"--perfect --all"})," ",z("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),M("li",{children:["Exit: ",z("code",{children:"solid"})," · ",z("code",{children:"stable-but-bland"})," · ",z("code",{children:"max-reached"})," ","· ",z("code",{children:"divergent"})]}),M("li",{children:[z("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),M("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."]})]})]}),M("details",{children:[z("summary",{children:"Pin-to-element flow"}),M("ol",{children:[z("li",{children:"Open a canvas"}),M("li",{children:[z("kbd",{children:"⌘"}),"+click element"]}),z("li",{children:"Status bar shows ● selector"}),M("li",{children:["Run"," ",M("code",{children:['/design:edit "',z("i",{children:"change just this"}),'"']})]}),M("li",{children:["Reload iframe (",z("kbd",{children:"⌘R"}),")"]})]})]}),M("details",{children:[z("summary",{children:"Comments"}),M("ol",{children:[M("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"}),M("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"opens panel — All / Open / Resolved"})]}),M("li",{children:["Click row in panel ",z("span",{children:"jumps to that file + pin"})]}),M("li",{children:["Claude reads ",z("code",{children:"_comments/<slug>.json"})," on next ",z("code",{children:"/design"})]})]})]})]})]})})}var mR=[{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 X20({kbd:X,alt:J}){let Q=(Y,W)=>z("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>z(MX,{children:G},`${G}-${Z}`))},W);return M("span",{className:"so-combos",children:[Q(X,"main"),J?J.split(" / ").map((Y)=>M(G0,{children:[z("span",{className:"so-or",children:"/"}),Q(Y,Y)]},Y)):null]})}function J20({open:X,onClose:J}){if(u.useEffect(()=>{if(!X)return;function Y(W){if(W.key==="Escape")W.preventDefault(),J()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[X,J]),!X)return null;let Q=mR.reduce((Y,W)=>Y+W.items.length,0);return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:M("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[M("div",{className:"so-overlay-hd",children:[z("span",{className:"so-title",children:"Keyboard shortcuts"}),M("span",{className:"so-trigger",children:["press ",z(MX,{children:"?"})," to open"]})]}),z("div",{className:"so-columns",children:mR.map((Y)=>M("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)=>M("div",{className:"so-pair",children:[z("dt",{children:W.label}),z("dd",{children:z(X20,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),M("div",{className:"so-overlay-ft",children:[M("span",{children:["close with ",z(MX,{children:"Esc"})]}),M("span",{className:"so-count",children:[Q," bindings · ",mR.length," groups"]})]})]})})}var Q20=["File","Edit","View","Selection","Tools","Help"];function B00(X){u.useEffect(()=>{function J(Y){if(Y.key==="Escape")X()}function Q(Y){if(!Y.target.closest(".st-dropdown, .st-menu"))X()}return window.addEventListener("keydown",J),window.addEventListener("mousedown",Q),()=>{window.removeEventListener("keydown",J),window.removeEventListener("mousedown",Q)}},[X])}function Y20({panels:X,onToggle:J,onClose:Q,onZoom:Y,hasCanvas:W}){return B00(Q),M("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[z("div",{className:"st-dd-hd",children:"Panels"}),X.map((G)=>M("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}J(G.id),Q()},children:[M("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check",children:G.checked?z(A9,{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(MX,{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)=>M("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":W?void 0:"true",onClick:()=>{if(!W)return;Y?.(G.op),Q()},children:[M("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:G.label})]}),z(MX,{children:G.shortcut})]},G.label))]})}function TK({label:X,left:J,header:Q,items:Y,onAction:W,onClose:G}){return B00(G),M("div",{className:"st-dropdown",role:"menu","aria-label":X,style:{left:J},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):M("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:[M("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:Z.label})]}),Z.shortcut?z(MX,{children:Z.shortcut}):null]},Z.id))]})}function W20({onAction:X,onClose:J}){return z(TK,{label:"Help",left:320,onAction:X,onClose:J,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"},...X9()?[{id:"collab-tour",label:"How sharing works"}]:[],...X9()?[{id:"quick-setup",label:"Quick setup"}]:[],...X9()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function G20({onAction:X,onClose:J,readOnly:Q=!1}){return z(TK,{label:"Selection",left:214,onAction:X,onClose:J,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},...Q?[]:[{id:"select-all-annotations",label:"Select all annotations",shortcut:"⌘ ⇧ A"}]]})}function Z20({onAction:X,onClose:J,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(TK,{label:"Tools",left:290,header:"Tool palette",onAction:X,onClose:J,items:Y})}function H20({onAction:X,onClose:J,hasCanvas:Q,readOnly:Y=!1}){return z(TK,{label:"File",left:40,onAction:X,onClose:J,items:Y?[{id:"export",label:"Export…",shortcut:"⇧⌘E"},{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:"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 z20({onAction:X,onClose:J,hasCanvas:Q,readOnly:Y=!1}){if(Y)return z(TK,{label:"Edit",left:90,onAction:X,onClose:J,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"}]});return z(TK,{label:"Edit",left:90,onAction:X,onClose:J,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 K20({activePath:X,project:J,cloud:Q,tabsCount:Y,openMenu:W,setOpenMenu:G,commentsPanelOpen:Z,onToggleComments:H,changesOpen:K,changesCount:U,onToggleChanges:q,onOpenSystem:B,sidebarOpen:N,onToggleSidebar:F,showHidden:D,onToggleShowHidden:_,onOpenHelp:R,onOpenShortcuts:w,onReportBug:O,onStartTour:P,onStartCollabTour:I,annotationsVisible:k,onToggleAnnotations:$,minimapVisible:C,onToggleMinimap:y,zoomCtlVisible:v,onToggleZoomCtl:h,presentMode:l,onTogglePresent:o,printGuidesVisible:x,onTogglePrintGuides:m,postToActiveCanvas:p,onOpenWhatsNew:f,onOpenReadiness:s,onOpenQuickSetup:n,onWatchIntro:c,whatsNewCount:U0,exportCenter:X0,artboardCount:H0=0,presence:r=null,inspectorOpen:D0,inspectorTab:z0,onToggleInspector:l0,autoOpenInspector:X8,onToggleAutoOpenInspector:d0,onOpenLayers:$0,timelineOpen:O0,onToggleTimeline:i0,hasComps:c8=!1,assistantOpen:z8,onToggleAssistant:Q9,assistantBusy:L8,assistantUnseen:W8,onNewCanvas:b8,onAssembleVideo:i8,onOpenExport:p9,onOpenSettings:M0,onOpenGenerate:j8,onReload:L9,onCloseCanvas:U8,onInsertArtboard:D9,readOnly:y0=!1}){let Z0=X===d8,S0=Z0?"SYSTEM":X?"CANVAS":"IDLE",c0=Z0?z("b",{children:"design system"}):X?M(G0,{children:[X.split("/").slice(0,-1).join("/"),"/",z("b",{children:gW(RK(X))})]}):z("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),q8=new Set(Q?["autoopen"]:["assistant","autoopen"]),N8=[{id:"tree",label:"Project Tree",shortcut:"T",checked:N,disabled:!1},{id:"changes",label:Q?"History":U>0?`Changes · ${U} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:K,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:Z,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:D,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:D0&&z0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:D0,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!X8,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:c8?"video":void 0,checked:O0,disabled:!1},...X9()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:z8,disabled:!1}]:Q?[{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:k,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:C,disabled:!X||Z0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:v,disabled:!X||Z0},{id:"present",label:"Presentation Mode",shortcut:"",checked:l,disabled:!X||Z0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:x,disabled:!X||Z0}].filter((w0)=>!y0||!q8.has(w0.id)),H8=["file","edit","view","selection","tools","help"];function m0(w0){if(H8.includes(w0))G(W===w0?null:w0)}return u.useEffect(()=>{if(!W||!H8.includes(W))return;let w0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function K8(I8){let k8=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!k8.length)return;let _9=k8.indexOf(document.activeElement);if(I8.key==="ArrowDown")I8.preventDefault(),k8[(_9+1)%k8.length].focus();else if(I8.key==="ArrowUp")I8.preventDefault(),k8[(_9-1+k8.length)%k8.length].focus();else if(I8.key==="Home")I8.preventDefault(),k8[0].focus();else if(I8.key==="End")I8.preventDefault(),k8[k8.length-1].focus();else if(I8.key==="ArrowRight"||I8.key==="ArrowLeft"){I8.preventDefault();let A8=I8.key==="ArrowRight"?1:-1,T9=H8.indexOf(W);G(H8[(T9+A8+H8.length)%H8.length])}else if(I8.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",K8),()=>{clearTimeout(w0),window.removeEventListener("keydown",K8)}},[W,G]),M("header",{className:"st-menubar",role:"menubar","aria-label":"Application menubar","data-testid":"menubar",children:[M("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"})]}),Q?M("span",{className:"st-cloudback","data-testid":"cloud-back",children:[z("a",{className:"st-cloudback-link",href:Q.dashboardUrl||"https://cloud.maude.sh",title:"Back to your projects",children:"← Dashboard"}),Q.projectName?z("span",{className:"st-cloudback-project","data-testid":"cloud-project-name",children:Q.projectName}):null]}):null,z("nav",{className:"st-menus","aria-label":"Application menus","data-tour":"menus",children:Q20.map((w0)=>{let K8=w0.toLowerCase(),I8=H8.includes(K8),k8=I8||K8==="help";return z("button",{type:"button",className:"st-menu",role:"menuitem","data-tour":K8==="help"?"help":void 0,"aria-haspopup":I8?"menu":void 0,"aria-expanded":I8?W===K8:void 0,onClick:()=>m0(K8),onMouseEnter:()=>{if(W!==null&&I8)G(K8)},children:w0},K8)})}),W==="file"&&z(H20,{readOnly:y0,hasCanvas:!!X,onAction:(w0)=>{if(w0==="new")b8?.();else if(w0==="assemble")i8?.();else if(w0==="export")p9?.("export");else if(w0==="handoff")p9?.("handoff");else if(w0==="generate")j8?.();else if(w0==="settings")M0?.();else if(w0==="reload")L9?.();else if(w0==="close")U8?.()},onClose:()=>G(null)}),W==="edit"&&z(z20,{readOnly:y0,hasCanvas:!!X&&!Z0,onAction:(w0)=>{if(w0==="undo")p({dgn:"undo"});else if(w0==="redo")p({dgn:"redo"});else if(w0==="deselect-all")p({dgn:"selection-clear"});else if(w0==="select-all-annotations")p({dgn:"annotation-select-all"});else if(w0.startsWith("new-artboard:"))D9?.(w0.slice(13))},onClose:()=>G(null)}),W==="view"&&z(Y20,{panels:N8,onToggle:(w0)=>{if(w0==="tree")F();else if(w0==="changes")q();else if(w0==="comments")H();else if(w0==="hidden")_();else if(w0==="annotate")$();else if(w0==="inspector")l0();else if(w0==="autoopen")d0?.();else if(w0==="timeline")i0?.();else if(w0==="assistant")Q9?.();else if(w0==="layers")$0?.();else if(w0==="minimap")y?.();else if(w0==="zoomctl")h?.();else if(w0==="present")o?.();else if(w0==="print-guides")m?.()},onZoom:(w0)=>p({dgn:"zoom",op:w0}),hasCanvas:!!X&&!Z0,onClose:()=>G(null)}),W==="selection"&&z(G20,{readOnly:y0,onAction:(w0)=>{if(w0==="deselect-all")p({dgn:"selection-clear"});else if(w0==="select-all-annotations")p({dgn:"annotation-select-all"})},onClose:()=>G(null)}),W==="tools"&&z(Z20,{readOnly:y0,onAction:(w0)=>p({dgn:"tool-set",tool:w0}),onClose:()=>G(null)}),W==="help"&&z(W20,{onAction:(w0)=>{if(w0==="shortcuts")w?.();else if(w0==="help")R?.();else if(w0==="report-bug")O?.();else if(w0==="tour")P?.();else if(w0==="collab-tour")I?.();else if(w0==="quick-setup")n?.();else if(w0==="readiness")s?.();else if(w0==="whatsnew")f?.();else if(w0==="watch-intro")c?.()},onClose:()=>G(null)}),M("div",{className:"st-mb-right","data-tour":"status",children:[r?z("div",{className:"st-presence",children:r}):null,y0&&z("span",{className:"st-stamp st-stamp--viewonly","data-testid":"view-only-stamp","data-tip":Q?.user?`${Q.user} is a viewer on this project — you can browse, comment and export. 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. Ask a project owner for edit access.",children:"VIEW ONLY"}),Q?.user?M("span",{className:"st-cloudwho","data-testid":"cloud-account",children:[z("span",{className:"st-cloudwho-email",title:Q.role?`Signed in as ${Q.user} — ${Q.role}`:Q.user,children:Q.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,X9()&&!y0&&z("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":z8?"true":"false","data-busy":L8?"true":"false","data-unseen":W8?"true":"false","aria-label":`Assistant${L8?" — working":W8?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:Q9,children:z(A9,{name:"sparkle",size:15})}),X0&&z(Gx,{center:X0}),z("button",{type:"button",className:"st-reportbug","data-testid":"report-bug-toggle","aria-label":"Report a bug","data-tip":"Report a bug",onClick:O,children:z(A9,{name:"bug",size:15})}),z("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":U0>0?"true":"false","aria-label":`What's new${U0>0?` — ${U0} unseen`:""}`,"data-tip":"What's new",onClick:f,children:z(A9,{name:"megaphone",size:15})}),z("span",{className:"st-stamp",children:S0}),z("span",{className:"st-mb-file",title:X||"",children:c0}),z("span",{className:"st-mb-sep"}),M("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[z("span",{className:"st-dot",style:{background:"var(--accent)"}}),H0," ARTBOARDS"]}),z("span",{className:"st-mb-sep"}),z("span",{className:"st-mb-proj",children:J||"maude"})]})]})}function U20({tabs:X,activePath:J,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:K,onIframeLoad:U,showQuickSetup:q,onStartQuickSetup:B,previewPath:N}){let F=u.useRef(null);return u.useEffect(()=>{if(N)F.current?.focus()},[N]),M("div",{className:"viewport st-stage","data-tour":"viewport",children:[N&&z("div",{ref:F,className:"st-file-preview-overlay",role:"region","aria-label":`Preview: ${pB(RK(N))}`,tabIndex:0,children:z(Lh,{path:N,kind:pR(RK(N))})}),X.length===0&&!N&&M("div",{className:"st-empty",children:[M("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"}),M("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(Z||"MAUDE").toUpperCase()," / v",dR," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),z("div",{className:"st-empty-title",children:"Nothing open yet"}),M("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(MX,{children:"⌘"})," and hover to preview an element, click to select it — ",z(MX,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",X9()?M(G0,{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]}),q&&z("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:B,children:"Start quick setup"})]}),X.map((D)=>{if(D.path===d8)return z("div",{className:"system-view"+(D.path===J?" active":""),children:z(O20,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},D.path);return z("iframe",{ref:(_)=>Q(D.path,_),src:Mz(D.path,H),className:D.path===J?"active":"","data-path":D.path,"data-testid":D.path===J?"canvas-frame":void 0,onLoad:()=>U?.(D.path),...H?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},D.path)}),K&&K===J&&z("div",{className:"st-canvas-loading","aria-hidden":"true",children:M("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%"}})]})})]})}var V20=["color","space","radius","shadow","leading","weight","motion","font","other"],q20={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function B20(X){return X==="color"}function N20({tokens:X,tokenGroups:J,tokensPath:Q}){if(!X||X.length===0)return M("section",{className:"sv-section sv-section-tokens",children:[M("h2",{children:["tokens",z("span",{className:"sv-h-num",children:"0"})]}),z("div",{className:"sv-empty",children:M("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=J||{},W=Array.from(new Set([...V20,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return z(G0,{children:W.map((G)=>{let Z=Y[G],H=B20(G);return M("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[M("h2",{children:["tokens · ",q20[G]||G,z("span",{className:"sv-h-num",children:Z.length})]}),z("div",{className:"sv-tokens-ladder",children:Z.map((K)=>M("div",{className:"sv-tok-cell",children:[H?z("div",{className:"sv-tok-swatch",style:{background:K.value}}):null,M("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 F20(X,J){let Q=X.name.match(/^--(?:type|fs|text)-(.+)$/);if(!Q)return null;let Y=Q[1];return(J||[]).find((W)=>/^--(?:lh|leading|line-height)-/.test(W.name)&&W.name.endsWith("-"+Y))?.value??null}function L20(X){if(!X?.length)return;let J=["body","sans","display","text","family"];for(let Q of J){let Y=X.find((W)=>W.name.includes(Q));if(Y)return Y.value}return X[0].value}function D20({tokenGroups:X}){let J=X?.fontsize||[];if(J.length===0)return null;let Q=X?.leading||[],Y=L20(X?.font);return M("section",{className:"sv-section sv-section-type",children:[M("h2",{children:["type · ladder",z("span",{className:"sv-h-num",children:J.length})]}),z("div",{className:"sv-type-list",children:J.map((W)=>{let G=F20(W,Q),Z={fontSize:W.value};if(G)Z.lineHeight=G;if(Y)Z.fontFamily=Y;return M("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 O20({data:X,onOpen:J,cfg:Q,onSelectDs:Y}){if(!X)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:q,availableDesignSystems:B}=X,N=(!W||!W.length)&&(!G||!G.length),F=Array.isArray(B)&&B.length>1,D=q?.name??B?.[0]?.name??"";return M("div",{className:"sv",children:[M("header",{className:"sv-header",children:[z("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),z("span",{className:"sv-title",children:"design system view"}),F?M("label",{className:"sv-ds-picker",children:[z("span",{className:"sv-ds-picker-label",children:"DS"}),z("select",{value:D,onChange:(_)=>Y&&Y(_.target.value),children:B.map((_)=>z("option",{value:_.name,children:_.name},_.name))})]}):null,z("span",{className:"sv-loc",children:z("code",{children:Z})})]}),q?.description?z("p",{className:"sv-ds-description",children:q.description}):null,z(N20,{tokens:H,tokenGroups:K,tokensPath:U}),z(D20,{tokenGroups:K}),N?z("div",{className:"sv-empty",children:M("p",{children:["No ",z("code",{children:"preview/"})," or ",z("code",{children:"ui_kits/"})," folders found under"," ",z("code",{children:Z}),"."]})}):M(G0,{children:[z(oe,{title:"preview",items:W,onOpen:J,kind:"preview",cfg:Q}),z(oe,{title:"ui kits",items:G,onOpen:J,kind:"ui_kits",cfg:Q})]})]})}function oe({title:X,items:J,onOpen:Q,kind:Y,cfg:W}){if(!J||J.length===0)return null;return M("section",{className:"sv-section",children:[M("h2",{children:[X," ",z("span",{className:"sv-count",children:J.length})]}),z("div",{className:"sv-previews sv-previews-"+Y,children:J.map((G)=>M("article",{className:"sv-preview-card",onClick:()=>Q(G.path),children:[z("div",{className:"sv-preview-frame",children:z("iframe",{src:Mz(G.path,W,{thumbnail:!0}),title:G.label,scrolling:"no",...W?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),M("div",{className:"sv-preview-foot",children:[z("strong",{children:G.label}),z("code",{children:G.path})]})]},G.path))})]})}function M20({activePath:X,selected:J,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,syncProject:K,syncOpen:U=!1,onOpenSync:q,changesCount:B=0,unpushed:N=0,savingIsManaged:F=!1,changesOpen:D=!1,onOpenChanges:_,version:R}){let w=X===d8,O=J&&J.selector?J.selector+(J.text?` — "${J.text.slice(0,60)}"`:""):"",P=J&&J.dom_path?J.dom_path.join(" > "):J?J.selector:"",I=W==="dark"?"light":"dark",k=(()=>{let C=Oz(H,{project:K});if(!C)return null;let y=C.names.length?` (${C.names.join(", ")})`:"";return{online:C.online,label:C.label,title:`${C.title}${y}${C.next?` — ${C.next}`:""}`}})(),$=k&&M(G0,{children:[z("span",{className:"st-sb-sync-dot"+(k.online?" is-online":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:"hub sync"}),z("span",{className:"val",title:k.title,children:k.label})]});return M("footer",{className:"st-statusbar",role:"contentinfo","data-testid":"statusbar",children:[M("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:X||"",children:w?"▦ design system":X||"—"})]}),X&&J&&J.selector&&!w&&M("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:P,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:"×"})]}),M("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[z("span",{className:"lbl",children:"comments"}),M("span",{className:"val",children:[Y," open"]})]}),_&&M("button",{type:"button",className:"st-sb-slot st-sb-changes"+(D?" is-open":"")+(B>0?" has-changes":N>0?" has-unpushed":""),onClick:_,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":D,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"}),M("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"})]}),k&&(q?z("button",{type:"button",className:"st-sb-slot st-sb-sync st-sb-sync--btn"+(U?" is-open":""),onClick:q,"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:$})),R&&z("span",{className:"st-sb-slot st-sb-version",role:"group","aria-label":"Maude version",children:M("span",{className:"val","data-testid":"statusbar-version",children:["v",R]})}),M("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${I} theme`,"data-tip-pos":"top","aria-label":`Switch to ${I} theme`,children:[z(A9,{name:W==="dark"?"sun":"moon",size:13}),I]})]})}function _20({commentsByFile:X,filter:J,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:K,width:U,resizing:q}){let B=V00(X),N=Object.keys(X||{}).sort(),F=[];for(let D of N){let _=X[D]||[],R=_.filter((O)=>{if(J==="open")return O.status!=="resolved";if(J==="resolved")return O.status==="resolved";return!0});if(R.length===0)continue;let w=_.filter((O)=>O.selector);F.push({file:D,comments:R.map((O)=>({...O,n:w.findIndex((P)=>P.id===O.id)+1}))})}return M("aside",{className:"st-rpanel"+(q?" 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:M("div",{className:"st-cm-filters",role:"tablist",children:[M("button",{type:"button",className:"st-cm-filter"+(J==="all"?" is-active":""),role:"tab","aria-selected":J==="all",onClick:()=>Q("all"),children:["All · ",B.all]}),M("button",{type:"button",className:"st-cm-filter"+(J==="open"?" is-active":""),role:"tab","aria-selected":J==="open",onClick:()=>Q("open"),children:["Open · ",B.open]}),M("button",{type:"button",className:"st-cm-filter"+(J==="resolved"?" is-active":""),role:"tab","aria-selected":J==="resolved",onClick:()=>Q("resolved"),children:["Resolved · ",B.resolved]})]})}),z("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:F.length===0?M("div",{className:"st-rp-empty",children:[M("p",{children:["No comments ",J!=="all"?`with status “${J}”`:"yet","."]}),M("p",{children:["Open a canvas, hold ",z(MX,{children:"⌘"})," and click an element, then press ",z(MX,{children:"C"})," — or hold ",z(MX,{children:"⌘⇧"})," and click directly."]})]}):F.map((D)=>M(G0,{children:[M("button",{type:"button",className:"st-cm-group-hd",onClick:()=>G(D.file,null),title:D.file,children:[z("span",{children:gW(RK(D.file))}),z("span",{className:"st-mono",children:D.comments.length})]}),D.comments.map((_)=>M("div",{className:"st-comment"+(_.status==="resolved"?" is-resolved":"")+(_.id===W?" is-active":""),onClick:()=>G(D.file,_.id),children:[M("div",{className:"st-comment-hd",children:[z("span",{className:"st-pin st-pin--inline",children:_.n||"·"}),z("span",{className:"st-comment-time",children:fq0(_.created)})]}),z("div",{className:"st-comment-txt",children:_.text}),M("div",{className:"st-comment-foot",children:[z("span",{className:"st-comment-sel",title:(_.dom_path||[]).join(" > "),children:_.selector||"—"}),Z&&H&&K?M("span",{className:"st-mini-act",children:[_.status==="resolved"?z("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(R)=>{R.stopPropagation(),H(_.id)},children:z(A9,{name:"reopen",size:14})}):z("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(R)=>{R.stopPropagation(),Z(_.id)},children:z(A9,{name:"resolve",size:14})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(R)=>{R.stopPropagation(),K(_.id)},children:z(A9,{name:"x",size:14})})]}):null]})]},_.id))]},D.file))})]})}var A20={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 w20({cloud:X}){let J=X?.role||null,[Q,Y]=u.useState(!1);if(!J||Q)return null;let W=`maude-cloud-role-seen:${J}`,G=!1;try{G=localStorage.getItem(W)==="1"}catch{}if(G)return null;let Z=A20[J];if(!Z)return null;return M("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 E20({update:X,onDismiss:J}){let[Q,Y]=u.useState(!1);if(!X)return null;let W=X.version?` (v${X.version})`:"";return M("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),M("span",{children:["Maude updated",W," · restart to apply"]}),z("button",{type:"button",className:"btn btn--primary btn--sm",disabled:Q,onClick:()=>{Y(!0),Cv().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:J,children:"Later"})]})}function P20({status:X}){let[J,Q]=u.useState(null);if(!X||X.linked===!1)return null;if(X.notSyncable)return null;let{state:Y,queuedOps:W,flash:G,conflicts:Z}=X,H=G==="synced",K=Y==="offline"||Y==="offline-long",U=X.docs?.rejected??0,q=Array.isArray(Z)?[...Z].reverse().find((D)=>D.kind==="cold-start-diverged"):null;if(!K&&!H&&!q&&U===0)return null;let B,N,F;if(H)B="success",N="Synced with hub",F=`${Y}:flash`;else if(K){let D=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.${D}`;else B="warn",N=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${D}`;F=`${Y}:offline`}else if(q){if(q.snapshotFailed)B="error",N=`Diverged on ${q.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 ${q.slug}: kept the ${q.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${q.slug}`;F=`diverged:${q.slug}:${q.at}`}else B="warn",N=`${U} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,F=`rejected:${U}`;if(J===F)return null;return M("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 R20=["block","inline-block","flex","inline-flex","grid","inline","none"],ne=["px","%","fr","em","auto","min-content","max-content"];var T20=["auto","stretch","flex-start","center","flex-end","baseline"];var re=["300","400","500","600","700","800"],ae=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],se=["none","solid","dashed","dotted","double"],te=["px","rem","em","%","vw","vh","auto"],ee=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),uR={"font-size":{node:z(Y7,{as:sU,size:12})},"line-height":{node:z(Y7,{as:WV,size:12})},"letter-spacing":{node:z(Y7,{as:BV,size:12})},gap:{node:z(Y7,{as:rz,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:z(Y7,{as:OV,size:12})},"border-width":{node:z(Y7,{as:qV,size:12})}};var X00=["static","relative","absolute","fixed","sticky"],I20=["normal","italic","oblique"],J00=["none","uppercase","lowercase","capitalize"];var Q00=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],k20=["fill","contain","cover","none","scale-down"];var Y00=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],W00=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],O5={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}},EK=null;function MF(X){if(!X)return"";if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();try{if(!EK)EK=document.createElement("canvas").getContext("2d");if(!EK)return"";EK.fillStyle="#000000",EK.fillStyle=X;let J=EK.fillStyle;if(/^#[0-9a-f]{6}$/i.test(J))return J.toLowerCase();let Q=J.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=(X)=>Math.min(1,Math.max(0,X));function BF(X){let J=/^#?([0-9a-f]{6})$/i.exec(X||"");if(!J)return{r:0,g:0,b:0};let Q=Number.parseInt(J[1],16);return{r:Q>>16&255,g:Q>>8&255,b:Q&255}}function k3({r:X,g:J,b:Q}){return`#${[X,J,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function C3({r:X,g:J,b:Q}){X/=255,J/=255,Q/=255;let Y=Math.max(X,J,Q),W=Math.min(X,J,Q),G=Y-W,Z=0;if(G){if(Y===X)Z=(J-Q)/G%6;else if(Y===J)Z=(Q-X)/G+2;else Z=(X-J)/G+4;if(Z*=60,Z<0)Z+=360}return{h:Z,s:Y?G/Y:0,v:Y}}function PK({h:X,s:J,v:Q}){let Y=Q*J,W=Y*(1-Math.abs(X/60%2-1)),G=Q-Y,Z=0,H=0,K=0;if(X<60)[Z,H,K]=[Y,W,0];else if(X<120)[Z,H,K]=[W,Y,0];else if(X<180)[Z,H,K]=[0,Y,W];else if(X<240)[Z,H,K]=[0,W,Y];else if(X<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 Z7(X){if(!X)return"";let J=/^(-?\d*\.?\d+)px$/.exec(X);return J?`${Math.round(Number.parseFloat(J[1]))}px`:X}function fQ(X){if(!X)return{n:"",unit:"px"};let J=X.trim(),Q=/^(-?\d*\.?\d+)\s*(px|rem|em|%|vw|vh)?$/.exec(J);if(Q)return{n:Q[1],unit:Q[2]||"px"};if(J==="auto")return{n:"",unit:"auto"};return{n:J,unit:""}}function G00(X,J){if(!X||Array.isArray(X)||Array.isArray(J)||!J)return X;if(!X.id&&!J.id){let Q=(Y)=>typeof Y.selector==="string"&&Y.selector.startsWith("[data-dc-screen=");if(Q(X)&&Q(J)&&X.selector===J.selector&&X.file===J.file)return{...X,authored:X.authored??J.authored,computed:X.computed??J.computed,customStyles:X.customStyles??J.customStyles,attrs:X.attrs??J.attrs,artboardId:X.artboardId??J.artboardId,worldW:X.worldW??J.worldW,worldH:X.worldH??J.worldH};return X}if(!X.id||X.id!==J.id)return X;return{...X,authored:X.authored??J.authored,computed:X.computed??J.computed,customStyles:X.customStyles??J.customStyles,attrs:X.attrs??J.attrs,photoKind:X.photoKind??J.photoKind,photoAsset:X.photoAsset??J.photoAsset}}function N00(X,J){return(X?J?.canvasDesignSystems?.[X]:null)||J?.defaultDesignSystem||J?.designSystems?.[0]?.name||null}function C20(X){let J={};for(let Z of X.matchAll(/(--[a-z0-9-]+)\s*:\s*([^;}]+)/gi))if(!(Z[1]in J))J[Z[1]]=Z[2].trim();let Q={};for(let Z of Object.keys(J)){let H=J[Z],K=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(H);Q[Z]=K&&J[K[1]]?J[K[1]]:H}let Y=Object.keys(J),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 F00(X,J,Q){let Y=X?.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(`/${J}/${K.tokensCssRel}`),q=U.ok?await U.text():"";return{name:K.name,...C20(q)}}catch{return null}})).then((K)=>{if(H)return;let U=K.filter(Boolean);U.sort((q,B)=>q.name===Q?-1:B.name===Q?1:0),Z(U)}),()=>{H=!0}},[W,J,Q]),G}function L00({seed:X,label:J,onApply:Q}){let[Y,W]=u.useState(()=>C3(BF(X||"#000000"))),G=u.useRef(Y);G.current=Y;let Z=u.useRef(null),H=u.useRef(null),K=u.useRef(X);u.useEffect(()=>{if(X&&X!==K.current)K.current=X,W(C3(BF(X)))},[X]);let U=k3(PK(Y)),q=(O)=>{O.preventDefault();let P=Z.current?.getBoundingClientRect();if(!P)return;let I=G.current.h,k=(C)=>{W({h:I,s:uY((C.clientX-P.left)/P.width),v:uY(1-(C.clientY-P.top)/P.height)})};k(O);let $=()=>{document.removeEventListener("pointermove",k),document.removeEventListener("pointerup",$),Q(k3(PK(G.current)))};document.addEventListener("pointermove",k),document.addEventListener("pointerup",$)},B=(O)=>{O.preventDefault();let P=H.current?.getBoundingClientRect();if(!P)return;let{s:I,v:k}=G.current,$=(y)=>{W({h:uY((y.clientX-P.left)/P.width)*360,s:I,v:k})};$(O);let C=()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",C),Q(k3(PK(G.current)))};document.addEventListener("pointermove",$),document.addEventListener("pointerup",C)},N=(O)=>{let P={...G.current,...O};W(P),Q(k3(PK(P)))},F=(O)=>{let P=O.shiftKey?0.1:0.02,k={ArrowLeft:[-P,0],ArrowRight:[P,0],ArrowUp:[0,P],ArrowDown:[0,-P]}[O.key];if(!k)return;O.preventDefault(),N({s:uY(G.current.s+k[0]),v:uY(G.current.v+k[1])})},D=(O)=>{let P=O.shiftKey?20:2,k={ArrowLeft:-P,ArrowRight:P}[O.key];if(k==null)return;O.preventDefault(),N({h:Math.min(360,Math.max(0,G.current.h+k))})},_=async()=>{try{let O=window.EyeDropper;if(!O)return;let P=await new O().open();if(P?.sRGBHex)W(C3(BF(P.sRGBHex))),Q(P.sRGBHex)}catch{}},R=PK(Y),w=(O)=>{let P={...R,...O},I=C3({r:uY(P.r/255)*255,g:uY(P.g/255)*255,b:uY(P.b/255)*255});W(I),Q(k3(PK(I)))};return M("div",{className:"st-cp-cpick",children:[M("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":J?`${J} hex value`:"hex value",onChange:(O)=>{let P=O.target.value;if(/^#?[0-9a-f]{6}$/i.test(P))W(C3(BF(P)))},onKeyDown:(O)=>{if(O.key==="Enter")Q(O.currentTarget.value)},onBlur:(O)=>Q(O.currentTarget.value),onFocus:(O)=>O.currentTarget.select()})]}),M("button",{type:"button",ref:Z,className:"st-cp-cpick-sv","aria-label":J?`${J} saturation and value`:"saturation and value",style:{background:`hsl(${Y.h} 100% 50%)`},onPointerDown:q,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}})]}),M("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:_,children:z(A9,{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":J?`${J} hue`:"hue",onPointerDown:B,onKeyDown:D,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)=>M("label",{className:"st-cp-cpick-rgbf",children:[z("input",{"aria-label":O.toUpperCase(),value:Math.round(R[O]),onChange:(P)=>w({[O]:uY((Number.parseFloat(P.target.value)||0)/255)*255}),onFocus:(P)=>P.currentTarget.select()}),z("span",{children:O.toUpperCase()})]},O))})]})}function FF({kind:X,groups:J,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:K}){let[U,q]=u.useState(!1),[B,N]=u.useState(null),[F,D]=u.useState("custom"),[_,R]=u.useState(""),w=u.useRef(null),O=u.useRef(null),P=typeof Q==="string"&&/var\(\s*--/.test(Q),I=(n)=>Q===`var(${n})`,k=(n)=>n.replace(/^--/,"").replace(/-/g," "),$=J||[],C=$.reduce((n,c)=>n+(c.names?.length||0),0),y=$.length>1,v=_.trim().toLowerCase(),h=!v?$:$.map((n)=>({...n,names:(n.names||[]).filter((c)=>k(c).toLowerCase().includes(v)||c.toLowerCase().includes(v)||(n.vals?.[c]||"").toLowerCase().includes(v))})).filter((n)=>n.names.length);u.useEffect(()=>{if(!U){R("");return}let n=()=>{let H0=w.current?.getBoundingClientRect();if(!H0)return;let r=224,D0=300,z0=Math.min(H0.right-r,window.innerWidth-r-8);if(z0<8)z0=8;let X8=window.innerHeight-H0.bottom>D0+8?H0.bottom+4:Math.max(8,H0.top-D0-4);N({left:z0,top:X8,width:r,maxHeight:D0})};n();let c=(H0)=>{if(O.current?.contains(H0.target)||w.current?.contains(H0.target))return;q(!1)},U0=(H0)=>{if(H0.key==="Escape")q(!1)},X0=(H0)=>{if(O.current?.contains(H0.target))return;n()};return document.addEventListener("pointerdown",c,!0),document.addEventListener("keydown",U0),window.addEventListener("resize",n),document.addEventListener("scroll",X0,!0),()=>{document.removeEventListener("pointerdown",c,!0),document.removeEventListener("keydown",U0),window.removeEventListener("resize",n),document.removeEventListener("scroll",X0,!0)}},[U]),u.useEffect(()=>{if(!U||!B||!O.current)return;let n=O.current.getBoundingClientRect(),c=B.left-n.left,U0=B.top-n.top;if(Math.abs(c)>0.5||Math.abs(U0)>0.5)N((X0)=>X0?{...X0,left:X0.left+c,top:X0.top+U0}:X0)},[U,B]);let l=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,o=(n,c,U0)=>{if(H&&n&&n!==H&&U0&&!l.test(U0))Y(U0);else Y(`var(${c})`);q(!1)},x=(n)=>{let c=(n||"").trim();if(c)Y(c)},m=M("div",{className:"st-cp-pop-search",children:[z(A9,{name:"search",size:12}),z("input",{value:_,onChange:(n)=>R(n.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),p=(n)=>n.map((c)=>M("div",{className:"st-cp-pop-group",children:[y?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((U0)=>M("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${I(U0)?" is-on":""}`,onClick:()=>o(c.ds,U0,c.vals?.[U0]),children:[z("span",{className:"st-cp-pop-cswatch",style:{background:c.vals?.[U0]||"transparent"},"aria-hidden":"true"}),z("span",{className:"st-cp-pop-name",children:k(U0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[U0]||""})]},`${c.ds}:${U0}`))})]},c.ds)),f=(n)=>n.map((c)=>M("div",{className:"st-cp-pop-group",children:[y?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((U0)=>M("button",{type:"button",className:`st-cp-pop-row${I(U0)?" is-on":""}`,onClick:()=>o(c.ds,U0,c.vals?.[U0]),children:[z("span",{className:"st-cp-pop-name",children:k(U0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[U0]||""})]},`${c.ds}:${U0}`))})]},c.ds)),s=z("div",{className:"st-cp-pop-empty",children:"No match"});return M(G0,{children:[G!==void 0?z("button",{type:"button",ref:w,className:`${K||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${P&&!K?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>q((n)=>!n),children:z("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):z("button",{type:"button",ref:w,className:`st-cp-tokbtn${P?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>q((n)=>!n),children:z("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),U&&B?H00.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:X==="color"?M(G0,{children:[M("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:()=>D("custom"),children:"Custom"}),z("button",{type:"button",role:"tab","aria-selected":F==="vars",className:`st-cp-poptab${F==="vars"?" is-active":""}`,onClick:()=>D("vars"),children:"Variables"})]}),F==="custom"?z(L00,{seed:Z||MF(Q)||"#000000",onApply:x}):!C?z("div",{className:"st-cp-pop-empty",children:"No color tokens"}):M(G0,{children:[m,h.length?p(h):s]})]}):!C?z("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):M(G0,{children:[m,h.length?f(h):s]})}),document.body):null]})}function Z00({label:X,tracks:J,editable:Q,onChange:Y}){let W=(K,U)=>{let q=J[K];Y(J.map((B,N)=>N===K?JU.has(U)?{value:0,unit:U}:{value:q.value||1,unit:U}:B))},G=(K,U)=>{Y(J.map((q,B)=>B===K?{...q,value:U}:q))},Z=()=>Y([...J,{value:1,unit:"fr"}]),H=(K)=>Y(J.filter((U,q)=>q!==K));return M("div",{className:"st-cp-gridtracks",children:[M("div",{className:"st-cp-gridtracks-hd",children:[z("span",{className:"st-cp-gridtracks-label",children:X}),z("button",{type:"button",className:"st-btn st-cp-gridtracks-add",disabled:!Q,onClick:Z,children:"+ Track"})]}),J.length===0?M("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",X.toLowerCase(),"."]}):J.map((K,U)=>{let q=JU.has(K.unit);return M("div",{className:"st-cp-gridtrack-row",children:[q?z(EW,{value:K.unit,ariaLabel:`${X} track ${U+1}`,options:ne.map((B)=>({value:B,label:B})),onChange:(B)=>W(U,B)}):z(JX,{value:K.value,min:K.unit==="fr"?0.1:0,step:K.unit==="fr"?0.1:1,ariaLabel:`${X} track ${U+1} value`,lead:String(U+1),unitSlot:z(nB,{value:K.unit,units:ne,ariaLabel:`${X} 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 ${X} track ${U+1}`,disabled:!Q||J.length<=1,onClick:()=>H(U),children:"×"})]},U)})]})}function $20({el:X,cfg:J,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let K=!!X.id,U=X.computed||{},[q,B]=u.useState({a:{},c:{},t:{}});u.useEffect(()=>{B({a:{},c:{},t:{}})},[X.id]);let N=(e,A0)=>{let q0={...e||{}};for(let[j0,n0]of Object.entries(A0))if(n0===null)delete q0[j0];else q0[j0]=n0;return q0},F=N(X.authored,q.a),D=N(X.customStyles,q.c),_=N(X.attrs,q.t),R=(e,A0)=>B((q0)=>({...q0,a:{...q0.a,[e]:A0}})),w=(e,A0)=>B((q0)=>({...q0,c:{...q0.c,[e]:A0}})),O=(e,A0)=>B((q0)=>({...q0,t:{...q0.t,[e]:A0}})),P=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),I=N00(X.file,J),k=F00(J,P,I),$=(e)=>k.map((A0)=>({ds:A0.name,names:A0[e]||[],vals:A0.vals})).filter((A0)=>A0.names.length),[C,y]=u.useState({}),[v,h]=u.useState({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),l=Object.keys(D).length>0||Object.keys(_).length>0;u.useEffect(()=>{if(l)h((e)=>e.Advanced?e:{...e,Advanced:!0})},[X.id,l]);let o=(F.position||Z7(U.position)||"static")!=="static";u.useEffect(()=>{if(o)h((e)=>e["d:Position"]?e:{...e,"d:Position":!0})},[X.id,o]);let x=H,[m,p]=u.useState({});async function f(e,A0,q0){y((j0)=>({...j0,[q0]:"saving"}));try{let j0=await fetch(e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(A0)}),n0=await j0.json().catch(()=>({}));y((y8)=>({...y8,[q0]:!j0.ok||!n0.ok?`err:${n0&&n0.error||`HTTP ${j0.status}`}`:"saved"}))}catch(j0){y((n0)=>({...n0,[q0]:`err:${j0&&j0.message?j0.message:String(j0)}`}))}}let s=(e,A0)=>{if(!Q||!X.id)return;Q({id:X.id,artboardId:X.artboardId??null,index:X.index??0,prop:e,value:A0})},n=(e,A0,q0,j0)=>{Y?.({op:e,canvas:X.file,id:X.id,key:A0,before:q0==null||q0===""?null:q0,after:j0==null||j0===""?null:j0})},c=(e,A0)=>{let q0=(A0||"").trim();if(!K||!q0)return;let j0=F[e]??null;if(q0===(j0??"").trim())return;s(e,q0),R(e,q0),f("/_api/edit-css",{canvas:X.file,id:X.id,property:e,value:q0},e),n("css",e,j0,q0)},U0=(e,A0)=>{let q0=(A0||"").trim(),j0=e.trim();if(!K||!j0||!q0)return;let n0=D[j0]??null;s(j0,q0),w(j0,q0),f("/_api/edit-css",{canvas:X.file,id:X.id,property:j0,value:q0},j0),n("css",j0,n0,q0)},X0=(e,A0)=>{let q0=(e||"").trim(),j0=(A0||"").trim();if(!K||!q0||!j0)return;let n0=_[q0]??null;O(q0,j0),f("/_api/edit-attr",{canvas:X.file,id:X.id,attr:q0,value:j0},`@${q0}`),n("attr",q0,n0,j0)},H0=(e)=>{if(!K)return;let A0=F[e]??null;s(e,null),R(e,null),f("/_api/edit-css",{canvas:X.file,id:X.id,property:e,reset:!0},e),n("css",e,A0,null)},r=(e)=>{if(!K)return;let A0=D[e]??null;s(e,null),w(e,null),f("/_api/edit-css",{canvas:X.file,id:X.id,property:e,reset:!0},e),n("css",e,A0,null)},D0=(e)=>{if(!K)return;let A0=_[e]??null;O(e,null),f("/_api/edit-attr",{canvas:X.file,id:X.id,attr:e,reset:!0},`@${e}`),n("attr",e,A0,null)},z0={display:X.parentDisplay,flexDirection:X.parentFlexDirection},l0=(e,A0)=>{if(!K)return;let q0=Math.round((e==="width"?X.bounds?.w:X.bounds?.h)||0),j0=e$(e,A0,z0,q0);for(let n0 of j0.reset)if(F[n0])H0(n0);for(let[n0,y8]of j0.set)c(n0,y8)},X8=X.parentDisplay==="flex"||X.parentDisplay==="inline-flex",d0=(e)=>{let A0=t$(e,F,U,z0);return M("div",{className:"st-cp-moderow",children:[z("span",{className:"st-cp-modelabel",children:e==="width"?"Width sizing":"Height sizing"}),z("div",{className:"st-cp-modeseg",role:"group","aria-label":`${e} sizing mode`,children:z(rB,{value:A0,ariaLabel:`${e} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(q0)=>l0(e,q0)})})]},`mode-${e}`)},$0=["flex-start","center","flex-end"],O0=["flex-start","center","flex-end"],i0=["t","c","b"],c8=["l","c","r"],z8=()=>{let e=!(F["flex-direction"]||Z7(U["flex-direction"])||"row").startsWith("column"),A0=Math.max(0,$0.indexOf(F["justify-content"]||Z7(U["justify-content"])||"flex-start")),q0=F["align-items"]||Z7(U["align-items"])||"stretch",j0=q0==="stretch"?1:Math.max(0,O0.indexOf(q0)),[n0,y8]=e?[A0,j0]:[j0,A0];return i0[y8]+c8[n0]},Q9=(e)=>{let A0=i0.indexOf(e[0]),q0=c8.indexOf(e[1]),j0=!(F["flex-direction"]||Z7(U["flex-direction"])||"row").startsWith("column"),[n0,y8]=j0?[q0,A0]:[A0,q0];c("justify-content",$0[n0]),c("align-items",O0[y8])},L8=(e)=>{if(!(e.metaKey||e.ctrlKey)||e.altKey)return;let A0=e.key.toLowerCase();if(A0==="z")e.preventDefault(),G?.(e.shiftKey?"redo":"undo");else if(A0==="y")e.preventDefault(),G?.("redo")},W8=(e)=>{let A0=F[e];if(!A0)return"inherit";return/var\(\s*--/.test(A0)?"bound":"raw"};if(!K)return M("div",{className:"st-cp",children:[z("div",{className:"st-cp-id",children:z("span",{className:"st-cp-idtag",children:X.tag||"element"})}),M("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 b8={bound:"token-bound",raw:"raw override",inherit:"inherited"},i8=(e)=>z("span",{className:`st-cp-prov st-cp-prov--${e}`,role:"img","aria-label":b8[e]}),p9=(e,A0)=>{let q0=A0??W8(e),j0=C[e],n0=typeof j0==="string"&&j0.startsWith("err:")?j0.slice(4):"",y8=n0?" is-err":j0==="saved"?" is-saved":j0==="saving"?" is-saving":"",S8=!!F[e],o8=n0?`error: ${n0}`:S8?`${b8[q0]} · double-click to reset`:b8[q0];return z("button",{type:"button",className:`st-cp-prov st-cp-prov--${q0}${y8}${S8?" is-resettable":""}`,"aria-label":o8,title:o8,tabIndex:S8?0:-1,onDoubleClick:S8?()=>H0(e):void 0,onKeyDown:S8?(e8)=>{if(e8.key==="Backspace"||e8.key==="Delete")e8.preventDefault(),H0(e)}:void 0})},M0=(e,A0,q0,j0)=>{let n0=q0===void 0&&!F[e],y8=j0??e;return M("div",{className:`st-cp-row${n0?" is-unset":""}`,children:[p9(e,q0),z("label",{className:"st-cp-label",title:y8,children:y8}),z("div",{className:"st-cp-ctl",children:A0})]},e)},j8={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"]},L9=(e)=>{(j8[e]||[]).forEach((A0)=>{if(F[A0])H0(A0)})},U8=(e,A0)=>{let q0=(j8[e]||[]).some((j0)=>F[j0]);return M("section",{className:"st-cp-sec",children:[M("div",{className:"st-cp-sechd-row",children:[M("button",{type:"button",className:"st-cp-sechd","aria-expanded":!!v[e],onClick:()=>h((j0)=>({...j0,[e]:!j0[e]})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:v[e]?"▾":"▸"}),e]}),z("button",{type:"button",className:`st-cp-secreset${q0?"":" is-quiet"}`,"aria-label":`reset ${e} section to original`,title:`reset ${e}`,disabled:!q0,onClick:()=>L9(e),children:z(Y7,{as:MZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${v[e]?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:A0})})]},e)},D9=(e,A0,q0,j0=!0)=>{let n0=`d:${e}`,y8=v[n0]===void 0?j0:v[n0],S8=A0.some((o8)=>F[o8]);return M("section",{className:"st-cp-sec",children:[M("div",{className:"st-cp-sechd-row",children:[M("button",{type:"button",className:"st-cp-sechd","aria-expanded":y8,onClick:()=>h((o8)=>({...o8,[n0]:!y8})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:y8?"▾":"▸"}),e]}),z("button",{type:"button",className:`st-cp-secreset${S8?"":" is-quiet"}`,"aria-label":`reset ${e} to original`,title:`reset ${e}`,disabled:!S8,onClick:()=>A0.forEach((o8)=>{if(F[o8])H0(o8)}),children:z(Y7,{as:MZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${y8?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:q0})})]},n0)},y0=(e)=>z("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!m[e],"aria-label":m[e]?`${e} — fewer options`:`${e} — more options`,title:m[e]?"fewer":"more",onClick:()=>p((A0)=>({...A0,[e]:!A0[e]})),children:m[e]?"▴":"···"}),Z0=(e,A0)=>M("select",{className:"st-cp-nsel","aria-label":e,value:A0.includes(F[e])?F[e]:"",onChange:(q0)=>c(e,q0.target.value),children:[z("option",{value:"",disabled:!0,children:Z7(U[e])||"—"}),A0.map((q0)=>z("option",{value:q0,children:q0},q0))]}),S0=(e)=>$(e).flatMap((A0)=>(A0.names||[]).map((q0)=>({name:q0,value:A0.vals?.[q0]||""}))),c0=(e,A0)=>z(wA,{value:F[e]||Z7(U[e])||A0[0].value,ariaLabel:e,options:A0,onChange:(q0)=>c(e,q0)}),q8=(e,A0,q0={})=>{let j0=fQ(F[e]??""),n0=ee.has(e),y8=F[e]??"",S8=typeof y8==="string"&&/var\(\s*--/.test(y8),o8=n0?"":j0.unit&&j0.unit!=="auto"?j0.unit:"px",e8=Number.parseFloat(fQ(Z7(U[e])??"").n)||0,P9=j0.n!==""&&j0.n!=null?Number.parseFloat(j0.n)||0:e8,V7=uR[e];return z(aB,{value:S8?y8:P9,tokens:S0(A0),ariaLabel:e,min:q0.min??0,lead:V7?V7.node??V7.t:void 0,unitSlot:n0?null:z(nB,{units:te,value:j0.unit||"px",ariaLabel:`${e} unit`,onChange:(h9)=>c(e,h9==="auto"?"auto":`${j0.n||"0"}${h9}`)}),onChange:(h9)=>c(e,typeof h9==="string"?h9:n0?`${h9}`:`${h9}${o8}`)})},N8=()=>{let e=(n0)=>Number.parseFloat(fQ(F[n0]??F["border-radius"]??Z7(U[n0])??Z7(U["border-radius"])??"0").n)||0,A0={tl:e("border-top-left-radius"),tr:e("border-top-right-radius"),bl:e("border-bottom-left-radius"),br:e("border-bottom-right-radius")},q0=(n0)=>{if(n0.tl===n0.tr&&n0.tr===n0.bl&&n0.bl===n0.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((S8)=>{if(F[S8])H0(S8)}),c("border-radius",`${n0.tl}px`);else c("border-top-left-radius",`${n0.tl}px`),c("border-top-right-radius",`${n0.tr}px`),c("border-bottom-left-radius",`${n0.bl}px`),c("border-bottom-right-radius",`${n0.br}px`)},j0=uR["border-radius"];return z(Th,{corners:A0,lead:j0?j0.node??j0.t:void 0,onCorners:q0})},H8=()=>M("div",{className:"st-cp-border",children:[w9("border-width",null,{fixedUnit:"px"}),M("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:se.includes(F["border-style"])?F["border-style"]:"",onChange:(e)=>c("border-style",e.target.value),children:[z("option",{value:"",disabled:!0,children:"style"}),se.map((e)=>z("option",{value:e,children:e},e))]}),z(FF,{kind:"color",groups:$("color"),current:F["border-color"],activeDs:I,swatchBg:U["border-color"]||F["border-color"]||"",seedHex:MF(U["border-color"]||F["border-color"])||"#000000",onPick:(e)=>c("border-color",e),label:"border colour"})]}),m0=()=>{let e=F.transform||Z7(U.transform)||"",A0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(e),q0=((A0?Number.parseFloat(A0[1]):0)%360+360)%360,j0=(n0)=>{let y8=(n0%360+360)%360,S8=(F.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();c("transform",`${S8?`${S8} `:""}rotate(${y8}deg)`.trim())};return M("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[z(Ph,{value:q0,onChange:j0}),z(JX,{value:q0,min:0,max:360,ariaLabel:"rotation",lead:z(Y7,{as:MZ}),steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:j0})]})},w0=()=>{let e=F.filter||Z7(U.filter)||"",A0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(e),q0=A0?Number.parseFloat(A0[1]):0;return z(JX,{value:q0,min:0,ariaLabel:"filter blur",unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(n0)=>{let y8=(F.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();c("filter",n0>0?`${y8?`${y8} `:""}blur(${n0}px)`.trim():y8||"none")}})},K8=()=>{let e=F.opacity,A0=e!=null&&e!==""?Number.parseFloat(e):Number.parseFloat(Z7(U.opacity))||1,q0=Math.round((Number.isNaN(A0)?1:A0)*100);return z(CJ,{value:q0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(j0)=>s("opacity",String(j0/100)),onCommit:(j0)=>c("opacity",String(j0/100))},`opacity:${e??""}`)},I8=()=>{let e=Number.parseInt(F["font-weight"]||Z7(U["font-weight"])||"400",10)>=600,A0=(F["font-style"]||Z7(U["font-style"]))==="italic",q0=/underline/.test(F["text-decoration"]||Z7(U["text-decoration"])||"");return z(wh,{value:{b:e,i:A0,u:q0},ariaLabel:"text style",options:[{value:"b",node:z(Y7,{as:GV}),label:"Bold"},{value:"i",node:z(Y7,{as:UV}),label:"Italic"},{value:"u",node:z(Y7,{as:AV}),label:"Underline"}],onToggle:(j0)=>{if(j0==="b")c("font-weight",e?"400":"700");else if(j0==="i")c("font-style",A0?"normal":"italic");else c("text-decoration",q0?"none":"underline")}})},k8=[{value:"row",node:z(Y7,{as:BW}),label:"Row"},{value:"column",node:z(Y7,{as:NW}),label:"Column"}],_9=[{value:"flex-start",node:z(Y7,{as:XV}),label:"Start"},{value:"center",node:z(Y7,{as:tU}),label:"Center"},{value:"flex-end",node:z(Y7,{as:eU}),label:"End"},{value:"space-between",node:z(Y7,{as:rz}),label:"Space between"}],A8=[{value:"flex-start",node:z(Y7,{as:YV}),label:"Start"},{value:"center",node:z(Y7,{as:JV}),label:"Center"},{value:"flex-end",node:z(Y7,{as:QV}),label:"End"},{value:"stretch",node:z(Y7,{as:MV}),label:"Stretch"}],T9=[{value:"left",node:z(Y7,{as:v5}),label:"Left"},{value:"center",node:z(Y7,{as:DW}),label:"Center"},{value:"right",node:z(Y7,{as:OW}),label:"Right"},{value:"justify",node:z(Y7,{as:MW}),label:"Justify"}],Y9=[{value:"visible",node:z(Y7,{as:OZ}),label:"Visible"},{value:"hidden",node:z(Y7,{as:_Z}),label:"Hidden"},{value:"scroll",node:z(Y7,{as:LV}),label:"Scroll"}],b7=(e,A0)=>{let q0=$(A0);return q0.length?z(FF,{kind:"value",groups:q0,current:F[e],activeDs:I,onPick:(j0)=>c(e,j0),label:`${e} design token`}):null},E0=(e)=>{let A0=e.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===A0)A0.select()})},f8=(e,A0)=>{if(e.key!=="ArrowUp"&&e.key!=="ArrowDown")return!1;e.preventDefault();let q0=e.shiftKey?10:1,j0=e.key==="ArrowUp"?1:-1,n0=(Number.parseFloat(e.currentTarget.value)||0)+j0*q0;return e.currentTarget.value=String(n0),A0(n0),!0},v9=(e)=>z("input",{className:"st-cp-fin","aria-label":e,defaultValue:F[e]??"",placeholder:Z7(U[e])||"—",onFocus:E0,onKeyDown:(A0)=>{if(A0.key==="Enter")A0.currentTarget.blur()},onBlur:(A0)=>c(e,A0.currentTarget.value)},`${e}:${F[e]??""}`),w9=(e,A0,q0={})=>{let j0=fQ(F[e]??""),n0=ee.has(e),y8=n0?"":q0.fixedUnit||(j0.unit&&j0.unit!=="auto"?j0.unit:"px"),S8=uR[e],o8=Number.parseFloat(fQ(Z7(U[e])??"").n)||0,e8=j0.n!==""&&j0.n!=null?Number.parseFloat(j0.n)||0:o8;return M(G0,{children:[z(JX,{value:e8,min:q0.min??0,step:1,ariaLabel:e,lead:S8?S8.node??S8.t:void 0,onCommit:(P9)=>c(e,n0?`${P9}`:`${P9}${y8}`),unitSlot:n0||q0.fixedUnit?null:z(nB,{units:te,value:j0.unit||"px",ariaLabel:`${e} unit`,onChange:(P9)=>c(e,P9==="auto"?"auto":`${j0.n||"0"}${P9}`)})},`${e}:${F[e]??""}`),b7(e,A0)]})},G6=(e)=>{let A0=U[e]||F[e]||"",q0=F[e]??"",j0=typeof q0==="string"&&/var\(\s*--/.test(q0),n0=j0?q0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):q0;return z(EV,{swatch:z(FF,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:$("color"),current:F[e],activeDs:I,swatchBg:A0,seedHex:MF(U[e]||F[e])||"#000000",onPick:(y8)=>c(e,y8),label:`${e} colour`}),displayValue:n0,bound:j0,ariaLabel:e,onValue:(y8)=>c(e,y8)})},_6=(e,A0)=>{let q0=null,j0=A0.unitless?"":"px",n0=(o8)=>A0.unitless?`${o8}`:`${o8}${j0}`,y8=(o8,e8,P9)=>{for(let V7 of e8??[e])P9(V7,n0(o8))},S8=AA({getBase:()=>q0?.value??"0",min:A0.min??0,step:1,sides:A0.sides,onInput:(o8,e8)=>{if(q0)q0.value=String(o8);if(e8){let P9=q0?.closest(".st-cp-box");for(let V7 of e8){if(V7===e)continue;let h9=P9?.querySelector(`.st-cp-boxv[aria-label="${V7}"]`);if(h9)h9.value=String(o8)}}y8(o8,e8,s)},onCommit:(o8,e8)=>y8(o8,e8,c)});return{onPointerDown:(o8)=>{q0=o8.currentTarget,S8(o8)}}},g8=(e,A0)=>{let q0=F[e],j0=q0!=null&&q0!==""?fQ(q0).n||q0:fQ(Z7(U[e])??"").n||"0",n0=!q0||q0==="0"||q0==="0px"||q0==="auto",y8=e.split("-").pop(),S8=y8==="top"||y8==="bottom"?[`${A0}-top`,`${A0}-bottom`]:[`${A0}-left`,`${A0}-right`],o8=[`${A0}-top`,`${A0}-right`,`${A0}-bottom`,`${A0}-left`];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${A0[0]}${e.split("-").pop()[0]}${n0?" is-zero":""}`,"aria-label":e,defaultValue:j0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",..._6(e,{sides:{pair:S8,all:o8}}),onFocus:E0,onKeyDown:(e8)=>{if(f8(e8,(P9)=>c(e,`${P9}px`)))return;if(e8.key==="Enter")e8.currentTarget.blur()},onBlur:(e8)=>{let P9=e8.currentTarget.value.trim();if(!P9)return;let V7=/[a-z%]/i.test(P9)?P9:`${P9}px`;c(e,V7)}},`${e}:${q0??""}`)},s9=(e)=>{let A0=F[e],q0=A0!=null&&A0!==""&&A0!=="auto"?fQ(A0).n||A0:fQ(Z7(U[e])??"").n||"",j0=!A0||A0==="auto"||A0==="0"||A0==="0px",n0=e==="top"||e==="bottom"?["top","bottom"]:["left","right"],y8=["top","right","bottom","left"];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${e[0]}${j0?" is-zero":""}`,"aria-label":e,defaultValue:q0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",..._6(e,{sides:{pair:n0,all:y8},min:-1/0}),onFocus:E0,onKeyDown:(S8)=>{if(f8(S8,(o8)=>c(e,`${o8}px`)))return;if(S8.key==="Enter")S8.currentTarget.blur()},onBlur:(S8)=>{let o8=S8.currentTarget.value.trim();if(!o8)return;let e8=/[a-z%]/i.test(o8)?o8:`${o8}px`;c(e,e8)}},`${e}:${A0??""}`)},m7=Object.entries(D),P7=Object.entries(_),E9=()=>{let e=(X.tag||"").toLowerCase(),q0=e==="img"||e==="video"||e==="picture"||e==="svg"||e==="canvas"||!!F["object-fit"]||!!F["object-position"]||!!F["aspect-ratio"],j0=(e==="img"||e==="video")&&!!X.attrs?.src&&!!W;return{showMedia:q0,canReplace:j0}},l6=(e)=>M(G0,{children:[e&&z("div",{className:"st-cp-mediabtn",children:z("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>W(X),children:"Replace…"})}),M0("object-fit",Z0("object-fit",k20)),M0("object-position",v9("object-position")),M0("aspect-ratio",M("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:W00.includes(F["aspect-ratio"])?F["aspect-ratio"]:"",onChange:(A0)=>{let q0=A0.target.value;if(c("aspect-ratio",q0),q0&&q0!=="auto"&&F.height)H0("height")},children:[z("option",{value:"",disabled:!0,children:Z7(U["aspect-ratio"])||"—"}),W00.map((A0)=>z("option",{value:A0,children:A0},A0))]}))]});return M("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:L8,children:[M("div",{className:"st-cp-id",children:[M("span",{className:"st-cp-idtag",children:[X.tag||"element",X.classes?M("span",{className:"st-cp-idcls",children:[".",X.classes.split(/\s+/)[0]]}):null]}),z("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:z(wA,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:z(Y7,{as:qW,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:z(Y7,{as:_W,size:12}),label:"Designer — Figma vocabulary"}],onChange:x})})]}),Z==="designer"?M(G0,{children:[D9("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let e=(F.display||Z7(U.display)||"").trim();return e==="flex"||e==="inline-flex"?M(G0,{children:[M0("flex-direction",c0("flex-direction",k8),void 0,"Direction"),M0("align-items",z(Eh,{value:z8(),onChange:Q9,ariaLabel:"auto-layout alignment"}),W8("align-items"),"Alignment"),M0("gap",q8("gap","space"),void 0,"Gap"),M("div",{className:"st-cp-modes",children:[d0("width"),d0("height")]}),M("div",{className:"st-cp-box","aria-label":"padding",children:[M("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[i8(W8("padding-top")),"padding"]}),g8("padding-top","padding"),g8("padding-right","padding"),g8("padding-bottom","padding"),g8("padding-left","padding")]}),z("div",{className:"st-cp-clustermore-row",children:y0("Auto layout")}),m["Auto layout"]?M0("flex-wrap",z(CQ,{checked:/^wrap/.test(F["flex-wrap"]||Z7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(q0)=>c("flex-wrap",q0?"wrap":"nowrap")}),W8("flex-wrap"),"Wrap"):null]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>c("display","flex"),children:"+ Auto layout (flex)"})})()),D9("Size",["width","height","min-width","max-width","min-height","max-height"],M(G0,{children:[M0("width",w9("width"),void 0,"Width"),M0("height",w9("height"),void 0,"Height"),z("div",{className:"st-cp-clustermore-row",children:y0("Size")}),m.Size?M(G0,{children:[M0("min-width",w9("min-width"),void 0,"Min width"),M0("max-width",w9("max-width"),void 0,"Max width"),M0("min-height",w9("min-height"),void 0,"Min height"),M0("max-height",w9("max-height"),void 0,"Max height")]}):null]})),D9("Position",["position","top","right","bottom","left","z-index"],M(G0,{children:[M0("position",Z0("position",X00),void 0,"Position"),M("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[M("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[i8(W8("top")),"inset"]}),s9("top"),s9("right"),s9("bottom"),s9("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||Z7(U.position)||"static"})]}),(F.position||Z7(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:y0("Position")}),m.Position?M0("z-index",w9("z-index"),void 0,"Layer order"):null]}),!1),D9("Fill",["background-color"],M0("background-color",G6("background-color"),void 0,"Fill")),D9("Stroke",["border-width","border-style","border-color"],M0("border",H8(),W8("border-width"),"Stroke")),D9("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],M0("border-radius",N8(),W8("border-radius"),"Corner radius")),D9("Effects",["box-shadow","filter","mix-blend-mode"],M(G0,{children:[M0("box-shadow",b7("box-shadow","shadow")||v9("box-shadow"),void 0,"Shadow"),M0("filter",w0(),W8("filter"),"Blur"),M0("mix-blend-mode",Z0("mix-blend-mode",Y00),void 0,"Blend")]})),D9("Opacity",["opacity"],M0("opacity",K8(),void 0,"Opacity")),D9("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],M(G0,{children:[M0("font-family",Z0("font-family",ae),void 0,"Font"),M0("color",G6("color"),void 0,"Color"),M0("font-size",q8("font-size","type"),void 0,"Size"),M0("font-weight",Z0("font-weight",re),void 0,"Weight"),M0("line-height",w9("line-height","lh"),void 0,"Line height"),M0("text-align",c0("text-align",T9),void 0,"Align"),z("div",{className:"st-cp-clustermore-row",children:y0("Text")}),m.Text?M(G0,{children:[M0("letter-spacing",w9("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),M0("font-style",Z0("font-style",I20),void 0,"Style"),M0("text-transform",Z0("text-transform",J00),void 0,"Case"),M0("white-space",Z0("white-space",Q00),void 0,"Whitespace")]}):null]})),D9("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],M("div",{className:"st-cp-box","aria-label":"margin",children:[M("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[i8(W8("margin-top")),"margin"]}),g8("margin-top","margin"),g8("margin-right","margin"),g8("margin-bottom","margin"),g8("margin-left","margin")]})),(()=>{let{showMedia:e,canReplace:A0}=E9();return e?D9("Media",["object-fit","object-position","aspect-ratio"],l6(A0)):null})()]}):M(G0,{children:[U8("Layout",(()=>{let e=(F.display||Z7(U.display)||"").trim(),A0=e==="flex"||e==="inline-flex",q0=e==="grid"||e==="inline-grid";return M(G0,{children:[M0("display",Z0("display",R20)),A0?M(G0,{children:[M0("flex-direction",c0("flex-direction",k8)),M0("flex-wrap",z(CQ,{checked:/^wrap/.test(F["flex-wrap"]||Z7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(j0)=>c("flex-wrap",j0?"wrap":"nowrap")}),W8("flex-wrap"))]}):null,A0||q0?M(G0,{children:[M0("align-items",c0("align-items",A8)),M0("justify-content",c0("justify-content",_9)),M0("gap",q8("gap","space"))]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>c("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let e=(F.display||Z7(U.display)||"").trim();if(!(e==="grid"||e==="inline-grid"))return null;let q0=F["grid-template-columns"]||"",j0=F["grid-template-rows"]||"",n0=PO(q0),y8=PO(j0),S8=n0.length>0||!q0.trim(),o8=y8.length>0||!j0.trim();return U8("Grid",M(G0,{children:[S8?z(Z00,{label:"Columns",tracks:n0,editable:K,onChange:(e8)=>c("grid-template-columns",RO(e8))}):M("div",{className:"st-cp-note",children:["Columns use ",z("code",{children:q0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),o8?z(Z00,{label:"Rows",tracks:y8,editable:K,onChange:(e8)=>c("grid-template-rows",RO(e8))}):M("div",{className:"st-cp-note",children:["Rows use ",z("code",{children:j0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),U8("Position",M(G0,{children:[M0("position",Z0("position",X00)),M("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[M("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[i8(W8("top")),"inset"]}),s9("top"),s9("right"),s9("bottom"),s9("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||Z7(U.position)||"static"})]}),(F.position||Z7(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,M0("z-index",w9("z-index"))]})),(X.parentDisplay==="grid"||X.parentDisplay==="inline-grid")&&U8("Grid item",M(G0,{children:[M("div",{className:"st-cp-note",children:["Manual cell placement — ",z("code",{children:"start / end"})," or ",z("code",{children:"start / span N"}),"."]}),M0("grid-column",v9("grid-column")),M0("grid-row",v9("grid-row"))]})),U8("Typography",M(G0,{children:[M0("font-family",Z0("font-family",ae)),M0("color",G6("color")),M0("font-size",q8("font-size","type")),M0("font-weight",Z0("font-weight",re)),M0("line-height",w9("line-height","lh")),M0("letter-spacing",w9("letter-spacing",null,{min:-1/0})),M0("text-align",c0("text-align",T9)),M0("font-style",I8(),W8("font-style")),M0("text-transform",Z0("text-transform",J00)),M0("white-space",Z0("white-space",Q00))]})),U8("Spacing",z(G0,{children:M("div",{className:"st-cp-box","aria-label":"margin and padding",children:[M("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[i8(W8("margin-top")),"margin"]}),g8("margin-top","margin"),g8("margin-right","margin"),g8("margin-bottom","margin"),g8("margin-left","margin"),M("div",{className:"st-cp-boxpad",children:[M("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[i8(W8("padding-top")),"padding"]}),g8("padding-top","padding"),g8("padding-right","padding"),g8("padding-bottom","padding"),g8("padding-left","padding"),M("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(F.width)||X.bounds?.w||0)," × ",Math.round(Number.parseFloat(F.height)||X.bounds?.h||0)]})]})]})})),U8("Size",M(G0,{children:[M("div",{className:"st-cp-modes",children:[d0("width"),d0("height")]}),M0("width",w9("width")),M0("height",w9("height")),M0("min-width",w9("min-width")),M0("max-width",w9("max-width")),M0("min-height",w9("min-height")),M0("max-height",w9("max-height")),M0("overflow",c0("overflow",Y9)),X8?M(G0,{children:[z("div",{className:"st-cp-subhd",children:"In flex parent"}),M0("align-self",Z0("align-self",T20)),M0("flex-grow",w9("flex-grow",null,{unitless:!0})),M0("flex-shrink",w9("flex-shrink",null,{unitless:!0})),M0("flex-basis",w9("flex-basis"))]}):null]})),(()=>{let{showMedia:e,canReplace:A0}=E9();return e?U8("Media",l6(A0)):null})(),U8("Appearance",M(G0,{children:[M0("background-color",G6("background-color")),M0("border-radius",N8(),W8("border-radius")),M0("border",H8(),W8("border-width")),M0("box-shadow",b7("box-shadow","shadow")||v9("box-shadow")),M0("filter",w0(),W8("filter")),M0("mix-blend-mode",Z0("mix-blend-mode",Y00)),M0("opacity",K8()),M0("rotation",m0(),W8("transform")),M0("transform",v9("transform")),M0("transform-origin",v9("transform-origin"))]})),(()=>{let e=Object.entries(C).find(([,A0])=>typeof A0==="string"&&A0.startsWith("err:"));return e?M("div",{className:"st-cp-save is-err",role:"status",children:[z(A9,{name:"x",size:12}),e[0],": ",e[1].slice(4)]}):null})(),U8("Advanced",M("div",{className:"st-cp-advbody",children:[m7.length?M(G0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),m7.map(([e,A0])=>M("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:e,"aria-label":`custom property ${e} name`}),z("input",{className:"st-cp-fin",defaultValue:A0,"aria-label":`${e} value`,onKeyDown:(q0)=>{if(q0.key==="Enter")q0.currentTarget.blur()},onBlur:(q0)=>U0(e,q0.currentTarget.value)},`cs:${e}:${A0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${e}`,title:"remove",onClick:()=>r(e),children:z(A9,{name:"x",size:11})})]},`cs:${e}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add CSS property"}),z(S20,{commit:U0}),z("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),P7.length?M(G0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),P7.map(([e,A0])=>M("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:e,"aria-label":`attribute ${e} name`}),z("input",{className:"st-cp-fin",defaultValue:A0,"aria-label":`${e} value`,onKeyDown:(q0)=>{if(q0.key==="Enter")q0.currentTarget.blur()},onBlur:(q0)=>X0(e,q0.currentTarget.value)},`at:${e}:${A0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${e}`,title:"remove",onClick:()=>D0(e),children:z(A9,{name:"x",size:11})})]},`at:${e}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),z(b20,{commit:X0})]}))]}),M("div",{className:"st-cp-legend",children:[M("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),M("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),M("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},X.id)}function S20({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return M("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom property name",placeholder:"property",value:J,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 b20({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return M("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom attribute name",placeholder:"data-…",value:J,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 y20={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function j20(X,J,Q,Y){if(!Array.isArray(X)||J===Q)return X;let W=JSON.parse(JSON.stringify(X)),G=null,Z=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===J)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 X;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:X}var f20=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function D00({node:X,depth:J,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:q,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:D,onToggleLock:_,onRename:R}){let w=`${X.id}:${X.index}`,O=X.children&&X.children.length>0,P=W.has(w),I=!!X.synthetic,k=!I&&F?F[X.id]:null,$=!I&&!!D?.has(w),[C,y]=u.useState(!1),[v,h]=u.useState(""),l=!I&&X.id===Q&&(Y==null||X.index===Y),o=G?.has(w)?G.get(w):!!X.hidden,x=!!q&&!I&&!$,m=()=>{y(!1);let s=v.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!s||s===(X.dcElement??""))return;R?.(X,s)},p=N?.key===w,f=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 M(G0,{children:[M("div",{className:"st-layer st-layer--row"+(l?" is-sel":"")+(o?" is-hidden":"")+(I?" is-group":"")+(k?" is-instance":"")+($?" is-locked":""),style:{paddingLeft:6+J*14,...f},role:"treeitem","aria-selected":I?void 0:l,"aria-expanded":O?!P:void 0,"aria-grabbed":x?p:void 0,tabIndex:0,title:I?`${X.tag} · group (unstamped wrapper)`:`${X.tag} · ${X.type}${R?" · F2 to rename":""}`,"data-layer-key":w,onClick:()=>I?O&&Z(w):H(X),onMouseEnter:()=>!I&&K(X),onMouseLeave:()=>K(null),onPointerDown:x?(s)=>B(s,X,w):void 0,onKeyDown:(s)=>{if(s.key==="Enter"||s.key===" ")if(s.preventDefault(),I)O&&Z(w);else H(X);else if(s.key==="F2"&&R&&!I)s.preventDefault(),h(X.dcElement||X.label||""),y(!0)},children:[O?z("button",{type:"button",className:"st-layer-caret","aria-label":P?"Expand":"Collapse",onClick:(s)=>{s.stopPropagation(),Z(w)},children:P?"▸":"▾"}):z("span",{className:"st-layer-caret","aria-hidden":"true"}),k?z("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:k.root?"◆":"◇"}):z(A9,{name:y20[X.type]||"box",size:12,className:"st-layer-ticon"}),C?z("input",{className:"st-layer-rename",value:v,autoFocus:!0,"aria-label":`Rename ${X.label}`,onFocus:(s)=>s.target.select(),onChange:(s)=>h(s.target.value),onClick:(s)=>s.stopPropagation(),onPointerDown:(s)=>s.stopPropagation(),onBlur:m,onKeyDown:(s)=>{if(s.stopPropagation(),s.key==="Enter")m();else if(s.key==="Escape")y(!1)}}):z("span",{className:"st-layer-label",onDoubleClick:R&&!I?(s)=>{s.stopPropagation(),h(X.dcElement||X.label||""),y(!0)}:void 0,children:X.label}),z("span",{className:"st-layer-type",children:k?k.component:X.type}),_&&!I?z("button",{type:"button",className:"st-layer-lock","aria-label":$?`Unlock ${X.label}`:`Lock ${X.label}`,"aria-pressed":$,title:$?"Unlock":"Lock",onClick:(s)=>{s.stopPropagation(),_(w)},children:z(A9,{name:$?"lock":"unlock",size:12})}):null,U&&!I?z("button",{type:"button",className:"st-layer-eye","aria-label":o?`Show ${X.label}`:`Hide ${X.label}`,"aria-pressed":o,title:o?"Show":"Hide",onClick:(s)=>{s.stopPropagation(),U(X)},children:z(A9,{name:o?"eye-off":"eye",size:13})}):null]}),O&&!P?X.children.map((s,n)=>z(D00,{node:s,depth:J+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:q,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:D,onToggleLock:_,onRename:R},`${s.id}:${s.index}`)):null]})}function v20({el:X}){let J=X?.computed||{},Q=X?.authored||{},Y=(U)=>{let q=Q[U];if(q&&/var\(\s*--/.test(q))return q.replace(/^var\(\s*|\s*\)$/g,"");return J[U]||q||""},W=(U,q)=>{let B=J[q]||Q[q];if(!B)return null;return M("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:U}),M("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(q)})]})]},U)},G=J["border-radius"]&&J["border-radius"]!=="0px",Z=G?fQ(J["border-radius"]).n||J["border-radius"]:null,H=J["font-size"]||J["font-weight"]?[J["font-size"],J["font-weight"]].filter(Boolean).join(" / "):null;if(!(J["background-color"]||J.color||G||H))return null;return M(G0,{children:[G?M("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Radius"}),M("div",{className:"st-insp-fields",children:[M("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?M("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 O00(X){if(X.artboardId)return X.artboardId;let J=/^\[data-dc-screen="([^"]+)"\]$/.exec(X.selector||"");return J?J[1]:null}var h20=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],x20=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function g20({el:X,cfg:J,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let K=O00(X),U=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),q=N00(X.file,J),B=F00(J,U,q),N=(f)=>B.map((s)=>({ds:s.name,names:s[f]||[],vals:s.vals})).filter((s)=>s.names.length),F=(f)=>N(f).flatMap((s)=>(s.names||[]).map((n)=>({name:n,value:s.vals?.[n]||""}))),D=(f)=>{let s=/^var\(\s*(--[\w-]+)\s*\)$/.exec(f||"");if(!s)return f||"";for(let n of B){let c=n.vals?.[s[1]];if(c)return c}return""},_=Number.isFinite(X.worldW)?X.worldW:Number.isFinite(X.bounds?.w)?X.bounds.w:null,R=Number.isFinite(X.worldH)?X.worldH:Number.isFinite(X.bounds?.h)?X.bounds.h:null,w=(f,s)=>{if(!K)return;let n=Number.isFinite(f)&&f>0?Math.round(f):void 0,c=Number.isFinite(s)&&s>0?Math.round(s):void 0;if(n==null&&c==null)return;Q?.(K,n,c)},O=Object.entries(O5).find(([,f])=>f.width===_&&f.height===R)?.[0],P=Object.entries(O5).find(([,f])=>f.width===_)?.[0],I=X.attrs?.["data-dc-fixed"]==="true",k=X.attrs?.["data-dc-bg"]??"",$=X.attrs?.["data-dc-padding"]??"",C=X.attrs?.["data-dc-layout"]??"",y=X.attrs?.["data-dc-gap"]??"",v=X.attrs?.["data-dc-kind"]||"digital",h=null;try{h=X.attrs?.["data-dc-print"]?JSON.parse(X.attrs["data-dc-print"]):null}catch{}let l=(f)=>{if(!K)return;let s=null;if(f==="print"&&!h){let n={paper:"a4"};try{let c=U2(n);if(c)s={defaults:n,widthPx:c.widthPx,heightPx:c.heightPx}}catch{}}if(G?.(K,f==="digital"?null:f,s),f==="web"&&I)Y?.(K,!1,void 0)},o=(f)=>{if(!K)return;let s={paper:"a4",...h,...f},n;try{n=U2(s)}catch{return}Q?.(K,n.widthPx,n.heightPx),Z?.(K,s)},x=(f,s)=>{if(!K)return;let n=Number.isFinite(s)?s:R,c=f&&Number.isFinite(n)?Math.round(n):void 0;Y?.(K,f,c)},m=(f)=>{let s=r$(I,f);if(s.kind==="resize")w(null,s.height);else if(s.kind==="promote-to-fixed")x(!0,s.height)},p=(f)=>{if(!K)return;W?.(K,f)};return M("section",{className:"st-cp-sec",children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Artboard"})}),M("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[z(JX,{value:_??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(f)=>w(f,null)}),z(JX,{value:R??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:I,onCommit:m})]}),z("div",{style:{padding:"0 12px 8px"},children:v==="print"?M("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:h?.paper??"",onChange:(f)=>o({paper:f.currentTarget.value}),children:[z("option",{value:"",disabled:!0,children:"Paper size…"}),K2.map((f)=>M("option",{value:f.id,children:[f.label," — ",f.width,"×",f.height,f.unit]},f.id))]}):v==="web"?M("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:P??"",onChange:(f)=>{let s=O5[f.currentTarget.value];if(s)w(s.width,null)},children:[z("option",{value:"",disabled:!0,children:P?`${O5[P].label} — ≤ ${O5[P].width}px`:"Breakpoint…"}),Object.entries(O5).map(([f,s])=>M("option",{value:f,children:[s.label," — ≤ ",s.width,"px breakpoint"]},f))]}):M("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:O??"",onChange:(f)=>{let s=O5[f.currentTarget.value];if(s)w(s.width,s.height)},children:[z("option",{value:"",disabled:!0,children:O?O5[O].label:"Preset size…"}),Object.entries(O5).map(([f,s])=>M("option",{value:f,children:[s.label," — ",s.width,"×",s.height]},f))]})}),z("div",{style:{padding:"0 12px 8px"},children:z(rB,{value:I?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(f)=>x(f==="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(EW,{value:v,ariaLabel:"artboard kind",options:x20.map(([f,s])=>({value:f,label:s})),onChange:l})}),v!=="print"&&K&&H?z("div",{style:{padding:"0 12px 8px"},children:M("select",{className:"st-cp-nsel","aria-label":"duplicate artboard at breakpoint width",value:"",onChange:(f)=>{let s=O5[f.currentTarget.value];if(s)H(K,s.width);f.currentTarget.value=""},children:[z("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(O5).map(([f,s])=>M("option",{value:f,children:[s.label," — ",s.width,"px"]},f))]})}):null,v==="print"?M(G0,{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(rB,{value:h?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(f)=>o({orientation:f})})}),z("div",{style:{padding:"0 12px 8px"},children:z(JX,{value:Number.isFinite(h?.bleedMm)?h.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:(f)=>o({bleedMm:f})})})]}):null,z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Style"})}),M("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let f=D(k),s=/var\(\s*--/.test(k),n=s?k.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):k;return z(EV,{swatch:z(FF,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:N("color"),current:k,activeDs:q,swatchBg:f,seedHex:MF(f)||"#000000",onPick:(c)=>p({background:c||null}),label:"artboard background colour"}),displayValue:n,bound:s,ariaLabel:"artboard background",onValue:(c)=>p({background:(c||"").trim()||null})})})(),z(EW,{value:C,ariaLabel:"artboard body layout",options:h20.map(([f,s])=>({value:f,label:s})),onChange:(f)=>p({layout:f||null})}),M("div",{style:{display:"flex",gap:8},children:[z(aB,{value:/^var\(/.test($)?$:Number.parseFloat($)||0,tokens:F("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(f)=>p({padding:typeof f==="string"?f:f>0?f:null})}),z(aB,{value:/^var\(/.test(y)?y:Number.parseFloat(y)||0,tokens:F("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(f)=>p({gap:typeof f==="string"?f:f>0?f:null})})]})]})]})}var cR=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,m20=new RegExp(cR.source,"gi");function u20(X){if(!X||Array.isArray(X))return null;if(X.photoAsset)return X.photoAsset;let J=X.html||"";if((X.tag||"").toLowerCase()!=="img"){let W=[...new Set(J.match(m20)||[])],G=[...new Set([...J.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(J))return W[0];return null}let Q=/data-photo-asset="([^"]+)"/.exec(J);if(Q)return Q[1];let Y=cR.exec(`${X.attrs?.src||""} ${J}`);return Y?Y[0]:null}function l20({testId:X,selected:J,onClose:Q,layersTree:Y,componentMap:W,lockedKeys:G,onToggleLock:Z,onDetachInstance:H,canvasFile:K,onSelectLayer:U,onHoverLayer:q,onReorderLayer:B,layersBusyRef:N,cfg:F,onOptimistic:D,onRecordEdit:_,onReplaceMedia:R,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:P,onSetArtboardKind:I,onSetArtboardPrint:k,onDuplicateArtboard:$,onUndoRedo:C,editScope:y,tab:v,onTabChange:h,width:l,resizing:o,photoSel:x,photoRev:m,onPhotoEdit:p,onPhotoRemoveBackground:f,onPhotoRecordEdit:s,onPhotoUndoRedo:n,layersOnly:c=!1,hideLayersTab:U0=!1,cpMode:X0,onSetCpMode:H0}){let[r,D0]=u.useState("inspect"),z0=c?"layers":v??r,l0=(m0)=>{D0(m0),h?.(m0)},[X8,d0]=u.useState(()=>new Set),[$0,O0]=u.useState(()=>new Map);u.useEffect(()=>{let m0=Array.isArray(J)?J[0]:J,w0=m0?.id;if(!w0||!Y?.nodes)return;let K8=m0.index,I8=null,k8=[];if(function _9(A8,T9){for(let Y9 of A8||[]){let b7=`${Y9.id}:${Y9.index}`;if(!Y9.synthetic&&Y9.id===w0&&(K8==null||Y9.index===K8))return I8=b7,k8.push(...T9),!0;if(Y9.children&&Y9.children.length&&_9(Y9.children,[...T9,b7]))return!0}return!1}(Y.nodes,[]),!I8)return;if(k8.length)d0((_9)=>{let A8=!1,T9=new Set(_9);for(let Y9 of k8)if(T9.delete(Y9))A8=!0;return A8?T9:_9});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${I8}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[J,Y]);let i0=(m0)=>{let w0=`${m0.id}:${m0.index}`;return $0.has(w0)?$0.get(w0):!!m0.hidden},[c8,z8]=u.useState(null),[Q9,L8]=u.useState(""),W8=(m0,w0)=>{if(!K||!m0?.id)return;fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:K,id:m0.id,attr:"data-dc-element",value:w0})}).then((K8)=>K8.json().catch(()=>({}))).then((K8)=>{if(!K8.ok)return;_?.({op:"attr",canvas:K,id:m0.id,key:"data-dc-element",before:m0.dcElement??null,after:w0})}).catch(()=>{})},b8=B?(m0,w0,K8)=>{if(N?.current)return;if(m0?.synthetic||w0?.synthetic)return;let I8=K8==="before"?`before ${w0.label}`:K8==="after"?`after ${w0.label}`:`into ${w0.label}`;L8(`Moved ${m0.label} ${I8}`),B(m0.id,w0.id,K8,{idIndex:m0.index,refIndex:w0.index})}:void 0,i8=()=>{let m0=[];return function w0(K8,I8,k8){(K8||[]).forEach((_9,A8)=>{if(m0.push({node:_9,depth:I8,parentNode:k8,siblings:K8,pos:A8}),_9.children&&_9.children.length&&!X8.has(`${_9.id}:${_9.index}`))w0(_9.children,I8+1,_9)})}(Y?.nodes,0,null),m0},p9=(m0)=>{if(m0.key!=="ArrowUp"&&m0.key!=="ArrowDown")return;if(!y0)return;let w0=i8(),K8=w0.findIndex((A8)=>A8.node.id===y0.id&&A8.node.index===y0.index);if(K8<0)return;let I8=m0.key==="ArrowDown"?1:-1,k8=w0[K8];if(!m0.altKey){let A8=w0[K8+I8];if(A8)m0.preventDefault(),U?.(A8.node);return}if(!b8||!Array.isArray(k8.siblings))return;m0.preventDefault();let _9=(A8)=>A8&&A8.children&&A8.children.length&&!X8.has(`${A8.id}:${A8.index}`);if(!m0.shiftKey){if(I8<0&&k8.pos>0)b8(k8.node,k8.siblings[k8.pos-1],"before");else if(I8>0&&k8.pos<k8.siblings.length-1)b8(k8.node,k8.siblings[k8.pos+1],"after");return}if(I8>0){let A8=k8.siblings[k8.pos+1];if(A8)b8(k8.node,A8,_9(A8)?"inside-start":"after");else if(k8.parentNode)b8(k8.node,k8.parentNode,"after")}else{let A8=k8.siblings[k8.pos-1];if(A8)b8(k8.node,A8,_9(A8)?"inside-end":"before");else if(k8.parentNode)b8(k8.node,k8.parentNode,"before")}},M0=u.useRef(null),j8=u.useRef(null),L9=(m0,w0,K8)=>{if(!b8||m0.button!==0||m0.metaKey||m0.ctrlKey||m0.shiftKey||m0.altKey)return;if(N?.current)return;let{clientX:I8,clientY:k8}=m0,_9=new Set([K8]);(function g8(s9){(s9.children||[]).forEach((m7)=>{_9.add(`${m7.id}:${m7.index}`),g8(m7)})})(w0);let A8=14,T9=6,Y9=[];(function g8(s9,m7){(s9||[]).forEach((P7)=>{let E9=`${P7.id}:${P7.index}`;if(Y9.push({node:P7,key:E9,id:P7.id,depth:m7,tag:P7.tag}),P7.children&&P7.children.length&&!X8.has(E9))g8(P7.children,m7+1)})})(Y?.nodes,0);let b7=new Map(Y9.map((g8)=>[g8.key,g8])),E0=!1,f8=(g8)=>{if(!E0){if(Math.hypot(g8.clientX-I8,g8.clientY-k8)<4)return;E0=!0}let s9=g8.clientX-I8,m7=g8.clientY-k8,P7=null,E9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((e)=>({rect:e.getBoundingClientRect(),it:b7.get(e.getAttribute("data-layer-key"))})).filter((e)=>e.it&&e.it.key!==K8);if(E9.length){let e=E9[0].rect.left,A0=E9[0].rect.right,q0=E9.length;for(let F7=0;F7<E9.length;F7++)if(g8.clientY<E9[F7].rect.top+E9[F7].rect.height/2){q0=F7;break}let j0=E9[q0-1]?.it||null,n0=E9[q0]?.it||null,y8=Math.round((g8.clientX-e-T9)/A8),S8=j0?j0.depth+(f20.has(j0.tag)?0:1):0,o8=n0?n0.depth:0,e8=Math.max(o8,Math.min(y8,S8)),P9=null,V7="before",h9=0;if(!j0){if(n0)P9=n0,V7="before",h9=n0.depth}else if(e8>j0.depth)P9=j0,V7="inside-start",h9=j0.depth+1;else if(e8===j0.depth)P9=j0,V7="after",h9=j0.depth;else{for(let F7=q0-1;F7>=0;F7--)if(E9[F7].it.depth===e8){P9=E9[F7].it;break}if(!P9)P9=j0;V7="after",h9=e8}if(P9&&P9.key!==K8&&!_9.has(P9.key)){let F7=j0?E9[q0-1].rect.bottom:E9[0].rect.top,ZX=e+T9+h9*A8;P7={refId:P9.id,position:V7,node:P9.node,y:F7,left:ZX,w:Math.max(24,A0-ZX)}}}let l6={key:K8,node:w0,dx:s9,dy:m7,target:P7};M0.current=l6,z8(l6)},v9=()=>{window.removeEventListener("pointermove",f8),window.removeEventListener("pointerup",G6),window.removeEventListener("keydown",_6,!0)},w9=()=>{let g8=(s9)=>{s9.preventDefault(),s9.stopImmediatePropagation(),document.removeEventListener("click",g8,!0)};document.addEventListener("click",g8,!0),setTimeout(()=>document.removeEventListener("click",g8,!0),300)},G6=()=>{v9();let g8=M0.current;if(M0.current=null,z8(null),E0&&g8?.target)w9(),b8(g8.node,g8.target.node,g8.target.position)},_6=(g8)=>{if(g8.key!=="Escape")return;if(g8.preventDefault(),g8.stopImmediatePropagation(),v9(),M0.current=null,z8(null),E0)w9()};window.addEventListener("pointermove",f8),window.addEventListener("pointerup",G6),window.addEventListener("keydown",_6,!0)},U8=(m0)=>d0((w0)=>{let K8=new Set(w0);if(K8.has(m0))K8.delete(m0);else K8.add(m0);return K8}),D9=(m0)=>{let w0=`${m0.id}:${m0.index}`,K8=i0(m0),I8=!K8;if(O0((k8)=>new Map(k8).set(w0,I8)),D?.({id:m0.id,artboardId:Y?.artboardId??null,index:m0.index,prop:"display",value:I8?"none":null}),!K||!m0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(I8?{canvas:K,id:m0.id,property:"display",value:"none"}:{canvas:K,id:m0.id,property:"display",reset:!0})}).catch(()=>{}),_?.({op:"css",canvas:K,id:m0.id,key:"display",before:K8?"none":null,after:I8?"none":null})},y0=Array.isArray(J)?J[0]:J,Z0=x?{asset:x.asset,kind:"annotation-image"}:(()=>{let m0=u20(y0);return m0?{asset:m0,kind:"artboard-img"}:null})(),S0=Z0?.kind==="annotation-image",c0=(m0)=>{if(!(m0.metaKey||m0.ctrlKey)||m0.altKey)return;let w0=m0.key.toLowerCase();if(w0==="z")m0.preventDefault(),n?.(m0.shiftKey?"redo":"undo");else if(w0==="y")m0.preventDefault(),n?.("redo")},q8=S0?"photo":z0==="photo"&&!Z0?"inspect":z0,N8=(m0,w0,K8)=>M("button",{type:"button",className:"st-rp-tab"+(q8===m0?" is-active":""),onClick:()=>l0(m0),children:[z(A9,{name:K8,size:14}),w0]}),H8=y0?.bounds||null;return M("aside",{className:"st-rpanel"+(o?" is-resizing":""),style:l?{width:l,flexBasis:l}:void 0,"aria-label":"Inspector","data-tour":"inspector","data-testid":X,children:[M("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:c?{display:"none"}:void 0,children:[S0?N8("photo","Photo","image"):M(G0,{children:[N8("inspect","Inspect","sliders"),!U0&&N8("layers","Layers","layers"),N8("css","CSS","code"),Z0?N8("photo","Photo","image"):null]}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:Q,children:z(A9,{name:"x",size:14})})]}),y0?.id&&!(Array.isArray(J)&&J.length>1)&&y?M("div",{className:`st-scope st-scope--${y.scope}`,title:y.scope==="shared"?`Editing this element's style changes ${y.affects} place${y.affects===1?"":"s"}${y.componentName?` (component ${y.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"}),y.scope==="shared"?`Shared${y.componentName?` · ${y.componentName}`:""} · edits ${y.affects} place${y.affects===1?"":"s"}`:"Local · this element only",y.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(y0.id,y0.index),children:"Detach"}):null]}):null,z("div",{className:"st-rp-body",children:q8==="photo"&&Z0?z("div",{onKeyDown:c0,children:z(ah,{asset:Z0.asset,ColorPicker:L00,StIcon:A9,onEdit:(m0)=>p?.(Z0.asset,m0),onRemoveBackground:f,onRecordEdit:(m0,w0)=>s?.(Z0.asset,m0,w0)},`${Z0.asset}:${m??0}`)}):!y0&&!(q8==="layers"&&Y?.nodes?.length)?z("div",{className:"st-rp-empty",children:M("p",{children:["Press ",z(MX,{children:"V"}),", then click an element to select it — or ",z(MX,{children:"⌘"}),"-click straight from Browse."]})}):y0&&q8==="inspect"?M(G0,{children:[z("div",{className:"st-rp-hd",children:y0.selector||y0.tag||"element"}),M("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Pos"}),M("div",{className:"st-insp-fields",children:[M("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"X"}),z("input",{value:H8?Math.round(H8.x):"—",readOnly:!0,"aria-label":"x position"})]}),M("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"Y"}),z("input",{value:H8?Math.round(H8.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),M("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Size"}),M("div",{className:"st-insp-fields",children:[M("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"W"}),z("input",{value:H8?Math.round(H8.w):"—",readOnly:!0,"aria-label":"width"})]}),M("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"H"}),z("input",{value:H8?Math.round(H8.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),M("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:y0.tag||"—"})})]}),y0.classes?M("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:y0.classes})})]}):null,z(v20,{el:y0})]}):q8==="layers"?M(G0,{children:[M("div",{className:"st-rp-hd",children:["Layers",Y?.nodes?.length?"":" · ancestry"]}),Y?.nodes?.length?M(G0,{children:[b8?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:j8,onKeyDown:p9,children:Y.nodes.map((m0,w0)=>z(D00,{node:m0,depth:0,selectedId:y0?.id,selectedIndex:y0?.index,collapsed:X8,hiddenOverride:$0,onToggle:U8,onSelect:(K8)=>{U?.(K8),j8.current?.focus()},onHover:(K8)=>q?.(K8),onToggleVisibility:D9,onReorder:b8,onRowPointerDown:L9,dragState:c8,componentMap:W,lockedKeys:G,onToggleLock:Z,onRename:W8},`${m0.id}:${m0.index}`))}),c8?.target?z("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:c8.target.left,top:c8.target.y-1,width:c8.target.w}}):null,z("div",{className:"sr-only",role:"status","aria-live":"polite",children:Q9})]}):y0&&Array.isArray(y0.dom_path)&&y0.dom_path.length?y0.dom_path.map((m0,w0)=>M("div",{className:"st-layer"+(w0===y0.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+w0*12},children:[z(A9,{name:"square",size:13}),m0]},w0)):z("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!y0.id&&O00(y0)?z(g20,{el:y0,cfg:F,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:P,onSetArtboardKind:I,onSetArtboardPrint:k,onDuplicateArtboard:$}):z($20,{el:y0,cfg:F,onOptimistic:D,onRecordEdit:_,onReplaceMedia:R,onUndoRedo:C,mode:X0,onSetMode:H0})})]})}function p20(){let[X,J]=u.useState([]),[Q,Y]=u.useState("Design"),[W,G]=u.useState([]),[Z,H]=u.useState(null),[K,U]=u.useState(null),q=u.useCallback((j)=>{U(j)},[]),[B,N]=u.useState(null),F=u.useRef(null);u.useEffect(()=>{F.current=B},[B]);let[D,_]=u.useState(null);u.useEffect(()=>{let j=Array.isArray(B)?B.length===1?B[0]:null:B,b=j&&typeof j.id==="string"?j.id:null;if(!b||!Z){_(null);return}let t=new AbortController,W0=new URLSearchParams({canvas:Z,id:b});return fetch(`/_api/edit-scope?${W0}`,{signal:t.signal}).then((F0)=>F0.ok?F0.json():null).then((F0)=>{if(F0?.ok)_(F0)}).catch(()=>{}),()=>t.abort()},[B,Z]);let R=u.useRef(0),w=u.useRef([]),O=u.useCallback((j)=>{if(!j?.id||!j.file)return;for(let b of w.current)clearTimeout(b);w.current=[50,450,1200,2500,5000].map((b)=>setTimeout(()=>{let t=F.current,W0=Array.isArray(t)?t[0]:t;if(!W0||W0.id!==j.id||W0.file!==j.file)return;let F0=m8.current.get(j.file);if(!F0?.contentWindow)return;try{F0.contentWindow.postMessage({dgn:"select-by-id",id:j.id,artboardId:j.artboardId??null,index:j.index??0},"*")}catch{}},b))},[]),P=u.useRef([]),I=u.useCallback((j,b)=>{if(!j||!b)return;for(let t of P.current)clearTimeout(t);P.current=[50,450,1200,2500,5000].map((t)=>setTimeout(()=>{let W0=F.current,F0=Array.isArray(W0)?W0[0]:W0;if(!F0||F0.artboardId!==j||F0.file!==b)return;let B0=m8.current.get(b);if(!B0?.contentWindow)return;try{B0.contentWindow.postMessage({dgn:"select-by-id",artboardId:j},"*")}catch{}},t))},[]),k=u.useRef(null),$=u.useRef(null),C=u.useRef(null),y=u.useRef(null),v=u.useRef(!1),h=u.useRef(null),[l,o]=u.useState(null),[x,m]=u.useState(null),p=u.useRef({canvas:null,at:0});u.useEffect(()=>{if(!Z||!l)return;let j=Date.now(),b=p.current;if(b.canvas===Z&&j-b.at<1500)return;p.current={canvas:Z,at:j},fetch(`/_api/component-map?canvas=${encodeURIComponent(Z)}`).then((t)=>t.json()).then((t)=>{if(t?.ok&&t.map&&typeof t.map==="object")m(t.map);else m(null)}).catch(()=>m(null))},[Z,l]);let[f,s]=u.useState(!1),[n,c]=u.useState(null),[U0,X0]=u.useState(null),[H0,r]=u.useState(null),[D0,z0]=u.useState(null),[l0,X8]=u.useState(null),[d0,$0]=u.useState(!1),[O0,i0]=u.useState(!1),[c8,z8]=u.useState(null),[Q9,L8]=u.useState(""),[W8,b8]=u.useState(null),[i8,p9]=u.useState(null),M0=u.useRef(null),j8=de("maude-sb-w",{min:200,max:420,def:252}),L9=de("maude-rp-w",{min:260,max:480,def:304}),[U8,D9]=u.useState(null),y0=u.useRef(null);u.useEffect(()=>{if(!U8)return;let j=(t)=>{let W0=y0.current?.getBoundingClientRect();if(!W0)return;if(U8==="sb")j8.setW(t.clientX-W0.left);else L9.setW(W0.right-t.clientX)},b=()=>D9(null);return window.addEventListener("pointermove",j),window.addEventListener("pointerup",b),()=>{window.removeEventListener("pointermove",j),window.removeEventListener("pointerup",b)}},[U8,j8.setW,L9.setW]);let Z0=u.useCallback((j)=>{clearTimeout(M0.current),M0.current=setTimeout(()=>{p9((b)=>b===j?null:b)},2500)},[]);u.useEffect(()=>{if(!i8)return;let j=setTimeout(()=>p9(null),15000);return()=>clearTimeout(j)},[i8]);let[S0,c0]=u.useState({designRel:".design",cloud:void 0}),q8=!!S0.readOnly,N8=u.useCallback(()=>{fetch("/_config").then((j)=>j.json()).then((j)=>{let b=(j.designRoot||".design").replace(/^\/+|\/+$/g,"");c0((t)=>({...t,designRel:b,tokensCssRel:j.tokensCssRel,designSystems:j.designSystems,canvasOrigin:j.canvasOrigin,readOnly:!!j.readOnly,canvasToken:j.canvasToken,version:j.version,cloud:j.cloud??null}))}).catch(()=>{})},[]);u.useEffect(()=>{N8()},[N8]),u.useEffect(()=>{let j=!1;return fetch("/_sync-status").then((b)=>b.json()).then((b)=>{if(j||!b||b.linked===!1)return;X0(b)}).catch(()=>{}),()=>{j=!0}},[]),u.useEffect(()=>{let j=!1;return fetch("/_api/git/status").then((b)=>b.json()).then((b)=>{if(!j&&b)z0(b)}).catch(()=>{}),()=>{j=!0}},[]);let[H8,m0]=u.useState({}),[w0,K8]=u.useState(null),[I8,k8]=u.useState(!1),[_9,A8]=u.useState("open"),[T9,Y9]=u.useState(Cq0),[b7,E0]=u.useState(()=>{return hR(ye,"advanced")==="designer"?"designer":"advanced"});u.useEffect(()=>{try{localStorage.setItem(ye,JSON.stringify(b7))}catch{}},[b7]);let[f8,v9]=u.useState(null),[w9,G6]=u.useState(()=>sZ(je,!0)),[_6,g8]=u.useState(()=>sZ(Se,!1)),[s9,m7]=u.useState(()=>hR(be,{})),[P7,E9]=u.useState(!1),[l6,e]=u.useState(!1);u.useEffect(()=>{if(!X9())return;let j=_v(()=>e(!0));return()=>{j.then((b)=>b()).catch(()=>{})}},[]);let[A0,q0]=u.useState(!1),[j0,n0]=u.useState(!1),[y8,S8]=u.useState(!1),[o8,e8]=u.useState(!1),[P9,V7]=u.useState(!1),{report:h9}=DA(X9()),[F7,ZX]=u.useState(!1),[vQ,QQ]=u.useState(!1),[M5,$6]=u.useState(null),[I9,y7]=u.useState(!1),[mW,L7]=u.useState(!1),[HX,_X]=u.useState(!1),[hQ,_7]=u.useState(!1),[u7,_5]=u.useState(()=>hR(xe,wK)),[H7,lY]=u.useState(()=>{try{let j=localStorage.getItem(ge);if(j==="separate"||j==="in-inspector")return j}catch{}return"separate"}),[j7,n9]=u.useState(!1),[q7,d9]=u.useState([]),[$9,mX]=u.useState(0),[pY,uX]=u.useState(!1),[zJ,YQ]=u.useState(!1),[AX,A5]=u.useState(!1),[uW,xQ]=u.useState(1),[dY,i]=u.useState(216),[J0,N0]=u.useState(null),[C0,R0]=u.useState([]),[Q8,G8]=u.useState([]),[z9,t8]=u.useState([]),[e7,wX]=u.useState(0),A6=u.useRef(0);u.useEffect(()=>{A6.current=$9},[$9]);let[D7,gQ]=u.useState(null),cY=u.useRef(null);u.useEffect(()=>{cY.current=D7},[D7]);let X6=u.useMemo(()=>PA(q7,{artboardId:[D7,J0],total:e7}),[q7,D7,J0,e7]),lX=u.useRef(null);u.useEffect(()=>{lX.current=X6},[X6]);let Z6=u.useMemo(()=>sz(q7,X6)?.fps||30,[q7,X6]),[zX,KJ]=u.useState(null),[w5,T8]=u.useState(0),V9=u.useCallback((j,b)=>{if(/concurrent edit|changed since it was read/i.test(b||""))x8("Timeline changed — reloaded, try again."),T8((t)=>t+1);else x8(`${j}: ${b||"failed"}`)},[]),[N9,UJ]=u.useState(!1),[EX,iY]=u.useState(!1),[lW,pW]=u.useState(!1),E5=u.useRef(N9);u.useEffect(()=>{if(E5.current=N9,N9){pW(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[N9]);let tZ=u.useCallback(()=>{if(!E5.current||document.hidden)pW(!0),ue("Claude finished","Your assistant turn is ready in Maude.")},[]),oY=u.useRef(0),nY=u.useCallback(()=>{if(!E5.current||document.hidden){pW(!0);let j=Date.now();if(j-oY.current<Tq0)return;oY.current=j,ue("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[PX,WQ]=u.useState("inspect"),[IK,pX]=u.useState(null),GQ=u.useRef({undo:[],redo:[]}),[dW,kK]=u.useState(0),[xJ,cW]=u.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),rY=u.useRef(xJ);u.useEffect(()=>{rY.current=xJ;try{localStorage.setItem("maude-auto-open-inspector",xJ?"1":"0")}catch{}},[xJ]);let eZ=u.useRef(!1);u.useEffect(()=>{eZ.current=HX||I8||d0||O0||N9},[HX,I8,d0,O0,N9]);let iW=u.useRef({open:{},side:wK});iW.current={open:{tree:w9,layers:hQ,inspector:HX,comments:I8,changes:d0,sync:O0,assistant:N9},side:u7};let mQ=u.useCallback((j,b)=>{if(j==="tree")G6(b);else if(j==="layers")_7(b);else if(j==="inspector")_X(b);else if(j==="comments")k8(b);else if(j==="changes")$0(b);else if(j==="sync")i0(b);else if(j==="assistant")UJ(b)},[]),oW=u.useCallback((j)=>iW.current.side?.[j]||wK[j],[]),RX=u.useCallback((j)=>{let b=oW(j);mQ(j,!0);for(let t of lR)if(t.id!==j&&oW(t.id)===b)mQ(t.id,!1)},[mQ,oW]),P5=u.useCallback((j)=>{if(iW.current.open?.[j])mQ(j,!1);else RX(j)},[RX,mQ]),gJ=RX,S6=P5,nW=u.useCallback((j)=>{if(!rY.current)return;if(q8)return;if(!j||!j.id)return;if(eZ.current)return;gJ("inspector"),WQ("css")},[gJ,q8]),aY=u.useCallback(()=>n9((j)=>!j),[]),ZQ=Lx(dR),sY=Xx({enabled:S0.cloud===null}),[rW,aW]=u.useState(!1),[tY,XH]=u.useState(!1);u.useEffect(()=>{if(!X9())return;let j=!0;return Pv().then((b)=>{if(!j)return;if(aW(!!b),!b&&!sZ($e,!1))XH(!0)}).catch(()=>{}),()=>{j=!1}},[]);let JH=u.useCallback(()=>{XH(!1);try{localStorage.setItem($e,"1")}catch{}},[]),[sW,eY]=u.useState(null);u.useEffect(()=>{if(!X9())return;let j;return kv((b)=>eY(b&&typeof b==="object"?b:{})).then((b)=>{j=b}).catch(()=>{}),()=>{try{j?.()}catch{}}},[]);let[b6,QH]=u.useState(null),[uQ,CK]=u.useState(()=>!sZ(Ce,!1)),R5=u.useCallback((j)=>{QH(Array.isArray(j)&&j.length?j:null)},[]),$K={setup:(j)=>{if(!j)return;if((j.canvas||j.requireSelection)&&W.length===0)RX("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [role="treeitem"]')?.click()}catch{}},80);if(j.inspector||j.tab||j.requireSelection)gJ("inspector");if(j.tab)WQ(j.tab);if(j.changes)gJ("changes")}},tW=u.useCallback(()=>{CK(!1);try{localStorage.setItem(Ce,"1")}catch{}},[]),[dX,X4]=u.useState(()=>sZ(he,!0)),[YH,SK]=u.useState(!1),[mJ,WH]=u.useState(()=>sZ(fe,!1)),[uJ,GH]=u.useState(()=>sZ(ve,!1)),[TX,eW]=u.useState(!1),[bK,cX]=u.useState(!1),[IX,HQ]=u.useState(0),[XG,yK]=u.useState(null),[lQ,zQ]=u.useState(!1),pQ=u.useRef(null),KQ=u.useRef(null),m8=u.useRef(new Map),M8=u.useCallback((j)=>{let b=Z?m8.current.get(Z):null;if(!b||!b.contentWindow)return;try{b.contentWindow.postMessage(j,"*")}catch{}},[Z]),dQ=u.useCallback((j,b)=>M8({dgn:"photo-preview",asset:j,edit:b}),[M8]),JG=u.useCallback((j,b,t)=>{GQ.current.undo.push({asset:j,before:b,after:t}),GQ.current.redo.length=0},[]),QG=u.useCallback((j)=>{let b=j?GQ.current.redo:GQ.current.undo;if(!b.length)return!1;let t=b.pop();(j?GQ.current.undo:GQ.current.redo).push(t);let W0=(j?t.after:t.before)||{};return dQ(t.asset,W0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(t.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(W0)}).catch(()=>{}),kK((F0)=>F0+1),!0},[dQ]),YG=u.useCallback(async(j)=>{M8({dgn:"photo-busy",asset:j,busy:!0});try{let b=await fetch(`/${j.replace(/^\/+/,"")}`);if(!b.ok)return null;let t=await b.blob(),{removeBackground:W0}=await Promise.resolve().then(() => (ke(),Ie)),F0=await W0(t),B0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":F0.type||"image/png"},body:F0}),k0=await B0.json().catch(()=>({}));if(B0.ok&&k0.path)return{maskAsset:k0.path};return null}catch(b){return console.error("[photo] background removal failed",b),null}finally{M8({dgn:"photo-busy",asset:j,busy:!1})}},[M8]);u.useEffect(()=>{let j=(W0)=>Array.from(W0.dataTransfer?.types??[]).includes("Files"),b=(W0)=>{if(j(W0))W0.preventDefault()},t=(W0)=>{if(j(W0))W0.preventDefault()};return document.addEventListener("dragover",b),document.addEventListener("drop",t),()=>{document.removeEventListener("dragover",b),document.removeEventListener("drop",t)}},[]);let w6=u.useRef({});w6.current={open:j7,comps:q7,frame:$9,total:e7,playing:pY,compId:X6,muted:AX,loop:zJ,sequences:C0,post:M8,canvas:Z};let T5=u.useRef({undo:[],redo:[]}),R7=u.useCallback((j,b,t)=>{if(typeof b!=="number")return;if(T5.current.undo.push({canvas:j,seq:b,label:t}),T5.current.redo=[],T5.current.undo.length>50)T5.current.undo.shift()},[]),K0=u.useCallback((j)=>{let b=T5.current,t=j==="undo"?b.undo:b.redo,W0=j==="undo"?b.redo:b.undo,F0=w6.current.canvas,B0=-1;for(let d=t.length-1;d>=0;d--)if(t[d].canvas===F0){B0=d;break}if(B0<0){x8(j==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let k0=t[B0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:k0.canvas,seq:k0.seq,dir:j})}).then((d)=>d.json().catch(()=>({}))).then((d)=>{if(t.splice(B0,1),d?.ok)W0.push(k0),x8(`${j==="undo"?"Undid":"Redid"}: ${k0.label}`,!0);else x8(`${j==="undo"?"Undo":"Redo"} skipped: ${d?.error||"failed"}`)}).catch(()=>x8(`${j==="undo"?"Undo":"Redo"} failed: network error`))},[]),p6=u.useCallback((j,b)=>{let t=j?.ok&&Array.isArray(j.clips)?j.clips.filter((W0)=>W0.kind==="sequence"):[];if(b==null)return null;if(typeof b==="object")return(b.stableId?t.find((W0)=>W0.stableId===b.stableId):null)||(Number.isInteger(b.index)?t[b.index]:null)||null;if(typeof b==="string")return t.find((W0)=>W0.stableId===b)||null;return t[b]||null},[]),J4=u.useCallback((j)=>{let b=w6.current.canvas;if(!b||b===d8)return;let t=cY.current||void 0,W0=`/_api/comp-clips?canvas=${encodeURIComponent(b)}${t?`&artboardId=${encodeURIComponent(t)}`:""}`;fetch(W0).then((F0)=>F0.json().catch(()=>({}))).then((F0)=>{let B0=p6(F0,j);if(!B0?.stableId)return null;return fetch("/_api/remove-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:b,artboardId:t,stableId:B0.stableId,contentHash:B0.contentHash})})}).then((F0)=>F0?F0.json():null).then((F0)=>{if(F0&&!F0.ok)console.warn("[remove-clip]",F0.error||"failed"),V9("Remove refused",F0.error);else if(F0?.ok){if(x8("Clip removed.",!0),F0.seq!=null)R7(b,F0.seq,"remove clip");KJ(null)}}).catch(()=>x8("Remove failed: network error"))},[p6,R7]),UQ=u.useCallback((j,b,t)=>{let W0=w6.current.canvas;if(!W0||W0===d8)return;let F0=cY.current||void 0,B0=`/_api/comp-clips?canvas=${encodeURIComponent(W0)}${F0?`&artboardId=${encodeURIComponent(F0)}`:""}`;fetch(B0).then((k0)=>k0.json().catch(()=>({}))).then((k0)=>{let d=k0?.ok&&Array.isArray(k0.clips)?k0.clips:[],_0=j?.transition?d.find((L0)=>L0.kind==="transition"&&L0.stableId===j.stableId)||null:p6(k0,j);if(!_0?.stableId)return null;return fetch("/_api/clip-edit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:W0,artboardId:F0,stableId:_0.stableId,contentHash:_0.contentHash,verb:b,...t})})}).then((k0)=>k0?k0.json():null).then((k0)=>{if(k0&&!k0.ok)console.warn("[clip-edit]",b,k0.error||"failed"),V9(`${b} refused`,k0.error);else if(k0?.ok){let d={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(x8(`Applied: ${d[b]||b}.`,!0),k0.seq!=null)R7(W0,k0.seq,d[b]||b)}}).catch(()=>x8(`${b} failed: network error`))},[p6,R7,V9]),[iX,f7]=u.useState(null),KX=u.useCallback((j,b="")=>new Promise((t)=>{f7({title:j,value:b,resolve:t})}),[]),VJ=u.useCallback((j)=>{f7((b)=>{return b?.resolve?.(j),null})},[]),Q4=u.useCallback((j,b)=>{let t=w6.current.canvas;if(!t||t===d8||!b||!String(b).trim())return;T7({type:"comments-add",payload:{file:t,text:String(b).trim(),selector:"",dom_path:[],tag:"",classes:"",bounds:null,html_excerpt:"",timeline:j}}),x8("Comment added.",!0)},[]);w6.current.selected=zX,w6.current.setSelected=KJ,w6.current.removeClip=J4,w6.current.clipVerb=UQ,w6.current.addComment=Q4,w6.current.askText=KX,u.useEffect(()=>{let j=(b)=>{let t=w6.current;if(!t.open||!t.comps?.length)return;let W0=b.target,F0=W0?.tagName;if(F0==="INPUT"&&W0?.type!=="range")return;if(F0==="TEXTAREA"||F0==="SELECT"||W0?.isContentEditable)return;let B0=sz(t.comps,t.compId)?.fps||30,k0=Math.max(1,t.total),d=(L0)=>{let p0=Math.max(0,Math.min(k0-1,Math.round(L0)));mX(p0),uX(!1),t.post({dgn:"timeline-seek",frame:p0,id:t.compId})},_0=()=>{let L0=new Set([0,k0-1]);for(let p0 of t.sequences||[]){L0.add(p0.from);for(let D8 of p0.keyframes||[])L0.add(D8.from),L0.add(D8.to)}return[...L0].filter((p0)=>p0>=0&&p0<k0).sort((p0,D8)=>p0-D8)};if((b.metaKey||b.ctrlKey)&&(b.key==="z"||b.key==="Z")){b.preventDefault(),K0(b.shiftKey?"redo":"undo");return}if(b.key==="Escape"){if(t.selected!=null)b.preventDefault(),t.setSelected?.(null);return}if((b.key==="Delete"||b.key==="Backspace")&&t.selected!=null){b.preventDefault(),t.removeClip?.({stableId:t.selected});return}if((b.metaKey||b.ctrlKey)&&(b.key==="b"||b.key==="B")){b.preventDefault();let L0=t.selected!=null?{stableId:t.selected}:null;if(!L0){let p0=t.sequences||[],D8=p0.find((B8)=>B8.series&&t.frame>=B8.from&&t.frame<B8.from+B8.duration)||p0.find((B8)=>t.frame>=B8.from&&t.frame<B8.from+B8.duration);if(D8?.stableId)L0={stableId:D8.stableId}}if(L0)t.clipVerb?.(L0,"split",{atFrame:t.frame});else x8("Nothing under the playhead to split.");return}if(b.key===" "||b.code==="Space")if(b.preventDefault(),t.playing)uX(!1),t.post({dgn:"timeline-pause",id:t.compId});else uX(!0),t.post({dgn:"timeline-mute",muted:t.muted,id:t.compId}),t.post({dgn:"timeline-loop",loop:t.loop,id:t.compId}),t.post({dgn:"timeline-play",id:t.compId});else if(b.key==="ArrowRight")b.preventDefault(),d(t.frame+(b.shiftKey?B0:1));else if(b.key==="ArrowLeft")b.preventDefault(),d(t.frame-(b.shiftKey?B0:1));else if(b.key==="Home")b.preventDefault(),d(0);else if(b.key==="End")b.preventDefault(),d(k0-1);else if(b.key==="."){b.preventDefault();let L0=_0().find((p0)=>p0>t.frame);if(L0!=null)d(L0)}else if(b.key===","){b.preventDefault();let L0=_0().reverse().find((p0)=>p0<t.frame);if(L0!=null)d(L0)}};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[]),u.useEffect(()=>{d9([]),mX(0),uX(!1),KJ(null),gQ(null);let j=setTimeout(()=>M8({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(j)},[Z,M8]);let[I5,Y4]=u.useState(""),[VQ,cQ]=u.useState([]),[WG,a0]=u.useState([]);u.useEffect(()=>{if(!j7||q7.length===0||!Z||Z===d8){Y4(""),cQ([]);return}let j=!0;return fetch(`/_api/canvas-source?file=${encodeURIComponent(Z)}`).then((b)=>b.ok?b.json():null).then((b)=>{if(j&&b?.ok&&typeof b.source==="string")Y4(b.source)}).catch(()=>{}),()=>{j=!1}},[j7,q7,Z,w5]),u.useEffect(()=>{if(!j7||!Z||Z===d8||!I5){cQ([]),a0([]);return}let j=!0,b=D7||void 0,t=`/_api/comp-clips?canvas=${encodeURIComponent(Z)}${b?`&artboardId=${encodeURIComponent(b)}`:""}`;return fetch(t).then((W0)=>W0.ok?W0.json():null).then((W0)=>{if(!j)return;let F0=W0?.ok&&Array.isArray(W0.clips)?W0.clips:[];cQ(F0.filter((B0)=>B0.kind==="sequence")),a0(F0.filter((B0)=>B0.kind==="transition"))}).catch(()=>{}),()=>{j=!1}},[j7,Z,I5,D7,w5]),u.useEffect(()=>{if(!I5){R0([]),G8([]),t8([]),wX(0);return}let j=J0??B?.artboardId??null,t=(j&&q7.find((B0)=>B0.artboardId===j||B0.id===j)||q7[0])?.durationInFrames||0,W0=dh(I5,t,j);gQ(W0.artboardId??j??null);let F0=W0.sequences.map((B0,k0)=>{let d=VQ[k0];if(!d)return B0;return{...B0,stableId:d.stableId,contentHash:d.contentHash,mediaProps:d.mediaProps??null,placeholder:d.placeholder??null,mediaTag:d.mediaTag??B0.mediaTag,mediaSrc:d.mediaSrc??B0.mediaSrc,replaceable:!!(d.mediaCdId||d.mediaArrayRef),layers:Array.isArray(d.layers)?d.layers:[],hidden:!!d.hidden}});R0(F0),G8(W0.audio||[]),t8(W0.transitions||[]),wX(W0.total)},[I5,VQ,B,q7,J0]);let oX=u.useCallback(()=>{X4((j)=>{let b=!j,t=Z?m8.current.get(Z):null;if(t&&t.contentWindow)try{t.contentWindow.postMessage({dgn:"view-annotations",visible:b},"*")}catch{}return b})},[Z]),UX=u.useCallback((j)=>{for(let b of m8.current.values())try{b.contentWindow.postMessage({dgn:"view-chrome",...j},"*")}catch{}},[]),o0=u.useCallback(()=>{WH((j)=>{let b=!j;return UX({minimap:b}),b})},[UX]),qQ=u.useCallback(()=>{GH((j)=>{let b=!j;return UX({zoom:b}),b})},[UX]),r0=u.useCallback(()=>{eW((j)=>{let b=!j;return UX({present:b}),b})},[UX]),iQ=u.useCallback(()=>{eW(!1),UX({present:!1})},[UX]),GG=u.useCallback(()=>{if(!Z||Z===d8)return;cX((j)=>{let b=!j;return M8({dgn:"view-chrome",print:b}),fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{overlays:{print:b}}})}).catch(()=>{}),b})},[Z,M8]);u.useEffect(()=>{let j=!1;return fetch("/_api/git-user").then((b)=>b.json()).then((b)=>{if(j)return;let t=b&&typeof b.name==="string"?b.name.trim():"";if(t)yK(t)}).catch(()=>{}),()=>{j=!0}},[]),u.useEffect(()=>{if(!Z||Z===d8){HQ(0),cX(!1);return}let j=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(Z)).then((b)=>b.json()).then((b)=>{if(j)return;let t=Array.isArray(b?.artboards)?b.artboards.length:0;HQ(t),cX(b?.overlays?.print===!0),nQ(new Set(Array.isArray(b?.locked)?b.locked:[]))}).catch(()=>{if(!j)HQ(0),cX(!1),nQ(new Set)}),()=>{j=!0}},[Z]),u.useEffect(()=>{if(!Z||Z===d8||!J0)return;let j=setTimeout(()=>{M8({dgn:"request-layers",artboardId:J0})},250);return()=>clearTimeout(j)},[Z,J0,M8]);let[oQ,nQ]=u.useState(()=>new Set),ZG=u.useCallback((j)=>{if(!Z||Z===d8)return;nQ((b)=>{let t=new Set(b);if(t.has(j))t.delete(j);else t.add(j);let W0=[...t];return fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{locked:W0}})}).catch(()=>{}),M8({dgn:"locked-set",locked:W0}),t})},[Z,M8]);u.useEffect(()=>{if(!Z||Z===d8)return;M8({dgn:"locked-set",locked:[...oQ]})},[oQ,Z,M8]),u.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",T9),localStorage.setItem(K00,T9)}catch{}for(let j of m8.current.values())try{j.contentWindow.postMessage({dgn:"theme",theme:T9},"*")}catch{}},[T9]),u.useEffect(()=>{try{localStorage.setItem(je,w9?"1":"0")}catch{}},[w9]),u.useEffect(()=>{try{localStorage.setItem(Se,_6?"1":"0")}catch{}},[_6]),u.useEffect(()=>{try{localStorage.setItem(be,JSON.stringify(s9))}catch{}},[s9]),u.useEffect(()=>{try{localStorage.setItem(fe,mJ?"1":"0")}catch{}},[mJ]),u.useEffect(()=>{try{localStorage.setItem(ve,uJ?"1":"0")}catch{}},[uJ]),u.useEffect(()=>{try{localStorage.setItem(he,dX?"1":"0")}catch{}},[dX]),u.useEffect(()=>{let j=!1;return fetch("/_api/ui-prefs").then((b)=>b.ok?b.json():Promise.reject(Error(`HTTP ${b.status}`))).then((b)=>{if(j||!b||typeof b!=="object")return;if(b.theme==="light"||b.theme==="dark")Y9(b.theme);if(typeof b.minimap==="boolean")WH(b.minimap);if(typeof b.zoom==="boolean")GH(b.zoom);if(typeof b.annotations==="boolean")X4(b.annotations);if(typeof b.autoOpenInspector==="boolean")cW(b.autoOpenInspector);if(b.panelSides&&typeof b.panelSides==="object")_5({...wK,...b.panelSides});if(b.layersMode==="separate"||b.layersMode==="in-inspector")lY(b.layersMode)}).catch(()=>{}).finally(()=>{if(!j)SK(!0)}),()=>{j=!0}},[]),u.useEffect(()=>{if(!YH)return;Iq0({theme:T9,minimap:mJ,zoom:uJ,annotations:dX,autoOpenInspector:xJ,panelSides:u7,layersMode:H7})},[YH,T9,mJ,uJ,dX,xJ,u7,H7]),u.useEffect(()=>{try{localStorage.setItem(xe,JSON.stringify(u7))}catch{}},[u7]),u.useEffect(()=>{try{localStorage.setItem(ge,H7)}catch{}},[H7]);let HG=u.useCallback((j,b)=>{m7((t)=>{let W0=t[j],F0=W0===void 0?b:W0;return{...t,[j]:!F0}})},[]),k5=u.useCallback(()=>{Y9((j)=>j==="dark"?"light":"dark")},[]),W7=u.useCallback(async()=>{try{let b=await(await fetch("/_index-data")).json();Y(b.project||"Design");let t=b.groups.map((W0)=>({...W0,tree:jq0(W0.paths,W0.stripPrefix,W0.dirs)}));J(t),c0((W0)=>({...W0,canvasDesignSystems:b.canvasDesignSystems??{},canvasKinds:b.canvasKinds??{}}))}catch(j){console.error("failed to load tree",j)}},[]);u.useEffect(()=>{W7()},[W7]);let lJ=u.useCallback(async(j)=>{try{let b=j?`/_system-data?ds=${encodeURIComponent(j)}`:"/_system-data",t=await fetch(b);if(!t.ok){console.error("failed to load system-data",t.status);return}let W0=await t.json();if(!j&&W0?.defaultDesignSystem&&!W0.ds){b8(W0);let F0=await fetch(`/_system-data?ds=${encodeURIComponent(W0.defaultDesignSystem)}`);if(F0.ok)b8(await F0.json());return}b8(W0)}catch(b){console.error("failed to load system-data",b)}},[]),W4=u.useCallback(async()=>{try{let b=await(await fetch("/_comments-all")).json();m0(b||{})}catch(j){console.error("failed to load comments",j)}},[]);u.useEffect(()=>{W4()},[W4]),u.useEffect(()=>{let j=null;function b(){let t=location.protocol==="https:"?"wss:":"ws:",W0=new WebSocket(t+"//"+location.host+"/_ws");KQ.current=W0,W0.addEventListener("open",()=>{s(!0),clearInterval(j),j=setInterval(()=>{if(W0.readyState===WebSocket.OPEN)W0.send('{"type":"ping"}')},25000)}),W0.addEventListener("close",()=>{s(!1),clearInterval(j),setTimeout(b,1000)}),W0.addEventListener("error",()=>{}),W0.addEventListener("message",(F0)=>{try{let B0=JSON.parse(F0.data);if(B0.type==="snapshot"&&B0.state)N((k0)=>G00(B0.state.selected,k0));else if(B0.type==="selected"){if(Date.now()-R.current<2000)return;let k0=B0.selected,d=Array.isArray(k0)?k0[0]:k0,_0=F.current,L0=Array.isArray(_0)?_0[0]:_0;if(N((p0)=>G00(k0,p0)),d?.id&&d.file&&(!L0||L0.id!==d.id||L0.file!==d.file))O(d)}else if(B0.type==="comments"&&typeof B0.file==="string")m0((k0)=>({...k0,[B0.file]:B0.comments||[]}));else if(B0.type==="ai-activity"&&typeof B0.file==="string"){if(zQ(!0),pQ.current)clearTimeout(pQ.current);pQ.current=setTimeout(()=>zQ(!1),8000);for(let k0 of m8.current.values())try{k0.contentWindow.postMessage({dgn:"ai-activity",file:B0.file,entry:B0.entry},"*")}catch{}}else if(B0.type==="export:job"&&B0.payload)sY.upsert(B0.payload);else if(B0.type==="sync:status"&&B0.payload)X0(B0.payload);else if(B0.type==="canvas-list-update"){if(W7(),B0.payload?.action==="moved"&&B0.payload.fromRel&&B0.payload.rel){let k0=(S0?.designRel||S0?.designRoot||".design").replace(/^\/+|\/+$/g,""),d=`${k0}/${B0.payload.fromRel}`,_0=`${k0}/${B0.payload.rel}`;G((L0)=>L0.map((p0)=>p0.path===d?{path:_0}:p0)),H((L0)=>L0===d?_0:L0)}}else if(B0.type==="config-updated")N8();else if(B0.type==="acp-focus"){if(X9())gJ("assistant")}else if(B0.type==="git-status"&&B0.payload)z0(B0.payload);else if(B0.type==="git-lifecycle"&&B0.payload){c(B0.payload);for(let k0 of m8.current.values())try{k0.contentWindow.postMessage({dgn:"git-lifecycle",payload:B0.payload},"*")}catch{}}}catch{}})}return b(),()=>{if(clearInterval(j),KQ.current)KQ.current.close()}},[W7,N8]);function T7(j){let b=KQ.current;try{if(b&&b.readyState===1)b.send(JSON.stringify(j))}catch{}}let VX=u.useCallback(async()=>{try{let j=await fetch("/_api/git/status");if(j.ok)z0(await j.json())}catch{}},[]),kX=u.useCallback(async()=>{try{let j=await fetch("/_api/git/status?remote=1");if(!j.ok)return;let b=await j.json();if(b&&b.repo!==!1)X8({remoteAhead:!!b.remoteAhead,behind:b.behind||0})}catch{}},[]),qX=u.useCallback(async(j,b)=>{try{let t=await fetch(j,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b||{})}),W0=await t.json().catch(()=>({}));return{ok:t.ok,...W0}}catch(t){return{ok:!1,error:"Network error — is the project still open?"}}},[]),zG=u.useCallback(async(j,b)=>{let t=await qX("/_api/git/commit",{message:j,files:b});if(t.ok)await VX();return t},[qX,VX]),G4=u.useCallback(async(j)=>{let b=await qX("/_api/git/discard",{files:j});if(b.ok)await VX();return b},[qX,VX]),KG=u.useCallback(async()=>{let j=await qX("/_api/git/push",{});if(j.ok)await VX(),kX();return j},[qX,VX,kX]),Z4=u.useCallback(async()=>{let j=await qX("/_api/git/pull",{});if(j.ok)await VX(),kX();if(j.conflict&&Array.isArray(j.files)&&j.files.length)z8({file:j.files[0],conflict:!0});return j},[qX,VX,kX]),UG=u.useCallback(async(j)=>{let b=await qX("/_api/git/resolve",{choice:j});if(b.ok)await VX(),kX();return b},[qX,VX,kX]),H4=u.useCallback(async(j)=>{try{let b="/_api/git/log?limit=40"+(j?`&path=${encodeURIComponent(j)}`:""),t=await fetch(b);if(!t.ok)return[];return(await t.json()).entries||[]}catch{return[]}},[]),VG=u.useMemo(()=>{let j={modified:"M",added:"A",deleted:"D",untracked:"U"},b=new Map;for(let t of D0?.files||[])b.set(t.path,j[t.status]);return b},[D0]),z4=!!S0.cloud,K4=!S0.cloud&&!!H0?.credentialed,rQ=z4||K4,U4=rQ?0:D0?.files?.length||0;u.useEffect(()=>{if(D0?.repo===!1)return;kX();let j=setInterval(kX,d0?60000:120000);return()=>clearInterval(j)},[D0?.repo,d0,kX]);let H6=u.useCallback((j)=>{if(G((b)=>{for(let t of b)if(t.path!==j)m8.current.delete(t.path);return[{path:j}]}),H(j),K8(null),U(null),j!==d8)p9(j)},[]),V4=u.useRef(!1);u.useEffect(()=>{if(V4.current)return;if(!S0.cloud)return;if(W.length>0)return;if(!X.length)return;let j=null;for(let b of X){for(let t of b.paths||[]){if(!JQ.test(t))continue;if(/(^|\/)system\//.test(t))continue;j=t;break}if(j)break}if(!j)return;V4.current=!0,H6(j)},[S0.cloud,X,W.length,H6]);let pJ=u.useCallback((j)=>{let b=typeof j==="string"?j:void 0;if(b)lJ(b);else if(!W8)lJ();H6(d8)},[W8,lJ,H6]);u.useEffect(()=>{T7({type:"tabs",tabs:W.map((j)=>j.path).filter((j)=>j!==d8)})},[W]),u.useEffect(()=>{if(Z&&Z!==d8)T7({type:"active",file:Z});else if(Z===d8)T7({type:"active",file:""});else T7({type:"active",file:""})},[Z]);let aQ=u.useCallback((j)=>{G((b)=>{let t=b.findIndex((F0)=>F0.path===j);if(t<0)return b;let W0=b.filter((F0)=>F0.path!==j);if(j===Z)if(W0.length===0)H(null);else H(W0[Math.max(0,t-1)].path);return W0}),m8.current.delete(j),p9((b)=>b===j?null:b)},[Z]),qJ=u.useCallback(()=>{if(!Z||Z===d8){if(Z===d8)lJ();return}let j=m8.current.get(Z);if(j)j.src=j.src},[Z,lJ]),q4=u.useCallback(()=>W7(),[W7]),[qG,B4]=u.useState(!1),sQ=u.useRef(!1),tQ=u.useCallback(async()=>{if(sQ.current)return;sQ.current=!0,B4(!0);try{await Promise.all([W7(),new Promise((j)=>setTimeout(j,550))])}finally{sQ.current=!1,B4(!1)}},[W7]);u.useEffect(()=>{let j=null,b=()=>{if(j)clearTimeout(j);j=setTimeout(()=>{j=null,q4()},150)};return window.addEventListener("focus",b),()=>{if(window.removeEventListener("focus",b),j)clearTimeout(j)}},[q4]);let BG=u.useCallback(async(j)=>{try{let b=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j,kind:"brief-board"})}),t=await b.json().catch(()=>({}));if(!b.ok||!t.ok)return{ok:!1,error:t.error||`create failed (${b.status})`};return await W7(),H6(t.file),{ok:!0,file:t.file}}catch(b){return{ok:!1,error:b instanceof Error?b.message:"network error"}}},[W7,H6]),N4=u.useCallback(async()=>{let j=await KX("New video name");if(!j)return;let t=(await KX("Size — 1920x1080 (landscape), 1080x1920 (portrait), 1080x1080 (square), or custom WxH","1920x1080")||"1920x1080").toLowerCase().match(/(\d{2,5})\s*[x×]\s*(\d{2,5})/),W0=t?Number(t[1]):1920,F0=t?Number(t[2]):1080,B0=Math.max(1,Math.min(60,Number(await KX("Frames per second","30"))||30));try{let k0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j,kind:"video-comp",clips:[],fps:B0,width:W0,height:F0})}),d=await k0.json().catch(()=>({}));if(!k0.ok||!d.ok){x8(`New video failed: ${d.error||`error ${k0.status}`}`);return}await W7(),H6(d.file),n9(!0),x8("New video created — drop clips on the timeline to start the cut.",!0)}catch(k0){x8(`New video failed: ${k0 instanceof Error?k0.message:"network error"}`)}},[W7,H6,KX]),NG=u.useCallback(async()=>{if(!Z||Z===d8)return;try{let j=await fetch(`/_api/annotations?file=${encodeURIComponent(Z)}`),b=j.ok?await j.text():"",t=[];if(b){let d=new DOMParser().parseFromString(b,"image/svg+xml");for(let _0 of d.querySelectorAll('[data-tool="mediaref"]')){let L0=_0.getAttribute("data-src");if(!L0)continue;t.push({src:L0,mediaKind:_0.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(t.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let F0=`${gW(RK(Z)).replace(/\.tsx$/i,"")} Video`,B0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:F0,kind:"video-comp",clips:t})}),k0=await B0.json().catch(()=>({}));if(!B0.ok||!k0.ok){window.alert(`Assemble failed: ${k0.error||`error ${B0.status}`}`);return}await W7(),H6(k0.file)}catch(j){window.alert(`Assemble failed: ${j instanceof Error?j.message:"network error"}`)}},[Z,W7,H6]),eQ=u.useCallback(({accept:j,resolveTarget:b})=>{let t=Z,W0=D7||void 0,F0=document.createElement("input");F0.type="file",F0.accept=j,F0.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(F0);let B0=()=>{if(F0.isConnected)F0.remove()};window.addEventListener("focus",()=>setTimeout(B0,300),{once:!0}),F0.addEventListener("change",()=>{let k0=F0.files?.[0];if(B0(),!k0)return;let d=`/_api/comp-clips?canvas=${encodeURIComponent(t)}${W0?`&artboardId=${encodeURIComponent(W0)}`:""}`;fetch(d).then((_0)=>_0.json().catch(()=>({}))).then((_0)=>{let L0=b(_0);if(!L0)return x8("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":k0.type||"application/octet-stream"},body:k0}).then((p0)=>p0.json().catch(()=>({}))).then((p0)=>{if(!p0?.path)return x8(`Upload failed: ${p0?.error||"unknown error"}`),null;if(L0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:t,arrayName:L0.arrayRef.arrayName,index:L0.arrayRef.index,field:L0.arrayRef.field,value:p0.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:t,id:L0.cdId,attr:"src",value:p0.path})})})}).then((_0)=>_0?_0.json():null).then((_0)=>{if(_0&&!_0.ok)x8(`Replace refused: ${_0.error||"failed"}`);else if(_0&&_0.ok){if(x8("Media replaced.",!0),_0.seq!=null)R7(t,_0.seq,"replace media")}}).catch(()=>x8("Replace failed: network error"))}),F0.click()},[Z,D7,R7]),FG=u.useCallback(async(j,b)=>{if(!window.confirm(`Move “${b}” to trash?
|
|
5653
|
+
`).length," lines, paths & secrets scrubbed) —"," ",M("details",{className:"rb-details",children:[z("summary",{children:"view"}),z("pre",{className:"rb-log",children:H.logs.serverLogTail})]})]})]}):null,X9()&&B.length>0&&M("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.crashLogs,onChange:(p)=>D({...F,crashLogs:p.target.checked})}),M("span",{children:["Crash logs (",B.length,") — ",z("code",{children:B.map((p)=>p.name).join(", ")})]})]})]}),M("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."]}),M("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:o,children:"Send report"})]})]}),Y==="sending"&&z("p",{className:"rb-hint",children:"Sending your report…"}),Y==="done"&&M(G0,{children:[P?.issueUrl?M("p",{children:["Thank you — your report is filed as"," ",M("button",{type:"button",className:"rb-link","data-testid":"report-bug-issue-link",onClick:()=>{if(X9())uU(P.issueUrl).catch(()=>navigator.clipboard?.writeText(P.issueUrl));else window.open(P.issueUrl,"_blank","noopener")},children:["report #",P.issueNumber]})," ","on the public Maude issue tracker. Screenshots and logs stay in a private repository only maintainers can open — the issue links to them."]}):M("p",{children:["The bundle is saved locally",P?.fallbackDir?M(G0,{children:[" ","at ",z("code",{children:P.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:h,children:"Done"})})]}),Y==="fallback"&&M(G0,{children:[z("p",{className:"rb-error","data-testid":"report-bug-error",children:k}),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."}),M("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:x,children:"Save locally & open GitHub"})]})]})]})]})})}var ZJ=v8(p8(),1);function qx(X){if(typeof X!=="string")return null;let J=X.match(/^(\d+)\.(\d+)\.(\d+)/);return J?[Number(J[1]),Number(J[2]),Number(J[3])]:null}function Bx(X,J){let Q=qx(X),Y=qx(J);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 Nx(X,J){if(!Array.isArray(X))return[];return X.filter((Q)=>Q&&(Q.version==null||Bx(Q.version,J)))}function Fx(X,J){let Q=J;if(Array.isArray(X)){for(let Y of X)if(Y&&Y.version&&Bx(Y.version,Q))Q=Y.version}return Q}var aA="mdcc-whatsnew-seen",sA="mdcc-whatsnew-toast-dismissed";function Fz0(X){return typeof X==="string"&&/^https?:\/\//i.test(X)}function Lz0(X){try{let J=localStorage.getItem(aA);if(J)return J;localStorage.setItem(aA,X)}catch{}return X}function Dz0(){try{return localStorage.getItem(sA)}catch{return null}}function Lx(X){let[J,Q]=ZJ.useState([]),[Y,W]=ZJ.useState(X),[G,Z]=ZJ.useState(()=>Lz0(X)),[H,K]=ZJ.useState(()=>Dz0()),[U,q]=ZJ.useState(!1);ZJ.useEffect(()=>{let O=!1,P=()=>{fetch("/_api/whats-new").then(($)=>$.json()).then(($)=>{if(O)return;if(Q(Array.isArray($?.entries)?$.entries:[]),typeof $?.version==="string")W($.version)}).catch(()=>{})};P();let I=()=>P(),k=()=>{if(document.visibilityState==="visible")P()};return window.addEventListener("focus",I),document.addEventListener("visibilitychange",k),()=>{O=!0,window.removeEventListener("focus",I),document.removeEventListener("visibilitychange",k)}},[]);let B=Nx(J,G),N=B.length>0&&H!==Y&&!U,F=B[0]??null,D=ZJ.useCallback(()=>{let O=Fx(J,Y);Z(O),K(Y);try{localStorage.setItem(aA,O),localStorage.setItem(sA,Y)}catch{}},[J,Y]),_=ZJ.useCallback(()=>{K(Y);try{localStorage.setItem(sA,Y)}catch{}},[Y]),R=ZJ.useCallback(()=>q(!0),[]),w=ZJ.useCallback(()=>{q(!1),D()},[D]);return{entries:J,unseen:B,feedVersion:Y,panelOpen:U,openPanel:R,closePanel:w,showToast:N,toastEntry:F,dismissToast:_,markAllSeen:D}}function Dx({wn:X}){if(!X.showToast||!X.toastEntry)return null;let J=X.toastEntry,Q=X.unseen.length;return M("div",{className:"st-toast",role:"status","aria-live":"polite",children:[z("button",{type:"button",className:"st-toast-close","aria-label":"Dismiss",onClick:X.dismissToast,children:"×"}),M("div",{className:"st-toast-hd",children:[z("span",{"aria-hidden":"true",children:"✦"}),"What's new",J.version?` · v${J.version}`:""]}),z("div",{className:"st-toast-title",children:J.title}),z("div",{className:"st-toast-txt",children:J.summary}),M("div",{className:"st-toast-actions",children:[z("button",{type:"button",className:"btn btn--primary btn--sm",onClick:X.openPanel,children:Q>1?`See all (${Q})`:"Details"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X.dismissToast,children:"Dismiss"})]})]})}function Ox({wn:X,onStartTour:J}){let{panelOpen:Q,closePanel:Y}=X;if(ZJ.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(X.unseen.map((G)=>G.id));return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)Y()},children:M("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[M("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:X.entries.length===0?z("p",{className:"mdcc-wn-empty",children:"Nothing new yet."}):z("ul",{className:"mdcc-wn-list",children:X.entries.map((G)=>M("li",{className:"mdcc-wn-item"+(W.has(G.id)?" is-unseen":""),children:[M("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}),Fz0(G.learnMore)&&z("a",{className:"mdcc-wn-item__more",href:G.learnMore,target:"_blank",rel:"noreferrer",children:"Learn more →"}),J&&Array.isArray(G.tour)&&G.tour.length>0&&z("button",{type:"button",className:"mdcc-wn-item__tour",onClick:()=>{Y(),J(G.tour)},children:"▶ Take tour"})]},G.id))})})]})})}var Y7=({as:X,size:J=14})=>z(X,{size:J,strokeWidth:1.75,style:{display:"block"}}),Ce="mdcc-usage-tour-seen",$e="mdcc-collab-tour-seen",d8="__system__",K00="mdcc-theme",Se="mdcc-show-hidden",be="mdcc-sections-expanded",ye="maude-cp-mode",je="mdcc-sidebar-open",fe="mdcc-minimap-visible",ve="mdcc-zoomctl-visible",he="mdcc-annotations-visible";var Tq0=30000;function Iq0(X){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(X)}).catch(()=>{})}catch{}}var lR=[{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"}],wK={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",sync:"right",assistant:"right"},xe="mdcc-panel-sides",ge="mdcc-layers-mode";function me({side:X,width:J,open:Q,ids:Y,activeId:W,onPick:G,children:Z,labels:H=null}){return M("div",{className:"st-dockslot st-dockslot--"+X+(Q?"":" is-collapsed"),style:{width:Q?J:0,flexBasis:Q?J:0},children:[Q&&Y.length>1&&z("div",{className:"st-docktabs",role:"tablist","aria-label":X+" panels",children:Y.map((K)=>z("button",{type:"button",role:"tab","aria-selected":W===K,className:"st-docktab"+(W===K?" is-active":""),onClick:()=>G(K),children:H?.[K]||(lR.find((U)=>U.id===K)||{}).label||K},K))}),Z]})}var JQ=/\.(tsx|html?)$/i,kq0=[[/\.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 pR(X){for(let[J,Q]of kq0)if(J.test(X))return Q;return null}function LF(X){return X.replace(/^\.[^/]+\//,"").replace(JQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}var dR="0.60.5";function ue(X,J){let Q=()=>{try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(X,{body:J})}catch{}};if(X9()){S7("send_notification",{title:X,body:J}).catch(Q);return}Q()}function Cq0(){if(typeof window>"u")return"dark";try{let X=localStorage.getItem(K00);if(X==="light"||X==="dark")return X}catch{}return"dark"}function sZ(X,J){if(typeof window>"u")return J;try{let Q=localStorage.getItem(X);if(Q==="1")return!0;if(Q==="0")return!1}catch{}return J}function hR(X,J){if(typeof window>"u")return J;try{let Q=localStorage.getItem(X);return Q?JSON.parse(Q):J}catch{return J}}function $q0(X){if(X.kind==="runtime")return!1;if(X.label==="Design system")return!1;return!0}function RK(X){return X.split("/").pop()}function x8(X,J=!1,Q){if(typeof document>"u")return;let Y=document.getElementById("st-op-toast");if(!Y)Y=document.createElement("div"),Y.id="st-op-toast",Y.setAttribute("role","status"),Y.style.cssText="position:fixed;left:50%;bottom:64px;transform:translateX(-50%);z-index:80;display:flex;align-items:center;gap:10px;max-width:440px;padding:8px 14px;border-radius:8px;font:12px/1.45 var(--font-mono,monospace);box-shadow:0 8px 28px rgba(0,0,0,.34);pointer-events:none;opacity:0;transition:opacity 140ms ease;",document.body.appendChild(Y);Y.style.background=J?"#1d3524":"#3a1d1d",Y.style.color=J?"#b7e4c0":"#f1b8b8",Y.textContent="";let W=document.createElement("span");if(W.textContent=X,Y.appendChild(W),Q){let G=document.createElement("button");G.type="button",G.textContent=Q.label,G.style.cssText="pointer-events:auto;background:none;border:0;text-decoration:underline;color:inherit;font:inherit;cursor:pointer;padding:0;",G.onclick=()=>{Q.onClick(),Y.style.opacity="0",Y.style.pointerEvents="none"},Y.appendChild(G)}Y.style.opacity="1",Y.style.pointerEvents=Q?"auto":"none",clearTimeout(x8._t),x8._t=setTimeout(()=>{Y.style.opacity="0",Y.style.pointerEvents="none"},Q?6000:3200)}var le="maude-browse-hint-seen";function Sq0(X=!1){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(le)==="1")return}catch{return}if(document.getElementById("st-browse-hint"))return;let J=document.createElement("div");J.id="st-browse-hint",J.setAttribute("role","status"),J.style.cssText="position:fixed;left:50%;bottom:64px;transform:translateX(-50%);z-index:81;display:flex;align-items:center;gap:10px;max-width:520px;padding:10px 14px;border-radius:10px;font:12px/1.5 var(--font-ui,system-ui,sans-serif);background:var(--surface-2,#1b1e24);color:var(--text-1,#e7eaf0);border:1px solid var(--border-1,#333a45);box-shadow:0 10px 34px rgba(0,0,0,.42);opacity:0;transition:opacity 160ms ease;",J.innerHTML="<span>Your mock is <strong>live</strong> — click things to try it. "+'Press <kbd style="padding:1px 6px;border-radius:5px;border:1px solid var(--border-1,#333a45);background:var(--surface-3,#262b33);font-family:var(--font-mono,monospace)">V</kbd> '+(X?"to select & inspect.</span>":"to select & edit like Figma.</span>")+'<button type="button" aria-label="Dismiss" style="background:none;border:none;color:inherit;'+'cursor:pointer;font-size:15px;line-height:1;opacity:.65;padding:2px">×</button>';let Q=()=>{try{localStorage.setItem(le,"1")}catch{}J.style.opacity="0",setTimeout(()=>J.remove(),200),document.removeEventListener("keydown",Y,!0)},Y=(W)=>{if((W.key==="v"||W.key==="V")&&!W.metaKey&&!W.ctrlKey&&!W.altKey)Q()};J.querySelector("button")?.addEventListener("click",Q),document.addEventListener("keydown",Y,!0),document.body.appendChild(J),requestAnimationFrame(()=>{J.style.opacity="1"}),setTimeout(Q,9000)}function gW(X){return X.replace(JQ,"")}function bq0(X){return X.replace(JQ,"")}function yq0(X){let J=new Map;for(let G of X){if(!JQ.test(G.name))continue;let Z=bq0(G.name);if(!J.has(Z)||/\.tsx$/i.test(G.name))J.set(Z,G)}let Q=new Map,Y=[];for(let G of X){if(JQ.test(G.name))continue;let Z=null;for(let H of J.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 J){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 jq0(X,J,Q){let Y={};for(let W of Q||[]){let Z=(W.startsWith(J)?W.slice(J.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 X){let Z=(W.startsWith(J)?W.slice(J.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 U00(X,J){if(!J)return X;let Q=J.toLowerCase(),Y={},W=!1,G=Object.keys(X).filter((Z)=>Z!=="_files");for(let Z of G){let H=U00(X[Z],J);if(H)Y[Z]=H,W=!0}if(X._files){let Z=X._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 NF(X){return(X||[]).filter((J)=>J.status!=="resolved").length}function fq0(X){if(!X)return"";let J=new Date(X).getTime();if(!J)return"";let Q=Math.max(0,Math.floor((Date.now()-J)/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(X).toLocaleDateString()}function V00(X){let J=0,Q=0,Y=0;for(let W of Object.values(X||{}))for(let G of W||[])if(J++,G.status==="resolved")Y++;else Q++;return{all:J,open:Q,resolved:Y}}function DF({d:X,size:J=14,color:Q}){return z("svg",{width:J,height:J,viewBox:"0 0 24 24",fill:"none",stroke:Q||"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{flex:"none"},children:z("path",{d:X})})}var vq0={"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:M(G0,{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":M(G0,{children:[z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),z("path",{d:"M8 7.5v3.5M6.25 9.25h3.5"})]}),lock:M(G0,{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:M(G0,{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:M(G0,{children:[z("circle",{cx:"7",cy:"7",r:"4"}),z("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:M(G0,{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:M(G0,{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:M(G0,{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:M(G0,{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:M(G0,{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":M(G0,{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:M(G0,{children:[z("circle",{cx:"8",cy:"8",r:"5.6"}),z("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:M(G0,{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:M(G0,{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:M(G0,{children:[z("polyline",{points:"4 4 12 4"}),z("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:M(G0,{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:M(G0,{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:M(G0,{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:M(G0,{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:M(G0,{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:M(G0,{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":M(G0,{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":M(G0,{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":M(G0,{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":M(G0,{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":M(G0,{children:[z("path",{d:"M3 13 6.6 3l3.6 10"}),z("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":M(G0,{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:M(G0,{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:M(G0,{children:[z("polyline",{points:"6 5 3 8 6 11"}),z("polyline",{points:"10 5 13 8 10 11"})]}),download:M(G0,{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:M(G0,{children:[z("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),z("path",{d:"M14 2v3.33h-3.33"})]}),help:M(G0,{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:M(G0,{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:M(G0,{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:M(G0,{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:M(G0,{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:M(G0,{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:M(G0,{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:M(G0,{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 hq0({open:X,onClose:J,actions:Q}){let[Y,W]=u.useState(""),[G,Z]=u.useState(0),H=u.useRef(null);u.useEffect(()=>{if(X)W(""),Z(0)},[X]),u.useEffect(()=>{H.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[G]);let K=u.useMemo(()=>{let q=Y.trim().toLowerCase();if(!q)return Q;return Q.filter((B)=>B.label.toLowerCase().includes(q)||B.group&&B.group.toLowerCase().includes(q))},[Y,Q]);if(u.useEffect(()=>{if(G>=K.length)Z(0)},[K.length,G]),!X)return null;let U=(q)=>{J(),q.run()};return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(q)=>{if(q.target===q.currentTarget)J()},children:M("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[M("div",{className:"st-pal-search",children:[z(A9,{name:"search",size:18}),z("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(q)=>W(q.target.value),onKeyDown:(q)=>{if(q.key==="Escape")q.preventDefault(),J();else if(q.key==="ArrowDown")q.preventDefault(),Z((B)=>Math.min(K.length-1,B+1));else if(q.key==="ArrowUp")q.preventDefault(),Z((B)=>Math.max(0,B-1));else if(q.key==="Enter"){if(q.preventDefault(),K[G])U(K[G])}}}),z(MX,{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((q,B)=>{let N=q.group&&(B===0||K[B-1].group!==q.group)?z("div",{className:"st-pal-group",children:q.group},"g-"+q.group):null;return M(G0,{children:[N,M("button",{type:"button",className:"st-pal-item"+(B===G?" is-active":""),onMouseEnter:()=>Z(B),onClick:()=>U(q),children:[z("span",{className:"st-pal-icon",children:z(A9,{name:q.icon,size:15})}),z("span",{className:"st-pal-label",children:q.label}),q.kbd?z("span",{className:"st-pal-kbd",children:z(MX,{children:q.kbd})}):null]})]},q.id)})})]})})}function A9({name:X,size:J=16,className:Q}){return z("svg",{className:Q,width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:vq0[X]})}function xq0(X){if(!X||typeof X!=="string")return"?";let J=X.trim().split(/[\s._-]+/).filter(Boolean);if(!J.length)return"?";if(J.length===1)return J[0].slice(0,2).toUpperCase();return((J[0][0]||"")+(J[J.length-1][0]||"")).toUpperCase()||"?"}function pe({initials:X,hue:J,title:Q,pulse:Y}){return z("span",{className:"st-avatar"+(Y?" is-pulsing":""),style:{"--av-hue":J},"data-tip":Q,"aria-label":Q,children:X})}function MX({children:X}){return z("span",{className:"kbd",children:X})}function de(X,{min:J,max:Q,def:Y}){let W=u.useCallback((K)=>Math.min(Q,Math.max(J,K)),[J,Q]),[G,Z]=u.useState(()=>{try{let K=parseInt(localStorage.getItem(X)||"",10);return Number.isFinite(K)?W(K):Y}catch{return Y}});u.useEffect(()=>{try{localStorage.setItem(X,String(G))}catch{}},[X,G]);let H=u.useCallback((K)=>Z((U)=>W(typeof K==="function"?K(U):K)),[W]);return{w:G,setW:H,min:J,max:Q,def:Y}}function ce({label:X,size:J,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:K,def:U}=J,q=W==="rtl"?-1:1;return z("div",{className:"st-grip"+(Y?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":X,"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*q);else if(B.key==="ArrowLeft")B.preventDefault(),Z((F)=>F-N*q);else if(B.key==="Home")B.preventDefault(),Z(H);else if(B.key==="End")B.preventDefault(),Z(K)},children:M("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 xR=[{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}],gR={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},gq0={png:["selection","artboard","canvas-as-separate"],pdf:["selection","artboard","canvas-as-separate"],svg:["selection","artboard","canvas-as-separate"],html:["artboard","canvas-as-separate"],pptx:["canvas-as-separate"],mp4:["artboard"],gif:["artboard"],webm:["artboard"],canva:["canvas-as-separate"],zip:["project-raw"]},mq0=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],I3=[{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}],uq0="2x",ie=[{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}],lq0="auto",pq0={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 dq0(X){let J=String(X||"").split(".").pop()?.toLowerCase();return pq0[J]||"application/octet-stream"}function cq0({designRel:X,onPick:J,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[Z,H]=u.useState(null),[K,U]=u.useState(!1),[q,B]=u.useState(null),[N,F]=u.useState(()=>new Set),[D,_]=u.useState({}),[R,w]=u.useState(W?"artboard":"annotation");u.useEffect(()=>{let x=!0;return fetch("/_api/assets").then((m)=>m.json()).then((m)=>{if(!x)return;let p=m.ok?m.assets:[];H(p),_((f)=>{let s={...f};for(let n of p)s[n.path]=n.kind;return s})}).catch(()=>x&&H([])),()=>{x=!1}},[]),u.useEffect(()=>{let x=(m)=>{if(m.key==="Escape")m.stopPropagation(),Q()};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[Q]);let O=Array.from(N).some((x)=>(D[x]||"image")!=="image"),P=!W||O,I=!W?"No artboard on this canvas":O?"Video/audio can only be added as annotations":"";u.useEffect(()=>{if(P&&R==="artboard")w("annotation")},[P,R]);let k=(x)=>{F((m)=>{let p=new Set(m);if(p.has(x))p.delete(x);else p.add(x);return p})},$=async(x)=>{let m=await fetch("/_api/asset",{method:"POST",headers:{"content-type":x.type||"application/octet-stream"},body:x}),p=await m.json().catch(()=>({}));if(m.ok&&p.path)return{ok:!0,path:p.path};return{ok:!1,error:p.error||`upload failed (HTTP ${m.status})`}},C=async(x)=>{if(!x)return;U(!0),B(null);let m=await $(x);if(U(!1),m.ok)J(m.path);else B(m.error)},y=(x)=>{if(typeof x==="string"&&x.startsWith("video/"))return"video";if(typeof x==="string"&&x.startsWith("audio/"))return"audio";return"image"},v=async(x)=>{if(!x.length)return;U(!0),B(null);let m=await Promise.all(x.map((s)=>$(s).then((n)=>({...n,file:s}))));U(!1);let p=m.filter((s)=>s.ok),f=m.length-p.length;if(f>0)B(`${f} of ${m.length} uploads failed`);if(p.length)_((s)=>{let n={...s};for(let c of p)n[c.path]=y(c.file.type);return n}),F((s)=>{let n=new Set(s);for(let c of p)n.add(c.path);return n})},h=async()=>{U(!0),B(null);try{if(Y){let p=(await Iv()||[]).map((f)=>new File([new Uint8Array(f.bytes)],f.name,{type:dq0(f.name)}));if(U(!1),p.length)await v(p);return}let x=await FZ();if(x?.bytes){await C(new Blob([new Uint8Array(x.bytes)]));return}}catch(x){B(x?.message||"open failed")}U(!1)},l=()=>{if(X9()){h();return}let x=document.createElement("input");if(x.type="file",x.accept="image/*,video/*",Y)x.multiple=!0;x.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(x);let m=()=>{if(x.isConnected)x.remove()};window.addEventListener("focus",()=>setTimeout(m,300),{once:!0}),x.addEventListener("change",()=>{let p=x.files?Array.from(x.files):[];if(m(),!p.length)return;if(Y)v(p);else C(p[0])}),x.click()},o=(x)=>`/${X}/${x}`;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(x)=>{if(x.target===x.currentTarget)Q()},children:M("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[M("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(A9,{name:"x",size:15})})]}),M("div",{className:"st-dialog-bd",children:[M("div",{className:"st-ap-toolbar",children:[z("button",{type:"button",className:"st-btn",onClick:l,disabled:K,children:K?"Uploading…":"Upload…"}),q&&z("span",{className:"st-ap-err",children:q})]}),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((x)=>{let m=Y&&N.has(x.path);return M("button",{type:"button",className:"st-ap-cell","data-selected":m?"true":void 0,"aria-pressed":Y?m:void 0,title:`${x.name} · ${Math.max(1,Math.round(x.size/1024))} KB`,onClick:()=>Y?k(x.path):J(x.path),children:[Y&&z("span",{className:"st-ap-check","aria-hidden":"true",children:m?z(A9,{name:"check",size:12}):null}),x.kind==="video"?z("video",{className:"st-ap-thumb",src:o(x.path),muted:!0,playsInline:!0}):z("img",{className:"st-ap-thumb",src:o(x.path),alt:x.name,loading:"lazy"}),z("span",{className:"st-ap-name",children:x.name})]},x.path)})})]}),Y&&N.size>0&&M("div",{className:"st-dialog-ft st-ap-confirm",children:[M("span",{className:"st-ap-count",children:[N.size," selected"]}),M("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":R==="artboard",disabled:P,onClick:()=>w("artboard"),children:"Add to artboard"}),z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":R==="annotation",onClick:()=>w("annotation"),children:"Add as annotation"})]}),P&&z("span",{className:"st-ap-dest-note",children:I}),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),R),children:"Insert"})]})]})})}function iq0({mode:X,initialScope:J,activePath:Q,hasComps:Y=!1,comps:W=[],activeArtboardId:G=null,selection:Z=null,onClose:H}){let[K,U]=u.useState(X==="handoff"?"shadcn":"png"),[q,B]=u.useState(J&&gR[J]?J:"artboard"),[N,F]=u.useState(2),[D,_]=u.useState(uq0),[R,w]=u.useState(!0),[O,P]=u.useState(!1),[I,k]=u.useState(!1),[$,C]=u.useState(!1),[y,v]=u.useState(lq0),[h,l]=u.useState(!0),[o,x]=u.useState(!1),[m,p]=u.useState(null),[f,s]=u.useState([]),n=xR.find(($0)=>$0.id===K)||xR[0],c=n.handoff?[]:gq0[n.format]||["artboard"],U0=900,X0=3600,H0=sz(W,PA(W,{artboardId:G})),r=H0?.durationInFrames||0,D0=H0?.fps||30,z0=n.temporal&&r>900,l0=n.temporal&&r>3600;u.useEffect(()=>{if(c.length&&!c.includes(q))B(c[0])},[c,q]);let X8=u.useCallback(()=>{fetch("/_api/export-history").then(($0)=>$0.json()).then(($0)=>s(Array.isArray($0?.history)?$0.history.slice(0,6):[])).catch(()=>{})},[]);u.useEffect(()=>{X8()},[X8]),u.useEffect(()=>{function $0(O0){if(O0.key==="Escape")O0.preventDefault(),H()}return window.addEventListener("keydown",$0),()=>window.removeEventListener("keydown",$0)},[H]);async function d0(){if(n.handoff){let i0=`/design:handoff ${Q&&Q!==d8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(i0)}catch{}p({ok:!0,msg:`Copied: ${i0} — run it in Claude Code.`});return}x(!0),p(null);let $0=n.temporal?{scale:N}:{};if(n.format==="png"){let O0=I3.find((i0)=>i0.id===D)||I3[1];if(O0.kind==="dpi")$0.dpi=O0.value;else $0.scale=O0.value}if(n.format==="mp4"||n.format==="webm")$0.audio=h;if(l0)$0.maxFrames=r;if(n.format==="pdf"){$0.pdfPrint={includeBleed:R,marks:{crop:I,registration:$}};let O0=ie.find((i0)=>i0.id===y)?.value;if(O0!==void 0)$0.dpi=O0}if(G)$0.artboardId=G;if(Z?.selector)$0.selection=Z;try{let O0=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:n.format,scope:q,options:$0})});if(!O0.ok){p({ok:!1,msg:await O0.text()||`Export failed (${O0.status})`}),x(!1);return}H()}catch(O0){p({ok:!1,msg:O0&&O0.message?O0.message:String(O0)}),x(!1)}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:($0)=>{if($0.target===$0.currentTarget)H()},children:M("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[M("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:H,children:z(A9,{name:"x",size:15})})]}),M("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:Q&&Q!==d8?`Format · ${gW(RK(Q))}`:"Format"}),z("div",{className:"st-fmt-grid",children:xR.filter(($0)=>!$0.temporal||Y).map(($0)=>M("button",{type:"button",className:"st-fmt"+($0.id===K?" is-on":""),onClick:()=>{U($0.id),p(null)},children:[z(A9,{name:$0.icon,size:16}),z("span",{className:"st-fmt-name",children:$0.label}),z("span",{className:"st-fmt-sub",children:$0.sub})]},$0.id))}),!n.handoff&&M("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-scope",children:"Scope"}),z("select",{id:"st-export-scope",className:"st-select",value:q,onChange:($0)=>B($0.target.value),children:c.map(($0)=>z("option",{value:$0,children:gR[$0]},$0))})]}),!n.handoff&&n.format==="png"&&M("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:D,onChange:($0)=>_($0.target.value),children:I3.map(($0)=>z("option",{value:$0.id,children:$0.label},$0.id))})]}),!n.handoff&&n.format==="png"&&z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let $0=I3.find((i0)=>i0.id===D)||I3[1],O0=$0.kind==="dpi"?$0.value/96:$0.value;return`${$0.label} ≈ ${Math.round(1440*O0)}×${Math.round(900*O0)} for a 1440×900 artboard.`})()}),!n.handoff&&n.temporal&&M("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:N,onChange:($0)=>F(Number($0.target.value)),children:mq0.map(($0)=>z("option",{value:$0.value,children:$0.label},$0.value))})]}),!n.handoff&&n.temporal&&M("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[N,"× the artboard's native resolution (e.g. 960×540 → ",960*N,"×",540*N,")."]}),z0&&M("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: ",r," frames (≈",Math.round(r/D0),"s).",l0?` 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."]}),!n.handoff&&n.format==="pdf"&&M(G0,{children:[M("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:y,onChange:($0)=>v($0.target.value),children:ie.map(($0)=>z("option",{value:$0.id,children:$0.label},$0.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)."}),z("div",{className:"st-dialog-row",children:M("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:R,onChange:($0)=>w($0.target.checked)}),"Include bleed"]})}),z("div",{className:"st-dialog-row",children:M("button",{type:"button",className:"st-dialog-lbl",style:{background:"none",border:0,padding:0,cursor:"pointer"},onClick:()=>P(($0)=>!$0),"aria-expanded":O,children:[O?"▾":"▸"," Marks"]})}),O&&M("div",{style:{padding:"0 12px 4px",display:"flex",flexDirection:"column",gap:6},children:[M("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:I,onChange:($0)=>k($0.target.checked)}),"Crop marks"]}),M("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:$,onChange:($0)=>C($0.target.checked)}),"Registration marks"]})]}),M("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.",q==="canvas-as-separate"?" One PDF page per artboard.":""]})]}),!n.handoff&&(n.format==="mp4"||n.format==="webm")&&z("div",{className:"st-dialog-row",children:M("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:h,onChange:($0)=>l($0.target.checked)}),"Export with audio"]})}),n.handoff&&M("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."]}),m&&z("div",{className:"callout "+(m.ok?"callout--success":"callout--error"),style:{fontSize:12},children:m.msg}),f.length>0&&M("div",{className:"st-export-recent",children:[z("div",{className:"st-rp-hd",children:"Recent"}),f.map(($0,O0)=>M("div",{className:"st-export-recent-row",children:[M("span",{children:[String($0.format||"").toUpperCase()," ·"," ",gR[$0.scope]||$0.scope]}),z("span",{className:"st-mono",children:$0.filename})]},O0))]})]}),M("div",{className:"st-dialog-ft",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:H,children:"Cancel"}),M("button",{type:"button",className:"btn btn--primary",disabled:o,onClick:d0,children:[z(A9,{name:"download",size:14}),n.handoff?"Copy handoff command":o?"Exporting…":`Export ${n.label}`]})]})]})})}var _F=12,AF=16;function oq0({name:X,depth:J,defaultOpen:Q,children:Y,dirPath:W,drag:G,menu:Z}){let[H,K]=u.useState(Q),U=G?G.dropProps(W,!0,()=>K(!0)):{},q=G?.overDir===W,B=G?G.dragProps(W,!0):{},N=G?.draggedPath===W,F=G?.busyPath===W,D=M("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${LF(W)}`,"aria-expanded":H,"aria-dropeffect":G?"move":void 0,"aria-busy":F||void 0,tabIndex:-1,className:"st-row"+(q?" is-drop-target":"")+(N?" is-dragging":"")+(F?" is-busy":""),style:{paddingLeft:_F+J*AF+"px"},onClick:()=>K((_)=>!_),onContextMenu:Z?(_)=>Z.openAt(_,{kind:"dir",dirPath:W}):void 0,...B,...U,children:[z("span",{className:"st-row-glyph",children:z(A9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:X})]});return M(G0,{children:[Z?M("div",{className:"st-row-wrap",role:"none",children:[D,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${LF(W)}`,title:`Folder actions — ${X}`,"aria-label":`Folder actions for ${X}`,"aria-haspopup":"menu",onClick:(_)=>Z.openAt(_,{kind:"dir",dirPath:W}),children:z(DF,{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})})]}):D,H&&Y]})}function nq0({name:X,dsName:J,depth:Q,defaultOpen:Y,active:W,onOpenSystem:G,children:Z}){let[H,K]=u.useState(Y);return M(G0,{children:[M("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:_F+Q*AF+"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(A9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),M("button",{type:"button",className:"st-ds-open",onClick:()=>G(J),"aria-label":`Open ${J} design system view`,title:"Open the design system view",children:[z("span",{className:"st-row-glyph",children:z(A9,{name:"folder",size:13})}),z("span",{className:"st-row-name",children:X})]})]}),H&&Z]})}function OF({file:X,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,onDelete:G,openCount:Z,depth:H,kind:K,sidecar:U,dirty:q,experimentalKind:B,drag:N,menu:F}){let D=X.path===J||X.path===Q,_=JQ.test(X.name),R=!_&&K!=="runtime"?pR(X.name):null,w=!_&&!R,O=_?gW(X.name):X.name,P=_&&typeof G==="function"&&K!=="runtime",I=_&&!U&&K!=="runtime"&&typeof N<"u",k=I?N.dragProps(X.path,!0):{},$=N?.draggedPath===X.path,C=N?.busyPath===X.path,y=I&&typeof F<"u",v=X.path.split("/").slice(0,-1).join("/"),h=_?"canvas-row-"+X.path.replace(/^\.[^/]+\//,"").replace(JQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,l=M("button",{type:"button",role:"treeitem","data-testid":h,"aria-selected":D,"aria-disabled":w?"true":void 0,"aria-busy":C||void 0,tabIndex:D?0:-1,className:"st-row"+(D?" is-sel":"")+(K==="runtime"?" is-muted":"")+($?" is-dragging":"")+(C?" is-busy":""),style:{paddingLeft:_F+H*AF+"px"},title:X.path+(Z?` — ${Z} open`:w?" (file index only)":""),onClick:()=>{if(_)Y(X.path);else if(R)W?.(X.path)},onContextMenu:y?(o)=>F.openAt(o,{kind:"file",path:X.path,dir:v}):void 0,...k,children:[z("span",{className:"st-row-glyph",children:z(A9,{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"}),q&&z("span",{className:"st-git-badge","data-kind":q,title:`Unsaved (${q})`,"aria-label":`Unsaved, ${q}`,children:q}),Z>0&&z("span",{className:"st-row-badge",children:Z})]});if(!P&&!y)return l;return M("div",{className:"st-row-wrap",role:"none",children:[l,y&&z("button",{type:"button",className:"st-row-menu-btn"+(P?" has-delete-sibling":""),"data-testid":`tree-row-menu-${LF(X.path)}`,title:`Move ${O}…`,"aria-label":`Actions for ${O}`,"aria-haspopup":"menu",onClick:(o)=>F.openAt(o,{kind:"file",path:X.path,dir:v}),children:z(DF,{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})}),P&&z("button",{type:"button",className:"st-row-del",title:`Delete ${O}`,"aria-label":`Delete canvas ${O}`,onClick:(o)=>{o.stopPropagation(),G(X.path,O)},children:z(DF,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})}function rq0({primary:X,sidecars:J,depth:Q,kind:Y,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,showHidden:q,forceOpen:B,dirtyByPath:N,experimentalKind:F,drag:D,menu:_}){let R=N?.get(X.path),w=J.length>0,[O,P]=u.useState(!1),I=B||O,k=X.path===W;if(!(w&&q))return z(OF,{file:X,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,depth:Q,kind:Y,dirty:R,experimentalKind:F,drag:D,menu:_});let C=typeof D<"u",y=C?D.dragProps(X.path,!0):{},v=D?.draggedPath===X.path,h=D?.busyPath===X.path,l=C&&typeof _<"u",o=X.path.split("/").slice(0,-1).join("/"),x=M("button",{type:"button",role:"treeitem","aria-selected":k,"aria-expanded":I,"aria-busy":h||void 0,tabIndex:k?0:-1,className:"st-row st-canvas-row"+(k?" is-sel":"")+(v?" is-dragging":"")+(h?" is-busy":""),style:{paddingLeft:_F+Q*AF+"px"},title:X.path,onClick:(m)=>{if(m.target.closest(".st-canvas-chev")){P((p)=>!p);return}Z(X.path)},onContextMenu:l?(m)=>_.openAt(m,{kind:"file",path:X.path,dir:o}):void 0,...y,children:[z("span",{className:"st-row-glyph st-canvas-chev",onClick:(m)=>{m.stopPropagation(),P((p)=>!p)},children:z(A9,{name:"chevron-right",className:"st-chev"+(I?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:gW(X.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"}),R&&z("span",{className:"st-git-badge","data-kind":R,title:`Unsaved (${R})`,"aria-label":`Unsaved, ${R}`,children:R}),U>0&&z("span",{className:"st-row-badge",children:U})]});return M(G0,{children:[l?M("div",{className:"st-row-wrap",role:"none",children:[x,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${LF(X.path)}`,title:`Move ${gW(X.name)}…`,"aria-label":`Actions for ${gW(X.name)}`,"aria-haspopup":"menu",onClick:(m)=>_.openAt(m,{kind:"file",path:X.path,dir:o}),children:z(DF,{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})})]}):x,I&&J.map((m)=>z(OF,{file:m,activePath:W,previewPath:G,onOpen:Z,onPreview:H,openCount:0,depth:Q+1,kind:Y,sidecar:!0},m.path))]})}function q00({node:X,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z=1,kind:H,showHidden:K,search:U,dsFolders:q,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:D,canvasKinds:_,dirPath:R="",drag:w,menu:O}){let P=Object.keys(X).filter((l)=>l!=="_files").sort(),I=X._files||[],{canvases:k,orphans:$}=u.useMemo(()=>yq0(I),[I]),{mediaOrphans:C,metaOrphans:y}=u.useMemo(()=>{let l=[],o=[];for(let x of $){let m=pR(x.primary.name);(m==="image"||m==="video"||m==="audio"||m==="font"?l:o).push(x)}return{mediaOrphans:l,metaOrphans:o}},[$]),v=!!(U&&U.trim()),h=u.useMemo(()=>{if(!q||Z!==1)return null;let l=new Map;for(let o of q)l.set(o.folder,o);return l},[q,Z]);return M(G0,{children:[k.map((l)=>{let o=v&&l.sidecars.some((x)=>{let m=U.toLowerCase();return x.name.toLowerCase().includes(m)||x.path.toLowerCase().includes(m)});return z(rq0,{primary:l.primary,sidecars:l.sidecars,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,onDelete:F,openCount:NF(G[l.primary.path]),depth:Z,kind:H,showHidden:K,forceOpen:o,dirtyByPath:D,experimentalKind:_?.[l.primary.path],drag:w,menu:O},l.primary.path)}),C.map((l)=>z(OF,{file:l.primary,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,openCount:NF(G[l.primary.path]),depth:Z,kind:H},l.primary.path)),K&&y.map((l)=>z(OF,{file:l.primary,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,openCount:NF(G[l.primary.path]),depth:Z,kind:H},l.primary.path)),P.map((l)=>{let o=h?.get(l),x=R?`${R}/${l}`:l,m=z(q00,{node:X[l],activePath:J,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z+1,kind:H,showHidden:K,search:U,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:D,canvasKinds:_,dirPath:x,drag:w,menu:O});if(o&&N)return z(nq0,{name:l,dsName:o.name,depth:Z,defaultOpen:!0,active:J===d8&&o.name===B,onOpenSystem:N,children:m},l);return z(oq0,{name:l,depth:Z,defaultOpen:!0,dirPath:x,drag:w,menu:O,children:m},l)})]})}var qF={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function aq0(X){if(X.kind==="project")return qF.project;if(X.kind==="runtime")return qF.runtime;if(X.label==="Design system")return qF.ds;if(X.label==="UI kit")return qF.canvas;return{title:X.label.toUpperCase(),pillFromCount:!0}}function sq0({readOnly:X=!1,cloud:J,groups:Q,activePath:Y,previewPath:W,activeDsName:G,onOpen:Z,onPreview:H,onOpenSystem:K,wsConnected:U,search:q,setSearch:B,commentsByFile:N,showHidden:F,sectionsExpanded:D,onToggleSection:_,onNewBoard:R,onDeleteBoard:w,onRefresh:O,refreshing:P,collapsed:I,onCollapse:k,width:$,resizing:C,dirtyByPath:y,project:v,gitBranch:h,remoteSync:l,onGetLatest:o,canvasKinds:x,onMoveCanvas:m,onNewFolder:p,onDeleteFolder:f,syncStatus:s,onLinkedHub:n}){let c=u.useMemo(()=>{if(!q)return Q;return Q.map((M0)=>({...M0,tree:U00(M0.tree,q),filtered:!!q}))},[Q,q]),U0=GS(m),X0=YS(),H0=u.useMemo(()=>{let M0=[];for(let j8 of Q){if(j8.label==="Design system"||j8.kind!=="canvas")continue;let L9=j8.fullPath.replace(/^\.[^/]+\//,"")||j8.fullPath;M0.push({path:j8.fullPath,label:L9});for(let U8 of j8.dirs||[])M0.push({path:U8,label:U8.replace(/^\.[^/]+\//,"")})}return M0},[Q]),r=X0.state?.extra,D0=r?.kind==="file"?[{id:"move-to",label:"Move to…",onSelect:()=>X0.showMoveTo()}]:r?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{X0.close();let M0=window.prompt("New folder name:");if(M0?.trim())p(r.dirPath,M0.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{X0.close(),f(r.dirPath,r.dirPath.split("/").pop())}}]:[],z0=r?.kind==="file"?H0.filter((M0)=>M0.path!==r.dir):[],[l0,X8]=u.useState(!1),[d0,$0]=u.useState("board"),[O0,i0]=u.useState(""),[c8,z8]=u.useState(""),[Q9,L8]=u.useState(!1),W8=u.useMemo(()=>Q.find((M0)=>M0.kind==="canvas"&&M0.label!=="Design system")?.fullPath,[Q]),b8=u.useCallback(async()=>{let M0=O0.trim();if(!M0||Q9)return;if(L8(!0),z8(""),d0==="folder"){if(!W8){L8(!1),z8("no canvas group to create a folder in");return}let L9=await p(W8,M0);if(L8(!1),L9?.ok)X8(!1),i0("");else z8(L9?.error||"could not create folder");return}let j8=await R(M0);if(L8(!1),j8?.ok)X8(!1),i0("");else z8(j8?.error||"could not create board")},[O0,Q9,R,p,d0,W8]),i8=u.useMemo(()=>{let M0=0;for(let j8 of Q)for(let L9 of j8.paths||[])if(JQ.test(L9))M0++;return M0},[Q]),p9=u.useMemo(()=>{let M0=0;for(let j8 of c)for(let L9 of j8.paths||[])if(JQ.test(L9))M0++;return M0},[c]);return M("nav",{className:"st-sidebar"+(I?" is-collapsed":"")+(C?" is-resizing":""),style:I||!$?void 0:{width:$,flexBasis:$},"aria-label":"Files","data-tour":"sidebar",children:[M("div",{className:"st-sb-hd",children:[z("span",{className:"st-sb-title",children:"Files"}),M("div",{className:"st-sb-hd-actions",children:[!X&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":l0&&d0==="board",onClick:()=>{z8(""),$0("board"),X8((M0)=>d0==="board"?!M0:!0)},children:z(A9,{name:"plus",size:15})}),!X&&W8&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":l0&&d0==="folder",onClick:()=>{z8(""),$0("folder"),X8((M0)=>d0==="folder"?!M0:!0)},children:z(A9,{name:"folder-plus",size:15})}),O&&z("button",{type:"button",className:"st-iconbtn st-refresh"+(P?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":P||void 0,disabled:P,onClick:()=>O(),children:z(A9,{name:"reload",size:15})}),M("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"}),p9," / ",i8]}),k&&z("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:k,children:z(A9,{name:"panel-left",size:15})})]})]}),l0?M("div",{className:"st-newboard",children:[z("input",{type:"text",autoFocus:!0,placeholder:d0==="folder"?"folder name…":"brief board name…",value:O0,maxLength:60,disabled:Q9,"aria-label":d0==="folder"?"New folder name":"New brief board name",onChange:(M0)=>i0(M0.target.value),onKeyDown:(M0)=>{if(M0.key==="Enter")M0.preventDefault(),b8();else if(M0.key==="Escape")M0.preventDefault(),X8(!1),i0(""),z8("")}}),z("button",{type:"button",className:"st-newboard-go",disabled:Q9||!O0.trim(),"data-tip":"Create · Enter","aria-label":d0==="folder"?"Create folder":"Create brief board",onClick:b8,children:Q9?"…":"↵"})]}):null,c8?z("div",{className:"st-newboard-err",role:"alert",children:c8}):null,z("div",{className:"st-search",children:M("div",{className:"st-search-box",children:[z(A9,{name:"search",size:13}),z("input",{type:"search","data-testid":"canvas-search",placeholder:"Search canvases…",value:q,onChange:(M0)=>B(M0.target.value),onKeyDown:(M0)=>{if(M0.key==="Escape")if(M0.preventDefault(),q)B("");else M0.currentTarget.blur()},"aria-label":"Filter files"}),q?z("button",{className:"st-search-clear",onClick:()=>B(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):z(MX,{children:"/"})]})}),z("div",{className:"st-tree",role:"tree","aria-label":"Project file tree","data-testid":"canvas-list",children:c.map((M0)=>{if(!F&&!q&&M0.kind==="runtime")return null;let j8=aq0(M0),L9=(M0.paths||[]).filter((w0)=>JQ.test(w0)).length,U8=j8.pill||(j8.pillFromDsCount?String(M0.dsFolders?.length||0):null)||(j8.pillFromCount?String(L9||M0.paths?.length||0):null),D9=M0.tree&&Object.keys(M0.tree).length>0,y0=M0.label==="Design system",Z0=M0.kind==="project";if(!F&&!q&&Z0&&L9===0)return null;let S0=$q0(M0),c0=D[M0.label],q8=!!q||(c0===void 0?S0:c0),N8=!y0&&M0.kind==="canvas"&&!X,H8=N8?U0.dropProps(M0.fullPath,!0):{},m0=U0.overDir===M0.fullPath;return M("div",{className:"st-tree-section",children:[M("button",{type:"button",className:"st-tree-sec-hd"+(m0?" is-drop-target":""),onClick:()=>_(M0.label,S0),"aria-expanded":q8,"aria-dropeffect":N8?"move":void 0,title:q8?"Collapse section":"Expand section",...H8,children:[z(A9,{name:"chevron-right",className:"st-chev"+(q8?" is-open":""),size:13}),z("span",{className:"st-sec-name",children:j8.title}),U8&&z("span",{className:"st-pill",children:U8})]}),q8&&(D9?z(q00,{node:M0.tree,activePath:Y,previewPath:W,onOpen:Z,onPreview:H,commentsByFile:N,depth:1,kind:M0.kind,showHidden:F,search:q,dsFolders:M0.dsFolders,activeDsName:G,onOpenSystem:y0?K:void 0,onDelete:y0||X?void 0:w,dirtyByPath:y,canvasKinds:x,dirPath:M0.fullPath,drag:!y0&&M0.kind==="canvas"&&!X?U0:void 0,menu:!y0&&M0.kind==="canvas"&&!X?X0:void 0}):z("div",{className:"st-tree-empty",children:q?"No matches.":"Empty."}))]},M0.label)})}),z(WS,{state:X0.state,onClose:X0.close,rootItems:D0,destinations:z0,onPickDestination:(M0)=>m(r.path,M0)}),z(mA,{project:v,liveBranch:h,remoteSync:l,onGetLatest:o}),J===null?z(UA,{syncStatus:s,onLinkedHub:n}):null,z(qA,{})]})}function tq0({shown:X,onExpand:J,onSearch:Q}){return z("div",{className:"st-rail"+(X?" is-shown":""),children:M("div",{className:"st-rail-inner",children:[z("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:J,children:z(A9,{name:"panel-left",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:z(A9,{name:"search",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:J,children:z(A9,{name:"folder",size:15})})]})})}function eq0({open:X,onClose:J,onStartTour:Q}){if(u.useEffect(()=>{if(!X)return;function Y(W){if(W.key==="Escape")J()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[X,J]),!X)return null;return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:M("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[M("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),M("span",{className:"sku",children:["MAUDE-DEV-SRV / v",dR]}),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:J,children:"×"})]}),M("div",{className:"help-modal-body",children:[M("details",{open:!0,children:[z("summary",{children:"Canvas selection & tools"}),M("ul",{children:[M("li",{children:[z("kbd",{children:"V"})," ",z("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),M("li",{children:[z("kbd",{children:"H"})," ",z("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),M("li",{children:[z("kbd",{children:"C"})," ",z("span",{children:"comment tool — hover paints, click drops a pin"})]}),M("li",{children:[z("kbd",{children:"⌘"})," + hover ",z("span",{children:"preview deepest element under cursor"})]}),M("li",{children:[z("kbd",{children:"⌘"})," + click ",z("span",{children:"select that element (replace)"})]}),M("li",{children:[z("kbd",{children:"⌘⇧"})," + click ",z("span",{children:"add deepest to selection (multi)"})]}),M("li",{children:["right-click ",z("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),M("li",{children:[z("kbd",{children:"Esc"})," in canvas ",z("span",{children:"clear selection + close menu"})]})]})]}),M("details",{children:[z("summary",{children:"Annotation tools"}),M("ul",{children:[M("li",{children:[z("kbd",{children:"B"})," ",z("span",{children:"pen — freehand stroke"})]}),M("li",{children:[z("kbd",{children:"R"})," ",z("span",{children:"rectangle — drag to define corners"})]}),M("li",{children:[z("kbd",{children:"O"})," ",z("span",{children:"ellipse — drag from center outward"})]}),M("li",{children:[z("kbd",{children:"A"})," ",z("span",{children:"arrow — drag tail → tip"})]}),M("li",{children:[z("kbd",{children:"E"})," ",z("span",{children:"eraser — click or drag over strokes to remove"})]}),M("li",{children:[z("kbd",{children:"V"})," + click stroke ",z("span",{children:"select annotation (Shift+click to multi)"})]}),M("li",{children:[z("kbd",{children:"V"})," + drag empty ",z("span",{children:"marquee-select strokes that overlap"})]}),M("li",{children:["double-click rect/ellipse ",z("span",{children:"add text inside the shape"})]}),M("li",{children:["arrow keys ",z("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),M("li",{children:[z("kbd",{children:"Backspace"})," ",z("span",{children:"delete selected annotations"})]}),M("li",{children:[z("kbd",{children:"⇧P"})," ",z("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),M("details",{children:[z("summary",{children:"Canvas & panels"}),M("ul",{children:[M("li",{children:["click in tree ",z("span",{children:"open canvas (replaces the active one)"})]}),M("li",{children:["File ▸ Close canvas ",z("span",{children:"clear the stage"})]}),M("li",{children:[z("kbd",{children:"⌘R"})," ",z("span",{children:"reload canvas"})]}),M("li",{children:[z("kbd",{children:"/"})," ",z("span",{children:"focus search"})]}),M("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"comments panel"})]}),M("li",{children:[z("kbd",{children:"⌘⇧I"})," ",z("span",{children:"inspector"})]}),M("li",{children:[z("kbd",{children:"?"})," ",z("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),M("details",{children:[z("summary",{children:"Slash commands"}),M("ul",{className:"cmds",children:[M("li",{children:[M("code",{children:['/design:edit "',z("i",{children:"feedback"}),'"']}),z("span",{children:"edit + 4-iter multi-axis loop"})]}),M("li",{children:[M("code",{children:['/design:edit "',z("i",{children:"…"}),'" --perfect']}),z("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),M("li",{children:[M("code",{children:['/design:edit "',z("i",{children:"…"}),'" --no-critic']}),z("span",{children:"raw edit, skip loop"})]}),M("li",{children:[M("code",{children:['/design:edit "',z("i",{children:"…"}),'" --opt-out=',z("i",{children:"scope"})]}),z("span",{children:"override DS scope (palette/aesthetic/full)"})]}),M("li",{children:[M("code",{children:['/design:new "',z("i",{children:"Name"}),'" "',z("i",{children:"brief"}),'"']}),z("span",{children:"scaffold canvas"})]}),M("li",{children:[M("code",{children:['/design:new "',z("i",{children:"…"}),'" --opt-out=aesthetic']}),z("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),M("li",{children:[z("code",{children:"/design:critic"}),z("span",{children:"review panel (routed)"})]}),M("li",{children:[z("code",{children:"/design:critic --all"}),z("span",{children:"10-critic sweep"})]}),M("li",{children:[z("code",{children:"/design:critic --agent signature-moment-critic"}),z("span",{children:"aspiration axis only"})]}),M("li",{children:[z("code",{children:"/design:rollback"}),z("span",{children:"undo last edit"})]}),M("li",{children:[z("code",{children:"/design:screenshot"}),z("span",{children:"capture canvas"})]}),M("li",{children:[z("code",{children:"/design:setup-docs"}),z("span",{children:"refresh README + INDEX"})]}),M("li",{children:[z("code",{children:"/design:handoff"}),z("span",{children:"migrate to apps/"})]})]})]}),M("details",{children:[z("summary",{children:"Opt-out scope"}),M("ul",{children:[M("li",{children:[z("strong",{children:"palette"})," ",z("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),M("li",{children:[z("strong",{children:"aesthetic"})," ",z("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),M("li",{children:[z("strong",{children:"full"})," ",z("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),M("li",{children:[z("em",{children:"A11y enforced at every scope"})," ",z("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),M("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.'})]})]}),M("details",{children:[z("summary",{children:"Auto-critic loop"}),M("ul",{children:[M("li",{children:[z("strong",{children:"Default"})," ",z("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),M("li",{children:[z("strong",{children:"--perfect"})," ",z("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),M("li",{children:[z("strong",{children:"--perfect --all"})," ",z("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),M("li",{children:["Exit: ",z("code",{children:"solid"})," · ",z("code",{children:"stable-but-bland"})," · ",z("code",{children:"max-reached"})," ","· ",z("code",{children:"divergent"})]}),M("li",{children:[z("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),M("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."]})]})]}),M("details",{children:[z("summary",{children:"Pin-to-element flow"}),M("ol",{children:[z("li",{children:"Open a canvas"}),M("li",{children:[z("kbd",{children:"⌘"}),"+click element"]}),z("li",{children:"Status bar shows ● selector"}),M("li",{children:["Run"," ",M("code",{children:['/design:edit "',z("i",{children:"change just this"}),'"']})]}),M("li",{children:["Reload iframe (",z("kbd",{children:"⌘R"}),")"]})]})]}),M("details",{children:[z("summary",{children:"Comments"}),M("ol",{children:[M("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"}),M("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"opens panel — All / Open / Resolved"})]}),M("li",{children:["Click row in panel ",z("span",{children:"jumps to that file + pin"})]}),M("li",{children:["Claude reads ",z("code",{children:"_comments/<slug>.json"})," on next ",z("code",{children:"/design"})]})]})]})]})]})})}var mR=[{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 X20({kbd:X,alt:J}){let Q=(Y,W)=>z("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>z(MX,{children:G},`${G}-${Z}`))},W);return M("span",{className:"so-combos",children:[Q(X,"main"),J?J.split(" / ").map((Y)=>M(G0,{children:[z("span",{className:"so-or",children:"/"}),Q(Y,Y)]},Y)):null]})}function J20({open:X,onClose:J}){if(u.useEffect(()=>{if(!X)return;function Y(W){if(W.key==="Escape")W.preventDefault(),J()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[X,J]),!X)return null;let Q=mR.reduce((Y,W)=>Y+W.items.length,0);return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:M("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[M("div",{className:"so-overlay-hd",children:[z("span",{className:"so-title",children:"Keyboard shortcuts"}),M("span",{className:"so-trigger",children:["press ",z(MX,{children:"?"})," to open"]})]}),z("div",{className:"so-columns",children:mR.map((Y)=>M("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)=>M("div",{className:"so-pair",children:[z("dt",{children:W.label}),z("dd",{children:z(X20,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),M("div",{className:"so-overlay-ft",children:[M("span",{children:["close with ",z(MX,{children:"Esc"})]}),M("span",{className:"so-count",children:[Q," bindings · ",mR.length," groups"]})]})]})})}var Q20=["File","Edit","View","Selection","Tools","Help"];function B00(X){u.useEffect(()=>{function J(Y){if(Y.key==="Escape")X()}function Q(Y){if(!Y.target.closest(".st-dropdown, .st-menu"))X()}return window.addEventListener("keydown",J),window.addEventListener("mousedown",Q),()=>{window.removeEventListener("keydown",J),window.removeEventListener("mousedown",Q)}},[X])}function Y20({panels:X,onToggle:J,onClose:Q,onZoom:Y,hasCanvas:W}){return B00(Q),M("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[z("div",{className:"st-dd-hd",children:"Panels"}),X.map((G)=>M("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}J(G.id),Q()},children:[M("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check",children:G.checked?z(A9,{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(MX,{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)=>M("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":W?void 0:"true",onClick:()=>{if(!W)return;Y?.(G.op),Q()},children:[M("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:G.label})]}),z(MX,{children:G.shortcut})]},G.label))]})}function TK({label:X,left:J,header:Q,items:Y,onAction:W,onClose:G}){return B00(G),M("div",{className:"st-dropdown",role:"menu","aria-label":X,style:{left:J},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):M("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:[M("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:Z.label})]}),Z.shortcut?z(MX,{children:Z.shortcut}):null]},Z.id))]})}function W20({onAction:X,onClose:J}){return z(TK,{label:"Help",left:320,onAction:X,onClose:J,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"},...X9()?[{id:"collab-tour",label:"How sharing works"}]:[],...X9()?[{id:"quick-setup",label:"Quick setup"}]:[],...X9()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function G20({onAction:X,onClose:J,readOnly:Q=!1}){return z(TK,{label:"Selection",left:214,onAction:X,onClose:J,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},...Q?[]:[{id:"select-all-annotations",label:"Select all annotations",shortcut:"⌘ ⇧ A"}]]})}function Z20({onAction:X,onClose:J,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(TK,{label:"Tools",left:290,header:"Tool palette",onAction:X,onClose:J,items:Y})}function H20({onAction:X,onClose:J,hasCanvas:Q,readOnly:Y=!1}){return z(TK,{label:"File",left:40,onAction:X,onClose:J,items:Y?[{id:"export",label:"Export…",shortcut:"⇧⌘E"},{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:"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 z20({onAction:X,onClose:J,hasCanvas:Q,readOnly:Y=!1}){if(Y)return z(TK,{label:"Edit",left:90,onAction:X,onClose:J,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"}]});return z(TK,{label:"Edit",left:90,onAction:X,onClose:J,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 K20({activePath:X,project:J,cloud:Q,tabsCount:Y,openMenu:W,setOpenMenu:G,commentsPanelOpen:Z,onToggleComments:H,changesOpen:K,changesCount:U,onToggleChanges:q,onOpenSystem:B,sidebarOpen:N,onToggleSidebar:F,showHidden:D,onToggleShowHidden:_,onOpenHelp:R,onOpenShortcuts:w,onReportBug:O,onStartTour:P,onStartCollabTour:I,annotationsVisible:k,onToggleAnnotations:$,minimapVisible:C,onToggleMinimap:y,zoomCtlVisible:v,onToggleZoomCtl:h,presentMode:l,onTogglePresent:o,printGuidesVisible:x,onTogglePrintGuides:m,postToActiveCanvas:p,onOpenWhatsNew:f,onOpenReadiness:s,onOpenQuickSetup:n,onWatchIntro:c,whatsNewCount:U0,exportCenter:X0,artboardCount:H0=0,presence:r=null,inspectorOpen:D0,inspectorTab:z0,onToggleInspector:l0,autoOpenInspector:X8,onToggleAutoOpenInspector:d0,onOpenLayers:$0,timelineOpen:O0,onToggleTimeline:i0,hasComps:c8=!1,assistantOpen:z8,onToggleAssistant:Q9,assistantBusy:L8,assistantUnseen:W8,onNewCanvas:b8,onAssembleVideo:i8,onOpenExport:p9,onOpenSettings:M0,onOpenGenerate:j8,onReload:L9,onCloseCanvas:U8,onInsertArtboard:D9,readOnly:y0=!1}){let Z0=X===d8,S0=Z0?"SYSTEM":X?"CANVAS":"IDLE",c0=Z0?z("b",{children:"design system"}):X?M(G0,{children:[X.split("/").slice(0,-1).join("/"),"/",z("b",{children:gW(RK(X))})]}):z("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),q8=new Set(Q?["autoopen"]:["assistant","autoopen"]),N8=[{id:"tree",label:"Project Tree",shortcut:"T",checked:N,disabled:!1},{id:"changes",label:Q?"History":U>0?`Changes · ${U} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:K,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:Z,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:D,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:D0&&z0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:D0,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!X8,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:c8?"video":void 0,checked:O0,disabled:!1},...X9()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:z8,disabled:!1}]:Q?[{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:k,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:C,disabled:!X||Z0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:v,disabled:!X||Z0},{id:"present",label:"Presentation Mode",shortcut:"",checked:l,disabled:!X||Z0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:x,disabled:!X||Z0}].filter((w0)=>!y0||!q8.has(w0.id)),H8=["file","edit","view","selection","tools","help"];function m0(w0){if(H8.includes(w0))G(W===w0?null:w0)}return u.useEffect(()=>{if(!W||!H8.includes(W))return;let w0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function K8(I8){let k8=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!k8.length)return;let _9=k8.indexOf(document.activeElement);if(I8.key==="ArrowDown")I8.preventDefault(),k8[(_9+1)%k8.length].focus();else if(I8.key==="ArrowUp")I8.preventDefault(),k8[(_9-1+k8.length)%k8.length].focus();else if(I8.key==="Home")I8.preventDefault(),k8[0].focus();else if(I8.key==="End")I8.preventDefault(),k8[k8.length-1].focus();else if(I8.key==="ArrowRight"||I8.key==="ArrowLeft"){I8.preventDefault();let A8=I8.key==="ArrowRight"?1:-1,T9=H8.indexOf(W);G(H8[(T9+A8+H8.length)%H8.length])}else if(I8.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",K8),()=>{clearTimeout(w0),window.removeEventListener("keydown",K8)}},[W,G]),M("header",{className:"st-menubar",role:"menubar","aria-label":"Application menubar","data-testid":"menubar",children:[M("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"})]}),Q?M("span",{className:"st-cloudback","data-testid":"cloud-back",children:[z("a",{className:"st-cloudback-link",href:Q.dashboardUrl||"https://cloud.maude.sh",title:"Back to your projects",children:"← Dashboard"}),Q.projectName?z("span",{className:"st-cloudback-project","data-testid":"cloud-project-name",children:Q.projectName}):null]}):null,z("nav",{className:"st-menus","aria-label":"Application menus","data-tour":"menus",children:Q20.map((w0)=>{let K8=w0.toLowerCase(),I8=H8.includes(K8),k8=I8||K8==="help";return z("button",{type:"button",className:"st-menu",role:"menuitem","data-tour":K8==="help"?"help":void 0,"aria-haspopup":I8?"menu":void 0,"aria-expanded":I8?W===K8:void 0,onClick:()=>m0(K8),onMouseEnter:()=>{if(W!==null&&I8)G(K8)},children:w0},K8)})}),W==="file"&&z(H20,{readOnly:y0,hasCanvas:!!X,onAction:(w0)=>{if(w0==="new")b8?.();else if(w0==="assemble")i8?.();else if(w0==="export")p9?.("export");else if(w0==="handoff")p9?.("handoff");else if(w0==="generate")j8?.();else if(w0==="settings")M0?.();else if(w0==="reload")L9?.();else if(w0==="close")U8?.()},onClose:()=>G(null)}),W==="edit"&&z(z20,{readOnly:y0,hasCanvas:!!X&&!Z0,onAction:(w0)=>{if(w0==="undo")p({dgn:"undo"});else if(w0==="redo")p({dgn:"redo"});else if(w0==="deselect-all")p({dgn:"selection-clear"});else if(w0==="select-all-annotations")p({dgn:"annotation-select-all"});else if(w0.startsWith("new-artboard:"))D9?.(w0.slice(13))},onClose:()=>G(null)}),W==="view"&&z(Y20,{panels:N8,onToggle:(w0)=>{if(w0==="tree")F();else if(w0==="changes")q();else if(w0==="comments")H();else if(w0==="hidden")_();else if(w0==="annotate")$();else if(w0==="inspector")l0();else if(w0==="autoopen")d0?.();else if(w0==="timeline")i0?.();else if(w0==="assistant")Q9?.();else if(w0==="layers")$0?.();else if(w0==="minimap")y?.();else if(w0==="zoomctl")h?.();else if(w0==="present")o?.();else if(w0==="print-guides")m?.()},onZoom:(w0)=>p({dgn:"zoom",op:w0}),hasCanvas:!!X&&!Z0,onClose:()=>G(null)}),W==="selection"&&z(G20,{readOnly:y0,onAction:(w0)=>{if(w0==="deselect-all")p({dgn:"selection-clear"});else if(w0==="select-all-annotations")p({dgn:"annotation-select-all"})},onClose:()=>G(null)}),W==="tools"&&z(Z20,{readOnly:y0,onAction:(w0)=>p({dgn:"tool-set",tool:w0}),onClose:()=>G(null)}),W==="help"&&z(W20,{onAction:(w0)=>{if(w0==="shortcuts")w?.();else if(w0==="help")R?.();else if(w0==="report-bug")O?.();else if(w0==="tour")P?.();else if(w0==="collab-tour")I?.();else if(w0==="quick-setup")n?.();else if(w0==="readiness")s?.();else if(w0==="whatsnew")f?.();else if(w0==="watch-intro")c?.()},onClose:()=>G(null)}),M("div",{className:"st-mb-right","data-tour":"status",children:[r?z("div",{className:"st-presence",children:r}):null,y0&&z("span",{className:"st-stamp st-stamp--viewonly","data-testid":"view-only-stamp","data-tip":Q?.user?`${Q.user} is a viewer on this project — you can browse, comment and export. 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. Ask a project owner for edit access.",children:"VIEW ONLY"}),Q?.user?M("span",{className:"st-cloudwho","data-testid":"cloud-account",children:[z("span",{className:"st-cloudwho-email",title:Q.role?`Signed in as ${Q.user} — ${Q.role}`:Q.user,children:Q.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,X9()&&!y0&&z("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":z8?"true":"false","data-busy":L8?"true":"false","data-unseen":W8?"true":"false","aria-label":`Assistant${L8?" — working":W8?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:Q9,children:z(A9,{name:"sparkle",size:15})}),X0&&z(Gx,{center:X0}),z("button",{type:"button",className:"st-reportbug","data-testid":"report-bug-toggle","aria-label":"Report a bug","data-tip":"Report a bug",onClick:O,children:z(A9,{name:"bug",size:15})}),z("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":U0>0?"true":"false","aria-label":`What's new${U0>0?` — ${U0} unseen`:""}`,"data-tip":"What's new",onClick:f,children:z(A9,{name:"megaphone",size:15})}),z("span",{className:"st-stamp",children:S0}),z("span",{className:"st-mb-file",title:X||"",children:c0}),z("span",{className:"st-mb-sep"}),M("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[z("span",{className:"st-dot",style:{background:"var(--accent)"}}),H0," ARTBOARDS"]}),z("span",{className:"st-mb-sep"}),z("span",{className:"st-mb-proj",children:J||"maude"})]})]})}function U20({tabs:X,activePath:J,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:K,onIframeLoad:U,showQuickSetup:q,onStartQuickSetup:B,previewPath:N}){let F=u.useRef(null);return u.useEffect(()=>{if(N)F.current?.focus()},[N]),M("div",{className:"viewport st-stage","data-tour":"viewport",children:[N&&z("div",{ref:F,className:"st-file-preview-overlay",role:"region","aria-label":`Preview: ${pB(RK(N))}`,tabIndex:0,children:z(Lh,{path:N,kind:pR(RK(N))})}),X.length===0&&!N&&M("div",{className:"st-empty",children:[M("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"}),M("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(Z||"MAUDE").toUpperCase()," / v",dR," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),z("div",{className:"st-empty-title",children:"Nothing open yet"}),M("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(MX,{children:"⌘"})," and hover to preview an element, click to select it — ",z(MX,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",X9()?M(G0,{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]}),q&&z("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:B,children:"Start quick setup"})]}),X.map((D)=>{if(D.path===d8)return z("div",{className:"system-view"+(D.path===J?" active":""),children:z(O20,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},D.path);return z("iframe",{ref:(_)=>Q(D.path,_),src:Mz(D.path,H),className:D.path===J?"active":"","data-path":D.path,"data-testid":D.path===J?"canvas-frame":void 0,onLoad:()=>U?.(D.path),...H?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},D.path)}),K&&K===J&&z("div",{className:"st-canvas-loading","aria-hidden":"true",children:M("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%"}})]})})]})}var V20=["color","space","radius","shadow","leading","weight","motion","font","other"],q20={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function B20(X){return X==="color"}function N20({tokens:X,tokenGroups:J,tokensPath:Q}){if(!X||X.length===0)return M("section",{className:"sv-section sv-section-tokens",children:[M("h2",{children:["tokens",z("span",{className:"sv-h-num",children:"0"})]}),z("div",{className:"sv-empty",children:M("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=J||{},W=Array.from(new Set([...V20,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return z(G0,{children:W.map((G)=>{let Z=Y[G],H=B20(G);return M("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[M("h2",{children:["tokens · ",q20[G]||G,z("span",{className:"sv-h-num",children:Z.length})]}),z("div",{className:"sv-tokens-ladder",children:Z.map((K)=>M("div",{className:"sv-tok-cell",children:[H?z("div",{className:"sv-tok-swatch",style:{background:K.value}}):null,M("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 F20(X,J){let Q=X.name.match(/^--(?:type|fs|text)-(.+)$/);if(!Q)return null;let Y=Q[1];return(J||[]).find((W)=>/^--(?:lh|leading|line-height)-/.test(W.name)&&W.name.endsWith("-"+Y))?.value??null}function L20(X){if(!X?.length)return;let J=["body","sans","display","text","family"];for(let Q of J){let Y=X.find((W)=>W.name.includes(Q));if(Y)return Y.value}return X[0].value}function D20({tokenGroups:X}){let J=X?.fontsize||[];if(J.length===0)return null;let Q=X?.leading||[],Y=L20(X?.font);return M("section",{className:"sv-section sv-section-type",children:[M("h2",{children:["type · ladder",z("span",{className:"sv-h-num",children:J.length})]}),z("div",{className:"sv-type-list",children:J.map((W)=>{let G=F20(W,Q),Z={fontSize:W.value};if(G)Z.lineHeight=G;if(Y)Z.fontFamily=Y;return M("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 O20({data:X,onOpen:J,cfg:Q,onSelectDs:Y}){if(!X)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:q,availableDesignSystems:B}=X,N=(!W||!W.length)&&(!G||!G.length),F=Array.isArray(B)&&B.length>1,D=q?.name??B?.[0]?.name??"";return M("div",{className:"sv",children:[M("header",{className:"sv-header",children:[z("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),z("span",{className:"sv-title",children:"design system view"}),F?M("label",{className:"sv-ds-picker",children:[z("span",{className:"sv-ds-picker-label",children:"DS"}),z("select",{value:D,onChange:(_)=>Y&&Y(_.target.value),children:B.map((_)=>z("option",{value:_.name,children:_.name},_.name))})]}):null,z("span",{className:"sv-loc",children:z("code",{children:Z})})]}),q?.description?z("p",{className:"sv-ds-description",children:q.description}):null,z(N20,{tokens:H,tokenGroups:K,tokensPath:U}),z(D20,{tokenGroups:K}),N?z("div",{className:"sv-empty",children:M("p",{children:["No ",z("code",{children:"preview/"})," or ",z("code",{children:"ui_kits/"})," folders found under"," ",z("code",{children:Z}),"."]})}):M(G0,{children:[z(oe,{title:"preview",items:W,onOpen:J,kind:"preview",cfg:Q}),z(oe,{title:"ui kits",items:G,onOpen:J,kind:"ui_kits",cfg:Q})]})]})}function oe({title:X,items:J,onOpen:Q,kind:Y,cfg:W}){if(!J||J.length===0)return null;return M("section",{className:"sv-section",children:[M("h2",{children:[X," ",z("span",{className:"sv-count",children:J.length})]}),z("div",{className:"sv-previews sv-previews-"+Y,children:J.map((G)=>M("article",{className:"sv-preview-card",onClick:()=>Q(G.path),children:[z("div",{className:"sv-preview-frame",children:z("iframe",{src:Mz(G.path,W,{thumbnail:!0}),title:G.label,scrolling:"no",...W?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),M("div",{className:"sv-preview-foot",children:[z("strong",{children:G.label}),z("code",{children:G.path})]})]},G.path))})]})}function M20({activePath:X,selected:J,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,syncProject:K,syncOpen:U=!1,onOpenSync:q,changesCount:B=0,unpushed:N=0,savingIsManaged:F=!1,changesOpen:D=!1,onOpenChanges:_,version:R}){let w=X===d8,O=J&&J.selector?J.selector+(J.text?` — "${J.text.slice(0,60)}"`:""):"",P=J&&J.dom_path?J.dom_path.join(" > "):J?J.selector:"",I=W==="dark"?"light":"dark",k=(()=>{let C=Oz(H,{project:K});if(!C)return null;let y=C.names.length?` (${C.names.join(", ")})`:"";return{online:C.online,label:C.label,title:`${C.title}${y}${C.next?` — ${C.next}`:""}`}})(),$=k&&M(G0,{children:[z("span",{className:"st-sb-sync-dot"+(k.online?" is-online":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:"hub sync"}),z("span",{className:"val",title:k.title,children:k.label})]});return M("footer",{className:"st-statusbar",role:"contentinfo","data-testid":"statusbar",children:[M("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:X||"",children:w?"▦ design system":X||"—"})]}),X&&J&&J.selector&&!w&&M("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:P,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:"×"})]}),M("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[z("span",{className:"lbl",children:"comments"}),M("span",{className:"val",children:[Y," open"]})]}),_&&M("button",{type:"button",className:"st-sb-slot st-sb-changes"+(D?" is-open":"")+(B>0?" has-changes":N>0?" has-unpushed":""),onClick:_,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":D,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"}),M("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"})]}),k&&(q?z("button",{type:"button",className:"st-sb-slot st-sb-sync st-sb-sync--btn"+(U?" is-open":""),onClick:q,"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:$})),R&&z("span",{className:"st-sb-slot st-sb-version",role:"group","aria-label":"Maude version",children:M("span",{className:"val","data-testid":"statusbar-version",children:["v",R]})}),M("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${I} theme`,"data-tip-pos":"top","aria-label":`Switch to ${I} theme`,children:[z(A9,{name:W==="dark"?"sun":"moon",size:13}),I]})]})}function _20({commentsByFile:X,filter:J,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:K,width:U,resizing:q}){let B=V00(X),N=Object.keys(X||{}).sort(),F=[];for(let D of N){let _=X[D]||[],R=_.filter((O)=>{if(J==="open")return O.status!=="resolved";if(J==="resolved")return O.status==="resolved";return!0});if(R.length===0)continue;let w=_.filter((O)=>O.selector);F.push({file:D,comments:R.map((O)=>({...O,n:w.findIndex((P)=>P.id===O.id)+1}))})}return M("aside",{className:"st-rpanel"+(q?" 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:M("div",{className:"st-cm-filters",role:"tablist",children:[M("button",{type:"button",className:"st-cm-filter"+(J==="all"?" is-active":""),role:"tab","aria-selected":J==="all",onClick:()=>Q("all"),children:["All · ",B.all]}),M("button",{type:"button",className:"st-cm-filter"+(J==="open"?" is-active":""),role:"tab","aria-selected":J==="open",onClick:()=>Q("open"),children:["Open · ",B.open]}),M("button",{type:"button",className:"st-cm-filter"+(J==="resolved"?" is-active":""),role:"tab","aria-selected":J==="resolved",onClick:()=>Q("resolved"),children:["Resolved · ",B.resolved]})]})}),z("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:F.length===0?M("div",{className:"st-rp-empty",children:[M("p",{children:["No comments ",J!=="all"?`with status “${J}”`:"yet","."]}),M("p",{children:["Open a canvas, hold ",z(MX,{children:"⌘"})," and click an element, then press ",z(MX,{children:"C"})," — or hold ",z(MX,{children:"⌘⇧"})," and click directly."]})]}):F.map((D)=>M(G0,{children:[M("button",{type:"button",className:"st-cm-group-hd",onClick:()=>G(D.file,null),title:D.file,children:[z("span",{children:gW(RK(D.file))}),z("span",{className:"st-mono",children:D.comments.length})]}),D.comments.map((_)=>M("div",{className:"st-comment"+(_.status==="resolved"?" is-resolved":"")+(_.id===W?" is-active":""),onClick:()=>G(D.file,_.id),children:[M("div",{className:"st-comment-hd",children:[z("span",{className:"st-pin st-pin--inline",children:_.n||"·"}),z("span",{className:"st-comment-time",children:fq0(_.created)})]}),z("div",{className:"st-comment-txt",children:_.text}),M("div",{className:"st-comment-foot",children:[z("span",{className:"st-comment-sel",title:(_.dom_path||[]).join(" > "),children:_.selector||"—"}),Z&&H&&K?M("span",{className:"st-mini-act",children:[_.status==="resolved"?z("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(R)=>{R.stopPropagation(),H(_.id)},children:z(A9,{name:"reopen",size:14})}):z("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(R)=>{R.stopPropagation(),Z(_.id)},children:z(A9,{name:"resolve",size:14})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(R)=>{R.stopPropagation(),K(_.id)},children:z(A9,{name:"x",size:14})})]}):null]})]},_.id))]},D.file))})]})}var A20={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 w20({cloud:X}){let J=X?.role||null,[Q,Y]=u.useState(!1);if(!J||Q)return null;let W=`maude-cloud-role-seen:${J}`,G=!1;try{G=localStorage.getItem(W)==="1"}catch{}if(G)return null;let Z=A20[J];if(!Z)return null;return M("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 E20({update:X,onDismiss:J}){let[Q,Y]=u.useState(!1);if(!X)return null;let W=X.version?` (v${X.version})`:"";return M("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),M("span",{children:["Maude updated",W," · restart to apply"]}),z("button",{type:"button",className:"btn btn--primary btn--sm",disabled:Q,onClick:()=>{Y(!0),Cv().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:J,children:"Later"})]})}function P20({status:X}){let[J,Q]=u.useState(null);if(!X||X.linked===!1)return null;if(X.notSyncable)return null;let{state:Y,queuedOps:W,flash:G,conflicts:Z}=X,H=G==="synced",K=Y==="offline"||Y==="offline-long",U=X.docs?.rejected??0,q=Array.isArray(Z)?[...Z].reverse().find((D)=>D.kind==="cold-start-diverged"):null;if(!K&&!H&&!q&&U===0)return null;let B,N,F;if(H)B="success",N="Synced with hub",F=`${Y}:flash`;else if(K){let D=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.${D}`;else B="warn",N=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${D}`;F=`${Y}:offline`}else if(q){if(q.snapshotFailed)B="error",N=`Diverged on ${q.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 ${q.slug}: kept the ${q.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${q.slug}`;F=`diverged:${q.slug}:${q.at}`}else B="warn",N=`${U} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,F=`rejected:${U}`;if(J===F)return null;return M("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 R20=["block","inline-block","flex","inline-flex","grid","inline","none"],ne=["px","%","fr","em","auto","min-content","max-content"];var T20=["auto","stretch","flex-start","center","flex-end","baseline"];var re=["300","400","500","600","700","800"],ae=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],se=["none","solid","dashed","dotted","double"],te=["px","rem","em","%","vw","vh","auto"],ee=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),uR={"font-size":{node:z(Y7,{as:sU,size:12})},"line-height":{node:z(Y7,{as:WV,size:12})},"letter-spacing":{node:z(Y7,{as:BV,size:12})},gap:{node:z(Y7,{as:rz,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:z(Y7,{as:OV,size:12})},"border-width":{node:z(Y7,{as:qV,size:12})}};var X00=["static","relative","absolute","fixed","sticky"],I20=["normal","italic","oblique"],J00=["none","uppercase","lowercase","capitalize"];var Q00=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],k20=["fill","contain","cover","none","scale-down"];var Y00=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],W00=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],O5={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}},EK=null;function MF(X){if(!X)return"";if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();try{if(!EK)EK=document.createElement("canvas").getContext("2d");if(!EK)return"";EK.fillStyle="#000000",EK.fillStyle=X;let J=EK.fillStyle;if(/^#[0-9a-f]{6}$/i.test(J))return J.toLowerCase();let Q=J.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=(X)=>Math.min(1,Math.max(0,X));function BF(X){let J=/^#?([0-9a-f]{6})$/i.exec(X||"");if(!J)return{r:0,g:0,b:0};let Q=Number.parseInt(J[1],16);return{r:Q>>16&255,g:Q>>8&255,b:Q&255}}function k3({r:X,g:J,b:Q}){return`#${[X,J,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function C3({r:X,g:J,b:Q}){X/=255,J/=255,Q/=255;let Y=Math.max(X,J,Q),W=Math.min(X,J,Q),G=Y-W,Z=0;if(G){if(Y===X)Z=(J-Q)/G%6;else if(Y===J)Z=(Q-X)/G+2;else Z=(X-J)/G+4;if(Z*=60,Z<0)Z+=360}return{h:Z,s:Y?G/Y:0,v:Y}}function PK({h:X,s:J,v:Q}){let Y=Q*J,W=Y*(1-Math.abs(X/60%2-1)),G=Q-Y,Z=0,H=0,K=0;if(X<60)[Z,H,K]=[Y,W,0];else if(X<120)[Z,H,K]=[W,Y,0];else if(X<180)[Z,H,K]=[0,Y,W];else if(X<240)[Z,H,K]=[0,W,Y];else if(X<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 Z7(X){if(!X)return"";let J=/^(-?\d*\.?\d+)px$/.exec(X);return J?`${Math.round(Number.parseFloat(J[1]))}px`:X}function fQ(X){if(!X)return{n:"",unit:"px"};let J=X.trim(),Q=/^(-?\d*\.?\d+)\s*(px|rem|em|%|vw|vh)?$/.exec(J);if(Q)return{n:Q[1],unit:Q[2]||"px"};if(J==="auto")return{n:"",unit:"auto"};return{n:J,unit:""}}function G00(X,J){if(!X||Array.isArray(X)||Array.isArray(J)||!J)return X;if(!X.id&&!J.id){let Q=(Y)=>typeof Y.selector==="string"&&Y.selector.startsWith("[data-dc-screen=");if(Q(X)&&Q(J)&&X.selector===J.selector&&X.file===J.file)return{...X,authored:X.authored??J.authored,computed:X.computed??J.computed,customStyles:X.customStyles??J.customStyles,attrs:X.attrs??J.attrs,artboardId:X.artboardId??J.artboardId,worldW:X.worldW??J.worldW,worldH:X.worldH??J.worldH};return X}if(!X.id||X.id!==J.id)return X;return{...X,authored:X.authored??J.authored,computed:X.computed??J.computed,customStyles:X.customStyles??J.customStyles,attrs:X.attrs??J.attrs,photoKind:X.photoKind??J.photoKind,photoAsset:X.photoAsset??J.photoAsset}}function N00(X,J){return(X?J?.canvasDesignSystems?.[X]:null)||J?.defaultDesignSystem||J?.designSystems?.[0]?.name||null}function C20(X){let J={};for(let Z of X.matchAll(/(--[a-z0-9-]+)\s*:\s*([^;}]+)/gi))if(!(Z[1]in J))J[Z[1]]=Z[2].trim();let Q={};for(let Z of Object.keys(J)){let H=J[Z],K=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(H);Q[Z]=K&&J[K[1]]?J[K[1]]:H}let Y=Object.keys(J),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 F00(X,J,Q){let Y=X?.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(`/${J}/${K.tokensCssRel}`),q=U.ok?await U.text():"";return{name:K.name,...C20(q)}}catch{return null}})).then((K)=>{if(H)return;let U=K.filter(Boolean);U.sort((q,B)=>q.name===Q?-1:B.name===Q?1:0),Z(U)}),()=>{H=!0}},[W,J,Q]),G}function L00({seed:X,label:J,onApply:Q}){let[Y,W]=u.useState(()=>C3(BF(X||"#000000"))),G=u.useRef(Y);G.current=Y;let Z=u.useRef(null),H=u.useRef(null),K=u.useRef(X);u.useEffect(()=>{if(X&&X!==K.current)K.current=X,W(C3(BF(X)))},[X]);let U=k3(PK(Y)),q=(O)=>{O.preventDefault();let P=Z.current?.getBoundingClientRect();if(!P)return;let I=G.current.h,k=(C)=>{W({h:I,s:uY((C.clientX-P.left)/P.width),v:uY(1-(C.clientY-P.top)/P.height)})};k(O);let $=()=>{document.removeEventListener("pointermove",k),document.removeEventListener("pointerup",$),Q(k3(PK(G.current)))};document.addEventListener("pointermove",k),document.addEventListener("pointerup",$)},B=(O)=>{O.preventDefault();let P=H.current?.getBoundingClientRect();if(!P)return;let{s:I,v:k}=G.current,$=(y)=>{W({h:uY((y.clientX-P.left)/P.width)*360,s:I,v:k})};$(O);let C=()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",C),Q(k3(PK(G.current)))};document.addEventListener("pointermove",$),document.addEventListener("pointerup",C)},N=(O)=>{let P={...G.current,...O};W(P),Q(k3(PK(P)))},F=(O)=>{let P=O.shiftKey?0.1:0.02,k={ArrowLeft:[-P,0],ArrowRight:[P,0],ArrowUp:[0,P],ArrowDown:[0,-P]}[O.key];if(!k)return;O.preventDefault(),N({s:uY(G.current.s+k[0]),v:uY(G.current.v+k[1])})},D=(O)=>{let P=O.shiftKey?20:2,k={ArrowLeft:-P,ArrowRight:P}[O.key];if(k==null)return;O.preventDefault(),N({h:Math.min(360,Math.max(0,G.current.h+k))})},_=async()=>{try{let O=window.EyeDropper;if(!O)return;let P=await new O().open();if(P?.sRGBHex)W(C3(BF(P.sRGBHex))),Q(P.sRGBHex)}catch{}},R=PK(Y),w=(O)=>{let P={...R,...O},I=C3({r:uY(P.r/255)*255,g:uY(P.g/255)*255,b:uY(P.b/255)*255});W(I),Q(k3(PK(I)))};return M("div",{className:"st-cp-cpick",children:[M("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":J?`${J} hex value`:"hex value",onChange:(O)=>{let P=O.target.value;if(/^#?[0-9a-f]{6}$/i.test(P))W(C3(BF(P)))},onKeyDown:(O)=>{if(O.key==="Enter")Q(O.currentTarget.value)},onBlur:(O)=>Q(O.currentTarget.value),onFocus:(O)=>O.currentTarget.select()})]}),M("button",{type:"button",ref:Z,className:"st-cp-cpick-sv","aria-label":J?`${J} saturation and value`:"saturation and value",style:{background:`hsl(${Y.h} 100% 50%)`},onPointerDown:q,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}})]}),M("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:_,children:z(A9,{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":J?`${J} hue`:"hue",onPointerDown:B,onKeyDown:D,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)=>M("label",{className:"st-cp-cpick-rgbf",children:[z("input",{"aria-label":O.toUpperCase(),value:Math.round(R[O]),onChange:(P)=>w({[O]:uY((Number.parseFloat(P.target.value)||0)/255)*255}),onFocus:(P)=>P.currentTarget.select()}),z("span",{children:O.toUpperCase()})]},O))})]})}function FF({kind:X,groups:J,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:K}){let[U,q]=u.useState(!1),[B,N]=u.useState(null),[F,D]=u.useState("custom"),[_,R]=u.useState(""),w=u.useRef(null),O=u.useRef(null),P=typeof Q==="string"&&/var\(\s*--/.test(Q),I=(n)=>Q===`var(${n})`,k=(n)=>n.replace(/^--/,"").replace(/-/g," "),$=J||[],C=$.reduce((n,c)=>n+(c.names?.length||0),0),y=$.length>1,v=_.trim().toLowerCase(),h=!v?$:$.map((n)=>({...n,names:(n.names||[]).filter((c)=>k(c).toLowerCase().includes(v)||c.toLowerCase().includes(v)||(n.vals?.[c]||"").toLowerCase().includes(v))})).filter((n)=>n.names.length);u.useEffect(()=>{if(!U){R("");return}let n=()=>{let H0=w.current?.getBoundingClientRect();if(!H0)return;let r=224,D0=300,z0=Math.min(H0.right-r,window.innerWidth-r-8);if(z0<8)z0=8;let X8=window.innerHeight-H0.bottom>D0+8?H0.bottom+4:Math.max(8,H0.top-D0-4);N({left:z0,top:X8,width:r,maxHeight:D0})};n();let c=(H0)=>{if(O.current?.contains(H0.target)||w.current?.contains(H0.target))return;q(!1)},U0=(H0)=>{if(H0.key==="Escape")q(!1)},X0=(H0)=>{if(O.current?.contains(H0.target))return;n()};return document.addEventListener("pointerdown",c,!0),document.addEventListener("keydown",U0),window.addEventListener("resize",n),document.addEventListener("scroll",X0,!0),()=>{document.removeEventListener("pointerdown",c,!0),document.removeEventListener("keydown",U0),window.removeEventListener("resize",n),document.removeEventListener("scroll",X0,!0)}},[U]),u.useEffect(()=>{if(!U||!B||!O.current)return;let n=O.current.getBoundingClientRect(),c=B.left-n.left,U0=B.top-n.top;if(Math.abs(c)>0.5||Math.abs(U0)>0.5)N((X0)=>X0?{...X0,left:X0.left+c,top:X0.top+U0}:X0)},[U,B]);let l=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,o=(n,c,U0)=>{if(H&&n&&n!==H&&U0&&!l.test(U0))Y(U0);else Y(`var(${c})`);q(!1)},x=(n)=>{let c=(n||"").trim();if(c)Y(c)},m=M("div",{className:"st-cp-pop-search",children:[z(A9,{name:"search",size:12}),z("input",{value:_,onChange:(n)=>R(n.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),p=(n)=>n.map((c)=>M("div",{className:"st-cp-pop-group",children:[y?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((U0)=>M("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${I(U0)?" is-on":""}`,onClick:()=>o(c.ds,U0,c.vals?.[U0]),children:[z("span",{className:"st-cp-pop-cswatch",style:{background:c.vals?.[U0]||"transparent"},"aria-hidden":"true"}),z("span",{className:"st-cp-pop-name",children:k(U0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[U0]||""})]},`${c.ds}:${U0}`))})]},c.ds)),f=(n)=>n.map((c)=>M("div",{className:"st-cp-pop-group",children:[y?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((U0)=>M("button",{type:"button",className:`st-cp-pop-row${I(U0)?" is-on":""}`,onClick:()=>o(c.ds,U0,c.vals?.[U0]),children:[z("span",{className:"st-cp-pop-name",children:k(U0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[U0]||""})]},`${c.ds}:${U0}`))})]},c.ds)),s=z("div",{className:"st-cp-pop-empty",children:"No match"});return M(G0,{children:[G!==void 0?z("button",{type:"button",ref:w,className:`${K||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${P&&!K?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>q((n)=>!n),children:z("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):z("button",{type:"button",ref:w,className:`st-cp-tokbtn${P?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>q((n)=>!n),children:z("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),U&&B?H00.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:X==="color"?M(G0,{children:[M("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:()=>D("custom"),children:"Custom"}),z("button",{type:"button",role:"tab","aria-selected":F==="vars",className:`st-cp-poptab${F==="vars"?" is-active":""}`,onClick:()=>D("vars"),children:"Variables"})]}),F==="custom"?z(L00,{seed:Z||MF(Q)||"#000000",onApply:x}):!C?z("div",{className:"st-cp-pop-empty",children:"No color tokens"}):M(G0,{children:[m,h.length?p(h):s]})]}):!C?z("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):M(G0,{children:[m,h.length?f(h):s]})}),document.body):null]})}function Z00({label:X,tracks:J,editable:Q,onChange:Y}){let W=(K,U)=>{let q=J[K];Y(J.map((B,N)=>N===K?JU.has(U)?{value:0,unit:U}:{value:q.value||1,unit:U}:B))},G=(K,U)=>{Y(J.map((q,B)=>B===K?{...q,value:U}:q))},Z=()=>Y([...J,{value:1,unit:"fr"}]),H=(K)=>Y(J.filter((U,q)=>q!==K));return M("div",{className:"st-cp-gridtracks",children:[M("div",{className:"st-cp-gridtracks-hd",children:[z("span",{className:"st-cp-gridtracks-label",children:X}),z("button",{type:"button",className:"st-btn st-cp-gridtracks-add",disabled:!Q,onClick:Z,children:"+ Track"})]}),J.length===0?M("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",X.toLowerCase(),"."]}):J.map((K,U)=>{let q=JU.has(K.unit);return M("div",{className:"st-cp-gridtrack-row",children:[q?z(EW,{value:K.unit,ariaLabel:`${X} track ${U+1}`,options:ne.map((B)=>({value:B,label:B})),onChange:(B)=>W(U,B)}):z(JX,{value:K.value,min:K.unit==="fr"?0.1:0,step:K.unit==="fr"?0.1:1,ariaLabel:`${X} track ${U+1} value`,lead:String(U+1),unitSlot:z(nB,{value:K.unit,units:ne,ariaLabel:`${X} 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 ${X} track ${U+1}`,disabled:!Q||J.length<=1,onClick:()=>H(U),children:"×"})]},U)})]})}function $20({el:X,cfg:J,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let K=!!X.id,U=X.computed||{},[q,B]=u.useState({a:{},c:{},t:{}});u.useEffect(()=>{B({a:{},c:{},t:{}})},[X.id]);let N=(e,A0)=>{let q0={...e||{}};for(let[j0,n0]of Object.entries(A0))if(n0===null)delete q0[j0];else q0[j0]=n0;return q0},F=N(X.authored,q.a),D=N(X.customStyles,q.c),_=N(X.attrs,q.t),R=(e,A0)=>B((q0)=>({...q0,a:{...q0.a,[e]:A0}})),w=(e,A0)=>B((q0)=>({...q0,c:{...q0.c,[e]:A0}})),O=(e,A0)=>B((q0)=>({...q0,t:{...q0.t,[e]:A0}})),P=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),I=N00(X.file,J),k=F00(J,P,I),$=(e)=>k.map((A0)=>({ds:A0.name,names:A0[e]||[],vals:A0.vals})).filter((A0)=>A0.names.length),[C,y]=u.useState({}),[v,h]=u.useState({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),l=Object.keys(D).length>0||Object.keys(_).length>0;u.useEffect(()=>{if(l)h((e)=>e.Advanced?e:{...e,Advanced:!0})},[X.id,l]);let o=(F.position||Z7(U.position)||"static")!=="static";u.useEffect(()=>{if(o)h((e)=>e["d:Position"]?e:{...e,"d:Position":!0})},[X.id,o]);let x=H,[m,p]=u.useState({});async function f(e,A0,q0){y((j0)=>({...j0,[q0]:"saving"}));try{let j0=await fetch(e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(A0)}),n0=await j0.json().catch(()=>({}));y((y8)=>({...y8,[q0]:!j0.ok||!n0.ok?`err:${n0&&n0.error||`HTTP ${j0.status}`}`:"saved"}))}catch(j0){y((n0)=>({...n0,[q0]:`err:${j0&&j0.message?j0.message:String(j0)}`}))}}let s=(e,A0)=>{if(!Q||!X.id)return;Q({id:X.id,artboardId:X.artboardId??null,index:X.index??0,prop:e,value:A0})},n=(e,A0,q0,j0)=>{Y?.({op:e,canvas:X.file,id:X.id,key:A0,before:q0==null||q0===""?null:q0,after:j0==null||j0===""?null:j0})},c=(e,A0)=>{let q0=(A0||"").trim();if(!K||!q0)return;let j0=F[e]??null;if(q0===(j0??"").trim())return;s(e,q0),R(e,q0),f("/_api/edit-css",{canvas:X.file,id:X.id,property:e,value:q0},e),n("css",e,j0,q0)},U0=(e,A0)=>{let q0=(A0||"").trim(),j0=e.trim();if(!K||!j0||!q0)return;let n0=D[j0]??null;s(j0,q0),w(j0,q0),f("/_api/edit-css",{canvas:X.file,id:X.id,property:j0,value:q0},j0),n("css",j0,n0,q0)},X0=(e,A0)=>{let q0=(e||"").trim(),j0=(A0||"").trim();if(!K||!q0||!j0)return;let n0=_[q0]??null;O(q0,j0),f("/_api/edit-attr",{canvas:X.file,id:X.id,attr:q0,value:j0},`@${q0}`),n("attr",q0,n0,j0)},H0=(e)=>{if(!K)return;let A0=F[e]??null;s(e,null),R(e,null),f("/_api/edit-css",{canvas:X.file,id:X.id,property:e,reset:!0},e),n("css",e,A0,null)},r=(e)=>{if(!K)return;let A0=D[e]??null;s(e,null),w(e,null),f("/_api/edit-css",{canvas:X.file,id:X.id,property:e,reset:!0},e),n("css",e,A0,null)},D0=(e)=>{if(!K)return;let A0=_[e]??null;O(e,null),f("/_api/edit-attr",{canvas:X.file,id:X.id,attr:e,reset:!0},`@${e}`),n("attr",e,A0,null)},z0={display:X.parentDisplay,flexDirection:X.parentFlexDirection},l0=(e,A0)=>{if(!K)return;let q0=Math.round((e==="width"?X.bounds?.w:X.bounds?.h)||0),j0=e$(e,A0,z0,q0);for(let n0 of j0.reset)if(F[n0])H0(n0);for(let[n0,y8]of j0.set)c(n0,y8)},X8=X.parentDisplay==="flex"||X.parentDisplay==="inline-flex",d0=(e)=>{let A0=t$(e,F,U,z0);return M("div",{className:"st-cp-moderow",children:[z("span",{className:"st-cp-modelabel",children:e==="width"?"Width sizing":"Height sizing"}),z("div",{className:"st-cp-modeseg",role:"group","aria-label":`${e} sizing mode`,children:z(rB,{value:A0,ariaLabel:`${e} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(q0)=>l0(e,q0)})})]},`mode-${e}`)},$0=["flex-start","center","flex-end"],O0=["flex-start","center","flex-end"],i0=["t","c","b"],c8=["l","c","r"],z8=()=>{let e=!(F["flex-direction"]||Z7(U["flex-direction"])||"row").startsWith("column"),A0=Math.max(0,$0.indexOf(F["justify-content"]||Z7(U["justify-content"])||"flex-start")),q0=F["align-items"]||Z7(U["align-items"])||"stretch",j0=q0==="stretch"?1:Math.max(0,O0.indexOf(q0)),[n0,y8]=e?[A0,j0]:[j0,A0];return i0[y8]+c8[n0]},Q9=(e)=>{let A0=i0.indexOf(e[0]),q0=c8.indexOf(e[1]),j0=!(F["flex-direction"]||Z7(U["flex-direction"])||"row").startsWith("column"),[n0,y8]=j0?[q0,A0]:[A0,q0];c("justify-content",$0[n0]),c("align-items",O0[y8])},L8=(e)=>{if(!(e.metaKey||e.ctrlKey)||e.altKey)return;let A0=e.key.toLowerCase();if(A0==="z")e.preventDefault(),G?.(e.shiftKey?"redo":"undo");else if(A0==="y")e.preventDefault(),G?.("redo")},W8=(e)=>{let A0=F[e];if(!A0)return"inherit";return/var\(\s*--/.test(A0)?"bound":"raw"};if(!K)return M("div",{className:"st-cp",children:[z("div",{className:"st-cp-id",children:z("span",{className:"st-cp-idtag",children:X.tag||"element"})}),M("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 b8={bound:"token-bound",raw:"raw override",inherit:"inherited"},i8=(e)=>z("span",{className:`st-cp-prov st-cp-prov--${e}`,role:"img","aria-label":b8[e]}),p9=(e,A0)=>{let q0=A0??W8(e),j0=C[e],n0=typeof j0==="string"&&j0.startsWith("err:")?j0.slice(4):"",y8=n0?" is-err":j0==="saved"?" is-saved":j0==="saving"?" is-saving":"",S8=!!F[e],o8=n0?`error: ${n0}`:S8?`${b8[q0]} · double-click to reset`:b8[q0];return z("button",{type:"button",className:`st-cp-prov st-cp-prov--${q0}${y8}${S8?" is-resettable":""}`,"aria-label":o8,title:o8,tabIndex:S8?0:-1,onDoubleClick:S8?()=>H0(e):void 0,onKeyDown:S8?(e8)=>{if(e8.key==="Backspace"||e8.key==="Delete")e8.preventDefault(),H0(e)}:void 0})},M0=(e,A0,q0,j0)=>{let n0=q0===void 0&&!F[e],y8=j0??e;return M("div",{className:`st-cp-row${n0?" is-unset":""}`,children:[p9(e,q0),z("label",{className:"st-cp-label",title:y8,children:y8}),z("div",{className:"st-cp-ctl",children:A0})]},e)},j8={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"]},L9=(e)=>{(j8[e]||[]).forEach((A0)=>{if(F[A0])H0(A0)})},U8=(e,A0)=>{let q0=(j8[e]||[]).some((j0)=>F[j0]);return M("section",{className:"st-cp-sec",children:[M("div",{className:"st-cp-sechd-row",children:[M("button",{type:"button",className:"st-cp-sechd","aria-expanded":!!v[e],onClick:()=>h((j0)=>({...j0,[e]:!j0[e]})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:v[e]?"▾":"▸"}),e]}),z("button",{type:"button",className:`st-cp-secreset${q0?"":" is-quiet"}`,"aria-label":`reset ${e} section to original`,title:`reset ${e}`,disabled:!q0,onClick:()=>L9(e),children:z(Y7,{as:MZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${v[e]?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:A0})})]},e)},D9=(e,A0,q0,j0=!0)=>{let n0=`d:${e}`,y8=v[n0]===void 0?j0:v[n0],S8=A0.some((o8)=>F[o8]);return M("section",{className:"st-cp-sec",children:[M("div",{className:"st-cp-sechd-row",children:[M("button",{type:"button",className:"st-cp-sechd","aria-expanded":y8,onClick:()=>h((o8)=>({...o8,[n0]:!y8})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:y8?"▾":"▸"}),e]}),z("button",{type:"button",className:`st-cp-secreset${S8?"":" is-quiet"}`,"aria-label":`reset ${e} to original`,title:`reset ${e}`,disabled:!S8,onClick:()=>A0.forEach((o8)=>{if(F[o8])H0(o8)}),children:z(Y7,{as:MZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${y8?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:q0})})]},n0)},y0=(e)=>z("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!m[e],"aria-label":m[e]?`${e} — fewer options`:`${e} — more options`,title:m[e]?"fewer":"more",onClick:()=>p((A0)=>({...A0,[e]:!A0[e]})),children:m[e]?"▴":"···"}),Z0=(e,A0)=>M("select",{className:"st-cp-nsel","aria-label":e,value:A0.includes(F[e])?F[e]:"",onChange:(q0)=>c(e,q0.target.value),children:[z("option",{value:"",disabled:!0,children:Z7(U[e])||"—"}),A0.map((q0)=>z("option",{value:q0,children:q0},q0))]}),S0=(e)=>$(e).flatMap((A0)=>(A0.names||[]).map((q0)=>({name:q0,value:A0.vals?.[q0]||""}))),c0=(e,A0)=>z(wA,{value:F[e]||Z7(U[e])||A0[0].value,ariaLabel:e,options:A0,onChange:(q0)=>c(e,q0)}),q8=(e,A0,q0={})=>{let j0=fQ(F[e]??""),n0=ee.has(e),y8=F[e]??"",S8=typeof y8==="string"&&/var\(\s*--/.test(y8),o8=n0?"":j0.unit&&j0.unit!=="auto"?j0.unit:"px",e8=Number.parseFloat(fQ(Z7(U[e])??"").n)||0,P9=j0.n!==""&&j0.n!=null?Number.parseFloat(j0.n)||0:e8,V7=uR[e];return z(aB,{value:S8?y8:P9,tokens:S0(A0),ariaLabel:e,min:q0.min??0,lead:V7?V7.node??V7.t:void 0,unitSlot:n0?null:z(nB,{units:te,value:j0.unit||"px",ariaLabel:`${e} unit`,onChange:(h9)=>c(e,h9==="auto"?"auto":`${j0.n||"0"}${h9}`)}),onChange:(h9)=>c(e,typeof h9==="string"?h9:n0?`${h9}`:`${h9}${o8}`)})},N8=()=>{let e=(n0)=>Number.parseFloat(fQ(F[n0]??F["border-radius"]??Z7(U[n0])??Z7(U["border-radius"])??"0").n)||0,A0={tl:e("border-top-left-radius"),tr:e("border-top-right-radius"),bl:e("border-bottom-left-radius"),br:e("border-bottom-right-radius")},q0=(n0)=>{if(n0.tl===n0.tr&&n0.tr===n0.bl&&n0.bl===n0.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((S8)=>{if(F[S8])H0(S8)}),c("border-radius",`${n0.tl}px`);else c("border-top-left-radius",`${n0.tl}px`),c("border-top-right-radius",`${n0.tr}px`),c("border-bottom-left-radius",`${n0.bl}px`),c("border-bottom-right-radius",`${n0.br}px`)},j0=uR["border-radius"];return z(Th,{corners:A0,lead:j0?j0.node??j0.t:void 0,onCorners:q0})},H8=()=>M("div",{className:"st-cp-border",children:[w9("border-width",null,{fixedUnit:"px"}),M("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:se.includes(F["border-style"])?F["border-style"]:"",onChange:(e)=>c("border-style",e.target.value),children:[z("option",{value:"",disabled:!0,children:"style"}),se.map((e)=>z("option",{value:e,children:e},e))]}),z(FF,{kind:"color",groups:$("color"),current:F["border-color"],activeDs:I,swatchBg:U["border-color"]||F["border-color"]||"",seedHex:MF(U["border-color"]||F["border-color"])||"#000000",onPick:(e)=>c("border-color",e),label:"border colour"})]}),m0=()=>{let e=F.transform||Z7(U.transform)||"",A0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(e),q0=((A0?Number.parseFloat(A0[1]):0)%360+360)%360,j0=(n0)=>{let y8=(n0%360+360)%360,S8=(F.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();c("transform",`${S8?`${S8} `:""}rotate(${y8}deg)`.trim())};return M("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[z(Ph,{value:q0,onChange:j0}),z(JX,{value:q0,min:0,max:360,ariaLabel:"rotation",lead:z(Y7,{as:MZ}),steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:j0})]})},w0=()=>{let e=F.filter||Z7(U.filter)||"",A0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(e),q0=A0?Number.parseFloat(A0[1]):0;return z(JX,{value:q0,min:0,ariaLabel:"filter blur",unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(n0)=>{let y8=(F.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();c("filter",n0>0?`${y8?`${y8} `:""}blur(${n0}px)`.trim():y8||"none")}})},K8=()=>{let e=F.opacity,A0=e!=null&&e!==""?Number.parseFloat(e):Number.parseFloat(Z7(U.opacity))||1,q0=Math.round((Number.isNaN(A0)?1:A0)*100);return z(CJ,{value:q0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(j0)=>s("opacity",String(j0/100)),onCommit:(j0)=>c("opacity",String(j0/100))},`opacity:${e??""}`)},I8=()=>{let e=Number.parseInt(F["font-weight"]||Z7(U["font-weight"])||"400",10)>=600,A0=(F["font-style"]||Z7(U["font-style"]))==="italic",q0=/underline/.test(F["text-decoration"]||Z7(U["text-decoration"])||"");return z(wh,{value:{b:e,i:A0,u:q0},ariaLabel:"text style",options:[{value:"b",node:z(Y7,{as:GV}),label:"Bold"},{value:"i",node:z(Y7,{as:UV}),label:"Italic"},{value:"u",node:z(Y7,{as:AV}),label:"Underline"}],onToggle:(j0)=>{if(j0==="b")c("font-weight",e?"400":"700");else if(j0==="i")c("font-style",A0?"normal":"italic");else c("text-decoration",q0?"none":"underline")}})},k8=[{value:"row",node:z(Y7,{as:BW}),label:"Row"},{value:"column",node:z(Y7,{as:NW}),label:"Column"}],_9=[{value:"flex-start",node:z(Y7,{as:XV}),label:"Start"},{value:"center",node:z(Y7,{as:tU}),label:"Center"},{value:"flex-end",node:z(Y7,{as:eU}),label:"End"},{value:"space-between",node:z(Y7,{as:rz}),label:"Space between"}],A8=[{value:"flex-start",node:z(Y7,{as:YV}),label:"Start"},{value:"center",node:z(Y7,{as:JV}),label:"Center"},{value:"flex-end",node:z(Y7,{as:QV}),label:"End"},{value:"stretch",node:z(Y7,{as:MV}),label:"Stretch"}],T9=[{value:"left",node:z(Y7,{as:v5}),label:"Left"},{value:"center",node:z(Y7,{as:DW}),label:"Center"},{value:"right",node:z(Y7,{as:OW}),label:"Right"},{value:"justify",node:z(Y7,{as:MW}),label:"Justify"}],Y9=[{value:"visible",node:z(Y7,{as:OZ}),label:"Visible"},{value:"hidden",node:z(Y7,{as:_Z}),label:"Hidden"},{value:"scroll",node:z(Y7,{as:LV}),label:"Scroll"}],b7=(e,A0)=>{let q0=$(A0);return q0.length?z(FF,{kind:"value",groups:q0,current:F[e],activeDs:I,onPick:(j0)=>c(e,j0),label:`${e} design token`}):null},E0=(e)=>{let A0=e.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===A0)A0.select()})},f8=(e,A0)=>{if(e.key!=="ArrowUp"&&e.key!=="ArrowDown")return!1;e.preventDefault();let q0=e.shiftKey?10:1,j0=e.key==="ArrowUp"?1:-1,n0=(Number.parseFloat(e.currentTarget.value)||0)+j0*q0;return e.currentTarget.value=String(n0),A0(n0),!0},v9=(e)=>z("input",{className:"st-cp-fin","aria-label":e,defaultValue:F[e]??"",placeholder:Z7(U[e])||"—",onFocus:E0,onKeyDown:(A0)=>{if(A0.key==="Enter")A0.currentTarget.blur()},onBlur:(A0)=>c(e,A0.currentTarget.value)},`${e}:${F[e]??""}`),w9=(e,A0,q0={})=>{let j0=fQ(F[e]??""),n0=ee.has(e),y8=n0?"":q0.fixedUnit||(j0.unit&&j0.unit!=="auto"?j0.unit:"px"),S8=uR[e],o8=Number.parseFloat(fQ(Z7(U[e])??"").n)||0,e8=j0.n!==""&&j0.n!=null?Number.parseFloat(j0.n)||0:o8;return M(G0,{children:[z(JX,{value:e8,min:q0.min??0,step:1,ariaLabel:e,lead:S8?S8.node??S8.t:void 0,onCommit:(P9)=>c(e,n0?`${P9}`:`${P9}${y8}`),unitSlot:n0||q0.fixedUnit?null:z(nB,{units:te,value:j0.unit||"px",ariaLabel:`${e} unit`,onChange:(P9)=>c(e,P9==="auto"?"auto":`${j0.n||"0"}${P9}`)})},`${e}:${F[e]??""}`),b7(e,A0)]})},G6=(e)=>{let A0=U[e]||F[e]||"",q0=F[e]??"",j0=typeof q0==="string"&&/var\(\s*--/.test(q0),n0=j0?q0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):q0;return z(EV,{swatch:z(FF,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:$("color"),current:F[e],activeDs:I,swatchBg:A0,seedHex:MF(U[e]||F[e])||"#000000",onPick:(y8)=>c(e,y8),label:`${e} colour`}),displayValue:n0,bound:j0,ariaLabel:e,onValue:(y8)=>c(e,y8)})},_6=(e,A0)=>{let q0=null,j0=A0.unitless?"":"px",n0=(o8)=>A0.unitless?`${o8}`:`${o8}${j0}`,y8=(o8,e8,P9)=>{for(let V7 of e8??[e])P9(V7,n0(o8))},S8=AA({getBase:()=>q0?.value??"0",min:A0.min??0,step:1,sides:A0.sides,onInput:(o8,e8)=>{if(q0)q0.value=String(o8);if(e8){let P9=q0?.closest(".st-cp-box");for(let V7 of e8){if(V7===e)continue;let h9=P9?.querySelector(`.st-cp-boxv[aria-label="${V7}"]`);if(h9)h9.value=String(o8)}}y8(o8,e8,s)},onCommit:(o8,e8)=>y8(o8,e8,c)});return{onPointerDown:(o8)=>{q0=o8.currentTarget,S8(o8)}}},g8=(e,A0)=>{let q0=F[e],j0=q0!=null&&q0!==""?fQ(q0).n||q0:fQ(Z7(U[e])??"").n||"0",n0=!q0||q0==="0"||q0==="0px"||q0==="auto",y8=e.split("-").pop(),S8=y8==="top"||y8==="bottom"?[`${A0}-top`,`${A0}-bottom`]:[`${A0}-left`,`${A0}-right`],o8=[`${A0}-top`,`${A0}-right`,`${A0}-bottom`,`${A0}-left`];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${A0[0]}${e.split("-").pop()[0]}${n0?" is-zero":""}`,"aria-label":e,defaultValue:j0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",..._6(e,{sides:{pair:S8,all:o8}}),onFocus:E0,onKeyDown:(e8)=>{if(f8(e8,(P9)=>c(e,`${P9}px`)))return;if(e8.key==="Enter")e8.currentTarget.blur()},onBlur:(e8)=>{let P9=e8.currentTarget.value.trim();if(!P9)return;let V7=/[a-z%]/i.test(P9)?P9:`${P9}px`;c(e,V7)}},`${e}:${q0??""}`)},s9=(e)=>{let A0=F[e],q0=A0!=null&&A0!==""&&A0!=="auto"?fQ(A0).n||A0:fQ(Z7(U[e])??"").n||"",j0=!A0||A0==="auto"||A0==="0"||A0==="0px",n0=e==="top"||e==="bottom"?["top","bottom"]:["left","right"],y8=["top","right","bottom","left"];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${e[0]}${j0?" is-zero":""}`,"aria-label":e,defaultValue:q0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",..._6(e,{sides:{pair:n0,all:y8},min:-1/0}),onFocus:E0,onKeyDown:(S8)=>{if(f8(S8,(o8)=>c(e,`${o8}px`)))return;if(S8.key==="Enter")S8.currentTarget.blur()},onBlur:(S8)=>{let o8=S8.currentTarget.value.trim();if(!o8)return;let e8=/[a-z%]/i.test(o8)?o8:`${o8}px`;c(e,e8)}},`${e}:${A0??""}`)},m7=Object.entries(D),P7=Object.entries(_),E9=()=>{let e=(X.tag||"").toLowerCase(),q0=e==="img"||e==="video"||e==="picture"||e==="svg"||e==="canvas"||!!F["object-fit"]||!!F["object-position"]||!!F["aspect-ratio"],j0=(e==="img"||e==="video")&&!!X.attrs?.src&&!!W;return{showMedia:q0,canReplace:j0}},l6=(e)=>M(G0,{children:[e&&z("div",{className:"st-cp-mediabtn",children:z("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>W(X),children:"Replace…"})}),M0("object-fit",Z0("object-fit",k20)),M0("object-position",v9("object-position")),M0("aspect-ratio",M("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:W00.includes(F["aspect-ratio"])?F["aspect-ratio"]:"",onChange:(A0)=>{let q0=A0.target.value;if(c("aspect-ratio",q0),q0&&q0!=="auto"&&F.height)H0("height")},children:[z("option",{value:"",disabled:!0,children:Z7(U["aspect-ratio"])||"—"}),W00.map((A0)=>z("option",{value:A0,children:A0},A0))]}))]});return M("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:L8,children:[M("div",{className:"st-cp-id",children:[M("span",{className:"st-cp-idtag",children:[X.tag||"element",X.classes?M("span",{className:"st-cp-idcls",children:[".",X.classes.split(/\s+/)[0]]}):null]}),z("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:z(wA,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:z(Y7,{as:qW,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:z(Y7,{as:_W,size:12}),label:"Designer — Figma vocabulary"}],onChange:x})})]}),Z==="designer"?M(G0,{children:[D9("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let e=(F.display||Z7(U.display)||"").trim();return e==="flex"||e==="inline-flex"?M(G0,{children:[M0("flex-direction",c0("flex-direction",k8),void 0,"Direction"),M0("align-items",z(Eh,{value:z8(),onChange:Q9,ariaLabel:"auto-layout alignment"}),W8("align-items"),"Alignment"),M0("gap",q8("gap","space"),void 0,"Gap"),M("div",{className:"st-cp-modes",children:[d0("width"),d0("height")]}),M("div",{className:"st-cp-box","aria-label":"padding",children:[M("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[i8(W8("padding-top")),"padding"]}),g8("padding-top","padding"),g8("padding-right","padding"),g8("padding-bottom","padding"),g8("padding-left","padding")]}),z("div",{className:"st-cp-clustermore-row",children:y0("Auto layout")}),m["Auto layout"]?M0("flex-wrap",z(CQ,{checked:/^wrap/.test(F["flex-wrap"]||Z7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(q0)=>c("flex-wrap",q0?"wrap":"nowrap")}),W8("flex-wrap"),"Wrap"):null]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>c("display","flex"),children:"+ Auto layout (flex)"})})()),D9("Size",["width","height","min-width","max-width","min-height","max-height"],M(G0,{children:[M0("width",w9("width"),void 0,"Width"),M0("height",w9("height"),void 0,"Height"),z("div",{className:"st-cp-clustermore-row",children:y0("Size")}),m.Size?M(G0,{children:[M0("min-width",w9("min-width"),void 0,"Min width"),M0("max-width",w9("max-width"),void 0,"Max width"),M0("min-height",w9("min-height"),void 0,"Min height"),M0("max-height",w9("max-height"),void 0,"Max height")]}):null]})),D9("Position",["position","top","right","bottom","left","z-index"],M(G0,{children:[M0("position",Z0("position",X00),void 0,"Position"),M("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[M("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[i8(W8("top")),"inset"]}),s9("top"),s9("right"),s9("bottom"),s9("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||Z7(U.position)||"static"})]}),(F.position||Z7(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:y0("Position")}),m.Position?M0("z-index",w9("z-index"),void 0,"Layer order"):null]}),!1),D9("Fill",["background-color"],M0("background-color",G6("background-color"),void 0,"Fill")),D9("Stroke",["border-width","border-style","border-color"],M0("border",H8(),W8("border-width"),"Stroke")),D9("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],M0("border-radius",N8(),W8("border-radius"),"Corner radius")),D9("Effects",["box-shadow","filter","mix-blend-mode"],M(G0,{children:[M0("box-shadow",b7("box-shadow","shadow")||v9("box-shadow"),void 0,"Shadow"),M0("filter",w0(),W8("filter"),"Blur"),M0("mix-blend-mode",Z0("mix-blend-mode",Y00),void 0,"Blend")]})),D9("Opacity",["opacity"],M0("opacity",K8(),void 0,"Opacity")),D9("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],M(G0,{children:[M0("font-family",Z0("font-family",ae),void 0,"Font"),M0("color",G6("color"),void 0,"Color"),M0("font-size",q8("font-size","type"),void 0,"Size"),M0("font-weight",Z0("font-weight",re),void 0,"Weight"),M0("line-height",w9("line-height","lh"),void 0,"Line height"),M0("text-align",c0("text-align",T9),void 0,"Align"),z("div",{className:"st-cp-clustermore-row",children:y0("Text")}),m.Text?M(G0,{children:[M0("letter-spacing",w9("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),M0("font-style",Z0("font-style",I20),void 0,"Style"),M0("text-transform",Z0("text-transform",J00),void 0,"Case"),M0("white-space",Z0("white-space",Q00),void 0,"Whitespace")]}):null]})),D9("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],M("div",{className:"st-cp-box","aria-label":"margin",children:[M("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[i8(W8("margin-top")),"margin"]}),g8("margin-top","margin"),g8("margin-right","margin"),g8("margin-bottom","margin"),g8("margin-left","margin")]})),(()=>{let{showMedia:e,canReplace:A0}=E9();return e?D9("Media",["object-fit","object-position","aspect-ratio"],l6(A0)):null})()]}):M(G0,{children:[U8("Layout",(()=>{let e=(F.display||Z7(U.display)||"").trim(),A0=e==="flex"||e==="inline-flex",q0=e==="grid"||e==="inline-grid";return M(G0,{children:[M0("display",Z0("display",R20)),A0?M(G0,{children:[M0("flex-direction",c0("flex-direction",k8)),M0("flex-wrap",z(CQ,{checked:/^wrap/.test(F["flex-wrap"]||Z7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(j0)=>c("flex-wrap",j0?"wrap":"nowrap")}),W8("flex-wrap"))]}):null,A0||q0?M(G0,{children:[M0("align-items",c0("align-items",A8)),M0("justify-content",c0("justify-content",_9)),M0("gap",q8("gap","space"))]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>c("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let e=(F.display||Z7(U.display)||"").trim();if(!(e==="grid"||e==="inline-grid"))return null;let q0=F["grid-template-columns"]||"",j0=F["grid-template-rows"]||"",n0=PO(q0),y8=PO(j0),S8=n0.length>0||!q0.trim(),o8=y8.length>0||!j0.trim();return U8("Grid",M(G0,{children:[S8?z(Z00,{label:"Columns",tracks:n0,editable:K,onChange:(e8)=>c("grid-template-columns",RO(e8))}):M("div",{className:"st-cp-note",children:["Columns use ",z("code",{children:q0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),o8?z(Z00,{label:"Rows",tracks:y8,editable:K,onChange:(e8)=>c("grid-template-rows",RO(e8))}):M("div",{className:"st-cp-note",children:["Rows use ",z("code",{children:j0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),U8("Position",M(G0,{children:[M0("position",Z0("position",X00)),M("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[M("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[i8(W8("top")),"inset"]}),s9("top"),s9("right"),s9("bottom"),s9("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||Z7(U.position)||"static"})]}),(F.position||Z7(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,M0("z-index",w9("z-index"))]})),(X.parentDisplay==="grid"||X.parentDisplay==="inline-grid")&&U8("Grid item",M(G0,{children:[M("div",{className:"st-cp-note",children:["Manual cell placement — ",z("code",{children:"start / end"})," or ",z("code",{children:"start / span N"}),"."]}),M0("grid-column",v9("grid-column")),M0("grid-row",v9("grid-row"))]})),U8("Typography",M(G0,{children:[M0("font-family",Z0("font-family",ae)),M0("color",G6("color")),M0("font-size",q8("font-size","type")),M0("font-weight",Z0("font-weight",re)),M0("line-height",w9("line-height","lh")),M0("letter-spacing",w9("letter-spacing",null,{min:-1/0})),M0("text-align",c0("text-align",T9)),M0("font-style",I8(),W8("font-style")),M0("text-transform",Z0("text-transform",J00)),M0("white-space",Z0("white-space",Q00))]})),U8("Spacing",z(G0,{children:M("div",{className:"st-cp-box","aria-label":"margin and padding",children:[M("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[i8(W8("margin-top")),"margin"]}),g8("margin-top","margin"),g8("margin-right","margin"),g8("margin-bottom","margin"),g8("margin-left","margin"),M("div",{className:"st-cp-boxpad",children:[M("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[i8(W8("padding-top")),"padding"]}),g8("padding-top","padding"),g8("padding-right","padding"),g8("padding-bottom","padding"),g8("padding-left","padding"),M("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(F.width)||X.bounds?.w||0)," × ",Math.round(Number.parseFloat(F.height)||X.bounds?.h||0)]})]})]})})),U8("Size",M(G0,{children:[M("div",{className:"st-cp-modes",children:[d0("width"),d0("height")]}),M0("width",w9("width")),M0("height",w9("height")),M0("min-width",w9("min-width")),M0("max-width",w9("max-width")),M0("min-height",w9("min-height")),M0("max-height",w9("max-height")),M0("overflow",c0("overflow",Y9)),X8?M(G0,{children:[z("div",{className:"st-cp-subhd",children:"In flex parent"}),M0("align-self",Z0("align-self",T20)),M0("flex-grow",w9("flex-grow",null,{unitless:!0})),M0("flex-shrink",w9("flex-shrink",null,{unitless:!0})),M0("flex-basis",w9("flex-basis"))]}):null]})),(()=>{let{showMedia:e,canReplace:A0}=E9();return e?U8("Media",l6(A0)):null})(),U8("Appearance",M(G0,{children:[M0("background-color",G6("background-color")),M0("border-radius",N8(),W8("border-radius")),M0("border",H8(),W8("border-width")),M0("box-shadow",b7("box-shadow","shadow")||v9("box-shadow")),M0("filter",w0(),W8("filter")),M0("mix-blend-mode",Z0("mix-blend-mode",Y00)),M0("opacity",K8()),M0("rotation",m0(),W8("transform")),M0("transform",v9("transform")),M0("transform-origin",v9("transform-origin"))]})),(()=>{let e=Object.entries(C).find(([,A0])=>typeof A0==="string"&&A0.startsWith("err:"));return e?M("div",{className:"st-cp-save is-err",role:"status",children:[z(A9,{name:"x",size:12}),e[0],": ",e[1].slice(4)]}):null})(),U8("Advanced",M("div",{className:"st-cp-advbody",children:[m7.length?M(G0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),m7.map(([e,A0])=>M("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:e,"aria-label":`custom property ${e} name`}),z("input",{className:"st-cp-fin",defaultValue:A0,"aria-label":`${e} value`,onKeyDown:(q0)=>{if(q0.key==="Enter")q0.currentTarget.blur()},onBlur:(q0)=>U0(e,q0.currentTarget.value)},`cs:${e}:${A0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${e}`,title:"remove",onClick:()=>r(e),children:z(A9,{name:"x",size:11})})]},`cs:${e}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add CSS property"}),z(S20,{commit:U0}),z("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),P7.length?M(G0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),P7.map(([e,A0])=>M("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:e,"aria-label":`attribute ${e} name`}),z("input",{className:"st-cp-fin",defaultValue:A0,"aria-label":`${e} value`,onKeyDown:(q0)=>{if(q0.key==="Enter")q0.currentTarget.blur()},onBlur:(q0)=>X0(e,q0.currentTarget.value)},`at:${e}:${A0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${e}`,title:"remove",onClick:()=>D0(e),children:z(A9,{name:"x",size:11})})]},`at:${e}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),z(b20,{commit:X0})]}))]}),M("div",{className:"st-cp-legend",children:[M("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),M("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),M("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},X.id)}function S20({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return M("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom property name",placeholder:"property",value:J,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 b20({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return M("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom attribute name",placeholder:"data-…",value:J,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 y20={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function j20(X,J,Q,Y){if(!Array.isArray(X)||J===Q)return X;let W=JSON.parse(JSON.stringify(X)),G=null,Z=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===J)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 X;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:X}var f20=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function D00({node:X,depth:J,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:q,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:D,onToggleLock:_,onRename:R}){let w=`${X.id}:${X.index}`,O=X.children&&X.children.length>0,P=W.has(w),I=!!X.synthetic,k=!I&&F?F[X.id]:null,$=!I&&!!D?.has(w),[C,y]=u.useState(!1),[v,h]=u.useState(""),l=!I&&X.id===Q&&(Y==null||X.index===Y),o=G?.has(w)?G.get(w):!!X.hidden,x=!!q&&!I&&!$,m=()=>{y(!1);let s=v.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!s||s===(X.dcElement??""))return;R?.(X,s)},p=N?.key===w,f=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 M(G0,{children:[M("div",{className:"st-layer st-layer--row"+(l?" is-sel":"")+(o?" is-hidden":"")+(I?" is-group":"")+(k?" is-instance":"")+($?" is-locked":""),style:{paddingLeft:6+J*14,...f},role:"treeitem","aria-selected":I?void 0:l,"aria-expanded":O?!P:void 0,"aria-grabbed":x?p:void 0,tabIndex:0,title:I?`${X.tag} · group (unstamped wrapper)`:`${X.tag} · ${X.type}${R?" · F2 to rename":""}`,"data-layer-key":w,onClick:()=>I?O&&Z(w):H(X),onMouseEnter:()=>!I&&K(X),onMouseLeave:()=>K(null),onPointerDown:x?(s)=>B(s,X,w):void 0,onKeyDown:(s)=>{if(s.key==="Enter"||s.key===" ")if(s.preventDefault(),I)O&&Z(w);else H(X);else if(s.key==="F2"&&R&&!I)s.preventDefault(),h(X.dcElement||X.label||""),y(!0)},children:[O?z("button",{type:"button",className:"st-layer-caret","aria-label":P?"Expand":"Collapse",onClick:(s)=>{s.stopPropagation(),Z(w)},children:P?"▸":"▾"}):z("span",{className:"st-layer-caret","aria-hidden":"true"}),k?z("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:k.root?"◆":"◇"}):z(A9,{name:y20[X.type]||"box",size:12,className:"st-layer-ticon"}),C?z("input",{className:"st-layer-rename",value:v,autoFocus:!0,"aria-label":`Rename ${X.label}`,onFocus:(s)=>s.target.select(),onChange:(s)=>h(s.target.value),onClick:(s)=>s.stopPropagation(),onPointerDown:(s)=>s.stopPropagation(),onBlur:m,onKeyDown:(s)=>{if(s.stopPropagation(),s.key==="Enter")m();else if(s.key==="Escape")y(!1)}}):z("span",{className:"st-layer-label",onDoubleClick:R&&!I?(s)=>{s.stopPropagation(),h(X.dcElement||X.label||""),y(!0)}:void 0,children:X.label}),z("span",{className:"st-layer-type",children:k?k.component:X.type}),_&&!I?z("button",{type:"button",className:"st-layer-lock","aria-label":$?`Unlock ${X.label}`:`Lock ${X.label}`,"aria-pressed":$,title:$?"Unlock":"Lock",onClick:(s)=>{s.stopPropagation(),_(w)},children:z(A9,{name:$?"lock":"unlock",size:12})}):null,U&&!I?z("button",{type:"button",className:"st-layer-eye","aria-label":o?`Show ${X.label}`:`Hide ${X.label}`,"aria-pressed":o,title:o?"Show":"Hide",onClick:(s)=>{s.stopPropagation(),U(X)},children:z(A9,{name:o?"eye-off":"eye",size:13})}):null]}),O&&!P?X.children.map((s,n)=>z(D00,{node:s,depth:J+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:q,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:D,onToggleLock:_,onRename:R},`${s.id}:${s.index}`)):null]})}function v20({el:X}){let J=X?.computed||{},Q=X?.authored||{},Y=(U)=>{let q=Q[U];if(q&&/var\(\s*--/.test(q))return q.replace(/^var\(\s*|\s*\)$/g,"");return J[U]||q||""},W=(U,q)=>{let B=J[q]||Q[q];if(!B)return null;return M("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:U}),M("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(q)})]})]},U)},G=J["border-radius"]&&J["border-radius"]!=="0px",Z=G?fQ(J["border-radius"]).n||J["border-radius"]:null,H=J["font-size"]||J["font-weight"]?[J["font-size"],J["font-weight"]].filter(Boolean).join(" / "):null;if(!(J["background-color"]||J.color||G||H))return null;return M(G0,{children:[G?M("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Radius"}),M("div",{className:"st-insp-fields",children:[M("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?M("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 O00(X){if(X.artboardId)return X.artboardId;let J=/^\[data-dc-screen="([^"]+)"\]$/.exec(X.selector||"");return J?J[1]:null}var h20=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],x20=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function g20({el:X,cfg:J,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let K=O00(X),U=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),q=N00(X.file,J),B=F00(J,U,q),N=(f)=>B.map((s)=>({ds:s.name,names:s[f]||[],vals:s.vals})).filter((s)=>s.names.length),F=(f)=>N(f).flatMap((s)=>(s.names||[]).map((n)=>({name:n,value:s.vals?.[n]||""}))),D=(f)=>{let s=/^var\(\s*(--[\w-]+)\s*\)$/.exec(f||"");if(!s)return f||"";for(let n of B){let c=n.vals?.[s[1]];if(c)return c}return""},_=Number.isFinite(X.worldW)?X.worldW:Number.isFinite(X.bounds?.w)?X.bounds.w:null,R=Number.isFinite(X.worldH)?X.worldH:Number.isFinite(X.bounds?.h)?X.bounds.h:null,w=(f,s)=>{if(!K)return;let n=Number.isFinite(f)&&f>0?Math.round(f):void 0,c=Number.isFinite(s)&&s>0?Math.round(s):void 0;if(n==null&&c==null)return;Q?.(K,n,c)},O=Object.entries(O5).find(([,f])=>f.width===_&&f.height===R)?.[0],P=Object.entries(O5).find(([,f])=>f.width===_)?.[0],I=X.attrs?.["data-dc-fixed"]==="true",k=X.attrs?.["data-dc-bg"]??"",$=X.attrs?.["data-dc-padding"]??"",C=X.attrs?.["data-dc-layout"]??"",y=X.attrs?.["data-dc-gap"]??"",v=X.attrs?.["data-dc-kind"]||"digital",h=null;try{h=X.attrs?.["data-dc-print"]?JSON.parse(X.attrs["data-dc-print"]):null}catch{}let l=(f)=>{if(!K)return;let s=null;if(f==="print"&&!h){let n={paper:"a4"};try{let c=U2(n);if(c)s={defaults:n,widthPx:c.widthPx,heightPx:c.heightPx}}catch{}}if(G?.(K,f==="digital"?null:f,s),f==="web"&&I)Y?.(K,!1,void 0)},o=(f)=>{if(!K)return;let s={paper:"a4",...h,...f},n;try{n=U2(s)}catch{return}Q?.(K,n.widthPx,n.heightPx),Z?.(K,s)},x=(f,s)=>{if(!K)return;let n=Number.isFinite(s)?s:R,c=f&&Number.isFinite(n)?Math.round(n):void 0;Y?.(K,f,c)},m=(f)=>{let s=r$(I,f);if(s.kind==="resize")w(null,s.height);else if(s.kind==="promote-to-fixed")x(!0,s.height)},p=(f)=>{if(!K)return;W?.(K,f)};return M("section",{className:"st-cp-sec",children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Artboard"})}),M("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[z(JX,{value:_??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(f)=>w(f,null)}),z(JX,{value:R??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:I,onCommit:m})]}),z("div",{style:{padding:"0 12px 8px"},children:v==="print"?M("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:h?.paper??"",onChange:(f)=>o({paper:f.currentTarget.value}),children:[z("option",{value:"",disabled:!0,children:"Paper size…"}),K2.map((f)=>M("option",{value:f.id,children:[f.label," — ",f.width,"×",f.height,f.unit]},f.id))]}):v==="web"?M("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:P??"",onChange:(f)=>{let s=O5[f.currentTarget.value];if(s)w(s.width,null)},children:[z("option",{value:"",disabled:!0,children:P?`${O5[P].label} — ≤ ${O5[P].width}px`:"Breakpoint…"}),Object.entries(O5).map(([f,s])=>M("option",{value:f,children:[s.label," — ≤ ",s.width,"px breakpoint"]},f))]}):M("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:O??"",onChange:(f)=>{let s=O5[f.currentTarget.value];if(s)w(s.width,s.height)},children:[z("option",{value:"",disabled:!0,children:O?O5[O].label:"Preset size…"}),Object.entries(O5).map(([f,s])=>M("option",{value:f,children:[s.label," — ",s.width,"×",s.height]},f))]})}),z("div",{style:{padding:"0 12px 8px"},children:z(rB,{value:I?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(f)=>x(f==="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(EW,{value:v,ariaLabel:"artboard kind",options:x20.map(([f,s])=>({value:f,label:s})),onChange:l})}),v!=="print"&&K&&H?z("div",{style:{padding:"0 12px 8px"},children:M("select",{className:"st-cp-nsel","aria-label":"duplicate artboard at breakpoint width",value:"",onChange:(f)=>{let s=O5[f.currentTarget.value];if(s)H(K,s.width);f.currentTarget.value=""},children:[z("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(O5).map(([f,s])=>M("option",{value:f,children:[s.label," — ",s.width,"px"]},f))]})}):null,v==="print"?M(G0,{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(rB,{value:h?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(f)=>o({orientation:f})})}),z("div",{style:{padding:"0 12px 8px"},children:z(JX,{value:Number.isFinite(h?.bleedMm)?h.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:(f)=>o({bleedMm:f})})})]}):null,z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Style"})}),M("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let f=D(k),s=/var\(\s*--/.test(k),n=s?k.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):k;return z(EV,{swatch:z(FF,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:N("color"),current:k,activeDs:q,swatchBg:f,seedHex:MF(f)||"#000000",onPick:(c)=>p({background:c||null}),label:"artboard background colour"}),displayValue:n,bound:s,ariaLabel:"artboard background",onValue:(c)=>p({background:(c||"").trim()||null})})})(),z(EW,{value:C,ariaLabel:"artboard body layout",options:h20.map(([f,s])=>({value:f,label:s})),onChange:(f)=>p({layout:f||null})}),M("div",{style:{display:"flex",gap:8},children:[z(aB,{value:/^var\(/.test($)?$:Number.parseFloat($)||0,tokens:F("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(f)=>p({padding:typeof f==="string"?f:f>0?f:null})}),z(aB,{value:/^var\(/.test(y)?y:Number.parseFloat(y)||0,tokens:F("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(f)=>p({gap:typeof f==="string"?f:f>0?f:null})})]})]})]})}var cR=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,m20=new RegExp(cR.source,"gi");function u20(X){if(!X||Array.isArray(X))return null;if(X.photoAsset)return X.photoAsset;let J=X.html||"";if((X.tag||"").toLowerCase()!=="img"){let W=[...new Set(J.match(m20)||[])],G=[...new Set([...J.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(J))return W[0];return null}let Q=/data-photo-asset="([^"]+)"/.exec(J);if(Q)return Q[1];let Y=cR.exec(`${X.attrs?.src||""} ${J}`);return Y?Y[0]:null}function l20({testId:X,selected:J,onClose:Q,layersTree:Y,componentMap:W,lockedKeys:G,onToggleLock:Z,onDetachInstance:H,canvasFile:K,onSelectLayer:U,onHoverLayer:q,onReorderLayer:B,layersBusyRef:N,cfg:F,onOptimistic:D,onRecordEdit:_,onReplaceMedia:R,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:P,onSetArtboardKind:I,onSetArtboardPrint:k,onDuplicateArtboard:$,onUndoRedo:C,editScope:y,tab:v,onTabChange:h,width:l,resizing:o,photoSel:x,photoRev:m,onPhotoEdit:p,onPhotoRemoveBackground:f,onPhotoRecordEdit:s,onPhotoUndoRedo:n,layersOnly:c=!1,hideLayersTab:U0=!1,cpMode:X0,onSetCpMode:H0}){let[r,D0]=u.useState("inspect"),z0=c?"layers":v??r,l0=(m0)=>{D0(m0),h?.(m0)},[X8,d0]=u.useState(()=>new Set),[$0,O0]=u.useState(()=>new Map);u.useEffect(()=>{let m0=Array.isArray(J)?J[0]:J,w0=m0?.id;if(!w0||!Y?.nodes)return;let K8=m0.index,I8=null,k8=[];if(function _9(A8,T9){for(let Y9 of A8||[]){let b7=`${Y9.id}:${Y9.index}`;if(!Y9.synthetic&&Y9.id===w0&&(K8==null||Y9.index===K8))return I8=b7,k8.push(...T9),!0;if(Y9.children&&Y9.children.length&&_9(Y9.children,[...T9,b7]))return!0}return!1}(Y.nodes,[]),!I8)return;if(k8.length)d0((_9)=>{let A8=!1,T9=new Set(_9);for(let Y9 of k8)if(T9.delete(Y9))A8=!0;return A8?T9:_9});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${I8}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[J,Y]);let i0=(m0)=>{let w0=`${m0.id}:${m0.index}`;return $0.has(w0)?$0.get(w0):!!m0.hidden},[c8,z8]=u.useState(null),[Q9,L8]=u.useState(""),W8=(m0,w0)=>{if(!K||!m0?.id)return;fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:K,id:m0.id,attr:"data-dc-element",value:w0})}).then((K8)=>K8.json().catch(()=>({}))).then((K8)=>{if(!K8.ok)return;_?.({op:"attr",canvas:K,id:m0.id,key:"data-dc-element",before:m0.dcElement??null,after:w0})}).catch(()=>{})},b8=B?(m0,w0,K8)=>{if(N?.current)return;if(m0?.synthetic||w0?.synthetic)return;let I8=K8==="before"?`before ${w0.label}`:K8==="after"?`after ${w0.label}`:`into ${w0.label}`;L8(`Moved ${m0.label} ${I8}`),B(m0.id,w0.id,K8,{idIndex:m0.index,refIndex:w0.index})}:void 0,i8=()=>{let m0=[];return function w0(K8,I8,k8){(K8||[]).forEach((_9,A8)=>{if(m0.push({node:_9,depth:I8,parentNode:k8,siblings:K8,pos:A8}),_9.children&&_9.children.length&&!X8.has(`${_9.id}:${_9.index}`))w0(_9.children,I8+1,_9)})}(Y?.nodes,0,null),m0},p9=(m0)=>{if(m0.key!=="ArrowUp"&&m0.key!=="ArrowDown")return;if(!y0)return;let w0=i8(),K8=w0.findIndex((A8)=>A8.node.id===y0.id&&A8.node.index===y0.index);if(K8<0)return;let I8=m0.key==="ArrowDown"?1:-1,k8=w0[K8];if(!m0.altKey){let A8=w0[K8+I8];if(A8)m0.preventDefault(),U?.(A8.node);return}if(!b8||!Array.isArray(k8.siblings))return;m0.preventDefault();let _9=(A8)=>A8&&A8.children&&A8.children.length&&!X8.has(`${A8.id}:${A8.index}`);if(!m0.shiftKey){if(I8<0&&k8.pos>0)b8(k8.node,k8.siblings[k8.pos-1],"before");else if(I8>0&&k8.pos<k8.siblings.length-1)b8(k8.node,k8.siblings[k8.pos+1],"after");return}if(I8>0){let A8=k8.siblings[k8.pos+1];if(A8)b8(k8.node,A8,_9(A8)?"inside-start":"after");else if(k8.parentNode)b8(k8.node,k8.parentNode,"after")}else{let A8=k8.siblings[k8.pos-1];if(A8)b8(k8.node,A8,_9(A8)?"inside-end":"before");else if(k8.parentNode)b8(k8.node,k8.parentNode,"before")}},M0=u.useRef(null),j8=u.useRef(null),L9=(m0,w0,K8)=>{if(!b8||m0.button!==0||m0.metaKey||m0.ctrlKey||m0.shiftKey||m0.altKey)return;if(N?.current)return;let{clientX:I8,clientY:k8}=m0,_9=new Set([K8]);(function g8(s9){(s9.children||[]).forEach((m7)=>{_9.add(`${m7.id}:${m7.index}`),g8(m7)})})(w0);let A8=14,T9=6,Y9=[];(function g8(s9,m7){(s9||[]).forEach((P7)=>{let E9=`${P7.id}:${P7.index}`;if(Y9.push({node:P7,key:E9,id:P7.id,depth:m7,tag:P7.tag}),P7.children&&P7.children.length&&!X8.has(E9))g8(P7.children,m7+1)})})(Y?.nodes,0);let b7=new Map(Y9.map((g8)=>[g8.key,g8])),E0=!1,f8=(g8)=>{if(!E0){if(Math.hypot(g8.clientX-I8,g8.clientY-k8)<4)return;E0=!0}let s9=g8.clientX-I8,m7=g8.clientY-k8,P7=null,E9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((e)=>({rect:e.getBoundingClientRect(),it:b7.get(e.getAttribute("data-layer-key"))})).filter((e)=>e.it&&e.it.key!==K8);if(E9.length){let e=E9[0].rect.left,A0=E9[0].rect.right,q0=E9.length;for(let F7=0;F7<E9.length;F7++)if(g8.clientY<E9[F7].rect.top+E9[F7].rect.height/2){q0=F7;break}let j0=E9[q0-1]?.it||null,n0=E9[q0]?.it||null,y8=Math.round((g8.clientX-e-T9)/A8),S8=j0?j0.depth+(f20.has(j0.tag)?0:1):0,o8=n0?n0.depth:0,e8=Math.max(o8,Math.min(y8,S8)),P9=null,V7="before",h9=0;if(!j0){if(n0)P9=n0,V7="before",h9=n0.depth}else if(e8>j0.depth)P9=j0,V7="inside-start",h9=j0.depth+1;else if(e8===j0.depth)P9=j0,V7="after",h9=j0.depth;else{for(let F7=q0-1;F7>=0;F7--)if(E9[F7].it.depth===e8){P9=E9[F7].it;break}if(!P9)P9=j0;V7="after",h9=e8}if(P9&&P9.key!==K8&&!_9.has(P9.key)){let F7=j0?E9[q0-1].rect.bottom:E9[0].rect.top,ZX=e+T9+h9*A8;P7={refId:P9.id,position:V7,node:P9.node,y:F7,left:ZX,w:Math.max(24,A0-ZX)}}}let l6={key:K8,node:w0,dx:s9,dy:m7,target:P7};M0.current=l6,z8(l6)},v9=()=>{window.removeEventListener("pointermove",f8),window.removeEventListener("pointerup",G6),window.removeEventListener("keydown",_6,!0)},w9=()=>{let g8=(s9)=>{s9.preventDefault(),s9.stopImmediatePropagation(),document.removeEventListener("click",g8,!0)};document.addEventListener("click",g8,!0),setTimeout(()=>document.removeEventListener("click",g8,!0),300)},G6=()=>{v9();let g8=M0.current;if(M0.current=null,z8(null),E0&&g8?.target)w9(),b8(g8.node,g8.target.node,g8.target.position)},_6=(g8)=>{if(g8.key!=="Escape")return;if(g8.preventDefault(),g8.stopImmediatePropagation(),v9(),M0.current=null,z8(null),E0)w9()};window.addEventListener("pointermove",f8),window.addEventListener("pointerup",G6),window.addEventListener("keydown",_6,!0)},U8=(m0)=>d0((w0)=>{let K8=new Set(w0);if(K8.has(m0))K8.delete(m0);else K8.add(m0);return K8}),D9=(m0)=>{let w0=`${m0.id}:${m0.index}`,K8=i0(m0),I8=!K8;if(O0((k8)=>new Map(k8).set(w0,I8)),D?.({id:m0.id,artboardId:Y?.artboardId??null,index:m0.index,prop:"display",value:I8?"none":null}),!K||!m0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(I8?{canvas:K,id:m0.id,property:"display",value:"none"}:{canvas:K,id:m0.id,property:"display",reset:!0})}).catch(()=>{}),_?.({op:"css",canvas:K,id:m0.id,key:"display",before:K8?"none":null,after:I8?"none":null})},y0=Array.isArray(J)?J[0]:J,Z0=x?{asset:x.asset,kind:"annotation-image"}:(()=>{let m0=u20(y0);return m0?{asset:m0,kind:"artboard-img"}:null})(),S0=Z0?.kind==="annotation-image",c0=(m0)=>{if(!(m0.metaKey||m0.ctrlKey)||m0.altKey)return;let w0=m0.key.toLowerCase();if(w0==="z")m0.preventDefault(),n?.(m0.shiftKey?"redo":"undo");else if(w0==="y")m0.preventDefault(),n?.("redo")},q8=S0?"photo":z0==="photo"&&!Z0?"inspect":z0,N8=(m0,w0,K8)=>M("button",{type:"button",className:"st-rp-tab"+(q8===m0?" is-active":""),onClick:()=>l0(m0),children:[z(A9,{name:K8,size:14}),w0]}),H8=y0?.bounds||null;return M("aside",{className:"st-rpanel"+(o?" is-resizing":""),style:l?{width:l,flexBasis:l}:void 0,"aria-label":"Inspector","data-tour":"inspector","data-testid":X,children:[M("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:c?{display:"none"}:void 0,children:[S0?N8("photo","Photo","image"):M(G0,{children:[N8("inspect","Inspect","sliders"),!U0&&N8("layers","Layers","layers"),N8("css","CSS","code"),Z0?N8("photo","Photo","image"):null]}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:Q,children:z(A9,{name:"x",size:14})})]}),y0?.id&&!(Array.isArray(J)&&J.length>1)&&y?M("div",{className:`st-scope st-scope--${y.scope}`,title:y.scope==="shared"?`Editing this element's style changes ${y.affects} place${y.affects===1?"":"s"}${y.componentName?` (component ${y.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"}),y.scope==="shared"?`Shared${y.componentName?` · ${y.componentName}`:""} · edits ${y.affects} place${y.affects===1?"":"s"}`:"Local · this element only",y.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(y0.id,y0.index),children:"Detach"}):null]}):null,z("div",{className:"st-rp-body",children:q8==="photo"&&Z0?z("div",{onKeyDown:c0,children:z(ah,{asset:Z0.asset,ColorPicker:L00,StIcon:A9,onEdit:(m0)=>p?.(Z0.asset,m0),onRemoveBackground:f,onRecordEdit:(m0,w0)=>s?.(Z0.asset,m0,w0)},`${Z0.asset}:${m??0}`)}):!y0&&!(q8==="layers"&&Y?.nodes?.length)?z("div",{className:"st-rp-empty",children:M("p",{children:["Press ",z(MX,{children:"V"}),", then click an element to select it — or ",z(MX,{children:"⌘"}),"-click straight from Browse."]})}):y0&&q8==="inspect"?M(G0,{children:[z("div",{className:"st-rp-hd",children:y0.selector||y0.tag||"element"}),M("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Pos"}),M("div",{className:"st-insp-fields",children:[M("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"X"}),z("input",{value:H8?Math.round(H8.x):"—",readOnly:!0,"aria-label":"x position"})]}),M("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"Y"}),z("input",{value:H8?Math.round(H8.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),M("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Size"}),M("div",{className:"st-insp-fields",children:[M("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"W"}),z("input",{value:H8?Math.round(H8.w):"—",readOnly:!0,"aria-label":"width"})]}),M("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"H"}),z("input",{value:H8?Math.round(H8.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),M("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:y0.tag||"—"})})]}),y0.classes?M("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:y0.classes})})]}):null,z(v20,{el:y0})]}):q8==="layers"?M(G0,{children:[M("div",{className:"st-rp-hd",children:["Layers",Y?.nodes?.length?"":" · ancestry"]}),Y?.nodes?.length?M(G0,{children:[b8?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:j8,onKeyDown:p9,children:Y.nodes.map((m0,w0)=>z(D00,{node:m0,depth:0,selectedId:y0?.id,selectedIndex:y0?.index,collapsed:X8,hiddenOverride:$0,onToggle:U8,onSelect:(K8)=>{U?.(K8),j8.current?.focus()},onHover:(K8)=>q?.(K8),onToggleVisibility:D9,onReorder:b8,onRowPointerDown:L9,dragState:c8,componentMap:W,lockedKeys:G,onToggleLock:Z,onRename:W8},`${m0.id}:${m0.index}`))}),c8?.target?z("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:c8.target.left,top:c8.target.y-1,width:c8.target.w}}):null,z("div",{className:"sr-only",role:"status","aria-live":"polite",children:Q9})]}):y0&&Array.isArray(y0.dom_path)&&y0.dom_path.length?y0.dom_path.map((m0,w0)=>M("div",{className:"st-layer"+(w0===y0.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+w0*12},children:[z(A9,{name:"square",size:13}),m0]},w0)):z("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!y0.id&&O00(y0)?z(g20,{el:y0,cfg:F,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:P,onSetArtboardKind:I,onSetArtboardPrint:k,onDuplicateArtboard:$}):z($20,{el:y0,cfg:F,onOptimistic:D,onRecordEdit:_,onReplaceMedia:R,onUndoRedo:C,mode:X0,onSetMode:H0})})]})}function p20(){let[X,J]=u.useState([]),[Q,Y]=u.useState("Design"),[W,G]=u.useState([]),[Z,H]=u.useState(null),[K,U]=u.useState(null),q=u.useCallback((j)=>{U(j)},[]),[B,N]=u.useState(null),F=u.useRef(null);u.useEffect(()=>{F.current=B},[B]);let[D,_]=u.useState(null);u.useEffect(()=>{let j=Array.isArray(B)?B.length===1?B[0]:null:B,b=j&&typeof j.id==="string"?j.id:null;if(!b||!Z){_(null);return}let t=new AbortController,W0=new URLSearchParams({canvas:Z,id:b});return fetch(`/_api/edit-scope?${W0}`,{signal:t.signal}).then((F0)=>F0.ok?F0.json():null).then((F0)=>{if(F0?.ok)_(F0)}).catch(()=>{}),()=>t.abort()},[B,Z]);let R=u.useRef(0),w=u.useRef([]),O=u.useCallback((j)=>{if(!j?.id||!j.file)return;for(let b of w.current)clearTimeout(b);w.current=[50,450,1200,2500,5000].map((b)=>setTimeout(()=>{let t=F.current,W0=Array.isArray(t)?t[0]:t;if(!W0||W0.id!==j.id||W0.file!==j.file)return;let F0=m8.current.get(j.file);if(!F0?.contentWindow)return;try{F0.contentWindow.postMessage({dgn:"select-by-id",id:j.id,artboardId:j.artboardId??null,index:j.index??0},"*")}catch{}},b))},[]),P=u.useRef([]),I=u.useCallback((j,b)=>{if(!j||!b)return;for(let t of P.current)clearTimeout(t);P.current=[50,450,1200,2500,5000].map((t)=>setTimeout(()=>{let W0=F.current,F0=Array.isArray(W0)?W0[0]:W0;if(!F0||F0.artboardId!==j||F0.file!==b)return;let B0=m8.current.get(b);if(!B0?.contentWindow)return;try{B0.contentWindow.postMessage({dgn:"select-by-id",artboardId:j},"*")}catch{}},t))},[]),k=u.useRef(null),$=u.useRef(null),C=u.useRef(null),y=u.useRef(null),v=u.useRef(!1),h=u.useRef(null),[l,o]=u.useState(null),[x,m]=u.useState(null),p=u.useRef({canvas:null,at:0});u.useEffect(()=>{if(!Z||!l)return;let j=Date.now(),b=p.current;if(b.canvas===Z&&j-b.at<1500)return;p.current={canvas:Z,at:j},fetch(`/_api/component-map?canvas=${encodeURIComponent(Z)}`).then((t)=>t.json()).then((t)=>{if(t?.ok&&t.map&&typeof t.map==="object")m(t.map);else m(null)}).catch(()=>m(null))},[Z,l]);let[f,s]=u.useState(!1),[n,c]=u.useState(null),[U0,X0]=u.useState(null),[H0,r]=u.useState(null),[D0,z0]=u.useState(null),[l0,X8]=u.useState(null),[d0,$0]=u.useState(!1),[O0,i0]=u.useState(!1),[c8,z8]=u.useState(null),[Q9,L8]=u.useState(""),[W8,b8]=u.useState(null),[i8,p9]=u.useState(null),M0=u.useRef(null),j8=de("maude-sb-w",{min:200,max:420,def:252}),L9=de("maude-rp-w",{min:260,max:480,def:304}),[U8,D9]=u.useState(null),y0=u.useRef(null);u.useEffect(()=>{if(!U8)return;let j=(t)=>{let W0=y0.current?.getBoundingClientRect();if(!W0)return;if(U8==="sb")j8.setW(t.clientX-W0.left);else L9.setW(W0.right-t.clientX)},b=()=>D9(null);return window.addEventListener("pointermove",j),window.addEventListener("pointerup",b),()=>{window.removeEventListener("pointermove",j),window.removeEventListener("pointerup",b)}},[U8,j8.setW,L9.setW]);let Z0=u.useCallback((j)=>{clearTimeout(M0.current),M0.current=setTimeout(()=>{p9((b)=>b===j?null:b)},2500)},[]);u.useEffect(()=>{if(!i8)return;let j=setTimeout(()=>p9(null),15000);return()=>clearTimeout(j)},[i8]);let[S0,c0]=u.useState({designRel:".design",cloud:void 0}),q8=!!S0.readOnly,N8=u.useCallback(()=>{fetch("/_config").then((j)=>j.json()).then((j)=>{let b=(j.designRoot||".design").replace(/^\/+|\/+$/g,"");c0((t)=>({...t,designRel:b,tokensCssRel:j.tokensCssRel,designSystems:j.designSystems,canvasOrigin:j.canvasOrigin,readOnly:!!j.readOnly,canvasToken:j.canvasToken,version:j.version,cloud:j.cloud??null}))}).catch(()=>{})},[]);u.useEffect(()=>{N8()},[N8]),u.useEffect(()=>{let j=!1;return fetch("/_sync-status").then((b)=>b.json()).then((b)=>{if(j||!b||b.linked===!1)return;X0(b)}).catch(()=>{}),()=>{j=!0}},[]),u.useEffect(()=>{let j=!1;return fetch("/_api/git/status").then((b)=>b.json()).then((b)=>{if(!j&&b)z0(b)}).catch(()=>{}),()=>{j=!0}},[]);let[H8,m0]=u.useState({}),[w0,K8]=u.useState(null),[I8,k8]=u.useState(!1),[_9,A8]=u.useState("open"),[T9,Y9]=u.useState(Cq0),[b7,E0]=u.useState(()=>{return hR(ye,"advanced")==="designer"?"designer":"advanced"});u.useEffect(()=>{try{localStorage.setItem(ye,JSON.stringify(b7))}catch{}},[b7]);let[f8,v9]=u.useState(null),[w9,G6]=u.useState(()=>sZ(je,!0)),[_6,g8]=u.useState(()=>sZ(Se,!1)),[s9,m7]=u.useState(()=>hR(be,{})),[P7,E9]=u.useState(!1),[l6,e]=u.useState(!1);u.useEffect(()=>{if(!X9())return;let j=_v(()=>e(!0));return()=>{j.then((b)=>b()).catch(()=>{})}},[]);let[A0,q0]=u.useState(!1),[j0,n0]=u.useState(!1),[y8,S8]=u.useState(!1),[o8,e8]=u.useState(!1),[P9,V7]=u.useState(!1),{report:h9}=DA(X9()),[F7,ZX]=u.useState(!1),[vQ,QQ]=u.useState(!1),[M5,$6]=u.useState(null),[I9,y7]=u.useState(!1),[mW,L7]=u.useState(!1),[HX,_X]=u.useState(!1),[hQ,_7]=u.useState(!1),[u7,_5]=u.useState(()=>hR(xe,wK)),[H7,lY]=u.useState(()=>{try{let j=localStorage.getItem(ge);if(j==="separate"||j==="in-inspector")return j}catch{}return"separate"}),[j7,n9]=u.useState(!1),[q7,d9]=u.useState([]),[$9,mX]=u.useState(0),[pY,uX]=u.useState(!1),[zJ,YQ]=u.useState(!1),[AX,A5]=u.useState(!1),[uW,xQ]=u.useState(1),[dY,i]=u.useState(216),[J0,N0]=u.useState(null),[C0,R0]=u.useState([]),[Q8,G8]=u.useState([]),[z9,t8]=u.useState([]),[e7,wX]=u.useState(0),A6=u.useRef(0);u.useEffect(()=>{A6.current=$9},[$9]);let[D7,gQ]=u.useState(null),cY=u.useRef(null);u.useEffect(()=>{cY.current=D7},[D7]);let X6=u.useMemo(()=>PA(q7,{artboardId:[D7,J0],total:e7}),[q7,D7,J0,e7]),lX=u.useRef(null);u.useEffect(()=>{lX.current=X6},[X6]);let Z6=u.useMemo(()=>sz(q7,X6)?.fps||30,[q7,X6]),[zX,KJ]=u.useState(null),[w5,T8]=u.useState(0),V9=u.useCallback((j,b)=>{if(/concurrent edit|changed since it was read/i.test(b||""))x8("Timeline changed — reloaded, try again."),T8((t)=>t+1);else x8(`${j}: ${b||"failed"}`)},[]),[N9,UJ]=u.useState(!1),[EX,iY]=u.useState(!1),[lW,pW]=u.useState(!1),E5=u.useRef(N9);u.useEffect(()=>{if(E5.current=N9,N9){pW(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[N9]);let tZ=u.useCallback(()=>{if(!E5.current||document.hidden)pW(!0),ue("Claude finished","Your assistant turn is ready in Maude.")},[]),oY=u.useRef(0),nY=u.useCallback(()=>{if(!E5.current||document.hidden){pW(!0);let j=Date.now();if(j-oY.current<Tq0)return;oY.current=j,ue("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[PX,WQ]=u.useState("inspect"),[IK,pX]=u.useState(null),GQ=u.useRef({undo:[],redo:[]}),[dW,kK]=u.useState(0),[xJ,cW]=u.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),rY=u.useRef(xJ);u.useEffect(()=>{rY.current=xJ;try{localStorage.setItem("maude-auto-open-inspector",xJ?"1":"0")}catch{}},[xJ]);let eZ=u.useRef(!1);u.useEffect(()=>{eZ.current=HX||I8||d0||O0||N9},[HX,I8,d0,O0,N9]);let iW=u.useRef({open:{},side:wK});iW.current={open:{tree:w9,layers:hQ,inspector:HX,comments:I8,changes:d0,sync:O0,assistant:N9},side:u7};let mQ=u.useCallback((j,b)=>{if(j==="tree")G6(b);else if(j==="layers")_7(b);else if(j==="inspector")_X(b);else if(j==="comments")k8(b);else if(j==="changes")$0(b);else if(j==="sync")i0(b);else if(j==="assistant")UJ(b)},[]),oW=u.useCallback((j)=>iW.current.side?.[j]||wK[j],[]),RX=u.useCallback((j)=>{let b=oW(j);mQ(j,!0);for(let t of lR)if(t.id!==j&&oW(t.id)===b)mQ(t.id,!1)},[mQ,oW]),P5=u.useCallback((j)=>{if(iW.current.open?.[j])mQ(j,!1);else RX(j)},[RX,mQ]),gJ=RX,S6=P5,nW=u.useCallback((j)=>{if(!rY.current)return;if(q8)return;if(!j||!j.id)return;if(eZ.current)return;gJ("inspector"),WQ("css")},[gJ,q8]),aY=u.useCallback(()=>n9((j)=>!j),[]),ZQ=Lx(dR),sY=Xx({enabled:S0.cloud===null}),[rW,aW]=u.useState(!1),[tY,XH]=u.useState(!1);u.useEffect(()=>{if(!X9())return;let j=!0;return Pv().then((b)=>{if(!j)return;if(aW(!!b),!b&&!sZ($e,!1))XH(!0)}).catch(()=>{}),()=>{j=!1}},[]);let JH=u.useCallback(()=>{XH(!1);try{localStorage.setItem($e,"1")}catch{}},[]),[sW,eY]=u.useState(null);u.useEffect(()=>{if(!X9())return;let j;return kv((b)=>eY(b&&typeof b==="object"?b:{})).then((b)=>{j=b}).catch(()=>{}),()=>{try{j?.()}catch{}}},[]);let[b6,QH]=u.useState(null),[uQ,CK]=u.useState(()=>!sZ(Ce,!1)),R5=u.useCallback((j)=>{QH(Array.isArray(j)&&j.length?j:null)},[]),$K={setup:(j)=>{if(!j)return;if((j.canvas||j.requireSelection)&&W.length===0)RX("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [role="treeitem"]')?.click()}catch{}},80);if(j.inspector||j.tab||j.requireSelection)gJ("inspector");if(j.tab)WQ(j.tab);if(j.changes)gJ("changes")}},tW=u.useCallback(()=>{CK(!1);try{localStorage.setItem(Ce,"1")}catch{}},[]),[dX,X4]=u.useState(()=>sZ(he,!0)),[YH,SK]=u.useState(!1),[mJ,WH]=u.useState(()=>sZ(fe,!1)),[uJ,GH]=u.useState(()=>sZ(ve,!1)),[TX,eW]=u.useState(!1),[bK,cX]=u.useState(!1),[IX,HQ]=u.useState(0),[XG,yK]=u.useState(null),[lQ,zQ]=u.useState(!1),pQ=u.useRef(null),KQ=u.useRef(null),m8=u.useRef(new Map),M8=u.useCallback((j)=>{let b=Z?m8.current.get(Z):null;if(!b||!b.contentWindow)return;try{b.contentWindow.postMessage(j,"*")}catch{}},[Z]),dQ=u.useCallback((j,b)=>M8({dgn:"photo-preview",asset:j,edit:b}),[M8]),JG=u.useCallback((j,b,t)=>{GQ.current.undo.push({asset:j,before:b,after:t}),GQ.current.redo.length=0},[]),QG=u.useCallback((j)=>{let b=j?GQ.current.redo:GQ.current.undo;if(!b.length)return!1;let t=b.pop();(j?GQ.current.undo:GQ.current.redo).push(t);let W0=(j?t.after:t.before)||{};return dQ(t.asset,W0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(t.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(W0)}).catch(()=>{}),kK((F0)=>F0+1),!0},[dQ]),YG=u.useCallback(async(j)=>{M8({dgn:"photo-busy",asset:j,busy:!0});try{let b=await fetch(`/${j.replace(/^\/+/,"")}`);if(!b.ok)return null;let t=await b.blob(),{removeBackground:W0}=await Promise.resolve().then(() => (ke(),Ie)),F0=await W0(t),B0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":F0.type||"image/png"},body:F0}),k0=await B0.json().catch(()=>({}));if(B0.ok&&k0.path)return{maskAsset:k0.path};return null}catch(b){return console.error("[photo] background removal failed",b),null}finally{M8({dgn:"photo-busy",asset:j,busy:!1})}},[M8]);u.useEffect(()=>{let j=(W0)=>Array.from(W0.dataTransfer?.types??[]).includes("Files"),b=(W0)=>{if(j(W0))W0.preventDefault()},t=(W0)=>{if(j(W0))W0.preventDefault()};return document.addEventListener("dragover",b),document.addEventListener("drop",t),()=>{document.removeEventListener("dragover",b),document.removeEventListener("drop",t)}},[]);let w6=u.useRef({});w6.current={open:j7,comps:q7,frame:$9,total:e7,playing:pY,compId:X6,muted:AX,loop:zJ,sequences:C0,post:M8,canvas:Z};let T5=u.useRef({undo:[],redo:[]}),R7=u.useCallback((j,b,t)=>{if(typeof b!=="number")return;if(T5.current.undo.push({canvas:j,seq:b,label:t}),T5.current.redo=[],T5.current.undo.length>50)T5.current.undo.shift()},[]),K0=u.useCallback((j)=>{let b=T5.current,t=j==="undo"?b.undo:b.redo,W0=j==="undo"?b.redo:b.undo,F0=w6.current.canvas,B0=-1;for(let d=t.length-1;d>=0;d--)if(t[d].canvas===F0){B0=d;break}if(B0<0){x8(j==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let k0=t[B0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:k0.canvas,seq:k0.seq,dir:j})}).then((d)=>d.json().catch(()=>({}))).then((d)=>{if(t.splice(B0,1),d?.ok)W0.push(k0),x8(`${j==="undo"?"Undid":"Redid"}: ${k0.label}`,!0);else x8(`${j==="undo"?"Undo":"Redo"} skipped: ${d?.error||"failed"}`)}).catch(()=>x8(`${j==="undo"?"Undo":"Redo"} failed: network error`))},[]),p6=u.useCallback((j,b)=>{let t=j?.ok&&Array.isArray(j.clips)?j.clips.filter((W0)=>W0.kind==="sequence"):[];if(b==null)return null;if(typeof b==="object")return(b.stableId?t.find((W0)=>W0.stableId===b.stableId):null)||(Number.isInteger(b.index)?t[b.index]:null)||null;if(typeof b==="string")return t.find((W0)=>W0.stableId===b)||null;return t[b]||null},[]),J4=u.useCallback((j)=>{let b=w6.current.canvas;if(!b||b===d8)return;let t=cY.current||void 0,W0=`/_api/comp-clips?canvas=${encodeURIComponent(b)}${t?`&artboardId=${encodeURIComponent(t)}`:""}`;fetch(W0).then((F0)=>F0.json().catch(()=>({}))).then((F0)=>{let B0=p6(F0,j);if(!B0?.stableId)return null;return fetch("/_api/remove-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:b,artboardId:t,stableId:B0.stableId,contentHash:B0.contentHash})})}).then((F0)=>F0?F0.json():null).then((F0)=>{if(F0&&!F0.ok)console.warn("[remove-clip]",F0.error||"failed"),V9("Remove refused",F0.error);else if(F0?.ok){if(x8("Clip removed.",!0),F0.seq!=null)R7(b,F0.seq,"remove clip");KJ(null)}}).catch(()=>x8("Remove failed: network error"))},[p6,R7]),UQ=u.useCallback((j,b,t)=>{let W0=w6.current.canvas;if(!W0||W0===d8)return;let F0=cY.current||void 0,B0=`/_api/comp-clips?canvas=${encodeURIComponent(W0)}${F0?`&artboardId=${encodeURIComponent(F0)}`:""}`;fetch(B0).then((k0)=>k0.json().catch(()=>({}))).then((k0)=>{let d=k0?.ok&&Array.isArray(k0.clips)?k0.clips:[],_0=j?.transition?d.find((L0)=>L0.kind==="transition"&&L0.stableId===j.stableId)||null:p6(k0,j);if(!_0?.stableId)return null;return fetch("/_api/clip-edit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:W0,artboardId:F0,stableId:_0.stableId,contentHash:_0.contentHash,verb:b,...t})})}).then((k0)=>k0?k0.json():null).then((k0)=>{if(k0&&!k0.ok)console.warn("[clip-edit]",b,k0.error||"failed"),V9(`${b} refused`,k0.error);else if(k0?.ok){let d={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(x8(`Applied: ${d[b]||b}.`,!0),k0.seq!=null)R7(W0,k0.seq,d[b]||b)}}).catch(()=>x8(`${b} failed: network error`))},[p6,R7,V9]),[iX,f7]=u.useState(null),KX=u.useCallback((j,b="")=>new Promise((t)=>{f7({title:j,value:b,resolve:t})}),[]),VJ=u.useCallback((j)=>{f7((b)=>{return b?.resolve?.(j),null})},[]),Q4=u.useCallback((j,b)=>{let t=w6.current.canvas;if(!t||t===d8||!b||!String(b).trim())return;T7({type:"comments-add",payload:{file:t,text:String(b).trim(),selector:"",dom_path:[],tag:"",classes:"",bounds:null,html_excerpt:"",timeline:j}}),x8("Comment added.",!0)},[]);w6.current.selected=zX,w6.current.setSelected=KJ,w6.current.removeClip=J4,w6.current.clipVerb=UQ,w6.current.addComment=Q4,w6.current.askText=KX,u.useEffect(()=>{let j=(b)=>{let t=w6.current;if(!t.open||!t.comps?.length)return;let W0=b.target,F0=W0?.tagName;if(F0==="INPUT"&&W0?.type!=="range")return;if(F0==="TEXTAREA"||F0==="SELECT"||W0?.isContentEditable)return;let B0=sz(t.comps,t.compId)?.fps||30,k0=Math.max(1,t.total),d=(L0)=>{let p0=Math.max(0,Math.min(k0-1,Math.round(L0)));mX(p0),uX(!1),t.post({dgn:"timeline-seek",frame:p0,id:t.compId})},_0=()=>{let L0=new Set([0,k0-1]);for(let p0 of t.sequences||[]){L0.add(p0.from);for(let D8 of p0.keyframes||[])L0.add(D8.from),L0.add(D8.to)}return[...L0].filter((p0)=>p0>=0&&p0<k0).sort((p0,D8)=>p0-D8)};if((b.metaKey||b.ctrlKey)&&(b.key==="z"||b.key==="Z")){b.preventDefault(),K0(b.shiftKey?"redo":"undo");return}if(b.key==="Escape"){if(t.selected!=null)b.preventDefault(),t.setSelected?.(null);return}if((b.key==="Delete"||b.key==="Backspace")&&t.selected!=null){b.preventDefault(),t.removeClip?.({stableId:t.selected});return}if((b.metaKey||b.ctrlKey)&&(b.key==="b"||b.key==="B")){b.preventDefault();let L0=t.selected!=null?{stableId:t.selected}:null;if(!L0){let p0=t.sequences||[],D8=p0.find((B8)=>B8.series&&t.frame>=B8.from&&t.frame<B8.from+B8.duration)||p0.find((B8)=>t.frame>=B8.from&&t.frame<B8.from+B8.duration);if(D8?.stableId)L0={stableId:D8.stableId}}if(L0)t.clipVerb?.(L0,"split",{atFrame:t.frame});else x8("Nothing under the playhead to split.");return}if(b.key===" "||b.code==="Space")if(b.preventDefault(),t.playing)uX(!1),t.post({dgn:"timeline-pause",id:t.compId});else uX(!0),t.post({dgn:"timeline-mute",muted:t.muted,id:t.compId}),t.post({dgn:"timeline-loop",loop:t.loop,id:t.compId}),t.post({dgn:"timeline-play",id:t.compId});else if(b.key==="ArrowRight")b.preventDefault(),d(t.frame+(b.shiftKey?B0:1));else if(b.key==="ArrowLeft")b.preventDefault(),d(t.frame-(b.shiftKey?B0:1));else if(b.key==="Home")b.preventDefault(),d(0);else if(b.key==="End")b.preventDefault(),d(k0-1);else if(b.key==="."){b.preventDefault();let L0=_0().find((p0)=>p0>t.frame);if(L0!=null)d(L0)}else if(b.key===","){b.preventDefault();let L0=_0().reverse().find((p0)=>p0<t.frame);if(L0!=null)d(L0)}};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[]),u.useEffect(()=>{d9([]),mX(0),uX(!1),KJ(null),gQ(null);let j=setTimeout(()=>M8({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(j)},[Z,M8]);let[I5,Y4]=u.useState(""),[VQ,cQ]=u.useState([]),[WG,a0]=u.useState([]);u.useEffect(()=>{if(!j7||q7.length===0||!Z||Z===d8){Y4(""),cQ([]);return}let j=!0;return fetch(`/_api/canvas-source?file=${encodeURIComponent(Z)}`).then((b)=>b.ok?b.json():null).then((b)=>{if(j&&b?.ok&&typeof b.source==="string")Y4(b.source)}).catch(()=>{}),()=>{j=!1}},[j7,q7,Z,w5]),u.useEffect(()=>{if(!j7||!Z||Z===d8||!I5){cQ([]),a0([]);return}let j=!0,b=D7||void 0,t=`/_api/comp-clips?canvas=${encodeURIComponent(Z)}${b?`&artboardId=${encodeURIComponent(b)}`:""}`;return fetch(t).then((W0)=>W0.ok?W0.json():null).then((W0)=>{if(!j)return;let F0=W0?.ok&&Array.isArray(W0.clips)?W0.clips:[];cQ(F0.filter((B0)=>B0.kind==="sequence")),a0(F0.filter((B0)=>B0.kind==="transition"))}).catch(()=>{}),()=>{j=!1}},[j7,Z,I5,D7,w5]),u.useEffect(()=>{if(!I5){R0([]),G8([]),t8([]),wX(0);return}let j=J0??B?.artboardId??null,t=(j&&q7.find((B0)=>B0.artboardId===j||B0.id===j)||q7[0])?.durationInFrames||0,W0=dh(I5,t,j);gQ(W0.artboardId??j??null);let F0=W0.sequences.map((B0,k0)=>{let d=VQ[k0];if(!d)return B0;return{...B0,stableId:d.stableId,contentHash:d.contentHash,mediaProps:d.mediaProps??null,placeholder:d.placeholder??null,mediaTag:d.mediaTag??B0.mediaTag,mediaSrc:d.mediaSrc??B0.mediaSrc,replaceable:!!(d.mediaCdId||d.mediaArrayRef),layers:Array.isArray(d.layers)?d.layers:[],hidden:!!d.hidden}});R0(F0),G8(W0.audio||[]),t8(W0.transitions||[]),wX(W0.total)},[I5,VQ,B,q7,J0]);let oX=u.useCallback(()=>{X4((j)=>{let b=!j,t=Z?m8.current.get(Z):null;if(t&&t.contentWindow)try{t.contentWindow.postMessage({dgn:"view-annotations",visible:b},"*")}catch{}return b})},[Z]),UX=u.useCallback((j)=>{for(let b of m8.current.values())try{b.contentWindow.postMessage({dgn:"view-chrome",...j},"*")}catch{}},[]),o0=u.useCallback(()=>{WH((j)=>{let b=!j;return UX({minimap:b}),b})},[UX]),qQ=u.useCallback(()=>{GH((j)=>{let b=!j;return UX({zoom:b}),b})},[UX]),r0=u.useCallback(()=>{eW((j)=>{let b=!j;return UX({present:b}),b})},[UX]),iQ=u.useCallback(()=>{eW(!1),UX({present:!1})},[UX]),GG=u.useCallback(()=>{if(!Z||Z===d8)return;cX((j)=>{let b=!j;return M8({dgn:"view-chrome",print:b}),fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{overlays:{print:b}}})}).catch(()=>{}),b})},[Z,M8]);u.useEffect(()=>{let j=!1;return fetch("/_api/git-user").then((b)=>b.json()).then((b)=>{if(j)return;let t=b&&typeof b.name==="string"?b.name.trim():"";if(t)yK(t)}).catch(()=>{}),()=>{j=!0}},[]),u.useEffect(()=>{if(!Z||Z===d8){HQ(0),cX(!1);return}let j=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(Z)).then((b)=>b.json()).then((b)=>{if(j)return;let t=Array.isArray(b?.artboards)?b.artboards.length:0;HQ(t),cX(b?.overlays?.print===!0),nQ(new Set(Array.isArray(b?.locked)?b.locked:[]))}).catch(()=>{if(!j)HQ(0),cX(!1),nQ(new Set)}),()=>{j=!0}},[Z]),u.useEffect(()=>{if(!Z||Z===d8||!J0)return;let j=setTimeout(()=>{M8({dgn:"request-layers",artboardId:J0})},250);return()=>clearTimeout(j)},[Z,J0,M8]);let[oQ,nQ]=u.useState(()=>new Set),ZG=u.useCallback((j)=>{if(!Z||Z===d8)return;nQ((b)=>{let t=new Set(b);if(t.has(j))t.delete(j);else t.add(j);let W0=[...t];return fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{locked:W0}})}).catch(()=>{}),M8({dgn:"locked-set",locked:W0}),t})},[Z,M8]);u.useEffect(()=>{if(!Z||Z===d8)return;M8({dgn:"locked-set",locked:[...oQ]})},[oQ,Z,M8]),u.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",T9),localStorage.setItem(K00,T9)}catch{}for(let j of m8.current.values())try{j.contentWindow.postMessage({dgn:"theme",theme:T9},"*")}catch{}},[T9]),u.useEffect(()=>{try{localStorage.setItem(je,w9?"1":"0")}catch{}},[w9]),u.useEffect(()=>{try{localStorage.setItem(Se,_6?"1":"0")}catch{}},[_6]),u.useEffect(()=>{try{localStorage.setItem(be,JSON.stringify(s9))}catch{}},[s9]),u.useEffect(()=>{try{localStorage.setItem(fe,mJ?"1":"0")}catch{}},[mJ]),u.useEffect(()=>{try{localStorage.setItem(ve,uJ?"1":"0")}catch{}},[uJ]),u.useEffect(()=>{try{localStorage.setItem(he,dX?"1":"0")}catch{}},[dX]),u.useEffect(()=>{let j=!1;return fetch("/_api/ui-prefs").then((b)=>b.ok?b.json():Promise.reject(Error(`HTTP ${b.status}`))).then((b)=>{if(j||!b||typeof b!=="object")return;if(b.theme==="light"||b.theme==="dark")Y9(b.theme);if(typeof b.minimap==="boolean")WH(b.minimap);if(typeof b.zoom==="boolean")GH(b.zoom);if(typeof b.annotations==="boolean")X4(b.annotations);if(typeof b.autoOpenInspector==="boolean")cW(b.autoOpenInspector);if(b.panelSides&&typeof b.panelSides==="object")_5({...wK,...b.panelSides});if(b.layersMode==="separate"||b.layersMode==="in-inspector")lY(b.layersMode)}).catch(()=>{}).finally(()=>{if(!j)SK(!0)}),()=>{j=!0}},[]),u.useEffect(()=>{if(!YH)return;Iq0({theme:T9,minimap:mJ,zoom:uJ,annotations:dX,autoOpenInspector:xJ,panelSides:u7,layersMode:H7})},[YH,T9,mJ,uJ,dX,xJ,u7,H7]),u.useEffect(()=>{try{localStorage.setItem(xe,JSON.stringify(u7))}catch{}},[u7]),u.useEffect(()=>{try{localStorage.setItem(ge,H7)}catch{}},[H7]);let HG=u.useCallback((j,b)=>{m7((t)=>{let W0=t[j],F0=W0===void 0?b:W0;return{...t,[j]:!F0}})},[]),k5=u.useCallback(()=>{Y9((j)=>j==="dark"?"light":"dark")},[]),W7=u.useCallback(async()=>{try{let b=await(await fetch("/_index-data")).json();Y(b.project||"Design");let t=b.groups.map((W0)=>({...W0,tree:jq0(W0.paths,W0.stripPrefix,W0.dirs)}));J(t),c0((W0)=>({...W0,canvasDesignSystems:b.canvasDesignSystems??{},canvasKinds:b.canvasKinds??{}}))}catch(j){console.error("failed to load tree",j)}},[]);u.useEffect(()=>{W7()},[W7]);let lJ=u.useCallback(async(j)=>{try{let b=j?`/_system-data?ds=${encodeURIComponent(j)}`:"/_system-data",t=await fetch(b);if(!t.ok){console.error("failed to load system-data",t.status);return}let W0=await t.json();if(!j&&W0?.defaultDesignSystem&&!W0.ds){b8(W0);let F0=await fetch(`/_system-data?ds=${encodeURIComponent(W0.defaultDesignSystem)}`);if(F0.ok)b8(await F0.json());return}b8(W0)}catch(b){console.error("failed to load system-data",b)}},[]),W4=u.useCallback(async()=>{try{let b=await(await fetch("/_comments-all")).json();m0(b||{})}catch(j){console.error("failed to load comments",j)}},[]);u.useEffect(()=>{W4()},[W4]),u.useEffect(()=>{let j=null;function b(){let t=location.protocol==="https:"?"wss:":"ws:",W0=new WebSocket(t+"//"+location.host+"/_ws");KQ.current=W0,W0.addEventListener("open",()=>{s(!0),clearInterval(j),j=setInterval(()=>{if(W0.readyState===WebSocket.OPEN)W0.send('{"type":"ping"}')},25000)}),W0.addEventListener("close",()=>{s(!1),clearInterval(j),setTimeout(b,1000)}),W0.addEventListener("error",()=>{}),W0.addEventListener("message",(F0)=>{try{let B0=JSON.parse(F0.data);if(B0.type==="snapshot"&&B0.state)N((k0)=>G00(B0.state.selected,k0));else if(B0.type==="selected"){if(Date.now()-R.current<2000)return;let k0=B0.selected,d=Array.isArray(k0)?k0[0]:k0,_0=F.current,L0=Array.isArray(_0)?_0[0]:_0;if(N((p0)=>G00(k0,p0)),d?.id&&d.file&&(!L0||L0.id!==d.id||L0.file!==d.file))O(d)}else if(B0.type==="comments"&&typeof B0.file==="string")m0((k0)=>({...k0,[B0.file]:B0.comments||[]}));else if(B0.type==="ai-activity"&&typeof B0.file==="string"){if(zQ(!0),pQ.current)clearTimeout(pQ.current);pQ.current=setTimeout(()=>zQ(!1),8000);for(let k0 of m8.current.values())try{k0.contentWindow.postMessage({dgn:"ai-activity",file:B0.file,entry:B0.entry},"*")}catch{}}else if(B0.type==="export:job"&&B0.payload)sY.upsert(B0.payload);else if(B0.type==="sync:status"&&B0.payload)X0(B0.payload);else if(B0.type==="canvas-list-update"){if(W7(),B0.payload?.action==="moved"&&B0.payload.fromRel&&B0.payload.rel){let k0=(S0?.designRel||S0?.designRoot||".design").replace(/^\/+|\/+$/g,""),d=`${k0}/${B0.payload.fromRel}`,_0=`${k0}/${B0.payload.rel}`;G((L0)=>L0.map((p0)=>p0.path===d?{path:_0}:p0)),H((L0)=>L0===d?_0:L0)}}else if(B0.type==="config-updated")N8();else if(B0.type==="acp-focus"){if(X9())gJ("assistant")}else if(B0.type==="git-status"&&B0.payload)z0(B0.payload);else if(B0.type==="git-lifecycle"&&B0.payload){c(B0.payload);for(let k0 of m8.current.values())try{k0.contentWindow.postMessage({dgn:"git-lifecycle",payload:B0.payload},"*")}catch{}}}catch{}})}return b(),()=>{if(clearInterval(j),KQ.current)KQ.current.close()}},[W7,N8]);function T7(j){let b=KQ.current;try{if(b&&b.readyState===1)b.send(JSON.stringify(j))}catch{}}let VX=u.useCallback(async()=>{try{let j=await fetch("/_api/git/status");if(j.ok)z0(await j.json())}catch{}},[]),kX=u.useCallback(async()=>{try{let j=await fetch("/_api/git/status?remote=1");if(!j.ok)return;let b=await j.json();if(b&&b.repo!==!1)X8({remoteAhead:!!b.remoteAhead,behind:b.behind||0})}catch{}},[]),qX=u.useCallback(async(j,b)=>{try{let t=await fetch(j,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b||{})}),W0=await t.json().catch(()=>({}));return{ok:t.ok,...W0}}catch(t){return{ok:!1,error:"Network error — is the project still open?"}}},[]),zG=u.useCallback(async(j,b)=>{let t=await qX("/_api/git/commit",{message:j,files:b});if(t.ok)await VX();return t},[qX,VX]),G4=u.useCallback(async(j)=>{let b=await qX("/_api/git/discard",{files:j});if(b.ok)await VX();return b},[qX,VX]),KG=u.useCallback(async()=>{let j=await qX("/_api/git/push",{});if(j.ok)await VX(),kX();return j},[qX,VX,kX]),Z4=u.useCallback(async()=>{let j=await qX("/_api/git/pull",{});if(j.ok)await VX(),kX();if(j.conflict&&Array.isArray(j.files)&&j.files.length)z8({file:j.files[0],conflict:!0});return j},[qX,VX,kX]),UG=u.useCallback(async(j)=>{let b=await qX("/_api/git/resolve",{choice:j});if(b.ok)await VX(),kX();return b},[qX,VX,kX]),H4=u.useCallback(async(j)=>{try{let b="/_api/git/log?limit=40"+(j?`&path=${encodeURIComponent(j)}`:""),t=await fetch(b);if(!t.ok)return[];return(await t.json()).entries||[]}catch{return[]}},[]),VG=u.useMemo(()=>{let j={modified:"M",added:"A",deleted:"D",untracked:"U"},b=new Map;for(let t of D0?.files||[])b.set(t.path,j[t.status]);return b},[D0]),z4=!!S0.cloud,K4=!S0.cloud&&!!H0?.credentialed,rQ=z4||K4,U4=rQ?0:D0?.files?.length||0;u.useEffect(()=>{if(D0?.repo===!1)return;kX();let j=setInterval(kX,d0?60000:120000);return()=>clearInterval(j)},[D0?.repo,d0,kX]);let H6=u.useCallback((j)=>{if(G((b)=>{for(let t of b)if(t.path!==j)m8.current.delete(t.path);return[{path:j}]}),H(j),K8(null),U(null),j!==d8)p9(j)},[]),V4=u.useRef(!1);u.useEffect(()=>{if(V4.current)return;if(!S0.cloud)return;if(W.length>0)return;if(!X.length)return;let j=null;for(let b of X){for(let t of b.paths||[]){if(!JQ.test(t))continue;if(/(^|\/)system\//.test(t))continue;j=t;break}if(j)break}if(!j)return;V4.current=!0,H6(j)},[S0.cloud,X,W.length,H6]);let pJ=u.useCallback((j)=>{let b=typeof j==="string"?j:void 0;if(b)lJ(b);else if(!W8)lJ();H6(d8)},[W8,lJ,H6]);u.useEffect(()=>{T7({type:"tabs",tabs:W.map((j)=>j.path).filter((j)=>j!==d8)})},[W]),u.useEffect(()=>{if(Z&&Z!==d8)T7({type:"active",file:Z});else if(Z===d8)T7({type:"active",file:""});else T7({type:"active",file:""})},[Z]);let aQ=u.useCallback((j)=>{G((b)=>{let t=b.findIndex((F0)=>F0.path===j);if(t<0)return b;let W0=b.filter((F0)=>F0.path!==j);if(j===Z)if(W0.length===0)H(null);else H(W0[Math.max(0,t-1)].path);return W0}),m8.current.delete(j),p9((b)=>b===j?null:b)},[Z]),qJ=u.useCallback(()=>{if(!Z||Z===d8){if(Z===d8)lJ();return}let j=m8.current.get(Z);if(j)j.src=j.src},[Z,lJ]),q4=u.useCallback(()=>W7(),[W7]),[qG,B4]=u.useState(!1),sQ=u.useRef(!1),tQ=u.useCallback(async()=>{if(sQ.current)return;sQ.current=!0,B4(!0);try{await Promise.all([W7(),new Promise((j)=>setTimeout(j,550))])}finally{sQ.current=!1,B4(!1)}},[W7]);u.useEffect(()=>{let j=null,b=()=>{if(j)clearTimeout(j);j=setTimeout(()=>{j=null,q4()},150)};return window.addEventListener("focus",b),()=>{if(window.removeEventListener("focus",b),j)clearTimeout(j)}},[q4]);let BG=u.useCallback(async(j)=>{try{let b=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j,kind:"brief-board"})}),t=await b.json().catch(()=>({}));if(!b.ok||!t.ok)return{ok:!1,error:t.error||`create failed (${b.status})`};return await W7(),H6(t.file),{ok:!0,file:t.file}}catch(b){return{ok:!1,error:b instanceof Error?b.message:"network error"}}},[W7,H6]),N4=u.useCallback(async()=>{let j=await KX("New video name");if(!j)return;let t=(await KX("Size — 1920x1080 (landscape), 1080x1920 (portrait), 1080x1080 (square), or custom WxH","1920x1080")||"1920x1080").toLowerCase().match(/(\d{2,5})\s*[x×]\s*(\d{2,5})/),W0=t?Number(t[1]):1920,F0=t?Number(t[2]):1080,B0=Math.max(1,Math.min(60,Number(await KX("Frames per second","30"))||30));try{let k0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j,kind:"video-comp",clips:[],fps:B0,width:W0,height:F0})}),d=await k0.json().catch(()=>({}));if(!k0.ok||!d.ok){x8(`New video failed: ${d.error||`error ${k0.status}`}`);return}await W7(),H6(d.file),n9(!0),x8("New video created — drop clips on the timeline to start the cut.",!0)}catch(k0){x8(`New video failed: ${k0 instanceof Error?k0.message:"network error"}`)}},[W7,H6,KX]),NG=u.useCallback(async()=>{if(!Z||Z===d8)return;try{let j=await fetch(`/_api/annotations?file=${encodeURIComponent(Z)}`),b=j.ok?await j.text():"",t=[];if(b){let d=new DOMParser().parseFromString(b,"image/svg+xml");for(let _0 of d.querySelectorAll('[data-tool="mediaref"]')){let L0=_0.getAttribute("data-src");if(!L0)continue;t.push({src:L0,mediaKind:_0.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(t.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let F0=`${gW(RK(Z)).replace(/\.tsx$/i,"")} Video`,B0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:F0,kind:"video-comp",clips:t})}),k0=await B0.json().catch(()=>({}));if(!B0.ok||!k0.ok){window.alert(`Assemble failed: ${k0.error||`error ${B0.status}`}`);return}await W7(),H6(k0.file)}catch(j){window.alert(`Assemble failed: ${j instanceof Error?j.message:"network error"}`)}},[Z,W7,H6]),eQ=u.useCallback(({accept:j,resolveTarget:b})=>{let t=Z,W0=D7||void 0,F0=document.createElement("input");F0.type="file",F0.accept=j,F0.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(F0);let B0=()=>{if(F0.isConnected)F0.remove()};window.addEventListener("focus",()=>setTimeout(B0,300),{once:!0}),F0.addEventListener("change",()=>{let k0=F0.files?.[0];if(B0(),!k0)return;let d=`/_api/comp-clips?canvas=${encodeURIComponent(t)}${W0?`&artboardId=${encodeURIComponent(W0)}`:""}`;fetch(d).then((_0)=>_0.json().catch(()=>({}))).then((_0)=>{let L0=b(_0);if(!L0)return x8("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":k0.type||"application/octet-stream"},body:k0}).then((p0)=>p0.json().catch(()=>({}))).then((p0)=>{if(!p0?.path)return x8(`Upload failed: ${p0?.error||"unknown error"}`),null;if(L0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:t,arrayName:L0.arrayRef.arrayName,index:L0.arrayRef.index,field:L0.arrayRef.field,value:p0.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:t,id:L0.cdId,attr:"src",value:p0.path})})})}).then((_0)=>_0?_0.json():null).then((_0)=>{if(_0&&!_0.ok)x8(`Replace refused: ${_0.error||"failed"}`);else if(_0&&_0.ok){if(x8("Media replaced.",!0),_0.seq!=null)R7(t,_0.seq,"replace media")}}).catch(()=>x8("Replace failed: network error"))}),F0.click()},[Z,D7,R7]),FG=u.useCallback(async(j,b)=>{if(!window.confirm(`Move “${b}” to trash?
|
|
5654
5654
|
|
|
5655
5655
|
Its annotations, history and comments move with it. `+"You can restore it from .design/_trash/."))return;try{let W0=await fetch(`/_api/canvas?file=${encodeURIComponent(j)}`,{method:"DELETE"}),F0=await W0.json().catch(()=>({}));if(!W0.ok||!F0.ok){window.alert(`Could not delete: ${F0.error||`error ${W0.status}`}`);return}if(await W7(),Z===j)G([]),H(null)}catch(W0){window.alert(`Delete failed: ${W0 instanceof Error?W0.message:"network error"}`)}},[W7,Z]),LG=u.useCallback(async function j(b,t){try{let W0=await fetch("/_api/fs-move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:b,toDir:t})}),F0=await W0.json().catch(()=>({}));if(!W0.ok||!F0.ok)return x8(`Could not move: ${F0.error||`error ${W0.status}`}`),{ok:!1,error:F0.error};let B0=(S0?.designRel||S0?.designRoot||".design").replace(/^\/+|\/+$/g,""),k0=`${B0}/${F0.fromRel}`,d=`${B0}/${F0.toRel}`;await W7(),G((L0)=>L0.map((p0)=>p0.path===k0?{path:d}:p0)),H((L0)=>L0===k0?d:L0);let _0=k0.split("/").slice(0,-1).join("/");return x8(`Moved to ${F0.toRel.split("/").slice(0,-1).join("/")||"."}`,!0,{label:"Undo",onClick:()=>{j(d,_0)}}),{ok:!0}}catch(W0){return x8(`Move failed: ${W0 instanceof Error?W0.message:"network error"}`),{ok:!1,error:"network error"}}},[W7,S0]),DG=u.useCallback(async(j,b)=>{try{let t=await fetch("/_api/fs-mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parent:j,name:b})}),W0=await t.json().catch(()=>({}));if(!t.ok||!W0.ok){let F0=W0.error||`error ${t.status}`;return x8(`Could not create folder: ${F0}`),{ok:!1,error:F0}}return await W7(),{ok:!0,dir:W0.dir}}catch(t){let W0=t instanceof Error?t.message:"network error";return x8(`Create folder failed: ${W0}`),{ok:!1,error:W0}}},[W7]),OG=u.useCallback(async(j,b)=>{if(!window.confirm(`Delete folder "${b}"?
|
|
5656
5656
|
|