@1agh/maude 0.53.0 → 0.53.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/studio/bin/_import-asset.mjs +1 -6
- package/apps/studio/bin/_import-brand.mjs +1 -1
- package/apps/studio/bin/_video-playwright.mjs +5 -1
- package/apps/studio/dist/client.bundle.js +1 -1
- package/apps/studio/http.ts +13 -3
- package/apps/studio/test/report-proxy.test.ts +125 -0
- package/package.json +8 -8
|
@@ -5650,7 +5650,7 @@ ${B.block}`:q,O=[],M=new Map;for await(let E of X.prompt(F,J(),z,Q?.(),Y?.(),Z?.
|
|
|
5650
5650
|
|
|
5651
5651
|
> Maude ${m.app.maudeVersion} · ${m.app.platform} ${m.app.arch} · ${m.app.surface}
|
|
5652
5652
|
> Local report bundle: \`${l?.dir??".design/_reports/"}\` (attach its files here)`),s=`${xZ0}?title=${p}&body=${h}&labels=report`;if(p8())try{await O1(s)}catch{window.open(s,"_blank","noopener")}else window.open(s,"_blank","noopener");P({fallbackDir:l?.dir??null}),Y("done")}catch{R("Saving the local bundle failed too — please file the issue by hand.")}}let g=W.trim().length>0;return K("div",{className:"st-scrim",onClick:b,"data-testid":"report-bug-dialog",children:A("div",{className:"st-dialog rb-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"rb-title",onClick:(m)=>m.stopPropagation(),children:[A("div",{className:"st-dialog-hd",children:[K("span",{className:"st-dialog-title",id:"rb-title",children:"Report a bug"}),K("button",{type:"button",className:"st-iconbtn",onClick:b,"aria-label":"Close",children:"×"})]}),A("div",{className:"st-dialog-bd rb-body",children:[Q==="describe"&&A(W0,{children:[K("label",{className:"rb-label",htmlFor:"rb-desc",children:"What happened? What did you expect instead?"}),K("textarea",{id:"rb-desc",className:"textarea","data-testid":"report-bug-description",rows:5,autoFocus:!0,value:W,onChange:(m)=>G(m.target.value),placeholder:"e.g. Clicking Export → PNG shows a spinner forever…"}),K("p",{className:"rb-hint",children:"Next you'll see exactly what gets attached — nothing is sent until you approve it."}),A("footer",{className:"rb-actions",children:[K("button",{type:"button",className:"st-btn",onClick:b,children:"Cancel"}),K("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-preview",disabled:!g,onClick:()=>Y("preview"),children:"Review & attach"})]})]}),Q==="preview"&&A(W0,{children:[A("div",{className:"rb-section",children:[A("div",{className:"rb-section-hd",children:[A("span",{children:["Screenshots (",z.length,")"]}),z.length>0&&K("button",{type:"button",className:`rb-link${M?" is-on":""}`,"data-testid":"report-bug-redact",onClick:()=>E((m)=>!m),children:M?"Done redacting":"Redact…"})]}),z.length===0?A("p",{className:"rb-hint",children:["No screenshot attached. Paste one (⌘V) to add it — up to ",q_,"."]}):A(W0,{children:[M&&K("p",{className:"rb-hint",children:"Drag over anything private — it ships as solid black."}),K("div",{className:"rb-shots",children:z.map((m,c)=>K(mZ0,{shot:m,redacting:M,onRects:(f)=>U((l)=>l.map((p,h)=>h===c?{...p,rects:f}:p)),onRemove:()=>{URL.revokeObjectURL(m.url),U((f)=>f.filter((l,p)=>p!==c))}},m.url))}),z.length<q_&&K("p",{className:"rb-hint",children:"Paste (⌘V) to attach another screenshot."})]})]}),A("div",{className:"rb-section",children:[K("div",{className:"rb-section-hd",children:K("span",{children:"Included with the report"})}),A("label",{className:"rb-check",children:[K("input",{type:"checkbox",checked:!0,disabled:!0}),A("span",{children:["Maude ",Z?.app?.maudeVersion??"…"," · ",Z?.app?.platform??"…"," ",Z?.app?.arch??""," · ",p8()?"desktop app":"browser"]})]}),Z?.context?.activeCanvas&&A("label",{className:"rb-check",children:[K("input",{type:"checkbox",checked:F.activeCanvas,onChange:(m)=>O({...F,activeCanvas:m.target.checked})}),A("span",{children:["Active canvas path — ",K("code",{children:Z.context.activeCanvas})]})]}),Z?.context?.projectName&&A("label",{className:"rb-check",children:[K("input",{type:"checkbox",checked:F.projectName,onChange:(m)=>O({...F,projectName:m.target.checked})}),A("span",{children:["Project name — ",K("code",{children:Z.context.projectName})]})]}),Z?.logs?.serverLogTail?A("label",{className:"rb-check",children:[K("input",{type:"checkbox","data-testid":"report-bug-consent-logs",checked:F.logTail,onChange:(m)=>O({...F,logTail:m.target.checked})}),A("span",{children:["Recent server log (",Z.logs.serverLogTail.split(`
|
|
5653
|
-
`).length," lines, paths & secrets scrubbed) —"," ",A("details",{className:"rb-details",children:[K("summary",{children:"view"}),K("pre",{className:"rb-log",children:Z.logs.serverLogTail})]})]})]}):null,p8()&&q.length>0&&A("label",{className:"rb-check",children:[K("input",{type:"checkbox",checked:F.crashLogs,onChange:(m)=>O({...F,crashLogs:m.target.checked})}),A("span",{children:["Crash logs (",q.length,") — ",K("code",{children:q.map((m)=>m.name).join(", ")})]})]})]}),A("p",{className:"rb-hint",children:["Your description and the system info above become a"," ",K("strong",{children:"public GitHub issue"}),"; screenshots and logs go to a private repository only maintainers can open."]}),A("footer",{className:"rb-actions",children:[K("button",{type:"button",className:"st-btn",onClick:()=>Y("describe"),children:"Back"}),K("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-send",onClick:y,children:"Send report"})]})]}),Q==="sending"&&K("p",{className:"rb-hint",children:"Sending your report…"}),Q==="done"&&A(W0,{children:[I?.issueUrl?A("p",{children:["Thank you — your report is filed as"," ",A("button",{type:"button",className:"rb-link","data-testid":"report-bug-issue-link",onClick:()=>{if(p8())O1(I.issueUrl).catch(()=>navigator.clipboard?.writeText(I.issueUrl));else window.open(I.issueUrl,"_blank","noopener")},children:["report #",I.issueNumber]})," ","on the public Maude issue tracker. Screenshots and logs stay in a private repository only maintainers can open — the issue links to them."]}):A("p",{children:["The bundle is saved locally",I?.fallbackDir?A(W0,{children:[" ","at ",K("code",{children:I.fallbackDir})]}):null," ","and a prefilled GitHub issue was opened — attach the bundle files there."]}),K("footer",{className:"rb-actions",children:K("button",{type:"button",className:"st-btn rb-primary",onClick:b,children:"Done"})})]}),Q==="fallback"&&A(W0,{children:[K("p",{className:"rb-error","data-testid":"report-bug-error",children:w}),K("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."}),A("footer",{className:"rb-actions",children:[K("button",{type:"button",className:"st-btn",onClick:()=>Y("preview"),children:"Back"}),K("button",{type:"button",className:"st-btn rb-primary",onClick:v,children:"Save locally & open GitHub"})]})]})]})]})})}var xX=I8(b8(),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 B_="mdcc-whatsnew-seen",N_="mdcc-whatsnew-toast-dismissed";function uZ0(X){return typeof X==="string"&&/^https?:\/\//i.test(X)}function lZ0(X){try{let J=localStorage.getItem(B_);if(J)return J;localStorage.setItem(B_,X)}catch{}return X}function pZ0(){try{return localStorage.getItem(N_)}catch{return null}}function Lx(X){let[J,Q]=xX.useState([]),[Y,W]=xX.useState(X),[G,Z]=xX.useState(()=>lZ0(X)),[H,z]=xX.useState(()=>pZ0()),[U,q]=xX.useState(!1);xX.useEffect(()=>{let w=!1,R=()=>{fetch("/_api/whats-new").then((b)=>b.json()).then((b)=>{if(w)return;if(Q(Array.isArray(b?.entries)?b.entries:[]),typeof b?.version==="string")W(b.version)}).catch(()=>{})};R();let T=()=>R(),C=()=>{if(document.visibilityState==="visible")R()};return window.addEventListener("focus",T),document.addEventListener("visibilitychange",C),()=>{w=!0,window.removeEventListener("focus",T),document.removeEventListener("visibilitychange",C)}},[]);let B=Nx(J,G),F=B.length>0&&H!==Y&&!U,O=B[0]??null,M=xX.useCallback(()=>{let w=Fx(J,Y);Z(w),z(Y);try{localStorage.setItem(B_,w),localStorage.setItem(N_,Y)}catch{}},[J,Y]),E=xX.useCallback(()=>{z(Y);try{localStorage.setItem(N_,Y)}catch{}},[Y]),I=xX.useCallback(()=>q(!0),[]),P=xX.useCallback(()=>{q(!1),M()},[M]);return{entries:J,unseen:B,feedVersion:Y,panelOpen:U,openPanel:I,closePanel:P,showToast:F,toastEntry:O,dismissToast:E,markAllSeen:M}}function Dx({wn:X}){if(!X.showToast||!X.toastEntry)return null;let J=X.toastEntry,Q=X.unseen.length;return A("div",{className:"st-toast",role:"status","aria-live":"polite",children:[K("button",{type:"button",className:"st-toast-close","aria-label":"Dismiss",onClick:X.dismissToast,children:"×"}),A("div",{className:"st-toast-hd",children:[K("span",{"aria-hidden":"true",children:"✦"}),"What's new",J.version?` · v${J.version}`:""]}),K("div",{className:"st-toast-title",children:J.title}),K("div",{className:"st-toast-txt",children:J.summary}),A("div",{className:"st-toast-actions",children:[K("button",{type:"button",className:"btn btn--primary btn--sm",onClick:X.openPanel,children:Q>1?`See all (${Q})`:"Details"}),K("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(xX.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 K("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)Y()},children:A("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[A("header",{className:"help-modal-hd",children:[K("span",{className:"title",id:"mdcc-wn-title",children:"✦ What’s new in maude"}),K("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:Y,children:"×"})]}),K("div",{className:"mdcc-wn-panel__body",children:X.entries.length===0?K("p",{className:"mdcc-wn-empty",children:"Nothing new yet."}):K("ul",{className:"mdcc-wn-list",children:X.entries.map((G)=>A("li",{className:"mdcc-wn-item"+(W.has(G.id)?" is-unseen":""),children:[A("div",{className:"mdcc-wn-item__hd",children:[K("span",{className:"mdcc-wn-kind mdcc-wn-kind--"+G.kind,children:G.kind}),K("span",{className:"mdcc-wn-item__title",children:G.title}),K("span",{className:"mdcc-wn-item__ver",children:G.version?`v${G.version}`:"next"})]}),K("p",{className:"mdcc-wn-item__summary",children:G.summary}),uZ0(G.learnMore)&&K("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&&K("button",{type:"button",className:"mdcc-wn-item__tour",onClick:()=>{Y(),J(G.tour)},children:"▶ Take tour"})]},G.id))})})]})})}var h9=({as:X,size:J=14})=>K(X,{size:J,strokeWidth:1.75,style:{display:"block"}}),Ct="mdcc-usage-tour-seen",$t="mdcc-collab-tour-seen",S8="__system__",Ue="mdcc-theme",St="mdcc-show-hidden",bt="mdcc-sections-expanded",jt="maude-cp-mode",yt="mdcc-sidebar-open",ft="mdcc-minimap-visible",vt="mdcc-zoomctl-visible",xt="mdcc-annotations-visible";var tV0=30000;function eV0(X){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(X)}).catch(()=>{})}catch{}}var GR=[{id:"tree",label:"Files"},{id:"layers",label:"Layers"},{id:"inspector",label:"Inspector"},{id:"comments",label:"Comments"},{id:"changes",label:"Changes"},{id:"assistant",label:"Assistant"}],ez={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",assistant:"right"},ht="mdcc-panel-sides",gt="mdcc-layers-mode";function mt({side:X,width:J,open:Q,ids:Y,activeId:W,onPick:G,children:Z}){return A("div",{className:"st-dockslot st-dockslot--"+X+(Q?"":" is-collapsed"),style:{width:Q?J:0,flexBasis:Q?J:0},children:[Q&&Y.length>1&&K("div",{className:"st-docktabs",role:"tablist","aria-label":X+" panels",children:Y.map((H)=>K("button",{type:"button",role:"tab","aria-selected":W===H,className:"st-docktab"+(W===H?" is-active":""),onClick:()=>G(H),children:(GR.find((z)=>z.id===H)||{}).label||H},H))}),Z]})}var AQ=/\.(tsx|html?)$/i;function uN(X){return X.replace(/^\.[^/]+\//,"").replace(AQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}var HR="0.53.0";function ut(X,J){try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(X,{body:J})}catch{}}function Xq0(){if(typeof window>"u")return"dark";try{let X=localStorage.getItem(Ue);if(X==="light"||X==="dark")return X}catch{}return"dark"}function kZ(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 XR(X,J){if(typeof window>"u")return J;try{let Q=localStorage.getItem(X);return Q?JSON.parse(Q):J}catch{return J}}function Jq0(X){if(X.kind==="runtime")return!1;if(X.label==="Design system")return!1;return!0}function dN(X){return X.split("/").pop()}function M8(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(M8._t),M8._t=setTimeout(()=>{Y.style.opacity="0",Y.style.pointerEvents="none"},Q?6000:3200)}var lt="maude-browse-hint-seen";function Qq0(X=!1){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(lt)==="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(lt,"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 AW(X){return X.replace(AQ,"")}function Yq0(X){return X.replace(AQ,"")}function Wq0(X){let J=new Map;for(let G of X){if(!AQ.test(G.name))continue;let Z=Yq0(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(AQ.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((z,U)=>z.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 Gq0(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 z of Z)H=H[z]=H[z]||{};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 z=0;z<Z.length;z++){let U=Z[z];if(z===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 Ve(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=Ve(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 pt(X){return(X||[]).filter((J)=>J.status!=="resolved").length}function Zq0(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 qe(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 lN({d:X,size:J=14,color:Q}){return K("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:K("path",{d:X})})}var Hq0={"chevron-down":K("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":K("polyline",{points:"6 3.5 10.5 8 6 12.5"}),file:A(W0,{children:[K("path",{d:"M4 2h5l3 3v9H4z"}),K("polyline",{points:"9 2 9 5 12 5"})]}),folder:K("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),"folder-plus":A(W0,{children:[K("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),K("path",{d:"M8 7.5v3.5M6.25 9.25h3.5"})]}),lock:A(W0,{children:[K("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),K("path",{d:"M5.5 7V5a2.5 2.5 0 015 0v2"})]}),unlock:A(W0,{children:[K("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),K("path",{d:"M5.5 7V5a2.5 2.5 0 015-.7"})]}),search:A(W0,{children:[K("circle",{cx:"7",cy:"7",r:"4"}),K("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:A(W0,{children:[K("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),K("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),check:K("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),x:A(W0,{children:[K("line",{x1:"4.3",y1:"4.3",x2:"11.7",y2:"11.7"}),K("line",{x1:"11.7",y1:"4.3",x2:"4.3",y2:"11.7"})]}),sun:A(W0,{children:[K("circle",{cx:"8",cy:"8",r:"2.6"}),K("line",{x1:"8",y1:"1.5",x2:"8",y2:"3"}),K("line",{x1:"8",y1:"13",x2:"8",y2:"14.5"}),K("line",{x1:"1.5",y1:"8",x2:"3",y2:"8"}),K("line",{x1:"13",y1:"8",x2:"14.5",y2:"8"}),K("line",{x1:"3.4",y1:"3.4",x2:"4.4",y2:"4.4"}),K("line",{x1:"11.6",y1:"11.6",x2:"12.6",y2:"12.6"}),K("line",{x1:"12.6",y1:"3.4",x2:"11.6",y2:"4.4"}),K("line",{x1:"4.4",y1:"11.6",x2:"3.4",y2:"12.6"})]}),moon:K("path",{d:"M12.5 9.6A5 5 0 1 1 7 3a4 4 0 0 0 5.5 6.6z"}),sparkle:K("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:A(W0,{children:[K("path",{d:"M2 6.7 11 4v8L2 9.3z"}),K("path",{d:"M11 5.2a2.4 2.4 0 0 1 0 5.6"}),K("path",{d:"M4.3 9.5v2.3a1.2 1.2 0 0 0 2.4 0v-1.7"})]}),"panel-left":A(W0,{children:[K("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),K("line",{x1:"6.4",y1:"3",x2:"6.4",y2:"13"})]}),resolve:A(W0,{children:[K("circle",{cx:"8",cy:"8",r:"5.6"}),K("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:A(W0,{children:[K("path",{d:"M3.2 8a5 5 0 1 1 1.4 3.5"}),K("polyline",{points:"3.2 11.4 3.2 8 6.6 8"})]}),layers:A(W0,{children:[K("polygon",{points:"8 2.2 13.8 5.5 8 8.8 2.2 5.5"}),K("polyline",{points:"2.2 9 8 12.3 13.8 9"})]}),box:K("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.2"}),type:A(W0,{children:[K("polyline",{points:"4 4 12 4"}),K("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:A(W0,{children:[K("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"3"}),K("line",{x1:"6",y1:"8",x2:"10",y2:"8"})]}),input:A(W0,{children:[K("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"1.2"}),K("line",{x1:"5",y1:"8",x2:"5",y2:"8"})]}),link:A(W0,{children:[K("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"}),K("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:A(W0,{children:[K("line",{x1:"6",y1:"4.5",x2:"13",y2:"4.5"}),K("line",{x1:"6",y1:"8",x2:"13",y2:"8"}),K("line",{x1:"6",y1:"11.5",x2:"13",y2:"11.5"}),K("circle",{cx:"3.2",cy:"4.5",r:"0.8",fill:"currentColor"}),K("circle",{cx:"3.2",cy:"8",r:"0.8",fill:"currentColor"}),K("circle",{cx:"3.2",cy:"11.5",r:"0.8",fill:"currentColor"})]}),eye:A(W0,{children:[K("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"}),K("circle",{cx:"8",cy:"8",r:"2"})]}),eyedropper:A(W0,{children:[K("path",{d:"M11 2.6a1.7 1.7 0 0 1 2.4 2.4l-1.2 1.2-2.4-2.4z"}),K("path",{d:"M9.5 4.6 4 10.1V12h1.9l5.5-5.5"})]}),"p-corner":K("path",{d:"M3.5 12.5V7a3.5 3.5 0 0 1 3.5-3.5h5.5"}),"p-opacity":A(W0,{children:[K("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.5"}),K("path",{d:"M3 8h10M8 3v10",strokeWidth:"0.9",opacity:"0.55"})]}),"p-lineheight":A(W0,{children:[K("line",{x1:"6.5",y1:"4",x2:"13",y2:"4"}),K("line",{x1:"6.5",y1:"8",x2:"13",y2:"8"}),K("line",{x1:"6.5",y1:"12",x2:"13",y2:"12"}),K("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":A(W0,{children:[K("path",{d:"M3 4v8M13 4v8"}),K("path",{d:"M6 11.5 8 5l2 6.5M6.7 9.3h2.6",strokeWidth:"1.1"})]}),"p-gap":A(W0,{children:[K("rect",{x:"2",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),K("rect",{x:"10.4",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),K("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":K("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"}),"p-size":A(W0,{children:[K("path",{d:"M3 13 6.6 3l3.6 10"}),K("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":A(W0,{children:[K("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"}),K("line",{x1:"2.5",y1:"2.5",x2:"13.5",y2:"13.5"})]}),sliders:A(W0,{children:[K("line",{x1:"3",y1:"5",x2:"13",y2:"5"}),K("circle",{cx:"6",cy:"5",r:"1.7",fill:"currentColor"}),K("line",{x1:"3",y1:"11",x2:"13",y2:"11"}),K("circle",{cx:"10",cy:"11",r:"1.7",fill:"currentColor"})]}),code:A(W0,{children:[K("polyline",{points:"6 5 3 8 6 11"}),K("polyline",{points:"10 5 13 8 10 11"})]}),download:A(W0,{children:[K("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),K("polyline",{points:"4.5 7 8 10.5 11.5 7"}),K("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),reload:A(W0,{children:[K("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),K("path",{d:"M14 2v3.33h-3.33"})]}),help:A(W0,{children:[K("circle",{cx:"8",cy:"8",r:"6"}),K("path",{d:"M6.3 6.2a1.8 1.8 0 1 1 2.3 1.9c-.5.2-.6.5-.6 1v.3"}),K("line",{x1:"8",y1:"11.4",x2:"8",y2:"11.5"})]}),image:A(W0,{children:[K("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),K("circle",{cx:"6",cy:"6.3",r:"1.1"}),K("path",{d:"M3 12l3-2.8 2.2 1.8 2.4-3L13.5 12"})]}),vector:A(W0,{children:[K("path",{d:"M3.6 11.2C6 5 10 5 12.4 11.2"}),K("rect",{x:"1.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),K("rect",{x:"11.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),K("rect",{x:"6.7",y:"2.6",width:"2.6",height:"2.6",rx:"0.4"})]}),presentation:A(W0,{children:[K("rect",{x:"2.5",y:"3",width:"11",height:"7.4",rx:"1"}),K("line",{x1:"8",y1:"10.4",x2:"8",y2:"13"}),K("line",{x1:"5.6",y1:"13.4",x2:"10.4",y2:"13.4"})]}),archive:A(W0,{children:[K("rect",{x:"2.5",y:"3",width:"11",height:"3",rx:"0.8"}),K("path",{d:"M3.6 6v6.2a1 1 0 0 0 1 1h6.8a1 1 0 0 0 1-1V6"}),K("line",{x1:"6.6",y1:"8.8",x2:"9.4",y2:"8.8"})]}),external:A(W0,{children:[K("path",{d:"M11 8.5V12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h3.5"}),K("polyline",{points:"9.5 3 13 3 13 6.5"}),K("line",{x1:"13",y1:"3",x2:"7.6",y2:"8.4"})]}),share:A(W0,{children:[K("circle",{cx:"4",cy:"8",r:"1.9"}),K("circle",{cx:"11.6",cy:"3.6",r:"1.9"}),K("circle",{cx:"11.6",cy:"12.4",r:"1.9"}),K("line",{x1:"5.7",y1:"7",x2:"9.9",y2:"4.6"}),K("line",{x1:"5.7",y1:"9",x2:"9.9",y2:"11.4"})]}),pen:A(W0,{children:[K("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"}),K("line",{x1:"9.6",y1:"4.2",x2:"11.8",y2:"6.4"})]}),square:K("rect",{x:"3.5",y:"3.5",width:"9",height:"9",rx:"1"})};function zq0({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 z=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>=z.length)Z(0)},[z.length,G]),!X)return null;let U=(q)=>{J(),q.run()};return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(q)=>{if(q.target===q.currentTarget)J()},children:A("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[A("div",{className:"st-pal-search",children:[K(G9,{name:"search",size:18}),K("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(z.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(),z[G])U(z[G])}}}),K(t6,{children:"⌘K"})]}),K("div",{className:"st-pal-list",ref:H,children:z.length===0?K("div",{className:"st-pal-empty",children:"No matching command."}):z.map((q,B)=>{let F=q.group&&(B===0||z[B-1].group!==q.group)?K("div",{className:"st-pal-group",children:q.group},"g-"+q.group):null;return A(W0,{children:[F,A("button",{type:"button",className:"st-pal-item"+(B===G?" is-active":""),onMouseEnter:()=>Z(B),onClick:()=>U(q),children:[K("span",{className:"st-pal-icon",children:K(G9,{name:q.icon,size:15})}),K("span",{className:"st-pal-label",children:q.label}),q.kbd?K("span",{className:"st-pal-kbd",children:K(t6,{children:q.kbd})}):null]})]},q.id)})})]})})}function G9({name:X,size:J=16,className:Q}){return K("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:Hq0[X]})}function Kq0(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 dt({initials:X,hue:J,title:Q,pulse:Y}){return K("span",{className:"st-avatar"+(Y?" is-pulsing":""),style:{"--av-hue":J},"data-tip":Q,"aria-label":Q,children:X})}function t6({children:X}){return K("span",{className:"kbd",children:X})}function ct(X,{min:J,max:Q,def:Y}){let W=u.useCallback((z)=>Math.min(Q,Math.max(J,z)),[J,Q]),[G,Z]=u.useState(()=>{try{let z=parseInt(localStorage.getItem(X)||"",10);return Number.isFinite(z)?W(z):Y}catch{return Y}});u.useEffect(()=>{try{localStorage.setItem(X,String(G))}catch{}},[X,G]);let H=u.useCallback((z)=>Z((U)=>W(typeof z==="function"?z(U):z)),[W]);return{w:G,setW:H,min:J,max:Q,def:Y}}function it({label:X,size:J,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:z,def:U}=J,q=W==="rtl"?-1:1;return K("div",{className:"st-grip"+(Y?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":X,"aria-valuemin":H,"aria-valuemax":z,"aria-valuenow":Math.round(G),onPointerDown:Q,onDoubleClick:()=>Z(U),onKeyDown:(B)=>{let F=B.shiftKey?24:8;if(B.key==="ArrowRight")B.preventDefault(),Z((O)=>O+F*q);else if(B.key==="ArrowLeft")B.preventDefault(),Z((O)=>O-F*q);else if(B.key==="Home")B.preventDefault(),Z(H);else if(B.key==="End")B.preventDefault(),Z(z)},children:A("svg",{className:"st-grip-dots",viewBox:"0 0 6 18","aria-hidden":"true",children:[K("circle",{cx:"3",cy:"3",r:"1.1",fill:"currentColor"}),K("circle",{cx:"3",cy:"9",r:"1.1",fill:"currentColor"}),K("circle",{cx:"3",cy:"15",r:"1.1",fill:"currentColor"})]})})}var JR=[{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}],QR={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},Uq0={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"]},Vq0=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],Yq=[{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}],qq0="2x",ot=[{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}],Bq0="auto",Nq0={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 Fq0(X){let J=String(X||"").split(".").pop()?.toLowerCase();return Nq0[J]||"application/octet-stream"}function Lq0({designRel:X,onPick:J,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[Z,H]=u.useState(null),[z,U]=u.useState(!1),[q,B]=u.useState(null),[F,O]=u.useState(()=>new Set),[M,E]=u.useState({}),[I,P]=u.useState(W?"artboard":"annotation");u.useEffect(()=>{let f=!0;return fetch("/_api/assets").then((l)=>l.json()).then((l)=>{if(!f)return;let p=l.ok?l.assets:[];H(p),E((h)=>{let s={...h};for(let a of p)s[a.path]=a.kind;return s})}).catch(()=>f&&H([])),()=>{f=!1}},[]),u.useEffect(()=>{let f=(l)=>{if(l.key==="Escape")l.stopPropagation(),Q()};return window.addEventListener("keydown",f,!0),()=>window.removeEventListener("keydown",f,!0)},[Q]);let w=Array.from(F).some((f)=>(M[f]||"image")!=="image"),R=!W||w,T=!W?"No artboard on this canvas":w?"Video/audio can only be added as annotations":"";u.useEffect(()=>{if(R&&I==="artboard")P("annotation")},[R,I]);let C=(f)=>{O((l)=>{let p=new Set(l);if(p.has(f))p.delete(f);else p.add(f);return p})},b=async(f)=>{let l=await fetch("/_api/asset",{method:"POST",headers:{"content-type":f.type||"application/octet-stream"},body:f}),p=await l.json().catch(()=>({}));if(l.ok&&p.path)return{ok:!0,path:p.path};return{ok:!1,error:p.error||`upload failed (HTTP ${l.status})`}},$=async(f)=>{if(!f)return;U(!0),B(null);let l=await b(f);if(U(!1),l.ok)J(l.path);else B(l.error)},y=(f)=>{if(typeof f==="string"&&f.startsWith("video/"))return"video";if(typeof f==="string"&&f.startsWith("audio/"))return"audio";return"image"},v=async(f)=>{if(!f.length)return;U(!0),B(null);let l=await Promise.all(f.map((s)=>b(s).then((a)=>({...a,file:s}))));U(!1);let p=l.filter((s)=>s.ok),h=l.length-p.length;if(h>0)B(`${h} of ${l.length} uploads failed`);if(p.length)E((s)=>{let a={...s};for(let i of p)a[i.path]=y(i.file.type);return a}),O((s)=>{let a=new Set(s);for(let i of p)a.add(i.path);return a})},g=async()=>{U(!0),B(null);try{if(Y){let p=(await ff()||[]).map((h)=>new File([new Uint8Array(h.bytes)],h.name,{type:Fq0(h.name)}));if(U(!1),p.length)await v(p);return}let f=await w1();if(f?.bytes){await $(new Blob([new Uint8Array(f.bytes)]));return}}catch(f){B(f?.message||"open failed")}U(!1)},m=()=>{if(p8()){g();return}let f=document.createElement("input");if(f.type="file",f.accept="image/*,video/*",Y)f.multiple=!0;f.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(f);let l=()=>{if(f.isConnected)f.remove()};window.addEventListener("focus",()=>setTimeout(l,300),{once:!0}),f.addEventListener("change",()=>{let p=f.files?Array.from(f.files):[];if(l(),!p.length)return;if(Y)v(p);else $(p[0])}),f.click()},c=(f)=>`/${X}/${f}`;return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(f)=>{if(f.target===f.currentTarget)Q()},children:A("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[A("div",{className:"st-dialog-hd",children:[K("span",{className:"st-dialog-title",children:"Choose media"}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:Q,children:K(G9,{name:"x",size:15})})]}),A("div",{className:"st-dialog-bd",children:[A("div",{className:"st-ap-toolbar",children:[K("button",{type:"button",className:"st-btn",onClick:m,disabled:z,children:z?"Uploading…":"Upload…"}),q&&K("span",{className:"st-ap-err",children:q})]}),K("div",{className:"st-ap-grid",children:Z==null?K("div",{className:"st-ap-empty",children:"Loading…"}):Z.length===0?K("div",{className:"st-ap-empty",children:"No assets yet — upload one."}):Z.map((f)=>{let l=Y&&F.has(f.path);return A("button",{type:"button",className:"st-ap-cell","data-selected":l?"true":void 0,"aria-pressed":Y?l:void 0,title:`${f.name} · ${Math.max(1,Math.round(f.size/1024))} KB`,onClick:()=>Y?C(f.path):J(f.path),children:[Y&&K("span",{className:"st-ap-check","aria-hidden":"true",children:l?K(G9,{name:"check",size:12}):null}),f.kind==="video"?K("video",{className:"st-ap-thumb",src:c(f.path),muted:!0,playsInline:!0}):K("img",{className:"st-ap-thumb",src:c(f.path),alt:f.name,loading:"lazy"}),K("span",{className:"st-ap-name",children:f.name})]},f.path)})})]}),Y&&F.size>0&&A("div",{className:"st-dialog-ft st-ap-confirm",children:[A("span",{className:"st-ap-count",children:[F.size," selected"]}),A("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[K("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":I==="artboard",disabled:R,onClick:()=>P("artboard"),children:"Add to artboard"}),K("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":I==="annotation",onClick:()=>P("annotation"),children:"Add as annotation"})]}),R&&K("span",{className:"st-ap-dest-note",children:T}),K("span",{className:"st-ap-confirm-spacer"}),K("button",{type:"button",className:"btn btn--ghost",onClick:Q,children:"Cancel"}),K("button",{type:"button",className:"btn btn--primary",onClick:()=>G?.(Array.from(F),I),children:"Insert"})]})]})})}function Dq0({mode:X,initialScope:J,activePath:Q,hasComps:Y=!1,comps:W=[],activeArtboardId:G=null,selection:Z=null,onClose:H}){let[z,U]=u.useState(X==="handoff"?"shadcn":"png"),[q,B]=u.useState(J&&QR[J]?J:"artboard"),[F,O]=u.useState(2),[M,E]=u.useState(qq0),[I,P]=u.useState(!0),[w,R]=u.useState(!1),[T,C]=u.useState(!1),[b,$]=u.useState(!1),[y,v]=u.useState(Bq0),[g,m]=u.useState(!0),[c,f]=u.useState(!1),[l,p]=u.useState(null),[h,s]=u.useState([]),a=JR.find((M0)=>M0.id===z)||JR[0],i=a.handoff?[]:Uq0[a.format]||["artboard"],K0=900,e=3600,r=W[0]||null,n=r?.durationInFrames||0,U0=r?.fps||30,f0=a.temporal&&n>900,J8=a.temporal&&n>3600;u.useEffect(()=>{if(i.length&&!i.includes(q))B(i[0])},[i,q]);let W8=u.useCallback(()=>{fetch("/_api/export-history").then((M0)=>M0.json()).then((M0)=>s(Array.isArray(M0?.history)?M0.history.slice(0,6):[])).catch(()=>{})},[]);u.useEffect(()=>{W8()},[W8]),u.useEffect(()=>{function M0(c0){if(c0.key==="Escape")c0.preventDefault(),H()}return window.addEventListener("keydown",M0),()=>window.removeEventListener("keydown",M0)},[H]);async function n0(){if(a.handoff){let e0=`/design:handoff ${Q&&Q!==S8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(e0)}catch{}p({ok:!0,msg:`Copied: ${e0} — run it in Claude Code.`});return}f(!0),p(null);let M0=a.temporal?{scale:F}:{};if(a.format==="png"){let c0=Yq.find((e0)=>e0.id===M)||Yq[1];if(c0.kind==="dpi")M0.dpi=c0.value;else M0.scale=c0.value}if(a.format==="mp4"||a.format==="webm")M0.audio=g;if(J8)M0.maxFrames=n;if(a.format==="pdf"){M0.pdfPrint={includeBleed:I,marks:{crop:T,registration:b}};let c0=ot.find((e0)=>e0.id===y)?.value;if(c0!==void 0)M0.dpi=c0}if(G)M0.artboardId=G;if(Z?.selector)M0.selection=Z;try{let c0=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:a.format,scope:q,options:M0})});if(!c0.ok){p({ok:!1,msg:await c0.text()||`Export failed (${c0.status})`}),f(!1);return}H()}catch(c0){p({ok:!1,msg:c0&&c0.message?c0.message:String(c0)}),f(!1)}}return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(M0)=>{if(M0.target===M0.currentTarget)H()},children:A("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[A("div",{className:"st-dialog-hd",children:[K("span",{className:"st-dialog-title",children:"Export & handoff"}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:H,children:K(G9,{name:"x",size:15})})]}),A("div",{className:"st-dialog-bd",children:[K("div",{className:"st-rp-hd",children:Q&&Q!==S8?`Format · ${AW(dN(Q))}`:"Format"}),K("div",{className:"st-fmt-grid",children:JR.filter((M0)=>!M0.temporal||Y).map((M0)=>A("button",{type:"button",className:"st-fmt"+(M0.id===z?" is-on":""),onClick:()=>{U(M0.id),p(null)},children:[K(G9,{name:M0.icon,size:16}),K("span",{className:"st-fmt-name",children:M0.label}),K("span",{className:"st-fmt-sub",children:M0.sub})]},M0.id))}),!a.handoff&&A("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-export-scope",children:"Scope"}),K("select",{id:"st-export-scope",className:"st-select",value:q,onChange:(M0)=>B(M0.target.value),children:i.map((M0)=>K("option",{value:M0,children:QR[M0]},M0))})]}),!a.handoff&&a.format==="png"&&A("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-export-size",children:"Resolution"}),K("select",{id:"st-export-size",className:"st-select",value:M,onChange:(M0)=>E(M0.target.value),children:Yq.map((M0)=>K("option",{value:M0.id,children:M0.label},M0.id))})]}),!a.handoff&&a.format==="png"&&K("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let M0=Yq.find((e0)=>e0.id===M)||Yq[1],c0=M0.kind==="dpi"?M0.value/96:M0.value;return`${M0.label} ≈ ${Math.round(1440*c0)}×${Math.round(900*c0)} for a 1440×900 artboard.`})()}),!a.handoff&&a.temporal&&A("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-export-temporal-size",children:"Resolution"}),K("select",{id:"st-export-temporal-size",className:"st-select",value:F,onChange:(M0)=>O(Number(M0.target.value)),children:Vq0.map((M0)=>K("option",{value:M0.value,children:M0.label},M0.value))})]}),!a.handoff&&a.temporal&&A("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[F,"× the artboard's native resolution (e.g. 960×540 → ",960*F,"×",540*F,")."]}),f0&&A("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: ",n," frames (≈",Math.round(n/U0),"s).",J8?` 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."]}),!a.handoff&&a.format==="pdf"&&A(W0,{children:[A("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-dpi",children:"Image quality"}),K("select",{id:"st-export-pdf-dpi",className:"st-select",value:y,onChange:(M0)=>v(M0.target.value),children:ot.map((M0)=>K("option",{value:M0.id,children:M0.label},M0.id))})]}),K("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)."}),K("div",{className:"st-dialog-row",children:A("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-bleed",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[K("input",{id:"st-export-pdf-bleed",type:"checkbox",checked:I,onChange:(M0)=>P(M0.target.checked)}),"Include bleed"]})}),K("div",{className:"st-dialog-row",children:A("button",{type:"button",className:"st-dialog-lbl",style:{background:"none",border:0,padding:0,cursor:"pointer"},onClick:()=>R((M0)=>!M0),"aria-expanded":w,children:[w?"▾":"▸"," Marks"]})}),w&&A("div",{style:{padding:"0 12px 4px",display:"flex",flexDirection:"column",gap:6},children:[A("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[K("input",{type:"checkbox",checked:T,onChange:(M0)=>C(M0.target.checked)}),"Crop marks"]}),A("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[K("input",{type:"checkbox",checked:b,onChange:(M0)=>$(M0.target.checked)}),"Registration marks"]})]}),A("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:["Bleed and marks apply to print (",K("code",{children:'kind="print"'}),") artboards only.",q==="canvas-as-separate"?" One PDF page per artboard.":""]})]}),!a.handoff&&(a.format==="mp4"||a.format==="webm")&&K("div",{className:"st-dialog-row",children:A("label",{className:"st-dialog-lbl",htmlFor:"st-export-audio",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[K("input",{id:"st-export-audio",type:"checkbox",checked:g,onChange:(M0)=>m(M0.target.checked)}),"Export with audio"]})}),a.handoff&&A("div",{className:"callout callout--info",style:{fontSize:12},children:["Hands the active canvas off to production. Copies"," ",K("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."]}),l&&K("div",{className:"callout "+(l.ok?"callout--success":"callout--error"),style:{fontSize:12},children:l.msg}),h.length>0&&A("div",{className:"st-export-recent",children:[K("div",{className:"st-rp-hd",children:"Recent"}),h.map((M0,c0)=>A("div",{className:"st-export-recent-row",children:[A("span",{children:[String(M0.format||"").toUpperCase()," ·"," ",QR[M0.scope]||M0.scope]}),K("span",{className:"st-mono",children:M0.filename})]},c0))]})]}),A("div",{className:"st-dialog-ft",children:[K("button",{type:"button",className:"btn btn--ghost",onClick:H,children:"Cancel"}),A("button",{type:"button",className:"btn btn--primary",disabled:c,onClick:n0,children:[K(G9,{name:"download",size:14}),a.handoff?"Copy handoff command":c?"Exporting…":`Export ${a.label}`]})]})]})})}var cN=12,iN=16;function Oq0({name:X,depth:J,defaultOpen:Q,children:Y,dirPath:W,drag:G,menu:Z}){let[H,z]=u.useState(Q),U=G?G.dropProps(W,!0,()=>z(!0)):{},q=G?.overDir===W,B=G?G.dragProps(W,!0):{},F=G?.draggedPath===W,O=G?.busyPath===W,M=A("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${uN(W)}`,"aria-expanded":H,"aria-dropeffect":G?"move":void 0,"aria-busy":O||void 0,tabIndex:-1,className:"st-row"+(q?" is-drop-target":"")+(F?" is-dragging":"")+(O?" is-busy":""),style:{paddingLeft:cN+J*iN+"px"},onClick:()=>z((E)=>!E),onContextMenu:Z?(E)=>Z.openAt(E,{kind:"dir",dirPath:W}):void 0,...B,...U,children:[K("span",{className:"st-row-glyph",children:K(G9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),K("span",{className:"st-row-name",children:X})]});return A(W0,{children:[Z?A("div",{className:"st-row-wrap",role:"none",children:[M,K("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${uN(W)}`,title:`Folder actions — ${X}`,"aria-label":`Folder actions for ${X}`,"aria-haspopup":"menu",onClick:(E)=>Z.openAt(E,{kind:"dir",dirPath:W}),children:K(lN,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})})]}):M,H&&Y]})}function Mq0({name:X,dsName:J,depth:Q,defaultOpen:Y,active:W,onOpenSystem:G,children:Z}){let[H,z]=u.useState(Y);return A(W0,{children:[A("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:cN+Q*iN+"px"},role:"treeitem","aria-expanded":H,children:[K("button",{type:"button",className:"st-ds-chev",onClick:()=>z((U)=>!U),"aria-label":H?"Collapse design system":"Expand design system",title:H?"Collapse":"Expand",children:K(G9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),A("button",{type:"button",className:"st-ds-open",onClick:()=>G(J),"aria-label":`Open ${J} design system view`,title:"Open the design system view",children:[K("span",{className:"st-row-glyph",children:K(G9,{name:"folder",size:13})}),K("span",{className:"st-row-name",children:X})]})]}),H&&Z]})}function ZR({file:X,activePath:J,onOpen:Q,onDelete:Y,openCount:W,depth:G,kind:Z,sidecar:H,dirty:z,experimentalKind:U,drag:q,menu:B}){let F=X.path===J,O=AQ.test(X.name),M=!O,E=O?AW(X.name):X.name,I=O&&typeof Y==="function"&&Z!=="runtime",P=O&&!H&&Z!=="runtime"&&typeof q<"u",w=P?q.dragProps(X.path,!0):{},R=q?.draggedPath===X.path,T=q?.busyPath===X.path,C=P&&typeof B<"u",b=X.path.split("/").slice(0,-1).join("/"),$=O?"canvas-row-"+X.path.replace(/^\.[^/]+\//,"").replace(AQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,y=A("button",{type:"button",role:"treeitem","data-testid":$,"aria-selected":F,"aria-disabled":M?"true":void 0,"aria-busy":T||void 0,tabIndex:F?0:-1,className:"st-row"+(F?" is-sel":"")+(Z==="runtime"?" is-muted":"")+(R?" is-dragging":"")+(T?" is-busy":""),style:{paddingLeft:cN+G*iN+"px"},title:X.path+(W?` — ${W} open`:M?" (file index only)":""),onClick:()=>{if(!M)Q(X.path)},onContextMenu:C?(v)=>B.openAt(v,{kind:"file",path:X.path,dir:b}):void 0,...w,children:[K("span",{className:"st-row-glyph",children:K(G9,{name:"file",size:13})}),K("span",{className:"st-row-name",children:E}),U==="reconstructed-experimental"&&K("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"}),z&&K("span",{className:"st-git-badge","data-kind":z,title:`Unsaved (${z})`,"aria-label":`Unsaved, ${z}`,children:z}),W>0&&K("span",{className:"st-row-badge",children:W})]});if(!I&&!C)return y;return A("div",{className:"st-row-wrap",role:"none",children:[y,C&&K("button",{type:"button",className:"st-row-menu-btn"+(I?" has-delete-sibling":""),"data-testid":`tree-row-menu-${uN(X.path)}`,title:`Move ${E}…`,"aria-label":`Actions for ${E}`,"aria-haspopup":"menu",onClick:(v)=>B.openAt(v,{kind:"file",path:X.path,dir:b}),children:K(lN,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})}),I&&K("button",{type:"button",className:"st-row-del",title:`Delete ${E}`,"aria-label":`Delete canvas ${E}`,onClick:(v)=>{v.stopPropagation(),Y(X.path,E)},children:K(lN,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})}function wq0({primary:X,sidecars:J,depth:Q,kind:Y,activePath:W,onOpen:G,onDelete:Z,openCount:H,showHidden:z,forceOpen:U,dirtyByPath:q,experimentalKind:B,drag:F,menu:O}){let M=q?.get(X.path),E=J.length>0,[I,P]=u.useState(!1),w=U||I,R=X.path===W;if(!(E&&z))return K(ZR,{file:X,activePath:W,onOpen:G,onDelete:Z,openCount:H,depth:Q,kind:Y,dirty:M,experimentalKind:B,drag:F,menu:O});let C=typeof F<"u",b=C?F.dragProps(X.path,!0):{},$=F?.draggedPath===X.path,y=F?.busyPath===X.path,v=C&&typeof O<"u",g=X.path.split("/").slice(0,-1).join("/"),m=A("button",{type:"button",role:"treeitem","aria-selected":R,"aria-expanded":w,"aria-busy":y||void 0,tabIndex:R?0:-1,className:"st-row st-canvas-row"+(R?" is-sel":"")+($?" is-dragging":"")+(y?" is-busy":""),style:{paddingLeft:cN+Q*iN+"px"},title:X.path,onClick:(c)=>{if(c.target.closest(".st-canvas-chev")){P((f)=>!f);return}G(X.path)},onContextMenu:v?(c)=>O.openAt(c,{kind:"file",path:X.path,dir:g}):void 0,...b,children:[K("span",{className:"st-row-glyph st-canvas-chev",onClick:(c)=>{c.stopPropagation(),P((f)=>!f)},children:K(G9,{name:"chevron-right",className:"st-chev"+(w?" is-open":""),size:13})}),K("span",{className:"st-row-name",children:AW(X.name)}),B==="reconstructed-experimental"&&K("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"}),M&&K("span",{className:"st-git-badge","data-kind":M,title:`Unsaved (${M})`,"aria-label":`Unsaved, ${M}`,children:M}),H>0&&K("span",{className:"st-row-badge",children:H})]});return A(W0,{children:[v?A("div",{className:"st-row-wrap",role:"none",children:[m,K("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${uN(X.path)}`,title:`Move ${AW(X.name)}…`,"aria-label":`Actions for ${AW(X.name)}`,"aria-haspopup":"menu",onClick:(c)=>O.openAt(c,{kind:"file",path:X.path,dir:g}),children:K(lN,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})})]}):m,w&&J.map((c)=>K(ZR,{file:c,activePath:W,onOpen:G,openCount:0,depth:Q+1,kind:Y,sidecar:!0},c.path))]})}function Be({node:X,activePath:J,onOpen:Q,commentsByFile:Y,depth:W=1,kind:G,showHidden:Z,search:H,dsFolders:z,activeDsName:U,onOpenSystem:q,onDelete:B,dirtyByPath:F,canvasKinds:O,dirPath:M="",drag:E,menu:I}){let P=Object.keys(X).filter(($)=>$!=="_files").sort(),w=X._files||[],{canvases:R,orphans:T}=u.useMemo(()=>Wq0(w),[w]),C=!!(H&&H.trim()),b=u.useMemo(()=>{if(!z||W!==1)return null;let $=new Map;for(let y of z)$.set(y.folder,y);return $},[z,W]);return A(W0,{children:[R.map(($)=>{let y=C&&$.sidecars.some((v)=>{let g=H.toLowerCase();return v.name.toLowerCase().includes(g)||v.path.toLowerCase().includes(g)});return K(wq0,{primary:$.primary,sidecars:$.sidecars,activePath:J,onOpen:Q,onDelete:B,openCount:pt(Y[$.primary.path]),depth:W,kind:G,showHidden:Z,forceOpen:y,dirtyByPath:F,experimentalKind:O?.[$.primary.path],drag:E,menu:I},$.primary.path)}),Z&&T.map(($)=>K(ZR,{file:$.primary,activePath:J,onOpen:Q,openCount:pt(Y[$.primary.path]),depth:W,kind:G},$.primary.path)),P.map(($)=>{let y=b?.get($),v=M?`${M}/${$}`:$,g=K(Be,{node:X[$],activePath:J,onOpen:Q,commentsByFile:Y,depth:W+1,kind:G,showHidden:Z,search:H,activeDsName:U,onOpenSystem:q,onDelete:B,dirtyByPath:F,canvasKinds:O,dirPath:v,drag:E,menu:I});if(y&&q)return K(Mq0,{name:$,dsName:y.name,depth:W,defaultOpen:!0,active:J===S8&&y.name===U,onOpenSystem:q,children:g},$);return K(Oq0,{name:$,depth:W,defaultOpen:!0,dirPath:v,drag:E,menu:I,children:g},$)})]})}var hN={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function _q0(X){if(X.kind==="project")return hN.project;if(X.kind==="runtime")return hN.runtime;if(X.label==="Design system")return hN.ds;if(X.label==="UI kit")return hN.canvas;return{title:X.label.toUpperCase(),pillFromCount:!0}}function Aq0({readOnly:X=!1,groups:J,activePath:Q,activeDsName:Y,onOpen:W,onOpenSystem:G,wsConnected:Z,search:H,setSearch:z,commentsByFile:U,showHidden:q,sectionsExpanded:B,onToggleSection:F,onNewBoard:O,onDeleteBoard:M,onRefresh:E,refreshing:I,collapsed:P,onCollapse:w,width:R,resizing:T,dirtyByPath:C,project:b,gitBranch:$,remoteSync:y,onGetLatest:v,canvasKinds:g,onMoveCanvas:m,onNewFolder:c,onDeleteFolder:f}){let l=u.useMemo(()=>{if(!H)return J;return J.map((j0)=>({...j0,tree:Ve(j0.tree,H),filtered:!!H}))},[J,H]),p=D$(m),h=F$(),s=u.useMemo(()=>{let j0=[];for(let g0 of J){if(g0.label==="Design system"||g0.kind!=="canvas")continue;let A8=g0.fullPath.replace(/^\.[^/]+\//,"")||g0.fullPath;j0.push({path:g0.fullPath,label:A8});for(let r8 of g0.dirs||[])j0.push({path:r8,label:r8.replace(/^\.[^/]+\//,"")})}return j0},[J]),a=h.state?.extra,i=a?.kind==="file"?[{id:"move-to",label:"Move to…",onSelect:()=>h.showMoveTo()}]:a?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{h.close();let j0=window.prompt("New folder name:");if(j0?.trim())c(a.dirPath,j0.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{h.close(),f(a.dirPath,a.dirPath.split("/").pop())}}]:[],K0=a?.kind==="file"?s.filter((j0)=>j0.path!==a.dir):[],[e,r]=u.useState(!1),[n,U0]=u.useState("board"),[f0,J8]=u.useState(""),[W8,n0]=u.useState(""),[M0,c0]=u.useState(!1),e0=u.useMemo(()=>J.find((j0)=>j0.kind==="canvas"&&j0.label!=="Design system")?.fullPath,[J]),C8=u.useCallback(async()=>{let j0=f0.trim();if(!j0||M0)return;if(c0(!0),n0(""),n==="folder"){if(!e0){c0(!1),n0("no canvas group to create a folder in");return}let A8=await c(e0,j0);if(c0(!1),A8?.ok)r(!1),J8("");else n0(A8?.error||"could not create folder");return}let g0=await O(j0);if(c0(!1),g0?.ok)r(!1),J8("");else n0(g0?.error||"could not create board")},[f0,M0,O,c,n,e0]),t0=u.useMemo(()=>{let j0=0;for(let g0 of J)for(let A8 of g0.paths||[])if(AQ.test(A8))j0++;return j0},[J]),h8=u.useMemo(()=>{let j0=0;for(let g0 of l)for(let A8 of g0.paths||[])if(AQ.test(A8))j0++;return j0},[l]);return A("nav",{className:"st-sidebar"+(P?" is-collapsed":"")+(T?" is-resizing":""),style:P||!R?void 0:{width:R,flexBasis:R},"aria-label":"Files","data-tour":"sidebar",children:[A("div",{className:"st-sb-hd",children:[K("span",{className:"st-sb-title",children:"Files"}),A("div",{className:"st-sb-hd-actions",children:[!X&&K("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":e&&n==="board",onClick:()=>{n0(""),U0("board"),r((j0)=>n==="board"?!j0:!0)},children:K(G9,{name:"plus",size:15})}),!X&&e0&&K("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":e&&n==="folder",onClick:()=>{n0(""),U0("folder"),r((j0)=>n==="folder"?!j0:!0)},children:K(G9,{name:"folder-plus",size:15})}),E&&K("button",{type:"button",className:"st-iconbtn st-refresh"+(I?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":I||void 0,disabled:I,onClick:()=>E(),children:K(G9,{name:"reload",size:15})}),A("span",{className:"st-live","data-tip":Z?"live · file index synced":"reconnecting…",children:[K("span",{className:"st-live-dot"+(Z?" is-connected":""),"aria-hidden":"true"}),h8," / ",t0]}),w&&K("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:w,children:K(G9,{name:"panel-left",size:15})})]})]}),e?A("div",{className:"st-newboard",children:[K("input",{type:"text",autoFocus:!0,placeholder:n==="folder"?"folder name…":"brief board name…",value:f0,maxLength:60,disabled:M0,"aria-label":n==="folder"?"New folder name":"New brief board name",onChange:(j0)=>J8(j0.target.value),onKeyDown:(j0)=>{if(j0.key==="Enter")j0.preventDefault(),C8();else if(j0.key==="Escape")j0.preventDefault(),r(!1),J8(""),n0("")}}),K("button",{type:"button",className:"st-newboard-go",disabled:M0||!f0.trim(),"data-tip":"Create · Enter","aria-label":n==="folder"?"Create folder":"Create brief board",onClick:C8,children:M0?"…":"↵"})]}):null,W8?K("div",{className:"st-newboard-err",role:"alert",children:W8}):null,K("div",{className:"st-search",children:A("div",{className:"st-search-box",children:[K(G9,{name:"search",size:13}),K("input",{type:"search",placeholder:"Search canvases…",value:H,onChange:(j0)=>z(j0.target.value),onKeyDown:(j0)=>{if(j0.key==="Escape")if(j0.preventDefault(),H)z("");else j0.currentTarget.blur()},"aria-label":"Filter files"}),H?K("button",{className:"st-search-clear",onClick:()=>z(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):K(t6,{children:"/"})]})}),K("div",{className:"st-tree",role:"tree","aria-label":"Project file tree","data-testid":"canvas-list",children:l.map((j0)=>{if(!q&&!H&&j0.kind==="runtime")return null;let g0=_q0(j0),A8=(j0.paths||[]).filter((T8)=>AQ.test(T8)).length,r8=g0.pill||(g0.pillFromDsCount?String(j0.dsFolders?.length||0):null)||(g0.pillFromCount?String(A8||j0.paths?.length||0):null),R9=j0.tree&&Object.keys(j0.tree).length>0,$0=j0.label==="Design system",V9=j0.kind==="project";if(!q&&!H&&V9&&A8===0)return null;let I0=Jq0(j0),Z8=B[j0.label],H0=!!H||(Z8===void 0?I0:Z8),k0=!$0&&j0.kind==="canvas"&&!X,F0=k0?p.dropProps(j0.fullPath,!0):{},G8=p.overDir===j0.fullPath;return A("div",{className:"st-tree-section",children:[A("button",{type:"button",className:"st-tree-sec-hd"+(G8?" is-drop-target":""),onClick:()=>F(j0.label,I0),"aria-expanded":H0,"aria-dropeffect":k0?"move":void 0,title:H0?"Collapse section":"Expand section",...F0,children:[K(G9,{name:"chevron-right",className:"st-chev"+(H0?" is-open":""),size:13}),K("span",{className:"st-sec-name",children:g0.title}),r8&&K("span",{className:"st-pill",children:r8})]}),H0&&(R9?K(Be,{node:j0.tree,activePath:Q,onOpen:W,commentsByFile:U,depth:1,kind:j0.kind,showHidden:q,search:H,dsFolders:j0.dsFolders,activeDsName:Y,onOpenSystem:$0?G:void 0,onDelete:$0||X?void 0:M,dirtyByPath:C,canvasKinds:g,dirPath:j0.fullPath,drag:!$0&&j0.kind==="canvas"&&!X?p:void 0,menu:!$0&&j0.kind==="canvas"&&!X?h:void 0}):K("div",{className:"st-tree-empty",children:H?"No matches.":"Empty."}))]},j0.label)})}),K(L$,{state:h.state,onClose:h.close,rootItems:i,destinations:K0,onPickDestination:(j0)=>m(a.path,j0)}),K(Y_,{project:b,liveBranch:$,remoteSync:y,onGetLatest:v}),K($w,{}),K(bw,{})]})}function Eq0({shown:X,onExpand:J,onSearch:Q}){return K("div",{className:"st-rail"+(X?" is-shown":""),children:A("div",{className:"st-rail-inner",children:[K("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:J,children:K(G9,{name:"panel-left",size:15})}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:K(G9,{name:"search",size:15})}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:J,children:K(G9,{name:"folder",size:15})})]})})}function Pq0({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 K("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:A("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[A("header",{className:"help-modal-hd",children:[K("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),A("span",{className:"sku",children:["MAUDE-DEV-SRV / v",HR]}),Q&&K("button",{type:"button",className:"mdcc-tour__back",style:{marginLeft:"auto"},onClick:Q,children:"▶ Take the tour"}),K("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:J,children:"×"})]}),A("div",{className:"help-modal-body",children:[A("details",{open:!0,children:[K("summary",{children:"Canvas selection & tools"}),A("ul",{children:[A("li",{children:[K("kbd",{children:"V"})," ",K("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),A("li",{children:[K("kbd",{children:"H"})," ",K("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),A("li",{children:[K("kbd",{children:"C"})," ",K("span",{children:"comment tool — hover paints, click drops a pin"})]}),A("li",{children:[K("kbd",{children:"⌘"})," + hover ",K("span",{children:"preview deepest element under cursor"})]}),A("li",{children:[K("kbd",{children:"⌘"})," + click ",K("span",{children:"select that element (replace)"})]}),A("li",{children:[K("kbd",{children:"⌘⇧"})," + click ",K("span",{children:"add deepest to selection (multi)"})]}),A("li",{children:["right-click ",K("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),A("li",{children:[K("kbd",{children:"Esc"})," in canvas ",K("span",{children:"clear selection + close menu"})]})]})]}),A("details",{children:[K("summary",{children:"Annotation tools"}),A("ul",{children:[A("li",{children:[K("kbd",{children:"B"})," ",K("span",{children:"pen — freehand stroke"})]}),A("li",{children:[K("kbd",{children:"R"})," ",K("span",{children:"rectangle — drag to define corners"})]}),A("li",{children:[K("kbd",{children:"O"})," ",K("span",{children:"ellipse — drag from center outward"})]}),A("li",{children:[K("kbd",{children:"A"})," ",K("span",{children:"arrow — drag tail → tip"})]}),A("li",{children:[K("kbd",{children:"E"})," ",K("span",{children:"eraser — click or drag over strokes to remove"})]}),A("li",{children:[K("kbd",{children:"V"})," + click stroke ",K("span",{children:"select annotation (Shift+click to multi)"})]}),A("li",{children:[K("kbd",{children:"V"})," + drag empty ",K("span",{children:"marquee-select strokes that overlap"})]}),A("li",{children:["double-click rect/ellipse ",K("span",{children:"add text inside the shape"})]}),A("li",{children:["arrow keys ",K("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),A("li",{children:[K("kbd",{children:"Backspace"})," ",K("span",{children:"delete selected annotations"})]}),A("li",{children:[K("kbd",{children:"⇧P"})," ",K("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),A("details",{children:[K("summary",{children:"Canvas & panels"}),A("ul",{children:[A("li",{children:["click in tree ",K("span",{children:"open canvas (replaces the active one)"})]}),A("li",{children:["File ▸ Close canvas ",K("span",{children:"clear the stage"})]}),A("li",{children:[K("kbd",{children:"⌘R"})," ",K("span",{children:"reload canvas"})]}),A("li",{children:[K("kbd",{children:"/"})," ",K("span",{children:"focus search"})]}),A("li",{children:[K("kbd",{children:"⌘⇧M"})," ",K("span",{children:"comments panel"})]}),A("li",{children:[K("kbd",{children:"⌘⇧I"})," ",K("span",{children:"inspector"})]}),A("li",{children:[K("kbd",{children:"?"})," ",K("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),A("details",{children:[K("summary",{children:"Slash commands"}),A("ul",{className:"cmds",children:[A("li",{children:[A("code",{children:['/design:edit "',K("i",{children:"feedback"}),'"']}),K("span",{children:"edit + 4-iter multi-axis loop"})]}),A("li",{children:[A("code",{children:['/design:edit "',K("i",{children:"…"}),'" --perfect']}),K("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),A("li",{children:[A("code",{children:['/design:edit "',K("i",{children:"…"}),'" --no-critic']}),K("span",{children:"raw edit, skip loop"})]}),A("li",{children:[A("code",{children:['/design:edit "',K("i",{children:"…"}),'" --opt-out=',K("i",{children:"scope"})]}),K("span",{children:"override DS scope (palette/aesthetic/full)"})]}),A("li",{children:[A("code",{children:['/design:new "',K("i",{children:"Name"}),'" "',K("i",{children:"brief"}),'"']}),K("span",{children:"scaffold canvas"})]}),A("li",{children:[A("code",{children:['/design:new "',K("i",{children:"…"}),'" --opt-out=aesthetic']}),K("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),A("li",{children:[K("code",{children:"/design:critic"}),K("span",{children:"review panel (routed)"})]}),A("li",{children:[K("code",{children:"/design:critic --all"}),K("span",{children:"10-critic sweep"})]}),A("li",{children:[K("code",{children:"/design:critic --agent signature-moment-critic"}),K("span",{children:"aspiration axis only"})]}),A("li",{children:[K("code",{children:"/design:rollback"}),K("span",{children:"undo last edit"})]}),A("li",{children:[K("code",{children:"/design:screenshot"}),K("span",{children:"capture canvas"})]}),A("li",{children:[K("code",{children:"/design:setup-docs"}),K("span",{children:"refresh README + INDEX"})]}),A("li",{children:[K("code",{children:"/design:handoff"}),K("span",{children:"migrate to apps/"})]})]})]}),A("details",{children:[K("summary",{children:"Opt-out scope"}),A("ul",{children:[A("li",{children:[K("strong",{children:"palette"})," ",K("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),A("li",{children:[K("strong",{children:"aesthetic"})," ",K("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),A("li",{children:[K("strong",{children:"full"})," ",K("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),A("li",{children:[K("em",{children:"A11y enforced at every scope"})," ",K("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),A("li",{children:["Persisted on canvas's ",K("code",{children:".meta.json"})," ",K("code",{children:"opt_out_scope"})," field — subsequent ",K("code",{children:"/design:edit"})," iterations inherit."]}),K("li",{children:'Inferred from brief ("modern", "vibrant", "off-system") with one-shot AskUserQuestion before iter-1 critics fire.'})]})]}),A("details",{children:[K("summary",{children:"Auto-critic loop"}),A("ul",{children:[A("li",{children:[K("strong",{children:"Default"})," ",K("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),A("li",{children:[K("strong",{children:"--perfect"})," ",K("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),A("li",{children:[K("strong",{children:"--perfect --all"})," ",K("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),A("li",{children:["Exit: ",K("code",{children:"solid"})," · ",K("code",{children:"stable-but-bland"})," · ",K("code",{children:"max-reached"})," ","· ",K("code",{children:"divergent"})]}),A("li",{children:[K("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),A("li",{children:["When ",K("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."]})]})]}),A("details",{children:[K("summary",{children:"Pin-to-element flow"}),A("ol",{children:[K("li",{children:"Open a canvas"}),A("li",{children:[K("kbd",{children:"⌘"}),"+click element"]}),K("li",{children:"Status bar shows ● selector"}),A("li",{children:["Run"," ",A("code",{children:['/design:edit "',K("i",{children:"change just this"}),'"']})]}),A("li",{children:["Reload iframe (",K("kbd",{children:"⌘R"}),")"]})]})]}),A("details",{children:[K("summary",{children:"Comments"}),A("ol",{children:[A("li",{children:[K("kbd",{children:"⌘"}),"+click element, then ",K("kbd",{children:"⌘C"})," ",K("span",{children:"or ⌘⇧+click"})]}),K("li",{children:"Numbered pin appears on canvas"}),A("li",{children:[K("kbd",{children:"⌘⇧M"})," ",K("span",{children:"opens panel — All / Open / Resolved"})]}),A("li",{children:["Click row in panel ",K("span",{children:"jumps to that file + pin"})]}),A("li",{children:["Claude reads ",K("code",{children:"_comments/<slug>.json"})," on next ",K("code",{children:"/design"})]})]})]})]})]})})}var YR=[{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 Rq0({kbd:X,alt:J}){let Q=(Y,W)=>K("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>K(t6,{children:G},`${G}-${Z}`))},W);return A("span",{className:"so-combos",children:[Q(X,"main"),J?J.split(" / ").map((Y)=>A(W0,{children:[K("span",{className:"so-or",children:"/"}),Q(Y,Y)]},Y)):null]})}function Iq0({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=YR.reduce((Y,W)=>Y+W.items.length,0);return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:A("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[A("div",{className:"so-overlay-hd",children:[K("span",{className:"so-title",children:"Keyboard shortcuts"}),A("span",{className:"so-trigger",children:["press ",K(t6,{children:"?"})," to open"]})]}),K("div",{className:"so-columns",children:YR.map((Y)=>A("section",{className:"so-section so-section--"+Y.id,children:[K("h3",{className:"so-section-hd",children:Y.label}),K("dl",{className:"so-list",children:Y.items.map((W)=>A("div",{className:"so-pair",children:[K("dt",{children:W.label}),K("dd",{children:K(Rq0,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),A("div",{className:"so-overlay-ft",children:[A("span",{children:["close with ",K(t6,{children:"Esc"})]}),A("span",{className:"so-count",children:[Q," bindings · ",YR.length," groups"]})]})]})})}var kq0=["File","Edit","View","Selection","Tools","Help"];function Ne(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 Tq0({panels:X,onToggle:J,onClose:Q,onZoom:Y,hasCanvas:W}){return Ne(Q),A("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[K("div",{className:"st-dd-hd",children:"Panels"}),X.map((G)=>A("button",{type:"button",role:"menuitem",className:"st-dd-item"+(G.checked?" is-on":""),"aria-disabled":G.disabled?"true":void 0,onClick:()=>{if(!G.disabled)J(G.id),Q()},children:[A("span",{className:"st-dd-lead",children:[K("span",{className:"st-dd-check",children:G.checked?K(G9,{name:"check",size:13}):null}),K("span",{children:G.label}),G.phase?K("span",{className:"st-dd-phase",children:G.phase}):null]}),G.shortcut?K(t6,{children:G.shortcut}):null]},G.id)),K("div",{className:"st-dd-sep"}),K("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)=>A("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":W?void 0:"true",onClick:()=>{if(!W)return;Y?.(G.op),Q()},children:[A("span",{className:"st-dd-lead",children:[K("span",{className:"st-dd-check"}),K("span",{children:G.label})]}),K(t6,{children:G.shortcut})]},G.label))]})}function QK({label:X,left:J,header:Q,items:Y,onAction:W,onClose:G}){return Ne(G),A("div",{className:"st-dropdown",role:"menu","aria-label":X,style:{left:J},children:[Q?K("div",{className:"st-dd-hd",children:Q}):null,Y.map((Z,H)=>Z.sep?K("div",{className:"st-dd-sep"},"s"+H):A("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:[A("span",{className:"st-dd-lead",children:[K("span",{className:"st-dd-check"}),K("span",{children:Z.label})]}),Z.shortcut?K(t6,{children:Z.shortcut}):null]},Z.id))]})}function Cq0({onAction:X,onClose:J}){return K(QK,{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"},...p8()?[{id:"collab-tour",label:"How sharing works"}]:[],...p8()?[{id:"quick-setup",label:"Quick setup"}]:[],...p8()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function $q0({onAction:X,onClose:J,readOnly:Q=!1}){return K(QK,{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 Sq0({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 K(QK,{label:"Tools",left:290,header:"Tool palette",onAction:X,onClose:J,items:Y})}function bq0({onAction:X,onClose:J,hasCanvas:Q,readOnly:Y=!1}){return K(QK,{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 jq0({onAction:X,onClose:J,hasCanvas:Q,readOnly:Y=!1}){if(Y)return K(QK,{label:"Edit",left:90,onAction:X,onClose:J,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"}]});return K(QK,{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 yq0({activePath:X,project:J,tabsCount:Q,openMenu:Y,setOpenMenu:W,commentsPanelOpen:G,onToggleComments:Z,changesOpen:H,changesCount:z,onToggleChanges:U,onOpenSystem:q,sidebarOpen:B,onToggleSidebar:F,showHidden:O,onToggleShowHidden:M,onOpenHelp:E,onOpenShortcuts:I,onReportBug:P,onStartTour:w,onStartCollabTour:R,annotationsVisible:T,onToggleAnnotations:C,minimapVisible:b,onToggleMinimap:$,zoomCtlVisible:y,onToggleZoomCtl:v,presentMode:g,onTogglePresent:m,printGuidesVisible:c,onTogglePrintGuides:f,postToActiveCanvas:l,onOpenWhatsNew:p,onOpenReadiness:h,onOpenQuickSetup:s,onWatchIntro:a,whatsNewCount:i,exportCenter:K0,artboardCount:e=0,presence:r=null,inspectorOpen:n,inspectorTab:U0,onToggleInspector:f0,autoOpenInspector:J8,onToggleAutoOpenInspector:W8,onOpenLayers:n0,timelineOpen:M0,onToggleTimeline:c0,hasComps:e0=!1,assistantOpen:C8,onToggleAssistant:t0,assistantBusy:h8,assistantUnseen:j0,onNewCanvas:g0,onAssembleVideo:A8,onOpenExport:r8,onOpenSettings:R9,onOpenGenerate:$0,onReload:V9,onCloseCanvas:I0,onInsertArtboard:Z8,readOnly:H0=!1}){let k0=X===S8,F0=k0?"SYSTEM":X?"CANVAS":"IDLE",G8=k0?K("b",{children:"design system"}):X?A(W0,{children:[X.split("/").slice(0,-1).join("/"),"/",K("b",{children:AW(dN(X))})]}):K("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),T8=new Set(["assistant","inspector","layers","autoopen"]),Q8=[{id:"tree",label:"Project Tree",shortcut:"T",checked:B,disabled:!1},{id:"changes",label:z>0?`Changes · ${z} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:H,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:G,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:O,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:n&&U0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:n,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!J8,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:e0?"video":void 0,checked:M0,disabled:!1},...p8()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:C8,disabled:!1}]:[],{id:"annotate",label:"Annotations",shortcut:"⇧ P",checked:T,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:b,disabled:!X||k0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:y,disabled:!X||k0},{id:"present",label:"Presentation Mode",shortcut:"",checked:g,disabled:!X||k0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:c,disabled:!X||k0}].filter((w0)=>!H0||!T8.has(w0.id)),R8=["file","edit","view","selection","tools","help"];function P0(w0){if(R8.includes(w0))W(Y===w0?null:w0)}return u.useEffect(()=>{if(!Y||!R8.includes(Y))return;let w0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function a0(N0){let m0=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!m0.length)return;let B8=m0.indexOf(document.activeElement);if(N0.key==="ArrowDown")N0.preventDefault(),m0[(B8+1)%m0.length].focus();else if(N0.key==="ArrowUp")N0.preventDefault(),m0[(B8-1+m0.length)%m0.length].focus();else if(N0.key==="Home")N0.preventDefault(),m0[0].focus();else if(N0.key==="End")N0.preventDefault(),m0[m0.length-1].focus();else if(N0.key==="ArrowRight"||N0.key==="ArrowLeft"){N0.preventDefault();let i8=N0.key==="ArrowRight"?1:-1,Q9=R8.indexOf(Y);W(R8[(Q9+i8+R8.length)%R8.length])}else if(N0.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",a0),()=>{clearTimeout(w0),window.removeEventListener("keydown",a0)}},[Y,W]),A("header",{className:"st-menubar",role:"menubar","aria-label":"Application menubar",children:[A("span",{className:"st-brand","data-tour":"brand",children:[K("span",{className:"st-brand-mark",children:K("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:K("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),K("span",{className:"st-brand-name",children:"maude"})]}),K("nav",{className:"st-menus","aria-label":"Application menus","data-tour":"menus",children:kq0.map((w0)=>{let a0=w0.toLowerCase(),N0=R8.includes(a0),m0=N0||a0==="help";return K("button",{type:"button",className:"st-menu",role:"menuitem","data-tour":a0==="help"?"help":void 0,"aria-haspopup":N0?"menu":void 0,"aria-expanded":N0?Y===a0:void 0,onClick:()=>P0(a0),onMouseEnter:()=>{if(Y!==null&&N0)W(a0)},children:w0},a0)})}),Y==="file"&&K(bq0,{readOnly:H0,hasCanvas:!!X,onAction:(w0)=>{if(w0==="new")g0?.();else if(w0==="assemble")A8?.();else if(w0==="export")r8?.("export");else if(w0==="handoff")r8?.("handoff");else if(w0==="generate")$0?.();else if(w0==="settings")R9?.();else if(w0==="reload")V9?.();else if(w0==="close")I0?.()},onClose:()=>W(null)}),Y==="edit"&&K(jq0,{readOnly:H0,hasCanvas:!!X&&!k0,onAction:(w0)=>{if(w0==="undo")l({dgn:"undo"});else if(w0==="redo")l({dgn:"redo"});else if(w0==="deselect-all")l({dgn:"selection-clear"});else if(w0==="select-all-annotations")l({dgn:"annotation-select-all"});else if(w0.startsWith("new-artboard:"))Z8?.(w0.slice(13))},onClose:()=>W(null)}),Y==="view"&&K(Tq0,{panels:Q8,onToggle:(w0)=>{if(w0==="tree")F();else if(w0==="changes")U();else if(w0==="comments")Z();else if(w0==="hidden")M();else if(w0==="annotate")C();else if(w0==="inspector")f0();else if(w0==="autoopen")W8?.();else if(w0==="timeline")c0?.();else if(w0==="assistant")t0?.();else if(w0==="layers")n0?.();else if(w0==="minimap")$?.();else if(w0==="zoomctl")v?.();else if(w0==="present")m?.();else if(w0==="print-guides")f?.()},onZoom:(w0)=>l({dgn:"zoom",op:w0}),hasCanvas:!!X&&!k0,onClose:()=>W(null)}),Y==="selection"&&K($q0,{readOnly:H0,onAction:(w0)=>{if(w0==="deselect-all")l({dgn:"selection-clear"});else if(w0==="select-all-annotations")l({dgn:"annotation-select-all"})},onClose:()=>W(null)}),Y==="tools"&&K(Sq0,{readOnly:H0,onAction:(w0)=>l({dgn:"tool-set",tool:w0}),onClose:()=>W(null)}),Y==="help"&&K(Cq0,{onAction:(w0)=>{if(w0==="shortcuts")I?.();else if(w0==="help")E?.();else if(w0==="report-bug")P?.();else if(w0==="tour")w?.();else if(w0==="collab-tour")R?.();else if(w0==="quick-setup")s?.();else if(w0==="readiness")h?.();else if(w0==="whatsnew")p?.();else if(w0==="watch-intro")a?.()},onClose:()=>W(null)}),A("div",{className:"st-mb-right","data-tour":"status",children:[r?K("div",{className:"st-presence",children:r}):null,H0&&K("span",{className:"st-stamp st-stamp--viewonly","data-testid":"view-only-stamp","data-tip":"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"}),p8()&&!H0&&K("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":C8?"true":"false","data-busy":h8?"true":"false","data-unseen":j0?"true":"false","aria-label":`Assistant${h8?" — working":j0?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:t0,children:K(G9,{name:"sparkle",size:15})}),K0&&K(Zx,{center:K0}),K("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":i>0?"true":"false","aria-label":`What's new${i>0?` — ${i} unseen`:""}`,"data-tip":"What's new",onClick:p,children:K(G9,{name:"megaphone",size:15})}),K("span",{className:"st-stamp",children:F0}),K("span",{className:"st-mb-file",title:X||"",children:G8}),K("span",{className:"st-mb-sep"}),A("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[K("span",{className:"st-dot",style:{background:"var(--accent)"}}),e," ARTBOARDS"]}),K("span",{className:"st-mb-sep"}),K("span",{className:"st-mb-proj",children:J||"maude"})]})]})}function fq0({tabs:X,activePath:J,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:z,onIframeLoad:U,showQuickSetup:q,onStartQuickSetup:B}){return A("div",{className:"viewport st-stage","data-tour":"viewport",children:[X.length===0&&A("div",{className:"st-empty",children:[A("div",{className:"st-empty-brand",children:[K("span",{className:"st-brand-mark",children:K("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:K("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),K("span",{className:"st-empty-wm",children:"maude"}),A("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(Z||"MAUDE").toUpperCase()," / v",HR," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),K("div",{className:"st-empty-title",children:"Nothing open yet"}),A("div",{className:"st-empty-body",children:["← Pick a screen from the list on the left, or open ",K("strong",{children:"Design system"})," above it to see your colors, type, and components.",K("br",{}),K("br",{}),K("strong",{children:"To select something on the canvas:"})," hold ",K(t6,{children:"⌘"})," and hover to preview an element, click to select it — ",K(t6,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",p8()?A(W0,{children:[K("br",{}),K("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&&K("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((F)=>{if(F.path===S8)return K("div",{className:"system-view"+(F.path===J?" active":""),children:K(pq0,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},F.path);return K("iframe",{ref:(O)=>Q(F.path,O),src:sH(F.path,H),className:F.path===J?"active":"","data-path":F.path,"data-testid":F.path===J?"canvas-frame":void 0,onLoad:()=>U?.(F.path),...H?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},F.path)}),z&&z===J&&K("div",{className:"st-canvas-loading","aria-hidden":"true",children:A("div",{className:"st-skel-card",children:[K("div",{className:"st-skel-cap st-mono",children:"compiling canvas…"}),K("span",{className:"skel st-skel-thumb"}),K("span",{className:"skel st-skel-line",style:{width:"72%"}}),K("span",{className:"skel st-skel-line",style:{width:"46%"}})]})})]})}var vq0=["color","space","radius","shadow","leading","weight","motion","font","other"],xq0={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function hq0(X){return X==="color"}function gq0({tokens:X,tokenGroups:J,tokensPath:Q}){if(!X||X.length===0)return A("section",{className:"sv-section sv-section-tokens",children:[A("h2",{children:["tokens",K("span",{className:"sv-h-num",children:"0"})]}),K("div",{className:"sv-empty",children:A("p",{children:["No tokens parsed from"," ",Q?K("code",{children:Q}):"the configured tokens file",". Does the file exist and contain CSS custom properties (",K("code",{children:"--name: value;"}),")?"]})})]});let Y=J||{},W=Array.from(new Set([...vq0,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return K(W0,{children:W.map((G)=>{let Z=Y[G],H=hq0(G);return A("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[A("h2",{children:["tokens · ",xq0[G]||G,K("span",{className:"sv-h-num",children:Z.length})]}),K("div",{className:"sv-tokens-ladder",children:Z.map((z)=>A("div",{className:"sv-tok-cell",children:[H?K("div",{className:"sv-tok-swatch",style:{background:z.value}}):null,A("div",{className:"sv-tok-meta",children:[K("code",{className:"sv-tok-name",children:z.name}),K("span",{className:"sv-tok-value",children:z.value||"—"})]})]},z.name+"|"+z.value))})]},G)})})}function mq0(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 uq0(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 lq0({tokenGroups:X}){let J=X?.fontsize||[];if(J.length===0)return null;let Q=X?.leading||[],Y=uq0(X?.font);return A("section",{className:"sv-section sv-section-type",children:[A("h2",{children:["type · ladder",K("span",{className:"sv-h-num",children:J.length})]}),K("div",{className:"sv-type-list",children:J.map((W)=>{let G=mq0(W,Q),Z={fontSize:W.value};if(G)Z.lineHeight=G;if(Y)Z.fontFamily=Y;return A("div",{className:"sv-type-row",children:[K("code",{className:"sv-type-tok",children:W.name}),K("span",{className:"sv-type-sample",style:Z,children:"The catalog is the system."})]},W.name)})})]})}function pq0({data:X,onOpen:J,cfg:Q,onSelectDs:Y}){if(!X)return K("div",{className:"sv-empty",children:K("p",{children:"Loading design system…"})});let{previewGallery:W,uiKitsGallery:G,systemDir:Z,tokens:H,tokenGroups:z,tokensPath:U,ds:q,availableDesignSystems:B}=X,F=(!W||!W.length)&&(!G||!G.length),O=Array.isArray(B)&&B.length>1,M=q?.name??B?.[0]?.name??"";return A("div",{className:"sv",children:[A("header",{className:"sv-header",children:[K("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),K("span",{className:"sv-title",children:"design system view"}),O?A("label",{className:"sv-ds-picker",children:[K("span",{className:"sv-ds-picker-label",children:"DS"}),K("select",{value:M,onChange:(E)=>Y&&Y(E.target.value),children:B.map((E)=>K("option",{value:E.name,children:E.name},E.name))})]}):null,K("span",{className:"sv-loc",children:K("code",{children:Z})})]}),q?.description?K("p",{className:"sv-ds-description",children:q.description}):null,K(gq0,{tokens:H,tokenGroups:z,tokensPath:U}),K(lq0,{tokenGroups:z}),F?K("div",{className:"sv-empty",children:A("p",{children:["No ",K("code",{children:"preview/"})," or ",K("code",{children:"ui_kits/"})," folders found under"," ",K("code",{children:Z}),"."]})}):A(W0,{children:[K(nt,{title:"preview",items:W,onOpen:J,kind:"preview",cfg:Q}),K(nt,{title:"ui kits",items:G,onOpen:J,kind:"ui_kits",cfg:Q})]})]})}function nt({title:X,items:J,onOpen:Q,kind:Y,cfg:W}){if(!J||J.length===0)return null;return A("section",{className:"sv-section",children:[A("h2",{children:[X," ",K("span",{className:"sv-count",children:J.length})]}),K("div",{className:"sv-previews sv-previews-"+Y,children:J.map((G)=>A("article",{className:"sv-preview-card",onClick:()=>Q(G.path),children:[K("div",{className:"sv-preview-frame",children:K("iframe",{src:sH(G.path,W,{thumbnail:!0}),title:G.label,scrolling:"no",...W?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),A("div",{className:"sv-preview-foot",children:[K("strong",{children:G.label}),K("code",{children:G.path})]})]},G.path))})]})}function dq0({activePath:X,selected:J,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,changesCount:z=0,unpushed:U=0,changesOpen:q=!1,onOpenChanges:B}){let F=X===S8,O=J&&J.selector?J.selector+(J.text?` — "${J.text.slice(0,60)}"`:""):"",M=J&&J.dom_path?J.dom_path.join(" > "):J?J.selector:"",E=W==="dark"?"light":"dark",I=(()=>{if(!H||H.linked===!1)return null;if(H.notSyncable)return{online:!1,label:`0 syncable${H.tsxCount>0?` · ${H.tsxCount} tsx`:""}`,title:H.reason||"Linked to a hub, but no canvases are syncable."};let P=H.queuedOps??0;if(H.state==="online"||H.flash==="synced")return{online:!0,label:P>0?`${P} ↑`:"synced",title:P>0?`${P} edit(s) queued to push`:"All changes synced to the hub"};return{online:!1,label:`${P} ↑`,title:H.state==="connecting"?"Connecting to the hub…":"Offline — edits queued, will sync when the hub reconnects"}})();return A("footer",{className:"st-statusbar",role:"contentinfo",children:[A("span",{className:"st-sb-slot st-sb-active",role:"group","aria-label":"Active file",children:[K("span",{className:"lead","aria-hidden":"true"}),K("span",{className:"lbl",children:"active"}),K("span",{className:"val",title:X||"",children:F?"▦ design system":X||"—"})]}),X&&J&&J.selector&&!F&&A("span",{className:"st-sb-slot st-sb-sel",role:"group","aria-label":"Selected element",children:[K("span",{className:"lbl",children:"selected"}),K("span",{className:"val",title:M,children:O}),K("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:"×"})]}),A("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[K("span",{className:"lbl",children:"comments"}),A("span",{className:"val",children:[Y," open"]})]}),B&&A("button",{type:"button",className:"st-sb-slot st-sb-changes"+(q?" is-open":"")+(z>0?" has-changes":U>0?" has-unpushed":""),onClick:B,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":q,children:[K("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),K("span",{className:"lbl",children:"changes"}),K("span",{className:"val",children:z>0?`${z} unsaved`:U>0?`${U} to publish`:"all saved"})]}),K("span",{className:"st-sb-spacer"}),A("span",{className:"st-sb-slot",role:"group","aria-label":"Connection",children:[K("span",{className:"st-live-dot"+(Q?" is-connected":""),"aria-hidden":"true"}),K("span",{className:"lbl",children:Q?"live":"reconnecting"})]}),I&&A("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:[K("span",{className:"st-sb-sync-dot"+(I.online?" is-online":""),"aria-hidden":"true"}),K("span",{className:"lbl",children:"hub sync"}),K("span",{className:"val",title:I.title,children:I.label})]}),A("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${E} theme`,"data-tip-pos":"top","aria-label":`Switch to ${E} theme`,children:[K(G9,{name:W==="dark"?"sun":"moon",size:13}),E]})]})}function cq0({commentsByFile:X,filter:J,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:z,width:U,resizing:q}){let B=qe(X),F=Object.keys(X||{}).sort(),O=[];for(let M of F){let E=X[M]||[],I=E.filter((w)=>{if(J==="open")return w.status!=="resolved";if(J==="resolved")return w.status==="resolved";return!0});if(I.length===0)continue;let P=E.filter((w)=>w.selector);O.push({file:M,comments:I.map((w)=>({...w,n:P.findIndex((R)=>R.id===w.id)+1}))})}return A("aside",{className:"st-rpanel"+(q?" is-resizing":""),style:U?{width:U,flexBasis:U}:void 0,"aria-label":"Comments",children:[K("div",{className:"st-rp-tabs st-rp-tabs--filters",children:A("div",{className:"st-cm-filters",role:"tablist",children:[A("button",{type:"button",className:"st-cm-filter"+(J==="all"?" is-active":""),role:"tab","aria-selected":J==="all",onClick:()=>Q("all"),children:["All · ",B.all]}),A("button",{type:"button",className:"st-cm-filter"+(J==="open"?" is-active":""),role:"tab","aria-selected":J==="open",onClick:()=>Q("open"),children:["Open · ",B.open]}),A("button",{type:"button",className:"st-cm-filter"+(J==="resolved"?" is-active":""),role:"tab","aria-selected":J==="resolved",onClick:()=>Q("resolved"),children:["Resolved · ",B.resolved]})]})}),K("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:O.length===0?A("div",{className:"st-rp-empty",children:[A("p",{children:["No comments ",J!=="all"?`with status “${J}”`:"yet","."]}),A("p",{children:["Open a canvas, hold ",K(t6,{children:"⌘"})," and click an element, then press ",K(t6,{children:"C"})," — or hold ",K(t6,{children:"⌘⇧"})," and click directly."]})]}):O.map((M)=>A(W0,{children:[A("button",{type:"button",className:"st-cm-group-hd",onClick:()=>G(M.file,null),title:M.file,children:[K("span",{children:AW(dN(M.file))}),K("span",{className:"st-mono",children:M.comments.length})]}),M.comments.map((E)=>A("div",{className:"st-comment"+(E.status==="resolved"?" is-resolved":"")+(E.id===W?" is-active":""),onClick:()=>G(M.file,E.id),children:[A("div",{className:"st-comment-hd",children:[K("span",{className:"st-pin st-pin--inline",children:E.n||"·"}),K("span",{className:"st-comment-time",children:Zq0(E.created)})]}),K("div",{className:"st-comment-txt",children:E.text}),A("div",{className:"st-comment-foot",children:[K("span",{className:"st-comment-sel",title:(E.dom_path||[]).join(" > "),children:E.selector||"—"}),Z&&H&&z?A("span",{className:"st-mini-act",children:[E.status==="resolved"?K("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(I)=>{I.stopPropagation(),H(E.id)},children:K(G9,{name:"reopen",size:14})}):K("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(I)=>{I.stopPropagation(),Z(E.id)},children:K(G9,{name:"resolve",size:14})}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(I)=>{I.stopPropagation(),z(E.id)},children:K(G9,{name:"x",size:14})})]}):null]})]},E.id))]},M.file))})]})}function iq0({update:X,onDismiss:J}){let[Q,Y]=u.useState(!1);if(!X)return null;let W=X.version?` (v${X.version})`:"";return A("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[K("span",{className:"st-banner-dot","aria-hidden":"true"}),A("span",{children:["Maude updated",W," · restart to apply"]}),K("button",{type:"button",className:"btn btn--primary btn--sm",disabled:Q,onClick:()=>{Y(!0),xf().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),K("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:J,children:"Later"})]})}function oq0({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",z=Y==="offline"||Y==="offline-long",U=X.docs?.rejected??0,q=Array.isArray(Z)?[...Z].reverse().find((M)=>M.kind==="cold-start-diverged"):null;if(!z&&!H&&!q&&U===0)return null;let B,F,O;if(H)B="success",F="Synced with hub",O=`${Y}:flash`;else if(z){let M=Z&&Z.length>0?` (${Z.length} conflict notice(s))`:"";if(Y==="offline-long")B="error",F=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${M}`;else B="warn",F=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${M}`;O=`${Y}:offline`}else if(q){if(q.snapshotFailed)B="error",F=`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",F=`Diverged on ${q.slug}: kept the ${q.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${q.slug}`;O=`diverged:${q.slug}:${q.at}`}else B="warn",F=`${U} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,O=`rejected:${U}`;if(J===O)return null;return A("div",{role:"status","aria-live":"polite",className:`st-banner st-banner--${B}`,children:[K("span",{className:"st-banner-dot","aria-hidden":"true"}),K("span",{children:F}),K("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(O),children:"×"})]})}var nq0=["block","inline-block","flex","inline-flex","grid","inline","none"],rt=["px","%","fr","em","auto","min-content","max-content"];var rq0=["auto","stretch","flex-start","center","flex-end","baseline"];var at=["300","400","500","600","700","800"],st=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],tt=["none","solid","dashed","dotted","double"],et=["px","rem","em","%","vw","vh","auto"],Xe=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),WR={"font-size":{node:K(h9,{as:T1,size:12})},"line-height":{node:K(h9,{as:f1,size:12})},"letter-spacing":{node:K(h9,{as:d1,size:12})},gap:{node:K(h9,{as:Tz,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:K(h9,{as:r1,size:12})},"border-width":{node:K(h9,{as:p1,size:12})}};var Je=["static","relative","absolute","fixed","sticky"],aq0=["normal","italic","oblique"],Qe=["none","uppercase","lowercase","capitalize"];var Ye=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],sq0=["fill","contain","cover","none","scale-down"];var We=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Ge=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],Z5={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}},XK=null;function pN(X){if(!X)return"";if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();try{if(!XK)XK=document.createElement("canvas").getContext("2d");if(!XK)return"";XK.fillStyle="#000000",XK.fillStyle=X;let J=XK.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 TY=(X)=>Math.min(1,Math.max(0,X));function gN(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 Wq({r:X,g:J,b:Q}){return`#${[X,J,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function Gq({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 JK({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,z=0;if(X<60)[Z,H,z]=[Y,W,0];else if(X<120)[Z,H,z]=[W,Y,0];else if(X<180)[Z,H,z]=[0,Y,W];else if(X<240)[Z,H,z]=[0,W,Y];else if(X<300)[Z,H,z]=[W,0,Y];else[Z,H,z]=[Y,0,W];return{r:(Z+G)*255,g:(H+G)*255,b:(z+G)*255}}function m9(X){if(!X)return"";let J=/^(-?\d*\.?\d+)px$/.exec(X);return J?`${Math.round(Number.parseFloat(J[1]))}px`:X}function _Q(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 Ze(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 Fe(X,J){return(X?J?.canvasDesignSystems?.[X]:null)||J?.defaultDesignSystem||J?.designSystems?.[0]?.name||null}function tq0(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],z=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(H);Q[Z]=z&&J[z[1]]?J[z[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 Le(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(z)=>{if(!z.tokensCssRel)return null;try{let U=await fetch(`/${J}/${z.tokensCssRel}`),q=U.ok?await U.text():"";return{name:z.name,...tq0(q)}}catch{return null}})).then((z)=>{if(H)return;let U=z.filter(Boolean);U.sort((q,B)=>q.name===Q?-1:B.name===Q?1:0),Z(U)}),()=>{H=!0}},[W,J,Q]),G}function De({seed:X,label:J,onApply:Q}){let[Y,W]=u.useState(()=>Gq(gN(X||"#000000"))),G=u.useRef(Y);G.current=Y;let Z=u.useRef(null),H=u.useRef(null),z=u.useRef(X);u.useEffect(()=>{if(X&&X!==z.current)z.current=X,W(Gq(gN(X)))},[X]);let U=Wq(JK(Y)),q=(w)=>{w.preventDefault();let R=Z.current?.getBoundingClientRect();if(!R)return;let T=G.current.h,C=($)=>{W({h:T,s:TY(($.clientX-R.left)/R.width),v:TY(1-($.clientY-R.top)/R.height)})};C(w);let b=()=>{document.removeEventListener("pointermove",C),document.removeEventListener("pointerup",b),Q(Wq(JK(G.current)))};document.addEventListener("pointermove",C),document.addEventListener("pointerup",b)},B=(w)=>{w.preventDefault();let R=H.current?.getBoundingClientRect();if(!R)return;let{s:T,v:C}=G.current,b=(y)=>{W({h:TY((y.clientX-R.left)/R.width)*360,s:T,v:C})};b(w);let $=()=>{document.removeEventListener("pointermove",b),document.removeEventListener("pointerup",$),Q(Wq(JK(G.current)))};document.addEventListener("pointermove",b),document.addEventListener("pointerup",$)},F=(w)=>{let R={...G.current,...w};W(R),Q(Wq(JK(R)))},O=(w)=>{let R=w.shiftKey?0.1:0.02,C={ArrowLeft:[-R,0],ArrowRight:[R,0],ArrowUp:[0,R],ArrowDown:[0,-R]}[w.key];if(!C)return;w.preventDefault(),F({s:TY(G.current.s+C[0]),v:TY(G.current.v+C[1])})},M=(w)=>{let R=w.shiftKey?20:2,C={ArrowLeft:-R,ArrowRight:R}[w.key];if(C==null)return;w.preventDefault(),F({h:Math.min(360,Math.max(0,G.current.h+C))})},E=async()=>{try{let w=window.EyeDropper;if(!w)return;let R=await new w().open();if(R?.sRGBHex)W(Gq(gN(R.sRGBHex))),Q(R.sRGBHex)}catch{}},I=JK(Y),P=(w)=>{let R={...I,...w},T=Gq({r:TY(R.r/255)*255,g:TY(R.g/255)*255,b:TY(R.b/255)*255});W(T),Q(Wq(JK(T)))};return A("div",{className:"st-cp-cpick",children:[A("div",{className:"st-cp-cpick-hexrow",children:[K("span",{className:"st-cp-cpick-hexsw",style:{background:U}}),K("input",{className:"st-cp-cpick-hex",type:"text",value:U,"aria-label":J?`${J} hex value`:"hex value",onChange:(w)=>{let R=w.target.value;if(/^#?[0-9a-f]{6}$/i.test(R))W(Gq(gN(R)))},onKeyDown:(w)=>{if(w.key==="Enter")Q(w.currentTarget.value)},onBlur:(w)=>Q(w.currentTarget.value),onFocus:(w)=>w.currentTarget.select()})]}),A("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:O,children:[K("span",{className:"st-cp-cpick-svwhite"}),K("span",{className:"st-cp-cpick-svblack"}),K("span",{className:"st-cp-cpick-knob",style:{left:`${Y.s*100}%`,top:`${(1-Y.v)*100}%`,background:U}})]}),A("div",{className:"st-cp-cpick-controls",children:[window.EyeDropper?K("button",{type:"button",className:"st-cp-cpick-eye","aria-label":"pick from screen",title:"eyedropper",onClick:E,children:K(G9,{name:"eyedropper",size:14})}):null,K("span",{className:"st-cp-cpick-preview",style:{background:U},"aria-hidden":"true"}),K("button",{type:"button",ref:H,className:"st-cp-cpick-hue","aria-label":J?`${J} hue`:"hue",onPointerDown:B,onKeyDown:M,children:K("span",{className:"st-cp-cpick-huethumb",style:{left:`${Y.h/360*100}%`}})})]}),K("div",{className:"st-cp-cpick-rgb",children:["r","g","b"].map((w)=>A("label",{className:"st-cp-cpick-rgbf",children:[K("input",{"aria-label":w.toUpperCase(),value:Math.round(I[w]),onChange:(R)=>P({[w]:TY((Number.parseFloat(R.target.value)||0)/255)*255}),onFocus:(R)=>R.currentTarget.select()}),K("span",{children:w.toUpperCase()})]},w))})]})}function mN({kind:X,groups:J,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:z}){let[U,q]=u.useState(!1),[B,F]=u.useState(null),[O,M]=u.useState("custom"),[E,I]=u.useState(""),P=u.useRef(null),w=u.useRef(null),R=typeof Q==="string"&&/var\(\s*--/.test(Q),T=(a)=>Q===`var(${a})`,C=(a)=>a.replace(/^--/,"").replace(/-/g," "),b=J||[],$=b.reduce((a,i)=>a+(i.names?.length||0),0),y=b.length>1,v=E.trim().toLowerCase(),g=!v?b:b.map((a)=>({...a,names:(a.names||[]).filter((i)=>C(i).toLowerCase().includes(v)||i.toLowerCase().includes(v)||(a.vals?.[i]||"").toLowerCase().includes(v))})).filter((a)=>a.names.length);u.useEffect(()=>{if(!U){I("");return}let a=()=>{let r=P.current?.getBoundingClientRect();if(!r)return;let n=224,U0=300,f0=Math.min(r.right-n,window.innerWidth-n-8);if(f0<8)f0=8;let W8=window.innerHeight-r.bottom>U0+8?r.bottom+4:Math.max(8,r.top-U0-4);F({left:f0,top:W8,width:n,maxHeight:U0})};a();let i=(r)=>{if(w.current?.contains(r.target)||P.current?.contains(r.target))return;q(!1)},K0=(r)=>{if(r.key==="Escape")q(!1)},e=(r)=>{if(w.current?.contains(r.target))return;a()};return document.addEventListener("pointerdown",i,!0),document.addEventListener("keydown",K0),window.addEventListener("resize",a),document.addEventListener("scroll",e,!0),()=>{document.removeEventListener("pointerdown",i,!0),document.removeEventListener("keydown",K0),window.removeEventListener("resize",a),document.removeEventListener("scroll",e,!0)}},[U]),u.useEffect(()=>{if(!U||!B||!w.current)return;let a=w.current.getBoundingClientRect(),i=B.left-a.left,K0=B.top-a.top;if(Math.abs(i)>0.5||Math.abs(K0)>0.5)F((e)=>e?{...e,left:e.left+i,top:e.top+K0}:e)},[U,B]);let m=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,c=(a,i,K0)=>{if(H&&a&&a!==H&&K0&&!m.test(K0))Y(K0);else Y(`var(${i})`);q(!1)},f=(a)=>{let i=(a||"").trim();if(i)Y(i)},l=A("div",{className:"st-cp-pop-search",children:[K(G9,{name:"search",size:12}),K("input",{value:E,onChange:(a)=>I(a.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),p=(a)=>a.map((i)=>A("div",{className:"st-cp-pop-group",children:[y?K("div",{className:"st-cp-pop-ds",children:i.ds}):null,K("div",{className:"st-cp-pop-list",children:i.names.map((K0)=>A("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${T(K0)?" is-on":""}`,onClick:()=>c(i.ds,K0,i.vals?.[K0]),children:[K("span",{className:"st-cp-pop-cswatch",style:{background:i.vals?.[K0]||"transparent"},"aria-hidden":"true"}),K("span",{className:"st-cp-pop-name",children:C(K0)}),K("span",{className:"st-cp-pop-val",children:i.vals?.[K0]||""})]},`${i.ds}:${K0}`))})]},i.ds)),h=(a)=>a.map((i)=>A("div",{className:"st-cp-pop-group",children:[y?K("div",{className:"st-cp-pop-ds",children:i.ds}):null,K("div",{className:"st-cp-pop-list",children:i.names.map((K0)=>A("button",{type:"button",className:`st-cp-pop-row${T(K0)?" is-on":""}`,onClick:()=>c(i.ds,K0,i.vals?.[K0]),children:[K("span",{className:"st-cp-pop-name",children:C(K0)}),K("span",{className:"st-cp-pop-val",children:i.vals?.[K0]||""})]},`${i.ds}:${K0}`))})]},i.ds)),s=K("div",{className:"st-cp-pop-empty",children:"No match"});return A(W0,{children:[G!==void 0?K("button",{type:"button",ref:P,className:`${z||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${R&&!z?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>q((a)=>!a),children:K("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):K("button",{type:"button",ref:P,className:`st-cp-tokbtn${R?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>q((a)=>!a),children:K("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),U&&B?ze.createPortal(K("div",{ref:w,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"?A(W0,{children:[A("div",{className:"st-cp-poptabs",role:"tablist",children:[K("button",{type:"button",role:"tab","aria-selected":O==="custom",className:`st-cp-poptab${O==="custom"?" is-active":""}`,onClick:()=>M("custom"),children:"Custom"}),K("button",{type:"button",role:"tab","aria-selected":O==="vars",className:`st-cp-poptab${O==="vars"?" is-active":""}`,onClick:()=>M("vars"),children:"Variables"})]}),O==="custom"?K(De,{seed:Z||pN(Q)||"#000000",onApply:f}):!$?K("div",{className:"st-cp-pop-empty",children:"No color tokens"}):A(W0,{children:[l,g.length?p(g):s]})]}):!$?K("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):A(W0,{children:[l,g.length?h(g):s]})}),document.body):null]})}function He({label:X,tracks:J,editable:Q,onChange:Y}){let W=(z,U)=>{let q=J[z];Y(J.map((B,F)=>F===z?yU.has(U)?{value:0,unit:U}:{value:q.value||1,unit:U}:B))},G=(z,U)=>{Y(J.map((q,B)=>B===z?{...q,value:U}:q))},Z=()=>Y([...J,{value:1,unit:"fr"}]),H=(z)=>Y(J.filter((U,q)=>q!==z));return A("div",{className:"st-cp-gridtracks",children:[A("div",{className:"st-cp-gridtracks-hd",children:[K("span",{className:"st-cp-gridtracks-label",children:X}),K("button",{type:"button",className:"st-btn st-cp-gridtracks-add",disabled:!Q,onClick:Z,children:"+ Track"})]}),J.length===0?A("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",X.toLowerCase(),"."]}):J.map((z,U)=>{let q=yU.has(z.unit);return A("div",{className:"st-cp-gridtrack-row",children:[q?K(ZW,{value:z.unit,ariaLabel:`${X} track ${U+1}`,options:rt.map((B)=>({value:B,label:B})),onChange:(B)=>W(U,B)}):K(v6,{value:z.value,min:z.unit==="fr"?0.1:0,step:z.unit==="fr"?0.1:1,ariaLabel:`${X} track ${U+1} value`,lead:String(U+1),unitSlot:K(_B,{value:z.unit,units:rt,ariaLabel:`${X} track ${U+1} unit`,onChange:(B)=>W(U,B)}),onCommit:(B)=>G(U,B)}),K("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 eq0({el:X,cfg:J,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let z=!!X.id,U=X.computed||{},[q,B]=u.useState({a:{},c:{},t:{}});u.useEffect(()=>{B({a:{},c:{},t:{}})},[X.id]);let F=(t,q0)=>{let Z0={...t||{}};for(let[R0,u0]of Object.entries(q0))if(u0===null)delete Z0[R0];else Z0[R0]=u0;return Z0},O=F(X.authored,q.a),M=F(X.customStyles,q.c),E=F(X.attrs,q.t),I=(t,q0)=>B((Z0)=>({...Z0,a:{...Z0.a,[t]:q0}})),P=(t,q0)=>B((Z0)=>({...Z0,c:{...Z0.c,[t]:q0}})),w=(t,q0)=>B((Z0)=>({...Z0,t:{...Z0.t,[t]:q0}})),R=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),T=Fe(X.file,J),C=Le(J,R,T),b=(t)=>C.map((q0)=>({ds:q0.name,names:q0[t]||[],vals:q0.vals})).filter((q0)=>q0.names.length),[$,y]=u.useState({}),[v,g]=u.useState({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),m=Object.keys(M).length>0||Object.keys(E).length>0;u.useEffect(()=>{if(m)g((t)=>t.Advanced?t:{...t,Advanced:!0})},[X.id,m]);let c=(O.position||m9(U.position)||"static")!=="static";u.useEffect(()=>{if(c)g((t)=>t["d:Position"]?t:{...t,"d:Position":!0})},[X.id,c]);let f=H,[l,p]=u.useState({});async function h(t,q0,Z0){y((R0)=>({...R0,[Z0]:"saving"}));try{let R0=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(q0)}),u0=await R0.json().catch(()=>({}));y((w8)=>({...w8,[Z0]:!R0.ok||!u0.ok?`err:${u0&&u0.error||`HTTP ${R0.status}`}`:"saved"}))}catch(R0){y((u0)=>({...u0,[Z0]:`err:${R0&&R0.message?R0.message:String(R0)}`}))}}let s=(t,q0)=>{if(!Q||!X.id)return;Q({id:X.id,artboardId:X.artboardId??null,index:X.index??0,prop:t,value:q0})},a=(t,q0,Z0,R0)=>{Y?.({op:t,canvas:X.file,id:X.id,key:q0,before:Z0==null||Z0===""?null:Z0,after:R0==null||R0===""?null:R0})},i=(t,q0)=>{let Z0=(q0||"").trim();if(!z||!Z0)return;let R0=O[t]??null;if(Z0===(R0??"").trim())return;s(t,Z0),I(t,Z0),h("/_api/edit-css",{canvas:X.file,id:X.id,property:t,value:Z0},t),a("css",t,R0,Z0)},K0=(t,q0)=>{let Z0=(q0||"").trim(),R0=t.trim();if(!z||!R0||!Z0)return;let u0=M[R0]??null;s(R0,Z0),P(R0,Z0),h("/_api/edit-css",{canvas:X.file,id:X.id,property:R0,value:Z0},R0),a("css",R0,u0,Z0)},e=(t,q0)=>{let Z0=(t||"").trim(),R0=(q0||"").trim();if(!z||!Z0||!R0)return;let u0=E[Z0]??null;w(Z0,R0),h("/_api/edit-attr",{canvas:X.file,id:X.id,attr:Z0,value:R0},`@${Z0}`),a("attr",Z0,u0,R0)},r=(t)=>{if(!z)return;let q0=O[t]??null;s(t,null),I(t,null),h("/_api/edit-css",{canvas:X.file,id:X.id,property:t,reset:!0},t),a("css",t,q0,null)},n=(t)=>{if(!z)return;let q0=M[t]??null;s(t,null),P(t,null),h("/_api/edit-css",{canvas:X.file,id:X.id,property:t,reset:!0},t),a("css",t,q0,null)},U0=(t)=>{if(!z)return;let q0=E[t]??null;w(t,null),h("/_api/edit-attr",{canvas:X.file,id:X.id,attr:t,reset:!0},`@${t}`),a("attr",t,q0,null)},f0={display:X.parentDisplay,flexDirection:X.parentFlexDirection},J8=(t,q0)=>{if(!z)return;let Z0=Math.round((t==="width"?X.bounds?.w:X.bounds?.h)||0),R0=B$(t,q0,f0,Z0);for(let u0 of R0.reset)if(O[u0])r(u0);for(let[u0,w8]of R0.set)i(u0,w8)},W8=X.parentDisplay==="flex"||X.parentDisplay==="inline-flex",n0=(t)=>{let q0=q$(t,O,U,f0);return A("div",{className:"st-cp-moderow",children:[K("span",{className:"st-cp-modelabel",children:t==="width"?"Width sizing":"Height sizing"}),K("div",{className:"st-cp-modeseg",role:"group","aria-label":`${t} sizing mode`,children:K(AB,{value:q0,ariaLabel:`${t} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(Z0)=>J8(t,Z0)})})]},`mode-${t}`)},M0=["flex-start","center","flex-end"],c0=["flex-start","center","flex-end"],e0=["t","c","b"],C8=["l","c","r"],t0=()=>{let t=!(O["flex-direction"]||m9(U["flex-direction"])||"row").startsWith("column"),q0=Math.max(0,M0.indexOf(O["justify-content"]||m9(U["justify-content"])||"flex-start")),Z0=O["align-items"]||m9(U["align-items"])||"stretch",R0=Z0==="stretch"?1:Math.max(0,c0.indexOf(Z0)),[u0,w8]=t?[q0,R0]:[R0,q0];return e0[w8]+C8[u0]},h8=(t)=>{let q0=e0.indexOf(t[0]),Z0=C8.indexOf(t[1]),R0=!(O["flex-direction"]||m9(U["flex-direction"])||"row").startsWith("column"),[u0,w8]=R0?[Z0,q0]:[q0,Z0];i("justify-content",M0[u0]),i("align-items",c0[w8])},j0=(t)=>{if(!(t.metaKey||t.ctrlKey)||t.altKey)return;let q0=t.key.toLowerCase();if(q0==="z")t.preventDefault(),G?.(t.shiftKey?"redo":"undo");else if(q0==="y")t.preventDefault(),G?.("redo")},g0=(t)=>{let q0=O[t];if(!q0)return"inherit";return/var\(\s*--/.test(q0)?"bound":"raw"};if(!z)return A("div",{className:"st-cp",children:[K("div",{className:"st-cp-id",children:K("span",{className:"st-cp-idtag",children:X.tag||"element"})}),A("div",{className:"st-css-disabled",children:["This selection has no stable element id (a legacy canvas, or a non-element target). Edit it with ",K("code",{children:"/design:edit"}),"."]})]});let A8={bound:"token-bound",raw:"raw override",inherit:"inherited"},r8=(t)=>K("span",{className:`st-cp-prov st-cp-prov--${t}`,role:"img","aria-label":A8[t]}),R9=(t,q0)=>{let Z0=q0??g0(t),R0=$[t],u0=typeof R0==="string"&&R0.startsWith("err:")?R0.slice(4):"",w8=u0?" is-err":R0==="saved"?" is-saved":R0==="saving"?" is-saving":"",L8=!!O[t],$8=u0?`error: ${u0}`:L8?`${A8[Z0]} · double-click to reset`:A8[Z0];return K("button",{type:"button",className:`st-cp-prov st-cp-prov--${Z0}${w8}${L8?" is-resettable":""}`,"aria-label":$8,title:$8,tabIndex:L8?0:-1,onDoubleClick:L8?()=>r(t):void 0,onKeyDown:L8?(E8)=>{if(E8.key==="Backspace"||E8.key==="Delete")E8.preventDefault(),r(t)}:void 0})},$0=(t,q0,Z0,R0)=>{let u0=Z0===void 0&&!O[t],w8=R0??t;return A("div",{className:`st-cp-row${u0?" is-unset":""}`,children:[R9(t,Z0),K("label",{className:"st-cp-label",title:w8,children:w8}),K("div",{className:"st-cp-ctl",children:q0})]},t)},V9={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"]},I0=(t)=>{(V9[t]||[]).forEach((q0)=>{if(O[q0])r(q0)})},Z8=(t,q0)=>{let Z0=(V9[t]||[]).some((R0)=>O[R0]);return A("section",{className:"st-cp-sec",children:[A("div",{className:"st-cp-sechd-row",children:[A("button",{type:"button",className:"st-cp-sechd","aria-expanded":!!v[t],onClick:()=>g((R0)=>({...R0,[t]:!R0[t]})),children:[K("span",{className:"st-cp-caret","aria-hidden":"true",children:v[t]?"▾":"▸"}),t]}),K("button",{type:"button",className:`st-cp-secreset${Z0?"":" is-quiet"}`,"aria-label":`reset ${t} section to original`,title:`reset ${t}`,disabled:!Z0,onClick:()=>I0(t),children:K(h9,{as:nG,size:12})})]}),K("div",{className:`st-cp-sec-anim${v[t]?" is-open":""}`,children:K("div",{className:"st-cp-sec-inner",children:q0})})]},t)},H0=(t,q0,Z0,R0=!0)=>{let u0=`d:${t}`,w8=v[u0]===void 0?R0:v[u0],L8=q0.some(($8)=>O[$8]);return A("section",{className:"st-cp-sec",children:[A("div",{className:"st-cp-sechd-row",children:[A("button",{type:"button",className:"st-cp-sechd","aria-expanded":w8,onClick:()=>g(($8)=>({...$8,[u0]:!w8})),children:[K("span",{className:"st-cp-caret","aria-hidden":"true",children:w8?"▾":"▸"}),t]}),K("button",{type:"button",className:`st-cp-secreset${L8?"":" is-quiet"}`,"aria-label":`reset ${t} to original`,title:`reset ${t}`,disabled:!L8,onClick:()=>q0.forEach(($8)=>{if(O[$8])r($8)}),children:K(h9,{as:nG,size:12})})]}),K("div",{className:`st-cp-sec-anim${w8?" is-open":""}`,children:K("div",{className:"st-cp-sec-inner",children:Z0})})]},u0)},k0=(t)=>K("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!l[t],"aria-label":l[t]?`${t} — fewer options`:`${t} — more options`,title:l[t]?"fewer":"more",onClick:()=>p((q0)=>({...q0,[t]:!q0[t]})),children:l[t]?"▴":"···"}),F0=(t,q0)=>A("select",{className:"st-cp-nsel","aria-label":t,value:q0.includes(O[t])?O[t]:"",onChange:(Z0)=>i(t,Z0.target.value),children:[K("option",{value:"",disabled:!0,children:m9(U[t])||"—"}),q0.map((Z0)=>K("option",{value:Z0,children:Z0},Z0))]}),G8=(t)=>b(t).flatMap((q0)=>(q0.names||[]).map((Z0)=>({name:Z0,value:q0.vals?.[Z0]||""}))),T8=(t,q0)=>K(uw,{value:O[t]||m9(U[t])||q0[0].value,ariaLabel:t,options:q0,onChange:(Z0)=>i(t,Z0)}),Q8=(t,q0,Z0={})=>{let R0=_Q(O[t]??""),u0=Xe.has(t),w8=O[t]??"",L8=typeof w8==="string"&&/var\(\s*--/.test(w8),$8=u0?"":R0.unit&&R0.unit!=="auto"?R0.unit:"px",E8=Number.parseFloat(_Q(m9(U[t])??"").n)||0,t8=R0.n!==""&&R0.n!=null?Number.parseFloat(R0.n)||0:E8,O9=WR[t];return K(EB,{value:L8?w8:t8,tokens:G8(q0),ariaLabel:t,min:Z0.min??0,lead:O9?O9.node??O9.t:void 0,unitSlot:u0?null:K(_B,{units:et,value:R0.unit||"px",ariaLabel:`${t} unit`,onChange:(M9)=>i(t,M9==="auto"?"auto":`${R0.n||"0"}${M9}`)}),onChange:(M9)=>i(t,typeof M9==="string"?M9:u0?`${M9}`:`${M9}${$8}`)})},R8=()=>{let t=(u0)=>Number.parseFloat(_Q(O[u0]??O["border-radius"]??m9(U[u0])??m9(U["border-radius"])??"0").n)||0,q0={tl:t("border-top-left-radius"),tr:t("border-top-right-radius"),bl:t("border-bottom-left-radius"),br:t("border-bottom-right-radius")},Z0=(u0)=>{if(u0.tl===u0.tr&&u0.tr===u0.bl&&u0.bl===u0.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((L8)=>{if(O[L8])r(L8)}),i("border-radius",`${u0.tl}px`);else i("border-top-left-radius",`${u0.tl}px`),i("border-top-right-radius",`${u0.tr}px`),i("border-bottom-left-radius",`${u0.bl}px`),i("border-bottom-right-radius",`${u0.br}px`)},R0=WR["border-radius"];return K(Sv,{corners:q0,lead:R0?R0.node??R0.t:void 0,onCorners:Z0})},P0=()=>A("div",{className:"st-cp-border",children:[Y9("border-width",null,{fixedUnit:"px"}),A("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:tt.includes(O["border-style"])?O["border-style"]:"",onChange:(t)=>i("border-style",t.target.value),children:[K("option",{value:"",disabled:!0,children:"style"}),tt.map((t)=>K("option",{value:t,children:t},t))]}),K(mN,{kind:"color",groups:b("color"),current:O["border-color"],activeDs:T,swatchBg:U["border-color"]||O["border-color"]||"",seedHex:pN(U["border-color"]||O["border-color"])||"#000000",onPick:(t)=>i("border-color",t),label:"border colour"})]}),w0=()=>{let t=O.transform||m9(U.transform)||"",q0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(t),Z0=((q0?Number.parseFloat(q0[1]):0)%360+360)%360,R0=(u0)=>{let w8=(u0%360+360)%360,L8=(O.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();i("transform",`${L8?`${L8} `:""}rotate(${w8}deg)`.trim())};return A("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[K(Cv,{value:Z0,onChange:R0}),K(v6,{value:Z0,min:0,max:360,ariaLabel:"rotation",lead:K(h9,{as:nG}),steppers:!1,unitSlot:K("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:R0})]})},a0=()=>{let t=O.filter||m9(U.filter)||"",q0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(t),Z0=q0?Number.parseFloat(q0[1]):0;return K(v6,{value:Z0,min:0,ariaLabel:"filter blur",unitSlot:K("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(u0)=>{let w8=(O.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();i("filter",u0>0?`${w8?`${w8} `:""}blur(${u0}px)`.trim():w8||"none")}})},N0=()=>{let t=O.opacity,q0=t!=null&&t!==""?Number.parseFloat(t):Number.parseFloat(m9(U.opacity))||1,Z0=Math.round((Number.isNaN(q0)?1:q0)*100);return K(BJ,{value:Z0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(R0)=>s("opacity",String(R0/100)),onCommit:(R0)=>i("opacity",String(R0/100))},`opacity:${t??""}`)},m0=()=>{let t=Number.parseInt(O["font-weight"]||m9(U["font-weight"])||"400",10)>=600,q0=(O["font-style"]||m9(U["font-style"]))==="italic",Z0=/underline/.test(O["text-decoration"]||m9(U["text-decoration"])||"");return K(kv,{value:{b:t,i:q0,u:Z0},ariaLabel:"text style",options:[{value:"b",node:K(h9,{as:v1}),label:"Bold"},{value:"i",node:K(h9,{as:u1}),label:"Italic"},{value:"u",node:K(h9,{as:t1}),label:"Underline"}],onToggle:(R0)=>{if(R0==="b")i("font-weight",t?"400":"700");else if(R0==="i")i("font-style",q0?"normal":"italic");else i("text-decoration",Z0?"none":"underline")}})},B8=[{value:"row",node:K(h9,{as:a4}),label:"Row"},{value:"column",node:K(h9,{as:s4}),label:"Column"}],i8=[{value:"flex-start",node:K(h9,{as:S1}),label:"Start"},{value:"center",node:K(h9,{as:C1}),label:"Center"},{value:"flex-end",node:K(h9,{as:$1}),label:"End"},{value:"space-between",node:K(h9,{as:Tz}),label:"Space between"}],Q9=[{value:"flex-start",node:K(h9,{as:y1}),label:"Start"},{value:"center",node:K(h9,{as:b1}),label:"Center"},{value:"flex-end",node:K(h9,{as:j1}),label:"End"},{value:"stretch",node:K(h9,{as:a1}),label:"Stretch"}],Y7=[{value:"left",node:K(h9,{as:E5}),label:"Left"},{value:"center",node:K(h9,{as:XW}),label:"Center"},{value:"right",node:K(h9,{as:JW}),label:"Right"},{value:"justify",node:K(h9,{as:QW}),label:"Justify"}],Z9=[{value:"visible",node:K(h9,{as:oG}),label:"Visible"},{value:"hidden",node:K(h9,{as:rG}),label:"Hidden"},{value:"scroll",node:K(h9,{as:o1}),label:"Scroll"}],W6=(t,q0)=>{let Z0=b(q0);return Z0.length?K(mN,{kind:"value",groups:Z0,current:O[t],activeDs:T,onPick:(R0)=>i(t,R0),label:`${t} design token`}):null},e9=(t)=>{let q0=t.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===q0)q0.select()})},DX=(t,q0)=>{if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return!1;t.preventDefault();let Z0=t.shiftKey?10:1,R0=t.key==="ArrowUp"?1:-1,u0=(Number.parseFloat(t.currentTarget.value)||0)+R0*Z0;return t.currentTarget.value=String(u0),q0(u0),!0},V7=(t)=>K("input",{className:"st-cp-fin","aria-label":t,defaultValue:O[t]??"",placeholder:m9(U[t])||"—",onFocus:e9,onKeyDown:(q0)=>{if(q0.key==="Enter")q0.currentTarget.blur()},onBlur:(q0)=>i(t,q0.currentTarget.value)},`${t}:${O[t]??""}`),Y9=(t,q0,Z0={})=>{let R0=_Q(O[t]??""),u0=Xe.has(t),w8=u0?"":Z0.fixedUnit||(R0.unit&&R0.unit!=="auto"?R0.unit:"px"),L8=WR[t],$8=Number.parseFloat(_Q(m9(U[t])??"").n)||0,E8=R0.n!==""&&R0.n!=null?Number.parseFloat(R0.n)||0:$8;return A(W0,{children:[K(v6,{value:E8,min:Z0.min??0,step:1,ariaLabel:t,lead:L8?L8.node??L8.t:void 0,onCommit:(t8)=>i(t,u0?`${t8}`:`${t8}${w8}`),unitSlot:u0||Z0.fixedUnit?null:K(_B,{units:et,value:R0.unit||"px",ariaLabel:`${t} unit`,onChange:(t8)=>i(t,t8==="auto"?"auto":`${R0.n||"0"}${t8}`)})},`${t}:${O[t]??""}`),W6(t,q0)]})},W7=(t)=>{let q0=U[t]||O[t]||"",Z0=O[t]??"",R0=typeof Z0==="string"&&/var\(\s*--/.test(Z0),u0=R0?Z0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):Z0;return K(XV,{swatch:K(mN,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:b("color"),current:O[t],activeDs:T,swatchBg:q0,seedHex:pN(U[t]||O[t])||"#000000",onPick:(w8)=>i(t,w8),label:`${t} colour`}),displayValue:u0,bound:R0,ariaLabel:t,onValue:(w8)=>i(t,w8)})},a8=(t,q0)=>{let Z0=null,R0=q0.unitless?"":"px",u0=($8)=>q0.unitless?`${$8}`:`${$8}${R0}`,w8=($8,E8,t8)=>{for(let O9 of E8??[t])t8(O9,u0($8))},L8=mw({getBase:()=>Z0?.value??"0",min:q0.min??0,step:1,sides:q0.sides,onInput:($8,E8)=>{if(Z0)Z0.value=String($8);if(E8){let t8=Z0?.closest(".st-cp-box");for(let O9 of E8){if(O9===t)continue;let M9=t8?.querySelector(`.st-cp-boxv[aria-label="${O9}"]`);if(M9)M9.value=String($8)}}w8($8,E8,s)},onCommit:($8,E8)=>w8($8,E8,i)});return{onPointerDown:($8)=>{Z0=$8.currentTarget,L8($8)}}},H9=(t,q0)=>{let Z0=O[t],R0=Z0!=null&&Z0!==""?_Q(Z0).n||Z0:_Q(m9(U[t])??"").n||"0",u0=!Z0||Z0==="0"||Z0==="0px"||Z0==="auto",w8=t.split("-").pop(),L8=w8==="top"||w8==="bottom"?[`${q0}-top`,`${q0}-bottom`]:[`${q0}-left`,`${q0}-right`],$8=[`${q0}-top`,`${q0}-right`,`${q0}-bottom`,`${q0}-left`];return K("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${q0[0]}${t.split("-").pop()[0]}${u0?" is-zero":""}`,"aria-label":t,defaultValue:R0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...a8(t,{sides:{pair:L8,all:$8}}),onFocus:e9,onKeyDown:(E8)=>{if(DX(E8,(t8)=>i(t,`${t8}px`)))return;if(E8.key==="Enter")E8.currentTarget.blur()},onBlur:(E8)=>{let t8=E8.currentTarget.value.trim();if(!t8)return;let O9=/[a-z%]/i.test(t8)?t8:`${t8}px`;i(t,O9)}},`${t}:${Z0??""}`)},u9=(t)=>{let q0=O[t],Z0=q0!=null&&q0!==""&&q0!=="auto"?_Q(q0).n||q0:_Q(m9(U[t])??"").n||"",R0=!q0||q0==="auto"||q0==="0"||q0==="0px",u0=t==="top"||t==="bottom"?["top","bottom"]:["left","right"],w8=["top","right","bottom","left"];return K("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${t[0]}${R0?" is-zero":""}`,"aria-label":t,defaultValue:Z0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...a8(t,{sides:{pair:u0,all:w8},min:-1/0}),onFocus:e9,onKeyDown:(L8)=>{if(DX(L8,($8)=>i(t,`${$8}px`)))return;if(L8.key==="Enter")L8.currentTarget.blur()},onBlur:(L8)=>{let $8=L8.currentTarget.value.trim();if(!$8)return;let E8=/[a-z%]/i.test($8)?$8:`${$8}px`;i(t,E8)}},`${t}:${q0??""}`)},l9=Object.entries(M),g9=Object.entries(E),q7=()=>{let t=(X.tag||"").toLowerCase(),Z0=t==="img"||t==="video"||t==="picture"||t==="svg"||t==="canvas"||!!O["object-fit"]||!!O["object-position"]||!!O["aspect-ratio"],R0=(t==="img"||t==="video")&&!!X.attrs?.src&&!!W;return{showMedia:Z0,canReplace:R0}},G7=(t)=>A(W0,{children:[t&&K("div",{className:"st-cp-mediabtn",children:K("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>W(X),children:"Replace…"})}),$0("object-fit",F0("object-fit",sq0)),$0("object-position",V7("object-position")),$0("aspect-ratio",A("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:Ge.includes(O["aspect-ratio"])?O["aspect-ratio"]:"",onChange:(q0)=>{let Z0=q0.target.value;if(i("aspect-ratio",Z0),Z0&&Z0!=="auto"&&O.height)r("height")},children:[K("option",{value:"",disabled:!0,children:m9(U["aspect-ratio"])||"—"}),Ge.map((q0)=>K("option",{value:q0,children:q0},q0))]}))]});return A("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:j0,children:[A("div",{className:"st-cp-id",children:[A("span",{className:"st-cp-idtag",children:[X.tag||"element",X.classes?A("span",{className:"st-cp-idcls",children:[".",X.classes.split(/\s+/)[0]]}):null]}),K("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:K(uw,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:K(h9,{as:r4,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:K(h9,{as:YW,size:12}),label:"Designer — Figma vocabulary"}],onChange:f})})]}),Z==="designer"?A(W0,{children:[H0("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let t=(O.display||m9(U.display)||"").trim();return t==="flex"||t==="inline-flex"?A(W0,{children:[$0("flex-direction",T8("flex-direction",B8),void 0,"Direction"),$0("align-items",K(Tv,{value:t0(),onChange:h8,ariaLabel:"auto-layout alignment"}),g0("align-items"),"Alignment"),$0("gap",Q8("gap","space"),void 0,"Gap"),A("div",{className:"st-cp-modes",children:[n0("width"),n0("height")]}),A("div",{className:"st-cp-box","aria-label":"padding",children:[A("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[r8(g0("padding-top")),"padding"]}),H9("padding-top","padding"),H9("padding-right","padding"),H9("padding-bottom","padding"),H9("padding-left","padding")]}),K("div",{className:"st-cp-clustermore-row",children:k0("Auto layout")}),l["Auto layout"]?$0("flex-wrap",K(FQ,{checked:/^wrap/.test(O["flex-wrap"]||m9(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(Z0)=>i("flex-wrap",Z0?"wrap":"nowrap")}),g0("flex-wrap"),"Wrap"):null]}):K("button",{type:"button",className:"st-cp-makeflex",disabled:!z,onClick:()=>i("display","flex"),children:"+ Auto layout (flex)"})})()),H0("Size",["width","height","min-width","max-width","min-height","max-height"],A(W0,{children:[$0("width",Y9("width"),void 0,"Width"),$0("height",Y9("height"),void 0,"Height"),K("div",{className:"st-cp-clustermore-row",children:k0("Size")}),l.Size?A(W0,{children:[$0("min-width",Y9("min-width"),void 0,"Min width"),$0("max-width",Y9("max-width"),void 0,"Max width"),$0("min-height",Y9("min-height"),void 0,"Min height"),$0("max-height",Y9("max-height"),void 0,"Max height")]}):null]})),H0("Position",["position","top","right","bottom","left","z-index"],A(W0,{children:[$0("position",F0("position",Je),void 0,"Position"),A("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[A("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[r8(g0("top")),"inset"]}),u9("top"),u9("right"),u9("bottom"),u9("left"),K("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:O.position||m9(U.position)||"static"})]}),(O.position||m9(U.position)||"static")==="static"?K("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,K("div",{className:"st-cp-clustermore-row",children:k0("Position")}),l.Position?$0("z-index",Y9("z-index"),void 0,"Layer order"):null]}),!1),H0("Fill",["background-color"],$0("background-color",W7("background-color"),void 0,"Fill")),H0("Stroke",["border-width","border-style","border-color"],$0("border",P0(),g0("border-width"),"Stroke")),H0("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],$0("border-radius",R8(),g0("border-radius"),"Corner radius")),H0("Effects",["box-shadow","filter","mix-blend-mode"],A(W0,{children:[$0("box-shadow",W6("box-shadow","shadow")||V7("box-shadow"),void 0,"Shadow"),$0("filter",a0(),g0("filter"),"Blur"),$0("mix-blend-mode",F0("mix-blend-mode",We),void 0,"Blend")]})),H0("Opacity",["opacity"],$0("opacity",N0(),void 0,"Opacity")),H0("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],A(W0,{children:[$0("font-family",F0("font-family",st),void 0,"Font"),$0("color",W7("color"),void 0,"Color"),$0("font-size",Q8("font-size","type"),void 0,"Size"),$0("font-weight",F0("font-weight",at),void 0,"Weight"),$0("line-height",Y9("line-height","lh"),void 0,"Line height"),$0("text-align",T8("text-align",Y7),void 0,"Align"),K("div",{className:"st-cp-clustermore-row",children:k0("Text")}),l.Text?A(W0,{children:[$0("letter-spacing",Y9("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),$0("font-style",F0("font-style",aq0),void 0,"Style"),$0("text-transform",F0("text-transform",Qe),void 0,"Case"),$0("white-space",F0("white-space",Ye),void 0,"Whitespace")]}):null]})),H0("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],A("div",{className:"st-cp-box","aria-label":"margin",children:[A("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[r8(g0("margin-top")),"margin"]}),H9("margin-top","margin"),H9("margin-right","margin"),H9("margin-bottom","margin"),H9("margin-left","margin")]})),(()=>{let{showMedia:t,canReplace:q0}=q7();return t?H0("Media",["object-fit","object-position","aspect-ratio"],G7(q0)):null})()]}):A(W0,{children:[Z8("Layout",(()=>{let t=(O.display||m9(U.display)||"").trim(),q0=t==="flex"||t==="inline-flex",Z0=t==="grid"||t==="inline-grid";return A(W0,{children:[$0("display",F0("display",nq0)),q0?A(W0,{children:[$0("flex-direction",T8("flex-direction",B8)),$0("flex-wrap",K(FQ,{checked:/^wrap/.test(O["flex-wrap"]||m9(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(R0)=>i("flex-wrap",R0?"wrap":"nowrap")}),g0("flex-wrap"))]}):null,q0||Z0?A(W0,{children:[$0("align-items",T8("align-items",Q9)),$0("justify-content",T8("justify-content",i8)),$0("gap",Q8("gap","space"))]}):K("button",{type:"button",className:"st-cp-makeflex",disabled:!z,onClick:()=>i("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let t=(O.display||m9(U.display)||"").trim();if(!(t==="grid"||t==="inline-grid"))return null;let Z0=O["grid-template-columns"]||"",R0=O["grid-template-rows"]||"",u0=rD(Z0),w8=rD(R0),L8=u0.length>0||!Z0.trim(),$8=w8.length>0||!R0.trim();return Z8("Grid",A(W0,{children:[L8?K(He,{label:"Columns",tracks:u0,editable:z,onChange:(E8)=>i("grid-template-columns",aD(E8))}):A("div",{className:"st-cp-note",children:["Columns use ",K("code",{children:Z0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),$8?K(He,{label:"Rows",tracks:w8,editable:z,onChange:(E8)=>i("grid-template-rows",aD(E8))}):A("div",{className:"st-cp-note",children:["Rows use ",K("code",{children:R0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),Z8("Position",A(W0,{children:[$0("position",F0("position",Je)),A("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[A("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[r8(g0("top")),"inset"]}),u9("top"),u9("right"),u9("bottom"),u9("left"),K("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:O.position||m9(U.position)||"static"})]}),(O.position||m9(U.position)||"static")==="static"?K("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,$0("z-index",Y9("z-index"))]})),(X.parentDisplay==="grid"||X.parentDisplay==="inline-grid")&&Z8("Grid item",A(W0,{children:[A("div",{className:"st-cp-note",children:["Manual cell placement — ",K("code",{children:"start / end"})," or ",K("code",{children:"start / span N"}),"."]}),$0("grid-column",V7("grid-column")),$0("grid-row",V7("grid-row"))]})),Z8("Typography",A(W0,{children:[$0("font-family",F0("font-family",st)),$0("color",W7("color")),$0("font-size",Q8("font-size","type")),$0("font-weight",F0("font-weight",at)),$0("line-height",Y9("line-height","lh")),$0("letter-spacing",Y9("letter-spacing",null,{min:-1/0})),$0("text-align",T8("text-align",Y7)),$0("font-style",m0(),g0("font-style")),$0("text-transform",F0("text-transform",Qe)),$0("white-space",F0("white-space",Ye))]})),Z8("Spacing",K(W0,{children:A("div",{className:"st-cp-box","aria-label":"margin and padding",children:[A("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[r8(g0("margin-top")),"margin"]}),H9("margin-top","margin"),H9("margin-right","margin"),H9("margin-bottom","margin"),H9("margin-left","margin"),A("div",{className:"st-cp-boxpad",children:[A("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[r8(g0("padding-top")),"padding"]}),H9("padding-top","padding"),H9("padding-right","padding"),H9("padding-bottom","padding"),H9("padding-left","padding"),A("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(O.width)||X.bounds?.w||0)," × ",Math.round(Number.parseFloat(O.height)||X.bounds?.h||0)]})]})]})})),Z8("Size",A(W0,{children:[A("div",{className:"st-cp-modes",children:[n0("width"),n0("height")]}),$0("width",Y9("width")),$0("height",Y9("height")),$0("min-width",Y9("min-width")),$0("max-width",Y9("max-width")),$0("min-height",Y9("min-height")),$0("max-height",Y9("max-height")),$0("overflow",T8("overflow",Z9)),W8?A(W0,{children:[K("div",{className:"st-cp-subhd",children:"In flex parent"}),$0("align-self",F0("align-self",rq0)),$0("flex-grow",Y9("flex-grow",null,{unitless:!0})),$0("flex-shrink",Y9("flex-shrink",null,{unitless:!0})),$0("flex-basis",Y9("flex-basis"))]}):null]})),(()=>{let{showMedia:t,canReplace:q0}=q7();return t?Z8("Media",G7(q0)):null})(),Z8("Appearance",A(W0,{children:[$0("background-color",W7("background-color")),$0("border-radius",R8(),g0("border-radius")),$0("border",P0(),g0("border-width")),$0("box-shadow",W6("box-shadow","shadow")||V7("box-shadow")),$0("filter",a0(),g0("filter")),$0("mix-blend-mode",F0("mix-blend-mode",We)),$0("opacity",N0()),$0("rotation",w0(),g0("transform")),$0("transform",V7("transform")),$0("transform-origin",V7("transform-origin"))]})),(()=>{let t=Object.entries($).find(([,q0])=>typeof q0==="string"&&q0.startsWith("err:"));return t?A("div",{className:"st-cp-save is-err",role:"status",children:[K(G9,{name:"x",size:12}),t[0],": ",t[1].slice(4)]}):null})(),Z8("Advanced",A("div",{className:"st-cp-advbody",children:[l9.length?A(W0,{children:[K("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),l9.map(([t,q0])=>A("div",{className:"st-cp-kv",children:[K("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`custom property ${t} name`}),K("input",{className:"st-cp-fin",defaultValue:q0,"aria-label":`${t} value`,onKeyDown:(Z0)=>{if(Z0.key==="Enter")Z0.currentTarget.blur()},onBlur:(Z0)=>K0(t,Z0.currentTarget.value)},`cs:${t}:${q0}`),K("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>n(t),children:K(G9,{name:"x",size:11})})]},`cs:${t}`))]}):null,K("div",{className:"st-cp-advgrp",children:"Add CSS property"}),K(X30,{commit:K0}),K("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),g9.length?A(W0,{children:[K("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),g9.map(([t,q0])=>A("div",{className:"st-cp-kv",children:[K("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`attribute ${t} name`}),K("input",{className:"st-cp-fin",defaultValue:q0,"aria-label":`${t} value`,onKeyDown:(Z0)=>{if(Z0.key==="Enter")Z0.currentTarget.blur()},onBlur:(Z0)=>e(t,Z0.currentTarget.value)},`at:${t}:${q0}`),K("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>U0(t),children:K(G9,{name:"x",size:11})})]},`at:${t}`))]}):null,K("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),K(J30,{commit:e})]}))]}),A("div",{className:"st-cp-legend",children:[A("span",{children:[K("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),A("span",{children:[K("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),A("span",{children:[K("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},X.id)}function X30({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return A("div",{className:"st-cp-kv",children:[K("input",{className:"st-cp-fin","aria-label":"custom property name",placeholder:"property",value:J,onChange:(Z)=>Q(Z.target.value)}),K("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 J30({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return A("div",{className:"st-cp-kv",children:[K("input",{className:"st-cp-fin","aria-label":"custom attribute name",placeholder:"data-…",value:J,onChange:(Z)=>Q(Z.target.value)}),K("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 Q30={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function Y30(X,J,Q,Y){if(!Array.isArray(X)||J===Q)return X;let W=JSON.parse(JSON.stringify(X)),G=null,Z=(z)=>{for(let U=0;U<z.length;U++){if(z[U].id===J)return G=z[U],z.splice(U,1),!0;if(z[U].children&&Z(z[U].children))return!0}return!1};if(Z(W),!G)return X;let H=(z)=>{for(let U=0;U<z.length;U++){if(z[U].id===Q){if(Y==="inside-start"||Y==="inside-end")if(z[U].children=z[U].children||[],Y==="inside-start")z[U].children.unshift(G);else z[U].children.push(G);else z.splice(Y==="before"?U:U+1,0,G);return!0}if(z[U].children&&H(z[U].children))return!0}return!1};return H(W)?W:X}var W30=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function Oe({node:X,depth:J,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:z,onToggleVisibility:U,onReorder:q,onRowPointerDown:B,dragState:F,componentMap:O,lockedKeys:M,onToggleLock:E,onRename:I}){let P=`${X.id}:${X.index}`,w=X.children&&X.children.length>0,R=W.has(P),T=!!X.synthetic,C=!T&&O?O[X.id]:null,b=!T&&!!M?.has(P),[$,y]=u.useState(!1),[v,g]=u.useState(""),m=!T&&X.id===Q&&(Y==null||X.index===Y),c=G?.has(P)?G.get(P):!!X.hidden,f=!!q&&!T&&!b,l=()=>{y(!1);let s=v.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!s||s===(X.dcElement??""))return;I?.(X,s)},p=F?.key===P,h=p?{transform:`translate(${F.dx}px, ${F.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 A(W0,{children:[A("div",{className:"st-layer st-layer--row"+(m?" is-sel":"")+(c?" is-hidden":"")+(T?" is-group":"")+(C?" is-instance":"")+(b?" is-locked":""),style:{paddingLeft:6+J*14,...h},role:"treeitem","aria-selected":T?void 0:m,"aria-expanded":w?!R:void 0,"aria-grabbed":f?p:void 0,tabIndex:0,title:T?`${X.tag} · group (unstamped wrapper)`:`${X.tag} · ${X.type}${I?" · F2 to rename":""}`,"data-layer-key":P,onClick:()=>T?w&&Z(P):H(X),onMouseEnter:()=>!T&&z(X),onMouseLeave:()=>z(null),onPointerDown:f?(s)=>B(s,X,P):void 0,onKeyDown:(s)=>{if(s.key==="Enter"||s.key===" ")if(s.preventDefault(),T)w&&Z(P);else H(X);else if(s.key==="F2"&&I&&!T)s.preventDefault(),g(X.dcElement||X.label||""),y(!0)},children:[w?K("button",{type:"button",className:"st-layer-caret","aria-label":R?"Expand":"Collapse",onClick:(s)=>{s.stopPropagation(),Z(P)},children:R?"▸":"▾"}):K("span",{className:"st-layer-caret","aria-hidden":"true"}),C?K("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:C.root?"◆":"◇"}):K(G9,{name:Q30[X.type]||"box",size:12,className:"st-layer-ticon"}),$?K("input",{className:"st-layer-rename",value:v,autoFocus:!0,"aria-label":`Rename ${X.label}`,onFocus:(s)=>s.target.select(),onChange:(s)=>g(s.target.value),onClick:(s)=>s.stopPropagation(),onPointerDown:(s)=>s.stopPropagation(),onBlur:l,onKeyDown:(s)=>{if(s.stopPropagation(),s.key==="Enter")l();else if(s.key==="Escape")y(!1)}}):K("span",{className:"st-layer-label",onDoubleClick:I&&!T?(s)=>{s.stopPropagation(),g(X.dcElement||X.label||""),y(!0)}:void 0,children:X.label}),K("span",{className:"st-layer-type",children:C?C.component:X.type}),E&&!T?K("button",{type:"button",className:"st-layer-lock","aria-label":b?`Unlock ${X.label}`:`Lock ${X.label}`,"aria-pressed":b,title:b?"Unlock":"Lock",onClick:(s)=>{s.stopPropagation(),E(P)},children:K(G9,{name:b?"lock":"unlock",size:12})}):null,U&&!T?K("button",{type:"button",className:"st-layer-eye","aria-label":c?`Show ${X.label}`:`Hide ${X.label}`,"aria-pressed":c,title:c?"Show":"Hide",onClick:(s)=>{s.stopPropagation(),U(X)},children:K(G9,{name:c?"eye-off":"eye",size:13})}):null]}),w&&!R?X.children.map((s,a)=>K(Oe,{node:s,depth:J+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:z,onToggleVisibility:U,onReorder:q,onRowPointerDown:B,dragState:F,componentMap:O,lockedKeys:M,onToggleLock:E,onRename:I},`${s.id}:${s.index}`)):null]})}function G30({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 A("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:U}),A("div",{className:"st-swatch-row",children:[K("span",{className:"st-insp-swatch",style:{background:B},"aria-hidden":"true"}),K("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?_Q(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 A(W0,{children:[G?A("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Radius"}),A("div",{className:"st-insp-fields",children:[A("span",{className:"st-fmini",style:{flex:"0 0 auto",maxWidth:84},children:[K("span",{className:"st-mtag",children:"r"}),K("input",{value:Z,readOnly:!0,"aria-label":"border radius"})]}),K("span",{className:"st-insp-unit",children:"px"})]})]}):null,W("Fill","background-color"),W("Text","color"),H?A("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Font"}),K("div",{className:"st-insp-fields",children:K("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:H})})]}):null]})}function Me(X){if(X.artboardId)return X.artboardId;let J=/^\[data-dc-screen="([^"]+)"\]$/.exec(X.selector||"");return J?J[1]:null}var Z30=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],H30=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function z30({el:X,cfg:J,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let z=Me(X),U=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),q=Fe(X.file,J),B=Le(J,U,q),F=(p)=>B.map((h)=>({ds:h.name,names:h[p]||[],vals:h.vals})).filter((h)=>h.names.length),O=(p)=>F(p).flatMap((h)=>(h.names||[]).map((s)=>({name:s,value:h.vals?.[s]||""}))),M=(p)=>{let h=/^var\(\s*(--[\w-]+)\s*\)$/.exec(p||"");if(!h)return p||"";for(let s of B){let a=s.vals?.[h[1]];if(a)return a}return""},E=Number.isFinite(X.worldW)?X.worldW:Number.isFinite(X.bounds?.w)?X.bounds.w:null,I=Number.isFinite(X.worldH)?X.worldH:Number.isFinite(X.bounds?.h)?X.bounds.h:null,P=(p,h)=>{if(!z)return;let s=Number.isFinite(p)&&p>0?Math.round(p):void 0,a=Number.isFinite(h)&&h>0?Math.round(h):void 0;if(s==null&&a==null)return;Q?.(z,s,a)},w=Object.entries(Z5).find(([,p])=>p.width===E&&p.height===I)?.[0],R=Object.entries(Z5).find(([,p])=>p.width===E)?.[0],T=X.attrs?.["data-dc-fixed"]==="true",C=X.attrs?.["data-dc-bg"]??"",b=X.attrs?.["data-dc-padding"]??"",$=X.attrs?.["data-dc-layout"]??"",y=X.attrs?.["data-dc-gap"]??"",v=X.attrs?.["data-dc-kind"]||"digital",g=null;try{g=X.attrs?.["data-dc-print"]?JSON.parse(X.attrs["data-dc-print"]):null}catch{}let m=(p)=>{if(!z)return;let h=null;if(p==="print"&&!g){let s={paper:"a4"};try{let a=m3(s);if(a)h={defaults:s,widthPx:a.widthPx,heightPx:a.heightPx}}catch{}}if(G?.(z,p==="digital"?null:p,h),p==="web"&&T)Y?.(z,!1,void 0)},c=(p)=>{if(!z)return;let h={paper:"a4",...g,...p},s;try{s=m3(h)}catch{return}Q?.(z,s.widthPx,s.heightPx),Z?.(z,h)},f=(p)=>{if(!z)return;let h=p&&Number.isFinite(I)?Math.round(I):void 0;Y?.(z,p,h)},l=(p)=>{if(!z)return;W?.(z,p)};return A("section",{className:"st-cp-sec",children:[K("div",{className:"st-cp-sechd-row",children:K("span",{className:"st-cp-sechd",children:"Artboard"})}),A("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[K(v6,{value:E??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(p)=>P(p,null)}),K(v6,{value:I??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:T,onCommit:(p)=>{if(T)P(null,p)}})]}),K("div",{style:{padding:"0 12px 8px"},children:v==="print"?A("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:g?.paper??"",onChange:(p)=>c({paper:p.currentTarget.value}),children:[K("option",{value:"",disabled:!0,children:"Paper size…"}),g3.map((p)=>A("option",{value:p.id,children:[p.label," — ",p.width,"×",p.height,p.unit]},p.id))]}):v==="web"?A("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:R??"",onChange:(p)=>{let h=Z5[p.currentTarget.value];if(h)P(h.width,null)},children:[K("option",{value:"",disabled:!0,children:R?`${Z5[R].label} — ≤ ${Z5[R].width}px`:"Breakpoint…"}),Object.entries(Z5).map(([p,h])=>A("option",{value:p,children:[h.label," — ≤ ",h.width,"px breakpoint"]},p))]}):A("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:w??"",onChange:(p)=>{let h=Z5[p.currentTarget.value];if(h)P(h.width,h.height)},children:[K("option",{value:"",disabled:!0,children:w?Z5[w].label:"Preset size…"}),Object.entries(Z5).map(([p,h])=>A("option",{value:p,children:[h.label," — ",h.width,"×",h.height]},p))]})}),K("div",{style:{padding:"0 12px 8px"},children:K(AB,{value:T?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(p)=>f(p==="fixed")})}),K("div",{className:"st-cp-sechd-row",children:K("span",{className:"st-cp-sechd",children:"Kind"})}),K("div",{style:{padding:"0 12px 8px"},children:K(ZW,{value:v,ariaLabel:"artboard kind",options:H30.map(([p,h])=>({value:p,label:h})),onChange:m})}),v!=="print"&&z&&H?K("div",{style:{padding:"0 12px 8px"},children:A("select",{className:"st-cp-nsel","aria-label":"duplicate artboard at breakpoint width",value:"",onChange:(p)=>{let h=Z5[p.currentTarget.value];if(h)H(z,h.width);p.currentTarget.value=""},children:[K("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(Z5).map(([p,h])=>A("option",{value:p,children:[h.label," — ",h.width,"px"]},p))]})}):null,v==="print"?A(W0,{children:[K("div",{className:"st-cp-sechd-row",children:K("span",{className:"st-cp-sechd",children:"Print"})}),K("div",{style:{padding:"0 12px 8px"},children:K(AB,{value:g?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(p)=>c({orientation:p})})}),K("div",{style:{padding:"0 12px 8px"},children:K(v6,{value:Number.isFinite(g?.bleedMm)?g.bleedMm:3,min:0,step:0.5,ariaLabel:"bleed, millimeters",lead:"B",steppers:!1,unitSlot:K("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"mm"}),onCommit:(p)=>c({bleedMm:p})})})]}):null,K("div",{className:"st-cp-sechd-row",children:K("span",{className:"st-cp-sechd",children:"Style"})}),A("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let p=M(C),h=/var\(\s*--/.test(C),s=h?C.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):C;return K(XV,{swatch:K(mN,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:F("color"),current:C,activeDs:q,swatchBg:p,seedHex:pN(p)||"#000000",onPick:(a)=>l({background:a||null}),label:"artboard background colour"}),displayValue:s,bound:h,ariaLabel:"artboard background",onValue:(a)=>l({background:(a||"").trim()||null})})})(),K(ZW,{value:$,ariaLabel:"artboard body layout",options:Z30.map(([p,h])=>({value:p,label:h})),onChange:(p)=>l({layout:p||null})}),A("div",{style:{display:"flex",gap:8},children:[K(EB,{value:/^var\(/.test(b)?b:Number.parseFloat(b)||0,tokens:O("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(p)=>l({padding:typeof p==="string"?p:p>0?p:null})}),K(EB,{value:/^var\(/.test(y)?y:Number.parseFloat(y)||0,tokens:O("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(p)=>l({gap:typeof p==="string"?p:p>0?p:null})})]})]})]})}var zR=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,K30=new RegExp(zR.source,"gi");function U30(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(K30)||[])],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=zR.exec(`${X.attrs?.src||""} ${J}`);return Y?Y[0]:null}function V30({selected:X,onClose:J,layersTree:Q,componentMap:Y,lockedKeys:W,onToggleLock:G,onDetachInstance:Z,canvasFile:H,onSelectLayer:z,onHoverLayer:U,onReorderLayer:q,layersBusyRef:B,cfg:F,onOptimistic:O,onRecordEdit:M,onReplaceMedia:E,onResizeArtboard:I,onSetArtboardHug:P,onSetArtboardStyle:w,onSetArtboardKind:R,onSetArtboardPrint:T,onDuplicateArtboard:C,onUndoRedo:b,editScope:$,tab:y,onTabChange:v,width:g,resizing:m,photoSel:c,photoRev:f,onPhotoEdit:l,onPhotoRemoveBackground:p,onPhotoRecordEdit:h,onPhotoUndoRedo:s,layersOnly:a=!1,hideLayersTab:i=!1,cpMode:K0,onSetCpMode:e}){let[r,n]=u.useState("inspect"),U0=a?"layers":y??r,f0=(P0)=>{n(P0),v?.(P0)},[J8,W8]=u.useState(()=>new Set),[n0,M0]=u.useState(()=>new Map);u.useEffect(()=>{let P0=Array.isArray(X)?X[0]:X,w0=P0?.id;if(!w0||!Q?.nodes)return;let a0=P0.index,N0=null,m0=[];if(function B8(i8,Q9){for(let Y7 of i8||[]){let Z9=`${Y7.id}:${Y7.index}`;if(!Y7.synthetic&&Y7.id===w0&&(a0==null||Y7.index===a0))return N0=Z9,m0.push(...Q9),!0;if(Y7.children&&Y7.children.length&&B8(Y7.children,[...Q9,Z9]))return!0}return!1}(Q.nodes,[]),!N0)return;if(m0.length)W8((B8)=>{let i8=!1,Q9=new Set(B8);for(let Y7 of m0)if(Q9.delete(Y7))i8=!0;return i8?Q9:B8});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${N0}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[X,Q]);let c0=(P0)=>{let w0=`${P0.id}:${P0.index}`;return n0.has(w0)?n0.get(w0):!!P0.hidden},[e0,C8]=u.useState(null),[t0,h8]=u.useState(""),j0=(P0,w0)=>{if(!H||!P0?.id)return;fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:H,id:P0.id,attr:"data-dc-element",value:w0})}).then((a0)=>a0.json().catch(()=>({}))).then((a0)=>{if(!a0.ok)return;M?.({op:"attr",canvas:H,id:P0.id,key:"data-dc-element",before:P0.dcElement??null,after:w0})}).catch(()=>{})},g0=q?(P0,w0,a0)=>{if(B?.current)return;if(P0?.synthetic||w0?.synthetic)return;let N0=a0==="before"?`before ${w0.label}`:a0==="after"?`after ${w0.label}`:`into ${w0.label}`;h8(`Moved ${P0.label} ${N0}`),q(P0.id,w0.id,a0,{idIndex:P0.index,refIndex:w0.index})}:void 0,A8=()=>{let P0=[];return function w0(a0,N0,m0){(a0||[]).forEach((B8,i8)=>{if(P0.push({node:B8,depth:N0,parentNode:m0,siblings:a0,pos:i8}),B8.children&&B8.children.length&&!J8.has(`${B8.id}:${B8.index}`))w0(B8.children,N0+1,B8)})}(Q?.nodes,0,null),P0},r8=(P0)=>{if(P0.key!=="ArrowUp"&&P0.key!=="ArrowDown")return;if(!H0)return;let w0=A8(),a0=w0.findIndex((i8)=>i8.node.id===H0.id&&i8.node.index===H0.index);if(a0<0)return;let N0=P0.key==="ArrowDown"?1:-1,m0=w0[a0];if(!P0.altKey){let i8=w0[a0+N0];if(i8)P0.preventDefault(),z?.(i8.node);return}if(!g0||!Array.isArray(m0.siblings))return;P0.preventDefault();let B8=(i8)=>i8&&i8.children&&i8.children.length&&!J8.has(`${i8.id}:${i8.index}`);if(!P0.shiftKey){if(N0<0&&m0.pos>0)g0(m0.node,m0.siblings[m0.pos-1],"before");else if(N0>0&&m0.pos<m0.siblings.length-1)g0(m0.node,m0.siblings[m0.pos+1],"after");return}if(N0>0){let i8=m0.siblings[m0.pos+1];if(i8)g0(m0.node,i8,B8(i8)?"inside-start":"after");else if(m0.parentNode)g0(m0.node,m0.parentNode,"after")}else{let i8=m0.siblings[m0.pos-1];if(i8)g0(m0.node,i8,B8(i8)?"inside-end":"before");else if(m0.parentNode)g0(m0.node,m0.parentNode,"before")}},R9=u.useRef(null),$0=u.useRef(null),V9=(P0,w0,a0)=>{if(!g0||P0.button!==0||P0.metaKey||P0.ctrlKey||P0.shiftKey||P0.altKey)return;if(B?.current)return;let{clientX:N0,clientY:m0}=P0,B8=new Set([a0]);(function a8(H9){(H9.children||[]).forEach((u9)=>{B8.add(`${u9.id}:${u9.index}`),a8(u9)})})(w0);let i8=14,Q9=6,Y7=[];(function a8(H9,u9){(H9||[]).forEach((l9)=>{let g9=`${l9.id}:${l9.index}`;if(Y7.push({node:l9,key:g9,id:l9.id,depth:u9,tag:l9.tag}),l9.children&&l9.children.length&&!J8.has(g9))a8(l9.children,u9+1)})})(Q?.nodes,0);let Z9=new Map(Y7.map((a8)=>[a8.key,a8])),W6=!1,e9=(a8)=>{if(!W6){if(Math.hypot(a8.clientX-N0,a8.clientY-m0)<4)return;W6=!0}let H9=a8.clientX-N0,u9=a8.clientY-m0,l9=null,g9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((G7)=>({rect:G7.getBoundingClientRect(),it:Z9.get(G7.getAttribute("data-layer-key"))})).filter((G7)=>G7.it&&G7.it.key!==a0);if(g9.length){let G7=g9[0].rect.left,t=g9[0].rect.right,q0=g9.length;for(let M9=0;M9<g9.length;M9++)if(a8.clientY<g9[M9].rect.top+g9[M9].rect.height/2){q0=M9;break}let Z0=g9[q0-1]?.it||null,R0=g9[q0]?.it||null,u0=Math.round((a8.clientX-G7-Q9)/i8),w8=Z0?Z0.depth+(W30.has(Z0.tag)?0:1):0,L8=R0?R0.depth:0,$8=Math.max(L8,Math.min(u0,w8)),E8=null,t8="before",O9=0;if(!Z0){if(R0)E8=R0,t8="before",O9=R0.depth}else if($8>Z0.depth)E8=Z0,t8="inside-start",O9=Z0.depth+1;else if($8===Z0.depth)E8=Z0,t8="after",O9=Z0.depth;else{for(let M9=q0-1;M9>=0;M9--)if(g9[M9].it.depth===$8){E8=g9[M9].it;break}if(!E8)E8=Z0;t8="after",O9=$8}if(E8&&E8.key!==a0&&!B8.has(E8.key)){let M9=Z0?g9[q0-1].rect.bottom:g9[0].rect.top,OX=G7+Q9+O9*i8;l9={refId:E8.id,position:t8,node:E8.node,y:M9,left:OX,w:Math.max(24,t-OX)}}}let q7={key:a0,node:w0,dx:H9,dy:u9,target:l9};R9.current=q7,C8(q7)},DX=()=>{window.removeEventListener("pointermove",e9),window.removeEventListener("pointerup",Y9),window.removeEventListener("keydown",W7,!0)},V7=()=>{let a8=(H9)=>{H9.preventDefault(),H9.stopImmediatePropagation(),document.removeEventListener("click",a8,!0)};document.addEventListener("click",a8,!0),setTimeout(()=>document.removeEventListener("click",a8,!0),300)},Y9=()=>{DX();let a8=R9.current;if(R9.current=null,C8(null),W6&&a8?.target)V7(),g0(a8.node,a8.target.node,a8.target.position)},W7=(a8)=>{if(a8.key!=="Escape")return;if(a8.preventDefault(),a8.stopImmediatePropagation(),DX(),R9.current=null,C8(null),W6)V7()};window.addEventListener("pointermove",e9),window.addEventListener("pointerup",Y9),window.addEventListener("keydown",W7,!0)},I0=(P0)=>W8((w0)=>{let a0=new Set(w0);if(a0.has(P0))a0.delete(P0);else a0.add(P0);return a0}),Z8=(P0)=>{let w0=`${P0.id}:${P0.index}`,a0=c0(P0),N0=!a0;if(M0((m0)=>new Map(m0).set(w0,N0)),O?.({id:P0.id,artboardId:Q?.artboardId??null,index:P0.index,prop:"display",value:N0?"none":null}),!H||!P0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(N0?{canvas:H,id:P0.id,property:"display",value:"none"}:{canvas:H,id:P0.id,property:"display",reset:!0})}).catch(()=>{}),M?.({op:"css",canvas:H,id:P0.id,key:"display",before:a0?"none":null,after:N0?"none":null})},H0=Array.isArray(X)?X[0]:X,k0=c?{asset:c.asset,kind:"annotation-image"}:(()=>{let P0=U30(H0);return P0?{asset:P0,kind:"artboard-img"}:null})(),F0=k0?.kind==="annotation-image",G8=(P0)=>{if(!(P0.metaKey||P0.ctrlKey)||P0.altKey)return;let w0=P0.key.toLowerCase();if(w0==="z")P0.preventDefault(),s?.(P0.shiftKey?"redo":"undo");else if(w0==="y")P0.preventDefault(),s?.("redo")},T8=F0?"photo":U0==="photo"&&!k0?"inspect":U0,Q8=(P0,w0,a0)=>A("button",{type:"button",className:"st-rp-tab"+(T8===P0?" is-active":""),onClick:()=>f0(P0),children:[K(G9,{name:a0,size:14}),w0]}),R8=H0?.bounds||null;return A("aside",{className:"st-rpanel"+(m?" is-resizing":""),style:g?{width:g,flexBasis:g}:void 0,"aria-label":"Inspector","data-tour":"inspector",children:[A("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:a?{display:"none"}:void 0,children:[F0?Q8("photo","Photo","image"):A(W0,{children:[Q8("inspect","Inspect","sliders"),!i&&Q8("layers","Layers","layers"),Q8("css","CSS","code"),k0?Q8("photo","Photo","image"):null]}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:J,children:K(G9,{name:"x",size:14})})]}),H0?.id&&!(Array.isArray(X)&&X.length>1)&&$?A("div",{className:`st-scope st-scope--${$.scope}`,title:$.scope==="shared"?`Editing this element's style changes ${$.affects} place${$.affects===1?"":"s"}${$.componentName?` (component ${$.componentName})`:""}. Move/resize a whole instance to keep it local.`:"This edit affects only this element.",children:[K("span",{className:"st-scope-dot","aria-hidden":"true"}),$.scope==="shared"?`Shared${$.componentName?` · ${$.componentName}`:""} · edits ${$.affects} place${$.affects===1?"":"s"}`:"Local · this element only",$.scope==="shared"&&Z?K("button",{type:"button",className:"st-scope-detach",title:"Clone this component for this instance only — edits stop affecting the other places",onClick:()=>Z(H0.id,H0.index),children:"Detach"}):null]}):null,K("div",{className:"st-rp-body",children:T8==="photo"&&k0?K("div",{onKeyDown:G8,children:K(tv,{asset:k0.asset,ColorPicker:De,StIcon:G9,onEdit:(P0)=>l?.(k0.asset,P0),onRemoveBackground:p,onRecordEdit:(P0,w0)=>h?.(k0.asset,P0,w0)},`${k0.asset}:${f??0}`)}):!H0&&!(T8==="layers"&&Q?.nodes?.length)?K("div",{className:"st-rp-empty",children:A("p",{children:["Press ",K(t6,{children:"V"}),", then click an element to select it — or ",K(t6,{children:"⌘"}),"-click straight from Browse."]})}):H0&&T8==="inspect"?A(W0,{children:[K("div",{className:"st-rp-hd",children:H0.selector||H0.tag||"element"}),A("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Pos"}),A("div",{className:"st-insp-fields",children:[A("span",{className:"st-fmini",children:[K("span",{className:"st-mtag",children:"X"}),K("input",{value:R8?Math.round(R8.x):"—",readOnly:!0,"aria-label":"x position"})]}),A("span",{className:"st-fmini",children:[K("span",{className:"st-mtag",children:"Y"}),K("input",{value:R8?Math.round(R8.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),A("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Size"}),A("div",{className:"st-insp-fields",children:[A("span",{className:"st-fmini",children:[K("span",{className:"st-mtag",children:"W"}),K("input",{value:R8?Math.round(R8.w):"—",readOnly:!0,"aria-label":"width"})]}),A("span",{className:"st-fmini",children:[K("span",{className:"st-mtag",children:"H"}),K("input",{value:R8?Math.round(R8.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),A("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Tag"}),K("div",{className:"st-insp-fields",children:K("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:H0.tag||"—"})})]}),H0.classes?A("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Class"}),K("div",{className:"st-insp-fields",children:K("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:H0.classes})})]}):null,K(G30,{el:H0})]}):T8==="layers"?A(W0,{children:[A("div",{className:"st-rp-hd",children:["Layers",Q?.nodes?.length?"":" · ancestry"]}),Q?.nodes?.length?A(W0,{children:[g0?K("div",{className:"st-rp-hint","aria-hidden":"true",children:"Drag or ↑/↓ select · Alt+↑/↓ move · Alt+Shift+↑/↓ move across"}):null,K("div",{role:"tree","aria-label":"Artboard layers",tabIndex:0,ref:$0,onKeyDown:r8,children:Q.nodes.map((P0,w0)=>K(Oe,{node:P0,depth:0,selectedId:H0?.id,selectedIndex:H0?.index,collapsed:J8,hiddenOverride:n0,onToggle:I0,onSelect:(a0)=>{z?.(a0),$0.current?.focus()},onHover:(a0)=>U?.(a0),onToggleVisibility:Z8,onReorder:g0,onRowPointerDown:V9,dragState:e0,componentMap:Y,lockedKeys:W,onToggleLock:G,onRename:j0},`${P0.id}:${P0.index}`))}),e0?.target?K("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:e0.target.left,top:e0.target.y-1,width:e0.target.w}}):null,K("div",{className:"sr-only",role:"status","aria-live":"polite",children:t0})]}):H0&&Array.isArray(H0.dom_path)&&H0.dom_path.length?H0.dom_path.map((P0,w0)=>A("div",{className:"st-layer"+(w0===H0.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+w0*12},children:[K(G9,{name:"square",size:13}),P0]},w0)):K("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!H0.id&&Me(H0)?K(z30,{el:H0,cfg:F,onResizeArtboard:I,onSetArtboardHug:P,onSetArtboardStyle:w,onSetArtboardKind:R,onSetArtboardPrint:T,onDuplicateArtboard:C}):K(eq0,{el:H0,cfg:F,onOptimistic:O,onRecordEdit:M,onReplaceMedia:E,onUndoRedo:b,mode:K0,onSetMode:e})})]})}function q30(){let[X,J]=u.useState([]),[Q,Y]=u.useState("Design"),[W,G]=u.useState([]),[Z,H]=u.useState(null),[z,U]=u.useState(null),q=u.useRef(null);u.useEffect(()=>{q.current=z},[z]);let[B,F]=u.useState(null);u.useEffect(()=>{let N=Array.isArray(z)?z.length===1?z[0]:null:z,L=N&&typeof N.id==="string"?N.id:null;if(!L||!Z){F(null);return}let _=new AbortController,k=new URLSearchParams({canvas:Z,id:L});return fetch(`/_api/edit-scope?${k}`,{signal:_.signal}).then((S)=>S.ok?S.json():null).then((S)=>{if(S?.ok)F(S)}).catch(()=>{}),()=>_.abort()},[z,Z]);let O=u.useRef(0),M=u.useRef([]),E=u.useCallback((N)=>{if(!N?.id||!N.file)return;for(let L of M.current)clearTimeout(L);M.current=[50,450,1200,2500,5000].map((L)=>setTimeout(()=>{let _=q.current,k=Array.isArray(_)?_[0]:_;if(!k||k.id!==N.id||k.file!==N.file)return;let S=x8.current.get(N.file);if(!S?.contentWindow)return;try{S.contentWindow.postMessage({dgn:"select-by-id",id:N.id,artboardId:N.artboardId??null,index:N.index??0},"*")}catch{}},L))},[]),I=u.useRef([]),P=u.useCallback((N,L)=>{if(!N||!L)return;for(let _ of I.current)clearTimeout(_);I.current=[50,450,1200,2500,5000].map((_)=>setTimeout(()=>{let k=q.current,S=Array.isArray(k)?k[0]:k;if(!S||S.artboardId!==N||S.file!==L)return;let x=x8.current.get(L);if(!x?.contentWindow)return;try{x.contentWindow.postMessage({dgn:"select-by-id",artboardId:N},"*")}catch{}},_))},[]),w=u.useRef(null),R=u.useRef(null),T=u.useRef(null),C=u.useRef(null),b=u.useRef(!1),$=u.useRef(null),[y,v]=u.useState(null),[g,m]=u.useState(null),c=u.useRef({canvas:null,at:0});u.useEffect(()=>{if(!Z||!y)return;let N=Date.now(),L=c.current;if(L.canvas===Z&&N-L.at<1500)return;c.current={canvas:Z,at:N},fetch(`/_api/component-map?canvas=${encodeURIComponent(Z)}`).then((_)=>_.json()).then((_)=>{if(_?.ok&&_.map&&typeof _.map==="object")m(_.map);else m(null)}).catch(()=>m(null))},[Z,y]);let[f,l]=u.useState(!1),[p,h]=u.useState(null),[s,a]=u.useState(null),[i,K0]=u.useState(null),[e,r]=u.useState(null),[n,U0]=u.useState(!1),[f0,J8]=u.useState(null),[W8,n0]=u.useState(""),[M0,c0]=u.useState(null),[e0,C8]=u.useState(null),t0=u.useRef(null),h8=ct("maude-sb-w",{min:200,max:420,def:252}),j0=ct("maude-rp-w",{min:260,max:480,def:304}),[g0,A8]=u.useState(null),r8=u.useRef(null);u.useEffect(()=>{if(!g0)return;let N=(_)=>{let k=r8.current?.getBoundingClientRect();if(!k)return;if(g0==="sb")h8.setW(_.clientX-k.left);else j0.setW(k.right-_.clientX)},L=()=>A8(null);return window.addEventListener("pointermove",N),window.addEventListener("pointerup",L),()=>{window.removeEventListener("pointermove",N),window.removeEventListener("pointerup",L)}},[g0,h8.setW,j0.setW]);let R9=u.useCallback((N)=>{clearTimeout(t0.current),t0.current=setTimeout(()=>{C8((L)=>L===N?null:L)},2500)},[]);u.useEffect(()=>{if(!e0)return;let N=setTimeout(()=>C8(null),15000);return()=>clearTimeout(N)},[e0]);let[$0,V9]=u.useState({designRel:".design"}),I0=!!$0.readOnly,Z8=u.useCallback(()=>{fetch("/_config").then((N)=>N.json()).then((N)=>{let L=(N.designRoot||".design").replace(/^\/+|\/+$/g,"");V9((_)=>({..._,designRel:L,tokensCssRel:N.tokensCssRel,designSystems:N.designSystems,canvasOrigin:N.canvasOrigin,readOnly:!!N.readOnly}))}).catch(()=>{})},[]);u.useEffect(()=>{Z8()},[Z8]),u.useEffect(()=>{let N=!1;return fetch("/_sync-status").then((L)=>L.json()).then((L)=>{if(N||!L||L.linked===!1)return;a(L)}).catch(()=>{}),()=>{N=!0}},[]),u.useEffect(()=>{let N=!1;return fetch("/_api/git/status").then((L)=>L.json()).then((L)=>{if(!N&&L)K0(L)}).catch(()=>{}),()=>{N=!0}},[]);let[H0,k0]=u.useState({}),[F0,G8]=u.useState(null),[T8,Q8]=u.useState(!1),[R8,P0]=u.useState("open"),[w0,a0]=u.useState(Xq0),[N0,m0]=u.useState(()=>{return XR(jt,"advanced")==="designer"?"designer":"advanced"});u.useEffect(()=>{try{localStorage.setItem(jt,JSON.stringify(N0))}catch{}},[N0]);let[B8,i8]=u.useState(null),[Q9,Y7]=u.useState(()=>kZ(yt,!0)),[Z9,W6]=u.useState(()=>kZ(St,!1)),[e9,DX]=u.useState(()=>XR(bt,{})),[V7,Y9]=u.useState(!1),[W7,a8]=u.useState(!1);u.useEffect(()=>{if(!p8())return;let N=Tf(()=>a8(!0));return()=>{N.then((L)=>L()).catch(()=>{})}},[]);let[H9,u9]=u.useState(!1),[l9,g9]=u.useState(!1),[q7,G7]=u.useState(!1),[t,q0]=u.useState(!1),{report:Z0}=vw(p8()),[R0,u0]=u.useState(!1),[w8,L8]=u.useState(!1),[$8,E8]=u.useState(null),[t8,O9]=u.useState(!1),[M9,OX]=u.useState(!1),[gX,H5]=u.useState(!1),[z5,z9]=u.useState(!1),[N6,l5]=u.useState(()=>XR(ht,ez)),[a9,CY]=u.useState(()=>{try{let N=localStorage.getItem(gt);if(N==="separate"||N==="in-inspector")return N}catch{}return"separate"}),[I9,e6]=u.useState(!1),[p9,mX]=u.useState([]),[d9,uX]=u.useState(0),[$Y,L9]=u.useState(!1),[XX,MX]=u.useState(!1),[X7,u6]=u.useState(!1),[$9,c9]=u.useState(1),[K5,U5]=u.useState(216),[G6,lX]=u.useState(null),[wX,SY]=u.useState([]),[EW,EQ]=u.useState([]),[o,Q0]=u.useState([]),[z0,E0]=u.useState(0),B0=u.useMemo(()=>{if(!p9.length)return null;return(p9.find((L)=>L.durationInFrames===z0)??p9[0]).id},[p9,z0]),l0=u.useRef(null);u.useEffect(()=>{l0.current=B0},[B0]);let o0=u.useRef(0);u.useEffect(()=>{o0.current=d9},[d9]);let[_8,l8]=u.useState(null),_X=u.useRef(null);u.useEffect(()=>{_X.current=_8},[_8]);let[pX,O7]=u.useState(null),[AX,bY]=u.useState(0),v7=u.useCallback((N,L)=>{if(/concurrent edit|changed since it was read/i.test(L||""))M8("Timeline changed — reloaded, try again."),bY((_)=>_+1);else M8(`${N}: ${L||"failed"}`)},[]),[JX,V5]=u.useState(!1),[q5,EX]=u.useState(!1),[l6,PX]=u.useState(!1),D8=u.useRef(JX);u.useEffect(()=>{if(D8.current=JX,JX){PX(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[JX]);let d7=u.useCallback(()=>{if(!D8.current||document.hidden)PX(!0),ut("Claude finished","Your assistant turn is ready in Maude.")},[]),M7=u.useRef(0),Z7=u.useCallback(()=>{if(!D8.current||document.hidden){PX(!0);let N=Date.now();if(N-M7.current<tV0)return;M7.current=N,ut("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[S9,AJ]=u.useState("inspect"),[B5,p5]=u.useState(null),EJ=u.useRef({undo:[],redo:[]}),[YK,PQ]=u.useState(0),[PJ,RQ]=u.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),TZ=u.useRef(PJ);u.useEffect(()=>{TZ.current=PJ;try{localStorage.setItem("maude-auto-open-inspector",PJ?"1":"0")}catch{}},[PJ]);let RJ=u.useRef(!1);u.useEffect(()=>{RJ.current=gX||T8||n||JX},[gX,T8,n,JX]);let PW=u.useRef({open:{},side:ez});PW.current={open:{tree:Q9,layers:z5,inspector:gX,comments:T8,changes:n,assistant:JX},side:N6};let IQ=u.useCallback((N,L)=>{if(N==="tree")Y7(L);else if(N==="layers")z9(L);else if(N==="inspector")H5(L);else if(N==="comments")Q8(L);else if(N==="changes")U0(L);else if(N==="assistant")V5(L)},[]),dX=u.useCallback((N)=>PW.current.side?.[N]||ez[N],[]),QX=u.useCallback((N)=>{let L=dX(N);IQ(N,!0);for(let _ of GR)if(_.id!==N&&dX(_.id)===L)IQ(_.id,!1)},[IQ,dX]),cX=u.useCallback((N)=>{if(PW.current.open?.[N])IQ(N,!1);else QX(N)},[QX,IQ]),IJ=QX,I6=cX,RW=u.useCallback((N)=>{if(!TZ.current)return;if(I0)return;if(!N||!N.id)return;if(RJ.current)return;IJ("inspector"),AJ("css")},[IJ,I0]),d5=u.useCallback(()=>e6((N)=>!N),[]),c5=Lx(HR),jY=Qx(),[WK,GK]=u.useState(!1),[CZ,$Z]=u.useState(!1);u.useEffect(()=>{if(!p8())return;let N=!0;return bf().then((L)=>{if(!N)return;if(GK(!!L),!L&&!kZ($t,!1))$Z(!0)}).catch(()=>{}),()=>{N=!1}},[]);let SZ=u.useCallback(()=>{$Z(!1);try{localStorage.setItem($t,"1")}catch{}},[]),[ZK,bZ]=u.useState(null);u.useEffect(()=>{if(!p8())return;let N;return vf((L)=>bZ(L&&typeof L==="object"?L:{})).then((L)=>{N=L}).catch(()=>{}),()=>{try{N?.()}catch{}}},[]);let[i5,jZ]=u.useState(null),[IW,kW]=u.useState(()=>!kZ(Ct,!1)),iX=u.useCallback((N)=>{jZ(Array.isArray(N)&&N.length?N:null)},[]),TW={setup:(N)=>{if(!N)return;if((N.canvas||N.requireSelection)&&W.length===0)QX("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [role="treeitem"]')?.click()}catch{}},80);if(N.inspector||N.tab||N.requireSelection)IJ("inspector");if(N.tab)AJ(N.tab);if(N.changes)IJ("changes")}},CW=u.useCallback(()=>{kW(!1);try{localStorage.setItem(Ct,"1")}catch{}},[]),[o5,yY]=u.useState(()=>kZ(xt,!0)),[fY,oX]=u.useState(!1),[kJ,vY]=u.useState(()=>kZ(ft,!1)),[TJ,yZ]=u.useState(()=>kZ(vt,!1)),[YX,$W]=u.useState(!1),[kQ,n5]=u.useState(!1),[HK,xY]=u.useState(0),[SW,zK]=u.useState(null),[KK,fZ]=u.useState(!1),bW=u.useRef(null),hY=u.useRef(null),x8=u.useRef(new Map),Y8=u.useCallback((N)=>{let L=Z?x8.current.get(Z):null;if(!L||!L.contentWindow)return;try{L.contentWindow.postMessage(N,"*")}catch{}},[Z]),k6=u.useCallback((N,L)=>Y8({dgn:"photo-preview",asset:N,edit:L}),[Y8]),jW=u.useCallback((N,L,_)=>{EJ.current.undo.push({asset:N,before:L,after:_}),EJ.current.redo.length=0},[]),yW=u.useCallback((N)=>{let L=N?EJ.current.redo:EJ.current.undo;if(!L.length)return!1;let _=L.pop();(N?EJ.current.undo:EJ.current.redo).push(_);let k=(N?_.after:_.before)||{};return k6(_.asset,k),fetch(`/_api/photo-edit?asset=${encodeURIComponent(_.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)}).catch(()=>{}),PQ((S)=>S+1),!0},[k6]),UK=u.useCallback(async(N)=>{Y8({dgn:"photo-busy",asset:N,busy:!0});try{let L=await fetch(`/${N.replace(/^\/+/,"")}`);if(!L.ok)return null;let _=await L.blob(),{removeBackground:k}=await Promise.resolve().then(() => (Tt(),kt)),S=await k(_),x=await fetch("/_api/asset",{method:"POST",headers:{"content-type":S.type||"image/png"},body:S}),j=await x.json().catch(()=>({}));if(x.ok&&j.path)return{maskAsset:j.path};return null}catch(L){return console.error("[photo] background removal failed",L),null}finally{Y8({dgn:"photo-busy",asset:N,busy:!1})}},[Y8]);u.useEffect(()=>{let N=(k)=>Array.from(k.dataTransfer?.types??[]).includes("Files"),L=(k)=>{if(N(k))k.preventDefault()},_=(k)=>{if(N(k))k.preventDefault()};return document.addEventListener("dragover",L),document.addEventListener("drop",_),()=>{document.removeEventListener("dragover",L),document.removeEventListener("drop",_)}},[]);let I7=u.useRef({});I7.current={open:I9,comps:p9,frame:d9,total:z0,playing:$Y,compId:B0,muted:X7,loop:XX,sequences:wX,post:Y8,canvas:Z};let nX=u.useRef({undo:[],redo:[]}),x7=u.useCallback((N,L,_)=>{if(typeof L!=="number")return;if(nX.current.undo.push({canvas:N,seq:L,label:_}),nX.current.redo=[],nX.current.undo.length>50)nX.current.undo.shift()},[]),fW=u.useCallback((N)=>{let L=nX.current,_=N==="undo"?L.undo:L.redo,k=N==="undo"?L.redo:L.undo,S=I7.current.canvas,x=-1;for(let d=_.length-1;d>=0;d--)if(_[d].canvas===S){x=d;break}if(x<0){M8(N==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let j=_[x];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:j.canvas,seq:j.seq,dir:N})}).then((d)=>d.json().catch(()=>({}))).then((d)=>{if(_.splice(x,1),d?.ok)k.push(j),M8(`${N==="undo"?"Undid":"Redid"}: ${j.label}`,!0);else M8(`${N==="undo"?"Undo":"Redo"} skipped: ${d?.error||"failed"}`)}).catch(()=>M8(`${N==="undo"?"Undo":"Redo"} failed: network error`))},[]),Z6=u.useCallback((N,L)=>{let _=N?.ok&&Array.isArray(N.clips)?N.clips.filter((k)=>k.kind==="sequence"):[];if(L==null)return null;if(typeof L==="object")return(L.stableId?_.find((k)=>k.stableId===L.stableId):null)||(Number.isInteger(L.index)?_[L.index]:null)||null;if(typeof L==="string")return _.find((k)=>k.stableId===L)||null;return _[L]||null},[]),gY=u.useCallback((N)=>{let L=I7.current.canvas;if(!L||L===S8)return;let _=_X.current||void 0,k=`/_api/comp-clips?canvas=${encodeURIComponent(L)}${_?`&artboardId=${encodeURIComponent(_)}`:""}`;fetch(k).then((S)=>S.json().catch(()=>({}))).then((S)=>{let x=Z6(S,N);if(!x?.stableId)return null;return fetch("/_api/remove-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:L,artboardId:_,stableId:x.stableId,contentHash:x.contentHash})})}).then((S)=>S?S.json():null).then((S)=>{if(S&&!S.ok)console.warn("[remove-clip]",S.error||"failed"),v7("Remove refused",S.error);else if(S?.ok){if(M8("Clip removed.",!0),S.seq!=null)x7(L,S.seq,"remove clip");O7(null)}}).catch(()=>M8("Remove failed: network error"))},[Z6,x7]),r5=u.useCallback((N,L,_)=>{let k=I7.current.canvas;if(!k||k===S8)return;let S=_X.current||void 0,x=`/_api/comp-clips?canvas=${encodeURIComponent(k)}${S?`&artboardId=${encodeURIComponent(S)}`:""}`;fetch(x).then((j)=>j.json().catch(()=>({}))).then((j)=>{let d=j?.ok&&Array.isArray(j.clips)?j.clips:[],X0=N?.transition?d.find((Y0)=>Y0.kind==="transition"&&Y0.stableId===N.stableId)||null:Z6(j,N);if(!X0?.stableId)return null;return fetch("/_api/clip-edit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:k,artboardId:S,stableId:X0.stableId,contentHash:X0.contentHash,verb:L,..._})})}).then((j)=>j?j.json():null).then((j)=>{if(j&&!j.ok)console.warn("[clip-edit]",L,j.error||"failed"),v7(`${L} refused`,j.error);else if(j?.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(M8(`Applied: ${d[L]||L}.`,!0),j.seq!=null)x7(k,j.seq,d[L]||L)}}).catch(()=>M8(`${L} failed: network error`))},[Z6,x7,v7]),[a5,vZ]=u.useState(null),CJ=u.useCallback((N,L="")=>new Promise((_)=>{vZ({title:N,value:L,resolve:_})}),[]),TQ=u.useCallback((N)=>{vZ((L)=>{return L?.resolve?.(N),null})},[]),mY=u.useCallback((N,L)=>{let _=I7.current.canvas;if(!_||_===S8||!L||!String(L).trim())return;B7({type:"comments-add",payload:{file:_,text:String(L).trim(),selector:"",dom_path:[],tag:"",classes:"",bounds:null,html_excerpt:"",timeline:N}}),M8("Comment added.",!0)},[]);I7.current.selected=pX,I7.current.setSelected=O7,I7.current.removeClip=gY,I7.current.clipVerb=r5,I7.current.addComment=mY,I7.current.askText=CJ,u.useEffect(()=>{let N=(L)=>{let _=I7.current;if(!_.open||!_.comps?.length)return;let k=L.target,S=k?.tagName;if(S==="INPUT"&&k?.type!=="range")return;if(S==="TEXTAREA"||S==="SELECT"||k?.isContentEditable)return;let x=_.comps[0]?.fps||30,j=Math.max(1,_.total),d=(Y0)=>{let V0=Math.max(0,Math.min(j-1,Math.round(Y0)));uX(V0),L9(!1),_.post({dgn:"timeline-seek",frame:V0,id:_.compId})},X0=()=>{let Y0=new Set([0,j-1]);for(let V0 of _.sequences||[]){Y0.add(V0.from);for(let L0 of V0.keyframes||[])Y0.add(L0.from),Y0.add(L0.to)}return[...Y0].filter((V0)=>V0>=0&&V0<j).sort((V0,L0)=>V0-L0)};if((L.metaKey||L.ctrlKey)&&(L.key==="z"||L.key==="Z")){L.preventDefault(),fW(L.shiftKey?"redo":"undo");return}if(L.key==="Escape"){if(_.selected!=null)L.preventDefault(),_.setSelected?.(null);return}if((L.key==="Delete"||L.key==="Backspace")&&_.selected!=null){L.preventDefault(),_.removeClip?.({stableId:_.selected});return}if((L.metaKey||L.ctrlKey)&&(L.key==="b"||L.key==="B")){L.preventDefault();let Y0=_.selected!=null?{stableId:_.selected}:null;if(!Y0){let V0=_.sequences||[],L0=V0.find((P8)=>P8.series&&_.frame>=P8.from&&_.frame<P8.from+P8.duration)||V0.find((P8)=>_.frame>=P8.from&&_.frame<P8.from+P8.duration);if(L0?.stableId)Y0={stableId:L0.stableId}}if(Y0)_.clipVerb?.(Y0,"split",{atFrame:_.frame});else M8("Nothing under the playhead to split.");return}if(L.key===" "||L.code==="Space")if(L.preventDefault(),_.playing)L9(!1),_.post({dgn:"timeline-pause",id:_.compId});else L9(!0),_.post({dgn:"timeline-mute",muted:_.muted,id:_.compId}),_.post({dgn:"timeline-loop",loop:_.loop,id:_.compId}),_.post({dgn:"timeline-play",id:_.compId});else if(L.key==="ArrowRight")L.preventDefault(),d(_.frame+(L.shiftKey?x:1));else if(L.key==="ArrowLeft")L.preventDefault(),d(_.frame-(L.shiftKey?x:1));else if(L.key==="Home")L.preventDefault(),d(0);else if(L.key==="End")L.preventDefault(),d(j-1);else if(L.key==="."){L.preventDefault();let Y0=X0().find((V0)=>V0>_.frame);if(Y0!=null)d(Y0)}else if(L.key===","){L.preventDefault();let Y0=X0().reverse().find((V0)=>V0<_.frame);if(Y0!=null)d(Y0)}};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[]),u.useEffect(()=>{mX([]),uX(0),L9(!1),O7(null),l8(null);let N=setTimeout(()=>Y8({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(N)},[Z,Y8]);let[WX,G0]=u.useState(""),[xZ,CQ]=u.useState([]),[vW,$J]=u.useState([]);u.useEffect(()=>{if(!I9||p9.length===0||!Z||Z===S8){G0(""),CQ([]);return}let N=!0;return fetch(`/_api/canvas-source?file=${encodeURIComponent(Z)}`).then((L)=>L.ok?L.json():null).then((L)=>{if(N&&L?.ok&&typeof L.source==="string")G0(L.source)}).catch(()=>{}),()=>{N=!1}},[I9,p9,Z,AX]),u.useEffect(()=>{if(!I9||!Z||Z===S8||!WX){CQ([]),$J([]);return}let N=!0,L=_8||void 0,_=`/_api/comp-clips?canvas=${encodeURIComponent(Z)}${L?`&artboardId=${encodeURIComponent(L)}`:""}`;return fetch(_).then((k)=>k.ok?k.json():null).then((k)=>{if(!N)return;let S=k?.ok&&Array.isArray(k.clips)?k.clips:[];CQ(S.filter((x)=>x.kind==="sequence")),$J(S.filter((x)=>x.kind==="transition"))}).catch(()=>{}),()=>{N=!1}},[I9,Z,WX,_8,AX]),u.useEffect(()=>{if(!WX){SY([]),EQ([]),Q0([]),E0(0);return}let N=p9[0]?.durationInFrames||0,L=G6??z?.artboardId??null,_=nv(WX,N,L);l8(_.artboardId??L??null);let k=_.sequences.map((S,x)=>{let j=xZ[x];if(!j)return S;return{...S,stableId:j.stableId,contentHash:j.contentHash,mediaProps:j.mediaProps??null,placeholder:j.placeholder??null,mediaTag:j.mediaTag??S.mediaTag,mediaSrc:j.mediaSrc??S.mediaSrc,replaceable:!!(j.mediaCdId||j.mediaArrayRef),layers:Array.isArray(j.layers)?j.layers:[],hidden:!!j.hidden}});SY(k),EQ(_.audio||[]),Q0(_.transitions||[]),E0(_.total)},[WX,xZ,z,p9,G6]);let w7=u.useCallback(()=>{yY((N)=>{let L=!N,_=Z?x8.current.get(Z):null;if(_&&_.contentWindow)try{_.contentWindow.postMessage({dgn:"view-annotations",visible:L},"*")}catch{}return L})},[Z]),c7=u.useCallback((N)=>{for(let L of x8.current.values())try{L.contentWindow.postMessage({dgn:"view-chrome",...N},"*")}catch{}},[]),s5=u.useCallback(()=>{vY((N)=>{let L=!N;return c7({minimap:L}),L})},[c7]),uY=u.useCallback(()=>{yZ((N)=>{let L=!N;return c7({zoom:L}),L})},[c7]),xW=u.useCallback(()=>{$W((N)=>{let L=!N;return c7({present:L}),L})},[c7]),$Q=u.useCallback(()=>{$W(!1),c7({present:!1})},[c7]),SQ=u.useCallback(()=>{if(!Z||Z===S8)return;n5((N)=>{let L=!N;return Y8({dgn:"view-chrome",print:L}),fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{overlays:{print:L}}})}).catch(()=>{}),L})},[Z,Y8]);u.useEffect(()=>{let N=!1;return fetch("/_api/git-user").then((L)=>L.json()).then((L)=>{if(N)return;let _=L&&typeof L.name==="string"?L.name.trim():"";if(_)zK(_)}).catch(()=>{}),()=>{N=!0}},[]),u.useEffect(()=>{if(!Z||Z===S8){xY(0),n5(!1);return}let N=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(Z)).then((L)=>L.json()).then((L)=>{if(N)return;let _=Array.isArray(L?.artboards)?L.artboards.length:0;xY(_),n5(L?.overlays?.print===!0),jQ(new Set(Array.isArray(L?.locked)?L.locked:[]))}).catch(()=>{if(!N)xY(0),n5(!1),jQ(new Set)}),()=>{N=!0}},[Z]),u.useEffect(()=>{if(!Z||Z===S8||!G6)return;let N=setTimeout(()=>{Y8({dgn:"request-layers",artboardId:G6})},250);return()=>clearTimeout(N)},[Z,G6,Y8]);let[bQ,jQ]=u.useState(()=>new Set),p0=u.useCallback((N)=>{if(!Z||Z===S8)return;jQ((L)=>{let _=new Set(L);if(_.has(N))_.delete(N);else _.add(N);let k=[..._];return fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{locked:k}})}).catch(()=>{}),Y8({dgn:"locked-set",locked:k}),_})},[Z,Y8]);u.useEffect(()=>{if(!Z||Z===S8)return;Y8({dgn:"locked-set",locked:[...bQ]})},[bQ,Z,Y8]),u.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",w0),localStorage.setItem(Ue,w0)}catch{}for(let N of x8.current.values())try{N.contentWindow.postMessage({dgn:"theme",theme:w0},"*")}catch{}},[w0]),u.useEffect(()=>{try{localStorage.setItem(yt,Q9?"1":"0")}catch{}},[Q9]),u.useEffect(()=>{try{localStorage.setItem(St,Z9?"1":"0")}catch{}},[Z9]),u.useEffect(()=>{try{localStorage.setItem(bt,JSON.stringify(e9))}catch{}},[e9]),u.useEffect(()=>{try{localStorage.setItem(ft,kJ?"1":"0")}catch{}},[kJ]),u.useEffect(()=>{try{localStorage.setItem(vt,TJ?"1":"0")}catch{}},[TJ]),u.useEffect(()=>{try{localStorage.setItem(xt,o5?"1":"0")}catch{}},[o5]),u.useEffect(()=>{let N=!1;return fetch("/_api/ui-prefs").then((L)=>L.ok?L.json():Promise.reject(Error(`HTTP ${L.status}`))).then((L)=>{if(N||!L||typeof L!=="object")return;if(L.theme==="light"||L.theme==="dark")a0(L.theme);if(typeof L.minimap==="boolean")vY(L.minimap);if(typeof L.zoom==="boolean")yZ(L.zoom);if(typeof L.annotations==="boolean")yY(L.annotations);if(typeof L.autoOpenInspector==="boolean")RQ(L.autoOpenInspector);if(L.panelSides&&typeof L.panelSides==="object")l5({...ez,...L.panelSides});if(L.layersMode==="separate"||L.layersMode==="in-inspector")CY(L.layersMode)}).catch(()=>{}).finally(()=>{if(!N)oX(!0)}),()=>{N=!0}},[]),u.useEffect(()=>{if(!fY)return;eV0({theme:w0,minimap:kJ,zoom:TJ,annotations:o5,autoOpenInspector:PJ,panelSides:N6,layersMode:a9})},[fY,w0,kJ,TJ,o5,PJ,N6,a9]),u.useEffect(()=>{try{localStorage.setItem(ht,JSON.stringify(N6))}catch{}},[N6]),u.useEffect(()=>{try{localStorage.setItem(gt,a9)}catch{}},[a9]);let rX=u.useCallback((N,L)=>{DX((_)=>{let k=_[N],S=k===void 0?L:k;return{..._,[N]:!S}})},[]),yQ=u.useCallback(()=>{a0((N)=>N==="dark"?"light":"dark")},[]),b0=u.useCallback(async()=>{try{let L=await(await fetch("/_index-data")).json();Y(L.project||"Design");let _=L.groups.map((k)=>({...k,tree:Gq0(k.paths,k.stripPrefix,k.dirs)}));J(_),V9((k)=>({...k,canvasDesignSystems:L.canvasDesignSystems??{},canvasKinds:L.canvasKinds??{}}))}catch(N){console.error("failed to load tree",N)}},[]);u.useEffect(()=>{b0()},[b0]);let RX=u.useCallback(async(N)=>{try{let L=N?`/_system-data?ds=${encodeURIComponent(N)}`:"/_system-data",_=await fetch(L);if(!_.ok){console.error("failed to load system-data",_.status);return}let k=await _.json();if(!N&&k?.defaultDesignSystem&&!k.ds){c0(k);let S=await fetch(`/_system-data?ds=${encodeURIComponent(k.defaultDesignSystem)}`);if(S.ok)c0(await S.json());return}c0(k)}catch(L){console.error("failed to load system-data",L)}},[]),v0=u.useCallback(async()=>{try{let L=await(await fetch("/_comments-all")).json();k0(L||{})}catch(N){console.error("failed to load comments",N)}},[]);u.useEffect(()=>{v0()},[v0]),u.useEffect(()=>{function N(){let L=location.protocol==="https:"?"wss:":"ws:",_=new WebSocket(L+"//"+location.host+"/_ws");hY.current=_,_.addEventListener("open",()=>l(!0)),_.addEventListener("close",()=>{l(!1),setTimeout(N,1000)}),_.addEventListener("error",()=>{}),_.addEventListener("message",(k)=>{try{let S=JSON.parse(k.data);if(S.type==="snapshot"&&S.state)U((x)=>Ze(S.state.selected,x));else if(S.type==="selected"){if(Date.now()-O.current<2000)return;let x=S.selected,j=Array.isArray(x)?x[0]:x,d=q.current,X0=Array.isArray(d)?d[0]:d;if(U((Y0)=>Ze(x,Y0)),j?.id&&j.file&&(!X0||X0.id!==j.id||X0.file!==j.file))E(j)}else if(S.type==="comments"&&typeof S.file==="string")k0((x)=>({...x,[S.file]:S.comments||[]}));else if(S.type==="ai-activity"&&typeof S.file==="string"){if(fZ(!0),bW.current)clearTimeout(bW.current);bW.current=setTimeout(()=>fZ(!1),8000);for(let x of x8.current.values())try{x.contentWindow.postMessage({dgn:"ai-activity",file:S.file,entry:S.entry},"*")}catch{}}else if(S.type==="export:job"&&S.payload)jY.upsert(S.payload);else if(S.type==="sync:status"&&S.payload)a(S.payload);else if(S.type==="canvas-list-update"){if(b0(),S.payload?.action==="moved"&&S.payload.fromRel&&S.payload.rel){let x=($0?.designRel||$0?.designRoot||".design").replace(/^\/+|\/+$/g,""),j=`${x}/${S.payload.fromRel}`,d=`${x}/${S.payload.rel}`;G((X0)=>X0.map((Y0)=>Y0.path===j?{path:d}:Y0)),H((X0)=>X0===j?d:X0)}}else if(S.type==="config-updated")Z8();else if(S.type==="acp-focus"){if(p8())IJ("assistant")}else if(S.type==="git-status"&&S.payload)K0(S.payload);else if(S.type==="git-lifecycle"&&S.payload){h(S.payload);for(let x of x8.current.values())try{x.contentWindow.postMessage({dgn:"git-lifecycle",payload:S.payload},"*")}catch{}}}catch{}})}return N(),()=>hY.current&&hY.current.close()},[b0,Z8]);function B7(N){let L=hY.current;try{if(L&&L.readyState===1)L.send(JSON.stringify(N))}catch{}}let p6=u.useCallback(async()=>{try{let N=await fetch("/_api/git/status");if(N.ok)K0(await N.json())}catch{}},[]),GX=u.useCallback(async()=>{try{let N=await fetch("/_api/git/status?remote=1");if(!N.ok)return;let L=await N.json();if(L&&L.repo!==!1)r({remoteAhead:!!L.remoteAhead,behind:L.behind||0})}catch{}},[]),d6=u.useCallback(async(N,L)=>{try{let _=await fetch(N,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(L||{})}),k=await _.json().catch(()=>({}));return{ok:_.ok,...k}}catch(_){return{ok:!1,error:"Network error — is the project still open?"}}},[]),hW=u.useCallback(async(N,L)=>{let _=await d6("/_api/git/commit",{message:N,files:L});if(_.ok)await p6();return _},[d6,p6]),lY=u.useCallback(async(N)=>{let L=await d6("/_api/git/discard",{files:N});if(L.ok)await p6();return L},[d6,p6]),fQ=u.useCallback(async()=>{let N=await d6("/_api/git/push",{});if(N.ok)await p6(),GX();return N},[d6,p6,GX]),pY=u.useCallback(async()=>{let N=await d6("/_api/git/pull",{});if(N.ok)await p6(),GX();if(N.conflict&&Array.isArray(N.files)&&N.files.length)J8({file:N.files[0],conflict:!0});return N},[d6,p6,GX]),gW=u.useCallback(async(N)=>{let L=await d6("/_api/git/resolve",{choice:N});if(L.ok)await p6(),GX();return L},[d6,p6,GX]),dY=u.useCallback(async(N)=>{try{let L="/_api/git/log?limit=40"+(N?`&path=${encodeURIComponent(N)}`:""),_=await fetch(L);if(!_.ok)return[];return(await _.json()).entries||[]}catch{return[]}},[]),mW=u.useMemo(()=>{let N={modified:"M",added:"A",deleted:"D",untracked:"U"},L=new Map;for(let _ of i?.files||[])L.set(_.path,N[_.status]);return L},[i]),cY=i?.files?.length||0;u.useEffect(()=>{if(i?.repo===!1)return;GX();let N=setInterval(GX,n?60000:120000);return()=>clearInterval(N)},[i?.repo,n,GX]);let F6=u.useCallback((N)=>{if(G((L)=>{for(let _ of L)if(_.path!==N)x8.current.delete(_.path);return[{path:N}]}),H(N),G8(null),N!==S8)C8(N)},[]),SJ=u.useCallback((N)=>{let L=typeof N==="string"?N:void 0;if(L)RX(L);else if(!M0)RX();F6(S8)},[M0,RX,F6]);u.useEffect(()=>{B7({type:"tabs",tabs:W.map((N)=>N.path).filter((N)=>N!==S8)})},[W]),u.useEffect(()=>{if(Z&&Z!==S8)B7({type:"active",file:Z});else if(Z===S8)B7({type:"active",file:""});else B7({type:"active",file:""})},[Z]);let vQ=u.useCallback((N)=>{G((L)=>{let _=L.findIndex((S)=>S.path===N);if(_<0)return L;let k=L.filter((S)=>S.path!==N);if(N===Z)if(k.length===0)H(null);else H(k[Math.max(0,_-1)].path);return k}),x8.current.delete(N),C8((L)=>L===N?null:L)},[Z]),aX=u.useCallback(()=>{if(!Z||Z===S8){if(Z===S8)RX();return}let N=x8.current.get(Z);if(N)N.src=N.src},[Z,RX]),iY=u.useCallback(()=>b0(),[b0]),[uW,oY]=u.useState(!1),xQ=u.useRef(!1),hQ=u.useCallback(async()=>{if(xQ.current)return;xQ.current=!0,oY(!0);try{await Promise.all([b0(),new Promise((N)=>setTimeout(N,550))])}finally{xQ.current=!1,oY(!1)}},[b0]);u.useEffect(()=>{let N=null,L=()=>{if(N)clearTimeout(N);N=setTimeout(()=>{N=null,iY()},150)};return window.addEventListener("focus",L),()=>{if(window.removeEventListener("focus",L),N)clearTimeout(N)}},[iY]);let lW=u.useCallback(async(N)=>{try{let L=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:N,kind:"brief-board"})}),_=await L.json().catch(()=>({}));if(!L.ok||!_.ok)return{ok:!1,error:_.error||`create failed (${L.status})`};return await b0(),F6(_.file),{ok:!0,file:_.file}}catch(L){return{ok:!1,error:L instanceof Error?L.message:"network error"}}},[b0,F6]),nY=u.useCallback(async()=>{let N=await CJ("New video name");if(!N)return;let _=(await CJ("Size — 1920x1080 (landscape), 1080x1920 (portrait), 1080x1080 (square), or custom WxH","1920x1080")||"1920x1080").toLowerCase().match(/(\d{2,5})\s*[x×]\s*(\d{2,5})/),k=_?Number(_[1]):1920,S=_?Number(_[2]):1080,x=Math.max(1,Math.min(60,Number(await CJ("Frames per second","30"))||30));try{let j=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:N,kind:"video-comp",clips:[],fps:x,width:k,height:S})}),d=await j.json().catch(()=>({}));if(!j.ok||!d.ok){M8(`New video failed: ${d.error||`error ${j.status}`}`);return}await b0(),F6(d.file),e6(!0),M8("New video created — drop clips on the timeline to start the cut.",!0)}catch(j){M8(`New video failed: ${j instanceof Error?j.message:"network error"}`)}},[b0,F6,CJ]),pW=u.useCallback(async()=>{if(!Z||Z===S8)return;try{let N=await fetch(`/_api/annotations?file=${encodeURIComponent(Z)}`),L=N.ok?await N.text():"",_=[];if(L){let d=new DOMParser().parseFromString(L,"image/svg+xml");for(let X0 of d.querySelectorAll('[data-tool="mediaref"]')){let Y0=X0.getAttribute("data-src");if(!Y0)continue;_.push({src:Y0,mediaKind:X0.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(_.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let S=`${AW(dN(Z)).replace(/\.tsx$/i,"")} Video`,x=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:S,kind:"video-comp",clips:_})}),j=await x.json().catch(()=>({}));if(!x.ok||!j.ok){window.alert(`Assemble failed: ${j.error||`error ${x.status}`}`);return}await b0(),F6(j.file)}catch(N){window.alert(`Assemble failed: ${N instanceof Error?N.message:"network error"}`)}},[Z,b0,F6]),gQ=u.useCallback(({accept:N,resolveTarget:L})=>{let _=Z,k=_8||void 0,S=document.createElement("input");S.type="file",S.accept=N,S.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(S);let x=()=>{if(S.isConnected)S.remove()};window.addEventListener("focus",()=>setTimeout(x,300),{once:!0}),S.addEventListener("change",()=>{let j=S.files?.[0];if(x(),!j)return;let d=`/_api/comp-clips?canvas=${encodeURIComponent(_)}${k?`&artboardId=${encodeURIComponent(k)}`:""}`;fetch(d).then((X0)=>X0.json().catch(()=>({}))).then((X0)=>{let Y0=L(X0);if(!Y0)return M8("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":j.type||"application/octet-stream"},body:j}).then((V0)=>V0.json().catch(()=>({}))).then((V0)=>{if(!V0?.path)return M8(`Upload failed: ${V0?.error||"unknown error"}`),null;if(Y0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:_,arrayName:Y0.arrayRef.arrayName,index:Y0.arrayRef.index,field:Y0.arrayRef.field,value:V0.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:_,id:Y0.cdId,attr:"src",value:V0.path})})})}).then((X0)=>X0?X0.json():null).then((X0)=>{if(X0&&!X0.ok)M8(`Replace refused: ${X0.error||"failed"}`);else if(X0&&X0.ok){if(M8("Media replaced.",!0),X0.seq!=null)x7(_,X0.seq,"replace media")}}).catch(()=>M8("Replace failed: network error"))}),S.click()},[Z,_8,x7]),dW=u.useCallback(async(N,L)=>{if(!window.confirm(`Move “${L}” to trash?
|
|
5653
|
+
`).length," lines, paths & secrets scrubbed) —"," ",A("details",{className:"rb-details",children:[K("summary",{children:"view"}),K("pre",{className:"rb-log",children:Z.logs.serverLogTail})]})]})]}):null,p8()&&q.length>0&&A("label",{className:"rb-check",children:[K("input",{type:"checkbox",checked:F.crashLogs,onChange:(m)=>O({...F,crashLogs:m.target.checked})}),A("span",{children:["Crash logs (",q.length,") — ",K("code",{children:q.map((m)=>m.name).join(", ")})]})]})]}),A("p",{className:"rb-hint",children:["Your description and the system info above become a"," ",K("strong",{children:"public GitHub issue"}),"; screenshots and logs go to a private repository only maintainers can open."]}),A("footer",{className:"rb-actions",children:[K("button",{type:"button",className:"st-btn",onClick:()=>Y("describe"),children:"Back"}),K("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-send",onClick:y,children:"Send report"})]})]}),Q==="sending"&&K("p",{className:"rb-hint",children:"Sending your report…"}),Q==="done"&&A(W0,{children:[I?.issueUrl?A("p",{children:["Thank you — your report is filed as"," ",A("button",{type:"button",className:"rb-link","data-testid":"report-bug-issue-link",onClick:()=>{if(p8())O1(I.issueUrl).catch(()=>navigator.clipboard?.writeText(I.issueUrl));else window.open(I.issueUrl,"_blank","noopener")},children:["report #",I.issueNumber]})," ","on the public Maude issue tracker. Screenshots and logs stay in a private repository only maintainers can open — the issue links to them."]}):A("p",{children:["The bundle is saved locally",I?.fallbackDir?A(W0,{children:[" ","at ",K("code",{children:I.fallbackDir})]}):null," ","and a prefilled GitHub issue was opened — attach the bundle files there."]}),K("footer",{className:"rb-actions",children:K("button",{type:"button",className:"st-btn rb-primary",onClick:b,children:"Done"})})]}),Q==="fallback"&&A(W0,{children:[K("p",{className:"rb-error","data-testid":"report-bug-error",children:w}),K("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."}),A("footer",{className:"rb-actions",children:[K("button",{type:"button",className:"st-btn",onClick:()=>Y("preview"),children:"Back"}),K("button",{type:"button",className:"st-btn rb-primary",onClick:v,children:"Save locally & open GitHub"})]})]})]})]})})}var xX=I8(b8(),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 B_="mdcc-whatsnew-seen",N_="mdcc-whatsnew-toast-dismissed";function uZ0(X){return typeof X==="string"&&/^https?:\/\//i.test(X)}function lZ0(X){try{let J=localStorage.getItem(B_);if(J)return J;localStorage.setItem(B_,X)}catch{}return X}function pZ0(){try{return localStorage.getItem(N_)}catch{return null}}function Lx(X){let[J,Q]=xX.useState([]),[Y,W]=xX.useState(X),[G,Z]=xX.useState(()=>lZ0(X)),[H,z]=xX.useState(()=>pZ0()),[U,q]=xX.useState(!1);xX.useEffect(()=>{let w=!1,R=()=>{fetch("/_api/whats-new").then((b)=>b.json()).then((b)=>{if(w)return;if(Q(Array.isArray(b?.entries)?b.entries:[]),typeof b?.version==="string")W(b.version)}).catch(()=>{})};R();let T=()=>R(),C=()=>{if(document.visibilityState==="visible")R()};return window.addEventListener("focus",T),document.addEventListener("visibilitychange",C),()=>{w=!0,window.removeEventListener("focus",T),document.removeEventListener("visibilitychange",C)}},[]);let B=Nx(J,G),F=B.length>0&&H!==Y&&!U,O=B[0]??null,M=xX.useCallback(()=>{let w=Fx(J,Y);Z(w),z(Y);try{localStorage.setItem(B_,w),localStorage.setItem(N_,Y)}catch{}},[J,Y]),E=xX.useCallback(()=>{z(Y);try{localStorage.setItem(N_,Y)}catch{}},[Y]),I=xX.useCallback(()=>q(!0),[]),P=xX.useCallback(()=>{q(!1),M()},[M]);return{entries:J,unseen:B,feedVersion:Y,panelOpen:U,openPanel:I,closePanel:P,showToast:F,toastEntry:O,dismissToast:E,markAllSeen:M}}function Dx({wn:X}){if(!X.showToast||!X.toastEntry)return null;let J=X.toastEntry,Q=X.unseen.length;return A("div",{className:"st-toast",role:"status","aria-live":"polite",children:[K("button",{type:"button",className:"st-toast-close","aria-label":"Dismiss",onClick:X.dismissToast,children:"×"}),A("div",{className:"st-toast-hd",children:[K("span",{"aria-hidden":"true",children:"✦"}),"What's new",J.version?` · v${J.version}`:""]}),K("div",{className:"st-toast-title",children:J.title}),K("div",{className:"st-toast-txt",children:J.summary}),A("div",{className:"st-toast-actions",children:[K("button",{type:"button",className:"btn btn--primary btn--sm",onClick:X.openPanel,children:Q>1?`See all (${Q})`:"Details"}),K("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(xX.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 K("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)Y()},children:A("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[A("header",{className:"help-modal-hd",children:[K("span",{className:"title",id:"mdcc-wn-title",children:"✦ What’s new in maude"}),K("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:Y,children:"×"})]}),K("div",{className:"mdcc-wn-panel__body",children:X.entries.length===0?K("p",{className:"mdcc-wn-empty",children:"Nothing new yet."}):K("ul",{className:"mdcc-wn-list",children:X.entries.map((G)=>A("li",{className:"mdcc-wn-item"+(W.has(G.id)?" is-unseen":""),children:[A("div",{className:"mdcc-wn-item__hd",children:[K("span",{className:"mdcc-wn-kind mdcc-wn-kind--"+G.kind,children:G.kind}),K("span",{className:"mdcc-wn-item__title",children:G.title}),K("span",{className:"mdcc-wn-item__ver",children:G.version?`v${G.version}`:"next"})]}),K("p",{className:"mdcc-wn-item__summary",children:G.summary}),uZ0(G.learnMore)&&K("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&&K("button",{type:"button",className:"mdcc-wn-item__tour",onClick:()=>{Y(),J(G.tour)},children:"▶ Take tour"})]},G.id))})})]})})}var h9=({as:X,size:J=14})=>K(X,{size:J,strokeWidth:1.75,style:{display:"block"}}),Ct="mdcc-usage-tour-seen",$t="mdcc-collab-tour-seen",S8="__system__",Ue="mdcc-theme",St="mdcc-show-hidden",bt="mdcc-sections-expanded",jt="maude-cp-mode",yt="mdcc-sidebar-open",ft="mdcc-minimap-visible",vt="mdcc-zoomctl-visible",xt="mdcc-annotations-visible";var tV0=30000;function eV0(X){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(X)}).catch(()=>{})}catch{}}var GR=[{id:"tree",label:"Files"},{id:"layers",label:"Layers"},{id:"inspector",label:"Inspector"},{id:"comments",label:"Comments"},{id:"changes",label:"Changes"},{id:"assistant",label:"Assistant"}],ez={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",assistant:"right"},ht="mdcc-panel-sides",gt="mdcc-layers-mode";function mt({side:X,width:J,open:Q,ids:Y,activeId:W,onPick:G,children:Z}){return A("div",{className:"st-dockslot st-dockslot--"+X+(Q?"":" is-collapsed"),style:{width:Q?J:0,flexBasis:Q?J:0},children:[Q&&Y.length>1&&K("div",{className:"st-docktabs",role:"tablist","aria-label":X+" panels",children:Y.map((H)=>K("button",{type:"button",role:"tab","aria-selected":W===H,className:"st-docktab"+(W===H?" is-active":""),onClick:()=>G(H),children:(GR.find((z)=>z.id===H)||{}).label||H},H))}),Z]})}var AQ=/\.(tsx|html?)$/i;function uN(X){return X.replace(/^\.[^/]+\//,"").replace(AQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}var HR="0.53.1";function ut(X,J){try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(X,{body:J})}catch{}}function Xq0(){if(typeof window>"u")return"dark";try{let X=localStorage.getItem(Ue);if(X==="light"||X==="dark")return X}catch{}return"dark"}function kZ(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 XR(X,J){if(typeof window>"u")return J;try{let Q=localStorage.getItem(X);return Q?JSON.parse(Q):J}catch{return J}}function Jq0(X){if(X.kind==="runtime")return!1;if(X.label==="Design system")return!1;return!0}function dN(X){return X.split("/").pop()}function M8(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(M8._t),M8._t=setTimeout(()=>{Y.style.opacity="0",Y.style.pointerEvents="none"},Q?6000:3200)}var lt="maude-browse-hint-seen";function Qq0(X=!1){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(lt)==="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(lt,"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 AW(X){return X.replace(AQ,"")}function Yq0(X){return X.replace(AQ,"")}function Wq0(X){let J=new Map;for(let G of X){if(!AQ.test(G.name))continue;let Z=Yq0(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(AQ.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((z,U)=>z.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 Gq0(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 z of Z)H=H[z]=H[z]||{};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 z=0;z<Z.length;z++){let U=Z[z];if(z===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 Ve(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=Ve(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 pt(X){return(X||[]).filter((J)=>J.status!=="resolved").length}function Zq0(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 qe(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 lN({d:X,size:J=14,color:Q}){return K("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:K("path",{d:X})})}var Hq0={"chevron-down":K("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":K("polyline",{points:"6 3.5 10.5 8 6 12.5"}),file:A(W0,{children:[K("path",{d:"M4 2h5l3 3v9H4z"}),K("polyline",{points:"9 2 9 5 12 5"})]}),folder:K("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),"folder-plus":A(W0,{children:[K("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),K("path",{d:"M8 7.5v3.5M6.25 9.25h3.5"})]}),lock:A(W0,{children:[K("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),K("path",{d:"M5.5 7V5a2.5 2.5 0 015 0v2"})]}),unlock:A(W0,{children:[K("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),K("path",{d:"M5.5 7V5a2.5 2.5 0 015-.7"})]}),search:A(W0,{children:[K("circle",{cx:"7",cy:"7",r:"4"}),K("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:A(W0,{children:[K("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),K("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),check:K("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),x:A(W0,{children:[K("line",{x1:"4.3",y1:"4.3",x2:"11.7",y2:"11.7"}),K("line",{x1:"11.7",y1:"4.3",x2:"4.3",y2:"11.7"})]}),sun:A(W0,{children:[K("circle",{cx:"8",cy:"8",r:"2.6"}),K("line",{x1:"8",y1:"1.5",x2:"8",y2:"3"}),K("line",{x1:"8",y1:"13",x2:"8",y2:"14.5"}),K("line",{x1:"1.5",y1:"8",x2:"3",y2:"8"}),K("line",{x1:"13",y1:"8",x2:"14.5",y2:"8"}),K("line",{x1:"3.4",y1:"3.4",x2:"4.4",y2:"4.4"}),K("line",{x1:"11.6",y1:"11.6",x2:"12.6",y2:"12.6"}),K("line",{x1:"12.6",y1:"3.4",x2:"11.6",y2:"4.4"}),K("line",{x1:"4.4",y1:"11.6",x2:"3.4",y2:"12.6"})]}),moon:K("path",{d:"M12.5 9.6A5 5 0 1 1 7 3a4 4 0 0 0 5.5 6.6z"}),sparkle:K("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:A(W0,{children:[K("path",{d:"M2 6.7 11 4v8L2 9.3z"}),K("path",{d:"M11 5.2a2.4 2.4 0 0 1 0 5.6"}),K("path",{d:"M4.3 9.5v2.3a1.2 1.2 0 0 0 2.4 0v-1.7"})]}),"panel-left":A(W0,{children:[K("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),K("line",{x1:"6.4",y1:"3",x2:"6.4",y2:"13"})]}),resolve:A(W0,{children:[K("circle",{cx:"8",cy:"8",r:"5.6"}),K("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:A(W0,{children:[K("path",{d:"M3.2 8a5 5 0 1 1 1.4 3.5"}),K("polyline",{points:"3.2 11.4 3.2 8 6.6 8"})]}),layers:A(W0,{children:[K("polygon",{points:"8 2.2 13.8 5.5 8 8.8 2.2 5.5"}),K("polyline",{points:"2.2 9 8 12.3 13.8 9"})]}),box:K("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.2"}),type:A(W0,{children:[K("polyline",{points:"4 4 12 4"}),K("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:A(W0,{children:[K("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"3"}),K("line",{x1:"6",y1:"8",x2:"10",y2:"8"})]}),input:A(W0,{children:[K("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"1.2"}),K("line",{x1:"5",y1:"8",x2:"5",y2:"8"})]}),link:A(W0,{children:[K("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"}),K("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:A(W0,{children:[K("line",{x1:"6",y1:"4.5",x2:"13",y2:"4.5"}),K("line",{x1:"6",y1:"8",x2:"13",y2:"8"}),K("line",{x1:"6",y1:"11.5",x2:"13",y2:"11.5"}),K("circle",{cx:"3.2",cy:"4.5",r:"0.8",fill:"currentColor"}),K("circle",{cx:"3.2",cy:"8",r:"0.8",fill:"currentColor"}),K("circle",{cx:"3.2",cy:"11.5",r:"0.8",fill:"currentColor"})]}),eye:A(W0,{children:[K("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"}),K("circle",{cx:"8",cy:"8",r:"2"})]}),eyedropper:A(W0,{children:[K("path",{d:"M11 2.6a1.7 1.7 0 0 1 2.4 2.4l-1.2 1.2-2.4-2.4z"}),K("path",{d:"M9.5 4.6 4 10.1V12h1.9l5.5-5.5"})]}),"p-corner":K("path",{d:"M3.5 12.5V7a3.5 3.5 0 0 1 3.5-3.5h5.5"}),"p-opacity":A(W0,{children:[K("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.5"}),K("path",{d:"M3 8h10M8 3v10",strokeWidth:"0.9",opacity:"0.55"})]}),"p-lineheight":A(W0,{children:[K("line",{x1:"6.5",y1:"4",x2:"13",y2:"4"}),K("line",{x1:"6.5",y1:"8",x2:"13",y2:"8"}),K("line",{x1:"6.5",y1:"12",x2:"13",y2:"12"}),K("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":A(W0,{children:[K("path",{d:"M3 4v8M13 4v8"}),K("path",{d:"M6 11.5 8 5l2 6.5M6.7 9.3h2.6",strokeWidth:"1.1"})]}),"p-gap":A(W0,{children:[K("rect",{x:"2",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),K("rect",{x:"10.4",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),K("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":K("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"}),"p-size":A(W0,{children:[K("path",{d:"M3 13 6.6 3l3.6 10"}),K("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":A(W0,{children:[K("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"}),K("line",{x1:"2.5",y1:"2.5",x2:"13.5",y2:"13.5"})]}),sliders:A(W0,{children:[K("line",{x1:"3",y1:"5",x2:"13",y2:"5"}),K("circle",{cx:"6",cy:"5",r:"1.7",fill:"currentColor"}),K("line",{x1:"3",y1:"11",x2:"13",y2:"11"}),K("circle",{cx:"10",cy:"11",r:"1.7",fill:"currentColor"})]}),code:A(W0,{children:[K("polyline",{points:"6 5 3 8 6 11"}),K("polyline",{points:"10 5 13 8 10 11"})]}),download:A(W0,{children:[K("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),K("polyline",{points:"4.5 7 8 10.5 11.5 7"}),K("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),reload:A(W0,{children:[K("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),K("path",{d:"M14 2v3.33h-3.33"})]}),help:A(W0,{children:[K("circle",{cx:"8",cy:"8",r:"6"}),K("path",{d:"M6.3 6.2a1.8 1.8 0 1 1 2.3 1.9c-.5.2-.6.5-.6 1v.3"}),K("line",{x1:"8",y1:"11.4",x2:"8",y2:"11.5"})]}),image:A(W0,{children:[K("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),K("circle",{cx:"6",cy:"6.3",r:"1.1"}),K("path",{d:"M3 12l3-2.8 2.2 1.8 2.4-3L13.5 12"})]}),vector:A(W0,{children:[K("path",{d:"M3.6 11.2C6 5 10 5 12.4 11.2"}),K("rect",{x:"1.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),K("rect",{x:"11.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),K("rect",{x:"6.7",y:"2.6",width:"2.6",height:"2.6",rx:"0.4"})]}),presentation:A(W0,{children:[K("rect",{x:"2.5",y:"3",width:"11",height:"7.4",rx:"1"}),K("line",{x1:"8",y1:"10.4",x2:"8",y2:"13"}),K("line",{x1:"5.6",y1:"13.4",x2:"10.4",y2:"13.4"})]}),archive:A(W0,{children:[K("rect",{x:"2.5",y:"3",width:"11",height:"3",rx:"0.8"}),K("path",{d:"M3.6 6v6.2a1 1 0 0 0 1 1h6.8a1 1 0 0 0 1-1V6"}),K("line",{x1:"6.6",y1:"8.8",x2:"9.4",y2:"8.8"})]}),external:A(W0,{children:[K("path",{d:"M11 8.5V12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h3.5"}),K("polyline",{points:"9.5 3 13 3 13 6.5"}),K("line",{x1:"13",y1:"3",x2:"7.6",y2:"8.4"})]}),share:A(W0,{children:[K("circle",{cx:"4",cy:"8",r:"1.9"}),K("circle",{cx:"11.6",cy:"3.6",r:"1.9"}),K("circle",{cx:"11.6",cy:"12.4",r:"1.9"}),K("line",{x1:"5.7",y1:"7",x2:"9.9",y2:"4.6"}),K("line",{x1:"5.7",y1:"9",x2:"9.9",y2:"11.4"})]}),pen:A(W0,{children:[K("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"}),K("line",{x1:"9.6",y1:"4.2",x2:"11.8",y2:"6.4"})]}),square:K("rect",{x:"3.5",y:"3.5",width:"9",height:"9",rx:"1"})};function zq0({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 z=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>=z.length)Z(0)},[z.length,G]),!X)return null;let U=(q)=>{J(),q.run()};return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(q)=>{if(q.target===q.currentTarget)J()},children:A("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[A("div",{className:"st-pal-search",children:[K(G9,{name:"search",size:18}),K("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(z.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(),z[G])U(z[G])}}}),K(t6,{children:"⌘K"})]}),K("div",{className:"st-pal-list",ref:H,children:z.length===0?K("div",{className:"st-pal-empty",children:"No matching command."}):z.map((q,B)=>{let F=q.group&&(B===0||z[B-1].group!==q.group)?K("div",{className:"st-pal-group",children:q.group},"g-"+q.group):null;return A(W0,{children:[F,A("button",{type:"button",className:"st-pal-item"+(B===G?" is-active":""),onMouseEnter:()=>Z(B),onClick:()=>U(q),children:[K("span",{className:"st-pal-icon",children:K(G9,{name:q.icon,size:15})}),K("span",{className:"st-pal-label",children:q.label}),q.kbd?K("span",{className:"st-pal-kbd",children:K(t6,{children:q.kbd})}):null]})]},q.id)})})]})})}function G9({name:X,size:J=16,className:Q}){return K("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:Hq0[X]})}function Kq0(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 dt({initials:X,hue:J,title:Q,pulse:Y}){return K("span",{className:"st-avatar"+(Y?" is-pulsing":""),style:{"--av-hue":J},"data-tip":Q,"aria-label":Q,children:X})}function t6({children:X}){return K("span",{className:"kbd",children:X})}function ct(X,{min:J,max:Q,def:Y}){let W=u.useCallback((z)=>Math.min(Q,Math.max(J,z)),[J,Q]),[G,Z]=u.useState(()=>{try{let z=parseInt(localStorage.getItem(X)||"",10);return Number.isFinite(z)?W(z):Y}catch{return Y}});u.useEffect(()=>{try{localStorage.setItem(X,String(G))}catch{}},[X,G]);let H=u.useCallback((z)=>Z((U)=>W(typeof z==="function"?z(U):z)),[W]);return{w:G,setW:H,min:J,max:Q,def:Y}}function it({label:X,size:J,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:z,def:U}=J,q=W==="rtl"?-1:1;return K("div",{className:"st-grip"+(Y?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":X,"aria-valuemin":H,"aria-valuemax":z,"aria-valuenow":Math.round(G),onPointerDown:Q,onDoubleClick:()=>Z(U),onKeyDown:(B)=>{let F=B.shiftKey?24:8;if(B.key==="ArrowRight")B.preventDefault(),Z((O)=>O+F*q);else if(B.key==="ArrowLeft")B.preventDefault(),Z((O)=>O-F*q);else if(B.key==="Home")B.preventDefault(),Z(H);else if(B.key==="End")B.preventDefault(),Z(z)},children:A("svg",{className:"st-grip-dots",viewBox:"0 0 6 18","aria-hidden":"true",children:[K("circle",{cx:"3",cy:"3",r:"1.1",fill:"currentColor"}),K("circle",{cx:"3",cy:"9",r:"1.1",fill:"currentColor"}),K("circle",{cx:"3",cy:"15",r:"1.1",fill:"currentColor"})]})})}var JR=[{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}],QR={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},Uq0={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"]},Vq0=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],Yq=[{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}],qq0="2x",ot=[{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}],Bq0="auto",Nq0={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 Fq0(X){let J=String(X||"").split(".").pop()?.toLowerCase();return Nq0[J]||"application/octet-stream"}function Lq0({designRel:X,onPick:J,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[Z,H]=u.useState(null),[z,U]=u.useState(!1),[q,B]=u.useState(null),[F,O]=u.useState(()=>new Set),[M,E]=u.useState({}),[I,P]=u.useState(W?"artboard":"annotation");u.useEffect(()=>{let f=!0;return fetch("/_api/assets").then((l)=>l.json()).then((l)=>{if(!f)return;let p=l.ok?l.assets:[];H(p),E((h)=>{let s={...h};for(let a of p)s[a.path]=a.kind;return s})}).catch(()=>f&&H([])),()=>{f=!1}},[]),u.useEffect(()=>{let f=(l)=>{if(l.key==="Escape")l.stopPropagation(),Q()};return window.addEventListener("keydown",f,!0),()=>window.removeEventListener("keydown",f,!0)},[Q]);let w=Array.from(F).some((f)=>(M[f]||"image")!=="image"),R=!W||w,T=!W?"No artboard on this canvas":w?"Video/audio can only be added as annotations":"";u.useEffect(()=>{if(R&&I==="artboard")P("annotation")},[R,I]);let C=(f)=>{O((l)=>{let p=new Set(l);if(p.has(f))p.delete(f);else p.add(f);return p})},b=async(f)=>{let l=await fetch("/_api/asset",{method:"POST",headers:{"content-type":f.type||"application/octet-stream"},body:f}),p=await l.json().catch(()=>({}));if(l.ok&&p.path)return{ok:!0,path:p.path};return{ok:!1,error:p.error||`upload failed (HTTP ${l.status})`}},$=async(f)=>{if(!f)return;U(!0),B(null);let l=await b(f);if(U(!1),l.ok)J(l.path);else B(l.error)},y=(f)=>{if(typeof f==="string"&&f.startsWith("video/"))return"video";if(typeof f==="string"&&f.startsWith("audio/"))return"audio";return"image"},v=async(f)=>{if(!f.length)return;U(!0),B(null);let l=await Promise.all(f.map((s)=>b(s).then((a)=>({...a,file:s}))));U(!1);let p=l.filter((s)=>s.ok),h=l.length-p.length;if(h>0)B(`${h} of ${l.length} uploads failed`);if(p.length)E((s)=>{let a={...s};for(let i of p)a[i.path]=y(i.file.type);return a}),O((s)=>{let a=new Set(s);for(let i of p)a.add(i.path);return a})},g=async()=>{U(!0),B(null);try{if(Y){let p=(await ff()||[]).map((h)=>new File([new Uint8Array(h.bytes)],h.name,{type:Fq0(h.name)}));if(U(!1),p.length)await v(p);return}let f=await w1();if(f?.bytes){await $(new Blob([new Uint8Array(f.bytes)]));return}}catch(f){B(f?.message||"open failed")}U(!1)},m=()=>{if(p8()){g();return}let f=document.createElement("input");if(f.type="file",f.accept="image/*,video/*",Y)f.multiple=!0;f.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(f);let l=()=>{if(f.isConnected)f.remove()};window.addEventListener("focus",()=>setTimeout(l,300),{once:!0}),f.addEventListener("change",()=>{let p=f.files?Array.from(f.files):[];if(l(),!p.length)return;if(Y)v(p);else $(p[0])}),f.click()},c=(f)=>`/${X}/${f}`;return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(f)=>{if(f.target===f.currentTarget)Q()},children:A("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[A("div",{className:"st-dialog-hd",children:[K("span",{className:"st-dialog-title",children:"Choose media"}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:Q,children:K(G9,{name:"x",size:15})})]}),A("div",{className:"st-dialog-bd",children:[A("div",{className:"st-ap-toolbar",children:[K("button",{type:"button",className:"st-btn",onClick:m,disabled:z,children:z?"Uploading…":"Upload…"}),q&&K("span",{className:"st-ap-err",children:q})]}),K("div",{className:"st-ap-grid",children:Z==null?K("div",{className:"st-ap-empty",children:"Loading…"}):Z.length===0?K("div",{className:"st-ap-empty",children:"No assets yet — upload one."}):Z.map((f)=>{let l=Y&&F.has(f.path);return A("button",{type:"button",className:"st-ap-cell","data-selected":l?"true":void 0,"aria-pressed":Y?l:void 0,title:`${f.name} · ${Math.max(1,Math.round(f.size/1024))} KB`,onClick:()=>Y?C(f.path):J(f.path),children:[Y&&K("span",{className:"st-ap-check","aria-hidden":"true",children:l?K(G9,{name:"check",size:12}):null}),f.kind==="video"?K("video",{className:"st-ap-thumb",src:c(f.path),muted:!0,playsInline:!0}):K("img",{className:"st-ap-thumb",src:c(f.path),alt:f.name,loading:"lazy"}),K("span",{className:"st-ap-name",children:f.name})]},f.path)})})]}),Y&&F.size>0&&A("div",{className:"st-dialog-ft st-ap-confirm",children:[A("span",{className:"st-ap-count",children:[F.size," selected"]}),A("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[K("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":I==="artboard",disabled:R,onClick:()=>P("artboard"),children:"Add to artboard"}),K("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":I==="annotation",onClick:()=>P("annotation"),children:"Add as annotation"})]}),R&&K("span",{className:"st-ap-dest-note",children:T}),K("span",{className:"st-ap-confirm-spacer"}),K("button",{type:"button",className:"btn btn--ghost",onClick:Q,children:"Cancel"}),K("button",{type:"button",className:"btn btn--primary",onClick:()=>G?.(Array.from(F),I),children:"Insert"})]})]})})}function Dq0({mode:X,initialScope:J,activePath:Q,hasComps:Y=!1,comps:W=[],activeArtboardId:G=null,selection:Z=null,onClose:H}){let[z,U]=u.useState(X==="handoff"?"shadcn":"png"),[q,B]=u.useState(J&&QR[J]?J:"artboard"),[F,O]=u.useState(2),[M,E]=u.useState(qq0),[I,P]=u.useState(!0),[w,R]=u.useState(!1),[T,C]=u.useState(!1),[b,$]=u.useState(!1),[y,v]=u.useState(Bq0),[g,m]=u.useState(!0),[c,f]=u.useState(!1),[l,p]=u.useState(null),[h,s]=u.useState([]),a=JR.find((M0)=>M0.id===z)||JR[0],i=a.handoff?[]:Uq0[a.format]||["artboard"],K0=900,e=3600,r=W[0]||null,n=r?.durationInFrames||0,U0=r?.fps||30,f0=a.temporal&&n>900,J8=a.temporal&&n>3600;u.useEffect(()=>{if(i.length&&!i.includes(q))B(i[0])},[i,q]);let W8=u.useCallback(()=>{fetch("/_api/export-history").then((M0)=>M0.json()).then((M0)=>s(Array.isArray(M0?.history)?M0.history.slice(0,6):[])).catch(()=>{})},[]);u.useEffect(()=>{W8()},[W8]),u.useEffect(()=>{function M0(c0){if(c0.key==="Escape")c0.preventDefault(),H()}return window.addEventListener("keydown",M0),()=>window.removeEventListener("keydown",M0)},[H]);async function n0(){if(a.handoff){let e0=`/design:handoff ${Q&&Q!==S8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(e0)}catch{}p({ok:!0,msg:`Copied: ${e0} — run it in Claude Code.`});return}f(!0),p(null);let M0=a.temporal?{scale:F}:{};if(a.format==="png"){let c0=Yq.find((e0)=>e0.id===M)||Yq[1];if(c0.kind==="dpi")M0.dpi=c0.value;else M0.scale=c0.value}if(a.format==="mp4"||a.format==="webm")M0.audio=g;if(J8)M0.maxFrames=n;if(a.format==="pdf"){M0.pdfPrint={includeBleed:I,marks:{crop:T,registration:b}};let c0=ot.find((e0)=>e0.id===y)?.value;if(c0!==void 0)M0.dpi=c0}if(G)M0.artboardId=G;if(Z?.selector)M0.selection=Z;try{let c0=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:a.format,scope:q,options:M0})});if(!c0.ok){p({ok:!1,msg:await c0.text()||`Export failed (${c0.status})`}),f(!1);return}H()}catch(c0){p({ok:!1,msg:c0&&c0.message?c0.message:String(c0)}),f(!1)}}return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(M0)=>{if(M0.target===M0.currentTarget)H()},children:A("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[A("div",{className:"st-dialog-hd",children:[K("span",{className:"st-dialog-title",children:"Export & handoff"}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:H,children:K(G9,{name:"x",size:15})})]}),A("div",{className:"st-dialog-bd",children:[K("div",{className:"st-rp-hd",children:Q&&Q!==S8?`Format · ${AW(dN(Q))}`:"Format"}),K("div",{className:"st-fmt-grid",children:JR.filter((M0)=>!M0.temporal||Y).map((M0)=>A("button",{type:"button",className:"st-fmt"+(M0.id===z?" is-on":""),onClick:()=>{U(M0.id),p(null)},children:[K(G9,{name:M0.icon,size:16}),K("span",{className:"st-fmt-name",children:M0.label}),K("span",{className:"st-fmt-sub",children:M0.sub})]},M0.id))}),!a.handoff&&A("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-export-scope",children:"Scope"}),K("select",{id:"st-export-scope",className:"st-select",value:q,onChange:(M0)=>B(M0.target.value),children:i.map((M0)=>K("option",{value:M0,children:QR[M0]},M0))})]}),!a.handoff&&a.format==="png"&&A("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-export-size",children:"Resolution"}),K("select",{id:"st-export-size",className:"st-select",value:M,onChange:(M0)=>E(M0.target.value),children:Yq.map((M0)=>K("option",{value:M0.id,children:M0.label},M0.id))})]}),!a.handoff&&a.format==="png"&&K("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let M0=Yq.find((e0)=>e0.id===M)||Yq[1],c0=M0.kind==="dpi"?M0.value/96:M0.value;return`${M0.label} ≈ ${Math.round(1440*c0)}×${Math.round(900*c0)} for a 1440×900 artboard.`})()}),!a.handoff&&a.temporal&&A("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-export-temporal-size",children:"Resolution"}),K("select",{id:"st-export-temporal-size",className:"st-select",value:F,onChange:(M0)=>O(Number(M0.target.value)),children:Vq0.map((M0)=>K("option",{value:M0.value,children:M0.label},M0.value))})]}),!a.handoff&&a.temporal&&A("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[F,"× the artboard's native resolution (e.g. 960×540 → ",960*F,"×",540*F,")."]}),f0&&A("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: ",n," frames (≈",Math.round(n/U0),"s).",J8?` 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."]}),!a.handoff&&a.format==="pdf"&&A(W0,{children:[A("div",{className:"st-dialog-row",children:[K("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-dpi",children:"Image quality"}),K("select",{id:"st-export-pdf-dpi",className:"st-select",value:y,onChange:(M0)=>v(M0.target.value),children:ot.map((M0)=>K("option",{value:M0.id,children:M0.label},M0.id))})]}),K("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)."}),K("div",{className:"st-dialog-row",children:A("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-bleed",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[K("input",{id:"st-export-pdf-bleed",type:"checkbox",checked:I,onChange:(M0)=>P(M0.target.checked)}),"Include bleed"]})}),K("div",{className:"st-dialog-row",children:A("button",{type:"button",className:"st-dialog-lbl",style:{background:"none",border:0,padding:0,cursor:"pointer"},onClick:()=>R((M0)=>!M0),"aria-expanded":w,children:[w?"▾":"▸"," Marks"]})}),w&&A("div",{style:{padding:"0 12px 4px",display:"flex",flexDirection:"column",gap:6},children:[A("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[K("input",{type:"checkbox",checked:T,onChange:(M0)=>C(M0.target.checked)}),"Crop marks"]}),A("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[K("input",{type:"checkbox",checked:b,onChange:(M0)=>$(M0.target.checked)}),"Registration marks"]})]}),A("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:["Bleed and marks apply to print (",K("code",{children:'kind="print"'}),") artboards only.",q==="canvas-as-separate"?" One PDF page per artboard.":""]})]}),!a.handoff&&(a.format==="mp4"||a.format==="webm")&&K("div",{className:"st-dialog-row",children:A("label",{className:"st-dialog-lbl",htmlFor:"st-export-audio",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[K("input",{id:"st-export-audio",type:"checkbox",checked:g,onChange:(M0)=>m(M0.target.checked)}),"Export with audio"]})}),a.handoff&&A("div",{className:"callout callout--info",style:{fontSize:12},children:["Hands the active canvas off to production. Copies"," ",K("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."]}),l&&K("div",{className:"callout "+(l.ok?"callout--success":"callout--error"),style:{fontSize:12},children:l.msg}),h.length>0&&A("div",{className:"st-export-recent",children:[K("div",{className:"st-rp-hd",children:"Recent"}),h.map((M0,c0)=>A("div",{className:"st-export-recent-row",children:[A("span",{children:[String(M0.format||"").toUpperCase()," ·"," ",QR[M0.scope]||M0.scope]}),K("span",{className:"st-mono",children:M0.filename})]},c0))]})]}),A("div",{className:"st-dialog-ft",children:[K("button",{type:"button",className:"btn btn--ghost",onClick:H,children:"Cancel"}),A("button",{type:"button",className:"btn btn--primary",disabled:c,onClick:n0,children:[K(G9,{name:"download",size:14}),a.handoff?"Copy handoff command":c?"Exporting…":`Export ${a.label}`]})]})]})})}var cN=12,iN=16;function Oq0({name:X,depth:J,defaultOpen:Q,children:Y,dirPath:W,drag:G,menu:Z}){let[H,z]=u.useState(Q),U=G?G.dropProps(W,!0,()=>z(!0)):{},q=G?.overDir===W,B=G?G.dragProps(W,!0):{},F=G?.draggedPath===W,O=G?.busyPath===W,M=A("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${uN(W)}`,"aria-expanded":H,"aria-dropeffect":G?"move":void 0,"aria-busy":O||void 0,tabIndex:-1,className:"st-row"+(q?" is-drop-target":"")+(F?" is-dragging":"")+(O?" is-busy":""),style:{paddingLeft:cN+J*iN+"px"},onClick:()=>z((E)=>!E),onContextMenu:Z?(E)=>Z.openAt(E,{kind:"dir",dirPath:W}):void 0,...B,...U,children:[K("span",{className:"st-row-glyph",children:K(G9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),K("span",{className:"st-row-name",children:X})]});return A(W0,{children:[Z?A("div",{className:"st-row-wrap",role:"none",children:[M,K("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${uN(W)}`,title:`Folder actions — ${X}`,"aria-label":`Folder actions for ${X}`,"aria-haspopup":"menu",onClick:(E)=>Z.openAt(E,{kind:"dir",dirPath:W}),children:K(lN,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})})]}):M,H&&Y]})}function Mq0({name:X,dsName:J,depth:Q,defaultOpen:Y,active:W,onOpenSystem:G,children:Z}){let[H,z]=u.useState(Y);return A(W0,{children:[A("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:cN+Q*iN+"px"},role:"treeitem","aria-expanded":H,children:[K("button",{type:"button",className:"st-ds-chev",onClick:()=>z((U)=>!U),"aria-label":H?"Collapse design system":"Expand design system",title:H?"Collapse":"Expand",children:K(G9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),A("button",{type:"button",className:"st-ds-open",onClick:()=>G(J),"aria-label":`Open ${J} design system view`,title:"Open the design system view",children:[K("span",{className:"st-row-glyph",children:K(G9,{name:"folder",size:13})}),K("span",{className:"st-row-name",children:X})]})]}),H&&Z]})}function ZR({file:X,activePath:J,onOpen:Q,onDelete:Y,openCount:W,depth:G,kind:Z,sidecar:H,dirty:z,experimentalKind:U,drag:q,menu:B}){let F=X.path===J,O=AQ.test(X.name),M=!O,E=O?AW(X.name):X.name,I=O&&typeof Y==="function"&&Z!=="runtime",P=O&&!H&&Z!=="runtime"&&typeof q<"u",w=P?q.dragProps(X.path,!0):{},R=q?.draggedPath===X.path,T=q?.busyPath===X.path,C=P&&typeof B<"u",b=X.path.split("/").slice(0,-1).join("/"),$=O?"canvas-row-"+X.path.replace(/^\.[^/]+\//,"").replace(AQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,y=A("button",{type:"button",role:"treeitem","data-testid":$,"aria-selected":F,"aria-disabled":M?"true":void 0,"aria-busy":T||void 0,tabIndex:F?0:-1,className:"st-row"+(F?" is-sel":"")+(Z==="runtime"?" is-muted":"")+(R?" is-dragging":"")+(T?" is-busy":""),style:{paddingLeft:cN+G*iN+"px"},title:X.path+(W?` — ${W} open`:M?" (file index only)":""),onClick:()=>{if(!M)Q(X.path)},onContextMenu:C?(v)=>B.openAt(v,{kind:"file",path:X.path,dir:b}):void 0,...w,children:[K("span",{className:"st-row-glyph",children:K(G9,{name:"file",size:13})}),K("span",{className:"st-row-name",children:E}),U==="reconstructed-experimental"&&K("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"}),z&&K("span",{className:"st-git-badge","data-kind":z,title:`Unsaved (${z})`,"aria-label":`Unsaved, ${z}`,children:z}),W>0&&K("span",{className:"st-row-badge",children:W})]});if(!I&&!C)return y;return A("div",{className:"st-row-wrap",role:"none",children:[y,C&&K("button",{type:"button",className:"st-row-menu-btn"+(I?" has-delete-sibling":""),"data-testid":`tree-row-menu-${uN(X.path)}`,title:`Move ${E}…`,"aria-label":`Actions for ${E}`,"aria-haspopup":"menu",onClick:(v)=>B.openAt(v,{kind:"file",path:X.path,dir:b}),children:K(lN,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})}),I&&K("button",{type:"button",className:"st-row-del",title:`Delete ${E}`,"aria-label":`Delete canvas ${E}`,onClick:(v)=>{v.stopPropagation(),Y(X.path,E)},children:K(lN,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})}function wq0({primary:X,sidecars:J,depth:Q,kind:Y,activePath:W,onOpen:G,onDelete:Z,openCount:H,showHidden:z,forceOpen:U,dirtyByPath:q,experimentalKind:B,drag:F,menu:O}){let M=q?.get(X.path),E=J.length>0,[I,P]=u.useState(!1),w=U||I,R=X.path===W;if(!(E&&z))return K(ZR,{file:X,activePath:W,onOpen:G,onDelete:Z,openCount:H,depth:Q,kind:Y,dirty:M,experimentalKind:B,drag:F,menu:O});let C=typeof F<"u",b=C?F.dragProps(X.path,!0):{},$=F?.draggedPath===X.path,y=F?.busyPath===X.path,v=C&&typeof O<"u",g=X.path.split("/").slice(0,-1).join("/"),m=A("button",{type:"button",role:"treeitem","aria-selected":R,"aria-expanded":w,"aria-busy":y||void 0,tabIndex:R?0:-1,className:"st-row st-canvas-row"+(R?" is-sel":"")+($?" is-dragging":"")+(y?" is-busy":""),style:{paddingLeft:cN+Q*iN+"px"},title:X.path,onClick:(c)=>{if(c.target.closest(".st-canvas-chev")){P((f)=>!f);return}G(X.path)},onContextMenu:v?(c)=>O.openAt(c,{kind:"file",path:X.path,dir:g}):void 0,...b,children:[K("span",{className:"st-row-glyph st-canvas-chev",onClick:(c)=>{c.stopPropagation(),P((f)=>!f)},children:K(G9,{name:"chevron-right",className:"st-chev"+(w?" is-open":""),size:13})}),K("span",{className:"st-row-name",children:AW(X.name)}),B==="reconstructed-experimental"&&K("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"}),M&&K("span",{className:"st-git-badge","data-kind":M,title:`Unsaved (${M})`,"aria-label":`Unsaved, ${M}`,children:M}),H>0&&K("span",{className:"st-row-badge",children:H})]});return A(W0,{children:[v?A("div",{className:"st-row-wrap",role:"none",children:[m,K("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${uN(X.path)}`,title:`Move ${AW(X.name)}…`,"aria-label":`Actions for ${AW(X.name)}`,"aria-haspopup":"menu",onClick:(c)=>O.openAt(c,{kind:"file",path:X.path,dir:g}),children:K(lN,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})})]}):m,w&&J.map((c)=>K(ZR,{file:c,activePath:W,onOpen:G,openCount:0,depth:Q+1,kind:Y,sidecar:!0},c.path))]})}function Be({node:X,activePath:J,onOpen:Q,commentsByFile:Y,depth:W=1,kind:G,showHidden:Z,search:H,dsFolders:z,activeDsName:U,onOpenSystem:q,onDelete:B,dirtyByPath:F,canvasKinds:O,dirPath:M="",drag:E,menu:I}){let P=Object.keys(X).filter(($)=>$!=="_files").sort(),w=X._files||[],{canvases:R,orphans:T}=u.useMemo(()=>Wq0(w),[w]),C=!!(H&&H.trim()),b=u.useMemo(()=>{if(!z||W!==1)return null;let $=new Map;for(let y of z)$.set(y.folder,y);return $},[z,W]);return A(W0,{children:[R.map(($)=>{let y=C&&$.sidecars.some((v)=>{let g=H.toLowerCase();return v.name.toLowerCase().includes(g)||v.path.toLowerCase().includes(g)});return K(wq0,{primary:$.primary,sidecars:$.sidecars,activePath:J,onOpen:Q,onDelete:B,openCount:pt(Y[$.primary.path]),depth:W,kind:G,showHidden:Z,forceOpen:y,dirtyByPath:F,experimentalKind:O?.[$.primary.path],drag:E,menu:I},$.primary.path)}),Z&&T.map(($)=>K(ZR,{file:$.primary,activePath:J,onOpen:Q,openCount:pt(Y[$.primary.path]),depth:W,kind:G},$.primary.path)),P.map(($)=>{let y=b?.get($),v=M?`${M}/${$}`:$,g=K(Be,{node:X[$],activePath:J,onOpen:Q,commentsByFile:Y,depth:W+1,kind:G,showHidden:Z,search:H,activeDsName:U,onOpenSystem:q,onDelete:B,dirtyByPath:F,canvasKinds:O,dirPath:v,drag:E,menu:I});if(y&&q)return K(Mq0,{name:$,dsName:y.name,depth:W,defaultOpen:!0,active:J===S8&&y.name===U,onOpenSystem:q,children:g},$);return K(Oq0,{name:$,depth:W,defaultOpen:!0,dirPath:v,drag:E,menu:I,children:g},$)})]})}var hN={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function _q0(X){if(X.kind==="project")return hN.project;if(X.kind==="runtime")return hN.runtime;if(X.label==="Design system")return hN.ds;if(X.label==="UI kit")return hN.canvas;return{title:X.label.toUpperCase(),pillFromCount:!0}}function Aq0({readOnly:X=!1,groups:J,activePath:Q,activeDsName:Y,onOpen:W,onOpenSystem:G,wsConnected:Z,search:H,setSearch:z,commentsByFile:U,showHidden:q,sectionsExpanded:B,onToggleSection:F,onNewBoard:O,onDeleteBoard:M,onRefresh:E,refreshing:I,collapsed:P,onCollapse:w,width:R,resizing:T,dirtyByPath:C,project:b,gitBranch:$,remoteSync:y,onGetLatest:v,canvasKinds:g,onMoveCanvas:m,onNewFolder:c,onDeleteFolder:f}){let l=u.useMemo(()=>{if(!H)return J;return J.map((j0)=>({...j0,tree:Ve(j0.tree,H),filtered:!!H}))},[J,H]),p=D$(m),h=F$(),s=u.useMemo(()=>{let j0=[];for(let g0 of J){if(g0.label==="Design system"||g0.kind!=="canvas")continue;let A8=g0.fullPath.replace(/^\.[^/]+\//,"")||g0.fullPath;j0.push({path:g0.fullPath,label:A8});for(let r8 of g0.dirs||[])j0.push({path:r8,label:r8.replace(/^\.[^/]+\//,"")})}return j0},[J]),a=h.state?.extra,i=a?.kind==="file"?[{id:"move-to",label:"Move to…",onSelect:()=>h.showMoveTo()}]:a?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{h.close();let j0=window.prompt("New folder name:");if(j0?.trim())c(a.dirPath,j0.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{h.close(),f(a.dirPath,a.dirPath.split("/").pop())}}]:[],K0=a?.kind==="file"?s.filter((j0)=>j0.path!==a.dir):[],[e,r]=u.useState(!1),[n,U0]=u.useState("board"),[f0,J8]=u.useState(""),[W8,n0]=u.useState(""),[M0,c0]=u.useState(!1),e0=u.useMemo(()=>J.find((j0)=>j0.kind==="canvas"&&j0.label!=="Design system")?.fullPath,[J]),C8=u.useCallback(async()=>{let j0=f0.trim();if(!j0||M0)return;if(c0(!0),n0(""),n==="folder"){if(!e0){c0(!1),n0("no canvas group to create a folder in");return}let A8=await c(e0,j0);if(c0(!1),A8?.ok)r(!1),J8("");else n0(A8?.error||"could not create folder");return}let g0=await O(j0);if(c0(!1),g0?.ok)r(!1),J8("");else n0(g0?.error||"could not create board")},[f0,M0,O,c,n,e0]),t0=u.useMemo(()=>{let j0=0;for(let g0 of J)for(let A8 of g0.paths||[])if(AQ.test(A8))j0++;return j0},[J]),h8=u.useMemo(()=>{let j0=0;for(let g0 of l)for(let A8 of g0.paths||[])if(AQ.test(A8))j0++;return j0},[l]);return A("nav",{className:"st-sidebar"+(P?" is-collapsed":"")+(T?" is-resizing":""),style:P||!R?void 0:{width:R,flexBasis:R},"aria-label":"Files","data-tour":"sidebar",children:[A("div",{className:"st-sb-hd",children:[K("span",{className:"st-sb-title",children:"Files"}),A("div",{className:"st-sb-hd-actions",children:[!X&&K("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":e&&n==="board",onClick:()=>{n0(""),U0("board"),r((j0)=>n==="board"?!j0:!0)},children:K(G9,{name:"plus",size:15})}),!X&&e0&&K("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":e&&n==="folder",onClick:()=>{n0(""),U0("folder"),r((j0)=>n==="folder"?!j0:!0)},children:K(G9,{name:"folder-plus",size:15})}),E&&K("button",{type:"button",className:"st-iconbtn st-refresh"+(I?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":I||void 0,disabled:I,onClick:()=>E(),children:K(G9,{name:"reload",size:15})}),A("span",{className:"st-live","data-tip":Z?"live · file index synced":"reconnecting…",children:[K("span",{className:"st-live-dot"+(Z?" is-connected":""),"aria-hidden":"true"}),h8," / ",t0]}),w&&K("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:w,children:K(G9,{name:"panel-left",size:15})})]})]}),e?A("div",{className:"st-newboard",children:[K("input",{type:"text",autoFocus:!0,placeholder:n==="folder"?"folder name…":"brief board name…",value:f0,maxLength:60,disabled:M0,"aria-label":n==="folder"?"New folder name":"New brief board name",onChange:(j0)=>J8(j0.target.value),onKeyDown:(j0)=>{if(j0.key==="Enter")j0.preventDefault(),C8();else if(j0.key==="Escape")j0.preventDefault(),r(!1),J8(""),n0("")}}),K("button",{type:"button",className:"st-newboard-go",disabled:M0||!f0.trim(),"data-tip":"Create · Enter","aria-label":n==="folder"?"Create folder":"Create brief board",onClick:C8,children:M0?"…":"↵"})]}):null,W8?K("div",{className:"st-newboard-err",role:"alert",children:W8}):null,K("div",{className:"st-search",children:A("div",{className:"st-search-box",children:[K(G9,{name:"search",size:13}),K("input",{type:"search",placeholder:"Search canvases…",value:H,onChange:(j0)=>z(j0.target.value),onKeyDown:(j0)=>{if(j0.key==="Escape")if(j0.preventDefault(),H)z("");else j0.currentTarget.blur()},"aria-label":"Filter files"}),H?K("button",{className:"st-search-clear",onClick:()=>z(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):K(t6,{children:"/"})]})}),K("div",{className:"st-tree",role:"tree","aria-label":"Project file tree","data-testid":"canvas-list",children:l.map((j0)=>{if(!q&&!H&&j0.kind==="runtime")return null;let g0=_q0(j0),A8=(j0.paths||[]).filter((T8)=>AQ.test(T8)).length,r8=g0.pill||(g0.pillFromDsCount?String(j0.dsFolders?.length||0):null)||(g0.pillFromCount?String(A8||j0.paths?.length||0):null),R9=j0.tree&&Object.keys(j0.tree).length>0,$0=j0.label==="Design system",V9=j0.kind==="project";if(!q&&!H&&V9&&A8===0)return null;let I0=Jq0(j0),Z8=B[j0.label],H0=!!H||(Z8===void 0?I0:Z8),k0=!$0&&j0.kind==="canvas"&&!X,F0=k0?p.dropProps(j0.fullPath,!0):{},G8=p.overDir===j0.fullPath;return A("div",{className:"st-tree-section",children:[A("button",{type:"button",className:"st-tree-sec-hd"+(G8?" is-drop-target":""),onClick:()=>F(j0.label,I0),"aria-expanded":H0,"aria-dropeffect":k0?"move":void 0,title:H0?"Collapse section":"Expand section",...F0,children:[K(G9,{name:"chevron-right",className:"st-chev"+(H0?" is-open":""),size:13}),K("span",{className:"st-sec-name",children:g0.title}),r8&&K("span",{className:"st-pill",children:r8})]}),H0&&(R9?K(Be,{node:j0.tree,activePath:Q,onOpen:W,commentsByFile:U,depth:1,kind:j0.kind,showHidden:q,search:H,dsFolders:j0.dsFolders,activeDsName:Y,onOpenSystem:$0?G:void 0,onDelete:$0||X?void 0:M,dirtyByPath:C,canvasKinds:g,dirPath:j0.fullPath,drag:!$0&&j0.kind==="canvas"&&!X?p:void 0,menu:!$0&&j0.kind==="canvas"&&!X?h:void 0}):K("div",{className:"st-tree-empty",children:H?"No matches.":"Empty."}))]},j0.label)})}),K(L$,{state:h.state,onClose:h.close,rootItems:i,destinations:K0,onPickDestination:(j0)=>m(a.path,j0)}),K(Y_,{project:b,liveBranch:$,remoteSync:y,onGetLatest:v}),K($w,{}),K(bw,{})]})}function Eq0({shown:X,onExpand:J,onSearch:Q}){return K("div",{className:"st-rail"+(X?" is-shown":""),children:A("div",{className:"st-rail-inner",children:[K("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:J,children:K(G9,{name:"panel-left",size:15})}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:K(G9,{name:"search",size:15})}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:J,children:K(G9,{name:"folder",size:15})})]})})}function Pq0({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 K("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:A("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[A("header",{className:"help-modal-hd",children:[K("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),A("span",{className:"sku",children:["MAUDE-DEV-SRV / v",HR]}),Q&&K("button",{type:"button",className:"mdcc-tour__back",style:{marginLeft:"auto"},onClick:Q,children:"▶ Take the tour"}),K("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:J,children:"×"})]}),A("div",{className:"help-modal-body",children:[A("details",{open:!0,children:[K("summary",{children:"Canvas selection & tools"}),A("ul",{children:[A("li",{children:[K("kbd",{children:"V"})," ",K("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),A("li",{children:[K("kbd",{children:"H"})," ",K("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),A("li",{children:[K("kbd",{children:"C"})," ",K("span",{children:"comment tool — hover paints, click drops a pin"})]}),A("li",{children:[K("kbd",{children:"⌘"})," + hover ",K("span",{children:"preview deepest element under cursor"})]}),A("li",{children:[K("kbd",{children:"⌘"})," + click ",K("span",{children:"select that element (replace)"})]}),A("li",{children:[K("kbd",{children:"⌘⇧"})," + click ",K("span",{children:"add deepest to selection (multi)"})]}),A("li",{children:["right-click ",K("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),A("li",{children:[K("kbd",{children:"Esc"})," in canvas ",K("span",{children:"clear selection + close menu"})]})]})]}),A("details",{children:[K("summary",{children:"Annotation tools"}),A("ul",{children:[A("li",{children:[K("kbd",{children:"B"})," ",K("span",{children:"pen — freehand stroke"})]}),A("li",{children:[K("kbd",{children:"R"})," ",K("span",{children:"rectangle — drag to define corners"})]}),A("li",{children:[K("kbd",{children:"O"})," ",K("span",{children:"ellipse — drag from center outward"})]}),A("li",{children:[K("kbd",{children:"A"})," ",K("span",{children:"arrow — drag tail → tip"})]}),A("li",{children:[K("kbd",{children:"E"})," ",K("span",{children:"eraser — click or drag over strokes to remove"})]}),A("li",{children:[K("kbd",{children:"V"})," + click stroke ",K("span",{children:"select annotation (Shift+click to multi)"})]}),A("li",{children:[K("kbd",{children:"V"})," + drag empty ",K("span",{children:"marquee-select strokes that overlap"})]}),A("li",{children:["double-click rect/ellipse ",K("span",{children:"add text inside the shape"})]}),A("li",{children:["arrow keys ",K("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),A("li",{children:[K("kbd",{children:"Backspace"})," ",K("span",{children:"delete selected annotations"})]}),A("li",{children:[K("kbd",{children:"⇧P"})," ",K("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),A("details",{children:[K("summary",{children:"Canvas & panels"}),A("ul",{children:[A("li",{children:["click in tree ",K("span",{children:"open canvas (replaces the active one)"})]}),A("li",{children:["File ▸ Close canvas ",K("span",{children:"clear the stage"})]}),A("li",{children:[K("kbd",{children:"⌘R"})," ",K("span",{children:"reload canvas"})]}),A("li",{children:[K("kbd",{children:"/"})," ",K("span",{children:"focus search"})]}),A("li",{children:[K("kbd",{children:"⌘⇧M"})," ",K("span",{children:"comments panel"})]}),A("li",{children:[K("kbd",{children:"⌘⇧I"})," ",K("span",{children:"inspector"})]}),A("li",{children:[K("kbd",{children:"?"})," ",K("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),A("details",{children:[K("summary",{children:"Slash commands"}),A("ul",{className:"cmds",children:[A("li",{children:[A("code",{children:['/design:edit "',K("i",{children:"feedback"}),'"']}),K("span",{children:"edit + 4-iter multi-axis loop"})]}),A("li",{children:[A("code",{children:['/design:edit "',K("i",{children:"…"}),'" --perfect']}),K("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),A("li",{children:[A("code",{children:['/design:edit "',K("i",{children:"…"}),'" --no-critic']}),K("span",{children:"raw edit, skip loop"})]}),A("li",{children:[A("code",{children:['/design:edit "',K("i",{children:"…"}),'" --opt-out=',K("i",{children:"scope"})]}),K("span",{children:"override DS scope (palette/aesthetic/full)"})]}),A("li",{children:[A("code",{children:['/design:new "',K("i",{children:"Name"}),'" "',K("i",{children:"brief"}),'"']}),K("span",{children:"scaffold canvas"})]}),A("li",{children:[A("code",{children:['/design:new "',K("i",{children:"…"}),'" --opt-out=aesthetic']}),K("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),A("li",{children:[K("code",{children:"/design:critic"}),K("span",{children:"review panel (routed)"})]}),A("li",{children:[K("code",{children:"/design:critic --all"}),K("span",{children:"10-critic sweep"})]}),A("li",{children:[K("code",{children:"/design:critic --agent signature-moment-critic"}),K("span",{children:"aspiration axis only"})]}),A("li",{children:[K("code",{children:"/design:rollback"}),K("span",{children:"undo last edit"})]}),A("li",{children:[K("code",{children:"/design:screenshot"}),K("span",{children:"capture canvas"})]}),A("li",{children:[K("code",{children:"/design:setup-docs"}),K("span",{children:"refresh README + INDEX"})]}),A("li",{children:[K("code",{children:"/design:handoff"}),K("span",{children:"migrate to apps/"})]})]})]}),A("details",{children:[K("summary",{children:"Opt-out scope"}),A("ul",{children:[A("li",{children:[K("strong",{children:"palette"})," ",K("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),A("li",{children:[K("strong",{children:"aesthetic"})," ",K("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),A("li",{children:[K("strong",{children:"full"})," ",K("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),A("li",{children:[K("em",{children:"A11y enforced at every scope"})," ",K("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),A("li",{children:["Persisted on canvas's ",K("code",{children:".meta.json"})," ",K("code",{children:"opt_out_scope"})," field — subsequent ",K("code",{children:"/design:edit"})," iterations inherit."]}),K("li",{children:'Inferred from brief ("modern", "vibrant", "off-system") with one-shot AskUserQuestion before iter-1 critics fire.'})]})]}),A("details",{children:[K("summary",{children:"Auto-critic loop"}),A("ul",{children:[A("li",{children:[K("strong",{children:"Default"})," ",K("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),A("li",{children:[K("strong",{children:"--perfect"})," ",K("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),A("li",{children:[K("strong",{children:"--perfect --all"})," ",K("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),A("li",{children:["Exit: ",K("code",{children:"solid"})," · ",K("code",{children:"stable-but-bland"})," · ",K("code",{children:"max-reached"})," ","· ",K("code",{children:"divergent"})]}),A("li",{children:[K("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),A("li",{children:["When ",K("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."]})]})]}),A("details",{children:[K("summary",{children:"Pin-to-element flow"}),A("ol",{children:[K("li",{children:"Open a canvas"}),A("li",{children:[K("kbd",{children:"⌘"}),"+click element"]}),K("li",{children:"Status bar shows ● selector"}),A("li",{children:["Run"," ",A("code",{children:['/design:edit "',K("i",{children:"change just this"}),'"']})]}),A("li",{children:["Reload iframe (",K("kbd",{children:"⌘R"}),")"]})]})]}),A("details",{children:[K("summary",{children:"Comments"}),A("ol",{children:[A("li",{children:[K("kbd",{children:"⌘"}),"+click element, then ",K("kbd",{children:"⌘C"})," ",K("span",{children:"or ⌘⇧+click"})]}),K("li",{children:"Numbered pin appears on canvas"}),A("li",{children:[K("kbd",{children:"⌘⇧M"})," ",K("span",{children:"opens panel — All / Open / Resolved"})]}),A("li",{children:["Click row in panel ",K("span",{children:"jumps to that file + pin"})]}),A("li",{children:["Claude reads ",K("code",{children:"_comments/<slug>.json"})," on next ",K("code",{children:"/design"})]})]})]})]})]})})}var YR=[{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 Rq0({kbd:X,alt:J}){let Q=(Y,W)=>K("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>K(t6,{children:G},`${G}-${Z}`))},W);return A("span",{className:"so-combos",children:[Q(X,"main"),J?J.split(" / ").map((Y)=>A(W0,{children:[K("span",{className:"so-or",children:"/"}),Q(Y,Y)]},Y)):null]})}function Iq0({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=YR.reduce((Y,W)=>Y+W.items.length,0);return K("div",{className:"st-scrim",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:A("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[A("div",{className:"so-overlay-hd",children:[K("span",{className:"so-title",children:"Keyboard shortcuts"}),A("span",{className:"so-trigger",children:["press ",K(t6,{children:"?"})," to open"]})]}),K("div",{className:"so-columns",children:YR.map((Y)=>A("section",{className:"so-section so-section--"+Y.id,children:[K("h3",{className:"so-section-hd",children:Y.label}),K("dl",{className:"so-list",children:Y.items.map((W)=>A("div",{className:"so-pair",children:[K("dt",{children:W.label}),K("dd",{children:K(Rq0,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),A("div",{className:"so-overlay-ft",children:[A("span",{children:["close with ",K(t6,{children:"Esc"})]}),A("span",{className:"so-count",children:[Q," bindings · ",YR.length," groups"]})]})]})})}var kq0=["File","Edit","View","Selection","Tools","Help"];function Ne(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 Tq0({panels:X,onToggle:J,onClose:Q,onZoom:Y,hasCanvas:W}){return Ne(Q),A("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[K("div",{className:"st-dd-hd",children:"Panels"}),X.map((G)=>A("button",{type:"button",role:"menuitem",className:"st-dd-item"+(G.checked?" is-on":""),"aria-disabled":G.disabled?"true":void 0,onClick:()=>{if(!G.disabled)J(G.id),Q()},children:[A("span",{className:"st-dd-lead",children:[K("span",{className:"st-dd-check",children:G.checked?K(G9,{name:"check",size:13}):null}),K("span",{children:G.label}),G.phase?K("span",{className:"st-dd-phase",children:G.phase}):null]}),G.shortcut?K(t6,{children:G.shortcut}):null]},G.id)),K("div",{className:"st-dd-sep"}),K("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)=>A("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":W?void 0:"true",onClick:()=>{if(!W)return;Y?.(G.op),Q()},children:[A("span",{className:"st-dd-lead",children:[K("span",{className:"st-dd-check"}),K("span",{children:G.label})]}),K(t6,{children:G.shortcut})]},G.label))]})}function QK({label:X,left:J,header:Q,items:Y,onAction:W,onClose:G}){return Ne(G),A("div",{className:"st-dropdown",role:"menu","aria-label":X,style:{left:J},children:[Q?K("div",{className:"st-dd-hd",children:Q}):null,Y.map((Z,H)=>Z.sep?K("div",{className:"st-dd-sep"},"s"+H):A("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:[A("span",{className:"st-dd-lead",children:[K("span",{className:"st-dd-check"}),K("span",{children:Z.label})]}),Z.shortcut?K(t6,{children:Z.shortcut}):null]},Z.id))]})}function Cq0({onAction:X,onClose:J}){return K(QK,{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"},...p8()?[{id:"collab-tour",label:"How sharing works"}]:[],...p8()?[{id:"quick-setup",label:"Quick setup"}]:[],...p8()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function $q0({onAction:X,onClose:J,readOnly:Q=!1}){return K(QK,{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 Sq0({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 K(QK,{label:"Tools",left:290,header:"Tool palette",onAction:X,onClose:J,items:Y})}function bq0({onAction:X,onClose:J,hasCanvas:Q,readOnly:Y=!1}){return K(QK,{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 jq0({onAction:X,onClose:J,hasCanvas:Q,readOnly:Y=!1}){if(Y)return K(QK,{label:"Edit",left:90,onAction:X,onClose:J,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"}]});return K(QK,{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 yq0({activePath:X,project:J,tabsCount:Q,openMenu:Y,setOpenMenu:W,commentsPanelOpen:G,onToggleComments:Z,changesOpen:H,changesCount:z,onToggleChanges:U,onOpenSystem:q,sidebarOpen:B,onToggleSidebar:F,showHidden:O,onToggleShowHidden:M,onOpenHelp:E,onOpenShortcuts:I,onReportBug:P,onStartTour:w,onStartCollabTour:R,annotationsVisible:T,onToggleAnnotations:C,minimapVisible:b,onToggleMinimap:$,zoomCtlVisible:y,onToggleZoomCtl:v,presentMode:g,onTogglePresent:m,printGuidesVisible:c,onTogglePrintGuides:f,postToActiveCanvas:l,onOpenWhatsNew:p,onOpenReadiness:h,onOpenQuickSetup:s,onWatchIntro:a,whatsNewCount:i,exportCenter:K0,artboardCount:e=0,presence:r=null,inspectorOpen:n,inspectorTab:U0,onToggleInspector:f0,autoOpenInspector:J8,onToggleAutoOpenInspector:W8,onOpenLayers:n0,timelineOpen:M0,onToggleTimeline:c0,hasComps:e0=!1,assistantOpen:C8,onToggleAssistant:t0,assistantBusy:h8,assistantUnseen:j0,onNewCanvas:g0,onAssembleVideo:A8,onOpenExport:r8,onOpenSettings:R9,onOpenGenerate:$0,onReload:V9,onCloseCanvas:I0,onInsertArtboard:Z8,readOnly:H0=!1}){let k0=X===S8,F0=k0?"SYSTEM":X?"CANVAS":"IDLE",G8=k0?K("b",{children:"design system"}):X?A(W0,{children:[X.split("/").slice(0,-1).join("/"),"/",K("b",{children:AW(dN(X))})]}):K("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),T8=new Set(["assistant","inspector","layers","autoopen"]),Q8=[{id:"tree",label:"Project Tree",shortcut:"T",checked:B,disabled:!1},{id:"changes",label:z>0?`Changes · ${z} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:H,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:G,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:O,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:n&&U0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:n,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!J8,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:e0?"video":void 0,checked:M0,disabled:!1},...p8()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:C8,disabled:!1}]:[],{id:"annotate",label:"Annotations",shortcut:"⇧ P",checked:T,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:b,disabled:!X||k0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:y,disabled:!X||k0},{id:"present",label:"Presentation Mode",shortcut:"",checked:g,disabled:!X||k0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:c,disabled:!X||k0}].filter((w0)=>!H0||!T8.has(w0.id)),R8=["file","edit","view","selection","tools","help"];function P0(w0){if(R8.includes(w0))W(Y===w0?null:w0)}return u.useEffect(()=>{if(!Y||!R8.includes(Y))return;let w0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function a0(N0){let m0=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!m0.length)return;let B8=m0.indexOf(document.activeElement);if(N0.key==="ArrowDown")N0.preventDefault(),m0[(B8+1)%m0.length].focus();else if(N0.key==="ArrowUp")N0.preventDefault(),m0[(B8-1+m0.length)%m0.length].focus();else if(N0.key==="Home")N0.preventDefault(),m0[0].focus();else if(N0.key==="End")N0.preventDefault(),m0[m0.length-1].focus();else if(N0.key==="ArrowRight"||N0.key==="ArrowLeft"){N0.preventDefault();let i8=N0.key==="ArrowRight"?1:-1,Q9=R8.indexOf(Y);W(R8[(Q9+i8+R8.length)%R8.length])}else if(N0.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",a0),()=>{clearTimeout(w0),window.removeEventListener("keydown",a0)}},[Y,W]),A("header",{className:"st-menubar",role:"menubar","aria-label":"Application menubar",children:[A("span",{className:"st-brand","data-tour":"brand",children:[K("span",{className:"st-brand-mark",children:K("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:K("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),K("span",{className:"st-brand-name",children:"maude"})]}),K("nav",{className:"st-menus","aria-label":"Application menus","data-tour":"menus",children:kq0.map((w0)=>{let a0=w0.toLowerCase(),N0=R8.includes(a0),m0=N0||a0==="help";return K("button",{type:"button",className:"st-menu",role:"menuitem","data-tour":a0==="help"?"help":void 0,"aria-haspopup":N0?"menu":void 0,"aria-expanded":N0?Y===a0:void 0,onClick:()=>P0(a0),onMouseEnter:()=>{if(Y!==null&&N0)W(a0)},children:w0},a0)})}),Y==="file"&&K(bq0,{readOnly:H0,hasCanvas:!!X,onAction:(w0)=>{if(w0==="new")g0?.();else if(w0==="assemble")A8?.();else if(w0==="export")r8?.("export");else if(w0==="handoff")r8?.("handoff");else if(w0==="generate")$0?.();else if(w0==="settings")R9?.();else if(w0==="reload")V9?.();else if(w0==="close")I0?.()},onClose:()=>W(null)}),Y==="edit"&&K(jq0,{readOnly:H0,hasCanvas:!!X&&!k0,onAction:(w0)=>{if(w0==="undo")l({dgn:"undo"});else if(w0==="redo")l({dgn:"redo"});else if(w0==="deselect-all")l({dgn:"selection-clear"});else if(w0==="select-all-annotations")l({dgn:"annotation-select-all"});else if(w0.startsWith("new-artboard:"))Z8?.(w0.slice(13))},onClose:()=>W(null)}),Y==="view"&&K(Tq0,{panels:Q8,onToggle:(w0)=>{if(w0==="tree")F();else if(w0==="changes")U();else if(w0==="comments")Z();else if(w0==="hidden")M();else if(w0==="annotate")C();else if(w0==="inspector")f0();else if(w0==="autoopen")W8?.();else if(w0==="timeline")c0?.();else if(w0==="assistant")t0?.();else if(w0==="layers")n0?.();else if(w0==="minimap")$?.();else if(w0==="zoomctl")v?.();else if(w0==="present")m?.();else if(w0==="print-guides")f?.()},onZoom:(w0)=>l({dgn:"zoom",op:w0}),hasCanvas:!!X&&!k0,onClose:()=>W(null)}),Y==="selection"&&K($q0,{readOnly:H0,onAction:(w0)=>{if(w0==="deselect-all")l({dgn:"selection-clear"});else if(w0==="select-all-annotations")l({dgn:"annotation-select-all"})},onClose:()=>W(null)}),Y==="tools"&&K(Sq0,{readOnly:H0,onAction:(w0)=>l({dgn:"tool-set",tool:w0}),onClose:()=>W(null)}),Y==="help"&&K(Cq0,{onAction:(w0)=>{if(w0==="shortcuts")I?.();else if(w0==="help")E?.();else if(w0==="report-bug")P?.();else if(w0==="tour")w?.();else if(w0==="collab-tour")R?.();else if(w0==="quick-setup")s?.();else if(w0==="readiness")h?.();else if(w0==="whatsnew")p?.();else if(w0==="watch-intro")a?.()},onClose:()=>W(null)}),A("div",{className:"st-mb-right","data-tour":"status",children:[r?K("div",{className:"st-presence",children:r}):null,H0&&K("span",{className:"st-stamp st-stamp--viewonly","data-testid":"view-only-stamp","data-tip":"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"}),p8()&&!H0&&K("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":C8?"true":"false","data-busy":h8?"true":"false","data-unseen":j0?"true":"false","aria-label":`Assistant${h8?" — working":j0?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:t0,children:K(G9,{name:"sparkle",size:15})}),K0&&K(Zx,{center:K0}),K("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":i>0?"true":"false","aria-label":`What's new${i>0?` — ${i} unseen`:""}`,"data-tip":"What's new",onClick:p,children:K(G9,{name:"megaphone",size:15})}),K("span",{className:"st-stamp",children:F0}),K("span",{className:"st-mb-file",title:X||"",children:G8}),K("span",{className:"st-mb-sep"}),A("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[K("span",{className:"st-dot",style:{background:"var(--accent)"}}),e," ARTBOARDS"]}),K("span",{className:"st-mb-sep"}),K("span",{className:"st-mb-proj",children:J||"maude"})]})]})}function fq0({tabs:X,activePath:J,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:z,onIframeLoad:U,showQuickSetup:q,onStartQuickSetup:B}){return A("div",{className:"viewport st-stage","data-tour":"viewport",children:[X.length===0&&A("div",{className:"st-empty",children:[A("div",{className:"st-empty-brand",children:[K("span",{className:"st-brand-mark",children:K("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:K("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),K("span",{className:"st-empty-wm",children:"maude"}),A("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(Z||"MAUDE").toUpperCase()," / v",HR," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),K("div",{className:"st-empty-title",children:"Nothing open yet"}),A("div",{className:"st-empty-body",children:["← Pick a screen from the list on the left, or open ",K("strong",{children:"Design system"})," above it to see your colors, type, and components.",K("br",{}),K("br",{}),K("strong",{children:"To select something on the canvas:"})," hold ",K(t6,{children:"⌘"})," and hover to preview an element, click to select it — ",K(t6,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",p8()?A(W0,{children:[K("br",{}),K("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&&K("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((F)=>{if(F.path===S8)return K("div",{className:"system-view"+(F.path===J?" active":""),children:K(pq0,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},F.path);return K("iframe",{ref:(O)=>Q(F.path,O),src:sH(F.path,H),className:F.path===J?"active":"","data-path":F.path,"data-testid":F.path===J?"canvas-frame":void 0,onLoad:()=>U?.(F.path),...H?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},F.path)}),z&&z===J&&K("div",{className:"st-canvas-loading","aria-hidden":"true",children:A("div",{className:"st-skel-card",children:[K("div",{className:"st-skel-cap st-mono",children:"compiling canvas…"}),K("span",{className:"skel st-skel-thumb"}),K("span",{className:"skel st-skel-line",style:{width:"72%"}}),K("span",{className:"skel st-skel-line",style:{width:"46%"}})]})})]})}var vq0=["color","space","radius","shadow","leading","weight","motion","font","other"],xq0={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function hq0(X){return X==="color"}function gq0({tokens:X,tokenGroups:J,tokensPath:Q}){if(!X||X.length===0)return A("section",{className:"sv-section sv-section-tokens",children:[A("h2",{children:["tokens",K("span",{className:"sv-h-num",children:"0"})]}),K("div",{className:"sv-empty",children:A("p",{children:["No tokens parsed from"," ",Q?K("code",{children:Q}):"the configured tokens file",". Does the file exist and contain CSS custom properties (",K("code",{children:"--name: value;"}),")?"]})})]});let Y=J||{},W=Array.from(new Set([...vq0,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return K(W0,{children:W.map((G)=>{let Z=Y[G],H=hq0(G);return A("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[A("h2",{children:["tokens · ",xq0[G]||G,K("span",{className:"sv-h-num",children:Z.length})]}),K("div",{className:"sv-tokens-ladder",children:Z.map((z)=>A("div",{className:"sv-tok-cell",children:[H?K("div",{className:"sv-tok-swatch",style:{background:z.value}}):null,A("div",{className:"sv-tok-meta",children:[K("code",{className:"sv-tok-name",children:z.name}),K("span",{className:"sv-tok-value",children:z.value||"—"})]})]},z.name+"|"+z.value))})]},G)})})}function mq0(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 uq0(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 lq0({tokenGroups:X}){let J=X?.fontsize||[];if(J.length===0)return null;let Q=X?.leading||[],Y=uq0(X?.font);return A("section",{className:"sv-section sv-section-type",children:[A("h2",{children:["type · ladder",K("span",{className:"sv-h-num",children:J.length})]}),K("div",{className:"sv-type-list",children:J.map((W)=>{let G=mq0(W,Q),Z={fontSize:W.value};if(G)Z.lineHeight=G;if(Y)Z.fontFamily=Y;return A("div",{className:"sv-type-row",children:[K("code",{className:"sv-type-tok",children:W.name}),K("span",{className:"sv-type-sample",style:Z,children:"The catalog is the system."})]},W.name)})})]})}function pq0({data:X,onOpen:J,cfg:Q,onSelectDs:Y}){if(!X)return K("div",{className:"sv-empty",children:K("p",{children:"Loading design system…"})});let{previewGallery:W,uiKitsGallery:G,systemDir:Z,tokens:H,tokenGroups:z,tokensPath:U,ds:q,availableDesignSystems:B}=X,F=(!W||!W.length)&&(!G||!G.length),O=Array.isArray(B)&&B.length>1,M=q?.name??B?.[0]?.name??"";return A("div",{className:"sv",children:[A("header",{className:"sv-header",children:[K("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),K("span",{className:"sv-title",children:"design system view"}),O?A("label",{className:"sv-ds-picker",children:[K("span",{className:"sv-ds-picker-label",children:"DS"}),K("select",{value:M,onChange:(E)=>Y&&Y(E.target.value),children:B.map((E)=>K("option",{value:E.name,children:E.name},E.name))})]}):null,K("span",{className:"sv-loc",children:K("code",{children:Z})})]}),q?.description?K("p",{className:"sv-ds-description",children:q.description}):null,K(gq0,{tokens:H,tokenGroups:z,tokensPath:U}),K(lq0,{tokenGroups:z}),F?K("div",{className:"sv-empty",children:A("p",{children:["No ",K("code",{children:"preview/"})," or ",K("code",{children:"ui_kits/"})," folders found under"," ",K("code",{children:Z}),"."]})}):A(W0,{children:[K(nt,{title:"preview",items:W,onOpen:J,kind:"preview",cfg:Q}),K(nt,{title:"ui kits",items:G,onOpen:J,kind:"ui_kits",cfg:Q})]})]})}function nt({title:X,items:J,onOpen:Q,kind:Y,cfg:W}){if(!J||J.length===0)return null;return A("section",{className:"sv-section",children:[A("h2",{children:[X," ",K("span",{className:"sv-count",children:J.length})]}),K("div",{className:"sv-previews sv-previews-"+Y,children:J.map((G)=>A("article",{className:"sv-preview-card",onClick:()=>Q(G.path),children:[K("div",{className:"sv-preview-frame",children:K("iframe",{src:sH(G.path,W,{thumbnail:!0}),title:G.label,scrolling:"no",...W?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),A("div",{className:"sv-preview-foot",children:[K("strong",{children:G.label}),K("code",{children:G.path})]})]},G.path))})]})}function dq0({activePath:X,selected:J,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,changesCount:z=0,unpushed:U=0,changesOpen:q=!1,onOpenChanges:B}){let F=X===S8,O=J&&J.selector?J.selector+(J.text?` — "${J.text.slice(0,60)}"`:""):"",M=J&&J.dom_path?J.dom_path.join(" > "):J?J.selector:"",E=W==="dark"?"light":"dark",I=(()=>{if(!H||H.linked===!1)return null;if(H.notSyncable)return{online:!1,label:`0 syncable${H.tsxCount>0?` · ${H.tsxCount} tsx`:""}`,title:H.reason||"Linked to a hub, but no canvases are syncable."};let P=H.queuedOps??0;if(H.state==="online"||H.flash==="synced")return{online:!0,label:P>0?`${P} ↑`:"synced",title:P>0?`${P} edit(s) queued to push`:"All changes synced to the hub"};return{online:!1,label:`${P} ↑`,title:H.state==="connecting"?"Connecting to the hub…":"Offline — edits queued, will sync when the hub reconnects"}})();return A("footer",{className:"st-statusbar",role:"contentinfo",children:[A("span",{className:"st-sb-slot st-sb-active",role:"group","aria-label":"Active file",children:[K("span",{className:"lead","aria-hidden":"true"}),K("span",{className:"lbl",children:"active"}),K("span",{className:"val",title:X||"",children:F?"▦ design system":X||"—"})]}),X&&J&&J.selector&&!F&&A("span",{className:"st-sb-slot st-sb-sel",role:"group","aria-label":"Selected element",children:[K("span",{className:"lbl",children:"selected"}),K("span",{className:"val",title:M,children:O}),K("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:"×"})]}),A("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[K("span",{className:"lbl",children:"comments"}),A("span",{className:"val",children:[Y," open"]})]}),B&&A("button",{type:"button",className:"st-sb-slot st-sb-changes"+(q?" is-open":"")+(z>0?" has-changes":U>0?" has-unpushed":""),onClick:B,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":q,children:[K("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),K("span",{className:"lbl",children:"changes"}),K("span",{className:"val",children:z>0?`${z} unsaved`:U>0?`${U} to publish`:"all saved"})]}),K("span",{className:"st-sb-spacer"}),A("span",{className:"st-sb-slot",role:"group","aria-label":"Connection",children:[K("span",{className:"st-live-dot"+(Q?" is-connected":""),"aria-hidden":"true"}),K("span",{className:"lbl",children:Q?"live":"reconnecting"})]}),I&&A("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:[K("span",{className:"st-sb-sync-dot"+(I.online?" is-online":""),"aria-hidden":"true"}),K("span",{className:"lbl",children:"hub sync"}),K("span",{className:"val",title:I.title,children:I.label})]}),A("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${E} theme`,"data-tip-pos":"top","aria-label":`Switch to ${E} theme`,children:[K(G9,{name:W==="dark"?"sun":"moon",size:13}),E]})]})}function cq0({commentsByFile:X,filter:J,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:z,width:U,resizing:q}){let B=qe(X),F=Object.keys(X||{}).sort(),O=[];for(let M of F){let E=X[M]||[],I=E.filter((w)=>{if(J==="open")return w.status!=="resolved";if(J==="resolved")return w.status==="resolved";return!0});if(I.length===0)continue;let P=E.filter((w)=>w.selector);O.push({file:M,comments:I.map((w)=>({...w,n:P.findIndex((R)=>R.id===w.id)+1}))})}return A("aside",{className:"st-rpanel"+(q?" is-resizing":""),style:U?{width:U,flexBasis:U}:void 0,"aria-label":"Comments",children:[K("div",{className:"st-rp-tabs st-rp-tabs--filters",children:A("div",{className:"st-cm-filters",role:"tablist",children:[A("button",{type:"button",className:"st-cm-filter"+(J==="all"?" is-active":""),role:"tab","aria-selected":J==="all",onClick:()=>Q("all"),children:["All · ",B.all]}),A("button",{type:"button",className:"st-cm-filter"+(J==="open"?" is-active":""),role:"tab","aria-selected":J==="open",onClick:()=>Q("open"),children:["Open · ",B.open]}),A("button",{type:"button",className:"st-cm-filter"+(J==="resolved"?" is-active":""),role:"tab","aria-selected":J==="resolved",onClick:()=>Q("resolved"),children:["Resolved · ",B.resolved]})]})}),K("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:O.length===0?A("div",{className:"st-rp-empty",children:[A("p",{children:["No comments ",J!=="all"?`with status “${J}”`:"yet","."]}),A("p",{children:["Open a canvas, hold ",K(t6,{children:"⌘"})," and click an element, then press ",K(t6,{children:"C"})," — or hold ",K(t6,{children:"⌘⇧"})," and click directly."]})]}):O.map((M)=>A(W0,{children:[A("button",{type:"button",className:"st-cm-group-hd",onClick:()=>G(M.file,null),title:M.file,children:[K("span",{children:AW(dN(M.file))}),K("span",{className:"st-mono",children:M.comments.length})]}),M.comments.map((E)=>A("div",{className:"st-comment"+(E.status==="resolved"?" is-resolved":"")+(E.id===W?" is-active":""),onClick:()=>G(M.file,E.id),children:[A("div",{className:"st-comment-hd",children:[K("span",{className:"st-pin st-pin--inline",children:E.n||"·"}),K("span",{className:"st-comment-time",children:Zq0(E.created)})]}),K("div",{className:"st-comment-txt",children:E.text}),A("div",{className:"st-comment-foot",children:[K("span",{className:"st-comment-sel",title:(E.dom_path||[]).join(" > "),children:E.selector||"—"}),Z&&H&&z?A("span",{className:"st-mini-act",children:[E.status==="resolved"?K("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(I)=>{I.stopPropagation(),H(E.id)},children:K(G9,{name:"reopen",size:14})}):K("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(I)=>{I.stopPropagation(),Z(E.id)},children:K(G9,{name:"resolve",size:14})}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(I)=>{I.stopPropagation(),z(E.id)},children:K(G9,{name:"x",size:14})})]}):null]})]},E.id))]},M.file))})]})}function iq0({update:X,onDismiss:J}){let[Q,Y]=u.useState(!1);if(!X)return null;let W=X.version?` (v${X.version})`:"";return A("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[K("span",{className:"st-banner-dot","aria-hidden":"true"}),A("span",{children:["Maude updated",W," · restart to apply"]}),K("button",{type:"button",className:"btn btn--primary btn--sm",disabled:Q,onClick:()=>{Y(!0),xf().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),K("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:J,children:"Later"})]})}function oq0({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",z=Y==="offline"||Y==="offline-long",U=X.docs?.rejected??0,q=Array.isArray(Z)?[...Z].reverse().find((M)=>M.kind==="cold-start-diverged"):null;if(!z&&!H&&!q&&U===0)return null;let B,F,O;if(H)B="success",F="Synced with hub",O=`${Y}:flash`;else if(z){let M=Z&&Z.length>0?` (${Z.length} conflict notice(s))`:"";if(Y==="offline-long")B="error",F=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${M}`;else B="warn",F=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${M}`;O=`${Y}:offline`}else if(q){if(q.snapshotFailed)B="error",F=`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",F=`Diverged on ${q.slug}: kept the ${q.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${q.slug}`;O=`diverged:${q.slug}:${q.at}`}else B="warn",F=`${U} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,O=`rejected:${U}`;if(J===O)return null;return A("div",{role:"status","aria-live":"polite",className:`st-banner st-banner--${B}`,children:[K("span",{className:"st-banner-dot","aria-hidden":"true"}),K("span",{children:F}),K("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(O),children:"×"})]})}var nq0=["block","inline-block","flex","inline-flex","grid","inline","none"],rt=["px","%","fr","em","auto","min-content","max-content"];var rq0=["auto","stretch","flex-start","center","flex-end","baseline"];var at=["300","400","500","600","700","800"],st=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],tt=["none","solid","dashed","dotted","double"],et=["px","rem","em","%","vw","vh","auto"],Xe=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),WR={"font-size":{node:K(h9,{as:T1,size:12})},"line-height":{node:K(h9,{as:f1,size:12})},"letter-spacing":{node:K(h9,{as:d1,size:12})},gap:{node:K(h9,{as:Tz,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:K(h9,{as:r1,size:12})},"border-width":{node:K(h9,{as:p1,size:12})}};var Je=["static","relative","absolute","fixed","sticky"],aq0=["normal","italic","oblique"],Qe=["none","uppercase","lowercase","capitalize"];var Ye=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],sq0=["fill","contain","cover","none","scale-down"];var We=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Ge=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],Z5={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}},XK=null;function pN(X){if(!X)return"";if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();try{if(!XK)XK=document.createElement("canvas").getContext("2d");if(!XK)return"";XK.fillStyle="#000000",XK.fillStyle=X;let J=XK.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 TY=(X)=>Math.min(1,Math.max(0,X));function gN(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 Wq({r:X,g:J,b:Q}){return`#${[X,J,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function Gq({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 JK({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,z=0;if(X<60)[Z,H,z]=[Y,W,0];else if(X<120)[Z,H,z]=[W,Y,0];else if(X<180)[Z,H,z]=[0,Y,W];else if(X<240)[Z,H,z]=[0,W,Y];else if(X<300)[Z,H,z]=[W,0,Y];else[Z,H,z]=[Y,0,W];return{r:(Z+G)*255,g:(H+G)*255,b:(z+G)*255}}function m9(X){if(!X)return"";let J=/^(-?\d*\.?\d+)px$/.exec(X);return J?`${Math.round(Number.parseFloat(J[1]))}px`:X}function _Q(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 Ze(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 Fe(X,J){return(X?J?.canvasDesignSystems?.[X]:null)||J?.defaultDesignSystem||J?.designSystems?.[0]?.name||null}function tq0(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],z=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(H);Q[Z]=z&&J[z[1]]?J[z[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 Le(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(z)=>{if(!z.tokensCssRel)return null;try{let U=await fetch(`/${J}/${z.tokensCssRel}`),q=U.ok?await U.text():"";return{name:z.name,...tq0(q)}}catch{return null}})).then((z)=>{if(H)return;let U=z.filter(Boolean);U.sort((q,B)=>q.name===Q?-1:B.name===Q?1:0),Z(U)}),()=>{H=!0}},[W,J,Q]),G}function De({seed:X,label:J,onApply:Q}){let[Y,W]=u.useState(()=>Gq(gN(X||"#000000"))),G=u.useRef(Y);G.current=Y;let Z=u.useRef(null),H=u.useRef(null),z=u.useRef(X);u.useEffect(()=>{if(X&&X!==z.current)z.current=X,W(Gq(gN(X)))},[X]);let U=Wq(JK(Y)),q=(w)=>{w.preventDefault();let R=Z.current?.getBoundingClientRect();if(!R)return;let T=G.current.h,C=($)=>{W({h:T,s:TY(($.clientX-R.left)/R.width),v:TY(1-($.clientY-R.top)/R.height)})};C(w);let b=()=>{document.removeEventListener("pointermove",C),document.removeEventListener("pointerup",b),Q(Wq(JK(G.current)))};document.addEventListener("pointermove",C),document.addEventListener("pointerup",b)},B=(w)=>{w.preventDefault();let R=H.current?.getBoundingClientRect();if(!R)return;let{s:T,v:C}=G.current,b=(y)=>{W({h:TY((y.clientX-R.left)/R.width)*360,s:T,v:C})};b(w);let $=()=>{document.removeEventListener("pointermove",b),document.removeEventListener("pointerup",$),Q(Wq(JK(G.current)))};document.addEventListener("pointermove",b),document.addEventListener("pointerup",$)},F=(w)=>{let R={...G.current,...w};W(R),Q(Wq(JK(R)))},O=(w)=>{let R=w.shiftKey?0.1:0.02,C={ArrowLeft:[-R,0],ArrowRight:[R,0],ArrowUp:[0,R],ArrowDown:[0,-R]}[w.key];if(!C)return;w.preventDefault(),F({s:TY(G.current.s+C[0]),v:TY(G.current.v+C[1])})},M=(w)=>{let R=w.shiftKey?20:2,C={ArrowLeft:-R,ArrowRight:R}[w.key];if(C==null)return;w.preventDefault(),F({h:Math.min(360,Math.max(0,G.current.h+C))})},E=async()=>{try{let w=window.EyeDropper;if(!w)return;let R=await new w().open();if(R?.sRGBHex)W(Gq(gN(R.sRGBHex))),Q(R.sRGBHex)}catch{}},I=JK(Y),P=(w)=>{let R={...I,...w},T=Gq({r:TY(R.r/255)*255,g:TY(R.g/255)*255,b:TY(R.b/255)*255});W(T),Q(Wq(JK(T)))};return A("div",{className:"st-cp-cpick",children:[A("div",{className:"st-cp-cpick-hexrow",children:[K("span",{className:"st-cp-cpick-hexsw",style:{background:U}}),K("input",{className:"st-cp-cpick-hex",type:"text",value:U,"aria-label":J?`${J} hex value`:"hex value",onChange:(w)=>{let R=w.target.value;if(/^#?[0-9a-f]{6}$/i.test(R))W(Gq(gN(R)))},onKeyDown:(w)=>{if(w.key==="Enter")Q(w.currentTarget.value)},onBlur:(w)=>Q(w.currentTarget.value),onFocus:(w)=>w.currentTarget.select()})]}),A("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:O,children:[K("span",{className:"st-cp-cpick-svwhite"}),K("span",{className:"st-cp-cpick-svblack"}),K("span",{className:"st-cp-cpick-knob",style:{left:`${Y.s*100}%`,top:`${(1-Y.v)*100}%`,background:U}})]}),A("div",{className:"st-cp-cpick-controls",children:[window.EyeDropper?K("button",{type:"button",className:"st-cp-cpick-eye","aria-label":"pick from screen",title:"eyedropper",onClick:E,children:K(G9,{name:"eyedropper",size:14})}):null,K("span",{className:"st-cp-cpick-preview",style:{background:U},"aria-hidden":"true"}),K("button",{type:"button",ref:H,className:"st-cp-cpick-hue","aria-label":J?`${J} hue`:"hue",onPointerDown:B,onKeyDown:M,children:K("span",{className:"st-cp-cpick-huethumb",style:{left:`${Y.h/360*100}%`}})})]}),K("div",{className:"st-cp-cpick-rgb",children:["r","g","b"].map((w)=>A("label",{className:"st-cp-cpick-rgbf",children:[K("input",{"aria-label":w.toUpperCase(),value:Math.round(I[w]),onChange:(R)=>P({[w]:TY((Number.parseFloat(R.target.value)||0)/255)*255}),onFocus:(R)=>R.currentTarget.select()}),K("span",{children:w.toUpperCase()})]},w))})]})}function mN({kind:X,groups:J,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:z}){let[U,q]=u.useState(!1),[B,F]=u.useState(null),[O,M]=u.useState("custom"),[E,I]=u.useState(""),P=u.useRef(null),w=u.useRef(null),R=typeof Q==="string"&&/var\(\s*--/.test(Q),T=(a)=>Q===`var(${a})`,C=(a)=>a.replace(/^--/,"").replace(/-/g," "),b=J||[],$=b.reduce((a,i)=>a+(i.names?.length||0),0),y=b.length>1,v=E.trim().toLowerCase(),g=!v?b:b.map((a)=>({...a,names:(a.names||[]).filter((i)=>C(i).toLowerCase().includes(v)||i.toLowerCase().includes(v)||(a.vals?.[i]||"").toLowerCase().includes(v))})).filter((a)=>a.names.length);u.useEffect(()=>{if(!U){I("");return}let a=()=>{let r=P.current?.getBoundingClientRect();if(!r)return;let n=224,U0=300,f0=Math.min(r.right-n,window.innerWidth-n-8);if(f0<8)f0=8;let W8=window.innerHeight-r.bottom>U0+8?r.bottom+4:Math.max(8,r.top-U0-4);F({left:f0,top:W8,width:n,maxHeight:U0})};a();let i=(r)=>{if(w.current?.contains(r.target)||P.current?.contains(r.target))return;q(!1)},K0=(r)=>{if(r.key==="Escape")q(!1)},e=(r)=>{if(w.current?.contains(r.target))return;a()};return document.addEventListener("pointerdown",i,!0),document.addEventListener("keydown",K0),window.addEventListener("resize",a),document.addEventListener("scroll",e,!0),()=>{document.removeEventListener("pointerdown",i,!0),document.removeEventListener("keydown",K0),window.removeEventListener("resize",a),document.removeEventListener("scroll",e,!0)}},[U]),u.useEffect(()=>{if(!U||!B||!w.current)return;let a=w.current.getBoundingClientRect(),i=B.left-a.left,K0=B.top-a.top;if(Math.abs(i)>0.5||Math.abs(K0)>0.5)F((e)=>e?{...e,left:e.left+i,top:e.top+K0}:e)},[U,B]);let m=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,c=(a,i,K0)=>{if(H&&a&&a!==H&&K0&&!m.test(K0))Y(K0);else Y(`var(${i})`);q(!1)},f=(a)=>{let i=(a||"").trim();if(i)Y(i)},l=A("div",{className:"st-cp-pop-search",children:[K(G9,{name:"search",size:12}),K("input",{value:E,onChange:(a)=>I(a.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),p=(a)=>a.map((i)=>A("div",{className:"st-cp-pop-group",children:[y?K("div",{className:"st-cp-pop-ds",children:i.ds}):null,K("div",{className:"st-cp-pop-list",children:i.names.map((K0)=>A("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${T(K0)?" is-on":""}`,onClick:()=>c(i.ds,K0,i.vals?.[K0]),children:[K("span",{className:"st-cp-pop-cswatch",style:{background:i.vals?.[K0]||"transparent"},"aria-hidden":"true"}),K("span",{className:"st-cp-pop-name",children:C(K0)}),K("span",{className:"st-cp-pop-val",children:i.vals?.[K0]||""})]},`${i.ds}:${K0}`))})]},i.ds)),h=(a)=>a.map((i)=>A("div",{className:"st-cp-pop-group",children:[y?K("div",{className:"st-cp-pop-ds",children:i.ds}):null,K("div",{className:"st-cp-pop-list",children:i.names.map((K0)=>A("button",{type:"button",className:`st-cp-pop-row${T(K0)?" is-on":""}`,onClick:()=>c(i.ds,K0,i.vals?.[K0]),children:[K("span",{className:"st-cp-pop-name",children:C(K0)}),K("span",{className:"st-cp-pop-val",children:i.vals?.[K0]||""})]},`${i.ds}:${K0}`))})]},i.ds)),s=K("div",{className:"st-cp-pop-empty",children:"No match"});return A(W0,{children:[G!==void 0?K("button",{type:"button",ref:P,className:`${z||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${R&&!z?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>q((a)=>!a),children:K("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):K("button",{type:"button",ref:P,className:`st-cp-tokbtn${R?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>q((a)=>!a),children:K("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),U&&B?ze.createPortal(K("div",{ref:w,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"?A(W0,{children:[A("div",{className:"st-cp-poptabs",role:"tablist",children:[K("button",{type:"button",role:"tab","aria-selected":O==="custom",className:`st-cp-poptab${O==="custom"?" is-active":""}`,onClick:()=>M("custom"),children:"Custom"}),K("button",{type:"button",role:"tab","aria-selected":O==="vars",className:`st-cp-poptab${O==="vars"?" is-active":""}`,onClick:()=>M("vars"),children:"Variables"})]}),O==="custom"?K(De,{seed:Z||pN(Q)||"#000000",onApply:f}):!$?K("div",{className:"st-cp-pop-empty",children:"No color tokens"}):A(W0,{children:[l,g.length?p(g):s]})]}):!$?K("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):A(W0,{children:[l,g.length?h(g):s]})}),document.body):null]})}function He({label:X,tracks:J,editable:Q,onChange:Y}){let W=(z,U)=>{let q=J[z];Y(J.map((B,F)=>F===z?yU.has(U)?{value:0,unit:U}:{value:q.value||1,unit:U}:B))},G=(z,U)=>{Y(J.map((q,B)=>B===z?{...q,value:U}:q))},Z=()=>Y([...J,{value:1,unit:"fr"}]),H=(z)=>Y(J.filter((U,q)=>q!==z));return A("div",{className:"st-cp-gridtracks",children:[A("div",{className:"st-cp-gridtracks-hd",children:[K("span",{className:"st-cp-gridtracks-label",children:X}),K("button",{type:"button",className:"st-btn st-cp-gridtracks-add",disabled:!Q,onClick:Z,children:"+ Track"})]}),J.length===0?A("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",X.toLowerCase(),"."]}):J.map((z,U)=>{let q=yU.has(z.unit);return A("div",{className:"st-cp-gridtrack-row",children:[q?K(ZW,{value:z.unit,ariaLabel:`${X} track ${U+1}`,options:rt.map((B)=>({value:B,label:B})),onChange:(B)=>W(U,B)}):K(v6,{value:z.value,min:z.unit==="fr"?0.1:0,step:z.unit==="fr"?0.1:1,ariaLabel:`${X} track ${U+1} value`,lead:String(U+1),unitSlot:K(_B,{value:z.unit,units:rt,ariaLabel:`${X} track ${U+1} unit`,onChange:(B)=>W(U,B)}),onCommit:(B)=>G(U,B)}),K("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 eq0({el:X,cfg:J,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let z=!!X.id,U=X.computed||{},[q,B]=u.useState({a:{},c:{},t:{}});u.useEffect(()=>{B({a:{},c:{},t:{}})},[X.id]);let F=(t,q0)=>{let Z0={...t||{}};for(let[R0,u0]of Object.entries(q0))if(u0===null)delete Z0[R0];else Z0[R0]=u0;return Z0},O=F(X.authored,q.a),M=F(X.customStyles,q.c),E=F(X.attrs,q.t),I=(t,q0)=>B((Z0)=>({...Z0,a:{...Z0.a,[t]:q0}})),P=(t,q0)=>B((Z0)=>({...Z0,c:{...Z0.c,[t]:q0}})),w=(t,q0)=>B((Z0)=>({...Z0,t:{...Z0.t,[t]:q0}})),R=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),T=Fe(X.file,J),C=Le(J,R,T),b=(t)=>C.map((q0)=>({ds:q0.name,names:q0[t]||[],vals:q0.vals})).filter((q0)=>q0.names.length),[$,y]=u.useState({}),[v,g]=u.useState({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),m=Object.keys(M).length>0||Object.keys(E).length>0;u.useEffect(()=>{if(m)g((t)=>t.Advanced?t:{...t,Advanced:!0})},[X.id,m]);let c=(O.position||m9(U.position)||"static")!=="static";u.useEffect(()=>{if(c)g((t)=>t["d:Position"]?t:{...t,"d:Position":!0})},[X.id,c]);let f=H,[l,p]=u.useState({});async function h(t,q0,Z0){y((R0)=>({...R0,[Z0]:"saving"}));try{let R0=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(q0)}),u0=await R0.json().catch(()=>({}));y((w8)=>({...w8,[Z0]:!R0.ok||!u0.ok?`err:${u0&&u0.error||`HTTP ${R0.status}`}`:"saved"}))}catch(R0){y((u0)=>({...u0,[Z0]:`err:${R0&&R0.message?R0.message:String(R0)}`}))}}let s=(t,q0)=>{if(!Q||!X.id)return;Q({id:X.id,artboardId:X.artboardId??null,index:X.index??0,prop:t,value:q0})},a=(t,q0,Z0,R0)=>{Y?.({op:t,canvas:X.file,id:X.id,key:q0,before:Z0==null||Z0===""?null:Z0,after:R0==null||R0===""?null:R0})},i=(t,q0)=>{let Z0=(q0||"").trim();if(!z||!Z0)return;let R0=O[t]??null;if(Z0===(R0??"").trim())return;s(t,Z0),I(t,Z0),h("/_api/edit-css",{canvas:X.file,id:X.id,property:t,value:Z0},t),a("css",t,R0,Z0)},K0=(t,q0)=>{let Z0=(q0||"").trim(),R0=t.trim();if(!z||!R0||!Z0)return;let u0=M[R0]??null;s(R0,Z0),P(R0,Z0),h("/_api/edit-css",{canvas:X.file,id:X.id,property:R0,value:Z0},R0),a("css",R0,u0,Z0)},e=(t,q0)=>{let Z0=(t||"").trim(),R0=(q0||"").trim();if(!z||!Z0||!R0)return;let u0=E[Z0]??null;w(Z0,R0),h("/_api/edit-attr",{canvas:X.file,id:X.id,attr:Z0,value:R0},`@${Z0}`),a("attr",Z0,u0,R0)},r=(t)=>{if(!z)return;let q0=O[t]??null;s(t,null),I(t,null),h("/_api/edit-css",{canvas:X.file,id:X.id,property:t,reset:!0},t),a("css",t,q0,null)},n=(t)=>{if(!z)return;let q0=M[t]??null;s(t,null),P(t,null),h("/_api/edit-css",{canvas:X.file,id:X.id,property:t,reset:!0},t),a("css",t,q0,null)},U0=(t)=>{if(!z)return;let q0=E[t]??null;w(t,null),h("/_api/edit-attr",{canvas:X.file,id:X.id,attr:t,reset:!0},`@${t}`),a("attr",t,q0,null)},f0={display:X.parentDisplay,flexDirection:X.parentFlexDirection},J8=(t,q0)=>{if(!z)return;let Z0=Math.round((t==="width"?X.bounds?.w:X.bounds?.h)||0),R0=B$(t,q0,f0,Z0);for(let u0 of R0.reset)if(O[u0])r(u0);for(let[u0,w8]of R0.set)i(u0,w8)},W8=X.parentDisplay==="flex"||X.parentDisplay==="inline-flex",n0=(t)=>{let q0=q$(t,O,U,f0);return A("div",{className:"st-cp-moderow",children:[K("span",{className:"st-cp-modelabel",children:t==="width"?"Width sizing":"Height sizing"}),K("div",{className:"st-cp-modeseg",role:"group","aria-label":`${t} sizing mode`,children:K(AB,{value:q0,ariaLabel:`${t} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(Z0)=>J8(t,Z0)})})]},`mode-${t}`)},M0=["flex-start","center","flex-end"],c0=["flex-start","center","flex-end"],e0=["t","c","b"],C8=["l","c","r"],t0=()=>{let t=!(O["flex-direction"]||m9(U["flex-direction"])||"row").startsWith("column"),q0=Math.max(0,M0.indexOf(O["justify-content"]||m9(U["justify-content"])||"flex-start")),Z0=O["align-items"]||m9(U["align-items"])||"stretch",R0=Z0==="stretch"?1:Math.max(0,c0.indexOf(Z0)),[u0,w8]=t?[q0,R0]:[R0,q0];return e0[w8]+C8[u0]},h8=(t)=>{let q0=e0.indexOf(t[0]),Z0=C8.indexOf(t[1]),R0=!(O["flex-direction"]||m9(U["flex-direction"])||"row").startsWith("column"),[u0,w8]=R0?[Z0,q0]:[q0,Z0];i("justify-content",M0[u0]),i("align-items",c0[w8])},j0=(t)=>{if(!(t.metaKey||t.ctrlKey)||t.altKey)return;let q0=t.key.toLowerCase();if(q0==="z")t.preventDefault(),G?.(t.shiftKey?"redo":"undo");else if(q0==="y")t.preventDefault(),G?.("redo")},g0=(t)=>{let q0=O[t];if(!q0)return"inherit";return/var\(\s*--/.test(q0)?"bound":"raw"};if(!z)return A("div",{className:"st-cp",children:[K("div",{className:"st-cp-id",children:K("span",{className:"st-cp-idtag",children:X.tag||"element"})}),A("div",{className:"st-css-disabled",children:["This selection has no stable element id (a legacy canvas, or a non-element target). Edit it with ",K("code",{children:"/design:edit"}),"."]})]});let A8={bound:"token-bound",raw:"raw override",inherit:"inherited"},r8=(t)=>K("span",{className:`st-cp-prov st-cp-prov--${t}`,role:"img","aria-label":A8[t]}),R9=(t,q0)=>{let Z0=q0??g0(t),R0=$[t],u0=typeof R0==="string"&&R0.startsWith("err:")?R0.slice(4):"",w8=u0?" is-err":R0==="saved"?" is-saved":R0==="saving"?" is-saving":"",L8=!!O[t],$8=u0?`error: ${u0}`:L8?`${A8[Z0]} · double-click to reset`:A8[Z0];return K("button",{type:"button",className:`st-cp-prov st-cp-prov--${Z0}${w8}${L8?" is-resettable":""}`,"aria-label":$8,title:$8,tabIndex:L8?0:-1,onDoubleClick:L8?()=>r(t):void 0,onKeyDown:L8?(E8)=>{if(E8.key==="Backspace"||E8.key==="Delete")E8.preventDefault(),r(t)}:void 0})},$0=(t,q0,Z0,R0)=>{let u0=Z0===void 0&&!O[t],w8=R0??t;return A("div",{className:`st-cp-row${u0?" is-unset":""}`,children:[R9(t,Z0),K("label",{className:"st-cp-label",title:w8,children:w8}),K("div",{className:"st-cp-ctl",children:q0})]},t)},V9={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"]},I0=(t)=>{(V9[t]||[]).forEach((q0)=>{if(O[q0])r(q0)})},Z8=(t,q0)=>{let Z0=(V9[t]||[]).some((R0)=>O[R0]);return A("section",{className:"st-cp-sec",children:[A("div",{className:"st-cp-sechd-row",children:[A("button",{type:"button",className:"st-cp-sechd","aria-expanded":!!v[t],onClick:()=>g((R0)=>({...R0,[t]:!R0[t]})),children:[K("span",{className:"st-cp-caret","aria-hidden":"true",children:v[t]?"▾":"▸"}),t]}),K("button",{type:"button",className:`st-cp-secreset${Z0?"":" is-quiet"}`,"aria-label":`reset ${t} section to original`,title:`reset ${t}`,disabled:!Z0,onClick:()=>I0(t),children:K(h9,{as:nG,size:12})})]}),K("div",{className:`st-cp-sec-anim${v[t]?" is-open":""}`,children:K("div",{className:"st-cp-sec-inner",children:q0})})]},t)},H0=(t,q0,Z0,R0=!0)=>{let u0=`d:${t}`,w8=v[u0]===void 0?R0:v[u0],L8=q0.some(($8)=>O[$8]);return A("section",{className:"st-cp-sec",children:[A("div",{className:"st-cp-sechd-row",children:[A("button",{type:"button",className:"st-cp-sechd","aria-expanded":w8,onClick:()=>g(($8)=>({...$8,[u0]:!w8})),children:[K("span",{className:"st-cp-caret","aria-hidden":"true",children:w8?"▾":"▸"}),t]}),K("button",{type:"button",className:`st-cp-secreset${L8?"":" is-quiet"}`,"aria-label":`reset ${t} to original`,title:`reset ${t}`,disabled:!L8,onClick:()=>q0.forEach(($8)=>{if(O[$8])r($8)}),children:K(h9,{as:nG,size:12})})]}),K("div",{className:`st-cp-sec-anim${w8?" is-open":""}`,children:K("div",{className:"st-cp-sec-inner",children:Z0})})]},u0)},k0=(t)=>K("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!l[t],"aria-label":l[t]?`${t} — fewer options`:`${t} — more options`,title:l[t]?"fewer":"more",onClick:()=>p((q0)=>({...q0,[t]:!q0[t]})),children:l[t]?"▴":"···"}),F0=(t,q0)=>A("select",{className:"st-cp-nsel","aria-label":t,value:q0.includes(O[t])?O[t]:"",onChange:(Z0)=>i(t,Z0.target.value),children:[K("option",{value:"",disabled:!0,children:m9(U[t])||"—"}),q0.map((Z0)=>K("option",{value:Z0,children:Z0},Z0))]}),G8=(t)=>b(t).flatMap((q0)=>(q0.names||[]).map((Z0)=>({name:Z0,value:q0.vals?.[Z0]||""}))),T8=(t,q0)=>K(uw,{value:O[t]||m9(U[t])||q0[0].value,ariaLabel:t,options:q0,onChange:(Z0)=>i(t,Z0)}),Q8=(t,q0,Z0={})=>{let R0=_Q(O[t]??""),u0=Xe.has(t),w8=O[t]??"",L8=typeof w8==="string"&&/var\(\s*--/.test(w8),$8=u0?"":R0.unit&&R0.unit!=="auto"?R0.unit:"px",E8=Number.parseFloat(_Q(m9(U[t])??"").n)||0,t8=R0.n!==""&&R0.n!=null?Number.parseFloat(R0.n)||0:E8,O9=WR[t];return K(EB,{value:L8?w8:t8,tokens:G8(q0),ariaLabel:t,min:Z0.min??0,lead:O9?O9.node??O9.t:void 0,unitSlot:u0?null:K(_B,{units:et,value:R0.unit||"px",ariaLabel:`${t} unit`,onChange:(M9)=>i(t,M9==="auto"?"auto":`${R0.n||"0"}${M9}`)}),onChange:(M9)=>i(t,typeof M9==="string"?M9:u0?`${M9}`:`${M9}${$8}`)})},R8=()=>{let t=(u0)=>Number.parseFloat(_Q(O[u0]??O["border-radius"]??m9(U[u0])??m9(U["border-radius"])??"0").n)||0,q0={tl:t("border-top-left-radius"),tr:t("border-top-right-radius"),bl:t("border-bottom-left-radius"),br:t("border-bottom-right-radius")},Z0=(u0)=>{if(u0.tl===u0.tr&&u0.tr===u0.bl&&u0.bl===u0.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((L8)=>{if(O[L8])r(L8)}),i("border-radius",`${u0.tl}px`);else i("border-top-left-radius",`${u0.tl}px`),i("border-top-right-radius",`${u0.tr}px`),i("border-bottom-left-radius",`${u0.bl}px`),i("border-bottom-right-radius",`${u0.br}px`)},R0=WR["border-radius"];return K(Sv,{corners:q0,lead:R0?R0.node??R0.t:void 0,onCorners:Z0})},P0=()=>A("div",{className:"st-cp-border",children:[Y9("border-width",null,{fixedUnit:"px"}),A("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:tt.includes(O["border-style"])?O["border-style"]:"",onChange:(t)=>i("border-style",t.target.value),children:[K("option",{value:"",disabled:!0,children:"style"}),tt.map((t)=>K("option",{value:t,children:t},t))]}),K(mN,{kind:"color",groups:b("color"),current:O["border-color"],activeDs:T,swatchBg:U["border-color"]||O["border-color"]||"",seedHex:pN(U["border-color"]||O["border-color"])||"#000000",onPick:(t)=>i("border-color",t),label:"border colour"})]}),w0=()=>{let t=O.transform||m9(U.transform)||"",q0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(t),Z0=((q0?Number.parseFloat(q0[1]):0)%360+360)%360,R0=(u0)=>{let w8=(u0%360+360)%360,L8=(O.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();i("transform",`${L8?`${L8} `:""}rotate(${w8}deg)`.trim())};return A("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[K(Cv,{value:Z0,onChange:R0}),K(v6,{value:Z0,min:0,max:360,ariaLabel:"rotation",lead:K(h9,{as:nG}),steppers:!1,unitSlot:K("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:R0})]})},a0=()=>{let t=O.filter||m9(U.filter)||"",q0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(t),Z0=q0?Number.parseFloat(q0[1]):0;return K(v6,{value:Z0,min:0,ariaLabel:"filter blur",unitSlot:K("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(u0)=>{let w8=(O.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();i("filter",u0>0?`${w8?`${w8} `:""}blur(${u0}px)`.trim():w8||"none")}})},N0=()=>{let t=O.opacity,q0=t!=null&&t!==""?Number.parseFloat(t):Number.parseFloat(m9(U.opacity))||1,Z0=Math.round((Number.isNaN(q0)?1:q0)*100);return K(BJ,{value:Z0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(R0)=>s("opacity",String(R0/100)),onCommit:(R0)=>i("opacity",String(R0/100))},`opacity:${t??""}`)},m0=()=>{let t=Number.parseInt(O["font-weight"]||m9(U["font-weight"])||"400",10)>=600,q0=(O["font-style"]||m9(U["font-style"]))==="italic",Z0=/underline/.test(O["text-decoration"]||m9(U["text-decoration"])||"");return K(kv,{value:{b:t,i:q0,u:Z0},ariaLabel:"text style",options:[{value:"b",node:K(h9,{as:v1}),label:"Bold"},{value:"i",node:K(h9,{as:u1}),label:"Italic"},{value:"u",node:K(h9,{as:t1}),label:"Underline"}],onToggle:(R0)=>{if(R0==="b")i("font-weight",t?"400":"700");else if(R0==="i")i("font-style",q0?"normal":"italic");else i("text-decoration",Z0?"none":"underline")}})},B8=[{value:"row",node:K(h9,{as:a4}),label:"Row"},{value:"column",node:K(h9,{as:s4}),label:"Column"}],i8=[{value:"flex-start",node:K(h9,{as:S1}),label:"Start"},{value:"center",node:K(h9,{as:C1}),label:"Center"},{value:"flex-end",node:K(h9,{as:$1}),label:"End"},{value:"space-between",node:K(h9,{as:Tz}),label:"Space between"}],Q9=[{value:"flex-start",node:K(h9,{as:y1}),label:"Start"},{value:"center",node:K(h9,{as:b1}),label:"Center"},{value:"flex-end",node:K(h9,{as:j1}),label:"End"},{value:"stretch",node:K(h9,{as:a1}),label:"Stretch"}],Y7=[{value:"left",node:K(h9,{as:E5}),label:"Left"},{value:"center",node:K(h9,{as:XW}),label:"Center"},{value:"right",node:K(h9,{as:JW}),label:"Right"},{value:"justify",node:K(h9,{as:QW}),label:"Justify"}],Z9=[{value:"visible",node:K(h9,{as:oG}),label:"Visible"},{value:"hidden",node:K(h9,{as:rG}),label:"Hidden"},{value:"scroll",node:K(h9,{as:o1}),label:"Scroll"}],W6=(t,q0)=>{let Z0=b(q0);return Z0.length?K(mN,{kind:"value",groups:Z0,current:O[t],activeDs:T,onPick:(R0)=>i(t,R0),label:`${t} design token`}):null},e9=(t)=>{let q0=t.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===q0)q0.select()})},DX=(t,q0)=>{if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return!1;t.preventDefault();let Z0=t.shiftKey?10:1,R0=t.key==="ArrowUp"?1:-1,u0=(Number.parseFloat(t.currentTarget.value)||0)+R0*Z0;return t.currentTarget.value=String(u0),q0(u0),!0},V7=(t)=>K("input",{className:"st-cp-fin","aria-label":t,defaultValue:O[t]??"",placeholder:m9(U[t])||"—",onFocus:e9,onKeyDown:(q0)=>{if(q0.key==="Enter")q0.currentTarget.blur()},onBlur:(q0)=>i(t,q0.currentTarget.value)},`${t}:${O[t]??""}`),Y9=(t,q0,Z0={})=>{let R0=_Q(O[t]??""),u0=Xe.has(t),w8=u0?"":Z0.fixedUnit||(R0.unit&&R0.unit!=="auto"?R0.unit:"px"),L8=WR[t],$8=Number.parseFloat(_Q(m9(U[t])??"").n)||0,E8=R0.n!==""&&R0.n!=null?Number.parseFloat(R0.n)||0:$8;return A(W0,{children:[K(v6,{value:E8,min:Z0.min??0,step:1,ariaLabel:t,lead:L8?L8.node??L8.t:void 0,onCommit:(t8)=>i(t,u0?`${t8}`:`${t8}${w8}`),unitSlot:u0||Z0.fixedUnit?null:K(_B,{units:et,value:R0.unit||"px",ariaLabel:`${t} unit`,onChange:(t8)=>i(t,t8==="auto"?"auto":`${R0.n||"0"}${t8}`)})},`${t}:${O[t]??""}`),W6(t,q0)]})},W7=(t)=>{let q0=U[t]||O[t]||"",Z0=O[t]??"",R0=typeof Z0==="string"&&/var\(\s*--/.test(Z0),u0=R0?Z0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):Z0;return K(XV,{swatch:K(mN,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:b("color"),current:O[t],activeDs:T,swatchBg:q0,seedHex:pN(U[t]||O[t])||"#000000",onPick:(w8)=>i(t,w8),label:`${t} colour`}),displayValue:u0,bound:R0,ariaLabel:t,onValue:(w8)=>i(t,w8)})},a8=(t,q0)=>{let Z0=null,R0=q0.unitless?"":"px",u0=($8)=>q0.unitless?`${$8}`:`${$8}${R0}`,w8=($8,E8,t8)=>{for(let O9 of E8??[t])t8(O9,u0($8))},L8=mw({getBase:()=>Z0?.value??"0",min:q0.min??0,step:1,sides:q0.sides,onInput:($8,E8)=>{if(Z0)Z0.value=String($8);if(E8){let t8=Z0?.closest(".st-cp-box");for(let O9 of E8){if(O9===t)continue;let M9=t8?.querySelector(`.st-cp-boxv[aria-label="${O9}"]`);if(M9)M9.value=String($8)}}w8($8,E8,s)},onCommit:($8,E8)=>w8($8,E8,i)});return{onPointerDown:($8)=>{Z0=$8.currentTarget,L8($8)}}},H9=(t,q0)=>{let Z0=O[t],R0=Z0!=null&&Z0!==""?_Q(Z0).n||Z0:_Q(m9(U[t])??"").n||"0",u0=!Z0||Z0==="0"||Z0==="0px"||Z0==="auto",w8=t.split("-").pop(),L8=w8==="top"||w8==="bottom"?[`${q0}-top`,`${q0}-bottom`]:[`${q0}-left`,`${q0}-right`],$8=[`${q0}-top`,`${q0}-right`,`${q0}-bottom`,`${q0}-left`];return K("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${q0[0]}${t.split("-").pop()[0]}${u0?" is-zero":""}`,"aria-label":t,defaultValue:R0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...a8(t,{sides:{pair:L8,all:$8}}),onFocus:e9,onKeyDown:(E8)=>{if(DX(E8,(t8)=>i(t,`${t8}px`)))return;if(E8.key==="Enter")E8.currentTarget.blur()},onBlur:(E8)=>{let t8=E8.currentTarget.value.trim();if(!t8)return;let O9=/[a-z%]/i.test(t8)?t8:`${t8}px`;i(t,O9)}},`${t}:${Z0??""}`)},u9=(t)=>{let q0=O[t],Z0=q0!=null&&q0!==""&&q0!=="auto"?_Q(q0).n||q0:_Q(m9(U[t])??"").n||"",R0=!q0||q0==="auto"||q0==="0"||q0==="0px",u0=t==="top"||t==="bottom"?["top","bottom"]:["left","right"],w8=["top","right","bottom","left"];return K("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${t[0]}${R0?" is-zero":""}`,"aria-label":t,defaultValue:Z0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...a8(t,{sides:{pair:u0,all:w8},min:-1/0}),onFocus:e9,onKeyDown:(L8)=>{if(DX(L8,($8)=>i(t,`${$8}px`)))return;if(L8.key==="Enter")L8.currentTarget.blur()},onBlur:(L8)=>{let $8=L8.currentTarget.value.trim();if(!$8)return;let E8=/[a-z%]/i.test($8)?$8:`${$8}px`;i(t,E8)}},`${t}:${q0??""}`)},l9=Object.entries(M),g9=Object.entries(E),q7=()=>{let t=(X.tag||"").toLowerCase(),Z0=t==="img"||t==="video"||t==="picture"||t==="svg"||t==="canvas"||!!O["object-fit"]||!!O["object-position"]||!!O["aspect-ratio"],R0=(t==="img"||t==="video")&&!!X.attrs?.src&&!!W;return{showMedia:Z0,canReplace:R0}},G7=(t)=>A(W0,{children:[t&&K("div",{className:"st-cp-mediabtn",children:K("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>W(X),children:"Replace…"})}),$0("object-fit",F0("object-fit",sq0)),$0("object-position",V7("object-position")),$0("aspect-ratio",A("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:Ge.includes(O["aspect-ratio"])?O["aspect-ratio"]:"",onChange:(q0)=>{let Z0=q0.target.value;if(i("aspect-ratio",Z0),Z0&&Z0!=="auto"&&O.height)r("height")},children:[K("option",{value:"",disabled:!0,children:m9(U["aspect-ratio"])||"—"}),Ge.map((q0)=>K("option",{value:q0,children:q0},q0))]}))]});return A("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:j0,children:[A("div",{className:"st-cp-id",children:[A("span",{className:"st-cp-idtag",children:[X.tag||"element",X.classes?A("span",{className:"st-cp-idcls",children:[".",X.classes.split(/\s+/)[0]]}):null]}),K("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:K(uw,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:K(h9,{as:r4,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:K(h9,{as:YW,size:12}),label:"Designer — Figma vocabulary"}],onChange:f})})]}),Z==="designer"?A(W0,{children:[H0("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let t=(O.display||m9(U.display)||"").trim();return t==="flex"||t==="inline-flex"?A(W0,{children:[$0("flex-direction",T8("flex-direction",B8),void 0,"Direction"),$0("align-items",K(Tv,{value:t0(),onChange:h8,ariaLabel:"auto-layout alignment"}),g0("align-items"),"Alignment"),$0("gap",Q8("gap","space"),void 0,"Gap"),A("div",{className:"st-cp-modes",children:[n0("width"),n0("height")]}),A("div",{className:"st-cp-box","aria-label":"padding",children:[A("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[r8(g0("padding-top")),"padding"]}),H9("padding-top","padding"),H9("padding-right","padding"),H9("padding-bottom","padding"),H9("padding-left","padding")]}),K("div",{className:"st-cp-clustermore-row",children:k0("Auto layout")}),l["Auto layout"]?$0("flex-wrap",K(FQ,{checked:/^wrap/.test(O["flex-wrap"]||m9(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(Z0)=>i("flex-wrap",Z0?"wrap":"nowrap")}),g0("flex-wrap"),"Wrap"):null]}):K("button",{type:"button",className:"st-cp-makeflex",disabled:!z,onClick:()=>i("display","flex"),children:"+ Auto layout (flex)"})})()),H0("Size",["width","height","min-width","max-width","min-height","max-height"],A(W0,{children:[$0("width",Y9("width"),void 0,"Width"),$0("height",Y9("height"),void 0,"Height"),K("div",{className:"st-cp-clustermore-row",children:k0("Size")}),l.Size?A(W0,{children:[$0("min-width",Y9("min-width"),void 0,"Min width"),$0("max-width",Y9("max-width"),void 0,"Max width"),$0("min-height",Y9("min-height"),void 0,"Min height"),$0("max-height",Y9("max-height"),void 0,"Max height")]}):null]})),H0("Position",["position","top","right","bottom","left","z-index"],A(W0,{children:[$0("position",F0("position",Je),void 0,"Position"),A("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[A("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[r8(g0("top")),"inset"]}),u9("top"),u9("right"),u9("bottom"),u9("left"),K("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:O.position||m9(U.position)||"static"})]}),(O.position||m9(U.position)||"static")==="static"?K("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,K("div",{className:"st-cp-clustermore-row",children:k0("Position")}),l.Position?$0("z-index",Y9("z-index"),void 0,"Layer order"):null]}),!1),H0("Fill",["background-color"],$0("background-color",W7("background-color"),void 0,"Fill")),H0("Stroke",["border-width","border-style","border-color"],$0("border",P0(),g0("border-width"),"Stroke")),H0("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],$0("border-radius",R8(),g0("border-radius"),"Corner radius")),H0("Effects",["box-shadow","filter","mix-blend-mode"],A(W0,{children:[$0("box-shadow",W6("box-shadow","shadow")||V7("box-shadow"),void 0,"Shadow"),$0("filter",a0(),g0("filter"),"Blur"),$0("mix-blend-mode",F0("mix-blend-mode",We),void 0,"Blend")]})),H0("Opacity",["opacity"],$0("opacity",N0(),void 0,"Opacity")),H0("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],A(W0,{children:[$0("font-family",F0("font-family",st),void 0,"Font"),$0("color",W7("color"),void 0,"Color"),$0("font-size",Q8("font-size","type"),void 0,"Size"),$0("font-weight",F0("font-weight",at),void 0,"Weight"),$0("line-height",Y9("line-height","lh"),void 0,"Line height"),$0("text-align",T8("text-align",Y7),void 0,"Align"),K("div",{className:"st-cp-clustermore-row",children:k0("Text")}),l.Text?A(W0,{children:[$0("letter-spacing",Y9("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),$0("font-style",F0("font-style",aq0),void 0,"Style"),$0("text-transform",F0("text-transform",Qe),void 0,"Case"),$0("white-space",F0("white-space",Ye),void 0,"Whitespace")]}):null]})),H0("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],A("div",{className:"st-cp-box","aria-label":"margin",children:[A("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[r8(g0("margin-top")),"margin"]}),H9("margin-top","margin"),H9("margin-right","margin"),H9("margin-bottom","margin"),H9("margin-left","margin")]})),(()=>{let{showMedia:t,canReplace:q0}=q7();return t?H0("Media",["object-fit","object-position","aspect-ratio"],G7(q0)):null})()]}):A(W0,{children:[Z8("Layout",(()=>{let t=(O.display||m9(U.display)||"").trim(),q0=t==="flex"||t==="inline-flex",Z0=t==="grid"||t==="inline-grid";return A(W0,{children:[$0("display",F0("display",nq0)),q0?A(W0,{children:[$0("flex-direction",T8("flex-direction",B8)),$0("flex-wrap",K(FQ,{checked:/^wrap/.test(O["flex-wrap"]||m9(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(R0)=>i("flex-wrap",R0?"wrap":"nowrap")}),g0("flex-wrap"))]}):null,q0||Z0?A(W0,{children:[$0("align-items",T8("align-items",Q9)),$0("justify-content",T8("justify-content",i8)),$0("gap",Q8("gap","space"))]}):K("button",{type:"button",className:"st-cp-makeflex",disabled:!z,onClick:()=>i("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let t=(O.display||m9(U.display)||"").trim();if(!(t==="grid"||t==="inline-grid"))return null;let Z0=O["grid-template-columns"]||"",R0=O["grid-template-rows"]||"",u0=rD(Z0),w8=rD(R0),L8=u0.length>0||!Z0.trim(),$8=w8.length>0||!R0.trim();return Z8("Grid",A(W0,{children:[L8?K(He,{label:"Columns",tracks:u0,editable:z,onChange:(E8)=>i("grid-template-columns",aD(E8))}):A("div",{className:"st-cp-note",children:["Columns use ",K("code",{children:Z0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),$8?K(He,{label:"Rows",tracks:w8,editable:z,onChange:(E8)=>i("grid-template-rows",aD(E8))}):A("div",{className:"st-cp-note",children:["Rows use ",K("code",{children:R0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),Z8("Position",A(W0,{children:[$0("position",F0("position",Je)),A("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[A("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[r8(g0("top")),"inset"]}),u9("top"),u9("right"),u9("bottom"),u9("left"),K("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:O.position||m9(U.position)||"static"})]}),(O.position||m9(U.position)||"static")==="static"?K("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,$0("z-index",Y9("z-index"))]})),(X.parentDisplay==="grid"||X.parentDisplay==="inline-grid")&&Z8("Grid item",A(W0,{children:[A("div",{className:"st-cp-note",children:["Manual cell placement — ",K("code",{children:"start / end"})," or ",K("code",{children:"start / span N"}),"."]}),$0("grid-column",V7("grid-column")),$0("grid-row",V7("grid-row"))]})),Z8("Typography",A(W0,{children:[$0("font-family",F0("font-family",st)),$0("color",W7("color")),$0("font-size",Q8("font-size","type")),$0("font-weight",F0("font-weight",at)),$0("line-height",Y9("line-height","lh")),$0("letter-spacing",Y9("letter-spacing",null,{min:-1/0})),$0("text-align",T8("text-align",Y7)),$0("font-style",m0(),g0("font-style")),$0("text-transform",F0("text-transform",Qe)),$0("white-space",F0("white-space",Ye))]})),Z8("Spacing",K(W0,{children:A("div",{className:"st-cp-box","aria-label":"margin and padding",children:[A("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[r8(g0("margin-top")),"margin"]}),H9("margin-top","margin"),H9("margin-right","margin"),H9("margin-bottom","margin"),H9("margin-left","margin"),A("div",{className:"st-cp-boxpad",children:[A("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[r8(g0("padding-top")),"padding"]}),H9("padding-top","padding"),H9("padding-right","padding"),H9("padding-bottom","padding"),H9("padding-left","padding"),A("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(O.width)||X.bounds?.w||0)," × ",Math.round(Number.parseFloat(O.height)||X.bounds?.h||0)]})]})]})})),Z8("Size",A(W0,{children:[A("div",{className:"st-cp-modes",children:[n0("width"),n0("height")]}),$0("width",Y9("width")),$0("height",Y9("height")),$0("min-width",Y9("min-width")),$0("max-width",Y9("max-width")),$0("min-height",Y9("min-height")),$0("max-height",Y9("max-height")),$0("overflow",T8("overflow",Z9)),W8?A(W0,{children:[K("div",{className:"st-cp-subhd",children:"In flex parent"}),$0("align-self",F0("align-self",rq0)),$0("flex-grow",Y9("flex-grow",null,{unitless:!0})),$0("flex-shrink",Y9("flex-shrink",null,{unitless:!0})),$0("flex-basis",Y9("flex-basis"))]}):null]})),(()=>{let{showMedia:t,canReplace:q0}=q7();return t?Z8("Media",G7(q0)):null})(),Z8("Appearance",A(W0,{children:[$0("background-color",W7("background-color")),$0("border-radius",R8(),g0("border-radius")),$0("border",P0(),g0("border-width")),$0("box-shadow",W6("box-shadow","shadow")||V7("box-shadow")),$0("filter",a0(),g0("filter")),$0("mix-blend-mode",F0("mix-blend-mode",We)),$0("opacity",N0()),$0("rotation",w0(),g0("transform")),$0("transform",V7("transform")),$0("transform-origin",V7("transform-origin"))]})),(()=>{let t=Object.entries($).find(([,q0])=>typeof q0==="string"&&q0.startsWith("err:"));return t?A("div",{className:"st-cp-save is-err",role:"status",children:[K(G9,{name:"x",size:12}),t[0],": ",t[1].slice(4)]}):null})(),Z8("Advanced",A("div",{className:"st-cp-advbody",children:[l9.length?A(W0,{children:[K("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),l9.map(([t,q0])=>A("div",{className:"st-cp-kv",children:[K("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`custom property ${t} name`}),K("input",{className:"st-cp-fin",defaultValue:q0,"aria-label":`${t} value`,onKeyDown:(Z0)=>{if(Z0.key==="Enter")Z0.currentTarget.blur()},onBlur:(Z0)=>K0(t,Z0.currentTarget.value)},`cs:${t}:${q0}`),K("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>n(t),children:K(G9,{name:"x",size:11})})]},`cs:${t}`))]}):null,K("div",{className:"st-cp-advgrp",children:"Add CSS property"}),K(X30,{commit:K0}),K("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),g9.length?A(W0,{children:[K("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),g9.map(([t,q0])=>A("div",{className:"st-cp-kv",children:[K("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`attribute ${t} name`}),K("input",{className:"st-cp-fin",defaultValue:q0,"aria-label":`${t} value`,onKeyDown:(Z0)=>{if(Z0.key==="Enter")Z0.currentTarget.blur()},onBlur:(Z0)=>e(t,Z0.currentTarget.value)},`at:${t}:${q0}`),K("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>U0(t),children:K(G9,{name:"x",size:11})})]},`at:${t}`))]}):null,K("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),K(J30,{commit:e})]}))]}),A("div",{className:"st-cp-legend",children:[A("span",{children:[K("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),A("span",{children:[K("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),A("span",{children:[K("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},X.id)}function X30({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return A("div",{className:"st-cp-kv",children:[K("input",{className:"st-cp-fin","aria-label":"custom property name",placeholder:"property",value:J,onChange:(Z)=>Q(Z.target.value)}),K("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 J30({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return A("div",{className:"st-cp-kv",children:[K("input",{className:"st-cp-fin","aria-label":"custom attribute name",placeholder:"data-…",value:J,onChange:(Z)=>Q(Z.target.value)}),K("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 Q30={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function Y30(X,J,Q,Y){if(!Array.isArray(X)||J===Q)return X;let W=JSON.parse(JSON.stringify(X)),G=null,Z=(z)=>{for(let U=0;U<z.length;U++){if(z[U].id===J)return G=z[U],z.splice(U,1),!0;if(z[U].children&&Z(z[U].children))return!0}return!1};if(Z(W),!G)return X;let H=(z)=>{for(let U=0;U<z.length;U++){if(z[U].id===Q){if(Y==="inside-start"||Y==="inside-end")if(z[U].children=z[U].children||[],Y==="inside-start")z[U].children.unshift(G);else z[U].children.push(G);else z.splice(Y==="before"?U:U+1,0,G);return!0}if(z[U].children&&H(z[U].children))return!0}return!1};return H(W)?W:X}var W30=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function Oe({node:X,depth:J,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:z,onToggleVisibility:U,onReorder:q,onRowPointerDown:B,dragState:F,componentMap:O,lockedKeys:M,onToggleLock:E,onRename:I}){let P=`${X.id}:${X.index}`,w=X.children&&X.children.length>0,R=W.has(P),T=!!X.synthetic,C=!T&&O?O[X.id]:null,b=!T&&!!M?.has(P),[$,y]=u.useState(!1),[v,g]=u.useState(""),m=!T&&X.id===Q&&(Y==null||X.index===Y),c=G?.has(P)?G.get(P):!!X.hidden,f=!!q&&!T&&!b,l=()=>{y(!1);let s=v.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!s||s===(X.dcElement??""))return;I?.(X,s)},p=F?.key===P,h=p?{transform:`translate(${F.dx}px, ${F.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 A(W0,{children:[A("div",{className:"st-layer st-layer--row"+(m?" is-sel":"")+(c?" is-hidden":"")+(T?" is-group":"")+(C?" is-instance":"")+(b?" is-locked":""),style:{paddingLeft:6+J*14,...h},role:"treeitem","aria-selected":T?void 0:m,"aria-expanded":w?!R:void 0,"aria-grabbed":f?p:void 0,tabIndex:0,title:T?`${X.tag} · group (unstamped wrapper)`:`${X.tag} · ${X.type}${I?" · F2 to rename":""}`,"data-layer-key":P,onClick:()=>T?w&&Z(P):H(X),onMouseEnter:()=>!T&&z(X),onMouseLeave:()=>z(null),onPointerDown:f?(s)=>B(s,X,P):void 0,onKeyDown:(s)=>{if(s.key==="Enter"||s.key===" ")if(s.preventDefault(),T)w&&Z(P);else H(X);else if(s.key==="F2"&&I&&!T)s.preventDefault(),g(X.dcElement||X.label||""),y(!0)},children:[w?K("button",{type:"button",className:"st-layer-caret","aria-label":R?"Expand":"Collapse",onClick:(s)=>{s.stopPropagation(),Z(P)},children:R?"▸":"▾"}):K("span",{className:"st-layer-caret","aria-hidden":"true"}),C?K("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:C.root?"◆":"◇"}):K(G9,{name:Q30[X.type]||"box",size:12,className:"st-layer-ticon"}),$?K("input",{className:"st-layer-rename",value:v,autoFocus:!0,"aria-label":`Rename ${X.label}`,onFocus:(s)=>s.target.select(),onChange:(s)=>g(s.target.value),onClick:(s)=>s.stopPropagation(),onPointerDown:(s)=>s.stopPropagation(),onBlur:l,onKeyDown:(s)=>{if(s.stopPropagation(),s.key==="Enter")l();else if(s.key==="Escape")y(!1)}}):K("span",{className:"st-layer-label",onDoubleClick:I&&!T?(s)=>{s.stopPropagation(),g(X.dcElement||X.label||""),y(!0)}:void 0,children:X.label}),K("span",{className:"st-layer-type",children:C?C.component:X.type}),E&&!T?K("button",{type:"button",className:"st-layer-lock","aria-label":b?`Unlock ${X.label}`:`Lock ${X.label}`,"aria-pressed":b,title:b?"Unlock":"Lock",onClick:(s)=>{s.stopPropagation(),E(P)},children:K(G9,{name:b?"lock":"unlock",size:12})}):null,U&&!T?K("button",{type:"button",className:"st-layer-eye","aria-label":c?`Show ${X.label}`:`Hide ${X.label}`,"aria-pressed":c,title:c?"Show":"Hide",onClick:(s)=>{s.stopPropagation(),U(X)},children:K(G9,{name:c?"eye-off":"eye",size:13})}):null]}),w&&!R?X.children.map((s,a)=>K(Oe,{node:s,depth:J+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:z,onToggleVisibility:U,onReorder:q,onRowPointerDown:B,dragState:F,componentMap:O,lockedKeys:M,onToggleLock:E,onRename:I},`${s.id}:${s.index}`)):null]})}function G30({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 A("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:U}),A("div",{className:"st-swatch-row",children:[K("span",{className:"st-insp-swatch",style:{background:B},"aria-hidden":"true"}),K("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?_Q(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 A(W0,{children:[G?A("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Radius"}),A("div",{className:"st-insp-fields",children:[A("span",{className:"st-fmini",style:{flex:"0 0 auto",maxWidth:84},children:[K("span",{className:"st-mtag",children:"r"}),K("input",{value:Z,readOnly:!0,"aria-label":"border radius"})]}),K("span",{className:"st-insp-unit",children:"px"})]})]}):null,W("Fill","background-color"),W("Text","color"),H?A("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Font"}),K("div",{className:"st-insp-fields",children:K("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:H})})]}):null]})}function Me(X){if(X.artboardId)return X.artboardId;let J=/^\[data-dc-screen="([^"]+)"\]$/.exec(X.selector||"");return J?J[1]:null}var Z30=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],H30=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function z30({el:X,cfg:J,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let z=Me(X),U=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),q=Fe(X.file,J),B=Le(J,U,q),F=(p)=>B.map((h)=>({ds:h.name,names:h[p]||[],vals:h.vals})).filter((h)=>h.names.length),O=(p)=>F(p).flatMap((h)=>(h.names||[]).map((s)=>({name:s,value:h.vals?.[s]||""}))),M=(p)=>{let h=/^var\(\s*(--[\w-]+)\s*\)$/.exec(p||"");if(!h)return p||"";for(let s of B){let a=s.vals?.[h[1]];if(a)return a}return""},E=Number.isFinite(X.worldW)?X.worldW:Number.isFinite(X.bounds?.w)?X.bounds.w:null,I=Number.isFinite(X.worldH)?X.worldH:Number.isFinite(X.bounds?.h)?X.bounds.h:null,P=(p,h)=>{if(!z)return;let s=Number.isFinite(p)&&p>0?Math.round(p):void 0,a=Number.isFinite(h)&&h>0?Math.round(h):void 0;if(s==null&&a==null)return;Q?.(z,s,a)},w=Object.entries(Z5).find(([,p])=>p.width===E&&p.height===I)?.[0],R=Object.entries(Z5).find(([,p])=>p.width===E)?.[0],T=X.attrs?.["data-dc-fixed"]==="true",C=X.attrs?.["data-dc-bg"]??"",b=X.attrs?.["data-dc-padding"]??"",$=X.attrs?.["data-dc-layout"]??"",y=X.attrs?.["data-dc-gap"]??"",v=X.attrs?.["data-dc-kind"]||"digital",g=null;try{g=X.attrs?.["data-dc-print"]?JSON.parse(X.attrs["data-dc-print"]):null}catch{}let m=(p)=>{if(!z)return;let h=null;if(p==="print"&&!g){let s={paper:"a4"};try{let a=m3(s);if(a)h={defaults:s,widthPx:a.widthPx,heightPx:a.heightPx}}catch{}}if(G?.(z,p==="digital"?null:p,h),p==="web"&&T)Y?.(z,!1,void 0)},c=(p)=>{if(!z)return;let h={paper:"a4",...g,...p},s;try{s=m3(h)}catch{return}Q?.(z,s.widthPx,s.heightPx),Z?.(z,h)},f=(p)=>{if(!z)return;let h=p&&Number.isFinite(I)?Math.round(I):void 0;Y?.(z,p,h)},l=(p)=>{if(!z)return;W?.(z,p)};return A("section",{className:"st-cp-sec",children:[K("div",{className:"st-cp-sechd-row",children:K("span",{className:"st-cp-sechd",children:"Artboard"})}),A("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[K(v6,{value:E??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(p)=>P(p,null)}),K(v6,{value:I??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:T,onCommit:(p)=>{if(T)P(null,p)}})]}),K("div",{style:{padding:"0 12px 8px"},children:v==="print"?A("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:g?.paper??"",onChange:(p)=>c({paper:p.currentTarget.value}),children:[K("option",{value:"",disabled:!0,children:"Paper size…"}),g3.map((p)=>A("option",{value:p.id,children:[p.label," — ",p.width,"×",p.height,p.unit]},p.id))]}):v==="web"?A("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:R??"",onChange:(p)=>{let h=Z5[p.currentTarget.value];if(h)P(h.width,null)},children:[K("option",{value:"",disabled:!0,children:R?`${Z5[R].label} — ≤ ${Z5[R].width}px`:"Breakpoint…"}),Object.entries(Z5).map(([p,h])=>A("option",{value:p,children:[h.label," — ≤ ",h.width,"px breakpoint"]},p))]}):A("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:w??"",onChange:(p)=>{let h=Z5[p.currentTarget.value];if(h)P(h.width,h.height)},children:[K("option",{value:"",disabled:!0,children:w?Z5[w].label:"Preset size…"}),Object.entries(Z5).map(([p,h])=>A("option",{value:p,children:[h.label," — ",h.width,"×",h.height]},p))]})}),K("div",{style:{padding:"0 12px 8px"},children:K(AB,{value:T?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(p)=>f(p==="fixed")})}),K("div",{className:"st-cp-sechd-row",children:K("span",{className:"st-cp-sechd",children:"Kind"})}),K("div",{style:{padding:"0 12px 8px"},children:K(ZW,{value:v,ariaLabel:"artboard kind",options:H30.map(([p,h])=>({value:p,label:h})),onChange:m})}),v!=="print"&&z&&H?K("div",{style:{padding:"0 12px 8px"},children:A("select",{className:"st-cp-nsel","aria-label":"duplicate artboard at breakpoint width",value:"",onChange:(p)=>{let h=Z5[p.currentTarget.value];if(h)H(z,h.width);p.currentTarget.value=""},children:[K("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(Z5).map(([p,h])=>A("option",{value:p,children:[h.label," — ",h.width,"px"]},p))]})}):null,v==="print"?A(W0,{children:[K("div",{className:"st-cp-sechd-row",children:K("span",{className:"st-cp-sechd",children:"Print"})}),K("div",{style:{padding:"0 12px 8px"},children:K(AB,{value:g?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(p)=>c({orientation:p})})}),K("div",{style:{padding:"0 12px 8px"},children:K(v6,{value:Number.isFinite(g?.bleedMm)?g.bleedMm:3,min:0,step:0.5,ariaLabel:"bleed, millimeters",lead:"B",steppers:!1,unitSlot:K("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"mm"}),onCommit:(p)=>c({bleedMm:p})})})]}):null,K("div",{className:"st-cp-sechd-row",children:K("span",{className:"st-cp-sechd",children:"Style"})}),A("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let p=M(C),h=/var\(\s*--/.test(C),s=h?C.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):C;return K(XV,{swatch:K(mN,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:F("color"),current:C,activeDs:q,swatchBg:p,seedHex:pN(p)||"#000000",onPick:(a)=>l({background:a||null}),label:"artboard background colour"}),displayValue:s,bound:h,ariaLabel:"artboard background",onValue:(a)=>l({background:(a||"").trim()||null})})})(),K(ZW,{value:$,ariaLabel:"artboard body layout",options:Z30.map(([p,h])=>({value:p,label:h})),onChange:(p)=>l({layout:p||null})}),A("div",{style:{display:"flex",gap:8},children:[K(EB,{value:/^var\(/.test(b)?b:Number.parseFloat(b)||0,tokens:O("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(p)=>l({padding:typeof p==="string"?p:p>0?p:null})}),K(EB,{value:/^var\(/.test(y)?y:Number.parseFloat(y)||0,tokens:O("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(p)=>l({gap:typeof p==="string"?p:p>0?p:null})})]})]})]})}var zR=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,K30=new RegExp(zR.source,"gi");function U30(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(K30)||[])],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=zR.exec(`${X.attrs?.src||""} ${J}`);return Y?Y[0]:null}function V30({selected:X,onClose:J,layersTree:Q,componentMap:Y,lockedKeys:W,onToggleLock:G,onDetachInstance:Z,canvasFile:H,onSelectLayer:z,onHoverLayer:U,onReorderLayer:q,layersBusyRef:B,cfg:F,onOptimistic:O,onRecordEdit:M,onReplaceMedia:E,onResizeArtboard:I,onSetArtboardHug:P,onSetArtboardStyle:w,onSetArtboardKind:R,onSetArtboardPrint:T,onDuplicateArtboard:C,onUndoRedo:b,editScope:$,tab:y,onTabChange:v,width:g,resizing:m,photoSel:c,photoRev:f,onPhotoEdit:l,onPhotoRemoveBackground:p,onPhotoRecordEdit:h,onPhotoUndoRedo:s,layersOnly:a=!1,hideLayersTab:i=!1,cpMode:K0,onSetCpMode:e}){let[r,n]=u.useState("inspect"),U0=a?"layers":y??r,f0=(P0)=>{n(P0),v?.(P0)},[J8,W8]=u.useState(()=>new Set),[n0,M0]=u.useState(()=>new Map);u.useEffect(()=>{let P0=Array.isArray(X)?X[0]:X,w0=P0?.id;if(!w0||!Q?.nodes)return;let a0=P0.index,N0=null,m0=[];if(function B8(i8,Q9){for(let Y7 of i8||[]){let Z9=`${Y7.id}:${Y7.index}`;if(!Y7.synthetic&&Y7.id===w0&&(a0==null||Y7.index===a0))return N0=Z9,m0.push(...Q9),!0;if(Y7.children&&Y7.children.length&&B8(Y7.children,[...Q9,Z9]))return!0}return!1}(Q.nodes,[]),!N0)return;if(m0.length)W8((B8)=>{let i8=!1,Q9=new Set(B8);for(let Y7 of m0)if(Q9.delete(Y7))i8=!0;return i8?Q9:B8});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${N0}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[X,Q]);let c0=(P0)=>{let w0=`${P0.id}:${P0.index}`;return n0.has(w0)?n0.get(w0):!!P0.hidden},[e0,C8]=u.useState(null),[t0,h8]=u.useState(""),j0=(P0,w0)=>{if(!H||!P0?.id)return;fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:H,id:P0.id,attr:"data-dc-element",value:w0})}).then((a0)=>a0.json().catch(()=>({}))).then((a0)=>{if(!a0.ok)return;M?.({op:"attr",canvas:H,id:P0.id,key:"data-dc-element",before:P0.dcElement??null,after:w0})}).catch(()=>{})},g0=q?(P0,w0,a0)=>{if(B?.current)return;if(P0?.synthetic||w0?.synthetic)return;let N0=a0==="before"?`before ${w0.label}`:a0==="after"?`after ${w0.label}`:`into ${w0.label}`;h8(`Moved ${P0.label} ${N0}`),q(P0.id,w0.id,a0,{idIndex:P0.index,refIndex:w0.index})}:void 0,A8=()=>{let P0=[];return function w0(a0,N0,m0){(a0||[]).forEach((B8,i8)=>{if(P0.push({node:B8,depth:N0,parentNode:m0,siblings:a0,pos:i8}),B8.children&&B8.children.length&&!J8.has(`${B8.id}:${B8.index}`))w0(B8.children,N0+1,B8)})}(Q?.nodes,0,null),P0},r8=(P0)=>{if(P0.key!=="ArrowUp"&&P0.key!=="ArrowDown")return;if(!H0)return;let w0=A8(),a0=w0.findIndex((i8)=>i8.node.id===H0.id&&i8.node.index===H0.index);if(a0<0)return;let N0=P0.key==="ArrowDown"?1:-1,m0=w0[a0];if(!P0.altKey){let i8=w0[a0+N0];if(i8)P0.preventDefault(),z?.(i8.node);return}if(!g0||!Array.isArray(m0.siblings))return;P0.preventDefault();let B8=(i8)=>i8&&i8.children&&i8.children.length&&!J8.has(`${i8.id}:${i8.index}`);if(!P0.shiftKey){if(N0<0&&m0.pos>0)g0(m0.node,m0.siblings[m0.pos-1],"before");else if(N0>0&&m0.pos<m0.siblings.length-1)g0(m0.node,m0.siblings[m0.pos+1],"after");return}if(N0>0){let i8=m0.siblings[m0.pos+1];if(i8)g0(m0.node,i8,B8(i8)?"inside-start":"after");else if(m0.parentNode)g0(m0.node,m0.parentNode,"after")}else{let i8=m0.siblings[m0.pos-1];if(i8)g0(m0.node,i8,B8(i8)?"inside-end":"before");else if(m0.parentNode)g0(m0.node,m0.parentNode,"before")}},R9=u.useRef(null),$0=u.useRef(null),V9=(P0,w0,a0)=>{if(!g0||P0.button!==0||P0.metaKey||P0.ctrlKey||P0.shiftKey||P0.altKey)return;if(B?.current)return;let{clientX:N0,clientY:m0}=P0,B8=new Set([a0]);(function a8(H9){(H9.children||[]).forEach((u9)=>{B8.add(`${u9.id}:${u9.index}`),a8(u9)})})(w0);let i8=14,Q9=6,Y7=[];(function a8(H9,u9){(H9||[]).forEach((l9)=>{let g9=`${l9.id}:${l9.index}`;if(Y7.push({node:l9,key:g9,id:l9.id,depth:u9,tag:l9.tag}),l9.children&&l9.children.length&&!J8.has(g9))a8(l9.children,u9+1)})})(Q?.nodes,0);let Z9=new Map(Y7.map((a8)=>[a8.key,a8])),W6=!1,e9=(a8)=>{if(!W6){if(Math.hypot(a8.clientX-N0,a8.clientY-m0)<4)return;W6=!0}let H9=a8.clientX-N0,u9=a8.clientY-m0,l9=null,g9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((G7)=>({rect:G7.getBoundingClientRect(),it:Z9.get(G7.getAttribute("data-layer-key"))})).filter((G7)=>G7.it&&G7.it.key!==a0);if(g9.length){let G7=g9[0].rect.left,t=g9[0].rect.right,q0=g9.length;for(let M9=0;M9<g9.length;M9++)if(a8.clientY<g9[M9].rect.top+g9[M9].rect.height/2){q0=M9;break}let Z0=g9[q0-1]?.it||null,R0=g9[q0]?.it||null,u0=Math.round((a8.clientX-G7-Q9)/i8),w8=Z0?Z0.depth+(W30.has(Z0.tag)?0:1):0,L8=R0?R0.depth:0,$8=Math.max(L8,Math.min(u0,w8)),E8=null,t8="before",O9=0;if(!Z0){if(R0)E8=R0,t8="before",O9=R0.depth}else if($8>Z0.depth)E8=Z0,t8="inside-start",O9=Z0.depth+1;else if($8===Z0.depth)E8=Z0,t8="after",O9=Z0.depth;else{for(let M9=q0-1;M9>=0;M9--)if(g9[M9].it.depth===$8){E8=g9[M9].it;break}if(!E8)E8=Z0;t8="after",O9=$8}if(E8&&E8.key!==a0&&!B8.has(E8.key)){let M9=Z0?g9[q0-1].rect.bottom:g9[0].rect.top,OX=G7+Q9+O9*i8;l9={refId:E8.id,position:t8,node:E8.node,y:M9,left:OX,w:Math.max(24,t-OX)}}}let q7={key:a0,node:w0,dx:H9,dy:u9,target:l9};R9.current=q7,C8(q7)},DX=()=>{window.removeEventListener("pointermove",e9),window.removeEventListener("pointerup",Y9),window.removeEventListener("keydown",W7,!0)},V7=()=>{let a8=(H9)=>{H9.preventDefault(),H9.stopImmediatePropagation(),document.removeEventListener("click",a8,!0)};document.addEventListener("click",a8,!0),setTimeout(()=>document.removeEventListener("click",a8,!0),300)},Y9=()=>{DX();let a8=R9.current;if(R9.current=null,C8(null),W6&&a8?.target)V7(),g0(a8.node,a8.target.node,a8.target.position)},W7=(a8)=>{if(a8.key!=="Escape")return;if(a8.preventDefault(),a8.stopImmediatePropagation(),DX(),R9.current=null,C8(null),W6)V7()};window.addEventListener("pointermove",e9),window.addEventListener("pointerup",Y9),window.addEventListener("keydown",W7,!0)},I0=(P0)=>W8((w0)=>{let a0=new Set(w0);if(a0.has(P0))a0.delete(P0);else a0.add(P0);return a0}),Z8=(P0)=>{let w0=`${P0.id}:${P0.index}`,a0=c0(P0),N0=!a0;if(M0((m0)=>new Map(m0).set(w0,N0)),O?.({id:P0.id,artboardId:Q?.artboardId??null,index:P0.index,prop:"display",value:N0?"none":null}),!H||!P0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(N0?{canvas:H,id:P0.id,property:"display",value:"none"}:{canvas:H,id:P0.id,property:"display",reset:!0})}).catch(()=>{}),M?.({op:"css",canvas:H,id:P0.id,key:"display",before:a0?"none":null,after:N0?"none":null})},H0=Array.isArray(X)?X[0]:X,k0=c?{asset:c.asset,kind:"annotation-image"}:(()=>{let P0=U30(H0);return P0?{asset:P0,kind:"artboard-img"}:null})(),F0=k0?.kind==="annotation-image",G8=(P0)=>{if(!(P0.metaKey||P0.ctrlKey)||P0.altKey)return;let w0=P0.key.toLowerCase();if(w0==="z")P0.preventDefault(),s?.(P0.shiftKey?"redo":"undo");else if(w0==="y")P0.preventDefault(),s?.("redo")},T8=F0?"photo":U0==="photo"&&!k0?"inspect":U0,Q8=(P0,w0,a0)=>A("button",{type:"button",className:"st-rp-tab"+(T8===P0?" is-active":""),onClick:()=>f0(P0),children:[K(G9,{name:a0,size:14}),w0]}),R8=H0?.bounds||null;return A("aside",{className:"st-rpanel"+(m?" is-resizing":""),style:g?{width:g,flexBasis:g}:void 0,"aria-label":"Inspector","data-tour":"inspector",children:[A("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:a?{display:"none"}:void 0,children:[F0?Q8("photo","Photo","image"):A(W0,{children:[Q8("inspect","Inspect","sliders"),!i&&Q8("layers","Layers","layers"),Q8("css","CSS","code"),k0?Q8("photo","Photo","image"):null]}),K("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:J,children:K(G9,{name:"x",size:14})})]}),H0?.id&&!(Array.isArray(X)&&X.length>1)&&$?A("div",{className:`st-scope st-scope--${$.scope}`,title:$.scope==="shared"?`Editing this element's style changes ${$.affects} place${$.affects===1?"":"s"}${$.componentName?` (component ${$.componentName})`:""}. Move/resize a whole instance to keep it local.`:"This edit affects only this element.",children:[K("span",{className:"st-scope-dot","aria-hidden":"true"}),$.scope==="shared"?`Shared${$.componentName?` · ${$.componentName}`:""} · edits ${$.affects} place${$.affects===1?"":"s"}`:"Local · this element only",$.scope==="shared"&&Z?K("button",{type:"button",className:"st-scope-detach",title:"Clone this component for this instance only — edits stop affecting the other places",onClick:()=>Z(H0.id,H0.index),children:"Detach"}):null]}):null,K("div",{className:"st-rp-body",children:T8==="photo"&&k0?K("div",{onKeyDown:G8,children:K(tv,{asset:k0.asset,ColorPicker:De,StIcon:G9,onEdit:(P0)=>l?.(k0.asset,P0),onRemoveBackground:p,onRecordEdit:(P0,w0)=>h?.(k0.asset,P0,w0)},`${k0.asset}:${f??0}`)}):!H0&&!(T8==="layers"&&Q?.nodes?.length)?K("div",{className:"st-rp-empty",children:A("p",{children:["Press ",K(t6,{children:"V"}),", then click an element to select it — or ",K(t6,{children:"⌘"}),"-click straight from Browse."]})}):H0&&T8==="inspect"?A(W0,{children:[K("div",{className:"st-rp-hd",children:H0.selector||H0.tag||"element"}),A("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Pos"}),A("div",{className:"st-insp-fields",children:[A("span",{className:"st-fmini",children:[K("span",{className:"st-mtag",children:"X"}),K("input",{value:R8?Math.round(R8.x):"—",readOnly:!0,"aria-label":"x position"})]}),A("span",{className:"st-fmini",children:[K("span",{className:"st-mtag",children:"Y"}),K("input",{value:R8?Math.round(R8.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),A("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Size"}),A("div",{className:"st-insp-fields",children:[A("span",{className:"st-fmini",children:[K("span",{className:"st-mtag",children:"W"}),K("input",{value:R8?Math.round(R8.w):"—",readOnly:!0,"aria-label":"width"})]}),A("span",{className:"st-fmini",children:[K("span",{className:"st-mtag",children:"H"}),K("input",{value:R8?Math.round(R8.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),A("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Tag"}),K("div",{className:"st-insp-fields",children:K("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:H0.tag||"—"})})]}),H0.classes?A("div",{className:"st-insp-row",children:[K("span",{className:"st-insp-label",children:"Class"}),K("div",{className:"st-insp-fields",children:K("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:H0.classes})})]}):null,K(G30,{el:H0})]}):T8==="layers"?A(W0,{children:[A("div",{className:"st-rp-hd",children:["Layers",Q?.nodes?.length?"":" · ancestry"]}),Q?.nodes?.length?A(W0,{children:[g0?K("div",{className:"st-rp-hint","aria-hidden":"true",children:"Drag or ↑/↓ select · Alt+↑/↓ move · Alt+Shift+↑/↓ move across"}):null,K("div",{role:"tree","aria-label":"Artboard layers",tabIndex:0,ref:$0,onKeyDown:r8,children:Q.nodes.map((P0,w0)=>K(Oe,{node:P0,depth:0,selectedId:H0?.id,selectedIndex:H0?.index,collapsed:J8,hiddenOverride:n0,onToggle:I0,onSelect:(a0)=>{z?.(a0),$0.current?.focus()},onHover:(a0)=>U?.(a0),onToggleVisibility:Z8,onReorder:g0,onRowPointerDown:V9,dragState:e0,componentMap:Y,lockedKeys:W,onToggleLock:G,onRename:j0},`${P0.id}:${P0.index}`))}),e0?.target?K("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:e0.target.left,top:e0.target.y-1,width:e0.target.w}}):null,K("div",{className:"sr-only",role:"status","aria-live":"polite",children:t0})]}):H0&&Array.isArray(H0.dom_path)&&H0.dom_path.length?H0.dom_path.map((P0,w0)=>A("div",{className:"st-layer"+(w0===H0.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+w0*12},children:[K(G9,{name:"square",size:13}),P0]},w0)):K("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!H0.id&&Me(H0)?K(z30,{el:H0,cfg:F,onResizeArtboard:I,onSetArtboardHug:P,onSetArtboardStyle:w,onSetArtboardKind:R,onSetArtboardPrint:T,onDuplicateArtboard:C}):K(eq0,{el:H0,cfg:F,onOptimistic:O,onRecordEdit:M,onReplaceMedia:E,onUndoRedo:b,mode:K0,onSetMode:e})})]})}function q30(){let[X,J]=u.useState([]),[Q,Y]=u.useState("Design"),[W,G]=u.useState([]),[Z,H]=u.useState(null),[z,U]=u.useState(null),q=u.useRef(null);u.useEffect(()=>{q.current=z},[z]);let[B,F]=u.useState(null);u.useEffect(()=>{let N=Array.isArray(z)?z.length===1?z[0]:null:z,L=N&&typeof N.id==="string"?N.id:null;if(!L||!Z){F(null);return}let _=new AbortController,k=new URLSearchParams({canvas:Z,id:L});return fetch(`/_api/edit-scope?${k}`,{signal:_.signal}).then((S)=>S.ok?S.json():null).then((S)=>{if(S?.ok)F(S)}).catch(()=>{}),()=>_.abort()},[z,Z]);let O=u.useRef(0),M=u.useRef([]),E=u.useCallback((N)=>{if(!N?.id||!N.file)return;for(let L of M.current)clearTimeout(L);M.current=[50,450,1200,2500,5000].map((L)=>setTimeout(()=>{let _=q.current,k=Array.isArray(_)?_[0]:_;if(!k||k.id!==N.id||k.file!==N.file)return;let S=x8.current.get(N.file);if(!S?.contentWindow)return;try{S.contentWindow.postMessage({dgn:"select-by-id",id:N.id,artboardId:N.artboardId??null,index:N.index??0},"*")}catch{}},L))},[]),I=u.useRef([]),P=u.useCallback((N,L)=>{if(!N||!L)return;for(let _ of I.current)clearTimeout(_);I.current=[50,450,1200,2500,5000].map((_)=>setTimeout(()=>{let k=q.current,S=Array.isArray(k)?k[0]:k;if(!S||S.artboardId!==N||S.file!==L)return;let x=x8.current.get(L);if(!x?.contentWindow)return;try{x.contentWindow.postMessage({dgn:"select-by-id",artboardId:N},"*")}catch{}},_))},[]),w=u.useRef(null),R=u.useRef(null),T=u.useRef(null),C=u.useRef(null),b=u.useRef(!1),$=u.useRef(null),[y,v]=u.useState(null),[g,m]=u.useState(null),c=u.useRef({canvas:null,at:0});u.useEffect(()=>{if(!Z||!y)return;let N=Date.now(),L=c.current;if(L.canvas===Z&&N-L.at<1500)return;c.current={canvas:Z,at:N},fetch(`/_api/component-map?canvas=${encodeURIComponent(Z)}`).then((_)=>_.json()).then((_)=>{if(_?.ok&&_.map&&typeof _.map==="object")m(_.map);else m(null)}).catch(()=>m(null))},[Z,y]);let[f,l]=u.useState(!1),[p,h]=u.useState(null),[s,a]=u.useState(null),[i,K0]=u.useState(null),[e,r]=u.useState(null),[n,U0]=u.useState(!1),[f0,J8]=u.useState(null),[W8,n0]=u.useState(""),[M0,c0]=u.useState(null),[e0,C8]=u.useState(null),t0=u.useRef(null),h8=ct("maude-sb-w",{min:200,max:420,def:252}),j0=ct("maude-rp-w",{min:260,max:480,def:304}),[g0,A8]=u.useState(null),r8=u.useRef(null);u.useEffect(()=>{if(!g0)return;let N=(_)=>{let k=r8.current?.getBoundingClientRect();if(!k)return;if(g0==="sb")h8.setW(_.clientX-k.left);else j0.setW(k.right-_.clientX)},L=()=>A8(null);return window.addEventListener("pointermove",N),window.addEventListener("pointerup",L),()=>{window.removeEventListener("pointermove",N),window.removeEventListener("pointerup",L)}},[g0,h8.setW,j0.setW]);let R9=u.useCallback((N)=>{clearTimeout(t0.current),t0.current=setTimeout(()=>{C8((L)=>L===N?null:L)},2500)},[]);u.useEffect(()=>{if(!e0)return;let N=setTimeout(()=>C8(null),15000);return()=>clearTimeout(N)},[e0]);let[$0,V9]=u.useState({designRel:".design"}),I0=!!$0.readOnly,Z8=u.useCallback(()=>{fetch("/_config").then((N)=>N.json()).then((N)=>{let L=(N.designRoot||".design").replace(/^\/+|\/+$/g,"");V9((_)=>({..._,designRel:L,tokensCssRel:N.tokensCssRel,designSystems:N.designSystems,canvasOrigin:N.canvasOrigin,readOnly:!!N.readOnly}))}).catch(()=>{})},[]);u.useEffect(()=>{Z8()},[Z8]),u.useEffect(()=>{let N=!1;return fetch("/_sync-status").then((L)=>L.json()).then((L)=>{if(N||!L||L.linked===!1)return;a(L)}).catch(()=>{}),()=>{N=!0}},[]),u.useEffect(()=>{let N=!1;return fetch("/_api/git/status").then((L)=>L.json()).then((L)=>{if(!N&&L)K0(L)}).catch(()=>{}),()=>{N=!0}},[]);let[H0,k0]=u.useState({}),[F0,G8]=u.useState(null),[T8,Q8]=u.useState(!1),[R8,P0]=u.useState("open"),[w0,a0]=u.useState(Xq0),[N0,m0]=u.useState(()=>{return XR(jt,"advanced")==="designer"?"designer":"advanced"});u.useEffect(()=>{try{localStorage.setItem(jt,JSON.stringify(N0))}catch{}},[N0]);let[B8,i8]=u.useState(null),[Q9,Y7]=u.useState(()=>kZ(yt,!0)),[Z9,W6]=u.useState(()=>kZ(St,!1)),[e9,DX]=u.useState(()=>XR(bt,{})),[V7,Y9]=u.useState(!1),[W7,a8]=u.useState(!1);u.useEffect(()=>{if(!p8())return;let N=Tf(()=>a8(!0));return()=>{N.then((L)=>L()).catch(()=>{})}},[]);let[H9,u9]=u.useState(!1),[l9,g9]=u.useState(!1),[q7,G7]=u.useState(!1),[t,q0]=u.useState(!1),{report:Z0}=vw(p8()),[R0,u0]=u.useState(!1),[w8,L8]=u.useState(!1),[$8,E8]=u.useState(null),[t8,O9]=u.useState(!1),[M9,OX]=u.useState(!1),[gX,H5]=u.useState(!1),[z5,z9]=u.useState(!1),[N6,l5]=u.useState(()=>XR(ht,ez)),[a9,CY]=u.useState(()=>{try{let N=localStorage.getItem(gt);if(N==="separate"||N==="in-inspector")return N}catch{}return"separate"}),[I9,e6]=u.useState(!1),[p9,mX]=u.useState([]),[d9,uX]=u.useState(0),[$Y,L9]=u.useState(!1),[XX,MX]=u.useState(!1),[X7,u6]=u.useState(!1),[$9,c9]=u.useState(1),[K5,U5]=u.useState(216),[G6,lX]=u.useState(null),[wX,SY]=u.useState([]),[EW,EQ]=u.useState([]),[o,Q0]=u.useState([]),[z0,E0]=u.useState(0),B0=u.useMemo(()=>{if(!p9.length)return null;return(p9.find((L)=>L.durationInFrames===z0)??p9[0]).id},[p9,z0]),l0=u.useRef(null);u.useEffect(()=>{l0.current=B0},[B0]);let o0=u.useRef(0);u.useEffect(()=>{o0.current=d9},[d9]);let[_8,l8]=u.useState(null),_X=u.useRef(null);u.useEffect(()=>{_X.current=_8},[_8]);let[pX,O7]=u.useState(null),[AX,bY]=u.useState(0),v7=u.useCallback((N,L)=>{if(/concurrent edit|changed since it was read/i.test(L||""))M8("Timeline changed — reloaded, try again."),bY((_)=>_+1);else M8(`${N}: ${L||"failed"}`)},[]),[JX,V5]=u.useState(!1),[q5,EX]=u.useState(!1),[l6,PX]=u.useState(!1),D8=u.useRef(JX);u.useEffect(()=>{if(D8.current=JX,JX){PX(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[JX]);let d7=u.useCallback(()=>{if(!D8.current||document.hidden)PX(!0),ut("Claude finished","Your assistant turn is ready in Maude.")},[]),M7=u.useRef(0),Z7=u.useCallback(()=>{if(!D8.current||document.hidden){PX(!0);let N=Date.now();if(N-M7.current<tV0)return;M7.current=N,ut("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[S9,AJ]=u.useState("inspect"),[B5,p5]=u.useState(null),EJ=u.useRef({undo:[],redo:[]}),[YK,PQ]=u.useState(0),[PJ,RQ]=u.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),TZ=u.useRef(PJ);u.useEffect(()=>{TZ.current=PJ;try{localStorage.setItem("maude-auto-open-inspector",PJ?"1":"0")}catch{}},[PJ]);let RJ=u.useRef(!1);u.useEffect(()=>{RJ.current=gX||T8||n||JX},[gX,T8,n,JX]);let PW=u.useRef({open:{},side:ez});PW.current={open:{tree:Q9,layers:z5,inspector:gX,comments:T8,changes:n,assistant:JX},side:N6};let IQ=u.useCallback((N,L)=>{if(N==="tree")Y7(L);else if(N==="layers")z9(L);else if(N==="inspector")H5(L);else if(N==="comments")Q8(L);else if(N==="changes")U0(L);else if(N==="assistant")V5(L)},[]),dX=u.useCallback((N)=>PW.current.side?.[N]||ez[N],[]),QX=u.useCallback((N)=>{let L=dX(N);IQ(N,!0);for(let _ of GR)if(_.id!==N&&dX(_.id)===L)IQ(_.id,!1)},[IQ,dX]),cX=u.useCallback((N)=>{if(PW.current.open?.[N])IQ(N,!1);else QX(N)},[QX,IQ]),IJ=QX,I6=cX,RW=u.useCallback((N)=>{if(!TZ.current)return;if(I0)return;if(!N||!N.id)return;if(RJ.current)return;IJ("inspector"),AJ("css")},[IJ,I0]),d5=u.useCallback(()=>e6((N)=>!N),[]),c5=Lx(HR),jY=Qx(),[WK,GK]=u.useState(!1),[CZ,$Z]=u.useState(!1);u.useEffect(()=>{if(!p8())return;let N=!0;return bf().then((L)=>{if(!N)return;if(GK(!!L),!L&&!kZ($t,!1))$Z(!0)}).catch(()=>{}),()=>{N=!1}},[]);let SZ=u.useCallback(()=>{$Z(!1);try{localStorage.setItem($t,"1")}catch{}},[]),[ZK,bZ]=u.useState(null);u.useEffect(()=>{if(!p8())return;let N;return vf((L)=>bZ(L&&typeof L==="object"?L:{})).then((L)=>{N=L}).catch(()=>{}),()=>{try{N?.()}catch{}}},[]);let[i5,jZ]=u.useState(null),[IW,kW]=u.useState(()=>!kZ(Ct,!1)),iX=u.useCallback((N)=>{jZ(Array.isArray(N)&&N.length?N:null)},[]),TW={setup:(N)=>{if(!N)return;if((N.canvas||N.requireSelection)&&W.length===0)QX("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [role="treeitem"]')?.click()}catch{}},80);if(N.inspector||N.tab||N.requireSelection)IJ("inspector");if(N.tab)AJ(N.tab);if(N.changes)IJ("changes")}},CW=u.useCallback(()=>{kW(!1);try{localStorage.setItem(Ct,"1")}catch{}},[]),[o5,yY]=u.useState(()=>kZ(xt,!0)),[fY,oX]=u.useState(!1),[kJ,vY]=u.useState(()=>kZ(ft,!1)),[TJ,yZ]=u.useState(()=>kZ(vt,!1)),[YX,$W]=u.useState(!1),[kQ,n5]=u.useState(!1),[HK,xY]=u.useState(0),[SW,zK]=u.useState(null),[KK,fZ]=u.useState(!1),bW=u.useRef(null),hY=u.useRef(null),x8=u.useRef(new Map),Y8=u.useCallback((N)=>{let L=Z?x8.current.get(Z):null;if(!L||!L.contentWindow)return;try{L.contentWindow.postMessage(N,"*")}catch{}},[Z]),k6=u.useCallback((N,L)=>Y8({dgn:"photo-preview",asset:N,edit:L}),[Y8]),jW=u.useCallback((N,L,_)=>{EJ.current.undo.push({asset:N,before:L,after:_}),EJ.current.redo.length=0},[]),yW=u.useCallback((N)=>{let L=N?EJ.current.redo:EJ.current.undo;if(!L.length)return!1;let _=L.pop();(N?EJ.current.undo:EJ.current.redo).push(_);let k=(N?_.after:_.before)||{};return k6(_.asset,k),fetch(`/_api/photo-edit?asset=${encodeURIComponent(_.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)}).catch(()=>{}),PQ((S)=>S+1),!0},[k6]),UK=u.useCallback(async(N)=>{Y8({dgn:"photo-busy",asset:N,busy:!0});try{let L=await fetch(`/${N.replace(/^\/+/,"")}`);if(!L.ok)return null;let _=await L.blob(),{removeBackground:k}=await Promise.resolve().then(() => (Tt(),kt)),S=await k(_),x=await fetch("/_api/asset",{method:"POST",headers:{"content-type":S.type||"image/png"},body:S}),j=await x.json().catch(()=>({}));if(x.ok&&j.path)return{maskAsset:j.path};return null}catch(L){return console.error("[photo] background removal failed",L),null}finally{Y8({dgn:"photo-busy",asset:N,busy:!1})}},[Y8]);u.useEffect(()=>{let N=(k)=>Array.from(k.dataTransfer?.types??[]).includes("Files"),L=(k)=>{if(N(k))k.preventDefault()},_=(k)=>{if(N(k))k.preventDefault()};return document.addEventListener("dragover",L),document.addEventListener("drop",_),()=>{document.removeEventListener("dragover",L),document.removeEventListener("drop",_)}},[]);let I7=u.useRef({});I7.current={open:I9,comps:p9,frame:d9,total:z0,playing:$Y,compId:B0,muted:X7,loop:XX,sequences:wX,post:Y8,canvas:Z};let nX=u.useRef({undo:[],redo:[]}),x7=u.useCallback((N,L,_)=>{if(typeof L!=="number")return;if(nX.current.undo.push({canvas:N,seq:L,label:_}),nX.current.redo=[],nX.current.undo.length>50)nX.current.undo.shift()},[]),fW=u.useCallback((N)=>{let L=nX.current,_=N==="undo"?L.undo:L.redo,k=N==="undo"?L.redo:L.undo,S=I7.current.canvas,x=-1;for(let d=_.length-1;d>=0;d--)if(_[d].canvas===S){x=d;break}if(x<0){M8(N==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let j=_[x];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:j.canvas,seq:j.seq,dir:N})}).then((d)=>d.json().catch(()=>({}))).then((d)=>{if(_.splice(x,1),d?.ok)k.push(j),M8(`${N==="undo"?"Undid":"Redid"}: ${j.label}`,!0);else M8(`${N==="undo"?"Undo":"Redo"} skipped: ${d?.error||"failed"}`)}).catch(()=>M8(`${N==="undo"?"Undo":"Redo"} failed: network error`))},[]),Z6=u.useCallback((N,L)=>{let _=N?.ok&&Array.isArray(N.clips)?N.clips.filter((k)=>k.kind==="sequence"):[];if(L==null)return null;if(typeof L==="object")return(L.stableId?_.find((k)=>k.stableId===L.stableId):null)||(Number.isInteger(L.index)?_[L.index]:null)||null;if(typeof L==="string")return _.find((k)=>k.stableId===L)||null;return _[L]||null},[]),gY=u.useCallback((N)=>{let L=I7.current.canvas;if(!L||L===S8)return;let _=_X.current||void 0,k=`/_api/comp-clips?canvas=${encodeURIComponent(L)}${_?`&artboardId=${encodeURIComponent(_)}`:""}`;fetch(k).then((S)=>S.json().catch(()=>({}))).then((S)=>{let x=Z6(S,N);if(!x?.stableId)return null;return fetch("/_api/remove-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:L,artboardId:_,stableId:x.stableId,contentHash:x.contentHash})})}).then((S)=>S?S.json():null).then((S)=>{if(S&&!S.ok)console.warn("[remove-clip]",S.error||"failed"),v7("Remove refused",S.error);else if(S?.ok){if(M8("Clip removed.",!0),S.seq!=null)x7(L,S.seq,"remove clip");O7(null)}}).catch(()=>M8("Remove failed: network error"))},[Z6,x7]),r5=u.useCallback((N,L,_)=>{let k=I7.current.canvas;if(!k||k===S8)return;let S=_X.current||void 0,x=`/_api/comp-clips?canvas=${encodeURIComponent(k)}${S?`&artboardId=${encodeURIComponent(S)}`:""}`;fetch(x).then((j)=>j.json().catch(()=>({}))).then((j)=>{let d=j?.ok&&Array.isArray(j.clips)?j.clips:[],X0=N?.transition?d.find((Y0)=>Y0.kind==="transition"&&Y0.stableId===N.stableId)||null:Z6(j,N);if(!X0?.stableId)return null;return fetch("/_api/clip-edit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:k,artboardId:S,stableId:X0.stableId,contentHash:X0.contentHash,verb:L,..._})})}).then((j)=>j?j.json():null).then((j)=>{if(j&&!j.ok)console.warn("[clip-edit]",L,j.error||"failed"),v7(`${L} refused`,j.error);else if(j?.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(M8(`Applied: ${d[L]||L}.`,!0),j.seq!=null)x7(k,j.seq,d[L]||L)}}).catch(()=>M8(`${L} failed: network error`))},[Z6,x7,v7]),[a5,vZ]=u.useState(null),CJ=u.useCallback((N,L="")=>new Promise((_)=>{vZ({title:N,value:L,resolve:_})}),[]),TQ=u.useCallback((N)=>{vZ((L)=>{return L?.resolve?.(N),null})},[]),mY=u.useCallback((N,L)=>{let _=I7.current.canvas;if(!_||_===S8||!L||!String(L).trim())return;B7({type:"comments-add",payload:{file:_,text:String(L).trim(),selector:"",dom_path:[],tag:"",classes:"",bounds:null,html_excerpt:"",timeline:N}}),M8("Comment added.",!0)},[]);I7.current.selected=pX,I7.current.setSelected=O7,I7.current.removeClip=gY,I7.current.clipVerb=r5,I7.current.addComment=mY,I7.current.askText=CJ,u.useEffect(()=>{let N=(L)=>{let _=I7.current;if(!_.open||!_.comps?.length)return;let k=L.target,S=k?.tagName;if(S==="INPUT"&&k?.type!=="range")return;if(S==="TEXTAREA"||S==="SELECT"||k?.isContentEditable)return;let x=_.comps[0]?.fps||30,j=Math.max(1,_.total),d=(Y0)=>{let V0=Math.max(0,Math.min(j-1,Math.round(Y0)));uX(V0),L9(!1),_.post({dgn:"timeline-seek",frame:V0,id:_.compId})},X0=()=>{let Y0=new Set([0,j-1]);for(let V0 of _.sequences||[]){Y0.add(V0.from);for(let L0 of V0.keyframes||[])Y0.add(L0.from),Y0.add(L0.to)}return[...Y0].filter((V0)=>V0>=0&&V0<j).sort((V0,L0)=>V0-L0)};if((L.metaKey||L.ctrlKey)&&(L.key==="z"||L.key==="Z")){L.preventDefault(),fW(L.shiftKey?"redo":"undo");return}if(L.key==="Escape"){if(_.selected!=null)L.preventDefault(),_.setSelected?.(null);return}if((L.key==="Delete"||L.key==="Backspace")&&_.selected!=null){L.preventDefault(),_.removeClip?.({stableId:_.selected});return}if((L.metaKey||L.ctrlKey)&&(L.key==="b"||L.key==="B")){L.preventDefault();let Y0=_.selected!=null?{stableId:_.selected}:null;if(!Y0){let V0=_.sequences||[],L0=V0.find((P8)=>P8.series&&_.frame>=P8.from&&_.frame<P8.from+P8.duration)||V0.find((P8)=>_.frame>=P8.from&&_.frame<P8.from+P8.duration);if(L0?.stableId)Y0={stableId:L0.stableId}}if(Y0)_.clipVerb?.(Y0,"split",{atFrame:_.frame});else M8("Nothing under the playhead to split.");return}if(L.key===" "||L.code==="Space")if(L.preventDefault(),_.playing)L9(!1),_.post({dgn:"timeline-pause",id:_.compId});else L9(!0),_.post({dgn:"timeline-mute",muted:_.muted,id:_.compId}),_.post({dgn:"timeline-loop",loop:_.loop,id:_.compId}),_.post({dgn:"timeline-play",id:_.compId});else if(L.key==="ArrowRight")L.preventDefault(),d(_.frame+(L.shiftKey?x:1));else if(L.key==="ArrowLeft")L.preventDefault(),d(_.frame-(L.shiftKey?x:1));else if(L.key==="Home")L.preventDefault(),d(0);else if(L.key==="End")L.preventDefault(),d(j-1);else if(L.key==="."){L.preventDefault();let Y0=X0().find((V0)=>V0>_.frame);if(Y0!=null)d(Y0)}else if(L.key===","){L.preventDefault();let Y0=X0().reverse().find((V0)=>V0<_.frame);if(Y0!=null)d(Y0)}};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[]),u.useEffect(()=>{mX([]),uX(0),L9(!1),O7(null),l8(null);let N=setTimeout(()=>Y8({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(N)},[Z,Y8]);let[WX,G0]=u.useState(""),[xZ,CQ]=u.useState([]),[vW,$J]=u.useState([]);u.useEffect(()=>{if(!I9||p9.length===0||!Z||Z===S8){G0(""),CQ([]);return}let N=!0;return fetch(`/_api/canvas-source?file=${encodeURIComponent(Z)}`).then((L)=>L.ok?L.json():null).then((L)=>{if(N&&L?.ok&&typeof L.source==="string")G0(L.source)}).catch(()=>{}),()=>{N=!1}},[I9,p9,Z,AX]),u.useEffect(()=>{if(!I9||!Z||Z===S8||!WX){CQ([]),$J([]);return}let N=!0,L=_8||void 0,_=`/_api/comp-clips?canvas=${encodeURIComponent(Z)}${L?`&artboardId=${encodeURIComponent(L)}`:""}`;return fetch(_).then((k)=>k.ok?k.json():null).then((k)=>{if(!N)return;let S=k?.ok&&Array.isArray(k.clips)?k.clips:[];CQ(S.filter((x)=>x.kind==="sequence")),$J(S.filter((x)=>x.kind==="transition"))}).catch(()=>{}),()=>{N=!1}},[I9,Z,WX,_8,AX]),u.useEffect(()=>{if(!WX){SY([]),EQ([]),Q0([]),E0(0);return}let N=p9[0]?.durationInFrames||0,L=G6??z?.artboardId??null,_=nv(WX,N,L);l8(_.artboardId??L??null);let k=_.sequences.map((S,x)=>{let j=xZ[x];if(!j)return S;return{...S,stableId:j.stableId,contentHash:j.contentHash,mediaProps:j.mediaProps??null,placeholder:j.placeholder??null,mediaTag:j.mediaTag??S.mediaTag,mediaSrc:j.mediaSrc??S.mediaSrc,replaceable:!!(j.mediaCdId||j.mediaArrayRef),layers:Array.isArray(j.layers)?j.layers:[],hidden:!!j.hidden}});SY(k),EQ(_.audio||[]),Q0(_.transitions||[]),E0(_.total)},[WX,xZ,z,p9,G6]);let w7=u.useCallback(()=>{yY((N)=>{let L=!N,_=Z?x8.current.get(Z):null;if(_&&_.contentWindow)try{_.contentWindow.postMessage({dgn:"view-annotations",visible:L},"*")}catch{}return L})},[Z]),c7=u.useCallback((N)=>{for(let L of x8.current.values())try{L.contentWindow.postMessage({dgn:"view-chrome",...N},"*")}catch{}},[]),s5=u.useCallback(()=>{vY((N)=>{let L=!N;return c7({minimap:L}),L})},[c7]),uY=u.useCallback(()=>{yZ((N)=>{let L=!N;return c7({zoom:L}),L})},[c7]),xW=u.useCallback(()=>{$W((N)=>{let L=!N;return c7({present:L}),L})},[c7]),$Q=u.useCallback(()=>{$W(!1),c7({present:!1})},[c7]),SQ=u.useCallback(()=>{if(!Z||Z===S8)return;n5((N)=>{let L=!N;return Y8({dgn:"view-chrome",print:L}),fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{overlays:{print:L}}})}).catch(()=>{}),L})},[Z,Y8]);u.useEffect(()=>{let N=!1;return fetch("/_api/git-user").then((L)=>L.json()).then((L)=>{if(N)return;let _=L&&typeof L.name==="string"?L.name.trim():"";if(_)zK(_)}).catch(()=>{}),()=>{N=!0}},[]),u.useEffect(()=>{if(!Z||Z===S8){xY(0),n5(!1);return}let N=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(Z)).then((L)=>L.json()).then((L)=>{if(N)return;let _=Array.isArray(L?.artboards)?L.artboards.length:0;xY(_),n5(L?.overlays?.print===!0),jQ(new Set(Array.isArray(L?.locked)?L.locked:[]))}).catch(()=>{if(!N)xY(0),n5(!1),jQ(new Set)}),()=>{N=!0}},[Z]),u.useEffect(()=>{if(!Z||Z===S8||!G6)return;let N=setTimeout(()=>{Y8({dgn:"request-layers",artboardId:G6})},250);return()=>clearTimeout(N)},[Z,G6,Y8]);let[bQ,jQ]=u.useState(()=>new Set),p0=u.useCallback((N)=>{if(!Z||Z===S8)return;jQ((L)=>{let _=new Set(L);if(_.has(N))_.delete(N);else _.add(N);let k=[..._];return fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{locked:k}})}).catch(()=>{}),Y8({dgn:"locked-set",locked:k}),_})},[Z,Y8]);u.useEffect(()=>{if(!Z||Z===S8)return;Y8({dgn:"locked-set",locked:[...bQ]})},[bQ,Z,Y8]),u.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",w0),localStorage.setItem(Ue,w0)}catch{}for(let N of x8.current.values())try{N.contentWindow.postMessage({dgn:"theme",theme:w0},"*")}catch{}},[w0]),u.useEffect(()=>{try{localStorage.setItem(yt,Q9?"1":"0")}catch{}},[Q9]),u.useEffect(()=>{try{localStorage.setItem(St,Z9?"1":"0")}catch{}},[Z9]),u.useEffect(()=>{try{localStorage.setItem(bt,JSON.stringify(e9))}catch{}},[e9]),u.useEffect(()=>{try{localStorage.setItem(ft,kJ?"1":"0")}catch{}},[kJ]),u.useEffect(()=>{try{localStorage.setItem(vt,TJ?"1":"0")}catch{}},[TJ]),u.useEffect(()=>{try{localStorage.setItem(xt,o5?"1":"0")}catch{}},[o5]),u.useEffect(()=>{let N=!1;return fetch("/_api/ui-prefs").then((L)=>L.ok?L.json():Promise.reject(Error(`HTTP ${L.status}`))).then((L)=>{if(N||!L||typeof L!=="object")return;if(L.theme==="light"||L.theme==="dark")a0(L.theme);if(typeof L.minimap==="boolean")vY(L.minimap);if(typeof L.zoom==="boolean")yZ(L.zoom);if(typeof L.annotations==="boolean")yY(L.annotations);if(typeof L.autoOpenInspector==="boolean")RQ(L.autoOpenInspector);if(L.panelSides&&typeof L.panelSides==="object")l5({...ez,...L.panelSides});if(L.layersMode==="separate"||L.layersMode==="in-inspector")CY(L.layersMode)}).catch(()=>{}).finally(()=>{if(!N)oX(!0)}),()=>{N=!0}},[]),u.useEffect(()=>{if(!fY)return;eV0({theme:w0,minimap:kJ,zoom:TJ,annotations:o5,autoOpenInspector:PJ,panelSides:N6,layersMode:a9})},[fY,w0,kJ,TJ,o5,PJ,N6,a9]),u.useEffect(()=>{try{localStorage.setItem(ht,JSON.stringify(N6))}catch{}},[N6]),u.useEffect(()=>{try{localStorage.setItem(gt,a9)}catch{}},[a9]);let rX=u.useCallback((N,L)=>{DX((_)=>{let k=_[N],S=k===void 0?L:k;return{..._,[N]:!S}})},[]),yQ=u.useCallback(()=>{a0((N)=>N==="dark"?"light":"dark")},[]),b0=u.useCallback(async()=>{try{let L=await(await fetch("/_index-data")).json();Y(L.project||"Design");let _=L.groups.map((k)=>({...k,tree:Gq0(k.paths,k.stripPrefix,k.dirs)}));J(_),V9((k)=>({...k,canvasDesignSystems:L.canvasDesignSystems??{},canvasKinds:L.canvasKinds??{}}))}catch(N){console.error("failed to load tree",N)}},[]);u.useEffect(()=>{b0()},[b0]);let RX=u.useCallback(async(N)=>{try{let L=N?`/_system-data?ds=${encodeURIComponent(N)}`:"/_system-data",_=await fetch(L);if(!_.ok){console.error("failed to load system-data",_.status);return}let k=await _.json();if(!N&&k?.defaultDesignSystem&&!k.ds){c0(k);let S=await fetch(`/_system-data?ds=${encodeURIComponent(k.defaultDesignSystem)}`);if(S.ok)c0(await S.json());return}c0(k)}catch(L){console.error("failed to load system-data",L)}},[]),v0=u.useCallback(async()=>{try{let L=await(await fetch("/_comments-all")).json();k0(L||{})}catch(N){console.error("failed to load comments",N)}},[]);u.useEffect(()=>{v0()},[v0]),u.useEffect(()=>{function N(){let L=location.protocol==="https:"?"wss:":"ws:",_=new WebSocket(L+"//"+location.host+"/_ws");hY.current=_,_.addEventListener("open",()=>l(!0)),_.addEventListener("close",()=>{l(!1),setTimeout(N,1000)}),_.addEventListener("error",()=>{}),_.addEventListener("message",(k)=>{try{let S=JSON.parse(k.data);if(S.type==="snapshot"&&S.state)U((x)=>Ze(S.state.selected,x));else if(S.type==="selected"){if(Date.now()-O.current<2000)return;let x=S.selected,j=Array.isArray(x)?x[0]:x,d=q.current,X0=Array.isArray(d)?d[0]:d;if(U((Y0)=>Ze(x,Y0)),j?.id&&j.file&&(!X0||X0.id!==j.id||X0.file!==j.file))E(j)}else if(S.type==="comments"&&typeof S.file==="string")k0((x)=>({...x,[S.file]:S.comments||[]}));else if(S.type==="ai-activity"&&typeof S.file==="string"){if(fZ(!0),bW.current)clearTimeout(bW.current);bW.current=setTimeout(()=>fZ(!1),8000);for(let x of x8.current.values())try{x.contentWindow.postMessage({dgn:"ai-activity",file:S.file,entry:S.entry},"*")}catch{}}else if(S.type==="export:job"&&S.payload)jY.upsert(S.payload);else if(S.type==="sync:status"&&S.payload)a(S.payload);else if(S.type==="canvas-list-update"){if(b0(),S.payload?.action==="moved"&&S.payload.fromRel&&S.payload.rel){let x=($0?.designRel||$0?.designRoot||".design").replace(/^\/+|\/+$/g,""),j=`${x}/${S.payload.fromRel}`,d=`${x}/${S.payload.rel}`;G((X0)=>X0.map((Y0)=>Y0.path===j?{path:d}:Y0)),H((X0)=>X0===j?d:X0)}}else if(S.type==="config-updated")Z8();else if(S.type==="acp-focus"){if(p8())IJ("assistant")}else if(S.type==="git-status"&&S.payload)K0(S.payload);else if(S.type==="git-lifecycle"&&S.payload){h(S.payload);for(let x of x8.current.values())try{x.contentWindow.postMessage({dgn:"git-lifecycle",payload:S.payload},"*")}catch{}}}catch{}})}return N(),()=>hY.current&&hY.current.close()},[b0,Z8]);function B7(N){let L=hY.current;try{if(L&&L.readyState===1)L.send(JSON.stringify(N))}catch{}}let p6=u.useCallback(async()=>{try{let N=await fetch("/_api/git/status");if(N.ok)K0(await N.json())}catch{}},[]),GX=u.useCallback(async()=>{try{let N=await fetch("/_api/git/status?remote=1");if(!N.ok)return;let L=await N.json();if(L&&L.repo!==!1)r({remoteAhead:!!L.remoteAhead,behind:L.behind||0})}catch{}},[]),d6=u.useCallback(async(N,L)=>{try{let _=await fetch(N,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(L||{})}),k=await _.json().catch(()=>({}));return{ok:_.ok,...k}}catch(_){return{ok:!1,error:"Network error — is the project still open?"}}},[]),hW=u.useCallback(async(N,L)=>{let _=await d6("/_api/git/commit",{message:N,files:L});if(_.ok)await p6();return _},[d6,p6]),lY=u.useCallback(async(N)=>{let L=await d6("/_api/git/discard",{files:N});if(L.ok)await p6();return L},[d6,p6]),fQ=u.useCallback(async()=>{let N=await d6("/_api/git/push",{});if(N.ok)await p6(),GX();return N},[d6,p6,GX]),pY=u.useCallback(async()=>{let N=await d6("/_api/git/pull",{});if(N.ok)await p6(),GX();if(N.conflict&&Array.isArray(N.files)&&N.files.length)J8({file:N.files[0],conflict:!0});return N},[d6,p6,GX]),gW=u.useCallback(async(N)=>{let L=await d6("/_api/git/resolve",{choice:N});if(L.ok)await p6(),GX();return L},[d6,p6,GX]),dY=u.useCallback(async(N)=>{try{let L="/_api/git/log?limit=40"+(N?`&path=${encodeURIComponent(N)}`:""),_=await fetch(L);if(!_.ok)return[];return(await _.json()).entries||[]}catch{return[]}},[]),mW=u.useMemo(()=>{let N={modified:"M",added:"A",deleted:"D",untracked:"U"},L=new Map;for(let _ of i?.files||[])L.set(_.path,N[_.status]);return L},[i]),cY=i?.files?.length||0;u.useEffect(()=>{if(i?.repo===!1)return;GX();let N=setInterval(GX,n?60000:120000);return()=>clearInterval(N)},[i?.repo,n,GX]);let F6=u.useCallback((N)=>{if(G((L)=>{for(let _ of L)if(_.path!==N)x8.current.delete(_.path);return[{path:N}]}),H(N),G8(null),N!==S8)C8(N)},[]),SJ=u.useCallback((N)=>{let L=typeof N==="string"?N:void 0;if(L)RX(L);else if(!M0)RX();F6(S8)},[M0,RX,F6]);u.useEffect(()=>{B7({type:"tabs",tabs:W.map((N)=>N.path).filter((N)=>N!==S8)})},[W]),u.useEffect(()=>{if(Z&&Z!==S8)B7({type:"active",file:Z});else if(Z===S8)B7({type:"active",file:""});else B7({type:"active",file:""})},[Z]);let vQ=u.useCallback((N)=>{G((L)=>{let _=L.findIndex((S)=>S.path===N);if(_<0)return L;let k=L.filter((S)=>S.path!==N);if(N===Z)if(k.length===0)H(null);else H(k[Math.max(0,_-1)].path);return k}),x8.current.delete(N),C8((L)=>L===N?null:L)},[Z]),aX=u.useCallback(()=>{if(!Z||Z===S8){if(Z===S8)RX();return}let N=x8.current.get(Z);if(N)N.src=N.src},[Z,RX]),iY=u.useCallback(()=>b0(),[b0]),[uW,oY]=u.useState(!1),xQ=u.useRef(!1),hQ=u.useCallback(async()=>{if(xQ.current)return;xQ.current=!0,oY(!0);try{await Promise.all([b0(),new Promise((N)=>setTimeout(N,550))])}finally{xQ.current=!1,oY(!1)}},[b0]);u.useEffect(()=>{let N=null,L=()=>{if(N)clearTimeout(N);N=setTimeout(()=>{N=null,iY()},150)};return window.addEventListener("focus",L),()=>{if(window.removeEventListener("focus",L),N)clearTimeout(N)}},[iY]);let lW=u.useCallback(async(N)=>{try{let L=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:N,kind:"brief-board"})}),_=await L.json().catch(()=>({}));if(!L.ok||!_.ok)return{ok:!1,error:_.error||`create failed (${L.status})`};return await b0(),F6(_.file),{ok:!0,file:_.file}}catch(L){return{ok:!1,error:L instanceof Error?L.message:"network error"}}},[b0,F6]),nY=u.useCallback(async()=>{let N=await CJ("New video name");if(!N)return;let _=(await CJ("Size — 1920x1080 (landscape), 1080x1920 (portrait), 1080x1080 (square), or custom WxH","1920x1080")||"1920x1080").toLowerCase().match(/(\d{2,5})\s*[x×]\s*(\d{2,5})/),k=_?Number(_[1]):1920,S=_?Number(_[2]):1080,x=Math.max(1,Math.min(60,Number(await CJ("Frames per second","30"))||30));try{let j=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:N,kind:"video-comp",clips:[],fps:x,width:k,height:S})}),d=await j.json().catch(()=>({}));if(!j.ok||!d.ok){M8(`New video failed: ${d.error||`error ${j.status}`}`);return}await b0(),F6(d.file),e6(!0),M8("New video created — drop clips on the timeline to start the cut.",!0)}catch(j){M8(`New video failed: ${j instanceof Error?j.message:"network error"}`)}},[b0,F6,CJ]),pW=u.useCallback(async()=>{if(!Z||Z===S8)return;try{let N=await fetch(`/_api/annotations?file=${encodeURIComponent(Z)}`),L=N.ok?await N.text():"",_=[];if(L){let d=new DOMParser().parseFromString(L,"image/svg+xml");for(let X0 of d.querySelectorAll('[data-tool="mediaref"]')){let Y0=X0.getAttribute("data-src");if(!Y0)continue;_.push({src:Y0,mediaKind:X0.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(_.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let S=`${AW(dN(Z)).replace(/\.tsx$/i,"")} Video`,x=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:S,kind:"video-comp",clips:_})}),j=await x.json().catch(()=>({}));if(!x.ok||!j.ok){window.alert(`Assemble failed: ${j.error||`error ${x.status}`}`);return}await b0(),F6(j.file)}catch(N){window.alert(`Assemble failed: ${N instanceof Error?N.message:"network error"}`)}},[Z,b0,F6]),gQ=u.useCallback(({accept:N,resolveTarget:L})=>{let _=Z,k=_8||void 0,S=document.createElement("input");S.type="file",S.accept=N,S.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(S);let x=()=>{if(S.isConnected)S.remove()};window.addEventListener("focus",()=>setTimeout(x,300),{once:!0}),S.addEventListener("change",()=>{let j=S.files?.[0];if(x(),!j)return;let d=`/_api/comp-clips?canvas=${encodeURIComponent(_)}${k?`&artboardId=${encodeURIComponent(k)}`:""}`;fetch(d).then((X0)=>X0.json().catch(()=>({}))).then((X0)=>{let Y0=L(X0);if(!Y0)return M8("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":j.type||"application/octet-stream"},body:j}).then((V0)=>V0.json().catch(()=>({}))).then((V0)=>{if(!V0?.path)return M8(`Upload failed: ${V0?.error||"unknown error"}`),null;if(Y0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:_,arrayName:Y0.arrayRef.arrayName,index:Y0.arrayRef.index,field:Y0.arrayRef.field,value:V0.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:_,id:Y0.cdId,attr:"src",value:V0.path})})})}).then((X0)=>X0?X0.json():null).then((X0)=>{if(X0&&!X0.ok)M8(`Replace refused: ${X0.error||"failed"}`);else if(X0&&X0.ok){if(M8("Media replaced.",!0),X0.seq!=null)x7(_,X0.seq,"replace media")}}).catch(()=>M8("Replace failed: network error"))}),S.click()},[Z,_8,x7]),dW=u.useCallback(async(N,L)=>{if(!window.confirm(`Move “${L}” to trash?
|
|
5654
5654
|
|
|
5655
5655
|
Its annotations, history and comments move with it. `+"You can restore it from .design/_trash/."))return;try{let k=await fetch(`/_api/canvas?file=${encodeURIComponent(N)}`,{method:"DELETE"}),S=await k.json().catch(()=>({}));if(!k.ok||!S.ok){window.alert(`Could not delete: ${S.error||`error ${k.status}`}`);return}if(await b0(),Z===N)G([]),H(null)}catch(k){window.alert(`Delete failed: ${k instanceof Error?k.message:"network error"}`)}},[b0,Z]),cW=u.useCallback(async function N(L,_){try{let k=await fetch("/_api/fs-move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:L,toDir:_})}),S=await k.json().catch(()=>({}));if(!k.ok||!S.ok)return M8(`Could not move: ${S.error||`error ${k.status}`}`),{ok:!1,error:S.error};let x=($0?.designRel||$0?.designRoot||".design").replace(/^\/+|\/+$/g,""),j=`${x}/${S.fromRel}`,d=`${x}/${S.toRel}`;await b0(),G((Y0)=>Y0.map((V0)=>V0.path===j?{path:d}:V0)),H((Y0)=>Y0===j?d:Y0);let X0=j.split("/").slice(0,-1).join("/");return M8(`Moved to ${S.toRel.split("/").slice(0,-1).join("/")||"."}`,!0,{label:"Undo",onClick:()=>{N(d,X0)}}),{ok:!0}}catch(k){return M8(`Move failed: ${k instanceof Error?k.message:"network error"}`),{ok:!1,error:"network error"}}},[b0,$0]),iW=u.useCallback(async(N,L)=>{try{let _=await fetch("/_api/fs-mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parent:N,name:L})}),k=await _.json().catch(()=>({}));if(!_.ok||!k.ok){let S=k.error||`error ${_.status}`;return M8(`Could not create folder: ${S}`),{ok:!1,error:S}}return await b0(),{ok:!0,dir:k.dir}}catch(_){let k=_ instanceof Error?_.message:"network error";return M8(`Create folder failed: ${k}`),{ok:!1,error:k}}},[b0]),oW=u.useCallback(async(N,L)=>{if(!window.confirm(`Delete folder "${L}"?
|
|
5656
5656
|
|