@1agh/maude 1.4.3 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5680,7 +5680,7 @@ ${B.block}`:V,F=[],M=new Map;for await(let A of J.prompt(N,X(),K,Q?.(),Y?.(),Z?.
5680
5680
 
5681
5681
  > Maude ${p.app.maudeVersion} · ${p.app.platform} ${p.app.arch} · ${p.app.surface}
5682
5682
  > Local report bundle: \`${e?.dir??".design/_reports/"}\` (attach its files here)`),s=`${iU0}?title=${c}&body=${K0}&labels=report`;if(G9())try{await LV(s)}catch{window.open(s,"_blank","noopener")}else window.open(s,"_blank","noopener");k({fallbackDir:e?.dir??null}),W("done")}catch{$("Saving the local bundle failed too — please file the issue by hand.")}}let h=G.trim().length>0;return z("div",{className:"st-scrim",onClick:m,"data-testid":"report-bug-dialog",children:D("div",{className:"st-dialog rb-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"rb-title",onClick:(p)=>p.stopPropagation(),children:[D("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",id:"rb-title",children:"Report a bug"}),z("button",{type:"button",className:"st-iconbtn",onClick:m,"aria-label":"Close",children:"×"})]}),D("div",{className:"st-dialog-bd rb-body",children:[Y==="describe"&&D(Q0,{children:[z("label",{className:"rb-label",htmlFor:"rb-desc",children:"What happened? What did you expect instead?"}),z("textarea",{id:"rb-desc",className:"textarea","data-testid":"report-bug-description",rows:5,autoFocus:!0,value:G,onChange:(p)=>Z(p.target.value),placeholder:"e.g. Clicking Export → PNG shows a spinner forever…"}),z("p",{className:"rb-hint",children:"Next you'll see exactly what gets attached — nothing is sent until you approve it."}),D("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:m,children:"Cancel"}),z("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-preview",disabled:!h,onClick:()=>W("preview"),children:"Review & attach"})]})]}),Y==="preview"&&D(Q0,{children:[D("div",{className:"rb-section",children:[D("div",{className:"rb-section-hd",children:[D("span",{children:["Screenshots (",U.length,")"]}),D("span",{className:"rb-hd-actions",children:[U.length<BE&&z("button",{type:"button",className:"rb-link","data-testid":"report-bug-attach",onClick:x,children:"Attach screenshot…"}),U.length>0&&z("button",{type:"button",className:`rb-link${w?" is-on":""}`,"data-testid":"report-bug-redact",onClick:()=>O((p)=>!p),children:w?"Done redacting":"Redact…"})]})]}),D("p",{className:"rb-hint",children:["Maude captures its own window and the active artboard for you. The window shot is a fresh render, so anything mid-flight — an open menu, a stuck spinner — won't be in it: grab that yourself (",oU0(H?.app?.platform),") and attach or paste (⌘V) it here."]}),A&&z("p",{className:"rb-hint","data-testid":"report-bug-shell-pending",children:"Capturing the Maude window…"}),U.length===0&&!A?D("p",{className:"rb-hint",children:["No screenshot attached yet — up to ",BE,"."]}):D(Q0,{children:[w&&z("p",{className:"rb-hint",children:"Drag over anything private — it ships as solid black."}),z("div",{className:"rb-shots",children:U.map((p,v)=>z(aU0,{shot:p,redacting:w,onRects:(r)=>V((e)=>e.map((c,K0)=>K0===v?{...c,rects:r}:c)),onRemove:()=>{URL.revokeObjectURL(p.url),V((r)=>r.filter((e,c)=>c!==v))}},p.url))})]})]}),D("div",{className:"rb-section",children:[z("div",{className:"rb-section-hd",children:z("span",{children:"Included with the report"})}),D("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:!0,disabled:!0}),D("span",{children:["Maude ",H?.app?.maudeVersion??"…"," · ",H?.app?.platform??"…"," ",H?.app?.arch??""," · ",G9()?"desktop app":"browser"]})]}),Q&&D("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.activeCanvas,onChange:(p)=>M({...F,activeCanvas:p.target.checked})}),D("span",{children:["Active canvas path — ",z("code",{children:Q})]})]}),H?.context?.projectName&&D("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.projectName,onChange:(p)=>M({...F,projectName:p.target.checked})}),D("span",{children:["Project name — ",z("code",{children:H.context.projectName})]})]}),H?.logs?.serverLogTail?D("label",{className:"rb-check",children:[z("input",{type:"checkbox","data-testid":"report-bug-consent-logs",checked:F.logTail,onChange:(p)=>M({...F,logTail:p.target.checked})}),D("span",{children:["Recent server log (",H.logs.serverLogTail.split(`
5683
- `).length," lines, paths & secrets scrubbed)",H?.process?` + server memory (${Math.round(H.process.rssBytes/1048576)} MB)`:""," ","—"," ",D("details",{className:"rb-details",children:[z("summary",{children:"view"}),z("pre",{className:"rb-log",children:H.logs.serverLogTail})]})]})]}):null,G9()&&B.length>0&&D("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.crashLogs,onChange:(p)=>M({...F,crashLogs:p.target.checked})}),D("span",{children:["Crash logs (",B.length,") — ",z("code",{children:B.map((p)=>p.name).join(", ")})]})]})]}),D("p",{className:"rb-hint",children:["Your description and the system info above become a"," ",z("strong",{children:"public GitHub issue"}),"; screenshots and logs go to a private repository only maintainers can open."]}),D("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("describe"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-send",onClick:a,children:"Send report"})]})]}),Y==="sending"&&z("p",{className:"rb-hint",children:"Sending your report…"}),Y==="done"&&D(Q0,{children:[I?.issueUrl?D("p",{children:["Thank you — your report is filed as"," ",D("button",{type:"button",className:"rb-link","data-testid":"report-bug-issue-link",onClick:()=>{if(G9())LV(I.issueUrl).catch(()=>navigator.clipboard?.writeText(I.issueUrl));else window.open(I.issueUrl,"_blank","noopener")},children:["report #",I.issueNumber]})," ","on the public Maude issue tracker. Screenshots and logs stay in a private repository only maintainers can open — the issue links to them."]}):D("p",{children:["The bundle is saved locally",I?.fallbackDir?D(Q0,{children:[" ","at ",z("code",{children:I.fallbackDir})]}):null," ","and a prefilled GitHub issue was opened — attach the bundle files there."]}),z("footer",{className:"rb-actions",children:z("button",{type:"button",className:"st-btn rb-primary",onClick:m,children:"Done"})})]}),Y==="fallback"&&D(Q0,{children:[z("p",{className:"rb-error","data-testid":"report-bug-error",children:R}),z("p",{className:"rb-hint",children:"You can save the report locally instead and file it on GitHub yourself — the prefilled issue carries the text; screenshots stay on this machine unless you attach them by hand."}),D("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("preview"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary",onClick:f,children:"Save locally & open GitHub"})]})]})]})]})})}var TJ=j8(s8(),1);function wm(J){if(typeof J!=="string")return null;let X=J.match(/^(\d+)\.(\d+)\.(\d+)/);return X?[Number(X[1]),Number(X[2]),Number(X[3])]:null}function Em(J,X){let Q=wm(J),Y=wm(X);if(!Q)return!1;if(!Y)return!0;for(let W=0;W<3;W++)if(Q[W]!==Y[W])return Q[W]>Y[W];return!1}function Pm(J,X){if(!Array.isArray(J))return[];return J.filter((Q)=>Q&&(Q.version==null||Em(Q.version,X)))}function Im(J,X){let Q=X;if(Array.isArray(J)){for(let Y of J)if(Y&&Y.version&&Em(Y.version,Q))Q=Y.version}return Q}var NE="mdcc-whatsnew-seen",FE="mdcc-whatsnew-toast-dismissed";function sU0(J){return typeof J==="string"&&/^https?:\/\//i.test(J)}function tU0(J){try{let X=localStorage.getItem(NE);if(X)return X;localStorage.setItem(NE,J)}catch{}return J}function eU0(){try{return localStorage.getItem(FE)}catch{return null}}function Tm(J){let[X,Q]=TJ.useState([]),[Y,W]=TJ.useState(J),[G,Z]=TJ.useState(()=>tU0(J)),[H,K]=TJ.useState(()=>eU0()),[U,V]=TJ.useState(!1);TJ.useEffect(()=>{let O=!1,I=()=>{fetch("/_api/whats-new").then(($)=>$.json()).then(($)=>{if(O)return;if(Q(Array.isArray($?.entries)?$.entries:[]),typeof $?.version==="string")W($.version)}).catch(()=>{})};I();let k=()=>I(),R=()=>{if(document.visibilityState==="visible")I()};return window.addEventListener("focus",k),document.addEventListener("visibilitychange",R),()=>{O=!0,window.removeEventListener("focus",k),document.removeEventListener("visibilitychange",R)}},[]);let B=Pm(X,G),N=B.length>0&&H!==Y&&!U,F=B[0]??null,M=TJ.useCallback(()=>{let O=Im(X,Y);Z(O),K(Y);try{localStorage.setItem(NE,O),localStorage.setItem(FE,Y)}catch{}},[X,Y]),A=TJ.useCallback(()=>{K(Y);try{localStorage.setItem(FE,Y)}catch{}},[Y]),E=TJ.useCallback(()=>V(!0),[]),w=TJ.useCallback(()=>{V(!1),M()},[M]);return{entries:X,unseen:B,feedVersion:Y,panelOpen:U,openPanel:E,closePanel:w,showToast:N,toastEntry:F,dismissToast:A,markAllSeen:M}}function km({wn:J}){let X=`whats-new-${J.feedVersion}`;return TJ.useEffect(()=>{if(!J.showToast||!J.toastEntry){$W(X);return}P5({id:X,group:"whats-new",kind:"info",duration:1e4,title:`What's new${J.toastEntry.version?` · v${J.toastEntry.version}`:""} — ${J.toastEntry.title}`,description:J.toastEntry.summary,action:{label:J.unseen.length>1?`See all (${J.unseen.length})`:"Details",onClick:J.openPanel},onDismiss:J.dismissToast})},[X,J.showToast,J.toastEntry,J.unseen.length,J.openPanel,J.dismissToast]),TJ.useEffect(()=>()=>$W(X),[X]),null}function Rm({wn:J,onStartTour:X}){let{panelOpen:Q,closePanel:Y}=J;if(TJ.useEffect(()=>{if(!Q)return;function G(Z){if(Z.key==="Escape")Y()}return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[Q,Y]),!Q)return null;let W=new Set(J.unseen.map((G)=>G.id));return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)Y()},children:D("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[D("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"mdcc-wn-title",children:"✦ What’s new in maude"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:Y,children:"×"})]}),z("div",{className:"mdcc-wn-panel__body",children:J.entries.length===0?z("p",{className:"mdcc-wn-empty",children:"Nothing new yet."}):z("ul",{className:"mdcc-wn-list",children:J.entries.map((G)=>D("li",{className:"mdcc-wn-item"+(W.has(G.id)?" is-unseen":""),children:[D("div",{className:"mdcc-wn-item__hd",children:[z("span",{className:"mdcc-wn-kind mdcc-wn-kind--"+G.kind,children:G.kind}),z("span",{className:"mdcc-wn-item__title",children:G.title}),z("span",{className:"mdcc-wn-item__ver",children:G.version?`v${G.version}`:"next"})]}),z("p",{className:"mdcc-wn-item__summary",children:G.summary}),sU0(G.learnMore)&&z("a",{className:"mdcc-wn-item__more",href:G.learnMore,target:"_blank",rel:"noreferrer",children:"Learn more →"}),X&&Array.isArray(G.tour)&&G.tour.length>0&&z("button",{type:"button",className:"mdcc-wn-item__tour",onClick:()=>{Y(),X(G.tour)},children:"▶ Take tour"})]},G.id))})})]})})}var K7=({as:J,size:X=14})=>z(J,{size:X,strokeWidth:1.75,style:{display:"block"}}),g80="mdcc-usage-tour-seen",m80="mdcc-collab-tour-seen",r8="__system__",A90="mdcc-theme",u80="mdcc-show-hidden",p80="mdcc-sections-expanded",l80="maude-cp-mode",d80="mdcc-sidebar-open",c80="mdcc-minimap-visible",i80="mdcc-zoomctl-visible",o80="mdcc-annotations-visible";var zF0=30000;function KF0(J){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(J)}).catch(()=>{})}catch{}}var Gk=[{id:"tree",label:"Files"},{id:"layers",label:"Layers"},{id:"inspector",label:"Inspector"},{id:"comments",label:"Comments"},{id:"changes",label:"Changes"},{id:"sync",label:"Sync"},{id:"assistant",label:"Assistant"}],sK={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",sync:"right",assistant:"right"},n80="mdcc-panel-sides",r80="mdcc-layers-mode";function a80({side:J,width:X,open:Q,ids:Y,activeId:W,onPick:G,children:Z,labels:H=null}){return D("div",{className:"st-dockslot st-dockslot--"+J+(Q?"":" is-collapsed"),style:{width:Q?X:0,flexBasis:Q?X:0},children:[Q&&Y.length>1&&z("div",{className:"st-docktabs",role:"tablist","aria-label":J+" panels",children:Y.map((K)=>z("button",{type:"button",role:"tab","data-testid":`dock-tab-${K}`,"aria-selected":W===K,className:"st-docktab"+(W===K?" is-active":""),onClick:()=>G(K),children:H?.[K]||(Gk.find((U)=>U.id===K)||{}).label||K},K))}),Z]})}var y5=/\.(tsx|html?)$/i,UF0=[[/\.md$/i,"markdown"],[/\.(css|json|txt|ya?ml)$/i,"text"],[/\.(svg|png|jpe?g|gif|webp|avif)$/i,"image"],[/\.(mp4|webm|mov)$/i,"video"],[/\.(mp3|wav|ogg|m4a)$/i,"audio"],[/\.(woff2?|ttf|otf)$/i,"font"]];function NL(J){for(let[X,Q]of UF0)if(X.test(J))return Q;return null}function Bq(J){return J.replace(/^\.[^/]+\//,"").replace(y5,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}function VF0(J){let X=[];return function Q(Y){for(let W of Y||[])X.push(W?.id??""),Q(W?.children)}(J),X.join(",")}var Zk="1.4.3";function WL(J,X){let Q=()=>{try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(J,{body:X})}catch{}};if(G9()){O7("send_notification",{title:J,body:X}).catch(Q);return}Q()}function qF0(){if(typeof window>"u")return"dark";try{let J=localStorage.getItem(A90);if(J==="light"||J==="dark")return J}catch{}return"dark"}function IH(J,X){if(typeof window>"u")return X;try{let Q=localStorage.getItem(J);if(Q==="1")return!0;if(Q==="0")return!1}catch{}return X}function Xk(J,X){if(typeof window>"u")return X;try{let Q=localStorage.getItem(J);return Q?JSON.parse(Q):X}catch{return X}}function BF0(J){if(J.kind==="runtime")return!1;if(J.label==="Design system")return!1;return!0}function Y4(J){return J.split("/").pop()}function f8(J,X=!1,Q){P5({title:J,kind:X?"success":"error",action:Q})}var s80="maude-mode-hint-seen";function HL(J=!1){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(s80)==="1")return}catch{return}if(HL.active)return;HL.active=!0;let X=()=>{HL.active=!1;try{localStorage.setItem(s80,"1")}catch{}document.removeEventListener("keydown",Q,!0)},Q=(Y)=>{if((Y.key==="v"||Y.key==="V")&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey)$W("mode-hint"),X()};if(J)document.addEventListener("keydown",Q,!0);P5({id:"mode-hint",title:J?"Your mock is live":"You’re in Edit",description:J?"Click things to try it. Press V to select & inspect.":"Click selects, like Figma. Switch to Preview in the toolbar to use the live mock.",onDismiss:X})}function VY(J){return J.replace(y5,"")}function NF0(J){return J.replace(y5,"")}function FF0(J){let X=new Map;for(let G of J){if(!y5.test(G.name))continue;let Z=NF0(G.name);if(!X.has(Z)||/\.tsx$/i.test(G.name))X.set(Z,G)}let Q=new Map,Y=[];for(let G of J){if(y5.test(G.name))continue;let Z=null;for(let H of X.keys()){if(G.name===H)continue;if(G.name.startsWith(`${H}.`)){if(!Z||H.length>Z.length)Z=H}}if(Z){let H=Q.get(Z)||[];H.push(G),Q.set(Z,H)}else Y.push(G)}let W=[];for(let[G,Z]of X){let H=(Q.get(G)||[]).sort((K,U)=>K.name.localeCompare(U.name));W.push({primary:Z,sidecars:H,orphan:!1})}return W.sort((G,Z)=>G.primary.name.localeCompare(Z.primary.name)),Y.sort((G,Z)=>G.name.localeCompare(Z.name)),{canvases:W,orphans:Y.map((G)=>({primary:G,sidecars:[],orphan:!0}))}}function LF0(J,X,Q){let Y={};for(let W of Q||[]){let Z=(W.startsWith(X)?W.slice(X.length).replace(/^\/+/,""):W).split("/").filter(Boolean),H=Y;for(let K of Z)H=H[K]=H[K]||{};H._files=H._files||[]}for(let W of J){let Z=(W.startsWith(X)?W.slice(X.length).replace(/^\/+/,""):W).split("/"),H=Y;for(let K=0;K<Z.length;K++){let U=Z[K];if(K===Z.length-1)H._files=H._files||[],H._files.push({name:U,path:W});else H[U]=H[U]||{},H=H[U]}}return Y}function _90(J,X){if(!X)return J;let Q=X.toLowerCase(),Y={},W=!1,G=Object.keys(J).filter((Z)=>Z!=="_files");for(let Z of G){let H=_90(J[Z],X);if(H)Y[Z]=H,W=!0}if(J._files){let Z=J._files.filter((H)=>H.name.toLowerCase().includes(Q)||H.path.toLowerCase().includes(Q));if(Z.length)Y._files=Z,W=!0}return W?Y:null}function zL(J){return(J||[]).filter((X)=>X.status!=="resolved").length}function DF0(J){if(!J)return"";let X=new Date(J).getTime();if(!X)return"";let Q=Math.max(0,Math.floor((Date.now()-X)/1000));if(Q<60)return Q+"s";let Y=Math.floor(Q/60);if(Y<60)return Y+"m";let W=Math.floor(Y/60);if(W<24)return W+"h";let G=Math.floor(W/24);if(G<7)return G+"d";return new Date(J).toLocaleDateString()}function w90(J){let X=0,Q=0,Y=0;for(let W of Object.values(J||{}))for(let G of W||[])if(X++,G.status==="resolved")Y++;else Q++;return{all:X,open:Q,resolved:Y}}function UL({d:J,size:X=14,color:Q}){return z("svg",{width:X,height:X,viewBox:"0 0 24 24",fill:"none",stroke:Q||"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{flex:"none"},children:z("path",{d:J})})}var MF0={"chevron-down":z("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":z("polyline",{points:"6 3.5 10.5 8 6 12.5"}),file:D(Q0,{children:[z("path",{d:"M4 2h5l3 3v9H4z"}),z("polyline",{points:"9 2 9 5 12 5"})]}),folder:z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),"folder-plus":D(Q0,{children:[z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),z("path",{d:"M8 7.5v3.5M6.25 9.25h3.5"})]}),lock:D(Q0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015 0v2"})]}),unlock:D(Q0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015-.7"})]}),search:D(Q0,{children:[z("circle",{cx:"7",cy:"7",r:"4"}),z("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:D(Q0,{children:[z("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),z("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),check:z("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),x:D(Q0,{children:[z("line",{x1:"4.3",y1:"4.3",x2:"11.7",y2:"11.7"}),z("line",{x1:"11.7",y1:"4.3",x2:"4.3",y2:"11.7"})]}),sun:D(Q0,{children:[z("circle",{cx:"8",cy:"8",r:"2.6"}),z("line",{x1:"8",y1:"1.5",x2:"8",y2:"3"}),z("line",{x1:"8",y1:"13",x2:"8",y2:"14.5"}),z("line",{x1:"1.5",y1:"8",x2:"3",y2:"8"}),z("line",{x1:"13",y1:"8",x2:"14.5",y2:"8"}),z("line",{x1:"3.4",y1:"3.4",x2:"4.4",y2:"4.4"}),z("line",{x1:"11.6",y1:"11.6",x2:"12.6",y2:"12.6"}),z("line",{x1:"12.6",y1:"3.4",x2:"11.6",y2:"4.4"}),z("line",{x1:"4.4",y1:"11.6",x2:"3.4",y2:"12.6"})]}),moon:z("path",{d:"M12.5 9.6A5 5 0 1 1 7 3a4 4 0 0 0 5.5 6.6z"}),sparkle:z("path",{d:"M8 1.8l1.4 4.8L14 8l-4.6 1.4L8 14.2l-1.4-4.8L2 8l4.6-1.4z",fill:"currentColor",stroke:"none"}),megaphone:D(Q0,{children:[z("path",{d:"M2 6.7 11 4v8L2 9.3z"}),z("path",{d:"M11 5.2a2.4 2.4 0 0 1 0 5.6"}),z("path",{d:"M4.3 9.5v2.3a1.2 1.2 0 0 0 2.4 0v-1.7"})]}),bug:D(Q0,{children:[z("circle",{cx:"8",cy:"9",r:"3.6"}),z("circle",{cx:"8",cy:"4.4",r:"1.3"}),z("path",{d:"M6.2 3.4 5.2 2M9.8 3.4l1-1.4"}),z("path",{d:"M4.6 7.6H2.2M4.6 9H2.2M4.6 10.6H2.5M11.4 7.6h2.4M11.4 9h2.4M11.4 10.6h2.3"})]}),"panel-left":D(Q0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("line",{x1:"6.4",y1:"3",x2:"6.4",y2:"13"})]}),resolve:D(Q0,{children:[z("circle",{cx:"8",cy:"8",r:"5.6"}),z("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:D(Q0,{children:[z("path",{d:"M3.2 8a5 5 0 1 1 1.4 3.5"}),z("polyline",{points:"3.2 11.4 3.2 8 6.6 8"})]}),layers:D(Q0,{children:[z("polygon",{points:"8 2.2 13.8 5.5 8 8.8 2.2 5.5"}),z("polyline",{points:"2.2 9 8 12.3 13.8 9"})]}),box:z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.2"}),type:D(Q0,{children:[z("polyline",{points:"4 4 12 4"}),z("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:D(Q0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"3"}),z("line",{x1:"6",y1:"8",x2:"10",y2:"8"})]}),input:D(Q0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"1.2"}),z("line",{x1:"5",y1:"8",x2:"5",y2:"8"})]}),link:D(Q0,{children:[z("path",{d:"M6.5 9.5a2.5 2.5 0 0 1 0-3.5l1.5-1.5a2.5 2.5 0 0 1 3.5 3.5l-1 1"}),z("path",{d:"M9.5 6.5a2.5 2.5 0 0 1 0 3.5l-1.5 1.5a2.5 2.5 0 0 1-3.5-3.5l1-1"})]}),list:D(Q0,{children:[z("line",{x1:"6",y1:"4.5",x2:"13",y2:"4.5"}),z("line",{x1:"6",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6",y1:"11.5",x2:"13",y2:"11.5"}),z("circle",{cx:"3.2",cy:"4.5",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"8",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"11.5",r:"0.8",fill:"currentColor"})]}),eye:D(Q0,{children:[z("path",{d:"M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z"}),z("circle",{cx:"8",cy:"8",r:"2"})]}),eyedropper:D(Q0,{children:[z("path",{d:"M11 2.6a1.7 1.7 0 0 1 2.4 2.4l-1.2 1.2-2.4-2.4z"}),z("path",{d:"M9.5 4.6 4 10.1V12h1.9l5.5-5.5"})]}),"p-corner":z("path",{d:"M3.5 12.5V7a3.5 3.5 0 0 1 3.5-3.5h5.5"}),"p-opacity":D(Q0,{children:[z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.5"}),z("path",{d:"M3 8h10M8 3v10",strokeWidth:"0.9",opacity:"0.55"})]}),"p-lineheight":D(Q0,{children:[z("line",{x1:"6.5",y1:"4",x2:"13",y2:"4"}),z("line",{x1:"6.5",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6.5",y1:"12",x2:"13",y2:"12"}),z("path",{d:"M3.2 4.6 3.2 11.4M2 6 3.2 4.5 4.4 6M2 10 3.2 11.5 4.4 10"})]}),"p-letterspacing":D(Q0,{children:[z("path",{d:"M3 4v8M13 4v8"}),z("path",{d:"M6 11.5 8 5l2 6.5M6.7 9.3h2.6",strokeWidth:"1.1"})]}),"p-gap":D(Q0,{children:[z("rect",{x:"2",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("rect",{x:"10.4",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("path",{d:"M6.8 8h2.4M7.4 6.9 6.4 8l1 1.1M8.6 6.9 9.6 8l-1 1.1",strokeWidth:"1"})]}),"p-border":z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"}),"p-size":D(Q0,{children:[z("path",{d:"M3 13 6.6 3l3.6 10"}),z("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":D(Q0,{children:[z("path",{d:"M6.3 4A6.7 6.7 0 0 1 8 3.5C12 3.5 14.5 8 14.5 8a12 12 0 0 1-2 2.4M4.4 5.3A12 12 0 0 0 1.5 8S4 12.5 8 12.5a6.5 6.5 0 0 0 2.1-.35"}),z("line",{x1:"2.5",y1:"2.5",x2:"13.5",y2:"13.5"})]}),sliders:D(Q0,{children:[z("line",{x1:"3",y1:"5",x2:"13",y2:"5"}),z("circle",{cx:"6",cy:"5",r:"1.7",fill:"currentColor"}),z("line",{x1:"3",y1:"11",x2:"13",y2:"11"}),z("circle",{cx:"10",cy:"11",r:"1.7",fill:"currentColor"})]}),code:D(Q0,{children:[z("polyline",{points:"6 5 3 8 6 11"}),z("polyline",{points:"10 5 13 8 10 11"})]}),download:D(Q0,{children:[z("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),z("polyline",{points:"4.5 7 8 10.5 11.5 7"}),z("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),reload:D(Q0,{children:[z("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),z("path",{d:"M14 2v3.33h-3.33"})]}),help:D(Q0,{children:[z("circle",{cx:"8",cy:"8",r:"6"}),z("path",{d:"M6.3 6.2a1.8 1.8 0 1 1 2.3 1.9c-.5.2-.6.5-.6 1v.3"}),z("line",{x1:"8",y1:"11.4",x2:"8",y2:"11.5"})]}),image:D(Q0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("circle",{cx:"6",cy:"6.3",r:"1.1"}),z("path",{d:"M3 12l3-2.8 2.2 1.8 2.4-3L13.5 12"})]}),vector:D(Q0,{children:[z("path",{d:"M3.6 11.2C6 5 10 5 12.4 11.2"}),z("rect",{x:"1.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"11.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"6.7",y:"2.6",width:"2.6",height:"2.6",rx:"0.4"})]}),presentation:D(Q0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"7.4",rx:"1"}),z("line",{x1:"8",y1:"10.4",x2:"8",y2:"13"}),z("line",{x1:"5.6",y1:"13.4",x2:"10.4",y2:"13.4"})]}),archive:D(Q0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"3",rx:"0.8"}),z("path",{d:"M3.6 6v6.2a1 1 0 0 0 1 1h6.8a1 1 0 0 0 1-1V6"}),z("line",{x1:"6.6",y1:"8.8",x2:"9.4",y2:"8.8"})]}),external:D(Q0,{children:[z("path",{d:"M11 8.5V12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h3.5"}),z("polyline",{points:"9.5 3 13 3 13 6.5"}),z("line",{x1:"13",y1:"3",x2:"7.6",y2:"8.4"})]}),share:D(Q0,{children:[z("circle",{cx:"4",cy:"8",r:"1.9"}),z("circle",{cx:"11.6",cy:"3.6",r:"1.9"}),z("circle",{cx:"11.6",cy:"12.4",r:"1.9"}),z("line",{x1:"5.7",y1:"7",x2:"9.9",y2:"4.6"}),z("line",{x1:"5.7",y1:"9",x2:"9.9",y2:"11.4"})]}),pen:D(Q0,{children:[z("path",{d:"M3 13l.8-3L10.6 3.2a1.1 1.1 0 0 1 1.6 0l.6.6a1.1 1.1 0 0 1 0 1.6L6 12.2z"}),z("line",{x1:"9.6",y1:"4.2",x2:"11.8",y2:"6.4"})]}),square:z("rect",{x:"3.5",y:"3.5",width:"9",height:"9",rx:"1"})};function OF0({open:J,onClose:X,actions:Q}){let[Y,W]=u.useState(""),[G,Z]=u.useState(0),H=u.useRef(null);u.useEffect(()=>{if(J)W(""),Z(0)},[J]),u.useEffect(()=>{H.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[G]);let K=u.useMemo(()=>i2(Q,Y),[Y,Q]);if(u.useEffect(()=>{if(G>=K.length)Z(0)},[K.length,G]),!J)return null;let U=(V)=>{X(),V.run()};return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(V)=>{if(V.target===V.currentTarget)X()},children:D("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[D("div",{className:"st-pal-search",children:[z(T9,{name:"search",size:18}),z("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(V)=>W(V.target.value),onKeyDown:(V)=>{if(V.key==="Escape")V.preventDefault(),X();else if(V.key==="ArrowDown")V.preventDefault(),Z((B)=>Math.min(K.length-1,B+1));else if(V.key==="ArrowUp")V.preventDefault(),Z((B)=>Math.max(0,B-1));else if(V.key==="Enter"){V.preventDefault();let B=Tb(Q,Y,V.currentTarget.value,G);if(B)U(B)}}}),z(CJ,{children:"⌘K"})]}),z("div",{className:"st-pal-list",ref:H,children:K.length===0?z("div",{className:"st-pal-empty",children:"No matching command."}):K.map((V,B)=>{let N=V.group&&(B===0||K[B-1].group!==V.group)?z("div",{className:"st-pal-group",children:V.group},"g-"+V.group):null;return D(Q0,{children:[N,D("button",{type:"button",className:"st-pal-item"+(B===G?" is-active":""),onMouseEnter:()=>Z(B),onClick:()=>U(V),children:[z("span",{className:"st-pal-icon",children:z(T9,{name:V.icon,size:15})}),z("span",{className:"st-pal-label",children:V.label}),V.kbd?z("span",{className:"st-pal-kbd",children:z(CJ,{children:V.kbd})}):null]})]},V.id)})})]})})}function T9({name:J,size:X=16,className:Q}){return z("svg",{className:Q,width:X,height:X,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:MF0[J]})}function AF0(J){if(!J||typeof J!=="string")return"?";let X=J.trim().split(/[\s._-]+/).filter(Boolean);if(!X.length)return"?";if(X.length===1)return X[0].slice(0,2).toUpperCase();return((X[0][0]||"")+(X[X.length-1][0]||"")).toUpperCase()||"?"}function t80({initials:J,hue:X,title:Q,pulse:Y}){return z("span",{className:"st-avatar"+(Y?" is-pulsing":""),style:{"--av-hue":X},"data-tip":Q,"aria-label":Q,children:J})}function CJ({children:J}){return z("span",{className:"kbd",children:J})}function e80(J,{min:X,max:Q,def:Y}){let W=u.useCallback((K)=>Math.min(Q,Math.max(X,K)),[X,Q]),[G,Z]=u.useState(()=>{try{let K=parseInt(localStorage.getItem(J)||"",10);return Number.isFinite(K)?W(K):Y}catch{return Y}});u.useEffect(()=>{try{localStorage.setItem(J,String(G))}catch{}},[J,G]);let H=u.useCallback((K)=>Z((U)=>W(typeof K==="function"?K(U):K)),[W]);return{w:G,setW:H,min:X,max:Q,def:Y}}function J90({label:J,size:X,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:K,def:U}=X,V=W==="rtl"?-1:1;return z("div",{className:"st-grip"+(Y?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":J,"aria-valuemin":H,"aria-valuemax":K,"aria-valuenow":Math.round(G),onPointerDown:Q,onDoubleClick:()=>Z(U),onKeyDown:(B)=>{let N=B.shiftKey?24:8;if(B.key==="ArrowRight")B.preventDefault(),Z((F)=>F+N*V);else if(B.key==="ArrowLeft")B.preventDefault(),Z((F)=>F-N*V);else if(B.key==="Home")B.preventDefault(),Z(H);else if(B.key==="End")B.preventDefault(),Z(K)},children:D("svg",{className:"st-grip-dots",viewBox:"0 0 6 18","aria-hidden":"true",children:[z("circle",{cx:"3",cy:"3",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"9",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"15",r:"1.1",fill:"currentColor"})]})})}var Qk=[{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}],X90={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},_F0=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],Kq=[{id:"1x",label:"1× (native)",kind:"scale",value:1},{id:"2x",label:"2× (retina)",kind:"scale",value:2},{id:"3x",label:"3× (max)",kind:"scale",value:3},{id:"dpi150",label:"150 dpi",kind:"dpi",value:150},{id:"dpi300",label:"300 dpi (print)",kind:"dpi",value:300},{id:"dpi600",label:"600 dpi (high-res print)",kind:"dpi",value:600}],wF0="2x",Q90=[{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}],EF0="auto",Y90=[{id:"keep",label:"Keep selectable (default)",description:"Text stays selectable and searchable. You are warned if a font came out unprintable."},{id:"embed",label:"Verify fonts embedded",description:"Same file, but the export fails instead of shipping a font a print shop would reject."},{id:"outline",label:"Convert to outlines (print-safe)",description:"Every glyph becomes a vector path — no fonts left to break. Text is no longer selectable "+"and the file can grow a lot. Needs Ghostscript installed locally; cloud workspaces have it."}],PF0="keep",IF0={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 TF0(J){let X=String(J||"").split(".").pop()?.toLowerCase();return IF0[X]||"application/octet-stream"}function kF0({designRel:J,onPick:X,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[Z,H]=u.useState(null),[K,U]=u.useState(!1),[V,B]=u.useState(null),[N,F]=u.useState(()=>new Set),[M,A]=u.useState({}),[E,w]=u.useState(W?"artboard":"annotation");u.useEffect(()=>{let f=!0;return fetch("/_api/assets").then((h)=>h.json()).then((h)=>{if(!f)return;let p=h.ok?h.assets:[];H(p),A((v)=>{let r={...v};for(let e of p)r[e.path]=e.kind;return r})}).catch(()=>f&&H([])),()=>{f=!1}},[]),u.useEffect(()=>{let f=(h)=>{if(h.key==="Escape")h.stopPropagation(),Q()};return window.addEventListener("keydown",f,!0),()=>window.removeEventListener("keydown",f,!0)},[Q]);let O=Array.from(N).some((f)=>(M[f]||"image")!=="image"),I=!W||O,k=!W?"No artboard on this canvas":O?"Video/audio can only be added as annotations":"";u.useEffect(()=>{if(I&&E==="artboard")w("annotation")},[I,E]);let R=(f)=>{F((h)=>{let p=new Set(h);if(p.has(f))p.delete(f);else p.add(f);return p})},$=async(f)=>{let h=await fetch("/_api/asset",{method:"POST",headers:{"content-type":f.type||"application/octet-stream"},body:f}),p=await h.json().catch(()=>({}));if(h.ok&&p.path)return{ok:!0,path:p.path};return{ok:!1,error:p.error||`upload failed (HTTP ${h.status})`}},C=async(f)=>{if(!f)return;U(!0),B(null);let h=await $(f);if(U(!1),h.ok)X(h.path);else B(h.error)},j=(f)=>{if(typeof f==="string"&&f.startsWith("video/"))return"video";if(typeof f==="string"&&f.startsWith("audio/"))return"audio";return"image"},x=async(f)=>{if(!f.length)return;U(!0),B(null);let h=await Promise.all(f.map((r)=>$(r).then((e)=>({...e,file:r}))));U(!1);let p=h.filter((r)=>r.ok),v=h.length-p.length;if(v>0)B(`${v} of ${h.length} uploads failed`);if(p.length)A((r)=>{let e={...r};for(let c of p)e[c.path]=j(c.file.type);return e}),F((r)=>{let e=new Set(r);for(let c of p)e.add(c.path);return e})},m=async()=>{U(!0),B(null);try{if(Y){let p=(await Vh()||[]).map((v)=>new File([new Uint8Array(v.bytes)],v.name,{type:TF0(v.name)}));if(U(!1),p.length)await x(p);return}let f=await lZ();if(f?.bytes){await C(new Blob([new Uint8Array(f.bytes)]));return}}catch(f){B(f?.message||"open failed")}U(!1)},d=()=>{if(G9()){m();return}let f=document.createElement("input");if(f.type="file",f.accept="image/*,video/*",Y)f.multiple=!0;f.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(f);let h=()=>{if(f.isConnected)f.remove()};window.addEventListener("focus",()=>setTimeout(h,300),{once:!0}),f.addEventListener("change",()=>{let p=f.files?Array.from(f.files):[];if(h(),!p.length)return;if(Y)x(p);else C(p[0])}),f.click()},a=(f)=>`/${J}/${f}`;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(f)=>{if(f.target===f.currentTarget)Q()},children:D("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[D("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Choose media"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:Q,children:z(T9,{name:"x",size:15})})]}),D("div",{className:"st-dialog-bd",children:[D("div",{className:"st-ap-toolbar",children:[z("button",{type:"button",className:"st-btn",onClick:d,disabled:K,children:K?"Uploading…":"Upload…"}),V&&z("span",{className:"st-ap-err",children:V})]}),z("div",{className:"st-ap-grid",children:Z==null?z("div",{className:"st-ap-empty",children:"Loading…"}):Z.length===0?z("div",{className:"st-ap-empty",children:"No assets yet — upload one."}):Z.map((f)=>{let h=Y&&N.has(f.path);return D("button",{type:"button",className:"st-ap-cell","data-selected":h?"true":void 0,"aria-pressed":Y?h:void 0,title:`${f.name} · ${Math.max(1,Math.round(f.size/1024))} KB`,onClick:()=>Y?R(f.path):X(f.path),children:[Y&&z("span",{className:"st-ap-check","aria-hidden":"true",children:h?z(T9,{name:"check",size:12}):null}),f.kind==="video"?z("video",{className:"st-ap-thumb",src:a(f.path),muted:!0,playsInline:!0}):z("img",{className:"st-ap-thumb",src:a(f.path),alt:f.name,loading:"lazy"}),z("span",{className:"st-ap-name",children:f.name})]},f.path)})})]}),Y&&N.size>0&&D("div",{className:"st-dialog-ft st-ap-confirm",children:[D("span",{className:"st-ap-count",children:[N.size," selected"]}),D("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":E==="artboard",disabled:I,onClick:()=>w("artboard"),children:"Add to artboard"}),z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":E==="annotation",onClick:()=>w("annotation"),children:"Add as annotation"})]}),I&&z("span",{className:"st-ap-dest-note",children:k}),z("span",{className:"st-ap-confirm-spacer"}),z("button",{type:"button",className:"btn btn--ghost",onClick:Q,children:"Cancel"}),z("button",{type:"button",className:"btn btn--primary",onClick:()=>G?.(Array.from(N),E),children:"Insert"})]})]})})}function VL(J,X){let Q=URL.createObjectURL(X),Y=document.createElement("a");Y.href=Q,Y.download=J||"export",document.body.appendChild(Y),Y.click(),Y.remove(),setTimeout(()=>URL.revokeObjectURL(Q),1e4)}function RF0({mode:J,initialScope:X,activePath:Q,hasComps:Y=!1,comps:W=[],activeArtboardId:G=null,selection:Z=null,exportLane:H="local",onBrowserCapture:K=null,onClose:U}){let V=u.useCallback((I0)=>H==="none"&&!I0.handoff&&I0.format!=="zip"&&!gb.has(I0.format)||H!=="local"&&I0.format==="canva",[H]),[B,N]=u.useState(J==="handoff"?"shadcn":"png"),[F,M]=u.useState(()=>X&&Rb("png",X)?X:_O("png")),[A,E]=u.useState(2),[w,O]=u.useState(wF0),[I,k]=u.useState(!0),[R,$]=u.useState(!1),[C,j]=u.useState(!1),[x,m]=u.useState(!1),[d,a]=u.useState(EF0),[f,h]=u.useState(PF0),[p,v]=u.useState(!0),[r,e]=u.useState(!1),[c,K0]=u.useState(null),[s,z0]=u.useState([]),o=Qk.find((I0)=>I0.id===B)||Qk[0],q0=o.handoff?[]:wO(o.format),Z0=900,k0=3600,a0=TK(W,mw(W,{artboardId:G})),s0=a0?.durationInFrames||0,t0=a0?.fps||30,E8=o.temporal&&s0>900,a8=o.temporal&&s0>3600;u.useEffect(()=>{if(q0.length&&!q0.includes(F))M(_O(o.format))},[q0,F,o.format]),u.useEffect(()=>{if(H!=="remote")return;fetch("/_api/export-warmup").catch(()=>{})},[H]);let F8=u.useCallback(()=>{fetch("/_api/export-history").then((I0)=>I0.json()).then((I0)=>z0(Array.isArray(I0?.history)?I0.history.slice(0,6):[])).catch(()=>{})},[]);u.useEffect(()=>{F8()},[F8]),u.useEffect(()=>{function I0(w0){if(w0.key==="Escape")w0.preventDefault(),U()}return window.addEventListener("keydown",I0),()=>window.removeEventListener("keydown",I0)},[U]);async function T8(){if(o.handoff){let W8=`/design:handoff ${Q&&Q!==r8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(W8)}catch{}K0({ok:!0,msg:`Copied: ${W8} — run it in Claude Code.`});return}if(V(o)){K0({ok:!1,msg:"This format needs the render service, which this workspace doesn’t have configured."});return}e(!0),K0(null);let I0=o.temporal?{scale:A}:{};if(o.format==="png"){let C0=Kq.find((W8)=>W8.id===w)||Kq[1];if(C0.kind==="dpi")I0.dpi=C0.value;else I0.scale=C0.value}if(o.format==="mp4"||o.format==="webm")I0.audio=p;if(a8)I0.maxFrames=s0;if(o.format==="pdf"){I0.pdfPrint={includeBleed:I,marks:{crop:C,registration:x}};let C0=Q90.find((W8)=>W8.id===d)?.value;if(C0!==void 0)I0.dpi=C0;if(f!=="keep")I0.text=f}if(G)I0.artboardId=G;if(Z?.selector)I0.selection=Z;if(Q&&Q!==r8)I0.canvasFile=Q;if($U.has(o.format)&&s2({exportLane:H,format:o.format,scope:F,artboardId:I0.artboardId})&&typeof K==="function")try{let C0=CO(I0);K0({ok:!0,msg:"Capturing…"});let W8=await K({format:o.format,artboardIds:[I0.artboardId],scale:C0,onProgress:(x8,S8)=>K0({ok:!0,msg:`Capturing ${x8}/${S8}…`})}),H8=await RO(W8,o.format);for(let x8 of H8)VL(x8.name,x8.blob);for(let x8 of H8)await $O({format:o.format,scope:F,filename:x8.name});e(!1),K0({ok:!0,msg:`Saved ${H8.map((x8)=>x8.name).join(", ")} to your downloads.`});return}catch(C0){if(H!=="remote"){K0({ok:!1,msg:`Capture failed: ${C0&&C0.message||C0}`}),e(!1);return}}if(s2({exportLane:H,format:o.format,scope:F})&&o.format==="pptx"&&typeof K==="function")try{K0({ok:!0,msg:"Capturing artboards…"});let C0=Q&&Q!==r8?Y4(Q).replace(/\.[^.]+$/,""):"export",{filename:W8,blob:H8}=await kO({capture:K,name:C0,onProgress:(x8,S8)=>K0({ok:!0,msg:`Capturing ${x8}/${S8}…`}),onAssemble:()=>K0({ok:!0,msg:"Assembling deck…"})});VL(W8,H8),await $O({format:o.format,scope:F,filename:W8}),e(!1),K0({ok:!0,msg:`Saved ${W8} to your downloads.`});return}catch(C0){if(H!=="remote"){K0({ok:!1,msg:`Deck export failed: ${C0&&C0.message||C0}`}),e(!1);return}}if(H==="none"&&$U.has(o.format)){K0({ok:!1,msg:"Without the render service this workspace exports PNG/SVG of the active artboard only — switch Scope to “Active artboard”, or ask your admin to add maude-render."}),e(!1);return}try{let C0=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:o.format,scope:F,options:I0})});if(!C0.ok){K0({ok:!1,msg:await C0.text()||`Export failed (${C0.status})`}),e(!1);return}U()}catch(C0){K0({ok:!1,msg:C0&&C0.message?C0.message:String(C0)}),e(!1)}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(I0)=>{if(I0.target===I0.currentTarget)U()},children:D("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[D("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Export & handoff"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:U,children:z(T9,{name:"x",size:15})})]}),D("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:Q&&Q!==r8?`Format · ${VY(Y4(Q))}`:"Format"}),z("div",{className:"st-fmt-grid",children:Qk.filter((I0)=>!I0.temporal||Y).map((I0)=>D("button",{type:"button","data-testid":`export-format-${I0.id}`,className:"st-fmt"+(I0.id===B?" is-on":""),disabled:V(I0),title:V(I0)?"Needs the render service — not configured on this workspace":void 0,onClick:()=>{N(I0.id),K0(null)},children:[z(T9,{name:I0.icon,size:16}),z("span",{className:"st-fmt-name",children:I0.label}),z("span",{className:"st-fmt-sub",children:I0.sub})]},I0.id))}),H==="none"&&D("div",{className:"st-dialog-note","data-testid":"export-lane-note",children:["PNG and SVG of the active artboard — and the PPTX deck — export right here in your browser; ZIP and AI handoff work too. PDF, video and other multi-artboard exports need the render service, which this workspace doesn't have configured — use the desktop app, or ask your admin to add the ",z("code",{children:" maude-render"})," service (see the self-hosting docs)."]}),!o.handoff&&D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-scope",children:"Scope"}),z("select",{id:"st-export-scope","data-testid":"export-scope",className:"st-select",value:F,onChange:(I0)=>M(I0.target.value),children:q0.map((I0)=>z("option",{value:I0,children:X90[I0]},I0))})]}),!o.handoff&&o.format==="png"&&D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-size",children:"Resolution"}),z("select",{id:"st-export-size",className:"st-select",value:w,onChange:(I0)=>O(I0.target.value),children:Kq.map((I0)=>z("option",{value:I0.id,children:I0.label},I0.id))})]}),!o.handoff&&o.format==="png"&&z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let I0=Kq.find((C0)=>C0.id===w)||Kq[1],w0=I0.kind==="dpi"?I0.value/96:I0.value;return`${I0.label} ≈ ${Math.round(1440*w0)}×${Math.round(900*w0)} for a 1440×900 artboard.`})()}),!o.handoff&&o.temporal&&D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-temporal-size",children:"Resolution"}),z("select",{id:"st-export-temporal-size",className:"st-select",value:A,onChange:(I0)=>E(Number(I0.target.value)),children:_F0.map((I0)=>z("option",{value:I0.value,children:I0.label},I0.value))})]}),!o.handoff&&o.temporal&&D("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[A,"× the artboard's native resolution (e.g. 960×540 → ",960*A,"×",540*A,")."]}),E8&&D("div",{className:"st-mono st-export-long-notice","data-testid":"export-long-comp-notice",style:{fontSize:11,color:"var(--accent)",lineHeight:1.5},children:["⚠ Long comp: ",s0," frames (≈",Math.round(s0/t0),"s).",a8?` Exceeds the default ${"3600"}-frame export cap — exporting raises the cap to the full length for this run.`:""," ","If the fast renderer falls back to frame-by-frame capture this can take several minutes; 2× resolution (≈720–1080p) is recommended for memory headroom."]}),!o.handoff&&o.format==="pdf"&&D(Q0,{children:[D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-dpi",children:"Image quality"}),z("select",{id:"st-export-pdf-dpi",className:"st-select",value:d,onChange:(I0)=>a(I0.target.value),children:Q90.map((I0)=>z("option",{value:I0.id,children:I0.label},I0.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:"The page stays vector; this only sets the capture density for raster content on it (dropped photos, large-format art)."}),D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-text",children:"Text"}),z("select",{id:"st-export-pdf-text",className:"st-select","data-testid":"export-pdf-text",value:f,onChange:(I0)=>h(I0.target.value),children:Y90.map((I0)=>z("option",{value:I0.id,children:I0.label},I0.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:Y90.find((I0)=>I0.id===f)?.description}),z("div",{className:"st-dialog-row",children:D("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-bleed",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-pdf-bleed",type:"checkbox",checked:I,onChange:(I0)=>k(I0.target.checked)}),"Include bleed"]})}),z("div",{className:"st-dialog-row",children:D("button",{type:"button",className:"st-dialog-lbl",style:{background:"none",border:0,padding:0,cursor:"pointer"},onClick:()=>$((I0)=>!I0),"aria-expanded":R,children:[R?"▾":"▸"," Marks"]})}),R&&D("div",{style:{padding:"0 12px 4px",display:"flex",flexDirection:"column",gap:6},children:[D("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:C,onChange:(I0)=>j(I0.target.checked)}),"Crop marks"]}),D("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:x,onChange:(I0)=>m(I0.target.checked)}),"Registration marks"]})]}),D("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:["Bleed and marks apply to print (",z("code",{children:'kind="print"'}),") artboards only.",F==="canvas-as-separate"?" One PDF page per artboard.":""]})]}),!o.handoff&&(o.format==="mp4"||o.format==="webm")&&z("div",{className:"st-dialog-row",children:D("label",{className:"st-dialog-lbl",htmlFor:"st-export-audio",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-audio",type:"checkbox",checked:p,onChange:(I0)=>v(I0.target.checked)}),"Export with audio"]})}),o.handoff&&D("div",{className:"callout callout--info",style:{fontSize:12},children:["Hands the active canvas off to production. Copies"," ",z("span",{className:"st-mono",children:"/design:handoff <path>"})," — run it in Claude Code to emit a ready-to-drop production component next to the canvas."]}),c&&z("div",{className:"callout "+(c.ok?"callout--success":"callout--error"),style:{fontSize:12},"data-testid":"export-status","data-ok":c.ok?"1":"0",children:c.msg}),s.length>0&&D("div",{className:"st-export-recent","data-testid":"export-recent",children:[z("div",{className:"st-rp-hd",children:"Recent"}),s.map((I0,w0)=>D("div",{className:"st-export-recent-row",children:[D("span",{children:[String(I0.format||"").toUpperCase()," ·"," ",X90[I0.scope]||I0.scope]}),z("span",{className:"st-mono",children:I0.filename})]},w0))]})]}),D("div",{className:"st-dialog-ft",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:U,children:"Cancel"}),D("button",{type:"button",className:"btn btn--primary","data-testid":"export-submit",disabled:r,onClick:T8,children:[z(T9,{name:"download",size:14}),o.handoff?"Copy handoff command":r?"Exporting…":`Export ${o.label}`]})]})]})})}var FL=12,LL=16;function CF0({name:J,depth:X,defaultOpen:Q,children:Y,dirPath:W,drag:G,menu:Z}){let[H,K]=u.useState(Q),U=G?G.dropProps(W,!0,()=>K(!0)):{},V=G?.overDir===W,B=G?G.dragProps(W,!0):{},N=G?.draggedPath===W,F=G?.busyPath===W,M=D("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${Bq(W)}`,"aria-expanded":H,"aria-dropeffect":G?"move":void 0,"aria-busy":F||void 0,tabIndex:-1,className:"st-row"+(V?" is-drop-target":"")+(N?" is-dragging":"")+(F?" is-busy":""),style:{paddingLeft:FL+X*LL+"px"},onClick:()=>K((A)=>!A),onContextMenu:Z?(A)=>Z.openAt(A,{kind:"dir",dirPath:W}):void 0,...B,...U,children:[z("span",{className:"st-row-glyph",children:z(T9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:J})]});return D(Q0,{children:[Z?D("div",{className:"st-row-wrap",role:"none",children:[M,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${Bq(W)}`,title:`Folder actions — ${J}`,"aria-label":`Folder actions for ${J}`,"aria-haspopup":"menu",onClick:(A)=>Z.openAt(A,{kind:"dir",dirPath:W}),children:z(UL,{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 $F0({name:J,dsName:X,depth:Q,defaultOpen:Y,active:W,onOpenSystem:G,children:Z}){let[H,K]=u.useState(Y);return D(Q0,{children:[D("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:FL+Q*LL+"px"},role:"treeitem","aria-expanded":H,children:[z("button",{type:"button",className:"st-ds-chev",onClick:()=>K((U)=>!U),"aria-label":H?"Collapse design system":"Expand design system",title:H?"Collapse":"Expand",children:z(T9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),D("button",{type:"button",className:"st-ds-open",onClick:()=>G(X),"aria-label":`Open ${X} design system view`,title:"Open the design system view",children:[z("span",{className:"st-row-glyph",children:z(T9,{name:"folder",size:13})}),z("span",{className:"st-row-name",children:J})]})]}),H&&Z]})}function qL({file:J,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,onDelete:G,openCount:Z,depth:H,kind:K,sidecar:U,dirty:V,experimentalKind:B,drag:N,menu:F}){let M=J.path===X||J.path===Q,A=y5.test(J.name),E=!A&&K!=="runtime"?NL(J.name):null,w=!A&&!E,O=A?VY(J.name):J.name,I=A&&typeof G==="function"&&K!=="runtime",k=A&&!U&&K!=="runtime"&&typeof N<"u",R=k?N.dragProps(J.path,!0):{},$=N?.draggedPath===J.path,C=N?.busyPath===J.path,j=k&&typeof F<"u",x=!A&&!!E&&!U&&typeof F<"u",m=typeof F<"u"&&K!=="runtime",d=J.path.split("/").slice(0,-1).join("/"),a=A?"canvas-row-"+J.path.replace(/^\.[^/]+\//,"").replace(y5,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,f=D("button",{type:"button",role:"treeitem","data-testid":a??(x?`file-row-${Bq(J.path)}`:void 0),"aria-selected":M,"aria-disabled":w?"true":void 0,"aria-busy":C||void 0,tabIndex:M?0:-1,className:"st-row"+(M?" is-sel":"")+(K==="runtime"?" is-muted":"")+($?" is-dragging":"")+(C?" is-busy":""),style:{paddingLeft:FL+H*LL+"px"},title:J.path+(Z?` — ${Z} open`:w?" (file index only)":""),onClick:()=>{if(A)Y(J.path);else if(E)W?.(J.path)},onContextMenu:m?(h)=>F.openAt(h,{kind:"file",path:J.path,dir:d,canMove:j||x,supporting:x,name:J.name}):void 0,...R,children:[z("span",{className:"st-row-glyph",children:z(T9,{name:"file",size:13})}),z("span",{className:"st-row-name",children:O}),B==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),B==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),V&&z("span",{className:"st-git-badge","data-kind":V,title:`Unsaved (${V})`,"aria-label":`Unsaved, ${V}`,children:V}),Z>0&&z("span",{className:"st-row-badge",children:Z})]});if(!I&&!m)return f;return D("div",{className:"st-row-wrap",role:"none",children:[f,m&&z("button",{type:"button",className:"st-row-menu-btn"+(I?" has-delete-sibling":""),"data-testid":`tree-row-menu-${Bq(J.path)}`,title:`Actions for ${O}`,"aria-label":`Actions for ${O}`,"aria-haspopup":"menu",onClick:(h)=>F.openAt(h,{kind:"file",path:J.path,dir:d,canMove:j||x,supporting:x,name:J.name}),children:z(UL,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})}),I&&z("button",{type:"button",className:"st-row-del",title:`Delete ${O}`,"aria-label":`Delete canvas ${O}`,onClick:(h)=>{h.stopPropagation(),G(J.path,O)},children:z(UL,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})}function SF0({primary:J,sidecars:X,depth:Q,kind:Y,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,showHidden:V,forceOpen:B,dirtyByPath:N,experimentalKind:F,drag:M,menu:A}){let E=N?.get(J.path),w=X.length>0,[O,I]=u.useState(!1),k=B||O,R=J.path===W;if(!(w&&V))return z(qL,{file:J,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,depth:Q,kind:Y,dirty:E,experimentalKind:F,drag:M,menu:A});let C=typeof M<"u",j=C?M.dragProps(J.path,!0):{},x=M?.draggedPath===J.path,m=M?.busyPath===J.path,d=C&&typeof A<"u",a=typeof A<"u"&&Y!=="runtime",f=J.path.split("/").slice(0,-1).join("/"),h=D("button",{type:"button",role:"treeitem","aria-selected":R,"aria-expanded":k,"aria-busy":m||void 0,tabIndex:R?0:-1,className:"st-row st-canvas-row"+(R?" is-sel":"")+(x?" is-dragging":"")+(m?" is-busy":""),style:{paddingLeft:FL+Q*LL+"px"},title:J.path,onClick:(p)=>{if(p.target.closest(".st-canvas-chev")){I((v)=>!v);return}Z(J.path)},onContextMenu:a?(p)=>A.openAt(p,{kind:"file",path:J.path,dir:f,canMove:d}):void 0,...j,children:[z("span",{className:"st-row-glyph st-canvas-chev",onClick:(p)=>{p.stopPropagation(),I((v)=>!v)},children:z(T9,{name:"chevron-right",className:"st-chev"+(k?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:VY(J.name)}),F==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),F==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),E&&z("span",{className:"st-git-badge","data-kind":E,title:`Unsaved (${E})`,"aria-label":`Unsaved, ${E}`,children:E}),U>0&&z("span",{className:"st-row-badge",children:U})]});return D(Q0,{children:[a?D("div",{className:"st-row-wrap",role:"none",children:[h,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${Bq(J.path)}`,title:`Actions for ${VY(J.name)}`,"aria-label":`Actions for ${VY(J.name)}`,"aria-haspopup":"menu",onClick:(p)=>A.openAt(p,{kind:"file",path:J.path,dir:f,canMove:d}),children:z(UL,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})})]}):h,k&&X.map((p)=>z(qL,{file:p,menu:A,activePath:W,previewPath:G,onOpen:Z,onPreview:H,openCount:0,depth:Q+1,kind:Y,sidecar:!0},p.path))]})}function E90({node:J,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z=1,kind:H,showHidden:K,search:U,dsFolders:V,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:M,canvasKinds:A,dirPath:E="",drag:w,menu:O}){let I=Object.keys(J).filter((d)=>d!=="_files").sort(),k=J._files||[],{canvases:R,orphans:$}=u.useMemo(()=>FF0(k),[k]),{mediaOrphans:C,metaOrphans:j}=u.useMemo(()=>{let d=[],a=[];for(let f of $){let h=NL(f.primary.name);(h==="image"||h==="video"||h==="audio"||h==="font"?d:a).push(f)}return{mediaOrphans:d,metaOrphans:a}},[$]),x=!!(U&&U.trim()),m=u.useMemo(()=>{if(!V||Z!==1)return null;let d=new Map;for(let a of V)d.set(a.folder,a);return d},[V,Z]);return D(Q0,{children:[R.map((d)=>{let a=x&&d.sidecars.some((f)=>{let h=U.toLowerCase();return f.name.toLowerCase().includes(h)||f.path.toLowerCase().includes(h)});return z(SF0,{primary:d.primary,sidecars:d.sidecars,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,onDelete:F,openCount:zL(G[d.primary.path]),depth:Z,kind:H,showHidden:K,forceOpen:a,dirtyByPath:M,experimentalKind:A?.[d.primary.path],drag:w,menu:O},d.primary.path)}),C.map((d)=>z(qL,{file:d.primary,menu:O,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,openCount:zL(G[d.primary.path]),depth:Z,kind:H},d.primary.path)),K&&j.map((d)=>z(qL,{file:d.primary,menu:O,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,openCount:zL(G[d.primary.path]),depth:Z,kind:H},d.primary.path)),I.map((d)=>{let a=m?.get(d),f=E?`${E}/${d}`:d,h=z(E90,{node:J[d],activePath:X,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z+1,kind:H,showHidden:K,search:U,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:M,canvasKinds:A,dirPath:f,drag:w,menu:O});if(a&&N)return z($F0,{name:d,dsName:a.name,depth:Z,defaultOpen:!0,active:X===r8&&a.name===B,onOpenSystem:N,children:h},d);return z(CF0,{name:d,depth:Z,defaultOpen:!0,dirPath:f,drag:w,menu:w?O:void 0,children:h},d)})]})}var GL={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function bF0(J){if(J.kind==="project")return GL.project;if(J.kind==="runtime")return GL.runtime;if(J.label==="Design system")return GL.ds;if(J.label==="UI kit")return GL.canvas;return{title:J.label.toUpperCase(),pillFromCount:!0}}function yF0({readOnly:J=!1,cloud:X,groups:Q,activePath:Y,previewPath:W,activeDsName:G,onOpen:Z,onPreview:H,onOpenSystem:K,wsConnected:U,search:V,setSearch:B,commentsByFile:N,showHidden:F,sectionsExpanded:M,onToggleSection:A,onNewBoard:E,onDeleteBoard:w,onRefresh:O,refreshing:I,collapsed:k,onCollapse:R,width:$,resizing:C,dirtyByPath:j,project:x,gitBranch:m,remoteSync:d,onGetLatest:a,canvasKinds:f,onMoveCanvas:h,onNewFolder:p,onDeleteFolder:v,onRenameFolder:r,onRenameCanvas:e,onDuplicateCanvas:c,onDeleteFile:K0,syncStatus:s,onLinkedHub:z0,onLocalProject:o,onOpenLinkedFile:q0,filesReady:Z0,onShare:k0,savingIsManaged:a0=!1}){let s0=u.useMemo(()=>{if(!V)return Q;return Q.map((b0)=>({...b0,tree:_90(b0.tree,V),filtered:!!V}))},[Q,V]),t0=lb(h),E8=ub(),a8=u.useMemo(()=>{let b0=[];for(let X8 of Q){if(X8.label==="Design system"||X8.kind!=="canvas")continue;let q8=X8.fullPath.replace(/^\.[^/]+\//,"")||X8.fullPath;b0.push({path:X8.fullPath,label:q8});for(let l0 of X8.dirs||[])b0.push({path:l0,label:l0.replace(/^\.[^/]+\//,"")})}return b0},[Q]),F8=E8.state?.extra,T8=F8?.kind==="file"?[{id:"share",label:"Share…",onSelect:()=>{E8.close(),k0(F8.path)}},...e&&/\.tsx$/i.test(F8.path)?[{id:"rename-canvas",label:"Rename…",onSelect:()=>{E8.close();let b0=VY(F8.path.split("/").pop()),X8=window.prompt("Rename canvas to:",b0);if(X8?.trim()&&X8.trim()!==b0)e(F8.path,X8.trim())}}]:[],...c&&/\.tsx$/i.test(F8.path)?[{id:"duplicate-canvas",label:"Duplicate",onSelect:()=>{E8.close(),c(F8.path)}}]:[],...F8.supporting&&e?[{id:"rename-file",label:"Rename…",onSelect:()=>{E8.close();let b0=F8.name??F8.path.split("/").pop(),X8=b0.includes(".")?b0.slice(b0.lastIndexOf(".")):"",q8=X8?b0.slice(0,-X8.length):b0,l0=window.prompt(`Rename ${b0} to:`,q8);if(l0?.trim()&&l0.trim()!==q8)e(F8.path,l0.trim())}}]:[],...F8.canMove?[{id:"move-to",label:"Move to…",onSelect:()=>E8.showMoveTo()}]:[],...F8.supporting&&K0?[{id:"delete-file",label:"Delete",destructive:!0,onSelect:()=>{E8.close(),K0(F8.path,F8.name??F8.path.split("/").pop())}}]:[]]:F8?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{E8.close();let b0=window.prompt("New folder name:");if(b0?.trim())p(F8.dirPath,b0.trim())}},{id:"rename-folder",label:"Rename folder",onSelect:()=>{E8.close();let b0=F8.dirPath.split("/").pop(),X8=window.prompt("Rename folder to:",b0);if(X8?.trim()&&X8.trim()!==b0)r(F8.dirPath,X8.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{E8.close(),v(F8.dirPath,F8.dirPath.split("/").pop())}}]:[],I0=F8?.kind==="file"||F8?.kind==="supporting"?a8.filter((b0)=>b0.path!==F8.dir):[],[w0,C0]=u.useState(!1),[W8,H8]=u.useState("board"),[x8,S8]=u.useState(""),[O9,v0]=u.useState(""),[$8,w9]=u.useState(!1),L8=u.useMemo(()=>Q.find((b0)=>b0.kind==="canvas"&&b0.label!=="Design system")?.fullPath,[Q]),V0=u.useCallback(async()=>{let b0=x8.trim();if(!b0||$8)return;if(w9(!0),v0(""),W8==="folder"){if(!L8){w9(!1),v0("no canvas group to create a folder in");return}let q8=await p(L8,b0);if(w9(!1),q8?.ok)C0(!1),S8("");else v0(q8?.error||"could not create folder");return}let X8=await E(b0);if(w9(!1),X8?.ok)C0(!1),S8("");else v0(X8?.error||"could not create board")},[x8,$8,E,p,W8,L8]),J8=u.useMemo(()=>{let b0=0;for(let X8 of Q)for(let q8 of X8.paths||[])if(y5.test(q8))b0++;return b0},[Q]),r0=u.useMemo(()=>{let b0=0;for(let X8 of s0)for(let q8 of X8.paths||[])if(y5.test(q8))b0++;return b0},[s0]);return D("nav",{className:"st-sidebar"+(k?" is-collapsed":"")+(C?" is-resizing":""),style:k||!$?void 0:{width:$,flexBasis:$},"aria-label":"Files","data-tour":"sidebar",children:[D("div",{className:"st-sb-hd",children:[z("span",{className:"st-sb-title",children:"Files"}),D("div",{className:"st-sb-hd-actions",children:[!J&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":w0&&W8==="board",onClick:()=>{v0(""),H8("board"),C0((b0)=>W8==="board"?!b0:!0)},children:z(T9,{name:"plus",size:15})}),!J&&L8&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":w0&&W8==="folder",onClick:()=>{v0(""),H8("folder"),C0((b0)=>W8==="folder"?!b0:!0)},children:z(T9,{name:"folder-plus",size:15})}),O&&z("button",{type:"button",className:"st-iconbtn st-refresh"+(I?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":I||void 0,disabled:I,onClick:()=>O(),children:z(T9,{name:"reload",size:15})}),D("span",{className:"st-live","data-tip":U?"live · file index synced":"reconnecting…",children:[z("span",{className:"st-live-dot"+(U?" is-connected":""),"aria-hidden":"true"}),r0," / ",J8]}),R&&z("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:R,children:z(T9,{name:"panel-left",size:15})})]})]}),w0?D("div",{className:"st-newboard",children:[z("input",{type:"text",autoFocus:!0,placeholder:W8==="folder"?"folder name…":"brief board name…",value:x8,maxLength:60,disabled:$8,"aria-label":W8==="folder"?"New folder name":"New brief board name",onChange:(b0)=>S8(b0.target.value),onKeyDown:(b0)=>{if(b0.key==="Enter")b0.preventDefault(),V0();else if(b0.key==="Escape")b0.preventDefault(),C0(!1),S8(""),v0("")}}),z("button",{type:"button",className:"st-newboard-go",disabled:$8||!x8.trim(),"data-tip":"Create · Enter","aria-label":W8==="folder"?"Create folder":"Create brief board",onClick:V0,children:$8?"…":"↵"})]}):null,O9?z("div",{className:"st-newboard-err",role:"alert",children:O9}):null,z("div",{className:"st-search",children:D("div",{className:"st-search-box",children:[z(T9,{name:"search",size:13}),z("input",{type:"search","data-testid":"canvas-search",placeholder:"Search canvases…",value:V,onChange:(b0)=>B(b0.target.value),onKeyDown:(b0)=>{if(b0.key==="Escape")if(b0.preventDefault(),V)B("");else b0.currentTarget.blur()},"aria-label":"Filter files"}),V?z("button",{className:"st-search-clear",onClick:()=>B(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):z(CJ,{children:"/"})]})}),z("div",{className:"st-tree",role:"tree","aria-label":"Project file tree","data-testid":"canvas-list",children:s0.map((b0)=>{if(!F&&!V&&b0.kind==="runtime")return null;let X8=bF0(b0),q8=(b0.paths||[]).filter((e0)=>y5.test(e0)).length,l0=X8.pill||(X8.pillFromDsCount?String(b0.dsFolders?.length||0):null)||(X8.pillFromCount?String(q8||b0.paths?.length||0):null),d0=b0.tree&&Object.keys(b0.tree).length>0,h0=b0.label==="Design system",y0=b0.kind==="project";if(!F&&!V&&y0&&q8===0)return null;let B8=BF0(b0),D8=M[b0.label],N0=!!V||(D8===void 0?B8:D8),o0=!h0&&b0.kind==="canvas"&&!J,h8=o0?t0.dropProps(b0.fullPath,!0):{},g8=t0.overDir===b0.fullPath;return D("div",{className:"st-tree-section",children:[D("button",{type:"button",className:"st-tree-sec-hd"+(g8?" is-drop-target":""),"data-testid":`tree-section-${b0.label.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,onClick:()=>A(b0.label,B8),"aria-expanded":N0,"aria-dropeffect":o0?"move":void 0,title:N0?"Collapse section":"Expand section",...h8,children:[z(T9,{name:"chevron-right",className:"st-chev"+(N0?" is-open":""),size:13}),z("span",{className:"st-sec-name",children:X8.title}),l0&&z("span",{className:"st-pill",children:l0})]}),N0&&(d0?z(E90,{node:b0.tree,activePath:Y,previewPath:W,onOpen:Z,onPreview:H,commentsByFile:N,depth:1,kind:b0.kind,showHidden:F,search:V,dsFolders:b0.dsFolders,activeDsName:G,onOpenSystem:h0?K:void 0,onDelete:h0||J?void 0:w,dirtyByPath:j,canvasKinds:f,dirPath:b0.fullPath,drag:!h0&&b0.kind==="canvas"&&!J?t0:void 0,menu:E8}):z("div",{className:"st-tree-empty",children:V?"No matches.":"Empty."}))]},b0.label)})}),z(pb,{state:E8.state,onClose:E8.close,rootItems:T8,destinations:I0,onPickDestination:(b0)=>h(F8.path,b0)}),z(WE,{project:x,liveBranch:m,remoteSync:d,onGetLatest:a,projectOnly:a0}),X===null?z(Ew,{syncStatus:s,onLinkedHub:z0,onLocalProject:o,onOpenFile:q0,filesReady:Z0}):null,z(Rw,{})]})}function jF0({shown:J,onExpand:X,onSearch:Q}){return z("div",{className:"st-rail"+(J?" is-shown":""),children:D("div",{className:"st-rail-inner",children:[z("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:X,children:z(T9,{name:"panel-left",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:z(T9,{name:"search",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:X,children:z(T9,{name:"folder",size:15})})]})})}function vF0({open:J,onClose:X,onStartTour:Q}){if(u.useEffect(()=>{if(!J)return;function Y(W){if(W.key==="Escape")X()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[J,X]),!J)return null;return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)X()},children:D("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[D("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),D("span",{className:"sku",children:["MAUDE-DEV-SRV / v",Zk]}),Q&&z("button",{type:"button",className:"mdcc-tour__back",style:{marginLeft:"auto"},onClick:Q,children:"▶ Take the tour"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:X,children:"×"})]}),D("div",{className:"help-modal-body",children:[D("details",{open:!0,children:[z("summary",{children:"Canvas selection & tools"}),D("ul",{children:[D("li",{children:[z("kbd",{children:"V"})," ",z("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),D("li",{children:[z("kbd",{children:"H"})," ",z("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),D("li",{children:[z("kbd",{children:"C"})," ",z("span",{children:"comment tool — hover paints, click drops a pin"})]}),D("li",{children:[z("kbd",{children:"⌘"})," + hover ",z("span",{children:"preview deepest element under cursor"})]}),D("li",{children:[z("kbd",{children:"⌘"})," + click ",z("span",{children:"select that element (replace)"})]}),D("li",{children:[z("kbd",{children:"⌘⇧"})," + click ",z("span",{children:"add deepest to selection (multi)"})]}),D("li",{children:["right-click ",z("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),D("li",{children:[z("kbd",{children:"Esc"})," in canvas ",z("span",{children:"clear selection + close menu"})]})]})]}),D("details",{children:[z("summary",{children:"Annotation tools"}),D("ul",{children:[D("li",{children:[z("kbd",{children:"B"})," ",z("span",{children:"pen — freehand stroke"})]}),D("li",{children:[z("kbd",{children:"R"})," ",z("span",{children:"rectangle — drag to define corners"})]}),D("li",{children:[z("kbd",{children:"O"})," ",z("span",{children:"ellipse — drag from center outward"})]}),D("li",{children:[z("kbd",{children:"A"})," ",z("span",{children:"arrow — drag tail → tip"})]}),D("li",{children:[z("kbd",{children:"E"})," ",z("span",{children:"eraser — click or drag over strokes to remove"})]}),D("li",{children:[z("kbd",{children:"V"})," + click stroke ",z("span",{children:"select annotation (Shift+click to multi)"})]}),D("li",{children:[z("kbd",{children:"V"})," + drag empty ",z("span",{children:"marquee-select strokes that overlap"})]}),D("li",{children:["double-click rect/ellipse ",z("span",{children:"add text inside the shape"})]}),D("li",{children:["arrow keys ",z("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),D("li",{children:[z("kbd",{children:"Backspace"})," ",z("span",{children:"delete selected annotations"})]}),D("li",{children:[z("kbd",{children:"⇧P"})," ",z("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),D("details",{children:[z("summary",{children:"Canvas & panels"}),D("ul",{children:[D("li",{children:["click in tree ",z("span",{children:"open canvas (replaces the active one)"})]}),D("li",{children:["File ▸ Close canvas ",z("span",{children:"clear the stage"})]}),D("li",{children:[z("kbd",{children:"⌘R"})," ",z("span",{children:"reload canvas"})]}),D("li",{children:[z("kbd",{children:"/"})," ",z("span",{children:"focus search"})]}),D("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"comments panel"})]}),D("li",{children:[z("kbd",{children:"⌘⇧I"})," ",z("span",{children:"inspector"})]}),D("li",{children:[z("kbd",{children:"?"})," ",z("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),D("details",{children:[z("summary",{children:"Slash commands"}),D("ul",{className:"cmds",children:[D("li",{children:[D("code",{children:['/design:edit "',z("i",{children:"feedback"}),'"']}),z("span",{children:"edit + 4-iter multi-axis loop"})]}),D("li",{children:[D("code",{children:['/design:edit "',z("i",{children:"…"}),'" --perfect']}),z("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),D("li",{children:[D("code",{children:['/design:edit "',z("i",{children:"…"}),'" --no-critic']}),z("span",{children:"raw edit, skip loop"})]}),D("li",{children:[D("code",{children:['/design:edit "',z("i",{children:"…"}),'" --opt-out=',z("i",{children:"scope"})]}),z("span",{children:"override DS scope (palette/aesthetic/full)"})]}),D("li",{children:[D("code",{children:['/design:new "',z("i",{children:"Name"}),'" "',z("i",{children:"brief"}),'"']}),z("span",{children:"scaffold canvas"})]}),D("li",{children:[D("code",{children:['/design:new "',z("i",{children:"…"}),'" --opt-out=aesthetic']}),z("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),D("li",{children:[z("code",{children:"/design:critic"}),z("span",{children:"review panel (routed)"})]}),D("li",{children:[z("code",{children:"/design:critic --all"}),z("span",{children:"10-critic sweep"})]}),D("li",{children:[z("code",{children:"/design:critic --agent signature-moment-critic"}),z("span",{children:"aspiration axis only"})]}),D("li",{children:[z("code",{children:"/design:rollback"}),z("span",{children:"undo last edit"})]}),D("li",{children:[z("code",{children:"/design:screenshot"}),z("span",{children:"capture canvas"})]}),D("li",{children:[z("code",{children:"/design:setup-docs"}),z("span",{children:"refresh README + INDEX"})]}),D("li",{children:[z("code",{children:"/design:handoff"}),z("span",{children:"migrate to apps/"})]})]})]}),D("details",{children:[z("summary",{children:"Opt-out scope"}),D("ul",{children:[D("li",{children:[z("strong",{children:"palette"})," ",z("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),D("li",{children:[z("strong",{children:"aesthetic"})," ",z("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),D("li",{children:[z("strong",{children:"full"})," ",z("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),D("li",{children:[z("em",{children:"A11y enforced at every scope"})," ",z("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),D("li",{children:["Persisted on canvas's ",z("code",{children:".meta.json"})," ",z("code",{children:"opt_out_scope"})," field — subsequent ",z("code",{children:"/design:edit"})," iterations inherit."]}),z("li",{children:'Inferred from brief ("modern", "vibrant", "off-system") with one-shot AskUserQuestion before iter-1 critics fire.'})]})]}),D("details",{children:[z("summary",{children:"Auto-critic loop"}),D("ul",{children:[D("li",{children:[z("strong",{children:"Default"})," ",z("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),D("li",{children:[z("strong",{children:"--perfect"})," ",z("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),D("li",{children:[z("strong",{children:"--perfect --all"})," ",z("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),D("li",{children:["Exit: ",z("code",{children:"solid"})," · ",z("code",{children:"stable-but-bland"})," · ",z("code",{children:"max-reached"})," ","· ",z("code",{children:"divergent"})]}),D("li",{children:[z("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),D("li",{children:["When ",z("code",{children:"opt_out_scope ∈ {aesthetic, full}"}),": iter-1 checkpoint fires — pick (a) run loop, (b) skip auto-loop and review iter 1, (c) a11y-only check."]})]})]}),D("details",{children:[z("summary",{children:"Pin-to-element flow"}),D("ol",{children:[z("li",{children:"Open a canvas"}),D("li",{children:[z("kbd",{children:"⌘"}),"+click element"]}),z("li",{children:"Status bar shows ● selector"}),D("li",{children:["Run"," ",D("code",{children:['/design:edit "',z("i",{children:"change just this"}),'"']})]}),D("li",{children:["Reload iframe (",z("kbd",{children:"⌘R"}),")"]})]})]}),D("details",{children:[z("summary",{children:"Comments"}),D("ol",{children:[D("li",{children:[z("kbd",{children:"⌘"}),"+click element, then ",z("kbd",{children:"⌘C"})," ",z("span",{children:"or ⌘⇧+click"})]}),z("li",{children:"Numbered pin appears on canvas"}),D("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"opens panel — All / Open / Resolved"})]}),D("li",{children:["Click row in panel ",z("span",{children:"jumps to that file + pin"})]}),D("li",{children:["Claude reads ",z("code",{children:"_comments/<slug>.json"})," on next ",z("code",{children:"/design"})]})]})]})]})]})})}var Yk=[{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 fF0({kbd:J,alt:X}){let Q=(Y,W)=>z("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>z(CJ,{children:G},`${G}-${Z}`))},W);return D("span",{className:"so-combos",children:[Q(J,"main"),X?X.split(" / ").map((Y)=>D(Q0,{children:[z("span",{className:"so-or",children:"/"}),Q(Y,Y)]},Y)):null]})}function xF0({open:J,onClose:X}){if(u.useEffect(()=>{if(!J)return;function Y(W){if(W.key==="Escape")W.preventDefault(),X()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[J,X]),!J)return null;let Q=Yk.reduce((Y,W)=>Y+W.items.length,0);return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)X()},children:D("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[D("div",{className:"so-overlay-hd",children:[z("span",{className:"so-title",children:"Keyboard shortcuts"}),D("span",{className:"so-trigger",children:["press ",z(CJ,{children:"?"})," to open"]})]}),z("div",{className:"so-columns",children:Yk.map((Y)=>D("section",{className:"so-section so-section--"+Y.id,children:[z("h3",{className:"so-section-hd",children:Y.label}),z("dl",{className:"so-list",children:Y.items.map((W)=>D("div",{className:"so-pair",children:[z("dt",{children:W.label}),z("dd",{children:z(fF0,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),D("div",{className:"so-overlay-ft",children:[D("span",{children:["close with ",z(CJ,{children:"Esc"})]}),D("span",{className:"so-count",children:[Q," bindings · ",Yk.length," groups"]})]})]})})}var hF0=["File","Edit","View","Selection","Tools","Help"];function P90(J){u.useEffect(()=>{function X(Y){if(Y.key==="Escape")J()}function Q(Y){if(!Y.target.closest(".st-dropdown, .st-menu"))J()}return window.addEventListener("keydown",X),window.addEventListener("mousedown",Q),()=>{window.removeEventListener("keydown",X),window.removeEventListener("mousedown",Q)}},[J])}function gF0({panels:J,onToggle:X,onClose:Q,onZoom:Y,hasCanvas:W}){return P90(Q),D("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[z("div",{className:"st-dd-hd",children:"Panels"}),J.map((G)=>D("button",{type:"button",role:"menuitem",className:"st-dd-item"+(G.checked?" is-on":""),"aria-disabled":G.disabled?"true":void 0,title:G.hint||void 0,onClick:()=>{if(G.disabled){if(G.href)window.open(G.href,"_blank","noopener,noreferrer"),Q();return}X(G.id),Q()},children:[D("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check",children:G.checked?z(T9,{name:"check",size:13}):null}),z("span",{children:G.label}),G.phase?z("span",{className:"st-dd-phase",children:G.phase}):null]}),G.shortcut?z(CJ,{children:G.shortcut}):null]},G.id)),z("div",{className:"st-dd-sep"}),z("div",{className:"st-dd-hd",children:"Zoom"}),[{op:"in",label:"Zoom In",shortcut:"⌘ +"},{op:"out",label:"Zoom Out",shortcut:"⌘ −"},{op:"fit",label:"Fit to Screen",shortcut:"⌘ 0"},{op:"actual",label:"Actual Size · 100 %",shortcut:"⌘ 1"}].map((G)=>D("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":W?void 0:"true",onClick:()=>{if(!W)return;Y?.(G.op),Q()},children:[D("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:G.label})]}),z(CJ,{children:G.shortcut})]},G.label))]})}function J1({label:J,left:X,header:Q,items:Y,onAction:W,onClose:G}){return P90(G),D("div",{className:"st-dropdown",role:"menu","aria-label":J,style:{left:X},children:[Q?z("div",{className:"st-dd-hd",children:Q}):null,Y.map((Z,H)=>Z.sep?z("div",{className:"st-dd-sep"},"s"+H):D("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":Z.disabled?"true":void 0,onClick:()=>{if(Z.disabled)return;W(Z.id),G()},children:[D("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:Z.label})]}),Z.shortcut?z(CJ,{children:Z.shortcut}):null]},Z.id))]})}function mF0({onAction:J,onClose:X}){return z(J1,{label:"Help",left:320,onAction:J,onClose:X,items:[{id:"shortcuts",label:"Keyboard shortcuts",shortcut:"?"},{id:"help",label:"Help · commands & flows",shortcut:"F1"},{id:"report-bug",label:"Report a bug…"},{sep:!0},{id:"tour",label:"Take the tour"},{id:"watch-intro",label:"Watch the intro"},...G9()?[{id:"collab-tour",label:"How sharing works"}]:[],...G9()?[{id:"quick-setup",label:"Quick setup"}]:[],...G9()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function uF0({onAction:J,onClose:X,readOnly:Q=!1}){return z(J1,{label:"Selection",left:214,onAction:J,onClose:X,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},...Q?[]:[{id:"select-all-annotations",label:"Select all annotations",shortcut:"⌘ ⇧ A"}]]})}function pF0({onAction:J,onClose:X,readOnly:Q=!1}){let Y=[{id:"browse",label:"Browse (interact)",shortcut:""},{id:"move",label:"Select",shortcut:"V"},{id:"hand",label:"Hand",shortcut:"H"},...Q?[]:[{id:"comment",label:"Comment",shortcut:"C"},{id:"pen",label:"Pen",shortcut:"B"},{id:"rect",label:"Rect",shortcut:"R"},{id:"ellipse",label:"Ellipse",shortcut:"O"},{id:"sticky",label:"Sticky",shortcut:"N"},{id:"arrow",label:"Arrow",shortcut:"A"},{id:"text",label:"Text",shortcut:"T"},{id:"eraser",label:"Eraser",shortcut:"E"}]];return z(J1,{label:"Tools",left:290,header:"Tool palette",onAction:J,onClose:X,items:Y})}function lF0({onAction:J,onClose:X,hasCanvas:Q,hasSharePath:Y,readOnly:W=!1}){return z(J1,{label:"File",left:40,onAction:J,onClose:X,items:W?[{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"share",label:"Share link…",disabled:!Y},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!Q},{id:"close",label:"Close canvas",disabled:!Q}]:[{id:"new",label:"New canvas…",shortcut:"N"},{id:"assemble",label:"Assemble dropped clips → video",disabled:!Q},{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"share",label:"Share link…",disabled:!Y},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"generate",label:"Generate with AI…"},{id:"settings",label:"Settings…",shortcut:"⌘,"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!Q},{id:"close",label:"Close canvas",disabled:!Q}]})}function dF0({onAction:J,onClose:X,hasCanvas:Q,readOnly:Y=!1}){if(Y)return z(J1,{label:"Edit",left:90,onAction:J,onClose:X,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"}]});return z(J1,{label:"Edit",left:90,onAction:J,onClose:X,items:[{id:"undo",label:"Undo",shortcut:"⌘Z"},{id:"redo",label:"Redo",shortcut:"⇧⌘Z"},{sep:!0},{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},{id:"select-all-annotations",label:"Select all annotations",shortcut:"⇧⌘A"},...Q?[{sep:!0},{id:"new-artboard:desktop",label:"New artboard: Desktop"},{id:"new-artboard:laptop",label:"New artboard: Laptop"},{id:"new-artboard:tablet",label:"New artboard: Tablet"},{id:"new-artboard:mobile",label:"New artboard: Mobile"},{id:"new-artboard:print-a4",label:"New artboard: A4 (print)"},{id:"new-artboard:print-letter",label:"New artboard: Letter (print)"}]:[]]})}function cF0({activePath:J,sharePath:X,onShare:Q,project:Y,cloud:W,tabsCount:G,openMenu:Z,setOpenMenu:H,commentsPanelOpen:K,onToggleComments:U,changesOpen:V,changesCount:B,onToggleChanges:N,onOpenSystem:F,sidebarOpen:M,onToggleSidebar:A,showHidden:E,onToggleShowHidden:w,onOpenHelp:O,onOpenShortcuts:I,onReportBug:k,onStartTour:R,onStartCollabTour:$,annotationsVisible:C,onToggleAnnotations:j,minimapVisible:x,onToggleMinimap:m,zoomCtlVisible:d,onToggleZoomCtl:a,presentMode:f,onTogglePresent:h,printGuidesVisible:p,onTogglePrintGuides:v,postToActiveCanvas:r,onOpenWhatsNew:e,onOpenReadiness:c,onOpenQuickSetup:K0,onWatchIntro:s,whatsNewCount:z0,exportCenter:o,artboardCount:q0=0,presence:Z0=null,inspectorOpen:k0,inspectorTab:a0,onToggleInspector:s0,autoOpenInspector:t0,onToggleAutoOpenInspector:E8,onOpenLayers:a8,timelineOpen:F8,onToggleTimeline:T8,hasComps:I0=!1,assistantOpen:w0,onToggleAssistant:C0,assistantBusy:W8,assistantUnseen:H8,onNewCanvas:x8,onAssembleVideo:S8,onOpenExport:O9,onOpenSettings:v0,onOpenGenerate:$8,onReload:w9,onCloseCanvas:L8,onInsertArtboard:V0,readOnly:J8=!1}){let r0=J===r8,b0=r0?"SYSTEM":J?"CANVAS":"IDLE",X8=r0?z("b",{children:"design system"}):J?D(Q0,{children:[J.split("/").slice(0,-1).join("/"),"/",z("b",{children:VY(Y4(J))})]}):z("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),q8=new Set(W?["autoopen"]:["assistant","autoopen"]),l0=[{id:"tree",label:"Project Tree",shortcut:"T",checked:M,disabled:!1},{id:"changes",label:W?"History":B>0?`Changes · ${B} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:V,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:K,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:E,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:k0&&a0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:k0,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!t0,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:I0?"video":void 0,checked:F8,disabled:!1},...G9()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:w0,disabled:!1}]:W?[{id:"assistant",label:"Assistant — in the desktop app",shortcut:"",checked:!1,disabled:!0,href:"https://maude.sh/download",hint:"The agent runs on your own Claude subscription, on your own machine."}]:[],{id:"annotate",label:"Annotations",shortcut:"⇧ P",checked:C,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:x,disabled:!J||r0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:d,disabled:!J||r0},{id:"present",label:"Presentation Mode",shortcut:"",checked:f,disabled:!J||r0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:p,disabled:!J||r0}].filter((y0)=>!J8||!q8.has(y0.id)),d0=["file","edit","view","selection","tools","help"];function h0(y0){if(d0.includes(y0))H(Z===y0?null:y0)}return u.useEffect(()=>{if(!Z||!d0.includes(Z))return;let y0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function B8(D8){let N0=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!N0.length)return;let o0=N0.indexOf(document.activeElement);if(D8.key==="ArrowDown")D8.preventDefault(),N0[(o0+1)%N0.length].focus();else if(D8.key==="ArrowUp")D8.preventDefault(),N0[(o0-1+N0.length)%N0.length].focus();else if(D8.key==="Home")D8.preventDefault(),N0[0].focus();else if(D8.key==="End")D8.preventDefault(),N0[N0.length-1].focus();else if(D8.key==="ArrowRight"||D8.key==="ArrowLeft"){D8.preventDefault();let h8=D8.key==="ArrowRight"?1:-1,g8=d0.indexOf(Z);H(d0[(g8+h8+d0.length)%d0.length])}else if(D8.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",B8),()=>{clearTimeout(y0),window.removeEventListener("keydown",B8)}},[Z,H]),D("header",{className:"st-menubar",role:"menubar","aria-label":"Application menubar","data-testid":"menubar",children:[D("span",{className:"st-brand","data-tour":"brand",children:[z("span",{className:"st-brand-mark",children:z("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),z("span",{className:"st-brand-name",children:"maude"})]}),W?D("span",{className:"st-cloudback","data-testid":"cloud-back",children:[W.dashboardUrl?z("a",{className:"st-cloudback-link",href:W.dashboardUrl,title:"Back to your projects",children:"← Dashboard"}):null,W.projectName?z("span",{className:"st-cloudback-project","data-testid":"cloud-project-name",children:W.projectName}):null]}):null,z("nav",{className:"st-menus","aria-label":"Application menus","data-tour":"menus",children:hF0.map((y0)=>{let B8=y0.toLowerCase(),D8=d0.includes(B8),N0=D8||B8==="help",o0=Z===B8;return z("button",{type:"button",className:"st-menu",role:"menuitem","data-testid":`menu-${B8}`,"data-tour":B8==="help"?"help":void 0,"aria-haspopup":D8?"menu":void 0,"aria-expanded":D8?o0:void 0,onClick:()=>h0(B8),onMouseEnter:()=>{if(Z!==null&&D8)H(B8)},children:y0},B8)})}),Z==="file"&&z(lF0,{readOnly:J8,hasCanvas:!!J,hasSharePath:!!X,onAction:(y0)=>{if(y0==="new")x8?.();else if(y0==="assemble")S8?.();else if(y0==="export")O9?.("export");else if(y0==="share")document.querySelector('[data-testid="menu-file"]')?.focus(),Q?.();else if(y0==="handoff")O9?.("handoff");else if(y0==="generate")$8?.();else if(y0==="settings")v0?.();else if(y0==="reload")w9?.();else if(y0==="close")L8?.()},onClose:()=>H(null)}),Z==="edit"&&z(dF0,{readOnly:J8,hasCanvas:!!J&&!r0,onAction:(y0)=>{if(y0==="undo")r({dgn:"undo"});else if(y0==="redo")r({dgn:"redo"});else if(y0==="deselect-all")r({dgn:"selection-clear"});else if(y0==="select-all-annotations")r({dgn:"annotation-select-all"});else if(y0.startsWith("new-artboard:"))V0?.(y0.slice(13))},onClose:()=>H(null)}),Z==="view"&&z(gF0,{panels:l0,onToggle:(y0)=>{if(y0==="tree")A();else if(y0==="changes")N();else if(y0==="comments")U();else if(y0==="hidden")w();else if(y0==="annotate")j();else if(y0==="inspector")s0();else if(y0==="autoopen")E8?.();else if(y0==="timeline")T8?.();else if(y0==="assistant")C0?.();else if(y0==="layers")a8?.();else if(y0==="minimap")m?.();else if(y0==="zoomctl")a?.();else if(y0==="present")h?.();else if(y0==="print-guides")v?.()},onZoom:(y0)=>r({dgn:"zoom",op:y0}),hasCanvas:!!J&&!r0,onClose:()=>H(null)}),Z==="selection"&&z(uF0,{readOnly:J8,onAction:(y0)=>{if(y0==="deselect-all")r({dgn:"selection-clear"});else if(y0==="select-all-annotations")r({dgn:"annotation-select-all"})},onClose:()=>H(null)}),Z==="tools"&&z(pF0,{readOnly:J8,onAction:(y0)=>r({dgn:"tool-set",tool:y0}),onClose:()=>H(null)}),Z==="help"&&z(mF0,{onAction:(y0)=>{if(y0==="shortcuts")I?.();else if(y0==="help")O?.();else if(y0==="report-bug")k?.();else if(y0==="tour")R?.();else if(y0==="collab-tour")$?.();else if(y0==="quick-setup")K0?.();else if(y0==="readiness")c?.();else if(y0==="whatsnew")e?.();else if(y0==="watch-intro")s?.()},onClose:()=>H(null)}),D("div",{className:"st-mb-right","data-tour":"status",children:[Z0?z("div",{className:"st-presence",children:Z0}):null,J8&&z("span",{className:"st-stamp st-stamp--viewonly","data-testid":"view-only-stamp","data-tip":W?.user?`${W.user} is a viewer on this project — you can browse, comment and export where available. Ask a project owner for edit access, or sign out if that is not the account you meant to use.`:"Your role in this project is viewer — you can browse, comment when available, and export where available. Ask a project owner for edit access.",children:"VIEW ONLY"}),W?.user?D("span",{className:"st-cloudwho","data-testid":"cloud-account",children:[z("span",{className:"st-cloudwho-email",title:W.role?`Signed in as ${W.user} — ${W.role}`:W.user,children:W.user}),z("form",{method:"post",action:"/auth/browser/signout",className:"st-cloudwho-form",children:z("button",{type:"submit",className:"st-cloudwho-out","data-testid":"cloud-signout",title:"Sign out of this project",children:"Sign out"})})]}):null,G9()&&!J8&&z("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":w0?"true":"false","data-busy":W8?"true":"false","data-unseen":H8?"true":"false","aria-label":`Assistant${W8?" — working":H8?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:C0,children:z(T9,{name:"sparkle",size:15})}),z("button",{type:"button",className:"st-mb-icon st-share-btn","data-testid":"share-btn","data-tip":X?"Share link":"Open a canvas to share it","aria-label":"Share link",disabled:!X,onClick:Q,children:z(T9,{name:"share",size:15})}),o&&z(Fm,{center:o}),z("button",{type:"button",className:"st-reportbug","data-testid":"report-bug-toggle","aria-label":"Report a bug","data-tip":"Report a bug",onClick:k,children:z(T9,{name:"bug",size:15})}),z("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":z0>0?"true":"false","aria-label":`What's new${z0>0?` — ${z0} unseen`:""}`,"data-tip":"What's new",onClick:e,children:z(T9,{name:"megaphone",size:15})}),z("span",{className:"st-stamp",children:b0}),z("span",{className:"st-mb-file",title:J||"",children:X8}),z("span",{className:"st-mb-sep"}),D("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[z("span",{className:"st-dot",style:{background:"var(--accent)"}}),q0," ARTBOARDS"]}),z("span",{className:"st-mb-sep"}),z("span",{className:"st-mb-proj",children:Y||"maude"})]})]})}function iF0({tabs:J,activePath:X,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:K,onIframeLoad:U,canvasError:V,canvasReloadNonce:B,onRetryCanvasLoad:N,loadedPath:F,showQuickSetup:M,onStartQuickSetup:A,previewPath:E}){let w=u.useRef(null);u.useEffect(()=>{if(E)w.current?.focus()},[E]);let O=u.useRef(new Map),I=new Set(J.map(($)=>$.path));for(let[$,C]of O.current)if(!I.has(C.path))O.current.delete($);let k=($)=>{let C=EZ($,{...H,canvasToken:void 0}),j=`${$}#${B}|${C}`,x=O.current.get(j);if(!x)x={path:$,src:EZ($,H)},O.current.set(j,x);return x.src},R=V&&V.path===X?"error":X&&X!==r8&&F===X?"ready":K&&K===X?"loading":"idle";return D("div",{className:"viewport st-stage","data-tour":"viewport","data-canvas-state":R,children:[E&&z("div",{ref:w,className:"st-file-preview-overlay",role:"region","aria-label":`Preview: ${$V(Y4(E))}`,tabIndex:0,children:z(Ig,{path:E,kind:NL(Y4(E))})}),J.length===0&&!E&&D("div",{className:"st-empty",children:[D("div",{className:"st-empty-brand",children:[z("span",{className:"st-brand-mark",children:z("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),z("span",{className:"st-empty-wm",children:"maude"}),D("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(Z||"MAUDE").toUpperCase()," / v",Zk," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),z("div",{className:"st-empty-title",children:"Nothing open yet"}),D("div",{className:"st-empty-body",children:["← Pick a screen from the list on the left, or open ",z("strong",{children:"Design system"})," above it to see your colors, type, and components.",z("br",{}),z("br",{}),z("strong",{children:"To select something on the canvas:"})," hold ",z(CJ,{children:"⌘"})," and hover to preview an element, click to select it — ",z(CJ,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",G9()?D(Q0,{children:[z("br",{}),z("br",{}),"Claude can see whatever's selected when you ask for a change in the Assistant panel, so pointing is often faster than describing it."]}):null]}),M&&z("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:A,children:"Start quick setup"})]}),J.map(($)=>{if($.path===r8)return z("div",{className:"system-view"+($.path===X?" active":""),children:z(JL0,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},$.path);return z("iframe",{ref:(C)=>Q($.path,C),src:k($.path),className:$.path===X?"active":"","data-path":$.path,"data-testid":$.path===X?"canvas-frame":void 0,onLoad:()=>U?.($.path),...H?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},`${$.path}#${B}`)}),K&&K===X&&z("div",{className:"st-canvas-loading","aria-hidden":"true",children:D("div",{className:"st-skel-card",children:[z("div",{className:"st-skel-cap st-mono",children:"compiling canvas…"}),z("span",{className:"skel st-skel-thumb"}),z("span",{className:"skel st-skel-line",style:{width:"72%"}}),z("span",{className:"skel st-skel-line",style:{width:"46%"}})]})}),V&&V.path===X&&z("div",{className:"st-canvas-error",role:"alert","data-testid":"canvas-load-error",children:D("div",{className:"st-canvas-error-card",children:[z("div",{className:"st-canvas-error-title",children:V.kind==="server"?"Maude's server isn't responding":"This canvas didn't finish loading"}),z("div",{className:"st-canvas-error-body",children:V.kind==="server"?z(Q0,{children:"The canvas couldn't be reached. This usually means Maude's server restarted underneath this window — your files on disk are untouched."}):D(Q0,{children:["The server is up, but"," ",z("code",{children:$V(Y4(V.path))})," ","never finished compiling. Its own error, if it has one, is in the canvas frame."]})}),z("button",{type:"button",className:"btn btn--primary","data-testid":"canvas-load-retry",onClick:()=>N?.(V.path),children:"Reload canvas"})]})})]})}var oF0=["color","space","radius","shadow","leading","weight","motion","font","other"],nF0={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function rF0(J){return J==="color"}function aF0({tokens:J,tokenGroups:X,tokensPath:Q}){if(!J||J.length===0)return D("section",{className:"sv-section sv-section-tokens",children:[D("h2",{children:["tokens",z("span",{className:"sv-h-num",children:"0"})]}),z("div",{className:"sv-empty",children:D("p",{children:["No tokens parsed from"," ",Q?z("code",{children:Q}):"the configured tokens file",". Does the file exist and contain CSS custom properties (",z("code",{children:"--name: value;"}),")?"]})})]});let Y=X||{},W=Array.from(new Set([...oF0,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return z(Q0,{children:W.map((G)=>{let Z=Y[G],H=rF0(G);return D("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[D("h2",{children:["tokens · ",nF0[G]||G,z("span",{className:"sv-h-num",children:Z.length})]}),z("div",{className:"sv-tokens-ladder",children:Z.map((K)=>D("div",{className:"sv-tok-cell",children:[H?z("div",{className:"sv-tok-swatch",style:{background:K.value}}):null,D("div",{className:"sv-tok-meta",children:[z("code",{className:"sv-tok-name",children:K.name}),z("span",{className:"sv-tok-value",children:K.value||"—"})]})]},K.name+"|"+K.value))})]},G)})})}function sF0(J,X){let Q=J.name.match(/^--(?:type|fs|text)-(.+)$/);if(!Q)return null;let Y=Q[1];return(X||[]).find((W)=>/^--(?:lh|leading|line-height)-/.test(W.name)&&W.name.endsWith("-"+Y))?.value??null}function tF0(J){if(!J?.length)return;let X=["body","sans","display","text","family"];for(let Q of X){let Y=J.find((W)=>W.name.includes(Q));if(Y)return Y.value}return J[0].value}function eF0({tokenGroups:J}){let X=J?.fontsize||[];if(X.length===0)return null;let Q=J?.leading||[],Y=tF0(J?.font);return D("section",{className:"sv-section sv-section-type",children:[D("h2",{children:["type · ladder",z("span",{className:"sv-h-num",children:X.length})]}),z("div",{className:"sv-type-list",children:X.map((W)=>{let G=sF0(W,Q),Z={fontSize:W.value};if(G)Z.lineHeight=G;if(Y)Z.fontFamily=Y;return D("div",{className:"sv-type-row",children:[z("code",{className:"sv-type-tok",children:W.name}),z("span",{className:"sv-type-sample",style:Z,children:"The catalog is the system."})]},W.name)})})]})}function JL0({data:J,onOpen:X,cfg:Q,onSelectDs:Y}){if(!J)return z("div",{className:"sv-empty",children:z("p",{children:"Loading design system…"})});let{previewGallery:W,uiKitsGallery:G,systemDir:Z,tokens:H,tokenGroups:K,tokensPath:U,ds:V,availableDesignSystems:B}=J,N=(!W||!W.length)&&(!G||!G.length),F=Array.isArray(B)&&B.length>1,M=V?.name??B?.[0]?.name??"";return D("div",{className:"sv",children:[D("header",{className:"sv-header",children:[z("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),z("span",{className:"sv-title",children:"design system view"}),F?D("label",{className:"sv-ds-picker",children:[z("span",{className:"sv-ds-picker-label",children:"DS"}),z("select",{value:M,onChange:(A)=>Y&&Y(A.target.value),children:B.map((A)=>z("option",{value:A.name,children:A.name},A.name))})]}):null,z("span",{className:"sv-loc",children:z("code",{children:Z})})]}),V?.description?z("p",{className:"sv-ds-description",children:V.description}):null,z(aF0,{tokens:H,tokenGroups:K,tokensPath:U}),z(eF0,{tokenGroups:K}),N?z("div",{className:"sv-empty",children:D("p",{children:["No ",z("code",{children:"preview/"})," or ",z("code",{children:"ui_kits/"})," folders found under"," ",z("code",{children:Z}),"."]})}):D(Q0,{children:[z(W90,{title:"preview",items:W,onOpen:X,kind:"preview",cfg:Q}),z(W90,{title:"ui kits",items:G,onOpen:X,kind:"ui_kits",cfg:Q})]})]})}function W90({title:J,items:X,onOpen:Q,kind:Y,cfg:W}){if(!X||X.length===0)return null;return D("section",{className:"sv-section",children:[D("h2",{children:[J," ",z("span",{className:"sv-count",children:X.length})]}),z("div",{className:"sv-previews sv-previews-"+Y,children:X.map((G)=>D("article",{className:"sv-preview-card",onClick:()=>Q(G.path),children:[z("div",{className:"sv-preview-frame",children:z("iframe",{src:EZ(G.path,W,{thumbnail:!0}),title:G.label,scrolling:"no",...W?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),D("div",{className:"sv-preview-foot",children:[z("strong",{children:G.label}),z("code",{children:G.path})]})]},G.path))})]})}function XL0({activePath:J,selected:X,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,syncProject:K,syncOpen:U=!1,onOpenSync:V,changesCount:B=0,unpushed:N=0,savingIsManaged:F=!1,changesOpen:M=!1,onOpenChanges:A,version:E}){let w=J===r8,O=X&&X.selector?X.selector+(X.text?` — "${X.text.slice(0,60)}"`:""):"",I=X&&X.dom_path?X.dom_path.join(" > "):X?X.selector:"",k=W==="dark"?"light":"dark",R=(()=>{let C=oz(H,{project:K});if(!C)return null;let j=C.names.length?` (${C.names.join(", ")})`:"";return{online:C.online,label:C.label,title:`${C.title}${j}${C.next?` — ${C.next}`:""}`}})(),$=R&&D(Q0,{children:[z("span",{className:"st-sb-sync-dot"+(R.online?" is-online":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:"hub sync"}),z("span",{className:"val",title:R.title,children:R.label})]});return D("footer",{className:"st-statusbar",role:"contentinfo","data-testid":"statusbar",children:[D("span",{className:"st-sb-slot st-sb-active",role:"group","aria-label":"Active file",children:[z("span",{className:"lead","aria-hidden":"true"}),z("span",{className:"lbl",children:"active"}),z("span",{className:"val",title:J||"",children:w?"▦ design system":J||"—"})]}),J&&X&&X.selector&&!w&&D("span",{className:"st-sb-slot st-sb-sel",role:"group","aria-label":"Selected element",children:[z("span",{className:"lbl",children:"selected"}),z("span",{className:"val",title:I,children:O}),z("button",{type:"button",className:"st-sb-sel-clear",onClick:Z,"data-tip":"Clear · Esc inside iframe","data-tip-pos":"top","aria-label":"Clear selection",children:"×"})]}),D("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[z("span",{className:"lbl",children:"comments"}),D("span",{className:"val",children:[Y," open"]})]}),A&&D("button",{type:"button",className:"st-sb-slot st-sb-changes"+(M?" is-open":"")+(B>0?" has-changes":N>0?" has-unpushed":""),onClick:A,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":M,children:[z("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),z("span",{className:"lbl",children:"changes"}),z("span",{className:"val",children:F?"cloud saving":B>0?`${B} unsaved`:N>0?`${N} to publish`:"all saved"})]}),z("span",{className:"st-sb-spacer"}),D("span",{className:"st-sb-slot",role:"group","aria-label":"Connection",children:[z("span",{className:"st-live-dot"+(Q?" is-connected":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:Q?"live":"reconnecting"})]}),R&&(V?z("button",{type:"button",className:"st-sb-slot st-sb-sync st-sb-sync--btn"+(U?" is-open":""),onClick:V,"data-testid":"open-sync","data-tip":"Open Sync panel","data-tip-pos":"top","aria-label":"Open Sync panel","aria-pressed":U,children:$}):z("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:$})),E&&z("span",{className:"st-sb-slot st-sb-version",role:"group","aria-label":"Maude version",children:D("span",{className:"val","data-testid":"statusbar-version",children:["v",E]})}),D("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${k} theme`,"data-tip-pos":"top","aria-label":`Switch to ${k} theme`,children:[z(T9,{name:W==="dark"?"sun":"moon",size:13}),k]})]})}function QL0({commentsByFile:J,filter:X,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:K,width:U,resizing:V}){let B=w90(J),N=Object.keys(J||{}).sort(),F=[];for(let M of N){let A=J[M]||[],E=A.filter((O)=>{if(X==="open")return O.status!=="resolved";if(X==="resolved")return O.status==="resolved";return!0});if(E.length===0)continue;let w=A.filter((O)=>O.selector);F.push({file:M,comments:E.map((O)=>({...O,n:w.findIndex((I)=>I.id===O.id)+1}))})}return D("aside",{className:"st-rpanel"+(V?" is-resizing":""),style:U?{width:U,flexBasis:U}:void 0,"aria-label":"Comments",children:[z("div",{className:"st-rp-tabs st-rp-tabs--filters",children:D("div",{className:"st-cm-filters",role:"tablist",children:[D("button",{type:"button",className:"st-cm-filter"+(X==="all"?" is-active":""),role:"tab","data-testid":"comment-filter-all","aria-selected":X==="all",onClick:()=>Q("all"),children:["All · ",B.all]}),D("button",{type:"button",className:"st-cm-filter"+(X==="open"?" is-active":""),role:"tab","data-testid":"comment-filter-open","aria-selected":X==="open",onClick:()=>Q("open"),children:["Open · ",B.open]}),D("button",{type:"button",className:"st-cm-filter"+(X==="resolved"?" is-active":""),role:"tab","data-testid":"comment-filter-resolved","aria-selected":X==="resolved",onClick:()=>Q("resolved"),children:["Resolved · ",B.resolved]})]})}),z("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:F.length===0?D("div",{className:"st-rp-empty",children:[D("p",{children:["No comments ",X!=="all"?`with status “${X}”`:"yet","."]}),D("p",{children:["Open a canvas, hold ",z(CJ,{children:"⌘"})," and click an element, then press ",z(CJ,{children:"C"})," — or hold ",z(CJ,{children:"⌘⇧"})," and click directly."]})]}):F.map((M)=>D(Q0,{children:[D("button",{type:"button",className:"st-cm-group-hd",onClick:()=>G(M.file,null),title:M.file,children:[z("span",{children:VY(Y4(M.file))}),z("span",{className:"st-mono",children:M.comments.length})]}),M.comments.map((A)=>D("div",{"data-testid":`comment-item-${A.id}`,className:"st-comment"+(A.status==="resolved"?" is-resolved":"")+(A.id===W?" is-active":""),onClick:()=>G(M.file,A.id),children:[D("div",{className:"st-comment-hd",children:[z("span",{className:"st-pin st-pin--inline",children:A.n||"·"}),z("span",{className:"st-comment-time",children:DF0(A.created)})]}),z("div",{className:"st-comment-txt",children:A.text}),D("div",{className:"st-comment-foot",children:[z("span",{className:"st-comment-sel",title:(A.dom_path||[]).join(" > "),children:A.selector||"—"}),Z&&H&&K?D("span",{className:"st-mini-act",children:[A.status==="resolved"?z("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(E)=>{E.stopPropagation(),H(A.id)},children:z(T9,{name:"reopen",size:14})}):z("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(E)=>{E.stopPropagation(),Z(A.id)},children:z(T9,{name:"resolve",size:14})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(E)=>{E.stopPropagation(),K(A.id)},children:z(T9,{name:"x",size:14})})]}):null]})]},A.id))]},M.file))})]})}var YL0={owner:"You own this project — edit, invite and export.",member:"You can edit this project, comment and export.",viewer:"You can look at this project, comment and download it, but not change it."};function WL0({cloud:J}){let X=J?.role||null,[Q,Y]=u.useState(!1);if(!X||Q)return null;let W=`maude-cloud-role-seen:${X}`,G=!1;try{G=localStorage.getItem(W)==="1"}catch{}if(G)return null;let Z=YL0[X];if(!Z)return null;return D("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info","data-testid":"cloud-role-banner",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:Z}),z("button",{type:"button",className:"btn btn--ghost btn--sm","data-testid":"cloud-role-banner-dismiss",onClick:()=>{Y(!0);try{localStorage.setItem(W,"1")}catch{}},children:"Got it"})]})}function GL0({update:J,onDismiss:X}){let[Q,Y]=u.useState(!1);if(!J)return null;let W=J.version?` (v${J.version})`:"";return D("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),D("span",{children:["Maude updated",W," · restart to apply"]}),z("button",{type:"button",className:"btn btn--primary btn--sm",disabled:Q,onClick:()=>{Y(!0),Bh().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X,children:"Later"})]})}function ZL0({status:J}){let[X,Q]=u.useState(null);if(!J||J.linked===!1)return null;if(J.notSyncable)return null;let{state:Y,queuedOps:W,flash:G,conflicts:Z}=J,H=G==="synced",K=Y==="offline"||Y==="offline-long",U=J.docs?.rejected??0,V=Array.isArray(Z)?[...Z].reverse().find((M)=>M.kind==="cold-start-diverged"):null;if(!K&&!H&&!V&&U===0)return null;let B,N,F;if(H)B="success",N="Synced with hub",F=`${Y}:flash`;else if(K){let M=Z&&Z.length>0?` (${Z.length} conflict notice(s))`:"";if(Y==="offline-long")B="error",N=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${M}`;else B="warn",N=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${M}`;F=`${Y}:offline`}else if(V){if(V.snapshotFailed)B="error",N=`Diverged on ${V.slug}: kept local — the history snapshot FAILED, so the overwrite was refused. Check disk space / .design/_history write access.`;else B="warn",N=`Diverged on ${V.slug}: kept the ${V.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${V.slug}`;F=`diverged:${V.slug}:${V.at}`}else B="warn",N=`${U} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,F=`rejected:${U}`;if(X===F)return null;return D("div",{role:"status","aria-live":"polite",className:`st-banner st-banner--${B}`,children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:N}),z("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(F),children:"×"})]})}var HL0=["block","inline-block","flex","inline-flex","grid","inline","none"],G90=["px","%","fr","em","auto","min-content","max-content"];var zL0=["auto","stretch","flex-start","center","flex-end","baseline"];var Z90=["300","400","500","600","700","800"],Uq=(J,X)=>J&&Object.hasOwn(J,"previous")?J.previous:X,H90=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],z90=["none","solid","dashed","dotted","double"],K90=["px","rem","em","%","vw","vh","auto"],U90=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),Wk={"font-size":{node:z(K7,{as:bV,size:12})},"line-height":{node:z(K7,{as:gV,size:12})},"letter-spacing":{node:z(K7,{as:nV,size:12})},gap:{node:z(K7,{as:PK,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:z(K7,{as:eV,size:12})},"border-width":{node:z(K7,{as:oV,size:12})}};var V90=["static","relative","absolute","fixed","sticky"],KL0=["normal","italic","oblique"],q90=["none","uppercase","lowercase","capitalize"];var B90=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],UL0=["fill","contain","cover","none","scale-down"];var N90=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],F90=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],b5={desktop:{label:"Desktop",width:1440,height:1024},laptop:{label:"Laptop",width:1280,height:800},tablet:{label:"Tablet",width:834,height:1194},mobile:{label:"Mobile",width:390,height:844}},tK=null;function BL(J){if(!J)return"";if(/^#[0-9a-f]{6}$/i.test(J))return J.toLowerCase();try{if(!tK)tK=document.createElement("canvas").getContext("2d");if(!tK)return"";tK.fillStyle="#000000",tK.fillStyle=J;let X=tK.fillStyle;if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();let Q=X.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(Q)return`#${[Q[1],Q[2],Q[3]].map((Y)=>Number(Y).toString(16).padStart(2,"0")).join("")}`}catch{}return""}var UY=(J)=>Math.min(1,Math.max(0,J));function ZL(J){let X=/^#?([0-9a-f]{6})$/i.exec(J||"");if(!X)return{r:0,g:0,b:0};let Q=Number.parseInt(X[1],16);return{r:Q>>16&255,g:Q>>8&255,b:Q&255}}function Vq({r:J,g:X,b:Q}){return`#${[J,X,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function qq({r:J,g:X,b:Q}){J/=255,X/=255,Q/=255;let Y=Math.max(J,X,Q),W=Math.min(J,X,Q),G=Y-W,Z=0;if(G){if(Y===J)Z=(X-Q)/G%6;else if(Y===X)Z=(Q-J)/G+2;else Z=(J-X)/G+4;if(Z*=60,Z<0)Z+=360}return{h:Z,s:Y?G/Y:0,v:Y}}function eK({h:J,s:X,v:Q}){let Y=Q*X,W=Y*(1-Math.abs(J/60%2-1)),G=Q-Y,Z=0,H=0,K=0;if(J<60)[Z,H,K]=[Y,W,0];else if(J<120)[Z,H,K]=[W,Y,0];else if(J<180)[Z,H,K]=[0,Y,W];else if(J<240)[Z,H,K]=[0,W,Y];else if(J<300)[Z,H,K]=[W,0,Y];else[Z,H,K]=[Y,0,W];return{r:(Z+G)*255,g:(H+G)*255,b:(K+G)*255}}function U7(J){if(!J)return"";let X=/^(-?\d*\.?\d+)px$/.exec(J);return X?`${Math.round(Number.parseFloat(X[1]))}px`:J}function Q4(J){if(!J)return{n:"",unit:"px"};let X=J.trim(),Q=/^(-?\d*\.?\d+)\s*(px|rem|em|%|vw|vh)?$/.exec(X);if(Q)return{n:Q[1],unit:Q[2]||"px"};if(X==="auto")return{n:"",unit:"auto"};return{n:X,unit:""}}function L90(J,X){if(!J||Array.isArray(J)||Array.isArray(X)||!X)return J;if(!J.id&&!X.id){let Q=(Y)=>typeof Y.selector==="string"&&Y.selector.startsWith("[data-dc-screen=");if(Q(J)&&Q(X)&&J.selector===X.selector&&J.file===X.file)return{...J,authored:J.authored??X.authored,computed:J.computed??X.computed,customStyles:J.customStyles??X.customStyles,attrs:J.attrs??X.attrs,artboardId:J.artboardId??X.artboardId,worldW:J.worldW??X.worldW,worldH:J.worldH??X.worldH};return J}if(!J.id||J.id!==X.id)return J;return{...J,authored:J.authored??X.authored,computed:J.computed??X.computed,customStyles:J.customStyles??X.customStyles,attrs:J.attrs??X.attrs,photoKind:J.photoKind??X.photoKind,photoAsset:J.photoAsset??X.photoAsset}}function I90(J,X){return(J?X?.canvasDesignSystems?.[J]:null)||X?.defaultDesignSystem||X?.designSystems?.[0]?.name||null}function VL0(J){let X={};for(let Z of J.matchAll(/(--[a-z0-9-]+)\s*:\s*([^;}]+)/gi))if(!(Z[1]in X))X[Z[1]]=Z[2].trim();let Q={};for(let Z of Object.keys(X)){let H=X[Z],K=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(H);Q[Z]=K&&X[K[1]]?X[K[1]]:H}let Y=Object.keys(X),W=(Z)=>Y.filter((H)=>Z.test(H)),G=(Z)=>/^(#[0-9a-f]{3,8}|rgba?\(|hsla?\(|oklch\(|oklab\(|lab\(|lch\(|hwb\(|color\()/i.test(Z)||/^(transparent|currentcolor|white|black|red|green|blue|gray|grey|orange|yellow|purple|pink|cyan|magenta|teal|navy|maroon|olive|lime|aqua|silver|gold)$/i.test(Z);return{color:Y.filter((Z)=>G(Q[Z])),space:W(/^--space-/),radius:W(/^--radius-/),type:W(/^--type-/),shadow:W(/^--shadow-/),lh:W(/^--lh-/),vals:Q}}function T90(J,X,Q){let Y=J?.designSystems||[],W=Y.map((H)=>`${H.name}:${H.tokensCssRel}`).join("|"),[G,Z]=u.useState([]);return u.useEffect(()=>{if(!Y.length)return;let H=!1;return Promise.all(Y.map(async(K)=>{if(!K.tokensCssRel)return null;try{let U=await fetch(`/${X}/${K.tokensCssRel}`),V=U.ok?await U.text():"";return{name:K.name,...VL0(V)}}catch{return null}})).then((K)=>{if(H)return;let U=K.filter(Boolean);U.sort((V,B)=>V.name===Q?-1:B.name===Q?1:0),Z(U)}),()=>{H=!0}},[W,X,Q]),G}function k90({seed:J,label:X,onApply:Q}){let[Y,W]=u.useState(()=>qq(ZL(J||"#000000"))),G=u.useRef(Y);G.current=Y;let Z=u.useRef(null),H=u.useRef(null),K=u.useRef(J);u.useEffect(()=>{if(J&&J!==K.current)K.current=J,W(qq(ZL(J)))},[J]);let U=Vq(eK(Y)),V=(O)=>{O.preventDefault();let I=Z.current?.getBoundingClientRect();if(!I)return;let k=G.current.h,R=(C)=>{W({h:k,s:UY((C.clientX-I.left)/I.width),v:UY(1-(C.clientY-I.top)/I.height)})};R(O);let $=()=>{document.removeEventListener("pointermove",R),document.removeEventListener("pointerup",$),Q(Vq(eK(G.current)))};document.addEventListener("pointermove",R),document.addEventListener("pointerup",$)},B=(O)=>{O.preventDefault();let I=H.current?.getBoundingClientRect();if(!I)return;let{s:k,v:R}=G.current,$=(j)=>{W({h:UY((j.clientX-I.left)/I.width)*360,s:k,v:R})};$(O);let C=()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",C),Q(Vq(eK(G.current)))};document.addEventListener("pointermove",$),document.addEventListener("pointerup",C)},N=(O)=>{let I={...G.current,...O};W(I),Q(Vq(eK(I)))},F=(O)=>{let I=O.shiftKey?0.1:0.02,R={ArrowLeft:[-I,0],ArrowRight:[I,0],ArrowUp:[0,I],ArrowDown:[0,-I]}[O.key];if(!R)return;O.preventDefault(),N({s:UY(G.current.s+R[0]),v:UY(G.current.v+R[1])})},M=(O)=>{let I=O.shiftKey?20:2,R={ArrowLeft:-I,ArrowRight:I}[O.key];if(R==null)return;O.preventDefault(),N({h:Math.min(360,Math.max(0,G.current.h+R))})},A=async()=>{try{let O=window.EyeDropper;if(!O)return;let I=await new O().open();if(I?.sRGBHex)W(qq(ZL(I.sRGBHex))),Q(I.sRGBHex)}catch{}},E=eK(Y),w=(O)=>{let I={...E,...O},k=qq({r:UY(I.r/255)*255,g:UY(I.g/255)*255,b:UY(I.b/255)*255});W(k),Q(Vq(eK(k)))};return D("div",{className:"st-cp-cpick",children:[D("div",{className:"st-cp-cpick-hexrow",children:[z("span",{className:"st-cp-cpick-hexsw",style:{background:U}}),z("input",{className:"st-cp-cpick-hex",type:"text",value:U,"aria-label":X?`${X} hex value`:"hex value",onChange:(O)=>{let I=O.target.value;if(/^#?[0-9a-f]{6}$/i.test(I))W(qq(ZL(I)))},onKeyDown:(O)=>{if(O.key==="Enter")Q(O.currentTarget.value)},onBlur:(O)=>Q(O.currentTarget.value),onFocus:(O)=>O.currentTarget.select()})]}),D("button",{type:"button",ref:Z,className:"st-cp-cpick-sv","aria-label":X?`${X} saturation and value`:"saturation and value",style:{background:`hsl(${Y.h} 100% 50%)`},onPointerDown:V,onKeyDown:F,children:[z("span",{className:"st-cp-cpick-svwhite"}),z("span",{className:"st-cp-cpick-svblack"}),z("span",{className:"st-cp-cpick-knob",style:{left:`${Y.s*100}%`,top:`${(1-Y.v)*100}%`,background:U}})]}),D("div",{className:"st-cp-cpick-controls",children:[window.EyeDropper?z("button",{type:"button",className:"st-cp-cpick-eye","aria-label":"pick from screen",title:"eyedropper",onClick:A,children:z(T9,{name:"eyedropper",size:14})}):null,z("span",{className:"st-cp-cpick-preview",style:{background:U},"aria-hidden":"true"}),z("button",{type:"button",ref:H,className:"st-cp-cpick-hue","aria-label":X?`${X} hue`:"hue",onPointerDown:B,onKeyDown:M,children:z("span",{className:"st-cp-cpick-huethumb",style:{left:`${Y.h/360*100}%`}})})]}),z("div",{className:"st-cp-cpick-rgb",children:["r","g","b"].map((O)=>D("label",{className:"st-cp-cpick-rgbf",children:[z("input",{"aria-label":O.toUpperCase(),value:Math.round(E[O]),onChange:(I)=>w({[O]:UY((Number.parseFloat(I.target.value)||0)/255)*255}),onFocus:(I)=>I.currentTarget.select()}),z("span",{children:O.toUpperCase()})]},O))})]})}function KL({kind:J,groups:X,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:K}){let[U,V]=u.useState(!1),[B,N]=u.useState(null),[F,M]=u.useState("custom"),[A,E]=u.useState(""),w=u.useRef(null),O=u.useRef(null),I=typeof Q==="string"&&/var\(\s*--/.test(Q),k=(e)=>Q===`var(${e})`,R=(e)=>e.replace(/^--/,"").replace(/-/g," "),$=X||[],C=$.reduce((e,c)=>e+(c.names?.length||0),0),j=$.length>1,x=A.trim().toLowerCase(),m=!x?$:$.map((e)=>({...e,names:(e.names||[]).filter((c)=>R(c).toLowerCase().includes(x)||c.toLowerCase().includes(x)||(e.vals?.[c]||"").toLowerCase().includes(x))})).filter((e)=>e.names.length);u.useEffect(()=>{if(!U){E("");return}let e=()=>{let z0=w.current?.getBoundingClientRect();if(!z0)return;let o=224,q0=300,Z0=Math.min(z0.right-o,window.innerWidth-o-8);if(Z0<8)Z0=8;let a0=window.innerHeight-z0.bottom>q0+8?z0.bottom+4:Math.max(8,z0.top-q0-4);N({left:Z0,top:a0,width:o,maxHeight:q0})};e();let c=(z0)=>{if(O.current?.contains(z0.target)||w.current?.contains(z0.target))return;V(!1)},K0=(z0)=>{if(z0.key==="Escape")V(!1)},s=(z0)=>{if(O.current?.contains(z0.target))return;e()};return document.addEventListener("pointerdown",c,!0),document.addEventListener("keydown",K0),window.addEventListener("resize",e),document.addEventListener("scroll",s,!0),()=>{document.removeEventListener("pointerdown",c,!0),document.removeEventListener("keydown",K0),window.removeEventListener("resize",e),document.removeEventListener("scroll",s,!0)}},[U]),u.useEffect(()=>{if(!U||!B||!O.current)return;let e=O.current.getBoundingClientRect(),c=B.left-e.left,K0=B.top-e.top;if(Math.abs(c)>0.5||Math.abs(K0)>0.5)N((s)=>s?{...s,left:s.left+c,top:s.top+K0}:s)},[U,B]);let d=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,a=(e,c,K0)=>{if(H&&e&&e!==H&&K0&&!d.test(K0))Y(K0);else Y(`var(${c})`);V(!1)},f=(e)=>{let c=(e||"").trim();if(c)Y(c)},h=D("div",{className:"st-cp-pop-search",children:[z(T9,{name:"search",size:12}),z("input",{value:A,onChange:(e)=>E(e.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),p=(e)=>e.map((c)=>D("div",{className:"st-cp-pop-group",children:[j?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((K0)=>D("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${k(K0)?" is-on":""}`,onClick:()=>a(c.ds,K0,c.vals?.[K0]),children:[z("span",{className:"st-cp-pop-cswatch",style:{background:c.vals?.[K0]||"transparent"},"aria-hidden":"true"}),z("span",{className:"st-cp-pop-name",children:R(K0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[K0]||""})]},`${c.ds}:${K0}`))})]},c.ds)),v=(e)=>e.map((c)=>D("div",{className:"st-cp-pop-group",children:[j?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((K0)=>D("button",{type:"button",className:`st-cp-pop-row${k(K0)?" is-on":""}`,onClick:()=>a(c.ds,K0,c.vals?.[K0]),children:[z("span",{className:"st-cp-pop-name",children:R(K0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[K0]||""})]},`${c.ds}:${K0}`))})]},c.ds)),r=z("div",{className:"st-cp-pop-empty",children:"No match"});return D(Q0,{children:[G!==void 0?z("button",{type:"button",ref:w,className:`${K||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${I&&!K?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>V((e)=>!e),children:z("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):z("button",{type:"button",ref:w,className:`st-cp-tokbtn${I?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>V((e)=>!e),children:z("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),U&&B?M90.createPortal(z("div",{ref:O,className:"maude st-cp-pop","data-theme":typeof document<"u"&&document.documentElement.getAttribute("data-theme")||"dark",role:"dialog","aria-label":W||"design tokens",style:{left:B.left,top:B.top,width:B.width,maxHeight:B.maxHeight},children:J==="color"?D(Q0,{children:[D("div",{className:"st-cp-poptabs",role:"tablist",children:[z("button",{type:"button",role:"tab","aria-selected":F==="custom",className:`st-cp-poptab${F==="custom"?" is-active":""}`,onClick:()=>M("custom"),children:"Custom"}),z("button",{type:"button",role:"tab","aria-selected":F==="vars",className:`st-cp-poptab${F==="vars"?" is-active":""}`,onClick:()=>M("vars"),children:"Variables"})]}),F==="custom"?z(k90,{seed:Z||BL(Q)||"#000000",onApply:f}):!C?z("div",{className:"st-cp-pop-empty",children:"No color tokens"}):D(Q0,{children:[h,m.length?p(m):r]})]}):!C?z("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):D(Q0,{children:[h,m.length?v(m):r]})}),document.body):null]})}function D90({label:J,tracks:X,editable:Q,onChange:Y}){let W=(K,U)=>{let V=X[K];Y(X.map((B,N)=>N===K?CU.has(U)?{value:0,unit:U}:{value:V.value||1,unit:U}:B))},G=(K,U)=>{Y(X.map((V,B)=>B===K?{...V,value:U}:V))},Z=()=>Y([...X,{value:1,unit:"fr"}]),H=(K)=>Y(X.filter((U,V)=>V!==K));return D("div",{className:"st-cp-gridtracks",children:[D("div",{className:"st-cp-gridtracks-hd",children:[z("span",{className:"st-cp-gridtracks-label",children:J}),z("button",{type:"button",className:"st-btn st-cp-gridtracks-add",disabled:!Q,onClick:Z,children:"+ Track"})]}),X.length===0?D("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",J.toLowerCase(),"."]}):X.map((K,U)=>{let V=CU.has(K.unit);return D("div",{className:"st-cp-gridtrack-row",children:[V?z(cW,{value:K.unit,ariaLabel:`${J} track ${U+1}`,options:G90.map((B)=>({value:B,label:B})),onChange:(B)=>W(U,B)}):z(zJ,{value:K.value,min:K.unit==="fr"?0.1:0,step:K.unit==="fr"?0.1:1,ariaLabel:`${J} track ${U+1} value`,lead:String(U+1),unitSlot:z(uN,{value:K.unit,units:G90,ariaLabel:`${J} track ${U+1} unit`,onChange:(B)=>W(U,B)}),onCommit:(B)=>G(U,B)}),z("button",{type:"button",className:"st-btn st-cp-gridtrack-remove","aria-label":`remove ${J} track ${U+1}`,disabled:!Q||X.length<=1,onClick:()=>H(U),children:"×"})]},U)})]})}function qL0({el:J,cfg:X,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let K=!!J.id,U=J.computed||{},[V,B]=u.useState({a:{},c:{},t:{}});u.useEffect(()=>{B({a:{},c:{},t:{}})},[J.id,J.authored,J.customStyles,J.attrs]);let N=(t,M0)=>{let _0={...t||{}};for(let[f0,Y8]of Object.entries(M0))if(Y8===null)delete _0[f0];else _0[f0]=Y8;return _0},F=N(J.authored,V.a),M=N(J.customStyles,V.c),A=N(J.attrs,V.t),E=(t,M0)=>B((_0)=>({..._0,a:{..._0.a,[t]:M0}})),w=(t,M0)=>B((_0)=>({..._0,c:{..._0.c,[t]:M0}})),O=(t,M0)=>B((_0)=>({..._0,t:{..._0.t,[t]:M0}})),I=(X?.designRel||X?.designRoot||".design").replace(/^\/+|\/+$/g,""),k=I90(J.file,X),R=T90(X,I,k),$=(t)=>R.map((M0)=>({ds:M0.name,names:M0[t]||[],vals:M0.vals})).filter((M0)=>M0.names.length),[C,j]=u.useState({}),[x,m]=u.useState({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),d=Object.keys(M).length>0||Object.keys(A).length>0;u.useEffect(()=>{if(d)m((t)=>t.Advanced?t:{...t,Advanced:!0})},[J.id,d]);let a=(F.position||U7(U.position)||"static")!=="static";u.useEffect(()=>{if(a)m((t)=>t["d:Position"]?t:{...t,"d:Position":!0})},[J.id,a]);let f=H,[h,p]=u.useState({});async function v(t,M0,_0){j((f0)=>({...f0,[_0]:"saving"}));try{let f0=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(M0)}),Y8=await f0.json().catch(()=>({}));return j((m8)=>({...m8,[_0]:!f0.ok||!Y8.ok?`err:${Y8&&Y8.error||`HTTP ${f0.status}`}`:"saved"})),f0.ok?Y8:null}catch(f0){return j((Y8)=>({...Y8,[_0]:`err:${f0&&f0.message?f0.message:String(f0)}`})),null}}let r=u.useRef(Promise.resolve()),e=(t,M0,_0,f0,Y8,m8,e8)=>{r.current=r.current.then(async()=>{let y8=await v(t,M0,_0);if(!y8?.ok)return;let W9=Object.hasOwn(y8,"previous")?y8.previous:m8;if((W9??null)===(e8??null))return;K0(f0,Y8,W9,e8)})},c=(t,M0)=>{if(!Q||!J.id)return;Q({id:J.id,artboardId:J.artboardId??null,index:J.index??0,prop:t,value:M0})},K0=(t,M0,_0,f0)=>{Y?.({op:t,canvas:J.file,id:J.id,key:M0,before:_0==null||_0===""?null:_0,after:f0==null||f0===""?null:f0})},s=(t,M0)=>{let _0=(M0||"").trim();if(!K||!_0)return;let f0=F[t]??null;if(_0===(f0??"").trim())return;c(t,_0),E(t,_0),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,value:_0},t,"css",t,f0,_0)},z0=(t,M0)=>{let _0=(M0||"").trim(),f0=t.trim();if(!K||!f0||!_0)return;let Y8=M[f0]??null;c(f0,_0),w(f0,_0),e("/_api/edit-css",{canvas:J.file,id:J.id,property:f0,value:_0},f0,"css",f0,Y8,_0)},o=(t,M0)=>{let _0=(t||"").trim(),f0=(M0||"").trim();if(!K||!_0||!f0)return;let Y8=A[_0]??null;O(_0,f0),e("/_api/edit-attr",{canvas:J.file,id:J.id,attr:_0,value:f0},`@${_0}`,"attr",_0,Y8,f0)},q0=(t)=>{if(!K)return;let M0=F[t]??null;c(t,null),E(t,null),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,reset:!0},t,"css",t,M0,null)},Z0=(t)=>{if(!K)return;let M0=M[t]??null;c(t,null),w(t,null),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,reset:!0},t,"css",t,M0,null)},k0=(t)=>{if(!K)return;let M0=A[t]??null;O(t,null),e("/_api/edit-attr",{canvas:J.file,id:J.id,attr:t,reset:!0},`@${t}`,"attr",t,M0,null)},a0={display:J.parentDisplay,flexDirection:J.parentFlexDirection},s0=(t,M0)=>{if(!K)return;let _0=Math.round((t==="width"?J.bounds?.w:J.bounds?.h)||0),f0=yb(t,M0,a0,_0);for(let Y8 of f0.reset)if(F[Y8])q0(Y8);for(let[Y8,m8]of f0.set)s(Y8,m8)},t0=J.parentDisplay==="flex"||J.parentDisplay==="inline-flex",E8=(t)=>{let M0=bb(t,F,U,a0);return D("div",{className:"st-cp-moderow",children:[z("span",{className:"st-cp-modelabel",children:t==="width"?"Width sizing":"Height sizing"}),z("div",{className:"st-cp-modeseg",role:"group","aria-label":`${t} sizing mode`,children:z(pN,{value:M0,ariaLabel:`${t} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(_0)=>s0(t,_0)})})]},`mode-${t}`)},a8=["flex-start","center","flex-end"],F8=["flex-start","center","flex-end"],T8=["t","c","b"],I0=["l","c","r"],w0=()=>{let t=!(F["flex-direction"]||U7(U["flex-direction"])||"row").startsWith("column"),M0=Math.max(0,a8.indexOf(F["justify-content"]||U7(U["justify-content"])||"flex-start")),_0=F["align-items"]||U7(U["align-items"])||"stretch",f0=_0==="stretch"?1:Math.max(0,F8.indexOf(_0)),[Y8,m8]=t?[M0,f0]:[f0,M0];return T8[m8]+I0[Y8]},C0=(t)=>{let M0=T8.indexOf(t[0]),_0=I0.indexOf(t[1]),f0=!(F["flex-direction"]||U7(U["flex-direction"])||"row").startsWith("column"),[Y8,m8]=f0?[_0,M0]:[M0,_0];s("justify-content",a8[Y8]),s("align-items",F8[m8])},W8=(t)=>{if(!(t.metaKey||t.ctrlKey)||t.altKey)return;let M0=t.key.toLowerCase();if(M0==="z")t.preventDefault(),G?.(t.shiftKey?"redo":"undo");else if(M0==="y")t.preventDefault(),G?.("redo")},H8=(t)=>{let M0=F[t];if(!M0)return"inherit";return/var\(\s*--/.test(M0)?"bound":"raw"};if(!K)return D("div",{className:"st-cp",children:[z("div",{className:"st-cp-id",children:z("span",{className:"st-cp-idtag",children:J.tag||"element"})}),D("div",{className:"st-css-disabled",children:["This selection has no stable element id (a legacy canvas, or a non-element target). Edit it with ",z("code",{children:"/design:edit"}),"."]})]});let x8={bound:"token-bound",raw:"raw override",inherit:"inherited"},S8=(t)=>z("span",{className:`st-cp-prov st-cp-prov--${t}`,role:"img","aria-label":x8[t]}),O9=(t,M0)=>{let _0=M0??H8(t),f0=C[t],Y8=typeof f0==="string"&&f0.startsWith("err:")?f0.slice(4):"",m8=Y8?" is-err":f0==="saved"?" is-saved":f0==="saving"?" is-saving":"",e8=!!F[t],y8=Y8?`error: ${Y8}`:e8?`${x8[_0]} · double-click to reset`:x8[_0];return z("button",{type:"button",className:`st-cp-prov st-cp-prov--${_0}${m8}${e8?" is-resettable":""}`,"aria-label":y8,title:y8,tabIndex:e8?0:-1,onDoubleClick:e8?()=>q0(t):void 0,onKeyDown:e8?(W9)=>{if(W9.key==="Backspace"||W9.key==="Delete")W9.preventDefault(),q0(t)}:void 0})},v0=(t,M0,_0,f0)=>{let Y8=_0===void 0&&!F[t],m8=f0??t;return D("div",{className:`st-cp-row${Y8?" is-unset":""}`,children:[O9(t,_0),z("label",{className:"st-cp-label",title:m8,children:m8}),z("div",{className:"st-cp-ctl",children:M0})]},t)},$8={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"]},w9=(t)=>{($8[t]||[]).forEach((M0)=>{if(F[M0])q0(M0)})},L8=(t,M0)=>{let _0=($8[t]||[]).some((f0)=>F[f0]);return D("section",{className:"st-cp-sec",children:[D("div",{className:"st-cp-sechd-row",children:[D("button",{type:"button",className:"st-cp-sechd","data-testid":`inspector-section-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,"aria-expanded":!!x[t],onClick:()=>m((f0)=>({...f0,[t]:!f0[t]})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:x[t]?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${_0?"":" is-quiet"}`,"aria-label":`reset ${t} section to original`,title:`reset ${t}`,disabled:!_0,onClick:()=>w9(t),children:z(K7,{as:oZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${x[t]?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:M0})})]},t)},V0=(t,M0,_0,f0=!0)=>{let Y8=`d:${t}`,m8=x[Y8]===void 0?f0:x[Y8],e8=M0.some((y8)=>F[y8]);return D("section",{className:"st-cp-sec",children:[D("div",{className:"st-cp-sechd-row",children:[D("button",{type:"button",className:"st-cp-sechd","aria-expanded":m8,onClick:()=>m((y8)=>({...y8,[Y8]:!m8})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:m8?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${e8?"":" is-quiet"}`,"aria-label":`reset ${t} to original`,title:`reset ${t}`,disabled:!e8,onClick:()=>M0.forEach((y8)=>{if(F[y8])q0(y8)}),children:z(K7,{as:oZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${m8?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:_0})})]},Y8)},J8=(t)=>z("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!h[t],"aria-label":h[t]?`${t} — fewer options`:`${t} — more options`,title:h[t]?"fewer":"more",onClick:()=>p((M0)=>({...M0,[t]:!M0[t]})),children:h[t]?"▴":"···"}),r0=(t,M0)=>D("select",{className:"st-cp-nsel","aria-label":t,value:M0.includes(F[t])?F[t]:"",onChange:(_0)=>s(t,_0.target.value),children:[z("option",{value:"",disabled:!0,children:U7(U[t])||"—"}),M0.map((_0)=>z("option",{value:_0,children:_0},_0))]}),b0=(t)=>$(t).flatMap((M0)=>(M0.names||[]).map((_0)=>({name:_0,value:M0.vals?.[_0]||""}))),X8=(t,M0)=>z(hw,{value:F[t]||U7(U[t])||M0[0].value,ariaLabel:t,options:M0,onChange:(_0)=>s(t,_0)}),q8=(t,M0,_0={})=>{let f0=Q4(F[t]??""),Y8=U90.has(t),m8=F[t]??"",e8=typeof m8==="string"&&/var\(\s*--/.test(m8),y8=Y8?"":f0.unit&&f0.unit!=="auto"?f0.unit:"px",W9=Number.parseFloat(Q4(U7(U[t])??"").n)||0,k9=f0.n!==""&&f0.n!=null?Number.parseFloat(f0.n)||0:W9,e9=Wk[t];return z(lN,{value:e8?m8:k9,tokens:b0(M0),ariaLabel:t,min:_0.min??0,lead:e9?e9.node??e9.t:void 0,unitSlot:Y8?null:z(uN,{units:K90,value:f0.unit||"px",ariaLabel:`${t} unit`,onChange:(J7)=>s(t,J7==="auto"?"auto":`${f0.n||"0"}${J7}`)}),onChange:(J7)=>s(t,typeof J7==="string"?J7:Y8?`${J7}`:`${J7}${y8}`)})},l0=()=>{let t=(Y8)=>Number.parseFloat(Q4(F[Y8]??F["border-radius"]??U7(U[Y8])??U7(U["border-radius"])??"0").n)||0,M0={tl:t("border-top-left-radius"),tr:t("border-top-right-radius"),bl:t("border-bottom-left-radius"),br:t("border-bottom-right-radius")},_0=(Y8)=>{if(Y8.tl===Y8.tr&&Y8.tr===Y8.bl&&Y8.bl===Y8.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((e8)=>{if(F[e8])q0(e8)}),s("border-radius",`${Y8.tl}px`);else s("border-top-left-radius",`${Y8.tl}px`),s("border-top-right-radius",`${Y8.tr}px`),s("border-bottom-left-radius",`${Y8.bl}px`),s("border-bottom-right-radius",`${Y8.br}px`)},f0=Wk["border-radius"];return z(vg,{corners:M0,lead:f0?f0.node??f0.t:void 0,onCorners:_0})},d0=()=>D("div",{className:"st-cp-border",children:[Q9("border-width",null,{fixedUnit:"px"}),D("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:z90.includes(F["border-style"])?F["border-style"]:"",onChange:(t)=>s("border-style",t.target.value),children:[z("option",{value:"",disabled:!0,children:"style"}),z90.map((t)=>z("option",{value:t,children:t},t))]}),z(KL,{kind:"color",groups:$("color"),current:F["border-color"],activeDs:k,swatchBg:U["border-color"]||F["border-color"]||"",seedHex:BL(U["border-color"]||F["border-color"])||"#000000",onPick:(t)=>s("border-color",t),label:"border colour"})]}),h0=()=>{let t=F.transform||U7(U.transform)||"",M0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(t),_0=((M0?Number.parseFloat(M0[1]):0)%360+360)%360,f0=(Y8)=>{let m8=(Y8%360+360)%360,e8=(F.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();s("transform",`${e8?`${e8} `:""}rotate(${m8}deg)`.trim())};return D("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[z(yg,{value:_0,onChange:f0}),z(zJ,{value:_0,min:0,max:360,ariaLabel:"rotation",lead:z(K7,{as:oZ}),steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:f0})]})},y0=()=>{let t=F.filter||U7(U.filter)||"",M0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(t),_0=M0?Number.parseFloat(M0[1]):0;return z(zJ,{value:_0,min:0,ariaLabel:"filter blur",unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(Y8)=>{let m8=(F.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();s("filter",Y8>0?`${m8?`${m8} `:""}blur(${Y8}px)`.trim():m8||"none")}})},B8=()=>{let t=F.opacity,M0=t!=null&&t!==""?Number.parseFloat(t):Number.parseFloat(U7(U.opacity))||1,_0=Math.round((Number.isNaN(M0)?1:M0)*100);return z(mX,{value:_0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(f0)=>c("opacity",String(f0/100)),onCommit:(f0)=>s("opacity",String(f0/100))},`opacity:${t??""}`)},D8=()=>{let t=Number.parseInt(F["font-weight"]||U7(U["font-weight"])||"400",10)>=600,M0=(F["font-style"]||U7(U["font-style"]))==="italic",_0=/underline/.test(F["text-decoration"]||U7(U["text-decoration"])||"");return z(Sg,{value:{b:t,i:M0,u:_0},ariaLabel:"text style",options:[{value:"b",node:z(K7,{as:mV}),label:"Bold"},{value:"i",node:z(K7,{as:cV}),label:"Italic"},{value:"u",node:z(K7,{as:Q3}),label:"Underline"}],onToggle:(f0)=>{if(f0==="b")s("font-weight",t?"400":"700");else if(f0==="i")s("font-style",M0?"normal":"italic");else s("text-decoration",_0?"none":"underline")}})},N0=[{value:"row",node:z(K7,{as:vW}),label:"Row"},{value:"column",node:z(K7,{as:fW}),label:"Column"}],o0=[{value:"flex-start",node:z(K7,{as:vV}),label:"Start"},{value:"center",node:z(K7,{as:yV}),label:"Center"},{value:"flex-end",node:z(K7,{as:jV}),label:"End"},{value:"space-between",node:z(K7,{as:PK}),label:"Space between"}],h8=[{value:"flex-start",node:z(K7,{as:hV}),label:"Start"},{value:"center",node:z(K7,{as:fV}),label:"Center"},{value:"flex-end",node:z(K7,{as:xV}),label:"End"},{value:"stretch",node:z(K7,{as:J3}),label:"Stretch"}],g8=[{value:"left",node:z(K7,{as:t5}),label:"Left"},{value:"center",node:z(K7,{as:gW}),label:"Center"},{value:"right",node:z(K7,{as:mW}),label:"Right"},{value:"justify",node:z(K7,{as:uW}),label:"Justify"}],e0=[{value:"visible",node:z(K7,{as:iZ}),label:"Visible"},{value:"hidden",node:z(K7,{as:nZ}),label:"Hidden"},{value:"scroll",node:z(K7,{as:sV}),label:"Scroll"}],a7=(t,M0)=>{let _0=$(M0);return _0.length?z(KL,{kind:"value",groups:_0,current:F[t],activeDs:k,onPick:(f0)=>s(t,f0),label:`${t} design token`}):null},F9=(t)=>{let M0=t.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===M0)M0.select()})},v7=(t,M0)=>{if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return!1;t.preventDefault();let _0=t.shiftKey?10:1,f0=t.key==="ArrowUp"?1:-1,Y8=(Number.parseFloat(t.currentTarget.value)||0)+f0*_0;return t.currentTarget.value=String(Y8),M0(Y8),!0},I8=(t)=>z("input",{className:"st-cp-fin","aria-label":t,defaultValue:F[t]??"",placeholder:U7(U[t])||"—",onFocus:F9,onKeyDown:(M0)=>{if(M0.key==="Enter")M0.currentTarget.blur()},onBlur:(M0)=>s(t,M0.currentTarget.value)},`${t}:${F[t]??""}`),Q9=(t,M0,_0={})=>{let f0=Q4(F[t]??""),Y8=U90.has(t),m8=Y8?"":_0.fixedUnit||(f0.unit&&f0.unit!=="auto"?f0.unit:"px"),e8=Wk[t],y8=Number.parseFloat(Q4(U7(U[t])??"").n)||0,W9=f0.n!==""&&f0.n!=null?Number.parseFloat(f0.n)||0:y8;return D(Q0,{children:[z(zJ,{value:W9,min:_0.min??0,step:1,ariaLabel:t,lead:e8?e8.node??e8.t:void 0,onCommit:(k9)=>s(t,Y8?`${k9}`:`${k9}${m8}`),unitSlot:Y8||_0.fixedUnit?null:z(uN,{units:K90,value:f0.unit||"px",ariaLabel:`${t} unit`,onChange:(k9)=>s(t,k9==="auto"?"auto":`${f0.n||"0"}${k9}`)})},`${t}:${F[t]??""}`),a7(t,M0)]})},c8=(t)=>{let M0=U[t]||F[t]||"",_0=F[t]??"",f0=typeof _0==="string"&&/var\(\s*--/.test(_0),Y8=f0?_0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):_0;return z(W3,{swatch:z(KL,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:$("color"),current:F[t],activeDs:k,swatchBg:M0,seedHex:BL(U[t]||F[t])||"#000000",onPick:(m8)=>s(t,m8),label:`${t} colour`}),displayValue:Y8,bound:f0,ariaLabel:t,onValue:(m8)=>s(t,m8)})},O0=(t,M0)=>{let _0=null,f0=M0.unitless?"":"px",Y8=(y8)=>M0.unitless?`${y8}`:`${y8}${f0}`,m8=(y8,W9,k9)=>{for(let e9 of W9??[t])k9(e9,Y8(y8))},e8=xw({getBase:()=>_0?.value??"0",min:M0.min??0,step:1,sides:M0.sides,onInput:(y8,W9)=>{if(_0)_0.value=String(y8);if(W9){let k9=_0?.closest(".st-cp-box");for(let e9 of W9){if(e9===t)continue;let J7=k9?.querySelector(`.st-cp-boxv[aria-label="${e9}"]`);if(J7)J7.value=String(y8)}}m8(y8,W9,c)},onCommit:(y8,W9)=>m8(y8,W9,s)});return{onPointerDown:(y8)=>{_0=y8.currentTarget,e8(y8)}}},K8=(t,M0)=>{let _0=F[t],f0=_0!=null&&_0!==""?Q4(_0).n||_0:Q4(U7(U[t])??"").n||"0",Y8=!_0||_0==="0"||_0==="0px"||_0==="auto",m8=t.split("-").pop(),e8=m8==="top"||m8==="bottom"?[`${M0}-top`,`${M0}-bottom`]:[`${M0}-left`,`${M0}-right`],y8=[`${M0}-top`,`${M0}-right`,`${M0}-bottom`,`${M0}-left`];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${M0[0]}${t.split("-").pop()[0]}${Y8?" is-zero":""}`,"aria-label":t,defaultValue:f0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...O0(t,{sides:{pair:e8,all:y8}}),onFocus:F9,onKeyDown:(W9)=>{if(v7(W9,(k9)=>s(t,`${k9}px`)))return;if(W9.key==="Enter")W9.currentTarget.blur()},onBlur:(W9)=>{let k9=W9.currentTarget.value.trim();if(!k9)return;let e9=/[a-z%]/i.test(k9)?k9:`${k9}px`;s(t,e9)}},`${t}:${_0??""}`)},C8=(t)=>{let M0=F[t],_0=M0!=null&&M0!==""&&M0!=="auto"?Q4(M0).n||M0:Q4(U7(U[t])??"").n||"",f0=!M0||M0==="auto"||M0==="0"||M0==="0px",Y8=t==="top"||t==="bottom"?["top","bottom"]:["left","right"],m8=["top","right","bottom","left"];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${t[0]}${f0?" is-zero":""}`,"aria-label":t,defaultValue:_0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...O0(t,{sides:{pair:Y8,all:m8},min:-1/0}),onFocus:F9,onKeyDown:(e8)=>{if(v7(e8,(y8)=>s(t,`${y8}px`)))return;if(e8.key==="Enter")e8.currentTarget.blur()},onBlur:(e8)=>{let y8=e8.currentTarget.value.trim();if(!y8)return;let W9=/[a-z%]/i.test(y8)?y8:`${y8}px`;s(t,W9)}},`${t}:${M0??""}`)},V9=Object.entries(M),x9=Object.entries(A),i9=()=>{let t=(J.tag||"").toLowerCase(),_0=t==="img"||t==="video"||t==="picture"||t==="svg"||t==="canvas"||!!F["object-fit"]||!!F["object-position"]||!!F["aspect-ratio"],f0=(t==="img"||t==="video")&&!!J.attrs?.src&&!!W;return{showMedia:_0,canReplace:f0}},h9=(t)=>D(Q0,{children:[t&&z("div",{className:"st-cp-mediabtn",children:z("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>W(J),children:"Replace…"})}),v0("object-fit",r0("object-fit",UL0)),v0("object-position",I8("object-position")),v0("aspect-ratio",D("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:F90.includes(F["aspect-ratio"])?F["aspect-ratio"]:"",onChange:(M0)=>{let _0=M0.target.value;if(s("aspect-ratio",_0),_0&&_0!=="auto"&&F.height)q0("height")},children:[z("option",{value:"",disabled:!0,children:U7(U["aspect-ratio"])||"—"}),F90.map((M0)=>z("option",{value:M0,children:M0},M0))]}))]});return D("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:W8,children:[D("div",{className:"st-cp-id",children:[D("span",{className:"st-cp-idtag",children:[J.tag||"element",J.classes?D("span",{className:"st-cp-idcls",children:[".",J.classes.split(/\s+/)[0]]}):null]}),z("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:z(hw,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:z(K7,{as:jW,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:z(K7,{as:pW,size:12}),label:"Designer — Figma vocabulary"}],onChange:f})})]}),Z==="designer"?D(Q0,{children:[V0("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let t=(F.display||U7(U.display)||"").trim();return t==="flex"||t==="inline-flex"?D(Q0,{children:[v0("flex-direction",X8("flex-direction",N0),void 0,"Direction"),v0("align-items",z(bg,{value:w0(),onChange:C0,ariaLabel:"auto-layout alignment"}),H8("align-items"),"Alignment"),v0("gap",q8("gap","space"),void 0,"Gap"),D("div",{className:"st-cp-modes",children:[E8("width"),E8("height")]}),D("div",{className:"st-cp-box","aria-label":"padding",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[S8(H8("padding-top")),"padding"]}),K8("padding-top","padding"),K8("padding-right","padding"),K8("padding-bottom","padding"),K8("padding-left","padding")]}),z("div",{className:"st-cp-clustermore-row",children:J8("Auto layout")}),h["Auto layout"]?v0("flex-wrap",z(aQ,{checked:/^wrap/.test(F["flex-wrap"]||U7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(_0)=>s("flex-wrap",_0?"wrap":"nowrap")}),H8("flex-wrap"),"Wrap"):null]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>s("display","flex"),children:"+ Auto layout (flex)"})})()),V0("Size",["width","height","min-width","max-width","min-height","max-height"],D(Q0,{children:[v0("width",Q9("width"),void 0,"Width"),v0("height",Q9("height"),void 0,"Height"),z("div",{className:"st-cp-clustermore-row",children:J8("Size")}),h.Size?D(Q0,{children:[v0("min-width",Q9("min-width"),void 0,"Min width"),v0("max-width",Q9("max-width"),void 0,"Max width"),v0("min-height",Q9("min-height"),void 0,"Min height"),v0("max-height",Q9("max-height"),void 0,"Max height")]}):null]})),V0("Position",["position","top","right","bottom","left","z-index"],D(Q0,{children:[v0("position",r0("position",V90),void 0,"Position"),D("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[S8(H8("top")),"inset"]}),C8("top"),C8("right"),C8("bottom"),C8("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||U7(U.position)||"static"})]}),(F.position||U7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,z("div",{className:"st-cp-clustermore-row",children:J8("Position")}),h.Position?v0("z-index",Q9("z-index"),void 0,"Layer order"):null]}),!1),V0("Fill",["background-color"],v0("background-color",c8("background-color"),void 0,"Fill")),V0("Stroke",["border-width","border-style","border-color"],v0("border",d0(),H8("border-width"),"Stroke")),V0("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],v0("border-radius",l0(),H8("border-radius"),"Corner radius")),V0("Effects",["box-shadow","filter","mix-blend-mode"],D(Q0,{children:[v0("box-shadow",a7("box-shadow","shadow")||I8("box-shadow"),void 0,"Shadow"),v0("filter",y0(),H8("filter"),"Blur"),v0("mix-blend-mode",r0("mix-blend-mode",N90),void 0,"Blend")]})),V0("Opacity",["opacity"],v0("opacity",B8(),void 0,"Opacity")),V0("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],D(Q0,{children:[v0("font-family",r0("font-family",H90),void 0,"Font"),v0("color",c8("color"),void 0,"Color"),v0("font-size",q8("font-size","type"),void 0,"Size"),v0("font-weight",r0("font-weight",Z90),void 0,"Weight"),v0("line-height",Q9("line-height","lh"),void 0,"Line height"),v0("text-align",X8("text-align",g8),void 0,"Align"),z("div",{className:"st-cp-clustermore-row",children:J8("Text")}),h.Text?D(Q0,{children:[v0("letter-spacing",Q9("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),v0("font-style",r0("font-style",KL0),void 0,"Style"),v0("text-transform",r0("text-transform",q90),void 0,"Case"),v0("white-space",r0("white-space",B90),void 0,"Whitespace")]}):null]})),V0("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],D("div",{className:"st-cp-box","aria-label":"margin",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[S8(H8("margin-top")),"margin"]}),K8("margin-top","margin"),K8("margin-right","margin"),K8("margin-bottom","margin"),K8("margin-left","margin")]})),(()=>{let{showMedia:t,canReplace:M0}=i9();return t?V0("Media",["object-fit","object-position","aspect-ratio"],h9(M0)):null})()]}):D(Q0,{children:[L8("Layout",(()=>{let t=(F.display||U7(U.display)||"").trim(),M0=t==="flex"||t==="inline-flex",_0=t==="grid"||t==="inline-grid";return D(Q0,{children:[v0("display",r0("display",HL0)),M0?D(Q0,{children:[v0("flex-direction",X8("flex-direction",N0)),v0("flex-wrap",z(aQ,{checked:/^wrap/.test(F["flex-wrap"]||U7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(f0)=>s("flex-wrap",f0?"wrap":"nowrap")}),H8("flex-wrap"))]}):null,M0||_0?D(Q0,{children:[v0("align-items",X8("align-items",h8)),v0("justify-content",X8("justify-content",o0)),v0("gap",q8("gap","space"))]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>s("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let t=(F.display||U7(U.display)||"").trim();if(!(t==="grid"||t==="inline-grid"))return null;let _0=F["grid-template-columns"]||"",f0=F["grid-template-rows"]||"",Y8=EO(_0),m8=EO(f0),e8=Y8.length>0||!_0.trim(),y8=m8.length>0||!f0.trim();return L8("Grid",D(Q0,{children:[e8?z(D90,{label:"Columns",tracks:Y8,editable:K,onChange:(W9)=>s("grid-template-columns",PO(W9))}):D("div",{className:"st-cp-note",children:["Columns use ",z("code",{children:_0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),y8?z(D90,{label:"Rows",tracks:m8,editable:K,onChange:(W9)=>s("grid-template-rows",PO(W9))}):D("div",{className:"st-cp-note",children:["Rows use ",z("code",{children:f0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),L8("Position",D(Q0,{children:[v0("position",r0("position",V90)),D("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[S8(H8("top")),"inset"]}),C8("top"),C8("right"),C8("bottom"),C8("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||U7(U.position)||"static"})]}),(F.position||U7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,v0("z-index",Q9("z-index"))]})),(J.parentDisplay==="grid"||J.parentDisplay==="inline-grid")&&L8("Grid item",D(Q0,{children:[D("div",{className:"st-cp-note",children:["Manual cell placement — ",z("code",{children:"start / end"})," or ",z("code",{children:"start / span N"}),"."]}),v0("grid-column",I8("grid-column")),v0("grid-row",I8("grid-row"))]})),L8("Typography",D(Q0,{children:[v0("font-family",r0("font-family",H90)),v0("color",c8("color")),v0("font-size",q8("font-size","type")),v0("font-weight",r0("font-weight",Z90)),v0("line-height",Q9("line-height","lh")),v0("letter-spacing",Q9("letter-spacing",null,{min:-1/0})),v0("text-align",X8("text-align",g8)),v0("font-style",D8(),H8("font-style")),v0("text-transform",r0("text-transform",q90)),v0("white-space",r0("white-space",B90))]})),L8("Spacing",z(Q0,{children:D("div",{className:"st-cp-box","aria-label":"margin and padding",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[S8(H8("margin-top")),"margin"]}),K8("margin-top","margin"),K8("margin-right","margin"),K8("margin-bottom","margin"),K8("margin-left","margin"),D("div",{className:"st-cp-boxpad",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[S8(H8("padding-top")),"padding"]}),K8("padding-top","padding"),K8("padding-right","padding"),K8("padding-bottom","padding"),K8("padding-left","padding"),D("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(F.width)||J.bounds?.w||0)," × ",Math.round(Number.parseFloat(F.height)||J.bounds?.h||0)]})]})]})})),L8("Size",D(Q0,{children:[D("div",{className:"st-cp-modes",children:[E8("width"),E8("height")]}),v0("width",Q9("width")),v0("height",Q9("height")),v0("min-width",Q9("min-width")),v0("max-width",Q9("max-width")),v0("min-height",Q9("min-height")),v0("max-height",Q9("max-height")),v0("overflow",X8("overflow",e0)),t0?D(Q0,{children:[z("div",{className:"st-cp-subhd",children:"In flex parent"}),v0("align-self",r0("align-self",zL0)),v0("flex-grow",Q9("flex-grow",null,{unitless:!0})),v0("flex-shrink",Q9("flex-shrink",null,{unitless:!0})),v0("flex-basis",Q9("flex-basis"))]}):null]})),(()=>{let{showMedia:t,canReplace:M0}=i9();return t?L8("Media",h9(M0)):null})(),L8("Appearance",D(Q0,{children:[v0("background-color",c8("background-color")),v0("border-radius",l0(),H8("border-radius")),v0("border",d0(),H8("border-width")),v0("box-shadow",a7("box-shadow","shadow")||I8("box-shadow")),v0("filter",y0(),H8("filter")),v0("mix-blend-mode",r0("mix-blend-mode",N90)),v0("opacity",B8()),v0("rotation",h0(),H8("transform")),v0("transform",I8("transform")),v0("transform-origin",I8("transform-origin"))]})),(()=>{let t=Object.entries(C).find(([,M0])=>typeof M0==="string"&&M0.startsWith("err:"));return t?D("div",{className:"st-cp-save is-err",role:"status",children:[z(T9,{name:"x",size:12}),t[0],": ",t[1].slice(4)]}):null})(),L8("Advanced",D("div",{className:"st-cp-advbody",children:[V9.length?D(Q0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),V9.map(([t,M0])=>D("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`custom property ${t} name`}),z("input",{className:"st-cp-fin",defaultValue:M0,"aria-label":`${t} value`,onKeyDown:(_0)=>{if(_0.key==="Enter")_0.currentTarget.blur()},onBlur:(_0)=>z0(t,_0.currentTarget.value)},`cs:${t}:${M0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>Z0(t),children:z(T9,{name:"x",size:11})})]},`cs:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add CSS property"}),z(BL0,{commit:z0}),z("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),x9.length?D(Q0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),x9.map(([t,M0])=>D("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`attribute ${t} name`}),z("input",{className:"st-cp-fin",defaultValue:M0,"aria-label":`${t} value`,onKeyDown:(_0)=>{if(_0.key==="Enter")_0.currentTarget.blur()},onBlur:(_0)=>o(t,_0.currentTarget.value)},`at:${t}:${M0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>k0(t),children:z(T9,{name:"x",size:11})})]},`at:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),z(NL0,{commit:o})]}))]}),D("div",{className:"st-cp-legend",children:[D("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),D("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),D("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},J.id)}function BL0({commit:J}){let[X,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(X.trim()&&Y.trim())J(X.trim(),Y),Q(""),W("")};return D("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom property name",placeholder:"property",value:X,onChange:(Z)=>Q(Z.target.value)}),z("input",{className:"st-cp-fin","aria-label":"custom property value",placeholder:"value",value:Y,onChange:(Z)=>W(Z.target.value),onKeyDown:(Z)=>{if(Z.key==="Enter")G()},onBlur:G})]})}function NL0({commit:J}){let[X,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(X.trim()&&Y.trim())J(X.trim(),Y),Q(""),W("")};return D("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom attribute name",placeholder:"data-…",value:X,onChange:(Z)=>Q(Z.target.value)}),z("input",{className:"st-cp-fin","aria-label":"custom attribute value",placeholder:"value",value:Y,onChange:(Z)=>W(Z.target.value),onKeyDown:(Z)=>{if(Z.key==="Enter")G()},onBlur:G})]})}var FL0={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function LL0(J,X,Q,Y){if(!Array.isArray(J)||X===Q)return J;let W=JSON.parse(JSON.stringify(J)),G=null,Z=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===X)return G=K[U],K.splice(U,1),!0;if(K[U].children&&Z(K[U].children))return!0}return!1};if(Z(W),!G)return J;let H=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===Q){if(Y==="inside-start"||Y==="inside-end")if(K[U].children=K[U].children||[],Y==="inside-start")K[U].children.unshift(G);else K[U].children.push(G);else K.splice(Y==="before"?U:U+1,0,G);return!0}if(K[U].children&&H(K[U].children))return!0}return!1};return H(W)?W:J}var DL0=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function R90({node:J,depth:X,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:V,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:M,onToggleLock:A,onRename:E}){let w=`${J.id}:${J.index}`,O=J.children&&J.children.length>0,I=W.has(w),k=!!J.synthetic,R=!k&&F?F[J.id]:null,$=!k&&!!M?.has(w),[C,j]=u.useState(!1),[x,m]=u.useState(""),d=!k&&J.id===Q&&(Y==null||J.index===Y),a=G?.has(w)?G.get(w):!!J.hidden,f=!!V&&!k&&!$,h=()=>{j(!1);let r=x.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!r||r===(J.dcElement??""))return;E?.(J,r)},p=N?.key===w,v=p?{transform:`translate(${N.dx}px, ${N.dy}px)`,opacity:0.9,zIndex:20,position:"relative",pointerEvents:"none",cursor:"grabbing",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.28)"}:null;return D(Q0,{children:[D("div",{className:"st-layer st-layer--row"+(d?" is-sel":"")+(a?" is-hidden":"")+(k?" is-group":"")+(R?" is-instance":"")+($?" is-locked":""),style:{paddingLeft:6+X*14,...v},role:"treeitem","aria-selected":k?void 0:d,"aria-expanded":O?!I:void 0,"aria-grabbed":f?p:void 0,tabIndex:0,title:k?`${J.tag} · group (unstamped wrapper)`:`${J.tag} · ${J.type}${E?" · F2 to rename":""}`,"data-layer-key":w,onClick:()=>k?O&&Z(w):H(J),onMouseEnter:()=>!k&&K(J),onMouseLeave:()=>K(null),onPointerDown:f?(r)=>B(r,J,w):void 0,onKeyDown:(r)=>{if(r.key==="Enter"||r.key===" ")if(r.preventDefault(),k)O&&Z(w);else H(J);else if(r.key==="F2"&&E&&!k)r.preventDefault(),m(J.dcElement||J.label||""),j(!0)},children:[O?z("button",{type:"button",className:"st-layer-caret","aria-label":I?"Expand":"Collapse",onClick:(r)=>{r.stopPropagation(),Z(w)},children:I?"▸":"▾"}):z("span",{className:"st-layer-caret","aria-hidden":"true"}),R?z("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:R.root?"◆":"◇"}):z(T9,{name:FL0[J.type]||"box",size:12,className:"st-layer-ticon"}),C?z("input",{className:"st-layer-rename",value:x,autoFocus:!0,"aria-label":`Rename ${J.label}`,onFocus:(r)=>r.target.select(),onChange:(r)=>m(r.target.value),onClick:(r)=>r.stopPropagation(),onPointerDown:(r)=>r.stopPropagation(),onBlur:h,onKeyDown:(r)=>{if(r.stopPropagation(),r.key==="Enter")h();else if(r.key==="Escape")j(!1)}}):z("span",{className:"st-layer-label",onDoubleClick:E&&!k?(r)=>{r.stopPropagation(),m(J.dcElement||J.label||""),j(!0)}:void 0,children:J.label}),z("span",{className:"st-layer-type",children:R?R.component:J.type}),A&&!k?z("button",{type:"button",className:"st-layer-lock","aria-label":$?`Unlock ${J.label}`:`Lock ${J.label}`,"aria-pressed":$,title:$?"Unlock":"Lock",onClick:(r)=>{r.stopPropagation(),A(w)},children:z(T9,{name:$?"lock":"unlock",size:12})}):null,U&&!k?z("button",{type:"button",className:"st-layer-eye","aria-label":a?`Show ${J.label}`:`Hide ${J.label}`,"aria-pressed":a,title:a?"Show":"Hide",onClick:(r)=>{r.stopPropagation(),U(J)},children:z(T9,{name:a?"eye-off":"eye",size:13})}):null]}),O&&!I?J.children.map((r,e)=>z(R90,{node:r,depth:X+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:V,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:M,onToggleLock:A,onRename:E},`${r.id}:${r.index}`)):null]})}function ML0({el:J}){let X=J?.computed||{},Q=J?.authored||{},Y=(U)=>{let V=Q[U];if(V&&/var\(\s*--/.test(V))return V.replace(/^var\(\s*|\s*\)$/g,"");return X[U]||V||""},W=(U,V)=>{let B=X[V]||Q[V];if(!B)return null;return D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:U}),D("div",{className:"st-swatch-row",children:[z("span",{className:"st-insp-swatch",style:{background:B},"aria-hidden":"true"}),z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Y(V)})]})]},U)},G=X["border-radius"]&&X["border-radius"]!=="0px",Z=G?Q4(X["border-radius"]).n||X["border-radius"]:null,H=X["font-size"]||X["font-weight"]?[X["font-size"],X["font-weight"]].filter(Boolean).join(" / "):null;if(!(X["background-color"]||X.color||G||H))return null;return D(Q0,{children:[G?D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Radius"}),D("div",{className:"st-insp-fields",children:[D("span",{className:"st-fmini",style:{flex:"0 0 auto",maxWidth:84},children:[z("span",{className:"st-mtag",children:"r"}),z("input",{value:Z,readOnly:!0,"aria-label":"border radius"})]}),z("span",{className:"st-insp-unit",children:"px"})]})]}):null,W("Fill","background-color"),W("Text","color"),H?D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Font"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:H})})]}):null]})}function C90(J){if(J.artboardId)return J.artboardId;let X=/^\[data-dc-screen="([^"]+)"\]$/.exec(J.selector||"");return X?X[1]:null}var OL0=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],AL0=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function _L0({el:J,cfg:X,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let K=C90(J),U=(X?.designRel||X?.designRoot||".design").replace(/^\/+|\/+$/g,""),V=I90(J.file,X),B=T90(X,U,V),N=(v)=>B.map((r)=>({ds:r.name,names:r[v]||[],vals:r.vals})).filter((r)=>r.names.length),F=(v)=>N(v).flatMap((r)=>(r.names||[]).map((e)=>({name:e,value:r.vals?.[e]||""}))),M=(v)=>{let r=/^var\(\s*(--[\w-]+)\s*\)$/.exec(v||"");if(!r)return v||"";for(let e of B){let c=e.vals?.[r[1]];if(c)return c}return""},A=Number.isFinite(J.worldW)?J.worldW:Number.isFinite(J.bounds?.w)?J.bounds.w:null,E=Number.isFinite(J.worldH)?J.worldH:Number.isFinite(J.bounds?.h)?J.bounds.h:null,w=(v,r)=>{if(!K)return;let e=Number.isFinite(v)&&v>0?Math.round(v):void 0,c=Number.isFinite(r)&&r>0?Math.round(r):void 0;if(e==null&&c==null)return;Q?.(K,e,c)},O=Object.entries(b5).find(([,v])=>v.width===A&&v.height===E)?.[0],I=Object.entries(b5).find(([,v])=>v.width===A)?.[0],k=J.attrs?.["data-dc-fixed"]==="true",R=J.attrs?.["data-dc-bg"]??"",$=J.attrs?.["data-dc-padding"]??"",C=J.attrs?.["data-dc-layout"]??"",j=J.attrs?.["data-dc-gap"]??"",x=J.attrs?.["data-dc-kind"]||"digital",m=null;try{m=J.attrs?.["data-dc-print"]?JSON.parse(J.attrs["data-dc-print"]):null}catch{}let d=(v)=>{if(!K)return;let r=null;if(v==="print"&&!m){let e={paper:"a4"};try{let c=a2(e);if(c)r={defaults:e,widthPx:c.widthPx,heightPx:c.heightPx}}catch{}}if(G?.(K,v==="digital"?null:v,r),v==="web"&&k)Y?.(K,!1,void 0)},a=(v)=>{if(!K)return;let r={paper:"a4",...m,...v},e;try{e=a2(r)}catch{return}Q?.(K,e.widthPx,e.heightPx),Z?.(K,r)},f=(v,r)=>{if(!K)return;let e=Number.isFinite(r)?r:E,c=v&&Number.isFinite(e)?Math.round(e):void 0;Y?.(K,v,c)},h=(v)=>{let r=Cb(k,v);if(r.kind==="resize")w(null,r.height);else if(r.kind==="promote-to-fixed")f(!0,r.height)},p=(v)=>{if(!K)return;W?.(K,v)};return D("section",{className:"st-cp-sec",children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Artboard"})}),D("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[z(zJ,{value:A??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(v)=>w(v,null)}),z(zJ,{value:E??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:k,onCommit:h})]}),z("div",{style:{padding:"0 12px 8px"},children:x==="print"?D("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:m?.paper??"",onChange:(v)=>a({paper:v.currentTarget.value}),children:[z("option",{value:"",disabled:!0,children:"Paper size…"}),r2.map((v)=>D("option",{value:v.id,children:[v.label," — ",v.width,"×",v.height,v.unit]},v.id))]}):x==="web"?D("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:I??"",onChange:(v)=>{let r=b5[v.currentTarget.value];if(r)w(r.width,null)},children:[z("option",{value:"",disabled:!0,children:I?`${b5[I].label} — ≤ ${b5[I].width}px`:"Breakpoint…"}),Object.entries(b5).map(([v,r])=>D("option",{value:v,children:[r.label," — ≤ ",r.width,"px breakpoint"]},v))]}):D("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:O??"",onChange:(v)=>{let r=b5[v.currentTarget.value];if(r)w(r.width,r.height)},children:[z("option",{value:"",disabled:!0,children:O?b5[O].label:"Preset size…"}),Object.entries(b5).map(([v,r])=>D("option",{value:v,children:[r.label," — ",r.width,"×",r.height]},v))]})}),z("div",{style:{padding:"0 12px 8px"},children:z(pN,{value:k?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(v)=>f(v==="fixed")})}),z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Kind"})}),z("div",{style:{padding:"0 12px 8px"},children:z(cW,{value:x,ariaLabel:"artboard kind",options:AL0.map(([v,r])=>({value:v,label:r})),onChange:d})}),x!=="print"&&K&&H?z("div",{style:{padding:"0 12px 8px"},children:D("select",{className:"st-cp-nsel","aria-label":"duplicate artboard at breakpoint width",value:"",onChange:(v)=>{let r=b5[v.currentTarget.value];if(r)H(K,r.width);v.currentTarget.value=""},children:[z("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(b5).map(([v,r])=>D("option",{value:v,children:[r.label," — ",r.width,"px"]},v))]})}):null,x==="print"?D(Q0,{children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Print"})}),z("div",{style:{padding:"0 12px 8px"},children:z(pN,{value:m?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(v)=>a({orientation:v})})}),z("div",{style:{padding:"0 12px 8px"},children:z(zJ,{value:Number.isFinite(m?.bleedMm)?m.bleedMm:3,min:0,step:0.5,ariaLabel:"bleed, millimeters",lead:"B",steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"mm"}),onCommit:(v)=>a({bleedMm:v})})})]}):null,z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Style"})}),D("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let v=M(R),r=/var\(\s*--/.test(R),e=r?R.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):R;return z(W3,{swatch:z(KL,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:N("color"),current:R,activeDs:V,swatchBg:v,seedHex:BL(v)||"#000000",onPick:(c)=>p({background:c||null}),label:"artboard background colour"}),displayValue:e,bound:r,ariaLabel:"artboard background",onValue:(c)=>p({background:(c||"").trim()||null})})})(),z(cW,{value:C,ariaLabel:"artboard body layout",options:OL0.map(([v,r])=>({value:v,label:r})),onChange:(v)=>p({layout:v||null})}),D("div",{style:{display:"flex",gap:8},children:[z(lN,{value:/^var\(/.test($)?$:Number.parseFloat($)||0,tokens:F("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(v)=>p({padding:typeof v==="string"?v:v>0?v:null})}),z(lN,{value:/^var\(/.test(j)?j:Number.parseFloat(j)||0,tokens:F("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(v)=>p({gap:typeof v==="string"?v:v>0?v:null})})]})]})]})}var Hk=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,wL0=new RegExp(Hk.source,"gi");function EL0(J){if(!J||Array.isArray(J))return null;if(J.photoAsset)return J.photoAsset;let X=J.html||"";if((J.tag||"").toLowerCase()!=="img"){let W=[...new Set(X.match(wL0)||[])],G=[...new Set([...X.matchAll(/data-photo-asset="([^"]+)"/g)].map((Z)=>Z[1]))];if(G.length===1)return G[0];if(G.length===0&&W.length===1&&/<img/i.test(X))return W[0];return null}let Q=/data-photo-asset="([^"]+)"/.exec(X);if(Q)return Q[1];let Y=Hk.exec(`${J.attrs?.src||""} ${X}`);return Y?Y[0]:null}function PL0({testId:J,selected:X,onClose:Q,layersTree:Y,componentMap:W,lockedKeys:G,onToggleLock:Z,onDetachInstance:H,canvasFile:K,onSelectLayer:U,onHoverLayer:V,onReorderLayer:B,layersBusyRef:N,cfg:F,onOptimistic:M,onRecordEdit:A,onReplaceMedia:E,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:I,onSetArtboardKind:k,onSetArtboardPrint:R,onDuplicateArtboard:$,onUndoRedo:C,editScope:j,tab:x,onTabChange:m,width:d,resizing:a,photoSel:f,photoRev:h,onPhotoEdit:p,onPhotoRemoveBackground:v,onPhotoRecordEdit:r,onPhotoUndoRedo:e,layersOnly:c=!1,hideLayersTab:K0=!1,cpMode:s,onSetCpMode:z0}){let[o,q0]=u.useState("inspect"),Z0=c?"layers":x??o,k0=(l0)=>{q0(l0),m?.(l0)},[a0,s0]=u.useState(()=>new Set),[t0,E8]=u.useState(()=>new Map);u.useEffect(()=>{let l0=Array.isArray(X)?X[0]:X,d0=l0?.id;if(!d0||!Y?.nodes)return;let h0=l0.index,y0=null,B8=[];if(function D8(N0,o0){for(let h8 of N0||[]){let g8=`${h8.id}:${h8.index}`;if(!h8.synthetic&&h8.id===d0&&(h0==null||h8.index===h0))return y0=g8,B8.push(...o0),!0;if(h8.children&&h8.children.length&&D8(h8.children,[...o0,g8]))return!0}return!1}(Y.nodes,[]),!y0)return;if(B8.length)s0((D8)=>{let N0=!1,o0=new Set(D8);for(let h8 of B8)if(o0.delete(h8))N0=!0;return N0?o0:D8});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${y0}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[X,Y]);let a8=(l0)=>{let d0=`${l0.id}:${l0.index}`;return t0.has(d0)?t0.get(d0):!!l0.hidden},[F8,T8]=u.useState(null),[I0,w0]=u.useState(""),C0=(l0,d0)=>{if(!K||!l0?.id)return;fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:K,id:l0.id,attr:"data-dc-element",value:d0})}).then((h0)=>h0.json().catch(()=>({}))).then((h0)=>{if(!h0.ok)return;A?.({op:"attr",canvas:K,id:l0.id,key:"data-dc-element",before:l0.dcElement??null,after:d0})}).catch(()=>{})},W8=B?(l0,d0,h0)=>{if(N?.current)return;if(l0?.synthetic||d0?.synthetic)return;let y0=h0==="before"?`before ${d0.label}`:h0==="after"?`after ${d0.label}`:`into ${d0.label}`;w0(`Moved ${l0.label} ${y0}`),B(l0.id,d0.id,h0,{idIndex:l0.index,refIndex:d0.index})}:void 0,H8=()=>{let l0=[];return function d0(h0,y0,B8){(h0||[]).forEach((D8,N0)=>{if(l0.push({node:D8,depth:y0,parentNode:B8,siblings:h0,pos:N0}),D8.children&&D8.children.length&&!a0.has(`${D8.id}:${D8.index}`))d0(D8.children,y0+1,D8)})}(Y?.nodes,0,null),l0},x8=(l0)=>{if(l0.key!=="ArrowUp"&&l0.key!=="ArrowDown")return;if(!L8)return;let d0=H8(),h0=d0.findIndex((N0)=>N0.node.id===L8.id&&N0.node.index===L8.index);if(h0<0)return;let y0=l0.key==="ArrowDown"?1:-1,B8=d0[h0];if(!l0.altKey){let N0=d0[h0+y0];if(N0)l0.preventDefault(),U?.(N0.node);return}if(!W8||!Array.isArray(B8.siblings))return;l0.preventDefault();let D8=(N0)=>N0&&N0.children&&N0.children.length&&!a0.has(`${N0.id}:${N0.index}`);if(!l0.shiftKey){if(y0<0&&B8.pos>0)W8(B8.node,B8.siblings[B8.pos-1],"before");else if(y0>0&&B8.pos<B8.siblings.length-1)W8(B8.node,B8.siblings[B8.pos+1],"after");return}if(y0>0){let N0=B8.siblings[B8.pos+1];if(N0)W8(B8.node,N0,D8(N0)?"inside-start":"after");else if(B8.parentNode)W8(B8.node,B8.parentNode,"after")}else{let N0=B8.siblings[B8.pos-1];if(N0)W8(B8.node,N0,D8(N0)?"inside-end":"before");else if(B8.parentNode)W8(B8.node,B8.parentNode,"before")}},S8=u.useRef(null),O9=u.useRef(null),v0=(l0,d0,h0)=>{if(!W8||l0.button!==0||l0.metaKey||l0.ctrlKey||l0.shiftKey||l0.altKey)return;if(N?.current)return;let{clientX:y0,clientY:B8}=l0,D8=new Set([h0]);(function c8(O0){(O0.children||[]).forEach((K8)=>{D8.add(`${K8.id}:${K8.index}`),c8(K8)})})(d0);let N0=14,o0=6,h8=[];(function c8(O0,K8){(O0||[]).forEach((C8)=>{let V9=`${C8.id}:${C8.index}`;if(h8.push({node:C8,key:V9,id:C8.id,depth:K8,tag:C8.tag}),C8.children&&C8.children.length&&!a0.has(V9))c8(C8.children,K8+1)})})(Y?.nodes,0);let g8=new Map(h8.map((c8)=>[c8.key,c8])),e0=!1,a7=(c8)=>{if(!e0){if(Math.hypot(c8.clientX-y0,c8.clientY-B8)<4)return;e0=!0}let O0=c8.clientX-y0,K8=c8.clientY-B8,C8=null,V9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((i9)=>({rect:i9.getBoundingClientRect(),it:g8.get(i9.getAttribute("data-layer-key"))})).filter((i9)=>i9.it&&i9.it.key!==h0);if(V9.length){let i9=V9[0].rect.left,h9=V9[0].rect.right,t=V9.length;for(let e9=0;e9<V9.length;e9++)if(c8.clientY<V9[e9].rect.top+V9[e9].rect.height/2){t=e9;break}let M0=V9[t-1]?.it||null,_0=V9[t]?.it||null,f0=Math.round((c8.clientX-i9-o0)/N0),Y8=M0?M0.depth+(DL0.has(M0.tag)?0:1):0,m8=_0?_0.depth:0,e8=Math.max(m8,Math.min(f0,Y8)),y8=null,W9="before",k9=0;if(!M0){if(_0)y8=_0,W9="before",k9=_0.depth}else if(e8>M0.depth)y8=M0,W9="inside-start",k9=M0.depth+1;else if(e8===M0.depth)y8=M0,W9="after",k9=M0.depth;else{for(let e9=t-1;e9>=0;e9--)if(V9[e9].it.depth===e8){y8=V9[e9].it;break}if(!y8)y8=M0;W9="after",k9=e8}if(y8&&y8.key!==h0&&!D8.has(y8.key)){let e9=M0?V9[t-1].rect.bottom:V9[0].rect.top,J7=i9+o0+k9*N0;C8={refId:y8.id,position:W9,node:y8.node,y:e9,left:J7,w:Math.max(24,h9-J7)}}}let x9={key:h0,node:d0,dx:O0,dy:K8,target:C8};S8.current=x9,T8(x9)},F9=()=>{window.removeEventListener("pointermove",a7),window.removeEventListener("pointerup",I8),window.removeEventListener("keydown",Q9,!0)},v7=()=>{let c8=(O0)=>{O0.preventDefault(),O0.stopImmediatePropagation(),document.removeEventListener("click",c8,!0)};document.addEventListener("click",c8,!0),setTimeout(()=>document.removeEventListener("click",c8,!0),300)},I8=()=>{F9();let c8=S8.current;if(S8.current=null,T8(null),e0&&c8?.target)v7(),W8(c8.node,c8.target.node,c8.target.position)},Q9=(c8)=>{if(c8.key!=="Escape")return;if(c8.preventDefault(),c8.stopImmediatePropagation(),F9(),S8.current=null,T8(null),e0)v7()};window.addEventListener("pointermove",a7),window.addEventListener("pointerup",I8),window.addEventListener("keydown",Q9,!0)},$8=(l0)=>s0((d0)=>{let h0=new Set(d0);if(h0.has(l0))h0.delete(l0);else h0.add(l0);return h0}),w9=(l0)=>{let d0=`${l0.id}:${l0.index}`,h0=a8(l0),y0=!h0;if(E8((B8)=>new Map(B8).set(d0,y0)),M?.({id:l0.id,artboardId:Y?.artboardId??null,index:l0.index,prop:"display",value:y0?"none":null}),!K||!l0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(y0?{canvas:K,id:l0.id,property:"display",value:"none"}:{canvas:K,id:l0.id,property:"display",reset:!0})}).catch(()=>{}),A?.({op:"css",canvas:K,id:l0.id,key:"display",before:h0?"none":null,after:y0?"none":null})},L8=Array.isArray(X)?X[0]:X,V0=f?{asset:f.asset,kind:"annotation-image"}:(()=>{let l0=EL0(L8);return l0?{asset:l0,kind:"artboard-img"}:null})(),J8=V0?.kind==="annotation-image",r0=(l0)=>{if(!(l0.metaKey||l0.ctrlKey)||l0.altKey)return;let d0=l0.key.toLowerCase();if(d0==="z")l0.preventDefault(),e?.(l0.shiftKey?"redo":"undo");else if(d0==="y")l0.preventDefault(),e?.("redo")},b0=J8?"photo":Z0==="photo"&&!V0?"css":Z0,X8=(l0,d0,h0)=>D("button",{type:"button",className:"st-rp-tab"+(b0===l0?" is-active":""),onClick:()=>k0(l0),children:[z(T9,{name:h0,size:14}),d0]}),q8=L8?.bounds||null;return D("aside",{className:"st-rpanel"+(a?" is-resizing":""),style:d?{width:d,flexBasis:d}:void 0,"aria-label":"Inspector","data-tour":"inspector","data-testid":J,children:[D("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:c?{display:"none"}:void 0,children:[J8?X8("photo","Photo","image"):D(Q0,{children:[X8("inspect","Inspect","sliders"),!K0&&X8("layers","Layers","layers"),X8("css","CSS","code"),V0?X8("photo","Photo","image"):null]}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:Q,children:z(T9,{name:"x",size:14})})]}),L8?.id&&!(Array.isArray(X)&&X.length>1)&&j?D("div",{className:`st-scope st-scope--${j.scope}`,title:j.scope==="shared"?`Editing this element's style changes ${j.affects} place${j.affects===1?"":"s"}${j.componentName?` (component ${j.componentName})`:""}. Move/resize a whole instance to keep it local.`:"This edit affects only this element.",children:[z("span",{className:"st-scope-dot","aria-hidden":"true"}),j.scope==="shared"?`Shared${j.componentName?` · ${j.componentName}`:""} · edits ${j.affects} place${j.affects===1?"":"s"}`:"Local · this element only",j.scope==="shared"&&H?z("button",{type:"button",className:"st-scope-detach",title:"Clone this component for this instance only — edits stop affecting the other places",onClick:()=>H(L8.id,L8.index),children:"Detach"}):null]}):null,z("div",{className:"st-rp-body",children:b0==="photo"&&V0?z("div",{onKeyDown:r0,children:z(Gm,{asset:V0.asset,ColorPicker:k90,StIcon:T9,onEdit:(l0)=>p?.(V0.asset,l0),onRemoveBackground:v,onRecordEdit:(l0,d0)=>r?.(V0.asset,l0,d0)},`${V0.asset}:${h??0}`)}):!L8&&!(b0==="layers"&&Y?.nodes?.length)?z("div",{className:"st-rp-empty",children:D("p",{children:["Press ",z(CJ,{children:"V"}),", then click an element to select it — or ",z(CJ,{children:"⌘"}),"-click straight from Browse."]})}):L8&&b0==="inspect"?D(Q0,{children:[z("div",{className:"st-rp-hd",children:L8.selector||L8.tag||"element"}),D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Pos"}),D("div",{className:"st-insp-fields",children:[D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"X"}),z("input",{value:q8?Math.round(q8.x):"—",readOnly:!0,"aria-label":"x position"})]}),D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"Y"}),z("input",{value:q8?Math.round(q8.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Size"}),D("div",{className:"st-insp-fields",children:[D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"W"}),z("input",{value:q8?Math.round(q8.w):"—",readOnly:!0,"aria-label":"width"})]}),D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"H"}),z("input",{value:q8?Math.round(q8.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Tag"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:L8.tag||"—"})})]}),L8.classes?D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Class"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:L8.classes})})]}):null,z(ML0,{el:L8})]}):b0==="layers"?D(Q0,{children:[D("div",{className:"st-rp-hd",children:["Layers",Y?.nodes?.length?"":" · ancestry"]}),Y?.nodes?.length?D(Q0,{children:[W8?z("div",{className:"st-rp-hint","aria-hidden":"true",children:"Drag or ↑/↓ select · Alt+↑/↓ move · Alt+Shift+↑/↓ move across"}):null,z("div",{role:"tree","aria-label":"Artboard layers",tabIndex:0,ref:O9,onKeyDown:x8,children:Y.nodes.map((l0,d0)=>z(R90,{node:l0,depth:0,selectedId:L8?.id,selectedIndex:L8?.index,collapsed:a0,hiddenOverride:t0,onToggle:$8,onSelect:(h0)=>{U?.(h0),O9.current?.focus()},onHover:(h0)=>V?.(h0),onToggleVisibility:w9,onReorder:W8,onRowPointerDown:v0,dragState:F8,componentMap:W,lockedKeys:G,onToggleLock:Z,onRename:C0},`${l0.id}:${l0.index}`))}),F8?.target?z("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:F8.target.left,top:F8.target.y-1,width:F8.target.w}}):null,z("div",{className:"sr-only",role:"status","aria-live":"polite",children:I0})]}):L8&&Array.isArray(L8.dom_path)&&L8.dom_path.length?L8.dom_path.map((l0,d0)=>D("div",{className:"st-layer"+(d0===L8.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+d0*12},children:[z(T9,{name:"square",size:13}),l0]},d0)):z("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!L8.id&&C90(L8)?z(_L0,{el:L8,cfg:F,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:I,onSetArtboardKind:k,onSetArtboardPrint:R,onDuplicateArtboard:$}):z(qL0,{el:L8,cfg:F,onOptimistic:M,onRecordEdit:A,onReplaceMedia:E,onUndoRedo:C,mode:s,onSetMode:z0})})]})}function IL0(){let[J,X]=u.useState([]),[Q,Y]=u.useState(!1),W=u.useRef("push"),G=u.useRef(null),[Z,H]=u.useState("Design"),[K,U]=u.useState([]),[V,B]=u.useState(null),[N,F]=u.useState(null),M=u.useCallback((b)=>{W.current="push",F(b)},[]),[A,E]=u.useState(null),w=u.useRef(null);u.useEffect(()=>{w.current=A},[A]);let[O,I]=u.useState(null);u.useEffect(()=>{let b=Array.isArray(A)?A.length===1?A[0]:null:A,S=b&&typeof b.id==="string"?b.id:null;if(!S||!V){I(null);return}let i=new AbortController,X0=new URLSearchParams({canvas:V,id:S});return fetch(`/_api/edit-scope?${X0}`,{signal:i.signal}).then((H0)=>H0.ok?H0.json():null).then((H0)=>{if(H0?.ok)I(H0)}).catch(()=>{}),()=>i.abort()},[A,V]);let k=u.useRef(0),R=u.useRef([]),$=u.useCallback((b)=>{if(!b?.id||!b.file)return;for(let S of R.current)clearTimeout(S);R.current=[50,450,1200,2500,5000].map((S)=>setTimeout(()=>{let i=w.current,X0=Array.isArray(i)?i[0]:i;if(!X0||X0.id!==b.id||X0.file!==b.file)return;let H0=i8.current.get(b.file);if(!H0?.contentWindow)return;try{H0.contentWindow.postMessage({dgn:"select-by-id",id:b.id,artboardId:b.artboardId??null,index:b.index??0},"*")}catch{}},S))},[]),C=u.useRef([]),j=u.useCallback((b,S)=>{if(!b||!S)return;for(let i of C.current)clearTimeout(i);C.current=[50,450,1200,2500,5000].map((i)=>setTimeout(()=>{let X0=w.current,H0=Array.isArray(X0)?X0[0]:X0;if(!H0||H0.artboardId!==b||H0.file!==S)return;let F0=i8.current.get(S);if(!F0?.contentWindow)return;try{F0.contentWindow.postMessage({dgn:"select-by-id",artboardId:b},"*")}catch{}},i))},[]),x=u.useRef(null),m=u.useRef(null),d=u.useRef(null);d.current=(b,S,i)=>{let X0=x.current;if(!X0||!X0.movedId)return;if(X0.staleSig!=null&&S===X0.staleSig)return;if(!function A0(l){return(l||[]).some((D0)=>D0.id===X0.movedId||A0(D0.children))}(b))return;x.current=null;let F0=V?i8.current.get(V)?.contentWindow:null;if(F0)try{F0.postMessage({dgn:"select-by-id",id:X0.movedId,artboardId:i,index:0},"*")}catch{}};let a=u.useRef(null),f=u.useRef(null),h=u.useRef(null),p=u.useRef(!1),v=u.useRef(null),[r,e]=u.useState(null),[c,K0]=u.useState(null),s=u.useRef({canvas:null,at:0});u.useEffect(()=>{if(!V||!r)return;let b=Date.now(),S=s.current;if(S.canvas===V&&b-S.at<1500)return;s.current={canvas:V,at:b},fetch(`/_api/component-map?canvas=${encodeURIComponent(V)}`).then((i)=>i.json()).then((i)=>{if(i?.ok&&i.map&&typeof i.map==="object")K0(i.map);else K0(null)}).catch(()=>K0(null))},[V,r]);let[z0,o]=u.useState(!1),[q0,Z0]=u.useState(null),[k0,a0]=u.useState(null),s0=u.useRef(null);u.useEffect(()=>{let b=k0?.files?.progress;if(!b)return;let S=s0.current;if(s0.current=b.phase,S===null||S===b.phase)return;if(b.phase==="converged"&&(S==="seeding"||S==="paused"))WL("Project synced",`${b.delivered} files are up to date.`);else if(b.phase==="blocked"){let i=(b.blocked??[]).reduce((X0,H0)=>X0+H0.count,0);WL("Sync needs a decision",`${i} file${i===1?"":"s"} could not be sent. Open the Sync panel for the reason.`)}},[k0?.files?.progress]),u.useEffect(()=>{if(typeof document>"u")return;let b=k0?.files?.progress,S=document.title.replace(/\s+—\s+syncing\s+\d+\/\d+$/,"");if(b&&(b.phase==="seeding"||b.phase==="paused")&&b.tracked>0)document.title=`${S} — syncing ${b.delivered}/${b.tracked}`;else document.title=S;return},[k0?.files?.progress]);let[t0,E8]=u.useState(null),[a8,F8]=u.useState(null),[T8,I0]=u.useState(null),[w0,C0]=u.useState(null),[W8,H8]=u.useState(!1),[x8,S8]=u.useState(!1),[O9,v0]=u.useState(null),[$8,w9]=u.useState(""),[L8,V0]=u.useState(null),[J8,r0]=u.useState(null),b0=u.useRef(null),[X8,q8]=u.useState(null),[l0,d0]=u.useState(0),[h0,y0]=u.useState(null),B8=e80("maude-sb-w",{min:200,max:420,def:252}),D8=e80("maude-rp-w",{min:260,max:480,def:304}),[N0,o0]=u.useState(null),h8=u.useRef(null);u.useEffect(()=>{if(!N0)return;let b=(i)=>{let X0=h8.current?.getBoundingClientRect();if(!X0)return;if(N0==="sb")B8.setW(i.clientX-X0.left);else D8.setW(X0.right-i.clientX)},S=()=>o0(null);return window.addEventListener("pointermove",b),window.addEventListener("pointerup",S),()=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",S)}},[N0,B8.setW,D8.setW]);let g8=u.useCallback((b)=>{clearTimeout(b0.current),b0.current=setTimeout(()=>{r0((S)=>S===b?null:S)},2500)},[]),[e0,a7]=u.useState({designRel:".design",cloud:void 0});u.useEffect(()=>{if(!J8)return;let b=J8,S=setTimeout(async()=>{let i="compile";try{if(!(await fetch(`${e0?.canvasOrigin||""}/_health`,{cache:"no-store"})).ok)i="server"}catch{i="server"}q8({path:b,kind:i}),r0((X0)=>X0===b?null:X0)},15000);return()=>clearTimeout(S)},[J8,e0?.canvasOrigin]);let F9=!!e0.cloud,v7=!e0.cloud&&!!t0?.credentialed,I8=F9||v7,Q9=I8?0:T8?.files?.length||0,c8=u.useRef(I8);c8.current=I8;let O0=!!e0.readOnly,K8=u.useCallback(()=>{fetch("/_config").then((b)=>b.json()).then((b)=>{let S=(b.designRoot||".design").replace(/^\/+|\/+$/g,"");a7((i)=>({...i,designRel:S,tokensCssRel:b.tokensCssRel,designSystems:b.designSystems,canvasOrigin:b.canvasOrigin,readOnly:!!b.readOnly,canvasToken:b.canvasToken,version:b.version,cloud:b.cloud??null,exportLane:b.exportLane}))}).catch(()=>{})},[]);u.useEffect(()=>{K8()},[K8]),u.useEffect(()=>{let b=!1;return fetch("/_sync-status").then((S)=>S.json()).then((S)=>{if(b||!S||S.linked===!1)return;a0(S)}).catch(()=>{}),()=>{b=!0}},[]),u.useEffect(()=>{if(I8){I0(null);return}let b=!1;return fetch("/_api/git/status").then((S)=>S.json()).then((S)=>{if(!b&&S)I0(S)}).catch(()=>{}),()=>{b=!0}},[I8]);let[C8,V9]=u.useState({}),[x9,i9]=u.useState(null),[h9,t]=u.useState(!1),[M0,_0]=u.useState("open"),[f0,Y8]=u.useState(qF0),[m8,e8]=u.useState(()=>{return Xk(l80,"advanced")==="designer"?"designer":"advanced"});u.useEffect(()=>{try{localStorage.setItem(l80,JSON.stringify(m8))}catch{}},[m8]);let[y8,W9]=u.useState(null),[k9,e9]=u.useState(()=>IH(d80,!0)),[J7,DQ]=u.useState(()=>IH(u80,!1)),[rX,BJ]=u.useState(()=>Xk(p80,{})),[iJ,oJ]=u.useState(!1),[e7,W4]=u.useState(!1);u.useEffect(()=>{if(!G9())return;let b=Yh(()=>W4(!0));return()=>{b.then((S)=>S()).catch(()=>{})}},[]);let[R7,FX]=u.useState(!1),[j9,qY]=u.useState(!1),[p7,j5]=u.useState(!1),[HG,f7]=u.useState(!1),[BY,LX]=u.useState(!1),{report:V7}=yw(G9()),[nJ,l9]=u.useState(!1),[q7,z6]=u.useState(!1),[$J,v5]=u.useState(null),[MQ,P6]=u.useState(null),[G4,OQ]=u.useState(!1),[zG,SJ]=u.useState(!1),[bJ,rJ]=u.useState(!1),[f5,Z4]=u.useState(!1),[NJ,H4]=u.useState(()=>Xk(n80,sK)),[n,W0]=u.useState(()=>{try{let b=localStorage.getItem(r80);if(b==="separate"||b==="in-inspector")return b}catch{}return"separate"}),[L0,j0]=u.useState(!1),[E0,z8]=u.useState([]),[O8,Z9]=u.useState(0),[L9,I6]=u.useState(!1),[AQ,s6]=u.useState(!1),[FJ,x5]=u.useState(!1),[TH,KG]=u.useState(1),[yJ,C7]=u.useState(216),[R9,DX]=u.useState(null),[K6,t8]=u.useState([]),[J6,x6]=u.useState([]),[MX,_Q]=u.useState([]),[aX,kH]=u.useState(0),OX=u.useRef(0);u.useEffect(()=>{OX.current=O8},[O8]);let[X6,RH]=u.useState(null),AX=u.useRef(null);u.useEffect(()=>{AX.current=X6},[X6]);let T6=u.useMemo(()=>mw(E0,{artboardId:[X6,R9],total:aX}),[E0,X6,R9,aX]),sX=u.useRef(null);u.useEffect(()=>{sX.current=T6},[T6]);let NY=u.useMemo(()=>TK(E0,T6)?.fps||30,[E0,T6]),[CH,FY]=u.useState(null),[LY,X1]=u.useState(0),LJ=u.useCallback((b,S)=>{if(/concurrent edit|changed since it was read/i.test(S||""))f8("Timeline changed — reloaded, try again."),X1((i)=>i+1);else f8(`${b}: ${S||"failed"}`)},[]),[_X,UG]=u.useState(!1),[Q1,$H]=u.useState(!1),[Y1,VG]=u.useState(!1),qG=u.useRef(_X);u.useEffect(()=>{if(qG.current=_X,_X){VG(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[_X]);let SH=u.useCallback(()=>{if(!qG.current||document.hidden)VG(!0),WL("Claude finished","Your assistant turn is ready in Maude.")},[]),bH=u.useRef(0),DY=u.useCallback(()=>{if(!qG.current||document.hidden){VG(!0);let b=Date.now();if(b-bH.current<zF0)return;bH.current=b,WL("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[h5,tX]=u.useState("inspect"),[BG,MY]=u.useState(null),wQ=u.useRef({undo:[],redo:[]}),[NG,FG]=u.useState(0),[U6,LG]=u.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),OY=u.useRef(U6);u.useEffect(()=>{OY.current=U6;try{localStorage.setItem("maude-auto-open-inspector",U6?"1":"0")}catch{}},[U6]);let yH=u.useRef(!1);u.useEffect(()=>{yH.current=bJ||h9||W8||x8||_X},[bJ,h9,W8,x8,_X]);let DG=u.useRef({open:{},side:sK});DG.current={open:{tree:k9,layers:f5,inspector:bJ,comments:h9,changes:W8,sync:x8,assistant:_X},side:NJ};let z4=u.useCallback((b,S)=>{if(b==="tree")e9(S);else if(b==="layers")Z4(S);else if(b==="inspector")rJ(S);else if(b==="comments")t(S);else if(b==="changes")H8(S);else if(b==="sync")S8(S);else if(b==="assistant")UG(S)},[]),MG=u.useCallback((b)=>DG.current.side?.[b]||sK[b],[]),k6=u.useCallback((b)=>{let S=MG(b);z4(b,!0);for(let i of Gk)if(i.id!==b&&MG(i.id)===S)z4(i.id,!1)},[z4,MG]),wX=u.useCallback((b)=>{if(DG.current.open?.[b])z4(b,!1);else k6(b)},[k6,z4]),eX=k6,h6=wX,OG=u.useCallback((b)=>{if(!OY.current)return;if(O0)return;if(!b||!b.id)return;if(yH.current)return;eX("inspector"),tX("css")},[eX,O0]),AY=u.useCallback(()=>j0((b)=>!b),[]),EQ=Tm(Zk),K4=Um({enabled:e0.cloud===null||e0.exportLane==="remote"}),[jH,W1]=u.useState(!1),[vH,J5]=u.useState(!1);u.useEffect(()=>{if(!G9())return;let b=!0;return Hh().then((S)=>{if(!b)return;if(W1(!!S),!S&&!IH(m80,!1))J5(!0)}).catch(()=>{}),()=>{b=!1}},[]);let DJ=u.useCallback(()=>{J5(!1);try{localStorage.setItem(m80,"1")}catch{}},[]),[AG,fH]=u.useState(null);u.useEffect(()=>{if(!G9())return;let b;return qh((S)=>fH(S&&typeof S==="object"?S:{})).then((S)=>{b=S}).catch(()=>{}),()=>{try{b?.()}catch{}}},[]);let[U4,PQ]=u.useState(null),[IQ,_G]=u.useState(()=>!IH(g80,!1)),EX=u.useCallback((b)=>{PQ(Array.isArray(b)&&b.length?b:null)},[]),wG={setup:(b)=>{if(!b)return;if((b.canvas||b.requireSelection)&&K.length===0)k6("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [role="treeitem"]')?.click()}catch{}},80);if(b.inspector||b.tab||b.requireSelection)eX("inspector");if(b.tab)tX(b.tab);if(b.changes)eX("changes")}},V4=u.useCallback(()=>{_G(!1);try{localStorage.setItem(g80,"1")}catch{}},[]),[X5,_Y]=u.useState(()=>IH(o80,!0)),[xH,EG]=u.useState(!1),[Q5,wY]=u.useState(()=>IH(c80,!1)),[g6,U0]=u.useState(()=>IH(i80,!1)),[jJ,q4]=u.useState(!1),[PG,aJ]=u.useState(!1),[l7,sJ]=u.useState(0),[g5,IG]=u.useState(null),[TG,EY]=u.useState(!1),m5=u.useRef(null),TQ=u.useRef(null),i8=u.useRef(new Map);u.useEffect(()=>{if(!e0?.canvasToken)return;let b=!1,S=null,i=0,X0=(A0)=>{clearTimeout(S);let l=fb(A0);i=Date.now()+l,S=setTimeout(H0,l)};async function H0(){let A0=null;try{let D0=await fetch("/_config",{cache:"no-store",credentials:"same-origin"});if(D0.ok)A0=(await D0.json())?.canvasToken}catch{}if(b)return;if(typeof A0!=="string"||!A0){clearTimeout(S),i=Date.now()+30000,S=setTimeout(H0,30000);return}vb(A0);let l=null;try{l=new URL(e0.canvasOrigin,location.href).origin}catch{}if(l)for(let D0 of i8.current.values())try{D0.contentWindow?.postMessage({dgn:"canvas-cap",t:A0},l)}catch{}X0(A0)}X0(e0.canvasToken);let F0=()=>{if(document.visibilityState==="visible"&&Date.now()>=i)H0()};return document.addEventListener("visibilitychange",F0),()=>{b=!0,clearTimeout(S),document.removeEventListener("visibilitychange",F0)}},[e0?.canvasToken,e0?.canvasOrigin]);let T0=u.useCallback((b)=>{let S=V?i8.current.get(V):null;if(!S||!S.contentWindow)return;try{S.contentWindow.postMessage(b,"*")}catch{}},[V]),tJ=u.useRef(0),kQ=u.useCallback(({format:b,artboardIds:S=null,scale:i=1,onProgress:X0,timeoutMs:H0=120000})=>new Promise((F0,A0)=>{let l=V?i8.current.get(V):null;if(!l||!l.contentWindow){A0(Error("no active canvas to capture"));return}let D0=l.contentWindow;tJ.current+=1;let P0=`cap-${Date.now().toString(36)}-${tJ.current}`,i0=!1,_8=(w7,d9)=>{if(i0)return;i0=!0,window.removeEventListener("message",A8),clearTimeout(q6),w7(d9)},A8=(w7)=>{if(w7.source!==D0)return;let d9=w7.data;if(!d9||d9.id!==P0)return;if(d9.dgn==="export-capture-progress")X0?.(d9.current,d9.total);else if(d9.dgn==="export-capture-done")_8(F0,Array.isArray(d9.items)?d9.items:[]);else if(d9.dgn==="export-capture-error")_8(A0,Error(d9.message||"capture failed"))},q6=setTimeout(()=>_8(A0,Error("capture timed out — the canvas did not answer")),H0);window.addEventListener("message",A8);try{D0.postMessage({dgn:"export-capture",id:P0,format:b,artboardIds:S,scale:i},"*")}catch(w7){_8(A0,w7)}}),[V]),Q8=u.useCallback((b,S)=>T0({dgn:"photo-preview",asset:b,edit:S}),[T0]),B4=u.useCallback((b,S,i)=>{wQ.current.undo.push({asset:b,before:S,after:i}),wQ.current.redo.length=0},[]),G8=u.useCallback((b)=>{let S=b?wQ.current.redo:wQ.current.undo;if(!S.length)return!1;let i=S.pop();(b?wQ.current.undo:wQ.current.redo).push(i);let X0=(b?i.after:i.before)||{};return Q8(i.asset,X0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(i.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(X0)}).catch(()=>{}),FG((H0)=>H0+1),!0},[Q8]),kG=u.useCallback(async(b)=>{T0({dgn:"photo-busy",asset:b,busy:!0});try{let S=await fetch(`/${b.replace(/^\/+/,"")}`);if(!S.ok)return null;let i=await S.blob(),{removeBackground:X0}=await Promise.resolve().then(() => (h80(),x80)),H0=await X0(i),F0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":H0.type||"image/png"},body:H0}),A0=await F0.json().catch(()=>({}));if(F0.ok&&A0.path)return{maskAsset:A0.path};return null}catch(S){return console.error("[photo] background removal failed",S),null}finally{T0({dgn:"photo-busy",asset:b,busy:!1})}},[T0]);u.useEffect(()=>{let b=(X0)=>Array.from(X0.dataTransfer?.types??[]).includes("Files"),S=(X0)=>{if(b(X0))X0.preventDefault()},i=(X0)=>{if(b(X0))X0.preventDefault()};return document.addEventListener("dragover",S),document.addEventListener("drop",i),()=>{document.removeEventListener("dragover",S),document.removeEventListener("drop",i)}},[]);let Q6=u.useRef({});Q6.current={open:L0,comps:E0,frame:O8,total:aX,playing:L9,compId:T6,muted:FJ,loop:AQ,sequences:K6,post:T0,canvas:V};let u5=u.useRef({undo:[],redo:[]}),Y6=u.useCallback((b,S,i)=>{if(typeof S!=="number")return;if(u5.current.undo.push({canvas:b,seq:S,label:i}),u5.current.redo=[],u5.current.undo.length>50)u5.current.undo.shift()},[]),RG=u.useCallback((b)=>{let S=u5.current,i=b==="undo"?S.undo:S.redo,X0=b==="undo"?S.redo:S.undo,H0=Q6.current.canvas,F0=-1;for(let l=i.length-1;l>=0;l--)if(i[l].canvas===H0){F0=l;break}if(F0<0){f8(b==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let A0=i[F0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:A0.canvas,seq:A0.seq,dir:b})}).then((l)=>l.json().catch(()=>({}))).then((l)=>{if(i.splice(F0,1),l?.ok)X0.push(A0),f8(`${b==="undo"?"Undid":"Redid"}: ${A0.label}`,!0);else f8(`${b==="undo"?"Undo":"Redo"} skipped: ${l?.error||"failed"}`)}).catch(()=>f8(`${b==="undo"?"Undo":"Redo"} failed: network error`))},[]),R6=u.useCallback((b,S)=>{let i=b?.ok&&Array.isArray(b.clips)?b.clips.filter((X0)=>X0.kind==="sequence"):[];if(S==null)return null;if(typeof S==="object")return(S.stableId?i.find((X0)=>X0.stableId===S.stableId):null)||(Number.isInteger(S.index)?i[S.index]:null)||null;if(typeof S==="string")return i.find((X0)=>X0.stableId===S)||null;return i[S]||null},[]),RQ=u.useCallback((b)=>{let S=Q6.current.canvas;if(!S||S===r8)return;let i=AX.current||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(S)}${i?`&artboardId=${encodeURIComponent(i)}`:""}`;fetch(X0).then((H0)=>H0.json().catch(()=>({}))).then((H0)=>{let F0=R6(H0,b);if(!F0?.stableId)return null;return fetch("/_api/remove-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:S,artboardId:i,stableId:F0.stableId,contentHash:F0.contentHash})})}).then((H0)=>H0?H0.json():null).then((H0)=>{if(H0&&!H0.ok)console.warn("[remove-clip]",H0.error||"failed"),LJ("Remove refused",H0.error);else if(H0?.ok){if(f8("Clip removed.",!0),H0.seq!=null)Y6(S,H0.seq,"remove clip");FY(null)}}).catch(()=>f8("Remove failed: network error"))},[R6,Y6]),CQ=u.useCallback((b,S,i)=>{let X0=Q6.current.canvas;if(!X0||X0===r8)return;let H0=AX.current||void 0,F0=`/_api/comp-clips?canvas=${encodeURIComponent(X0)}${H0?`&artboardId=${encodeURIComponent(H0)}`:""}`;fetch(F0).then((A0)=>A0.json().catch(()=>({}))).then((A0)=>{let l=A0?.ok&&Array.isArray(A0.clips)?A0.clips:[],D0=b?.transition?l.find((P0)=>P0.kind==="transition"&&P0.stableId===b.stableId)||null:R6(A0,b);if(!D0?.stableId)return null;return fetch("/_api/clip-edit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:X0,artboardId:H0,stableId:D0.stableId,contentHash:D0.contentHash,verb:S,...i})})}).then((A0)=>A0?A0.json():null).then((A0)=>{if(A0&&!A0.ok)console.warn("[clip-edit]",S,A0.error||"failed"),LJ(`${S} refused`,A0.error);else if(A0?.ok){let l={speed:"set speed","trim-in":"trim in-point",audio:"clip audio","detach-audio":"detach audio",framing:"crop clip",grade:"grade clip",transition:"edit transition",split:"split clip","insert-transition":"add transition","remove-transition":"remove transition","set-text":"edit text","to-overlay":"move to overlay layer","to-storyline":"move to storyline","layer-order":"reorder layers"};if(f8(`Applied: ${l[S]||S}.`,!0),A0.seq!=null)Y6(X0,A0.seq,l[S]||S)}}).catch(()=>f8(`${S} failed: network error`))},[R6,Y6,LJ]),[$Q,PY]=u.useState(null),Y5=u.useCallback((b,S="")=>new Promise((i)=>{PY({title:b,value:S,resolve:i})}),[]),p5=u.useCallback((b)=>{PY((S)=>{return S?.resolve?.(b),null})},[]),IY=u.useCallback((b,S)=>{let i=Q6.current.canvas;if(!i||i===r8||!S||!String(S).trim())return;$7({type:"comments-add",payload:{file:i,text:String(S).trim(),selector:"",dom_path:[],tag:"",classes:"",bounds:null,html_excerpt:"",timeline:b}}),f8("Comment added.",!0)},[]);Q6.current.selected=CH,Q6.current.setSelected=FY,Q6.current.removeClip=RQ,Q6.current.clipVerb=CQ,Q6.current.addComment=IY,Q6.current.askText=Y5,u.useEffect(()=>{let b=(S)=>{let i=Q6.current;if(!i.open||!i.comps?.length)return;let X0=S.target,H0=X0?.tagName;if(H0==="INPUT"&&X0?.type!=="range")return;if(H0==="TEXTAREA"||H0==="SELECT"||X0?.isContentEditable)return;let F0=TK(i.comps,i.compId)?.fps||30,A0=Math.max(1,i.total),l=(P0)=>{let i0=Math.max(0,Math.min(A0-1,Math.round(P0)));Z9(i0),I6(!1),i.post({dgn:"timeline-seek",frame:i0,id:i.compId})},D0=()=>{let P0=new Set([0,A0-1]);for(let i0 of i.sequences||[]){P0.add(i0.from);for(let _8 of i0.keyframes||[])P0.add(_8.from),P0.add(_8.to)}return[...P0].filter((i0)=>i0>=0&&i0<A0).sort((i0,_8)=>i0-_8)};if((S.metaKey||S.ctrlKey)&&(S.key==="z"||S.key==="Z")){S.preventDefault(),RG(S.shiftKey?"redo":"undo");return}if(S.key==="Escape"){if(i.selected!=null)S.preventDefault(),i.setSelected?.(null);return}if((S.key==="Delete"||S.key==="Backspace")&&i.selected!=null){S.preventDefault(),i.removeClip?.({stableId:i.selected});return}if((S.metaKey||S.ctrlKey)&&(S.key==="b"||S.key==="B")){S.preventDefault();let P0=i.selected!=null?{stableId:i.selected}:null;if(!P0){let i0=i.sequences||[],_8=i0.find((A8)=>A8.series&&i.frame>=A8.from&&i.frame<A8.from+A8.duration)||i0.find((A8)=>i.frame>=A8.from&&i.frame<A8.from+A8.duration);if(_8?.stableId)P0={stableId:_8.stableId}}if(P0)i.clipVerb?.(P0,"split",{atFrame:i.frame});else f8("Nothing under the playhead to split.");return}if(S.key===" "||S.code==="Space")if(S.preventDefault(),i.playing)I6(!1),i.post({dgn:"timeline-pause",id:i.compId});else I6(!0),i.post({dgn:"timeline-mute",muted:i.muted,id:i.compId}),i.post({dgn:"timeline-loop",loop:i.loop,id:i.compId}),i.post({dgn:"timeline-play",id:i.compId});else if(S.key==="ArrowRight")S.preventDefault(),l(i.frame+(S.shiftKey?F0:1));else if(S.key==="ArrowLeft")S.preventDefault(),l(i.frame-(S.shiftKey?F0:1));else if(S.key==="Home")S.preventDefault(),l(0);else if(S.key==="End")S.preventDefault(),l(A0-1);else if(S.key==="."){S.preventDefault();let P0=D0().find((i0)=>i0>i.frame);if(P0!=null)l(P0)}else if(S.key===","){S.preventDefault();let P0=D0().reverse().find((i0)=>i0<i.frame);if(P0!=null)l(P0)}};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[]),u.useEffect(()=>{z8([]),Z9(0),I6(!1),FY(null),RH(null);let b=setTimeout(()=>T0({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(b)},[V,T0]);let[l5,TY]=u.useState(""),[kY,N4]=u.useState([]),[CG,RY]=u.useState([]);u.useEffect(()=>{if(!L0||E0.length===0||!V||V===r8){TY(""),N4([]);return}let b=!0;return fetch(`/_api/canvas-source?file=${encodeURIComponent(V)}`).then((S)=>S.ok?S.json():null).then((S)=>{if(b&&S?.ok&&typeof S.source==="string")TY(S.source)}).catch(()=>{}),()=>{b=!1}},[L0,E0,V,LY]),u.useEffect(()=>{if(!L0||!V||V===r8||!l5){N4([]),RY([]);return}let b=!0,S=X6||void 0,i=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${S?`&artboardId=${encodeURIComponent(S)}`:""}`;return fetch(i).then((X0)=>X0.ok?X0.json():null).then((X0)=>{if(!b)return;let H0=X0?.ok&&Array.isArray(X0.clips)?X0.clips:[];N4(H0.filter((F0)=>F0.kind==="sequence")),RY(H0.filter((F0)=>F0.kind==="transition"))}).catch(()=>{}),()=>{b=!1}},[L0,V,l5,X6,LY]),u.useEffect(()=>{if(!l5){t8([]),x6([]),_Q([]),kH(0);return}let b=R9??A?.artboardId??null,i=(b&&E0.find((F0)=>F0.artboardId===b||F0.id===b)||E0[0])?.durationInFrames||0,X0=eg(l5,i,b);RH(X0.artboardId??b??null);let H0=X0.sequences.map((F0,A0)=>{let l=kY[A0];if(!l)return F0;return{...F0,stableId:l.stableId,contentHash:l.contentHash,mediaProps:l.mediaProps??null,placeholder:l.placeholder??null,mediaTag:l.mediaTag??F0.mediaTag,mediaSrc:l.mediaSrc??F0.mediaSrc,replaceable:!!(l.mediaCdId||l.mediaArrayRef),layers:Array.isArray(l.layers)?l.layers:[],hidden:!!l.hidden}});t8(H0),x6(X0.audio||[]),_Q(X0.transitions||[]),kH(X0.total)},[l5,kY,A,E0,R9]);let CY=u.useCallback(()=>{_Y((b)=>{let S=!b,i=V?i8.current.get(V):null;if(i&&i.contentWindow)try{i.contentWindow.postMessage({dgn:"view-annotations",visible:S},"*")}catch{}return S})},[V]),MJ=u.useCallback((b)=>{for(let S of i8.current.values())try{S.contentWindow.postMessage({dgn:"view-chrome",...b},"*")}catch{}},[]),$Y=u.useCallback(()=>{wY((b)=>{let S=!b;return MJ({minimap:S}),S})},[MJ]),SY=u.useCallback(()=>{U0((b)=>{let S=!b;return MJ({zoom:S}),S})},[MJ]),$G=u.useCallback(()=>{q4((b)=>{let S=!b;return MJ({present:S}),S})},[MJ]),F4=u.useCallback(()=>{q4(!1),MJ({present:!1})},[MJ]),SG=u.useCallback(()=>{if(!V||V===r8)return;aJ((b)=>{let S=!b;return T0({dgn:"view-chrome",print:S}),fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:V,patch:{overlays:{print:S}}})}).catch(()=>{}),S})},[V,T0]);u.useEffect(()=>{let b=!1;return fetch("/_api/git-user").then((S)=>S.json()).then((S)=>{if(b)return;let i=S&&typeof S.name==="string"?S.name.trim():"";if(i)IG(i)}).catch(()=>{}),()=>{b=!0}},[]),u.useEffect(()=>{if(!V||V===r8){sJ(0),aJ(!1);return}let b=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(V)).then((S)=>S.json()).then((S)=>{if(b)return;let i=Array.isArray(S?.artboards)?S.artboards.length:0;sJ(i),aJ(S?.overlays?.print===!0),D4(new Set(Array.isArray(S?.locked)?S.locked:[]))}).catch(()=>{if(!b)sJ(0),aJ(!1),D4(new Set)}),()=>{b=!0}},[V]),u.useEffect(()=>{if(!V||V===r8||!R9)return;let b=setTimeout(()=>{T0({dgn:"request-layers",artboardId:R9})},250);return()=>clearTimeout(b)},[V,R9,T0]);let[L4,D4]=u.useState(()=>new Set),bG=u.useCallback((b)=>{if(!V||V===r8)return;D4((S)=>{let i=new Set(S);if(i.has(b))i.delete(b);else i.add(b);let X0=[...i];return fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:V,patch:{locked:X0}})}).catch(()=>{}),T0({dgn:"locked-set",locked:X0}),i})},[V,T0]);u.useEffect(()=>{if(!V||V===r8)return;T0({dgn:"locked-set",locked:[...L4]})},[L4,V,T0]),u.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",f0),localStorage.setItem(A90,f0)}catch{}for(let b of i8.current.values())try{b.contentWindow.postMessage({dgn:"theme",theme:f0},"*")}catch{}},[f0]),u.useEffect(()=>{try{localStorage.setItem(d80,k9?"1":"0")}catch{}},[k9]),u.useEffect(()=>{try{localStorage.setItem(u80,J7?"1":"0")}catch{}},[J7]),u.useEffect(()=>{try{localStorage.setItem(p80,JSON.stringify(rX))}catch{}},[rX]),u.useEffect(()=>{try{localStorage.setItem(c80,Q5?"1":"0")}catch{}},[Q5]),u.useEffect(()=>{try{localStorage.setItem(i80,g6?"1":"0")}catch{}},[g6]),u.useEffect(()=>{try{localStorage.setItem(o80,X5?"1":"0")}catch{}},[X5]),u.useEffect(()=>{let b=!1;return fetch("/_api/ui-prefs").then((S)=>S.ok?S.json():Promise.reject(Error(`HTTP ${S.status}`))).then((S)=>{if(b||!S||typeof S!=="object")return;if(S.theme==="light"||S.theme==="dark")Y8(S.theme);if(typeof S.minimap==="boolean")wY(S.minimap);if(typeof S.zoom==="boolean")U0(S.zoom);if(typeof S.annotations==="boolean")_Y(S.annotations);if(typeof S.autoOpenInspector==="boolean")LG(S.autoOpenInspector);if(S.panelSides&&typeof S.panelSides==="object")H4({...sK,...S.panelSides});if(S.layersMode==="separate"||S.layersMode==="in-inspector")W0(S.layersMode)}).catch(()=>{}).finally(()=>{if(!b)EG(!0)}),()=>{b=!0}},[]),u.useEffect(()=>{if(!xH)return;KF0({theme:f0,minimap:Q5,zoom:g6,annotations:X5,autoOpenInspector:U6,panelSides:NJ,layersMode:n})},[xH,f0,Q5,g6,X5,U6,NJ,n]),u.useEffect(()=>{try{localStorage.setItem(n80,JSON.stringify(NJ))}catch{}},[NJ]),u.useEffect(()=>{try{localStorage.setItem(r80,n)}catch{}},[n]);let yG=u.useCallback((b,S)=>{BJ((i)=>{let X0=i[b],H0=X0===void 0?S:X0;return{...i,[b]:!H0}})},[]),M4=u.useCallback(()=>{Y8((b)=>b==="dark"?"light":"dark")},[]),O4=u.useRef(null),y9=u.useCallback(()=>O4.current?.reload()??Promise.resolve(),[]);u.useEffect(()=>{let b=hb({read:async(S)=>{let i=await fetch("/_index-data",{signal:S,cache:"no-store"});if(!i.ok)throw Object.assign(Error(`Project index request failed: ${i.status}`),{status:i.status});let X0=await i.json(),H0=X0.groups.map((F0)=>({...F0,tree:LF0(F0.paths,F0.stripPrefix,F0.dirs)}));return{data:X0,built:H0}},apply:({data:S,built:i})=>{H(S.project||"Design"),X(i),Y(!0),a7((X0)=>({...X0,canvasDesignSystems:S.canvasDesignSystems??{},canvasKinds:S.canvasKinds??{}}))},onError:(S)=>console.error("failed to load tree",S)});return O4.current=b,y9(),()=>{O4.current=null,b.dispose()}},[y9]);let W5=u.useCallback(async(b)=>{try{let S=b?`/_system-data?ds=${encodeURIComponent(b)}`:"/_system-data",i=await fetch(S);if(!i.ok){console.error("failed to load system-data",i.status);return}let X0=await i.json();if(!b&&X0?.defaultDesignSystem&&!X0.ds){V0(X0);let H0=await fetch(`/_system-data?ds=${encodeURIComponent(X0.defaultDesignSystem)}`);if(H0.ok)V0(await H0.json());return}V0(X0)}catch(S){console.error("failed to load system-data",S)}},[]),bY=u.useCallback(async()=>{try{let S=await(await fetch("/_comments-all")).json();V9(S||{})}catch(b){console.error("failed to load comments",b)}},[]);u.useEffect(()=>{bY()},[bY]);let yY=u.useRef(()=>{});u.useEffect(()=>{let b=null,S=!1;function i(){let X0=location.protocol==="https:"?"wss:":"ws:",H0=new WebSocket(X0+"//"+location.host+"/_ws");TQ.current=H0,H0.addEventListener("open",()=>{if(o(!0),S)K8();S=!0,clearInterval(b),b=setInterval(()=>{if(H0.readyState===WebSocket.OPEN)H0.send('{"type":"ping"}')},25000)}),H0.addEventListener("close",()=>{o(!1),clearInterval(b),setTimeout(i,1000)}),H0.addEventListener("error",()=>{}),H0.addEventListener("message",(F0)=>{try{let A0=JSON.parse(F0.data);if(A0.type==="snapshot"&&A0.state)E((l)=>L90(A0.state.selected,l));else if(A0.type==="selected"){if(Date.now()-k.current<2000)return;let l=A0.selected,D0=Array.isArray(l)?l[0]:l,P0=w.current,i0=Array.isArray(P0)?P0[0]:P0;if(E((_8)=>L90(l,_8)),D0?.id&&D0.file&&(!i0||i0.id!==D0.id||i0.file!==D0.file))$(D0)}else if(A0.type==="comments"&&typeof A0.file==="string")V9((l)=>({...l,[A0.file]:A0.comments||[]}));else if(A0.type==="ai-activity"&&typeof A0.file==="string"){if(EY(!0),m5.current)clearTimeout(m5.current);m5.current=setTimeout(()=>EY(!1),8000);for(let l of i8.current.values())try{l.contentWindow.postMessage({dgn:"ai-activity",file:A0.file,entry:A0.entry},"*")}catch{}}else if(A0.type==="export:job"&&A0.payload)K4.upsert(A0.payload);else if(A0.type==="sync:status"&&A0.payload)a0(A0.payload);else if(A0.type==="canvas-list-update")y9(),yY.current(A0.payload);else if(A0.type==="config-updated")K8();else if(A0.type==="acp-focus"){if(G9())eX("assistant")}else if(A0.type==="git-status"&&A0.payload){if(!c8.current)I0(A0.payload)}else if(A0.type==="git-lifecycle"&&A0.payload){Z0(A0.payload);for(let l of i8.current.values())try{l.contentWindow.postMessage({dgn:"git-lifecycle",payload:A0.payload},"*")}catch{}}}catch{}})}return i(),()=>{if(clearInterval(b),TQ.current)TQ.current.close()}},[y9,K8]);function $7(b){let S=TQ.current;try{if(S&&S.readyState===1)S.send(JSON.stringify(b))}catch{}}let OJ=u.useCallback(async()=>{if(c8.current)return;try{let b=await fetch("/_api/git/status");if(b.ok)I0(await b.json())}catch{}},[]),vJ=u.useCallback(async()=>{if(c8.current)return;try{let b=await fetch("/_api/git/status?remote=1");if(!b.ok)return;let S=await b.json();if(S&&S.repo!==!1)C0({remoteAhead:!!S.remoteAhead,behind:S.behind||0})}catch{}},[]),AJ=u.useCallback(async(b,S)=>{try{let i=await fetch(b,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(S||{})}),X0=await i.json().catch(()=>({}));return{ok:i.ok,...X0}}catch(i){return{ok:!1,error:"Network error — is the project still open?"}}},[]),jG=u.useCallback(async(b,S)=>{let i=await AJ("/_api/git/commit",{message:b,files:S});if(i.ok)await OJ();return i},[AJ,OJ]),jY=u.useCallback(async(b)=>{let S=await AJ("/_api/git/discard",{files:b});if(S.ok)await OJ();return S},[AJ,OJ]),vG=u.useCallback(async()=>{let b=await AJ("/_api/git/push",{});if(b.ok)await OJ(),vJ();return b},[AJ,OJ,vJ]),vY=u.useCallback(async()=>{let b=await AJ("/_api/git/pull",{});if(b.ok)await OJ(),vJ();if(b.conflict&&Array.isArray(b.files)&&b.files.length)v0({file:b.files[0],conflict:!0});return b},[AJ,OJ,vJ]),fG=u.useCallback(async(b)=>{let S=await AJ("/_api/git/resolve",{choice:b});if(S.ok)await OJ(),vJ();return S},[AJ,OJ,vJ]),fY=u.useCallback(async(b)=>{try{let S="/_api/git/log?limit=40"+(b?`&path=${encodeURIComponent(b)}`:""),i=await fetch(S);if(!i.ok)return[];return(await i.json()).entries||[]}catch{return[]}},[]),[xG,hG]=u.useState(null),gG=u.useCallback(async(b)=>{try{let S="/_api/cloud/history?limit=40"+(b?`&path=${encodeURIComponent(b)}`:""),i=await fetch(S);if(!i.ok)return null;let X0=await i.json();if(!X0?.ok)return null;return hG({branch:X0.branch??null,project:X0.project??null,hubHost:X0.hubHost??null}),X0.entries||[]}catch{return null}},[]),[mG,uG]=u.useState(!1),pG=u.useCallback(async(b)=>{try{let S="/_api/project/history?limit=40"+(b?`&path=${encodeURIComponent(b)}`:""),i=await fetch(S);if(!i.ok)return"legacy";let X0=await i.json();if(!X0?.ok)return X0?.reason==="legacy"?"legacy":null;return(X0.history||[]).map((H0)=>{let F0=b?"":(H0.canvases||[]).map((A0)=>A0.split("/").pop()).join(", ");return{sha:`r${H0.revision}`,message:[H0.label||H0.kind,F0].filter(Boolean).join(" · "),author:H0.actor,date:new Date(H0.committedAt).toISOString(),accepted:{revision:H0.revision,actionId:H0.actionId,mine:!!H0.mine,undo:H0.kind==="undo"||H0.kind==="redo"}}})}catch{return null}},[]),lG=u.useMemo(()=>{let b={modified:"M",added:"A",deleted:"D",untracked:"U"},S=new Map;if(I8)return S;for(let i of T8?.files||[])S.set(i.path,b[i.status]);return S},[T8,I8]);u.useEffect(()=>{if(I8){C0(null);return}if(T8?.repo===!1)return;vJ();let b=setInterval(vJ,W8?60000:120000);return()=>clearInterval(b)},[I8,T8?.repo,W8,vJ]);let V6=u.useCallback((b)=>{if(W.current="push",i9(null),F(null),b===V)return;if(U((S)=>{for(let i of S)if(i.path!==b)i8.current.delete(i.path);return[{path:b}]}),B(b),q8(null),y0(null),b!==r8)r0(b)},[V]),A4=u.useCallback((b,S="push")=>{let i=J.flatMap((X0)=>X0.paths||[]).find((X0)=>CW(X0,e0.designRel)===b);if(i&&y5.test(i))V6(i);else if(i&&NL(Y4(i)))M(i);else U([]),B(null),F(null),P5({title:"Not here yet",description:`${b} is not in this project (not synced yet?)`,kind:"info"});W.current=S},[J,e0.designRel,V6,M]),hH=u.useRef(!1);u.useEffect(()=>{if(!Q||e0.cloud===void 0||hH.current)return;hH.current=!0;let b=PV(location,e0.designRel);if(b)A4(b,"none")},[Q,e0.cloud,e0.designRel,A4]),u.useEffect(()=>{if(!Q||e0.cloud===void 0)return;let b=()=>{let S=PV(location,e0.designRel);if(S)A4(S,"none");else W.current="none",U([]),B(null),F(null)};return window.addEventListener("popstate",b),()=>window.removeEventListener("popstate",b)},[Q,e0.cloud,e0.designRel,A4]),u.useEffect(()=>{let b=N||(V===r8?null:V);if(b===G.current)return;G.current=b;let S=CW(b,e0.designRel);if(W.current!=="none"&&PV(location,e0.designRel)!==S)history[S?"pushState":"replaceState"](S?{open:S}:null,"",ah(location,S));W.current="push"},[V,N,e0.designRel]);let xY=N||(V===r8?null:V),dG=e0.cloud?"cloud":G9()?"native":"local",gH=(b)=>Jg({rel:CW(b,e0.designRel),shell:dG,location,linkedHubUrl:t0?.url,project:e0.cloud?Z:a8,localUrl:location.origin}),mH=(b=xY)=>{let S=CW(b,e0.designRel);if(S)v5({path:b,rel:S,label:Y4(b)})},G1=u.useCallback((b)=>{if(q8(null),y0(null),K8(),d0((S)=>S+1),b&&b!==r8)r0(b)},[K8]),cG=u.useRef(!1);u.useEffect(()=>{if(cG.current)return;if(!e0.cloud)return;if(new URLSearchParams(location.search).has("open")){cG.current=!0;return}if(K.length>0)return;if(!J.length)return;let b=null;for(let S of J){for(let i of S.paths||[]){if(!y5.test(i))continue;if(/(^|\/)system\//.test(i))continue;b=i;break}if(b)break}if(!b)return;cG.current=!0,V6(b)},[e0.cloud,J,K.length,V6]);let SQ=u.useCallback((b)=>{let S=typeof b==="string"?b:void 0;if(S)W5(S);else if(!L8)W5();V6(r8)},[L8,W5,V6]);u.useEffect(()=>{$7({type:"tabs",tabs:K.map((b)=>b.path).filter((b)=>b!==r8)})},[K]),u.useEffect(()=>{if(V&&V!==r8)$7({type:"active",file:V});else if(V===r8)$7({type:"active",file:""});else $7({type:"active",file:""})},[V]);let hY=u.useCallback((b)=>{U((S)=>{let i=S.findIndex((H0)=>H0.path===b);if(i<0)return S;let X0=S.filter((H0)=>H0.path!==b);if(b===V)if(X0.length===0)B(null);else B(X0[Math.max(0,i-1)].path);return X0}),i8.current.delete(b),r0((S)=>S===b?null:S)},[V]);yY.current=(b)=>{if(!b?.rel)return;let S=(e0?.designRel||e0?.designRoot||".design").replace(/^\/+|\/+$/g,""),i=`${S}/${b.rel}`;if(b.action==="removed")hY(i);else if(b.action==="moved"&&b.fromRel){let X0=`${S}/${b.fromRel}`;U((H0)=>H0.map((F0)=>F0.path===X0?{...F0,path:i}:F0)),B((H0)=>H0===X0?i:H0),r0((H0)=>H0===X0?null:H0),i8.current.delete(X0)}};let d5=u.useCallback(()=>{if(!V||V===r8){if(V===r8)W5();return}let b=i8.current.get(V);if(b)b.src=b.src},[V,W5]),uH=u.useCallback(()=>y9(),[y9]),[Z1,pH]=u.useState(!1),iG=u.useRef(!1),oG=u.useCallback(async()=>{if(iG.current)return;iG.current=!0,pH(!0);try{await Promise.all([y9(),new Promise((b)=>setTimeout(b,550))])}finally{iG.current=!1,pH(!1)}},[y9]);u.useEffect(()=>{let b=null,S=()=>{if(b)clearTimeout(b);b=setTimeout(()=>{b=null,uH()},150)};return window.addEventListener("focus",S),()=>{if(window.removeEventListener("focus",S),b)clearTimeout(b)}},[uH]);let H1=u.useCallback(async(b)=>{try{let S=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b,kind:"brief-board"})}),i=await S.json().catch(()=>({}));if(!S.ok||!i.ok)return{ok:!1,error:i.error||`create failed (${S.status})`};return await y9(),V6(i.file),{ok:!0,file:i.file}}catch(S){return{ok:!1,error:S instanceof Error?S.message:"network error"}}},[y9,V6]),lH=u.useCallback(async()=>{let b=await Y5("New video name");if(!b)return;let i=(await Y5("Size — 1920x1080 (landscape), 1080x1920 (portrait), 1080x1080 (square), or custom WxH","1920x1080")||"1920x1080").toLowerCase().match(/(\d{2,5})\s*[x×]\s*(\d{2,5})/),X0=i?Number(i[1]):1920,H0=i?Number(i[2]):1080,F0=Math.max(1,Math.min(60,Number(await Y5("Frames per second","30"))||30));try{let A0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b,kind:"video-comp",clips:[],fps:F0,width:X0,height:H0})}),l=await A0.json().catch(()=>({}));if(!A0.ok||!l.ok){f8(`New video failed: ${l.error||`error ${A0.status}`}`);return}await y9(),V6(l.file),j0(!0),f8("New video created — drop clips on the timeline to start the cut.",!0)}catch(A0){f8(`New video failed: ${A0 instanceof Error?A0.message:"network error"}`)}},[y9,V6,Y5]),z1=u.useCallback(async()=>{if(!V||V===r8)return;try{let b=await fetch(`/_api/annotations?file=${encodeURIComponent(V)}`),S=b.ok?await b.text():"",i=[];if(S){let l=new DOMParser().parseFromString(S,"image/svg+xml");for(let D0 of l.querySelectorAll('[data-tool="mediaref"]')){let P0=D0.getAttribute("data-src");if(!P0)continue;i.push({src:P0,mediaKind:D0.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(i.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let H0=`${VY(Y4(V)).replace(/\.tsx$/i,"")} Video`,F0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:H0,kind:"video-comp",clips:i})}),A0=await F0.json().catch(()=>({}));if(!F0.ok||!A0.ok){window.alert(`Assemble failed: ${A0.error||`error ${F0.status}`}`);return}await y9(),V6(A0.file)}catch(b){window.alert(`Assemble failed: ${b instanceof Error?b.message:"network error"}`)}},[V,y9,V6]),nG=u.useCallback(({accept:b,resolveTarget:S})=>{let i=V,X0=X6||void 0,H0=document.createElement("input");H0.type="file",H0.accept=b,H0.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(H0);let F0=()=>{if(H0.isConnected)H0.remove()};window.addEventListener("focus",()=>setTimeout(F0,300),{once:!0}),H0.addEventListener("change",()=>{let A0=H0.files?.[0];if(F0(),!A0)return;let l=`/_api/comp-clips?canvas=${encodeURIComponent(i)}${X0?`&artboardId=${encodeURIComponent(X0)}`:""}`;fetch(l).then((D0)=>D0.json().catch(()=>({}))).then((D0)=>{let P0=S(D0);if(!P0)return f8("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":A0.type||"application/octet-stream"},body:A0}).then((i0)=>i0.json().catch(()=>({}))).then((i0)=>{if(!i0?.path)return f8(`Upload failed: ${i0?.error||"unknown error"}`),null;if(P0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:i,arrayName:P0.arrayRef.arrayName,index:P0.arrayRef.index,field:P0.arrayRef.field,value:i0.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:i,id:P0.cdId,attr:"src",value:i0.path})})})}).then((D0)=>D0?D0.json():null).then((D0)=>{if(D0&&!D0.ok)f8(`Replace refused: ${D0.error||"failed"}`);else if(D0&&D0.ok){if(f8("Media replaced.",!0),D0.seq!=null)Y6(i,D0.seq,"replace media")}}).catch(()=>f8("Replace failed: network error"))}),H0.click()},[V,X6,Y6]),K1=u.useCallback(async(b,S)=>{if(!window.confirm(`Move “${S}” to trash?
5683
+ `).length," lines, paths & secrets scrubbed)",H?.process?` + server memory (${Math.round(H.process.rssBytes/1048576)} MB)`:""," ","—"," ",D("details",{className:"rb-details",children:[z("summary",{children:"view"}),z("pre",{className:"rb-log",children:H.logs.serverLogTail})]})]})]}):null,G9()&&B.length>0&&D("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.crashLogs,onChange:(p)=>M({...F,crashLogs:p.target.checked})}),D("span",{children:["Crash logs (",B.length,") — ",z("code",{children:B.map((p)=>p.name).join(", ")})]})]})]}),D("p",{className:"rb-hint",children:["Your description and the system info above become a"," ",z("strong",{children:"public GitHub issue"}),"; screenshots and logs go to a private repository only maintainers can open."]}),D("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("describe"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-send",onClick:a,children:"Send report"})]})]}),Y==="sending"&&z("p",{className:"rb-hint",children:"Sending your report…"}),Y==="done"&&D(Q0,{children:[I?.issueUrl?D("p",{children:["Thank you — your report is filed as"," ",D("button",{type:"button",className:"rb-link","data-testid":"report-bug-issue-link",onClick:()=>{if(G9())LV(I.issueUrl).catch(()=>navigator.clipboard?.writeText(I.issueUrl));else window.open(I.issueUrl,"_blank","noopener")},children:["report #",I.issueNumber]})," ","on the public Maude issue tracker. Screenshots and logs stay in a private repository only maintainers can open — the issue links to them."]}):D("p",{children:["The bundle is saved locally",I?.fallbackDir?D(Q0,{children:[" ","at ",z("code",{children:I.fallbackDir})]}):null," ","and a prefilled GitHub issue was opened — attach the bundle files there."]}),z("footer",{className:"rb-actions",children:z("button",{type:"button",className:"st-btn rb-primary",onClick:m,children:"Done"})})]}),Y==="fallback"&&D(Q0,{children:[z("p",{className:"rb-error","data-testid":"report-bug-error",children:R}),z("p",{className:"rb-hint",children:"You can save the report locally instead and file it on GitHub yourself — the prefilled issue carries the text; screenshots stay on this machine unless you attach them by hand."}),D("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("preview"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary",onClick:f,children:"Save locally & open GitHub"})]})]})]})]})})}var TJ=j8(s8(),1);function wm(J){if(typeof J!=="string")return null;let X=J.match(/^(\d+)\.(\d+)\.(\d+)/);return X?[Number(X[1]),Number(X[2]),Number(X[3])]:null}function Em(J,X){let Q=wm(J),Y=wm(X);if(!Q)return!1;if(!Y)return!0;for(let W=0;W<3;W++)if(Q[W]!==Y[W])return Q[W]>Y[W];return!1}function Pm(J,X){if(!Array.isArray(J))return[];return J.filter((Q)=>Q&&(Q.version==null||Em(Q.version,X)))}function Im(J,X){let Q=X;if(Array.isArray(J)){for(let Y of J)if(Y&&Y.version&&Em(Y.version,Q))Q=Y.version}return Q}var NE="mdcc-whatsnew-seen",FE="mdcc-whatsnew-toast-dismissed";function sU0(J){return typeof J==="string"&&/^https?:\/\//i.test(J)}function tU0(J){try{let X=localStorage.getItem(NE);if(X)return X;localStorage.setItem(NE,J)}catch{}return J}function eU0(){try{return localStorage.getItem(FE)}catch{return null}}function Tm(J){let[X,Q]=TJ.useState([]),[Y,W]=TJ.useState(J),[G,Z]=TJ.useState(()=>tU0(J)),[H,K]=TJ.useState(()=>eU0()),[U,V]=TJ.useState(!1);TJ.useEffect(()=>{let O=!1,I=()=>{fetch("/_api/whats-new").then(($)=>$.json()).then(($)=>{if(O)return;if(Q(Array.isArray($?.entries)?$.entries:[]),typeof $?.version==="string")W($.version)}).catch(()=>{})};I();let k=()=>I(),R=()=>{if(document.visibilityState==="visible")I()};return window.addEventListener("focus",k),document.addEventListener("visibilitychange",R),()=>{O=!0,window.removeEventListener("focus",k),document.removeEventListener("visibilitychange",R)}},[]);let B=Pm(X,G),N=B.length>0&&H!==Y&&!U,F=B[0]??null,M=TJ.useCallback(()=>{let O=Im(X,Y);Z(O),K(Y);try{localStorage.setItem(NE,O),localStorage.setItem(FE,Y)}catch{}},[X,Y]),A=TJ.useCallback(()=>{K(Y);try{localStorage.setItem(FE,Y)}catch{}},[Y]),E=TJ.useCallback(()=>V(!0),[]),w=TJ.useCallback(()=>{V(!1),M()},[M]);return{entries:X,unseen:B,feedVersion:Y,panelOpen:U,openPanel:E,closePanel:w,showToast:N,toastEntry:F,dismissToast:A,markAllSeen:M}}function km({wn:J}){let X=`whats-new-${J.feedVersion}`;return TJ.useEffect(()=>{if(!J.showToast||!J.toastEntry){$W(X);return}P5({id:X,group:"whats-new",kind:"info",duration:1e4,title:`What's new${J.toastEntry.version?` · v${J.toastEntry.version}`:""} — ${J.toastEntry.title}`,description:J.toastEntry.summary,action:{label:J.unseen.length>1?`See all (${J.unseen.length})`:"Details",onClick:J.openPanel},onDismiss:J.dismissToast})},[X,J.showToast,J.toastEntry,J.unseen.length,J.openPanel,J.dismissToast]),TJ.useEffect(()=>()=>$W(X),[X]),null}function Rm({wn:J,onStartTour:X}){let{panelOpen:Q,closePanel:Y}=J;if(TJ.useEffect(()=>{if(!Q)return;function G(Z){if(Z.key==="Escape")Y()}return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[Q,Y]),!Q)return null;let W=new Set(J.unseen.map((G)=>G.id));return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)Y()},children:D("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[D("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"mdcc-wn-title",children:"✦ What’s new in maude"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:Y,children:"×"})]}),z("div",{className:"mdcc-wn-panel__body",children:J.entries.length===0?z("p",{className:"mdcc-wn-empty",children:"Nothing new yet."}):z("ul",{className:"mdcc-wn-list",children:J.entries.map((G)=>D("li",{className:"mdcc-wn-item"+(W.has(G.id)?" is-unseen":""),children:[D("div",{className:"mdcc-wn-item__hd",children:[z("span",{className:"mdcc-wn-kind mdcc-wn-kind--"+G.kind,children:G.kind}),z("span",{className:"mdcc-wn-item__title",children:G.title}),z("span",{className:"mdcc-wn-item__ver",children:G.version?`v${G.version}`:"next"})]}),z("p",{className:"mdcc-wn-item__summary",children:G.summary}),sU0(G.learnMore)&&z("a",{className:"mdcc-wn-item__more",href:G.learnMore,target:"_blank",rel:"noreferrer",children:"Learn more →"}),X&&Array.isArray(G.tour)&&G.tour.length>0&&z("button",{type:"button",className:"mdcc-wn-item__tour",onClick:()=>{Y(),X(G.tour)},children:"▶ Take tour"})]},G.id))})})]})})}var K7=({as:J,size:X=14})=>z(J,{size:X,strokeWidth:1.75,style:{display:"block"}}),g80="mdcc-usage-tour-seen",m80="mdcc-collab-tour-seen",r8="__system__",A90="mdcc-theme",u80="mdcc-show-hidden",p80="mdcc-sections-expanded",l80="maude-cp-mode",d80="mdcc-sidebar-open",c80="mdcc-minimap-visible",i80="mdcc-zoomctl-visible",o80="mdcc-annotations-visible";var zF0=30000;function KF0(J){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(J)}).catch(()=>{})}catch{}}var Gk=[{id:"tree",label:"Files"},{id:"layers",label:"Layers"},{id:"inspector",label:"Inspector"},{id:"comments",label:"Comments"},{id:"changes",label:"Changes"},{id:"sync",label:"Sync"},{id:"assistant",label:"Assistant"}],sK={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",sync:"right",assistant:"right"},n80="mdcc-panel-sides",r80="mdcc-layers-mode";function a80({side:J,width:X,open:Q,ids:Y,activeId:W,onPick:G,children:Z,labels:H=null}){return D("div",{className:"st-dockslot st-dockslot--"+J+(Q?"":" is-collapsed"),style:{width:Q?X:0,flexBasis:Q?X:0},children:[Q&&Y.length>1&&z("div",{className:"st-docktabs",role:"tablist","aria-label":J+" panels",children:Y.map((K)=>z("button",{type:"button",role:"tab","data-testid":`dock-tab-${K}`,"aria-selected":W===K,className:"st-docktab"+(W===K?" is-active":""),onClick:()=>G(K),children:H?.[K]||(Gk.find((U)=>U.id===K)||{}).label||K},K))}),Z]})}var y5=/\.(tsx|html?)$/i,UF0=[[/\.md$/i,"markdown"],[/\.(css|json|txt|ya?ml)$/i,"text"],[/\.(svg|png|jpe?g|gif|webp|avif)$/i,"image"],[/\.(mp4|webm|mov)$/i,"video"],[/\.(mp3|wav|ogg|m4a)$/i,"audio"],[/\.(woff2?|ttf|otf)$/i,"font"]];function NL(J){for(let[X,Q]of UF0)if(X.test(J))return Q;return null}function Bq(J){return J.replace(/^\.[^/]+\//,"").replace(y5,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}function VF0(J){let X=[];return function Q(Y){for(let W of Y||[])X.push(W?.id??""),Q(W?.children)}(J),X.join(",")}var Zk="1.4.4";function WL(J,X){let Q=()=>{try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(J,{body:X})}catch{}};if(G9()){O7("send_notification",{title:J,body:X}).catch(Q);return}Q()}function qF0(){if(typeof window>"u")return"dark";try{let J=localStorage.getItem(A90);if(J==="light"||J==="dark")return J}catch{}return"dark"}function IH(J,X){if(typeof window>"u")return X;try{let Q=localStorage.getItem(J);if(Q==="1")return!0;if(Q==="0")return!1}catch{}return X}function Xk(J,X){if(typeof window>"u")return X;try{let Q=localStorage.getItem(J);return Q?JSON.parse(Q):X}catch{return X}}function BF0(J){if(J.kind==="runtime")return!1;if(J.label==="Design system")return!1;return!0}function Y4(J){return J.split("/").pop()}function f8(J,X=!1,Q){P5({title:J,kind:X?"success":"error",action:Q})}var s80="maude-mode-hint-seen";function HL(J=!1){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(s80)==="1")return}catch{return}if(HL.active)return;HL.active=!0;let X=()=>{HL.active=!1;try{localStorage.setItem(s80,"1")}catch{}document.removeEventListener("keydown",Q,!0)},Q=(Y)=>{if((Y.key==="v"||Y.key==="V")&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey)$W("mode-hint"),X()};if(J)document.addEventListener("keydown",Q,!0);P5({id:"mode-hint",title:J?"Your mock is live":"You’re in Edit",description:J?"Click things to try it. Press V to select & inspect.":"Click selects, like Figma. Switch to Preview in the toolbar to use the live mock.",onDismiss:X})}function VY(J){return J.replace(y5,"")}function NF0(J){return J.replace(y5,"")}function FF0(J){let X=new Map;for(let G of J){if(!y5.test(G.name))continue;let Z=NF0(G.name);if(!X.has(Z)||/\.tsx$/i.test(G.name))X.set(Z,G)}let Q=new Map,Y=[];for(let G of J){if(y5.test(G.name))continue;let Z=null;for(let H of X.keys()){if(G.name===H)continue;if(G.name.startsWith(`${H}.`)){if(!Z||H.length>Z.length)Z=H}}if(Z){let H=Q.get(Z)||[];H.push(G),Q.set(Z,H)}else Y.push(G)}let W=[];for(let[G,Z]of X){let H=(Q.get(G)||[]).sort((K,U)=>K.name.localeCompare(U.name));W.push({primary:Z,sidecars:H,orphan:!1})}return W.sort((G,Z)=>G.primary.name.localeCompare(Z.primary.name)),Y.sort((G,Z)=>G.name.localeCompare(Z.name)),{canvases:W,orphans:Y.map((G)=>({primary:G,sidecars:[],orphan:!0}))}}function LF0(J,X,Q){let Y={};for(let W of Q||[]){let Z=(W.startsWith(X)?W.slice(X.length).replace(/^\/+/,""):W).split("/").filter(Boolean),H=Y;for(let K of Z)H=H[K]=H[K]||{};H._files=H._files||[]}for(let W of J){let Z=(W.startsWith(X)?W.slice(X.length).replace(/^\/+/,""):W).split("/"),H=Y;for(let K=0;K<Z.length;K++){let U=Z[K];if(K===Z.length-1)H._files=H._files||[],H._files.push({name:U,path:W});else H[U]=H[U]||{},H=H[U]}}return Y}function _90(J,X){if(!X)return J;let Q=X.toLowerCase(),Y={},W=!1,G=Object.keys(J).filter((Z)=>Z!=="_files");for(let Z of G){let H=_90(J[Z],X);if(H)Y[Z]=H,W=!0}if(J._files){let Z=J._files.filter((H)=>H.name.toLowerCase().includes(Q)||H.path.toLowerCase().includes(Q));if(Z.length)Y._files=Z,W=!0}return W?Y:null}function zL(J){return(J||[]).filter((X)=>X.status!=="resolved").length}function DF0(J){if(!J)return"";let X=new Date(J).getTime();if(!X)return"";let Q=Math.max(0,Math.floor((Date.now()-X)/1000));if(Q<60)return Q+"s";let Y=Math.floor(Q/60);if(Y<60)return Y+"m";let W=Math.floor(Y/60);if(W<24)return W+"h";let G=Math.floor(W/24);if(G<7)return G+"d";return new Date(J).toLocaleDateString()}function w90(J){let X=0,Q=0,Y=0;for(let W of Object.values(J||{}))for(let G of W||[])if(X++,G.status==="resolved")Y++;else Q++;return{all:X,open:Q,resolved:Y}}function UL({d:J,size:X=14,color:Q}){return z("svg",{width:X,height:X,viewBox:"0 0 24 24",fill:"none",stroke:Q||"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{flex:"none"},children:z("path",{d:J})})}var MF0={"chevron-down":z("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":z("polyline",{points:"6 3.5 10.5 8 6 12.5"}),file:D(Q0,{children:[z("path",{d:"M4 2h5l3 3v9H4z"}),z("polyline",{points:"9 2 9 5 12 5"})]}),folder:z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),"folder-plus":D(Q0,{children:[z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),z("path",{d:"M8 7.5v3.5M6.25 9.25h3.5"})]}),lock:D(Q0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015 0v2"})]}),unlock:D(Q0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015-.7"})]}),search:D(Q0,{children:[z("circle",{cx:"7",cy:"7",r:"4"}),z("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:D(Q0,{children:[z("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),z("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),check:z("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),x:D(Q0,{children:[z("line",{x1:"4.3",y1:"4.3",x2:"11.7",y2:"11.7"}),z("line",{x1:"11.7",y1:"4.3",x2:"4.3",y2:"11.7"})]}),sun:D(Q0,{children:[z("circle",{cx:"8",cy:"8",r:"2.6"}),z("line",{x1:"8",y1:"1.5",x2:"8",y2:"3"}),z("line",{x1:"8",y1:"13",x2:"8",y2:"14.5"}),z("line",{x1:"1.5",y1:"8",x2:"3",y2:"8"}),z("line",{x1:"13",y1:"8",x2:"14.5",y2:"8"}),z("line",{x1:"3.4",y1:"3.4",x2:"4.4",y2:"4.4"}),z("line",{x1:"11.6",y1:"11.6",x2:"12.6",y2:"12.6"}),z("line",{x1:"12.6",y1:"3.4",x2:"11.6",y2:"4.4"}),z("line",{x1:"4.4",y1:"11.6",x2:"3.4",y2:"12.6"})]}),moon:z("path",{d:"M12.5 9.6A5 5 0 1 1 7 3a4 4 0 0 0 5.5 6.6z"}),sparkle:z("path",{d:"M8 1.8l1.4 4.8L14 8l-4.6 1.4L8 14.2l-1.4-4.8L2 8l4.6-1.4z",fill:"currentColor",stroke:"none"}),megaphone:D(Q0,{children:[z("path",{d:"M2 6.7 11 4v8L2 9.3z"}),z("path",{d:"M11 5.2a2.4 2.4 0 0 1 0 5.6"}),z("path",{d:"M4.3 9.5v2.3a1.2 1.2 0 0 0 2.4 0v-1.7"})]}),bug:D(Q0,{children:[z("circle",{cx:"8",cy:"9",r:"3.6"}),z("circle",{cx:"8",cy:"4.4",r:"1.3"}),z("path",{d:"M6.2 3.4 5.2 2M9.8 3.4l1-1.4"}),z("path",{d:"M4.6 7.6H2.2M4.6 9H2.2M4.6 10.6H2.5M11.4 7.6h2.4M11.4 9h2.4M11.4 10.6h2.3"})]}),"panel-left":D(Q0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("line",{x1:"6.4",y1:"3",x2:"6.4",y2:"13"})]}),resolve:D(Q0,{children:[z("circle",{cx:"8",cy:"8",r:"5.6"}),z("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:D(Q0,{children:[z("path",{d:"M3.2 8a5 5 0 1 1 1.4 3.5"}),z("polyline",{points:"3.2 11.4 3.2 8 6.6 8"})]}),layers:D(Q0,{children:[z("polygon",{points:"8 2.2 13.8 5.5 8 8.8 2.2 5.5"}),z("polyline",{points:"2.2 9 8 12.3 13.8 9"})]}),box:z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.2"}),type:D(Q0,{children:[z("polyline",{points:"4 4 12 4"}),z("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:D(Q0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"3"}),z("line",{x1:"6",y1:"8",x2:"10",y2:"8"})]}),input:D(Q0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"1.2"}),z("line",{x1:"5",y1:"8",x2:"5",y2:"8"})]}),link:D(Q0,{children:[z("path",{d:"M6.5 9.5a2.5 2.5 0 0 1 0-3.5l1.5-1.5a2.5 2.5 0 0 1 3.5 3.5l-1 1"}),z("path",{d:"M9.5 6.5a2.5 2.5 0 0 1 0 3.5l-1.5 1.5a2.5 2.5 0 0 1-3.5-3.5l1-1"})]}),list:D(Q0,{children:[z("line",{x1:"6",y1:"4.5",x2:"13",y2:"4.5"}),z("line",{x1:"6",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6",y1:"11.5",x2:"13",y2:"11.5"}),z("circle",{cx:"3.2",cy:"4.5",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"8",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"11.5",r:"0.8",fill:"currentColor"})]}),eye:D(Q0,{children:[z("path",{d:"M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z"}),z("circle",{cx:"8",cy:"8",r:"2"})]}),eyedropper:D(Q0,{children:[z("path",{d:"M11 2.6a1.7 1.7 0 0 1 2.4 2.4l-1.2 1.2-2.4-2.4z"}),z("path",{d:"M9.5 4.6 4 10.1V12h1.9l5.5-5.5"})]}),"p-corner":z("path",{d:"M3.5 12.5V7a3.5 3.5 0 0 1 3.5-3.5h5.5"}),"p-opacity":D(Q0,{children:[z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.5"}),z("path",{d:"M3 8h10M8 3v10",strokeWidth:"0.9",opacity:"0.55"})]}),"p-lineheight":D(Q0,{children:[z("line",{x1:"6.5",y1:"4",x2:"13",y2:"4"}),z("line",{x1:"6.5",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6.5",y1:"12",x2:"13",y2:"12"}),z("path",{d:"M3.2 4.6 3.2 11.4M2 6 3.2 4.5 4.4 6M2 10 3.2 11.5 4.4 10"})]}),"p-letterspacing":D(Q0,{children:[z("path",{d:"M3 4v8M13 4v8"}),z("path",{d:"M6 11.5 8 5l2 6.5M6.7 9.3h2.6",strokeWidth:"1.1"})]}),"p-gap":D(Q0,{children:[z("rect",{x:"2",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("rect",{x:"10.4",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("path",{d:"M6.8 8h2.4M7.4 6.9 6.4 8l1 1.1M8.6 6.9 9.6 8l-1 1.1",strokeWidth:"1"})]}),"p-border":z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"}),"p-size":D(Q0,{children:[z("path",{d:"M3 13 6.6 3l3.6 10"}),z("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":D(Q0,{children:[z("path",{d:"M6.3 4A6.7 6.7 0 0 1 8 3.5C12 3.5 14.5 8 14.5 8a12 12 0 0 1-2 2.4M4.4 5.3A12 12 0 0 0 1.5 8S4 12.5 8 12.5a6.5 6.5 0 0 0 2.1-.35"}),z("line",{x1:"2.5",y1:"2.5",x2:"13.5",y2:"13.5"})]}),sliders:D(Q0,{children:[z("line",{x1:"3",y1:"5",x2:"13",y2:"5"}),z("circle",{cx:"6",cy:"5",r:"1.7",fill:"currentColor"}),z("line",{x1:"3",y1:"11",x2:"13",y2:"11"}),z("circle",{cx:"10",cy:"11",r:"1.7",fill:"currentColor"})]}),code:D(Q0,{children:[z("polyline",{points:"6 5 3 8 6 11"}),z("polyline",{points:"10 5 13 8 10 11"})]}),download:D(Q0,{children:[z("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),z("polyline",{points:"4.5 7 8 10.5 11.5 7"}),z("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),reload:D(Q0,{children:[z("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),z("path",{d:"M14 2v3.33h-3.33"})]}),help:D(Q0,{children:[z("circle",{cx:"8",cy:"8",r:"6"}),z("path",{d:"M6.3 6.2a1.8 1.8 0 1 1 2.3 1.9c-.5.2-.6.5-.6 1v.3"}),z("line",{x1:"8",y1:"11.4",x2:"8",y2:"11.5"})]}),image:D(Q0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("circle",{cx:"6",cy:"6.3",r:"1.1"}),z("path",{d:"M3 12l3-2.8 2.2 1.8 2.4-3L13.5 12"})]}),vector:D(Q0,{children:[z("path",{d:"M3.6 11.2C6 5 10 5 12.4 11.2"}),z("rect",{x:"1.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"11.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"6.7",y:"2.6",width:"2.6",height:"2.6",rx:"0.4"})]}),presentation:D(Q0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"7.4",rx:"1"}),z("line",{x1:"8",y1:"10.4",x2:"8",y2:"13"}),z("line",{x1:"5.6",y1:"13.4",x2:"10.4",y2:"13.4"})]}),archive:D(Q0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"3",rx:"0.8"}),z("path",{d:"M3.6 6v6.2a1 1 0 0 0 1 1h6.8a1 1 0 0 0 1-1V6"}),z("line",{x1:"6.6",y1:"8.8",x2:"9.4",y2:"8.8"})]}),external:D(Q0,{children:[z("path",{d:"M11 8.5V12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h3.5"}),z("polyline",{points:"9.5 3 13 3 13 6.5"}),z("line",{x1:"13",y1:"3",x2:"7.6",y2:"8.4"})]}),share:D(Q0,{children:[z("circle",{cx:"4",cy:"8",r:"1.9"}),z("circle",{cx:"11.6",cy:"3.6",r:"1.9"}),z("circle",{cx:"11.6",cy:"12.4",r:"1.9"}),z("line",{x1:"5.7",y1:"7",x2:"9.9",y2:"4.6"}),z("line",{x1:"5.7",y1:"9",x2:"9.9",y2:"11.4"})]}),pen:D(Q0,{children:[z("path",{d:"M3 13l.8-3L10.6 3.2a1.1 1.1 0 0 1 1.6 0l.6.6a1.1 1.1 0 0 1 0 1.6L6 12.2z"}),z("line",{x1:"9.6",y1:"4.2",x2:"11.8",y2:"6.4"})]}),square:z("rect",{x:"3.5",y:"3.5",width:"9",height:"9",rx:"1"})};function OF0({open:J,onClose:X,actions:Q}){let[Y,W]=u.useState(""),[G,Z]=u.useState(0),H=u.useRef(null);u.useEffect(()=>{if(J)W(""),Z(0)},[J]),u.useEffect(()=>{H.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[G]);let K=u.useMemo(()=>i2(Q,Y),[Y,Q]);if(u.useEffect(()=>{if(G>=K.length)Z(0)},[K.length,G]),!J)return null;let U=(V)=>{X(),V.run()};return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(V)=>{if(V.target===V.currentTarget)X()},children:D("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[D("div",{className:"st-pal-search",children:[z(T9,{name:"search",size:18}),z("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(V)=>W(V.target.value),onKeyDown:(V)=>{if(V.key==="Escape")V.preventDefault(),X();else if(V.key==="ArrowDown")V.preventDefault(),Z((B)=>Math.min(K.length-1,B+1));else if(V.key==="ArrowUp")V.preventDefault(),Z((B)=>Math.max(0,B-1));else if(V.key==="Enter"){V.preventDefault();let B=Tb(Q,Y,V.currentTarget.value,G);if(B)U(B)}}}),z(CJ,{children:"⌘K"})]}),z("div",{className:"st-pal-list",ref:H,children:K.length===0?z("div",{className:"st-pal-empty",children:"No matching command."}):K.map((V,B)=>{let N=V.group&&(B===0||K[B-1].group!==V.group)?z("div",{className:"st-pal-group",children:V.group},"g-"+V.group):null;return D(Q0,{children:[N,D("button",{type:"button",className:"st-pal-item"+(B===G?" is-active":""),onMouseEnter:()=>Z(B),onClick:()=>U(V),children:[z("span",{className:"st-pal-icon",children:z(T9,{name:V.icon,size:15})}),z("span",{className:"st-pal-label",children:V.label}),V.kbd?z("span",{className:"st-pal-kbd",children:z(CJ,{children:V.kbd})}):null]})]},V.id)})})]})})}function T9({name:J,size:X=16,className:Q}){return z("svg",{className:Q,width:X,height:X,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:MF0[J]})}function AF0(J){if(!J||typeof J!=="string")return"?";let X=J.trim().split(/[\s._-]+/).filter(Boolean);if(!X.length)return"?";if(X.length===1)return X[0].slice(0,2).toUpperCase();return((X[0][0]||"")+(X[X.length-1][0]||"")).toUpperCase()||"?"}function t80({initials:J,hue:X,title:Q,pulse:Y}){return z("span",{className:"st-avatar"+(Y?" is-pulsing":""),style:{"--av-hue":X},"data-tip":Q,"aria-label":Q,children:J})}function CJ({children:J}){return z("span",{className:"kbd",children:J})}function e80(J,{min:X,max:Q,def:Y}){let W=u.useCallback((K)=>Math.min(Q,Math.max(X,K)),[X,Q]),[G,Z]=u.useState(()=>{try{let K=parseInt(localStorage.getItem(J)||"",10);return Number.isFinite(K)?W(K):Y}catch{return Y}});u.useEffect(()=>{try{localStorage.setItem(J,String(G))}catch{}},[J,G]);let H=u.useCallback((K)=>Z((U)=>W(typeof K==="function"?K(U):K)),[W]);return{w:G,setW:H,min:X,max:Q,def:Y}}function J90({label:J,size:X,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:K,def:U}=X,V=W==="rtl"?-1:1;return z("div",{className:"st-grip"+(Y?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":J,"aria-valuemin":H,"aria-valuemax":K,"aria-valuenow":Math.round(G),onPointerDown:Q,onDoubleClick:()=>Z(U),onKeyDown:(B)=>{let N=B.shiftKey?24:8;if(B.key==="ArrowRight")B.preventDefault(),Z((F)=>F+N*V);else if(B.key==="ArrowLeft")B.preventDefault(),Z((F)=>F-N*V);else if(B.key==="Home")B.preventDefault(),Z(H);else if(B.key==="End")B.preventDefault(),Z(K)},children:D("svg",{className:"st-grip-dots",viewBox:"0 0 6 18","aria-hidden":"true",children:[z("circle",{cx:"3",cy:"3",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"9",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"15",r:"1.1",fill:"currentColor"})]})})}var Qk=[{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}],X90={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},_F0=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],Kq=[{id:"1x",label:"1× (native)",kind:"scale",value:1},{id:"2x",label:"2× (retina)",kind:"scale",value:2},{id:"3x",label:"3× (max)",kind:"scale",value:3},{id:"dpi150",label:"150 dpi",kind:"dpi",value:150},{id:"dpi300",label:"300 dpi (print)",kind:"dpi",value:300},{id:"dpi600",label:"600 dpi (high-res print)",kind:"dpi",value:600}],wF0="2x",Q90=[{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}],EF0="auto",Y90=[{id:"keep",label:"Keep selectable (default)",description:"Text stays selectable and searchable. You are warned if a font came out unprintable."},{id:"embed",label:"Verify fonts embedded",description:"Same file, but the export fails instead of shipping a font a print shop would reject."},{id:"outline",label:"Convert to outlines (print-safe)",description:"Every glyph becomes a vector path — no fonts left to break. Text is no longer selectable "+"and the file can grow a lot. Needs Ghostscript installed locally; cloud workspaces have it."}],PF0="keep",IF0={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 TF0(J){let X=String(J||"").split(".").pop()?.toLowerCase();return IF0[X]||"application/octet-stream"}function kF0({designRel:J,onPick:X,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[Z,H]=u.useState(null),[K,U]=u.useState(!1),[V,B]=u.useState(null),[N,F]=u.useState(()=>new Set),[M,A]=u.useState({}),[E,w]=u.useState(W?"artboard":"annotation");u.useEffect(()=>{let f=!0;return fetch("/_api/assets").then((h)=>h.json()).then((h)=>{if(!f)return;let p=h.ok?h.assets:[];H(p),A((v)=>{let r={...v};for(let e of p)r[e.path]=e.kind;return r})}).catch(()=>f&&H([])),()=>{f=!1}},[]),u.useEffect(()=>{let f=(h)=>{if(h.key==="Escape")h.stopPropagation(),Q()};return window.addEventListener("keydown",f,!0),()=>window.removeEventListener("keydown",f,!0)},[Q]);let O=Array.from(N).some((f)=>(M[f]||"image")!=="image"),I=!W||O,k=!W?"No artboard on this canvas":O?"Video/audio can only be added as annotations":"";u.useEffect(()=>{if(I&&E==="artboard")w("annotation")},[I,E]);let R=(f)=>{F((h)=>{let p=new Set(h);if(p.has(f))p.delete(f);else p.add(f);return p})},$=async(f)=>{let h=await fetch("/_api/asset",{method:"POST",headers:{"content-type":f.type||"application/octet-stream"},body:f}),p=await h.json().catch(()=>({}));if(h.ok&&p.path)return{ok:!0,path:p.path};return{ok:!1,error:p.error||`upload failed (HTTP ${h.status})`}},C=async(f)=>{if(!f)return;U(!0),B(null);let h=await $(f);if(U(!1),h.ok)X(h.path);else B(h.error)},j=(f)=>{if(typeof f==="string"&&f.startsWith("video/"))return"video";if(typeof f==="string"&&f.startsWith("audio/"))return"audio";return"image"},x=async(f)=>{if(!f.length)return;U(!0),B(null);let h=await Promise.all(f.map((r)=>$(r).then((e)=>({...e,file:r}))));U(!1);let p=h.filter((r)=>r.ok),v=h.length-p.length;if(v>0)B(`${v} of ${h.length} uploads failed`);if(p.length)A((r)=>{let e={...r};for(let c of p)e[c.path]=j(c.file.type);return e}),F((r)=>{let e=new Set(r);for(let c of p)e.add(c.path);return e})},m=async()=>{U(!0),B(null);try{if(Y){let p=(await Vh()||[]).map((v)=>new File([new Uint8Array(v.bytes)],v.name,{type:TF0(v.name)}));if(U(!1),p.length)await x(p);return}let f=await lZ();if(f?.bytes){await C(new Blob([new Uint8Array(f.bytes)]));return}}catch(f){B(f?.message||"open failed")}U(!1)},d=()=>{if(G9()){m();return}let f=document.createElement("input");if(f.type="file",f.accept="image/*,video/*",Y)f.multiple=!0;f.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(f);let h=()=>{if(f.isConnected)f.remove()};window.addEventListener("focus",()=>setTimeout(h,300),{once:!0}),f.addEventListener("change",()=>{let p=f.files?Array.from(f.files):[];if(h(),!p.length)return;if(Y)x(p);else C(p[0])}),f.click()},a=(f)=>`/${J}/${f}`;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(f)=>{if(f.target===f.currentTarget)Q()},children:D("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[D("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Choose media"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:Q,children:z(T9,{name:"x",size:15})})]}),D("div",{className:"st-dialog-bd",children:[D("div",{className:"st-ap-toolbar",children:[z("button",{type:"button",className:"st-btn",onClick:d,disabled:K,children:K?"Uploading…":"Upload…"}),V&&z("span",{className:"st-ap-err",children:V})]}),z("div",{className:"st-ap-grid",children:Z==null?z("div",{className:"st-ap-empty",children:"Loading…"}):Z.length===0?z("div",{className:"st-ap-empty",children:"No assets yet — upload one."}):Z.map((f)=>{let h=Y&&N.has(f.path);return D("button",{type:"button",className:"st-ap-cell","data-selected":h?"true":void 0,"aria-pressed":Y?h:void 0,title:`${f.name} · ${Math.max(1,Math.round(f.size/1024))} KB`,onClick:()=>Y?R(f.path):X(f.path),children:[Y&&z("span",{className:"st-ap-check","aria-hidden":"true",children:h?z(T9,{name:"check",size:12}):null}),f.kind==="video"?z("video",{className:"st-ap-thumb",src:a(f.path),muted:!0,playsInline:!0}):z("img",{className:"st-ap-thumb",src:a(f.path),alt:f.name,loading:"lazy"}),z("span",{className:"st-ap-name",children:f.name})]},f.path)})})]}),Y&&N.size>0&&D("div",{className:"st-dialog-ft st-ap-confirm",children:[D("span",{className:"st-ap-count",children:[N.size," selected"]}),D("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":E==="artboard",disabled:I,onClick:()=>w("artboard"),children:"Add to artboard"}),z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":E==="annotation",onClick:()=>w("annotation"),children:"Add as annotation"})]}),I&&z("span",{className:"st-ap-dest-note",children:k}),z("span",{className:"st-ap-confirm-spacer"}),z("button",{type:"button",className:"btn btn--ghost",onClick:Q,children:"Cancel"}),z("button",{type:"button",className:"btn btn--primary",onClick:()=>G?.(Array.from(N),E),children:"Insert"})]})]})})}function VL(J,X){let Q=URL.createObjectURL(X),Y=document.createElement("a");Y.href=Q,Y.download=J||"export",document.body.appendChild(Y),Y.click(),Y.remove(),setTimeout(()=>URL.revokeObjectURL(Q),1e4)}function RF0({mode:J,initialScope:X,activePath:Q,hasComps:Y=!1,comps:W=[],activeArtboardId:G=null,selection:Z=null,exportLane:H="local",onBrowserCapture:K=null,onClose:U}){let V=u.useCallback((I0)=>H==="none"&&!I0.handoff&&I0.format!=="zip"&&!gb.has(I0.format)||H!=="local"&&I0.format==="canva",[H]),[B,N]=u.useState(J==="handoff"?"shadcn":"png"),[F,M]=u.useState(()=>X&&Rb("png",X)?X:_O("png")),[A,E]=u.useState(2),[w,O]=u.useState(wF0),[I,k]=u.useState(!0),[R,$]=u.useState(!1),[C,j]=u.useState(!1),[x,m]=u.useState(!1),[d,a]=u.useState(EF0),[f,h]=u.useState(PF0),[p,v]=u.useState(!0),[r,e]=u.useState(!1),[c,K0]=u.useState(null),[s,z0]=u.useState([]),o=Qk.find((I0)=>I0.id===B)||Qk[0],q0=o.handoff?[]:wO(o.format),Z0=900,k0=3600,a0=TK(W,mw(W,{artboardId:G})),s0=a0?.durationInFrames||0,t0=a0?.fps||30,E8=o.temporal&&s0>900,a8=o.temporal&&s0>3600;u.useEffect(()=>{if(q0.length&&!q0.includes(F))M(_O(o.format))},[q0,F,o.format]),u.useEffect(()=>{if(H!=="remote")return;fetch("/_api/export-warmup").catch(()=>{})},[H]);let F8=u.useCallback(()=>{fetch("/_api/export-history").then((I0)=>I0.json()).then((I0)=>z0(Array.isArray(I0?.history)?I0.history.slice(0,6):[])).catch(()=>{})},[]);u.useEffect(()=>{F8()},[F8]),u.useEffect(()=>{function I0(w0){if(w0.key==="Escape")w0.preventDefault(),U()}return window.addEventListener("keydown",I0),()=>window.removeEventListener("keydown",I0)},[U]);async function T8(){if(o.handoff){let W8=`/design:handoff ${Q&&Q!==r8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(W8)}catch{}K0({ok:!0,msg:`Copied: ${W8} — run it in Claude Code.`});return}if(V(o)){K0({ok:!1,msg:"This format needs the render service, which this workspace doesn’t have configured."});return}e(!0),K0(null);let I0=o.temporal?{scale:A}:{};if(o.format==="png"){let C0=Kq.find((W8)=>W8.id===w)||Kq[1];if(C0.kind==="dpi")I0.dpi=C0.value;else I0.scale=C0.value}if(o.format==="mp4"||o.format==="webm")I0.audio=p;if(a8)I0.maxFrames=s0;if(o.format==="pdf"){I0.pdfPrint={includeBleed:I,marks:{crop:C,registration:x}};let C0=Q90.find((W8)=>W8.id===d)?.value;if(C0!==void 0)I0.dpi=C0;if(f!=="keep")I0.text=f}if(G)I0.artboardId=G;if(Z?.selector)I0.selection=Z;if(Q&&Q!==r8)I0.canvasFile=Q;if($U.has(o.format)&&s2({exportLane:H,format:o.format,scope:F,artboardId:I0.artboardId})&&typeof K==="function")try{let C0=CO(I0);K0({ok:!0,msg:"Capturing…"});let W8=await K({format:o.format,artboardIds:[I0.artboardId],scale:C0,onProgress:(x8,S8)=>K0({ok:!0,msg:`Capturing ${x8}/${S8}…`})}),H8=await RO(W8,o.format);for(let x8 of H8)VL(x8.name,x8.blob);for(let x8 of H8)await $O({format:o.format,scope:F,filename:x8.name});e(!1),K0({ok:!0,msg:`Saved ${H8.map((x8)=>x8.name).join(", ")} to your downloads.`});return}catch(C0){if(H!=="remote"){K0({ok:!1,msg:`Capture failed: ${C0&&C0.message||C0}`}),e(!1);return}}if(s2({exportLane:H,format:o.format,scope:F})&&o.format==="pptx"&&typeof K==="function")try{K0({ok:!0,msg:"Capturing artboards…"});let C0=Q&&Q!==r8?Y4(Q).replace(/\.[^.]+$/,""):"export",{filename:W8,blob:H8}=await kO({capture:K,name:C0,onProgress:(x8,S8)=>K0({ok:!0,msg:`Capturing ${x8}/${S8}…`}),onAssemble:()=>K0({ok:!0,msg:"Assembling deck…"})});VL(W8,H8),await $O({format:o.format,scope:F,filename:W8}),e(!1),K0({ok:!0,msg:`Saved ${W8} to your downloads.`});return}catch(C0){if(H!=="remote"){K0({ok:!1,msg:`Deck export failed: ${C0&&C0.message||C0}`}),e(!1);return}}if(H==="none"&&$U.has(o.format)){K0({ok:!1,msg:"Without the render service this workspace exports PNG/SVG of the active artboard only — switch Scope to “Active artboard”, or ask your admin to add maude-render."}),e(!1);return}try{let C0=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:o.format,scope:F,options:I0})});if(!C0.ok){K0({ok:!1,msg:await C0.text()||`Export failed (${C0.status})`}),e(!1);return}U()}catch(C0){K0({ok:!1,msg:C0&&C0.message?C0.message:String(C0)}),e(!1)}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(I0)=>{if(I0.target===I0.currentTarget)U()},children:D("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[D("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Export & handoff"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:U,children:z(T9,{name:"x",size:15})})]}),D("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:Q&&Q!==r8?`Format · ${VY(Y4(Q))}`:"Format"}),z("div",{className:"st-fmt-grid",children:Qk.filter((I0)=>!I0.temporal||Y).map((I0)=>D("button",{type:"button","data-testid":`export-format-${I0.id}`,className:"st-fmt"+(I0.id===B?" is-on":""),disabled:V(I0),title:V(I0)?"Needs the render service — not configured on this workspace":void 0,onClick:()=>{N(I0.id),K0(null)},children:[z(T9,{name:I0.icon,size:16}),z("span",{className:"st-fmt-name",children:I0.label}),z("span",{className:"st-fmt-sub",children:I0.sub})]},I0.id))}),H==="none"&&D("div",{className:"st-dialog-note","data-testid":"export-lane-note",children:["PNG and SVG of the active artboard — and the PPTX deck — export right here in your browser; ZIP and AI handoff work too. PDF, video and other multi-artboard exports need the render service, which this workspace doesn't have configured — use the desktop app, or ask your admin to add the ",z("code",{children:" maude-render"})," service (see the self-hosting docs)."]}),!o.handoff&&D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-scope",children:"Scope"}),z("select",{id:"st-export-scope","data-testid":"export-scope",className:"st-select",value:F,onChange:(I0)=>M(I0.target.value),children:q0.map((I0)=>z("option",{value:I0,children:X90[I0]},I0))})]}),!o.handoff&&o.format==="png"&&D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-size",children:"Resolution"}),z("select",{id:"st-export-size",className:"st-select",value:w,onChange:(I0)=>O(I0.target.value),children:Kq.map((I0)=>z("option",{value:I0.id,children:I0.label},I0.id))})]}),!o.handoff&&o.format==="png"&&z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let I0=Kq.find((C0)=>C0.id===w)||Kq[1],w0=I0.kind==="dpi"?I0.value/96:I0.value;return`${I0.label} ≈ ${Math.round(1440*w0)}×${Math.round(900*w0)} for a 1440×900 artboard.`})()}),!o.handoff&&o.temporal&&D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-temporal-size",children:"Resolution"}),z("select",{id:"st-export-temporal-size",className:"st-select",value:A,onChange:(I0)=>E(Number(I0.target.value)),children:_F0.map((I0)=>z("option",{value:I0.value,children:I0.label},I0.value))})]}),!o.handoff&&o.temporal&&D("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[A,"× the artboard's native resolution (e.g. 960×540 → ",960*A,"×",540*A,")."]}),E8&&D("div",{className:"st-mono st-export-long-notice","data-testid":"export-long-comp-notice",style:{fontSize:11,color:"var(--accent)",lineHeight:1.5},children:["⚠ Long comp: ",s0," frames (≈",Math.round(s0/t0),"s).",a8?` Exceeds the default ${"3600"}-frame export cap — exporting raises the cap to the full length for this run.`:""," ","If the fast renderer falls back to frame-by-frame capture this can take several minutes; 2× resolution (≈720–1080p) is recommended for memory headroom."]}),!o.handoff&&o.format==="pdf"&&D(Q0,{children:[D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-dpi",children:"Image quality"}),z("select",{id:"st-export-pdf-dpi",className:"st-select",value:d,onChange:(I0)=>a(I0.target.value),children:Q90.map((I0)=>z("option",{value:I0.id,children:I0.label},I0.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:"The page stays vector; this only sets the capture density for raster content on it (dropped photos, large-format art)."}),D("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-text",children:"Text"}),z("select",{id:"st-export-pdf-text",className:"st-select","data-testid":"export-pdf-text",value:f,onChange:(I0)=>h(I0.target.value),children:Y90.map((I0)=>z("option",{value:I0.id,children:I0.label},I0.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:Y90.find((I0)=>I0.id===f)?.description}),z("div",{className:"st-dialog-row",children:D("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-bleed",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-pdf-bleed",type:"checkbox",checked:I,onChange:(I0)=>k(I0.target.checked)}),"Include bleed"]})}),z("div",{className:"st-dialog-row",children:D("button",{type:"button",className:"st-dialog-lbl",style:{background:"none",border:0,padding:0,cursor:"pointer"},onClick:()=>$((I0)=>!I0),"aria-expanded":R,children:[R?"▾":"▸"," Marks"]})}),R&&D("div",{style:{padding:"0 12px 4px",display:"flex",flexDirection:"column",gap:6},children:[D("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:C,onChange:(I0)=>j(I0.target.checked)}),"Crop marks"]}),D("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:x,onChange:(I0)=>m(I0.target.checked)}),"Registration marks"]})]}),D("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:["Bleed and marks apply to print (",z("code",{children:'kind="print"'}),") artboards only.",F==="canvas-as-separate"?" One PDF page per artboard.":""]})]}),!o.handoff&&(o.format==="mp4"||o.format==="webm")&&z("div",{className:"st-dialog-row",children:D("label",{className:"st-dialog-lbl",htmlFor:"st-export-audio",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-audio",type:"checkbox",checked:p,onChange:(I0)=>v(I0.target.checked)}),"Export with audio"]})}),o.handoff&&D("div",{className:"callout callout--info",style:{fontSize:12},children:["Hands the active canvas off to production. Copies"," ",z("span",{className:"st-mono",children:"/design:handoff <path>"})," — run it in Claude Code to emit a ready-to-drop production component next to the canvas."]}),c&&z("div",{className:"callout "+(c.ok?"callout--success":"callout--error"),style:{fontSize:12},"data-testid":"export-status","data-ok":c.ok?"1":"0",children:c.msg}),s.length>0&&D("div",{className:"st-export-recent","data-testid":"export-recent",children:[z("div",{className:"st-rp-hd",children:"Recent"}),s.map((I0,w0)=>D("div",{className:"st-export-recent-row",children:[D("span",{children:[String(I0.format||"").toUpperCase()," ·"," ",X90[I0.scope]||I0.scope]}),z("span",{className:"st-mono",children:I0.filename})]},w0))]})]}),D("div",{className:"st-dialog-ft",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:U,children:"Cancel"}),D("button",{type:"button",className:"btn btn--primary","data-testid":"export-submit",disabled:r,onClick:T8,children:[z(T9,{name:"download",size:14}),o.handoff?"Copy handoff command":r?"Exporting…":`Export ${o.label}`]})]})]})})}var FL=12,LL=16;function CF0({name:J,depth:X,defaultOpen:Q,children:Y,dirPath:W,drag:G,menu:Z}){let[H,K]=u.useState(Q),U=G?G.dropProps(W,!0,()=>K(!0)):{},V=G?.overDir===W,B=G?G.dragProps(W,!0):{},N=G?.draggedPath===W,F=G?.busyPath===W,M=D("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${Bq(W)}`,"aria-expanded":H,"aria-dropeffect":G?"move":void 0,"aria-busy":F||void 0,tabIndex:-1,className:"st-row"+(V?" is-drop-target":"")+(N?" is-dragging":"")+(F?" is-busy":""),style:{paddingLeft:FL+X*LL+"px"},onClick:()=>K((A)=>!A),onContextMenu:Z?(A)=>Z.openAt(A,{kind:"dir",dirPath:W}):void 0,...B,...U,children:[z("span",{className:"st-row-glyph",children:z(T9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:J})]});return D(Q0,{children:[Z?D("div",{className:"st-row-wrap",role:"none",children:[M,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${Bq(W)}`,title:`Folder actions — ${J}`,"aria-label":`Folder actions for ${J}`,"aria-haspopup":"menu",onClick:(A)=>Z.openAt(A,{kind:"dir",dirPath:W}),children:z(UL,{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 $F0({name:J,dsName:X,depth:Q,defaultOpen:Y,active:W,onOpenSystem:G,children:Z}){let[H,K]=u.useState(Y);return D(Q0,{children:[D("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:FL+Q*LL+"px"},role:"treeitem","aria-expanded":H,children:[z("button",{type:"button",className:"st-ds-chev",onClick:()=>K((U)=>!U),"aria-label":H?"Collapse design system":"Expand design system",title:H?"Collapse":"Expand",children:z(T9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),D("button",{type:"button",className:"st-ds-open",onClick:()=>G(X),"aria-label":`Open ${X} design system view`,title:"Open the design system view",children:[z("span",{className:"st-row-glyph",children:z(T9,{name:"folder",size:13})}),z("span",{className:"st-row-name",children:J})]})]}),H&&Z]})}function qL({file:J,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,onDelete:G,openCount:Z,depth:H,kind:K,sidecar:U,dirty:V,experimentalKind:B,drag:N,menu:F}){let M=J.path===X||J.path===Q,A=y5.test(J.name),E=!A&&K!=="runtime"?NL(J.name):null,w=!A&&!E,O=A?VY(J.name):J.name,I=A&&typeof G==="function"&&K!=="runtime",k=A&&!U&&K!=="runtime"&&typeof N<"u",R=k?N.dragProps(J.path,!0):{},$=N?.draggedPath===J.path,C=N?.busyPath===J.path,j=k&&typeof F<"u",x=!A&&!!E&&!U&&typeof F<"u",m=typeof F<"u"&&K!=="runtime",d=J.path.split("/").slice(0,-1).join("/"),a=A?"canvas-row-"+J.path.replace(/^\.[^/]+\//,"").replace(y5,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,f=D("button",{type:"button",role:"treeitem","data-testid":a??(x?`file-row-${Bq(J.path)}`:void 0),"aria-selected":M,"aria-disabled":w?"true":void 0,"aria-busy":C||void 0,tabIndex:M?0:-1,className:"st-row"+(M?" is-sel":"")+(K==="runtime"?" is-muted":"")+($?" is-dragging":"")+(C?" is-busy":""),style:{paddingLeft:FL+H*LL+"px"},title:J.path+(Z?` — ${Z} open`:w?" (file index only)":""),onClick:()=>{if(A)Y(J.path);else if(E)W?.(J.path)},onContextMenu:m?(h)=>F.openAt(h,{kind:"file",path:J.path,dir:d,canMove:j||x,supporting:x,name:J.name}):void 0,...R,children:[z("span",{className:"st-row-glyph",children:z(T9,{name:"file",size:13})}),z("span",{className:"st-row-name",children:O}),B==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),B==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),V&&z("span",{className:"st-git-badge","data-kind":V,title:`Unsaved (${V})`,"aria-label":`Unsaved, ${V}`,children:V}),Z>0&&z("span",{className:"st-row-badge",children:Z})]});if(!I&&!m)return f;return D("div",{className:"st-row-wrap",role:"none",children:[f,m&&z("button",{type:"button",className:"st-row-menu-btn"+(I?" has-delete-sibling":""),"data-testid":`tree-row-menu-${Bq(J.path)}`,title:`Actions for ${O}`,"aria-label":`Actions for ${O}`,"aria-haspopup":"menu",onClick:(h)=>F.openAt(h,{kind:"file",path:J.path,dir:d,canMove:j||x,supporting:x,name:J.name}),children:z(UL,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})}),I&&z("button",{type:"button",className:"st-row-del",title:`Delete ${O}`,"aria-label":`Delete canvas ${O}`,onClick:(h)=>{h.stopPropagation(),G(J.path,O)},children:z(UL,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})}function SF0({primary:J,sidecars:X,depth:Q,kind:Y,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,showHidden:V,forceOpen:B,dirtyByPath:N,experimentalKind:F,drag:M,menu:A}){let E=N?.get(J.path),w=X.length>0,[O,I]=u.useState(!1),k=B||O,R=J.path===W;if(!(w&&V))return z(qL,{file:J,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,depth:Q,kind:Y,dirty:E,experimentalKind:F,drag:M,menu:A});let C=typeof M<"u",j=C?M.dragProps(J.path,!0):{},x=M?.draggedPath===J.path,m=M?.busyPath===J.path,d=C&&typeof A<"u",a=typeof A<"u"&&Y!=="runtime",f=J.path.split("/").slice(0,-1).join("/"),h=D("button",{type:"button",role:"treeitem","aria-selected":R,"aria-expanded":k,"aria-busy":m||void 0,tabIndex:R?0:-1,className:"st-row st-canvas-row"+(R?" is-sel":"")+(x?" is-dragging":"")+(m?" is-busy":""),style:{paddingLeft:FL+Q*LL+"px"},title:J.path,onClick:(p)=>{if(p.target.closest(".st-canvas-chev")){I((v)=>!v);return}Z(J.path)},onContextMenu:a?(p)=>A.openAt(p,{kind:"file",path:J.path,dir:f,canMove:d}):void 0,...j,children:[z("span",{className:"st-row-glyph st-canvas-chev",onClick:(p)=>{p.stopPropagation(),I((v)=>!v)},children:z(T9,{name:"chevron-right",className:"st-chev"+(k?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:VY(J.name)}),F==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),F==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),E&&z("span",{className:"st-git-badge","data-kind":E,title:`Unsaved (${E})`,"aria-label":`Unsaved, ${E}`,children:E}),U>0&&z("span",{className:"st-row-badge",children:U})]});return D(Q0,{children:[a?D("div",{className:"st-row-wrap",role:"none",children:[h,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${Bq(J.path)}`,title:`Actions for ${VY(J.name)}`,"aria-label":`Actions for ${VY(J.name)}`,"aria-haspopup":"menu",onClick:(p)=>A.openAt(p,{kind:"file",path:J.path,dir:f,canMove:d}),children:z(UL,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})})]}):h,k&&X.map((p)=>z(qL,{file:p,menu:A,activePath:W,previewPath:G,onOpen:Z,onPreview:H,openCount:0,depth:Q+1,kind:Y,sidecar:!0},p.path))]})}function E90({node:J,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z=1,kind:H,showHidden:K,search:U,dsFolders:V,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:M,canvasKinds:A,dirPath:E="",drag:w,menu:O}){let I=Object.keys(J).filter((d)=>d!=="_files").sort(),k=J._files||[],{canvases:R,orphans:$}=u.useMemo(()=>FF0(k),[k]),{mediaOrphans:C,metaOrphans:j}=u.useMemo(()=>{let d=[],a=[];for(let f of $){let h=NL(f.primary.name);(h==="image"||h==="video"||h==="audio"||h==="font"?d:a).push(f)}return{mediaOrphans:d,metaOrphans:a}},[$]),x=!!(U&&U.trim()),m=u.useMemo(()=>{if(!V||Z!==1)return null;let d=new Map;for(let a of V)d.set(a.folder,a);return d},[V,Z]);return D(Q0,{children:[R.map((d)=>{let a=x&&d.sidecars.some((f)=>{let h=U.toLowerCase();return f.name.toLowerCase().includes(h)||f.path.toLowerCase().includes(h)});return z(SF0,{primary:d.primary,sidecars:d.sidecars,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,onDelete:F,openCount:zL(G[d.primary.path]),depth:Z,kind:H,showHidden:K,forceOpen:a,dirtyByPath:M,experimentalKind:A?.[d.primary.path],drag:w,menu:O},d.primary.path)}),C.map((d)=>z(qL,{file:d.primary,menu:O,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,openCount:zL(G[d.primary.path]),depth:Z,kind:H},d.primary.path)),K&&j.map((d)=>z(qL,{file:d.primary,menu:O,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,openCount:zL(G[d.primary.path]),depth:Z,kind:H},d.primary.path)),I.map((d)=>{let a=m?.get(d),f=E?`${E}/${d}`:d,h=z(E90,{node:J[d],activePath:X,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z+1,kind:H,showHidden:K,search:U,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:M,canvasKinds:A,dirPath:f,drag:w,menu:O});if(a&&N)return z($F0,{name:d,dsName:a.name,depth:Z,defaultOpen:!0,active:X===r8&&a.name===B,onOpenSystem:N,children:h},d);return z(CF0,{name:d,depth:Z,defaultOpen:!0,dirPath:f,drag:w,menu:w?O:void 0,children:h},d)})]})}var GL={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function bF0(J){if(J.kind==="project")return GL.project;if(J.kind==="runtime")return GL.runtime;if(J.label==="Design system")return GL.ds;if(J.label==="UI kit")return GL.canvas;return{title:J.label.toUpperCase(),pillFromCount:!0}}function yF0({readOnly:J=!1,cloud:X,groups:Q,activePath:Y,previewPath:W,activeDsName:G,onOpen:Z,onPreview:H,onOpenSystem:K,wsConnected:U,search:V,setSearch:B,commentsByFile:N,showHidden:F,sectionsExpanded:M,onToggleSection:A,onNewBoard:E,onDeleteBoard:w,onRefresh:O,refreshing:I,collapsed:k,onCollapse:R,width:$,resizing:C,dirtyByPath:j,project:x,gitBranch:m,remoteSync:d,onGetLatest:a,canvasKinds:f,onMoveCanvas:h,onNewFolder:p,onDeleteFolder:v,onRenameFolder:r,onRenameCanvas:e,onDuplicateCanvas:c,onDeleteFile:K0,syncStatus:s,onLinkedHub:z0,onLocalProject:o,onOpenLinkedFile:q0,filesReady:Z0,onShare:k0,savingIsManaged:a0=!1}){let s0=u.useMemo(()=>{if(!V)return Q;return Q.map((b0)=>({...b0,tree:_90(b0.tree,V),filtered:!!V}))},[Q,V]),t0=lb(h),E8=ub(),a8=u.useMemo(()=>{let b0=[];for(let X8 of Q){if(X8.label==="Design system"||X8.kind!=="canvas")continue;let q8=X8.fullPath.replace(/^\.[^/]+\//,"")||X8.fullPath;b0.push({path:X8.fullPath,label:q8});for(let l0 of X8.dirs||[])b0.push({path:l0,label:l0.replace(/^\.[^/]+\//,"")})}return b0},[Q]),F8=E8.state?.extra,T8=F8?.kind==="file"?[{id:"share",label:"Share…",onSelect:()=>{E8.close(),k0(F8.path)}},...e&&/\.tsx$/i.test(F8.path)?[{id:"rename-canvas",label:"Rename…",onSelect:()=>{E8.close();let b0=VY(F8.path.split("/").pop()),X8=window.prompt("Rename canvas to:",b0);if(X8?.trim()&&X8.trim()!==b0)e(F8.path,X8.trim())}}]:[],...c&&/\.tsx$/i.test(F8.path)?[{id:"duplicate-canvas",label:"Duplicate",onSelect:()=>{E8.close(),c(F8.path)}}]:[],...F8.supporting&&e?[{id:"rename-file",label:"Rename…",onSelect:()=>{E8.close();let b0=F8.name??F8.path.split("/").pop(),X8=b0.includes(".")?b0.slice(b0.lastIndexOf(".")):"",q8=X8?b0.slice(0,-X8.length):b0,l0=window.prompt(`Rename ${b0} to:`,q8);if(l0?.trim()&&l0.trim()!==q8)e(F8.path,l0.trim())}}]:[],...F8.canMove?[{id:"move-to",label:"Move to…",onSelect:()=>E8.showMoveTo()}]:[],...F8.supporting&&K0?[{id:"delete-file",label:"Delete",destructive:!0,onSelect:()=>{E8.close(),K0(F8.path,F8.name??F8.path.split("/").pop())}}]:[]]:F8?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{E8.close();let b0=window.prompt("New folder name:");if(b0?.trim())p(F8.dirPath,b0.trim())}},{id:"rename-folder",label:"Rename folder",onSelect:()=>{E8.close();let b0=F8.dirPath.split("/").pop(),X8=window.prompt("Rename folder to:",b0);if(X8?.trim()&&X8.trim()!==b0)r(F8.dirPath,X8.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{E8.close(),v(F8.dirPath,F8.dirPath.split("/").pop())}}]:[],I0=F8?.kind==="file"||F8?.kind==="supporting"?a8.filter((b0)=>b0.path!==F8.dir):[],[w0,C0]=u.useState(!1),[W8,H8]=u.useState("board"),[x8,S8]=u.useState(""),[O9,v0]=u.useState(""),[$8,w9]=u.useState(!1),L8=u.useMemo(()=>Q.find((b0)=>b0.kind==="canvas"&&b0.label!=="Design system")?.fullPath,[Q]),V0=u.useCallback(async()=>{let b0=x8.trim();if(!b0||$8)return;if(w9(!0),v0(""),W8==="folder"){if(!L8){w9(!1),v0("no canvas group to create a folder in");return}let q8=await p(L8,b0);if(w9(!1),q8?.ok)C0(!1),S8("");else v0(q8?.error||"could not create folder");return}let X8=await E(b0);if(w9(!1),X8?.ok)C0(!1),S8("");else v0(X8?.error||"could not create board")},[x8,$8,E,p,W8,L8]),J8=u.useMemo(()=>{let b0=0;for(let X8 of Q)for(let q8 of X8.paths||[])if(y5.test(q8))b0++;return b0},[Q]),r0=u.useMemo(()=>{let b0=0;for(let X8 of s0)for(let q8 of X8.paths||[])if(y5.test(q8))b0++;return b0},[s0]);return D("nav",{className:"st-sidebar"+(k?" is-collapsed":"")+(C?" is-resizing":""),style:k||!$?void 0:{width:$,flexBasis:$},"aria-label":"Files","data-tour":"sidebar",children:[D("div",{className:"st-sb-hd",children:[z("span",{className:"st-sb-title",children:"Files"}),D("div",{className:"st-sb-hd-actions",children:[!J&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":w0&&W8==="board",onClick:()=>{v0(""),H8("board"),C0((b0)=>W8==="board"?!b0:!0)},children:z(T9,{name:"plus",size:15})}),!J&&L8&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":w0&&W8==="folder",onClick:()=>{v0(""),H8("folder"),C0((b0)=>W8==="folder"?!b0:!0)},children:z(T9,{name:"folder-plus",size:15})}),O&&z("button",{type:"button",className:"st-iconbtn st-refresh"+(I?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":I||void 0,disabled:I,onClick:()=>O(),children:z(T9,{name:"reload",size:15})}),D("span",{className:"st-live","data-tip":U?"live · file index synced":"reconnecting…",children:[z("span",{className:"st-live-dot"+(U?" is-connected":""),"aria-hidden":"true"}),r0," / ",J8]}),R&&z("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:R,children:z(T9,{name:"panel-left",size:15})})]})]}),w0?D("div",{className:"st-newboard",children:[z("input",{type:"text",autoFocus:!0,placeholder:W8==="folder"?"folder name…":"brief board name…",value:x8,maxLength:60,disabled:$8,"aria-label":W8==="folder"?"New folder name":"New brief board name",onChange:(b0)=>S8(b0.target.value),onKeyDown:(b0)=>{if(b0.key==="Enter")b0.preventDefault(),V0();else if(b0.key==="Escape")b0.preventDefault(),C0(!1),S8(""),v0("")}}),z("button",{type:"button",className:"st-newboard-go",disabled:$8||!x8.trim(),"data-tip":"Create · Enter","aria-label":W8==="folder"?"Create folder":"Create brief board",onClick:V0,children:$8?"…":"↵"})]}):null,O9?z("div",{className:"st-newboard-err",role:"alert",children:O9}):null,z("div",{className:"st-search",children:D("div",{className:"st-search-box",children:[z(T9,{name:"search",size:13}),z("input",{type:"search","data-testid":"canvas-search",placeholder:"Search canvases…",value:V,onChange:(b0)=>B(b0.target.value),onKeyDown:(b0)=>{if(b0.key==="Escape")if(b0.preventDefault(),V)B("");else b0.currentTarget.blur()},"aria-label":"Filter files"}),V?z("button",{className:"st-search-clear",onClick:()=>B(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):z(CJ,{children:"/"})]})}),z("div",{className:"st-tree",role:"tree","aria-label":"Project file tree","data-testid":"canvas-list",children:s0.map((b0)=>{if(!F&&!V&&b0.kind==="runtime")return null;let X8=bF0(b0),q8=(b0.paths||[]).filter((e0)=>y5.test(e0)).length,l0=X8.pill||(X8.pillFromDsCount?String(b0.dsFolders?.length||0):null)||(X8.pillFromCount?String(q8||b0.paths?.length||0):null),d0=b0.tree&&Object.keys(b0.tree).length>0,h0=b0.label==="Design system",y0=b0.kind==="project";if(!F&&!V&&y0&&q8===0)return null;let B8=BF0(b0),D8=M[b0.label],N0=!!V||(D8===void 0?B8:D8),o0=!h0&&b0.kind==="canvas"&&!J,h8=o0?t0.dropProps(b0.fullPath,!0):{},g8=t0.overDir===b0.fullPath;return D("div",{className:"st-tree-section",children:[D("button",{type:"button",className:"st-tree-sec-hd"+(g8?" is-drop-target":""),"data-testid":`tree-section-${b0.label.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,onClick:()=>A(b0.label,B8),"aria-expanded":N0,"aria-dropeffect":o0?"move":void 0,title:N0?"Collapse section":"Expand section",...h8,children:[z(T9,{name:"chevron-right",className:"st-chev"+(N0?" is-open":""),size:13}),z("span",{className:"st-sec-name",children:X8.title}),l0&&z("span",{className:"st-pill",children:l0})]}),N0&&(d0?z(E90,{node:b0.tree,activePath:Y,previewPath:W,onOpen:Z,onPreview:H,commentsByFile:N,depth:1,kind:b0.kind,showHidden:F,search:V,dsFolders:b0.dsFolders,activeDsName:G,onOpenSystem:h0?K:void 0,onDelete:h0||J?void 0:w,dirtyByPath:j,canvasKinds:f,dirPath:b0.fullPath,drag:!h0&&b0.kind==="canvas"&&!J?t0:void 0,menu:E8}):z("div",{className:"st-tree-empty",children:V?"No matches.":"Empty."}))]},b0.label)})}),z(pb,{state:E8.state,onClose:E8.close,rootItems:T8,destinations:I0,onPickDestination:(b0)=>h(F8.path,b0)}),z(WE,{project:x,liveBranch:m,remoteSync:d,onGetLatest:a,projectOnly:a0}),X===null?z(Ew,{syncStatus:s,onLinkedHub:z0,onLocalProject:o,onOpenFile:q0,filesReady:Z0}):null,z(Rw,{})]})}function jF0({shown:J,onExpand:X,onSearch:Q}){return z("div",{className:"st-rail"+(J?" is-shown":""),children:D("div",{className:"st-rail-inner",children:[z("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:X,children:z(T9,{name:"panel-left",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:z(T9,{name:"search",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:X,children:z(T9,{name:"folder",size:15})})]})})}function vF0({open:J,onClose:X,onStartTour:Q}){if(u.useEffect(()=>{if(!J)return;function Y(W){if(W.key==="Escape")X()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[J,X]),!J)return null;return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)X()},children:D("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[D("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),D("span",{className:"sku",children:["MAUDE-DEV-SRV / v",Zk]}),Q&&z("button",{type:"button",className:"mdcc-tour__back",style:{marginLeft:"auto"},onClick:Q,children:"▶ Take the tour"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:X,children:"×"})]}),D("div",{className:"help-modal-body",children:[D("details",{open:!0,children:[z("summary",{children:"Canvas selection & tools"}),D("ul",{children:[D("li",{children:[z("kbd",{children:"V"})," ",z("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),D("li",{children:[z("kbd",{children:"H"})," ",z("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),D("li",{children:[z("kbd",{children:"C"})," ",z("span",{children:"comment tool — hover paints, click drops a pin"})]}),D("li",{children:[z("kbd",{children:"⌘"})," + hover ",z("span",{children:"preview deepest element under cursor"})]}),D("li",{children:[z("kbd",{children:"⌘"})," + click ",z("span",{children:"select that element (replace)"})]}),D("li",{children:[z("kbd",{children:"⌘⇧"})," + click ",z("span",{children:"add deepest to selection (multi)"})]}),D("li",{children:["right-click ",z("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),D("li",{children:[z("kbd",{children:"Esc"})," in canvas ",z("span",{children:"clear selection + close menu"})]})]})]}),D("details",{children:[z("summary",{children:"Annotation tools"}),D("ul",{children:[D("li",{children:[z("kbd",{children:"B"})," ",z("span",{children:"pen — freehand stroke"})]}),D("li",{children:[z("kbd",{children:"R"})," ",z("span",{children:"rectangle — drag to define corners"})]}),D("li",{children:[z("kbd",{children:"O"})," ",z("span",{children:"ellipse — drag from center outward"})]}),D("li",{children:[z("kbd",{children:"A"})," ",z("span",{children:"arrow — drag tail → tip"})]}),D("li",{children:[z("kbd",{children:"E"})," ",z("span",{children:"eraser — click or drag over strokes to remove"})]}),D("li",{children:[z("kbd",{children:"V"})," + click stroke ",z("span",{children:"select annotation (Shift+click to multi)"})]}),D("li",{children:[z("kbd",{children:"V"})," + drag empty ",z("span",{children:"marquee-select strokes that overlap"})]}),D("li",{children:["double-click rect/ellipse ",z("span",{children:"add text inside the shape"})]}),D("li",{children:["arrow keys ",z("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),D("li",{children:[z("kbd",{children:"Backspace"})," ",z("span",{children:"delete selected annotations"})]}),D("li",{children:[z("kbd",{children:"⇧P"})," ",z("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),D("details",{children:[z("summary",{children:"Canvas & panels"}),D("ul",{children:[D("li",{children:["click in tree ",z("span",{children:"open canvas (replaces the active one)"})]}),D("li",{children:["File ▸ Close canvas ",z("span",{children:"clear the stage"})]}),D("li",{children:[z("kbd",{children:"⌘R"})," ",z("span",{children:"reload canvas"})]}),D("li",{children:[z("kbd",{children:"/"})," ",z("span",{children:"focus search"})]}),D("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"comments panel"})]}),D("li",{children:[z("kbd",{children:"⌘⇧I"})," ",z("span",{children:"inspector"})]}),D("li",{children:[z("kbd",{children:"?"})," ",z("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),D("details",{children:[z("summary",{children:"Slash commands"}),D("ul",{className:"cmds",children:[D("li",{children:[D("code",{children:['/design:edit "',z("i",{children:"feedback"}),'"']}),z("span",{children:"edit + 4-iter multi-axis loop"})]}),D("li",{children:[D("code",{children:['/design:edit "',z("i",{children:"…"}),'" --perfect']}),z("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),D("li",{children:[D("code",{children:['/design:edit "',z("i",{children:"…"}),'" --no-critic']}),z("span",{children:"raw edit, skip loop"})]}),D("li",{children:[D("code",{children:['/design:edit "',z("i",{children:"…"}),'" --opt-out=',z("i",{children:"scope"})]}),z("span",{children:"override DS scope (palette/aesthetic/full)"})]}),D("li",{children:[D("code",{children:['/design:new "',z("i",{children:"Name"}),'" "',z("i",{children:"brief"}),'"']}),z("span",{children:"scaffold canvas"})]}),D("li",{children:[D("code",{children:['/design:new "',z("i",{children:"…"}),'" --opt-out=aesthetic']}),z("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),D("li",{children:[z("code",{children:"/design:critic"}),z("span",{children:"review panel (routed)"})]}),D("li",{children:[z("code",{children:"/design:critic --all"}),z("span",{children:"10-critic sweep"})]}),D("li",{children:[z("code",{children:"/design:critic --agent signature-moment-critic"}),z("span",{children:"aspiration axis only"})]}),D("li",{children:[z("code",{children:"/design:rollback"}),z("span",{children:"undo last edit"})]}),D("li",{children:[z("code",{children:"/design:screenshot"}),z("span",{children:"capture canvas"})]}),D("li",{children:[z("code",{children:"/design:setup-docs"}),z("span",{children:"refresh README + INDEX"})]}),D("li",{children:[z("code",{children:"/design:handoff"}),z("span",{children:"migrate to apps/"})]})]})]}),D("details",{children:[z("summary",{children:"Opt-out scope"}),D("ul",{children:[D("li",{children:[z("strong",{children:"palette"})," ",z("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),D("li",{children:[z("strong",{children:"aesthetic"})," ",z("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),D("li",{children:[z("strong",{children:"full"})," ",z("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),D("li",{children:[z("em",{children:"A11y enforced at every scope"})," ",z("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),D("li",{children:["Persisted on canvas's ",z("code",{children:".meta.json"})," ",z("code",{children:"opt_out_scope"})," field — subsequent ",z("code",{children:"/design:edit"})," iterations inherit."]}),z("li",{children:'Inferred from brief ("modern", "vibrant", "off-system") with one-shot AskUserQuestion before iter-1 critics fire.'})]})]}),D("details",{children:[z("summary",{children:"Auto-critic loop"}),D("ul",{children:[D("li",{children:[z("strong",{children:"Default"})," ",z("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),D("li",{children:[z("strong",{children:"--perfect"})," ",z("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),D("li",{children:[z("strong",{children:"--perfect --all"})," ",z("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),D("li",{children:["Exit: ",z("code",{children:"solid"})," · ",z("code",{children:"stable-but-bland"})," · ",z("code",{children:"max-reached"})," ","· ",z("code",{children:"divergent"})]}),D("li",{children:[z("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),D("li",{children:["When ",z("code",{children:"opt_out_scope ∈ {aesthetic, full}"}),": iter-1 checkpoint fires — pick (a) run loop, (b) skip auto-loop and review iter 1, (c) a11y-only check."]})]})]}),D("details",{children:[z("summary",{children:"Pin-to-element flow"}),D("ol",{children:[z("li",{children:"Open a canvas"}),D("li",{children:[z("kbd",{children:"⌘"}),"+click element"]}),z("li",{children:"Status bar shows ● selector"}),D("li",{children:["Run"," ",D("code",{children:['/design:edit "',z("i",{children:"change just this"}),'"']})]}),D("li",{children:["Reload iframe (",z("kbd",{children:"⌘R"}),")"]})]})]}),D("details",{children:[z("summary",{children:"Comments"}),D("ol",{children:[D("li",{children:[z("kbd",{children:"⌘"}),"+click element, then ",z("kbd",{children:"⌘C"})," ",z("span",{children:"or ⌘⇧+click"})]}),z("li",{children:"Numbered pin appears on canvas"}),D("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"opens panel — All / Open / Resolved"})]}),D("li",{children:["Click row in panel ",z("span",{children:"jumps to that file + pin"})]}),D("li",{children:["Claude reads ",z("code",{children:"_comments/<slug>.json"})," on next ",z("code",{children:"/design"})]})]})]})]})]})})}var Yk=[{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 fF0({kbd:J,alt:X}){let Q=(Y,W)=>z("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>z(CJ,{children:G},`${G}-${Z}`))},W);return D("span",{className:"so-combos",children:[Q(J,"main"),X?X.split(" / ").map((Y)=>D(Q0,{children:[z("span",{className:"so-or",children:"/"}),Q(Y,Y)]},Y)):null]})}function xF0({open:J,onClose:X}){if(u.useEffect(()=>{if(!J)return;function Y(W){if(W.key==="Escape")W.preventDefault(),X()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[J,X]),!J)return null;let Q=Yk.reduce((Y,W)=>Y+W.items.length,0);return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)X()},children:D("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[D("div",{className:"so-overlay-hd",children:[z("span",{className:"so-title",children:"Keyboard shortcuts"}),D("span",{className:"so-trigger",children:["press ",z(CJ,{children:"?"})," to open"]})]}),z("div",{className:"so-columns",children:Yk.map((Y)=>D("section",{className:"so-section so-section--"+Y.id,children:[z("h3",{className:"so-section-hd",children:Y.label}),z("dl",{className:"so-list",children:Y.items.map((W)=>D("div",{className:"so-pair",children:[z("dt",{children:W.label}),z("dd",{children:z(fF0,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),D("div",{className:"so-overlay-ft",children:[D("span",{children:["close with ",z(CJ,{children:"Esc"})]}),D("span",{className:"so-count",children:[Q," bindings · ",Yk.length," groups"]})]})]})})}var hF0=["File","Edit","View","Selection","Tools","Help"];function P90(J){u.useEffect(()=>{function X(Y){if(Y.key==="Escape")J()}function Q(Y){if(!Y.target.closest(".st-dropdown, .st-menu"))J()}return window.addEventListener("keydown",X),window.addEventListener("mousedown",Q),()=>{window.removeEventListener("keydown",X),window.removeEventListener("mousedown",Q)}},[J])}function gF0({panels:J,onToggle:X,onClose:Q,onZoom:Y,hasCanvas:W}){return P90(Q),D("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[z("div",{className:"st-dd-hd",children:"Panels"}),J.map((G)=>D("button",{type:"button",role:"menuitem",className:"st-dd-item"+(G.checked?" is-on":""),"aria-disabled":G.disabled?"true":void 0,title:G.hint||void 0,onClick:()=>{if(G.disabled){if(G.href)window.open(G.href,"_blank","noopener,noreferrer"),Q();return}X(G.id),Q()},children:[D("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check",children:G.checked?z(T9,{name:"check",size:13}):null}),z("span",{children:G.label}),G.phase?z("span",{className:"st-dd-phase",children:G.phase}):null]}),G.shortcut?z(CJ,{children:G.shortcut}):null]},G.id)),z("div",{className:"st-dd-sep"}),z("div",{className:"st-dd-hd",children:"Zoom"}),[{op:"in",label:"Zoom In",shortcut:"⌘ +"},{op:"out",label:"Zoom Out",shortcut:"⌘ −"},{op:"fit",label:"Fit to Screen",shortcut:"⌘ 0"},{op:"actual",label:"Actual Size · 100 %",shortcut:"⌘ 1"}].map((G)=>D("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":W?void 0:"true",onClick:()=>{if(!W)return;Y?.(G.op),Q()},children:[D("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:G.label})]}),z(CJ,{children:G.shortcut})]},G.label))]})}function J1({label:J,left:X,header:Q,items:Y,onAction:W,onClose:G}){return P90(G),D("div",{className:"st-dropdown",role:"menu","aria-label":J,style:{left:X},children:[Q?z("div",{className:"st-dd-hd",children:Q}):null,Y.map((Z,H)=>Z.sep?z("div",{className:"st-dd-sep"},"s"+H):D("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":Z.disabled?"true":void 0,onClick:()=>{if(Z.disabled)return;W(Z.id),G()},children:[D("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:Z.label})]}),Z.shortcut?z(CJ,{children:Z.shortcut}):null]},Z.id))]})}function mF0({onAction:J,onClose:X}){return z(J1,{label:"Help",left:320,onAction:J,onClose:X,items:[{id:"shortcuts",label:"Keyboard shortcuts",shortcut:"?"},{id:"help",label:"Help · commands & flows",shortcut:"F1"},{id:"report-bug",label:"Report a bug…"},{sep:!0},{id:"tour",label:"Take the tour"},{id:"watch-intro",label:"Watch the intro"},...G9()?[{id:"collab-tour",label:"How sharing works"}]:[],...G9()?[{id:"quick-setup",label:"Quick setup"}]:[],...G9()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function uF0({onAction:J,onClose:X,readOnly:Q=!1}){return z(J1,{label:"Selection",left:214,onAction:J,onClose:X,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},...Q?[]:[{id:"select-all-annotations",label:"Select all annotations",shortcut:"⌘ ⇧ A"}]]})}function pF0({onAction:J,onClose:X,readOnly:Q=!1}){let Y=[{id:"browse",label:"Browse (interact)",shortcut:""},{id:"move",label:"Select",shortcut:"V"},{id:"hand",label:"Hand",shortcut:"H"},...Q?[]:[{id:"comment",label:"Comment",shortcut:"C"},{id:"pen",label:"Pen",shortcut:"B"},{id:"rect",label:"Rect",shortcut:"R"},{id:"ellipse",label:"Ellipse",shortcut:"O"},{id:"sticky",label:"Sticky",shortcut:"N"},{id:"arrow",label:"Arrow",shortcut:"A"},{id:"text",label:"Text",shortcut:"T"},{id:"eraser",label:"Eraser",shortcut:"E"}]];return z(J1,{label:"Tools",left:290,header:"Tool palette",onAction:J,onClose:X,items:Y})}function lF0({onAction:J,onClose:X,hasCanvas:Q,hasSharePath:Y,readOnly:W=!1}){return z(J1,{label:"File",left:40,onAction:J,onClose:X,items:W?[{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"share",label:"Share link…",disabled:!Y},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!Q},{id:"close",label:"Close canvas",disabled:!Q}]:[{id:"new",label:"New canvas…",shortcut:"N"},{id:"assemble",label:"Assemble dropped clips → video",disabled:!Q},{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"share",label:"Share link…",disabled:!Y},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"generate",label:"Generate with AI…"},{id:"settings",label:"Settings…",shortcut:"⌘,"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!Q},{id:"close",label:"Close canvas",disabled:!Q}]})}function dF0({onAction:J,onClose:X,hasCanvas:Q,readOnly:Y=!1}){if(Y)return z(J1,{label:"Edit",left:90,onAction:J,onClose:X,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"}]});return z(J1,{label:"Edit",left:90,onAction:J,onClose:X,items:[{id:"undo",label:"Undo",shortcut:"⌘Z"},{id:"redo",label:"Redo",shortcut:"⇧⌘Z"},{sep:!0},{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},{id:"select-all-annotations",label:"Select all annotations",shortcut:"⇧⌘A"},...Q?[{sep:!0},{id:"new-artboard:desktop",label:"New artboard: Desktop"},{id:"new-artboard:laptop",label:"New artboard: Laptop"},{id:"new-artboard:tablet",label:"New artboard: Tablet"},{id:"new-artboard:mobile",label:"New artboard: Mobile"},{id:"new-artboard:print-a4",label:"New artboard: A4 (print)"},{id:"new-artboard:print-letter",label:"New artboard: Letter (print)"}]:[]]})}function cF0({activePath:J,sharePath:X,onShare:Q,project:Y,cloud:W,tabsCount:G,openMenu:Z,setOpenMenu:H,commentsPanelOpen:K,onToggleComments:U,changesOpen:V,changesCount:B,onToggleChanges:N,onOpenSystem:F,sidebarOpen:M,onToggleSidebar:A,showHidden:E,onToggleShowHidden:w,onOpenHelp:O,onOpenShortcuts:I,onReportBug:k,onStartTour:R,onStartCollabTour:$,annotationsVisible:C,onToggleAnnotations:j,minimapVisible:x,onToggleMinimap:m,zoomCtlVisible:d,onToggleZoomCtl:a,presentMode:f,onTogglePresent:h,printGuidesVisible:p,onTogglePrintGuides:v,postToActiveCanvas:r,onOpenWhatsNew:e,onOpenReadiness:c,onOpenQuickSetup:K0,onWatchIntro:s,whatsNewCount:z0,exportCenter:o,artboardCount:q0=0,presence:Z0=null,inspectorOpen:k0,inspectorTab:a0,onToggleInspector:s0,autoOpenInspector:t0,onToggleAutoOpenInspector:E8,onOpenLayers:a8,timelineOpen:F8,onToggleTimeline:T8,hasComps:I0=!1,assistantOpen:w0,onToggleAssistant:C0,assistantBusy:W8,assistantUnseen:H8,onNewCanvas:x8,onAssembleVideo:S8,onOpenExport:O9,onOpenSettings:v0,onOpenGenerate:$8,onReload:w9,onCloseCanvas:L8,onInsertArtboard:V0,readOnly:J8=!1}){let r0=J===r8,b0=r0?"SYSTEM":J?"CANVAS":"IDLE",X8=r0?z("b",{children:"design system"}):J?D(Q0,{children:[J.split("/").slice(0,-1).join("/"),"/",z("b",{children:VY(Y4(J))})]}):z("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),q8=new Set(W?["autoopen"]:["assistant","autoopen"]),l0=[{id:"tree",label:"Project Tree",shortcut:"T",checked:M,disabled:!1},{id:"changes",label:W?"History":B>0?`Changes · ${B} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:V,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:K,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:E,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:k0&&a0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:k0,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!t0,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:I0?"video":void 0,checked:F8,disabled:!1},...G9()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:w0,disabled:!1}]:W?[{id:"assistant",label:"Assistant — in the desktop app",shortcut:"",checked:!1,disabled:!0,href:"https://maude.sh/download",hint:"The agent runs on your own Claude subscription, on your own machine."}]:[],{id:"annotate",label:"Annotations",shortcut:"⇧ P",checked:C,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:x,disabled:!J||r0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:d,disabled:!J||r0},{id:"present",label:"Presentation Mode",shortcut:"",checked:f,disabled:!J||r0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:p,disabled:!J||r0}].filter((y0)=>!J8||!q8.has(y0.id)),d0=["file","edit","view","selection","tools","help"];function h0(y0){if(d0.includes(y0))H(Z===y0?null:y0)}return u.useEffect(()=>{if(!Z||!d0.includes(Z))return;let y0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function B8(D8){let N0=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!N0.length)return;let o0=N0.indexOf(document.activeElement);if(D8.key==="ArrowDown")D8.preventDefault(),N0[(o0+1)%N0.length].focus();else if(D8.key==="ArrowUp")D8.preventDefault(),N0[(o0-1+N0.length)%N0.length].focus();else if(D8.key==="Home")D8.preventDefault(),N0[0].focus();else if(D8.key==="End")D8.preventDefault(),N0[N0.length-1].focus();else if(D8.key==="ArrowRight"||D8.key==="ArrowLeft"){D8.preventDefault();let h8=D8.key==="ArrowRight"?1:-1,g8=d0.indexOf(Z);H(d0[(g8+h8+d0.length)%d0.length])}else if(D8.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",B8),()=>{clearTimeout(y0),window.removeEventListener("keydown",B8)}},[Z,H]),D("header",{className:"st-menubar",role:"menubar","aria-label":"Application menubar","data-testid":"menubar",children:[D("span",{className:"st-brand","data-tour":"brand",children:[z("span",{className:"st-brand-mark",children:z("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),z("span",{className:"st-brand-name",children:"maude"})]}),W?D("span",{className:"st-cloudback","data-testid":"cloud-back",children:[W.dashboardUrl?z("a",{className:"st-cloudback-link",href:W.dashboardUrl,title:"Back to your projects",children:"← Dashboard"}):null,W.projectName?z("span",{className:"st-cloudback-project","data-testid":"cloud-project-name",children:W.projectName}):null]}):null,z("nav",{className:"st-menus","aria-label":"Application menus","data-tour":"menus",children:hF0.map((y0)=>{let B8=y0.toLowerCase(),D8=d0.includes(B8),N0=D8||B8==="help",o0=Z===B8;return z("button",{type:"button",className:"st-menu",role:"menuitem","data-testid":`menu-${B8}`,"data-tour":B8==="help"?"help":void 0,"aria-haspopup":D8?"menu":void 0,"aria-expanded":D8?o0:void 0,onClick:()=>h0(B8),onMouseEnter:()=>{if(Z!==null&&D8)H(B8)},children:y0},B8)})}),Z==="file"&&z(lF0,{readOnly:J8,hasCanvas:!!J,hasSharePath:!!X,onAction:(y0)=>{if(y0==="new")x8?.();else if(y0==="assemble")S8?.();else if(y0==="export")O9?.("export");else if(y0==="share")document.querySelector('[data-testid="menu-file"]')?.focus(),Q?.();else if(y0==="handoff")O9?.("handoff");else if(y0==="generate")$8?.();else if(y0==="settings")v0?.();else if(y0==="reload")w9?.();else if(y0==="close")L8?.()},onClose:()=>H(null)}),Z==="edit"&&z(dF0,{readOnly:J8,hasCanvas:!!J&&!r0,onAction:(y0)=>{if(y0==="undo")r({dgn:"undo"});else if(y0==="redo")r({dgn:"redo"});else if(y0==="deselect-all")r({dgn:"selection-clear"});else if(y0==="select-all-annotations")r({dgn:"annotation-select-all"});else if(y0.startsWith("new-artboard:"))V0?.(y0.slice(13))},onClose:()=>H(null)}),Z==="view"&&z(gF0,{panels:l0,onToggle:(y0)=>{if(y0==="tree")A();else if(y0==="changes")N();else if(y0==="comments")U();else if(y0==="hidden")w();else if(y0==="annotate")j();else if(y0==="inspector")s0();else if(y0==="autoopen")E8?.();else if(y0==="timeline")T8?.();else if(y0==="assistant")C0?.();else if(y0==="layers")a8?.();else if(y0==="minimap")m?.();else if(y0==="zoomctl")a?.();else if(y0==="present")h?.();else if(y0==="print-guides")v?.()},onZoom:(y0)=>r({dgn:"zoom",op:y0}),hasCanvas:!!J&&!r0,onClose:()=>H(null)}),Z==="selection"&&z(uF0,{readOnly:J8,onAction:(y0)=>{if(y0==="deselect-all")r({dgn:"selection-clear"});else if(y0==="select-all-annotations")r({dgn:"annotation-select-all"})},onClose:()=>H(null)}),Z==="tools"&&z(pF0,{readOnly:J8,onAction:(y0)=>r({dgn:"tool-set",tool:y0}),onClose:()=>H(null)}),Z==="help"&&z(mF0,{onAction:(y0)=>{if(y0==="shortcuts")I?.();else if(y0==="help")O?.();else if(y0==="report-bug")k?.();else if(y0==="tour")R?.();else if(y0==="collab-tour")$?.();else if(y0==="quick-setup")K0?.();else if(y0==="readiness")c?.();else if(y0==="whatsnew")e?.();else if(y0==="watch-intro")s?.()},onClose:()=>H(null)}),D("div",{className:"st-mb-right","data-tour":"status",children:[Z0?z("div",{className:"st-presence",children:Z0}):null,J8&&z("span",{className:"st-stamp st-stamp--viewonly","data-testid":"view-only-stamp","data-tip":W?.user?`${W.user} is a viewer on this project — you can browse, comment and export where available. Ask a project owner for edit access, or sign out if that is not the account you meant to use.`:"Your role in this project is viewer — you can browse, comment when available, and export where available. Ask a project owner for edit access.",children:"VIEW ONLY"}),W?.user?D("span",{className:"st-cloudwho","data-testid":"cloud-account",children:[z("span",{className:"st-cloudwho-email",title:W.role?`Signed in as ${W.user} — ${W.role}`:W.user,children:W.user}),z("form",{method:"post",action:"/auth/browser/signout",className:"st-cloudwho-form",children:z("button",{type:"submit",className:"st-cloudwho-out","data-testid":"cloud-signout",title:"Sign out of this project",children:"Sign out"})})]}):null,G9()&&!J8&&z("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":w0?"true":"false","data-busy":W8?"true":"false","data-unseen":H8?"true":"false","aria-label":`Assistant${W8?" — working":H8?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:C0,children:z(T9,{name:"sparkle",size:15})}),z("button",{type:"button",className:"st-mb-icon st-share-btn","data-testid":"share-btn","data-tip":X?"Share link":"Open a canvas to share it","aria-label":"Share link",disabled:!X,onClick:Q,children:z(T9,{name:"share",size:15})}),o&&z(Fm,{center:o}),z("button",{type:"button",className:"st-reportbug","data-testid":"report-bug-toggle","aria-label":"Report a bug","data-tip":"Report a bug",onClick:k,children:z(T9,{name:"bug",size:15})}),z("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":z0>0?"true":"false","aria-label":`What's new${z0>0?` — ${z0} unseen`:""}`,"data-tip":"What's new",onClick:e,children:z(T9,{name:"megaphone",size:15})}),z("span",{className:"st-stamp",children:b0}),z("span",{className:"st-mb-file",title:J||"",children:X8}),z("span",{className:"st-mb-sep"}),D("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[z("span",{className:"st-dot",style:{background:"var(--accent)"}}),q0," ARTBOARDS"]}),z("span",{className:"st-mb-sep"}),z("span",{className:"st-mb-proj",children:Y||"maude"})]})]})}function iF0({tabs:J,activePath:X,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:K,onIframeLoad:U,canvasError:V,canvasReloadNonce:B,onRetryCanvasLoad:N,loadedPath:F,showQuickSetup:M,onStartQuickSetup:A,previewPath:E}){let w=u.useRef(null);u.useEffect(()=>{if(E)w.current?.focus()},[E]);let O=u.useRef(new Map),I=new Set(J.map(($)=>$.path));for(let[$,C]of O.current)if(!I.has(C.path))O.current.delete($);let k=($)=>{let C=EZ($,{...H,canvasToken:void 0}),j=`${$}#${B}|${C}`,x=O.current.get(j);if(!x)x={path:$,src:EZ($,H)},O.current.set(j,x);return x.src},R=V&&V.path===X?"error":X&&X!==r8&&F===X?"ready":K&&K===X?"loading":"idle";return D("div",{className:"viewport st-stage","data-tour":"viewport","data-canvas-state":R,children:[E&&z("div",{ref:w,className:"st-file-preview-overlay",role:"region","aria-label":`Preview: ${$V(Y4(E))}`,tabIndex:0,children:z(Ig,{path:E,kind:NL(Y4(E))})}),J.length===0&&!E&&D("div",{className:"st-empty",children:[D("div",{className:"st-empty-brand",children:[z("span",{className:"st-brand-mark",children:z("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),z("span",{className:"st-empty-wm",children:"maude"}),D("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(Z||"MAUDE").toUpperCase()," / v",Zk," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),z("div",{className:"st-empty-title",children:"Nothing open yet"}),D("div",{className:"st-empty-body",children:["← Pick a screen from the list on the left, or open ",z("strong",{children:"Design system"})," above it to see your colors, type, and components.",z("br",{}),z("br",{}),z("strong",{children:"To select something on the canvas:"})," hold ",z(CJ,{children:"⌘"})," and hover to preview an element, click to select it — ",z(CJ,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",G9()?D(Q0,{children:[z("br",{}),z("br",{}),"Claude can see whatever's selected when you ask for a change in the Assistant panel, so pointing is often faster than describing it."]}):null]}),M&&z("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:A,children:"Start quick setup"})]}),J.map(($)=>{if($.path===r8)return z("div",{className:"system-view"+($.path===X?" active":""),children:z(JL0,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},$.path);return z("iframe",{ref:(C)=>Q($.path,C),src:k($.path),className:$.path===X?"active":"","data-path":$.path,"data-testid":$.path===X?"canvas-frame":void 0,onLoad:()=>U?.($.path),...H?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},`${$.path}#${B}`)}),K&&K===X&&z("div",{className:"st-canvas-loading","aria-hidden":"true",children:D("div",{className:"st-skel-card",children:[z("div",{className:"st-skel-cap st-mono",children:"compiling canvas…"}),z("span",{className:"skel st-skel-thumb"}),z("span",{className:"skel st-skel-line",style:{width:"72%"}}),z("span",{className:"skel st-skel-line",style:{width:"46%"}})]})}),V&&V.path===X&&z("div",{className:"st-canvas-error",role:"alert","data-testid":"canvas-load-error",children:D("div",{className:"st-canvas-error-card",children:[z("div",{className:"st-canvas-error-title",children:V.kind==="server"?"Maude's server isn't responding":"This canvas didn't finish loading"}),z("div",{className:"st-canvas-error-body",children:V.kind==="server"?z(Q0,{children:"The canvas couldn't be reached. This usually means Maude's server restarted underneath this window — your files on disk are untouched."}):D(Q0,{children:["The server is up, but"," ",z("code",{children:$V(Y4(V.path))})," ","never finished compiling. Its own error, if it has one, is in the canvas frame."]})}),z("button",{type:"button",className:"btn btn--primary","data-testid":"canvas-load-retry",onClick:()=>N?.(V.path),children:"Reload canvas"})]})})]})}var oF0=["color","space","radius","shadow","leading","weight","motion","font","other"],nF0={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function rF0(J){return J==="color"}function aF0({tokens:J,tokenGroups:X,tokensPath:Q}){if(!J||J.length===0)return D("section",{className:"sv-section sv-section-tokens",children:[D("h2",{children:["tokens",z("span",{className:"sv-h-num",children:"0"})]}),z("div",{className:"sv-empty",children:D("p",{children:["No tokens parsed from"," ",Q?z("code",{children:Q}):"the configured tokens file",". Does the file exist and contain CSS custom properties (",z("code",{children:"--name: value;"}),")?"]})})]});let Y=X||{},W=Array.from(new Set([...oF0,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return z(Q0,{children:W.map((G)=>{let Z=Y[G],H=rF0(G);return D("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[D("h2",{children:["tokens · ",nF0[G]||G,z("span",{className:"sv-h-num",children:Z.length})]}),z("div",{className:"sv-tokens-ladder",children:Z.map((K)=>D("div",{className:"sv-tok-cell",children:[H?z("div",{className:"sv-tok-swatch",style:{background:K.value}}):null,D("div",{className:"sv-tok-meta",children:[z("code",{className:"sv-tok-name",children:K.name}),z("span",{className:"sv-tok-value",children:K.value||"—"})]})]},K.name+"|"+K.value))})]},G)})})}function sF0(J,X){let Q=J.name.match(/^--(?:type|fs|text)-(.+)$/);if(!Q)return null;let Y=Q[1];return(X||[]).find((W)=>/^--(?:lh|leading|line-height)-/.test(W.name)&&W.name.endsWith("-"+Y))?.value??null}function tF0(J){if(!J?.length)return;let X=["body","sans","display","text","family"];for(let Q of X){let Y=J.find((W)=>W.name.includes(Q));if(Y)return Y.value}return J[0].value}function eF0({tokenGroups:J}){let X=J?.fontsize||[];if(X.length===0)return null;let Q=J?.leading||[],Y=tF0(J?.font);return D("section",{className:"sv-section sv-section-type",children:[D("h2",{children:["type · ladder",z("span",{className:"sv-h-num",children:X.length})]}),z("div",{className:"sv-type-list",children:X.map((W)=>{let G=sF0(W,Q),Z={fontSize:W.value};if(G)Z.lineHeight=G;if(Y)Z.fontFamily=Y;return D("div",{className:"sv-type-row",children:[z("code",{className:"sv-type-tok",children:W.name}),z("span",{className:"sv-type-sample",style:Z,children:"The catalog is the system."})]},W.name)})})]})}function JL0({data:J,onOpen:X,cfg:Q,onSelectDs:Y}){if(!J)return z("div",{className:"sv-empty",children:z("p",{children:"Loading design system…"})});let{previewGallery:W,uiKitsGallery:G,systemDir:Z,tokens:H,tokenGroups:K,tokensPath:U,ds:V,availableDesignSystems:B}=J,N=(!W||!W.length)&&(!G||!G.length),F=Array.isArray(B)&&B.length>1,M=V?.name??B?.[0]?.name??"";return D("div",{className:"sv",children:[D("header",{className:"sv-header",children:[z("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),z("span",{className:"sv-title",children:"design system view"}),F?D("label",{className:"sv-ds-picker",children:[z("span",{className:"sv-ds-picker-label",children:"DS"}),z("select",{value:M,onChange:(A)=>Y&&Y(A.target.value),children:B.map((A)=>z("option",{value:A.name,children:A.name},A.name))})]}):null,z("span",{className:"sv-loc",children:z("code",{children:Z})})]}),V?.description?z("p",{className:"sv-ds-description",children:V.description}):null,z(aF0,{tokens:H,tokenGroups:K,tokensPath:U}),z(eF0,{tokenGroups:K}),N?z("div",{className:"sv-empty",children:D("p",{children:["No ",z("code",{children:"preview/"})," or ",z("code",{children:"ui_kits/"})," folders found under"," ",z("code",{children:Z}),"."]})}):D(Q0,{children:[z(W90,{title:"preview",items:W,onOpen:X,kind:"preview",cfg:Q}),z(W90,{title:"ui kits",items:G,onOpen:X,kind:"ui_kits",cfg:Q})]})]})}function W90({title:J,items:X,onOpen:Q,kind:Y,cfg:W}){if(!X||X.length===0)return null;return D("section",{className:"sv-section",children:[D("h2",{children:[J," ",z("span",{className:"sv-count",children:X.length})]}),z("div",{className:"sv-previews sv-previews-"+Y,children:X.map((G)=>D("article",{className:"sv-preview-card",onClick:()=>Q(G.path),children:[z("div",{className:"sv-preview-frame",children:z("iframe",{src:EZ(G.path,W,{thumbnail:!0}),title:G.label,scrolling:"no",...W?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),D("div",{className:"sv-preview-foot",children:[z("strong",{children:G.label}),z("code",{children:G.path})]})]},G.path))})]})}function XL0({activePath:J,selected:X,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,syncProject:K,syncOpen:U=!1,onOpenSync:V,changesCount:B=0,unpushed:N=0,savingIsManaged:F=!1,changesOpen:M=!1,onOpenChanges:A,version:E}){let w=J===r8,O=X&&X.selector?X.selector+(X.text?` — "${X.text.slice(0,60)}"`:""):"",I=X&&X.dom_path?X.dom_path.join(" > "):X?X.selector:"",k=W==="dark"?"light":"dark",R=(()=>{let C=oz(H,{project:K});if(!C)return null;let j=C.names.length?` (${C.names.join(", ")})`:"";return{online:C.online,label:C.label,title:`${C.title}${j}${C.next?` — ${C.next}`:""}`}})(),$=R&&D(Q0,{children:[z("span",{className:"st-sb-sync-dot"+(R.online?" is-online":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:"hub sync"}),z("span",{className:"val",title:R.title,children:R.label})]});return D("footer",{className:"st-statusbar",role:"contentinfo","data-testid":"statusbar",children:[D("span",{className:"st-sb-slot st-sb-active",role:"group","aria-label":"Active file",children:[z("span",{className:"lead","aria-hidden":"true"}),z("span",{className:"lbl",children:"active"}),z("span",{className:"val",title:J||"",children:w?"▦ design system":J||"—"})]}),J&&X&&X.selector&&!w&&D("span",{className:"st-sb-slot st-sb-sel",role:"group","aria-label":"Selected element",children:[z("span",{className:"lbl",children:"selected"}),z("span",{className:"val",title:I,children:O}),z("button",{type:"button",className:"st-sb-sel-clear",onClick:Z,"data-tip":"Clear · Esc inside iframe","data-tip-pos":"top","aria-label":"Clear selection",children:"×"})]}),D("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[z("span",{className:"lbl",children:"comments"}),D("span",{className:"val",children:[Y," open"]})]}),A&&D("button",{type:"button",className:"st-sb-slot st-sb-changes"+(M?" is-open":"")+(B>0?" has-changes":N>0?" has-unpushed":""),onClick:A,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":M,children:[z("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),z("span",{className:"lbl",children:"changes"}),z("span",{className:"val",children:F?"cloud saving":B>0?`${B} unsaved`:N>0?`${N} to publish`:"all saved"})]}),z("span",{className:"st-sb-spacer"}),D("span",{className:"st-sb-slot",role:"group","aria-label":"Connection",children:[z("span",{className:"st-live-dot"+(Q?" is-connected":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:Q?"live":"reconnecting"})]}),R&&(V?z("button",{type:"button",className:"st-sb-slot st-sb-sync st-sb-sync--btn"+(U?" is-open":""),onClick:V,"data-testid":"open-sync","data-tip":"Open Sync panel","data-tip-pos":"top","aria-label":"Open Sync panel","aria-pressed":U,children:$}):z("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:$})),E&&z("span",{className:"st-sb-slot st-sb-version",role:"group","aria-label":"Maude version",children:D("span",{className:"val","data-testid":"statusbar-version",children:["v",E]})}),D("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${k} theme`,"data-tip-pos":"top","aria-label":`Switch to ${k} theme`,children:[z(T9,{name:W==="dark"?"sun":"moon",size:13}),k]})]})}function QL0({commentsByFile:J,filter:X,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:K,width:U,resizing:V}){let B=w90(J),N=Object.keys(J||{}).sort(),F=[];for(let M of N){let A=J[M]||[],E=A.filter((O)=>{if(X==="open")return O.status!=="resolved";if(X==="resolved")return O.status==="resolved";return!0});if(E.length===0)continue;let w=A.filter((O)=>O.selector);F.push({file:M,comments:E.map((O)=>({...O,n:w.findIndex((I)=>I.id===O.id)+1}))})}return D("aside",{className:"st-rpanel"+(V?" is-resizing":""),style:U?{width:U,flexBasis:U}:void 0,"aria-label":"Comments",children:[z("div",{className:"st-rp-tabs st-rp-tabs--filters",children:D("div",{className:"st-cm-filters",role:"tablist",children:[D("button",{type:"button",className:"st-cm-filter"+(X==="all"?" is-active":""),role:"tab","data-testid":"comment-filter-all","aria-selected":X==="all",onClick:()=>Q("all"),children:["All · ",B.all]}),D("button",{type:"button",className:"st-cm-filter"+(X==="open"?" is-active":""),role:"tab","data-testid":"comment-filter-open","aria-selected":X==="open",onClick:()=>Q("open"),children:["Open · ",B.open]}),D("button",{type:"button",className:"st-cm-filter"+(X==="resolved"?" is-active":""),role:"tab","data-testid":"comment-filter-resolved","aria-selected":X==="resolved",onClick:()=>Q("resolved"),children:["Resolved · ",B.resolved]})]})}),z("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:F.length===0?D("div",{className:"st-rp-empty",children:[D("p",{children:["No comments ",X!=="all"?`with status “${X}”`:"yet","."]}),D("p",{children:["Open a canvas, hold ",z(CJ,{children:"⌘"})," and click an element, then press ",z(CJ,{children:"C"})," — or hold ",z(CJ,{children:"⌘⇧"})," and click directly."]})]}):F.map((M)=>D(Q0,{children:[D("button",{type:"button",className:"st-cm-group-hd",onClick:()=>G(M.file,null),title:M.file,children:[z("span",{children:VY(Y4(M.file))}),z("span",{className:"st-mono",children:M.comments.length})]}),M.comments.map((A)=>D("div",{"data-testid":`comment-item-${A.id}`,className:"st-comment"+(A.status==="resolved"?" is-resolved":"")+(A.id===W?" is-active":""),onClick:()=>G(M.file,A.id),children:[D("div",{className:"st-comment-hd",children:[z("span",{className:"st-pin st-pin--inline",children:A.n||"·"}),z("span",{className:"st-comment-time",children:DF0(A.created)})]}),z("div",{className:"st-comment-txt",children:A.text}),D("div",{className:"st-comment-foot",children:[z("span",{className:"st-comment-sel",title:(A.dom_path||[]).join(" > "),children:A.selector||"—"}),Z&&H&&K?D("span",{className:"st-mini-act",children:[A.status==="resolved"?z("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(E)=>{E.stopPropagation(),H(A.id)},children:z(T9,{name:"reopen",size:14})}):z("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(E)=>{E.stopPropagation(),Z(A.id)},children:z(T9,{name:"resolve",size:14})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(E)=>{E.stopPropagation(),K(A.id)},children:z(T9,{name:"x",size:14})})]}):null]})]},A.id))]},M.file))})]})}var YL0={owner:"You own this project — edit, invite and export.",member:"You can edit this project, comment and export.",viewer:"You can look at this project, comment and download it, but not change it."};function WL0({cloud:J}){let X=J?.role||null,[Q,Y]=u.useState(!1);if(!X||Q)return null;let W=`maude-cloud-role-seen:${X}`,G=!1;try{G=localStorage.getItem(W)==="1"}catch{}if(G)return null;let Z=YL0[X];if(!Z)return null;return D("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info","data-testid":"cloud-role-banner",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:Z}),z("button",{type:"button",className:"btn btn--ghost btn--sm","data-testid":"cloud-role-banner-dismiss",onClick:()=>{Y(!0);try{localStorage.setItem(W,"1")}catch{}},children:"Got it"})]})}function GL0({update:J,onDismiss:X}){let[Q,Y]=u.useState(!1);if(!J)return null;let W=J.version?` (v${J.version})`:"";return D("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),D("span",{children:["Maude updated",W," · restart to apply"]}),z("button",{type:"button",className:"btn btn--primary btn--sm",disabled:Q,onClick:()=>{Y(!0),Bh().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X,children:"Later"})]})}function ZL0({status:J}){let[X,Q]=u.useState(null);if(!J||J.linked===!1)return null;if(J.notSyncable)return null;let{state:Y,queuedOps:W,flash:G,conflicts:Z}=J,H=G==="synced",K=Y==="offline"||Y==="offline-long",U=J.docs?.rejected??0,V=Array.isArray(Z)?[...Z].reverse().find((M)=>M.kind==="cold-start-diverged"):null;if(!K&&!H&&!V&&U===0)return null;let B,N,F;if(H)B="success",N="Synced with hub",F=`${Y}:flash`;else if(K){let M=Z&&Z.length>0?` (${Z.length} conflict notice(s))`:"";if(Y==="offline-long")B="error",N=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${M}`;else B="warn",N=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${M}`;F=`${Y}:offline`}else if(V){if(V.snapshotFailed)B="error",N=`Diverged on ${V.slug}: kept local — the history snapshot FAILED, so the overwrite was refused. Check disk space / .design/_history write access.`;else B="warn",N=`Diverged on ${V.slug}: kept the ${V.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${V.slug}`;F=`diverged:${V.slug}:${V.at}`}else B="warn",N=`${U} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,F=`rejected:${U}`;if(X===F)return null;return D("div",{role:"status","aria-live":"polite",className:`st-banner st-banner--${B}`,children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:N}),z("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(F),children:"×"})]})}var HL0=["block","inline-block","flex","inline-flex","grid","inline","none"],G90=["px","%","fr","em","auto","min-content","max-content"];var zL0=["auto","stretch","flex-start","center","flex-end","baseline"];var Z90=["300","400","500","600","700","800"],Uq=(J,X)=>J&&Object.hasOwn(J,"previous")?J.previous:X,H90=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],z90=["none","solid","dashed","dotted","double"],K90=["px","rem","em","%","vw","vh","auto"],U90=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),Wk={"font-size":{node:z(K7,{as:bV,size:12})},"line-height":{node:z(K7,{as:gV,size:12})},"letter-spacing":{node:z(K7,{as:nV,size:12})},gap:{node:z(K7,{as:PK,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:z(K7,{as:eV,size:12})},"border-width":{node:z(K7,{as:oV,size:12})}};var V90=["static","relative","absolute","fixed","sticky"],KL0=["normal","italic","oblique"],q90=["none","uppercase","lowercase","capitalize"];var B90=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],UL0=["fill","contain","cover","none","scale-down"];var N90=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],F90=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],b5={desktop:{label:"Desktop",width:1440,height:1024},laptop:{label:"Laptop",width:1280,height:800},tablet:{label:"Tablet",width:834,height:1194},mobile:{label:"Mobile",width:390,height:844}},tK=null;function BL(J){if(!J)return"";if(/^#[0-9a-f]{6}$/i.test(J))return J.toLowerCase();try{if(!tK)tK=document.createElement("canvas").getContext("2d");if(!tK)return"";tK.fillStyle="#000000",tK.fillStyle=J;let X=tK.fillStyle;if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();let Q=X.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(Q)return`#${[Q[1],Q[2],Q[3]].map((Y)=>Number(Y).toString(16).padStart(2,"0")).join("")}`}catch{}return""}var UY=(J)=>Math.min(1,Math.max(0,J));function ZL(J){let X=/^#?([0-9a-f]{6})$/i.exec(J||"");if(!X)return{r:0,g:0,b:0};let Q=Number.parseInt(X[1],16);return{r:Q>>16&255,g:Q>>8&255,b:Q&255}}function Vq({r:J,g:X,b:Q}){return`#${[J,X,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function qq({r:J,g:X,b:Q}){J/=255,X/=255,Q/=255;let Y=Math.max(J,X,Q),W=Math.min(J,X,Q),G=Y-W,Z=0;if(G){if(Y===J)Z=(X-Q)/G%6;else if(Y===X)Z=(Q-J)/G+2;else Z=(J-X)/G+4;if(Z*=60,Z<0)Z+=360}return{h:Z,s:Y?G/Y:0,v:Y}}function eK({h:J,s:X,v:Q}){let Y=Q*X,W=Y*(1-Math.abs(J/60%2-1)),G=Q-Y,Z=0,H=0,K=0;if(J<60)[Z,H,K]=[Y,W,0];else if(J<120)[Z,H,K]=[W,Y,0];else if(J<180)[Z,H,K]=[0,Y,W];else if(J<240)[Z,H,K]=[0,W,Y];else if(J<300)[Z,H,K]=[W,0,Y];else[Z,H,K]=[Y,0,W];return{r:(Z+G)*255,g:(H+G)*255,b:(K+G)*255}}function U7(J){if(!J)return"";let X=/^(-?\d*\.?\d+)px$/.exec(J);return X?`${Math.round(Number.parseFloat(X[1]))}px`:J}function Q4(J){if(!J)return{n:"",unit:"px"};let X=J.trim(),Q=/^(-?\d*\.?\d+)\s*(px|rem|em|%|vw|vh)?$/.exec(X);if(Q)return{n:Q[1],unit:Q[2]||"px"};if(X==="auto")return{n:"",unit:"auto"};return{n:X,unit:""}}function L90(J,X){if(!J||Array.isArray(J)||Array.isArray(X)||!X)return J;if(!J.id&&!X.id){let Q=(Y)=>typeof Y.selector==="string"&&Y.selector.startsWith("[data-dc-screen=");if(Q(J)&&Q(X)&&J.selector===X.selector&&J.file===X.file)return{...J,authored:J.authored??X.authored,computed:J.computed??X.computed,customStyles:J.customStyles??X.customStyles,attrs:J.attrs??X.attrs,artboardId:J.artboardId??X.artboardId,worldW:J.worldW??X.worldW,worldH:J.worldH??X.worldH};return J}if(!J.id||J.id!==X.id)return J;return{...J,authored:J.authored??X.authored,computed:J.computed??X.computed,customStyles:J.customStyles??X.customStyles,attrs:J.attrs??X.attrs,photoKind:J.photoKind??X.photoKind,photoAsset:J.photoAsset??X.photoAsset}}function I90(J,X){return(J?X?.canvasDesignSystems?.[J]:null)||X?.defaultDesignSystem||X?.designSystems?.[0]?.name||null}function VL0(J){let X={};for(let Z of J.matchAll(/(--[a-z0-9-]+)\s*:\s*([^;}]+)/gi))if(!(Z[1]in X))X[Z[1]]=Z[2].trim();let Q={};for(let Z of Object.keys(X)){let H=X[Z],K=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(H);Q[Z]=K&&X[K[1]]?X[K[1]]:H}let Y=Object.keys(X),W=(Z)=>Y.filter((H)=>Z.test(H)),G=(Z)=>/^(#[0-9a-f]{3,8}|rgba?\(|hsla?\(|oklch\(|oklab\(|lab\(|lch\(|hwb\(|color\()/i.test(Z)||/^(transparent|currentcolor|white|black|red|green|blue|gray|grey|orange|yellow|purple|pink|cyan|magenta|teal|navy|maroon|olive|lime|aqua|silver|gold)$/i.test(Z);return{color:Y.filter((Z)=>G(Q[Z])),space:W(/^--space-/),radius:W(/^--radius-/),type:W(/^--type-/),shadow:W(/^--shadow-/),lh:W(/^--lh-/),vals:Q}}function T90(J,X,Q){let Y=J?.designSystems||[],W=Y.map((H)=>`${H.name}:${H.tokensCssRel}`).join("|"),[G,Z]=u.useState([]);return u.useEffect(()=>{if(!Y.length)return;let H=!1;return Promise.all(Y.map(async(K)=>{if(!K.tokensCssRel)return null;try{let U=await fetch(`/${X}/${K.tokensCssRel}`),V=U.ok?await U.text():"";return{name:K.name,...VL0(V)}}catch{return null}})).then((K)=>{if(H)return;let U=K.filter(Boolean);U.sort((V,B)=>V.name===Q?-1:B.name===Q?1:0),Z(U)}),()=>{H=!0}},[W,X,Q]),G}function k90({seed:J,label:X,onApply:Q}){let[Y,W]=u.useState(()=>qq(ZL(J||"#000000"))),G=u.useRef(Y);G.current=Y;let Z=u.useRef(null),H=u.useRef(null),K=u.useRef(J);u.useEffect(()=>{if(J&&J!==K.current)K.current=J,W(qq(ZL(J)))},[J]);let U=Vq(eK(Y)),V=(O)=>{O.preventDefault();let I=Z.current?.getBoundingClientRect();if(!I)return;let k=G.current.h,R=(C)=>{W({h:k,s:UY((C.clientX-I.left)/I.width),v:UY(1-(C.clientY-I.top)/I.height)})};R(O);let $=()=>{document.removeEventListener("pointermove",R),document.removeEventListener("pointerup",$),Q(Vq(eK(G.current)))};document.addEventListener("pointermove",R),document.addEventListener("pointerup",$)},B=(O)=>{O.preventDefault();let I=H.current?.getBoundingClientRect();if(!I)return;let{s:k,v:R}=G.current,$=(j)=>{W({h:UY((j.clientX-I.left)/I.width)*360,s:k,v:R})};$(O);let C=()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",C),Q(Vq(eK(G.current)))};document.addEventListener("pointermove",$),document.addEventListener("pointerup",C)},N=(O)=>{let I={...G.current,...O};W(I),Q(Vq(eK(I)))},F=(O)=>{let I=O.shiftKey?0.1:0.02,R={ArrowLeft:[-I,0],ArrowRight:[I,0],ArrowUp:[0,I],ArrowDown:[0,-I]}[O.key];if(!R)return;O.preventDefault(),N({s:UY(G.current.s+R[0]),v:UY(G.current.v+R[1])})},M=(O)=>{let I=O.shiftKey?20:2,R={ArrowLeft:-I,ArrowRight:I}[O.key];if(R==null)return;O.preventDefault(),N({h:Math.min(360,Math.max(0,G.current.h+R))})},A=async()=>{try{let O=window.EyeDropper;if(!O)return;let I=await new O().open();if(I?.sRGBHex)W(qq(ZL(I.sRGBHex))),Q(I.sRGBHex)}catch{}},E=eK(Y),w=(O)=>{let I={...E,...O},k=qq({r:UY(I.r/255)*255,g:UY(I.g/255)*255,b:UY(I.b/255)*255});W(k),Q(Vq(eK(k)))};return D("div",{className:"st-cp-cpick",children:[D("div",{className:"st-cp-cpick-hexrow",children:[z("span",{className:"st-cp-cpick-hexsw",style:{background:U}}),z("input",{className:"st-cp-cpick-hex",type:"text",value:U,"aria-label":X?`${X} hex value`:"hex value",onChange:(O)=>{let I=O.target.value;if(/^#?[0-9a-f]{6}$/i.test(I))W(qq(ZL(I)))},onKeyDown:(O)=>{if(O.key==="Enter")Q(O.currentTarget.value)},onBlur:(O)=>Q(O.currentTarget.value),onFocus:(O)=>O.currentTarget.select()})]}),D("button",{type:"button",ref:Z,className:"st-cp-cpick-sv","aria-label":X?`${X} saturation and value`:"saturation and value",style:{background:`hsl(${Y.h} 100% 50%)`},onPointerDown:V,onKeyDown:F,children:[z("span",{className:"st-cp-cpick-svwhite"}),z("span",{className:"st-cp-cpick-svblack"}),z("span",{className:"st-cp-cpick-knob",style:{left:`${Y.s*100}%`,top:`${(1-Y.v)*100}%`,background:U}})]}),D("div",{className:"st-cp-cpick-controls",children:[window.EyeDropper?z("button",{type:"button",className:"st-cp-cpick-eye","aria-label":"pick from screen",title:"eyedropper",onClick:A,children:z(T9,{name:"eyedropper",size:14})}):null,z("span",{className:"st-cp-cpick-preview",style:{background:U},"aria-hidden":"true"}),z("button",{type:"button",ref:H,className:"st-cp-cpick-hue","aria-label":X?`${X} hue`:"hue",onPointerDown:B,onKeyDown:M,children:z("span",{className:"st-cp-cpick-huethumb",style:{left:`${Y.h/360*100}%`}})})]}),z("div",{className:"st-cp-cpick-rgb",children:["r","g","b"].map((O)=>D("label",{className:"st-cp-cpick-rgbf",children:[z("input",{"aria-label":O.toUpperCase(),value:Math.round(E[O]),onChange:(I)=>w({[O]:UY((Number.parseFloat(I.target.value)||0)/255)*255}),onFocus:(I)=>I.currentTarget.select()}),z("span",{children:O.toUpperCase()})]},O))})]})}function KL({kind:J,groups:X,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:K}){let[U,V]=u.useState(!1),[B,N]=u.useState(null),[F,M]=u.useState("custom"),[A,E]=u.useState(""),w=u.useRef(null),O=u.useRef(null),I=typeof Q==="string"&&/var\(\s*--/.test(Q),k=(e)=>Q===`var(${e})`,R=(e)=>e.replace(/^--/,"").replace(/-/g," "),$=X||[],C=$.reduce((e,c)=>e+(c.names?.length||0),0),j=$.length>1,x=A.trim().toLowerCase(),m=!x?$:$.map((e)=>({...e,names:(e.names||[]).filter((c)=>R(c).toLowerCase().includes(x)||c.toLowerCase().includes(x)||(e.vals?.[c]||"").toLowerCase().includes(x))})).filter((e)=>e.names.length);u.useEffect(()=>{if(!U){E("");return}let e=()=>{let z0=w.current?.getBoundingClientRect();if(!z0)return;let o=224,q0=300,Z0=Math.min(z0.right-o,window.innerWidth-o-8);if(Z0<8)Z0=8;let a0=window.innerHeight-z0.bottom>q0+8?z0.bottom+4:Math.max(8,z0.top-q0-4);N({left:Z0,top:a0,width:o,maxHeight:q0})};e();let c=(z0)=>{if(O.current?.contains(z0.target)||w.current?.contains(z0.target))return;V(!1)},K0=(z0)=>{if(z0.key==="Escape")V(!1)},s=(z0)=>{if(O.current?.contains(z0.target))return;e()};return document.addEventListener("pointerdown",c,!0),document.addEventListener("keydown",K0),window.addEventListener("resize",e),document.addEventListener("scroll",s,!0),()=>{document.removeEventListener("pointerdown",c,!0),document.removeEventListener("keydown",K0),window.removeEventListener("resize",e),document.removeEventListener("scroll",s,!0)}},[U]),u.useEffect(()=>{if(!U||!B||!O.current)return;let e=O.current.getBoundingClientRect(),c=B.left-e.left,K0=B.top-e.top;if(Math.abs(c)>0.5||Math.abs(K0)>0.5)N((s)=>s?{...s,left:s.left+c,top:s.top+K0}:s)},[U,B]);let d=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,a=(e,c,K0)=>{if(H&&e&&e!==H&&K0&&!d.test(K0))Y(K0);else Y(`var(${c})`);V(!1)},f=(e)=>{let c=(e||"").trim();if(c)Y(c)},h=D("div",{className:"st-cp-pop-search",children:[z(T9,{name:"search",size:12}),z("input",{value:A,onChange:(e)=>E(e.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),p=(e)=>e.map((c)=>D("div",{className:"st-cp-pop-group",children:[j?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((K0)=>D("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${k(K0)?" is-on":""}`,onClick:()=>a(c.ds,K0,c.vals?.[K0]),children:[z("span",{className:"st-cp-pop-cswatch",style:{background:c.vals?.[K0]||"transparent"},"aria-hidden":"true"}),z("span",{className:"st-cp-pop-name",children:R(K0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[K0]||""})]},`${c.ds}:${K0}`))})]},c.ds)),v=(e)=>e.map((c)=>D("div",{className:"st-cp-pop-group",children:[j?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((K0)=>D("button",{type:"button",className:`st-cp-pop-row${k(K0)?" is-on":""}`,onClick:()=>a(c.ds,K0,c.vals?.[K0]),children:[z("span",{className:"st-cp-pop-name",children:R(K0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[K0]||""})]},`${c.ds}:${K0}`))})]},c.ds)),r=z("div",{className:"st-cp-pop-empty",children:"No match"});return D(Q0,{children:[G!==void 0?z("button",{type:"button",ref:w,className:`${K||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${I&&!K?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>V((e)=>!e),children:z("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):z("button",{type:"button",ref:w,className:`st-cp-tokbtn${I?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>V((e)=>!e),children:z("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),U&&B?M90.createPortal(z("div",{ref:O,className:"maude st-cp-pop","data-theme":typeof document<"u"&&document.documentElement.getAttribute("data-theme")||"dark",role:"dialog","aria-label":W||"design tokens",style:{left:B.left,top:B.top,width:B.width,maxHeight:B.maxHeight},children:J==="color"?D(Q0,{children:[D("div",{className:"st-cp-poptabs",role:"tablist",children:[z("button",{type:"button",role:"tab","aria-selected":F==="custom",className:`st-cp-poptab${F==="custom"?" is-active":""}`,onClick:()=>M("custom"),children:"Custom"}),z("button",{type:"button",role:"tab","aria-selected":F==="vars",className:`st-cp-poptab${F==="vars"?" is-active":""}`,onClick:()=>M("vars"),children:"Variables"})]}),F==="custom"?z(k90,{seed:Z||BL(Q)||"#000000",onApply:f}):!C?z("div",{className:"st-cp-pop-empty",children:"No color tokens"}):D(Q0,{children:[h,m.length?p(m):r]})]}):!C?z("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):D(Q0,{children:[h,m.length?v(m):r]})}),document.body):null]})}function D90({label:J,tracks:X,editable:Q,onChange:Y}){let W=(K,U)=>{let V=X[K];Y(X.map((B,N)=>N===K?CU.has(U)?{value:0,unit:U}:{value:V.value||1,unit:U}:B))},G=(K,U)=>{Y(X.map((V,B)=>B===K?{...V,value:U}:V))},Z=()=>Y([...X,{value:1,unit:"fr"}]),H=(K)=>Y(X.filter((U,V)=>V!==K));return D("div",{className:"st-cp-gridtracks",children:[D("div",{className:"st-cp-gridtracks-hd",children:[z("span",{className:"st-cp-gridtracks-label",children:J}),z("button",{type:"button",className:"st-btn st-cp-gridtracks-add",disabled:!Q,onClick:Z,children:"+ Track"})]}),X.length===0?D("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",J.toLowerCase(),"."]}):X.map((K,U)=>{let V=CU.has(K.unit);return D("div",{className:"st-cp-gridtrack-row",children:[V?z(cW,{value:K.unit,ariaLabel:`${J} track ${U+1}`,options:G90.map((B)=>({value:B,label:B})),onChange:(B)=>W(U,B)}):z(zJ,{value:K.value,min:K.unit==="fr"?0.1:0,step:K.unit==="fr"?0.1:1,ariaLabel:`${J} track ${U+1} value`,lead:String(U+1),unitSlot:z(uN,{value:K.unit,units:G90,ariaLabel:`${J} track ${U+1} unit`,onChange:(B)=>W(U,B)}),onCommit:(B)=>G(U,B)}),z("button",{type:"button",className:"st-btn st-cp-gridtrack-remove","aria-label":`remove ${J} track ${U+1}`,disabled:!Q||X.length<=1,onClick:()=>H(U),children:"×"})]},U)})]})}function qL0({el:J,cfg:X,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let K=!!J.id,U=J.computed||{},[V,B]=u.useState({a:{},c:{},t:{}});u.useEffect(()=>{B({a:{},c:{},t:{}})},[J.id,J.authored,J.customStyles,J.attrs]);let N=(t,M0)=>{let _0={...t||{}};for(let[f0,Y8]of Object.entries(M0))if(Y8===null)delete _0[f0];else _0[f0]=Y8;return _0},F=N(J.authored,V.a),M=N(J.customStyles,V.c),A=N(J.attrs,V.t),E=(t,M0)=>B((_0)=>({..._0,a:{..._0.a,[t]:M0}})),w=(t,M0)=>B((_0)=>({..._0,c:{..._0.c,[t]:M0}})),O=(t,M0)=>B((_0)=>({..._0,t:{..._0.t,[t]:M0}})),I=(X?.designRel||X?.designRoot||".design").replace(/^\/+|\/+$/g,""),k=I90(J.file,X),R=T90(X,I,k),$=(t)=>R.map((M0)=>({ds:M0.name,names:M0[t]||[],vals:M0.vals})).filter((M0)=>M0.names.length),[C,j]=u.useState({}),[x,m]=u.useState({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),d=Object.keys(M).length>0||Object.keys(A).length>0;u.useEffect(()=>{if(d)m((t)=>t.Advanced?t:{...t,Advanced:!0})},[J.id,d]);let a=(F.position||U7(U.position)||"static")!=="static";u.useEffect(()=>{if(a)m((t)=>t["d:Position"]?t:{...t,"d:Position":!0})},[J.id,a]);let f=H,[h,p]=u.useState({});async function v(t,M0,_0){j((f0)=>({...f0,[_0]:"saving"}));try{let f0=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(M0)}),Y8=await f0.json().catch(()=>({}));return j((m8)=>({...m8,[_0]:!f0.ok||!Y8.ok?`err:${Y8&&Y8.error||`HTTP ${f0.status}`}`:"saved"})),f0.ok?Y8:null}catch(f0){return j((Y8)=>({...Y8,[_0]:`err:${f0&&f0.message?f0.message:String(f0)}`})),null}}let r=u.useRef(Promise.resolve()),e=(t,M0,_0,f0,Y8,m8,e8)=>{r.current=r.current.then(async()=>{let y8=await v(t,M0,_0);if(!y8?.ok)return;let W9=Object.hasOwn(y8,"previous")?y8.previous:m8;if((W9??null)===(e8??null))return;K0(f0,Y8,W9,e8)})},c=(t,M0)=>{if(!Q||!J.id)return;Q({id:J.id,artboardId:J.artboardId??null,index:J.index??0,prop:t,value:M0})},K0=(t,M0,_0,f0)=>{Y?.({op:t,canvas:J.file,id:J.id,key:M0,before:_0==null||_0===""?null:_0,after:f0==null||f0===""?null:f0})},s=(t,M0)=>{let _0=(M0||"").trim();if(!K||!_0)return;let f0=F[t]??null;if(_0===(f0??"").trim())return;c(t,_0),E(t,_0),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,value:_0},t,"css",t,f0,_0)},z0=(t,M0)=>{let _0=(M0||"").trim(),f0=t.trim();if(!K||!f0||!_0)return;let Y8=M[f0]??null;c(f0,_0),w(f0,_0),e("/_api/edit-css",{canvas:J.file,id:J.id,property:f0,value:_0},f0,"css",f0,Y8,_0)},o=(t,M0)=>{let _0=(t||"").trim(),f0=(M0||"").trim();if(!K||!_0||!f0)return;let Y8=A[_0]??null;O(_0,f0),e("/_api/edit-attr",{canvas:J.file,id:J.id,attr:_0,value:f0},`@${_0}`,"attr",_0,Y8,f0)},q0=(t)=>{if(!K)return;let M0=F[t]??null;c(t,null),E(t,null),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,reset:!0},t,"css",t,M0,null)},Z0=(t)=>{if(!K)return;let M0=M[t]??null;c(t,null),w(t,null),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,reset:!0},t,"css",t,M0,null)},k0=(t)=>{if(!K)return;let M0=A[t]??null;O(t,null),e("/_api/edit-attr",{canvas:J.file,id:J.id,attr:t,reset:!0},`@${t}`,"attr",t,M0,null)},a0={display:J.parentDisplay,flexDirection:J.parentFlexDirection},s0=(t,M0)=>{if(!K)return;let _0=Math.round((t==="width"?J.bounds?.w:J.bounds?.h)||0),f0=yb(t,M0,a0,_0);for(let Y8 of f0.reset)if(F[Y8])q0(Y8);for(let[Y8,m8]of f0.set)s(Y8,m8)},t0=J.parentDisplay==="flex"||J.parentDisplay==="inline-flex",E8=(t)=>{let M0=bb(t,F,U,a0);return D("div",{className:"st-cp-moderow",children:[z("span",{className:"st-cp-modelabel",children:t==="width"?"Width sizing":"Height sizing"}),z("div",{className:"st-cp-modeseg",role:"group","aria-label":`${t} sizing mode`,children:z(pN,{value:M0,ariaLabel:`${t} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(_0)=>s0(t,_0)})})]},`mode-${t}`)},a8=["flex-start","center","flex-end"],F8=["flex-start","center","flex-end"],T8=["t","c","b"],I0=["l","c","r"],w0=()=>{let t=!(F["flex-direction"]||U7(U["flex-direction"])||"row").startsWith("column"),M0=Math.max(0,a8.indexOf(F["justify-content"]||U7(U["justify-content"])||"flex-start")),_0=F["align-items"]||U7(U["align-items"])||"stretch",f0=_0==="stretch"?1:Math.max(0,F8.indexOf(_0)),[Y8,m8]=t?[M0,f0]:[f0,M0];return T8[m8]+I0[Y8]},C0=(t)=>{let M0=T8.indexOf(t[0]),_0=I0.indexOf(t[1]),f0=!(F["flex-direction"]||U7(U["flex-direction"])||"row").startsWith("column"),[Y8,m8]=f0?[_0,M0]:[M0,_0];s("justify-content",a8[Y8]),s("align-items",F8[m8])},W8=(t)=>{if(!(t.metaKey||t.ctrlKey)||t.altKey)return;let M0=t.key.toLowerCase();if(M0==="z")t.preventDefault(),G?.(t.shiftKey?"redo":"undo");else if(M0==="y")t.preventDefault(),G?.("redo")},H8=(t)=>{let M0=F[t];if(!M0)return"inherit";return/var\(\s*--/.test(M0)?"bound":"raw"};if(!K)return D("div",{className:"st-cp",children:[z("div",{className:"st-cp-id",children:z("span",{className:"st-cp-idtag",children:J.tag||"element"})}),D("div",{className:"st-css-disabled",children:["This selection has no stable element id (a legacy canvas, or a non-element target). Edit it with ",z("code",{children:"/design:edit"}),"."]})]});let x8={bound:"token-bound",raw:"raw override",inherit:"inherited"},S8=(t)=>z("span",{className:`st-cp-prov st-cp-prov--${t}`,role:"img","aria-label":x8[t]}),O9=(t,M0)=>{let _0=M0??H8(t),f0=C[t],Y8=typeof f0==="string"&&f0.startsWith("err:")?f0.slice(4):"",m8=Y8?" is-err":f0==="saved"?" is-saved":f0==="saving"?" is-saving":"",e8=!!F[t],y8=Y8?`error: ${Y8}`:e8?`${x8[_0]} · double-click to reset`:x8[_0];return z("button",{type:"button",className:`st-cp-prov st-cp-prov--${_0}${m8}${e8?" is-resettable":""}`,"aria-label":y8,title:y8,tabIndex:e8?0:-1,onDoubleClick:e8?()=>q0(t):void 0,onKeyDown:e8?(W9)=>{if(W9.key==="Backspace"||W9.key==="Delete")W9.preventDefault(),q0(t)}:void 0})},v0=(t,M0,_0,f0)=>{let Y8=_0===void 0&&!F[t],m8=f0??t;return D("div",{className:`st-cp-row${Y8?" is-unset":""}`,children:[O9(t,_0),z("label",{className:"st-cp-label",title:m8,children:m8}),z("div",{className:"st-cp-ctl",children:M0})]},t)},$8={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"]},w9=(t)=>{($8[t]||[]).forEach((M0)=>{if(F[M0])q0(M0)})},L8=(t,M0)=>{let _0=($8[t]||[]).some((f0)=>F[f0]);return D("section",{className:"st-cp-sec",children:[D("div",{className:"st-cp-sechd-row",children:[D("button",{type:"button",className:"st-cp-sechd","data-testid":`inspector-section-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,"aria-expanded":!!x[t],onClick:()=>m((f0)=>({...f0,[t]:!f0[t]})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:x[t]?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${_0?"":" is-quiet"}`,"aria-label":`reset ${t} section to original`,title:`reset ${t}`,disabled:!_0,onClick:()=>w9(t),children:z(K7,{as:oZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${x[t]?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:M0})})]},t)},V0=(t,M0,_0,f0=!0)=>{let Y8=`d:${t}`,m8=x[Y8]===void 0?f0:x[Y8],e8=M0.some((y8)=>F[y8]);return D("section",{className:"st-cp-sec",children:[D("div",{className:"st-cp-sechd-row",children:[D("button",{type:"button",className:"st-cp-sechd","aria-expanded":m8,onClick:()=>m((y8)=>({...y8,[Y8]:!m8})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:m8?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${e8?"":" is-quiet"}`,"aria-label":`reset ${t} to original`,title:`reset ${t}`,disabled:!e8,onClick:()=>M0.forEach((y8)=>{if(F[y8])q0(y8)}),children:z(K7,{as:oZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${m8?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:_0})})]},Y8)},J8=(t)=>z("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!h[t],"aria-label":h[t]?`${t} — fewer options`:`${t} — more options`,title:h[t]?"fewer":"more",onClick:()=>p((M0)=>({...M0,[t]:!M0[t]})),children:h[t]?"▴":"···"}),r0=(t,M0)=>D("select",{className:"st-cp-nsel","aria-label":t,value:M0.includes(F[t])?F[t]:"",onChange:(_0)=>s(t,_0.target.value),children:[z("option",{value:"",disabled:!0,children:U7(U[t])||"—"}),M0.map((_0)=>z("option",{value:_0,children:_0},_0))]}),b0=(t)=>$(t).flatMap((M0)=>(M0.names||[]).map((_0)=>({name:_0,value:M0.vals?.[_0]||""}))),X8=(t,M0)=>z(hw,{value:F[t]||U7(U[t])||M0[0].value,ariaLabel:t,options:M0,onChange:(_0)=>s(t,_0)}),q8=(t,M0,_0={})=>{let f0=Q4(F[t]??""),Y8=U90.has(t),m8=F[t]??"",e8=typeof m8==="string"&&/var\(\s*--/.test(m8),y8=Y8?"":f0.unit&&f0.unit!=="auto"?f0.unit:"px",W9=Number.parseFloat(Q4(U7(U[t])??"").n)||0,k9=f0.n!==""&&f0.n!=null?Number.parseFloat(f0.n)||0:W9,e9=Wk[t];return z(lN,{value:e8?m8:k9,tokens:b0(M0),ariaLabel:t,min:_0.min??0,lead:e9?e9.node??e9.t:void 0,unitSlot:Y8?null:z(uN,{units:K90,value:f0.unit||"px",ariaLabel:`${t} unit`,onChange:(J7)=>s(t,J7==="auto"?"auto":`${f0.n||"0"}${J7}`)}),onChange:(J7)=>s(t,typeof J7==="string"?J7:Y8?`${J7}`:`${J7}${y8}`)})},l0=()=>{let t=(Y8)=>Number.parseFloat(Q4(F[Y8]??F["border-radius"]??U7(U[Y8])??U7(U["border-radius"])??"0").n)||0,M0={tl:t("border-top-left-radius"),tr:t("border-top-right-radius"),bl:t("border-bottom-left-radius"),br:t("border-bottom-right-radius")},_0=(Y8)=>{if(Y8.tl===Y8.tr&&Y8.tr===Y8.bl&&Y8.bl===Y8.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((e8)=>{if(F[e8])q0(e8)}),s("border-radius",`${Y8.tl}px`);else s("border-top-left-radius",`${Y8.tl}px`),s("border-top-right-radius",`${Y8.tr}px`),s("border-bottom-left-radius",`${Y8.bl}px`),s("border-bottom-right-radius",`${Y8.br}px`)},f0=Wk["border-radius"];return z(vg,{corners:M0,lead:f0?f0.node??f0.t:void 0,onCorners:_0})},d0=()=>D("div",{className:"st-cp-border",children:[Q9("border-width",null,{fixedUnit:"px"}),D("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:z90.includes(F["border-style"])?F["border-style"]:"",onChange:(t)=>s("border-style",t.target.value),children:[z("option",{value:"",disabled:!0,children:"style"}),z90.map((t)=>z("option",{value:t,children:t},t))]}),z(KL,{kind:"color",groups:$("color"),current:F["border-color"],activeDs:k,swatchBg:U["border-color"]||F["border-color"]||"",seedHex:BL(U["border-color"]||F["border-color"])||"#000000",onPick:(t)=>s("border-color",t),label:"border colour"})]}),h0=()=>{let t=F.transform||U7(U.transform)||"",M0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(t),_0=((M0?Number.parseFloat(M0[1]):0)%360+360)%360,f0=(Y8)=>{let m8=(Y8%360+360)%360,e8=(F.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();s("transform",`${e8?`${e8} `:""}rotate(${m8}deg)`.trim())};return D("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[z(yg,{value:_0,onChange:f0}),z(zJ,{value:_0,min:0,max:360,ariaLabel:"rotation",lead:z(K7,{as:oZ}),steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:f0})]})},y0=()=>{let t=F.filter||U7(U.filter)||"",M0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(t),_0=M0?Number.parseFloat(M0[1]):0;return z(zJ,{value:_0,min:0,ariaLabel:"filter blur",unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(Y8)=>{let m8=(F.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();s("filter",Y8>0?`${m8?`${m8} `:""}blur(${Y8}px)`.trim():m8||"none")}})},B8=()=>{let t=F.opacity,M0=t!=null&&t!==""?Number.parseFloat(t):Number.parseFloat(U7(U.opacity))||1,_0=Math.round((Number.isNaN(M0)?1:M0)*100);return z(mX,{value:_0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(f0)=>c("opacity",String(f0/100)),onCommit:(f0)=>s("opacity",String(f0/100))},`opacity:${t??""}`)},D8=()=>{let t=Number.parseInt(F["font-weight"]||U7(U["font-weight"])||"400",10)>=600,M0=(F["font-style"]||U7(U["font-style"]))==="italic",_0=/underline/.test(F["text-decoration"]||U7(U["text-decoration"])||"");return z(Sg,{value:{b:t,i:M0,u:_0},ariaLabel:"text style",options:[{value:"b",node:z(K7,{as:mV}),label:"Bold"},{value:"i",node:z(K7,{as:cV}),label:"Italic"},{value:"u",node:z(K7,{as:Q3}),label:"Underline"}],onToggle:(f0)=>{if(f0==="b")s("font-weight",t?"400":"700");else if(f0==="i")s("font-style",M0?"normal":"italic");else s("text-decoration",_0?"none":"underline")}})},N0=[{value:"row",node:z(K7,{as:vW}),label:"Row"},{value:"column",node:z(K7,{as:fW}),label:"Column"}],o0=[{value:"flex-start",node:z(K7,{as:vV}),label:"Start"},{value:"center",node:z(K7,{as:yV}),label:"Center"},{value:"flex-end",node:z(K7,{as:jV}),label:"End"},{value:"space-between",node:z(K7,{as:PK}),label:"Space between"}],h8=[{value:"flex-start",node:z(K7,{as:hV}),label:"Start"},{value:"center",node:z(K7,{as:fV}),label:"Center"},{value:"flex-end",node:z(K7,{as:xV}),label:"End"},{value:"stretch",node:z(K7,{as:J3}),label:"Stretch"}],g8=[{value:"left",node:z(K7,{as:t5}),label:"Left"},{value:"center",node:z(K7,{as:gW}),label:"Center"},{value:"right",node:z(K7,{as:mW}),label:"Right"},{value:"justify",node:z(K7,{as:uW}),label:"Justify"}],e0=[{value:"visible",node:z(K7,{as:iZ}),label:"Visible"},{value:"hidden",node:z(K7,{as:nZ}),label:"Hidden"},{value:"scroll",node:z(K7,{as:sV}),label:"Scroll"}],a7=(t,M0)=>{let _0=$(M0);return _0.length?z(KL,{kind:"value",groups:_0,current:F[t],activeDs:k,onPick:(f0)=>s(t,f0),label:`${t} design token`}):null},F9=(t)=>{let M0=t.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===M0)M0.select()})},v7=(t,M0)=>{if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return!1;t.preventDefault();let _0=t.shiftKey?10:1,f0=t.key==="ArrowUp"?1:-1,Y8=(Number.parseFloat(t.currentTarget.value)||0)+f0*_0;return t.currentTarget.value=String(Y8),M0(Y8),!0},I8=(t)=>z("input",{className:"st-cp-fin","aria-label":t,defaultValue:F[t]??"",placeholder:U7(U[t])||"—",onFocus:F9,onKeyDown:(M0)=>{if(M0.key==="Enter")M0.currentTarget.blur()},onBlur:(M0)=>s(t,M0.currentTarget.value)},`${t}:${F[t]??""}`),Q9=(t,M0,_0={})=>{let f0=Q4(F[t]??""),Y8=U90.has(t),m8=Y8?"":_0.fixedUnit||(f0.unit&&f0.unit!=="auto"?f0.unit:"px"),e8=Wk[t],y8=Number.parseFloat(Q4(U7(U[t])??"").n)||0,W9=f0.n!==""&&f0.n!=null?Number.parseFloat(f0.n)||0:y8;return D(Q0,{children:[z(zJ,{value:W9,min:_0.min??0,step:1,ariaLabel:t,lead:e8?e8.node??e8.t:void 0,onCommit:(k9)=>s(t,Y8?`${k9}`:`${k9}${m8}`),unitSlot:Y8||_0.fixedUnit?null:z(uN,{units:K90,value:f0.unit||"px",ariaLabel:`${t} unit`,onChange:(k9)=>s(t,k9==="auto"?"auto":`${f0.n||"0"}${k9}`)})},`${t}:${F[t]??""}`),a7(t,M0)]})},c8=(t)=>{let M0=U[t]||F[t]||"",_0=F[t]??"",f0=typeof _0==="string"&&/var\(\s*--/.test(_0),Y8=f0?_0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):_0;return z(W3,{swatch:z(KL,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:$("color"),current:F[t],activeDs:k,swatchBg:M0,seedHex:BL(U[t]||F[t])||"#000000",onPick:(m8)=>s(t,m8),label:`${t} colour`}),displayValue:Y8,bound:f0,ariaLabel:t,onValue:(m8)=>s(t,m8)})},O0=(t,M0)=>{let _0=null,f0=M0.unitless?"":"px",Y8=(y8)=>M0.unitless?`${y8}`:`${y8}${f0}`,m8=(y8,W9,k9)=>{for(let e9 of W9??[t])k9(e9,Y8(y8))},e8=xw({getBase:()=>_0?.value??"0",min:M0.min??0,step:1,sides:M0.sides,onInput:(y8,W9)=>{if(_0)_0.value=String(y8);if(W9){let k9=_0?.closest(".st-cp-box");for(let e9 of W9){if(e9===t)continue;let J7=k9?.querySelector(`.st-cp-boxv[aria-label="${e9}"]`);if(J7)J7.value=String(y8)}}m8(y8,W9,c)},onCommit:(y8,W9)=>m8(y8,W9,s)});return{onPointerDown:(y8)=>{_0=y8.currentTarget,e8(y8)}}},K8=(t,M0)=>{let _0=F[t],f0=_0!=null&&_0!==""?Q4(_0).n||_0:Q4(U7(U[t])??"").n||"0",Y8=!_0||_0==="0"||_0==="0px"||_0==="auto",m8=t.split("-").pop(),e8=m8==="top"||m8==="bottom"?[`${M0}-top`,`${M0}-bottom`]:[`${M0}-left`,`${M0}-right`],y8=[`${M0}-top`,`${M0}-right`,`${M0}-bottom`,`${M0}-left`];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${M0[0]}${t.split("-").pop()[0]}${Y8?" is-zero":""}`,"aria-label":t,defaultValue:f0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...O0(t,{sides:{pair:e8,all:y8}}),onFocus:F9,onKeyDown:(W9)=>{if(v7(W9,(k9)=>s(t,`${k9}px`)))return;if(W9.key==="Enter")W9.currentTarget.blur()},onBlur:(W9)=>{let k9=W9.currentTarget.value.trim();if(!k9)return;let e9=/[a-z%]/i.test(k9)?k9:`${k9}px`;s(t,e9)}},`${t}:${_0??""}`)},C8=(t)=>{let M0=F[t],_0=M0!=null&&M0!==""&&M0!=="auto"?Q4(M0).n||M0:Q4(U7(U[t])??"").n||"",f0=!M0||M0==="auto"||M0==="0"||M0==="0px",Y8=t==="top"||t==="bottom"?["top","bottom"]:["left","right"],m8=["top","right","bottom","left"];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${t[0]}${f0?" is-zero":""}`,"aria-label":t,defaultValue:_0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...O0(t,{sides:{pair:Y8,all:m8},min:-1/0}),onFocus:F9,onKeyDown:(e8)=>{if(v7(e8,(y8)=>s(t,`${y8}px`)))return;if(e8.key==="Enter")e8.currentTarget.blur()},onBlur:(e8)=>{let y8=e8.currentTarget.value.trim();if(!y8)return;let W9=/[a-z%]/i.test(y8)?y8:`${y8}px`;s(t,W9)}},`${t}:${M0??""}`)},V9=Object.entries(M),x9=Object.entries(A),i9=()=>{let t=(J.tag||"").toLowerCase(),_0=t==="img"||t==="video"||t==="picture"||t==="svg"||t==="canvas"||!!F["object-fit"]||!!F["object-position"]||!!F["aspect-ratio"],f0=(t==="img"||t==="video")&&!!J.attrs?.src&&!!W;return{showMedia:_0,canReplace:f0}},h9=(t)=>D(Q0,{children:[t&&z("div",{className:"st-cp-mediabtn",children:z("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>W(J),children:"Replace…"})}),v0("object-fit",r0("object-fit",UL0)),v0("object-position",I8("object-position")),v0("aspect-ratio",D("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:F90.includes(F["aspect-ratio"])?F["aspect-ratio"]:"",onChange:(M0)=>{let _0=M0.target.value;if(s("aspect-ratio",_0),_0&&_0!=="auto"&&F.height)q0("height")},children:[z("option",{value:"",disabled:!0,children:U7(U["aspect-ratio"])||"—"}),F90.map((M0)=>z("option",{value:M0,children:M0},M0))]}))]});return D("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:W8,children:[D("div",{className:"st-cp-id",children:[D("span",{className:"st-cp-idtag",children:[J.tag||"element",J.classes?D("span",{className:"st-cp-idcls",children:[".",J.classes.split(/\s+/)[0]]}):null]}),z("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:z(hw,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:z(K7,{as:jW,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:z(K7,{as:pW,size:12}),label:"Designer — Figma vocabulary"}],onChange:f})})]}),Z==="designer"?D(Q0,{children:[V0("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let t=(F.display||U7(U.display)||"").trim();return t==="flex"||t==="inline-flex"?D(Q0,{children:[v0("flex-direction",X8("flex-direction",N0),void 0,"Direction"),v0("align-items",z(bg,{value:w0(),onChange:C0,ariaLabel:"auto-layout alignment"}),H8("align-items"),"Alignment"),v0("gap",q8("gap","space"),void 0,"Gap"),D("div",{className:"st-cp-modes",children:[E8("width"),E8("height")]}),D("div",{className:"st-cp-box","aria-label":"padding",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[S8(H8("padding-top")),"padding"]}),K8("padding-top","padding"),K8("padding-right","padding"),K8("padding-bottom","padding"),K8("padding-left","padding")]}),z("div",{className:"st-cp-clustermore-row",children:J8("Auto layout")}),h["Auto layout"]?v0("flex-wrap",z(aQ,{checked:/^wrap/.test(F["flex-wrap"]||U7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(_0)=>s("flex-wrap",_0?"wrap":"nowrap")}),H8("flex-wrap"),"Wrap"):null]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>s("display","flex"),children:"+ Auto layout (flex)"})})()),V0("Size",["width","height","min-width","max-width","min-height","max-height"],D(Q0,{children:[v0("width",Q9("width"),void 0,"Width"),v0("height",Q9("height"),void 0,"Height"),z("div",{className:"st-cp-clustermore-row",children:J8("Size")}),h.Size?D(Q0,{children:[v0("min-width",Q9("min-width"),void 0,"Min width"),v0("max-width",Q9("max-width"),void 0,"Max width"),v0("min-height",Q9("min-height"),void 0,"Min height"),v0("max-height",Q9("max-height"),void 0,"Max height")]}):null]})),V0("Position",["position","top","right","bottom","left","z-index"],D(Q0,{children:[v0("position",r0("position",V90),void 0,"Position"),D("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[S8(H8("top")),"inset"]}),C8("top"),C8("right"),C8("bottom"),C8("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||U7(U.position)||"static"})]}),(F.position||U7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,z("div",{className:"st-cp-clustermore-row",children:J8("Position")}),h.Position?v0("z-index",Q9("z-index"),void 0,"Layer order"):null]}),!1),V0("Fill",["background-color"],v0("background-color",c8("background-color"),void 0,"Fill")),V0("Stroke",["border-width","border-style","border-color"],v0("border",d0(),H8("border-width"),"Stroke")),V0("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],v0("border-radius",l0(),H8("border-radius"),"Corner radius")),V0("Effects",["box-shadow","filter","mix-blend-mode"],D(Q0,{children:[v0("box-shadow",a7("box-shadow","shadow")||I8("box-shadow"),void 0,"Shadow"),v0("filter",y0(),H8("filter"),"Blur"),v0("mix-blend-mode",r0("mix-blend-mode",N90),void 0,"Blend")]})),V0("Opacity",["opacity"],v0("opacity",B8(),void 0,"Opacity")),V0("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],D(Q0,{children:[v0("font-family",r0("font-family",H90),void 0,"Font"),v0("color",c8("color"),void 0,"Color"),v0("font-size",q8("font-size","type"),void 0,"Size"),v0("font-weight",r0("font-weight",Z90),void 0,"Weight"),v0("line-height",Q9("line-height","lh"),void 0,"Line height"),v0("text-align",X8("text-align",g8),void 0,"Align"),z("div",{className:"st-cp-clustermore-row",children:J8("Text")}),h.Text?D(Q0,{children:[v0("letter-spacing",Q9("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),v0("font-style",r0("font-style",KL0),void 0,"Style"),v0("text-transform",r0("text-transform",q90),void 0,"Case"),v0("white-space",r0("white-space",B90),void 0,"Whitespace")]}):null]})),V0("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],D("div",{className:"st-cp-box","aria-label":"margin",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[S8(H8("margin-top")),"margin"]}),K8("margin-top","margin"),K8("margin-right","margin"),K8("margin-bottom","margin"),K8("margin-left","margin")]})),(()=>{let{showMedia:t,canReplace:M0}=i9();return t?V0("Media",["object-fit","object-position","aspect-ratio"],h9(M0)):null})()]}):D(Q0,{children:[L8("Layout",(()=>{let t=(F.display||U7(U.display)||"").trim(),M0=t==="flex"||t==="inline-flex",_0=t==="grid"||t==="inline-grid";return D(Q0,{children:[v0("display",r0("display",HL0)),M0?D(Q0,{children:[v0("flex-direction",X8("flex-direction",N0)),v0("flex-wrap",z(aQ,{checked:/^wrap/.test(F["flex-wrap"]||U7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(f0)=>s("flex-wrap",f0?"wrap":"nowrap")}),H8("flex-wrap"))]}):null,M0||_0?D(Q0,{children:[v0("align-items",X8("align-items",h8)),v0("justify-content",X8("justify-content",o0)),v0("gap",q8("gap","space"))]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>s("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let t=(F.display||U7(U.display)||"").trim();if(!(t==="grid"||t==="inline-grid"))return null;let _0=F["grid-template-columns"]||"",f0=F["grid-template-rows"]||"",Y8=EO(_0),m8=EO(f0),e8=Y8.length>0||!_0.trim(),y8=m8.length>0||!f0.trim();return L8("Grid",D(Q0,{children:[e8?z(D90,{label:"Columns",tracks:Y8,editable:K,onChange:(W9)=>s("grid-template-columns",PO(W9))}):D("div",{className:"st-cp-note",children:["Columns use ",z("code",{children:_0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),y8?z(D90,{label:"Rows",tracks:m8,editable:K,onChange:(W9)=>s("grid-template-rows",PO(W9))}):D("div",{className:"st-cp-note",children:["Rows use ",z("code",{children:f0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),L8("Position",D(Q0,{children:[v0("position",r0("position",V90)),D("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[S8(H8("top")),"inset"]}),C8("top"),C8("right"),C8("bottom"),C8("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||U7(U.position)||"static"})]}),(F.position||U7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,v0("z-index",Q9("z-index"))]})),(J.parentDisplay==="grid"||J.parentDisplay==="inline-grid")&&L8("Grid item",D(Q0,{children:[D("div",{className:"st-cp-note",children:["Manual cell placement — ",z("code",{children:"start / end"})," or ",z("code",{children:"start / span N"}),"."]}),v0("grid-column",I8("grid-column")),v0("grid-row",I8("grid-row"))]})),L8("Typography",D(Q0,{children:[v0("font-family",r0("font-family",H90)),v0("color",c8("color")),v0("font-size",q8("font-size","type")),v0("font-weight",r0("font-weight",Z90)),v0("line-height",Q9("line-height","lh")),v0("letter-spacing",Q9("letter-spacing",null,{min:-1/0})),v0("text-align",X8("text-align",g8)),v0("font-style",D8(),H8("font-style")),v0("text-transform",r0("text-transform",q90)),v0("white-space",r0("white-space",B90))]})),L8("Spacing",z(Q0,{children:D("div",{className:"st-cp-box","aria-label":"margin and padding",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[S8(H8("margin-top")),"margin"]}),K8("margin-top","margin"),K8("margin-right","margin"),K8("margin-bottom","margin"),K8("margin-left","margin"),D("div",{className:"st-cp-boxpad",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[S8(H8("padding-top")),"padding"]}),K8("padding-top","padding"),K8("padding-right","padding"),K8("padding-bottom","padding"),K8("padding-left","padding"),D("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(F.width)||J.bounds?.w||0)," × ",Math.round(Number.parseFloat(F.height)||J.bounds?.h||0)]})]})]})})),L8("Size",D(Q0,{children:[D("div",{className:"st-cp-modes",children:[E8("width"),E8("height")]}),v0("width",Q9("width")),v0("height",Q9("height")),v0("min-width",Q9("min-width")),v0("max-width",Q9("max-width")),v0("min-height",Q9("min-height")),v0("max-height",Q9("max-height")),v0("overflow",X8("overflow",e0)),t0?D(Q0,{children:[z("div",{className:"st-cp-subhd",children:"In flex parent"}),v0("align-self",r0("align-self",zL0)),v0("flex-grow",Q9("flex-grow",null,{unitless:!0})),v0("flex-shrink",Q9("flex-shrink",null,{unitless:!0})),v0("flex-basis",Q9("flex-basis"))]}):null]})),(()=>{let{showMedia:t,canReplace:M0}=i9();return t?L8("Media",h9(M0)):null})(),L8("Appearance",D(Q0,{children:[v0("background-color",c8("background-color")),v0("border-radius",l0(),H8("border-radius")),v0("border",d0(),H8("border-width")),v0("box-shadow",a7("box-shadow","shadow")||I8("box-shadow")),v0("filter",y0(),H8("filter")),v0("mix-blend-mode",r0("mix-blend-mode",N90)),v0("opacity",B8()),v0("rotation",h0(),H8("transform")),v0("transform",I8("transform")),v0("transform-origin",I8("transform-origin"))]})),(()=>{let t=Object.entries(C).find(([,M0])=>typeof M0==="string"&&M0.startsWith("err:"));return t?D("div",{className:"st-cp-save is-err",role:"status",children:[z(T9,{name:"x",size:12}),t[0],": ",t[1].slice(4)]}):null})(),L8("Advanced",D("div",{className:"st-cp-advbody",children:[V9.length?D(Q0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),V9.map(([t,M0])=>D("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`custom property ${t} name`}),z("input",{className:"st-cp-fin",defaultValue:M0,"aria-label":`${t} value`,onKeyDown:(_0)=>{if(_0.key==="Enter")_0.currentTarget.blur()},onBlur:(_0)=>z0(t,_0.currentTarget.value)},`cs:${t}:${M0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>Z0(t),children:z(T9,{name:"x",size:11})})]},`cs:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add CSS property"}),z(BL0,{commit:z0}),z("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),x9.length?D(Q0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),x9.map(([t,M0])=>D("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`attribute ${t} name`}),z("input",{className:"st-cp-fin",defaultValue:M0,"aria-label":`${t} value`,onKeyDown:(_0)=>{if(_0.key==="Enter")_0.currentTarget.blur()},onBlur:(_0)=>o(t,_0.currentTarget.value)},`at:${t}:${M0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>k0(t),children:z(T9,{name:"x",size:11})})]},`at:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),z(NL0,{commit:o})]}))]}),D("div",{className:"st-cp-legend",children:[D("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),D("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),D("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},J.id)}function BL0({commit:J}){let[X,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(X.trim()&&Y.trim())J(X.trim(),Y),Q(""),W("")};return D("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom property name",placeholder:"property",value:X,onChange:(Z)=>Q(Z.target.value)}),z("input",{className:"st-cp-fin","aria-label":"custom property value",placeholder:"value",value:Y,onChange:(Z)=>W(Z.target.value),onKeyDown:(Z)=>{if(Z.key==="Enter")G()},onBlur:G})]})}function NL0({commit:J}){let[X,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(X.trim()&&Y.trim())J(X.trim(),Y),Q(""),W("")};return D("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom attribute name",placeholder:"data-…",value:X,onChange:(Z)=>Q(Z.target.value)}),z("input",{className:"st-cp-fin","aria-label":"custom attribute value",placeholder:"value",value:Y,onChange:(Z)=>W(Z.target.value),onKeyDown:(Z)=>{if(Z.key==="Enter")G()},onBlur:G})]})}var FL0={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function LL0(J,X,Q,Y){if(!Array.isArray(J)||X===Q)return J;let W=JSON.parse(JSON.stringify(J)),G=null,Z=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===X)return G=K[U],K.splice(U,1),!0;if(K[U].children&&Z(K[U].children))return!0}return!1};if(Z(W),!G)return J;let H=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===Q){if(Y==="inside-start"||Y==="inside-end")if(K[U].children=K[U].children||[],Y==="inside-start")K[U].children.unshift(G);else K[U].children.push(G);else K.splice(Y==="before"?U:U+1,0,G);return!0}if(K[U].children&&H(K[U].children))return!0}return!1};return H(W)?W:J}var DL0=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function R90({node:J,depth:X,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:V,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:M,onToggleLock:A,onRename:E}){let w=`${J.id}:${J.index}`,O=J.children&&J.children.length>0,I=W.has(w),k=!!J.synthetic,R=!k&&F?F[J.id]:null,$=!k&&!!M?.has(w),[C,j]=u.useState(!1),[x,m]=u.useState(""),d=!k&&J.id===Q&&(Y==null||J.index===Y),a=G?.has(w)?G.get(w):!!J.hidden,f=!!V&&!k&&!$,h=()=>{j(!1);let r=x.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!r||r===(J.dcElement??""))return;E?.(J,r)},p=N?.key===w,v=p?{transform:`translate(${N.dx}px, ${N.dy}px)`,opacity:0.9,zIndex:20,position:"relative",pointerEvents:"none",cursor:"grabbing",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.28)"}:null;return D(Q0,{children:[D("div",{className:"st-layer st-layer--row"+(d?" is-sel":"")+(a?" is-hidden":"")+(k?" is-group":"")+(R?" is-instance":"")+($?" is-locked":""),style:{paddingLeft:6+X*14,...v},role:"treeitem","aria-selected":k?void 0:d,"aria-expanded":O?!I:void 0,"aria-grabbed":f?p:void 0,tabIndex:0,title:k?`${J.tag} · group (unstamped wrapper)`:`${J.tag} · ${J.type}${E?" · F2 to rename":""}`,"data-layer-key":w,onClick:()=>k?O&&Z(w):H(J),onMouseEnter:()=>!k&&K(J),onMouseLeave:()=>K(null),onPointerDown:f?(r)=>B(r,J,w):void 0,onKeyDown:(r)=>{if(r.key==="Enter"||r.key===" ")if(r.preventDefault(),k)O&&Z(w);else H(J);else if(r.key==="F2"&&E&&!k)r.preventDefault(),m(J.dcElement||J.label||""),j(!0)},children:[O?z("button",{type:"button",className:"st-layer-caret","aria-label":I?"Expand":"Collapse",onClick:(r)=>{r.stopPropagation(),Z(w)},children:I?"▸":"▾"}):z("span",{className:"st-layer-caret","aria-hidden":"true"}),R?z("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:R.root?"◆":"◇"}):z(T9,{name:FL0[J.type]||"box",size:12,className:"st-layer-ticon"}),C?z("input",{className:"st-layer-rename",value:x,autoFocus:!0,"aria-label":`Rename ${J.label}`,onFocus:(r)=>r.target.select(),onChange:(r)=>m(r.target.value),onClick:(r)=>r.stopPropagation(),onPointerDown:(r)=>r.stopPropagation(),onBlur:h,onKeyDown:(r)=>{if(r.stopPropagation(),r.key==="Enter")h();else if(r.key==="Escape")j(!1)}}):z("span",{className:"st-layer-label",onDoubleClick:E&&!k?(r)=>{r.stopPropagation(),m(J.dcElement||J.label||""),j(!0)}:void 0,children:J.label}),z("span",{className:"st-layer-type",children:R?R.component:J.type}),A&&!k?z("button",{type:"button",className:"st-layer-lock","aria-label":$?`Unlock ${J.label}`:`Lock ${J.label}`,"aria-pressed":$,title:$?"Unlock":"Lock",onClick:(r)=>{r.stopPropagation(),A(w)},children:z(T9,{name:$?"lock":"unlock",size:12})}):null,U&&!k?z("button",{type:"button",className:"st-layer-eye","aria-label":a?`Show ${J.label}`:`Hide ${J.label}`,"aria-pressed":a,title:a?"Show":"Hide",onClick:(r)=>{r.stopPropagation(),U(J)},children:z(T9,{name:a?"eye-off":"eye",size:13})}):null]}),O&&!I?J.children.map((r,e)=>z(R90,{node:r,depth:X+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:V,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:M,onToggleLock:A,onRename:E},`${r.id}:${r.index}`)):null]})}function ML0({el:J}){let X=J?.computed||{},Q=J?.authored||{},Y=(U)=>{let V=Q[U];if(V&&/var\(\s*--/.test(V))return V.replace(/^var\(\s*|\s*\)$/g,"");return X[U]||V||""},W=(U,V)=>{let B=X[V]||Q[V];if(!B)return null;return D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:U}),D("div",{className:"st-swatch-row",children:[z("span",{className:"st-insp-swatch",style:{background:B},"aria-hidden":"true"}),z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Y(V)})]})]},U)},G=X["border-radius"]&&X["border-radius"]!=="0px",Z=G?Q4(X["border-radius"]).n||X["border-radius"]:null,H=X["font-size"]||X["font-weight"]?[X["font-size"],X["font-weight"]].filter(Boolean).join(" / "):null;if(!(X["background-color"]||X.color||G||H))return null;return D(Q0,{children:[G?D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Radius"}),D("div",{className:"st-insp-fields",children:[D("span",{className:"st-fmini",style:{flex:"0 0 auto",maxWidth:84},children:[z("span",{className:"st-mtag",children:"r"}),z("input",{value:Z,readOnly:!0,"aria-label":"border radius"})]}),z("span",{className:"st-insp-unit",children:"px"})]})]}):null,W("Fill","background-color"),W("Text","color"),H?D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Font"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:H})})]}):null]})}function C90(J){if(J.artboardId)return J.artboardId;let X=/^\[data-dc-screen="([^"]+)"\]$/.exec(J.selector||"");return X?X[1]:null}var OL0=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],AL0=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function _L0({el:J,cfg:X,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let K=C90(J),U=(X?.designRel||X?.designRoot||".design").replace(/^\/+|\/+$/g,""),V=I90(J.file,X),B=T90(X,U,V),N=(v)=>B.map((r)=>({ds:r.name,names:r[v]||[],vals:r.vals})).filter((r)=>r.names.length),F=(v)=>N(v).flatMap((r)=>(r.names||[]).map((e)=>({name:e,value:r.vals?.[e]||""}))),M=(v)=>{let r=/^var\(\s*(--[\w-]+)\s*\)$/.exec(v||"");if(!r)return v||"";for(let e of B){let c=e.vals?.[r[1]];if(c)return c}return""},A=Number.isFinite(J.worldW)?J.worldW:Number.isFinite(J.bounds?.w)?J.bounds.w:null,E=Number.isFinite(J.worldH)?J.worldH:Number.isFinite(J.bounds?.h)?J.bounds.h:null,w=(v,r)=>{if(!K)return;let e=Number.isFinite(v)&&v>0?Math.round(v):void 0,c=Number.isFinite(r)&&r>0?Math.round(r):void 0;if(e==null&&c==null)return;Q?.(K,e,c)},O=Object.entries(b5).find(([,v])=>v.width===A&&v.height===E)?.[0],I=Object.entries(b5).find(([,v])=>v.width===A)?.[0],k=J.attrs?.["data-dc-fixed"]==="true",R=J.attrs?.["data-dc-bg"]??"",$=J.attrs?.["data-dc-padding"]??"",C=J.attrs?.["data-dc-layout"]??"",j=J.attrs?.["data-dc-gap"]??"",x=J.attrs?.["data-dc-kind"]||"digital",m=null;try{m=J.attrs?.["data-dc-print"]?JSON.parse(J.attrs["data-dc-print"]):null}catch{}let d=(v)=>{if(!K)return;let r=null;if(v==="print"&&!m){let e={paper:"a4"};try{let c=a2(e);if(c)r={defaults:e,widthPx:c.widthPx,heightPx:c.heightPx}}catch{}}if(G?.(K,v==="digital"?null:v,r),v==="web"&&k)Y?.(K,!1,void 0)},a=(v)=>{if(!K)return;let r={paper:"a4",...m,...v},e;try{e=a2(r)}catch{return}Q?.(K,e.widthPx,e.heightPx),Z?.(K,r)},f=(v,r)=>{if(!K)return;let e=Number.isFinite(r)?r:E,c=v&&Number.isFinite(e)?Math.round(e):void 0;Y?.(K,v,c)},h=(v)=>{let r=Cb(k,v);if(r.kind==="resize")w(null,r.height);else if(r.kind==="promote-to-fixed")f(!0,r.height)},p=(v)=>{if(!K)return;W?.(K,v)};return D("section",{className:"st-cp-sec",children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Artboard"})}),D("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[z(zJ,{value:A??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(v)=>w(v,null)}),z(zJ,{value:E??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:k,onCommit:h})]}),z("div",{style:{padding:"0 12px 8px"},children:x==="print"?D("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:m?.paper??"",onChange:(v)=>a({paper:v.currentTarget.value}),children:[z("option",{value:"",disabled:!0,children:"Paper size…"}),r2.map((v)=>D("option",{value:v.id,children:[v.label," — ",v.width,"×",v.height,v.unit]},v.id))]}):x==="web"?D("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:I??"",onChange:(v)=>{let r=b5[v.currentTarget.value];if(r)w(r.width,null)},children:[z("option",{value:"",disabled:!0,children:I?`${b5[I].label} — ≤ ${b5[I].width}px`:"Breakpoint…"}),Object.entries(b5).map(([v,r])=>D("option",{value:v,children:[r.label," — ≤ ",r.width,"px breakpoint"]},v))]}):D("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:O??"",onChange:(v)=>{let r=b5[v.currentTarget.value];if(r)w(r.width,r.height)},children:[z("option",{value:"",disabled:!0,children:O?b5[O].label:"Preset size…"}),Object.entries(b5).map(([v,r])=>D("option",{value:v,children:[r.label," — ",r.width,"×",r.height]},v))]})}),z("div",{style:{padding:"0 12px 8px"},children:z(pN,{value:k?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(v)=>f(v==="fixed")})}),z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Kind"})}),z("div",{style:{padding:"0 12px 8px"},children:z(cW,{value:x,ariaLabel:"artboard kind",options:AL0.map(([v,r])=>({value:v,label:r})),onChange:d})}),x!=="print"&&K&&H?z("div",{style:{padding:"0 12px 8px"},children:D("select",{className:"st-cp-nsel","aria-label":"duplicate artboard at breakpoint width",value:"",onChange:(v)=>{let r=b5[v.currentTarget.value];if(r)H(K,r.width);v.currentTarget.value=""},children:[z("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(b5).map(([v,r])=>D("option",{value:v,children:[r.label," — ",r.width,"px"]},v))]})}):null,x==="print"?D(Q0,{children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Print"})}),z("div",{style:{padding:"0 12px 8px"},children:z(pN,{value:m?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(v)=>a({orientation:v})})}),z("div",{style:{padding:"0 12px 8px"},children:z(zJ,{value:Number.isFinite(m?.bleedMm)?m.bleedMm:3,min:0,step:0.5,ariaLabel:"bleed, millimeters",lead:"B",steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"mm"}),onCommit:(v)=>a({bleedMm:v})})})]}):null,z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Style"})}),D("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let v=M(R),r=/var\(\s*--/.test(R),e=r?R.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):R;return z(W3,{swatch:z(KL,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:N("color"),current:R,activeDs:V,swatchBg:v,seedHex:BL(v)||"#000000",onPick:(c)=>p({background:c||null}),label:"artboard background colour"}),displayValue:e,bound:r,ariaLabel:"artboard background",onValue:(c)=>p({background:(c||"").trim()||null})})})(),z(cW,{value:C,ariaLabel:"artboard body layout",options:OL0.map(([v,r])=>({value:v,label:r})),onChange:(v)=>p({layout:v||null})}),D("div",{style:{display:"flex",gap:8},children:[z(lN,{value:/^var\(/.test($)?$:Number.parseFloat($)||0,tokens:F("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(v)=>p({padding:typeof v==="string"?v:v>0?v:null})}),z(lN,{value:/^var\(/.test(j)?j:Number.parseFloat(j)||0,tokens:F("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(v)=>p({gap:typeof v==="string"?v:v>0?v:null})})]})]})]})}var Hk=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,wL0=new RegExp(Hk.source,"gi");function EL0(J){if(!J||Array.isArray(J))return null;if(J.photoAsset)return J.photoAsset;let X=J.html||"";if((J.tag||"").toLowerCase()!=="img"){let W=[...new Set(X.match(wL0)||[])],G=[...new Set([...X.matchAll(/data-photo-asset="([^"]+)"/g)].map((Z)=>Z[1]))];if(G.length===1)return G[0];if(G.length===0&&W.length===1&&/<img/i.test(X))return W[0];return null}let Q=/data-photo-asset="([^"]+)"/.exec(X);if(Q)return Q[1];let Y=Hk.exec(`${J.attrs?.src||""} ${X}`);return Y?Y[0]:null}function PL0({testId:J,selected:X,onClose:Q,layersTree:Y,componentMap:W,lockedKeys:G,onToggleLock:Z,onDetachInstance:H,canvasFile:K,onSelectLayer:U,onHoverLayer:V,onReorderLayer:B,layersBusyRef:N,cfg:F,onOptimistic:M,onRecordEdit:A,onReplaceMedia:E,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:I,onSetArtboardKind:k,onSetArtboardPrint:R,onDuplicateArtboard:$,onUndoRedo:C,editScope:j,tab:x,onTabChange:m,width:d,resizing:a,photoSel:f,photoRev:h,onPhotoEdit:p,onPhotoRemoveBackground:v,onPhotoRecordEdit:r,onPhotoUndoRedo:e,layersOnly:c=!1,hideLayersTab:K0=!1,cpMode:s,onSetCpMode:z0}){let[o,q0]=u.useState("inspect"),Z0=c?"layers":x??o,k0=(l0)=>{q0(l0),m?.(l0)},[a0,s0]=u.useState(()=>new Set),[t0,E8]=u.useState(()=>new Map);u.useEffect(()=>{let l0=Array.isArray(X)?X[0]:X,d0=l0?.id;if(!d0||!Y?.nodes)return;let h0=l0.index,y0=null,B8=[];if(function D8(N0,o0){for(let h8 of N0||[]){let g8=`${h8.id}:${h8.index}`;if(!h8.synthetic&&h8.id===d0&&(h0==null||h8.index===h0))return y0=g8,B8.push(...o0),!0;if(h8.children&&h8.children.length&&D8(h8.children,[...o0,g8]))return!0}return!1}(Y.nodes,[]),!y0)return;if(B8.length)s0((D8)=>{let N0=!1,o0=new Set(D8);for(let h8 of B8)if(o0.delete(h8))N0=!0;return N0?o0:D8});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${y0}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[X,Y]);let a8=(l0)=>{let d0=`${l0.id}:${l0.index}`;return t0.has(d0)?t0.get(d0):!!l0.hidden},[F8,T8]=u.useState(null),[I0,w0]=u.useState(""),C0=(l0,d0)=>{if(!K||!l0?.id)return;fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:K,id:l0.id,attr:"data-dc-element",value:d0})}).then((h0)=>h0.json().catch(()=>({}))).then((h0)=>{if(!h0.ok)return;A?.({op:"attr",canvas:K,id:l0.id,key:"data-dc-element",before:l0.dcElement??null,after:d0})}).catch(()=>{})},W8=B?(l0,d0,h0)=>{if(N?.current)return;if(l0?.synthetic||d0?.synthetic)return;let y0=h0==="before"?`before ${d0.label}`:h0==="after"?`after ${d0.label}`:`into ${d0.label}`;w0(`Moved ${l0.label} ${y0}`),B(l0.id,d0.id,h0,{idIndex:l0.index,refIndex:d0.index})}:void 0,H8=()=>{let l0=[];return function d0(h0,y0,B8){(h0||[]).forEach((D8,N0)=>{if(l0.push({node:D8,depth:y0,parentNode:B8,siblings:h0,pos:N0}),D8.children&&D8.children.length&&!a0.has(`${D8.id}:${D8.index}`))d0(D8.children,y0+1,D8)})}(Y?.nodes,0,null),l0},x8=(l0)=>{if(l0.key!=="ArrowUp"&&l0.key!=="ArrowDown")return;if(!L8)return;let d0=H8(),h0=d0.findIndex((N0)=>N0.node.id===L8.id&&N0.node.index===L8.index);if(h0<0)return;let y0=l0.key==="ArrowDown"?1:-1,B8=d0[h0];if(!l0.altKey){let N0=d0[h0+y0];if(N0)l0.preventDefault(),U?.(N0.node);return}if(!W8||!Array.isArray(B8.siblings))return;l0.preventDefault();let D8=(N0)=>N0&&N0.children&&N0.children.length&&!a0.has(`${N0.id}:${N0.index}`);if(!l0.shiftKey){if(y0<0&&B8.pos>0)W8(B8.node,B8.siblings[B8.pos-1],"before");else if(y0>0&&B8.pos<B8.siblings.length-1)W8(B8.node,B8.siblings[B8.pos+1],"after");return}if(y0>0){let N0=B8.siblings[B8.pos+1];if(N0)W8(B8.node,N0,D8(N0)?"inside-start":"after");else if(B8.parentNode)W8(B8.node,B8.parentNode,"after")}else{let N0=B8.siblings[B8.pos-1];if(N0)W8(B8.node,N0,D8(N0)?"inside-end":"before");else if(B8.parentNode)W8(B8.node,B8.parentNode,"before")}},S8=u.useRef(null),O9=u.useRef(null),v0=(l0,d0,h0)=>{if(!W8||l0.button!==0||l0.metaKey||l0.ctrlKey||l0.shiftKey||l0.altKey)return;if(N?.current)return;let{clientX:y0,clientY:B8}=l0,D8=new Set([h0]);(function c8(O0){(O0.children||[]).forEach((K8)=>{D8.add(`${K8.id}:${K8.index}`),c8(K8)})})(d0);let N0=14,o0=6,h8=[];(function c8(O0,K8){(O0||[]).forEach((C8)=>{let V9=`${C8.id}:${C8.index}`;if(h8.push({node:C8,key:V9,id:C8.id,depth:K8,tag:C8.tag}),C8.children&&C8.children.length&&!a0.has(V9))c8(C8.children,K8+1)})})(Y?.nodes,0);let g8=new Map(h8.map((c8)=>[c8.key,c8])),e0=!1,a7=(c8)=>{if(!e0){if(Math.hypot(c8.clientX-y0,c8.clientY-B8)<4)return;e0=!0}let O0=c8.clientX-y0,K8=c8.clientY-B8,C8=null,V9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((i9)=>({rect:i9.getBoundingClientRect(),it:g8.get(i9.getAttribute("data-layer-key"))})).filter((i9)=>i9.it&&i9.it.key!==h0);if(V9.length){let i9=V9[0].rect.left,h9=V9[0].rect.right,t=V9.length;for(let e9=0;e9<V9.length;e9++)if(c8.clientY<V9[e9].rect.top+V9[e9].rect.height/2){t=e9;break}let M0=V9[t-1]?.it||null,_0=V9[t]?.it||null,f0=Math.round((c8.clientX-i9-o0)/N0),Y8=M0?M0.depth+(DL0.has(M0.tag)?0:1):0,m8=_0?_0.depth:0,e8=Math.max(m8,Math.min(f0,Y8)),y8=null,W9="before",k9=0;if(!M0){if(_0)y8=_0,W9="before",k9=_0.depth}else if(e8>M0.depth)y8=M0,W9="inside-start",k9=M0.depth+1;else if(e8===M0.depth)y8=M0,W9="after",k9=M0.depth;else{for(let e9=t-1;e9>=0;e9--)if(V9[e9].it.depth===e8){y8=V9[e9].it;break}if(!y8)y8=M0;W9="after",k9=e8}if(y8&&y8.key!==h0&&!D8.has(y8.key)){let e9=M0?V9[t-1].rect.bottom:V9[0].rect.top,J7=i9+o0+k9*N0;C8={refId:y8.id,position:W9,node:y8.node,y:e9,left:J7,w:Math.max(24,h9-J7)}}}let x9={key:h0,node:d0,dx:O0,dy:K8,target:C8};S8.current=x9,T8(x9)},F9=()=>{window.removeEventListener("pointermove",a7),window.removeEventListener("pointerup",I8),window.removeEventListener("keydown",Q9,!0)},v7=()=>{let c8=(O0)=>{O0.preventDefault(),O0.stopImmediatePropagation(),document.removeEventListener("click",c8,!0)};document.addEventListener("click",c8,!0),setTimeout(()=>document.removeEventListener("click",c8,!0),300)},I8=()=>{F9();let c8=S8.current;if(S8.current=null,T8(null),e0&&c8?.target)v7(),W8(c8.node,c8.target.node,c8.target.position)},Q9=(c8)=>{if(c8.key!=="Escape")return;if(c8.preventDefault(),c8.stopImmediatePropagation(),F9(),S8.current=null,T8(null),e0)v7()};window.addEventListener("pointermove",a7),window.addEventListener("pointerup",I8),window.addEventListener("keydown",Q9,!0)},$8=(l0)=>s0((d0)=>{let h0=new Set(d0);if(h0.has(l0))h0.delete(l0);else h0.add(l0);return h0}),w9=(l0)=>{let d0=`${l0.id}:${l0.index}`,h0=a8(l0),y0=!h0;if(E8((B8)=>new Map(B8).set(d0,y0)),M?.({id:l0.id,artboardId:Y?.artboardId??null,index:l0.index,prop:"display",value:y0?"none":null}),!K||!l0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(y0?{canvas:K,id:l0.id,property:"display",value:"none"}:{canvas:K,id:l0.id,property:"display",reset:!0})}).catch(()=>{}),A?.({op:"css",canvas:K,id:l0.id,key:"display",before:h0?"none":null,after:y0?"none":null})},L8=Array.isArray(X)?X[0]:X,V0=f?{asset:f.asset,kind:"annotation-image"}:(()=>{let l0=EL0(L8);return l0?{asset:l0,kind:"artboard-img"}:null})(),J8=V0?.kind==="annotation-image",r0=(l0)=>{if(!(l0.metaKey||l0.ctrlKey)||l0.altKey)return;let d0=l0.key.toLowerCase();if(d0==="z")l0.preventDefault(),e?.(l0.shiftKey?"redo":"undo");else if(d0==="y")l0.preventDefault(),e?.("redo")},b0=J8?"photo":Z0==="photo"&&!V0?"css":Z0,X8=(l0,d0,h0)=>D("button",{type:"button",className:"st-rp-tab"+(b0===l0?" is-active":""),onClick:()=>k0(l0),children:[z(T9,{name:h0,size:14}),d0]}),q8=L8?.bounds||null;return D("aside",{className:"st-rpanel"+(a?" is-resizing":""),style:d?{width:d,flexBasis:d}:void 0,"aria-label":"Inspector","data-tour":"inspector","data-testid":J,children:[D("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:c?{display:"none"}:void 0,children:[J8?X8("photo","Photo","image"):D(Q0,{children:[X8("inspect","Inspect","sliders"),!K0&&X8("layers","Layers","layers"),X8("css","CSS","code"),V0?X8("photo","Photo","image"):null]}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:Q,children:z(T9,{name:"x",size:14})})]}),L8?.id&&!(Array.isArray(X)&&X.length>1)&&j?D("div",{className:`st-scope st-scope--${j.scope}`,title:j.scope==="shared"?`Editing this element's style changes ${j.affects} place${j.affects===1?"":"s"}${j.componentName?` (component ${j.componentName})`:""}. Move/resize a whole instance to keep it local.`:"This edit affects only this element.",children:[z("span",{className:"st-scope-dot","aria-hidden":"true"}),j.scope==="shared"?`Shared${j.componentName?` · ${j.componentName}`:""} · edits ${j.affects} place${j.affects===1?"":"s"}`:"Local · this element only",j.scope==="shared"&&H?z("button",{type:"button",className:"st-scope-detach",title:"Clone this component for this instance only — edits stop affecting the other places",onClick:()=>H(L8.id,L8.index),children:"Detach"}):null]}):null,z("div",{className:"st-rp-body",children:b0==="photo"&&V0?z("div",{onKeyDown:r0,children:z(Gm,{asset:V0.asset,ColorPicker:k90,StIcon:T9,onEdit:(l0)=>p?.(V0.asset,l0),onRemoveBackground:v,onRecordEdit:(l0,d0)=>r?.(V0.asset,l0,d0)},`${V0.asset}:${h??0}`)}):!L8&&!(b0==="layers"&&Y?.nodes?.length)?z("div",{className:"st-rp-empty",children:D("p",{children:["Press ",z(CJ,{children:"V"}),", then click an element to select it — or ",z(CJ,{children:"⌘"}),"-click straight from Browse."]})}):L8&&b0==="inspect"?D(Q0,{children:[z("div",{className:"st-rp-hd",children:L8.selector||L8.tag||"element"}),D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Pos"}),D("div",{className:"st-insp-fields",children:[D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"X"}),z("input",{value:q8?Math.round(q8.x):"—",readOnly:!0,"aria-label":"x position"})]}),D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"Y"}),z("input",{value:q8?Math.round(q8.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Size"}),D("div",{className:"st-insp-fields",children:[D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"W"}),z("input",{value:q8?Math.round(q8.w):"—",readOnly:!0,"aria-label":"width"})]}),D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"H"}),z("input",{value:q8?Math.round(q8.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Tag"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:L8.tag||"—"})})]}),L8.classes?D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Class"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:L8.classes})})]}):null,z(ML0,{el:L8})]}):b0==="layers"?D(Q0,{children:[D("div",{className:"st-rp-hd",children:["Layers",Y?.nodes?.length?"":" · ancestry"]}),Y?.nodes?.length?D(Q0,{children:[W8?z("div",{className:"st-rp-hint","aria-hidden":"true",children:"Drag or ↑/↓ select · Alt+↑/↓ move · Alt+Shift+↑/↓ move across"}):null,z("div",{role:"tree","aria-label":"Artboard layers",tabIndex:0,ref:O9,onKeyDown:x8,children:Y.nodes.map((l0,d0)=>z(R90,{node:l0,depth:0,selectedId:L8?.id,selectedIndex:L8?.index,collapsed:a0,hiddenOverride:t0,onToggle:$8,onSelect:(h0)=>{U?.(h0),O9.current?.focus()},onHover:(h0)=>V?.(h0),onToggleVisibility:w9,onReorder:W8,onRowPointerDown:v0,dragState:F8,componentMap:W,lockedKeys:G,onToggleLock:Z,onRename:C0},`${l0.id}:${l0.index}`))}),F8?.target?z("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:F8.target.left,top:F8.target.y-1,width:F8.target.w}}):null,z("div",{className:"sr-only",role:"status","aria-live":"polite",children:I0})]}):L8&&Array.isArray(L8.dom_path)&&L8.dom_path.length?L8.dom_path.map((l0,d0)=>D("div",{className:"st-layer"+(d0===L8.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+d0*12},children:[z(T9,{name:"square",size:13}),l0]},d0)):z("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!L8.id&&C90(L8)?z(_L0,{el:L8,cfg:F,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:I,onSetArtboardKind:k,onSetArtboardPrint:R,onDuplicateArtboard:$}):z(qL0,{el:L8,cfg:F,onOptimistic:M,onRecordEdit:A,onReplaceMedia:E,onUndoRedo:C,mode:s,onSetMode:z0})})]})}function IL0(){let[J,X]=u.useState([]),[Q,Y]=u.useState(!1),W=u.useRef("push"),G=u.useRef(null),[Z,H]=u.useState("Design"),[K,U]=u.useState([]),[V,B]=u.useState(null),[N,F]=u.useState(null),M=u.useCallback((b)=>{W.current="push",F(b)},[]),[A,E]=u.useState(null),w=u.useRef(null);u.useEffect(()=>{w.current=A},[A]);let[O,I]=u.useState(null);u.useEffect(()=>{let b=Array.isArray(A)?A.length===1?A[0]:null:A,S=b&&typeof b.id==="string"?b.id:null;if(!S||!V){I(null);return}let i=new AbortController,X0=new URLSearchParams({canvas:V,id:S});return fetch(`/_api/edit-scope?${X0}`,{signal:i.signal}).then((H0)=>H0.ok?H0.json():null).then((H0)=>{if(H0?.ok)I(H0)}).catch(()=>{}),()=>i.abort()},[A,V]);let k=u.useRef(0),R=u.useRef([]),$=u.useCallback((b)=>{if(!b?.id||!b.file)return;for(let S of R.current)clearTimeout(S);R.current=[50,450,1200,2500,5000].map((S)=>setTimeout(()=>{let i=w.current,X0=Array.isArray(i)?i[0]:i;if(!X0||X0.id!==b.id||X0.file!==b.file)return;let H0=i8.current.get(b.file);if(!H0?.contentWindow)return;try{H0.contentWindow.postMessage({dgn:"select-by-id",id:b.id,artboardId:b.artboardId??null,index:b.index??0},"*")}catch{}},S))},[]),C=u.useRef([]),j=u.useCallback((b,S)=>{if(!b||!S)return;for(let i of C.current)clearTimeout(i);C.current=[50,450,1200,2500,5000].map((i)=>setTimeout(()=>{let X0=w.current,H0=Array.isArray(X0)?X0[0]:X0;if(!H0||H0.artboardId!==b||H0.file!==S)return;let F0=i8.current.get(S);if(!F0?.contentWindow)return;try{F0.contentWindow.postMessage({dgn:"select-by-id",artboardId:b},"*")}catch{}},i))},[]),x=u.useRef(null),m=u.useRef(null),d=u.useRef(null);d.current=(b,S,i)=>{let X0=x.current;if(!X0||!X0.movedId)return;if(X0.staleSig!=null&&S===X0.staleSig)return;if(!function A0(l){return(l||[]).some((D0)=>D0.id===X0.movedId||A0(D0.children))}(b))return;x.current=null;let F0=V?i8.current.get(V)?.contentWindow:null;if(F0)try{F0.postMessage({dgn:"select-by-id",id:X0.movedId,artboardId:i,index:0},"*")}catch{}};let a=u.useRef(null),f=u.useRef(null),h=u.useRef(null),p=u.useRef(!1),v=u.useRef(null),[r,e]=u.useState(null),[c,K0]=u.useState(null),s=u.useRef({canvas:null,at:0});u.useEffect(()=>{if(!V||!r)return;let b=Date.now(),S=s.current;if(S.canvas===V&&b-S.at<1500)return;s.current={canvas:V,at:b},fetch(`/_api/component-map?canvas=${encodeURIComponent(V)}`).then((i)=>i.json()).then((i)=>{if(i?.ok&&i.map&&typeof i.map==="object")K0(i.map);else K0(null)}).catch(()=>K0(null))},[V,r]);let[z0,o]=u.useState(!1),[q0,Z0]=u.useState(null),[k0,a0]=u.useState(null),s0=u.useRef(null);u.useEffect(()=>{let b=k0?.files?.progress;if(!b)return;let S=s0.current;if(s0.current=b.phase,S===null||S===b.phase)return;if(b.phase==="converged"&&(S==="seeding"||S==="paused"))WL("Project synced",`${b.delivered} files are up to date.`);else if(b.phase==="blocked"){let i=(b.blocked??[]).reduce((X0,H0)=>X0+H0.count,0);WL("Sync needs a decision",`${i} file${i===1?"":"s"} could not be sent. Open the Sync panel for the reason.`)}},[k0?.files?.progress]),u.useEffect(()=>{if(typeof document>"u")return;let b=k0?.files?.progress,S=document.title.replace(/\s+—\s+syncing\s+\d+\/\d+$/,"");if(b&&(b.phase==="seeding"||b.phase==="paused")&&b.tracked>0)document.title=`${S} — syncing ${b.delivered}/${b.tracked}`;else document.title=S;return},[k0?.files?.progress]);let[t0,E8]=u.useState(null),[a8,F8]=u.useState(null),[T8,I0]=u.useState(null),[w0,C0]=u.useState(null),[W8,H8]=u.useState(!1),[x8,S8]=u.useState(!1),[O9,v0]=u.useState(null),[$8,w9]=u.useState(""),[L8,V0]=u.useState(null),[J8,r0]=u.useState(null),b0=u.useRef(null),[X8,q8]=u.useState(null),[l0,d0]=u.useState(0),[h0,y0]=u.useState(null),B8=e80("maude-sb-w",{min:200,max:420,def:252}),D8=e80("maude-rp-w",{min:260,max:480,def:304}),[N0,o0]=u.useState(null),h8=u.useRef(null);u.useEffect(()=>{if(!N0)return;let b=(i)=>{let X0=h8.current?.getBoundingClientRect();if(!X0)return;if(N0==="sb")B8.setW(i.clientX-X0.left);else D8.setW(X0.right-i.clientX)},S=()=>o0(null);return window.addEventListener("pointermove",b),window.addEventListener("pointerup",S),()=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",S)}},[N0,B8.setW,D8.setW]);let g8=u.useCallback((b)=>{clearTimeout(b0.current),b0.current=setTimeout(()=>{r0((S)=>S===b?null:S)},2500)},[]),[e0,a7]=u.useState({designRel:".design",cloud:void 0});u.useEffect(()=>{if(!J8)return;let b=J8,S=setTimeout(async()=>{let i="compile";try{if(!(await fetch(`${e0?.canvasOrigin||""}/_health`,{cache:"no-store"})).ok)i="server"}catch{i="server"}q8({path:b,kind:i}),r0((X0)=>X0===b?null:X0)},15000);return()=>clearTimeout(S)},[J8,e0?.canvasOrigin]);let F9=!!e0.cloud,v7=!e0.cloud&&!!t0?.credentialed,I8=F9||v7,Q9=I8?0:T8?.files?.length||0,c8=u.useRef(I8);c8.current=I8;let O0=!!e0.readOnly,K8=u.useCallback(()=>{fetch("/_config").then((b)=>b.json()).then((b)=>{let S=(b.designRoot||".design").replace(/^\/+|\/+$/g,"");a7((i)=>({...i,designRel:S,tokensCssRel:b.tokensCssRel,designSystems:b.designSystems,canvasOrigin:b.canvasOrigin,readOnly:!!b.readOnly,canvasToken:b.canvasToken,version:b.version,cloud:b.cloud??null,exportLane:b.exportLane}))}).catch(()=>{})},[]);u.useEffect(()=>{K8()},[K8]),u.useEffect(()=>{let b=!1;return fetch("/_sync-status").then((S)=>S.json()).then((S)=>{if(b||!S||S.linked===!1)return;a0(S)}).catch(()=>{}),()=>{b=!0}},[]),u.useEffect(()=>{if(I8){I0(null);return}let b=!1;return fetch("/_api/git/status").then((S)=>S.json()).then((S)=>{if(!b&&S)I0(S)}).catch(()=>{}),()=>{b=!0}},[I8]);let[C8,V9]=u.useState({}),[x9,i9]=u.useState(null),[h9,t]=u.useState(!1),[M0,_0]=u.useState("open"),[f0,Y8]=u.useState(qF0),[m8,e8]=u.useState(()=>{return Xk(l80,"advanced")==="designer"?"designer":"advanced"});u.useEffect(()=>{try{localStorage.setItem(l80,JSON.stringify(m8))}catch{}},[m8]);let[y8,W9]=u.useState(null),[k9,e9]=u.useState(()=>IH(d80,!0)),[J7,DQ]=u.useState(()=>IH(u80,!1)),[rX,BJ]=u.useState(()=>Xk(p80,{})),[iJ,oJ]=u.useState(!1),[e7,W4]=u.useState(!1);u.useEffect(()=>{if(!G9())return;let b=Yh(()=>W4(!0));return()=>{b.then((S)=>S()).catch(()=>{})}},[]);let[R7,FX]=u.useState(!1),[j9,qY]=u.useState(!1),[p7,j5]=u.useState(!1),[HG,f7]=u.useState(!1),[BY,LX]=u.useState(!1),{report:V7}=yw(G9()),[nJ,l9]=u.useState(!1),[q7,z6]=u.useState(!1),[$J,v5]=u.useState(null),[MQ,P6]=u.useState(null),[G4,OQ]=u.useState(!1),[zG,SJ]=u.useState(!1),[bJ,rJ]=u.useState(!1),[f5,Z4]=u.useState(!1),[NJ,H4]=u.useState(()=>Xk(n80,sK)),[n,W0]=u.useState(()=>{try{let b=localStorage.getItem(r80);if(b==="separate"||b==="in-inspector")return b}catch{}return"separate"}),[L0,j0]=u.useState(!1),[E0,z8]=u.useState([]),[O8,Z9]=u.useState(0),[L9,I6]=u.useState(!1),[AQ,s6]=u.useState(!1),[FJ,x5]=u.useState(!1),[TH,KG]=u.useState(1),[yJ,C7]=u.useState(216),[R9,DX]=u.useState(null),[K6,t8]=u.useState([]),[J6,x6]=u.useState([]),[MX,_Q]=u.useState([]),[aX,kH]=u.useState(0),OX=u.useRef(0);u.useEffect(()=>{OX.current=O8},[O8]);let[X6,RH]=u.useState(null),AX=u.useRef(null);u.useEffect(()=>{AX.current=X6},[X6]);let T6=u.useMemo(()=>mw(E0,{artboardId:[X6,R9],total:aX}),[E0,X6,R9,aX]),sX=u.useRef(null);u.useEffect(()=>{sX.current=T6},[T6]);let NY=u.useMemo(()=>TK(E0,T6)?.fps||30,[E0,T6]),[CH,FY]=u.useState(null),[LY,X1]=u.useState(0),LJ=u.useCallback((b,S)=>{if(/concurrent edit|changed since it was read/i.test(S||""))f8("Timeline changed — reloaded, try again."),X1((i)=>i+1);else f8(`${b}: ${S||"failed"}`)},[]),[_X,UG]=u.useState(!1),[Q1,$H]=u.useState(!1),[Y1,VG]=u.useState(!1),qG=u.useRef(_X);u.useEffect(()=>{if(qG.current=_X,_X){VG(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[_X]);let SH=u.useCallback(()=>{if(!qG.current||document.hidden)VG(!0),WL("Claude finished","Your assistant turn is ready in Maude.")},[]),bH=u.useRef(0),DY=u.useCallback(()=>{if(!qG.current||document.hidden){VG(!0);let b=Date.now();if(b-bH.current<zF0)return;bH.current=b,WL("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[h5,tX]=u.useState("inspect"),[BG,MY]=u.useState(null),wQ=u.useRef({undo:[],redo:[]}),[NG,FG]=u.useState(0),[U6,LG]=u.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),OY=u.useRef(U6);u.useEffect(()=>{OY.current=U6;try{localStorage.setItem("maude-auto-open-inspector",U6?"1":"0")}catch{}},[U6]);let yH=u.useRef(!1);u.useEffect(()=>{yH.current=bJ||h9||W8||x8||_X},[bJ,h9,W8,x8,_X]);let DG=u.useRef({open:{},side:sK});DG.current={open:{tree:k9,layers:f5,inspector:bJ,comments:h9,changes:W8,sync:x8,assistant:_X},side:NJ};let z4=u.useCallback((b,S)=>{if(b==="tree")e9(S);else if(b==="layers")Z4(S);else if(b==="inspector")rJ(S);else if(b==="comments")t(S);else if(b==="changes")H8(S);else if(b==="sync")S8(S);else if(b==="assistant")UG(S)},[]),MG=u.useCallback((b)=>DG.current.side?.[b]||sK[b],[]),k6=u.useCallback((b)=>{let S=MG(b);z4(b,!0);for(let i of Gk)if(i.id!==b&&MG(i.id)===S)z4(i.id,!1)},[z4,MG]),wX=u.useCallback((b)=>{if(DG.current.open?.[b])z4(b,!1);else k6(b)},[k6,z4]),eX=k6,h6=wX,OG=u.useCallback((b)=>{if(!OY.current)return;if(O0)return;if(!b||!b.id)return;if(yH.current)return;eX("inspector"),tX("css")},[eX,O0]),AY=u.useCallback(()=>j0((b)=>!b),[]),EQ=Tm(Zk),K4=Um({enabled:e0.cloud===null||e0.exportLane==="remote"}),[jH,W1]=u.useState(!1),[vH,J5]=u.useState(!1);u.useEffect(()=>{if(!G9())return;let b=!0;return Hh().then((S)=>{if(!b)return;if(W1(!!S),!S&&!IH(m80,!1))J5(!0)}).catch(()=>{}),()=>{b=!1}},[]);let DJ=u.useCallback(()=>{J5(!1);try{localStorage.setItem(m80,"1")}catch{}},[]),[AG,fH]=u.useState(null);u.useEffect(()=>{if(!G9())return;let b;return qh((S)=>fH(S&&typeof S==="object"?S:{})).then((S)=>{b=S}).catch(()=>{}),()=>{try{b?.()}catch{}}},[]);let[U4,PQ]=u.useState(null),[IQ,_G]=u.useState(()=>!IH(g80,!1)),EX=u.useCallback((b)=>{PQ(Array.isArray(b)&&b.length?b:null)},[]),wG={setup:(b)=>{if(!b)return;if((b.canvas||b.requireSelection)&&K.length===0)k6("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [role="treeitem"]')?.click()}catch{}},80);if(b.inspector||b.tab||b.requireSelection)eX("inspector");if(b.tab)tX(b.tab);if(b.changes)eX("changes")}},V4=u.useCallback(()=>{_G(!1);try{localStorage.setItem(g80,"1")}catch{}},[]),[X5,_Y]=u.useState(()=>IH(o80,!0)),[xH,EG]=u.useState(!1),[Q5,wY]=u.useState(()=>IH(c80,!1)),[g6,U0]=u.useState(()=>IH(i80,!1)),[jJ,q4]=u.useState(!1),[PG,aJ]=u.useState(!1),[l7,sJ]=u.useState(0),[g5,IG]=u.useState(null),[TG,EY]=u.useState(!1),m5=u.useRef(null),TQ=u.useRef(null),i8=u.useRef(new Map);u.useEffect(()=>{if(!e0?.canvasToken)return;let b=!1,S=null,i=0,X0=(A0)=>{clearTimeout(S);let l=fb(A0);i=Date.now()+l,S=setTimeout(H0,l)};async function H0(){let A0=null;try{let D0=await fetch("/_config",{cache:"no-store",credentials:"same-origin"});if(D0.ok)A0=(await D0.json())?.canvasToken}catch{}if(b)return;if(typeof A0!=="string"||!A0){clearTimeout(S),i=Date.now()+30000,S=setTimeout(H0,30000);return}vb(A0);let l=null;try{l=new URL(e0.canvasOrigin,location.href).origin}catch{}if(l)for(let D0 of i8.current.values())try{D0.contentWindow?.postMessage({dgn:"canvas-cap",t:A0},l)}catch{}X0(A0)}X0(e0.canvasToken);let F0=()=>{if(document.visibilityState==="visible"&&Date.now()>=i)H0()};return document.addEventListener("visibilitychange",F0),()=>{b=!0,clearTimeout(S),document.removeEventListener("visibilitychange",F0)}},[e0?.canvasToken,e0?.canvasOrigin]);let T0=u.useCallback((b)=>{let S=V?i8.current.get(V):null;if(!S||!S.contentWindow)return;try{S.contentWindow.postMessage(b,"*")}catch{}},[V]),tJ=u.useRef(0),kQ=u.useCallback(({format:b,artboardIds:S=null,scale:i=1,onProgress:X0,timeoutMs:H0=120000})=>new Promise((F0,A0)=>{let l=V?i8.current.get(V):null;if(!l||!l.contentWindow){A0(Error("no active canvas to capture"));return}let D0=l.contentWindow;tJ.current+=1;let P0=`cap-${Date.now().toString(36)}-${tJ.current}`,i0=!1,_8=(w7,d9)=>{if(i0)return;i0=!0,window.removeEventListener("message",A8),clearTimeout(q6),w7(d9)},A8=(w7)=>{if(w7.source!==D0)return;let d9=w7.data;if(!d9||d9.id!==P0)return;if(d9.dgn==="export-capture-progress")X0?.(d9.current,d9.total);else if(d9.dgn==="export-capture-done")_8(F0,Array.isArray(d9.items)?d9.items:[]);else if(d9.dgn==="export-capture-error")_8(A0,Error(d9.message||"capture failed"))},q6=setTimeout(()=>_8(A0,Error("capture timed out — the canvas did not answer")),H0);window.addEventListener("message",A8);try{D0.postMessage({dgn:"export-capture",id:P0,format:b,artboardIds:S,scale:i},"*")}catch(w7){_8(A0,w7)}}),[V]),Q8=u.useCallback((b,S)=>T0({dgn:"photo-preview",asset:b,edit:S}),[T0]),B4=u.useCallback((b,S,i)=>{wQ.current.undo.push({asset:b,before:S,after:i}),wQ.current.redo.length=0},[]),G8=u.useCallback((b)=>{let S=b?wQ.current.redo:wQ.current.undo;if(!S.length)return!1;let i=S.pop();(b?wQ.current.undo:wQ.current.redo).push(i);let X0=(b?i.after:i.before)||{};return Q8(i.asset,X0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(i.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(X0)}).catch(()=>{}),FG((H0)=>H0+1),!0},[Q8]),kG=u.useCallback(async(b)=>{T0({dgn:"photo-busy",asset:b,busy:!0});try{let S=await fetch(`/${b.replace(/^\/+/,"")}`);if(!S.ok)return null;let i=await S.blob(),{removeBackground:X0}=await Promise.resolve().then(() => (h80(),x80)),H0=await X0(i),F0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":H0.type||"image/png"},body:H0}),A0=await F0.json().catch(()=>({}));if(F0.ok&&A0.path)return{maskAsset:A0.path};return null}catch(S){return console.error("[photo] background removal failed",S),null}finally{T0({dgn:"photo-busy",asset:b,busy:!1})}},[T0]);u.useEffect(()=>{let b=(X0)=>Array.from(X0.dataTransfer?.types??[]).includes("Files"),S=(X0)=>{if(b(X0))X0.preventDefault()},i=(X0)=>{if(b(X0))X0.preventDefault()};return document.addEventListener("dragover",S),document.addEventListener("drop",i),()=>{document.removeEventListener("dragover",S),document.removeEventListener("drop",i)}},[]);let Q6=u.useRef({});Q6.current={open:L0,comps:E0,frame:O8,total:aX,playing:L9,compId:T6,muted:FJ,loop:AQ,sequences:K6,post:T0,canvas:V};let u5=u.useRef({undo:[],redo:[]}),Y6=u.useCallback((b,S,i)=>{if(typeof S!=="number")return;if(u5.current.undo.push({canvas:b,seq:S,label:i}),u5.current.redo=[],u5.current.undo.length>50)u5.current.undo.shift()},[]),RG=u.useCallback((b)=>{let S=u5.current,i=b==="undo"?S.undo:S.redo,X0=b==="undo"?S.redo:S.undo,H0=Q6.current.canvas,F0=-1;for(let l=i.length-1;l>=0;l--)if(i[l].canvas===H0){F0=l;break}if(F0<0){f8(b==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let A0=i[F0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:A0.canvas,seq:A0.seq,dir:b})}).then((l)=>l.json().catch(()=>({}))).then((l)=>{if(i.splice(F0,1),l?.ok)X0.push(A0),f8(`${b==="undo"?"Undid":"Redid"}: ${A0.label}`,!0);else f8(`${b==="undo"?"Undo":"Redo"} skipped: ${l?.error||"failed"}`)}).catch(()=>f8(`${b==="undo"?"Undo":"Redo"} failed: network error`))},[]),R6=u.useCallback((b,S)=>{let i=b?.ok&&Array.isArray(b.clips)?b.clips.filter((X0)=>X0.kind==="sequence"):[];if(S==null)return null;if(typeof S==="object")return(S.stableId?i.find((X0)=>X0.stableId===S.stableId):null)||(Number.isInteger(S.index)?i[S.index]:null)||null;if(typeof S==="string")return i.find((X0)=>X0.stableId===S)||null;return i[S]||null},[]),RQ=u.useCallback((b)=>{let S=Q6.current.canvas;if(!S||S===r8)return;let i=AX.current||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(S)}${i?`&artboardId=${encodeURIComponent(i)}`:""}`;fetch(X0).then((H0)=>H0.json().catch(()=>({}))).then((H0)=>{let F0=R6(H0,b);if(!F0?.stableId)return null;return fetch("/_api/remove-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:S,artboardId:i,stableId:F0.stableId,contentHash:F0.contentHash})})}).then((H0)=>H0?H0.json():null).then((H0)=>{if(H0&&!H0.ok)console.warn("[remove-clip]",H0.error||"failed"),LJ("Remove refused",H0.error);else if(H0?.ok){if(f8("Clip removed.",!0),H0.seq!=null)Y6(S,H0.seq,"remove clip");FY(null)}}).catch(()=>f8("Remove failed: network error"))},[R6,Y6]),CQ=u.useCallback((b,S,i)=>{let X0=Q6.current.canvas;if(!X0||X0===r8)return;let H0=AX.current||void 0,F0=`/_api/comp-clips?canvas=${encodeURIComponent(X0)}${H0?`&artboardId=${encodeURIComponent(H0)}`:""}`;fetch(F0).then((A0)=>A0.json().catch(()=>({}))).then((A0)=>{let l=A0?.ok&&Array.isArray(A0.clips)?A0.clips:[],D0=b?.transition?l.find((P0)=>P0.kind==="transition"&&P0.stableId===b.stableId)||null:R6(A0,b);if(!D0?.stableId)return null;return fetch("/_api/clip-edit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:X0,artboardId:H0,stableId:D0.stableId,contentHash:D0.contentHash,verb:S,...i})})}).then((A0)=>A0?A0.json():null).then((A0)=>{if(A0&&!A0.ok)console.warn("[clip-edit]",S,A0.error||"failed"),LJ(`${S} refused`,A0.error);else if(A0?.ok){let l={speed:"set speed","trim-in":"trim in-point",audio:"clip audio","detach-audio":"detach audio",framing:"crop clip",grade:"grade clip",transition:"edit transition",split:"split clip","insert-transition":"add transition","remove-transition":"remove transition","set-text":"edit text","to-overlay":"move to overlay layer","to-storyline":"move to storyline","layer-order":"reorder layers"};if(f8(`Applied: ${l[S]||S}.`,!0),A0.seq!=null)Y6(X0,A0.seq,l[S]||S)}}).catch(()=>f8(`${S} failed: network error`))},[R6,Y6,LJ]),[$Q,PY]=u.useState(null),Y5=u.useCallback((b,S="")=>new Promise((i)=>{PY({title:b,value:S,resolve:i})}),[]),p5=u.useCallback((b)=>{PY((S)=>{return S?.resolve?.(b),null})},[]),IY=u.useCallback((b,S)=>{let i=Q6.current.canvas;if(!i||i===r8||!S||!String(S).trim())return;$7({type:"comments-add",payload:{file:i,text:String(S).trim(),selector:"",dom_path:[],tag:"",classes:"",bounds:null,html_excerpt:"",timeline:b}}),f8("Comment added.",!0)},[]);Q6.current.selected=CH,Q6.current.setSelected=FY,Q6.current.removeClip=RQ,Q6.current.clipVerb=CQ,Q6.current.addComment=IY,Q6.current.askText=Y5,u.useEffect(()=>{let b=(S)=>{let i=Q6.current;if(!i.open||!i.comps?.length)return;let X0=S.target,H0=X0?.tagName;if(H0==="INPUT"&&X0?.type!=="range")return;if(H0==="TEXTAREA"||H0==="SELECT"||X0?.isContentEditable)return;let F0=TK(i.comps,i.compId)?.fps||30,A0=Math.max(1,i.total),l=(P0)=>{let i0=Math.max(0,Math.min(A0-1,Math.round(P0)));Z9(i0),I6(!1),i.post({dgn:"timeline-seek",frame:i0,id:i.compId})},D0=()=>{let P0=new Set([0,A0-1]);for(let i0 of i.sequences||[]){P0.add(i0.from);for(let _8 of i0.keyframes||[])P0.add(_8.from),P0.add(_8.to)}return[...P0].filter((i0)=>i0>=0&&i0<A0).sort((i0,_8)=>i0-_8)};if((S.metaKey||S.ctrlKey)&&(S.key==="z"||S.key==="Z")){S.preventDefault(),RG(S.shiftKey?"redo":"undo");return}if(S.key==="Escape"){if(i.selected!=null)S.preventDefault(),i.setSelected?.(null);return}if((S.key==="Delete"||S.key==="Backspace")&&i.selected!=null){S.preventDefault(),i.removeClip?.({stableId:i.selected});return}if((S.metaKey||S.ctrlKey)&&(S.key==="b"||S.key==="B")){S.preventDefault();let P0=i.selected!=null?{stableId:i.selected}:null;if(!P0){let i0=i.sequences||[],_8=i0.find((A8)=>A8.series&&i.frame>=A8.from&&i.frame<A8.from+A8.duration)||i0.find((A8)=>i.frame>=A8.from&&i.frame<A8.from+A8.duration);if(_8?.stableId)P0={stableId:_8.stableId}}if(P0)i.clipVerb?.(P0,"split",{atFrame:i.frame});else f8("Nothing under the playhead to split.");return}if(S.key===" "||S.code==="Space")if(S.preventDefault(),i.playing)I6(!1),i.post({dgn:"timeline-pause",id:i.compId});else I6(!0),i.post({dgn:"timeline-mute",muted:i.muted,id:i.compId}),i.post({dgn:"timeline-loop",loop:i.loop,id:i.compId}),i.post({dgn:"timeline-play",id:i.compId});else if(S.key==="ArrowRight")S.preventDefault(),l(i.frame+(S.shiftKey?F0:1));else if(S.key==="ArrowLeft")S.preventDefault(),l(i.frame-(S.shiftKey?F0:1));else if(S.key==="Home")S.preventDefault(),l(0);else if(S.key==="End")S.preventDefault(),l(A0-1);else if(S.key==="."){S.preventDefault();let P0=D0().find((i0)=>i0>i.frame);if(P0!=null)l(P0)}else if(S.key===","){S.preventDefault();let P0=D0().reverse().find((i0)=>i0<i.frame);if(P0!=null)l(P0)}};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[]),u.useEffect(()=>{z8([]),Z9(0),I6(!1),FY(null),RH(null);let b=setTimeout(()=>T0({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(b)},[V,T0]);let[l5,TY]=u.useState(""),[kY,N4]=u.useState([]),[CG,RY]=u.useState([]);u.useEffect(()=>{if(!L0||E0.length===0||!V||V===r8){TY(""),N4([]);return}let b=!0;return fetch(`/_api/canvas-source?file=${encodeURIComponent(V)}`).then((S)=>S.ok?S.json():null).then((S)=>{if(b&&S?.ok&&typeof S.source==="string")TY(S.source)}).catch(()=>{}),()=>{b=!1}},[L0,E0,V,LY]),u.useEffect(()=>{if(!L0||!V||V===r8||!l5){N4([]),RY([]);return}let b=!0,S=X6||void 0,i=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${S?`&artboardId=${encodeURIComponent(S)}`:""}`;return fetch(i).then((X0)=>X0.ok?X0.json():null).then((X0)=>{if(!b)return;let H0=X0?.ok&&Array.isArray(X0.clips)?X0.clips:[];N4(H0.filter((F0)=>F0.kind==="sequence")),RY(H0.filter((F0)=>F0.kind==="transition"))}).catch(()=>{}),()=>{b=!1}},[L0,V,l5,X6,LY]),u.useEffect(()=>{if(!l5){t8([]),x6([]),_Q([]),kH(0);return}let b=R9??A?.artboardId??null,i=(b&&E0.find((F0)=>F0.artboardId===b||F0.id===b)||E0[0])?.durationInFrames||0,X0=eg(l5,i,b);RH(X0.artboardId??b??null);let H0=X0.sequences.map((F0,A0)=>{let l=kY[A0];if(!l)return F0;return{...F0,stableId:l.stableId,contentHash:l.contentHash,mediaProps:l.mediaProps??null,placeholder:l.placeholder??null,mediaTag:l.mediaTag??F0.mediaTag,mediaSrc:l.mediaSrc??F0.mediaSrc,replaceable:!!(l.mediaCdId||l.mediaArrayRef),layers:Array.isArray(l.layers)?l.layers:[],hidden:!!l.hidden}});t8(H0),x6(X0.audio||[]),_Q(X0.transitions||[]),kH(X0.total)},[l5,kY,A,E0,R9]);let CY=u.useCallback(()=>{_Y((b)=>{let S=!b,i=V?i8.current.get(V):null;if(i&&i.contentWindow)try{i.contentWindow.postMessage({dgn:"view-annotations",visible:S},"*")}catch{}return S})},[V]),MJ=u.useCallback((b)=>{for(let S of i8.current.values())try{S.contentWindow.postMessage({dgn:"view-chrome",...b},"*")}catch{}},[]),$Y=u.useCallback(()=>{wY((b)=>{let S=!b;return MJ({minimap:S}),S})},[MJ]),SY=u.useCallback(()=>{U0((b)=>{let S=!b;return MJ({zoom:S}),S})},[MJ]),$G=u.useCallback(()=>{q4((b)=>{let S=!b;return MJ({present:S}),S})},[MJ]),F4=u.useCallback(()=>{q4(!1),MJ({present:!1})},[MJ]),SG=u.useCallback(()=>{if(!V||V===r8)return;aJ((b)=>{let S=!b;return T0({dgn:"view-chrome",print:S}),fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:V,patch:{overlays:{print:S}}})}).catch(()=>{}),S})},[V,T0]);u.useEffect(()=>{let b=!1;return fetch("/_api/git-user").then((S)=>S.json()).then((S)=>{if(b)return;let i=S&&typeof S.name==="string"?S.name.trim():"";if(i)IG(i)}).catch(()=>{}),()=>{b=!0}},[]),u.useEffect(()=>{if(!V||V===r8){sJ(0),aJ(!1);return}let b=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(V)).then((S)=>S.json()).then((S)=>{if(b)return;let i=Array.isArray(S?.artboards)?S.artboards.length:0;sJ(i),aJ(S?.overlays?.print===!0),D4(new Set(Array.isArray(S?.locked)?S.locked:[]))}).catch(()=>{if(!b)sJ(0),aJ(!1),D4(new Set)}),()=>{b=!0}},[V]),u.useEffect(()=>{if(!V||V===r8||!R9)return;let b=setTimeout(()=>{T0({dgn:"request-layers",artboardId:R9})},250);return()=>clearTimeout(b)},[V,R9,T0]);let[L4,D4]=u.useState(()=>new Set),bG=u.useCallback((b)=>{if(!V||V===r8)return;D4((S)=>{let i=new Set(S);if(i.has(b))i.delete(b);else i.add(b);let X0=[...i];return fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:V,patch:{locked:X0}})}).catch(()=>{}),T0({dgn:"locked-set",locked:X0}),i})},[V,T0]);u.useEffect(()=>{if(!V||V===r8)return;T0({dgn:"locked-set",locked:[...L4]})},[L4,V,T0]),u.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",f0),localStorage.setItem(A90,f0)}catch{}for(let b of i8.current.values())try{b.contentWindow.postMessage({dgn:"theme",theme:f0},"*")}catch{}},[f0]),u.useEffect(()=>{try{localStorage.setItem(d80,k9?"1":"0")}catch{}},[k9]),u.useEffect(()=>{try{localStorage.setItem(u80,J7?"1":"0")}catch{}},[J7]),u.useEffect(()=>{try{localStorage.setItem(p80,JSON.stringify(rX))}catch{}},[rX]),u.useEffect(()=>{try{localStorage.setItem(c80,Q5?"1":"0")}catch{}},[Q5]),u.useEffect(()=>{try{localStorage.setItem(i80,g6?"1":"0")}catch{}},[g6]),u.useEffect(()=>{try{localStorage.setItem(o80,X5?"1":"0")}catch{}},[X5]),u.useEffect(()=>{let b=!1;return fetch("/_api/ui-prefs").then((S)=>S.ok?S.json():Promise.reject(Error(`HTTP ${S.status}`))).then((S)=>{if(b||!S||typeof S!=="object")return;if(S.theme==="light"||S.theme==="dark")Y8(S.theme);if(typeof S.minimap==="boolean")wY(S.minimap);if(typeof S.zoom==="boolean")U0(S.zoom);if(typeof S.annotations==="boolean")_Y(S.annotations);if(typeof S.autoOpenInspector==="boolean")LG(S.autoOpenInspector);if(S.panelSides&&typeof S.panelSides==="object")H4({...sK,...S.panelSides});if(S.layersMode==="separate"||S.layersMode==="in-inspector")W0(S.layersMode)}).catch(()=>{}).finally(()=>{if(!b)EG(!0)}),()=>{b=!0}},[]),u.useEffect(()=>{if(!xH)return;KF0({theme:f0,minimap:Q5,zoom:g6,annotations:X5,autoOpenInspector:U6,panelSides:NJ,layersMode:n})},[xH,f0,Q5,g6,X5,U6,NJ,n]),u.useEffect(()=>{try{localStorage.setItem(n80,JSON.stringify(NJ))}catch{}},[NJ]),u.useEffect(()=>{try{localStorage.setItem(r80,n)}catch{}},[n]);let yG=u.useCallback((b,S)=>{BJ((i)=>{let X0=i[b],H0=X0===void 0?S:X0;return{...i,[b]:!H0}})},[]),M4=u.useCallback(()=>{Y8((b)=>b==="dark"?"light":"dark")},[]),O4=u.useRef(null),y9=u.useCallback(()=>O4.current?.reload()??Promise.resolve(),[]);u.useEffect(()=>{let b=hb({read:async(S)=>{let i=await fetch("/_index-data",{signal:S,cache:"no-store"});if(!i.ok)throw Object.assign(Error(`Project index request failed: ${i.status}`),{status:i.status});let X0=await i.json(),H0=X0.groups.map((F0)=>({...F0,tree:LF0(F0.paths,F0.stripPrefix,F0.dirs)}));return{data:X0,built:H0}},apply:({data:S,built:i})=>{H(S.project||"Design"),X(i),Y(!0),a7((X0)=>({...X0,canvasDesignSystems:S.canvasDesignSystems??{},canvasKinds:S.canvasKinds??{}}))},onError:(S)=>console.error("failed to load tree",S)});return O4.current=b,y9(),()=>{O4.current=null,b.dispose()}},[y9]);let W5=u.useCallback(async(b)=>{try{let S=b?`/_system-data?ds=${encodeURIComponent(b)}`:"/_system-data",i=await fetch(S);if(!i.ok){console.error("failed to load system-data",i.status);return}let X0=await i.json();if(!b&&X0?.defaultDesignSystem&&!X0.ds){V0(X0);let H0=await fetch(`/_system-data?ds=${encodeURIComponent(X0.defaultDesignSystem)}`);if(H0.ok)V0(await H0.json());return}V0(X0)}catch(S){console.error("failed to load system-data",S)}},[]),bY=u.useCallback(async()=>{try{let S=await(await fetch("/_comments-all")).json();V9(S||{})}catch(b){console.error("failed to load comments",b)}},[]);u.useEffect(()=>{bY()},[bY]);let yY=u.useRef(()=>{});u.useEffect(()=>{let b=null,S=!1;function i(){let X0=location.protocol==="https:"?"wss:":"ws:",H0=new WebSocket(X0+"//"+location.host+"/_ws");TQ.current=H0,H0.addEventListener("open",()=>{if(o(!0),S)K8();S=!0,clearInterval(b),b=setInterval(()=>{if(H0.readyState===WebSocket.OPEN)H0.send('{"type":"ping"}')},25000)}),H0.addEventListener("close",()=>{o(!1),clearInterval(b),setTimeout(i,1000)}),H0.addEventListener("error",()=>{}),H0.addEventListener("message",(F0)=>{try{let A0=JSON.parse(F0.data);if(A0.type==="snapshot"&&A0.state)E((l)=>L90(A0.state.selected,l));else if(A0.type==="selected"){if(Date.now()-k.current<2000)return;let l=A0.selected,D0=Array.isArray(l)?l[0]:l,P0=w.current,i0=Array.isArray(P0)?P0[0]:P0;if(E((_8)=>L90(l,_8)),D0?.id&&D0.file&&(!i0||i0.id!==D0.id||i0.file!==D0.file))$(D0)}else if(A0.type==="comments"&&typeof A0.file==="string")V9((l)=>({...l,[A0.file]:A0.comments||[]}));else if(A0.type==="ai-activity"&&typeof A0.file==="string"){if(EY(!0),m5.current)clearTimeout(m5.current);m5.current=setTimeout(()=>EY(!1),8000);for(let l of i8.current.values())try{l.contentWindow.postMessage({dgn:"ai-activity",file:A0.file,entry:A0.entry},"*")}catch{}}else if(A0.type==="export:job"&&A0.payload)K4.upsert(A0.payload);else if(A0.type==="sync:status"&&A0.payload)a0(A0.payload);else if(A0.type==="canvas-list-update")y9(),yY.current(A0.payload);else if(A0.type==="config-updated")K8();else if(A0.type==="acp-focus"){if(G9())eX("assistant")}else if(A0.type==="git-status"&&A0.payload){if(!c8.current)I0(A0.payload)}else if(A0.type==="git-lifecycle"&&A0.payload){Z0(A0.payload);for(let l of i8.current.values())try{l.contentWindow.postMessage({dgn:"git-lifecycle",payload:A0.payload},"*")}catch{}}}catch{}})}return i(),()=>{if(clearInterval(b),TQ.current)TQ.current.close()}},[y9,K8]);function $7(b){let S=TQ.current;try{if(S&&S.readyState===1)S.send(JSON.stringify(b))}catch{}}let OJ=u.useCallback(async()=>{if(c8.current)return;try{let b=await fetch("/_api/git/status");if(b.ok)I0(await b.json())}catch{}},[]),vJ=u.useCallback(async()=>{if(c8.current)return;try{let b=await fetch("/_api/git/status?remote=1");if(!b.ok)return;let S=await b.json();if(S&&S.repo!==!1)C0({remoteAhead:!!S.remoteAhead,behind:S.behind||0})}catch{}},[]),AJ=u.useCallback(async(b,S)=>{try{let i=await fetch(b,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(S||{})}),X0=await i.json().catch(()=>({}));return{ok:i.ok,...X0}}catch(i){return{ok:!1,error:"Network error — is the project still open?"}}},[]),jG=u.useCallback(async(b,S)=>{let i=await AJ("/_api/git/commit",{message:b,files:S});if(i.ok)await OJ();return i},[AJ,OJ]),jY=u.useCallback(async(b)=>{let S=await AJ("/_api/git/discard",{files:b});if(S.ok)await OJ();return S},[AJ,OJ]),vG=u.useCallback(async()=>{let b=await AJ("/_api/git/push",{});if(b.ok)await OJ(),vJ();return b},[AJ,OJ,vJ]),vY=u.useCallback(async()=>{let b=await AJ("/_api/git/pull",{});if(b.ok)await OJ(),vJ();if(b.conflict&&Array.isArray(b.files)&&b.files.length)v0({file:b.files[0],conflict:!0});return b},[AJ,OJ,vJ]),fG=u.useCallback(async(b)=>{let S=await AJ("/_api/git/resolve",{choice:b});if(S.ok)await OJ(),vJ();return S},[AJ,OJ,vJ]),fY=u.useCallback(async(b)=>{try{let S="/_api/git/log?limit=40"+(b?`&path=${encodeURIComponent(b)}`:""),i=await fetch(S);if(!i.ok)return[];return(await i.json()).entries||[]}catch{return[]}},[]),[xG,hG]=u.useState(null),gG=u.useCallback(async(b)=>{try{let S="/_api/cloud/history?limit=40"+(b?`&path=${encodeURIComponent(b)}`:""),i=await fetch(S);if(!i.ok)return null;let X0=await i.json();if(!X0?.ok)return null;return hG({branch:X0.branch??null,project:X0.project??null,hubHost:X0.hubHost??null}),X0.entries||[]}catch{return null}},[]),[mG,uG]=u.useState(!1),pG=u.useCallback(async(b)=>{try{let S="/_api/project/history?limit=40"+(b?`&path=${encodeURIComponent(b)}`:""),i=await fetch(S);if(!i.ok)return"legacy";let X0=await i.json();if(!X0?.ok)return X0?.reason==="legacy"?"legacy":null;return(X0.history||[]).map((H0)=>{let F0=b?"":(H0.canvases||[]).map((A0)=>A0.split("/").pop()).join(", ");return{sha:`r${H0.revision}`,message:[H0.label||H0.kind,F0].filter(Boolean).join(" · "),author:H0.actor,date:new Date(H0.committedAt).toISOString(),accepted:{revision:H0.revision,actionId:H0.actionId,mine:!!H0.mine,undo:H0.kind==="undo"||H0.kind==="redo"}}})}catch{return null}},[]),lG=u.useMemo(()=>{let b={modified:"M",added:"A",deleted:"D",untracked:"U"},S=new Map;if(I8)return S;for(let i of T8?.files||[])S.set(i.path,b[i.status]);return S},[T8,I8]);u.useEffect(()=>{if(I8){C0(null);return}if(T8?.repo===!1)return;vJ();let b=setInterval(vJ,W8?60000:120000);return()=>clearInterval(b)},[I8,T8?.repo,W8,vJ]);let V6=u.useCallback((b)=>{if(W.current="push",i9(null),F(null),b===V)return;if(U((S)=>{for(let i of S)if(i.path!==b)i8.current.delete(i.path);return[{path:b}]}),B(b),q8(null),y0(null),b!==r8)r0(b)},[V]),A4=u.useCallback((b,S="push")=>{let i=J.flatMap((X0)=>X0.paths||[]).find((X0)=>CW(X0,e0.designRel)===b);if(i&&y5.test(i))V6(i);else if(i&&NL(Y4(i)))M(i);else U([]),B(null),F(null),P5({title:"Not here yet",description:`${b} is not in this project (not synced yet?)`,kind:"info"});W.current=S},[J,e0.designRel,V6,M]),hH=u.useRef(!1);u.useEffect(()=>{if(!Q||e0.cloud===void 0||hH.current)return;hH.current=!0;let b=PV(location,e0.designRel);if(b)A4(b,"none")},[Q,e0.cloud,e0.designRel,A4]),u.useEffect(()=>{if(!Q||e0.cloud===void 0)return;let b=()=>{let S=PV(location,e0.designRel);if(S)A4(S,"none");else W.current="none",U([]),B(null),F(null)};return window.addEventListener("popstate",b),()=>window.removeEventListener("popstate",b)},[Q,e0.cloud,e0.designRel,A4]),u.useEffect(()=>{let b=N||(V===r8?null:V);if(b===G.current)return;G.current=b;let S=CW(b,e0.designRel);if(W.current!=="none"&&PV(location,e0.designRel)!==S)history[S?"pushState":"replaceState"](S?{open:S}:null,"",ah(location,S));W.current="push"},[V,N,e0.designRel]);let xY=N||(V===r8?null:V),dG=e0.cloud?"cloud":G9()?"native":"local",gH=(b)=>Jg({rel:CW(b,e0.designRel),shell:dG,location,linkedHubUrl:t0?.url,project:e0.cloud?Z:a8,localUrl:location.origin}),mH=(b=xY)=>{let S=CW(b,e0.designRel);if(S)v5({path:b,rel:S,label:Y4(b)})},G1=u.useCallback((b)=>{if(q8(null),y0(null),K8(),d0((S)=>S+1),b&&b!==r8)r0(b)},[K8]),cG=u.useRef(!1);u.useEffect(()=>{if(cG.current)return;if(!e0.cloud)return;if(new URLSearchParams(location.search).has("open")){cG.current=!0;return}if(K.length>0)return;if(!J.length)return;let b=null;for(let S of J){for(let i of S.paths||[]){if(!y5.test(i))continue;if(/(^|\/)system\//.test(i))continue;b=i;break}if(b)break}if(!b)return;cG.current=!0,V6(b)},[e0.cloud,J,K.length,V6]);let SQ=u.useCallback((b)=>{let S=typeof b==="string"?b:void 0;if(S)W5(S);else if(!L8)W5();V6(r8)},[L8,W5,V6]);u.useEffect(()=>{$7({type:"tabs",tabs:K.map((b)=>b.path).filter((b)=>b!==r8)})},[K]),u.useEffect(()=>{if(V&&V!==r8)$7({type:"active",file:V});else if(V===r8)$7({type:"active",file:""});else $7({type:"active",file:""})},[V]);let hY=u.useCallback((b)=>{U((S)=>{let i=S.findIndex((H0)=>H0.path===b);if(i<0)return S;let X0=S.filter((H0)=>H0.path!==b);if(b===V)if(X0.length===0)B(null);else B(X0[Math.max(0,i-1)].path);return X0}),i8.current.delete(b),r0((S)=>S===b?null:S)},[V]);yY.current=(b)=>{if(!b?.rel)return;let S=(e0?.designRel||e0?.designRoot||".design").replace(/^\/+|\/+$/g,""),i=`${S}/${b.rel}`;if(b.action==="removed")hY(i);else if(b.action==="moved"&&b.fromRel){let X0=`${S}/${b.fromRel}`;U((H0)=>H0.map((F0)=>F0.path===X0?{...F0,path:i}:F0)),B((H0)=>H0===X0?i:H0),r0((H0)=>H0===X0?null:H0),i8.current.delete(X0)}};let d5=u.useCallback(()=>{if(!V||V===r8){if(V===r8)W5();return}let b=i8.current.get(V);if(b)b.src=b.src},[V,W5]),uH=u.useCallback(()=>y9(),[y9]),[Z1,pH]=u.useState(!1),iG=u.useRef(!1),oG=u.useCallback(async()=>{if(iG.current)return;iG.current=!0,pH(!0);try{await Promise.all([y9(),new Promise((b)=>setTimeout(b,550))])}finally{iG.current=!1,pH(!1)}},[y9]);u.useEffect(()=>{let b=null,S=()=>{if(b)clearTimeout(b);b=setTimeout(()=>{b=null,uH()},150)};return window.addEventListener("focus",S),()=>{if(window.removeEventListener("focus",S),b)clearTimeout(b)}},[uH]);let H1=u.useCallback(async(b)=>{try{let S=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b,kind:"brief-board"})}),i=await S.json().catch(()=>({}));if(!S.ok||!i.ok)return{ok:!1,error:i.error||`create failed (${S.status})`};return await y9(),V6(i.file),{ok:!0,file:i.file}}catch(S){return{ok:!1,error:S instanceof Error?S.message:"network error"}}},[y9,V6]),lH=u.useCallback(async()=>{let b=await Y5("New video name");if(!b)return;let i=(await Y5("Size — 1920x1080 (landscape), 1080x1920 (portrait), 1080x1080 (square), or custom WxH","1920x1080")||"1920x1080").toLowerCase().match(/(\d{2,5})\s*[x×]\s*(\d{2,5})/),X0=i?Number(i[1]):1920,H0=i?Number(i[2]):1080,F0=Math.max(1,Math.min(60,Number(await Y5("Frames per second","30"))||30));try{let A0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b,kind:"video-comp",clips:[],fps:F0,width:X0,height:H0})}),l=await A0.json().catch(()=>({}));if(!A0.ok||!l.ok){f8(`New video failed: ${l.error||`error ${A0.status}`}`);return}await y9(),V6(l.file),j0(!0),f8("New video created — drop clips on the timeline to start the cut.",!0)}catch(A0){f8(`New video failed: ${A0 instanceof Error?A0.message:"network error"}`)}},[y9,V6,Y5]),z1=u.useCallback(async()=>{if(!V||V===r8)return;try{let b=await fetch(`/_api/annotations?file=${encodeURIComponent(V)}`),S=b.ok?await b.text():"",i=[];if(S){let l=new DOMParser().parseFromString(S,"image/svg+xml");for(let D0 of l.querySelectorAll('[data-tool="mediaref"]')){let P0=D0.getAttribute("data-src");if(!P0)continue;i.push({src:P0,mediaKind:D0.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(i.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let H0=`${VY(Y4(V)).replace(/\.tsx$/i,"")} Video`,F0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:H0,kind:"video-comp",clips:i})}),A0=await F0.json().catch(()=>({}));if(!F0.ok||!A0.ok){window.alert(`Assemble failed: ${A0.error||`error ${F0.status}`}`);return}await y9(),V6(A0.file)}catch(b){window.alert(`Assemble failed: ${b instanceof Error?b.message:"network error"}`)}},[V,y9,V6]),nG=u.useCallback(({accept:b,resolveTarget:S})=>{let i=V,X0=X6||void 0,H0=document.createElement("input");H0.type="file",H0.accept=b,H0.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(H0);let F0=()=>{if(H0.isConnected)H0.remove()};window.addEventListener("focus",()=>setTimeout(F0,300),{once:!0}),H0.addEventListener("change",()=>{let A0=H0.files?.[0];if(F0(),!A0)return;let l=`/_api/comp-clips?canvas=${encodeURIComponent(i)}${X0?`&artboardId=${encodeURIComponent(X0)}`:""}`;fetch(l).then((D0)=>D0.json().catch(()=>({}))).then((D0)=>{let P0=S(D0);if(!P0)return f8("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":A0.type||"application/octet-stream"},body:A0}).then((i0)=>i0.json().catch(()=>({}))).then((i0)=>{if(!i0?.path)return f8(`Upload failed: ${i0?.error||"unknown error"}`),null;if(P0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:i,arrayName:P0.arrayRef.arrayName,index:P0.arrayRef.index,field:P0.arrayRef.field,value:i0.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:i,id:P0.cdId,attr:"src",value:i0.path})})})}).then((D0)=>D0?D0.json():null).then((D0)=>{if(D0&&!D0.ok)f8(`Replace refused: ${D0.error||"failed"}`);else if(D0&&D0.ok){if(f8("Media replaced.",!0),D0.seq!=null)Y6(i,D0.seq,"replace media")}}).catch(()=>f8("Replace failed: network error"))}),H0.click()},[V,X6,Y6]),K1=u.useCallback(async(b,S)=>{if(!window.confirm(`Move “${S}” to trash?
5684
5684
 
5685
5685
  Its annotations, history and comments move with it. `+"You can restore it from .design/_trash/."))return;try{let X0=await fetch(`/_api/canvas?file=${encodeURIComponent(b)}`,{method:"DELETE"}),H0=await X0.json().catch(()=>({}));if(!X0.ok||!H0.ok){window.alert(`Could not delete: ${H0.error||`error ${X0.status}`}`);return}if(await y9(),V===b)U([]),B(null)}catch(X0){window.alert(`Delete failed: ${X0 instanceof Error?X0.message:"network error"}`)}},[y9,V]),U1=u.useCallback(async function b(S,i){try{let X0=await fetch("/_api/fs-move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:S,toDir:i})}),H0=await X0.json().catch(()=>({}));if(!X0.ok||!H0.ok)return f8(`Could not move: ${H0.error||`error ${X0.status}`}`),{ok:!1,error:H0.error};let F0=(e0?.designRel||e0?.designRoot||".design").replace(/^\/+|\/+$/g,""),A0=`${F0}/${H0.fromRel}`,l=`${F0}/${H0.toRel}`;await y9(),U((P0)=>P0.map((i0)=>i0.path===A0?{path:l}:i0)),B((P0)=>P0===A0?l:P0);let D0=A0.split("/").slice(0,-1).join("/");return f8(`Moved to ${H0.toRel.split("/").slice(0,-1).join("/")||"."}`,!0,{label:"Undo",onClick:()=>{b(l,D0)}}),{ok:!0}}catch(X0){return f8(`Move failed: ${X0 instanceof Error?X0.message:"network error"}`),{ok:!1,error:"network error"}}},[y9,e0]),V1=u.useCallback(async(b,S)=>{try{let i=await fetch("/_api/fs-mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parent:b,name:S})}),X0=await i.json().catch(()=>({}));if(!i.ok||!X0.ok){let H0=X0.error||`error ${i.status}`;return f8(`Could not create folder: ${H0}`),{ok:!1,error:H0}}return await y9(),{ok:!0,dir:X0.dir}}catch(i){let X0=i instanceof Error?i.message:"network error";return f8(`Create folder failed: ${X0}`),{ok:!1,error:X0}}},[y9]),q1=u.useCallback(async(b,S)=>{if(!window.confirm(`Delete folder "${S}"?
5686
5686