@1agh/maude 1.5.0 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/studio/annotations/ai-write.ts +1 -0
- package/apps/studio/annotations/ops-merge.ts +15 -0
- package/apps/studio/annotations/ops.ts +30 -5
- package/apps/studio/api.ts +1 -0
- package/apps/studio/collab/registry.ts +1 -0
- package/apps/studio/dist/client.bundle.js +1 -1
- package/apps/studio/sync/codec.ts +1 -0
- package/package.json +8 -8
|
@@ -5680,7 +5680,7 @@ ${B.block}`:V,F=[],M=new Map;for await(let A of J.prompt(N,X(),K,Q?.(),Y?.(),Z?.
|
|
|
5680
5680
|
|
|
5681
5681
|
> Maude ${u.app.maudeVersion} · ${u.app.platform} ${u.app.arch} · ${u.app.surface}
|
|
5682
5682
|
> Local report bundle: \`${e?.dir??".design/_reports/"}\` (attach its files here)`),r=`${LV0}?title=${s}&body=${H0}&labels=report`;if(G9())try{await EV(r)}catch{window.open(r,"_blank","noopener")}else window.open(r,"_blank","noopener");T({fallbackDir:e?.dir??null}),W("done")}catch{$("Saving the local bundle failed too — please file the issue by hand.")}}let h=G.trim().length>0;return z("div",{className:"st-scrim",onClick:m,"data-testid":"report-bug-dialog",children:D("div",{className:"st-dialog rb-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"rb-title",onClick:(u)=>u.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:(u)=>Z(u.target.value),placeholder:"e.g. Clicking Export → PNG shows a spinner forever…"}),z("p",{className:"rb-hint",children:"Next you'll see exactly what gets attached — nothing is sent until you approve it."}),D("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:m,children:"Cancel"}),z("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-preview",disabled:!h,onClick:()=>W("preview"),children:"Review & attach"})]})]}),Y==="preview"&&D(Q0,{children:[D("div",{className:"rb-section",children:[D("div",{className:"rb-section-hd",children:[D("span",{children:["Screenshots (",U.length,")"]}),D("span",{className:"rb-hd-actions",children:[U.length<EE&&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((u)=>!u),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 (",DV0(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 ",EE,"."]}):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((u,v)=>z(AV0,{shot:u,redacting:w,onRects:(n)=>V((e)=>e.map((s,H0)=>H0===v?{...s,rects:n}:s)),onRemove:()=>{URL.revokeObjectURL(u.url),V((n)=>n.filter((e,s)=>s!==v))}},u.url))})]})]}),D("div",{className:"rb-section",children:[z("div",{className:"rb-section-hd",children:z("span",{children:"Included with the report"})}),D("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:!0,disabled:!0}),D("span",{children:["Maude ",H?.app?.maudeVersion??"…"," · ",H?.app?.platform??"…"," ",H?.app?.arch??""," · ",G9()?"desktop app":"browser"]})]}),Q&&D("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.activeCanvas,onChange:(u)=>M({...F,activeCanvas:u.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:(u)=>M({...F,projectName:u.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:(u)=>M({...F,logTail:u.target.checked})}),D("span",{children:["Recent server log (",H.logs.serverLogTail.split(`
|
|
5683
|
-
`).length," lines, paths & secrets scrubbed)",H?.process?` + server memory (${Math.round(H.process.rssBytes/1048576)} MB)`:""," ","—"," ",D("details",{className:"rb-details",children:[z("summary",{children:"view"}),z("pre",{className:"rb-log",children:H.logs.serverLogTail})]})]})]}):null,G9()&&B.length>0&&D("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.crashLogs,onChange:(u)=>M({...F,crashLogs:u.target.checked})}),D("span",{children:["Crash logs (",B.length,") — ",z("code",{children:B.map((u)=>u.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:[I?.issueUrl?D("p",{children:["Thank you — your report is filed as"," ",D("button",{type:"button",className:"rb-link","data-testid":"report-bug-issue-link",onClick:()=>{if(G9())EV(I.issueUrl).catch(()=>navigator.clipboard?.writeText(I.issueUrl));else window.open(I.issueUrl,"_blank","noopener")},children:["report #",I.issueNumber]})," ","on the public Maude issue tracker. Screenshots and logs stay in a private repository only maintainers can open — the issue links to them."]}):D("p",{children:["The bundle is saved locally",I?.fallbackDir?D(Q0,{children:[" ","at ",z("code",{children:I.fallbackDir})]}):null," ","and a prefilled GitHub issue was opened — attach the bundle files there."]}),z("footer",{className:"rb-actions",children:z("button",{type:"button",className:"st-btn rb-primary",onClick:m,children:"Done"})})]}),Y==="fallback"&&D(Q0,{children:[z("p",{className:"rb-error","data-testid":"report-bug-error",children:R}),z("p",{className:"rb-hint",children:"You can save the report locally instead and file it on GitHub yourself — the prefilled issue carries the text; screenshots stay on this machine unless you attach them by hand."}),D("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("preview"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary",onClick:x,children:"Save locally & open GitHub"})]})]})]})]})})}var PJ=b8(i8(),1);function fm(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 xm(J,X){let Q=fm(J),Y=fm(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 hm(J,X){if(!Array.isArray(J))return[];return J.filter((Q)=>Q&&(Q.version==null||xm(Q.version,X)))}function gm(J,X){let Q=X;if(Array.isArray(J)){for(let Y of J)if(Y&&Y.version&&xm(Y.version,Q))Q=Y.version}return Q}var PE="mdcc-whatsnew-seen",IE="mdcc-whatsnew-toast-dismissed";function _V0(J){return typeof J==="string"&&/^https?:\/\//i.test(J)}function wV0(J){try{let X=localStorage.getItem(PE);if(X)return X;localStorage.setItem(PE,J)}catch{}return J}function EV0(){try{return localStorage.getItem(IE)}catch{return null}}function mm(J){let[X,Q]=PJ.useState([]),[Y,W]=PJ.useState(J),[G,Z]=PJ.useState(()=>wV0(J)),[H,K]=PJ.useState(()=>EV0()),[U,V]=PJ.useState(!1);PJ.useEffect(()=>{let O=!1,I=()=>{fetch("/_api/whats-new").then(($)=>$.json()).then(($)=>{if(O)return;if(Q(Array.isArray($?.entries)?$.entries:[]),typeof $?.version==="string")W($.version)}).catch(()=>{})};I();let T=()=>I(),R=()=>{if(document.visibilityState==="visible")I()};return window.addEventListener("focus",T),document.addEventListener("visibilitychange",R),()=>{O=!0,window.removeEventListener("focus",T),document.removeEventListener("visibilitychange",R)}},[]);let B=hm(X,G),N=B.length>0&&H!==Y&&!U,F=B[0]??null,M=PJ.useCallback(()=>{let O=gm(X,Y);Z(O),K(Y);try{localStorage.setItem(PE,O),localStorage.setItem(IE,Y)}catch{}},[X,Y]),A=PJ.useCallback(()=>{K(Y);try{localStorage.setItem(IE,Y)}catch{}},[Y]),E=PJ.useCallback(()=>V(!0),[]),w=PJ.useCallback(()=>{V(!1),M()},[M]);return{entries:X,unseen:B,feedVersion:Y,panelOpen:U,openPanel:E,closePanel:w,showToast:N,toastEntry:F,dismissToast:A,markAllSeen:M}}function um({wn:J}){let X=`whats-new-${J.feedVersion}`;return PJ.useEffect(()=>{if(!J.showToast||!J.toastEntry){yW(X);return}P5({id:X,group:"whats-new",kind:"info",duration:1e4,title:`What's new${J.toastEntry.version?` · v${J.toastEntry.version}`:""} — ${J.toastEntry.title}`,description:J.toastEntry.summary,action:{label:J.unseen.length>1?`See all (${J.unseen.length})`:"Details",onClick:J.openPanel},onDismiss:J.dismissToast})},[X,J.showToast,J.toastEntry,J.unseen.length,J.openPanel,J.dismissToast]),PJ.useEffect(()=>()=>yW(X),[X]),null}function pm({wn:J,onStartTour:X}){let{panelOpen:Q,closePanel:Y}=J;if(PJ.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}),_V0(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 s5=b8(i8(),1),PV0=Object.freeze({dirs:[],sections:{}}),IV0="mdcc-sections-expanded",kV0=250,TV0=3000;function dm(J,X){return!!X&&J.dirs.includes(X)}function RV0(J,X){return J.sections[X]===!0}function kE(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 cm(J,X,Q){if(!X||J.sections[X]===!!Q)return J;return{...J,sections:{...J.sections,[X]:!!Q}}}function im(J,X){return cm(J,X,!RV0(J,X))}function CV0(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 HF(J,X,Q,{includeSelf:Y=!1}={}){if(!Q)return J;let W=CV0(X,Q);if(!W)return J;let G=cm(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 V=0;V<K;V++)U=`${U}/${H[V]}`,G=kE(G,U,!0);return G}function TE(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 om(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 nm(J,X){let Q=J.dirs.filter((Y)=>X.has(Y));return Q.length===J.dirs.length?J:{...J,dirs:Q}}function lm(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 $V0(){try{let J=JSON.parse(localStorage.getItem(IV0)||"null");return J&&typeof J==="object"&&!Array.isArray(J)?J:null}catch{return null}}function rm({fetchImpl:J}={}){let[X,Q]=s5.useState(PV0),[Y,W]=s5.useState(!1),G=J||((...U)=>fetch(...U)),Z=s5.useRef(G);Z.current=G,s5.useEffect(()=>{let U=!1,V=typeof AbortController==="function"?new AbortController:null,B=setTimeout(()=>V?.abort(),TV0);return Z.current("/_api/tree-state",V?{signal:V.signal}:void 0).then((N)=>N.ok?N.json():Promise.reject(Error(`HTTP ${N.status}`))).then((N)=>{if(U)return;let F=lm(N);if(!(N&&typeof N==="object"&&N.sections&&Object.keys(N.sections).length)){let A=$V0();if(A)F=lm({...F,sections:A})}Q(F)}).catch(()=>{}).finally(()=>{if(clearTimeout(B),!U)W(!0)}),()=>{U=!0,clearTimeout(B)}},[]);let H=s5.useRef(!0);s5.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{}},kV0);return()=>clearTimeout(U)},[Y,X]);let K=s5.useCallback((U)=>Q((V)=>U(V)),[]);return{state:X,ready:Y,update:K}}var K7=({as:J,size:X=14})=>z(J,{size:X,strokeWidth:1.75,style:{display:"block"}}),Z90="mdcc-usage-tour-seen",H90="mdcc-collab-tour-seen",o8="__system__",u90="mdcc-theme",z90="mdcc-show-hidden",K90="maude-cp-mode",U90="mdcc-sidebar-open",V90="mdcc-minimap-visible",q90="mdcc-zoomctl-visible",B90="mdcc-annotations-visible";var gF0=30000;function mF0(J){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(J)}).catch(()=>{})}catch{}}var LT=[{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"}],rK={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",sync:"right",assistant:"right"},N90="mdcc-panel-sides",F90="mdcc-layers-mode";function L90({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]||(LT.find((U)=>U.id===K)||{}).label||K},K))}),Z]})}var y5=/\.(tsx|html?)$/i,uF0=[[/\.md$/i,"markdown"],[/\.(css|json|txt|ya?ml)$/i,"text"],[/\.(svg|png|jpe?g|gif|webp|avif)$/i,"image"],[/\.(mp4|webm|mov)$/i,"video"],[/\.(mp3|wav|ogg|m4a)$/i,"audio"],[/\.(woff2?|ttf|otf)$/i,"font"]];function EL(J){for(let[X,Q]of uF0)if(X.test(J))return Q;return null}function Aq(J){return J.replace(/^\.[^/]+\//,"").replace(y5,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}function pF0(J){let X=[];return function Q(Y){for(let W of Y||[])X.push(W?.id??""),Q(W?.children)}(J),X.join(",")}var DT="1.5.0";function BL(J,X){let Q=()=>{try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(J,{body:X})}catch{}};if(G9()){_7("send_notification",{title:J,body:X}).catch(Q);return}Q()}function lF0(){if(typeof window>"u")return"dark";try{let J=localStorage.getItem(u90);if(J==="light"||J==="dark")return J}catch{}return"dark"}function EH(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 D90(J,X){if(typeof window>"u")return X;try{let Q=localStorage.getItem(J);return Q?JSON.parse(Q):X}catch{return X}}function dF0(){return!1}var cF0=[];function Q4(J){return J.split("/").pop()}function x8(J,X=!1,Q){P5({title:J,kind:X?"success":"error",action:Q})}var M90="maude-mode-hint-seen";function LL(J=!1){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(M90)==="1")return}catch{return}if(LL.active)return;LL.active=!0;let X=()=>{LL.active=!1;try{localStorage.setItem(M90,"1")}catch{}document.removeEventListener("keydown",Q,!0)},Q=(Y)=>{if((Y.key==="v"||Y.key==="V")&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey)yW("mode-hint"),X()};if(J)document.addEventListener("keydown",Q,!0);P5({id:"mode-hint",title:J?"Your mock is live":"You’re in Edit",description:J?"Click things to try it. Press V to select & inspect.":"Click selects, like Figma. Switch to Preview in the toolbar to use the live mock.",onDismiss:X})}function X4(J){return J.replace(y5,"")}function iF0(J){return J.replace(y5,"")}function oF0(J){let X=new Map;for(let G of J){if(!y5.test(G.name))continue;let Z=iF0(G.name);if(!X.has(Z)||/\.tsx$/i.test(G.name))X.set(Z,G)}let Q=new Map,Y=[];for(let G of J){if(y5.test(G.name))continue;let Z=null;for(let H of X.keys()){if(G.name===H)continue;if(G.name.startsWith(`${H}.`)){if(!Z||H.length>Z.length)Z=H}}if(Z){let H=Q.get(Z)||[];H.push(G),Q.set(Z,H)}else Y.push(G)}let W=[];for(let[G,Z]of X){let H=(Q.get(G)||[]).sort((K,U)=>K.name.localeCompare(U.name));W.push({primary:Z,sidecars:H,orphan:!1})}return W.sort((G,Z)=>G.primary.name.localeCompare(Z.primary.name)),Y.sort((G,Z)=>G.name.localeCompare(Z.name)),{canvases:W,orphans:Y.map((G)=>({primary:G,sidecars:[],orphan:!0}))}}function nF0(J,X,Q){let Y={};for(let W of Q||[]){let Z=(W.startsWith(X)?W.slice(X.length).replace(/^\/+/,""):W).split("/").filter(Boolean),H=Y;for(let K of Z)H=H[K]=H[K]||{};H._files=H._files||[]}for(let W of J){let Z=(W.startsWith(X)?W.slice(X.length).replace(/^\/+/,""):W).split("/"),H=Y;for(let K=0;K<Z.length;K++){let U=Z[K];if(K===Z.length-1)H._files=H._files||[],H._files.push({name:U,path:W});else H[U]=H[U]||{},H=H[U]}}return Y}function p90(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=p90(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 DL(J){return(J||[]).filter((X)=>X.status!=="resolved").length}function rF0(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 l90(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 OL({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 aF0={"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 sF0({open:J,onClose:X,actions:Q}){let[Y,W]=p.useState(""),[G,Z]=p.useState(0),H=p.useRef(null);p.useEffect(()=>{if(J)W(""),Z(0)},[J]),p.useEffect(()=>{H.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[G]);let K=p.useMemo(()=>JB(Q,Y),[Y,Q]);if(p.useEffect(()=>{if(G>=K.length)Z(0)},[K.length,G]),!J)return null;let U=(V)=>{X(),V.run()};return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(V)=>{if(V.target===V.currentTarget)X()},children:D("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[D("div",{className:"st-pal-search",children:[z(k9,{name:"search",size:18}),z("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(V)=>W(V.target.value),onKeyDown:(V)=>{if(V.key==="Escape")V.preventDefault(),X();else if(V.key==="ArrowDown")V.preventDefault(),Z((B)=>Math.min(K.length-1,B+1));else if(V.key==="ArrowUp")V.preventDefault(),Z((B)=>Math.max(0,B-1));else if(V.key==="Enter"){V.preventDefault();let B=gb(Q,Y,V.currentTarget.value,G);if(B)U(B)}}}),z(TJ,{children:"⌘K"})]}),z("div",{className:"st-pal-list",ref:H,children:K.length===0?z("div",{className:"st-pal-empty",children:"No matching command."}):K.map((V,B)=>{let N=V.group&&(B===0||K[B-1].group!==V.group)?z("div",{className:"st-pal-group",children:V.group},"g-"+V.group):null;return D(Q0,{children:[N,D("button",{type:"button",className:"st-pal-item"+(B===G?" is-active":""),onMouseEnter:()=>Z(B),onClick:()=>U(V),children:[z("span",{className:"st-pal-icon",children:z(k9,{name:V.icon,size:15})}),z("span",{className:"st-pal-label",children:V.label}),V.kbd?z("span",{className:"st-pal-kbd",children:z(TJ,{children:V.kbd})}):null]})]},V.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:aF0[J]})}function tF0(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 O90({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 TJ({children:J}){return z("span",{className:"kbd",children:J})}function A90(J,{min:X,max:Q,def:Y}){let W=p.useCallback((K)=>Math.min(Q,Math.max(X,K)),[X,Q]),[G,Z]=p.useState(()=>{try{let K=parseInt(localStorage.getItem(J)||"",10);return Number.isFinite(K)?W(K):Y}catch{return Y}});p.useEffect(()=>{try{localStorage.setItem(J,String(G))}catch{}},[J,G]);let H=p.useCallback((K)=>Z((U)=>W(typeof K==="function"?K(U):K)),[W]);return{w:G,setW:H,min:X,max:Q,def:Y}}function _90({label:J,size:X,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:K,def:U}=X,V=W==="rtl"?-1:1;return z("div",{className:"st-grip"+(Y?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":J,"aria-valuemin":H,"aria-valuemax":K,"aria-valuenow":Math.round(G),onPointerDown:Q,onDoubleClick:()=>Z(U),onKeyDown:(B)=>{let N=B.shiftKey?24:8;if(B.key==="ArrowRight")B.preventDefault(),Z((F)=>F+N*V);else if(B.key==="ArrowLeft")B.preventDefault(),Z((F)=>F-N*V);else if(B.key==="Home")B.preventDefault(),Z(H);else if(B.key==="End")B.preventDefault(),Z(K)},children:D("svg",{className:"st-grip-dots",viewBox:"0 0 6 18","aria-hidden":"true",children:[z("circle",{cx:"3",cy:"3",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"9",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"15",r:"1.1",fill:"currentColor"})]})})}var BT=[{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}],w90={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},eF0=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],Lq=[{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}],JL0="2x",E90=[{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}],XL0="auto",P90=[{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."}],QL0="keep",YL0={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 WL0(J){let X=String(J||"").split(".").pop()?.toLowerCase();return YL0[X]||"application/octet-stream"}function GL0({designRel:J,onPick:X,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[Z,H]=p.useState(null),[K,U]=p.useState(!1),[V,B]=p.useState(null),[N,F]=p.useState(()=>new Set),[M,A]=p.useState({}),[E,w]=p.useState(W?"artboard":"annotation");p.useEffect(()=>{let x=!0;return fetch("/_api/assets").then((h)=>h.json()).then((h)=>{if(!x)return;let u=h.ok?h.assets:[];H(u),A((v)=>{let n={...v};for(let e of u)n[e.path]=e.kind;return n})}).catch(()=>x&&H([])),()=>{x=!1}},[]),p.useEffect(()=>{let x=(h)=>{if(h.key==="Escape")h.stopPropagation(),Q()};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[Q]);let O=Array.from(N).some((x)=>(M[x]||"image")!=="image"),I=!W||O,T=!W?"No artboard on this canvas":O?"Video/audio can only be added as annotations":"";p.useEffect(()=>{if(I&&E==="artboard")w("annotation")},[I,E]);let R=(x)=>{F((h)=>{let u=new Set(h);if(u.has(x))u.delete(x);else u.add(x);return u})},$=async(x)=>{let h=await fetch("/_api/asset",{method:"POST",headers:{"content-type":x.type||"application/octet-stream"},body:x}),u=await h.json().catch(()=>({}));if(h.ok&&u.path)return{ok:!0,path:u.path};return{ok:!1,error:u.error||`upload failed (HTTP ${h.status})`}},C=async(x)=>{if(!x)return;U(!0),B(null);let h=await $(x);if(U(!1),h.ok)X(h.path);else B(h.error)},j=(x)=>{if(typeof x==="string"&&x.startsWith("video/"))return"video";if(typeof x==="string"&&x.startsWith("audio/"))return"audio";return"image"},f=async(x)=>{if(!x.length)return;U(!0),B(null);let h=await Promise.all(x.map((n)=>$(n).then((e)=>({...e,file:n}))));U(!1);let u=h.filter((n)=>n.ok),v=h.length-u.length;if(v>0)B(`${v} of ${h.length} uploads failed`);if(u.length)A((n)=>{let e={...n};for(let s of u)e[s.path]=j(s.file.type);return e}),F((n)=>{let e=new Set(n);for(let s of u)e.add(s.path);return e})},m=async()=>{U(!0),B(null);try{if(Y){let u=(await Ih()||[]).map((v)=>new File([new Uint8Array(v.bytes)],v.name,{type:WL0(v.name)}));if(U(!1),u.length)await f(u);return}let x=await uZ();if(x?.bytes){await C(new Blob([new Uint8Array(x.bytes)]));return}}catch(x){B(x?.message||"open failed")}U(!1)},c=()=>{if(G9()){m();return}let x=document.createElement("input");if(x.type="file",x.accept="image/*,video/*",Y)x.multiple=!0;x.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(x);let h=()=>{if(x.isConnected)x.remove()};window.addEventListener("focus",()=>setTimeout(h,300),{once:!0}),x.addEventListener("change",()=>{let u=x.files?Array.from(x.files):[];if(h(),!u.length)return;if(Y)f(u);else C(u[0])}),x.click()},o=(x)=>`/${J}/${x}`;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(x)=>{if(x.target===x.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…"}),V&&z("span",{className:"st-ap-err",children:V})]}),z("div",{className:"st-ap-grid",children:Z==null?z("div",{className:"st-ap-empty",children:"Loading…"}):Z.length===0?z("div",{className:"st-ap-empty",children:"No assets yet — upload one."}):Z.map((x)=>{let h=Y&&N.has(x.path);return D("button",{type:"button",className:"st-ap-cell","data-selected":h?"true":void 0,"aria-pressed":Y?h:void 0,title:`${x.name} · ${Math.max(1,Math.round(x.size/1024))} KB`,onClick:()=>Y?R(x.path):X(x.path),children:[Y&&z("span",{className:"st-ap-check","aria-hidden":"true",children:h?z(k9,{name:"check",size:12}):null}),x.kind==="video"?z("video",{className:"st-ap-thumb",src:o(x.path),muted:!0,playsInline:!0}):z("img",{className:"st-ap-thumb",src:o(x.path),alt:x.name,loading:"lazy"}),z("span",{className:"st-ap-name",children:x.name})]},x.path)})})]}),Y&&N.size>0&&D("div",{className:"st-dialog-ft st-ap-confirm",children:[D("span",{className:"st-ap-count",children:[N.size," selected"]}),D("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":E==="artboard",disabled:I,onClick:()=>w("artboard"),children:"Add to artboard"}),z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":E==="annotation",onClick:()=>w("annotation"),children:"Add as annotation"})]}),I&&z("span",{className:"st-ap-dest-note",children: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(N),E),children:"Insert"})]})]})})}function AL(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 ZL0({mode:J,initialScope:X,activePath:Q,hasComps:Y=!1,comps:W=[],activeArtboardId:G=null,selection:Z=null,exportLane:H="local",onBrowserCapture:K=null,onClose:U}){let V=p.useCallback(($0)=>H==="none"&&!$0.handoff&&$0.format!=="zip"&&!tb.has($0.format)||H!=="local"&&$0.format==="canva",[H]),[B,N]=p.useState(J==="handoff"?"shadcn":"png"),[F,M]=p.useState(()=>X&&ub("png",X)?X:bO("png")),[A,E]=p.useState(2),[w,O]=p.useState(JL0),[I,T]=p.useState(!0),[R,$]=p.useState(!1),[C,j]=p.useState(!1),[f,m]=p.useState(!1),[c,o]=p.useState(XL0),[x,h]=p.useState(QL0),[u,v]=p.useState(!0),[n,e]=p.useState(!1),[s,H0]=p.useState(null),[r,z0]=p.useState([]),i=BT.find(($0)=>$0.id===B)||BT[0],q0=i.handoff?[]:yO(i.format),Z0=900,I0=3600,e0=PK(W,aw(W,{artboardId:G})),J8=e0?.durationInFrames||0,Y8=e0?.fps||30,P8=i.temporal&&J8>900,S8=i.temporal&&J8>3600;p.useEffect(()=>{if(q0.length&&!q0.includes(F))M(bO(i.format))},[q0,F,i.format]),p.useEffect(()=>{if(H!=="remote")return;fetch("/_api/export-warmup").catch(()=>{})},[H]);let a8=p.useCallback(()=>{fetch("/_api/export-history").then(($0)=>$0.json()).then(($0)=>z0(Array.isArray($0?.history)?$0.history.slice(0,6):[])).catch(()=>{})},[]);p.useEffect(()=>{a8()},[a8]),p.useEffect(()=>{function $0(w0){if(w0.key==="Escape")w0.preventDefault(),U()}return window.addEventListener("keydown",$0),()=>window.removeEventListener("keydown",$0)},[U]);async function n0(){if(i.handoff){let H8=`/design:handoff ${Q&&Q!==o8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(H8)}catch{}H0({ok:!0,msg:`Copied: ${H8} — run it in Claude Code.`});return}if(V(i)){H0({ok:!1,msg:"This format needs the render service, which this workspace doesn’t have configured."});return}e(!0),H0(null);let $0=i.temporal?{scale:A}:{};if(i.format==="png"){let S0=Lq.find((H8)=>H8.id===w)||Lq[1];if(S0.kind==="dpi")$0.dpi=S0.value;else $0.scale=S0.value}if(i.format==="mp4"||i.format==="webm")$0.audio=u;if(S8)$0.maxFrames=J8;if(i.format==="pdf"){$0.pdfPrint={includeBleed:I,marks:{crop:C,registration:f}};let S0=E90.find((H8)=>H8.id===c)?.value;if(S0!==void 0)$0.dpi=S0;if(x!=="keep")$0.text=x}if(G)$0.artboardId=G;if(Z?.selector)$0.selection=Z;if(Q&&Q!==o8)$0.canvasFile=Q;if(fU.has(i.format)&&GB({exportLane:H,format:i.format,scope:F,artboardId:$0.artboardId})&&typeof K==="function")try{let S0=mO($0);H0({ok:!0,msg:"Capturing…"});let H8=await K({format:i.format,artboardIds:[$0.artboardId],scale:S0,onProgress:(u8,y8)=>H0({ok:!0,msg:`Capturing ${u8}/${y8}…`})}),X8=await gO(H8,i.format);for(let u8 of X8)AL(u8.name,u8.blob);for(let u8 of X8)await uO({format:i.format,scope:F,filename:u8.name});e(!1),H0({ok:!0,msg:`Saved ${X8.map((u8)=>u8.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(GB({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?Q4(Q).replace(/\.[^.]+$/,""):"export",{filename:H8,blob:X8}=await hO({capture:K,name:S0,onProgress:(u8,y8)=>H0({ok:!0,msg:`Capturing ${u8}/${y8}…`}),onAssemble:()=>H0({ok:!0,msg:"Assembling deck…"})});AL(H8,X8),await uO({format:i.format,scope:F,filename:H8}),e(!1),H0({ok:!0,msg:`Saved ${H8} 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"&&fU.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:$0})});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:($0)=>{if($0.target===$0.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 · ${X4(Q4(Q))}`:"Format"}),z("div",{className:"st-fmt-grid",children:BT.filter(($0)=>!$0.temporal||Y).map(($0)=>D("button",{type:"button","data-testid":`export-format-${$0.id}`,className:"st-fmt"+($0.id===B?" is-on":""),disabled:V($0),title:V($0)?"Needs the render service — not configured on this workspace":void 0,onClick:()=>{N($0.id),H0(null)},children:[z(k9,{name:$0.icon,size:16}),z("span",{className:"st-fmt-name",children:$0.label}),z("span",{className:"st-fmt-sub",children:$0.sub})]},$0.id))}),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:($0)=>M($0.target.value),children:q0.map(($0)=>z("option",{value:$0,children:w90[$0]},$0))})]}),!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:($0)=>O($0.target.value),children:Lq.map(($0)=>z("option",{value:$0.id,children:$0.label},$0.id))})]}),!i.handoff&&i.format==="png"&&z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let $0=Lq.find((S0)=>S0.id===w)||Lq[1],w0=$0.kind==="dpi"?$0.value/96:$0.value;return`${$0.label} ≈ ${Math.round(1440*w0)}×${Math.round(900*w0)} 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:($0)=>E(Number($0.target.value)),children:eF0.map(($0)=>z("option",{value:$0.value,children:$0.label},$0.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: ",J8," frames (≈",Math.round(J8/Y8),"s).",S8?` 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:($0)=>o($0.target.value),children:E90.map(($0)=>z("option",{value:$0.id,children:$0.label},$0.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:"The page stays vector; this only sets the capture density for raster content on it (dropped photos, large-format art)."}),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:x,onChange:($0)=>h($0.target.value),children:P90.map(($0)=>z("option",{value:$0.id,children:$0.label},$0.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:P90.find(($0)=>$0.id===x)?.description}),z("div",{className:"st-dialog-row",children:D("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-bleed",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-pdf-bleed",type:"checkbox",checked:I,onChange:($0)=>T($0.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:()=>$(($0)=>!$0),"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:($0)=>j($0.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:($0)=>m($0.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:u,onChange:($0)=>v($0.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}),r.length>0&&D("div",{className:"st-export-recent","data-testid":"export-recent",children:[z("div",{className:"st-rp-hd",children:"Recent"}),r.map(($0,w0)=>D("div",{className:"st-export-recent-row",children:[D("span",{children:[String($0.format||"").toUpperCase()," ·"," ",w90[$0.scope]||$0.scope]}),z("span",{className:"st-mono",children:$0.filename})]},w0))]})]}),D("div",{className:"st-dialog-ft",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:U,children:"Cancel"}),D("button",{type:"button",className:"btn btn--primary","data-testid":"export-submit",disabled:n,onClick:n0,children:[z(k9,{name:"download",size:14}),i.handoff?"Copy handoff command":n?"Exporting…":`Export ${i.label}`]})]})]})})}var PL=12,IL=16;function HL0({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)},V=W?W.dropProps(Y,!0,()=>U(!0)):{},B=W?.overDir===Y,N=W?W.dragProps(Y,!0):{},F=W?.draggedPath===Y,M=W?.busyPath===Y,A=D("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${Aq(Y)}`,"aria-expanded":K,"aria-dropeffect":W?"move":void 0,"aria-busy":M||void 0,tabIndex:-1,className:"st-row"+(B?" is-drop-target":"")+(F?" is-dragging":"")+(M?" is-busy":""),style:{paddingLeft:PL+X*IL+"px"},onClick:()=>U((E)=>!E),onContextMenu:G?(E)=>G.openAt(E,{kind:"dir",dirPath:Y}):void 0,...N,...V,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-${Aq(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(OL,{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 zL0({name:J,dsName:X,dirPath:Q,depth:Y,active:W,onOpenSystem:G,children:Z,expansion:H,forceOpen:K}){let U=!!K||!!H?.isOpen(Q),V=(B)=>{if(K)return;let N=typeof B==="function"?B(U):B;if(N!==U)H?.setOpen(Q,N)};return z(dz,{label:J,expanded:U,selected:W,onToggle:()=>V((B)=>!B),row:D("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:PL+Y*IL+"px"},children:[z("button",{type:"button",className:"st-ds-chev",onClick:()=>V((B)=>!B),"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 _L({file:J,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,onDelete:G,openCount:Z,depth:H,kind:K,sidecar:U,dirty:V,experimentalKind:B,drag:N,menu:F}){let M=J.path===X||J.path===Q,A=y5.test(J.name),E=!A&&K!=="runtime"?EL(J.name):null,w=!A&&!E,O=A?X4(J.name):J.name,I=A&&typeof G==="function"&&K!=="runtime",T=A&&!U&&K!=="runtime"&&typeof N<"u",R=T?N.dragProps(J.path,!0):{},$=N?.draggedPath===J.path,C=N?.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(y5,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,x=D("button",{type:"button",role:"treeitem","data-testid":o??(f?`file-row-${Aq(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:PL+H*IL+"px"},title:J.path+(Z?` — ${Z} open`:w?" (file index only)":""),onClick:()=>{if(A)Y(J.path);else if(E)W?.(J.path)},onContextMenu:m?(h)=>F.openAt(h,{kind:"file",path:J.path,dir: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}),B==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),B==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),V&&z("span",{className:"st-git-badge","data-kind":V,title:`Unsaved (${V})`,"aria-label":`Unsaved, ${V}`,children:V}),Z>0&&z("span",{className:"st-row-badge",children:Z})]});return z(dz,{label:O,row:x,selected:M,disabled:w,busy:C,actions:D(Q0,{children:[m&&z("button",{type:"button",className:"st-row-menu-btn"+(I?" has-delete-sibling":""),"data-testid":`tree-row-menu-${Aq(J.path)}`,title:`Actions for ${O}`,"aria-label":`Actions for ${O}`,"aria-haspopup":"menu",onClick:(h)=>F.openAt(h,{kind:"file",path:J.path,dir:c,canMove:j||f,supporting:f,name:J.name}),children:z(OL,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})}),I&&z("button",{type:"button",className:"st-row-del",title:`Delete ${O}`,"aria-label":`Delete canvas ${O}`,onClick:(h)=>{h.stopPropagation(),G(J.path,O)},children:z(OL,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})})}function KL0({primary:J,sidecars:X,depth:Q,kind:Y,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,showHidden:V,forceOpen:B,dirtyByPath:N,experimentalKind:F,drag:M,menu:A}){let E=N?.get(J.path),w=X.length>0,[O,I]=p.useState(!1),T=B||O,R=J.path===W;if(!(w&&V))return z(_L,{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",x=J.path.split("/").slice(0,-1).join("/"),h=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:PL+Q*IL+"px"},title:J.path,onClick:(u)=>{if(u.target.closest(".st-canvas-chev")){I((v)=>!v);return}Z(J.path)},onContextMenu:o?(u)=>A.openAt(u,{kind:"file",path:J.path,dir:x,canMove:c}):void 0,...j,children:[z("span",{className:"st-row-glyph st-canvas-chev",onClick:(u)=>{u.stopPropagation(),I((v)=>!v)},children:z(k9,{name:"chevron-right",className:"st-chev"+(T?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:X4(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:X4(J.name),row:h,selected:R,expanded:T,busy:m,onToggle:()=>I((u)=>!u),actions:o?z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${Aq(J.path)}`,title:`Actions for ${X4(J.name)}`,"aria-label":`Actions for ${X4(J.name)}`,"aria-haspopup":"menu",onClick:(u)=>A.openAt(u,{kind:"file",path:J.path,dir:x,canMove:c}),children:z(OL,{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((u)=>z(_L,{file:u,menu:A,activePath:W,previewPath:G,onOpen:Z,onPreview:H,openCount:0,depth:Q+1,kind:Y,sidecar:!0},u.path))})}function d90({node:J,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z=1,kind:H,showHidden:K,search:U,dsFolders:V,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:M,canvasKinds:A,dirPath:E="",drag:w,menu:O,expansion:I}){let T=Object.keys(J).filter((o)=>o!=="_files").sort(),R=J._files||[],{canvases:$,orphans:C}=p.useMemo(()=>oF0(R),[R]),{mediaOrphans:j,metaOrphans:f}=p.useMemo(()=>{let o=[],x=[];for(let h of C){let u=EL(h.primary.name);(u==="image"||u==="video"||u==="audio"||u==="font"?o:x).push(h)}return{mediaOrphans:o,metaOrphans:x}},[C]),m=!!(U&&U.trim()),c=p.useMemo(()=>{if(!V||Z!==1)return null;let o=new Map;for(let x of V)o.set(x.folder,x);return o},[V,Z]);return D(Q0,{children:[$.map((o)=>{let x=m&&o.sidecars.some((h)=>{let u=U.toLowerCase();return h.name.toLowerCase().includes(u)||h.path.toLowerCase().includes(u)});return z(KL0,{primary:o.primary,sidecars:o.sidecars,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,onDelete:F,openCount:DL(G[o.primary.path]),depth:Z,kind:H,showHidden:K,forceOpen:x,dirtyByPath:M,experimentalKind:A?.[o.primary.path],drag:w,menu:O},o.primary.path)}),j.map((o)=>z(_L,{file:o.primary,menu:O,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,openCount:DL(G[o.primary.path]),depth:Z,kind:H},o.primary.path)),K&&f.map((o)=>z(_L,{file:o.primary,menu:O,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,openCount:DL(G[o.primary.path]),depth:Z,kind:H},o.primary.path)),T.map((o)=>{let x=c?.get(o),h=E?`${E}/${o}`:o,u=z(d90,{node:J[o],activePath:X,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z+1,kind:H,showHidden:K,search:U,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:M,canvasKinds:A,dirPath:h,drag:w,menu:O,expansion:I});if(x&&N)return z(zL0,{name:o,dsName:x.name,dirPath:h,depth:Z,expansion:I,forceOpen:m,active:X===o8&&x.name===B,onOpenSystem:N,children:u},o);return z(HL0,{name:o,depth:Z,dirPath:h,expansion:I,forceOpen:m,drag:w,menu:w?O:void 0,children:u},o)})]})}var NL={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function UL0(J){if(J.kind==="project")return NL.project;if(J.kind==="runtime")return NL.runtime;if(J.label==="Design system")return NL.ds;if(J.label==="UI kit")return NL.canvas;return{title:J.label.toUpperCase(),pillFromCount:!0}}function VL0({readOnly:J=!1,cloud:X,groups:Q,activePath:Y,previewPath:W,activeDsName:G,onOpen:Z,onPreview:H,onOpenSystem:K,wsConnected:U,search:V,setSearch:B,commentsByFile:N,showHidden:F,sectionsExpanded:M,onToggleSection:A,treeExpansion:E,onNewBoard:w,onDeleteBoard:O,onRefresh:I,refreshing:T,collapsed:R,onCollapse:$,width:C,resizing:j,dirtyByPath:f,project:m,gitBranch:c,remoteSync:o,onGetLatest:x,canvasKinds:h,onMoveCanvas:u,onNewFolder:v,onDeleteFolder:n,onRenameFolder:e,onRenameCanvas:s,onDuplicateCanvas:H0,onDeleteFile:r,syncStatus:z0,onLinkedHub:i,onLocalProject:q0,onOpenLinkedFile:Z0,filesReady:I0,onShare:e0,savingIsManaged:J8=!1}){let Y8=p.useMemo(()=>{if(!V)return Q;return Q.map((k0)=>({...k0,tree:p90(k0.tree,V),filtered:!!V}))},[Q,V]),P8=Yy(u),S8=Jy(),a8=p.useMemo(()=>{let k0=[];for(let r0 of Q){if(r0.label==="Design system"||r0.kind!=="canvas")continue;let g0=r0.fullPath.replace(/^\.[^/]+\//,"")||r0.fullPath;k0.push({path:r0.fullPath,label:g0});for(let m0 of r0.dirs||[])k0.push({path:m0,label:m0.replace(/^\.[^/]+\//,"")})}return k0},[Q]),n0=S8.state?.extra,$0=n0?.kind==="file"?[{id:"share",label:"Share…",onSelect:()=>{S8.close(),e0(n0.path)}},...s&&/\.tsx$/i.test(n0.path)?[{id:"rename-canvas",label:"Rename…",onSelect:()=>{S8.close();let k0=X4(n0.path.split("/").pop()),r0=window.prompt("Rename canvas to:",k0);if(r0?.trim()&&r0.trim()!==k0)s(n0.path,r0.trim())}}]:[],...H0&&/\.tsx$/i.test(n0.path)?[{id:"duplicate-canvas",label:"Duplicate",onSelect:()=>{S8.close(),H0(n0.path)}}]:[],...n0.supporting&&s?[{id:"rename-file",label:"Rename…",onSelect:()=>{S8.close();let k0=n0.name??n0.path.split("/").pop(),r0=k0.includes(".")?k0.slice(k0.lastIndexOf(".")):"",g0=r0?k0.slice(0,-r0.length):k0,m0=window.prompt(`Rename ${k0} to:`,g0);if(m0?.trim()&&m0.trim()!==g0)s(n0.path,m0.trim())}}]:[],...n0.canMove?[{id:"move-to",label:"Move to…",onSelect:()=>S8.showMoveTo()}]:[],...n0.supporting&&r?[{id:"delete-file",label:"Delete",destructive:!0,onSelect:()=>{S8.close(),r(n0.path,n0.name??n0.path.split("/").pop())}}]:[]]:n0?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{S8.close();let k0=window.prompt("New folder name:");if(k0?.trim())v(n0.dirPath,k0.trim())}},{id:"rename-folder",label:"Rename folder",onSelect:()=>{S8.close();let k0=n0.dirPath.split("/").pop(),r0=window.prompt("Rename folder to:",k0);if(r0?.trim()&&r0.trim()!==k0)e(n0.dirPath,r0.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{S8.close(),n(n0.dirPath,n0.dirPath.split("/").pop())}}]:[],w0=n0?.kind==="file"||n0?.kind==="supporting"?a8.filter((k0)=>k0.path!==n0.dir):[],[S0,H8]=p.useState(!1),[X8,u8]=p.useState("board"),[y8,L9]=p.useState(""),[h0,T8]=p.useState(""),[A9,N8]=p.useState(!1),B0=p.useMemo(()=>Q.find((k0)=>k0.kind==="canvas"&&k0.label!=="Design system")?.fullPath,[Q]),Q8=p.useCallback(async()=>{let k0=y8.trim();if(!k0||A9)return;if(N8(!0),T8(""),X8==="folder"){if(!B0){N8(!1),T8("no canvas group to create a folder in");return}let g0=await v(B0,k0);if(N8(!1),g0?.ok)H8(!1),L9("");else T8(g0?.error||"could not create folder");return}let r0=await w(k0);if(N8(!1),r0?.ok)H8(!1),L9("");else T8(r0?.error||"could not create board")},[y8,A9,w,v,X8,B0]),s0=p.useMemo(()=>{let k0=0;for(let r0 of Q)for(let g0 of r0.paths||[])if(y5.test(g0))k0++;return k0},[Q]),s8=p.useMemo(()=>{let k0=0;for(let r0 of Y8)for(let g0 of r0.paths||[])if(y5.test(g0))k0++;return k0},[Y8]);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":S0&&X8==="board",onClick:()=>{T8(""),u8("board"),H8((k0)=>X8==="board"?!k0:!0)},children:z(k9,{name:"plus",size:15})}),!J&&B0&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":S0&&X8==="folder",onClick:()=>{T8(""),u8("folder"),H8((k0)=>X8==="folder"?!k0:!0)},children:z(k9,{name:"folder-plus",size:15})}),I&&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:()=>I(),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"}),s8," / ",s0]}),$&&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})})]})]}),S0?D("div",{className:"st-newboard",children:[z("input",{type:"text",autoFocus:!0,placeholder:X8==="folder"?"folder name…":"brief board name…",value:y8,maxLength:60,disabled:A9,"aria-label":X8==="folder"?"New folder name":"New brief board name",onChange:(k0)=>L9(k0.target.value),onKeyDown:(k0)=>{if(k0.key==="Enter")k0.preventDefault(),Q8();else if(k0.key==="Escape")k0.preventDefault(),H8(!1),L9(""),T8("")}}),z("button",{type:"button",className:"st-newboard-go",disabled:A9||!y8.trim(),"data-tip":"Create · Enter","aria-label":X8==="folder"?"Create folder":"Create brief board",onClick:Q8,children:A9?"…":"↵"})]}):null,h0?z("div",{className:"st-newboard-err",role:"alert",children:h0}):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:V,onChange:(k0)=>B(k0.target.value),onKeyDown:(k0)=>{if(k0.key==="Escape")if(k0.preventDefault(),V)B("");else k0.currentTarget.blur()},"aria-label":"Filter files"}),V?z("button",{className:"st-search-clear",onClick:()=>B(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):z(TJ,{children:"/"})]})}),z(Qy,{"aria-label":"Project file tree","data-testid":"canvas-list",children:Y8.map((k0)=>{if(!F&&!V&&k0.kind==="runtime")return null;let r0=UL0(k0),g0=(k0.paths||[]).filter((x7)=>y5.test(x7)).length,m0=r0.pill||(r0.pillFromDsCount?String(k0.dsFolders?.length||0):null)||(r0.pillFromCount?String(g0||k0.paths?.length||0):null),I8=k0.tree&&Object.keys(k0.tree).length>0,O0=k0.label==="Design system",G8=k0.kind==="project";if(!F&&!V&&G8&&g0===0)return null;let _8=dF0(k0),V0=M[k0.label],o0=!!V||(V0===void 0?_8:V0),k8=!O0&&k0.kind==="canvas"&&!J,X9=k8?P8.dropProps(k0.fullPath,!0):{},c0=P8.overDir===k0.fullPath;return z(dz,{className:"st-tree-section",label:r0.title,expanded:o0,onToggle:()=>A(k0.label,_8),row:D("button",{type:"button",className:"st-tree-sec-hd"+(c0?" is-drop-target":""),"data-testid":`tree-section-${k0.label.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,onClick:()=>A(k0.label,_8),"aria-expanded":o0,"aria-dropeffect":k8?"move":void 0,title:o0?"Collapse section":"Expand section",...X9,children:[z(k9,{name:"chevron-right",className:"st-chev"+(o0?" is-open":""),size:13}),z("span",{className:"st-sec-name",children:r0.title}),m0&&z("span",{className:"st-pill",children:m0})]}),children:o0&&(I8?z(d90,{node:k0.tree,activePath:Y,previewPath:W,onOpen:Z,onPreview:H,commentsByFile:N,depth:1,kind:k0.kind,showHidden:F,search:V,dsFolders:k0.dsFolders,activeDsName:G,onOpenSystem:O0?K:void 0,onDelete:O0||J?void 0:O,dirtyByPath:f,canvasKinds:h,dirPath:k0.fullPath,drag:!O0&&k0.kind==="canvas"&&!J?P8:void 0,menu:S8,expansion:E}):z("div",{className:"st-tree-empty",children:V?"No matches.":"Empty."}))},k0.label)})}),z(Xy,{state:S8.state,onClose:S8.close,rootItems:$0,destinations:w0,onPickDestination:(k0)=>u(n0.path,k0)}),z(NE,{project:m,liveBranch:c,remoteSync:o,onGetLatest:x,projectOnly:J8}),X===null?z(yw,{syncStatus:z0,onLinkedHub:i,onLocalProject:q0,onOpenFile:Z0,filesReady:I0}):null,z(hw,{})]})}function qL0({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 BL0({open:J,onClose:X,onStartTour:Q}){if(p.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",DT]}),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 NT=[{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 NL0({kbd:J,alt:X}){let Q=(Y,W)=>z("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>z(TJ,{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 FL0({open:J,onClose:X}){if(p.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=NT.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(TJ,{children:"?"})," to open"]})]}),z("div",{className:"so-columns",children:NT.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(NL0,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),D("div",{className:"so-overlay-ft",children:[D("span",{children:["close with ",z(TJ,{children:"Esc"})]}),D("span",{className:"so-count",children:[Q," bindings · ",NT.length," groups"]})]})]})})}var LL0=["File","Edit","View","Selection","Tools","Help"];function c90(J){p.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 DL0({panels:J,onToggle:X,onClose:Q,onZoom:Y,hasCanvas:W}){return c90(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(TJ,{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(TJ,{children:G.shortcut})]},G.label))]})}function eK({label:J,left:X,header:Q,items:Y,onAction:W,onClose:G}){return c90(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(TJ,{children:Z.shortcut}):null]},Z.id))]})}function ML0({onAction:J,onClose:X}){return z(eK,{label:"Help",left:320,onAction:J,onClose:X,items:[{id:"shortcuts",label:"Keyboard shortcuts",shortcut:"?"},{id:"help",label:"Help · commands & flows",shortcut:"F1"},{id:"report-bug",label:"Report a bug…"},{sep:!0},{id:"tour",label:"Take the tour"},{id:"watch-intro",label:"Watch the intro"},...G9()?[{id:"collab-tour",label:"How sharing works"}]:[],...G9()?[{id:"quick-setup",label:"Quick setup"}]:[],...G9()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function OL0({onAction:J,onClose:X,readOnly:Q=!1}){return z(eK,{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 AL0({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(eK,{label:"Tools",left:290,header:"Tool palette",onAction:J,onClose:X,items:Y})}function _L0({onAction:J,onClose:X,hasCanvas:Q,hasSharePath:Y,readOnly:W=!1}){return z(eK,{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 wL0({onAction:J,onClose:X,hasCanvas:Q,readOnly:Y=!1}){if(Y)return z(eK,{label:"Edit",left:90,onAction:J,onClose:X,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"}]});return z(eK,{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 EL0({activePath:J,sharePath:X,onShare:Q,project:Y,cloud:W,tabsCount:G,openMenu:Z,setOpenMenu:H,commentsPanelOpen:K,onToggleComments:U,changesOpen:V,changesCount:B,onToggleChanges:N,onOpenSystem:F,sidebarOpen:M,onToggleSidebar:A,showHidden:E,onToggleShowHidden:w,onOpenHelp:O,onOpenShortcuts:I,onReportBug:T,onStartTour:R,onStartCollabTour:$,annotationsVisible:C,onToggleAnnotations:j,minimapVisible:f,onToggleMinimap:m,zoomCtlVisible:c,onToggleZoomCtl:o,presentMode:x,onTogglePresent:h,printGuidesVisible:u,onTogglePrintGuides:v,postToActiveCanvas:n,onOpenWhatsNew:e,onOpenReadiness:s,onOpenQuickSetup:H0,onWatchIntro:r,whatsNewCount:z0,exportCenter:i,artboardCount:q0=0,presence:Z0=null,inspectorOpen:I0,inspectorTab:e0,onToggleInspector:J8,autoOpenInspector:Y8,onToggleAutoOpenInspector:P8,onOpenLayers:S8,timelineOpen:a8,onToggleTimeline:n0,hasComps:$0=!1,assistantOpen:w0,onToggleAssistant:S0,assistantBusy:H8,assistantUnseen:X8,onNewCanvas:u8,onAssembleVideo:y8,onOpenExport:L9,onOpenSettings:h0,onOpenGenerate:T8,onReload:A9,onCloseCanvas:N8,onInsertArtboard:B0,readOnly:Q8=!1}){let s0=J===o8,s8=s0?"SYSTEM":J?"CANVAS":"IDLE",k0=s0?z("b",{children:"design system"}):J?D(Q0,{children:[J.split("/").slice(0,-1).join("/"),"/",z("b",{children:X4(Q4(J))})]}):z("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),r0=new Set(W?["autoopen"]:["assistant","autoopen"]),g0=[{id:"tree",label:"Project Tree",shortcut:"T",checked:M,disabled:!1},{id:"changes",label:W?"History":B>0?`Changes · ${B} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:V,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:K,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:E,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:I0&&e0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:I0,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!Y8,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:$0?"video":void 0,checked:a8,disabled:!1},...G9()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:w0,disabled:!1}]:W?[{id:"assistant",label:"Assistant — in the desktop app",shortcut:"",checked:!1,disabled:!0,href:"https://maude.sh/download",hint:"The agent runs on your own Claude subscription, on your own machine."}]:[],{id:"annotate",label:"Annotations",shortcut:"⇧ P",checked:C,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:f,disabled:!J||s0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:c,disabled:!J||s0},{id:"present",label:"Presentation Mode",shortcut:"",checked:x,disabled:!J||s0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:u,disabled:!J||s0}].filter((O0)=>!Q8||!r0.has(O0.id)),m0=["file","edit","view","selection","tools","help"];function I8(O0){if(m0.includes(O0))H(Z===O0?null:O0)}return p.useEffect(()=>{if(!Z||!m0.includes(Z))return;let O0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function G8(_8){let V0=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!V0.length)return;let o0=V0.indexOf(document.activeElement);if(_8.key==="ArrowDown")_8.preventDefault(),V0[(o0+1)%V0.length].focus();else if(_8.key==="ArrowUp")_8.preventDefault(),V0[(o0-1+V0.length)%V0.length].focus();else if(_8.key==="Home")_8.preventDefault(),V0[0].focus();else if(_8.key==="End")_8.preventDefault(),V0[V0.length-1].focus();else if(_8.key==="ArrowRight"||_8.key==="ArrowLeft"){_8.preventDefault();let k8=_8.key==="ArrowRight"?1:-1,X9=m0.indexOf(Z);H(m0[(X9+k8+m0.length)%m0.length])}else if(_8.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",G8),()=>{clearTimeout(O0),window.removeEventListener("keydown",G8)}},[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:LL0.map((O0)=>{let G8=O0.toLowerCase(),_8=m0.includes(G8),V0=_8||G8==="help",o0=Z===G8;return z("button",{type:"button",className:"st-menu",role:"menuitem","data-testid":`menu-${G8}`,"data-tour":G8==="help"?"help":void 0,"aria-haspopup":_8?"menu":void 0,"aria-expanded":_8?o0:void 0,onClick:()=>I8(G8),onMouseEnter:()=>{if(Z!==null&&_8)H(G8)},children:O0},G8)})}),Z==="file"&&z(_L0,{readOnly:Q8,hasCanvas:!!J,hasSharePath:!!X,onAction:(O0)=>{if(O0==="new")u8?.();else if(O0==="assemble")y8?.();else if(O0==="export")L9?.("export");else if(O0==="share")document.querySelector('[data-testid="menu-file"]')?.focus(),Q?.();else if(O0==="handoff")L9?.("handoff");else if(O0==="generate")T8?.();else if(O0==="settings")h0?.();else if(O0==="reload")A9?.();else if(O0==="close")N8?.()},onClose:()=>H(null)}),Z==="edit"&&z(wL0,{readOnly:Q8,hasCanvas:!!J&&!s0,onAction:(O0)=>{if(O0==="undo")n({dgn:"undo"});else if(O0==="redo")n({dgn:"redo"});else if(O0==="deselect-all")n({dgn:"selection-clear"});else if(O0==="select-all-annotations")n({dgn:"annotation-select-all"});else if(O0.startsWith("new-artboard:"))B0?.(O0.slice(13))},onClose:()=>H(null)}),Z==="view"&&z(DL0,{panels:g0,onToggle:(O0)=>{if(O0==="tree")A();else if(O0==="changes")N();else if(O0==="comments")U();else if(O0==="hidden")w();else if(O0==="annotate")j();else if(O0==="inspector")J8();else if(O0==="autoopen")P8?.();else if(O0==="timeline")n0?.();else if(O0==="assistant")S0?.();else if(O0==="layers")S8?.();else if(O0==="minimap")m?.();else if(O0==="zoomctl")o?.();else if(O0==="present")h?.();else if(O0==="print-guides")v?.()},onZoom:(O0)=>n({dgn:"zoom",op:O0}),hasCanvas:!!J&&!s0,onClose:()=>H(null)}),Z==="selection"&&z(OL0,{readOnly:Q8,onAction:(O0)=>{if(O0==="deselect-all")n({dgn:"selection-clear"});else if(O0==="select-all-annotations")n({dgn:"annotation-select-all"})},onClose:()=>H(null)}),Z==="tools"&&z(AL0,{readOnly:Q8,onAction:(O0)=>n({dgn:"tool-set",tool:O0}),onClose:()=>H(null)}),Z==="help"&&z(ML0,{onAction:(O0)=>{if(O0==="shortcuts")I?.();else if(O0==="help")O?.();else if(O0==="report-bug")T?.();else if(O0==="tour")R?.();else if(O0==="collab-tour")$?.();else if(O0==="quick-setup")H0?.();else if(O0==="readiness")s?.();else if(O0==="whatsnew")e?.();else if(O0==="watch-intro")r?.()},onClose:()=>H(null)}),D("div",{className:"st-mb-right","data-tour":"status",children:[Z0?z("div",{className:"st-presence",children:Z0}):null,Q8&&z("span",{className:"st-stamp st-stamp--viewonly","data-testid":"view-only-stamp","data-tip":W?.user?`${W.user} is a viewer on this project — you can browse, comment and export where available. Ask a project owner for edit access, or sign out if that is not the account you meant to use.`:"Your role in this project is viewer — you can browse, comment when available, and export where available. Ask a project owner for edit access.",children:"VIEW ONLY"}),W?.user?D("span",{className:"st-cloudwho","data-testid":"cloud-account",children:[z("span",{className:"st-cloudwho-email",title:W.role?`Signed in as ${W.user} — ${W.role}`:W.user,children:W.user}),z("form",{method:"post",action:"/auth/browser/signout",className:"st-cloudwho-form",children:z("button",{type:"submit",className:"st-cloudwho-out","data-testid":"cloud-signout",title:"Sign out of this project",children:"Sign out"})})]}):null,G9()&&!Q8&&z("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":w0?"true":"false","data-busy":H8?"true":"false","data-unseen":X8?"true":"false","aria-label":`Assistant${H8?" — 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(Cm,{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:s8}),z("span",{className:"st-mb-file",title:J||"",children:k0}),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 PL0({tabs:J,activePath:X,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:K,onIframeLoad:U,canvasError:V,canvasReloadNonce:B,onRetryCanvasLoad:N,loadedPath:F,showQuickSetup:M,onStartQuickSetup:A,previewPath:E}){let w=p.useRef(null);p.useEffect(()=>{if(E)w.current?.focus()},[E]);let O=p.useRef(new Map),I=new Set(J.map(($)=>$.path));for(let[$,C]of O.current)if(!I.has(C.path))O.current.delete($);let T=($)=>{let C=_Z($,{...H,canvasToken:void 0}),j=`${$}#${B}|${C}`,f=O.current.get(j);if(!f)f={path:$,src:_Z($,H)},O.current.set(j,f);return f.src},R=V&&V.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: ${xV(Q4(E))}`,tabIndex:0,children:z(gg,{path:E,kind:EL(Q4(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",DT," / 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(TJ,{children:"⌘"})," and hover to preview an element, click to select it — ",z(TJ,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",G9()?D(Q0,{children:[z("br",{}),z("br",{}),"Claude can see whatever's selected when you ask for a change in the Assistant panel, so pointing is often faster than describing it."]}):null]}),M&&z("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:A,children:"Start quick setup"})]}),J.map(($)=>{if($.path===o8)return z("div",{className:"system-view"+($.path===X?" active":""),children:z(bL0,{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}#${B}`)}),K&&K===X&&z("div",{className:"st-canvas-loading","aria-hidden":"true",children:D("div",{className:"st-skel-card",children:[z("div",{className:"st-skel-cap st-mono",children:"compiling canvas…"}),z("span",{className:"skel st-skel-thumb"}),z("span",{className:"skel st-skel-line",style:{width:"72%"}}),z("span",{className:"skel st-skel-line",style:{width:"46%"}})]})}),V&&V.path===X&&z("div",{className:"st-canvas-error",role:"alert","data-testid":"canvas-load-error",children:D("div",{className:"st-canvas-error-card",children:[z("div",{className:"st-canvas-error-title",children:V.kind==="server"?"Maude's server isn't responding":"This canvas didn't finish loading"}),z("div",{className:"st-canvas-error-body",children:V.kind==="server"?z(Q0,{children:"The canvas couldn't be reached. This usually means Maude's server restarted underneath this window — your files on disk are untouched."}):D(Q0,{children:["The server is up, but"," ",z("code",{children:xV(Q4(V.path))})," ","never finished compiling. Its own error, if it has one, is in the canvas frame."]})}),z("button",{type:"button",className:"btn btn--primary","data-testid":"canvas-load-retry",onClick:()=>N?.(V.path),children:"Reload canvas"})]})})]})}var IL0=["color","space","radius","shadow","leading","weight","motion","font","other"],kL0={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function TL0(J){return J==="color"}function RL0({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([...IL0,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return z(Q0,{children:W.map((G)=>{let Z=Y[G],H=TL0(G);return D("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[D("h2",{children:["tokens · ",kL0[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 CL0(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 $L0(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 SL0({tokenGroups:J}){let X=J?.fontsize||[];if(X.length===0)return null;let Q=J?.leading||[],Y=$L0(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=CL0(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 bL0({data:J,onOpen:X,cfg:Q,onSelectDs:Y}){if(!J)return z("div",{className:"sv-empty",children:z("p",{children:"Loading design system…"})});let{previewGallery:W,uiKitsGallery:G,systemDir:Z,tokens:H,tokenGroups:K,tokensPath:U,ds:V,availableDesignSystems:B}=J,N=(!W||!W.length)&&(!G||!G.length),F=Array.isArray(B)&&B.length>1,M=V?.name??B?.[0]?.name??"";return D("div",{className:"sv",children:[D("header",{className:"sv-header",children:[z("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),z("span",{className:"sv-title",children:"design system view"}),F?D("label",{className:"sv-ds-picker",children:[z("span",{className:"sv-ds-picker-label",children:"DS"}),z("select",{value:M,onChange:(A)=>Y&&Y(A.target.value),children:B.map((A)=>z("option",{value:A.name,children:A.name},A.name))})]}):null,z("span",{className:"sv-loc",children:z("code",{children:Z})})]}),V?.description?z("p",{className:"sv-ds-description",children:V.description}):null,z(RL0,{tokens:H,tokenGroups:K,tokensPath:U}),z(SL0,{tokenGroups:K}),N?z("div",{className:"sv-empty",children:D("p",{children:["No ",z("code",{children:"preview/"})," or ",z("code",{children:"ui_kits/"})," folders found under"," ",z("code",{children:Z}),"."]})}):D(Q0,{children:[z(I90,{title:"preview",items:W,onOpen:X,kind:"preview",cfg:Q}),z(I90,{title:"ui kits",items:G,onOpen:X,kind:"ui_kits",cfg:Q})]})]})}function I90({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:_Z(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 yL0({activePath:J,selected:X,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,syncProject:K,syncOpen:U=!1,onOpenSync:V,changesCount:B=0,unpushed:N=0,savingIsManaged:F=!1,changesOpen:M=!1,onOpenChanges:A,version:E}){let w=J===o8,O=X&&X.selector?X.selector+(X.text?` — "${X.text.slice(0,60)}"`:""):"",I=X&&X.dom_path?X.dom_path.join(" > "):X?X.selector:"",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:I,children:O}),z("button",{type:"button",className:"st-sb-sel-clear",onClick:Z,"data-tip":"Clear · Esc inside iframe","data-tip-pos":"top","aria-label":"Clear selection",children:"×"})]}),D("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[z("span",{className:"lbl",children:"comments"}),D("span",{className:"val",children:[Y," open"]})]}),A&&D("button",{type:"button",className:"st-sb-slot st-sb-changes"+(M?" is-open":"")+(B>0?" has-changes":N>0?" has-unpushed":""),onClick:A,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":M,children:[z("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),z("span",{className:"lbl",children:"changes"}),z("span",{className:"val",children:F?"cloud saving":B>0?`${B} unsaved`:N>0?`${N} to publish`:"all saved"})]}),z("span",{className:"st-sb-spacer"}),D("span",{className:"st-sb-slot",role:"group","aria-label":"Connection",children:[z("span",{className:"st-live-dot"+(Q?" is-connected":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:Q?"live":"reconnecting"})]}),R&&(V?z("button",{type:"button",className:"st-sb-slot st-sb-sync st-sb-sync--btn"+(U?" is-open":""),onClick:V,"data-testid":"open-sync","data-tip":"Open Sync panel","data-tip-pos":"top","aria-label":"Open Sync panel","aria-pressed":U,children:$}):z("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:$})),E&&z("span",{className:"st-sb-slot st-sb-version",role:"group","aria-label":"Maude version",children:D("span",{className:"val","data-testid":"statusbar-version",children:["v",E]})}),D("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${T} theme`,"data-tip-pos":"top","aria-label":`Switch to ${T} theme`,children:[z(k9,{name:W==="dark"?"sun":"moon",size:13}),T]})]})}function jL0({commentsByFile:J,filter:X,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:K,width:U,resizing:V}){let B=l90(J),N=Object.keys(J||{}).sort(),F=[];for(let M of N){let A=J[M]||[],E=A.filter((O)=>{if(X==="open")return O.status!=="resolved";if(X==="resolved")return O.status==="resolved";return!0});if(E.length===0)continue;let w=A.filter((O)=>O.selector);F.push({file:M,comments:E.map((O)=>({...O,n:w.findIndex((I)=>I.id===O.id)+1}))})}return D("aside",{className:"st-rpanel"+(V?" is-resizing":""),style:U?{width:U,flexBasis:U}:void 0,"aria-label":"Comments",children:[z("div",{className:"st-rp-tabs st-rp-tabs--filters",children:D("div",{className:"st-cm-filters",role:"tablist",children:[D("button",{type:"button",className:"st-cm-filter"+(X==="all"?" is-active":""),role:"tab","data-testid":"comment-filter-all","aria-selected":X==="all",onClick:()=>Q("all"),children:["All · ",B.all]}),D("button",{type:"button",className:"st-cm-filter"+(X==="open"?" is-active":""),role:"tab","data-testid":"comment-filter-open","aria-selected":X==="open",onClick:()=>Q("open"),children:["Open · ",B.open]}),D("button",{type:"button",className:"st-cm-filter"+(X==="resolved"?" is-active":""),role:"tab","data-testid":"comment-filter-resolved","aria-selected":X==="resolved",onClick:()=>Q("resolved"),children:["Resolved · ",B.resolved]})]})}),z("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:F.length===0?D("div",{className:"st-rp-empty",children:[D("p",{children:["No comments ",X!=="all"?`with status “${X}”`:"yet","."]}),D("p",{children:["Open a canvas, hold ",z(TJ,{children:"⌘"})," and click an element, then press ",z(TJ,{children:"C"})," — or hold ",z(TJ,{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:X4(Q4(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:rF0(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 vL0={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 fL0({cloud:J}){let X=J?.role||null,[Q,Y]=p.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=vL0[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 xL0({update:J,onDismiss:X}){let[Q,Y]=p.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),Th().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X,children:"Later"})]})}function hL0({status:J}){let[X,Q]=p.useState(null);if(!J||J.linked===!1)return null;if(J.notSyncable)return null;let{state:Y,queuedOps:W,flash:G,conflicts:Z}=J,H=G==="synced",K=Y==="offline"||Y==="offline-long",U=J.docs?.rejected??0,V=Array.isArray(Z)?[...Z].reverse().find((M)=>M.kind==="cold-start-diverged"):null;if(!K&&!H&&!V&&U===0)return null;let B,N,F;if(H)B="success",N="Synced with hub",F=`${Y}:flash`;else if(K){let M=Z&&Z.length>0?` (${Z.length} conflict notice(s))`:"";if(Y==="offline-long")B="error",N=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${M}`;else B="warn",N=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${M}`;F=`${Y}:offline`}else if(V){if(V.snapshotFailed)B="error",N=`Diverged on ${V.slug}: kept local — the history snapshot FAILED, so the overwrite was refused. Check disk space / .design/_history write access.`;else B="warn",N=`Diverged on ${V.slug}: kept the ${V.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${V.slug}`;F=`diverged:${V.slug}:${V.at}`}else B="warn",N=`${U} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,F=`rejected:${U}`;if(X===F)return null;return D("div",{role:"status","aria-live":"polite",className:`st-banner st-banner--${B}`,children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:N}),z("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(F),children:"×"})]})}var gL0=["block","inline-block","flex","inline-flex","grid","inline","none"],k90=["px","%","fr","em","auto","min-content","max-content"];var mL0=["auto","stretch","flex-start","center","flex-end","baseline"];var T90=["300","400","500","600","700","800"],Dq=(J,X)=>J&&Object.hasOwn(J,"previous")?J.previous:X,R90=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],C90=["none","solid","dashed","dotted","double"],$90=["px","rem","em","%","vw","vh","auto"],S90=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),FT={"font-size":{node:z(K7,{as:gV,size:12})},"line-height":{node:z(K7,{as:iV,size:12})},"letter-spacing":{node:z(K7,{as:X3,size:12})},gap:{node:z(K7,{as:wK,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:z(K7,{as:Z3,size:12})},"border-width":{node:z(K7,{as:J3,size:12})}};var b90=["static","relative","absolute","fixed","sticky"],uL0=["normal","italic","oblique"],y90=["none","uppercase","lowercase","capitalize"];var j90=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],pL0=["fill","contain","cover","none","scale-down"];var v90=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],f90=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],b5={desktop:{label:"Desktop",width:1440,height:1024},laptop:{label:"Laptop",width:1280,height:800},tablet:{label:"Tablet",width:834,height:1194},mobile:{label:"Mobile",width:390,height:844}},aK=null;function wL(J){if(!J)return"";if(/^#[0-9a-f]{6}$/i.test(J))return J.toLowerCase();try{if(!aK)aK=document.createElement("canvas").getContext("2d");if(!aK)return"";aK.fillStyle="#000000",aK.fillStyle=J;let X=aK.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 FY=(J)=>Math.min(1,Math.max(0,J));function FL(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 Mq({r:J,g:X,b:Q}){return`#${[J,X,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function Oq({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 sK({h:J,s:X,v:Q}){let Y=Q*X,W=Y*(1-Math.abs(J/60%2-1)),G=Q-Y,Z=0,H=0,K=0;if(J<60)[Z,H,K]=[Y,W,0];else if(J<120)[Z,H,K]=[W,Y,0];else if(J<180)[Z,H,K]=[0,Y,W];else if(J<240)[Z,H,K]=[0,W,Y];else if(J<300)[Z,H,K]=[W,0,Y];else[Z,H,K]=[Y,0,W];return{r:(Z+G)*255,g:(H+G)*255,b:(K+G)*255}}function U7(J){if(!J)return"";let X=/^(-?\d*\.?\d+)px$/.exec(J);return X?`${Math.round(Number.parseFloat(X[1]))}px`:J}function J4(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 x90(J,X){if(!J||Array.isArray(J)||Array.isArray(X)||!X)return J;if(!J.id&&!X.id){let Q=(Y)=>typeof Y.selector==="string"&&Y.selector.startsWith("[data-dc-screen=");if(Q(J)&&Q(X)&&J.selector===X.selector&&J.file===X.file)return{...J,authored:J.authored??X.authored,computed:J.computed??X.computed,customStyles:J.customStyles??X.customStyles,attrs:J.attrs??X.attrs,artboardId:J.artboardId??X.artboardId,worldW:J.worldW??X.worldW,worldH:J.worldH??X.worldH};return J}if(!J.id||J.id!==X.id)return J;return{...J,authored:J.authored??X.authored,computed:J.computed??X.computed,customStyles:J.customStyles??X.customStyles,attrs:J.attrs??X.attrs,photoKind:J.photoKind??X.photoKind,photoAsset:J.photoAsset??X.photoAsset}}function i90(J,X){return(J?X?.canvasDesignSystems?.[J]:null)||X?.defaultDesignSystem||X?.designSystems?.[0]?.name||null}function lL0(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 o90(J,X,Q){let Y=J?.designSystems||[],W=Y.map((H)=>`${H.name}:${H.tokensCssRel}`).join("|"),[G,Z]=p.useState([]);return p.useEffect(()=>{if(!Y.length)return;let H=!1;return Promise.all(Y.map(async(K)=>{if(!K.tokensCssRel)return null;try{let U=await fetch(`/${X}/${K.tokensCssRel}`),V=U.ok?await U.text():"";return{name:K.name,...lL0(V)}}catch{return null}})).then((K)=>{if(H)return;let U=K.filter(Boolean);U.sort((V,B)=>V.name===Q?-1:B.name===Q?1:0),Z(U)}),()=>{H=!0}},[W,X,Q]),G}function n90({seed:J,label:X,onApply:Q}){let[Y,W]=p.useState(()=>Oq(FL(J||"#000000"))),G=p.useRef(Y);G.current=Y;let Z=p.useRef(null),H=p.useRef(null),K=p.useRef(J);p.useEffect(()=>{if(J&&J!==K.current)K.current=J,W(Oq(FL(J)))},[J]);let U=Mq(sK(Y)),V=(O)=>{O.preventDefault();let I=Z.current?.getBoundingClientRect();if(!I)return;let T=G.current.h,R=(C)=>{W({h:T,s:FY((C.clientX-I.left)/I.width),v:FY(1-(C.clientY-I.top)/I.height)})};R(O);let $=()=>{document.removeEventListener("pointermove",R),document.removeEventListener("pointerup",$),Q(Mq(sK(G.current)))};document.addEventListener("pointermove",R),document.addEventListener("pointerup",$)},B=(O)=>{O.preventDefault();let I=H.current?.getBoundingClientRect();if(!I)return;let{s:T,v:R}=G.current,$=(j)=>{W({h:FY((j.clientX-I.left)/I.width)*360,s:T,v:R})};$(O);let C=()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",C),Q(Mq(sK(G.current)))};document.addEventListener("pointermove",$),document.addEventListener("pointerup",C)},N=(O)=>{let I={...G.current,...O};W(I),Q(Mq(sK(I)))},F=(O)=>{let I=O.shiftKey?0.1:0.02,R={ArrowLeft:[-I,0],ArrowRight:[I,0],ArrowUp:[0,I],ArrowDown:[0,-I]}[O.key];if(!R)return;O.preventDefault(),N({s:FY(G.current.s+R[0]),v:FY(G.current.v+R[1])})},M=(O)=>{let I=O.shiftKey?20:2,R={ArrowLeft:-I,ArrowRight:I}[O.key];if(R==null)return;O.preventDefault(),N({h:Math.min(360,Math.max(0,G.current.h+R))})},A=async()=>{try{let O=window.EyeDropper;if(!O)return;let I=await new O().open();if(I?.sRGBHex)W(Oq(FL(I.sRGBHex))),Q(I.sRGBHex)}catch{}},E=sK(Y),w=(O)=>{let I={...E,...O},T=Oq({r:FY(I.r/255)*255,g:FY(I.g/255)*255,b:FY(I.b/255)*255});W(T),Q(Mq(sK(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 I=O.target.value;if(/^#?[0-9a-f]{6}$/i.test(I))W(Oq(FL(I)))},onKeyDown:(O)=>{if(O.key==="Enter")Q(O.currentTarget.value)},onBlur:(O)=>Q(O.currentTarget.value),onFocus:(O)=>O.currentTarget.select()})]}),D("button",{type:"button",ref:Z,className:"st-cp-cpick-sv","aria-label":X?`${X} saturation and value`:"saturation and value",style:{background:`hsl(${Y.h} 100% 50%)`},onPointerDown:V,onKeyDown:F,children:[z("span",{className:"st-cp-cpick-svwhite"}),z("span",{className:"st-cp-cpick-svblack"}),z("span",{className:"st-cp-cpick-knob",style:{left:`${Y.s*100}%`,top:`${(1-Y.v)*100}%`,background:U}})]}),D("div",{className:"st-cp-cpick-controls",children:[window.EyeDropper?z("button",{type:"button",className:"st-cp-cpick-eye","aria-label":"pick from screen",title:"eyedropper",onClick:A,children:z(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:B,onKeyDown:M,children:z("span",{className:"st-cp-cpick-huethumb",style:{left:`${Y.h/360*100}%`}})})]}),z("div",{className:"st-cp-cpick-rgb",children:["r","g","b"].map((O)=>D("label",{className:"st-cp-cpick-rgbf",children:[z("input",{"aria-label":O.toUpperCase(),value:Math.round(E[O]),onChange:(I)=>w({[O]:FY((Number.parseFloat(I.target.value)||0)/255)*255}),onFocus:(I)=>I.currentTarget.select()}),z("span",{children:O.toUpperCase()})]},O))})]})}function ML({kind:J,groups:X,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:K}){let[U,V]=p.useState(!1),[B,N]=p.useState(null),[F,M]=p.useState("custom"),[A,E]=p.useState(""),w=p.useRef(null),O=p.useRef(null),I=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);p.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 e0=window.innerHeight-z0.bottom>q0+8?z0.bottom+4:Math.max(8,z0.top-q0-4);N({left:Z0,top:e0,width:i,maxHeight:q0})};e();let s=(z0)=>{if(O.current?.contains(z0.target)||w.current?.contains(z0.target))return;V(!1)},H0=(z0)=>{if(z0.key==="Escape")V(!1)},r=(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",r,!0),()=>{document.removeEventListener("pointerdown",s,!0),document.removeEventListener("keydown",H0),window.removeEventListener("resize",e),document.removeEventListener("scroll",r,!0)}},[U]),p.useEffect(()=>{if(!U||!B||!O.current)return;let e=O.current.getBoundingClientRect(),s=B.left-e.left,H0=B.top-e.top;if(Math.abs(s)>0.5||Math.abs(H0)>0.5)N((r)=>r?{...r,left:r.left+s,top:r.top+H0}:r)},[U,B]);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})`);V(!1)},x=(e)=>{let s=(e||"").trim();if(s)Y(s)},h=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})]}),u=(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)),v=(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"}${I&&!K?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>V((e)=>!e),children:z("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):z("button",{type:"button",ref:w,className:`st-cp-tokbtn${I?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>V((e)=>!e),children:z("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),U&&B?g90.createPortal(z("div",{ref:O,className:"maude st-cp-pop","data-theme":typeof document<"u"&&document.documentElement.getAttribute("data-theme")||"dark",role:"dialog","aria-label":W||"design tokens",style:{left:B.left,top:B.top,width:B.width,maxHeight:B.maxHeight},children:J==="color"?D(Q0,{children:[D("div",{className:"st-cp-poptabs",role:"tablist",children:[z("button",{type:"button",role:"tab","aria-selected":F==="custom",className:`st-cp-poptab${F==="custom"?" is-active":""}`,onClick:()=>M("custom"),children:"Custom"}),z("button",{type:"button",role:"tab","aria-selected":F==="vars",className:`st-cp-poptab${F==="vars"?" is-active":""}`,onClick:()=>M("vars"),children:"Variables"})]}),F==="custom"?z(n90,{seed:Z||wL(Q)||"#000000",onApply:x}):!C?z("div",{className:"st-cp-pop-empty",children:"No color tokens"}):D(Q0,{children:[h,m.length?u(m):n]})]}):!C?z("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):D(Q0,{children:[h,m.length?v(m):n]})}),document.body):null]})}function h90({label:J,tracks:X,editable:Q,onChange:Y}){let W=(K,U)=>{let V=X[K];Y(X.map((B,N)=>N===K?vU.has(U)?{value:0,unit:U}:{value:V.value||1,unit:U}:B))},G=(K,U)=>{Y(X.map((V,B)=>B===K?{...V,value:U}:V))},Z=()=>Y([...X,{value:1,unit:"fr"}]),H=(K)=>Y(X.filter((U,V)=>V!==K));return D("div",{className:"st-cp-gridtracks",children:[D("div",{className:"st-cp-gridtracks-hd",children:[z("span",{className:"st-cp-gridtracks-label",children:J}),z("button",{type:"button",className:"st-btn st-cp-gridtracks-add",disabled:!Q,onClick:Z,children:"+ Track"})]}),X.length===0?D("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",J.toLowerCase(),"."]}):X.map((K,U)=>{let V=vU.has(K.unit);return D("div",{className:"st-cp-gridtrack-row",children:[V?z(rW,{value:K.unit,ariaLabel:`${J} track ${U+1}`,options:k90.map((B)=>({value:B,label:B})),onChange:(B)=>W(U,B)}):z(zJ,{value:K.value,min:K.unit==="fr"?0.1:0,step:K.unit==="fr"?0.1:1,ariaLabel:`${J} track ${U+1} value`,lead:String(U+1),unitSlot:z(rN,{value:K.unit,units:k90,ariaLabel:`${J} track ${U+1} unit`,onChange:(B)=>W(U,B)}),onCommit:(B)=>G(U,B)}),z("button",{type:"button",className:"st-btn st-cp-gridtrack-remove","aria-label":`remove ${J} track ${U+1}`,disabled:!Q||X.length<=1,onClick:()=>H(U),children:"×"})]},U)})]})}var tK={pending:0,waiters:[]};function r90(J){tK.pending+=1;let X=()=>{if(tK.pending-=1,tK.pending===0)for(let Q of tK.waiters.splice(0))Q()};return J.then(X,X),J}function dL0(){return tK.pending===0?Promise.resolve():new Promise((J)=>tK.waiters.push(J))}function cL0({el:J,cfg:X,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let K=!!J.id,U=J.computed||{},[V,B]=p.useState({a:{},c:{},t:{}});p.useEffect(()=>{B({a:{},c:{},t:{}})},[J.id,J.authored,J.customStyles,J.attrs]);let N=(t,M0)=>{let E0={...t||{}};for(let[v0,Z8]of Object.entries(M0))if(Z8===null)delete E0[v0];else E0[v0]=Z8;return E0},F=N(J.authored,V.a),M=N(J.customStyles,V.c),A=N(J.attrs,V.t),E=(t,M0)=>B((E0)=>({...E0,a:{...E0.a,[t]:M0}})),w=(t,M0)=>B((E0)=>({...E0,c:{...E0.c,[t]:M0}})),O=(t,M0)=>B((E0)=>({...E0,t:{...E0.t,[t]:M0}})),I=(X?.designRel||X?.designRoot||".design").replace(/^\/+|\/+$/g,""),T=i90(J.file,X),R=o90(X,I,T),$=(t)=>R.map((M0)=>({ds:M0.name,names:M0[t]||[],vals:M0.vals})).filter((M0)=>M0.names.length),[C,j]=p.useState({}),[f,m]=p.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;p.useEffect(()=>{if(c)m((t)=>t.Advanced?t:{...t,Advanced:!0})},[J.id,c]);let o=(F.position||U7(U.position)||"static")!=="static";p.useEffect(()=>{if(o)m((t)=>t["d:Position"]?t:{...t,"d:Position":!0})},[J.id,o]);let x=H,[h,u]=p.useState({});async function v(t,M0,E0){j((v0)=>({...v0,[E0]:"saving"}));try{let v0=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(M0)}),Z8=await v0.json().catch(()=>({}));return j((h8)=>({...h8,[E0]:!v0.ok||!Z8.ok?`err:${Z8&&Z8.error||`HTTP ${v0.status}`}`:"saved"})),v0.ok?Z8:null}catch(v0){return j((Z8)=>({...Z8,[E0]:`err:${v0&&v0.message?v0.message:String(v0)}`})),null}}let n=p.useRef(Promise.resolve()),e=(t,M0,E0,v0,Z8,h8,t8)=>{n.current=r90(n.current.then(async()=>{let v8=await v(t,M0,E0);if(!v8?.ok)return;let W9=Object.hasOwn(v8,"previous")?v8.previous:h8;if((W9??null)===(t8??null))return;H0(v0,Z8,W9,t8)}))},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,E0,v0)=>{Y?.({op:t,canvas:J.file,id:J.id,key:M0,before:E0==null||E0===""?null:E0,after:v0==null||v0===""?null:v0})},r=(t,M0)=>{let E0=(M0||"").trim();if(!K||!E0)return;let v0=F[t]??null;if(E0===(v0??"").trim())return;s(t,E0),E(t,E0),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,value:E0},t,"css",t,v0,E0)},z0=(t,M0)=>{let E0=(M0||"").trim(),v0=t.trim();if(!K||!v0||!E0)return;let Z8=M[v0]??null;s(v0,E0),w(v0,E0),e("/_api/edit-css",{canvas:J.file,id:J.id,property:v0,value:E0},v0,"css",v0,Z8,E0)},i=(t,M0)=>{let E0=(t||"").trim(),v0=(M0||"").trim();if(!K||!E0||!v0)return;let Z8=A[E0]??null;O(E0,v0),e("/_api/edit-attr",{canvas:J.file,id:J.id,attr:E0,value:v0},`@${E0}`,"attr",E0,Z8,v0)},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)},I0=(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)},e0={display:J.parentDisplay,flexDirection:J.parentFlexDirection},J8=(t,M0)=>{if(!K)return;let E0=Math.round((t==="width"?J.bounds?.w:J.bounds?.h)||0),v0=ib(t,M0,e0,E0);for(let Z8 of v0.reset)if(F[Z8])q0(Z8);for(let[Z8,h8]of v0.set)r(Z8,h8)},Y8=J.parentDisplay==="flex"||J.parentDisplay==="inline-flex",P8=(t)=>{let M0=cb(t,F,U,e0);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(aN,{value:M0,ariaLabel:`${t} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(E0)=>J8(t,E0)})})]},`mode-${t}`)},S8=["flex-start","center","flex-end"],a8=["flex-start","center","flex-end"],n0=["t","c","b"],$0=["l","c","r"],w0=()=>{let t=!(F["flex-direction"]||U7(U["flex-direction"])||"row").startsWith("column"),M0=Math.max(0,S8.indexOf(F["justify-content"]||U7(U["justify-content"])||"flex-start")),E0=F["align-items"]||U7(U["align-items"])||"stretch",v0=E0==="stretch"?1:Math.max(0,a8.indexOf(E0)),[Z8,h8]=t?[M0,v0]:[v0,M0];return n0[h8]+$0[Z8]},S0=(t)=>{let M0=n0.indexOf(t[0]),E0=$0.indexOf(t[1]),v0=!(F["flex-direction"]||U7(U["flex-direction"])||"row").startsWith("column"),[Z8,h8]=v0?[E0,M0]:[M0,E0];r("justify-content",S8[Z8]),r("align-items",a8[h8])},H8=(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 u8={bound:"token-bound",raw:"raw override",inherit:"inherited"},y8=(t)=>z("span",{className:`st-cp-prov st-cp-prov--${t}`,role:"img","aria-label":u8[t]}),L9=(t,M0)=>{let E0=M0??X8(t),v0=C[t],Z8=typeof v0==="string"&&v0.startsWith("err:")?v0.slice(4):"",h8=Z8?" is-err":v0==="saved"?" is-saved":v0==="saving"?" is-saving":"",t8=!!F[t],v8=Z8?`error: ${Z8}`:t8?`${u8[E0]} · double-click to reset`:u8[E0];return z("button",{type:"button",className:`st-cp-prov st-cp-prov--${E0}${h8}${t8?" is-resettable":""}`,"aria-label":v8,title:v8,tabIndex:t8?0:-1,onDoubleClick:t8?()=>q0(t):void 0,onKeyDown:t8?(W9)=>{if(W9.key==="Backspace"||W9.key==="Delete")W9.preventDefault(),q0(t)}:void 0})},h0=(t,M0,E0,v0)=>{let Z8=E0===void 0&&!F[t],h8=v0??t;return D("div",{className:`st-cp-row${Z8?" is-unset":""}`,children:[L9(t,E0),z("label",{className:"st-cp-label",title:h8,children:h8}),z("div",{className:"st-cp-ctl",children:M0})]},t)},T8={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"]},A9=(t)=>{(T8[t]||[]).forEach((M0)=>{if(F[M0])q0(M0)})},N8=(t,M0)=>{let E0=(T8[t]||[]).some((v0)=>F[v0]);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((v0)=>({...v0,[t]:!v0[t]})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:f[t]?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${E0?"":" is-quiet"}`,"aria-label":`reset ${t} section to original`,title:`reset ${t}`,disabled:!E0,onClick:()=>A9(t),children:z(K7,{as:cZ,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,E0,v0=!0)=>{let Z8=`d:${t}`,h8=f[Z8]===void 0?v0:f[Z8],t8=M0.some((v8)=>F[v8]);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":h8,onClick:()=>m((v8)=>({...v8,[Z8]:!h8})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:h8?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${t8?"":" is-quiet"}`,"aria-label":`reset ${t} to original`,title:`reset ${t}`,disabled:!t8,onClick:()=>M0.forEach((v8)=>{if(F[v8])q0(v8)}),children:z(K7,{as:cZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${h8?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:E0})})]},Z8)},Q8=(t)=>z("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!h[t],"aria-label":h[t]?`${t} — fewer options`:`${t} — more options`,title:h[t]?"fewer":"more",onClick:()=>u((M0)=>({...M0,[t]:!M0[t]})),children:h[t]?"▴":"···"}),s0=(t,M0)=>D("select",{className:"st-cp-nsel","aria-label":t,value:M0.includes(F[t])?F[t]:"",onChange:(E0)=>r(t,E0.target.value),children:[z("option",{value:"",disabled:!0,children:U7(U[t])||"—"}),M0.map((E0)=>z("option",{value:E0,children:E0},E0))]}),s8=(t)=>$(t).flatMap((M0)=>(M0.names||[]).map((E0)=>({name:E0,value:M0.vals?.[E0]||""}))),k0=(t,M0)=>z(nw,{value:F[t]||U7(U[t])||M0[0].value,ariaLabel:t,options:M0,onChange:(E0)=>r(t,E0)}),r0=(t,M0,E0={})=>{let v0=J4(F[t]??""),Z8=S90.has(t),h8=F[t]??"",t8=typeof h8==="string"&&/var\(\s*--/.test(h8),v8=Z8?"":v0.unit&&v0.unit!=="auto"?v0.unit:"px",W9=Number.parseFloat(J4(U7(U[t])??"").n)||0,T9=v0.n!==""&&v0.n!=null?Number.parseFloat(v0.n)||0:W9,s9=FT[t];return z(sN,{value:t8?h8:T9,tokens:s8(M0),ariaLabel:t,min:E0.min??0,lead:s9?s9.node??s9.t:void 0,unitSlot:Z8?null:z(rN,{units:$90,value:v0.unit||"px",ariaLabel:`${t} unit`,onChange:(t9)=>r(t,t9==="auto"?"auto":`${v0.n||"0"}${t9}`)}),onChange:(t9)=>r(t,typeof t9==="string"?t9:Z8?`${t9}`:`${t9}${v8}`)})},g0=()=>{let t=(Z8)=>Number.parseFloat(J4(F[Z8]??F["border-radius"]??U7(U[Z8])??U7(U["border-radius"])??"0").n)||0,M0={tl:t("border-top-left-radius"),tr:t("border-top-right-radius"),bl:t("border-bottom-left-radius"),br:t("border-bottom-right-radius")},E0=(Z8)=>{if(Z8.tl===Z8.tr&&Z8.tr===Z8.bl&&Z8.bl===Z8.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((t8)=>{if(F[t8])q0(t8)}),r("border-radius",`${Z8.tl}px`);else r("border-top-left-radius",`${Z8.tl}px`),r("border-top-right-radius",`${Z8.tr}px`),r("border-bottom-left-radius",`${Z8.bl}px`),r("border-bottom-right-radius",`${Z8.br}px`)},v0=FT["border-radius"];return z(rg,{corners:M0,lead:v0?v0.node??v0.t:void 0,onCorners:E0})},m0=()=>D("div",{className:"st-cp-border",children:[Q9("border-width",null,{fixedUnit:"px"}),D("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:C90.includes(F["border-style"])?F["border-style"]:"",onChange:(t)=>r("border-style",t.target.value),children:[z("option",{value:"",disabled:!0,children:"style"}),C90.map((t)=>z("option",{value:t,children:t},t))]}),z(ML,{kind:"color",groups:$("color"),current:F["border-color"],activeDs:T,swatchBg:U["border-color"]||F["border-color"]||"",seedHex:wL(U["border-color"]||F["border-color"])||"#000000",onPick:(t)=>r("border-color",t),label:"border colour"})]}),I8=()=>{let t=F.transform||U7(U.transform)||"",M0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(t),E0=((M0?Number.parseFloat(M0[1]):0)%360+360)%360,v0=(Z8)=>{let h8=(Z8%360+360)%360,t8=(F.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();r("transform",`${t8?`${t8} `:""}rotate(${h8}deg)`.trim())};return D("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[z(og,{value:E0,onChange:v0}),z(zJ,{value:E0,min:0,max:360,ariaLabel:"rotation",lead:z(K7,{as:cZ}),steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:v0})]})},O0=()=>{let t=F.filter||U7(U.filter)||"",M0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(t),E0=M0?Number.parseFloat(M0[1]):0;return z(zJ,{value:E0,min:0,ariaLabel:"filter blur",unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(Z8)=>{let h8=(F.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();r("filter",Z8>0?`${h8?`${h8} `:""}blur(${Z8}px)`.trim():h8||"none")}})},G8=()=>{let t=F.opacity,M0=t!=null&&t!==""?Number.parseFloat(t):Number.parseFloat(U7(U.opacity))||1,E0=Math.round((Number.isNaN(M0)?1:M0)*100);return z(vX,{value:E0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(v0)=>s("opacity",String(v0/100)),onCommit:(v0)=>r("opacity",String(v0/100))},`opacity:${t??""}`)},_8=()=>{let t=Number.parseInt(F["font-weight"]||U7(U["font-weight"])||"400",10)>=600,M0=(F["font-style"]||U7(U["font-style"]))==="italic",E0=/underline/.test(F["text-decoration"]||U7(U["text-decoration"])||"");return z(cg,{value:{b:t,i:M0,u:E0},ariaLabel:"text style",options:[{value:"b",node:z(K7,{as:oV}),label:"Bold"},{value:"i",node:z(K7,{as:tV}),label:"Italic"},{value:"u",node:z(K7,{as:K3}),label:"Underline"}],onToggle:(v0)=>{if(v0==="b")r("font-weight",t?"400":"700");else if(v0==="i")r("font-style",M0?"normal":"italic");else r("text-decoration",E0?"none":"underline")}})},V0=[{value:"row",node:z(K7,{as:gW}),label:"Row"},{value:"column",node:z(K7,{as:mW}),label:"Column"}],o0=[{value:"flex-start",node:z(K7,{as:pV}),label:"Start"},{value:"center",node:z(K7,{as:mV}),label:"Center"},{value:"flex-end",node:z(K7,{as:uV}),label:"End"},{value:"space-between",node:z(K7,{as:wK}),label:"Space between"}],k8=[{value:"flex-start",node:z(K7,{as:cV}),label:"Start"},{value:"center",node:z(K7,{as:lV}),label:"Center"},{value:"flex-end",node:z(K7,{as:dV}),label:"End"},{value:"stretch",node:z(K7,{as:H3}),label:"Stretch"}],X9=[{value:"left",node:z(K7,{as:a5}),label:"Left"},{value:"center",node:z(K7,{as:lW}),label:"Center"},{value:"right",node:z(K7,{as:dW}),label:"Right"},{value:"justify",node:z(K7,{as:cW}),label:"Justify"}],c0=[{value:"visible",node:z(K7,{as:dZ}),label:"Visible"},{value:"hidden",node:z(K7,{as:iZ}),label:"Hidden"},{value:"scroll",node:z(K7,{as:W3}),label:"Scroll"}],x7=(t,M0)=>{let E0=$(M0);return E0.length?z(ML,{kind:"value",groups:E0,current:F[t],activeDs:T,onPick:(v0)=>r(t,v0),label:`${t} design token`}):null},D9=(t)=>{let M0=t.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===M0)M0.select()})},h7=(t,M0)=>{if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return!1;t.preventDefault();let E0=t.shiftKey?10:1,v0=t.key==="ArrowUp"?1:-1,Z8=(Number.parseFloat(t.currentTarget.value)||0)+v0*E0;return t.currentTarget.value=String(Z8),M0(Z8),!0},w8=(t)=>z("input",{className:"st-cp-fin","aria-label":t,defaultValue:F[t]??"",placeholder:U7(U[t])||"—",onFocus:D9,onKeyDown:(M0)=>{if(M0.key==="Enter")M0.currentTarget.blur()},onBlur:(M0)=>r(t,M0.currentTarget.value)},`${t}:${F[t]??""}`),Q9=(t,M0,E0={})=>{let v0=J4(F[t]??""),Z8=S90.has(t),h8=Z8?"":E0.fixedUnit||(v0.unit&&v0.unit!=="auto"?v0.unit:"px"),t8=FT[t],v8=Number.parseFloat(J4(U7(U[t])??"").n)||0,W9=v0.n!==""&&v0.n!=null?Number.parseFloat(v0.n)||0:v8;return D(Q0,{children:[z(zJ,{value:W9,min:E0.min??0,step:1,ariaLabel:t,lead:t8?t8.node??t8.t:void 0,onCommit:(T9)=>r(t,Z8?`${T9}`:`${T9}${h8}`),unitSlot:Z8||E0.fixedUnit?null:z(rN,{units:$90,value:v0.unit||"px",ariaLabel:`${t} unit`,onChange:(T9)=>r(t,T9==="auto"?"auto":`${v0.n||"0"}${T9}`)})},`${t}:${F[t]??""}`),x7(t,M0)]})},d8=(t)=>{let M0=U[t]||F[t]||"",E0=F[t]??"",v0=typeof E0==="string"&&/var\(\s*--/.test(E0),Z8=v0?E0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):E0;return z(V3,{swatch:z(ML,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:$("color"),current:F[t],activeDs:T,swatchBg:M0,seedHex:wL(U[t]||F[t])||"#000000",onPick:(h8)=>r(t,h8),label:`${t} colour`}),displayValue:Z8,bound:v0,ariaLabel:t,onValue:(h8)=>r(t,h8)})},A0=(t,M0)=>{let E0=null,v0=M0.unitless?"":"px",Z8=(v8)=>M0.unitless?`${v8}`:`${v8}${v0}`,h8=(v8,W9,T9)=>{for(let s9 of W9??[t])T9(s9,Z8(v8))},t8=ow({getBase:()=>E0?.value??"0",min:M0.min??0,step:1,sides:M0.sides,onInput:(v8,W9)=>{if(E0)E0.value=String(v8);if(W9){let T9=E0?.closest(".st-cp-box");for(let s9 of W9){if(s9===t)continue;let t9=T9?.querySelector(`.st-cp-boxv[aria-label="${s9}"]`);if(t9)t9.value=String(v8)}}h8(v8,W9,s)},onCommit:(v8,W9)=>h8(v8,W9,r)});return{onPointerDown:(v8)=>{E0=v8.currentTarget,t8(v8)}}},U8=(t,M0)=>{let E0=F[t],v0=E0!=null&&E0!==""?J4(E0).n||E0:J4(U7(U[t])??"").n||"0",Z8=!E0||E0==="0"||E0==="0px"||E0==="auto",h8=t.split("-").pop(),t8=h8==="top"||h8==="bottom"?[`${M0}-top`,`${M0}-bottom`]:[`${M0}-left`,`${M0}-right`],v8=[`${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]}${Z8?" is-zero":""}`,"aria-label":t,defaultValue:v0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...A0(t,{sides:{pair:t8,all:v8}}),onFocus:D9,onKeyDown:(W9)=>{if(h7(W9,(T9)=>r(t,`${T9}px`)))return;if(W9.key==="Enter")W9.currentTarget.blur()},onBlur:(W9)=>{let T9=W9.currentTarget.value.trim();if(!T9)return;let s9=/[a-z%]/i.test(T9)?T9:`${T9}px`;r(t,s9)}},`${t}:${E0??""}`)},C8=(t)=>{let M0=F[t],E0=M0!=null&&M0!==""&&M0!=="auto"?J4(M0).n||M0:J4(U7(U[t])??"").n||"",v0=!M0||M0==="auto"||M0==="0"||M0==="0px",Z8=t==="top"||t==="bottom"?["top","bottom"]:["left","right"],h8=["top","right","bottom","left"];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${t[0]}${v0?" is-zero":""}`,"aria-label":t,defaultValue:E0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...A0(t,{sides:{pair:Z8,all:h8},min:-1/0}),onFocus:D9,onKeyDown:(t8)=>{if(h7(t8,(v8)=>r(t,`${v8}px`)))return;if(t8.key==="Enter")t8.currentTarget.blur()},onBlur:(t8)=>{let v8=t8.currentTarget.value.trim();if(!v8)return;let W9=/[a-z%]/i.test(v8)?v8:`${v8}px`;r(t,W9)}},`${t}:${M0??""}`)},V9=Object.entries(M),f9=Object.entries(A),d9=()=>{let t=(J.tag||"").toLowerCase(),E0=t==="img"||t==="video"||t==="picture"||t==="svg"||t==="canvas"||!!F["object-fit"]||!!F["object-position"]||!!F["aspect-ratio"],v0=(t==="img"||t==="video")&&!!J.attrs?.src&&!!W;return{showMedia:E0,canReplace:v0}},x9=(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…"})}),h0("object-fit",s0("object-fit",pL0)),h0("object-position",w8("object-position")),h0("aspect-ratio",D("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:f90.includes(F["aspect-ratio"])?F["aspect-ratio"]:"",onChange:(M0)=>{let E0=M0.target.value;if(r("aspect-ratio",E0),E0&&E0!=="auto"&&F.height)q0("height")},children:[z("option",{value:"",disabled:!0,children:U7(U["aspect-ratio"])||"—"}),f90.map((M0)=>z("option",{value:M0,children:M0},M0))]}))]});return D("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:H8,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(nw,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:z(K7,{as:hW,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:z(K7,{as:iW,size:12}),label:"Designer — Figma vocabulary"}],onChange:x})})]}),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||U7(U.display)||"").trim();return t==="flex"||t==="inline-flex"?D(Q0,{children:[h0("flex-direction",k0("flex-direction",V0),void 0,"Direction"),h0("align-items",z(ig,{value:w0(),onChange:S0,ariaLabel:"auto-layout alignment"}),X8("align-items"),"Alignment"),h0("gap",r0("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:[y8(X8("padding-top")),"padding"]}),U8("padding-top","padding"),U8("padding-right","padding"),U8("padding-bottom","padding"),U8("padding-left","padding")]}),z("div",{className:"st-cp-clustermore-row",children:Q8("Auto layout")}),h["Auto layout"]?h0("flex-wrap",z(nQ,{checked:/^wrap/.test(F["flex-wrap"]||U7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(E0)=>r("flex-wrap",E0?"wrap":"nowrap")}),X8("flex-wrap"),"Wrap"):null]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>r("display","flex"),children:"+ Auto layout (flex)"})})()),B0("Size",["width","height","min-width","max-width","min-height","max-height"],D(Q0,{children:[h0("width",Q9("width"),void 0,"Width"),h0("height",Q9("height"),void 0,"Height"),z("div",{className:"st-cp-clustermore-row",children:Q8("Size")}),h.Size?D(Q0,{children:[h0("min-width",Q9("min-width"),void 0,"Min width"),h0("max-width",Q9("max-width"),void 0,"Max width"),h0("min-height",Q9("min-height"),void 0,"Min height"),h0("max-height",Q9("max-height"),void 0,"Max height")]}):null]})),B0("Position",["position","top","right","bottom","left","z-index"],D(Q0,{children:[h0("position",s0("position",b90),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:[y8(X8("top")),"inset"]}),C8("top"),C8("right"),C8("bottom"),C8("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||U7(U.position)||"static"})]}),(F.position||U7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,z("div",{className:"st-cp-clustermore-row",children:Q8("Position")}),h.Position?h0("z-index",Q9("z-index"),void 0,"Layer order"):null]}),!1),B0("Fill",["background-color"],h0("background-color",d8("background-color"),void 0,"Fill")),B0("Stroke",["border-width","border-style","border-color"],h0("border",m0(),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"],h0("border-radius",g0(),X8("border-radius"),"Corner radius")),B0("Effects",["box-shadow","filter","mix-blend-mode"],D(Q0,{children:[h0("box-shadow",x7("box-shadow","shadow")||w8("box-shadow"),void 0,"Shadow"),h0("filter",O0(),X8("filter"),"Blur"),h0("mix-blend-mode",s0("mix-blend-mode",v90),void 0,"Blend")]})),B0("Opacity",["opacity"],h0("opacity",G8(),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:[h0("font-family",s0("font-family",R90),void 0,"Font"),h0("color",d8("color"),void 0,"Color"),h0("font-size",r0("font-size","type"),void 0,"Size"),h0("font-weight",s0("font-weight",T90),void 0,"Weight"),h0("line-height",Q9("line-height","lh"),void 0,"Line height"),h0("text-align",k0("text-align",X9),void 0,"Align"),z("div",{className:"st-cp-clustermore-row",children:Q8("Text")}),h.Text?D(Q0,{children:[h0("letter-spacing",Q9("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),h0("font-style",s0("font-style",uL0),void 0,"Style"),h0("text-transform",s0("text-transform",y90),void 0,"Case"),h0("white-space",s0("white-space",j90),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:[y8(X8("margin-top")),"margin"]}),U8("margin-top","margin"),U8("margin-right","margin"),U8("margin-bottom","margin"),U8("margin-left","margin")]})),(()=>{let{showMedia:t,canReplace:M0}=d9();return t?B0("Media",["object-fit","object-position","aspect-ratio"],x9(M0)):null})()]}):D(Q0,{children:[N8("Layout",(()=>{let t=(F.display||U7(U.display)||"").trim(),M0=t==="flex"||t==="inline-flex",E0=t==="grid"||t==="inline-grid";return D(Q0,{children:[h0("display",s0("display",gL0)),M0?D(Q0,{children:[h0("flex-direction",k0("flex-direction",V0)),h0("flex-wrap",z(nQ,{checked:/^wrap/.test(F["flex-wrap"]||U7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(v0)=>r("flex-wrap",v0?"wrap":"nowrap")}),X8("flex-wrap"))]}):null,M0||E0?D(Q0,{children:[h0("align-items",k0("align-items",k8)),h0("justify-content",k0("justify-content",o0)),h0("gap",r0("gap","space"))]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>r("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let t=(F.display||U7(U.display)||"").trim();if(!(t==="grid"||t==="inline-grid"))return null;let E0=F["grid-template-columns"]||"",v0=F["grid-template-rows"]||"",Z8=jO(E0),h8=jO(v0),t8=Z8.length>0||!E0.trim(),v8=h8.length>0||!v0.trim();return N8("Grid",D(Q0,{children:[t8?z(h90,{label:"Columns",tracks:Z8,editable:K,onChange:(W9)=>r("grid-template-columns",vO(W9))}):D("div",{className:"st-cp-note",children:["Columns use ",z("code",{children:E0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),v8?z(h90,{label:"Rows",tracks:h8,editable:K,onChange:(W9)=>r("grid-template-rows",vO(W9))}):D("div",{className:"st-cp-note",children:["Rows use ",z("code",{children:v0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),N8("Position",D(Q0,{children:[h0("position",s0("position",b90)),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:[y8(X8("top")),"inset"]}),C8("top"),C8("right"),C8("bottom"),C8("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||U7(U.position)||"static"})]}),(F.position||U7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,h0("z-index",Q9("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"}),"."]}),h0("grid-column",w8("grid-column")),h0("grid-row",w8("grid-row"))]})),N8("Typography",D(Q0,{children:[h0("font-family",s0("font-family",R90)),h0("color",d8("color")),h0("font-size",r0("font-size","type")),h0("font-weight",s0("font-weight",T90)),h0("line-height",Q9("line-height","lh")),h0("letter-spacing",Q9("letter-spacing",null,{min:-1/0})),h0("text-align",k0("text-align",X9)),h0("font-style",_8(),X8("font-style")),h0("text-transform",s0("text-transform",y90)),h0("white-space",s0("white-space",j90))]})),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:[y8(X8("margin-top")),"margin"]}),U8("margin-top","margin"),U8("margin-right","margin"),U8("margin-bottom","margin"),U8("margin-left","margin"),D("div",{className:"st-cp-boxpad",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[y8(X8("padding-top")),"padding"]}),U8("padding-top","padding"),U8("padding-right","padding"),U8("padding-bottom","padding"),U8("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")]}),h0("width",Q9("width")),h0("height",Q9("height")),h0("min-width",Q9("min-width")),h0("max-width",Q9("max-width")),h0("min-height",Q9("min-height")),h0("max-height",Q9("max-height")),h0("overflow",k0("overflow",c0)),Y8?D(Q0,{children:[z("div",{className:"st-cp-subhd",children:"In flex parent"}),h0("align-self",s0("align-self",mL0)),h0("flex-grow",Q9("flex-grow",null,{unitless:!0})),h0("flex-shrink",Q9("flex-shrink",null,{unitless:!0})),h0("flex-basis",Q9("flex-basis"))]}):null]})),(()=>{let{showMedia:t,canReplace:M0}=d9();return t?N8("Media",x9(M0)):null})(),N8("Appearance",D(Q0,{children:[h0("background-color",d8("background-color")),h0("border-radius",g0(),X8("border-radius")),h0("border",m0(),X8("border-width")),h0("box-shadow",x7("box-shadow","shadow")||w8("box-shadow")),h0("filter",O0(),X8("filter")),h0("mix-blend-mode",s0("mix-blend-mode",v90)),h0("opacity",G8()),h0("rotation",I8(),X8("transform")),h0("transform",w8("transform")),h0("transform-origin",w8("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:[V9.length?D(Q0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),V9.map(([t,M0])=>D("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`custom property ${t} name`}),z("input",{className:"st-cp-fin",defaultValue:M0,"aria-label":`${t} value`,onKeyDown:(E0)=>{if(E0.key==="Enter")E0.currentTarget.blur()},onBlur:(E0)=>z0(t,E0.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(iL0,{commit:z0}),z("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),f9.length?D(Q0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),f9.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:(E0)=>{if(E0.key==="Enter")E0.currentTarget.blur()},onBlur:(E0)=>i(t,E0.currentTarget.value)},`at:${t}:${M0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>I0(t),children:z(k9,{name:"x",size:11})})]},`at:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),z(oL0,{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 iL0({commit:J}){let[X,Q]=p.useState(""),[Y,W]=p.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 oL0({commit:J}){let[X,Q]=p.useState(""),[Y,W]=p.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 nL0={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function rL0(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 aL0=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function a90({node:J,depth:X,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:V,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:M,onToggleLock:A,onRename:E}){let w=`${J.id}:${J.index}`,O=J.children&&J.children.length>0,I=W.has(w),T=!!J.synthetic,R=!T&&F?F[J.id]:null,$=!T&&!!M?.has(w),[C,j]=p.useState(!1),[f,m]=p.useState(""),c=!T&&J.id===Q&&(Y==null||J.index===Y),o=G?.has(w)?G.get(w):!!J.hidden,x=!!V&&!T&&!$,h=()=>{j(!1);let n=f.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!n||n===(J.dcElement??""))return;E?.(J,n)},u=N?.key===w,v=u?{transform:`translate(${N.dx}px, ${N.dy}px)`,opacity:0.9,zIndex:20,position:"relative",pointerEvents:"none",cursor:"grabbing",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.28)"}:null;return D(Q0,{children:[D("div",{className:"st-layer st-layer--row"+(c?" is-sel":"")+(o?" is-hidden":"")+(T?" is-group":"")+(R?" is-instance":"")+($?" is-locked":""),style:{paddingLeft:6+X*14,...v},role:"treeitem","aria-selected":T?void 0:c,"aria-expanded":O?!I:void 0,"aria-grabbed":x?u: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:x?(n)=>B(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":I?"Expand":"Collapse",onClick:(n)=>{n.stopPropagation(),Z(w)},children:I?"▸":"▾"}):z("span",{className:"st-layer-caret","aria-hidden":"true"}),R?z("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:R.root?"◆":"◇"}):z(k9,{name:nL0[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:h,onKeyDown:(n)=>{if(n.stopPropagation(),n.key==="Enter")h();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&&!I?J.children.map((n,e)=>z(a90,{node:n,depth:X+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:V,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:M,onToggleLock:A,onRename:E},`${n.id}:${n.index}`)):null]})}function sL0({el:J}){let X=J?.computed||{},Q=J?.authored||{},Y=(U)=>{let V=Q[U];if(V&&/var\(\s*--/.test(V))return V.replace(/^var\(\s*|\s*\)$/g,"");return X[U]||V||""},W=(U,V)=>{let B=X[V]||Q[V];if(!B)return null;return D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:U}),D("div",{className:"st-swatch-row",children:[z("span",{className:"st-insp-swatch",style:{background:B},"aria-hidden":"true"}),z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Y(V)})]})]},U)},G=X["border-radius"]&&X["border-radius"]!=="0px",Z=G?J4(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 s90(J){if(J.artboardId)return J.artboardId;let X=/^\[data-dc-screen="([^"]+)"\]$/.exec(J.selector||"");return X?X[1]:null}var tL0=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],eL0=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function JD0({el:J,cfg:X,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let K=s90(J),U=(X?.designRel||X?.designRoot||".design").replace(/^\/+|\/+$/g,""),V=i90(J.file,X),B=o90(X,U,V),N=(v)=>B.map((n)=>({ds:n.name,names:n[v]||[],vals:n.vals})).filter((n)=>n.names.length),F=(v)=>N(v).flatMap((n)=>(n.names||[]).map((e)=>({name:e,value:n.vals?.[e]||""}))),M=(v)=>{let n=/^var\(\s*(--[\w-]+)\s*\)$/.exec(v||"");if(!n)return v||"";for(let e of B){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=(v,n)=>{if(!K)return;let e=Number.isFinite(v)&&v>0?Math.round(v):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(b5).find(([,v])=>v.width===A&&v.height===E)?.[0],I=Object.entries(b5).find(([,v])=>v.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=(v)=>{if(!K)return;let n=null;if(v==="print"&&!m){let e={paper:"a4"};try{let s=WB(e);if(s)n={defaults:e,widthPx:s.widthPx,heightPx:s.heightPx}}catch{}}if(G?.(K,v==="digital"?null:v,n),v==="web"&&T)Y?.(K,!1,void 0)},o=(v)=>{if(!K)return;let n={paper:"a4",...m,...v},e;try{e=WB(n)}catch{return}Q?.(K,e.widthPx,e.heightPx),Z?.(K,n)},x=(v,n)=>{if(!K)return;let e=Number.isFinite(n)?n:E,s=v&&Number.isFinite(e)?Math.round(e):void 0;Y?.(K,v,s)},h=(v)=>{let n=pb(T,v);if(n.kind==="resize")w(null,n.height);else if(n.kind==="promote-to-fixed")x(!0,n.height)},u=(v)=>{if(!K)return;W?.(K,v)};return D("section",{className:"st-cp-sec",children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Artboard"})}),D("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[z(zJ,{value:A??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(v)=>w(v,null)}),z(zJ,{value:E??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:T,onCommit:h})]}),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:(v)=>o({paper:v.currentTarget.value}),children:[z("option",{value:"",disabled:!0,children:"Paper size…"}),YB.map((v)=>D("option",{value:v.id,children:[v.label," — ",v.width,"×",v.height,v.unit]},v.id))]}):f==="web"?D("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:I??"",onChange:(v)=>{let n=b5[v.currentTarget.value];if(n)w(n.width,null)},children:[z("option",{value:"",disabled:!0,children:I?`${b5[I].label} — ≤ ${b5[I].width}px`:"Breakpoint…"}),Object.entries(b5).map(([v,n])=>D("option",{value:v,children:[n.label," — ≤ ",n.width,"px breakpoint"]},v))]}):D("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:O??"",onChange:(v)=>{let n=b5[v.currentTarget.value];if(n)w(n.width,n.height)},children:[z("option",{value:"",disabled:!0,children:O?b5[O].label:"Preset size…"}),Object.entries(b5).map(([v,n])=>D("option",{value:v,children:[n.label," — ",n.width,"×",n.height]},v))]})}),z("div",{style:{padding:"0 12px 8px"},children:z(aN,{value:T?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(v)=>x(v==="fixed")})}),z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Kind"})}),z("div",{style:{padding:"0 12px 8px"},children:z(rW,{value:f,ariaLabel:"artboard kind",options:eL0.map(([v,n])=>({value:v,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:(v)=>{let n=b5[v.currentTarget.value];if(n)H(K,n.width);v.currentTarget.value=""},children:[z("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(b5).map(([v,n])=>D("option",{value:v,children:[n.label," — ",n.width,"px"]},v))]})}):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(aN,{value:m?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(v)=>o({orientation:v})})}),z("div",{style:{padding:"0 12px 8px"},children:z(zJ,{value:Number.isFinite(m?.bleedMm)?m.bleedMm:3,min:0,step:0.5,ariaLabel:"bleed, millimeters",lead:"B",steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"mm"}),onCommit:(v)=>o({bleedMm:v})})})]}):null,z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Style"})}),D("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let v=M(R),n=/var\(\s*--/.test(R),e=n?R.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):R;return z(V3,{swatch:z(ML,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:N("color"),current:R,activeDs:V,swatchBg:v,seedHex:wL(v)||"#000000",onPick:(s)=>u({background:s||null}),label:"artboard background colour"}),displayValue:e,bound:n,ariaLabel:"artboard background",onValue:(s)=>u({background:(s||"").trim()||null})})})(),z(rW,{value:C,ariaLabel:"artboard body layout",options:tL0.map(([v,n])=>({value:v,label:n})),onChange:(v)=>u({layout:v||null})}),D("div",{style:{display:"flex",gap:8},children:[z(sN,{value:/^var\(/.test($)?$:Number.parseFloat($)||0,tokens:F("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(v)=>u({padding:typeof v==="string"?v:v>0?v:null})}),z(sN,{value:/^var\(/.test(j)?j:Number.parseFloat(j)||0,tokens:F("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(v)=>u({gap:typeof v==="string"?v:v>0?v:null})})]})]})]})}var MT=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,XD0=new RegExp(MT.source,"gi");function QD0(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(XD0)||[])],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=MT.exec(`${J.attrs?.src||""} ${X}`);return Y?Y[0]:null}function YD0({testId:J,selected:X,onClose:Q,layersTree:Y,componentMap:W,lockedKeys:G,onToggleLock:Z,onDetachInstance:H,canvasFile:K,onSelectLayer:U,onHoverLayer:V,onReorderLayer:B,layersBusyRef:N,cfg:F,onOptimistic:M,onRecordEdit:A,onReplaceMedia:E,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:I,onSetArtboardKind:T,onSetArtboardPrint:R,onDuplicateArtboard:$,onUndoRedo:C,editScope:j,tab:f,onTabChange:m,width:c,resizing:o,photoSel:x,photoRev:h,onPhotoEdit:u,onPhotoRemoveBackground:v,onPhotoRecordEdit:n,onPhotoUndoRedo:e,layersOnly:s=!1,hideLayersTab:H0=!1,cpMode:r,onSetCpMode:z0}){let[i,q0]=p.useState("inspect"),Z0=s?"layers":f??i,I0=(g0)=>{q0(g0),m?.(g0)},[e0,J8]=p.useState(()=>new Set),[Y8,P8]=p.useState(()=>new Map);p.useEffect(()=>{let g0=Array.isArray(X)?X[0]:X,m0=g0?.id;if(!m0||!Y?.nodes)return;let I8=g0.index,O0=null,G8=[];if(function _8(V0,o0){for(let k8 of V0||[]){let X9=`${k8.id}:${k8.index}`;if(!k8.synthetic&&k8.id===m0&&(I8==null||k8.index===I8))return O0=X9,G8.push(...o0),!0;if(k8.children&&k8.children.length&&_8(k8.children,[...o0,X9]))return!0}return!1}(Y.nodes,[]),!O0)return;if(G8.length)J8((_8)=>{let V0=!1,o0=new Set(_8);for(let k8 of G8)if(o0.delete(k8))V0=!0;return V0?o0:_8});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${O0}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[X,Y]);let S8=(g0)=>{let m0=`${g0.id}:${g0.index}`;return Y8.has(m0)?Y8.get(m0):!!g0.hidden},[a8,n0]=p.useState(null),[$0,w0]=p.useState(""),S0=(g0,m0)=>{if(!K||!g0?.id)return;r90(fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:K,id:g0.id,attr:"data-dc-element",value:m0})}).then((I8)=>I8.json().catch(()=>({}))).then((I8)=>{if(!I8.ok)return;A?.({op:"attr",canvas:K,id:g0.id,key:"data-dc-element",before:g0.dcElement??null,after:m0})}).catch(()=>{}))},H8=B?(g0,m0,I8)=>{if(N?.current)return;if(g0?.synthetic||m0?.synthetic)return;let O0=I8==="before"?`before ${m0.label}`:I8==="after"?`after ${m0.label}`:`into ${m0.label}`;w0(`Moved ${g0.label} ${O0}`),B(g0.id,m0.id,I8,{idIndex:g0.index,refIndex:m0.index})}:void 0,X8=()=>{let g0=[];return function m0(I8,O0,G8){(I8||[]).forEach((_8,V0)=>{if(g0.push({node:_8,depth:O0,parentNode:G8,siblings:I8,pos:V0}),_8.children&&_8.children.length&&!e0.has(`${_8.id}:${_8.index}`))m0(_8.children,O0+1,_8)})}(Y?.nodes,0,null),g0},u8=(g0)=>{if(g0.key!=="ArrowUp"&&g0.key!=="ArrowDown")return;if(!N8)return;let m0=X8(),I8=m0.findIndex((V0)=>V0.node.id===N8.id&&V0.node.index===N8.index);if(I8<0)return;let O0=g0.key==="ArrowDown"?1:-1,G8=m0[I8];if(!g0.altKey){let V0=m0[I8+O0];if(V0)g0.preventDefault(),U?.(V0.node);return}if(!H8||!Array.isArray(G8.siblings))return;g0.preventDefault();let _8=(V0)=>V0&&V0.children&&V0.children.length&&!e0.has(`${V0.id}:${V0.index}`);if(!g0.shiftKey){if(O0<0&&G8.pos>0)H8(G8.node,G8.siblings[G8.pos-1],"before");else if(O0>0&&G8.pos<G8.siblings.length-1)H8(G8.node,G8.siblings[G8.pos+1],"after");return}if(O0>0){let V0=G8.siblings[G8.pos+1];if(V0)H8(G8.node,V0,_8(V0)?"inside-start":"after");else if(G8.parentNode)H8(G8.node,G8.parentNode,"after")}else{let V0=G8.siblings[G8.pos-1];if(V0)H8(G8.node,V0,_8(V0)?"inside-end":"before");else if(G8.parentNode)H8(G8.node,G8.parentNode,"before")}},y8=p.useRef(null),L9=p.useRef(null),h0=(g0,m0,I8)=>{if(!H8||g0.button!==0||g0.metaKey||g0.ctrlKey||g0.shiftKey||g0.altKey)return;if(N?.current)return;let{clientX:O0,clientY:G8}=g0,_8=new Set([I8]);(function d8(A0){(A0.children||[]).forEach((U8)=>{_8.add(`${U8.id}:${U8.index}`),d8(U8)})})(m0);let V0=14,o0=6,k8=[];(function d8(A0,U8){(A0||[]).forEach((C8)=>{let V9=`${C8.id}:${C8.index}`;if(k8.push({node:C8,key:V9,id:C8.id,depth:U8,tag:C8.tag}),C8.children&&C8.children.length&&!e0.has(V9))d8(C8.children,U8+1)})})(Y?.nodes,0);let X9=new Map(k8.map((d8)=>[d8.key,d8])),c0=!1,x7=(d8)=>{if(!c0){if(Math.hypot(d8.clientX-O0,d8.clientY-G8)<4)return;c0=!0}let A0=d8.clientX-O0,U8=d8.clientY-G8,C8=null,V9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((d9)=>({rect:d9.getBoundingClientRect(),it:X9.get(d9.getAttribute("data-layer-key"))})).filter((d9)=>d9.it&&d9.it.key!==I8);if(V9.length){let d9=V9[0].rect.left,x9=V9[0].rect.right,t=V9.length;for(let s9=0;s9<V9.length;s9++)if(d8.clientY<V9[s9].rect.top+V9[s9].rect.height/2){t=s9;break}let M0=V9[t-1]?.it||null,E0=V9[t]?.it||null,v0=Math.round((d8.clientX-d9-o0)/V0),Z8=M0?M0.depth+(aL0.has(M0.tag)?0:1):0,h8=E0?E0.depth:0,t8=Math.max(h8,Math.min(v0,Z8)),v8=null,W9="before",T9=0;if(!M0){if(E0)v8=E0,W9="before",T9=E0.depth}else if(t8>M0.depth)v8=M0,W9="inside-start",T9=M0.depth+1;else if(t8===M0.depth)v8=M0,W9="after",T9=M0.depth;else{for(let s9=t-1;s9>=0;s9--)if(V9[s9].it.depth===t8){v8=V9[s9].it;break}if(!v8)v8=M0;W9="after",T9=t8}if(v8&&v8.key!==I8&&!_8.has(v8.key)){let s9=M0?V9[t-1].rect.bottom:V9[0].rect.top,t9=d9+o0+T9*V0;C8={refId:v8.id,position:W9,node:v8.node,y:s9,left:t9,w:Math.max(24,x9-t9)}}}let f9={key:I8,node:m0,dx:A0,dy:U8,target:C8};y8.current=f9,n0(f9)},D9=()=>{window.removeEventListener("pointermove",x7),window.removeEventListener("pointerup",w8),window.removeEventListener("keydown",Q9,!0)},h7=()=>{let d8=(A0)=>{A0.preventDefault(),A0.stopImmediatePropagation(),document.removeEventListener("click",d8,!0)};document.addEventListener("click",d8,!0),setTimeout(()=>document.removeEventListener("click",d8,!0),300)},w8=()=>{D9();let d8=y8.current;if(y8.current=null,n0(null),c0&&d8?.target)h7(),H8(d8.node,d8.target.node,d8.target.position)},Q9=(d8)=>{if(d8.key!=="Escape")return;if(d8.preventDefault(),d8.stopImmediatePropagation(),D9(),y8.current=null,n0(null),c0)h7()};window.addEventListener("pointermove",x7),window.addEventListener("pointerup",w8),window.addEventListener("keydown",Q9,!0)},T8=(g0)=>J8((m0)=>{let I8=new Set(m0);if(I8.has(g0))I8.delete(g0);else I8.add(g0);return I8}),A9=(g0)=>{let m0=`${g0.id}:${g0.index}`,I8=S8(g0),O0=!I8;if(P8((G8)=>new Map(G8).set(m0,O0)),M?.({id:g0.id,artboardId:Y?.artboardId??null,index:g0.index,prop:"display",value:O0?"none":null}),!K||!g0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(O0?{canvas:K,id:g0.id,property:"display",value:"none"}:{canvas:K,id:g0.id,property:"display",reset:!0})}).catch(()=>{}),A?.({op:"css",canvas:K,id:g0.id,key:"display",before:I8?"none":null,after:O0?"none":null})},N8=Array.isArray(X)?X[0]:X,B0=x?{asset:x.asset,kind:"annotation-image"}:(()=>{let g0=QD0(N8);return g0?{asset:g0,kind:"artboard-img"}:null})(),Q8=B0?.kind==="annotation-image",s0=(g0)=>{if(!(g0.metaKey||g0.ctrlKey)||g0.altKey)return;let m0=g0.key.toLowerCase();if(m0==="z")g0.preventDefault(),e?.(g0.shiftKey?"redo":"undo");else if(m0==="y")g0.preventDefault(),e?.("redo")},s8=Q8?"photo":Z0==="photo"&&!B0?"css":Z0,k0=(g0,m0,I8)=>D("button",{type:"button",className:"st-rp-tab"+(s8===g0?" is-active":""),onClick:()=>I0(g0),children:[z(k9,{name:I8,size:14}),m0]}),r0=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:[Q8?k0("photo","Photo","image"):D(Q0,{children:[k0("inspect","Inspect","sliders"),!H0&&k0("layers","Layers","layers"),k0("css","CSS","code"),B0?k0("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:s8==="photo"&&B0?z("div",{onKeyDown:s0,children:z(Om,{asset:B0.asset,ColorPicker:n90,StIcon:k9,onEdit:(g0)=>u?.(B0.asset,g0),onRemoveBackground:v,onRecordEdit:(g0,m0)=>n?.(B0.asset,g0,m0)},`${B0.asset}:${h??0}`)}):!N8&&!(s8==="layers"&&Y?.nodes?.length)?z("div",{className:"st-rp-empty",children:D("p",{children:["Press ",z(TJ,{children:"V"}),", then click an element to select it — or ",z(TJ,{children:"⌘"}),"-click straight from Browse."]})}):N8&&s8==="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:r0?Math.round(r0.x):"—",readOnly:!0,"aria-label":"x position"})]}),D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"Y"}),z("input",{value:r0?Math.round(r0.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:r0?Math.round(r0.w):"—",readOnly:!0,"aria-label":"width"})]}),D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"H"}),z("input",{value:r0?Math.round(r0.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(sL0,{el:N8})]}):s8==="layers"?D(Q0,{children:[D("div",{className:"st-rp-hd",children:["Layers",Y?.nodes?.length?"":" · ancestry"]}),Y?.nodes?.length?D(Q0,{children:[H8?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:L9,onKeyDown:u8,children:Y.nodes.map((g0,m0)=>z(a90,{node:g0,depth:0,selectedId:N8?.id,selectedIndex:N8?.index,collapsed:e0,hiddenOverride:Y8,onToggle:T8,onSelect:(I8)=>{U?.(I8),L9.current?.focus()},onHover:(I8)=>V?.(I8),onToggleVisibility:A9,onReorder:H8,onRowPointerDown:h0,dragState:a8,componentMap:W,lockedKeys:G,onToggleLock:Z,onRename:S0},`${g0.id}:${g0.index}`))}),a8?.target?z("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:a8.target.left,top:a8.target.y-1,width:a8.target.w}}):null,z("div",{className:"sr-only",role:"status","aria-live":"polite",children:$0})]}):N8&&Array.isArray(N8.dom_path)&&N8.dom_path.length?N8.dom_path.map((g0,m0)=>D("div",{className:"st-layer"+(m0===N8.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+m0*12},children:[z(k9,{name:"square",size:13}),g0]},m0)):z("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!N8.id&&s90(N8)?z(JD0,{el:N8,cfg:F,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:I,onSetArtboardKind:T,onSetArtboardPrint:R,onDuplicateArtboard:$}):z(cL0,{el:N8,cfg:F,onOptimistic:M,onRecordEdit:A,onReplaceMedia:E,onUndoRedo:C,mode:r,onSetMode:z0})})]})}function WD0(){let[J,X]=p.useState([]),[Q,Y]=p.useState(!1),W=p.useRef("push"),G=p.useRef(null),[Z,H]=p.useState("Design"),[K,U]=p.useState([]),[V,B]=p.useState(null),[N,F]=p.useState(null),M=p.useCallback((b)=>{W.current="push",F(b)},[]),[A,E]=p.useState(null),w=p.useRef(null);p.useEffect(()=>{w.current=A},[A]);let[O,I]=p.useState(null);p.useEffect(()=>{let b=Array.isArray(A)?A.length===1?A[0]:null:A,S=b&&typeof b.id==="string"?b.id:null;if(!S||!V){I(null);return}let 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)I(K0)}).catch(()=>{}),()=>d.abort()},[A,V]);let T=p.useRef(0),R=p.useRef([]),$=p.useCallback((b)=>{if(!b?.id||!b.file)return;for(let S of R.current)clearTimeout(S);R.current=[50,450,1200,2500,5000].map((S)=>setTimeout(()=>{let d=w.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))},[]),C=p.useRef([]),j=p.useCallback((b,S)=>{if(!b||!S)return;for(let d of C.current)clearTimeout(d);C.current=[50,450,1200,2500,5000].map((d)=>setTimeout(()=>{let X0=w.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))},[]),f=p.useRef(null),m=p.useRef(null),c=p.useRef(null);c.current=(b,S,d)=>{let X0=f.current;if(!X0||!X0.movedId)return;if(X0.staleSig!=null&&S===X0.staleSig)return;if(!function _0(l){return(l||[]).some((L0)=>L0.id===X0.movedId||_0(L0.children))}(b))return;f.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 o=p.useRef(null),x=p.useRef(null),h=p.useRef(null),u=p.useRef(!1),v=p.useRef(null),[n,e]=p.useState(null),[s,H0]=p.useState(null),r=p.useRef({canvas:null,at:0});p.useEffect(()=>{if(!V||!n)return;let b=Date.now(),S=r.current;if(S.canvas===V&&b-S.at<1500)return;r.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")H0(d.map);else H0(null)}).catch(()=>H0(null))},[V,n]);let[z0,i]=p.useState(!1),[q0,Z0]=p.useState(null),[I0,e0]=p.useState(null),J8=p.useRef(null);p.useEffect(()=>{let b=I0?.files?.progress;if(!b)return;let S=J8.current;if(J8.current=b.phase,S===null||S===b.phase)return;if(b.phase==="converged"&&(S==="seeding"||S==="paused"))BL("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);BL("Sync needs a decision",`${d} file${d===1?"":"s"} could not be sent. Open the Sync panel for the reason.`)}},[I0?.files?.progress]),p.useEffect(()=>{if(typeof document>"u")return;let b=I0?.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},[I0?.files?.progress]);let[Y8,P8]=p.useState(null),[S8,a8]=p.useState(null),[n0,$0]=p.useState(null),[w0,S0]=p.useState(null),[H8,X8]=p.useState(!1),[u8,y8]=p.useState(!1),[L9,h0]=p.useState(null),[T8,A9]=p.useState(""),[N8,B0]=p.useState(null),[Q8,s0]=p.useState(null),s8=p.useRef(null),[k0,r0]=p.useState(null),[g0,m0]=p.useState(0),[I8,O0]=p.useState(null),G8=A90("maude-sb-w",{min:200,max:420,def:252}),_8=A90("maude-rp-w",{min:260,max:480,def:304}),[V0,o0]=p.useState(null),k8=p.useRef(null);p.useEffect(()=>{if(!V0)return;let b=(d)=>{let X0=k8.current?.getBoundingClientRect();if(!X0)return;if(V0==="sb")G8.setW(d.clientX-X0.left);else _8.setW(X0.right-d.clientX)},S=()=>o0(null);return window.addEventListener("pointermove",b),window.addEventListener("pointerup",S),()=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",S)}},[V0,G8.setW,_8.setW]);let X9=p.useCallback((b)=>{clearTimeout(s8.current),s8.current=setTimeout(()=>{s0((S)=>S===b?null:S)},2500)},[]),[c0,x7]=p.useState({designRel:".design",cloud:void 0});p.useEffect(()=>{if(!Q8)return;let b=Q8,S=setTimeout(async()=>{let d="compile";try{if(!(await fetch(`${c0?.canvasOrigin||""}/_health`,{cache:"no-store"})).ok)d="server"}catch{d="server"}r0({path:b,kind:d}),s0((X0)=>X0===b?null:X0)},15000);return()=>clearTimeout(S)},[Q8,c0?.canvasOrigin]);let D9=!!c0.cloud,h7=!c0.cloud&&!!Y8?.credentialed,w8=D9||h7,Q9=w8?0:n0?.files?.length||0,d8=p.useRef(w8);d8.current=w8;let A0=!!c0.readOnly,U8=p.useCallback(()=>{fetch("/_config").then((b)=>b.json()).then((b)=>{let S=(b.designRoot||".design").replace(/^\/+|\/+$/g,"");x7((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(()=>{})},[]);p.useEffect(()=>{U8()},[U8]),p.useEffect(()=>{let b=!1;return fetch("/_sync-status").then((S)=>S.json()).then((S)=>{if(b||!S||S.linked===!1)return;e0(S)}).catch(()=>{}),()=>{b=!0}},[]),p.useEffect(()=>{if(w8){$0(null);return}let b=!1;return fetch("/_api/git/status").then((S)=>S.json()).then((S)=>{if(!b&&S)$0(S)}).catch(()=>{}),()=>{b=!0}},[w8]);let[C8,V9]=p.useState({}),[f9,d9]=p.useState(null),[x9,t]=p.useState(!1),[M0,E0]=p.useState("open"),[v0,Z8]=p.useState(lF0),[h8,t8]=p.useState(()=>{return D90(K90,"advanced")==="designer"?"designer":"advanced"});p.useEffect(()=>{try{localStorage.setItem(K90,JSON.stringify(h8))}catch{}},[h8]);let[v8,W9]=p.useState(null),[T9,s9]=p.useState(()=>EH(U90,!0)),[t9,LQ]=p.useState(()=>EH(z90,!1)),BJ=rm(),V7=BJ.update,dJ=BJ.state.sections,[DQ,$7]=p.useState(!1),[PH,M7]=p.useState(!1);p.useEffect(()=>{if(!G9())return;let b=Dh(()=>M7(!0));return()=>{b.then((S)=>S()).catch(()=>{})}},[]);let[dX,b9]=p.useState(!1),[VG,g7]=p.useState(!1),[Y4,W4]=p.useState(!1),[c7,G4]=p.useState(!1),[cX,q7]=p.useState(!1),{report:RJ}=lw(G9()),[X7,Q7]=p.useState(!1),[j6,CJ]=p.useState(!1),[iX,Z4]=p.useState(null),[zX,$J]=p.useState(null),[H4,MQ]=p.useState(!1),[KX,oX]=p.useState(!1),[i6,nX]=p.useState(!1),[LY,z4]=p.useState(!1),[o6,a]=p.useState(()=>D90(N90,rK)),[Y0,D0]=p.useState(()=>{try{let b=localStorage.getItem(F90);if(b==="separate"||b==="in-inspector")return b}catch{}return"separate"}),[b0,T0]=p.useState(!1),[t0,D8]=p.useState([]),[Z9,q9]=p.useState(0),[UX,SJ]=p.useState(!1),[P6,VX]=p.useState(!1),[qX,qG]=p.useState(!1),[BG,bJ]=p.useState(1),[S7,Y7]=p.useState(216),[i7,n6]=p.useState(null),[c8,e7]=p.useState([]),[r6,cJ]=p.useState([]),[K4,DY]=p.useState([]),[OQ,rX]=p.useState(0),NG=p.useRef(0);p.useEffect(()=>{NG.current=Z9},[Z9]);let[Q6,aX]=p.useState(null),FG=p.useRef(null);p.useEffect(()=>{FG.current=Q6},[Q6]);let Y6=p.useMemo(()=>aw(t0,{artboardId:[Q6,i7],total:OQ}),[t0,Q6,i7,OQ]),AQ=p.useRef(null);p.useEffect(()=>{AQ.current=Y6},[Y6]);let MY=p.useMemo(()=>PK(t0,Y6)?.fps||30,[t0,Y6]),[IH,_Q]=p.useState(null),[kH,J1]=p.useState(0),NJ=p.useCallback((b,S)=>{if(/concurrent edit|changed since it was read/i.test(S||""))x8("Timeline changed — reloaded, try again."),J1((d)=>d+1);else x8(`${b}: ${S||"failed"}`)},[]),[BX,LG]=p.useState(!1),[X1,TH]=p.useState(!1),[Q1,DG]=p.useState(!1),MG=p.useRef(BX);p.useEffect(()=>{if(MG.current=BX,BX){DG(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[BX]);let RH=p.useCallback(()=>{if(!MG.current||document.hidden)DG(!0),BL("Claude finished","Your assistant turn is ready in Maude.")},[]),CH=p.useRef(0),wQ=p.useCallback(()=>{if(!MG.current||document.hidden){DG(!0);let b=Date.now();if(b-CH.current<gF0)return;CH.current=b,BL("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[j5,sX]=p.useState("inspect"),[Y1,OY]=p.useState(null),tX=p.useRef({undo:[],redo:[]}),[OG,NX]=p.useState(0),[eX,U4]=p.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),$H=p.useRef(eX);p.useEffect(()=>{$H.current=eX;try{localStorage.setItem("maude-auto-open-inspector",eX?"1":"0")}catch{}},[eX]);let SH=p.useRef(!1);p.useEffect(()=>{SH.current=i6||x9||H8||u8||BX},[i6,x9,H8,u8,BX]);let AG=p.useRef({open:{},side:rK});AG.current={open:{tree:T9,layers:LY,inspector:i6,comments:x9,changes:H8,sync:u8,assistant:BX},side:o6};let V4=p.useCallback((b,S)=>{if(b==="tree")s9(S);else if(b==="layers")z4(S);else if(b==="inspector")nX(S);else if(b==="comments")t(S);else if(b==="changes")X8(S);else if(b==="sync")y8(S);else if(b==="assistant")LG(S)},[]),v5=p.useCallback((b)=>AG.current.side?.[b]||rK[b],[]),a6=p.useCallback((b)=>{let S=v5(b);V4(b,!0);for(let d of LT)if(d.id!==b&&v5(d.id)===S)V4(d.id,!1)},[V4,v5]),f5=p.useCallback((b)=>{if(AG.current.open?.[b])V4(b,!1);else a6(b)},[a6,V4]),FX=a6,v6=f5,_G=p.useCallback((b)=>{if(!$H.current)return;if(A0)return;if(!b||!b.id)return;if(SH.current)return;FX("inspector"),sX("css")},[FX,A0]),AY=p.useCallback(()=>T0((b)=>!b),[]),EQ=mm(DT),q4=Pm({enabled:c0.cloud===null||c0.exportLane==="remote"}),[bH,W1]=p.useState(!1),[J5,FJ]=p.useState(!1);p.useEffect(()=>{if(!G9())return;let b=!0;return _h().then((S)=>{if(!b)return;if(W1(!!S),!S&&!EH(H90,!1))FJ(!0)}).catch(()=>{}),()=>{b=!1}},[]);let _Y=p.useCallback(()=>{FJ(!1);try{localStorage.setItem(H90,"1")}catch{}},[]),[G1,yH]=p.useState(null);p.useEffect(()=>{if(!G9())return;let b;return kh((S)=>yH(S&&typeof S==="object"?S:{})).then((S)=>{b=S}).catch(()=>{}),()=>{try{b?.()}catch{}}},[]);let[LX,PQ]=p.useState(null),[wY,wG]=p.useState(()=>!EH(Z90,!1)),DX=p.useCallback((b)=>{PQ(Array.isArray(b)&&b.length?b:null)},[]),EG={setup:(b)=>{if(!b)return;if((b.canvas||b.requireSelection)&&K.length===0)a6("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [data-testid^="canvas-row-"]')?.click()}catch{}},80);if(b.inspector||b.tab||b.requireSelection)FX("inspector");if(b.tab)sX(b.tab);if(b.changes)FX("changes")}},B4=p.useCallback(()=>{wG(!1);try{localStorage.setItem(Z90,"1")}catch{}},[]),[X5,jH]=p.useState(()=>EH(B90,!0)),[EY,Z1]=p.useState(!1),[iJ,Q5]=p.useState(()=>EH(V90,!1)),[U0,vH]=p.useState(()=>EH(q90,!1)),[s6,N4]=p.useState(!1),[x5,I7]=p.useState(!1),[h5,Y5]=p.useState(0),[F4,PG]=p.useState(null),[IG,IQ]=p.useState(!1),L4=p.useRef(null),kQ=p.useRef(null),R0=p.useRef(new Map);p.useEffect(()=>{if(!c0?.canvasToken)return;let b=!1,S=null,d=0,X0=(_0)=>{clearTimeout(S);let l=rb(_0);d=Date.now()+l,S=setTimeout(K0,l)};async function K0(){let _0=null;try{let L0=await fetch("/_config",{cache:"no-store",credentials:"same-origin"});if(L0.ok)_0=(await L0.json())?.canvasToken}catch{}if(b)return;if(typeof _0!=="string"||!_0){clearTimeout(S),d=Date.now()+30000,S=setTimeout(K0,30000);return}nb(_0);let l=null;try{l=new URL(c0.canvasOrigin,location.href).origin}catch{}if(l)for(let L0 of R0.current.values())try{L0.contentWindow?.postMessage({dgn:"canvas-cap",t:_0},l)}catch{}X0(_0)}X0(c0.canvasToken);let F0=()=>{if(document.visibilityState==="visible"&&Date.now()>=d)K0()};return document.addEventListener("visibilitychange",F0),()=>{b=!0,clearTimeout(S),document.removeEventListener("visibilitychange",F0)}},[c0?.canvasToken,c0?.canvasOrigin]);let $8=p.useCallback((b)=>{let S=V?R0.current.get(V):null;if(!S||!S.contentWindow)return;try{S.contentWindow.postMessage(b,"*")}catch{}},[V]),PY=p.useRef(0),W8=p.useCallback(({format:b,artboardIds:S=null,scale:d=1,onProgress:X0,timeoutMs:K0=120000})=>new Promise((F0,_0)=>{let l=V?R0.current.get(V):null;if(!l||!l.contentWindow){_0(Error("no active canvas to capture"));return}let L0=l.contentWindow;PY.current+=1;let P0=`cap-${Date.now().toString(36)}-${PY.current}`,i0=!1,M8=(E7,p9)=>{if(i0)return;i0=!0,window.removeEventListener("message",L8),clearTimeout(q6),E7(p9)},L8=(E7)=>{if(E7.source!==L0)return;let p9=E7.data;if(!p9||p9.id!==P0)return;if(p9.dgn==="export-capture-progress")X0?.(p9.current,p9.total);else if(p9.dgn==="export-capture-done")M8(F0,Array.isArray(p9.items)?p9.items:[]);else if(p9.dgn==="export-capture-error")M8(_0,Error(p9.message||"capture failed"))},q6=setTimeout(()=>M8(_0,Error("capture timed out — the canvas did not answer")),K0);window.addEventListener("message",L8);try{L0.postMessage({dgn:"export-capture",id:P0,format:b,artboardIds:S,scale:d},"*")}catch(E7){M8(_0,E7)}}),[V]),g5=p.useCallback((b,S)=>$8({dgn:"photo-preview",asset:b,edit:S}),[$8]),z8=p.useCallback((b,S,d)=>{tX.current.undo.push({asset:b,before:S,after:d}),tX.current.redo.length=0},[]),D4=p.useCallback((b)=>{let S=b?tX.current.redo:tX.current.undo;if(!S.length)return!1;let d=S.pop();(b?tX.current.undo:tX.current.redo).push(d);let X0=(b?d.after:d.before)||{};return g5(d.asset,X0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(d.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(X0)}).catch(()=>{}),NX((K0)=>K0+1),!0},[g5]),kG=p.useCallback(async(b)=>{$8({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(() => (G90(),W90)),K0=await X0(d),F0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":K0.type||"image/png"},body:K0}),_0=await F0.json().catch(()=>({}));if(F0.ok&&_0.path)return{maskAsset:_0.path};return null}catch(S){return console.error("[photo] background removal failed",S),null}finally{$8({dgn:"photo-busy",asset:b,busy:!1})}},[$8]);p.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 W6=p.useRef({});W6.current={open:b0,comps:t0,frame:Z9,total:OQ,playing:UX,compId:Y6,muted:qX,loop:P6,sequences:c8,post:$8,canvas:V};let m5=p.useRef({undo:[],redo:[]}),G6=p.useCallback((b,S,d)=>{if(typeof S!=="number")return;if(m5.current.undo.push({canvas:b,seq:S,label:d}),m5.current.redo=[],m5.current.undo.length>50)m5.current.undo.shift()},[]),TG=p.useCallback((b)=>{let S=m5.current,d=b==="undo"?S.undo:S.redo,X0=b==="undo"?S.redo:S.undo,K0=W6.current.canvas,F0=-1;for(let l=d.length-1;l>=0;l--)if(d[l].canvas===K0){F0=l;break}if(F0<0){x8(b==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let _0=d[F0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:_0.canvas,seq:_0.seq,dir:b})}).then((l)=>l.json().catch(()=>({}))).then((l)=>{if(d.splice(F0,1),l?.ok)X0.push(_0),x8(`${b==="undo"?"Undid":"Redid"}: ${_0.label}`,!0);else x8(`${b==="undo"?"Undo":"Redo"} skipped: ${l?.error||"failed"}`)}).catch(()=>x8(`${b==="undo"?"Undo":"Redo"} failed: network error`))},[]),Z6=p.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},[]),IY=p.useCallback((b)=>{let S=W6.current.canvas;if(!S||S===o8)return;let d=FG.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=Z6(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(x8("Clip removed.",!0),K0.seq!=null)G6(S,K0.seq,"remove clip");_Q(null)}}).catch(()=>x8("Remove failed: network error"))},[Z6,G6]),TQ=p.useCallback((b,S,d)=>{let X0=W6.current.canvas;if(!X0||X0===o8)return;let K0=FG.current||void 0,F0=`/_api/comp-clips?canvas=${encodeURIComponent(X0)}${K0?`&artboardId=${encodeURIComponent(K0)}`:""}`;fetch(F0).then((_0)=>_0.json().catch(()=>({}))).then((_0)=>{let l=_0?.ok&&Array.isArray(_0.clips)?_0.clips:[],L0=b?.transition?l.find((P0)=>P0.kind==="transition"&&P0.stableId===b.stableId)||null:Z6(_0,b);if(!L0?.stableId)return null;return fetch("/_api/clip-edit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:X0,artboardId:K0,stableId:L0.stableId,contentHash:L0.contentHash,verb:S,...d})})}).then((_0)=>_0?_0.json():null).then((_0)=>{if(_0&&!_0.ok)console.warn("[clip-edit]",S,_0.error||"failed"),NJ(`${S} refused`,_0.error);else if(_0?.ok){let l={speed:"set speed","trim-in":"trim in-point",audio:"clip audio","detach-audio":"detach audio",framing:"crop clip",grade:"grade clip",transition:"edit transition",split:"split clip","insert-transition":"add transition","remove-transition":"remove transition","set-text":"edit text","to-overlay":"move to overlay layer","to-storyline":"move to storyline","layer-order":"reorder layers"};if(x8(`Applied: ${l[S]||S}.`,!0),_0.seq!=null)G6(X0,_0.seq,l[S]||S)}}).catch(()=>x8(`${S} failed: network error`))},[Z6,G6,NJ]),[RQ,kY]=p.useState(null),W5=p.useCallback((b,S="")=>new Promise((d)=>{kY({title:b,value:S,resolve:d})}),[]),u5=p.useCallback((b)=>{kY((S)=>{return S?.resolve?.(b),null})},[]),TY=p.useCallback((b,S)=>{let d=W6.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}}),x8("Comment added.",!0)},[]);W6.current.selected=IH,W6.current.setSelected=_Q,W6.current.removeClip=IY,W6.current.clipVerb=TQ,W6.current.addComment=TY,W6.current.askText=W5,p.useEffect(()=>{let b=(S)=>{let d=W6.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=PK(d.comps,d.compId)?.fps||30,_0=Math.max(1,d.total),l=(P0)=>{let i0=Math.max(0,Math.min(_0-1,Math.round(P0)));q9(i0),SJ(!1),d.post({dgn:"timeline-seek",frame:i0,id:d.compId})},L0=()=>{let P0=new Set([0,_0-1]);for(let i0 of d.sequences||[]){P0.add(i0.from);for(let M8 of i0.keyframes||[])P0.add(M8.from),P0.add(M8.to)}return[...P0].filter((i0)=>i0>=0&&i0<_0).sort((i0,M8)=>i0-M8)};if((S.metaKey||S.ctrlKey)&&(S.key==="z"||S.key==="Z")){S.preventDefault(),TG(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 P0=d.selected!=null?{stableId:d.selected}:null;if(!P0){let i0=d.sequences||[],M8=i0.find((L8)=>L8.series&&d.frame>=L8.from&&d.frame<L8.from+L8.duration)||i0.find((L8)=>d.frame>=L8.from&&d.frame<L8.from+L8.duration);if(M8?.stableId)P0={stableId:M8.stableId}}if(P0)d.clipVerb?.(P0,"split",{atFrame:d.frame});else x8("Nothing under the playhead to split.");return}if(S.key===" "||S.code==="Space")if(S.preventDefault(),d.playing)SJ(!1),d.post({dgn:"timeline-pause",id:d.compId});else SJ(!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(),l(d.frame+(S.shiftKey?F0:1));else if(S.key==="ArrowLeft")S.preventDefault(),l(d.frame-(S.shiftKey?F0:1));else if(S.key==="Home")S.preventDefault(),l(0);else if(S.key==="End")S.preventDefault(),l(_0-1);else if(S.key==="."){S.preventDefault();let P0=L0().find((i0)=>i0>d.frame);if(P0!=null)l(P0)}else if(S.key===","){S.preventDefault();let P0=L0().reverse().find((i0)=>i0<d.frame);if(P0!=null)l(P0)}};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[]),p.useEffect(()=>{D8([]),q9(0),SJ(!1),_Q(null),aX(null);let b=setTimeout(()=>$8({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(b)},[V,$8]);let[p5,RY]=p.useState(""),[CY,M4]=p.useState([]),[RG,$Y]=p.useState([]);p.useEffect(()=>{if(!b0||t0.length===0||!V||V===o8){RY(""),M4([]);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")RY(S.source)}).catch(()=>{}),()=>{b=!1}},[b0,t0,V,kH]),p.useEffect(()=>{if(!b0||!V||V===o8||!p5){M4([]),$Y([]);return}let b=!0,S=Q6||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:[];M4(K0.filter((F0)=>F0.kind==="sequence")),$Y(K0.filter((F0)=>F0.kind==="transition"))}).catch(()=>{}),()=>{b=!1}},[b0,V,p5,Q6,kH]),p.useEffect(()=>{if(!p5){e7([]),cJ([]),DY([]),rX(0);return}let b=i7??A?.artboardId??null,d=(b&&t0.find((F0)=>F0.artboardId===b||F0.id===b)||t0[0])?.durationInFrames||0,X0=Bm(p5,d,b);aX(X0.artboardId??b??null);let K0=X0.sequences.map((F0,_0)=>{let l=CY[_0];if(!l)return F0;return{...F0,stableId:l.stableId,contentHash:l.contentHash,mediaProps:l.mediaProps??null,placeholder:l.placeholder??null,mediaTag:l.mediaTag??F0.mediaTag,mediaSrc:l.mediaSrc??F0.mediaSrc,replaceable:!!(l.mediaCdId||l.mediaArrayRef),layers:Array.isArray(l.layers)?l.layers:[],hidden:!!l.hidden}});e7(K0),cJ(X0.audio||[]),DY(X0.transitions||[]),rX(X0.total)},[p5,CY,A,t0,i7]);let SY=p.useCallback(()=>{jH((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]),LJ=p.useCallback((b)=>{for(let S of R0.current.values())try{S.contentWindow.postMessage({dgn:"view-chrome",...b},"*")}catch{}},[]),bY=p.useCallback(()=>{Q5((b)=>{let S=!b;return LJ({minimap:S}),S})},[LJ]),yY=p.useCallback(()=>{vH((b)=>{let S=!b;return LJ({zoom:S}),S})},[LJ]),CG=p.useCallback(()=>{N4((b)=>{let S=!b;return LJ({present:S}),S})},[LJ]),O4=p.useCallback(()=>{N4(!1),LJ({present:!1})},[LJ]),$G=p.useCallback(()=>{if(!V||V===o8)return;I7((b)=>{let S=!b;return $8({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,$8]);p.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)PG(d)}).catch(()=>{}),()=>{b=!0}},[]),p.useEffect(()=>{if(!V||V===o8){Y5(0),I7(!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;Y5(d),I7(S?.overlays?.print===!0),_4(new Set(Array.isArray(S?.locked)?S.locked:[]))}).catch(()=>{if(!b)Y5(0),I7(!1),_4(new Set)}),()=>{b=!0}},[V]),p.useEffect(()=>{if(!V||V===o8||!i7)return;let b=setTimeout(()=>{$8({dgn:"request-layers",artboardId:i7})},250);return()=>clearTimeout(b)},[V,i7,$8]);let[A4,_4]=p.useState(()=>new Set),SG=p.useCallback((b)=>{if(!V||V===o8)return;_4((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(()=>{}),$8({dgn:"locked-set",locked:X0}),d})},[V,$8]);p.useEffect(()=>{if(!V||V===o8)return;$8({dgn:"locked-set",locked:[...A4]})},[A4,V,$8]),p.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",v0),localStorage.setItem(u90,v0)}catch{}for(let b of R0.current.values())try{b.contentWindow.postMessage({dgn:"theme",theme:v0},"*")}catch{}},[v0]),p.useEffect(()=>{try{localStorage.setItem(U90,T9?"1":"0")}catch{}},[T9]),p.useEffect(()=>{try{localStorage.setItem(z90,t9?"1":"0")}catch{}},[t9]),p.useEffect(()=>{try{localStorage.setItem(V90,iJ?"1":"0")}catch{}},[iJ]),p.useEffect(()=>{try{localStorage.setItem(q90,U0?"1":"0")}catch{}},[U0]),p.useEffect(()=>{try{localStorage.setItem(B90,X5?"1":"0")}catch{}},[X5]),p.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")Z8(S.theme);if(typeof S.minimap==="boolean")Q5(S.minimap);if(typeof S.zoom==="boolean")vH(S.zoom);if(typeof S.annotations==="boolean")jH(S.annotations);if(typeof S.autoOpenInspector==="boolean")U4(S.autoOpenInspector);if(S.panelSides&&typeof S.panelSides==="object")a({...rK,...S.panelSides});if(S.layersMode==="separate"||S.layersMode==="in-inspector")D0(S.layersMode)}).catch(()=>{}).finally(()=>{if(!b)Z1(!0)}),()=>{b=!0}},[]),p.useEffect(()=>{if(!EY)return;mF0({theme:v0,minimap:iJ,zoom:U0,annotations:X5,autoOpenInspector:eX,panelSides:o6,layersMode:Y0})},[EY,v0,iJ,U0,X5,eX,o6,Y0]),p.useEffect(()=>{try{localStorage.setItem(N90,JSON.stringify(o6))}catch{}},[o6]),p.useEffect(()=>{try{localStorage.setItem(F90,Y0)}catch{}},[Y0]);let jY=p.useRef(!1);p.useEffect(()=>{if(jY.current||!BJ.ready||!Q||!J.length)return;jY.current=!0;let b=om(J);V7((S)=>nm(S,b))},[BJ.ready,Q,J,V7]);let bG=p.useCallback((b)=>V7((S)=>im(S,b)),[V7]),yG=p.useMemo(()=>({isOpen:(b)=>dm(BJ.state,b),setOpen:(b,S)=>V7((d)=>kE(d,b,S))}),[BJ.state,V7]),w4=p.useCallback(()=>{Z8((b)=>b==="dark"?"light":"dark")},[]),E4=p.useRef(null),y9=p.useCallback(()=>E4.current?.reload()??Promise.resolve(),[]);p.useEffect(()=>{let b=sb({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:nF0(F0.paths,F0.stripPrefix,F0.dirs)}));return{data:X0,built:K0}},apply:({data:S,built:d})=>{H(S.project||"Design"),X(d),Y(!0),x7((X0)=>({...X0,canvasDesignSystems:S.canvasDesignSystems??{},canvasKinds:S.canvasKinds??{}}))},onError:(S)=>console.error("failed to load tree",S)});return E4.current=b,y9(),()=>{E4.current=null,b.dispose()}},[y9]);let G5=p.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){B0(X0);let K0=await fetch(`/_system-data?ds=${encodeURIComponent(X0.defaultDesignSystem)}`);if(K0.ok)B0(await K0.json());return}B0(X0)}catch(S){console.error("failed to load system-data",S)}},[]),vY=p.useCallback(async()=>{try{let S=await(await fetch("/_comments-all")).json();V9(S||{})}catch(b){console.error("failed to load comments",b)}},[]);p.useEffect(()=>{vY()},[vY]);let fY=p.useRef(()=>{});p.useEffect(()=>{let b=null,S=!1;function d(){let X0=location.protocol==="https:"?"wss:":"ws:",K0=new WebSocket(X0+"//"+location.host+"/_ws");kQ.current=K0,K0.addEventListener("open",()=>{if(i(!0),S)U8();S=!0,clearInterval(b),b=setInterval(()=>{if(K0.readyState===WebSocket.OPEN)K0.send('{"type":"ping"}')},25000)}),K0.addEventListener("close",()=>{i(!1),clearInterval(b),setTimeout(d,1000)}),K0.addEventListener("error",()=>{}),K0.addEventListener("message",(F0)=>{try{let _0=JSON.parse(F0.data);if(_0.type==="snapshot"&&_0.state)E((l)=>x90(_0.state.selected,l));else if(_0.type==="selected"){if(Date.now()-T.current<2000)return;let l=_0.selected,L0=Array.isArray(l)?l[0]:l,P0=w.current,i0=Array.isArray(P0)?P0[0]:P0;if(E((M8)=>x90(l,M8)),L0?.id&&L0.file&&(!i0||i0.id!==L0.id||i0.file!==L0.file))$(L0)}else if(_0.type==="comments"&&typeof _0.file==="string")V9((l)=>({...l,[_0.file]:_0.comments||[]}));else if(_0.type==="ai-activity"&&typeof _0.file==="string"){if(IQ(!0),L4.current)clearTimeout(L4.current);L4.current=setTimeout(()=>IQ(!1),8000);for(let l of R0.current.values())try{l.contentWindow.postMessage({dgn:"ai-activity",file:_0.file,entry:_0.entry},"*")}catch{}}else if(_0.type==="export:job"&&_0.payload)q4.upsert(_0.payload);else if(_0.type==="sync:status"&&_0.payload)e0(_0.payload);else if(_0.type==="canvas-list-update")y9(),fY.current(_0.payload);else if(_0.type==="config-updated")U8();else if(_0.type==="acp-focus"){if(G9())FX("assistant")}else if(_0.type==="git-status"&&_0.payload){if(!d8.current)$0(_0.payload)}else if(_0.type==="git-lifecycle"&&_0.payload){Z0(_0.payload);for(let l of R0.current.values())try{l.contentWindow.postMessage({dgn:"git-lifecycle",payload:_0.payload},"*")}catch{}}}catch{}})}return d(),()=>{if(clearInterval(b),kQ.current)kQ.current.close()}},[y9,U8]);function b7(b){let S=kQ.current;try{if(S&&S.readyState===1)S.send(JSON.stringify(b))}catch{}}let DJ=p.useCallback(async()=>{if(d8.current)return;try{let b=await fetch("/_api/git/status");if(b.ok)$0(await b.json())}catch{}},[]),yJ=p.useCallback(async()=>{if(d8.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)S0({remoteAhead:!!S.remoteAhead,behind:S.behind||0})}catch{}},[]),MJ=p.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?"}}},[]),jG=p.useCallback(async(b,S)=>{let d=await MJ("/_api/git/commit",{message:b,files:S});if(d.ok)await DJ();return d},[MJ,DJ]),xY=p.useCallback(async(b)=>{let S=await MJ("/_api/git/discard",{files:b});if(S.ok)await DJ();return S},[MJ,DJ]),vG=p.useCallback(async()=>{let b=await MJ("/_api/git/push",{});if(b.ok)await DJ(),yJ();return b},[MJ,DJ,yJ]),hY=p.useCallback(async()=>{let b=await MJ("/_api/git/pull",{});if(b.ok)await DJ(),yJ();if(b.conflict&&Array.isArray(b.files)&&b.files.length)h0({file:b.files[0],conflict:!0});return b},[MJ,DJ,yJ]),fG=p.useCallback(async(b)=>{let S=await MJ("/_api/git/resolve",{choice:b});if(S.ok)await DJ(),yJ();return S},[MJ,DJ,yJ]),P4=p.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[]}},[]),[xG,hG]=p.useState(null),gG=p.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 hG({branch:X0.branch??null,project:X0.project??null,hubHost:X0.hubHost??null}),X0.entries||[]}catch{return null}},[]),[mG,H1]=p.useState(!1),[z1,K1]=p.useState(0),uG=p.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((_0)=>_0.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}},[]),pG=/^r\d+$/.test(L9?.beforeSha||""),U1=p.useCallback(async(b)=>{if(!pG)return P4(b);let S=await uG(b);return Array.isArray(S)?S:[]},[pG,P4,uG]),fH=p.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 K1((K0)=>K0+1),X0;return{ok:!1,error:X0?.error}},[]),V1=p.useMemo(()=>{let b={modified:"M",added:"A",deleted:"D",untracked:"U"},S=new Map;if(w8)return S;for(let d of n0?.files||[])S.set(d.path,b[d.status]);return S},[n0,w8]);p.useEffect(()=>{if(w8){S0(null);return}if(n0?.repo===!1)return;yJ();let b=setInterval(yJ,H8?60000:120000);return()=>clearInterval(b)},[w8,n0?.repo,H8,yJ]);let V6=p.useCallback((b,{reveal:S=!0}={})=>{if(S&&b&&b!==o8)V7((d)=>HF(d,J,b));if(W.current="push",d9(null),F(null),b===V)return;if(U((d)=>{for(let X0 of d)if(X0.path!==b)R0.current.delete(X0.path);return[{path:b}]}),B(b),r0(null),O0(null),b!==o8)s0(b)},[V,J,V7]),I4=p.useCallback((b,S="push")=>{let d=J.flatMap((X0)=>X0.paths||[]).find((X0)=>bW(X0,c0.designRel)===b);if(d&&y5.test(d))V6(d,{reveal:!1});else if(d&&EL(Q4(d)))M(d);else U([]),B(null),F(null),P5({title:"Not here yet",description:`${b} is not in this project (not synced yet?)`,kind:"info"});W.current=S},[J,c0.designRel,V6,M]),xH=p.useRef(!1);p.useEffect(()=>{if(!Q||c0.cloud===void 0||xH.current)return;xH.current=!0;let b=$V(location,c0.designRel);if(b)I4(b,"none")},[Q,c0.cloud,c0.designRel,I4]),p.useEffect(()=>{if(!Q||c0.cloud===void 0)return;let b=()=>{let S=$V(location,c0.designRel);if(S)I4(S,"none");else W.current="none",U([]),B(null),F(null)};return window.addEventListener("popstate",b),()=>window.removeEventListener("popstate",b)},[Q,c0.cloud,c0.designRel,I4]),p.useEffect(()=>{let b=N||(V===o8?null:V);if(b===G.current)return;G.current=b;let S=bW(b,c0.designRel);if(W.current!=="none"&&$V(location,c0.designRel)!==S)history[S?"pushState":"replaceState"](S?{open:S}:null,"",Ug(location,S));W.current="push"},[V,N,c0.designRel]);let gY=N||(V===o8?null:V),lG=c0.cloud?"cloud":G9()?"native":"local",hH=(b)=>Ng({rel:bW(b,c0.designRel),shell:lG,location,linkedHubUrl:Y8?.url,project:c0.cloud?Z:S8,localUrl:location.origin}),gH=(b=gY)=>{let S=bW(b,c0.designRel);if(S)Z4({path:b,rel:S,label:Q4(b)})},q1=p.useCallback((b)=>{if(r0(null),O0(null),U8(),m0((S)=>S+1),b&&b!==o8)s0(b)},[U8]),dG=p.useRef(!1);p.useEffect(()=>{if(dG.current)return;if(!c0.cloud)return;if(new URLSearchParams(location.search).has("open")){dG.current=!0;return}if(K.length>0)return;if(!J.length)return;let b=null;for(let S of J){for(let d of S.paths||[]){if(!y5.test(d))continue;if(/(^|\/)system\//.test(d))continue;b=d;break}if(b)break}if(!b)return;dG.current=!0,V6(b,{reveal:!1})},[c0.cloud,J,K.length,V6]);let CQ=p.useCallback((b)=>{let S=typeof b==="string"?b:void 0;if(S)G5(S);else if(!N8)G5();V6(o8)},[N8,G5,V6]);p.useEffect(()=>{b7({type:"tabs",tabs:K.map((b)=>b.path).filter((b)=>b!==o8)})},[K]),p.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 mY=p.useCallback((b)=>{U((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)B(null);else B(X0[Math.max(0,d-1)].path);return X0}),R0.current.delete(b),s0((S)=>S===b?null:S)},[V]);fY.current=(b)=>{if(!b?.rel)return;let S=(c0?.designRel||c0?.designRoot||".design").replace(/^\/+|\/+$/g,""),d=`${S}/${b.rel}`;if(b.action==="removed")mY(d);else if(b.action==="moved"&&b.fromRel){let X0=`${S}/${b.fromRel}`;U((K0)=>K0.map((F0)=>F0.path===X0?{...F0,path:d}:F0)),B((K0)=>K0===X0?d:K0),s0((K0)=>K0===X0?null:K0),R0.current.delete(X0)}};let l5=p.useCallback(()=>{if(!V||V===o8){if(V===o8)G5();return}let b=R0.current.get(V);if(b)b.src=b.src},[V,G5]),mH=p.useCallback(()=>y9(),[y9]),[B1,uH]=p.useState(!1),cG=p.useRef(!1),iG=p.useCallback(async()=>{if(cG.current)return;cG.current=!0,uH(!0);try{await Promise.all([y9(),new Promise((b)=>setTimeout(b,550))])}finally{cG.current=!1,uH(!1)}},[y9]);p.useEffect(()=>{let b=null,S=()=>{if(b)clearTimeout(b);b=setTimeout(()=>{b=null,mH()},150)};return window.addEventListener("focus",S),()=>{if(window.removeEventListener("focus",S),b)clearTimeout(b)}},[mH]);let N1=p.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 y9(),V6(d.file),{ok:!0,file:d.file}}catch(S){return{ok:!1,error:S instanceof Error?S.message:"network error"}}},[y9,V6]),pH=p.useCallback(async()=>{let b=await W5("New video name");if(!b)return;let d=(await W5("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 W5("Frames per second","30"))||30));try{let _0=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})}),l=await _0.json().catch(()=>({}));if(!_0.ok||!l.ok){x8(`New video failed: ${l.error||`error ${_0.status}`}`);return}await y9(),V6(l.file),T0(!0),x8("New video created — drop clips on the timeline to start the cut.",!0)}catch(_0){x8(`New video failed: ${_0 instanceof Error?_0.message:"network error"}`)}},[y9,V6,W5]),F1=p.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 l=new DOMParser().parseFromString(S,"image/svg+xml");for(let L0 of l.querySelectorAll('[data-tool="mediaref"]')){let P0=L0.getAttribute("data-src");if(!P0)continue;d.push({src:P0,mediaKind:L0.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=`${X4(Q4(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})}),_0=await F0.json().catch(()=>({}));if(!F0.ok||!_0.ok){window.alert(`Assemble failed: ${_0.error||`error ${F0.status}`}`);return}await y9(),V6(_0.file)}catch(b){window.alert(`Assemble failed: ${b instanceof Error?b.message:"network error"}`)}},[V,y9,V6]),oG=p.useCallback(({accept:b,resolveTarget:S})=>{let d=V,X0=Q6||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 _0=K0.files?.[0];if(F0(),!_0)return;let l=`/_api/comp-clips?canvas=${encodeURIComponent(d)}${X0?`&artboardId=${encodeURIComponent(X0)}`:""}`;fetch(l).then((L0)=>L0.json().catch(()=>({}))).then((L0)=>{let P0=S(L0);if(!P0)return x8("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":_0.type||"application/octet-stream"},body:_0}).then((i0)=>i0.json().catch(()=>({}))).then((i0)=>{if(!i0?.path)return x8(`Upload failed: ${i0?.error||"unknown error"}`),null;if(P0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:d,arrayName:P0.arrayRef.arrayName,index:P0.arrayRef.index,field:P0.arrayRef.field,value:i0.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:d,id:P0.cdId,attr:"src",value:i0.path})})})}).then((L0)=>L0?L0.json():null).then((L0)=>{if(L0&&!L0.ok)x8(`Replace refused: ${L0.error||"failed"}`);else if(L0&&L0.ok){if(x8("Media replaced.",!0),L0.seq!=null)G6(d,L0.seq,"replace media")}}).catch(()=>x8("Replace failed: network error"))}),K0.click()},[V,Q6,G6]),L1=p.useCallback(async(b,S)=>{if(!window.confirm(`Move “${S}” to trash?
|
|
5683
|
+
`).length," lines, paths & secrets scrubbed)",H?.process?` + server memory (${Math.round(H.process.rssBytes/1048576)} MB)`:""," ","—"," ",D("details",{className:"rb-details",children:[z("summary",{children:"view"}),z("pre",{className:"rb-log",children:H.logs.serverLogTail})]})]})]}):null,G9()&&B.length>0&&D("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.crashLogs,onChange:(u)=>M({...F,crashLogs:u.target.checked})}),D("span",{children:["Crash logs (",B.length,") — ",z("code",{children:B.map((u)=>u.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:[I?.issueUrl?D("p",{children:["Thank you — your report is filed as"," ",D("button",{type:"button",className:"rb-link","data-testid":"report-bug-issue-link",onClick:()=>{if(G9())EV(I.issueUrl).catch(()=>navigator.clipboard?.writeText(I.issueUrl));else window.open(I.issueUrl,"_blank","noopener")},children:["report #",I.issueNumber]})," ","on the public Maude issue tracker. Screenshots and logs stay in a private repository only maintainers can open — the issue links to them."]}):D("p",{children:["The bundle is saved locally",I?.fallbackDir?D(Q0,{children:[" ","at ",z("code",{children:I.fallbackDir})]}):null," ","and a prefilled GitHub issue was opened — attach the bundle files there."]}),z("footer",{className:"rb-actions",children:z("button",{type:"button",className:"st-btn rb-primary",onClick:m,children:"Done"})})]}),Y==="fallback"&&D(Q0,{children:[z("p",{className:"rb-error","data-testid":"report-bug-error",children:R}),z("p",{className:"rb-hint",children:"You can save the report locally instead and file it on GitHub yourself — the prefilled issue carries the text; screenshots stay on this machine unless you attach them by hand."}),D("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("preview"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary",onClick:x,children:"Save locally & open GitHub"})]})]})]})]})})}var PJ=b8(i8(),1);function fm(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 xm(J,X){let Q=fm(J),Y=fm(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 hm(J,X){if(!Array.isArray(J))return[];return J.filter((Q)=>Q&&(Q.version==null||xm(Q.version,X)))}function gm(J,X){let Q=X;if(Array.isArray(J)){for(let Y of J)if(Y&&Y.version&&xm(Y.version,Q))Q=Y.version}return Q}var PE="mdcc-whatsnew-seen",IE="mdcc-whatsnew-toast-dismissed";function _V0(J){return typeof J==="string"&&/^https?:\/\//i.test(J)}function wV0(J){try{let X=localStorage.getItem(PE);if(X)return X;localStorage.setItem(PE,J)}catch{}return J}function EV0(){try{return localStorage.getItem(IE)}catch{return null}}function mm(J){let[X,Q]=PJ.useState([]),[Y,W]=PJ.useState(J),[G,Z]=PJ.useState(()=>wV0(J)),[H,K]=PJ.useState(()=>EV0()),[U,V]=PJ.useState(!1);PJ.useEffect(()=>{let O=!1,I=()=>{fetch("/_api/whats-new").then(($)=>$.json()).then(($)=>{if(O)return;if(Q(Array.isArray($?.entries)?$.entries:[]),typeof $?.version==="string")W($.version)}).catch(()=>{})};I();let T=()=>I(),R=()=>{if(document.visibilityState==="visible")I()};return window.addEventListener("focus",T),document.addEventListener("visibilitychange",R),()=>{O=!0,window.removeEventListener("focus",T),document.removeEventListener("visibilitychange",R)}},[]);let B=hm(X,G),N=B.length>0&&H!==Y&&!U,F=B[0]??null,M=PJ.useCallback(()=>{let O=gm(X,Y);Z(O),K(Y);try{localStorage.setItem(PE,O),localStorage.setItem(IE,Y)}catch{}},[X,Y]),A=PJ.useCallback(()=>{K(Y);try{localStorage.setItem(IE,Y)}catch{}},[Y]),E=PJ.useCallback(()=>V(!0),[]),w=PJ.useCallback(()=>{V(!1),M()},[M]);return{entries:X,unseen:B,feedVersion:Y,panelOpen:U,openPanel:E,closePanel:w,showToast:N,toastEntry:F,dismissToast:A,markAllSeen:M}}function um({wn:J}){let X=`whats-new-${J.feedVersion}`;return PJ.useEffect(()=>{if(!J.showToast||!J.toastEntry){yW(X);return}P5({id:X,group:"whats-new",kind:"info",duration:1e4,title:`What's new${J.toastEntry.version?` · v${J.toastEntry.version}`:""} — ${J.toastEntry.title}`,description:J.toastEntry.summary,action:{label:J.unseen.length>1?`See all (${J.unseen.length})`:"Details",onClick:J.openPanel},onDismiss:J.dismissToast})},[X,J.showToast,J.toastEntry,J.unseen.length,J.openPanel,J.dismissToast]),PJ.useEffect(()=>()=>yW(X),[X]),null}function pm({wn:J,onStartTour:X}){let{panelOpen:Q,closePanel:Y}=J;if(PJ.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}),_V0(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 s5=b8(i8(),1),PV0=Object.freeze({dirs:[],sections:{}}),IV0="mdcc-sections-expanded",kV0=250,TV0=3000;function dm(J,X){return!!X&&J.dirs.includes(X)}function RV0(J,X){return J.sections[X]===!0}function kE(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 cm(J,X,Q){if(!X||J.sections[X]===!!Q)return J;return{...J,sections:{...J.sections,[X]:!!Q}}}function im(J,X){return cm(J,X,!RV0(J,X))}function CV0(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 HF(J,X,Q,{includeSelf:Y=!1}={}){if(!Q)return J;let W=CV0(X,Q);if(!W)return J;let G=cm(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 V=0;V<K;V++)U=`${U}/${H[V]}`,G=kE(G,U,!0);return G}function TE(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 om(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 nm(J,X){let Q=J.dirs.filter((Y)=>X.has(Y));return Q.length===J.dirs.length?J:{...J,dirs:Q}}function lm(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 $V0(){try{let J=JSON.parse(localStorage.getItem(IV0)||"null");return J&&typeof J==="object"&&!Array.isArray(J)?J:null}catch{return null}}function rm({fetchImpl:J}={}){let[X,Q]=s5.useState(PV0),[Y,W]=s5.useState(!1),G=J||((...U)=>fetch(...U)),Z=s5.useRef(G);Z.current=G,s5.useEffect(()=>{let U=!1,V=typeof AbortController==="function"?new AbortController:null,B=setTimeout(()=>V?.abort(),TV0);return Z.current("/_api/tree-state",V?{signal:V.signal}:void 0).then((N)=>N.ok?N.json():Promise.reject(Error(`HTTP ${N.status}`))).then((N)=>{if(U)return;let F=lm(N);if(!(N&&typeof N==="object"&&N.sections&&Object.keys(N.sections).length)){let A=$V0();if(A)F=lm({...F,sections:A})}Q(F)}).catch(()=>{}).finally(()=>{if(clearTimeout(B),!U)W(!0)}),()=>{U=!0,clearTimeout(B)}},[]);let H=s5.useRef(!0);s5.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{}},kV0);return()=>clearTimeout(U)},[Y,X]);let K=s5.useCallback((U)=>Q((V)=>U(V)),[]);return{state:X,ready:Y,update:K}}var K7=({as:J,size:X=14})=>z(J,{size:X,strokeWidth:1.75,style:{display:"block"}}),Z90="mdcc-usage-tour-seen",H90="mdcc-collab-tour-seen",o8="__system__",u90="mdcc-theme",z90="mdcc-show-hidden",K90="maude-cp-mode",U90="mdcc-sidebar-open",V90="mdcc-minimap-visible",q90="mdcc-zoomctl-visible",B90="mdcc-annotations-visible";var gF0=30000;function mF0(J){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(J)}).catch(()=>{})}catch{}}var LT=[{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"}],rK={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",sync:"right",assistant:"right"},N90="mdcc-panel-sides",F90="mdcc-layers-mode";function L90({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]||(LT.find((U)=>U.id===K)||{}).label||K},K))}),Z]})}var y5=/\.(tsx|html?)$/i,uF0=[[/\.md$/i,"markdown"],[/\.(css|json|txt|ya?ml)$/i,"text"],[/\.(svg|png|jpe?g|gif|webp|avif)$/i,"image"],[/\.(mp4|webm|mov)$/i,"video"],[/\.(mp3|wav|ogg|m4a)$/i,"audio"],[/\.(woff2?|ttf|otf)$/i,"font"]];function EL(J){for(let[X,Q]of uF0)if(X.test(J))return Q;return null}function Aq(J){return J.replace(/^\.[^/]+\//,"").replace(y5,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}function pF0(J){let X=[];return function Q(Y){for(let W of Y||[])X.push(W?.id??""),Q(W?.children)}(J),X.join(",")}var DT="1.5.2";function BL(J,X){let Q=()=>{try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(J,{body:X})}catch{}};if(G9()){_7("send_notification",{title:J,body:X}).catch(Q);return}Q()}function lF0(){if(typeof window>"u")return"dark";try{let J=localStorage.getItem(u90);if(J==="light"||J==="dark")return J}catch{}return"dark"}function EH(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 D90(J,X){if(typeof window>"u")return X;try{let Q=localStorage.getItem(J);return Q?JSON.parse(Q):X}catch{return X}}function dF0(){return!1}var cF0=[];function Q4(J){return J.split("/").pop()}function x8(J,X=!1,Q){P5({title:J,kind:X?"success":"error",action:Q})}var M90="maude-mode-hint-seen";function LL(J=!1){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(M90)==="1")return}catch{return}if(LL.active)return;LL.active=!0;let X=()=>{LL.active=!1;try{localStorage.setItem(M90,"1")}catch{}document.removeEventListener("keydown",Q,!0)},Q=(Y)=>{if((Y.key==="v"||Y.key==="V")&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey)yW("mode-hint"),X()};if(J)document.addEventListener("keydown",Q,!0);P5({id:"mode-hint",title:J?"Your mock is live":"You’re in Edit",description:J?"Click things to try it. Press V to select & inspect.":"Click selects, like Figma. Switch to Preview in the toolbar to use the live mock.",onDismiss:X})}function X4(J){return J.replace(y5,"")}function iF0(J){return J.replace(y5,"")}function oF0(J){let X=new Map;for(let G of J){if(!y5.test(G.name))continue;let Z=iF0(G.name);if(!X.has(Z)||/\.tsx$/i.test(G.name))X.set(Z,G)}let Q=new Map,Y=[];for(let G of J){if(y5.test(G.name))continue;let Z=null;for(let H of X.keys()){if(G.name===H)continue;if(G.name.startsWith(`${H}.`)){if(!Z||H.length>Z.length)Z=H}}if(Z){let H=Q.get(Z)||[];H.push(G),Q.set(Z,H)}else Y.push(G)}let W=[];for(let[G,Z]of X){let H=(Q.get(G)||[]).sort((K,U)=>K.name.localeCompare(U.name));W.push({primary:Z,sidecars:H,orphan:!1})}return W.sort((G,Z)=>G.primary.name.localeCompare(Z.primary.name)),Y.sort((G,Z)=>G.name.localeCompare(Z.name)),{canvases:W,orphans:Y.map((G)=>({primary:G,sidecars:[],orphan:!0}))}}function nF0(J,X,Q){let Y={};for(let W of Q||[]){let Z=(W.startsWith(X)?W.slice(X.length).replace(/^\/+/,""):W).split("/").filter(Boolean),H=Y;for(let K of Z)H=H[K]=H[K]||{};H._files=H._files||[]}for(let W of J){let Z=(W.startsWith(X)?W.slice(X.length).replace(/^\/+/,""):W).split("/"),H=Y;for(let K=0;K<Z.length;K++){let U=Z[K];if(K===Z.length-1)H._files=H._files||[],H._files.push({name:U,path:W});else H[U]=H[U]||{},H=H[U]}}return Y}function p90(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=p90(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 DL(J){return(J||[]).filter((X)=>X.status!=="resolved").length}function rF0(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 l90(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 OL({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 aF0={"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 sF0({open:J,onClose:X,actions:Q}){let[Y,W]=p.useState(""),[G,Z]=p.useState(0),H=p.useRef(null);p.useEffect(()=>{if(J)W(""),Z(0)},[J]),p.useEffect(()=>{H.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[G]);let K=p.useMemo(()=>JB(Q,Y),[Y,Q]);if(p.useEffect(()=>{if(G>=K.length)Z(0)},[K.length,G]),!J)return null;let U=(V)=>{X(),V.run()};return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(V)=>{if(V.target===V.currentTarget)X()},children:D("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[D("div",{className:"st-pal-search",children:[z(k9,{name:"search",size:18}),z("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(V)=>W(V.target.value),onKeyDown:(V)=>{if(V.key==="Escape")V.preventDefault(),X();else if(V.key==="ArrowDown")V.preventDefault(),Z((B)=>Math.min(K.length-1,B+1));else if(V.key==="ArrowUp")V.preventDefault(),Z((B)=>Math.max(0,B-1));else if(V.key==="Enter"){V.preventDefault();let B=gb(Q,Y,V.currentTarget.value,G);if(B)U(B)}}}),z(TJ,{children:"⌘K"})]}),z("div",{className:"st-pal-list",ref:H,children:K.length===0?z("div",{className:"st-pal-empty",children:"No matching command."}):K.map((V,B)=>{let N=V.group&&(B===0||K[B-1].group!==V.group)?z("div",{className:"st-pal-group",children:V.group},"g-"+V.group):null;return D(Q0,{children:[N,D("button",{type:"button",className:"st-pal-item"+(B===G?" is-active":""),onMouseEnter:()=>Z(B),onClick:()=>U(V),children:[z("span",{className:"st-pal-icon",children:z(k9,{name:V.icon,size:15})}),z("span",{className:"st-pal-label",children:V.label}),V.kbd?z("span",{className:"st-pal-kbd",children:z(TJ,{children:V.kbd})}):null]})]},V.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:aF0[J]})}function tF0(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 O90({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 TJ({children:J}){return z("span",{className:"kbd",children:J})}function A90(J,{min:X,max:Q,def:Y}){let W=p.useCallback((K)=>Math.min(Q,Math.max(X,K)),[X,Q]),[G,Z]=p.useState(()=>{try{let K=parseInt(localStorage.getItem(J)||"",10);return Number.isFinite(K)?W(K):Y}catch{return Y}});p.useEffect(()=>{try{localStorage.setItem(J,String(G))}catch{}},[J,G]);let H=p.useCallback((K)=>Z((U)=>W(typeof K==="function"?K(U):K)),[W]);return{w:G,setW:H,min:X,max:Q,def:Y}}function _90({label:J,size:X,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:K,def:U}=X,V=W==="rtl"?-1:1;return z("div",{className:"st-grip"+(Y?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":J,"aria-valuemin":H,"aria-valuemax":K,"aria-valuenow":Math.round(G),onPointerDown:Q,onDoubleClick:()=>Z(U),onKeyDown:(B)=>{let N=B.shiftKey?24:8;if(B.key==="ArrowRight")B.preventDefault(),Z((F)=>F+N*V);else if(B.key==="ArrowLeft")B.preventDefault(),Z((F)=>F-N*V);else if(B.key==="Home")B.preventDefault(),Z(H);else if(B.key==="End")B.preventDefault(),Z(K)},children:D("svg",{className:"st-grip-dots",viewBox:"0 0 6 18","aria-hidden":"true",children:[z("circle",{cx:"3",cy:"3",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"9",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"15",r:"1.1",fill:"currentColor"})]})})}var BT=[{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}],w90={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},eF0=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],Lq=[{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}],JL0="2x",E90=[{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}],XL0="auto",P90=[{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."}],QL0="keep",YL0={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 WL0(J){let X=String(J||"").split(".").pop()?.toLowerCase();return YL0[X]||"application/octet-stream"}function GL0({designRel:J,onPick:X,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[Z,H]=p.useState(null),[K,U]=p.useState(!1),[V,B]=p.useState(null),[N,F]=p.useState(()=>new Set),[M,A]=p.useState({}),[E,w]=p.useState(W?"artboard":"annotation");p.useEffect(()=>{let x=!0;return fetch("/_api/assets").then((h)=>h.json()).then((h)=>{if(!x)return;let u=h.ok?h.assets:[];H(u),A((v)=>{let n={...v};for(let e of u)n[e.path]=e.kind;return n})}).catch(()=>x&&H([])),()=>{x=!1}},[]),p.useEffect(()=>{let x=(h)=>{if(h.key==="Escape")h.stopPropagation(),Q()};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[Q]);let O=Array.from(N).some((x)=>(M[x]||"image")!=="image"),I=!W||O,T=!W?"No artboard on this canvas":O?"Video/audio can only be added as annotations":"";p.useEffect(()=>{if(I&&E==="artboard")w("annotation")},[I,E]);let R=(x)=>{F((h)=>{let u=new Set(h);if(u.has(x))u.delete(x);else u.add(x);return u})},$=async(x)=>{let h=await fetch("/_api/asset",{method:"POST",headers:{"content-type":x.type||"application/octet-stream"},body:x}),u=await h.json().catch(()=>({}));if(h.ok&&u.path)return{ok:!0,path:u.path};return{ok:!1,error:u.error||`upload failed (HTTP ${h.status})`}},C=async(x)=>{if(!x)return;U(!0),B(null);let h=await $(x);if(U(!1),h.ok)X(h.path);else B(h.error)},j=(x)=>{if(typeof x==="string"&&x.startsWith("video/"))return"video";if(typeof x==="string"&&x.startsWith("audio/"))return"audio";return"image"},f=async(x)=>{if(!x.length)return;U(!0),B(null);let h=await Promise.all(x.map((n)=>$(n).then((e)=>({...e,file:n}))));U(!1);let u=h.filter((n)=>n.ok),v=h.length-u.length;if(v>0)B(`${v} of ${h.length} uploads failed`);if(u.length)A((n)=>{let e={...n};for(let s of u)e[s.path]=j(s.file.type);return e}),F((n)=>{let e=new Set(n);for(let s of u)e.add(s.path);return e})},m=async()=>{U(!0),B(null);try{if(Y){let u=(await Ih()||[]).map((v)=>new File([new Uint8Array(v.bytes)],v.name,{type:WL0(v.name)}));if(U(!1),u.length)await f(u);return}let x=await uZ();if(x?.bytes){await C(new Blob([new Uint8Array(x.bytes)]));return}}catch(x){B(x?.message||"open failed")}U(!1)},c=()=>{if(G9()){m();return}let x=document.createElement("input");if(x.type="file",x.accept="image/*,video/*",Y)x.multiple=!0;x.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(x);let h=()=>{if(x.isConnected)x.remove()};window.addEventListener("focus",()=>setTimeout(h,300),{once:!0}),x.addEventListener("change",()=>{let u=x.files?Array.from(x.files):[];if(h(),!u.length)return;if(Y)f(u);else C(u[0])}),x.click()},o=(x)=>`/${J}/${x}`;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(x)=>{if(x.target===x.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…"}),V&&z("span",{className:"st-ap-err",children:V})]}),z("div",{className:"st-ap-grid",children:Z==null?z("div",{className:"st-ap-empty",children:"Loading…"}):Z.length===0?z("div",{className:"st-ap-empty",children:"No assets yet — upload one."}):Z.map((x)=>{let h=Y&&N.has(x.path);return D("button",{type:"button",className:"st-ap-cell","data-selected":h?"true":void 0,"aria-pressed":Y?h:void 0,title:`${x.name} · ${Math.max(1,Math.round(x.size/1024))} KB`,onClick:()=>Y?R(x.path):X(x.path),children:[Y&&z("span",{className:"st-ap-check","aria-hidden":"true",children:h?z(k9,{name:"check",size:12}):null}),x.kind==="video"?z("video",{className:"st-ap-thumb",src:o(x.path),muted:!0,playsInline:!0}):z("img",{className:"st-ap-thumb",src:o(x.path),alt:x.name,loading:"lazy"}),z("span",{className:"st-ap-name",children:x.name})]},x.path)})})]}),Y&&N.size>0&&D("div",{className:"st-dialog-ft st-ap-confirm",children:[D("span",{className:"st-ap-count",children:[N.size," selected"]}),D("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":E==="artboard",disabled:I,onClick:()=>w("artboard"),children:"Add to artboard"}),z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":E==="annotation",onClick:()=>w("annotation"),children:"Add as annotation"})]}),I&&z("span",{className:"st-ap-dest-note",children: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(N),E),children:"Insert"})]})]})})}function AL(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 ZL0({mode:J,initialScope:X,activePath:Q,hasComps:Y=!1,comps:W=[],activeArtboardId:G=null,selection:Z=null,exportLane:H="local",onBrowserCapture:K=null,onClose:U}){let V=p.useCallback(($0)=>H==="none"&&!$0.handoff&&$0.format!=="zip"&&!tb.has($0.format)||H!=="local"&&$0.format==="canva",[H]),[B,N]=p.useState(J==="handoff"?"shadcn":"png"),[F,M]=p.useState(()=>X&&ub("png",X)?X:bO("png")),[A,E]=p.useState(2),[w,O]=p.useState(JL0),[I,T]=p.useState(!0),[R,$]=p.useState(!1),[C,j]=p.useState(!1),[f,m]=p.useState(!1),[c,o]=p.useState(XL0),[x,h]=p.useState(QL0),[u,v]=p.useState(!0),[n,e]=p.useState(!1),[s,H0]=p.useState(null),[r,z0]=p.useState([]),i=BT.find(($0)=>$0.id===B)||BT[0],q0=i.handoff?[]:yO(i.format),Z0=900,I0=3600,e0=PK(W,aw(W,{artboardId:G})),J8=e0?.durationInFrames||0,Y8=e0?.fps||30,P8=i.temporal&&J8>900,S8=i.temporal&&J8>3600;p.useEffect(()=>{if(q0.length&&!q0.includes(F))M(bO(i.format))},[q0,F,i.format]),p.useEffect(()=>{if(H!=="remote")return;fetch("/_api/export-warmup").catch(()=>{})},[H]);let a8=p.useCallback(()=>{fetch("/_api/export-history").then(($0)=>$0.json()).then(($0)=>z0(Array.isArray($0?.history)?$0.history.slice(0,6):[])).catch(()=>{})},[]);p.useEffect(()=>{a8()},[a8]),p.useEffect(()=>{function $0(w0){if(w0.key==="Escape")w0.preventDefault(),U()}return window.addEventListener("keydown",$0),()=>window.removeEventListener("keydown",$0)},[U]);async function n0(){if(i.handoff){let H8=`/design:handoff ${Q&&Q!==o8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(H8)}catch{}H0({ok:!0,msg:`Copied: ${H8} — run it in Claude Code.`});return}if(V(i)){H0({ok:!1,msg:"This format needs the render service, which this workspace doesn’t have configured."});return}e(!0),H0(null);let $0=i.temporal?{scale:A}:{};if(i.format==="png"){let S0=Lq.find((H8)=>H8.id===w)||Lq[1];if(S0.kind==="dpi")$0.dpi=S0.value;else $0.scale=S0.value}if(i.format==="mp4"||i.format==="webm")$0.audio=u;if(S8)$0.maxFrames=J8;if(i.format==="pdf"){$0.pdfPrint={includeBleed:I,marks:{crop:C,registration:f}};let S0=E90.find((H8)=>H8.id===c)?.value;if(S0!==void 0)$0.dpi=S0;if(x!=="keep")$0.text=x}if(G)$0.artboardId=G;if(Z?.selector)$0.selection=Z;if(Q&&Q!==o8)$0.canvasFile=Q;if(fU.has(i.format)&&GB({exportLane:H,format:i.format,scope:F,artboardId:$0.artboardId})&&typeof K==="function")try{let S0=mO($0);H0({ok:!0,msg:"Capturing…"});let H8=await K({format:i.format,artboardIds:[$0.artboardId],scale:S0,onProgress:(u8,y8)=>H0({ok:!0,msg:`Capturing ${u8}/${y8}…`})}),X8=await gO(H8,i.format);for(let u8 of X8)AL(u8.name,u8.blob);for(let u8 of X8)await uO({format:i.format,scope:F,filename:u8.name});e(!1),H0({ok:!0,msg:`Saved ${X8.map((u8)=>u8.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(GB({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?Q4(Q).replace(/\.[^.]+$/,""):"export",{filename:H8,blob:X8}=await hO({capture:K,name:S0,onProgress:(u8,y8)=>H0({ok:!0,msg:`Capturing ${u8}/${y8}…`}),onAssemble:()=>H0({ok:!0,msg:"Assembling deck…"})});AL(H8,X8),await uO({format:i.format,scope:F,filename:H8}),e(!1),H0({ok:!0,msg:`Saved ${H8} 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"&&fU.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:$0})});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:($0)=>{if($0.target===$0.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 · ${X4(Q4(Q))}`:"Format"}),z("div",{className:"st-fmt-grid",children:BT.filter(($0)=>!$0.temporal||Y).map(($0)=>D("button",{type:"button","data-testid":`export-format-${$0.id}`,className:"st-fmt"+($0.id===B?" is-on":""),disabled:V($0),title:V($0)?"Needs the render service — not configured on this workspace":void 0,onClick:()=>{N($0.id),H0(null)},children:[z(k9,{name:$0.icon,size:16}),z("span",{className:"st-fmt-name",children:$0.label}),z("span",{className:"st-fmt-sub",children:$0.sub})]},$0.id))}),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:($0)=>M($0.target.value),children:q0.map(($0)=>z("option",{value:$0,children:w90[$0]},$0))})]}),!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:($0)=>O($0.target.value),children:Lq.map(($0)=>z("option",{value:$0.id,children:$0.label},$0.id))})]}),!i.handoff&&i.format==="png"&&z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let $0=Lq.find((S0)=>S0.id===w)||Lq[1],w0=$0.kind==="dpi"?$0.value/96:$0.value;return`${$0.label} ≈ ${Math.round(1440*w0)}×${Math.round(900*w0)} 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:($0)=>E(Number($0.target.value)),children:eF0.map(($0)=>z("option",{value:$0.value,children:$0.label},$0.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: ",J8," frames (≈",Math.round(J8/Y8),"s).",S8?` 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:($0)=>o($0.target.value),children:E90.map(($0)=>z("option",{value:$0.id,children:$0.label},$0.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:"The page stays vector; this only sets the capture density for raster content on it (dropped photos, large-format art)."}),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:x,onChange:($0)=>h($0.target.value),children:P90.map(($0)=>z("option",{value:$0.id,children:$0.label},$0.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:P90.find(($0)=>$0.id===x)?.description}),z("div",{className:"st-dialog-row",children:D("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-bleed",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-pdf-bleed",type:"checkbox",checked:I,onChange:($0)=>T($0.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:()=>$(($0)=>!$0),"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:($0)=>j($0.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:($0)=>m($0.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:u,onChange:($0)=>v($0.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}),r.length>0&&D("div",{className:"st-export-recent","data-testid":"export-recent",children:[z("div",{className:"st-rp-hd",children:"Recent"}),r.map(($0,w0)=>D("div",{className:"st-export-recent-row",children:[D("span",{children:[String($0.format||"").toUpperCase()," ·"," ",w90[$0.scope]||$0.scope]}),z("span",{className:"st-mono",children:$0.filename})]},w0))]})]}),D("div",{className:"st-dialog-ft",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:U,children:"Cancel"}),D("button",{type:"button",className:"btn btn--primary","data-testid":"export-submit",disabled:n,onClick:n0,children:[z(k9,{name:"download",size:14}),i.handoff?"Copy handoff command":n?"Exporting…":`Export ${i.label}`]})]})]})})}var PL=12,IL=16;function HL0({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)},V=W?W.dropProps(Y,!0,()=>U(!0)):{},B=W?.overDir===Y,N=W?W.dragProps(Y,!0):{},F=W?.draggedPath===Y,M=W?.busyPath===Y,A=D("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${Aq(Y)}`,"aria-expanded":K,"aria-dropeffect":W?"move":void 0,"aria-busy":M||void 0,tabIndex:-1,className:"st-row"+(B?" is-drop-target":"")+(F?" is-dragging":"")+(M?" is-busy":""),style:{paddingLeft:PL+X*IL+"px"},onClick:()=>U((E)=>!E),onContextMenu:G?(E)=>G.openAt(E,{kind:"dir",dirPath:Y}):void 0,...N,...V,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-${Aq(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(OL,{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 zL0({name:J,dsName:X,dirPath:Q,depth:Y,active:W,onOpenSystem:G,children:Z,expansion:H,forceOpen:K}){let U=!!K||!!H?.isOpen(Q),V=(B)=>{if(K)return;let N=typeof B==="function"?B(U):B;if(N!==U)H?.setOpen(Q,N)};return z(dz,{label:J,expanded:U,selected:W,onToggle:()=>V((B)=>!B),row:D("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:PL+Y*IL+"px"},children:[z("button",{type:"button",className:"st-ds-chev",onClick:()=>V((B)=>!B),"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 _L({file:J,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,onDelete:G,openCount:Z,depth:H,kind:K,sidecar:U,dirty:V,experimentalKind:B,drag:N,menu:F}){let M=J.path===X||J.path===Q,A=y5.test(J.name),E=!A&&K!=="runtime"?EL(J.name):null,w=!A&&!E,O=A?X4(J.name):J.name,I=A&&typeof G==="function"&&K!=="runtime",T=A&&!U&&K!=="runtime"&&typeof N<"u",R=T?N.dragProps(J.path,!0):{},$=N?.draggedPath===J.path,C=N?.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(y5,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,x=D("button",{type:"button",role:"treeitem","data-testid":o??(f?`file-row-${Aq(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:PL+H*IL+"px"},title:J.path+(Z?` — ${Z} open`:w?" (file index only)":""),onClick:()=>{if(A)Y(J.path);else if(E)W?.(J.path)},onContextMenu:m?(h)=>F.openAt(h,{kind:"file",path:J.path,dir: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}),B==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),B==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),V&&z("span",{className:"st-git-badge","data-kind":V,title:`Unsaved (${V})`,"aria-label":`Unsaved, ${V}`,children:V}),Z>0&&z("span",{className:"st-row-badge",children:Z})]});return z(dz,{label:O,row:x,selected:M,disabled:w,busy:C,actions:D(Q0,{children:[m&&z("button",{type:"button",className:"st-row-menu-btn"+(I?" has-delete-sibling":""),"data-testid":`tree-row-menu-${Aq(J.path)}`,title:`Actions for ${O}`,"aria-label":`Actions for ${O}`,"aria-haspopup":"menu",onClick:(h)=>F.openAt(h,{kind:"file",path:J.path,dir:c,canMove:j||f,supporting:f,name:J.name}),children:z(OL,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})}),I&&z("button",{type:"button",className:"st-row-del",title:`Delete ${O}`,"aria-label":`Delete canvas ${O}`,onClick:(h)=>{h.stopPropagation(),G(J.path,O)},children:z(OL,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})})}function KL0({primary:J,sidecars:X,depth:Q,kind:Y,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,showHidden:V,forceOpen:B,dirtyByPath:N,experimentalKind:F,drag:M,menu:A}){let E=N?.get(J.path),w=X.length>0,[O,I]=p.useState(!1),T=B||O,R=J.path===W;if(!(w&&V))return z(_L,{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",x=J.path.split("/").slice(0,-1).join("/"),h=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:PL+Q*IL+"px"},title:J.path,onClick:(u)=>{if(u.target.closest(".st-canvas-chev")){I((v)=>!v);return}Z(J.path)},onContextMenu:o?(u)=>A.openAt(u,{kind:"file",path:J.path,dir:x,canMove:c}):void 0,...j,children:[z("span",{className:"st-row-glyph st-canvas-chev",onClick:(u)=>{u.stopPropagation(),I((v)=>!v)},children:z(k9,{name:"chevron-right",className:"st-chev"+(T?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:X4(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:X4(J.name),row:h,selected:R,expanded:T,busy:m,onToggle:()=>I((u)=>!u),actions:o?z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${Aq(J.path)}`,title:`Actions for ${X4(J.name)}`,"aria-label":`Actions for ${X4(J.name)}`,"aria-haspopup":"menu",onClick:(u)=>A.openAt(u,{kind:"file",path:J.path,dir:x,canMove:c}),children:z(OL,{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((u)=>z(_L,{file:u,menu:A,activePath:W,previewPath:G,onOpen:Z,onPreview:H,openCount:0,depth:Q+1,kind:Y,sidecar:!0},u.path))})}function d90({node:J,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z=1,kind:H,showHidden:K,search:U,dsFolders:V,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:M,canvasKinds:A,dirPath:E="",drag:w,menu:O,expansion:I}){let T=Object.keys(J).filter((o)=>o!=="_files").sort(),R=J._files||[],{canvases:$,orphans:C}=p.useMemo(()=>oF0(R),[R]),{mediaOrphans:j,metaOrphans:f}=p.useMemo(()=>{let o=[],x=[];for(let h of C){let u=EL(h.primary.name);(u==="image"||u==="video"||u==="audio"||u==="font"?o:x).push(h)}return{mediaOrphans:o,metaOrphans:x}},[C]),m=!!(U&&U.trim()),c=p.useMemo(()=>{if(!V||Z!==1)return null;let o=new Map;for(let x of V)o.set(x.folder,x);return o},[V,Z]);return D(Q0,{children:[$.map((o)=>{let x=m&&o.sidecars.some((h)=>{let u=U.toLowerCase();return h.name.toLowerCase().includes(u)||h.path.toLowerCase().includes(u)});return z(KL0,{primary:o.primary,sidecars:o.sidecars,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,onDelete:F,openCount:DL(G[o.primary.path]),depth:Z,kind:H,showHidden:K,forceOpen:x,dirtyByPath:M,experimentalKind:A?.[o.primary.path],drag:w,menu:O},o.primary.path)}),j.map((o)=>z(_L,{file:o.primary,menu:O,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,openCount:DL(G[o.primary.path]),depth:Z,kind:H},o.primary.path)),K&&f.map((o)=>z(_L,{file:o.primary,menu:O,activePath:X,previewPath:Q,onOpen:Y,onPreview:W,openCount:DL(G[o.primary.path]),depth:Z,kind:H},o.primary.path)),T.map((o)=>{let x=c?.get(o),h=E?`${E}/${o}`:o,u=z(d90,{node:J[o],activePath:X,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z+1,kind:H,showHidden:K,search:U,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:M,canvasKinds:A,dirPath:h,drag:w,menu:O,expansion:I});if(x&&N)return z(zL0,{name:o,dsName:x.name,dirPath:h,depth:Z,expansion:I,forceOpen:m,active:X===o8&&x.name===B,onOpenSystem:N,children:u},o);return z(HL0,{name:o,depth:Z,dirPath:h,expansion:I,forceOpen:m,drag:w,menu:w?O:void 0,children:u},o)})]})}var NL={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function UL0(J){if(J.kind==="project")return NL.project;if(J.kind==="runtime")return NL.runtime;if(J.label==="Design system")return NL.ds;if(J.label==="UI kit")return NL.canvas;return{title:J.label.toUpperCase(),pillFromCount:!0}}function VL0({readOnly:J=!1,cloud:X,groups:Q,activePath:Y,previewPath:W,activeDsName:G,onOpen:Z,onPreview:H,onOpenSystem:K,wsConnected:U,search:V,setSearch:B,commentsByFile:N,showHidden:F,sectionsExpanded:M,onToggleSection:A,treeExpansion:E,onNewBoard:w,onDeleteBoard:O,onRefresh:I,refreshing:T,collapsed:R,onCollapse:$,width:C,resizing:j,dirtyByPath:f,project:m,gitBranch:c,remoteSync:o,onGetLatest:x,canvasKinds:h,onMoveCanvas:u,onNewFolder:v,onDeleteFolder:n,onRenameFolder:e,onRenameCanvas:s,onDuplicateCanvas:H0,onDeleteFile:r,syncStatus:z0,onLinkedHub:i,onLocalProject:q0,onOpenLinkedFile:Z0,filesReady:I0,onShare:e0,savingIsManaged:J8=!1}){let Y8=p.useMemo(()=>{if(!V)return Q;return Q.map((k0)=>({...k0,tree:p90(k0.tree,V),filtered:!!V}))},[Q,V]),P8=Yy(u),S8=Jy(),a8=p.useMemo(()=>{let k0=[];for(let r0 of Q){if(r0.label==="Design system"||r0.kind!=="canvas")continue;let g0=r0.fullPath.replace(/^\.[^/]+\//,"")||r0.fullPath;k0.push({path:r0.fullPath,label:g0});for(let m0 of r0.dirs||[])k0.push({path:m0,label:m0.replace(/^\.[^/]+\//,"")})}return k0},[Q]),n0=S8.state?.extra,$0=n0?.kind==="file"?[{id:"share",label:"Share…",onSelect:()=>{S8.close(),e0(n0.path)}},...s&&/\.tsx$/i.test(n0.path)?[{id:"rename-canvas",label:"Rename…",onSelect:()=>{S8.close();let k0=X4(n0.path.split("/").pop()),r0=window.prompt("Rename canvas to:",k0);if(r0?.trim()&&r0.trim()!==k0)s(n0.path,r0.trim())}}]:[],...H0&&/\.tsx$/i.test(n0.path)?[{id:"duplicate-canvas",label:"Duplicate",onSelect:()=>{S8.close(),H0(n0.path)}}]:[],...n0.supporting&&s?[{id:"rename-file",label:"Rename…",onSelect:()=>{S8.close();let k0=n0.name??n0.path.split("/").pop(),r0=k0.includes(".")?k0.slice(k0.lastIndexOf(".")):"",g0=r0?k0.slice(0,-r0.length):k0,m0=window.prompt(`Rename ${k0} to:`,g0);if(m0?.trim()&&m0.trim()!==g0)s(n0.path,m0.trim())}}]:[],...n0.canMove?[{id:"move-to",label:"Move to…",onSelect:()=>S8.showMoveTo()}]:[],...n0.supporting&&r?[{id:"delete-file",label:"Delete",destructive:!0,onSelect:()=>{S8.close(),r(n0.path,n0.name??n0.path.split("/").pop())}}]:[]]:n0?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{S8.close();let k0=window.prompt("New folder name:");if(k0?.trim())v(n0.dirPath,k0.trim())}},{id:"rename-folder",label:"Rename folder",onSelect:()=>{S8.close();let k0=n0.dirPath.split("/").pop(),r0=window.prompt("Rename folder to:",k0);if(r0?.trim()&&r0.trim()!==k0)e(n0.dirPath,r0.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{S8.close(),n(n0.dirPath,n0.dirPath.split("/").pop())}}]:[],w0=n0?.kind==="file"||n0?.kind==="supporting"?a8.filter((k0)=>k0.path!==n0.dir):[],[S0,H8]=p.useState(!1),[X8,u8]=p.useState("board"),[y8,L9]=p.useState(""),[h0,T8]=p.useState(""),[A9,N8]=p.useState(!1),B0=p.useMemo(()=>Q.find((k0)=>k0.kind==="canvas"&&k0.label!=="Design system")?.fullPath,[Q]),Q8=p.useCallback(async()=>{let k0=y8.trim();if(!k0||A9)return;if(N8(!0),T8(""),X8==="folder"){if(!B0){N8(!1),T8("no canvas group to create a folder in");return}let g0=await v(B0,k0);if(N8(!1),g0?.ok)H8(!1),L9("");else T8(g0?.error||"could not create folder");return}let r0=await w(k0);if(N8(!1),r0?.ok)H8(!1),L9("");else T8(r0?.error||"could not create board")},[y8,A9,w,v,X8,B0]),s0=p.useMemo(()=>{let k0=0;for(let r0 of Q)for(let g0 of r0.paths||[])if(y5.test(g0))k0++;return k0},[Q]),s8=p.useMemo(()=>{let k0=0;for(let r0 of Y8)for(let g0 of r0.paths||[])if(y5.test(g0))k0++;return k0},[Y8]);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":S0&&X8==="board",onClick:()=>{T8(""),u8("board"),H8((k0)=>X8==="board"?!k0:!0)},children:z(k9,{name:"plus",size:15})}),!J&&B0&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":S0&&X8==="folder",onClick:()=>{T8(""),u8("folder"),H8((k0)=>X8==="folder"?!k0:!0)},children:z(k9,{name:"folder-plus",size:15})}),I&&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:()=>I(),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"}),s8," / ",s0]}),$&&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})})]})]}),S0?D("div",{className:"st-newboard",children:[z("input",{type:"text",autoFocus:!0,placeholder:X8==="folder"?"folder name…":"brief board name…",value:y8,maxLength:60,disabled:A9,"aria-label":X8==="folder"?"New folder name":"New brief board name",onChange:(k0)=>L9(k0.target.value),onKeyDown:(k0)=>{if(k0.key==="Enter")k0.preventDefault(),Q8();else if(k0.key==="Escape")k0.preventDefault(),H8(!1),L9(""),T8("")}}),z("button",{type:"button",className:"st-newboard-go",disabled:A9||!y8.trim(),"data-tip":"Create · Enter","aria-label":X8==="folder"?"Create folder":"Create brief board",onClick:Q8,children:A9?"…":"↵"})]}):null,h0?z("div",{className:"st-newboard-err",role:"alert",children:h0}):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:V,onChange:(k0)=>B(k0.target.value),onKeyDown:(k0)=>{if(k0.key==="Escape")if(k0.preventDefault(),V)B("");else k0.currentTarget.blur()},"aria-label":"Filter files"}),V?z("button",{className:"st-search-clear",onClick:()=>B(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):z(TJ,{children:"/"})]})}),z(Qy,{"aria-label":"Project file tree","data-testid":"canvas-list",children:Y8.map((k0)=>{if(!F&&!V&&k0.kind==="runtime")return null;let r0=UL0(k0),g0=(k0.paths||[]).filter((x7)=>y5.test(x7)).length,m0=r0.pill||(r0.pillFromDsCount?String(k0.dsFolders?.length||0):null)||(r0.pillFromCount?String(g0||k0.paths?.length||0):null),I8=k0.tree&&Object.keys(k0.tree).length>0,O0=k0.label==="Design system",G8=k0.kind==="project";if(!F&&!V&&G8&&g0===0)return null;let _8=dF0(k0),V0=M[k0.label],o0=!!V||(V0===void 0?_8:V0),k8=!O0&&k0.kind==="canvas"&&!J,X9=k8?P8.dropProps(k0.fullPath,!0):{},c0=P8.overDir===k0.fullPath;return z(dz,{className:"st-tree-section",label:r0.title,expanded:o0,onToggle:()=>A(k0.label,_8),row:D("button",{type:"button",className:"st-tree-sec-hd"+(c0?" is-drop-target":""),"data-testid":`tree-section-${k0.label.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,onClick:()=>A(k0.label,_8),"aria-expanded":o0,"aria-dropeffect":k8?"move":void 0,title:o0?"Collapse section":"Expand section",...X9,children:[z(k9,{name:"chevron-right",className:"st-chev"+(o0?" is-open":""),size:13}),z("span",{className:"st-sec-name",children:r0.title}),m0&&z("span",{className:"st-pill",children:m0})]}),children:o0&&(I8?z(d90,{node:k0.tree,activePath:Y,previewPath:W,onOpen:Z,onPreview:H,commentsByFile:N,depth:1,kind:k0.kind,showHidden:F,search:V,dsFolders:k0.dsFolders,activeDsName:G,onOpenSystem:O0?K:void 0,onDelete:O0||J?void 0:O,dirtyByPath:f,canvasKinds:h,dirPath:k0.fullPath,drag:!O0&&k0.kind==="canvas"&&!J?P8:void 0,menu:S8,expansion:E}):z("div",{className:"st-tree-empty",children:V?"No matches.":"Empty."}))},k0.label)})}),z(Xy,{state:S8.state,onClose:S8.close,rootItems:$0,destinations:w0,onPickDestination:(k0)=>u(n0.path,k0)}),z(NE,{project:m,liveBranch:c,remoteSync:o,onGetLatest:x,projectOnly:J8}),X===null?z(yw,{syncStatus:z0,onLinkedHub:i,onLocalProject:q0,onOpenFile:Z0,filesReady:I0}):null,z(hw,{})]})}function qL0({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 BL0({open:J,onClose:X,onStartTour:Q}){if(p.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",DT]}),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 NT=[{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 NL0({kbd:J,alt:X}){let Q=(Y,W)=>z("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>z(TJ,{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 FL0({open:J,onClose:X}){if(p.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=NT.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(TJ,{children:"?"})," to open"]})]}),z("div",{className:"so-columns",children:NT.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(NL0,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),D("div",{className:"so-overlay-ft",children:[D("span",{children:["close with ",z(TJ,{children:"Esc"})]}),D("span",{className:"so-count",children:[Q," bindings · ",NT.length," groups"]})]})]})})}var LL0=["File","Edit","View","Selection","Tools","Help"];function c90(J){p.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 DL0({panels:J,onToggle:X,onClose:Q,onZoom:Y,hasCanvas:W}){return c90(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(TJ,{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(TJ,{children:G.shortcut})]},G.label))]})}function eK({label:J,left:X,header:Q,items:Y,onAction:W,onClose:G}){return c90(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(TJ,{children:Z.shortcut}):null]},Z.id))]})}function ML0({onAction:J,onClose:X}){return z(eK,{label:"Help",left:320,onAction:J,onClose:X,items:[{id:"shortcuts",label:"Keyboard shortcuts",shortcut:"?"},{id:"help",label:"Help · commands & flows",shortcut:"F1"},{id:"report-bug",label:"Report a bug…"},{sep:!0},{id:"tour",label:"Take the tour"},{id:"watch-intro",label:"Watch the intro"},...G9()?[{id:"collab-tour",label:"How sharing works"}]:[],...G9()?[{id:"quick-setup",label:"Quick setup"}]:[],...G9()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function OL0({onAction:J,onClose:X,readOnly:Q=!1}){return z(eK,{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 AL0({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(eK,{label:"Tools",left:290,header:"Tool palette",onAction:J,onClose:X,items:Y})}function _L0({onAction:J,onClose:X,hasCanvas:Q,hasSharePath:Y,readOnly:W=!1}){return z(eK,{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 wL0({onAction:J,onClose:X,hasCanvas:Q,readOnly:Y=!1}){if(Y)return z(eK,{label:"Edit",left:90,onAction:J,onClose:X,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"}]});return z(eK,{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 EL0({activePath:J,sharePath:X,onShare:Q,project:Y,cloud:W,tabsCount:G,openMenu:Z,setOpenMenu:H,commentsPanelOpen:K,onToggleComments:U,changesOpen:V,changesCount:B,onToggleChanges:N,onOpenSystem:F,sidebarOpen:M,onToggleSidebar:A,showHidden:E,onToggleShowHidden:w,onOpenHelp:O,onOpenShortcuts:I,onReportBug:T,onStartTour:R,onStartCollabTour:$,annotationsVisible:C,onToggleAnnotations:j,minimapVisible:f,onToggleMinimap:m,zoomCtlVisible:c,onToggleZoomCtl:o,presentMode:x,onTogglePresent:h,printGuidesVisible:u,onTogglePrintGuides:v,postToActiveCanvas:n,onOpenWhatsNew:e,onOpenReadiness:s,onOpenQuickSetup:H0,onWatchIntro:r,whatsNewCount:z0,exportCenter:i,artboardCount:q0=0,presence:Z0=null,inspectorOpen:I0,inspectorTab:e0,onToggleInspector:J8,autoOpenInspector:Y8,onToggleAutoOpenInspector:P8,onOpenLayers:S8,timelineOpen:a8,onToggleTimeline:n0,hasComps:$0=!1,assistantOpen:w0,onToggleAssistant:S0,assistantBusy:H8,assistantUnseen:X8,onNewCanvas:u8,onAssembleVideo:y8,onOpenExport:L9,onOpenSettings:h0,onOpenGenerate:T8,onReload:A9,onCloseCanvas:N8,onInsertArtboard:B0,readOnly:Q8=!1}){let s0=J===o8,s8=s0?"SYSTEM":J?"CANVAS":"IDLE",k0=s0?z("b",{children:"design system"}):J?D(Q0,{children:[J.split("/").slice(0,-1).join("/"),"/",z("b",{children:X4(Q4(J))})]}):z("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),r0=new Set(W?["autoopen"]:["assistant","autoopen"]),g0=[{id:"tree",label:"Project Tree",shortcut:"T",checked:M,disabled:!1},{id:"changes",label:W?"History":B>0?`Changes · ${B} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:V,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:K,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:E,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:I0&&e0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:I0,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!Y8,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:$0?"video":void 0,checked:a8,disabled:!1},...G9()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:w0,disabled:!1}]:W?[{id:"assistant",label:"Assistant — in the desktop app",shortcut:"",checked:!1,disabled:!0,href:"https://maude.sh/download",hint:"The agent runs on your own Claude subscription, on your own machine."}]:[],{id:"annotate",label:"Annotations",shortcut:"⇧ P",checked:C,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:f,disabled:!J||s0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:c,disabled:!J||s0},{id:"present",label:"Presentation Mode",shortcut:"",checked:x,disabled:!J||s0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:u,disabled:!J||s0}].filter((O0)=>!Q8||!r0.has(O0.id)),m0=["file","edit","view","selection","tools","help"];function I8(O0){if(m0.includes(O0))H(Z===O0?null:O0)}return p.useEffect(()=>{if(!Z||!m0.includes(Z))return;let O0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function G8(_8){let V0=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!V0.length)return;let o0=V0.indexOf(document.activeElement);if(_8.key==="ArrowDown")_8.preventDefault(),V0[(o0+1)%V0.length].focus();else if(_8.key==="ArrowUp")_8.preventDefault(),V0[(o0-1+V0.length)%V0.length].focus();else if(_8.key==="Home")_8.preventDefault(),V0[0].focus();else if(_8.key==="End")_8.preventDefault(),V0[V0.length-1].focus();else if(_8.key==="ArrowRight"||_8.key==="ArrowLeft"){_8.preventDefault();let k8=_8.key==="ArrowRight"?1:-1,X9=m0.indexOf(Z);H(m0[(X9+k8+m0.length)%m0.length])}else if(_8.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",G8),()=>{clearTimeout(O0),window.removeEventListener("keydown",G8)}},[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:LL0.map((O0)=>{let G8=O0.toLowerCase(),_8=m0.includes(G8),V0=_8||G8==="help",o0=Z===G8;return z("button",{type:"button",className:"st-menu",role:"menuitem","data-testid":`menu-${G8}`,"data-tour":G8==="help"?"help":void 0,"aria-haspopup":_8?"menu":void 0,"aria-expanded":_8?o0:void 0,onClick:()=>I8(G8),onMouseEnter:()=>{if(Z!==null&&_8)H(G8)},children:O0},G8)})}),Z==="file"&&z(_L0,{readOnly:Q8,hasCanvas:!!J,hasSharePath:!!X,onAction:(O0)=>{if(O0==="new")u8?.();else if(O0==="assemble")y8?.();else if(O0==="export")L9?.("export");else if(O0==="share")document.querySelector('[data-testid="menu-file"]')?.focus(),Q?.();else if(O0==="handoff")L9?.("handoff");else if(O0==="generate")T8?.();else if(O0==="settings")h0?.();else if(O0==="reload")A9?.();else if(O0==="close")N8?.()},onClose:()=>H(null)}),Z==="edit"&&z(wL0,{readOnly:Q8,hasCanvas:!!J&&!s0,onAction:(O0)=>{if(O0==="undo")n({dgn:"undo"});else if(O0==="redo")n({dgn:"redo"});else if(O0==="deselect-all")n({dgn:"selection-clear"});else if(O0==="select-all-annotations")n({dgn:"annotation-select-all"});else if(O0.startsWith("new-artboard:"))B0?.(O0.slice(13))},onClose:()=>H(null)}),Z==="view"&&z(DL0,{panels:g0,onToggle:(O0)=>{if(O0==="tree")A();else if(O0==="changes")N();else if(O0==="comments")U();else if(O0==="hidden")w();else if(O0==="annotate")j();else if(O0==="inspector")J8();else if(O0==="autoopen")P8?.();else if(O0==="timeline")n0?.();else if(O0==="assistant")S0?.();else if(O0==="layers")S8?.();else if(O0==="minimap")m?.();else if(O0==="zoomctl")o?.();else if(O0==="present")h?.();else if(O0==="print-guides")v?.()},onZoom:(O0)=>n({dgn:"zoom",op:O0}),hasCanvas:!!J&&!s0,onClose:()=>H(null)}),Z==="selection"&&z(OL0,{readOnly:Q8,onAction:(O0)=>{if(O0==="deselect-all")n({dgn:"selection-clear"});else if(O0==="select-all-annotations")n({dgn:"annotation-select-all"})},onClose:()=>H(null)}),Z==="tools"&&z(AL0,{readOnly:Q8,onAction:(O0)=>n({dgn:"tool-set",tool:O0}),onClose:()=>H(null)}),Z==="help"&&z(ML0,{onAction:(O0)=>{if(O0==="shortcuts")I?.();else if(O0==="help")O?.();else if(O0==="report-bug")T?.();else if(O0==="tour")R?.();else if(O0==="collab-tour")$?.();else if(O0==="quick-setup")H0?.();else if(O0==="readiness")s?.();else if(O0==="whatsnew")e?.();else if(O0==="watch-intro")r?.()},onClose:()=>H(null)}),D("div",{className:"st-mb-right","data-tour":"status",children:[Z0?z("div",{className:"st-presence",children:Z0}):null,Q8&&z("span",{className:"st-stamp st-stamp--viewonly","data-testid":"view-only-stamp","data-tip":W?.user?`${W.user} is a viewer on this project — you can browse, comment and export where available. Ask a project owner for edit access, or sign out if that is not the account you meant to use.`:"Your role in this project is viewer — you can browse, comment when available, and export where available. Ask a project owner for edit access.",children:"VIEW ONLY"}),W?.user?D("span",{className:"st-cloudwho","data-testid":"cloud-account",children:[z("span",{className:"st-cloudwho-email",title:W.role?`Signed in as ${W.user} — ${W.role}`:W.user,children:W.user}),z("form",{method:"post",action:"/auth/browser/signout",className:"st-cloudwho-form",children:z("button",{type:"submit",className:"st-cloudwho-out","data-testid":"cloud-signout",title:"Sign out of this project",children:"Sign out"})})]}):null,G9()&&!Q8&&z("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":w0?"true":"false","data-busy":H8?"true":"false","data-unseen":X8?"true":"false","aria-label":`Assistant${H8?" — 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(Cm,{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:s8}),z("span",{className:"st-mb-file",title:J||"",children:k0}),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 PL0({tabs:J,activePath:X,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:K,onIframeLoad:U,canvasError:V,canvasReloadNonce:B,onRetryCanvasLoad:N,loadedPath:F,showQuickSetup:M,onStartQuickSetup:A,previewPath:E}){let w=p.useRef(null);p.useEffect(()=>{if(E)w.current?.focus()},[E]);let O=p.useRef(new Map),I=new Set(J.map(($)=>$.path));for(let[$,C]of O.current)if(!I.has(C.path))O.current.delete($);let T=($)=>{let C=_Z($,{...H,canvasToken:void 0}),j=`${$}#${B}|${C}`,f=O.current.get(j);if(!f)f={path:$,src:_Z($,H)},O.current.set(j,f);return f.src},R=V&&V.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: ${xV(Q4(E))}`,tabIndex:0,children:z(gg,{path:E,kind:EL(Q4(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",DT," / 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(TJ,{children:"⌘"})," and hover to preview an element, click to select it — ",z(TJ,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",G9()?D(Q0,{children:[z("br",{}),z("br",{}),"Claude can see whatever's selected when you ask for a change in the Assistant panel, so pointing is often faster than describing it."]}):null]}),M&&z("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:A,children:"Start quick setup"})]}),J.map(($)=>{if($.path===o8)return z("div",{className:"system-view"+($.path===X?" active":""),children:z(bL0,{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}#${B}`)}),K&&K===X&&z("div",{className:"st-canvas-loading","aria-hidden":"true",children:D("div",{className:"st-skel-card",children:[z("div",{className:"st-skel-cap st-mono",children:"compiling canvas…"}),z("span",{className:"skel st-skel-thumb"}),z("span",{className:"skel st-skel-line",style:{width:"72%"}}),z("span",{className:"skel st-skel-line",style:{width:"46%"}})]})}),V&&V.path===X&&z("div",{className:"st-canvas-error",role:"alert","data-testid":"canvas-load-error",children:D("div",{className:"st-canvas-error-card",children:[z("div",{className:"st-canvas-error-title",children:V.kind==="server"?"Maude's server isn't responding":"This canvas didn't finish loading"}),z("div",{className:"st-canvas-error-body",children:V.kind==="server"?z(Q0,{children:"The canvas couldn't be reached. This usually means Maude's server restarted underneath this window — your files on disk are untouched."}):D(Q0,{children:["The server is up, but"," ",z("code",{children:xV(Q4(V.path))})," ","never finished compiling. Its own error, if it has one, is in the canvas frame."]})}),z("button",{type:"button",className:"btn btn--primary","data-testid":"canvas-load-retry",onClick:()=>N?.(V.path),children:"Reload canvas"})]})})]})}var IL0=["color","space","radius","shadow","leading","weight","motion","font","other"],kL0={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function TL0(J){return J==="color"}function RL0({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([...IL0,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return z(Q0,{children:W.map((G)=>{let Z=Y[G],H=TL0(G);return D("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[D("h2",{children:["tokens · ",kL0[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 CL0(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 $L0(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 SL0({tokenGroups:J}){let X=J?.fontsize||[];if(X.length===0)return null;let Q=J?.leading||[],Y=$L0(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=CL0(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 bL0({data:J,onOpen:X,cfg:Q,onSelectDs:Y}){if(!J)return z("div",{className:"sv-empty",children:z("p",{children:"Loading design system…"})});let{previewGallery:W,uiKitsGallery:G,systemDir:Z,tokens:H,tokenGroups:K,tokensPath:U,ds:V,availableDesignSystems:B}=J,N=(!W||!W.length)&&(!G||!G.length),F=Array.isArray(B)&&B.length>1,M=V?.name??B?.[0]?.name??"";return D("div",{className:"sv",children:[D("header",{className:"sv-header",children:[z("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),z("span",{className:"sv-title",children:"design system view"}),F?D("label",{className:"sv-ds-picker",children:[z("span",{className:"sv-ds-picker-label",children:"DS"}),z("select",{value:M,onChange:(A)=>Y&&Y(A.target.value),children:B.map((A)=>z("option",{value:A.name,children:A.name},A.name))})]}):null,z("span",{className:"sv-loc",children:z("code",{children:Z})})]}),V?.description?z("p",{className:"sv-ds-description",children:V.description}):null,z(RL0,{tokens:H,tokenGroups:K,tokensPath:U}),z(SL0,{tokenGroups:K}),N?z("div",{className:"sv-empty",children:D("p",{children:["No ",z("code",{children:"preview/"})," or ",z("code",{children:"ui_kits/"})," folders found under"," ",z("code",{children:Z}),"."]})}):D(Q0,{children:[z(I90,{title:"preview",items:W,onOpen:X,kind:"preview",cfg:Q}),z(I90,{title:"ui kits",items:G,onOpen:X,kind:"ui_kits",cfg:Q})]})]})}function I90({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:_Z(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 yL0({activePath:J,selected:X,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,syncProject:K,syncOpen:U=!1,onOpenSync:V,changesCount:B=0,unpushed:N=0,savingIsManaged:F=!1,changesOpen:M=!1,onOpenChanges:A,version:E}){let w=J===o8,O=X&&X.selector?X.selector+(X.text?` — "${X.text.slice(0,60)}"`:""):"",I=X&&X.dom_path?X.dom_path.join(" > "):X?X.selector:"",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:I,children:O}),z("button",{type:"button",className:"st-sb-sel-clear",onClick:Z,"data-tip":"Clear · Esc inside iframe","data-tip-pos":"top","aria-label":"Clear selection",children:"×"})]}),D("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[z("span",{className:"lbl",children:"comments"}),D("span",{className:"val",children:[Y," open"]})]}),A&&D("button",{type:"button",className:"st-sb-slot st-sb-changes"+(M?" is-open":"")+(B>0?" has-changes":N>0?" has-unpushed":""),onClick:A,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":M,children:[z("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),z("span",{className:"lbl",children:"changes"}),z("span",{className:"val",children:F?"cloud saving":B>0?`${B} unsaved`:N>0?`${N} to publish`:"all saved"})]}),z("span",{className:"st-sb-spacer"}),D("span",{className:"st-sb-slot",role:"group","aria-label":"Connection",children:[z("span",{className:"st-live-dot"+(Q?" is-connected":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:Q?"live":"reconnecting"})]}),R&&(V?z("button",{type:"button",className:"st-sb-slot st-sb-sync st-sb-sync--btn"+(U?" is-open":""),onClick:V,"data-testid":"open-sync","data-tip":"Open Sync panel","data-tip-pos":"top","aria-label":"Open Sync panel","aria-pressed":U,children:$}):z("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:$})),E&&z("span",{className:"st-sb-slot st-sb-version",role:"group","aria-label":"Maude version",children:D("span",{className:"val","data-testid":"statusbar-version",children:["v",E]})}),D("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${T} theme`,"data-tip-pos":"top","aria-label":`Switch to ${T} theme`,children:[z(k9,{name:W==="dark"?"sun":"moon",size:13}),T]})]})}function jL0({commentsByFile:J,filter:X,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:K,width:U,resizing:V}){let B=l90(J),N=Object.keys(J||{}).sort(),F=[];for(let M of N){let A=J[M]||[],E=A.filter((O)=>{if(X==="open")return O.status!=="resolved";if(X==="resolved")return O.status==="resolved";return!0});if(E.length===0)continue;let w=A.filter((O)=>O.selector);F.push({file:M,comments:E.map((O)=>({...O,n:w.findIndex((I)=>I.id===O.id)+1}))})}return D("aside",{className:"st-rpanel"+(V?" is-resizing":""),style:U?{width:U,flexBasis:U}:void 0,"aria-label":"Comments",children:[z("div",{className:"st-rp-tabs st-rp-tabs--filters",children:D("div",{className:"st-cm-filters",role:"tablist",children:[D("button",{type:"button",className:"st-cm-filter"+(X==="all"?" is-active":""),role:"tab","data-testid":"comment-filter-all","aria-selected":X==="all",onClick:()=>Q("all"),children:["All · ",B.all]}),D("button",{type:"button",className:"st-cm-filter"+(X==="open"?" is-active":""),role:"tab","data-testid":"comment-filter-open","aria-selected":X==="open",onClick:()=>Q("open"),children:["Open · ",B.open]}),D("button",{type:"button",className:"st-cm-filter"+(X==="resolved"?" is-active":""),role:"tab","data-testid":"comment-filter-resolved","aria-selected":X==="resolved",onClick:()=>Q("resolved"),children:["Resolved · ",B.resolved]})]})}),z("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:F.length===0?D("div",{className:"st-rp-empty",children:[D("p",{children:["No comments ",X!=="all"?`with status “${X}”`:"yet","."]}),D("p",{children:["Open a canvas, hold ",z(TJ,{children:"⌘"})," and click an element, then press ",z(TJ,{children:"C"})," — or hold ",z(TJ,{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:X4(Q4(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:rF0(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 vL0={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 fL0({cloud:J}){let X=J?.role||null,[Q,Y]=p.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=vL0[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 xL0({update:J,onDismiss:X}){let[Q,Y]=p.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),Th().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X,children:"Later"})]})}function hL0({status:J}){let[X,Q]=p.useState(null);if(!J||J.linked===!1)return null;if(J.notSyncable)return null;let{state:Y,queuedOps:W,flash:G,conflicts:Z}=J,H=G==="synced",K=Y==="offline"||Y==="offline-long",U=J.docs?.rejected??0,V=Array.isArray(Z)?[...Z].reverse().find((M)=>M.kind==="cold-start-diverged"):null;if(!K&&!H&&!V&&U===0)return null;let B,N,F;if(H)B="success",N="Synced with hub",F=`${Y}:flash`;else if(K){let M=Z&&Z.length>0?` (${Z.length} conflict notice(s))`:"";if(Y==="offline-long")B="error",N=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${M}`;else B="warn",N=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${M}`;F=`${Y}:offline`}else if(V){if(V.snapshotFailed)B="error",N=`Diverged on ${V.slug}: kept local — the history snapshot FAILED, so the overwrite was refused. Check disk space / .design/_history write access.`;else B="warn",N=`Diverged on ${V.slug}: kept the ${V.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${V.slug}`;F=`diverged:${V.slug}:${V.at}`}else B="warn",N=`${U} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,F=`rejected:${U}`;if(X===F)return null;return D("div",{role:"status","aria-live":"polite",className:`st-banner st-banner--${B}`,children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:N}),z("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(F),children:"×"})]})}var gL0=["block","inline-block","flex","inline-flex","grid","inline","none"],k90=["px","%","fr","em","auto","min-content","max-content"];var mL0=["auto","stretch","flex-start","center","flex-end","baseline"];var T90=["300","400","500","600","700","800"],Dq=(J,X)=>J&&Object.hasOwn(J,"previous")?J.previous:X,R90=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],C90=["none","solid","dashed","dotted","double"],$90=["px","rem","em","%","vw","vh","auto"],S90=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),FT={"font-size":{node:z(K7,{as:gV,size:12})},"line-height":{node:z(K7,{as:iV,size:12})},"letter-spacing":{node:z(K7,{as:X3,size:12})},gap:{node:z(K7,{as:wK,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:z(K7,{as:Z3,size:12})},"border-width":{node:z(K7,{as:J3,size:12})}};var b90=["static","relative","absolute","fixed","sticky"],uL0=["normal","italic","oblique"],y90=["none","uppercase","lowercase","capitalize"];var j90=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],pL0=["fill","contain","cover","none","scale-down"];var v90=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],f90=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],b5={desktop:{label:"Desktop",width:1440,height:1024},laptop:{label:"Laptop",width:1280,height:800},tablet:{label:"Tablet",width:834,height:1194},mobile:{label:"Mobile",width:390,height:844}},aK=null;function wL(J){if(!J)return"";if(/^#[0-9a-f]{6}$/i.test(J))return J.toLowerCase();try{if(!aK)aK=document.createElement("canvas").getContext("2d");if(!aK)return"";aK.fillStyle="#000000",aK.fillStyle=J;let X=aK.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 FY=(J)=>Math.min(1,Math.max(0,J));function FL(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 Mq({r:J,g:X,b:Q}){return`#${[J,X,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function Oq({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 sK({h:J,s:X,v:Q}){let Y=Q*X,W=Y*(1-Math.abs(J/60%2-1)),G=Q-Y,Z=0,H=0,K=0;if(J<60)[Z,H,K]=[Y,W,0];else if(J<120)[Z,H,K]=[W,Y,0];else if(J<180)[Z,H,K]=[0,Y,W];else if(J<240)[Z,H,K]=[0,W,Y];else if(J<300)[Z,H,K]=[W,0,Y];else[Z,H,K]=[Y,0,W];return{r:(Z+G)*255,g:(H+G)*255,b:(K+G)*255}}function U7(J){if(!J)return"";let X=/^(-?\d*\.?\d+)px$/.exec(J);return X?`${Math.round(Number.parseFloat(X[1]))}px`:J}function J4(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 x90(J,X){if(!J||Array.isArray(J)||Array.isArray(X)||!X)return J;if(!J.id&&!X.id){let Q=(Y)=>typeof Y.selector==="string"&&Y.selector.startsWith("[data-dc-screen=");if(Q(J)&&Q(X)&&J.selector===X.selector&&J.file===X.file)return{...J,authored:J.authored??X.authored,computed:J.computed??X.computed,customStyles:J.customStyles??X.customStyles,attrs:J.attrs??X.attrs,artboardId:J.artboardId??X.artboardId,worldW:J.worldW??X.worldW,worldH:J.worldH??X.worldH};return J}if(!J.id||J.id!==X.id)return J;return{...J,authored:J.authored??X.authored,computed:J.computed??X.computed,customStyles:J.customStyles??X.customStyles,attrs:J.attrs??X.attrs,photoKind:J.photoKind??X.photoKind,photoAsset:J.photoAsset??X.photoAsset}}function i90(J,X){return(J?X?.canvasDesignSystems?.[J]:null)||X?.defaultDesignSystem||X?.designSystems?.[0]?.name||null}function lL0(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 o90(J,X,Q){let Y=J?.designSystems||[],W=Y.map((H)=>`${H.name}:${H.tokensCssRel}`).join("|"),[G,Z]=p.useState([]);return p.useEffect(()=>{if(!Y.length)return;let H=!1;return Promise.all(Y.map(async(K)=>{if(!K.tokensCssRel)return null;try{let U=await fetch(`/${X}/${K.tokensCssRel}`),V=U.ok?await U.text():"";return{name:K.name,...lL0(V)}}catch{return null}})).then((K)=>{if(H)return;let U=K.filter(Boolean);U.sort((V,B)=>V.name===Q?-1:B.name===Q?1:0),Z(U)}),()=>{H=!0}},[W,X,Q]),G}function n90({seed:J,label:X,onApply:Q}){let[Y,W]=p.useState(()=>Oq(FL(J||"#000000"))),G=p.useRef(Y);G.current=Y;let Z=p.useRef(null),H=p.useRef(null),K=p.useRef(J);p.useEffect(()=>{if(J&&J!==K.current)K.current=J,W(Oq(FL(J)))},[J]);let U=Mq(sK(Y)),V=(O)=>{O.preventDefault();let I=Z.current?.getBoundingClientRect();if(!I)return;let T=G.current.h,R=(C)=>{W({h:T,s:FY((C.clientX-I.left)/I.width),v:FY(1-(C.clientY-I.top)/I.height)})};R(O);let $=()=>{document.removeEventListener("pointermove",R),document.removeEventListener("pointerup",$),Q(Mq(sK(G.current)))};document.addEventListener("pointermove",R),document.addEventListener("pointerup",$)},B=(O)=>{O.preventDefault();let I=H.current?.getBoundingClientRect();if(!I)return;let{s:T,v:R}=G.current,$=(j)=>{W({h:FY((j.clientX-I.left)/I.width)*360,s:T,v:R})};$(O);let C=()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",C),Q(Mq(sK(G.current)))};document.addEventListener("pointermove",$),document.addEventListener("pointerup",C)},N=(O)=>{let I={...G.current,...O};W(I),Q(Mq(sK(I)))},F=(O)=>{let I=O.shiftKey?0.1:0.02,R={ArrowLeft:[-I,0],ArrowRight:[I,0],ArrowUp:[0,I],ArrowDown:[0,-I]}[O.key];if(!R)return;O.preventDefault(),N({s:FY(G.current.s+R[0]),v:FY(G.current.v+R[1])})},M=(O)=>{let I=O.shiftKey?20:2,R={ArrowLeft:-I,ArrowRight:I}[O.key];if(R==null)return;O.preventDefault(),N({h:Math.min(360,Math.max(0,G.current.h+R))})},A=async()=>{try{let O=window.EyeDropper;if(!O)return;let I=await new O().open();if(I?.sRGBHex)W(Oq(FL(I.sRGBHex))),Q(I.sRGBHex)}catch{}},E=sK(Y),w=(O)=>{let I={...E,...O},T=Oq({r:FY(I.r/255)*255,g:FY(I.g/255)*255,b:FY(I.b/255)*255});W(T),Q(Mq(sK(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 I=O.target.value;if(/^#?[0-9a-f]{6}$/i.test(I))W(Oq(FL(I)))},onKeyDown:(O)=>{if(O.key==="Enter")Q(O.currentTarget.value)},onBlur:(O)=>Q(O.currentTarget.value),onFocus:(O)=>O.currentTarget.select()})]}),D("button",{type:"button",ref:Z,className:"st-cp-cpick-sv","aria-label":X?`${X} saturation and value`:"saturation and value",style:{background:`hsl(${Y.h} 100% 50%)`},onPointerDown:V,onKeyDown:F,children:[z("span",{className:"st-cp-cpick-svwhite"}),z("span",{className:"st-cp-cpick-svblack"}),z("span",{className:"st-cp-cpick-knob",style:{left:`${Y.s*100}%`,top:`${(1-Y.v)*100}%`,background:U}})]}),D("div",{className:"st-cp-cpick-controls",children:[window.EyeDropper?z("button",{type:"button",className:"st-cp-cpick-eye","aria-label":"pick from screen",title:"eyedropper",onClick:A,children:z(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:B,onKeyDown:M,children:z("span",{className:"st-cp-cpick-huethumb",style:{left:`${Y.h/360*100}%`}})})]}),z("div",{className:"st-cp-cpick-rgb",children:["r","g","b"].map((O)=>D("label",{className:"st-cp-cpick-rgbf",children:[z("input",{"aria-label":O.toUpperCase(),value:Math.round(E[O]),onChange:(I)=>w({[O]:FY((Number.parseFloat(I.target.value)||0)/255)*255}),onFocus:(I)=>I.currentTarget.select()}),z("span",{children:O.toUpperCase()})]},O))})]})}function ML({kind:J,groups:X,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:K}){let[U,V]=p.useState(!1),[B,N]=p.useState(null),[F,M]=p.useState("custom"),[A,E]=p.useState(""),w=p.useRef(null),O=p.useRef(null),I=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);p.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 e0=window.innerHeight-z0.bottom>q0+8?z0.bottom+4:Math.max(8,z0.top-q0-4);N({left:Z0,top:e0,width:i,maxHeight:q0})};e();let s=(z0)=>{if(O.current?.contains(z0.target)||w.current?.contains(z0.target))return;V(!1)},H0=(z0)=>{if(z0.key==="Escape")V(!1)},r=(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",r,!0),()=>{document.removeEventListener("pointerdown",s,!0),document.removeEventListener("keydown",H0),window.removeEventListener("resize",e),document.removeEventListener("scroll",r,!0)}},[U]),p.useEffect(()=>{if(!U||!B||!O.current)return;let e=O.current.getBoundingClientRect(),s=B.left-e.left,H0=B.top-e.top;if(Math.abs(s)>0.5||Math.abs(H0)>0.5)N((r)=>r?{...r,left:r.left+s,top:r.top+H0}:r)},[U,B]);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})`);V(!1)},x=(e)=>{let s=(e||"").trim();if(s)Y(s)},h=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})]}),u=(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)),v=(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"}${I&&!K?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>V((e)=>!e),children:z("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):z("button",{type:"button",ref:w,className:`st-cp-tokbtn${I?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>V((e)=>!e),children:z("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),U&&B?g90.createPortal(z("div",{ref:O,className:"maude st-cp-pop","data-theme":typeof document<"u"&&document.documentElement.getAttribute("data-theme")||"dark",role:"dialog","aria-label":W||"design tokens",style:{left:B.left,top:B.top,width:B.width,maxHeight:B.maxHeight},children:J==="color"?D(Q0,{children:[D("div",{className:"st-cp-poptabs",role:"tablist",children:[z("button",{type:"button",role:"tab","aria-selected":F==="custom",className:`st-cp-poptab${F==="custom"?" is-active":""}`,onClick:()=>M("custom"),children:"Custom"}),z("button",{type:"button",role:"tab","aria-selected":F==="vars",className:`st-cp-poptab${F==="vars"?" is-active":""}`,onClick:()=>M("vars"),children:"Variables"})]}),F==="custom"?z(n90,{seed:Z||wL(Q)||"#000000",onApply:x}):!C?z("div",{className:"st-cp-pop-empty",children:"No color tokens"}):D(Q0,{children:[h,m.length?u(m):n]})]}):!C?z("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):D(Q0,{children:[h,m.length?v(m):n]})}),document.body):null]})}function h90({label:J,tracks:X,editable:Q,onChange:Y}){let W=(K,U)=>{let V=X[K];Y(X.map((B,N)=>N===K?vU.has(U)?{value:0,unit:U}:{value:V.value||1,unit:U}:B))},G=(K,U)=>{Y(X.map((V,B)=>B===K?{...V,value:U}:V))},Z=()=>Y([...X,{value:1,unit:"fr"}]),H=(K)=>Y(X.filter((U,V)=>V!==K));return D("div",{className:"st-cp-gridtracks",children:[D("div",{className:"st-cp-gridtracks-hd",children:[z("span",{className:"st-cp-gridtracks-label",children:J}),z("button",{type:"button",className:"st-btn st-cp-gridtracks-add",disabled:!Q,onClick:Z,children:"+ Track"})]}),X.length===0?D("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",J.toLowerCase(),"."]}):X.map((K,U)=>{let V=vU.has(K.unit);return D("div",{className:"st-cp-gridtrack-row",children:[V?z(rW,{value:K.unit,ariaLabel:`${J} track ${U+1}`,options:k90.map((B)=>({value:B,label:B})),onChange:(B)=>W(U,B)}):z(zJ,{value:K.value,min:K.unit==="fr"?0.1:0,step:K.unit==="fr"?0.1:1,ariaLabel:`${J} track ${U+1} value`,lead:String(U+1),unitSlot:z(rN,{value:K.unit,units:k90,ariaLabel:`${J} track ${U+1} unit`,onChange:(B)=>W(U,B)}),onCommit:(B)=>G(U,B)}),z("button",{type:"button",className:"st-btn st-cp-gridtrack-remove","aria-label":`remove ${J} track ${U+1}`,disabled:!Q||X.length<=1,onClick:()=>H(U),children:"×"})]},U)})]})}var tK={pending:0,waiters:[]};function r90(J){tK.pending+=1;let X=()=>{if(tK.pending-=1,tK.pending===0)for(let Q of tK.waiters.splice(0))Q()};return J.then(X,X),J}function dL0(){return tK.pending===0?Promise.resolve():new Promise((J)=>tK.waiters.push(J))}function cL0({el:J,cfg:X,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let K=!!J.id,U=J.computed||{},[V,B]=p.useState({a:{},c:{},t:{}});p.useEffect(()=>{B({a:{},c:{},t:{}})},[J.id,J.authored,J.customStyles,J.attrs]);let N=(t,M0)=>{let E0={...t||{}};for(let[v0,Z8]of Object.entries(M0))if(Z8===null)delete E0[v0];else E0[v0]=Z8;return E0},F=N(J.authored,V.a),M=N(J.customStyles,V.c),A=N(J.attrs,V.t),E=(t,M0)=>B((E0)=>({...E0,a:{...E0.a,[t]:M0}})),w=(t,M0)=>B((E0)=>({...E0,c:{...E0.c,[t]:M0}})),O=(t,M0)=>B((E0)=>({...E0,t:{...E0.t,[t]:M0}})),I=(X?.designRel||X?.designRoot||".design").replace(/^\/+|\/+$/g,""),T=i90(J.file,X),R=o90(X,I,T),$=(t)=>R.map((M0)=>({ds:M0.name,names:M0[t]||[],vals:M0.vals})).filter((M0)=>M0.names.length),[C,j]=p.useState({}),[f,m]=p.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;p.useEffect(()=>{if(c)m((t)=>t.Advanced?t:{...t,Advanced:!0})},[J.id,c]);let o=(F.position||U7(U.position)||"static")!=="static";p.useEffect(()=>{if(o)m((t)=>t["d:Position"]?t:{...t,"d:Position":!0})},[J.id,o]);let x=H,[h,u]=p.useState({});async function v(t,M0,E0){j((v0)=>({...v0,[E0]:"saving"}));try{let v0=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(M0)}),Z8=await v0.json().catch(()=>({}));return j((h8)=>({...h8,[E0]:!v0.ok||!Z8.ok?`err:${Z8&&Z8.error||`HTTP ${v0.status}`}`:"saved"})),v0.ok?Z8:null}catch(v0){return j((Z8)=>({...Z8,[E0]:`err:${v0&&v0.message?v0.message:String(v0)}`})),null}}let n=p.useRef(Promise.resolve()),e=(t,M0,E0,v0,Z8,h8,t8)=>{n.current=r90(n.current.then(async()=>{let v8=await v(t,M0,E0);if(!v8?.ok)return;let W9=Object.hasOwn(v8,"previous")?v8.previous:h8;if((W9??null)===(t8??null))return;H0(v0,Z8,W9,t8)}))},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,E0,v0)=>{Y?.({op:t,canvas:J.file,id:J.id,key:M0,before:E0==null||E0===""?null:E0,after:v0==null||v0===""?null:v0})},r=(t,M0)=>{let E0=(M0||"").trim();if(!K||!E0)return;let v0=F[t]??null;if(E0===(v0??"").trim())return;s(t,E0),E(t,E0),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,value:E0},t,"css",t,v0,E0)},z0=(t,M0)=>{let E0=(M0||"").trim(),v0=t.trim();if(!K||!v0||!E0)return;let Z8=M[v0]??null;s(v0,E0),w(v0,E0),e("/_api/edit-css",{canvas:J.file,id:J.id,property:v0,value:E0},v0,"css",v0,Z8,E0)},i=(t,M0)=>{let E0=(t||"").trim(),v0=(M0||"").trim();if(!K||!E0||!v0)return;let Z8=A[E0]??null;O(E0,v0),e("/_api/edit-attr",{canvas:J.file,id:J.id,attr:E0,value:v0},`@${E0}`,"attr",E0,Z8,v0)},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)},I0=(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)},e0={display:J.parentDisplay,flexDirection:J.parentFlexDirection},J8=(t,M0)=>{if(!K)return;let E0=Math.round((t==="width"?J.bounds?.w:J.bounds?.h)||0),v0=ib(t,M0,e0,E0);for(let Z8 of v0.reset)if(F[Z8])q0(Z8);for(let[Z8,h8]of v0.set)r(Z8,h8)},Y8=J.parentDisplay==="flex"||J.parentDisplay==="inline-flex",P8=(t)=>{let M0=cb(t,F,U,e0);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(aN,{value:M0,ariaLabel:`${t} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(E0)=>J8(t,E0)})})]},`mode-${t}`)},S8=["flex-start","center","flex-end"],a8=["flex-start","center","flex-end"],n0=["t","c","b"],$0=["l","c","r"],w0=()=>{let t=!(F["flex-direction"]||U7(U["flex-direction"])||"row").startsWith("column"),M0=Math.max(0,S8.indexOf(F["justify-content"]||U7(U["justify-content"])||"flex-start")),E0=F["align-items"]||U7(U["align-items"])||"stretch",v0=E0==="stretch"?1:Math.max(0,a8.indexOf(E0)),[Z8,h8]=t?[M0,v0]:[v0,M0];return n0[h8]+$0[Z8]},S0=(t)=>{let M0=n0.indexOf(t[0]),E0=$0.indexOf(t[1]),v0=!(F["flex-direction"]||U7(U["flex-direction"])||"row").startsWith("column"),[Z8,h8]=v0?[E0,M0]:[M0,E0];r("justify-content",S8[Z8]),r("align-items",a8[h8])},H8=(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 u8={bound:"token-bound",raw:"raw override",inherit:"inherited"},y8=(t)=>z("span",{className:`st-cp-prov st-cp-prov--${t}`,role:"img","aria-label":u8[t]}),L9=(t,M0)=>{let E0=M0??X8(t),v0=C[t],Z8=typeof v0==="string"&&v0.startsWith("err:")?v0.slice(4):"",h8=Z8?" is-err":v0==="saved"?" is-saved":v0==="saving"?" is-saving":"",t8=!!F[t],v8=Z8?`error: ${Z8}`:t8?`${u8[E0]} · double-click to reset`:u8[E0];return z("button",{type:"button",className:`st-cp-prov st-cp-prov--${E0}${h8}${t8?" is-resettable":""}`,"aria-label":v8,title:v8,tabIndex:t8?0:-1,onDoubleClick:t8?()=>q0(t):void 0,onKeyDown:t8?(W9)=>{if(W9.key==="Backspace"||W9.key==="Delete")W9.preventDefault(),q0(t)}:void 0})},h0=(t,M0,E0,v0)=>{let Z8=E0===void 0&&!F[t],h8=v0??t;return D("div",{className:`st-cp-row${Z8?" is-unset":""}`,children:[L9(t,E0),z("label",{className:"st-cp-label",title:h8,children:h8}),z("div",{className:"st-cp-ctl",children:M0})]},t)},T8={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"]},A9=(t)=>{(T8[t]||[]).forEach((M0)=>{if(F[M0])q0(M0)})},N8=(t,M0)=>{let E0=(T8[t]||[]).some((v0)=>F[v0]);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((v0)=>({...v0,[t]:!v0[t]})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:f[t]?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${E0?"":" is-quiet"}`,"aria-label":`reset ${t} section to original`,title:`reset ${t}`,disabled:!E0,onClick:()=>A9(t),children:z(K7,{as:cZ,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,E0,v0=!0)=>{let Z8=`d:${t}`,h8=f[Z8]===void 0?v0:f[Z8],t8=M0.some((v8)=>F[v8]);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":h8,onClick:()=>m((v8)=>({...v8,[Z8]:!h8})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:h8?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${t8?"":" is-quiet"}`,"aria-label":`reset ${t} to original`,title:`reset ${t}`,disabled:!t8,onClick:()=>M0.forEach((v8)=>{if(F[v8])q0(v8)}),children:z(K7,{as:cZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${h8?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:E0})})]},Z8)},Q8=(t)=>z("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!h[t],"aria-label":h[t]?`${t} — fewer options`:`${t} — more options`,title:h[t]?"fewer":"more",onClick:()=>u((M0)=>({...M0,[t]:!M0[t]})),children:h[t]?"▴":"···"}),s0=(t,M0)=>D("select",{className:"st-cp-nsel","aria-label":t,value:M0.includes(F[t])?F[t]:"",onChange:(E0)=>r(t,E0.target.value),children:[z("option",{value:"",disabled:!0,children:U7(U[t])||"—"}),M0.map((E0)=>z("option",{value:E0,children:E0},E0))]}),s8=(t)=>$(t).flatMap((M0)=>(M0.names||[]).map((E0)=>({name:E0,value:M0.vals?.[E0]||""}))),k0=(t,M0)=>z(nw,{value:F[t]||U7(U[t])||M0[0].value,ariaLabel:t,options:M0,onChange:(E0)=>r(t,E0)}),r0=(t,M0,E0={})=>{let v0=J4(F[t]??""),Z8=S90.has(t),h8=F[t]??"",t8=typeof h8==="string"&&/var\(\s*--/.test(h8),v8=Z8?"":v0.unit&&v0.unit!=="auto"?v0.unit:"px",W9=Number.parseFloat(J4(U7(U[t])??"").n)||0,T9=v0.n!==""&&v0.n!=null?Number.parseFloat(v0.n)||0:W9,s9=FT[t];return z(sN,{value:t8?h8:T9,tokens:s8(M0),ariaLabel:t,min:E0.min??0,lead:s9?s9.node??s9.t:void 0,unitSlot:Z8?null:z(rN,{units:$90,value:v0.unit||"px",ariaLabel:`${t} unit`,onChange:(t9)=>r(t,t9==="auto"?"auto":`${v0.n||"0"}${t9}`)}),onChange:(t9)=>r(t,typeof t9==="string"?t9:Z8?`${t9}`:`${t9}${v8}`)})},g0=()=>{let t=(Z8)=>Number.parseFloat(J4(F[Z8]??F["border-radius"]??U7(U[Z8])??U7(U["border-radius"])??"0").n)||0,M0={tl:t("border-top-left-radius"),tr:t("border-top-right-radius"),bl:t("border-bottom-left-radius"),br:t("border-bottom-right-radius")},E0=(Z8)=>{if(Z8.tl===Z8.tr&&Z8.tr===Z8.bl&&Z8.bl===Z8.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((t8)=>{if(F[t8])q0(t8)}),r("border-radius",`${Z8.tl}px`);else r("border-top-left-radius",`${Z8.tl}px`),r("border-top-right-radius",`${Z8.tr}px`),r("border-bottom-left-radius",`${Z8.bl}px`),r("border-bottom-right-radius",`${Z8.br}px`)},v0=FT["border-radius"];return z(rg,{corners:M0,lead:v0?v0.node??v0.t:void 0,onCorners:E0})},m0=()=>D("div",{className:"st-cp-border",children:[Q9("border-width",null,{fixedUnit:"px"}),D("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:C90.includes(F["border-style"])?F["border-style"]:"",onChange:(t)=>r("border-style",t.target.value),children:[z("option",{value:"",disabled:!0,children:"style"}),C90.map((t)=>z("option",{value:t,children:t},t))]}),z(ML,{kind:"color",groups:$("color"),current:F["border-color"],activeDs:T,swatchBg:U["border-color"]||F["border-color"]||"",seedHex:wL(U["border-color"]||F["border-color"])||"#000000",onPick:(t)=>r("border-color",t),label:"border colour"})]}),I8=()=>{let t=F.transform||U7(U.transform)||"",M0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(t),E0=((M0?Number.parseFloat(M0[1]):0)%360+360)%360,v0=(Z8)=>{let h8=(Z8%360+360)%360,t8=(F.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();r("transform",`${t8?`${t8} `:""}rotate(${h8}deg)`.trim())};return D("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[z(og,{value:E0,onChange:v0}),z(zJ,{value:E0,min:0,max:360,ariaLabel:"rotation",lead:z(K7,{as:cZ}),steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:v0})]})},O0=()=>{let t=F.filter||U7(U.filter)||"",M0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(t),E0=M0?Number.parseFloat(M0[1]):0;return z(zJ,{value:E0,min:0,ariaLabel:"filter blur",unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(Z8)=>{let h8=(F.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();r("filter",Z8>0?`${h8?`${h8} `:""}blur(${Z8}px)`.trim():h8||"none")}})},G8=()=>{let t=F.opacity,M0=t!=null&&t!==""?Number.parseFloat(t):Number.parseFloat(U7(U.opacity))||1,E0=Math.round((Number.isNaN(M0)?1:M0)*100);return z(vX,{value:E0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(v0)=>s("opacity",String(v0/100)),onCommit:(v0)=>r("opacity",String(v0/100))},`opacity:${t??""}`)},_8=()=>{let t=Number.parseInt(F["font-weight"]||U7(U["font-weight"])||"400",10)>=600,M0=(F["font-style"]||U7(U["font-style"]))==="italic",E0=/underline/.test(F["text-decoration"]||U7(U["text-decoration"])||"");return z(cg,{value:{b:t,i:M0,u:E0},ariaLabel:"text style",options:[{value:"b",node:z(K7,{as:oV}),label:"Bold"},{value:"i",node:z(K7,{as:tV}),label:"Italic"},{value:"u",node:z(K7,{as:K3}),label:"Underline"}],onToggle:(v0)=>{if(v0==="b")r("font-weight",t?"400":"700");else if(v0==="i")r("font-style",M0?"normal":"italic");else r("text-decoration",E0?"none":"underline")}})},V0=[{value:"row",node:z(K7,{as:gW}),label:"Row"},{value:"column",node:z(K7,{as:mW}),label:"Column"}],o0=[{value:"flex-start",node:z(K7,{as:pV}),label:"Start"},{value:"center",node:z(K7,{as:mV}),label:"Center"},{value:"flex-end",node:z(K7,{as:uV}),label:"End"},{value:"space-between",node:z(K7,{as:wK}),label:"Space between"}],k8=[{value:"flex-start",node:z(K7,{as:cV}),label:"Start"},{value:"center",node:z(K7,{as:lV}),label:"Center"},{value:"flex-end",node:z(K7,{as:dV}),label:"End"},{value:"stretch",node:z(K7,{as:H3}),label:"Stretch"}],X9=[{value:"left",node:z(K7,{as:a5}),label:"Left"},{value:"center",node:z(K7,{as:lW}),label:"Center"},{value:"right",node:z(K7,{as:dW}),label:"Right"},{value:"justify",node:z(K7,{as:cW}),label:"Justify"}],c0=[{value:"visible",node:z(K7,{as:dZ}),label:"Visible"},{value:"hidden",node:z(K7,{as:iZ}),label:"Hidden"},{value:"scroll",node:z(K7,{as:W3}),label:"Scroll"}],x7=(t,M0)=>{let E0=$(M0);return E0.length?z(ML,{kind:"value",groups:E0,current:F[t],activeDs:T,onPick:(v0)=>r(t,v0),label:`${t} design token`}):null},D9=(t)=>{let M0=t.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===M0)M0.select()})},h7=(t,M0)=>{if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return!1;t.preventDefault();let E0=t.shiftKey?10:1,v0=t.key==="ArrowUp"?1:-1,Z8=(Number.parseFloat(t.currentTarget.value)||0)+v0*E0;return t.currentTarget.value=String(Z8),M0(Z8),!0},w8=(t)=>z("input",{className:"st-cp-fin","aria-label":t,defaultValue:F[t]??"",placeholder:U7(U[t])||"—",onFocus:D9,onKeyDown:(M0)=>{if(M0.key==="Enter")M0.currentTarget.blur()},onBlur:(M0)=>r(t,M0.currentTarget.value)},`${t}:${F[t]??""}`),Q9=(t,M0,E0={})=>{let v0=J4(F[t]??""),Z8=S90.has(t),h8=Z8?"":E0.fixedUnit||(v0.unit&&v0.unit!=="auto"?v0.unit:"px"),t8=FT[t],v8=Number.parseFloat(J4(U7(U[t])??"").n)||0,W9=v0.n!==""&&v0.n!=null?Number.parseFloat(v0.n)||0:v8;return D(Q0,{children:[z(zJ,{value:W9,min:E0.min??0,step:1,ariaLabel:t,lead:t8?t8.node??t8.t:void 0,onCommit:(T9)=>r(t,Z8?`${T9}`:`${T9}${h8}`),unitSlot:Z8||E0.fixedUnit?null:z(rN,{units:$90,value:v0.unit||"px",ariaLabel:`${t} unit`,onChange:(T9)=>r(t,T9==="auto"?"auto":`${v0.n||"0"}${T9}`)})},`${t}:${F[t]??""}`),x7(t,M0)]})},d8=(t)=>{let M0=U[t]||F[t]||"",E0=F[t]??"",v0=typeof E0==="string"&&/var\(\s*--/.test(E0),Z8=v0?E0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):E0;return z(V3,{swatch:z(ML,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:$("color"),current:F[t],activeDs:T,swatchBg:M0,seedHex:wL(U[t]||F[t])||"#000000",onPick:(h8)=>r(t,h8),label:`${t} colour`}),displayValue:Z8,bound:v0,ariaLabel:t,onValue:(h8)=>r(t,h8)})},A0=(t,M0)=>{let E0=null,v0=M0.unitless?"":"px",Z8=(v8)=>M0.unitless?`${v8}`:`${v8}${v0}`,h8=(v8,W9,T9)=>{for(let s9 of W9??[t])T9(s9,Z8(v8))},t8=ow({getBase:()=>E0?.value??"0",min:M0.min??0,step:1,sides:M0.sides,onInput:(v8,W9)=>{if(E0)E0.value=String(v8);if(W9){let T9=E0?.closest(".st-cp-box");for(let s9 of W9){if(s9===t)continue;let t9=T9?.querySelector(`.st-cp-boxv[aria-label="${s9}"]`);if(t9)t9.value=String(v8)}}h8(v8,W9,s)},onCommit:(v8,W9)=>h8(v8,W9,r)});return{onPointerDown:(v8)=>{E0=v8.currentTarget,t8(v8)}}},U8=(t,M0)=>{let E0=F[t],v0=E0!=null&&E0!==""?J4(E0).n||E0:J4(U7(U[t])??"").n||"0",Z8=!E0||E0==="0"||E0==="0px"||E0==="auto",h8=t.split("-").pop(),t8=h8==="top"||h8==="bottom"?[`${M0}-top`,`${M0}-bottom`]:[`${M0}-left`,`${M0}-right`],v8=[`${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]}${Z8?" is-zero":""}`,"aria-label":t,defaultValue:v0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...A0(t,{sides:{pair:t8,all:v8}}),onFocus:D9,onKeyDown:(W9)=>{if(h7(W9,(T9)=>r(t,`${T9}px`)))return;if(W9.key==="Enter")W9.currentTarget.blur()},onBlur:(W9)=>{let T9=W9.currentTarget.value.trim();if(!T9)return;let s9=/[a-z%]/i.test(T9)?T9:`${T9}px`;r(t,s9)}},`${t}:${E0??""}`)},C8=(t)=>{let M0=F[t],E0=M0!=null&&M0!==""&&M0!=="auto"?J4(M0).n||M0:J4(U7(U[t])??"").n||"",v0=!M0||M0==="auto"||M0==="0"||M0==="0px",Z8=t==="top"||t==="bottom"?["top","bottom"]:["left","right"],h8=["top","right","bottom","left"];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${t[0]}${v0?" is-zero":""}`,"aria-label":t,defaultValue:E0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...A0(t,{sides:{pair:Z8,all:h8},min:-1/0}),onFocus:D9,onKeyDown:(t8)=>{if(h7(t8,(v8)=>r(t,`${v8}px`)))return;if(t8.key==="Enter")t8.currentTarget.blur()},onBlur:(t8)=>{let v8=t8.currentTarget.value.trim();if(!v8)return;let W9=/[a-z%]/i.test(v8)?v8:`${v8}px`;r(t,W9)}},`${t}:${M0??""}`)},V9=Object.entries(M),f9=Object.entries(A),d9=()=>{let t=(J.tag||"").toLowerCase(),E0=t==="img"||t==="video"||t==="picture"||t==="svg"||t==="canvas"||!!F["object-fit"]||!!F["object-position"]||!!F["aspect-ratio"],v0=(t==="img"||t==="video")&&!!J.attrs?.src&&!!W;return{showMedia:E0,canReplace:v0}},x9=(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…"})}),h0("object-fit",s0("object-fit",pL0)),h0("object-position",w8("object-position")),h0("aspect-ratio",D("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:f90.includes(F["aspect-ratio"])?F["aspect-ratio"]:"",onChange:(M0)=>{let E0=M0.target.value;if(r("aspect-ratio",E0),E0&&E0!=="auto"&&F.height)q0("height")},children:[z("option",{value:"",disabled:!0,children:U7(U["aspect-ratio"])||"—"}),f90.map((M0)=>z("option",{value:M0,children:M0},M0))]}))]});return D("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:H8,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(nw,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:z(K7,{as:hW,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:z(K7,{as:iW,size:12}),label:"Designer — Figma vocabulary"}],onChange:x})})]}),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||U7(U.display)||"").trim();return t==="flex"||t==="inline-flex"?D(Q0,{children:[h0("flex-direction",k0("flex-direction",V0),void 0,"Direction"),h0("align-items",z(ig,{value:w0(),onChange:S0,ariaLabel:"auto-layout alignment"}),X8("align-items"),"Alignment"),h0("gap",r0("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:[y8(X8("padding-top")),"padding"]}),U8("padding-top","padding"),U8("padding-right","padding"),U8("padding-bottom","padding"),U8("padding-left","padding")]}),z("div",{className:"st-cp-clustermore-row",children:Q8("Auto layout")}),h["Auto layout"]?h0("flex-wrap",z(nQ,{checked:/^wrap/.test(F["flex-wrap"]||U7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(E0)=>r("flex-wrap",E0?"wrap":"nowrap")}),X8("flex-wrap"),"Wrap"):null]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>r("display","flex"),children:"+ Auto layout (flex)"})})()),B0("Size",["width","height","min-width","max-width","min-height","max-height"],D(Q0,{children:[h0("width",Q9("width"),void 0,"Width"),h0("height",Q9("height"),void 0,"Height"),z("div",{className:"st-cp-clustermore-row",children:Q8("Size")}),h.Size?D(Q0,{children:[h0("min-width",Q9("min-width"),void 0,"Min width"),h0("max-width",Q9("max-width"),void 0,"Max width"),h0("min-height",Q9("min-height"),void 0,"Min height"),h0("max-height",Q9("max-height"),void 0,"Max height")]}):null]})),B0("Position",["position","top","right","bottom","left","z-index"],D(Q0,{children:[h0("position",s0("position",b90),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:[y8(X8("top")),"inset"]}),C8("top"),C8("right"),C8("bottom"),C8("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||U7(U.position)||"static"})]}),(F.position||U7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,z("div",{className:"st-cp-clustermore-row",children:Q8("Position")}),h.Position?h0("z-index",Q9("z-index"),void 0,"Layer order"):null]}),!1),B0("Fill",["background-color"],h0("background-color",d8("background-color"),void 0,"Fill")),B0("Stroke",["border-width","border-style","border-color"],h0("border",m0(),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"],h0("border-radius",g0(),X8("border-radius"),"Corner radius")),B0("Effects",["box-shadow","filter","mix-blend-mode"],D(Q0,{children:[h0("box-shadow",x7("box-shadow","shadow")||w8("box-shadow"),void 0,"Shadow"),h0("filter",O0(),X8("filter"),"Blur"),h0("mix-blend-mode",s0("mix-blend-mode",v90),void 0,"Blend")]})),B0("Opacity",["opacity"],h0("opacity",G8(),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:[h0("font-family",s0("font-family",R90),void 0,"Font"),h0("color",d8("color"),void 0,"Color"),h0("font-size",r0("font-size","type"),void 0,"Size"),h0("font-weight",s0("font-weight",T90),void 0,"Weight"),h0("line-height",Q9("line-height","lh"),void 0,"Line height"),h0("text-align",k0("text-align",X9),void 0,"Align"),z("div",{className:"st-cp-clustermore-row",children:Q8("Text")}),h.Text?D(Q0,{children:[h0("letter-spacing",Q9("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),h0("font-style",s0("font-style",uL0),void 0,"Style"),h0("text-transform",s0("text-transform",y90),void 0,"Case"),h0("white-space",s0("white-space",j90),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:[y8(X8("margin-top")),"margin"]}),U8("margin-top","margin"),U8("margin-right","margin"),U8("margin-bottom","margin"),U8("margin-left","margin")]})),(()=>{let{showMedia:t,canReplace:M0}=d9();return t?B0("Media",["object-fit","object-position","aspect-ratio"],x9(M0)):null})()]}):D(Q0,{children:[N8("Layout",(()=>{let t=(F.display||U7(U.display)||"").trim(),M0=t==="flex"||t==="inline-flex",E0=t==="grid"||t==="inline-grid";return D(Q0,{children:[h0("display",s0("display",gL0)),M0?D(Q0,{children:[h0("flex-direction",k0("flex-direction",V0)),h0("flex-wrap",z(nQ,{checked:/^wrap/.test(F["flex-wrap"]||U7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(v0)=>r("flex-wrap",v0?"wrap":"nowrap")}),X8("flex-wrap"))]}):null,M0||E0?D(Q0,{children:[h0("align-items",k0("align-items",k8)),h0("justify-content",k0("justify-content",o0)),h0("gap",r0("gap","space"))]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>r("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let t=(F.display||U7(U.display)||"").trim();if(!(t==="grid"||t==="inline-grid"))return null;let E0=F["grid-template-columns"]||"",v0=F["grid-template-rows"]||"",Z8=jO(E0),h8=jO(v0),t8=Z8.length>0||!E0.trim(),v8=h8.length>0||!v0.trim();return N8("Grid",D(Q0,{children:[t8?z(h90,{label:"Columns",tracks:Z8,editable:K,onChange:(W9)=>r("grid-template-columns",vO(W9))}):D("div",{className:"st-cp-note",children:["Columns use ",z("code",{children:E0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),v8?z(h90,{label:"Rows",tracks:h8,editable:K,onChange:(W9)=>r("grid-template-rows",vO(W9))}):D("div",{className:"st-cp-note",children:["Rows use ",z("code",{children:v0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),N8("Position",D(Q0,{children:[h0("position",s0("position",b90)),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:[y8(X8("top")),"inset"]}),C8("top"),C8("right"),C8("bottom"),C8("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||U7(U.position)||"static"})]}),(F.position||U7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,h0("z-index",Q9("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"}),"."]}),h0("grid-column",w8("grid-column")),h0("grid-row",w8("grid-row"))]})),N8("Typography",D(Q0,{children:[h0("font-family",s0("font-family",R90)),h0("color",d8("color")),h0("font-size",r0("font-size","type")),h0("font-weight",s0("font-weight",T90)),h0("line-height",Q9("line-height","lh")),h0("letter-spacing",Q9("letter-spacing",null,{min:-1/0})),h0("text-align",k0("text-align",X9)),h0("font-style",_8(),X8("font-style")),h0("text-transform",s0("text-transform",y90)),h0("white-space",s0("white-space",j90))]})),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:[y8(X8("margin-top")),"margin"]}),U8("margin-top","margin"),U8("margin-right","margin"),U8("margin-bottom","margin"),U8("margin-left","margin"),D("div",{className:"st-cp-boxpad",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[y8(X8("padding-top")),"padding"]}),U8("padding-top","padding"),U8("padding-right","padding"),U8("padding-bottom","padding"),U8("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")]}),h0("width",Q9("width")),h0("height",Q9("height")),h0("min-width",Q9("min-width")),h0("max-width",Q9("max-width")),h0("min-height",Q9("min-height")),h0("max-height",Q9("max-height")),h0("overflow",k0("overflow",c0)),Y8?D(Q0,{children:[z("div",{className:"st-cp-subhd",children:"In flex parent"}),h0("align-self",s0("align-self",mL0)),h0("flex-grow",Q9("flex-grow",null,{unitless:!0})),h0("flex-shrink",Q9("flex-shrink",null,{unitless:!0})),h0("flex-basis",Q9("flex-basis"))]}):null]})),(()=>{let{showMedia:t,canReplace:M0}=d9();return t?N8("Media",x9(M0)):null})(),N8("Appearance",D(Q0,{children:[h0("background-color",d8("background-color")),h0("border-radius",g0(),X8("border-radius")),h0("border",m0(),X8("border-width")),h0("box-shadow",x7("box-shadow","shadow")||w8("box-shadow")),h0("filter",O0(),X8("filter")),h0("mix-blend-mode",s0("mix-blend-mode",v90)),h0("opacity",G8()),h0("rotation",I8(),X8("transform")),h0("transform",w8("transform")),h0("transform-origin",w8("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:[V9.length?D(Q0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),V9.map(([t,M0])=>D("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:t,"aria-label":`custom property ${t} name`}),z("input",{className:"st-cp-fin",defaultValue:M0,"aria-label":`${t} value`,onKeyDown:(E0)=>{if(E0.key==="Enter")E0.currentTarget.blur()},onBlur:(E0)=>z0(t,E0.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(iL0,{commit:z0}),z("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),f9.length?D(Q0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),f9.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:(E0)=>{if(E0.key==="Enter")E0.currentTarget.blur()},onBlur:(E0)=>i(t,E0.currentTarget.value)},`at:${t}:${M0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>I0(t),children:z(k9,{name:"x",size:11})})]},`at:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),z(oL0,{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 iL0({commit:J}){let[X,Q]=p.useState(""),[Y,W]=p.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 oL0({commit:J}){let[X,Q]=p.useState(""),[Y,W]=p.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 nL0={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function rL0(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 aL0=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function a90({node:J,depth:X,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:V,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:M,onToggleLock:A,onRename:E}){let w=`${J.id}:${J.index}`,O=J.children&&J.children.length>0,I=W.has(w),T=!!J.synthetic,R=!T&&F?F[J.id]:null,$=!T&&!!M?.has(w),[C,j]=p.useState(!1),[f,m]=p.useState(""),c=!T&&J.id===Q&&(Y==null||J.index===Y),o=G?.has(w)?G.get(w):!!J.hidden,x=!!V&&!T&&!$,h=()=>{j(!1);let n=f.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!n||n===(J.dcElement??""))return;E?.(J,n)},u=N?.key===w,v=u?{transform:`translate(${N.dx}px, ${N.dy}px)`,opacity:0.9,zIndex:20,position:"relative",pointerEvents:"none",cursor:"grabbing",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.28)"}:null;return D(Q0,{children:[D("div",{className:"st-layer st-layer--row"+(c?" is-sel":"")+(o?" is-hidden":"")+(T?" is-group":"")+(R?" is-instance":"")+($?" is-locked":""),style:{paddingLeft:6+X*14,...v},role:"treeitem","aria-selected":T?void 0:c,"aria-expanded":O?!I:void 0,"aria-grabbed":x?u: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:x?(n)=>B(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":I?"Expand":"Collapse",onClick:(n)=>{n.stopPropagation(),Z(w)},children:I?"▸":"▾"}):z("span",{className:"st-layer-caret","aria-hidden":"true"}),R?z("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:R.root?"◆":"◇"}):z(k9,{name:nL0[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:h,onKeyDown:(n)=>{if(n.stopPropagation(),n.key==="Enter")h();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&&!I?J.children.map((n,e)=>z(a90,{node:n,depth:X+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:V,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:M,onToggleLock:A,onRename:E},`${n.id}:${n.index}`)):null]})}function sL0({el:J}){let X=J?.computed||{},Q=J?.authored||{},Y=(U)=>{let V=Q[U];if(V&&/var\(\s*--/.test(V))return V.replace(/^var\(\s*|\s*\)$/g,"");return X[U]||V||""},W=(U,V)=>{let B=X[V]||Q[V];if(!B)return null;return D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:U}),D("div",{className:"st-swatch-row",children:[z("span",{className:"st-insp-swatch",style:{background:B},"aria-hidden":"true"}),z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Y(V)})]})]},U)},G=X["border-radius"]&&X["border-radius"]!=="0px",Z=G?J4(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 s90(J){if(J.artboardId)return J.artboardId;let X=/^\[data-dc-screen="([^"]+)"\]$/.exec(J.selector||"");return X?X[1]:null}var tL0=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],eL0=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function JD0({el:J,cfg:X,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let K=s90(J),U=(X?.designRel||X?.designRoot||".design").replace(/^\/+|\/+$/g,""),V=i90(J.file,X),B=o90(X,U,V),N=(v)=>B.map((n)=>({ds:n.name,names:n[v]||[],vals:n.vals})).filter((n)=>n.names.length),F=(v)=>N(v).flatMap((n)=>(n.names||[]).map((e)=>({name:e,value:n.vals?.[e]||""}))),M=(v)=>{let n=/^var\(\s*(--[\w-]+)\s*\)$/.exec(v||"");if(!n)return v||"";for(let e of B){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=(v,n)=>{if(!K)return;let e=Number.isFinite(v)&&v>0?Math.round(v):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(b5).find(([,v])=>v.width===A&&v.height===E)?.[0],I=Object.entries(b5).find(([,v])=>v.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=(v)=>{if(!K)return;let n=null;if(v==="print"&&!m){let e={paper:"a4"};try{let s=WB(e);if(s)n={defaults:e,widthPx:s.widthPx,heightPx:s.heightPx}}catch{}}if(G?.(K,v==="digital"?null:v,n),v==="web"&&T)Y?.(K,!1,void 0)},o=(v)=>{if(!K)return;let n={paper:"a4",...m,...v},e;try{e=WB(n)}catch{return}Q?.(K,e.widthPx,e.heightPx),Z?.(K,n)},x=(v,n)=>{if(!K)return;let e=Number.isFinite(n)?n:E,s=v&&Number.isFinite(e)?Math.round(e):void 0;Y?.(K,v,s)},h=(v)=>{let n=pb(T,v);if(n.kind==="resize")w(null,n.height);else if(n.kind==="promote-to-fixed")x(!0,n.height)},u=(v)=>{if(!K)return;W?.(K,v)};return D("section",{className:"st-cp-sec",children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Artboard"})}),D("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[z(zJ,{value:A??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(v)=>w(v,null)}),z(zJ,{value:E??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:T,onCommit:h})]}),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:(v)=>o({paper:v.currentTarget.value}),children:[z("option",{value:"",disabled:!0,children:"Paper size…"}),YB.map((v)=>D("option",{value:v.id,children:[v.label," — ",v.width,"×",v.height,v.unit]},v.id))]}):f==="web"?D("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:I??"",onChange:(v)=>{let n=b5[v.currentTarget.value];if(n)w(n.width,null)},children:[z("option",{value:"",disabled:!0,children:I?`${b5[I].label} — ≤ ${b5[I].width}px`:"Breakpoint…"}),Object.entries(b5).map(([v,n])=>D("option",{value:v,children:[n.label," — ≤ ",n.width,"px breakpoint"]},v))]}):D("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:O??"",onChange:(v)=>{let n=b5[v.currentTarget.value];if(n)w(n.width,n.height)},children:[z("option",{value:"",disabled:!0,children:O?b5[O].label:"Preset size…"}),Object.entries(b5).map(([v,n])=>D("option",{value:v,children:[n.label," — ",n.width,"×",n.height]},v))]})}),z("div",{style:{padding:"0 12px 8px"},children:z(aN,{value:T?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(v)=>x(v==="fixed")})}),z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Kind"})}),z("div",{style:{padding:"0 12px 8px"},children:z(rW,{value:f,ariaLabel:"artboard kind",options:eL0.map(([v,n])=>({value:v,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:(v)=>{let n=b5[v.currentTarget.value];if(n)H(K,n.width);v.currentTarget.value=""},children:[z("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(b5).map(([v,n])=>D("option",{value:v,children:[n.label," — ",n.width,"px"]},v))]})}):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(aN,{value:m?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(v)=>o({orientation:v})})}),z("div",{style:{padding:"0 12px 8px"},children:z(zJ,{value:Number.isFinite(m?.bleedMm)?m.bleedMm:3,min:0,step:0.5,ariaLabel:"bleed, millimeters",lead:"B",steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"mm"}),onCommit:(v)=>o({bleedMm:v})})})]}):null,z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Style"})}),D("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let v=M(R),n=/var\(\s*--/.test(R),e=n?R.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):R;return z(V3,{swatch:z(ML,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:N("color"),current:R,activeDs:V,swatchBg:v,seedHex:wL(v)||"#000000",onPick:(s)=>u({background:s||null}),label:"artboard background colour"}),displayValue:e,bound:n,ariaLabel:"artboard background",onValue:(s)=>u({background:(s||"").trim()||null})})})(),z(rW,{value:C,ariaLabel:"artboard body layout",options:tL0.map(([v,n])=>({value:v,label:n})),onChange:(v)=>u({layout:v||null})}),D("div",{style:{display:"flex",gap:8},children:[z(sN,{value:/^var\(/.test($)?$:Number.parseFloat($)||0,tokens:F("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(v)=>u({padding:typeof v==="string"?v:v>0?v:null})}),z(sN,{value:/^var\(/.test(j)?j:Number.parseFloat(j)||0,tokens:F("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(v)=>u({gap:typeof v==="string"?v:v>0?v:null})})]})]})]})}var MT=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,XD0=new RegExp(MT.source,"gi");function QD0(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(XD0)||[])],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=MT.exec(`${J.attrs?.src||""} ${X}`);return Y?Y[0]:null}function YD0({testId:J,selected:X,onClose:Q,layersTree:Y,componentMap:W,lockedKeys:G,onToggleLock:Z,onDetachInstance:H,canvasFile:K,onSelectLayer:U,onHoverLayer:V,onReorderLayer:B,layersBusyRef:N,cfg:F,onOptimistic:M,onRecordEdit:A,onReplaceMedia:E,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:I,onSetArtboardKind:T,onSetArtboardPrint:R,onDuplicateArtboard:$,onUndoRedo:C,editScope:j,tab:f,onTabChange:m,width:c,resizing:o,photoSel:x,photoRev:h,onPhotoEdit:u,onPhotoRemoveBackground:v,onPhotoRecordEdit:n,onPhotoUndoRedo:e,layersOnly:s=!1,hideLayersTab:H0=!1,cpMode:r,onSetCpMode:z0}){let[i,q0]=p.useState("inspect"),Z0=s?"layers":f??i,I0=(g0)=>{q0(g0),m?.(g0)},[e0,J8]=p.useState(()=>new Set),[Y8,P8]=p.useState(()=>new Map);p.useEffect(()=>{let g0=Array.isArray(X)?X[0]:X,m0=g0?.id;if(!m0||!Y?.nodes)return;let I8=g0.index,O0=null,G8=[];if(function _8(V0,o0){for(let k8 of V0||[]){let X9=`${k8.id}:${k8.index}`;if(!k8.synthetic&&k8.id===m0&&(I8==null||k8.index===I8))return O0=X9,G8.push(...o0),!0;if(k8.children&&k8.children.length&&_8(k8.children,[...o0,X9]))return!0}return!1}(Y.nodes,[]),!O0)return;if(G8.length)J8((_8)=>{let V0=!1,o0=new Set(_8);for(let k8 of G8)if(o0.delete(k8))V0=!0;return V0?o0:_8});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${O0}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[X,Y]);let S8=(g0)=>{let m0=`${g0.id}:${g0.index}`;return Y8.has(m0)?Y8.get(m0):!!g0.hidden},[a8,n0]=p.useState(null),[$0,w0]=p.useState(""),S0=(g0,m0)=>{if(!K||!g0?.id)return;r90(fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:K,id:g0.id,attr:"data-dc-element",value:m0})}).then((I8)=>I8.json().catch(()=>({}))).then((I8)=>{if(!I8.ok)return;A?.({op:"attr",canvas:K,id:g0.id,key:"data-dc-element",before:g0.dcElement??null,after:m0})}).catch(()=>{}))},H8=B?(g0,m0,I8)=>{if(N?.current)return;if(g0?.synthetic||m0?.synthetic)return;let O0=I8==="before"?`before ${m0.label}`:I8==="after"?`after ${m0.label}`:`into ${m0.label}`;w0(`Moved ${g0.label} ${O0}`),B(g0.id,m0.id,I8,{idIndex:g0.index,refIndex:m0.index})}:void 0,X8=()=>{let g0=[];return function m0(I8,O0,G8){(I8||[]).forEach((_8,V0)=>{if(g0.push({node:_8,depth:O0,parentNode:G8,siblings:I8,pos:V0}),_8.children&&_8.children.length&&!e0.has(`${_8.id}:${_8.index}`))m0(_8.children,O0+1,_8)})}(Y?.nodes,0,null),g0},u8=(g0)=>{if(g0.key!=="ArrowUp"&&g0.key!=="ArrowDown")return;if(!N8)return;let m0=X8(),I8=m0.findIndex((V0)=>V0.node.id===N8.id&&V0.node.index===N8.index);if(I8<0)return;let O0=g0.key==="ArrowDown"?1:-1,G8=m0[I8];if(!g0.altKey){let V0=m0[I8+O0];if(V0)g0.preventDefault(),U?.(V0.node);return}if(!H8||!Array.isArray(G8.siblings))return;g0.preventDefault();let _8=(V0)=>V0&&V0.children&&V0.children.length&&!e0.has(`${V0.id}:${V0.index}`);if(!g0.shiftKey){if(O0<0&&G8.pos>0)H8(G8.node,G8.siblings[G8.pos-1],"before");else if(O0>0&&G8.pos<G8.siblings.length-1)H8(G8.node,G8.siblings[G8.pos+1],"after");return}if(O0>0){let V0=G8.siblings[G8.pos+1];if(V0)H8(G8.node,V0,_8(V0)?"inside-start":"after");else if(G8.parentNode)H8(G8.node,G8.parentNode,"after")}else{let V0=G8.siblings[G8.pos-1];if(V0)H8(G8.node,V0,_8(V0)?"inside-end":"before");else if(G8.parentNode)H8(G8.node,G8.parentNode,"before")}},y8=p.useRef(null),L9=p.useRef(null),h0=(g0,m0,I8)=>{if(!H8||g0.button!==0||g0.metaKey||g0.ctrlKey||g0.shiftKey||g0.altKey)return;if(N?.current)return;let{clientX:O0,clientY:G8}=g0,_8=new Set([I8]);(function d8(A0){(A0.children||[]).forEach((U8)=>{_8.add(`${U8.id}:${U8.index}`),d8(U8)})})(m0);let V0=14,o0=6,k8=[];(function d8(A0,U8){(A0||[]).forEach((C8)=>{let V9=`${C8.id}:${C8.index}`;if(k8.push({node:C8,key:V9,id:C8.id,depth:U8,tag:C8.tag}),C8.children&&C8.children.length&&!e0.has(V9))d8(C8.children,U8+1)})})(Y?.nodes,0);let X9=new Map(k8.map((d8)=>[d8.key,d8])),c0=!1,x7=(d8)=>{if(!c0){if(Math.hypot(d8.clientX-O0,d8.clientY-G8)<4)return;c0=!0}let A0=d8.clientX-O0,U8=d8.clientY-G8,C8=null,V9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((d9)=>({rect:d9.getBoundingClientRect(),it:X9.get(d9.getAttribute("data-layer-key"))})).filter((d9)=>d9.it&&d9.it.key!==I8);if(V9.length){let d9=V9[0].rect.left,x9=V9[0].rect.right,t=V9.length;for(let s9=0;s9<V9.length;s9++)if(d8.clientY<V9[s9].rect.top+V9[s9].rect.height/2){t=s9;break}let M0=V9[t-1]?.it||null,E0=V9[t]?.it||null,v0=Math.round((d8.clientX-d9-o0)/V0),Z8=M0?M0.depth+(aL0.has(M0.tag)?0:1):0,h8=E0?E0.depth:0,t8=Math.max(h8,Math.min(v0,Z8)),v8=null,W9="before",T9=0;if(!M0){if(E0)v8=E0,W9="before",T9=E0.depth}else if(t8>M0.depth)v8=M0,W9="inside-start",T9=M0.depth+1;else if(t8===M0.depth)v8=M0,W9="after",T9=M0.depth;else{for(let s9=t-1;s9>=0;s9--)if(V9[s9].it.depth===t8){v8=V9[s9].it;break}if(!v8)v8=M0;W9="after",T9=t8}if(v8&&v8.key!==I8&&!_8.has(v8.key)){let s9=M0?V9[t-1].rect.bottom:V9[0].rect.top,t9=d9+o0+T9*V0;C8={refId:v8.id,position:W9,node:v8.node,y:s9,left:t9,w:Math.max(24,x9-t9)}}}let f9={key:I8,node:m0,dx:A0,dy:U8,target:C8};y8.current=f9,n0(f9)},D9=()=>{window.removeEventListener("pointermove",x7),window.removeEventListener("pointerup",w8),window.removeEventListener("keydown",Q9,!0)},h7=()=>{let d8=(A0)=>{A0.preventDefault(),A0.stopImmediatePropagation(),document.removeEventListener("click",d8,!0)};document.addEventListener("click",d8,!0),setTimeout(()=>document.removeEventListener("click",d8,!0),300)},w8=()=>{D9();let d8=y8.current;if(y8.current=null,n0(null),c0&&d8?.target)h7(),H8(d8.node,d8.target.node,d8.target.position)},Q9=(d8)=>{if(d8.key!=="Escape")return;if(d8.preventDefault(),d8.stopImmediatePropagation(),D9(),y8.current=null,n0(null),c0)h7()};window.addEventListener("pointermove",x7),window.addEventListener("pointerup",w8),window.addEventListener("keydown",Q9,!0)},T8=(g0)=>J8((m0)=>{let I8=new Set(m0);if(I8.has(g0))I8.delete(g0);else I8.add(g0);return I8}),A9=(g0)=>{let m0=`${g0.id}:${g0.index}`,I8=S8(g0),O0=!I8;if(P8((G8)=>new Map(G8).set(m0,O0)),M?.({id:g0.id,artboardId:Y?.artboardId??null,index:g0.index,prop:"display",value:O0?"none":null}),!K||!g0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(O0?{canvas:K,id:g0.id,property:"display",value:"none"}:{canvas:K,id:g0.id,property:"display",reset:!0})}).catch(()=>{}),A?.({op:"css",canvas:K,id:g0.id,key:"display",before:I8?"none":null,after:O0?"none":null})},N8=Array.isArray(X)?X[0]:X,B0=x?{asset:x.asset,kind:"annotation-image"}:(()=>{let g0=QD0(N8);return g0?{asset:g0,kind:"artboard-img"}:null})(),Q8=B0?.kind==="annotation-image",s0=(g0)=>{if(!(g0.metaKey||g0.ctrlKey)||g0.altKey)return;let m0=g0.key.toLowerCase();if(m0==="z")g0.preventDefault(),e?.(g0.shiftKey?"redo":"undo");else if(m0==="y")g0.preventDefault(),e?.("redo")},s8=Q8?"photo":Z0==="photo"&&!B0?"css":Z0,k0=(g0,m0,I8)=>D("button",{type:"button",className:"st-rp-tab"+(s8===g0?" is-active":""),onClick:()=>I0(g0),children:[z(k9,{name:I8,size:14}),m0]}),r0=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:[Q8?k0("photo","Photo","image"):D(Q0,{children:[k0("inspect","Inspect","sliders"),!H0&&k0("layers","Layers","layers"),k0("css","CSS","code"),B0?k0("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:s8==="photo"&&B0?z("div",{onKeyDown:s0,children:z(Om,{asset:B0.asset,ColorPicker:n90,StIcon:k9,onEdit:(g0)=>u?.(B0.asset,g0),onRemoveBackground:v,onRecordEdit:(g0,m0)=>n?.(B0.asset,g0,m0)},`${B0.asset}:${h??0}`)}):!N8&&!(s8==="layers"&&Y?.nodes?.length)?z("div",{className:"st-rp-empty",children:D("p",{children:["Press ",z(TJ,{children:"V"}),", then click an element to select it — or ",z(TJ,{children:"⌘"}),"-click straight from Browse."]})}):N8&&s8==="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:r0?Math.round(r0.x):"—",readOnly:!0,"aria-label":"x position"})]}),D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"Y"}),z("input",{value:r0?Math.round(r0.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:r0?Math.round(r0.w):"—",readOnly:!0,"aria-label":"width"})]}),D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"H"}),z("input",{value:r0?Math.round(r0.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(sL0,{el:N8})]}):s8==="layers"?D(Q0,{children:[D("div",{className:"st-rp-hd",children:["Layers",Y?.nodes?.length?"":" · ancestry"]}),Y?.nodes?.length?D(Q0,{children:[H8?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:L9,onKeyDown:u8,children:Y.nodes.map((g0,m0)=>z(a90,{node:g0,depth:0,selectedId:N8?.id,selectedIndex:N8?.index,collapsed:e0,hiddenOverride:Y8,onToggle:T8,onSelect:(I8)=>{U?.(I8),L9.current?.focus()},onHover:(I8)=>V?.(I8),onToggleVisibility:A9,onReorder:H8,onRowPointerDown:h0,dragState:a8,componentMap:W,lockedKeys:G,onToggleLock:Z,onRename:S0},`${g0.id}:${g0.index}`))}),a8?.target?z("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:a8.target.left,top:a8.target.y-1,width:a8.target.w}}):null,z("div",{className:"sr-only",role:"status","aria-live":"polite",children:$0})]}):N8&&Array.isArray(N8.dom_path)&&N8.dom_path.length?N8.dom_path.map((g0,m0)=>D("div",{className:"st-layer"+(m0===N8.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+m0*12},children:[z(k9,{name:"square",size:13}),g0]},m0)):z("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!N8.id&&s90(N8)?z(JD0,{el:N8,cfg:F,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:I,onSetArtboardKind:T,onSetArtboardPrint:R,onDuplicateArtboard:$}):z(cL0,{el:N8,cfg:F,onOptimistic:M,onRecordEdit:A,onReplaceMedia:E,onUndoRedo:C,mode:r,onSetMode:z0})})]})}function WD0(){let[J,X]=p.useState([]),[Q,Y]=p.useState(!1),W=p.useRef("push"),G=p.useRef(null),[Z,H]=p.useState("Design"),[K,U]=p.useState([]),[V,B]=p.useState(null),[N,F]=p.useState(null),M=p.useCallback((b)=>{W.current="push",F(b)},[]),[A,E]=p.useState(null),w=p.useRef(null);p.useEffect(()=>{w.current=A},[A]);let[O,I]=p.useState(null);p.useEffect(()=>{let b=Array.isArray(A)?A.length===1?A[0]:null:A,S=b&&typeof b.id==="string"?b.id:null;if(!S||!V){I(null);return}let 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)I(K0)}).catch(()=>{}),()=>d.abort()},[A,V]);let T=p.useRef(0),R=p.useRef([]),$=p.useCallback((b)=>{if(!b?.id||!b.file)return;for(let S of R.current)clearTimeout(S);R.current=[50,450,1200,2500,5000].map((S)=>setTimeout(()=>{let d=w.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))},[]),C=p.useRef([]),j=p.useCallback((b,S)=>{if(!b||!S)return;for(let d of C.current)clearTimeout(d);C.current=[50,450,1200,2500,5000].map((d)=>setTimeout(()=>{let X0=w.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))},[]),f=p.useRef(null),m=p.useRef(null),c=p.useRef(null);c.current=(b,S,d)=>{let X0=f.current;if(!X0||!X0.movedId)return;if(X0.staleSig!=null&&S===X0.staleSig)return;if(!function _0(l){return(l||[]).some((L0)=>L0.id===X0.movedId||_0(L0.children))}(b))return;f.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 o=p.useRef(null),x=p.useRef(null),h=p.useRef(null),u=p.useRef(!1),v=p.useRef(null),[n,e]=p.useState(null),[s,H0]=p.useState(null),r=p.useRef({canvas:null,at:0});p.useEffect(()=>{if(!V||!n)return;let b=Date.now(),S=r.current;if(S.canvas===V&&b-S.at<1500)return;r.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")H0(d.map);else H0(null)}).catch(()=>H0(null))},[V,n]);let[z0,i]=p.useState(!1),[q0,Z0]=p.useState(null),[I0,e0]=p.useState(null),J8=p.useRef(null);p.useEffect(()=>{let b=I0?.files?.progress;if(!b)return;let S=J8.current;if(J8.current=b.phase,S===null||S===b.phase)return;if(b.phase==="converged"&&(S==="seeding"||S==="paused"))BL("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);BL("Sync needs a decision",`${d} file${d===1?"":"s"} could not be sent. Open the Sync panel for the reason.`)}},[I0?.files?.progress]),p.useEffect(()=>{if(typeof document>"u")return;let b=I0?.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},[I0?.files?.progress]);let[Y8,P8]=p.useState(null),[S8,a8]=p.useState(null),[n0,$0]=p.useState(null),[w0,S0]=p.useState(null),[H8,X8]=p.useState(!1),[u8,y8]=p.useState(!1),[L9,h0]=p.useState(null),[T8,A9]=p.useState(""),[N8,B0]=p.useState(null),[Q8,s0]=p.useState(null),s8=p.useRef(null),[k0,r0]=p.useState(null),[g0,m0]=p.useState(0),[I8,O0]=p.useState(null),G8=A90("maude-sb-w",{min:200,max:420,def:252}),_8=A90("maude-rp-w",{min:260,max:480,def:304}),[V0,o0]=p.useState(null),k8=p.useRef(null);p.useEffect(()=>{if(!V0)return;let b=(d)=>{let X0=k8.current?.getBoundingClientRect();if(!X0)return;if(V0==="sb")G8.setW(d.clientX-X0.left);else _8.setW(X0.right-d.clientX)},S=()=>o0(null);return window.addEventListener("pointermove",b),window.addEventListener("pointerup",S),()=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",S)}},[V0,G8.setW,_8.setW]);let X9=p.useCallback((b)=>{clearTimeout(s8.current),s8.current=setTimeout(()=>{s0((S)=>S===b?null:S)},2500)},[]),[c0,x7]=p.useState({designRel:".design",cloud:void 0});p.useEffect(()=>{if(!Q8)return;let b=Q8,S=setTimeout(async()=>{let d="compile";try{if(!(await fetch(`${c0?.canvasOrigin||""}/_health`,{cache:"no-store"})).ok)d="server"}catch{d="server"}r0({path:b,kind:d}),s0((X0)=>X0===b?null:X0)},15000);return()=>clearTimeout(S)},[Q8,c0?.canvasOrigin]);let D9=!!c0.cloud,h7=!c0.cloud&&!!Y8?.credentialed,w8=D9||h7,Q9=w8?0:n0?.files?.length||0,d8=p.useRef(w8);d8.current=w8;let A0=!!c0.readOnly,U8=p.useCallback(()=>{fetch("/_config").then((b)=>b.json()).then((b)=>{let S=(b.designRoot||".design").replace(/^\/+|\/+$/g,"");x7((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(()=>{})},[]);p.useEffect(()=>{U8()},[U8]),p.useEffect(()=>{let b=!1;return fetch("/_sync-status").then((S)=>S.json()).then((S)=>{if(b||!S||S.linked===!1)return;e0(S)}).catch(()=>{}),()=>{b=!0}},[]),p.useEffect(()=>{if(w8){$0(null);return}let b=!1;return fetch("/_api/git/status").then((S)=>S.json()).then((S)=>{if(!b&&S)$0(S)}).catch(()=>{}),()=>{b=!0}},[w8]);let[C8,V9]=p.useState({}),[f9,d9]=p.useState(null),[x9,t]=p.useState(!1),[M0,E0]=p.useState("open"),[v0,Z8]=p.useState(lF0),[h8,t8]=p.useState(()=>{return D90(K90,"advanced")==="designer"?"designer":"advanced"});p.useEffect(()=>{try{localStorage.setItem(K90,JSON.stringify(h8))}catch{}},[h8]);let[v8,W9]=p.useState(null),[T9,s9]=p.useState(()=>EH(U90,!0)),[t9,LQ]=p.useState(()=>EH(z90,!1)),BJ=rm(),V7=BJ.update,dJ=BJ.state.sections,[DQ,$7]=p.useState(!1),[PH,M7]=p.useState(!1);p.useEffect(()=>{if(!G9())return;let b=Dh(()=>M7(!0));return()=>{b.then((S)=>S()).catch(()=>{})}},[]);let[dX,b9]=p.useState(!1),[VG,g7]=p.useState(!1),[Y4,W4]=p.useState(!1),[c7,G4]=p.useState(!1),[cX,q7]=p.useState(!1),{report:RJ}=lw(G9()),[X7,Q7]=p.useState(!1),[j6,CJ]=p.useState(!1),[iX,Z4]=p.useState(null),[zX,$J]=p.useState(null),[H4,MQ]=p.useState(!1),[KX,oX]=p.useState(!1),[i6,nX]=p.useState(!1),[LY,z4]=p.useState(!1),[o6,a]=p.useState(()=>D90(N90,rK)),[Y0,D0]=p.useState(()=>{try{let b=localStorage.getItem(F90);if(b==="separate"||b==="in-inspector")return b}catch{}return"separate"}),[b0,T0]=p.useState(!1),[t0,D8]=p.useState([]),[Z9,q9]=p.useState(0),[UX,SJ]=p.useState(!1),[P6,VX]=p.useState(!1),[qX,qG]=p.useState(!1),[BG,bJ]=p.useState(1),[S7,Y7]=p.useState(216),[i7,n6]=p.useState(null),[c8,e7]=p.useState([]),[r6,cJ]=p.useState([]),[K4,DY]=p.useState([]),[OQ,rX]=p.useState(0),NG=p.useRef(0);p.useEffect(()=>{NG.current=Z9},[Z9]);let[Q6,aX]=p.useState(null),FG=p.useRef(null);p.useEffect(()=>{FG.current=Q6},[Q6]);let Y6=p.useMemo(()=>aw(t0,{artboardId:[Q6,i7],total:OQ}),[t0,Q6,i7,OQ]),AQ=p.useRef(null);p.useEffect(()=>{AQ.current=Y6},[Y6]);let MY=p.useMemo(()=>PK(t0,Y6)?.fps||30,[t0,Y6]),[IH,_Q]=p.useState(null),[kH,J1]=p.useState(0),NJ=p.useCallback((b,S)=>{if(/concurrent edit|changed since it was read/i.test(S||""))x8("Timeline changed — reloaded, try again."),J1((d)=>d+1);else x8(`${b}: ${S||"failed"}`)},[]),[BX,LG]=p.useState(!1),[X1,TH]=p.useState(!1),[Q1,DG]=p.useState(!1),MG=p.useRef(BX);p.useEffect(()=>{if(MG.current=BX,BX){DG(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[BX]);let RH=p.useCallback(()=>{if(!MG.current||document.hidden)DG(!0),BL("Claude finished","Your assistant turn is ready in Maude.")},[]),CH=p.useRef(0),wQ=p.useCallback(()=>{if(!MG.current||document.hidden){DG(!0);let b=Date.now();if(b-CH.current<gF0)return;CH.current=b,BL("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[j5,sX]=p.useState("inspect"),[Y1,OY]=p.useState(null),tX=p.useRef({undo:[],redo:[]}),[OG,NX]=p.useState(0),[eX,U4]=p.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),$H=p.useRef(eX);p.useEffect(()=>{$H.current=eX;try{localStorage.setItem("maude-auto-open-inspector",eX?"1":"0")}catch{}},[eX]);let SH=p.useRef(!1);p.useEffect(()=>{SH.current=i6||x9||H8||u8||BX},[i6,x9,H8,u8,BX]);let AG=p.useRef({open:{},side:rK});AG.current={open:{tree:T9,layers:LY,inspector:i6,comments:x9,changes:H8,sync:u8,assistant:BX},side:o6};let V4=p.useCallback((b,S)=>{if(b==="tree")s9(S);else if(b==="layers")z4(S);else if(b==="inspector")nX(S);else if(b==="comments")t(S);else if(b==="changes")X8(S);else if(b==="sync")y8(S);else if(b==="assistant")LG(S)},[]),v5=p.useCallback((b)=>AG.current.side?.[b]||rK[b],[]),a6=p.useCallback((b)=>{let S=v5(b);V4(b,!0);for(let d of LT)if(d.id!==b&&v5(d.id)===S)V4(d.id,!1)},[V4,v5]),f5=p.useCallback((b)=>{if(AG.current.open?.[b])V4(b,!1);else a6(b)},[a6,V4]),FX=a6,v6=f5,_G=p.useCallback((b)=>{if(!$H.current)return;if(A0)return;if(!b||!b.id)return;if(SH.current)return;FX("inspector"),sX("css")},[FX,A0]),AY=p.useCallback(()=>T0((b)=>!b),[]),EQ=mm(DT),q4=Pm({enabled:c0.cloud===null||c0.exportLane==="remote"}),[bH,W1]=p.useState(!1),[J5,FJ]=p.useState(!1);p.useEffect(()=>{if(!G9())return;let b=!0;return _h().then((S)=>{if(!b)return;if(W1(!!S),!S&&!EH(H90,!1))FJ(!0)}).catch(()=>{}),()=>{b=!1}},[]);let _Y=p.useCallback(()=>{FJ(!1);try{localStorage.setItem(H90,"1")}catch{}},[]),[G1,yH]=p.useState(null);p.useEffect(()=>{if(!G9())return;let b;return kh((S)=>yH(S&&typeof S==="object"?S:{})).then((S)=>{b=S}).catch(()=>{}),()=>{try{b?.()}catch{}}},[]);let[LX,PQ]=p.useState(null),[wY,wG]=p.useState(()=>!EH(Z90,!1)),DX=p.useCallback((b)=>{PQ(Array.isArray(b)&&b.length?b:null)},[]),EG={setup:(b)=>{if(!b)return;if((b.canvas||b.requireSelection)&&K.length===0)a6("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [data-testid^="canvas-row-"]')?.click()}catch{}},80);if(b.inspector||b.tab||b.requireSelection)FX("inspector");if(b.tab)sX(b.tab);if(b.changes)FX("changes")}},B4=p.useCallback(()=>{wG(!1);try{localStorage.setItem(Z90,"1")}catch{}},[]),[X5,jH]=p.useState(()=>EH(B90,!0)),[EY,Z1]=p.useState(!1),[iJ,Q5]=p.useState(()=>EH(V90,!1)),[U0,vH]=p.useState(()=>EH(q90,!1)),[s6,N4]=p.useState(!1),[x5,I7]=p.useState(!1),[h5,Y5]=p.useState(0),[F4,PG]=p.useState(null),[IG,IQ]=p.useState(!1),L4=p.useRef(null),kQ=p.useRef(null),R0=p.useRef(new Map);p.useEffect(()=>{if(!c0?.canvasToken)return;let b=!1,S=null,d=0,X0=(_0)=>{clearTimeout(S);let l=rb(_0);d=Date.now()+l,S=setTimeout(K0,l)};async function K0(){let _0=null;try{let L0=await fetch("/_config",{cache:"no-store",credentials:"same-origin"});if(L0.ok)_0=(await L0.json())?.canvasToken}catch{}if(b)return;if(typeof _0!=="string"||!_0){clearTimeout(S),d=Date.now()+30000,S=setTimeout(K0,30000);return}nb(_0);let l=null;try{l=new URL(c0.canvasOrigin,location.href).origin}catch{}if(l)for(let L0 of R0.current.values())try{L0.contentWindow?.postMessage({dgn:"canvas-cap",t:_0},l)}catch{}X0(_0)}X0(c0.canvasToken);let F0=()=>{if(document.visibilityState==="visible"&&Date.now()>=d)K0()};return document.addEventListener("visibilitychange",F0),()=>{b=!0,clearTimeout(S),document.removeEventListener("visibilitychange",F0)}},[c0?.canvasToken,c0?.canvasOrigin]);let $8=p.useCallback((b)=>{let S=V?R0.current.get(V):null;if(!S||!S.contentWindow)return;try{S.contentWindow.postMessage(b,"*")}catch{}},[V]),PY=p.useRef(0),W8=p.useCallback(({format:b,artboardIds:S=null,scale:d=1,onProgress:X0,timeoutMs:K0=120000})=>new Promise((F0,_0)=>{let l=V?R0.current.get(V):null;if(!l||!l.contentWindow){_0(Error("no active canvas to capture"));return}let L0=l.contentWindow;PY.current+=1;let P0=`cap-${Date.now().toString(36)}-${PY.current}`,i0=!1,M8=(E7,p9)=>{if(i0)return;i0=!0,window.removeEventListener("message",L8),clearTimeout(q6),E7(p9)},L8=(E7)=>{if(E7.source!==L0)return;let p9=E7.data;if(!p9||p9.id!==P0)return;if(p9.dgn==="export-capture-progress")X0?.(p9.current,p9.total);else if(p9.dgn==="export-capture-done")M8(F0,Array.isArray(p9.items)?p9.items:[]);else if(p9.dgn==="export-capture-error")M8(_0,Error(p9.message||"capture failed"))},q6=setTimeout(()=>M8(_0,Error("capture timed out — the canvas did not answer")),K0);window.addEventListener("message",L8);try{L0.postMessage({dgn:"export-capture",id:P0,format:b,artboardIds:S,scale:d},"*")}catch(E7){M8(_0,E7)}}),[V]),g5=p.useCallback((b,S)=>$8({dgn:"photo-preview",asset:b,edit:S}),[$8]),z8=p.useCallback((b,S,d)=>{tX.current.undo.push({asset:b,before:S,after:d}),tX.current.redo.length=0},[]),D4=p.useCallback((b)=>{let S=b?tX.current.redo:tX.current.undo;if(!S.length)return!1;let d=S.pop();(b?tX.current.undo:tX.current.redo).push(d);let X0=(b?d.after:d.before)||{};return g5(d.asset,X0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(d.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(X0)}).catch(()=>{}),NX((K0)=>K0+1),!0},[g5]),kG=p.useCallback(async(b)=>{$8({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(() => (G90(),W90)),K0=await X0(d),F0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":K0.type||"image/png"},body:K0}),_0=await F0.json().catch(()=>({}));if(F0.ok&&_0.path)return{maskAsset:_0.path};return null}catch(S){return console.error("[photo] background removal failed",S),null}finally{$8({dgn:"photo-busy",asset:b,busy:!1})}},[$8]);p.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 W6=p.useRef({});W6.current={open:b0,comps:t0,frame:Z9,total:OQ,playing:UX,compId:Y6,muted:qX,loop:P6,sequences:c8,post:$8,canvas:V};let m5=p.useRef({undo:[],redo:[]}),G6=p.useCallback((b,S,d)=>{if(typeof S!=="number")return;if(m5.current.undo.push({canvas:b,seq:S,label:d}),m5.current.redo=[],m5.current.undo.length>50)m5.current.undo.shift()},[]),TG=p.useCallback((b)=>{let S=m5.current,d=b==="undo"?S.undo:S.redo,X0=b==="undo"?S.redo:S.undo,K0=W6.current.canvas,F0=-1;for(let l=d.length-1;l>=0;l--)if(d[l].canvas===K0){F0=l;break}if(F0<0){x8(b==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let _0=d[F0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:_0.canvas,seq:_0.seq,dir:b})}).then((l)=>l.json().catch(()=>({}))).then((l)=>{if(d.splice(F0,1),l?.ok)X0.push(_0),x8(`${b==="undo"?"Undid":"Redid"}: ${_0.label}`,!0);else x8(`${b==="undo"?"Undo":"Redo"} skipped: ${l?.error||"failed"}`)}).catch(()=>x8(`${b==="undo"?"Undo":"Redo"} failed: network error`))},[]),Z6=p.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},[]),IY=p.useCallback((b)=>{let S=W6.current.canvas;if(!S||S===o8)return;let d=FG.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=Z6(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(x8("Clip removed.",!0),K0.seq!=null)G6(S,K0.seq,"remove clip");_Q(null)}}).catch(()=>x8("Remove failed: network error"))},[Z6,G6]),TQ=p.useCallback((b,S,d)=>{let X0=W6.current.canvas;if(!X0||X0===o8)return;let K0=FG.current||void 0,F0=`/_api/comp-clips?canvas=${encodeURIComponent(X0)}${K0?`&artboardId=${encodeURIComponent(K0)}`:""}`;fetch(F0).then((_0)=>_0.json().catch(()=>({}))).then((_0)=>{let l=_0?.ok&&Array.isArray(_0.clips)?_0.clips:[],L0=b?.transition?l.find((P0)=>P0.kind==="transition"&&P0.stableId===b.stableId)||null:Z6(_0,b);if(!L0?.stableId)return null;return fetch("/_api/clip-edit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:X0,artboardId:K0,stableId:L0.stableId,contentHash:L0.contentHash,verb:S,...d})})}).then((_0)=>_0?_0.json():null).then((_0)=>{if(_0&&!_0.ok)console.warn("[clip-edit]",S,_0.error||"failed"),NJ(`${S} refused`,_0.error);else if(_0?.ok){let l={speed:"set speed","trim-in":"trim in-point",audio:"clip audio","detach-audio":"detach audio",framing:"crop clip",grade:"grade clip",transition:"edit transition",split:"split clip","insert-transition":"add transition","remove-transition":"remove transition","set-text":"edit text","to-overlay":"move to overlay layer","to-storyline":"move to storyline","layer-order":"reorder layers"};if(x8(`Applied: ${l[S]||S}.`,!0),_0.seq!=null)G6(X0,_0.seq,l[S]||S)}}).catch(()=>x8(`${S} failed: network error`))},[Z6,G6,NJ]),[RQ,kY]=p.useState(null),W5=p.useCallback((b,S="")=>new Promise((d)=>{kY({title:b,value:S,resolve:d})}),[]),u5=p.useCallback((b)=>{kY((S)=>{return S?.resolve?.(b),null})},[]),TY=p.useCallback((b,S)=>{let d=W6.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}}),x8("Comment added.",!0)},[]);W6.current.selected=IH,W6.current.setSelected=_Q,W6.current.removeClip=IY,W6.current.clipVerb=TQ,W6.current.addComment=TY,W6.current.askText=W5,p.useEffect(()=>{let b=(S)=>{let d=W6.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=PK(d.comps,d.compId)?.fps||30,_0=Math.max(1,d.total),l=(P0)=>{let i0=Math.max(0,Math.min(_0-1,Math.round(P0)));q9(i0),SJ(!1),d.post({dgn:"timeline-seek",frame:i0,id:d.compId})},L0=()=>{let P0=new Set([0,_0-1]);for(let i0 of d.sequences||[]){P0.add(i0.from);for(let M8 of i0.keyframes||[])P0.add(M8.from),P0.add(M8.to)}return[...P0].filter((i0)=>i0>=0&&i0<_0).sort((i0,M8)=>i0-M8)};if((S.metaKey||S.ctrlKey)&&(S.key==="z"||S.key==="Z")){S.preventDefault(),TG(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 P0=d.selected!=null?{stableId:d.selected}:null;if(!P0){let i0=d.sequences||[],M8=i0.find((L8)=>L8.series&&d.frame>=L8.from&&d.frame<L8.from+L8.duration)||i0.find((L8)=>d.frame>=L8.from&&d.frame<L8.from+L8.duration);if(M8?.stableId)P0={stableId:M8.stableId}}if(P0)d.clipVerb?.(P0,"split",{atFrame:d.frame});else x8("Nothing under the playhead to split.");return}if(S.key===" "||S.code==="Space")if(S.preventDefault(),d.playing)SJ(!1),d.post({dgn:"timeline-pause",id:d.compId});else SJ(!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(),l(d.frame+(S.shiftKey?F0:1));else if(S.key==="ArrowLeft")S.preventDefault(),l(d.frame-(S.shiftKey?F0:1));else if(S.key==="Home")S.preventDefault(),l(0);else if(S.key==="End")S.preventDefault(),l(_0-1);else if(S.key==="."){S.preventDefault();let P0=L0().find((i0)=>i0>d.frame);if(P0!=null)l(P0)}else if(S.key===","){S.preventDefault();let P0=L0().reverse().find((i0)=>i0<d.frame);if(P0!=null)l(P0)}};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[]),p.useEffect(()=>{D8([]),q9(0),SJ(!1),_Q(null),aX(null);let b=setTimeout(()=>$8({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(b)},[V,$8]);let[p5,RY]=p.useState(""),[CY,M4]=p.useState([]),[RG,$Y]=p.useState([]);p.useEffect(()=>{if(!b0||t0.length===0||!V||V===o8){RY(""),M4([]);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")RY(S.source)}).catch(()=>{}),()=>{b=!1}},[b0,t0,V,kH]),p.useEffect(()=>{if(!b0||!V||V===o8||!p5){M4([]),$Y([]);return}let b=!0,S=Q6||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:[];M4(K0.filter((F0)=>F0.kind==="sequence")),$Y(K0.filter((F0)=>F0.kind==="transition"))}).catch(()=>{}),()=>{b=!1}},[b0,V,p5,Q6,kH]),p.useEffect(()=>{if(!p5){e7([]),cJ([]),DY([]),rX(0);return}let b=i7??A?.artboardId??null,d=(b&&t0.find((F0)=>F0.artboardId===b||F0.id===b)||t0[0])?.durationInFrames||0,X0=Bm(p5,d,b);aX(X0.artboardId??b??null);let K0=X0.sequences.map((F0,_0)=>{let l=CY[_0];if(!l)return F0;return{...F0,stableId:l.stableId,contentHash:l.contentHash,mediaProps:l.mediaProps??null,placeholder:l.placeholder??null,mediaTag:l.mediaTag??F0.mediaTag,mediaSrc:l.mediaSrc??F0.mediaSrc,replaceable:!!(l.mediaCdId||l.mediaArrayRef),layers:Array.isArray(l.layers)?l.layers:[],hidden:!!l.hidden}});e7(K0),cJ(X0.audio||[]),DY(X0.transitions||[]),rX(X0.total)},[p5,CY,A,t0,i7]);let SY=p.useCallback(()=>{jH((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]),LJ=p.useCallback((b)=>{for(let S of R0.current.values())try{S.contentWindow.postMessage({dgn:"view-chrome",...b},"*")}catch{}},[]),bY=p.useCallback(()=>{Q5((b)=>{let S=!b;return LJ({minimap:S}),S})},[LJ]),yY=p.useCallback(()=>{vH((b)=>{let S=!b;return LJ({zoom:S}),S})},[LJ]),CG=p.useCallback(()=>{N4((b)=>{let S=!b;return LJ({present:S}),S})},[LJ]),O4=p.useCallback(()=>{N4(!1),LJ({present:!1})},[LJ]),$G=p.useCallback(()=>{if(!V||V===o8)return;I7((b)=>{let S=!b;return $8({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,$8]);p.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)PG(d)}).catch(()=>{}),()=>{b=!0}},[]),p.useEffect(()=>{if(!V||V===o8){Y5(0),I7(!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;Y5(d),I7(S?.overlays?.print===!0),_4(new Set(Array.isArray(S?.locked)?S.locked:[]))}).catch(()=>{if(!b)Y5(0),I7(!1),_4(new Set)}),()=>{b=!0}},[V]),p.useEffect(()=>{if(!V||V===o8||!i7)return;let b=setTimeout(()=>{$8({dgn:"request-layers",artboardId:i7})},250);return()=>clearTimeout(b)},[V,i7,$8]);let[A4,_4]=p.useState(()=>new Set),SG=p.useCallback((b)=>{if(!V||V===o8)return;_4((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(()=>{}),$8({dgn:"locked-set",locked:X0}),d})},[V,$8]);p.useEffect(()=>{if(!V||V===o8)return;$8({dgn:"locked-set",locked:[...A4]})},[A4,V,$8]),p.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",v0),localStorage.setItem(u90,v0)}catch{}for(let b of R0.current.values())try{b.contentWindow.postMessage({dgn:"theme",theme:v0},"*")}catch{}},[v0]),p.useEffect(()=>{try{localStorage.setItem(U90,T9?"1":"0")}catch{}},[T9]),p.useEffect(()=>{try{localStorage.setItem(z90,t9?"1":"0")}catch{}},[t9]),p.useEffect(()=>{try{localStorage.setItem(V90,iJ?"1":"0")}catch{}},[iJ]),p.useEffect(()=>{try{localStorage.setItem(q90,U0?"1":"0")}catch{}},[U0]),p.useEffect(()=>{try{localStorage.setItem(B90,X5?"1":"0")}catch{}},[X5]),p.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")Z8(S.theme);if(typeof S.minimap==="boolean")Q5(S.minimap);if(typeof S.zoom==="boolean")vH(S.zoom);if(typeof S.annotations==="boolean")jH(S.annotations);if(typeof S.autoOpenInspector==="boolean")U4(S.autoOpenInspector);if(S.panelSides&&typeof S.panelSides==="object")a({...rK,...S.panelSides});if(S.layersMode==="separate"||S.layersMode==="in-inspector")D0(S.layersMode)}).catch(()=>{}).finally(()=>{if(!b)Z1(!0)}),()=>{b=!0}},[]),p.useEffect(()=>{if(!EY)return;mF0({theme:v0,minimap:iJ,zoom:U0,annotations:X5,autoOpenInspector:eX,panelSides:o6,layersMode:Y0})},[EY,v0,iJ,U0,X5,eX,o6,Y0]),p.useEffect(()=>{try{localStorage.setItem(N90,JSON.stringify(o6))}catch{}},[o6]),p.useEffect(()=>{try{localStorage.setItem(F90,Y0)}catch{}},[Y0]);let jY=p.useRef(!1);p.useEffect(()=>{if(jY.current||!BJ.ready||!Q||!J.length)return;jY.current=!0;let b=om(J);V7((S)=>nm(S,b))},[BJ.ready,Q,J,V7]);let bG=p.useCallback((b)=>V7((S)=>im(S,b)),[V7]),yG=p.useMemo(()=>({isOpen:(b)=>dm(BJ.state,b),setOpen:(b,S)=>V7((d)=>kE(d,b,S))}),[BJ.state,V7]),w4=p.useCallback(()=>{Z8((b)=>b==="dark"?"light":"dark")},[]),E4=p.useRef(null),y9=p.useCallback(()=>E4.current?.reload()??Promise.resolve(),[]);p.useEffect(()=>{let b=sb({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:nF0(F0.paths,F0.stripPrefix,F0.dirs)}));return{data:X0,built:K0}},apply:({data:S,built:d})=>{H(S.project||"Design"),X(d),Y(!0),x7((X0)=>({...X0,canvasDesignSystems:S.canvasDesignSystems??{},canvasKinds:S.canvasKinds??{}}))},onError:(S)=>console.error("failed to load tree",S)});return E4.current=b,y9(),()=>{E4.current=null,b.dispose()}},[y9]);let G5=p.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){B0(X0);let K0=await fetch(`/_system-data?ds=${encodeURIComponent(X0.defaultDesignSystem)}`);if(K0.ok)B0(await K0.json());return}B0(X0)}catch(S){console.error("failed to load system-data",S)}},[]),vY=p.useCallback(async()=>{try{let S=await(await fetch("/_comments-all")).json();V9(S||{})}catch(b){console.error("failed to load comments",b)}},[]);p.useEffect(()=>{vY()},[vY]);let fY=p.useRef(()=>{});p.useEffect(()=>{let b=null,S=!1;function d(){let X0=location.protocol==="https:"?"wss:":"ws:",K0=new WebSocket(X0+"//"+location.host+"/_ws");kQ.current=K0,K0.addEventListener("open",()=>{if(i(!0),S)U8();S=!0,clearInterval(b),b=setInterval(()=>{if(K0.readyState===WebSocket.OPEN)K0.send('{"type":"ping"}')},25000)}),K0.addEventListener("close",()=>{i(!1),clearInterval(b),setTimeout(d,1000)}),K0.addEventListener("error",()=>{}),K0.addEventListener("message",(F0)=>{try{let _0=JSON.parse(F0.data);if(_0.type==="snapshot"&&_0.state)E((l)=>x90(_0.state.selected,l));else if(_0.type==="selected"){if(Date.now()-T.current<2000)return;let l=_0.selected,L0=Array.isArray(l)?l[0]:l,P0=w.current,i0=Array.isArray(P0)?P0[0]:P0;if(E((M8)=>x90(l,M8)),L0?.id&&L0.file&&(!i0||i0.id!==L0.id||i0.file!==L0.file))$(L0)}else if(_0.type==="comments"&&typeof _0.file==="string")V9((l)=>({...l,[_0.file]:_0.comments||[]}));else if(_0.type==="ai-activity"&&typeof _0.file==="string"){if(IQ(!0),L4.current)clearTimeout(L4.current);L4.current=setTimeout(()=>IQ(!1),8000);for(let l of R0.current.values())try{l.contentWindow.postMessage({dgn:"ai-activity",file:_0.file,entry:_0.entry},"*")}catch{}}else if(_0.type==="export:job"&&_0.payload)q4.upsert(_0.payload);else if(_0.type==="sync:status"&&_0.payload)e0(_0.payload);else if(_0.type==="canvas-list-update")y9(),fY.current(_0.payload);else if(_0.type==="config-updated")U8();else if(_0.type==="acp-focus"){if(G9())FX("assistant")}else if(_0.type==="git-status"&&_0.payload){if(!d8.current)$0(_0.payload)}else if(_0.type==="git-lifecycle"&&_0.payload){Z0(_0.payload);for(let l of R0.current.values())try{l.contentWindow.postMessage({dgn:"git-lifecycle",payload:_0.payload},"*")}catch{}}}catch{}})}return d(),()=>{if(clearInterval(b),kQ.current)kQ.current.close()}},[y9,U8]);function b7(b){let S=kQ.current;try{if(S&&S.readyState===1)S.send(JSON.stringify(b))}catch{}}let DJ=p.useCallback(async()=>{if(d8.current)return;try{let b=await fetch("/_api/git/status");if(b.ok)$0(await b.json())}catch{}},[]),yJ=p.useCallback(async()=>{if(d8.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)S0({remoteAhead:!!S.remoteAhead,behind:S.behind||0})}catch{}},[]),MJ=p.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?"}}},[]),jG=p.useCallback(async(b,S)=>{let d=await MJ("/_api/git/commit",{message:b,files:S});if(d.ok)await DJ();return d},[MJ,DJ]),xY=p.useCallback(async(b)=>{let S=await MJ("/_api/git/discard",{files:b});if(S.ok)await DJ();return S},[MJ,DJ]),vG=p.useCallback(async()=>{let b=await MJ("/_api/git/push",{});if(b.ok)await DJ(),yJ();return b},[MJ,DJ,yJ]),hY=p.useCallback(async()=>{let b=await MJ("/_api/git/pull",{});if(b.ok)await DJ(),yJ();if(b.conflict&&Array.isArray(b.files)&&b.files.length)h0({file:b.files[0],conflict:!0});return b},[MJ,DJ,yJ]),fG=p.useCallback(async(b)=>{let S=await MJ("/_api/git/resolve",{choice:b});if(S.ok)await DJ(),yJ();return S},[MJ,DJ,yJ]),P4=p.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[]}},[]),[xG,hG]=p.useState(null),gG=p.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 hG({branch:X0.branch??null,project:X0.project??null,hubHost:X0.hubHost??null}),X0.entries||[]}catch{return null}},[]),[mG,H1]=p.useState(!1),[z1,K1]=p.useState(0),uG=p.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((_0)=>_0.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}},[]),pG=/^r\d+$/.test(L9?.beforeSha||""),U1=p.useCallback(async(b)=>{if(!pG)return P4(b);let S=await uG(b);return Array.isArray(S)?S:[]},[pG,P4,uG]),fH=p.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 K1((K0)=>K0+1),X0;return{ok:!1,error:X0?.error}},[]),V1=p.useMemo(()=>{let b={modified:"M",added:"A",deleted:"D",untracked:"U"},S=new Map;if(w8)return S;for(let d of n0?.files||[])S.set(d.path,b[d.status]);return S},[n0,w8]);p.useEffect(()=>{if(w8){S0(null);return}if(n0?.repo===!1)return;yJ();let b=setInterval(yJ,H8?60000:120000);return()=>clearInterval(b)},[w8,n0?.repo,H8,yJ]);let V6=p.useCallback((b,{reveal:S=!0}={})=>{if(S&&b&&b!==o8)V7((d)=>HF(d,J,b));if(W.current="push",d9(null),F(null),b===V)return;if(U((d)=>{for(let X0 of d)if(X0.path!==b)R0.current.delete(X0.path);return[{path:b}]}),B(b),r0(null),O0(null),b!==o8)s0(b)},[V,J,V7]),I4=p.useCallback((b,S="push")=>{let d=J.flatMap((X0)=>X0.paths||[]).find((X0)=>bW(X0,c0.designRel)===b);if(d&&y5.test(d))V6(d,{reveal:!1});else if(d&&EL(Q4(d)))M(d);else U([]),B(null),F(null),P5({title:"Not here yet",description:`${b} is not in this project (not synced yet?)`,kind:"info"});W.current=S},[J,c0.designRel,V6,M]),xH=p.useRef(!1);p.useEffect(()=>{if(!Q||c0.cloud===void 0||xH.current)return;xH.current=!0;let b=$V(location,c0.designRel);if(b)I4(b,"none")},[Q,c0.cloud,c0.designRel,I4]),p.useEffect(()=>{if(!Q||c0.cloud===void 0)return;let b=()=>{let S=$V(location,c0.designRel);if(S)I4(S,"none");else W.current="none",U([]),B(null),F(null)};return window.addEventListener("popstate",b),()=>window.removeEventListener("popstate",b)},[Q,c0.cloud,c0.designRel,I4]),p.useEffect(()=>{let b=N||(V===o8?null:V);if(b===G.current)return;G.current=b;let S=bW(b,c0.designRel);if(W.current!=="none"&&$V(location,c0.designRel)!==S)history[S?"pushState":"replaceState"](S?{open:S}:null,"",Ug(location,S));W.current="push"},[V,N,c0.designRel]);let gY=N||(V===o8?null:V),lG=c0.cloud?"cloud":G9()?"native":"local",hH=(b)=>Ng({rel:bW(b,c0.designRel),shell:lG,location,linkedHubUrl:Y8?.url,project:c0.cloud?Z:S8,localUrl:location.origin}),gH=(b=gY)=>{let S=bW(b,c0.designRel);if(S)Z4({path:b,rel:S,label:Q4(b)})},q1=p.useCallback((b)=>{if(r0(null),O0(null),U8(),m0((S)=>S+1),b&&b!==o8)s0(b)},[U8]),dG=p.useRef(!1);p.useEffect(()=>{if(dG.current)return;if(!c0.cloud)return;if(new URLSearchParams(location.search).has("open")){dG.current=!0;return}if(K.length>0)return;if(!J.length)return;let b=null;for(let S of J){for(let d of S.paths||[]){if(!y5.test(d))continue;if(/(^|\/)system\//.test(d))continue;b=d;break}if(b)break}if(!b)return;dG.current=!0,V6(b,{reveal:!1})},[c0.cloud,J,K.length,V6]);let CQ=p.useCallback((b)=>{let S=typeof b==="string"?b:void 0;if(S)G5(S);else if(!N8)G5();V6(o8)},[N8,G5,V6]);p.useEffect(()=>{b7({type:"tabs",tabs:K.map((b)=>b.path).filter((b)=>b!==o8)})},[K]),p.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 mY=p.useCallback((b)=>{U((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)B(null);else B(X0[Math.max(0,d-1)].path);return X0}),R0.current.delete(b),s0((S)=>S===b?null:S)},[V]);fY.current=(b)=>{if(!b?.rel)return;let S=(c0?.designRel||c0?.designRoot||".design").replace(/^\/+|\/+$/g,""),d=`${S}/${b.rel}`;if(b.action==="removed")mY(d);else if(b.action==="moved"&&b.fromRel){let X0=`${S}/${b.fromRel}`;U((K0)=>K0.map((F0)=>F0.path===X0?{...F0,path:d}:F0)),B((K0)=>K0===X0?d:K0),s0((K0)=>K0===X0?null:K0),R0.current.delete(X0)}};let l5=p.useCallback(()=>{if(!V||V===o8){if(V===o8)G5();return}let b=R0.current.get(V);if(b)b.src=b.src},[V,G5]),mH=p.useCallback(()=>y9(),[y9]),[B1,uH]=p.useState(!1),cG=p.useRef(!1),iG=p.useCallback(async()=>{if(cG.current)return;cG.current=!0,uH(!0);try{await Promise.all([y9(),new Promise((b)=>setTimeout(b,550))])}finally{cG.current=!1,uH(!1)}},[y9]);p.useEffect(()=>{let b=null,S=()=>{if(b)clearTimeout(b);b=setTimeout(()=>{b=null,mH()},150)};return window.addEventListener("focus",S),()=>{if(window.removeEventListener("focus",S),b)clearTimeout(b)}},[mH]);let N1=p.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 y9(),V6(d.file),{ok:!0,file:d.file}}catch(S){return{ok:!1,error:S instanceof Error?S.message:"network error"}}},[y9,V6]),pH=p.useCallback(async()=>{let b=await W5("New video name");if(!b)return;let d=(await W5("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 W5("Frames per second","30"))||30));try{let _0=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})}),l=await _0.json().catch(()=>({}));if(!_0.ok||!l.ok){x8(`New video failed: ${l.error||`error ${_0.status}`}`);return}await y9(),V6(l.file),T0(!0),x8("New video created — drop clips on the timeline to start the cut.",!0)}catch(_0){x8(`New video failed: ${_0 instanceof Error?_0.message:"network error"}`)}},[y9,V6,W5]),F1=p.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 l=new DOMParser().parseFromString(S,"image/svg+xml");for(let L0 of l.querySelectorAll('[data-tool="mediaref"]')){let P0=L0.getAttribute("data-src");if(!P0)continue;d.push({src:P0,mediaKind:L0.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=`${X4(Q4(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})}),_0=await F0.json().catch(()=>({}));if(!F0.ok||!_0.ok){window.alert(`Assemble failed: ${_0.error||`error ${F0.status}`}`);return}await y9(),V6(_0.file)}catch(b){window.alert(`Assemble failed: ${b instanceof Error?b.message:"network error"}`)}},[V,y9,V6]),oG=p.useCallback(({accept:b,resolveTarget:S})=>{let d=V,X0=Q6||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 _0=K0.files?.[0];if(F0(),!_0)return;let l=`/_api/comp-clips?canvas=${encodeURIComponent(d)}${X0?`&artboardId=${encodeURIComponent(X0)}`:""}`;fetch(l).then((L0)=>L0.json().catch(()=>({}))).then((L0)=>{let P0=S(L0);if(!P0)return x8("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":_0.type||"application/octet-stream"},body:_0}).then((i0)=>i0.json().catch(()=>({}))).then((i0)=>{if(!i0?.path)return x8(`Upload failed: ${i0?.error||"unknown error"}`),null;if(P0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:d,arrayName:P0.arrayRef.arrayName,index:P0.arrayRef.index,field:P0.arrayRef.field,value:i0.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:d,id:P0.cdId,attr:"src",value:i0.path})})})}).then((L0)=>L0?L0.json():null).then((L0)=>{if(L0&&!L0.ok)x8(`Replace refused: ${L0.error||"failed"}`);else if(L0&&L0.ok){if(x8("Media replaced.",!0),L0.seq!=null)G6(d,L0.seq,"replace media")}}).catch(()=>x8("Replace failed: network error"))}),K0.click()},[V,Q6,G6]),L1=p.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 y9(),V===b)U([]),B(null)}catch(X0){window.alert(`Delete failed: ${X0 instanceof Error?X0.message:"network error"}`)}},[y9,V]),D1=p.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 x8(`Could not move: ${K0.error||`error ${X0.status}`}`),{ok:!1,error:K0.error};let F0=(c0?.designRel||c0?.designRoot||".design").replace(/^\/+|\/+$/g,""),_0=`${F0}/${K0.fromRel}`,l=`${F0}/${K0.toRel}`;V7((P0)=>HF(TE(P0,_0,l),J,l)),await y9(),U((P0)=>P0.map((i0)=>i0.path===_0?{path:l}:i0)),B((P0)=>P0===_0?l:P0);let L0=_0.split("/").slice(0,-1).join("/");return x8(`Moved to ${K0.toRel.split("/").slice(0,-1).join("/")||"."}`,!0,{label:"Undo",onClick:()=>{b(l,L0)}}),{ok:!0}}catch(X0){return x8(`Move failed: ${X0 instanceof Error?X0.message:"network error"}`),{ok:!1,error:"network error"}}},[y9,c0,J,V7]),M1=p.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 x8(`Could not create folder: ${K0}`),{ok:!1,error:K0}}return V7((K0)=>HF(K0,J,b,{includeSelf:!0})),await y9(),{ok:!0,dir:X0.dir}}catch(d){let X0=d instanceof Error?d.message:"network error";return x8(`Create folder failed: ${X0}`),{ok:!1,error:X0}}},[y9,J,V7]),O1=p.useCallback(async(b,S)=>{if(!window.confirm(`Delete folder "${S}"?
|
|
5686
5686
|
|