@1agh/maude 1.6.9 → 1.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5680,10 +5680,10 @@ ${N.block}`:B,F=[],M=new Map;for await(let A of J.prompt(V,X(),K,Q?.(),Y?.(),Z?.
|
|
|
5680
5680
|
|
|
5681
5681
|
> Maude ${l.app.maudeVersion} · ${l.app.platform} ${l.app.arch} · ${l.app.surface}
|
|
5682
5682
|
> Local report bundle: \`${e?.dir??".design/_reports/"}\` (attach its files here)`),a=`${RV0}?title=${s}&body=${H0}&labels=report`;if(H9())try{await IV(a)}catch{window.open(a,"_blank","noopener")}else window.open(a,"_blank","noopener");T({fallbackDir:e?.dir??null}),W("done")}catch{$("Saving the local bundle failed too — please file the issue by hand.")}}let g=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:(l)=>l.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:(l)=>Z(l.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:!g,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<CE&&z("button",{type:"button",className:"rb-link","data-testid":"report-bug-attach",onClick:f,children:"Attach screenshot…"}),U.length>0&&z("button",{type:"button",className:`rb-link${w?" is-on":""}`,"data-testid":"report-bug-redact",onClick:()=>O((l)=>!l),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 (",CV0(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 ",CE,"."]}):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((l,x)=>z(bV0,{shot:l,redacting:w,onRects:(n)=>B((e)=>e.map((s,H0)=>H0===x?{...s,rects:n}:s)),onRemove:()=>{URL.revokeObjectURL(l.url),B((n)=>n.filter((e,s)=>s!==x))}},l.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??""," · ",H9()?"desktop app":"browser"]})]}),Q&&D("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.activeCanvas,onChange:(l)=>M({...F,activeCanvas:l.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:(l)=>M({...F,projectName:l.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:(l)=>M({...F,logTail:l.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,H9()&&N.length>0&&D("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.crashLogs,onChange:(l)=>M({...F,crashLogs:l.target.checked})}),D("span",{children:["Crash logs (",N.length,") — ",z("code",{children:N.map((l)=>l.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:o,children:"Send report"})]})]}),Y==="sending"&&z("p",{className:"rb-hint",children:"Sending your report…"}),Y==="done"&&D(Q0,{children:[P?.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(H9())IV(P.issueUrl).catch(()=>navigator.clipboard?.writeText(P.issueUrl));else window.open(P.issueUrl,"_blank","noopener")},children:["report #",P.issueNumber]})," ","on the public Maude issue tracker. Screenshots and logs stay in a private repository only maintainers can open — the issue links to them."]}):D("p",{children:["The bundle is saved locally",P?.fallbackDir?D(Q0,{children:[" ","at ",z("code",{children:P.fallbackDir})]}):null," ","and a prefilled GitHub issue was opened — attach the bundle files there."]}),z("footer",{className:"rb-actions",children:z("button",{type:"button",className:"st-btn rb-primary",onClick: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:v,children:"Save locally & open GitHub"})]})]})]})]})})}var IJ=y8(i8(),1);function cm(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 im(J,X){let Q=cm(J),Y=cm(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 om(J,X){if(!Array.isArray(J))return[];return J.filter((Q)=>Q&&(Q.version==null||im(Q.version,X)))}function nm(J,X){let Q=X;if(Array.isArray(J)){for(let Y of J)if(Y&&Y.version&&im(Y.version,Q))Q=Y.version}return Q}var $E="mdcc-whatsnew-seen",SE="mdcc-whatsnew-toast-dismissed";function yV0(J){return typeof J==="string"&&/^https?:\/\//i.test(J)}function jV0(J){try{let X=localStorage.getItem($E);if(X)return X;localStorage.setItem($E,J)}catch{}return J}function vV0(){try{return localStorage.getItem(SE)}catch{return null}}function rm(J){let[X,Q]=IJ.useState([]),[Y,W]=IJ.useState(J),[G,Z]=IJ.useState(()=>jV0(J)),[H,K]=IJ.useState(()=>vV0()),[U,B]=IJ.useState(!1);IJ.useEffect(()=>{let O=!1,P=()=>{fetch("/_api/whats-new").then(($)=>$.json()).then(($)=>{if(O)return;if(Q(Array.isArray($?.entries)?$.entries:[]),typeof $?.version==="string")W($.version)}).catch(()=>{})};P();let T=()=>P(),R=()=>{if(document.visibilityState==="visible")P()};return window.addEventListener("focus",T),document.addEventListener("visibilitychange",R),()=>{O=!0,window.removeEventListener("focus",T),document.removeEventListener("visibilitychange",R)}},[]);let N=om(X,G),V=N.length>0&&H!==Y&&!U,F=N[0]??null,M=IJ.useCallback(()=>{let O=nm(X,Y);Z(O),K(Y);try{localStorage.setItem($E,O),localStorage.setItem(SE,Y)}catch{}},[X,Y]),A=IJ.useCallback(()=>{K(Y);try{localStorage.setItem(SE,Y)}catch{}},[Y]),E=IJ.useCallback(()=>B(!0),[]),w=IJ.useCallback(()=>{B(!1),M()},[M]);return{entries:X,unseen:N,feedVersion:Y,panelOpen:U,openPanel:E,closePanel:w,showToast:V,toastEntry:F,dismissToast:A,markAllSeen:M}}function am({wn:J}){let X=`whats-new-${J.feedVersion}`;return IJ.useEffect(()=>{if(!J.showToast||!J.toastEntry){hW(X);return}w5({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]),IJ.useEffect(()=>()=>hW(X),[X]),null}function sm({wn:J,onStartTour:X}){let{panelOpen:Q,closePanel:Y}=J;if(IJ.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}),yV0(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 o5=y8(i8(),1),fV0=Object.freeze({dirs:[],sections:{}}),xV0="mdcc-sections-expanded",hV0=250,gV0=3000;function em(J,X){return!!X&&J.dirs.includes(X)}function mV0(J,X){return J.sections[X]===!0}function bE(J,X,Q){if(!X)return J;if(J.dirs.includes(X)===!!Q)return J;let W=Q?[...J.dirs,X].sort():J.dirs.filter((G)=>G!==X);return{...J,dirs:W}}function Ju(J,X,Q){if(!X||J.sections[X]===!!Q)return J;return{...J,sections:{...J.sections,[X]:!!Q}}}function Xu(J,X){return Ju(J,X,!mV0(J,X))}function uV0(J,X){let Q=null;for(let Y of J||[]){let W=Y.fullPath;if(!W||!(X===W||X.startsWith(W+"/")))continue;if(!Q||W.length>Q.fullPath.length)Q=Y}return Q}function zF(J,X,Q,{includeSelf:Y=!1}={}){if(!Q)return J;let W=uV0(X,Q);if(!W)return J;let G=Ju(J,W.label,!0),Z=Q.slice(W.fullPath.length+1);if(!Z)return G;let H=Z.split("/"),K=Y?H.length:H.length-1,U=W.fullPath;for(let B=0;B<K;B++)U=`${U}/${H[B]}`,G=bE(G,U,!0);return G}function yE(J,X,Q){if(!X||!Q||X===Q)return J;let Y=!1,W=J.dirs.map((G)=>{if(G===X)return Y=!0,Q;if(G.startsWith(X+"/"))return Y=!0,Q+G.slice(X.length);return G});return Y?{...J,dirs:[...new Set(W)].sort()}:J}function Qu(J){let X=new Set,Q=(Y,W)=>{for(let G of Object.keys(Y||{})){if(G==="_files")continue;let Z=`${W}/${G}`;X.add(Z),Q(Y[G],Z)}};for(let Y of J||[])if(Y.fullPath)Q(Y.tree,Y.fullPath);return X}function Yu(J,X){let Q=J.dirs.filter((Y)=>X.has(Y));return Q.length===J.dirs.length?J:{...J,dirs:Q}}function tm(J){let X=J&&typeof J==="object"&&!Array.isArray(J)?J:{},Q=Array.isArray(X.dirs)?[...new Set(X.dirs.filter((W)=>typeof W==="string"&&W))].sort():[],Y={};if(X.sections&&typeof X.sections==="object"&&!Array.isArray(X.sections)){for(let[W,G]of Object.entries(X.sections))if(typeof G==="boolean")Y[W]=G}return{dirs:Q,sections:Y}}function pV0(){try{let J=JSON.parse(localStorage.getItem(xV0)||"null");return J&&typeof J==="object"&&!Array.isArray(J)?J:null}catch{return null}}function Wu({fetchImpl:J}={}){let[X,Q]=o5.useState(fV0),[Y,W]=o5.useState(!1),G=J||((...U)=>fetch(...U)),Z=o5.useRef(G);Z.current=G,o5.useEffect(()=>{let U=!1,B=typeof AbortController==="function"?new AbortController:null,N=setTimeout(()=>B?.abort(),gV0);return Z.current("/_api/tree-state",B?{signal:B.signal}:void 0).then((V)=>V.ok?V.json():Promise.reject(Error(`HTTP ${V.status}`))).then((V)=>{if(U)return;let F=tm(V);if(!(V&&typeof V==="object"&&V.sections&&Object.keys(V.sections).length)){let A=pV0();if(A)F=tm({...F,sections:A})}Q(F)}).catch(()=>{}).finally(()=>{if(clearTimeout(N),!U)W(!0)}),()=>{U=!0,clearTimeout(N)}},[]);let H=o5.useRef(!0);o5.useEffect(()=>{if(!Y)return;if(H.current){H.current=!1;return}let U=setTimeout(()=>{try{Z.current("/_api/tree-state",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(X)}).catch(()=>{})}catch{}},hV0);return()=>clearTimeout(U)},[Y,X]);let K=o5.useCallback((U)=>Q((B)=>U(B)),[]);return{state:X,ready:Y,update:K}}var V7=({as:J,size:X=14})=>z(J,{size:X,strokeWidth:1.75,style:{display:"block"}}),F90="mdcc-usage-tour-seen",L90="mdcc-collab-tour-seen",o8="__system__",s90="mdcc-theme",D90="mdcc-show-hidden",M90="maude-cp-mode",O90="mdcc-sidebar-open",A90="mdcc-minimap-visible",_90="mdcc-zoomctl-visible",w90="mdcc-annotations-visible";var sF0=30000;function tF0(J){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(J)}).catch(()=>{})}catch{}}var wT=[{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"}],aK={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",sync:"right",assistant:"right"},E90="mdcc-panel-sides",P90="mdcc-layers-mode";function I90({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]||(wT.find((U)=>U.id===K)||{}).label||K},K))}),Z]})}var S5=/\.(tsx|html?)$/i,k90=(J)=>/\.(tsx|jsx)$/i.test(String(J||"")),eF0=[[/\.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 PL(J){for(let[X,Q]of eF0)if(X.test(J))return Q;return null}function _q(J){return J.replace(/^\.[^/]+\//,"").replace(S5,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}function JL0(J){let X=[];return function Q(Y){for(let W of Y||[])X.push(W?.id??""),Q(W?.children)}(J),X.join(",")}var ET="1.6.9";function NL(J,X){let Q=()=>{try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(J,{body:X})}catch{}};if(H9()){w7("send_notification",{title:J,body:X}).catch(Q);return}Q()}function XL0(){if(typeof window>"u")return"dark";try{let J=localStorage.getItem(s90);if(J==="light"||J==="dark")return J}catch{}return"dark"}function TH(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 T90(J,X){if(typeof window>"u")return X;try{let Q=localStorage.getItem(J);return Q?JSON.parse(Q):X}catch{return X}}function QL0(){return!1}var YL0=[];function qQ(J){return J.split("/").pop()}function g8(J,X=!1,Q){w5({title:J,kind:X?"success":"error",action:Q})}var R90="maude-mode-hint-seen";function DL(J=!1){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(R90)==="1")return}catch{return}if(DL.active)return;DL.active=!0;let X=()=>{DL.active=!1;try{localStorage.setItem(R90,"1")}catch{}document.removeEventListener("keydown",Q,!0)},Q=(Y)=>{if((Y.key==="v"||Y.key==="V")&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey)hW("mode-hint"),X()};if(J)document.addEventListener("keydown",Q,!0);w5({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 Y4(J){return J.replace(S5,"")}function WL0(J){return J.replace(S5,"")}function GL0(J){let X=new Map;for(let G of J){if(!S5.test(G.name))continue;let Z=WL0(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(S5.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 ZL0(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 t90(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=t90(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 ML(J){return(J||[]).filter((X)=>X.status!=="resolved").length}function HL0(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 e90(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 AL({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 zL0={"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 KL0({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(()=>QB(Q,Y),[Y,Q]);if(u.useEffect(()=>{if(G>=K.length)Z(0)},[K.length,G]),!J)return null;let U=(B)=>{X(),B.run()};return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(B)=>{if(B.target===B.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(k9,{name:"search",size:18}),z("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(B)=>W(B.target.value),onKeyDown:(B)=>{if(B.key==="Escape")B.preventDefault(),X();else if(B.key==="ArrowDown")B.preventDefault(),Z((N)=>Math.min(K.length-1,N+1));else if(B.key==="ArrowUp")B.preventDefault(),Z((N)=>Math.max(0,N-1));else if(B.key==="Enter"){B.preventDefault();let N=cb(Q,Y,B.currentTarget.value,G);if(N)U(N)}}}),z(RJ,{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((B,N)=>{let V=B.group&&(N===0||K[N-1].group!==B.group)?z("div",{className:"st-pal-group",children:B.group},"g-"+B.group):null;return D(Q0,{children:[V,D("button",{type:"button",className:"st-pal-item"+(N===G?" is-active":""),onMouseEnter:()=>Z(N),onClick:()=>U(B),children:[z("span",{className:"st-pal-icon",children:z(k9,{name:B.icon,size:15})}),z("span",{className:"st-pal-label",children:B.label}),B.kbd?z("span",{className:"st-pal-kbd",children:z(RJ,{children:B.kbd})}):null]})]},B.id)})})]})})}function k9({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:zL0[J]})}function UL0(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 C90({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 RJ({children:J}){return z("span",{className:"kbd",children:J})}function $90(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 S90({label:J,size:X,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:K,def:U}=X,B=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:(N)=>{let V=N.shiftKey?24:8;if(N.key==="ArrowRight")N.preventDefault(),Z((F)=>F+V*B);else if(N.key==="ArrowLeft")N.preventDefault(),Z((F)=>F-V*B);else if(N.key==="Home")N.preventDefault(),Z(H);else if(N.key==="End")N.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 OT=[{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}],b90={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},VL0=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],Dq=[{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}],qL0="2x",y90=[{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}],BL0="auto",j90=[{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."}],NL0="keep",FL0={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 LL0(J){let X=String(J||"").split(".").pop()?.toLowerCase();return FL0[X]||"application/octet-stream"}function DL0({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),[B,N]=u.useState(null),[V,F]=u.useState(()=>new Set),[M,A]=u.useState({}),[E,w]=u.useState(W?"artboard":"annotation");u.useEffect(()=>{let v=!0;return fetch("/_api/assets").then((g)=>g.json()).then((g)=>{if(!v)return;let l=g.ok?g.assets:[];H(l),A((x)=>{let n={...x};for(let e of l)n[e.path]=e.kind;return n})}).catch(()=>v&&H([])),()=>{v=!1}},[]),u.useEffect(()=>{let v=(g)=>{if(g.key==="Escape")g.stopPropagation(),Q()};return window.addEventListener("keydown",v,!0),()=>window.removeEventListener("keydown",v,!0)},[Q]);let O=Array.from(V).some((v)=>(M[v]||"image")!=="image"),P=!W||O,T=!W?"No artboard on this canvas":O?"Video/audio can only be added as annotations":"";u.useEffect(()=>{if(P&&E==="artboard")w("annotation")},[P,E]);let R=(v)=>{F((g)=>{let l=new Set(g);if(l.has(v))l.delete(v);else l.add(v);return l})},$=async(v)=>{let g=await fetch("/_api/asset",{method:"POST",headers:{"content-type":v.type||"application/octet-stream"},body:v}),l=await g.json().catch(()=>({}));if(g.ok&&l.path)return{ok:!0,path:l.path};return{ok:!1,error:l.error||`upload failed (HTTP ${g.status})`}},C=async(v)=>{if(!v)return;U(!0),N(null);let g=await $(v);if(U(!1),g.ok)X(g.path);else N(g.error)},j=(v)=>{if(typeof v==="string"&&v.startsWith("video/"))return"video";if(typeof v==="string"&&v.startsWith("audio/"))return"audio";return"image"},f=async(v)=>{if(!v.length)return;U(!0),N(null);let g=await Promise.all(v.map((n)=>$(n).then((e)=>({...e,file:n}))));U(!1);let l=g.filter((n)=>n.ok),x=g.length-l.length;if(x>0)N(`${x} of ${g.length} uploads failed`);if(l.length)A((n)=>{let e={...n};for(let s of l)e[s.path]=j(s.file.type);return e}),F((n)=>{let e=new Set(n);for(let s of l)e.add(s.path);return e})},m=async()=>{U(!0),N(null);try{if(Y){let l=(await bh()||[]).map((x)=>new File([new Uint8Array(x.bytes)],x.name,{type:LL0(x.name)}));if(U(!1),l.length)await f(l);return}let v=await cZ();if(v?.bytes){await C(new Blob([new Uint8Array(v.bytes)]));return}}catch(v){N(v?.message||"open failed")}U(!1)},c=()=>{if(H9()){m();return}let v=document.createElement("input");if(v.type="file",v.accept="image/*,video/*",Y)v.multiple=!0;v.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(v);let g=()=>{if(v.isConnected)v.remove()};window.addEventListener("focus",()=>setTimeout(g,300),{once:!0}),v.addEventListener("change",()=>{let l=v.files?Array.from(v.files):[];if(g(),!l.length)return;if(Y)f(l);else C(l[0])}),v.click()},o=(v)=>`/${J}/${v}`;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(v)=>{if(v.target===v.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(k9,{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:c,disabled:K,children:K?"Uploading…":"Upload…"}),B&&z("span",{className:"st-ap-err",children:B})]}),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((v)=>{let g=Y&&V.has(v.path);return D("button",{type:"button",className:"st-ap-cell","data-selected":g?"true":void 0,"aria-pressed":Y?g:void 0,title:`${v.name} · ${Math.max(1,Math.round(v.size/1024))} KB`,onClick:()=>Y?R(v.path):X(v.path),children:[Y&&z("span",{className:"st-ap-check","aria-hidden":"true",children:g?z(k9,{name:"check",size:12}):null}),v.kind==="video"?z("video",{className:"st-ap-thumb",src:o(v.path),muted:!0,playsInline:!0}):z("img",{className:"st-ap-thumb",src:o(v.path),alt:v.name,loading:"lazy"}),z("span",{className:"st-ap-name",children:v.name})]},v.path)})})]}),Y&&V.size>0&&D("div",{className:"st-dialog-ft st-ap-confirm",children:[D("span",{className:"st-ap-count",children:[V.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:P,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"})]}),P&&z("span",{className:"st-ap-dest-note",children:T}),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(V),E),children:"Insert"})]})]})})}function _L(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 ML0({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 B=u.useCallback((w0)=>H==="none"&&!w0.handoff&&w0.format!=="zip"&&!Gy.has(w0.format)||H!=="local"&&w0.format==="canva",[H]),[N,V]=u.useState(J==="handoff"?"shadcn":"png"),[F,M]=u.useState(()=>X&&ob("png",X)?X:jO("png")),[A,E]=u.useState(2),[w,O]=u.useState(qL0),[P,T]=u.useState(!0),[R,$]=u.useState(!1),[C,j]=u.useState(!1),[f,m]=u.useState(!1),[c,o]=u.useState(BL0),[v,g]=u.useState(NL0),[l,x]=u.useState(!0),[n,e]=u.useState(!1),[s,H0]=u.useState(null),[a,z0]=u.useState([]),i=OT.find((w0)=>w0.id===N)||OT[0],q0=i.handoff?[]:vO(i.format),Z0=900,C0=3600,a0=IK(W,QE(W,{artboardId:G})),o0=a0?.durationInFrames||0,J8=a0?.fps||30,P8=i.temporal&&o0>900,n8=i.temporal&&o0>3600;u.useEffect(()=>{if(q0.length&&!q0.includes(F))M(jO(i.format))},[q0,F,i.format]),u.useEffect(()=>{if(H!=="remote")return;fetch("/_api/export-warmup").catch(()=>{})},[H]);let C8=u.useCallback(()=>{fetch("/_api/export-history").then((w0)=>w0.json()).then((w0)=>z0(Array.isArray(w0?.history)?w0.history.slice(0,6):[])).catch(()=>{})},[]);u.useEffect(()=>{C8()},[C8]),u.useEffect(()=>{function w0(A0){if(A0.key==="Escape")A0.preventDefault(),U()}return window.addEventListener("keydown",w0),()=>window.removeEventListener("keydown",w0)},[U]);async function w8(){if(i.handoff){let q8=`/design:handoff ${Q&&Q!==o8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(q8)}catch{}H0({ok:!0,msg:`Copied: ${q8} — run it in Claude Code.`});return}if(B(i)){H0({ok:!1,msg:"This format needs the render service, which this workspace doesn’t have configured."});return}e(!0),H0(null);let w0=i.temporal?{scale:A}:{};if(i.format==="png"){let S0=Dq.find((q8)=>q8.id===w)||Dq[1];if(S0.kind==="dpi")w0.dpi=S0.value;else w0.scale=S0.value}if(i.format==="mp4"||i.format==="webm")w0.audio=l;if(n8)w0.maxFrames=o0;if(i.format==="pdf"){w0.pdfPrint={includeBleed:P,marks:{crop:C,registration:f}};let S0=y90.find((q8)=>q8.id===c)?.value;if(S0!==void 0)w0.dpi=S0;if(v!=="keep")w0.text=v}if(G)w0.artboardId=G;if(Z?.selector)w0.selection=Z;if(Q&&Q!==o8)w0.canvasFile=Q;if(hU.has(i.format)&&HB({exportLane:H,format:i.format,scope:F,artboardId:w0.artboardId})&&typeof K==="function")try{let S0=pO(w0);H0({ok:!0,msg:"Capturing…"});let q8=await K({format:i.format,artboardIds:[w0.artboardId],scale:S0,onProgress:(k8,x8)=>H0({ok:!0,msg:`Capturing ${k8}/${x8}…`})}),X8=await uO(q8,i.format);for(let k8 of X8)_L(k8.name,k8.blob);for(let k8 of X8)await lO({format:i.format,scope:F,filename:k8.name});e(!1),H0({ok:!0,msg:`Saved ${X8.map((k8)=>k8.name).join(", ")} to your downloads.`});return}catch(S0){if(H!=="remote"){H0({ok:!1,msg:`Capture failed: ${S0&&S0.message||S0}`}),e(!1);return}}if(HB({exportLane:H,format:i.format,scope:F})&&i.format==="pptx"&&typeof K==="function")try{H0({ok:!0,msg:"Capturing artboards…"});let S0=Q&&Q!==o8?qQ(Q).replace(/\.[^.]+$/,""):"export",{filename:q8,blob:X8}=await mO({capture:K,name:S0,onProgress:(k8,x8)=>H0({ok:!0,msg:`Capturing ${k8}/${x8}…`}),onAssemble:()=>H0({ok:!0,msg:"Assembling deck…"})});_L(q8,X8),await lO({format:i.format,scope:F,filename:q8}),e(!1),H0({ok:!0,msg:`Saved ${q8} to your downloads.`});return}catch(S0){if(H!=="remote"){H0({ok:!1,msg:`Deck export failed: ${S0&&S0.message||S0}`}),e(!1);return}}if(H==="none"&&hU.has(i.format)){H0({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 S0=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:i.format,scope:F,options:w0})});if(!S0.ok){H0({ok:!1,msg:await S0.text()||`Export failed (${S0.status})`}),e(!1);return}U()}catch(S0){H0({ok:!1,msg:S0&&S0.message?S0.message:String(S0)}),e(!1)}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(w0)=>{if(w0.target===w0.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(k9,{name:"x",size:15})})]}),D("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:Q&&Q!==o8?`Format · ${Y4(qQ(Q))}`:"Format"}),z("div",{className:"st-fmt-grid",children:OT.filter((w0)=>!w0.temporal||Y).map((w0)=>D("button",{type:"button","data-testid":`export-format-${w0.id}`,className:"st-fmt"+(w0.id===N?" is-on":""),disabled:B(w0),title:B(w0)?"Needs the render service — not configured on this workspace":void 0,onClick:()=>{V(w0.id),H0(null)},children:[z(k9,{name:w0.icon,size:16}),z("span",{className:"st-fmt-name",children:w0.label}),z("span",{className:"st-fmt-sub",children:w0.sub})]},w0.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)."]}),!i.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:(w0)=>M(w0.target.value),children:q0.map((w0)=>z("option",{value:w0,children:b90[w0]},w0))})]}),!i.handoff&&i.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:(w0)=>O(w0.target.value),children:Dq.map((w0)=>z("option",{value:w0.id,children:w0.label},w0.id))})]}),!i.handoff&&i.format==="png"&&z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let w0=Dq.find((S0)=>S0.id===w)||Dq[1],A0=w0.kind==="dpi"?w0.value/96:w0.value;return`${w0.label} ≈ ${Math.round(1440*A0)}×${Math.round(900*A0)} for a 1440×900 artboard.`})()}),!i.handoff&&i.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:(w0)=>E(Number(w0.target.value)),children:VL0.map((w0)=>z("option",{value:w0.value,children:w0.label},w0.value))})]}),!i.handoff&&i.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,")."]}),P8&&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: ",o0," frames (≈",Math.round(o0/J8),"s).",n8?` 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."]}),!i.handoff&&i.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:c,onChange:(w0)=>o(w0.target.value),children:y90.map((w0)=>z("option",{value:w0.id,children:w0.label},w0.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:v,onChange:(w0)=>g(w0.target.value),children:j90.map((w0)=>z("option",{value:w0.id,children:w0.label},w0.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:j90.find((w0)=>w0.id===v)?.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:P,onChange:(w0)=>T(w0.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:()=>$((w0)=>!w0),"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:(w0)=>j(w0.target.checked)}),"Crop marks"]}),D("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:f,onChange:(w0)=>m(w0.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.":""]})]}),!i.handoff&&(i.format==="mp4"||i.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:l,onChange:(w0)=>x(w0.target.checked)}),"Export with audio"]})}),i.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."]}),s&&z("div",{className:"callout "+(s.ok?"callout--success":"callout--error"),style:{fontSize:12},"data-testid":"export-status","data-ok":s.ok?"1":"0",children:s.msg}),a.length>0&&D("div",{className:"st-export-recent","data-testid":"export-recent",children:[z("div",{className:"st-rp-hd",children:"Recent"}),a.map((w0,A0)=>D("div",{className:"st-export-recent-row",children:[D("span",{children:[String(w0.format||"").toUpperCase()," ·"," ",b90[w0.scope]||w0.scope]}),z("span",{className:"st-mono",children:w0.filename})]},A0))]})]}),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:n,onClick:w8,children:[z(k9,{name:"download",size:14}),i.handoff?"Copy handoff command":n?"Exporting…":`Export ${i.label}`]})]})]})})}var IL=12,kL=16;function OL0({name:J,depth:X,children:Q,dirPath:Y,drag:W,menu:G,expansion:Z,forceOpen:H}){let K=!!H||!!Z?.isOpen(Y),U=(E)=>{if(H)return;let w=typeof E==="function"?E(K):E;if(w!==K)Z?.setOpen(Y,w)},B=W?W.dropProps(Y,!0,()=>U(!0)):{},N=W?.overDir===Y,V=W?W.dragProps(Y,!0):{},F=W?.draggedPath===Y,M=W?.busyPath===Y,A=D("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${_q(Y)}`,"aria-expanded":K,"aria-dropeffect":W?"move":void 0,"aria-busy":M||void 0,tabIndex:-1,className:"st-row"+(N?" is-drop-target":"")+(F?" is-dragging":"")+(M?" is-busy":""),style:{paddingLeft:IL+X*kL+"px"},onClick:()=>U((E)=>!E),onContextMenu:G?(E)=>G.openAt(E,{kind:"dir",dirPath:Y}):void 0,...V,...B,children:[z("span",{className:"st-row-glyph",children:z(k9,{name:"chevron-right",className:"st-chev"+(K?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:J})]});return z(dz,{label:J,row:A,expanded:K,busy:M,onToggle:()=>U((E)=>!E),actions:G?z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${_q(Y)}`,title:`Folder actions — ${J}`,"aria-label":`Folder actions for ${J}`,"aria-haspopup":"menu",onClick:(E)=>G.openAt(E,{kind:"dir",dirPath:Y}),children:z(AL,{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})}):null,children:K&&Q})}function AL0({name:J,dsName:X,dirPath:Q,depth:Y,active:W,onOpenSystem:G,children:Z,expansion:H,forceOpen:K}){let U=!!K||!!H?.isOpen(Q),B=(N)=>{if(K)return;let V=typeof N==="function"?N(U):N;if(V!==U)H?.setOpen(Q,V)};return z(dz,{label:J,expanded:U,selected:W,onToggle:()=>B((N)=>!N),row:D("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:IL+Y*kL+"px"},children:[z("button",{type:"button",className:"st-ds-chev",onClick:()=>B((N)=>!N),"aria-label":U?"Collapse design system":"Expand design system",title:U?"Collapse":"Expand",children:z(k9,{name:"chevron-right",className:"st-chev"+(U?" is-open":""),size:13})}),D("button",{type:"button",className:"st-ds-open","data-tree-primary":"",tabIndex:-1,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(k9,{name:"folder",size:13})}),z("span",{className:"st-row-name",children:J})]})]}),children:U&&Z})}function wL({file:J,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,onDelete:G,openCount:Z,depth:H,kind:K,sidecar:U,dirty:B,experimentalKind:N,drag:V,menu:F}){let M=J.path===X||J.path===Q,A=S5.test(J.name),E=!A&&K!=="runtime"?PL(J.name):null,w=!A&&!E,O=A?Y4(J.name):J.name,P=A&&typeof G==="function"&&K!=="runtime",T=A&&!U&&K!=="runtime"&&typeof V<"u",R=T?V.dragProps(J.path,!0):{},$=V?.draggedPath===J.path,C=V?.busyPath===J.path,j=T&&typeof F<"u",f=!A&&!!E&&!U&&typeof F<"u",m=typeof F<"u"&&K!=="runtime",c=J.path.split("/").slice(0,-1).join("/"),o=A?"canvas-row-"+J.path.replace(/^\.[^/]+\//,"").replace(S5,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,v=D("button",{type:"button",role:"treeitem","data-testid":o??(f?`file-row-${_q(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:IL+H*kL+"px"},title:J.path+(Z?` — ${Z} open`:w?" (file index only)":""),onClick:()=>{if(A)Y(J.path);else if(E)W?.(J.path)},onPointerEnter:E==="image"?()=>nw(J.path):void 0,onFocus:E==="image"?()=>nw(J.path):void 0,onContextMenu:m?(g)=>F.openAt(g,{kind:"file",path:J.path,dir:c,canMove:j||f,supporting:f,name:J.name}):void 0,...R,children:[z("span",{className:"st-row-glyph",children:z(k9,{name:"file",size:13})}),z("span",{className:"st-row-name",children:O}),N==="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"}),N==="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"}),B&&z("span",{className:"st-git-badge","data-kind":B,title:`Unsaved (${B})`,"aria-label":`Unsaved, ${B}`,children:B}),Z>0&&z("span",{className:"st-row-badge",children:Z})]});return z(dz,{label:O,row:v,selected:M,disabled:w,busy:C,actions:D(Q0,{children:[m&&z("button",{type:"button",className:"st-row-menu-btn"+(P?" has-delete-sibling":""),"data-testid":`tree-row-menu-${_q(J.path)}`,title:`Actions for ${O}`,"aria-label":`Actions for ${O}`,"aria-haspopup":"menu",onClick:(g)=>F.openAt(g,{kind:"file",path:J.path,dir:c,canMove:j||f,supporting:f,name:J.name}),children:z(AL,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})}),P&&z("button",{type:"button",className:"st-row-del",title:`Delete ${O}`,"aria-label":`Delete canvas ${O}`,onClick:(g)=>{g.stopPropagation(),G(J.path,O)},children:z(AL,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})})}function _L0({primary:J,sidecars:X,depth:Q,kind:Y,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,showHidden:B,forceOpen:N,dirtyByPath:V,experimentalKind:F,drag:M,menu:A}){let E=V?.get(J.path),w=X.length>0,[O,P]=u.useState(!1),T=N||O,R=J.path===W;if(!(w&&B))return z(wL,{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):{},f=M?.draggedPath===J.path,m=M?.busyPath===J.path,c=C&&typeof A<"u",o=typeof A<"u"&&Y!=="runtime",v=J.path.split("/").slice(0,-1).join("/"),g=D("button",{type:"button",role:"treeitem","aria-selected":R,"aria-expanded":T,"aria-busy":m||void 0,tabIndex:R?0:-1,className:"st-row st-canvas-row"+(R?" is-sel":"")+(f?" is-dragging":"")+(m?" is-busy":""),style:{paddingLeft:IL+Q*kL+"px"},title:J.path,onClick:(l)=>{if(l.target.closest(".st-canvas-chev")){P((x)=>!x);return}Z(J.path)},onContextMenu:o?(l)=>A.openAt(l,{kind:"file",path:J.path,dir:v,canMove:c}):void 0,...j,children:[z("span",{className:"st-row-glyph st-canvas-chev",onClick:(l)=>{l.stopPropagation(),P((x)=>!x)},children:z(k9,{name:"chevron-right",className:"st-chev"+(T?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:Y4(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 z(dz,{label:Y4(J.name),row:g,selected:R,expanded:T,busy:m,onToggle:()=>P((l)=>!l),actions:o?z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${_q(J.path)}`,title:`Actions for ${Y4(J.name)}`,"aria-label":`Actions for ${Y4(J.name)}`,"aria-haspopup":"menu",onClick:(l)=>A.openAt(l,{kind:"file",path:J.path,dir:v,canMove:c}),children:z(AL,{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})}):null,children:T&&X.map((l)=>z(wL,{file:l,menu:A,activePath:W,previewPath:G,onOpen:Z,onPreview:H,openCount:0,depth:Q+1,kind:Y,sidecar:!0},l.path))})}function J70({node:J,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z=1,kind:H,showHidden:K,search:U,dsFolders:B,activeDsName:N,onOpenSystem:V,onDelete:F,dirtyByPath:M,canvasKinds:A,dirPath:E="",drag:w,menu:O,expansion:P}){let T=Object.keys(J).filter((o)=>o!=="_files").sort(),R=J._files||[],{canvases:$,orphans:C}=u.useMemo(()=>GL0(R),[R]),{mediaOrphans:j,metaOrphans:f}=u.useMemo(()=>{let o=[],v=[];for(let g of C){let l=PL(g.primary.name);(l==="image"||l==="video"||l==="audio"||l==="font"?o:v).push(g)}return{mediaOrphans:o,metaOrphans:v}},[C]),m=!!(U&&U.trim()),c=u.useMemo(()=>{if(!B||Z!==1)return null;let o=new Map;for(let v of B)o.set(v.folder,v);return o},[B,Z]);return D(Q0,{children:[$.map((o)=>{let v=m&&o.sidecars.some((g)=>{let l=U.toLowerCase();return g.name.toLowerCase().includes(l)||g.path.toLowerCase().includes(l)});return z(_L0,{primary:o.primary,sidecars:o.sidecars,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,onDelete:F,openCount:ML(G[o.primary.path]),depth:Z,kind:H,showHidden:K,forceOpen:v,dirtyByPath:M,experimentalKind:A?.[o.primary.path],drag:w,menu:O},o.primary.path)}),j.map((o)=>z(wL,{file:o.primary,menu:O,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,openCount:ML(G[o.primary.path]),depth:Z,kind:H},o.primary.path)),K&&f.map((o)=>z(wL,{file:o.primary,menu:O,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,openCount:ML(G[o.primary.path]),depth:Z,kind:H},o.primary.path)),T.map((o)=>{let v=c?.get(o),g=E?`${E}/${o}`:o,l=z(J70,{node:J[o],activePath:X,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z+1,kind:H,showHidden:K,search:U,activeDsName:N,onOpenSystem:V,onDelete:F,dirtyByPath:M,canvasKinds:A,dirPath:g,drag:w,menu:O,expansion:P});if(v&&V)return z(AL0,{name:o,dsName:v.name,dirPath:g,depth:Z,expansion:P,forceOpen:m,active:X===o8&&v.name===N,onOpenSystem:V,children:l},o);return z(OL0,{name:o,depth:Z,dirPath:g,expansion:P,forceOpen:m,drag:w,menu:w?O:void 0,children:l},o)})]})}var FL={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function wL0(J){if(J.kind==="project")return FL.project;if(J.kind==="runtime")return FL.runtime;if(J.label==="Design system")return FL.ds;if(J.label==="UI kit")return FL.canvas;return{title:J.label.toUpperCase(),pillFromCount:!0}}function EL0({failures:J,cloud:X}){let[Q,Y]=u.useState(!1);u.useEffect(()=>{let G=setTimeout(()=>Y(!0),3000);return()=>clearTimeout(G)},[]);let W=J>0?"The project is taking a while to answer — trying again…":X?"Still loading — a large cloud project can take a few seconds to list.":"Still loading — a large project can take a few seconds to list.";return D("div",{className:"st-tree-loading",role:"status","aria-live":"polite","data-testid":"tree-loading",children:[D("div",{className:"st-tree-loading-head",children:[z("span",{className:"st-canvas-loading-spinner","aria-hidden":"true"}),z("span",{children:"Loading files…"})]}),[64,48,72,40,56,68,44].map((G,Z)=>z("span",{className:"skel st-tree-loading-row",style:{width:`${G}%`,marginLeft:Z%3?22:8},"aria-hidden":"true"},Z)),(Q||J>0)&&z("div",{className:"st-tree-loading-hint",children:W})]})}function PL0({readOnly:J=!1,cloud:X,groups:Q,activePath:Y,previewPath:W,activeDsName:G,onOpen:Z,onPreview:H,onOpenSystem:K,wsConnected:U,search:B,setSearch:N,commentsByFile:V,showHidden:F,sectionsExpanded:M,onToggleSection:A,treeExpansion:E,onNewBoard:w,onDeleteBoard:O,onRefresh:P,refreshing:T,collapsed:R,onCollapse:$,width:C,resizing:j,dirtyByPath:f,project:m,gitBranch:c,remoteSync:o,onGetLatest:v,canvasKinds:g,onMoveCanvas:l,onNewFolder:x,onDeleteFolder:n,onRenameFolder:e,onRenameCanvas:s,onDuplicateCanvas:H0,onDeleteFile:a,syncStatus:z0,onLinkedHub:i,onLocalProject:q0,onOpenLinkedFile:Z0,filesReady:C0,treeLoadFailures:a0=0,onShare:o0,savingIsManaged:J8=!1}){let P8=u.useMemo(()=>{if(!B)return Q;return Q.map((k0)=>({...k0,tree:t90(k0.tree,B),filtered:!!B}))},[Q,B]),n8=Uy(l),C8=Hy(),w8=u.useMemo(()=>{let k0=[];for(let b0 of Q){if(b0.label==="Design system"||b0.kind!=="canvas")continue;let h0=b0.fullPath.replace(/^\.[^/]+\//,"")||b0.fullPath;k0.push({path:b0.fullPath,label:h0});for(let O8 of b0.dirs||[])k0.push({path:O8,label:O8.replace(/^\.[^/]+\//,"")})}return k0},[Q]),w0=C8.state?.extra,A0=w0?.kind==="file"?[{id:"share",label:"Share…",onSelect:()=>{C8.close(),o0(w0.path)}},...s&&/\.tsx$/i.test(w0.path)?[{id:"rename-canvas",label:"Rename…",onSelect:()=>{C8.close();let k0=Y4(w0.path.split("/").pop()),b0=window.prompt("Rename canvas to:",k0);if(b0?.trim()&&b0.trim()!==k0)s(w0.path,b0.trim())}}]:[],...H0&&/\.tsx$/i.test(w0.path)?[{id:"duplicate-canvas",label:"Duplicate",onSelect:()=>{C8.close(),H0(w0.path)}}]:[],...w0.supporting&&s?[{id:"rename-file",label:"Rename…",onSelect:()=>{C8.close();let k0=w0.name??w0.path.split("/").pop(),b0=k0.includes(".")?k0.slice(k0.lastIndexOf(".")):"",h0=b0?k0.slice(0,-b0.length):k0,O8=window.prompt(`Rename ${k0} to:`,h0);if(O8?.trim()&&O8.trim()!==h0)s(w0.path,O8.trim())}}]:[],...w0.canMove?[{id:"move-to",label:"Move to…",onSelect:()=>C8.showMoveTo()}]:[],...w0.supporting&&a?[{id:"delete-file",label:"Delete",destructive:!0,onSelect:()=>{C8.close(),a(w0.path,w0.name??w0.path.split("/").pop())}}]:[]]:w0?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{C8.close();let k0=window.prompt("New folder name:");if(k0?.trim())x(w0.dirPath,k0.trim())}},{id:"rename-folder",label:"Rename folder",onSelect:()=>{C8.close();let k0=w0.dirPath.split("/").pop(),b0=window.prompt("Rename folder to:",k0);if(b0?.trim()&&b0.trim()!==k0)e(w0.dirPath,b0.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{C8.close(),n(w0.dirPath,w0.dirPath.split("/").pop())}}]:[],S0=w0?.kind==="file"||w0?.kind==="supporting"?w8.filter((k0)=>k0.path!==w0.dir):[],[q8,X8]=u.useState(!1),[k8,x8]=u.useState("board"),[N9,m0]=u.useState(""),[R8,z9]=u.useState(""),[N8,B0]=u.useState(!1),t0=u.useMemo(()=>Q.find((k0)=>k0.kind==="canvas"&&k0.label!=="Design system")?.fullPath,[Q]),s0=u.useCallback(async()=>{let k0=N9.trim();if(!k0||N8)return;if(B0(!0),z9(""),k8==="folder"){if(!t0){B0(!1),z9("no canvas group to create a folder in");return}let h0=await x(t0,k0);if(B0(!1),h0?.ok)X8(!1),m0("");else z9(h0?.error||"could not create folder");return}let b0=await w(k0);if(B0(!1),b0?.ok)X8(!1),m0("");else z9(b0?.error||"could not create board")},[N9,N8,w,x,k8,t0]),p8=u.useMemo(()=>{let k0=0;for(let b0 of Q)for(let h0 of b0.paths||[])if(S5.test(h0))k0++;return k0},[Q]),_8=u.useMemo(()=>{let k0=0;for(let b0 of P8)for(let h0 of b0.paths||[])if(S5.test(h0))k0++;return k0},[P8]);return D("nav",{className:"st-sidebar"+(R?" is-collapsed":"")+(j?" is-resizing":""),style:R||!C?void 0:{width:C,flexBasis:C},"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":q8&&k8==="board",onClick:()=>{z9(""),x8("board"),X8((k0)=>k8==="board"?!k0:!0)},children:z(k9,{name:"plus",size:15})}),!J&&t0&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":q8&&k8==="folder",onClick:()=>{z9(""),x8("folder"),X8((k0)=>k8==="folder"?!k0:!0)},children:z(k9,{name:"folder-plus",size:15})}),P&&z("button",{type:"button",className:"st-iconbtn st-refresh"+(T?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":T||void 0,disabled:T,onClick:()=>P(),children:z(k9,{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"}),_8," / ",p8]}),$&&z("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:$,children:z(k9,{name:"panel-left",size:15})})]})]}),q8?D("div",{className:"st-newboard",children:[z("input",{type:"text",autoFocus:!0,placeholder:k8==="folder"?"folder name…":"brief board name…",value:N9,maxLength:60,disabled:N8,"aria-label":k8==="folder"?"New folder name":"New brief board name",onChange:(k0)=>m0(k0.target.value),onKeyDown:(k0)=>{if(k0.key==="Enter")k0.preventDefault(),s0();else if(k0.key==="Escape")k0.preventDefault(),X8(!1),m0(""),z9("")}}),z("button",{type:"button",className:"st-newboard-go",disabled:N8||!N9.trim(),"data-tip":"Create · Enter","aria-label":k8==="folder"?"Create folder":"Create brief board",onClick:s0,children:N8?"…":"↵"})]}):null,R8?z("div",{className:"st-newboard-err",role:"alert",children:R8}):null,z("div",{className:"st-search",children:D("div",{className:"st-search-box",children:[z(k9,{name:"search",size:13}),z("input",{type:"search","data-testid":"canvas-search",placeholder:"Search canvases…",value:B,onChange:(k0)=>N(k0.target.value),onKeyDown:(k0)=>{if(k0.key==="Escape")if(k0.preventDefault(),B)N("");else k0.currentTarget.blur()},"aria-label":"Filter files"}),B?z("button",{className:"st-search-clear",onClick:()=>N(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):z(RJ,{children:"/"})]})}),!C0&&z(EL0,{failures:a0,cloud:X}),z(Ky,{"aria-label":"Project file tree","data-testid":"canvas-list",children:P8.map((k0)=>{if(!F&&!B&&k0.kind==="runtime")return null;let b0=wL0(k0),h0=(k0.paths||[]).filter((i0)=>S5.test(i0)).length,O8=b0.pill||(b0.pillFromDsCount?String(k0.dsFolders?.length||0):null)||(b0.pillFromCount?String(h0||k0.paths?.length||0):null),P0=k0.tree&&Object.keys(k0.tree).length>0,e0=k0.label==="Design system",E8=k0.kind==="project";if(!F&&!B&&E8&&h0===0)return null;let U0=QL0(k0),n0=M[k0.label],D8=!!B||(n0===void 0?U0:n0),e8=!e0&&k0.kind==="canvas"&&!J,L9=e8?n8.dropProps(k0.fullPath,!0):{},l7=n8.overDir===k0.fullPath;return z(dz,{className:"st-tree-section",label:b0.title,expanded:D8,onToggle:()=>A(k0.label,U0),row:D("button",{type:"button",className:"st-tree-sec-hd"+(l7?" is-drop-target":""),"data-testid":`tree-section-${k0.label.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,onClick:()=>A(k0.label,U0),"aria-expanded":D8,"aria-dropeffect":e8?"move":void 0,title:D8?"Collapse section":"Expand section",...L9,children:[z(k9,{name:"chevron-right",className:"st-chev"+(D8?" is-open":""),size:13}),z("span",{className:"st-sec-name",children:b0.title}),O8&&z("span",{className:"st-pill",children:O8})]}),children:D8&&(P0?z(J70,{node:k0.tree,activePath:Y,previewPath:W,onOpen:Z,onPreview:H,commentsByFile:V,depth:1,kind:k0.kind,showHidden:F,search:B,dsFolders:k0.dsFolders,activeDsName:G,onOpenSystem:e0?K:void 0,onDelete:e0||J?void 0:O,dirtyByPath:f,canvasKinds:g,dirPath:k0.fullPath,drag:!e0&&k0.kind==="canvas"&&!J?n8:void 0,menu:C8,expansion:E}):z("div",{className:"st-tree-empty",children:B?"No matches.":"Empty."}))},k0.label)})}),z(zy,{state:C8.state,onClose:C8.close,rootItems:A0,destinations:S0,onPickDestination:(k0)=>l(w0.path,k0)}),z(AE,{project:m,liveBranch:c,remoteSync:o,onGetLatest:v,projectOnly:J8}),X===null?z(vw,{syncStatus:z0,onLinkedHub:i,onLocalProject:q0,onOpenFile:Z0,filesReady:C0}):null,z(mw,{})]})}function IL0({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(k9,{name:"panel-left",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:z(k9,{name:"search",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:X,children:z(k9,{name:"folder",size:15})})]})})}function kL0({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",ET]}),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 AT=[{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 TL0({kbd:J,alt:X}){let Q=(Y,W)=>z("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>z(RJ,{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 RL0({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=AT.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(RJ,{children:"?"})," to open"]})]}),z("div",{className:"so-columns",children:AT.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(TL0,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),D("div",{className:"so-overlay-ft",children:[D("span",{children:["close with ",z(RJ,{children:"Esc"})]}),D("span",{className:"so-count",children:[Q," bindings · ",AT.length," groups"]})]})]})})}var CL0=["File","Edit","View","Selection","Tools","Help"];function X70(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 $L0({panels:J,onToggle:X,onClose:Q,onZoom:Y,hasCanvas:W}){return X70(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(k9,{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(RJ,{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(RJ,{children:G.shortcut})]},G.label))]})}function J1({label:J,left:X,header:Q,items:Y,onAction:W,onClose:G}){return X70(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(RJ,{children:Z.shortcut}):null]},Z.id))]})}function SL0({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"},...H9()?[{id:"collab-tour",label:"How sharing works"}]:[],...H9()?[{id:"quick-setup",label:"Quick setup"}]:[],...H9()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function bL0({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 yL0({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 jL0({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 vL0({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 fL0({activePath:J,sharePath:X,onShare:Q,project:Y,cloud:W,tabsCount:G,openMenu:Z,setOpenMenu:H,commentsPanelOpen:K,onToggleComments:U,changesOpen:B,changesCount:N,onToggleChanges:V,onOpenSystem:F,sidebarOpen:M,onToggleSidebar:A,showHidden:E,onToggleShowHidden:w,onOpenHelp:O,onOpenShortcuts:P,onReportBug:T,onStartTour:R,onStartCollabTour:$,annotationsVisible:C,onToggleAnnotations:j,minimapVisible:f,onToggleMinimap:m,zoomCtlVisible:c,onToggleZoomCtl:o,presentMode:v,onTogglePresent:g,printGuidesVisible:l,onTogglePrintGuides:x,postToActiveCanvas:n,onOpenWhatsNew:e,onOpenReadiness:s,onOpenQuickSetup:H0,onWatchIntro:a,whatsNewCount:z0,exportCenter:i,artboardCount:q0=0,presence:Z0=null,inspectorOpen:C0,inspectorTab:a0,onToggleInspector:o0,autoOpenInspector:J8,onToggleAutoOpenInspector:P8,onOpenLayers:n8,timelineOpen:C8,onToggleTimeline:w8,hasComps:w0=!1,assistantOpen:A0,onToggleAssistant:S0,assistantBusy:q8,assistantUnseen:X8,onNewCanvas:k8,onAssembleVideo:x8,onOpenExport:N9,onOpenSettings:m0,onOpenGenerate:R8,onReload:z9,onCloseCanvas:N8,onInsertArtboard:B0,readOnly:t0=!1}){let s0=J===o8,p8=s0?"SYSTEM":J?"CANVAS":"IDLE",_8=s0?z("b",{children:"design system"}):J?D(Q0,{children:[J.split("/").slice(0,-1).join("/"),"/",z("b",{children:Y4(qQ(J))})]}):z("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),k0=new Set(W?["autoopen"]:["assistant","autoopen"]),b0=[{id:"tree",label:"Project Tree",shortcut:"T",checked:M,disabled:!1},{id:"changes",label:W?"History":N>0?`Changes · ${N} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:B,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:C0&&a0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:C0,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!J8,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:w0?"video":void 0,checked:C8,disabled:!1},...H9()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:A0,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:f,disabled:!J||s0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:c,disabled:!J||s0},{id:"present",label:"Presentation Mode",shortcut:"",checked:v,disabled:!J||s0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:l,disabled:!J||s0}].filter((P0)=>!t0||!k0.has(P0.id)),h0=["file","edit","view","selection","tools","help"];function O8(P0){if(h0.includes(P0))H(Z===P0?null:P0)}return u.useEffect(()=>{if(!Z||!h0.includes(Z))return;let P0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function e0(E8){let U0=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!U0.length)return;let n0=U0.indexOf(document.activeElement);if(E8.key==="ArrowDown")E8.preventDefault(),U0[(n0+1)%U0.length].focus();else if(E8.key==="ArrowUp")E8.preventDefault(),U0[(n0-1+U0.length)%U0.length].focus();else if(E8.key==="Home")E8.preventDefault(),U0[0].focus();else if(E8.key==="End")E8.preventDefault(),U0[U0.length-1].focus();else if(E8.key==="ArrowRight"||E8.key==="ArrowLeft"){E8.preventDefault();let D8=E8.key==="ArrowRight"?1:-1,e8=h0.indexOf(Z);H(h0[(e8+D8+h0.length)%h0.length])}else if(E8.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",e0),()=>{clearTimeout(P0),window.removeEventListener("keydown",e0)}},[Z,H]),D("header",{className:"st-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",role:"menubar","aria-label":"Application menus","data-tour":"menus",children:CL0.map((P0)=>{let e0=P0.toLowerCase(),E8=h0.includes(e0),U0=E8||e0==="help",n0=Z===e0;return z("button",{type:"button",className:"st-menu",role:"menuitem","data-testid":`menu-${e0}`,"data-tour":e0==="help"?"help":void 0,"aria-haspopup":E8?"menu":void 0,"aria-expanded":E8?n0:void 0,onClick:()=>O8(e0),onMouseEnter:()=>{if(Z!==null&&E8)H(e0)},children:P0},e0)})}),Z==="file"&&z(jL0,{readOnly:t0,hasCanvas:!!J,hasSharePath:!!X,onAction:(P0)=>{if(P0==="new")k8?.();else if(P0==="assemble")x8?.();else if(P0==="export")N9?.("export");else if(P0==="share")document.querySelector('[data-testid="menu-file"]')?.focus(),Q?.();else if(P0==="handoff")N9?.("handoff");else if(P0==="generate")R8?.();else if(P0==="settings")m0?.();else if(P0==="reload")z9?.();else if(P0==="close")N8?.()},onClose:()=>H(null)}),Z==="edit"&&z(vL0,{readOnly:t0,hasCanvas:!!J&&!s0,onAction:(P0)=>{if(P0==="undo")n({dgn:"undo"});else if(P0==="redo")n({dgn:"redo"});else if(P0==="deselect-all")n({dgn:"selection-clear"});else if(P0==="select-all-annotations")n({dgn:"annotation-select-all"});else if(P0.startsWith("new-artboard:"))B0?.(P0.slice(13))},onClose:()=>H(null)}),Z==="view"&&z($L0,{panels:b0,onToggle:(P0)=>{if(P0==="tree")A();else if(P0==="changes")V();else if(P0==="comments")U();else if(P0==="hidden")w();else if(P0==="annotate")j();else if(P0==="inspector")o0();else if(P0==="autoopen")P8?.();else if(P0==="timeline")w8?.();else if(P0==="assistant")S0?.();else if(P0==="layers")n8?.();else if(P0==="minimap")m?.();else if(P0==="zoomctl")o?.();else if(P0==="present")g?.();else if(P0==="print-guides")x?.()},onZoom:(P0)=>n({dgn:"zoom",op:P0}),hasCanvas:!!J&&!s0,onClose:()=>H(null)}),Z==="selection"&&z(bL0,{readOnly:t0,onAction:(P0)=>{if(P0==="deselect-all")n({dgn:"selection-clear"});else if(P0==="select-all-annotations")n({dgn:"annotation-select-all"})},onClose:()=>H(null)}),Z==="tools"&&z(yL0,{readOnly:t0,onAction:(P0)=>n({dgn:"tool-set",tool:P0}),onClose:()=>H(null)}),Z==="help"&&z(SL0,{onAction:(P0)=>{if(P0==="shortcuts")P?.();else if(P0==="help")O?.();else if(P0==="report-bug")T?.();else if(P0==="tour")R?.();else if(P0==="collab-tour")$?.();else if(P0==="quick-setup")H0?.();else if(P0==="readiness")s?.();else if(P0==="whatsnew")e?.();else if(P0==="watch-intro")a?.()},onClose:()=>H(null)}),D("div",{className:"st-mb-right","data-tour":"status",children:[Z0?z("div",{className:"st-presence",children:Z0}):null,t0&&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,H9()&&!t0&&z("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":A0?"true":"false","data-busy":q8?"true":"false","data-unseen":X8?"true":"false","aria-label":`Assistant${q8?" — working":X8?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:S0,children:z(k9,{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(k9,{name:"share",size:15})}),i&&z(hm,{center:i}),z("button",{type:"button",className:"st-reportbug","data-testid":"report-bug-toggle","aria-label":"Report a bug","data-tip":"Report a bug",onClick:T,children:z(k9,{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(k9,{name:"megaphone",size:15})}),z("span",{className:"st-stamp",children:p8}),z("span",{className:"st-mb-file",title:J||"",children:_8}),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 xL0({tabs:J,activePath:X,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:K,onIframeLoad:U,canvasError:B,canvasReloadNonce:N,onRetryCanvasLoad:V,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),P=new Set(J.map(($)=>$.path));for(let[$,C]of O.current)if(!P.has(C.path))O.current.delete($);let T=($)=>{let C=IZ($,{...H,canvasToken:void 0}),j=`${$}#${N}|${C}`,f=O.current.get(j);if(!f)f={path:$,src:IZ($,H)},O.current.set(j,f);return f.src},R=B&&B.path===X?"error":X&&X!==o8&&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: ${_K(qQ(E))}`,tabIndex:0,children:z(ng,{path:E,kind:PL(qQ(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",ET," / 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(RJ,{children:"⌘"})," and hover to preview an element, click to select it — ",z(RJ,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",H9()?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===o8)return z("div",{className:"system-view"+($.path===X?" active":""),children:z(iL0,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},$.path);return z("iframe",{ref:(C)=>Q($.path,C),src:T($.path),title:`Canvas: ${$.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}#${N}`)}),K&&K===X&&z(hL0,{path:K,cloud:!!H?.cloud},K),B&&B.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:B.kind==="server"?"Maude's server isn't responding":"This canvas didn't finish loading"}),z("div",{className:"st-canvas-error-body",children:B.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:_K(qQ(B.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:()=>V?.(B.path),children:"Reload canvas"})]})})]})}function hL0({path:J,cloud:X}){let[Q,Y]=u.useState(!1);u.useEffect(()=>{let G=setTimeout(()=>Y(!0),4000);return()=>clearTimeout(G)},[]);let W=_K(qQ(J||"").replace(/\.(tsx|jsx|html?)$/i,""));return z("div",{className:"st-canvas-loading",role:"status","aria-live":"polite","data-testid":"canvas-loading",children:D("div",{className:"st-skel-card",children:[D("div",{className:"st-canvas-loading-head",children:[z("span",{className:"st-canvas-loading-spinner","aria-hidden":"true"}),D("span",{className:"st-canvas-loading-title",children:["Opening ",W,"…"]})]}),z("span",{className:"skel st-skel-thumb","aria-hidden":"true"}),z("span",{className:"skel st-skel-line",style:{width:"72%"},"aria-hidden":"true"}),z("span",{className:"skel st-skel-line",style:{width:"46%"},"aria-hidden":"true"}),z("div",{className:"st-canvas-loading-hint"+(Q?" is-shown":""),children:X?"Still working — the first open of a canvas fetches its images and fonts from cloud storage. It is quicker next time.":"Still working — large canvases take a moment to build."})]})})}var gL0=["color","space","radius","shadow","leading","weight","motion","font","other"],mL0={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function uL0(J){return J==="color"}function pL0({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([...gL0,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return z(Q0,{children:W.map((G)=>{let Z=Y[G],H=uL0(G);return D("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[D("h2",{children:["tokens · ",mL0[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 lL0(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 dL0(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 cL0({tokenGroups:J}){let X=J?.fontsize||[];if(X.length===0)return null;let Q=J?.leading||[],Y=dL0(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=lL0(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 iL0({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:B,availableDesignSystems:N}=J,V=(!W||!W.length)&&(!G||!G.length),F=Array.isArray(N)&&N.length>1,M=B?.name??N?.[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:N.map((A)=>z("option",{value:A.name,children:A.name},A.name))})]}):null,z("span",{className:"sv-loc",children:z("code",{children:Z})})]}),B?.description?z("p",{className:"sv-ds-description",children:B.description}):null,z(pL0,{tokens:H,tokenGroups:K,tokensPath:U}),z(cL0,{tokenGroups:K}),V?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(v90,{title:"preview",items:W,onOpen:X,kind:"preview",cfg:Q}),z(v90,{title:"ui kits",items:G,onOpen:X,kind:"ui_kits",cfg:Q})]})]})}function v90({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:IZ(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 oL0({activePath:J,selected:X,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,syncProject:K,syncOpen:U=!1,onOpenSync:B,changesCount:N=0,unpushed:V=0,savingIsManaged:F=!1,changesOpen:M=!1,onOpenChanges:A,version:E}){let w=J===o8,O=X&&X.selector?X.selector+(X.text?` — "${X.text.slice(0,60)}"`:""):"",P=X&&X.dom_path?X.dom_path.join(" > "):X?X.selector:"",T=W==="dark"?"light":"dark",R=(()=>{let C=lz(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:P,children:O}),z("button",{type:"button",className:"st-sb-sel-clear",onClick:Z,"data-tip":"Clear · Esc inside iframe","data-tip-pos":"top","aria-label":"Clear selection",children:"×"})]}),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":"")+(N>0?" has-changes":V>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":N>0?`${N} unsaved`:V>0?`${V} 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&&(B?z("button",{type:"button",className:"st-sb-slot st-sb-sync st-sb-sync--btn"+(U?" is-open":""),onClick:B,"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 ${T} theme`,"data-tip-pos":"top","aria-label":`Switch to ${T} theme`,children:[z(k9,{name:W==="dark"?"sun":"moon",size:13}),T]})]})}function nL0({commentsByFile:J,filter:X,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:K,width:U,resizing:B}){let N=e90(J),V=Object.keys(J||{}).sort(),F=[];for(let M of V){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((P)=>P.id===O.id)+1}))})}return D("aside",{className:"st-rpanel"+(B?" 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 · ",N.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 · ",N.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 · ",N.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(RJ,{children:"⌘"})," and click an element, then press ",z(RJ,{children:"C"})," — or hold ",z(RJ,{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:Y4(qQ(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:HL0(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(k9,{name:"reopen",size:14})}):z("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(E)=>{E.stopPropagation(),Z(A.id)},children:z(k9,{name:"resolve",size:14})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(E)=>{E.stopPropagation(),K(A.id)},children:z(k9,{name:"x",size:14})})]}):null]})]},A.id))]},M.file))})]})}var rL0={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 aL0({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=rL0[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 sL0({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),jh().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X,children:"Later"})]})}function tL0({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,B=Array.isArray(Z)?[...Z].reverse().find((M)=>M.kind==="cold-start-diverged"):null;if(!K&&!H&&!B&&U===0)return null;let N,V,F;if(H)N="success",V="Synced with hub",F=`${Y}:flash`;else if(K){let M=Z&&Z.length>0?` (${Z.length} conflict notice(s))`:"";if(Y==="offline-long")N="error",V=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${M}`;else N="warn",V=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${M}`;F=`${Y}:offline`}else if(B){if(B.snapshotFailed)N="error",V=`Diverged on ${B.slug}: kept local — the history snapshot FAILED, so the overwrite was refused. Check disk space / .design/_history write access.`;else N="warn",V=`Diverged on ${B.slug}: kept the ${B.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${B.slug}`;F=`diverged:${B.slug}:${B.at}`}else N="warn",V=`${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--${N}`,children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:V}),z("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(F),children:"×"})]})}var eL0=["block","inline-block","flex","inline-flex","grid","inline","none"],f90=["px","%","fr","em","auto","min-content","max-content"];var JD0=["auto","stretch","flex-start","center","flex-end","baseline"];var x90=["300","400","500","600","700","800"],Mq=(J,X)=>J&&Object.hasOwn(J,"previous")?J.previous:X,h90=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],g90=["none","solid","dashed","dotted","double"],m90=["px","rem","em","%","vw","vh","auto"],u90=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),_T={"font-size":{node:z(V7,{as:mV,size:12})},"line-height":{node:z(V7,{as:oV,size:12})},"letter-spacing":{node:z(V7,{as:Q3,size:12})},gap:{node:z(V7,{as:EK,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:z(V7,{as:H3,size:12})},"border-width":{node:z(V7,{as:X3,size:12})}};var p90=["static","relative","absolute","fixed","sticky"],XD0=["normal","italic","oblique"],l90=["none","uppercase","lowercase","capitalize"];var d90=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],QD0=["fill","contain","cover","none","scale-down"];var c90=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],i90=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],$5={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}},sK=null;function EL(J){if(!J)return"";if(/^#[0-9a-f]{6}$/i.test(J))return J.toLowerCase();try{if(!sK)sK=document.createElement("canvas").getContext("2d");if(!sK)return"";sK.fillStyle="#000000",sK.fillStyle=J;let X=sK.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 NY=(J)=>Math.min(1,Math.max(0,J));function LL(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 Oq({r:J,g:X,b:Q}){return`#${[J,X,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function Aq({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 tK({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 N7(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 o90(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 Q70(J,X){return(J?X?.canvasDesignSystems?.[J]:null)||X?.defaultDesignSystem||X?.designSystems?.[0]?.name||null}function YD0(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 Y70(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}`),B=U.ok?await U.text():"";return{name:K.name,...YD0(B)}}catch{return null}})).then((K)=>{if(H)return;let U=K.filter(Boolean);U.sort((B,N)=>B.name===Q?-1:N.name===Q?1:0),Z(U)}),()=>{H=!0}},[W,X,Q]),G}function W70({seed:J,label:X,onApply:Q}){let[Y,W]=u.useState(()=>Aq(LL(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(Aq(LL(J)))},[J]);let U=Oq(tK(Y)),B=(O)=>{O.preventDefault();let P=Z.current?.getBoundingClientRect();if(!P)return;let T=G.current.h,R=(C)=>{W({h:T,s:NY((C.clientX-P.left)/P.width),v:NY(1-(C.clientY-P.top)/P.height)})};R(O);let $=()=>{document.removeEventListener("pointermove",R),document.removeEventListener("pointerup",$),Q(Oq(tK(G.current)))};document.addEventListener("pointermove",R),document.addEventListener("pointerup",$)},N=(O)=>{O.preventDefault();let P=H.current?.getBoundingClientRect();if(!P)return;let{s:T,v:R}=G.current,$=(j)=>{W({h:NY((j.clientX-P.left)/P.width)*360,s:T,v:R})};$(O);let C=()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",C),Q(Oq(tK(G.current)))};document.addEventListener("pointermove",$),document.addEventListener("pointerup",C)},V=(O)=>{let P={...G.current,...O};W(P),Q(Oq(tK(P)))},F=(O)=>{let P=O.shiftKey?0.1:0.02,R={ArrowLeft:[-P,0],ArrowRight:[P,0],ArrowUp:[0,P],ArrowDown:[0,-P]}[O.key];if(!R)return;O.preventDefault(),V({s:NY(G.current.s+R[0]),v:NY(G.current.v+R[1])})},M=(O)=>{let P=O.shiftKey?20:2,R={ArrowLeft:-P,ArrowRight:P}[O.key];if(R==null)return;O.preventDefault(),V({h:Math.min(360,Math.max(0,G.current.h+R))})},A=async()=>{try{let O=window.EyeDropper;if(!O)return;let P=await new O().open();if(P?.sRGBHex)W(Aq(LL(P.sRGBHex))),Q(P.sRGBHex)}catch{}},E=tK(Y),w=(O)=>{let P={...E,...O},T=Aq({r:NY(P.r/255)*255,g:NY(P.g/255)*255,b:NY(P.b/255)*255});W(T),Q(Oq(tK(T)))};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 P=O.target.value;if(/^#?[0-9a-f]{6}$/i.test(P))W(Aq(LL(P)))},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:B,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(k9,{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:N,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:(P)=>w({[O]:NY((Number.parseFloat(P.target.value)||0)/255)*255}),onFocus:(P)=>P.currentTarget.select()}),z("span",{children:O.toUpperCase()})]},O))})]})}function OL({kind:J,groups:X,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:K}){let[U,B]=u.useState(!1),[N,V]=u.useState(null),[F,M]=u.useState("custom"),[A,E]=u.useState(""),w=u.useRef(null),O=u.useRef(null),P=typeof Q==="string"&&/var\(\s*--/.test(Q),T=(e)=>Q===`var(${e})`,R=(e)=>e.replace(/^--/,"").replace(/-/g," "),$=X||[],C=$.reduce((e,s)=>e+(s.names?.length||0),0),j=$.length>1,f=A.trim().toLowerCase(),m=!f?$:$.map((e)=>({...e,names:(e.names||[]).filter((s)=>R(s).toLowerCase().includes(f)||s.toLowerCase().includes(f)||(e.vals?.[s]||"").toLowerCase().includes(f))})).filter((e)=>e.names.length);u.useEffect(()=>{if(!U){E("");return}let e=()=>{let z0=w.current?.getBoundingClientRect();if(!z0)return;let i=224,q0=300,Z0=Math.min(z0.right-i,window.innerWidth-i-8);if(Z0<8)Z0=8;let a0=window.innerHeight-z0.bottom>q0+8?z0.bottom+4:Math.max(8,z0.top-q0-4);V({left:Z0,top:a0,width:i,maxHeight:q0})};e();let s=(z0)=>{if(O.current?.contains(z0.target)||w.current?.contains(z0.target))return;B(!1)},H0=(z0)=>{if(z0.key==="Escape")B(!1)},a=(z0)=>{if(O.current?.contains(z0.target))return;e()};return document.addEventListener("pointerdown",s,!0),document.addEventListener("keydown",H0),window.addEventListener("resize",e),document.addEventListener("scroll",a,!0),()=>{document.removeEventListener("pointerdown",s,!0),document.removeEventListener("keydown",H0),window.removeEventListener("resize",e),document.removeEventListener("scroll",a,!0)}},[U]),u.useEffect(()=>{if(!U||!N||!O.current)return;let e=O.current.getBoundingClientRect(),s=N.left-e.left,H0=N.top-e.top;if(Math.abs(s)>0.5||Math.abs(H0)>0.5)V((a)=>a?{...a,left:a.left+s,top:a.top+H0}:a)},[U,N]);let c=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,o=(e,s,H0)=>{if(H&&e&&e!==H&&H0&&!c.test(H0))Y(H0);else Y(`var(${s})`);B(!1)},v=(e)=>{let s=(e||"").trim();if(s)Y(s)},g=D("div",{className:"st-cp-pop-search",children:[z(k9,{name:"search",size:12}),z("input",{value:A,onChange:(e)=>E(e.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),l=(e)=>e.map((s)=>D("div",{className:"st-cp-pop-group",children:[j?z("div",{className:"st-cp-pop-ds",children:s.ds}):null,z("div",{className:"st-cp-pop-list",children:s.names.map((H0)=>D("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${T(H0)?" is-on":""}`,onClick:()=>o(s.ds,H0,s.vals?.[H0]),children:[z("span",{className:"st-cp-pop-cswatch",style:{background:s.vals?.[H0]||"transparent"},"aria-hidden":"true"}),z("span",{className:"st-cp-pop-name",children:R(H0)}),z("span",{className:"st-cp-pop-val",children:s.vals?.[H0]||""})]},`${s.ds}:${H0}`))})]},s.ds)),x=(e)=>e.map((s)=>D("div",{className:"st-cp-pop-group",children:[j?z("div",{className:"st-cp-pop-ds",children:s.ds}):null,z("div",{className:"st-cp-pop-list",children:s.names.map((H0)=>D("button",{type:"button",className:`st-cp-pop-row${T(H0)?" is-on":""}`,onClick:()=>o(s.ds,H0,s.vals?.[H0]),children:[z("span",{className:"st-cp-pop-name",children:R(H0)}),z("span",{className:"st-cp-pop-val",children:s.vals?.[H0]||""})]},`${s.ds}:${H0}`))})]},s.ds)),n=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"}${P&&!K?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>B((e)=>!e),children:z("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):z("button",{type:"button",ref:w,className:`st-cp-tokbtn${P?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>B((e)=>!e),children:z("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),U&&N?r90.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:N.left,top:N.top,width:N.width,maxHeight:N.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(W70,{seed:Z||EL(Q)||"#000000",onApply:v}):!C?z("div",{className:"st-cp-pop-empty",children:"No color tokens"}):D(Q0,{children:[g,m.length?l(m):n]})]}):!C?z("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):D(Q0,{children:[g,m.length?x(m):n]})}),document.body):null]})}function n90({label:J,tracks:X,editable:Q,onChange:Y}){let W=(K,U)=>{let B=X[K];Y(X.map((N,V)=>V===K?xU.has(U)?{value:0,unit:U}:{value:B.value||1,unit:U}:N))},G=(K,U)=>{Y(X.map((B,N)=>N===K?{...B,value:U}:B))},Z=()=>Y([...X,{value:1,unit:"fr"}]),H=(K)=>Y(X.filter((U,B)=>B!==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 B=xU.has(K.unit);return D("div",{className:"st-cp-gridtrack-row",children:[B?z(JG,{value:K.unit,ariaLabel:`${J} track ${U+1}`,options:f90.map((N)=>({value:N,label:N})),onChange:(N)=>W(U,N)}):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(aN,{value:K.unit,units:f90,ariaLabel:`${J} track ${U+1} unit`,onChange:(N)=>W(U,N)}),onCommit:(N)=>G(U,N)}),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)})]})}var eK={pending:0,waiters:[]};function G70(J){eK.pending+=1;let X=()=>{if(eK.pending-=1,eK.pending===0)for(let Q of eK.waiters.splice(0))Q()};return J.then(X,X),J}function WD0(){return eK.pending===0?Promise.resolve():new Promise((J)=>eK.waiters.push(J))}function GD0({el:J,cfg:X,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let K=!!J.id,U=J.computed||{},[B,N]=u.useState({a:{},c:{},t:{}});u.useEffect(()=>{N({a:{},c:{},t:{}})},[J.id,J.authored,J.customStyles,J.attrs]);let V=(t,M0)=>{let _0={...t||{}};for(let[u0,Q8]of Object.entries(M0))if(Q8===null)delete _0[u0];else _0[u0]=Q8;return _0},F=V(J.authored,B.a),M=V(J.customStyles,B.c),A=V(J.attrs,B.t),E=(t,M0)=>N((_0)=>({..._0,a:{..._0.a,[t]:M0}})),w=(t,M0)=>N((_0)=>({..._0,c:{..._0.c,[t]:M0}})),O=(t,M0)=>N((_0)=>({..._0,t:{..._0.t,[t]:M0}})),P=(X?.designRel||X?.designRoot||".design").replace(/^\/+|\/+$/g,""),T=Q70(J.file,X),R=Y70(X,P,T),$=(t)=>R.map((M0)=>({ds:M0.name,names:M0[t]||[],vals:M0.vals})).filter((M0)=>M0.names.length),[C,j]=u.useState({}),[f,m]=u.useState({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),c=Object.keys(M).length>0||Object.keys(A).length>0;u.useEffect(()=>{if(c)m((t)=>t.Advanced?t:{...t,Advanced:!0})},[J.id,c]);let o=(F.position||N7(U.position)||"static")!=="static";u.useEffect(()=>{if(o)m((t)=>t["d:Position"]?t:{...t,"d:Position":!0})},[J.id,o]);let v=H,[g,l]=u.useState({});async function x(t,M0,_0){j((u0)=>({...u0,[_0]:"saving"}));try{let u0=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(M0)}),Q8=await u0.json().catch(()=>({}));return j((a8)=>({...a8,[_0]:!u0.ok||!Q8.ok?`err:${Q8&&Q8.error||`HTTP ${u0.status}`}`:"saved"})),u0.ok?Q8:null}catch(u0){return j((Q8)=>({...Q8,[_0]:`err:${u0&&u0.message?u0.message:String(u0)}`})),null}}let n=u.useRef(Promise.resolve()),e=(t,M0,_0,u0,Q8,a8,j8)=>{n.current=G70(n.current.then(async()=>{let S8=await x(t,M0,_0);if(!S8?.ok)return;let G9=Object.hasOwn(S8,"previous")?S8.previous:a8;if((G9??null)===(j8??null))return;H0(u0,Q8,G9,j8)}))},s=(t,M0)=>{if(!Q||!J.id)return;Q({id:J.id,artboardId:J.artboardId??null,index:J.index??0,prop:t,value:M0})},H0=(t,M0,_0,u0)=>{Y?.({op:t,canvas:J.file,id:J.id,key:M0,before:_0==null||_0===""?null:_0,after:u0==null||u0===""?null:u0})},a=(t,M0)=>{let _0=(M0||"").trim();if(!K||!_0)return;let u0=F[t]??null;if(_0===(u0??"").trim())return;s(t,_0),E(t,_0),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,value:_0},t,"css",t,u0,_0)},z0=(t,M0)=>{let _0=(M0||"").trim(),u0=t.trim();if(!K||!u0||!_0)return;let Q8=M[u0]??null;s(u0,_0),w(u0,_0),e("/_api/edit-css",{canvas:J.file,id:J.id,property:u0,value:_0},u0,"css",u0,Q8,_0)},i=(t,M0)=>{let _0=(t||"").trim(),u0=(M0||"").trim();if(!K||!_0||!u0)return;let Q8=A[_0]??null;O(_0,u0),e("/_api/edit-attr",{canvas:J.file,id:J.id,attr:_0,value:u0},`@${_0}`,"attr",_0,Q8,u0)},q0=(t)=>{if(!K)return;let M0=F[t]??null;s(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;s(t,null),w(t,null),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,reset:!0},t,"css",t,M0,null)},C0=(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},o0=(t,M0)=>{if(!K)return;let _0=Math.round((t==="width"?J.bounds?.w:J.bounds?.h)||0),u0=tb(t,M0,a0,_0);for(let Q8 of u0.reset)if(F[Q8])q0(Q8);for(let[Q8,a8]of u0.set)a(Q8,a8)},J8=J.parentDisplay==="flex"||J.parentDisplay==="inline-flex",P8=(t)=>{let M0=sb(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(sN,{value:M0,ariaLabel:`${t} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(_0)=>o0(t,_0)})})]},`mode-${t}`)},n8=["flex-start","center","flex-end"],C8=["flex-start","center","flex-end"],w8=["t","c","b"],w0=["l","c","r"],A0=()=>{let t=!(F["flex-direction"]||N7(U["flex-direction"])||"row").startsWith("column"),M0=Math.max(0,n8.indexOf(F["justify-content"]||N7(U["justify-content"])||"flex-start")),_0=F["align-items"]||N7(U["align-items"])||"stretch",u0=_0==="stretch"?1:Math.max(0,C8.indexOf(_0)),[Q8,a8]=t?[M0,u0]:[u0,M0];return w8[a8]+w0[Q8]},S0=(t)=>{let M0=w8.indexOf(t[0]),_0=w0.indexOf(t[1]),u0=!(F["flex-direction"]||N7(U["flex-direction"])||"row").startsWith("column"),[Q8,a8]=u0?[_0,M0]:[M0,_0];a("justify-content",n8[Q8]),a("align-items",C8[a8])},q8=(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")},X8=(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 k8={bound:"token-bound",raw:"raw override",inherit:"inherited"},x8=(t)=>z("span",{className:`st-cp-prov st-cp-prov--${t}`,role:"img","aria-label":k8[t]}),N9=(t,M0)=>{let _0=M0??X8(t),u0=C[t],Q8=typeof u0==="string"&&u0.startsWith("err:")?u0.slice(4):"",a8=Q8?" is-err":u0==="saved"?" is-saved":u0==="saving"?" is-saving":"",j8=!!F[t],S8=Q8?`error: ${Q8}`:j8?`${k8[_0]} · double-click to reset`:k8[_0];return z("button",{type:"button",className:`st-cp-prov st-cp-prov--${_0}${a8}${j8?" is-resettable":""}`,"aria-label":S8,title:S8,tabIndex:j8?0:-1,onDoubleClick:j8?()=>q0(t):void 0,onKeyDown:j8?(G9)=>{if(G9.key==="Backspace"||G9.key==="Delete")G9.preventDefault(),q0(t)}:void 0})},m0=(t,M0,_0,u0)=>{let Q8=_0===void 0&&!F[t],a8=u0??t;return D("div",{className:`st-cp-row${Q8?" is-unset":""}`,children:[N9(t,_0),z("label",{className:"st-cp-label",title:a8,children:a8}),z("div",{className:"st-cp-ctl",children:M0})]},t)},R8={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"]},z9=(t)=>{(R8[t]||[]).forEach((M0)=>{if(F[M0])q0(M0)})},N8=(t,M0)=>{let _0=(R8[t]||[]).some((u0)=>F[u0]);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":!!f[t],onClick:()=>m((u0)=>({...u0,[t]:!u0[t]})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:f[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:()=>z9(t),children:z(V7,{as:rZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${f[t]?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:M0})})]},t)},B0=(t,M0,_0,u0=!0)=>{let Q8=`d:${t}`,a8=f[Q8]===void 0?u0:f[Q8],j8=M0.some((S8)=>F[S8]);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":a8,onClick:()=>m((S8)=>({...S8,[Q8]:!a8})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:a8?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${j8?"":" is-quiet"}`,"aria-label":`reset ${t} to original`,title:`reset ${t}`,disabled:!j8,onClick:()=>M0.forEach((S8)=>{if(F[S8])q0(S8)}),children:z(V7,{as:rZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${a8?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:_0})})]},Q8)},t0=(t)=>z("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!g[t],"aria-label":g[t]?`${t} — fewer options`:`${t} — more options`,title:g[t]?"fewer":"more",onClick:()=>l((M0)=>({...M0,[t]:!M0[t]})),children:g[t]?"▴":"···"}),s0=(t,M0)=>D("select",{className:"st-cp-nsel","aria-label":t,value:M0.includes(F[t])?F[t]:"",onChange:(_0)=>a(t,_0.target.value),children:[z("option",{value:"",disabled:!0,children:N7(U[t])||"—"}),M0.map((_0)=>z("option",{value:_0,children:_0},_0))]}),p8=(t)=>$(t).flatMap((M0)=>(M0.names||[]).map((_0)=>({name:_0,value:M0.vals?.[_0]||""}))),_8=(t,M0)=>z(JE,{value:F[t]||N7(U[t])||M0[0].value,ariaLabel:t,options:M0,onChange:(_0)=>a(t,_0)}),k0=(t,M0,_0={})=>{let u0=Q4(F[t]??""),Q8=u90.has(t),a8=F[t]??"",j8=typeof a8==="string"&&/var\(\s*--/.test(a8),S8=Q8?"":u0.unit&&u0.unit!=="auto"?u0.unit:"px",G9=Number.parseFloat(Q4(N7(U[t])??"").n)||0,y9=u0.n!==""&&u0.n!=null?Number.parseFloat(u0.n)||0:G9,t9=_T[t];return z(tN,{value:j8?a8:y9,tokens:p8(M0),ariaLabel:t,min:_0.min??0,lead:t9?t9.node??t9.t:void 0,unitSlot:Q8?null:z(aN,{units:m90,value:u0.unit||"px",ariaLabel:`${t} unit`,onChange:(q7)=>a(t,q7==="auto"?"auto":`${u0.n||"0"}${q7}`)}),onChange:(q7)=>a(t,typeof q7==="string"?q7:Q8?`${q7}`:`${q7}${S8}`)})},b0=()=>{let t=(Q8)=>Number.parseFloat(Q4(F[Q8]??F["border-radius"]??N7(U[Q8])??N7(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=(Q8)=>{if(Q8.tl===Q8.tr&&Q8.tr===Q8.bl&&Q8.bl===Q8.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((j8)=>{if(F[j8])q0(j8)}),a("border-radius",`${Q8.tl}px`);else a("border-top-left-radius",`${Q8.tl}px`),a("border-top-right-radius",`${Q8.tr}px`),a("border-bottom-left-radius",`${Q8.bl}px`),a("border-bottom-right-radius",`${Q8.br}px`)},u0=_T["border-radius"];return z(Wm,{corners:M0,lead:u0?u0.node??u0.t:void 0,onCorners:_0})},h0=()=>D("div",{className:"st-cp-border",children:[Y9("border-width",null,{fixedUnit:"px"}),D("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:g90.includes(F["border-style"])?F["border-style"]:"",onChange:(t)=>a("border-style",t.target.value),children:[z("option",{value:"",disabled:!0,children:"style"}),g90.map((t)=>z("option",{value:t,children:t},t))]}),z(OL,{kind:"color",groups:$("color"),current:F["border-color"],activeDs:T,swatchBg:U["border-color"]||F["border-color"]||"",seedHex:EL(U["border-color"]||F["border-color"])||"#000000",onPick:(t)=>a("border-color",t),label:"border colour"})]}),O8=()=>{let t=F.transform||N7(U.transform)||"",M0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(t),_0=((M0?Number.parseFloat(M0[1]):0)%360+360)%360,u0=(Q8)=>{let a8=(Q8%360+360)%360,j8=(F.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();a("transform",`${j8?`${j8} `:""}rotate(${a8}deg)`.trim())};return D("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[z(Qm,{value:_0,onChange:u0}),z(ZJ,{value:_0,min:0,max:360,ariaLabel:"rotation",lead:z(V7,{as:rZ}),steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:u0})]})},P0=()=>{let t=F.filter||N7(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:(Q8)=>{let a8=(F.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();a("filter",Q8>0?`${a8?`${a8} `:""}blur(${Q8}px)`.trim():a8||"none")}})},e0=()=>{let t=F.opacity,M0=t!=null&&t!==""?Number.parseFloat(t):Number.parseFloat(N7(U.opacity))||1,_0=Math.round((Number.isNaN(M0)?1:M0)*100);return z(xX,{value:_0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(u0)=>s("opacity",String(u0/100)),onCommit:(u0)=>a("opacity",String(u0/100))},`opacity:${t??""}`)},E8=()=>{let t=Number.parseInt(F["font-weight"]||N7(U["font-weight"])||"400",10)>=600,M0=(F["font-style"]||N7(U["font-style"]))==="italic",_0=/underline/.test(F["text-decoration"]||N7(U["text-decoration"])||"");return z(Jm,{value:{b:t,i:M0,u:_0},ariaLabel:"text style",options:[{value:"b",node:z(V7,{as:nV}),label:"Bold"},{value:"i",node:z(V7,{as:eV}),label:"Italic"},{value:"u",node:z(V7,{as:U3}),label:"Underline"}],onToggle:(u0)=>{if(u0==="b")a("font-weight",t?"400":"700");else if(u0==="i")a("font-style",M0?"normal":"italic");else a("text-decoration",_0?"none":"underline")}})},U0=[{value:"row",node:z(V7,{as:dW}),label:"Row"},{value:"column",node:z(V7,{as:cW}),label:"Column"}],n0=[{value:"flex-start",node:z(V7,{as:lV}),label:"Start"},{value:"center",node:z(V7,{as:uV}),label:"Center"},{value:"flex-end",node:z(V7,{as:pV}),label:"End"},{value:"space-between",node:z(V7,{as:EK}),label:"Space between"}],D8=[{value:"flex-start",node:z(V7,{as:iV}),label:"Start"},{value:"center",node:z(V7,{as:dV}),label:"Center"},{value:"flex-end",node:z(V7,{as:cV}),label:"End"},{value:"stretch",node:z(V7,{as:z3}),label:"Stretch"}],e8=[{value:"left",node:z(V7,{as:i5}),label:"Left"},{value:"center",node:z(V7,{as:nW}),label:"Center"},{value:"right",node:z(V7,{as:rW}),label:"Right"},{value:"justify",node:z(V7,{as:aW}),label:"Justify"}],L9=[{value:"visible",node:z(V7,{as:nZ}),label:"Visible"},{value:"hidden",node:z(V7,{as:aZ}),label:"Hidden"},{value:"scroll",node:z(V7,{as:G3}),label:"Scroll"}],l7=(t,M0)=>{let _0=$(M0);return _0.length?z(OL,{kind:"value",groups:_0,current:F[t],activeDs:T,onPick:(u0)=>a(t,u0),label:`${t} design token`}):null},i0=(t)=>{let M0=t.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===M0)M0.select()})},t7=(t,M0)=>{if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return!1;t.preventDefault();let _0=t.shiftKey?10:1,u0=t.key==="ArrowUp"?1:-1,Q8=(Number.parseFloat(t.currentTarget.value)||0)+u0*_0;return t.currentTarget.value=String(Q8),M0(Q8),!0},$8=(t)=>z("input",{className:"st-cp-fin","aria-label":t,defaultValue:F[t]??"",placeholder:N7(U[t])||"—",onFocus:i0,onKeyDown:(M0)=>{if(M0.key==="Enter")M0.currentTarget.blur()},onBlur:(M0)=>a(t,M0.currentTarget.value)},`${t}:${F[t]??""}`),Y9=(t,M0,_0={})=>{let u0=Q4(F[t]??""),Q8=u90.has(t),a8=Q8?"":_0.fixedUnit||(u0.unit&&u0.unit!=="auto"?u0.unit:"px"),j8=_T[t],S8=Number.parseFloat(Q4(N7(U[t])??"").n)||0,G9=u0.n!==""&&u0.n!=null?Number.parseFloat(u0.n)||0:S8;return D(Q0,{children:[z(ZJ,{value:G9,min:_0.min??0,step:1,ariaLabel:t,lead:j8?j8.node??j8.t:void 0,onCommit:(y9)=>a(t,Q8?`${y9}`:`${y9}${a8}`),unitSlot:Q8||_0.fixedUnit?null:z(aN,{units:m90,value:u0.unit||"px",ariaLabel:`${t} unit`,onChange:(y9)=>a(t,y9==="auto"?"auto":`${u0.n||"0"}${y9}`)})},`${t}:${F[t]??""}`),l7(t,M0)]})},c8=(t)=>{let M0=U[t]||F[t]||"",_0=F[t]??"",u0=typeof _0==="string"&&/var\(\s*--/.test(_0),Q8=u0?_0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):_0;return z(q3,{swatch:z(OL,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:$("color"),current:F[t],activeDs:T,swatchBg:M0,seedHex:EL(U[t]||F[t])||"#000000",onPick:(a8)=>a(t,a8),label:`${t} colour`}),displayValue:Q8,bound:u0,ariaLabel:t,onValue:(a8)=>a(t,a8)})},E0=(t,M0)=>{let _0=null,u0=M0.unitless?"":"px",Q8=(S8)=>M0.unitless?`${S8}`:`${S8}${u0}`,a8=(S8,G9,y9)=>{for(let t9 of G9??[t])y9(t9,Q8(S8))},j8=ew({getBase:()=>_0?.value??"0",min:M0.min??0,step:1,sides:M0.sides,onInput:(S8,G9)=>{if(_0)_0.value=String(S8);if(G9){let y9=_0?.closest(".st-cp-box");for(let t9 of G9){if(t9===t)continue;let q7=y9?.querySelector(`.st-cp-boxv[aria-label="${t9}"]`);if(q7)q7.value=String(S8)}}a8(S8,G9,s)},onCommit:(S8,G9)=>a8(S8,G9,a)});return{onPointerDown:(S8)=>{_0=S8.currentTarget,j8(S8)}}},V8=(t,M0)=>{let _0=F[t],u0=_0!=null&&_0!==""?Q4(_0).n||_0:Q4(N7(U[t])??"").n||"0",Q8=!_0||_0==="0"||_0==="0px"||_0==="auto",a8=t.split("-").pop(),j8=a8==="top"||a8==="bottom"?[`${M0}-top`,`${M0}-bottom`]:[`${M0}-left`,`${M0}-right`],S8=[`${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]}${Q8?" is-zero":""}`,"aria-label":t,defaultValue:u0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...E0(t,{sides:{pair:j8,all:S8}}),onFocus:i0,onKeyDown:(G9)=>{if(t7(G9,(y9)=>a(t,`${y9}px`)))return;if(G9.key==="Enter")G9.currentTarget.blur()},onBlur:(G9)=>{let y9=G9.currentTarget.value.trim();if(!y9)return;let t9=/[a-z%]/i.test(y9)?y9:`${y9}px`;a(t,t9)}},`${t}:${_0??""}`)},f8=(t)=>{let M0=F[t],_0=M0!=null&&M0!==""&&M0!=="auto"?Q4(M0).n||M0:Q4(N7(U[t])??"").n||"",u0=!M0||M0==="auto"||M0==="0"||M0==="0px",Q8=t==="top"||t==="bottom"?["top","bottom"]:["left","right"],a8=["top","right","bottom","left"];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${t[0]}${u0?" is-zero":""}`,"aria-label":t,defaultValue:_0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...E0(t,{sides:{pair:Q8,all:a8},min:-1/0}),onFocus:i0,onKeyDown:(j8)=>{if(t7(j8,(S8)=>a(t,`${S8}px`)))return;if(j8.key==="Enter")j8.currentTarget.blur()},onBlur:(j8)=>{let S8=j8.currentTarget.value.trim();if(!S8)return;let G9=/[a-z%]/i.test(S8)?S8:`${S8}px`;a(t,G9)}},`${t}:${M0??""}`)},r8=Object.entries(M),x9=Object.entries(A),b9=()=>{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"],u0=(t==="img"||t==="video")&&!!J.attrs?.src&&!!W;return{showMedia:_0,canReplace:u0}},s9=(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…"})}),m0("object-fit",s0("object-fit",QD0)),m0("object-position",$8("object-position")),m0("aspect-ratio",D("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:i90.includes(F["aspect-ratio"])?F["aspect-ratio"]:"",onChange:(M0)=>{let _0=M0.target.value;if(a("aspect-ratio",_0),_0&&_0!=="auto"&&F.height)q0("height")},children:[z("option",{value:"",disabled:!0,children:N7(U["aspect-ratio"])||"—"}),i90.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:q8,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(JE,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:z(V7,{as:lW,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:z(V7,{as:sW,size:12}),label:"Designer — Figma vocabulary"}],onChange:v})})]}),Z==="designer"?D(Q0,{children:[B0("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let t=(F.display||N7(U.display)||"").trim();return t==="flex"||t==="inline-flex"?D(Q0,{children:[m0("flex-direction",_8("flex-direction",U0),void 0,"Direction"),m0("align-items",z(Xm,{value:A0(),onChange:S0,ariaLabel:"auto-layout alignment"}),X8("align-items"),"Alignment"),m0("gap",k0("gap","space"),void 0,"Gap"),D("div",{className:"st-cp-modes",children:[P8("width"),P8("height")]}),D("div",{className:"st-cp-box","aria-label":"padding",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[x8(X8("padding-top")),"padding"]}),V8("padding-top","padding"),V8("padding-right","padding"),V8("padding-bottom","padding"),V8("padding-left","padding")]}),z("div",{className:"st-cp-clustermore-row",children:t0("Auto layout")}),g["Auto layout"]?m0("flex-wrap",z(aQ,{checked:/^wrap/.test(F["flex-wrap"]||N7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(_0)=>a("flex-wrap",_0?"wrap":"nowrap")}),X8("flex-wrap"),"Wrap"):null]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>a("display","flex"),children:"+ Auto layout (flex)"})})()),B0("Size",["width","height","min-width","max-width","min-height","max-height"],D(Q0,{children:[m0("width",Y9("width"),void 0,"Width"),m0("height",Y9("height"),void 0,"Height"),z("div",{className:"st-cp-clustermore-row",children:t0("Size")}),g.Size?D(Q0,{children:[m0("min-width",Y9("min-width"),void 0,"Min width"),m0("max-width",Y9("max-width"),void 0,"Max width"),m0("min-height",Y9("min-height"),void 0,"Min height"),m0("max-height",Y9("max-height"),void 0,"Max height")]}):null]})),B0("Position",["position","top","right","bottom","left","z-index"],D(Q0,{children:[m0("position",s0("position",p90),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:[x8(X8("top")),"inset"]}),f8("top"),f8("right"),f8("bottom"),f8("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||N7(U.position)||"static"})]}),(F.position||N7(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:t0("Position")}),g.Position?m0("z-index",Y9("z-index"),void 0,"Layer order"):null]}),!1),B0("Fill",["background-color"],m0("background-color",c8("background-color"),void 0,"Fill")),B0("Stroke",["border-width","border-style","border-color"],m0("border",h0(),X8("border-width"),"Stroke")),B0("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],m0("border-radius",b0(),X8("border-radius"),"Corner radius")),B0("Effects",["box-shadow","filter","mix-blend-mode"],D(Q0,{children:[m0("box-shadow",l7("box-shadow","shadow")||$8("box-shadow"),void 0,"Shadow"),m0("filter",P0(),X8("filter"),"Blur"),m0("mix-blend-mode",s0("mix-blend-mode",c90),void 0,"Blend")]})),B0("Opacity",["opacity"],m0("opacity",e0(),void 0,"Opacity")),B0("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],D(Q0,{children:[m0("font-family",s0("font-family",h90),void 0,"Font"),m0("color",c8("color"),void 0,"Color"),m0("font-size",k0("font-size","type"),void 0,"Size"),m0("font-weight",s0("font-weight",x90),void 0,"Weight"),m0("line-height",Y9("line-height","lh"),void 0,"Line height"),m0("text-align",_8("text-align",e8),void 0,"Align"),z("div",{className:"st-cp-clustermore-row",children:t0("Text")}),g.Text?D(Q0,{children:[m0("letter-spacing",Y9("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),m0("font-style",s0("font-style",XD0),void 0,"Style"),m0("text-transform",s0("text-transform",l90),void 0,"Case"),m0("white-space",s0("white-space",d90),void 0,"Whitespace")]}):null]})),B0("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:[x8(X8("margin-top")),"margin"]}),V8("margin-top","margin"),V8("margin-right","margin"),V8("margin-bottom","margin"),V8("margin-left","margin")]})),(()=>{let{showMedia:t,canReplace:M0}=b9();return t?B0("Media",["object-fit","object-position","aspect-ratio"],s9(M0)):null})()]}):D(Q0,{children:[N8("Layout",(()=>{let t=(F.display||N7(U.display)||"").trim(),M0=t==="flex"||t==="inline-flex",_0=t==="grid"||t==="inline-grid";return D(Q0,{children:[m0("display",s0("display",eL0)),M0?D(Q0,{children:[m0("flex-direction",_8("flex-direction",U0)),m0("flex-wrap",z(aQ,{checked:/^wrap/.test(F["flex-wrap"]||N7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(u0)=>a("flex-wrap",u0?"wrap":"nowrap")}),X8("flex-wrap"))]}):null,M0||_0?D(Q0,{children:[m0("align-items",_8("align-items",D8)),m0("justify-content",_8("justify-content",n0)),m0("gap",k0("gap","space"))]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>a("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let t=(F.display||N7(U.display)||"").trim();if(!(t==="grid"||t==="inline-grid"))return null;let _0=F["grid-template-columns"]||"",u0=F["grid-template-rows"]||"",Q8=fO(_0),a8=fO(u0),j8=Q8.length>0||!_0.trim(),S8=a8.length>0||!u0.trim();return N8("Grid",D(Q0,{children:[j8?z(n90,{label:"Columns",tracks:Q8,editable:K,onChange:(G9)=>a("grid-template-columns",xO(G9))}):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."]}),S8?z(n90,{label:"Rows",tracks:a8,editable:K,onChange:(G9)=>a("grid-template-rows",xO(G9))}):D("div",{className:"st-cp-note",children:["Rows use ",z("code",{children:u0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),N8("Position",D(Q0,{children:[m0("position",s0("position",p90)),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:[x8(X8("top")),"inset"]}),f8("top"),f8("right"),f8("bottom"),f8("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||N7(U.position)||"static"})]}),(F.position||N7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,m0("z-index",Y9("z-index"))]})),(J.parentDisplay==="grid"||J.parentDisplay==="inline-grid")&&N8("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"}),"."]}),m0("grid-column",$8("grid-column")),m0("grid-row",$8("grid-row"))]})),N8("Typography",D(Q0,{children:[m0("font-family",s0("font-family",h90)),m0("color",c8("color")),m0("font-size",k0("font-size","type")),m0("font-weight",s0("font-weight",x90)),m0("line-height",Y9("line-height","lh")),m0("letter-spacing",Y9("letter-spacing",null,{min:-1/0})),m0("text-align",_8("text-align",e8)),m0("font-style",E8(),X8("font-style")),m0("text-transform",s0("text-transform",l90)),m0("white-space",s0("white-space",d90))]})),N8("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:[x8(X8("margin-top")),"margin"]}),V8("margin-top","margin"),V8("margin-right","margin"),V8("margin-bottom","margin"),V8("margin-left","margin"),D("div",{className:"st-cp-boxpad",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[x8(X8("padding-top")),"padding"]}),V8("padding-top","padding"),V8("padding-right","padding"),V8("padding-bottom","padding"),V8("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)]})]})]})})),N8("Size",D(Q0,{children:[D("div",{className:"st-cp-modes",children:[P8("width"),P8("height")]}),m0("width",Y9("width")),m0("height",Y9("height")),m0("min-width",Y9("min-width")),m0("max-width",Y9("max-width")),m0("min-height",Y9("min-height")),m0("max-height",Y9("max-height")),m0("overflow",_8("overflow",L9)),J8?D(Q0,{children:[z("div",{className:"st-cp-subhd",children:"In flex parent"}),m0("align-self",s0("align-self",JD0)),m0("flex-grow",Y9("flex-grow",null,{unitless:!0})),m0("flex-shrink",Y9("flex-shrink",null,{unitless:!0})),m0("flex-basis",Y9("flex-basis"))]}):null]})),(()=>{let{showMedia:t,canReplace:M0}=b9();return t?N8("Media",s9(M0)):null})(),N8("Appearance",D(Q0,{children:[m0("background-color",c8("background-color")),m0("border-radius",b0(),X8("border-radius")),m0("border",h0(),X8("border-width")),m0("box-shadow",l7("box-shadow","shadow")||$8("box-shadow")),m0("filter",P0(),X8("filter")),m0("mix-blend-mode",s0("mix-blend-mode",c90)),m0("opacity",e0()),m0("rotation",O8(),X8("transform")),m0("transform",$8("transform")),m0("transform-origin",$8("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(k9,{name:"x",size:12}),t[0],": ",t[1].slice(4)]}):null})(),N8("Advanced",D("div",{className:"st-cp-advbody",children:[r8.length?D(Q0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),r8.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(k9,{name:"x",size:11})})]},`cs:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add CSS property"}),z(ZD0,{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)=>i(t,_0.currentTarget.value)},`at:${t}:${M0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>C0(t),children:z(k9,{name:"x",size:11})})]},`at:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),z(HD0,{commit:i})]}))]}),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 ZD0({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 HD0({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 zD0={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function KD0(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 UD0=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function Z70({node:J,depth:X,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:B,onRowPointerDown:N,dragState:V,componentMap:F,lockedKeys:M,onToggleLock:A,onRename:E}){let w=`${J.id}:${J.index}`,O=J.children&&J.children.length>0,P=W.has(w),T=!!J.synthetic,R=!T&&F?F[J.id]:null,$=!T&&!!M?.has(w),[C,j]=u.useState(!1),[f,m]=u.useState(""),c=!T&&J.id===Q&&(Y==null||J.index===Y),o=G?.has(w)?G.get(w):!!J.hidden,v=!!B&&!T&&!$,g=()=>{j(!1);let n=f.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!n||n===(J.dcElement??""))return;E?.(J,n)},l=V?.key===w,x=l?{transform:`translate(${V.dx}px, ${V.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"+(c?" is-sel":"")+(o?" is-hidden":"")+(T?" is-group":"")+(R?" is-instance":"")+($?" is-locked":""),style:{paddingLeft:6+X*14,...x},role:"treeitem","aria-selected":T?void 0:c,"aria-expanded":O?!P:void 0,"aria-grabbed":v?l:void 0,tabIndex:0,title:T?`${J.tag} · group (unstamped wrapper)`:`${J.tag} · ${J.type}${E?" · F2 to rename":""}`,"data-layer-key":w,onClick:()=>T?O&&Z(w):H(J),onMouseEnter:()=>!T&&K(J),onMouseLeave:()=>K(null),onPointerDown:v?(n)=>N(n,J,w):void 0,onKeyDown:(n)=>{if(n.key==="Enter"||n.key===" ")if(n.preventDefault(),T)O&&Z(w);else H(J);else if(n.key==="F2"&&E&&!T)n.preventDefault(),m(J.dcElement||J.label||""),j(!0)},children:[O?z("button",{type:"button",className:"st-layer-caret","aria-label":P?"Expand":"Collapse",onClick:(n)=>{n.stopPropagation(),Z(w)},children:P?"▸":"▾"}):z("span",{className:"st-layer-caret","aria-hidden":"true"}),R?z("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:R.root?"◆":"◇"}):z(k9,{name:zD0[J.type]||"box",size:12,className:"st-layer-ticon"}),C?z("input",{className:"st-layer-rename",value:f,autoFocus:!0,"aria-label":`Rename ${J.label}`,onFocus:(n)=>n.target.select(),onChange:(n)=>m(n.target.value),onClick:(n)=>n.stopPropagation(),onPointerDown:(n)=>n.stopPropagation(),onBlur:g,onKeyDown:(n)=>{if(n.stopPropagation(),n.key==="Enter")g();else if(n.key==="Escape")j(!1)}}):z("span",{className:"st-layer-label",onDoubleClick:E&&!T?(n)=>{n.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&&!T?z("button",{type:"button",className:"st-layer-lock","aria-label":$?`Unlock ${J.label}`:`Lock ${J.label}`,"aria-pressed":$,title:$?"Unlock":"Lock",onClick:(n)=>{n.stopPropagation(),A(w)},children:z(k9,{name:$?"lock":"unlock",size:12})}):null,U&&!T?z("button",{type:"button",className:"st-layer-eye","aria-label":o?`Show ${J.label}`:`Hide ${J.label}`,"aria-pressed":o,title:o?"Show":"Hide",onClick:(n)=>{n.stopPropagation(),U(J)},children:z(k9,{name:o?"eye-off":"eye",size:13})}):null]}),O&&!P?J.children.map((n,e)=>z(Z70,{node:n,depth:X+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:B,onRowPointerDown:N,dragState:V,componentMap:F,lockedKeys:M,onToggleLock:A,onRename:E},`${n.id}:${n.index}`)):null]})}function VD0({el:J}){let X=J?.computed||{},Q=J?.authored||{},Y=(U)=>{let B=Q[U];if(B&&/var\(\s*--/.test(B))return B.replace(/^var\(\s*|\s*\)$/g,"");return X[U]||B||""},W=(U,B)=>{let N=X[B]||Q[B];if(!N)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:N},"aria-hidden":"true"}),z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Y(B)})]})]},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 H70(J){if(J.artboardId)return J.artboardId;let X=/^\[data-dc-screen="([^"]+)"\]$/.exec(J.selector||"");return X?X[1]:null}var qD0=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],BD0=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function ND0({el:J,cfg:X,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let K=H70(J),U=(X?.designRel||X?.designRoot||".design").replace(/^\/+|\/+$/g,""),B=Q70(J.file,X),N=Y70(X,U,B),V=(x)=>N.map((n)=>({ds:n.name,names:n[x]||[],vals:n.vals})).filter((n)=>n.names.length),F=(x)=>V(x).flatMap((n)=>(n.names||[]).map((e)=>({name:e,value:n.vals?.[e]||""}))),M=(x)=>{let n=/^var\(\s*(--[\w-]+)\s*\)$/.exec(x||"");if(!n)return x||"";for(let e of N){let s=e.vals?.[n[1]];if(s)return s}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=(x,n)=>{if(!K)return;let e=Number.isFinite(x)&&x>0?Math.round(x):void 0,s=Number.isFinite(n)&&n>0?Math.round(n):void 0;if(e==null&&s==null)return;Q?.(K,e,s)},O=Object.entries($5).find(([,x])=>x.width===A&&x.height===E)?.[0],P=Object.entries($5).find(([,x])=>x.width===A)?.[0],T=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"]??"",f=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 c=(x)=>{if(!K)return;let n=null;if(x==="print"&&!m){let e={paper:"a4"};try{let s=ZB(e);if(s)n={defaults:e,widthPx:s.widthPx,heightPx:s.heightPx}}catch{}}if(G?.(K,x==="digital"?null:x,n),x==="web"&&T)Y?.(K,!1,void 0)},o=(x)=>{if(!K)return;let n={paper:"a4",...m,...x},e;try{e=ZB(n)}catch{return}Q?.(K,e.widthPx,e.heightPx),Z?.(K,n)},v=(x,n)=>{if(!K)return;let e=Number.isFinite(n)?n:E,s=x&&Number.isFinite(e)?Math.round(e):void 0;Y?.(K,x,s)},g=(x)=>{let n=nb(T,x);if(n.kind==="resize")w(null,n.height);else if(n.kind==="promote-to-fixed")v(!0,n.height)},l=(x)=>{if(!K)return;W?.(K,x)};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:(x)=>w(x,null)}),z(ZJ,{value:E??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:T,onCommit:g})]}),z("div",{style:{padding:"0 12px 8px"},children:f==="print"?D("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:m?.paper??"",onChange:(x)=>o({paper:x.currentTarget.value}),children:[z("option",{value:"",disabled:!0,children:"Paper size…"}),GB.map((x)=>D("option",{value:x.id,children:[x.label," — ",x.width,"×",x.height,x.unit]},x.id))]}):f==="web"?D("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:P??"",onChange:(x)=>{let n=$5[x.currentTarget.value];if(n)w(n.width,null)},children:[z("option",{value:"",disabled:!0,children:P?`${$5[P].label} — ≤ ${$5[P].width}px`:"Breakpoint…"}),Object.entries($5).map(([x,n])=>D("option",{value:x,children:[n.label," — ≤ ",n.width,"px breakpoint"]},x))]}):D("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:O??"",onChange:(x)=>{let n=$5[x.currentTarget.value];if(n)w(n.width,n.height)},children:[z("option",{value:"",disabled:!0,children:O?$5[O].label:"Preset size…"}),Object.entries($5).map(([x,n])=>D("option",{value:x,children:[n.label," — ",n.width,"×",n.height]},x))]})}),z("div",{style:{padding:"0 12px 8px"},children:z(sN,{value:T?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(x)=>v(x==="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(JG,{value:f,ariaLabel:"artboard kind",options:BD0.map(([x,n])=>({value:x,label:n})),onChange:c})}),f!=="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:(x)=>{let n=$5[x.currentTarget.value];if(n)H(K,n.width);x.currentTarget.value=""},children:[z("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries($5).map(([x,n])=>D("option",{value:x,children:[n.label," — ",n.width,"px"]},x))]})}):null,f==="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(sN,{value:m?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(x)=>o({orientation:x})})}),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:(x)=>o({bleedMm:x})})})]}):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 x=M(R),n=/var\(\s*--/.test(R),e=n?R.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):R;return z(q3,{swatch:z(OL,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:V("color"),current:R,activeDs:B,swatchBg:x,seedHex:EL(x)||"#000000",onPick:(s)=>l({background:s||null}),label:"artboard background colour"}),displayValue:e,bound:n,ariaLabel:"artboard background",onValue:(s)=>l({background:(s||"").trim()||null})})})(),z(JG,{value:C,ariaLabel:"artboard body layout",options:qD0.map(([x,n])=>({value:x,label:n})),onChange:(x)=>l({layout:x||null})}),D("div",{style:{display:"flex",gap:8},children:[z(tN,{value:/^var\(/.test($)?$:Number.parseFloat($)||0,tokens:F("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(x)=>l({padding:typeof x==="string"?x:x>0?x:null})}),z(tN,{value:/^var\(/.test(j)?j:Number.parseFloat(j)||0,tokens:F("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(x)=>l({gap:typeof x==="string"?x:x>0?x:null})})]})]})]})}var PT=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,FD0=new RegExp(PT.source,"gi");function LD0(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(FD0)||[])],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=PT.exec(`${J.attrs?.src||""} ${X}`);return Y?Y[0]:null}function DD0({testId:J,selected:X,onClose:Q,layersTree:Y,componentMap:W,lockedKeys:G,onToggleLock:Z,onDetachInstance:H,canvasFile:K,onSelectLayer:U,onHoverLayer:B,onReorderLayer:N,layersBusyRef:V,cfg:F,onOptimistic:M,onRecordEdit:A,onReplaceMedia:E,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:P,onSetArtboardKind:T,onSetArtboardPrint:R,onDuplicateArtboard:$,onUndoRedo:C,editScope:j,tab:f,onTabChange:m,width:c,resizing:o,photoSel:v,photoRev:g,onPhotoEdit:l,onPhotoRemoveBackground:x,onPhotoRecordEdit:n,onPhotoUndoRedo:e,layersOnly:s=!1,hideLayersTab:H0=!1,cpMode:a,onSetCpMode:z0}){let[i,q0]=u.useState("inspect"),Z0=s?"layers":f??i,C0=(b0)=>{q0(b0),m?.(b0)},[a0,o0]=u.useState(()=>new Set),[J8,P8]=u.useState(()=>new Map);u.useEffect(()=>{let b0=Array.isArray(X)?X[0]:X,h0=b0?.id;if(!h0||!Y?.nodes)return;let O8=b0.index,P0=null,e0=[];if(function E8(U0,n0){for(let D8 of U0||[]){let e8=`${D8.id}:${D8.index}`;if(!D8.synthetic&&D8.id===h0&&(O8==null||D8.index===O8))return P0=e8,e0.push(...n0),!0;if(D8.children&&D8.children.length&&E8(D8.children,[...n0,e8]))return!0}return!1}(Y.nodes,[]),!P0)return;if(e0.length)o0((E8)=>{let U0=!1,n0=new Set(E8);for(let D8 of e0)if(n0.delete(D8))U0=!0;return U0?n0:E8});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${P0}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[X,Y]);let n8=(b0)=>{let h0=`${b0.id}:${b0.index}`;return J8.has(h0)?J8.get(h0):!!b0.hidden},[C8,w8]=u.useState(null),[w0,A0]=u.useState(""),S0=(b0,h0)=>{if(!K||!b0?.id)return;G70(fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:K,id:b0.id,attr:"data-dc-element",value:h0})}).then((O8)=>O8.json().catch(()=>({}))).then((O8)=>{if(!O8.ok)return;A?.({op:"attr",canvas:K,id:b0.id,key:"data-dc-element",before:b0.dcElement??null,after:h0})}).catch(()=>{}))},q8=N?(b0,h0,O8)=>{if(V?.current)return;if(b0?.synthetic||h0?.synthetic)return;let P0=O8==="before"?`before ${h0.label}`:O8==="after"?`after ${h0.label}`:`into ${h0.label}`;A0(`Moved ${b0.label} ${P0}`),N(b0.id,h0.id,O8,{idIndex:b0.index,refIndex:h0.index})}:void 0,X8=()=>{let b0=[];return function h0(O8,P0,e0){(O8||[]).forEach((E8,U0)=>{if(b0.push({node:E8,depth:P0,parentNode:e0,siblings:O8,pos:U0}),E8.children&&E8.children.length&&!a0.has(`${E8.id}:${E8.index}`))h0(E8.children,P0+1,E8)})}(Y?.nodes,0,null),b0},k8=(b0)=>{if(b0.key!=="ArrowUp"&&b0.key!=="ArrowDown")return;if(!N8)return;let h0=X8(),O8=h0.findIndex((U0)=>U0.node.id===N8.id&&U0.node.index===N8.index);if(O8<0)return;let P0=b0.key==="ArrowDown"?1:-1,e0=h0[O8];if(!b0.altKey){let U0=h0[O8+P0];if(U0)b0.preventDefault(),U?.(U0.node);return}if(!q8||!Array.isArray(e0.siblings))return;b0.preventDefault();let E8=(U0)=>U0&&U0.children&&U0.children.length&&!a0.has(`${U0.id}:${U0.index}`);if(!b0.shiftKey){if(P0<0&&e0.pos>0)q8(e0.node,e0.siblings[e0.pos-1],"before");else if(P0>0&&e0.pos<e0.siblings.length-1)q8(e0.node,e0.siblings[e0.pos+1],"after");return}if(P0>0){let U0=e0.siblings[e0.pos+1];if(U0)q8(e0.node,U0,E8(U0)?"inside-start":"after");else if(e0.parentNode)q8(e0.node,e0.parentNode,"after")}else{let U0=e0.siblings[e0.pos-1];if(U0)q8(e0.node,U0,E8(U0)?"inside-end":"before");else if(e0.parentNode)q8(e0.node,e0.parentNode,"before")}},x8=u.useRef(null),N9=u.useRef(null),m0=(b0,h0,O8)=>{if(!q8||b0.button!==0||b0.metaKey||b0.ctrlKey||b0.shiftKey||b0.altKey)return;if(V?.current)return;let{clientX:P0,clientY:e0}=b0,E8=new Set([O8]);(function c8(E0){(E0.children||[]).forEach((V8)=>{E8.add(`${V8.id}:${V8.index}`),c8(V8)})})(h0);let U0=14,n0=6,D8=[];(function c8(E0,V8){(E0||[]).forEach((f8)=>{let r8=`${f8.id}:${f8.index}`;if(D8.push({node:f8,key:r8,id:f8.id,depth:V8,tag:f8.tag}),f8.children&&f8.children.length&&!a0.has(r8))c8(f8.children,V8+1)})})(Y?.nodes,0);let e8=new Map(D8.map((c8)=>[c8.key,c8])),L9=!1,l7=(c8)=>{if(!L9){if(Math.hypot(c8.clientX-P0,c8.clientY-e0)<4)return;L9=!0}let E0=c8.clientX-P0,V8=c8.clientY-e0,f8=null,r8=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((b9)=>({rect:b9.getBoundingClientRect(),it:e8.get(b9.getAttribute("data-layer-key"))})).filter((b9)=>b9.it&&b9.it.key!==O8);if(r8.length){let b9=r8[0].rect.left,s9=r8[0].rect.right,t=r8.length;for(let t9=0;t9<r8.length;t9++)if(c8.clientY<r8[t9].rect.top+r8[t9].rect.height/2){t=t9;break}let M0=r8[t-1]?.it||null,_0=r8[t]?.it||null,u0=Math.round((c8.clientX-b9-n0)/U0),Q8=M0?M0.depth+(UD0.has(M0.tag)?0:1):0,a8=_0?_0.depth:0,j8=Math.max(a8,Math.min(u0,Q8)),S8=null,G9="before",y9=0;if(!M0){if(_0)S8=_0,G9="before",y9=_0.depth}else if(j8>M0.depth)S8=M0,G9="inside-start",y9=M0.depth+1;else if(j8===M0.depth)S8=M0,G9="after",y9=M0.depth;else{for(let t9=t-1;t9>=0;t9--)if(r8[t9].it.depth===j8){S8=r8[t9].it;break}if(!S8)S8=M0;G9="after",y9=j8}if(S8&&S8.key!==O8&&!E8.has(S8.key)){let t9=M0?r8[t-1].rect.bottom:r8[0].rect.top,q7=b9+n0+y9*U0;f8={refId:S8.id,position:G9,node:S8.node,y:t9,left:q7,w:Math.max(24,s9-q7)}}}let x9={key:O8,node:h0,dx:E0,dy:V8,target:f8};x8.current=x9,w8(x9)},i0=()=>{window.removeEventListener("pointermove",l7),window.removeEventListener("pointerup",$8),window.removeEventListener("keydown",Y9,!0)},t7=()=>{let c8=(E0)=>{E0.preventDefault(),E0.stopImmediatePropagation(),document.removeEventListener("click",c8,!0)};document.addEventListener("click",c8,!0),setTimeout(()=>document.removeEventListener("click",c8,!0),300)},$8=()=>{i0();let c8=x8.current;if(x8.current=null,w8(null),L9&&c8?.target)t7(),q8(c8.node,c8.target.node,c8.target.position)},Y9=(c8)=>{if(c8.key!=="Escape")return;if(c8.preventDefault(),c8.stopImmediatePropagation(),i0(),x8.current=null,w8(null),L9)t7()};window.addEventListener("pointermove",l7),window.addEventListener("pointerup",$8),window.addEventListener("keydown",Y9,!0)},R8=(b0)=>o0((h0)=>{let O8=new Set(h0);if(O8.has(b0))O8.delete(b0);else O8.add(b0);return O8}),z9=(b0)=>{let h0=`${b0.id}:${b0.index}`,O8=n8(b0),P0=!O8;if(P8((e0)=>new Map(e0).set(h0,P0)),M?.({id:b0.id,artboardId:Y?.artboardId??null,index:b0.index,prop:"display",value:P0?"none":null}),!K||!b0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(P0?{canvas:K,id:b0.id,property:"display",value:"none"}:{canvas:K,id:b0.id,property:"display",reset:!0})}).catch(()=>{}),A?.({op:"css",canvas:K,id:b0.id,key:"display",before:O8?"none":null,after:P0?"none":null})},N8=Array.isArray(X)?X[0]:X,B0=v?{asset:v.asset,kind:"annotation-image"}:(()=>{let b0=LD0(N8);return b0?{asset:b0,kind:"artboard-img"}:null})(),t0=B0?.kind==="annotation-image",s0=(b0)=>{if(!(b0.metaKey||b0.ctrlKey)||b0.altKey)return;let h0=b0.key.toLowerCase();if(h0==="z")b0.preventDefault(),e?.(b0.shiftKey?"redo":"undo");else if(h0==="y")b0.preventDefault(),e?.("redo")},p8=t0?"photo":Z0==="photo"&&!B0?"css":Z0,_8=(b0,h0,O8)=>D("button",{type:"button",className:"st-rp-tab"+(p8===b0?" is-active":""),onClick:()=>C0(b0),children:[z(k9,{name:O8,size:14}),h0]}),k0=N8?.bounds||null;return D("aside",{className:"st-rpanel"+(o?" is-resizing":""),style:c?{width:c,flexBasis:c}:void 0,"aria-label":"Inspector","data-tour":"inspector","data-testid":J,children:[D("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:s?{display:"none"}:void 0,children:[t0?_8("photo","Photo","image"):D(Q0,{children:[_8("inspect","Inspect","sliders"),!H0&&_8("layers","Layers","layers"),_8("css","CSS","code"),B0?_8("photo","Photo","image"):null]}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:Q,children:z(k9,{name:"x",size:14})})]}),N8?.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(N8.id,N8.index),children:"Detach"}):null]}):null,z("div",{className:"st-rp-body",children:p8==="photo"&&B0?z("div",{onKeyDown:s0,children:z(Rm,{asset:B0.asset,ColorPicker:W70,StIcon:k9,onEdit:(b0)=>l?.(B0.asset,b0),onRemoveBackground:x,onRecordEdit:(b0,h0)=>n?.(B0.asset,b0,h0)},`${B0.asset}:${g??0}`)}):!N8&&!(p8==="layers"&&Y?.nodes?.length)?z("div",{className:"st-rp-empty",children:D("p",{children:["Press ",z(RJ,{children:"V"}),", then click an element to select it — or ",z(RJ,{children:"⌘"}),"-click straight from Browse."]})}):N8&&p8==="inspect"?D(Q0,{children:[z("div",{className:"st-rp-hd",children:N8.selector||N8.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:k0?Math.round(k0.x):"—",readOnly:!0,"aria-label":"x position"})]}),D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"Y"}),z("input",{value:k0?Math.round(k0.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:k0?Math.round(k0.w):"—",readOnly:!0,"aria-label":"width"})]}),D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"H"}),z("input",{value:k0?Math.round(k0.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:N8.tag||"—"})})]}),N8.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:N8.classes})})]}):null,z(VD0,{el:N8})]}):p8==="layers"?D(Q0,{children:[D("div",{className:"st-rp-hd",children:["Layers",Y?.nodes?.length?"":" · ancestry"]}),Y?.nodes?.length?D(Q0,{children:[q8?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:N9,onKeyDown:k8,children:Y.nodes.map((b0,h0)=>z(Z70,{node:b0,depth:0,selectedId:N8?.id,selectedIndex:N8?.index,collapsed:a0,hiddenOverride:J8,onToggle:R8,onSelect:(O8)=>{U?.(O8),N9.current?.focus()},onHover:(O8)=>B?.(O8),onToggleVisibility:z9,onReorder:q8,onRowPointerDown:m0,dragState:C8,componentMap:W,lockedKeys:G,onToggleLock:Z,onRename:S0},`${b0.id}:${b0.index}`))}),C8?.target?z("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:C8.target.left,top:C8.target.y-1,width:C8.target.w}}):null,z("div",{className:"sr-only",role:"status","aria-live":"polite",children:w0})]}):N8&&Array.isArray(N8.dom_path)&&N8.dom_path.length?N8.dom_path.map((b0,h0)=>D("div",{className:"st-layer"+(h0===N8.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+h0*12},children:[z(k9,{name:"square",size:13}),b0]},h0)):z("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!N8.id&&H70(N8)?z(ND0,{el:N8,cfg:F,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:P,onSetArtboardKind:T,onSetArtboardPrint:R,onDuplicateArtboard:$}):z(GD0,{el:N8,cfg:F,onOptimistic:M,onRecordEdit:A,onReplaceMedia:E,onUndoRedo:C,mode:a,onSetMode:z0})})]})}function MD0(){let[J,X]=u.useState([]),[Q,Y]=u.useState(!1),[W,G]=u.useState(0),Z=u.useRef("push"),H=u.useRef(null),[K,U]=u.useState("Design"),[B,N]=u.useState([]),[V,F]=u.useState(null),[M,A]=u.useState(null),E=u.useCallback((b)=>{Z.current="push",A(b)},[]),[w,O]=u.useState(null),P=u.useRef(null);u.useEffect(()=>{P.current=w},[w]);let[T,R]=u.useState(null);u.useEffect(()=>{let b=Array.isArray(w)?w.length===1?w[0]:null:w,S=b&&typeof b.id==="string"?b.id:null;if(!S||!V){R(null);return}let d=new AbortController,X0=new URLSearchParams({canvas:V,id:S});return fetch(`/_api/edit-scope?${X0}`,{signal:d.signal}).then((K0)=>K0.ok?K0.json():null).then((K0)=>{if(K0?.ok)R(K0)}).catch(()=>{}),()=>d.abort()},[w,V]);let $=u.useRef(0),C=u.useRef([]),j=u.useCallback((b)=>{if(!b?.id||!b.file)return;for(let S of C.current)clearTimeout(S);C.current=[50,450,1200,2500,5000].map((S)=>setTimeout(()=>{let d=P.current,X0=Array.isArray(d)?d[0]:d;if(!X0||X0.id!==b.id||X0.file!==b.file)return;let K0=R0.current.get(b.file);if(!K0?.contentWindow)return;try{K0.contentWindow.postMessage({dgn:"select-by-id",id:b.id,artboardId:b.artboardId??null,index:b.index??0},"*")}catch{}},S))},[]),f=u.useRef([]),m=u.useCallback((b,S)=>{if(!b||!S)return;for(let d of f.current)clearTimeout(d);f.current=[50,450,1200,2500,5000].map((d)=>setTimeout(()=>{let X0=P.current,K0=Array.isArray(X0)?X0[0]:X0;if(!K0||K0.artboardId!==b||K0.file!==S)return;let F0=R0.current.get(S);if(!F0?.contentWindow)return;try{F0.contentWindow.postMessage({dgn:"select-by-id",artboardId:b},"*")}catch{}},d))},[]),c=u.useRef(null),o=u.useRef(null),v=u.useRef(null);v.current=(b,S,d)=>{let X0=c.current;if(!X0||!X0.movedId)return;if(X0.staleSig!=null&&S===X0.staleSig)return;if(!function I0(p){return(p||[]).some((D0)=>D0.id===X0.movedId||I0(D0.children))}(b))return;c.current=null;let F0=V?R0.current.get(V)?.contentWindow:null;if(F0)try{F0.postMessage({dgn:"select-by-id",id:X0.movedId,artboardId:d,index:0},"*")}catch{}};let g=u.useRef(null),l=u.useRef(null),x=u.useRef(null),n=u.useRef(!1),e=u.useRef(null),[s,H0]=u.useState(null),[a,z0]=u.useState(null),i=u.useRef({canvas:null,at:0});u.useEffect(()=>{if(!V||!s)return;let b=Date.now(),S=i.current;if(S.canvas===V&&b-S.at<1500)return;i.current={canvas:V,at:b},fetch(`/_api/component-map?canvas=${encodeURIComponent(V)}`).then((d)=>d.json()).then((d)=>{if(d?.ok&&d.map&&typeof d.map==="object")z0(d.map);else z0(null)}).catch(()=>z0(null))},[V,s]);let[q0,Z0]=u.useState(!1),[C0,a0]=u.useState(null),[o0,J8]=u.useState(null),P8=u.useRef(null);u.useEffect(()=>{let b=o0?.files?.progress;if(!b)return;let S=P8.current;if(P8.current=b.phase,S===null||S===b.phase)return;if(b.phase==="converged"&&(S==="seeding"||S==="paused"))NL("Project synced",`${b.delivered} files are up to date.`);else if(b.phase==="blocked"){let d=(b.blocked??[]).reduce((X0,K0)=>X0+K0.count,0);NL("Sync needs a decision",`${d} file${d===1?"":"s"} could not be sent. Open the Sync panel for the reason.`)}},[o0?.files?.progress]),u.useEffect(()=>{if(typeof document>"u")return;let b=o0?.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},[o0?.files?.progress]);let[n8,C8]=u.useState(null),[w8,w0]=u.useState(null),[A0,S0]=u.useState(null),[q8,X8]=u.useState(null),[k8,x8]=u.useState(!1),[N9,m0]=u.useState(!1),[R8,z9]=u.useState(null),[N8,B0]=u.useState(""),[t0,s0]=u.useState(null),[p8,_8]=u.useState(null),k0=u.useRef(null),[b0,h0]=u.useState(null),[O8,P0]=u.useState(0),[e0,E8]=u.useState(null),U0=$90("maude-sb-w",{min:200,max:420,def:252}),n0=$90("maude-rp-w",{min:260,max:480,def:304}),[D8,e8]=u.useState(null),L9=u.useRef(null);u.useEffect(()=>{if(!D8)return;let b=(d)=>{let X0=L9.current?.getBoundingClientRect();if(!X0)return;if(D8==="sb")U0.setW(d.clientX-X0.left);else n0.setW(X0.right-d.clientX)},S=()=>e8(null);return window.addEventListener("pointermove",b),window.addEventListener("pointerup",S),()=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",S)}},[D8,U0.setW,n0.setW]);let l7=u.useCallback((b)=>{if(k90(b))return;clearTimeout(k0.current),k0.current=setTimeout(()=>{_8((S)=>S===b?null:S)},2500)},[]),[i0,t7]=u.useState({designRel:".design",cloud:void 0}),$8=!!p8&&e0===p8;u.useEffect(()=>{if(!p8)return;let b=p8,S=setTimeout(async()=>{let d="compile";try{if(!(await fetch(`${i0?.canvasOrigin||""}/_health`,{cache:"no-store"})).ok)d="server"}catch{d="server"}h0({path:b,kind:d}),_8((X0)=>X0===b?null:X0)},$8?60000:15000);return()=>clearTimeout(S)},[p8,$8,i0?.canvasOrigin]);let Y9=!!i0.cloud,c8=!i0.cloud&&!!n8?.credentialed,E0=Y9||c8,V8=E0?0:A0?.files?.length||0,f8=u.useRef(E0);f8.current=E0;let r8=!!i0.readOnly,x9=u.useCallback(()=>{fetch("/_config").then((b)=>b.json()).then((b)=>{let S=(b.designRoot||".design").replace(/^\/+|\/+$/g,"");t7((d)=>({...d,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(()=>{x9()},[x9]),u.useEffect(()=>{let b=!1;return fetch("/_sync-status").then((S)=>S.json()).then((S)=>{if(b||!S||S.linked===!1)return;J8(S)}).catch(()=>{}),()=>{b=!0}},[]),u.useEffect(()=>{if(E0){S0(null);return}let b=!1;return fetch("/_api/git/status").then((S)=>S.json()).then((S)=>{if(!b&&S)S0(S)}).catch(()=>{}),()=>{b=!0}},[E0]);let[b9,s9]=u.useState({}),[t,M0]=u.useState(null),[_0,u0]=u.useState(!1),[Q8,a8]=u.useState("open"),[j8,S8]=u.useState(XL0),[G9,y9]=u.useState(()=>{return T90(M90,"advanced")==="designer"?"designer":"advanced"});u.useEffect(()=>{try{localStorage.setItem(M90,JSON.stringify(G9))}catch{}},[G9]);let[t9,q7]=u.useState(null),[CJ,BQ]=u.useState(()=>TH(O90,!0)),[w6,$J]=u.useState(()=>TH(D90,!1)),VJ=Wu(),d9=VJ.update,RH=VJ.state.sections,[S7,qJ]=u.useState(!1),[j9,NQ]=u.useState(!1);u.useEffect(()=>{if(!H9())return;let b=Ph(()=>NQ(!0));return()=>{b.then((S)=>S()).catch(()=>{})}},[]);let[d7,FQ]=u.useState(!1),[LG,x7]=u.useState(!1),[FY,nJ]=u.useState(!1),[O7,SJ]=u.useState(!1),[Q7,B7]=u.useState(!1),{report:E6}=rw(H9()),[qX,BX]=u.useState(!1),[LY,NX]=u.useState(!1),[W4,DY]=u.useState(null),[G4,X6]=u.useState(null),[iX,bJ]=u.useState(!1),[LQ,Z4]=u.useState(!1),[oX,DQ]=u.useState(!1),[r,W0]=u.useState(!1),[L0,v0]=u.useState(()=>T90(E90,aK)),[T0,W8]=u.useState(()=>{try{let b=localStorage.getItem(P90);if(b==="separate"||b==="in-inspector")return b}catch{}return"separate"}),[B8,K9]=u.useState(!1),[J9,FX]=u.useState([]),[b5,z6]=u.useState(0),[rJ,n6]=u.useState(!1),[MY,DG]=u.useState(!1),[v6,k7]=u.useState(!1),[W7,nX]=u.useState(1),[BJ,X9]=u.useState(216),[Y7,f6]=u.useState(null),[r6,MQ]=u.useState([]),[MG,CH]=u.useState([]),[y5,$H]=u.useState([]),[OQ,rX]=u.useState(0),OG=u.useRef(0);u.useEffect(()=>{OG.current=b5},[b5]);let[c7,SH]=u.useState(null),AG=u.useRef(null);u.useEffect(()=>{AG.current=c7},[c7]);let P6=u.useMemo(()=>QE(J9,{artboardId:[c7,Y7],total:OQ}),[J9,c7,Y7,OQ]),aX=u.useRef(null);u.useEffect(()=>{aX.current=P6},[P6]);let OY=u.useMemo(()=>IK(J9,P6)?.fps||30,[J9,P6]),[bH,AY]=u.useState(null),[yH,X1]=u.useState(0),NJ=u.useCallback((b,S)=>{if(/concurrent edit|changed since it was read/i.test(S||""))g8("Timeline changed — reloaded, try again."),X1((d)=>d+1);else g8(`${b}: ${S||"failed"}`)},[]),[LX,_G]=u.useState(!1),[Q1,jH]=u.useState(!1),[Y1,wG]=u.useState(!1),H4=u.useRef(LX);u.useEffect(()=>{if(H4.current=LX,LX){wG(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[LX]);let _Y=u.useCallback(()=>{if(!H4.current||document.hidden)wG(!0),NL("Claude finished","Your assistant turn is ready in Maude.")},[]),wY=u.useRef(0),EY=u.useCallback(()=>{if(!H4.current||document.hidden){wG(!0);let b=Date.now();if(b-wY.current<sF0)return;wY.current=b,NL("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[z4,sX]=u.useState("inspect"),[EG,FJ]=u.useState(null),AQ=u.useRef({undo:[],redo:[]}),[PG,W1]=u.useState(0),[tX,IG]=u.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),vH=u.useRef(tX);u.useEffect(()=>{vH.current=tX;try{localStorage.setItem("maude-auto-open-inspector",tX?"1":"0")}catch{}},[tX]);let _Q=u.useRef(!1);u.useEffect(()=>{_Q.current=oX||_0||k8||N9||LX},[oX,_0,k8,N9,LX]);let K4=u.useRef({open:{},side:aK});K4.current={open:{tree:CJ,layers:r,inspector:oX,comments:_0,changes:k8,sync:N9,assistant:LX},side:L0};let U4=u.useCallback((b,S)=>{if(b==="tree")BQ(S);else if(b==="layers")W0(S);else if(b==="inspector")DQ(S);else if(b==="comments")u0(S);else if(b==="changes")x8(S);else if(b==="sync")m0(S);else if(b==="assistant")_G(S)},[]),kG=u.useCallback((b)=>K4.current.side?.[b]||aK[b],[]),yJ=u.useCallback((b)=>{let S=kG(b);U4(b,!0);for(let d of wT)if(d.id!==b&&kG(d.id)===S)U4(d.id,!1)},[U4,kG]),j5=u.useCallback((b)=>{if(K4.current.open?.[b])U4(b,!1);else yJ(b)},[yJ,U4]),DX=yJ,x6=j5,TG=u.useCallback((b)=>{if(!vH.current)return;if(r8)return;if(!b||!b.id)return;if(_Q.current)return;DX("inspector"),sX("css")},[DX,r8]),PY=u.useCallback(()=>K9((b)=>!b),[]),wQ=rm(ET),jJ=ym({enabled:i0.cloud===null||i0.exportLane==="remote"}),[LJ,RG]=u.useState(!1),[fH,xH]=u.useState(!1);u.useEffect(()=>{if(!H9())return;let b=!0;return Rh().then((S)=>{if(!b)return;if(RG(!!S),!S&&!TH(L90,!1))xH(!0)}).catch(()=>{}),()=>{b=!1}},[]);let EQ=u.useCallback(()=>{xH(!1);try{localStorage.setItem(L90,"1")}catch{}},[]),[V4,IY]=u.useState(null);u.useEffect(()=>{if(!H9())return;let b;return yh((S)=>IY(S&&typeof S==="object"?S:{})).then((S)=>{b=S}).catch(()=>{}),()=>{try{b?.()}catch{}}},[]);let[v5,kY]=u.useState(null),[TY,CG]=u.useState(()=>!TH(F90,!1)),MX=u.useCallback((b)=>{kY(Array.isArray(b)&&b.length?b:null)},[]),G1={setup:(b)=>{if(!b)return;if((b.canvas||b.requireSelection)&&B.length===0)yJ("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [data-testid^="canvas-row-"]')?.click()}catch{}},80);if(b.inspector||b.tab||b.requireSelection)DX("inspector");if(b.tab)sX(b.tab);if(b.changes)DX("changes")}},q4=u.useCallback(()=>{CG(!1);try{localStorage.setItem(F90,"1")}catch{}},[]),[PQ,RY]=u.useState(()=>TH(w90,!0)),[eX,V0]=u.useState(!1),[J5,CY]=u.useState(()=>TH(A90,!1)),[aJ,X5]=u.useState(()=>TH(_90,!1)),[e9,OX]=u.useState(!1),[B4,IQ]=u.useState(!1),[$G,kQ]=u.useState(0),[f5,SG]=u.useState(null),[bG,G8]=u.useState(!1),vJ=u.useRef(null),TQ=u.useRef(null),R0=u.useRef(new Map);u.useEffect(()=>{if(!i0?.canvasToken)return;let b=!1,S=null,d=0,X0=(O0)=>{clearTimeout(S);let g0=Xy(O0);d=Date.now()+g0,S=setTimeout(K0,g0)};async function K0(){let O0=null;try{let K8=await fetch("/_config",{cache:"no-store",credentials:"same-origin"});if(K8.ok)O0=(await K8.json())?.canvasToken}catch{}if(b)return;if(typeof O0!=="string"||!O0){clearTimeout(S),d=Date.now()+30000,S=setTimeout(K0,30000);return}Jy(O0);let g0=F0();if(g0)for(let K8 of R0.current.values())try{K8.contentWindow?.postMessage({dgn:"canvas-cap",t:O0},g0)}catch{}return X0(O0),O0}function F0(){try{return new URL(i0.canvasOrigin,location.href).origin}catch{return null}}let I0=!1;async function p(O0){if(O0.data?.dgn!=="canvas-expired"||O0.origin!==F0()||I0)return;I0=!0;try{let g0=await K0();if(!g0)return;for(let K8 of R0.current.values())if(K8.contentWindow===O0.source)K8.src=Qy(K8.src,g0)}finally{I0=!1}}window.addEventListener("message",p),X0(i0.canvasToken);let D0=()=>{if(document.visibilityState==="visible"&&Date.now()>=d)K0()};return document.addEventListener("visibilitychange",D0),()=>{b=!0,clearTimeout(S),document.removeEventListener("visibilitychange",D0),window.removeEventListener("message",p)}},[i0?.canvasToken,i0?.canvasOrigin]);let b8=u.useCallback((b)=>{let S=V?R0.current.get(V):null;if(!S||!S.contentWindow)return;try{S.contentWindow.postMessage(b,"*")}catch{}},[V]),Y8=u.useRef(0),RQ=u.useCallback(({format:b,artboardIds:S=null,scale:d=1,onProgress:X0,timeoutMs:K0=120000})=>new Promise((F0,I0)=>{let p=V?R0.current.get(V):null;if(!p||!p.contentWindow){I0(Error("no active canvas to capture"));return}let D0=p.contentWindow;Y8.current+=1;let O0=`cap-${Date.now().toString(36)}-${Y8.current}`,g0=!1,K8=(P7,p9)=>{if(g0)return;g0=!0,window.removeEventListener("message",L8),clearTimeout(U6),P7(p9)},L8=(P7)=>{if(P7.source!==D0)return;let p9=P7.data;if(!p9||p9.id!==O0)return;if(p9.dgn==="export-capture-progress")X0?.(p9.current,p9.total);else if(p9.dgn==="export-capture-done")K8(F0,Array.isArray(p9.items)?p9.items:[]);else if(p9.dgn==="export-capture-error")K8(I0,Error(p9.message||"capture failed"))},U6=setTimeout(()=>K8(I0,Error("capture timed out — the canvas did not answer")),K0);window.addEventListener("message",L8);try{D0.postMessage({dgn:"export-capture",id:O0,format:b,artboardIds:S,scale:d},"*")}catch(P7){K8(I0,P7)}}),[V]),N4=u.useCallback((b,S)=>b8({dgn:"photo-preview",asset:b,edit:S}),[b8]),yG=u.useCallback((b,S,d)=>{AQ.current.undo.push({asset:b,before:S,after:d}),AQ.current.redo.length=0},[]),F4=u.useCallback((b)=>{let S=b?AQ.current.redo:AQ.current.undo;if(!S.length)return!1;let d=S.pop();(b?AQ.current.undo:AQ.current.redo).push(d);let X0=(b?d.after:d.before)||{};return N4(d.asset,X0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(d.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(X0)}).catch(()=>{}),W1((K0)=>K0+1),!0},[N4]),jG=u.useCallback(async(b)=>{b8({dgn:"photo-busy",asset:b,busy:!0});try{let S=await fetch(`/${b.replace(/^\/+/,"")}`);if(!S.ok)return null;let d=await S.blob(),{removeBackground:X0}=await Promise.resolve().then(() => (N90(),B90)),K0=await X0(d),F0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":K0.type||"image/png"},body:K0}),I0=await F0.json().catch(()=>({}));if(F0.ok&&I0.path)return{maskAsset:I0.path};return null}catch(S){return console.error("[photo] background removal failed",S),null}finally{b8({dgn:"photo-busy",asset:b,busy:!1})}},[b8]);u.useEffect(()=>{let b=(X0)=>Array.from(X0.dataTransfer?.types??[]).includes("Files"),S=(X0)=>{if(b(X0))X0.preventDefault()},d=(X0)=>{if(b(X0))X0.preventDefault()};return document.addEventListener("dragover",S),document.addEventListener("drop",d),()=>{document.removeEventListener("dragover",S),document.removeEventListener("drop",d)}},[]);let Q6=u.useRef({});Q6.current={open:B8,comps:J9,frame:b5,total:OQ,playing:rJ,compId:P6,muted:v6,loop:MY,sequences:r6,post:b8,canvas:V};let AX=u.useRef({undo:[],redo:[]}),Y6=u.useCallback((b,S,d)=>{if(typeof S!=="number")return;if(AX.current.undo.push({canvas:b,seq:S,label:d}),AX.current.redo=[],AX.current.undo.length>50)AX.current.undo.shift()},[]),vG=u.useCallback((b)=>{let S=AX.current,d=b==="undo"?S.undo:S.redo,X0=b==="undo"?S.redo:S.undo,K0=Q6.current.canvas,F0=-1;for(let p=d.length-1;p>=0;p--)if(d[p].canvas===K0){F0=p;break}if(F0<0){g8(b==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let I0=d[F0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:I0.canvas,seq:I0.seq,dir:b})}).then((p)=>p.json().catch(()=>({}))).then((p)=>{if(d.splice(F0,1),p?.ok)X0.push(I0),g8(`${b==="undo"?"Undid":"Redid"}: ${I0.label}`,!0);else g8(`${b==="undo"?"Undo":"Redo"} skipped: ${p?.error||"failed"}`)}).catch(()=>g8(`${b==="undo"?"Undo":"Redo"} failed: network error`))},[]),I6=u.useCallback((b,S)=>{let d=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?d.find((X0)=>X0.stableId===S.stableId):null)||(Number.isInteger(S.index)?d[S.index]:null)||null;if(typeof S==="string")return d.find((X0)=>X0.stableId===S)||null;return d[S]||null},[]),$Y=u.useCallback((b)=>{let S=Q6.current.canvas;if(!S||S===o8)return;let d=AG.current||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(S)}${d?`&artboardId=${encodeURIComponent(d)}`:""}`;fetch(X0).then((K0)=>K0.json().catch(()=>({}))).then((K0)=>{let F0=I6(K0,b);if(!F0?.stableId)return null;return fetch("/_api/remove-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:S,artboardId:d,stableId:F0.stableId,contentHash:F0.contentHash})})}).then((K0)=>K0?K0.json():null).then((K0)=>{if(K0&&!K0.ok)console.warn("[remove-clip]",K0.error||"failed"),NJ("Remove refused",K0.error);else if(K0?.ok){if(g8("Clip removed.",!0),K0.seq!=null)Y6(S,K0.seq,"remove clip");AY(null)}}).catch(()=>g8("Remove failed: network error"))},[I6,Y6]),CQ=u.useCallback((b,S,d)=>{let X0=Q6.current.canvas;if(!X0||X0===o8)return;let K0=AG.current||void 0,F0=`/_api/comp-clips?canvas=${encodeURIComponent(X0)}${K0?`&artboardId=${encodeURIComponent(K0)}`:""}`;fetch(F0).then((I0)=>I0.json().catch(()=>({}))).then((I0)=>{let p=I0?.ok&&Array.isArray(I0.clips)?I0.clips:[],D0=b?.transition?p.find((O0)=>O0.kind==="transition"&&O0.stableId===b.stableId)||null:I6(I0,b);if(!D0?.stableId)return null;return fetch("/_api/clip-edit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:X0,artboardId:K0,stableId:D0.stableId,contentHash:D0.contentHash,verb:S,...d})})}).then((I0)=>I0?I0.json():null).then((I0)=>{if(I0&&!I0.ok)console.warn("[clip-edit]",S,I0.error||"failed"),NJ(`${S} refused`,I0.error);else if(I0?.ok){let p={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(g8(`Applied: ${p[S]||S}.`,!0),I0.seq!=null)Y6(X0,I0.seq,p[S]||S)}}).catch(()=>g8(`${S} failed: network error`))},[I6,Y6,NJ]),[$Q,SY]=u.useState(null),Q5=u.useCallback((b,S="")=>new Promise((d)=>{SY({title:b,value:S,resolve:d})}),[]),x5=u.useCallback((b)=>{SY((S)=>{return S?.resolve?.(b),null})},[]),bY=u.useCallback((b,S)=>{let d=Q6.current.canvas;if(!d||d===o8||!S||!String(S).trim())return;b7({type:"comments-add",payload:{file:d,text:String(S).trim(),selector:"",dom_path:[],tag:"",classes:"",bounds:null,html_excerpt:"",timeline:b}}),g8("Comment added.",!0)},[]);Q6.current.selected=bH,Q6.current.setSelected=AY,Q6.current.removeClip=$Y,Q6.current.clipVerb=CQ,Q6.current.addComment=bY,Q6.current.askText=Q5,u.useEffect(()=>{let b=(S)=>{let d=Q6.current;if(!d.open||!d.comps?.length)return;let X0=S.target,K0=X0?.tagName;if(K0==="INPUT"&&X0?.type!=="range")return;if(K0==="TEXTAREA"||K0==="SELECT"||X0?.isContentEditable)return;let F0=IK(d.comps,d.compId)?.fps||30,I0=Math.max(1,d.total),p=(O0)=>{let g0=Math.max(0,Math.min(I0-1,Math.round(O0)));z6(g0),n6(!1),d.post({dgn:"timeline-seek",frame:g0,id:d.compId})},D0=()=>{let O0=new Set([0,I0-1]);for(let g0 of d.sequences||[]){O0.add(g0.from);for(let K8 of g0.keyframes||[])O0.add(K8.from),O0.add(K8.to)}return[...O0].filter((g0)=>g0>=0&&g0<I0).sort((g0,K8)=>g0-K8)};if((S.metaKey||S.ctrlKey)&&(S.key==="z"||S.key==="Z")){S.preventDefault(),vG(S.shiftKey?"redo":"undo");return}if(S.key==="Escape"){if(d.selected!=null)S.preventDefault(),d.setSelected?.(null);return}if((S.key==="Delete"||S.key==="Backspace")&&d.selected!=null){S.preventDefault(),d.removeClip?.({stableId:d.selected});return}if((S.metaKey||S.ctrlKey)&&(S.key==="b"||S.key==="B")){S.preventDefault();let O0=d.selected!=null?{stableId:d.selected}:null;if(!O0){let g0=d.sequences||[],K8=g0.find((L8)=>L8.series&&d.frame>=L8.from&&d.frame<L8.from+L8.duration)||g0.find((L8)=>d.frame>=L8.from&&d.frame<L8.from+L8.duration);if(K8?.stableId)O0={stableId:K8.stableId}}if(O0)d.clipVerb?.(O0,"split",{atFrame:d.frame});else g8("Nothing under the playhead to split.");return}if(S.key===" "||S.code==="Space")if(S.preventDefault(),d.playing)n6(!1),d.post({dgn:"timeline-pause",id:d.compId});else n6(!0),d.post({dgn:"timeline-mute",muted:d.muted,id:d.compId}),d.post({dgn:"timeline-loop",loop:d.loop,id:d.compId}),d.post({dgn:"timeline-play",id:d.compId});else if(S.key==="ArrowRight")S.preventDefault(),p(d.frame+(S.shiftKey?F0:1));else if(S.key==="ArrowLeft")S.preventDefault(),p(d.frame-(S.shiftKey?F0:1));else if(S.key==="Home")S.preventDefault(),p(0);else if(S.key==="End")S.preventDefault(),p(I0-1);else if(S.key==="."){S.preventDefault();let O0=D0().find((g0)=>g0>d.frame);if(O0!=null)p(O0)}else if(S.key===","){S.preventDefault();let O0=D0().reverse().find((g0)=>g0<d.frame);if(O0!=null)p(O0)}};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[]),u.useEffect(()=>{FX([]),z6(0),n6(!1),AY(null),SH(null);let b=setTimeout(()=>b8({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(b)},[V,b8]);let[h5,yY]=u.useState(""),[jY,L4]=u.useState([]),[fG,vY]=u.useState([]);u.useEffect(()=>{if(!B8||J9.length===0||!V||V===o8){yY(""),L4([]);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")yY(S.source)}).catch(()=>{}),()=>{b=!1}},[B8,J9,V,yH]),u.useEffect(()=>{if(!B8||!V||V===o8||!h5){L4([]),vY([]);return}let b=!0,S=c7||void 0,d=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${S?`&artboardId=${encodeURIComponent(S)}`:""}`;return fetch(d).then((X0)=>X0.ok?X0.json():null).then((X0)=>{if(!b)return;let K0=X0?.ok&&Array.isArray(X0.clips)?X0.clips:[];L4(K0.filter((F0)=>F0.kind==="sequence")),vY(K0.filter((F0)=>F0.kind==="transition"))}).catch(()=>{}),()=>{b=!1}},[B8,V,h5,c7,yH]),u.useEffect(()=>{if(!h5){MQ([]),CH([]),$H([]),rX(0);return}let b=Y7??w?.artboardId??null,d=(b&&J9.find((F0)=>F0.artboardId===b||F0.id===b)||J9[0])?.durationInFrames||0,X0=wm(h5,d,b);SH(X0.artboardId??b??null);let K0=X0.sequences.map((F0,I0)=>{let p=jY[I0];if(!p)return F0;return{...F0,stableId:p.stableId,contentHash:p.contentHash,mediaProps:p.mediaProps??null,placeholder:p.placeholder??null,mediaTag:p.mediaTag??F0.mediaTag,mediaSrc:p.mediaSrc??F0.mediaSrc,replaceable:!!(p.mediaCdId||p.mediaArrayRef),layers:Array.isArray(p.layers)?p.layers:[],hidden:!!p.hidden}});MQ(K0),CH(X0.audio||[]),$H(X0.transitions||[]),rX(X0.total)},[h5,jY,w,J9,Y7]);let fY=u.useCallback(()=>{RY((b)=>{let S=!b,d=V?R0.current.get(V):null;if(d&&d.contentWindow)try{d.contentWindow.postMessage({dgn:"view-annotations",visible:S},"*")}catch{}return S})},[V]),DJ=u.useCallback((b)=>{for(let S of R0.current.values())try{S.contentWindow.postMessage({dgn:"view-chrome",...b},"*")}catch{}},[]),xY=u.useCallback(()=>{CY((b)=>{let S=!b;return DJ({minimap:S}),S})},[DJ]),hY=u.useCallback(()=>{X5((b)=>{let S=!b;return DJ({zoom:S}),S})},[DJ]),xG=u.useCallback(()=>{OX((b)=>{let S=!b;return DJ({present:S}),S})},[DJ]),D4=u.useCallback(()=>{OX(!1),DJ({present:!1})},[DJ]),hG=u.useCallback(()=>{if(!V||V===o8)return;IQ((b)=>{let S=!b;return b8({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,b8]);u.useEffect(()=>{let b=!1;return fetch("/_api/git-user").then((S)=>S.json()).then((S)=>{if(b)return;let d=S&&typeof S.name==="string"?S.name.trim():"";if(d)SG(d)}).catch(()=>{}),()=>{b=!0}},[]),u.useEffect(()=>{if(!V||V===o8){kQ(0),IQ(!1);return}let b=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(V)).then((S)=>S.json()).then((S)=>{if(b)return;let d=Array.isArray(S?.artboards)?S.artboards.length:0;kQ(d),IQ(S?.overlays?.print===!0),O4(new Set(Array.isArray(S?.locked)?S.locked:[]))}).catch(()=>{if(!b)kQ(0),IQ(!1),O4(new Set)}),()=>{b=!0}},[V]),u.useEffect(()=>{if(!V||V===o8||!Y7)return;let b=setTimeout(()=>{b8({dgn:"request-layers",artboardId:Y7})},250);return()=>clearTimeout(b)},[V,Y7,b8]);let[M4,O4]=u.useState(()=>new Set),gG=u.useCallback((b)=>{if(!V||V===o8)return;O4((S)=>{let d=new Set(S);if(d.has(b))d.delete(b);else d.add(b);let X0=[...d];return fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:V,patch:{locked:X0}})}).catch(()=>{}),b8({dgn:"locked-set",locked:X0}),d})},[V,b8]);u.useEffect(()=>{if(!V||V===o8)return;b8({dgn:"locked-set",locked:[...M4]})},[M4,V,b8]),u.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",j8),localStorage.setItem(s90,j8)}catch{}for(let b of R0.current.values())try{b.contentWindow.postMessage({dgn:"theme",theme:j8},"*")}catch{}},[j8]),u.useEffect(()=>{try{localStorage.setItem(O90,CJ?"1":"0")}catch{}},[CJ]),u.useEffect(()=>{try{localStorage.setItem(D90,w6?"1":"0")}catch{}},[w6]),u.useEffect(()=>{try{localStorage.setItem(A90,J5?"1":"0")}catch{}},[J5]),u.useEffect(()=>{try{localStorage.setItem(_90,aJ?"1":"0")}catch{}},[aJ]),u.useEffect(()=>{try{localStorage.setItem(w90,PQ?"1":"0")}catch{}},[PQ]),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")S8(S.theme);if(typeof S.minimap==="boolean")CY(S.minimap);if(typeof S.zoom==="boolean")X5(S.zoom);if(typeof S.annotations==="boolean")RY(S.annotations);if(typeof S.autoOpenInspector==="boolean")IG(S.autoOpenInspector);if(S.panelSides&&typeof S.panelSides==="object")v0({...aK,...S.panelSides});if(S.layersMode==="separate"||S.layersMode==="in-inspector")W8(S.layersMode)}).catch(()=>{}).finally(()=>{if(!b)V0(!0)}),()=>{b=!0}},[]),u.useEffect(()=>{if(!eX)return;tF0({theme:j8,minimap:J5,zoom:aJ,annotations:PQ,autoOpenInspector:tX,panelSides:L0,layersMode:T0})},[eX,j8,J5,aJ,PQ,tX,L0,T0]),u.useEffect(()=>{try{localStorage.setItem(E90,JSON.stringify(L0))}catch{}},[L0]),u.useEffect(()=>{try{localStorage.setItem(P90,T0)}catch{}},[T0]);let gY=u.useRef(!1);u.useEffect(()=>{if(gY.current||!VJ.ready||!Q||!J.length)return;gY.current=!0;let b=Qu(J);d9((S)=>Yu(S,b))},[VJ.ready,Q,J,d9]);let mG=u.useCallback((b)=>d9((S)=>Xu(S,b)),[d9]),uG=u.useMemo(()=>({isOpen:(b)=>em(VJ.state,b),setOpen:(b,S)=>d9((d)=>bE(d,b,S))}),[VJ.state,d9]),A4=u.useCallback(()=>{S8((b)=>b==="dark"?"light":"dark")},[]),_4=u.useRef(null),S9=u.useCallback(()=>_4.current?.reload()??Promise.resolve(),[]);u.useEffect(()=>{let b=Wy({read:async(S)=>{let d=await fetch("/_index-data",{signal:S,cache:"no-store"});if(!d.ok)throw Object.assign(Error(`Project index request failed: ${d.status}`),{status:d.status});let X0=await d.json(),K0=X0.groups.map((F0)=>({...F0,tree:ZL0(F0.paths,F0.stripPrefix,F0.dirs)}));return{data:X0,built:K0}},apply:({data:S,built:d})=>{U(S.project||"Design"),X(d),Y(!0),G(0),t7((X0)=>({...X0,canvasDesignSystems:S.canvasDesignSystems??{},canvasKinds:S.canvasKinds??{}}))},onError:(S)=>{console.error("failed to load tree",S),G((d)=>d+1)}});return _4.current=b,S9(),()=>{_4.current=null,b.dispose()}},[S9]);let Y5=u.useCallback(async(b)=>{try{let S=b?`/_system-data?ds=${encodeURIComponent(b)}`:"/_system-data",d=await fetch(S);if(!d.ok){console.error("failed to load system-data",d.status);return}let X0=await d.json();if(!b&&X0?.defaultDesignSystem&&!X0.ds){s0(X0);let K0=await fetch(`/_system-data?ds=${encodeURIComponent(X0.defaultDesignSystem)}`);if(K0.ok)s0(await K0.json());return}s0(X0)}catch(S){console.error("failed to load system-data",S)}},[]),mY=u.useCallback(async()=>{try{let S=await(await fetch("/_comments-all")).json();s9(S||{})}catch(b){console.error("failed to load comments",b)}},[]);u.useEffect(()=>{mY()},[mY]);let uY=u.useRef(()=>{});u.useEffect(()=>{let b=null,S=!1;function d(){let X0=location.protocol==="https:"?"wss:":"ws:",K0=new WebSocket(X0+"//"+location.host+"/_ws");TQ.current=K0,K0.addEventListener("open",()=>{if(Z0(!0),S)x9();S=!0,clearInterval(b),b=setInterval(()=>{if(K0.readyState===WebSocket.OPEN)K0.send('{"type":"ping"}')},25000)}),K0.addEventListener("close",()=>{Z0(!1),clearInterval(b),setTimeout(d,1000)}),K0.addEventListener("error",()=>{}),K0.addEventListener("message",(F0)=>{try{let I0=JSON.parse(F0.data);if(I0.type==="snapshot"&&I0.state)O((p)=>o90(I0.state.selected,p));else if(I0.type==="selected"){if(Date.now()-$.current<2000)return;let p=I0.selected,D0=Array.isArray(p)?p[0]:p,O0=P.current,g0=Array.isArray(O0)?O0[0]:O0;if(O((K8)=>o90(p,K8)),D0?.id&&D0.file&&(!g0||g0.id!==D0.id||g0.file!==D0.file))j(D0)}else if(I0.type==="comments"&&typeof I0.file==="string")s9((p)=>({...p,[I0.file]:I0.comments||[]}));else if(I0.type==="ai-activity"&&typeof I0.file==="string"){if(G8(!0),vJ.current)clearTimeout(vJ.current);vJ.current=setTimeout(()=>G8(!1),8000);for(let p of R0.current.values())try{p.contentWindow.postMessage({dgn:"ai-activity",file:I0.file,entry:I0.entry},"*")}catch{}}else if(I0.type==="export:job"&&I0.payload)jJ.upsert(I0.payload);else if(I0.type==="sync:status"&&I0.payload)J8(I0.payload);else if(I0.type==="canvas-list-update")S9(),uY.current(I0.payload);else if(I0.type==="config-updated")x9();else if(I0.type==="acp-focus"){if(H9())DX("assistant")}else if(I0.type==="git-status"&&I0.payload){if(!f8.current)S0(I0.payload)}else if(I0.type==="git-lifecycle"&&I0.payload){a0(I0.payload);for(let p of R0.current.values())try{p.contentWindow.postMessage({dgn:"git-lifecycle",payload:I0.payload},"*")}catch{}}}catch{}})}return d(),()=>{if(clearInterval(b),TQ.current)TQ.current.close()}},[S9,x9]);function b7(b){let S=TQ.current;try{if(S&&S.readyState===1)S.send(JSON.stringify(b))}catch{}}let MJ=u.useCallback(async()=>{if(f8.current)return;try{let b=await fetch("/_api/git/status");if(b.ok)S0(await b.json())}catch{}},[]),fJ=u.useCallback(async()=>{if(f8.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)X8({remoteAhead:!!S.remoteAhead,behind:S.behind||0})}catch{}},[]),OJ=u.useCallback(async(b,S)=>{try{let d=await fetch(b,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(S||{})}),X0=await d.json().catch(()=>({}));return{ok:d.ok,...X0}}catch(d){return{ok:!1,error:"Network error — is the project still open?"}}},[]),pG=u.useCallback(async(b,S)=>{let d=await OJ("/_api/git/commit",{message:b,files:S});if(d.ok)await MJ();return d},[OJ,MJ]),pY=u.useCallback(async(b)=>{let S=await OJ("/_api/git/discard",{files:b});if(S.ok)await MJ();return S},[OJ,MJ]),lG=u.useCallback(async()=>{let b=await OJ("/_api/git/push",{});if(b.ok)await MJ(),fJ();return b},[OJ,MJ,fJ]),lY=u.useCallback(async()=>{let b=await OJ("/_api/git/pull",{});if(b.ok)await MJ(),fJ();if(b.conflict&&Array.isArray(b.files)&&b.files.length)z9({file:b.files[0],conflict:!0});return b},[OJ,MJ,fJ]),dG=u.useCallback(async(b)=>{let S=await OJ("/_api/git/resolve",{choice:b});if(S.ok)await MJ(),fJ();return S},[OJ,MJ,fJ]),w4=u.useCallback(async(b)=>{try{let S="/_api/git/log?limit=40"+(b?`&path=${encodeURIComponent(b)}`:""),d=await fetch(S);if(!d.ok)return[];return(await d.json()).entries||[]}catch{return[]}},[]),[cG,Z1]=u.useState(null),H1=u.useCallback(async(b)=>{try{let S="/_api/cloud/history?limit=40"+(b?`&path=${encodeURIComponent(b)}`:""),d=await fetch(S);if(!d.ok)return null;let X0=await d.json();if(!X0?.ok)return null;return Z1({branch:X0.branch??null,project:X0.project??null,hubHost:X0.hubHost??null}),X0.entries||[]}catch{return null}},[]),[z1,K1]=u.useState(!1),[U1,V1]=u.useState(0),iG=u.useCallback(async(b)=>{try{let S="/_api/project/history?limit=40"+(b?`&path=${encodeURIComponent(b)}`:""),d=await fetch(S);if(!d.ok)return"legacy";let X0=await d.json();if(!X0?.ok)return X0?.reason==="legacy"?"legacy":null;return(X0.history||[]).map((K0)=>{let F0=b?"":(K0.canvases||[]).map((I0)=>I0.split("/").pop()).join(", ");return{sha:`r${K0.revision}`,message:[K0.label||K0.kind,F0].filter(Boolean).join(" · "),author:K0.actor,date:new Date(K0.committedAt).toISOString(),accepted:{revision:K0.revision,actionId:K0.actionId,mine:!!K0.mine,undo:K0.kind==="undo"||K0.kind==="redo"}}})}catch{return null}},[]),oG=/^r\d+$/.test(R8?.beforeSha||""),q1=u.useCallback(async(b)=>{if(!oG)return w4(b);let S=await iG(b);return Array.isArray(S)?S:[]},[oG,w4,iG]),hH=u.useCallback(async(b,S)=>{if(!b||!Number.isSafeInteger(S)||S<0)return{ok:!1,error:"Choose a saved project version to restore."};let d=await fetch("/_api/project/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:b,revision:S})}).catch(()=>null),X0=d?await d.json().catch(()=>null):null;if(d?.ok&&X0?.ok)return V1((K0)=>K0+1),X0;return{ok:!1,error:X0?.error}},[]),B1=u.useMemo(()=>{let b={modified:"M",added:"A",deleted:"D",untracked:"U"},S=new Map;if(E0)return S;for(let d of A0?.files||[])S.set(d.path,b[d.status]);return S},[A0,E0]);u.useEffect(()=>{if(E0){X8(null);return}if(A0?.repo===!1)return;fJ();let b=setInterval(fJ,k8?60000:120000);return()=>clearInterval(b)},[E0,A0?.repo,k8,fJ]);let K6=u.useCallback((b,{reveal:S=!0}={})=>{if(S&&b&&b!==o8)d9((d)=>zF(d,J,b));if(Z.current="push",M0(null),A(null),b===V)return;if(N((d)=>{for(let X0 of d)if(X0.path!==b)R0.current.delete(X0.path);return[{path:b}]}),F(b),h0(null),E8(null),b!==o8)_8(b)},[V,J,d9]),E4=u.useCallback((b,S="push")=>{let d=J.flatMap((X0)=>X0.paths||[]).find((X0)=>xW(X0,i0.designRel)===b);if(d&&S5.test(d))K6(d,{reveal:!1});else if(d&&PL(qQ(d)))E(d);else N([]),F(null),A(null),w5({title:"Not here yet",description:`${b} is not in this project (not synced yet?)`,kind:"info"});Z.current=S},[J,i0.designRel,K6,E]),gH=u.useRef(!1);u.useEffect(()=>{if(!Q||i0.cloud===void 0||gH.current)return;gH.current=!0;let b=bV(location,i0.designRel);if(b)E4(b,"none")},[Q,i0.cloud,i0.designRel,E4]),u.useEffect(()=>{if(!Q||i0.cloud===void 0)return;let b=()=>{let S=bV(location,i0.designRel);if(S)E4(S,"none");else Z.current="none",N([]),F(null),A(null)};return window.addEventListener("popstate",b),()=>window.removeEventListener("popstate",b)},[Q,i0.cloud,i0.designRel,E4]),u.useEffect(()=>{let b=M||(V===o8?null:V);if(b===H.current)return;H.current=b;let S=xW(b,i0.designRel);if(Z.current!=="none"&&bV(location,i0.designRel)!==S)history[S?"pushState":"replaceState"](S?{open:S}:null,"",Dg(location,S));Z.current="push"},[V,M,i0.designRel]);let dY=M||(V===o8?null:V),nG=i0.cloud?"cloud":H9()?"native":"local",mH=(b)=>_g({rel:xW(b,i0.designRel),shell:nG,location,linkedHubUrl:n8?.url,project:i0.cloud?K:w8,localUrl:location.origin}),uH=(b=dY)=>{let S=xW(b,i0.designRel);if(S)DY({path:b,rel:S,label:qQ(b)})},N1=u.useCallback((b)=>{if(h0(null),E8(null),x9(),P0((S)=>S+1),b&&b!==o8)_8(b)},[x9]),rG=u.useRef(!1);u.useEffect(()=>{if(rG.current)return;if(!i0.cloud)return;if(new URLSearchParams(location.search).has("open")){rG.current=!0;return}if(B.length>0)return;if(!J.length)return;let b=null;for(let S of J){for(let d of S.paths||[]){if(!S5.test(d))continue;if(/(^|\/)system\//.test(d))continue;b=d;break}if(b)break}if(!b)return;rG.current=!0,K6(b,{reveal:!1})},[i0.cloud,J,B.length,K6]);let SQ=u.useCallback((b)=>{let S=typeof b==="string"?b:void 0;if(S)Y5(S);else if(!t0)Y5();K6(o8)},[t0,Y5,K6]);u.useEffect(()=>{b7({type:"tabs",tabs:B.map((b)=>b.path).filter((b)=>b!==o8)})},[B]),u.useEffect(()=>{if(V&&V!==o8)b7({type:"active",file:V});else if(V===o8)b7({type:"active",file:""});else b7({type:"active",file:""})},[V]);let cY=u.useCallback((b)=>{N((S)=>{let d=S.findIndex((K0)=>K0.path===b);if(d<0)return S;let X0=S.filter((K0)=>K0.path!==b);if(b===V)if(X0.length===0)F(null);else F(X0[Math.max(0,d-1)].path);return X0}),R0.current.delete(b),_8((S)=>S===b?null:S)},[V]);uY.current=(b)=>{if(!b?.rel)return;let S=(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,""),d=`${S}/${b.rel}`;if(b.action==="removed")cY(d);else if(b.action==="moved"&&b.fromRel){let X0=`${S}/${b.fromRel}`;N((K0)=>K0.map((F0)=>F0.path===X0?{...F0,path:d}:F0)),F((K0)=>K0===X0?d:K0),_8((K0)=>K0===X0?null:K0),R0.current.delete(X0)}};let g5=u.useCallback(()=>{if(!V||V===o8){if(V===o8)Y5();return}let b=R0.current.get(V);if(b)b.src=b.src},[V,Y5]),pH=u.useCallback(()=>S9(),[S9]),[F1,lH]=u.useState(!1),aG=u.useRef(!1),sG=u.useCallback(async()=>{if(aG.current)return;aG.current=!0,lH(!0);try{await Promise.all([S9(),new Promise((b)=>setTimeout(b,550))])}finally{aG.current=!1,lH(!1)}},[S9]);u.useEffect(()=>{let b=null,S=()=>{if(b)clearTimeout(b);b=setTimeout(()=>{b=null,pH()},150)};return window.addEventListener("focus",S),()=>{if(window.removeEventListener("focus",S),b)clearTimeout(b)}},[pH]);let L1=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"})}),d=await S.json().catch(()=>({}));if(!S.ok||!d.ok)return{ok:!1,error:d.error||`create failed (${S.status})`};return await S9(),K6(d.file),{ok:!0,file:d.file}}catch(S){return{ok:!1,error:S instanceof Error?S.message:"network error"}}},[S9,K6]),dH=u.useCallback(async()=>{let b=await Q5("New video name");if(!b)return;let d=(await Q5("Size — 1920x1080 (landscape), 1080x1920 (portrait), 1080x1080 (square), or custom WxH","1920x1080")||"1920x1080").toLowerCase().match(/(\d{2,5})\s*[x×]\s*(\d{2,5})/),X0=d?Number(d[1]):1920,K0=d?Number(d[2]):1080,F0=Math.max(1,Math.min(60,Number(await Q5("Frames per second","30"))||30));try{let I0=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:K0})}),p=await I0.json().catch(()=>({}));if(!I0.ok||!p.ok){g8(`New video failed: ${p.error||`error ${I0.status}`}`);return}await S9(),K6(p.file),K9(!0),g8("New video created — drop clips on the timeline to start the cut.",!0)}catch(I0){g8(`New video failed: ${I0 instanceof Error?I0.message:"network error"}`)}},[S9,K6,Q5]),D1=u.useCallback(async()=>{if(!V||V===o8)return;try{let b=await fetch(`/_api/annotations?file=${encodeURIComponent(V)}`),S=b.ok?await b.text():"",d=[];if(S){let p=new DOMParser().parseFromString(S,"image/svg+xml");for(let D0 of p.querySelectorAll('[data-tool="mediaref"]')){let O0=D0.getAttribute("data-src");if(!O0)continue;d.push({src:O0,mediaKind:D0.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(d.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let K0=`${Y4(qQ(V)).replace(/\.tsx$/i,"")} Video`,F0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:K0,kind:"video-comp",clips:d})}),I0=await F0.json().catch(()=>({}));if(!F0.ok||!I0.ok){window.alert(`Assemble failed: ${I0.error||`error ${F0.status}`}`);return}await S9(),K6(I0.file)}catch(b){window.alert(`Assemble failed: ${b instanceof Error?b.message:"network error"}`)}},[V,S9,K6]),tG=u.useCallback(({accept:b,resolveTarget:S})=>{let d=V,X0=c7||void 0,K0=document.createElement("input");K0.type="file",K0.accept=b,K0.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(K0);let F0=()=>{if(K0.isConnected)K0.remove()};window.addEventListener("focus",()=>setTimeout(F0,300),{once:!0}),K0.addEventListener("change",()=>{let I0=K0.files?.[0];if(F0(),!I0)return;let p=`/_api/comp-clips?canvas=${encodeURIComponent(d)}${X0?`&artboardId=${encodeURIComponent(X0)}`:""}`;fetch(p).then((D0)=>D0.json().catch(()=>({}))).then((D0)=>{let O0=S(D0);if(!O0)return g8("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":I0.type||"application/octet-stream"},body:I0}).then((g0)=>g0.json().catch(()=>({}))).then((g0)=>{if(!g0?.path)return g8(`Upload failed: ${g0?.error||"unknown error"}`),null;if(O0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:d,arrayName:O0.arrayRef.arrayName,index:O0.arrayRef.index,field:O0.arrayRef.field,value:g0.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:d,id:O0.cdId,attr:"src",value:g0.path})})})}).then((D0)=>D0?D0.json():null).then((D0)=>{if(D0&&!D0.ok)g8(`Replace refused: ${D0.error||"failed"}`);else if(D0&&D0.ok){if(g8("Media replaced.",!0),D0.seq!=null)Y6(d,D0.seq,"replace media")}}).catch(()=>g8("Replace failed: network error"))}),K0.click()},[V,c7,Y6]),M1=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,H9()&&N.length>0&&D("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.crashLogs,onChange:(l)=>M({...F,crashLogs:l.target.checked})}),D("span",{children:["Crash logs (",N.length,") — ",z("code",{children:N.map((l)=>l.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:o,children:"Send report"})]})]}),Y==="sending"&&z("p",{className:"rb-hint",children:"Sending your report…"}),Y==="done"&&D(Q0,{children:[P?.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(H9())IV(P.issueUrl).catch(()=>navigator.clipboard?.writeText(P.issueUrl));else window.open(P.issueUrl,"_blank","noopener")},children:["report #",P.issueNumber]})," ","on the public Maude issue tracker. Screenshots and logs stay in a private repository only maintainers can open — the issue links to them."]}):D("p",{children:["The bundle is saved locally",P?.fallbackDir?D(Q0,{children:[" ","at ",z("code",{children:P.fallbackDir})]}):null," ","and a prefilled GitHub issue was opened — attach the bundle files there."]}),z("footer",{className:"rb-actions",children:z("button",{type:"button",className:"st-btn rb-primary",onClick: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:v,children:"Save locally & open GitHub"})]})]})]})]})})}var IJ=y8(i8(),1);function cm(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 im(J,X){let Q=cm(J),Y=cm(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 om(J,X){if(!Array.isArray(J))return[];return J.filter((Q)=>Q&&(Q.version==null||im(Q.version,X)))}function nm(J,X){let Q=X;if(Array.isArray(J)){for(let Y of J)if(Y&&Y.version&&im(Y.version,Q))Q=Y.version}return Q}var $E="mdcc-whatsnew-seen",SE="mdcc-whatsnew-toast-dismissed";function yV0(J){return typeof J==="string"&&/^https?:\/\//i.test(J)}function jV0(J){try{let X=localStorage.getItem($E);if(X)return X;localStorage.setItem($E,J)}catch{}return J}function vV0(){try{return localStorage.getItem(SE)}catch{return null}}function rm(J){let[X,Q]=IJ.useState([]),[Y,W]=IJ.useState(J),[G,Z]=IJ.useState(()=>jV0(J)),[H,K]=IJ.useState(()=>vV0()),[U,B]=IJ.useState(!1);IJ.useEffect(()=>{let O=!1,P=()=>{fetch("/_api/whats-new").then(($)=>$.json()).then(($)=>{if(O)return;if(Q(Array.isArray($?.entries)?$.entries:[]),typeof $?.version==="string")W($.version)}).catch(()=>{})};P();let T=()=>P(),R=()=>{if(document.visibilityState==="visible")P()};return window.addEventListener("focus",T),document.addEventListener("visibilitychange",R),()=>{O=!0,window.removeEventListener("focus",T),document.removeEventListener("visibilitychange",R)}},[]);let N=om(X,G),V=N.length>0&&H!==Y&&!U,F=N[0]??null,M=IJ.useCallback(()=>{let O=nm(X,Y);Z(O),K(Y);try{localStorage.setItem($E,O),localStorage.setItem(SE,Y)}catch{}},[X,Y]),A=IJ.useCallback(()=>{K(Y);try{localStorage.setItem(SE,Y)}catch{}},[Y]),E=IJ.useCallback(()=>B(!0),[]),w=IJ.useCallback(()=>{B(!1),M()},[M]);return{entries:X,unseen:N,feedVersion:Y,panelOpen:U,openPanel:E,closePanel:w,showToast:V,toastEntry:F,dismissToast:A,markAllSeen:M}}function am({wn:J}){let X=`whats-new-${J.feedVersion}`;return IJ.useEffect(()=>{if(!J.showToast||!J.toastEntry){hW(X);return}w5({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]),IJ.useEffect(()=>()=>hW(X),[X]),null}function sm({wn:J,onStartTour:X}){let{panelOpen:Q,closePanel:Y}=J;if(IJ.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}),yV0(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 o5=y8(i8(),1),fV0=Object.freeze({dirs:[],sections:{}}),xV0="mdcc-sections-expanded",hV0=250,gV0=3000;function em(J,X){return!!X&&J.dirs.includes(X)}function mV0(J,X){return J.sections[X]===!0}function bE(J,X,Q){if(!X)return J;if(J.dirs.includes(X)===!!Q)return J;let W=Q?[...J.dirs,X].sort():J.dirs.filter((G)=>G!==X);return{...J,dirs:W}}function Ju(J,X,Q){if(!X||J.sections[X]===!!Q)return J;return{...J,sections:{...J.sections,[X]:!!Q}}}function Xu(J,X){return Ju(J,X,!mV0(J,X))}function uV0(J,X){let Q=null;for(let Y of J||[]){let W=Y.fullPath;if(!W||!(X===W||X.startsWith(W+"/")))continue;if(!Q||W.length>Q.fullPath.length)Q=Y}return Q}function zF(J,X,Q,{includeSelf:Y=!1}={}){if(!Q)return J;let W=uV0(X,Q);if(!W)return J;let G=Ju(J,W.label,!0),Z=Q.slice(W.fullPath.length+1);if(!Z)return G;let H=Z.split("/"),K=Y?H.length:H.length-1,U=W.fullPath;for(let B=0;B<K;B++)U=`${U}/${H[B]}`,G=bE(G,U,!0);return G}function yE(J,X,Q){if(!X||!Q||X===Q)return J;let Y=!1,W=J.dirs.map((G)=>{if(G===X)return Y=!0,Q;if(G.startsWith(X+"/"))return Y=!0,Q+G.slice(X.length);return G});return Y?{...J,dirs:[...new Set(W)].sort()}:J}function Qu(J){let X=new Set,Q=(Y,W)=>{for(let G of Object.keys(Y||{})){if(G==="_files")continue;let Z=`${W}/${G}`;X.add(Z),Q(Y[G],Z)}};for(let Y of J||[])if(Y.fullPath)Q(Y.tree,Y.fullPath);return X}function Yu(J,X){let Q=J.dirs.filter((Y)=>X.has(Y));return Q.length===J.dirs.length?J:{...J,dirs:Q}}function tm(J){let X=J&&typeof J==="object"&&!Array.isArray(J)?J:{},Q=Array.isArray(X.dirs)?[...new Set(X.dirs.filter((W)=>typeof W==="string"&&W))].sort():[],Y={};if(X.sections&&typeof X.sections==="object"&&!Array.isArray(X.sections)){for(let[W,G]of Object.entries(X.sections))if(typeof G==="boolean")Y[W]=G}return{dirs:Q,sections:Y}}function pV0(){try{let J=JSON.parse(localStorage.getItem(xV0)||"null");return J&&typeof J==="object"&&!Array.isArray(J)?J:null}catch{return null}}function Wu({fetchImpl:J}={}){let[X,Q]=o5.useState(fV0),[Y,W]=o5.useState(!1),G=J||((...U)=>fetch(...U)),Z=o5.useRef(G);Z.current=G,o5.useEffect(()=>{let U=!1,B=typeof AbortController==="function"?new AbortController:null,N=setTimeout(()=>B?.abort(),gV0);return Z.current("/_api/tree-state",B?{signal:B.signal}:void 0).then((V)=>V.ok?V.json():Promise.reject(Error(`HTTP ${V.status}`))).then((V)=>{if(U)return;let F=tm(V);if(!(V&&typeof V==="object"&&V.sections&&Object.keys(V.sections).length)){let A=pV0();if(A)F=tm({...F,sections:A})}Q(F)}).catch(()=>{}).finally(()=>{if(clearTimeout(N),!U)W(!0)}),()=>{U=!0,clearTimeout(N)}},[]);let H=o5.useRef(!0);o5.useEffect(()=>{if(!Y)return;if(H.current){H.current=!1;return}let U=setTimeout(()=>{try{Z.current("/_api/tree-state",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(X)}).catch(()=>{})}catch{}},hV0);return()=>clearTimeout(U)},[Y,X]);let K=o5.useCallback((U)=>Q((B)=>U(B)),[]);return{state:X,ready:Y,update:K}}var V7=({as:J,size:X=14})=>z(J,{size:X,strokeWidth:1.75,style:{display:"block"}}),F90="mdcc-usage-tour-seen",L90="mdcc-collab-tour-seen",o8="__system__",s90="mdcc-theme",D90="mdcc-show-hidden",M90="maude-cp-mode",O90="mdcc-sidebar-open",A90="mdcc-minimap-visible",_90="mdcc-zoomctl-visible",w90="mdcc-annotations-visible";var sF0=30000;function tF0(J){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(J)}).catch(()=>{})}catch{}}var wT=[{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"}],aK={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",sync:"right",assistant:"right"},E90="mdcc-panel-sides",P90="mdcc-layers-mode";function I90({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]||(wT.find((U)=>U.id===K)||{}).label||K},K))}),Z]})}var S5=/\.(tsx|html?)$/i,k90=(J)=>/\.(tsx|jsx)$/i.test(String(J||"")),eF0=[[/\.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 PL(J){for(let[X,Q]of eF0)if(X.test(J))return Q;return null}function _q(J){return J.replace(/^\.[^/]+\//,"").replace(S5,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}function JL0(J){let X=[];return function Q(Y){for(let W of Y||[])X.push(W?.id??""),Q(W?.children)}(J),X.join(",")}var ET="1.6.11";function NL(J,X){let Q=()=>{try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(J,{body:X})}catch{}};if(H9()){w7("send_notification",{title:J,body:X}).catch(Q);return}Q()}function XL0(){if(typeof window>"u")return"dark";try{let J=localStorage.getItem(s90);if(J==="light"||J==="dark")return J}catch{}return"dark"}function TH(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 T90(J,X){if(typeof window>"u")return X;try{let Q=localStorage.getItem(J);return Q?JSON.parse(Q):X}catch{return X}}function QL0(){return!1}var YL0=[];function qQ(J){return J.split("/").pop()}function g8(J,X=!1,Q){w5({title:J,kind:X?"success":"error",action:Q})}var R90="maude-mode-hint-seen";function DL(J=!1){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(R90)==="1")return}catch{return}if(DL.active)return;DL.active=!0;let X=()=>{DL.active=!1;try{localStorage.setItem(R90,"1")}catch{}document.removeEventListener("keydown",Q,!0)},Q=(Y)=>{if((Y.key==="v"||Y.key==="V")&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey)hW("mode-hint"),X()};if(J)document.addEventListener("keydown",Q,!0);w5({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 Y4(J){return J.replace(S5,"")}function WL0(J){return J.replace(S5,"")}function GL0(J){let X=new Map;for(let G of J){if(!S5.test(G.name))continue;let Z=WL0(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(S5.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 ZL0(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 t90(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=t90(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 ML(J){return(J||[]).filter((X)=>X.status!=="resolved").length}function HL0(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 e90(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 AL({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 zL0={"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 KL0({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(()=>QB(Q,Y),[Y,Q]);if(u.useEffect(()=>{if(G>=K.length)Z(0)},[K.length,G]),!J)return null;let U=(B)=>{X(),B.run()};return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(B)=>{if(B.target===B.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(k9,{name:"search",size:18}),z("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(B)=>W(B.target.value),onKeyDown:(B)=>{if(B.key==="Escape")B.preventDefault(),X();else if(B.key==="ArrowDown")B.preventDefault(),Z((N)=>Math.min(K.length-1,N+1));else if(B.key==="ArrowUp")B.preventDefault(),Z((N)=>Math.max(0,N-1));else if(B.key==="Enter"){B.preventDefault();let N=cb(Q,Y,B.currentTarget.value,G);if(N)U(N)}}}),z(RJ,{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((B,N)=>{let V=B.group&&(N===0||K[N-1].group!==B.group)?z("div",{className:"st-pal-group",children:B.group},"g-"+B.group):null;return D(Q0,{children:[V,D("button",{type:"button",className:"st-pal-item"+(N===G?" is-active":""),onMouseEnter:()=>Z(N),onClick:()=>U(B),children:[z("span",{className:"st-pal-icon",children:z(k9,{name:B.icon,size:15})}),z("span",{className:"st-pal-label",children:B.label}),B.kbd?z("span",{className:"st-pal-kbd",children:z(RJ,{children:B.kbd})}):null]})]},B.id)})})]})})}function k9({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:zL0[J]})}function UL0(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 C90({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 RJ({children:J}){return z("span",{className:"kbd",children:J})}function $90(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 S90({label:J,size:X,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:K,def:U}=X,B=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:(N)=>{let V=N.shiftKey?24:8;if(N.key==="ArrowRight")N.preventDefault(),Z((F)=>F+V*B);else if(N.key==="ArrowLeft")N.preventDefault(),Z((F)=>F-V*B);else if(N.key==="Home")N.preventDefault(),Z(H);else if(N.key==="End")N.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 OT=[{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}],b90={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},VL0=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],Dq=[{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}],qL0="2x",y90=[{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}],BL0="auto",j90=[{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."}],NL0="keep",FL0={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 LL0(J){let X=String(J||"").split(".").pop()?.toLowerCase();return FL0[X]||"application/octet-stream"}function DL0({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),[B,N]=u.useState(null),[V,F]=u.useState(()=>new Set),[M,A]=u.useState({}),[E,w]=u.useState(W?"artboard":"annotation");u.useEffect(()=>{let v=!0;return fetch("/_api/assets").then((g)=>g.json()).then((g)=>{if(!v)return;let l=g.ok?g.assets:[];H(l),A((x)=>{let n={...x};for(let e of l)n[e.path]=e.kind;return n})}).catch(()=>v&&H([])),()=>{v=!1}},[]),u.useEffect(()=>{let v=(g)=>{if(g.key==="Escape")g.stopPropagation(),Q()};return window.addEventListener("keydown",v,!0),()=>window.removeEventListener("keydown",v,!0)},[Q]);let O=Array.from(V).some((v)=>(M[v]||"image")!=="image"),P=!W||O,T=!W?"No artboard on this canvas":O?"Video/audio can only be added as annotations":"";u.useEffect(()=>{if(P&&E==="artboard")w("annotation")},[P,E]);let R=(v)=>{F((g)=>{let l=new Set(g);if(l.has(v))l.delete(v);else l.add(v);return l})},$=async(v)=>{let g=await fetch("/_api/asset",{method:"POST",headers:{"content-type":v.type||"application/octet-stream"},body:v}),l=await g.json().catch(()=>({}));if(g.ok&&l.path)return{ok:!0,path:l.path};return{ok:!1,error:l.error||`upload failed (HTTP ${g.status})`}},C=async(v)=>{if(!v)return;U(!0),N(null);let g=await $(v);if(U(!1),g.ok)X(g.path);else N(g.error)},j=(v)=>{if(typeof v==="string"&&v.startsWith("video/"))return"video";if(typeof v==="string"&&v.startsWith("audio/"))return"audio";return"image"},f=async(v)=>{if(!v.length)return;U(!0),N(null);let g=await Promise.all(v.map((n)=>$(n).then((e)=>({...e,file:n}))));U(!1);let l=g.filter((n)=>n.ok),x=g.length-l.length;if(x>0)N(`${x} of ${g.length} uploads failed`);if(l.length)A((n)=>{let e={...n};for(let s of l)e[s.path]=j(s.file.type);return e}),F((n)=>{let e=new Set(n);for(let s of l)e.add(s.path);return e})},m=async()=>{U(!0),N(null);try{if(Y){let l=(await bh()||[]).map((x)=>new File([new Uint8Array(x.bytes)],x.name,{type:LL0(x.name)}));if(U(!1),l.length)await f(l);return}let v=await cZ();if(v?.bytes){await C(new Blob([new Uint8Array(v.bytes)]));return}}catch(v){N(v?.message||"open failed")}U(!1)},c=()=>{if(H9()){m();return}let v=document.createElement("input");if(v.type="file",v.accept="image/*,video/*",Y)v.multiple=!0;v.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(v);let g=()=>{if(v.isConnected)v.remove()};window.addEventListener("focus",()=>setTimeout(g,300),{once:!0}),v.addEventListener("change",()=>{let l=v.files?Array.from(v.files):[];if(g(),!l.length)return;if(Y)f(l);else C(l[0])}),v.click()},o=(v)=>`/${J}/${v}`;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(v)=>{if(v.target===v.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(k9,{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:c,disabled:K,children:K?"Uploading…":"Upload…"}),B&&z("span",{className:"st-ap-err",children:B})]}),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((v)=>{let g=Y&&V.has(v.path);return D("button",{type:"button",className:"st-ap-cell","data-selected":g?"true":void 0,"aria-pressed":Y?g:void 0,title:`${v.name} · ${Math.max(1,Math.round(v.size/1024))} KB`,onClick:()=>Y?R(v.path):X(v.path),children:[Y&&z("span",{className:"st-ap-check","aria-hidden":"true",children:g?z(k9,{name:"check",size:12}):null}),v.kind==="video"?z("video",{className:"st-ap-thumb",src:o(v.path),muted:!0,playsInline:!0}):z("img",{className:"st-ap-thumb",src:o(v.path),alt:v.name,loading:"lazy"}),z("span",{className:"st-ap-name",children:v.name})]},v.path)})})]}),Y&&V.size>0&&D("div",{className:"st-dialog-ft st-ap-confirm",children:[D("span",{className:"st-ap-count",children:[V.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:P,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"})]}),P&&z("span",{className:"st-ap-dest-note",children:T}),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(V),E),children:"Insert"})]})]})})}function _L(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 ML0({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 B=u.useCallback((w0)=>H==="none"&&!w0.handoff&&w0.format!=="zip"&&!Gy.has(w0.format)||H!=="local"&&w0.format==="canva",[H]),[N,V]=u.useState(J==="handoff"?"shadcn":"png"),[F,M]=u.useState(()=>X&&ob("png",X)?X:jO("png")),[A,E]=u.useState(2),[w,O]=u.useState(qL0),[P,T]=u.useState(!0),[R,$]=u.useState(!1),[C,j]=u.useState(!1),[f,m]=u.useState(!1),[c,o]=u.useState(BL0),[v,g]=u.useState(NL0),[l,x]=u.useState(!0),[n,e]=u.useState(!1),[s,H0]=u.useState(null),[a,z0]=u.useState([]),i=OT.find((w0)=>w0.id===N)||OT[0],q0=i.handoff?[]:vO(i.format),Z0=900,C0=3600,a0=IK(W,QE(W,{artboardId:G})),o0=a0?.durationInFrames||0,J8=a0?.fps||30,P8=i.temporal&&o0>900,n8=i.temporal&&o0>3600;u.useEffect(()=>{if(q0.length&&!q0.includes(F))M(jO(i.format))},[q0,F,i.format]),u.useEffect(()=>{if(H!=="remote")return;fetch("/_api/export-warmup").catch(()=>{})},[H]);let C8=u.useCallback(()=>{fetch("/_api/export-history").then((w0)=>w0.json()).then((w0)=>z0(Array.isArray(w0?.history)?w0.history.slice(0,6):[])).catch(()=>{})},[]);u.useEffect(()=>{C8()},[C8]),u.useEffect(()=>{function w0(A0){if(A0.key==="Escape")A0.preventDefault(),U()}return window.addEventListener("keydown",w0),()=>window.removeEventListener("keydown",w0)},[U]);async function w8(){if(i.handoff){let q8=`/design:handoff ${Q&&Q!==o8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(q8)}catch{}H0({ok:!0,msg:`Copied: ${q8} — run it in Claude Code.`});return}if(B(i)){H0({ok:!1,msg:"This format needs the render service, which this workspace doesn’t have configured."});return}e(!0),H0(null);let w0=i.temporal?{scale:A}:{};if(i.format==="png"){let S0=Dq.find((q8)=>q8.id===w)||Dq[1];if(S0.kind==="dpi")w0.dpi=S0.value;else w0.scale=S0.value}if(i.format==="mp4"||i.format==="webm")w0.audio=l;if(n8)w0.maxFrames=o0;if(i.format==="pdf"){w0.pdfPrint={includeBleed:P,marks:{crop:C,registration:f}};let S0=y90.find((q8)=>q8.id===c)?.value;if(S0!==void 0)w0.dpi=S0;if(v!=="keep")w0.text=v}if(G)w0.artboardId=G;if(Z?.selector)w0.selection=Z;if(Q&&Q!==o8)w0.canvasFile=Q;if(hU.has(i.format)&&HB({exportLane:H,format:i.format,scope:F,artboardId:w0.artboardId})&&typeof K==="function")try{let S0=pO(w0);H0({ok:!0,msg:"Capturing…"});let q8=await K({format:i.format,artboardIds:[w0.artboardId],scale:S0,onProgress:(k8,x8)=>H0({ok:!0,msg:`Capturing ${k8}/${x8}…`})}),X8=await uO(q8,i.format);for(let k8 of X8)_L(k8.name,k8.blob);for(let k8 of X8)await lO({format:i.format,scope:F,filename:k8.name});e(!1),H0({ok:!0,msg:`Saved ${X8.map((k8)=>k8.name).join(", ")} to your downloads.`});return}catch(S0){if(H!=="remote"){H0({ok:!1,msg:`Capture failed: ${S0&&S0.message||S0}`}),e(!1);return}}if(HB({exportLane:H,format:i.format,scope:F})&&i.format==="pptx"&&typeof K==="function")try{H0({ok:!0,msg:"Capturing artboards…"});let S0=Q&&Q!==o8?qQ(Q).replace(/\.[^.]+$/,""):"export",{filename:q8,blob:X8}=await mO({capture:K,name:S0,onProgress:(k8,x8)=>H0({ok:!0,msg:`Capturing ${k8}/${x8}…`}),onAssemble:()=>H0({ok:!0,msg:"Assembling deck…"})});_L(q8,X8),await lO({format:i.format,scope:F,filename:q8}),e(!1),H0({ok:!0,msg:`Saved ${q8} to your downloads.`});return}catch(S0){if(H!=="remote"){H0({ok:!1,msg:`Deck export failed: ${S0&&S0.message||S0}`}),e(!1);return}}if(H==="none"&&hU.has(i.format)){H0({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 S0=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:i.format,scope:F,options:w0})});if(!S0.ok){H0({ok:!1,msg:await S0.text()||`Export failed (${S0.status})`}),e(!1);return}U()}catch(S0){H0({ok:!1,msg:S0&&S0.message?S0.message:String(S0)}),e(!1)}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(w0)=>{if(w0.target===w0.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(k9,{name:"x",size:15})})]}),D("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:Q&&Q!==o8?`Format · ${Y4(qQ(Q))}`:"Format"}),z("div",{className:"st-fmt-grid",children:OT.filter((w0)=>!w0.temporal||Y).map((w0)=>D("button",{type:"button","data-testid":`export-format-${w0.id}`,className:"st-fmt"+(w0.id===N?" is-on":""),disabled:B(w0),title:B(w0)?"Needs the render service — not configured on this workspace":void 0,onClick:()=>{V(w0.id),H0(null)},children:[z(k9,{name:w0.icon,size:16}),z("span",{className:"st-fmt-name",children:w0.label}),z("span",{className:"st-fmt-sub",children:w0.sub})]},w0.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)."]}),!i.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:(w0)=>M(w0.target.value),children:q0.map((w0)=>z("option",{value:w0,children:b90[w0]},w0))})]}),!i.handoff&&i.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:(w0)=>O(w0.target.value),children:Dq.map((w0)=>z("option",{value:w0.id,children:w0.label},w0.id))})]}),!i.handoff&&i.format==="png"&&z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let w0=Dq.find((S0)=>S0.id===w)||Dq[1],A0=w0.kind==="dpi"?w0.value/96:w0.value;return`${w0.label} ≈ ${Math.round(1440*A0)}×${Math.round(900*A0)} for a 1440×900 artboard.`})()}),!i.handoff&&i.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:(w0)=>E(Number(w0.target.value)),children:VL0.map((w0)=>z("option",{value:w0.value,children:w0.label},w0.value))})]}),!i.handoff&&i.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,")."]}),P8&&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: ",o0," frames (≈",Math.round(o0/J8),"s).",n8?` 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."]}),!i.handoff&&i.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:c,onChange:(w0)=>o(w0.target.value),children:y90.map((w0)=>z("option",{value:w0.id,children:w0.label},w0.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:v,onChange:(w0)=>g(w0.target.value),children:j90.map((w0)=>z("option",{value:w0.id,children:w0.label},w0.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:j90.find((w0)=>w0.id===v)?.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:P,onChange:(w0)=>T(w0.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:()=>$((w0)=>!w0),"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:(w0)=>j(w0.target.checked)}),"Crop marks"]}),D("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:f,onChange:(w0)=>m(w0.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.":""]})]}),!i.handoff&&(i.format==="mp4"||i.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:l,onChange:(w0)=>x(w0.target.checked)}),"Export with audio"]})}),i.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."]}),s&&z("div",{className:"callout "+(s.ok?"callout--success":"callout--error"),style:{fontSize:12},"data-testid":"export-status","data-ok":s.ok?"1":"0",children:s.msg}),a.length>0&&D("div",{className:"st-export-recent","data-testid":"export-recent",children:[z("div",{className:"st-rp-hd",children:"Recent"}),a.map((w0,A0)=>D("div",{className:"st-export-recent-row",children:[D("span",{children:[String(w0.format||"").toUpperCase()," ·"," ",b90[w0.scope]||w0.scope]}),z("span",{className:"st-mono",children:w0.filename})]},A0))]})]}),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:n,onClick:w8,children:[z(k9,{name:"download",size:14}),i.handoff?"Copy handoff command":n?"Exporting…":`Export ${i.label}`]})]})]})})}var IL=12,kL=16;function OL0({name:J,depth:X,children:Q,dirPath:Y,drag:W,menu:G,expansion:Z,forceOpen:H}){let K=!!H||!!Z?.isOpen(Y),U=(E)=>{if(H)return;let w=typeof E==="function"?E(K):E;if(w!==K)Z?.setOpen(Y,w)},B=W?W.dropProps(Y,!0,()=>U(!0)):{},N=W?.overDir===Y,V=W?W.dragProps(Y,!0):{},F=W?.draggedPath===Y,M=W?.busyPath===Y,A=D("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${_q(Y)}`,"aria-expanded":K,"aria-dropeffect":W?"move":void 0,"aria-busy":M||void 0,tabIndex:-1,className:"st-row"+(N?" is-drop-target":"")+(F?" is-dragging":"")+(M?" is-busy":""),style:{paddingLeft:IL+X*kL+"px"},onClick:()=>U((E)=>!E),onContextMenu:G?(E)=>G.openAt(E,{kind:"dir",dirPath:Y}):void 0,...V,...B,children:[z("span",{className:"st-row-glyph",children:z(k9,{name:"chevron-right",className:"st-chev"+(K?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:J})]});return z(dz,{label:J,row:A,expanded:K,busy:M,onToggle:()=>U((E)=>!E),actions:G?z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${_q(Y)}`,title:`Folder actions — ${J}`,"aria-label":`Folder actions for ${J}`,"aria-haspopup":"menu",onClick:(E)=>G.openAt(E,{kind:"dir",dirPath:Y}),children:z(AL,{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})}):null,children:K&&Q})}function AL0({name:J,dsName:X,dirPath:Q,depth:Y,active:W,onOpenSystem:G,children:Z,expansion:H,forceOpen:K}){let U=!!K||!!H?.isOpen(Q),B=(N)=>{if(K)return;let V=typeof N==="function"?N(U):N;if(V!==U)H?.setOpen(Q,V)};return z(dz,{label:J,expanded:U,selected:W,onToggle:()=>B((N)=>!N),row:D("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:IL+Y*kL+"px"},children:[z("button",{type:"button",className:"st-ds-chev",onClick:()=>B((N)=>!N),"aria-label":U?"Collapse design system":"Expand design system",title:U?"Collapse":"Expand",children:z(k9,{name:"chevron-right",className:"st-chev"+(U?" is-open":""),size:13})}),D("button",{type:"button",className:"st-ds-open","data-tree-primary":"",tabIndex:-1,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(k9,{name:"folder",size:13})}),z("span",{className:"st-row-name",children:J})]})]}),children:U&&Z})}function wL({file:J,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,onDelete:G,openCount:Z,depth:H,kind:K,sidecar:U,dirty:B,experimentalKind:N,drag:V,menu:F}){let M=J.path===X||J.path===Q,A=S5.test(J.name),E=!A&&K!=="runtime"?PL(J.name):null,w=!A&&!E,O=A?Y4(J.name):J.name,P=A&&typeof G==="function"&&K!=="runtime",T=A&&!U&&K!=="runtime"&&typeof V<"u",R=T?V.dragProps(J.path,!0):{},$=V?.draggedPath===J.path,C=V?.busyPath===J.path,j=T&&typeof F<"u",f=!A&&!!E&&!U&&typeof F<"u",m=typeof F<"u"&&K!=="runtime",c=J.path.split("/").slice(0,-1).join("/"),o=A?"canvas-row-"+J.path.replace(/^\.[^/]+\//,"").replace(S5,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,v=D("button",{type:"button",role:"treeitem","data-testid":o??(f?`file-row-${_q(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:IL+H*kL+"px"},title:J.path+(Z?` — ${Z} open`:w?" (file index only)":""),onClick:()=>{if(A)Y(J.path);else if(E)W?.(J.path)},onPointerEnter:E==="image"?()=>nw(J.path):void 0,onFocus:E==="image"?()=>nw(J.path):void 0,onContextMenu:m?(g)=>F.openAt(g,{kind:"file",path:J.path,dir:c,canMove:j||f,supporting:f,name:J.name}):void 0,...R,children:[z("span",{className:"st-row-glyph",children:z(k9,{name:"file",size:13})}),z("span",{className:"st-row-name",children:O}),N==="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"}),N==="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"}),B&&z("span",{className:"st-git-badge","data-kind":B,title:`Unsaved (${B})`,"aria-label":`Unsaved, ${B}`,children:B}),Z>0&&z("span",{className:"st-row-badge",children:Z})]});return z(dz,{label:O,row:v,selected:M,disabled:w,busy:C,actions:D(Q0,{children:[m&&z("button",{type:"button",className:"st-row-menu-btn"+(P?" has-delete-sibling":""),"data-testid":`tree-row-menu-${_q(J.path)}`,title:`Actions for ${O}`,"aria-label":`Actions for ${O}`,"aria-haspopup":"menu",onClick:(g)=>F.openAt(g,{kind:"file",path:J.path,dir:c,canMove:j||f,supporting:f,name:J.name}),children:z(AL,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})}),P&&z("button",{type:"button",className:"st-row-del",title:`Delete ${O}`,"aria-label":`Delete canvas ${O}`,onClick:(g)=>{g.stopPropagation(),G(J.path,O)},children:z(AL,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})})}function _L0({primary:J,sidecars:X,depth:Q,kind:Y,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,showHidden:B,forceOpen:N,dirtyByPath:V,experimentalKind:F,drag:M,menu:A}){let E=V?.get(J.path),w=X.length>0,[O,P]=u.useState(!1),T=N||O,R=J.path===W;if(!(w&&B))return z(wL,{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):{},f=M?.draggedPath===J.path,m=M?.busyPath===J.path,c=C&&typeof A<"u",o=typeof A<"u"&&Y!=="runtime",v=J.path.split("/").slice(0,-1).join("/"),g=D("button",{type:"button",role:"treeitem","aria-selected":R,"aria-expanded":T,"aria-busy":m||void 0,tabIndex:R?0:-1,className:"st-row st-canvas-row"+(R?" is-sel":"")+(f?" is-dragging":"")+(m?" is-busy":""),style:{paddingLeft:IL+Q*kL+"px"},title:J.path,onClick:(l)=>{if(l.target.closest(".st-canvas-chev")){P((x)=>!x);return}Z(J.path)},onContextMenu:o?(l)=>A.openAt(l,{kind:"file",path:J.path,dir:v,canMove:c}):void 0,...j,children:[z("span",{className:"st-row-glyph st-canvas-chev",onClick:(l)=>{l.stopPropagation(),P((x)=>!x)},children:z(k9,{name:"chevron-right",className:"st-chev"+(T?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:Y4(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 z(dz,{label:Y4(J.name),row:g,selected:R,expanded:T,busy:m,onToggle:()=>P((l)=>!l),actions:o?z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${_q(J.path)}`,title:`Actions for ${Y4(J.name)}`,"aria-label":`Actions for ${Y4(J.name)}`,"aria-haspopup":"menu",onClick:(l)=>A.openAt(l,{kind:"file",path:J.path,dir:v,canMove:c}),children:z(AL,{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})}):null,children:T&&X.map((l)=>z(wL,{file:l,menu:A,activePath:W,previewPath:G,onOpen:Z,onPreview:H,openCount:0,depth:Q+1,kind:Y,sidecar:!0},l.path))})}function J70({node:J,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z=1,kind:H,showHidden:K,search:U,dsFolders:B,activeDsName:N,onOpenSystem:V,onDelete:F,dirtyByPath:M,canvasKinds:A,dirPath:E="",drag:w,menu:O,expansion:P}){let T=Object.keys(J).filter((o)=>o!=="_files").sort(),R=J._files||[],{canvases:$,orphans:C}=u.useMemo(()=>GL0(R),[R]),{mediaOrphans:j,metaOrphans:f}=u.useMemo(()=>{let o=[],v=[];for(let g of C){let l=PL(g.primary.name);(l==="image"||l==="video"||l==="audio"||l==="font"?o:v).push(g)}return{mediaOrphans:o,metaOrphans:v}},[C]),m=!!(U&&U.trim()),c=u.useMemo(()=>{if(!B||Z!==1)return null;let o=new Map;for(let v of B)o.set(v.folder,v);return o},[B,Z]);return D(Q0,{children:[$.map((o)=>{let v=m&&o.sidecars.some((g)=>{let l=U.toLowerCase();return g.name.toLowerCase().includes(l)||g.path.toLowerCase().includes(l)});return z(_L0,{primary:o.primary,sidecars:o.sidecars,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,onDelete:F,openCount:ML(G[o.primary.path]),depth:Z,kind:H,showHidden:K,forceOpen:v,dirtyByPath:M,experimentalKind:A?.[o.primary.path],drag:w,menu:O},o.primary.path)}),j.map((o)=>z(wL,{file:o.primary,menu:O,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,openCount:ML(G[o.primary.path]),depth:Z,kind:H},o.primary.path)),K&&f.map((o)=>z(wL,{file:o.primary,menu:O,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,openCount:ML(G[o.primary.path]),depth:Z,kind:H},o.primary.path)),T.map((o)=>{let v=c?.get(o),g=E?`${E}/${o}`:o,l=z(J70,{node:J[o],activePath:X,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z+1,kind:H,showHidden:K,search:U,activeDsName:N,onOpenSystem:V,onDelete:F,dirtyByPath:M,canvasKinds:A,dirPath:g,drag:w,menu:O,expansion:P});if(v&&V)return z(AL0,{name:o,dsName:v.name,dirPath:g,depth:Z,expansion:P,forceOpen:m,active:X===o8&&v.name===N,onOpenSystem:V,children:l},o);return z(OL0,{name:o,depth:Z,dirPath:g,expansion:P,forceOpen:m,drag:w,menu:w?O:void 0,children:l},o)})]})}var FL={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function wL0(J){if(J.kind==="project")return FL.project;if(J.kind==="runtime")return FL.runtime;if(J.label==="Design system")return FL.ds;if(J.label==="UI kit")return FL.canvas;return{title:J.label.toUpperCase(),pillFromCount:!0}}function EL0({failures:J,cloud:X}){let[Q,Y]=u.useState(!1);u.useEffect(()=>{let G=setTimeout(()=>Y(!0),3000);return()=>clearTimeout(G)},[]);let W=J>0?"The project is taking a while to answer — trying again…":X?"Still loading — a large cloud project can take a few seconds to list.":"Still loading — a large project can take a few seconds to list.";return D("div",{className:"st-tree-loading",role:"status","aria-live":"polite","data-testid":"tree-loading",children:[D("div",{className:"st-tree-loading-head",children:[z("span",{className:"st-canvas-loading-spinner","aria-hidden":"true"}),z("span",{children:"Loading files…"})]}),[64,48,72,40,56,68,44].map((G,Z)=>z("span",{className:"skel st-tree-loading-row",style:{width:`${G}%`,marginLeft:Z%3?22:8},"aria-hidden":"true"},Z)),(Q||J>0)&&z("div",{className:"st-tree-loading-hint",children:W})]})}function PL0({readOnly:J=!1,cloud:X,groups:Q,activePath:Y,previewPath:W,activeDsName:G,onOpen:Z,onPreview:H,onOpenSystem:K,wsConnected:U,search:B,setSearch:N,commentsByFile:V,showHidden:F,sectionsExpanded:M,onToggleSection:A,treeExpansion:E,onNewBoard:w,onDeleteBoard:O,onRefresh:P,refreshing:T,collapsed:R,onCollapse:$,width:C,resizing:j,dirtyByPath:f,project:m,gitBranch:c,remoteSync:o,onGetLatest:v,canvasKinds:g,onMoveCanvas:l,onNewFolder:x,onDeleteFolder:n,onRenameFolder:e,onRenameCanvas:s,onDuplicateCanvas:H0,onDeleteFile:a,syncStatus:z0,onLinkedHub:i,onLocalProject:q0,onOpenLinkedFile:Z0,filesReady:C0,treeLoadFailures:a0=0,onShare:o0,savingIsManaged:J8=!1}){let P8=u.useMemo(()=>{if(!B)return Q;return Q.map((k0)=>({...k0,tree:t90(k0.tree,B),filtered:!!B}))},[Q,B]),n8=Uy(l),C8=Hy(),w8=u.useMemo(()=>{let k0=[];for(let b0 of Q){if(b0.label==="Design system"||b0.kind!=="canvas")continue;let h0=b0.fullPath.replace(/^\.[^/]+\//,"")||b0.fullPath;k0.push({path:b0.fullPath,label:h0});for(let O8 of b0.dirs||[])k0.push({path:O8,label:O8.replace(/^\.[^/]+\//,"")})}return k0},[Q]),w0=C8.state?.extra,A0=w0?.kind==="file"?[{id:"share",label:"Share…",onSelect:()=>{C8.close(),o0(w0.path)}},...s&&/\.tsx$/i.test(w0.path)?[{id:"rename-canvas",label:"Rename…",onSelect:()=>{C8.close();let k0=Y4(w0.path.split("/").pop()),b0=window.prompt("Rename canvas to:",k0);if(b0?.trim()&&b0.trim()!==k0)s(w0.path,b0.trim())}}]:[],...H0&&/\.tsx$/i.test(w0.path)?[{id:"duplicate-canvas",label:"Duplicate",onSelect:()=>{C8.close(),H0(w0.path)}}]:[],...w0.supporting&&s?[{id:"rename-file",label:"Rename…",onSelect:()=>{C8.close();let k0=w0.name??w0.path.split("/").pop(),b0=k0.includes(".")?k0.slice(k0.lastIndexOf(".")):"",h0=b0?k0.slice(0,-b0.length):k0,O8=window.prompt(`Rename ${k0} to:`,h0);if(O8?.trim()&&O8.trim()!==h0)s(w0.path,O8.trim())}}]:[],...w0.canMove?[{id:"move-to",label:"Move to…",onSelect:()=>C8.showMoveTo()}]:[],...w0.supporting&&a?[{id:"delete-file",label:"Delete",destructive:!0,onSelect:()=>{C8.close(),a(w0.path,w0.name??w0.path.split("/").pop())}}]:[]]:w0?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{C8.close();let k0=window.prompt("New folder name:");if(k0?.trim())x(w0.dirPath,k0.trim())}},{id:"rename-folder",label:"Rename folder",onSelect:()=>{C8.close();let k0=w0.dirPath.split("/").pop(),b0=window.prompt("Rename folder to:",k0);if(b0?.trim()&&b0.trim()!==k0)e(w0.dirPath,b0.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{C8.close(),n(w0.dirPath,w0.dirPath.split("/").pop())}}]:[],S0=w0?.kind==="file"||w0?.kind==="supporting"?w8.filter((k0)=>k0.path!==w0.dir):[],[q8,X8]=u.useState(!1),[k8,x8]=u.useState("board"),[N9,m0]=u.useState(""),[R8,z9]=u.useState(""),[N8,B0]=u.useState(!1),t0=u.useMemo(()=>Q.find((k0)=>k0.kind==="canvas"&&k0.label!=="Design system")?.fullPath,[Q]),s0=u.useCallback(async()=>{let k0=N9.trim();if(!k0||N8)return;if(B0(!0),z9(""),k8==="folder"){if(!t0){B0(!1),z9("no canvas group to create a folder in");return}let h0=await x(t0,k0);if(B0(!1),h0?.ok)X8(!1),m0("");else z9(h0?.error||"could not create folder");return}let b0=await w(k0);if(B0(!1),b0?.ok)X8(!1),m0("");else z9(b0?.error||"could not create board")},[N9,N8,w,x,k8,t0]),p8=u.useMemo(()=>{let k0=0;for(let b0 of Q)for(let h0 of b0.paths||[])if(S5.test(h0))k0++;return k0},[Q]),_8=u.useMemo(()=>{let k0=0;for(let b0 of P8)for(let h0 of b0.paths||[])if(S5.test(h0))k0++;return k0},[P8]);return D("nav",{className:"st-sidebar"+(R?" is-collapsed":"")+(j?" is-resizing":""),style:R||!C?void 0:{width:C,flexBasis:C},"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":q8&&k8==="board",onClick:()=>{z9(""),x8("board"),X8((k0)=>k8==="board"?!k0:!0)},children:z(k9,{name:"plus",size:15})}),!J&&t0&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":q8&&k8==="folder",onClick:()=>{z9(""),x8("folder"),X8((k0)=>k8==="folder"?!k0:!0)},children:z(k9,{name:"folder-plus",size:15})}),P&&z("button",{type:"button",className:"st-iconbtn st-refresh"+(T?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":T||void 0,disabled:T,onClick:()=>P(),children:z(k9,{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"}),_8," / ",p8]}),$&&z("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:$,children:z(k9,{name:"panel-left",size:15})})]})]}),q8?D("div",{className:"st-newboard",children:[z("input",{type:"text",autoFocus:!0,placeholder:k8==="folder"?"folder name…":"brief board name…",value:N9,maxLength:60,disabled:N8,"aria-label":k8==="folder"?"New folder name":"New brief board name",onChange:(k0)=>m0(k0.target.value),onKeyDown:(k0)=>{if(k0.key==="Enter")k0.preventDefault(),s0();else if(k0.key==="Escape")k0.preventDefault(),X8(!1),m0(""),z9("")}}),z("button",{type:"button",className:"st-newboard-go",disabled:N8||!N9.trim(),"data-tip":"Create · Enter","aria-label":k8==="folder"?"Create folder":"Create brief board",onClick:s0,children:N8?"…":"↵"})]}):null,R8?z("div",{className:"st-newboard-err",role:"alert",children:R8}):null,z("div",{className:"st-search",children:D("div",{className:"st-search-box",children:[z(k9,{name:"search",size:13}),z("input",{type:"search","data-testid":"canvas-search",placeholder:"Search canvases…",value:B,onChange:(k0)=>N(k0.target.value),onKeyDown:(k0)=>{if(k0.key==="Escape")if(k0.preventDefault(),B)N("");else k0.currentTarget.blur()},"aria-label":"Filter files"}),B?z("button",{className:"st-search-clear",onClick:()=>N(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):z(RJ,{children:"/"})]})}),!C0&&z(EL0,{failures:a0,cloud:X}),z(Ky,{"aria-label":"Project file tree","data-testid":"canvas-list",children:P8.map((k0)=>{if(!F&&!B&&k0.kind==="runtime")return null;let b0=wL0(k0),h0=(k0.paths||[]).filter((i0)=>S5.test(i0)).length,O8=b0.pill||(b0.pillFromDsCount?String(k0.dsFolders?.length||0):null)||(b0.pillFromCount?String(h0||k0.paths?.length||0):null),P0=k0.tree&&Object.keys(k0.tree).length>0,e0=k0.label==="Design system",E8=k0.kind==="project";if(!F&&!B&&E8&&h0===0)return null;let U0=QL0(k0),n0=M[k0.label],D8=!!B||(n0===void 0?U0:n0),e8=!e0&&k0.kind==="canvas"&&!J,L9=e8?n8.dropProps(k0.fullPath,!0):{},l7=n8.overDir===k0.fullPath;return z(dz,{className:"st-tree-section",label:b0.title,expanded:D8,onToggle:()=>A(k0.label,U0),row:D("button",{type:"button",className:"st-tree-sec-hd"+(l7?" is-drop-target":""),"data-testid":`tree-section-${k0.label.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,onClick:()=>A(k0.label,U0),"aria-expanded":D8,"aria-dropeffect":e8?"move":void 0,title:D8?"Collapse section":"Expand section",...L9,children:[z(k9,{name:"chevron-right",className:"st-chev"+(D8?" is-open":""),size:13}),z("span",{className:"st-sec-name",children:b0.title}),O8&&z("span",{className:"st-pill",children:O8})]}),children:D8&&(P0?z(J70,{node:k0.tree,activePath:Y,previewPath:W,onOpen:Z,onPreview:H,commentsByFile:V,depth:1,kind:k0.kind,showHidden:F,search:B,dsFolders:k0.dsFolders,activeDsName:G,onOpenSystem:e0?K:void 0,onDelete:e0||J?void 0:O,dirtyByPath:f,canvasKinds:g,dirPath:k0.fullPath,drag:!e0&&k0.kind==="canvas"&&!J?n8:void 0,menu:C8,expansion:E}):z("div",{className:"st-tree-empty",children:B?"No matches.":"Empty."}))},k0.label)})}),z(zy,{state:C8.state,onClose:C8.close,rootItems:A0,destinations:S0,onPickDestination:(k0)=>l(w0.path,k0)}),z(AE,{project:m,liveBranch:c,remoteSync:o,onGetLatest:v,projectOnly:J8}),X===null?z(vw,{syncStatus:z0,onLinkedHub:i,onLocalProject:q0,onOpenFile:Z0,filesReady:C0}):null,z(mw,{})]})}function IL0({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(k9,{name:"panel-left",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:z(k9,{name:"search",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:X,children:z(k9,{name:"folder",size:15})})]})})}function kL0({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",ET]}),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 AT=[{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 TL0({kbd:J,alt:X}){let Q=(Y,W)=>z("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>z(RJ,{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 RL0({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=AT.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(RJ,{children:"?"})," to open"]})]}),z("div",{className:"so-columns",children:AT.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(TL0,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),D("div",{className:"so-overlay-ft",children:[D("span",{children:["close with ",z(RJ,{children:"Esc"})]}),D("span",{className:"so-count",children:[Q," bindings · ",AT.length," groups"]})]})]})})}var CL0=["File","Edit","View","Selection","Tools","Help"];function X70(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 $L0({panels:J,onToggle:X,onClose:Q,onZoom:Y,hasCanvas:W}){return X70(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(k9,{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(RJ,{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(RJ,{children:G.shortcut})]},G.label))]})}function J1({label:J,left:X,header:Q,items:Y,onAction:W,onClose:G}){return X70(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(RJ,{children:Z.shortcut}):null]},Z.id))]})}function SL0({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"},...H9()?[{id:"collab-tour",label:"How sharing works"}]:[],...H9()?[{id:"quick-setup",label:"Quick setup"}]:[],...H9()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function bL0({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 yL0({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 jL0({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 vL0({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 fL0({activePath:J,sharePath:X,onShare:Q,project:Y,cloud:W,tabsCount:G,openMenu:Z,setOpenMenu:H,commentsPanelOpen:K,onToggleComments:U,changesOpen:B,changesCount:N,onToggleChanges:V,onOpenSystem:F,sidebarOpen:M,onToggleSidebar:A,showHidden:E,onToggleShowHidden:w,onOpenHelp:O,onOpenShortcuts:P,onReportBug:T,onStartTour:R,onStartCollabTour:$,annotationsVisible:C,onToggleAnnotations:j,minimapVisible:f,onToggleMinimap:m,zoomCtlVisible:c,onToggleZoomCtl:o,presentMode:v,onTogglePresent:g,printGuidesVisible:l,onTogglePrintGuides:x,postToActiveCanvas:n,onOpenWhatsNew:e,onOpenReadiness:s,onOpenQuickSetup:H0,onWatchIntro:a,whatsNewCount:z0,exportCenter:i,artboardCount:q0=0,presence:Z0=null,inspectorOpen:C0,inspectorTab:a0,onToggleInspector:o0,autoOpenInspector:J8,onToggleAutoOpenInspector:P8,onOpenLayers:n8,timelineOpen:C8,onToggleTimeline:w8,hasComps:w0=!1,assistantOpen:A0,onToggleAssistant:S0,assistantBusy:q8,assistantUnseen:X8,onNewCanvas:k8,onAssembleVideo:x8,onOpenExport:N9,onOpenSettings:m0,onOpenGenerate:R8,onReload:z9,onCloseCanvas:N8,onInsertArtboard:B0,readOnly:t0=!1}){let s0=J===o8,p8=s0?"SYSTEM":J?"CANVAS":"IDLE",_8=s0?z("b",{children:"design system"}):J?D(Q0,{children:[J.split("/").slice(0,-1).join("/"),"/",z("b",{children:Y4(qQ(J))})]}):z("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),k0=new Set(W?["autoopen"]:["assistant","autoopen"]),b0=[{id:"tree",label:"Project Tree",shortcut:"T",checked:M,disabled:!1},{id:"changes",label:W?"History":N>0?`Changes · ${N} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:B,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:C0&&a0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:C0,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!J8,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:w0?"video":void 0,checked:C8,disabled:!1},...H9()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:A0,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:f,disabled:!J||s0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:c,disabled:!J||s0},{id:"present",label:"Presentation Mode",shortcut:"",checked:v,disabled:!J||s0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:l,disabled:!J||s0}].filter((P0)=>!t0||!k0.has(P0.id)),h0=["file","edit","view","selection","tools","help"];function O8(P0){if(h0.includes(P0))H(Z===P0?null:P0)}return u.useEffect(()=>{if(!Z||!h0.includes(Z))return;let P0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function e0(E8){let U0=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!U0.length)return;let n0=U0.indexOf(document.activeElement);if(E8.key==="ArrowDown")E8.preventDefault(),U0[(n0+1)%U0.length].focus();else if(E8.key==="ArrowUp")E8.preventDefault(),U0[(n0-1+U0.length)%U0.length].focus();else if(E8.key==="Home")E8.preventDefault(),U0[0].focus();else if(E8.key==="End")E8.preventDefault(),U0[U0.length-1].focus();else if(E8.key==="ArrowRight"||E8.key==="ArrowLeft"){E8.preventDefault();let D8=E8.key==="ArrowRight"?1:-1,e8=h0.indexOf(Z);H(h0[(e8+D8+h0.length)%h0.length])}else if(E8.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",e0),()=>{clearTimeout(P0),window.removeEventListener("keydown",e0)}},[Z,H]),D("header",{className:"st-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",role:"menubar","aria-label":"Application menus","data-tour":"menus",children:CL0.map((P0)=>{let e0=P0.toLowerCase(),E8=h0.includes(e0),U0=E8||e0==="help",n0=Z===e0;return z("button",{type:"button",className:"st-menu",role:"menuitem","data-testid":`menu-${e0}`,"data-tour":e0==="help"?"help":void 0,"aria-haspopup":E8?"menu":void 0,"aria-expanded":E8?n0:void 0,onClick:()=>O8(e0),onMouseEnter:()=>{if(Z!==null&&E8)H(e0)},children:P0},e0)})}),Z==="file"&&z(jL0,{readOnly:t0,hasCanvas:!!J,hasSharePath:!!X,onAction:(P0)=>{if(P0==="new")k8?.();else if(P0==="assemble")x8?.();else if(P0==="export")N9?.("export");else if(P0==="share")document.querySelector('[data-testid="menu-file"]')?.focus(),Q?.();else if(P0==="handoff")N9?.("handoff");else if(P0==="generate")R8?.();else if(P0==="settings")m0?.();else if(P0==="reload")z9?.();else if(P0==="close")N8?.()},onClose:()=>H(null)}),Z==="edit"&&z(vL0,{readOnly:t0,hasCanvas:!!J&&!s0,onAction:(P0)=>{if(P0==="undo")n({dgn:"undo"});else if(P0==="redo")n({dgn:"redo"});else if(P0==="deselect-all")n({dgn:"selection-clear"});else if(P0==="select-all-annotations")n({dgn:"annotation-select-all"});else if(P0.startsWith("new-artboard:"))B0?.(P0.slice(13))},onClose:()=>H(null)}),Z==="view"&&z($L0,{panels:b0,onToggle:(P0)=>{if(P0==="tree")A();else if(P0==="changes")V();else if(P0==="comments")U();else if(P0==="hidden")w();else if(P0==="annotate")j();else if(P0==="inspector")o0();else if(P0==="autoopen")P8?.();else if(P0==="timeline")w8?.();else if(P0==="assistant")S0?.();else if(P0==="layers")n8?.();else if(P0==="minimap")m?.();else if(P0==="zoomctl")o?.();else if(P0==="present")g?.();else if(P0==="print-guides")x?.()},onZoom:(P0)=>n({dgn:"zoom",op:P0}),hasCanvas:!!J&&!s0,onClose:()=>H(null)}),Z==="selection"&&z(bL0,{readOnly:t0,onAction:(P0)=>{if(P0==="deselect-all")n({dgn:"selection-clear"});else if(P0==="select-all-annotations")n({dgn:"annotation-select-all"})},onClose:()=>H(null)}),Z==="tools"&&z(yL0,{readOnly:t0,onAction:(P0)=>n({dgn:"tool-set",tool:P0}),onClose:()=>H(null)}),Z==="help"&&z(SL0,{onAction:(P0)=>{if(P0==="shortcuts")P?.();else if(P0==="help")O?.();else if(P0==="report-bug")T?.();else if(P0==="tour")R?.();else if(P0==="collab-tour")$?.();else if(P0==="quick-setup")H0?.();else if(P0==="readiness")s?.();else if(P0==="whatsnew")e?.();else if(P0==="watch-intro")a?.()},onClose:()=>H(null)}),D("div",{className:"st-mb-right","data-tour":"status",children:[Z0?z("div",{className:"st-presence",children:Z0}):null,t0&&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,H9()&&!t0&&z("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":A0?"true":"false","data-busy":q8?"true":"false","data-unseen":X8?"true":"false","aria-label":`Assistant${q8?" — working":X8?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:S0,children:z(k9,{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(k9,{name:"share",size:15})}),i&&z(hm,{center:i}),z("button",{type:"button",className:"st-reportbug","data-testid":"report-bug-toggle","aria-label":"Report a bug","data-tip":"Report a bug",onClick:T,children:z(k9,{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(k9,{name:"megaphone",size:15})}),z("span",{className:"st-stamp",children:p8}),z("span",{className:"st-mb-file",title:J||"",children:_8}),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 xL0({tabs:J,activePath:X,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:K,onIframeLoad:U,canvasError:B,canvasReloadNonce:N,onRetryCanvasLoad:V,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),P=new Set(J.map(($)=>$.path));for(let[$,C]of O.current)if(!P.has(C.path))O.current.delete($);let T=($)=>{let C=IZ($,{...H,canvasToken:void 0}),j=`${$}#${N}|${C}`,f=O.current.get(j);if(!f)f={path:$,src:IZ($,H)},O.current.set(j,f);return f.src},R=B&&B.path===X?"error":X&&X!==o8&&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: ${_K(qQ(E))}`,tabIndex:0,children:z(ng,{path:E,kind:PL(qQ(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",ET," / 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(RJ,{children:"⌘"})," and hover to preview an element, click to select it — ",z(RJ,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",H9()?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===o8)return z("div",{className:"system-view"+($.path===X?" active":""),children:z(iL0,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},$.path);return z("iframe",{ref:(C)=>Q($.path,C),src:T($.path),title:`Canvas: ${$.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}#${N}`)}),K&&K===X&&z(hL0,{path:K,cloud:!!H?.cloud},K),B&&B.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:B.kind==="server"?"Maude's server isn't responding":"This canvas didn't finish loading"}),z("div",{className:"st-canvas-error-body",children:B.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:_K(qQ(B.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:()=>V?.(B.path),children:"Reload canvas"})]})})]})}function hL0({path:J,cloud:X}){let[Q,Y]=u.useState(!1);u.useEffect(()=>{let G=setTimeout(()=>Y(!0),4000);return()=>clearTimeout(G)},[]);let W=_K(qQ(J||"").replace(/\.(tsx|jsx|html?)$/i,""));return z("div",{className:"st-canvas-loading",role:"status","aria-live":"polite","data-testid":"canvas-loading",children:D("div",{className:"st-skel-card",children:[D("div",{className:"st-canvas-loading-head",children:[z("span",{className:"st-canvas-loading-spinner","aria-hidden":"true"}),D("span",{className:"st-canvas-loading-title",children:["Opening ",W,"…"]})]}),z("span",{className:"skel st-skel-thumb","aria-hidden":"true"}),z("span",{className:"skel st-skel-line",style:{width:"72%"},"aria-hidden":"true"}),z("span",{className:"skel st-skel-line",style:{width:"46%"},"aria-hidden":"true"}),z("div",{className:"st-canvas-loading-hint"+(Q?" is-shown":""),children:X?"Still working — the first open of a canvas fetches its images and fonts from cloud storage. It is quicker next time.":"Still working — large canvases take a moment to build."})]})})}var gL0=["color","space","radius","shadow","leading","weight","motion","font","other"],mL0={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function uL0(J){return J==="color"}function pL0({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([...gL0,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return z(Q0,{children:W.map((G)=>{let Z=Y[G],H=uL0(G);return D("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[D("h2",{children:["tokens · ",mL0[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 lL0(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 dL0(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 cL0({tokenGroups:J}){let X=J?.fontsize||[];if(X.length===0)return null;let Q=J?.leading||[],Y=dL0(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=lL0(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 iL0({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:B,availableDesignSystems:N}=J,V=(!W||!W.length)&&(!G||!G.length),F=Array.isArray(N)&&N.length>1,M=B?.name??N?.[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:N.map((A)=>z("option",{value:A.name,children:A.name},A.name))})]}):null,z("span",{className:"sv-loc",children:z("code",{children:Z})})]}),B?.description?z("p",{className:"sv-ds-description",children:B.description}):null,z(pL0,{tokens:H,tokenGroups:K,tokensPath:U}),z(cL0,{tokenGroups:K}),V?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(v90,{title:"preview",items:W,onOpen:X,kind:"preview",cfg:Q}),z(v90,{title:"ui kits",items:G,onOpen:X,kind:"ui_kits",cfg:Q})]})]})}function v90({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:IZ(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 oL0({activePath:J,selected:X,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,syncProject:K,syncOpen:U=!1,onOpenSync:B,changesCount:N=0,unpushed:V=0,savingIsManaged:F=!1,changesOpen:M=!1,onOpenChanges:A,version:E}){let w=J===o8,O=X&&X.selector?X.selector+(X.text?` — "${X.text.slice(0,60)}"`:""):"",P=X&&X.dom_path?X.dom_path.join(" > "):X?X.selector:"",T=W==="dark"?"light":"dark",R=(()=>{let C=lz(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:P,children:O}),z("button",{type:"button",className:"st-sb-sel-clear",onClick:Z,"data-tip":"Clear · Esc inside iframe","data-tip-pos":"top","aria-label":"Clear selection",children:"×"})]}),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":"")+(N>0?" has-changes":V>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":N>0?`${N} unsaved`:V>0?`${V} 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&&(B?z("button",{type:"button",className:"st-sb-slot st-sb-sync st-sb-sync--btn"+(U?" is-open":""),onClick:B,"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 ${T} theme`,"data-tip-pos":"top","aria-label":`Switch to ${T} theme`,children:[z(k9,{name:W==="dark"?"sun":"moon",size:13}),T]})]})}function nL0({commentsByFile:J,filter:X,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:K,width:U,resizing:B}){let N=e90(J),V=Object.keys(J||{}).sort(),F=[];for(let M of V){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((P)=>P.id===O.id)+1}))})}return D("aside",{className:"st-rpanel"+(B?" 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 · ",N.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 · ",N.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 · ",N.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(RJ,{children:"⌘"})," and click an element, then press ",z(RJ,{children:"C"})," — or hold ",z(RJ,{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:Y4(qQ(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:HL0(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(k9,{name:"reopen",size:14})}):z("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(E)=>{E.stopPropagation(),Z(A.id)},children:z(k9,{name:"resolve",size:14})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(E)=>{E.stopPropagation(),K(A.id)},children:z(k9,{name:"x",size:14})})]}):null]})]},A.id))]},M.file))})]})}var rL0={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 aL0({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=rL0[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 sL0({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),jh().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X,children:"Later"})]})}function tL0({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,B=Array.isArray(Z)?[...Z].reverse().find((M)=>M.kind==="cold-start-diverged"):null;if(!K&&!H&&!B&&U===0)return null;let N,V,F;if(H)N="success",V="Synced with hub",F=`${Y}:flash`;else if(K){let M=Z&&Z.length>0?` (${Z.length} conflict notice(s))`:"";if(Y==="offline-long")N="error",V=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${M}`;else N="warn",V=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${M}`;F=`${Y}:offline`}else if(B){if(B.snapshotFailed)N="error",V=`Diverged on ${B.slug}: kept local — the history snapshot FAILED, so the overwrite was refused. Check disk space / .design/_history write access.`;else N="warn",V=`Diverged on ${B.slug}: kept the ${B.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${B.slug}`;F=`diverged:${B.slug}:${B.at}`}else N="warn",V=`${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--${N}`,children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:V}),z("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(F),children:"×"})]})}var eL0=["block","inline-block","flex","inline-flex","grid","inline","none"],f90=["px","%","fr","em","auto","min-content","max-content"];var JD0=["auto","stretch","flex-start","center","flex-end","baseline"];var x90=["300","400","500","600","700","800"],Mq=(J,X)=>J&&Object.hasOwn(J,"previous")?J.previous:X,h90=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],g90=["none","solid","dashed","dotted","double"],m90=["px","rem","em","%","vw","vh","auto"],u90=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),_T={"font-size":{node:z(V7,{as:mV,size:12})},"line-height":{node:z(V7,{as:oV,size:12})},"letter-spacing":{node:z(V7,{as:Q3,size:12})},gap:{node:z(V7,{as:EK,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:z(V7,{as:H3,size:12})},"border-width":{node:z(V7,{as:X3,size:12})}};var p90=["static","relative","absolute","fixed","sticky"],XD0=["normal","italic","oblique"],l90=["none","uppercase","lowercase","capitalize"];var d90=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],QD0=["fill","contain","cover","none","scale-down"];var c90=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],i90=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],$5={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}},sK=null;function EL(J){if(!J)return"";if(/^#[0-9a-f]{6}$/i.test(J))return J.toLowerCase();try{if(!sK)sK=document.createElement("canvas").getContext("2d");if(!sK)return"";sK.fillStyle="#000000",sK.fillStyle=J;let X=sK.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 NY=(J)=>Math.min(1,Math.max(0,J));function LL(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 Oq({r:J,g:X,b:Q}){return`#${[J,X,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function Aq({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 tK({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 N7(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 o90(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 Q70(J,X){return(J?X?.canvasDesignSystems?.[J]:null)||X?.defaultDesignSystem||X?.designSystems?.[0]?.name||null}function YD0(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 Y70(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}`),B=U.ok?await U.text():"";return{name:K.name,...YD0(B)}}catch{return null}})).then((K)=>{if(H)return;let U=K.filter(Boolean);U.sort((B,N)=>B.name===Q?-1:N.name===Q?1:0),Z(U)}),()=>{H=!0}},[W,X,Q]),G}function W70({seed:J,label:X,onApply:Q}){let[Y,W]=u.useState(()=>Aq(LL(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(Aq(LL(J)))},[J]);let U=Oq(tK(Y)),B=(O)=>{O.preventDefault();let P=Z.current?.getBoundingClientRect();if(!P)return;let T=G.current.h,R=(C)=>{W({h:T,s:NY((C.clientX-P.left)/P.width),v:NY(1-(C.clientY-P.top)/P.height)})};R(O);let $=()=>{document.removeEventListener("pointermove",R),document.removeEventListener("pointerup",$),Q(Oq(tK(G.current)))};document.addEventListener("pointermove",R),document.addEventListener("pointerup",$)},N=(O)=>{O.preventDefault();let P=H.current?.getBoundingClientRect();if(!P)return;let{s:T,v:R}=G.current,$=(j)=>{W({h:NY((j.clientX-P.left)/P.width)*360,s:T,v:R})};$(O);let C=()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",C),Q(Oq(tK(G.current)))};document.addEventListener("pointermove",$),document.addEventListener("pointerup",C)},V=(O)=>{let P={...G.current,...O};W(P),Q(Oq(tK(P)))},F=(O)=>{let P=O.shiftKey?0.1:0.02,R={ArrowLeft:[-P,0],ArrowRight:[P,0],ArrowUp:[0,P],ArrowDown:[0,-P]}[O.key];if(!R)return;O.preventDefault(),V({s:NY(G.current.s+R[0]),v:NY(G.current.v+R[1])})},M=(O)=>{let P=O.shiftKey?20:2,R={ArrowLeft:-P,ArrowRight:P}[O.key];if(R==null)return;O.preventDefault(),V({h:Math.min(360,Math.max(0,G.current.h+R))})},A=async()=>{try{let O=window.EyeDropper;if(!O)return;let P=await new O().open();if(P?.sRGBHex)W(Aq(LL(P.sRGBHex))),Q(P.sRGBHex)}catch{}},E=tK(Y),w=(O)=>{let P={...E,...O},T=Aq({r:NY(P.r/255)*255,g:NY(P.g/255)*255,b:NY(P.b/255)*255});W(T),Q(Oq(tK(T)))};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 P=O.target.value;if(/^#?[0-9a-f]{6}$/i.test(P))W(Aq(LL(P)))},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:B,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(k9,{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:N,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:(P)=>w({[O]:NY((Number.parseFloat(P.target.value)||0)/255)*255}),onFocus:(P)=>P.currentTarget.select()}),z("span",{children:O.toUpperCase()})]},O))})]})}function OL({kind:J,groups:X,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:K}){let[U,B]=u.useState(!1),[N,V]=u.useState(null),[F,M]=u.useState("custom"),[A,E]=u.useState(""),w=u.useRef(null),O=u.useRef(null),P=typeof Q==="string"&&/var\(\s*--/.test(Q),T=(e)=>Q===`var(${e})`,R=(e)=>e.replace(/^--/,"").replace(/-/g," "),$=X||[],C=$.reduce((e,s)=>e+(s.names?.length||0),0),j=$.length>1,f=A.trim().toLowerCase(),m=!f?$:$.map((e)=>({...e,names:(e.names||[]).filter((s)=>R(s).toLowerCase().includes(f)||s.toLowerCase().includes(f)||(e.vals?.[s]||"").toLowerCase().includes(f))})).filter((e)=>e.names.length);u.useEffect(()=>{if(!U){E("");return}let e=()=>{let z0=w.current?.getBoundingClientRect();if(!z0)return;let i=224,q0=300,Z0=Math.min(z0.right-i,window.innerWidth-i-8);if(Z0<8)Z0=8;let a0=window.innerHeight-z0.bottom>q0+8?z0.bottom+4:Math.max(8,z0.top-q0-4);V({left:Z0,top:a0,width:i,maxHeight:q0})};e();let s=(z0)=>{if(O.current?.contains(z0.target)||w.current?.contains(z0.target))return;B(!1)},H0=(z0)=>{if(z0.key==="Escape")B(!1)},a=(z0)=>{if(O.current?.contains(z0.target))return;e()};return document.addEventListener("pointerdown",s,!0),document.addEventListener("keydown",H0),window.addEventListener("resize",e),document.addEventListener("scroll",a,!0),()=>{document.removeEventListener("pointerdown",s,!0),document.removeEventListener("keydown",H0),window.removeEventListener("resize",e),document.removeEventListener("scroll",a,!0)}},[U]),u.useEffect(()=>{if(!U||!N||!O.current)return;let e=O.current.getBoundingClientRect(),s=N.left-e.left,H0=N.top-e.top;if(Math.abs(s)>0.5||Math.abs(H0)>0.5)V((a)=>a?{...a,left:a.left+s,top:a.top+H0}:a)},[U,N]);let c=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,o=(e,s,H0)=>{if(H&&e&&e!==H&&H0&&!c.test(H0))Y(H0);else Y(`var(${s})`);B(!1)},v=(e)=>{let s=(e||"").trim();if(s)Y(s)},g=D("div",{className:"st-cp-pop-search",children:[z(k9,{name:"search",size:12}),z("input",{value:A,onChange:(e)=>E(e.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),l=(e)=>e.map((s)=>D("div",{className:"st-cp-pop-group",children:[j?z("div",{className:"st-cp-pop-ds",children:s.ds}):null,z("div",{className:"st-cp-pop-list",children:s.names.map((H0)=>D("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${T(H0)?" is-on":""}`,onClick:()=>o(s.ds,H0,s.vals?.[H0]),children:[z("span",{className:"st-cp-pop-cswatch",style:{background:s.vals?.[H0]||"transparent"},"aria-hidden":"true"}),z("span",{className:"st-cp-pop-name",children:R(H0)}),z("span",{className:"st-cp-pop-val",children:s.vals?.[H0]||""})]},`${s.ds}:${H0}`))})]},s.ds)),x=(e)=>e.map((s)=>D("div",{className:"st-cp-pop-group",children:[j?z("div",{className:"st-cp-pop-ds",children:s.ds}):null,z("div",{className:"st-cp-pop-list",children:s.names.map((H0)=>D("button",{type:"button",className:`st-cp-pop-row${T(H0)?" is-on":""}`,onClick:()=>o(s.ds,H0,s.vals?.[H0]),children:[z("span",{className:"st-cp-pop-name",children:R(H0)}),z("span",{className:"st-cp-pop-val",children:s.vals?.[H0]||""})]},`${s.ds}:${H0}`))})]},s.ds)),n=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"}${P&&!K?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>B((e)=>!e),children:z("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):z("button",{type:"button",ref:w,className:`st-cp-tokbtn${P?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>B((e)=>!e),children:z("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),U&&N?r90.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:N.left,top:N.top,width:N.width,maxHeight:N.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(W70,{seed:Z||EL(Q)||"#000000",onApply:v}):!C?z("div",{className:"st-cp-pop-empty",children:"No color tokens"}):D(Q0,{children:[g,m.length?l(m):n]})]}):!C?z("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):D(Q0,{children:[g,m.length?x(m):n]})}),document.body):null]})}function n90({label:J,tracks:X,editable:Q,onChange:Y}){let W=(K,U)=>{let B=X[K];Y(X.map((N,V)=>V===K?xU.has(U)?{value:0,unit:U}:{value:B.value||1,unit:U}:N))},G=(K,U)=>{Y(X.map((B,N)=>N===K?{...B,value:U}:B))},Z=()=>Y([...X,{value:1,unit:"fr"}]),H=(K)=>Y(X.filter((U,B)=>B!==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 B=xU.has(K.unit);return D("div",{className:"st-cp-gridtrack-row",children:[B?z(JG,{value:K.unit,ariaLabel:`${J} track ${U+1}`,options:f90.map((N)=>({value:N,label:N})),onChange:(N)=>W(U,N)}):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(aN,{value:K.unit,units:f90,ariaLabel:`${J} track ${U+1} unit`,onChange:(N)=>W(U,N)}),onCommit:(N)=>G(U,N)}),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)})]})}var eK={pending:0,waiters:[]};function G70(J){eK.pending+=1;let X=()=>{if(eK.pending-=1,eK.pending===0)for(let Q of eK.waiters.splice(0))Q()};return J.then(X,X),J}function WD0(){return eK.pending===0?Promise.resolve():new Promise((J)=>eK.waiters.push(J))}function GD0({el:J,cfg:X,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let K=!!J.id,U=J.computed||{},[B,N]=u.useState({a:{},c:{},t:{}});u.useEffect(()=>{N({a:{},c:{},t:{}})},[J.id,J.authored,J.customStyles,J.attrs]);let V=(t,M0)=>{let _0={...t||{}};for(let[u0,Q8]of Object.entries(M0))if(Q8===null)delete _0[u0];else _0[u0]=Q8;return _0},F=V(J.authored,B.a),M=V(J.customStyles,B.c),A=V(J.attrs,B.t),E=(t,M0)=>N((_0)=>({..._0,a:{..._0.a,[t]:M0}})),w=(t,M0)=>N((_0)=>({..._0,c:{..._0.c,[t]:M0}})),O=(t,M0)=>N((_0)=>({..._0,t:{..._0.t,[t]:M0}})),P=(X?.designRel||X?.designRoot||".design").replace(/^\/+|\/+$/g,""),T=Q70(J.file,X),R=Y70(X,P,T),$=(t)=>R.map((M0)=>({ds:M0.name,names:M0[t]||[],vals:M0.vals})).filter((M0)=>M0.names.length),[C,j]=u.useState({}),[f,m]=u.useState({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),c=Object.keys(M).length>0||Object.keys(A).length>0;u.useEffect(()=>{if(c)m((t)=>t.Advanced?t:{...t,Advanced:!0})},[J.id,c]);let o=(F.position||N7(U.position)||"static")!=="static";u.useEffect(()=>{if(o)m((t)=>t["d:Position"]?t:{...t,"d:Position":!0})},[J.id,o]);let v=H,[g,l]=u.useState({});async function x(t,M0,_0){j((u0)=>({...u0,[_0]:"saving"}));try{let u0=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(M0)}),Q8=await u0.json().catch(()=>({}));return j((a8)=>({...a8,[_0]:!u0.ok||!Q8.ok?`err:${Q8&&Q8.error||`HTTP ${u0.status}`}`:"saved"})),u0.ok?Q8:null}catch(u0){return j((Q8)=>({...Q8,[_0]:`err:${u0&&u0.message?u0.message:String(u0)}`})),null}}let n=u.useRef(Promise.resolve()),e=(t,M0,_0,u0,Q8,a8,j8)=>{n.current=G70(n.current.then(async()=>{let S8=await x(t,M0,_0);if(!S8?.ok)return;let G9=Object.hasOwn(S8,"previous")?S8.previous:a8;if((G9??null)===(j8??null))return;H0(u0,Q8,G9,j8)}))},s=(t,M0)=>{if(!Q||!J.id)return;Q({id:J.id,artboardId:J.artboardId??null,index:J.index??0,prop:t,value:M0})},H0=(t,M0,_0,u0)=>{Y?.({op:t,canvas:J.file,id:J.id,key:M0,before:_0==null||_0===""?null:_0,after:u0==null||u0===""?null:u0})},a=(t,M0)=>{let _0=(M0||"").trim();if(!K||!_0)return;let u0=F[t]??null;if(_0===(u0??"").trim())return;s(t,_0),E(t,_0),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,value:_0},t,"css",t,u0,_0)},z0=(t,M0)=>{let _0=(M0||"").trim(),u0=t.trim();if(!K||!u0||!_0)return;let Q8=M[u0]??null;s(u0,_0),w(u0,_0),e("/_api/edit-css",{canvas:J.file,id:J.id,property:u0,value:_0},u0,"css",u0,Q8,_0)},i=(t,M0)=>{let _0=(t||"").trim(),u0=(M0||"").trim();if(!K||!_0||!u0)return;let Q8=A[_0]??null;O(_0,u0),e("/_api/edit-attr",{canvas:J.file,id:J.id,attr:_0,value:u0},`@${_0}`,"attr",_0,Q8,u0)},q0=(t)=>{if(!K)return;let M0=F[t]??null;s(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;s(t,null),w(t,null),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,reset:!0},t,"css",t,M0,null)},C0=(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},o0=(t,M0)=>{if(!K)return;let _0=Math.round((t==="width"?J.bounds?.w:J.bounds?.h)||0),u0=tb(t,M0,a0,_0);for(let Q8 of u0.reset)if(F[Q8])q0(Q8);for(let[Q8,a8]of u0.set)a(Q8,a8)},J8=J.parentDisplay==="flex"||J.parentDisplay==="inline-flex",P8=(t)=>{let M0=sb(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(sN,{value:M0,ariaLabel:`${t} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(_0)=>o0(t,_0)})})]},`mode-${t}`)},n8=["flex-start","center","flex-end"],C8=["flex-start","center","flex-end"],w8=["t","c","b"],w0=["l","c","r"],A0=()=>{let t=!(F["flex-direction"]||N7(U["flex-direction"])||"row").startsWith("column"),M0=Math.max(0,n8.indexOf(F["justify-content"]||N7(U["justify-content"])||"flex-start")),_0=F["align-items"]||N7(U["align-items"])||"stretch",u0=_0==="stretch"?1:Math.max(0,C8.indexOf(_0)),[Q8,a8]=t?[M0,u0]:[u0,M0];return w8[a8]+w0[Q8]},S0=(t)=>{let M0=w8.indexOf(t[0]),_0=w0.indexOf(t[1]),u0=!(F["flex-direction"]||N7(U["flex-direction"])||"row").startsWith("column"),[Q8,a8]=u0?[_0,M0]:[M0,_0];a("justify-content",n8[Q8]),a("align-items",C8[a8])},q8=(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")},X8=(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 k8={bound:"token-bound",raw:"raw override",inherit:"inherited"},x8=(t)=>z("span",{className:`st-cp-prov st-cp-prov--${t}`,role:"img","aria-label":k8[t]}),N9=(t,M0)=>{let _0=M0??X8(t),u0=C[t],Q8=typeof u0==="string"&&u0.startsWith("err:")?u0.slice(4):"",a8=Q8?" is-err":u0==="saved"?" is-saved":u0==="saving"?" is-saving":"",j8=!!F[t],S8=Q8?`error: ${Q8}`:j8?`${k8[_0]} · double-click to reset`:k8[_0];return z("button",{type:"button",className:`st-cp-prov st-cp-prov--${_0}${a8}${j8?" is-resettable":""}`,"aria-label":S8,title:S8,tabIndex:j8?0:-1,onDoubleClick:j8?()=>q0(t):void 0,onKeyDown:j8?(G9)=>{if(G9.key==="Backspace"||G9.key==="Delete")G9.preventDefault(),q0(t)}:void 0})},m0=(t,M0,_0,u0)=>{let Q8=_0===void 0&&!F[t],a8=u0??t;return D("div",{className:`st-cp-row${Q8?" is-unset":""}`,children:[N9(t,_0),z("label",{className:"st-cp-label",title:a8,children:a8}),z("div",{className:"st-cp-ctl",children:M0})]},t)},R8={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"]},z9=(t)=>{(R8[t]||[]).forEach((M0)=>{if(F[M0])q0(M0)})},N8=(t,M0)=>{let _0=(R8[t]||[]).some((u0)=>F[u0]);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":!!f[t],onClick:()=>m((u0)=>({...u0,[t]:!u0[t]})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:f[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:()=>z9(t),children:z(V7,{as:rZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${f[t]?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:M0})})]},t)},B0=(t,M0,_0,u0=!0)=>{let Q8=`d:${t}`,a8=f[Q8]===void 0?u0:f[Q8],j8=M0.some((S8)=>F[S8]);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":a8,onClick:()=>m((S8)=>({...S8,[Q8]:!a8})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:a8?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${j8?"":" is-quiet"}`,"aria-label":`reset ${t} to original`,title:`reset ${t}`,disabled:!j8,onClick:()=>M0.forEach((S8)=>{if(F[S8])q0(S8)}),children:z(V7,{as:rZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${a8?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:_0})})]},Q8)},t0=(t)=>z("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!g[t],"aria-label":g[t]?`${t} — fewer options`:`${t} — more options`,title:g[t]?"fewer":"more",onClick:()=>l((M0)=>({...M0,[t]:!M0[t]})),children:g[t]?"▴":"···"}),s0=(t,M0)=>D("select",{className:"st-cp-nsel","aria-label":t,value:M0.includes(F[t])?F[t]:"",onChange:(_0)=>a(t,_0.target.value),children:[z("option",{value:"",disabled:!0,children:N7(U[t])||"—"}),M0.map((_0)=>z("option",{value:_0,children:_0},_0))]}),p8=(t)=>$(t).flatMap((M0)=>(M0.names||[]).map((_0)=>({name:_0,value:M0.vals?.[_0]||""}))),_8=(t,M0)=>z(JE,{value:F[t]||N7(U[t])||M0[0].value,ariaLabel:t,options:M0,onChange:(_0)=>a(t,_0)}),k0=(t,M0,_0={})=>{let u0=Q4(F[t]??""),Q8=u90.has(t),a8=F[t]??"",j8=typeof a8==="string"&&/var\(\s*--/.test(a8),S8=Q8?"":u0.unit&&u0.unit!=="auto"?u0.unit:"px",G9=Number.parseFloat(Q4(N7(U[t])??"").n)||0,y9=u0.n!==""&&u0.n!=null?Number.parseFloat(u0.n)||0:G9,t9=_T[t];return z(tN,{value:j8?a8:y9,tokens:p8(M0),ariaLabel:t,min:_0.min??0,lead:t9?t9.node??t9.t:void 0,unitSlot:Q8?null:z(aN,{units:m90,value:u0.unit||"px",ariaLabel:`${t} unit`,onChange:(q7)=>a(t,q7==="auto"?"auto":`${u0.n||"0"}${q7}`)}),onChange:(q7)=>a(t,typeof q7==="string"?q7:Q8?`${q7}`:`${q7}${S8}`)})},b0=()=>{let t=(Q8)=>Number.parseFloat(Q4(F[Q8]??F["border-radius"]??N7(U[Q8])??N7(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=(Q8)=>{if(Q8.tl===Q8.tr&&Q8.tr===Q8.bl&&Q8.bl===Q8.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((j8)=>{if(F[j8])q0(j8)}),a("border-radius",`${Q8.tl}px`);else a("border-top-left-radius",`${Q8.tl}px`),a("border-top-right-radius",`${Q8.tr}px`),a("border-bottom-left-radius",`${Q8.bl}px`),a("border-bottom-right-radius",`${Q8.br}px`)},u0=_T["border-radius"];return z(Wm,{corners:M0,lead:u0?u0.node??u0.t:void 0,onCorners:_0})},h0=()=>D("div",{className:"st-cp-border",children:[Y9("border-width",null,{fixedUnit:"px"}),D("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:g90.includes(F["border-style"])?F["border-style"]:"",onChange:(t)=>a("border-style",t.target.value),children:[z("option",{value:"",disabled:!0,children:"style"}),g90.map((t)=>z("option",{value:t,children:t},t))]}),z(OL,{kind:"color",groups:$("color"),current:F["border-color"],activeDs:T,swatchBg:U["border-color"]||F["border-color"]||"",seedHex:EL(U["border-color"]||F["border-color"])||"#000000",onPick:(t)=>a("border-color",t),label:"border colour"})]}),O8=()=>{let t=F.transform||N7(U.transform)||"",M0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(t),_0=((M0?Number.parseFloat(M0[1]):0)%360+360)%360,u0=(Q8)=>{let a8=(Q8%360+360)%360,j8=(F.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();a("transform",`${j8?`${j8} `:""}rotate(${a8}deg)`.trim())};return D("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[z(Qm,{value:_0,onChange:u0}),z(ZJ,{value:_0,min:0,max:360,ariaLabel:"rotation",lead:z(V7,{as:rZ}),steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:u0})]})},P0=()=>{let t=F.filter||N7(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:(Q8)=>{let a8=(F.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();a("filter",Q8>0?`${a8?`${a8} `:""}blur(${Q8}px)`.trim():a8||"none")}})},e0=()=>{let t=F.opacity,M0=t!=null&&t!==""?Number.parseFloat(t):Number.parseFloat(N7(U.opacity))||1,_0=Math.round((Number.isNaN(M0)?1:M0)*100);return z(xX,{value:_0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(u0)=>s("opacity",String(u0/100)),onCommit:(u0)=>a("opacity",String(u0/100))},`opacity:${t??""}`)},E8=()=>{let t=Number.parseInt(F["font-weight"]||N7(U["font-weight"])||"400",10)>=600,M0=(F["font-style"]||N7(U["font-style"]))==="italic",_0=/underline/.test(F["text-decoration"]||N7(U["text-decoration"])||"");return z(Jm,{value:{b:t,i:M0,u:_0},ariaLabel:"text style",options:[{value:"b",node:z(V7,{as:nV}),label:"Bold"},{value:"i",node:z(V7,{as:eV}),label:"Italic"},{value:"u",node:z(V7,{as:U3}),label:"Underline"}],onToggle:(u0)=>{if(u0==="b")a("font-weight",t?"400":"700");else if(u0==="i")a("font-style",M0?"normal":"italic");else a("text-decoration",_0?"none":"underline")}})},U0=[{value:"row",node:z(V7,{as:dW}),label:"Row"},{value:"column",node:z(V7,{as:cW}),label:"Column"}],n0=[{value:"flex-start",node:z(V7,{as:lV}),label:"Start"},{value:"center",node:z(V7,{as:uV}),label:"Center"},{value:"flex-end",node:z(V7,{as:pV}),label:"End"},{value:"space-between",node:z(V7,{as:EK}),label:"Space between"}],D8=[{value:"flex-start",node:z(V7,{as:iV}),label:"Start"},{value:"center",node:z(V7,{as:dV}),label:"Center"},{value:"flex-end",node:z(V7,{as:cV}),label:"End"},{value:"stretch",node:z(V7,{as:z3}),label:"Stretch"}],e8=[{value:"left",node:z(V7,{as:i5}),label:"Left"},{value:"center",node:z(V7,{as:nW}),label:"Center"},{value:"right",node:z(V7,{as:rW}),label:"Right"},{value:"justify",node:z(V7,{as:aW}),label:"Justify"}],L9=[{value:"visible",node:z(V7,{as:nZ}),label:"Visible"},{value:"hidden",node:z(V7,{as:aZ}),label:"Hidden"},{value:"scroll",node:z(V7,{as:G3}),label:"Scroll"}],l7=(t,M0)=>{let _0=$(M0);return _0.length?z(OL,{kind:"value",groups:_0,current:F[t],activeDs:T,onPick:(u0)=>a(t,u0),label:`${t} design token`}):null},i0=(t)=>{let M0=t.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===M0)M0.select()})},t7=(t,M0)=>{if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return!1;t.preventDefault();let _0=t.shiftKey?10:1,u0=t.key==="ArrowUp"?1:-1,Q8=(Number.parseFloat(t.currentTarget.value)||0)+u0*_0;return t.currentTarget.value=String(Q8),M0(Q8),!0},$8=(t)=>z("input",{className:"st-cp-fin","aria-label":t,defaultValue:F[t]??"",placeholder:N7(U[t])||"—",onFocus:i0,onKeyDown:(M0)=>{if(M0.key==="Enter")M0.currentTarget.blur()},onBlur:(M0)=>a(t,M0.currentTarget.value)},`${t}:${F[t]??""}`),Y9=(t,M0,_0={})=>{let u0=Q4(F[t]??""),Q8=u90.has(t),a8=Q8?"":_0.fixedUnit||(u0.unit&&u0.unit!=="auto"?u0.unit:"px"),j8=_T[t],S8=Number.parseFloat(Q4(N7(U[t])??"").n)||0,G9=u0.n!==""&&u0.n!=null?Number.parseFloat(u0.n)||0:S8;return D(Q0,{children:[z(ZJ,{value:G9,min:_0.min??0,step:1,ariaLabel:t,lead:j8?j8.node??j8.t:void 0,onCommit:(y9)=>a(t,Q8?`${y9}`:`${y9}${a8}`),unitSlot:Q8||_0.fixedUnit?null:z(aN,{units:m90,value:u0.unit||"px",ariaLabel:`${t} unit`,onChange:(y9)=>a(t,y9==="auto"?"auto":`${u0.n||"0"}${y9}`)})},`${t}:${F[t]??""}`),l7(t,M0)]})},c8=(t)=>{let M0=U[t]||F[t]||"",_0=F[t]??"",u0=typeof _0==="string"&&/var\(\s*--/.test(_0),Q8=u0?_0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):_0;return z(q3,{swatch:z(OL,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:$("color"),current:F[t],activeDs:T,swatchBg:M0,seedHex:EL(U[t]||F[t])||"#000000",onPick:(a8)=>a(t,a8),label:`${t} colour`}),displayValue:Q8,bound:u0,ariaLabel:t,onValue:(a8)=>a(t,a8)})},E0=(t,M0)=>{let _0=null,u0=M0.unitless?"":"px",Q8=(S8)=>M0.unitless?`${S8}`:`${S8}${u0}`,a8=(S8,G9,y9)=>{for(let t9 of G9??[t])y9(t9,Q8(S8))},j8=ew({getBase:()=>_0?.value??"0",min:M0.min??0,step:1,sides:M0.sides,onInput:(S8,G9)=>{if(_0)_0.value=String(S8);if(G9){let y9=_0?.closest(".st-cp-box");for(let t9 of G9){if(t9===t)continue;let q7=y9?.querySelector(`.st-cp-boxv[aria-label="${t9}"]`);if(q7)q7.value=String(S8)}}a8(S8,G9,s)},onCommit:(S8,G9)=>a8(S8,G9,a)});return{onPointerDown:(S8)=>{_0=S8.currentTarget,j8(S8)}}},V8=(t,M0)=>{let _0=F[t],u0=_0!=null&&_0!==""?Q4(_0).n||_0:Q4(N7(U[t])??"").n||"0",Q8=!_0||_0==="0"||_0==="0px"||_0==="auto",a8=t.split("-").pop(),j8=a8==="top"||a8==="bottom"?[`${M0}-top`,`${M0}-bottom`]:[`${M0}-left`,`${M0}-right`],S8=[`${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]}${Q8?" is-zero":""}`,"aria-label":t,defaultValue:u0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...E0(t,{sides:{pair:j8,all:S8}}),onFocus:i0,onKeyDown:(G9)=>{if(t7(G9,(y9)=>a(t,`${y9}px`)))return;if(G9.key==="Enter")G9.currentTarget.blur()},onBlur:(G9)=>{let y9=G9.currentTarget.value.trim();if(!y9)return;let t9=/[a-z%]/i.test(y9)?y9:`${y9}px`;a(t,t9)}},`${t}:${_0??""}`)},f8=(t)=>{let M0=F[t],_0=M0!=null&&M0!==""&&M0!=="auto"?Q4(M0).n||M0:Q4(N7(U[t])??"").n||"",u0=!M0||M0==="auto"||M0==="0"||M0==="0px",Q8=t==="top"||t==="bottom"?["top","bottom"]:["left","right"],a8=["top","right","bottom","left"];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${t[0]}${u0?" is-zero":""}`,"aria-label":t,defaultValue:_0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...E0(t,{sides:{pair:Q8,all:a8},min:-1/0}),onFocus:i0,onKeyDown:(j8)=>{if(t7(j8,(S8)=>a(t,`${S8}px`)))return;if(j8.key==="Enter")j8.currentTarget.blur()},onBlur:(j8)=>{let S8=j8.currentTarget.value.trim();if(!S8)return;let G9=/[a-z%]/i.test(S8)?S8:`${S8}px`;a(t,G9)}},`${t}:${M0??""}`)},r8=Object.entries(M),x9=Object.entries(A),b9=()=>{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"],u0=(t==="img"||t==="video")&&!!J.attrs?.src&&!!W;return{showMedia:_0,canReplace:u0}},s9=(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…"})}),m0("object-fit",s0("object-fit",QD0)),m0("object-position",$8("object-position")),m0("aspect-ratio",D("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:i90.includes(F["aspect-ratio"])?F["aspect-ratio"]:"",onChange:(M0)=>{let _0=M0.target.value;if(a("aspect-ratio",_0),_0&&_0!=="auto"&&F.height)q0("height")},children:[z("option",{value:"",disabled:!0,children:N7(U["aspect-ratio"])||"—"}),i90.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:q8,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(JE,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:z(V7,{as:lW,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:z(V7,{as:sW,size:12}),label:"Designer — Figma vocabulary"}],onChange:v})})]}),Z==="designer"?D(Q0,{children:[B0("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let t=(F.display||N7(U.display)||"").trim();return t==="flex"||t==="inline-flex"?D(Q0,{children:[m0("flex-direction",_8("flex-direction",U0),void 0,"Direction"),m0("align-items",z(Xm,{value:A0(),onChange:S0,ariaLabel:"auto-layout alignment"}),X8("align-items"),"Alignment"),m0("gap",k0("gap","space"),void 0,"Gap"),D("div",{className:"st-cp-modes",children:[P8("width"),P8("height")]}),D("div",{className:"st-cp-box","aria-label":"padding",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[x8(X8("padding-top")),"padding"]}),V8("padding-top","padding"),V8("padding-right","padding"),V8("padding-bottom","padding"),V8("padding-left","padding")]}),z("div",{className:"st-cp-clustermore-row",children:t0("Auto layout")}),g["Auto layout"]?m0("flex-wrap",z(aQ,{checked:/^wrap/.test(F["flex-wrap"]||N7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(_0)=>a("flex-wrap",_0?"wrap":"nowrap")}),X8("flex-wrap"),"Wrap"):null]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>a("display","flex"),children:"+ Auto layout (flex)"})})()),B0("Size",["width","height","min-width","max-width","min-height","max-height"],D(Q0,{children:[m0("width",Y9("width"),void 0,"Width"),m0("height",Y9("height"),void 0,"Height"),z("div",{className:"st-cp-clustermore-row",children:t0("Size")}),g.Size?D(Q0,{children:[m0("min-width",Y9("min-width"),void 0,"Min width"),m0("max-width",Y9("max-width"),void 0,"Max width"),m0("min-height",Y9("min-height"),void 0,"Min height"),m0("max-height",Y9("max-height"),void 0,"Max height")]}):null]})),B0("Position",["position","top","right","bottom","left","z-index"],D(Q0,{children:[m0("position",s0("position",p90),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:[x8(X8("top")),"inset"]}),f8("top"),f8("right"),f8("bottom"),f8("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||N7(U.position)||"static"})]}),(F.position||N7(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:t0("Position")}),g.Position?m0("z-index",Y9("z-index"),void 0,"Layer order"):null]}),!1),B0("Fill",["background-color"],m0("background-color",c8("background-color"),void 0,"Fill")),B0("Stroke",["border-width","border-style","border-color"],m0("border",h0(),X8("border-width"),"Stroke")),B0("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],m0("border-radius",b0(),X8("border-radius"),"Corner radius")),B0("Effects",["box-shadow","filter","mix-blend-mode"],D(Q0,{children:[m0("box-shadow",l7("box-shadow","shadow")||$8("box-shadow"),void 0,"Shadow"),m0("filter",P0(),X8("filter"),"Blur"),m0("mix-blend-mode",s0("mix-blend-mode",c90),void 0,"Blend")]})),B0("Opacity",["opacity"],m0("opacity",e0(),void 0,"Opacity")),B0("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],D(Q0,{children:[m0("font-family",s0("font-family",h90),void 0,"Font"),m0("color",c8("color"),void 0,"Color"),m0("font-size",k0("font-size","type"),void 0,"Size"),m0("font-weight",s0("font-weight",x90),void 0,"Weight"),m0("line-height",Y9("line-height","lh"),void 0,"Line height"),m0("text-align",_8("text-align",e8),void 0,"Align"),z("div",{className:"st-cp-clustermore-row",children:t0("Text")}),g.Text?D(Q0,{children:[m0("letter-spacing",Y9("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),m0("font-style",s0("font-style",XD0),void 0,"Style"),m0("text-transform",s0("text-transform",l90),void 0,"Case"),m0("white-space",s0("white-space",d90),void 0,"Whitespace")]}):null]})),B0("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:[x8(X8("margin-top")),"margin"]}),V8("margin-top","margin"),V8("margin-right","margin"),V8("margin-bottom","margin"),V8("margin-left","margin")]})),(()=>{let{showMedia:t,canReplace:M0}=b9();return t?B0("Media",["object-fit","object-position","aspect-ratio"],s9(M0)):null})()]}):D(Q0,{children:[N8("Layout",(()=>{let t=(F.display||N7(U.display)||"").trim(),M0=t==="flex"||t==="inline-flex",_0=t==="grid"||t==="inline-grid";return D(Q0,{children:[m0("display",s0("display",eL0)),M0?D(Q0,{children:[m0("flex-direction",_8("flex-direction",U0)),m0("flex-wrap",z(aQ,{checked:/^wrap/.test(F["flex-wrap"]||N7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(u0)=>a("flex-wrap",u0?"wrap":"nowrap")}),X8("flex-wrap"))]}):null,M0||_0?D(Q0,{children:[m0("align-items",_8("align-items",D8)),m0("justify-content",_8("justify-content",n0)),m0("gap",k0("gap","space"))]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>a("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let t=(F.display||N7(U.display)||"").trim();if(!(t==="grid"||t==="inline-grid"))return null;let _0=F["grid-template-columns"]||"",u0=F["grid-template-rows"]||"",Q8=fO(_0),a8=fO(u0),j8=Q8.length>0||!_0.trim(),S8=a8.length>0||!u0.trim();return N8("Grid",D(Q0,{children:[j8?z(n90,{label:"Columns",tracks:Q8,editable:K,onChange:(G9)=>a("grid-template-columns",xO(G9))}):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."]}),S8?z(n90,{label:"Rows",tracks:a8,editable:K,onChange:(G9)=>a("grid-template-rows",xO(G9))}):D("div",{className:"st-cp-note",children:["Rows use ",z("code",{children:u0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),N8("Position",D(Q0,{children:[m0("position",s0("position",p90)),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:[x8(X8("top")),"inset"]}),f8("top"),f8("right"),f8("bottom"),f8("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||N7(U.position)||"static"})]}),(F.position||N7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,m0("z-index",Y9("z-index"))]})),(J.parentDisplay==="grid"||J.parentDisplay==="inline-grid")&&N8("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"}),"."]}),m0("grid-column",$8("grid-column")),m0("grid-row",$8("grid-row"))]})),N8("Typography",D(Q0,{children:[m0("font-family",s0("font-family",h90)),m0("color",c8("color")),m0("font-size",k0("font-size","type")),m0("font-weight",s0("font-weight",x90)),m0("line-height",Y9("line-height","lh")),m0("letter-spacing",Y9("letter-spacing",null,{min:-1/0})),m0("text-align",_8("text-align",e8)),m0("font-style",E8(),X8("font-style")),m0("text-transform",s0("text-transform",l90)),m0("white-space",s0("white-space",d90))]})),N8("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:[x8(X8("margin-top")),"margin"]}),V8("margin-top","margin"),V8("margin-right","margin"),V8("margin-bottom","margin"),V8("margin-left","margin"),D("div",{className:"st-cp-boxpad",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[x8(X8("padding-top")),"padding"]}),V8("padding-top","padding"),V8("padding-right","padding"),V8("padding-bottom","padding"),V8("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)]})]})]})})),N8("Size",D(Q0,{children:[D("div",{className:"st-cp-modes",children:[P8("width"),P8("height")]}),m0("width",Y9("width")),m0("height",Y9("height")),m0("min-width",Y9("min-width")),m0("max-width",Y9("max-width")),m0("min-height",Y9("min-height")),m0("max-height",Y9("max-height")),m0("overflow",_8("overflow",L9)),J8?D(Q0,{children:[z("div",{className:"st-cp-subhd",children:"In flex parent"}),m0("align-self",s0("align-self",JD0)),m0("flex-grow",Y9("flex-grow",null,{unitless:!0})),m0("flex-shrink",Y9("flex-shrink",null,{unitless:!0})),m0("flex-basis",Y9("flex-basis"))]}):null]})),(()=>{let{showMedia:t,canReplace:M0}=b9();return t?N8("Media",s9(M0)):null})(),N8("Appearance",D(Q0,{children:[m0("background-color",c8("background-color")),m0("border-radius",b0(),X8("border-radius")),m0("border",h0(),X8("border-width")),m0("box-shadow",l7("box-shadow","shadow")||$8("box-shadow")),m0("filter",P0(),X8("filter")),m0("mix-blend-mode",s0("mix-blend-mode",c90)),m0("opacity",e0()),m0("rotation",O8(),X8("transform")),m0("transform",$8("transform")),m0("transform-origin",$8("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(k9,{name:"x",size:12}),t[0],": ",t[1].slice(4)]}):null})(),N8("Advanced",D("div",{className:"st-cp-advbody",children:[r8.length?D(Q0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),r8.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(k9,{name:"x",size:11})})]},`cs:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add CSS property"}),z(ZD0,{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)=>i(t,_0.currentTarget.value)},`at:${t}:${M0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>C0(t),children:z(k9,{name:"x",size:11})})]},`at:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),z(HD0,{commit:i})]}))]}),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 ZD0({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 HD0({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 zD0={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function KD0(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 UD0=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function Z70({node:J,depth:X,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:B,onRowPointerDown:N,dragState:V,componentMap:F,lockedKeys:M,onToggleLock:A,onRename:E}){let w=`${J.id}:${J.index}`,O=J.children&&J.children.length>0,P=W.has(w),T=!!J.synthetic,R=!T&&F?F[J.id]:null,$=!T&&!!M?.has(w),[C,j]=u.useState(!1),[f,m]=u.useState(""),c=!T&&J.id===Q&&(Y==null||J.index===Y),o=G?.has(w)?G.get(w):!!J.hidden,v=!!B&&!T&&!$,g=()=>{j(!1);let n=f.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!n||n===(J.dcElement??""))return;E?.(J,n)},l=V?.key===w,x=l?{transform:`translate(${V.dx}px, ${V.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"+(c?" is-sel":"")+(o?" is-hidden":"")+(T?" is-group":"")+(R?" is-instance":"")+($?" is-locked":""),style:{paddingLeft:6+X*14,...x},role:"treeitem","aria-selected":T?void 0:c,"aria-expanded":O?!P:void 0,"aria-grabbed":v?l:void 0,tabIndex:0,title:T?`${J.tag} · group (unstamped wrapper)`:`${J.tag} · ${J.type}${E?" · F2 to rename":""}`,"data-layer-key":w,onClick:()=>T?O&&Z(w):H(J),onMouseEnter:()=>!T&&K(J),onMouseLeave:()=>K(null),onPointerDown:v?(n)=>N(n,J,w):void 0,onKeyDown:(n)=>{if(n.key==="Enter"||n.key===" ")if(n.preventDefault(),T)O&&Z(w);else H(J);else if(n.key==="F2"&&E&&!T)n.preventDefault(),m(J.dcElement||J.label||""),j(!0)},children:[O?z("button",{type:"button",className:"st-layer-caret","aria-label":P?"Expand":"Collapse",onClick:(n)=>{n.stopPropagation(),Z(w)},children:P?"▸":"▾"}):z("span",{className:"st-layer-caret","aria-hidden":"true"}),R?z("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:R.root?"◆":"◇"}):z(k9,{name:zD0[J.type]||"box",size:12,className:"st-layer-ticon"}),C?z("input",{className:"st-layer-rename",value:f,autoFocus:!0,"aria-label":`Rename ${J.label}`,onFocus:(n)=>n.target.select(),onChange:(n)=>m(n.target.value),onClick:(n)=>n.stopPropagation(),onPointerDown:(n)=>n.stopPropagation(),onBlur:g,onKeyDown:(n)=>{if(n.stopPropagation(),n.key==="Enter")g();else if(n.key==="Escape")j(!1)}}):z("span",{className:"st-layer-label",onDoubleClick:E&&!T?(n)=>{n.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&&!T?z("button",{type:"button",className:"st-layer-lock","aria-label":$?`Unlock ${J.label}`:`Lock ${J.label}`,"aria-pressed":$,title:$?"Unlock":"Lock",onClick:(n)=>{n.stopPropagation(),A(w)},children:z(k9,{name:$?"lock":"unlock",size:12})}):null,U&&!T?z("button",{type:"button",className:"st-layer-eye","aria-label":o?`Show ${J.label}`:`Hide ${J.label}`,"aria-pressed":o,title:o?"Show":"Hide",onClick:(n)=>{n.stopPropagation(),U(J)},children:z(k9,{name:o?"eye-off":"eye",size:13})}):null]}),O&&!P?J.children.map((n,e)=>z(Z70,{node:n,depth:X+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:B,onRowPointerDown:N,dragState:V,componentMap:F,lockedKeys:M,onToggleLock:A,onRename:E},`${n.id}:${n.index}`)):null]})}function VD0({el:J}){let X=J?.computed||{},Q=J?.authored||{},Y=(U)=>{let B=Q[U];if(B&&/var\(\s*--/.test(B))return B.replace(/^var\(\s*|\s*\)$/g,"");return X[U]||B||""},W=(U,B)=>{let N=X[B]||Q[B];if(!N)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:N},"aria-hidden":"true"}),z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Y(B)})]})]},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 H70(J){if(J.artboardId)return J.artboardId;let X=/^\[data-dc-screen="([^"]+)"\]$/.exec(J.selector||"");return X?X[1]:null}var qD0=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],BD0=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function ND0({el:J,cfg:X,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let K=H70(J),U=(X?.designRel||X?.designRoot||".design").replace(/^\/+|\/+$/g,""),B=Q70(J.file,X),N=Y70(X,U,B),V=(x)=>N.map((n)=>({ds:n.name,names:n[x]||[],vals:n.vals})).filter((n)=>n.names.length),F=(x)=>V(x).flatMap((n)=>(n.names||[]).map((e)=>({name:e,value:n.vals?.[e]||""}))),M=(x)=>{let n=/^var\(\s*(--[\w-]+)\s*\)$/.exec(x||"");if(!n)return x||"";for(let e of N){let s=e.vals?.[n[1]];if(s)return s}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=(x,n)=>{if(!K)return;let e=Number.isFinite(x)&&x>0?Math.round(x):void 0,s=Number.isFinite(n)&&n>0?Math.round(n):void 0;if(e==null&&s==null)return;Q?.(K,e,s)},O=Object.entries($5).find(([,x])=>x.width===A&&x.height===E)?.[0],P=Object.entries($5).find(([,x])=>x.width===A)?.[0],T=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"]??"",f=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 c=(x)=>{if(!K)return;let n=null;if(x==="print"&&!m){let e={paper:"a4"};try{let s=ZB(e);if(s)n={defaults:e,widthPx:s.widthPx,heightPx:s.heightPx}}catch{}}if(G?.(K,x==="digital"?null:x,n),x==="web"&&T)Y?.(K,!1,void 0)},o=(x)=>{if(!K)return;let n={paper:"a4",...m,...x},e;try{e=ZB(n)}catch{return}Q?.(K,e.widthPx,e.heightPx),Z?.(K,n)},v=(x,n)=>{if(!K)return;let e=Number.isFinite(n)?n:E,s=x&&Number.isFinite(e)?Math.round(e):void 0;Y?.(K,x,s)},g=(x)=>{let n=nb(T,x);if(n.kind==="resize")w(null,n.height);else if(n.kind==="promote-to-fixed")v(!0,n.height)},l=(x)=>{if(!K)return;W?.(K,x)};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:(x)=>w(x,null)}),z(ZJ,{value:E??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:T,onCommit:g})]}),z("div",{style:{padding:"0 12px 8px"},children:f==="print"?D("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:m?.paper??"",onChange:(x)=>o({paper:x.currentTarget.value}),children:[z("option",{value:"",disabled:!0,children:"Paper size…"}),GB.map((x)=>D("option",{value:x.id,children:[x.label," — ",x.width,"×",x.height,x.unit]},x.id))]}):f==="web"?D("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:P??"",onChange:(x)=>{let n=$5[x.currentTarget.value];if(n)w(n.width,null)},children:[z("option",{value:"",disabled:!0,children:P?`${$5[P].label} — ≤ ${$5[P].width}px`:"Breakpoint…"}),Object.entries($5).map(([x,n])=>D("option",{value:x,children:[n.label," — ≤ ",n.width,"px breakpoint"]},x))]}):D("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:O??"",onChange:(x)=>{let n=$5[x.currentTarget.value];if(n)w(n.width,n.height)},children:[z("option",{value:"",disabled:!0,children:O?$5[O].label:"Preset size…"}),Object.entries($5).map(([x,n])=>D("option",{value:x,children:[n.label," — ",n.width,"×",n.height]},x))]})}),z("div",{style:{padding:"0 12px 8px"},children:z(sN,{value:T?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(x)=>v(x==="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(JG,{value:f,ariaLabel:"artboard kind",options:BD0.map(([x,n])=>({value:x,label:n})),onChange:c})}),f!=="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:(x)=>{let n=$5[x.currentTarget.value];if(n)H(K,n.width);x.currentTarget.value=""},children:[z("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries($5).map(([x,n])=>D("option",{value:x,children:[n.label," — ",n.width,"px"]},x))]})}):null,f==="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(sN,{value:m?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(x)=>o({orientation:x})})}),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:(x)=>o({bleedMm:x})})})]}):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 x=M(R),n=/var\(\s*--/.test(R),e=n?R.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):R;return z(q3,{swatch:z(OL,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:V("color"),current:R,activeDs:B,swatchBg:x,seedHex:EL(x)||"#000000",onPick:(s)=>l({background:s||null}),label:"artboard background colour"}),displayValue:e,bound:n,ariaLabel:"artboard background",onValue:(s)=>l({background:(s||"").trim()||null})})})(),z(JG,{value:C,ariaLabel:"artboard body layout",options:qD0.map(([x,n])=>({value:x,label:n})),onChange:(x)=>l({layout:x||null})}),D("div",{style:{display:"flex",gap:8},children:[z(tN,{value:/^var\(/.test($)?$:Number.parseFloat($)||0,tokens:F("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(x)=>l({padding:typeof x==="string"?x:x>0?x:null})}),z(tN,{value:/^var\(/.test(j)?j:Number.parseFloat(j)||0,tokens:F("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(x)=>l({gap:typeof x==="string"?x:x>0?x:null})})]})]})]})}var PT=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,FD0=new RegExp(PT.source,"gi");function LD0(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(FD0)||[])],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=PT.exec(`${J.attrs?.src||""} ${X}`);return Y?Y[0]:null}function DD0({testId:J,selected:X,onClose:Q,layersTree:Y,componentMap:W,lockedKeys:G,onToggleLock:Z,onDetachInstance:H,canvasFile:K,onSelectLayer:U,onHoverLayer:B,onReorderLayer:N,layersBusyRef:V,cfg:F,onOptimistic:M,onRecordEdit:A,onReplaceMedia:E,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:P,onSetArtboardKind:T,onSetArtboardPrint:R,onDuplicateArtboard:$,onUndoRedo:C,editScope:j,tab:f,onTabChange:m,width:c,resizing:o,photoSel:v,photoRev:g,onPhotoEdit:l,onPhotoRemoveBackground:x,onPhotoRecordEdit:n,onPhotoUndoRedo:e,layersOnly:s=!1,hideLayersTab:H0=!1,cpMode:a,onSetCpMode:z0}){let[i,q0]=u.useState("inspect"),Z0=s?"layers":f??i,C0=(b0)=>{q0(b0),m?.(b0)},[a0,o0]=u.useState(()=>new Set),[J8,P8]=u.useState(()=>new Map);u.useEffect(()=>{let b0=Array.isArray(X)?X[0]:X,h0=b0?.id;if(!h0||!Y?.nodes)return;let O8=b0.index,P0=null,e0=[];if(function E8(U0,n0){for(let D8 of U0||[]){let e8=`${D8.id}:${D8.index}`;if(!D8.synthetic&&D8.id===h0&&(O8==null||D8.index===O8))return P0=e8,e0.push(...n0),!0;if(D8.children&&D8.children.length&&E8(D8.children,[...n0,e8]))return!0}return!1}(Y.nodes,[]),!P0)return;if(e0.length)o0((E8)=>{let U0=!1,n0=new Set(E8);for(let D8 of e0)if(n0.delete(D8))U0=!0;return U0?n0:E8});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${P0}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[X,Y]);let n8=(b0)=>{let h0=`${b0.id}:${b0.index}`;return J8.has(h0)?J8.get(h0):!!b0.hidden},[C8,w8]=u.useState(null),[w0,A0]=u.useState(""),S0=(b0,h0)=>{if(!K||!b0?.id)return;G70(fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:K,id:b0.id,attr:"data-dc-element",value:h0})}).then((O8)=>O8.json().catch(()=>({}))).then((O8)=>{if(!O8.ok)return;A?.({op:"attr",canvas:K,id:b0.id,key:"data-dc-element",before:b0.dcElement??null,after:h0})}).catch(()=>{}))},q8=N?(b0,h0,O8)=>{if(V?.current)return;if(b0?.synthetic||h0?.synthetic)return;let P0=O8==="before"?`before ${h0.label}`:O8==="after"?`after ${h0.label}`:`into ${h0.label}`;A0(`Moved ${b0.label} ${P0}`),N(b0.id,h0.id,O8,{idIndex:b0.index,refIndex:h0.index})}:void 0,X8=()=>{let b0=[];return function h0(O8,P0,e0){(O8||[]).forEach((E8,U0)=>{if(b0.push({node:E8,depth:P0,parentNode:e0,siblings:O8,pos:U0}),E8.children&&E8.children.length&&!a0.has(`${E8.id}:${E8.index}`))h0(E8.children,P0+1,E8)})}(Y?.nodes,0,null),b0},k8=(b0)=>{if(b0.key!=="ArrowUp"&&b0.key!=="ArrowDown")return;if(!N8)return;let h0=X8(),O8=h0.findIndex((U0)=>U0.node.id===N8.id&&U0.node.index===N8.index);if(O8<0)return;let P0=b0.key==="ArrowDown"?1:-1,e0=h0[O8];if(!b0.altKey){let U0=h0[O8+P0];if(U0)b0.preventDefault(),U?.(U0.node);return}if(!q8||!Array.isArray(e0.siblings))return;b0.preventDefault();let E8=(U0)=>U0&&U0.children&&U0.children.length&&!a0.has(`${U0.id}:${U0.index}`);if(!b0.shiftKey){if(P0<0&&e0.pos>0)q8(e0.node,e0.siblings[e0.pos-1],"before");else if(P0>0&&e0.pos<e0.siblings.length-1)q8(e0.node,e0.siblings[e0.pos+1],"after");return}if(P0>0){let U0=e0.siblings[e0.pos+1];if(U0)q8(e0.node,U0,E8(U0)?"inside-start":"after");else if(e0.parentNode)q8(e0.node,e0.parentNode,"after")}else{let U0=e0.siblings[e0.pos-1];if(U0)q8(e0.node,U0,E8(U0)?"inside-end":"before");else if(e0.parentNode)q8(e0.node,e0.parentNode,"before")}},x8=u.useRef(null),N9=u.useRef(null),m0=(b0,h0,O8)=>{if(!q8||b0.button!==0||b0.metaKey||b0.ctrlKey||b0.shiftKey||b0.altKey)return;if(V?.current)return;let{clientX:P0,clientY:e0}=b0,E8=new Set([O8]);(function c8(E0){(E0.children||[]).forEach((V8)=>{E8.add(`${V8.id}:${V8.index}`),c8(V8)})})(h0);let U0=14,n0=6,D8=[];(function c8(E0,V8){(E0||[]).forEach((f8)=>{let r8=`${f8.id}:${f8.index}`;if(D8.push({node:f8,key:r8,id:f8.id,depth:V8,tag:f8.tag}),f8.children&&f8.children.length&&!a0.has(r8))c8(f8.children,V8+1)})})(Y?.nodes,0);let e8=new Map(D8.map((c8)=>[c8.key,c8])),L9=!1,l7=(c8)=>{if(!L9){if(Math.hypot(c8.clientX-P0,c8.clientY-e0)<4)return;L9=!0}let E0=c8.clientX-P0,V8=c8.clientY-e0,f8=null,r8=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((b9)=>({rect:b9.getBoundingClientRect(),it:e8.get(b9.getAttribute("data-layer-key"))})).filter((b9)=>b9.it&&b9.it.key!==O8);if(r8.length){let b9=r8[0].rect.left,s9=r8[0].rect.right,t=r8.length;for(let t9=0;t9<r8.length;t9++)if(c8.clientY<r8[t9].rect.top+r8[t9].rect.height/2){t=t9;break}let M0=r8[t-1]?.it||null,_0=r8[t]?.it||null,u0=Math.round((c8.clientX-b9-n0)/U0),Q8=M0?M0.depth+(UD0.has(M0.tag)?0:1):0,a8=_0?_0.depth:0,j8=Math.max(a8,Math.min(u0,Q8)),S8=null,G9="before",y9=0;if(!M0){if(_0)S8=_0,G9="before",y9=_0.depth}else if(j8>M0.depth)S8=M0,G9="inside-start",y9=M0.depth+1;else if(j8===M0.depth)S8=M0,G9="after",y9=M0.depth;else{for(let t9=t-1;t9>=0;t9--)if(r8[t9].it.depth===j8){S8=r8[t9].it;break}if(!S8)S8=M0;G9="after",y9=j8}if(S8&&S8.key!==O8&&!E8.has(S8.key)){let t9=M0?r8[t-1].rect.bottom:r8[0].rect.top,q7=b9+n0+y9*U0;f8={refId:S8.id,position:G9,node:S8.node,y:t9,left:q7,w:Math.max(24,s9-q7)}}}let x9={key:O8,node:h0,dx:E0,dy:V8,target:f8};x8.current=x9,w8(x9)},i0=()=>{window.removeEventListener("pointermove",l7),window.removeEventListener("pointerup",$8),window.removeEventListener("keydown",Y9,!0)},t7=()=>{let c8=(E0)=>{E0.preventDefault(),E0.stopImmediatePropagation(),document.removeEventListener("click",c8,!0)};document.addEventListener("click",c8,!0),setTimeout(()=>document.removeEventListener("click",c8,!0),300)},$8=()=>{i0();let c8=x8.current;if(x8.current=null,w8(null),L9&&c8?.target)t7(),q8(c8.node,c8.target.node,c8.target.position)},Y9=(c8)=>{if(c8.key!=="Escape")return;if(c8.preventDefault(),c8.stopImmediatePropagation(),i0(),x8.current=null,w8(null),L9)t7()};window.addEventListener("pointermove",l7),window.addEventListener("pointerup",$8),window.addEventListener("keydown",Y9,!0)},R8=(b0)=>o0((h0)=>{let O8=new Set(h0);if(O8.has(b0))O8.delete(b0);else O8.add(b0);return O8}),z9=(b0)=>{let h0=`${b0.id}:${b0.index}`,O8=n8(b0),P0=!O8;if(P8((e0)=>new Map(e0).set(h0,P0)),M?.({id:b0.id,artboardId:Y?.artboardId??null,index:b0.index,prop:"display",value:P0?"none":null}),!K||!b0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(P0?{canvas:K,id:b0.id,property:"display",value:"none"}:{canvas:K,id:b0.id,property:"display",reset:!0})}).catch(()=>{}),A?.({op:"css",canvas:K,id:b0.id,key:"display",before:O8?"none":null,after:P0?"none":null})},N8=Array.isArray(X)?X[0]:X,B0=v?{asset:v.asset,kind:"annotation-image"}:(()=>{let b0=LD0(N8);return b0?{asset:b0,kind:"artboard-img"}:null})(),t0=B0?.kind==="annotation-image",s0=(b0)=>{if(!(b0.metaKey||b0.ctrlKey)||b0.altKey)return;let h0=b0.key.toLowerCase();if(h0==="z")b0.preventDefault(),e?.(b0.shiftKey?"redo":"undo");else if(h0==="y")b0.preventDefault(),e?.("redo")},p8=t0?"photo":Z0==="photo"&&!B0?"css":Z0,_8=(b0,h0,O8)=>D("button",{type:"button",className:"st-rp-tab"+(p8===b0?" is-active":""),onClick:()=>C0(b0),children:[z(k9,{name:O8,size:14}),h0]}),k0=N8?.bounds||null;return D("aside",{className:"st-rpanel"+(o?" is-resizing":""),style:c?{width:c,flexBasis:c}:void 0,"aria-label":"Inspector","data-tour":"inspector","data-testid":J,children:[D("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:s?{display:"none"}:void 0,children:[t0?_8("photo","Photo","image"):D(Q0,{children:[_8("inspect","Inspect","sliders"),!H0&&_8("layers","Layers","layers"),_8("css","CSS","code"),B0?_8("photo","Photo","image"):null]}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:Q,children:z(k9,{name:"x",size:14})})]}),N8?.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(N8.id,N8.index),children:"Detach"}):null]}):null,z("div",{className:"st-rp-body",children:p8==="photo"&&B0?z("div",{onKeyDown:s0,children:z(Rm,{asset:B0.asset,ColorPicker:W70,StIcon:k9,onEdit:(b0)=>l?.(B0.asset,b0),onRemoveBackground:x,onRecordEdit:(b0,h0)=>n?.(B0.asset,b0,h0)},`${B0.asset}:${g??0}`)}):!N8&&!(p8==="layers"&&Y?.nodes?.length)?z("div",{className:"st-rp-empty",children:D("p",{children:["Press ",z(RJ,{children:"V"}),", then click an element to select it — or ",z(RJ,{children:"⌘"}),"-click straight from Browse."]})}):N8&&p8==="inspect"?D(Q0,{children:[z("div",{className:"st-rp-hd",children:N8.selector||N8.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:k0?Math.round(k0.x):"—",readOnly:!0,"aria-label":"x position"})]}),D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"Y"}),z("input",{value:k0?Math.round(k0.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:k0?Math.round(k0.w):"—",readOnly:!0,"aria-label":"width"})]}),D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"H"}),z("input",{value:k0?Math.round(k0.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:N8.tag||"—"})})]}),N8.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:N8.classes})})]}):null,z(VD0,{el:N8})]}):p8==="layers"?D(Q0,{children:[D("div",{className:"st-rp-hd",children:["Layers",Y?.nodes?.length?"":" · ancestry"]}),Y?.nodes?.length?D(Q0,{children:[q8?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:N9,onKeyDown:k8,children:Y.nodes.map((b0,h0)=>z(Z70,{node:b0,depth:0,selectedId:N8?.id,selectedIndex:N8?.index,collapsed:a0,hiddenOverride:J8,onToggle:R8,onSelect:(O8)=>{U?.(O8),N9.current?.focus()},onHover:(O8)=>B?.(O8),onToggleVisibility:z9,onReorder:q8,onRowPointerDown:m0,dragState:C8,componentMap:W,lockedKeys:G,onToggleLock:Z,onRename:S0},`${b0.id}:${b0.index}`))}),C8?.target?z("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:C8.target.left,top:C8.target.y-1,width:C8.target.w}}):null,z("div",{className:"sr-only",role:"status","aria-live":"polite",children:w0})]}):N8&&Array.isArray(N8.dom_path)&&N8.dom_path.length?N8.dom_path.map((b0,h0)=>D("div",{className:"st-layer"+(h0===N8.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+h0*12},children:[z(k9,{name:"square",size:13}),b0]},h0)):z("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!N8.id&&H70(N8)?z(ND0,{el:N8,cfg:F,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:P,onSetArtboardKind:T,onSetArtboardPrint:R,onDuplicateArtboard:$}):z(GD0,{el:N8,cfg:F,onOptimistic:M,onRecordEdit:A,onReplaceMedia:E,onUndoRedo:C,mode:a,onSetMode:z0})})]})}function MD0(){let[J,X]=u.useState([]),[Q,Y]=u.useState(!1),[W,G]=u.useState(0),Z=u.useRef("push"),H=u.useRef(null),[K,U]=u.useState("Design"),[B,N]=u.useState([]),[V,F]=u.useState(null),[M,A]=u.useState(null),E=u.useCallback((b)=>{Z.current="push",A(b)},[]),[w,O]=u.useState(null),P=u.useRef(null);u.useEffect(()=>{P.current=w},[w]);let[T,R]=u.useState(null);u.useEffect(()=>{let b=Array.isArray(w)?w.length===1?w[0]:null:w,S=b&&typeof b.id==="string"?b.id:null;if(!S||!V){R(null);return}let d=new AbortController,X0=new URLSearchParams({canvas:V,id:S});return fetch(`/_api/edit-scope?${X0}`,{signal:d.signal}).then((K0)=>K0.ok?K0.json():null).then((K0)=>{if(K0?.ok)R(K0)}).catch(()=>{}),()=>d.abort()},[w,V]);let $=u.useRef(0),C=u.useRef([]),j=u.useCallback((b)=>{if(!b?.id||!b.file)return;for(let S of C.current)clearTimeout(S);C.current=[50,450,1200,2500,5000].map((S)=>setTimeout(()=>{let d=P.current,X0=Array.isArray(d)?d[0]:d;if(!X0||X0.id!==b.id||X0.file!==b.file)return;let K0=R0.current.get(b.file);if(!K0?.contentWindow)return;try{K0.contentWindow.postMessage({dgn:"select-by-id",id:b.id,artboardId:b.artboardId??null,index:b.index??0},"*")}catch{}},S))},[]),f=u.useRef([]),m=u.useCallback((b,S)=>{if(!b||!S)return;for(let d of f.current)clearTimeout(d);f.current=[50,450,1200,2500,5000].map((d)=>setTimeout(()=>{let X0=P.current,K0=Array.isArray(X0)?X0[0]:X0;if(!K0||K0.artboardId!==b||K0.file!==S)return;let F0=R0.current.get(S);if(!F0?.contentWindow)return;try{F0.contentWindow.postMessage({dgn:"select-by-id",artboardId:b},"*")}catch{}},d))},[]),c=u.useRef(null),o=u.useRef(null),v=u.useRef(null);v.current=(b,S,d)=>{let X0=c.current;if(!X0||!X0.movedId)return;if(X0.staleSig!=null&&S===X0.staleSig)return;if(!function I0(p){return(p||[]).some((D0)=>D0.id===X0.movedId||I0(D0.children))}(b))return;c.current=null;let F0=V?R0.current.get(V)?.contentWindow:null;if(F0)try{F0.postMessage({dgn:"select-by-id",id:X0.movedId,artboardId:d,index:0},"*")}catch{}};let g=u.useRef(null),l=u.useRef(null),x=u.useRef(null),n=u.useRef(!1),e=u.useRef(null),[s,H0]=u.useState(null),[a,z0]=u.useState(null),i=u.useRef({canvas:null,at:0});u.useEffect(()=>{if(!V||!s)return;let b=Date.now(),S=i.current;if(S.canvas===V&&b-S.at<1500)return;i.current={canvas:V,at:b},fetch(`/_api/component-map?canvas=${encodeURIComponent(V)}`).then((d)=>d.json()).then((d)=>{if(d?.ok&&d.map&&typeof d.map==="object")z0(d.map);else z0(null)}).catch(()=>z0(null))},[V,s]);let[q0,Z0]=u.useState(!1),[C0,a0]=u.useState(null),[o0,J8]=u.useState(null),P8=u.useRef(null);u.useEffect(()=>{let b=o0?.files?.progress;if(!b)return;let S=P8.current;if(P8.current=b.phase,S===null||S===b.phase)return;if(b.phase==="converged"&&(S==="seeding"||S==="paused"))NL("Project synced",`${b.delivered} files are up to date.`);else if(b.phase==="blocked"){let d=(b.blocked??[]).reduce((X0,K0)=>X0+K0.count,0);NL("Sync needs a decision",`${d} file${d===1?"":"s"} could not be sent. Open the Sync panel for the reason.`)}},[o0?.files?.progress]),u.useEffect(()=>{if(typeof document>"u")return;let b=o0?.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},[o0?.files?.progress]);let[n8,C8]=u.useState(null),[w8,w0]=u.useState(null),[A0,S0]=u.useState(null),[q8,X8]=u.useState(null),[k8,x8]=u.useState(!1),[N9,m0]=u.useState(!1),[R8,z9]=u.useState(null),[N8,B0]=u.useState(""),[t0,s0]=u.useState(null),[p8,_8]=u.useState(null),k0=u.useRef(null),[b0,h0]=u.useState(null),[O8,P0]=u.useState(0),[e0,E8]=u.useState(null),U0=$90("maude-sb-w",{min:200,max:420,def:252}),n0=$90("maude-rp-w",{min:260,max:480,def:304}),[D8,e8]=u.useState(null),L9=u.useRef(null);u.useEffect(()=>{if(!D8)return;let b=(d)=>{let X0=L9.current?.getBoundingClientRect();if(!X0)return;if(D8==="sb")U0.setW(d.clientX-X0.left);else n0.setW(X0.right-d.clientX)},S=()=>e8(null);return window.addEventListener("pointermove",b),window.addEventListener("pointerup",S),()=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",S)}},[D8,U0.setW,n0.setW]);let l7=u.useCallback((b)=>{if(k90(b))return;clearTimeout(k0.current),k0.current=setTimeout(()=>{_8((S)=>S===b?null:S)},2500)},[]),[i0,t7]=u.useState({designRel:".design",cloud:void 0}),$8=!!p8&&e0===p8;u.useEffect(()=>{if(!p8)return;let b=p8,S=setTimeout(async()=>{let d="compile";try{if(!(await fetch(`${i0?.canvasOrigin||""}/_health`,{cache:"no-store"})).ok)d="server"}catch{d="server"}h0({path:b,kind:d}),_8((X0)=>X0===b?null:X0)},$8?60000:15000);return()=>clearTimeout(S)},[p8,$8,i0?.canvasOrigin]);let Y9=!!i0.cloud,c8=!i0.cloud&&!!n8?.credentialed,E0=Y9||c8,V8=E0?0:A0?.files?.length||0,f8=u.useRef(E0);f8.current=E0;let r8=!!i0.readOnly,x9=u.useCallback(()=>{fetch("/_config").then((b)=>b.json()).then((b)=>{let S=(b.designRoot||".design").replace(/^\/+|\/+$/g,"");t7((d)=>({...d,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(()=>{x9()},[x9]),u.useEffect(()=>{let b=!1;return fetch("/_sync-status").then((S)=>S.json()).then((S)=>{if(b||!S||S.linked===!1)return;J8(S)}).catch(()=>{}),()=>{b=!0}},[]),u.useEffect(()=>{if(E0){S0(null);return}let b=!1;return fetch("/_api/git/status").then((S)=>S.json()).then((S)=>{if(!b&&S)S0(S)}).catch(()=>{}),()=>{b=!0}},[E0]);let[b9,s9]=u.useState({}),[t,M0]=u.useState(null),[_0,u0]=u.useState(!1),[Q8,a8]=u.useState("open"),[j8,S8]=u.useState(XL0),[G9,y9]=u.useState(()=>{return T90(M90,"advanced")==="designer"?"designer":"advanced"});u.useEffect(()=>{try{localStorage.setItem(M90,JSON.stringify(G9))}catch{}},[G9]);let[t9,q7]=u.useState(null),[CJ,BQ]=u.useState(()=>TH(O90,!0)),[w6,$J]=u.useState(()=>TH(D90,!1)),VJ=Wu(),d9=VJ.update,RH=VJ.state.sections,[S7,qJ]=u.useState(!1),[j9,NQ]=u.useState(!1);u.useEffect(()=>{if(!H9())return;let b=Ph(()=>NQ(!0));return()=>{b.then((S)=>S()).catch(()=>{})}},[]);let[d7,FQ]=u.useState(!1),[LG,x7]=u.useState(!1),[FY,nJ]=u.useState(!1),[O7,SJ]=u.useState(!1),[Q7,B7]=u.useState(!1),{report:E6}=rw(H9()),[qX,BX]=u.useState(!1),[LY,NX]=u.useState(!1),[W4,DY]=u.useState(null),[G4,X6]=u.useState(null),[iX,bJ]=u.useState(!1),[LQ,Z4]=u.useState(!1),[oX,DQ]=u.useState(!1),[r,W0]=u.useState(!1),[L0,v0]=u.useState(()=>T90(E90,aK)),[T0,W8]=u.useState(()=>{try{let b=localStorage.getItem(P90);if(b==="separate"||b==="in-inspector")return b}catch{}return"separate"}),[B8,K9]=u.useState(!1),[J9,FX]=u.useState([]),[b5,z6]=u.useState(0),[rJ,n6]=u.useState(!1),[MY,DG]=u.useState(!1),[v6,k7]=u.useState(!1),[W7,nX]=u.useState(1),[BJ,X9]=u.useState(216),[Y7,f6]=u.useState(null),[r6,MQ]=u.useState([]),[MG,CH]=u.useState([]),[y5,$H]=u.useState([]),[OQ,rX]=u.useState(0),OG=u.useRef(0);u.useEffect(()=>{OG.current=b5},[b5]);let[c7,SH]=u.useState(null),AG=u.useRef(null);u.useEffect(()=>{AG.current=c7},[c7]);let P6=u.useMemo(()=>QE(J9,{artboardId:[c7,Y7],total:OQ}),[J9,c7,Y7,OQ]),aX=u.useRef(null);u.useEffect(()=>{aX.current=P6},[P6]);let OY=u.useMemo(()=>IK(J9,P6)?.fps||30,[J9,P6]),[bH,AY]=u.useState(null),[yH,X1]=u.useState(0),NJ=u.useCallback((b,S)=>{if(/concurrent edit|changed since it was read/i.test(S||""))g8("Timeline changed — reloaded, try again."),X1((d)=>d+1);else g8(`${b}: ${S||"failed"}`)},[]),[LX,_G]=u.useState(!1),[Q1,jH]=u.useState(!1),[Y1,wG]=u.useState(!1),H4=u.useRef(LX);u.useEffect(()=>{if(H4.current=LX,LX){wG(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[LX]);let _Y=u.useCallback(()=>{if(!H4.current||document.hidden)wG(!0),NL("Claude finished","Your assistant turn is ready in Maude.")},[]),wY=u.useRef(0),EY=u.useCallback(()=>{if(!H4.current||document.hidden){wG(!0);let b=Date.now();if(b-wY.current<sF0)return;wY.current=b,NL("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[z4,sX]=u.useState("inspect"),[EG,FJ]=u.useState(null),AQ=u.useRef({undo:[],redo:[]}),[PG,W1]=u.useState(0),[tX,IG]=u.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),vH=u.useRef(tX);u.useEffect(()=>{vH.current=tX;try{localStorage.setItem("maude-auto-open-inspector",tX?"1":"0")}catch{}},[tX]);let _Q=u.useRef(!1);u.useEffect(()=>{_Q.current=oX||_0||k8||N9||LX},[oX,_0,k8,N9,LX]);let K4=u.useRef({open:{},side:aK});K4.current={open:{tree:CJ,layers:r,inspector:oX,comments:_0,changes:k8,sync:N9,assistant:LX},side:L0};let U4=u.useCallback((b,S)=>{if(b==="tree")BQ(S);else if(b==="layers")W0(S);else if(b==="inspector")DQ(S);else if(b==="comments")u0(S);else if(b==="changes")x8(S);else if(b==="sync")m0(S);else if(b==="assistant")_G(S)},[]),kG=u.useCallback((b)=>K4.current.side?.[b]||aK[b],[]),yJ=u.useCallback((b)=>{let S=kG(b);U4(b,!0);for(let d of wT)if(d.id!==b&&kG(d.id)===S)U4(d.id,!1)},[U4,kG]),j5=u.useCallback((b)=>{if(K4.current.open?.[b])U4(b,!1);else yJ(b)},[yJ,U4]),DX=yJ,x6=j5,TG=u.useCallback((b)=>{if(!vH.current)return;if(r8)return;if(!b||!b.id)return;if(_Q.current)return;DX("inspector"),sX("css")},[DX,r8]),PY=u.useCallback(()=>K9((b)=>!b),[]),wQ=rm(ET),jJ=ym({enabled:i0.cloud===null||i0.exportLane==="remote"}),[LJ,RG]=u.useState(!1),[fH,xH]=u.useState(!1);u.useEffect(()=>{if(!H9())return;let b=!0;return Rh().then((S)=>{if(!b)return;if(RG(!!S),!S&&!TH(L90,!1))xH(!0)}).catch(()=>{}),()=>{b=!1}},[]);let EQ=u.useCallback(()=>{xH(!1);try{localStorage.setItem(L90,"1")}catch{}},[]),[V4,IY]=u.useState(null);u.useEffect(()=>{if(!H9())return;let b;return yh((S)=>IY(S&&typeof S==="object"?S:{})).then((S)=>{b=S}).catch(()=>{}),()=>{try{b?.()}catch{}}},[]);let[v5,kY]=u.useState(null),[TY,CG]=u.useState(()=>!TH(F90,!1)),MX=u.useCallback((b)=>{kY(Array.isArray(b)&&b.length?b:null)},[]),G1={setup:(b)=>{if(!b)return;if((b.canvas||b.requireSelection)&&B.length===0)yJ("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [data-testid^="canvas-row-"]')?.click()}catch{}},80);if(b.inspector||b.tab||b.requireSelection)DX("inspector");if(b.tab)sX(b.tab);if(b.changes)DX("changes")}},q4=u.useCallback(()=>{CG(!1);try{localStorage.setItem(F90,"1")}catch{}},[]),[PQ,RY]=u.useState(()=>TH(w90,!0)),[eX,V0]=u.useState(!1),[J5,CY]=u.useState(()=>TH(A90,!1)),[aJ,X5]=u.useState(()=>TH(_90,!1)),[e9,OX]=u.useState(!1),[B4,IQ]=u.useState(!1),[$G,kQ]=u.useState(0),[f5,SG]=u.useState(null),[bG,G8]=u.useState(!1),vJ=u.useRef(null),TQ=u.useRef(null),R0=u.useRef(new Map);u.useEffect(()=>{if(!i0?.canvasToken)return;let b=!1,S=null,d=0,X0=(O0)=>{clearTimeout(S);let g0=Xy(O0);d=Date.now()+g0,S=setTimeout(K0,g0)};async function K0(){let O0=null;try{let K8=await fetch("/_config",{cache:"no-store",credentials:"same-origin"});if(K8.ok)O0=(await K8.json())?.canvasToken}catch{}if(b)return;if(typeof O0!=="string"||!O0){clearTimeout(S),d=Date.now()+30000,S=setTimeout(K0,30000);return}Jy(O0);let g0=F0();if(g0)for(let K8 of R0.current.values())try{K8.contentWindow?.postMessage({dgn:"canvas-cap",t:O0},g0)}catch{}return X0(O0),O0}function F0(){try{return new URL(i0.canvasOrigin,location.href).origin}catch{return null}}let I0=!1;async function p(O0){if(O0.data?.dgn!=="canvas-expired"||O0.origin!==F0()||I0)return;I0=!0;try{let g0=await K0();if(!g0)return;for(let K8 of R0.current.values())if(K8.contentWindow===O0.source)K8.src=Qy(K8.src,g0)}finally{I0=!1}}window.addEventListener("message",p),X0(i0.canvasToken);let D0=()=>{if(document.visibilityState==="visible"&&Date.now()>=d)K0()};return document.addEventListener("visibilitychange",D0),()=>{b=!0,clearTimeout(S),document.removeEventListener("visibilitychange",D0),window.removeEventListener("message",p)}},[i0?.canvasToken,i0?.canvasOrigin]);let b8=u.useCallback((b)=>{let S=V?R0.current.get(V):null;if(!S||!S.contentWindow)return;try{S.contentWindow.postMessage(b,"*")}catch{}},[V]),Y8=u.useRef(0),RQ=u.useCallback(({format:b,artboardIds:S=null,scale:d=1,onProgress:X0,timeoutMs:K0=120000})=>new Promise((F0,I0)=>{let p=V?R0.current.get(V):null;if(!p||!p.contentWindow){I0(Error("no active canvas to capture"));return}let D0=p.contentWindow;Y8.current+=1;let O0=`cap-${Date.now().toString(36)}-${Y8.current}`,g0=!1,K8=(P7,p9)=>{if(g0)return;g0=!0,window.removeEventListener("message",L8),clearTimeout(U6),P7(p9)},L8=(P7)=>{if(P7.source!==D0)return;let p9=P7.data;if(!p9||p9.id!==O0)return;if(p9.dgn==="export-capture-progress")X0?.(p9.current,p9.total);else if(p9.dgn==="export-capture-done")K8(F0,Array.isArray(p9.items)?p9.items:[]);else if(p9.dgn==="export-capture-error")K8(I0,Error(p9.message||"capture failed"))},U6=setTimeout(()=>K8(I0,Error("capture timed out — the canvas did not answer")),K0);window.addEventListener("message",L8);try{D0.postMessage({dgn:"export-capture",id:O0,format:b,artboardIds:S,scale:d},"*")}catch(P7){K8(I0,P7)}}),[V]),N4=u.useCallback((b,S)=>b8({dgn:"photo-preview",asset:b,edit:S}),[b8]),yG=u.useCallback((b,S,d)=>{AQ.current.undo.push({asset:b,before:S,after:d}),AQ.current.redo.length=0},[]),F4=u.useCallback((b)=>{let S=b?AQ.current.redo:AQ.current.undo;if(!S.length)return!1;let d=S.pop();(b?AQ.current.undo:AQ.current.redo).push(d);let X0=(b?d.after:d.before)||{};return N4(d.asset,X0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(d.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(X0)}).catch(()=>{}),W1((K0)=>K0+1),!0},[N4]),jG=u.useCallback(async(b)=>{b8({dgn:"photo-busy",asset:b,busy:!0});try{let S=await fetch(`/${b.replace(/^\/+/,"")}`);if(!S.ok)return null;let d=await S.blob(),{removeBackground:X0}=await Promise.resolve().then(() => (N90(),B90)),K0=await X0(d),F0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":K0.type||"image/png"},body:K0}),I0=await F0.json().catch(()=>({}));if(F0.ok&&I0.path)return{maskAsset:I0.path};return null}catch(S){return console.error("[photo] background removal failed",S),null}finally{b8({dgn:"photo-busy",asset:b,busy:!1})}},[b8]);u.useEffect(()=>{let b=(X0)=>Array.from(X0.dataTransfer?.types??[]).includes("Files"),S=(X0)=>{if(b(X0))X0.preventDefault()},d=(X0)=>{if(b(X0))X0.preventDefault()};return document.addEventListener("dragover",S),document.addEventListener("drop",d),()=>{document.removeEventListener("dragover",S),document.removeEventListener("drop",d)}},[]);let Q6=u.useRef({});Q6.current={open:B8,comps:J9,frame:b5,total:OQ,playing:rJ,compId:P6,muted:v6,loop:MY,sequences:r6,post:b8,canvas:V};let AX=u.useRef({undo:[],redo:[]}),Y6=u.useCallback((b,S,d)=>{if(typeof S!=="number")return;if(AX.current.undo.push({canvas:b,seq:S,label:d}),AX.current.redo=[],AX.current.undo.length>50)AX.current.undo.shift()},[]),vG=u.useCallback((b)=>{let S=AX.current,d=b==="undo"?S.undo:S.redo,X0=b==="undo"?S.redo:S.undo,K0=Q6.current.canvas,F0=-1;for(let p=d.length-1;p>=0;p--)if(d[p].canvas===K0){F0=p;break}if(F0<0){g8(b==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let I0=d[F0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:I0.canvas,seq:I0.seq,dir:b})}).then((p)=>p.json().catch(()=>({}))).then((p)=>{if(d.splice(F0,1),p?.ok)X0.push(I0),g8(`${b==="undo"?"Undid":"Redid"}: ${I0.label}`,!0);else g8(`${b==="undo"?"Undo":"Redo"} skipped: ${p?.error||"failed"}`)}).catch(()=>g8(`${b==="undo"?"Undo":"Redo"} failed: network error`))},[]),I6=u.useCallback((b,S)=>{let d=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?d.find((X0)=>X0.stableId===S.stableId):null)||(Number.isInteger(S.index)?d[S.index]:null)||null;if(typeof S==="string")return d.find((X0)=>X0.stableId===S)||null;return d[S]||null},[]),$Y=u.useCallback((b)=>{let S=Q6.current.canvas;if(!S||S===o8)return;let d=AG.current||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(S)}${d?`&artboardId=${encodeURIComponent(d)}`:""}`;fetch(X0).then((K0)=>K0.json().catch(()=>({}))).then((K0)=>{let F0=I6(K0,b);if(!F0?.stableId)return null;return fetch("/_api/remove-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:S,artboardId:d,stableId:F0.stableId,contentHash:F0.contentHash})})}).then((K0)=>K0?K0.json():null).then((K0)=>{if(K0&&!K0.ok)console.warn("[remove-clip]",K0.error||"failed"),NJ("Remove refused",K0.error);else if(K0?.ok){if(g8("Clip removed.",!0),K0.seq!=null)Y6(S,K0.seq,"remove clip");AY(null)}}).catch(()=>g8("Remove failed: network error"))},[I6,Y6]),CQ=u.useCallback((b,S,d)=>{let X0=Q6.current.canvas;if(!X0||X0===o8)return;let K0=AG.current||void 0,F0=`/_api/comp-clips?canvas=${encodeURIComponent(X0)}${K0?`&artboardId=${encodeURIComponent(K0)}`:""}`;fetch(F0).then((I0)=>I0.json().catch(()=>({}))).then((I0)=>{let p=I0?.ok&&Array.isArray(I0.clips)?I0.clips:[],D0=b?.transition?p.find((O0)=>O0.kind==="transition"&&O0.stableId===b.stableId)||null:I6(I0,b);if(!D0?.stableId)return null;return fetch("/_api/clip-edit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:X0,artboardId:K0,stableId:D0.stableId,contentHash:D0.contentHash,verb:S,...d})})}).then((I0)=>I0?I0.json():null).then((I0)=>{if(I0&&!I0.ok)console.warn("[clip-edit]",S,I0.error||"failed"),NJ(`${S} refused`,I0.error);else if(I0?.ok){let p={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(g8(`Applied: ${p[S]||S}.`,!0),I0.seq!=null)Y6(X0,I0.seq,p[S]||S)}}).catch(()=>g8(`${S} failed: network error`))},[I6,Y6,NJ]),[$Q,SY]=u.useState(null),Q5=u.useCallback((b,S="")=>new Promise((d)=>{SY({title:b,value:S,resolve:d})}),[]),x5=u.useCallback((b)=>{SY((S)=>{return S?.resolve?.(b),null})},[]),bY=u.useCallback((b,S)=>{let d=Q6.current.canvas;if(!d||d===o8||!S||!String(S).trim())return;b7({type:"comments-add",payload:{file:d,text:String(S).trim(),selector:"",dom_path:[],tag:"",classes:"",bounds:null,html_excerpt:"",timeline:b}}),g8("Comment added.",!0)},[]);Q6.current.selected=bH,Q6.current.setSelected=AY,Q6.current.removeClip=$Y,Q6.current.clipVerb=CQ,Q6.current.addComment=bY,Q6.current.askText=Q5,u.useEffect(()=>{let b=(S)=>{let d=Q6.current;if(!d.open||!d.comps?.length)return;let X0=S.target,K0=X0?.tagName;if(K0==="INPUT"&&X0?.type!=="range")return;if(K0==="TEXTAREA"||K0==="SELECT"||X0?.isContentEditable)return;let F0=IK(d.comps,d.compId)?.fps||30,I0=Math.max(1,d.total),p=(O0)=>{let g0=Math.max(0,Math.min(I0-1,Math.round(O0)));z6(g0),n6(!1),d.post({dgn:"timeline-seek",frame:g0,id:d.compId})},D0=()=>{let O0=new Set([0,I0-1]);for(let g0 of d.sequences||[]){O0.add(g0.from);for(let K8 of g0.keyframes||[])O0.add(K8.from),O0.add(K8.to)}return[...O0].filter((g0)=>g0>=0&&g0<I0).sort((g0,K8)=>g0-K8)};if((S.metaKey||S.ctrlKey)&&(S.key==="z"||S.key==="Z")){S.preventDefault(),vG(S.shiftKey?"redo":"undo");return}if(S.key==="Escape"){if(d.selected!=null)S.preventDefault(),d.setSelected?.(null);return}if((S.key==="Delete"||S.key==="Backspace")&&d.selected!=null){S.preventDefault(),d.removeClip?.({stableId:d.selected});return}if((S.metaKey||S.ctrlKey)&&(S.key==="b"||S.key==="B")){S.preventDefault();let O0=d.selected!=null?{stableId:d.selected}:null;if(!O0){let g0=d.sequences||[],K8=g0.find((L8)=>L8.series&&d.frame>=L8.from&&d.frame<L8.from+L8.duration)||g0.find((L8)=>d.frame>=L8.from&&d.frame<L8.from+L8.duration);if(K8?.stableId)O0={stableId:K8.stableId}}if(O0)d.clipVerb?.(O0,"split",{atFrame:d.frame});else g8("Nothing under the playhead to split.");return}if(S.key===" "||S.code==="Space")if(S.preventDefault(),d.playing)n6(!1),d.post({dgn:"timeline-pause",id:d.compId});else n6(!0),d.post({dgn:"timeline-mute",muted:d.muted,id:d.compId}),d.post({dgn:"timeline-loop",loop:d.loop,id:d.compId}),d.post({dgn:"timeline-play",id:d.compId});else if(S.key==="ArrowRight")S.preventDefault(),p(d.frame+(S.shiftKey?F0:1));else if(S.key==="ArrowLeft")S.preventDefault(),p(d.frame-(S.shiftKey?F0:1));else if(S.key==="Home")S.preventDefault(),p(0);else if(S.key==="End")S.preventDefault(),p(I0-1);else if(S.key==="."){S.preventDefault();let O0=D0().find((g0)=>g0>d.frame);if(O0!=null)p(O0)}else if(S.key===","){S.preventDefault();let O0=D0().reverse().find((g0)=>g0<d.frame);if(O0!=null)p(O0)}};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[]),u.useEffect(()=>{FX([]),z6(0),n6(!1),AY(null),SH(null);let b=setTimeout(()=>b8({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(b)},[V,b8]);let[h5,yY]=u.useState(""),[jY,L4]=u.useState([]),[fG,vY]=u.useState([]);u.useEffect(()=>{if(!B8||J9.length===0||!V||V===o8){yY(""),L4([]);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")yY(S.source)}).catch(()=>{}),()=>{b=!1}},[B8,J9,V,yH]),u.useEffect(()=>{if(!B8||!V||V===o8||!h5){L4([]),vY([]);return}let b=!0,S=c7||void 0,d=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${S?`&artboardId=${encodeURIComponent(S)}`:""}`;return fetch(d).then((X0)=>X0.ok?X0.json():null).then((X0)=>{if(!b)return;let K0=X0?.ok&&Array.isArray(X0.clips)?X0.clips:[];L4(K0.filter((F0)=>F0.kind==="sequence")),vY(K0.filter((F0)=>F0.kind==="transition"))}).catch(()=>{}),()=>{b=!1}},[B8,V,h5,c7,yH]),u.useEffect(()=>{if(!h5){MQ([]),CH([]),$H([]),rX(0);return}let b=Y7??w?.artboardId??null,d=(b&&J9.find((F0)=>F0.artboardId===b||F0.id===b)||J9[0])?.durationInFrames||0,X0=wm(h5,d,b);SH(X0.artboardId??b??null);let K0=X0.sequences.map((F0,I0)=>{let p=jY[I0];if(!p)return F0;return{...F0,stableId:p.stableId,contentHash:p.contentHash,mediaProps:p.mediaProps??null,placeholder:p.placeholder??null,mediaTag:p.mediaTag??F0.mediaTag,mediaSrc:p.mediaSrc??F0.mediaSrc,replaceable:!!(p.mediaCdId||p.mediaArrayRef),layers:Array.isArray(p.layers)?p.layers:[],hidden:!!p.hidden}});MQ(K0),CH(X0.audio||[]),$H(X0.transitions||[]),rX(X0.total)},[h5,jY,w,J9,Y7]);let fY=u.useCallback(()=>{RY((b)=>{let S=!b,d=V?R0.current.get(V):null;if(d&&d.contentWindow)try{d.contentWindow.postMessage({dgn:"view-annotations",visible:S},"*")}catch{}return S})},[V]),DJ=u.useCallback((b)=>{for(let S of R0.current.values())try{S.contentWindow.postMessage({dgn:"view-chrome",...b},"*")}catch{}},[]),xY=u.useCallback(()=>{CY((b)=>{let S=!b;return DJ({minimap:S}),S})},[DJ]),hY=u.useCallback(()=>{X5((b)=>{let S=!b;return DJ({zoom:S}),S})},[DJ]),xG=u.useCallback(()=>{OX((b)=>{let S=!b;return DJ({present:S}),S})},[DJ]),D4=u.useCallback(()=>{OX(!1),DJ({present:!1})},[DJ]),hG=u.useCallback(()=>{if(!V||V===o8)return;IQ((b)=>{let S=!b;return b8({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,b8]);u.useEffect(()=>{let b=!1;return fetch("/_api/git-user").then((S)=>S.json()).then((S)=>{if(b)return;let d=S&&typeof S.name==="string"?S.name.trim():"";if(d)SG(d)}).catch(()=>{}),()=>{b=!0}},[]),u.useEffect(()=>{if(!V||V===o8){kQ(0),IQ(!1);return}let b=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(V)).then((S)=>S.json()).then((S)=>{if(b)return;let d=Array.isArray(S?.artboards)?S.artboards.length:0;kQ(d),IQ(S?.overlays?.print===!0),O4(new Set(Array.isArray(S?.locked)?S.locked:[]))}).catch(()=>{if(!b)kQ(0),IQ(!1),O4(new Set)}),()=>{b=!0}},[V]),u.useEffect(()=>{if(!V||V===o8||!Y7)return;let b=setTimeout(()=>{b8({dgn:"request-layers",artboardId:Y7})},250);return()=>clearTimeout(b)},[V,Y7,b8]);let[M4,O4]=u.useState(()=>new Set),gG=u.useCallback((b)=>{if(!V||V===o8)return;O4((S)=>{let d=new Set(S);if(d.has(b))d.delete(b);else d.add(b);let X0=[...d];return fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:V,patch:{locked:X0}})}).catch(()=>{}),b8({dgn:"locked-set",locked:X0}),d})},[V,b8]);u.useEffect(()=>{if(!V||V===o8)return;b8({dgn:"locked-set",locked:[...M4]})},[M4,V,b8]),u.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",j8),localStorage.setItem(s90,j8)}catch{}for(let b of R0.current.values())try{b.contentWindow.postMessage({dgn:"theme",theme:j8},"*")}catch{}},[j8]),u.useEffect(()=>{try{localStorage.setItem(O90,CJ?"1":"0")}catch{}},[CJ]),u.useEffect(()=>{try{localStorage.setItem(D90,w6?"1":"0")}catch{}},[w6]),u.useEffect(()=>{try{localStorage.setItem(A90,J5?"1":"0")}catch{}},[J5]),u.useEffect(()=>{try{localStorage.setItem(_90,aJ?"1":"0")}catch{}},[aJ]),u.useEffect(()=>{try{localStorage.setItem(w90,PQ?"1":"0")}catch{}},[PQ]),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")S8(S.theme);if(typeof S.minimap==="boolean")CY(S.minimap);if(typeof S.zoom==="boolean")X5(S.zoom);if(typeof S.annotations==="boolean")RY(S.annotations);if(typeof S.autoOpenInspector==="boolean")IG(S.autoOpenInspector);if(S.panelSides&&typeof S.panelSides==="object")v0({...aK,...S.panelSides});if(S.layersMode==="separate"||S.layersMode==="in-inspector")W8(S.layersMode)}).catch(()=>{}).finally(()=>{if(!b)V0(!0)}),()=>{b=!0}},[]),u.useEffect(()=>{if(!eX)return;tF0({theme:j8,minimap:J5,zoom:aJ,annotations:PQ,autoOpenInspector:tX,panelSides:L0,layersMode:T0})},[eX,j8,J5,aJ,PQ,tX,L0,T0]),u.useEffect(()=>{try{localStorage.setItem(E90,JSON.stringify(L0))}catch{}},[L0]),u.useEffect(()=>{try{localStorage.setItem(P90,T0)}catch{}},[T0]);let gY=u.useRef(!1);u.useEffect(()=>{if(gY.current||!VJ.ready||!Q||!J.length)return;gY.current=!0;let b=Qu(J);d9((S)=>Yu(S,b))},[VJ.ready,Q,J,d9]);let mG=u.useCallback((b)=>d9((S)=>Xu(S,b)),[d9]),uG=u.useMemo(()=>({isOpen:(b)=>em(VJ.state,b),setOpen:(b,S)=>d9((d)=>bE(d,b,S))}),[VJ.state,d9]),A4=u.useCallback(()=>{S8((b)=>b==="dark"?"light":"dark")},[]),_4=u.useRef(null),S9=u.useCallback(()=>_4.current?.reload()??Promise.resolve(),[]);u.useEffect(()=>{let b=Wy({read:async(S)=>{let d=await fetch("/_index-data",{signal:S,cache:"no-store"});if(!d.ok)throw Object.assign(Error(`Project index request failed: ${d.status}`),{status:d.status});let X0=await d.json(),K0=X0.groups.map((F0)=>({...F0,tree:ZL0(F0.paths,F0.stripPrefix,F0.dirs)}));return{data:X0,built:K0}},apply:({data:S,built:d})=>{U(S.project||"Design"),X(d),Y(!0),G(0),t7((X0)=>({...X0,canvasDesignSystems:S.canvasDesignSystems??{},canvasKinds:S.canvasKinds??{}}))},onError:(S)=>{console.error("failed to load tree",S),G((d)=>d+1)}});return _4.current=b,S9(),()=>{_4.current=null,b.dispose()}},[S9]);let Y5=u.useCallback(async(b)=>{try{let S=b?`/_system-data?ds=${encodeURIComponent(b)}`:"/_system-data",d=await fetch(S);if(!d.ok){console.error("failed to load system-data",d.status);return}let X0=await d.json();if(!b&&X0?.defaultDesignSystem&&!X0.ds){s0(X0);let K0=await fetch(`/_system-data?ds=${encodeURIComponent(X0.defaultDesignSystem)}`);if(K0.ok)s0(await K0.json());return}s0(X0)}catch(S){console.error("failed to load system-data",S)}},[]),mY=u.useCallback(async()=>{try{let S=await(await fetch("/_comments-all")).json();s9(S||{})}catch(b){console.error("failed to load comments",b)}},[]);u.useEffect(()=>{mY()},[mY]);let uY=u.useRef(()=>{});u.useEffect(()=>{let b=null,S=!1;function d(){let X0=location.protocol==="https:"?"wss:":"ws:",K0=new WebSocket(X0+"//"+location.host+"/_ws");TQ.current=K0,K0.addEventListener("open",()=>{if(Z0(!0),S)x9();S=!0,clearInterval(b),b=setInterval(()=>{if(K0.readyState===WebSocket.OPEN)K0.send('{"type":"ping"}')},25000)}),K0.addEventListener("close",()=>{Z0(!1),clearInterval(b),setTimeout(d,1000)}),K0.addEventListener("error",()=>{}),K0.addEventListener("message",(F0)=>{try{let I0=JSON.parse(F0.data);if(I0.type==="snapshot"&&I0.state)O((p)=>o90(I0.state.selected,p));else if(I0.type==="selected"){if(Date.now()-$.current<2000)return;let p=I0.selected,D0=Array.isArray(p)?p[0]:p,O0=P.current,g0=Array.isArray(O0)?O0[0]:O0;if(O((K8)=>o90(p,K8)),D0?.id&&D0.file&&(!g0||g0.id!==D0.id||g0.file!==D0.file))j(D0)}else if(I0.type==="comments"&&typeof I0.file==="string")s9((p)=>({...p,[I0.file]:I0.comments||[]}));else if(I0.type==="ai-activity"&&typeof I0.file==="string"){if(G8(!0),vJ.current)clearTimeout(vJ.current);vJ.current=setTimeout(()=>G8(!1),8000);for(let p of R0.current.values())try{p.contentWindow.postMessage({dgn:"ai-activity",file:I0.file,entry:I0.entry},"*")}catch{}}else if(I0.type==="export:job"&&I0.payload)jJ.upsert(I0.payload);else if(I0.type==="sync:status"&&I0.payload)J8(I0.payload);else if(I0.type==="canvas-list-update")S9(),uY.current(I0.payload);else if(I0.type==="config-updated")x9();else if(I0.type==="acp-focus"){if(H9())DX("assistant")}else if(I0.type==="git-status"&&I0.payload){if(!f8.current)S0(I0.payload)}else if(I0.type==="git-lifecycle"&&I0.payload){a0(I0.payload);for(let p of R0.current.values())try{p.contentWindow.postMessage({dgn:"git-lifecycle",payload:I0.payload},"*")}catch{}}}catch{}})}return d(),()=>{if(clearInterval(b),TQ.current)TQ.current.close()}},[S9,x9]);function b7(b){let S=TQ.current;try{if(S&&S.readyState===1)S.send(JSON.stringify(b))}catch{}}let MJ=u.useCallback(async()=>{if(f8.current)return;try{let b=await fetch("/_api/git/status");if(b.ok)S0(await b.json())}catch{}},[]),fJ=u.useCallback(async()=>{if(f8.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)X8({remoteAhead:!!S.remoteAhead,behind:S.behind||0})}catch{}},[]),OJ=u.useCallback(async(b,S)=>{try{let d=await fetch(b,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(S||{})}),X0=await d.json().catch(()=>({}));return{ok:d.ok,...X0}}catch(d){return{ok:!1,error:"Network error — is the project still open?"}}},[]),pG=u.useCallback(async(b,S)=>{let d=await OJ("/_api/git/commit",{message:b,files:S});if(d.ok)await MJ();return d},[OJ,MJ]),pY=u.useCallback(async(b)=>{let S=await OJ("/_api/git/discard",{files:b});if(S.ok)await MJ();return S},[OJ,MJ]),lG=u.useCallback(async()=>{let b=await OJ("/_api/git/push",{});if(b.ok)await MJ(),fJ();return b},[OJ,MJ,fJ]),lY=u.useCallback(async()=>{let b=await OJ("/_api/git/pull",{});if(b.ok)await MJ(),fJ();if(b.conflict&&Array.isArray(b.files)&&b.files.length)z9({file:b.files[0],conflict:!0});return b},[OJ,MJ,fJ]),dG=u.useCallback(async(b)=>{let S=await OJ("/_api/git/resolve",{choice:b});if(S.ok)await MJ(),fJ();return S},[OJ,MJ,fJ]),w4=u.useCallback(async(b)=>{try{let S="/_api/git/log?limit=40"+(b?`&path=${encodeURIComponent(b)}`:""),d=await fetch(S);if(!d.ok)return[];return(await d.json()).entries||[]}catch{return[]}},[]),[cG,Z1]=u.useState(null),H1=u.useCallback(async(b)=>{try{let S="/_api/cloud/history?limit=40"+(b?`&path=${encodeURIComponent(b)}`:""),d=await fetch(S);if(!d.ok)return null;let X0=await d.json();if(!X0?.ok)return null;return Z1({branch:X0.branch??null,project:X0.project??null,hubHost:X0.hubHost??null}),X0.entries||[]}catch{return null}},[]),[z1,K1]=u.useState(!1),[U1,V1]=u.useState(0),iG=u.useCallback(async(b)=>{try{let S="/_api/project/history?limit=40"+(b?`&path=${encodeURIComponent(b)}`:""),d=await fetch(S);if(!d.ok)return"legacy";let X0=await d.json();if(!X0?.ok)return X0?.reason==="legacy"?"legacy":null;return(X0.history||[]).map((K0)=>{let F0=b?"":(K0.canvases||[]).map((I0)=>I0.split("/").pop()).join(", ");return{sha:`r${K0.revision}`,message:[K0.label||K0.kind,F0].filter(Boolean).join(" · "),author:K0.actor,date:new Date(K0.committedAt).toISOString(),accepted:{revision:K0.revision,actionId:K0.actionId,mine:!!K0.mine,undo:K0.kind==="undo"||K0.kind==="redo"}}})}catch{return null}},[]),oG=/^r\d+$/.test(R8?.beforeSha||""),q1=u.useCallback(async(b)=>{if(!oG)return w4(b);let S=await iG(b);return Array.isArray(S)?S:[]},[oG,w4,iG]),hH=u.useCallback(async(b,S)=>{if(!b||!Number.isSafeInteger(S)||S<0)return{ok:!1,error:"Choose a saved project version to restore."};let d=await fetch("/_api/project/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:b,revision:S})}).catch(()=>null),X0=d?await d.json().catch(()=>null):null;if(d?.ok&&X0?.ok)return V1((K0)=>K0+1),X0;return{ok:!1,error:X0?.error}},[]),B1=u.useMemo(()=>{let b={modified:"M",added:"A",deleted:"D",untracked:"U"},S=new Map;if(E0)return S;for(let d of A0?.files||[])S.set(d.path,b[d.status]);return S},[A0,E0]);u.useEffect(()=>{if(E0){X8(null);return}if(A0?.repo===!1)return;fJ();let b=setInterval(fJ,k8?60000:120000);return()=>clearInterval(b)},[E0,A0?.repo,k8,fJ]);let K6=u.useCallback((b,{reveal:S=!0}={})=>{if(S&&b&&b!==o8)d9((d)=>zF(d,J,b));if(Z.current="push",M0(null),A(null),b===V)return;if(N((d)=>{for(let X0 of d)if(X0.path!==b)R0.current.delete(X0.path);return[{path:b}]}),F(b),h0(null),E8(null),b!==o8)_8(b)},[V,J,d9]),E4=u.useCallback((b,S="push")=>{let d=J.flatMap((X0)=>X0.paths||[]).find((X0)=>xW(X0,i0.designRel)===b);if(d&&S5.test(d))K6(d,{reveal:!1});else if(d&&PL(qQ(d)))E(d);else N([]),F(null),A(null),w5({title:"Not here yet",description:`${b} is not in this project (not synced yet?)`,kind:"info"});Z.current=S},[J,i0.designRel,K6,E]),gH=u.useRef(!1);u.useEffect(()=>{if(!Q||i0.cloud===void 0||gH.current)return;gH.current=!0;let b=bV(location,i0.designRel);if(b)E4(b,"none")},[Q,i0.cloud,i0.designRel,E4]),u.useEffect(()=>{if(!Q||i0.cloud===void 0)return;let b=()=>{let S=bV(location,i0.designRel);if(S)E4(S,"none");else Z.current="none",N([]),F(null),A(null)};return window.addEventListener("popstate",b),()=>window.removeEventListener("popstate",b)},[Q,i0.cloud,i0.designRel,E4]),u.useEffect(()=>{let b=M||(V===o8?null:V);if(b===H.current)return;H.current=b;let S=xW(b,i0.designRel);if(Z.current!=="none"&&bV(location,i0.designRel)!==S)history[S?"pushState":"replaceState"](S?{open:S}:null,"",Dg(location,S));Z.current="push"},[V,M,i0.designRel]);let dY=M||(V===o8?null:V),nG=i0.cloud?"cloud":H9()?"native":"local",mH=(b)=>_g({rel:xW(b,i0.designRel),shell:nG,location,linkedHubUrl:n8?.url,project:i0.cloud?K:w8,localUrl:location.origin}),uH=(b=dY)=>{let S=xW(b,i0.designRel);if(S)DY({path:b,rel:S,label:qQ(b)})},N1=u.useCallback((b)=>{if(h0(null),E8(null),x9(),P0((S)=>S+1),b&&b!==o8)_8(b)},[x9]),rG=u.useRef(!1);u.useEffect(()=>{if(rG.current)return;if(!i0.cloud)return;if(new URLSearchParams(location.search).has("open")){rG.current=!0;return}if(B.length>0)return;if(!J.length)return;let b=null;for(let S of J){for(let d of S.paths||[]){if(!S5.test(d))continue;if(/(^|\/)system\//.test(d))continue;b=d;break}if(b)break}if(!b)return;rG.current=!0,K6(b,{reveal:!1})},[i0.cloud,J,B.length,K6]);let SQ=u.useCallback((b)=>{let S=typeof b==="string"?b:void 0;if(S)Y5(S);else if(!t0)Y5();K6(o8)},[t0,Y5,K6]);u.useEffect(()=>{b7({type:"tabs",tabs:B.map((b)=>b.path).filter((b)=>b!==o8)})},[B]),u.useEffect(()=>{if(V&&V!==o8)b7({type:"active",file:V});else if(V===o8)b7({type:"active",file:""});else b7({type:"active",file:""})},[V]);let cY=u.useCallback((b)=>{N((S)=>{let d=S.findIndex((K0)=>K0.path===b);if(d<0)return S;let X0=S.filter((K0)=>K0.path!==b);if(b===V)if(X0.length===0)F(null);else F(X0[Math.max(0,d-1)].path);return X0}),R0.current.delete(b),_8((S)=>S===b?null:S)},[V]);uY.current=(b)=>{if(!b?.rel)return;let S=(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,""),d=`${S}/${b.rel}`;if(b.action==="removed")cY(d);else if(b.action==="moved"&&b.fromRel){let X0=`${S}/${b.fromRel}`;N((K0)=>K0.map((F0)=>F0.path===X0?{...F0,path:d}:F0)),F((K0)=>K0===X0?d:K0),_8((K0)=>K0===X0?null:K0),R0.current.delete(X0)}};let g5=u.useCallback(()=>{if(!V||V===o8){if(V===o8)Y5();return}let b=R0.current.get(V);if(b)b.src=b.src},[V,Y5]),pH=u.useCallback(()=>S9(),[S9]),[F1,lH]=u.useState(!1),aG=u.useRef(!1),sG=u.useCallback(async()=>{if(aG.current)return;aG.current=!0,lH(!0);try{await Promise.all([S9(),new Promise((b)=>setTimeout(b,550))])}finally{aG.current=!1,lH(!1)}},[S9]);u.useEffect(()=>{let b=null,S=()=>{if(b)clearTimeout(b);b=setTimeout(()=>{b=null,pH()},150)};return window.addEventListener("focus",S),()=>{if(window.removeEventListener("focus",S),b)clearTimeout(b)}},[pH]);let L1=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"})}),d=await S.json().catch(()=>({}));if(!S.ok||!d.ok)return{ok:!1,error:d.error||`create failed (${S.status})`};return await S9(),K6(d.file),{ok:!0,file:d.file}}catch(S){return{ok:!1,error:S instanceof Error?S.message:"network error"}}},[S9,K6]),dH=u.useCallback(async()=>{let b=await Q5("New video name");if(!b)return;let d=(await Q5("Size — 1920x1080 (landscape), 1080x1920 (portrait), 1080x1080 (square), or custom WxH","1920x1080")||"1920x1080").toLowerCase().match(/(\d{2,5})\s*[x×]\s*(\d{2,5})/),X0=d?Number(d[1]):1920,K0=d?Number(d[2]):1080,F0=Math.max(1,Math.min(60,Number(await Q5("Frames per second","30"))||30));try{let I0=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:K0})}),p=await I0.json().catch(()=>({}));if(!I0.ok||!p.ok){g8(`New video failed: ${p.error||`error ${I0.status}`}`);return}await S9(),K6(p.file),K9(!0),g8("New video created — drop clips on the timeline to start the cut.",!0)}catch(I0){g8(`New video failed: ${I0 instanceof Error?I0.message:"network error"}`)}},[S9,K6,Q5]),D1=u.useCallback(async()=>{if(!V||V===o8)return;try{let b=await fetch(`/_api/annotations?file=${encodeURIComponent(V)}`),S=b.ok?await b.text():"",d=[];if(S){let p=new DOMParser().parseFromString(S,"image/svg+xml");for(let D0 of p.querySelectorAll('[data-tool="mediaref"]')){let O0=D0.getAttribute("data-src");if(!O0)continue;d.push({src:O0,mediaKind:D0.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(d.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let K0=`${Y4(qQ(V)).replace(/\.tsx$/i,"")} Video`,F0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:K0,kind:"video-comp",clips:d})}),I0=await F0.json().catch(()=>({}));if(!F0.ok||!I0.ok){window.alert(`Assemble failed: ${I0.error||`error ${F0.status}`}`);return}await S9(),K6(I0.file)}catch(b){window.alert(`Assemble failed: ${b instanceof Error?b.message:"network error"}`)}},[V,S9,K6]),tG=u.useCallback(({accept:b,resolveTarget:S})=>{let d=V,X0=c7||void 0,K0=document.createElement("input");K0.type="file",K0.accept=b,K0.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(K0);let F0=()=>{if(K0.isConnected)K0.remove()};window.addEventListener("focus",()=>setTimeout(F0,300),{once:!0}),K0.addEventListener("change",()=>{let I0=K0.files?.[0];if(F0(),!I0)return;let p=`/_api/comp-clips?canvas=${encodeURIComponent(d)}${X0?`&artboardId=${encodeURIComponent(X0)}`:""}`;fetch(p).then((D0)=>D0.json().catch(()=>({}))).then((D0)=>{let O0=S(D0);if(!O0)return g8("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":I0.type||"application/octet-stream"},body:I0}).then((g0)=>g0.json().catch(()=>({}))).then((g0)=>{if(!g0?.path)return g8(`Upload failed: ${g0?.error||"unknown error"}`),null;if(O0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:d,arrayName:O0.arrayRef.arrayName,index:O0.arrayRef.index,field:O0.arrayRef.field,value:g0.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:d,id:O0.cdId,attr:"src",value:g0.path})})})}).then((D0)=>D0?D0.json():null).then((D0)=>{if(D0&&!D0.ok)g8(`Replace refused: ${D0.error||"failed"}`);else if(D0&&D0.ok){if(g8("Media replaced.",!0),D0.seq!=null)Y6(d,D0.seq,"replace media")}}).catch(()=>g8("Replace failed: network error"))}),K0.click()},[V,c7,Y6]),M1=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"}),K0=await X0.json().catch(()=>({}));if(!X0.ok||!K0.ok){window.alert(`Could not delete: ${K0.error||`error ${X0.status}`}`);return}if(await S9(),V===b)N([]),F(null)}catch(X0){window.alert(`Delete failed: ${X0 instanceof Error?X0.message:"network error"}`)}},[S9,V]),O1=u.useCallback(async function b(S,d){try{let X0=await fetch("/_api/fs-move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:S,toDir:d})}),K0=await X0.json().catch(()=>({}));if(!X0.ok||!K0.ok)return g8(`Could not move: ${K0.error||`error ${X0.status}`}`),{ok:!1,error:K0.error};let F0=(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,""),I0=`${F0}/${K0.fromRel}`,p=`${F0}/${K0.toRel}`;d9((O0)=>zF(yE(O0,I0,p),J,p)),await S9(),N((O0)=>O0.map((g0)=>g0.path===I0?{path:p}:g0)),F((O0)=>O0===I0?p:O0);let D0=I0.split("/").slice(0,-1).join("/");return g8(`Moved to ${K0.toRel.split("/").slice(0,-1).join("/")||"."}`,!0,{label:"Undo",onClick:()=>{b(p,D0)}}),{ok:!0}}catch(X0){return g8(`Move failed: ${X0 instanceof Error?X0.message:"network error"}`),{ok:!1,error:"network error"}}},[S9,i0,J,d9]),A1=u.useCallback(async(b,S)=>{try{let d=await fetch("/_api/fs-mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parent:b,name:S})}),X0=await d.json().catch(()=>({}));if(!d.ok||!X0.ok){let K0=X0.error||`error ${d.status}`;return g8(`Could not create folder: ${K0}`),{ok:!1,error:K0}}return d9((K0)=>zF(K0,J,b,{includeSelf:!0})),await S9(),{ok:!0,dir:X0.dir}}catch(d){let X0=d instanceof Error?d.message:"network error";return g8(`Create folder failed: ${X0}`),{ok:!1,error:X0}}},[S9,J,d9]),_1=u.useCallback(async(b,S)=>{if(!window.confirm(`Delete folder "${S}"?
|
|
5686
5686
|
|
|
5687
5687
|
Every canvas inside moves to trash (recoverable from .design/_trash/); any empty subfolders are removed.`))return;try{let X0=await fetch(`/_api/canvas?file=${encodeURIComponent(b)}`,{method:"DELETE"}),K0=await X0.json().catch(()=>({}));if(!X0.ok||!K0.ok){g8(`Could not delete folder: ${K0.error||`error ${X0.status}`}`);return}await S9()}catch(X0){g8(`Delete folder failed: ${X0 instanceof Error?X0.message:"network error"}`)}},[S9]),w1=u.useCallback(async(b,S)=>{let d=b.split("/").slice(0,-1).join("/");try{let X0=await fetch("/_api/fs-move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:b,toDir:d,toName:S})}),K0=await X0.json().catch(()=>({}));if(!X0.ok||!K0.ok){g8(`Could not rename folder: ${K0.error||`error ${X0.status}`}`);return}let F0=(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,""),I0=typeof K0.toRel==="string"?`${F0}/${K0.toRel}`:`${d}/${S}`;d9((p)=>yE(p,b,I0)),await S9()}catch(X0){g8(`Rename failed: ${X0 instanceof Error?X0.message:"network error"}`)}},[S9,i0,d9]),E1=u.useCallback(async(b,S)=>{try{let d=await fetch("/_api/fs-move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:b,toName:S})}),X0=await d.json().catch(()=>({}));if(!d.ok||!X0.ok){g8(`Could not rename: ${X0.error||`error ${d.status}`}`);return}let K0=(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,""),F0=`${K0}/${X0.fromRel}`,I0=`${K0}/${X0.toRel}`;await S9(),N((p)=>p.map((D0)=>D0.path===F0?{path:I0}:D0)),F((p)=>p===F0?I0:p)}catch(d){g8(`Rename failed: ${d instanceof Error?d.message:"network error"}`)}},[S9,i0]),P1=u.useCallback(async(b)=>{try{let S=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({duplicateOf:b})}),d=await S.json().catch(()=>({}));if(!S.ok||!d.ok){g8(`Could not duplicate: ${d.error||`error ${S.status}`}`);return}await S9(),g8(`Duplicated as ${d.rel.split("/").pop().replace(/\.tsx$/i,"")}`,!0)}catch(S){g8(`Duplicate failed: ${S instanceof Error?S.message:"network error"}`)}},[S9]),I1=u.useCallback(async(b,S)=>{if(!window.confirm(`Move “${S}” to trash?
|
|
5688
5688
|
|
|
5689
|
-
You can restore it from .design/_trash/.`))return;try{let d=await fetch(`/_api/canvas?file=${encodeURIComponent(b)}`,{method:"DELETE"}),X0=await d.json().catch(()=>({}));if(!d.ok||!X0.ok){g8(`Could not delete: ${X0.error||`error ${d.status}`}`);return}await S9()}catch(d){g8(`Delete failed: ${d instanceof Error?d.message:"network error"}`)}},[S9]),k1=u.useCallback(()=>{if(b7({type:"clear-select"}),O(null),V&&V!==o8){let b=R0.current.get(V);if(b&&b.contentWindow)try{b.contentWindow.postMessage({dgn:"force-clear"},"*")}catch{}}},[V]);u.useEffect(()=>{if(!V||V===o8)return;let b=R0.current.get(V);if(!b||!b.contentWindow)return;let S=e9?[]:b9[V]||[];try{b.contentWindow.postMessage({dgn:"comments-set",comments:S},"*")}catch{}},[V,b9,e9]),u.useEffect(()=>{let b=(F0)=>!!V&&(b9[V]||[]).some((I0)=>I0&&I0.id===F0);function S(F0){let I0=i0?.canvasOrigin||window.location.origin;if(F0.origin!==I0)return;let p=F0.data;if(!p||typeof p!=="object"||!p.dgn)return;if(p.dgn==="canvas-notice"){let D0=V&&V!==o8?R0.current.get(V)?.contentWindow:null,O0=Sm(F0,I0,D0);if(O0)Sg(O0.title,O0.kind);return}if(p.dgn==="tool-cursor"){if(p.tool==="browse"){document.body.style.cursor="";let O0=document.getElementById("dc-app-cursor");if(O0)O0.textContent="";DL(r8);return}let D0=db(p.tool);if(D0){document.body.style.cursor=D0;let O0=document.getElementById("dc-app-cursor");if(!O0)O0=document.createElement("style"),O0.id="dc-app-cursor",document.head.appendChild(O0);O0.textContent=`* { cursor: ${D0} !important; }`}return}if(p.dgn==="select"||p.dgn==="select-set"||p.dgn==="clear-select"||p.dgn==="edit-text"||p.dgn==="apply-edit"||p.dgn==="undo-barrier"){let D0=V&&V!==o8?R0.current.get(V)?.contentWindow:null;if(F0.source!==D0)return}if(p.dgn==="select"&&p.selection)FJ(null),$.current=Date.now(),b7({type:"select",selection:p.selection}),O(p.selection),TG(p.selection);else if(p.dgn==="select-set"){FJ(null),$.current=Date.now();let D0=p.selection;if(D0==null)b7({type:"clear-select"}),O(null);else if(Array.isArray(D0)){let O0=D0[0]??null;if(O0)b7({type:"select",selection:O0});if(O(O0),D0.length===1)TG(O0)}else b7({type:"select",selection:D0}),O(D0),TG(D0)}else if(p.dgn==="clear-select")FJ(null),$.current=Date.now(),b7({type:"clear-select"}),O(null);else if(p.dgn==="edit-text"&&p.id){let D0=F0.source,O0=(g0)=>{try{D0?.postMessage({dgn:"edit-reverted",op:"text",id:p.id,reason:g0},"*")}catch{}};fetch("/_api/edit-text",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:p.file,id:p.id,text:p.text??"",...typeof p.occurrence==="number"?{occurrence:p.occurrence}:{},...typeof p.before==="string"?{before:p.before}:{}})}).then((g0)=>g0.json().catch(()=>({}))).then((g0)=>{if(!g0.ok)O0(g0.error||"this element can't be edited inline")}).catch(()=>O0("network error"))}else if(p.dgn==="undo-barrier"&&typeof p.requestId==="string"){let D0=F0.source;Promise.all([k6.current.catch(()=>{}),WD0()]).then(()=>{try{D0?.postMessage({dgn:"undo-barrier-ok",requestId:p.requestId},"*")}catch{}})}else if(p.dgn==="apply-edit"&&p.id&&(p.op==="css"||p.op==="text"||p.op==="attr")){let D0=Yy(p);if(!D0)return;let O0=F0.source,g0=(L8)=>{if(typeof p.requestId!=="string")return;try{O0?.postMessage({dgn:"apply-edit-result",requestId:p.requestId,...L8},"*")}catch{}},K8=typeof p.value==="string"?p.value:null;k6.current=k6.current.catch(()=>{}).then(()=>fetch(D0.url,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(D0.body)}).then((L8)=>L8.json().catch(()=>({}))).then((L8)=>{if(L8.ok){if(D0.op==="css")_X({id:p.id,prop:p.key,value:K8});g0({ok:!0});return}console.warn("[apply-edit]",D0.op,L8.error||"failed"),g0({ok:!1,error:L8.error||"failed",conflict:L8.conflict===!0})}).catch(()=>g0({ok:!1,error:"network error"})))}else if(p.dgn==="layers-tree"){H0({artboardId:p.artboardId,nodes:Array.isArray(p.tree)?p.tree:[]});let D0=JL0(p.tree);if(o.current={tree:p.tree,sig:D0,artboardId:p.artboardId??null},n.current=!1,e.current)clearTimeout(e.current),e.current=null;v.current?.(p.tree,D0,p.artboardId??null)}else if(p.dgn==="reorder-revert"){let D0=V?R0.current.get(V)?.contentWindow:null,O0=typeof p.seq==="number"&&(p.dir==="undo"||p.dir==="redo");if(F0.source===D0&&O0&&V){if(n.current=!0,e.current)clearTimeout(e.current);e.current=setTimeout(()=>{n.current=!1,e.current=null},700),fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,seq:p.seq,dir:p.dir})}).then((g0)=>g0.json().catch(()=>({}))).then((g0)=>{if(!g0.ok)console.warn("[reorder-revert]",g0.error||"failed")}).catch(()=>{})}}else if(p.dgn==="reorder-request"){let D0=V?R0.current.get(V)?.contentWindow:null,O0=typeof p.id==="string"&&typeof p.refId==="string"&&(p.position==="before"||p.position==="after"||p.position==="inside-start"||p.position==="inside-end");if(F0.source===D0&&O0)g.current?.(p.id,p.refId,p.position,{idIndex:Number.isInteger(p.idIndex)?p.idIndex:void 0,refIndex:Number.isInteger(p.refIndex)?p.refIndex:void 0})}else if(p.dgn==="reposition-request"){let D0=V?R0.current.get(V)?.contentWindow:null,O0=typeof p.id==="string"&&Number.isFinite(p.left)&&Number.isFinite(p.top)&&Number.isFinite(p.beforeLeft)&&Number.isFinite(p.beforeTop);if(F0.source===D0&&O0)l.current?.(p.id,p.left,p.top,p.beforeLeft,p.beforeTop,Number.isInteger(p.idIndex)?p.idIndex:void 0)}else if(p.dgn==="resize-request"){let D0=V?R0.current.get(V)?.contentWindow:null,O0=typeof p.id==="string"&&p.patch&&typeof p.patch==="object";if(F0.source===D0&&O0)x.current?.(p.id,p.patch,p.before,Number.isInteger(p.idIndex)?p.idIndex:void 0)}else if(p.dgn==="delete-request"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof p.id==="string")kT.current?.(p.id,Number.isInteger(p.idIndex)?p.idIndex:void 0)}else if(p.dgn==="duplicate-request"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof p.id==="string")ST.current?.(p.id,Number.isInteger(p.idIndex)?p.idIndex:void 0)}else if(p.dgn==="copy-style"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0)yT.current?.()}else if(p.dgn==="paste-style"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof p.id==="string")jT.current?.(p.id)}else if(p.dgn==="insert-request"){let D0=V?R0.current.get(V)?.contentWindow:null,O0=typeof p.refId==="string",g0=typeof p.artboardId==="string",K8=p.position==="before"||p.position==="after"||p.position==="inside-start"||p.position==="inside-end",L8=O0!==g0&&(p.kind==="div"||p.kind==="text"||p.kind==="image")&&K8&&(!g0||p.position==="inside-start"||p.position==="inside-end");if(F0.source===D0&&L8)TT.current?.(p.refId,p.position,p.kind,{artboardId:g0?p.artboardId:void 0,src:typeof p.src==="string"?p.src:void 0,refIndex:Number.isInteger(p.refIndex)?p.refIndex:void 0})}else if(p.dgn==="insert-image-request"){let D0=V?R0.current.get(V)?.contentWindow:null,O0=typeof p.refId==="string",g0=typeof p.artboardId==="string",K8=!O0&&!g0,L8=(O0!==g0||K8)&&(K8||p.position==="before"||p.position==="after"||p.position==="inside-start"||p.position==="inside-end")&&(!g0||p.position==="inside-start"||p.position==="inside-end");if(F0.source===D0&&L8)Pq.current?.({purpose:"insert-image",canvas:V,refId:p.refId,artboardId:g0?p.artboardId:void 0,position:K8?void 0:p.position,refIndex:Number.isInteger(p.refIndex)?p.refIndex:void 0,multiple:!0,hasArtboardAnchor:!K8})}else if(p.dgn==="replace-media-request"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof p.id==="string")Pq.current?.({purpose:"replace-src",canvas:V,id:p.id,before:typeof p.before==="string"?p.before:null})}else if(p.dgn==="convert-to-absolute-request"){let D0=V?R0.current.get(V)?.contentWindow:null,O0=Array.isArray(p.containers)&&p.containers.length>0,g0=typeof p.containerId==="string"&&Array.isArray(p.children)&&p.children.length>0;if(F0.source===D0&&(O0||g0)){let K8=O0?p.containers.reduce((L8,U6)=>L8+(Array.isArray(U6?.children)?U6.children.length:0),0):p.children.length;I.current?.("/_api/convert-to-absolute",O0?{allowShared:p.allowShared===!0,containers:p.containers,...Array.isArray(p.dissolve)&&p.dissolve.length>0?{dissolve:p.dissolve}:{}}:{containerId:p.containerId,containerSetRelative:p.containerSetRelative===!0,allowShared:p.allowShared===!0,children:p.children},{label:"convert to absolute",onOk:()=>{b8({dgn:"selection-clear"}),b8({dgn:"op-toast",message:`Converted ${K8} element${K8===1?"":"s"} to absolute — press V and drag them freely (⌘Z to undo).`})},onFail:(L8)=>b8({dgn:"op-toast",message:`Convert failed: ${L8?.error||"unknown error"}`})})}}else if(p.dgn==="replace-annotation-media-request"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof p.id==="string")Pq.current?.({purpose:"replace-annotation-media",canvas:V,id:p.id,before:typeof p.before==="string"?p.before:null})}else if(p.dgn==="edit-annotation-photo-request"){let D0=V?R0.current.get(V)?.contentWindow:null,O0=PT.exec(typeof p.asset==="string"?p.asset:"")?.[0]||null;if(F0.source===D0&&typeof p.id==="string"&&O0)FJ({asset:O0,strokeId:p.id}),DX("inspector"),sX("photo")}else if(p.dgn==="open-sticker-picker"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0)vT.current?.({canvas:V})}else if(p.dgn==="insert-artboard-request"){let D0=V?R0.current.get(V)?.contentWindow:null,O0=typeof p.id==="string"&&Number.isFinite(p.width)&&Number.isFinite(p.height);if(F0.source===D0&&O0)RT.current?.({id:p.id,label:typeof p.label==="string"?p.label:p.id,width:p.width,height:p.height})}else if(p.dgn==="resize-artboard-request"){let D0=V?R0.current.get(V)?.contentWindow:null,O0=typeof p.artboardId==="string"&&(Number.isFinite(p.width)||Number.isFinite(p.height));if(F0.source===D0&&O0)CT.current?.(p.artboardId,Number.isFinite(p.width)?p.width:void 0,Number.isFinite(p.height)?p.height:void 0)}else if(p.dgn==="delete-artboard-request"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof p.artboardId==="string")$T.current?.(p.artboardId)}else if(p.dgn==="rename-artboard-request"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof p.artboardId==="string"&&typeof p.label==="string"&&p.label.trim())I.current?.("/_api/set-artboard-label",{artboardId:p.artboardId,label:p.label.slice(0,80)},{label:"rename artboard"})}else if(p.dgn==="set-artboard-kind-request"){let D0=V?R0.current.get(V)?.contentWindow:null,O0=p.kind===null||typeof p.kind==="string";if(F0.source===D0&&typeof p.artboardId==="string"&&O0)IT.current?.(p.artboardId,p.kind)}else if(p.dgn==="duplicate-artboard-request"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof p.artboardId==="string"&&Number.isFinite(p.width))bT.current?.(p.artboardId,p.width)}else if(p.dgn==="open-inspector"){if(DX("inspector"),typeof p.tab==="string")sX(p.tab)}else if(p.dgn==="present-enter"){let D0=V?R0.current.get(V)?.contentWindow:null,O0=!!document.querySelector('[role="dialog"][aria-modal="true"]');if(F0.source===D0&&!O0&&!e9)OX(!0),DJ({present:!0})}else if(p.dgn==="comment-compose"&&p.selection)O(p.selection);else if(p.dgn==="comment-submit"&&p.payload&&typeof p.payload.text==="string"){let D0=p.payload,O0=String(D0.text).trim(),g0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===g0&&O0&&V&&V!==o8)b7({type:"comments-add",payload:{file:V,selector:D0.selector,index:D0.index,dom_path:D0.dom_path,tag:D0.tag,classes:D0.classes,bounds:D0.bounds,html_excerpt:D0.html_excerpt,annotationId:D0.annotationId,world:D0.world,text:O0}})}else if(p.dgn==="comment-patch"&&p.id&&p.patch&&typeof p.patch==="object"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0&&b(p.id))b7({type:"comments-patch",id:p.id,patch:p.patch})}else if(p.dgn==="comment-delete"&&p.id){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0&&b(p.id))b7({type:"comments-delete",id:p.id}),M0((O0)=>O0===p.id?null:O0)}else if(p.dgn==="comment-click"&&p.id)M0(p.id);else if(p.dgn==="artboards"&&typeof p.count==="number"){let D0=Math.round(p.count);if(Number.isFinite(D0)&&D0>=0&&D0<=999)kQ(D0)}else if(p.dgn==="active-artboard"){let D0=V&&V!==o8?R0.current.get(V)?.contentWindow:null;if(F0.source!==D0)return;f6(JF(p.id))}else if(p.dgn==="timeline-comps"&&Array.isArray(p.comps)){let D0=V&&V!==o8?R0.current.get(V)?.contentWindow:null;if(F0.source!==D0)return;let O0=p.comps.filter((L8)=>L8&&typeof L8.id==="string").slice(0,32).map((L8)=>({id:String(L8.id).slice(0,120),fps:Math.max(1,Math.min(120,Math.round(Number(L8.fps)||30))),durationInFrames:Math.max(1,Math.min(1e6,Math.round(Number(L8.durationInFrames)||1))),width:Math.max(1,Math.round(Number(L8.width)||0)),height:Math.max(1,Math.round(Number(L8.height)||0)),artboardId:JF(L8.artboardId),artboardLabel:JF(L8.artboardLabel)}));FX(O0);let g0=aX.current;if(g0&&O0.some((L8)=>L8.id===g0)&&OG.current>0)b8({dgn:"timeline-seek",frame:OG.current,id:g0})}else if(p.dgn==="timeline-frame"&&typeof p.frame==="number"){let D0=V&&V!==o8?R0.current.get(V)?.contentWindow:null;if(F0.source!==D0)return;if(p.id&&aX.current&&p.id!==aX.current)return;if(Number.isFinite(p.frame))z6(Math.max(0,Math.round(p.frame)))}else if(p.dgn==="timeline-ended"){let D0=V&&V!==o8?R0.current.get(V)?.contentWindow:null;if(F0.source!==D0)return;if(p.id&&aX.current&&p.id!==aX.current)return;n6(!1)}else if(p.dgn==="toggle-palette")NX((D0)=>!D0);else if(p.dgn==="shell-shortcut"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0){if(p.id==="reload")g5();else if(p.id==="inspector")x6("inspector");else if(p.id==="assistant"&&H9())x6("assistant");else if(p.id==="comments")x6("comments");else if(p.id==="changes")x6("changes");else if(p.id==="timeline")PY();else if(p.id==="export")X6({mode:"export"});else if(p.id==="handoff")X6({mode:"handoff"})}}else if(p.dgn==="open-export"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0)X6({mode:"export",scope:p.detail&&typeof p.detail.scope==="string"?p.detail.scope:void 0})}else if(p.dgn==="open-timeline-request"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0){if(typeof p.artboardId==="string")f6(p.artboardId.slice(0,120));K9(!0)}}else if((p.dgn==="canvas-rendered"||p.dgn==="canvas-failed")&&p.file)_8((D0)=>D0===p.file?null:D0);else if(p.dgn==="loaded"&&p.file){if(!k90(p.file))_8((g0)=>g0===p.file?null:g0);E8(p.file),h0((g0)=>g0&&g0.path===p.file?null:g0);let D0=e9?[]:b9[p.file]||[],O0=[...R0.current.entries()].find(([g0])=>g0===p.file)?.[1];if(O0&&O0.contentWindow){try{O0.contentWindow.postMessage({dgn:"comments-set",comments:D0},"*")}catch{}try{O0.contentWindow.postMessage({dgn:"theme",theme:j8},"*")}catch{}try{O0.contentWindow.postMessage({dgn:"view-chrome",minimap:J5,zoom:aJ,present:e9},"*")}catch{}if(t&&D0.some((K8)=>K8.id===t))try{O0.contentWindow.postMessage({dgn:"comment-focus",id:t},"*")}catch{}let g0=c.current;if(g0&&g0.file===p.file){c.current=null;try{O0.contentWindow.postMessage({dgn:"request-layers",artboardId:g0.artboardId??null},"*")}catch{}if(g0.movedId)try{O0.contentWindow.postMessage({dgn:"select-by-id",id:g0.movedId,artboardId:g0.artboardId??null,index:0},"*")}catch{}}else{let K8=P.current,L8=Array.isArray(K8)?K8[0]:K8;if(L8&&L8.id&&L8.file===p.file)j(L8)}}}else if(p.dgn==="export-request"&&p.id&&p.payload){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source!==D0)return;X0(F0.source,p.id,p.payload)}else if(p.dgn==="export-history-request"&&p.id)K0(F0.source,p.id)}let d=i0?.canvasOrigin||window.location.origin;async function X0(F0,I0,p){if(p?.options&&V&&V!==o8)p.options.canvasFile=V;let D0=(K8)=>{try{if(F0)F0.postMessage({dgn:"export-result",id:I0,...K8},d)}catch{}},O0=p?.options||{};if(HB({exportLane:i0.exportLane||"local",format:p?.format,scope:p?.scope,artboardId:O0.artboardId}))try{if(p.format==="pptx"){let{filename:K8,blob:L8}=await mO({capture:RQ,name:V?V.replace(/^.*\//,"").replace(/\.[^.]+$/,""):"export"});_L(K8,L8)}else{let K8=pO(O0),L8=await RQ({format:p.format,artboardIds:[O0.artboardId],scale:K8}),U6=await uO(L8,p.format);for(let P7 of U6)_L(P7.name,P7.blob)}D0({ok:!0,browser:!0});return}catch{if(i0.exportLane!=="remote"){D0({ok:!1,error:"Capturing in the browser failed and this workspace has no render service to fall back to — try again, or ask your admin to add maude-render."});return}}if(i0.exportLane==="none"&&p?.format!=="zip"){D0({ok:!1,error:"This format needs the render service, which this workspace doesn’t have configured. PNG/SVG of the active artboard and the PPTX deck export straight from the browser; ZIP works too. For the rest use the desktop app or ask your admin to add maude-render."});return}try{let K8=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(p)});if(!K8.ok){D0({ok:!1,error:await K8.text()||String(K8.status)});return}let{jobId:L8}=await K8.json();D0({ok:!0,jobId:L8})}catch(K8){D0({ok:!1,error:K8&&K8.message?K8.message:String(K8)})}}async function K0(F0,I0){let p=[];try{let D0=await fetch("/_api/export-history");if(D0.ok){let O0=await D0.json();if(Array.isArray(O0.history))p=O0.history}}catch{}try{if(F0)F0.postMessage({dgn:"export-history-result",id:I0,history:p},d)}catch{}}return window.addEventListener("message",S),()=>window.removeEventListener("message",S)},[b9,t,i0,j8,g5,e9,J5,aJ,DJ,V,b8,RQ]);let T1=u.useCallback(()=>{if(!V||V===o8)return;let b=R0.current.get(V);if(b&&b.contentWindow)try{b.contentWindow.postMessage({dgn:"force-clear"},"*")}catch{}},[V]),_X=u.useCallback((b)=>{if(!V||V===o8)return;let S=R0.current.get(V);if(S&&S.contentWindow)try{S.contentWindow.postMessage({dgn:"apply-style",...b},"*")}catch{}},[V]),sJ=u.useCallback((b)=>{if(!V||V===o8||!b)return;let S=R0.current.get(V);if(S&&S.contentWindow)try{S.contentWindow.postMessage({dgn:"record-edit",payload:b},"*")}catch{}},[V]),k6=u.useRef(Promise.resolve()),q=u.useCallback((b,S,d,X0)=>{let K0=Number.isInteger(X0?.idIndex)?X0.idIndex:void 0,F0=Number.isInteger(X0?.refIndex)?X0.refIndex:void 0;if(!b||!S)return;if(b===S&&(K0??0)===(F0??0))return;let I0=P.current,p=Array.isArray(I0)?I0[0]:I0,D0=V;if(!D0)return;let O0=V,g0=s?.artboardId??p?.artboardId??null;if(H0((K8)=>K8?{...K8,nodes:KD0(K8.nodes,b,S,d)}:K8),n.current=!0,e.current)clearTimeout(e.current);e.current=setTimeout(()=>{n.current=!1,e.current=null},700),k6.current=k6.current.catch(()=>{}).then(()=>fetch("/_api/reorder",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:D0,id:b,refId:S,position:d,idIndex:K0,refIndex:F0})}).then((K8)=>K8.json().catch(()=>({}))).then((K8)=>{if(!K8.ok){if(console.warn("[reorder]",K8.error||"failed"),b8({dgn:"reorder-failed"}),b8({dgn:"request-layers",artboardId:g0}),n.current=!1,e.current)clearTimeout(e.current),e.current=null;return}if(c.current={file:O0,movedId:K8.movedId||null,artboardId:g0},typeof K8.seq==="number")b8({dgn:"record-edit",payload:{op:"reorder",canvas:D0,seq:K8.seq,label:"move element"}})}).catch(()=>{}))},[V,s,b8]);u.useEffect(()=>{g.current=q},[q]);let L=u.useCallback((b,S,d,X0,K0,F0)=>{if(!b||!V)return;let I0=V,p=Number.isInteger(F0)?F0:void 0;_X({id:b,prop:"left",value:`${S}px`}),_X({id:b,prop:"top",value:`${d}px`});let D0=null,O0=(g0,K8)=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:I0,id:b,property:g0,value:`${K8}px`,idIndex:p})}).then((L8)=>L8.json().catch(()=>({})));k6.current=k6.current.catch(()=>{}).then(()=>O0("left",S)).then((g0)=>{if(!g0.ok)throw Error(g0.error||"left write failed");return D0=g0,O0("top",d)}).then((g0)=>{if(!g0.ok)throw Error(g0.error||"top write failed");sJ({op:"css",canvas:I0,id:b,key:"left",before:Mq(D0,`${X0}px`),after:`${S}px`}),sJ({op:"css",canvas:I0,id:b,key:"top",before:Mq(g0,`${K0}px`),after:`${d}px`})}).catch((g0)=>{console.warn("[reposition]",g0?.message||g0),b8({dgn:"reposition-failed"})})},[V,b8,sJ,_X]);u.useEffect(()=>{l.current=L},[L]);let _=u.useCallback((b,S,d,X0)=>{if(!b||!V||!S||typeof S!=="object")return;let K0=V,F0=d&&typeof d==="object"?d:{},I0=Number.isInteger(X0)?X0:void 0,p=["width","height","left","top","transform","padding-top","padding-right","padding-bottom","padding-left","gap","grid-template-columns","grid-template-rows"].filter((p9)=>typeof S[p9]==="string"&&S[p9]);if(!p.length)return;let D0=P.current,O0=Array.isArray(D0)?D0.length===1?D0[0]:null:D0,g0=O0&&O0.id===b?O0.artboardId??null:null,K8=O0&&O0.id===b?O0.index??0:0;for(let p9 of p)_X({id:b,artboardId:g0,index:K8,prop:p9,value:S[p9]});let L8=(p9,AJ)=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:K0,id:b,property:p9,value:AJ,idIndex:I0})}).then((XZ)=>XZ.json().catch(()=>({}))),U6={},P7=k6.current.catch(()=>{});for(let p9 of p)P7=P7.then((AJ)=>{if(AJ&&AJ.ok===!1)throw Error(AJ.error||`${p9} write failed`);return L8(p9,S[p9]).then((XZ)=>{return U6[p9]=XZ,XZ})});k6.current=P7.then((p9)=>{if(p9&&p9.ok===!1)throw Error(p9.error||"resize write failed");for(let AJ of p)sJ({op:"css",canvas:K0,id:b,key:AJ,before:Mq(U6[AJ],F0[AJ]??null),after:S[AJ]});j({id:b,file:K0,artboardId:g0,index:K8})}).catch((p9)=>{console.warn("[resize]",p9?.message||p9),b8({dgn:"resize-failed"})})},[V,b8,sJ,_X,j]);u.useEffect(()=>{x.current=_},[_]);let I=u.useRef(null),k=u.useCallback((b,S,{label:d,onOk:X0,onFail:K0}={})=>{if(!V)return;let F0=V,I0=K0??((p)=>b8({dgn:"op-toast",message:`Couldn't ${d||"apply the edit"}${p?.error?` — ${p.error}`:""}.`}));k6.current=k6.current.catch(()=>{}).then(()=>fetch(b,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...S,canvas:F0})}).then((p)=>p.json().catch(()=>({}))).then((p)=>{if(!p.ok){console.warn(`[${b}]`,p.error||"failed"),I0?.(p);return}if(typeof p.seq==="number")b8({dgn:"record-edit",payload:{op:"reorder",canvas:F0,seq:p.seq,label:d||"edit"}});X0?.(p,F0)}).catch((p)=>I0?.({error:p?.message})))},[V,b8]);u.useEffect(()=>{I.current=k},[k]);let y=u.useCallback((b,S)=>{k("/_api/delete-element",{id:b,idIndex:Number.isInteger(S)?S:void 0},{label:"delete element",onOk:()=>b8({dgn:"selection-clear"})})},[k,b8]),h=u.useCallback((b,S,d,X0={})=>{let K0=o.current?.sig??null;k("/_api/insert-element",{refId:b,artboardId:typeof X0.artboardId==="string"?X0.artboardId:void 0,position:S,kind:d,src:typeof X0.src==="string"?X0.src:void 0,refIndex:Number.isInteger(X0.refIndex)?X0.refIndex:void 0},{label:`insert ${d}`,onOk:(F0,I0)=>{if(!F0.newId)return;c.current={file:I0,movedId:F0.newId,artboardId:null,staleSig:K0};let p=o.current;if(p)v.current?.(p.tree,p.sig,p.artboardId)}})},[k]),J0=u.useCallback((b)=>{if(typeof b!=="string"||!b)return!1;if(!V)return!1;let S=P.current?.artboardId??Y7??null;if(!S)return!1;return h(void 0,"inside-end","image",{artboardId:S,src:b}),!0},[V,Y7,h]),G0=u.useCallback((b,S)=>{k("/_api/detach-component",{id:b,idIndex:Number.isInteger(S)?S:void 0},{label:"detach instance",onOk:(d)=>{b8({dgn:"selection-clear"}),b8({dgn:"op-toast",message:`Detached — this instance is now ${d.detachedName||"its own component"}; edits stay local (⌘Z to undo).`})},onFail:(d)=>b8({dgn:"op-toast",message:`Detach failed: ${d?.error||"unknown error"}`})})},[k,b8]),N0=u.useCallback((b,S)=>{let d=o.current?.sig??null;k("/_api/duplicate-element",{id:b,idIndex:Number.isInteger(S)?S:void 0},{label:"duplicate element",onOk:(X0,K0)=>{if(!X0.newId)return;c.current={file:K0,movedId:X0.newId,artboardId:null,staleSig:d};let F0=o.current;if(F0)v.current?.(F0.tree,F0.sig,F0.artboardId)}})},[k]),$0=u.useRef(null),c0=u.useMemo(()=>new Set(["position","top","right","bottom","left","inset","width","height","min-width","max-width","min-height","max-height","margin","margin-top","margin-right","margin-bottom","margin-left"]),[]),Z8=u.useCallback(()=>{let b=P.current,S=Array.isArray(b)?b.length===1?b[0]:null:b;if(!S)return;let d={};for(let[X0,K0]of Object.entries(S.authored||{}))if(!c0.has(X0))d[X0]=K0;for(let[X0,K0]of Object.entries(S.customStyles||{}))if(!c0.has(X0))d[X0]=K0;$0.current=Object.keys(d).length?d:null},[c0]),W9=u.useCallback((b)=>{let S=V,d=$0.current;if(!S||!b||!d)return;let X0=Object.entries(d),K0=k6.current.catch(()=>{});for(let[F0,I0]of X0)_X({id:b,prop:F0,value:I0}),K0=K0.then(()=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:S,id:b,property:F0,value:I0})}).then((p)=>p.json().catch(()=>({}))).then((p)=>{if(p.ok)sJ({op:"css",canvas:S,id:b,key:F0,before:Mq(p,null),after:I0})}).catch(()=>{}));k6.current=K0},[V,_X,sJ]),G7=u.useCallback(({id:b,label:S,width:d,height:X0})=>{k("/_api/insert-artboard",{id:b,label:S,width:d,height:X0},{label:"insert artboard"})},[k]),xJ=u.useCallback((b,S,d)=>{k("/_api/resize-artboard",{artboardId:b,width:S,height:d},{label:"resize artboard",onFail:()=>b8({dgn:"resize-artboard-failed"}),onOk:()=>m(b,V)})},[k,b8,m,V]),wq=u.useCallback((b)=>{k("/_api/delete-artboard",{artboardId:b},{label:"delete artboard"})},[k]),TL=u.useCallback((b,S)=>{k("/_api/duplicate-artboard",{artboardId:b,width:S},{label:"duplicate artboard at width"})},[k]),z70=u.useCallback((b,S,d)=>{k("/_api/set-artboard-hug",{artboardId:b,fixed:S,freezeHeight:d},{label:S?"pin artboard height":"hug artboard height",onOk:()=>m(b,V)})},[k,m,V]),K70=u.useCallback((b,S)=>{k("/_api/set-artboard-style",{artboardId:b,...S},{label:"artboard style",onOk:()=>m(b,V)})},[k,m,V]),RL=u.useRef(null),Eq=u.useCallback((b,S)=>{k("/_api/set-artboard-kind",{artboardId:b,kind:S},{label:"artboard kind",onOk:()=>m(b,V)});let d=RL.current;if(S==="print"&&d&&d.artboardId===b)RL.current=null,k("/_api/resize-artboard",{artboardId:b,width:d.widthPx,height:d.heightPx},{label:"artboard size"}),k("/_api/set-artboard-print",{artboardId:b,print:d.defaults},{label:"artboard print"})},[k,m,V]),IT=u.useRef(null);u.useEffect(()=>{IT.current=Eq},[Eq]);let R1=u.useCallback((b,S,d)=>{if(S==="print"||S==null||S==="digital"){if(d)RL.current={artboardId:b,...d};b8({dgn:"freeze-and-set-kind",artboardId:b,kind:S==="digital"?null:S,ask:!0});return}Eq(b,S)},[Eq,b8]),CL=u.useCallback((b,S)=>{k("/_api/set-artboard-print",{artboardId:b,print:S},{label:"artboard print",onOk:()=>m(b,V)})},[k,m,V]),U70=u.useCallback((b)=>{let S=`s${Math.random().toString(36).slice(2,8)}`;if(b.startsWith("print-")){let X0=b.slice(6),K0;try{K0=ZB({paper:X0})}catch{return}let F0=GB.find((I0)=>I0.id===X0);G7({id:S,label:F0?F0.label:X0.toUpperCase(),width:K0.widthPx,height:K0.heightPx}),R1(S,"print"),CL(S,{paper:X0});return}let d=$5[b];if(!d)return;G7({id:S,label:d.label,width:d.width,height:d.height})},[G7,R1,CL]),kT=u.useRef(null),TT=u.useRef(null),RT=u.useRef(null),CT=u.useRef(null),$T=u.useRef(null),V70=u.useRef(null),ST=u.useRef(null),bT=u.useRef(null),yT=u.useRef(null),jT=u.useRef(null);u.useEffect(()=>{kT.current=y,TT.current=h,RT.current=G7,CT.current=xJ,$T.current=wq,V70.current=R1,ST.current=N0,bT.current=TL,yT.current=Z8,jT.current=W9},[y,h,G7,xJ,wq,R1,N0,TL,Z8,W9]),u.useEffect(()=>{let b=(S)=>{if(S.key!=="Backspace"&&S.key!=="Delete")return;if(S.metaKey||S.ctrlKey||S.altKey)return;let d=S.target;if(d&&(d.tagName==="INPUT"||d.tagName==="TEXTAREA"||d.tagName==="SELECT"||d.isContentEditable))return;if(S.preventDefault(),!V||V===o8)return;let K0=Array.isArray(w)?w.length===1?w[0]:null:w;if(K0?.artboardId&&!K0.id)wq(K0.artboardId)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[V,w,wq]);let[eG,C1]=u.useState(null),Pq=u.useRef(null);u.useEffect(()=>{Pq.current=(b)=>C1(b)},[]);let[$L,SL]=u.useState(null),vT=u.useRef(null);u.useEffect(()=>{vT.current=(b)=>SL(b)},[]);let q70=u.useCallback((b)=>{let S=eG;if(C1(null),!S||!b)return;if(S.canvas&&S.canvas!==V){console.warn("[asset-picker] active canvas changed since request — aborting");return}if(S.purpose==="insert-image"){h(S.refId,S.position||"after","image",{artboardId:S.artboardId,src:b,refIndex:S.refIndex});return}if(S.purpose==="replace-src"){let d=V;if(!d||!S.id)return;k6.current=k6.current.catch(()=>{}).then(()=>fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:d,id:S.id,attr:"src",value:b})}).then((X0)=>X0.json().catch(()=>({}))).then((X0)=>{if(X0.ok)sJ({op:"attr",canvas:d,id:S.id,key:"src",before:Mq(X0,S.before??null),after:b});else console.warn("[replace-src]",X0.error||"failed")}).catch(()=>{}));return}if(S.purpose==="replace-annotation-media")b8({dgn:"replace-annotation-media",id:S.id,path:b})},[eG,h,V,sJ,b8]),B70=u.useCallback((b,S)=>{let d=eG;if(C1(null),!d||!Array.isArray(b)||!b.length)return;if(d.canvas&&d.canvas!==V){console.warn("[asset-picker] active canvas changed since request — aborting");return}if(S==="artboard"){let X0=P.current?.artboardId??Y7??null;if(!X0)return;for(let K0 of b)h(void 0,"inside-end","image",{artboardId:X0,src:K0});return}b8({dgn:"insert-annotation-media",paths:b})},[eG,V,h,Y7,b8]),N70=u.useCallback(async(b)=>{let S=$L;if(SL(null),!S||!b?.url)return;if(S.canvas&&S.canvas!==V){console.warn("[sticker-picker] active canvas changed since request — aborting");return}try{let d=await fetch(b.url).then((F0)=>F0.ok?F0.blob():Promise.reject(Error(`HTTP ${F0.status}`))),X0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":d.type||"image/png"},body:d}),K0=await X0.json().catch(()=>({}));if(!X0.ok||!K0.path){console.warn("[sticker-picker]",K0.error||`upload failed (HTTP ${X0.status})`);return}b8({dgn:"insert-sticker",path:K0.path})}catch{console.warn("[sticker-picker] could not load or upload that sticker")}},[$L,V,b8]),F70=u.useCallback((b)=>{if(!b?.id)return;C1({purpose:"replace-src",canvas:V,id:b.id,before:b.attrs?.src??null})},[V]),L70=u.useCallback((b)=>{b7({type:"comments-patch",id:b,patch:{status:"resolved"}})},[]),D70=u.useCallback((b)=>{b7({type:"comments-patch",id:b,patch:{status:"open"}})},[]),M70=u.useCallback((b)=>{b7({type:"comments-delete",id:b}),M0((S)=>S===b?null:S)},[]),O70=u.useCallback((b,S)=>{if(b&&b!==V)N((X0)=>X0.find((K0)=>K0.path===b)?X0:[...X0,{path:b}]),F(b);if(S==null){M0(null);return}M0(S);let d=()=>{let X0=R0.current.get(b);if(X0&&X0.contentWindow)try{X0.contentWindow.postMessage({dgn:"comment-focus",id:S},"*")}catch{}};d(),setTimeout(d,200)},[V]);u.useEffect(()=>{function b(S){let d=S.metaKey||S.ctrlKey,X0=["INPUT","TEXTAREA"].includes(document.activeElement?.tagName)||document.activeElement?.isContentEditable,K0=document.activeElement?.tagName==="IFRAME";if(e9&&S.key==="Escape"){S.preventDefault(),D4();return}if(d&&(S.key==="k"||S.key==="K")){S.preventDefault(),NX((F0)=>!F0);return}if(d&&!S.altKey&&(S.key==="z"||S.key==="Z"||S.key==="y"||S.key==="Y")){if(!X0&&!K0&&V&&V!==o8){if((S.key==="z"||S.key==="Z")&&Q6.current.open&&Q6.current.comps?.length)return;let F0=S.key==="y"||S.key==="Y"||S.shiftKey;if(z4==="photo"&&F4(F0)){S.preventDefault();return}S.preventDefault(),b8({dgn:F0?"redo":"undo"});return}}if(d&&S.shiftKey&&(S.key==="r"||S.key==="R")){S.preventDefault(),sG();return}if(d&&(S.key==="r"||S.key==="R")){S.preventDefault(),g5();return}if(d&&S.shiftKey&&(S.key==="m"||S.key==="M")){S.preventDefault(),x6("comments");return}if(d&&S.shiftKey&&(S.key==="g"||S.key==="G")){S.preventDefault(),x6("changes");return}if(d&&S.shiftKey&&(S.key==="i"||S.key==="I")){S.preventDefault(),x6("inspector");return}if(d&&S.shiftKey&&(S.key==="a"||S.key==="A")&&H9()){if(S.preventDefault(),!r8)x6("assistant");return}if(d&&S.shiftKey&&(S.key==="e"||S.key==="E")){S.preventDefault(),X6({mode:"export"});return}if(d&&S.shiftKey&&(S.key==="h"||S.key==="H")){S.preventDefault(),X6({mode:"handoff"});return}if(d&&!S.shiftKey&&!S.altKey&&S.key===","){if(S.preventDefault(),!r8)bJ(!0);return}if(d&&S.shiftKey&&(S.key==="t"||S.key==="T")){S.preventDefault(),PY();return}if(d&&!S.shiftKey&&!S.altKey&&(S.key==="c"||S.key==="C")){if(w&&w.selector&&V&&V!==o8&&!X0&&console&&console.warn)console.warn("Cmd+C comment-drop deprecated — press C inside the canvas to enter Comment tool, then click the element.")}if(X0)return;if(S.key==="/"){S.preventDefault();let F0=document.querySelector(".st-search input");if(F0)F0.focus();return}if(d&&(S.key==="f"||S.key==="F")){if(S.preventDefault(),!CJ)yJ("tree");setTimeout(()=>{let F0=document.querySelector(".st-search input");if(F0)F0.focus()},0);return}if(K0){if(S.key!=="Escape")return}if(S.key==="t"||S.key==="T"){if(S.shiftKey||d)return;S.preventDefault(),j5("tree");return}if(S.key==="h"||S.key==="H"){if(S.shiftKey||d)return;S.preventDefault(),$J((F0)=>!F0);return}if((S.key==="s"||S.key==="S")&&!d&&!S.shiftKey){if(S.preventDefault(),V===o8)cY(o8);else SQ();return}if((S.key==="n"||S.key==="N")&&!d&&!S.shiftKey){S.preventDefault(),yJ("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60);return}if(S.key==="?"){S.preventDefault(),BX((F0)=>!F0);return}if(S.key==="F1"){S.preventDefault(),qJ(!0);return}if(S.key==="Escape"){if(t){M0(null);return}}}return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[g5,sG,w,V,t,CJ,SQ,cY,T1,e9,D4,PY,z4,F4,r8]);let A70=u.useCallback((b,S)=>{if(S)R0.current.set(b,S)},[]),_70=e90(b9).open,w70=u.useCallback((b)=>{let S=b.target;if(S&&(S.tagName==="INPUT"||S.tagName==="TEXTAREA"||S.isContentEditable))return;b.preventDefault()},[]),E70=u.useMemo(()=>[{id:"new",group:"Canvas",label:"New canvas…",icon:"plus",kbd:"N",run:()=>{yJ("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60)}},{id:"new-video",group:"Canvas",label:"New video…",icon:"plus",run:()=>dH()},{id:"export",group:"Canvas",label:"Export…",icon:"download",kbd:"⇧⌘E",run:()=>X6({mode:"export"})},{id:"share-link",group:"Canvas",label:"Copy share link",icon:"link",run:()=>{let b=mH(dY),S=b.web??b.app??b.local;if(S)vV(S)}},{id:"handoff",group:"Canvas",label:"Handoff to production",icon:"external",kbd:"⇧⌘H",run:()=>X6({mode:"handoff"})},{id:"generate",group:"Canvas",label:"Generate with AI…",icon:"sparkle",run:()=>Z4(!0)},{id:"settings",group:"Canvas",label:"Settings…",icon:"sliders",kbd:"⌘,",run:()=>bJ(!0)},{id:"system",group:"View",label:"Open design system view",icon:"sliders",kbd:"S",run:()=>SQ()},{id:"comments",group:"View",label:"Toggle comments panel",icon:"resolve",kbd:"⌘⇧M",run:()=>x6("comments")},{id:"inspector",group:"View",label:"Open inspector",icon:"sliders",kbd:"⌘⇧I",run:()=>DX("inspector")},{id:"reload",group:"View",label:"Reload active canvas",icon:"reload",kbd:"⌘R",run:()=>g5()},{id:"draw",group:"Tools",label:"Draw a mark with the SVG agent",icon:"pen",run:()=>{try{navigator.clipboard?.writeText("/design:draw ")}catch{}}},{id:"theme",group:"Tools",label:"Toggle light / dark theme",icon:"sun",run:()=>A4()},{id:"whatsnew",group:"Help",label:"What's new in maude",icon:"sparkle",run:()=>wQ.openPanel()},{id:"shortcuts",group:"Help",label:"Keyboard shortcuts",icon:"help",kbd:"?",run:()=>BX(!0)},{id:"help",group:"Help",label:"Help · commands & flows",icon:"help",kbd:"F1",run:()=>qJ(!0)},{id:"report-bug",group:"Help",label:"Report a bug…",icon:"help",run:()=>NQ(!0)}],[SQ,A4,g5,wQ,dH,dY,nG,n8,w8,i0.designRel]),P70=(b)=>{if(r8&&b==="assistant")return!1;if(b==="sync")return!!o0;return b==="assistant"?H9():b==="layers"?T0==="separate":!0},fT=(b)=>wT.filter((S)=>P70(S.id)&&(L0[S.id]||aK[S.id])===b).map((S)=>S.id),xT={tree:CJ,layers:r,inspector:oX,comments:_0,changes:k8,sync:N9,assistant:LX},hT=i0.cloud?{changes:"History"}:null,gT=fT("left"),mT=fT("right"),P4=gT.find((b)=>xT[b])||null,iY=mT.find((b)=>xT[b])||null,uT=H9()&&!r8&&(L0.assistant||"right")==="left",pT=H9()&&!r8&&(L0.assistant||"right")==="right",JZ=(b)=>(L0[b]||aK[b])==="left"?D8==="sb":D8==="rp",$1=V&&V!==o8&&/\.(tsx|html)$/i.test(V)?V:null,lT=$1?ML(b9[$1]):0,dT=(b)=>{if(b==="tree")return z(PL0,{cloud:i0.cloud,readOnly:r8,groups:VJ.ready?J:YL0,activePath:V,previewPath:M,activeDsName:V===o8?t0?.ds?.name??null:null,onOpen:K6,onPreview:E,onOpenLinkedFile:E4,filesReady:Q,treeLoadFailures:W,onShare:uH,onOpenSystem:SQ,wsConnected:q0,search:N8,setSearch:B0,commentsByFile:b9,showHidden:w6,sectionsExpanded:RH,onToggleSection:mG,treeExpansion:uG,onNewBoard:L1,onDeleteBoard:M1,onMoveCanvas:O1,onNewFolder:A1,onDeleteFolder:_1,onRenameFolder:w1,onRenameCanvas:E1,onDuplicateCanvas:P1,onDeleteFile:I1,onRefresh:sG,refreshing:F1,collapsed:!1,onCollapse:()=>j5("tree"),resizing:JZ("tree"),dirtyByPath:B1,project:K,gitBranch:A0?.branch,remoteSync:q8,onGetLatest:lY,canvasKinds:i0?.canvasKinds,syncStatus:o0,onLinkedHub:C8,onLocalProject:w0,savingIsManaged:E0});if(b==="changes")return z(_w,{status:A0&&q8?{...A0,...q8}:A0,project:K,readOnly:!H9()||r8,historyOnly:Y9,cloudManaged:c8,resizing:JZ("changes"),onClose:()=>x8(!1),onCommit:pG,onDiscard:pY,onPublish:lG,onGetLatest:lY,loadLog:async(S)=>{let d=await iG(S);if(K1(d!=="legacy"),d!=="legacy")return d;return(c8?H1:w4)(S)},historySource:z1?"project":c8?"cloud":"local",historyRefresh:`${o0?.appliedRevision??0}:${U1}`,onRestoreVersion:(S)=>hH(V,S).then((d)=>!!d.ok),onUndoAction:Y9?void 0:async(S)=>{let d=await fetch("/_api/project/undo",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionId:S})}).catch(()=>null);return!!(d?await d.json().catch(()=>null):null)?.ok},cloudHistory:cG,onOpenCanvas:(S)=>K6(S),onOpenDiff:(S)=>z9({file:S,beforeSha:"HEAD",conflict:!1}),activeCanvas:$1,onPreviewVersion:(S)=>z9({file:V,beforeSha:S,conflict:!1}),designRel:(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,"")});if(b==="sync")return z(hw,{status:o0,project:i0?.cloud?.projectName||K,cloud:i0?.cloud??null,groupPaths:(J||[]).map((S)=>S.path).filter(Boolean),resizing:JZ("sync"),onClose:()=>m0(!1)});if(b==="inspector"||b==="layers")return z(DD0,{testId:b==="layers"?"layers-panel":"inspector-panel",layersOnly:b==="layers",hideLayersTab:T0==="separate",cpMode:G9,onSetCpMode:y9,selected:w,cfg:i0,tab:b==="layers"?"layers":z4,onTabChange:sX,onClose:()=>b==="layers"?W0(!1):DQ(!1),onOptimistic:_X,onRecordEdit:sJ,onReplaceMedia:F70,onResizeArtboard:xJ,onSetArtboardHug:z70,onSetArtboardStyle:K70,onSetArtboardKind:R1,onSetArtboardPrint:CL,onDuplicateArtboard:TL,editScope:T,onUndoRedo:(S)=>b8({dgn:S}),photoSel:EG,photoRev:PG,onPhotoEdit:N4,onPhotoRemoveBackground:jG,onPhotoRecordEdit:yG,onPhotoUndoRedo:(S)=>F4(S==="redo"),layersTree:s,componentMap:a,lockedKeys:M4,onToggleLock:gG,onDetachInstance:G0,canvasFile:V,onSelectLayer:(S)=>b8({dgn:"select-by-id",id:S.id,artboardId:s?.artboardId,index:S.index}),onHoverLayer:(S)=>b8({dgn:"highlight",id:S?S.id:null,artboardId:s?.artboardId,index:S?S.index:0}),onReorderLayer:q,layersBusyRef:n,resizing:JZ(b)});if(b==="comments")return z(nL0,{commentsByFile:b9,filter:Q8,setFilter:a8,activePath:V,focusedId:t,onJump:O70,onResolve:r8?void 0:L70,onReopen:r8?void 0:D70,onDelete:r8?void 0:M70,resizing:JZ("comments")});return null};return D("div",{className:"maude"+(e9?" is-present":""),"data-theme":j8,onContextMenu:w70,children:[LJ&&z(pw,{}),z(aL0,{cloud:i0.cloud}),z(sL0,{update:V4,onDismiss:()=>IY(null)}),z(tL0,{status:o0}),!LJ&&z(Ew,{status:o0,cloud:i0.cloud}),z(bg,{paused:!!TY||!!v5,hiddenGroups:jJ.panelOpen?["exports"]:[]}),z(am,{wn:wQ}),z(gm,{center:jJ}),C0&&D("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:"Repo state changed — reload to sync?"}),z("button",{type:"button",className:"btn btn--primary btn--sm",onClick:()=>{try{window.location.reload()}catch{}},children:"Reload"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:()=>a0(null),children:"Dismiss"})]}),D("div",{className:"st-shell",children:[z(fL0,{sharePath:dY,onShare:()=>uH(),readOnly:r8,cloud:i0.cloud,activePath:V,project:K,tabsCount:B.length,openMenu:t9,setOpenMenu:q7,commentsPanelOpen:_0,onToggleComments:()=>x6("comments"),changesOpen:k8,changesCount:V8,onToggleChanges:()=>x6("changes"),onOpenSystem:SQ,sidebarOpen:CJ,onToggleSidebar:()=>j5("tree"),showHidden:w6,onToggleShowHidden:()=>$J((b)=>!b),onOpenHelp:()=>qJ(!0),onOpenShortcuts:()=>BX(!0),onReportBug:()=>NQ(!0),onStartTour:()=>MX(HF),onStartCollabTour:()=>MX(kE),annotationsVisible:PQ,onToggleAnnotations:fY,minimapVisible:J5,onToggleMinimap:xY,zoomCtlVisible:aJ,onToggleZoomCtl:hY,presentMode:e9,onTogglePresent:xG,printGuidesVisible:B4,onTogglePrintGuides:hG,postToActiveCanvas:b8,onOpenReadiness:()=>FQ(!0),onOpenQuickSetup:()=>nJ(!0),onWatchIntro:()=>x7(!0),onOpenWhatsNew:wQ.openPanel,whatsNewCount:wQ.unseen.length,exportCenter:jJ,artboardCount:$G,inspectorOpen:oX,inspectorTab:z4,onToggleInspector:()=>x6("inspector"),autoOpenInspector:tX,onToggleAutoOpenInspector:()=>IG((b)=>!b),onInsertArtboard:U70,timelineOpen:B8,onToggleTimeline:PY,hasComps:J9.length>0,assistantOpen:LX,onToggleAssistant:()=>x6("assistant"),assistantBusy:Q1,assistantUnseen:Y1,onOpenLayers:()=>{if(T0==="separate")j5("layers");else if(oX&&z4==="layers")DQ(!1);else sX("layers"),yJ("inspector")},onNewCanvas:()=>{yJ("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60)},onAssembleVideo:D1,onOpenExport:(b)=>X6({mode:b}),onOpenSettings:()=>bJ(!0),onOpenGenerate:()=>Z4(!0),onReload:g5,onCloseCanvas:()=>V&&cY(V),presence:D(Q0,{children:[z(C90,{initials:UL0(f5||"you"),hue:"var(--accent)",title:f5?`${f5} (you)`:"You"}),bG&&z(C90,{initials:"C",hue:"var(--presence-agent)",title:"Claude · editing",pulse:!0})]})}),D("div",{className:"st-body"+(D8?" is-resizing":""),ref:L9,children:[z(IL0,{shown:!P4,onExpand:()=>yJ("tree"),onSearch:()=>{yJ("tree"),setTimeout(()=>document.querySelector(".st-search input")?.focus(),60)}}),(P4||uT)&&D(I90,{side:"left",width:U0.w,open:!!P4,ids:gT,activeId:P4,onPick:j5,labels:hT,children:[uT&&z(vN,{hidden:P4!=="assistant",activeCanvas:$1,selected:w,openComments:lT,designRel:(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,""),resizing:JZ("assistant"),onClose:()=>_G(!1),onBusyChange:jH,onFinished:_Y,onPermissionRequest:EY,onElicitationRequest:EY}),P4&&P4!=="assistant"&&dT(P4)]}),P4&&z(S90,{label:"Resize left panel",size:U0,active:D8==="sb",onPointerDown:(b)=>{b.preventDefault(),b.currentTarget.setPointerCapture?.(b.pointerId),e8("sb")}}),z("div",{className:"main",children:z(xL0,{tabs:B,activePath:V,registerIframe:A70,systemData:t0,onOpenFromSystem:K6,onSelectDs:Y5,project:K,cfg:i0,loadingPath:p8,onIframeLoad:l7,canvasError:b0,canvasReloadNonce:O8,onRetryCanvasLoad:N1,loadedPath:e0,showQuickSetup:H9()&&!r8&&!!E6&&!E6.ready,onStartQuickSetup:()=>nJ(!0),previewPath:M})}),iY&&z(S90,{label:"Resize right panel",dir:"rtl",size:n0,active:D8==="rp",onPointerDown:(b)=>{b.preventDefault(),b.currentTarget.setPointerCapture?.(b.pointerId),e8("rp")}}),(iY||pT)&&D(I90,{side:"right",width:n0.w,open:!!iY,ids:mT,activeId:iY,onPick:j5,labels:hT,children:[pT&&z(vN,{hidden:iY!=="assistant",activeCanvas:$1,selected:w,openComments:lT,designRel:(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,""),resizing:JZ("assistant"),onClose:()=>_G(!1),onBusyChange:jH,onFinished:_Y,onPermissionRequest:EY,onElicitationRequest:EY}),iY&&iY!=="assistant"&&dT(iY)]})]}),B8&&z(BE,{comps:J9,compId:P6,sequences:r6,audio:MG,transitions:y5,total:OQ,frame:b5,playing:rJ,loop:MY,onSeek:(b)=>{z6(b),n6(!1),b8({dgn:"timeline-seek",frame:b,id:P6})},onPlay:()=>{n6(!0),b8({dgn:"timeline-mute",muted:v6,id:P6}),b8({dgn:"timeline-loop",loop:MY,id:P6}),b8({dgn:"timeline-play",id:P6})},onPause:()=>{n6(!1),b8({dgn:"timeline-pause",id:P6})},onToggleLoop:()=>DG((b)=>{let S=!b;return b8({dgn:"timeline-loop",loop:S,id:P6}),S}),muted:v6,onToggleMute:()=>{k7((b)=>{let S=!b;return b8({dgn:"timeline-mute",muted:S,id:P6}),S})},volume:W7,onVolume:(b)=>{if(nX(b),b>0&&v6)k7(!1),b8({dgn:"timeline-mute",muted:!1,id:P6});b8({dgn:"timeline-volume",volume:b,id:P6})},onRetime:(b,S)=>{if(!V||V===o8)return;let d=c7||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${d?`&artboardId=${encodeURIComponent(d)}`:""}`;fetch(X0).then((K0)=>K0.json().catch(()=>({}))).then((K0)=>{let F0=I6(K0,b),I0=b&&typeof b==="object"?b.index:b,p=F0?.stableId?{canvas:V,artboardId:d,stableId:F0.stableId,contentHash:F0.contentHash,...S}:{canvas:V,index:I0,...S};return fetch("/_api/retime-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(p)})}).then((K0)=>K0.json()).then((K0)=>{if(!K0?.ok)console.warn("[retime]",K0?.error||"failed"),NJ("Retime refused",K0?.error);else if(g8(S.from!=null?"Clip moved.":"Clip trimmed.",!0),K0?.seq!=null)Y6(V,K0.seq,S.from!=null?"move clip":"trim clip")}).catch(()=>{})},onRemove:$Y,onReplace:(b)=>{if(!V||V===o8)return;tG({accept:"video/*,image/*",resolveTarget:(S)=>{let d=I6(S,b);if(d?.mediaArrayRef)return{arrayRef:d.mediaArrayRef};if(d?.mediaCdId)return{cdId:d.mediaCdId};return null}})},onReplaceAudio:(b)=>{if(!V||V===o8)return;tG({accept:"audio/*",resolveTarget:(S)=>{let d=S?.ok&&Array.isArray(S.media)?S.media.filter((X0)=>X0.tag==="Audio"):[];return d[b]?.cdId?{cdId:d[b].cdId}:null}})},onReplaceLayer:(b,S)=>{if(!V||V===o8)return;let d=b&&typeof b==="object"?b.index:b,X0=r6[d]?.layers?.[S]?.kind==="audio"?"audio/*":r6[d]?.layers?.[S]?.kind==="image"?"image/*":"video/*";tG({accept:X0,resolveTarget:(K0)=>{let F0=I6(K0,b)?.layers?.[S];if(F0?.mediaArrayRef)return{arrayRef:F0.mediaArrayRef};if(F0?.mediaCdId)return{cdId:F0.mediaCdId};return null}})},onReorder:(b,S)=>{if(!V||V===o8)return;let d=c7||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${d?`&artboardId=${encodeURIComponent(d)}`:""}`;fetch(X0).then((K0)=>K0.json().catch(()=>({}))).then((K0)=>{let F0=K0?.ok&&Array.isArray(K0.clips)?K0.clips.filter((K8)=>K8.kind==="sequence"):[],I0=I6(K0,b),p=I0?F0.indexOf(I0):-1,D0=S==="forward"?p+1:p-1,O0=p>=0?F0[D0]||null:null,g0=S==="forward"?"after":"before";if(!I0?.stableId||!O0?.stableId)return null;return fetch("/_api/reorder-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:d,stableId:I0.stableId,contentHash:I0.contentHash,refStableId:O0.stableId,refContentHash:O0.contentHash,position:g0})})}).then((K0)=>K0?K0.json():null).then((K0)=>{if(K0&&!K0.ok)console.warn("[reorder-clip]",K0.error||"failed"),NJ("Reorder refused",K0.error);else if(K0?.seq!=null)Y6(V,K0.seq,"reorder clip")}).catch(()=>{})},onToggleHide:(b)=>{if(!V||V===o8)return;let S=c7||void 0,d=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${S?`&artboardId=${encodeURIComponent(S)}`:""}`;fetch(d).then((X0)=>X0.json().catch(()=>({}))).then((X0)=>{let K0=I6(X0,b);if(!K0?.stableId)return null;return fetch("/_api/toggle-hide",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:S,stableId:K0.stableId,contentHash:K0.contentHash})})}).then((X0)=>X0?X0.json():null).then((X0)=>{if(X0&&!X0.ok)NJ("Hide refused",X0.error);else if(X0&&X0.ok){if(g8(X0.hidden?"Clip hidden.":"Clip shown.",!0),X0.seq!=null)Y6(V,X0.seq,X0.hidden?"hide clip":"show clip")}}).catch(()=>g8("Hide failed: network error"))},onReorderMove:(b,S,d)=>{if(!V||V===o8)return;let X0=c7||void 0,K0=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${X0?`&artboardId=${encodeURIComponent(X0)}`:""}`;fetch(K0).then((F0)=>F0.json().catch(()=>({}))).then((F0)=>{let I0=I6(F0,b),p=I6(F0,S);if(!I0?.stableId||!p?.stableId)return null;return fetch("/_api/reorder-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:X0,stableId:I0.stableId,contentHash:I0.contentHash,refStableId:p.stableId,refContentHash:p.contentHash,position:d,mode:"move"})})}).then((F0)=>F0?F0.json():null).then((F0)=>{if(F0&&!F0.ok)console.warn("[reorder-move]",F0.error||"failed"),NJ("Reorder refused",F0.error);else if(F0?.ok){if(g8("Clip moved.",!0),F0.seq!=null)Y6(V,F0.seq,"move clip")}}).catch(()=>g8("Reorder failed: network error"))},onDropMedia:(b,S)=>{if(!V||V===o8)return;let d=c7||void 0,X0=OY,K0=V,F0=(Array.isArray(b)?b:[b]).filter(Boolean);(async()=>{if(!J9.length){let p=[];for(let O0 of F0){let g0=O0.type.startsWith("audio/")?"audio":O0.type.startsWith("video/")?"video":null;if(!g0)continue;try{let K8=await fetch("/_api/asset",{method:"POST",headers:{"Content-Type":O0.type||"application/octet-stream"},body:O0}),L8=await K8.json().catch(()=>({}));if(L8?.path)p.push({src:L8.path,mediaKind:g0});else g8(`Upload failed: ${L8?.error||`HTTP ${K8.status}`}`)}catch{g8("Upload failed: network error")}}if(!p.length){g8("No video/audio files in the drop — nothing to cut.");return}let D0=!1;for(let O0 of p){let g0=await ZE(O0.src).catch(()=>null),K8={canvas:K0,lane:O0.mediaKind==="audio"&&D0?"audio":"storyline",durationInFrames:B3(X0,g0),mediaTag:O0.mediaKind==="audio"?"Audio":"Video",src:O0.src};if(K8.lane==="audio")K8.from=0;let L8=await fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(K8)}).catch(()=>null),U6=L8?await L8.json().catch(()=>null):null;if(U6?.ok){if(D0=!0,U6.seq!=null)Y6(K0,U6.seq,"add clip")}else if(!D0)break;else NJ("Insert refused",U6?.error)}if(D0){g8("Artboard upgraded to a video comp — clips added to the storyline.",!0);return}for(let O0=0;O0<8;O0+=1){let g0=O0===0?"New Cut":`New Cut ${O0+1}`,K8=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:g0,kind:"video-comp",clips:p})}).catch(()=>null),L8=K8?await K8.json().catch(()=>({})):{};if(K8?.status===409)continue;if(!K8?.ok||!L8.ok){g8(`New cut failed: ${L8.error||"create refused"}`);return}await S9(),K6(L8.file),g8(`Started a new cut from ${p.length} clip${p.length>1?"s":""}.`,!0);return}g8('New cut failed: too many "New Cut" canvases — rename some.');return}let I0=S?.lane==="storyline"?S.index:void 0;for(let p of F0){let D0=p.type.startsWith("video/")?"Video":p.type.startsWith("audio/")?"Audio":p.type.startsWith("image/")?"Img":null;if(!D0)continue;let O0;try{O0=await(await fetch("/_api/asset",{method:"POST",headers:{"Content-Type":p.type||"application/octet-stream"},body:p})).json().catch(()=>({}))}catch{O0=null}if(!O0?.path){g8(`Upload failed: ${O0?.error||"server unreachable — retry in a moment"}`);continue}let g0=D0==="Audio",K8=D0==="Video"?await ZE(O0.path).catch(()=>null):null,L8={canvas:K0,artboardId:d,mediaTag:D0,src:O0.path};if(S&&(g0||S.lane==="audio"))L8.lane="audio",L8.from=Math.max(0,S.frame??0),L8.durationInFrames=Math.max(X0,OQ-L8.from);else if(S?.lane==="storyline"&&!g0){if(L8.lane="storyline",I0!=null)L8.index=I0,I0+=1;L8.durationInFrames=B3(X0,K8)}else if(S?.lane==="overlay"&&!g0){if((r6||[]).length===0)L8.lane="storyline";else L8.lane="overlay",L8.from=Math.max(0,S.frame??0);L8.durationInFrames=B3(X0,K8)}else if(!g0)L8.lane="storyline",L8.durationInFrames=B3(X0,K8);else L8.lane="audio",L8.from=0,L8.durationInFrames=Math.max(X0,OQ);try{let P7=await(await fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(L8)})).json().catch(()=>null);if(P7&&!P7.ok)console.warn("[insert-clip]",P7.error||"failed"),NJ("Insert refused",P7.error);else if(P7?.ok){if(g8("Clip added to the timeline.",!0),P7.seq!=null)Y6(K0,P7.seq,"add clip")}}catch{g8("Insert failed: network error")}}})()},height:BJ,onResize:X9,onClose:()=>K9(!1),selectedClipId:bH,onSelect:AY,transitionClips:fG,onClipVerb:CQ,comments:(b9[V]||[]).filter((b)=>b&&b.timeline),promptText:Q5,onAddComment:bY,onResolveComment:(b)=>b7({type:"comments-patch",id:b,patch:{status:"resolved"}}),onDeleteComment:(b)=>b7({type:"comments-delete",id:b}),onSplitAtPlayhead:()=>{let b=Q6.current,S=b.selected!=null?{stableId:b.selected}:null;if(!S){let d=b.sequences||[],X0=d.find((K0)=>K0.series&&b.frame>=K0.from&&b.frame<K0.from+K0.duration)||d.find((K0)=>b.frame>=K0.from&&b.frame<K0.from+K0.duration);if(X0?.stableId)S={stableId:X0.stableId}}if(S)CQ(S,"split",{atFrame:b.frame});else g8("Nothing under the playhead to split.")},onAddTitle:(b)=>{if(!V||V===o8)return;Promise.resolve("Title").then((S)=>{if(!S)return;fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:c7||void 0,lane:"overlay",from:b,durationInFrames:Math.round(OY*3),mediaTag:"Title",src:S})}).then((X0)=>X0.json().catch(()=>null)).then((X0)=>{if(X0&&!X0.ok)NJ("Title refused",X0.error);else if(X0?.ok){if(g8("Title added.",!0),X0.seq!=null)Y6(V,X0.seq,"add title")}}).catch(()=>g8("Title failed: network error"))})},onAddAiClip:()=>{if(!V||V===o8)return;(async()=>{fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:c7||void 0,lane:"storyline",durationInFrames:Math.round(OY*5),placeholder:{prompt:"Describe this shot — double-click to edit",kind:"veo"}})}).then((X0)=>X0.json().catch(()=>null)).then((X0)=>{if(X0&&!X0.ok)NJ("AI clip refused",X0.error);else if(X0?.ok){if(g8("AI placeholder added — double-click its text to write the prompt, then right-click → Generate ✨.",!0),X0.seq!=null)Y6(V,X0.seq,"add AI placeholder")}}).catch(()=>g8("AI clip failed: network error"))})()},onGeneratePlaceholder:(b)=>{if(!V||V===o8)return;let S=V,d=c7||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(S)}${d?`&artboardId=${encodeURIComponent(d)}`:""}`;fetch(X0).then((K0)=>K0.json().catch(()=>({}))).then((K0)=>{let F0=I6(K0,b),I0=F0?.placeholder;if(!F0?.stableId||!I0?.prompt){g8("No AI placeholder prompt on this clip.");return}let p=I0.kind==="image"?"image":"video",D0=I0.kind==="motion"?`Clean, minimal motion-graphics animation (flat shapes, smooth easing): ${I0.prompt}`:I0.prompt;fetch("/_api/generate-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({provider:"gemini",modality:p,prompt:D0})}).then(async(O0)=>O0.ok?O0.json():Promise.reject(Error(await O0.text()))).then((O0)=>{let g0=O0?.id;if(!g0)throw Error("no job id");g8(`Generating ${I0.kind}… (runs in the background)`,!0);let K8=F0.stableId,L8=()=>{fetch("/_api/generate-jobs").then((U6)=>U6.json().catch(()=>({}))).then((U6)=>{let P7=(U6?.jobs||[]).find((AJ)=>AJ.id===g0);if(!P7||P7.status==="failed"){g8(`Generation failed: ${P7?.error||"job lost"}`);return}if(P7.status!=="done"){setTimeout(L8,4000);return}let p9=P7.assets?.[0];if(!p9){g8("Generation finished but produced no asset.");return}fetch(X0).then((AJ)=>AJ.json().catch(()=>({}))).then((AJ)=>{let XZ=I6(AJ,{stableId:K8});if(!XZ?.stableId){g8("Placeholder clip is gone — generated asset kept in assets/.");return}CQ({stableId:XZ.stableId},"resolve-placeholder",{src:p9,mediaKind:p==="image"?"image":"video"})})}).catch(()=>setTimeout(L8,6000))};setTimeout(L8,3000)}).catch((O0)=>g8(`Generate failed: ${O0?.message||"provider error"} — is a Gemini key set in Settings?`))}).catch(()=>g8("Generate failed: network error"))},onAddImage:(b)=>{if(!V||V===o8)return;let S=(X0,K0)=>{let F0=OY;fetch("/_api/asset",{method:"POST",headers:{"Content-Type":K0||"application/octet-stream"},body:X0}).then((I0)=>I0.json().catch(()=>({}))).then((I0)=>{if(!I0?.path)return g8(`Upload failed: ${I0?.error||"unknown error"}`),null;return fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:c7||void 0,lane:"overlay",from:b,durationInFrames:Math.round(F0*3),mediaTag:"Img",src:I0.path})})}).then((I0)=>I0?I0.json():null).then((I0)=>{if(I0&&!I0.ok)NJ("Image refused",I0.error);else if(I0?.ok){if(g8("Image overlay added.",!0),I0.seq!=null)Y6(V,I0.seq,"add image overlay")}}).catch(()=>g8("Image failed: network error"))};if(H9()){cZ().then((X0)=>{if(X0?.bytes)S(new Blob([new Uint8Array(X0.bytes)]),"")}).catch((X0)=>g8(`Image pick failed: ${X0?.message||"dialog error"}`));return}let d=document.createElement("input");d.type="file",d.accept="image/*",d.addEventListener("change",()=>{let X0=d.files?.[0];if(X0)S(X0,X0.type)}),d.click()},resolveMediaUrl:(b)=>`/${(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,"")}/${b}`}),z(oL0,{activePath:V,selected:w,wsConnected:q0,openCount:_70,theme:j8,onToggleTheme:A4,onClearSelected:k1,syncStatus:o0,syncProject:i0?.cloud?.projectName||K,syncOpen:N9,onOpenSync:o0?()=>x6("sync"):void 0,changesCount:V8,unpushed:E0?0:A0?.unpushed||0,savingIsManaged:E0,changesOpen:k8,onOpenChanges:A0?.repo||E0?()=>DX("changes"):void 0,version:i0?.version})]}),e9&&D("button",{type:"button",className:"st-present-exit",onClick:D4,"aria-label":"Exit presentation mode",title:"Exit presentation mode (Esc)",children:[z("svg",{viewBox:"0 0 16 16",width:"13",height:"13",fill:"none","aria-hidden":"true",children:z("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})}),z("span",{children:"Exit presentation"}),z("kbd",{className:"st-present-exit-kbd",children:"Esc"})]}),z(KL0,{open:LY,onClose:()=>NX(!1),actions:E70}),$Q&&z("div",{className:"st-scrim",role:"presentation",onMouseDown:(b)=>{if(b.target===b.currentTarget)x5(null)},children:D("div",{className:"st-dialog st-prompt",role:"dialog","aria-modal":"true","aria-label":$Q.title,children:[z("div",{className:"st-dialog-hd",children:z("span",{className:"st-dialog-title",children:$Q.title})}),D("div",{className:"st-dialog-bd",children:[z("input",{className:"st-input","data-testid":"shell-prompt-input",autoFocus:!0,defaultValue:$Q.value,onKeyDown:(b)=>{if(b.stopPropagation(),b.key==="Enter")x5(b.currentTarget.value);else if(b.key==="Escape")x5(null)}}),D("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:10},children:[z("button",{type:"button",className:"tlci-btn",onClick:()=>x5(null),children:"Cancel"}),z("button",{type:"button",className:"tlci-btn","data-testid":"shell-prompt-ok",onClick:(b)=>x5(b.currentTarget.closest(".st-dialog")?.querySelector("input")?.value??""),children:"OK"})]})]})]})}),W4&&z(yg,{target:W4,links:mH(W4.path),shell:nG,onClose:()=>DY(null),Icon:k9}),G4&&z(ML0,{mode:G4.mode,initialScope:G4.scope,activePath:V,hasComps:J9.length>0,comps:J9,activeArtboardId:w?.artboardId??Y7??null,selection:w?.selector?{selector:w.selector,file:w.file}:null,exportLane:i0.exportLane||"local",onBrowserCapture:RQ,onClose:()=>X6(null)}),iX&&z(_E,{cloud:i0.cloud,onClose:()=>bJ(!1),initialTab:typeof iX==="string"?iX:void 0,theme:j8,onSetTheme:S8,cpMode:G9,onSetCpMode:y9,minimapVisible:J5,onToggleMinimap:xY,zoomCtlVisible:aJ,onToggleZoomCtl:hY,annotationsVisible:PQ,onToggleAnnotations:fY,autoOpenInspector:tX,onToggleAutoOpenInspector:()=>IG((b)=>!b),hasCanvas:!!V&&V!==o8,panelSide:L0,onSetPanelSide:(b,S)=>v0((d)=>({...d,[b]:S})),layersMode:T0,onSetLayersMode:(b)=>{if(W8(b),b!=="separate")W0(!1)}}),LQ&&z(FE,{onClose:()=>Z4(!1),onInsert:J0}),eG&&z(DL0,{designRel:(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,""),onPick:q70,onClose:()=>C1(null),multiple:!!eG.multiple,hasArtboardAnchor:!!eG.hasArtboardAnchor,onPickMany:B70}),$L&&z(wE,{onPick:N70,onClose:()=>SL(null)}),R8&&z(Aw,{target:R8,cfg:i0,loadLog:q1,onClose:()=>z9(null),onRestore:async(b,S)=>{let d=oG?await hH(b,/^r\d+$/.test(S||"")?Number(S.slice(1)):NaN):await pY([b]);if(d?.ok)z9(null);else window.alert(d?.error||"Could not restore that version. Try again.")},onResolve:async(b)=>{let S=await dG(b);if(S.ok)z9(null);else window.alert(S.error||"Could not finish the merge. Get the latest again, then retry.")}}),z(RL0,{open:qX,onClose:()=>BX(!1)}),z(kL0,{open:S7,onClose:()=>qJ(!1),onStartTour:()=>{qJ(!1),MX(HF)}}),z(dm,{open:j9,activeCanvas:V,onClose:()=>NQ(!1)}),z(sm,{wn:wQ,onStartTour:MX}),z(mm,{center:jJ}),z(uh,{open:d7,onClose:()=>FQ(!1)}),z(xV,{open:LG,onClose:()=>x7(!1)}),z(aw,{open:FY,onClose:()=>nJ(!1),onStartTour:()=>MX($m),onBringBrand:()=>SJ(!0),onImportFigma:()=>B7(!0)}),z(lw,{open:O7,onClose:()=>SJ(!1)}),Q7&&z(dw,{onClose:()=>B7(!1),onImported:()=>S9()}),TY&&!v5&&!fH&&D("div",{className:"mdcc-tour-nudge",role:"status","aria-live":"polite",children:[z("div",{className:"mdcc-tour-nudge__body",children:"New here? Take a 60-second tour of the canvas browser."}),z("button",{type:"button",className:"mdcc-tour-nudge__cta",onClick:()=>{q4(),MX(HF)},children:"Start"}),z("button",{type:"button",className:"mdcc-tour-nudge__skip","aria-label":"Dismiss",onClick:q4,children:"×"})]}),fH&&!v5&&D("div",{className:"mdcc-tour-nudge",role:"status","aria-live":"polite",children:[z("div",{className:"mdcc-tour-nudge__body",children:"New to working with a team? See how saving & sharing works — 60 seconds."}),z("button",{type:"button",className:"mdcc-tour-nudge__cta",onClick:()=>{EQ(),MX(kE)},children:"Start"}),z("button",{type:"button",className:"mdcc-tour-nudge__skip","aria-label":"Dismiss",onClick:EQ,children:"×"})]}),z(Cm,{steps:v5??[],open:!!v5,onClose:()=>kY(null),onComplete:q4,bus:G1,hasSelection:!!w,hasCanvas:B.length>0})]})}a90.createRoot(document.getElementById("root")).render(z(MD0,{}));
|
|
5689
|
+
You can restore it from .design/_trash/.`))return;try{let d=await fetch(`/_api/canvas?file=${encodeURIComponent(b)}`,{method:"DELETE"}),X0=await d.json().catch(()=>({}));if(!d.ok||!X0.ok){g8(`Could not delete: ${X0.error||`error ${d.status}`}`);return}await S9()}catch(d){g8(`Delete failed: ${d instanceof Error?d.message:"network error"}`)}},[S9]),k1=u.useCallback(()=>{if(b7({type:"clear-select"}),O(null),V&&V!==o8){let b=R0.current.get(V);if(b&&b.contentWindow)try{b.contentWindow.postMessage({dgn:"force-clear"},"*")}catch{}}},[V]);u.useEffect(()=>{if(!V||V===o8)return;let b=R0.current.get(V);if(!b||!b.contentWindow)return;let S=e9?[]:b9[V]||[];try{b.contentWindow.postMessage({dgn:"comments-set",comments:S},"*")}catch{}},[V,b9,e9]),u.useEffect(()=>{let b=(F0)=>!!V&&(b9[V]||[]).some((I0)=>I0&&I0.id===F0);function S(F0){let I0=i0?.canvasOrigin||window.location.origin;if(F0.origin!==I0)return;let p=F0.data;if(!p||typeof p!=="object"||!p.dgn)return;if(p.dgn==="canvas-notice"){let D0=V&&V!==o8?R0.current.get(V)?.contentWindow:null,O0=Sm(F0,I0,D0);if(O0)Sg(O0.title,O0.kind);return}if(p.dgn==="tool-cursor"){if(p.tool==="browse"){document.body.style.cursor="";let O0=document.getElementById("dc-app-cursor");if(O0)O0.textContent="";DL(r8);return}let D0=db(p.tool);if(D0){document.body.style.cursor=D0;let O0=document.getElementById("dc-app-cursor");if(!O0)O0=document.createElement("style"),O0.id="dc-app-cursor",document.head.appendChild(O0);O0.textContent=`* { cursor: ${D0} !important; }`}return}if(p.dgn==="select"||p.dgn==="select-set"||p.dgn==="clear-select"||p.dgn==="edit-text"||p.dgn==="apply-edit"||p.dgn==="undo-barrier"){let D0=V&&V!==o8?R0.current.get(V)?.contentWindow:null;if(F0.source!==D0)return}if(p.dgn==="select"&&p.selection)FJ(null),$.current=Date.now(),b7({type:"select",selection:p.selection}),O(p.selection),TG(p.selection);else if(p.dgn==="select-set"){FJ(null),$.current=Date.now();let D0=p.selection;if(D0==null)b7({type:"clear-select"}),O(null);else if(Array.isArray(D0)){let O0=D0[0]??null;if(O0)b7({type:"select",selection:O0});if(O(O0),D0.length===1)TG(O0)}else b7({type:"select",selection:D0}),O(D0),TG(D0)}else if(p.dgn==="clear-select")FJ(null),$.current=Date.now(),b7({type:"clear-select"}),O(null);else if(p.dgn==="edit-text"&&p.id){let D0=F0.source,O0=(g0)=>{try{D0?.postMessage({dgn:"edit-reverted",op:"text",id:p.id,reason:g0},"*")}catch{}};fetch("/_api/edit-text",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:p.file,id:p.id,text:p.text??"",...typeof p.occurrence==="number"?{occurrence:p.occurrence}:{},...typeof p.before==="string"?{before:p.before}:{}})}).then((g0)=>g0.json().catch(()=>({}))).then((g0)=>{if(!g0.ok)O0(g0.error||"this element can't be edited inline")}).catch(()=>O0("network error"))}else if(p.dgn==="undo-barrier"&&typeof p.requestId==="string"){let D0=F0.source;Promise.all([k6.current.catch(()=>{}),WD0()]).then(()=>{try{D0?.postMessage({dgn:"undo-barrier-ok",requestId:p.requestId},"*")}catch{}})}else if(p.dgn==="apply-edit"&&p.id&&(p.op==="css"||p.op==="text"||p.op==="attr")){let D0=Yy(p);if(!D0)return;let O0=F0.source,g0=(L8)=>{if(typeof p.requestId!=="string")return;try{O0?.postMessage({dgn:"apply-edit-result",requestId:p.requestId,...L8},"*")}catch{}},K8=typeof p.value==="string"?p.value:null;k6.current=k6.current.catch(()=>{}).then(()=>fetch(D0.url,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(D0.body)}).then((L8)=>L8.json().catch(()=>({}))).then((L8)=>{if(L8.ok){if(D0.op==="css")_X({id:p.id,prop:p.key,value:K8});g0({ok:!0});return}console.warn("[apply-edit]",D0.op,L8.error||"failed"),g0({ok:!1,error:L8.error||"failed",conflict:L8.conflict===!0})}).catch(()=>g0({ok:!1,error:"network error"})))}else if(p.dgn==="layers-tree"){H0({artboardId:p.artboardId,nodes:Array.isArray(p.tree)?p.tree:[]});let D0=JL0(p.tree);if(o.current={tree:p.tree,sig:D0,artboardId:p.artboardId??null},n.current=!1,e.current)clearTimeout(e.current),e.current=null;v.current?.(p.tree,D0,p.artboardId??null)}else if(p.dgn==="reorder-revert"){let D0=V?R0.current.get(V)?.contentWindow:null,O0=typeof p.seq==="number"&&(p.dir==="undo"||p.dir==="redo");if(F0.source===D0&&O0&&V){if(n.current=!0,e.current)clearTimeout(e.current);e.current=setTimeout(()=>{n.current=!1,e.current=null},700),fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,seq:p.seq,dir:p.dir})}).then((g0)=>g0.json().catch(()=>({}))).then((g0)=>{if(!g0.ok)console.warn("[reorder-revert]",g0.error||"failed")}).catch(()=>{})}}else if(p.dgn==="reorder-request"){let D0=V?R0.current.get(V)?.contentWindow:null,O0=typeof p.id==="string"&&typeof p.refId==="string"&&(p.position==="before"||p.position==="after"||p.position==="inside-start"||p.position==="inside-end");if(F0.source===D0&&O0)g.current?.(p.id,p.refId,p.position,{idIndex:Number.isInteger(p.idIndex)?p.idIndex:void 0,refIndex:Number.isInteger(p.refIndex)?p.refIndex:void 0})}else if(p.dgn==="reposition-request"){let D0=V?R0.current.get(V)?.contentWindow:null,O0=typeof p.id==="string"&&Number.isFinite(p.left)&&Number.isFinite(p.top)&&Number.isFinite(p.beforeLeft)&&Number.isFinite(p.beforeTop);if(F0.source===D0&&O0)l.current?.(p.id,p.left,p.top,p.beforeLeft,p.beforeTop,Number.isInteger(p.idIndex)?p.idIndex:void 0)}else if(p.dgn==="resize-request"){let D0=V?R0.current.get(V)?.contentWindow:null,O0=typeof p.id==="string"&&p.patch&&typeof p.patch==="object";if(F0.source===D0&&O0)x.current?.(p.id,p.patch,p.before,Number.isInteger(p.idIndex)?p.idIndex:void 0)}else if(p.dgn==="delete-request"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof p.id==="string")kT.current?.(p.id,Number.isInteger(p.idIndex)?p.idIndex:void 0)}else if(p.dgn==="duplicate-request"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof p.id==="string")ST.current?.(p.id,Number.isInteger(p.idIndex)?p.idIndex:void 0)}else if(p.dgn==="copy-style"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0)yT.current?.()}else if(p.dgn==="paste-style"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof p.id==="string")jT.current?.(p.id)}else if(p.dgn==="insert-request"){let D0=V?R0.current.get(V)?.contentWindow:null,O0=typeof p.refId==="string",g0=typeof p.artboardId==="string",K8=p.position==="before"||p.position==="after"||p.position==="inside-start"||p.position==="inside-end",L8=O0!==g0&&(p.kind==="div"||p.kind==="text"||p.kind==="image")&&K8&&(!g0||p.position==="inside-start"||p.position==="inside-end");if(F0.source===D0&&L8)TT.current?.(p.refId,p.position,p.kind,{artboardId:g0?p.artboardId:void 0,src:typeof p.src==="string"?p.src:void 0,refIndex:Number.isInteger(p.refIndex)?p.refIndex:void 0})}else if(p.dgn==="insert-image-request"){let D0=V?R0.current.get(V)?.contentWindow:null,O0=typeof p.refId==="string",g0=typeof p.artboardId==="string",K8=!O0&&!g0,L8=(O0!==g0||K8)&&(K8||p.position==="before"||p.position==="after"||p.position==="inside-start"||p.position==="inside-end")&&(!g0||p.position==="inside-start"||p.position==="inside-end");if(F0.source===D0&&L8)Pq.current?.({purpose:"insert-image",canvas:V,refId:p.refId,artboardId:g0?p.artboardId:void 0,position:K8?void 0:p.position,refIndex:Number.isInteger(p.refIndex)?p.refIndex:void 0,multiple:!0,hasArtboardAnchor:!K8})}else if(p.dgn==="replace-media-request"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof p.id==="string")Pq.current?.({purpose:"replace-src",canvas:V,id:p.id,before:typeof p.before==="string"?p.before:null})}else if(p.dgn==="convert-to-absolute-request"){let D0=V?R0.current.get(V)?.contentWindow:null,O0=Array.isArray(p.containers)&&p.containers.length>0,g0=typeof p.containerId==="string"&&Array.isArray(p.children)&&p.children.length>0;if(F0.source===D0&&(O0||g0)){let K8=O0?p.containers.reduce((L8,U6)=>L8+(Array.isArray(U6?.children)?U6.children.length:0),0):p.children.length;I.current?.("/_api/convert-to-absolute",O0?{allowShared:p.allowShared===!0,containers:p.containers,...Array.isArray(p.dissolve)&&p.dissolve.length>0?{dissolve:p.dissolve}:{}}:{containerId:p.containerId,containerSetRelative:p.containerSetRelative===!0,allowShared:p.allowShared===!0,children:p.children},{label:"convert to absolute",onOk:()=>{b8({dgn:"selection-clear"}),b8({dgn:"op-toast",message:`Converted ${K8} element${K8===1?"":"s"} to absolute — press V and drag them freely (⌘Z to undo).`})},onFail:(L8)=>b8({dgn:"op-toast",message:`Convert failed: ${L8?.error||"unknown error"}`})})}}else if(p.dgn==="replace-annotation-media-request"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof p.id==="string")Pq.current?.({purpose:"replace-annotation-media",canvas:V,id:p.id,before:typeof p.before==="string"?p.before:null})}else if(p.dgn==="edit-annotation-photo-request"){let D0=V?R0.current.get(V)?.contentWindow:null,O0=PT.exec(typeof p.asset==="string"?p.asset:"")?.[0]||null;if(F0.source===D0&&typeof p.id==="string"&&O0)FJ({asset:O0,strokeId:p.id}),DX("inspector"),sX("photo")}else if(p.dgn==="open-sticker-picker"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0)vT.current?.({canvas:V})}else if(p.dgn==="insert-artboard-request"){let D0=V?R0.current.get(V)?.contentWindow:null,O0=typeof p.id==="string"&&Number.isFinite(p.width)&&Number.isFinite(p.height);if(F0.source===D0&&O0)RT.current?.({id:p.id,label:typeof p.label==="string"?p.label:p.id,width:p.width,height:p.height})}else if(p.dgn==="resize-artboard-request"){let D0=V?R0.current.get(V)?.contentWindow:null,O0=typeof p.artboardId==="string"&&(Number.isFinite(p.width)||Number.isFinite(p.height));if(F0.source===D0&&O0)CT.current?.(p.artboardId,Number.isFinite(p.width)?p.width:void 0,Number.isFinite(p.height)?p.height:void 0)}else if(p.dgn==="delete-artboard-request"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof p.artboardId==="string")$T.current?.(p.artboardId)}else if(p.dgn==="rename-artboard-request"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof p.artboardId==="string"&&typeof p.label==="string"&&p.label.trim())I.current?.("/_api/set-artboard-label",{artboardId:p.artboardId,label:p.label.slice(0,80)},{label:"rename artboard"})}else if(p.dgn==="set-artboard-kind-request"){let D0=V?R0.current.get(V)?.contentWindow:null,O0=p.kind===null||typeof p.kind==="string";if(F0.source===D0&&typeof p.artboardId==="string"&&O0)IT.current?.(p.artboardId,p.kind)}else if(p.dgn==="duplicate-artboard-request"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0&&typeof p.artboardId==="string"&&Number.isFinite(p.width))bT.current?.(p.artboardId,p.width)}else if(p.dgn==="open-inspector"){if(DX("inspector"),typeof p.tab==="string")sX(p.tab)}else if(p.dgn==="present-enter"){let D0=V?R0.current.get(V)?.contentWindow:null,O0=!!document.querySelector('[role="dialog"][aria-modal="true"]');if(F0.source===D0&&!O0&&!e9)OX(!0),DJ({present:!0})}else if(p.dgn==="comment-compose"&&p.selection)O(p.selection);else if(p.dgn==="comment-submit"&&p.payload&&typeof p.payload.text==="string"){let D0=p.payload,O0=String(D0.text).trim(),g0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===g0&&O0&&V&&V!==o8)b7({type:"comments-add",payload:{file:V,selector:D0.selector,index:D0.index,dom_path:D0.dom_path,tag:D0.tag,classes:D0.classes,bounds:D0.bounds,html_excerpt:D0.html_excerpt,annotationId:D0.annotationId,world:D0.world,text:O0}})}else if(p.dgn==="comment-patch"&&p.id&&p.patch&&typeof p.patch==="object"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0&&b(p.id))b7({type:"comments-patch",id:p.id,patch:p.patch})}else if(p.dgn==="comment-delete"&&p.id){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0&&b(p.id))b7({type:"comments-delete",id:p.id}),M0((O0)=>O0===p.id?null:O0)}else if(p.dgn==="comment-click"&&p.id)M0(p.id);else if(p.dgn==="artboards"&&typeof p.count==="number"){let D0=Math.round(p.count);if(Number.isFinite(D0)&&D0>=0&&D0<=999)kQ(D0)}else if(p.dgn==="active-artboard"){let D0=V&&V!==o8?R0.current.get(V)?.contentWindow:null;if(F0.source!==D0)return;f6(JF(p.id))}else if(p.dgn==="timeline-comps"&&Array.isArray(p.comps)){let D0=V&&V!==o8?R0.current.get(V)?.contentWindow:null;if(F0.source!==D0)return;let O0=p.comps.filter((L8)=>L8&&typeof L8.id==="string").slice(0,32).map((L8)=>({id:String(L8.id).slice(0,120),fps:Math.max(1,Math.min(120,Math.round(Number(L8.fps)||30))),durationInFrames:Math.max(1,Math.min(1e6,Math.round(Number(L8.durationInFrames)||1))),width:Math.max(1,Math.round(Number(L8.width)||0)),height:Math.max(1,Math.round(Number(L8.height)||0)),artboardId:JF(L8.artboardId),artboardLabel:JF(L8.artboardLabel)}));FX(O0);let g0=aX.current;if(g0&&O0.some((L8)=>L8.id===g0)&&OG.current>0)b8({dgn:"timeline-seek",frame:OG.current,id:g0})}else if(p.dgn==="timeline-frame"&&typeof p.frame==="number"){let D0=V&&V!==o8?R0.current.get(V)?.contentWindow:null;if(F0.source!==D0)return;if(p.id&&aX.current&&p.id!==aX.current)return;if(Number.isFinite(p.frame))z6(Math.max(0,Math.round(p.frame)))}else if(p.dgn==="timeline-ended"){let D0=V&&V!==o8?R0.current.get(V)?.contentWindow:null;if(F0.source!==D0)return;if(p.id&&aX.current&&p.id!==aX.current)return;n6(!1)}else if(p.dgn==="toggle-palette")NX((D0)=>!D0);else if(p.dgn==="shell-shortcut"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0){if(p.id==="reload")g5();else if(p.id==="inspector")x6("inspector");else if(p.id==="assistant"&&H9())x6("assistant");else if(p.id==="comments")x6("comments");else if(p.id==="changes")x6("changes");else if(p.id==="timeline")PY();else if(p.id==="export")X6({mode:"export"});else if(p.id==="handoff")X6({mode:"handoff"})}}else if(p.dgn==="open-export"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0)X6({mode:"export",scope:p.detail&&typeof p.detail.scope==="string"?p.detail.scope:void 0})}else if(p.dgn==="open-timeline-request"){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0){if(typeof p.artboardId==="string")f6(p.artboardId.slice(0,120));K9(!0)}}else if((p.dgn==="canvas-rendered"||p.dgn==="canvas-failed")&&p.file){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source===D0)_8((O0)=>O0===p.file?null:O0)}else if(p.dgn==="loaded"&&p.file){if(!k90(p.file))_8((g0)=>g0===p.file?null:g0);E8(p.file),h0((g0)=>g0&&g0.path===p.file?null:g0);let D0=e9?[]:b9[p.file]||[],O0=[...R0.current.entries()].find(([g0])=>g0===p.file)?.[1];if(O0&&O0.contentWindow){try{O0.contentWindow.postMessage({dgn:"comments-set",comments:D0},"*")}catch{}try{O0.contentWindow.postMessage({dgn:"theme",theme:j8},"*")}catch{}try{O0.contentWindow.postMessage({dgn:"view-chrome",minimap:J5,zoom:aJ,present:e9},"*")}catch{}if(t&&D0.some((K8)=>K8.id===t))try{O0.contentWindow.postMessage({dgn:"comment-focus",id:t},"*")}catch{}let g0=c.current;if(g0&&g0.file===p.file){c.current=null;try{O0.contentWindow.postMessage({dgn:"request-layers",artboardId:g0.artboardId??null},"*")}catch{}if(g0.movedId)try{O0.contentWindow.postMessage({dgn:"select-by-id",id:g0.movedId,artboardId:g0.artboardId??null,index:0},"*")}catch{}}else{let K8=P.current,L8=Array.isArray(K8)?K8[0]:K8;if(L8&&L8.id&&L8.file===p.file)j(L8)}}}else if(p.dgn==="export-request"&&p.id&&p.payload){let D0=V?R0.current.get(V)?.contentWindow:null;if(F0.source!==D0)return;X0(F0.source,p.id,p.payload)}else if(p.dgn==="export-history-request"&&p.id)K0(F0.source,p.id)}let d=i0?.canvasOrigin||window.location.origin;async function X0(F0,I0,p){if(p?.options&&V&&V!==o8)p.options.canvasFile=V;let D0=(K8)=>{try{if(F0)F0.postMessage({dgn:"export-result",id:I0,...K8},d)}catch{}},O0=p?.options||{};if(HB({exportLane:i0.exportLane||"local",format:p?.format,scope:p?.scope,artboardId:O0.artboardId}))try{if(p.format==="pptx"){let{filename:K8,blob:L8}=await mO({capture:RQ,name:V?V.replace(/^.*\//,"").replace(/\.[^.]+$/,""):"export"});_L(K8,L8)}else{let K8=pO(O0),L8=await RQ({format:p.format,artboardIds:[O0.artboardId],scale:K8}),U6=await uO(L8,p.format);for(let P7 of U6)_L(P7.name,P7.blob)}D0({ok:!0,browser:!0});return}catch{if(i0.exportLane!=="remote"){D0({ok:!1,error:"Capturing in the browser failed and this workspace has no render service to fall back to — try again, or ask your admin to add maude-render."});return}}if(i0.exportLane==="none"&&p?.format!=="zip"){D0({ok:!1,error:"This format needs the render service, which this workspace doesn’t have configured. PNG/SVG of the active artboard and the PPTX deck export straight from the browser; ZIP works too. For the rest use the desktop app or ask your admin to add maude-render."});return}try{let K8=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(p)});if(!K8.ok){D0({ok:!1,error:await K8.text()||String(K8.status)});return}let{jobId:L8}=await K8.json();D0({ok:!0,jobId:L8})}catch(K8){D0({ok:!1,error:K8&&K8.message?K8.message:String(K8)})}}async function K0(F0,I0){let p=[];try{let D0=await fetch("/_api/export-history");if(D0.ok){let O0=await D0.json();if(Array.isArray(O0.history))p=O0.history}}catch{}try{if(F0)F0.postMessage({dgn:"export-history-result",id:I0,history:p},d)}catch{}}return window.addEventListener("message",S),()=>window.removeEventListener("message",S)},[b9,t,i0,j8,g5,e9,J5,aJ,DJ,V,b8,RQ]);let T1=u.useCallback(()=>{if(!V||V===o8)return;let b=R0.current.get(V);if(b&&b.contentWindow)try{b.contentWindow.postMessage({dgn:"force-clear"},"*")}catch{}},[V]),_X=u.useCallback((b)=>{if(!V||V===o8)return;let S=R0.current.get(V);if(S&&S.contentWindow)try{S.contentWindow.postMessage({dgn:"apply-style",...b},"*")}catch{}},[V]),sJ=u.useCallback((b)=>{if(!V||V===o8||!b)return;let S=R0.current.get(V);if(S&&S.contentWindow)try{S.contentWindow.postMessage({dgn:"record-edit",payload:b},"*")}catch{}},[V]),k6=u.useRef(Promise.resolve()),q=u.useCallback((b,S,d,X0)=>{let K0=Number.isInteger(X0?.idIndex)?X0.idIndex:void 0,F0=Number.isInteger(X0?.refIndex)?X0.refIndex:void 0;if(!b||!S)return;if(b===S&&(K0??0)===(F0??0))return;let I0=P.current,p=Array.isArray(I0)?I0[0]:I0,D0=V;if(!D0)return;let O0=V,g0=s?.artboardId??p?.artboardId??null;if(H0((K8)=>K8?{...K8,nodes:KD0(K8.nodes,b,S,d)}:K8),n.current=!0,e.current)clearTimeout(e.current);e.current=setTimeout(()=>{n.current=!1,e.current=null},700),k6.current=k6.current.catch(()=>{}).then(()=>fetch("/_api/reorder",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:D0,id:b,refId:S,position:d,idIndex:K0,refIndex:F0})}).then((K8)=>K8.json().catch(()=>({}))).then((K8)=>{if(!K8.ok){if(console.warn("[reorder]",K8.error||"failed"),b8({dgn:"reorder-failed"}),b8({dgn:"request-layers",artboardId:g0}),n.current=!1,e.current)clearTimeout(e.current),e.current=null;return}if(c.current={file:O0,movedId:K8.movedId||null,artboardId:g0},typeof K8.seq==="number")b8({dgn:"record-edit",payload:{op:"reorder",canvas:D0,seq:K8.seq,label:"move element"}})}).catch(()=>{}))},[V,s,b8]);u.useEffect(()=>{g.current=q},[q]);let L=u.useCallback((b,S,d,X0,K0,F0)=>{if(!b||!V)return;let I0=V,p=Number.isInteger(F0)?F0:void 0;_X({id:b,prop:"left",value:`${S}px`}),_X({id:b,prop:"top",value:`${d}px`});let D0=null,O0=(g0,K8)=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:I0,id:b,property:g0,value:`${K8}px`,idIndex:p})}).then((L8)=>L8.json().catch(()=>({})));k6.current=k6.current.catch(()=>{}).then(()=>O0("left",S)).then((g0)=>{if(!g0.ok)throw Error(g0.error||"left write failed");return D0=g0,O0("top",d)}).then((g0)=>{if(!g0.ok)throw Error(g0.error||"top write failed");sJ({op:"css",canvas:I0,id:b,key:"left",before:Mq(D0,`${X0}px`),after:`${S}px`}),sJ({op:"css",canvas:I0,id:b,key:"top",before:Mq(g0,`${K0}px`),after:`${d}px`})}).catch((g0)=>{console.warn("[reposition]",g0?.message||g0),b8({dgn:"reposition-failed"})})},[V,b8,sJ,_X]);u.useEffect(()=>{l.current=L},[L]);let _=u.useCallback((b,S,d,X0)=>{if(!b||!V||!S||typeof S!=="object")return;let K0=V,F0=d&&typeof d==="object"?d:{},I0=Number.isInteger(X0)?X0:void 0,p=["width","height","left","top","transform","padding-top","padding-right","padding-bottom","padding-left","gap","grid-template-columns","grid-template-rows"].filter((p9)=>typeof S[p9]==="string"&&S[p9]);if(!p.length)return;let D0=P.current,O0=Array.isArray(D0)?D0.length===1?D0[0]:null:D0,g0=O0&&O0.id===b?O0.artboardId??null:null,K8=O0&&O0.id===b?O0.index??0:0;for(let p9 of p)_X({id:b,artboardId:g0,index:K8,prop:p9,value:S[p9]});let L8=(p9,AJ)=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:K0,id:b,property:p9,value:AJ,idIndex:I0})}).then((XZ)=>XZ.json().catch(()=>({}))),U6={},P7=k6.current.catch(()=>{});for(let p9 of p)P7=P7.then((AJ)=>{if(AJ&&AJ.ok===!1)throw Error(AJ.error||`${p9} write failed`);return L8(p9,S[p9]).then((XZ)=>{return U6[p9]=XZ,XZ})});k6.current=P7.then((p9)=>{if(p9&&p9.ok===!1)throw Error(p9.error||"resize write failed");for(let AJ of p)sJ({op:"css",canvas:K0,id:b,key:AJ,before:Mq(U6[AJ],F0[AJ]??null),after:S[AJ]});j({id:b,file:K0,artboardId:g0,index:K8})}).catch((p9)=>{console.warn("[resize]",p9?.message||p9),b8({dgn:"resize-failed"})})},[V,b8,sJ,_X,j]);u.useEffect(()=>{x.current=_},[_]);let I=u.useRef(null),k=u.useCallback((b,S,{label:d,onOk:X0,onFail:K0}={})=>{if(!V)return;let F0=V,I0=K0??((p)=>b8({dgn:"op-toast",message:`Couldn't ${d||"apply the edit"}${p?.error?` — ${p.error}`:""}.`}));k6.current=k6.current.catch(()=>{}).then(()=>fetch(b,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...S,canvas:F0})}).then((p)=>p.json().catch(()=>({}))).then((p)=>{if(!p.ok){console.warn(`[${b}]`,p.error||"failed"),I0?.(p);return}if(typeof p.seq==="number")b8({dgn:"record-edit",payload:{op:"reorder",canvas:F0,seq:p.seq,label:d||"edit"}});X0?.(p,F0)}).catch((p)=>I0?.({error:p?.message})))},[V,b8]);u.useEffect(()=>{I.current=k},[k]);let y=u.useCallback((b,S)=>{k("/_api/delete-element",{id:b,idIndex:Number.isInteger(S)?S:void 0},{label:"delete element",onOk:()=>b8({dgn:"selection-clear"})})},[k,b8]),h=u.useCallback((b,S,d,X0={})=>{let K0=o.current?.sig??null;k("/_api/insert-element",{refId:b,artboardId:typeof X0.artboardId==="string"?X0.artboardId:void 0,position:S,kind:d,src:typeof X0.src==="string"?X0.src:void 0,refIndex:Number.isInteger(X0.refIndex)?X0.refIndex:void 0},{label:`insert ${d}`,onOk:(F0,I0)=>{if(!F0.newId)return;c.current={file:I0,movedId:F0.newId,artboardId:null,staleSig:K0};let p=o.current;if(p)v.current?.(p.tree,p.sig,p.artboardId)}})},[k]),J0=u.useCallback((b)=>{if(typeof b!=="string"||!b)return!1;if(!V)return!1;let S=P.current?.artboardId??Y7??null;if(!S)return!1;return h(void 0,"inside-end","image",{artboardId:S,src:b}),!0},[V,Y7,h]),G0=u.useCallback((b,S)=>{k("/_api/detach-component",{id:b,idIndex:Number.isInteger(S)?S:void 0},{label:"detach instance",onOk:(d)=>{b8({dgn:"selection-clear"}),b8({dgn:"op-toast",message:`Detached — this instance is now ${d.detachedName||"its own component"}; edits stay local (⌘Z to undo).`})},onFail:(d)=>b8({dgn:"op-toast",message:`Detach failed: ${d?.error||"unknown error"}`})})},[k,b8]),N0=u.useCallback((b,S)=>{let d=o.current?.sig??null;k("/_api/duplicate-element",{id:b,idIndex:Number.isInteger(S)?S:void 0},{label:"duplicate element",onOk:(X0,K0)=>{if(!X0.newId)return;c.current={file:K0,movedId:X0.newId,artboardId:null,staleSig:d};let F0=o.current;if(F0)v.current?.(F0.tree,F0.sig,F0.artboardId)}})},[k]),$0=u.useRef(null),c0=u.useMemo(()=>new Set(["position","top","right","bottom","left","inset","width","height","min-width","max-width","min-height","max-height","margin","margin-top","margin-right","margin-bottom","margin-left"]),[]),Z8=u.useCallback(()=>{let b=P.current,S=Array.isArray(b)?b.length===1?b[0]:null:b;if(!S)return;let d={};for(let[X0,K0]of Object.entries(S.authored||{}))if(!c0.has(X0))d[X0]=K0;for(let[X0,K0]of Object.entries(S.customStyles||{}))if(!c0.has(X0))d[X0]=K0;$0.current=Object.keys(d).length?d:null},[c0]),W9=u.useCallback((b)=>{let S=V,d=$0.current;if(!S||!b||!d)return;let X0=Object.entries(d),K0=k6.current.catch(()=>{});for(let[F0,I0]of X0)_X({id:b,prop:F0,value:I0}),K0=K0.then(()=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:S,id:b,property:F0,value:I0})}).then((p)=>p.json().catch(()=>({}))).then((p)=>{if(p.ok)sJ({op:"css",canvas:S,id:b,key:F0,before:Mq(p,null),after:I0})}).catch(()=>{}));k6.current=K0},[V,_X,sJ]),G7=u.useCallback(({id:b,label:S,width:d,height:X0})=>{k("/_api/insert-artboard",{id:b,label:S,width:d,height:X0},{label:"insert artboard"})},[k]),xJ=u.useCallback((b,S,d)=>{k("/_api/resize-artboard",{artboardId:b,width:S,height:d},{label:"resize artboard",onFail:()=>b8({dgn:"resize-artboard-failed"}),onOk:()=>m(b,V)})},[k,b8,m,V]),wq=u.useCallback((b)=>{k("/_api/delete-artboard",{artboardId:b},{label:"delete artboard"})},[k]),TL=u.useCallback((b,S)=>{k("/_api/duplicate-artboard",{artboardId:b,width:S},{label:"duplicate artboard at width"})},[k]),z70=u.useCallback((b,S,d)=>{k("/_api/set-artboard-hug",{artboardId:b,fixed:S,freezeHeight:d},{label:S?"pin artboard height":"hug artboard height",onOk:()=>m(b,V)})},[k,m,V]),K70=u.useCallback((b,S)=>{k("/_api/set-artboard-style",{artboardId:b,...S},{label:"artboard style",onOk:()=>m(b,V)})},[k,m,V]),RL=u.useRef(null),Eq=u.useCallback((b,S)=>{k("/_api/set-artboard-kind",{artboardId:b,kind:S},{label:"artboard kind",onOk:()=>m(b,V)});let d=RL.current;if(S==="print"&&d&&d.artboardId===b)RL.current=null,k("/_api/resize-artboard",{artboardId:b,width:d.widthPx,height:d.heightPx},{label:"artboard size"}),k("/_api/set-artboard-print",{artboardId:b,print:d.defaults},{label:"artboard print"})},[k,m,V]),IT=u.useRef(null);u.useEffect(()=>{IT.current=Eq},[Eq]);let R1=u.useCallback((b,S,d)=>{if(S==="print"||S==null||S==="digital"){if(d)RL.current={artboardId:b,...d};b8({dgn:"freeze-and-set-kind",artboardId:b,kind:S==="digital"?null:S,ask:!0});return}Eq(b,S)},[Eq,b8]),CL=u.useCallback((b,S)=>{k("/_api/set-artboard-print",{artboardId:b,print:S},{label:"artboard print",onOk:()=>m(b,V)})},[k,m,V]),U70=u.useCallback((b)=>{let S=`s${Math.random().toString(36).slice(2,8)}`;if(b.startsWith("print-")){let X0=b.slice(6),K0;try{K0=ZB({paper:X0})}catch{return}let F0=GB.find((I0)=>I0.id===X0);G7({id:S,label:F0?F0.label:X0.toUpperCase(),width:K0.widthPx,height:K0.heightPx}),R1(S,"print"),CL(S,{paper:X0});return}let d=$5[b];if(!d)return;G7({id:S,label:d.label,width:d.width,height:d.height})},[G7,R1,CL]),kT=u.useRef(null),TT=u.useRef(null),RT=u.useRef(null),CT=u.useRef(null),$T=u.useRef(null),V70=u.useRef(null),ST=u.useRef(null),bT=u.useRef(null),yT=u.useRef(null),jT=u.useRef(null);u.useEffect(()=>{kT.current=y,TT.current=h,RT.current=G7,CT.current=xJ,$T.current=wq,V70.current=R1,ST.current=N0,bT.current=TL,yT.current=Z8,jT.current=W9},[y,h,G7,xJ,wq,R1,N0,TL,Z8,W9]),u.useEffect(()=>{let b=(S)=>{if(S.key!=="Backspace"&&S.key!=="Delete")return;if(S.metaKey||S.ctrlKey||S.altKey)return;let d=S.target;if(d&&(d.tagName==="INPUT"||d.tagName==="TEXTAREA"||d.tagName==="SELECT"||d.isContentEditable))return;if(S.preventDefault(),!V||V===o8)return;let K0=Array.isArray(w)?w.length===1?w[0]:null:w;if(K0?.artboardId&&!K0.id)wq(K0.artboardId)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[V,w,wq]);let[eG,C1]=u.useState(null),Pq=u.useRef(null);u.useEffect(()=>{Pq.current=(b)=>C1(b)},[]);let[$L,SL]=u.useState(null),vT=u.useRef(null);u.useEffect(()=>{vT.current=(b)=>SL(b)},[]);let q70=u.useCallback((b)=>{let S=eG;if(C1(null),!S||!b)return;if(S.canvas&&S.canvas!==V){console.warn("[asset-picker] active canvas changed since request — aborting");return}if(S.purpose==="insert-image"){h(S.refId,S.position||"after","image",{artboardId:S.artboardId,src:b,refIndex:S.refIndex});return}if(S.purpose==="replace-src"){let d=V;if(!d||!S.id)return;k6.current=k6.current.catch(()=>{}).then(()=>fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:d,id:S.id,attr:"src",value:b})}).then((X0)=>X0.json().catch(()=>({}))).then((X0)=>{if(X0.ok)sJ({op:"attr",canvas:d,id:S.id,key:"src",before:Mq(X0,S.before??null),after:b});else console.warn("[replace-src]",X0.error||"failed")}).catch(()=>{}));return}if(S.purpose==="replace-annotation-media")b8({dgn:"replace-annotation-media",id:S.id,path:b})},[eG,h,V,sJ,b8]),B70=u.useCallback((b,S)=>{let d=eG;if(C1(null),!d||!Array.isArray(b)||!b.length)return;if(d.canvas&&d.canvas!==V){console.warn("[asset-picker] active canvas changed since request — aborting");return}if(S==="artboard"){let X0=P.current?.artboardId??Y7??null;if(!X0)return;for(let K0 of b)h(void 0,"inside-end","image",{artboardId:X0,src:K0});return}b8({dgn:"insert-annotation-media",paths:b})},[eG,V,h,Y7,b8]),N70=u.useCallback(async(b)=>{let S=$L;if(SL(null),!S||!b?.url)return;if(S.canvas&&S.canvas!==V){console.warn("[sticker-picker] active canvas changed since request — aborting");return}try{let d=await fetch(b.url).then((F0)=>F0.ok?F0.blob():Promise.reject(Error(`HTTP ${F0.status}`))),X0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":d.type||"image/png"},body:d}),K0=await X0.json().catch(()=>({}));if(!X0.ok||!K0.path){console.warn("[sticker-picker]",K0.error||`upload failed (HTTP ${X0.status})`);return}b8({dgn:"insert-sticker",path:K0.path})}catch{console.warn("[sticker-picker] could not load or upload that sticker")}},[$L,V,b8]),F70=u.useCallback((b)=>{if(!b?.id)return;C1({purpose:"replace-src",canvas:V,id:b.id,before:b.attrs?.src??null})},[V]),L70=u.useCallback((b)=>{b7({type:"comments-patch",id:b,patch:{status:"resolved"}})},[]),D70=u.useCallback((b)=>{b7({type:"comments-patch",id:b,patch:{status:"open"}})},[]),M70=u.useCallback((b)=>{b7({type:"comments-delete",id:b}),M0((S)=>S===b?null:S)},[]),O70=u.useCallback((b,S)=>{if(b&&b!==V)N((X0)=>X0.find((K0)=>K0.path===b)?X0:[...X0,{path:b}]),F(b);if(S==null){M0(null);return}M0(S);let d=()=>{let X0=R0.current.get(b);if(X0&&X0.contentWindow)try{X0.contentWindow.postMessage({dgn:"comment-focus",id:S},"*")}catch{}};d(),setTimeout(d,200)},[V]);u.useEffect(()=>{function b(S){let d=S.metaKey||S.ctrlKey,X0=["INPUT","TEXTAREA"].includes(document.activeElement?.tagName)||document.activeElement?.isContentEditable,K0=document.activeElement?.tagName==="IFRAME";if(e9&&S.key==="Escape"){S.preventDefault(),D4();return}if(d&&(S.key==="k"||S.key==="K")){S.preventDefault(),NX((F0)=>!F0);return}if(d&&!S.altKey&&(S.key==="z"||S.key==="Z"||S.key==="y"||S.key==="Y")){if(!X0&&!K0&&V&&V!==o8){if((S.key==="z"||S.key==="Z")&&Q6.current.open&&Q6.current.comps?.length)return;let F0=S.key==="y"||S.key==="Y"||S.shiftKey;if(z4==="photo"&&F4(F0)){S.preventDefault();return}S.preventDefault(),b8({dgn:F0?"redo":"undo"});return}}if(d&&S.shiftKey&&(S.key==="r"||S.key==="R")){S.preventDefault(),sG();return}if(d&&(S.key==="r"||S.key==="R")){S.preventDefault(),g5();return}if(d&&S.shiftKey&&(S.key==="m"||S.key==="M")){S.preventDefault(),x6("comments");return}if(d&&S.shiftKey&&(S.key==="g"||S.key==="G")){S.preventDefault(),x6("changes");return}if(d&&S.shiftKey&&(S.key==="i"||S.key==="I")){S.preventDefault(),x6("inspector");return}if(d&&S.shiftKey&&(S.key==="a"||S.key==="A")&&H9()){if(S.preventDefault(),!r8)x6("assistant");return}if(d&&S.shiftKey&&(S.key==="e"||S.key==="E")){S.preventDefault(),X6({mode:"export"});return}if(d&&S.shiftKey&&(S.key==="h"||S.key==="H")){S.preventDefault(),X6({mode:"handoff"});return}if(d&&!S.shiftKey&&!S.altKey&&S.key===","){if(S.preventDefault(),!r8)bJ(!0);return}if(d&&S.shiftKey&&(S.key==="t"||S.key==="T")){S.preventDefault(),PY();return}if(d&&!S.shiftKey&&!S.altKey&&(S.key==="c"||S.key==="C")){if(w&&w.selector&&V&&V!==o8&&!X0&&console&&console.warn)console.warn("Cmd+C comment-drop deprecated — press C inside the canvas to enter Comment tool, then click the element.")}if(X0)return;if(S.key==="/"){S.preventDefault();let F0=document.querySelector(".st-search input");if(F0)F0.focus();return}if(d&&(S.key==="f"||S.key==="F")){if(S.preventDefault(),!CJ)yJ("tree");setTimeout(()=>{let F0=document.querySelector(".st-search input");if(F0)F0.focus()},0);return}if(K0){if(S.key!=="Escape")return}if(S.key==="t"||S.key==="T"){if(S.shiftKey||d)return;S.preventDefault(),j5("tree");return}if(S.key==="h"||S.key==="H"){if(S.shiftKey||d)return;S.preventDefault(),$J((F0)=>!F0);return}if((S.key==="s"||S.key==="S")&&!d&&!S.shiftKey){if(S.preventDefault(),V===o8)cY(o8);else SQ();return}if((S.key==="n"||S.key==="N")&&!d&&!S.shiftKey){S.preventDefault(),yJ("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60);return}if(S.key==="?"){S.preventDefault(),BX((F0)=>!F0);return}if(S.key==="F1"){S.preventDefault(),qJ(!0);return}if(S.key==="Escape"){if(t){M0(null);return}}}return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[g5,sG,w,V,t,CJ,SQ,cY,T1,e9,D4,PY,z4,F4,r8]);let A70=u.useCallback((b,S)=>{if(S)R0.current.set(b,S)},[]),_70=e90(b9).open,w70=u.useCallback((b)=>{let S=b.target;if(S&&(S.tagName==="INPUT"||S.tagName==="TEXTAREA"||S.isContentEditable))return;b.preventDefault()},[]),E70=u.useMemo(()=>[{id:"new",group:"Canvas",label:"New canvas…",icon:"plus",kbd:"N",run:()=>{yJ("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60)}},{id:"new-video",group:"Canvas",label:"New video…",icon:"plus",run:()=>dH()},{id:"export",group:"Canvas",label:"Export…",icon:"download",kbd:"⇧⌘E",run:()=>X6({mode:"export"})},{id:"share-link",group:"Canvas",label:"Copy share link",icon:"link",run:()=>{let b=mH(dY),S=b.web??b.app??b.local;if(S)vV(S)}},{id:"handoff",group:"Canvas",label:"Handoff to production",icon:"external",kbd:"⇧⌘H",run:()=>X6({mode:"handoff"})},{id:"generate",group:"Canvas",label:"Generate with AI…",icon:"sparkle",run:()=>Z4(!0)},{id:"settings",group:"Canvas",label:"Settings…",icon:"sliders",kbd:"⌘,",run:()=>bJ(!0)},{id:"system",group:"View",label:"Open design system view",icon:"sliders",kbd:"S",run:()=>SQ()},{id:"comments",group:"View",label:"Toggle comments panel",icon:"resolve",kbd:"⌘⇧M",run:()=>x6("comments")},{id:"inspector",group:"View",label:"Open inspector",icon:"sliders",kbd:"⌘⇧I",run:()=>DX("inspector")},{id:"reload",group:"View",label:"Reload active canvas",icon:"reload",kbd:"⌘R",run:()=>g5()},{id:"draw",group:"Tools",label:"Draw a mark with the SVG agent",icon:"pen",run:()=>{try{navigator.clipboard?.writeText("/design:draw ")}catch{}}},{id:"theme",group:"Tools",label:"Toggle light / dark theme",icon:"sun",run:()=>A4()},{id:"whatsnew",group:"Help",label:"What's new in maude",icon:"sparkle",run:()=>wQ.openPanel()},{id:"shortcuts",group:"Help",label:"Keyboard shortcuts",icon:"help",kbd:"?",run:()=>BX(!0)},{id:"help",group:"Help",label:"Help · commands & flows",icon:"help",kbd:"F1",run:()=>qJ(!0)},{id:"report-bug",group:"Help",label:"Report a bug…",icon:"help",run:()=>NQ(!0)}],[SQ,A4,g5,wQ,dH,dY,nG,n8,w8,i0.designRel]),P70=(b)=>{if(r8&&b==="assistant")return!1;if(b==="sync")return!!o0;return b==="assistant"?H9():b==="layers"?T0==="separate":!0},fT=(b)=>wT.filter((S)=>P70(S.id)&&(L0[S.id]||aK[S.id])===b).map((S)=>S.id),xT={tree:CJ,layers:r,inspector:oX,comments:_0,changes:k8,sync:N9,assistant:LX},hT=i0.cloud?{changes:"History"}:null,gT=fT("left"),mT=fT("right"),P4=gT.find((b)=>xT[b])||null,iY=mT.find((b)=>xT[b])||null,uT=H9()&&!r8&&(L0.assistant||"right")==="left",pT=H9()&&!r8&&(L0.assistant||"right")==="right",JZ=(b)=>(L0[b]||aK[b])==="left"?D8==="sb":D8==="rp",$1=V&&V!==o8&&/\.(tsx|html)$/i.test(V)?V:null,lT=$1?ML(b9[$1]):0,dT=(b)=>{if(b==="tree")return z(PL0,{cloud:i0.cloud,readOnly:r8,groups:VJ.ready?J:YL0,activePath:V,previewPath:M,activeDsName:V===o8?t0?.ds?.name??null:null,onOpen:K6,onPreview:E,onOpenLinkedFile:E4,filesReady:Q,treeLoadFailures:W,onShare:uH,onOpenSystem:SQ,wsConnected:q0,search:N8,setSearch:B0,commentsByFile:b9,showHidden:w6,sectionsExpanded:RH,onToggleSection:mG,treeExpansion:uG,onNewBoard:L1,onDeleteBoard:M1,onMoveCanvas:O1,onNewFolder:A1,onDeleteFolder:_1,onRenameFolder:w1,onRenameCanvas:E1,onDuplicateCanvas:P1,onDeleteFile:I1,onRefresh:sG,refreshing:F1,collapsed:!1,onCollapse:()=>j5("tree"),resizing:JZ("tree"),dirtyByPath:B1,project:K,gitBranch:A0?.branch,remoteSync:q8,onGetLatest:lY,canvasKinds:i0?.canvasKinds,syncStatus:o0,onLinkedHub:C8,onLocalProject:w0,savingIsManaged:E0});if(b==="changes")return z(_w,{status:A0&&q8?{...A0,...q8}:A0,project:K,readOnly:!H9()||r8,historyOnly:Y9,cloudManaged:c8,resizing:JZ("changes"),onClose:()=>x8(!1),onCommit:pG,onDiscard:pY,onPublish:lG,onGetLatest:lY,loadLog:async(S)=>{let d=await iG(S);if(K1(d!=="legacy"),d!=="legacy")return d;return(c8?H1:w4)(S)},historySource:z1?"project":c8?"cloud":"local",historyRefresh:`${o0?.appliedRevision??0}:${U1}`,onRestoreVersion:(S)=>hH(V,S).then((d)=>!!d.ok),onUndoAction:Y9?void 0:async(S)=>{let d=await fetch("/_api/project/undo",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionId:S})}).catch(()=>null);return!!(d?await d.json().catch(()=>null):null)?.ok},cloudHistory:cG,onOpenCanvas:(S)=>K6(S),onOpenDiff:(S)=>z9({file:S,beforeSha:"HEAD",conflict:!1}),activeCanvas:$1,onPreviewVersion:(S)=>z9({file:V,beforeSha:S,conflict:!1}),designRel:(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,"")});if(b==="sync")return z(hw,{status:o0,project:i0?.cloud?.projectName||K,cloud:i0?.cloud??null,groupPaths:(J||[]).map((S)=>S.path).filter(Boolean),resizing:JZ("sync"),onClose:()=>m0(!1)});if(b==="inspector"||b==="layers")return z(DD0,{testId:b==="layers"?"layers-panel":"inspector-panel",layersOnly:b==="layers",hideLayersTab:T0==="separate",cpMode:G9,onSetCpMode:y9,selected:w,cfg:i0,tab:b==="layers"?"layers":z4,onTabChange:sX,onClose:()=>b==="layers"?W0(!1):DQ(!1),onOptimistic:_X,onRecordEdit:sJ,onReplaceMedia:F70,onResizeArtboard:xJ,onSetArtboardHug:z70,onSetArtboardStyle:K70,onSetArtboardKind:R1,onSetArtboardPrint:CL,onDuplicateArtboard:TL,editScope:T,onUndoRedo:(S)=>b8({dgn:S}),photoSel:EG,photoRev:PG,onPhotoEdit:N4,onPhotoRemoveBackground:jG,onPhotoRecordEdit:yG,onPhotoUndoRedo:(S)=>F4(S==="redo"),layersTree:s,componentMap:a,lockedKeys:M4,onToggleLock:gG,onDetachInstance:G0,canvasFile:V,onSelectLayer:(S)=>b8({dgn:"select-by-id",id:S.id,artboardId:s?.artboardId,index:S.index}),onHoverLayer:(S)=>b8({dgn:"highlight",id:S?S.id:null,artboardId:s?.artboardId,index:S?S.index:0}),onReorderLayer:q,layersBusyRef:n,resizing:JZ(b)});if(b==="comments")return z(nL0,{commentsByFile:b9,filter:Q8,setFilter:a8,activePath:V,focusedId:t,onJump:O70,onResolve:r8?void 0:L70,onReopen:r8?void 0:D70,onDelete:r8?void 0:M70,resizing:JZ("comments")});return null};return D("div",{className:"maude"+(e9?" is-present":""),"data-theme":j8,onContextMenu:w70,children:[LJ&&z(pw,{}),z(aL0,{cloud:i0.cloud}),z(sL0,{update:V4,onDismiss:()=>IY(null)}),z(tL0,{status:o0}),!LJ&&z(Ew,{status:o0,cloud:i0.cloud}),z(bg,{paused:!!TY||!!v5,hiddenGroups:jJ.panelOpen?["exports"]:[]}),z(am,{wn:wQ}),z(gm,{center:jJ}),C0&&D("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:"Repo state changed — reload to sync?"}),z("button",{type:"button",className:"btn btn--primary btn--sm",onClick:()=>{try{window.location.reload()}catch{}},children:"Reload"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:()=>a0(null),children:"Dismiss"})]}),D("div",{className:"st-shell",children:[z(fL0,{sharePath:dY,onShare:()=>uH(),readOnly:r8,cloud:i0.cloud,activePath:V,project:K,tabsCount:B.length,openMenu:t9,setOpenMenu:q7,commentsPanelOpen:_0,onToggleComments:()=>x6("comments"),changesOpen:k8,changesCount:V8,onToggleChanges:()=>x6("changes"),onOpenSystem:SQ,sidebarOpen:CJ,onToggleSidebar:()=>j5("tree"),showHidden:w6,onToggleShowHidden:()=>$J((b)=>!b),onOpenHelp:()=>qJ(!0),onOpenShortcuts:()=>BX(!0),onReportBug:()=>NQ(!0),onStartTour:()=>MX(HF),onStartCollabTour:()=>MX(kE),annotationsVisible:PQ,onToggleAnnotations:fY,minimapVisible:J5,onToggleMinimap:xY,zoomCtlVisible:aJ,onToggleZoomCtl:hY,presentMode:e9,onTogglePresent:xG,printGuidesVisible:B4,onTogglePrintGuides:hG,postToActiveCanvas:b8,onOpenReadiness:()=>FQ(!0),onOpenQuickSetup:()=>nJ(!0),onWatchIntro:()=>x7(!0),onOpenWhatsNew:wQ.openPanel,whatsNewCount:wQ.unseen.length,exportCenter:jJ,artboardCount:$G,inspectorOpen:oX,inspectorTab:z4,onToggleInspector:()=>x6("inspector"),autoOpenInspector:tX,onToggleAutoOpenInspector:()=>IG((b)=>!b),onInsertArtboard:U70,timelineOpen:B8,onToggleTimeline:PY,hasComps:J9.length>0,assistantOpen:LX,onToggleAssistant:()=>x6("assistant"),assistantBusy:Q1,assistantUnseen:Y1,onOpenLayers:()=>{if(T0==="separate")j5("layers");else if(oX&&z4==="layers")DQ(!1);else sX("layers"),yJ("inspector")},onNewCanvas:()=>{yJ("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60)},onAssembleVideo:D1,onOpenExport:(b)=>X6({mode:b}),onOpenSettings:()=>bJ(!0),onOpenGenerate:()=>Z4(!0),onReload:g5,onCloseCanvas:()=>V&&cY(V),presence:D(Q0,{children:[z(C90,{initials:UL0(f5||"you"),hue:"var(--accent)",title:f5?`${f5} (you)`:"You"}),bG&&z(C90,{initials:"C",hue:"var(--presence-agent)",title:"Claude · editing",pulse:!0})]})}),D("div",{className:"st-body"+(D8?" is-resizing":""),ref:L9,children:[z(IL0,{shown:!P4,onExpand:()=>yJ("tree"),onSearch:()=>{yJ("tree"),setTimeout(()=>document.querySelector(".st-search input")?.focus(),60)}}),(P4||uT)&&D(I90,{side:"left",width:U0.w,open:!!P4,ids:gT,activeId:P4,onPick:j5,labels:hT,children:[uT&&z(vN,{hidden:P4!=="assistant",activeCanvas:$1,selected:w,openComments:lT,designRel:(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,""),resizing:JZ("assistant"),onClose:()=>_G(!1),onBusyChange:jH,onFinished:_Y,onPermissionRequest:EY,onElicitationRequest:EY}),P4&&P4!=="assistant"&&dT(P4)]}),P4&&z(S90,{label:"Resize left panel",size:U0,active:D8==="sb",onPointerDown:(b)=>{b.preventDefault(),b.currentTarget.setPointerCapture?.(b.pointerId),e8("sb")}}),z("div",{className:"main",children:z(xL0,{tabs:B,activePath:V,registerIframe:A70,systemData:t0,onOpenFromSystem:K6,onSelectDs:Y5,project:K,cfg:i0,loadingPath:p8,onIframeLoad:l7,canvasError:b0,canvasReloadNonce:O8,onRetryCanvasLoad:N1,loadedPath:e0,showQuickSetup:H9()&&!r8&&!!E6&&!E6.ready,onStartQuickSetup:()=>nJ(!0),previewPath:M})}),iY&&z(S90,{label:"Resize right panel",dir:"rtl",size:n0,active:D8==="rp",onPointerDown:(b)=>{b.preventDefault(),b.currentTarget.setPointerCapture?.(b.pointerId),e8("rp")}}),(iY||pT)&&D(I90,{side:"right",width:n0.w,open:!!iY,ids:mT,activeId:iY,onPick:j5,labels:hT,children:[pT&&z(vN,{hidden:iY!=="assistant",activeCanvas:$1,selected:w,openComments:lT,designRel:(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,""),resizing:JZ("assistant"),onClose:()=>_G(!1),onBusyChange:jH,onFinished:_Y,onPermissionRequest:EY,onElicitationRequest:EY}),iY&&iY!=="assistant"&&dT(iY)]})]}),B8&&z(BE,{comps:J9,compId:P6,sequences:r6,audio:MG,transitions:y5,total:OQ,frame:b5,playing:rJ,loop:MY,onSeek:(b)=>{z6(b),n6(!1),b8({dgn:"timeline-seek",frame:b,id:P6})},onPlay:()=>{n6(!0),b8({dgn:"timeline-mute",muted:v6,id:P6}),b8({dgn:"timeline-loop",loop:MY,id:P6}),b8({dgn:"timeline-play",id:P6})},onPause:()=>{n6(!1),b8({dgn:"timeline-pause",id:P6})},onToggleLoop:()=>DG((b)=>{let S=!b;return b8({dgn:"timeline-loop",loop:S,id:P6}),S}),muted:v6,onToggleMute:()=>{k7((b)=>{let S=!b;return b8({dgn:"timeline-mute",muted:S,id:P6}),S})},volume:W7,onVolume:(b)=>{if(nX(b),b>0&&v6)k7(!1),b8({dgn:"timeline-mute",muted:!1,id:P6});b8({dgn:"timeline-volume",volume:b,id:P6})},onRetime:(b,S)=>{if(!V||V===o8)return;let d=c7||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${d?`&artboardId=${encodeURIComponent(d)}`:""}`;fetch(X0).then((K0)=>K0.json().catch(()=>({}))).then((K0)=>{let F0=I6(K0,b),I0=b&&typeof b==="object"?b.index:b,p=F0?.stableId?{canvas:V,artboardId:d,stableId:F0.stableId,contentHash:F0.contentHash,...S}:{canvas:V,index:I0,...S};return fetch("/_api/retime-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(p)})}).then((K0)=>K0.json()).then((K0)=>{if(!K0?.ok)console.warn("[retime]",K0?.error||"failed"),NJ("Retime refused",K0?.error);else if(g8(S.from!=null?"Clip moved.":"Clip trimmed.",!0),K0?.seq!=null)Y6(V,K0.seq,S.from!=null?"move clip":"trim clip")}).catch(()=>{})},onRemove:$Y,onReplace:(b)=>{if(!V||V===o8)return;tG({accept:"video/*,image/*",resolveTarget:(S)=>{let d=I6(S,b);if(d?.mediaArrayRef)return{arrayRef:d.mediaArrayRef};if(d?.mediaCdId)return{cdId:d.mediaCdId};return null}})},onReplaceAudio:(b)=>{if(!V||V===o8)return;tG({accept:"audio/*",resolveTarget:(S)=>{let d=S?.ok&&Array.isArray(S.media)?S.media.filter((X0)=>X0.tag==="Audio"):[];return d[b]?.cdId?{cdId:d[b].cdId}:null}})},onReplaceLayer:(b,S)=>{if(!V||V===o8)return;let d=b&&typeof b==="object"?b.index:b,X0=r6[d]?.layers?.[S]?.kind==="audio"?"audio/*":r6[d]?.layers?.[S]?.kind==="image"?"image/*":"video/*";tG({accept:X0,resolveTarget:(K0)=>{let F0=I6(K0,b)?.layers?.[S];if(F0?.mediaArrayRef)return{arrayRef:F0.mediaArrayRef};if(F0?.mediaCdId)return{cdId:F0.mediaCdId};return null}})},onReorder:(b,S)=>{if(!V||V===o8)return;let d=c7||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${d?`&artboardId=${encodeURIComponent(d)}`:""}`;fetch(X0).then((K0)=>K0.json().catch(()=>({}))).then((K0)=>{let F0=K0?.ok&&Array.isArray(K0.clips)?K0.clips.filter((K8)=>K8.kind==="sequence"):[],I0=I6(K0,b),p=I0?F0.indexOf(I0):-1,D0=S==="forward"?p+1:p-1,O0=p>=0?F0[D0]||null:null,g0=S==="forward"?"after":"before";if(!I0?.stableId||!O0?.stableId)return null;return fetch("/_api/reorder-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:d,stableId:I0.stableId,contentHash:I0.contentHash,refStableId:O0.stableId,refContentHash:O0.contentHash,position:g0})})}).then((K0)=>K0?K0.json():null).then((K0)=>{if(K0&&!K0.ok)console.warn("[reorder-clip]",K0.error||"failed"),NJ("Reorder refused",K0.error);else if(K0?.seq!=null)Y6(V,K0.seq,"reorder clip")}).catch(()=>{})},onToggleHide:(b)=>{if(!V||V===o8)return;let S=c7||void 0,d=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${S?`&artboardId=${encodeURIComponent(S)}`:""}`;fetch(d).then((X0)=>X0.json().catch(()=>({}))).then((X0)=>{let K0=I6(X0,b);if(!K0?.stableId)return null;return fetch("/_api/toggle-hide",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:S,stableId:K0.stableId,contentHash:K0.contentHash})})}).then((X0)=>X0?X0.json():null).then((X0)=>{if(X0&&!X0.ok)NJ("Hide refused",X0.error);else if(X0&&X0.ok){if(g8(X0.hidden?"Clip hidden.":"Clip shown.",!0),X0.seq!=null)Y6(V,X0.seq,X0.hidden?"hide clip":"show clip")}}).catch(()=>g8("Hide failed: network error"))},onReorderMove:(b,S,d)=>{if(!V||V===o8)return;let X0=c7||void 0,K0=`/_api/comp-clips?canvas=${encodeURIComponent(V)}${X0?`&artboardId=${encodeURIComponent(X0)}`:""}`;fetch(K0).then((F0)=>F0.json().catch(()=>({}))).then((F0)=>{let I0=I6(F0,b),p=I6(F0,S);if(!I0?.stableId||!p?.stableId)return null;return fetch("/_api/reorder-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:X0,stableId:I0.stableId,contentHash:I0.contentHash,refStableId:p.stableId,refContentHash:p.contentHash,position:d,mode:"move"})})}).then((F0)=>F0?F0.json():null).then((F0)=>{if(F0&&!F0.ok)console.warn("[reorder-move]",F0.error||"failed"),NJ("Reorder refused",F0.error);else if(F0?.ok){if(g8("Clip moved.",!0),F0.seq!=null)Y6(V,F0.seq,"move clip")}}).catch(()=>g8("Reorder failed: network error"))},onDropMedia:(b,S)=>{if(!V||V===o8)return;let d=c7||void 0,X0=OY,K0=V,F0=(Array.isArray(b)?b:[b]).filter(Boolean);(async()=>{if(!J9.length){let p=[];for(let O0 of F0){let g0=O0.type.startsWith("audio/")?"audio":O0.type.startsWith("video/")?"video":null;if(!g0)continue;try{let K8=await fetch("/_api/asset",{method:"POST",headers:{"Content-Type":O0.type||"application/octet-stream"},body:O0}),L8=await K8.json().catch(()=>({}));if(L8?.path)p.push({src:L8.path,mediaKind:g0});else g8(`Upload failed: ${L8?.error||`HTTP ${K8.status}`}`)}catch{g8("Upload failed: network error")}}if(!p.length){g8("No video/audio files in the drop — nothing to cut.");return}let D0=!1;for(let O0 of p){let g0=await ZE(O0.src).catch(()=>null),K8={canvas:K0,lane:O0.mediaKind==="audio"&&D0?"audio":"storyline",durationInFrames:B3(X0,g0),mediaTag:O0.mediaKind==="audio"?"Audio":"Video",src:O0.src};if(K8.lane==="audio")K8.from=0;let L8=await fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(K8)}).catch(()=>null),U6=L8?await L8.json().catch(()=>null):null;if(U6?.ok){if(D0=!0,U6.seq!=null)Y6(K0,U6.seq,"add clip")}else if(!D0)break;else NJ("Insert refused",U6?.error)}if(D0){g8("Artboard upgraded to a video comp — clips added to the storyline.",!0);return}for(let O0=0;O0<8;O0+=1){let g0=O0===0?"New Cut":`New Cut ${O0+1}`,K8=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:g0,kind:"video-comp",clips:p})}).catch(()=>null),L8=K8?await K8.json().catch(()=>({})):{};if(K8?.status===409)continue;if(!K8?.ok||!L8.ok){g8(`New cut failed: ${L8.error||"create refused"}`);return}await S9(),K6(L8.file),g8(`Started a new cut from ${p.length} clip${p.length>1?"s":""}.`,!0);return}g8('New cut failed: too many "New Cut" canvases — rename some.');return}let I0=S?.lane==="storyline"?S.index:void 0;for(let p of F0){let D0=p.type.startsWith("video/")?"Video":p.type.startsWith("audio/")?"Audio":p.type.startsWith("image/")?"Img":null;if(!D0)continue;let O0;try{O0=await(await fetch("/_api/asset",{method:"POST",headers:{"Content-Type":p.type||"application/octet-stream"},body:p})).json().catch(()=>({}))}catch{O0=null}if(!O0?.path){g8(`Upload failed: ${O0?.error||"server unreachable — retry in a moment"}`);continue}let g0=D0==="Audio",K8=D0==="Video"?await ZE(O0.path).catch(()=>null):null,L8={canvas:K0,artboardId:d,mediaTag:D0,src:O0.path};if(S&&(g0||S.lane==="audio"))L8.lane="audio",L8.from=Math.max(0,S.frame??0),L8.durationInFrames=Math.max(X0,OQ-L8.from);else if(S?.lane==="storyline"&&!g0){if(L8.lane="storyline",I0!=null)L8.index=I0,I0+=1;L8.durationInFrames=B3(X0,K8)}else if(S?.lane==="overlay"&&!g0){if((r6||[]).length===0)L8.lane="storyline";else L8.lane="overlay",L8.from=Math.max(0,S.frame??0);L8.durationInFrames=B3(X0,K8)}else if(!g0)L8.lane="storyline",L8.durationInFrames=B3(X0,K8);else L8.lane="audio",L8.from=0,L8.durationInFrames=Math.max(X0,OQ);try{let P7=await(await fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(L8)})).json().catch(()=>null);if(P7&&!P7.ok)console.warn("[insert-clip]",P7.error||"failed"),NJ("Insert refused",P7.error);else if(P7?.ok){if(g8("Clip added to the timeline.",!0),P7.seq!=null)Y6(K0,P7.seq,"add clip")}}catch{g8("Insert failed: network error")}}})()},height:BJ,onResize:X9,onClose:()=>K9(!1),selectedClipId:bH,onSelect:AY,transitionClips:fG,onClipVerb:CQ,comments:(b9[V]||[]).filter((b)=>b&&b.timeline),promptText:Q5,onAddComment:bY,onResolveComment:(b)=>b7({type:"comments-patch",id:b,patch:{status:"resolved"}}),onDeleteComment:(b)=>b7({type:"comments-delete",id:b}),onSplitAtPlayhead:()=>{let b=Q6.current,S=b.selected!=null?{stableId:b.selected}:null;if(!S){let d=b.sequences||[],X0=d.find((K0)=>K0.series&&b.frame>=K0.from&&b.frame<K0.from+K0.duration)||d.find((K0)=>b.frame>=K0.from&&b.frame<K0.from+K0.duration);if(X0?.stableId)S={stableId:X0.stableId}}if(S)CQ(S,"split",{atFrame:b.frame});else g8("Nothing under the playhead to split.")},onAddTitle:(b)=>{if(!V||V===o8)return;Promise.resolve("Title").then((S)=>{if(!S)return;fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:c7||void 0,lane:"overlay",from:b,durationInFrames:Math.round(OY*3),mediaTag:"Title",src:S})}).then((X0)=>X0.json().catch(()=>null)).then((X0)=>{if(X0&&!X0.ok)NJ("Title refused",X0.error);else if(X0?.ok){if(g8("Title added.",!0),X0.seq!=null)Y6(V,X0.seq,"add title")}}).catch(()=>g8("Title failed: network error"))})},onAddAiClip:()=>{if(!V||V===o8)return;(async()=>{fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:c7||void 0,lane:"storyline",durationInFrames:Math.round(OY*5),placeholder:{prompt:"Describe this shot — double-click to edit",kind:"veo"}})}).then((X0)=>X0.json().catch(()=>null)).then((X0)=>{if(X0&&!X0.ok)NJ("AI clip refused",X0.error);else if(X0?.ok){if(g8("AI placeholder added — double-click its text to write the prompt, then right-click → Generate ✨.",!0),X0.seq!=null)Y6(V,X0.seq,"add AI placeholder")}}).catch(()=>g8("AI clip failed: network error"))})()},onGeneratePlaceholder:(b)=>{if(!V||V===o8)return;let S=V,d=c7||void 0,X0=`/_api/comp-clips?canvas=${encodeURIComponent(S)}${d?`&artboardId=${encodeURIComponent(d)}`:""}`;fetch(X0).then((K0)=>K0.json().catch(()=>({}))).then((K0)=>{let F0=I6(K0,b),I0=F0?.placeholder;if(!F0?.stableId||!I0?.prompt){g8("No AI placeholder prompt on this clip.");return}let p=I0.kind==="image"?"image":"video",D0=I0.kind==="motion"?`Clean, minimal motion-graphics animation (flat shapes, smooth easing): ${I0.prompt}`:I0.prompt;fetch("/_api/generate-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({provider:"gemini",modality:p,prompt:D0})}).then(async(O0)=>O0.ok?O0.json():Promise.reject(Error(await O0.text()))).then((O0)=>{let g0=O0?.id;if(!g0)throw Error("no job id");g8(`Generating ${I0.kind}… (runs in the background)`,!0);let K8=F0.stableId,L8=()=>{fetch("/_api/generate-jobs").then((U6)=>U6.json().catch(()=>({}))).then((U6)=>{let P7=(U6?.jobs||[]).find((AJ)=>AJ.id===g0);if(!P7||P7.status==="failed"){g8(`Generation failed: ${P7?.error||"job lost"}`);return}if(P7.status!=="done"){setTimeout(L8,4000);return}let p9=P7.assets?.[0];if(!p9){g8("Generation finished but produced no asset.");return}fetch(X0).then((AJ)=>AJ.json().catch(()=>({}))).then((AJ)=>{let XZ=I6(AJ,{stableId:K8});if(!XZ?.stableId){g8("Placeholder clip is gone — generated asset kept in assets/.");return}CQ({stableId:XZ.stableId},"resolve-placeholder",{src:p9,mediaKind:p==="image"?"image":"video"})})}).catch(()=>setTimeout(L8,6000))};setTimeout(L8,3000)}).catch((O0)=>g8(`Generate failed: ${O0?.message||"provider error"} — is a Gemini key set in Settings?`))}).catch(()=>g8("Generate failed: network error"))},onAddImage:(b)=>{if(!V||V===o8)return;let S=(X0,K0)=>{let F0=OY;fetch("/_api/asset",{method:"POST",headers:{"Content-Type":K0||"application/octet-stream"},body:X0}).then((I0)=>I0.json().catch(()=>({}))).then((I0)=>{if(!I0?.path)return g8(`Upload failed: ${I0?.error||"unknown error"}`),null;return fetch("/_api/insert-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:V,artboardId:c7||void 0,lane:"overlay",from:b,durationInFrames:Math.round(F0*3),mediaTag:"Img",src:I0.path})})}).then((I0)=>I0?I0.json():null).then((I0)=>{if(I0&&!I0.ok)NJ("Image refused",I0.error);else if(I0?.ok){if(g8("Image overlay added.",!0),I0.seq!=null)Y6(V,I0.seq,"add image overlay")}}).catch(()=>g8("Image failed: network error"))};if(H9()){cZ().then((X0)=>{if(X0?.bytes)S(new Blob([new Uint8Array(X0.bytes)]),"")}).catch((X0)=>g8(`Image pick failed: ${X0?.message||"dialog error"}`));return}let d=document.createElement("input");d.type="file",d.accept="image/*",d.addEventListener("change",()=>{let X0=d.files?.[0];if(X0)S(X0,X0.type)}),d.click()},resolveMediaUrl:(b)=>`/${(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,"")}/${b}`}),z(oL0,{activePath:V,selected:w,wsConnected:q0,openCount:_70,theme:j8,onToggleTheme:A4,onClearSelected:k1,syncStatus:o0,syncProject:i0?.cloud?.projectName||K,syncOpen:N9,onOpenSync:o0?()=>x6("sync"):void 0,changesCount:V8,unpushed:E0?0:A0?.unpushed||0,savingIsManaged:E0,changesOpen:k8,onOpenChanges:A0?.repo||E0?()=>DX("changes"):void 0,version:i0?.version})]}),e9&&D("button",{type:"button",className:"st-present-exit",onClick:D4,"aria-label":"Exit presentation mode",title:"Exit presentation mode (Esc)",children:[z("svg",{viewBox:"0 0 16 16",width:"13",height:"13",fill:"none","aria-hidden":"true",children:z("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})}),z("span",{children:"Exit presentation"}),z("kbd",{className:"st-present-exit-kbd",children:"Esc"})]}),z(KL0,{open:LY,onClose:()=>NX(!1),actions:E70}),$Q&&z("div",{className:"st-scrim",role:"presentation",onMouseDown:(b)=>{if(b.target===b.currentTarget)x5(null)},children:D("div",{className:"st-dialog st-prompt",role:"dialog","aria-modal":"true","aria-label":$Q.title,children:[z("div",{className:"st-dialog-hd",children:z("span",{className:"st-dialog-title",children:$Q.title})}),D("div",{className:"st-dialog-bd",children:[z("input",{className:"st-input","data-testid":"shell-prompt-input",autoFocus:!0,defaultValue:$Q.value,onKeyDown:(b)=>{if(b.stopPropagation(),b.key==="Enter")x5(b.currentTarget.value);else if(b.key==="Escape")x5(null)}}),D("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:10},children:[z("button",{type:"button",className:"tlci-btn",onClick:()=>x5(null),children:"Cancel"}),z("button",{type:"button",className:"tlci-btn","data-testid":"shell-prompt-ok",onClick:(b)=>x5(b.currentTarget.closest(".st-dialog")?.querySelector("input")?.value??""),children:"OK"})]})]})]})}),W4&&z(yg,{target:W4,links:mH(W4.path),shell:nG,onClose:()=>DY(null),Icon:k9}),G4&&z(ML0,{mode:G4.mode,initialScope:G4.scope,activePath:V,hasComps:J9.length>0,comps:J9,activeArtboardId:w?.artboardId??Y7??null,selection:w?.selector?{selector:w.selector,file:w.file}:null,exportLane:i0.exportLane||"local",onBrowserCapture:RQ,onClose:()=>X6(null)}),iX&&z(_E,{cloud:i0.cloud,onClose:()=>bJ(!1),initialTab:typeof iX==="string"?iX:void 0,theme:j8,onSetTheme:S8,cpMode:G9,onSetCpMode:y9,minimapVisible:J5,onToggleMinimap:xY,zoomCtlVisible:aJ,onToggleZoomCtl:hY,annotationsVisible:PQ,onToggleAnnotations:fY,autoOpenInspector:tX,onToggleAutoOpenInspector:()=>IG((b)=>!b),hasCanvas:!!V&&V!==o8,panelSide:L0,onSetPanelSide:(b,S)=>v0((d)=>({...d,[b]:S})),layersMode:T0,onSetLayersMode:(b)=>{if(W8(b),b!=="separate")W0(!1)}}),LQ&&z(FE,{onClose:()=>Z4(!1),onInsert:J0}),eG&&z(DL0,{designRel:(i0?.designRel||i0?.designRoot||".design").replace(/^\/+|\/+$/g,""),onPick:q70,onClose:()=>C1(null),multiple:!!eG.multiple,hasArtboardAnchor:!!eG.hasArtboardAnchor,onPickMany:B70}),$L&&z(wE,{onPick:N70,onClose:()=>SL(null)}),R8&&z(Aw,{target:R8,cfg:i0,loadLog:q1,onClose:()=>z9(null),onRestore:async(b,S)=>{let d=oG?await hH(b,/^r\d+$/.test(S||"")?Number(S.slice(1)):NaN):await pY([b]);if(d?.ok)z9(null);else window.alert(d?.error||"Could not restore that version. Try again.")},onResolve:async(b)=>{let S=await dG(b);if(S.ok)z9(null);else window.alert(S.error||"Could not finish the merge. Get the latest again, then retry.")}}),z(RL0,{open:qX,onClose:()=>BX(!1)}),z(kL0,{open:S7,onClose:()=>qJ(!1),onStartTour:()=>{qJ(!1),MX(HF)}}),z(dm,{open:j9,activeCanvas:V,onClose:()=>NQ(!1)}),z(sm,{wn:wQ,onStartTour:MX}),z(mm,{center:jJ}),z(uh,{open:d7,onClose:()=>FQ(!1)}),z(xV,{open:LG,onClose:()=>x7(!1)}),z(aw,{open:FY,onClose:()=>nJ(!1),onStartTour:()=>MX($m),onBringBrand:()=>SJ(!0),onImportFigma:()=>B7(!0)}),z(lw,{open:O7,onClose:()=>SJ(!1)}),Q7&&z(dw,{onClose:()=>B7(!1),onImported:()=>S9()}),TY&&!v5&&!fH&&D("div",{className:"mdcc-tour-nudge",role:"status","aria-live":"polite",children:[z("div",{className:"mdcc-tour-nudge__body",children:"New here? Take a 60-second tour of the canvas browser."}),z("button",{type:"button",className:"mdcc-tour-nudge__cta",onClick:()=>{q4(),MX(HF)},children:"Start"}),z("button",{type:"button",className:"mdcc-tour-nudge__skip","aria-label":"Dismiss",onClick:q4,children:"×"})]}),fH&&!v5&&D("div",{className:"mdcc-tour-nudge",role:"status","aria-live":"polite",children:[z("div",{className:"mdcc-tour-nudge__body",children:"New to working with a team? See how saving & sharing works — 60 seconds."}),z("button",{type:"button",className:"mdcc-tour-nudge__cta",onClick:()=>{EQ(),MX(kE)},children:"Start"}),z("button",{type:"button",className:"mdcc-tour-nudge__skip","aria-label":"Dismiss",onClick:EQ,children:"×"})]}),z(Cm,{steps:v5??[],open:!!v5,onClose:()=>kY(null),onComplete:q4,bus:G1,hasSelection:!!w,hasCanvas:B.length>0})]})}a90.createRoot(document.getElementById("root")).render(z(MD0,{}));
|