@1agh/maude 1.6.6 → 1.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5680,7 +5680,7 @@ ${B.block}`:V,F=[],M=new Map;for await(let A of J.prompt(N,X(),K,Q?.(),Y?.(),Z?.
5680
5680
 
5681
5681
  > Maude ${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)`),a=`${kV0}?title=${s}&body=${H0}&labels=report`;if(H9())try{await IV(a)}catch{window.open(a,"_blank","noopener")}else window.open(a,"_blank","noopener");T({fallbackDir:e?.dir??null}),W("done")}catch{$("Saving the local bundle failed too — please file the issue by hand.")}}let 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<TE&&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 (",TV0(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 ",TE,"."]}):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($V0,{shot:u,redacting:w,onRects:(r)=>V((e)=>e.map((s,H0)=>H0===v?{...s,rects:r}:s)),onRemove:()=>{URL.revokeObjectURL(u.url),V((r)=>r.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??""," · ",H9()?"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,H9()&&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(H9())IV(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 lm(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 dm(J,X){let Q=lm(J),Y=lm(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 cm(J,X){if(!Array.isArray(J))return[];return J.filter((Q)=>Q&&(Q.version==null||dm(Q.version,X)))}function im(J,X){let Q=X;if(Array.isArray(J)){for(let Y of J)if(Y&&Y.version&&dm(Y.version,Q))Q=Y.version}return Q}var RE="mdcc-whatsnew-seen",CE="mdcc-whatsnew-toast-dismissed";function SV0(J){return typeof J==="string"&&/^https?:\/\//i.test(J)}function bV0(J){try{let X=localStorage.getItem(RE);if(X)return X;localStorage.setItem(RE,J)}catch{}return J}function yV0(){try{return localStorage.getItem(CE)}catch{return null}}function om(J){let[X,Q]=PJ.useState([]),[Y,W]=PJ.useState(J),[G,Z]=PJ.useState(()=>bV0(J)),[H,K]=PJ.useState(()=>yV0()),[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=cm(X,G),N=B.length>0&&H!==Y&&!U,F=B[0]??null,M=PJ.useCallback(()=>{let O=im(X,Y);Z(O),K(Y);try{localStorage.setItem(RE,O),localStorage.setItem(CE,Y)}catch{}},[X,Y]),A=PJ.useCallback(()=>{K(Y);try{localStorage.setItem(CE,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 nm({wn:J}){let X=`whats-new-${J.feedVersion}`;return PJ.useEffect(()=>{if(!J.showToast||!J.toastEntry){gW(X);return}A5({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(()=>()=>gW(X),[X]),null}function rm({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}),SV0(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 c5=b8(i8(),1),jV0=Object.freeze({dirs:[],sections:{}}),vV0="mdcc-sections-expanded",fV0=250,xV0=3000;function sm(J,X){return!!X&&J.dirs.includes(X)}function hV0(J,X){return J.sections[X]===!0}function $E(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 tm(J,X,Q){if(!X||J.sections[X]===!!Q)return J;return{...J,sections:{...J.sections,[X]:!!Q}}}function em(J,X){return tm(J,X,!hV0(J,X))}function gV0(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=gV0(X,Q);if(!W)return J;let G=tm(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=$E(G,U,!0);return G}function SE(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 Ju(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 Xu(J,X){let Q=J.dirs.filter((Y)=>X.has(Y));return Q.length===J.dirs.length?J:{...J,dirs:Q}}function am(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 mV0(){try{let J=JSON.parse(localStorage.getItem(vV0)||"null");return J&&typeof J==="object"&&!Array.isArray(J)?J:null}catch{return null}}function Qu({fetchImpl:J}={}){let[X,Q]=c5.useState(jV0),[Y,W]=c5.useState(!1),G=J||((...U)=>fetch(...U)),Z=c5.useRef(G);Z.current=G,c5.useEffect(()=>{let U=!1,V=typeof AbortController==="function"?new AbortController:null,B=setTimeout(()=>V?.abort(),xV0);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=am(N);if(!(N&&typeof N==="object"&&N.sections&&Object.keys(N.sections).length)){let A=mV0();if(A)F=am({...F,sections:A})}Q(F)}).catch(()=>{}).finally(()=>{if(clearTimeout(B),!U)W(!0)}),()=>{U=!0,clearTimeout(B)}},[]);let H=c5.useRef(!0);c5.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{}},fV0);return()=>clearTimeout(U)},[Y,X]);let K=c5.useCallback((U)=>Q((V)=>U(V)),[]);return{state:X,ready:Y,update:K}}var z7=({as:J,size:X=14})=>z(J,{size:X,strokeWidth:1.75,style:{display:"block"}}),B90="mdcc-usage-tour-seen",N90="mdcc-collab-tour-seen",o8="__system__",r90="mdcc-theme",F90="mdcc-show-hidden",L90="maude-cp-mode",D90="mdcc-sidebar-open",M90="mdcc-minimap-visible",O90="mdcc-zoomctl-visible",A90="mdcc-annotations-visible";var rF0=30000;function aF0(J){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(J)}).catch(()=>{})}catch{}}var AT=[{id:"tree",label:"Files"},{id:"layers",label:"Layers"},{id:"inspector",label:"Inspector"},{id:"comments",label:"Comments"},{id:"changes",label:"Changes"},{id:"sync",label:"Sync"},{id:"assistant",label:"Assistant"}],sK={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",sync:"right",assistant:"right"},_90="mdcc-panel-sides",w90="mdcc-layers-mode";function E90({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]||(AT.find((U)=>U.id===K)||{}).label||K},K))}),Z]})}var C5=/\.(tsx|html?)$/i,P90=(J)=>/\.(tsx|jsx)$/i.test(String(J||"")),sF0=[[/\.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 sF0)if(X.test(J))return Q;return null}function _q(J){return J.replace(/^\.[^/]+\//,"").replace(C5,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}function tF0(J){let X=[];return function Q(Y){for(let W of Y||[])X.push(W?.id??""),Q(W?.children)}(J),X.join(",")}var _T="1.6.6";function BL(J,X){let Q=()=>{try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(J,{body:X})}catch{}};if(H9()){A7("send_notification",{title:J,body:X}).catch(Q);return}Q()}function eF0(){if(typeof window>"u")return"dark";try{let J=localStorage.getItem(r90);if(J==="light"||J==="dark")return J}catch{}return"dark"}function kH(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 I90(J,X){if(typeof window>"u")return X;try{let Q=localStorage.getItem(J);return Q?JSON.parse(Q):X}catch{return X}}function JL0(){return!1}var XL0=[];function UQ(J){return J.split("/").pop()}function g8(J,X=!1,Q){A5({title:J,kind:X?"success":"error",action:Q})}var k90="maude-mode-hint-seen";function LL(J=!1){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(k90)==="1")return}catch{return}if(LL.active)return;LL.active=!0;let X=()=>{LL.active=!1;try{localStorage.setItem(k90,"1")}catch{}document.removeEventListener("keydown",Q,!0)},Q=(Y)=>{if((Y.key==="v"||Y.key==="V")&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey)gW("mode-hint"),X()};if(J)document.addEventListener("keydown",Q,!0);A5({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(C5,"")}function QL0(J){return J.replace(C5,"")}function YL0(J){let X=new Map;for(let G of J){if(!C5.test(G.name))continue;let Z=QL0(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(C5.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 WL0(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 a90(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=a90(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 GL0(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 s90(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 ZL0={"chevron-down":z("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":z("polyline",{points:"6 3.5 10.5 8 6 12.5"}),file:D(Q0,{children:[z("path",{d:"M4 2h5l3 3v9H4z"}),z("polyline",{points:"9 2 9 5 12 5"})]}),folder:z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),"folder-plus":D(Q0,{children:[z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),z("path",{d:"M8 7.5v3.5M6.25 9.25h3.5"})]}),lock:D(Q0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015 0v2"})]}),unlock:D(Q0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015-.7"})]}),search:D(Q0,{children:[z("circle",{cx:"7",cy:"7",r:"4"}),z("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:D(Q0,{children:[z("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),z("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),check:z("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),x:D(Q0,{children:[z("line",{x1:"4.3",y1:"4.3",x2:"11.7",y2:"11.7"}),z("line",{x1:"11.7",y1:"4.3",x2:"4.3",y2:"11.7"})]}),sun:D(Q0,{children:[z("circle",{cx:"8",cy:"8",r:"2.6"}),z("line",{x1:"8",y1:"1.5",x2:"8",y2:"3"}),z("line",{x1:"8",y1:"13",x2:"8",y2:"14.5"}),z("line",{x1:"1.5",y1:"8",x2:"3",y2:"8"}),z("line",{x1:"13",y1:"8",x2:"14.5",y2:"8"}),z("line",{x1:"3.4",y1:"3.4",x2:"4.4",y2:"4.4"}),z("line",{x1:"11.6",y1:"11.6",x2:"12.6",y2:"12.6"}),z("line",{x1:"12.6",y1:"3.4",x2:"11.6",y2:"4.4"}),z("line",{x1:"4.4",y1:"11.6",x2:"3.4",y2:"12.6"})]}),moon:z("path",{d:"M12.5 9.6A5 5 0 1 1 7 3a4 4 0 0 0 5.5 6.6z"}),sparkle:z("path",{d:"M8 1.8l1.4 4.8L14 8l-4.6 1.4L8 14.2l-1.4-4.8L2 8l4.6-1.4z",fill:"currentColor",stroke:"none"}),megaphone:D(Q0,{children:[z("path",{d:"M2 6.7 11 4v8L2 9.3z"}),z("path",{d:"M11 5.2a2.4 2.4 0 0 1 0 5.6"}),z("path",{d:"M4.3 9.5v2.3a1.2 1.2 0 0 0 2.4 0v-1.7"})]}),bug:D(Q0,{children:[z("circle",{cx:"8",cy:"9",r:"3.6"}),z("circle",{cx:"8",cy:"4.4",r:"1.3"}),z("path",{d:"M6.2 3.4 5.2 2M9.8 3.4l1-1.4"}),z("path",{d:"M4.6 7.6H2.2M4.6 9H2.2M4.6 10.6H2.5M11.4 7.6h2.4M11.4 9h2.4M11.4 10.6h2.3"})]}),"panel-left":D(Q0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("line",{x1:"6.4",y1:"3",x2:"6.4",y2:"13"})]}),resolve:D(Q0,{children:[z("circle",{cx:"8",cy:"8",r:"5.6"}),z("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:D(Q0,{children:[z("path",{d:"M3.2 8a5 5 0 1 1 1.4 3.5"}),z("polyline",{points:"3.2 11.4 3.2 8 6.6 8"})]}),layers:D(Q0,{children:[z("polygon",{points:"8 2.2 13.8 5.5 8 8.8 2.2 5.5"}),z("polyline",{points:"2.2 9 8 12.3 13.8 9"})]}),box:z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.2"}),type:D(Q0,{children:[z("polyline",{points:"4 4 12 4"}),z("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:D(Q0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"3"}),z("line",{x1:"6",y1:"8",x2:"10",y2:"8"})]}),input:D(Q0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"1.2"}),z("line",{x1:"5",y1:"8",x2:"5",y2:"8"})]}),link:D(Q0,{children:[z("path",{d:"M6.5 9.5a2.5 2.5 0 0 1 0-3.5l1.5-1.5a2.5 2.5 0 0 1 3.5 3.5l-1 1"}),z("path",{d:"M9.5 6.5a2.5 2.5 0 0 1 0 3.5l-1.5 1.5a2.5 2.5 0 0 1-3.5-3.5l1-1"})]}),list:D(Q0,{children:[z("line",{x1:"6",y1:"4.5",x2:"13",y2:"4.5"}),z("line",{x1:"6",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6",y1:"11.5",x2:"13",y2:"11.5"}),z("circle",{cx:"3.2",cy:"4.5",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"8",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"11.5",r:"0.8",fill:"currentColor"})]}),eye:D(Q0,{children:[z("path",{d:"M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z"}),z("circle",{cx:"8",cy:"8",r:"2"})]}),eyedropper:D(Q0,{children:[z("path",{d:"M11 2.6a1.7 1.7 0 0 1 2.4 2.4l-1.2 1.2-2.4-2.4z"}),z("path",{d:"M9.5 4.6 4 10.1V12h1.9l5.5-5.5"})]}),"p-corner":z("path",{d:"M3.5 12.5V7a3.5 3.5 0 0 1 3.5-3.5h5.5"}),"p-opacity":D(Q0,{children:[z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.5"}),z("path",{d:"M3 8h10M8 3v10",strokeWidth:"0.9",opacity:"0.55"})]}),"p-lineheight":D(Q0,{children:[z("line",{x1:"6.5",y1:"4",x2:"13",y2:"4"}),z("line",{x1:"6.5",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6.5",y1:"12",x2:"13",y2:"12"}),z("path",{d:"M3.2 4.6 3.2 11.4M2 6 3.2 4.5 4.4 6M2 10 3.2 11.5 4.4 10"})]}),"p-letterspacing":D(Q0,{children:[z("path",{d:"M3 4v8M13 4v8"}),z("path",{d:"M6 11.5 8 5l2 6.5M6.7 9.3h2.6",strokeWidth:"1.1"})]}),"p-gap":D(Q0,{children:[z("rect",{x:"2",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("rect",{x:"10.4",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("path",{d:"M6.8 8h2.4M7.4 6.9 6.4 8l1 1.1M8.6 6.9 9.6 8l-1 1.1",strokeWidth:"1"})]}),"p-border":z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"}),"p-size":D(Q0,{children:[z("path",{d:"M3 13 6.6 3l3.6 10"}),z("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":D(Q0,{children:[z("path",{d:"M6.3 4A6.7 6.7 0 0 1 8 3.5C12 3.5 14.5 8 14.5 8a12 12 0 0 1-2 2.4M4.4 5.3A12 12 0 0 0 1.5 8S4 12.5 8 12.5a6.5 6.5 0 0 0 2.1-.35"}),z("line",{x1:"2.5",y1:"2.5",x2:"13.5",y2:"13.5"})]}),sliders:D(Q0,{children:[z("line",{x1:"3",y1:"5",x2:"13",y2:"5"}),z("circle",{cx:"6",cy:"5",r:"1.7",fill:"currentColor"}),z("line",{x1:"3",y1:"11",x2:"13",y2:"11"}),z("circle",{cx:"10",cy:"11",r:"1.7",fill:"currentColor"})]}),code:D(Q0,{children:[z("polyline",{points:"6 5 3 8 6 11"}),z("polyline",{points:"10 5 13 8 10 11"})]}),download:D(Q0,{children:[z("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),z("polyline",{points:"4.5 7 8 10.5 11.5 7"}),z("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),reload:D(Q0,{children:[z("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),z("path",{d:"M14 2v3.33h-3.33"})]}),help:D(Q0,{children:[z("circle",{cx:"8",cy:"8",r:"6"}),z("path",{d:"M6.3 6.2a1.8 1.8 0 1 1 2.3 1.9c-.5.2-.6.5-.6 1v.3"}),z("line",{x1:"8",y1:"11.4",x2:"8",y2:"11.5"})]}),image:D(Q0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("circle",{cx:"6",cy:"6.3",r:"1.1"}),z("path",{d:"M3 12l3-2.8 2.2 1.8 2.4-3L13.5 12"})]}),vector:D(Q0,{children:[z("path",{d:"M3.6 11.2C6 5 10 5 12.4 11.2"}),z("rect",{x:"1.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"11.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"6.7",y:"2.6",width:"2.6",height:"2.6",rx:"0.4"})]}),presentation:D(Q0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"7.4",rx:"1"}),z("line",{x1:"8",y1:"10.4",x2:"8",y2:"13"}),z("line",{x1:"5.6",y1:"13.4",x2:"10.4",y2:"13.4"})]}),archive:D(Q0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"3",rx:"0.8"}),z("path",{d:"M3.6 6v6.2a1 1 0 0 0 1 1h6.8a1 1 0 0 0 1-1V6"}),z("line",{x1:"6.6",y1:"8.8",x2:"9.4",y2:"8.8"})]}),external:D(Q0,{children:[z("path",{d:"M11 8.5V12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h3.5"}),z("polyline",{points:"9.5 3 13 3 13 6.5"}),z("line",{x1:"13",y1:"3",x2:"7.6",y2:"8.4"})]}),share:D(Q0,{children:[z("circle",{cx:"4",cy:"8",r:"1.9"}),z("circle",{cx:"11.6",cy:"3.6",r:"1.9"}),z("circle",{cx:"11.6",cy:"12.4",r:"1.9"}),z("line",{x1:"5.7",y1:"7",x2:"9.9",y2:"4.6"}),z("line",{x1:"5.7",y1:"9",x2:"9.9",y2:"11.4"})]}),pen:D(Q0,{children:[z("path",{d:"M3 13l.8-3L10.6 3.2a1.1 1.1 0 0 1 1.6 0l.6.6a1.1 1.1 0 0 1 0 1.6L6 12.2z"}),z("line",{x1:"9.6",y1:"4.2",x2:"11.8",y2:"6.4"})]}),square:z("rect",{x:"3.5",y:"3.5",width:"9",height:"9",rx:"1"})};function HL0({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(()=>XB(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(T9,{name:"search",size:18}),z("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(V)=>W(V.target.value),onKeyDown:(V)=>{if(V.key==="Escape")V.preventDefault(),X();else if(V.key==="ArrowDown")V.preventDefault(),Z((B)=>Math.min(K.length-1,B+1));else if(V.key==="ArrowUp")V.preventDefault(),Z((B)=>Math.max(0,B-1));else if(V.key==="Enter"){V.preventDefault();let B=lb(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(T9,{name:V.icon,size:15})}),z("span",{className:"st-pal-label",children:V.label}),V.kbd?z("span",{className:"st-pal-kbd",children:z(TJ,{children:V.kbd})}):null]})]},V.id)})})]})})}function T9({name:J,size:X=16,className:Q}){return z("svg",{className:Q,width:X,height:X,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:ZL0[J]})}function zL0(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 T90({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 R90(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 C90({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 DT=[{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}],$90={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},KL0=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],Dq=[{id:"1x",label:"1× (native)",kind:"scale",value:1},{id:"2x",label:"2× (retina)",kind:"scale",value:2},{id:"3x",label:"3× (max)",kind:"scale",value:3},{id:"dpi150",label:"150 dpi",kind:"dpi",value:150},{id:"dpi300",label:"300 dpi (print)",kind:"dpi",value:300},{id:"dpi600",label:"600 dpi (high-res print)",kind:"dpi",value:600}],UL0="2x",S90=[{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}],VL0="auto",b90=[{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",BL0={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 NL0(J){let X=String(J||"").split(".").pop()?.toLowerCase();return BL0[X]||"application/octet-stream"}function FL0({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 r={...v};for(let e of u)r[e.path]=e.kind;return r})}).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((r)=>$(r).then((e)=>({...e,file:r}))));U(!1);let u=h.filter((r)=>r.ok),v=h.length-u.length;if(v>0)B(`${v} of ${h.length} uploads failed`);if(u.length)A((r)=>{let e={...r};for(let s of u)e[s.path]=j(s.file.type);return e}),F((r)=>{let e=new Set(r);for(let s of u)e.add(s.path);return e})},m=async()=>{U(!0),B(null);try{if(Y){let u=(await $h()||[]).map((v)=>new File([new Uint8Array(v.bytes)],v.name,{type:NL0(v.name)}));if(U(!1),u.length)await f(u);return}let x=await dZ();if(x?.bytes){await C(new Blob([new Uint8Array(x.bytes)]));return}}catch(x){B(x?.message||"open failed")}U(!1)},c=()=>{if(H9()){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(T9,{name:"x",size:15})})]}),D("div",{className:"st-dialog-bd",children:[D("div",{className:"st-ap-toolbar",children:[z("button",{type:"button",className:"st-btn",onClick: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(T9,{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 LL0({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((C0)=>H==="none"&&!C0.handoff&&C0.format!=="zip"&&!Yy.has(C0.format)||H!=="local"&&C0.format==="canva",[H]),[B,N]=p.useState(J==="handoff"?"shadcn":"png"),[F,M]=p.useState(()=>X&&cb("png",X)?X:bO("png")),[A,E]=p.useState(2),[w,O]=p.useState(UL0),[I,T]=p.useState(!0),[R,$]=p.useState(!1),[C,j]=p.useState(!1),[f,m]=p.useState(!1),[c,o]=p.useState(VL0),[x,h]=p.useState(qL0),[u,v]=p.useState(!0),[r,e]=p.useState(!1),[s,H0]=p.useState(null),[a,z0]=p.useState([]),i=DT.find((C0)=>C0.id===B)||DT[0],q0=i.handoff?[]:yO(i.format),Z0=900,P0=3600,s0=kK(W,JE(W,{artboardId:G})),e0=s0?.durationInFrames||0,Y8=s0?.fps||30,E8=i.temporal&&e0>900,C8=i.temporal&&e0>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 t8=p.useCallback(()=>{fetch("/_api/export-history").then((C0)=>C0.json()).then((C0)=>z0(Array.isArray(C0?.history)?C0.history.slice(0,6):[])).catch(()=>{})},[]);p.useEffect(()=>{t8()},[t8]),p.useEffect(()=>{function C0(_0){if(_0.key==="Escape")_0.preventDefault(),U()}return window.addEventListener("keydown",C0),()=>window.removeEventListener("keydown",C0)},[U]);async function o0(){if(i.handoff){let V8=`/design:handoff ${Q&&Q!==o8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(V8)}catch{}H0({ok:!0,msg:`Copied: ${V8} — 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 C0=i.temporal?{scale:A}:{};if(i.format==="png"){let $0=Dq.find((V8)=>V8.id===w)||Dq[1];if($0.kind==="dpi")C0.dpi=$0.value;else C0.scale=$0.value}if(i.format==="mp4"||i.format==="webm")C0.audio=u;if(C8)C0.maxFrames=e0;if(i.format==="pdf"){C0.pdfPrint={includeBleed:I,marks:{crop:C,registration:f}};let $0=S90.find((V8)=>V8.id===c)?.value;if($0!==void 0)C0.dpi=$0;if(x!=="keep")C0.text=x}if(G)C0.artboardId=G;if(Z?.selector)C0.selection=Z;if(Q&&Q!==o8)C0.canvasFile=Q;if(hU.has(i.format)&&ZB({exportLane:H,format:i.format,scope:F,artboardId:C0.artboardId})&&typeof K==="function")try{let $0=mO(C0);H0({ok:!0,msg:"Capturing…"});let V8=await K({format:i.format,artboardIds:[C0.artboardId],scale:$0,onProgress:(p8,y8)=>H0({ok:!0,msg:`Capturing ${p8}/${y8}…`})}),Q8=await gO(V8,i.format);for(let p8 of Q8)AL(p8.name,p8.blob);for(let p8 of Q8)await uO({format:i.format,scope:F,filename:p8.name});e(!1),H0({ok:!0,msg:`Saved ${Q8.map((p8)=>p8.name).join(", ")} to your downloads.`});return}catch($0){if(H!=="remote"){H0({ok:!1,msg:`Capture failed: ${$0&&$0.message||$0}`}),e(!1);return}}if(ZB({exportLane:H,format:i.format,scope:F})&&i.format==="pptx"&&typeof K==="function")try{H0({ok:!0,msg:"Capturing artboards…"});let $0=Q&&Q!==o8?UQ(Q).replace(/\.[^.]+$/,""):"export",{filename:V8,blob:Q8}=await hO({capture:K,name:$0,onProgress:(p8,y8)=>H0({ok:!0,msg:`Capturing ${p8}/${y8}…`}),onAssemble:()=>H0({ok:!0,msg:"Assembling deck…"})});AL(V8,Q8),await uO({format:i.format,scope:F,filename:V8}),e(!1),H0({ok:!0,msg:`Saved ${V8} to your downloads.`});return}catch($0){if(H!=="remote"){H0({ok:!1,msg:`Deck export failed: ${$0&&$0.message||$0}`}),e(!1);return}}if(H==="none"&&hU.has(i.format)){H0({ok:!1,msg:"Without the render service this workspace exports PNG/SVG of the active artboard only — switch Scope to “Active artboard”, or ask your admin to add maude-render."}),e(!1);return}try{let $0=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:i.format,scope:F,options:C0})});if(!$0.ok){H0({ok:!1,msg:await $0.text()||`Export failed (${$0.status})`}),e(!1);return}U()}catch($0){H0({ok:!1,msg:$0&&$0.message?$0.message:String($0)}),e(!1)}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(C0)=>{if(C0.target===C0.currentTarget)U()},children:D("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[D("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Export & handoff"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:U,children:z(T9,{name:"x",size:15})})]}),D("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:Q&&Q!==o8?`Format · ${X4(UQ(Q))}`:"Format"}),z("div",{className:"st-fmt-grid",children:DT.filter((C0)=>!C0.temporal||Y).map((C0)=>D("button",{type:"button","data-testid":`export-format-${C0.id}`,className:"st-fmt"+(C0.id===B?" is-on":""),disabled:V(C0),title:V(C0)?"Needs the render service — not configured on this workspace":void 0,onClick:()=>{N(C0.id),H0(null)},children:[z(T9,{name:C0.icon,size:16}),z("span",{className:"st-fmt-name",children:C0.label}),z("span",{className:"st-fmt-sub",children:C0.sub})]},C0.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:(C0)=>M(C0.target.value),children:q0.map((C0)=>z("option",{value:C0,children:$90[C0]},C0))})]}),!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:(C0)=>O(C0.target.value),children:Dq.map((C0)=>z("option",{value:C0.id,children:C0.label},C0.id))})]}),!i.handoff&&i.format==="png"&&z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let C0=Dq.find(($0)=>$0.id===w)||Dq[1],_0=C0.kind==="dpi"?C0.value/96:C0.value;return`${C0.label} ≈ ${Math.round(1440*_0)}×${Math.round(900*_0)} 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:(C0)=>E(Number(C0.target.value)),children:KL0.map((C0)=>z("option",{value:C0.value,children:C0.label},C0.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,")."]}),E8&&D("div",{className:"st-mono st-export-long-notice","data-testid":"export-long-comp-notice",style:{fontSize:11,color:"var(--accent)",lineHeight:1.5},children:["⚠ Long comp: ",e0," frames (≈",Math.round(e0/Y8),"s).",C8?` 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:(C0)=>o(C0.target.value),children:S90.map((C0)=>z("option",{value:C0.id,children:C0.label},C0.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:(C0)=>h(C0.target.value),children:b90.map((C0)=>z("option",{value:C0.id,children:C0.label},C0.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:b90.find((C0)=>C0.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:(C0)=>T(C0.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:()=>$((C0)=>!C0),"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:(C0)=>j(C0.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:(C0)=>m(C0.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:(C0)=>v(C0.target.checked)}),"Export with audio"]})}),i.handoff&&D("div",{className:"callout callout--info",style:{fontSize:12},children:["Hands the active canvas off to production. Copies"," ",z("span",{className:"st-mono",children:"/design:handoff <path>"})," — run it in Claude Code to emit a ready-to-drop production component next to the canvas."]}),s&&z("div",{className:"callout "+(s.ok?"callout--success":"callout--error"),style:{fontSize:12},"data-testid":"export-status","data-ok":s.ok?"1":"0",children:s.msg}),a.length>0&&D("div",{className:"st-export-recent","data-testid":"export-recent",children:[z("div",{className:"st-rp-hd",children:"Recent"}),a.map((C0,_0)=>D("div",{className:"st-export-recent-row",children:[D("span",{children:[String(C0.format||"").toUpperCase()," ·"," ",$90[C0.scope]||C0.scope]}),z("span",{className:"st-mono",children:C0.filename})]},_0))]})]}),D("div",{className:"st-dialog-ft",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:U,children:"Cancel"}),D("button",{type:"button",className:"btn btn--primary","data-testid":"export-submit",disabled:r,onClick:o0,children:[z(T9,{name:"download",size:14}),i.handoff?"Copy handoff command":r?"Exporting…":`Export ${i.label}`]})]})]})})}var PL=12,IL=16;function DL0({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-${_q(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(T9,{name:"chevron-right",className:"st-chev"+(K?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:J})]});return z(cz,{label:J,row:A,expanded:K,busy:M,onToggle:()=>U((E)=>!E),actions:G?z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${_q(Y)}`,title:`Folder actions — ${J}`,"aria-label":`Folder actions for ${J}`,"aria-haspopup":"menu",onClick:(E)=>G.openAt(E,{kind:"dir",dirPath:Y}),children:z(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 ML0({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(cz,{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(T9,{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(T9,{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=C5.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(C5,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,x=D("button",{type:"button",role:"treeitem","data-testid":o??(f?`file-row-${_q(J.path)}`:void 0),"aria-selected":M,"aria-disabled":w?"true":void 0,"aria-busy":C||void 0,tabIndex:M?0:-1,className:"st-row"+(M?" is-sel":"")+(K==="runtime"?" is-muted":"")+($?" is-dragging":"")+(C?" is-busy":""),style:{paddingLeft: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)},onPointerEnter:E==="image"?()=>iw(J.path):void 0,onFocus:E==="image"?()=>iw(J.path):void 0,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(T9,{name:"file",size:13})}),z("span",{className:"st-row-name",children:O}),B==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),B==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),V&&z("span",{className:"st-git-badge","data-kind":V,title:`Unsaved (${V})`,"aria-label":`Unsaved, ${V}`,children:V}),Z>0&&z("span",{className:"st-row-badge",children:Z})]});return z(cz,{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-${_q(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 OL0({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(T9,{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(cz,{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-${_q(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 t90({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(()=>YL0(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(OL0,{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(t90,{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(ML0,{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(DL0,{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 AL0(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 _L0({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:r,onRenameFolder:e,onRenameCanvas:s,onDuplicateCanvas:H0,onDeleteFile:a,syncStatus:z0,onLinkedHub:i,onLocalProject:q0,onOpenLinkedFile:Z0,filesReady:P0,onShare:s0,savingIsManaged:e0=!1}){let Y8=p.useMemo(()=>{if(!V)return Q;return Q.map((T0)=>({...T0,tree:a90(T0.tree,V),filtered:!!V}))},[Q,V]),E8=zy(u),C8=Gy(),t8=p.useMemo(()=>{let T0=[];for(let n0 of Q){if(n0.label==="Design system"||n0.kind!=="canvas")continue;let x0=n0.fullPath.replace(/^\.[^/]+\//,"")||n0.fullPath;T0.push({path:n0.fullPath,label:x0});for(let g0 of n0.dirs||[])T0.push({path:g0,label:g0.replace(/^\.[^/]+\//,"")})}return T0},[Q]),o0=C8.state?.extra,C0=o0?.kind==="file"?[{id:"share",label:"Share…",onSelect:()=>{C8.close(),s0(o0.path)}},...s&&/\.tsx$/i.test(o0.path)?[{id:"rename-canvas",label:"Rename…",onSelect:()=>{C8.close();let T0=X4(o0.path.split("/").pop()),n0=window.prompt("Rename canvas to:",T0);if(n0?.trim()&&n0.trim()!==T0)s(o0.path,n0.trim())}}]:[],...H0&&/\.tsx$/i.test(o0.path)?[{id:"duplicate-canvas",label:"Duplicate",onSelect:()=>{C8.close(),H0(o0.path)}}]:[],...o0.supporting&&s?[{id:"rename-file",label:"Rename…",onSelect:()=>{C8.close();let T0=o0.name??o0.path.split("/").pop(),n0=T0.includes(".")?T0.slice(T0.lastIndexOf(".")):"",x0=n0?T0.slice(0,-n0.length):T0,g0=window.prompt(`Rename ${T0} to:`,x0);if(g0?.trim()&&g0.trim()!==x0)s(o0.path,g0.trim())}}]:[],...o0.canMove?[{id:"move-to",label:"Move to…",onSelect:()=>C8.showMoveTo()}]:[],...o0.supporting&&a?[{id:"delete-file",label:"Delete",destructive:!0,onSelect:()=>{C8.close(),a(o0.path,o0.name??o0.path.split("/").pop())}}]:[]]:o0?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{C8.close();let T0=window.prompt("New folder name:");if(T0?.trim())v(o0.dirPath,T0.trim())}},{id:"rename-folder",label:"Rename folder",onSelect:()=>{C8.close();let T0=o0.dirPath.split("/").pop(),n0=window.prompt("Rename folder to:",T0);if(n0?.trim()&&n0.trim()!==T0)e(o0.dirPath,n0.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{C8.close(),r(o0.dirPath,o0.dirPath.split("/").pop())}}]:[],_0=o0?.kind==="file"||o0?.kind==="supporting"?t8.filter((T0)=>T0.path!==o0.dir):[],[$0,V8]=p.useState(!1),[Q8,p8]=p.useState("board"),[y8,D9]=p.useState(""),[f0,k8]=p.useState(""),[A9,L8]=p.useState(!1),B0=p.useMemo(()=>Q.find((T0)=>T0.kind==="canvas"&&T0.label!=="Design system")?.fullPath,[Q]),J8=p.useCallback(async()=>{let T0=y8.trim();if(!T0||A9)return;if(L8(!0),k8(""),Q8==="folder"){if(!B0){L8(!1),k8("no canvas group to create a folder in");return}let x0=await v(B0,T0);if(L8(!1),x0?.ok)V8(!1),D9("");else k8(x0?.error||"could not create folder");return}let n0=await w(T0);if(L8(!1),n0?.ok)V8(!1),D9("");else k8(n0?.error||"could not create board")},[y8,A9,w,v,Q8,B0]),a0=p.useMemo(()=>{let T0=0;for(let n0 of Q)for(let x0 of n0.paths||[])if(C5.test(x0))T0++;return T0},[Q]),e8=p.useMemo(()=>{let T0=0;for(let n0 of Y8)for(let x0 of n0.paths||[])if(C5.test(x0))T0++;return T0},[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":$0&&Q8==="board",onClick:()=>{k8(""),p8("board"),V8((T0)=>Q8==="board"?!T0:!0)},children:z(T9,{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":$0&&Q8==="folder",onClick:()=>{k8(""),p8("folder"),V8((T0)=>Q8==="folder"?!T0:!0)},children:z(T9,{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(T9,{name:"reload",size:15})}),D("span",{className:"st-live","data-tip":U?"live · file index synced":"reconnecting…",children:[z("span",{className:"st-live-dot"+(U?" is-connected":""),"aria-hidden":"true"}),e8," / ",a0]}),$&&z("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:$,children:z(T9,{name:"panel-left",size:15})})]})]}),$0?D("div",{className:"st-newboard",children:[z("input",{type:"text",autoFocus:!0,placeholder:Q8==="folder"?"folder name…":"brief board name…",value:y8,maxLength:60,disabled:A9,"aria-label":Q8==="folder"?"New folder name":"New brief board name",onChange:(T0)=>D9(T0.target.value),onKeyDown:(T0)=>{if(T0.key==="Enter")T0.preventDefault(),J8();else if(T0.key==="Escape")T0.preventDefault(),V8(!1),D9(""),k8("")}}),z("button",{type:"button",className:"st-newboard-go",disabled:A9||!y8.trim(),"data-tip":"Create · Enter","aria-label":Q8==="folder"?"Create folder":"Create brief board",onClick:J8,children:A9?"…":"↵"})]}):null,f0?z("div",{className:"st-newboard-err",role:"alert",children:f0}):null,z("div",{className:"st-search",children:D("div",{className:"st-search-box",children:[z(T9,{name:"search",size:13}),z("input",{type:"search","data-testid":"canvas-search",placeholder:"Search canvases…",value:V,onChange:(T0)=>B(T0.target.value),onKeyDown:(T0)=>{if(T0.key==="Escape")if(T0.preventDefault(),V)B("");else T0.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(Hy,{"aria-label":"Project file tree","data-testid":"canvas-list",children:Y8.map((T0)=>{if(!F&&!V&&T0.kind==="runtime")return null;let n0=AL0(T0),x0=(T0.paths||[]).filter((m7)=>C5.test(m7)).length,g0=n0.pill||(n0.pillFromDsCount?String(T0.dsFolders?.length||0):null)||(n0.pillFromCount?String(x0||T0.paths?.length||0):null),P8=T0.tree&&Object.keys(T0.tree).length>0,A0=T0.label==="Design system",W8=T0.kind==="project";if(!F&&!V&&W8&&x0===0)return null;let _8=JL0(T0),U0=M[T0.label],i0=!!V||(U0===void 0?_8:U0),I8=!A0&&T0.kind==="canvas"&&!J,Y9=I8?E8.dropProps(T0.fullPath,!0):{},d0=E8.overDir===T0.fullPath;return z(cz,{className:"st-tree-section",label:n0.title,expanded:i0,onToggle:()=>A(T0.label,_8),row:D("button",{type:"button",className:"st-tree-sec-hd"+(d0?" is-drop-target":""),"data-testid":`tree-section-${T0.label.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,onClick:()=>A(T0.label,_8),"aria-expanded":i0,"aria-dropeffect":I8?"move":void 0,title:i0?"Collapse section":"Expand section",...Y9,children:[z(T9,{name:"chevron-right",className:"st-chev"+(i0?" is-open":""),size:13}),z("span",{className:"st-sec-name",children:n0.title}),g0&&z("span",{className:"st-pill",children:g0})]}),children:i0&&(P8?z(t90,{node:T0.tree,activePath:Y,previewPath:W,onOpen:Z,onPreview:H,commentsByFile:N,depth:1,kind:T0.kind,showHidden:F,search:V,dsFolders:T0.dsFolders,activeDsName:G,onOpenSystem:A0?K:void 0,onDelete:A0||J?void 0:O,dirtyByPath:f,canvasKinds:h,dirPath:T0.fullPath,drag:!A0&&T0.kind==="canvas"&&!J?E8:void 0,menu:C8,expansion:E}):z("div",{className:"st-tree-empty",children:V?"No matches.":"Empty."}))},T0.label)})}),z(Zy,{state:C8.state,onClose:C8.close,rootItems:C0,destinations:_0,onPickDestination:(T0)=>u(o0.path,T0)}),z(ME,{project:m,liveBranch:c,remoteSync:o,onGetLatest:x,projectOnly:e0}),X===null?z(yw,{syncStatus:z0,onLinkedHub:i,onLocalProject:q0,onOpenFile:Z0,filesReady:P0}):null,z(hw,{})]})}function wL0({shown:J,onExpand:X,onSearch:Q}){return z("div",{className:"st-rail"+(J?" is-shown":""),children:D("div",{className:"st-rail-inner",children:[z("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:X,children:z(T9,{name:"panel-left",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:z(T9,{name:"search",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:X,children:z(T9,{name:"folder",size:15})})]})})}function EL0({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",_T]}),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 MT=[{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 PL0({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 IL0({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=MT.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:MT.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(PL0,{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 · ",MT.length," groups"]})]})]})})}var kL0=["File","Edit","View","Selection","Tools","Help"];function e90(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 TL0({panels:J,onToggle:X,onClose:Q,onZoom:Y,hasCanvas:W}){return e90(Q),D("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[z("div",{className:"st-dd-hd",children:"Panels"}),J.map((G)=>D("button",{type:"button",role:"menuitem",className:"st-dd-item"+(G.checked?" is-on":""),"aria-disabled":G.disabled?"true":void 0,title:G.hint||void 0,onClick:()=>{if(G.disabled){if(G.href)window.open(G.href,"_blank","noopener,noreferrer"),Q();return}X(G.id),Q()},children:[D("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check",children:G.checked?z(T9,{name:"check",size:13}):null}),z("span",{children:G.label}),G.phase?z("span",{className:"st-dd-phase",children:G.phase}):null]}),G.shortcut?z(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 X1({label:J,left:X,header:Q,items:Y,onAction:W,onClose:G}){return e90(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 RL0({onAction:J,onClose:X}){return z(X1,{label:"Help",left:320,onAction:J,onClose:X,items:[{id:"shortcuts",label:"Keyboard shortcuts",shortcut:"?"},{id:"help",label:"Help · commands & flows",shortcut:"F1"},{id:"report-bug",label:"Report a bug…"},{sep:!0},{id:"tour",label:"Take the tour"},{id:"watch-intro",label:"Watch the intro"},...H9()?[{id:"collab-tour",label:"How sharing works"}]:[],...H9()?[{id:"quick-setup",label:"Quick setup"}]:[],...H9()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function CL0({onAction:J,onClose:X,readOnly:Q=!1}){return z(X1,{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 $L0({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(X1,{label:"Tools",left:290,header:"Tool palette",onAction:J,onClose:X,items:Y})}function SL0({onAction:J,onClose:X,hasCanvas:Q,hasSharePath:Y,readOnly:W=!1}){return z(X1,{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 bL0({onAction:J,onClose:X,hasCanvas:Q,readOnly:Y=!1}){if(Y)return z(X1,{label:"Edit",left:90,onAction:J,onClose:X,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"}]});return z(X1,{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 yL0({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:r,onOpenWhatsNew:e,onOpenReadiness:s,onOpenQuickSetup:H0,onWatchIntro:a,whatsNewCount:z0,exportCenter:i,artboardCount:q0=0,presence:Z0=null,inspectorOpen:P0,inspectorTab:s0,onToggleInspector:e0,autoOpenInspector:Y8,onToggleAutoOpenInspector:E8,onOpenLayers:C8,timelineOpen:t8,onToggleTimeline:o0,hasComps:C0=!1,assistantOpen:_0,onToggleAssistant:$0,assistantBusy:V8,assistantUnseen:Q8,onNewCanvas:p8,onAssembleVideo:y8,onOpenExport:D9,onOpenSettings:f0,onOpenGenerate:k8,onReload:A9,onCloseCanvas:L8,onInsertArtboard:B0,readOnly:J8=!1}){let a0=J===o8,e8=a0?"SYSTEM":J?"CANVAS":"IDLE",T0=a0?z("b",{children:"design system"}):J?D(Q0,{children:[J.split("/").slice(0,-1).join("/"),"/",z("b",{children:X4(UQ(J))})]}):z("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),n0=new Set(W?["autoopen"]:["assistant","autoopen"]),x0=[{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:P0&&s0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:P0,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!Y8,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:C0?"video":void 0,checked:t8,disabled:!1},...H9()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:_0,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||a0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:c,disabled:!J||a0},{id:"present",label:"Presentation Mode",shortcut:"",checked:x,disabled:!J||a0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:u,disabled:!J||a0}].filter((A0)=>!J8||!n0.has(A0.id)),g0=["file","edit","view","selection","tools","help"];function P8(A0){if(g0.includes(A0))H(Z===A0?null:A0)}return p.useEffect(()=>{if(!Z||!g0.includes(Z))return;let A0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function W8(_8){let U0=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!U0.length)return;let i0=U0.indexOf(document.activeElement);if(_8.key==="ArrowDown")_8.preventDefault(),U0[(i0+1)%U0.length].focus();else if(_8.key==="ArrowUp")_8.preventDefault(),U0[(i0-1+U0.length)%U0.length].focus();else if(_8.key==="Home")_8.preventDefault(),U0[0].focus();else if(_8.key==="End")_8.preventDefault(),U0[U0.length-1].focus();else if(_8.key==="ArrowRight"||_8.key==="ArrowLeft"){_8.preventDefault();let I8=_8.key==="ArrowRight"?1:-1,Y9=g0.indexOf(Z);H(g0[(Y9+I8+g0.length)%g0.length])}else if(_8.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",W8),()=>{clearTimeout(A0),window.removeEventListener("keydown",W8)}},[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:kL0.map((A0)=>{let W8=A0.toLowerCase(),_8=g0.includes(W8),U0=_8||W8==="help",i0=Z===W8;return z("button",{type:"button",className:"st-menu",role:"menuitem","data-testid":`menu-${W8}`,"data-tour":W8==="help"?"help":void 0,"aria-haspopup":_8?"menu":void 0,"aria-expanded":_8?i0:void 0,onClick:()=>P8(W8),onMouseEnter:()=>{if(Z!==null&&_8)H(W8)},children:A0},W8)})}),Z==="file"&&z(SL0,{readOnly:J8,hasCanvas:!!J,hasSharePath:!!X,onAction:(A0)=>{if(A0==="new")p8?.();else if(A0==="assemble")y8?.();else if(A0==="export")D9?.("export");else if(A0==="share")document.querySelector('[data-testid="menu-file"]')?.focus(),Q?.();else if(A0==="handoff")D9?.("handoff");else if(A0==="generate")k8?.();else if(A0==="settings")f0?.();else if(A0==="reload")A9?.();else if(A0==="close")L8?.()},onClose:()=>H(null)}),Z==="edit"&&z(bL0,{readOnly:J8,hasCanvas:!!J&&!a0,onAction:(A0)=>{if(A0==="undo")r({dgn:"undo"});else if(A0==="redo")r({dgn:"redo"});else if(A0==="deselect-all")r({dgn:"selection-clear"});else if(A0==="select-all-annotations")r({dgn:"annotation-select-all"});else if(A0.startsWith("new-artboard:"))B0?.(A0.slice(13))},onClose:()=>H(null)}),Z==="view"&&z(TL0,{panels:x0,onToggle:(A0)=>{if(A0==="tree")A();else if(A0==="changes")N();else if(A0==="comments")U();else if(A0==="hidden")w();else if(A0==="annotate")j();else if(A0==="inspector")e0();else if(A0==="autoopen")E8?.();else if(A0==="timeline")o0?.();else if(A0==="assistant")$0?.();else if(A0==="layers")C8?.();else if(A0==="minimap")m?.();else if(A0==="zoomctl")o?.();else if(A0==="present")h?.();else if(A0==="print-guides")v?.()},onZoom:(A0)=>r({dgn:"zoom",op:A0}),hasCanvas:!!J&&!a0,onClose:()=>H(null)}),Z==="selection"&&z(CL0,{readOnly:J8,onAction:(A0)=>{if(A0==="deselect-all")r({dgn:"selection-clear"});else if(A0==="select-all-annotations")r({dgn:"annotation-select-all"})},onClose:()=>H(null)}),Z==="tools"&&z($L0,{readOnly:J8,onAction:(A0)=>r({dgn:"tool-set",tool:A0}),onClose:()=>H(null)}),Z==="help"&&z(RL0,{onAction:(A0)=>{if(A0==="shortcuts")I?.();else if(A0==="help")O?.();else if(A0==="report-bug")T?.();else if(A0==="tour")R?.();else if(A0==="collab-tour")$?.();else if(A0==="quick-setup")H0?.();else if(A0==="readiness")s?.();else if(A0==="whatsnew")e?.();else if(A0==="watch-intro")a?.()},onClose:()=>H(null)}),D("div",{className:"st-mb-right","data-tour":"status",children:[Z0?z("div",{className:"st-presence",children:Z0}):null,J8&&z("span",{className:"st-stamp st-stamp--viewonly","data-testid":"view-only-stamp","data-tip":W?.user?`${W.user} is a viewer on this project — you can browse, comment and export where available. Ask a project owner for edit access, or sign out if that is not the account you meant to use.`:"Your role in this project is viewer — you can browse, comment when available, and export where available. Ask a project owner for edit access.",children:"VIEW ONLY"}),W?.user?D("span",{className:"st-cloudwho","data-testid":"cloud-account",children:[z("span",{className:"st-cloudwho-email",title:W.role?`Signed in as ${W.user} — ${W.role}`:W.user,children:W.user}),z("form",{method:"post",action:"/auth/browser/signout",className:"st-cloudwho-form",children:z("button",{type:"submit",className:"st-cloudwho-out","data-testid":"cloud-signout",title:"Sign out of this project",children:"Sign out"})})]}):null,H9()&&!J8&&z("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":_0?"true":"false","data-busy":V8?"true":"false","data-unseen":Q8?"true":"false","aria-label":`Assistant${V8?" — working":Q8?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:$0,children:z(T9,{name:"sparkle",size:15})}),z("button",{type:"button",className:"st-mb-icon st-share-btn","data-testid":"share-btn","data-tip":X?"Share link":"Open a canvas to share it","aria-label":"Share link",disabled:!X,onClick:Q,children:z(T9,{name:"share",size:15})}),i&&z(fm,{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(T9,{name:"bug",size:15})}),z("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":z0>0?"true":"false","aria-label":`What's new${z0>0?` — ${z0} unseen`:""}`,"data-tip":"What's new",onClick:e,children:z(T9,{name:"megaphone",size:15})}),z("span",{className:"st-stamp",children:e8}),z("span",{className:"st-mb-file",title:J||"",children:T0}),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 jL0({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=PZ($,{...H,canvasToken:void 0}),j=`${$}#${B}|${C}`,f=O.current.get(j);if(!f)f={path:$,src:PZ($,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: ${wK(UQ(E))}`,tabIndex:0,children:z(ig,{path:E,kind:EL(UQ(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",_T," / 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.",H9()?D(Q0,{children:[z("br",{}),z("br",{}),"Claude can see whatever's selected when you ask for a change in the Assistant panel, so pointing is often faster than describing it."]}):null]}),M&&z("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:A,children:"Start quick setup"})]}),J.map(($)=>{if($.path===o8)return z("div",{className:"system-view"+($.path===X?" active":""),children:z(lL0,{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(vL0,{path:K,cloud:!!H?.cloud},K),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:wK(UQ(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"})]})})]})}function vL0({path:J,cloud:X}){let[Q,Y]=p.useState(!1);p.useEffect(()=>{let G=setTimeout(()=>Y(!0),4000);return()=>clearTimeout(G)},[]);let W=wK(UQ(J||"").replace(/\.(tsx|jsx|html?)$/i,""));return z("div",{className:"st-canvas-loading",role:"status","aria-live":"polite","data-testid":"canvas-loading",children:D("div",{className:"st-skel-card",children:[D("div",{className:"st-canvas-loading-head",children:[z("span",{className:"st-canvas-loading-spinner","aria-hidden":"true"}),D("span",{className:"st-canvas-loading-title",children:["Opening ",W,"…"]})]}),z("span",{className:"skel st-skel-thumb","aria-hidden":"true"}),z("span",{className:"skel st-skel-line",style:{width:"72%"},"aria-hidden":"true"}),z("span",{className:"skel st-skel-line",style:{width:"46%"},"aria-hidden":"true"}),z("div",{className:"st-canvas-loading-hint"+(Q?" is-shown":""),children:X?"Still working — the first open of a canvas fetches its images and fonts from cloud storage. It is quicker next time.":"Still working — large canvases take a moment to build."})]})})}var fL0=["color","space","radius","shadow","leading","weight","motion","font","other"],xL0={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function hL0(J){return J==="color"}function gL0({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([...fL0,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return z(Q0,{children:W.map((G)=>{let Z=Y[G],H=hL0(G);return D("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[D("h2",{children:["tokens · ",xL0[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 mL0(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 uL0(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 pL0({tokenGroups:J}){let X=J?.fontsize||[];if(X.length===0)return null;let Q=J?.leading||[],Y=uL0(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=mL0(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 lL0({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(gL0,{tokens:H,tokenGroups:K,tokensPath:U}),z(pL0,{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(y90,{title:"preview",items:W,onOpen:X,kind:"preview",cfg:Q}),z(y90,{title:"ui kits",items:G,onOpen:X,kind:"ui_kits",cfg:Q})]})]})}function y90({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:PZ(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 dL0({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=dz(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(T9,{name:W==="dark"?"sun":"moon",size:13}),T]})]})}function cL0({commentsByFile:J,filter:X,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:K,width:U,resizing:V}){let B=s90(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(UQ(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:GL0(A.created)})]}),z("div",{className:"st-comment-txt",children:A.text}),D("div",{className:"st-comment-foot",children:[z("span",{className:"st-comment-sel",title:(A.dom_path||[]).join(" > "),children:A.selector||"—"}),Z&&H&&K?D("span",{className:"st-mini-act",children:[A.status==="resolved"?z("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(E)=>{E.stopPropagation(),H(A.id)},children:z(T9,{name:"reopen",size:14})}):z("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(E)=>{E.stopPropagation(),Z(A.id)},children:z(T9,{name:"resolve",size:14})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(E)=>{E.stopPropagation(),K(A.id)},children:z(T9,{name:"x",size:14})})]}):null]})]},A.id))]},M.file))})]})}var iL0={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 oL0({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=iL0[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 nL0({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),bh().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X,children:"Later"})]})}function rL0({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 aL0=["block","inline-block","flex","inline-flex","grid","inline","none"],j90=["px","%","fr","em","auto","min-content","max-content"];var sL0=["auto","stretch","flex-start","center","flex-end","baseline"];var v90=["300","400","500","600","700","800"],Mq=(J,X)=>J&&Object.hasOwn(J,"previous")?J.previous:X,f90=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],x90=["none","solid","dashed","dotted","double"],h90=["px","rem","em","%","vw","vh","auto"],g90=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),OT={"font-size":{node:z(z7,{as:mV,size:12})},"line-height":{node:z(z7,{as:oV,size:12})},"letter-spacing":{node:z(z7,{as:Q3,size:12})},gap:{node:z(z7,{as:PK,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:z(z7,{as:H3,size:12})},"border-width":{node:z(z7,{as:X3,size:12})}};var m90=["static","relative","absolute","fixed","sticky"],tL0=["normal","italic","oblique"],u90=["none","uppercase","lowercase","capitalize"];var p90=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],eL0=["fill","contain","cover","none","scale-down"];var l90=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],d90=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],R5={desktop:{label:"Desktop",width:1440,height:1024},laptop:{label:"Laptop",width:1280,height:800},tablet:{label:"Tablet",width:834,height:1194},mobile:{label:"Mobile",width:390,height:844}},tK=null;function wL(J){if(!J)return"";if(/^#[0-9a-f]{6}$/i.test(J))return J.toLowerCase();try{if(!tK)tK=document.createElement("canvas").getContext("2d");if(!tK)return"";tK.fillStyle="#000000",tK.fillStyle=J;let X=tK.fillStyle;if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();let Q=X.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(Q)return`#${[Q[1],Q[2],Q[3]].map((Y)=>Number(Y).toString(16).padStart(2,"0")).join("")}`}catch{}return""}var 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 Oq({r:J,g:X,b:Q}){return`#${[J,X,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function Aq({r:J,g:X,b:Q}){J/=255,X/=255,Q/=255;let Y=Math.max(J,X,Q),W=Math.min(J,X,Q),G=Y-W,Z=0;if(G){if(Y===J)Z=(X-Q)/G%6;else if(Y===X)Z=(Q-J)/G+2;else Z=(J-X)/G+4;if(Z*=60,Z<0)Z+=360}return{h:Z,s:Y?G/Y:0,v:Y}}function eK({h:J,s:X,v:Q}){let Y=Q*X,W=Y*(1-Math.abs(J/60%2-1)),G=Q-Y,Z=0,H=0,K=0;if(J<60)[Z,H,K]=[Y,W,0];else if(J<120)[Z,H,K]=[W,Y,0];else if(J<180)[Z,H,K]=[0,Y,W];else if(J<240)[Z,H,K]=[0,W,Y];else if(J<300)[Z,H,K]=[W,0,Y];else[Z,H,K]=[Y,0,W];return{r:(Z+G)*255,g:(H+G)*255,b:(K+G)*255}}function V7(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 c90(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 J70(J,X){return(J?X?.canvasDesignSystems?.[J]:null)||X?.defaultDesignSystem||X?.designSystems?.[0]?.name||null}function JD0(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 X70(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,...JD0(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 Q70({seed:J,label:X,onApply:Q}){let[Y,W]=p.useState(()=>Aq(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(Aq(FL(J)))},[J]);let U=Oq(eK(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(Oq(eK(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(Oq(eK(G.current)))};document.addEventListener("pointermove",$),document.addEventListener("pointerup",C)},N=(O)=>{let I={...G.current,...O};W(I),Q(Oq(eK(I)))},F=(O)=>{let I=O.shiftKey?0.1:0.02,R={ArrowLeft:[-I,0],ArrowRight:[I,0],ArrowUp:[0,I],ArrowDown:[0,-I]}[O.key];if(!R)return;O.preventDefault(),N({s: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(Aq(FL(I.sRGBHex))),Q(I.sRGBHex)}catch{}},E=eK(Y),w=(O)=>{let I={...E,...O},T=Aq({r:FY(I.r/255)*255,g:FY(I.g/255)*255,b:FY(I.b/255)*255});W(T),Q(Oq(eK(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(Aq(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(T9,{name:"eyedropper",size:14})}):null,z("span",{className:"st-cp-cpick-preview",style:{background:U},"aria-hidden":"true"}),z("button",{type:"button",ref:H,className:"st-cp-cpick-hue","aria-label":X?`${X} hue`:"hue",onPointerDown:B,onKeyDown:M,children:z("span",{className:"st-cp-cpick-huethumb",style:{left:`${Y.h/360*100}%`}})})]}),z("div",{className:"st-cp-cpick-rgb",children:["r","g","b"].map((O)=>D("label",{className:"st-cp-cpick-rgbf",children:[z("input",{"aria-label":O.toUpperCase(),value:Math.round(E[O]),onChange:(I)=>w({[O]: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 s0=window.innerHeight-z0.bottom>q0+8?z0.bottom+4:Math.max(8,z0.top-q0-4);N({left:Z0,top:s0,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)},a=(z0)=>{if(O.current?.contains(z0.target))return;e()};return document.addEventListener("pointerdown",s,!0),document.addEventListener("keydown",H0),window.addEventListener("resize",e),document.addEventListener("scroll",a,!0),()=>{document.removeEventListener("pointerdown",s,!0),document.removeEventListener("keydown",H0),window.removeEventListener("resize",e),document.removeEventListener("scroll",a,!0)}},[U]),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((a)=>a?{...a,left:a.left+s,top:a.top+H0}:a)},[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(T9,{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)),r=z("div",{className:"st-cp-pop-empty",children:"No match"});return D(Q0,{children:[G!==void 0?z("button",{type:"button",ref:w,className:`${K||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${I&&!K?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>V((e)=>!e),children:z("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):z("button",{type:"button",ref:w,className:`st-cp-tokbtn${I?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>V((e)=>!e),children:z("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),U&&B?o90.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(Q70,{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):r]})]}):!C?z("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):D(Q0,{children:[h,m.length?v(m):r]})}),document.body):null]})}function i90({label:J,tracks:X,editable:Q,onChange:Y}){let W=(K,U)=>{let V=X[K];Y(X.map((B,N)=>N===K?xU.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=xU.has(K.unit);return D("div",{className:"st-cp-gridtrack-row",children:[V?z(XG,{value:K.unit,ariaLabel:`${J} track ${U+1}`,options:j90.map((B)=>({value:B,label:B})),onChange:(B)=>W(U,B)}):z(HJ,{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:j90,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 J1={pending:0,waiters:[]};function Y70(J){J1.pending+=1;let X=()=>{if(J1.pending-=1,J1.pending===0)for(let Q of J1.waiters.splice(0))Q()};return J.then(X,X),J}function XD0(){return J1.pending===0?Promise.resolve():new Promise((J)=>J1.waiters.push(J))}function QD0({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,O0)=>{let w0={...t||{}};for(let[m0,t0]of Object.entries(O0))if(t0===null)delete w0[m0];else w0[m0]=t0;return w0},F=N(J.authored,V.a),M=N(J.customStyles,V.c),A=N(J.attrs,V.t),E=(t,O0)=>B((w0)=>({...w0,a:{...w0.a,[t]:O0}})),w=(t,O0)=>B((w0)=>({...w0,c:{...w0.c,[t]:O0}})),O=(t,O0)=>B((w0)=>({...w0,t:{...w0.t,[t]:O0}})),I=(X?.designRel||X?.designRoot||".design").replace(/^\/+|\/+$/g,""),T=J70(J.file,X),R=X70(X,I,T),$=(t)=>R.map((O0)=>({ds:O0.name,names:O0[t]||[],vals:O0.vals})).filter((O0)=>O0.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||V7(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,O0,w0){j((m0)=>({...m0,[w0]:"saving"}));try{let m0=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(O0)}),t0=await m0.json().catch(()=>({}));return j((l8)=>({...l8,[w0]:!m0.ok||!t0.ok?`err:${t0&&t0.error||`HTTP ${m0.status}`}`:"saved"})),m0.ok?t0:null}catch(m0){return j((t0)=>({...t0,[w0]:`err:${m0&&m0.message?m0.message:String(m0)}`})),null}}let r=p.useRef(Promise.resolve()),e=(t,O0,w0,m0,t0,l8,s8)=>{r.current=Y70(r.current.then(async()=>{let v8=await v(t,O0,w0);if(!v8?.ok)return;let Z9=Object.hasOwn(v8,"previous")?v8.previous:l8;if((Z9??null)===(s8??null))return;H0(m0,t0,Z9,s8)}))},s=(t,O0)=>{if(!Q||!J.id)return;Q({id:J.id,artboardId:J.artboardId??null,index:J.index??0,prop:t,value:O0})},H0=(t,O0,w0,m0)=>{Y?.({op:t,canvas:J.file,id:J.id,key:O0,before:w0==null||w0===""?null:w0,after:m0==null||m0===""?null:m0})},a=(t,O0)=>{let w0=(O0||"").trim();if(!K||!w0)return;let m0=F[t]??null;if(w0===(m0??"").trim())return;s(t,w0),E(t,w0),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,value:w0},t,"css",t,m0,w0)},z0=(t,O0)=>{let w0=(O0||"").trim(),m0=t.trim();if(!K||!m0||!w0)return;let t0=M[m0]??null;s(m0,w0),w(m0,w0),e("/_api/edit-css",{canvas:J.file,id:J.id,property:m0,value:w0},m0,"css",m0,t0,w0)},i=(t,O0)=>{let w0=(t||"").trim(),m0=(O0||"").trim();if(!K||!w0||!m0)return;let t0=A[w0]??null;O(w0,m0),e("/_api/edit-attr",{canvas:J.file,id:J.id,attr:w0,value:m0},`@${w0}`,"attr",w0,t0,m0)},q0=(t)=>{if(!K)return;let O0=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,O0,null)},Z0=(t)=>{if(!K)return;let O0=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,O0,null)},P0=(t)=>{if(!K)return;let O0=A[t]??null;O(t,null),e("/_api/edit-attr",{canvas:J.file,id:J.id,attr:t,reset:!0},`@${t}`,"attr",t,O0,null)},s0={display:J.parentDisplay,flexDirection:J.parentFlexDirection},e0=(t,O0)=>{if(!K)return;let w0=Math.round((t==="width"?J.bounds?.w:J.bounds?.h)||0),m0=ab(t,O0,s0,w0);for(let t0 of m0.reset)if(F[t0])q0(t0);for(let[t0,l8]of m0.set)a(t0,l8)},Y8=J.parentDisplay==="flex"||J.parentDisplay==="inline-flex",E8=(t)=>{let O0=rb(t,F,U,s0);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:O0,ariaLabel:`${t} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(w0)=>e0(t,w0)})})]},`mode-${t}`)},C8=["flex-start","center","flex-end"],t8=["flex-start","center","flex-end"],o0=["t","c","b"],C0=["l","c","r"],_0=()=>{let t=!(F["flex-direction"]||V7(U["flex-direction"])||"row").startsWith("column"),O0=Math.max(0,C8.indexOf(F["justify-content"]||V7(U["justify-content"])||"flex-start")),w0=F["align-items"]||V7(U["align-items"])||"stretch",m0=w0==="stretch"?1:Math.max(0,t8.indexOf(w0)),[t0,l8]=t?[O0,m0]:[m0,O0];return o0[l8]+C0[t0]},$0=(t)=>{let O0=o0.indexOf(t[0]),w0=C0.indexOf(t[1]),m0=!(F["flex-direction"]||V7(U["flex-direction"])||"row").startsWith("column"),[t0,l8]=m0?[w0,O0]:[O0,w0];a("justify-content",C8[t0]),a("align-items",t8[l8])},V8=(t)=>{if(!(t.metaKey||t.ctrlKey)||t.altKey)return;let O0=t.key.toLowerCase();if(O0==="z")t.preventDefault(),G?.(t.shiftKey?"redo":"undo");else if(O0==="y")t.preventDefault(),G?.("redo")},Q8=(t)=>{let O0=F[t];if(!O0)return"inherit";return/var\(\s*--/.test(O0)?"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 p8={bound:"token-bound",raw:"raw override",inherit:"inherited"},y8=(t)=>z("span",{className:`st-cp-prov st-cp-prov--${t}`,role:"img","aria-label":p8[t]}),D9=(t,O0)=>{let w0=O0??Q8(t),m0=C[t],t0=typeof m0==="string"&&m0.startsWith("err:")?m0.slice(4):"",l8=t0?" is-err":m0==="saved"?" is-saved":m0==="saving"?" is-saving":"",s8=!!F[t],v8=t0?`error: ${t0}`:s8?`${p8[w0]} · double-click to reset`:p8[w0];return z("button",{type:"button",className:`st-cp-prov st-cp-prov--${w0}${l8}${s8?" is-resettable":""}`,"aria-label":v8,title:v8,tabIndex:s8?0:-1,onDoubleClick:s8?()=>q0(t):void 0,onKeyDown:s8?(Z9)=>{if(Z9.key==="Backspace"||Z9.key==="Delete")Z9.preventDefault(),q0(t)}:void 0})},f0=(t,O0,w0,m0)=>{let t0=w0===void 0&&!F[t],l8=m0??t;return D("div",{className:`st-cp-row${t0?" is-unset":""}`,children:[D9(t,w0),z("label",{className:"st-cp-label",title:l8,children:l8}),z("div",{className:"st-cp-ctl",children:O0})]},t)},k8={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)=>{(k8[t]||[]).forEach((O0)=>{if(F[O0])q0(O0)})},L8=(t,O0)=>{let w0=(k8[t]||[]).some((m0)=>F[m0]);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((m0)=>({...m0,[t]:!m0[t]})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:f[t]?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${w0?"":" is-quiet"}`,"aria-label":`reset ${t} section to original`,title:`reset ${t}`,disabled:!w0,onClick:()=>A9(t),children:z(z7,{as:nZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${f[t]?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:O0})})]},t)},B0=(t,O0,w0,m0=!0)=>{let t0=`d:${t}`,l8=f[t0]===void 0?m0:f[t0],s8=O0.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":l8,onClick:()=>m((v8)=>({...v8,[t0]:!l8})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:l8?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${s8?"":" is-quiet"}`,"aria-label":`reset ${t} to original`,title:`reset ${t}`,disabled:!s8,onClick:()=>O0.forEach((v8)=>{if(F[v8])q0(v8)}),children:z(z7,{as:nZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${l8?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:w0})})]},t0)},J8=(t)=>z("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!h[t],"aria-label":h[t]?`${t} — fewer options`:`${t} — more options`,title:h[t]?"fewer":"more",onClick:()=>u((O0)=>({...O0,[t]:!O0[t]})),children:h[t]?"▴":"···"}),a0=(t,O0)=>D("select",{className:"st-cp-nsel","aria-label":t,value:O0.includes(F[t])?F[t]:"",onChange:(w0)=>a(t,w0.target.value),children:[z("option",{value:"",disabled:!0,children:V7(U[t])||"—"}),O0.map((w0)=>z("option",{value:w0,children:w0},w0))]}),e8=(t)=>$(t).flatMap((O0)=>(O0.names||[]).map((w0)=>({name:w0,value:O0.vals?.[w0]||""}))),T0=(t,O0)=>z(tw,{value:F[t]||V7(U[t])||O0[0].value,ariaLabel:t,options:O0,onChange:(w0)=>a(t,w0)}),n0=(t,O0,w0={})=>{let m0=J4(F[t]??""),t0=g90.has(t),l8=F[t]??"",s8=typeof l8==="string"&&/var\(\s*--/.test(l8),v8=t0?"":m0.unit&&m0.unit!=="auto"?m0.unit:"px",Z9=Number.parseFloat(J4(V7(U[t])??"").n)||0,h9=m0.n!==""&&m0.n!=null?Number.parseFloat(m0.n)||0:Z9,b9=OT[t];return z(sN,{value:s8?l8:h9,tokens:e8(O0),ariaLabel:t,min:w0.min??0,lead:b9?b9.node??b9.t:void 0,unitSlot:t0?null:z(rN,{units:h90,value:m0.unit||"px",ariaLabel:`${t} unit`,onChange:(K7)=>a(t,K7==="auto"?"auto":`${m0.n||"0"}${K7}`)}),onChange:(K7)=>a(t,typeof K7==="string"?K7:t0?`${K7}`:`${K7}${v8}`)})},x0=()=>{let t=(t0)=>Number.parseFloat(J4(F[t0]??F["border-radius"]??V7(U[t0])??V7(U["border-radius"])??"0").n)||0,O0={tl:t("border-top-left-radius"),tr:t("border-top-right-radius"),bl:t("border-bottom-left-radius"),br:t("border-bottom-right-radius")},w0=(t0)=>{if(t0.tl===t0.tr&&t0.tr===t0.bl&&t0.bl===t0.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((s8)=>{if(F[s8])q0(s8)}),a("border-radius",`${t0.tl}px`);else a("border-top-left-radius",`${t0.tl}px`),a("border-top-right-radius",`${t0.tr}px`),a("border-bottom-left-radius",`${t0.bl}px`),a("border-bottom-right-radius",`${t0.br}px`)},m0=OT["border-radius"];return z(Qm,{corners:O0,lead:m0?m0.node??m0.t:void 0,onCorners:w0})},g0=()=>D("div",{className:"st-cp-border",children:[j8("border-width",null,{fixedUnit:"px"}),D("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:x90.includes(F["border-style"])?F["border-style"]:"",onChange:(t)=>a("border-style",t.target.value),children:[z("option",{value:"",disabled:!0,children:"style"}),x90.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)=>a("border-color",t),label:"border colour"})]}),P8=()=>{let t=F.transform||V7(U.transform)||"",O0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(t),w0=((O0?Number.parseFloat(O0[1]):0)%360+360)%360,m0=(t0)=>{let l8=(t0%360+360)%360,s8=(F.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();a("transform",`${s8?`${s8} `:""}rotate(${l8}deg)`.trim())};return D("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[z(Jm,{value:w0,onChange:m0}),z(HJ,{value:w0,min:0,max:360,ariaLabel:"rotation",lead:z(z7,{as:nZ}),steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:m0})]})},A0=()=>{let t=F.filter||V7(U.filter)||"",O0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(t),w0=O0?Number.parseFloat(O0[1]):0;return z(HJ,{value:w0,min:0,ariaLabel:"filter blur",unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(t0)=>{let l8=(F.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();a("filter",t0>0?`${l8?`${l8} `:""}blur(${t0}px)`.trim():l8||"none")}})},W8=()=>{let t=F.opacity,O0=t!=null&&t!==""?Number.parseFloat(t):Number.parseFloat(V7(U.opacity))||1,w0=Math.round((Number.isNaN(O0)?1:O0)*100);return z(hX,{value:w0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(m0)=>s("opacity",String(m0/100)),onCommit:(m0)=>a("opacity",String(m0/100))},`opacity:${t??""}`)},_8=()=>{let t=Number.parseInt(F["font-weight"]||V7(U["font-weight"])||"400",10)>=600,O0=(F["font-style"]||V7(U["font-style"]))==="italic",w0=/underline/.test(F["text-decoration"]||V7(U["text-decoration"])||"");return z(tg,{value:{b:t,i:O0,u:w0},ariaLabel:"text style",options:[{value:"b",node:z(z7,{as:nV}),label:"Bold"},{value:"i",node:z(z7,{as:eV}),label:"Italic"},{value:"u",node:z(z7,{as:U3}),label:"Underline"}],onToggle:(m0)=>{if(m0==="b")a("font-weight",t?"400":"700");else if(m0==="i")a("font-style",O0?"normal":"italic");else a("text-decoration",w0?"none":"underline")}})},U0=[{value:"row",node:z(z7,{as:cW}),label:"Row"},{value:"column",node:z(z7,{as:iW}),label:"Column"}],i0=[{value:"flex-start",node:z(z7,{as:lV}),label:"Start"},{value:"center",node:z(z7,{as:uV}),label:"Center"},{value:"flex-end",node:z(z7,{as:pV}),label:"End"},{value:"space-between",node:z(z7,{as:PK}),label:"Space between"}],I8=[{value:"flex-start",node:z(z7,{as:iV}),label:"Start"},{value:"center",node:z(z7,{as:dV}),label:"Center"},{value:"flex-end",node:z(z7,{as:cV}),label:"End"},{value:"stretch",node:z(z7,{as:z3}),label:"Stretch"}],Y9=[{value:"left",node:z(z7,{as:d5}),label:"Left"},{value:"center",node:z(z7,{as:rW}),label:"Center"},{value:"right",node:z(z7,{as:aW}),label:"Right"},{value:"justify",node:z(z7,{as:sW}),label:"Justify"}],d0=[{value:"visible",node:z(z7,{as:oZ}),label:"Visible"},{value:"hidden",node:z(z7,{as:rZ}),label:"Hidden"},{value:"scroll",node:z(z7,{as:G3}),label:"Scroll"}],m7=(t,O0)=>{let w0=$(O0);return w0.length?z(ML,{kind:"value",groups:w0,current:F[t],activeDs:T,onPick:(m0)=>a(t,m0),label:`${t} design token`}):null},_9=(t)=>{let O0=t.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===O0)O0.select()})},o7=(t,O0)=>{if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return!1;t.preventDefault();let w0=t.shiftKey?10:1,m0=t.key==="ArrowUp"?1:-1,t0=(Number.parseFloat(t.currentTarget.value)||0)+m0*w0;return t.currentTarget.value=String(t0),O0(t0),!0},T8=(t)=>z("input",{className:"st-cp-fin","aria-label":t,defaultValue:F[t]??"",placeholder:V7(U[t])||"—",onFocus:_9,onKeyDown:(O0)=>{if(O0.key==="Enter")O0.currentTarget.blur()},onBlur:(O0)=>a(t,O0.currentTarget.value)},`${t}:${F[t]??""}`),j8=(t,O0,w0={})=>{let m0=J4(F[t]??""),t0=g90.has(t),l8=t0?"":w0.fixedUnit||(m0.unit&&m0.unit!=="auto"?m0.unit:"px"),s8=OT[t],v8=Number.parseFloat(J4(V7(U[t])??"").n)||0,Z9=m0.n!==""&&m0.n!=null?Number.parseFloat(m0.n)||0:v8;return D(Q0,{children:[z(HJ,{value:Z9,min:w0.min??0,step:1,ariaLabel:t,lead:s8?s8.node??s8.t:void 0,onCommit:(h9)=>a(t,t0?`${h9}`:`${h9}${l8}`),unitSlot:t0||w0.fixedUnit?null:z(rN,{units:h90,value:m0.unit||"px",ariaLabel:`${t} unit`,onChange:(h9)=>a(t,h9==="auto"?"auto":`${m0.n||"0"}${h9}`)})},`${t}:${F[t]??""}`),m7(t,O0)]})},a8=(t)=>{let O0=U[t]||F[t]||"",w0=F[t]??"",m0=typeof w0==="string"&&/var\(\s*--/.test(w0),t0=m0?w0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):w0;return z(q3,{swatch:z(ML,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:$("color"),current:F[t],activeDs:T,swatchBg:O0,seedHex:wL(U[t]||F[t])||"#000000",onPick:(l8)=>a(t,l8),label:`${t} colour`}),displayValue:t0,bound:m0,ariaLabel:t,onValue:(l8)=>a(t,l8)})},I0=(t,O0)=>{let w0=null,m0=O0.unitless?"":"px",t0=(v8)=>O0.unitless?`${v8}`:`${v8}${m0}`,l8=(v8,Z9,h9)=>{for(let b9 of Z9??[t])h9(b9,t0(v8))},s8=sw({getBase:()=>w0?.value??"0",min:O0.min??0,step:1,sides:O0.sides,onInput:(v8,Z9)=>{if(w0)w0.value=String(v8);if(Z9){let h9=w0?.closest(".st-cp-box");for(let b9 of Z9){if(b9===t)continue;let K7=h9?.querySelector(`.st-cp-boxv[aria-label="${b9}"]`);if(K7)K7.value=String(v8)}}l8(v8,Z9,s)},onCommit:(v8,Z9)=>l8(v8,Z9,a)});return{onPointerDown:(v8)=>{w0=v8.currentTarget,s8(v8)}}},X8=(t,O0)=>{let w0=F[t],m0=w0!=null&&w0!==""?J4(w0).n||w0:J4(V7(U[t])??"").n||"0",t0=!w0||w0==="0"||w0==="0px"||w0==="auto",l8=t.split("-").pop(),s8=l8==="top"||l8==="bottom"?[`${O0}-top`,`${O0}-bottom`]:[`${O0}-left`,`${O0}-right`],v8=[`${O0}-top`,`${O0}-right`,`${O0}-bottom`,`${O0}-left`];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${O0[0]}${t.split("-").pop()[0]}${t0?" is-zero":""}`,"aria-label":t,defaultValue:m0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...I0(t,{sides:{pair:s8,all:v8}}),onFocus:_9,onKeyDown:(Z9)=>{if(o7(Z9,(h9)=>a(t,`${h9}px`)))return;if(Z9.key==="Enter")Z9.currentTarget.blur()},onBlur:(Z9)=>{let h9=Z9.currentTarget.value.trim();if(!h9)return;let b9=/[a-z%]/i.test(h9)?h9:`${h9}px`;a(t,b9)}},`${t}:${w0??""}`)},$8=(t)=>{let O0=F[t],w0=O0!=null&&O0!==""&&O0!=="auto"?J4(O0).n||O0:J4(V7(U[t])??"").n||"",m0=!O0||O0==="auto"||O0==="0"||O0==="0px",t0=t==="top"||t==="bottom"?["top","bottom"]:["left","right"],l8=["top","right","bottom","left"];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${t[0]}${m0?" is-zero":""}`,"aria-label":t,defaultValue:w0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...I0(t,{sides:{pair:t0,all:l8},min:-1/0}),onFocus:_9,onKeyDown:(s8)=>{if(o7(s8,(v8)=>a(t,`${v8}px`)))return;if(s8.key==="Enter")s8.currentTarget.blur()},onBlur:(s8)=>{let v8=s8.currentTarget.value.trim();if(!v8)return;let Z9=/[a-z%]/i.test(v8)?v8:`${v8}px`;a(t,Z9)}},`${t}:${O0??""}`)},W9=Object.entries(M),X7=Object.entries(A),c9=()=>{let t=(J.tag||"").toLowerCase(),w0=t==="img"||t==="video"||t==="picture"||t==="svg"||t==="canvas"||!!F["object-fit"]||!!F["object-position"]||!!F["aspect-ratio"],m0=(t==="img"||t==="video")&&!!J.attrs?.src&&!!W;return{showMedia:w0,canReplace:m0}},y9=(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…"})}),f0("object-fit",a0("object-fit",eL0)),f0("object-position",T8("object-position")),f0("aspect-ratio",D("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:d90.includes(F["aspect-ratio"])?F["aspect-ratio"]:"",onChange:(O0)=>{let w0=O0.target.value;if(a("aspect-ratio",w0),w0&&w0!=="auto"&&F.height)q0("height")},children:[z("option",{value:"",disabled:!0,children:V7(U["aspect-ratio"])||"—"}),d90.map((O0)=>z("option",{value:O0,children:O0},O0))]}))]});return D("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:V8,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(tw,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:z(z7,{as:dW,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:z(z7,{as:tW,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||V7(U.display)||"").trim();return t==="flex"||t==="inline-flex"?D(Q0,{children:[f0("flex-direction",T0("flex-direction",U0),void 0,"Direction"),f0("align-items",z(eg,{value:_0(),onChange:$0,ariaLabel:"auto-layout alignment"}),Q8("align-items"),"Alignment"),f0("gap",n0("gap","space"),void 0,"Gap"),D("div",{className:"st-cp-modes",children:[E8("width"),E8("height")]}),D("div",{className:"st-cp-box","aria-label":"padding",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[y8(Q8("padding-top")),"padding"]}),X8("padding-top","padding"),X8("padding-right","padding"),X8("padding-bottom","padding"),X8("padding-left","padding")]}),z("div",{className:"st-cp-clustermore-row",children:J8("Auto layout")}),h["Auto layout"]?f0("flex-wrap",z(nQ,{checked:/^wrap/.test(F["flex-wrap"]||V7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(w0)=>a("flex-wrap",w0?"wrap":"nowrap")}),Q8("flex-wrap"),"Wrap"):null]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>a("display","flex"),children:"+ Auto layout (flex)"})})()),B0("Size",["width","height","min-width","max-width","min-height","max-height"],D(Q0,{children:[f0("width",j8("width"),void 0,"Width"),f0("height",j8("height"),void 0,"Height"),z("div",{className:"st-cp-clustermore-row",children:J8("Size")}),h.Size?D(Q0,{children:[f0("min-width",j8("min-width"),void 0,"Min width"),f0("max-width",j8("max-width"),void 0,"Max width"),f0("min-height",j8("min-height"),void 0,"Min height"),f0("max-height",j8("max-height"),void 0,"Max height")]}):null]})),B0("Position",["position","top","right","bottom","left","z-index"],D(Q0,{children:[f0("position",a0("position",m90),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(Q8("top")),"inset"]}),$8("top"),$8("right"),$8("bottom"),$8("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||V7(U.position)||"static"})]}),(F.position||V7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,z("div",{className:"st-cp-clustermore-row",children:J8("Position")}),h.Position?f0("z-index",j8("z-index"),void 0,"Layer order"):null]}),!1),B0("Fill",["background-color"],f0("background-color",a8("background-color"),void 0,"Fill")),B0("Stroke",["border-width","border-style","border-color"],f0("border",g0(),Q8("border-width"),"Stroke")),B0("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],f0("border-radius",x0(),Q8("border-radius"),"Corner radius")),B0("Effects",["box-shadow","filter","mix-blend-mode"],D(Q0,{children:[f0("box-shadow",m7("box-shadow","shadow")||T8("box-shadow"),void 0,"Shadow"),f0("filter",A0(),Q8("filter"),"Blur"),f0("mix-blend-mode",a0("mix-blend-mode",l90),void 0,"Blend")]})),B0("Opacity",["opacity"],f0("opacity",W8(),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:[f0("font-family",a0("font-family",f90),void 0,"Font"),f0("color",a8("color"),void 0,"Color"),f0("font-size",n0("font-size","type"),void 0,"Size"),f0("font-weight",a0("font-weight",v90),void 0,"Weight"),f0("line-height",j8("line-height","lh"),void 0,"Line height"),f0("text-align",T0("text-align",Y9),void 0,"Align"),z("div",{className:"st-cp-clustermore-row",children:J8("Text")}),h.Text?D(Q0,{children:[f0("letter-spacing",j8("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),f0("font-style",a0("font-style",tL0),void 0,"Style"),f0("text-transform",a0("text-transform",u90),void 0,"Case"),f0("white-space",a0("white-space",p90),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(Q8("margin-top")),"margin"]}),X8("margin-top","margin"),X8("margin-right","margin"),X8("margin-bottom","margin"),X8("margin-left","margin")]})),(()=>{let{showMedia:t,canReplace:O0}=c9();return t?B0("Media",["object-fit","object-position","aspect-ratio"],y9(O0)):null})()]}):D(Q0,{children:[L8("Layout",(()=>{let t=(F.display||V7(U.display)||"").trim(),O0=t==="flex"||t==="inline-flex",w0=t==="grid"||t==="inline-grid";return D(Q0,{children:[f0("display",a0("display",aL0)),O0?D(Q0,{children:[f0("flex-direction",T0("flex-direction",U0)),f0("flex-wrap",z(nQ,{checked:/^wrap/.test(F["flex-wrap"]||V7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(m0)=>a("flex-wrap",m0?"wrap":"nowrap")}),Q8("flex-wrap"))]}):null,O0||w0?D(Q0,{children:[f0("align-items",T0("align-items",I8)),f0("justify-content",T0("justify-content",i0)),f0("gap",n0("gap","space"))]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>a("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let t=(F.display||V7(U.display)||"").trim();if(!(t==="grid"||t==="inline-grid"))return null;let w0=F["grid-template-columns"]||"",m0=F["grid-template-rows"]||"",t0=jO(w0),l8=jO(m0),s8=t0.length>0||!w0.trim(),v8=l8.length>0||!m0.trim();return L8("Grid",D(Q0,{children:[s8?z(i90,{label:"Columns",tracks:t0,editable:K,onChange:(Z9)=>a("grid-template-columns",vO(Z9))}):D("div",{className:"st-cp-note",children:["Columns use ",z("code",{children:w0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),v8?z(i90,{label:"Rows",tracks:l8,editable:K,onChange:(Z9)=>a("grid-template-rows",vO(Z9))}):D("div",{className:"st-cp-note",children:["Rows use ",z("code",{children:m0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),L8("Position",D(Q0,{children:[f0("position",a0("position",m90)),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(Q8("top")),"inset"]}),$8("top"),$8("right"),$8("bottom"),$8("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||V7(U.position)||"static"})]}),(F.position||V7(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,f0("z-index",j8("z-index"))]})),(J.parentDisplay==="grid"||J.parentDisplay==="inline-grid")&&L8("Grid item",D(Q0,{children:[D("div",{className:"st-cp-note",children:["Manual cell placement — ",z("code",{children:"start / end"})," or ",z("code",{children:"start / span N"}),"."]}),f0("grid-column",T8("grid-column")),f0("grid-row",T8("grid-row"))]})),L8("Typography",D(Q0,{children:[f0("font-family",a0("font-family",f90)),f0("color",a8("color")),f0("font-size",n0("font-size","type")),f0("font-weight",a0("font-weight",v90)),f0("line-height",j8("line-height","lh")),f0("letter-spacing",j8("letter-spacing",null,{min:-1/0})),f0("text-align",T0("text-align",Y9)),f0("font-style",_8(),Q8("font-style")),f0("text-transform",a0("text-transform",u90)),f0("white-space",a0("white-space",p90))]})),L8("Spacing",z(Q0,{children:D("div",{className:"st-cp-box","aria-label":"margin and padding",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[y8(Q8("margin-top")),"margin"]}),X8("margin-top","margin"),X8("margin-right","margin"),X8("margin-bottom","margin"),X8("margin-left","margin"),D("div",{className:"st-cp-boxpad",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[y8(Q8("padding-top")),"padding"]}),X8("padding-top","padding"),X8("padding-right","padding"),X8("padding-bottom","padding"),X8("padding-left","padding"),D("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(F.width)||J.bounds?.w||0)," × ",Math.round(Number.parseFloat(F.height)||J.bounds?.h||0)]})]})]})})),L8("Size",D(Q0,{children:[D("div",{className:"st-cp-modes",children:[E8("width"),E8("height")]}),f0("width",j8("width")),f0("height",j8("height")),f0("min-width",j8("min-width")),f0("max-width",j8("max-width")),f0("min-height",j8("min-height")),f0("max-height",j8("max-height")),f0("overflow",T0("overflow",d0)),Y8?D(Q0,{children:[z("div",{className:"st-cp-subhd",children:"In flex parent"}),f0("align-self",a0("align-self",sL0)),f0("flex-grow",j8("flex-grow",null,{unitless:!0})),f0("flex-shrink",j8("flex-shrink",null,{unitless:!0})),f0("flex-basis",j8("flex-basis"))]}):null]})),(()=>{let{showMedia:t,canReplace:O0}=c9();return t?L8("Media",y9(O0)):null})(),L8("Appearance",D(Q0,{children:[f0("background-color",a8("background-color")),f0("border-radius",x0(),Q8("border-radius")),f0("border",g0(),Q8("border-width")),f0("box-shadow",m7("box-shadow","shadow")||T8("box-shadow")),f0("filter",A0(),Q8("filter")),f0("mix-blend-mode",a0("mix-blend-mode",l90)),f0("opacity",W8()),f0("rotation",P8(),Q8("transform")),f0("transform",T8("transform")),f0("transform-origin",T8("transform-origin"))]})),(()=>{let t=Object.entries(C).find(([,O0])=>typeof O0==="string"&&O0.startsWith("err:"));return t?D("div",{className:"st-cp-save is-err",role:"status",children:[z(T9,{name:"x",size:12}),t[0],": ",t[1].slice(4)]}):null})(),L8("Advanced",D("div",{className:"st-cp-advbody",children:[W9.length?D(Q0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),W9.map(([t,O0])=>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:O0,"aria-label":`${t} value`,onKeyDown:(w0)=>{if(w0.key==="Enter")w0.currentTarget.blur()},onBlur:(w0)=>z0(t,w0.currentTarget.value)},`cs:${t}:${O0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>Z0(t),children:z(T9,{name:"x",size:11})})]},`cs:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add CSS property"}),z(YD0,{commit:z0}),z("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),X7.length?D(Q0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),X7.map(([t,O0])=>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:O0,"aria-label":`${t} value`,onKeyDown:(w0)=>{if(w0.key==="Enter")w0.currentTarget.blur()},onBlur:(w0)=>i(t,w0.currentTarget.value)},`at:${t}:${O0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>P0(t),children:z(T9,{name:"x",size:11})})]},`at:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),z(WD0,{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 YD0({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 WD0({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 GD0={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function ZD0(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 HD0=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function W70({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 r=f.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!r||r===(J.dcElement??""))return;E?.(J,r)},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?(r)=>B(r,J,w):void 0,onKeyDown:(r)=>{if(r.key==="Enter"||r.key===" ")if(r.preventDefault(),T)O&&Z(w);else H(J);else if(r.key==="F2"&&E&&!T)r.preventDefault(),m(J.dcElement||J.label||""),j(!0)},children:[O?z("button",{type:"button",className:"st-layer-caret","aria-label":I?"Expand":"Collapse",onClick:(r)=>{r.stopPropagation(),Z(w)},children:I?"▸":"▾"}):z("span",{className:"st-layer-caret","aria-hidden":"true"}),R?z("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:R.root?"◆":"◇"}):z(T9,{name:GD0[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:(r)=>r.target.select(),onChange:(r)=>m(r.target.value),onClick:(r)=>r.stopPropagation(),onPointerDown:(r)=>r.stopPropagation(),onBlur:h,onKeyDown:(r)=>{if(r.stopPropagation(),r.key==="Enter")h();else if(r.key==="Escape")j(!1)}}):z("span",{className:"st-layer-label",onDoubleClick:E&&!T?(r)=>{r.stopPropagation(),m(J.dcElement||J.label||""),j(!0)}:void 0,children:J.label}),z("span",{className:"st-layer-type",children:R?R.component:J.type}),A&&!T?z("button",{type:"button",className:"st-layer-lock","aria-label":$?`Unlock ${J.label}`:`Lock ${J.label}`,"aria-pressed":$,title:$?"Unlock":"Lock",onClick:(r)=>{r.stopPropagation(),A(w)},children:z(T9,{name:$?"lock":"unlock",size:12})}):null,U&&!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:(r)=>{r.stopPropagation(),U(J)},children:z(T9,{name:o?"eye-off":"eye",size:13})}):null]}),O&&!I?J.children.map((r,e)=>z(W70,{node:r,depth:X+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:V,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:M,onToggleLock:A,onRename:E},`${r.id}:${r.index}`)):null]})}function zD0({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 G70(J){if(J.artboardId)return J.artboardId;let X=/^\[data-dc-screen="([^"]+)"\]$/.exec(J.selector||"");return X?X[1]:null}var KD0=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],UD0=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function VD0({el:J,cfg:X,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let K=G70(J),U=(X?.designRel||X?.designRoot||".design").replace(/^\/+|\/+$/g,""),V=J70(J.file,X),B=X70(X,U,V),N=(v)=>B.map((r)=>({ds:r.name,names:r[v]||[],vals:r.vals})).filter((r)=>r.names.length),F=(v)=>N(v).flatMap((r)=>(r.names||[]).map((e)=>({name:e,value:r.vals?.[e]||""}))),M=(v)=>{let r=/^var\(\s*(--[\w-]+)\s*\)$/.exec(v||"");if(!r)return v||"";for(let e of B){let s=e.vals?.[r[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,r)=>{if(!K)return;let e=Number.isFinite(v)&&v>0?Math.round(v):void 0,s=Number.isFinite(r)&&r>0?Math.round(r):void 0;if(e==null&&s==null)return;Q?.(K,e,s)},O=Object.entries(R5).find(([,v])=>v.width===A&&v.height===E)?.[0],I=Object.entries(R5).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 r=null;if(v==="print"&&!m){let e={paper:"a4"};try{let s=GB(e);if(s)r={defaults:e,widthPx:s.widthPx,heightPx:s.heightPx}}catch{}}if(G?.(K,v==="digital"?null:v,r),v==="web"&&T)Y?.(K,!1,void 0)},o=(v)=>{if(!K)return;let r={paper:"a4",...m,...v},e;try{e=GB(r)}catch{return}Q?.(K,e.widthPx,e.heightPx),Z?.(K,r)},x=(v,r)=>{if(!K)return;let e=Number.isFinite(r)?r:E,s=v&&Number.isFinite(e)?Math.round(e):void 0;Y?.(K,v,s)},h=(v)=>{let r=ib(T,v);if(r.kind==="resize")w(null,r.height);else if(r.kind==="promote-to-fixed")x(!0,r.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(HJ,{value:A??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(v)=>w(v,null)}),z(HJ,{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…"}),WB.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 r=R5[v.currentTarget.value];if(r)w(r.width,null)},children:[z("option",{value:"",disabled:!0,children:I?`${R5[I].label} — ≤ ${R5[I].width}px`:"Breakpoint…"}),Object.entries(R5).map(([v,r])=>D("option",{value:v,children:[r.label," — ≤ ",r.width,"px breakpoint"]},v))]}):D("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:O??"",onChange:(v)=>{let r=R5[v.currentTarget.value];if(r)w(r.width,r.height)},children:[z("option",{value:"",disabled:!0,children:O?R5[O].label:"Preset size…"}),Object.entries(R5).map(([v,r])=>D("option",{value:v,children:[r.label," — ",r.width,"×",r.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(XG,{value:f,ariaLabel:"artboard kind",options:UD0.map(([v,r])=>({value:v,label:r})),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 r=R5[v.currentTarget.value];if(r)H(K,r.width);v.currentTarget.value=""},children:[z("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(R5).map(([v,r])=>D("option",{value:v,children:[r.label," — ",r.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(HJ,{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),r=/var\(\s*--/.test(R),e=r?R.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):R;return z(q3,{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:r,ariaLabel:"artboard background",onValue:(s)=>u({background:(s||"").trim()||null})})})(),z(XG,{value:C,ariaLabel:"artboard body layout",options:KD0.map(([v,r])=>({value:v,label:r})),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 wT=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,qD0=new RegExp(wT.source,"gi");function BD0(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(qD0)||[])],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=wT.exec(`${J.attrs?.src||""} ${X}`);return Y?Y[0]:null}function ND0({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:r,onPhotoUndoRedo:e,layersOnly:s=!1,hideLayersTab:H0=!1,cpMode:a,onSetCpMode:z0}){let[i,q0]=p.useState("inspect"),Z0=s?"layers":f??i,P0=(x0)=>{q0(x0),m?.(x0)},[s0,e0]=p.useState(()=>new Set),[Y8,E8]=p.useState(()=>new Map);p.useEffect(()=>{let x0=Array.isArray(X)?X[0]:X,g0=x0?.id;if(!g0||!Y?.nodes)return;let P8=x0.index,A0=null,W8=[];if(function _8(U0,i0){for(let I8 of U0||[]){let Y9=`${I8.id}:${I8.index}`;if(!I8.synthetic&&I8.id===g0&&(P8==null||I8.index===P8))return A0=Y9,W8.push(...i0),!0;if(I8.children&&I8.children.length&&_8(I8.children,[...i0,Y9]))return!0}return!1}(Y.nodes,[]),!A0)return;if(W8.length)e0((_8)=>{let U0=!1,i0=new Set(_8);for(let I8 of W8)if(i0.delete(I8))U0=!0;return U0?i0:_8});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${A0}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[X,Y]);let C8=(x0)=>{let g0=`${x0.id}:${x0.index}`;return Y8.has(g0)?Y8.get(g0):!!x0.hidden},[t8,o0]=p.useState(null),[C0,_0]=p.useState(""),$0=(x0,g0)=>{if(!K||!x0?.id)return;Y70(fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:K,id:x0.id,attr:"data-dc-element",value:g0})}).then((P8)=>P8.json().catch(()=>({}))).then((P8)=>{if(!P8.ok)return;A?.({op:"attr",canvas:K,id:x0.id,key:"data-dc-element",before:x0.dcElement??null,after:g0})}).catch(()=>{}))},V8=B?(x0,g0,P8)=>{if(N?.current)return;if(x0?.synthetic||g0?.synthetic)return;let A0=P8==="before"?`before ${g0.label}`:P8==="after"?`after ${g0.label}`:`into ${g0.label}`;_0(`Moved ${x0.label} ${A0}`),B(x0.id,g0.id,P8,{idIndex:x0.index,refIndex:g0.index})}:void 0,Q8=()=>{let x0=[];return function g0(P8,A0,W8){(P8||[]).forEach((_8,U0)=>{if(x0.push({node:_8,depth:A0,parentNode:W8,siblings:P8,pos:U0}),_8.children&&_8.children.length&&!s0.has(`${_8.id}:${_8.index}`))g0(_8.children,A0+1,_8)})}(Y?.nodes,0,null),x0},p8=(x0)=>{if(x0.key!=="ArrowUp"&&x0.key!=="ArrowDown")return;if(!L8)return;let g0=Q8(),P8=g0.findIndex((U0)=>U0.node.id===L8.id&&U0.node.index===L8.index);if(P8<0)return;let A0=x0.key==="ArrowDown"?1:-1,W8=g0[P8];if(!x0.altKey){let U0=g0[P8+A0];if(U0)x0.preventDefault(),U?.(U0.node);return}if(!V8||!Array.isArray(W8.siblings))return;x0.preventDefault();let _8=(U0)=>U0&&U0.children&&U0.children.length&&!s0.has(`${U0.id}:${U0.index}`);if(!x0.shiftKey){if(A0<0&&W8.pos>0)V8(W8.node,W8.siblings[W8.pos-1],"before");else if(A0>0&&W8.pos<W8.siblings.length-1)V8(W8.node,W8.siblings[W8.pos+1],"after");return}if(A0>0){let U0=W8.siblings[W8.pos+1];if(U0)V8(W8.node,U0,_8(U0)?"inside-start":"after");else if(W8.parentNode)V8(W8.node,W8.parentNode,"after")}else{let U0=W8.siblings[W8.pos-1];if(U0)V8(W8.node,U0,_8(U0)?"inside-end":"before");else if(W8.parentNode)V8(W8.node,W8.parentNode,"before")}},y8=p.useRef(null),D9=p.useRef(null),f0=(x0,g0,P8)=>{if(!V8||x0.button!==0||x0.metaKey||x0.ctrlKey||x0.shiftKey||x0.altKey)return;if(N?.current)return;let{clientX:A0,clientY:W8}=x0,_8=new Set([P8]);(function a8(I0){(I0.children||[]).forEach((X8)=>{_8.add(`${X8.id}:${X8.index}`),a8(X8)})})(g0);let U0=14,i0=6,I8=[];(function a8(I0,X8){(I0||[]).forEach(($8)=>{let W9=`${$8.id}:${$8.index}`;if(I8.push({node:$8,key:W9,id:$8.id,depth:X8,tag:$8.tag}),$8.children&&$8.children.length&&!s0.has(W9))a8($8.children,X8+1)})})(Y?.nodes,0);let Y9=new Map(I8.map((a8)=>[a8.key,a8])),d0=!1,m7=(a8)=>{if(!d0){if(Math.hypot(a8.clientX-A0,a8.clientY-W8)<4)return;d0=!0}let I0=a8.clientX-A0,X8=a8.clientY-W8,$8=null,W9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((c9)=>({rect:c9.getBoundingClientRect(),it:Y9.get(c9.getAttribute("data-layer-key"))})).filter((c9)=>c9.it&&c9.it.key!==P8);if(W9.length){let c9=W9[0].rect.left,y9=W9[0].rect.right,t=W9.length;for(let b9=0;b9<W9.length;b9++)if(a8.clientY<W9[b9].rect.top+W9[b9].rect.height/2){t=b9;break}let O0=W9[t-1]?.it||null,w0=W9[t]?.it||null,m0=Math.round((a8.clientX-c9-i0)/U0),t0=O0?O0.depth+(HD0.has(O0.tag)?0:1):0,l8=w0?w0.depth:0,s8=Math.max(l8,Math.min(m0,t0)),v8=null,Z9="before",h9=0;if(!O0){if(w0)v8=w0,Z9="before",h9=w0.depth}else if(s8>O0.depth)v8=O0,Z9="inside-start",h9=O0.depth+1;else if(s8===O0.depth)v8=O0,Z9="after",h9=O0.depth;else{for(let b9=t-1;b9>=0;b9--)if(W9[b9].it.depth===s8){v8=W9[b9].it;break}if(!v8)v8=O0;Z9="after",h9=s8}if(v8&&v8.key!==P8&&!_8.has(v8.key)){let b9=O0?W9[t-1].rect.bottom:W9[0].rect.top,K7=c9+i0+h9*U0;$8={refId:v8.id,position:Z9,node:v8.node,y:b9,left:K7,w:Math.max(24,y9-K7)}}}let X7={key:P8,node:g0,dx:I0,dy:X8,target:$8};y8.current=X7,o0(X7)},_9=()=>{window.removeEventListener("pointermove",m7),window.removeEventListener("pointerup",T8),window.removeEventListener("keydown",j8,!0)},o7=()=>{let a8=(I0)=>{I0.preventDefault(),I0.stopImmediatePropagation(),document.removeEventListener("click",a8,!0)};document.addEventListener("click",a8,!0),setTimeout(()=>document.removeEventListener("click",a8,!0),300)},T8=()=>{_9();let a8=y8.current;if(y8.current=null,o0(null),d0&&a8?.target)o7(),V8(a8.node,a8.target.node,a8.target.position)},j8=(a8)=>{if(a8.key!=="Escape")return;if(a8.preventDefault(),a8.stopImmediatePropagation(),_9(),y8.current=null,o0(null),d0)o7()};window.addEventListener("pointermove",m7),window.addEventListener("pointerup",T8),window.addEventListener("keydown",j8,!0)},k8=(x0)=>e0((g0)=>{let P8=new Set(g0);if(P8.has(x0))P8.delete(x0);else P8.add(x0);return P8}),A9=(x0)=>{let g0=`${x0.id}:${x0.index}`,P8=C8(x0),A0=!P8;if(E8((W8)=>new Map(W8).set(g0,A0)),M?.({id:x0.id,artboardId:Y?.artboardId??null,index:x0.index,prop:"display",value:A0?"none":null}),!K||!x0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(A0?{canvas:K,id:x0.id,property:"display",value:"none"}:{canvas:K,id:x0.id,property:"display",reset:!0})}).catch(()=>{}),A?.({op:"css",canvas:K,id:x0.id,key:"display",before:P8?"none":null,after:A0?"none":null})},L8=Array.isArray(X)?X[0]:X,B0=x?{asset:x.asset,kind:"annotation-image"}:(()=>{let x0=BD0(L8);return x0?{asset:x0,kind:"artboard-img"}:null})(),J8=B0?.kind==="annotation-image",a0=(x0)=>{if(!(x0.metaKey||x0.ctrlKey)||x0.altKey)return;let g0=x0.key.toLowerCase();if(g0==="z")x0.preventDefault(),e?.(x0.shiftKey?"redo":"undo");else if(g0==="y")x0.preventDefault(),e?.("redo")},e8=J8?"photo":Z0==="photo"&&!B0?"css":Z0,T0=(x0,g0,P8)=>D("button",{type:"button",className:"st-rp-tab"+(e8===x0?" is-active":""),onClick:()=>P0(x0),children:[z(T9,{name:P8,size:14}),g0]}),n0=L8?.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:[J8?T0("photo","Photo","image"):D(Q0,{children:[T0("inspect","Inspect","sliders"),!H0&&T0("layers","Layers","layers"),T0("css","CSS","code"),B0?T0("photo","Photo","image"):null]}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:Q,children:z(T9,{name:"x",size:14})})]}),L8?.id&&!(Array.isArray(X)&&X.length>1)&&j?D("div",{className:`st-scope st-scope--${j.scope}`,title:j.scope==="shared"?`Editing this element's style changes ${j.affects} place${j.affects===1?"":"s"}${j.componentName?` (component ${j.componentName})`:""}. Move/resize a whole instance to keep it local.`:"This edit affects only this element.",children:[z("span",{className:"st-scope-dot","aria-hidden":"true"}),j.scope==="shared"?`Shared${j.componentName?` · ${j.componentName}`:""} · edits ${j.affects} place${j.affects===1?"":"s"}`:"Local · this element only",j.scope==="shared"&&H?z("button",{type:"button",className:"st-scope-detach",title:"Clone this component for this instance only — edits stop affecting the other places",onClick:()=>H(L8.id,L8.index),children:"Detach"}):null]}):null,z("div",{className:"st-rp-body",children:e8==="photo"&&B0?z("div",{onKeyDown:a0,children:z(km,{asset:B0.asset,ColorPicker:Q70,StIcon:T9,onEdit:(x0)=>u?.(B0.asset,x0),onRemoveBackground:v,onRecordEdit:(x0,g0)=>r?.(B0.asset,x0,g0)},`${B0.asset}:${h??0}`)}):!L8&&!(e8==="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."]})}):L8&&e8==="inspect"?D(Q0,{children:[z("div",{className:"st-rp-hd",children:L8.selector||L8.tag||"element"}),D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Pos"}),D("div",{className:"st-insp-fields",children:[D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"X"}),z("input",{value:n0?Math.round(n0.x):"—",readOnly:!0,"aria-label":"x position"})]}),D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"Y"}),z("input",{value:n0?Math.round(n0.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:n0?Math.round(n0.w):"—",readOnly:!0,"aria-label":"width"})]}),D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"H"}),z("input",{value:n0?Math.round(n0.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Tag"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:L8.tag||"—"})})]}),L8.classes?D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Class"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:L8.classes})})]}):null,z(zD0,{el:L8})]}):e8==="layers"?D(Q0,{children:[D("div",{className:"st-rp-hd",children:["Layers",Y?.nodes?.length?"":" · ancestry"]}),Y?.nodes?.length?D(Q0,{children:[V8?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:D9,onKeyDown:p8,children:Y.nodes.map((x0,g0)=>z(W70,{node:x0,depth:0,selectedId:L8?.id,selectedIndex:L8?.index,collapsed:s0,hiddenOverride:Y8,onToggle:k8,onSelect:(P8)=>{U?.(P8),D9.current?.focus()},onHover:(P8)=>V?.(P8),onToggleVisibility:A9,onReorder:V8,onRowPointerDown:f0,dragState:t8,componentMap:W,lockedKeys:G,onToggleLock:Z,onRename:$0},`${x0.id}:${x0.index}`))}),t8?.target?z("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:t8.target.left,top:t8.target.y-1,width:t8.target.w}}):null,z("div",{className:"sr-only",role:"status","aria-live":"polite",children:C0})]}):L8&&Array.isArray(L8.dom_path)&&L8.dom_path.length?L8.dom_path.map((x0,g0)=>D("div",{className:"st-layer"+(g0===L8.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+g0*12},children:[z(T9,{name:"square",size:13}),x0]},g0)):z("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!L8.id&&G70(L8)?z(VD0,{el:L8,cfg:F,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:I,onSetArtboardKind:T,onSetArtboardPrint:R,onDuplicateArtboard:$}):z(QD0,{el:L8,cfg:F,onOptimistic:M,onRecordEdit:A,onReplaceMedia:E,onUndoRedo:C,mode:a,onSetMode:z0})})]})}function FD0(){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=S8.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=S8.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 E0(l){return(l||[]).some((L0)=>L0.id===X0.movedId||E0(L0.children))}(b))return;f.current=null;let F0=V?S8.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),[r,e]=p.useState(null),[s,H0]=p.useState(null),a=p.useRef({canvas:null,at:0});p.useEffect(()=>{if(!V||!r)return;let b=Date.now(),S=a.current;if(S.canvas===V&&b-S.at<1500)return;a.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,r]);let[z0,i]=p.useState(!1),[q0,Z0]=p.useState(null),[P0,s0]=p.useState(null),e0=p.useRef(null);p.useEffect(()=>{let b=P0?.files?.progress;if(!b)return;let S=e0.current;if(e0.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.`)}},[P0?.files?.progress]),p.useEffect(()=>{if(typeof document>"u")return;let b=P0?.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},[P0?.files?.progress]);let[Y8,E8]=p.useState(null),[C8,t8]=p.useState(null),[o0,C0]=p.useState(null),[_0,$0]=p.useState(null),[V8,Q8]=p.useState(!1),[p8,y8]=p.useState(!1),[D9,f0]=p.useState(null),[k8,A9]=p.useState(""),[L8,B0]=p.useState(null),[J8,a0]=p.useState(null),e8=p.useRef(null),[T0,n0]=p.useState(null),[x0,g0]=p.useState(0),[P8,A0]=p.useState(null),W8=R90("maude-sb-w",{min:200,max:420,def:252}),_8=R90("maude-rp-w",{min:260,max:480,def:304}),[U0,i0]=p.useState(null),I8=p.useRef(null);p.useEffect(()=>{if(!U0)return;let b=(d)=>{let X0=I8.current?.getBoundingClientRect();if(!X0)return;if(U0==="sb")W8.setW(d.clientX-X0.left);else _8.setW(X0.right-d.clientX)},S=()=>i0(null);return window.addEventListener("pointermove",b),window.addEventListener("pointerup",S),()=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",S)}},[U0,W8.setW,_8.setW]);let Y9=p.useCallback((b)=>{if(P90(b))return;clearTimeout(e8.current),e8.current=setTimeout(()=>{a0((S)=>S===b?null:S)},2500)},[]),[d0,m7]=p.useState({designRel:".design",cloud:void 0}),_9=!!J8&&P8===J8;p.useEffect(()=>{if(!J8)return;let b=J8,S=setTimeout(async()=>{let d="compile";try{if(!(await fetch(`${d0?.canvasOrigin||""}/_health`,{cache:"no-store"})).ok)d="server"}catch{d="server"}n0({path:b,kind:d}),a0((X0)=>X0===b?null:X0)},_9?60000:15000);return()=>clearTimeout(S)},[J8,_9,d0?.canvasOrigin]);let o7=!!d0.cloud,T8=!d0.cloud&&!!Y8?.credentialed,j8=o7||T8,a8=j8?0:o0?.files?.length||0,I0=p.useRef(j8);I0.current=j8;let X8=!!d0.readOnly,$8=p.useCallback(()=>{fetch("/_config").then((b)=>b.json()).then((b)=>{let S=(b.designRoot||".design").replace(/^\/+|\/+$/g,"");m7((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(()=>{$8()},[$8]),p.useEffect(()=>{let b=!1;return fetch("/_sync-status").then((S)=>S.json()).then((S)=>{if(b||!S||S.linked===!1)return;s0(S)}).catch(()=>{}),()=>{b=!0}},[]),p.useEffect(()=>{if(j8){C0(null);return}let b=!1;return fetch("/_api/git/status").then((S)=>S.json()).then((S)=>{if(!b&&S)C0(S)}).catch(()=>{}),()=>{b=!0}},[j8]);let[W9,X7]=p.useState({}),[c9,y9]=p.useState(null),[t,O0]=p.useState(!1),[w0,m0]=p.useState("open"),[t0,l8]=p.useState(eF0),[s8,v8]=p.useState(()=>{return I90(L90,"advanced")==="designer"?"designer":"advanced"});p.useEffect(()=>{try{localStorage.setItem(L90,JSON.stringify(s8))}catch{}},[s8]);let[Z9,h9]=p.useState(null),[b9,K7]=p.useState(()=>kH(D90,!0)),[oX,$5]=p.useState(()=>kH(F90,!1)),Q6=Qu(),w7=Q6.update,VQ=Q6.state.sections,[G6,qQ]=p.useState(!1),[S7,RJ]=p.useState(!1);p.useEffect(()=>{if(!H9())return;let b=wh(()=>RJ(!0));return()=>{b.then((S)=>S()).catch(()=>{})}},[]);let[v9,LY]=p.useState(!1),[n7,BQ]=p.useState(!1),[DG,b7]=p.useState(!1),[DY,qX]=p.useState(!1),[D7,CJ]=p.useState(!1),{report:t9}=ow(H9()),[q7,Z6]=p.useState(!1),[BX,nX]=p.useState(!1),[NQ,rX]=p.useState(null),[Q4,$J]=p.useState(null),[Y4,qJ]=p.useState(!1),[FQ,nJ]=p.useState(!1),[SJ,W4]=p.useState(!1),[MY,LQ]=p.useState(!1),[n,W0]=p.useState(()=>I90(_90,sK)),[D0,y0]=p.useState(()=>{try{let b=localStorage.getItem(w90);if(b==="separate"||b==="in-inspector")return b}catch{}return"separate"}),[k0,Z8]=p.useState(!1),[K8,V9]=p.useState([]),[B9,bJ]=p.useState(0),[G4,u7]=p.useState(!1),[yJ,DQ]=p.useState(!1),[Z4,OY]=p.useState(!1),[jJ,y7]=p.useState(1),[Q7,aX]=p.useState(216),[E7,J9]=p.useState(null),[j7,x6]=p.useState([]),[NX,MQ]=p.useState([]),[MG,TH]=p.useState([]),[BJ,RH]=p.useState(0),OG=p.useRef(0);p.useEffect(()=>{OG.current=B9},[B9]);let[P7,CH]=p.useState(null),H4=p.useRef(null);p.useEffect(()=>{H4.current=P7},[P7]);let k6=p.useMemo(()=>JE(K8,{artboardId:[P7,E7],total:BJ}),[K8,P7,E7,BJ]),OQ=p.useRef(null);p.useEffect(()=>{OQ.current=k6},[k6]);let AY=p.useMemo(()=>kK(K8,k6)?.fps||30,[K8,k6]),[_Y,wY]=p.useState(null),[$H,Q1]=p.useState(0),NJ=p.useCallback((b,S)=>{if(/concurrent edit|changed since it was read/i.test(S||""))g8("Timeline changed — reloaded, try again."),Q1((d)=>d+1);else g8(`${b}: ${S||"failed"}`)},[]),[FX,AG]=p.useState(!1),[Y1,SH]=p.useState(!1),[W1,_G]=p.useState(!1),wG=p.useRef(FX);p.useEffect(()=>{if(wG.current=FX,FX){_G(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[FX]);let bH=p.useCallback(()=>{if(!wG.current||document.hidden)_G(!0),BL("Claude finished","Your assistant turn is ready in Maude.")},[]),EY=p.useRef(0),AQ=p.useCallback(()=>{if(!wG.current||document.hidden){_G(!0);let b=Date.now();if(b-EY.current<rF0)return;EY.current=b,BL("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[S5,_Q]=p.useState("inspect"),[G1,wQ]=p.useState(null),sX=p.useRef({undo:[],redo:[]}),[LX,Z1]=p.useState(0),[rJ,EG]=p.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),yH=p.useRef(rJ);p.useEffect(()=>{yH.current=rJ;try{localStorage.setItem("maude-auto-open-inspector",rJ?"1":"0")}catch{}},[rJ]);let jH=p.useRef(!1);p.useEffect(()=>{jH.current=SJ||t||V8||p8||FX},[SJ,t,V8,p8,FX]);let PG=p.useRef({open:{},side:sK});PG.current={open:{tree:b9,layers:MY,inspector:SJ,comments:t,changes:V8,sync:p8,assistant:FX},side:n};let DX=p.useCallback((b,S)=>{if(b==="tree")K7(S);else if(b==="layers")LQ(S);else if(b==="inspector")W4(S);else if(b==="comments")O0(S);else if(b==="changes")Q8(S);else if(b==="sync")y8(S);else if(b==="assistant")AG(S)},[]),z4=p.useCallback((b)=>PG.current.side?.[b]||sK[b],[]),vJ=p.useCallback((b)=>{let S=z4(b);DX(b,!0);for(let d of AT)if(d.id!==b&&z4(d.id)===S)DX(d.id,!1)},[DX,z4]),b5=p.useCallback((b)=>{if(PG.current.open?.[b])DX(b,!1);else vJ(b)},[vJ,DX]),MX=vJ,h6=b5,IG=p.useCallback((b)=>{if(!yH.current)return;if(X8)return;if(!b||!b.id)return;if(jH.current)return;MX("inspector"),_Q("css")},[MX,X8]),PY=p.useCallback(()=>Z8((b)=>!b),[]),EQ=om(_T),K4=Sm({enabled:d0.cloud===null||d0.exportLane==="remote"}),[vH,y5]=p.useState(!1),[FJ,IY]=p.useState(!1);p.useEffect(()=>{if(!H9())return;let b=!0;return kh().then((S)=>{if(!b)return;if(y5(!!S),!S&&!kH(N90,!1))IY(!0)}).catch(()=>{}),()=>{b=!1}},[]);let fH=p.useCallback(()=>{IY(!1);try{localStorage.setItem(N90,"1")}catch{}},[]),[H1,PQ]=p.useState(null);p.useEffect(()=>{if(!H9())return;let b;return Sh((S)=>PQ(S&&typeof S==="object"?S:{})).then((S)=>{b=S}).catch(()=>{}),()=>{try{b?.()}catch{}}},[]);let[OX,kY]=p.useState(null),[TY,kG]=p.useState(()=>!kH(B90,!1)),AX=p.useCallback((b)=>{kY(Array.isArray(b)&&b.length?b:null)},[]),TG={setup:(b)=>{if(!b)return;if((b.canvas||b.requireSelection)&&K.length===0)vJ("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [data-testid^="canvas-row-"]')?.click()}catch{}},80);if(b.inspector||b.tab||b.requireSelection)MX("inspector");if(b.tab)_Q(b.tab);if(b.changes)MX("changes")}},U4=p.useCallback(()=>{kG(!1);try{localStorage.setItem(B90,"1")}catch{}},[]),[IQ,RY]=p.useState(()=>kH(A90,!0)),[xH,RG]=p.useState(!1),[g6,V0]=p.useState(()=>kH(M90,!1)),[tX,CY]=p.useState(()=>kH(O90,!1)),[a6,_X]=p.useState(!1),[r7,aJ]=p.useState(!1),[V4,kQ]=p.useState(0),[q4,CG]=p.useState(null),[B4,$Y]=p.useState(!1),N4=p.useRef(null),U8=p.useRef(null),S8=p.useRef(new Map);p.useEffect(()=>{if(!d0?.canvasToken)return;let b=!1,S=null,d=0,X0=(M0)=>{clearTimeout(S);let h0=eb(M0);d=Date.now()+h0,S=setTimeout(K0,h0)};async function K0(){let M0=null;try{let N8=await fetch("/_config",{cache:"no-store",credentials:"same-origin"});if(N8.ok)M0=(await N8.json())?.canvasToken}catch{}if(b)return;if(typeof M0!=="string"||!M0){clearTimeout(S),d=Date.now()+30000,S=setTimeout(K0,30000);return}tb(M0);let h0=F0();if(h0)for(let N8 of S8.current.values())try{N8.contentWindow?.postMessage({dgn:"canvas-cap",t:M0},h0)}catch{}return X0(M0),M0}function F0(){try{return new URL(d0.canvasOrigin,location.href).origin}catch{return null}}let E0=!1;async function l(M0){if(M0.data?.dgn!=="canvas-expired"||M0.origin!==F0()||E0)return;E0=!0;try{let h0=await K0();if(!h0)return;for(let N8 of S8.current.values())if(N8.contentWindow===M0.source)N8.src=Jy(N8.src,h0)}finally{E0=!1}}window.addEventListener("message",l),X0(d0.canvasToken);let L0=()=>{if(document.visibilityState==="visible"&&Date.now()>=d)K0()};return document.addEventListener("visibilitychange",L0),()=>{b=!0,clearTimeout(S),document.removeEventListener("visibilitychange",L0),window.removeEventListener("message",l)}},[d0?.canvasToken,d0?.canvasOrigin]);let x8=p.useCallback((b)=>{let S=V?S8.current.get(V):null;if(!S||!S.contentWindow)return;try{S.contentWindow.postMessage(b,"*")}catch{}},[V]),G8=p.useRef(0),eX=p.useCallback(({format:b,artboardIds:S=null,scale:d=1,onProgress:X0,timeoutMs:K0=120000})=>new Promise((F0,E0)=>{let l=V?S8.current.get(V):null;if(!l||!l.contentWindow){E0(Error("no active canvas to capture"));return}let L0=l.contentWindow;G8.current+=1;let M0=`cap-${Date.now().toString(36)}-${G8.current}`,h0=!1,N8=(I7,l9)=>{if(h0)return;h0=!0,window.removeEventListener("message",M8),clearTimeout(N6),I7(l9)},M8=(I7)=>{if(I7.source!==L0)return;let l9=I7.data;if(!l9||l9.id!==M0)return;if(l9.dgn==="export-capture-progress")X0?.(l9.current,l9.total);else if(l9.dgn==="export-capture-done")N8(F0,Array.isArray(l9.items)?l9.items:[]);else if(l9.dgn==="export-capture-error")N8(E0,Error(l9.message||"capture failed"))},N6=setTimeout(()=>N8(E0,Error("capture timed out — the canvas did not answer")),K0);window.addEventListener("message",M8);try{L0.postMessage({dgn:"export-capture",id:M0,format:b,artboardIds:S,scale:d},"*")}catch(I7){N8(E0,I7)}}),[V]),H8=p.useCallback((b,S)=>x8({dgn:"photo-preview",asset:b,edit:S}),[x8]),$G=p.useCallback((b,S,d)=>{sX.current.undo.push({asset:b,before:S,after:d}),sX.current.redo.length=0},[]),F4=p.useCallback((b)=>{let S=b?sX.current.redo:sX.current.undo;if(!S.length)return!1;let d=S.pop();(b?sX.current.undo:sX.current.redo).push(d);let X0=(b?d.after:d.before)||{};return H8(d.asset,X0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(d.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(X0)}).catch(()=>{}),Z1((K0)=>K0+1),!0},[H8]),SG=p.useCallback(async(b)=>{x8({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(() => (q90(),V90)),K0=await X0(d),F0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":K0.type||"image/png"},body:K0}),E0=await F0.json().catch(()=>({}));if(F0.ok&&E0.path)return{maskAsset:E0.path};return null}catch(S){return console.error("[photo] background removal failed",S),null}finally{x8({dgn:"photo-busy",asset:b,busy:!1})}},[x8]);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 H6=p.useRef({});H6.current={open:k0,comps:K8,frame:B9,total:BJ,playing:G4,compId:k6,muted:Z4,loop:yJ,sequences:j7,post:x8,canvas:V};let j5=p.useRef({undo:[],redo:[]}),z6=p.useCallback((b,S,d)=>{if(typeof S!=="number")return;if(j5.current.undo.push({canvas:b,seq:S,label:d}),j5.current.redo=[],j5.current.undo.length>50)j5.current.undo.shift()},[]),L4=p.useCallback((b)=>{let S=j5.current,d=b==="undo"?S.undo:S.redo,X0=b==="undo"?S.redo:S.undo,K0=H6.current.canvas,F0=-1;for(let l=d.length-1;l>=0;l--)if(d[l].canvas===K0){F0=l;break}if(F0<0){g8(b==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let E0=d[F0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:E0.canvas,seq:E0.seq,dir:b})}).then((l)=>l.json().catch(()=>({}))).then((l)=>{if(d.splice(F0,1),l?.ok)X0.push(E0),g8(`${b==="undo"?"Undid":"Redid"}: ${E0.label}`,!0);else g8(`${b==="undo"?"Undo":"Redo"} skipped: ${l?.error||"failed"}`)}).catch(()=>g8(`${b==="undo"?"Undo":"Redo"} failed: network error`))},[]),T6=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},[]),SY=p.useCallback((b)=>{let S=H6.current.canvas;if(!S||S===o8)return;let d=H4.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=T6(K0,b);if(!F0?.stableId)return null;return fetch("/_api/remove-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:S,artboardId:d,stableId:F0.stableId,contentHash:F0.contentHash})})}).then((K0)=>K0?K0.json():null).then((K0)=>{if(K0&&!K0.ok)console.warn("[remove-clip]",K0.error||"failed"),NJ("Remove refused",K0.error);else if(K0?.ok){if(g8("Clip removed.",!0),K0.seq!=null)z6(S,K0.seq,"remove clip");wY(null)}}).catch(()=>g8("Remove failed: network error"))},[T6,z6]),TQ=p.useCallback((b,S,d)=>{let X0=H6.current.canvas;if(!X0||X0===o8)return;let K0=H4.current||void 0,F0=`/_api/comp-clips?canvas=${encodeURIComponent(X0)}${K0?`&artboardId=${encodeURIComponent(K0)}`:""}`;fetch(F0).then((E0)=>E0.json().catch(()=>({}))).then((E0)=>{let l=E0?.ok&&Array.isArray(E0.clips)?E0.clips:[],L0=b?.transition?l.find((M0)=>M0.kind==="transition"&&M0.stableId===b.stableId)||null:T6(E0,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((E0)=>E0?E0.json():null).then((E0)=>{if(E0&&!E0.ok)console.warn("[clip-edit]",S,E0.error||"failed"),NJ(`${S} refused`,E0.error);else if(E0?.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(g8(`Applied: ${l[S]||S}.`,!0),E0.seq!=null)z6(X0,E0.seq,l[S]||S)}}).catch(()=>g8(`${S} failed: network error`))},[T6,z6,NJ]),[RQ,bY]=p.useState(null),J5=p.useCallback((b,S="")=>new Promise((d)=>{bY({title:b,value:S,resolve:d})}),[]),v5=p.useCallback((b)=>{bY((S)=>{return S?.resolve?.(b),null})},[]),yY=p.useCallback((b,S)=>{let d=H6.current.canvas;if(!d||d===o8||!S||!String(S).trim())return;v7({type:"comments-add",payload:{file:d,text:String(S).trim(),selector:"",dom_path:[],tag:"",classes:"",bounds:null,html_excerpt:"",timeline:b}}),g8("Comment added.",!0)},[]);H6.current.selected=_Y,H6.current.setSelected=wY,H6.current.removeClip=SY,H6.current.clipVerb=TQ,H6.current.addComment=yY,H6.current.askText=J5,p.useEffect(()=>{let b=(S)=>{let d=H6.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=kK(d.comps,d.compId)?.fps||30,E0=Math.max(1,d.total),l=(M0)=>{let h0=Math.max(0,Math.min(E0-1,Math.round(M0)));bJ(h0),u7(!1),d.post({dgn:"timeline-seek",frame:h0,id:d.compId})},L0=()=>{let M0=new Set([0,E0-1]);for(let h0 of d.sequences||[]){M0.add(h0.from);for(let N8 of h0.keyframes||[])M0.add(N8.from),M0.add(N8.to)}return[...M0].filter((h0)=>h0>=0&&h0<E0).sort((h0,N8)=>h0-N8)};if((S.metaKey||S.ctrlKey)&&(S.key==="z"||S.key==="Z")){S.preventDefault(),L4(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 M0=d.selected!=null?{stableId:d.selected}:null;if(!M0){let h0=d.sequences||[],N8=h0.find((M8)=>M8.series&&d.frame>=M8.from&&d.frame<M8.from+M8.duration)||h0.find((M8)=>d.frame>=M8.from&&d.frame<M8.from+M8.duration);if(N8?.stableId)M0={stableId:N8.stableId}}if(M0)d.clipVerb?.(M0,"split",{atFrame:d.frame});else g8("Nothing under the playhead to split.");return}if(S.key===" "||S.code==="Space")if(S.preventDefault(),d.playing)u7(!1),d.post({dgn:"timeline-pause",id:d.compId});else u7(!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(E0-1);else if(S.key==="."){S.preventDefault();let M0=L0().find((h0)=>h0>d.frame);if(M0!=null)l(M0)}else if(S.key===","){S.preventDefault();let M0=L0().reverse().find((h0)=>h0<d.frame);if(M0!=null)l(M0)}};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[]),p.useEffect(()=>{V9([]),bJ(0),u7(!1),wY(null),CH(null);let b=setTimeout(()=>x8({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(b)},[V,x8]);let[f5,jY]=p.useState(""),[vY,D4]=p.useState([]),[bG,fY]=p.useState([]);p.useEffect(()=>{if(!k0||K8.length===0||!V||V===o8){jY(""),D4([]);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")jY(S.source)}).catch(()=>{}),()=>{b=!1}},[k0,K8,V,$H]),p.useEffect(()=>{if(!k0||!V||V===o8||!f5){D4([]),fY([]);return}let b=!0,S=P7||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:[];D4(K0.filter((F0)=>F0.kind==="sequence")),fY(K0.filter((F0)=>F0.kind==="transition"))}).catch(()=>{}),()=>{b=!1}},[k0,V,f5,P7,$H]),p.useEffect(()=>{if(!f5){x6([]),MQ([]),TH([]),RH(0);return}let b=E7??A?.artboardId??null,d=(b&&K8.find((F0)=>F0.artboardId===b||F0.id===b)||K8[0])?.durationInFrames||0,X0=Am(f5,d,b);CH(X0.artboardId??b??null);let K0=X0.sequences.map((F0,E0)=>{let l=vY[E0];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}});x6(K0),MQ(X0.audio||[]),TH(X0.transitions||[]),RH(X0.total)},[f5,vY,A,K8,E7]);let xY=p.useCallback(()=>{RY((b)=>{let S=!b,d=V?S8.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 S8.current.values())try{S.contentWindow.postMessage({dgn:"view-chrome",...b},"*")}catch{}},[]),hY=p.useCallback(()=>{V0((b)=>{let S=!b;return LJ({minimap:S}),S})},[LJ]),gY=p.useCallback(()=>{CY((b)=>{let S=!b;return LJ({zoom:S}),S})},[LJ]),yG=p.useCallback(()=>{_X((b)=>{let S=!b;return LJ({present:S}),S})},[LJ]),M4=p.useCallback(()=>{_X(!1),LJ({present:!1})},[LJ]),jG=p.useCallback(()=>{if(!V||V===o8)return;aJ((b)=>{let S=!b;return x8({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,x8]);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)CG(d)}).catch(()=>{}),()=>{b=!0}},[]),p.useEffect(()=>{if(!V||V===o8){kQ(0),aJ(!1);return}let b=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(V)).then((S)=>S.json()).then((S)=>{if(b)return;let d=Array.isArray(S?.artboards)?S.artboards.length:0;kQ(d),aJ(S?.overlays?.print===!0),A4(new Set(Array.isArray(S?.locked)?S.locked:[]))}).catch(()=>{if(!b)kQ(0),aJ(!1),A4(new Set)}),()=>{b=!0}},[V]),p.useEffect(()=>{if(!V||V===o8||!E7)return;let b=setTimeout(()=>{x8({dgn:"request-layers",artboardId:E7})},250);return()=>clearTimeout(b)},[V,E7,x8]);let[O4,A4]=p.useState(()=>new Set),vG=p.useCallback((b)=>{if(!V||V===o8)return;A4((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(()=>{}),x8({dgn:"locked-set",locked:X0}),d})},[V,x8]);p.useEffect(()=>{if(!V||V===o8)return;x8({dgn:"locked-set",locked:[...O4]})},[O4,V,x8]),p.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",t0),localStorage.setItem(r90,t0)}catch{}for(let b of S8.current.values())try{b.contentWindow.postMessage({dgn:"theme",theme:t0},"*")}catch{}},[t0]),p.useEffect(()=>{try{localStorage.setItem(D90,b9?"1":"0")}catch{}},[b9]),p.useEffect(()=>{try{localStorage.setItem(F90,oX?"1":"0")}catch{}},[oX]),p.useEffect(()=>{try{localStorage.setItem(M90,g6?"1":"0")}catch{}},[g6]),p.useEffect(()=>{try{localStorage.setItem(O90,tX?"1":"0")}catch{}},[tX]),p.useEffect(()=>{try{localStorage.setItem(A90,IQ?"1":"0")}catch{}},[IQ]),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")l8(S.theme);if(typeof S.minimap==="boolean")V0(S.minimap);if(typeof S.zoom==="boolean")CY(S.zoom);if(typeof S.annotations==="boolean")RY(S.annotations);if(typeof S.autoOpenInspector==="boolean")EG(S.autoOpenInspector);if(S.panelSides&&typeof S.panelSides==="object")W0({...sK,...S.panelSides});if(S.layersMode==="separate"||S.layersMode==="in-inspector")y0(S.layersMode)}).catch(()=>{}).finally(()=>{if(!b)RG(!0)}),()=>{b=!0}},[]),p.useEffect(()=>{if(!xH)return;aF0({theme:t0,minimap:g6,zoom:tX,annotations:IQ,autoOpenInspector:rJ,panelSides:n,layersMode:D0})},[xH,t0,g6,tX,IQ,rJ,n,D0]),p.useEffect(()=>{try{localStorage.setItem(_90,JSON.stringify(n))}catch{}},[n]),p.useEffect(()=>{try{localStorage.setItem(w90,D0)}catch{}},[D0]);let mY=p.useRef(!1);p.useEffect(()=>{if(mY.current||!Q6.ready||!Q||!J.length)return;mY.current=!0;let b=Ju(J);w7((S)=>Xu(S,b))},[Q6.ready,Q,J,w7]);let fG=p.useCallback((b)=>w7((S)=>em(S,b)),[w7]),xG=p.useMemo(()=>({isOpen:(b)=>sm(Q6.state,b),setOpen:(b,S)=>w7((d)=>$E(d,b,S))}),[Q6.state,w7]),_4=p.useCallback(()=>{l8((b)=>b==="dark"?"light":"dark")},[]),w4=p.useRef(null),j9=p.useCallback(()=>w4.current?.reload()??Promise.resolve(),[]);p.useEffect(()=>{let b=Qy({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:WL0(F0.paths,F0.stripPrefix,F0.dirs)}));return{data:X0,built:K0}},apply:({data:S,built:d})=>{H(S.project||"Design"),X(d),Y(!0),m7((X0)=>({...X0,canvasDesignSystems:S.canvasDesignSystems??{},canvasKinds:S.canvasKinds??{}}))},onError:(S)=>console.error("failed to load tree",S)});return w4.current=b,j9(),()=>{w4.current=null,b.dispose()}},[j9]);let X5=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)}},[]),uY=p.useCallback(async()=>{try{let S=await(await fetch("/_comments-all")).json();X7(S||{})}catch(b){console.error("failed to load comments",b)}},[]);p.useEffect(()=>{uY()},[uY]);let pY=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");U8.current=K0,K0.addEventListener("open",()=>{if(i(!0),S)$8();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 E0=JSON.parse(F0.data);if(E0.type==="snapshot"&&E0.state)E((l)=>c90(E0.state.selected,l));else if(E0.type==="selected"){if(Date.now()-T.current<2000)return;let l=E0.selected,L0=Array.isArray(l)?l[0]:l,M0=w.current,h0=Array.isArray(M0)?M0[0]:M0;if(E((N8)=>c90(l,N8)),L0?.id&&L0.file&&(!h0||h0.id!==L0.id||h0.file!==L0.file))$(L0)}else if(E0.type==="comments"&&typeof E0.file==="string")X7((l)=>({...l,[E0.file]:E0.comments||[]}));else if(E0.type==="ai-activity"&&typeof E0.file==="string"){if($Y(!0),N4.current)clearTimeout(N4.current);N4.current=setTimeout(()=>$Y(!1),8000);for(let l of S8.current.values())try{l.contentWindow.postMessage({dgn:"ai-activity",file:E0.file,entry:E0.entry},"*")}catch{}}else if(E0.type==="export:job"&&E0.payload)K4.upsert(E0.payload);else if(E0.type==="sync:status"&&E0.payload)s0(E0.payload);else if(E0.type==="canvas-list-update")j9(),pY.current(E0.payload);else if(E0.type==="config-updated")$8();else if(E0.type==="acp-focus"){if(H9())MX("assistant")}else if(E0.type==="git-status"&&E0.payload){if(!I0.current)C0(E0.payload)}else if(E0.type==="git-lifecycle"&&E0.payload){Z0(E0.payload);for(let l of S8.current.values())try{l.contentWindow.postMessage({dgn:"git-lifecycle",payload:E0.payload},"*")}catch{}}}catch{}})}return d(),()=>{if(clearInterval(b),U8.current)U8.current.close()}},[j9,$8]);function v7(b){let S=U8.current;try{if(S&&S.readyState===1)S.send(JSON.stringify(b))}catch{}}let DJ=p.useCallback(async()=>{if(I0.current)return;try{let b=await fetch("/_api/git/status");if(b.ok)C0(await b.json())}catch{}},[]),fJ=p.useCallback(async()=>{if(I0.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)$0({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?"}}},[]),hG=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]),lY=p.useCallback(async(b)=>{let S=await MJ("/_api/git/discard",{files:b});if(S.ok)await DJ();return S},[MJ,DJ]),gG=p.useCallback(async()=>{let b=await MJ("/_api/git/push",{});if(b.ok)await DJ(),fJ();return b},[MJ,DJ,fJ]),dY=p.useCallback(async()=>{let b=await MJ("/_api/git/pull",{});if(b.ok)await DJ(),fJ();if(b.conflict&&Array.isArray(b.files)&&b.files.length)f0({file:b.files[0],conflict:!0});return b},[MJ,DJ,fJ]),mG=p.useCallback(async(b)=>{let S=await MJ("/_api/git/resolve",{choice:b});if(S.ok)await DJ(),fJ();return S},[MJ,DJ,fJ]),E4=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[]}},[]),[uG,pG]=p.useState(null),lG=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 pG({branch:X0.branch??null,project:X0.project??null,hubHost:X0.hubHost??null}),X0.entries||[]}catch{return null}},[]),[z1,K1]=p.useState(!1),[U1,V1]=p.useState(0),dG=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((E0)=>E0.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}},[]),cG=/^r\d+$/.test(D9?.beforeSha||""),q1=p.useCallback(async(b)=>{if(!cG)return E4(b);let S=await dG(b);return Array.isArray(S)?S:[]},[cG,E4,dG]),hH=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 V1((K0)=>K0+1),X0;return{ok:!1,error:X0?.error}},[]),B1=p.useMemo(()=>{let b={modified:"M",added:"A",deleted:"D",untracked:"U"},S=new Map;if(j8)return S;for(let d of o0?.files||[])S.set(d.path,b[d.status]);return S},[o0,j8]);p.useEffect(()=>{if(j8){$0(null);return}if(o0?.repo===!1)return;fJ();let b=setInterval(fJ,V8?60000:120000);return()=>clearInterval(b)},[j8,o0?.repo,V8,fJ]);let B6=p.useCallback((b,{reveal:S=!0}={})=>{if(S&&b&&b!==o8)w7((d)=>HF(d,J,b));if(W.current="push",y9(null),F(null),b===V)return;if(U((d)=>{for(let X0 of d)if(X0.path!==b)S8.current.delete(X0.path);return[{path:b}]}),B(b),n0(null),A0(null),b!==o8)a0(b)},[V,J,w7]),P4=p.useCallback((b,S="push")=>{let d=J.flatMap((X0)=>X0.paths||[]).find((X0)=>hW(X0,d0.designRel)===b);if(d&&C5.test(d))B6(d,{reveal:!1});else if(d&&EL(UQ(d)))M(d);else U([]),B(null),F(null),A5({title:"Not here yet",description:`${b} is not in this project (not synced yet?)`,kind:"info"});W.current=S},[J,d0.designRel,B6,M]),gH=p.useRef(!1);p.useEffect(()=>{if(!Q||d0.cloud===void 0||gH.current)return;gH.current=!0;let b=bV(location,d0.designRel);if(b)P4(b,"none")},[Q,d0.cloud,d0.designRel,P4]),p.useEffect(()=>{if(!Q||d0.cloud===void 0)return;let b=()=>{let S=bV(location,d0.designRel);if(S)P4(S,"none");else W.current="none",U([]),B(null),F(null)};return window.addEventListener("popstate",b),()=>window.removeEventListener("popstate",b)},[Q,d0.cloud,d0.designRel,P4]),p.useEffect(()=>{let b=N||(V===o8?null:V);if(b===G.current)return;G.current=b;let S=hW(b,d0.designRel);if(W.current!=="none"&&bV(location,d0.designRel)!==S)history[S?"pushState":"replaceState"](S?{open:S}:null,"",Fg(location,S));W.current="push"},[V,N,d0.designRel]);let cY=N||(V===o8?null:V),iG=d0.cloud?"cloud":H9()?"native":"local",mH=(b)=>Og({rel:hW(b,d0.designRel),shell:iG,location,linkedHubUrl:Y8?.url,project:d0.cloud?Z:C8,localUrl:location.origin}),uH=(b=cY)=>{let S=hW(b,d0.designRel);if(S)rX({path:b,rel:S,label:UQ(b)})},N1=p.useCallback((b)=>{if(n0(null),A0(null),$8(),g0((S)=>S+1),b&&b!==o8)a0(b)},[$8]),oG=p.useRef(!1);p.useEffect(()=>{if(oG.current)return;if(!d0.cloud)return;if(new URLSearchParams(location.search).has("open")){oG.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(!C5.test(d))continue;if(/(^|\/)system\//.test(d))continue;b=d;break}if(b)break}if(!b)return;oG.current=!0,B6(b,{reveal:!1})},[d0.cloud,J,K.length,B6]);let CQ=p.useCallback((b)=>{let S=typeof b==="string"?b:void 0;if(S)X5(S);else if(!L8)X5();B6(o8)},[L8,X5,B6]);p.useEffect(()=>{v7({type:"tabs",tabs:K.map((b)=>b.path).filter((b)=>b!==o8)})},[K]),p.useEffect(()=>{if(V&&V!==o8)v7({type:"active",file:V});else if(V===o8)v7({type:"active",file:""});else v7({type:"active",file:""})},[V]);let iY=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}),S8.current.delete(b),a0((S)=>S===b?null:S)},[V]);pY.current=(b)=>{if(!b?.rel)return;let S=(d0?.designRel||d0?.designRoot||".design").replace(/^\/+|\/+$/g,""),d=`${S}/${b.rel}`;if(b.action==="removed")iY(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),a0((K0)=>K0===X0?null:K0),S8.current.delete(X0)}};let x5=p.useCallback(()=>{if(!V||V===o8){if(V===o8)X5();return}let b=S8.current.get(V);if(b)b.src=b.src},[V,X5]),pH=p.useCallback(()=>j9(),[j9]),[F1,lH]=p.useState(!1),nG=p.useRef(!1),rG=p.useCallback(async()=>{if(nG.current)return;nG.current=!0,lH(!0);try{await Promise.all([j9(),new Promise((b)=>setTimeout(b,550))])}finally{nG.current=!1,lH(!1)}},[j9]);p.useEffect(()=>{let b=null,S=()=>{if(b)clearTimeout(b);b=setTimeout(()=>{b=null,pH()},150)};return window.addEventListener("focus",S),()=>{if(window.removeEventListener("focus",S),b)clearTimeout(b)}},[pH]);let L1=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 j9(),B6(d.file),{ok:!0,file:d.file}}catch(S){return{ok:!1,error:S instanceof Error?S.message:"network error"}}},[j9,B6]),dH=p.useCallback(async()=>{let b=await J5("New video name");if(!b)return;let d=(await J5("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 J5("Frames per second","30"))||30));try{let E0=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 E0.json().catch(()=>({}));if(!E0.ok||!l.ok){g8(`New video failed: ${l.error||`error ${E0.status}`}`);return}await j9(),B6(l.file),Z8(!0),g8("New video created — drop clips on the timeline to start the cut.",!0)}catch(E0){g8(`New video failed: ${E0 instanceof Error?E0.message:"network error"}`)}},[j9,B6,J5]),D1=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 M0=L0.getAttribute("data-src");if(!M0)continue;d.push({src:M0,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(UQ(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})}),E0=await F0.json().catch(()=>({}));if(!F0.ok||!E0.ok){window.alert(`Assemble failed: ${E0.error||`error ${F0.status}`}`);return}await j9(),B6(E0.file)}catch(b){window.alert(`Assemble failed: ${b instanceof Error?b.message:"network error"}`)}},[V,j9,B6]),aG=p.useCallback(({accept:b,resolveTarget:S})=>{let d=V,X0=P7||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 E0=K0.files?.[0];if(F0(),!E0)return;let l=`/_api/comp-clips?canvas=${encodeURIComponent(d)}${X0?`&artboardId=${encodeURIComponent(X0)}`:""}`;fetch(l).then((L0)=>L0.json().catch(()=>({}))).then((L0)=>{let M0=S(L0);if(!M0)return g8("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":E0.type||"application/octet-stream"},body:E0}).then((h0)=>h0.json().catch(()=>({}))).then((h0)=>{if(!h0?.path)return g8(`Upload failed: ${h0?.error||"unknown error"}`),null;if(M0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:d,arrayName:M0.arrayRef.arrayName,index:M0.arrayRef.index,field:M0.arrayRef.field,value:h0.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:d,id:M0.cdId,attr:"src",value:h0.path})})})}).then((L0)=>L0?L0.json():null).then((L0)=>{if(L0&&!L0.ok)g8(`Replace refused: ${L0.error||"failed"}`);else if(L0&&L0.ok){if(g8("Media replaced.",!0),L0.seq!=null)z6(d,L0.seq,"replace media")}}).catch(()=>g8("Replace failed: network error"))}),K0.click()},[V,P7,z6]),M1=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,H9()&&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(H9())IV(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 lm(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 dm(J,X){let Q=lm(J),Y=lm(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 cm(J,X){if(!Array.isArray(J))return[];return J.filter((Q)=>Q&&(Q.version==null||dm(Q.version,X)))}function im(J,X){let Q=X;if(Array.isArray(J)){for(let Y of J)if(Y&&Y.version&&dm(Y.version,Q))Q=Y.version}return Q}var RE="mdcc-whatsnew-seen",CE="mdcc-whatsnew-toast-dismissed";function SV0(J){return typeof J==="string"&&/^https?:\/\//i.test(J)}function bV0(J){try{let X=localStorage.getItem(RE);if(X)return X;localStorage.setItem(RE,J)}catch{}return J}function yV0(){try{return localStorage.getItem(CE)}catch{return null}}function om(J){let[X,Q]=PJ.useState([]),[Y,W]=PJ.useState(J),[G,Z]=PJ.useState(()=>bV0(J)),[H,K]=PJ.useState(()=>yV0()),[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=cm(X,G),N=B.length>0&&H!==Y&&!U,F=B[0]??null,M=PJ.useCallback(()=>{let O=im(X,Y);Z(O),K(Y);try{localStorage.setItem(RE,O),localStorage.setItem(CE,Y)}catch{}},[X,Y]),A=PJ.useCallback(()=>{K(Y);try{localStorage.setItem(CE,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 nm({wn:J}){let X=`whats-new-${J.feedVersion}`;return PJ.useEffect(()=>{if(!J.showToast||!J.toastEntry){gW(X);return}A5({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(()=>()=>gW(X),[X]),null}function rm({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}),SV0(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 c5=b8(i8(),1),jV0=Object.freeze({dirs:[],sections:{}}),vV0="mdcc-sections-expanded",fV0=250,xV0=3000;function sm(J,X){return!!X&&J.dirs.includes(X)}function hV0(J,X){return J.sections[X]===!0}function $E(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 tm(J,X,Q){if(!X||J.sections[X]===!!Q)return J;return{...J,sections:{...J.sections,[X]:!!Q}}}function em(J,X){return tm(J,X,!hV0(J,X))}function gV0(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=gV0(X,Q);if(!W)return J;let G=tm(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=$E(G,U,!0);return G}function SE(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 Ju(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 Xu(J,X){let Q=J.dirs.filter((Y)=>X.has(Y));return Q.length===J.dirs.length?J:{...J,dirs:Q}}function am(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 mV0(){try{let J=JSON.parse(localStorage.getItem(vV0)||"null");return J&&typeof J==="object"&&!Array.isArray(J)?J:null}catch{return null}}function Qu({fetchImpl:J}={}){let[X,Q]=c5.useState(jV0),[Y,W]=c5.useState(!1),G=J||((...U)=>fetch(...U)),Z=c5.useRef(G);Z.current=G,c5.useEffect(()=>{let U=!1,V=typeof AbortController==="function"?new AbortController:null,B=setTimeout(()=>V?.abort(),xV0);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=am(N);if(!(N&&typeof N==="object"&&N.sections&&Object.keys(N.sections).length)){let A=mV0();if(A)F=am({...F,sections:A})}Q(F)}).catch(()=>{}).finally(()=>{if(clearTimeout(B),!U)W(!0)}),()=>{U=!0,clearTimeout(B)}},[]);let H=c5.useRef(!0);c5.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{}},fV0);return()=>clearTimeout(U)},[Y,X]);let K=c5.useCallback((U)=>Q((V)=>U(V)),[]);return{state:X,ready:Y,update:K}}var z7=({as:J,size:X=14})=>z(J,{size:X,strokeWidth:1.75,style:{display:"block"}}),B90="mdcc-usage-tour-seen",N90="mdcc-collab-tour-seen",o8="__system__",r90="mdcc-theme",F90="mdcc-show-hidden",L90="maude-cp-mode",D90="mdcc-sidebar-open",M90="mdcc-minimap-visible",O90="mdcc-zoomctl-visible",A90="mdcc-annotations-visible";var rF0=30000;function aF0(J){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(J)}).catch(()=>{})}catch{}}var AT=[{id:"tree",label:"Files"},{id:"layers",label:"Layers"},{id:"inspector",label:"Inspector"},{id:"comments",label:"Comments"},{id:"changes",label:"Changes"},{id:"sync",label:"Sync"},{id:"assistant",label:"Assistant"}],sK={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",sync:"right",assistant:"right"},_90="mdcc-panel-sides",w90="mdcc-layers-mode";function E90({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]||(AT.find((U)=>U.id===K)||{}).label||K},K))}),Z]})}var C5=/\.(tsx|html?)$/i,P90=(J)=>/\.(tsx|jsx)$/i.test(String(J||"")),sF0=[[/\.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 sF0)if(X.test(J))return Q;return null}function _q(J){return J.replace(/^\.[^/]+\//,"").replace(C5,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}function tF0(J){let X=[];return function Q(Y){for(let W of Y||[])X.push(W?.id??""),Q(W?.children)}(J),X.join(",")}var _T="1.6.7";function BL(J,X){let Q=()=>{try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(J,{body:X})}catch{}};if(H9()){A7("send_notification",{title:J,body:X}).catch(Q);return}Q()}function eF0(){if(typeof window>"u")return"dark";try{let J=localStorage.getItem(r90);if(J==="light"||J==="dark")return J}catch{}return"dark"}function kH(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 I90(J,X){if(typeof window>"u")return X;try{let Q=localStorage.getItem(J);return Q?JSON.parse(Q):X}catch{return X}}function JL0(){return!1}var XL0=[];function UQ(J){return J.split("/").pop()}function g8(J,X=!1,Q){A5({title:J,kind:X?"success":"error",action:Q})}var k90="maude-mode-hint-seen";function LL(J=!1){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(k90)==="1")return}catch{return}if(LL.active)return;LL.active=!0;let X=()=>{LL.active=!1;try{localStorage.setItem(k90,"1")}catch{}document.removeEventListener("keydown",Q,!0)},Q=(Y)=>{if((Y.key==="v"||Y.key==="V")&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey)gW("mode-hint"),X()};if(J)document.addEventListener("keydown",Q,!0);A5({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(C5,"")}function QL0(J){return J.replace(C5,"")}function YL0(J){let X=new Map;for(let G of J){if(!C5.test(G.name))continue;let Z=QL0(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(C5.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 WL0(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 a90(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=a90(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 GL0(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 s90(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 ZL0={"chevron-down":z("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":z("polyline",{points:"6 3.5 10.5 8 6 12.5"}),file:D(Q0,{children:[z("path",{d:"M4 2h5l3 3v9H4z"}),z("polyline",{points:"9 2 9 5 12 5"})]}),folder:z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),"folder-plus":D(Q0,{children:[z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),z("path",{d:"M8 7.5v3.5M6.25 9.25h3.5"})]}),lock:D(Q0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015 0v2"})]}),unlock:D(Q0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015-.7"})]}),search:D(Q0,{children:[z("circle",{cx:"7",cy:"7",r:"4"}),z("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:D(Q0,{children:[z("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),z("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),check:z("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),x:D(Q0,{children:[z("line",{x1:"4.3",y1:"4.3",x2:"11.7",y2:"11.7"}),z("line",{x1:"11.7",y1:"4.3",x2:"4.3",y2:"11.7"})]}),sun:D(Q0,{children:[z("circle",{cx:"8",cy:"8",r:"2.6"}),z("line",{x1:"8",y1:"1.5",x2:"8",y2:"3"}),z("line",{x1:"8",y1:"13",x2:"8",y2:"14.5"}),z("line",{x1:"1.5",y1:"8",x2:"3",y2:"8"}),z("line",{x1:"13",y1:"8",x2:"14.5",y2:"8"}),z("line",{x1:"3.4",y1:"3.4",x2:"4.4",y2:"4.4"}),z("line",{x1:"11.6",y1:"11.6",x2:"12.6",y2:"12.6"}),z("line",{x1:"12.6",y1:"3.4",x2:"11.6",y2:"4.4"}),z("line",{x1:"4.4",y1:"11.6",x2:"3.4",y2:"12.6"})]}),moon:z("path",{d:"M12.5 9.6A5 5 0 1 1 7 3a4 4 0 0 0 5.5 6.6z"}),sparkle:z("path",{d:"M8 1.8l1.4 4.8L14 8l-4.6 1.4L8 14.2l-1.4-4.8L2 8l4.6-1.4z",fill:"currentColor",stroke:"none"}),megaphone:D(Q0,{children:[z("path",{d:"M2 6.7 11 4v8L2 9.3z"}),z("path",{d:"M11 5.2a2.4 2.4 0 0 1 0 5.6"}),z("path",{d:"M4.3 9.5v2.3a1.2 1.2 0 0 0 2.4 0v-1.7"})]}),bug:D(Q0,{children:[z("circle",{cx:"8",cy:"9",r:"3.6"}),z("circle",{cx:"8",cy:"4.4",r:"1.3"}),z("path",{d:"M6.2 3.4 5.2 2M9.8 3.4l1-1.4"}),z("path",{d:"M4.6 7.6H2.2M4.6 9H2.2M4.6 10.6H2.5M11.4 7.6h2.4M11.4 9h2.4M11.4 10.6h2.3"})]}),"panel-left":D(Q0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("line",{x1:"6.4",y1:"3",x2:"6.4",y2:"13"})]}),resolve:D(Q0,{children:[z("circle",{cx:"8",cy:"8",r:"5.6"}),z("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:D(Q0,{children:[z("path",{d:"M3.2 8a5 5 0 1 1 1.4 3.5"}),z("polyline",{points:"3.2 11.4 3.2 8 6.6 8"})]}),layers:D(Q0,{children:[z("polygon",{points:"8 2.2 13.8 5.5 8 8.8 2.2 5.5"}),z("polyline",{points:"2.2 9 8 12.3 13.8 9"})]}),box:z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.2"}),type:D(Q0,{children:[z("polyline",{points:"4 4 12 4"}),z("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:D(Q0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"3"}),z("line",{x1:"6",y1:"8",x2:"10",y2:"8"})]}),input:D(Q0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"1.2"}),z("line",{x1:"5",y1:"8",x2:"5",y2:"8"})]}),link:D(Q0,{children:[z("path",{d:"M6.5 9.5a2.5 2.5 0 0 1 0-3.5l1.5-1.5a2.5 2.5 0 0 1 3.5 3.5l-1 1"}),z("path",{d:"M9.5 6.5a2.5 2.5 0 0 1 0 3.5l-1.5 1.5a2.5 2.5 0 0 1-3.5-3.5l1-1"})]}),list:D(Q0,{children:[z("line",{x1:"6",y1:"4.5",x2:"13",y2:"4.5"}),z("line",{x1:"6",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6",y1:"11.5",x2:"13",y2:"11.5"}),z("circle",{cx:"3.2",cy:"4.5",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"8",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"11.5",r:"0.8",fill:"currentColor"})]}),eye:D(Q0,{children:[z("path",{d:"M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z"}),z("circle",{cx:"8",cy:"8",r:"2"})]}),eyedropper:D(Q0,{children:[z("path",{d:"M11 2.6a1.7 1.7 0 0 1 2.4 2.4l-1.2 1.2-2.4-2.4z"}),z("path",{d:"M9.5 4.6 4 10.1V12h1.9l5.5-5.5"})]}),"p-corner":z("path",{d:"M3.5 12.5V7a3.5 3.5 0 0 1 3.5-3.5h5.5"}),"p-opacity":D(Q0,{children:[z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.5"}),z("path",{d:"M3 8h10M8 3v10",strokeWidth:"0.9",opacity:"0.55"})]}),"p-lineheight":D(Q0,{children:[z("line",{x1:"6.5",y1:"4",x2:"13",y2:"4"}),z("line",{x1:"6.5",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6.5",y1:"12",x2:"13",y2:"12"}),z("path",{d:"M3.2 4.6 3.2 11.4M2 6 3.2 4.5 4.4 6M2 10 3.2 11.5 4.4 10"})]}),"p-letterspacing":D(Q0,{children:[z("path",{d:"M3 4v8M13 4v8"}),z("path",{d:"M6 11.5 8 5l2 6.5M6.7 9.3h2.6",strokeWidth:"1.1"})]}),"p-gap":D(Q0,{children:[z("rect",{x:"2",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("rect",{x:"10.4",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("path",{d:"M6.8 8h2.4M7.4 6.9 6.4 8l1 1.1M8.6 6.9 9.6 8l-1 1.1",strokeWidth:"1"})]}),"p-border":z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"}),"p-size":D(Q0,{children:[z("path",{d:"M3 13 6.6 3l3.6 10"}),z("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":D(Q0,{children:[z("path",{d:"M6.3 4A6.7 6.7 0 0 1 8 3.5C12 3.5 14.5 8 14.5 8a12 12 0 0 1-2 2.4M4.4 5.3A12 12 0 0 0 1.5 8S4 12.5 8 12.5a6.5 6.5 0 0 0 2.1-.35"}),z("line",{x1:"2.5",y1:"2.5",x2:"13.5",y2:"13.5"})]}),sliders:D(Q0,{children:[z("line",{x1:"3",y1:"5",x2:"13",y2:"5"}),z("circle",{cx:"6",cy:"5",r:"1.7",fill:"currentColor"}),z("line",{x1:"3",y1:"11",x2:"13",y2:"11"}),z("circle",{cx:"10",cy:"11",r:"1.7",fill:"currentColor"})]}),code:D(Q0,{children:[z("polyline",{points:"6 5 3 8 6 11"}),z("polyline",{points:"10 5 13 8 10 11"})]}),download:D(Q0,{children:[z("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),z("polyline",{points:"4.5 7 8 10.5 11.5 7"}),z("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),reload:D(Q0,{children:[z("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),z("path",{d:"M14 2v3.33h-3.33"})]}),help:D(Q0,{children:[z("circle",{cx:"8",cy:"8",r:"6"}),z("path",{d:"M6.3 6.2a1.8 1.8 0 1 1 2.3 1.9c-.5.2-.6.5-.6 1v.3"}),z("line",{x1:"8",y1:"11.4",x2:"8",y2:"11.5"})]}),image:D(Q0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("circle",{cx:"6",cy:"6.3",r:"1.1"}),z("path",{d:"M3 12l3-2.8 2.2 1.8 2.4-3L13.5 12"})]}),vector:D(Q0,{children:[z("path",{d:"M3.6 11.2C6 5 10 5 12.4 11.2"}),z("rect",{x:"1.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"11.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"6.7",y:"2.6",width:"2.6",height:"2.6",rx:"0.4"})]}),presentation:D(Q0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"7.4",rx:"1"}),z("line",{x1:"8",y1:"10.4",x2:"8",y2:"13"}),z("line",{x1:"5.6",y1:"13.4",x2:"10.4",y2:"13.4"})]}),archive:D(Q0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"3",rx:"0.8"}),z("path",{d:"M3.6 6v6.2a1 1 0 0 0 1 1h6.8a1 1 0 0 0 1-1V6"}),z("line",{x1:"6.6",y1:"8.8",x2:"9.4",y2:"8.8"})]}),external:D(Q0,{children:[z("path",{d:"M11 8.5V12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h3.5"}),z("polyline",{points:"9.5 3 13 3 13 6.5"}),z("line",{x1:"13",y1:"3",x2:"7.6",y2:"8.4"})]}),share:D(Q0,{children:[z("circle",{cx:"4",cy:"8",r:"1.9"}),z("circle",{cx:"11.6",cy:"3.6",r:"1.9"}),z("circle",{cx:"11.6",cy:"12.4",r:"1.9"}),z("line",{x1:"5.7",y1:"7",x2:"9.9",y2:"4.6"}),z("line",{x1:"5.7",y1:"9",x2:"9.9",y2:"11.4"})]}),pen:D(Q0,{children:[z("path",{d:"M3 13l.8-3L10.6 3.2a1.1 1.1 0 0 1 1.6 0l.6.6a1.1 1.1 0 0 1 0 1.6L6 12.2z"}),z("line",{x1:"9.6",y1:"4.2",x2:"11.8",y2:"6.4"})]}),square:z("rect",{x:"3.5",y:"3.5",width:"9",height:"9",rx:"1"})};function HL0({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(()=>XB(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(T9,{name:"search",size:18}),z("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(V)=>W(V.target.value),onKeyDown:(V)=>{if(V.key==="Escape")V.preventDefault(),X();else if(V.key==="ArrowDown")V.preventDefault(),Z((B)=>Math.min(K.length-1,B+1));else if(V.key==="ArrowUp")V.preventDefault(),Z((B)=>Math.max(0,B-1));else if(V.key==="Enter"){V.preventDefault();let B=lb(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(T9,{name:V.icon,size:15})}),z("span",{className:"st-pal-label",children:V.label}),V.kbd?z("span",{className:"st-pal-kbd",children:z(TJ,{children:V.kbd})}):null]})]},V.id)})})]})})}function T9({name:J,size:X=16,className:Q}){return z("svg",{className:Q,width:X,height:X,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:ZL0[J]})}function zL0(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 T90({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 R90(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 C90({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 DT=[{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}],$90={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},KL0=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],Dq=[{id:"1x",label:"1× (native)",kind:"scale",value:1},{id:"2x",label:"2× (retina)",kind:"scale",value:2},{id:"3x",label:"3× (max)",kind:"scale",value:3},{id:"dpi150",label:"150 dpi",kind:"dpi",value:150},{id:"dpi300",label:"300 dpi (print)",kind:"dpi",value:300},{id:"dpi600",label:"600 dpi (high-res print)",kind:"dpi",value:600}],UL0="2x",S90=[{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}],VL0="auto",b90=[{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",BL0={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 NL0(J){let X=String(J||"").split(".").pop()?.toLowerCase();return BL0[X]||"application/octet-stream"}function FL0({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 r={...v};for(let e of u)r[e.path]=e.kind;return r})}).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((r)=>$(r).then((e)=>({...e,file:r}))));U(!1);let u=h.filter((r)=>r.ok),v=h.length-u.length;if(v>0)B(`${v} of ${h.length} uploads failed`);if(u.length)A((r)=>{let e={...r};for(let s of u)e[s.path]=j(s.file.type);return e}),F((r)=>{let e=new Set(r);for(let s of u)e.add(s.path);return e})},m=async()=>{U(!0),B(null);try{if(Y){let u=(await $h()||[]).map((v)=>new File([new Uint8Array(v.bytes)],v.name,{type:NL0(v.name)}));if(U(!1),u.length)await f(u);return}let x=await dZ();if(x?.bytes){await C(new Blob([new Uint8Array(x.bytes)]));return}}catch(x){B(x?.message||"open failed")}U(!1)},c=()=>{if(H9()){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(T9,{name:"x",size:15})})]}),D("div",{className:"st-dialog-bd",children:[D("div",{className:"st-ap-toolbar",children:[z("button",{type:"button",className:"st-btn",onClick: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(T9,{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 LL0({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((C0)=>H==="none"&&!C0.handoff&&C0.format!=="zip"&&!Yy.has(C0.format)||H!=="local"&&C0.format==="canva",[H]),[B,N]=p.useState(J==="handoff"?"shadcn":"png"),[F,M]=p.useState(()=>X&&cb("png",X)?X:bO("png")),[A,E]=p.useState(2),[w,O]=p.useState(UL0),[I,T]=p.useState(!0),[R,$]=p.useState(!1),[C,j]=p.useState(!1),[f,m]=p.useState(!1),[c,o]=p.useState(VL0),[x,h]=p.useState(qL0),[u,v]=p.useState(!0),[r,e]=p.useState(!1),[s,H0]=p.useState(null),[a,z0]=p.useState([]),i=DT.find((C0)=>C0.id===B)||DT[0],q0=i.handoff?[]:yO(i.format),Z0=900,P0=3600,s0=kK(W,JE(W,{artboardId:G})),e0=s0?.durationInFrames||0,Y8=s0?.fps||30,E8=i.temporal&&e0>900,C8=i.temporal&&e0>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 t8=p.useCallback(()=>{fetch("/_api/export-history").then((C0)=>C0.json()).then((C0)=>z0(Array.isArray(C0?.history)?C0.history.slice(0,6):[])).catch(()=>{})},[]);p.useEffect(()=>{t8()},[t8]),p.useEffect(()=>{function C0(_0){if(_0.key==="Escape")_0.preventDefault(),U()}return window.addEventListener("keydown",C0),()=>window.removeEventListener("keydown",C0)},[U]);async function o0(){if(i.handoff){let V8=`/design:handoff ${Q&&Q!==o8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(V8)}catch{}H0({ok:!0,msg:`Copied: ${V8} — 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 C0=i.temporal?{scale:A}:{};if(i.format==="png"){let $0=Dq.find((V8)=>V8.id===w)||Dq[1];if($0.kind==="dpi")C0.dpi=$0.value;else C0.scale=$0.value}if(i.format==="mp4"||i.format==="webm")C0.audio=u;if(C8)C0.maxFrames=e0;if(i.format==="pdf"){C0.pdfPrint={includeBleed:I,marks:{crop:C,registration:f}};let $0=S90.find((V8)=>V8.id===c)?.value;if($0!==void 0)C0.dpi=$0;if(x!=="keep")C0.text=x}if(G)C0.artboardId=G;if(Z?.selector)C0.selection=Z;if(Q&&Q!==o8)C0.canvasFile=Q;if(hU.has(i.format)&&ZB({exportLane:H,format:i.format,scope:F,artboardId:C0.artboardId})&&typeof K==="function")try{let $0=mO(C0);H0({ok:!0,msg:"Capturing…"});let V8=await K({format:i.format,artboardIds:[C0.artboardId],scale:$0,onProgress:(p8,y8)=>H0({ok:!0,msg:`Capturing ${p8}/${y8}…`})}),Q8=await gO(V8,i.format);for(let p8 of Q8)AL(p8.name,p8.blob);for(let p8 of Q8)await uO({format:i.format,scope:F,filename:p8.name});e(!1),H0({ok:!0,msg:`Saved ${Q8.map((p8)=>p8.name).join(", ")} to your downloads.`});return}catch($0){if(H!=="remote"){H0({ok:!1,msg:`Capture failed: ${$0&&$0.message||$0}`}),e(!1);return}}if(ZB({exportLane:H,format:i.format,scope:F})&&i.format==="pptx"&&typeof K==="function")try{H0({ok:!0,msg:"Capturing artboards…"});let $0=Q&&Q!==o8?UQ(Q).replace(/\.[^.]+$/,""):"export",{filename:V8,blob:Q8}=await hO({capture:K,name:$0,onProgress:(p8,y8)=>H0({ok:!0,msg:`Capturing ${p8}/${y8}…`}),onAssemble:()=>H0({ok:!0,msg:"Assembling deck…"})});AL(V8,Q8),await uO({format:i.format,scope:F,filename:V8}),e(!1),H0({ok:!0,msg:`Saved ${V8} to your downloads.`});return}catch($0){if(H!=="remote"){H0({ok:!1,msg:`Deck export failed: ${$0&&$0.message||$0}`}),e(!1);return}}if(H==="none"&&hU.has(i.format)){H0({ok:!1,msg:"Without the render service this workspace exports PNG/SVG of the active artboard only — switch Scope to “Active artboard”, or ask your admin to add maude-render."}),e(!1);return}try{let $0=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:i.format,scope:F,options:C0})});if(!$0.ok){H0({ok:!1,msg:await $0.text()||`Export failed (${$0.status})`}),e(!1);return}U()}catch($0){H0({ok:!1,msg:$0&&$0.message?$0.message:String($0)}),e(!1)}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(C0)=>{if(C0.target===C0.currentTarget)U()},children:D("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[D("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Export & handoff"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:U,children:z(T9,{name:"x",size:15})})]}),D("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:Q&&Q!==o8?`Format · ${X4(UQ(Q))}`:"Format"}),z("div",{className:"st-fmt-grid",children:DT.filter((C0)=>!C0.temporal||Y).map((C0)=>D("button",{type:"button","data-testid":`export-format-${C0.id}`,className:"st-fmt"+(C0.id===B?" is-on":""),disabled:V(C0),title:V(C0)?"Needs the render service — not configured on this workspace":void 0,onClick:()=>{N(C0.id),H0(null)},children:[z(T9,{name:C0.icon,size:16}),z("span",{className:"st-fmt-name",children:C0.label}),z("span",{className:"st-fmt-sub",children:C0.sub})]},C0.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:(C0)=>M(C0.target.value),children:q0.map((C0)=>z("option",{value:C0,children:$90[C0]},C0))})]}),!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:(C0)=>O(C0.target.value),children:Dq.map((C0)=>z("option",{value:C0.id,children:C0.label},C0.id))})]}),!i.handoff&&i.format==="png"&&z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let C0=Dq.find(($0)=>$0.id===w)||Dq[1],_0=C0.kind==="dpi"?C0.value/96:C0.value;return`${C0.label} ≈ ${Math.round(1440*_0)}×${Math.round(900*_0)} 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:(C0)=>E(Number(C0.target.value)),children:KL0.map((C0)=>z("option",{value:C0.value,children:C0.label},C0.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,")."]}),E8&&D("div",{className:"st-mono st-export-long-notice","data-testid":"export-long-comp-notice",style:{fontSize:11,color:"var(--accent)",lineHeight:1.5},children:["⚠ Long comp: ",e0," frames (≈",Math.round(e0/Y8),"s).",C8?` 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:(C0)=>o(C0.target.value),children:S90.map((C0)=>z("option",{value:C0.id,children:C0.label},C0.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:(C0)=>h(C0.target.value),children:b90.map((C0)=>z("option",{value:C0.id,children:C0.label},C0.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:b90.find((C0)=>C0.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:(C0)=>T(C0.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:()=>$((C0)=>!C0),"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:(C0)=>j(C0.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:(C0)=>m(C0.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:(C0)=>v(C0.target.checked)}),"Export with audio"]})}),i.handoff&&D("div",{className:"callout callout--info",style:{fontSize:12},children:["Hands the active canvas off to production. Copies"," ",z("span",{className:"st-mono",children:"/design:handoff <path>"})," — run it in Claude Code to emit a ready-to-drop production component next to the canvas."]}),s&&z("div",{className:"callout "+(s.ok?"callout--success":"callout--error"),style:{fontSize:12},"data-testid":"export-status","data-ok":s.ok?"1":"0",children:s.msg}),a.length>0&&D("div",{className:"st-export-recent","data-testid":"export-recent",children:[z("div",{className:"st-rp-hd",children:"Recent"}),a.map((C0,_0)=>D("div",{className:"st-export-recent-row",children:[D("span",{children:[String(C0.format||"").toUpperCase()," ·"," ",$90[C0.scope]||C0.scope]}),z("span",{className:"st-mono",children:C0.filename})]},_0))]})]}),D("div",{className:"st-dialog-ft",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:U,children:"Cancel"}),D("button",{type:"button",className:"btn btn--primary","data-testid":"export-submit",disabled:r,onClick:o0,children:[z(T9,{name:"download",size:14}),i.handoff?"Copy handoff command":r?"Exporting…":`Export ${i.label}`]})]})]})})}var PL=12,IL=16;function DL0({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-${_q(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(T9,{name:"chevron-right",className:"st-chev"+(K?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:J})]});return z(cz,{label:J,row:A,expanded:K,busy:M,onToggle:()=>U((E)=>!E),actions:G?z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${_q(Y)}`,title:`Folder actions — ${J}`,"aria-label":`Folder actions for ${J}`,"aria-haspopup":"menu",onClick:(E)=>G.openAt(E,{kind:"dir",dirPath:Y}),children:z(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 ML0({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(cz,{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(T9,{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(T9,{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=C5.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(C5,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,x=D("button",{type:"button",role:"treeitem","data-testid":o??(f?`file-row-${_q(J.path)}`:void 0),"aria-selected":M,"aria-disabled":w?"true":void 0,"aria-busy":C||void 0,tabIndex:M?0:-1,className:"st-row"+(M?" is-sel":"")+(K==="runtime"?" is-muted":"")+($?" is-dragging":"")+(C?" is-busy":""),style:{paddingLeft: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)},onPointerEnter:E==="image"?()=>iw(J.path):void 0,onFocus:E==="image"?()=>iw(J.path):void 0,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(T9,{name:"file",size:13})}),z("span",{className:"st-row-name",children:O}),B==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),B==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),V&&z("span",{className:"st-git-badge","data-kind":V,title:`Unsaved (${V})`,"aria-label":`Unsaved, ${V}`,children:V}),Z>0&&z("span",{className:"st-row-badge",children:Z})]});return z(cz,{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-${_q(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 OL0({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(T9,{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(cz,{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-${_q(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 t90({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(()=>YL0(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(OL0,{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(t90,{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(ML0,{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(DL0,{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 AL0(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 _L0({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:r,onRenameFolder:e,onRenameCanvas:s,onDuplicateCanvas:H0,onDeleteFile:a,syncStatus:z0,onLinkedHub:i,onLocalProject:q0,onOpenLinkedFile:Z0,filesReady:P0,onShare:s0,savingIsManaged:e0=!1}){let Y8=p.useMemo(()=>{if(!V)return Q;return Q.map((T0)=>({...T0,tree:a90(T0.tree,V),filtered:!!V}))},[Q,V]),E8=zy(u),C8=Gy(),t8=p.useMemo(()=>{let T0=[];for(let n0 of Q){if(n0.label==="Design system"||n0.kind!=="canvas")continue;let x0=n0.fullPath.replace(/^\.[^/]+\//,"")||n0.fullPath;T0.push({path:n0.fullPath,label:x0});for(let g0 of n0.dirs||[])T0.push({path:g0,label:g0.replace(/^\.[^/]+\//,"")})}return T0},[Q]),o0=C8.state?.extra,C0=o0?.kind==="file"?[{id:"share",label:"Share…",onSelect:()=>{C8.close(),s0(o0.path)}},...s&&/\.tsx$/i.test(o0.path)?[{id:"rename-canvas",label:"Rename…",onSelect:()=>{C8.close();let T0=X4(o0.path.split("/").pop()),n0=window.prompt("Rename canvas to:",T0);if(n0?.trim()&&n0.trim()!==T0)s(o0.path,n0.trim())}}]:[],...H0&&/\.tsx$/i.test(o0.path)?[{id:"duplicate-canvas",label:"Duplicate",onSelect:()=>{C8.close(),H0(o0.path)}}]:[],...o0.supporting&&s?[{id:"rename-file",label:"Rename…",onSelect:()=>{C8.close();let T0=o0.name??o0.path.split("/").pop(),n0=T0.includes(".")?T0.slice(T0.lastIndexOf(".")):"",x0=n0?T0.slice(0,-n0.length):T0,g0=window.prompt(`Rename ${T0} to:`,x0);if(g0?.trim()&&g0.trim()!==x0)s(o0.path,g0.trim())}}]:[],...o0.canMove?[{id:"move-to",label:"Move to…",onSelect:()=>C8.showMoveTo()}]:[],...o0.supporting&&a?[{id:"delete-file",label:"Delete",destructive:!0,onSelect:()=>{C8.close(),a(o0.path,o0.name??o0.path.split("/").pop())}}]:[]]:o0?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{C8.close();let T0=window.prompt("New folder name:");if(T0?.trim())v(o0.dirPath,T0.trim())}},{id:"rename-folder",label:"Rename folder",onSelect:()=>{C8.close();let T0=o0.dirPath.split("/").pop(),n0=window.prompt("Rename folder to:",T0);if(n0?.trim()&&n0.trim()!==T0)e(o0.dirPath,n0.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{C8.close(),r(o0.dirPath,o0.dirPath.split("/").pop())}}]:[],_0=o0?.kind==="file"||o0?.kind==="supporting"?t8.filter((T0)=>T0.path!==o0.dir):[],[$0,V8]=p.useState(!1),[Q8,p8]=p.useState("board"),[y8,D9]=p.useState(""),[f0,k8]=p.useState(""),[A9,L8]=p.useState(!1),B0=p.useMemo(()=>Q.find((T0)=>T0.kind==="canvas"&&T0.label!=="Design system")?.fullPath,[Q]),J8=p.useCallback(async()=>{let T0=y8.trim();if(!T0||A9)return;if(L8(!0),k8(""),Q8==="folder"){if(!B0){L8(!1),k8("no canvas group to create a folder in");return}let x0=await v(B0,T0);if(L8(!1),x0?.ok)V8(!1),D9("");else k8(x0?.error||"could not create folder");return}let n0=await w(T0);if(L8(!1),n0?.ok)V8(!1),D9("");else k8(n0?.error||"could not create board")},[y8,A9,w,v,Q8,B0]),a0=p.useMemo(()=>{let T0=0;for(let n0 of Q)for(let x0 of n0.paths||[])if(C5.test(x0))T0++;return T0},[Q]),e8=p.useMemo(()=>{let T0=0;for(let n0 of Y8)for(let x0 of n0.paths||[])if(C5.test(x0))T0++;return T0},[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":$0&&Q8==="board",onClick:()=>{k8(""),p8("board"),V8((T0)=>Q8==="board"?!T0:!0)},children:z(T9,{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":$0&&Q8==="folder",onClick:()=>{k8(""),p8("folder"),V8((T0)=>Q8==="folder"?!T0:!0)},children:z(T9,{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(T9,{name:"reload",size:15})}),D("span",{className:"st-live","data-tip":U?"live · file index synced":"reconnecting…",children:[z("span",{className:"st-live-dot"+(U?" is-connected":""),"aria-hidden":"true"}),e8," / ",a0]}),$&&z("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:$,children:z(T9,{name:"panel-left",size:15})})]})]}),$0?D("div",{className:"st-newboard",children:[z("input",{type:"text",autoFocus:!0,placeholder:Q8==="folder"?"folder name…":"brief board name…",value:y8,maxLength:60,disabled:A9,"aria-label":Q8==="folder"?"New folder name":"New brief board name",onChange:(T0)=>D9(T0.target.value),onKeyDown:(T0)=>{if(T0.key==="Enter")T0.preventDefault(),J8();else if(T0.key==="Escape")T0.preventDefault(),V8(!1),D9(""),k8("")}}),z("button",{type:"button",className:"st-newboard-go",disabled:A9||!y8.trim(),"data-tip":"Create · Enter","aria-label":Q8==="folder"?"Create folder":"Create brief board",onClick:J8,children:A9?"…":"↵"})]}):null,f0?z("div",{className:"st-newboard-err",role:"alert",children:f0}):null,z("div",{className:"st-search",children:D("div",{className:"st-search-box",children:[z(T9,{name:"search",size:13}),z("input",{type:"search","data-testid":"canvas-search",placeholder:"Search canvases…",value:V,onChange:(T0)=>B(T0.target.value),onKeyDown:(T0)=>{if(T0.key==="Escape")if(T0.preventDefault(),V)B("");else T0.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(Hy,{"aria-label":"Project file tree","data-testid":"canvas-list",children:Y8.map((T0)=>{if(!F&&!V&&T0.kind==="runtime")return null;let n0=AL0(T0),x0=(T0.paths||[]).filter((m7)=>C5.test(m7)).length,g0=n0.pill||(n0.pillFromDsCount?String(T0.dsFolders?.length||0):null)||(n0.pillFromCount?String(x0||T0.paths?.length||0):null),P8=T0.tree&&Object.keys(T0.tree).length>0,A0=T0.label==="Design system",W8=T0.kind==="project";if(!F&&!V&&W8&&x0===0)return null;let _8=JL0(T0),U0=M[T0.label],i0=!!V||(U0===void 0?_8:U0),I8=!A0&&T0.kind==="canvas"&&!J,Y9=I8?E8.dropProps(T0.fullPath,!0):{},d0=E8.overDir===T0.fullPath;return z(cz,{className:"st-tree-section",label:n0.title,expanded:i0,onToggle:()=>A(T0.label,_8),row:D("button",{type:"button",className:"st-tree-sec-hd"+(d0?" is-drop-target":""),"data-testid":`tree-section-${T0.label.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,onClick:()=>A(T0.label,_8),"aria-expanded":i0,"aria-dropeffect":I8?"move":void 0,title:i0?"Collapse section":"Expand section",...Y9,children:[z(T9,{name:"chevron-right",className:"st-chev"+(i0?" is-open":""),size:13}),z("span",{className:"st-sec-name",children:n0.title}),g0&&z("span",{className:"st-pill",children:g0})]}),children:i0&&(P8?z(t90,{node:T0.tree,activePath:Y,previewPath:W,onOpen:Z,onPreview:H,commentsByFile:N,depth:1,kind:T0.kind,showHidden:F,search:V,dsFolders:T0.dsFolders,activeDsName:G,onOpenSystem:A0?K:void 0,onDelete:A0||J?void 0:O,dirtyByPath:f,canvasKinds:h,dirPath:T0.fullPath,drag:!A0&&T0.kind==="canvas"&&!J?E8:void 0,menu:C8,expansion:E}):z("div",{className:"st-tree-empty",children:V?"No matches.":"Empty."}))},T0.label)})}),z(Zy,{state:C8.state,onClose:C8.close,rootItems:C0,destinations:_0,onPickDestination:(T0)=>u(o0.path,T0)}),z(ME,{project:m,liveBranch:c,remoteSync:o,onGetLatest:x,projectOnly:e0}),X===null?z(yw,{syncStatus:z0,onLinkedHub:i,onLocalProject:q0,onOpenFile:Z0,filesReady:P0}):null,z(hw,{})]})}function wL0({shown:J,onExpand:X,onSearch:Q}){return z("div",{className:"st-rail"+(J?" is-shown":""),children:D("div",{className:"st-rail-inner",children:[z("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:X,children:z(T9,{name:"panel-left",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:z(T9,{name:"search",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:X,children:z(T9,{name:"folder",size:15})})]})})}function EL0({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",_T]}),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 MT=[{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 PL0({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 IL0({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=MT.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:MT.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(PL0,{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 · ",MT.length," groups"]})]})]})})}var kL0=["File","Edit","View","Selection","Tools","Help"];function e90(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 TL0({panels:J,onToggle:X,onClose:Q,onZoom:Y,hasCanvas:W}){return e90(Q),D("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[z("div",{className:"st-dd-hd",children:"Panels"}),J.map((G)=>D("button",{type:"button",role:"menuitem",className:"st-dd-item"+(G.checked?" is-on":""),"aria-disabled":G.disabled?"true":void 0,title:G.hint||void 0,onClick:()=>{if(G.disabled){if(G.href)window.open(G.href,"_blank","noopener,noreferrer"),Q();return}X(G.id),Q()},children:[D("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check",children:G.checked?z(T9,{name:"check",size:13}):null}),z("span",{children:G.label}),G.phase?z("span",{className:"st-dd-phase",children:G.phase}):null]}),G.shortcut?z(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 X1({label:J,left:X,header:Q,items:Y,onAction:W,onClose:G}){return e90(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 RL0({onAction:J,onClose:X}){return z(X1,{label:"Help",left:320,onAction:J,onClose:X,items:[{id:"shortcuts",label:"Keyboard shortcuts",shortcut:"?"},{id:"help",label:"Help · commands & flows",shortcut:"F1"},{id:"report-bug",label:"Report a bug…"},{sep:!0},{id:"tour",label:"Take the tour"},{id:"watch-intro",label:"Watch the intro"},...H9()?[{id:"collab-tour",label:"How sharing works"}]:[],...H9()?[{id:"quick-setup",label:"Quick setup"}]:[],...H9()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function CL0({onAction:J,onClose:X,readOnly:Q=!1}){return z(X1,{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 $L0({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(X1,{label:"Tools",left:290,header:"Tool palette",onAction:J,onClose:X,items:Y})}function SL0({onAction:J,onClose:X,hasCanvas:Q,hasSharePath:Y,readOnly:W=!1}){return z(X1,{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 bL0({onAction:J,onClose:X,hasCanvas:Q,readOnly:Y=!1}){if(Y)return z(X1,{label:"Edit",left:90,onAction:J,onClose:X,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"}]});return z(X1,{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 yL0({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:r,onOpenWhatsNew:e,onOpenReadiness:s,onOpenQuickSetup:H0,onWatchIntro:a,whatsNewCount:z0,exportCenter:i,artboardCount:q0=0,presence:Z0=null,inspectorOpen:P0,inspectorTab:s0,onToggleInspector:e0,autoOpenInspector:Y8,onToggleAutoOpenInspector:E8,onOpenLayers:C8,timelineOpen:t8,onToggleTimeline:o0,hasComps:C0=!1,assistantOpen:_0,onToggleAssistant:$0,assistantBusy:V8,assistantUnseen:Q8,onNewCanvas:p8,onAssembleVideo:y8,onOpenExport:D9,onOpenSettings:f0,onOpenGenerate:k8,onReload:A9,onCloseCanvas:L8,onInsertArtboard:B0,readOnly:J8=!1}){let a0=J===o8,e8=a0?"SYSTEM":J?"CANVAS":"IDLE",T0=a0?z("b",{children:"design system"}):J?D(Q0,{children:[J.split("/").slice(0,-1).join("/"),"/",z("b",{children:X4(UQ(J))})]}):z("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),n0=new Set(W?["autoopen"]:["assistant","autoopen"]),x0=[{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:P0&&s0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:P0,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!Y8,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:C0?"video":void 0,checked:t8,disabled:!1},...H9()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:_0,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||a0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:c,disabled:!J||a0},{id:"present",label:"Presentation Mode",shortcut:"",checked:x,disabled:!J||a0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:u,disabled:!J||a0}].filter((A0)=>!J8||!n0.has(A0.id)),g0=["file","edit","view","selection","tools","help"];function P8(A0){if(g0.includes(A0))H(Z===A0?null:A0)}return p.useEffect(()=>{if(!Z||!g0.includes(Z))return;let A0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function W8(_8){let U0=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!U0.length)return;let i0=U0.indexOf(document.activeElement);if(_8.key==="ArrowDown")_8.preventDefault(),U0[(i0+1)%U0.length].focus();else if(_8.key==="ArrowUp")_8.preventDefault(),U0[(i0-1+U0.length)%U0.length].focus();else if(_8.key==="Home")_8.preventDefault(),U0[0].focus();else if(_8.key==="End")_8.preventDefault(),U0[U0.length-1].focus();else if(_8.key==="ArrowRight"||_8.key==="ArrowLeft"){_8.preventDefault();let I8=_8.key==="ArrowRight"?1:-1,Y9=g0.indexOf(Z);H(g0[(Y9+I8+g0.length)%g0.length])}else if(_8.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",W8),()=>{clearTimeout(A0),window.removeEventListener("keydown",W8)}},[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:kL0.map((A0)=>{let W8=A0.toLowerCase(),_8=g0.includes(W8),U0=_8||W8==="help",i0=Z===W8;return z("button",{type:"button",className:"st-menu",role:"menuitem","data-testid":`menu-${W8}`,"data-tour":W8==="help"?"help":void 0,"aria-haspopup":_8?"menu":void 0,"aria-expanded":_8?i0:void 0,onClick:()=>P8(W8),onMouseEnter:()=>{if(Z!==null&&_8)H(W8)},children:A0},W8)})}),Z==="file"&&z(SL0,{readOnly:J8,hasCanvas:!!J,hasSharePath:!!X,onAction:(A0)=>{if(A0==="new")p8?.();else if(A0==="assemble")y8?.();else if(A0==="export")D9?.("export");else if(A0==="share")document.querySelector('[data-testid="menu-file"]')?.focus(),Q?.();else if(A0==="handoff")D9?.("handoff");else if(A0==="generate")k8?.();else if(A0==="settings")f0?.();else if(A0==="reload")A9?.();else if(A0==="close")L8?.()},onClose:()=>H(null)}),Z==="edit"&&z(bL0,{readOnly:J8,hasCanvas:!!J&&!a0,onAction:(A0)=>{if(A0==="undo")r({dgn:"undo"});else if(A0==="redo")r({dgn:"redo"});else if(A0==="deselect-all")r({dgn:"selection-clear"});else if(A0==="select-all-annotations")r({dgn:"annotation-select-all"});else if(A0.startsWith("new-artboard:"))B0?.(A0.slice(13))},onClose:()=>H(null)}),Z==="view"&&z(TL0,{panels:x0,onToggle:(A0)=>{if(A0==="tree")A();else if(A0==="changes")N();else if(A0==="comments")U();else if(A0==="hidden")w();else if(A0==="annotate")j();else if(A0==="inspector")e0();else if(A0==="autoopen")E8?.();else if(A0==="timeline")o0?.();else if(A0==="assistant")$0?.();else if(A0==="layers")C8?.();else if(A0==="minimap")m?.();else if(A0==="zoomctl")o?.();else if(A0==="present")h?.();else if(A0==="print-guides")v?.()},onZoom:(A0)=>r({dgn:"zoom",op:A0}),hasCanvas:!!J&&!a0,onClose:()=>H(null)}),Z==="selection"&&z(CL0,{readOnly:J8,onAction:(A0)=>{if(A0==="deselect-all")r({dgn:"selection-clear"});else if(A0==="select-all-annotations")r({dgn:"annotation-select-all"})},onClose:()=>H(null)}),Z==="tools"&&z($L0,{readOnly:J8,onAction:(A0)=>r({dgn:"tool-set",tool:A0}),onClose:()=>H(null)}),Z==="help"&&z(RL0,{onAction:(A0)=>{if(A0==="shortcuts")I?.();else if(A0==="help")O?.();else if(A0==="report-bug")T?.();else if(A0==="tour")R?.();else if(A0==="collab-tour")$?.();else if(A0==="quick-setup")H0?.();else if(A0==="readiness")s?.();else if(A0==="whatsnew")e?.();else if(A0==="watch-intro")a?.()},onClose:()=>H(null)}),D("div",{className:"st-mb-right","data-tour":"status",children:[Z0?z("div",{className:"st-presence",children:Z0}):null,J8&&z("span",{className:"st-stamp st-stamp--viewonly","data-testid":"view-only-stamp","data-tip":W?.user?`${W.user} is a viewer on this project — you can browse, comment and export where available. Ask a project owner for edit access, or sign out if that is not the account you meant to use.`:"Your role in this project is viewer — you can browse, comment when available, and export where available. Ask a project owner for edit access.",children:"VIEW ONLY"}),W?.user?D("span",{className:"st-cloudwho","data-testid":"cloud-account",children:[z("span",{className:"st-cloudwho-email",title:W.role?`Signed in as ${W.user} — ${W.role}`:W.user,children:W.user}),z("form",{method:"post",action:"/auth/browser/signout",className:"st-cloudwho-form",children:z("button",{type:"submit",className:"st-cloudwho-out","data-testid":"cloud-signout",title:"Sign out of this project",children:"Sign out"})})]}):null,H9()&&!J8&&z("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":_0?"true":"false","data-busy":V8?"true":"false","data-unseen":Q8?"true":"false","aria-label":`Assistant${V8?" — working":Q8?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:$0,children:z(T9,{name:"sparkle",size:15})}),z("button",{type:"button",className:"st-mb-icon st-share-btn","data-testid":"share-btn","data-tip":X?"Share link":"Open a canvas to share it","aria-label":"Share link",disabled:!X,onClick:Q,children:z(T9,{name:"share",size:15})}),i&&z(fm,{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(T9,{name:"bug",size:15})}),z("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":z0>0?"true":"false","aria-label":`What's new${z0>0?` — ${z0} unseen`:""}`,"data-tip":"What's new",onClick:e,children:z(T9,{name:"megaphone",size:15})}),z("span",{className:"st-stamp",children:e8}),z("span",{className:"st-mb-file",title:J||"",children:T0}),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 jL0({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=PZ($,{...H,canvasToken:void 0}),j=`${$}#${B}|${C}`,f=O.current.get(j);if(!f)f={path:$,src:PZ($,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: ${wK(UQ(E))}`,tabIndex:0,children:z(ig,{path:E,kind:EL(UQ(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",_T," / 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.",H9()?D(Q0,{children:[z("br",{}),z("br",{}),"Claude can see whatever's selected when you ask for a change in the Assistant panel, so pointing is often faster than describing it."]}):null]}),M&&z("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:A,children:"Start quick setup"})]}),J.map(($)=>{if($.path===o8)return z("div",{className:"system-view"+($.path===X?" active":""),children:z(lL0,{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(vL0,{path:K,cloud:!!H?.cloud},K),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:wK(UQ(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"})]})})]})}function vL0({path:J,cloud:X}){let[Q,Y]=p.useState(!1);p.useEffect(()=>{let G=setTimeout(()=>Y(!0),4000);return()=>clearTimeout(G)},[]);let W=wK(UQ(J||"").replace(/\.(tsx|jsx|html?)$/i,""));return z("div",{className:"st-canvas-loading",role:"status","aria-live":"polite","data-testid":"canvas-loading",children:D("div",{className:"st-skel-card",children:[D("div",{className:"st-canvas-loading-head",children:[z("span",{className:"st-canvas-loading-spinner","aria-hidden":"true"}),D("span",{className:"st-canvas-loading-title",children:["Opening ",W,"…"]})]}),z("span",{className:"skel st-skel-thumb","aria-hidden":"true"}),z("span",{className:"skel st-skel-line",style:{width:"72%"},"aria-hidden":"true"}),z("span",{className:"skel st-skel-line",style:{width:"46%"},"aria-hidden":"true"}),z("div",{className:"st-canvas-loading-hint"+(Q?" is-shown":""),children:X?"Still working — the first open of a canvas fetches its images and fonts from cloud storage. It is quicker next time.":"Still working — large canvases take a moment to build."})]})})}var fL0=["color","space","radius","shadow","leading","weight","motion","font","other"],xL0={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function hL0(J){return J==="color"}function gL0({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([...fL0,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return z(Q0,{children:W.map((G)=>{let Z=Y[G],H=hL0(G);return D("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[D("h2",{children:["tokens · ",xL0[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 mL0(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 uL0(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 pL0({tokenGroups:J}){let X=J?.fontsize||[];if(X.length===0)return null;let Q=J?.leading||[],Y=uL0(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=mL0(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 lL0({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(gL0,{tokens:H,tokenGroups:K,tokensPath:U}),z(pL0,{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(y90,{title:"preview",items:W,onOpen:X,kind:"preview",cfg:Q}),z(y90,{title:"ui kits",items:G,onOpen:X,kind:"ui_kits",cfg:Q})]})]})}function y90({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:PZ(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 dL0({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=dz(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(T9,{name:W==="dark"?"sun":"moon",size:13}),T]})]})}function cL0({commentsByFile:J,filter:X,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:K,width:U,resizing:V}){let B=s90(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(UQ(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:GL0(A.created)})]}),z("div",{className:"st-comment-txt",children:A.text}),D("div",{className:"st-comment-foot",children:[z("span",{className:"st-comment-sel",title:(A.dom_path||[]).join(" > "),children:A.selector||"—"}),Z&&H&&K?D("span",{className:"st-mini-act",children:[A.status==="resolved"?z("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(E)=>{E.stopPropagation(),H(A.id)},children:z(T9,{name:"reopen",size:14})}):z("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(E)=>{E.stopPropagation(),Z(A.id)},children:z(T9,{name:"resolve",size:14})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(E)=>{E.stopPropagation(),K(A.id)},children:z(T9,{name:"x",size:14})})]}):null]})]},A.id))]},M.file))})]})}var iL0={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 oL0({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=iL0[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 nL0({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),bh().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X,children:"Later"})]})}function rL0({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 aL0=["block","inline-block","flex","inline-flex","grid","inline","none"],j90=["px","%","fr","em","auto","min-content","max-content"];var sL0=["auto","stretch","flex-start","center","flex-end","baseline"];var v90=["300","400","500","600","700","800"],Mq=(J,X)=>J&&Object.hasOwn(J,"previous")?J.previous:X,f90=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],x90=["none","solid","dashed","dotted","double"],h90=["px","rem","em","%","vw","vh","auto"],g90=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),OT={"font-size":{node:z(z7,{as:mV,size:12})},"line-height":{node:z(z7,{as:oV,size:12})},"letter-spacing":{node:z(z7,{as:Q3,size:12})},gap:{node:z(z7,{as:PK,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:z(z7,{as:H3,size:12})},"border-width":{node:z(z7,{as:X3,size:12})}};var m90=["static","relative","absolute","fixed","sticky"],tL0=["normal","italic","oblique"],u90=["none","uppercase","lowercase","capitalize"];var p90=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],eL0=["fill","contain","cover","none","scale-down"];var l90=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],d90=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],R5={desktop:{label:"Desktop",width:1440,height:1024},laptop:{label:"Laptop",width:1280,height:800},tablet:{label:"Tablet",width:834,height:1194},mobile:{label:"Mobile",width:390,height:844}},tK=null;function wL(J){if(!J)return"";if(/^#[0-9a-f]{6}$/i.test(J))return J.toLowerCase();try{if(!tK)tK=document.createElement("canvas").getContext("2d");if(!tK)return"";tK.fillStyle="#000000",tK.fillStyle=J;let X=tK.fillStyle;if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();let Q=X.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(Q)return`#${[Q[1],Q[2],Q[3]].map((Y)=>Number(Y).toString(16).padStart(2,"0")).join("")}`}catch{}return""}var 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 Oq({r:J,g:X,b:Q}){return`#${[J,X,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function Aq({r:J,g:X,b:Q}){J/=255,X/=255,Q/=255;let Y=Math.max(J,X,Q),W=Math.min(J,X,Q),G=Y-W,Z=0;if(G){if(Y===J)Z=(X-Q)/G%6;else if(Y===X)Z=(Q-J)/G+2;else Z=(J-X)/G+4;if(Z*=60,Z<0)Z+=360}return{h:Z,s:Y?G/Y:0,v:Y}}function eK({h:J,s:X,v:Q}){let Y=Q*X,W=Y*(1-Math.abs(J/60%2-1)),G=Q-Y,Z=0,H=0,K=0;if(J<60)[Z,H,K]=[Y,W,0];else if(J<120)[Z,H,K]=[W,Y,0];else if(J<180)[Z,H,K]=[0,Y,W];else if(J<240)[Z,H,K]=[0,W,Y];else if(J<300)[Z,H,K]=[W,0,Y];else[Z,H,K]=[Y,0,W];return{r:(Z+G)*255,g:(H+G)*255,b:(K+G)*255}}function V7(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 c90(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 J70(J,X){return(J?X?.canvasDesignSystems?.[J]:null)||X?.defaultDesignSystem||X?.designSystems?.[0]?.name||null}function JD0(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 X70(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,...JD0(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 Q70({seed:J,label:X,onApply:Q}){let[Y,W]=p.useState(()=>Aq(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(Aq(FL(J)))},[J]);let U=Oq(eK(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(Oq(eK(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(Oq(eK(G.current)))};document.addEventListener("pointermove",$),document.addEventListener("pointerup",C)},N=(O)=>{let I={...G.current,...O};W(I),Q(Oq(eK(I)))},F=(O)=>{let I=O.shiftKey?0.1:0.02,R={ArrowLeft:[-I,0],ArrowRight:[I,0],ArrowUp:[0,I],ArrowDown:[0,-I]}[O.key];if(!R)return;O.preventDefault(),N({s: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(Aq(FL(I.sRGBHex))),Q(I.sRGBHex)}catch{}},E=eK(Y),w=(O)=>{let I={...E,...O},T=Aq({r:FY(I.r/255)*255,g:FY(I.g/255)*255,b:FY(I.b/255)*255});W(T),Q(Oq(eK(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(Aq(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(T9,{name:"eyedropper",size:14})}):null,z("span",{className:"st-cp-cpick-preview",style:{background:U},"aria-hidden":"true"}),z("button",{type:"button",ref:H,className:"st-cp-cpick-hue","aria-label":X?`${X} hue`:"hue",onPointerDown:B,onKeyDown:M,children:z("span",{className:"st-cp-cpick-huethumb",style:{left:`${Y.h/360*100}%`}})})]}),z("div",{className:"st-cp-cpick-rgb",children:["r","g","b"].map((O)=>D("label",{className:"st-cp-cpick-rgbf",children:[z("input",{"aria-label":O.toUpperCase(),value:Math.round(E[O]),onChange:(I)=>w({[O]: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 s0=window.innerHeight-z0.bottom>q0+8?z0.bottom+4:Math.max(8,z0.top-q0-4);N({left:Z0,top:s0,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)},a=(z0)=>{if(O.current?.contains(z0.target))return;e()};return document.addEventListener("pointerdown",s,!0),document.addEventListener("keydown",H0),window.addEventListener("resize",e),document.addEventListener("scroll",a,!0),()=>{document.removeEventListener("pointerdown",s,!0),document.removeEventListener("keydown",H0),window.removeEventListener("resize",e),document.removeEventListener("scroll",a,!0)}},[U]),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((a)=>a?{...a,left:a.left+s,top:a.top+H0}:a)},[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(T9,{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)),r=z("div",{className:"st-cp-pop-empty",children:"No match"});return D(Q0,{children:[G!==void 0?z("button",{type:"button",ref:w,className:`${K||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${I&&!K?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>V((e)=>!e),children:z("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):z("button",{type:"button",ref:w,className:`st-cp-tokbtn${I?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>V((e)=>!e),children:z("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),U&&B?o90.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(Q70,{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):r]})]}):!C?z("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):D(Q0,{children:[h,m.length?v(m):r]})}),document.body):null]})}function i90({label:J,tracks:X,editable:Q,onChange:Y}){let W=(K,U)=>{let V=X[K];Y(X.map((B,N)=>N===K?xU.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=xU.has(K.unit);return D("div",{className:"st-cp-gridtrack-row",children:[V?z(XG,{value:K.unit,ariaLabel:`${J} track ${U+1}`,options:j90.map((B)=>({value:B,label:B})),onChange:(B)=>W(U,B)}):z(HJ,{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:j90,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 J1={pending:0,waiters:[]};function Y70(J){J1.pending+=1;let X=()=>{if(J1.pending-=1,J1.pending===0)for(let Q of J1.waiters.splice(0))Q()};return J.then(X,X),J}function XD0(){return J1.pending===0?Promise.resolve():new Promise((J)=>J1.waiters.push(J))}function QD0({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,O0)=>{let w0={...t||{}};for(let[m0,t0]of Object.entries(O0))if(t0===null)delete w0[m0];else w0[m0]=t0;return w0},F=N(J.authored,V.a),M=N(J.customStyles,V.c),A=N(J.attrs,V.t),E=(t,O0)=>B((w0)=>({...w0,a:{...w0.a,[t]:O0}})),w=(t,O0)=>B((w0)=>({...w0,c:{...w0.c,[t]:O0}})),O=(t,O0)=>B((w0)=>({...w0,t:{...w0.t,[t]:O0}})),I=(X?.designRel||X?.designRoot||".design").replace(/^\/+|\/+$/g,""),T=J70(J.file,X),R=X70(X,I,T),$=(t)=>R.map((O0)=>({ds:O0.name,names:O0[t]||[],vals:O0.vals})).filter((O0)=>O0.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||V7(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,O0,w0){j((m0)=>({...m0,[w0]:"saving"}));try{let m0=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(O0)}),t0=await m0.json().catch(()=>({}));return j((l8)=>({...l8,[w0]:!m0.ok||!t0.ok?`err:${t0&&t0.error||`HTTP ${m0.status}`}`:"saved"})),m0.ok?t0:null}catch(m0){return j((t0)=>({...t0,[w0]:`err:${m0&&m0.message?m0.message:String(m0)}`})),null}}let r=p.useRef(Promise.resolve()),e=(t,O0,w0,m0,t0,l8,s8)=>{r.current=Y70(r.current.then(async()=>{let v8=await v(t,O0,w0);if(!v8?.ok)return;let Z9=Object.hasOwn(v8,"previous")?v8.previous:l8;if((Z9??null)===(s8??null))return;H0(m0,t0,Z9,s8)}))},s=(t,O0)=>{if(!Q||!J.id)return;Q({id:J.id,artboardId:J.artboardId??null,index:J.index??0,prop:t,value:O0})},H0=(t,O0,w0,m0)=>{Y?.({op:t,canvas:J.file,id:J.id,key:O0,before:w0==null||w0===""?null:w0,after:m0==null||m0===""?null:m0})},a=(t,O0)=>{let w0=(O0||"").trim();if(!K||!w0)return;let m0=F[t]??null;if(w0===(m0??"").trim())return;s(t,w0),E(t,w0),e("/_api/edit-css",{canvas:J.file,id:J.id,property:t,value:w0},t,"css",t,m0,w0)},z0=(t,O0)=>{let w0=(O0||"").trim(),m0=t.trim();if(!K||!m0||!w0)return;let t0=M[m0]??null;s(m0,w0),w(m0,w0),e("/_api/edit-css",{canvas:J.file,id:J.id,property:m0,value:w0},m0,"css",m0,t0,w0)},i=(t,O0)=>{let w0=(t||"").trim(),m0=(O0||"").trim();if(!K||!w0||!m0)return;let t0=A[w0]??null;O(w0,m0),e("/_api/edit-attr",{canvas:J.file,id:J.id,attr:w0,value:m0},`@${w0}`,"attr",w0,t0,m0)},q0=(t)=>{if(!K)return;let O0=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,O0,null)},Z0=(t)=>{if(!K)return;let O0=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,O0,null)},P0=(t)=>{if(!K)return;let O0=A[t]??null;O(t,null),e("/_api/edit-attr",{canvas:J.file,id:J.id,attr:t,reset:!0},`@${t}`,"attr",t,O0,null)},s0={display:J.parentDisplay,flexDirection:J.parentFlexDirection},e0=(t,O0)=>{if(!K)return;let w0=Math.round((t==="width"?J.bounds?.w:J.bounds?.h)||0),m0=ab(t,O0,s0,w0);for(let t0 of m0.reset)if(F[t0])q0(t0);for(let[t0,l8]of m0.set)a(t0,l8)},Y8=J.parentDisplay==="flex"||J.parentDisplay==="inline-flex",E8=(t)=>{let O0=rb(t,F,U,s0);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:O0,ariaLabel:`${t} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(w0)=>e0(t,w0)})})]},`mode-${t}`)},C8=["flex-start","center","flex-end"],t8=["flex-start","center","flex-end"],o0=["t","c","b"],C0=["l","c","r"],_0=()=>{let t=!(F["flex-direction"]||V7(U["flex-direction"])||"row").startsWith("column"),O0=Math.max(0,C8.indexOf(F["justify-content"]||V7(U["justify-content"])||"flex-start")),w0=F["align-items"]||V7(U["align-items"])||"stretch",m0=w0==="stretch"?1:Math.max(0,t8.indexOf(w0)),[t0,l8]=t?[O0,m0]:[m0,O0];return o0[l8]+C0[t0]},$0=(t)=>{let O0=o0.indexOf(t[0]),w0=C0.indexOf(t[1]),m0=!(F["flex-direction"]||V7(U["flex-direction"])||"row").startsWith("column"),[t0,l8]=m0?[w0,O0]:[O0,w0];a("justify-content",C8[t0]),a("align-items",t8[l8])},V8=(t)=>{if(!(t.metaKey||t.ctrlKey)||t.altKey)return;let O0=t.key.toLowerCase();if(O0==="z")t.preventDefault(),G?.(t.shiftKey?"redo":"undo");else if(O0==="y")t.preventDefault(),G?.("redo")},Q8=(t)=>{let O0=F[t];if(!O0)return"inherit";return/var\(\s*--/.test(O0)?"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 p8={bound:"token-bound",raw:"raw override",inherit:"inherited"},y8=(t)=>z("span",{className:`st-cp-prov st-cp-prov--${t}`,role:"img","aria-label":p8[t]}),D9=(t,O0)=>{let w0=O0??Q8(t),m0=C[t],t0=typeof m0==="string"&&m0.startsWith("err:")?m0.slice(4):"",l8=t0?" is-err":m0==="saved"?" is-saved":m0==="saving"?" is-saving":"",s8=!!F[t],v8=t0?`error: ${t0}`:s8?`${p8[w0]} · double-click to reset`:p8[w0];return z("button",{type:"button",className:`st-cp-prov st-cp-prov--${w0}${l8}${s8?" is-resettable":""}`,"aria-label":v8,title:v8,tabIndex:s8?0:-1,onDoubleClick:s8?()=>q0(t):void 0,onKeyDown:s8?(Z9)=>{if(Z9.key==="Backspace"||Z9.key==="Delete")Z9.preventDefault(),q0(t)}:void 0})},f0=(t,O0,w0,m0)=>{let t0=w0===void 0&&!F[t],l8=m0??t;return D("div",{className:`st-cp-row${t0?" is-unset":""}`,children:[D9(t,w0),z("label",{className:"st-cp-label",title:l8,children:l8}),z("div",{className:"st-cp-ctl",children:O0})]},t)},k8={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)=>{(k8[t]||[]).forEach((O0)=>{if(F[O0])q0(O0)})},L8=(t,O0)=>{let w0=(k8[t]||[]).some((m0)=>F[m0]);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((m0)=>({...m0,[t]:!m0[t]})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:f[t]?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${w0?"":" is-quiet"}`,"aria-label":`reset ${t} section to original`,title:`reset ${t}`,disabled:!w0,onClick:()=>A9(t),children:z(z7,{as:nZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${f[t]?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:O0})})]},t)},B0=(t,O0,w0,m0=!0)=>{let t0=`d:${t}`,l8=f[t0]===void 0?m0:f[t0],s8=O0.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":l8,onClick:()=>m((v8)=>({...v8,[t0]:!l8})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:l8?"▾":"▸"}),t]}),z("button",{type:"button",className:`st-cp-secreset${s8?"":" is-quiet"}`,"aria-label":`reset ${t} to original`,title:`reset ${t}`,disabled:!s8,onClick:()=>O0.forEach((v8)=>{if(F[v8])q0(v8)}),children:z(z7,{as:nZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${l8?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:w0})})]},t0)},J8=(t)=>z("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!h[t],"aria-label":h[t]?`${t} — fewer options`:`${t} — more options`,title:h[t]?"fewer":"more",onClick:()=>u((O0)=>({...O0,[t]:!O0[t]})),children:h[t]?"▴":"···"}),a0=(t,O0)=>D("select",{className:"st-cp-nsel","aria-label":t,value:O0.includes(F[t])?F[t]:"",onChange:(w0)=>a(t,w0.target.value),children:[z("option",{value:"",disabled:!0,children:V7(U[t])||"—"}),O0.map((w0)=>z("option",{value:w0,children:w0},w0))]}),e8=(t)=>$(t).flatMap((O0)=>(O0.names||[]).map((w0)=>({name:w0,value:O0.vals?.[w0]||""}))),T0=(t,O0)=>z(tw,{value:F[t]||V7(U[t])||O0[0].value,ariaLabel:t,options:O0,onChange:(w0)=>a(t,w0)}),n0=(t,O0,w0={})=>{let m0=J4(F[t]??""),t0=g90.has(t),l8=F[t]??"",s8=typeof l8==="string"&&/var\(\s*--/.test(l8),v8=t0?"":m0.unit&&m0.unit!=="auto"?m0.unit:"px",Z9=Number.parseFloat(J4(V7(U[t])??"").n)||0,h9=m0.n!==""&&m0.n!=null?Number.parseFloat(m0.n)||0:Z9,b9=OT[t];return z(sN,{value:s8?l8:h9,tokens:e8(O0),ariaLabel:t,min:w0.min??0,lead:b9?b9.node??b9.t:void 0,unitSlot:t0?null:z(rN,{units:h90,value:m0.unit||"px",ariaLabel:`${t} unit`,onChange:(K7)=>a(t,K7==="auto"?"auto":`${m0.n||"0"}${K7}`)}),onChange:(K7)=>a(t,typeof K7==="string"?K7:t0?`${K7}`:`${K7}${v8}`)})},x0=()=>{let t=(t0)=>Number.parseFloat(J4(F[t0]??F["border-radius"]??V7(U[t0])??V7(U["border-radius"])??"0").n)||0,O0={tl:t("border-top-left-radius"),tr:t("border-top-right-radius"),bl:t("border-bottom-left-radius"),br:t("border-bottom-right-radius")},w0=(t0)=>{if(t0.tl===t0.tr&&t0.tr===t0.bl&&t0.bl===t0.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((s8)=>{if(F[s8])q0(s8)}),a("border-radius",`${t0.tl}px`);else a("border-top-left-radius",`${t0.tl}px`),a("border-top-right-radius",`${t0.tr}px`),a("border-bottom-left-radius",`${t0.bl}px`),a("border-bottom-right-radius",`${t0.br}px`)},m0=OT["border-radius"];return z(Qm,{corners:O0,lead:m0?m0.node??m0.t:void 0,onCorners:w0})},g0=()=>D("div",{className:"st-cp-border",children:[j8("border-width",null,{fixedUnit:"px"}),D("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:x90.includes(F["border-style"])?F["border-style"]:"",onChange:(t)=>a("border-style",t.target.value),children:[z("option",{value:"",disabled:!0,children:"style"}),x90.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)=>a("border-color",t),label:"border colour"})]}),P8=()=>{let t=F.transform||V7(U.transform)||"",O0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(t),w0=((O0?Number.parseFloat(O0[1]):0)%360+360)%360,m0=(t0)=>{let l8=(t0%360+360)%360,s8=(F.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();a("transform",`${s8?`${s8} `:""}rotate(${l8}deg)`.trim())};return D("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[z(Jm,{value:w0,onChange:m0}),z(HJ,{value:w0,min:0,max:360,ariaLabel:"rotation",lead:z(z7,{as:nZ}),steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:m0})]})},A0=()=>{let t=F.filter||V7(U.filter)||"",O0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(t),w0=O0?Number.parseFloat(O0[1]):0;return z(HJ,{value:w0,min:0,ariaLabel:"filter blur",unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(t0)=>{let l8=(F.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();a("filter",t0>0?`${l8?`${l8} `:""}blur(${t0}px)`.trim():l8||"none")}})},W8=()=>{let t=F.opacity,O0=t!=null&&t!==""?Number.parseFloat(t):Number.parseFloat(V7(U.opacity))||1,w0=Math.round((Number.isNaN(O0)?1:O0)*100);return z(hX,{value:w0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(m0)=>s("opacity",String(m0/100)),onCommit:(m0)=>a("opacity",String(m0/100))},`opacity:${t??""}`)},_8=()=>{let t=Number.parseInt(F["font-weight"]||V7(U["font-weight"])||"400",10)>=600,O0=(F["font-style"]||V7(U["font-style"]))==="italic",w0=/underline/.test(F["text-decoration"]||V7(U["text-decoration"])||"");return z(tg,{value:{b:t,i:O0,u:w0},ariaLabel:"text style",options:[{value:"b",node:z(z7,{as:nV}),label:"Bold"},{value:"i",node:z(z7,{as:eV}),label:"Italic"},{value:"u",node:z(z7,{as:U3}),label:"Underline"}],onToggle:(m0)=>{if(m0==="b")a("font-weight",t?"400":"700");else if(m0==="i")a("font-style",O0?"normal":"italic");else a("text-decoration",w0?"none":"underline")}})},U0=[{value:"row",node:z(z7,{as:cW}),label:"Row"},{value:"column",node:z(z7,{as:iW}),label:"Column"}],i0=[{value:"flex-start",node:z(z7,{as:lV}),label:"Start"},{value:"center",node:z(z7,{as:uV}),label:"Center"},{value:"flex-end",node:z(z7,{as:pV}),label:"End"},{value:"space-between",node:z(z7,{as:PK}),label:"Space between"}],I8=[{value:"flex-start",node:z(z7,{as:iV}),label:"Start"},{value:"center",node:z(z7,{as:dV}),label:"Center"},{value:"flex-end",node:z(z7,{as:cV}),label:"End"},{value:"stretch",node:z(z7,{as:z3}),label:"Stretch"}],Y9=[{value:"left",node:z(z7,{as:d5}),label:"Left"},{value:"center",node:z(z7,{as:rW}),label:"Center"},{value:"right",node:z(z7,{as:aW}),label:"Right"},{value:"justify",node:z(z7,{as:sW}),label:"Justify"}],d0=[{value:"visible",node:z(z7,{as:oZ}),label:"Visible"},{value:"hidden",node:z(z7,{as:rZ}),label:"Hidden"},{value:"scroll",node:z(z7,{as:G3}),label:"Scroll"}],m7=(t,O0)=>{let w0=$(O0);return w0.length?z(ML,{kind:"value",groups:w0,current:F[t],activeDs:T,onPick:(m0)=>a(t,m0),label:`${t} design token`}):null},_9=(t)=>{let O0=t.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===O0)O0.select()})},o7=(t,O0)=>{if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return!1;t.preventDefault();let w0=t.shiftKey?10:1,m0=t.key==="ArrowUp"?1:-1,t0=(Number.parseFloat(t.currentTarget.value)||0)+m0*w0;return t.currentTarget.value=String(t0),O0(t0),!0},T8=(t)=>z("input",{className:"st-cp-fin","aria-label":t,defaultValue:F[t]??"",placeholder:V7(U[t])||"—",onFocus:_9,onKeyDown:(O0)=>{if(O0.key==="Enter")O0.currentTarget.blur()},onBlur:(O0)=>a(t,O0.currentTarget.value)},`${t}:${F[t]??""}`),j8=(t,O0,w0={})=>{let m0=J4(F[t]??""),t0=g90.has(t),l8=t0?"":w0.fixedUnit||(m0.unit&&m0.unit!=="auto"?m0.unit:"px"),s8=OT[t],v8=Number.parseFloat(J4(V7(U[t])??"").n)||0,Z9=m0.n!==""&&m0.n!=null?Number.parseFloat(m0.n)||0:v8;return D(Q0,{children:[z(HJ,{value:Z9,min:w0.min??0,step:1,ariaLabel:t,lead:s8?s8.node??s8.t:void 0,onCommit:(h9)=>a(t,t0?`${h9}`:`${h9}${l8}`),unitSlot:t0||w0.fixedUnit?null:z(rN,{units:h90,value:m0.unit||"px",ariaLabel:`${t} unit`,onChange:(h9)=>a(t,h9==="auto"?"auto":`${m0.n||"0"}${h9}`)})},`${t}:${F[t]??""}`),m7(t,O0)]})},a8=(t)=>{let O0=U[t]||F[t]||"",w0=F[t]??"",m0=typeof w0==="string"&&/var\(\s*--/.test(w0),t0=m0?w0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):w0;return z(q3,{swatch:z(ML,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:$("color"),current:F[t],activeDs:T,swatchBg:O0,seedHex:wL(U[t]||F[t])||"#000000",onPick:(l8)=>a(t,l8),label:`${t} colour`}),displayValue:t0,bound:m0,ariaLabel:t,onValue:(l8)=>a(t,l8)})},I0=(t,O0)=>{let w0=null,m0=O0.unitless?"":"px",t0=(v8)=>O0.unitless?`${v8}`:`${v8}${m0}`,l8=(v8,Z9,h9)=>{for(let b9 of Z9??[t])h9(b9,t0(v8))},s8=sw({getBase:()=>w0?.value??"0",min:O0.min??0,step:1,sides:O0.sides,onInput:(v8,Z9)=>{if(w0)w0.value=String(v8);if(Z9){let h9=w0?.closest(".st-cp-box");for(let b9 of Z9){if(b9===t)continue;let K7=h9?.querySelector(`.st-cp-boxv[aria-label="${b9}"]`);if(K7)K7.value=String(v8)}}l8(v8,Z9,s)},onCommit:(v8,Z9)=>l8(v8,Z9,a)});return{onPointerDown:(v8)=>{w0=v8.currentTarget,s8(v8)}}},X8=(t,O0)=>{let w0=F[t],m0=w0!=null&&w0!==""?J4(w0).n||w0:J4(V7(U[t])??"").n||"0",t0=!w0||w0==="0"||w0==="0px"||w0==="auto",l8=t.split("-").pop(),s8=l8==="top"||l8==="bottom"?[`${O0}-top`,`${O0}-bottom`]:[`${O0}-left`,`${O0}-right`],v8=[`${O0}-top`,`${O0}-right`,`${O0}-bottom`,`${O0}-left`];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${O0[0]}${t.split("-").pop()[0]}${t0?" is-zero":""}`,"aria-label":t,defaultValue:m0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...I0(t,{sides:{pair:s8,all:v8}}),onFocus:_9,onKeyDown:(Z9)=>{if(o7(Z9,(h9)=>a(t,`${h9}px`)))return;if(Z9.key==="Enter")Z9.currentTarget.blur()},onBlur:(Z9)=>{let h9=Z9.currentTarget.value.trim();if(!h9)return;let b9=/[a-z%]/i.test(h9)?h9:`${h9}px`;a(t,b9)}},`${t}:${w0??""}`)},$8=(t)=>{let O0=F[t],w0=O0!=null&&O0!==""&&O0!=="auto"?J4(O0).n||O0:J4(V7(U[t])??"").n||"",m0=!O0||O0==="auto"||O0==="0"||O0==="0px",t0=t==="top"||t==="bottom"?["top","bottom"]:["left","right"],l8=["top","right","bottom","left"];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${t[0]}${m0?" is-zero":""}`,"aria-label":t,defaultValue:w0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...I0(t,{sides:{pair:t0,all:l8},min:-1/0}),onFocus:_9,onKeyDown:(s8)=>{if(o7(s8,(v8)=>a(t,`${v8}px`)))return;if(s8.key==="Enter")s8.currentTarget.blur()},onBlur:(s8)=>{let v8=s8.currentTarget.value.trim();if(!v8)return;let Z9=/[a-z%]/i.test(v8)?v8:`${v8}px`;a(t,Z9)}},`${t}:${O0??""}`)},W9=Object.entries(M),X7=Object.entries(A),c9=()=>{let t=(J.tag||"").toLowerCase(),w0=t==="img"||t==="video"||t==="picture"||t==="svg"||t==="canvas"||!!F["object-fit"]||!!F["object-position"]||!!F["aspect-ratio"],m0=(t==="img"||t==="video")&&!!J.attrs?.src&&!!W;return{showMedia:w0,canReplace:m0}},y9=(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…"})}),f0("object-fit",a0("object-fit",eL0)),f0("object-position",T8("object-position")),f0("aspect-ratio",D("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:d90.includes(F["aspect-ratio"])?F["aspect-ratio"]:"",onChange:(O0)=>{let w0=O0.target.value;if(a("aspect-ratio",w0),w0&&w0!=="auto"&&F.height)q0("height")},children:[z("option",{value:"",disabled:!0,children:V7(U["aspect-ratio"])||"—"}),d90.map((O0)=>z("option",{value:O0,children:O0},O0))]}))]});return D("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:V8,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(tw,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:z(z7,{as:dW,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:z(z7,{as:tW,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||V7(U.display)||"").trim();return t==="flex"||t==="inline-flex"?D(Q0,{children:[f0("flex-direction",T0("flex-direction",U0),void 0,"Direction"),f0("align-items",z(eg,{value:_0(),onChange:$0,ariaLabel:"auto-layout alignment"}),Q8("align-items"),"Alignment"),f0("gap",n0("gap","space"),void 0,"Gap"),D("div",{className:"st-cp-modes",children:[E8("width"),E8("height")]}),D("div",{className:"st-cp-box","aria-label":"padding",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[y8(Q8("padding-top")),"padding"]}),X8("padding-top","padding"),X8("padding-right","padding"),X8("padding-bottom","padding"),X8("padding-left","padding")]}),z("div",{className:"st-cp-clustermore-row",children:J8("Auto layout")}),h["Auto layout"]?f0("flex-wrap",z(nQ,{checked:/^wrap/.test(F["flex-wrap"]||V7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(w0)=>a("flex-wrap",w0?"wrap":"nowrap")}),Q8("flex-wrap"),"Wrap"):null]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>a("display","flex"),children:"+ Auto layout (flex)"})})()),B0("Size",["width","height","min-width","max-width","min-height","max-height"],D(Q0,{children:[f0("width",j8("width"),void 0,"Width"),f0("height",j8("height"),void 0,"Height"),z("div",{className:"st-cp-clustermore-row",children:J8("Size")}),h.Size?D(Q0,{children:[f0("min-width",j8("min-width"),void 0,"Min width"),f0("max-width",j8("max-width"),void 0,"Max width"),f0("min-height",j8("min-height"),void 0,"Min height"),f0("max-height",j8("max-height"),void 0,"Max height")]}):null]})),B0("Position",["position","top","right","bottom","left","z-index"],D(Q0,{children:[f0("position",a0("position",m90),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(Q8("top")),"inset"]}),$8("top"),$8("right"),$8("bottom"),$8("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||V7(U.position)||"static"})]}),(F.position||V7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,z("div",{className:"st-cp-clustermore-row",children:J8("Position")}),h.Position?f0("z-index",j8("z-index"),void 0,"Layer order"):null]}),!1),B0("Fill",["background-color"],f0("background-color",a8("background-color"),void 0,"Fill")),B0("Stroke",["border-width","border-style","border-color"],f0("border",g0(),Q8("border-width"),"Stroke")),B0("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],f0("border-radius",x0(),Q8("border-radius"),"Corner radius")),B0("Effects",["box-shadow","filter","mix-blend-mode"],D(Q0,{children:[f0("box-shadow",m7("box-shadow","shadow")||T8("box-shadow"),void 0,"Shadow"),f0("filter",A0(),Q8("filter"),"Blur"),f0("mix-blend-mode",a0("mix-blend-mode",l90),void 0,"Blend")]})),B0("Opacity",["opacity"],f0("opacity",W8(),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:[f0("font-family",a0("font-family",f90),void 0,"Font"),f0("color",a8("color"),void 0,"Color"),f0("font-size",n0("font-size","type"),void 0,"Size"),f0("font-weight",a0("font-weight",v90),void 0,"Weight"),f0("line-height",j8("line-height","lh"),void 0,"Line height"),f0("text-align",T0("text-align",Y9),void 0,"Align"),z("div",{className:"st-cp-clustermore-row",children:J8("Text")}),h.Text?D(Q0,{children:[f0("letter-spacing",j8("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),f0("font-style",a0("font-style",tL0),void 0,"Style"),f0("text-transform",a0("text-transform",u90),void 0,"Case"),f0("white-space",a0("white-space",p90),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(Q8("margin-top")),"margin"]}),X8("margin-top","margin"),X8("margin-right","margin"),X8("margin-bottom","margin"),X8("margin-left","margin")]})),(()=>{let{showMedia:t,canReplace:O0}=c9();return t?B0("Media",["object-fit","object-position","aspect-ratio"],y9(O0)):null})()]}):D(Q0,{children:[L8("Layout",(()=>{let t=(F.display||V7(U.display)||"").trim(),O0=t==="flex"||t==="inline-flex",w0=t==="grid"||t==="inline-grid";return D(Q0,{children:[f0("display",a0("display",aL0)),O0?D(Q0,{children:[f0("flex-direction",T0("flex-direction",U0)),f0("flex-wrap",z(nQ,{checked:/^wrap/.test(F["flex-wrap"]||V7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(m0)=>a("flex-wrap",m0?"wrap":"nowrap")}),Q8("flex-wrap"))]}):null,O0||w0?D(Q0,{children:[f0("align-items",T0("align-items",I8)),f0("justify-content",T0("justify-content",i0)),f0("gap",n0("gap","space"))]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>a("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let t=(F.display||V7(U.display)||"").trim();if(!(t==="grid"||t==="inline-grid"))return null;let w0=F["grid-template-columns"]||"",m0=F["grid-template-rows"]||"",t0=jO(w0),l8=jO(m0),s8=t0.length>0||!w0.trim(),v8=l8.length>0||!m0.trim();return L8("Grid",D(Q0,{children:[s8?z(i90,{label:"Columns",tracks:t0,editable:K,onChange:(Z9)=>a("grid-template-columns",vO(Z9))}):D("div",{className:"st-cp-note",children:["Columns use ",z("code",{children:w0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),v8?z(i90,{label:"Rows",tracks:l8,editable:K,onChange:(Z9)=>a("grid-template-rows",vO(Z9))}):D("div",{className:"st-cp-note",children:["Rows use ",z("code",{children:m0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),L8("Position",D(Q0,{children:[f0("position",a0("position",m90)),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(Q8("top")),"inset"]}),$8("top"),$8("right"),$8("bottom"),$8("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||V7(U.position)||"static"})]}),(F.position||V7(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,f0("z-index",j8("z-index"))]})),(J.parentDisplay==="grid"||J.parentDisplay==="inline-grid")&&L8("Grid item",D(Q0,{children:[D("div",{className:"st-cp-note",children:["Manual cell placement — ",z("code",{children:"start / end"})," or ",z("code",{children:"start / span N"}),"."]}),f0("grid-column",T8("grid-column")),f0("grid-row",T8("grid-row"))]})),L8("Typography",D(Q0,{children:[f0("font-family",a0("font-family",f90)),f0("color",a8("color")),f0("font-size",n0("font-size","type")),f0("font-weight",a0("font-weight",v90)),f0("line-height",j8("line-height","lh")),f0("letter-spacing",j8("letter-spacing",null,{min:-1/0})),f0("text-align",T0("text-align",Y9)),f0("font-style",_8(),Q8("font-style")),f0("text-transform",a0("text-transform",u90)),f0("white-space",a0("white-space",p90))]})),L8("Spacing",z(Q0,{children:D("div",{className:"st-cp-box","aria-label":"margin and padding",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[y8(Q8("margin-top")),"margin"]}),X8("margin-top","margin"),X8("margin-right","margin"),X8("margin-bottom","margin"),X8("margin-left","margin"),D("div",{className:"st-cp-boxpad",children:[D("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[y8(Q8("padding-top")),"padding"]}),X8("padding-top","padding"),X8("padding-right","padding"),X8("padding-bottom","padding"),X8("padding-left","padding"),D("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(F.width)||J.bounds?.w||0)," × ",Math.round(Number.parseFloat(F.height)||J.bounds?.h||0)]})]})]})})),L8("Size",D(Q0,{children:[D("div",{className:"st-cp-modes",children:[E8("width"),E8("height")]}),f0("width",j8("width")),f0("height",j8("height")),f0("min-width",j8("min-width")),f0("max-width",j8("max-width")),f0("min-height",j8("min-height")),f0("max-height",j8("max-height")),f0("overflow",T0("overflow",d0)),Y8?D(Q0,{children:[z("div",{className:"st-cp-subhd",children:"In flex parent"}),f0("align-self",a0("align-self",sL0)),f0("flex-grow",j8("flex-grow",null,{unitless:!0})),f0("flex-shrink",j8("flex-shrink",null,{unitless:!0})),f0("flex-basis",j8("flex-basis"))]}):null]})),(()=>{let{showMedia:t,canReplace:O0}=c9();return t?L8("Media",y9(O0)):null})(),L8("Appearance",D(Q0,{children:[f0("background-color",a8("background-color")),f0("border-radius",x0(),Q8("border-radius")),f0("border",g0(),Q8("border-width")),f0("box-shadow",m7("box-shadow","shadow")||T8("box-shadow")),f0("filter",A0(),Q8("filter")),f0("mix-blend-mode",a0("mix-blend-mode",l90)),f0("opacity",W8()),f0("rotation",P8(),Q8("transform")),f0("transform",T8("transform")),f0("transform-origin",T8("transform-origin"))]})),(()=>{let t=Object.entries(C).find(([,O0])=>typeof O0==="string"&&O0.startsWith("err:"));return t?D("div",{className:"st-cp-save is-err",role:"status",children:[z(T9,{name:"x",size:12}),t[0],": ",t[1].slice(4)]}):null})(),L8("Advanced",D("div",{className:"st-cp-advbody",children:[W9.length?D(Q0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),W9.map(([t,O0])=>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:O0,"aria-label":`${t} value`,onKeyDown:(w0)=>{if(w0.key==="Enter")w0.currentTarget.blur()},onBlur:(w0)=>z0(t,w0.currentTarget.value)},`cs:${t}:${O0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>Z0(t),children:z(T9,{name:"x",size:11})})]},`cs:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add CSS property"}),z(YD0,{commit:z0}),z("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),X7.length?D(Q0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),X7.map(([t,O0])=>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:O0,"aria-label":`${t} value`,onKeyDown:(w0)=>{if(w0.key==="Enter")w0.currentTarget.blur()},onBlur:(w0)=>i(t,w0.currentTarget.value)},`at:${t}:${O0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${t}`,title:"remove",onClick:()=>P0(t),children:z(T9,{name:"x",size:11})})]},`at:${t}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),z(WD0,{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 YD0({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 WD0({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 GD0={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function ZD0(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 HD0=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function W70({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 r=f.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!r||r===(J.dcElement??""))return;E?.(J,r)},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?(r)=>B(r,J,w):void 0,onKeyDown:(r)=>{if(r.key==="Enter"||r.key===" ")if(r.preventDefault(),T)O&&Z(w);else H(J);else if(r.key==="F2"&&E&&!T)r.preventDefault(),m(J.dcElement||J.label||""),j(!0)},children:[O?z("button",{type:"button",className:"st-layer-caret","aria-label":I?"Expand":"Collapse",onClick:(r)=>{r.stopPropagation(),Z(w)},children:I?"▸":"▾"}):z("span",{className:"st-layer-caret","aria-hidden":"true"}),R?z("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:R.root?"◆":"◇"}):z(T9,{name:GD0[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:(r)=>r.target.select(),onChange:(r)=>m(r.target.value),onClick:(r)=>r.stopPropagation(),onPointerDown:(r)=>r.stopPropagation(),onBlur:h,onKeyDown:(r)=>{if(r.stopPropagation(),r.key==="Enter")h();else if(r.key==="Escape")j(!1)}}):z("span",{className:"st-layer-label",onDoubleClick:E&&!T?(r)=>{r.stopPropagation(),m(J.dcElement||J.label||""),j(!0)}:void 0,children:J.label}),z("span",{className:"st-layer-type",children:R?R.component:J.type}),A&&!T?z("button",{type:"button",className:"st-layer-lock","aria-label":$?`Unlock ${J.label}`:`Lock ${J.label}`,"aria-pressed":$,title:$?"Unlock":"Lock",onClick:(r)=>{r.stopPropagation(),A(w)},children:z(T9,{name:$?"lock":"unlock",size:12})}):null,U&&!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:(r)=>{r.stopPropagation(),U(J)},children:z(T9,{name:o?"eye-off":"eye",size:13})}):null]}),O&&!I?J.children.map((r,e)=>z(W70,{node:r,depth:X+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:V,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:M,onToggleLock:A,onRename:E},`${r.id}:${r.index}`)):null]})}function zD0({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 G70(J){if(J.artboardId)return J.artboardId;let X=/^\[data-dc-screen="([^"]+)"\]$/.exec(J.selector||"");return X?X[1]:null}var KD0=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],UD0=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function VD0({el:J,cfg:X,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let K=G70(J),U=(X?.designRel||X?.designRoot||".design").replace(/^\/+|\/+$/g,""),V=J70(J.file,X),B=X70(X,U,V),N=(v)=>B.map((r)=>({ds:r.name,names:r[v]||[],vals:r.vals})).filter((r)=>r.names.length),F=(v)=>N(v).flatMap((r)=>(r.names||[]).map((e)=>({name:e,value:r.vals?.[e]||""}))),M=(v)=>{let r=/^var\(\s*(--[\w-]+)\s*\)$/.exec(v||"");if(!r)return v||"";for(let e of B){let s=e.vals?.[r[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,r)=>{if(!K)return;let e=Number.isFinite(v)&&v>0?Math.round(v):void 0,s=Number.isFinite(r)&&r>0?Math.round(r):void 0;if(e==null&&s==null)return;Q?.(K,e,s)},O=Object.entries(R5).find(([,v])=>v.width===A&&v.height===E)?.[0],I=Object.entries(R5).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 r=null;if(v==="print"&&!m){let e={paper:"a4"};try{let s=GB(e);if(s)r={defaults:e,widthPx:s.widthPx,heightPx:s.heightPx}}catch{}}if(G?.(K,v==="digital"?null:v,r),v==="web"&&T)Y?.(K,!1,void 0)},o=(v)=>{if(!K)return;let r={paper:"a4",...m,...v},e;try{e=GB(r)}catch{return}Q?.(K,e.widthPx,e.heightPx),Z?.(K,r)},x=(v,r)=>{if(!K)return;let e=Number.isFinite(r)?r:E,s=v&&Number.isFinite(e)?Math.round(e):void 0;Y?.(K,v,s)},h=(v)=>{let r=ib(T,v);if(r.kind==="resize")w(null,r.height);else if(r.kind==="promote-to-fixed")x(!0,r.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(HJ,{value:A??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(v)=>w(v,null)}),z(HJ,{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…"}),WB.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 r=R5[v.currentTarget.value];if(r)w(r.width,null)},children:[z("option",{value:"",disabled:!0,children:I?`${R5[I].label} — ≤ ${R5[I].width}px`:"Breakpoint…"}),Object.entries(R5).map(([v,r])=>D("option",{value:v,children:[r.label," — ≤ ",r.width,"px breakpoint"]},v))]}):D("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:O??"",onChange:(v)=>{let r=R5[v.currentTarget.value];if(r)w(r.width,r.height)},children:[z("option",{value:"",disabled:!0,children:O?R5[O].label:"Preset size…"}),Object.entries(R5).map(([v,r])=>D("option",{value:v,children:[r.label," — ",r.width,"×",r.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(XG,{value:f,ariaLabel:"artboard kind",options:UD0.map(([v,r])=>({value:v,label:r})),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 r=R5[v.currentTarget.value];if(r)H(K,r.width);v.currentTarget.value=""},children:[z("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(R5).map(([v,r])=>D("option",{value:v,children:[r.label," — ",r.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(HJ,{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),r=/var\(\s*--/.test(R),e=r?R.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):R;return z(q3,{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:r,ariaLabel:"artboard background",onValue:(s)=>u({background:(s||"").trim()||null})})})(),z(XG,{value:C,ariaLabel:"artboard body layout",options:KD0.map(([v,r])=>({value:v,label:r})),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 wT=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,qD0=new RegExp(wT.source,"gi");function BD0(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(qD0)||[])],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=wT.exec(`${J.attrs?.src||""} ${X}`);return Y?Y[0]:null}function ND0({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:r,onPhotoUndoRedo:e,layersOnly:s=!1,hideLayersTab:H0=!1,cpMode:a,onSetCpMode:z0}){let[i,q0]=p.useState("inspect"),Z0=s?"layers":f??i,P0=(x0)=>{q0(x0),m?.(x0)},[s0,e0]=p.useState(()=>new Set),[Y8,E8]=p.useState(()=>new Map);p.useEffect(()=>{let x0=Array.isArray(X)?X[0]:X,g0=x0?.id;if(!g0||!Y?.nodes)return;let P8=x0.index,A0=null,W8=[];if(function _8(U0,i0){for(let I8 of U0||[]){let Y9=`${I8.id}:${I8.index}`;if(!I8.synthetic&&I8.id===g0&&(P8==null||I8.index===P8))return A0=Y9,W8.push(...i0),!0;if(I8.children&&I8.children.length&&_8(I8.children,[...i0,Y9]))return!0}return!1}(Y.nodes,[]),!A0)return;if(W8.length)e0((_8)=>{let U0=!1,i0=new Set(_8);for(let I8 of W8)if(i0.delete(I8))U0=!0;return U0?i0:_8});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${A0}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[X,Y]);let C8=(x0)=>{let g0=`${x0.id}:${x0.index}`;return Y8.has(g0)?Y8.get(g0):!!x0.hidden},[t8,o0]=p.useState(null),[C0,_0]=p.useState(""),$0=(x0,g0)=>{if(!K||!x0?.id)return;Y70(fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:K,id:x0.id,attr:"data-dc-element",value:g0})}).then((P8)=>P8.json().catch(()=>({}))).then((P8)=>{if(!P8.ok)return;A?.({op:"attr",canvas:K,id:x0.id,key:"data-dc-element",before:x0.dcElement??null,after:g0})}).catch(()=>{}))},V8=B?(x0,g0,P8)=>{if(N?.current)return;if(x0?.synthetic||g0?.synthetic)return;let A0=P8==="before"?`before ${g0.label}`:P8==="after"?`after ${g0.label}`:`into ${g0.label}`;_0(`Moved ${x0.label} ${A0}`),B(x0.id,g0.id,P8,{idIndex:x0.index,refIndex:g0.index})}:void 0,Q8=()=>{let x0=[];return function g0(P8,A0,W8){(P8||[]).forEach((_8,U0)=>{if(x0.push({node:_8,depth:A0,parentNode:W8,siblings:P8,pos:U0}),_8.children&&_8.children.length&&!s0.has(`${_8.id}:${_8.index}`))g0(_8.children,A0+1,_8)})}(Y?.nodes,0,null),x0},p8=(x0)=>{if(x0.key!=="ArrowUp"&&x0.key!=="ArrowDown")return;if(!L8)return;let g0=Q8(),P8=g0.findIndex((U0)=>U0.node.id===L8.id&&U0.node.index===L8.index);if(P8<0)return;let A0=x0.key==="ArrowDown"?1:-1,W8=g0[P8];if(!x0.altKey){let U0=g0[P8+A0];if(U0)x0.preventDefault(),U?.(U0.node);return}if(!V8||!Array.isArray(W8.siblings))return;x0.preventDefault();let _8=(U0)=>U0&&U0.children&&U0.children.length&&!s0.has(`${U0.id}:${U0.index}`);if(!x0.shiftKey){if(A0<0&&W8.pos>0)V8(W8.node,W8.siblings[W8.pos-1],"before");else if(A0>0&&W8.pos<W8.siblings.length-1)V8(W8.node,W8.siblings[W8.pos+1],"after");return}if(A0>0){let U0=W8.siblings[W8.pos+1];if(U0)V8(W8.node,U0,_8(U0)?"inside-start":"after");else if(W8.parentNode)V8(W8.node,W8.parentNode,"after")}else{let U0=W8.siblings[W8.pos-1];if(U0)V8(W8.node,U0,_8(U0)?"inside-end":"before");else if(W8.parentNode)V8(W8.node,W8.parentNode,"before")}},y8=p.useRef(null),D9=p.useRef(null),f0=(x0,g0,P8)=>{if(!V8||x0.button!==0||x0.metaKey||x0.ctrlKey||x0.shiftKey||x0.altKey)return;if(N?.current)return;let{clientX:A0,clientY:W8}=x0,_8=new Set([P8]);(function a8(I0){(I0.children||[]).forEach((X8)=>{_8.add(`${X8.id}:${X8.index}`),a8(X8)})})(g0);let U0=14,i0=6,I8=[];(function a8(I0,X8){(I0||[]).forEach(($8)=>{let W9=`${$8.id}:${$8.index}`;if(I8.push({node:$8,key:W9,id:$8.id,depth:X8,tag:$8.tag}),$8.children&&$8.children.length&&!s0.has(W9))a8($8.children,X8+1)})})(Y?.nodes,0);let Y9=new Map(I8.map((a8)=>[a8.key,a8])),d0=!1,m7=(a8)=>{if(!d0){if(Math.hypot(a8.clientX-A0,a8.clientY-W8)<4)return;d0=!0}let I0=a8.clientX-A0,X8=a8.clientY-W8,$8=null,W9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((c9)=>({rect:c9.getBoundingClientRect(),it:Y9.get(c9.getAttribute("data-layer-key"))})).filter((c9)=>c9.it&&c9.it.key!==P8);if(W9.length){let c9=W9[0].rect.left,y9=W9[0].rect.right,t=W9.length;for(let b9=0;b9<W9.length;b9++)if(a8.clientY<W9[b9].rect.top+W9[b9].rect.height/2){t=b9;break}let O0=W9[t-1]?.it||null,w0=W9[t]?.it||null,m0=Math.round((a8.clientX-c9-i0)/U0),t0=O0?O0.depth+(HD0.has(O0.tag)?0:1):0,l8=w0?w0.depth:0,s8=Math.max(l8,Math.min(m0,t0)),v8=null,Z9="before",h9=0;if(!O0){if(w0)v8=w0,Z9="before",h9=w0.depth}else if(s8>O0.depth)v8=O0,Z9="inside-start",h9=O0.depth+1;else if(s8===O0.depth)v8=O0,Z9="after",h9=O0.depth;else{for(let b9=t-1;b9>=0;b9--)if(W9[b9].it.depth===s8){v8=W9[b9].it;break}if(!v8)v8=O0;Z9="after",h9=s8}if(v8&&v8.key!==P8&&!_8.has(v8.key)){let b9=O0?W9[t-1].rect.bottom:W9[0].rect.top,K7=c9+i0+h9*U0;$8={refId:v8.id,position:Z9,node:v8.node,y:b9,left:K7,w:Math.max(24,y9-K7)}}}let X7={key:P8,node:g0,dx:I0,dy:X8,target:$8};y8.current=X7,o0(X7)},_9=()=>{window.removeEventListener("pointermove",m7),window.removeEventListener("pointerup",T8),window.removeEventListener("keydown",j8,!0)},o7=()=>{let a8=(I0)=>{I0.preventDefault(),I0.stopImmediatePropagation(),document.removeEventListener("click",a8,!0)};document.addEventListener("click",a8,!0),setTimeout(()=>document.removeEventListener("click",a8,!0),300)},T8=()=>{_9();let a8=y8.current;if(y8.current=null,o0(null),d0&&a8?.target)o7(),V8(a8.node,a8.target.node,a8.target.position)},j8=(a8)=>{if(a8.key!=="Escape")return;if(a8.preventDefault(),a8.stopImmediatePropagation(),_9(),y8.current=null,o0(null),d0)o7()};window.addEventListener("pointermove",m7),window.addEventListener("pointerup",T8),window.addEventListener("keydown",j8,!0)},k8=(x0)=>e0((g0)=>{let P8=new Set(g0);if(P8.has(x0))P8.delete(x0);else P8.add(x0);return P8}),A9=(x0)=>{let g0=`${x0.id}:${x0.index}`,P8=C8(x0),A0=!P8;if(E8((W8)=>new Map(W8).set(g0,A0)),M?.({id:x0.id,artboardId:Y?.artboardId??null,index:x0.index,prop:"display",value:A0?"none":null}),!K||!x0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(A0?{canvas:K,id:x0.id,property:"display",value:"none"}:{canvas:K,id:x0.id,property:"display",reset:!0})}).catch(()=>{}),A?.({op:"css",canvas:K,id:x0.id,key:"display",before:P8?"none":null,after:A0?"none":null})},L8=Array.isArray(X)?X[0]:X,B0=x?{asset:x.asset,kind:"annotation-image"}:(()=>{let x0=BD0(L8);return x0?{asset:x0,kind:"artboard-img"}:null})(),J8=B0?.kind==="annotation-image",a0=(x0)=>{if(!(x0.metaKey||x0.ctrlKey)||x0.altKey)return;let g0=x0.key.toLowerCase();if(g0==="z")x0.preventDefault(),e?.(x0.shiftKey?"redo":"undo");else if(g0==="y")x0.preventDefault(),e?.("redo")},e8=J8?"photo":Z0==="photo"&&!B0?"css":Z0,T0=(x0,g0,P8)=>D("button",{type:"button",className:"st-rp-tab"+(e8===x0?" is-active":""),onClick:()=>P0(x0),children:[z(T9,{name:P8,size:14}),g0]}),n0=L8?.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:[J8?T0("photo","Photo","image"):D(Q0,{children:[T0("inspect","Inspect","sliders"),!H0&&T0("layers","Layers","layers"),T0("css","CSS","code"),B0?T0("photo","Photo","image"):null]}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:Q,children:z(T9,{name:"x",size:14})})]}),L8?.id&&!(Array.isArray(X)&&X.length>1)&&j?D("div",{className:`st-scope st-scope--${j.scope}`,title:j.scope==="shared"?`Editing this element's style changes ${j.affects} place${j.affects===1?"":"s"}${j.componentName?` (component ${j.componentName})`:""}. Move/resize a whole instance to keep it local.`:"This edit affects only this element.",children:[z("span",{className:"st-scope-dot","aria-hidden":"true"}),j.scope==="shared"?`Shared${j.componentName?` · ${j.componentName}`:""} · edits ${j.affects} place${j.affects===1?"":"s"}`:"Local · this element only",j.scope==="shared"&&H?z("button",{type:"button",className:"st-scope-detach",title:"Clone this component for this instance only — edits stop affecting the other places",onClick:()=>H(L8.id,L8.index),children:"Detach"}):null]}):null,z("div",{className:"st-rp-body",children:e8==="photo"&&B0?z("div",{onKeyDown:a0,children:z(km,{asset:B0.asset,ColorPicker:Q70,StIcon:T9,onEdit:(x0)=>u?.(B0.asset,x0),onRemoveBackground:v,onRecordEdit:(x0,g0)=>r?.(B0.asset,x0,g0)},`${B0.asset}:${h??0}`)}):!L8&&!(e8==="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."]})}):L8&&e8==="inspect"?D(Q0,{children:[z("div",{className:"st-rp-hd",children:L8.selector||L8.tag||"element"}),D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Pos"}),D("div",{className:"st-insp-fields",children:[D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"X"}),z("input",{value:n0?Math.round(n0.x):"—",readOnly:!0,"aria-label":"x position"})]}),D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"Y"}),z("input",{value:n0?Math.round(n0.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:n0?Math.round(n0.w):"—",readOnly:!0,"aria-label":"width"})]}),D("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"H"}),z("input",{value:n0?Math.round(n0.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Tag"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:L8.tag||"—"})})]}),L8.classes?D("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Class"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:L8.classes})})]}):null,z(zD0,{el:L8})]}):e8==="layers"?D(Q0,{children:[D("div",{className:"st-rp-hd",children:["Layers",Y?.nodes?.length?"":" · ancestry"]}),Y?.nodes?.length?D(Q0,{children:[V8?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:D9,onKeyDown:p8,children:Y.nodes.map((x0,g0)=>z(W70,{node:x0,depth:0,selectedId:L8?.id,selectedIndex:L8?.index,collapsed:s0,hiddenOverride:Y8,onToggle:k8,onSelect:(P8)=>{U?.(P8),D9.current?.focus()},onHover:(P8)=>V?.(P8),onToggleVisibility:A9,onReorder:V8,onRowPointerDown:f0,dragState:t8,componentMap:W,lockedKeys:G,onToggleLock:Z,onRename:$0},`${x0.id}:${x0.index}`))}),t8?.target?z("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:t8.target.left,top:t8.target.y-1,width:t8.target.w}}):null,z("div",{className:"sr-only",role:"status","aria-live":"polite",children:C0})]}):L8&&Array.isArray(L8.dom_path)&&L8.dom_path.length?L8.dom_path.map((x0,g0)=>D("div",{className:"st-layer"+(g0===L8.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+g0*12},children:[z(T9,{name:"square",size:13}),x0]},g0)):z("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!L8.id&&G70(L8)?z(VD0,{el:L8,cfg:F,onResizeArtboard:w,onSetArtboardHug:O,onSetArtboardStyle:I,onSetArtboardKind:T,onSetArtboardPrint:R,onDuplicateArtboard:$}):z(QD0,{el:L8,cfg:F,onOptimistic:M,onRecordEdit:A,onReplaceMedia:E,onUndoRedo:C,mode:a,onSetMode:z0})})]})}function FD0(){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=S8.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=S8.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 E0(l){return(l||[]).some((L0)=>L0.id===X0.movedId||E0(L0.children))}(b))return;f.current=null;let F0=V?S8.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),[r,e]=p.useState(null),[s,H0]=p.useState(null),a=p.useRef({canvas:null,at:0});p.useEffect(()=>{if(!V||!r)return;let b=Date.now(),S=a.current;if(S.canvas===V&&b-S.at<1500)return;a.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,r]);let[z0,i]=p.useState(!1),[q0,Z0]=p.useState(null),[P0,s0]=p.useState(null),e0=p.useRef(null);p.useEffect(()=>{let b=P0?.files?.progress;if(!b)return;let S=e0.current;if(e0.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.`)}},[P0?.files?.progress]),p.useEffect(()=>{if(typeof document>"u")return;let b=P0?.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},[P0?.files?.progress]);let[Y8,E8]=p.useState(null),[C8,t8]=p.useState(null),[o0,C0]=p.useState(null),[_0,$0]=p.useState(null),[V8,Q8]=p.useState(!1),[p8,y8]=p.useState(!1),[D9,f0]=p.useState(null),[k8,A9]=p.useState(""),[L8,B0]=p.useState(null),[J8,a0]=p.useState(null),e8=p.useRef(null),[T0,n0]=p.useState(null),[x0,g0]=p.useState(0),[P8,A0]=p.useState(null),W8=R90("maude-sb-w",{min:200,max:420,def:252}),_8=R90("maude-rp-w",{min:260,max:480,def:304}),[U0,i0]=p.useState(null),I8=p.useRef(null);p.useEffect(()=>{if(!U0)return;let b=(d)=>{let X0=I8.current?.getBoundingClientRect();if(!X0)return;if(U0==="sb")W8.setW(d.clientX-X0.left);else _8.setW(X0.right-d.clientX)},S=()=>i0(null);return window.addEventListener("pointermove",b),window.addEventListener("pointerup",S),()=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",S)}},[U0,W8.setW,_8.setW]);let Y9=p.useCallback((b)=>{if(P90(b))return;clearTimeout(e8.current),e8.current=setTimeout(()=>{a0((S)=>S===b?null:S)},2500)},[]),[d0,m7]=p.useState({designRel:".design",cloud:void 0}),_9=!!J8&&P8===J8;p.useEffect(()=>{if(!J8)return;let b=J8,S=setTimeout(async()=>{let d="compile";try{if(!(await fetch(`${d0?.canvasOrigin||""}/_health`,{cache:"no-store"})).ok)d="server"}catch{d="server"}n0({path:b,kind:d}),a0((X0)=>X0===b?null:X0)},_9?60000:15000);return()=>clearTimeout(S)},[J8,_9,d0?.canvasOrigin]);let o7=!!d0.cloud,T8=!d0.cloud&&!!Y8?.credentialed,j8=o7||T8,a8=j8?0:o0?.files?.length||0,I0=p.useRef(j8);I0.current=j8;let X8=!!d0.readOnly,$8=p.useCallback(()=>{fetch("/_config").then((b)=>b.json()).then((b)=>{let S=(b.designRoot||".design").replace(/^\/+|\/+$/g,"");m7((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(()=>{$8()},[$8]),p.useEffect(()=>{let b=!1;return fetch("/_sync-status").then((S)=>S.json()).then((S)=>{if(b||!S||S.linked===!1)return;s0(S)}).catch(()=>{}),()=>{b=!0}},[]),p.useEffect(()=>{if(j8){C0(null);return}let b=!1;return fetch("/_api/git/status").then((S)=>S.json()).then((S)=>{if(!b&&S)C0(S)}).catch(()=>{}),()=>{b=!0}},[j8]);let[W9,X7]=p.useState({}),[c9,y9]=p.useState(null),[t,O0]=p.useState(!1),[w0,m0]=p.useState("open"),[t0,l8]=p.useState(eF0),[s8,v8]=p.useState(()=>{return I90(L90,"advanced")==="designer"?"designer":"advanced"});p.useEffect(()=>{try{localStorage.setItem(L90,JSON.stringify(s8))}catch{}},[s8]);let[Z9,h9]=p.useState(null),[b9,K7]=p.useState(()=>kH(D90,!0)),[oX,$5]=p.useState(()=>kH(F90,!1)),Q6=Qu(),w7=Q6.update,VQ=Q6.state.sections,[G6,qQ]=p.useState(!1),[S7,RJ]=p.useState(!1);p.useEffect(()=>{if(!H9())return;let b=wh(()=>RJ(!0));return()=>{b.then((S)=>S()).catch(()=>{})}},[]);let[v9,LY]=p.useState(!1),[n7,BQ]=p.useState(!1),[DG,b7]=p.useState(!1),[DY,qX]=p.useState(!1),[D7,CJ]=p.useState(!1),{report:t9}=ow(H9()),[q7,Z6]=p.useState(!1),[BX,nX]=p.useState(!1),[NQ,rX]=p.useState(null),[Q4,$J]=p.useState(null),[Y4,qJ]=p.useState(!1),[FQ,nJ]=p.useState(!1),[SJ,W4]=p.useState(!1),[MY,LQ]=p.useState(!1),[n,W0]=p.useState(()=>I90(_90,sK)),[D0,y0]=p.useState(()=>{try{let b=localStorage.getItem(w90);if(b==="separate"||b==="in-inspector")return b}catch{}return"separate"}),[k0,Z8]=p.useState(!1),[K8,V9]=p.useState([]),[B9,bJ]=p.useState(0),[G4,u7]=p.useState(!1),[yJ,DQ]=p.useState(!1),[Z4,OY]=p.useState(!1),[jJ,y7]=p.useState(1),[Q7,aX]=p.useState(216),[E7,J9]=p.useState(null),[j7,x6]=p.useState([]),[NX,MQ]=p.useState([]),[MG,TH]=p.useState([]),[BJ,RH]=p.useState(0),OG=p.useRef(0);p.useEffect(()=>{OG.current=B9},[B9]);let[P7,CH]=p.useState(null),H4=p.useRef(null);p.useEffect(()=>{H4.current=P7},[P7]);let k6=p.useMemo(()=>JE(K8,{artboardId:[P7,E7],total:BJ}),[K8,P7,E7,BJ]),OQ=p.useRef(null);p.useEffect(()=>{OQ.current=k6},[k6]);let AY=p.useMemo(()=>kK(K8,k6)?.fps||30,[K8,k6]),[_Y,wY]=p.useState(null),[$H,Q1]=p.useState(0),NJ=p.useCallback((b,S)=>{if(/concurrent edit|changed since it was read/i.test(S||""))g8("Timeline changed — reloaded, try again."),Q1((d)=>d+1);else g8(`${b}: ${S||"failed"}`)},[]),[FX,AG]=p.useState(!1),[Y1,SH]=p.useState(!1),[W1,_G]=p.useState(!1),wG=p.useRef(FX);p.useEffect(()=>{if(wG.current=FX,FX){_G(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[FX]);let bH=p.useCallback(()=>{if(!wG.current||document.hidden)_G(!0),BL("Claude finished","Your assistant turn is ready in Maude.")},[]),EY=p.useRef(0),AQ=p.useCallback(()=>{if(!wG.current||document.hidden){_G(!0);let b=Date.now();if(b-EY.current<rF0)return;EY.current=b,BL("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[S5,_Q]=p.useState("inspect"),[G1,wQ]=p.useState(null),sX=p.useRef({undo:[],redo:[]}),[LX,Z1]=p.useState(0),[rJ,EG]=p.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),yH=p.useRef(rJ);p.useEffect(()=>{yH.current=rJ;try{localStorage.setItem("maude-auto-open-inspector",rJ?"1":"0")}catch{}},[rJ]);let jH=p.useRef(!1);p.useEffect(()=>{jH.current=SJ||t||V8||p8||FX},[SJ,t,V8,p8,FX]);let PG=p.useRef({open:{},side:sK});PG.current={open:{tree:b9,layers:MY,inspector:SJ,comments:t,changes:V8,sync:p8,assistant:FX},side:n};let DX=p.useCallback((b,S)=>{if(b==="tree")K7(S);else if(b==="layers")LQ(S);else if(b==="inspector")W4(S);else if(b==="comments")O0(S);else if(b==="changes")Q8(S);else if(b==="sync")y8(S);else if(b==="assistant")AG(S)},[]),z4=p.useCallback((b)=>PG.current.side?.[b]||sK[b],[]),vJ=p.useCallback((b)=>{let S=z4(b);DX(b,!0);for(let d of AT)if(d.id!==b&&z4(d.id)===S)DX(d.id,!1)},[DX,z4]),b5=p.useCallback((b)=>{if(PG.current.open?.[b])DX(b,!1);else vJ(b)},[vJ,DX]),MX=vJ,h6=b5,IG=p.useCallback((b)=>{if(!yH.current)return;if(X8)return;if(!b||!b.id)return;if(jH.current)return;MX("inspector"),_Q("css")},[MX,X8]),PY=p.useCallback(()=>Z8((b)=>!b),[]),EQ=om(_T),K4=Sm({enabled:d0.cloud===null||d0.exportLane==="remote"}),[vH,y5]=p.useState(!1),[FJ,IY]=p.useState(!1);p.useEffect(()=>{if(!H9())return;let b=!0;return kh().then((S)=>{if(!b)return;if(y5(!!S),!S&&!kH(N90,!1))IY(!0)}).catch(()=>{}),()=>{b=!1}},[]);let fH=p.useCallback(()=>{IY(!1);try{localStorage.setItem(N90,"1")}catch{}},[]),[H1,PQ]=p.useState(null);p.useEffect(()=>{if(!H9())return;let b;return Sh((S)=>PQ(S&&typeof S==="object"?S:{})).then((S)=>{b=S}).catch(()=>{}),()=>{try{b?.()}catch{}}},[]);let[OX,kY]=p.useState(null),[TY,kG]=p.useState(()=>!kH(B90,!1)),AX=p.useCallback((b)=>{kY(Array.isArray(b)&&b.length?b:null)},[]),TG={setup:(b)=>{if(!b)return;if((b.canvas||b.requireSelection)&&K.length===0)vJ("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [data-testid^="canvas-row-"]')?.click()}catch{}},80);if(b.inspector||b.tab||b.requireSelection)MX("inspector");if(b.tab)_Q(b.tab);if(b.changes)MX("changes")}},U4=p.useCallback(()=>{kG(!1);try{localStorage.setItem(B90,"1")}catch{}},[]),[IQ,RY]=p.useState(()=>kH(A90,!0)),[xH,RG]=p.useState(!1),[g6,V0]=p.useState(()=>kH(M90,!1)),[tX,CY]=p.useState(()=>kH(O90,!1)),[a6,_X]=p.useState(!1),[r7,aJ]=p.useState(!1),[V4,kQ]=p.useState(0),[q4,CG]=p.useState(null),[B4,$Y]=p.useState(!1),N4=p.useRef(null),U8=p.useRef(null),S8=p.useRef(new Map);p.useEffect(()=>{if(!d0?.canvasToken)return;let b=!1,S=null,d=0,X0=(M0)=>{clearTimeout(S);let h0=eb(M0);d=Date.now()+h0,S=setTimeout(K0,h0)};async function K0(){let M0=null;try{let N8=await fetch("/_config",{cache:"no-store",credentials:"same-origin"});if(N8.ok)M0=(await N8.json())?.canvasToken}catch{}if(b)return;if(typeof M0!=="string"||!M0){clearTimeout(S),d=Date.now()+30000,S=setTimeout(K0,30000);return}tb(M0);let h0=F0();if(h0)for(let N8 of S8.current.values())try{N8.contentWindow?.postMessage({dgn:"canvas-cap",t:M0},h0)}catch{}return X0(M0),M0}function F0(){try{return new URL(d0.canvasOrigin,location.href).origin}catch{return null}}let E0=!1;async function l(M0){if(M0.data?.dgn!=="canvas-expired"||M0.origin!==F0()||E0)return;E0=!0;try{let h0=await K0();if(!h0)return;for(let N8 of S8.current.values())if(N8.contentWindow===M0.source)N8.src=Jy(N8.src,h0)}finally{E0=!1}}window.addEventListener("message",l),X0(d0.canvasToken);let L0=()=>{if(document.visibilityState==="visible"&&Date.now()>=d)K0()};return document.addEventListener("visibilitychange",L0),()=>{b=!0,clearTimeout(S),document.removeEventListener("visibilitychange",L0),window.removeEventListener("message",l)}},[d0?.canvasToken,d0?.canvasOrigin]);let x8=p.useCallback((b)=>{let S=V?S8.current.get(V):null;if(!S||!S.contentWindow)return;try{S.contentWindow.postMessage(b,"*")}catch{}},[V]),G8=p.useRef(0),eX=p.useCallback(({format:b,artboardIds:S=null,scale:d=1,onProgress:X0,timeoutMs:K0=120000})=>new Promise((F0,E0)=>{let l=V?S8.current.get(V):null;if(!l||!l.contentWindow){E0(Error("no active canvas to capture"));return}let L0=l.contentWindow;G8.current+=1;let M0=`cap-${Date.now().toString(36)}-${G8.current}`,h0=!1,N8=(I7,l9)=>{if(h0)return;h0=!0,window.removeEventListener("message",M8),clearTimeout(N6),I7(l9)},M8=(I7)=>{if(I7.source!==L0)return;let l9=I7.data;if(!l9||l9.id!==M0)return;if(l9.dgn==="export-capture-progress")X0?.(l9.current,l9.total);else if(l9.dgn==="export-capture-done")N8(F0,Array.isArray(l9.items)?l9.items:[]);else if(l9.dgn==="export-capture-error")N8(E0,Error(l9.message||"capture failed"))},N6=setTimeout(()=>N8(E0,Error("capture timed out — the canvas did not answer")),K0);window.addEventListener("message",M8);try{L0.postMessage({dgn:"export-capture",id:M0,format:b,artboardIds:S,scale:d},"*")}catch(I7){N8(E0,I7)}}),[V]),H8=p.useCallback((b,S)=>x8({dgn:"photo-preview",asset:b,edit:S}),[x8]),$G=p.useCallback((b,S,d)=>{sX.current.undo.push({asset:b,before:S,after:d}),sX.current.redo.length=0},[]),F4=p.useCallback((b)=>{let S=b?sX.current.redo:sX.current.undo;if(!S.length)return!1;let d=S.pop();(b?sX.current.undo:sX.current.redo).push(d);let X0=(b?d.after:d.before)||{};return H8(d.asset,X0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(d.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(X0)}).catch(()=>{}),Z1((K0)=>K0+1),!0},[H8]),SG=p.useCallback(async(b)=>{x8({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(() => (q90(),V90)),K0=await X0(d),F0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":K0.type||"image/png"},body:K0}),E0=await F0.json().catch(()=>({}));if(F0.ok&&E0.path)return{maskAsset:E0.path};return null}catch(S){return console.error("[photo] background removal failed",S),null}finally{x8({dgn:"photo-busy",asset:b,busy:!1})}},[x8]);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 H6=p.useRef({});H6.current={open:k0,comps:K8,frame:B9,total:BJ,playing:G4,compId:k6,muted:Z4,loop:yJ,sequences:j7,post:x8,canvas:V};let j5=p.useRef({undo:[],redo:[]}),z6=p.useCallback((b,S,d)=>{if(typeof S!=="number")return;if(j5.current.undo.push({canvas:b,seq:S,label:d}),j5.current.redo=[],j5.current.undo.length>50)j5.current.undo.shift()},[]),L4=p.useCallback((b)=>{let S=j5.current,d=b==="undo"?S.undo:S.redo,X0=b==="undo"?S.redo:S.undo,K0=H6.current.canvas,F0=-1;for(let l=d.length-1;l>=0;l--)if(d[l].canvas===K0){F0=l;break}if(F0<0){g8(b==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let E0=d[F0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:E0.canvas,seq:E0.seq,dir:b})}).then((l)=>l.json().catch(()=>({}))).then((l)=>{if(d.splice(F0,1),l?.ok)X0.push(E0),g8(`${b==="undo"?"Undid":"Redid"}: ${E0.label}`,!0);else g8(`${b==="undo"?"Undo":"Redo"} skipped: ${l?.error||"failed"}`)}).catch(()=>g8(`${b==="undo"?"Undo":"Redo"} failed: network error`))},[]),T6=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},[]),SY=p.useCallback((b)=>{let S=H6.current.canvas;if(!S||S===o8)return;let d=H4.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=T6(K0,b);if(!F0?.stableId)return null;return fetch("/_api/remove-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:S,artboardId:d,stableId:F0.stableId,contentHash:F0.contentHash})})}).then((K0)=>K0?K0.json():null).then((K0)=>{if(K0&&!K0.ok)console.warn("[remove-clip]",K0.error||"failed"),NJ("Remove refused",K0.error);else if(K0?.ok){if(g8("Clip removed.",!0),K0.seq!=null)z6(S,K0.seq,"remove clip");wY(null)}}).catch(()=>g8("Remove failed: network error"))},[T6,z6]),TQ=p.useCallback((b,S,d)=>{let X0=H6.current.canvas;if(!X0||X0===o8)return;let K0=H4.current||void 0,F0=`/_api/comp-clips?canvas=${encodeURIComponent(X0)}${K0?`&artboardId=${encodeURIComponent(K0)}`:""}`;fetch(F0).then((E0)=>E0.json().catch(()=>({}))).then((E0)=>{let l=E0?.ok&&Array.isArray(E0.clips)?E0.clips:[],L0=b?.transition?l.find((M0)=>M0.kind==="transition"&&M0.stableId===b.stableId)||null:T6(E0,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((E0)=>E0?E0.json():null).then((E0)=>{if(E0&&!E0.ok)console.warn("[clip-edit]",S,E0.error||"failed"),NJ(`${S} refused`,E0.error);else if(E0?.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(g8(`Applied: ${l[S]||S}.`,!0),E0.seq!=null)z6(X0,E0.seq,l[S]||S)}}).catch(()=>g8(`${S} failed: network error`))},[T6,z6,NJ]),[RQ,bY]=p.useState(null),J5=p.useCallback((b,S="")=>new Promise((d)=>{bY({title:b,value:S,resolve:d})}),[]),v5=p.useCallback((b)=>{bY((S)=>{return S?.resolve?.(b),null})},[]),yY=p.useCallback((b,S)=>{let d=H6.current.canvas;if(!d||d===o8||!S||!String(S).trim())return;v7({type:"comments-add",payload:{file:d,text:String(S).trim(),selector:"",dom_path:[],tag:"",classes:"",bounds:null,html_excerpt:"",timeline:b}}),g8("Comment added.",!0)},[]);H6.current.selected=_Y,H6.current.setSelected=wY,H6.current.removeClip=SY,H6.current.clipVerb=TQ,H6.current.addComment=yY,H6.current.askText=J5,p.useEffect(()=>{let b=(S)=>{let d=H6.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=kK(d.comps,d.compId)?.fps||30,E0=Math.max(1,d.total),l=(M0)=>{let h0=Math.max(0,Math.min(E0-1,Math.round(M0)));bJ(h0),u7(!1),d.post({dgn:"timeline-seek",frame:h0,id:d.compId})},L0=()=>{let M0=new Set([0,E0-1]);for(let h0 of d.sequences||[]){M0.add(h0.from);for(let N8 of h0.keyframes||[])M0.add(N8.from),M0.add(N8.to)}return[...M0].filter((h0)=>h0>=0&&h0<E0).sort((h0,N8)=>h0-N8)};if((S.metaKey||S.ctrlKey)&&(S.key==="z"||S.key==="Z")){S.preventDefault(),L4(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 M0=d.selected!=null?{stableId:d.selected}:null;if(!M0){let h0=d.sequences||[],N8=h0.find((M8)=>M8.series&&d.frame>=M8.from&&d.frame<M8.from+M8.duration)||h0.find((M8)=>d.frame>=M8.from&&d.frame<M8.from+M8.duration);if(N8?.stableId)M0={stableId:N8.stableId}}if(M0)d.clipVerb?.(M0,"split",{atFrame:d.frame});else g8("Nothing under the playhead to split.");return}if(S.key===" "||S.code==="Space")if(S.preventDefault(),d.playing)u7(!1),d.post({dgn:"timeline-pause",id:d.compId});else u7(!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(E0-1);else if(S.key==="."){S.preventDefault();let M0=L0().find((h0)=>h0>d.frame);if(M0!=null)l(M0)}else if(S.key===","){S.preventDefault();let M0=L0().reverse().find((h0)=>h0<d.frame);if(M0!=null)l(M0)}};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[]),p.useEffect(()=>{V9([]),bJ(0),u7(!1),wY(null),CH(null);let b=setTimeout(()=>x8({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(b)},[V,x8]);let[f5,jY]=p.useState(""),[vY,D4]=p.useState([]),[bG,fY]=p.useState([]);p.useEffect(()=>{if(!k0||K8.length===0||!V||V===o8){jY(""),D4([]);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")jY(S.source)}).catch(()=>{}),()=>{b=!1}},[k0,K8,V,$H]),p.useEffect(()=>{if(!k0||!V||V===o8||!f5){D4([]),fY([]);return}let b=!0,S=P7||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:[];D4(K0.filter((F0)=>F0.kind==="sequence")),fY(K0.filter((F0)=>F0.kind==="transition"))}).catch(()=>{}),()=>{b=!1}},[k0,V,f5,P7,$H]),p.useEffect(()=>{if(!f5){x6([]),MQ([]),TH([]),RH(0);return}let b=E7??A?.artboardId??null,d=(b&&K8.find((F0)=>F0.artboardId===b||F0.id===b)||K8[0])?.durationInFrames||0,X0=Am(f5,d,b);CH(X0.artboardId??b??null);let K0=X0.sequences.map((F0,E0)=>{let l=vY[E0];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}});x6(K0),MQ(X0.audio||[]),TH(X0.transitions||[]),RH(X0.total)},[f5,vY,A,K8,E7]);let xY=p.useCallback(()=>{RY((b)=>{let S=!b,d=V?S8.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 S8.current.values())try{S.contentWindow.postMessage({dgn:"view-chrome",...b},"*")}catch{}},[]),hY=p.useCallback(()=>{V0((b)=>{let S=!b;return LJ({minimap:S}),S})},[LJ]),gY=p.useCallback(()=>{CY((b)=>{let S=!b;return LJ({zoom:S}),S})},[LJ]),yG=p.useCallback(()=>{_X((b)=>{let S=!b;return LJ({present:S}),S})},[LJ]),M4=p.useCallback(()=>{_X(!1),LJ({present:!1})},[LJ]),jG=p.useCallback(()=>{if(!V||V===o8)return;aJ((b)=>{let S=!b;return x8({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,x8]);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)CG(d)}).catch(()=>{}),()=>{b=!0}},[]),p.useEffect(()=>{if(!V||V===o8){kQ(0),aJ(!1);return}let b=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(V)).then((S)=>S.json()).then((S)=>{if(b)return;let d=Array.isArray(S?.artboards)?S.artboards.length:0;kQ(d),aJ(S?.overlays?.print===!0),A4(new Set(Array.isArray(S?.locked)?S.locked:[]))}).catch(()=>{if(!b)kQ(0),aJ(!1),A4(new Set)}),()=>{b=!0}},[V]),p.useEffect(()=>{if(!V||V===o8||!E7)return;let b=setTimeout(()=>{x8({dgn:"request-layers",artboardId:E7})},250);return()=>clearTimeout(b)},[V,E7,x8]);let[O4,A4]=p.useState(()=>new Set),vG=p.useCallback((b)=>{if(!V||V===o8)return;A4((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(()=>{}),x8({dgn:"locked-set",locked:X0}),d})},[V,x8]);p.useEffect(()=>{if(!V||V===o8)return;x8({dgn:"locked-set",locked:[...O4]})},[O4,V,x8]),p.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",t0),localStorage.setItem(r90,t0)}catch{}for(let b of S8.current.values())try{b.contentWindow.postMessage({dgn:"theme",theme:t0},"*")}catch{}},[t0]),p.useEffect(()=>{try{localStorage.setItem(D90,b9?"1":"0")}catch{}},[b9]),p.useEffect(()=>{try{localStorage.setItem(F90,oX?"1":"0")}catch{}},[oX]),p.useEffect(()=>{try{localStorage.setItem(M90,g6?"1":"0")}catch{}},[g6]),p.useEffect(()=>{try{localStorage.setItem(O90,tX?"1":"0")}catch{}},[tX]),p.useEffect(()=>{try{localStorage.setItem(A90,IQ?"1":"0")}catch{}},[IQ]),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")l8(S.theme);if(typeof S.minimap==="boolean")V0(S.minimap);if(typeof S.zoom==="boolean")CY(S.zoom);if(typeof S.annotations==="boolean")RY(S.annotations);if(typeof S.autoOpenInspector==="boolean")EG(S.autoOpenInspector);if(S.panelSides&&typeof S.panelSides==="object")W0({...sK,...S.panelSides});if(S.layersMode==="separate"||S.layersMode==="in-inspector")y0(S.layersMode)}).catch(()=>{}).finally(()=>{if(!b)RG(!0)}),()=>{b=!0}},[]),p.useEffect(()=>{if(!xH)return;aF0({theme:t0,minimap:g6,zoom:tX,annotations:IQ,autoOpenInspector:rJ,panelSides:n,layersMode:D0})},[xH,t0,g6,tX,IQ,rJ,n,D0]),p.useEffect(()=>{try{localStorage.setItem(_90,JSON.stringify(n))}catch{}},[n]),p.useEffect(()=>{try{localStorage.setItem(w90,D0)}catch{}},[D0]);let mY=p.useRef(!1);p.useEffect(()=>{if(mY.current||!Q6.ready||!Q||!J.length)return;mY.current=!0;let b=Ju(J);w7((S)=>Xu(S,b))},[Q6.ready,Q,J,w7]);let fG=p.useCallback((b)=>w7((S)=>em(S,b)),[w7]),xG=p.useMemo(()=>({isOpen:(b)=>sm(Q6.state,b),setOpen:(b,S)=>w7((d)=>$E(d,b,S))}),[Q6.state,w7]),_4=p.useCallback(()=>{l8((b)=>b==="dark"?"light":"dark")},[]),w4=p.useRef(null),j9=p.useCallback(()=>w4.current?.reload()??Promise.resolve(),[]);p.useEffect(()=>{let b=Qy({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:WL0(F0.paths,F0.stripPrefix,F0.dirs)}));return{data:X0,built:K0}},apply:({data:S,built:d})=>{H(S.project||"Design"),X(d),Y(!0),m7((X0)=>({...X0,canvasDesignSystems:S.canvasDesignSystems??{},canvasKinds:S.canvasKinds??{}}))},onError:(S)=>console.error("failed to load tree",S)});return w4.current=b,j9(),()=>{w4.current=null,b.dispose()}},[j9]);let X5=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)}},[]),uY=p.useCallback(async()=>{try{let S=await(await fetch("/_comments-all")).json();X7(S||{})}catch(b){console.error("failed to load comments",b)}},[]);p.useEffect(()=>{uY()},[uY]);let pY=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");U8.current=K0,K0.addEventListener("open",()=>{if(i(!0),S)$8();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 E0=JSON.parse(F0.data);if(E0.type==="snapshot"&&E0.state)E((l)=>c90(E0.state.selected,l));else if(E0.type==="selected"){if(Date.now()-T.current<2000)return;let l=E0.selected,L0=Array.isArray(l)?l[0]:l,M0=w.current,h0=Array.isArray(M0)?M0[0]:M0;if(E((N8)=>c90(l,N8)),L0?.id&&L0.file&&(!h0||h0.id!==L0.id||h0.file!==L0.file))$(L0)}else if(E0.type==="comments"&&typeof E0.file==="string")X7((l)=>({...l,[E0.file]:E0.comments||[]}));else if(E0.type==="ai-activity"&&typeof E0.file==="string"){if($Y(!0),N4.current)clearTimeout(N4.current);N4.current=setTimeout(()=>$Y(!1),8000);for(let l of S8.current.values())try{l.contentWindow.postMessage({dgn:"ai-activity",file:E0.file,entry:E0.entry},"*")}catch{}}else if(E0.type==="export:job"&&E0.payload)K4.upsert(E0.payload);else if(E0.type==="sync:status"&&E0.payload)s0(E0.payload);else if(E0.type==="canvas-list-update")j9(),pY.current(E0.payload);else if(E0.type==="config-updated")$8();else if(E0.type==="acp-focus"){if(H9())MX("assistant")}else if(E0.type==="git-status"&&E0.payload){if(!I0.current)C0(E0.payload)}else if(E0.type==="git-lifecycle"&&E0.payload){Z0(E0.payload);for(let l of S8.current.values())try{l.contentWindow.postMessage({dgn:"git-lifecycle",payload:E0.payload},"*")}catch{}}}catch{}})}return d(),()=>{if(clearInterval(b),U8.current)U8.current.close()}},[j9,$8]);function v7(b){let S=U8.current;try{if(S&&S.readyState===1)S.send(JSON.stringify(b))}catch{}}let DJ=p.useCallback(async()=>{if(I0.current)return;try{let b=await fetch("/_api/git/status");if(b.ok)C0(await b.json())}catch{}},[]),fJ=p.useCallback(async()=>{if(I0.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)$0({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?"}}},[]),hG=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]),lY=p.useCallback(async(b)=>{let S=await MJ("/_api/git/discard",{files:b});if(S.ok)await DJ();return S},[MJ,DJ]),gG=p.useCallback(async()=>{let b=await MJ("/_api/git/push",{});if(b.ok)await DJ(),fJ();return b},[MJ,DJ,fJ]),dY=p.useCallback(async()=>{let b=await MJ("/_api/git/pull",{});if(b.ok)await DJ(),fJ();if(b.conflict&&Array.isArray(b.files)&&b.files.length)f0({file:b.files[0],conflict:!0});return b},[MJ,DJ,fJ]),mG=p.useCallback(async(b)=>{let S=await MJ("/_api/git/resolve",{choice:b});if(S.ok)await DJ(),fJ();return S},[MJ,DJ,fJ]),E4=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[]}},[]),[uG,pG]=p.useState(null),lG=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 pG({branch:X0.branch??null,project:X0.project??null,hubHost:X0.hubHost??null}),X0.entries||[]}catch{return null}},[]),[z1,K1]=p.useState(!1),[U1,V1]=p.useState(0),dG=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((E0)=>E0.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}},[]),cG=/^r\d+$/.test(D9?.beforeSha||""),q1=p.useCallback(async(b)=>{if(!cG)return E4(b);let S=await dG(b);return Array.isArray(S)?S:[]},[cG,E4,dG]),hH=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 V1((K0)=>K0+1),X0;return{ok:!1,error:X0?.error}},[]),B1=p.useMemo(()=>{let b={modified:"M",added:"A",deleted:"D",untracked:"U"},S=new Map;if(j8)return S;for(let d of o0?.files||[])S.set(d.path,b[d.status]);return S},[o0,j8]);p.useEffect(()=>{if(j8){$0(null);return}if(o0?.repo===!1)return;fJ();let b=setInterval(fJ,V8?60000:120000);return()=>clearInterval(b)},[j8,o0?.repo,V8,fJ]);let B6=p.useCallback((b,{reveal:S=!0}={})=>{if(S&&b&&b!==o8)w7((d)=>HF(d,J,b));if(W.current="push",y9(null),F(null),b===V)return;if(U((d)=>{for(let X0 of d)if(X0.path!==b)S8.current.delete(X0.path);return[{path:b}]}),B(b),n0(null),A0(null),b!==o8)a0(b)},[V,J,w7]),P4=p.useCallback((b,S="push")=>{let d=J.flatMap((X0)=>X0.paths||[]).find((X0)=>hW(X0,d0.designRel)===b);if(d&&C5.test(d))B6(d,{reveal:!1});else if(d&&EL(UQ(d)))M(d);else U([]),B(null),F(null),A5({title:"Not here yet",description:`${b} is not in this project (not synced yet?)`,kind:"info"});W.current=S},[J,d0.designRel,B6,M]),gH=p.useRef(!1);p.useEffect(()=>{if(!Q||d0.cloud===void 0||gH.current)return;gH.current=!0;let b=bV(location,d0.designRel);if(b)P4(b,"none")},[Q,d0.cloud,d0.designRel,P4]),p.useEffect(()=>{if(!Q||d0.cloud===void 0)return;let b=()=>{let S=bV(location,d0.designRel);if(S)P4(S,"none");else W.current="none",U([]),B(null),F(null)};return window.addEventListener("popstate",b),()=>window.removeEventListener("popstate",b)},[Q,d0.cloud,d0.designRel,P4]),p.useEffect(()=>{let b=N||(V===o8?null:V);if(b===G.current)return;G.current=b;let S=hW(b,d0.designRel);if(W.current!=="none"&&bV(location,d0.designRel)!==S)history[S?"pushState":"replaceState"](S?{open:S}:null,"",Fg(location,S));W.current="push"},[V,N,d0.designRel]);let cY=N||(V===o8?null:V),iG=d0.cloud?"cloud":H9()?"native":"local",mH=(b)=>Og({rel:hW(b,d0.designRel),shell:iG,location,linkedHubUrl:Y8?.url,project:d0.cloud?Z:C8,localUrl:location.origin}),uH=(b=cY)=>{let S=hW(b,d0.designRel);if(S)rX({path:b,rel:S,label:UQ(b)})},N1=p.useCallback((b)=>{if(n0(null),A0(null),$8(),g0((S)=>S+1),b&&b!==o8)a0(b)},[$8]),oG=p.useRef(!1);p.useEffect(()=>{if(oG.current)return;if(!d0.cloud)return;if(new URLSearchParams(location.search).has("open")){oG.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(!C5.test(d))continue;if(/(^|\/)system\//.test(d))continue;b=d;break}if(b)break}if(!b)return;oG.current=!0,B6(b,{reveal:!1})},[d0.cloud,J,K.length,B6]);let CQ=p.useCallback((b)=>{let S=typeof b==="string"?b:void 0;if(S)X5(S);else if(!L8)X5();B6(o8)},[L8,X5,B6]);p.useEffect(()=>{v7({type:"tabs",tabs:K.map((b)=>b.path).filter((b)=>b!==o8)})},[K]),p.useEffect(()=>{if(V&&V!==o8)v7({type:"active",file:V});else if(V===o8)v7({type:"active",file:""});else v7({type:"active",file:""})},[V]);let iY=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}),S8.current.delete(b),a0((S)=>S===b?null:S)},[V]);pY.current=(b)=>{if(!b?.rel)return;let S=(d0?.designRel||d0?.designRoot||".design").replace(/^\/+|\/+$/g,""),d=`${S}/${b.rel}`;if(b.action==="removed")iY(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),a0((K0)=>K0===X0?null:K0),S8.current.delete(X0)}};let x5=p.useCallback(()=>{if(!V||V===o8){if(V===o8)X5();return}let b=S8.current.get(V);if(b)b.src=b.src},[V,X5]),pH=p.useCallback(()=>j9(),[j9]),[F1,lH]=p.useState(!1),nG=p.useRef(!1),rG=p.useCallback(async()=>{if(nG.current)return;nG.current=!0,lH(!0);try{await Promise.all([j9(),new Promise((b)=>setTimeout(b,550))])}finally{nG.current=!1,lH(!1)}},[j9]);p.useEffect(()=>{let b=null,S=()=>{if(b)clearTimeout(b);b=setTimeout(()=>{b=null,pH()},150)};return window.addEventListener("focus",S),()=>{if(window.removeEventListener("focus",S),b)clearTimeout(b)}},[pH]);let L1=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 j9(),B6(d.file),{ok:!0,file:d.file}}catch(S){return{ok:!1,error:S instanceof Error?S.message:"network error"}}},[j9,B6]),dH=p.useCallback(async()=>{let b=await J5("New video name");if(!b)return;let d=(await J5("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 J5("Frames per second","30"))||30));try{let E0=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 E0.json().catch(()=>({}));if(!E0.ok||!l.ok){g8(`New video failed: ${l.error||`error ${E0.status}`}`);return}await j9(),B6(l.file),Z8(!0),g8("New video created — drop clips on the timeline to start the cut.",!0)}catch(E0){g8(`New video failed: ${E0 instanceof Error?E0.message:"network error"}`)}},[j9,B6,J5]),D1=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 M0=L0.getAttribute("data-src");if(!M0)continue;d.push({src:M0,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(UQ(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})}),E0=await F0.json().catch(()=>({}));if(!F0.ok||!E0.ok){window.alert(`Assemble failed: ${E0.error||`error ${F0.status}`}`);return}await j9(),B6(E0.file)}catch(b){window.alert(`Assemble failed: ${b instanceof Error?b.message:"network error"}`)}},[V,j9,B6]),aG=p.useCallback(({accept:b,resolveTarget:S})=>{let d=V,X0=P7||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 E0=K0.files?.[0];if(F0(),!E0)return;let l=`/_api/comp-clips?canvas=${encodeURIComponent(d)}${X0?`&artboardId=${encodeURIComponent(X0)}`:""}`;fetch(l).then((L0)=>L0.json().catch(()=>({}))).then((L0)=>{let M0=S(L0);if(!M0)return g8("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":E0.type||"application/octet-stream"},body:E0}).then((h0)=>h0.json().catch(()=>({}))).then((h0)=>{if(!h0?.path)return g8(`Upload failed: ${h0?.error||"unknown error"}`),null;if(M0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:d,arrayName:M0.arrayRef.arrayName,index:M0.arrayRef.index,field:M0.arrayRef.field,value:h0.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:d,id:M0.cdId,attr:"src",value:h0.path})})})}).then((L0)=>L0?L0.json():null).then((L0)=>{if(L0&&!L0.ok)g8(`Replace refused: ${L0.error||"failed"}`);else if(L0&&L0.ok){if(g8("Media replaced.",!0),L0.seq!=null)z6(d,L0.seq,"replace media")}}).catch(()=>g8("Replace failed: network error"))}),K0.click()},[V,P7,z6]),M1=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 j9(),V===b)U([]),B(null)}catch(X0){window.alert(`Delete failed: ${X0 instanceof Error?X0.message:"network error"}`)}},[j9,V]),O1=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 g8(`Could not move: ${K0.error||`error ${X0.status}`}`),{ok:!1,error:K0.error};let F0=(d0?.designRel||d0?.designRoot||".design").replace(/^\/+|\/+$/g,""),E0=`${F0}/${K0.fromRel}`,l=`${F0}/${K0.toRel}`;w7((M0)=>HF(SE(M0,E0,l),J,l)),await j9(),U((M0)=>M0.map((h0)=>h0.path===E0?{path:l}:h0)),B((M0)=>M0===E0?l:M0);let L0=E0.split("/").slice(0,-1).join("/");return g8(`Moved to ${K0.toRel.split("/").slice(0,-1).join("/")||"."}`,!0,{label:"Undo",onClick:()=>{b(l,L0)}}),{ok:!0}}catch(X0){return g8(`Move failed: ${X0 instanceof Error?X0.message:"network error"}`),{ok:!1,error:"network error"}}},[j9,d0,J,w7]),A1=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 g8(`Could not create folder: ${K0}`),{ok:!1,error:K0}}return w7((K0)=>HF(K0,J,b,{includeSelf:!0})),await j9(),{ok:!0,dir:X0.dir}}catch(d){let X0=d instanceof Error?d.message:"network error";return g8(`Create folder failed: ${X0}`),{ok:!1,error:X0}}},[j9,J,w7]),_1=p.useCallback(async(b,S)=>{if(!window.confirm(`Delete folder "${S}"?
5686
5686