@1agh/maude 1.9.1 → 1.10.0

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 @@ ${p.block}`:f,h=[],b=new Map;for await(let w of e.prompt(m,t(),u,a?.(),n?.(),o?.
5680
5680
 
5681
5681
  > Maude ${z.app.maudeVersion} · ${z.app.platform} ${z.app.arch} · ${z.app.surface}
5682
5682
  > Local report bundle: \`${X?.dir??".design/_reports/"}\` (attach its files here)`),G=`${Wye}?title=${K}&body=${ie}&labels=report`;if(na())try{await Gb(G)}catch{window.open(G,"_blank","noopener")}else window.open(G,"_blank","noopener");I({fallbackDir:X?.dir??null}),r("done")}catch{N("Saving the local bundle failed too — please file the issue by hand.")}}let U=s.trim().length>0;return l("div",{className:"st-scrim",onClick:H,"data-testid":"report-bug-dialog",children:y("div",{className:"st-dialog rb-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"rb-title",onClick:(z)=>z.stopPropagation(),children:[y("div",{className:"st-dialog-hd",children:[l("span",{className:"st-dialog-title",id:"rb-title",children:"Report a bug"}),l("button",{type:"button",className:"st-iconbtn",onClick:H,"aria-label":"Close",children:"×"})]}),y("div",{className:"st-dialog-bd rb-body",children:[n==="describe"&&y(te,{children:[l("label",{className:"rb-label",htmlFor:"rb-desc",children:"What happened? What did you expect instead?"}),l("textarea",{id:"rb-desc",className:"textarea","data-testid":"report-bug-description",rows:5,autoFocus:!0,value:s,onChange:(z)=>o(z.target.value),placeholder:"e.g. Clicking Export → PNG shows a spinner forever…"}),l("p",{className:"rb-hint",children:"Next you'll see exactly what gets attached — nothing is sent until you approve it."}),y("footer",{className:"rb-actions",children:[l("button",{type:"button",className:"st-btn",onClick:H,children:"Cancel"}),l("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-preview",disabled:!U,onClick:()=>r("preview"),children:"Review & attach"})]})]}),n==="preview"&&y(te,{children:[y("div",{className:"rb-section",children:[y("div",{className:"rb-section-hd",children:[y("span",{children:["Screenshots (",c.length,")"]}),y("span",{className:"rb-hd-actions",children:[c.length<PA&&l("button",{type:"button",className:"rb-link","data-testid":"report-bug-attach",onClick:O,children:"Attach screenshot…"}),c.length>0&&l("button",{type:"button",className:`rb-link${_?" is-on":""}`,"data-testid":"report-bug-redact",onClick:()=>v((z)=>!z),children:_?"Done redacting":"Redact…"})]})]}),y("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 (",Kye(i?.app?.platform),") and attach or paste (⌘V) it here."]}),w&&l("p",{className:"rb-hint","data-testid":"report-bug-shell-pending",children:"Capturing the Maude window…"}),c.length===0&&!w?y("p",{className:"rb-hint",children:["No screenshot attached yet — up to ",PA,"."]}):y(te,{children:[_&&l("p",{className:"rb-hint",children:"Drag over anything private — it ships as solid black."}),l("div",{className:"rb-shots",children:c.map((z,M)=>l(Zye,{shot:z,redacting:_,onRects:(F)=>f((X)=>X.map((K,ie)=>ie===M?{...K,rects:F}:K)),onRemove:()=>{URL.revokeObjectURL(z.url),f((F)=>F.filter((X,K)=>K!==M))}},z.url))})]})]}),y("div",{className:"rb-section",children:[l("div",{className:"rb-section-hd",children:l("span",{children:"Included with the report"})}),y("label",{className:"rb-check",children:[l("input",{type:"checkbox",checked:!0,disabled:!0}),y("span",{children:["Maude ",i?.app?.maudeVersion??"…"," · ",i?.app?.platform??"…"," ",i?.app?.arch??""," · ",na()?"desktop app":"browser"]})]}),a&&y("label",{className:"rb-check",children:[l("input",{type:"checkbox",checked:h.activeCanvas,onChange:(z)=>b({...h,activeCanvas:z.target.checked})}),y("span",{children:["Active canvas path — ",l("code",{children:a})]})]}),i?.context?.projectName&&y("label",{className:"rb-check",children:[l("input",{type:"checkbox",checked:h.projectName,onChange:(z)=>b({...h,projectName:z.target.checked})}),y("span",{children:["Project name — ",l("code",{children:i.context.projectName})]})]}),i?.logs?.serverLogTail?y("label",{className:"rb-check",children:[l("input",{type:"checkbox","data-testid":"report-bug-consent-logs",checked:h.logTail,onChange:(z)=>b({...h,logTail:z.target.checked})}),y("span",{children:["Recent server log (",i.logs.serverLogTail.split(`
5683
- `).length," lines, paths & secrets scrubbed)",i?.process?` + server memory (${Math.round(i.process.rssBytes/1048576)} MB)`:""," ","—"," ",y("details",{className:"rb-details",children:[l("summary",{children:"view"}),l("pre",{className:"rb-log",children:i.logs.serverLogTail})]})]})]}):null,na()&&p.length>0&&y("label",{className:"rb-check",children:[l("input",{type:"checkbox",checked:h.crashLogs,onChange:(z)=>b({...h,crashLogs:z.target.checked})}),y("span",{children:["Crash logs (",p.length,") — ",l("code",{children:p.map((z)=>z.name).join(", ")})]})]})]}),y("p",{className:"rb-hint",children:["Your description and the system info above become a"," ",l("strong",{children:"public GitHub issue"}),"; screenshots and logs go to a private repository only maintainers can open."]}),y("footer",{className:"rb-actions",children:[l("button",{type:"button",className:"st-btn",onClick:()=>r("describe"),children:"Back"}),l("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-send",onClick:q,children:"Send report"})]})]}),n==="sending"&&l("p",{className:"rb-hint",children:"Sending your report…"}),n==="done"&&y(te,{children:[k?.issueUrl?y("p",{children:["Thank you — your report is filed as"," ",y("button",{type:"button",className:"rb-link","data-testid":"report-bug-issue-link",onClick:()=>{if(na())Gb(k.issueUrl).catch(()=>navigator.clipboard?.writeText(k.issueUrl));else window.open(k.issueUrl,"_blank","noopener")},children:["report #",k.issueNumber]})," ","on the public Maude issue tracker. Screenshots and logs stay in a private repository only maintainers can open — the issue links to them."]}):y("p",{children:["The bundle is saved locally",k?.fallbackDir?y(te,{children:[" ","at ",l("code",{children:k.fallbackDir})]}):null," ","and a prefilled GitHub issue was opened — attach the bundle files there."]}),l("footer",{className:"rb-actions",children:l("button",{type:"button",className:"st-btn rb-primary",onClick:H,children:"Done"})})]}),n==="fallback"&&y(te,{children:[l("p",{className:"rb-error","data-testid":"report-bug-error",children:A}),l("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."}),y("footer",{className:"rb-actions",children:[l("button",{type:"button",className:"st-btn",onClick:()=>r("preview"),children:"Back"}),l("button",{type:"button",className:"st-btn rb-primary",onClick:D,children:"Save locally & open GitHub"})]})]})]})]})})}function uj(e){if(typeof e!=="string")return null;let t=e.match(/^(\d+)\.(\d+)\.(\d+)/);return t?[Number(t[1]),Number(t[2]),Number(t[3])]:null}function cj(e,t){let a=uj(e),n=uj(t);if(!a)return!1;if(!n)return!0;for(let r=0;r<3;r++)if(a[r]!==n[r])return a[r]>n[r];return!1}function dj(e,t){if(!Array.isArray(e))return[];return e.filter((a)=>a&&(a.version==null||cj(a.version,t)))}function fj(e,t){let a=t;if(Array.isArray(e)){for(let n of e)if(n&&n.version&&cj(n.version,a))a=n.version}return a}var zA="mdcc-whatsnew-seen",BA="mdcc-whatsnew-toast-dismissed";function Yye(e){return typeof e==="string"&&/^https?:\/\//i.test(e)}function Jye(e){try{let t=localStorage.getItem(zA);if(t)return t;localStorage.setItem(zA,e)}catch{}return e}function ebe(){try{return localStorage.getItem(BA)}catch{return null}}function UA(e){let[t,a]=P([]),[n,r]=P(e),[s,o]=P(()=>Jye(e)),[i,u]=P(()=>ebe()),[c,f]=P(!1);ee(()=>{let v=!1,k=()=>{fetch("/_api/whats-new").then((N)=>N.json()).then((N)=>{if(v)return;if(a(Array.isArray(N?.entries)?N.entries:[]),typeof N?.version==="string")r(N.version)}).catch(()=>{})};k();let I=()=>k(),A=()=>{if(document.visibilityState==="visible")k()};return window.addEventListener("focus",I),document.addEventListener("visibilitychange",A),()=>{v=!0,window.removeEventListener("focus",I),document.removeEventListener("visibilitychange",A)}},[]);let p=dj(t,s),m=p.length>0&&i!==n&&!c,h=p[0]??null,b=ce(()=>{let v=fj(t,n);o(v),u(n);try{localStorage.setItem(zA,v),localStorage.setItem(BA,n)}catch{}},[t,n]),w=ce(()=>{u(n);try{localStorage.setItem(BA,n)}catch{}},[n]),S=ce(()=>f(!0),[]),_=ce(()=>{f(!1),b()},[b]);return{entries:t,unseen:p,feedVersion:n,panelOpen:c,openPanel:S,closePanel:_,showToast:m,toastEntry:h,dismissToast:w,markAllSeen:b}}function pj({wn:e}){let t=`whats-new-${e.feedVersion}`;return ee(()=>{if(!e.showToast||!e.toastEntry){Zu(t);return}uo({id:t,group:"whats-new",kind:"info",duration:1e4,title:`What's new${e.toastEntry.version?` · v${e.toastEntry.version}`:""} — ${e.toastEntry.title}`,description:e.toastEntry.summary,action:{label:e.unseen.length>1?`See all (${e.unseen.length})`:"Details",onClick:e.openPanel},onDismiss:e.dismissToast})},[t,e.showToast,e.toastEntry,e.unseen.length,e.openPanel,e.dismissToast]),ee(()=>()=>Zu(t),[t]),null}function mj({wn:e,onStartTour:t}){let{panelOpen:a,closePanel:n}=e;if(ee(()=>{if(!a)return;function s(o){if(o.key==="Escape")n()}return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[a,n]),!a)return null;let r=new Set(e.unseen.map((s)=>s.id));return l("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(s)=>{if(s.target===s.currentTarget)n()},children:y("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[y("header",{className:"help-modal-hd",children:[l("span",{className:"title",id:"mdcc-wn-title",children:"✦ What’s new in maude"}),l("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:n,children:"×"})]}),l("div",{className:"mdcc-wn-panel__body",children:e.entries.length===0?l("p",{className:"mdcc-wn-empty",children:"Nothing new yet."}):l("ul",{className:"mdcc-wn-list",children:e.entries.map((s)=>y("li",{className:"mdcc-wn-item"+(r.has(s.id)?" is-unseen":""),children:[y("div",{className:"mdcc-wn-item__hd",children:[l("span",{className:"mdcc-wn-kind mdcc-wn-kind--"+s.kind,children:s.kind}),l("span",{className:"mdcc-wn-item__title",children:s.title}),l("span",{className:"mdcc-wn-item__ver",children:s.version?`v${s.version}`:"next"})]}),l("p",{className:"mdcc-wn-item__summary",children:s.summary}),Yye(s.learnMore)&&l("a",{className:"mdcc-wn-item__more",href:s.learnMore,target:"_blank",rel:"noreferrer",children:"Learn more →"}),t&&Array.isArray(s.tour)&&s.tour.length>0&&l("button",{type:"button",className:"mdcc-wn-item__tour",onClick:()=>{n(),t(s.tour)},children:"▶ Take tour"})]},s.id))})})]})})}var tbe=Object.freeze({dirs:[],sections:{}}),abe="mdcc-sections-expanded",nbe=250,rbe=3000;function gj(e,t){return!!t&&e.dirs.includes(t)}function sbe(e,t){return e.sections[t]===!0}function FA(e,t,a){if(!t)return e;if(e.dirs.includes(t)===!!a)return e;let r=a?[...e.dirs,t].sort():e.dirs.filter((s)=>s!==t);return{...e,dirs:r}}function yj(e,t,a){if(!t||e.sections[t]===!!a)return e;return{...e,sections:{...e.sections,[t]:!!a}}}function jA(e,t){return yj(e,t,!sbe(e,t))}function obe(e,t){let a=null;for(let n of e||[]){let r=n.fullPath;if(!r||!(t===r||t.startsWith(r+"/")))continue;if(!a||r.length>a.fullPath.length)a=n}return a}function Dv(e,t,a,{includeSelf:n=!1}={}){if(!a)return e;let r=obe(t,a);if(!r)return e;let s=yj(e,r.label,!0),o=a.slice(r.fullPath.length+1);if(!o)return s;let i=o.split("/"),u=n?i.length:i.length-1,c=r.fullPath;for(let f=0;f<u;f++)c=`${c}/${i[f]}`,s=FA(s,c,!0);return s}function Y_(e,t,a){if(!t||!a||t===a)return e;let n=!1,r=e.dirs.map((s)=>{if(s===t)return n=!0,a;if(s.startsWith(t+"/"))return n=!0,a+s.slice(t.length);return s});return n?{...e,dirs:[...new Set(r)].sort()}:e}function HA(e){let t=new Set,a=(n,r)=>{for(let s of Object.keys(n||{})){if(s==="_files")continue;let o=`${r}/${s}`;t.add(o),a(n[s],o)}};for(let n of e||[])if(n.fullPath)a(n.tree,n.fullPath);return t}function qA(e,t){let a=e.dirs.filter((n)=>t.has(n));return a.length===e.dirs.length?e:{...e,dirs:a}}function hj(e){let t=e&&typeof e==="object"&&!Array.isArray(e)?e:{},a=Array.isArray(t.dirs)?[...new Set(t.dirs.filter((r)=>typeof r==="string"&&r))].sort():[],n={};if(t.sections&&typeof t.sections==="object"&&!Array.isArray(t.sections)){for(let[r,s]of Object.entries(t.sections))if(typeof s==="boolean")n[r]=s}return{dirs:a,sections:n}}function ibe(){try{let e=JSON.parse(localStorage.getItem(abe)||"null");return e&&typeof e==="object"&&!Array.isArray(e)?e:null}catch{return null}}function VA({fetchImpl:e}={}){let[t,a]=P(tbe),[n,r]=P(!1),s=e||((...c)=>fetch(...c)),o=me(s);o.current=s,ee(()=>{let c=!1,f=typeof AbortController==="function"?new AbortController:null,p=setTimeout(()=>f?.abort(),rbe);return o.current("/_api/tree-state",f?{signal:f.signal}:void 0).then((m)=>m.ok?m.json():Promise.reject(Error(`HTTP ${m.status}`))).then((m)=>{if(c)return;let h=hj(m);if(!(m&&typeof m==="object"&&m.sections&&Object.keys(m.sections).length)){let w=ibe();if(w)h=hj({...h,sections:w})}a(h)}).catch(()=>{}).finally(()=>{if(clearTimeout(p),!c)r(!0)}),()=>{c=!0,clearTimeout(p)}},[]);let i=me(!0);ee(()=>{if(!n)return;if(i.current){i.current=!1;return}let c=setTimeout(()=>{try{o.current("/_api/tree-state",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(t)}).catch(()=>{})}catch{}},nbe);return()=>clearTimeout(c)},[n,t]);let u=ce((c)=>a((f)=>c(f)),[]);return{state:t,ready:n,update:u}}var J_="mdcc-usage-tour-seen",e2="mdcc-collab-tour-seen",Ft="__system__",Pv="mdcc-theme",zv="mdcc-show-hidden",t2="maude-cp-mode",Bv="mdcc-sidebar-open",Uv="mdcc-minimap-visible",Fv="mdcc-zoomctl-visible",jv="mdcc-annotations-visible";var GA=30000,Hv="mdcc-panel-sides",qv="mdcc-layers-mode",ws=/\.(tsx|html?)$/i,Vv=(e)=>/\.(tsx|jsx)$/i.test(String(e||"")),Sp="1.9.1",WA=[],a2="maude-mode-hint-seen";function KA(e){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(e)}).catch(()=>{})}catch{}}var lbe=[[/\.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 $d(e){for(let[t,a]of lbe)if(t.test(e))return a;return null}function Cp(e){return e.replace(/^\.[^/]+\//,"").replace(ws,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}function QA(e){let t=[];return function a(n){for(let r of n||[])t.push(r?.id??""),a(r?.children)}(e),t.join(",")}function Gh(e,t){let a=()=>{try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(e,{body:t})}catch{}};if(na()){bn("send_notification",{title:e,body:t}).catch(a);return}a()}function XA(){if(typeof window>"u")return"dark";try{let e=localStorage.getItem(Pv);if(e==="light"||e==="dark")return e}catch{}return"dark"}function tc(e,t){if(typeof window>"u")return t;try{let a=localStorage.getItem(e);if(a==="1")return!0;if(a==="0")return!1}catch{}return t}function n2(e,t){if(typeof window>"u")return t;try{let a=localStorage.getItem(e);return a?JSON.parse(a):t}catch{return t}}function ZA(){return!1}function us(e){return e.split("/").pop()}function Gt(e,t=!1,a){uo({title:e,kind:t?"success":"error",action:a})}function Vh(e=!1){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(a2)==="1")return}catch{return}if(Vh.active)return;Vh.active=!0;let t=()=>{Vh.active=!1;try{localStorage.setItem(a2,"1")}catch{}document.removeEventListener("keydown",a,!0)},a=(n)=>{if((n.key==="v"||n.key==="V")&&!n.metaKey&&!n.ctrlKey&&!n.altKey)Zu("mode-hint"),t()};if(e)document.addEventListener("keydown",a,!0);uo({id:"mode-hint",title:e?"Your mock is live":"You’re in Edit",description:e?"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:t})}function xs(e){return e.replace(ws,"")}function ube(e){return e.replace(ws,"")}function YA(e){let t=new Map;for(let s of e){if(!ws.test(s.name))continue;let o=ube(s.name);if(!t.has(o)||/\.tsx$/i.test(s.name))t.set(o,s)}let a=new Map,n=[];for(let s of e){if(ws.test(s.name))continue;let o=null;for(let i of t.keys()){if(s.name===i)continue;if(s.name.startsWith(`${i}.`)){if(!o||i.length>o.length)o=i}}if(o){let i=a.get(o)||[];i.push(s),a.set(o,i)}else n.push(s)}let r=[];for(let[s,o]of t){let i=(a.get(s)||[]).sort((u,c)=>u.name.localeCompare(c.name));r.push({primary:o,sidecars:i,orphan:!1})}return r.sort((s,o)=>s.primary.name.localeCompare(o.primary.name)),n.sort((s,o)=>s.name.localeCompare(o.name)),{canvases:r,orphans:n.map((s)=>({primary:s,sidecars:[],orphan:!0}))}}function JA(e,t,a){let n={};for(let r of a||[]){let o=(r.startsWith(t)?r.slice(t.length).replace(/^\/+/,""):r).split("/").filter(Boolean),i=n;for(let u of o)i=i[u]=i[u]||{};i._files=i._files||[]}for(let r of e){let o=(r.startsWith(t)?r.slice(t.length).replace(/^\/+/,""):r).split("/"),i=n;for(let u=0;u<o.length;u++){let c=o[u];if(u===o.length-1)i._files=i._files||[],i._files.push({name:c,path:r});else i[c]=i[c]||{},i=i[c]}}return n}function r2(e,t){if(!t)return e;let a=t.toLowerCase(),n={},r=!1,s=Object.keys(e).filter((o)=>o!=="_files");for(let o of s){let i=r2(e[o],t);if(i)n[o]=i,r=!0}if(e._files){let o=e._files.filter((i)=>i.name.toLowerCase().includes(a)||i.path.toLowerCase().includes(a));if(o.length)n._files=o,r=!0}return r?n:null}function kp(e){return(e||[]).filter((t)=>t.status!=="resolved").length}function eE(e){if(!e)return"";let t=new Date(e).getTime();if(!t)return"";let a=Math.max(0,Math.floor((Date.now()-t)/1000));if(a<60)return a+"s";let n=Math.floor(a/60);if(n<60)return n+"m";let r=Math.floor(n/60);if(r<24)return r+"h";let s=Math.floor(r/24);if(s<7)return s+"d";return new Date(e).toLocaleDateString()}function Gv(e){let t=0,a=0,n=0;for(let r of Object.values(e||{}))for(let s of r||[])if(t++,s.status==="resolved")n++;else a++;return{all:t,open:a,resolved:n}}var sn=({as:e,size:t=14})=>l(e,{size:t,strokeWidth:1.75,style:{display:"block"}});function Wh({d:e,size:t=14,color:a}){return l("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:a||"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{flex:"none"},children:l("path",{d:e})})}var cbe={"chevron-down":l("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":l("polyline",{points:"6 3.5 10.5 8 6 12.5"}),file:y(te,{children:[l("path",{d:"M4 2h5l3 3v9H4z"}),l("polyline",{points:"9 2 9 5 12 5"})]}),folder:l("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),"folder-plus":y(te,{children:[l("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),l("path",{d:"M8 7.5v3.5M6.25 9.25h3.5"})]}),lock:y(te,{children:[l("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),l("path",{d:"M5.5 7V5a2.5 2.5 0 015 0v2"})]}),unlock:y(te,{children:[l("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),l("path",{d:"M5.5 7V5a2.5 2.5 0 015-.7"})]}),search:y(te,{children:[l("circle",{cx:"7",cy:"7",r:"4"}),l("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:y(te,{children:[l("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),l("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),check:l("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),x:y(te,{children:[l("line",{x1:"4.3",y1:"4.3",x2:"11.7",y2:"11.7"}),l("line",{x1:"11.7",y1:"4.3",x2:"4.3",y2:"11.7"})]}),sun:y(te,{children:[l("circle",{cx:"8",cy:"8",r:"2.6"}),l("line",{x1:"8",y1:"1.5",x2:"8",y2:"3"}),l("line",{x1:"8",y1:"13",x2:"8",y2:"14.5"}),l("line",{x1:"1.5",y1:"8",x2:"3",y2:"8"}),l("line",{x1:"13",y1:"8",x2:"14.5",y2:"8"}),l("line",{x1:"3.4",y1:"3.4",x2:"4.4",y2:"4.4"}),l("line",{x1:"11.6",y1:"11.6",x2:"12.6",y2:"12.6"}),l("line",{x1:"12.6",y1:"3.4",x2:"11.6",y2:"4.4"}),l("line",{x1:"4.4",y1:"11.6",x2:"3.4",y2:"12.6"})]}),moon:l("path",{d:"M12.5 9.6A5 5 0 1 1 7 3a4 4 0 0 0 5.5 6.6z"}),sparkle:l("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:y(te,{children:[l("path",{d:"M2 6.7 11 4v8L2 9.3z"}),l("path",{d:"M11 5.2a2.4 2.4 0 0 1 0 5.6"}),l("path",{d:"M4.3 9.5v2.3a1.2 1.2 0 0 0 2.4 0v-1.7"})]}),bug:y(te,{children:[l("circle",{cx:"8",cy:"9",r:"3.6"}),l("circle",{cx:"8",cy:"4.4",r:"1.3"}),l("path",{d:"M6.2 3.4 5.2 2M9.8 3.4l1-1.4"}),l("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":y(te,{children:[l("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),l("line",{x1:"6.4",y1:"3",x2:"6.4",y2:"13"})]}),resolve:y(te,{children:[l("circle",{cx:"8",cy:"8",r:"5.6"}),l("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:y(te,{children:[l("path",{d:"M3.2 8a5 5 0 1 1 1.4 3.5"}),l("polyline",{points:"3.2 11.4 3.2 8 6.6 8"})]}),layers:y(te,{children:[l("polygon",{points:"8 2.2 13.8 5.5 8 8.8 2.2 5.5"}),l("polyline",{points:"2.2 9 8 12.3 13.8 9"})]}),box:l("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.2"}),type:y(te,{children:[l("polyline",{points:"4 4 12 4"}),l("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:y(te,{children:[l("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"3"}),l("line",{x1:"6",y1:"8",x2:"10",y2:"8"})]}),input:y(te,{children:[l("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"1.2"}),l("line",{x1:"5",y1:"8",x2:"5",y2:"8"})]}),link:y(te,{children:[l("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"}),l("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:y(te,{children:[l("line",{x1:"6",y1:"4.5",x2:"13",y2:"4.5"}),l("line",{x1:"6",y1:"8",x2:"13",y2:"8"}),l("line",{x1:"6",y1:"11.5",x2:"13",y2:"11.5"}),l("circle",{cx:"3.2",cy:"4.5",r:"0.8",fill:"currentColor"}),l("circle",{cx:"3.2",cy:"8",r:"0.8",fill:"currentColor"}),l("circle",{cx:"3.2",cy:"11.5",r:"0.8",fill:"currentColor"})]}),eye:y(te,{children:[l("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"}),l("circle",{cx:"8",cy:"8",r:"2"})]}),eyedropper:y(te,{children:[l("path",{d:"M11 2.6a1.7 1.7 0 0 1 2.4 2.4l-1.2 1.2-2.4-2.4z"}),l("path",{d:"M9.5 4.6 4 10.1V12h1.9l5.5-5.5"})]}),"p-corner":l("path",{d:"M3.5 12.5V7a3.5 3.5 0 0 1 3.5-3.5h5.5"}),"p-opacity":y(te,{children:[l("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.5"}),l("path",{d:"M3 8h10M8 3v10",strokeWidth:"0.9",opacity:"0.55"})]}),"p-lineheight":y(te,{children:[l("line",{x1:"6.5",y1:"4",x2:"13",y2:"4"}),l("line",{x1:"6.5",y1:"8",x2:"13",y2:"8"}),l("line",{x1:"6.5",y1:"12",x2:"13",y2:"12"}),l("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":y(te,{children:[l("path",{d:"M3 4v8M13 4v8"}),l("path",{d:"M6 11.5 8 5l2 6.5M6.7 9.3h2.6",strokeWidth:"1.1"})]}),"p-gap":y(te,{children:[l("rect",{x:"2",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),l("rect",{x:"10.4",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),l("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":l("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"}),"p-size":y(te,{children:[l("path",{d:"M3 13 6.6 3l3.6 10"}),l("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":y(te,{children:[l("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"}),l("line",{x1:"2.5",y1:"2.5",x2:"13.5",y2:"13.5"})]}),sliders:y(te,{children:[l("line",{x1:"3",y1:"5",x2:"13",y2:"5"}),l("circle",{cx:"6",cy:"5",r:"1.7",fill:"currentColor"}),l("line",{x1:"3",y1:"11",x2:"13",y2:"11"}),l("circle",{cx:"10",cy:"11",r:"1.7",fill:"currentColor"})]}),code:y(te,{children:[l("polyline",{points:"6 5 3 8 6 11"}),l("polyline",{points:"10 5 13 8 10 11"})]}),download:y(te,{children:[l("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),l("polyline",{points:"4.5 7 8 10.5 11.5 7"}),l("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),reload:y(te,{children:[l("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),l("path",{d:"M14 2v3.33h-3.33"})]}),help:y(te,{children:[l("circle",{cx:"8",cy:"8",r:"6"}),l("path",{d:"M6.3 6.2a1.8 1.8 0 1 1 2.3 1.9c-.5.2-.6.5-.6 1v.3"}),l("line",{x1:"8",y1:"11.4",x2:"8",y2:"11.5"})]}),image:y(te,{children:[l("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),l("circle",{cx:"6",cy:"6.3",r:"1.1"}),l("path",{d:"M3 12l3-2.8 2.2 1.8 2.4-3L13.5 12"})]}),vector:y(te,{children:[l("path",{d:"M3.6 11.2C6 5 10 5 12.4 11.2"}),l("rect",{x:"1.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),l("rect",{x:"11.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),l("rect",{x:"6.7",y:"2.6",width:"2.6",height:"2.6",rx:"0.4"})]}),presentation:y(te,{children:[l("rect",{x:"2.5",y:"3",width:"11",height:"7.4",rx:"1"}),l("line",{x1:"8",y1:"10.4",x2:"8",y2:"13"}),l("line",{x1:"5.6",y1:"13.4",x2:"10.4",y2:"13.4"})]}),archive:y(te,{children:[l("rect",{x:"2.5",y:"3",width:"11",height:"3",rx:"0.8"}),l("path",{d:"M3.6 6v6.2a1 1 0 0 0 1 1h6.8a1 1 0 0 0 1-1V6"}),l("line",{x1:"6.6",y1:"8.8",x2:"9.4",y2:"8.8"})]}),external:y(te,{children:[l("path",{d:"M11 8.5V12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h3.5"}),l("polyline",{points:"9.5 3 13 3 13 6.5"}),l("line",{x1:"13",y1:"3",x2:"7.6",y2:"8.4"})]}),share:y(te,{children:[l("circle",{cx:"4",cy:"8",r:"1.9"}),l("circle",{cx:"11.6",cy:"3.6",r:"1.9"}),l("circle",{cx:"11.6",cy:"12.4",r:"1.9"}),l("line",{x1:"5.7",y1:"7",x2:"9.9",y2:"4.6"}),l("line",{x1:"5.7",y1:"9",x2:"9.9",y2:"11.4"})]}),pen:y(te,{children:[l("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"}),l("line",{x1:"9.6",y1:"4.2",x2:"11.8",y2:"6.4"})]}),square:l("rect",{x:"3.5",y:"3.5",width:"9",height:"9",rx:"1"})};function ga({name:e,size:t=16,className:a}){return l("svg",{className:a,width:t,height:t,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:cbe[e]})}function bj(e){if(!e||typeof e!=="string")return"?";let t=e.trim().split(/[\s._-]+/).filter(Boolean);if(!t.length)return"?";if(t.length===1)return t[0].slice(0,2).toUpperCase();return((t[0][0]||"")+(t[t.length-1][0]||"")).toUpperCase()||"?"}function tE({initials:e,hue:t,title:a,pulse:n}){return l("span",{className:"st-avatar"+(n?" is-pulsing":""),style:{"--av-hue":t},"data-tip":a,"aria-label":a,children:e})}function Gn({children:e}){return l("span",{className:"kbd",children:e})}var Kh=[{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"}],Wl={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",sync:"right",assistant:"right"};function aE({side:e,width:t,open:a,ids:n,activeId:r,onPick:s,children:o,labels:i=null}){return y("div",{className:"st-dockslot st-dockslot--"+e+(a?"":" is-collapsed"),style:{width:a?t:0,flexBasis:a?t:0},children:[a&&n.length>1&&l("div",{className:"st-docktabs",role:"tablist","aria-label":e+" panels",children:n.map((u)=>l("button",{type:"button",role:"tab","data-testid":`dock-tab-${u}`,"aria-selected":r===u,className:"st-docktab"+(r===u?" is-active":""),onClick:()=>s(u),children:i?.[u]||(Kh.find((c)=>c.id===u)||{}).label||u},u))}),o]})}function s2(e,{min:t,max:a,def:n}){let r=ce((u)=>Math.min(a,Math.max(t,u)),[t,a]),[s,o]=P(()=>{try{let u=parseInt(localStorage.getItem(e)||"",10);return Number.isFinite(u)?r(u):n}catch{return n}});ee(()=>{try{localStorage.setItem(e,String(s))}catch{}},[e,s]);let i=ce((u)=>o((c)=>r(typeof u==="function"?u(c):u)),[r]);return{w:s,setW:i,min:t,max:a,def:n}}function nE({label:e,size:t,onPointerDown:a,active:n,dir:r="ltr"}){let{w:s,setW:o,min:i,max:u,def:c}=t,f=r==="rtl"?-1:1;return l("div",{className:"st-grip"+(n?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":e,"aria-valuemin":i,"aria-valuemax":u,"aria-valuenow":Math.round(s),onPointerDown:a,onDoubleClick:()=>o(c),onKeyDown:(p)=>{let m=p.shiftKey?24:8;if(p.key==="ArrowRight")p.preventDefault(),o((h)=>h+m*f);else if(p.key==="ArrowLeft")p.preventDefault(),o((h)=>h-m*f);else if(p.key==="Home")p.preventDefault(),o(i);else if(p.key==="End")p.preventDefault(),o(u)},children:y("svg",{className:"st-grip-dots",viewBox:"0 0 6 18","aria-hidden":"true",children:[l("circle",{cx:"3",cy:"3",r:"1.1",fill:"currentColor"}),l("circle",{cx:"3",cy:"9",r:"1.1",fill:"currentColor"}),l("circle",{cx:"3",cy:"15",r:"1.1",fill:"currentColor"})]})})}function vj({open:e,onClose:t,actions:a}){let[n,r]=P(""),[s,o]=P(0),i=me(null);ee(()=>{if(e)r(""),o(0)},[e]),ee(()=>{i.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[s]);let u=Kt(()=>sb(a,n),[n,a]);if(ee(()=>{if(s>=u.length)o(0)},[u.length,s]),!e)return null;let c=(f)=>{t(),f.run()};return l("div",{className:"st-scrim",role:"presentation",onMouseDown:(f)=>{if(f.target===f.currentTarget)t()},children:y("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[y("div",{className:"st-pal-search",children:[l(ga,{name:"search",size:18}),l("input",{autoFocus:!0,placeholder:"Type a command or search…",value:n,"aria-label":"Command search",onChange:(f)=>r(f.target.value),onKeyDown:(f)=>{if(f.key==="Escape")f.preventDefault(),t();else if(f.key==="ArrowDown")f.preventDefault(),o((p)=>Math.min(u.length-1,p+1));else if(f.key==="ArrowUp")f.preventDefault(),o((p)=>Math.max(0,p-1));else if(f.key==="Enter"){f.preventDefault();let p=EI(a,n,f.currentTarget.value,s);if(p)c(p)}}}),l(Gn,{children:"⌘K"})]}),l("div",{className:"st-pal-list",ref:i,children:u.length===0?l("div",{className:"st-pal-empty",children:"No matching command."}):u.map((f,p)=>{let m=f.group&&(p===0||u[p-1].group!==f.group)?l("div",{className:"st-pal-group",children:f.group},"g-"+f.group):null;return y(Jn,{children:[m,y("button",{type:"button",className:"st-pal-item"+(p===s?" is-active":""),onMouseEnter:()=>o(p),onClick:()=>c(f),children:[l("span",{className:"st-pal-icon",children:l(ga,{name:f.icon,size:15})}),l("span",{className:"st-pal-label",children:f.label}),f.kbd?l("span",{className:"st-pal-kbd",children:l(Gn,{children:f.kbd})}):null]})]},f.id)})})]})})}var dbe={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 wj(e){let t=String(e||"").split(".").pop()?.toLowerCase();return dbe[t]||"application/octet-stream"}function xj({designRel:e,onPick:t,onClose:a,multiple:n=!1,hasArtboardAnchor:r=!1,onPickMany:s}){let[o,i]=P(null),[u,c]=P(!1),[f,p]=P(null),[m,h]=P(null),[b,w]=P(()=>new Set),[S,_]=P({}),[v,k]=P(r?"artboard":"annotation");ee(()=>{let z=!0;return fetch("/_api/assets").then((M)=>M.json()).then((M)=>{if(!z)return;let F=M.ok?M.assets:[];i(F),_((X)=>{let K={...X};for(let ie of F)K[ie.path]=ie.kind;return K})}).catch(()=>z&&i([])),()=>{z=!1}},[]),ee(()=>{let z=(M)=>{if(M.key==="Escape")M.stopPropagation(),a()};return window.addEventListener("keydown",z,!0),()=>window.removeEventListener("keydown",z,!0)},[a]);let I=Array.from(b).some((z)=>(S[z]||"image")!=="image"),A=!r||I,N=!r?"No artboard on this canvas":I?"Video/audio can only be added as annotations":"";ee(()=>{if(A&&v==="artboard")k("annotation")},[A,v]);let E=(z)=>{w((M)=>{let F=new Set(M);if(F.has(z))F.delete(z);else F.add(z);return F})},R=async(z)=>{let M=await LA(z,{onProgress:p});return p(null),"path"in M?{ok:!0,path:M.path}:{ok:!1,error:M.error}},O=async(z)=>{if(!z)return;c(!0),h(null);let M=await R(z);if(c(!1),M.ok)t(M.path);else h(M.error)},H=(z)=>{if(typeof z==="string"&&z.startsWith("video/"))return"video";if(typeof z==="string"&&z.startsWith("audio/"))return"audio";return"image"},V=async(z)=>{if(!z.length)return;c(!0),h(null);let M=await Promise.all(z.map((K)=>R(K).then((ie)=>({...ie,file:K}))));c(!1);let F=M.filter((K)=>K.ok),X=M.length-F.length;if(X>0)h(`${X} of ${M.length} uploads failed`);if(F.length)_((K)=>{let ie={...K};for(let G of F)ie[G.path]=H(G.file.type);return ie}),w((K)=>{let ie=new Set(K);for(let G of F)ie.add(G.path);return ie})},q=async()=>{c(!0),h(null);try{if(n){let F=(await m3()||[]).map((X)=>Qb(X,wj(X.name)));c(!1);try{if(F.length)await V(F)}finally{for(let X of F)X.release()}return}let z=await dd();if(z){let M=Qb(z,wj(z.name));try{await O(M)}finally{M.release()}return}}catch(z){h(z?.message||"open failed")}c(!1)},D=()=>{if(na()){q();return}let z=document.createElement("input");if(z.type="file",z.accept="image/*,video/*",n)z.multiple=!0;z.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(z);let M=()=>{if(z.isConnected)z.remove()};window.addEventListener("focus",()=>setTimeout(M,300),{once:!0}),z.addEventListener("change",()=>{let F=z.files?Array.from(z.files):[];if(M(),!F.length)return;if(n)V(F);else O(F[0])}),z.click()},U=(z)=>`/${e}/${z}`;return l("div",{className:"st-scrim",role:"presentation",onMouseDown:(z)=>{if(z.target===z.currentTarget)a()},children:y("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[y("div",{className:"st-dialog-hd",children:[l("span",{className:"st-dialog-title",children:"Choose media"}),l("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:a,children:l(ga,{name:"x",size:15})})]}),y("div",{className:"st-dialog-bd",children:[y("div",{className:"st-ap-toolbar",children:[l("button",{type:"button",className:"st-btn",onClick:D,disabled:u,children:u?f==null?"Uploading…":`Uploading… ${Math.round(f*100)}%`:"Upload…"}),m&&l("span",{className:"st-ap-err",children:m})]}),l("div",{className:"st-ap-grid",children:o==null?l("div",{className:"st-ap-empty",children:"Loading…"}):o.length===0?l("div",{className:"st-ap-empty",children:"No assets yet — upload one."}):o.map((z)=>{let M=n&&b.has(z.path);return y("button",{type:"button",className:"st-ap-cell","data-selected":M?"true":void 0,"aria-pressed":n?M:void 0,title:`${z.name} · ${Math.max(1,Math.round(z.size/1024))} KB`,onClick:()=>n?E(z.path):t(z.path),children:[n&&l("span",{className:"st-ap-check","aria-hidden":"true",children:M?l(ga,{name:"check",size:12}):null}),z.kind==="video"?l("video",{className:"st-ap-thumb",src:U(z.path),muted:!0,playsInline:!0}):l("img",{className:"st-ap-thumb",src:U(z.path),alt:z.name,loading:"lazy"}),l("span",{className:"st-ap-name",children:z.name})]},z.path)})})]}),n&&b.size>0&&y("div",{className:"st-dialog-ft st-ap-confirm",children:[y("span",{className:"st-ap-count",children:[b.size," selected"]}),y("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[l("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":v==="artboard",disabled:A,onClick:()=>k("artboard"),children:"Add to artboard"}),l("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":v==="annotation",onClick:()=>k("annotation"),children:"Add as annotation"})]}),A&&l("span",{className:"st-ap-dest-note",children:N}),l("span",{className:"st-ap-confirm-spacer"}),l("button",{type:"button",className:"btn btn--ghost",onClick:a,children:"Cancel"}),l("button",{type:"button",className:"btn btn--primary",onClick:()=>s?.(Array.from(b),v),children:"Insert"})]})]})})}var rE=[{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}],_j={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","canvas-whole":"Whole canvas · one image","selection-bounds":"Selection area · one image","project-raw":"Whole project (raw)"},Sj=new Set(["canvas-whole","selection-bounds"]),fbe=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],Wv=[{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}],pbe="2x",Cj=[{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}],mbe="auto",kj=[{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."}],hbe="keep";function Qh(e,t){let a=URL.createObjectURL(t),n=document.createElement("a");n.href=a,n.download=e||"export",document.body.appendChild(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(a),1e4)}function Ij({mode:e,initialScope:t,activePath:a,hasComps:n=!1,comps:r=[],activeArtboardId:s=null,selection:o=null,exportLane:i="local",onBrowserCapture:u=null,onQuerySelection:c=null,onClose:f}){let p=ce((_e)=>i==="none"&&!_e.handoff&&_e.format!=="zip"&&!UI.has(_e.format)||i!=="local"&&_e.format==="canva",[i]),[m,h]=P(e==="handoff"?"shadcn":"png"),[b,w]=P(()=>t&&NI("png",t)?t:M1("png")),[S,_]=P(2),[v,k]=P(pbe),[I,A]=P(!0),[N,E]=P(!1),[R,O]=P(!1),[H,V]=P(!1),[q,D]=P(mbe),[U,z]=P(hbe),[M,F]=P(!1),[X,K]=P(!0),[ie,G]=P(!1),[se,Z]=P(null),[pe,oe]=P([]),ye=rE.find((_e)=>_e.id===m)||rE[0],Je=ye.handoff?[]:R1(ye.format),Ke=900,ot=3600,yt=Yu(r,Lv(r,{artboardId:s})),rt=yt?.durationInFrames||0,nt=yt?.fps||30,bt=ye.temporal&&rt>900,kt=ye.temporal&&rt>3600;ee(()=>{if(Je.length&&!Je.includes(b))w(M1(ye.format))},[Je,b,ye.format]),ee(()=>{if(i!=="remote")return;fetch("/_api/export-warmup").catch(()=>{})},[i]);let Se=ce(()=>{fetch("/_api/export-history").then((_e)=>_e.json()).then((_e)=>oe(Array.isArray(_e?.history)?_e.history.slice(0,6):[])).catch(()=>{})},[]);ee(()=>{Se()},[Se]),ee(()=>{function _e(Ye){if(Ye.key==="Escape")Ye.preventDefault(),f()}return window.addEventListener("keydown",_e),()=>window.removeEventListener("keydown",_e)},[f]);async function qe(){if(ye.handoff){let ht=`/design:handoff ${a&&a!==Ft?a:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(ht)}catch{}Z({ok:!0,msg:`Copied: ${ht} — run it in Claude Code.`});return}if(p(ye)){Z({ok:!1,msg:"This format needs the render service, which this workspace doesn’t have configured."});return}G(!0),Z(null);let _e=ye.temporal?{scale:S}:{};if(ye.format==="png"){let He=Wv.find((ht)=>ht.id===v)||Wv[1];if(He.kind==="dpi")_e.dpi=He.value;else _e.scale=He.value}if(ye.format==="mp4"||ye.format==="webm")_e.audio=X;if(kt)_e.maxFrames=rt;if(ye.format==="pdf"){_e.pdfPrint={includeBleed:I,marks:{crop:R,registration:H}};let He=Cj.find((ht)=>ht.id===q)?.value;if(He!==void 0)_e.dpi=He;if(U!=="keep")_e.text=U}if(s)_e.artboardId=s;if(o?.selector)_e.selection=o;if(Sj.has(b)&&M)_e.includeAnnotations=!0;if(b==="selection-bounds"&&typeof c==="function"){let He=await c();if(He?.length)_e.selectionAll=He}if(a&&a!==Ft)_e.canvasFile=a;if(lb.has(ye.format)&&lh({exportLane:i,format:ye.format,scope:b,artboardId:_e.artboardId})&&typeof u==="function")try{let He=db(_e);Z({ok:!0,msg:"Capturing…"});let ht=await u({format:ye.format,artboardIds:[_e.artboardId],scale:He,onProgress:(Ne,At)=>Z({ok:!0,msg:`Capturing ${Ne}/${At}…`})}),Xt=await cb(ht,ye.format);for(let Ne of Xt)Qh(Ne.name,Ne.blob);for(let Ne of Xt)await B1({format:ye.format,scope:b,filename:Ne.name});G(!1),Z({ok:!0,msg:`Saved ${Xt.map((Ne)=>Ne.name).join(", ")} to your downloads.`});return}catch(He){if(i!=="remote"){Z({ok:!1,msg:`Capture failed: ${He&&He.message||He}`}),G(!1);return}}if(lh({exportLane:i,format:ye.format,scope:b})&&ye.format==="pptx"&&typeof u==="function")try{Z({ok:!0,msg:"Capturing artboards…"});let He=a&&a!==Ft?us(a).replace(/\.[^.]+$/,""):"export",{filename:ht,blob:Xt}=await ub({capture:u,name:He,onProgress:(Ne,At)=>Z({ok:!0,msg:`Capturing ${Ne}/${At}…`}),onAssemble:()=>Z({ok:!0,msg:"Assembling deck…"})});Qh(ht,Xt),await B1({format:ye.format,scope:b,filename:ht}),G(!1),Z({ok:!0,msg:`Saved ${ht} to your downloads.`});return}catch(He){if(i!=="remote"){Z({ok:!1,msg:`Deck export failed: ${He&&He.message||He}`}),G(!1);return}}if(i==="none"&&lb.has(ye.format)){Z({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."}),G(!1);return}try{let He=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:ye.format,scope:b,options:_e})});if(!He.ok){Z({ok:!1,msg:await He.text()||`Export failed (${He.status})`}),G(!1);return}f()}catch(He){Z({ok:!1,msg:He&&He.message?He.message:String(He)}),G(!1)}}return l("div",{className:"st-scrim",role:"presentation",onMouseDown:(_e)=>{if(_e.target===_e.currentTarget)f()},children:y("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[y("div",{className:"st-dialog-hd",children:[l("span",{className:"st-dialog-title",children:"Export & handoff"}),l("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:f,children:l(ga,{name:"x",size:15})})]}),y("div",{className:"st-dialog-bd",children:[l("div",{className:"st-rp-hd",children:a&&a!==Ft?`Format · ${xs(us(a))}`:"Format"}),l("div",{className:"st-fmt-grid",children:rE.filter((_e)=>!_e.temporal||n).map((_e)=>y("button",{type:"button","data-testid":`export-format-${_e.id}`,className:"st-fmt"+(_e.id===m?" is-on":""),disabled:p(_e),title:p(_e)?"Needs the render service — not configured on this workspace":void 0,onClick:()=>{h(_e.id),Z(null)},children:[l(ga,{name:_e.icon,size:16}),l("span",{className:"st-fmt-name",children:_e.label}),l("span",{className:"st-fmt-sub",children:_e.sub})]},_e.id))}),i==="none"&&y("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 ",l("code",{children:" maude-render"})," service (see the self-hosting docs)."]}),!ye.handoff&&y("div",{className:"st-dialog-row",children:[l("label",{className:"st-dialog-lbl",htmlFor:"st-export-scope",children:"Scope"}),l("select",{id:"st-export-scope","data-testid":"export-scope",className:"st-select",value:b,onChange:(_e)=>w(_e.target.value),children:Je.map((_e)=>l("option",{value:_e,children:_j[_e]},_e))})]}),!ye.handoff&&Sj.has(b)&&y("div",{className:"st-dialog-row",children:[l("label",{className:"st-dialog-lbl",htmlFor:"st-export-annotations",children:"Annotations"}),y("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[l("input",{id:"st-export-annotations",type:"checkbox","data-testid":"export-include-annotations",checked:M,onChange:(_e)=>F(_e.target.checked)}),"Include annotations"]})]}),!ye.handoff&&ye.format==="png"&&y("div",{className:"st-dialog-row",children:[l("label",{className:"st-dialog-lbl",htmlFor:"st-export-size",children:"Resolution"}),l("select",{id:"st-export-size",className:"st-select",value:v,onChange:(_e)=>k(_e.target.value),children:Wv.map((_e)=>l("option",{value:_e.id,children:_e.label},_e.id))})]}),!ye.handoff&&ye.format==="png"&&l("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let _e=Wv.find((He)=>He.id===v)||Wv[1],Ye=_e.kind==="dpi"?_e.value/96:_e.value;return`${_e.label} ≈ ${Math.round(1440*Ye)}×${Math.round(900*Ye)} for a 1440×900 artboard.`})()}),!ye.handoff&&ye.temporal&&y("div",{className:"st-dialog-row",children:[l("label",{className:"st-dialog-lbl",htmlFor:"st-export-temporal-size",children:"Resolution"}),l("select",{id:"st-export-temporal-size",className:"st-select",value:S,onChange:(_e)=>_(Number(_e.target.value)),children:fbe.map((_e)=>l("option",{value:_e.value,children:_e.label},_e.value))})]}),!ye.handoff&&ye.temporal&&y("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[S,"× the artboard's native resolution (e.g. 960×540 → ",960*S,"×",540*S,")."]}),bt&&y("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: ",rt," frames (≈",Math.round(rt/nt),"s).",kt?` 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."]}),!ye.handoff&&ye.format==="pdf"&&y(te,{children:[y("div",{className:"st-dialog-row",children:[l("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-dpi",children:"Image quality"}),l("select",{id:"st-export-pdf-dpi",className:"st-select",value:q,onChange:(_e)=>D(_e.target.value),children:Cj.map((_e)=>l("option",{value:_e.id,children:_e.label},_e.id))})]}),l("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)."}),y("div",{className:"st-dialog-row",children:[l("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-text",children:"Text"}),l("select",{id:"st-export-pdf-text",className:"st-select","data-testid":"export-pdf-text",value:U,onChange:(_e)=>z(_e.target.value),children:kj.map((_e)=>l("option",{value:_e.id,children:_e.label},_e.id))})]}),l("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:kj.find((_e)=>_e.id===U)?.description}),l("div",{className:"st-dialog-row",children:y("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-bleed",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[l("input",{id:"st-export-pdf-bleed",type:"checkbox",checked:I,onChange:(_e)=>A(_e.target.checked)}),"Include bleed"]})}),l("div",{className:"st-dialog-row",children:y("button",{type:"button",className:"st-dialog-lbl",style:{background:"none",border:0,padding:0,cursor:"pointer"},onClick:()=>E((_e)=>!_e),"aria-expanded":N,children:[N?"▾":"▸"," Marks"]})}),N&&y("div",{style:{padding:"0 12px 4px",display:"flex",flexDirection:"column",gap:6},children:[y("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[l("input",{type:"checkbox",checked:R,onChange:(_e)=>O(_e.target.checked)}),"Crop marks"]}),y("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[l("input",{type:"checkbox",checked:H,onChange:(_e)=>V(_e.target.checked)}),"Registration marks"]})]}),y("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:["Bleed and marks apply to print (",l("code",{children:'kind="print"'}),") artboards only.",b==="canvas-as-separate"?" One PDF page per artboard.":""]})]}),!ye.handoff&&(ye.format==="mp4"||ye.format==="webm")&&l("div",{className:"st-dialog-row",children:y("label",{className:"st-dialog-lbl",htmlFor:"st-export-audio",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[l("input",{id:"st-export-audio",type:"checkbox",checked:X,onChange:(_e)=>K(_e.target.checked)}),"Export with audio"]})}),ye.handoff&&y("div",{className:"callout callout--info",style:{fontSize:12},children:["Hands the active canvas off to production. Copies"," ",l("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."]}),se&&l("div",{className:"callout "+(se.ok?"callout--success":"callout--error"),style:{fontSize:12},"data-testid":"export-status","data-ok":se.ok?"1":"0",children:se.msg}),pe.length>0&&y("div",{className:"st-export-recent","data-testid":"export-recent",children:[l("div",{className:"st-rp-hd",children:"Recent"}),pe.map((_e,Ye)=>y("div",{className:"st-export-recent-row",children:[y("span",{children:[String(_e.format||"").toUpperCase()," ·"," ",_j[_e.scope]||_e.scope]}),l("span",{className:"st-mono",children:_e.filename})]},Ye))]})]}),y("div",{className:"st-dialog-ft",children:[l("button",{type:"button",className:"btn btn--ghost",onClick:f,children:"Cancel"}),y("button",{type:"button",className:"btn btn--primary","data-testid":"export-submit",disabled:ie,onClick:qe,children:[l(ga,{name:"download",size:14}),ye.handoff?"Copy handoff command":ie?"Exporting…":`Export ${ye.label}`]})]})]})})}var l2=12,u2=16;function gbe({name:e,depth:t,children:a,dirPath:n,drag:r,menu:s,expansion:o,forceOpen:i}){let u=!!i||!!o?.isOpen(n),c=(S)=>{if(i)return;let _=typeof S==="function"?S(u):S;if(_!==u)o?.setOpen(n,_)},f=r?r.dropProps(n,!0,()=>c(!0)):{},p=r?.overDir===n,m=r?r.dragProps(n,!0):{},h=r?.draggedPath===n,b=r?.busyPath===n,w=y("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${Cp(n)}`,"aria-expanded":u,"aria-dropeffect":r?"move":void 0,"aria-busy":b||void 0,tabIndex:-1,className:"st-row"+(p?" is-drop-target":"")+(h?" is-dragging":"")+(b?" is-busy":""),style:{paddingLeft:l2+t*u2+"px"},onClick:()=>c((S)=>!S),onContextMenu:s?(S)=>s.openAt(S,{kind:"dir",dirPath:n}):void 0,...m,...f,children:[l("span",{className:"st-row-glyph",children:l(ga,{name:"chevron-right",className:"st-chev"+(u?" is-open":""),size:13})}),l("span",{className:"st-row-name",children:e})]});return l(Jf,{label:e,row:w,expanded:u,busy:b,onToggle:()=>c((S)=>!S),actions:s?l("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${Cp(n)}`,title:`Folder actions — ${e}`,"aria-label":`Folder actions for ${e}`,"aria-haspopup":"menu",onClick:(S)=>s.openAt(S,{kind:"dir",dirPath:n}),children:l(Wh,{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:u&&a})}function ybe({name:e,dsName:t,dirPath:a,depth:n,active:r,onOpenSystem:s,children:o,expansion:i,forceOpen:u}){let c=!!u||!!i?.isOpen(a),f=(p)=>{if(u)return;let m=typeof p==="function"?p(c):p;if(m!==c)i?.setOpen(a,m)};return l(Jf,{label:e,expanded:c,selected:r,onToggle:()=>f((p)=>!p),row:y("div",{className:"st-row st-ds-folder"+(r?" is-sel":""),style:{paddingLeft:l2+n*u2+"px"},children:[l("button",{type:"button",className:"st-ds-chev",onClick:()=>f((p)=>!p),"aria-label":c?"Collapse design system":"Expand design system",title:c?"Collapse":"Expand",children:l(ga,{name:"chevron-right",className:"st-chev"+(c?" is-open":""),size:13})}),y("button",{type:"button",className:"st-ds-open","data-tree-primary":"",tabIndex:-1,onClick:()=>s(t),"aria-label":`Open ${t} design system view`,title:"Open the design system view",children:[l("span",{className:"st-row-glyph",children:l(ga,{name:"folder",size:13})}),l("span",{className:"st-row-name",children:e})]})]}),children:c&&o})}function i2({file:e,activePath:t,previewPath:a,onOpen:n,onPreview:r,onDelete:s,openCount:o,depth:i,kind:u,sidecar:c,dirty:f,experimentalKind:p,drag:m,menu:h}){let b=e.path===t||e.path===a,w=ws.test(e.name),S=!w&&u!=="runtime"?$d(e.name):null,_=!w&&!S,v=w?xs(e.name):e.name,k=w&&typeof s==="function"&&u!=="runtime",I=w&&!c&&u!=="runtime"&&typeof m<"u",A=I?m.dragProps(e.path,!0):{},N=m?.draggedPath===e.path,E=m?.busyPath===e.path,R=I&&typeof h<"u",O=!w&&!!S&&!c&&typeof h<"u",H=typeof h<"u"&&u!=="runtime",V=e.path.split("/").slice(0,-1).join("/"),q=w?"canvas-row-"+e.path.replace(/^\.[^/]+\//,"").replace(ws,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,D=y("button",{type:"button",role:"treeitem","data-testid":q??(O?`file-row-${Cp(e.path)}`:void 0),"aria-selected":b,"aria-disabled":_?"true":void 0,"aria-busy":E||void 0,tabIndex:b?0:-1,className:"st-row"+(b?" is-sel":"")+(u==="runtime"?" is-muted":"")+(N?" is-dragging":"")+(E?" is-busy":""),style:{paddingLeft:l2+i*u2+"px"},title:e.path+(o?` — ${o} open`:_?" (file index only)":""),onClick:()=>{if(w)n(e.path);else if(S)r?.(e.path)},onPointerEnter:S==="image"?()=>D_(e.path):void 0,onFocus:S==="image"?()=>D_(e.path):void 0,onContextMenu:H?(U)=>h.openAt(U,{kind:"file",path:e.path,dir:V,canMove:R||O,supporting:O,name:e.name}):void 0,...A,children:[l("span",{className:"st-row-glyph",children:l(ga,{name:"file",size:13})}),l("span",{className:"st-row-name",children:v}),p==="reconstructed-experimental"&&l("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"}),p==="imported-figma"&&l("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"}),f&&l("span",{className:"st-git-badge","data-kind":f,title:`Unsaved (${f})`,"aria-label":`Unsaved, ${f}`,children:f}),o>0&&l("span",{className:"st-row-badge",children:o})]});return l(Jf,{label:v,row:D,selected:b,disabled:_,busy:E,actions:y(te,{children:[H&&l("button",{type:"button",className:"st-row-menu-btn"+(k?" has-delete-sibling":""),"data-testid":`tree-row-menu-${Cp(e.path)}`,title:`Actions for ${v}`,"aria-label":`Actions for ${v}`,"aria-haspopup":"menu",onClick:(U)=>h.openAt(U,{kind:"file",path:e.path,dir:V,canMove:R||O,supporting:O,name:e.name}),children:l(Wh,{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})}),k&&l("button",{type:"button",className:"st-row-del",title:`Delete ${v}`,"aria-label":`Delete canvas ${v}`,onClick:(U)=>{U.stopPropagation(),s(e.path,v)},children:l(Wh,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})})}function bbe({primary:e,sidecars:t,depth:a,kind:n,activePath:r,previewPath:s,onOpen:o,onPreview:i,onDelete:u,openCount:c,showHidden:f,forceOpen:p,dirtyByPath:m,experimentalKind:h,drag:b,menu:w}){let S=m?.get(e.path),_=t.length>0,[v,k]=P(!1),I=p||v,A=e.path===r;if(!(_&&f))return l(i2,{file:e,activePath:r,previewPath:s,onOpen:o,onPreview:i,onDelete:u,openCount:c,depth:a,kind:n,dirty:S,experimentalKind:h,drag:b,menu:w});let E=typeof b<"u",R=E?b.dragProps(e.path,!0):{},O=b?.draggedPath===e.path,H=b?.busyPath===e.path,V=E&&typeof w<"u",q=typeof w<"u"&&n!=="runtime",D=e.path.split("/").slice(0,-1).join("/"),U=y("button",{type:"button",role:"treeitem","aria-selected":A,"aria-expanded":I,"aria-busy":H||void 0,tabIndex:A?0:-1,className:"st-row st-canvas-row"+(A?" is-sel":"")+(O?" is-dragging":"")+(H?" is-busy":""),style:{paddingLeft:l2+a*u2+"px"},title:e.path,onClick:(z)=>{if(z.target.closest(".st-canvas-chev")){k((M)=>!M);return}o(e.path)},onContextMenu:q?(z)=>w.openAt(z,{kind:"file",path:e.path,dir:D,canMove:V}):void 0,...R,children:[l("span",{className:"st-row-glyph st-canvas-chev",onClick:(z)=>{z.stopPropagation(),k((M)=>!M)},children:l(ga,{name:"chevron-right",className:"st-chev"+(I?" is-open":""),size:13})}),l("span",{className:"st-row-name",children:xs(e.name)}),h==="reconstructed-experimental"&&l("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"}),h==="imported-figma"&&l("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"}),S&&l("span",{className:"st-git-badge","data-kind":S,title:`Unsaved (${S})`,"aria-label":`Unsaved, ${S}`,children:S}),c>0&&l("span",{className:"st-row-badge",children:c})]});return l(Jf,{label:xs(e.name),row:U,selected:A,expanded:I,busy:H,onToggle:()=>k((z)=>!z),actions:q?l("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${Cp(e.path)}`,title:`Actions for ${xs(e.name)}`,"aria-label":`Actions for ${xs(e.name)}`,"aria-haspopup":"menu",onClick:(z)=>w.openAt(z,{kind:"file",path:e.path,dir:D,canMove:V}),children:l(Wh,{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:I&&t.map((z)=>l(i2,{file:z,menu:w,activePath:r,previewPath:s,onOpen:o,onPreview:i,openCount:0,depth:a+1,kind:n,sidecar:!0},z.path))})}function Tj({node:e,activePath:t,previewPath:a,onOpen:n,onPreview:r,commentsByFile:s,depth:o=1,kind:i,showHidden:u,search:c,dsFolders:f,activeDsName:p,onOpenSystem:m,onDelete:h,dirtyByPath:b,canvasKinds:w,dirPath:S="",drag:_,menu:v,expansion:k}){let I=Object.keys(e).filter((q)=>q!=="_files").sort(),A=e._files||[],{canvases:N,orphans:E}=Kt(()=>YA(A),[A]),{mediaOrphans:R,metaOrphans:O}=Kt(()=>{let q=[],D=[];for(let U of E){let z=$d(U.primary.name);(z==="image"||z==="video"||z==="audio"||z==="font"?q:D).push(U)}return{mediaOrphans:q,metaOrphans:D}},[E]),H=!!(c&&c.trim()),V=Kt(()=>{if(!f||o!==1)return null;let q=new Map;for(let D of f)q.set(D.folder,D);return q},[f,o]);return y(Jn,{children:[N.map((q)=>{let D=H&&q.sidecars.some((U)=>{let z=c.toLowerCase();return U.name.toLowerCase().includes(z)||U.path.toLowerCase().includes(z)});return l(bbe,{primary:q.primary,sidecars:q.sidecars,activePath:t,previewPath:a,onOpen:n,onPreview:r,onDelete:h,openCount:kp(s[q.primary.path]),depth:o,kind:i,showHidden:u,forceOpen:D,dirtyByPath:b,experimentalKind:w?.[q.primary.path],drag:_,menu:v},q.primary.path)}),R.map((q)=>l(i2,{file:q.primary,menu:v,activePath:t,previewPath:a,onOpen:n,onPreview:r,openCount:kp(s[q.primary.path]),depth:o,kind:i},q.primary.path)),u&&O.map((q)=>l(i2,{file:q.primary,menu:v,activePath:t,previewPath:a,onOpen:n,onPreview:r,openCount:kp(s[q.primary.path]),depth:o,kind:i},q.primary.path)),I.map((q)=>{let D=V?.get(q),U=S?`${S}/${q}`:q,z=l(Tj,{node:e[q],activePath:t,previewPath:a,onOpen:n,onPreview:r,commentsByFile:s,depth:o+1,kind:i,showHidden:u,search:c,activeDsName:p,onOpenSystem:m,onDelete:h,dirtyByPath:b,canvasKinds:w,dirPath:U,drag:_,menu:v,expansion:k});if(D&&m)return l(ybe,{name:q,dsName:D.name,dirPath:U,depth:o,expansion:k,forceOpen:H,active:t===Ft&&D.name===p,onOpenSystem:m,children:z},q);return l(gbe,{name:q,depth:o,dirPath:U,expansion:k,forceOpen:H,drag:_,menu:_?v:void 0,children:z},q)})]})}var o2={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function vbe(e){if(e.kind==="project")return o2.project;if(e.kind==="runtime")return o2.runtime;if(e.label==="Design system")return o2.ds;if(e.label==="UI kit")return o2.canvas;return{title:e.label.toUpperCase(),pillFromCount:!0}}function wbe({failures:e,cloud:t}){let[a,n]=P(!1);ee(()=>{let s=setTimeout(()=>n(!0),3000);return()=>clearTimeout(s)},[]);let r=e>0?"The project is taking a while to answer — trying again…":t?"Still loading — a large cloud project can take a few seconds to list.":"Still loading — a large project can take a few seconds to list.";return y("div",{className:"st-tree-loading",role:"status","aria-live":"polite","data-testid":"tree-loading",children:[y("div",{className:"st-tree-loading-head",children:[l("span",{className:"st-canvas-loading-spinner","aria-hidden":"true"}),l("span",{children:"Loading files…"})]}),[64,48,72,40,56,68,44].map((s,o)=>l("span",{className:"skel st-tree-loading-row",style:{width:`${s}%`,marginLeft:o%3?22:8},"aria-hidden":"true"},o)),(a||e>0)&&l("div",{className:"st-tree-loading-hint",children:r})]})}function sE({readOnly:e=!1,cloud:t,groups:a,activePath:n,previewPath:r,activeDsName:s,onOpen:o,onPreview:i,onOpenSystem:u,wsConnected:c,search:f,setSearch:p,commentsByFile:m,showHidden:h,sectionsExpanded:b,onToggleSection:w,treeExpansion:S,onNewBoard:_,onDeleteBoard:v,onRefresh:k,refreshing:I,collapsed:A,onCollapse:N,width:E,resizing:R,dirtyByPath:O,project:H,gitBranch:V,remoteSync:q,onGetLatest:D,canvasKinds:U,onMoveCanvas:z,onNewFolder:M,onDeleteFolder:F,onRenameFolder:X,onRenameCanvas:K,onDuplicateCanvas:ie,onDeleteFile:G,syncStatus:se,onLinkedHub:Z,onLocalProject:pe,onOpenLinkedFile:oe,filesReady:ye,treeLoadFailures:Je=0,onShare:Ke,savingIsManaged:ot=!1}){let yt=Kt(()=>{if(!f)return a;return a.map((ue)=>({...ue,tree:r2(ue.tree,f),filtered:!!f}))},[a,f]),rt=VI(z),nt=FI(),bt=Kt(()=>{let ue=[];for(let be of a){if(be.label==="Design system"||be.kind!=="canvas")continue;let Te=be.fullPath.replace(/^\.[^/]+\//,"")||be.fullPath;ue.push({path:be.fullPath,label:Te});for(let tt of be.dirs||[])ue.push({path:tt,label:tt.replace(/^\.[^/]+\//,"")})}return ue},[a]),kt=nt.state?.extra,Se=kt?.kind==="file"?[{id:"share",label:"Share…",onSelect:()=>{nt.close(),Ke(kt.path)}},...K&&/\.tsx$/i.test(kt.path)?[{id:"rename-canvas",label:"Rename…",onSelect:()=>{nt.close();let ue=xs(kt.path.split("/").pop()),be=window.prompt("Rename canvas to:",ue);if(be?.trim()&&be.trim()!==ue)K(kt.path,be.trim())}}]:[],...ie&&/\.tsx$/i.test(kt.path)?[{id:"duplicate-canvas",label:"Duplicate",onSelect:()=>{nt.close(),ie(kt.path)}}]:[],...kt.supporting&&K?[{id:"rename-file",label:"Rename…",onSelect:()=>{nt.close();let ue=kt.name??kt.path.split("/").pop(),be=ue.includes(".")?ue.slice(ue.lastIndexOf(".")):"",Te=be?ue.slice(0,-be.length):ue,tt=window.prompt(`Rename ${ue} to:`,Te);if(tt?.trim()&&tt.trim()!==Te)K(kt.path,tt.trim())}}]:[],...kt.canMove?[{id:"move-to",label:"Move to…",onSelect:()=>nt.showMoveTo()}]:[],...kt.supporting&&G?[{id:"delete-file",label:"Delete",destructive:!0,onSelect:()=>{nt.close(),G(kt.path,kt.name??kt.path.split("/").pop())}}]:[]]:kt?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{nt.close();let ue=window.prompt("New folder name:");if(ue?.trim())M(kt.dirPath,ue.trim())}},{id:"rename-folder",label:"Rename folder",onSelect:()=>{nt.close();let ue=kt.dirPath.split("/").pop(),be=window.prompt("Rename folder to:",ue);if(be?.trim()&&be.trim()!==ue)X(kt.dirPath,be.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{nt.close(),F(kt.dirPath,kt.dirPath.split("/").pop())}}]:[],qe=kt?.kind==="file"||kt?.kind==="supporting"?bt.filter((ue)=>ue.path!==kt.dir):[],[_e,Ye]=P(!1),[He,ht]=P("board"),[Xt,Ne]=P(""),[At,ua]=P(""),[Be,fe]=P(!1),Ze=Kt(()=>a.find((ue)=>ue.kind==="canvas"&&ue.label!=="Design system")?.fullPath,[a]),he=ce(async()=>{let ue=Xt.trim();if(!ue||Be)return;if(fe(!0),ua(""),He==="folder"){if(!Ze){fe(!1),ua("no canvas group to create a folder in");return}let Te=await M(Ze,ue);if(fe(!1),Te?.ok)Ye(!1),Ne("");else ua(Te?.error||"could not create folder");return}let be=await _(ue);if(fe(!1),be?.ok)Ye(!1),Ne("");else ua(be?.error||"could not create board")},[Xt,Be,_,M,He,Ze]),Le=Kt(()=>{let ue=0;for(let be of a)for(let Te of be.paths||[])if(ws.test(Te))ue++;return ue},[a]),Ie=Kt(()=>{let ue=0;for(let be of yt)for(let Te of be.paths||[])if(ws.test(Te))ue++;return ue},[yt]);return y("nav",{className:"st-sidebar"+(A?" is-collapsed":"")+(R?" is-resizing":""),style:A||!E?void 0:{width:E,flexBasis:E},"aria-label":"Files","data-tour":"sidebar",children:[y("div",{className:"st-sb-hd",children:[l("span",{className:"st-sb-title",children:"Files"}),y("div",{className:"st-sb-hd-actions",children:[!e&&l("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":_e&&He==="board",onClick:()=>{ua(""),ht("board"),Ye((ue)=>He==="board"?!ue:!0)},children:l(ga,{name:"plus",size:15})}),!e&&Ze&&l("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":_e&&He==="folder",onClick:()=>{ua(""),ht("folder"),Ye((ue)=>He==="folder"?!ue:!0)},children:l(ga,{name:"folder-plus",size:15})}),k&&l("button",{type:"button",className:"st-iconbtn st-refresh"+(I?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":I||void 0,disabled:I,onClick:()=>k(),children:l(ga,{name:"reload",size:15})}),y("span",{className:"st-live","data-tip":c?"live · file index synced":"reconnecting…",children:[l("span",{className:"st-live-dot"+(c?" is-connected":""),"aria-hidden":"true"}),Ie," / ",Le]}),N&&l("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:N,children:l(ga,{name:"panel-left",size:15})})]})]}),_e?y("div",{className:"st-newboard",children:[l("input",{type:"text",autoFocus:!0,placeholder:He==="folder"?"folder name…":"brief board name…",value:Xt,maxLength:60,disabled:Be,"aria-label":He==="folder"?"New folder name":"New brief board name",onChange:(ue)=>Ne(ue.target.value),onKeyDown:(ue)=>{if(ue.key==="Enter")ue.preventDefault(),he();else if(ue.key==="Escape")ue.preventDefault(),Ye(!1),Ne(""),ua("")}}),l("button",{type:"button",className:"st-newboard-go",disabled:Be||!Xt.trim(),"data-tip":"Create · Enter","aria-label":He==="folder"?"Create folder":"Create brief board",onClick:he,children:Be?"…":"↵"})]}):null,At?l("div",{className:"st-newboard-err",role:"alert",children:At}):null,l("div",{className:"st-search",children:y("div",{className:"st-search-box",children:[l(ga,{name:"search",size:13}),l("input",{type:"search","data-testid":"canvas-search",placeholder:"Search canvases…",value:f,onChange:(ue)=>p(ue.target.value),onKeyDown:(ue)=>{if(ue.key==="Escape")if(ue.preventDefault(),f)p("");else ue.currentTarget.blur()},"aria-label":"Filter files"}),f?l("button",{className:"st-search-clear",onClick:()=>p(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):l(Gn,{children:"/"})]})}),!ye&&l(wbe,{failures:Je,cloud:t}),l(HI,{"aria-label":"Project file tree","data-testid":"canvas-list",children:yt.map((ue)=>{if(!h&&!f&&ue.kind==="runtime")return null;let be=vbe(ue),Te=(ue.paths||[]).filter((Pt)=>ws.test(Pt)).length,tt=be.pill||(be.pillFromDsCount?String(ue.dsFolders?.length||0):null)||(be.pillFromCount?String(Te||ue.paths?.length||0):null),we=ue.tree&&Object.keys(ue.tree).length>0,Ue=ue.label==="Design system",lt=ue.kind==="project";if(!h&&!f&&lt&&Te===0)return null;let le=ZA(ue),We=b[ue.label],xt=!!f||(We===void 0?le:We),Wt=!Ue&&ue.kind==="canvas"&&!e,pa=Wt?rt.dropProps(ue.fullPath,!0):{},Qa=rt.overDir===ue.fullPath;return l(Jf,{className:"st-tree-section",label:be.title,expanded:xt,onToggle:()=>w(ue.label,le),row:y("button",{type:"button",className:"st-tree-sec-hd"+(Qa?" is-drop-target":""),"data-testid":`tree-section-${ue.label.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,onClick:()=>w(ue.label,le),"aria-expanded":xt,"aria-dropeffect":Wt?"move":void 0,title:xt?"Collapse section":"Expand section",...pa,children:[l(ga,{name:"chevron-right",className:"st-chev"+(xt?" is-open":""),size:13}),l("span",{className:"st-sec-name",children:be.title}),tt&&l("span",{className:"st-pill",children:tt})]}),children:xt&&(we?l(Tj,{node:ue.tree,activePath:n,previewPath:r,onOpen:o,onPreview:i,commentsByFile:m,depth:1,kind:ue.kind,showHidden:h,search:f,dsFolders:ue.dsFolders,activeDsName:s,onOpenSystem:Ue?u:void 0,onDelete:Ue||e?void 0:v,dirtyByPath:O,canvasKinds:U,dirPath:ue.fullPath,drag:!Ue&&ue.kind==="canvas"&&!e?rt:void 0,menu:nt,expansion:S}):l("div",{className:"st-tree-empty",children:f?"No matches.":"Empty."}))},ue.label)})}),l(jI,{state:nt.state,onClose:nt.close,rootItems:Se,destinations:qe,onPickDestination:(ue)=>z(kt.path,ue)}),l(K_,{project:H,liveBranch:V,remoteSync:q,onGetLatest:D,projectOnly:ot}),t===null?l(A_,{syncStatus:se,onLinkedHub:Z,onLocalProject:pe,onOpenFile:oe,filesReady:ye}):null,l(O_,{})]})}function $j({shown:e,onExpand:t,onSearch:a}){return l("div",{className:"st-rail"+(e?" is-shown":""),children:y("div",{className:"st-rail-inner",children:[l("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:t,children:l(ga,{name:"panel-left",size:15})}),l("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:a,children:l(ga,{name:"search",size:15})}),l("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:t,children:l(ga,{name:"folder",size:15})})]})})}function Aj({open:e,onClose:t,onStartTour:a}){if(ee(()=>{if(!e)return;function n(r){if(r.key==="Escape")t()}return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,t]),!e)return null;return l("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(n)=>{if(n.target===n.currentTarget)t()},children:y("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[y("header",{className:"help-modal-hd",children:[l("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),y("span",{className:"sku",children:["MAUDE-DEV-SRV / v",Sp]}),a&&l("button",{type:"button",className:"mdcc-tour__back",style:{marginLeft:"auto"},onClick:a,children:"▶ Take the tour"}),l("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:t,children:"×"})]}),y("div",{className:"help-modal-body",children:[y("details",{open:!0,children:[l("summary",{children:"Canvas selection & tools"}),y("ul",{children:[y("li",{children:[l("kbd",{children:"V"})," ",l("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),y("li",{children:[l("kbd",{children:"H"})," ",l("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),y("li",{children:[l("kbd",{children:"C"})," ",l("span",{children:"comment tool — hover paints, click drops a pin"})]}),y("li",{children:[l("kbd",{children:"⌘"})," + hover ",l("span",{children:"preview deepest element under cursor"})]}),y("li",{children:[l("kbd",{children:"⌘"})," + click ",l("span",{children:"select that element (replace)"})]}),y("li",{children:[l("kbd",{children:"⌘⇧"})," + click ",l("span",{children:"add deepest to selection (multi)"})]}),y("li",{children:["right-click ",l("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),y("li",{children:[l("kbd",{children:"Esc"})," in canvas ",l("span",{children:"clear selection + close menu"})]})]})]}),y("details",{children:[l("summary",{children:"Annotation tools"}),y("ul",{children:[y("li",{children:[l("kbd",{children:"B"})," ",l("span",{children:"pen — freehand stroke"})]}),y("li",{children:[l("kbd",{children:"R"})," ",l("span",{children:"rectangle — drag to define corners"})]}),y("li",{children:[l("kbd",{children:"O"})," ",l("span",{children:"ellipse — drag from center outward"})]}),y("li",{children:[l("kbd",{children:"A"})," ",l("span",{children:"arrow — drag tail → tip"})]}),y("li",{children:[l("kbd",{children:"E"})," ",l("span",{children:"eraser — click or drag over strokes to remove"})]}),y("li",{children:[l("kbd",{children:"V"})," + click stroke ",l("span",{children:"select annotation (Shift+click to multi)"})]}),y("li",{children:[l("kbd",{children:"V"})," + drag empty ",l("span",{children:"marquee-select strokes that overlap"})]}),y("li",{children:["double-click rect/ellipse ",l("span",{children:"add text inside the shape"})]}),y("li",{children:["arrow keys ",l("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),y("li",{children:[l("kbd",{children:"Backspace"})," ",l("span",{children:"delete selected annotations"})]}),y("li",{children:[l("kbd",{children:"⇧P"})," ",l("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),y("details",{children:[l("summary",{children:"Canvas & panels"}),y("ul",{children:[y("li",{children:["click in tree ",l("span",{children:"open canvas (replaces the active one)"})]}),y("li",{children:["File ▸ Close canvas ",l("span",{children:"clear the stage"})]}),y("li",{children:[l("kbd",{children:"⌘R"})," ",l("span",{children:"reload canvas"})]}),y("li",{children:[l("kbd",{children:"/"})," ",l("span",{children:"focus search"})]}),y("li",{children:[l("kbd",{children:"⌘⇧M"})," ",l("span",{children:"comments panel"})]}),y("li",{children:[l("kbd",{children:"⌘⇧I"})," ",l("span",{children:"inspector"})]}),y("li",{children:[l("kbd",{children:"?"})," ",l("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),y("details",{children:[l("summary",{children:"Slash commands"}),y("ul",{className:"cmds",children:[y("li",{children:[y("code",{children:['/design:edit "',l("i",{children:"feedback"}),'"']}),l("span",{children:"edit + 4-iter multi-axis loop"})]}),y("li",{children:[y("code",{children:['/design:edit "',l("i",{children:"…"}),'" --perfect']}),l("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),y("li",{children:[y("code",{children:['/design:edit "',l("i",{children:"…"}),'" --no-critic']}),l("span",{children:"raw edit, skip loop"})]}),y("li",{children:[y("code",{children:['/design:edit "',l("i",{children:"…"}),'" --opt-out=',l("i",{children:"scope"})]}),l("span",{children:"override DS scope (palette/aesthetic/full)"})]}),y("li",{children:[y("code",{children:['/design:new "',l("i",{children:"Name"}),'" "',l("i",{children:"brief"}),'"']}),l("span",{children:"scaffold canvas"})]}),y("li",{children:[y("code",{children:['/design:new "',l("i",{children:"…"}),'" --opt-out=aesthetic']}),l("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),y("li",{children:[l("code",{children:"/design:critic"}),l("span",{children:"review panel (routed)"})]}),y("li",{children:[l("code",{children:"/design:critic --all"}),l("span",{children:"10-critic sweep"})]}),y("li",{children:[l("code",{children:"/design:critic --agent signature-moment-critic"}),l("span",{children:"aspiration axis only"})]}),y("li",{children:[l("code",{children:"/design:rollback"}),l("span",{children:"undo last edit"})]}),y("li",{children:[l("code",{children:"/design:screenshot"}),l("span",{children:"capture canvas"})]}),y("li",{children:[l("code",{children:"/design:setup-docs"}),l("span",{children:"refresh README + INDEX"})]}),y("li",{children:[l("code",{children:"/design:handoff"}),l("span",{children:"migrate to apps/"})]})]})]}),y("details",{children:[l("summary",{children:"Opt-out scope"}),y("ul",{children:[y("li",{children:[l("strong",{children:"palette"})," ",l("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),y("li",{children:[l("strong",{children:"aesthetic"})," ",l("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),y("li",{children:[l("strong",{children:"full"})," ",l("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),y("li",{children:[l("em",{children:"A11y enforced at every scope"})," ",l("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),y("li",{children:["Persisted on canvas's ",l("code",{children:".meta.json"})," ",l("code",{children:"opt_out_scope"})," field — subsequent ",l("code",{children:"/design:edit"})," iterations inherit."]}),l("li",{children:'Inferred from brief ("modern", "vibrant", "off-system") with one-shot AskUserQuestion before iter-1 critics fire.'})]})]}),y("details",{children:[l("summary",{children:"Auto-critic loop"}),y("ul",{children:[y("li",{children:[l("strong",{children:"Default"})," ",l("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),y("li",{children:[l("strong",{children:"--perfect"})," ",l("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),y("li",{children:[l("strong",{children:"--perfect --all"})," ",l("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),y("li",{children:["Exit: ",l("code",{children:"solid"})," · ",l("code",{children:"stable-but-bland"})," · ",l("code",{children:"max-reached"})," ","· ",l("code",{children:"divergent"})]}),y("li",{children:[l("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),y("li",{children:["When ",l("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."]})]})]}),y("details",{children:[l("summary",{children:"Pin-to-element flow"}),y("ol",{children:[l("li",{children:"Open a canvas"}),y("li",{children:[l("kbd",{children:"⌘"}),"+click element"]}),l("li",{children:"Status bar shows ● selector"}),y("li",{children:["Run"," ",y("code",{children:['/design:edit "',l("i",{children:"change just this"}),'"']})]}),y("li",{children:["Reload iframe (",l("kbd",{children:"⌘R"}),")"]})]})]}),y("details",{children:[l("summary",{children:"Comments"}),y("ol",{children:[y("li",{children:[l("kbd",{children:"⌘"}),"+click element, then ",l("kbd",{children:"⌘C"})," ",l("span",{children:"or ⌘⇧+click"})]}),l("li",{children:"Numbered pin appears on canvas"}),y("li",{children:[l("kbd",{children:"⌘⇧M"})," ",l("span",{children:"opens panel — All / Open / Resolved"})]}),y("li",{children:["Click row in panel ",l("span",{children:"jumps to that file + pin"})]}),y("li",{children:["Claude reads ",l("code",{children:"_comments/<slug>.json"})," on next ",l("code",{children:"/design"})]})]})]})]})]})})}var oE=[{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 xbe({kbd:e,alt:t}){let a=(n,r)=>l("span",{className:"so-combo",children:n.split(" ").map((s,o)=>l(Gn,{children:s},`${s}-${o}`))},r);return y("span",{className:"so-combos",children:[a(e,"main"),t?t.split(" / ").map((n)=>y(Jn,{children:[l("span",{className:"so-or",children:"/"}),a(n,n)]},n)):null]})}function Ej({open:e,onClose:t}){if(ee(()=>{if(!e)return;function n(r){if(r.key==="Escape")r.preventDefault(),t()}return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,t]),!e)return null;let a=oE.reduce((n,r)=>n+r.items.length,0);return l("div",{className:"st-scrim",role:"presentation",onMouseDown:(n)=>{if(n.target===n.currentTarget)t()},children:y("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[y("div",{className:"so-overlay-hd",children:[l("span",{className:"so-title",children:"Keyboard shortcuts"}),y("span",{className:"so-trigger",children:["press ",l(Gn,{children:"?"})," to open"]})]}),l("div",{className:"so-columns",children:oE.map((n)=>y("section",{className:"so-section so-section--"+n.id,children:[l("h3",{className:"so-section-hd",children:n.label}),l("dl",{className:"so-list",children:n.items.map((r)=>y("div",{className:"so-pair",children:[l("dt",{children:r.label}),l("dd",{children:l(xbe,{kbd:r.kbd,alt:r.alt})})]},r.label))})]},n.id))}),y("div",{className:"so-overlay-ft",children:[y("span",{children:["close with ",l(Gn,{children:"Esc"})]}),y("span",{className:"so-count",children:[a," bindings · ",oE.length," groups"]})]})]})})}var _be=["File","Edit","View","Selection","Tools","Help"];function Nj(e){ee(()=>{function t(n){if(n.key==="Escape")e()}function a(n){if(!n.target.closest(".st-dropdown, .st-menu"))e()}return window.addEventListener("keydown",t),window.addEventListener("mousedown",a),()=>{window.removeEventListener("keydown",t),window.removeEventListener("mousedown",a)}},[e])}function Sbe({panels:e,onToggle:t,onClose:a,onZoom:n,hasCanvas:r}){return Nj(a),y("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[l("div",{className:"st-dd-hd",children:"Panels"}),e.map((s)=>y("button",{type:"button",role:"menuitem",className:"st-dd-item"+(s.checked?" is-on":""),"aria-disabled":s.disabled?"true":void 0,title:s.hint||void 0,onClick:()=>{if(s.disabled){if(s.href)window.open(s.href,"_blank","noopener,noreferrer"),a();return}t(s.id),a()},children:[y("span",{className:"st-dd-lead",children:[l("span",{className:"st-dd-check",children:s.checked?l(ga,{name:"check",size:13}):null}),l("span",{children:s.label}),s.phase?l("span",{className:"st-dd-phase",children:s.phase}):null]}),s.shortcut?l(Gn,{children:s.shortcut}):null]},s.id)),l("div",{className:"st-dd-sep"}),l("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((s)=>y("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":r?void 0:"true",onClick:()=>{if(!r)return;n?.(s.op),a()},children:[y("span",{className:"st-dd-lead",children:[l("span",{className:"st-dd-check"}),l("span",{children:s.label})]}),l(Gn,{children:s.shortcut})]},s.label))]})}function Xh({label:e,left:t,header:a,items:n,onAction:r,onClose:s}){return Nj(s),y("div",{className:"st-dropdown",role:"menu","aria-label":e,style:{left:t},children:[a?l("div",{className:"st-dd-hd",children:a}):null,n.map((o,i)=>o.sep?l("div",{className:"st-dd-sep"},"s"+i):y("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":o.disabled?"true":void 0,onClick:()=>{if(o.disabled)return;r(o.id),s()},children:[y("span",{className:"st-dd-lead",children:[l("span",{className:"st-dd-check"}),l("span",{children:o.label})]}),o.shortcut?l(Gn,{children:o.shortcut}):null]},o.id))]})}function Cbe({onAction:e,onClose:t}){return l(Xh,{label:"Help",left:320,onAction:e,onClose:t,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"},...na()?[{id:"collab-tour",label:"How sharing works"}]:[],...na()?[{id:"quick-setup",label:"Quick setup"}]:[],...na()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function kbe({onAction:e,onClose:t,readOnly:a=!1}){return l(Xh,{label:"Selection",left:214,onAction:e,onClose:t,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},...a?[]:[{id:"select-all-annotations",label:"Select all annotations",shortcut:"⌘ ⇧ A"}]]})}function Ibe({onAction:e,onClose:t,readOnly:a=!1}){let n=[{id:"browse",label:"Browse (interact)",shortcut:""},{id:"move",label:"Select",shortcut:"V"},{id:"hand",label:"Hand",shortcut:"H"},...a?[]:[{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 l(Xh,{label:"Tools",left:290,header:"Tool palette",onAction:e,onClose:t,items:n})}function Tbe({onAction:e,onClose:t,hasCanvas:a,hasSharePath:n,readOnly:r=!1}){return l(Xh,{label:"File",left:40,onAction:e,onClose:t,items:r?[{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"share",label:"Share link…",disabled:!n},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!a},{id:"close",label:"Close canvas",disabled:!a}]:[{id:"new",label:"New canvas…",shortcut:"N"},{id:"assemble",label:"Assemble dropped clips → video",disabled:!a},{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"share",label:"Share link…",disabled:!n},{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:!a},{id:"close",label:"Close canvas",disabled:!a}]})}function $be({onAction:e,onClose:t,hasCanvas:a,readOnly:n=!1}){if(n)return l(Xh,{label:"Edit",left:90,onAction:e,onClose:t,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"}]});return l(Xh,{label:"Edit",left:90,onAction:e,onClose:t,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"},...a?[{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 Lj({activePath:e,sharePath:t,onShare:a,project:n,cloud:r,tabsCount:s,openMenu:o,setOpenMenu:i,commentsPanelOpen:u,onToggleComments:c,changesOpen:f,changesCount:p,onToggleChanges:m,onOpenSystem:h,sidebarOpen:b,onToggleSidebar:w,showHidden:S,onToggleShowHidden:_,onOpenHelp:v,onOpenShortcuts:k,onReportBug:I,onStartTour:A,onStartCollabTour:N,annotationsVisible:E,onToggleAnnotations:R,minimapVisible:O,onToggleMinimap:H,zoomCtlVisible:V,onToggleZoomCtl:q,presentMode:D,onTogglePresent:U,printGuidesVisible:z,onTogglePrintGuides:M,postToActiveCanvas:F,onOpenWhatsNew:X,onOpenReadiness:K,onOpenQuickSetup:ie,onWatchIntro:G,whatsNewCount:se,exportCenter:Z,artboardCount:pe=0,presence:oe=null,inspectorOpen:ye,inspectorTab:Je,onToggleInspector:Ke,autoOpenInspector:ot,onToggleAutoOpenInspector:yt,onOpenLayers:rt,timelineOpen:nt,onToggleTimeline:bt,hasComps:kt=!1,assistantOpen:Se,onToggleAssistant:qe,assistantBusy:_e,assistantUnseen:Ye,onNewCanvas:He,onAssembleVideo:ht,onOpenExport:Xt,onOpenSettings:Ne,onOpenGenerate:At,onReload:ua,onCloseCanvas:Be,onInsertArtboard:fe,readOnly:Ze=!1}){let he=e===Ft,Le=he?"SYSTEM":e?"CANVAS":"IDLE",Ie=he?l("b",{children:"design system"}):e?y(te,{children:[e.split("/").slice(0,-1).join("/"),"/",l("b",{children:xs(us(e))})]}):l("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),ue=new Set(r?["autoopen"]:["assistant","autoopen"]),be=[{id:"tree",label:"Project Tree",shortcut:"T",checked:b,disabled:!1},{id:"changes",label:r?"History":p>0?`Changes · ${p} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:f,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:u,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:S,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:ye&&Je==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:ye,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!ot,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:kt?"video":void 0,checked:nt,disabled:!1},...na()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:Se,disabled:!1}]:r?[{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:E,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:O,disabled:!e||he},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:V,disabled:!e||he},{id:"present",label:"Presentation Mode",shortcut:"",checked:D,disabled:!e||he},{id:"print-guides",label:"Show print guides",shortcut:"",checked:z,disabled:!e||he}].filter((we)=>!Ze||!ue.has(we.id)),Te=["file","edit","view","selection","tools","help"];function tt(we){if(Te.includes(we))i(o===we?null:we)}return ee(()=>{if(!o||!Te.includes(o))return;let we=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function Ue(lt){let le=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!le.length)return;let We=le.indexOf(document.activeElement);if(lt.key==="ArrowDown")lt.preventDefault(),le[(We+1)%le.length].focus();else if(lt.key==="ArrowUp")lt.preventDefault(),le[(We-1+le.length)%le.length].focus();else if(lt.key==="Home")lt.preventDefault(),le[0].focus();else if(lt.key==="End")lt.preventDefault(),le[le.length-1].focus();else if(lt.key==="ArrowRight"||lt.key==="ArrowLeft"){lt.preventDefault();let xt=lt.key==="ArrowRight"?1:-1,Wt=Te.indexOf(o);i(Te[(Wt+xt+Te.length)%Te.length])}else if(lt.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",Ue),()=>{clearTimeout(we),window.removeEventListener("keydown",Ue)}},[o,i]),y("header",{className:"st-menubar","aria-label":"Application menubar","data-testid":"menubar",children:[y("span",{className:"st-brand","data-tour":"brand",children:[l("span",{className:"st-brand-mark",children:l("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:l("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),l("span",{className:"st-brand-name",children:"maude"})]}),r?y("span",{className:"st-cloudback","data-testid":"cloud-back",children:[r.dashboardUrl?l("a",{className:"st-cloudback-link",href:r.dashboardUrl,title:"Back to your projects",children:"← Dashboard"}):null,r.projectName?l("span",{className:"st-cloudback-project","data-testid":"cloud-project-name",children:r.projectName}):null]}):null,l("nav",{className:"st-menus",role:"menubar","aria-label":"Application menus","data-tour":"menus",children:_be.map((we)=>{let Ue=we.toLowerCase(),lt=Te.includes(Ue),le=lt||Ue==="help",We=o===Ue;return l("button",{type:"button",className:"st-menu",role:"menuitem","data-testid":`menu-${Ue}`,"data-tour":Ue==="help"?"help":void 0,"aria-haspopup":lt?"menu":void 0,"aria-expanded":lt?We:void 0,onClick:()=>tt(Ue),onMouseEnter:()=>{if(o!==null&&lt)i(Ue)},children:we},Ue)})}),o==="file"&&l(Tbe,{readOnly:Ze,hasCanvas:!!e,hasSharePath:!!t,onAction:(we)=>{if(we==="new")He?.();else if(we==="assemble")ht?.();else if(we==="export")Xt?.("export");else if(we==="share")document.querySelector('[data-testid="menu-file"]')?.focus(),a?.();else if(we==="handoff")Xt?.("handoff");else if(we==="generate")At?.();else if(we==="settings")Ne?.();else if(we==="reload")ua?.();else if(we==="close")Be?.()},onClose:()=>i(null)}),o==="edit"&&l($be,{readOnly:Ze,hasCanvas:!!e&&!he,onAction:(we)=>{if(we==="undo")F({dgn:"undo"});else if(we==="redo")F({dgn:"redo"});else if(we==="deselect-all")F({dgn:"selection-clear"});else if(we==="select-all-annotations")F({dgn:"annotation-select-all"});else if(we.startsWith("new-artboard:"))fe?.(we.slice(13))},onClose:()=>i(null)}),o==="view"&&l(Sbe,{panels:be,onToggle:(we)=>{if(we==="tree")w();else if(we==="changes")m();else if(we==="comments")c();else if(we==="hidden")_();else if(we==="annotate")R();else if(we==="inspector")Ke();else if(we==="autoopen")yt?.();else if(we==="timeline")bt?.();else if(we==="assistant")qe?.();else if(we==="layers")rt?.();else if(we==="minimap")H?.();else if(we==="zoomctl")q?.();else if(we==="present")U?.();else if(we==="print-guides")M?.()},onZoom:(we)=>F({dgn:"zoom",op:we}),hasCanvas:!!e&&!he,onClose:()=>i(null)}),o==="selection"&&l(kbe,{readOnly:Ze,onAction:(we)=>{if(we==="deselect-all")F({dgn:"selection-clear"});else if(we==="select-all-annotations")F({dgn:"annotation-select-all"})},onClose:()=>i(null)}),o==="tools"&&l(Ibe,{readOnly:Ze,onAction:(we)=>F({dgn:"tool-set",tool:we}),onClose:()=>i(null)}),o==="help"&&l(Cbe,{onAction:(we)=>{if(we==="shortcuts")k?.();else if(we==="help")v?.();else if(we==="report-bug")I?.();else if(we==="tour")A?.();else if(we==="collab-tour")N?.();else if(we==="quick-setup")ie?.();else if(we==="readiness")K?.();else if(we==="whatsnew")X?.();else if(we==="watch-intro")G?.()},onClose:()=>i(null)}),y("div",{className:"st-mb-right","data-tour":"status",children:[oe?l("div",{className:"st-presence",children:oe}):null,Ze&&l("span",{className:"st-stamp st-stamp--viewonly","data-testid":"view-only-stamp","data-tip":r?.user?`${r.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"}),r?.user?y("span",{className:"st-cloudwho","data-testid":"cloud-account",children:[l("span",{className:"st-cloudwho-email",title:r.role?`Signed in as ${r.user} — ${r.role}`:r.user,children:r.user}),l("form",{method:"post",action:"/auth/browser/signout",className:"st-cloudwho-form",children:l("button",{type:"submit",className:"st-cloudwho-out","data-testid":"cloud-signout",title:"Sign out of this project",children:"Sign out"})})]}):null,na()&&!Ze&&l("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":Se?"true":"false","data-busy":_e?"true":"false","data-unseen":Ye?"true":"false","aria-label":`Assistant${_e?" — working":Ye?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:qe,children:l(ga,{name:"sparkle",size:15})}),l("button",{type:"button",className:"st-mb-icon st-share-btn","data-testid":"share-btn","data-tip":t?"Share link":"Open a canvas to share it","aria-label":"Share link",disabled:!t,onClick:a,children:l(ga,{name:"share",size:15})}),Z&&l(DA,{center:Z}),l("button",{type:"button",className:"st-reportbug","data-testid":"report-bug-toggle","aria-label":"Report a bug","data-tip":"Report a bug",onClick:I,children:l(ga,{name:"bug",size:15})}),l("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":se>0?"true":"false","aria-label":`What's new${se>0?` — ${se} unseen`:""}`,"data-tip":"What's new",onClick:X,children:l(ga,{name:"megaphone",size:15})}),l("span",{className:"st-stamp",children:Le}),l("span",{className:"st-mb-file",title:e||"",children:Ie}),l("span",{className:"st-mb-sep"}),y("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[l("span",{className:"st-dot",style:{background:"var(--accent)"}}),pe," ARTBOARDS"]}),l("span",{className:"st-mb-sep"}),l("span",{className:"st-mb-proj",children:n||"maude"})]})]})}var Abe=["color","space","radius","shadow","leading","weight","motion","font","other"],Ebe={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function Nbe(e){return e==="color"}function Lbe({tokens:e,tokenGroups:t,tokensPath:a}){if(!e||e.length===0)return y("section",{className:"sv-section sv-section-tokens",children:[y("h2",{children:["tokens",l("span",{className:"sv-h-num",children:"0"})]}),l("div",{className:"sv-empty",children:y("p",{children:["No tokens parsed from"," ",a?l("code",{children:a}):"the configured tokens file",". Does the file exist and contain CSS custom properties (",l("code",{children:"--name: value;"}),")?"]})})]});let n=t||{},r=Array.from(new Set([...Abe,...Object.keys(n)])).filter((s)=>n[s]?.length);return l(te,{children:r.map((s)=>{let o=n[s],i=Nbe(s);return y("section",{className:"sv-section sv-section-tokens sv-section-"+s,children:[y("h2",{children:["tokens · ",Ebe[s]||s,l("span",{className:"sv-h-num",children:o.length})]}),l("div",{className:"sv-tokens-ladder",children:o.map((u)=>y("div",{className:"sv-tok-cell",children:[i?l("div",{className:"sv-tok-swatch",style:{background:u.value}}):null,y("div",{className:"sv-tok-meta",children:[l("code",{className:"sv-tok-name",children:u.name}),l("span",{className:"sv-tok-value",children:u.value||"—"})]})]},u.name+"|"+u.value))})]},s)})})}function Mbe(e,t){let a=e.name.match(/^--(?:type|fs|text)-(.+)$/);if(!a)return null;let n=a[1];return(t||[]).find((r)=>/^--(?:lh|leading|line-height)-/.test(r.name)&&r.name.endsWith("-"+n))?.value??null}function Rbe(e){if(!e?.length)return;let t=["body","sans","display","text","family"];for(let a of t){let n=e.find((r)=>r.name.includes(a));if(n)return n.value}return e[0].value}function Obe({tokenGroups:e}){let t=e?.fontsize||[];if(t.length===0)return null;let a=e?.leading||[],n=Rbe(e?.font);return y("section",{className:"sv-section sv-section-type",children:[y("h2",{children:["type · ladder",l("span",{className:"sv-h-num",children:t.length})]}),l("div",{className:"sv-type-list",children:t.map((r)=>{let s=Mbe(r,a),o={fontSize:r.value};if(s)o.lineHeight=s;if(n)o.fontFamily=n;return y("div",{className:"sv-type-row",children:[l("code",{className:"sv-type-tok",children:r.name}),l("span",{className:"sv-type-sample",style:o,children:"The catalog is the system."})]},r.name)})})]})}function iE({data:e,onOpen:t,cfg:a,onSelectDs:n}){if(!e)return l("div",{className:"sv-empty",children:l("p",{children:"Loading design system…"})});let{previewGallery:r,uiKitsGallery:s,systemDir:o,tokens:i,tokenGroups:u,tokensPath:c,ds:f,availableDesignSystems:p}=e,m=(!r||!r.length)&&(!s||!s.length),h=Array.isArray(p)&&p.length>1,b=f?.name??p?.[0]?.name??"";return y("div",{className:"sv",children:[y("header",{className:"sv-header",children:[l("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),l("span",{className:"sv-title",children:"design system view"}),h?y("label",{className:"sv-ds-picker",children:[l("span",{className:"sv-ds-picker-label",children:"DS"}),l("select",{value:b,onChange:(w)=>n&&n(w.target.value),children:p.map((w)=>l("option",{value:w.name,children:w.name},w.name))})]}):null,l("span",{className:"sv-loc",children:l("code",{children:o})})]}),f?.description?l("p",{className:"sv-ds-description",children:f.description}):null,l(Lbe,{tokens:i,tokenGroups:u,tokensPath:c}),l(Obe,{tokenGroups:u}),m?l("div",{className:"sv-empty",children:y("p",{children:["No ",l("code",{children:"preview/"})," or ",l("code",{children:"ui_kits/"})," folders found under"," ",l("code",{children:o}),"."]})}):y(te,{children:[l(Mj,{title:"preview",items:r,onOpen:t,kind:"preview",cfg:a}),l(Mj,{title:"ui kits",items:s,onOpen:t,kind:"ui_kits",cfg:a})]})]})}function Mj({title:e,items:t,onOpen:a,kind:n,cfg:r}){if(!t||t.length===0)return null;return y("section",{className:"sv-section",children:[y("h2",{children:[e," ",l("span",{className:"sv-count",children:t.length})]}),l("div",{className:"sv-previews sv-previews-"+n,children:t.map((s)=>y("article",{className:"sv-preview-card",onClick:()=>a(s.path),children:[l("div",{className:"sv-preview-frame",children:l("iframe",{src:Qi(s.path,r,{thumbnail:!0}),title:s.label,scrolling:"no",...r?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),y("div",{className:"sv-preview-foot",children:[l("strong",{children:s.label}),l("code",{children:s.path})]})]},s.path))})]})}function Rj({tabs:e,activePath:t,registerIframe:a,systemData:n,onOpenFromSystem:r,onSelectDs:s,project:o,cfg:i,loadingPath:u,onIframeLoad:c,canvasError:f,canvasReloadNonce:p,onRetryCanvasLoad:m,loadedPath:h,showQuickSetup:b,onStartQuickSetup:w,previewPath:S}){let _=me(null);ee(()=>{if(S)_.current?.focus()},[S]);let v=me(new Map),k=new Set(e.map((N)=>N.path));for(let[N,E]of v.current)if(!k.has(E.path))v.current.delete(N);let I=(N)=>{let E=Qi(N,{...i,canvasToken:void 0}),R=`${N}#${p}|${E}`,O=v.current.get(R);if(!O)O={path:N,src:Qi(N,i)},v.current.set(R,O);return O.src},A=f&&f.path===t?"error":t&&t!==Ft&&h===t?"ready":u&&u===t?"loading":"idle";return y("div",{className:"viewport st-stage","data-tour":"viewport","data-canvas-state":A,children:[S&&l("div",{ref:_,className:"st-file-preview-overlay",role:"region","aria-label":`Preview: ${gp(us(S))}`,tabIndex:0,children:l(Z3,{path:S,kind:$d(us(S))})}),e.length===0&&!S&&y("div",{className:"st-empty",children:[y("div",{className:"st-empty-brand",children:[l("span",{className:"st-brand-mark",children:l("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:l("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),l("span",{className:"st-empty-wm",children:"maude"}),y("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(o||"MAUDE").toUpperCase()," / v",Sp," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),l("div",{className:"st-empty-title",children:"Nothing open yet"}),y("div",{className:"st-empty-body",children:["← Pick a screen from the list on the left, or open ",l("strong",{children:"Design system"})," above it to see your colors, type, and components.",l("br",{}),l("br",{}),l("strong",{children:"To select something on the canvas:"})," hold ",l(Gn,{children:"⌘"})," and hover to preview an element, click to select it — ",l(Gn,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",na()?y(te,{children:[l("br",{}),l("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]}),b&&l("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:w,children:"Start quick setup"})]}),e.map((N)=>{if(N.path===Ft)return l("div",{className:"system-view"+(N.path===t?" active":""),children:l(iE,{data:n,onOpen:r,cfg:i,onSelectDs:s})},N.path);return l("iframe",{ref:(E)=>a(N.path,E),src:I(N.path),title:`Canvas: ${N.path}`,className:N.path===t?"active":"","data-path":N.path,"data-testid":N.path===t?"canvas-frame":void 0,onLoad:()=>c?.(N.path),...i?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},`${N.path}#${p}`)}),u&&u===t&&l(Dbe,{path:u,cloud:!!i?.cloud},u),f&&f.path===t&&l("div",{className:"st-canvas-error",role:"alert","data-testid":"canvas-load-error",children:y("div",{className:"st-canvas-error-card",children:[l("div",{className:"st-canvas-error-title",children:f.kind==="server"?"Maude's server isn't responding":"This canvas didn't finish loading"}),l("div",{className:"st-canvas-error-body",children:f.kind==="server"?l(te,{children:"The canvas couldn't be reached. This usually means Maude's server restarted underneath this window — your files on disk are untouched."}):y(te,{children:["The server is up, but"," ",l("code",{children:gp(us(f.path))})," ","never finished compiling. Its own error, if it has one, is in the canvas frame."]})}),l("button",{type:"button",className:"btn btn--primary","data-testid":"canvas-load-retry",onClick:()=>m?.(f.path),children:"Reload canvas"})]})})]})}function Dbe({path:e,cloud:t}){let[a,n]=P(!1);ee(()=>{let s=setTimeout(()=>n(!0),4000);return()=>clearTimeout(s)},[]);let r=gp(us(e||"").replace(/\.(tsx|jsx|html?)$/i,""));return l("div",{className:"st-canvas-loading",role:"status","aria-live":"polite","data-testid":"canvas-loading",children:y("div",{className:"st-skel-card",children:[y("div",{className:"st-canvas-loading-head",children:[l("span",{className:"st-canvas-loading-spinner","aria-hidden":"true"}),y("span",{className:"st-canvas-loading-title",children:["Opening ",r,"…"]})]}),l("span",{className:"skel st-skel-thumb","aria-hidden":"true"}),l("span",{className:"skel st-skel-line",style:{width:"72%"},"aria-hidden":"true"}),l("span",{className:"skel st-skel-line",style:{width:"46%"},"aria-hidden":"true"}),l("div",{className:"st-canvas-loading-hint"+(a?" is-shown":""),children:t?"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."})]})})}function Oj({activePath:e,selected:t,wsConnected:a,openCount:n,theme:r,onToggleTheme:s,onClearSelected:o,syncStatus:i,syncProject:u,syncOpen:c=!1,onOpenSync:f,changesCount:p=0,unpushed:m=0,savingIsManaged:h=!1,changesOpen:b=!1,onOpenChanges:w,version:S}){let _=e===Ft,v=t&&t.selector?t.selector+(t.text?` — "${t.text.slice(0,60)}"`:""):"",k=t&&t.dom_path?t.dom_path.join(" > "):t?t.selector:"",I=r==="dark"?"light":"dark",A=(()=>{let E=Zf(i,{project:u});if(!E)return null;let R=E.names.length?` (${E.names.join(", ")})`:"";return{online:E.online,phase:E.phase,label:E.label,title:`${E.title}${R}${E.next?` — ${E.next}`:""}`}})(),N=A&&y(te,{children:[l("span",{className:"st-sb-sync-dot"+(A.online?" is-online":""),"aria-hidden":"true"}),l("span",{className:"lbl",children:"hub sync"}),l("span",{className:"val",title:A.title,"data-testid":"statusbar-sync","data-phase":A.phase,children:A.label})]});return y("footer",{className:"st-statusbar",role:"contentinfo","data-testid":"statusbar",children:[y("span",{className:"st-sb-slot st-sb-active",role:"group","aria-label":"Active file",children:[l("span",{className:"lead","aria-hidden":"true"}),l("span",{className:"lbl",children:"active"}),l("span",{className:"val",title:e||"",children:_?"▦ design system":e||"—"})]}),e&&t&&t.selector&&!_&&y("span",{className:"st-sb-slot st-sb-sel",role:"group","aria-label":"Selected element",children:[l("span",{className:"lbl",children:"selected"}),l("span",{className:"val",title:k,children:v}),l("button",{type:"button",className:"st-sb-sel-clear",onClick:o,"data-tip":"Clear · Esc inside iframe","data-tip-pos":"top","aria-label":"Clear selection",children:"×"})]}),y("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[l("span",{className:"lbl",children:"comments"}),y("span",{className:"val",children:[n," open"]})]}),w&&y("button",{type:"button",className:"st-sb-slot st-sb-changes"+(b?" is-open":"")+(p>0?" has-changes":m>0?" has-unpushed":""),onClick:w,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":b,children:[l("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),l("span",{className:"lbl",children:"changes"}),l("span",{className:"val",children:h?"cloud saving":p>0?`${p} unsaved`:m>0?`${m} to publish`:"all saved"})]}),l("span",{className:"st-sb-spacer"}),y("span",{className:"st-sb-slot",role:"group","aria-label":"Connection",children:[l("span",{className:"st-live-dot"+(a?" is-connected":""),"aria-hidden":"true"}),l("span",{className:"lbl",children:a?"live":"reconnecting"})]}),A&&(f?l("button",{type:"button",className:"st-sb-slot st-sb-sync st-sb-sync--btn"+(c?" is-open":""),onClick:f,"data-testid":"open-sync","data-tip":"Open Sync panel","data-tip-pos":"top","aria-label":"Open Sync panel","aria-pressed":c,children:N}):l("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:N})),S&&l("span",{className:"st-sb-slot st-sb-version",role:"group","aria-label":"Maude version",children:y("span",{className:"val","data-testid":"statusbar-version",children:["v",S]})}),y("button",{type:"button",className:"st-sb-theme",onClick:s,"data-tip":`Switch to ${I} theme`,"data-tip-pos":"top","aria-label":`Switch to ${I} theme`,children:[l(ga,{name:r==="dark"?"sun":"moon",size:13}),I]})]})}function lE({commentsByFile:e,filter:t,setFilter:a,activePath:n,focusedId:r,onJump:s,onResolve:o,onReopen:i,onDelete:u,width:c,resizing:f}){let p=Gv(e),m=Object.keys(e||{}).sort(),h=[];for(let b of m){let w=e[b]||[],S=w.filter((v)=>{if(t==="open")return v.status!=="resolved";if(t==="resolved")return v.status==="resolved";return!0});if(S.length===0)continue;let _=w.filter((v)=>v.selector);h.push({file:b,comments:S.map((v)=>({...v,n:_.findIndex((k)=>k.id===v.id)+1}))})}return y("aside",{className:"st-rpanel"+(f?" is-resizing":""),style:c?{width:c,flexBasis:c}:void 0,"aria-label":"Comments",children:[l("div",{className:"st-rp-tabs st-rp-tabs--filters",children:y("div",{className:"st-cm-filters",role:"tablist",children:[y("button",{type:"button",className:"st-cm-filter"+(t==="all"?" is-active":""),role:"tab","data-testid":"comment-filter-all","aria-selected":t==="all",onClick:()=>a("all"),children:["All · ",p.all]}),y("button",{type:"button",className:"st-cm-filter"+(t==="open"?" is-active":""),role:"tab","data-testid":"comment-filter-open","aria-selected":t==="open",onClick:()=>a("open"),children:["Open · ",p.open]}),y("button",{type:"button",className:"st-cm-filter"+(t==="resolved"?" is-active":""),role:"tab","data-testid":"comment-filter-resolved","aria-selected":t==="resolved",onClick:()=>a("resolved"),children:["Resolved · ",p.resolved]})]})}),l("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:h.length===0?y("div",{className:"st-rp-empty",children:[y("p",{children:["No comments ",t!=="all"?`with status “${t}”`:"yet","."]}),y("p",{children:["Open a canvas, hold ",l(Gn,{children:"⌘"})," and click an element, then press ",l(Gn,{children:"C"})," — or hold ",l(Gn,{children:"⌘⇧"})," and click directly."]})]}):h.map((b)=>y(Jn,{children:[y("button",{type:"button",className:"st-cm-group-hd",onClick:()=>s(b.file,null),title:b.file,children:[l("span",{children:xs(us(b.file))}),l("span",{className:"st-mono",children:b.comments.length})]}),b.comments.map((w)=>y("div",{"data-testid":`comment-item-${w.id}`,className:"st-comment"+(w.status==="resolved"?" is-resolved":"")+(w.id===r?" is-active":""),onClick:()=>s(b.file,w.id),children:[y("div",{className:"st-comment-hd",children:[l("span",{className:"st-pin st-pin--inline",children:w.n||"·"}),l("span",{className:"st-comment-time",children:eE(w.created)})]}),l("div",{className:"st-comment-txt",children:w.text}),y("div",{className:"st-comment-foot",children:[l("span",{className:"st-comment-sel",title:(w.dom_path||[]).join(" > "),children:w.selector||"—"}),o&&i&&u?y("span",{className:"st-mini-act",children:[w.status==="resolved"?l("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(S)=>{S.stopPropagation(),i(w.id)},children:l(ga,{name:"reopen",size:14})}):l("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(S)=>{S.stopPropagation(),o(w.id)},children:l(ga,{name:"resolve",size:14})}),l("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(S)=>{S.stopPropagation(),u(w.id)},children:l(ga,{name:"x",size:14})})]}):null]})]},w.id))]},b.file))})]})}var Pbe={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 Dj({cloud:e}){let t=e?.role||null,[a,n]=P(!1);if(!t||a)return null;let r=`maude-cloud-role-seen:${t}`,s=!1;try{s=localStorage.getItem(r)==="1"}catch{}if(s)return null;let o=Pbe[t];if(!o)return null;return y("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info","data-testid":"cloud-role-banner",children:[l("span",{className:"st-banner-dot","aria-hidden":"true"}),l("span",{children:o}),l("button",{type:"button",className:"btn btn--ghost btn--sm","data-testid":"cloud-role-banner-dismiss",onClick:()=>{n(!0);try{localStorage.setItem(r,"1")}catch{}},children:"Got it"})]})}var Zh={newer:"This project now uses Maude 2. It's open here to look at — nothing in it is lost.",action:"Update Maude to edit",noBuild:"This project now uses Maude 2, which isn't out yet. It stays open here to look at.",cloud:"This project now uses Maude 2. It's open here to look at."},zbe="https://maude.sh/download";function Bbe({cfg:e,native:t,updateReady:a,askedForUpdate:n}){let r=e?.formatGate;if(!r||!(r.projectFormat>r.supported))return null;if(e?.cloud)return{line:Zh.cloud,action:null};if(t){if(a)return{line:Zh.newer,action:"restart"};if(n)return{line:Zh.noBuild,action:null};return{line:Zh.newer,action:"check"}}return{line:Zh.newer,action:"download"}}function Pj({cfg:e,updateReady:t}){let[a,n]=P(!1),[r,s]=P(!1),o=Bbe({cfg:e,native:na(),updateReady:t,askedForUpdate:a});if(!o)return null;let i=()=>{if(o.action==="restart")s(!0),h_().catch(()=>s(!1));else if(o.action==="check")n(!0);else if(o.action==="download")window.open(zbe,"_blank","noopener,noreferrer")};return y("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info","data-testid":"format-gate-banner",children:[l("span",{className:"st-banner-dot","aria-hidden":"true"}),l("span",{children:o.line}),o.action&&l("button",{type:"button",className:"btn btn--primary btn--sm","data-testid":"format-gate-update",disabled:r,onClick:i,children:r?"Restarting…":Zh.action})]})}function zj({update:e,onDismiss:t}){let[a,n]=P(!1);if(!e)return null;let r=e.version?` (v${e.version})`:"";return y("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[l("span",{className:"st-banner-dot","aria-hidden":"true"}),y("span",{children:["Maude updated",r," · restart to apply"]}),l("button",{type:"button",className:"btn btn--primary btn--sm",disabled:a,onClick:()=>{n(!0),h_().catch(()=>n(!1))},children:a?"Restarting…":"Restart now"}),l("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:t,children:"Later"})]})}function Bj({status:e}){let[t,a]=P(null);if(!e||e.linked===!1)return null;if(e.notSyncable)return null;let{state:n,queuedOps:r,flash:s,conflicts:o}=e,i=s==="synced",u=n==="offline"||n==="offline-long",c=e.docs?.rejected??0,f=Array.isArray(o)?[...o].reverse().find((b)=>b.kind==="cold-start-diverged"):null;if(!u&&!i&&!f&&c===0)return null;let p,m,h;if(i)p="success",m="Synced with hub",h=`${n}:flash`;else if(u){let b=o&&o.length>0?` (${o.length} conflict notice(s))`:"";if(n==="offline-long")p="error",m=`Long offline — ${r} edit(s) queued. Consider \`git commit && git push\` as backup.${b}`;else p="warn",m=`Working offline · ${r} edit(s) queued · will sync when the hub reconnects.${b}`;h=`${n}:offline`}else if(f){if(f.snapshotFailed)p="error",m=`Diverged on ${f.slug}: kept local — the history snapshot FAILED, so the overwrite was refused. Check disk space / .design/_history write access.`;else p="warn",m=`Diverged on ${f.slug}: kept the ${f.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${f.slug}`;h=`diverged:${f.slug}:${f.at}`}else p="warn",m=`${c} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,h=`rejected:${c}`;if(t===h)return null;return y("div",{role:"status","aria-live":"polite",className:`st-banner st-banner--${p}`,children:[l("span",{className:"st-banner-dot","aria-hidden":"true"}),l("span",{children:m}),l("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>a(h),children:"×"})]})}var uE=["block","inline-block","flex","inline-flex","grid","inline","none"],c2=["px","%","fr","em","auto","min-content","max-content"];var cE=["auto","stretch","flex-start","center","flex-end","baseline"];var d2=["300","400","500","600","700","800"],Ip=(e,t)=>e&&Object.hasOwn(e,"previous")?e.previous:t,f2=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],p2=["none","solid","dashed","dotted","double"],m2=["px","rem","em","%","vw","vh","auto"],h2=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),Kv={"font-size":{node:l(sn,{as:sv,size:12})},"line-height":{node:l(sn,{as:fv,size:12})},"letter-spacing":{node:l(sn,{as:xv,size:12})},gap:{node:l(sn,{as:yp,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:l(sn,{as:Iv,size:12})},"border-width":{node:l(sn,{as:wv,size:12})}};var g2=["static","relative","absolute","fixed","sticky"],dE=["normal","italic","oblique"],y2=["none","uppercase","lowercase","capitalize"];var b2=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],fE=["fill","contain","cover","none","scale-down"];var v2=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],w2=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],Os={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}};var Yh=null;function Ad(e){if(!e)return"";if(/^#[0-9a-f]{6}$/i.test(e))return e.toLowerCase();try{if(!Yh)Yh=document.createElement("canvas").getContext("2d");if(!Yh)return"";Yh.fillStyle="#000000",Yh.fillStyle=e;let t=Yh.fillStyle;if(/^#[0-9a-f]{6}$/i.test(t))return t.toLowerCase();let a=t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(a)return`#${[a[1],a[2],a[3]].map((n)=>Number(n).toString(16).padStart(2,"0")).join("")}`}catch{}return""}var el=(e)=>Math.min(1,Math.max(0,e));function Jh(e){let t=/^#?([0-9a-f]{6})$/i.exec(e||"");if(!t)return{r:0,g:0,b:0};let a=Number.parseInt(t[1],16);return{r:a>>16&255,g:a>>8&255,b:a&255}}function Tp({r:e,g:t,b:a}){return`#${[e,t,a].map((n)=>Math.round(n).toString(16).padStart(2,"0")).join("")}`}function $p({r:e,g:t,b:a}){e/=255,t/=255,a/=255;let n=Math.max(e,t,a),r=Math.min(e,t,a),s=n-r,o=0;if(s){if(n===e)o=(t-a)/s%6;else if(n===t)o=(a-e)/s+2;else o=(e-t)/s+4;if(o*=60,o<0)o+=360}return{h:o,s:n?s/n:0,v:n}}function Ed({h:e,s:t,v:a}){let n=a*t,r=n*(1-Math.abs(e/60%2-1)),s=a-n,o=0,i=0,u=0;if(e<60)[o,i,u]=[n,r,0];else if(e<120)[o,i,u]=[r,n,0];else if(e<180)[o,i,u]=[0,n,r];else if(e<240)[o,i,u]=[0,r,n];else if(e<300)[o,i,u]=[r,0,n];else[o,i,u]=[n,0,r];return{r:(o+s)*255,g:(i+s)*255,b:(u+s)*255}}function mn(e){if(!e)return"";let t=/^(-?\d*\.?\d+)px$/.exec(e);return t?`${Math.round(Number.parseFloat(t[1]))}px`:e}function qo(e){if(!e)return{n:"",unit:"px"};let t=e.trim(),a=/^(-?\d*\.?\d+)\s*(px|rem|em|%|vw|vh)?$/.exec(t);if(a)return{n:a[1],unit:a[2]||"px"};if(t==="auto")return{n:"",unit:"auto"};return{n:t,unit:""}}function pE(e,t){if(!e||Array.isArray(e)||Array.isArray(t)||!t)return e;if(!e.id&&!t.id){let a=(n)=>typeof n.selector==="string"&&n.selector.startsWith("[data-dc-screen=");if(a(e)&&a(t)&&e.selector===t.selector&&e.file===t.file)return{...e,authored:e.authored??t.authored,computed:e.computed??t.computed,customStyles:e.customStyles??t.customStyles,attrs:e.attrs??t.attrs,artboardId:e.artboardId??t.artboardId,worldW:e.worldW??t.worldW,worldH:e.worldH??t.worldH};return e}if(!e.id||e.id!==t.id)return e;return{...e,authored:e.authored??t.authored,computed:e.computed??t.computed,customStyles:e.customStyles??t.customStyles,attrs:e.attrs??t.attrs,photoKind:e.photoKind??t.photoKind,photoAsset:e.photoAsset??t.photoAsset}}function Qv(e,t){return(e?t?.canvasDesignSystems?.[e]:null)||t?.defaultDesignSystem||t?.designSystems?.[0]?.name||null}function Ube(e){let t={};for(let o of e.matchAll(/(--[a-z0-9-]+)\s*:\s*([^;}]+)/gi))if(!(o[1]in t))t[o[1]]=o[2].trim();let a={};for(let o of Object.keys(t)){let i=t[o],u=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(i);a[o]=u&&t[u[1]]?t[u[1]]:i}let n=Object.keys(t),r=(o)=>n.filter((i)=>o.test(i)),s=(o)=>/^(#[0-9a-f]{3,8}|rgba?\(|hsla?\(|oklch\(|oklab\(|lab\(|lch\(|hwb\(|color\()/i.test(o)||/^(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(o);return{color:n.filter((o)=>s(a[o])),space:r(/^--space-/),radius:r(/^--radius-/),type:r(/^--type-/),shadow:r(/^--shadow-/),lh:r(/^--lh-/),vals:a}}function Xv(e,t,a){let n=e?.designSystems||[],r=n.map((i)=>`${i.name}:${i.tokensCssRel}`).join("|"),[s,o]=P([]);return ee(()=>{if(!n.length)return;let i=!1;return Promise.all(n.map(async(u)=>{if(!u.tokensCssRel)return null;try{let c=await fetch(`/${t}/${u.tokensCssRel}`),f=c.ok?await c.text():"";return{name:u.name,...Ube(f)}}catch{return null}})).then((u)=>{if(i)return;let c=u.filter(Boolean);c.sort((f,p)=>f.name===a?-1:p.name===a?1:0),o(c)}),()=>{i=!0}},[r,t,a]),s}function Zv({seed:e,label:t,onApply:a}){let[n,r]=P(()=>$p(Jh(e||"#000000"))),s=me(n);s.current=n;let o=me(null),i=me(null),u=me(e);ee(()=>{if(e&&e!==u.current)u.current=e,r($p(Jh(e)))},[e]);let c=Tp(Ed(n)),f=(v)=>{v.preventDefault();let k=o.current?.getBoundingClientRect();if(!k)return;let I=s.current.h,A=(E)=>{r({h:I,s:el((E.clientX-k.left)/k.width),v:el(1-(E.clientY-k.top)/k.height)})};A(v);let N=()=>{document.removeEventListener("pointermove",A),document.removeEventListener("pointerup",N),a(Tp(Ed(s.current)))};document.addEventListener("pointermove",A),document.addEventListener("pointerup",N)},p=(v)=>{v.preventDefault();let k=i.current?.getBoundingClientRect();if(!k)return;let{s:I,v:A}=s.current,N=(R)=>{r({h:el((R.clientX-k.left)/k.width)*360,s:I,v:A})};N(v);let E=()=>{document.removeEventListener("pointermove",N),document.removeEventListener("pointerup",E),a(Tp(Ed(s.current)))};document.addEventListener("pointermove",N),document.addEventListener("pointerup",E)},m=(v)=>{let k={...s.current,...v};r(k),a(Tp(Ed(k)))},h=(v)=>{let k=v.shiftKey?0.1:0.02,A={ArrowLeft:[-k,0],ArrowRight:[k,0],ArrowUp:[0,k],ArrowDown:[0,-k]}[v.key];if(!A)return;v.preventDefault(),m({s:el(s.current.s+A[0]),v:el(s.current.v+A[1])})},b=(v)=>{let k=v.shiftKey?20:2,A={ArrowLeft:-k,ArrowRight:k}[v.key];if(A==null)return;v.preventDefault(),m({h:Math.min(360,Math.max(0,s.current.h+A))})},w=async()=>{try{let v=window.EyeDropper;if(!v)return;let k=await new v().open();if(k?.sRGBHex)r($p(Jh(k.sRGBHex))),a(k.sRGBHex)}catch{}},S=Ed(n),_=(v)=>{let k={...S,...v},I=$p({r:el(k.r/255)*255,g:el(k.g/255)*255,b:el(k.b/255)*255});r(I),a(Tp(Ed(I)))};return y("div",{className:"st-cp-cpick",children:[y("div",{className:"st-cp-cpick-hexrow",children:[l("span",{className:"st-cp-cpick-hexsw",style:{background:c}}),l("input",{className:"st-cp-cpick-hex",type:"text",value:c,"aria-label":t?`${t} hex value`:"hex value",onChange:(v)=>{let k=v.target.value;if(/^#?[0-9a-f]{6}$/i.test(k))r($p(Jh(k)))},onKeyDown:(v)=>{if(v.key==="Enter")a(v.currentTarget.value)},onBlur:(v)=>a(v.currentTarget.value),onFocus:(v)=>v.currentTarget.select()})]}),y("button",{type:"button",ref:o,className:"st-cp-cpick-sv","aria-label":t?`${t} saturation and value`:"saturation and value",style:{background:`hsl(${n.h} 100% 50%)`},onPointerDown:f,onKeyDown:h,children:[l("span",{className:"st-cp-cpick-svwhite"}),l("span",{className:"st-cp-cpick-svblack"}),l("span",{className:"st-cp-cpick-knob",style:{left:`${n.s*100}%`,top:`${(1-n.v)*100}%`,background:c}})]}),y("div",{className:"st-cp-cpick-controls",children:[window.EyeDropper?l("button",{type:"button",className:"st-cp-cpick-eye","aria-label":"pick from screen",title:"eyedropper",onClick:w,children:l(ga,{name:"eyedropper",size:14})}):null,l("span",{className:"st-cp-cpick-preview",style:{background:c},"aria-hidden":"true"}),l("button",{type:"button",ref:i,className:"st-cp-cpick-hue","aria-label":t?`${t} hue`:"hue",onPointerDown:p,onKeyDown:b,children:l("span",{className:"st-cp-cpick-huethumb",style:{left:`${n.h/360*100}%`}})})]}),l("div",{className:"st-cp-cpick-rgb",children:["r","g","b"].map((v)=>y("label",{className:"st-cp-cpick-rgbf",children:[l("input",{"aria-label":v.toUpperCase(),value:Math.round(S[v]),onChange:(k)=>_({[v]:el((Number.parseFloat(k.target.value)||0)/255)*255}),onFocus:(k)=>k.currentTarget.select()}),l("span",{children:v.toUpperCase()})]},v))})]})}function Ap({kind:e,groups:t,current:a,onPick:n,label:r,swatchBg:s,seedHex:o,activeDs:i,swatchClassName:u}){let[c,f]=P(!1),[p,m]=P(null),[h,b]=P("custom"),[w,S]=P(""),_=me(null),v=me(null),k=typeof a==="string"&&/var\(\s*--/.test(a),I=(X)=>a===`var(${X})`,A=(X)=>X.replace(/^--/,"").replace(/-/g," "),N=t||[],E=N.reduce((X,K)=>X+(K.names?.length||0),0),R=N.length>1,O=w.trim().toLowerCase(),H=!O?N:N.map((X)=>({...X,names:(X.names||[]).filter((K)=>A(K).toLowerCase().includes(O)||K.toLowerCase().includes(O)||(X.vals?.[K]||"").toLowerCase().includes(O))})).filter((X)=>X.names.length);ee(()=>{if(!c){S("");return}let X=()=>{let se=_.current?.getBoundingClientRect();if(!se)return;let Z=224,pe=300,oe=Math.min(se.right-Z,window.innerWidth-Z-8);if(oe<8)oe=8;let Je=window.innerHeight-se.bottom>pe+8?se.bottom+4:Math.max(8,se.top-pe-4);m({left:oe,top:Je,width:Z,maxHeight:pe})};X();let K=(se)=>{if(v.current?.contains(se.target)||_.current?.contains(se.target))return;f(!1)},ie=(se)=>{if(se.key==="Escape")f(!1)},G=(se)=>{if(v.current?.contains(se.target))return;X()};return document.addEventListener("pointerdown",K,!0),document.addEventListener("keydown",ie),window.addEventListener("resize",X),document.addEventListener("scroll",G,!0),()=>{document.removeEventListener("pointerdown",K,!0),document.removeEventListener("keydown",ie),window.removeEventListener("resize",X),document.removeEventListener("scroll",G,!0)}},[c]),ee(()=>{if(!c||!p||!v.current)return;let X=v.current.getBoundingClientRect(),K=p.left-X.left,ie=p.top-X.top;if(Math.abs(K)>0.5||Math.abs(ie)>0.5)m((G)=>G?{...G,left:G.left+K,top:G.top+ie}:G)},[c,p]);let V=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,q=(X,K,ie)=>{if(i&&X&&X!==i&&ie&&!V.test(ie))n(ie);else n(`var(${K})`);f(!1)},D=(X)=>{let K=(X||"").trim();if(K)n(K)},U=y("div",{className:"st-cp-pop-search",children:[l(ga,{name:"search",size:12}),l("input",{value:w,onChange:(X)=>S(X.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),z=(X)=>X.map((K)=>y("div",{className:"st-cp-pop-group",children:[R?l("div",{className:"st-cp-pop-ds",children:K.ds}):null,l("div",{className:"st-cp-pop-list",children:K.names.map((ie)=>y("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${I(ie)?" is-on":""}`,onClick:()=>q(K.ds,ie,K.vals?.[ie]),children:[l("span",{className:"st-cp-pop-cswatch",style:{background:K.vals?.[ie]||"transparent"},"aria-hidden":"true"}),l("span",{className:"st-cp-pop-name",children:A(ie)}),l("span",{className:"st-cp-pop-val",children:K.vals?.[ie]||""})]},`${K.ds}:${ie}`))})]},K.ds)),M=(X)=>X.map((K)=>y("div",{className:"st-cp-pop-group",children:[R?l("div",{className:"st-cp-pop-ds",children:K.ds}):null,l("div",{className:"st-cp-pop-list",children:K.names.map((ie)=>y("button",{type:"button",className:`st-cp-pop-row${I(ie)?" is-on":""}`,onClick:()=>q(K.ds,ie,K.vals?.[ie]),children:[l("span",{className:"st-cp-pop-name",children:A(ie)}),l("span",{className:"st-cp-pop-val",children:K.vals?.[ie]||""})]},`${K.ds}:${ie}`))})]},K.ds)),F=l("div",{className:"st-cp-pop-empty",children:"No match"});return y(te,{children:[s!==void 0?l("button",{type:"button",ref:_,className:`${u||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${k&&!u?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":c,"aria-label":r||"pick a colour",title:a||"pick a colour",onClick:()=>f((X)=>!X),children:l("span",{style:{position:"absolute",inset:0,background:s||"transparent"}})}):l("button",{type:"button",ref:_,className:`st-cp-tokbtn${k?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":c,"aria-label":r||"pick a design token",title:"design tokens",onClick:()=>f((X)=>!X),children:l("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),c&&p?vu(l("div",{ref:v,className:"maude st-cp-pop","data-theme":typeof document<"u"&&document.documentElement.getAttribute("data-theme")||"dark",role:"dialog","aria-label":r||"design tokens",style:{left:p.left,top:p.top,width:p.width,maxHeight:p.maxHeight},children:e==="color"?y(te,{children:[y("div",{className:"st-cp-poptabs",role:"tablist",children:[l("button",{type:"button",role:"tab","aria-selected":h==="custom",className:`st-cp-poptab${h==="custom"?" is-active":""}`,onClick:()=>b("custom"),children:"Custom"}),l("button",{type:"button",role:"tab","aria-selected":h==="vars",className:`st-cp-poptab${h==="vars"?" is-active":""}`,onClick:()=>b("vars"),children:"Variables"})]}),h==="custom"?l(Zv,{seed:o||Ad(a)||"#000000",onApply:D}):!E?l("div",{className:"st-cp-pop-empty",children:"No color tokens"}):y(te,{children:[U,H.length?z(H):F]})]}):!E?l("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):y(te,{children:[U,H.length?M(H):F]})}),document.body):null]})}function x2({label:e,tracks:t,editable:a,onChange:n}){let r=(u,c)=>{let f=t[u];n(t.map((p,m)=>m===u?rh.has(c)?{value:0,unit:c}:{value:f.value||1,unit:c}:p))},s=(u,c)=>{n(t.map((f,p)=>p===u?{...f,value:c}:f))},o=()=>n([...t,{value:1,unit:"fr"}]),i=(u)=>n(t.filter((c,f)=>f!==u));return y("div",{className:"st-cp-gridtracks",children:[y("div",{className:"st-cp-gridtracks-hd",children:[l("span",{className:"st-cp-gridtracks-label",children:e}),l("button",{type:"button",className:"st-btn st-cp-gridtracks-add",disabled:!a,onClick:o,children:"+ Track"})]}),t.length===0?y("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",e.toLowerCase(),"."]}):t.map((u,c)=>{let f=rh.has(u.unit);return y("div",{className:"st-cp-gridtrack-row",children:[f?l(Vl,{value:u.unit,ariaLabel:`${e} track ${c+1}`,options:c2.map((p)=>({value:p,label:p})),onChange:(p)=>r(c,p)}):l(Sr,{value:u.value,min:u.unit==="fr"?0.1:0,step:u.unit==="fr"?0.1:1,ariaLabel:`${e} track ${c+1} value`,lead:String(c+1),unitSlot:l(Ph,{value:u.unit,units:c2,ariaLabel:`${e} track ${c+1} unit`,onChange:(p)=>r(c,p)}),onCommit:(p)=>s(c,p)}),l("button",{type:"button",className:"st-btn st-cp-gridtrack-remove","aria-label":`remove ${e} track ${c+1}`,disabled:!a||t.length<=1,onClick:()=>i(c),children:"×"})]},c)})]})}var eg={pending:0,waiters:[]};function _2(e){eg.pending+=1;let t=()=>{if(eg.pending-=1,eg.pending===0)for(let a of eg.waiters.splice(0))a()};return e.then(t,t),e}function mE(){return eg.pending===0?Promise.resolve():new Promise((e)=>eg.waiters.push(e))}function hE({el:e,cfg:t,onOptimistic:a,onRecordEdit:n,onReplaceMedia:r,onUndoRedo:s,mode:o,onSetMode:i}){let u=!!e.id,c=e.computed||{},[f,p]=P({a:{},c:{},t:{}});ee(()=>{p({a:{},c:{},t:{}})},[e.id,e.authored,e.customStyles,e.attrs]);let m=(B,ae)=>{let de={...B||{}};for(let[Ce,Pe]of Object.entries(ae))if(Pe===null)delete de[Ce];else de[Ce]=Pe;return de},h=m(e.authored,f.a),b=m(e.customStyles,f.c),w=m(e.attrs,f.t),S=(B,ae)=>p((de)=>({...de,a:{...de.a,[B]:ae}})),_=(B,ae)=>p((de)=>({...de,c:{...de.c,[B]:ae}})),v=(B,ae)=>p((de)=>({...de,t:{...de.t,[B]:ae}})),k=(t?.designRel||t?.designRoot||".design").replace(/^\/+|\/+$/g,""),I=Qv(e.file,t),A=Xv(t,k,I),N=(B)=>A.map((ae)=>({ds:ae.name,names:ae[B]||[],vals:ae.vals})).filter((ae)=>ae.names.length),[E,R]=P({}),[O,H]=P({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),V=Object.keys(b).length>0||Object.keys(w).length>0;ee(()=>{if(V)H((B)=>B.Advanced?B:{...B,Advanced:!0})},[e.id,V]);let q=(h.position||mn(c.position)||"static")!=="static";ee(()=>{if(q)H((B)=>B["d:Position"]?B:{...B,"d:Position":!0})},[e.id,q]);let D=i,[U,z]=P({});async function M(B,ae,de){R((Ce)=>({...Ce,[de]:"saving"}));try{let Ce=await fetch(B,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(ae)}),Pe=await Ce.json().catch(()=>({}));return R((ct)=>({...ct,[de]:!Ce.ok||!Pe.ok?`err:${Pe&&Pe.error||`HTTP ${Ce.status}`}`:"saved"})),Ce.ok?Pe:null}catch(Ce){return R((Pe)=>({...Pe,[de]:`err:${Ce&&Ce.message?Ce.message:String(Ce)}`})),null}}let F=me(Promise.resolve()),X=(B,ae,de,Ce,Pe,ct,ft)=>{F.current=_2(F.current.then(async()=>{let Ot=await M(B,ae,de);if(!Ot?.ok)return;let Mt=Object.hasOwn(Ot,"previous")?Ot.previous:ct;if((Mt??null)===(ft??null))return;ie(Ce,Pe,Mt,ft)}))},K=(B,ae)=>{if(!a||!e.id)return;a({id:e.id,artboardId:e.artboardId??null,index:e.index??0,prop:B,value:ae})},ie=(B,ae,de,Ce)=>{n?.({op:B,canvas:e.file,id:e.id,key:ae,before:de==null||de===""?null:de,after:Ce==null||Ce===""?null:Ce})},G=(B,ae)=>{let de=(ae||"").trim();if(!u||!de)return;let Ce=h[B]??null;if(de===(Ce??"").trim())return;K(B,de),S(B,de),X("/_api/edit-css",{canvas:e.file,id:e.id,property:B,value:de},B,"css",B,Ce,de)},se=(B,ae)=>{let de=(ae||"").trim(),Ce=B.trim();if(!u||!Ce||!de)return;let Pe=b[Ce]??null;K(Ce,de),_(Ce,de),X("/_api/edit-css",{canvas:e.file,id:e.id,property:Ce,value:de},Ce,"css",Ce,Pe,de)},Z=(B,ae)=>{let de=(B||"").trim(),Ce=(ae||"").trim();if(!u||!de||!Ce)return;let Pe=w[de]??null;v(de,Ce),X("/_api/edit-attr",{canvas:e.file,id:e.id,attr:de,value:Ce},`@${de}`,"attr",de,Pe,Ce)},pe=(B)=>{if(!u)return;let ae=h[B]??null;K(B,null),S(B,null),X("/_api/edit-css",{canvas:e.file,id:e.id,property:B,reset:!0},B,"css",B,ae,null)},oe=(B)=>{if(!u)return;let ae=b[B]??null;K(B,null),_(B,null),X("/_api/edit-css",{canvas:e.file,id:e.id,property:B,reset:!0},B,"css",B,ae,null)},ye=(B)=>{if(!u)return;let ae=w[B]??null;v(B,null),X("/_api/edit-attr",{canvas:e.file,id:e.id,attr:B,reset:!0},`@${B}`,"attr",B,ae,null)},Je={display:e.parentDisplay,flexDirection:e.parentFlexDirection},Ke=(B,ae)=>{if(!u)return;let de=Math.round((B==="width"?e.bounds?.w:e.bounds?.h)||0),Ce=OI(B,ae,Je,de);for(let Pe of Ce.reset)if(h[Pe])pe(Pe);for(let[Pe,ct]of Ce.set)G(Pe,ct)},ot=e.parentDisplay==="flex"||e.parentDisplay==="inline-flex",yt=(B)=>{let ae=RI(B,h,c,Je);return y("div",{className:"st-cp-moderow",children:[l("span",{className:"st-cp-modelabel",children:B==="width"?"Width sizing":"Height sizing"}),l("div",{className:"st-cp-modeseg",role:"group","aria-label":`${B} sizing mode`,children:l(zh,{value:ae,ariaLabel:`${B} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(de)=>Ke(B,de)})})]},`mode-${B}`)},rt=["flex-start","center","flex-end"],nt=["flex-start","center","flex-end"],bt=["t","c","b"],kt=["l","c","r"],Se=()=>{let B=!(h["flex-direction"]||mn(c["flex-direction"])||"row").startsWith("column"),ae=Math.max(0,rt.indexOf(h["justify-content"]||mn(c["justify-content"])||"flex-start")),de=h["align-items"]||mn(c["align-items"])||"stretch",Ce=de==="stretch"?1:Math.max(0,nt.indexOf(de)),[Pe,ct]=B?[ae,Ce]:[Ce,ae];return bt[ct]+kt[Pe]},qe=(B)=>{let ae=bt.indexOf(B[0]),de=kt.indexOf(B[1]),Ce=!(h["flex-direction"]||mn(c["flex-direction"])||"row").startsWith("column"),[Pe,ct]=Ce?[de,ae]:[ae,de];G("justify-content",rt[Pe]),G("align-items",nt[ct])},_e=(B)=>{if(!(B.metaKey||B.ctrlKey)||B.altKey)return;let ae=B.key.toLowerCase();if(ae==="z")B.preventDefault(),s?.(B.shiftKey?"redo":"undo");else if(ae==="y")B.preventDefault(),s?.("redo")},Ye=(B)=>{let ae=h[B];if(!ae)return"inherit";return/var\(\s*--/.test(ae)?"bound":"raw"};if(!u)return y("div",{className:"st-cp",children:[l("div",{className:"st-cp-id",children:l("span",{className:"st-cp-idtag",children:e.tag||"element"})}),y("div",{className:"st-css-disabled",children:["This selection has no stable element id (a legacy canvas, or a non-element target). Edit it with ",l("code",{children:"/design:edit"}),"."]})]});let He={bound:"token-bound",raw:"raw override",inherit:"inherited"},ht=(B)=>l("span",{className:`st-cp-prov st-cp-prov--${B}`,role:"img","aria-label":He[B]}),Xt=(B,ae)=>{let de=ae??Ye(B),Ce=E[B],Pe=typeof Ce==="string"&&Ce.startsWith("err:")?Ce.slice(4):"",ct=Pe?" is-err":Ce==="saved"?" is-saved":Ce==="saving"?" is-saving":"",ft=!!h[B],Ot=Pe?`error: ${Pe}`:ft?`${He[de]} · double-click to reset`:He[de];return l("button",{type:"button",className:`st-cp-prov st-cp-prov--${de}${ct}${ft?" is-resettable":""}`,"aria-label":Ot,title:Ot,tabIndex:ft?0:-1,onDoubleClick:ft?()=>pe(B):void 0,onKeyDown:ft?(Mt)=>{if(Mt.key==="Backspace"||Mt.key==="Delete")Mt.preventDefault(),pe(B)}:void 0})},Ne=(B,ae,de,Ce)=>{let Pe=de===void 0&&!h[B],ct=Ce??B;return y("div",{className:`st-cp-row${Pe?" is-unset":""}`,children:[Xt(B,de),l("label",{className:"st-cp-label",title:ct,children:ct}),l("div",{className:"st-cp-ctl",children:ae})]},B)},At={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"]},ua=(B)=>{(At[B]||[]).forEach((ae)=>{if(h[ae])pe(ae)})},Be=(B,ae)=>{let de=(At[B]||[]).some((Ce)=>h[Ce]);return y("section",{className:"st-cp-sec",children:[y("div",{className:"st-cp-sechd-row",children:[y("button",{type:"button",className:"st-cp-sechd","data-testid":`inspector-section-${B.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,"aria-expanded":!!O[B],onClick:()=>H((Ce)=>({...Ce,[B]:!Ce[B]})),children:[l("span",{className:"st-cp-caret","aria-hidden":"true",children:O[B]?"▾":"▸"}),B]}),l("button",{type:"button",className:`st-cp-secreset${de?"":" is-quiet"}`,"aria-label":`reset ${B} section to original`,title:`reset ${B}`,disabled:!de,onClick:()=>ua(B),children:l(sn,{as:vp,size:12})})]}),l("div",{className:`st-cp-sec-anim${O[B]?" is-open":""}`,children:l("div",{className:"st-cp-sec-inner",children:ae})})]},B)},fe=(B,ae,de,Ce=!0)=>{let Pe=`d:${B}`,ct=O[Pe]===void 0?Ce:O[Pe],ft=ae.some((Ot)=>h[Ot]);return y("section",{className:"st-cp-sec",children:[y("div",{className:"st-cp-sechd-row",children:[y("button",{type:"button",className:"st-cp-sechd","aria-expanded":ct,onClick:()=>H((Ot)=>({...Ot,[Pe]:!ct})),children:[l("span",{className:"st-cp-caret","aria-hidden":"true",children:ct?"▾":"▸"}),B]}),l("button",{type:"button",className:`st-cp-secreset${ft?"":" is-quiet"}`,"aria-label":`reset ${B} to original`,title:`reset ${B}`,disabled:!ft,onClick:()=>ae.forEach((Ot)=>{if(h[Ot])pe(Ot)}),children:l(sn,{as:vp,size:12})})]}),l("div",{className:`st-cp-sec-anim${ct?" is-open":""}`,children:l("div",{className:"st-cp-sec-inner",children:de})})]},Pe)},Ze=(B)=>l("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!U[B],"aria-label":U[B]?`${B} — fewer options`:`${B} — more options`,title:U[B]?"fewer":"more",onClick:()=>z((ae)=>({...ae,[B]:!ae[B]})),children:U[B]?"▴":"···"}),he=(B,ae)=>y("select",{className:"st-cp-nsel","aria-label":B,value:ae.includes(h[B])?h[B]:"",onChange:(de)=>G(B,de.target.value),children:[l("option",{value:"",disabled:!0,children:mn(c[B])||"—"}),ae.map((de)=>l("option",{value:de,children:de},de))]}),Le=(B)=>N(B).flatMap((ae)=>(ae.names||[]).map((de)=>({name:de,value:ae.vals?.[de]||""}))),Ie=(B,ae)=>l(F_,{value:h[B]||mn(c[B])||ae[0].value,ariaLabel:B,options:ae,onChange:(de)=>G(B,de)}),ue=(B,ae,de={})=>{let Ce=qo(h[B]??""),Pe=h2.has(B),ct=h[B]??"",ft=typeof ct==="string"&&/var\(\s*--/.test(ct),Ot=Pe?"":Ce.unit&&Ce.unit!=="auto"?Ce.unit:"px",Mt=Number.parseFloat(qo(mn(c[B])??"").n)||0,da=Ce.n!==""&&Ce.n!=null?Number.parseFloat(Ce.n)||0:Mt,Ta=Kv[B];return l(Bh,{value:ft?ct:da,tokens:Le(ae),ariaLabel:B,min:de.min??0,lead:Ta?Ta.node??Ta.t:void 0,unitSlot:Pe?null:l(Ph,{units:m2,value:Ce.unit||"px",ariaLabel:`${B} unit`,onChange:(Ma)=>G(B,Ma==="auto"?"auto":`${Ce.n||"0"}${Ma}`)}),onChange:(Ma)=>G(B,typeof Ma==="string"?Ma:Pe?`${Ma}`:`${Ma}${Ot}`)})},be=()=>{let B=(Pe)=>Number.parseFloat(qo(h[Pe]??h["border-radius"]??mn(c[Pe])??mn(c["border-radius"])??"0").n)||0,ae={tl:B("border-top-left-radius"),tr:B("border-top-right-radius"),bl:B("border-bottom-left-radius"),br:B("border-bottom-right-radius")},de=(Pe)=>{if(Pe.tl===Pe.tr&&Pe.tr===Pe.bl&&Pe.bl===Pe.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((ft)=>{if(h[ft])pe(ft)}),G("border-radius",`${Pe.tl}px`);else G("border-top-left-radius",`${Pe.tl}px`),G("border-top-right-radius",`${Pe.tr}px`),G("border-bottom-left-radius",`${Pe.bl}px`),G("border-bottom-right-radius",`${Pe.br}px`)},Ce=Kv["border-radius"];return l(rA,{corners:ae,lead:Ce?Ce.node??Ce.t:void 0,onCorners:de})},Te=()=>y("div",{className:"st-cp-border",children:[Yt("border-width",null,{fixedUnit:"px"}),y("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:p2.includes(h["border-style"])?h["border-style"]:"",onChange:(B)=>G("border-style",B.target.value),children:[l("option",{value:"",disabled:!0,children:"style"}),p2.map((B)=>l("option",{value:B,children:B},B))]}),l(Ap,{kind:"color",groups:N("color"),current:h["border-color"],activeDs:I,swatchBg:c["border-color"]||h["border-color"]||"",seedHex:Ad(c["border-color"]||h["border-color"])||"#000000",onPick:(B)=>G("border-color",B),label:"border colour"})]}),tt=()=>{let B=h.transform||mn(c.transform)||"",ae=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(B),de=((ae?Number.parseFloat(ae[1]):0)%360+360)%360,Ce=(Pe)=>{let ct=(Pe%360+360)%360,ft=(h.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();G("transform",`${ft?`${ft} `:""}rotate(${ct}deg)`.trim())};return y("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[l(nA,{value:de,onChange:Ce}),l(Sr,{value:de,min:0,max:360,ariaLabel:"rotation",lead:l(sn,{as:vp}),steppers:!1,unitSlot:l("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:Ce})]})},we=()=>{let B=h.filter||mn(c.filter)||"",ae=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(B),de=ae?Number.parseFloat(ae[1]):0;return l(Sr,{value:de,min:0,ariaLabel:"filter blur",unitSlot:l("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(Pe)=>{let ct=(h.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();G("filter",Pe>0?`${ct?`${ct} `:""}blur(${Pe}px)`.trim():ct||"none")}})},Ue=()=>{let B=h.opacity,ae=B!=null&&B!==""?Number.parseFloat(B):Number.parseFloat(mn(c.opacity))||1,de=Math.round((Number.isNaN(ae)?1:ae)*100);return l(co,{value:de,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(Ce)=>K("opacity",String(Ce/100)),onCommit:(Ce)=>G("opacity",String(Ce/100))},`opacity:${B??""}`)},lt=()=>{let B=Number.parseInt(h["font-weight"]||mn(c["font-weight"])||"400",10)>=600,ae=(h["font-style"]||mn(c["font-style"]))==="italic",de=/underline/.test(h["text-decoration"]||mn(c["text-decoration"])||"");return l(tA,{value:{b:B,i:ae,u:de},ariaLabel:"text style",options:[{value:"b",node:l(sn,{as:pv}),label:"Bold"},{value:"i",node:l(sn,{as:bv}),label:"Italic"},{value:"u",node:l(sn,{as:Av}),label:"Underline"}],onToggle:(Ce)=>{if(Ce==="b")G("font-weight",B?"400":"700");else if(Ce==="i")G("font-style",ae?"normal":"italic");else G("text-decoration",de?"none":"underline")}})},le=[{value:"row",node:l(sn,{as:gd}),label:"Row"},{value:"column",node:l(sn,{as:yd}),label:"Column"}],We=[{value:"flex-start",node:l(sn,{as:lv}),label:"Start"},{value:"center",node:l(sn,{as:ov}),label:"Center"},{value:"flex-end",node:l(sn,{as:iv}),label:"End"},{value:"space-between",node:l(sn,{as:yp}),label:"Space between"}],xt=[{value:"flex-start",node:l(sn,{as:dv}),label:"Start"},{value:"center",node:l(sn,{as:uv}),label:"Center"},{value:"flex-end",node:l(sn,{as:cv}),label:"End"},{value:"stretch",node:l(sn,{as:Tv}),label:"Stretch"}],Wt=[{value:"left",node:l(sn,{as:Yi}),label:"Left"},{value:"center",node:l(sn,{as:wd}),label:"Center"},{value:"right",node:l(sn,{as:_d}),label:"Right"},{value:"justify",node:l(sn,{as:xd}),label:"Justify"}],pa=[{value:"visible",node:l(sn,{as:bp}),label:"Visible"},{value:"hidden",node:l(sn,{as:wp}),label:"Hidden"},{value:"scroll",node:l(sn,{as:Cv}),label:"Scroll"}],Qa=(B,ae)=>{let de=N(ae);return de.length?l(Ap,{kind:"value",groups:de,current:h[B],activeDs:I,onPick:(Ce)=>G(B,Ce),label:`${B} design token`}):null},Pt=(B)=>{let ae=B.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===ae)ae.select()})},pn=(B,ae)=>{if(B.key!=="ArrowUp"&&B.key!=="ArrowDown")return!1;B.preventDefault();let de=B.shiftKey?10:1,Ce=B.key==="ArrowUp"?1:-1,Pe=(Number.parseFloat(B.currentTarget.value)||0)+Ce*de;return B.currentTarget.value=String(Pe),ae(Pe),!0},Dt=(B)=>l("input",{className:"st-cp-fin","aria-label":B,defaultValue:h[B]??"",placeholder:mn(c[B])||"—",onFocus:Pt,onKeyDown:(ae)=>{if(ae.key==="Enter")ae.currentTarget.blur()},onBlur:(ae)=>G(B,ae.currentTarget.value)},`${B}:${h[B]??""}`),Yt=(B,ae,de={})=>{let Ce=qo(h[B]??""),Pe=h2.has(B),ct=Pe?"":de.fixedUnit||(Ce.unit&&Ce.unit!=="auto"?Ce.unit:"px"),ft=Kv[B],Ot=Number.parseFloat(qo(mn(c[B])??"").n)||0,Mt=Ce.n!==""&&Ce.n!=null?Number.parseFloat(Ce.n)||0:Ot;return y(te,{children:[l(Sr,{value:Mt,min:de.min??0,step:1,ariaLabel:B,lead:ft?ft.node??ft.t:void 0,onCommit:(da)=>G(B,Pe?`${da}`:`${da}${ct}`),unitSlot:Pe||de.fixedUnit?null:l(Ph,{units:m2,value:Ce.unit||"px",ariaLabel:`${B} unit`,onChange:(da)=>G(B,da==="auto"?"auto":`${Ce.n||"0"}${da}`)})},`${B}:${h[B]??""}`),Qa(B,ae)]})},Vt=(B)=>{let ae=c[B]||h[B]||"",de=h[B]??"",Ce=typeof de==="string"&&/var\(\s*--/.test(de),Pe=Ce?de.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):de;return l(xp,{swatch:l(Ap,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:N("color"),current:h[B],activeDs:I,swatchBg:ae,seedHex:Ad(c[B]||h[B])||"#000000",onPick:(ct)=>G(B,ct),label:`${B} colour`}),displayValue:Pe,bound:Ce,ariaLabel:B,onValue:(ct)=>G(B,ct)})},ke=(B,ae)=>{let de=null,Ce=ae.unitless?"":"px",Pe=(Ot)=>ae.unitless?`${Ot}`:`${Ot}${Ce}`,ct=(Ot,Mt,da)=>{for(let Ta of Mt??[B])da(Ta,Pe(Ot))},ft=U_({getBase:()=>de?.value??"0",min:ae.min??0,step:1,sides:ae.sides,onInput:(Ot,Mt)=>{if(de)de.value=String(Ot);if(Mt){let da=de?.closest(".st-cp-box");for(let Ta of Mt){if(Ta===B)continue;let Ma=da?.querySelector(`.st-cp-boxv[aria-label="${Ta}"]`);if(Ma)Ma.value=String(Ot)}}ct(Ot,Mt,K)},onCommit:(Ot,Mt)=>ct(Ot,Mt,G)});return{onPointerDown:(Ot)=>{de=Ot.currentTarget,ft(Ot)}}},dt=(B,ae)=>{let de=h[B],Ce=de!=null&&de!==""?qo(de).n||de:qo(mn(c[B])??"").n||"0",Pe=!de||de==="0"||de==="0px"||de==="auto",ct=B.split("-").pop(),ft=ct==="top"||ct==="bottom"?[`${ae}-top`,`${ae}-bottom`]:[`${ae}-left`,`${ae}-right`],Ot=[`${ae}-top`,`${ae}-right`,`${ae}-bottom`,`${ae}-left`];return l("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${ae[0]}${B.split("-").pop()[0]}${Pe?" is-zero":""}`,"aria-label":B,defaultValue:Ce,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...ke(B,{sides:{pair:ft,all:Ot}}),onFocus:Pt,onKeyDown:(Mt)=>{if(pn(Mt,(da)=>G(B,`${da}px`)))return;if(Mt.key==="Enter")Mt.currentTarget.blur()},onBlur:(Mt)=>{let da=Mt.currentTarget.value.trim();if(!da)return;let Ta=/[a-z%]/i.test(da)?da:`${da}px`;G(B,Ta)}},`${B}:${de??""}`)},Bt=(B)=>{let ae=h[B],de=ae!=null&&ae!==""&&ae!=="auto"?qo(ae).n||ae:qo(mn(c[B])??"").n||"",Ce=!ae||ae==="auto"||ae==="0"||ae==="0px",Pe=B==="top"||B==="bottom"?["top","bottom"]:["left","right"],ct=["top","right","bottom","left"];return l("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${B[0]}${Ce?" is-zero":""}`,"aria-label":B,defaultValue:de,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...ke(B,{sides:{pair:Pe,all:ct},min:-1/0}),onFocus:Pt,onKeyDown:(ft)=>{if(pn(ft,(Ot)=>G(B,`${Ot}px`)))return;if(ft.key==="Enter")ft.currentTarget.blur()},onBlur:(ft)=>{let Ot=ft.currentTarget.value.trim();if(!Ot)return;let Mt=/[a-z%]/i.test(Ot)?Ot:`${Ot}px`;G(B,Mt)}},`${B}:${ae??""}`)},oa=Object.entries(b),Pa=Object.entries(w),Va=()=>{let B=(e.tag||"").toLowerCase(),de=B==="img"||B==="video"||B==="picture"||B==="svg"||B==="canvas"||!!h["object-fit"]||!!h["object-position"]||!!h["aspect-ratio"],Ce=(B==="img"||B==="video")&&!!e.attrs?.src&&!!r;return{showMedia:de,canReplace:Ce}},Ve=(B)=>y(te,{children:[B&&l("div",{className:"st-cp-mediabtn",children:l("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>r(e),children:"Replace…"})}),Ne("object-fit",he("object-fit",fE)),Ne("object-position",Dt("object-position")),Ne("aspect-ratio",y("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:w2.includes(h["aspect-ratio"])?h["aspect-ratio"]:"",onChange:(ae)=>{let de=ae.target.value;if(G("aspect-ratio",de),de&&de!=="auto"&&h.height)pe("height")},children:[l("option",{value:"",disabled:!0,children:mn(c["aspect-ratio"])||"—"}),w2.map((ae)=>l("option",{value:ae,children:ae},ae))]}))]});return y("div",{className:`st-cp${o==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:_e,children:[y("div",{className:"st-cp-id",children:[y("span",{className:"st-cp-idtag",children:[e.tag||"element",e.classes?y("span",{className:"st-cp-idcls",children:[".",e.classes.split(/\s+/)[0]]}):null]}),l("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:l(F_,{value:o,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:l(sn,{as:hd,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:l(sn,{as:Sd,size:12}),label:"Designer — Figma vocabulary"}],onChange:D})})]}),o==="designer"?y(te,{children:[fe("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let B=(h.display||mn(c.display)||"").trim();return B==="flex"||B==="inline-flex"?y(te,{children:[Ne("flex-direction",Ie("flex-direction",le),void 0,"Direction"),Ne("align-items",l(aA,{value:Se(),onChange:qe,ariaLabel:"auto-layout alignment"}),Ye("align-items"),"Alignment"),Ne("gap",ue("gap","space"),void 0,"Gap"),y("div",{className:"st-cp-modes",children:[yt("width"),yt("height")]}),y("div",{className:"st-cp-box","aria-label":"padding",children:[y("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[ht(Ye("padding-top")),"padding"]}),dt("padding-top","padding"),dt("padding-right","padding"),dt("padding-bottom","padding"),dt("padding-left","padding")]}),l("div",{className:"st-cp-clustermore-row",children:Ze("Auto layout")}),U["Auto layout"]?Ne("flex-wrap",l(Ji,{checked:/^wrap/.test(h["flex-wrap"]||mn(c["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(de)=>G("flex-wrap",de?"wrap":"nowrap")}),Ye("flex-wrap"),"Wrap"):null]}):l("button",{type:"button",className:"st-cp-makeflex",disabled:!u,onClick:()=>G("display","flex"),children:"+ Auto layout (flex)"})})()),fe("Size",["width","height","min-width","max-width","min-height","max-height"],y(te,{children:[Ne("width",Yt("width"),void 0,"Width"),Ne("height",Yt("height"),void 0,"Height"),l("div",{className:"st-cp-clustermore-row",children:Ze("Size")}),U.Size?y(te,{children:[Ne("min-width",Yt("min-width"),void 0,"Min width"),Ne("max-width",Yt("max-width"),void 0,"Max width"),Ne("min-height",Yt("min-height"),void 0,"Min height"),Ne("max-height",Yt("max-height"),void 0,"Max height")]}):null]})),fe("Position",["position","top","right","bottom","left","z-index"],y(te,{children:[Ne("position",he("position",g2),void 0,"Position"),y("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[y("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[ht(Ye("top")),"inset"]}),Bt("top"),Bt("right"),Bt("bottom"),Bt("left"),l("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:h.position||mn(c.position)||"static"})]}),(h.position||mn(c.position)||"static")==="static"?l("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,l("div",{className:"st-cp-clustermore-row",children:Ze("Position")}),U.Position?Ne("z-index",Yt("z-index"),void 0,"Layer order"):null]}),!1),fe("Fill",["background-color"],Ne("background-color",Vt("background-color"),void 0,"Fill")),fe("Stroke",["border-width","border-style","border-color"],Ne("border",Te(),Ye("border-width"),"Stroke")),fe("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],Ne("border-radius",be(),Ye("border-radius"),"Corner radius")),fe("Effects",["box-shadow","filter","mix-blend-mode"],y(te,{children:[Ne("box-shadow",Qa("box-shadow","shadow")||Dt("box-shadow"),void 0,"Shadow"),Ne("filter",we(),Ye("filter"),"Blur"),Ne("mix-blend-mode",he("mix-blend-mode",v2),void 0,"Blend")]})),fe("Opacity",["opacity"],Ne("opacity",Ue(),void 0,"Opacity")),fe("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],y(te,{children:[Ne("font-family",he("font-family",f2),void 0,"Font"),Ne("color",Vt("color"),void 0,"Color"),Ne("font-size",ue("font-size","type"),void 0,"Size"),Ne("font-weight",he("font-weight",d2),void 0,"Weight"),Ne("line-height",Yt("line-height","lh"),void 0,"Line height"),Ne("text-align",Ie("text-align",Wt),void 0,"Align"),l("div",{className:"st-cp-clustermore-row",children:Ze("Text")}),U.Text?y(te,{children:[Ne("letter-spacing",Yt("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),Ne("font-style",he("font-style",dE),void 0,"Style"),Ne("text-transform",he("text-transform",y2),void 0,"Case"),Ne("white-space",he("white-space",b2),void 0,"Whitespace")]}):null]})),fe("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],y("div",{className:"st-cp-box","aria-label":"margin",children:[y("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[ht(Ye("margin-top")),"margin"]}),dt("margin-top","margin"),dt("margin-right","margin"),dt("margin-bottom","margin"),dt("margin-left","margin")]})),(()=>{let{showMedia:B,canReplace:ae}=Va();return B?fe("Media",["object-fit","object-position","aspect-ratio"],Ve(ae)):null})()]}):y(te,{children:[Be("Layout",(()=>{let B=(h.display||mn(c.display)||"").trim(),ae=B==="flex"||B==="inline-flex",de=B==="grid"||B==="inline-grid";return y(te,{children:[Ne("display",he("display",uE)),ae?y(te,{children:[Ne("flex-direction",Ie("flex-direction",le)),Ne("flex-wrap",l(Ji,{checked:/^wrap/.test(h["flex-wrap"]||mn(c["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(Ce)=>G("flex-wrap",Ce?"wrap":"nowrap")}),Ye("flex-wrap"))]}):null,ae||de?y(te,{children:[Ne("align-items",Ie("align-items",xt)),Ne("justify-content",Ie("justify-content",We)),Ne("gap",ue("gap","space"))]}):l("button",{type:"button",className:"st-cp-makeflex",disabled:!u,onClick:()=>G("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let B=(h.display||mn(c.display)||"").trim();if(!(B==="grid"||B==="inline-grid"))return null;let de=h["grid-template-columns"]||"",Ce=h["grid-template-rows"]||"",Pe=O1(de),ct=O1(Ce),ft=Pe.length>0||!de.trim(),Ot=ct.length>0||!Ce.trim();return Be("Grid",y(te,{children:[ft?l(x2,{label:"Columns",tracks:Pe,editable:u,onChange:(Mt)=>G("grid-template-columns",D1(Mt))}):y("div",{className:"st-cp-note",children:["Columns use ",l("code",{children:de})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),Ot?l(x2,{label:"Rows",tracks:ct,editable:u,onChange:(Mt)=>G("grid-template-rows",D1(Mt))}):y("div",{className:"st-cp-note",children:["Rows use ",l("code",{children:Ce})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),Be("Position",y(te,{children:[Ne("position",he("position",g2)),y("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[y("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[ht(Ye("top")),"inset"]}),Bt("top"),Bt("right"),Bt("bottom"),Bt("left"),l("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:h.position||mn(c.position)||"static"})]}),(h.position||mn(c.position)||"static")==="static"?l("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,Ne("z-index",Yt("z-index"))]})),(e.parentDisplay==="grid"||e.parentDisplay==="inline-grid")&&Be("Grid item",y(te,{children:[y("div",{className:"st-cp-note",children:["Manual cell placement — ",l("code",{children:"start / end"})," or ",l("code",{children:"start / span N"}),"."]}),Ne("grid-column",Dt("grid-column")),Ne("grid-row",Dt("grid-row"))]})),Be("Typography",y(te,{children:[Ne("font-family",he("font-family",f2)),Ne("color",Vt("color")),Ne("font-size",ue("font-size","type")),Ne("font-weight",he("font-weight",d2)),Ne("line-height",Yt("line-height","lh")),Ne("letter-spacing",Yt("letter-spacing",null,{min:-1/0})),Ne("text-align",Ie("text-align",Wt)),Ne("font-style",lt(),Ye("font-style")),Ne("text-transform",he("text-transform",y2)),Ne("white-space",he("white-space",b2))]})),Be("Spacing",l(te,{children:y("div",{className:"st-cp-box","aria-label":"margin and padding",children:[y("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[ht(Ye("margin-top")),"margin"]}),dt("margin-top","margin"),dt("margin-right","margin"),dt("margin-bottom","margin"),dt("margin-left","margin"),y("div",{className:"st-cp-boxpad",children:[y("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[ht(Ye("padding-top")),"padding"]}),dt("padding-top","padding"),dt("padding-right","padding"),dt("padding-bottom","padding"),dt("padding-left","padding"),y("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(h.width)||e.bounds?.w||0)," × ",Math.round(Number.parseFloat(h.height)||e.bounds?.h||0)]})]})]})})),Be("Size",y(te,{children:[y("div",{className:"st-cp-modes",children:[yt("width"),yt("height")]}),Ne("width",Yt("width")),Ne("height",Yt("height")),Ne("min-width",Yt("min-width")),Ne("max-width",Yt("max-width")),Ne("min-height",Yt("min-height")),Ne("max-height",Yt("max-height")),Ne("overflow",Ie("overflow",pa)),ot?y(te,{children:[l("div",{className:"st-cp-subhd",children:"In flex parent"}),Ne("align-self",he("align-self",cE)),Ne("flex-grow",Yt("flex-grow",null,{unitless:!0})),Ne("flex-shrink",Yt("flex-shrink",null,{unitless:!0})),Ne("flex-basis",Yt("flex-basis"))]}):null]})),(()=>{let{showMedia:B,canReplace:ae}=Va();return B?Be("Media",Ve(ae)):null})(),Be("Appearance",y(te,{children:[Ne("background-color",Vt("background-color")),Ne("border-radius",be(),Ye("border-radius")),Ne("border",Te(),Ye("border-width")),Ne("box-shadow",Qa("box-shadow","shadow")||Dt("box-shadow")),Ne("filter",we(),Ye("filter")),Ne("mix-blend-mode",he("mix-blend-mode",v2)),Ne("opacity",Ue()),Ne("rotation",tt(),Ye("transform")),Ne("transform",Dt("transform")),Ne("transform-origin",Dt("transform-origin"))]})),(()=>{let B=Object.entries(E).find(([,ae])=>typeof ae==="string"&&ae.startsWith("err:"));return B?y("div",{className:"st-cp-save is-err",role:"status",children:[l(ga,{name:"x",size:12}),B[0],": ",B[1].slice(4)]}):null})(),Be("Advanced",y("div",{className:"st-cp-advbody",children:[oa.length?y(te,{children:[l("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),oa.map(([B,ae])=>y("div",{className:"st-cp-kv",children:[l("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:B,"aria-label":`custom property ${B} name`}),l("input",{className:"st-cp-fin",defaultValue:ae,"aria-label":`${B} value`,onKeyDown:(de)=>{if(de.key==="Enter")de.currentTarget.blur()},onBlur:(de)=>se(B,de.currentTarget.value)},`cs:${B}:${ae}`),l("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${B}`,title:"remove",onClick:()=>oe(B),children:l(ga,{name:"x",size:11})})]},`cs:${B}`))]}):null,l("div",{className:"st-cp-advgrp",children:"Add CSS property"}),l(Fbe,{commit:se}),l("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),Pa.length?y(te,{children:[l("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),Pa.map(([B,ae])=>y("div",{className:"st-cp-kv",children:[l("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:B,"aria-label":`attribute ${B} name`}),l("input",{className:"st-cp-fin",defaultValue:ae,"aria-label":`${B} value`,onKeyDown:(de)=>{if(de.key==="Enter")de.currentTarget.blur()},onBlur:(de)=>Z(B,de.currentTarget.value)},`at:${B}:${ae}`),l("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${B}`,title:"remove",onClick:()=>ye(B),children:l(ga,{name:"x",size:11})})]},`at:${B}`))]}):null,l("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),l(jbe,{commit:Z})]}))]}),y("div",{className:"st-cp-legend",children:[y("span",{children:[l("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),y("span",{children:[l("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),y("span",{children:[l("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},e.id)}function Fbe({commit:e}){let[t,a]=P(""),[n,r]=P(""),s=()=>{if(t.trim()&&n.trim())e(t.trim(),n),a(""),r("")};return y("div",{className:"st-cp-kv",children:[l("input",{className:"st-cp-fin","aria-label":"custom property name",placeholder:"property",value:t,onChange:(o)=>a(o.target.value)}),l("input",{className:"st-cp-fin","aria-label":"custom property value",placeholder:"value",value:n,onChange:(o)=>r(o.target.value),onKeyDown:(o)=>{if(o.key==="Enter")s()},onBlur:s})]})}function jbe({commit:e}){let[t,a]=P(""),[n,r]=P(""),s=()=>{if(t.trim()&&n.trim())e(t.trim(),n),a(""),r("")};return y("div",{className:"st-cp-kv",children:[l("input",{className:"st-cp-fin","aria-label":"custom attribute name",placeholder:"data-…",value:t,onChange:(o)=>a(o.target.value)}),l("input",{className:"st-cp-fin","aria-label":"custom attribute value",placeholder:"value",value:n,onChange:(o)=>r(o.target.value),onKeyDown:(o)=>{if(o.key==="Enter")s()},onBlur:s})]})}var Hbe={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function gE(e,t,a,n){if(!Array.isArray(e)||t===a)return e;let r=JSON.parse(JSON.stringify(e)),s=null,o=(u)=>{for(let c=0;c<u.length;c++){if(u[c].id===t)return s=u[c],u.splice(c,1),!0;if(u[c].children&&o(u[c].children))return!0}return!1};if(o(r),!s)return e;let i=(u)=>{for(let c=0;c<u.length;c++){if(u[c].id===a){if(n==="inside-start"||n==="inside-end")if(u[c].children=u[c].children||[],n==="inside-start")u[c].children.unshift(s);else u[c].children.push(s);else u.splice(n==="before"?c:c+1,0,s);return!0}if(u[c].children&&i(u[c].children))return!0}return!1};return i(r)?r:e}var yE=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function S2({node:e,depth:t,selectedId:a,selectedIndex:n,collapsed:r,hiddenOverride:s,onToggle:o,onSelect:i,onHover:u,onToggleVisibility:c,onReorder:f,onRowPointerDown:p,dragState:m,componentMap:h,lockedKeys:b,onToggleLock:w,onRename:S}){let _=`${e.id}:${e.index}`,v=e.children&&e.children.length>0,k=r.has(_),I=!!e.synthetic,A=!I&&h?h[e.id]:null,N=!I&&!!b?.has(_),[E,R]=P(!1),[O,H]=P(""),V=!I&&e.id===a&&(n==null||e.index===n),q=s?.has(_)?s.get(_):!!e.hidden,D=!!f&&!I&&!N,U=()=>{R(!1);let F=O.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!F||F===(e.dcElement??""))return;S?.(e,F)},z=m?.key===_,M=z?{transform:`translate(${m.dx}px, ${m.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 y(te,{children:[y("div",{className:"st-layer st-layer--row"+(V?" is-sel":"")+(q?" is-hidden":"")+(I?" is-group":"")+(A?" is-instance":"")+(N?" is-locked":""),style:{paddingLeft:6+t*14,...M},role:"treeitem","aria-selected":I?void 0:V,"aria-expanded":v?!k:void 0,"aria-grabbed":D?z:void 0,tabIndex:0,title:I?`${e.tag} · group (unstamped wrapper)`:`${e.tag} · ${e.type}${S?" · F2 to rename":""}`,"data-layer-key":_,onClick:()=>I?v&&o(_):i(e),onMouseEnter:()=>!I&&u(e),onMouseLeave:()=>u(null),onPointerDown:D?(F)=>p(F,e,_):void 0,onKeyDown:(F)=>{if(F.key==="Enter"||F.key===" ")if(F.preventDefault(),I)v&&o(_);else i(e);else if(F.key==="F2"&&S&&!I)F.preventDefault(),H(e.dcElement||e.label||""),R(!0)},children:[v?l("button",{type:"button",className:"st-layer-caret","aria-label":k?"Expand":"Collapse",onClick:(F)=>{F.stopPropagation(),o(_)},children:k?"▸":"▾"}):l("span",{className:"st-layer-caret","aria-hidden":"true"}),A?l("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:A.root?"◆":"◇"}):l(ga,{name:Hbe[e.type]||"box",size:12,className:"st-layer-ticon"}),E?l("input",{className:"st-layer-rename",value:O,autoFocus:!0,"aria-label":`Rename ${e.label}`,onFocus:(F)=>F.target.select(),onChange:(F)=>H(F.target.value),onClick:(F)=>F.stopPropagation(),onPointerDown:(F)=>F.stopPropagation(),onBlur:U,onKeyDown:(F)=>{if(F.stopPropagation(),F.key==="Enter")U();else if(F.key==="Escape")R(!1)}}):l("span",{className:"st-layer-label",onDoubleClick:S&&!I?(F)=>{F.stopPropagation(),H(e.dcElement||e.label||""),R(!0)}:void 0,children:e.label}),l("span",{className:"st-layer-type",children:A?A.component:e.type}),w&&!I?l("button",{type:"button",className:"st-layer-lock","aria-label":N?`Unlock ${e.label}`:`Lock ${e.label}`,"aria-pressed":N,title:N?"Unlock":"Lock",onClick:(F)=>{F.stopPropagation(),w(_)},children:l(ga,{name:N?"lock":"unlock",size:12})}):null,c&&!I?l("button",{type:"button",className:"st-layer-eye","aria-label":q?`Show ${e.label}`:`Hide ${e.label}`,"aria-pressed":q,title:q?"Show":"Hide",onClick:(F)=>{F.stopPropagation(),c(e)},children:l(ga,{name:q?"eye-off":"eye",size:13})}):null]}),v&&!k?e.children.map((F,X)=>l(S2,{node:F,depth:t+1,selectedId:a,selectedIndex:n,collapsed:r,hiddenOverride:s,onToggle:o,onSelect:i,onHover:u,onToggleVisibility:c,onReorder:f,onRowPointerDown:p,dragState:m,componentMap:h,lockedKeys:b,onToggleLock:w,onRename:S},`${F.id}:${F.index}`)):null]})}function bE({el:e}){let t=e?.computed||{},a=e?.authored||{},n=(c)=>{let f=a[c];if(f&&/var\(\s*--/.test(f))return f.replace(/^var\(\s*|\s*\)$/g,"");return t[c]||f||""},r=(c,f)=>{let p=t[f]||a[f];if(!p)return null;return y("div",{className:"st-insp-row",children:[l("span",{className:"st-insp-label",children:c}),y("div",{className:"st-swatch-row",children:[l("span",{className:"st-insp-swatch",style:{background:p},"aria-hidden":"true"}),l("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:n(f)})]})]},c)},s=t["border-radius"]&&t["border-radius"]!=="0px",o=s?qo(t["border-radius"]).n||t["border-radius"]:null,i=t["font-size"]||t["font-weight"]?[t["font-size"],t["font-weight"]].filter(Boolean).join(" / "):null;if(!(t["background-color"]||t.color||s||i))return null;return y(te,{children:[s?y("div",{className:"st-insp-row",children:[l("span",{className:"st-insp-label",children:"Radius"}),y("div",{className:"st-insp-fields",children:[y("span",{className:"st-fmini",style:{flex:"0 0 auto",maxWidth:84},children:[l("span",{className:"st-mtag",children:"r"}),l("input",{value:o,readOnly:!0,"aria-label":"border radius"})]}),l("span",{className:"st-insp-unit",children:"px"})]})]}):null,r("Fill","background-color"),r("Text","color"),i?y("div",{className:"st-insp-row",children:[l("span",{className:"st-insp-label",children:"Font"}),l("div",{className:"st-insp-fields",children:l("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:i})})]}):null]})}function C2(e){if(e.artboardId)return e.artboardId;let t=/^\[data-dc-screen="([^"]+)"\]$/.exec(e.selector||"");return t?t[1]:null}var qbe=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],Vbe=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function vE({el:e,cfg:t,onResizeArtboard:a,onSetArtboardHug:n,onSetArtboardStyle:r,onSetArtboardKind:s,onSetArtboardPrint:o,onDuplicateArtboard:i}){let u=C2(e),c=(t?.designRel||t?.designRoot||".design").replace(/^\/+|\/+$/g,""),f=Qv(e.file,t),p=Xv(t,c,f),m=(M)=>p.map((F)=>({ds:F.name,names:F[M]||[],vals:F.vals})).filter((F)=>F.names.length),h=(M)=>m(M).flatMap((F)=>(F.names||[]).map((X)=>({name:X,value:F.vals?.[X]||""}))),b=(M)=>{let F=/^var\(\s*(--[\w-]+)\s*\)$/.exec(M||"");if(!F)return M||"";for(let X of p){let K=X.vals?.[F[1]];if(K)return K}return""},w=Number.isFinite(e.worldW)?e.worldW:Number.isFinite(e.bounds?.w)?e.bounds.w:null,S=Number.isFinite(e.worldH)?e.worldH:Number.isFinite(e.bounds?.h)?e.bounds.h:null,_=(M,F)=>{if(!u)return;let X=Number.isFinite(M)&&M>0?Math.round(M):void 0,K=Number.isFinite(F)&&F>0?Math.round(F):void 0;if(X==null&&K==null)return;a?.(u,X,K)},v=Object.entries(Os).find(([,M])=>M.width===w&&M.height===S)?.[0],k=Object.entries(Os).find(([,M])=>M.width===w)?.[0],I=e.attrs?.["data-dc-fixed"]==="true",A=e.attrs?.["data-dc-bg"]??"",N=e.attrs?.["data-dc-padding"]??"",E=e.attrs?.["data-dc-layout"]??"",R=e.attrs?.["data-dc-gap"]??"",O=e.attrs?.["data-dc-kind"]||"digital",H=null;try{H=e.attrs?.["data-dc-print"]?JSON.parse(e.attrs["data-dc-print"]):null}catch{}let V=(M)=>{if(!u)return;let F=null;if(M==="print"&&!H){let X={paper:"a4"};try{let K=oh(X);if(K)F={defaults:X,widthPx:K.widthPx,heightPx:K.heightPx}}catch{}}if(s?.(u,M==="digital"?null:M,F),M==="web"&&I)n?.(u,!1,void 0)},q=(M)=>{if(!u)return;let F={paper:"a4",...H,...M},X;try{X=oh(F)}catch{return}a?.(u,X.widthPx,X.heightPx),o?.(u,F)},D=(M,F)=>{if(!u)return;let X=Number.isFinite(F)?F:S,K=M&&Number.isFinite(X)?Math.round(X):void 0;n?.(u,M,K)},U=(M)=>{let F=MI(I,M);if(F.kind==="resize")_(null,F.height);else if(F.kind==="promote-to-fixed")D(!0,F.height)},z=(M)=>{if(!u)return;r?.(u,M)};return y("section",{className:"st-cp-sec",children:[l("div",{className:"st-cp-sechd-row",children:l("span",{className:"st-cp-sechd",children:"Artboard"})}),y("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[l(Sr,{value:w??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(M)=>_(M,null)}),l(Sr,{value:S??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:I,onCommit:U})]}),l("div",{style:{padding:"0 12px 8px"},children:O==="print"?y("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:H?.paper??"",onChange:(M)=>q({paper:M.currentTarget.value}),children:[l("option",{value:"",disabled:!0,children:"Paper size…"}),sh.map((M)=>y("option",{value:M.id,children:[M.label," — ",M.width,"×",M.height,M.unit]},M.id))]}):O==="web"?y("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:k??"",onChange:(M)=>{let F=Os[M.currentTarget.value];if(F)_(F.width,null)},children:[l("option",{value:"",disabled:!0,children:k?`${Os[k].label} — ≤ ${Os[k].width}px`:"Breakpoint…"}),Object.entries(Os).map(([M,F])=>y("option",{value:M,children:[F.label," — ≤ ",F.width,"px breakpoint"]},M))]}):y("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:v??"",onChange:(M)=>{let F=Os[M.currentTarget.value];if(F)_(F.width,F.height)},children:[l("option",{value:"",disabled:!0,children:v?Os[v].label:"Preset size…"}),Object.entries(Os).map(([M,F])=>y("option",{value:M,children:[F.label," — ",F.width,"×",F.height]},M))]})}),l("div",{style:{padding:"0 12px 8px"},children:l(zh,{value:I?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(M)=>D(M==="fixed")})}),l("div",{className:"st-cp-sechd-row",children:l("span",{className:"st-cp-sechd",children:"Kind"})}),l("div",{style:{padding:"0 12px 8px"},children:l(Vl,{value:O,ariaLabel:"artboard kind",options:Vbe.map(([M,F])=>({value:M,label:F})),onChange:V})}),O!=="print"&&u&&i?l("div",{style:{padding:"0 12px 8px"},children:y("select",{className:"st-cp-nsel","aria-label":"duplicate artboard at breakpoint width",value:"",onChange:(M)=>{let F=Os[M.currentTarget.value];if(F)i(u,F.width);M.currentTarget.value=""},children:[l("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(Os).map(([M,F])=>y("option",{value:M,children:[F.label," — ",F.width,"px"]},M))]})}):null,O==="print"?y(te,{children:[l("div",{className:"st-cp-sechd-row",children:l("span",{className:"st-cp-sechd",children:"Print"})}),l("div",{style:{padding:"0 12px 8px"},children:l(zh,{value:H?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(M)=>q({orientation:M})})}),l("div",{style:{padding:"0 12px 8px"},children:l(Sr,{value:Number.isFinite(H?.bleedMm)?H.bleedMm:3,min:0,step:0.5,ariaLabel:"bleed, millimeters",lead:"B",steppers:!1,unitSlot:l("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"mm"}),onCommit:(M)=>q({bleedMm:M})})})]}):null,l("div",{className:"st-cp-sechd-row",children:l("span",{className:"st-cp-sechd",children:"Style"})}),y("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let M=b(A),F=/var\(\s*--/.test(A),X=F?A.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):A;return l(xp,{swatch:l(Ap,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:m("color"),current:A,activeDs:f,swatchBg:M,seedHex:Ad(M)||"#000000",onPick:(K)=>z({background:K||null}),label:"artboard background colour"}),displayValue:X,bound:F,ariaLabel:"artboard background",onValue:(K)=>z({background:(K||"").trim()||null})})})(),l(Vl,{value:E,ariaLabel:"artboard body layout",options:qbe.map(([M,F])=>({value:M,label:F})),onChange:(M)=>z({layout:M||null})}),y("div",{style:{display:"flex",gap:8},children:[l(Bh,{value:/^var\(/.test(N)?N:Number.parseFloat(N)||0,tokens:h("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(M)=>z({padding:typeof M==="string"?M:M>0?M:null})}),l(Bh,{value:/^var\(/.test(R)?R:Number.parseFloat(R)||0,tokens:h("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(M)=>z({gap:typeof M==="string"?M:M>0?M:null})})]})]})]})}var Yv=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,Gbe=new RegExp(Yv.source,"gi");function Wbe(e){if(!e||Array.isArray(e))return null;if(e.photoAsset)return e.photoAsset;let t=e.html||"";if((e.tag||"").toLowerCase()!=="img"){let r=[...new Set(t.match(Gbe)||[])],s=[...new Set([...t.matchAll(/data-photo-asset="([^"]+)"/g)].map((o)=>o[1]))];if(s.length===1)return s[0];if(s.length===0&&r.length===1&&/<img/i.test(t))return r[0];return null}let a=/data-photo-asset="([^"]+)"/.exec(t);if(a)return a[1];let n=Yv.exec(`${e.attrs?.src||""} ${t}`);return n?n[0]:null}function wE({testId:e,selected:t,onClose:a,layersTree:n,componentMap:r,lockedKeys:s,onToggleLock:o,onDetachInstance:i,canvasFile:u,onSelectLayer:c,onHoverLayer:f,onReorderLayer:p,layersBusyRef:m,cfg:h,onOptimistic:b,onRecordEdit:w,onReplaceMedia:S,onResizeArtboard:_,onSetArtboardHug:v,onSetArtboardStyle:k,onSetArtboardKind:I,onSetArtboardPrint:A,onDuplicateArtboard:N,onUndoRedo:E,editScope:R,tab:O,onTabChange:H,width:V,resizing:q,photoSel:D,photoRev:U,onPhotoEdit:z,onPhotoRemoveBackground:M,onPhotoRecordEdit:F,onPhotoUndoRedo:X,layersOnly:K=!1,hideLayersTab:ie=!1,cpMode:G,onSetCpMode:se}){let[Z,pe]=P("inspect"),oe=K?"layers":O??Z,ye=(be)=>{pe(be),H?.(be)},[Je,Ke]=P(()=>new Set),[ot,yt]=P(()=>new Map);ee(()=>{let be=Array.isArray(t)?t[0]:t,Te=be?.id;if(!Te||!n?.nodes)return;let tt=be.index,we=null,Ue=[];if(function lt(le,We){for(let xt of le||[]){let Wt=`${xt.id}:${xt.index}`;if(!xt.synthetic&&xt.id===Te&&(tt==null||xt.index===tt))return we=Wt,Ue.push(...We),!0;if(xt.children&&xt.children.length&&lt(xt.children,[...We,Wt]))return!0}return!1}(n.nodes,[]),!we)return;if(Ue.length)Ke((lt)=>{let le=!1,We=new Set(lt);for(let xt of Ue)if(We.delete(xt))le=!0;return le?We:lt});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${we}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[t,n]);let rt=(be)=>{let Te=`${be.id}:${be.index}`;return ot.has(Te)?ot.get(Te):!!be.hidden},[nt,bt]=P(null),[kt,Se]=P(""),qe=(be,Te)=>{if(!u||!be?.id)return;_2(fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:u,id:be.id,attr:"data-dc-element",value:Te})}).then((tt)=>tt.json().catch(()=>({}))).then((tt)=>{if(!tt.ok)return;w?.({op:"attr",canvas:u,id:be.id,key:"data-dc-element",before:be.dcElement??null,after:Te})}).catch(()=>{}))},_e=p?(be,Te,tt)=>{if(m?.current)return;if(be?.synthetic||Te?.synthetic)return;let we=tt==="before"?`before ${Te.label}`:tt==="after"?`after ${Te.label}`:`into ${Te.label}`;Se(`Moved ${be.label} ${we}`),p(be.id,Te.id,tt,{idIndex:be.index,refIndex:Te.index})}:void 0,Ye=()=>{let be=[];return function Te(tt,we,Ue){(tt||[]).forEach((lt,le)=>{if(be.push({node:lt,depth:we,parentNode:Ue,siblings:tt,pos:le}),lt.children&&lt.children.length&&!Je.has(`${lt.id}:${lt.index}`))Te(lt.children,we+1,lt)})}(n?.nodes,0,null),be},He=(be)=>{if(be.key!=="ArrowUp"&&be.key!=="ArrowDown")return;if(!Be)return;let Te=Ye(),tt=Te.findIndex((le)=>le.node.id===Be.id&&le.node.index===Be.index);if(tt<0)return;let we=be.key==="ArrowDown"?1:-1,Ue=Te[tt];if(!be.altKey){let le=Te[tt+we];if(le)be.preventDefault(),c?.(le.node);return}if(!_e||!Array.isArray(Ue.siblings))return;be.preventDefault();let lt=(le)=>le&&le.children&&le.children.length&&!Je.has(`${le.id}:${le.index}`);if(!be.shiftKey){if(we<0&&Ue.pos>0)_e(Ue.node,Ue.siblings[Ue.pos-1],"before");else if(we>0&&Ue.pos<Ue.siblings.length-1)_e(Ue.node,Ue.siblings[Ue.pos+1],"after");return}if(we>0){let le=Ue.siblings[Ue.pos+1];if(le)_e(Ue.node,le,lt(le)?"inside-start":"after");else if(Ue.parentNode)_e(Ue.node,Ue.parentNode,"after")}else{let le=Ue.siblings[Ue.pos-1];if(le)_e(Ue.node,le,lt(le)?"inside-end":"before");else if(Ue.parentNode)_e(Ue.node,Ue.parentNode,"before")}},ht=me(null),Xt=me(null),Ne=(be,Te,tt)=>{if(!_e||be.button!==0||be.metaKey||be.ctrlKey||be.shiftKey||be.altKey)return;if(m?.current)return;let{clientX:we,clientY:Ue}=be,lt=new Set([tt]);(function Vt(ke){(ke.children||[]).forEach((dt)=>{lt.add(`${dt.id}:${dt.index}`),Vt(dt)})})(Te);let le=14,We=6,xt=[];(function Vt(ke,dt){(ke||[]).forEach((Bt)=>{let oa=`${Bt.id}:${Bt.index}`;if(xt.push({node:Bt,key:oa,id:Bt.id,depth:dt,tag:Bt.tag}),Bt.children&&Bt.children.length&&!Je.has(oa))Vt(Bt.children,dt+1)})})(n?.nodes,0);let Wt=new Map(xt.map((Vt)=>[Vt.key,Vt])),pa=!1,Qa=(Vt)=>{if(!pa){if(Math.hypot(Vt.clientX-we,Vt.clientY-Ue)<4)return;pa=!0}let ke=Vt.clientX-we,dt=Vt.clientY-Ue,Bt=null,oa=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((Va)=>({rect:Va.getBoundingClientRect(),it:Wt.get(Va.getAttribute("data-layer-key"))})).filter((Va)=>Va.it&&Va.it.key!==tt);if(oa.length){let Va=oa[0].rect.left,Ve=oa[0].rect.right,B=oa.length;for(let Ta=0;Ta<oa.length;Ta++)if(Vt.clientY<oa[Ta].rect.top+oa[Ta].rect.height/2){B=Ta;break}let ae=oa[B-1]?.it||null,de=oa[B]?.it||null,Ce=Math.round((Vt.clientX-Va-We)/le),Pe=ae?ae.depth+(yE.has(ae.tag)?0:1):0,ct=de?de.depth:0,ft=Math.max(ct,Math.min(Ce,Pe)),Ot=null,Mt="before",da=0;if(!ae){if(de)Ot=de,Mt="before",da=de.depth}else if(ft>ae.depth)Ot=ae,Mt="inside-start",da=ae.depth+1;else if(ft===ae.depth)Ot=ae,Mt="after",da=ae.depth;else{for(let Ta=B-1;Ta>=0;Ta--)if(oa[Ta].it.depth===ft){Ot=oa[Ta].it;break}if(!Ot)Ot=ae;Mt="after",da=ft}if(Ot&&Ot.key!==tt&&!lt.has(Ot.key)){let Ta=ae?oa[B-1].rect.bottom:oa[0].rect.top,Ma=Va+We+da*le;Bt={refId:Ot.id,position:Mt,node:Ot.node,y:Ta,left:Ma,w:Math.max(24,Ve-Ma)}}}let Pa={key:tt,node:Te,dx:ke,dy:dt,target:Bt};ht.current=Pa,bt(Pa)},Pt=()=>{window.removeEventListener("pointermove",Qa),window.removeEventListener("pointerup",Dt),window.removeEventListener("keydown",Yt,!0)},pn=()=>{let Vt=(ke)=>{ke.preventDefault(),ke.stopImmediatePropagation(),document.removeEventListener("click",Vt,!0)};document.addEventListener("click",Vt,!0),setTimeout(()=>document.removeEventListener("click",Vt,!0),300)},Dt=()=>{Pt();let Vt=ht.current;if(ht.current=null,bt(null),pa&&Vt?.target)pn(),_e(Vt.node,Vt.target.node,Vt.target.position)},Yt=(Vt)=>{if(Vt.key!=="Escape")return;if(Vt.preventDefault(),Vt.stopImmediatePropagation(),Pt(),ht.current=null,bt(null),pa)pn()};window.addEventListener("pointermove",Qa),window.addEventListener("pointerup",Dt),window.addEventListener("keydown",Yt,!0)},At=(be)=>Ke((Te)=>{let tt=new Set(Te);if(tt.has(be))tt.delete(be);else tt.add(be);return tt}),ua=(be)=>{let Te=`${be.id}:${be.index}`,tt=rt(be),we=!tt;if(yt((Ue)=>new Map(Ue).set(Te,we)),b?.({id:be.id,artboardId:n?.artboardId??null,index:be.index,prop:"display",value:we?"none":null}),!u||!be.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(we?{canvas:u,id:be.id,property:"display",value:"none"}:{canvas:u,id:be.id,property:"display",reset:!0})}).catch(()=>{}),w?.({op:"css",canvas:u,id:be.id,key:"display",before:tt?"none":null,after:we?"none":null})},Be=Array.isArray(t)?t[0]:t,fe=D?{asset:D.asset,kind:"annotation-image"}:(()=>{let be=Wbe(Be);return be?{asset:be,kind:"artboard-img"}:null})(),Ze=fe?.kind==="annotation-image",he=(be)=>{if(!(be.metaKey||be.ctrlKey)||be.altKey)return;let Te=be.key.toLowerCase();if(Te==="z")be.preventDefault(),X?.(be.shiftKey?"redo":"undo");else if(Te==="y")be.preventDefault(),X?.("redo")},Le=Ze?"photo":oe==="photo"&&!fe?"css":oe,Ie=(be,Te,tt)=>y("button",{type:"button",className:"st-rp-tab"+(Le===be?" is-active":""),onClick:()=>ye(be),children:[l(ga,{name:tt,size:14}),Te]}),ue=Be?.bounds||null;return y("aside",{className:"st-rpanel"+(q?" is-resizing":""),style:V?{width:V,flexBasis:V}:void 0,"aria-label":"Inspector","data-tour":"inspector","data-testid":e,children:[y("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:K?{display:"none"}:void 0,children:[Ze?Ie("photo","Photo","image"):y(te,{children:[Ie("inspect","Inspect","sliders"),!ie&&Ie("layers","Layers","layers"),Ie("css","CSS","code"),fe?Ie("photo","Photo","image"):null]}),l("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:a,children:l(ga,{name:"x",size:14})})]}),Be?.id&&!(Array.isArray(t)&&t.length>1)&&R?y("div",{className:`st-scope st-scope--${R.scope}`,title:R.scope==="shared"?`Editing this element's style changes ${R.affects} place${R.affects===1?"":"s"}${R.componentName?` (component ${R.componentName})`:""}. Move/resize a whole instance to keep it local.`:"This edit affects only this element.",children:[l("span",{className:"st-scope-dot","aria-hidden":"true"}),R.scope==="shared"?`Shared${R.componentName?` · ${R.componentName}`:""} · edits ${R.affects} place${R.affects===1?"":"s"}`:"Local · this element only",R.scope==="shared"&&i?l("button",{type:"button",className:"st-scope-detach",title:"Clone this component for this instance only — edits stop affecting the other places",onClick:()=>i(Be.id,Be.index),children:"Detach"}):null]}):null,l("div",{className:"st-rp-body",children:Le==="photo"&&fe?l("div",{onKeyDown:he,children:l(TA,{asset:fe.asset,ColorPicker:Zv,StIcon:ga,onEdit:(be)=>z?.(fe.asset,be),onRemoveBackground:M,onRecordEdit:(be,Te)=>F?.(fe.asset,be,Te)},`${fe.asset}:${U??0}`)}):!Be&&!(Le==="layers"&&n?.nodes?.length)?l("div",{className:"st-rp-empty",children:y("p",{children:["Press ",l(Gn,{children:"V"}),", then click an element to select it — or ",l(Gn,{children:"⌘"}),"-click straight from Browse."]})}):Be&&Le==="inspect"?y(te,{children:[l("div",{className:"st-rp-hd",children:Be.selector||Be.tag||"element"}),y("div",{className:"st-insp-row",children:[l("span",{className:"st-insp-label",children:"Pos"}),y("div",{className:"st-insp-fields",children:[y("span",{className:"st-fmini",children:[l("span",{className:"st-mtag",children:"X"}),l("input",{value:ue?Math.round(ue.x):"—",readOnly:!0,"aria-label":"x position"})]}),y("span",{className:"st-fmini",children:[l("span",{className:"st-mtag",children:"Y"}),l("input",{value:ue?Math.round(ue.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),y("div",{className:"st-insp-row",children:[l("span",{className:"st-insp-label",children:"Size"}),y("div",{className:"st-insp-fields",children:[y("span",{className:"st-fmini",children:[l("span",{className:"st-mtag",children:"W"}),l("input",{value:ue?Math.round(ue.w):"—",readOnly:!0,"aria-label":"width"})]}),y("span",{className:"st-fmini",children:[l("span",{className:"st-mtag",children:"H"}),l("input",{value:ue?Math.round(ue.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),y("div",{className:"st-insp-row",children:[l("span",{className:"st-insp-label",children:"Tag"}),l("div",{className:"st-insp-fields",children:l("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:Be.tag||"—"})})]}),Be.classes?y("div",{className:"st-insp-row",children:[l("span",{className:"st-insp-label",children:"Class"}),l("div",{className:"st-insp-fields",children:l("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Be.classes})})]}):null,l(bE,{el:Be})]}):Le==="layers"?y(te,{children:[y("div",{className:"st-rp-hd",children:["Layers",n?.nodes?.length?"":" · ancestry"]}),n?.nodes?.length?y(te,{children:[_e?l("div",{className:"st-rp-hint","aria-hidden":"true",children:"Drag or ↑/↓ select · Alt+↑/↓ move · Alt+Shift+↑/↓ move across"}):null,l("div",{role:"tree","aria-label":"Artboard layers",tabIndex:0,ref:Xt,onKeyDown:He,children:n.nodes.map((be,Te)=>l(S2,{node:be,depth:0,selectedId:Be?.id,selectedIndex:Be?.index,collapsed:Je,hiddenOverride:ot,onToggle:At,onSelect:(tt)=>{c?.(tt),Xt.current?.focus()},onHover:(tt)=>f?.(tt),onToggleVisibility:ua,onReorder:_e,onRowPointerDown:Ne,dragState:nt,componentMap:r,lockedKeys:s,onToggleLock:o,onRename:qe},`${be.id}:${be.index}`))}),nt?.target?l("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:nt.target.left,top:nt.target.y-1,width:nt.target.w}}):null,l("div",{className:"sr-only",role:"status","aria-live":"polite",children:kt})]}):Be&&Array.isArray(Be.dom_path)&&Be.dom_path.length?Be.dom_path.map((be,Te)=>y("div",{className:"st-layer"+(Te===Be.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+Te*12},children:[l(ga,{name:"square",size:13}),be]},Te)):l("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!Be.id&&C2(Be)?l(vE,{el:Be,cfg:h,onResizeArtboard:_,onSetArtboardHug:v,onSetArtboardStyle:k,onSetArtboardKind:I,onSetArtboardPrint:A,onDuplicateArtboard:N}):l(hE,{el:Be,cfg:h,onOptimistic:b,onRecordEdit:w,onReplaceMedia:S,onUndoRedo:E,mode:G,onSetMode:se})})]})}function Uj({groups:e,treeLoaded:t,treeLoadFailures:a,project:n,activePath:r,previewPath:s,onPreview:o,selected:i,editScope:u,layersBusyRef:c,layersTree:f,componentMap:p,wsConnected:m,syncStatus:h,cloudLinkedHub:b,setCloudLinkedHub:w,localProjectName:S,setLocalProjectName:_,gitStatus:v,remoteSync:k,changesOpen:I,setChangesOpen:A,syncPanelOpen:N,setSyncPanelOpen:E,setDiffTarget:R,search:O,setSearch:H,systemData:V,dragSide:q,cfg:D,cellManaged:U,cloudManaged:z,savingIsManaged:M,viewerMode:F,commentsByFile:X,focusedCommentId:K,commentsPanelOpen:ie,commentsFilter:G,setCommentsFilter:se,cpMode:Z,setCpMode:pe,sidebarOpen:oe,showHidden:ye,treeExp:Je,sectionsExpanded:Ke,setHelpOpen:ot,setReportBugOpen:yt,setShortcutsOpen:rt,setExportDialog:nt,setSettingsOpen:bt,setGenerateOpen:kt,inspectorOpen:Se,setInspectorOpen:qe,layersOpen:_e,setLayersOpen:Ye,panelSide:He,layersMode:ht,assistantOpen:Xt,inspectorTab:Ne,setInspectorTab:At,photoSel:ua,photoRev:Be,openPanelExclusive:fe,togglePanel:Ze,openRightPanel:he,toggleRightPanel:Le,whatsNew:Ie,postToActiveCanvas:ue,onPhotoEdit:be,onPhotoRecordEdit:Te,performPhotoUndo:tt,onPhotoRemoveBackground:we,lockedKeys:Ue,toggleLockedKey:lt,toggleSection:le,treeExpansion:We,toggleTheme:xt,gitCommit:Wt,gitDiscard:pa,gitPublish:Qa,gitGetLatest:Pt,gitLoadLog:pn,cloudHistory:Dt,gitLoadCloudLog:Yt,projectHistoryOn:Vt,setProjectHistoryOn:ke,projectHistoryRefresh:dt,loadAcceptedLog:Bt,restoreProjectVersion:oa,dirtyByPath:Pa,openTab:Va,openLinkedFile:Ve,sharePath:B,shareShell:ae,shareLinksFor:de,showShare:Ce,openSystem:Pe,reloadActive:ct,treeRefreshing:ft,refreshTree:Ot,createBoard:Mt,createVideo:da,deleteBoard:Ta,moveCanvasReq:Ma,newFolderReq:Or,deleteFolderReq:Qr,renameFolderReq:De,renameCanvasReq:Ge,duplicateCanvasReq:Nt,deleteFileReq:Ut,applyOptimisticStyle:ka,recordSourceEdit:it,reorderLayer:$a,detachInstanceShell:Q,resizeArtboardShell:Ee,duplicateArtboardShell:et,setArtboardHugShell:Rt,setArtboardStyleShell:Zt,setArtboardKindShell:Ht,setArtboardPrintShell:jn,onReplaceMedia:Mn,resolveComment:va,reopenComment:xn,deleteComment:ja,jumpToComment:cn}){let Nn=Kt(()=>[{id:"new",group:"Canvas",label:"New canvas…",icon:"plus",kbd:"N",run:()=>{fe("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60)}},{id:"new-video",group:"Canvas",label:"New video…",icon:"plus",run:()=>da()},{id:"export",group:"Canvas",label:"Export…",icon:"download",kbd:"⇧⌘E",run:()=>nt({mode:"export"})},{id:"share-link",group:"Canvas",label:"Copy share link",icon:"link",run:()=>{let W=de(B),J=W.web??W.app??W.local;if(J)Rh(J)}},{id:"handoff",group:"Canvas",label:"Handoff to production",icon:"external",kbd:"⇧⌘H",run:()=>nt({mode:"handoff"})},{id:"generate",group:"Canvas",label:"Generate with AI…",icon:"sparkle",run:()=>kt(!0)},{id:"settings",group:"Canvas",label:"Settings…",icon:"sliders",kbd:"⌘,",run:()=>bt(!0)},{id:"system",group:"View",label:"Open design system view",icon:"sliders",kbd:"S",run:()=>Pe()},{id:"comments",group:"View",label:"Toggle comments panel",icon:"resolve",kbd:"⌘⇧M",run:()=>Le("comments")},{id:"inspector",group:"View",label:"Open inspector",icon:"sliders",kbd:"⌘⇧I",run:()=>he("inspector")},{id:"reload",group:"View",label:"Reload active canvas",icon:"reload",kbd:"⌘R",run:()=>ct()},{id:"draw",group:"Tools",label:"Draw a mark with the SVG agent",icon:"pen",run:()=>{try{navigator.clipboard?.writeText("/design:draw ")}catch{}}},{id:"theme",group:"Tools",label:"Toggle light / dark theme",icon:"sun",run:()=>xt()},{id:"whatsnew",group:"Help",label:"What's new in maude",icon:"sparkle",run:()=>Ie.openPanel()},{id:"shortcuts",group:"Help",label:"Keyboard shortcuts",icon:"help",kbd:"?",run:()=>rt(!0)},{id:"help",group:"Help",label:"Help · commands & flows",icon:"help",kbd:"F1",run:()=>ot(!0)},{id:"report-bug",group:"Help",label:"Report a bug…",icon:"help",run:()=>yt(!0)}],[Pe,xt,ct,Ie,da,B,ae,b,S,D.designRel]),Dr=(W)=>{if(F&&W==="assistant")return!1;if(W==="sync")return!!h;return W==="assistant"?na():W==="layers"?ht==="separate":!0},Xr=(W)=>Kh.filter((J)=>Dr(J.id)&&(He[J.id]||Wl[J.id])===W).map((J)=>J.id),Bs={tree:oe,layers:_e,inspector:Se,comments:ie,changes:I,sync:N,assistant:Xt},ps=D.cloud?{changes:"History"}:null,mo=Xr("left"),Zo=Xr("right"),Yo=mo.find((W)=>Bs[W])||null,Pr=Zo.find((W)=>Bs[W])||null,Us=na()&&!F&&(He.assistant||"right")==="left",ms=na()&&!F&&(He.assistant||"right")==="right",Cr=(W)=>(He[W]||Wl[W])==="left"?q==="sb":q==="rp",hs=r&&r!==Ft&&/\.(tsx|html)$/i.test(r)?r:null,Cs=hs?kp(X[hs]):0;return{activeCanvasFile:hs,activeOpenComments:Cs,dockLabels:ps,leftActive:Yo,leftHostsAssistant:Us,leftIds:mo,paletteActions:Nn,renderPanelBody:(W)=>{if(W==="tree")return l(sE,{cloud:D.cloud,readOnly:F,groups:Je.ready?e:WA,activePath:r,previewPath:s,activeDsName:r===Ft?V?.ds?.name??null:null,onOpen:Va,onPreview:o,onOpenLinkedFile:Ve,filesReady:t,treeLoadFailures:a,onShare:Ce,onOpenSystem:Pe,wsConnected:m,search:O,setSearch:H,commentsByFile:X,showHidden:ye,sectionsExpanded:Ke,onToggleSection:le,treeExpansion:We,onNewBoard:Mt,onDeleteBoard:Ta,onMoveCanvas:Ma,onNewFolder:Or,onDeleteFolder:Qr,onRenameFolder:De,onRenameCanvas:Ge,onDuplicateCanvas:Nt,onDeleteFile:Ut,onRefresh:Ot,refreshing:ft,collapsed:!1,onCollapse:()=>Ze("tree"),resizing:Cr("tree"),dirtyByPath:Pa,project:n,gitBranch:v?.branch,remoteSync:k,onGetLatest:Pt,canvasKinds:D?.canvasKinds,syncStatus:h,onLinkedHub:w,onLocalProject:_,savingIsManaged:M});if(W==="changes")return l(S_,{status:v&&k?{...v,...k}:v,project:n,readOnly:!na()||F,historyOnly:U,cloudManaged:z,resizing:Cr("changes"),onClose:()=>A(!1),onCommit:Wt,onDiscard:pa,onPublish:Qa,onGetLatest:Pt,loadLog:async(J)=>{let xe=await Bt(J);if(ke(xe!=="legacy"),xe!=="legacy")return xe;return(z?Yt:pn)(J)},historySource:Vt?"project":z?"cloud":"local",historyRefresh:`${h?.appliedRevision??0}:${dt}`,onRestoreVersion:(J)=>oa(r,J).then((xe)=>!!xe.ok),onUndoAction:U?void 0:async(J)=>{let xe=await fetch("/_api/project/undo",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionId:J})}).catch(()=>null);return!!(xe?await xe.json().catch(()=>null):null)?.ok},cloudHistory:Dt,onOpenCanvas:(J)=>Va(J),onOpenDiff:(J)=>R({file:J,beforeSha:"HEAD",conflict:!1}),activeCanvas:hs,onPreviewVersion:(J)=>R({file:r,beforeSha:J,conflict:!1}),designRel:(D?.designRel||D?.designRoot||".design").replace(/^\/+|\/+$/g,"")});if(W==="sync")return l(M_,{status:h,project:D?.cloud?.projectName||n,cloud:D?.cloud??null,groupPaths:(e||[]).map((J)=>J.path).filter(Boolean),resizing:Cr("sync"),onClose:()=>E(!1)});if(W==="inspector"||W==="layers")return l(wE,{testId:W==="layers"?"layers-panel":"inspector-panel",layersOnly:W==="layers",hideLayersTab:ht==="separate",cpMode:Z,onSetCpMode:pe,selected:i,cfg:D,tab:W==="layers"?"layers":Ne,onTabChange:At,onClose:()=>W==="layers"?Ye(!1):qe(!1),onOptimistic:ka,onRecordEdit:it,onReplaceMedia:Mn,onResizeArtboard:Ee,onSetArtboardHug:Rt,onSetArtboardStyle:Zt,onSetArtboardKind:Ht,onSetArtboardPrint:jn,onDuplicateArtboard:et,editScope:u,onUndoRedo:(J)=>ue({dgn:J}),photoSel:ua,photoRev:Be,onPhotoEdit:be,onPhotoRemoveBackground:we,onPhotoRecordEdit:Te,onPhotoUndoRedo:(J)=>tt(J==="redo"),layersTree:f,componentMap:p,lockedKeys:Ue,onToggleLock:lt,onDetachInstance:Q,canvasFile:r,onSelectLayer:(J)=>ue({dgn:"select-by-id",id:J.id,artboardId:f?.artboardId,index:J.index}),onHoverLayer:(J)=>ue({dgn:"highlight",id:J?J.id:null,artboardId:f?.artboardId,index:J?J.index:0}),onReorderLayer:$a,layersBusyRef:c,resizing:Cr(W)});if(W==="comments")return l(lE,{commentsByFile:X,filter:G,setFilter:se,activePath:r,focusedId:K,onJump:cn,onResolve:F?void 0:va,onReopen:F?void 0:xn,onDelete:F?void 0:ja,resizing:Cr("comments")});return null},resizingFor:Cr,rightActive:Pr,rightHostsAssistant:ms,rightIds:Zo}}function Fj({activePath:e,selected:t,viewerMode:a,commentsByFile:n,focusedCommentId:r,setFocusedCommentId:s,sidebarOpen:o,setShowHidden:i,setHelpOpen:u,setShortcutsOpen:c,setPaletteOpen:f,setExportDialog:p,setSettingsOpen:m,inspectorTab:h,openPanelExclusive:b,togglePanel:w,toggleRightPanel:S,toggleTimeline:_,presentMode:v,iframesRef:k,postToActiveCanvas:I,performPhotoUndo:A,tlKeyRef:N,exitPresent:E,openSystem:R,closeTab:O,reloadActive:H,refreshTree:V,clearActiveCanvasSelection:q}){ee(()=>{function M(F){let X=F.metaKey||F.ctrlKey,K=["INPUT","TEXTAREA"].includes(document.activeElement?.tagName)||document.activeElement?.isContentEditable,ie=document.activeElement?.tagName==="IFRAME";if(v&&F.key==="Escape"){F.preventDefault(),E();return}if(X&&(F.key==="k"||F.key==="K")){F.preventDefault(),f((G)=>!G);return}if(X&&!F.altKey&&(F.key==="z"||F.key==="Z"||F.key==="y"||F.key==="Y")){if(!K&&!ie&&e&&e!==Ft){if((F.key==="z"||F.key==="Z")&&N.current.open&&N.current.comps?.length)return;let G=F.key==="y"||F.key==="Y"||F.shiftKey;if(h==="photo"&&A(G)){F.preventDefault();return}F.preventDefault(),I({dgn:G?"redo":"undo"});return}}if(X&&F.shiftKey&&(F.key==="r"||F.key==="R")){F.preventDefault(),V();return}if(X&&(F.key==="r"||F.key==="R")){F.preventDefault(),H();return}if(X&&F.shiftKey&&(F.key==="m"||F.key==="M")){F.preventDefault(),S("comments");return}if(X&&F.shiftKey&&(F.key==="g"||F.key==="G")){F.preventDefault(),S("changes");return}if(X&&F.shiftKey&&(F.key==="i"||F.key==="I")){F.preventDefault(),S("inspector");return}if(X&&F.shiftKey&&(F.key==="a"||F.key==="A")&&na()){if(F.preventDefault(),!a)S("assistant");return}if(X&&F.shiftKey&&(F.key==="e"||F.key==="E")){F.preventDefault(),p({mode:"export"});return}if(X&&F.shiftKey&&(F.key==="h"||F.key==="H")){F.preventDefault(),p({mode:"handoff"});return}if(X&&!F.shiftKey&&!F.altKey&&F.key===","){if(F.preventDefault(),!a)m(!0);return}if(X&&F.shiftKey&&(F.key==="t"||F.key==="T")){F.preventDefault(),_();return}if(X&&!F.shiftKey&&!F.altKey&&(F.key==="c"||F.key==="C")){if(t&&t.selector&&e&&e!==Ft&&!K&&console&&console.warn)console.warn("Cmd+C comment-drop deprecated — press C inside the canvas to enter Comment tool, then click the element.")}if(K)return;if(F.key==="/"){F.preventDefault();let G=document.querySelector(".st-search input");if(G)G.focus();return}if(X&&(F.key==="f"||F.key==="F")){if(F.preventDefault(),!o)b("tree");setTimeout(()=>{let G=document.querySelector(".st-search input");if(G)G.focus()},0);return}if(ie){if(F.key!=="Escape")return}if(F.key==="t"||F.key==="T"){if(F.shiftKey||X)return;F.preventDefault(),w("tree");return}if(F.key==="h"||F.key==="H"){if(F.shiftKey||X)return;F.preventDefault(),i((G)=>!G);return}if((F.key==="s"||F.key==="S")&&!X&&!F.shiftKey){if(F.preventDefault(),e===Ft)O(Ft);else R();return}if((F.key==="n"||F.key==="N")&&!X&&!F.shiftKey){F.preventDefault(),b("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60);return}if(F.key==="?"){F.preventDefault(),c((G)=>!G);return}if(F.key==="F1"){F.preventDefault(),u(!0);return}if(F.key==="Escape"){if(r){s(null);return}}}return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[H,V,t,e,r,o,R,O,q,v,E,_,h,A,a]);let D=ce((M,F)=>{if(F)k.current.set(M,F)},[]),U=Gv(n).open;return{onShellContextMenu:ce((M)=>{let F=M.target;if(F&&(F.tagName==="INPUT"||F.tagName==="TEXTAREA"||F.isContentEditable))return;M.preventDefault()},[]),registerIframe:D,totalOpen:U}}var k2=(e)=>(Array.isArray(e)?e[0]:e)??null;function jj(e,t,a=Date.now()){if(!t||a-t.at>=2000)return!1;let n=k2(e);if(n==null)return k2(t.sel)==null;return n.file===t.file}function I2(e,t,a=Date.now()){return{at:a,sel:e??null,file:k2(e)?.file??t??null}}function Hj(e,t,a){let n=k2(e),r=n!=null&&n.file===t;return{activeArtboardId:(r?n.artboardId:null)??a??null,selection:r&&n.selector?{selector:n.selector,file:n.file}:null}}function qj({activePath:e,selected:t,setSelected:a,selectedRef:n,lastLocalSelectRef:r,scheduleHaloRestore:s,scheduleArtboardResync:o,pendingReorderRef:i,lastLayersTreeRef:u,settlePendingSelectionRef:c,reorderLayerRef:f,repositionElementRef:p,resizeElementRef:m,layersBusyRef:h,layersBusyTimerRef:b,layersTree:w,setLayersTree:S,setLoadingPath:_,setCanvasError:v,setLoadedPath:k,cfg:I,viewerMode:A,commentsByFile:N,focusedCommentId:E,setFocusedCommentId:R,theme:O,setPaletteOpen:H,setExportDialog:V,setTimelineOpen:q,setActiveComps:D,setTimelineFrame:U,setTimelinePlaying:z,canvasActiveArtboard:M,setCanvasActiveArtboard:F,timelineFrameRef:X,timelineCompIdRef:K,setInspectorTab:ie,setPhotoSel:G,openRightPanel:se,toggleRightPanel:Z,maybeAutoOpenInspectorOnSelect:pe,toggleTimeline:oe,minimapVisible:ye,zoomCtlVisible:Je,presentMode:Ke,setPresentMode:ot,setActiveArtboards:yt,iframesRef:rt,postToActiveCanvas:nt,captureFromCanvas:bt,broadcastChrome:kt,wsSend:Se,reloadActive:qe}){ee(()=>{let De=(it)=>!!e&&(N[e]||[]).some(($a)=>$a&&$a.id===it);function Ge(it){let $a=I?.canvasOrigin||window.location.origin;if(it.origin!==$a)return;let Q=it.data;if(!Q||typeof Q!=="object"||!Q.dgn)return;if(Q.dgn==="canvas-notice"){let Ee=e&&e!==Ft?rt.current.get(e)?.contentWindow:null,et=MA(it,$a,Ee);if(et)M3(et.title,et.kind);return}if(Q.dgn==="tool-cursor"){if(Q.tool==="browse"){document.body.style.cursor="";let et=document.getElementById("dc-app-cursor");if(et)et.textContent="";Vh(A);return}let Ee=AI(Q.tool);if(Ee){document.body.style.cursor=Ee;let et=document.getElementById("dc-app-cursor");if(!et)et=document.createElement("style"),et.id="dc-app-cursor",document.head.appendChild(et);et.textContent=`* { cursor: ${Ee} !important; }`}return}if(Q.dgn==="select"||Q.dgn==="select-set"||Q.dgn==="clear-select"||Q.dgn==="edit-text"||Q.dgn==="apply-edit"||Q.dgn==="undo-barrier"){let Ee=e&&e!==Ft?rt.current.get(e)?.contentWindow:null;if(it.source!==Ee)return}if(Q.dgn==="select"&&Q.selection)G(null),r.current=I2(Q.selection,e),Se({type:"select",selection:Q.selection}),a(Q.selection),pe(Q.selection);else if(Q.dgn==="select-set"){G(null),r.current=I2(Q.selection,e);let Ee=Q.selection;if(Ee==null)Se({type:"clear-select"}),a(null);else if(Array.isArray(Ee)){let et=Ee[0]??null;if(et)Se({type:"select",selection:et});if(a(et),Ee.length===1)pe(et)}else Se({type:"select",selection:Ee}),a(Ee),pe(Ee)}else if(Q.dgn==="clear-select")G(null),r.current=I2(null,e),Se({type:"clear-select"}),a(null);else if(Q.dgn==="edit-text"&&Q.id){let Ee=it.source,et=(Rt)=>{try{Ee?.postMessage({dgn:"edit-reverted",op:"text",id:Q.id,reason:Rt},"*")}catch{}};fetch("/_api/edit-text",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Q.file,id:Q.id,text:Q.text??"",...typeof Q.occurrence==="number"?{occurrence:Q.occurrence}:{},...typeof Q.before==="string"?{before:Q.before}:{}})}).then((Rt)=>Rt.json().catch(()=>({}))).then((Rt)=>{if(!Rt.ok)et(Rt.error||"this element can't be edited inline")}).catch(()=>et("network error"))}else if(Q.dgn==="undo-barrier"&&typeof Q.requestId==="string"){let Ee=it.source;Promise.all([ht.current.catch(()=>{}),mE()]).then(()=>{try{Ee?.postMessage({dgn:"undo-barrier-ok",requestId:Q.requestId},"*")}catch{}})}else if(Q.dgn==="apply-edit"&&Q.id&&(Q.op==="css"||Q.op==="text"||Q.op==="attr")){let Ee=zI(Q);if(!Ee)return;let et=it.source,Rt=(Ht)=>{if(typeof Q.requestId!=="string")return;try{et?.postMessage({dgn:"apply-edit-result",requestId:Q.requestId,...Ht},"*")}catch{}},Zt=typeof Q.value==="string"?Q.value:null;ht.current=ht.current.catch(()=>{}).then(()=>fetch(Ee.url,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(Ee.body)}).then((Ht)=>Ht.json().catch(()=>({}))).then((Ht)=>{if(Ht.ok){if(Ee.op==="css")Ye({id:Q.id,prop:Q.key,value:Zt});Rt({ok:!0});return}console.warn("[apply-edit]",Ee.op,Ht.error||"failed"),Rt({ok:!1,error:Ht.error||"failed",conflict:Ht.conflict===!0})}).catch(()=>Rt({ok:!1,error:"network error"})))}else if(Q.dgn==="layers-tree"){S({artboardId:Q.artboardId,nodes:Array.isArray(Q.tree)?Q.tree:[]});let Ee=QA(Q.tree);if(u.current={tree:Q.tree,sig:Ee,artboardId:Q.artboardId??null},h.current=!1,b.current)clearTimeout(b.current),b.current=null;c.current?.(Q.tree,Ee,Q.artboardId??null)}else if(Q.dgn==="reorder-revert"){let Ee=e?rt.current.get(e)?.contentWindow:null,et=typeof Q.seq==="number"&&(Q.dir==="undo"||Q.dir==="redo");if(it.source===Ee&&et&&e){if(h.current=!0,b.current)clearTimeout(b.current);b.current=setTimeout(()=>{h.current=!1,b.current=null},700),fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:e,seq:Q.seq,dir:Q.dir})}).then((Rt)=>Rt.json().catch(()=>({}))).then((Rt)=>{if(!Rt.ok)console.warn("[reorder-revert]",Rt.error||"failed")}).catch(()=>{})}}else if(Q.dgn==="reorder-request"){let Ee=e?rt.current.get(e)?.contentWindow:null,et=typeof Q.id==="string"&&typeof Q.refId==="string"&&(Q.position==="before"||Q.position==="after"||Q.position==="inside-start"||Q.position==="inside-end");if(it.source===Ee&&et)f.current?.(Q.id,Q.refId,Q.position,{idIndex:Number.isInteger(Q.idIndex)?Q.idIndex:void 0,refIndex:Number.isInteger(Q.refIndex)?Q.refIndex:void 0})}else if(Q.dgn==="reposition-request"){let Ee=e?rt.current.get(e)?.contentWindow:null,et=typeof Q.id==="string"&&Number.isFinite(Q.left)&&Number.isFinite(Q.top)&&Number.isFinite(Q.beforeLeft)&&Number.isFinite(Q.beforeTop);if(it.source===Ee&&et)p.current?.(Q.id,Q.left,Q.top,Q.beforeLeft,Q.beforeTop,Number.isInteger(Q.idIndex)?Q.idIndex:void 0)}else if(Q.dgn==="resize-request"){let Ee=e?rt.current.get(e)?.contentWindow:null,et=typeof Q.id==="string"&&Q.patch&&typeof Q.patch==="object";if(it.source===Ee&&et)m.current?.(Q.id,Q.patch,Q.before,Number.isInteger(Q.idIndex)?Q.idIndex:void 0)}else if(Q.dgn==="delete-request"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee&&typeof Q.id==="string")Yt.current?.(Q.id,Number.isInteger(Q.idIndex)?Q.idIndex:void 0)}else if(Q.dgn==="duplicate-request"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee&&typeof Q.id==="string")Pa.current?.(Q.id,Number.isInteger(Q.idIndex)?Q.idIndex:void 0)}else if(Q.dgn==="copy-style"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee)Ve.current?.()}else if(Q.dgn==="paste-style"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee&&typeof Q.id==="string")B.current?.(Q.id)}else if(Q.dgn==="insert-request"){let Ee=e?rt.current.get(e)?.contentWindow:null,et=typeof Q.refId==="string",Rt=typeof Q.artboardId==="string",Zt=Q.position==="before"||Q.position==="after"||Q.position==="inside-start"||Q.position==="inside-end",Ht=et!==Rt&&(Q.kind==="div"||Q.kind==="text"||Q.kind==="image")&&Zt&&(!Rt||Q.position==="inside-start"||Q.position==="inside-end");if(it.source===Ee&&Ht)Vt.current?.(Q.refId,Q.position,Q.kind,{artboardId:Rt?Q.artboardId:void 0,src:typeof Q.src==="string"?Q.src:void 0,refIndex:Number.isInteger(Q.refIndex)?Q.refIndex:void 0})}else if(Q.dgn==="insert-image-request"){let Ee=e?rt.current.get(e)?.contentWindow:null,et=typeof Q.refId==="string",Rt=typeof Q.artboardId==="string",Zt=!et&&!Rt,Ht=(et!==Rt||Zt)&&(Zt||Q.position==="before"||Q.position==="after"||Q.position==="inside-start"||Q.position==="inside-end")&&(!Rt||Q.position==="inside-start"||Q.position==="inside-end");if(it.source===Ee&&Ht)Ce.current?.({purpose:"insert-image",canvas:e,refId:Q.refId,artboardId:Rt?Q.artboardId:void 0,position:Zt?void 0:Q.position,refIndex:Number.isInteger(Q.refIndex)?Q.refIndex:void 0,multiple:!0,hasArtboardAnchor:!Zt})}else if(Q.dgn==="replace-media-request"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee&&typeof Q.id==="string")Ce.current?.({purpose:"replace-src",canvas:e,id:Q.id,before:typeof Q.before==="string"?Q.before:null})}else if(Q.dgn==="convert-to-absolute-request"){let Ee=e?rt.current.get(e)?.contentWindow:null,et=Array.isArray(Q.containers)&&Q.containers.length>0,Rt=typeof Q.containerId==="string"&&Array.isArray(Q.children)&&Q.children.length>0;if(it.source===Ee&&(et||Rt)){let Zt=et?Q.containers.reduce((Ht,jn)=>Ht+(Array.isArray(jn?.children)?jn.children.length:0),0):Q.children.length;ua.current?.("/_api/convert-to-absolute",et?{allowShared:Q.allowShared===!0,containers:Q.containers,...Array.isArray(Q.dissolve)&&Q.dissolve.length>0?{dissolve:Q.dissolve}:{}}:{containerId:Q.containerId,containerSetRelative:Q.containerSetRelative===!0,allowShared:Q.allowShared===!0,children:Q.children},{label:"convert to absolute",onOk:()=>{nt({dgn:"selection-clear"}),nt({dgn:"op-toast",message:`Converted ${Zt} element${Zt===1?"":"s"} to absolute — press V and drag them freely (⌘Z to undo).`})},onFail:(Ht)=>nt({dgn:"op-toast",message:`Convert failed: ${Ht?.error||"unknown error"}`})})}}else if(Q.dgn==="replace-annotation-media-request"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee&&typeof Q.id==="string")Ce.current?.({purpose:"replace-annotation-media",canvas:e,id:Q.id,before:typeof Q.before==="string"?Q.before:null})}else if(Q.dgn==="edit-annotation-photo-request"){let Ee=e?rt.current.get(e)?.contentWindow:null,et=Yv.exec(typeof Q.asset==="string"?Q.asset:"")?.[0]||null;if(it.source===Ee&&typeof Q.id==="string"&&et)G({asset:et,strokeId:Q.id}),se("inspector"),ie("photo")}else if(Q.dgn==="open-sticker-picker"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee)ft.current?.({canvas:e})}else if(Q.dgn==="insert-artboard-request"){let Ee=e?rt.current.get(e)?.contentWindow:null,et=typeof Q.id==="string"&&Number.isFinite(Q.width)&&Number.isFinite(Q.height);if(it.source===Ee&&et)ke.current?.({id:Q.id,label:typeof Q.label==="string"?Q.label:Q.id,width:Q.width,height:Q.height})}else if(Q.dgn==="resize-artboard-request"){let Ee=e?rt.current.get(e)?.contentWindow:null,et=typeof Q.artboardId==="string"&&(Number.isFinite(Q.width)||Number.isFinite(Q.height));if(it.source===Ee&&et)dt.current?.(Q.artboardId,Number.isFinite(Q.width)?Q.width:void 0,Number.isFinite(Q.height)?Q.height:void 0)}else if(Q.dgn==="delete-artboard-request"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee&&typeof Q.artboardId==="string")Bt.current?.(Q.artboardId)}else if(Q.dgn==="rename-artboard-request"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee&&typeof Q.artboardId==="string"&&typeof Q.label==="string"&&Q.label.trim())ua.current?.("/_api/set-artboard-label",{artboardId:Q.artboardId,label:Q.label.slice(0,80)},{label:"rename artboard"})}else if(Q.dgn==="set-artboard-kind-request"){let Ee=e?rt.current.get(e)?.contentWindow:null,et=Q.kind===null||typeof Q.kind==="string";if(it.source===Ee&&typeof Q.artboardId==="string"&&et)Qa.current?.(Q.artboardId,Q.kind)}else if(Q.dgn==="duplicate-artboard-request"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee&&typeof Q.artboardId==="string"&&Number.isFinite(Q.width))Va.current?.(Q.artboardId,Q.width)}else if(Q.dgn==="open-inspector"){if(se("inspector"),typeof Q.tab==="string")ie(Q.tab)}else if(Q.dgn==="present-enter"){let Ee=e?rt.current.get(e)?.contentWindow:null,et=!!document.querySelector('[role="dialog"][aria-modal="true"]');if(it.source===Ee&&!et&&!Ke)ot(!0),kt({present:!0})}else if(Q.dgn==="comment-compose"&&Q.selection)a(Q.selection);else if(Q.dgn==="comment-submit"&&Q.payload&&typeof Q.payload.text==="string"){let Ee=Q.payload,et=String(Ee.text).trim(),Rt=e?rt.current.get(e)?.contentWindow:null;if(it.source===Rt&&et&&e&&e!==Ft)Se({type:"comments-add",payload:{file:e,selector:Ee.selector,index:Ee.index,dom_path:Ee.dom_path,tag:Ee.tag,classes:Ee.classes,bounds:Ee.bounds,html_excerpt:Ee.html_excerpt,annotationId:Ee.annotationId,world:Ee.world,text:et}})}else if(Q.dgn==="comment-patch"&&Q.id&&Q.patch&&typeof Q.patch==="object"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee&&De(Q.id))Se({type:"comments-patch",id:Q.id,patch:Q.patch})}else if(Q.dgn==="comment-delete"&&Q.id){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee&&De(Q.id))Se({type:"comments-delete",id:Q.id}),R((et)=>et===Q.id?null:et)}else if(Q.dgn==="comment-click"&&Q.id)R(Q.id);else if(Q.dgn==="artboards"&&typeof Q.count==="number"){let Ee=Math.round(Q.count);if(Number.isFinite(Ee)&&Ee>=0&&Ee<=999)yt(Ee)}else if(Q.dgn==="active-artboard"){let Ee=e&&e!==Ft?rt.current.get(e)?.contentWindow:null;if(it.source!==Ee)return;F(Nv(Q.id))}else if(Q.dgn==="timeline-comps"&&Array.isArray(Q.comps)){let Ee=e&&e!==Ft?rt.current.get(e)?.contentWindow:null;if(it.source!==Ee)return;let et=Q.comps.filter((Ht)=>Ht&&typeof Ht.id==="string").slice(0,32).map((Ht)=>({id:String(Ht.id).slice(0,120),fps:Math.max(1,Math.min(120,Math.round(Number(Ht.fps)||30))),durationInFrames:Math.max(1,Math.min(1e6,Math.round(Number(Ht.durationInFrames)||1))),width:Math.max(1,Math.round(Number(Ht.width)||0)),height:Math.max(1,Math.round(Number(Ht.height)||0)),artboardId:Nv(Ht.artboardId),artboardLabel:Nv(Ht.artboardLabel)}));D(et);let Rt=K.current;if(Rt&&et.some((Ht)=>Ht.id===Rt)&&X.current>0)nt({dgn:"timeline-seek",frame:X.current,id:Rt})}else if(Q.dgn==="timeline-frame"&&typeof Q.frame==="number"){let Ee=e&&e!==Ft?rt.current.get(e)?.contentWindow:null;if(it.source!==Ee)return;if(Q.id&&K.current&&Q.id!==K.current)return;if(Number.isFinite(Q.frame))U(Math.max(0,Math.round(Q.frame)))}else if(Q.dgn==="timeline-ended"){let Ee=e&&e!==Ft?rt.current.get(e)?.contentWindow:null;if(it.source!==Ee)return;if(Q.id&&K.current&&Q.id!==K.current)return;z(!1)}else if(Q.dgn==="toggle-palette"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(Ee&&it.source===Ee)H((et)=>!et)}else if(Q.dgn==="shell-shortcut"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee){if(Q.id==="reload")qe();else if(Q.id==="inspector")Z("inspector");else if(Q.id==="assistant"&&na())Z("assistant");else if(Q.id==="comments")Z("comments");else if(Q.id==="changes")Z("changes");else if(Q.id==="timeline")oe();else if(Q.id==="export")V({mode:"export"});else if(Q.id==="handoff")V({mode:"handoff"})}}else if(Q.dgn==="open-export"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee)V({mode:"export",scope:Q.detail&&typeof Q.detail.scope==="string"?Q.detail.scope:void 0})}else if(Q.dgn==="open-timeline-request"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee){if(typeof Q.artboardId==="string")F(Q.artboardId.slice(0,120));q(!0)}}else if((Q.dgn==="canvas-rendered"||Q.dgn==="canvas-failed")&&Q.file){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee)_((et)=>et===Q.file?null:et)}else if(Q.dgn==="loaded"&&Q.file){if(!Vv(Q.file))_((Rt)=>Rt===Q.file?null:Rt);k(Q.file),v((Rt)=>Rt&&Rt.path===Q.file?null:Rt);let Ee=Ke?[]:N[Q.file]||[],et=[...rt.current.entries()].find(([Rt])=>Rt===Q.file)?.[1];if(et&&et.contentWindow){try{et.contentWindow.postMessage({dgn:"comments-set",comments:Ee},"*")}catch{}try{et.contentWindow.postMessage({dgn:"theme",theme:O},"*")}catch{}try{et.contentWindow.postMessage({dgn:"view-chrome",minimap:ye,zoom:Je,present:Ke},"*")}catch{}if(E&&Ee.some((Zt)=>Zt.id===E))try{et.contentWindow.postMessage({dgn:"comment-focus",id:E},"*")}catch{}let Rt=i.current;if(Rt&&Rt.file===Q.file){i.current=null;try{et.contentWindow.postMessage({dgn:"request-layers",artboardId:Rt.artboardId??null},"*")}catch{}if(Rt.movedId)try{et.contentWindow.postMessage({dgn:"select-by-id",id:Rt.movedId,artboardId:Rt.artboardId??null,index:0},"*")}catch{}}else{let Zt=n.current,Ht=Array.isArray(Zt)?Zt[0]:Zt;if(Ht&&Ht.id&&Ht.file===Q.file)s(Ht)}}}else if(Q.dgn==="export-request"&&Q.id&&Q.payload){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source!==Ee)return;Ut(it.source,Q.id,Q.payload)}else if(Q.dgn==="export-history-request"&&Q.id)ka(it.source,Q.id)}let Nt=I?.canvasOrigin||window.location.origin;async function Ut(it,$a,Q){if(Q?.options&&e&&e!==Ft)Q.options.canvasFile=e;let Ee=(Zt)=>{try{if(it)it.postMessage({dgn:"export-result",id:$a,...Zt},Nt)}catch{}},et=Q?.options||{};if(lh({exportLane:I.exportLane||"local",format:Q?.format,scope:Q?.scope,artboardId:et.artboardId}))try{if(Q.format==="pptx"){let{filename:Zt,blob:Ht}=await ub({capture:bt,name:e?e.replace(/^.*\//,"").replace(/\.[^.]+$/,""):"export"});Qh(Zt,Ht)}else{let Zt=db(et),Ht=await bt({format:Q.format,artboardIds:[et.artboardId],scale:Zt}),jn=await cb(Ht,Q.format);for(let Mn of jn)Qh(Mn.name,Mn.blob)}Ee({ok:!0,browser:!0});return}catch{if(I.exportLane!=="remote"){Ee({ok:!1,error:"Capturing in the browser failed and this workspace has no render service to fall back to — try again, or ask your admin to add maude-render."});return}}if(I.exportLane==="none"&&Q?.format!=="zip"){Ee({ok:!1,error:"This format needs the render service, which this workspace doesn’t have configured. PNG/SVG of the active artboard and the PPTX deck export straight from the browser; ZIP works too. For the rest use the desktop app or ask your admin to add maude-render."});return}try{let Zt=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(Q)});if(!Zt.ok){Ee({ok:!1,error:await Zt.text()||String(Zt.status)});return}let{jobId:Ht}=await Zt.json();Ee({ok:!0,jobId:Ht})}catch(Zt){Ee({ok:!1,error:Zt&&Zt.message?Zt.message:String(Zt)})}}async function ka(it,$a){let Q=[];try{let Ee=await fetch("/_api/export-history");if(Ee.ok){let et=await Ee.json();if(Array.isArray(et.history))Q=et.history}}catch{}try{if(it)it.postMessage({dgn:"export-history-result",id:$a,history:Q},Nt)}catch{}}return window.addEventListener("message",Ge),()=>window.removeEventListener("message",Ge)},[N,E,I,O,qe,Ke,ye,Je,kt,e,nt,bt]);let _e=ce(()=>{if(!e||e===Ft)return;let De=rt.current.get(e);if(De&&De.contentWindow)try{De.contentWindow.postMessage({dgn:"force-clear"},"*")}catch{}},[e]),Ye=ce((De)=>{if(!e||e===Ft)return;let Ge=rt.current.get(e);if(Ge&&Ge.contentWindow)try{Ge.contentWindow.postMessage({dgn:"apply-style",...De},"*")}catch{}},[e]),He=ce((De)=>{if(!e||e===Ft||!De)return;let Ge=rt.current.get(e);if(Ge&&Ge.contentWindow)try{Ge.contentWindow.postMessage({dgn:"record-edit",payload:De},"*")}catch{}},[e]),ht=me(Promise.resolve()),Xt=ce((De,Ge,Nt,Ut)=>{let ka=Number.isInteger(Ut?.idIndex)?Ut.idIndex:void 0,it=Number.isInteger(Ut?.refIndex)?Ut.refIndex:void 0;if(!De||!Ge)return;if(De===Ge&&(ka??0)===(it??0))return;let $a=n.current,Q=Array.isArray($a)?$a[0]:$a,Ee=e;if(!Ee)return;let et=e,Rt=w?.artboardId??Q?.artboardId??null;if(S((Zt)=>Zt?{...Zt,nodes:gE(Zt.nodes,De,Ge,Nt)}:Zt),h.current=!0,b.current)clearTimeout(b.current);b.current=setTimeout(()=>{h.current=!1,b.current=null},700),ht.current=ht.current.catch(()=>{}).then(()=>fetch("/_api/reorder",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Ee,id:De,refId:Ge,position:Nt,idIndex:ka,refIndex:it})}).then((Zt)=>Zt.json().catch(()=>({}))).then((Zt)=>{if(!Zt.ok){if(console.warn("[reorder]",Zt.error||"failed"),nt({dgn:"reorder-failed"}),nt({dgn:"request-layers",artboardId:Rt}),h.current=!1,b.current)clearTimeout(b.current),b.current=null;return}if(i.current={file:et,movedId:Zt.movedId||null,artboardId:Rt},typeof Zt.seq==="number")nt({dgn:"record-edit",payload:{op:"reorder",canvas:Ee,seq:Zt.seq,label:"move element"}})}).catch(()=>{}))},[e,w,nt]);ee(()=>{f.current=Xt},[Xt]);let Ne=ce((De,Ge,Nt,Ut,ka,it)=>{if(!De||!e)return;let $a=e,Q=Number.isInteger(it)?it:void 0;Ye({id:De,prop:"left",value:`${Ge}px`}),Ye({id:De,prop:"top",value:`${Nt}px`});let Ee=null,et=(Rt,Zt)=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:$a,id:De,property:Rt,value:`${Zt}px`,idIndex:Q})}).then((Ht)=>Ht.json().catch(()=>({})));ht.current=ht.current.catch(()=>{}).then(()=>et("left",Ge)).then((Rt)=>{if(!Rt.ok)throw Error(Rt.error||"left write failed");return Ee=Rt,et("top",Nt)}).then((Rt)=>{if(!Rt.ok)throw Error(Rt.error||"top write failed");He({op:"css",canvas:$a,id:De,key:"left",before:Ip(Ee,`${Ut}px`),after:`${Ge}px`}),He({op:"css",canvas:$a,id:De,key:"top",before:Ip(Rt,`${ka}px`),after:`${Nt}px`})}).catch((Rt)=>{console.warn("[reposition]",Rt?.message||Rt),nt({dgn:"reposition-failed"})})},[e,nt,He,Ye]);ee(()=>{p.current=Ne},[Ne]);let At=ce((De,Ge,Nt,Ut)=>{if(!De||!e||!Ge||typeof Ge!=="object")return;let ka=e,it=Nt&&typeof Nt==="object"?Nt:{},$a=Number.isInteger(Ut)?Ut:void 0,Q=["width","height","left","top","transform","padding-top","padding-right","padding-bottom","padding-left","gap","grid-template-columns","grid-template-rows"].filter((va)=>typeof Ge[va]==="string"&&Ge[va]);if(!Q.length)return;let Ee=n.current,et=Array.isArray(Ee)?Ee.length===1?Ee[0]:null:Ee,Rt=et&&et.id===De?et.artboardId??null:null,Zt=et&&et.id===De?et.index??0:0;for(let va of Q)Ye({id:De,artboardId:Rt,index:Zt,prop:va,value:Ge[va]});let Ht=(va,xn)=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:ka,id:De,property:va,value:xn,idIndex:$a})}).then((ja)=>ja.json().catch(()=>({}))),jn={},Mn=ht.current.catch(()=>{});for(let va of Q)Mn=Mn.then((xn)=>{if(xn&&xn.ok===!1)throw Error(xn.error||`${va} write failed`);return Ht(va,Ge[va]).then((ja)=>(jn[va]=ja,ja))});ht.current=Mn.then((va)=>{if(va&&va.ok===!1)throw Error(va.error||"resize write failed");for(let xn of Q)He({op:"css",canvas:ka,id:De,key:xn,before:Ip(jn[xn],it[xn]??null),after:Ge[xn]});s({id:De,file:ka,artboardId:Rt,index:Zt})}).catch((va)=>{console.warn("[resize]",va?.message||va),nt({dgn:"resize-failed"})})},[e,nt,He,Ye,s]);ee(()=>{m.current=At},[At]);let ua=me(null),Be=ce((De,Ge,{label:Nt,onOk:Ut,onFail:ka}={})=>{if(!e)return;let it=e,$a=ka??((Q)=>nt({dgn:"op-toast",message:`Couldn't ${Nt||"apply the edit"}${Q?.error?` — ${Q.error}`:""}.`}));ht.current=ht.current.catch(()=>{}).then(()=>fetch(De,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...Ge,canvas:it})}).then((Q)=>Q.json().catch(()=>({}))).then((Q)=>{if(!Q.ok){console.warn(`[${De}]`,Q.error||"failed"),$a?.(Q);return}if(typeof Q.seq==="number")nt({dgn:"record-edit",payload:{op:"reorder",canvas:it,seq:Q.seq,label:Nt||"edit"}});Ut?.(Q,it)}).catch((Q)=>$a?.({error:Q?.message})))},[e,nt]);ee(()=>{ua.current=Be},[Be]);let fe=ce((De,Ge)=>{Be("/_api/delete-element",{id:De,idIndex:Number.isInteger(Ge)?Ge:void 0},{label:"delete element",onOk:()=>nt({dgn:"selection-clear"})})},[Be,nt]),Ze=ce((De,Ge,Nt,Ut={})=>{let ka=u.current?.sig??null;Be("/_api/insert-element",{refId:De,artboardId:typeof Ut.artboardId==="string"?Ut.artboardId:void 0,position:Ge,kind:Nt,src:typeof Ut.src==="string"?Ut.src:void 0,refIndex:Number.isInteger(Ut.refIndex)?Ut.refIndex:void 0},{label:`insert ${Nt}`,onOk:(it,$a)=>{if(!it.newId)return;i.current={file:$a,movedId:it.newId,artboardId:null,staleSig:ka};let Q=u.current;if(Q)c.current?.(Q.tree,Q.sig,Q.artboardId)}})},[Be]),he=ce((De)=>{if(typeof De!=="string"||!De)return!1;if(!e)return!1;let Ge=n.current?.artboardId??M??null;if(!Ge)return!1;return Ze(void 0,"inside-end","image",{artboardId:Ge,src:De}),!0},[e,M,Ze]),Le=ce((De,Ge)=>{Be("/_api/detach-component",{id:De,idIndex:Number.isInteger(Ge)?Ge:void 0},{label:"detach instance",onOk:(Nt)=>{nt({dgn:"selection-clear"}),nt({dgn:"op-toast",message:`Detached — this instance is now ${Nt.detachedName||"its own component"}; edits stay local (⌘Z to undo).`})},onFail:(Nt)=>nt({dgn:"op-toast",message:`Detach failed: ${Nt?.error||"unknown error"}`})})},[Be,nt]),Ie=ce((De,Ge)=>{let Nt=u.current?.sig??null;Be("/_api/duplicate-element",{id:De,idIndex:Number.isInteger(Ge)?Ge:void 0},{label:"duplicate element",onOk:(Ut,ka)=>{if(!Ut.newId)return;i.current={file:ka,movedId:Ut.newId,artboardId:null,staleSig:Nt};let it=u.current;if(it)c.current?.(it.tree,it.sig,it.artboardId)}})},[Be]),ue=me(null),be=Kt(()=>new Set(["position","top","right","bottom","left","inset","width","height","min-width","max-width","min-height","max-height","margin","margin-top","margin-right","margin-bottom","margin-left"]),[]),Te=ce(()=>{let De=n.current,Ge=Array.isArray(De)?De.length===1?De[0]:null:De;if(!Ge)return;let Nt={};for(let[Ut,ka]of Object.entries(Ge.authored||{}))if(!be.has(Ut))Nt[Ut]=ka;for(let[Ut,ka]of Object.entries(Ge.customStyles||{}))if(!be.has(Ut))Nt[Ut]=ka;ue.current=Object.keys(Nt).length?Nt:null},[be]),tt=ce((De)=>{let Ge=e,Nt=ue.current;if(!Ge||!De||!Nt)return;let Ut=Object.entries(Nt),ka=ht.current.catch(()=>{});for(let[it,$a]of Ut)Ye({id:De,prop:it,value:$a}),ka=ka.then(()=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Ge,id:De,property:it,value:$a})}).then((Q)=>Q.json().catch(()=>({}))).then((Q)=>{if(Q.ok)He({op:"css",canvas:Ge,id:De,key:it,before:Ip(Q,null),after:$a})}).catch(()=>{}));ht.current=ka},[e,Ye,He]),we=ce(({id:De,label:Ge,width:Nt,height:Ut})=>{Be("/_api/insert-artboard",{id:De,label:Ge,width:Nt,height:Ut},{label:"insert artboard"})},[Be]),Ue=ce((De,Ge,Nt)=>{Be("/_api/resize-artboard",{artboardId:De,width:Ge,height:Nt},{label:"resize artboard",onFail:()=>nt({dgn:"resize-artboard-failed"}),onOk:()=>o(De,e)})},[Be,nt,o,e]),lt=ce((De)=>{Be("/_api/delete-artboard",{artboardId:De},{label:"delete artboard"})},[Be]),le=ce((De,Ge)=>{Be("/_api/duplicate-artboard",{artboardId:De,width:Ge},{label:"duplicate artboard at width"})},[Be]),We=ce((De,Ge,Nt)=>{Be("/_api/set-artboard-hug",{artboardId:De,fixed:Ge,freezeHeight:Nt},{label:Ge?"pin artboard height":"hug artboard height",onOk:()=>o(De,e)})},[Be,o,e]),xt=ce((De,Ge)=>{Be("/_api/set-artboard-style",{artboardId:De,...Ge},{label:"artboard style",onOk:()=>o(De,e)})},[Be,o,e]),Wt=me(null),pa=ce((De,Ge)=>{Be("/_api/set-artboard-kind",{artboardId:De,kind:Ge},{label:"artboard kind",onOk:()=>o(De,e)});let Nt=Wt.current;if(Ge==="print"&&Nt&&Nt.artboardId===De)Wt.current=null,Be("/_api/resize-artboard",{artboardId:De,width:Nt.widthPx,height:Nt.heightPx},{label:"artboard size"}),Be("/_api/set-artboard-print",{artboardId:De,print:Nt.defaults},{label:"artboard print"})},[Be,o,e]),Qa=me(null);ee(()=>{Qa.current=pa},[pa]);let Pt=ce((De,Ge,Nt)=>{if(Ge==="print"||Ge==null||Ge==="digital"){if(Nt)Wt.current={artboardId:De,...Nt};nt({dgn:"freeze-and-set-kind",artboardId:De,kind:Ge==="digital"?null:Ge,ask:!0});return}pa(De,Ge)},[pa,nt]),pn=ce((De,Ge)=>{Be("/_api/set-artboard-print",{artboardId:De,print:Ge},{label:"artboard print",onOk:()=>o(De,e)})},[Be,o,e]),Dt=ce((De)=>{let Ge=`s${Math.random().toString(36).slice(2,8)}`;if(De.startsWith("print-")){let Ut=De.slice(6),ka;try{ka=oh({paper:Ut})}catch{return}let it=sh.find(($a)=>$a.id===Ut);we({id:Ge,label:it?it.label:Ut.toUpperCase(),width:ka.widthPx,height:ka.heightPx}),Pt(Ge,"print"),pn(Ge,{paper:Ut});return}let Nt=Os[De];if(!Nt)return;we({id:Ge,label:Nt.label,width:Nt.width,height:Nt.height})},[we,Pt,pn]),Yt=me(null),Vt=me(null),ke=me(null),dt=me(null),Bt=me(null),oa=me(null),Pa=me(null),Va=me(null),Ve=me(null),B=me(null);ee(()=>{Yt.current=fe,Vt.current=Ze,ke.current=we,dt.current=Ue,Bt.current=lt,oa.current=Pt,Pa.current=Ie,Va.current=le,Ve.current=Te,B.current=tt},[fe,Ze,we,Ue,lt,Pt,Ie,le,Te,tt]),ee(()=>{let De=(Ge)=>{if(Ge.key!=="Backspace"&&Ge.key!=="Delete")return;if(Ge.metaKey||Ge.ctrlKey||Ge.altKey)return;let Nt=Ge.target;if(Nt&&(Nt.tagName==="INPUT"||Nt.tagName==="TEXTAREA"||Nt.tagName==="SELECT"||Nt.isContentEditable))return;if(Ge.preventDefault(),!e||e===Ft)return;let ka=Array.isArray(t)?t.length===1?t[0]:null:t;if(ka?.artboardId&&!ka.id)lt(ka.artboardId)};return window.addEventListener("keydown",De),()=>window.removeEventListener("keydown",De)},[e,t,lt]);let[ae,de]=P(null),Ce=me(null);ee(()=>{Ce.current=(De)=>de(De)},[]);let[Pe,ct]=P(null),ft=me(null);ee(()=>{ft.current=(De)=>ct(De)},[]);let Ot=ce((De)=>{let Ge=ae;if(de(null),!Ge||!De)return;if(Ge.canvas&&Ge.canvas!==e){console.warn("[asset-picker] active canvas changed since request — aborting");return}if(Ge.purpose==="insert-image"){Ze(Ge.refId,Ge.position||"after","image",{artboardId:Ge.artboardId,src:De,refIndex:Ge.refIndex});return}if(Ge.purpose==="replace-src"){let Nt=e;if(!Nt||!Ge.id)return;ht.current=ht.current.catch(()=>{}).then(()=>fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Nt,id:Ge.id,attr:"src",value:De})}).then((Ut)=>Ut.json().catch(()=>({}))).then((Ut)=>{if(Ut.ok)He({op:"attr",canvas:Nt,id:Ge.id,key:"src",before:Ip(Ut,Ge.before??null),after:De});else console.warn("[replace-src]",Ut.error||"failed")}).catch(()=>{}));return}if(Ge.purpose==="replace-annotation-media")nt({dgn:"replace-annotation-media",id:Ge.id,path:De})},[ae,Ze,e,He,nt]),Mt=ce((De,Ge)=>{let Nt=ae;if(de(null),!Nt||!Array.isArray(De)||!De.length)return;if(Nt.canvas&&Nt.canvas!==e){console.warn("[asset-picker] active canvas changed since request — aborting");return}if(Ge==="artboard"){let Ut=n.current?.artboardId??M??null;if(!Ut)return;for(let ka of De)Ze(void 0,"inside-end","image",{artboardId:Ut,src:ka});return}nt({dgn:"insert-annotation-media",paths:De})},[ae,e,Ze,M,nt]),da=ce(async(De)=>{let Ge=Pe;if(ct(null),!Ge||!De?.url)return;if(Ge.canvas&&Ge.canvas!==e){console.warn("[sticker-picker] active canvas changed since request — aborting");return}try{let Nt=await fetch(De.url).then((it)=>it.ok?it.blob():Promise.reject(Error(`HTTP ${it.status}`))),Ut=await fetch("/_api/asset",{method:"POST",headers:{"content-type":Nt.type||"image/png"},body:Nt}),ka=await Ut.json().catch(()=>({}));if(!Ut.ok||!ka.path){console.warn("[sticker-picker]",ka.error||`upload failed (HTTP ${Ut.status})`);return}nt({dgn:"insert-sticker",path:ka.path})}catch{console.warn("[sticker-picker] could not load or upload that sticker")}},[Pe,e,nt]),Ta=ce((De)=>{if(!De?.id)return;de({purpose:"replace-src",canvas:e,id:De.id,before:De.attrs?.src??null})},[e]),Ma=ce((De)=>{Se({type:"comments-patch",id:De,patch:{status:"resolved"}})},[]),Or=ce((De)=>{Se({type:"comments-patch",id:De,patch:{status:"open"}})},[]),Qr=ce((De)=>{Se({type:"comments-delete",id:De}),R((Ge)=>Ge===De?null:Ge)},[]);return{applyOptimisticStyle:Ye,assetPickerReq:ae,clearActiveCanvasSelection:_e,deleteComment:Qr,detachInstanceShell:Le,duplicateArtboardShell:le,insertGeneratedImage:he,onAssetPicked:Ot,onInsertArtboard:Dt,onPickMany:Mt,onReplaceMedia:Ta,onStickerPicked:da,recordSourceEdit:He,reopenComment:Or,reorderLayer:Xt,resizeArtboardShell:Ue,resolveComment:Ma,setArtboardHugShell:We,setArtboardKindShell:Pt,setArtboardPrintShell:pn,setArtboardStyleShell:xt,setAssetPickerReq:de,setStickerPickerReq:ct,stickerPickerReq:Pe}}function Vj({groups:e,treeLoaded:t,addressMode:a,previousAddressPath:n,project:r,tabs:s,setTabs:o,activePath:i,setActivePath:u,previewPath:c,setPreviewPath:f,onPreview:p,setSelected:m,cloudLinkedHub:h,localProjectName:b,systemData:w,setLoadingPath:S,setCanvasError:_,setCanvasReloadNonce:v,setLoadedPath:k,cfg:I,loadServerConfig:A,setFocusedCommentId:N,updateTreeExp:E,setShareDialog:R,setTimelineOpen:O,timelineArtboardId:H,iframesRef:V,pushTlUndo:q,askText:D,loadTree:U,loadSystemData:z,canvasListChangeRef:M,wsSend:F}){let X=ce((he,{reveal:Le=!0}={})=>{if(Le&&he&&he!==Ft)E((Ie)=>Dv(Ie,e,he));if(a.current="push",N(null),f(null),he===i)return;if(o((Ie)=>{for(let ue of Ie)if(ue.path!==he)V.current.delete(ue.path);return[{path:he}]}),u(he),_(null),k(null),he!==Ft)S(he)},[i,e,E]),K=ce((he,Le="push")=>{let Ie=e.flatMap((ue)=>ue.paths||[]).find((ue)=>Zi(ue,I.designRel)===he);if(Ie&&ws.test(Ie))X(Ie,{reveal:!1});else if(Ie&&$d(us(Ie)))p(Ie);else o([]),u(null),f(null),uo({title:"Not here yet",description:`${he} is not in this project (not synced yet?)`,kind:"info"});a.current=Le},[e,I.designRel,X,p]),ie=me(!1);ee(()=>{if(!t||I.cloud===void 0||ie.current)return;ie.current=!0;let he=fd(location,I.designRel);if(he)K(he,"none")},[t,I.cloud,I.designRel,K]),ee(()=>{if(!t||I.cloud===void 0)return;let he=()=>{let Le=fd(location,I.designRel);if(Le)K(Le,"none");else a.current="none",o([]),u(null),f(null)};return window.addEventListener("popstate",he),()=>window.removeEventListener("popstate",he)},[t,I.cloud,I.designRel,K]),ee(()=>{let he=c||(i===Ft?null:i);if(he===n.current)return;n.current=he;let Le=Zi(he,I.designRel);if(a.current!=="none"&&fd(location,I.designRel)!==Le)history[Le?"pushState":"replaceState"](Le?{open:Le}:null,"",T3(location,Le));a.current="push"},[i,c,I.designRel]);let G=c||(i===Ft?null:i),se=I.cloud?"cloud":na()?"native":"local",Z=(he)=>$3({rel:Zi(he,I.designRel),shell:se,location,linkedHubUrl:h?.url,project:I.cloud?r:b,localUrl:location.origin}),pe=(he=G)=>{let Le=Zi(he,I.designRel);if(Le)R({path:he,rel:Le,label:us(he)})},oe=ce((he)=>{if(_(null),k(null),A(),v((Le)=>Le+1),he&&he!==Ft)S(he)},[A]),ye=me(!1);ee(()=>{if(ye.current)return;if(!I.cloud)return;if(new URLSearchParams(location.search).has("open")){ye.current=!0;return}if(s.length>0)return;if(!e.length)return;let he=null;for(let Le of e){for(let Ie of Le.paths||[]){if(!ws.test(Ie))continue;if(/(^|\/)system\//.test(Ie))continue;he=Ie;break}if(he)break}if(!he)return;ye.current=!0,X(he,{reveal:!1})},[I.cloud,e,s.length,X]);let Je=ce((he)=>{let Le=typeof he==="string"?he:void 0;if(Le)z(Le);else if(!w)z();X(Ft)},[w,z,X]);ee(()=>{F({type:"tabs",tabs:s.map((he)=>he.path).filter((he)=>he!==Ft)})},[s]),ee(()=>{if(i&&i!==Ft)F({type:"active",file:i});else if(i===Ft)F({type:"active",file:""});else F({type:"active",file:""})},[i]);let Ke=ce((he)=>{o((Le)=>{let Ie=Le.findIndex((be)=>be.path===he);if(Ie<0)return Le;let ue=Le.filter((be)=>be.path!==he);if(he===i)if(ue.length===0)u(null);else u(ue[Math.max(0,Ie-1)].path);return ue}),V.current.delete(he),S((Le)=>Le===he?null:Le)},[i]);M.current=(he)=>{if(!he?.rel)return;let Le=(I?.designRel||I?.designRoot||".design").replace(/^\/+|\/+$/g,""),Ie=`${Le}/${he.rel}`;if(he.action==="removed")Ke(Ie);else if(he.action==="moved"&&he.fromRel){let ue=`${Le}/${he.fromRel}`;o((be)=>be.map((Te)=>Te.path===ue?{...Te,path:Ie}:Te)),u((be)=>be===ue?Ie:be),S((be)=>be===ue?null:be),V.current.delete(ue)}};let ot=ce(()=>{if(!i||i===Ft){if(i===Ft)z();return}let he=V.current.get(i);if(he)he.src=he.src},[i,z]),yt=ce(()=>U(),[U]),[rt,nt]=P(!1),bt=me(!1),kt=ce(async()=>{if(bt.current)return;bt.current=!0,nt(!0);try{await Promise.all([U(),new Promise((he)=>setTimeout(he,550))])}finally{bt.current=!1,nt(!1)}},[U]);ee(()=>{let he=null,Le=()=>{if(he)clearTimeout(he);he=setTimeout(()=>{he=null,yt()},150)};return window.addEventListener("focus",Le),()=>{if(window.removeEventListener("focus",Le),he)clearTimeout(he)}},[yt]);let Se=ce(async(he)=>{try{let Le=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:he,kind:"brief-board"})}),Ie=await Le.json().catch(()=>({}));if(!Le.ok||!Ie.ok)return{ok:!1,error:Ie.error||`create failed (${Le.status})`};return await U(),X(Ie.file),{ok:!0,file:Ie.file}}catch(Le){return{ok:!1,error:Le instanceof Error?Le.message:"network error"}}},[U,X]),qe=ce(async()=>{let he=await D("New video name");if(!he)return;let Ie=(await D("Size — 1920x1080 (landscape), 1080x1920 (portrait), 1080x1080 (square), or custom WxH","1920x1080")||"1920x1080").toLowerCase().match(/(\d{2,5})\s*[x×]\s*(\d{2,5})/),ue=Ie?Number(Ie[1]):1920,be=Ie?Number(Ie[2]):1080,Te=Math.max(1,Math.min(60,Number(await D("Frames per second","30"))||30));try{let tt=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:he,kind:"video-comp",clips:[],fps:Te,width:ue,height:be})}),we=await tt.json().catch(()=>({}));if(!tt.ok||!we.ok){Gt(`New video failed: ${we.error||`error ${tt.status}`}`);return}await U(),X(we.file),O(!0),Gt("New video created — drop clips on the timeline to start the cut.",!0)}catch(tt){Gt(`New video failed: ${tt instanceof Error?tt.message:"network error"}`)}},[U,X,D]),_e=ce(async()=>{if(!i||i===Ft)return;try{let he=await fetch(`/_api/annotations?file=${encodeURIComponent(i)}`),Le=he.ok?await he.text():"",Ie=[];if(Le){let we=new DOMParser().parseFromString(Le,"image/svg+xml");for(let Ue of we.querySelectorAll('[data-tool="mediaref"]')){let lt=Ue.getAttribute("data-src");if(!lt)continue;Ie.push({src:lt,mediaKind:Ue.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(Ie.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let be=`${xs(us(i)).replace(/\.tsx$/i,"")} Video`,Te=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:be,kind:"video-comp",clips:Ie})}),tt=await Te.json().catch(()=>({}));if(!Te.ok||!tt.ok){window.alert(`Assemble failed: ${tt.error||`error ${Te.status}`}`);return}await U(),X(tt.file)}catch(he){window.alert(`Assemble failed: ${he instanceof Error?he.message:"network error"}`)}},[i,U,X]),Ye=ce(({accept:he,resolveTarget:Le})=>{let Ie=i,ue=H||void 0,be=document.createElement("input");be.type="file",be.accept=he,be.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(be);let Te=()=>{if(be.isConnected)be.remove()};window.addEventListener("focus",()=>setTimeout(Te,300),{once:!0}),be.addEventListener("change",()=>{let tt=be.files?.[0];if(Te(),!tt)return;let we=`/_api/comp-clips?canvas=${encodeURIComponent(Ie)}${ue?`&artboardId=${encodeURIComponent(ue)}`:""}`;fetch(we).then((Ue)=>Ue.json().catch(()=>({}))).then((Ue)=>{let lt=Le(Ue);if(!lt)return Gt("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":tt.type||"application/octet-stream"},body:tt}).then((le)=>le.json().catch(()=>({}))).then((le)=>{if(!le?.path)return Gt(`Upload failed: ${le?.error||"unknown error"}`),null;if(lt.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Ie,arrayName:lt.arrayRef.arrayName,index:lt.arrayRef.index,field:lt.arrayRef.field,value:le.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Ie,id:lt.cdId,attr:"src",value:le.path})})})}).then((Ue)=>Ue?Ue.json():null).then((Ue)=>{if(Ue&&!Ue.ok)Gt(`Replace refused: ${Ue.error||"failed"}`);else if(Ue&&Ue.ok){if(Gt("Media replaced.",!0),Ue.seq!=null)q(Ie,Ue.seq,"replace media")}}).catch(()=>Gt("Replace failed: network error"))}),be.click()},[i,H,q]),He=ce(async(he,Le)=>{if(!window.confirm(`Move “${Le}” to trash?
5683
+ `).length," lines, paths & secrets scrubbed)",i?.process?` + server memory (${Math.round(i.process.rssBytes/1048576)} MB)`:""," ","—"," ",y("details",{className:"rb-details",children:[l("summary",{children:"view"}),l("pre",{className:"rb-log",children:i.logs.serverLogTail})]})]})]}):null,na()&&p.length>0&&y("label",{className:"rb-check",children:[l("input",{type:"checkbox",checked:h.crashLogs,onChange:(z)=>b({...h,crashLogs:z.target.checked})}),y("span",{children:["Crash logs (",p.length,") — ",l("code",{children:p.map((z)=>z.name).join(", ")})]})]})]}),y("p",{className:"rb-hint",children:["Your description and the system info above become a"," ",l("strong",{children:"public GitHub issue"}),"; screenshots and logs go to a private repository only maintainers can open."]}),y("footer",{className:"rb-actions",children:[l("button",{type:"button",className:"st-btn",onClick:()=>r("describe"),children:"Back"}),l("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-send",onClick:q,children:"Send report"})]})]}),n==="sending"&&l("p",{className:"rb-hint",children:"Sending your report…"}),n==="done"&&y(te,{children:[k?.issueUrl?y("p",{children:["Thank you — your report is filed as"," ",y("button",{type:"button",className:"rb-link","data-testid":"report-bug-issue-link",onClick:()=>{if(na())Gb(k.issueUrl).catch(()=>navigator.clipboard?.writeText(k.issueUrl));else window.open(k.issueUrl,"_blank","noopener")},children:["report #",k.issueNumber]})," ","on the public Maude issue tracker. Screenshots and logs stay in a private repository only maintainers can open — the issue links to them."]}):y("p",{children:["The bundle is saved locally",k?.fallbackDir?y(te,{children:[" ","at ",l("code",{children:k.fallbackDir})]}):null," ","and a prefilled GitHub issue was opened — attach the bundle files there."]}),l("footer",{className:"rb-actions",children:l("button",{type:"button",className:"st-btn rb-primary",onClick:H,children:"Done"})})]}),n==="fallback"&&y(te,{children:[l("p",{className:"rb-error","data-testid":"report-bug-error",children:A}),l("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."}),y("footer",{className:"rb-actions",children:[l("button",{type:"button",className:"st-btn",onClick:()=>r("preview"),children:"Back"}),l("button",{type:"button",className:"st-btn rb-primary",onClick:D,children:"Save locally & open GitHub"})]})]})]})]})})}function uj(e){if(typeof e!=="string")return null;let t=e.match(/^(\d+)\.(\d+)\.(\d+)/);return t?[Number(t[1]),Number(t[2]),Number(t[3])]:null}function cj(e,t){let a=uj(e),n=uj(t);if(!a)return!1;if(!n)return!0;for(let r=0;r<3;r++)if(a[r]!==n[r])return a[r]>n[r];return!1}function dj(e,t){if(!Array.isArray(e))return[];return e.filter((a)=>a&&(a.version==null||cj(a.version,t)))}function fj(e,t){let a=t;if(Array.isArray(e)){for(let n of e)if(n&&n.version&&cj(n.version,a))a=n.version}return a}var zA="mdcc-whatsnew-seen",BA="mdcc-whatsnew-toast-dismissed";function Yye(e){return typeof e==="string"&&/^https?:\/\//i.test(e)}function Jye(e){try{let t=localStorage.getItem(zA);if(t)return t;localStorage.setItem(zA,e)}catch{}return e}function ebe(){try{return localStorage.getItem(BA)}catch{return null}}function UA(e){let[t,a]=P([]),[n,r]=P(e),[s,o]=P(()=>Jye(e)),[i,u]=P(()=>ebe()),[c,f]=P(!1);ee(()=>{let v=!1,k=()=>{fetch("/_api/whats-new").then((N)=>N.json()).then((N)=>{if(v)return;if(a(Array.isArray(N?.entries)?N.entries:[]),typeof N?.version==="string")r(N.version)}).catch(()=>{})};k();let I=()=>k(),A=()=>{if(document.visibilityState==="visible")k()};return window.addEventListener("focus",I),document.addEventListener("visibilitychange",A),()=>{v=!0,window.removeEventListener("focus",I),document.removeEventListener("visibilitychange",A)}},[]);let p=dj(t,s),m=p.length>0&&i!==n&&!c,h=p[0]??null,b=ce(()=>{let v=fj(t,n);o(v),u(n);try{localStorage.setItem(zA,v),localStorage.setItem(BA,n)}catch{}},[t,n]),w=ce(()=>{u(n);try{localStorage.setItem(BA,n)}catch{}},[n]),S=ce(()=>f(!0),[]),_=ce(()=>{f(!1),b()},[b]);return{entries:t,unseen:p,feedVersion:n,panelOpen:c,openPanel:S,closePanel:_,showToast:m,toastEntry:h,dismissToast:w,markAllSeen:b}}function pj({wn:e}){let t=`whats-new-${e.feedVersion}`;return ee(()=>{if(!e.showToast||!e.toastEntry){Zu(t);return}uo({id:t,group:"whats-new",kind:"info",duration:1e4,title:`What's new${e.toastEntry.version?` · v${e.toastEntry.version}`:""} — ${e.toastEntry.title}`,description:e.toastEntry.summary,action:{label:e.unseen.length>1?`See all (${e.unseen.length})`:"Details",onClick:e.openPanel},onDismiss:e.dismissToast})},[t,e.showToast,e.toastEntry,e.unseen.length,e.openPanel,e.dismissToast]),ee(()=>()=>Zu(t),[t]),null}function mj({wn:e,onStartTour:t}){let{panelOpen:a,closePanel:n}=e;if(ee(()=>{if(!a)return;function s(o){if(o.key==="Escape")n()}return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[a,n]),!a)return null;let r=new Set(e.unseen.map((s)=>s.id));return l("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(s)=>{if(s.target===s.currentTarget)n()},children:y("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[y("header",{className:"help-modal-hd",children:[l("span",{className:"title",id:"mdcc-wn-title",children:"✦ What’s new in maude"}),l("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:n,children:"×"})]}),l("div",{className:"mdcc-wn-panel__body",children:e.entries.length===0?l("p",{className:"mdcc-wn-empty",children:"Nothing new yet."}):l("ul",{className:"mdcc-wn-list",children:e.entries.map((s)=>y("li",{className:"mdcc-wn-item"+(r.has(s.id)?" is-unseen":""),children:[y("div",{className:"mdcc-wn-item__hd",children:[l("span",{className:"mdcc-wn-kind mdcc-wn-kind--"+s.kind,children:s.kind}),l("span",{className:"mdcc-wn-item__title",children:s.title}),l("span",{className:"mdcc-wn-item__ver",children:s.version?`v${s.version}`:"next"})]}),l("p",{className:"mdcc-wn-item__summary",children:s.summary}),Yye(s.learnMore)&&l("a",{className:"mdcc-wn-item__more",href:s.learnMore,target:"_blank",rel:"noreferrer",children:"Learn more →"}),t&&Array.isArray(s.tour)&&s.tour.length>0&&l("button",{type:"button",className:"mdcc-wn-item__tour",onClick:()=>{n(),t(s.tour)},children:"▶ Take tour"})]},s.id))})})]})})}var tbe=Object.freeze({dirs:[],sections:{}}),abe="mdcc-sections-expanded",nbe=250,rbe=3000;function gj(e,t){return!!t&&e.dirs.includes(t)}function sbe(e,t){return e.sections[t]===!0}function FA(e,t,a){if(!t)return e;if(e.dirs.includes(t)===!!a)return e;let r=a?[...e.dirs,t].sort():e.dirs.filter((s)=>s!==t);return{...e,dirs:r}}function yj(e,t,a){if(!t||e.sections[t]===!!a)return e;return{...e,sections:{...e.sections,[t]:!!a}}}function jA(e,t){return yj(e,t,!sbe(e,t))}function obe(e,t){let a=null;for(let n of e||[]){let r=n.fullPath;if(!r||!(t===r||t.startsWith(r+"/")))continue;if(!a||r.length>a.fullPath.length)a=n}return a}function Dv(e,t,a,{includeSelf:n=!1}={}){if(!a)return e;let r=obe(t,a);if(!r)return e;let s=yj(e,r.label,!0),o=a.slice(r.fullPath.length+1);if(!o)return s;let i=o.split("/"),u=n?i.length:i.length-1,c=r.fullPath;for(let f=0;f<u;f++)c=`${c}/${i[f]}`,s=FA(s,c,!0);return s}function Y_(e,t,a){if(!t||!a||t===a)return e;let n=!1,r=e.dirs.map((s)=>{if(s===t)return n=!0,a;if(s.startsWith(t+"/"))return n=!0,a+s.slice(t.length);return s});return n?{...e,dirs:[...new Set(r)].sort()}:e}function HA(e){let t=new Set,a=(n,r)=>{for(let s of Object.keys(n||{})){if(s==="_files")continue;let o=`${r}/${s}`;t.add(o),a(n[s],o)}};for(let n of e||[])if(n.fullPath)a(n.tree,n.fullPath);return t}function qA(e,t){let a=e.dirs.filter((n)=>t.has(n));return a.length===e.dirs.length?e:{...e,dirs:a}}function hj(e){let t=e&&typeof e==="object"&&!Array.isArray(e)?e:{},a=Array.isArray(t.dirs)?[...new Set(t.dirs.filter((r)=>typeof r==="string"&&r))].sort():[],n={};if(t.sections&&typeof t.sections==="object"&&!Array.isArray(t.sections)){for(let[r,s]of Object.entries(t.sections))if(typeof s==="boolean")n[r]=s}return{dirs:a,sections:n}}function ibe(){try{let e=JSON.parse(localStorage.getItem(abe)||"null");return e&&typeof e==="object"&&!Array.isArray(e)?e:null}catch{return null}}function VA({fetchImpl:e}={}){let[t,a]=P(tbe),[n,r]=P(!1),s=e||((...c)=>fetch(...c)),o=me(s);o.current=s,ee(()=>{let c=!1,f=typeof AbortController==="function"?new AbortController:null,p=setTimeout(()=>f?.abort(),rbe);return o.current("/_api/tree-state",f?{signal:f.signal}:void 0).then((m)=>m.ok?m.json():Promise.reject(Error(`HTTP ${m.status}`))).then((m)=>{if(c)return;let h=hj(m);if(!(m&&typeof m==="object"&&m.sections&&Object.keys(m.sections).length)){let w=ibe();if(w)h=hj({...h,sections:w})}a(h)}).catch(()=>{}).finally(()=>{if(clearTimeout(p),!c)r(!0)}),()=>{c=!0,clearTimeout(p)}},[]);let i=me(!0);ee(()=>{if(!n)return;if(i.current){i.current=!1;return}let c=setTimeout(()=>{try{o.current("/_api/tree-state",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(t)}).catch(()=>{})}catch{}},nbe);return()=>clearTimeout(c)},[n,t]);let u=ce((c)=>a((f)=>c(f)),[]);return{state:t,ready:n,update:u}}var J_="mdcc-usage-tour-seen",e2="mdcc-collab-tour-seen",Ft="__system__",Pv="mdcc-theme",zv="mdcc-show-hidden",t2="maude-cp-mode",Bv="mdcc-sidebar-open",Uv="mdcc-minimap-visible",Fv="mdcc-zoomctl-visible",jv="mdcc-annotations-visible";var GA=30000,Hv="mdcc-panel-sides",qv="mdcc-layers-mode",ws=/\.(tsx|html?)$/i,Vv=(e)=>/\.(tsx|jsx)$/i.test(String(e||"")),Sp="1.10.0",WA=[],a2="maude-mode-hint-seen";function KA(e){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(e)}).catch(()=>{})}catch{}}var lbe=[[/\.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 $d(e){for(let[t,a]of lbe)if(t.test(e))return a;return null}function Cp(e){return e.replace(/^\.[^/]+\//,"").replace(ws,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}function QA(e){let t=[];return function a(n){for(let r of n||[])t.push(r?.id??""),a(r?.children)}(e),t.join(",")}function Gh(e,t){let a=()=>{try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(e,{body:t})}catch{}};if(na()){bn("send_notification",{title:e,body:t}).catch(a);return}a()}function XA(){if(typeof window>"u")return"dark";try{let e=localStorage.getItem(Pv);if(e==="light"||e==="dark")return e}catch{}return"dark"}function tc(e,t){if(typeof window>"u")return t;try{let a=localStorage.getItem(e);if(a==="1")return!0;if(a==="0")return!1}catch{}return t}function n2(e,t){if(typeof window>"u")return t;try{let a=localStorage.getItem(e);return a?JSON.parse(a):t}catch{return t}}function ZA(){return!1}function us(e){return e.split("/").pop()}function Gt(e,t=!1,a){uo({title:e,kind:t?"success":"error",action:a})}function Vh(e=!1){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(a2)==="1")return}catch{return}if(Vh.active)return;Vh.active=!0;let t=()=>{Vh.active=!1;try{localStorage.setItem(a2,"1")}catch{}document.removeEventListener("keydown",a,!0)},a=(n)=>{if((n.key==="v"||n.key==="V")&&!n.metaKey&&!n.ctrlKey&&!n.altKey)Zu("mode-hint"),t()};if(e)document.addEventListener("keydown",a,!0);uo({id:"mode-hint",title:e?"Your mock is live":"You’re in Edit",description:e?"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:t})}function xs(e){return e.replace(ws,"")}function ube(e){return e.replace(ws,"")}function YA(e){let t=new Map;for(let s of e){if(!ws.test(s.name))continue;let o=ube(s.name);if(!t.has(o)||/\.tsx$/i.test(s.name))t.set(o,s)}let a=new Map,n=[];for(let s of e){if(ws.test(s.name))continue;let o=null;for(let i of t.keys()){if(s.name===i)continue;if(s.name.startsWith(`${i}.`)){if(!o||i.length>o.length)o=i}}if(o){let i=a.get(o)||[];i.push(s),a.set(o,i)}else n.push(s)}let r=[];for(let[s,o]of t){let i=(a.get(s)||[]).sort((u,c)=>u.name.localeCompare(c.name));r.push({primary:o,sidecars:i,orphan:!1})}return r.sort((s,o)=>s.primary.name.localeCompare(o.primary.name)),n.sort((s,o)=>s.name.localeCompare(o.name)),{canvases:r,orphans:n.map((s)=>({primary:s,sidecars:[],orphan:!0}))}}function JA(e,t,a){let n={};for(let r of a||[]){let o=(r.startsWith(t)?r.slice(t.length).replace(/^\/+/,""):r).split("/").filter(Boolean),i=n;for(let u of o)i=i[u]=i[u]||{};i._files=i._files||[]}for(let r of e){let o=(r.startsWith(t)?r.slice(t.length).replace(/^\/+/,""):r).split("/"),i=n;for(let u=0;u<o.length;u++){let c=o[u];if(u===o.length-1)i._files=i._files||[],i._files.push({name:c,path:r});else i[c]=i[c]||{},i=i[c]}}return n}function r2(e,t){if(!t)return e;let a=t.toLowerCase(),n={},r=!1,s=Object.keys(e).filter((o)=>o!=="_files");for(let o of s){let i=r2(e[o],t);if(i)n[o]=i,r=!0}if(e._files){let o=e._files.filter((i)=>i.name.toLowerCase().includes(a)||i.path.toLowerCase().includes(a));if(o.length)n._files=o,r=!0}return r?n:null}function kp(e){return(e||[]).filter((t)=>t.status!=="resolved").length}function eE(e){if(!e)return"";let t=new Date(e).getTime();if(!t)return"";let a=Math.max(0,Math.floor((Date.now()-t)/1000));if(a<60)return a+"s";let n=Math.floor(a/60);if(n<60)return n+"m";let r=Math.floor(n/60);if(r<24)return r+"h";let s=Math.floor(r/24);if(s<7)return s+"d";return new Date(e).toLocaleDateString()}function Gv(e){let t=0,a=0,n=0;for(let r of Object.values(e||{}))for(let s of r||[])if(t++,s.status==="resolved")n++;else a++;return{all:t,open:a,resolved:n}}var sn=({as:e,size:t=14})=>l(e,{size:t,strokeWidth:1.75,style:{display:"block"}});function Wh({d:e,size:t=14,color:a}){return l("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:a||"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{flex:"none"},children:l("path",{d:e})})}var cbe={"chevron-down":l("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":l("polyline",{points:"6 3.5 10.5 8 6 12.5"}),file:y(te,{children:[l("path",{d:"M4 2h5l3 3v9H4z"}),l("polyline",{points:"9 2 9 5 12 5"})]}),folder:l("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),"folder-plus":y(te,{children:[l("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),l("path",{d:"M8 7.5v3.5M6.25 9.25h3.5"})]}),lock:y(te,{children:[l("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),l("path",{d:"M5.5 7V5a2.5 2.5 0 015 0v2"})]}),unlock:y(te,{children:[l("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),l("path",{d:"M5.5 7V5a2.5 2.5 0 015-.7"})]}),search:y(te,{children:[l("circle",{cx:"7",cy:"7",r:"4"}),l("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:y(te,{children:[l("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),l("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),check:l("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),x:y(te,{children:[l("line",{x1:"4.3",y1:"4.3",x2:"11.7",y2:"11.7"}),l("line",{x1:"11.7",y1:"4.3",x2:"4.3",y2:"11.7"})]}),sun:y(te,{children:[l("circle",{cx:"8",cy:"8",r:"2.6"}),l("line",{x1:"8",y1:"1.5",x2:"8",y2:"3"}),l("line",{x1:"8",y1:"13",x2:"8",y2:"14.5"}),l("line",{x1:"1.5",y1:"8",x2:"3",y2:"8"}),l("line",{x1:"13",y1:"8",x2:"14.5",y2:"8"}),l("line",{x1:"3.4",y1:"3.4",x2:"4.4",y2:"4.4"}),l("line",{x1:"11.6",y1:"11.6",x2:"12.6",y2:"12.6"}),l("line",{x1:"12.6",y1:"3.4",x2:"11.6",y2:"4.4"}),l("line",{x1:"4.4",y1:"11.6",x2:"3.4",y2:"12.6"})]}),moon:l("path",{d:"M12.5 9.6A5 5 0 1 1 7 3a4 4 0 0 0 5.5 6.6z"}),sparkle:l("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:y(te,{children:[l("path",{d:"M2 6.7 11 4v8L2 9.3z"}),l("path",{d:"M11 5.2a2.4 2.4 0 0 1 0 5.6"}),l("path",{d:"M4.3 9.5v2.3a1.2 1.2 0 0 0 2.4 0v-1.7"})]}),bug:y(te,{children:[l("circle",{cx:"8",cy:"9",r:"3.6"}),l("circle",{cx:"8",cy:"4.4",r:"1.3"}),l("path",{d:"M6.2 3.4 5.2 2M9.8 3.4l1-1.4"}),l("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":y(te,{children:[l("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),l("line",{x1:"6.4",y1:"3",x2:"6.4",y2:"13"})]}),resolve:y(te,{children:[l("circle",{cx:"8",cy:"8",r:"5.6"}),l("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:y(te,{children:[l("path",{d:"M3.2 8a5 5 0 1 1 1.4 3.5"}),l("polyline",{points:"3.2 11.4 3.2 8 6.6 8"})]}),layers:y(te,{children:[l("polygon",{points:"8 2.2 13.8 5.5 8 8.8 2.2 5.5"}),l("polyline",{points:"2.2 9 8 12.3 13.8 9"})]}),box:l("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.2"}),type:y(te,{children:[l("polyline",{points:"4 4 12 4"}),l("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:y(te,{children:[l("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"3"}),l("line",{x1:"6",y1:"8",x2:"10",y2:"8"})]}),input:y(te,{children:[l("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"1.2"}),l("line",{x1:"5",y1:"8",x2:"5",y2:"8"})]}),link:y(te,{children:[l("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"}),l("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:y(te,{children:[l("line",{x1:"6",y1:"4.5",x2:"13",y2:"4.5"}),l("line",{x1:"6",y1:"8",x2:"13",y2:"8"}),l("line",{x1:"6",y1:"11.5",x2:"13",y2:"11.5"}),l("circle",{cx:"3.2",cy:"4.5",r:"0.8",fill:"currentColor"}),l("circle",{cx:"3.2",cy:"8",r:"0.8",fill:"currentColor"}),l("circle",{cx:"3.2",cy:"11.5",r:"0.8",fill:"currentColor"})]}),eye:y(te,{children:[l("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"}),l("circle",{cx:"8",cy:"8",r:"2"})]}),eyedropper:y(te,{children:[l("path",{d:"M11 2.6a1.7 1.7 0 0 1 2.4 2.4l-1.2 1.2-2.4-2.4z"}),l("path",{d:"M9.5 4.6 4 10.1V12h1.9l5.5-5.5"})]}),"p-corner":l("path",{d:"M3.5 12.5V7a3.5 3.5 0 0 1 3.5-3.5h5.5"}),"p-opacity":y(te,{children:[l("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.5"}),l("path",{d:"M3 8h10M8 3v10",strokeWidth:"0.9",opacity:"0.55"})]}),"p-lineheight":y(te,{children:[l("line",{x1:"6.5",y1:"4",x2:"13",y2:"4"}),l("line",{x1:"6.5",y1:"8",x2:"13",y2:"8"}),l("line",{x1:"6.5",y1:"12",x2:"13",y2:"12"}),l("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":y(te,{children:[l("path",{d:"M3 4v8M13 4v8"}),l("path",{d:"M6 11.5 8 5l2 6.5M6.7 9.3h2.6",strokeWidth:"1.1"})]}),"p-gap":y(te,{children:[l("rect",{x:"2",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),l("rect",{x:"10.4",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),l("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":l("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"}),"p-size":y(te,{children:[l("path",{d:"M3 13 6.6 3l3.6 10"}),l("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":y(te,{children:[l("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"}),l("line",{x1:"2.5",y1:"2.5",x2:"13.5",y2:"13.5"})]}),sliders:y(te,{children:[l("line",{x1:"3",y1:"5",x2:"13",y2:"5"}),l("circle",{cx:"6",cy:"5",r:"1.7",fill:"currentColor"}),l("line",{x1:"3",y1:"11",x2:"13",y2:"11"}),l("circle",{cx:"10",cy:"11",r:"1.7",fill:"currentColor"})]}),code:y(te,{children:[l("polyline",{points:"6 5 3 8 6 11"}),l("polyline",{points:"10 5 13 8 10 11"})]}),download:y(te,{children:[l("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),l("polyline",{points:"4.5 7 8 10.5 11.5 7"}),l("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),reload:y(te,{children:[l("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),l("path",{d:"M14 2v3.33h-3.33"})]}),help:y(te,{children:[l("circle",{cx:"8",cy:"8",r:"6"}),l("path",{d:"M6.3 6.2a1.8 1.8 0 1 1 2.3 1.9c-.5.2-.6.5-.6 1v.3"}),l("line",{x1:"8",y1:"11.4",x2:"8",y2:"11.5"})]}),image:y(te,{children:[l("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),l("circle",{cx:"6",cy:"6.3",r:"1.1"}),l("path",{d:"M3 12l3-2.8 2.2 1.8 2.4-3L13.5 12"})]}),vector:y(te,{children:[l("path",{d:"M3.6 11.2C6 5 10 5 12.4 11.2"}),l("rect",{x:"1.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),l("rect",{x:"11.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),l("rect",{x:"6.7",y:"2.6",width:"2.6",height:"2.6",rx:"0.4"})]}),presentation:y(te,{children:[l("rect",{x:"2.5",y:"3",width:"11",height:"7.4",rx:"1"}),l("line",{x1:"8",y1:"10.4",x2:"8",y2:"13"}),l("line",{x1:"5.6",y1:"13.4",x2:"10.4",y2:"13.4"})]}),archive:y(te,{children:[l("rect",{x:"2.5",y:"3",width:"11",height:"3",rx:"0.8"}),l("path",{d:"M3.6 6v6.2a1 1 0 0 0 1 1h6.8a1 1 0 0 0 1-1V6"}),l("line",{x1:"6.6",y1:"8.8",x2:"9.4",y2:"8.8"})]}),external:y(te,{children:[l("path",{d:"M11 8.5V12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h3.5"}),l("polyline",{points:"9.5 3 13 3 13 6.5"}),l("line",{x1:"13",y1:"3",x2:"7.6",y2:"8.4"})]}),share:y(te,{children:[l("circle",{cx:"4",cy:"8",r:"1.9"}),l("circle",{cx:"11.6",cy:"3.6",r:"1.9"}),l("circle",{cx:"11.6",cy:"12.4",r:"1.9"}),l("line",{x1:"5.7",y1:"7",x2:"9.9",y2:"4.6"}),l("line",{x1:"5.7",y1:"9",x2:"9.9",y2:"11.4"})]}),pen:y(te,{children:[l("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"}),l("line",{x1:"9.6",y1:"4.2",x2:"11.8",y2:"6.4"})]}),square:l("rect",{x:"3.5",y:"3.5",width:"9",height:"9",rx:"1"})};function ga({name:e,size:t=16,className:a}){return l("svg",{className:a,width:t,height:t,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:cbe[e]})}function bj(e){if(!e||typeof e!=="string")return"?";let t=e.trim().split(/[\s._-]+/).filter(Boolean);if(!t.length)return"?";if(t.length===1)return t[0].slice(0,2).toUpperCase();return((t[0][0]||"")+(t[t.length-1][0]||"")).toUpperCase()||"?"}function tE({initials:e,hue:t,title:a,pulse:n}){return l("span",{className:"st-avatar"+(n?" is-pulsing":""),style:{"--av-hue":t},"data-tip":a,"aria-label":a,children:e})}function Gn({children:e}){return l("span",{className:"kbd",children:e})}var Kh=[{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"}],Wl={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",sync:"right",assistant:"right"};function aE({side:e,width:t,open:a,ids:n,activeId:r,onPick:s,children:o,labels:i=null}){return y("div",{className:"st-dockslot st-dockslot--"+e+(a?"":" is-collapsed"),style:{width:a?t:0,flexBasis:a?t:0},children:[a&&n.length>1&&l("div",{className:"st-docktabs",role:"tablist","aria-label":e+" panels",children:n.map((u)=>l("button",{type:"button",role:"tab","data-testid":`dock-tab-${u}`,"aria-selected":r===u,className:"st-docktab"+(r===u?" is-active":""),onClick:()=>s(u),children:i?.[u]||(Kh.find((c)=>c.id===u)||{}).label||u},u))}),o]})}function s2(e,{min:t,max:a,def:n}){let r=ce((u)=>Math.min(a,Math.max(t,u)),[t,a]),[s,o]=P(()=>{try{let u=parseInt(localStorage.getItem(e)||"",10);return Number.isFinite(u)?r(u):n}catch{return n}});ee(()=>{try{localStorage.setItem(e,String(s))}catch{}},[e,s]);let i=ce((u)=>o((c)=>r(typeof u==="function"?u(c):u)),[r]);return{w:s,setW:i,min:t,max:a,def:n}}function nE({label:e,size:t,onPointerDown:a,active:n,dir:r="ltr"}){let{w:s,setW:o,min:i,max:u,def:c}=t,f=r==="rtl"?-1:1;return l("div",{className:"st-grip"+(n?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":e,"aria-valuemin":i,"aria-valuemax":u,"aria-valuenow":Math.round(s),onPointerDown:a,onDoubleClick:()=>o(c),onKeyDown:(p)=>{let m=p.shiftKey?24:8;if(p.key==="ArrowRight")p.preventDefault(),o((h)=>h+m*f);else if(p.key==="ArrowLeft")p.preventDefault(),o((h)=>h-m*f);else if(p.key==="Home")p.preventDefault(),o(i);else if(p.key==="End")p.preventDefault(),o(u)},children:y("svg",{className:"st-grip-dots",viewBox:"0 0 6 18","aria-hidden":"true",children:[l("circle",{cx:"3",cy:"3",r:"1.1",fill:"currentColor"}),l("circle",{cx:"3",cy:"9",r:"1.1",fill:"currentColor"}),l("circle",{cx:"3",cy:"15",r:"1.1",fill:"currentColor"})]})})}function vj({open:e,onClose:t,actions:a}){let[n,r]=P(""),[s,o]=P(0),i=me(null);ee(()=>{if(e)r(""),o(0)},[e]),ee(()=>{i.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[s]);let u=Kt(()=>sb(a,n),[n,a]);if(ee(()=>{if(s>=u.length)o(0)},[u.length,s]),!e)return null;let c=(f)=>{t(),f.run()};return l("div",{className:"st-scrim",role:"presentation",onMouseDown:(f)=>{if(f.target===f.currentTarget)t()},children:y("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[y("div",{className:"st-pal-search",children:[l(ga,{name:"search",size:18}),l("input",{autoFocus:!0,placeholder:"Type a command or search…",value:n,"aria-label":"Command search",onChange:(f)=>r(f.target.value),onKeyDown:(f)=>{if(f.key==="Escape")f.preventDefault(),t();else if(f.key==="ArrowDown")f.preventDefault(),o((p)=>Math.min(u.length-1,p+1));else if(f.key==="ArrowUp")f.preventDefault(),o((p)=>Math.max(0,p-1));else if(f.key==="Enter"){f.preventDefault();let p=EI(a,n,f.currentTarget.value,s);if(p)c(p)}}}),l(Gn,{children:"⌘K"})]}),l("div",{className:"st-pal-list",ref:i,children:u.length===0?l("div",{className:"st-pal-empty",children:"No matching command."}):u.map((f,p)=>{let m=f.group&&(p===0||u[p-1].group!==f.group)?l("div",{className:"st-pal-group",children:f.group},"g-"+f.group):null;return y(Jn,{children:[m,y("button",{type:"button",className:"st-pal-item"+(p===s?" is-active":""),onMouseEnter:()=>o(p),onClick:()=>c(f),children:[l("span",{className:"st-pal-icon",children:l(ga,{name:f.icon,size:15})}),l("span",{className:"st-pal-label",children:f.label}),f.kbd?l("span",{className:"st-pal-kbd",children:l(Gn,{children:f.kbd})}):null]})]},f.id)})})]})})}var dbe={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 wj(e){let t=String(e||"").split(".").pop()?.toLowerCase();return dbe[t]||"application/octet-stream"}function xj({designRel:e,onPick:t,onClose:a,multiple:n=!1,hasArtboardAnchor:r=!1,onPickMany:s}){let[o,i]=P(null),[u,c]=P(!1),[f,p]=P(null),[m,h]=P(null),[b,w]=P(()=>new Set),[S,_]=P({}),[v,k]=P(r?"artboard":"annotation");ee(()=>{let z=!0;return fetch("/_api/assets").then((M)=>M.json()).then((M)=>{if(!z)return;let F=M.ok?M.assets:[];i(F),_((X)=>{let K={...X};for(let ie of F)K[ie.path]=ie.kind;return K})}).catch(()=>z&&i([])),()=>{z=!1}},[]),ee(()=>{let z=(M)=>{if(M.key==="Escape")M.stopPropagation(),a()};return window.addEventListener("keydown",z,!0),()=>window.removeEventListener("keydown",z,!0)},[a]);let I=Array.from(b).some((z)=>(S[z]||"image")!=="image"),A=!r||I,N=!r?"No artboard on this canvas":I?"Video/audio can only be added as annotations":"";ee(()=>{if(A&&v==="artboard")k("annotation")},[A,v]);let E=(z)=>{w((M)=>{let F=new Set(M);if(F.has(z))F.delete(z);else F.add(z);return F})},R=async(z)=>{let M=await LA(z,{onProgress:p});return p(null),"path"in M?{ok:!0,path:M.path}:{ok:!1,error:M.error}},O=async(z)=>{if(!z)return;c(!0),h(null);let M=await R(z);if(c(!1),M.ok)t(M.path);else h(M.error)},H=(z)=>{if(typeof z==="string"&&z.startsWith("video/"))return"video";if(typeof z==="string"&&z.startsWith("audio/"))return"audio";return"image"},V=async(z)=>{if(!z.length)return;c(!0),h(null);let M=await Promise.all(z.map((K)=>R(K).then((ie)=>({...ie,file:K}))));c(!1);let F=M.filter((K)=>K.ok),X=M.length-F.length;if(X>0)h(`${X} of ${M.length} uploads failed`);if(F.length)_((K)=>{let ie={...K};for(let G of F)ie[G.path]=H(G.file.type);return ie}),w((K)=>{let ie=new Set(K);for(let G of F)ie.add(G.path);return ie})},q=async()=>{c(!0),h(null);try{if(n){let F=(await m3()||[]).map((X)=>Qb(X,wj(X.name)));c(!1);try{if(F.length)await V(F)}finally{for(let X of F)X.release()}return}let z=await dd();if(z){let M=Qb(z,wj(z.name));try{await O(M)}finally{M.release()}return}}catch(z){h(z?.message||"open failed")}c(!1)},D=()=>{if(na()){q();return}let z=document.createElement("input");if(z.type="file",z.accept="image/*,video/*",n)z.multiple=!0;z.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(z);let M=()=>{if(z.isConnected)z.remove()};window.addEventListener("focus",()=>setTimeout(M,300),{once:!0}),z.addEventListener("change",()=>{let F=z.files?Array.from(z.files):[];if(M(),!F.length)return;if(n)V(F);else O(F[0])}),z.click()},U=(z)=>`/${e}/${z}`;return l("div",{className:"st-scrim",role:"presentation",onMouseDown:(z)=>{if(z.target===z.currentTarget)a()},children:y("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[y("div",{className:"st-dialog-hd",children:[l("span",{className:"st-dialog-title",children:"Choose media"}),l("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:a,children:l(ga,{name:"x",size:15})})]}),y("div",{className:"st-dialog-bd",children:[y("div",{className:"st-ap-toolbar",children:[l("button",{type:"button",className:"st-btn",onClick:D,disabled:u,children:u?f==null?"Uploading…":`Uploading… ${Math.round(f*100)}%`:"Upload…"}),m&&l("span",{className:"st-ap-err",children:m})]}),l("div",{className:"st-ap-grid",children:o==null?l("div",{className:"st-ap-empty",children:"Loading…"}):o.length===0?l("div",{className:"st-ap-empty",children:"No assets yet — upload one."}):o.map((z)=>{let M=n&&b.has(z.path);return y("button",{type:"button",className:"st-ap-cell","data-selected":M?"true":void 0,"aria-pressed":n?M:void 0,title:`${z.name} · ${Math.max(1,Math.round(z.size/1024))} KB`,onClick:()=>n?E(z.path):t(z.path),children:[n&&l("span",{className:"st-ap-check","aria-hidden":"true",children:M?l(ga,{name:"check",size:12}):null}),z.kind==="video"?l("video",{className:"st-ap-thumb",src:U(z.path),muted:!0,playsInline:!0}):l("img",{className:"st-ap-thumb",src:U(z.path),alt:z.name,loading:"lazy"}),l("span",{className:"st-ap-name",children:z.name})]},z.path)})})]}),n&&b.size>0&&y("div",{className:"st-dialog-ft st-ap-confirm",children:[y("span",{className:"st-ap-count",children:[b.size," selected"]}),y("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[l("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":v==="artboard",disabled:A,onClick:()=>k("artboard"),children:"Add to artboard"}),l("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":v==="annotation",onClick:()=>k("annotation"),children:"Add as annotation"})]}),A&&l("span",{className:"st-ap-dest-note",children:N}),l("span",{className:"st-ap-confirm-spacer"}),l("button",{type:"button",className:"btn btn--ghost",onClick:a,children:"Cancel"}),l("button",{type:"button",className:"btn btn--primary",onClick:()=>s?.(Array.from(b),v),children:"Insert"})]})]})})}var rE=[{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}],_j={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","canvas-whole":"Whole canvas · one image","selection-bounds":"Selection area · one image","project-raw":"Whole project (raw)"},Sj=new Set(["canvas-whole","selection-bounds"]),fbe=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],Wv=[{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}],pbe="2x",Cj=[{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}],mbe="auto",kj=[{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."}],hbe="keep";function Qh(e,t){let a=URL.createObjectURL(t),n=document.createElement("a");n.href=a,n.download=e||"export",document.body.appendChild(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(a),1e4)}function Ij({mode:e,initialScope:t,activePath:a,hasComps:n=!1,comps:r=[],activeArtboardId:s=null,selection:o=null,exportLane:i="local",onBrowserCapture:u=null,onQuerySelection:c=null,onClose:f}){let p=ce((_e)=>i==="none"&&!_e.handoff&&_e.format!=="zip"&&!UI.has(_e.format)||i!=="local"&&_e.format==="canva",[i]),[m,h]=P(e==="handoff"?"shadcn":"png"),[b,w]=P(()=>t&&NI("png",t)?t:M1("png")),[S,_]=P(2),[v,k]=P(pbe),[I,A]=P(!0),[N,E]=P(!1),[R,O]=P(!1),[H,V]=P(!1),[q,D]=P(mbe),[U,z]=P(hbe),[M,F]=P(!1),[X,K]=P(!0),[ie,G]=P(!1),[se,Z]=P(null),[pe,oe]=P([]),ye=rE.find((_e)=>_e.id===m)||rE[0],Je=ye.handoff?[]:R1(ye.format),Ke=900,ot=3600,yt=Yu(r,Lv(r,{artboardId:s})),rt=yt?.durationInFrames||0,nt=yt?.fps||30,bt=ye.temporal&&rt>900,kt=ye.temporal&&rt>3600;ee(()=>{if(Je.length&&!Je.includes(b))w(M1(ye.format))},[Je,b,ye.format]),ee(()=>{if(i!=="remote")return;fetch("/_api/export-warmup").catch(()=>{})},[i]);let Se=ce(()=>{fetch("/_api/export-history").then((_e)=>_e.json()).then((_e)=>oe(Array.isArray(_e?.history)?_e.history.slice(0,6):[])).catch(()=>{})},[]);ee(()=>{Se()},[Se]),ee(()=>{function _e(Ye){if(Ye.key==="Escape")Ye.preventDefault(),f()}return window.addEventListener("keydown",_e),()=>window.removeEventListener("keydown",_e)},[f]);async function qe(){if(ye.handoff){let ht=`/design:handoff ${a&&a!==Ft?a:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(ht)}catch{}Z({ok:!0,msg:`Copied: ${ht} — run it in Claude Code.`});return}if(p(ye)){Z({ok:!1,msg:"This format needs the render service, which this workspace doesn’t have configured."});return}G(!0),Z(null);let _e=ye.temporal?{scale:S}:{};if(ye.format==="png"){let He=Wv.find((ht)=>ht.id===v)||Wv[1];if(He.kind==="dpi")_e.dpi=He.value;else _e.scale=He.value}if(ye.format==="mp4"||ye.format==="webm")_e.audio=X;if(kt)_e.maxFrames=rt;if(ye.format==="pdf"){_e.pdfPrint={includeBleed:I,marks:{crop:R,registration:H}};let He=Cj.find((ht)=>ht.id===q)?.value;if(He!==void 0)_e.dpi=He;if(U!=="keep")_e.text=U}if(s)_e.artboardId=s;if(o?.selector)_e.selection=o;if(Sj.has(b)&&M)_e.includeAnnotations=!0;if(b==="selection-bounds"&&typeof c==="function"){let He=await c();if(He?.length)_e.selectionAll=He}if(a&&a!==Ft)_e.canvasFile=a;if(lb.has(ye.format)&&lh({exportLane:i,format:ye.format,scope:b,artboardId:_e.artboardId})&&typeof u==="function")try{let He=db(_e);Z({ok:!0,msg:"Capturing…"});let ht=await u({format:ye.format,artboardIds:[_e.artboardId],scale:He,onProgress:(Ne,At)=>Z({ok:!0,msg:`Capturing ${Ne}/${At}…`})}),Xt=await cb(ht,ye.format);for(let Ne of Xt)Qh(Ne.name,Ne.blob);for(let Ne of Xt)await B1({format:ye.format,scope:b,filename:Ne.name});G(!1),Z({ok:!0,msg:`Saved ${Xt.map((Ne)=>Ne.name).join(", ")} to your downloads.`});return}catch(He){if(i!=="remote"){Z({ok:!1,msg:`Capture failed: ${He&&He.message||He}`}),G(!1);return}}if(lh({exportLane:i,format:ye.format,scope:b})&&ye.format==="pptx"&&typeof u==="function")try{Z({ok:!0,msg:"Capturing artboards…"});let He=a&&a!==Ft?us(a).replace(/\.[^.]+$/,""):"export",{filename:ht,blob:Xt}=await ub({capture:u,name:He,onProgress:(Ne,At)=>Z({ok:!0,msg:`Capturing ${Ne}/${At}…`}),onAssemble:()=>Z({ok:!0,msg:"Assembling deck…"})});Qh(ht,Xt),await B1({format:ye.format,scope:b,filename:ht}),G(!1),Z({ok:!0,msg:`Saved ${ht} to your downloads.`});return}catch(He){if(i!=="remote"){Z({ok:!1,msg:`Deck export failed: ${He&&He.message||He}`}),G(!1);return}}if(i==="none"&&lb.has(ye.format)){Z({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."}),G(!1);return}try{let He=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:ye.format,scope:b,options:_e})});if(!He.ok){Z({ok:!1,msg:await He.text()||`Export failed (${He.status})`}),G(!1);return}f()}catch(He){Z({ok:!1,msg:He&&He.message?He.message:String(He)}),G(!1)}}return l("div",{className:"st-scrim",role:"presentation",onMouseDown:(_e)=>{if(_e.target===_e.currentTarget)f()},children:y("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[y("div",{className:"st-dialog-hd",children:[l("span",{className:"st-dialog-title",children:"Export & handoff"}),l("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:f,children:l(ga,{name:"x",size:15})})]}),y("div",{className:"st-dialog-bd",children:[l("div",{className:"st-rp-hd",children:a&&a!==Ft?`Format · ${xs(us(a))}`:"Format"}),l("div",{className:"st-fmt-grid",children:rE.filter((_e)=>!_e.temporal||n).map((_e)=>y("button",{type:"button","data-testid":`export-format-${_e.id}`,className:"st-fmt"+(_e.id===m?" is-on":""),disabled:p(_e),title:p(_e)?"Needs the render service — not configured on this workspace":void 0,onClick:()=>{h(_e.id),Z(null)},children:[l(ga,{name:_e.icon,size:16}),l("span",{className:"st-fmt-name",children:_e.label}),l("span",{className:"st-fmt-sub",children:_e.sub})]},_e.id))}),i==="none"&&y("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 ",l("code",{children:" maude-render"})," service (see the self-hosting docs)."]}),!ye.handoff&&y("div",{className:"st-dialog-row",children:[l("label",{className:"st-dialog-lbl",htmlFor:"st-export-scope",children:"Scope"}),l("select",{id:"st-export-scope","data-testid":"export-scope",className:"st-select",value:b,onChange:(_e)=>w(_e.target.value),children:Je.map((_e)=>l("option",{value:_e,children:_j[_e]},_e))})]}),!ye.handoff&&Sj.has(b)&&y("div",{className:"st-dialog-row",children:[l("label",{className:"st-dialog-lbl",htmlFor:"st-export-annotations",children:"Annotations"}),y("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[l("input",{id:"st-export-annotations",type:"checkbox","data-testid":"export-include-annotations",checked:M,onChange:(_e)=>F(_e.target.checked)}),"Include annotations"]})]}),!ye.handoff&&ye.format==="png"&&y("div",{className:"st-dialog-row",children:[l("label",{className:"st-dialog-lbl",htmlFor:"st-export-size",children:"Resolution"}),l("select",{id:"st-export-size",className:"st-select",value:v,onChange:(_e)=>k(_e.target.value),children:Wv.map((_e)=>l("option",{value:_e.id,children:_e.label},_e.id))})]}),!ye.handoff&&ye.format==="png"&&l("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let _e=Wv.find((He)=>He.id===v)||Wv[1],Ye=_e.kind==="dpi"?_e.value/96:_e.value;return`${_e.label} ≈ ${Math.round(1440*Ye)}×${Math.round(900*Ye)} for a 1440×900 artboard.`})()}),!ye.handoff&&ye.temporal&&y("div",{className:"st-dialog-row",children:[l("label",{className:"st-dialog-lbl",htmlFor:"st-export-temporal-size",children:"Resolution"}),l("select",{id:"st-export-temporal-size",className:"st-select",value:S,onChange:(_e)=>_(Number(_e.target.value)),children:fbe.map((_e)=>l("option",{value:_e.value,children:_e.label},_e.value))})]}),!ye.handoff&&ye.temporal&&y("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[S,"× the artboard's native resolution (e.g. 960×540 → ",960*S,"×",540*S,")."]}),bt&&y("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: ",rt," frames (≈",Math.round(rt/nt),"s).",kt?` 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."]}),!ye.handoff&&ye.format==="pdf"&&y(te,{children:[y("div",{className:"st-dialog-row",children:[l("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-dpi",children:"Image quality"}),l("select",{id:"st-export-pdf-dpi",className:"st-select",value:q,onChange:(_e)=>D(_e.target.value),children:Cj.map((_e)=>l("option",{value:_e.id,children:_e.label},_e.id))})]}),l("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)."}),y("div",{className:"st-dialog-row",children:[l("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-text",children:"Text"}),l("select",{id:"st-export-pdf-text",className:"st-select","data-testid":"export-pdf-text",value:U,onChange:(_e)=>z(_e.target.value),children:kj.map((_e)=>l("option",{value:_e.id,children:_e.label},_e.id))})]}),l("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:kj.find((_e)=>_e.id===U)?.description}),l("div",{className:"st-dialog-row",children:y("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-bleed",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[l("input",{id:"st-export-pdf-bleed",type:"checkbox",checked:I,onChange:(_e)=>A(_e.target.checked)}),"Include bleed"]})}),l("div",{className:"st-dialog-row",children:y("button",{type:"button",className:"st-dialog-lbl",style:{background:"none",border:0,padding:0,cursor:"pointer"},onClick:()=>E((_e)=>!_e),"aria-expanded":N,children:[N?"▾":"▸"," Marks"]})}),N&&y("div",{style:{padding:"0 12px 4px",display:"flex",flexDirection:"column",gap:6},children:[y("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[l("input",{type:"checkbox",checked:R,onChange:(_e)=>O(_e.target.checked)}),"Crop marks"]}),y("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[l("input",{type:"checkbox",checked:H,onChange:(_e)=>V(_e.target.checked)}),"Registration marks"]})]}),y("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:["Bleed and marks apply to print (",l("code",{children:'kind="print"'}),") artboards only.",b==="canvas-as-separate"?" One PDF page per artboard.":""]})]}),!ye.handoff&&(ye.format==="mp4"||ye.format==="webm")&&l("div",{className:"st-dialog-row",children:y("label",{className:"st-dialog-lbl",htmlFor:"st-export-audio",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[l("input",{id:"st-export-audio",type:"checkbox",checked:X,onChange:(_e)=>K(_e.target.checked)}),"Export with audio"]})}),ye.handoff&&y("div",{className:"callout callout--info",style:{fontSize:12},children:["Hands the active canvas off to production. Copies"," ",l("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."]}),se&&l("div",{className:"callout "+(se.ok?"callout--success":"callout--error"),style:{fontSize:12},"data-testid":"export-status","data-ok":se.ok?"1":"0",children:se.msg}),pe.length>0&&y("div",{className:"st-export-recent","data-testid":"export-recent",children:[l("div",{className:"st-rp-hd",children:"Recent"}),pe.map((_e,Ye)=>y("div",{className:"st-export-recent-row",children:[y("span",{children:[String(_e.format||"").toUpperCase()," ·"," ",_j[_e.scope]||_e.scope]}),l("span",{className:"st-mono",children:_e.filename})]},Ye))]})]}),y("div",{className:"st-dialog-ft",children:[l("button",{type:"button",className:"btn btn--ghost",onClick:f,children:"Cancel"}),y("button",{type:"button",className:"btn btn--primary","data-testid":"export-submit",disabled:ie,onClick:qe,children:[l(ga,{name:"download",size:14}),ye.handoff?"Copy handoff command":ie?"Exporting…":`Export ${ye.label}`]})]})]})})}var l2=12,u2=16;function gbe({name:e,depth:t,children:a,dirPath:n,drag:r,menu:s,expansion:o,forceOpen:i}){let u=!!i||!!o?.isOpen(n),c=(S)=>{if(i)return;let _=typeof S==="function"?S(u):S;if(_!==u)o?.setOpen(n,_)},f=r?r.dropProps(n,!0,()=>c(!0)):{},p=r?.overDir===n,m=r?r.dragProps(n,!0):{},h=r?.draggedPath===n,b=r?.busyPath===n,w=y("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${Cp(n)}`,"aria-expanded":u,"aria-dropeffect":r?"move":void 0,"aria-busy":b||void 0,tabIndex:-1,className:"st-row"+(p?" is-drop-target":"")+(h?" is-dragging":"")+(b?" is-busy":""),style:{paddingLeft:l2+t*u2+"px"},onClick:()=>c((S)=>!S),onContextMenu:s?(S)=>s.openAt(S,{kind:"dir",dirPath:n}):void 0,...m,...f,children:[l("span",{className:"st-row-glyph",children:l(ga,{name:"chevron-right",className:"st-chev"+(u?" is-open":""),size:13})}),l("span",{className:"st-row-name",children:e})]});return l(Jf,{label:e,row:w,expanded:u,busy:b,onToggle:()=>c((S)=>!S),actions:s?l("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${Cp(n)}`,title:`Folder actions — ${e}`,"aria-label":`Folder actions for ${e}`,"aria-haspopup":"menu",onClick:(S)=>s.openAt(S,{kind:"dir",dirPath:n}),children:l(Wh,{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:u&&a})}function ybe({name:e,dsName:t,dirPath:a,depth:n,active:r,onOpenSystem:s,children:o,expansion:i,forceOpen:u}){let c=!!u||!!i?.isOpen(a),f=(p)=>{if(u)return;let m=typeof p==="function"?p(c):p;if(m!==c)i?.setOpen(a,m)};return l(Jf,{label:e,expanded:c,selected:r,onToggle:()=>f((p)=>!p),row:y("div",{className:"st-row st-ds-folder"+(r?" is-sel":""),style:{paddingLeft:l2+n*u2+"px"},children:[l("button",{type:"button",className:"st-ds-chev",onClick:()=>f((p)=>!p),"aria-label":c?"Collapse design system":"Expand design system",title:c?"Collapse":"Expand",children:l(ga,{name:"chevron-right",className:"st-chev"+(c?" is-open":""),size:13})}),y("button",{type:"button",className:"st-ds-open","data-tree-primary":"",tabIndex:-1,onClick:()=>s(t),"aria-label":`Open ${t} design system view`,title:"Open the design system view",children:[l("span",{className:"st-row-glyph",children:l(ga,{name:"folder",size:13})}),l("span",{className:"st-row-name",children:e})]})]}),children:c&&o})}function i2({file:e,activePath:t,previewPath:a,onOpen:n,onPreview:r,onDelete:s,openCount:o,depth:i,kind:u,sidecar:c,dirty:f,experimentalKind:p,drag:m,menu:h}){let b=e.path===t||e.path===a,w=ws.test(e.name),S=!w&&u!=="runtime"?$d(e.name):null,_=!w&&!S,v=w?xs(e.name):e.name,k=w&&typeof s==="function"&&u!=="runtime",I=w&&!c&&u!=="runtime"&&typeof m<"u",A=I?m.dragProps(e.path,!0):{},N=m?.draggedPath===e.path,E=m?.busyPath===e.path,R=I&&typeof h<"u",O=!w&&!!S&&!c&&typeof h<"u",H=typeof h<"u"&&u!=="runtime",V=e.path.split("/").slice(0,-1).join("/"),q=w?"canvas-row-"+e.path.replace(/^\.[^/]+\//,"").replace(ws,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,D=y("button",{type:"button",role:"treeitem","data-testid":q??(O?`file-row-${Cp(e.path)}`:void 0),"aria-selected":b,"aria-disabled":_?"true":void 0,"aria-busy":E||void 0,tabIndex:b?0:-1,className:"st-row"+(b?" is-sel":"")+(u==="runtime"?" is-muted":"")+(N?" is-dragging":"")+(E?" is-busy":""),style:{paddingLeft:l2+i*u2+"px"},title:e.path+(o?` — ${o} open`:_?" (file index only)":""),onClick:()=>{if(w)n(e.path);else if(S)r?.(e.path)},onPointerEnter:S==="image"?()=>D_(e.path):void 0,onFocus:S==="image"?()=>D_(e.path):void 0,onContextMenu:H?(U)=>h.openAt(U,{kind:"file",path:e.path,dir:V,canMove:R||O,supporting:O,name:e.name}):void 0,...A,children:[l("span",{className:"st-row-glyph",children:l(ga,{name:"file",size:13})}),l("span",{className:"st-row-name",children:v}),p==="reconstructed-experimental"&&l("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"}),p==="imported-figma"&&l("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"}),f&&l("span",{className:"st-git-badge","data-kind":f,title:`Unsaved (${f})`,"aria-label":`Unsaved, ${f}`,children:f}),o>0&&l("span",{className:"st-row-badge",children:o})]});return l(Jf,{label:v,row:D,selected:b,disabled:_,busy:E,actions:y(te,{children:[H&&l("button",{type:"button",className:"st-row-menu-btn"+(k?" has-delete-sibling":""),"data-testid":`tree-row-menu-${Cp(e.path)}`,title:`Actions for ${v}`,"aria-label":`Actions for ${v}`,"aria-haspopup":"menu",onClick:(U)=>h.openAt(U,{kind:"file",path:e.path,dir:V,canMove:R||O,supporting:O,name:e.name}),children:l(Wh,{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})}),k&&l("button",{type:"button",className:"st-row-del",title:`Delete ${v}`,"aria-label":`Delete canvas ${v}`,onClick:(U)=>{U.stopPropagation(),s(e.path,v)},children:l(Wh,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})})}function bbe({primary:e,sidecars:t,depth:a,kind:n,activePath:r,previewPath:s,onOpen:o,onPreview:i,onDelete:u,openCount:c,showHidden:f,forceOpen:p,dirtyByPath:m,experimentalKind:h,drag:b,menu:w}){let S=m?.get(e.path),_=t.length>0,[v,k]=P(!1),I=p||v,A=e.path===r;if(!(_&&f))return l(i2,{file:e,activePath:r,previewPath:s,onOpen:o,onPreview:i,onDelete:u,openCount:c,depth:a,kind:n,dirty:S,experimentalKind:h,drag:b,menu:w});let E=typeof b<"u",R=E?b.dragProps(e.path,!0):{},O=b?.draggedPath===e.path,H=b?.busyPath===e.path,V=E&&typeof w<"u",q=typeof w<"u"&&n!=="runtime",D=e.path.split("/").slice(0,-1).join("/"),U=y("button",{type:"button",role:"treeitem","aria-selected":A,"aria-expanded":I,"aria-busy":H||void 0,tabIndex:A?0:-1,className:"st-row st-canvas-row"+(A?" is-sel":"")+(O?" is-dragging":"")+(H?" is-busy":""),style:{paddingLeft:l2+a*u2+"px"},title:e.path,onClick:(z)=>{if(z.target.closest(".st-canvas-chev")){k((M)=>!M);return}o(e.path)},onContextMenu:q?(z)=>w.openAt(z,{kind:"file",path:e.path,dir:D,canMove:V}):void 0,...R,children:[l("span",{className:"st-row-glyph st-canvas-chev",onClick:(z)=>{z.stopPropagation(),k((M)=>!M)},children:l(ga,{name:"chevron-right",className:"st-chev"+(I?" is-open":""),size:13})}),l("span",{className:"st-row-name",children:xs(e.name)}),h==="reconstructed-experimental"&&l("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"}),h==="imported-figma"&&l("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"}),S&&l("span",{className:"st-git-badge","data-kind":S,title:`Unsaved (${S})`,"aria-label":`Unsaved, ${S}`,children:S}),c>0&&l("span",{className:"st-row-badge",children:c})]});return l(Jf,{label:xs(e.name),row:U,selected:A,expanded:I,busy:H,onToggle:()=>k((z)=>!z),actions:q?l("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${Cp(e.path)}`,title:`Actions for ${xs(e.name)}`,"aria-label":`Actions for ${xs(e.name)}`,"aria-haspopup":"menu",onClick:(z)=>w.openAt(z,{kind:"file",path:e.path,dir:D,canMove:V}),children:l(Wh,{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:I&&t.map((z)=>l(i2,{file:z,menu:w,activePath:r,previewPath:s,onOpen:o,onPreview:i,openCount:0,depth:a+1,kind:n,sidecar:!0},z.path))})}function Tj({node:e,activePath:t,previewPath:a,onOpen:n,onPreview:r,commentsByFile:s,depth:o=1,kind:i,showHidden:u,search:c,dsFolders:f,activeDsName:p,onOpenSystem:m,onDelete:h,dirtyByPath:b,canvasKinds:w,dirPath:S="",drag:_,menu:v,expansion:k}){let I=Object.keys(e).filter((q)=>q!=="_files").sort(),A=e._files||[],{canvases:N,orphans:E}=Kt(()=>YA(A),[A]),{mediaOrphans:R,metaOrphans:O}=Kt(()=>{let q=[],D=[];for(let U of E){let z=$d(U.primary.name);(z==="image"||z==="video"||z==="audio"||z==="font"?q:D).push(U)}return{mediaOrphans:q,metaOrphans:D}},[E]),H=!!(c&&c.trim()),V=Kt(()=>{if(!f||o!==1)return null;let q=new Map;for(let D of f)q.set(D.folder,D);return q},[f,o]);return y(Jn,{children:[N.map((q)=>{let D=H&&q.sidecars.some((U)=>{let z=c.toLowerCase();return U.name.toLowerCase().includes(z)||U.path.toLowerCase().includes(z)});return l(bbe,{primary:q.primary,sidecars:q.sidecars,activePath:t,previewPath:a,onOpen:n,onPreview:r,onDelete:h,openCount:kp(s[q.primary.path]),depth:o,kind:i,showHidden:u,forceOpen:D,dirtyByPath:b,experimentalKind:w?.[q.primary.path],drag:_,menu:v},q.primary.path)}),R.map((q)=>l(i2,{file:q.primary,menu:v,activePath:t,previewPath:a,onOpen:n,onPreview:r,openCount:kp(s[q.primary.path]),depth:o,kind:i},q.primary.path)),u&&O.map((q)=>l(i2,{file:q.primary,menu:v,activePath:t,previewPath:a,onOpen:n,onPreview:r,openCount:kp(s[q.primary.path]),depth:o,kind:i},q.primary.path)),I.map((q)=>{let D=V?.get(q),U=S?`${S}/${q}`:q,z=l(Tj,{node:e[q],activePath:t,previewPath:a,onOpen:n,onPreview:r,commentsByFile:s,depth:o+1,kind:i,showHidden:u,search:c,activeDsName:p,onOpenSystem:m,onDelete:h,dirtyByPath:b,canvasKinds:w,dirPath:U,drag:_,menu:v,expansion:k});if(D&&m)return l(ybe,{name:q,dsName:D.name,dirPath:U,depth:o,expansion:k,forceOpen:H,active:t===Ft&&D.name===p,onOpenSystem:m,children:z},q);return l(gbe,{name:q,depth:o,dirPath:U,expansion:k,forceOpen:H,drag:_,menu:_?v:void 0,children:z},q)})]})}var o2={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function vbe(e){if(e.kind==="project")return o2.project;if(e.kind==="runtime")return o2.runtime;if(e.label==="Design system")return o2.ds;if(e.label==="UI kit")return o2.canvas;return{title:e.label.toUpperCase(),pillFromCount:!0}}function wbe({failures:e,cloud:t}){let[a,n]=P(!1);ee(()=>{let s=setTimeout(()=>n(!0),3000);return()=>clearTimeout(s)},[]);let r=e>0?"The project is taking a while to answer — trying again…":t?"Still loading — a large cloud project can take a few seconds to list.":"Still loading — a large project can take a few seconds to list.";return y("div",{className:"st-tree-loading",role:"status","aria-live":"polite","data-testid":"tree-loading",children:[y("div",{className:"st-tree-loading-head",children:[l("span",{className:"st-canvas-loading-spinner","aria-hidden":"true"}),l("span",{children:"Loading files…"})]}),[64,48,72,40,56,68,44].map((s,o)=>l("span",{className:"skel st-tree-loading-row",style:{width:`${s}%`,marginLeft:o%3?22:8},"aria-hidden":"true"},o)),(a||e>0)&&l("div",{className:"st-tree-loading-hint",children:r})]})}function sE({readOnly:e=!1,cloud:t,groups:a,activePath:n,previewPath:r,activeDsName:s,onOpen:o,onPreview:i,onOpenSystem:u,wsConnected:c,search:f,setSearch:p,commentsByFile:m,showHidden:h,sectionsExpanded:b,onToggleSection:w,treeExpansion:S,onNewBoard:_,onDeleteBoard:v,onRefresh:k,refreshing:I,collapsed:A,onCollapse:N,width:E,resizing:R,dirtyByPath:O,project:H,gitBranch:V,remoteSync:q,onGetLatest:D,canvasKinds:U,onMoveCanvas:z,onNewFolder:M,onDeleteFolder:F,onRenameFolder:X,onRenameCanvas:K,onDuplicateCanvas:ie,onDeleteFile:G,syncStatus:se,onLinkedHub:Z,onLocalProject:pe,onOpenLinkedFile:oe,filesReady:ye,treeLoadFailures:Je=0,onShare:Ke,savingIsManaged:ot=!1}){let yt=Kt(()=>{if(!f)return a;return a.map((ue)=>({...ue,tree:r2(ue.tree,f),filtered:!!f}))},[a,f]),rt=VI(z),nt=FI(),bt=Kt(()=>{let ue=[];for(let be of a){if(be.label==="Design system"||be.kind!=="canvas")continue;let Te=be.fullPath.replace(/^\.[^/]+\//,"")||be.fullPath;ue.push({path:be.fullPath,label:Te});for(let tt of be.dirs||[])ue.push({path:tt,label:tt.replace(/^\.[^/]+\//,"")})}return ue},[a]),kt=nt.state?.extra,Se=kt?.kind==="file"?[{id:"share",label:"Share…",onSelect:()=>{nt.close(),Ke(kt.path)}},...K&&/\.tsx$/i.test(kt.path)?[{id:"rename-canvas",label:"Rename…",onSelect:()=>{nt.close();let ue=xs(kt.path.split("/").pop()),be=window.prompt("Rename canvas to:",ue);if(be?.trim()&&be.trim()!==ue)K(kt.path,be.trim())}}]:[],...ie&&/\.tsx$/i.test(kt.path)?[{id:"duplicate-canvas",label:"Duplicate",onSelect:()=>{nt.close(),ie(kt.path)}}]:[],...kt.supporting&&K?[{id:"rename-file",label:"Rename…",onSelect:()=>{nt.close();let ue=kt.name??kt.path.split("/").pop(),be=ue.includes(".")?ue.slice(ue.lastIndexOf(".")):"",Te=be?ue.slice(0,-be.length):ue,tt=window.prompt(`Rename ${ue} to:`,Te);if(tt?.trim()&&tt.trim()!==Te)K(kt.path,tt.trim())}}]:[],...kt.canMove?[{id:"move-to",label:"Move to…",onSelect:()=>nt.showMoveTo()}]:[],...kt.supporting&&G?[{id:"delete-file",label:"Delete",destructive:!0,onSelect:()=>{nt.close(),G(kt.path,kt.name??kt.path.split("/").pop())}}]:[]]:kt?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{nt.close();let ue=window.prompt("New folder name:");if(ue?.trim())M(kt.dirPath,ue.trim())}},{id:"rename-folder",label:"Rename folder",onSelect:()=>{nt.close();let ue=kt.dirPath.split("/").pop(),be=window.prompt("Rename folder to:",ue);if(be?.trim()&&be.trim()!==ue)X(kt.dirPath,be.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{nt.close(),F(kt.dirPath,kt.dirPath.split("/").pop())}}]:[],qe=kt?.kind==="file"||kt?.kind==="supporting"?bt.filter((ue)=>ue.path!==kt.dir):[],[_e,Ye]=P(!1),[He,ht]=P("board"),[Xt,Ne]=P(""),[At,ua]=P(""),[Be,fe]=P(!1),Ze=Kt(()=>a.find((ue)=>ue.kind==="canvas"&&ue.label!=="Design system")?.fullPath,[a]),he=ce(async()=>{let ue=Xt.trim();if(!ue||Be)return;if(fe(!0),ua(""),He==="folder"){if(!Ze){fe(!1),ua("no canvas group to create a folder in");return}let Te=await M(Ze,ue);if(fe(!1),Te?.ok)Ye(!1),Ne("");else ua(Te?.error||"could not create folder");return}let be=await _(ue);if(fe(!1),be?.ok)Ye(!1),Ne("");else ua(be?.error||"could not create board")},[Xt,Be,_,M,He,Ze]),Le=Kt(()=>{let ue=0;for(let be of a)for(let Te of be.paths||[])if(ws.test(Te))ue++;return ue},[a]),Ie=Kt(()=>{let ue=0;for(let be of yt)for(let Te of be.paths||[])if(ws.test(Te))ue++;return ue},[yt]);return y("nav",{className:"st-sidebar"+(A?" is-collapsed":"")+(R?" is-resizing":""),style:A||!E?void 0:{width:E,flexBasis:E},"aria-label":"Files","data-tour":"sidebar",children:[y("div",{className:"st-sb-hd",children:[l("span",{className:"st-sb-title",children:"Files"}),y("div",{className:"st-sb-hd-actions",children:[!e&&l("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":_e&&He==="board",onClick:()=>{ua(""),ht("board"),Ye((ue)=>He==="board"?!ue:!0)},children:l(ga,{name:"plus",size:15})}),!e&&Ze&&l("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":_e&&He==="folder",onClick:()=>{ua(""),ht("folder"),Ye((ue)=>He==="folder"?!ue:!0)},children:l(ga,{name:"folder-plus",size:15})}),k&&l("button",{type:"button",className:"st-iconbtn st-refresh"+(I?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":I||void 0,disabled:I,onClick:()=>k(),children:l(ga,{name:"reload",size:15})}),y("span",{className:"st-live","data-tip":c?"live · file index synced":"reconnecting…",children:[l("span",{className:"st-live-dot"+(c?" is-connected":""),"aria-hidden":"true"}),Ie," / ",Le]}),N&&l("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:N,children:l(ga,{name:"panel-left",size:15})})]})]}),_e?y("div",{className:"st-newboard",children:[l("input",{type:"text",autoFocus:!0,placeholder:He==="folder"?"folder name…":"brief board name…",value:Xt,maxLength:60,disabled:Be,"aria-label":He==="folder"?"New folder name":"New brief board name",onChange:(ue)=>Ne(ue.target.value),onKeyDown:(ue)=>{if(ue.key==="Enter")ue.preventDefault(),he();else if(ue.key==="Escape")ue.preventDefault(),Ye(!1),Ne(""),ua("")}}),l("button",{type:"button",className:"st-newboard-go",disabled:Be||!Xt.trim(),"data-tip":"Create · Enter","aria-label":He==="folder"?"Create folder":"Create brief board",onClick:he,children:Be?"…":"↵"})]}):null,At?l("div",{className:"st-newboard-err",role:"alert",children:At}):null,l("div",{className:"st-search",children:y("div",{className:"st-search-box",children:[l(ga,{name:"search",size:13}),l("input",{type:"search","data-testid":"canvas-search",placeholder:"Search canvases…",value:f,onChange:(ue)=>p(ue.target.value),onKeyDown:(ue)=>{if(ue.key==="Escape")if(ue.preventDefault(),f)p("");else ue.currentTarget.blur()},"aria-label":"Filter files"}),f?l("button",{className:"st-search-clear",onClick:()=>p(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):l(Gn,{children:"/"})]})}),!ye&&l(wbe,{failures:Je,cloud:t}),l(HI,{"aria-label":"Project file tree","data-testid":"canvas-list",children:yt.map((ue)=>{if(!h&&!f&&ue.kind==="runtime")return null;let be=vbe(ue),Te=(ue.paths||[]).filter((Pt)=>ws.test(Pt)).length,tt=be.pill||(be.pillFromDsCount?String(ue.dsFolders?.length||0):null)||(be.pillFromCount?String(Te||ue.paths?.length||0):null),we=ue.tree&&Object.keys(ue.tree).length>0,Ue=ue.label==="Design system",lt=ue.kind==="project";if(!h&&!f&&lt&&Te===0)return null;let le=ZA(ue),We=b[ue.label],xt=!!f||(We===void 0?le:We),Wt=!Ue&&ue.kind==="canvas"&&!e,pa=Wt?rt.dropProps(ue.fullPath,!0):{},Qa=rt.overDir===ue.fullPath;return l(Jf,{className:"st-tree-section",label:be.title,expanded:xt,onToggle:()=>w(ue.label,le),row:y("button",{type:"button",className:"st-tree-sec-hd"+(Qa?" is-drop-target":""),"data-testid":`tree-section-${ue.label.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,onClick:()=>w(ue.label,le),"aria-expanded":xt,"aria-dropeffect":Wt?"move":void 0,title:xt?"Collapse section":"Expand section",...pa,children:[l(ga,{name:"chevron-right",className:"st-chev"+(xt?" is-open":""),size:13}),l("span",{className:"st-sec-name",children:be.title}),tt&&l("span",{className:"st-pill",children:tt})]}),children:xt&&(we?l(Tj,{node:ue.tree,activePath:n,previewPath:r,onOpen:o,onPreview:i,commentsByFile:m,depth:1,kind:ue.kind,showHidden:h,search:f,dsFolders:ue.dsFolders,activeDsName:s,onOpenSystem:Ue?u:void 0,onDelete:Ue||e?void 0:v,dirtyByPath:O,canvasKinds:U,dirPath:ue.fullPath,drag:!Ue&&ue.kind==="canvas"&&!e?rt:void 0,menu:nt,expansion:S}):l("div",{className:"st-tree-empty",children:f?"No matches.":"Empty."}))},ue.label)})}),l(jI,{state:nt.state,onClose:nt.close,rootItems:Se,destinations:qe,onPickDestination:(ue)=>z(kt.path,ue)}),l(K_,{project:H,liveBranch:V,remoteSync:q,onGetLatest:D,projectOnly:ot}),t===null?l(A_,{syncStatus:se,onLinkedHub:Z,onLocalProject:pe,onOpenFile:oe,filesReady:ye}):null,l(O_,{})]})}function $j({shown:e,onExpand:t,onSearch:a}){return l("div",{className:"st-rail"+(e?" is-shown":""),children:y("div",{className:"st-rail-inner",children:[l("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:t,children:l(ga,{name:"panel-left",size:15})}),l("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:a,children:l(ga,{name:"search",size:15})}),l("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:t,children:l(ga,{name:"folder",size:15})})]})})}function Aj({open:e,onClose:t,onStartTour:a}){if(ee(()=>{if(!e)return;function n(r){if(r.key==="Escape")t()}return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,t]),!e)return null;return l("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(n)=>{if(n.target===n.currentTarget)t()},children:y("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[y("header",{className:"help-modal-hd",children:[l("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),y("span",{className:"sku",children:["MAUDE-DEV-SRV / v",Sp]}),a&&l("button",{type:"button",className:"mdcc-tour__back",style:{marginLeft:"auto"},onClick:a,children:"▶ Take the tour"}),l("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:t,children:"×"})]}),y("div",{className:"help-modal-body",children:[y("details",{open:!0,children:[l("summary",{children:"Canvas selection & tools"}),y("ul",{children:[y("li",{children:[l("kbd",{children:"V"})," ",l("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),y("li",{children:[l("kbd",{children:"H"})," ",l("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),y("li",{children:[l("kbd",{children:"C"})," ",l("span",{children:"comment tool — hover paints, click drops a pin"})]}),y("li",{children:[l("kbd",{children:"⌘"})," + hover ",l("span",{children:"preview deepest element under cursor"})]}),y("li",{children:[l("kbd",{children:"⌘"})," + click ",l("span",{children:"select that element (replace)"})]}),y("li",{children:[l("kbd",{children:"⌘⇧"})," + click ",l("span",{children:"add deepest to selection (multi)"})]}),y("li",{children:["right-click ",l("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),y("li",{children:[l("kbd",{children:"Esc"})," in canvas ",l("span",{children:"clear selection + close menu"})]})]})]}),y("details",{children:[l("summary",{children:"Annotation tools"}),y("ul",{children:[y("li",{children:[l("kbd",{children:"B"})," ",l("span",{children:"pen — freehand stroke"})]}),y("li",{children:[l("kbd",{children:"R"})," ",l("span",{children:"rectangle — drag to define corners"})]}),y("li",{children:[l("kbd",{children:"O"})," ",l("span",{children:"ellipse — drag from center outward"})]}),y("li",{children:[l("kbd",{children:"A"})," ",l("span",{children:"arrow — drag tail → tip"})]}),y("li",{children:[l("kbd",{children:"E"})," ",l("span",{children:"eraser — click or drag over strokes to remove"})]}),y("li",{children:[l("kbd",{children:"V"})," + click stroke ",l("span",{children:"select annotation (Shift+click to multi)"})]}),y("li",{children:[l("kbd",{children:"V"})," + drag empty ",l("span",{children:"marquee-select strokes that overlap"})]}),y("li",{children:["double-click rect/ellipse ",l("span",{children:"add text inside the shape"})]}),y("li",{children:["arrow keys ",l("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),y("li",{children:[l("kbd",{children:"Backspace"})," ",l("span",{children:"delete selected annotations"})]}),y("li",{children:[l("kbd",{children:"⇧P"})," ",l("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),y("details",{children:[l("summary",{children:"Canvas & panels"}),y("ul",{children:[y("li",{children:["click in tree ",l("span",{children:"open canvas (replaces the active one)"})]}),y("li",{children:["File ▸ Close canvas ",l("span",{children:"clear the stage"})]}),y("li",{children:[l("kbd",{children:"⌘R"})," ",l("span",{children:"reload canvas"})]}),y("li",{children:[l("kbd",{children:"/"})," ",l("span",{children:"focus search"})]}),y("li",{children:[l("kbd",{children:"⌘⇧M"})," ",l("span",{children:"comments panel"})]}),y("li",{children:[l("kbd",{children:"⌘⇧I"})," ",l("span",{children:"inspector"})]}),y("li",{children:[l("kbd",{children:"?"})," ",l("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),y("details",{children:[l("summary",{children:"Slash commands"}),y("ul",{className:"cmds",children:[y("li",{children:[y("code",{children:['/design:edit "',l("i",{children:"feedback"}),'"']}),l("span",{children:"edit + 4-iter multi-axis loop"})]}),y("li",{children:[y("code",{children:['/design:edit "',l("i",{children:"…"}),'" --perfect']}),l("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),y("li",{children:[y("code",{children:['/design:edit "',l("i",{children:"…"}),'" --no-critic']}),l("span",{children:"raw edit, skip loop"})]}),y("li",{children:[y("code",{children:['/design:edit "',l("i",{children:"…"}),'" --opt-out=',l("i",{children:"scope"})]}),l("span",{children:"override DS scope (palette/aesthetic/full)"})]}),y("li",{children:[y("code",{children:['/design:new "',l("i",{children:"Name"}),'" "',l("i",{children:"brief"}),'"']}),l("span",{children:"scaffold canvas"})]}),y("li",{children:[y("code",{children:['/design:new "',l("i",{children:"…"}),'" --opt-out=aesthetic']}),l("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),y("li",{children:[l("code",{children:"/design:critic"}),l("span",{children:"review panel (routed)"})]}),y("li",{children:[l("code",{children:"/design:critic --all"}),l("span",{children:"10-critic sweep"})]}),y("li",{children:[l("code",{children:"/design:critic --agent signature-moment-critic"}),l("span",{children:"aspiration axis only"})]}),y("li",{children:[l("code",{children:"/design:rollback"}),l("span",{children:"undo last edit"})]}),y("li",{children:[l("code",{children:"/design:screenshot"}),l("span",{children:"capture canvas"})]}),y("li",{children:[l("code",{children:"/design:setup-docs"}),l("span",{children:"refresh README + INDEX"})]}),y("li",{children:[l("code",{children:"/design:handoff"}),l("span",{children:"migrate to apps/"})]})]})]}),y("details",{children:[l("summary",{children:"Opt-out scope"}),y("ul",{children:[y("li",{children:[l("strong",{children:"palette"})," ",l("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),y("li",{children:[l("strong",{children:"aesthetic"})," ",l("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),y("li",{children:[l("strong",{children:"full"})," ",l("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),y("li",{children:[l("em",{children:"A11y enforced at every scope"})," ",l("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),y("li",{children:["Persisted on canvas's ",l("code",{children:".meta.json"})," ",l("code",{children:"opt_out_scope"})," field — subsequent ",l("code",{children:"/design:edit"})," iterations inherit."]}),l("li",{children:'Inferred from brief ("modern", "vibrant", "off-system") with one-shot AskUserQuestion before iter-1 critics fire.'})]})]}),y("details",{children:[l("summary",{children:"Auto-critic loop"}),y("ul",{children:[y("li",{children:[l("strong",{children:"Default"})," ",l("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),y("li",{children:[l("strong",{children:"--perfect"})," ",l("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),y("li",{children:[l("strong",{children:"--perfect --all"})," ",l("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),y("li",{children:["Exit: ",l("code",{children:"solid"})," · ",l("code",{children:"stable-but-bland"})," · ",l("code",{children:"max-reached"})," ","· ",l("code",{children:"divergent"})]}),y("li",{children:[l("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),y("li",{children:["When ",l("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."]})]})]}),y("details",{children:[l("summary",{children:"Pin-to-element flow"}),y("ol",{children:[l("li",{children:"Open a canvas"}),y("li",{children:[l("kbd",{children:"⌘"}),"+click element"]}),l("li",{children:"Status bar shows ● selector"}),y("li",{children:["Run"," ",y("code",{children:['/design:edit "',l("i",{children:"change just this"}),'"']})]}),y("li",{children:["Reload iframe (",l("kbd",{children:"⌘R"}),")"]})]})]}),y("details",{children:[l("summary",{children:"Comments"}),y("ol",{children:[y("li",{children:[l("kbd",{children:"⌘"}),"+click element, then ",l("kbd",{children:"⌘C"})," ",l("span",{children:"or ⌘⇧+click"})]}),l("li",{children:"Numbered pin appears on canvas"}),y("li",{children:[l("kbd",{children:"⌘⇧M"})," ",l("span",{children:"opens panel — All / Open / Resolved"})]}),y("li",{children:["Click row in panel ",l("span",{children:"jumps to that file + pin"})]}),y("li",{children:["Claude reads ",l("code",{children:"_comments/<slug>.json"})," on next ",l("code",{children:"/design"})]})]})]})]})]})})}var oE=[{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 xbe({kbd:e,alt:t}){let a=(n,r)=>l("span",{className:"so-combo",children:n.split(" ").map((s,o)=>l(Gn,{children:s},`${s}-${o}`))},r);return y("span",{className:"so-combos",children:[a(e,"main"),t?t.split(" / ").map((n)=>y(Jn,{children:[l("span",{className:"so-or",children:"/"}),a(n,n)]},n)):null]})}function Ej({open:e,onClose:t}){if(ee(()=>{if(!e)return;function n(r){if(r.key==="Escape")r.preventDefault(),t()}return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,t]),!e)return null;let a=oE.reduce((n,r)=>n+r.items.length,0);return l("div",{className:"st-scrim",role:"presentation",onMouseDown:(n)=>{if(n.target===n.currentTarget)t()},children:y("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[y("div",{className:"so-overlay-hd",children:[l("span",{className:"so-title",children:"Keyboard shortcuts"}),y("span",{className:"so-trigger",children:["press ",l(Gn,{children:"?"})," to open"]})]}),l("div",{className:"so-columns",children:oE.map((n)=>y("section",{className:"so-section so-section--"+n.id,children:[l("h3",{className:"so-section-hd",children:n.label}),l("dl",{className:"so-list",children:n.items.map((r)=>y("div",{className:"so-pair",children:[l("dt",{children:r.label}),l("dd",{children:l(xbe,{kbd:r.kbd,alt:r.alt})})]},r.label))})]},n.id))}),y("div",{className:"so-overlay-ft",children:[y("span",{children:["close with ",l(Gn,{children:"Esc"})]}),y("span",{className:"so-count",children:[a," bindings · ",oE.length," groups"]})]})]})})}var _be=["File","Edit","View","Selection","Tools","Help"];function Nj(e){ee(()=>{function t(n){if(n.key==="Escape")e()}function a(n){if(!n.target.closest(".st-dropdown, .st-menu"))e()}return window.addEventListener("keydown",t),window.addEventListener("mousedown",a),()=>{window.removeEventListener("keydown",t),window.removeEventListener("mousedown",a)}},[e])}function Sbe({panels:e,onToggle:t,onClose:a,onZoom:n,hasCanvas:r}){return Nj(a),y("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[l("div",{className:"st-dd-hd",children:"Panels"}),e.map((s)=>y("button",{type:"button",role:"menuitem",className:"st-dd-item"+(s.checked?" is-on":""),"aria-disabled":s.disabled?"true":void 0,title:s.hint||void 0,onClick:()=>{if(s.disabled){if(s.href)window.open(s.href,"_blank","noopener,noreferrer"),a();return}t(s.id),a()},children:[y("span",{className:"st-dd-lead",children:[l("span",{className:"st-dd-check",children:s.checked?l(ga,{name:"check",size:13}):null}),l("span",{children:s.label}),s.phase?l("span",{className:"st-dd-phase",children:s.phase}):null]}),s.shortcut?l(Gn,{children:s.shortcut}):null]},s.id)),l("div",{className:"st-dd-sep"}),l("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((s)=>y("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":r?void 0:"true",onClick:()=>{if(!r)return;n?.(s.op),a()},children:[y("span",{className:"st-dd-lead",children:[l("span",{className:"st-dd-check"}),l("span",{children:s.label})]}),l(Gn,{children:s.shortcut})]},s.label))]})}function Xh({label:e,left:t,header:a,items:n,onAction:r,onClose:s}){return Nj(s),y("div",{className:"st-dropdown",role:"menu","aria-label":e,style:{left:t},children:[a?l("div",{className:"st-dd-hd",children:a}):null,n.map((o,i)=>o.sep?l("div",{className:"st-dd-sep"},"s"+i):y("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":o.disabled?"true":void 0,onClick:()=>{if(o.disabled)return;r(o.id),s()},children:[y("span",{className:"st-dd-lead",children:[l("span",{className:"st-dd-check"}),l("span",{children:o.label})]}),o.shortcut?l(Gn,{children:o.shortcut}):null]},o.id))]})}function Cbe({onAction:e,onClose:t}){return l(Xh,{label:"Help",left:320,onAction:e,onClose:t,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"},...na()?[{id:"collab-tour",label:"How sharing works"}]:[],...na()?[{id:"quick-setup",label:"Quick setup"}]:[],...na()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function kbe({onAction:e,onClose:t,readOnly:a=!1}){return l(Xh,{label:"Selection",left:214,onAction:e,onClose:t,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},...a?[]:[{id:"select-all-annotations",label:"Select all annotations",shortcut:"⌘ ⇧ A"}]]})}function Ibe({onAction:e,onClose:t,readOnly:a=!1}){let n=[{id:"browse",label:"Browse (interact)",shortcut:""},{id:"move",label:"Select",shortcut:"V"},{id:"hand",label:"Hand",shortcut:"H"},...a?[]:[{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 l(Xh,{label:"Tools",left:290,header:"Tool palette",onAction:e,onClose:t,items:n})}function Tbe({onAction:e,onClose:t,hasCanvas:a,hasSharePath:n,readOnly:r=!1}){return l(Xh,{label:"File",left:40,onAction:e,onClose:t,items:r?[{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"share",label:"Share link…",disabled:!n},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!a},{id:"close",label:"Close canvas",disabled:!a}]:[{id:"new",label:"New canvas…",shortcut:"N"},{id:"assemble",label:"Assemble dropped clips → video",disabled:!a},{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"share",label:"Share link…",disabled:!n},{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:!a},{id:"close",label:"Close canvas",disabled:!a}]})}function $be({onAction:e,onClose:t,hasCanvas:a,readOnly:n=!1}){if(n)return l(Xh,{label:"Edit",left:90,onAction:e,onClose:t,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"}]});return l(Xh,{label:"Edit",left:90,onAction:e,onClose:t,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"},...a?[{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 Lj({activePath:e,sharePath:t,onShare:a,project:n,cloud:r,tabsCount:s,openMenu:o,setOpenMenu:i,commentsPanelOpen:u,onToggleComments:c,changesOpen:f,changesCount:p,onToggleChanges:m,onOpenSystem:h,sidebarOpen:b,onToggleSidebar:w,showHidden:S,onToggleShowHidden:_,onOpenHelp:v,onOpenShortcuts:k,onReportBug:I,onStartTour:A,onStartCollabTour:N,annotationsVisible:E,onToggleAnnotations:R,minimapVisible:O,onToggleMinimap:H,zoomCtlVisible:V,onToggleZoomCtl:q,presentMode:D,onTogglePresent:U,printGuidesVisible:z,onTogglePrintGuides:M,postToActiveCanvas:F,onOpenWhatsNew:X,onOpenReadiness:K,onOpenQuickSetup:ie,onWatchIntro:G,whatsNewCount:se,exportCenter:Z,artboardCount:pe=0,presence:oe=null,inspectorOpen:ye,inspectorTab:Je,onToggleInspector:Ke,autoOpenInspector:ot,onToggleAutoOpenInspector:yt,onOpenLayers:rt,timelineOpen:nt,onToggleTimeline:bt,hasComps:kt=!1,assistantOpen:Se,onToggleAssistant:qe,assistantBusy:_e,assistantUnseen:Ye,onNewCanvas:He,onAssembleVideo:ht,onOpenExport:Xt,onOpenSettings:Ne,onOpenGenerate:At,onReload:ua,onCloseCanvas:Be,onInsertArtboard:fe,readOnly:Ze=!1}){let he=e===Ft,Le=he?"SYSTEM":e?"CANVAS":"IDLE",Ie=he?l("b",{children:"design system"}):e?y(te,{children:[e.split("/").slice(0,-1).join("/"),"/",l("b",{children:xs(us(e))})]}):l("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),ue=new Set(r?["autoopen"]:["assistant","autoopen"]),be=[{id:"tree",label:"Project Tree",shortcut:"T",checked:b,disabled:!1},{id:"changes",label:r?"History":p>0?`Changes · ${p} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:f,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:u,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:S,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:ye&&Je==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:ye,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!ot,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:kt?"video":void 0,checked:nt,disabled:!1},...na()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:Se,disabled:!1}]:r?[{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:E,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:O,disabled:!e||he},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:V,disabled:!e||he},{id:"present",label:"Presentation Mode",shortcut:"",checked:D,disabled:!e||he},{id:"print-guides",label:"Show print guides",shortcut:"",checked:z,disabled:!e||he}].filter((we)=>!Ze||!ue.has(we.id)),Te=["file","edit","view","selection","tools","help"];function tt(we){if(Te.includes(we))i(o===we?null:we)}return ee(()=>{if(!o||!Te.includes(o))return;let we=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function Ue(lt){let le=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!le.length)return;let We=le.indexOf(document.activeElement);if(lt.key==="ArrowDown")lt.preventDefault(),le[(We+1)%le.length].focus();else if(lt.key==="ArrowUp")lt.preventDefault(),le[(We-1+le.length)%le.length].focus();else if(lt.key==="Home")lt.preventDefault(),le[0].focus();else if(lt.key==="End")lt.preventDefault(),le[le.length-1].focus();else if(lt.key==="ArrowRight"||lt.key==="ArrowLeft"){lt.preventDefault();let xt=lt.key==="ArrowRight"?1:-1,Wt=Te.indexOf(o);i(Te[(Wt+xt+Te.length)%Te.length])}else if(lt.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",Ue),()=>{clearTimeout(we),window.removeEventListener("keydown",Ue)}},[o,i]),y("header",{className:"st-menubar","aria-label":"Application menubar","data-testid":"menubar",children:[y("span",{className:"st-brand","data-tour":"brand",children:[l("span",{className:"st-brand-mark",children:l("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:l("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),l("span",{className:"st-brand-name",children:"maude"})]}),r?y("span",{className:"st-cloudback","data-testid":"cloud-back",children:[r.dashboardUrl?l("a",{className:"st-cloudback-link",href:r.dashboardUrl,title:"Back to your projects",children:"← Dashboard"}):null,r.projectName?l("span",{className:"st-cloudback-project","data-testid":"cloud-project-name",children:r.projectName}):null]}):null,l("nav",{className:"st-menus",role:"menubar","aria-label":"Application menus","data-tour":"menus",children:_be.map((we)=>{let Ue=we.toLowerCase(),lt=Te.includes(Ue),le=lt||Ue==="help",We=o===Ue;return l("button",{type:"button",className:"st-menu",role:"menuitem","data-testid":`menu-${Ue}`,"data-tour":Ue==="help"?"help":void 0,"aria-haspopup":lt?"menu":void 0,"aria-expanded":lt?We:void 0,onClick:()=>tt(Ue),onMouseEnter:()=>{if(o!==null&&lt)i(Ue)},children:we},Ue)})}),o==="file"&&l(Tbe,{readOnly:Ze,hasCanvas:!!e,hasSharePath:!!t,onAction:(we)=>{if(we==="new")He?.();else if(we==="assemble")ht?.();else if(we==="export")Xt?.("export");else if(we==="share")document.querySelector('[data-testid="menu-file"]')?.focus(),a?.();else if(we==="handoff")Xt?.("handoff");else if(we==="generate")At?.();else if(we==="settings")Ne?.();else if(we==="reload")ua?.();else if(we==="close")Be?.()},onClose:()=>i(null)}),o==="edit"&&l($be,{readOnly:Ze,hasCanvas:!!e&&!he,onAction:(we)=>{if(we==="undo")F({dgn:"undo"});else if(we==="redo")F({dgn:"redo"});else if(we==="deselect-all")F({dgn:"selection-clear"});else if(we==="select-all-annotations")F({dgn:"annotation-select-all"});else if(we.startsWith("new-artboard:"))fe?.(we.slice(13))},onClose:()=>i(null)}),o==="view"&&l(Sbe,{panels:be,onToggle:(we)=>{if(we==="tree")w();else if(we==="changes")m();else if(we==="comments")c();else if(we==="hidden")_();else if(we==="annotate")R();else if(we==="inspector")Ke();else if(we==="autoopen")yt?.();else if(we==="timeline")bt?.();else if(we==="assistant")qe?.();else if(we==="layers")rt?.();else if(we==="minimap")H?.();else if(we==="zoomctl")q?.();else if(we==="present")U?.();else if(we==="print-guides")M?.()},onZoom:(we)=>F({dgn:"zoom",op:we}),hasCanvas:!!e&&!he,onClose:()=>i(null)}),o==="selection"&&l(kbe,{readOnly:Ze,onAction:(we)=>{if(we==="deselect-all")F({dgn:"selection-clear"});else if(we==="select-all-annotations")F({dgn:"annotation-select-all"})},onClose:()=>i(null)}),o==="tools"&&l(Ibe,{readOnly:Ze,onAction:(we)=>F({dgn:"tool-set",tool:we}),onClose:()=>i(null)}),o==="help"&&l(Cbe,{onAction:(we)=>{if(we==="shortcuts")k?.();else if(we==="help")v?.();else if(we==="report-bug")I?.();else if(we==="tour")A?.();else if(we==="collab-tour")N?.();else if(we==="quick-setup")ie?.();else if(we==="readiness")K?.();else if(we==="whatsnew")X?.();else if(we==="watch-intro")G?.()},onClose:()=>i(null)}),y("div",{className:"st-mb-right","data-tour":"status",children:[oe?l("div",{className:"st-presence",children:oe}):null,Ze&&l("span",{className:"st-stamp st-stamp--viewonly","data-testid":"view-only-stamp","data-tip":r?.user?`${r.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"}),r?.user?y("span",{className:"st-cloudwho","data-testid":"cloud-account",children:[l("span",{className:"st-cloudwho-email",title:r.role?`Signed in as ${r.user} — ${r.role}`:r.user,children:r.user}),l("form",{method:"post",action:"/auth/browser/signout",className:"st-cloudwho-form",children:l("button",{type:"submit",className:"st-cloudwho-out","data-testid":"cloud-signout",title:"Sign out of this project",children:"Sign out"})})]}):null,na()&&!Ze&&l("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":Se?"true":"false","data-busy":_e?"true":"false","data-unseen":Ye?"true":"false","aria-label":`Assistant${_e?" — working":Ye?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:qe,children:l(ga,{name:"sparkle",size:15})}),l("button",{type:"button",className:"st-mb-icon st-share-btn","data-testid":"share-btn","data-tip":t?"Share link":"Open a canvas to share it","aria-label":"Share link",disabled:!t,onClick:a,children:l(ga,{name:"share",size:15})}),Z&&l(DA,{center:Z}),l("button",{type:"button",className:"st-reportbug","data-testid":"report-bug-toggle","aria-label":"Report a bug","data-tip":"Report a bug",onClick:I,children:l(ga,{name:"bug",size:15})}),l("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":se>0?"true":"false","aria-label":`What's new${se>0?` — ${se} unseen`:""}`,"data-tip":"What's new",onClick:X,children:l(ga,{name:"megaphone",size:15})}),l("span",{className:"st-stamp",children:Le}),l("span",{className:"st-mb-file",title:e||"",children:Ie}),l("span",{className:"st-mb-sep"}),y("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[l("span",{className:"st-dot",style:{background:"var(--accent)"}}),pe," ARTBOARDS"]}),l("span",{className:"st-mb-sep"}),l("span",{className:"st-mb-proj",children:n||"maude"})]})]})}var Abe=["color","space","radius","shadow","leading","weight","motion","font","other"],Ebe={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function Nbe(e){return e==="color"}function Lbe({tokens:e,tokenGroups:t,tokensPath:a}){if(!e||e.length===0)return y("section",{className:"sv-section sv-section-tokens",children:[y("h2",{children:["tokens",l("span",{className:"sv-h-num",children:"0"})]}),l("div",{className:"sv-empty",children:y("p",{children:["No tokens parsed from"," ",a?l("code",{children:a}):"the configured tokens file",". Does the file exist and contain CSS custom properties (",l("code",{children:"--name: value;"}),")?"]})})]});let n=t||{},r=Array.from(new Set([...Abe,...Object.keys(n)])).filter((s)=>n[s]?.length);return l(te,{children:r.map((s)=>{let o=n[s],i=Nbe(s);return y("section",{className:"sv-section sv-section-tokens sv-section-"+s,children:[y("h2",{children:["tokens · ",Ebe[s]||s,l("span",{className:"sv-h-num",children:o.length})]}),l("div",{className:"sv-tokens-ladder",children:o.map((u)=>y("div",{className:"sv-tok-cell",children:[i?l("div",{className:"sv-tok-swatch",style:{background:u.value}}):null,y("div",{className:"sv-tok-meta",children:[l("code",{className:"sv-tok-name",children:u.name}),l("span",{className:"sv-tok-value",children:u.value||"—"})]})]},u.name+"|"+u.value))})]},s)})})}function Mbe(e,t){let a=e.name.match(/^--(?:type|fs|text)-(.+)$/);if(!a)return null;let n=a[1];return(t||[]).find((r)=>/^--(?:lh|leading|line-height)-/.test(r.name)&&r.name.endsWith("-"+n))?.value??null}function Rbe(e){if(!e?.length)return;let t=["body","sans","display","text","family"];for(let a of t){let n=e.find((r)=>r.name.includes(a));if(n)return n.value}return e[0].value}function Obe({tokenGroups:e}){let t=e?.fontsize||[];if(t.length===0)return null;let a=e?.leading||[],n=Rbe(e?.font);return y("section",{className:"sv-section sv-section-type",children:[y("h2",{children:["type · ladder",l("span",{className:"sv-h-num",children:t.length})]}),l("div",{className:"sv-type-list",children:t.map((r)=>{let s=Mbe(r,a),o={fontSize:r.value};if(s)o.lineHeight=s;if(n)o.fontFamily=n;return y("div",{className:"sv-type-row",children:[l("code",{className:"sv-type-tok",children:r.name}),l("span",{className:"sv-type-sample",style:o,children:"The catalog is the system."})]},r.name)})})]})}function iE({data:e,onOpen:t,cfg:a,onSelectDs:n}){if(!e)return l("div",{className:"sv-empty",children:l("p",{children:"Loading design system…"})});let{previewGallery:r,uiKitsGallery:s,systemDir:o,tokens:i,tokenGroups:u,tokensPath:c,ds:f,availableDesignSystems:p}=e,m=(!r||!r.length)&&(!s||!s.length),h=Array.isArray(p)&&p.length>1,b=f?.name??p?.[0]?.name??"";return y("div",{className:"sv",children:[y("header",{className:"sv-header",children:[l("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),l("span",{className:"sv-title",children:"design system view"}),h?y("label",{className:"sv-ds-picker",children:[l("span",{className:"sv-ds-picker-label",children:"DS"}),l("select",{value:b,onChange:(w)=>n&&n(w.target.value),children:p.map((w)=>l("option",{value:w.name,children:w.name},w.name))})]}):null,l("span",{className:"sv-loc",children:l("code",{children:o})})]}),f?.description?l("p",{className:"sv-ds-description",children:f.description}):null,l(Lbe,{tokens:i,tokenGroups:u,tokensPath:c}),l(Obe,{tokenGroups:u}),m?l("div",{className:"sv-empty",children:y("p",{children:["No ",l("code",{children:"preview/"})," or ",l("code",{children:"ui_kits/"})," folders found under"," ",l("code",{children:o}),"."]})}):y(te,{children:[l(Mj,{title:"preview",items:r,onOpen:t,kind:"preview",cfg:a}),l(Mj,{title:"ui kits",items:s,onOpen:t,kind:"ui_kits",cfg:a})]})]})}function Mj({title:e,items:t,onOpen:a,kind:n,cfg:r}){if(!t||t.length===0)return null;return y("section",{className:"sv-section",children:[y("h2",{children:[e," ",l("span",{className:"sv-count",children:t.length})]}),l("div",{className:"sv-previews sv-previews-"+n,children:t.map((s)=>y("article",{className:"sv-preview-card",onClick:()=>a(s.path),children:[l("div",{className:"sv-preview-frame",children:l("iframe",{src:Qi(s.path,r,{thumbnail:!0}),title:s.label,scrolling:"no",...r?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),y("div",{className:"sv-preview-foot",children:[l("strong",{children:s.label}),l("code",{children:s.path})]})]},s.path))})]})}function Rj({tabs:e,activePath:t,registerIframe:a,systemData:n,onOpenFromSystem:r,onSelectDs:s,project:o,cfg:i,loadingPath:u,onIframeLoad:c,canvasError:f,canvasReloadNonce:p,onRetryCanvasLoad:m,loadedPath:h,showQuickSetup:b,onStartQuickSetup:w,previewPath:S}){let _=me(null);ee(()=>{if(S)_.current?.focus()},[S]);let v=me(new Map),k=new Set(e.map((N)=>N.path));for(let[N,E]of v.current)if(!k.has(E.path))v.current.delete(N);let I=(N)=>{let E=Qi(N,{...i,canvasToken:void 0}),R=`${N}#${p}|${E}`,O=v.current.get(R);if(!O)O={path:N,src:Qi(N,i)},v.current.set(R,O);return O.src},A=f&&f.path===t?"error":t&&t!==Ft&&h===t?"ready":u&&u===t?"loading":"idle";return y("div",{className:"viewport st-stage","data-tour":"viewport","data-canvas-state":A,children:[S&&l("div",{ref:_,className:"st-file-preview-overlay",role:"region","aria-label":`Preview: ${gp(us(S))}`,tabIndex:0,children:l(Z3,{path:S,kind:$d(us(S))})}),e.length===0&&!S&&y("div",{className:"st-empty",children:[y("div",{className:"st-empty-brand",children:[l("span",{className:"st-brand-mark",children:l("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:l("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),l("span",{className:"st-empty-wm",children:"maude"}),y("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(o||"MAUDE").toUpperCase()," / v",Sp," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),l("div",{className:"st-empty-title",children:"Nothing open yet"}),y("div",{className:"st-empty-body",children:["← Pick a screen from the list on the left, or open ",l("strong",{children:"Design system"})," above it to see your colors, type, and components.",l("br",{}),l("br",{}),l("strong",{children:"To select something on the canvas:"})," hold ",l(Gn,{children:"⌘"})," and hover to preview an element, click to select it — ",l(Gn,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",na()?y(te,{children:[l("br",{}),l("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]}),b&&l("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:w,children:"Start quick setup"})]}),e.map((N)=>{if(N.path===Ft)return l("div",{className:"system-view"+(N.path===t?" active":""),children:l(iE,{data:n,onOpen:r,cfg:i,onSelectDs:s})},N.path);return l("iframe",{ref:(E)=>a(N.path,E),src:I(N.path),title:`Canvas: ${N.path}`,className:N.path===t?"active":"","data-path":N.path,"data-testid":N.path===t?"canvas-frame":void 0,onLoad:()=>c?.(N.path),...i?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},`${N.path}#${p}`)}),u&&u===t&&l(Dbe,{path:u,cloud:!!i?.cloud},u),f&&f.path===t&&l("div",{className:"st-canvas-error",role:"alert","data-testid":"canvas-load-error",children:y("div",{className:"st-canvas-error-card",children:[l("div",{className:"st-canvas-error-title",children:f.kind==="server"?"Maude's server isn't responding":"This canvas didn't finish loading"}),l("div",{className:"st-canvas-error-body",children:f.kind==="server"?l(te,{children:"The canvas couldn't be reached. This usually means Maude's server restarted underneath this window — your files on disk are untouched."}):y(te,{children:["The server is up, but"," ",l("code",{children:gp(us(f.path))})," ","never finished compiling. Its own error, if it has one, is in the canvas frame."]})}),l("button",{type:"button",className:"btn btn--primary","data-testid":"canvas-load-retry",onClick:()=>m?.(f.path),children:"Reload canvas"})]})})]})}function Dbe({path:e,cloud:t}){let[a,n]=P(!1);ee(()=>{let s=setTimeout(()=>n(!0),4000);return()=>clearTimeout(s)},[]);let r=gp(us(e||"").replace(/\.(tsx|jsx|html?)$/i,""));return l("div",{className:"st-canvas-loading",role:"status","aria-live":"polite","data-testid":"canvas-loading",children:y("div",{className:"st-skel-card",children:[y("div",{className:"st-canvas-loading-head",children:[l("span",{className:"st-canvas-loading-spinner","aria-hidden":"true"}),y("span",{className:"st-canvas-loading-title",children:["Opening ",r,"…"]})]}),l("span",{className:"skel st-skel-thumb","aria-hidden":"true"}),l("span",{className:"skel st-skel-line",style:{width:"72%"},"aria-hidden":"true"}),l("span",{className:"skel st-skel-line",style:{width:"46%"},"aria-hidden":"true"}),l("div",{className:"st-canvas-loading-hint"+(a?" is-shown":""),children:t?"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."})]})})}function Oj({activePath:e,selected:t,wsConnected:a,openCount:n,theme:r,onToggleTheme:s,onClearSelected:o,syncStatus:i,syncProject:u,syncOpen:c=!1,onOpenSync:f,changesCount:p=0,unpushed:m=0,savingIsManaged:h=!1,changesOpen:b=!1,onOpenChanges:w,version:S}){let _=e===Ft,v=t&&t.selector?t.selector+(t.text?` — "${t.text.slice(0,60)}"`:""):"",k=t&&t.dom_path?t.dom_path.join(" > "):t?t.selector:"",I=r==="dark"?"light":"dark",A=(()=>{let E=Zf(i,{project:u});if(!E)return null;let R=E.names.length?` (${E.names.join(", ")})`:"";return{online:E.online,phase:E.phase,label:E.label,title:`${E.title}${R}${E.next?` — ${E.next}`:""}`}})(),N=A&&y(te,{children:[l("span",{className:"st-sb-sync-dot"+(A.online?" is-online":""),"aria-hidden":"true"}),l("span",{className:"lbl",children:"hub sync"}),l("span",{className:"val",title:A.title,"data-testid":"statusbar-sync","data-phase":A.phase,children:A.label})]});return y("footer",{className:"st-statusbar",role:"contentinfo","data-testid":"statusbar",children:[y("span",{className:"st-sb-slot st-sb-active",role:"group","aria-label":"Active file",children:[l("span",{className:"lead","aria-hidden":"true"}),l("span",{className:"lbl",children:"active"}),l("span",{className:"val",title:e||"",children:_?"▦ design system":e||"—"})]}),e&&t&&t.selector&&!_&&y("span",{className:"st-sb-slot st-sb-sel",role:"group","aria-label":"Selected element",children:[l("span",{className:"lbl",children:"selected"}),l("span",{className:"val",title:k,children:v}),l("button",{type:"button",className:"st-sb-sel-clear",onClick:o,"data-tip":"Clear · Esc inside iframe","data-tip-pos":"top","aria-label":"Clear selection",children:"×"})]}),y("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[l("span",{className:"lbl",children:"comments"}),y("span",{className:"val",children:[n," open"]})]}),w&&y("button",{type:"button",className:"st-sb-slot st-sb-changes"+(b?" is-open":"")+(p>0?" has-changes":m>0?" has-unpushed":""),onClick:w,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":b,children:[l("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),l("span",{className:"lbl",children:"changes"}),l("span",{className:"val",children:h?"cloud saving":p>0?`${p} unsaved`:m>0?`${m} to publish`:"all saved"})]}),l("span",{className:"st-sb-spacer"}),y("span",{className:"st-sb-slot",role:"group","aria-label":"Connection",children:[l("span",{className:"st-live-dot"+(a?" is-connected":""),"aria-hidden":"true"}),l("span",{className:"lbl",children:a?"live":"reconnecting"})]}),A&&(f?l("button",{type:"button",className:"st-sb-slot st-sb-sync st-sb-sync--btn"+(c?" is-open":""),onClick:f,"data-testid":"open-sync","data-tip":"Open Sync panel","data-tip-pos":"top","aria-label":"Open Sync panel","aria-pressed":c,children:N}):l("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:N})),S&&l("span",{className:"st-sb-slot st-sb-version",role:"group","aria-label":"Maude version",children:y("span",{className:"val","data-testid":"statusbar-version",children:["v",S]})}),y("button",{type:"button",className:"st-sb-theme",onClick:s,"data-tip":`Switch to ${I} theme`,"data-tip-pos":"top","aria-label":`Switch to ${I} theme`,children:[l(ga,{name:r==="dark"?"sun":"moon",size:13}),I]})]})}function lE({commentsByFile:e,filter:t,setFilter:a,activePath:n,focusedId:r,onJump:s,onResolve:o,onReopen:i,onDelete:u,width:c,resizing:f}){let p=Gv(e),m=Object.keys(e||{}).sort(),h=[];for(let b of m){let w=e[b]||[],S=w.filter((v)=>{if(t==="open")return v.status!=="resolved";if(t==="resolved")return v.status==="resolved";return!0});if(S.length===0)continue;let _=w.filter((v)=>v.selector);h.push({file:b,comments:S.map((v)=>({...v,n:_.findIndex((k)=>k.id===v.id)+1}))})}return y("aside",{className:"st-rpanel"+(f?" is-resizing":""),style:c?{width:c,flexBasis:c}:void 0,"aria-label":"Comments",children:[l("div",{className:"st-rp-tabs st-rp-tabs--filters",children:y("div",{className:"st-cm-filters",role:"tablist",children:[y("button",{type:"button",className:"st-cm-filter"+(t==="all"?" is-active":""),role:"tab","data-testid":"comment-filter-all","aria-selected":t==="all",onClick:()=>a("all"),children:["All · ",p.all]}),y("button",{type:"button",className:"st-cm-filter"+(t==="open"?" is-active":""),role:"tab","data-testid":"comment-filter-open","aria-selected":t==="open",onClick:()=>a("open"),children:["Open · ",p.open]}),y("button",{type:"button",className:"st-cm-filter"+(t==="resolved"?" is-active":""),role:"tab","data-testid":"comment-filter-resolved","aria-selected":t==="resolved",onClick:()=>a("resolved"),children:["Resolved · ",p.resolved]})]})}),l("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:h.length===0?y("div",{className:"st-rp-empty",children:[y("p",{children:["No comments ",t!=="all"?`with status “${t}”`:"yet","."]}),y("p",{children:["Open a canvas, hold ",l(Gn,{children:"⌘"})," and click an element, then press ",l(Gn,{children:"C"})," — or hold ",l(Gn,{children:"⌘⇧"})," and click directly."]})]}):h.map((b)=>y(Jn,{children:[y("button",{type:"button",className:"st-cm-group-hd",onClick:()=>s(b.file,null),title:b.file,children:[l("span",{children:xs(us(b.file))}),l("span",{className:"st-mono",children:b.comments.length})]}),b.comments.map((w)=>y("div",{"data-testid":`comment-item-${w.id}`,className:"st-comment"+(w.status==="resolved"?" is-resolved":"")+(w.id===r?" is-active":""),onClick:()=>s(b.file,w.id),children:[y("div",{className:"st-comment-hd",children:[l("span",{className:"st-pin st-pin--inline",children:w.n||"·"}),l("span",{className:"st-comment-time",children:eE(w.created)})]}),l("div",{className:"st-comment-txt",children:w.text}),y("div",{className:"st-comment-foot",children:[l("span",{className:"st-comment-sel",title:(w.dom_path||[]).join(" > "),children:w.selector||"—"}),o&&i&&u?y("span",{className:"st-mini-act",children:[w.status==="resolved"?l("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(S)=>{S.stopPropagation(),i(w.id)},children:l(ga,{name:"reopen",size:14})}):l("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(S)=>{S.stopPropagation(),o(w.id)},children:l(ga,{name:"resolve",size:14})}),l("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(S)=>{S.stopPropagation(),u(w.id)},children:l(ga,{name:"x",size:14})})]}):null]})]},w.id))]},b.file))})]})}var Pbe={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 Dj({cloud:e}){let t=e?.role||null,[a,n]=P(!1);if(!t||a)return null;let r=`maude-cloud-role-seen:${t}`,s=!1;try{s=localStorage.getItem(r)==="1"}catch{}if(s)return null;let o=Pbe[t];if(!o)return null;return y("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info","data-testid":"cloud-role-banner",children:[l("span",{className:"st-banner-dot","aria-hidden":"true"}),l("span",{children:o}),l("button",{type:"button",className:"btn btn--ghost btn--sm","data-testid":"cloud-role-banner-dismiss",onClick:()=>{n(!0);try{localStorage.setItem(r,"1")}catch{}},children:"Got it"})]})}var Zh={newer:"This project now uses Maude 2. It's open here to look at — nothing in it is lost.",action:"Update Maude to edit",noBuild:"This project now uses Maude 2, which isn't out yet. It stays open here to look at.",cloud:"This project now uses Maude 2. It's open here to look at."},zbe="https://maude.sh/download";function Bbe({cfg:e,native:t,updateReady:a,askedForUpdate:n}){let r=e?.formatGate;if(!r||!(r.projectFormat>r.supported))return null;if(e?.cloud)return{line:Zh.cloud,action:null};if(t){if(a)return{line:Zh.newer,action:"restart"};if(n)return{line:Zh.noBuild,action:null};return{line:Zh.newer,action:"check"}}return{line:Zh.newer,action:"download"}}function Pj({cfg:e,updateReady:t}){let[a,n]=P(!1),[r,s]=P(!1),o=Bbe({cfg:e,native:na(),updateReady:t,askedForUpdate:a});if(!o)return null;let i=()=>{if(o.action==="restart")s(!0),h_().catch(()=>s(!1));else if(o.action==="check")n(!0);else if(o.action==="download")window.open(zbe,"_blank","noopener,noreferrer")};return y("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info","data-testid":"format-gate-banner",children:[l("span",{className:"st-banner-dot","aria-hidden":"true"}),l("span",{children:o.line}),o.action&&l("button",{type:"button",className:"btn btn--primary btn--sm","data-testid":"format-gate-update",disabled:r,onClick:i,children:r?"Restarting…":Zh.action})]})}function zj({update:e,onDismiss:t}){let[a,n]=P(!1);if(!e)return null;let r=e.version?` (v${e.version})`:"";return y("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[l("span",{className:"st-banner-dot","aria-hidden":"true"}),y("span",{children:["Maude updated",r," · restart to apply"]}),l("button",{type:"button",className:"btn btn--primary btn--sm",disabled:a,onClick:()=>{n(!0),h_().catch(()=>n(!1))},children:a?"Restarting…":"Restart now"}),l("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:t,children:"Later"})]})}function Bj({status:e}){let[t,a]=P(null);if(!e||e.linked===!1)return null;if(e.notSyncable)return null;let{state:n,queuedOps:r,flash:s,conflicts:o}=e,i=s==="synced",u=n==="offline"||n==="offline-long",c=e.docs?.rejected??0,f=Array.isArray(o)?[...o].reverse().find((b)=>b.kind==="cold-start-diverged"):null;if(!u&&!i&&!f&&c===0)return null;let p,m,h;if(i)p="success",m="Synced with hub",h=`${n}:flash`;else if(u){let b=o&&o.length>0?` (${o.length} conflict notice(s))`:"";if(n==="offline-long")p="error",m=`Long offline — ${r} edit(s) queued. Consider \`git commit && git push\` as backup.${b}`;else p="warn",m=`Working offline · ${r} edit(s) queued · will sync when the hub reconnects.${b}`;h=`${n}:offline`}else if(f){if(f.snapshotFailed)p="error",m=`Diverged on ${f.slug}: kept local — the history snapshot FAILED, so the overwrite was refused. Check disk space / .design/_history write access.`;else p="warn",m=`Diverged on ${f.slug}: kept the ${f.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${f.slug}`;h=`diverged:${f.slug}:${f.at}`}else p="warn",m=`${c} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,h=`rejected:${c}`;if(t===h)return null;return y("div",{role:"status","aria-live":"polite",className:`st-banner st-banner--${p}`,children:[l("span",{className:"st-banner-dot","aria-hidden":"true"}),l("span",{children:m}),l("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>a(h),children:"×"})]})}var uE=["block","inline-block","flex","inline-flex","grid","inline","none"],c2=["px","%","fr","em","auto","min-content","max-content"];var cE=["auto","stretch","flex-start","center","flex-end","baseline"];var d2=["300","400","500","600","700","800"],Ip=(e,t)=>e&&Object.hasOwn(e,"previous")?e.previous:t,f2=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],p2=["none","solid","dashed","dotted","double"],m2=["px","rem","em","%","vw","vh","auto"],h2=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),Kv={"font-size":{node:l(sn,{as:sv,size:12})},"line-height":{node:l(sn,{as:fv,size:12})},"letter-spacing":{node:l(sn,{as:xv,size:12})},gap:{node:l(sn,{as:yp,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:l(sn,{as:Iv,size:12})},"border-width":{node:l(sn,{as:wv,size:12})}};var g2=["static","relative","absolute","fixed","sticky"],dE=["normal","italic","oblique"],y2=["none","uppercase","lowercase","capitalize"];var b2=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],fE=["fill","contain","cover","none","scale-down"];var v2=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],w2=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],Os={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}};var Yh=null;function Ad(e){if(!e)return"";if(/^#[0-9a-f]{6}$/i.test(e))return e.toLowerCase();try{if(!Yh)Yh=document.createElement("canvas").getContext("2d");if(!Yh)return"";Yh.fillStyle="#000000",Yh.fillStyle=e;let t=Yh.fillStyle;if(/^#[0-9a-f]{6}$/i.test(t))return t.toLowerCase();let a=t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(a)return`#${[a[1],a[2],a[3]].map((n)=>Number(n).toString(16).padStart(2,"0")).join("")}`}catch{}return""}var el=(e)=>Math.min(1,Math.max(0,e));function Jh(e){let t=/^#?([0-9a-f]{6})$/i.exec(e||"");if(!t)return{r:0,g:0,b:0};let a=Number.parseInt(t[1],16);return{r:a>>16&255,g:a>>8&255,b:a&255}}function Tp({r:e,g:t,b:a}){return`#${[e,t,a].map((n)=>Math.round(n).toString(16).padStart(2,"0")).join("")}`}function $p({r:e,g:t,b:a}){e/=255,t/=255,a/=255;let n=Math.max(e,t,a),r=Math.min(e,t,a),s=n-r,o=0;if(s){if(n===e)o=(t-a)/s%6;else if(n===t)o=(a-e)/s+2;else o=(e-t)/s+4;if(o*=60,o<0)o+=360}return{h:o,s:n?s/n:0,v:n}}function Ed({h:e,s:t,v:a}){let n=a*t,r=n*(1-Math.abs(e/60%2-1)),s=a-n,o=0,i=0,u=0;if(e<60)[o,i,u]=[n,r,0];else if(e<120)[o,i,u]=[r,n,0];else if(e<180)[o,i,u]=[0,n,r];else if(e<240)[o,i,u]=[0,r,n];else if(e<300)[o,i,u]=[r,0,n];else[o,i,u]=[n,0,r];return{r:(o+s)*255,g:(i+s)*255,b:(u+s)*255}}function mn(e){if(!e)return"";let t=/^(-?\d*\.?\d+)px$/.exec(e);return t?`${Math.round(Number.parseFloat(t[1]))}px`:e}function qo(e){if(!e)return{n:"",unit:"px"};let t=e.trim(),a=/^(-?\d*\.?\d+)\s*(px|rem|em|%|vw|vh)?$/.exec(t);if(a)return{n:a[1],unit:a[2]||"px"};if(t==="auto")return{n:"",unit:"auto"};return{n:t,unit:""}}function pE(e,t){if(!e||Array.isArray(e)||Array.isArray(t)||!t)return e;if(!e.id&&!t.id){let a=(n)=>typeof n.selector==="string"&&n.selector.startsWith("[data-dc-screen=");if(a(e)&&a(t)&&e.selector===t.selector&&e.file===t.file)return{...e,authored:e.authored??t.authored,computed:e.computed??t.computed,customStyles:e.customStyles??t.customStyles,attrs:e.attrs??t.attrs,artboardId:e.artboardId??t.artboardId,worldW:e.worldW??t.worldW,worldH:e.worldH??t.worldH};return e}if(!e.id||e.id!==t.id)return e;return{...e,authored:e.authored??t.authored,computed:e.computed??t.computed,customStyles:e.customStyles??t.customStyles,attrs:e.attrs??t.attrs,photoKind:e.photoKind??t.photoKind,photoAsset:e.photoAsset??t.photoAsset}}function Qv(e,t){return(e?t?.canvasDesignSystems?.[e]:null)||t?.defaultDesignSystem||t?.designSystems?.[0]?.name||null}function Ube(e){let t={};for(let o of e.matchAll(/(--[a-z0-9-]+)\s*:\s*([^;}]+)/gi))if(!(o[1]in t))t[o[1]]=o[2].trim();let a={};for(let o of Object.keys(t)){let i=t[o],u=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(i);a[o]=u&&t[u[1]]?t[u[1]]:i}let n=Object.keys(t),r=(o)=>n.filter((i)=>o.test(i)),s=(o)=>/^(#[0-9a-f]{3,8}|rgba?\(|hsla?\(|oklch\(|oklab\(|lab\(|lch\(|hwb\(|color\()/i.test(o)||/^(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(o);return{color:n.filter((o)=>s(a[o])),space:r(/^--space-/),radius:r(/^--radius-/),type:r(/^--type-/),shadow:r(/^--shadow-/),lh:r(/^--lh-/),vals:a}}function Xv(e,t,a){let n=e?.designSystems||[],r=n.map((i)=>`${i.name}:${i.tokensCssRel}`).join("|"),[s,o]=P([]);return ee(()=>{if(!n.length)return;let i=!1;return Promise.all(n.map(async(u)=>{if(!u.tokensCssRel)return null;try{let c=await fetch(`/${t}/${u.tokensCssRel}`),f=c.ok?await c.text():"";return{name:u.name,...Ube(f)}}catch{return null}})).then((u)=>{if(i)return;let c=u.filter(Boolean);c.sort((f,p)=>f.name===a?-1:p.name===a?1:0),o(c)}),()=>{i=!0}},[r,t,a]),s}function Zv({seed:e,label:t,onApply:a}){let[n,r]=P(()=>$p(Jh(e||"#000000"))),s=me(n);s.current=n;let o=me(null),i=me(null),u=me(e);ee(()=>{if(e&&e!==u.current)u.current=e,r($p(Jh(e)))},[e]);let c=Tp(Ed(n)),f=(v)=>{v.preventDefault();let k=o.current?.getBoundingClientRect();if(!k)return;let I=s.current.h,A=(E)=>{r({h:I,s:el((E.clientX-k.left)/k.width),v:el(1-(E.clientY-k.top)/k.height)})};A(v);let N=()=>{document.removeEventListener("pointermove",A),document.removeEventListener("pointerup",N),a(Tp(Ed(s.current)))};document.addEventListener("pointermove",A),document.addEventListener("pointerup",N)},p=(v)=>{v.preventDefault();let k=i.current?.getBoundingClientRect();if(!k)return;let{s:I,v:A}=s.current,N=(R)=>{r({h:el((R.clientX-k.left)/k.width)*360,s:I,v:A})};N(v);let E=()=>{document.removeEventListener("pointermove",N),document.removeEventListener("pointerup",E),a(Tp(Ed(s.current)))};document.addEventListener("pointermove",N),document.addEventListener("pointerup",E)},m=(v)=>{let k={...s.current,...v};r(k),a(Tp(Ed(k)))},h=(v)=>{let k=v.shiftKey?0.1:0.02,A={ArrowLeft:[-k,0],ArrowRight:[k,0],ArrowUp:[0,k],ArrowDown:[0,-k]}[v.key];if(!A)return;v.preventDefault(),m({s:el(s.current.s+A[0]),v:el(s.current.v+A[1])})},b=(v)=>{let k=v.shiftKey?20:2,A={ArrowLeft:-k,ArrowRight:k}[v.key];if(A==null)return;v.preventDefault(),m({h:Math.min(360,Math.max(0,s.current.h+A))})},w=async()=>{try{let v=window.EyeDropper;if(!v)return;let k=await new v().open();if(k?.sRGBHex)r($p(Jh(k.sRGBHex))),a(k.sRGBHex)}catch{}},S=Ed(n),_=(v)=>{let k={...S,...v},I=$p({r:el(k.r/255)*255,g:el(k.g/255)*255,b:el(k.b/255)*255});r(I),a(Tp(Ed(I)))};return y("div",{className:"st-cp-cpick",children:[y("div",{className:"st-cp-cpick-hexrow",children:[l("span",{className:"st-cp-cpick-hexsw",style:{background:c}}),l("input",{className:"st-cp-cpick-hex",type:"text",value:c,"aria-label":t?`${t} hex value`:"hex value",onChange:(v)=>{let k=v.target.value;if(/^#?[0-9a-f]{6}$/i.test(k))r($p(Jh(k)))},onKeyDown:(v)=>{if(v.key==="Enter")a(v.currentTarget.value)},onBlur:(v)=>a(v.currentTarget.value),onFocus:(v)=>v.currentTarget.select()})]}),y("button",{type:"button",ref:o,className:"st-cp-cpick-sv","aria-label":t?`${t} saturation and value`:"saturation and value",style:{background:`hsl(${n.h} 100% 50%)`},onPointerDown:f,onKeyDown:h,children:[l("span",{className:"st-cp-cpick-svwhite"}),l("span",{className:"st-cp-cpick-svblack"}),l("span",{className:"st-cp-cpick-knob",style:{left:`${n.s*100}%`,top:`${(1-n.v)*100}%`,background:c}})]}),y("div",{className:"st-cp-cpick-controls",children:[window.EyeDropper?l("button",{type:"button",className:"st-cp-cpick-eye","aria-label":"pick from screen",title:"eyedropper",onClick:w,children:l(ga,{name:"eyedropper",size:14})}):null,l("span",{className:"st-cp-cpick-preview",style:{background:c},"aria-hidden":"true"}),l("button",{type:"button",ref:i,className:"st-cp-cpick-hue","aria-label":t?`${t} hue`:"hue",onPointerDown:p,onKeyDown:b,children:l("span",{className:"st-cp-cpick-huethumb",style:{left:`${n.h/360*100}%`}})})]}),l("div",{className:"st-cp-cpick-rgb",children:["r","g","b"].map((v)=>y("label",{className:"st-cp-cpick-rgbf",children:[l("input",{"aria-label":v.toUpperCase(),value:Math.round(S[v]),onChange:(k)=>_({[v]:el((Number.parseFloat(k.target.value)||0)/255)*255}),onFocus:(k)=>k.currentTarget.select()}),l("span",{children:v.toUpperCase()})]},v))})]})}function Ap({kind:e,groups:t,current:a,onPick:n,label:r,swatchBg:s,seedHex:o,activeDs:i,swatchClassName:u}){let[c,f]=P(!1),[p,m]=P(null),[h,b]=P("custom"),[w,S]=P(""),_=me(null),v=me(null),k=typeof a==="string"&&/var\(\s*--/.test(a),I=(X)=>a===`var(${X})`,A=(X)=>X.replace(/^--/,"").replace(/-/g," "),N=t||[],E=N.reduce((X,K)=>X+(K.names?.length||0),0),R=N.length>1,O=w.trim().toLowerCase(),H=!O?N:N.map((X)=>({...X,names:(X.names||[]).filter((K)=>A(K).toLowerCase().includes(O)||K.toLowerCase().includes(O)||(X.vals?.[K]||"").toLowerCase().includes(O))})).filter((X)=>X.names.length);ee(()=>{if(!c){S("");return}let X=()=>{let se=_.current?.getBoundingClientRect();if(!se)return;let Z=224,pe=300,oe=Math.min(se.right-Z,window.innerWidth-Z-8);if(oe<8)oe=8;let Je=window.innerHeight-se.bottom>pe+8?se.bottom+4:Math.max(8,se.top-pe-4);m({left:oe,top:Je,width:Z,maxHeight:pe})};X();let K=(se)=>{if(v.current?.contains(se.target)||_.current?.contains(se.target))return;f(!1)},ie=(se)=>{if(se.key==="Escape")f(!1)},G=(se)=>{if(v.current?.contains(se.target))return;X()};return document.addEventListener("pointerdown",K,!0),document.addEventListener("keydown",ie),window.addEventListener("resize",X),document.addEventListener("scroll",G,!0),()=>{document.removeEventListener("pointerdown",K,!0),document.removeEventListener("keydown",ie),window.removeEventListener("resize",X),document.removeEventListener("scroll",G,!0)}},[c]),ee(()=>{if(!c||!p||!v.current)return;let X=v.current.getBoundingClientRect(),K=p.left-X.left,ie=p.top-X.top;if(Math.abs(K)>0.5||Math.abs(ie)>0.5)m((G)=>G?{...G,left:G.left+K,top:G.top+ie}:G)},[c,p]);let V=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,q=(X,K,ie)=>{if(i&&X&&X!==i&&ie&&!V.test(ie))n(ie);else n(`var(${K})`);f(!1)},D=(X)=>{let K=(X||"").trim();if(K)n(K)},U=y("div",{className:"st-cp-pop-search",children:[l(ga,{name:"search",size:12}),l("input",{value:w,onChange:(X)=>S(X.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),z=(X)=>X.map((K)=>y("div",{className:"st-cp-pop-group",children:[R?l("div",{className:"st-cp-pop-ds",children:K.ds}):null,l("div",{className:"st-cp-pop-list",children:K.names.map((ie)=>y("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${I(ie)?" is-on":""}`,onClick:()=>q(K.ds,ie,K.vals?.[ie]),children:[l("span",{className:"st-cp-pop-cswatch",style:{background:K.vals?.[ie]||"transparent"},"aria-hidden":"true"}),l("span",{className:"st-cp-pop-name",children:A(ie)}),l("span",{className:"st-cp-pop-val",children:K.vals?.[ie]||""})]},`${K.ds}:${ie}`))})]},K.ds)),M=(X)=>X.map((K)=>y("div",{className:"st-cp-pop-group",children:[R?l("div",{className:"st-cp-pop-ds",children:K.ds}):null,l("div",{className:"st-cp-pop-list",children:K.names.map((ie)=>y("button",{type:"button",className:`st-cp-pop-row${I(ie)?" is-on":""}`,onClick:()=>q(K.ds,ie,K.vals?.[ie]),children:[l("span",{className:"st-cp-pop-name",children:A(ie)}),l("span",{className:"st-cp-pop-val",children:K.vals?.[ie]||""})]},`${K.ds}:${ie}`))})]},K.ds)),F=l("div",{className:"st-cp-pop-empty",children:"No match"});return y(te,{children:[s!==void 0?l("button",{type:"button",ref:_,className:`${u||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${k&&!u?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":c,"aria-label":r||"pick a colour",title:a||"pick a colour",onClick:()=>f((X)=>!X),children:l("span",{style:{position:"absolute",inset:0,background:s||"transparent"}})}):l("button",{type:"button",ref:_,className:`st-cp-tokbtn${k?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":c,"aria-label":r||"pick a design token",title:"design tokens",onClick:()=>f((X)=>!X),children:l("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),c&&p?vu(l("div",{ref:v,className:"maude st-cp-pop","data-theme":typeof document<"u"&&document.documentElement.getAttribute("data-theme")||"dark",role:"dialog","aria-label":r||"design tokens",style:{left:p.left,top:p.top,width:p.width,maxHeight:p.maxHeight},children:e==="color"?y(te,{children:[y("div",{className:"st-cp-poptabs",role:"tablist",children:[l("button",{type:"button",role:"tab","aria-selected":h==="custom",className:`st-cp-poptab${h==="custom"?" is-active":""}`,onClick:()=>b("custom"),children:"Custom"}),l("button",{type:"button",role:"tab","aria-selected":h==="vars",className:`st-cp-poptab${h==="vars"?" is-active":""}`,onClick:()=>b("vars"),children:"Variables"})]}),h==="custom"?l(Zv,{seed:o||Ad(a)||"#000000",onApply:D}):!E?l("div",{className:"st-cp-pop-empty",children:"No color tokens"}):y(te,{children:[U,H.length?z(H):F]})]}):!E?l("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):y(te,{children:[U,H.length?M(H):F]})}),document.body):null]})}function x2({label:e,tracks:t,editable:a,onChange:n}){let r=(u,c)=>{let f=t[u];n(t.map((p,m)=>m===u?rh.has(c)?{value:0,unit:c}:{value:f.value||1,unit:c}:p))},s=(u,c)=>{n(t.map((f,p)=>p===u?{...f,value:c}:f))},o=()=>n([...t,{value:1,unit:"fr"}]),i=(u)=>n(t.filter((c,f)=>f!==u));return y("div",{className:"st-cp-gridtracks",children:[y("div",{className:"st-cp-gridtracks-hd",children:[l("span",{className:"st-cp-gridtracks-label",children:e}),l("button",{type:"button",className:"st-btn st-cp-gridtracks-add",disabled:!a,onClick:o,children:"+ Track"})]}),t.length===0?y("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",e.toLowerCase(),"."]}):t.map((u,c)=>{let f=rh.has(u.unit);return y("div",{className:"st-cp-gridtrack-row",children:[f?l(Vl,{value:u.unit,ariaLabel:`${e} track ${c+1}`,options:c2.map((p)=>({value:p,label:p})),onChange:(p)=>r(c,p)}):l(Sr,{value:u.value,min:u.unit==="fr"?0.1:0,step:u.unit==="fr"?0.1:1,ariaLabel:`${e} track ${c+1} value`,lead:String(c+1),unitSlot:l(Ph,{value:u.unit,units:c2,ariaLabel:`${e} track ${c+1} unit`,onChange:(p)=>r(c,p)}),onCommit:(p)=>s(c,p)}),l("button",{type:"button",className:"st-btn st-cp-gridtrack-remove","aria-label":`remove ${e} track ${c+1}`,disabled:!a||t.length<=1,onClick:()=>i(c),children:"×"})]},c)})]})}var eg={pending:0,waiters:[]};function _2(e){eg.pending+=1;let t=()=>{if(eg.pending-=1,eg.pending===0)for(let a of eg.waiters.splice(0))a()};return e.then(t,t),e}function mE(){return eg.pending===0?Promise.resolve():new Promise((e)=>eg.waiters.push(e))}function hE({el:e,cfg:t,onOptimistic:a,onRecordEdit:n,onReplaceMedia:r,onUndoRedo:s,mode:o,onSetMode:i}){let u=!!e.id,c=e.computed||{},[f,p]=P({a:{},c:{},t:{}});ee(()=>{p({a:{},c:{},t:{}})},[e.id,e.authored,e.customStyles,e.attrs]);let m=(B,ae)=>{let de={...B||{}};for(let[Ce,Pe]of Object.entries(ae))if(Pe===null)delete de[Ce];else de[Ce]=Pe;return de},h=m(e.authored,f.a),b=m(e.customStyles,f.c),w=m(e.attrs,f.t),S=(B,ae)=>p((de)=>({...de,a:{...de.a,[B]:ae}})),_=(B,ae)=>p((de)=>({...de,c:{...de.c,[B]:ae}})),v=(B,ae)=>p((de)=>({...de,t:{...de.t,[B]:ae}})),k=(t?.designRel||t?.designRoot||".design").replace(/^\/+|\/+$/g,""),I=Qv(e.file,t),A=Xv(t,k,I),N=(B)=>A.map((ae)=>({ds:ae.name,names:ae[B]||[],vals:ae.vals})).filter((ae)=>ae.names.length),[E,R]=P({}),[O,H]=P({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),V=Object.keys(b).length>0||Object.keys(w).length>0;ee(()=>{if(V)H((B)=>B.Advanced?B:{...B,Advanced:!0})},[e.id,V]);let q=(h.position||mn(c.position)||"static")!=="static";ee(()=>{if(q)H((B)=>B["d:Position"]?B:{...B,"d:Position":!0})},[e.id,q]);let D=i,[U,z]=P({});async function M(B,ae,de){R((Ce)=>({...Ce,[de]:"saving"}));try{let Ce=await fetch(B,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(ae)}),Pe=await Ce.json().catch(()=>({}));return R((ct)=>({...ct,[de]:!Ce.ok||!Pe.ok?`err:${Pe&&Pe.error||`HTTP ${Ce.status}`}`:"saved"})),Ce.ok?Pe:null}catch(Ce){return R((Pe)=>({...Pe,[de]:`err:${Ce&&Ce.message?Ce.message:String(Ce)}`})),null}}let F=me(Promise.resolve()),X=(B,ae,de,Ce,Pe,ct,ft)=>{F.current=_2(F.current.then(async()=>{let Ot=await M(B,ae,de);if(!Ot?.ok)return;let Mt=Object.hasOwn(Ot,"previous")?Ot.previous:ct;if((Mt??null)===(ft??null))return;ie(Ce,Pe,Mt,ft)}))},K=(B,ae)=>{if(!a||!e.id)return;a({id:e.id,artboardId:e.artboardId??null,index:e.index??0,prop:B,value:ae})},ie=(B,ae,de,Ce)=>{n?.({op:B,canvas:e.file,id:e.id,key:ae,before:de==null||de===""?null:de,after:Ce==null||Ce===""?null:Ce})},G=(B,ae)=>{let de=(ae||"").trim();if(!u||!de)return;let Ce=h[B]??null;if(de===(Ce??"").trim())return;K(B,de),S(B,de),X("/_api/edit-css",{canvas:e.file,id:e.id,property:B,value:de},B,"css",B,Ce,de)},se=(B,ae)=>{let de=(ae||"").trim(),Ce=B.trim();if(!u||!Ce||!de)return;let Pe=b[Ce]??null;K(Ce,de),_(Ce,de),X("/_api/edit-css",{canvas:e.file,id:e.id,property:Ce,value:de},Ce,"css",Ce,Pe,de)},Z=(B,ae)=>{let de=(B||"").trim(),Ce=(ae||"").trim();if(!u||!de||!Ce)return;let Pe=w[de]??null;v(de,Ce),X("/_api/edit-attr",{canvas:e.file,id:e.id,attr:de,value:Ce},`@${de}`,"attr",de,Pe,Ce)},pe=(B)=>{if(!u)return;let ae=h[B]??null;K(B,null),S(B,null),X("/_api/edit-css",{canvas:e.file,id:e.id,property:B,reset:!0},B,"css",B,ae,null)},oe=(B)=>{if(!u)return;let ae=b[B]??null;K(B,null),_(B,null),X("/_api/edit-css",{canvas:e.file,id:e.id,property:B,reset:!0},B,"css",B,ae,null)},ye=(B)=>{if(!u)return;let ae=w[B]??null;v(B,null),X("/_api/edit-attr",{canvas:e.file,id:e.id,attr:B,reset:!0},`@${B}`,"attr",B,ae,null)},Je={display:e.parentDisplay,flexDirection:e.parentFlexDirection},Ke=(B,ae)=>{if(!u)return;let de=Math.round((B==="width"?e.bounds?.w:e.bounds?.h)||0),Ce=OI(B,ae,Je,de);for(let Pe of Ce.reset)if(h[Pe])pe(Pe);for(let[Pe,ct]of Ce.set)G(Pe,ct)},ot=e.parentDisplay==="flex"||e.parentDisplay==="inline-flex",yt=(B)=>{let ae=RI(B,h,c,Je);return y("div",{className:"st-cp-moderow",children:[l("span",{className:"st-cp-modelabel",children:B==="width"?"Width sizing":"Height sizing"}),l("div",{className:"st-cp-modeseg",role:"group","aria-label":`${B} sizing mode`,children:l(zh,{value:ae,ariaLabel:`${B} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(de)=>Ke(B,de)})})]},`mode-${B}`)},rt=["flex-start","center","flex-end"],nt=["flex-start","center","flex-end"],bt=["t","c","b"],kt=["l","c","r"],Se=()=>{let B=!(h["flex-direction"]||mn(c["flex-direction"])||"row").startsWith("column"),ae=Math.max(0,rt.indexOf(h["justify-content"]||mn(c["justify-content"])||"flex-start")),de=h["align-items"]||mn(c["align-items"])||"stretch",Ce=de==="stretch"?1:Math.max(0,nt.indexOf(de)),[Pe,ct]=B?[ae,Ce]:[Ce,ae];return bt[ct]+kt[Pe]},qe=(B)=>{let ae=bt.indexOf(B[0]),de=kt.indexOf(B[1]),Ce=!(h["flex-direction"]||mn(c["flex-direction"])||"row").startsWith("column"),[Pe,ct]=Ce?[de,ae]:[ae,de];G("justify-content",rt[Pe]),G("align-items",nt[ct])},_e=(B)=>{if(!(B.metaKey||B.ctrlKey)||B.altKey)return;let ae=B.key.toLowerCase();if(ae==="z")B.preventDefault(),s?.(B.shiftKey?"redo":"undo");else if(ae==="y")B.preventDefault(),s?.("redo")},Ye=(B)=>{let ae=h[B];if(!ae)return"inherit";return/var\(\s*--/.test(ae)?"bound":"raw"};if(!u)return y("div",{className:"st-cp",children:[l("div",{className:"st-cp-id",children:l("span",{className:"st-cp-idtag",children:e.tag||"element"})}),y("div",{className:"st-css-disabled",children:["This selection has no stable element id (a legacy canvas, or a non-element target). Edit it with ",l("code",{children:"/design:edit"}),"."]})]});let He={bound:"token-bound",raw:"raw override",inherit:"inherited"},ht=(B)=>l("span",{className:`st-cp-prov st-cp-prov--${B}`,role:"img","aria-label":He[B]}),Xt=(B,ae)=>{let de=ae??Ye(B),Ce=E[B],Pe=typeof Ce==="string"&&Ce.startsWith("err:")?Ce.slice(4):"",ct=Pe?" is-err":Ce==="saved"?" is-saved":Ce==="saving"?" is-saving":"",ft=!!h[B],Ot=Pe?`error: ${Pe}`:ft?`${He[de]} · double-click to reset`:He[de];return l("button",{type:"button",className:`st-cp-prov st-cp-prov--${de}${ct}${ft?" is-resettable":""}`,"aria-label":Ot,title:Ot,tabIndex:ft?0:-1,onDoubleClick:ft?()=>pe(B):void 0,onKeyDown:ft?(Mt)=>{if(Mt.key==="Backspace"||Mt.key==="Delete")Mt.preventDefault(),pe(B)}:void 0})},Ne=(B,ae,de,Ce)=>{let Pe=de===void 0&&!h[B],ct=Ce??B;return y("div",{className:`st-cp-row${Pe?" is-unset":""}`,children:[Xt(B,de),l("label",{className:"st-cp-label",title:ct,children:ct}),l("div",{className:"st-cp-ctl",children:ae})]},B)},At={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"]},ua=(B)=>{(At[B]||[]).forEach((ae)=>{if(h[ae])pe(ae)})},Be=(B,ae)=>{let de=(At[B]||[]).some((Ce)=>h[Ce]);return y("section",{className:"st-cp-sec",children:[y("div",{className:"st-cp-sechd-row",children:[y("button",{type:"button",className:"st-cp-sechd","data-testid":`inspector-section-${B.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,"aria-expanded":!!O[B],onClick:()=>H((Ce)=>({...Ce,[B]:!Ce[B]})),children:[l("span",{className:"st-cp-caret","aria-hidden":"true",children:O[B]?"▾":"▸"}),B]}),l("button",{type:"button",className:`st-cp-secreset${de?"":" is-quiet"}`,"aria-label":`reset ${B} section to original`,title:`reset ${B}`,disabled:!de,onClick:()=>ua(B),children:l(sn,{as:vp,size:12})})]}),l("div",{className:`st-cp-sec-anim${O[B]?" is-open":""}`,children:l("div",{className:"st-cp-sec-inner",children:ae})})]},B)},fe=(B,ae,de,Ce=!0)=>{let Pe=`d:${B}`,ct=O[Pe]===void 0?Ce:O[Pe],ft=ae.some((Ot)=>h[Ot]);return y("section",{className:"st-cp-sec",children:[y("div",{className:"st-cp-sechd-row",children:[y("button",{type:"button",className:"st-cp-sechd","aria-expanded":ct,onClick:()=>H((Ot)=>({...Ot,[Pe]:!ct})),children:[l("span",{className:"st-cp-caret","aria-hidden":"true",children:ct?"▾":"▸"}),B]}),l("button",{type:"button",className:`st-cp-secreset${ft?"":" is-quiet"}`,"aria-label":`reset ${B} to original`,title:`reset ${B}`,disabled:!ft,onClick:()=>ae.forEach((Ot)=>{if(h[Ot])pe(Ot)}),children:l(sn,{as:vp,size:12})})]}),l("div",{className:`st-cp-sec-anim${ct?" is-open":""}`,children:l("div",{className:"st-cp-sec-inner",children:de})})]},Pe)},Ze=(B)=>l("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!U[B],"aria-label":U[B]?`${B} — fewer options`:`${B} — more options`,title:U[B]?"fewer":"more",onClick:()=>z((ae)=>({...ae,[B]:!ae[B]})),children:U[B]?"▴":"···"}),he=(B,ae)=>y("select",{className:"st-cp-nsel","aria-label":B,value:ae.includes(h[B])?h[B]:"",onChange:(de)=>G(B,de.target.value),children:[l("option",{value:"",disabled:!0,children:mn(c[B])||"—"}),ae.map((de)=>l("option",{value:de,children:de},de))]}),Le=(B)=>N(B).flatMap((ae)=>(ae.names||[]).map((de)=>({name:de,value:ae.vals?.[de]||""}))),Ie=(B,ae)=>l(F_,{value:h[B]||mn(c[B])||ae[0].value,ariaLabel:B,options:ae,onChange:(de)=>G(B,de)}),ue=(B,ae,de={})=>{let Ce=qo(h[B]??""),Pe=h2.has(B),ct=h[B]??"",ft=typeof ct==="string"&&/var\(\s*--/.test(ct),Ot=Pe?"":Ce.unit&&Ce.unit!=="auto"?Ce.unit:"px",Mt=Number.parseFloat(qo(mn(c[B])??"").n)||0,da=Ce.n!==""&&Ce.n!=null?Number.parseFloat(Ce.n)||0:Mt,Ta=Kv[B];return l(Bh,{value:ft?ct:da,tokens:Le(ae),ariaLabel:B,min:de.min??0,lead:Ta?Ta.node??Ta.t:void 0,unitSlot:Pe?null:l(Ph,{units:m2,value:Ce.unit||"px",ariaLabel:`${B} unit`,onChange:(Ma)=>G(B,Ma==="auto"?"auto":`${Ce.n||"0"}${Ma}`)}),onChange:(Ma)=>G(B,typeof Ma==="string"?Ma:Pe?`${Ma}`:`${Ma}${Ot}`)})},be=()=>{let B=(Pe)=>Number.parseFloat(qo(h[Pe]??h["border-radius"]??mn(c[Pe])??mn(c["border-radius"])??"0").n)||0,ae={tl:B("border-top-left-radius"),tr:B("border-top-right-radius"),bl:B("border-bottom-left-radius"),br:B("border-bottom-right-radius")},de=(Pe)=>{if(Pe.tl===Pe.tr&&Pe.tr===Pe.bl&&Pe.bl===Pe.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((ft)=>{if(h[ft])pe(ft)}),G("border-radius",`${Pe.tl}px`);else G("border-top-left-radius",`${Pe.tl}px`),G("border-top-right-radius",`${Pe.tr}px`),G("border-bottom-left-radius",`${Pe.bl}px`),G("border-bottom-right-radius",`${Pe.br}px`)},Ce=Kv["border-radius"];return l(rA,{corners:ae,lead:Ce?Ce.node??Ce.t:void 0,onCorners:de})},Te=()=>y("div",{className:"st-cp-border",children:[Yt("border-width",null,{fixedUnit:"px"}),y("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:p2.includes(h["border-style"])?h["border-style"]:"",onChange:(B)=>G("border-style",B.target.value),children:[l("option",{value:"",disabled:!0,children:"style"}),p2.map((B)=>l("option",{value:B,children:B},B))]}),l(Ap,{kind:"color",groups:N("color"),current:h["border-color"],activeDs:I,swatchBg:c["border-color"]||h["border-color"]||"",seedHex:Ad(c["border-color"]||h["border-color"])||"#000000",onPick:(B)=>G("border-color",B),label:"border colour"})]}),tt=()=>{let B=h.transform||mn(c.transform)||"",ae=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(B),de=((ae?Number.parseFloat(ae[1]):0)%360+360)%360,Ce=(Pe)=>{let ct=(Pe%360+360)%360,ft=(h.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();G("transform",`${ft?`${ft} `:""}rotate(${ct}deg)`.trim())};return y("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[l(nA,{value:de,onChange:Ce}),l(Sr,{value:de,min:0,max:360,ariaLabel:"rotation",lead:l(sn,{as:vp}),steppers:!1,unitSlot:l("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:Ce})]})},we=()=>{let B=h.filter||mn(c.filter)||"",ae=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(B),de=ae?Number.parseFloat(ae[1]):0;return l(Sr,{value:de,min:0,ariaLabel:"filter blur",unitSlot:l("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(Pe)=>{let ct=(h.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();G("filter",Pe>0?`${ct?`${ct} `:""}blur(${Pe}px)`.trim():ct||"none")}})},Ue=()=>{let B=h.opacity,ae=B!=null&&B!==""?Number.parseFloat(B):Number.parseFloat(mn(c.opacity))||1,de=Math.round((Number.isNaN(ae)?1:ae)*100);return l(co,{value:de,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(Ce)=>K("opacity",String(Ce/100)),onCommit:(Ce)=>G("opacity",String(Ce/100))},`opacity:${B??""}`)},lt=()=>{let B=Number.parseInt(h["font-weight"]||mn(c["font-weight"])||"400",10)>=600,ae=(h["font-style"]||mn(c["font-style"]))==="italic",de=/underline/.test(h["text-decoration"]||mn(c["text-decoration"])||"");return l(tA,{value:{b:B,i:ae,u:de},ariaLabel:"text style",options:[{value:"b",node:l(sn,{as:pv}),label:"Bold"},{value:"i",node:l(sn,{as:bv}),label:"Italic"},{value:"u",node:l(sn,{as:Av}),label:"Underline"}],onToggle:(Ce)=>{if(Ce==="b")G("font-weight",B?"400":"700");else if(Ce==="i")G("font-style",ae?"normal":"italic");else G("text-decoration",de?"none":"underline")}})},le=[{value:"row",node:l(sn,{as:gd}),label:"Row"},{value:"column",node:l(sn,{as:yd}),label:"Column"}],We=[{value:"flex-start",node:l(sn,{as:lv}),label:"Start"},{value:"center",node:l(sn,{as:ov}),label:"Center"},{value:"flex-end",node:l(sn,{as:iv}),label:"End"},{value:"space-between",node:l(sn,{as:yp}),label:"Space between"}],xt=[{value:"flex-start",node:l(sn,{as:dv}),label:"Start"},{value:"center",node:l(sn,{as:uv}),label:"Center"},{value:"flex-end",node:l(sn,{as:cv}),label:"End"},{value:"stretch",node:l(sn,{as:Tv}),label:"Stretch"}],Wt=[{value:"left",node:l(sn,{as:Yi}),label:"Left"},{value:"center",node:l(sn,{as:wd}),label:"Center"},{value:"right",node:l(sn,{as:_d}),label:"Right"},{value:"justify",node:l(sn,{as:xd}),label:"Justify"}],pa=[{value:"visible",node:l(sn,{as:bp}),label:"Visible"},{value:"hidden",node:l(sn,{as:wp}),label:"Hidden"},{value:"scroll",node:l(sn,{as:Cv}),label:"Scroll"}],Qa=(B,ae)=>{let de=N(ae);return de.length?l(Ap,{kind:"value",groups:de,current:h[B],activeDs:I,onPick:(Ce)=>G(B,Ce),label:`${B} design token`}):null},Pt=(B)=>{let ae=B.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===ae)ae.select()})},pn=(B,ae)=>{if(B.key!=="ArrowUp"&&B.key!=="ArrowDown")return!1;B.preventDefault();let de=B.shiftKey?10:1,Ce=B.key==="ArrowUp"?1:-1,Pe=(Number.parseFloat(B.currentTarget.value)||0)+Ce*de;return B.currentTarget.value=String(Pe),ae(Pe),!0},Dt=(B)=>l("input",{className:"st-cp-fin","aria-label":B,defaultValue:h[B]??"",placeholder:mn(c[B])||"—",onFocus:Pt,onKeyDown:(ae)=>{if(ae.key==="Enter")ae.currentTarget.blur()},onBlur:(ae)=>G(B,ae.currentTarget.value)},`${B}:${h[B]??""}`),Yt=(B,ae,de={})=>{let Ce=qo(h[B]??""),Pe=h2.has(B),ct=Pe?"":de.fixedUnit||(Ce.unit&&Ce.unit!=="auto"?Ce.unit:"px"),ft=Kv[B],Ot=Number.parseFloat(qo(mn(c[B])??"").n)||0,Mt=Ce.n!==""&&Ce.n!=null?Number.parseFloat(Ce.n)||0:Ot;return y(te,{children:[l(Sr,{value:Mt,min:de.min??0,step:1,ariaLabel:B,lead:ft?ft.node??ft.t:void 0,onCommit:(da)=>G(B,Pe?`${da}`:`${da}${ct}`),unitSlot:Pe||de.fixedUnit?null:l(Ph,{units:m2,value:Ce.unit||"px",ariaLabel:`${B} unit`,onChange:(da)=>G(B,da==="auto"?"auto":`${Ce.n||"0"}${da}`)})},`${B}:${h[B]??""}`),Qa(B,ae)]})},Vt=(B)=>{let ae=c[B]||h[B]||"",de=h[B]??"",Ce=typeof de==="string"&&/var\(\s*--/.test(de),Pe=Ce?de.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):de;return l(xp,{swatch:l(Ap,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:N("color"),current:h[B],activeDs:I,swatchBg:ae,seedHex:Ad(c[B]||h[B])||"#000000",onPick:(ct)=>G(B,ct),label:`${B} colour`}),displayValue:Pe,bound:Ce,ariaLabel:B,onValue:(ct)=>G(B,ct)})},ke=(B,ae)=>{let de=null,Ce=ae.unitless?"":"px",Pe=(Ot)=>ae.unitless?`${Ot}`:`${Ot}${Ce}`,ct=(Ot,Mt,da)=>{for(let Ta of Mt??[B])da(Ta,Pe(Ot))},ft=U_({getBase:()=>de?.value??"0",min:ae.min??0,step:1,sides:ae.sides,onInput:(Ot,Mt)=>{if(de)de.value=String(Ot);if(Mt){let da=de?.closest(".st-cp-box");for(let Ta of Mt){if(Ta===B)continue;let Ma=da?.querySelector(`.st-cp-boxv[aria-label="${Ta}"]`);if(Ma)Ma.value=String(Ot)}}ct(Ot,Mt,K)},onCommit:(Ot,Mt)=>ct(Ot,Mt,G)});return{onPointerDown:(Ot)=>{de=Ot.currentTarget,ft(Ot)}}},dt=(B,ae)=>{let de=h[B],Ce=de!=null&&de!==""?qo(de).n||de:qo(mn(c[B])??"").n||"0",Pe=!de||de==="0"||de==="0px"||de==="auto",ct=B.split("-").pop(),ft=ct==="top"||ct==="bottom"?[`${ae}-top`,`${ae}-bottom`]:[`${ae}-left`,`${ae}-right`],Ot=[`${ae}-top`,`${ae}-right`,`${ae}-bottom`,`${ae}-left`];return l("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${ae[0]}${B.split("-").pop()[0]}${Pe?" is-zero":""}`,"aria-label":B,defaultValue:Ce,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...ke(B,{sides:{pair:ft,all:Ot}}),onFocus:Pt,onKeyDown:(Mt)=>{if(pn(Mt,(da)=>G(B,`${da}px`)))return;if(Mt.key==="Enter")Mt.currentTarget.blur()},onBlur:(Mt)=>{let da=Mt.currentTarget.value.trim();if(!da)return;let Ta=/[a-z%]/i.test(da)?da:`${da}px`;G(B,Ta)}},`${B}:${de??""}`)},Bt=(B)=>{let ae=h[B],de=ae!=null&&ae!==""&&ae!=="auto"?qo(ae).n||ae:qo(mn(c[B])??"").n||"",Ce=!ae||ae==="auto"||ae==="0"||ae==="0px",Pe=B==="top"||B==="bottom"?["top","bottom"]:["left","right"],ct=["top","right","bottom","left"];return l("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${B[0]}${Ce?" is-zero":""}`,"aria-label":B,defaultValue:de,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...ke(B,{sides:{pair:Pe,all:ct},min:-1/0}),onFocus:Pt,onKeyDown:(ft)=>{if(pn(ft,(Ot)=>G(B,`${Ot}px`)))return;if(ft.key==="Enter")ft.currentTarget.blur()},onBlur:(ft)=>{let Ot=ft.currentTarget.value.trim();if(!Ot)return;let Mt=/[a-z%]/i.test(Ot)?Ot:`${Ot}px`;G(B,Mt)}},`${B}:${ae??""}`)},oa=Object.entries(b),Pa=Object.entries(w),Va=()=>{let B=(e.tag||"").toLowerCase(),de=B==="img"||B==="video"||B==="picture"||B==="svg"||B==="canvas"||!!h["object-fit"]||!!h["object-position"]||!!h["aspect-ratio"],Ce=(B==="img"||B==="video")&&!!e.attrs?.src&&!!r;return{showMedia:de,canReplace:Ce}},Ve=(B)=>y(te,{children:[B&&l("div",{className:"st-cp-mediabtn",children:l("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>r(e),children:"Replace…"})}),Ne("object-fit",he("object-fit",fE)),Ne("object-position",Dt("object-position")),Ne("aspect-ratio",y("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:w2.includes(h["aspect-ratio"])?h["aspect-ratio"]:"",onChange:(ae)=>{let de=ae.target.value;if(G("aspect-ratio",de),de&&de!=="auto"&&h.height)pe("height")},children:[l("option",{value:"",disabled:!0,children:mn(c["aspect-ratio"])||"—"}),w2.map((ae)=>l("option",{value:ae,children:ae},ae))]}))]});return y("div",{className:`st-cp${o==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:_e,children:[y("div",{className:"st-cp-id",children:[y("span",{className:"st-cp-idtag",children:[e.tag||"element",e.classes?y("span",{className:"st-cp-idcls",children:[".",e.classes.split(/\s+/)[0]]}):null]}),l("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:l(F_,{value:o,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:l(sn,{as:hd,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:l(sn,{as:Sd,size:12}),label:"Designer — Figma vocabulary"}],onChange:D})})]}),o==="designer"?y(te,{children:[fe("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let B=(h.display||mn(c.display)||"").trim();return B==="flex"||B==="inline-flex"?y(te,{children:[Ne("flex-direction",Ie("flex-direction",le),void 0,"Direction"),Ne("align-items",l(aA,{value:Se(),onChange:qe,ariaLabel:"auto-layout alignment"}),Ye("align-items"),"Alignment"),Ne("gap",ue("gap","space"),void 0,"Gap"),y("div",{className:"st-cp-modes",children:[yt("width"),yt("height")]}),y("div",{className:"st-cp-box","aria-label":"padding",children:[y("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[ht(Ye("padding-top")),"padding"]}),dt("padding-top","padding"),dt("padding-right","padding"),dt("padding-bottom","padding"),dt("padding-left","padding")]}),l("div",{className:"st-cp-clustermore-row",children:Ze("Auto layout")}),U["Auto layout"]?Ne("flex-wrap",l(Ji,{checked:/^wrap/.test(h["flex-wrap"]||mn(c["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(de)=>G("flex-wrap",de?"wrap":"nowrap")}),Ye("flex-wrap"),"Wrap"):null]}):l("button",{type:"button",className:"st-cp-makeflex",disabled:!u,onClick:()=>G("display","flex"),children:"+ Auto layout (flex)"})})()),fe("Size",["width","height","min-width","max-width","min-height","max-height"],y(te,{children:[Ne("width",Yt("width"),void 0,"Width"),Ne("height",Yt("height"),void 0,"Height"),l("div",{className:"st-cp-clustermore-row",children:Ze("Size")}),U.Size?y(te,{children:[Ne("min-width",Yt("min-width"),void 0,"Min width"),Ne("max-width",Yt("max-width"),void 0,"Max width"),Ne("min-height",Yt("min-height"),void 0,"Min height"),Ne("max-height",Yt("max-height"),void 0,"Max height")]}):null]})),fe("Position",["position","top","right","bottom","left","z-index"],y(te,{children:[Ne("position",he("position",g2),void 0,"Position"),y("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[y("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[ht(Ye("top")),"inset"]}),Bt("top"),Bt("right"),Bt("bottom"),Bt("left"),l("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:h.position||mn(c.position)||"static"})]}),(h.position||mn(c.position)||"static")==="static"?l("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,l("div",{className:"st-cp-clustermore-row",children:Ze("Position")}),U.Position?Ne("z-index",Yt("z-index"),void 0,"Layer order"):null]}),!1),fe("Fill",["background-color"],Ne("background-color",Vt("background-color"),void 0,"Fill")),fe("Stroke",["border-width","border-style","border-color"],Ne("border",Te(),Ye("border-width"),"Stroke")),fe("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],Ne("border-radius",be(),Ye("border-radius"),"Corner radius")),fe("Effects",["box-shadow","filter","mix-blend-mode"],y(te,{children:[Ne("box-shadow",Qa("box-shadow","shadow")||Dt("box-shadow"),void 0,"Shadow"),Ne("filter",we(),Ye("filter"),"Blur"),Ne("mix-blend-mode",he("mix-blend-mode",v2),void 0,"Blend")]})),fe("Opacity",["opacity"],Ne("opacity",Ue(),void 0,"Opacity")),fe("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],y(te,{children:[Ne("font-family",he("font-family",f2),void 0,"Font"),Ne("color",Vt("color"),void 0,"Color"),Ne("font-size",ue("font-size","type"),void 0,"Size"),Ne("font-weight",he("font-weight",d2),void 0,"Weight"),Ne("line-height",Yt("line-height","lh"),void 0,"Line height"),Ne("text-align",Ie("text-align",Wt),void 0,"Align"),l("div",{className:"st-cp-clustermore-row",children:Ze("Text")}),U.Text?y(te,{children:[Ne("letter-spacing",Yt("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),Ne("font-style",he("font-style",dE),void 0,"Style"),Ne("text-transform",he("text-transform",y2),void 0,"Case"),Ne("white-space",he("white-space",b2),void 0,"Whitespace")]}):null]})),fe("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],y("div",{className:"st-cp-box","aria-label":"margin",children:[y("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[ht(Ye("margin-top")),"margin"]}),dt("margin-top","margin"),dt("margin-right","margin"),dt("margin-bottom","margin"),dt("margin-left","margin")]})),(()=>{let{showMedia:B,canReplace:ae}=Va();return B?fe("Media",["object-fit","object-position","aspect-ratio"],Ve(ae)):null})()]}):y(te,{children:[Be("Layout",(()=>{let B=(h.display||mn(c.display)||"").trim(),ae=B==="flex"||B==="inline-flex",de=B==="grid"||B==="inline-grid";return y(te,{children:[Ne("display",he("display",uE)),ae?y(te,{children:[Ne("flex-direction",Ie("flex-direction",le)),Ne("flex-wrap",l(Ji,{checked:/^wrap/.test(h["flex-wrap"]||mn(c["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(Ce)=>G("flex-wrap",Ce?"wrap":"nowrap")}),Ye("flex-wrap"))]}):null,ae||de?y(te,{children:[Ne("align-items",Ie("align-items",xt)),Ne("justify-content",Ie("justify-content",We)),Ne("gap",ue("gap","space"))]}):l("button",{type:"button",className:"st-cp-makeflex",disabled:!u,onClick:()=>G("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let B=(h.display||mn(c.display)||"").trim();if(!(B==="grid"||B==="inline-grid"))return null;let de=h["grid-template-columns"]||"",Ce=h["grid-template-rows"]||"",Pe=O1(de),ct=O1(Ce),ft=Pe.length>0||!de.trim(),Ot=ct.length>0||!Ce.trim();return Be("Grid",y(te,{children:[ft?l(x2,{label:"Columns",tracks:Pe,editable:u,onChange:(Mt)=>G("grid-template-columns",D1(Mt))}):y("div",{className:"st-cp-note",children:["Columns use ",l("code",{children:de})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),Ot?l(x2,{label:"Rows",tracks:ct,editable:u,onChange:(Mt)=>G("grid-template-rows",D1(Mt))}):y("div",{className:"st-cp-note",children:["Rows use ",l("code",{children:Ce})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),Be("Position",y(te,{children:[Ne("position",he("position",g2)),y("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[y("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[ht(Ye("top")),"inset"]}),Bt("top"),Bt("right"),Bt("bottom"),Bt("left"),l("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:h.position||mn(c.position)||"static"})]}),(h.position||mn(c.position)||"static")==="static"?l("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,Ne("z-index",Yt("z-index"))]})),(e.parentDisplay==="grid"||e.parentDisplay==="inline-grid")&&Be("Grid item",y(te,{children:[y("div",{className:"st-cp-note",children:["Manual cell placement — ",l("code",{children:"start / end"})," or ",l("code",{children:"start / span N"}),"."]}),Ne("grid-column",Dt("grid-column")),Ne("grid-row",Dt("grid-row"))]})),Be("Typography",y(te,{children:[Ne("font-family",he("font-family",f2)),Ne("color",Vt("color")),Ne("font-size",ue("font-size","type")),Ne("font-weight",he("font-weight",d2)),Ne("line-height",Yt("line-height","lh")),Ne("letter-spacing",Yt("letter-spacing",null,{min:-1/0})),Ne("text-align",Ie("text-align",Wt)),Ne("font-style",lt(),Ye("font-style")),Ne("text-transform",he("text-transform",y2)),Ne("white-space",he("white-space",b2))]})),Be("Spacing",l(te,{children:y("div",{className:"st-cp-box","aria-label":"margin and padding",children:[y("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[ht(Ye("margin-top")),"margin"]}),dt("margin-top","margin"),dt("margin-right","margin"),dt("margin-bottom","margin"),dt("margin-left","margin"),y("div",{className:"st-cp-boxpad",children:[y("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[ht(Ye("padding-top")),"padding"]}),dt("padding-top","padding"),dt("padding-right","padding"),dt("padding-bottom","padding"),dt("padding-left","padding"),y("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(h.width)||e.bounds?.w||0)," × ",Math.round(Number.parseFloat(h.height)||e.bounds?.h||0)]})]})]})})),Be("Size",y(te,{children:[y("div",{className:"st-cp-modes",children:[yt("width"),yt("height")]}),Ne("width",Yt("width")),Ne("height",Yt("height")),Ne("min-width",Yt("min-width")),Ne("max-width",Yt("max-width")),Ne("min-height",Yt("min-height")),Ne("max-height",Yt("max-height")),Ne("overflow",Ie("overflow",pa)),ot?y(te,{children:[l("div",{className:"st-cp-subhd",children:"In flex parent"}),Ne("align-self",he("align-self",cE)),Ne("flex-grow",Yt("flex-grow",null,{unitless:!0})),Ne("flex-shrink",Yt("flex-shrink",null,{unitless:!0})),Ne("flex-basis",Yt("flex-basis"))]}):null]})),(()=>{let{showMedia:B,canReplace:ae}=Va();return B?Be("Media",Ve(ae)):null})(),Be("Appearance",y(te,{children:[Ne("background-color",Vt("background-color")),Ne("border-radius",be(),Ye("border-radius")),Ne("border",Te(),Ye("border-width")),Ne("box-shadow",Qa("box-shadow","shadow")||Dt("box-shadow")),Ne("filter",we(),Ye("filter")),Ne("mix-blend-mode",he("mix-blend-mode",v2)),Ne("opacity",Ue()),Ne("rotation",tt(),Ye("transform")),Ne("transform",Dt("transform")),Ne("transform-origin",Dt("transform-origin"))]})),(()=>{let B=Object.entries(E).find(([,ae])=>typeof ae==="string"&&ae.startsWith("err:"));return B?y("div",{className:"st-cp-save is-err",role:"status",children:[l(ga,{name:"x",size:12}),B[0],": ",B[1].slice(4)]}):null})(),Be("Advanced",y("div",{className:"st-cp-advbody",children:[oa.length?y(te,{children:[l("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),oa.map(([B,ae])=>y("div",{className:"st-cp-kv",children:[l("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:B,"aria-label":`custom property ${B} name`}),l("input",{className:"st-cp-fin",defaultValue:ae,"aria-label":`${B} value`,onKeyDown:(de)=>{if(de.key==="Enter")de.currentTarget.blur()},onBlur:(de)=>se(B,de.currentTarget.value)},`cs:${B}:${ae}`),l("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${B}`,title:"remove",onClick:()=>oe(B),children:l(ga,{name:"x",size:11})})]},`cs:${B}`))]}):null,l("div",{className:"st-cp-advgrp",children:"Add CSS property"}),l(Fbe,{commit:se}),l("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),Pa.length?y(te,{children:[l("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),Pa.map(([B,ae])=>y("div",{className:"st-cp-kv",children:[l("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:B,"aria-label":`attribute ${B} name`}),l("input",{className:"st-cp-fin",defaultValue:ae,"aria-label":`${B} value`,onKeyDown:(de)=>{if(de.key==="Enter")de.currentTarget.blur()},onBlur:(de)=>Z(B,de.currentTarget.value)},`at:${B}:${ae}`),l("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${B}`,title:"remove",onClick:()=>ye(B),children:l(ga,{name:"x",size:11})})]},`at:${B}`))]}):null,l("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),l(jbe,{commit:Z})]}))]}),y("div",{className:"st-cp-legend",children:[y("span",{children:[l("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),y("span",{children:[l("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),y("span",{children:[l("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},e.id)}function Fbe({commit:e}){let[t,a]=P(""),[n,r]=P(""),s=()=>{if(t.trim()&&n.trim())e(t.trim(),n),a(""),r("")};return y("div",{className:"st-cp-kv",children:[l("input",{className:"st-cp-fin","aria-label":"custom property name",placeholder:"property",value:t,onChange:(o)=>a(o.target.value)}),l("input",{className:"st-cp-fin","aria-label":"custom property value",placeholder:"value",value:n,onChange:(o)=>r(o.target.value),onKeyDown:(o)=>{if(o.key==="Enter")s()},onBlur:s})]})}function jbe({commit:e}){let[t,a]=P(""),[n,r]=P(""),s=()=>{if(t.trim()&&n.trim())e(t.trim(),n),a(""),r("")};return y("div",{className:"st-cp-kv",children:[l("input",{className:"st-cp-fin","aria-label":"custom attribute name",placeholder:"data-…",value:t,onChange:(o)=>a(o.target.value)}),l("input",{className:"st-cp-fin","aria-label":"custom attribute value",placeholder:"value",value:n,onChange:(o)=>r(o.target.value),onKeyDown:(o)=>{if(o.key==="Enter")s()},onBlur:s})]})}var Hbe={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function gE(e,t,a,n){if(!Array.isArray(e)||t===a)return e;let r=JSON.parse(JSON.stringify(e)),s=null,o=(u)=>{for(let c=0;c<u.length;c++){if(u[c].id===t)return s=u[c],u.splice(c,1),!0;if(u[c].children&&o(u[c].children))return!0}return!1};if(o(r),!s)return e;let i=(u)=>{for(let c=0;c<u.length;c++){if(u[c].id===a){if(n==="inside-start"||n==="inside-end")if(u[c].children=u[c].children||[],n==="inside-start")u[c].children.unshift(s);else u[c].children.push(s);else u.splice(n==="before"?c:c+1,0,s);return!0}if(u[c].children&&i(u[c].children))return!0}return!1};return i(r)?r:e}var yE=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function S2({node:e,depth:t,selectedId:a,selectedIndex:n,collapsed:r,hiddenOverride:s,onToggle:o,onSelect:i,onHover:u,onToggleVisibility:c,onReorder:f,onRowPointerDown:p,dragState:m,componentMap:h,lockedKeys:b,onToggleLock:w,onRename:S}){let _=`${e.id}:${e.index}`,v=e.children&&e.children.length>0,k=r.has(_),I=!!e.synthetic,A=!I&&h?h[e.id]:null,N=!I&&!!b?.has(_),[E,R]=P(!1),[O,H]=P(""),V=!I&&e.id===a&&(n==null||e.index===n),q=s?.has(_)?s.get(_):!!e.hidden,D=!!f&&!I&&!N,U=()=>{R(!1);let F=O.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!F||F===(e.dcElement??""))return;S?.(e,F)},z=m?.key===_,M=z?{transform:`translate(${m.dx}px, ${m.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 y(te,{children:[y("div",{className:"st-layer st-layer--row"+(V?" is-sel":"")+(q?" is-hidden":"")+(I?" is-group":"")+(A?" is-instance":"")+(N?" is-locked":""),style:{paddingLeft:6+t*14,...M},role:"treeitem","aria-selected":I?void 0:V,"aria-expanded":v?!k:void 0,"aria-grabbed":D?z:void 0,tabIndex:0,title:I?`${e.tag} · group (unstamped wrapper)`:`${e.tag} · ${e.type}${S?" · F2 to rename":""}`,"data-layer-key":_,onClick:()=>I?v&&o(_):i(e),onMouseEnter:()=>!I&&u(e),onMouseLeave:()=>u(null),onPointerDown:D?(F)=>p(F,e,_):void 0,onKeyDown:(F)=>{if(F.key==="Enter"||F.key===" ")if(F.preventDefault(),I)v&&o(_);else i(e);else if(F.key==="F2"&&S&&!I)F.preventDefault(),H(e.dcElement||e.label||""),R(!0)},children:[v?l("button",{type:"button",className:"st-layer-caret","aria-label":k?"Expand":"Collapse",onClick:(F)=>{F.stopPropagation(),o(_)},children:k?"▸":"▾"}):l("span",{className:"st-layer-caret","aria-hidden":"true"}),A?l("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:A.root?"◆":"◇"}):l(ga,{name:Hbe[e.type]||"box",size:12,className:"st-layer-ticon"}),E?l("input",{className:"st-layer-rename",value:O,autoFocus:!0,"aria-label":`Rename ${e.label}`,onFocus:(F)=>F.target.select(),onChange:(F)=>H(F.target.value),onClick:(F)=>F.stopPropagation(),onPointerDown:(F)=>F.stopPropagation(),onBlur:U,onKeyDown:(F)=>{if(F.stopPropagation(),F.key==="Enter")U();else if(F.key==="Escape")R(!1)}}):l("span",{className:"st-layer-label",onDoubleClick:S&&!I?(F)=>{F.stopPropagation(),H(e.dcElement||e.label||""),R(!0)}:void 0,children:e.label}),l("span",{className:"st-layer-type",children:A?A.component:e.type}),w&&!I?l("button",{type:"button",className:"st-layer-lock","aria-label":N?`Unlock ${e.label}`:`Lock ${e.label}`,"aria-pressed":N,title:N?"Unlock":"Lock",onClick:(F)=>{F.stopPropagation(),w(_)},children:l(ga,{name:N?"lock":"unlock",size:12})}):null,c&&!I?l("button",{type:"button",className:"st-layer-eye","aria-label":q?`Show ${e.label}`:`Hide ${e.label}`,"aria-pressed":q,title:q?"Show":"Hide",onClick:(F)=>{F.stopPropagation(),c(e)},children:l(ga,{name:q?"eye-off":"eye",size:13})}):null]}),v&&!k?e.children.map((F,X)=>l(S2,{node:F,depth:t+1,selectedId:a,selectedIndex:n,collapsed:r,hiddenOverride:s,onToggle:o,onSelect:i,onHover:u,onToggleVisibility:c,onReorder:f,onRowPointerDown:p,dragState:m,componentMap:h,lockedKeys:b,onToggleLock:w,onRename:S},`${F.id}:${F.index}`)):null]})}function bE({el:e}){let t=e?.computed||{},a=e?.authored||{},n=(c)=>{let f=a[c];if(f&&/var\(\s*--/.test(f))return f.replace(/^var\(\s*|\s*\)$/g,"");return t[c]||f||""},r=(c,f)=>{let p=t[f]||a[f];if(!p)return null;return y("div",{className:"st-insp-row",children:[l("span",{className:"st-insp-label",children:c}),y("div",{className:"st-swatch-row",children:[l("span",{className:"st-insp-swatch",style:{background:p},"aria-hidden":"true"}),l("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:n(f)})]})]},c)},s=t["border-radius"]&&t["border-radius"]!=="0px",o=s?qo(t["border-radius"]).n||t["border-radius"]:null,i=t["font-size"]||t["font-weight"]?[t["font-size"],t["font-weight"]].filter(Boolean).join(" / "):null;if(!(t["background-color"]||t.color||s||i))return null;return y(te,{children:[s?y("div",{className:"st-insp-row",children:[l("span",{className:"st-insp-label",children:"Radius"}),y("div",{className:"st-insp-fields",children:[y("span",{className:"st-fmini",style:{flex:"0 0 auto",maxWidth:84},children:[l("span",{className:"st-mtag",children:"r"}),l("input",{value:o,readOnly:!0,"aria-label":"border radius"})]}),l("span",{className:"st-insp-unit",children:"px"})]})]}):null,r("Fill","background-color"),r("Text","color"),i?y("div",{className:"st-insp-row",children:[l("span",{className:"st-insp-label",children:"Font"}),l("div",{className:"st-insp-fields",children:l("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:i})})]}):null]})}function C2(e){if(e.artboardId)return e.artboardId;let t=/^\[data-dc-screen="([^"]+)"\]$/.exec(e.selector||"");return t?t[1]:null}var qbe=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],Vbe=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function vE({el:e,cfg:t,onResizeArtboard:a,onSetArtboardHug:n,onSetArtboardStyle:r,onSetArtboardKind:s,onSetArtboardPrint:o,onDuplicateArtboard:i}){let u=C2(e),c=(t?.designRel||t?.designRoot||".design").replace(/^\/+|\/+$/g,""),f=Qv(e.file,t),p=Xv(t,c,f),m=(M)=>p.map((F)=>({ds:F.name,names:F[M]||[],vals:F.vals})).filter((F)=>F.names.length),h=(M)=>m(M).flatMap((F)=>(F.names||[]).map((X)=>({name:X,value:F.vals?.[X]||""}))),b=(M)=>{let F=/^var\(\s*(--[\w-]+)\s*\)$/.exec(M||"");if(!F)return M||"";for(let X of p){let K=X.vals?.[F[1]];if(K)return K}return""},w=Number.isFinite(e.worldW)?e.worldW:Number.isFinite(e.bounds?.w)?e.bounds.w:null,S=Number.isFinite(e.worldH)?e.worldH:Number.isFinite(e.bounds?.h)?e.bounds.h:null,_=(M,F)=>{if(!u)return;let X=Number.isFinite(M)&&M>0?Math.round(M):void 0,K=Number.isFinite(F)&&F>0?Math.round(F):void 0;if(X==null&&K==null)return;a?.(u,X,K)},v=Object.entries(Os).find(([,M])=>M.width===w&&M.height===S)?.[0],k=Object.entries(Os).find(([,M])=>M.width===w)?.[0],I=e.attrs?.["data-dc-fixed"]==="true",A=e.attrs?.["data-dc-bg"]??"",N=e.attrs?.["data-dc-padding"]??"",E=e.attrs?.["data-dc-layout"]??"",R=e.attrs?.["data-dc-gap"]??"",O=e.attrs?.["data-dc-kind"]||"digital",H=null;try{H=e.attrs?.["data-dc-print"]?JSON.parse(e.attrs["data-dc-print"]):null}catch{}let V=(M)=>{if(!u)return;let F=null;if(M==="print"&&!H){let X={paper:"a4"};try{let K=oh(X);if(K)F={defaults:X,widthPx:K.widthPx,heightPx:K.heightPx}}catch{}}if(s?.(u,M==="digital"?null:M,F),M==="web"&&I)n?.(u,!1,void 0)},q=(M)=>{if(!u)return;let F={paper:"a4",...H,...M},X;try{X=oh(F)}catch{return}a?.(u,X.widthPx,X.heightPx),o?.(u,F)},D=(M,F)=>{if(!u)return;let X=Number.isFinite(F)?F:S,K=M&&Number.isFinite(X)?Math.round(X):void 0;n?.(u,M,K)},U=(M)=>{let F=MI(I,M);if(F.kind==="resize")_(null,F.height);else if(F.kind==="promote-to-fixed")D(!0,F.height)},z=(M)=>{if(!u)return;r?.(u,M)};return y("section",{className:"st-cp-sec",children:[l("div",{className:"st-cp-sechd-row",children:l("span",{className:"st-cp-sechd",children:"Artboard"})}),y("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[l(Sr,{value:w??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(M)=>_(M,null)}),l(Sr,{value:S??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:I,onCommit:U})]}),l("div",{style:{padding:"0 12px 8px"},children:O==="print"?y("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:H?.paper??"",onChange:(M)=>q({paper:M.currentTarget.value}),children:[l("option",{value:"",disabled:!0,children:"Paper size…"}),sh.map((M)=>y("option",{value:M.id,children:[M.label," — ",M.width,"×",M.height,M.unit]},M.id))]}):O==="web"?y("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:k??"",onChange:(M)=>{let F=Os[M.currentTarget.value];if(F)_(F.width,null)},children:[l("option",{value:"",disabled:!0,children:k?`${Os[k].label} — ≤ ${Os[k].width}px`:"Breakpoint…"}),Object.entries(Os).map(([M,F])=>y("option",{value:M,children:[F.label," — ≤ ",F.width,"px breakpoint"]},M))]}):y("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:v??"",onChange:(M)=>{let F=Os[M.currentTarget.value];if(F)_(F.width,F.height)},children:[l("option",{value:"",disabled:!0,children:v?Os[v].label:"Preset size…"}),Object.entries(Os).map(([M,F])=>y("option",{value:M,children:[F.label," — ",F.width,"×",F.height]},M))]})}),l("div",{style:{padding:"0 12px 8px"},children:l(zh,{value:I?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(M)=>D(M==="fixed")})}),l("div",{className:"st-cp-sechd-row",children:l("span",{className:"st-cp-sechd",children:"Kind"})}),l("div",{style:{padding:"0 12px 8px"},children:l(Vl,{value:O,ariaLabel:"artboard kind",options:Vbe.map(([M,F])=>({value:M,label:F})),onChange:V})}),O!=="print"&&u&&i?l("div",{style:{padding:"0 12px 8px"},children:y("select",{className:"st-cp-nsel","aria-label":"duplicate artboard at breakpoint width",value:"",onChange:(M)=>{let F=Os[M.currentTarget.value];if(F)i(u,F.width);M.currentTarget.value=""},children:[l("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(Os).map(([M,F])=>y("option",{value:M,children:[F.label," — ",F.width,"px"]},M))]})}):null,O==="print"?y(te,{children:[l("div",{className:"st-cp-sechd-row",children:l("span",{className:"st-cp-sechd",children:"Print"})}),l("div",{style:{padding:"0 12px 8px"},children:l(zh,{value:H?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(M)=>q({orientation:M})})}),l("div",{style:{padding:"0 12px 8px"},children:l(Sr,{value:Number.isFinite(H?.bleedMm)?H.bleedMm:3,min:0,step:0.5,ariaLabel:"bleed, millimeters",lead:"B",steppers:!1,unitSlot:l("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"mm"}),onCommit:(M)=>q({bleedMm:M})})})]}):null,l("div",{className:"st-cp-sechd-row",children:l("span",{className:"st-cp-sechd",children:"Style"})}),y("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let M=b(A),F=/var\(\s*--/.test(A),X=F?A.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):A;return l(xp,{swatch:l(Ap,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:m("color"),current:A,activeDs:f,swatchBg:M,seedHex:Ad(M)||"#000000",onPick:(K)=>z({background:K||null}),label:"artboard background colour"}),displayValue:X,bound:F,ariaLabel:"artboard background",onValue:(K)=>z({background:(K||"").trim()||null})})})(),l(Vl,{value:E,ariaLabel:"artboard body layout",options:qbe.map(([M,F])=>({value:M,label:F})),onChange:(M)=>z({layout:M||null})}),y("div",{style:{display:"flex",gap:8},children:[l(Bh,{value:/^var\(/.test(N)?N:Number.parseFloat(N)||0,tokens:h("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(M)=>z({padding:typeof M==="string"?M:M>0?M:null})}),l(Bh,{value:/^var\(/.test(R)?R:Number.parseFloat(R)||0,tokens:h("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(M)=>z({gap:typeof M==="string"?M:M>0?M:null})})]})]})]})}var Yv=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,Gbe=new RegExp(Yv.source,"gi");function Wbe(e){if(!e||Array.isArray(e))return null;if(e.photoAsset)return e.photoAsset;let t=e.html||"";if((e.tag||"").toLowerCase()!=="img"){let r=[...new Set(t.match(Gbe)||[])],s=[...new Set([...t.matchAll(/data-photo-asset="([^"]+)"/g)].map((o)=>o[1]))];if(s.length===1)return s[0];if(s.length===0&&r.length===1&&/<img/i.test(t))return r[0];return null}let a=/data-photo-asset="([^"]+)"/.exec(t);if(a)return a[1];let n=Yv.exec(`${e.attrs?.src||""} ${t}`);return n?n[0]:null}function wE({testId:e,selected:t,onClose:a,layersTree:n,componentMap:r,lockedKeys:s,onToggleLock:o,onDetachInstance:i,canvasFile:u,onSelectLayer:c,onHoverLayer:f,onReorderLayer:p,layersBusyRef:m,cfg:h,onOptimistic:b,onRecordEdit:w,onReplaceMedia:S,onResizeArtboard:_,onSetArtboardHug:v,onSetArtboardStyle:k,onSetArtboardKind:I,onSetArtboardPrint:A,onDuplicateArtboard:N,onUndoRedo:E,editScope:R,tab:O,onTabChange:H,width:V,resizing:q,photoSel:D,photoRev:U,onPhotoEdit:z,onPhotoRemoveBackground:M,onPhotoRecordEdit:F,onPhotoUndoRedo:X,layersOnly:K=!1,hideLayersTab:ie=!1,cpMode:G,onSetCpMode:se}){let[Z,pe]=P("inspect"),oe=K?"layers":O??Z,ye=(be)=>{pe(be),H?.(be)},[Je,Ke]=P(()=>new Set),[ot,yt]=P(()=>new Map);ee(()=>{let be=Array.isArray(t)?t[0]:t,Te=be?.id;if(!Te||!n?.nodes)return;let tt=be.index,we=null,Ue=[];if(function lt(le,We){for(let xt of le||[]){let Wt=`${xt.id}:${xt.index}`;if(!xt.synthetic&&xt.id===Te&&(tt==null||xt.index===tt))return we=Wt,Ue.push(...We),!0;if(xt.children&&xt.children.length&&lt(xt.children,[...We,Wt]))return!0}return!1}(n.nodes,[]),!we)return;if(Ue.length)Ke((lt)=>{let le=!1,We=new Set(lt);for(let xt of Ue)if(We.delete(xt))le=!0;return le?We:lt});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${we}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[t,n]);let rt=(be)=>{let Te=`${be.id}:${be.index}`;return ot.has(Te)?ot.get(Te):!!be.hidden},[nt,bt]=P(null),[kt,Se]=P(""),qe=(be,Te)=>{if(!u||!be?.id)return;_2(fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:u,id:be.id,attr:"data-dc-element",value:Te})}).then((tt)=>tt.json().catch(()=>({}))).then((tt)=>{if(!tt.ok)return;w?.({op:"attr",canvas:u,id:be.id,key:"data-dc-element",before:be.dcElement??null,after:Te})}).catch(()=>{}))},_e=p?(be,Te,tt)=>{if(m?.current)return;if(be?.synthetic||Te?.synthetic)return;let we=tt==="before"?`before ${Te.label}`:tt==="after"?`after ${Te.label}`:`into ${Te.label}`;Se(`Moved ${be.label} ${we}`),p(be.id,Te.id,tt,{idIndex:be.index,refIndex:Te.index})}:void 0,Ye=()=>{let be=[];return function Te(tt,we,Ue){(tt||[]).forEach((lt,le)=>{if(be.push({node:lt,depth:we,parentNode:Ue,siblings:tt,pos:le}),lt.children&&lt.children.length&&!Je.has(`${lt.id}:${lt.index}`))Te(lt.children,we+1,lt)})}(n?.nodes,0,null),be},He=(be)=>{if(be.key!=="ArrowUp"&&be.key!=="ArrowDown")return;if(!Be)return;let Te=Ye(),tt=Te.findIndex((le)=>le.node.id===Be.id&&le.node.index===Be.index);if(tt<0)return;let we=be.key==="ArrowDown"?1:-1,Ue=Te[tt];if(!be.altKey){let le=Te[tt+we];if(le)be.preventDefault(),c?.(le.node);return}if(!_e||!Array.isArray(Ue.siblings))return;be.preventDefault();let lt=(le)=>le&&le.children&&le.children.length&&!Je.has(`${le.id}:${le.index}`);if(!be.shiftKey){if(we<0&&Ue.pos>0)_e(Ue.node,Ue.siblings[Ue.pos-1],"before");else if(we>0&&Ue.pos<Ue.siblings.length-1)_e(Ue.node,Ue.siblings[Ue.pos+1],"after");return}if(we>0){let le=Ue.siblings[Ue.pos+1];if(le)_e(Ue.node,le,lt(le)?"inside-start":"after");else if(Ue.parentNode)_e(Ue.node,Ue.parentNode,"after")}else{let le=Ue.siblings[Ue.pos-1];if(le)_e(Ue.node,le,lt(le)?"inside-end":"before");else if(Ue.parentNode)_e(Ue.node,Ue.parentNode,"before")}},ht=me(null),Xt=me(null),Ne=(be,Te,tt)=>{if(!_e||be.button!==0||be.metaKey||be.ctrlKey||be.shiftKey||be.altKey)return;if(m?.current)return;let{clientX:we,clientY:Ue}=be,lt=new Set([tt]);(function Vt(ke){(ke.children||[]).forEach((dt)=>{lt.add(`${dt.id}:${dt.index}`),Vt(dt)})})(Te);let le=14,We=6,xt=[];(function Vt(ke,dt){(ke||[]).forEach((Bt)=>{let oa=`${Bt.id}:${Bt.index}`;if(xt.push({node:Bt,key:oa,id:Bt.id,depth:dt,tag:Bt.tag}),Bt.children&&Bt.children.length&&!Je.has(oa))Vt(Bt.children,dt+1)})})(n?.nodes,0);let Wt=new Map(xt.map((Vt)=>[Vt.key,Vt])),pa=!1,Qa=(Vt)=>{if(!pa){if(Math.hypot(Vt.clientX-we,Vt.clientY-Ue)<4)return;pa=!0}let ke=Vt.clientX-we,dt=Vt.clientY-Ue,Bt=null,oa=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((Va)=>({rect:Va.getBoundingClientRect(),it:Wt.get(Va.getAttribute("data-layer-key"))})).filter((Va)=>Va.it&&Va.it.key!==tt);if(oa.length){let Va=oa[0].rect.left,Ve=oa[0].rect.right,B=oa.length;for(let Ta=0;Ta<oa.length;Ta++)if(Vt.clientY<oa[Ta].rect.top+oa[Ta].rect.height/2){B=Ta;break}let ae=oa[B-1]?.it||null,de=oa[B]?.it||null,Ce=Math.round((Vt.clientX-Va-We)/le),Pe=ae?ae.depth+(yE.has(ae.tag)?0:1):0,ct=de?de.depth:0,ft=Math.max(ct,Math.min(Ce,Pe)),Ot=null,Mt="before",da=0;if(!ae){if(de)Ot=de,Mt="before",da=de.depth}else if(ft>ae.depth)Ot=ae,Mt="inside-start",da=ae.depth+1;else if(ft===ae.depth)Ot=ae,Mt="after",da=ae.depth;else{for(let Ta=B-1;Ta>=0;Ta--)if(oa[Ta].it.depth===ft){Ot=oa[Ta].it;break}if(!Ot)Ot=ae;Mt="after",da=ft}if(Ot&&Ot.key!==tt&&!lt.has(Ot.key)){let Ta=ae?oa[B-1].rect.bottom:oa[0].rect.top,Ma=Va+We+da*le;Bt={refId:Ot.id,position:Mt,node:Ot.node,y:Ta,left:Ma,w:Math.max(24,Ve-Ma)}}}let Pa={key:tt,node:Te,dx:ke,dy:dt,target:Bt};ht.current=Pa,bt(Pa)},Pt=()=>{window.removeEventListener("pointermove",Qa),window.removeEventListener("pointerup",Dt),window.removeEventListener("keydown",Yt,!0)},pn=()=>{let Vt=(ke)=>{ke.preventDefault(),ke.stopImmediatePropagation(),document.removeEventListener("click",Vt,!0)};document.addEventListener("click",Vt,!0),setTimeout(()=>document.removeEventListener("click",Vt,!0),300)},Dt=()=>{Pt();let Vt=ht.current;if(ht.current=null,bt(null),pa&&Vt?.target)pn(),_e(Vt.node,Vt.target.node,Vt.target.position)},Yt=(Vt)=>{if(Vt.key!=="Escape")return;if(Vt.preventDefault(),Vt.stopImmediatePropagation(),Pt(),ht.current=null,bt(null),pa)pn()};window.addEventListener("pointermove",Qa),window.addEventListener("pointerup",Dt),window.addEventListener("keydown",Yt,!0)},At=(be)=>Ke((Te)=>{let tt=new Set(Te);if(tt.has(be))tt.delete(be);else tt.add(be);return tt}),ua=(be)=>{let Te=`${be.id}:${be.index}`,tt=rt(be),we=!tt;if(yt((Ue)=>new Map(Ue).set(Te,we)),b?.({id:be.id,artboardId:n?.artboardId??null,index:be.index,prop:"display",value:we?"none":null}),!u||!be.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(we?{canvas:u,id:be.id,property:"display",value:"none"}:{canvas:u,id:be.id,property:"display",reset:!0})}).catch(()=>{}),w?.({op:"css",canvas:u,id:be.id,key:"display",before:tt?"none":null,after:we?"none":null})},Be=Array.isArray(t)?t[0]:t,fe=D?{asset:D.asset,kind:"annotation-image"}:(()=>{let be=Wbe(Be);return be?{asset:be,kind:"artboard-img"}:null})(),Ze=fe?.kind==="annotation-image",he=(be)=>{if(!(be.metaKey||be.ctrlKey)||be.altKey)return;let Te=be.key.toLowerCase();if(Te==="z")be.preventDefault(),X?.(be.shiftKey?"redo":"undo");else if(Te==="y")be.preventDefault(),X?.("redo")},Le=Ze?"photo":oe==="photo"&&!fe?"css":oe,Ie=(be,Te,tt)=>y("button",{type:"button",className:"st-rp-tab"+(Le===be?" is-active":""),onClick:()=>ye(be),children:[l(ga,{name:tt,size:14}),Te]}),ue=Be?.bounds||null;return y("aside",{className:"st-rpanel"+(q?" is-resizing":""),style:V?{width:V,flexBasis:V}:void 0,"aria-label":"Inspector","data-tour":"inspector","data-testid":e,children:[y("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:K?{display:"none"}:void 0,children:[Ze?Ie("photo","Photo","image"):y(te,{children:[Ie("inspect","Inspect","sliders"),!ie&&Ie("layers","Layers","layers"),Ie("css","CSS","code"),fe?Ie("photo","Photo","image"):null]}),l("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:a,children:l(ga,{name:"x",size:14})})]}),Be?.id&&!(Array.isArray(t)&&t.length>1)&&R?y("div",{className:`st-scope st-scope--${R.scope}`,title:R.scope==="shared"?`Editing this element's style changes ${R.affects} place${R.affects===1?"":"s"}${R.componentName?` (component ${R.componentName})`:""}. Move/resize a whole instance to keep it local.`:"This edit affects only this element.",children:[l("span",{className:"st-scope-dot","aria-hidden":"true"}),R.scope==="shared"?`Shared${R.componentName?` · ${R.componentName}`:""} · edits ${R.affects} place${R.affects===1?"":"s"}`:"Local · this element only",R.scope==="shared"&&i?l("button",{type:"button",className:"st-scope-detach",title:"Clone this component for this instance only — edits stop affecting the other places",onClick:()=>i(Be.id,Be.index),children:"Detach"}):null]}):null,l("div",{className:"st-rp-body",children:Le==="photo"&&fe?l("div",{onKeyDown:he,children:l(TA,{asset:fe.asset,ColorPicker:Zv,StIcon:ga,onEdit:(be)=>z?.(fe.asset,be),onRemoveBackground:M,onRecordEdit:(be,Te)=>F?.(fe.asset,be,Te)},`${fe.asset}:${U??0}`)}):!Be&&!(Le==="layers"&&n?.nodes?.length)?l("div",{className:"st-rp-empty",children:y("p",{children:["Press ",l(Gn,{children:"V"}),", then click an element to select it — or ",l(Gn,{children:"⌘"}),"-click straight from Browse."]})}):Be&&Le==="inspect"?y(te,{children:[l("div",{className:"st-rp-hd",children:Be.selector||Be.tag||"element"}),y("div",{className:"st-insp-row",children:[l("span",{className:"st-insp-label",children:"Pos"}),y("div",{className:"st-insp-fields",children:[y("span",{className:"st-fmini",children:[l("span",{className:"st-mtag",children:"X"}),l("input",{value:ue?Math.round(ue.x):"—",readOnly:!0,"aria-label":"x position"})]}),y("span",{className:"st-fmini",children:[l("span",{className:"st-mtag",children:"Y"}),l("input",{value:ue?Math.round(ue.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),y("div",{className:"st-insp-row",children:[l("span",{className:"st-insp-label",children:"Size"}),y("div",{className:"st-insp-fields",children:[y("span",{className:"st-fmini",children:[l("span",{className:"st-mtag",children:"W"}),l("input",{value:ue?Math.round(ue.w):"—",readOnly:!0,"aria-label":"width"})]}),y("span",{className:"st-fmini",children:[l("span",{className:"st-mtag",children:"H"}),l("input",{value:ue?Math.round(ue.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),y("div",{className:"st-insp-row",children:[l("span",{className:"st-insp-label",children:"Tag"}),l("div",{className:"st-insp-fields",children:l("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:Be.tag||"—"})})]}),Be.classes?y("div",{className:"st-insp-row",children:[l("span",{className:"st-insp-label",children:"Class"}),l("div",{className:"st-insp-fields",children:l("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Be.classes})})]}):null,l(bE,{el:Be})]}):Le==="layers"?y(te,{children:[y("div",{className:"st-rp-hd",children:["Layers",n?.nodes?.length?"":" · ancestry"]}),n?.nodes?.length?y(te,{children:[_e?l("div",{className:"st-rp-hint","aria-hidden":"true",children:"Drag or ↑/↓ select · Alt+↑/↓ move · Alt+Shift+↑/↓ move across"}):null,l("div",{role:"tree","aria-label":"Artboard layers",tabIndex:0,ref:Xt,onKeyDown:He,children:n.nodes.map((be,Te)=>l(S2,{node:be,depth:0,selectedId:Be?.id,selectedIndex:Be?.index,collapsed:Je,hiddenOverride:ot,onToggle:At,onSelect:(tt)=>{c?.(tt),Xt.current?.focus()},onHover:(tt)=>f?.(tt),onToggleVisibility:ua,onReorder:_e,onRowPointerDown:Ne,dragState:nt,componentMap:r,lockedKeys:s,onToggleLock:o,onRename:qe},`${be.id}:${be.index}`))}),nt?.target?l("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:nt.target.left,top:nt.target.y-1,width:nt.target.w}}):null,l("div",{className:"sr-only",role:"status","aria-live":"polite",children:kt})]}):Be&&Array.isArray(Be.dom_path)&&Be.dom_path.length?Be.dom_path.map((be,Te)=>y("div",{className:"st-layer"+(Te===Be.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+Te*12},children:[l(ga,{name:"square",size:13}),be]},Te)):l("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!Be.id&&C2(Be)?l(vE,{el:Be,cfg:h,onResizeArtboard:_,onSetArtboardHug:v,onSetArtboardStyle:k,onSetArtboardKind:I,onSetArtboardPrint:A,onDuplicateArtboard:N}):l(hE,{el:Be,cfg:h,onOptimistic:b,onRecordEdit:w,onReplaceMedia:S,onUndoRedo:E,mode:G,onSetMode:se})})]})}function Uj({groups:e,treeLoaded:t,treeLoadFailures:a,project:n,activePath:r,previewPath:s,onPreview:o,selected:i,editScope:u,layersBusyRef:c,layersTree:f,componentMap:p,wsConnected:m,syncStatus:h,cloudLinkedHub:b,setCloudLinkedHub:w,localProjectName:S,setLocalProjectName:_,gitStatus:v,remoteSync:k,changesOpen:I,setChangesOpen:A,syncPanelOpen:N,setSyncPanelOpen:E,setDiffTarget:R,search:O,setSearch:H,systemData:V,dragSide:q,cfg:D,cellManaged:U,cloudManaged:z,savingIsManaged:M,viewerMode:F,commentsByFile:X,focusedCommentId:K,commentsPanelOpen:ie,commentsFilter:G,setCommentsFilter:se,cpMode:Z,setCpMode:pe,sidebarOpen:oe,showHidden:ye,treeExp:Je,sectionsExpanded:Ke,setHelpOpen:ot,setReportBugOpen:yt,setShortcutsOpen:rt,setExportDialog:nt,setSettingsOpen:bt,setGenerateOpen:kt,inspectorOpen:Se,setInspectorOpen:qe,layersOpen:_e,setLayersOpen:Ye,panelSide:He,layersMode:ht,assistantOpen:Xt,inspectorTab:Ne,setInspectorTab:At,photoSel:ua,photoRev:Be,openPanelExclusive:fe,togglePanel:Ze,openRightPanel:he,toggleRightPanel:Le,whatsNew:Ie,postToActiveCanvas:ue,onPhotoEdit:be,onPhotoRecordEdit:Te,performPhotoUndo:tt,onPhotoRemoveBackground:we,lockedKeys:Ue,toggleLockedKey:lt,toggleSection:le,treeExpansion:We,toggleTheme:xt,gitCommit:Wt,gitDiscard:pa,gitPublish:Qa,gitGetLatest:Pt,gitLoadLog:pn,cloudHistory:Dt,gitLoadCloudLog:Yt,projectHistoryOn:Vt,setProjectHistoryOn:ke,projectHistoryRefresh:dt,loadAcceptedLog:Bt,restoreProjectVersion:oa,dirtyByPath:Pa,openTab:Va,openLinkedFile:Ve,sharePath:B,shareShell:ae,shareLinksFor:de,showShare:Ce,openSystem:Pe,reloadActive:ct,treeRefreshing:ft,refreshTree:Ot,createBoard:Mt,createVideo:da,deleteBoard:Ta,moveCanvasReq:Ma,newFolderReq:Or,deleteFolderReq:Qr,renameFolderReq:De,renameCanvasReq:Ge,duplicateCanvasReq:Nt,deleteFileReq:Ut,applyOptimisticStyle:ka,recordSourceEdit:it,reorderLayer:$a,detachInstanceShell:Q,resizeArtboardShell:Ee,duplicateArtboardShell:et,setArtboardHugShell:Rt,setArtboardStyleShell:Zt,setArtboardKindShell:Ht,setArtboardPrintShell:jn,onReplaceMedia:Mn,resolveComment:va,reopenComment:xn,deleteComment:ja,jumpToComment:cn}){let Nn=Kt(()=>[{id:"new",group:"Canvas",label:"New canvas…",icon:"plus",kbd:"N",run:()=>{fe("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60)}},{id:"new-video",group:"Canvas",label:"New video…",icon:"plus",run:()=>da()},{id:"export",group:"Canvas",label:"Export…",icon:"download",kbd:"⇧⌘E",run:()=>nt({mode:"export"})},{id:"share-link",group:"Canvas",label:"Copy share link",icon:"link",run:()=>{let W=de(B),J=W.web??W.app??W.local;if(J)Rh(J)}},{id:"handoff",group:"Canvas",label:"Handoff to production",icon:"external",kbd:"⇧⌘H",run:()=>nt({mode:"handoff"})},{id:"generate",group:"Canvas",label:"Generate with AI…",icon:"sparkle",run:()=>kt(!0)},{id:"settings",group:"Canvas",label:"Settings…",icon:"sliders",kbd:"⌘,",run:()=>bt(!0)},{id:"system",group:"View",label:"Open design system view",icon:"sliders",kbd:"S",run:()=>Pe()},{id:"comments",group:"View",label:"Toggle comments panel",icon:"resolve",kbd:"⌘⇧M",run:()=>Le("comments")},{id:"inspector",group:"View",label:"Open inspector",icon:"sliders",kbd:"⌘⇧I",run:()=>he("inspector")},{id:"reload",group:"View",label:"Reload active canvas",icon:"reload",kbd:"⌘R",run:()=>ct()},{id:"draw",group:"Tools",label:"Draw a mark with the SVG agent",icon:"pen",run:()=>{try{navigator.clipboard?.writeText("/design:draw ")}catch{}}},{id:"theme",group:"Tools",label:"Toggle light / dark theme",icon:"sun",run:()=>xt()},{id:"whatsnew",group:"Help",label:"What's new in maude",icon:"sparkle",run:()=>Ie.openPanel()},{id:"shortcuts",group:"Help",label:"Keyboard shortcuts",icon:"help",kbd:"?",run:()=>rt(!0)},{id:"help",group:"Help",label:"Help · commands & flows",icon:"help",kbd:"F1",run:()=>ot(!0)},{id:"report-bug",group:"Help",label:"Report a bug…",icon:"help",run:()=>yt(!0)}],[Pe,xt,ct,Ie,da,B,ae,b,S,D.designRel]),Dr=(W)=>{if(F&&W==="assistant")return!1;if(W==="sync")return!!h;return W==="assistant"?na():W==="layers"?ht==="separate":!0},Xr=(W)=>Kh.filter((J)=>Dr(J.id)&&(He[J.id]||Wl[J.id])===W).map((J)=>J.id),Bs={tree:oe,layers:_e,inspector:Se,comments:ie,changes:I,sync:N,assistant:Xt},ps=D.cloud?{changes:"History"}:null,mo=Xr("left"),Zo=Xr("right"),Yo=mo.find((W)=>Bs[W])||null,Pr=Zo.find((W)=>Bs[W])||null,Us=na()&&!F&&(He.assistant||"right")==="left",ms=na()&&!F&&(He.assistant||"right")==="right",Cr=(W)=>(He[W]||Wl[W])==="left"?q==="sb":q==="rp",hs=r&&r!==Ft&&/\.(tsx|html)$/i.test(r)?r:null,Cs=hs?kp(X[hs]):0;return{activeCanvasFile:hs,activeOpenComments:Cs,dockLabels:ps,leftActive:Yo,leftHostsAssistant:Us,leftIds:mo,paletteActions:Nn,renderPanelBody:(W)=>{if(W==="tree")return l(sE,{cloud:D.cloud,readOnly:F,groups:Je.ready?e:WA,activePath:r,previewPath:s,activeDsName:r===Ft?V?.ds?.name??null:null,onOpen:Va,onPreview:o,onOpenLinkedFile:Ve,filesReady:t,treeLoadFailures:a,onShare:Ce,onOpenSystem:Pe,wsConnected:m,search:O,setSearch:H,commentsByFile:X,showHidden:ye,sectionsExpanded:Ke,onToggleSection:le,treeExpansion:We,onNewBoard:Mt,onDeleteBoard:Ta,onMoveCanvas:Ma,onNewFolder:Or,onDeleteFolder:Qr,onRenameFolder:De,onRenameCanvas:Ge,onDuplicateCanvas:Nt,onDeleteFile:Ut,onRefresh:Ot,refreshing:ft,collapsed:!1,onCollapse:()=>Ze("tree"),resizing:Cr("tree"),dirtyByPath:Pa,project:n,gitBranch:v?.branch,remoteSync:k,onGetLatest:Pt,canvasKinds:D?.canvasKinds,syncStatus:h,onLinkedHub:w,onLocalProject:_,savingIsManaged:M});if(W==="changes")return l(S_,{status:v&&k?{...v,...k}:v,project:n,readOnly:!na()||F,historyOnly:U,cloudManaged:z,resizing:Cr("changes"),onClose:()=>A(!1),onCommit:Wt,onDiscard:pa,onPublish:Qa,onGetLatest:Pt,loadLog:async(J)=>{let xe=await Bt(J);if(ke(xe!=="legacy"),xe!=="legacy")return xe;return(z?Yt:pn)(J)},historySource:Vt?"project":z?"cloud":"local",historyRefresh:`${h?.appliedRevision??0}:${dt}`,onRestoreVersion:(J)=>oa(r,J).then((xe)=>!!xe.ok),onUndoAction:U?void 0:async(J)=>{let xe=await fetch("/_api/project/undo",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionId:J})}).catch(()=>null);return!!(xe?await xe.json().catch(()=>null):null)?.ok},cloudHistory:Dt,onOpenCanvas:(J)=>Va(J),onOpenDiff:(J)=>R({file:J,beforeSha:"HEAD",conflict:!1}),activeCanvas:hs,onPreviewVersion:(J)=>R({file:r,beforeSha:J,conflict:!1}),designRel:(D?.designRel||D?.designRoot||".design").replace(/^\/+|\/+$/g,"")});if(W==="sync")return l(M_,{status:h,project:D?.cloud?.projectName||n,cloud:D?.cloud??null,groupPaths:(e||[]).map((J)=>J.path).filter(Boolean),resizing:Cr("sync"),onClose:()=>E(!1)});if(W==="inspector"||W==="layers")return l(wE,{testId:W==="layers"?"layers-panel":"inspector-panel",layersOnly:W==="layers",hideLayersTab:ht==="separate",cpMode:Z,onSetCpMode:pe,selected:i,cfg:D,tab:W==="layers"?"layers":Ne,onTabChange:At,onClose:()=>W==="layers"?Ye(!1):qe(!1),onOptimistic:ka,onRecordEdit:it,onReplaceMedia:Mn,onResizeArtboard:Ee,onSetArtboardHug:Rt,onSetArtboardStyle:Zt,onSetArtboardKind:Ht,onSetArtboardPrint:jn,onDuplicateArtboard:et,editScope:u,onUndoRedo:(J)=>ue({dgn:J}),photoSel:ua,photoRev:Be,onPhotoEdit:be,onPhotoRemoveBackground:we,onPhotoRecordEdit:Te,onPhotoUndoRedo:(J)=>tt(J==="redo"),layersTree:f,componentMap:p,lockedKeys:Ue,onToggleLock:lt,onDetachInstance:Q,canvasFile:r,onSelectLayer:(J)=>ue({dgn:"select-by-id",id:J.id,artboardId:f?.artboardId,index:J.index}),onHoverLayer:(J)=>ue({dgn:"highlight",id:J?J.id:null,artboardId:f?.artboardId,index:J?J.index:0}),onReorderLayer:$a,layersBusyRef:c,resizing:Cr(W)});if(W==="comments")return l(lE,{commentsByFile:X,filter:G,setFilter:se,activePath:r,focusedId:K,onJump:cn,onResolve:F?void 0:va,onReopen:F?void 0:xn,onDelete:F?void 0:ja,resizing:Cr("comments")});return null},resizingFor:Cr,rightActive:Pr,rightHostsAssistant:ms,rightIds:Zo}}function Fj({activePath:e,selected:t,viewerMode:a,commentsByFile:n,focusedCommentId:r,setFocusedCommentId:s,sidebarOpen:o,setShowHidden:i,setHelpOpen:u,setShortcutsOpen:c,setPaletteOpen:f,setExportDialog:p,setSettingsOpen:m,inspectorTab:h,openPanelExclusive:b,togglePanel:w,toggleRightPanel:S,toggleTimeline:_,presentMode:v,iframesRef:k,postToActiveCanvas:I,performPhotoUndo:A,tlKeyRef:N,exitPresent:E,openSystem:R,closeTab:O,reloadActive:H,refreshTree:V,clearActiveCanvasSelection:q}){ee(()=>{function M(F){let X=F.metaKey||F.ctrlKey,K=["INPUT","TEXTAREA"].includes(document.activeElement?.tagName)||document.activeElement?.isContentEditable,ie=document.activeElement?.tagName==="IFRAME";if(v&&F.key==="Escape"){F.preventDefault(),E();return}if(X&&(F.key==="k"||F.key==="K")){F.preventDefault(),f((G)=>!G);return}if(X&&!F.altKey&&(F.key==="z"||F.key==="Z"||F.key==="y"||F.key==="Y")){if(!K&&!ie&&e&&e!==Ft){if((F.key==="z"||F.key==="Z")&&N.current.open&&N.current.comps?.length)return;let G=F.key==="y"||F.key==="Y"||F.shiftKey;if(h==="photo"&&A(G)){F.preventDefault();return}F.preventDefault(),I({dgn:G?"redo":"undo"});return}}if(X&&F.shiftKey&&(F.key==="r"||F.key==="R")){F.preventDefault(),V();return}if(X&&(F.key==="r"||F.key==="R")){F.preventDefault(),H();return}if(X&&F.shiftKey&&(F.key==="m"||F.key==="M")){F.preventDefault(),S("comments");return}if(X&&F.shiftKey&&(F.key==="g"||F.key==="G")){F.preventDefault(),S("changes");return}if(X&&F.shiftKey&&(F.key==="i"||F.key==="I")){F.preventDefault(),S("inspector");return}if(X&&F.shiftKey&&(F.key==="a"||F.key==="A")&&na()){if(F.preventDefault(),!a)S("assistant");return}if(X&&F.shiftKey&&(F.key==="e"||F.key==="E")){F.preventDefault(),p({mode:"export"});return}if(X&&F.shiftKey&&(F.key==="h"||F.key==="H")){F.preventDefault(),p({mode:"handoff"});return}if(X&&!F.shiftKey&&!F.altKey&&F.key===","){if(F.preventDefault(),!a)m(!0);return}if(X&&F.shiftKey&&(F.key==="t"||F.key==="T")){F.preventDefault(),_();return}if(X&&!F.shiftKey&&!F.altKey&&(F.key==="c"||F.key==="C")){if(t&&t.selector&&e&&e!==Ft&&!K&&console&&console.warn)console.warn("Cmd+C comment-drop deprecated — press C inside the canvas to enter Comment tool, then click the element.")}if(K)return;if(F.key==="/"){F.preventDefault();let G=document.querySelector(".st-search input");if(G)G.focus();return}if(X&&(F.key==="f"||F.key==="F")){if(F.preventDefault(),!o)b("tree");setTimeout(()=>{let G=document.querySelector(".st-search input");if(G)G.focus()},0);return}if(ie){if(F.key!=="Escape")return}if(F.key==="t"||F.key==="T"){if(F.shiftKey||X)return;F.preventDefault(),w("tree");return}if(F.key==="h"||F.key==="H"){if(F.shiftKey||X)return;F.preventDefault(),i((G)=>!G);return}if((F.key==="s"||F.key==="S")&&!X&&!F.shiftKey){if(F.preventDefault(),e===Ft)O(Ft);else R();return}if((F.key==="n"||F.key==="N")&&!X&&!F.shiftKey){F.preventDefault(),b("tree"),setTimeout(()=>document.querySelector('[aria-label="New blank brief board"]')?.click(),60);return}if(F.key==="?"){F.preventDefault(),c((G)=>!G);return}if(F.key==="F1"){F.preventDefault(),u(!0);return}if(F.key==="Escape"){if(r){s(null);return}}}return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[H,V,t,e,r,o,R,O,q,v,E,_,h,A,a]);let D=ce((M,F)=>{if(F)k.current.set(M,F)},[]),U=Gv(n).open;return{onShellContextMenu:ce((M)=>{let F=M.target;if(F&&(F.tagName==="INPUT"||F.tagName==="TEXTAREA"||F.isContentEditable))return;M.preventDefault()},[]),registerIframe:D,totalOpen:U}}var k2=(e)=>(Array.isArray(e)?e[0]:e)??null;function jj(e,t,a=Date.now()){if(!t||a-t.at>=2000)return!1;let n=k2(e);if(n==null)return k2(t.sel)==null;return n.file===t.file}function I2(e,t,a=Date.now()){return{at:a,sel:e??null,file:k2(e)?.file??t??null}}function Hj(e,t,a){let n=k2(e),r=n!=null&&n.file===t;return{activeArtboardId:(r?n.artboardId:null)??a??null,selection:r&&n.selector?{selector:n.selector,file:n.file}:null}}function qj({activePath:e,selected:t,setSelected:a,selectedRef:n,lastLocalSelectRef:r,scheduleHaloRestore:s,scheduleArtboardResync:o,pendingReorderRef:i,lastLayersTreeRef:u,settlePendingSelectionRef:c,reorderLayerRef:f,repositionElementRef:p,resizeElementRef:m,layersBusyRef:h,layersBusyTimerRef:b,layersTree:w,setLayersTree:S,setLoadingPath:_,setCanvasError:v,setLoadedPath:k,cfg:I,viewerMode:A,commentsByFile:N,focusedCommentId:E,setFocusedCommentId:R,theme:O,setPaletteOpen:H,setExportDialog:V,setTimelineOpen:q,setActiveComps:D,setTimelineFrame:U,setTimelinePlaying:z,canvasActiveArtboard:M,setCanvasActiveArtboard:F,timelineFrameRef:X,timelineCompIdRef:K,setInspectorTab:ie,setPhotoSel:G,openRightPanel:se,toggleRightPanel:Z,maybeAutoOpenInspectorOnSelect:pe,toggleTimeline:oe,minimapVisible:ye,zoomCtlVisible:Je,presentMode:Ke,setPresentMode:ot,setActiveArtboards:yt,iframesRef:rt,postToActiveCanvas:nt,captureFromCanvas:bt,broadcastChrome:kt,wsSend:Se,reloadActive:qe}){ee(()=>{let De=(it)=>!!e&&(N[e]||[]).some(($a)=>$a&&$a.id===it);function Ge(it){let $a=I?.canvasOrigin||window.location.origin;if(it.origin!==$a)return;let Q=it.data;if(!Q||typeof Q!=="object"||!Q.dgn)return;if(Q.dgn==="canvas-notice"){let Ee=e&&e!==Ft?rt.current.get(e)?.contentWindow:null,et=MA(it,$a,Ee);if(et)M3(et.title,et.kind);return}if(Q.dgn==="tool-cursor"){if(Q.tool==="browse"){document.body.style.cursor="";let et=document.getElementById("dc-app-cursor");if(et)et.textContent="";Vh(A);return}let Ee=AI(Q.tool);if(Ee){document.body.style.cursor=Ee;let et=document.getElementById("dc-app-cursor");if(!et)et=document.createElement("style"),et.id="dc-app-cursor",document.head.appendChild(et);et.textContent=`* { cursor: ${Ee} !important; }`}return}if(Q.dgn==="select"||Q.dgn==="select-set"||Q.dgn==="clear-select"||Q.dgn==="edit-text"||Q.dgn==="apply-edit"||Q.dgn==="undo-barrier"){let Ee=e&&e!==Ft?rt.current.get(e)?.contentWindow:null;if(it.source!==Ee)return}if(Q.dgn==="select"&&Q.selection)G(null),r.current=I2(Q.selection,e),Se({type:"select",selection:Q.selection}),a(Q.selection),pe(Q.selection);else if(Q.dgn==="select-set"){G(null),r.current=I2(Q.selection,e);let Ee=Q.selection;if(Ee==null)Se({type:"clear-select"}),a(null);else if(Array.isArray(Ee)){let et=Ee[0]??null;if(et)Se({type:"select",selection:et});if(a(et),Ee.length===1)pe(et)}else Se({type:"select",selection:Ee}),a(Ee),pe(Ee)}else if(Q.dgn==="clear-select")G(null),r.current=I2(null,e),Se({type:"clear-select"}),a(null);else if(Q.dgn==="edit-text"&&Q.id){let Ee=it.source,et=(Rt)=>{try{Ee?.postMessage({dgn:"edit-reverted",op:"text",id:Q.id,reason:Rt},"*")}catch{}};fetch("/_api/edit-text",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Q.file,id:Q.id,text:Q.text??"",...typeof Q.occurrence==="number"?{occurrence:Q.occurrence}:{},...typeof Q.before==="string"?{before:Q.before}:{}})}).then((Rt)=>Rt.json().catch(()=>({}))).then((Rt)=>{if(!Rt.ok)et(Rt.error||"this element can't be edited inline")}).catch(()=>et("network error"))}else if(Q.dgn==="undo-barrier"&&typeof Q.requestId==="string"){let Ee=it.source;Promise.all([ht.current.catch(()=>{}),mE()]).then(()=>{try{Ee?.postMessage({dgn:"undo-barrier-ok",requestId:Q.requestId},"*")}catch{}})}else if(Q.dgn==="apply-edit"&&Q.id&&(Q.op==="css"||Q.op==="text"||Q.op==="attr")){let Ee=zI(Q);if(!Ee)return;let et=it.source,Rt=(Ht)=>{if(typeof Q.requestId!=="string")return;try{et?.postMessage({dgn:"apply-edit-result",requestId:Q.requestId,...Ht},"*")}catch{}},Zt=typeof Q.value==="string"?Q.value:null;ht.current=ht.current.catch(()=>{}).then(()=>fetch(Ee.url,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(Ee.body)}).then((Ht)=>Ht.json().catch(()=>({}))).then((Ht)=>{if(Ht.ok){if(Ee.op==="css")Ye({id:Q.id,prop:Q.key,value:Zt});Rt({ok:!0});return}console.warn("[apply-edit]",Ee.op,Ht.error||"failed"),Rt({ok:!1,error:Ht.error||"failed",conflict:Ht.conflict===!0})}).catch(()=>Rt({ok:!1,error:"network error"})))}else if(Q.dgn==="layers-tree"){S({artboardId:Q.artboardId,nodes:Array.isArray(Q.tree)?Q.tree:[]});let Ee=QA(Q.tree);if(u.current={tree:Q.tree,sig:Ee,artboardId:Q.artboardId??null},h.current=!1,b.current)clearTimeout(b.current),b.current=null;c.current?.(Q.tree,Ee,Q.artboardId??null)}else if(Q.dgn==="reorder-revert"){let Ee=e?rt.current.get(e)?.contentWindow:null,et=typeof Q.seq==="number"&&(Q.dir==="undo"||Q.dir==="redo");if(it.source===Ee&&et&&e){if(h.current=!0,b.current)clearTimeout(b.current);b.current=setTimeout(()=>{h.current=!1,b.current=null},700),fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:e,seq:Q.seq,dir:Q.dir})}).then((Rt)=>Rt.json().catch(()=>({}))).then((Rt)=>{if(!Rt.ok)console.warn("[reorder-revert]",Rt.error||"failed")}).catch(()=>{})}}else if(Q.dgn==="reorder-request"){let Ee=e?rt.current.get(e)?.contentWindow:null,et=typeof Q.id==="string"&&typeof Q.refId==="string"&&(Q.position==="before"||Q.position==="after"||Q.position==="inside-start"||Q.position==="inside-end");if(it.source===Ee&&et)f.current?.(Q.id,Q.refId,Q.position,{idIndex:Number.isInteger(Q.idIndex)?Q.idIndex:void 0,refIndex:Number.isInteger(Q.refIndex)?Q.refIndex:void 0})}else if(Q.dgn==="reposition-request"){let Ee=e?rt.current.get(e)?.contentWindow:null,et=typeof Q.id==="string"&&Number.isFinite(Q.left)&&Number.isFinite(Q.top)&&Number.isFinite(Q.beforeLeft)&&Number.isFinite(Q.beforeTop);if(it.source===Ee&&et)p.current?.(Q.id,Q.left,Q.top,Q.beforeLeft,Q.beforeTop,Number.isInteger(Q.idIndex)?Q.idIndex:void 0)}else if(Q.dgn==="resize-request"){let Ee=e?rt.current.get(e)?.contentWindow:null,et=typeof Q.id==="string"&&Q.patch&&typeof Q.patch==="object";if(it.source===Ee&&et)m.current?.(Q.id,Q.patch,Q.before,Number.isInteger(Q.idIndex)?Q.idIndex:void 0)}else if(Q.dgn==="delete-request"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee&&typeof Q.id==="string")Yt.current?.(Q.id,Number.isInteger(Q.idIndex)?Q.idIndex:void 0)}else if(Q.dgn==="duplicate-request"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee&&typeof Q.id==="string")Pa.current?.(Q.id,Number.isInteger(Q.idIndex)?Q.idIndex:void 0)}else if(Q.dgn==="copy-style"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee)Ve.current?.()}else if(Q.dgn==="paste-style"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee&&typeof Q.id==="string")B.current?.(Q.id)}else if(Q.dgn==="insert-request"){let Ee=e?rt.current.get(e)?.contentWindow:null,et=typeof Q.refId==="string",Rt=typeof Q.artboardId==="string",Zt=Q.position==="before"||Q.position==="after"||Q.position==="inside-start"||Q.position==="inside-end",Ht=et!==Rt&&(Q.kind==="div"||Q.kind==="text"||Q.kind==="image")&&Zt&&(!Rt||Q.position==="inside-start"||Q.position==="inside-end");if(it.source===Ee&&Ht)Vt.current?.(Q.refId,Q.position,Q.kind,{artboardId:Rt?Q.artboardId:void 0,src:typeof Q.src==="string"?Q.src:void 0,refIndex:Number.isInteger(Q.refIndex)?Q.refIndex:void 0})}else if(Q.dgn==="insert-image-request"){let Ee=e?rt.current.get(e)?.contentWindow:null,et=typeof Q.refId==="string",Rt=typeof Q.artboardId==="string",Zt=!et&&!Rt,Ht=(et!==Rt||Zt)&&(Zt||Q.position==="before"||Q.position==="after"||Q.position==="inside-start"||Q.position==="inside-end")&&(!Rt||Q.position==="inside-start"||Q.position==="inside-end");if(it.source===Ee&&Ht)Ce.current?.({purpose:"insert-image",canvas:e,refId:Q.refId,artboardId:Rt?Q.artboardId:void 0,position:Zt?void 0:Q.position,refIndex:Number.isInteger(Q.refIndex)?Q.refIndex:void 0,multiple:!0,hasArtboardAnchor:!Zt})}else if(Q.dgn==="replace-media-request"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee&&typeof Q.id==="string")Ce.current?.({purpose:"replace-src",canvas:e,id:Q.id,before:typeof Q.before==="string"?Q.before:null})}else if(Q.dgn==="convert-to-absolute-request"){let Ee=e?rt.current.get(e)?.contentWindow:null,et=Array.isArray(Q.containers)&&Q.containers.length>0,Rt=typeof Q.containerId==="string"&&Array.isArray(Q.children)&&Q.children.length>0;if(it.source===Ee&&(et||Rt)){let Zt=et?Q.containers.reduce((Ht,jn)=>Ht+(Array.isArray(jn?.children)?jn.children.length:0),0):Q.children.length;ua.current?.("/_api/convert-to-absolute",et?{allowShared:Q.allowShared===!0,containers:Q.containers,...Array.isArray(Q.dissolve)&&Q.dissolve.length>0?{dissolve:Q.dissolve}:{}}:{containerId:Q.containerId,containerSetRelative:Q.containerSetRelative===!0,allowShared:Q.allowShared===!0,children:Q.children},{label:"convert to absolute",onOk:()=>{nt({dgn:"selection-clear"}),nt({dgn:"op-toast",message:`Converted ${Zt} element${Zt===1?"":"s"} to absolute — press V and drag them freely (⌘Z to undo).`})},onFail:(Ht)=>nt({dgn:"op-toast",message:`Convert failed: ${Ht?.error||"unknown error"}`})})}}else if(Q.dgn==="replace-annotation-media-request"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee&&typeof Q.id==="string")Ce.current?.({purpose:"replace-annotation-media",canvas:e,id:Q.id,before:typeof Q.before==="string"?Q.before:null})}else if(Q.dgn==="edit-annotation-photo-request"){let Ee=e?rt.current.get(e)?.contentWindow:null,et=Yv.exec(typeof Q.asset==="string"?Q.asset:"")?.[0]||null;if(it.source===Ee&&typeof Q.id==="string"&&et)G({asset:et,strokeId:Q.id}),se("inspector"),ie("photo")}else if(Q.dgn==="open-sticker-picker"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee)ft.current?.({canvas:e})}else if(Q.dgn==="insert-artboard-request"){let Ee=e?rt.current.get(e)?.contentWindow:null,et=typeof Q.id==="string"&&Number.isFinite(Q.width)&&Number.isFinite(Q.height);if(it.source===Ee&&et)ke.current?.({id:Q.id,label:typeof Q.label==="string"?Q.label:Q.id,width:Q.width,height:Q.height})}else if(Q.dgn==="resize-artboard-request"){let Ee=e?rt.current.get(e)?.contentWindow:null,et=typeof Q.artboardId==="string"&&(Number.isFinite(Q.width)||Number.isFinite(Q.height));if(it.source===Ee&&et)dt.current?.(Q.artboardId,Number.isFinite(Q.width)?Q.width:void 0,Number.isFinite(Q.height)?Q.height:void 0)}else if(Q.dgn==="delete-artboard-request"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee&&typeof Q.artboardId==="string")Bt.current?.(Q.artboardId)}else if(Q.dgn==="rename-artboard-request"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee&&typeof Q.artboardId==="string"&&typeof Q.label==="string"&&Q.label.trim())ua.current?.("/_api/set-artboard-label",{artboardId:Q.artboardId,label:Q.label.slice(0,80)},{label:"rename artboard"})}else if(Q.dgn==="set-artboard-kind-request"){let Ee=e?rt.current.get(e)?.contentWindow:null,et=Q.kind===null||typeof Q.kind==="string";if(it.source===Ee&&typeof Q.artboardId==="string"&&et)Qa.current?.(Q.artboardId,Q.kind)}else if(Q.dgn==="duplicate-artboard-request"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee&&typeof Q.artboardId==="string"&&Number.isFinite(Q.width))Va.current?.(Q.artboardId,Q.width)}else if(Q.dgn==="open-inspector"){if(se("inspector"),typeof Q.tab==="string")ie(Q.tab)}else if(Q.dgn==="present-enter"){let Ee=e?rt.current.get(e)?.contentWindow:null,et=!!document.querySelector('[role="dialog"][aria-modal="true"]');if(it.source===Ee&&!et&&!Ke)ot(!0),kt({present:!0})}else if(Q.dgn==="comment-compose"&&Q.selection)a(Q.selection);else if(Q.dgn==="comment-submit"&&Q.payload&&typeof Q.payload.text==="string"){let Ee=Q.payload,et=String(Ee.text).trim(),Rt=e?rt.current.get(e)?.contentWindow:null;if(it.source===Rt&&et&&e&&e!==Ft)Se({type:"comments-add",payload:{file:e,selector:Ee.selector,index:Ee.index,dom_path:Ee.dom_path,tag:Ee.tag,classes:Ee.classes,bounds:Ee.bounds,html_excerpt:Ee.html_excerpt,annotationId:Ee.annotationId,world:Ee.world,text:et}})}else if(Q.dgn==="comment-patch"&&Q.id&&Q.patch&&typeof Q.patch==="object"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee&&De(Q.id))Se({type:"comments-patch",id:Q.id,patch:Q.patch})}else if(Q.dgn==="comment-delete"&&Q.id){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee&&De(Q.id))Se({type:"comments-delete",id:Q.id}),R((et)=>et===Q.id?null:et)}else if(Q.dgn==="comment-click"&&Q.id)R(Q.id);else if(Q.dgn==="artboards"&&typeof Q.count==="number"){let Ee=Math.round(Q.count);if(Number.isFinite(Ee)&&Ee>=0&&Ee<=999)yt(Ee)}else if(Q.dgn==="active-artboard"){let Ee=e&&e!==Ft?rt.current.get(e)?.contentWindow:null;if(it.source!==Ee)return;F(Nv(Q.id))}else if(Q.dgn==="timeline-comps"&&Array.isArray(Q.comps)){let Ee=e&&e!==Ft?rt.current.get(e)?.contentWindow:null;if(it.source!==Ee)return;let et=Q.comps.filter((Ht)=>Ht&&typeof Ht.id==="string").slice(0,32).map((Ht)=>({id:String(Ht.id).slice(0,120),fps:Math.max(1,Math.min(120,Math.round(Number(Ht.fps)||30))),durationInFrames:Math.max(1,Math.min(1e6,Math.round(Number(Ht.durationInFrames)||1))),width:Math.max(1,Math.round(Number(Ht.width)||0)),height:Math.max(1,Math.round(Number(Ht.height)||0)),artboardId:Nv(Ht.artboardId),artboardLabel:Nv(Ht.artboardLabel)}));D(et);let Rt=K.current;if(Rt&&et.some((Ht)=>Ht.id===Rt)&&X.current>0)nt({dgn:"timeline-seek",frame:X.current,id:Rt})}else if(Q.dgn==="timeline-frame"&&typeof Q.frame==="number"){let Ee=e&&e!==Ft?rt.current.get(e)?.contentWindow:null;if(it.source!==Ee)return;if(Q.id&&K.current&&Q.id!==K.current)return;if(Number.isFinite(Q.frame))U(Math.max(0,Math.round(Q.frame)))}else if(Q.dgn==="timeline-ended"){let Ee=e&&e!==Ft?rt.current.get(e)?.contentWindow:null;if(it.source!==Ee)return;if(Q.id&&K.current&&Q.id!==K.current)return;z(!1)}else if(Q.dgn==="toggle-palette"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(Ee&&it.source===Ee)H((et)=>!et)}else if(Q.dgn==="shell-shortcut"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee){if(Q.id==="reload")qe();else if(Q.id==="inspector")Z("inspector");else if(Q.id==="assistant"&&na())Z("assistant");else if(Q.id==="comments")Z("comments");else if(Q.id==="changes")Z("changes");else if(Q.id==="timeline")oe();else if(Q.id==="export")V({mode:"export"});else if(Q.id==="handoff")V({mode:"handoff"})}}else if(Q.dgn==="open-export"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee)V({mode:"export",scope:Q.detail&&typeof Q.detail.scope==="string"?Q.detail.scope:void 0})}else if(Q.dgn==="open-timeline-request"){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee){if(typeof Q.artboardId==="string")F(Q.artboardId.slice(0,120));q(!0)}}else if((Q.dgn==="canvas-rendered"||Q.dgn==="canvas-failed")&&Q.file){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source===Ee)_((et)=>et===Q.file?null:et)}else if(Q.dgn==="loaded"&&Q.file){if(!Vv(Q.file))_((Rt)=>Rt===Q.file?null:Rt);k(Q.file),v((Rt)=>Rt&&Rt.path===Q.file?null:Rt);let Ee=Ke?[]:N[Q.file]||[],et=[...rt.current.entries()].find(([Rt])=>Rt===Q.file)?.[1];if(et&&et.contentWindow){try{et.contentWindow.postMessage({dgn:"comments-set",comments:Ee},"*")}catch{}try{et.contentWindow.postMessage({dgn:"theme",theme:O},"*")}catch{}try{et.contentWindow.postMessage({dgn:"view-chrome",minimap:ye,zoom:Je,present:Ke},"*")}catch{}if(E&&Ee.some((Zt)=>Zt.id===E))try{et.contentWindow.postMessage({dgn:"comment-focus",id:E},"*")}catch{}let Rt=i.current;if(Rt&&Rt.file===Q.file){i.current=null;try{et.contentWindow.postMessage({dgn:"request-layers",artboardId:Rt.artboardId??null},"*")}catch{}if(Rt.movedId)try{et.contentWindow.postMessage({dgn:"select-by-id",id:Rt.movedId,artboardId:Rt.artboardId??null,index:0},"*")}catch{}}else{let Zt=n.current,Ht=Array.isArray(Zt)?Zt[0]:Zt;if(Ht&&Ht.id&&Ht.file===Q.file)s(Ht)}}}else if(Q.dgn==="export-request"&&Q.id&&Q.payload){let Ee=e?rt.current.get(e)?.contentWindow:null;if(it.source!==Ee)return;Ut(it.source,Q.id,Q.payload)}else if(Q.dgn==="export-history-request"&&Q.id)ka(it.source,Q.id)}let Nt=I?.canvasOrigin||window.location.origin;async function Ut(it,$a,Q){if(Q?.options&&e&&e!==Ft)Q.options.canvasFile=e;let Ee=(Zt)=>{try{if(it)it.postMessage({dgn:"export-result",id:$a,...Zt},Nt)}catch{}},et=Q?.options||{};if(lh({exportLane:I.exportLane||"local",format:Q?.format,scope:Q?.scope,artboardId:et.artboardId}))try{if(Q.format==="pptx"){let{filename:Zt,blob:Ht}=await ub({capture:bt,name:e?e.replace(/^.*\//,"").replace(/\.[^.]+$/,""):"export"});Qh(Zt,Ht)}else{let Zt=db(et),Ht=await bt({format:Q.format,artboardIds:[et.artboardId],scale:Zt}),jn=await cb(Ht,Q.format);for(let Mn of jn)Qh(Mn.name,Mn.blob)}Ee({ok:!0,browser:!0});return}catch{if(I.exportLane!=="remote"){Ee({ok:!1,error:"Capturing in the browser failed and this workspace has no render service to fall back to — try again, or ask your admin to add maude-render."});return}}if(I.exportLane==="none"&&Q?.format!=="zip"){Ee({ok:!1,error:"This format needs the render service, which this workspace doesn’t have configured. PNG/SVG of the active artboard and the PPTX deck export straight from the browser; ZIP works too. For the rest use the desktop app or ask your admin to add maude-render."});return}try{let Zt=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(Q)});if(!Zt.ok){Ee({ok:!1,error:await Zt.text()||String(Zt.status)});return}let{jobId:Ht}=await Zt.json();Ee({ok:!0,jobId:Ht})}catch(Zt){Ee({ok:!1,error:Zt&&Zt.message?Zt.message:String(Zt)})}}async function ka(it,$a){let Q=[];try{let Ee=await fetch("/_api/export-history");if(Ee.ok){let et=await Ee.json();if(Array.isArray(et.history))Q=et.history}}catch{}try{if(it)it.postMessage({dgn:"export-history-result",id:$a,history:Q},Nt)}catch{}}return window.addEventListener("message",Ge),()=>window.removeEventListener("message",Ge)},[N,E,I,O,qe,Ke,ye,Je,kt,e,nt,bt]);let _e=ce(()=>{if(!e||e===Ft)return;let De=rt.current.get(e);if(De&&De.contentWindow)try{De.contentWindow.postMessage({dgn:"force-clear"},"*")}catch{}},[e]),Ye=ce((De)=>{if(!e||e===Ft)return;let Ge=rt.current.get(e);if(Ge&&Ge.contentWindow)try{Ge.contentWindow.postMessage({dgn:"apply-style",...De},"*")}catch{}},[e]),He=ce((De)=>{if(!e||e===Ft||!De)return;let Ge=rt.current.get(e);if(Ge&&Ge.contentWindow)try{Ge.contentWindow.postMessage({dgn:"record-edit",payload:De},"*")}catch{}},[e]),ht=me(Promise.resolve()),Xt=ce((De,Ge,Nt,Ut)=>{let ka=Number.isInteger(Ut?.idIndex)?Ut.idIndex:void 0,it=Number.isInteger(Ut?.refIndex)?Ut.refIndex:void 0;if(!De||!Ge)return;if(De===Ge&&(ka??0)===(it??0))return;let $a=n.current,Q=Array.isArray($a)?$a[0]:$a,Ee=e;if(!Ee)return;let et=e,Rt=w?.artboardId??Q?.artboardId??null;if(S((Zt)=>Zt?{...Zt,nodes:gE(Zt.nodes,De,Ge,Nt)}:Zt),h.current=!0,b.current)clearTimeout(b.current);b.current=setTimeout(()=>{h.current=!1,b.current=null},700),ht.current=ht.current.catch(()=>{}).then(()=>fetch("/_api/reorder",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Ee,id:De,refId:Ge,position:Nt,idIndex:ka,refIndex:it})}).then((Zt)=>Zt.json().catch(()=>({}))).then((Zt)=>{if(!Zt.ok){if(console.warn("[reorder]",Zt.error||"failed"),nt({dgn:"reorder-failed"}),nt({dgn:"request-layers",artboardId:Rt}),h.current=!1,b.current)clearTimeout(b.current),b.current=null;return}if(i.current={file:et,movedId:Zt.movedId||null,artboardId:Rt},typeof Zt.seq==="number")nt({dgn:"record-edit",payload:{op:"reorder",canvas:Ee,seq:Zt.seq,label:"move element"}})}).catch(()=>{}))},[e,w,nt]);ee(()=>{f.current=Xt},[Xt]);let Ne=ce((De,Ge,Nt,Ut,ka,it)=>{if(!De||!e)return;let $a=e,Q=Number.isInteger(it)?it:void 0;Ye({id:De,prop:"left",value:`${Ge}px`}),Ye({id:De,prop:"top",value:`${Nt}px`});let Ee=null,et=(Rt,Zt)=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:$a,id:De,property:Rt,value:`${Zt}px`,idIndex:Q})}).then((Ht)=>Ht.json().catch(()=>({})));ht.current=ht.current.catch(()=>{}).then(()=>et("left",Ge)).then((Rt)=>{if(!Rt.ok)throw Error(Rt.error||"left write failed");return Ee=Rt,et("top",Nt)}).then((Rt)=>{if(!Rt.ok)throw Error(Rt.error||"top write failed");He({op:"css",canvas:$a,id:De,key:"left",before:Ip(Ee,`${Ut}px`),after:`${Ge}px`}),He({op:"css",canvas:$a,id:De,key:"top",before:Ip(Rt,`${ka}px`),after:`${Nt}px`})}).catch((Rt)=>{console.warn("[reposition]",Rt?.message||Rt),nt({dgn:"reposition-failed"})})},[e,nt,He,Ye]);ee(()=>{p.current=Ne},[Ne]);let At=ce((De,Ge,Nt,Ut)=>{if(!De||!e||!Ge||typeof Ge!=="object")return;let ka=e,it=Nt&&typeof Nt==="object"?Nt:{},$a=Number.isInteger(Ut)?Ut:void 0,Q=["width","height","left","top","transform","padding-top","padding-right","padding-bottom","padding-left","gap","grid-template-columns","grid-template-rows"].filter((va)=>typeof Ge[va]==="string"&&Ge[va]);if(!Q.length)return;let Ee=n.current,et=Array.isArray(Ee)?Ee.length===1?Ee[0]:null:Ee,Rt=et&&et.id===De?et.artboardId??null:null,Zt=et&&et.id===De?et.index??0:0;for(let va of Q)Ye({id:De,artboardId:Rt,index:Zt,prop:va,value:Ge[va]});let Ht=(va,xn)=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:ka,id:De,property:va,value:xn,idIndex:$a})}).then((ja)=>ja.json().catch(()=>({}))),jn={},Mn=ht.current.catch(()=>{});for(let va of Q)Mn=Mn.then((xn)=>{if(xn&&xn.ok===!1)throw Error(xn.error||`${va} write failed`);return Ht(va,Ge[va]).then((ja)=>(jn[va]=ja,ja))});ht.current=Mn.then((va)=>{if(va&&va.ok===!1)throw Error(va.error||"resize write failed");for(let xn of Q)He({op:"css",canvas:ka,id:De,key:xn,before:Ip(jn[xn],it[xn]??null),after:Ge[xn]});s({id:De,file:ka,artboardId:Rt,index:Zt})}).catch((va)=>{console.warn("[resize]",va?.message||va),nt({dgn:"resize-failed"})})},[e,nt,He,Ye,s]);ee(()=>{m.current=At},[At]);let ua=me(null),Be=ce((De,Ge,{label:Nt,onOk:Ut,onFail:ka}={})=>{if(!e)return;let it=e,$a=ka??((Q)=>nt({dgn:"op-toast",message:`Couldn't ${Nt||"apply the edit"}${Q?.error?` — ${Q.error}`:""}.`}));ht.current=ht.current.catch(()=>{}).then(()=>fetch(De,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...Ge,canvas:it})}).then((Q)=>Q.json().catch(()=>({}))).then((Q)=>{if(!Q.ok){console.warn(`[${De}]`,Q.error||"failed"),$a?.(Q);return}if(typeof Q.seq==="number")nt({dgn:"record-edit",payload:{op:"reorder",canvas:it,seq:Q.seq,label:Nt||"edit"}});Ut?.(Q,it)}).catch((Q)=>$a?.({error:Q?.message})))},[e,nt]);ee(()=>{ua.current=Be},[Be]);let fe=ce((De,Ge)=>{Be("/_api/delete-element",{id:De,idIndex:Number.isInteger(Ge)?Ge:void 0},{label:"delete element",onOk:()=>nt({dgn:"selection-clear"})})},[Be,nt]),Ze=ce((De,Ge,Nt,Ut={})=>{let ka=u.current?.sig??null;Be("/_api/insert-element",{refId:De,artboardId:typeof Ut.artboardId==="string"?Ut.artboardId:void 0,position:Ge,kind:Nt,src:typeof Ut.src==="string"?Ut.src:void 0,refIndex:Number.isInteger(Ut.refIndex)?Ut.refIndex:void 0},{label:`insert ${Nt}`,onOk:(it,$a)=>{if(!it.newId)return;i.current={file:$a,movedId:it.newId,artboardId:null,staleSig:ka};let Q=u.current;if(Q)c.current?.(Q.tree,Q.sig,Q.artboardId)}})},[Be]),he=ce((De)=>{if(typeof De!=="string"||!De)return!1;if(!e)return!1;let Ge=n.current?.artboardId??M??null;if(!Ge)return!1;return Ze(void 0,"inside-end","image",{artboardId:Ge,src:De}),!0},[e,M,Ze]),Le=ce((De,Ge)=>{Be("/_api/detach-component",{id:De,idIndex:Number.isInteger(Ge)?Ge:void 0},{label:"detach instance",onOk:(Nt)=>{nt({dgn:"selection-clear"}),nt({dgn:"op-toast",message:`Detached — this instance is now ${Nt.detachedName||"its own component"}; edits stay local (⌘Z to undo).`})},onFail:(Nt)=>nt({dgn:"op-toast",message:`Detach failed: ${Nt?.error||"unknown error"}`})})},[Be,nt]),Ie=ce((De,Ge)=>{let Nt=u.current?.sig??null;Be("/_api/duplicate-element",{id:De,idIndex:Number.isInteger(Ge)?Ge:void 0},{label:"duplicate element",onOk:(Ut,ka)=>{if(!Ut.newId)return;i.current={file:ka,movedId:Ut.newId,artboardId:null,staleSig:Nt};let it=u.current;if(it)c.current?.(it.tree,it.sig,it.artboardId)}})},[Be]),ue=me(null),be=Kt(()=>new Set(["position","top","right","bottom","left","inset","width","height","min-width","max-width","min-height","max-height","margin","margin-top","margin-right","margin-bottom","margin-left"]),[]),Te=ce(()=>{let De=n.current,Ge=Array.isArray(De)?De.length===1?De[0]:null:De;if(!Ge)return;let Nt={};for(let[Ut,ka]of Object.entries(Ge.authored||{}))if(!be.has(Ut))Nt[Ut]=ka;for(let[Ut,ka]of Object.entries(Ge.customStyles||{}))if(!be.has(Ut))Nt[Ut]=ka;ue.current=Object.keys(Nt).length?Nt:null},[be]),tt=ce((De)=>{let Ge=e,Nt=ue.current;if(!Ge||!De||!Nt)return;let Ut=Object.entries(Nt),ka=ht.current.catch(()=>{});for(let[it,$a]of Ut)Ye({id:De,prop:it,value:$a}),ka=ka.then(()=>fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Ge,id:De,property:it,value:$a})}).then((Q)=>Q.json().catch(()=>({}))).then((Q)=>{if(Q.ok)He({op:"css",canvas:Ge,id:De,key:it,before:Ip(Q,null),after:$a})}).catch(()=>{}));ht.current=ka},[e,Ye,He]),we=ce(({id:De,label:Ge,width:Nt,height:Ut})=>{Be("/_api/insert-artboard",{id:De,label:Ge,width:Nt,height:Ut},{label:"insert artboard"})},[Be]),Ue=ce((De,Ge,Nt)=>{Be("/_api/resize-artboard",{artboardId:De,width:Ge,height:Nt},{label:"resize artboard",onFail:()=>nt({dgn:"resize-artboard-failed"}),onOk:()=>o(De,e)})},[Be,nt,o,e]),lt=ce((De)=>{Be("/_api/delete-artboard",{artboardId:De},{label:"delete artboard"})},[Be]),le=ce((De,Ge)=>{Be("/_api/duplicate-artboard",{artboardId:De,width:Ge},{label:"duplicate artboard at width"})},[Be]),We=ce((De,Ge,Nt)=>{Be("/_api/set-artboard-hug",{artboardId:De,fixed:Ge,freezeHeight:Nt},{label:Ge?"pin artboard height":"hug artboard height",onOk:()=>o(De,e)})},[Be,o,e]),xt=ce((De,Ge)=>{Be("/_api/set-artboard-style",{artboardId:De,...Ge},{label:"artboard style",onOk:()=>o(De,e)})},[Be,o,e]),Wt=me(null),pa=ce((De,Ge)=>{Be("/_api/set-artboard-kind",{artboardId:De,kind:Ge},{label:"artboard kind",onOk:()=>o(De,e)});let Nt=Wt.current;if(Ge==="print"&&Nt&&Nt.artboardId===De)Wt.current=null,Be("/_api/resize-artboard",{artboardId:De,width:Nt.widthPx,height:Nt.heightPx},{label:"artboard size"}),Be("/_api/set-artboard-print",{artboardId:De,print:Nt.defaults},{label:"artboard print"})},[Be,o,e]),Qa=me(null);ee(()=>{Qa.current=pa},[pa]);let Pt=ce((De,Ge,Nt)=>{if(Ge==="print"||Ge==null||Ge==="digital"){if(Nt)Wt.current={artboardId:De,...Nt};nt({dgn:"freeze-and-set-kind",artboardId:De,kind:Ge==="digital"?null:Ge,ask:!0});return}pa(De,Ge)},[pa,nt]),pn=ce((De,Ge)=>{Be("/_api/set-artboard-print",{artboardId:De,print:Ge},{label:"artboard print",onOk:()=>o(De,e)})},[Be,o,e]),Dt=ce((De)=>{let Ge=`s${Math.random().toString(36).slice(2,8)}`;if(De.startsWith("print-")){let Ut=De.slice(6),ka;try{ka=oh({paper:Ut})}catch{return}let it=sh.find(($a)=>$a.id===Ut);we({id:Ge,label:it?it.label:Ut.toUpperCase(),width:ka.widthPx,height:ka.heightPx}),Pt(Ge,"print"),pn(Ge,{paper:Ut});return}let Nt=Os[De];if(!Nt)return;we({id:Ge,label:Nt.label,width:Nt.width,height:Nt.height})},[we,Pt,pn]),Yt=me(null),Vt=me(null),ke=me(null),dt=me(null),Bt=me(null),oa=me(null),Pa=me(null),Va=me(null),Ve=me(null),B=me(null);ee(()=>{Yt.current=fe,Vt.current=Ze,ke.current=we,dt.current=Ue,Bt.current=lt,oa.current=Pt,Pa.current=Ie,Va.current=le,Ve.current=Te,B.current=tt},[fe,Ze,we,Ue,lt,Pt,Ie,le,Te,tt]),ee(()=>{let De=(Ge)=>{if(Ge.key!=="Backspace"&&Ge.key!=="Delete")return;if(Ge.metaKey||Ge.ctrlKey||Ge.altKey)return;let Nt=Ge.target;if(Nt&&(Nt.tagName==="INPUT"||Nt.tagName==="TEXTAREA"||Nt.tagName==="SELECT"||Nt.isContentEditable))return;if(Ge.preventDefault(),!e||e===Ft)return;let ka=Array.isArray(t)?t.length===1?t[0]:null:t;if(ka?.artboardId&&!ka.id)lt(ka.artboardId)};return window.addEventListener("keydown",De),()=>window.removeEventListener("keydown",De)},[e,t,lt]);let[ae,de]=P(null),Ce=me(null);ee(()=>{Ce.current=(De)=>de(De)},[]);let[Pe,ct]=P(null),ft=me(null);ee(()=>{ft.current=(De)=>ct(De)},[]);let Ot=ce((De)=>{let Ge=ae;if(de(null),!Ge||!De)return;if(Ge.canvas&&Ge.canvas!==e){console.warn("[asset-picker] active canvas changed since request — aborting");return}if(Ge.purpose==="insert-image"){Ze(Ge.refId,Ge.position||"after","image",{artboardId:Ge.artboardId,src:De,refIndex:Ge.refIndex});return}if(Ge.purpose==="replace-src"){let Nt=e;if(!Nt||!Ge.id)return;ht.current=ht.current.catch(()=>{}).then(()=>fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Nt,id:Ge.id,attr:"src",value:De})}).then((Ut)=>Ut.json().catch(()=>({}))).then((Ut)=>{if(Ut.ok)He({op:"attr",canvas:Nt,id:Ge.id,key:"src",before:Ip(Ut,Ge.before??null),after:De});else console.warn("[replace-src]",Ut.error||"failed")}).catch(()=>{}));return}if(Ge.purpose==="replace-annotation-media")nt({dgn:"replace-annotation-media",id:Ge.id,path:De})},[ae,Ze,e,He,nt]),Mt=ce((De,Ge)=>{let Nt=ae;if(de(null),!Nt||!Array.isArray(De)||!De.length)return;if(Nt.canvas&&Nt.canvas!==e){console.warn("[asset-picker] active canvas changed since request — aborting");return}if(Ge==="artboard"){let Ut=n.current?.artboardId??M??null;if(!Ut)return;for(let ka of De)Ze(void 0,"inside-end","image",{artboardId:Ut,src:ka});return}nt({dgn:"insert-annotation-media",paths:De})},[ae,e,Ze,M,nt]),da=ce(async(De)=>{let Ge=Pe;if(ct(null),!Ge||!De?.url)return;if(Ge.canvas&&Ge.canvas!==e){console.warn("[sticker-picker] active canvas changed since request — aborting");return}try{let Nt=await fetch(De.url).then((it)=>it.ok?it.blob():Promise.reject(Error(`HTTP ${it.status}`))),Ut=await fetch("/_api/asset",{method:"POST",headers:{"content-type":Nt.type||"image/png"},body:Nt}),ka=await Ut.json().catch(()=>({}));if(!Ut.ok||!ka.path){console.warn("[sticker-picker]",ka.error||`upload failed (HTTP ${Ut.status})`);return}nt({dgn:"insert-sticker",path:ka.path})}catch{console.warn("[sticker-picker] could not load or upload that sticker")}},[Pe,e,nt]),Ta=ce((De)=>{if(!De?.id)return;de({purpose:"replace-src",canvas:e,id:De.id,before:De.attrs?.src??null})},[e]),Ma=ce((De)=>{Se({type:"comments-patch",id:De,patch:{status:"resolved"}})},[]),Or=ce((De)=>{Se({type:"comments-patch",id:De,patch:{status:"open"}})},[]),Qr=ce((De)=>{Se({type:"comments-delete",id:De}),R((Ge)=>Ge===De?null:Ge)},[]);return{applyOptimisticStyle:Ye,assetPickerReq:ae,clearActiveCanvasSelection:_e,deleteComment:Qr,detachInstanceShell:Le,duplicateArtboardShell:le,insertGeneratedImage:he,onAssetPicked:Ot,onInsertArtboard:Dt,onPickMany:Mt,onReplaceMedia:Ta,onStickerPicked:da,recordSourceEdit:He,reopenComment:Or,reorderLayer:Xt,resizeArtboardShell:Ue,resolveComment:Ma,setArtboardHugShell:We,setArtboardKindShell:Pt,setArtboardPrintShell:pn,setArtboardStyleShell:xt,setAssetPickerReq:de,setStickerPickerReq:ct,stickerPickerReq:Pe}}function Vj({groups:e,treeLoaded:t,addressMode:a,previousAddressPath:n,project:r,tabs:s,setTabs:o,activePath:i,setActivePath:u,previewPath:c,setPreviewPath:f,onPreview:p,setSelected:m,cloudLinkedHub:h,localProjectName:b,systemData:w,setLoadingPath:S,setCanvasError:_,setCanvasReloadNonce:v,setLoadedPath:k,cfg:I,loadServerConfig:A,setFocusedCommentId:N,updateTreeExp:E,setShareDialog:R,setTimelineOpen:O,timelineArtboardId:H,iframesRef:V,pushTlUndo:q,askText:D,loadTree:U,loadSystemData:z,canvasListChangeRef:M,wsSend:F}){let X=ce((he,{reveal:Le=!0}={})=>{if(Le&&he&&he!==Ft)E((Ie)=>Dv(Ie,e,he));if(a.current="push",N(null),f(null),he===i)return;if(o((Ie)=>{for(let ue of Ie)if(ue.path!==he)V.current.delete(ue.path);return[{path:he}]}),u(he),_(null),k(null),he!==Ft)S(he)},[i,e,E]),K=ce((he,Le="push")=>{let Ie=e.flatMap((ue)=>ue.paths||[]).find((ue)=>Zi(ue,I.designRel)===he);if(Ie&&ws.test(Ie))X(Ie,{reveal:!1});else if(Ie&&$d(us(Ie)))p(Ie);else o([]),u(null),f(null),uo({title:"Not here yet",description:`${he} is not in this project (not synced yet?)`,kind:"info"});a.current=Le},[e,I.designRel,X,p]),ie=me(!1);ee(()=>{if(!t||I.cloud===void 0||ie.current)return;ie.current=!0;let he=fd(location,I.designRel);if(he)K(he,"none")},[t,I.cloud,I.designRel,K]),ee(()=>{if(!t||I.cloud===void 0)return;let he=()=>{let Le=fd(location,I.designRel);if(Le)K(Le,"none");else a.current="none",o([]),u(null),f(null)};return window.addEventListener("popstate",he),()=>window.removeEventListener("popstate",he)},[t,I.cloud,I.designRel,K]),ee(()=>{let he=c||(i===Ft?null:i);if(he===n.current)return;n.current=he;let Le=Zi(he,I.designRel);if(a.current!=="none"&&fd(location,I.designRel)!==Le)history[Le?"pushState":"replaceState"](Le?{open:Le}:null,"",T3(location,Le));a.current="push"},[i,c,I.designRel]);let G=c||(i===Ft?null:i),se=I.cloud?"cloud":na()?"native":"local",Z=(he)=>$3({rel:Zi(he,I.designRel),shell:se,location,linkedHubUrl:h?.url,project:I.cloud?r:b,localUrl:location.origin}),pe=(he=G)=>{let Le=Zi(he,I.designRel);if(Le)R({path:he,rel:Le,label:us(he)})},oe=ce((he)=>{if(_(null),k(null),A(),v((Le)=>Le+1),he&&he!==Ft)S(he)},[A]),ye=me(!1);ee(()=>{if(ye.current)return;if(!I.cloud)return;if(new URLSearchParams(location.search).has("open")){ye.current=!0;return}if(s.length>0)return;if(!e.length)return;let he=null;for(let Le of e){for(let Ie of Le.paths||[]){if(!ws.test(Ie))continue;if(/(^|\/)system\//.test(Ie))continue;he=Ie;break}if(he)break}if(!he)return;ye.current=!0,X(he,{reveal:!1})},[I.cloud,e,s.length,X]);let Je=ce((he)=>{let Le=typeof he==="string"?he:void 0;if(Le)z(Le);else if(!w)z();X(Ft)},[w,z,X]);ee(()=>{F({type:"tabs",tabs:s.map((he)=>he.path).filter((he)=>he!==Ft)})},[s]),ee(()=>{if(i&&i!==Ft)F({type:"active",file:i});else if(i===Ft)F({type:"active",file:""});else F({type:"active",file:""})},[i]);let Ke=ce((he)=>{o((Le)=>{let Ie=Le.findIndex((be)=>be.path===he);if(Ie<0)return Le;let ue=Le.filter((be)=>be.path!==he);if(he===i)if(ue.length===0)u(null);else u(ue[Math.max(0,Ie-1)].path);return ue}),V.current.delete(he),S((Le)=>Le===he?null:Le)},[i]);M.current=(he)=>{if(!he?.rel)return;let Le=(I?.designRel||I?.designRoot||".design").replace(/^\/+|\/+$/g,""),Ie=`${Le}/${he.rel}`;if(he.action==="removed")Ke(Ie);else if(he.action==="moved"&&he.fromRel){let ue=`${Le}/${he.fromRel}`;o((be)=>be.map((Te)=>Te.path===ue?{...Te,path:Ie}:Te)),u((be)=>be===ue?Ie:be),S((be)=>be===ue?null:be),V.current.delete(ue)}};let ot=ce(()=>{if(!i||i===Ft){if(i===Ft)z();return}let he=V.current.get(i);if(he)he.src=he.src},[i,z]),yt=ce(()=>U(),[U]),[rt,nt]=P(!1),bt=me(!1),kt=ce(async()=>{if(bt.current)return;bt.current=!0,nt(!0);try{await Promise.all([U(),new Promise((he)=>setTimeout(he,550))])}finally{bt.current=!1,nt(!1)}},[U]);ee(()=>{let he=null,Le=()=>{if(he)clearTimeout(he);he=setTimeout(()=>{he=null,yt()},150)};return window.addEventListener("focus",Le),()=>{if(window.removeEventListener("focus",Le),he)clearTimeout(he)}},[yt]);let Se=ce(async(he)=>{try{let Le=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:he,kind:"brief-board"})}),Ie=await Le.json().catch(()=>({}));if(!Le.ok||!Ie.ok)return{ok:!1,error:Ie.error||`create failed (${Le.status})`};return await U(),X(Ie.file),{ok:!0,file:Ie.file}}catch(Le){return{ok:!1,error:Le instanceof Error?Le.message:"network error"}}},[U,X]),qe=ce(async()=>{let he=await D("New video name");if(!he)return;let Ie=(await D("Size — 1920x1080 (landscape), 1080x1920 (portrait), 1080x1080 (square), or custom WxH","1920x1080")||"1920x1080").toLowerCase().match(/(\d{2,5})\s*[x×]\s*(\d{2,5})/),ue=Ie?Number(Ie[1]):1920,be=Ie?Number(Ie[2]):1080,Te=Math.max(1,Math.min(60,Number(await D("Frames per second","30"))||30));try{let tt=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:he,kind:"video-comp",clips:[],fps:Te,width:ue,height:be})}),we=await tt.json().catch(()=>({}));if(!tt.ok||!we.ok){Gt(`New video failed: ${we.error||`error ${tt.status}`}`);return}await U(),X(we.file),O(!0),Gt("New video created — drop clips on the timeline to start the cut.",!0)}catch(tt){Gt(`New video failed: ${tt instanceof Error?tt.message:"network error"}`)}},[U,X,D]),_e=ce(async()=>{if(!i||i===Ft)return;try{let he=await fetch(`/_api/annotations?file=${encodeURIComponent(i)}`),Le=he.ok?await he.text():"",Ie=[];if(Le){let we=new DOMParser().parseFromString(Le,"image/svg+xml");for(let Ue of we.querySelectorAll('[data-tool="mediaref"]')){let lt=Ue.getAttribute("data-src");if(!lt)continue;Ie.push({src:lt,mediaKind:Ue.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(Ie.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let be=`${xs(us(i)).replace(/\.tsx$/i,"")} Video`,Te=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:be,kind:"video-comp",clips:Ie})}),tt=await Te.json().catch(()=>({}));if(!Te.ok||!tt.ok){window.alert(`Assemble failed: ${tt.error||`error ${Te.status}`}`);return}await U(),X(tt.file)}catch(he){window.alert(`Assemble failed: ${he instanceof Error?he.message:"network error"}`)}},[i,U,X]),Ye=ce(({accept:he,resolveTarget:Le})=>{let Ie=i,ue=H||void 0,be=document.createElement("input");be.type="file",be.accept=he,be.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(be);let Te=()=>{if(be.isConnected)be.remove()};window.addEventListener("focus",()=>setTimeout(Te,300),{once:!0}),be.addEventListener("change",()=>{let tt=be.files?.[0];if(Te(),!tt)return;let we=`/_api/comp-clips?canvas=${encodeURIComponent(Ie)}${ue?`&artboardId=${encodeURIComponent(ue)}`:""}`;fetch(we).then((Ue)=>Ue.json().catch(()=>({}))).then((Ue)=>{let lt=Le(Ue);if(!lt)return Gt("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":tt.type||"application/octet-stream"},body:tt}).then((le)=>le.json().catch(()=>({}))).then((le)=>{if(!le?.path)return Gt(`Upload failed: ${le?.error||"unknown error"}`),null;if(lt.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Ie,arrayName:lt.arrayRef.arrayName,index:lt.arrayRef.index,field:lt.arrayRef.field,value:le.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:Ie,id:lt.cdId,attr:"src",value:le.path})})})}).then((Ue)=>Ue?Ue.json():null).then((Ue)=>{if(Ue&&!Ue.ok)Gt(`Replace refused: ${Ue.error||"failed"}`);else if(Ue&&Ue.ok){if(Gt("Media replaced.",!0),Ue.seq!=null)q(Ie,Ue.seq,"replace media")}}).catch(()=>Gt("Replace failed: network error"))}),be.click()},[i,H,q]),He=ce(async(he,Le)=>{if(!window.confirm(`Move “${Le}” to trash?
5684
5684
 
5685
5685
  Its annotations, history and comments move with it. `+"You can restore it from .design/_trash/."))return;try{let ue=await fetch(`/_api/canvas?file=${encodeURIComponent(he)}`,{method:"DELETE"}),be=await ue.json().catch(()=>({}));if(!ue.ok||!be.ok){window.alert(`Could not delete: ${be.error||`error ${ue.status}`}`);return}if(await U(),i===he)o([]),u(null)}catch(ue){window.alert(`Delete failed: ${ue instanceof Error?ue.message:"network error"}`)}},[U,i]),ht=ce(async function he(Le,Ie){try{let ue=await fetch("/_api/fs-move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Le,toDir:Ie})}),be=await ue.json().catch(()=>({}));if(!ue.ok||!be.ok)return Gt(`Could not move: ${be.error||`error ${ue.status}`}`),{ok:!1,error:be.error};let Te=(I?.designRel||I?.designRoot||".design").replace(/^\/+|\/+$/g,""),tt=`${Te}/${be.fromRel}`,we=`${Te}/${be.toRel}`;E((lt)=>Dv(Y_(lt,tt,we),e,we)),await U(),o((lt)=>lt.map((le)=>le.path===tt?{path:we}:le)),u((lt)=>lt===tt?we:lt);let Ue=tt.split("/").slice(0,-1).join("/");return Gt(`Moved to ${be.toRel.split("/").slice(0,-1).join("/")||"."}`,!0,{label:"Undo",onClick:()=>{he(we,Ue)}}),{ok:!0}}catch(ue){return Gt(`Move failed: ${ue instanceof Error?ue.message:"network error"}`),{ok:!1,error:"network error"}}},[U,I,e,E]),Xt=ce(async(he,Le)=>{try{let Ie=await fetch("/_api/fs-mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parent:he,name:Le})}),ue=await Ie.json().catch(()=>({}));if(!Ie.ok||!ue.ok){let be=ue.error||`error ${Ie.status}`;return Gt(`Could not create folder: ${be}`),{ok:!1,error:be}}return E((be)=>Dv(be,e,he,{includeSelf:!0})),await U(),{ok:!0,dir:ue.dir}}catch(Ie){let ue=Ie instanceof Error?Ie.message:"network error";return Gt(`Create folder failed: ${ue}`),{ok:!1,error:ue}}},[U,e,E]),Ne=ce(async(he,Le)=>{if(!window.confirm(`Delete folder "${Le}"?
5686
5686