@1agh/maude 1.0.8 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5561,7 +5561,7 @@ ${B.block}`:q,F=[],D=new Map;for await(let _ of X.prompt(N,J(),K,Q?.(),Y?.(),Z?.
5561
5561
  `),count:Q.length,stale:Y}}function YA({id:X,label:J,currentValue:Q,options:Y,onChange:W,disabled:G}){let Z=cU(Y);if(!Z.length)return null;return z("select",{className:"chat-select",value:Q??"","aria-label":J,title:Z.find((H)=>H.value===Q)?.description||J,disabled:G,onChange:(H)=>W(X,H.target.value),children:Z.map((H)=>z("option",{value:H.value,children:H.name||H.value},H.value))})}function WA({modes:X,configOptions:J,onSetMode:Q,onSetConfig:Y,disabled:W}){let G=X?.availableModes??[],Z=J?.model??null,H=J?.effort??null,K=J?.fast??null;if(!G.length&&!Z&&!H&&!K)return z("span",{className:"chat-caps chat-caps--connecting","data-testid":"chat-caps-connecting",children:"Connecting…"});return O("div",{className:"chat-caps","data-testid":"chat-caps-bar",children:[G.length?z("select",{className:"chat-select",value:X?.currentModeId??"","aria-label":"Permission mode","data-testid":"chat-mode-picker",title:G.find((U)=>U.id===X?.currentModeId)?.description||"Permission mode",disabled:W,onChange:(U)=>Q(U.target.value),children:G.map((U)=>z("option",{value:U.id,children:U.name||U.id},U.id))}):null,Z?z(YA,{id:Z.id,label:"Model",currentValue:Z.currentValue,options:Z.options,onChange:Y,disabled:W}):null,H?z(YA,{id:H.id,label:"Effort",currentValue:H.currentValue,options:H.options,onChange:Y,disabled:W}):null,K?z(YA,{id:K.id,label:"Fast mode",currentValue:K.currentValue,options:K.options,onChange:Y,disabled:W}):null]})}var V5=x8(r8(),1);var XG0=/\b(password|passphrase|secret|api[\s_-]?key|access[\s_-]?key|private[\s_-]?key|auth(?:entication)?[\s_-]?token|credential|oauth[\s_-]?token)\b/i;function ZA(...X){let J=X.filter((Q)=>typeof Q==="string").join(" ");return XG0.test(J)}var JG0="_claude/askUserQuestionOption";function GA(X){if(Array.isArray(X?.oneOf))return X.oneOf.map((J)=>({value:J?.const,label:J?.title??String(J?.const??""),description:J?.description??null,preview:J?._meta?.[JG0]?.preview??null}));if(Array.isArray(X?.enum))return X.enum.map((J)=>({value:J,label:String(J),description:null,preview:null}));return[]}function QG0(X){if(!X||typeof X!=="object")return null;if(X.type==="string"&&(Array.isArray(X.oneOf)||Array.isArray(X.enum)))return{kind:"single",options:GA(X)};if(X.type==="array"){let J=X.items,Q=Array.isArray(J?.anyOf)?GA({oneOf:J.anyOf}):GA(J);if(Q.length)return{kind:"multi",options:Q};return{kind:"text",options:[]}}return{kind:"text",options:[]}}function Cf(X){let J=X?.properties;if(!J||typeof J!=="object")return[];let Q=Object.keys(J),Y=new Set(Array.isArray(X.required)?X.required:[]),W=new Set;for(let Z of Q){if(!Z.endsWith("_custom"))continue;let H=Z.slice(0,-7);if(H&&Object.hasOwn(J,H))W.add(Z)}let G=[];for(let Z of Q){if(W.has(Z))continue;let H=J[Z],K=QG0(H);if(!K)continue;let U=W.has(`${Z}_custom`)?`${Z}_custom`:null;G.push({id:Z,title:H.title??null,description:H.description??null,kind:K.kind,options:K.options,required:Y.has(Z),customFieldId:U,secretShaped:ZA(H.title,H.description)})}return G}function $f(X,J){let Q=Object.create(null),Y=J&&typeof J==="object"?J:{};for(let W of X??[]){let G=W.customFieldId?Y[W.customFieldId]:void 0,Z=typeof G==="string"?G.trim():"";if(W.kind==="multi"){let K=Array.isArray(Y[W.id])?Y[W.id]:[],U=Z?[...K,Z]:K;if(U.length)Q[W.id]=U;continue}if(Z){Q[W.customFieldId]=Z;continue}let H=Y[W.id];if(typeof H==="string"&&H!=="")Q[W.id]=H}return Q}var YG0="Please answer the following questions.";function Sf(X,J){let Q=X.customFieldId?J[X.customFieldId]:void 0;if(typeof Q==="string"&&Q.trim()!=="")return!0;if(X.kind==="multi")return Array.isArray(J[X.id])&&J[X.id].length>0;return typeof J[X.id]==="string"&&J[X.id]!==""}function WG0({q:X,answers:J,setAnswer:Q,customOpen:Y,onChooseOption:W,onChooseOther:G,onToggleCustom:Z,groupName:H,cardSecretShaped:K}){let U=K||X.secretShaped;return O("fieldset",{className:"chat-elicit-question","data-testid":`chat-elicit-question-${X.id}`,children:[X.title||X.description?O("legend",{className:"chat-elicit-question-hd",children:[X.title?z("span",{className:"chat-elicit-question-chip",children:X.title}):null,X.description||null]}):null,X.kind==="single"?O("div",{className:"chat-elicit-options",children:[X.options.map((q,B)=>O("label",{className:"chat-elicit-option","data-testid":`chat-elicit-option-${X.id}-${B}`,children:[z("input",{type:"radio",name:H,checked:!Y&&J[X.id]===q.value,onChange:()=>W(q.value)}),O("span",{className:"chat-elicit-option-body",children:[O("span",{children:[q.label,q.description?O("span",{className:"chat-elicit-option-desc",children:[" — ",q.description]}):null]}),q.preview?z("pre",{className:"chat-elicit-option-preview",children:q.preview}):null]})]},q.value)),X.customFieldId?O("label",{className:"chat-elicit-option chat-elicit-option--other","data-testid":`chat-elicit-option-${X.id}-other`,children:[z("input",{type:"radio",name:H,checked:Y,onChange:G}),z("span",{className:"chat-elicit-option-body",children:z("span",{children:"Other — type your own answer"})})]}):null,X.customFieldId&&Y?z("input",{type:U?"password":"text",className:"chat-elicit-text chat-elicit-custom chat-elicit-custom--inline",placeholder:"Type your own answer…",autoFocus:!0,value:J[X.customFieldId]||"",onChange:(q)=>Q(X.customFieldId,q.target.value),"data-testid":`chat-elicit-custom-${X.id}`}):null]}):null,X.kind==="multi"?z("div",{className:"chat-elicit-options",children:X.options.map((q,B)=>{let N=Array.isArray(J[X.id])?J[X.id]:[];return O("label",{className:"chat-elicit-option","data-testid":`chat-elicit-option-${X.id}-${B}`,children:[z("input",{type:"checkbox",checked:N.includes(q.value),onChange:(F)=>Q(X.id,F.target.checked?[...N,q.value]:N.filter((D)=>D!==q.value))}),O("span",{className:"chat-elicit-option-body",children:[O("span",{children:[q.label,q.description?O("span",{className:"chat-elicit-option-desc",children:[" — ",q.description]}):null]}),q.preview?z("pre",{className:"chat-elicit-option-preview",children:q.preview}):null]})]},q.value)})}):null,X.kind==="text"?z("input",{type:U?"password":"text",className:"chat-elicit-text",value:J[X.id]||"",onChange:(q)=>Q(X.id,q.target.value),"data-testid":`chat-elicit-text-${X.id}`}):null,X.kind==="multi"&&X.customFieldId?Y?O("div",{className:"chat-elicit-custom-wrap",children:[z("input",{type:U?"password":"text",className:"chat-elicit-text chat-elicit-custom",placeholder:"Type your own answer…",autoFocus:!0,value:J[X.customFieldId]||"",onChange:(q)=>Q(X.customFieldId,q.target.value)}),z("p",{className:"chat-elicit-custom-note",children:"Added to your selections above."})]}):z("button",{type:"button",className:"chat-elicit-custom-toggle",onClick:Z,children:"Add your own answer to your selections?"}):null,U?z("p",{className:"chat-elicit-secret-warning","data-testid":"chat-elicit-secret-warning",children:"This looks like it's asking for a password, key, or other credential — Maude never needs your real ones here."}):null]})}function HA({request:X,onRespond:J}){let Q=V5.useRef(null),Y=V5.useMemo(()=>Cf(X.requestedSchema),[X]),[W,G]=V5.useState({}),[Z,H]=V5.useState(()=>new Set),[K,U]=V5.useState(0),q=Y.length>1;V5.useEffect(()=>{G({}),H(new Set),U(0)},[X.id]),V5.useEffect(()=>{Q.current?.focus()},[X.id]);let B=(m,p)=>G((v)=>({...v,[m]:p})),N=(m)=>H((p)=>new Set(p).add(m)),F=(m)=>H((p)=>{if(!p.has(m))return p;let v=new Set(p);return v.delete(m),v}),D=(m)=>{if(Z.has(m))B(m,""),F(m);else N(m)},_=(m,p)=>{if(G((v)=>({...v,[m.id]:p,...m.customFieldId?{[m.customFieldId]:""}:{}})),m.customFieldId)F(m.customFieldId)},R=(m)=>{B(m.id,""),N(m.customFieldId)},w=Y.filter((m)=>m.required).every((m)=>Sf(m,W)),M=q?Y[K]:null,P=!M||!M.required||Sf(M,W),I=!q||K===Y.length-1,k=()=>{if(!w)return;J({action:"accept",content:$f(Y,W)})},$=()=>J({action:"decline"}),C=()=>J({action:"cancel"}),y=()=>U((m)=>Math.max(0,m-1)),f=()=>{if(!P)return;U((m)=>Math.min(Y.length-1,m+1))};V5.useEffect(()=>{function m(v){if(v.key==="Escape")v.preventDefault(),C();else if(v.key==="Enter"&&v.target?.tagName!=="BUTTON")if(v.preventDefault(),I)k();else f()}let p=Q.current;return p?.addEventListener("keydown",m),()=>p?.removeEventListener("keydown",m)},[X.id,w,P,I,W,K]);let h=X.toolCallId?"Requested by the tool call above":"Requested by a connected tool (not tied to a visible step)",d=q?M?[M]:[]:Y,n=ZA(X.message),x=!!X.message&&(!q||X.message!==YG0);return O("div",{className:"chat-elicit",role:"alertdialog","aria-label":"Input requested",tabIndex:-1,ref:Q,"data-testid":"chat-elicit-prompt",children:[O("div",{className:"chat-elicit-hd",children:[x?z("b",{children:X.message}):null,O("div",{className:"chat-elicit-meta",children:[q?O("span",{"data-testid":"chat-elicit-step",children:["Question ",K+1," of ",Y.length]}):null,z("span",{className:"chat-elicit-attribution",children:h})]})]}),d.map((m)=>z(WG0,{q:m,answers:W,setAnswer:B,customOpen:Z.has(m.customFieldId),onChooseOption:(p)=>_(m,p),onChooseOther:()=>R(m),onToggleCustom:()=>D(m.customFieldId),groupName:`elicit-${X.id}-${m.id}`,cardSecretShaped:n},m.id)),O("div",{className:"chat-elicit-actions",children:[q&&K>0?z("button",{type:"button",className:"btn",onClick:y,"data-testid":"chat-elicit-back",children:"Back"}):null,I?z("button",{type:"button",className:"btn btn--primary",disabled:!w,onClick:k,"data-testid":"chat-elicit-submit",children:"Submit"}):z("button",{type:"button",className:"btn btn--primary",disabled:!P,onClick:f,"data-testid":"chat-elicit-next",children:"Next"}),z("span",{className:"chat-elicit-actions-spacer"}),z("button",{type:"button",className:"btn",onClick:$,title:"Let Claude continue without an answer","data-testid":"chat-elicit-skip",children:"Skip"}),z("button",{type:"button",className:"btn btn--danger",onClick:C,title:"Stop this question — the action it was part of is aborted too","data-testid":"chat-elicit-cancel",children:"Cancel"})]})]})}var yB=x8(r8(),1);function GG0(X){let J=X?.rawInput,Q=J&&typeof J==="object"?J.path||J.file_path||J.abs_path||J.filePath:void 0,Y=Array.isArray(X?.locations)?X.locations[0]?.path:void 0,W=Q||Y;return W?String(W).split("/").pop():null}function ZG0(X){if(X==="reject_once"||X==="reject_always")return"btn btn--danger";if(X==="allow_once")return"btn btn--primary";return"btn"}function HG0(X){let J=Array.isArray(X)?X:[];return J.find((Q)=>Q?.kind==="allow_once")??J.find((Q)=>Q?.kind==="allow_always")??null}function zG0(X){return(Array.isArray(X)?X:[]).find((Q)=>Q?.kind==="reject_once"||Q?.kind==="reject_always")??null}var KG0=/[\p{Cc}\u202A-\u202E\u2066-\u2069\u200E\u200F\u061C\u200B-\u200D\uFEFF\u00AD]/gu;function bf(X){return String(X).replace(KG0,"�")}function UG0(X){if(!X||X.outOfProjectWrite!==!0)return null;let J=Array.isArray(X.resolvedPaths)?X.resolvedPaths.filter(Boolean).map(bf):[];return{lead:X.reason==="no-target"?"Claude asked to write a file but did not say which one.":X.reason==="disagreement"?"Claude named two different files for one write.":X.reason==="in-project-denied"?"This file is part of how your project RUNS, not part of its design.":J.length>1?"Claude wants to write files outside this project.":"Claude wants to write a file outside this project.",paths:J,scopeRoot:typeof X.scopeRoot==="string"?bf(X.scopeRoot):"",note:"This is allowed once, for this request only.",inProjectDenied:X.reason==="in-project-denied"}}function VG0(X,J){let Q=Array.isArray(X)?X:[];return J?Q.filter((Y)=>Y?.kind!=="allow_always"):Q}function zA({request:X,onRespond:J,queueLength:Q=1}){let Y=yB.useRef(null),{toolCall:W}=X,G=GG0(W),Z=UG0(X.scope),H=VG0(X.options,!!Z),K=X.scope?.reason==="in-project-denied"?"Write to a file that runs":"Write outside this project",U=Z?Z.paths.length===1?String(Z.paths[0]).split("/").pop():null:G,q=HG0(H),B=zG0(H);return yB.useEffect(()=>{Y.current?.focus();function N(D){if(D.key==="Enter"&&q)D.preventDefault(),J(q.optionId);else if(D.key==="Escape")D.preventDefault(),J(B?B.optionId:"cancelled")}let F=Y.current;return F?.addEventListener("keydown",N),()=>F?.removeEventListener("keydown",N)},[X.id]),O("div",{className:"chat-perm"+(Z?" chat-perm--outside":""),role:"alertdialog","aria-label":Z?Z.inProjectDenied?"Permission request — file that runs code":"Permission request — file outside this project":"Permission request",tabIndex:-1,ref:Y,"data-testid":"chat-permission-prompt",children:[O("div",{className:"chat-perm-hd",children:[z("b",{title:Z?K:W?.title||"Tool call",children:Z?K:W?.title||"Tool call"}),U?z("span",{className:"chat-tool-path",children:U}):null,Q>1?O("span",{className:"chat-perm-queue","data-testid":"chat-perm-queue",children:["+",Q-1," more waiting"]}):null]}),Z?O("div",{className:"chat-perm-outside","data-testid":"chat-perm-outside",children:[z("p",{className:"chat-perm-body",children:Z.lead}),Z.paths.length>0?z("ul",{className:"chat-perm-paths","data-testid":"chat-perm-paths",children:Z.paths.map((N)=>z("li",{className:"chat-perm-path",children:N},N))}):null,Z.scopeRoot?z("p",{className:"chat-perm-scope",children:Z.inProjectDenied?z(G0,{children:"Git hooks and Claude settings can execute code later, so Maude asks even though they live inside this project."}):O(G0,{children:["This project is ",z("span",{className:"chat-perm-root",children:Z.scopeRoot}),". Edits inside it never ask."]})}):null,z("p",{className:"chat-perm-note",children:Z.note})]}):z("p",{className:"chat-perm-body",children:"Claude wants permission to continue. Choose an option:"}),z("div",{className:"chat-perm-actions",children:H.map((N)=>z("button",{type:"button",className:ZG0(N.kind),onClick:()=>J(N.optionId),children:N.name},N.optionId))})]})}function qG0(X){return/^https?:\/\//i.test(X)?X:null}var yf=/(`[^`]+`)|(\*\*[^*]+\*\*)|(\*[^*\n]+\*)|(\[[^\]]+\]\([^)\s]+\))/g;function iU(X){let J=[],Q=0,Y=0,W;yf.lastIndex=0;while((W=yf.exec(X))!==null){if(W.index>Q)J.push(X.slice(Q,W.index));let G=W[0];if(G.startsWith("`"))J.push(z("code",{children:G.slice(1,-1)},Y++));else if(G.startsWith("**"))J.push(z("strong",{children:G.slice(2,-2)},Y++));else if(G.startsWith("*"))J.push(z("em",{children:G.slice(1,-1)},Y++));else{let Z=/\[([^\]]+)\]\(([^)\s]+)\)/.exec(G),H=Z&&qG0(Z[2]);J.push(H?z("a",{href:H,target:"_blank",rel:"noreferrer noopener",children:Z[1]},Y++):Z?Z[1]:G)}Q=W.index+G.length}if(Q<X.length)J.push(X.slice(Q));return J}var jf=/\|/,BG0=/^:?-+:?$/;function KA(X){let J=X.trim();if(J.startsWith("|"))J=J.slice(1);if(J.endsWith("|"))J=J.slice(0,-1);return J.split(/(?<!\\)\|/).map((Q)=>Q.trim().replace(/\\\|/g,"|"))}function NG0(X){let J=KA(X);if(!J.length||!J.every((Q)=>BG0.test(Q)))return null;return J.map((Q)=>{let Y=Q.startsWith(":"),W=Q.endsWith(":");if(Y&&W)return"center";if(W)return"right";if(Y)return"left";return null})}function oU({text:X}){let J=String(X).split(`
5562
5562
  `),Q=[],Y=0,W=0,G=(Z)=>/^\s*[-*]\s/.test(Z)||/^\s*\d+\.\s/.test(Z);while(Y<J.length){let Z=J[Y];if(Z.trimStart().startsWith("```")){let K=[];Y++;while(Y<J.length&&!J[Y].trimStart().startsWith("```"))K.push(J[Y]),Y++;Y++,Q.push(z("pre",{className:"chat-code",children:z("code",{children:K.join(`
5563
5563
  `)})},W++));continue}if(/^#{1,6}\s/.test(Z)){Q.push(z("p",{className:"chat-md-h",children:iU(Z.replace(/^#{1,6}\s/,""))},W++)),Y++;continue}if(G(Z)){let K=/^\s*\d+\.\s/.test(Z),U=[];while(Y<J.length&&G(J[Y]))U.push(z("li",{children:iU(J[Y].replace(/^\s*(?:[-*]|\d+\.)\s/,""))},U.length)),Y++;Q.push(K?z("ol",{className:"chat-md-list",children:U},W++):z("ul",{className:"chat-md-list",children:U},W++));continue}if(jf.test(Z)&&Y+1<J.length){let K=NG0(J[Y+1]);if(K){let U=KA(Z);Y+=2;let q=[];while(Y<J.length&&J[Y].trim()!==""&&jf.test(J[Y]))q.push(KA(J[Y])),Y++;Q.push(z("div",{className:"chat-md-table-wrap",children:O("table",{className:"chat-md-table",children:[z("thead",{children:z("tr",{children:U.map((B,N)=>z("th",{style:K[N]?{textAlign:K[N]}:void 0,children:iU(B)},N))})}),z("tbody",{children:q.map((B,N)=>z("tr",{children:U.map((F,D)=>z("td",{style:K[D]?{textAlign:K[D]}:void 0,children:B[D]!==void 0?iU(B[D]):""},D))},N))})]})},W++));continue}}if(Z.trim()===""){Y++;continue}let H=[Z];Y++;while(Y<J.length&&J[Y].trim()!==""&&!J[Y].trimStart().startsWith("```")&&!/^#{1,6}\s/.test(J[Y])&&!G(J[Y]))H.push(J[Y]),Y++;Q.push(z("p",{className:"chat-md-p",children:iU(H.join(`
5564
- `))},W++))}return z(G0,{children:Q})}var JX=x8(r8(),1);function W9(){return typeof window<"u"&&!!window.__TAURI__}function vf(){let X=typeof window<"u"?window.__TAURI__:null;if(!X)throw Error("GitHub sign-in is only available in the Maude desktop app.");return X}function y7(X,J){return vf().core.invoke(X,J)}function DZ(X,J){return vf().event.listen(X,(Q)=>J(Q.payload))}var jB=()=>y7("github_sign_in"),ff=()=>y7("github_sign_out"),vB=()=>y7("github_is_signed_in"),fB=()=>y7("github_open_verification",{url:"https://github.com/login/device"}),nU=(X)=>y7("open_github_url",{url:X}),xf=(X)=>y7("open_cloud_url",{url:X}),xB=(X)=>DZ("github://device-code",X),hf=(X)=>DZ("github://signed-in",X),gf=(X)=>DZ("menu://new-project",X),mf=(X)=>DZ("menu://report-bug",X);async function qW(X,J={}){let Q={...J.headers||{}};if(J.body)Q["Content-Type"]="application/json";let Y;try{Y=await fetch(X,{...J,headers:Q})}catch{return{ok:!1,status:0,json:{error:"Maude isn’t reachable right now."}}}let W=null;try{W=await Y.json()}catch{W=null}return{ok:Y.ok,status:Y.status,json:W}}var BW=()=>qW("/_api/github/identity"),hB=()=>qW("/_api/github/repos");var uf=(X)=>qW("/_api/github/invite",{method:"POST",body:JSON.stringify({username:X})}),gB=(X)=>qW("/_api/github/clone",{method:"POST",body:JSON.stringify(X)}),mB=(X)=>qW("/_api/github/create-project",{method:"POST",body:JSON.stringify(X)}),lf=(X)=>qW("/_api/project/create-local",{method:"POST",body:JSON.stringify(X)}),rU=(X)=>qW("/_api/design/init",{method:"POST",body:JSON.stringify({dir:X})}),pf=(X)=>qW("/_api/hub/link",{method:"POST",body:JSON.stringify(X)}),df=()=>y7("app_is_first_run");var cf=()=>y7("app_recent_projects"),x4=()=>y7("pick_directory"),q5=(X)=>y7("open_local_project",{path:X}),of=(X,J)=>y7("save_export",{filename:X,jobId:J}),OZ=()=>y7("pick_media_file"),nf=()=>y7("pick_media_files"),rf=(X)=>DZ("update-ready",X),af=()=>y7("restart_to_update"),sf=()=>y7("prefs_get_crash_reporting"),tf=(X)=>y7("prefs_set_crash_reporting",{enabled:X}),ef=()=>y7("prefs_get_claude_auto_setup"),Xx=(X)=>y7("prefs_set_claude_auto_setup",{enabled:X});function aU(X=!0){let[J,Q]=JX.useState(null),[Y,W]=JX.useState(X),G=JX.useCallback(()=>{return W(!0),fetch("/_api/preflight").then((Z)=>Z.json()).then((Z)=>{return Q(Z&&Array.isArray(Z.items)?Z:null),W(!1),Z}).catch(()=>{return Q(null),W(!1),null})},[]);return JX.useEffect(()=>{if(!X)return;let Z=!0;return fetch("/_api/preflight").then((H)=>H.json()).then((H)=>Z&&(Q(H&&Array.isArray(H.items)?H:null),W(!1))).catch(()=>Z&&(Q(null),W(!1))),()=>{Z=!1}},[X]),{report:J,loading:Y,refresh:G}}function FG0({status:X}){if(X==="present")return z("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:z("polyline",{points:"3 8.4 6.4 11.8 13 4.4"})});if(X==="unknown")return O("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[z("path",{d:"M6 6a2 2 0 1 1 2.6 1.9c-.4.2-.6.5-.6 1V10"}),z("circle",{cx:"8",cy:"12.4",r:"0.6",fill:"currentColor",stroke:"none"})]});return O("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[z("circle",{cx:"8",cy:"8",r:"5.5"}),z("line",{x1:"8",y1:"5",x2:"8",y2:"8.6"})]})}function Jx({text:X}){let J=[],Q=/`([^`]+)`/g,Y=0,W;while((W=Q.exec(X))!==null){if(W.index>Y)J.push(X.slice(Y,W.index));J.push(z("code",{children:W[1]},J.length)),Y=W.index+W[0].length}if(Y<X.length)J.push(X.slice(Y));return z(G0,{children:J})}var LG0=2000,DG0=120000,OG0=1500,Qx=180000;function MG0({mode:X,refresh:J}){let[Q,Y]=JX.useState("idle"),[W,G]=JX.useState(null),Z=JX.useRef({interval:null,deadline:0}),H=()=>{if(Z.current.interval)clearInterval(Z.current.interval);Z.current.interval=null},K=()=>{Y("waiting"),Z.current.deadline=Date.now()+DG0,Z.current.interval=setInterval(async()=>{if(Date.now()>Z.current.deadline){H(),Y("error"),G("Sign-in timed out — try again.");return}if((await J())?.items?.find((_)=>_.id==="claude")?.status==="present")H()},LG0)},U=async()=>{let F=await fetch("/_api/claude/signin",{method:"POST"}).then((D)=>D.json()).catch(()=>({ok:!1,reason:"Could not reach Maude."}));if(!F.ok){Y("error"),G(F.reason||"Could not start sign-in.");return}K()},q=()=>{Y("installing"),Z.current.deadline=Date.now()+Qx,Z.current.interval=setInterval(async()=>{if(Date.now()>Z.current.deadline){H(),Y("error"),G("Install is taking longer than expected — it may still finish in the background; you can also run the command below yourself, then Re-check.");return}let F=await fetch("/_api/claude/install-status").then((D)=>D.json()).catch(()=>null);if(F&&F.phase==="running"){Z.current.deadline=Date.now()+Qx;return}if(!F||F.phase!=="done")return;if(H(),!F.ok){Y("error"),G(F.reason||"Install failed — you can also run the command below yourself.");return}await U()},OG0)},B=async()=>{if(G(null),X==="install"){let F=await fetch("/_api/claude/install",{method:"POST"}).then((D)=>D.json()).catch(()=>({ok:!1,reason:"Could not reach Maude."}));if(!F.ok){Y("error"),G(F.reason||"Could not start the installer.");return}q()}else await U()},N=async()=>{H(),Y("idle"),await fetch("/_api/claude/signin-cancel",{method:"POST"}).catch(()=>{})};if(JX.useEffect(()=>()=>H(),[]),Q==="installing")return z("span",{className:"rdy-fix",children:z("span",{className:"rdy-fix-tx",children:"Installing Claude Code…"})});if(Q==="waiting")return O("span",{className:"rdy-fix",children:[z("span",{className:"rdy-fix-tx",children:"Waiting for you to finish signing in in your browser…"}),z("button",{type:"button",className:"rdy-copy",onClick:N,children:"Cancel"})]});return O("span",{className:"rdy-fix",children:[W?z("span",{className:"rdy-fix-tx rdy-fix-tx--err",children:W}):null,z("button",{type:"button",className:"rdy-signin","data-testid":X==="install"?"acp-setup-install":"acp-setup-signin",onClick:B,children:X==="install"?"Set up AI editing":"Sign in to Claude"})]})}function _G0({command:X}){let[J,Q]=JX.useState(!1);return O("span",{className:"rdy-cmd",children:[z("code",{className:"rdy-cmd-tx",children:X}),z("button",{type:"button",className:"rdy-copy",onClick:()=>{navigator.clipboard?.writeText(X).then(()=>{Q(!0),setTimeout(()=>Q(!1),1500)},()=>{})},"aria-label":"Copy install command",children:J?"Copied":"Copy"})]})}function AG0({item:X,refresh:J}){let[Q,Y]=JX.useState(!1),W=()=>{let G=X.remediation?.replace(/`/g,"")??"";navigator.clipboard?.writeText(G).then(()=>{Y(!0),setTimeout(()=>Y(!1),1500)},()=>{})};return O("li",{className:`rdy-row rdy-row--${X.status}${X.required?"":" rdy-row--opt"}`,"data-testid":`rdy-row-${X.id}`,children:[z("span",{className:"rdy-ic","aria-hidden":"true",children:z(FG0,{status:X.status})}),O("span",{className:"rdy-tx",children:[z("span",{className:"rdy-label",children:X.label}),z("span",{className:"rdy-detail",children:z(Jx,{text:X.detail})}),X.remediation?O("span",{className:"rdy-fix",children:[z("span",{className:"rdy-fix-tx",children:z(Jx,{text:X.remediation})}),!X.installCommand&&!X.action?z("button",{type:"button",className:"rdy-copy",onClick:W,"aria-label":`Copy the fix for ${X.label}`,children:Q?"Copied":"Copy"}):null]}):null,X.action==="signin"&&X.resolvedPath?O("span",{className:"rdy-fix-tx rdy-resolved-path",children:[X.resolvedViaMaude?"Installed by Maude: ":"Found on your PATH: ",z("code",{children:X.resolvedPath})]}):null,(X.action==="install"||X.action==="signin")&&J?z(MG0,{mode:X.action,refresh:J}):null,X.installCommand?O(G0,{children:[X.action==="install"?z("span",{className:"rdy-fix-tx rdy-fallback-label",children:"Clicking above runs this command, then opens your browser to sign in. Prefer to do it yourself?"}):null,z(_G0,{command:X.installCommand})]}):null]})]})}function rz({report:X,loading:J,refresh:Q}){return O("div",{className:"rdy",children:[z("ul",{className:"rdy-list",children:X?.items?.map((Y)=>z(AG0,{item:Y,refresh:Q},Y.id))}),Q?z("div",{className:"rdy-foot",children:z("button",{type:"button",className:"btn btn--ghost btn--sm rdy-recheck",onClick:Q,disabled:J,children:J?"Checking…":"Re-check"})}):null]})}function wG0(){let[X,J]=JX.useState(!0);if(JX.useEffect(()=>{let Q=!0;return ef().then((Y)=>Q&&J(Y!==!1)).catch(()=>{}),()=>{Q=!1}},[]),!W9())return null;return O("label",{className:"rdy-autosetup-toggle",children:[z("input",{type:"checkbox",checked:X,onChange:(Q)=>{let Y=Q.target.checked;J(Y),Xx(Y).catch(()=>J(!Y))}}),z("span",{children:"Offer to install Claude Code and sign in automatically. Turn off to see only the copy-paste command — takes effect next launch or project switch."})]})}function Yx({open:X,onClose:J}){let{report:Q,loading:Y,refresh:W}=aU(X);if(JX.useEffect(()=>{if(!X)return;let G=(Z)=>Z.key==="Escape"&&J();return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[X,J]),!X)return null;return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)J()},children:O("div",{className:"help-modal rdy-modal",role:"dialog","aria-modal":"true","aria-labelledby":"rdy-modal-title",children:[O("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"rdy-modal-title",children:"Check AI editing readiness"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:J,children:"×"})]}),O("div",{className:"help-modal-body",children:[z("p",{className:"rdy-modal-note",children:"The canvas browser, version history, and sharing work with no setup. AI editing additionally drives a Claude Code you have installed — here's what it needs:"}),Q?z(rz,{report:Q,loading:Y,refresh:W}):z("p",{className:"rdy-modal-note",children:Y?"Checking…":"Couldn't reach the readiness probe."}),z(wG0,{})]})]})})}var Gx=[{name:"design:edit",description:"Iterate on the active canvas in place",argHint:'"<feedback>"'},{name:"design:new",description:"Scaffold a new multi-artboard canvas",argHint:'Name "<brief>"'},{name:"design:setup-ds",description:"Create a new design system",argHint:'<name> ["<brief>"]'},{name:"design:critic",description:"Run the critic panel on the active canvas",argHint:"[--agent <name>]"},{name:"design:draw",description:"Draw a production-grade SVG via the geometry engine",argHint:'"<what to draw>"'},{name:"design:screenshot",description:"Capture a screenshot of the active canvas"},{name:"design:browse",description:"Open the local design browser"},{name:"design:export",description:"Export the active canvas (PNG / PDF / SVG / …)"},{name:"design:rollback",description:"Revert the last edit snapshot",argHint:"[--steps N]"},{name:"design:handoff",description:"Emit a shadcn registry-item sidecar"},{name:"design:smoke",description:"Batch-screenshot every canvas + preview specimen"},{name:"design:setup-docs",description:"Refresh the design root README + INDEX"},{name:"design:to-lottie",description:"Productionize an animation to a .lottie from code"},{name:"design:to-rn",description:"Generate a react-native-svg + Reanimated component"},{name:"design:init",description:"One-time project env init for the design plugin"},{name:"design:help",description:"List all design commands"}];function az(X){if(!X)return"";let J=String(X).trim();if(J.startsWith("/"))J=J.slice(1);return J.toLowerCase()}function Wx(X){let J=X.indexOf(":");return J>0?X.slice(0,J):"other"}function EG0(X,J){if(X.group!==J.group)return X.group<J.group?-1:1;return X.name<J.name?-1:X.name>J.name?1:0}function Zx(X,J){let Q=Array.isArray(J)?J:[],Y=new Set(Q.map((H)=>az(H?.name)).filter(Boolean)),W=new Map;for(let H of X){let K=az(H.name);if(!K)continue;W.set(K,{name:K,description:H.description||"",argHint:H.argHint||"",group:Wx(K),live:Y.has(K)})}for(let H of Q){let K=az(H?.name);if(!K)continue;let U=W.get(K);if(U){if(U.live=!0,!U.description&&H.description)U.description=H.description}else W.set(K,{name:K,description:H?.description||"",argHint:"",group:Wx(K),live:!0})}let G=Y.size?Y:new Set(W.keys());return{all:[...W.values()].sort(EG0),existsSet:G}}function UA(X){let J=(X||"").replace(/^\s+/,"");if(!J.startsWith("/"))return null;let Q=J.match(/^\/([\w:-]*)$/);if(Q)return{token:Q[1],full:null,typing:!0};let Y=J.match(/^\/([\w:-]+)(?=\s)/);if(Y)return{token:Y[1],full:`/${Y[1]}`,typing:!1};return null}function Hx(X,J,Q=8){let Y=az(J);if(!Y)return X.slice(0,Q);let W=[],G=[];for(let Z of X)if(Z.name.startsWith(Y))W.push(Z);else if(Z.name.includes(Y)||Z.description.toLowerCase().includes(Y))G.push(Z);return[...W,...G].slice(0,Q)}var zx=x8(r8(),1);function VA(X){let J=Array.isArray(X)?X:[],Q=[],Y=0;while(Y<J.length){let W=J[Y];if(W?.type==="tool-call"){let G=[],Z=Y;while(Z<J.length&&J[Z]?.type==="tool-call")G.push(J[Z]),Z++;Q.push(G.length>1?{type:"tool-group",parts:G}:{type:"single",part:G[0]}),Y=Z}else Q.push({type:"single",part:W}),Y++}return Q}function PG0(X){let J=X.map((W)=>W.toolName||"tool"),Q=[...new Set(J)];if(Q.length===1)return`Ran ${X.length} × ${Q[0]}`;let Y=Q.slice(0,3).join(", ");return`Ran ${X.length} tools — ${Y}${Q.length>3?"…":""}`}function uB({parts:X,ToolCard:J,forceOpen:Q=!1,verbose:Y=!1}){let[W,G]=zx.useState(Q),Z=X.every((K)=>K.result!==void 0),H=X.some((K)=>K.isError);return O("details",{className:"chat-toolgroup",open:Q||W,onToggle:(K)=>G(K.currentTarget.open),"data-testid":"chat-tool-group",children:[O("summary",{className:"chat-toolgroup-sum",children:[z("span",{className:`chat-tool-dot ${Z?"chat-tool-dot--done":"chat-tool-dot--run"}`}),z("span",{children:PG0(X)}),H?z("span",{className:"del",children:" · error"}):null]}),z("div",{className:"chat-toolgroup-body",children:X.map((K,U)=>z(J,{toolName:K.toolName,args:K.args,result:K.result,isError:K.isError,verbose:Y,flat:!0},K.toolCallId||U))})]})}var qA=["normal","thinking","verbose","summary"],sU="normal";function BA(X,J){let Q=Array.isArray(X)?X:[];if(J==="summary"){for(let Y=Q.length-1;Y>=0;Y--)if(Q[Y]?.type==="text")return[Q[Y]];return[]}if(J==="thinking"||J==="verbose")return Q.slice();return Q.filter((Y)=>Y?.type!=="reasoning")}function NA(X){return X==="verbose"}var sz=({size:X=16})=>z("svg",{width:X,height:X,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:z("path",{d:"M8 1.5l1.4 3.7 3.7 1.4-3.7 1.4L8 11.7 6.6 8 2.9 6.6l3.7-1.4L8 1.5z",fill:"currentColor"})}),FA=({size:X=13})=>z("svg",{width:X,height:X,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:z("path",{d:"M13.5 4.5l-7 7L3 8",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})}),RG0=({size:X=14})=>z("svg",{width:X,height:X,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:z("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),TG0=({size:X=16})=>z("svg",{width:X,height:X,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:z("path",{d:"M8 12.5V4.2M4.4 7.6 8 4l3.6 3.6",stroke:"currentColor",strokeWidth:"2.1",strokeLinecap:"round",strokeLinejoin:"round"})}),Fx=({size:X=14})=>O("svg",{width:X,height:X,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[z("rect",{x:"5.5",y:"5.5",width:"8",height:"8",rx:"1.3",stroke:"currentColor",strokeWidth:"1.4"}),z("path",{d:"M10.5 5.5V3.8A1.3 1.3 0 0 0 9.2 2.5H3.8A1.3 1.3 0 0 0 2.5 3.8v5.4a1.3 1.3 0 0 0 1.3 1.3h1.7",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),IG0=({size:X=14})=>z("svg",{width:X,height:X,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:z("path",{d:"M13 8A5 5 0 1 1 11.3 4.3M13 2.5v3.2h-3.2",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})}),kG0=({size:X=15})=>O("svg",{width:X,height:X,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[z("rect",{x:"2",y:"2",width:"5",height:"5",rx:"1",fill:"currentColor"}),z("rect",{x:"9",y:"2",width:"5",height:"5",rx:"1",fill:"currentColor",opacity:"0.55"}),z("rect",{x:"2",y:"9",width:"5",height:"5",rx:"1",fill:"currentColor",opacity:"0.55"}),z("rect",{x:"9",y:"9",width:"5",height:"5",rx:"1",fill:"currentColor",opacity:"0.3"})]}),CG0=[{label:"/design:edit",prompt:"/design:edit "},{label:"/design:new",prompt:"/design:new "},{label:"/design:critic",prompt:"/design:critic"},{label:"/design:screenshot",prompt:"/design:screenshot"}],$G0=["/design:edit make the primary button more prominent","/design:critic",'/design:new Pricing "a 3-tier pricing page"'];function Kx(X,J,Q){let Y=J.some((W)=>!X.current.has(W.id));if(X.current=new Set(J.map((W)=>W.id)),Y)Q?.()}function lB(X,J){try{return localStorage.getItem(X)??J}catch{return J}}function Lx(X,J){try{localStorage.setItem(X,J)}catch{}}var Dx="maude-acp-picks";function SG0(){let X=lB(Dx,null);if(X)try{let W=JSON.parse(X);if(W&&typeof W==="object")return W}catch{}let J={},Q=lB("maude-acp-model",""),Y=lB("maude-acp-effort","");if(Q)J.model=Q;if(Y&&Y!=="balanced")J.effort=Y;return J}function bG0(X){Lx(Dx,JSON.stringify(X))}function yG0(X){if(!X)return null;return(X.split("/").pop()||X).replace(/\.(tsx|html)$/i,"")}var jG0=new Set(["bypassPermissions","dontAsk"]);function vG0(X){if(!X?.currentModeId||!X.availableModes?.length)return null;let Q=X.availableModes.find((Y)=>Y.id===X.currentModeId)?.name||X.currentModeId;return jG0.has(X.currentModeId)?`${Q} — no prompts`:`${Q} — you'll be asked`}function fG0({modes:X,onSetMode:J}){if(!Of(X))return null;let Y=X.availableModes.find((K)=>K.id===X.currentModeId)?.name||X.currentModeId,W=X.currentModeId==="plan",G=new Set(X.availableModes.map((K)=>K.id)),Z=G.has("acceptEdits")?"acceptEdits":G.has("default")?"default":null,H=Z&&(X.availableModes.find((K)=>K.id===Z)?.name||Z);return O("div",{className:"chat-mode-banner",role:"alert","data-testid":"chat-mode-banner",children:[z("span",{className:"chat-mode-banner-icon","aria-hidden":"true",children:"⏸"}),O("span",{className:"chat-mode-banner-text",children:[z("b",{children:Y})," — ",W?"Claude is planning and won't edit files or run tools.":"edits and tools without a standing approval are denied — nothing will change."]}),Z?O("button",{type:"button",className:"chat-mode-banner-cta",onClick:()=>J(Z),"data-testid":"chat-mode-banner-switch",children:["Switch to ",H]}):null]})}var Ux=/\[(?:image|file|link)-\d+\]/g,xG0=/\.(?:png|jpe?g|gif|webp|svg|avif|bmp|heic|heif|ico|tiff?)$/i;function hG0(X){let J=(X||"").trim();if(!J||/\s/.test(J))return null;let Q=/^(?:https?|ftp):\/\/[^\s]+$/i.test(J),Y=/^[a-zA-Z]:\\[^\s]+$/.test(J),W=/^(?:~|\.{0,2})\/[^\s]+$/.test(J),G=J.includes("/")&&/\.[a-z0-9]{1,8}$/i.test(J);if(!Q&&!Y&&!W&&!G)return null;let Z=J.split(/[?#]/)[0];return{kind:xG0.test(Z)?"image":Q?"link":"file",value:J}}function Vx(X,J){let Q=new RegExp(`\\[${J}-(\\d+)\\]`,"g"),Y=0,W;while(W=Q.exec(X||""))Y=Math.max(Y,parseInt(W[1],10));return Y+1}function gG0(X,J="chip"){let Q=[],Y=0,W,G=0;Ux.lastIndex=0;while(W=Ux.exec(X)){if(W.index>Y)Q.push(X.slice(Y,W.index));Q.push(z("span",{className:"chat-paste-chip",children:W[0]},`${J}-${G++}`)),Y=W.index+W[0].length}if(Y<X.length)Q.push(X.slice(Y));return Q}function mG0(X){let Q=((X?.files)?Array.from(X.files):[]).find((W)=>W.type&&W.type.startsWith("image/"));if(Q)return Q;let Y=X?.items?Array.from(X.items):[];for(let W of Y)if(W.kind==="file"&&W.type&&W.type.startsWith("image/")){let G=W.getAsFile();if(G)return G}return null}function qx(X,J){if(document.execCommand&&document.execCommand("insertText",!1,J))return;let Q=X.selectionStart??X.value.length,Y=X.selectionEnd??Q,W=X.value.slice(0,Q)+J+X.value.slice(Y);Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value")?.set?.call(X,W),X.dispatchEvent(new Event("input",{bubbles:!0}));let Z=Q+J.length;X.setSelectionRange(Z,Z)}async function uG0(X){let J=await X.arrayBuffer(),Q=await fetch("/_api/acp/attachment",{method:"POST",headers:{"Content-Type":X.type||"application/octet-stream"},body:J});if(!Q.ok)return null;let Y=await Q.json().catch(()=>null);return Y&&Y.path||null}function Ox({text:X}){let J=g0.useContext(tU),Q=Tf(X,J?.designRel);return O("div",{className:"chat-bubble",children:[z(oU,{text:X}),Q.length?z("div",{className:"chat-thumbrow",children:Q.map((Y)=>{let W=Y.split("/").pop();return z(LA,{src:Y,label:`Open ${W}`,caption:W},Y)})}):null]})}function Mx({text:X}){return O("details",{className:"chat-think",children:[O("summary",{className:"chat-think-sum",children:[z("span",{className:"chat-think-spark",children:z(sz,{size:11})}),"Thinking"]}),z("div",{className:"chat-think-body",children:z(oU,{text:X})})]})}function Bx(X,J=800){let Q;try{Q=typeof X==="string"?X:JSON.stringify(X,null,2)}catch{return null}if(!Q||Q==="{}"||Q==="[]"||Q==='""'||Q==="null")return null;return Q.length>J?`${Q.slice(0,J)}…`:Q}function pB({toolName:X,args:J,result:Q,isError:Y,verbose:W,flat:G=!1}){let Z=Q===void 0,H=J&&typeof J==="object"?J.path||J.file||J.filePath:void 0,K=W&&J&&typeof J==="object"&&Object.keys(J).length?Bx(J):null,U=W&&!Z&&Q!=null?Bx(Q):null,q=Z?"running…":Y?"failed":"done";if(G)return O("div",{className:"chat-tool-row","data-testid":"chat-tool-row",children:[O("div",{className:"chat-tool-row-main",children:[z("span",{className:`chat-tool-dot ${Z?"chat-tool-dot--run":"chat-tool-dot--done"}`}),z("b",{children:X}),H?z("span",{className:"chat-tool-path",children:String(H).split("/").pop()}):null,z("span",{className:`chat-tool-row-status${Y?" del":""}`,children:q})]}),K?z("pre",{className:"chat-tool-detail",children:K}):null,U?z("pre",{className:"chat-tool-detail",children:U}):null]});return O("div",{className:"chat-tool",children:[O("div",{className:"chat-tool-hd",children:[z("b",{children:X}),H?z("span",{className:"chat-tool-path",children:String(H).split("/").pop()}):null,z("span",{className:`chat-tool-dot ${Z?"chat-tool-dot--run":"chat-tool-dot--done"}`})]}),!Z?O("div",{className:"chat-tool-body",children:[z("div",{className:`chat-tool-line${Y?" del":""}`,children:Y?"failed":"done"}),K?z("pre",{className:"chat-tool-detail",children:K}):null,U?z("pre",{className:"chat-tool-detail",children:U}):null]}):null]})}var tU=g0.createContext(null);function _x(X){return`/_api/acp/attachment?name=${encodeURIComponent(X)}`}function LA({src:X,label:J="Open image",caption:Q}){let Y=g0.useContext(tU),W=z("button",{type:"button",className:"chat-thumb-btn","aria-label":J,onClick:()=>Y?.openLightbox(X),children:z("img",{className:"chat-thumb",src:X,alt:"",loading:"lazy"})});if(!Q)return W;return O("figure",{className:"chat-thumb-fig",children:[W,z("figcaption",{className:"chat-thumb-cap",title:Q,children:Q})]})}function lG0({token:X,kind:J}){let Q=g0.useContext(tU),[Y,W]=g0.useState(()=>J==="image"?Q?.chipName(X):null);if(g0.useEffect(()=>{if(J!=="image"||Y||!Q)return;let G=0,Z=setInterval(()=>{let H=Q.chipName(X);if(H)W(H),clearInterval(Z);else if(++G>20)clearInterval(Z)},250);return()=>clearInterval(Z)},[J,Y,Q,X]),!Y)return z("span",{className:"chat-paste-chip",children:X});return z(LA,{src:_x(Y),label:"Open pasted image"})}function pG0({src:X,onClose:J}){let Q=g0.useRef(null),Y=g0.useRef(null);return g0.useEffect(()=>{Y.current=document.activeElement,Q.current?.focus();function W(G){if(G.key==="Escape")G.preventDefault(),G.stopPropagation(),J()}return window.addEventListener("keydown",W,!0),()=>{window.removeEventListener("keydown",W,!0);try{Y.current?.focus?.()}catch{}}},[J]),O("div",{className:"chat-lightbox",role:"dialog","aria-modal":"true","aria-label":"Pasted image",onClick:J,children:[z("img",{src:X,alt:"pasted image, enlarged",onClick:(W)=>W.stopPropagation()}),z("button",{type:"button",ref:Q,className:"chat-lightbox-close","aria-label":"Close image",title:"Close image",onClick:J,children:"×"})]})}function dG0({text:X}){let J=Rf(X),Q=[],Y=[];return J.forEach((W,G)=>{if(W.type==="text")Q.push(z("span",{children:W.text},`t-${G}`));else if(W.type==="chip"&&W.kind!=="image")Q.push(z("span",{className:"chat-paste-chip",children:W.token},`c-${G}`));else if(W.type==="chip")Y.push(z(lG0,{token:W.token,kind:W.kind},`c-${G}`));else Y.push(z(LA,{src:_x(W.name),label:"Open pasted image"},`a-${G}`))}),O("div",{className:"chat-bubble",children:[Q,Y.length?z("div",{className:"chat-thumbrow",children:Y}):null]})}function cG0(){return O("div",{className:"chat-msg chat-msg--user",children:[z(r_.Parts,{components:{Text:dG0}}),z("div",{className:"chat-msg-actions","data-testid":"chat-msg-actions",children:z(uU.Copy,{className:"chat-msg-action","aria-label":"Copy message",title:"Copy message",children:z(Fx,{size:12})})})]})}function iG0(){let X=V_((Z)=>Z.content)||[],{transcriptView:J}=g0.useContext(tU)||{},Q=J||sU,Y=g0.useMemo(()=>BA(X,Q),[X,Q]),W=g0.useMemo(()=>VA(Y),[Y]),G=NA(Q);return O("div",{className:"chat-msg chat-msg--assistant",children:[O("div",{className:"chat-msg-role",children:[z("span",{className:"chat-msg-spark",children:z(sz,{size:13})}),"Claude"]}),W.map((Z,H)=>Z.type==="tool-group"?z(uB,{parts:Z.parts,ToolCard:pB,forceOpen:G,verbose:G},`g-${H}`):Z.part?.type==="text"?z(Ox,{text:Z.part.text},`t-${H}`):Z.part?.type==="reasoning"?z(Mx,{text:Z.part.text},`r-${H}`):Z.part?.type==="tool-call"?z(pB,{toolName:Z.part.toolName,args:Z.part.args,result:Z.part.result,isError:Z.part.isError,verbose:G},Z.part.toolCallId||`tc-${H}`):null),O("div",{className:"chat-msg-actions","data-testid":"chat-msg-actions",children:[z(uU.Copy,{className:"chat-msg-action","aria-label":"Copy message",title:"Copy message",children:z(Fx,{size:12})}),z(uU.Reload,{className:"chat-msg-action","aria-label":"Retry",title:"Retry — re-send the last message",children:z(IG0,{size:12})})]})]})}function oG0({tools:X=[],transcriptView:J,onSetTranscriptView:Q}){let W=OB((G)=>G.isRunning)||X.length>0;return O("div",{className:"chat-statusrow",children:[z("span",{className:`chat-status-dot ${W?"chat-status-dot--working":"chat-status-dot--ready"}`}),W?"Working…":"Ready",z("span",{className:"chat-statusrow-sep",children:"·"}),z("span",{className:"chat-statusrow-cc",children:"Claude Code"}),z("span",{className:"chat-statusrow-spacer"}),O("label",{className:"chat-view-label",title:"Transcript view — how much detail replies show",children:[z("span",{className:"chat-view-label-tx",children:"View"}),z("select",{className:"chat-select",value:J,"aria-label":"Transcript view","data-testid":"chat-transcript-menu",onChange:(G)=>Q(G.target.value),children:qA.map((G)=>z("option",{value:G,children:G[0].toUpperCase()+G.slice(1)},G))})]})]})}function nG0(X){let[,J]=g0.useState(0),Q=g0.useRef(null);if(g0.useEffect(()=>{if(!X){Q.current=null;return}Q.current=Date.now();let W=setInterval(()=>J((G)=>G+1),1000);return()=>clearInterval(W)},[X]),!X||Q.current==null)return null;let Y=Math.floor((Date.now()-Q.current)/1000);if(Y<1)return null;return`${Math.floor(Y/60)}:${String(Y%60).padStart(2,"0")}`}function rG0({tools:X}){let Q=OB((W)=>W.isRunning)||X.length>0,Y=nG0(Q);if(!Q)return null;return O("div",{className:"chat-activity",role:"status","aria-live":"polite",children:[z("span",{className:"chat-activity-spin","aria-hidden":"true"}),z("span",{className:"chat-activity-text",children:_f(X)}),Y?z("span",{className:"chat-activity-elapsed",children:Y}):null]})}function aG0({parts:X,viewMode:J}){let Q=J||sU,Y=g0.useMemo(()=>BA(X,Q),[X,Q]);if(!Y.length)return null;let W=VA(Y),G=NA(Q);return O("div",{className:"chat-msg chat-msg--assistant chat-msg--continued",children:[O("div",{className:"chat-msg-role",children:[z("span",{className:"chat-msg-spark",children:z(sz,{size:13})}),"Claude"]}),W.map((Z,H)=>Z.type==="tool-group"?z(uB,{parts:Z.parts,ToolCard:pB,forceOpen:G,verbose:G},`g-${H}`):Z.part?.type==="text"?z(Ox,{text:Z.part.text},`t-${H}`):Z.part?.type==="reasoning"?z(Mx,{text:Z.part.text},`r-${H}`):Z.part?.type==="tool-call"?z(pB,{toolName:Z.part.toolName,args:Z.part.args,result:Z.part.result,isError:Z.part.isError,verbose:G},Z.part.toolCallId||`tc-${H}`):null)]})}function Ax(X){if(!X)return null;let J=X>100000000000?X:X*1000;try{return new Date(J).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return null}}function sG0({usage:X,modes:J}){let[Q,Y]=g0.useState(!1),[W,G]=g0.useState(null),Z=g0.useRef(null),H=g0.useRef(null);g0.useEffect(()=>{if(!Q)return;let N=()=>{let _=H.current?.getBoundingClientRect();if(_)G({bottom:window.innerHeight-_.top+8,right:window.innerWidth-_.right})};N();let F=(_)=>{if(Z.current&&!Z.current.contains(_.target))Y(!1)},D=(_)=>{if(_.key==="Escape")Y(!1)};return document.addEventListener("pointerdown",F),document.addEventListener("keydown",D),window.addEventListener("resize",N),()=>{document.removeEventListener("pointerdown",F),document.removeEventListener("keydown",D),window.removeEventListener("resize",N)}},[Q]);let K=X.context,U=vG0(J),q=X.asOf?new Date(X.asOf).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):null,B=X.rateLimit?Ax(X.rateLimit.resetsAt):null;return O("div",{className:"chat-foot-info",ref:Z,children:[z("button",{ref:H,type:"button",className:"chat-foot-info-btn","aria-label":"Chat info","aria-expanded":Q,title:"Chat info","data-testid":"chat-foot-info-btn",onClick:()=>Y((N)=>!N),children:"ⓘ"}),Q&&W?O("div",{className:"chat-foot-popover",role:"dialog","aria-label":"Chat info","data-testid":"chat-foot-popover",style:{bottom:W.bottom,right:W.right},children:[K?O("div",{className:"chat-foot-popover-section",children:[O("div",{className:"chat-foot-popover-label-row",children:[z("span",{children:"Context"}),O("span",{children:[K.pct,"%"]})]}),z("span",{className:"chat-usage-bar chat-usage-bar--wide","aria-hidden":"true",children:z("span",{className:"chat-usage-bar-fill",style:{width:`${K.pct}%`}})}),O("div",{className:"chat-foot-popover-row--muted",children:[K.used.toLocaleString()," / ",K.size.toLocaleString()," tokens"]})]}):null,X.rateLimit?O(G0,{children:[z("div",{className:"chat-foot-popover-sep"}),O("div",{className:"chat-foot-popover-label-row",children:[z("span",{children:X.rateLimit.label}),z("span",{children:X.rateLimit.pct!=null?`${X.rateLimit.pct}%`:"—"})]}),B?O("div",{className:"chat-foot-popover-row--muted",children:["resets ",B]}):null]}):null,U?O(G0,{children:[z("div",{className:"chat-foot-popover-sep"}),z("div",{className:"chat-foot-popover-row",children:U})]}):null,z("div",{className:"chat-foot-popover-sep"}),O("div",{className:"chat-foot-popover-foot",children:[z("div",{className:"chat-foot-popover-row--muted",children:"↵ to send · ⇧↵ newline"}),O("div",{className:"chat-foot-popover-row--muted",children:["Uses your Claude subscription",q?` · updated ${q}`:""]})]})]}):null]})}function tG0({rateLimit:X,onDismiss:J}){if(!X)return null;let Q=Ax(X.resetsAt);return O("div",{className:"chat-usage-banner",role:"status","data-testid":"chat-usage-banner",children:[O("span",{children:["You're at ",X.pct!=null?`${X.pct}%`:"high usage"," of your ",X.label,Q?` · resets ${Q}`:""]}),z("button",{type:"button",className:"chat-usage-banner-x","aria-label":"Dismiss",title:"Dismiss",onClick:J,children:"×"})]})}function eG0({error:X,onRetry:J}){let[Q,Y]=g0.useState(!1);if(!X)return null;return O("div",{className:"chat-error-card",role:"alert","data-testid":"chat-error-card",children:[O("div",{className:"chat-error-hd",children:[z("span",{className:"chat-error-ic","aria-hidden":"true",children:"⚠"}),z("b",{children:"Connection problem"})]}),Q?z("p",{className:"chat-error-detail",children:X.message}):z("p",{className:"chat-error-detail chat-error-detail--muted",children:"Something interrupted the connection to Claude."}),O("div",{className:"chat-error-actions",children:[z("button",{type:"button",className:"btn btn--sm",onClick:()=>Y((W)=>!W),children:Q?"Hide details":"View details"}),z("button",{type:"button",className:"btn btn--primary btn--sm",onClick:J,children:"Try again"})]})]})}function XZ0(){return O("div",{className:"chat-empty",children:[z("span",{className:"chat-empty-mark",children:z(sz,{size:28})}),z("div",{className:"chat-empty-title",children:"Edit this canvas with Claude"}),z("div",{className:"chat-empty-sub",children:"Ask for a change, a critique, or a new screen — Claude runs on your own subscription."}),O(U5.Suggestion,{prompt:"/design:setup-ds ",send:!1,className:"chat-empty-cta",children:[z("span",{className:"chat-empty-cta-ic",children:z(kG0,{size:15})}),"Create new design system"]}),z("div",{className:"chat-sugs",children:$G0.map((X)=>z(U5.Suggestion,{prompt:X,send:!1,className:"chat-sug",children:X},X))})]})}function JZ0({openComments:X=0}){return O("div",{className:"chat-quick",children:[X>0?z(U5.Suggestion,{prompt:"/design:edit fix open comments",send:!1,className:"btn btn--ghost btn--sm chat-qa chat-qa--comments","data-testid":"chat-qa-implement-comments",children:`✓ Implement ${X} comment${X===1?"":"s"}`}):null,CG0.map((J)=>z(U5.Suggestion,{prompt:J.prompt,send:!1,className:"btn btn--ghost btn--sm chat-qa",children:J.label},J.label))]})}function QZ0(X){let[J,Q]=g0.useState([]);return g0.useEffect(()=>X.onCommands(Q),[X]),g0.useMemo(()=>Zx(Gx,J),[J])}function YZ0({items:X,activeIndex:J,onPick:Q,onHover:Y}){if(!X.length)return null;return z("div",{className:"chat-cmd-menu",role:"listbox","data-testid":"chat-cmd-menu",children:X.map((W,G)=>O("button",{type:"button",role:"option","aria-selected":G===J,"data-testid":`chat-cmd-item-${W.name.replace(/[^a-z0-9]+/gi,"-")}`,className:`chat-cmd-item${G===J?" is-active":""}`,onMouseEnter:()=>Y(G),onMouseDown:(Z)=>{Z.preventDefault(),Q(W)},children:[O("span",{className:`chat-cmd-name chat-cmd-name--${W.group}`,children:["/",W.name]}),W.description?z("span",{className:"chat-cmd-desc",children:W.description}):null,W.argHint?z("span",{className:"chat-cmd-arg",children:W.argHint}):null]},W.name))})}function WZ0({existsSet:X,attachmentsRef:J,onAttachChange:Q}){let Y=DB((F)=>F.text),W=g0.useRef(null),G=UA(Y),Z=G?az(G.token):"",H=!!(G&&Z&&X.has(Z)),K=null,U=0;if(H){let F=Y.match(/^\s*/)[0],D=`/${G.token}`;K=O(G0,{children:[F,z("span",{className:"chat-cmd-pill",children:D})]}),U=F.length+D.length}let q=Y.slice(U),B=Y.endsWith(`
5564
+ `))},W++))}return z(G0,{children:Q})}var JX=x8(r8(),1);function W9(){return typeof window<"u"&&!!window.__TAURI__}function vf(){let X=typeof window<"u"?window.__TAURI__:null;if(!X)throw Error("GitHub sign-in is only available in the Maude desktop app.");return X}function y7(X,J){return vf().core.invoke(X,J)}function DZ(X,J){return vf().event.listen(X,(Q)=>J(Q.payload))}var jB=()=>y7("github_sign_in"),ff=()=>y7("github_sign_out"),vB=()=>y7("github_is_signed_in"),fB=()=>y7("github_open_verification",{url:"https://github.com/login/device"}),nU=(X)=>y7("open_github_url",{url:X}),xf=(X)=>y7("open_cloud_url",{url:X}),xB=(X)=>DZ("github://device-code",X),hf=(X)=>DZ("github://signed-in",X),gf=(X)=>DZ("menu://new-project",X),mf=(X)=>DZ("menu://report-bug",X);async function qW(X,J={}){let Q={...J.headers||{}};if(J.body)Q["Content-Type"]="application/json";let Y;try{Y=await fetch(X,{...J,headers:Q})}catch{return{ok:!1,status:0,json:{error:"Maude isn’t reachable right now."}}}let W=null;try{W=await Y.json()}catch{W=null}return{ok:Y.ok,status:Y.status,json:W}}var BW=()=>qW("/_api/github/identity"),hB=()=>qW("/_api/github/repos");var uf=(X)=>qW("/_api/github/invite",{method:"POST",body:JSON.stringify({username:X})}),gB=(X)=>qW("/_api/github/clone",{method:"POST",body:JSON.stringify(X)}),mB=(X)=>qW("/_api/github/create-project",{method:"POST",body:JSON.stringify(X)}),lf=(X)=>qW("/_api/project/create-local",{method:"POST",body:JSON.stringify(X)}),rU=(X)=>qW("/_api/design/init",{method:"POST",body:JSON.stringify({dir:X})}),pf=(X)=>qW("/_api/hub/link",{method:"POST",body:JSON.stringify(X)}),df=()=>y7("app_is_first_run");var cf=()=>y7("app_recent_projects"),x4=()=>y7("pick_directory"),q5=(X)=>y7("open_local_project",{path:X}),of=(X,J)=>y7("save_export",{filename:X,jobId:J}),OZ=()=>y7("pick_media_file"),nf=()=>y7("pick_media_files"),rf=(X)=>DZ("update-ready",X),af=()=>y7("restart_to_update"),sf=()=>y7("prefs_get_crash_reporting"),tf=(X)=>y7("prefs_set_crash_reporting",{enabled:X}),ef=()=>y7("prefs_get_claude_auto_setup"),Xx=(X)=>y7("prefs_set_claude_auto_setup",{enabled:X});function aU(X=!0){let[J,Q]=JX.useState(null),[Y,W]=JX.useState(X),G=JX.useCallback(()=>{return W(!0),fetch("/_api/preflight").then((Z)=>Z.json()).then((Z)=>{return Q(Z&&Array.isArray(Z.items)?Z:null),W(!1),Z}).catch(()=>{return Q(null),W(!1),null})},[]);return JX.useEffect(()=>{if(!X)return;let Z=!0;return fetch("/_api/preflight").then((H)=>H.json()).then((H)=>Z&&(Q(H&&Array.isArray(H.items)?H:null),W(!1))).catch(()=>Z&&(Q(null),W(!1))),()=>{Z=!1}},[X]),{report:J,loading:Y,refresh:G}}function FG0({status:X}){if(X==="present")return z("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:z("polyline",{points:"3 8.4 6.4 11.8 13 4.4"})});if(X==="unknown")return O("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[z("path",{d:"M6 6a2 2 0 1 1 2.6 1.9c-.4.2-.6.5-.6 1V10"}),z("circle",{cx:"8",cy:"12.4",r:"0.6",fill:"currentColor",stroke:"none"})]});return O("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[z("circle",{cx:"8",cy:"8",r:"5.5"}),z("line",{x1:"8",y1:"5",x2:"8",y2:"8.6"})]})}function Jx({text:X}){let J=[],Q=/`([^`]+)`/g,Y=0,W;while((W=Q.exec(X))!==null){if(W.index>Y)J.push(X.slice(Y,W.index));J.push(z("code",{children:W[1]},J.length)),Y=W.index+W[0].length}if(Y<X.length)J.push(X.slice(Y));return z(G0,{children:J})}var LG0=2000,DG0=120000,OG0=1500,Qx=180000;function MG0({mode:X,refresh:J}){let[Q,Y]=JX.useState("idle"),[W,G]=JX.useState(null),Z=JX.useRef({interval:null,deadline:0}),H=()=>{if(Z.current.interval)clearInterval(Z.current.interval);Z.current.interval=null},K=()=>{Y("waiting"),Z.current.deadline=Date.now()+DG0,Z.current.interval=setInterval(async()=>{if(Date.now()>Z.current.deadline){H(),Y("error"),G("Sign-in timed out — try again.");return}if((await J())?.items?.find((_)=>_.id==="claude")?.status==="present")H()},LG0)},U=async()=>{let F=await fetch("/_api/claude/signin",{method:"POST"}).then((D)=>D.json()).catch(()=>({ok:!1,reason:"Could not reach Maude."}));if(!F.ok){Y("error"),G(F.reason||"Could not start sign-in.");return}K()},q=()=>{Y("installing"),Z.current.deadline=Date.now()+Qx,Z.current.interval=setInterval(async()=>{if(Date.now()>Z.current.deadline){H(),Y("error"),G("Install is taking longer than expected — it may still finish in the background; you can also run the command below yourself, then Re-check.");return}let F=await fetch("/_api/claude/install-status").then((D)=>D.json()).catch(()=>null);if(F&&F.phase==="running"){Z.current.deadline=Date.now()+Qx;return}if(!F||F.phase!=="done")return;if(H(),!F.ok){Y("error"),G(F.reason||"Install failed — you can also run the command below yourself.");return}await U()},OG0)},B=async()=>{if(G(null),X==="install"){let F=await fetch("/_api/claude/install",{method:"POST"}).then((D)=>D.json()).catch(()=>({ok:!1,reason:"Could not reach Maude."}));if(!F.ok){Y("error"),G(F.reason||"Could not start the installer.");return}q()}else await U()},N=async()=>{H(),Y("idle"),await fetch("/_api/claude/signin-cancel",{method:"POST"}).catch(()=>{})};if(JX.useEffect(()=>()=>H(),[]),Q==="installing")return z("span",{className:"rdy-fix",children:z("span",{className:"rdy-fix-tx",children:"Installing Claude Code…"})});if(Q==="waiting")return O("span",{className:"rdy-fix",children:[z("span",{className:"rdy-fix-tx",children:"Waiting for you to finish signing in in your browser…"}),z("button",{type:"button",className:"rdy-copy",onClick:N,children:"Cancel"})]});return O("span",{className:"rdy-fix",children:[W?z("span",{className:"rdy-fix-tx rdy-fix-tx--err",children:W}):null,z("button",{type:"button",className:"rdy-signin","data-testid":X==="install"?"acp-setup-install":"acp-setup-signin",onClick:B,children:X==="install"?"Set up AI editing":"Sign in to Claude"})]})}function _G0({command:X}){let[J,Q]=JX.useState(!1);return O("span",{className:"rdy-cmd",children:[z("code",{className:"rdy-cmd-tx",children:X}),z("button",{type:"button",className:"rdy-copy",onClick:()=>{navigator.clipboard?.writeText(X).then(()=>{Q(!0),setTimeout(()=>Q(!1),1500)},()=>{})},"aria-label":"Copy install command",children:J?"Copied":"Copy"})]})}function AG0({item:X,refresh:J}){let[Q,Y]=JX.useState(!1),W=()=>{let G=X.remediation?.replace(/`/g,"")??"";navigator.clipboard?.writeText(G).then(()=>{Y(!0),setTimeout(()=>Y(!1),1500)},()=>{})};return O("li",{className:`rdy-row rdy-row--${X.status}${X.required?"":" rdy-row--opt"}`,"data-testid":`rdy-row-${X.id}`,children:[z("span",{className:"rdy-ic","aria-hidden":"true",children:z(FG0,{status:X.status})}),O("span",{className:"rdy-tx",children:[z("span",{className:"rdy-label",children:X.label}),z("span",{className:"rdy-detail",children:z(Jx,{text:X.detail})}),X.remediation?O("span",{className:"rdy-fix",children:[z("span",{className:"rdy-fix-tx",children:z(Jx,{text:X.remediation})}),!X.installCommand&&!X.action?z("button",{type:"button",className:"rdy-copy",onClick:W,"aria-label":`Copy the fix for ${X.label}`,children:Q?"Copied":"Copy"}):null]}):null,X.resolvedPath?O("span",{className:"rdy-fix-tx rdy-resolved-path",children:[X.resolvedViaMaude?"Installed by Maude: ":"Found on your PATH: ",z("code",{children:X.resolvedPath})]}):null,(X.action==="install"||X.action==="signin")&&J?z(MG0,{mode:X.action,refresh:J}):null,X.installCommand?O(G0,{children:[X.action==="install"?z("span",{className:"rdy-fix-tx rdy-fallback-label",children:"Clicking above runs this command, then opens your browser to sign in. Prefer to do it yourself?"}):null,z(_G0,{command:X.installCommand})]}):null]})]})}function rz({report:X,loading:J,refresh:Q}){return O("div",{className:"rdy",children:[z("ul",{className:"rdy-list",children:X?.items?.map((Y)=>z(AG0,{item:Y,refresh:Q},Y.id))}),Q?z("div",{className:"rdy-foot",children:z("button",{type:"button",className:"btn btn--ghost btn--sm rdy-recheck",onClick:Q,disabled:J,children:J?"Checking…":"Re-check"})}):null]})}function wG0(){let[X,J]=JX.useState(!0);if(JX.useEffect(()=>{let Q=!0;return ef().then((Y)=>Q&&J(Y!==!1)).catch(()=>{}),()=>{Q=!1}},[]),!W9())return null;return O("label",{className:"rdy-autosetup-toggle",children:[z("input",{type:"checkbox",checked:X,onChange:(Q)=>{let Y=Q.target.checked;J(Y),Xx(Y).catch(()=>J(!Y))}}),z("span",{children:"Offer to install Claude Code and sign in automatically. Turn off to see only the copy-paste command — takes effect next launch or project switch."})]})}function Yx({open:X,onClose:J}){let{report:Q,loading:Y,refresh:W}=aU(X);if(JX.useEffect(()=>{if(!X)return;let G=(Z)=>Z.key==="Escape"&&J();return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[X,J]),!X)return null;return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)J()},children:O("div",{className:"help-modal rdy-modal",role:"dialog","aria-modal":"true","aria-labelledby":"rdy-modal-title",children:[O("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"rdy-modal-title",children:"Check AI editing readiness"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:J,children:"×"})]}),O("div",{className:"help-modal-body",children:[z("p",{className:"rdy-modal-note",children:"The canvas browser, version history, and sharing work with no setup. AI editing additionally drives a Claude Code you have installed — here's what it needs:"}),Q?z(rz,{report:Q,loading:Y,refresh:W}):z("p",{className:"rdy-modal-note",children:Y?"Checking…":"Couldn't reach the readiness probe."}),z(wG0,{})]})]})})}var Gx=[{name:"design:edit",description:"Iterate on the active canvas in place",argHint:'"<feedback>"'},{name:"design:new",description:"Scaffold a new multi-artboard canvas",argHint:'Name "<brief>"'},{name:"design:setup-ds",description:"Create a new design system",argHint:'<name> ["<brief>"]'},{name:"design:critic",description:"Run the critic panel on the active canvas",argHint:"[--agent <name>]"},{name:"design:draw",description:"Draw a production-grade SVG via the geometry engine",argHint:'"<what to draw>"'},{name:"design:screenshot",description:"Capture a screenshot of the active canvas"},{name:"design:browse",description:"Open the local design browser"},{name:"design:export",description:"Export the active canvas (PNG / PDF / SVG / …)"},{name:"design:rollback",description:"Revert the last edit snapshot",argHint:"[--steps N]"},{name:"design:handoff",description:"Emit a shadcn registry-item sidecar"},{name:"design:smoke",description:"Batch-screenshot every canvas + preview specimen"},{name:"design:setup-docs",description:"Refresh the design root README + INDEX"},{name:"design:to-lottie",description:"Productionize an animation to a .lottie from code"},{name:"design:to-rn",description:"Generate a react-native-svg + Reanimated component"},{name:"design:init",description:"One-time project env init for the design plugin"},{name:"design:help",description:"List all design commands"}];function az(X){if(!X)return"";let J=String(X).trim();if(J.startsWith("/"))J=J.slice(1);return J.toLowerCase()}function Wx(X){let J=X.indexOf(":");return J>0?X.slice(0,J):"other"}function EG0(X,J){if(X.group!==J.group)return X.group<J.group?-1:1;return X.name<J.name?-1:X.name>J.name?1:0}function Zx(X,J){let Q=Array.isArray(J)?J:[],Y=new Set(Q.map((H)=>az(H?.name)).filter(Boolean)),W=new Map;for(let H of X){let K=az(H.name);if(!K)continue;W.set(K,{name:K,description:H.description||"",argHint:H.argHint||"",group:Wx(K),live:Y.has(K)})}for(let H of Q){let K=az(H?.name);if(!K)continue;let U=W.get(K);if(U){if(U.live=!0,!U.description&&H.description)U.description=H.description}else W.set(K,{name:K,description:H?.description||"",argHint:"",group:Wx(K),live:!0})}let G=Y.size?Y:new Set(W.keys());return{all:[...W.values()].sort(EG0),existsSet:G}}function UA(X){let J=(X||"").replace(/^\s+/,"");if(!J.startsWith("/"))return null;let Q=J.match(/^\/([\w:-]*)$/);if(Q)return{token:Q[1],full:null,typing:!0};let Y=J.match(/^\/([\w:-]+)(?=\s)/);if(Y)return{token:Y[1],full:`/${Y[1]}`,typing:!1};return null}function Hx(X,J,Q=8){let Y=az(J);if(!Y)return X.slice(0,Q);let W=[],G=[];for(let Z of X)if(Z.name.startsWith(Y))W.push(Z);else if(Z.name.includes(Y)||Z.description.toLowerCase().includes(Y))G.push(Z);return[...W,...G].slice(0,Q)}var zx=x8(r8(),1);function VA(X){let J=Array.isArray(X)?X:[],Q=[],Y=0;while(Y<J.length){let W=J[Y];if(W?.type==="tool-call"){let G=[],Z=Y;while(Z<J.length&&J[Z]?.type==="tool-call")G.push(J[Z]),Z++;Q.push(G.length>1?{type:"tool-group",parts:G}:{type:"single",part:G[0]}),Y=Z}else Q.push({type:"single",part:W}),Y++}return Q}function PG0(X){let J=X.map((W)=>W.toolName||"tool"),Q=[...new Set(J)];if(Q.length===1)return`Ran ${X.length} × ${Q[0]}`;let Y=Q.slice(0,3).join(", ");return`Ran ${X.length} tools — ${Y}${Q.length>3?"…":""}`}function uB({parts:X,ToolCard:J,forceOpen:Q=!1,verbose:Y=!1}){let[W,G]=zx.useState(Q),Z=X.every((K)=>K.result!==void 0),H=X.some((K)=>K.isError);return O("details",{className:"chat-toolgroup",open:Q||W,onToggle:(K)=>G(K.currentTarget.open),"data-testid":"chat-tool-group",children:[O("summary",{className:"chat-toolgroup-sum",children:[z("span",{className:`chat-tool-dot ${Z?"chat-tool-dot--done":"chat-tool-dot--run"}`}),z("span",{children:PG0(X)}),H?z("span",{className:"del",children:" · error"}):null]}),z("div",{className:"chat-toolgroup-body",children:X.map((K,U)=>z(J,{toolName:K.toolName,args:K.args,result:K.result,isError:K.isError,verbose:Y,flat:!0},K.toolCallId||U))})]})}var qA=["normal","thinking","verbose","summary"],sU="normal";function BA(X,J){let Q=Array.isArray(X)?X:[];if(J==="summary"){for(let Y=Q.length-1;Y>=0;Y--)if(Q[Y]?.type==="text")return[Q[Y]];return[]}if(J==="thinking"||J==="verbose")return Q.slice();return Q.filter((Y)=>Y?.type!=="reasoning")}function NA(X){return X==="verbose"}var sz=({size:X=16})=>z("svg",{width:X,height:X,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:z("path",{d:"M8 1.5l1.4 3.7 3.7 1.4-3.7 1.4L8 11.7 6.6 8 2.9 6.6l3.7-1.4L8 1.5z",fill:"currentColor"})}),FA=({size:X=13})=>z("svg",{width:X,height:X,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:z("path",{d:"M13.5 4.5l-7 7L3 8",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})}),RG0=({size:X=14})=>z("svg",{width:X,height:X,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:z("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),TG0=({size:X=16})=>z("svg",{width:X,height:X,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:z("path",{d:"M8 12.5V4.2M4.4 7.6 8 4l3.6 3.6",stroke:"currentColor",strokeWidth:"2.1",strokeLinecap:"round",strokeLinejoin:"round"})}),Fx=({size:X=14})=>O("svg",{width:X,height:X,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[z("rect",{x:"5.5",y:"5.5",width:"8",height:"8",rx:"1.3",stroke:"currentColor",strokeWidth:"1.4"}),z("path",{d:"M10.5 5.5V3.8A1.3 1.3 0 0 0 9.2 2.5H3.8A1.3 1.3 0 0 0 2.5 3.8v5.4a1.3 1.3 0 0 0 1.3 1.3h1.7",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),IG0=({size:X=14})=>z("svg",{width:X,height:X,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:z("path",{d:"M13 8A5 5 0 1 1 11.3 4.3M13 2.5v3.2h-3.2",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})}),kG0=({size:X=15})=>O("svg",{width:X,height:X,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[z("rect",{x:"2",y:"2",width:"5",height:"5",rx:"1",fill:"currentColor"}),z("rect",{x:"9",y:"2",width:"5",height:"5",rx:"1",fill:"currentColor",opacity:"0.55"}),z("rect",{x:"2",y:"9",width:"5",height:"5",rx:"1",fill:"currentColor",opacity:"0.55"}),z("rect",{x:"9",y:"9",width:"5",height:"5",rx:"1",fill:"currentColor",opacity:"0.3"})]}),CG0=[{label:"/design:edit",prompt:"/design:edit "},{label:"/design:new",prompt:"/design:new "},{label:"/design:critic",prompt:"/design:critic"},{label:"/design:screenshot",prompt:"/design:screenshot"}],$G0=["/design:edit make the primary button more prominent","/design:critic",'/design:new Pricing "a 3-tier pricing page"'];function Kx(X,J,Q){let Y=J.some((W)=>!X.current.has(W.id));if(X.current=new Set(J.map((W)=>W.id)),Y)Q?.()}function lB(X,J){try{return localStorage.getItem(X)??J}catch{return J}}function Lx(X,J){try{localStorage.setItem(X,J)}catch{}}var Dx="maude-acp-picks";function SG0(){let X=lB(Dx,null);if(X)try{let W=JSON.parse(X);if(W&&typeof W==="object")return W}catch{}let J={},Q=lB("maude-acp-model",""),Y=lB("maude-acp-effort","");if(Q)J.model=Q;if(Y&&Y!=="balanced")J.effort=Y;return J}function bG0(X){Lx(Dx,JSON.stringify(X))}function yG0(X){if(!X)return null;return(X.split("/").pop()||X).replace(/\.(tsx|html)$/i,"")}var jG0=new Set(["bypassPermissions","dontAsk"]);function vG0(X){if(!X?.currentModeId||!X.availableModes?.length)return null;let Q=X.availableModes.find((Y)=>Y.id===X.currentModeId)?.name||X.currentModeId;return jG0.has(X.currentModeId)?`${Q} — no prompts`:`${Q} — you'll be asked`}function fG0({modes:X,onSetMode:J}){if(!Of(X))return null;let Y=X.availableModes.find((K)=>K.id===X.currentModeId)?.name||X.currentModeId,W=X.currentModeId==="plan",G=new Set(X.availableModes.map((K)=>K.id)),Z=G.has("acceptEdits")?"acceptEdits":G.has("default")?"default":null,H=Z&&(X.availableModes.find((K)=>K.id===Z)?.name||Z);return O("div",{className:"chat-mode-banner",role:"alert","data-testid":"chat-mode-banner",children:[z("span",{className:"chat-mode-banner-icon","aria-hidden":"true",children:"⏸"}),O("span",{className:"chat-mode-banner-text",children:[z("b",{children:Y})," — ",W?"Claude is planning and won't edit files or run tools.":"edits and tools without a standing approval are denied — nothing will change."]}),Z?O("button",{type:"button",className:"chat-mode-banner-cta",onClick:()=>J(Z),"data-testid":"chat-mode-banner-switch",children:["Switch to ",H]}):null]})}var Ux=/\[(?:image|file|link)-\d+\]/g,xG0=/\.(?:png|jpe?g|gif|webp|svg|avif|bmp|heic|heif|ico|tiff?)$/i;function hG0(X){let J=(X||"").trim();if(!J||/\s/.test(J))return null;let Q=/^(?:https?|ftp):\/\/[^\s]+$/i.test(J),Y=/^[a-zA-Z]:\\[^\s]+$/.test(J),W=/^(?:~|\.{0,2})\/[^\s]+$/.test(J),G=J.includes("/")&&/\.[a-z0-9]{1,8}$/i.test(J);if(!Q&&!Y&&!W&&!G)return null;let Z=J.split(/[?#]/)[0];return{kind:xG0.test(Z)?"image":Q?"link":"file",value:J}}function Vx(X,J){let Q=new RegExp(`\\[${J}-(\\d+)\\]`,"g"),Y=0,W;while(W=Q.exec(X||""))Y=Math.max(Y,parseInt(W[1],10));return Y+1}function gG0(X,J="chip"){let Q=[],Y=0,W,G=0;Ux.lastIndex=0;while(W=Ux.exec(X)){if(W.index>Y)Q.push(X.slice(Y,W.index));Q.push(z("span",{className:"chat-paste-chip",children:W[0]},`${J}-${G++}`)),Y=W.index+W[0].length}if(Y<X.length)Q.push(X.slice(Y));return Q}function mG0(X){let Q=((X?.files)?Array.from(X.files):[]).find((W)=>W.type&&W.type.startsWith("image/"));if(Q)return Q;let Y=X?.items?Array.from(X.items):[];for(let W of Y)if(W.kind==="file"&&W.type&&W.type.startsWith("image/")){let G=W.getAsFile();if(G)return G}return null}function qx(X,J){if(document.execCommand&&document.execCommand("insertText",!1,J))return;let Q=X.selectionStart??X.value.length,Y=X.selectionEnd??Q,W=X.value.slice(0,Q)+J+X.value.slice(Y);Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value")?.set?.call(X,W),X.dispatchEvent(new Event("input",{bubbles:!0}));let Z=Q+J.length;X.setSelectionRange(Z,Z)}async function uG0(X){let J=await X.arrayBuffer(),Q=await fetch("/_api/acp/attachment",{method:"POST",headers:{"Content-Type":X.type||"application/octet-stream"},body:J});if(!Q.ok)return null;let Y=await Q.json().catch(()=>null);return Y&&Y.path||null}function Ox({text:X}){let J=g0.useContext(tU),Q=Tf(X,J?.designRel);return O("div",{className:"chat-bubble",children:[z(oU,{text:X}),Q.length?z("div",{className:"chat-thumbrow",children:Q.map((Y)=>{let W=Y.split("/").pop();return z(LA,{src:Y,label:`Open ${W}`,caption:W},Y)})}):null]})}function Mx({text:X}){return O("details",{className:"chat-think",children:[O("summary",{className:"chat-think-sum",children:[z("span",{className:"chat-think-spark",children:z(sz,{size:11})}),"Thinking"]}),z("div",{className:"chat-think-body",children:z(oU,{text:X})})]})}function Bx(X,J=800){let Q;try{Q=typeof X==="string"?X:JSON.stringify(X,null,2)}catch{return null}if(!Q||Q==="{}"||Q==="[]"||Q==='""'||Q==="null")return null;return Q.length>J?`${Q.slice(0,J)}…`:Q}function pB({toolName:X,args:J,result:Q,isError:Y,verbose:W,flat:G=!1}){let Z=Q===void 0,H=J&&typeof J==="object"?J.path||J.file||J.filePath:void 0,K=W&&J&&typeof J==="object"&&Object.keys(J).length?Bx(J):null,U=W&&!Z&&Q!=null?Bx(Q):null,q=Z?"running…":Y?"failed":"done";if(G)return O("div",{className:"chat-tool-row","data-testid":"chat-tool-row",children:[O("div",{className:"chat-tool-row-main",children:[z("span",{className:`chat-tool-dot ${Z?"chat-tool-dot--run":"chat-tool-dot--done"}`}),z("b",{children:X}),H?z("span",{className:"chat-tool-path",children:String(H).split("/").pop()}):null,z("span",{className:`chat-tool-row-status${Y?" del":""}`,children:q})]}),K?z("pre",{className:"chat-tool-detail",children:K}):null,U?z("pre",{className:"chat-tool-detail",children:U}):null]});return O("div",{className:"chat-tool",children:[O("div",{className:"chat-tool-hd",children:[z("b",{children:X}),H?z("span",{className:"chat-tool-path",children:String(H).split("/").pop()}):null,z("span",{className:`chat-tool-dot ${Z?"chat-tool-dot--run":"chat-tool-dot--done"}`})]}),!Z?O("div",{className:"chat-tool-body",children:[z("div",{className:`chat-tool-line${Y?" del":""}`,children:Y?"failed":"done"}),K?z("pre",{className:"chat-tool-detail",children:K}):null,U?z("pre",{className:"chat-tool-detail",children:U}):null]}):null]})}var tU=g0.createContext(null);function _x(X){return`/_api/acp/attachment?name=${encodeURIComponent(X)}`}function LA({src:X,label:J="Open image",caption:Q}){let Y=g0.useContext(tU),W=z("button",{type:"button",className:"chat-thumb-btn","aria-label":J,onClick:()=>Y?.openLightbox(X),children:z("img",{className:"chat-thumb",src:X,alt:"",loading:"lazy"})});if(!Q)return W;return O("figure",{className:"chat-thumb-fig",children:[W,z("figcaption",{className:"chat-thumb-cap",title:Q,children:Q})]})}function lG0({token:X,kind:J}){let Q=g0.useContext(tU),[Y,W]=g0.useState(()=>J==="image"?Q?.chipName(X):null);if(g0.useEffect(()=>{if(J!=="image"||Y||!Q)return;let G=0,Z=setInterval(()=>{let H=Q.chipName(X);if(H)W(H),clearInterval(Z);else if(++G>20)clearInterval(Z)},250);return()=>clearInterval(Z)},[J,Y,Q,X]),!Y)return z("span",{className:"chat-paste-chip",children:X});return z(LA,{src:_x(Y),label:"Open pasted image"})}function pG0({src:X,onClose:J}){let Q=g0.useRef(null),Y=g0.useRef(null);return g0.useEffect(()=>{Y.current=document.activeElement,Q.current?.focus();function W(G){if(G.key==="Escape")G.preventDefault(),G.stopPropagation(),J()}return window.addEventListener("keydown",W,!0),()=>{window.removeEventListener("keydown",W,!0);try{Y.current?.focus?.()}catch{}}},[J]),O("div",{className:"chat-lightbox",role:"dialog","aria-modal":"true","aria-label":"Pasted image",onClick:J,children:[z("img",{src:X,alt:"pasted image, enlarged",onClick:(W)=>W.stopPropagation()}),z("button",{type:"button",ref:Q,className:"chat-lightbox-close","aria-label":"Close image",title:"Close image",onClick:J,children:"×"})]})}function dG0({text:X}){let J=Rf(X),Q=[],Y=[];return J.forEach((W,G)=>{if(W.type==="text")Q.push(z("span",{children:W.text},`t-${G}`));else if(W.type==="chip"&&W.kind!=="image")Q.push(z("span",{className:"chat-paste-chip",children:W.token},`c-${G}`));else if(W.type==="chip")Y.push(z(lG0,{token:W.token,kind:W.kind},`c-${G}`));else Y.push(z(LA,{src:_x(W.name),label:"Open pasted image"},`a-${G}`))}),O("div",{className:"chat-bubble",children:[Q,Y.length?z("div",{className:"chat-thumbrow",children:Y}):null]})}function cG0(){return O("div",{className:"chat-msg chat-msg--user",children:[z(r_.Parts,{components:{Text:dG0}}),z("div",{className:"chat-msg-actions","data-testid":"chat-msg-actions",children:z(uU.Copy,{className:"chat-msg-action","aria-label":"Copy message",title:"Copy message",children:z(Fx,{size:12})})})]})}function iG0(){let X=V_((Z)=>Z.content)||[],{transcriptView:J}=g0.useContext(tU)||{},Q=J||sU,Y=g0.useMemo(()=>BA(X,Q),[X,Q]),W=g0.useMemo(()=>VA(Y),[Y]),G=NA(Q);return O("div",{className:"chat-msg chat-msg--assistant",children:[O("div",{className:"chat-msg-role",children:[z("span",{className:"chat-msg-spark",children:z(sz,{size:13})}),"Claude"]}),W.map((Z,H)=>Z.type==="tool-group"?z(uB,{parts:Z.parts,ToolCard:pB,forceOpen:G,verbose:G},`g-${H}`):Z.part?.type==="text"?z(Ox,{text:Z.part.text},`t-${H}`):Z.part?.type==="reasoning"?z(Mx,{text:Z.part.text},`r-${H}`):Z.part?.type==="tool-call"?z(pB,{toolName:Z.part.toolName,args:Z.part.args,result:Z.part.result,isError:Z.part.isError,verbose:G},Z.part.toolCallId||`tc-${H}`):null),O("div",{className:"chat-msg-actions","data-testid":"chat-msg-actions",children:[z(uU.Copy,{className:"chat-msg-action","aria-label":"Copy message",title:"Copy message",children:z(Fx,{size:12})}),z(uU.Reload,{className:"chat-msg-action","aria-label":"Retry",title:"Retry — re-send the last message",children:z(IG0,{size:12})})]})]})}function oG0({tools:X=[],transcriptView:J,onSetTranscriptView:Q}){let W=OB((G)=>G.isRunning)||X.length>0;return O("div",{className:"chat-statusrow",children:[z("span",{className:`chat-status-dot ${W?"chat-status-dot--working":"chat-status-dot--ready"}`}),W?"Working…":"Ready",z("span",{className:"chat-statusrow-sep",children:"·"}),z("span",{className:"chat-statusrow-cc",children:"Claude Code"}),z("span",{className:"chat-statusrow-spacer"}),O("label",{className:"chat-view-label",title:"Transcript view — how much detail replies show",children:[z("span",{className:"chat-view-label-tx",children:"View"}),z("select",{className:"chat-select",value:J,"aria-label":"Transcript view","data-testid":"chat-transcript-menu",onChange:(G)=>Q(G.target.value),children:qA.map((G)=>z("option",{value:G,children:G[0].toUpperCase()+G.slice(1)},G))})]})]})}function nG0(X){let[,J]=g0.useState(0),Q=g0.useRef(null);if(g0.useEffect(()=>{if(!X){Q.current=null;return}Q.current=Date.now();let W=setInterval(()=>J((G)=>G+1),1000);return()=>clearInterval(W)},[X]),!X||Q.current==null)return null;let Y=Math.floor((Date.now()-Q.current)/1000);if(Y<1)return null;return`${Math.floor(Y/60)}:${String(Y%60).padStart(2,"0")}`}function rG0({tools:X}){let Q=OB((W)=>W.isRunning)||X.length>0,Y=nG0(Q);if(!Q)return null;return O("div",{className:"chat-activity",role:"status","aria-live":"polite",children:[z("span",{className:"chat-activity-spin","aria-hidden":"true"}),z("span",{className:"chat-activity-text",children:_f(X)}),Y?z("span",{className:"chat-activity-elapsed",children:Y}):null]})}function aG0({parts:X,viewMode:J}){let Q=J||sU,Y=g0.useMemo(()=>BA(X,Q),[X,Q]);if(!Y.length)return null;let W=VA(Y),G=NA(Q);return O("div",{className:"chat-msg chat-msg--assistant chat-msg--continued",children:[O("div",{className:"chat-msg-role",children:[z("span",{className:"chat-msg-spark",children:z(sz,{size:13})}),"Claude"]}),W.map((Z,H)=>Z.type==="tool-group"?z(uB,{parts:Z.parts,ToolCard:pB,forceOpen:G,verbose:G},`g-${H}`):Z.part?.type==="text"?z(Ox,{text:Z.part.text},`t-${H}`):Z.part?.type==="reasoning"?z(Mx,{text:Z.part.text},`r-${H}`):Z.part?.type==="tool-call"?z(pB,{toolName:Z.part.toolName,args:Z.part.args,result:Z.part.result,isError:Z.part.isError,verbose:G},Z.part.toolCallId||`tc-${H}`):null)]})}function Ax(X){if(!X)return null;let J=X>100000000000?X:X*1000;try{return new Date(J).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return null}}function sG0({usage:X,modes:J}){let[Q,Y]=g0.useState(!1),[W,G]=g0.useState(null),Z=g0.useRef(null),H=g0.useRef(null);g0.useEffect(()=>{if(!Q)return;let N=()=>{let _=H.current?.getBoundingClientRect();if(_)G({bottom:window.innerHeight-_.top+8,right:window.innerWidth-_.right})};N();let F=(_)=>{if(Z.current&&!Z.current.contains(_.target))Y(!1)},D=(_)=>{if(_.key==="Escape")Y(!1)};return document.addEventListener("pointerdown",F),document.addEventListener("keydown",D),window.addEventListener("resize",N),()=>{document.removeEventListener("pointerdown",F),document.removeEventListener("keydown",D),window.removeEventListener("resize",N)}},[Q]);let K=X.context,U=vG0(J),q=X.asOf?new Date(X.asOf).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):null,B=X.rateLimit?Ax(X.rateLimit.resetsAt):null;return O("div",{className:"chat-foot-info",ref:Z,children:[z("button",{ref:H,type:"button",className:"chat-foot-info-btn","aria-label":"Chat info","aria-expanded":Q,title:"Chat info","data-testid":"chat-foot-info-btn",onClick:()=>Y((N)=>!N),children:"ⓘ"}),Q&&W?O("div",{className:"chat-foot-popover",role:"dialog","aria-label":"Chat info","data-testid":"chat-foot-popover",style:{bottom:W.bottom,right:W.right},children:[K?O("div",{className:"chat-foot-popover-section",children:[O("div",{className:"chat-foot-popover-label-row",children:[z("span",{children:"Context"}),O("span",{children:[K.pct,"%"]})]}),z("span",{className:"chat-usage-bar chat-usage-bar--wide","aria-hidden":"true",children:z("span",{className:"chat-usage-bar-fill",style:{width:`${K.pct}%`}})}),O("div",{className:"chat-foot-popover-row--muted",children:[K.used.toLocaleString()," / ",K.size.toLocaleString()," tokens"]})]}):null,X.rateLimit?O(G0,{children:[z("div",{className:"chat-foot-popover-sep"}),O("div",{className:"chat-foot-popover-label-row",children:[z("span",{children:X.rateLimit.label}),z("span",{children:X.rateLimit.pct!=null?`${X.rateLimit.pct}%`:"—"})]}),B?O("div",{className:"chat-foot-popover-row--muted",children:["resets ",B]}):null]}):null,U?O(G0,{children:[z("div",{className:"chat-foot-popover-sep"}),z("div",{className:"chat-foot-popover-row",children:U})]}):null,z("div",{className:"chat-foot-popover-sep"}),O("div",{className:"chat-foot-popover-foot",children:[z("div",{className:"chat-foot-popover-row--muted",children:"↵ to send · ⇧↵ newline"}),O("div",{className:"chat-foot-popover-row--muted",children:["Uses your Claude subscription",q?` · updated ${q}`:""]})]})]}):null]})}function tG0({rateLimit:X,onDismiss:J}){if(!X)return null;let Q=Ax(X.resetsAt);return O("div",{className:"chat-usage-banner",role:"status","data-testid":"chat-usage-banner",children:[O("span",{children:["You're at ",X.pct!=null?`${X.pct}%`:"high usage"," of your ",X.label,Q?` · resets ${Q}`:""]}),z("button",{type:"button",className:"chat-usage-banner-x","aria-label":"Dismiss",title:"Dismiss",onClick:J,children:"×"})]})}function eG0({error:X,onRetry:J}){let[Q,Y]=g0.useState(!1);if(!X)return null;return O("div",{className:"chat-error-card",role:"alert","data-testid":"chat-error-card",children:[O("div",{className:"chat-error-hd",children:[z("span",{className:"chat-error-ic","aria-hidden":"true",children:"⚠"}),z("b",{children:"Connection problem"})]}),Q?z("p",{className:"chat-error-detail",children:X.message}):z("p",{className:"chat-error-detail chat-error-detail--muted",children:"Something interrupted the connection to Claude."}),O("div",{className:"chat-error-actions",children:[z("button",{type:"button",className:"btn btn--sm",onClick:()=>Y((W)=>!W),children:Q?"Hide details":"View details"}),z("button",{type:"button",className:"btn btn--primary btn--sm",onClick:J,children:"Try again"})]})]})}function XZ0(){return O("div",{className:"chat-empty",children:[z("span",{className:"chat-empty-mark",children:z(sz,{size:28})}),z("div",{className:"chat-empty-title",children:"Edit this canvas with Claude"}),z("div",{className:"chat-empty-sub",children:"Ask for a change, a critique, or a new screen — Claude runs on your own subscription."}),O(U5.Suggestion,{prompt:"/design:setup-ds ",send:!1,className:"chat-empty-cta",children:[z("span",{className:"chat-empty-cta-ic",children:z(kG0,{size:15})}),"Create new design system"]}),z("div",{className:"chat-sugs",children:$G0.map((X)=>z(U5.Suggestion,{prompt:X,send:!1,className:"chat-sug",children:X},X))})]})}function JZ0({openComments:X=0}){return O("div",{className:"chat-quick",children:[X>0?z(U5.Suggestion,{prompt:"/design:edit fix open comments",send:!1,className:"btn btn--ghost btn--sm chat-qa chat-qa--comments","data-testid":"chat-qa-implement-comments",children:`✓ Implement ${X} comment${X===1?"":"s"}`}):null,CG0.map((J)=>z(U5.Suggestion,{prompt:J.prompt,send:!1,className:"btn btn--ghost btn--sm chat-qa",children:J.label},J.label))]})}function QZ0(X){let[J,Q]=g0.useState([]);return g0.useEffect(()=>X.onCommands(Q),[X]),g0.useMemo(()=>Zx(Gx,J),[J])}function YZ0({items:X,activeIndex:J,onPick:Q,onHover:Y}){if(!X.length)return null;return z("div",{className:"chat-cmd-menu",role:"listbox","data-testid":"chat-cmd-menu",children:X.map((W,G)=>O("button",{type:"button",role:"option","aria-selected":G===J,"data-testid":`chat-cmd-item-${W.name.replace(/[^a-z0-9]+/gi,"-")}`,className:`chat-cmd-item${G===J?" is-active":""}`,onMouseEnter:()=>Y(G),onMouseDown:(Z)=>{Z.preventDefault(),Q(W)},children:[O("span",{className:`chat-cmd-name chat-cmd-name--${W.group}`,children:["/",W.name]}),W.description?z("span",{className:"chat-cmd-desc",children:W.description}):null,W.argHint?z("span",{className:"chat-cmd-arg",children:W.argHint}):null]},W.name))})}function WZ0({existsSet:X,attachmentsRef:J,onAttachChange:Q}){let Y=DB((F)=>F.text),W=g0.useRef(null),G=UA(Y),Z=G?az(G.token):"",H=!!(G&&Z&&X.has(Z)),K=null,U=0;if(H){let F=Y.match(/^\s*/)[0],D=`/${G.token}`;K=O(G0,{children:[F,z("span",{className:"chat-cmd-pill",children:D})]}),U=F.length+D.length}let q=Y.slice(U),B=Y.endsWith(`
5565
5565
  `)?"​":"",N=g0.useCallback((F)=>{let{clipboardData:D,currentTarget:_}=F,{map:R,pending:w}=J.current,M=mG0(D);if(M){F.preventDefault();let k=`[image-${Vx(_.value,"image")}]`;R.set(k,null),qx(_,k),Q?.();let $=uG0(M).then((C)=>{if(C)R.set(k,C);else R.delete(k)}).catch(()=>R.delete(k)).finally(()=>{w.delete($),Q?.()});w.add($);return}let P=hG0(D?.getData("text/plain"));if(!P)return;F.preventDefault();let I=`[${P.kind}-${Vx(_.value,P.kind)}]`;R.set(I,P.value),qx(_,I),Q?.()},[J,Q]);return O("div",{className:"chat-input-wrap",children:[O("div",{className:"chat-input-mirror","aria-hidden":"true",ref:W,children:[K,gG0(q),B]}),z(nz.Input,{className:"chat-input chat-input--overlay",submitMode:"enter",placeholder:"Ask Claude to change this canvas…",onPaste:N,onScroll:(F)=>{if(W.current)W.current.scrollTop=F.currentTarget.scrollTop}})]})}function GZ0({activeCanvas:X,chatCtx:J,onCtxDismiss:Q,picksRef:Y,caps:W,onSetMode:G,onSetConfig:Z,conn:H,chatId:K,attachmentsRef:U,usage:q,showRateLimitBanner:B,onDismissRateLimitBanner:N}){let F=yG0(X),{all:D,existsSet:_}=QZ0(H),R=LB(),w=DB((v)=>v.text),M=UA(w),[P,I]=g0.useState(!1),[k,$]=g0.useState(0),C=!!(M&&M.typing)&&!P,[y,f]=g0.useState(0),h=g0.useCallback(()=>f((v)=>v+1),[]),d=g0.useMemo(()=>{let v=U.current.map,r=new Set,a=[];for(let c of w.matchAll(/\[(?:image|file|link)-\d+\]/g)){if(r.has(c[0]))continue;r.add(c[0]),a.push({token:c[0],value:v.get(c[0])??null})}return a},[w,y,U]),n=g0.useMemo(()=>C?Hx(D,M.token):[],[C,D,M?.token]);g0.useEffect(()=>{$(0),I(!1)},[M?.token]);let x=g0.useRef(!1);g0.useEffect(()=>{if(C&&!x.current){x.current=!0;let v=Y.current;H.warm(K,v.model,v.effort,v.mode)}},[C,H,K,Y]);let m=g0.useCallback((v)=>{R.setText(`/${v.name} `),I(!1),$(0)},[R]),p=g0.useCallback((v)=>{if(!C||!n.length)return;let r=()=>{v.preventDefault(),v.stopPropagation()};if(v.key==="ArrowDown")r(),$((a)=>(a+1)%n.length);else if(v.key==="ArrowUp")r(),$((a)=>(a-1+n.length)%n.length);else if(v.key==="Enter"||v.key==="Tab")r(),m(n[Math.min(k,n.length-1)]);else if(v.key==="Escape")r(),I(!0)},[C,n,k,m]);return O("div",{className:"chat-composer","data-testid":"chat-composer",children:[O(U5.If,{running:!1,children:[B?z(tG0,{rateLimit:q.rateLimit,onDismiss:N}):null,J?O("div",{className:`chat-ctx${J.stale?" chat-ctx--stale":""}`,"data-testid":"chat-context-chip",children:[O("span",{className:"chat-ctx-label",children:["◆ ",J.chipLabel,J.stale?" — canvas changed since selection":""]}),z("button",{type:"button",className:"chat-ctx-x","aria-label":"Remove canvas context from this message",title:"Remove canvas context from this message",onClick:Q,children:"×"})]}):F?O("div",{className:"chat-ctx",children:["Editing: ",z("b",{children:F})]}):null,O("div",{className:"chat-cmd-anchor",onKeyDownCapture:p,children:[C?z(YZ0,{items:n,activeIndex:k,onPick:m,onHover:$}):null,O(nz.Root,{className:"chat-box",children:[z(WZ0,{existsSet:_,attachmentsRef:U,onAttachChange:h}),O("div",{className:"chat-toolbar",children:[z(WA,{modes:W.modes,configOptions:W.parsedOptions,onSetMode:G,onSetConfig:Z}),z("span",{className:"chat-toolbar-spacer"}),z(sG0,{usage:q,modes:W.modes}),z(nz.Send,{className:"chat-send","aria-label":"Send message",children:z(TG0,{})})]})]})]}),d.length?z("div",{className:"chat-attach",role:"list","aria-label":"Attachments — expands on send",children:d.map((v)=>O("div",{className:"chat-attach-row",role:"listitem",children:[z("span",{className:"chat-attach-tok",children:v.token}),z("span",{className:"chat-attach-arrow","aria-hidden":"true",children:"→"}),z("span",{className:"chat-attach-val",title:v.value||void 0,children:v.value||"attaching…"})]},v.token))}):null]}),z(U5.If,{running:!0,children:O("div",{className:"chat-stopbar",children:[O("span",{className:"chat-stop-meta",children:[z("span",{className:"chat-status-dot chat-status-dot--working"}),"Working…"]}),z("span",{className:"chat-foot-spacer"}),z(nz.Cancel,{className:"btn btn--danger","aria-label":"Stop",children:"Stop"})]})})]})}function ZZ0({reason:X,readiness:J,readinessLoading:Q,onRecheck:Y}){return O("div",{className:"chat-disabled","data-testid":"acp-not-connected",children:[z("span",{className:"chat-disabled-mark",children:z(sz,{size:28})}),z("div",{className:"chat-disabled-title",children:"AI editing isn't ready yet"}),O("div",{className:"chat-disabled-sub",children:[X?z("p",{children:X}):null,z("p",{children:"AI editing pairs with a Claude Code you have installed. Here's what it still needs:"})]}),J?z(rz,{report:J,loading:Q,refresh:Y}):z("p",{className:"chat-disabled-sub",children:"Checking what's needed…"}),O("div",{className:"chat-trust",children:[O("div",{className:"chat-trust-row",children:[z(FA,{})," Runs on your Pro/Max subscription"]}),O("div",{className:"chat-trust-row",children:[z(FA,{})," Signs in via Claude Code's own login — Maude never sees your credentials"]}),O("div",{className:"chat-trust-row",children:[z(FA,{})," Never metered API billing"]})]})]})}function Nx(){return`c-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`}function HZ0(X){return(X||[]).map((J)=>{if(J.role==="user")return{role:"user",content:[{type:"text",text:(J.parts||[]).map((Q)=>Q.text||"").join("")}]};return{role:"assistant",content:(J.parts||[]).map((Q,Y)=>Q.type==="text"?{type:"text",text:Q.text||""}:{type:"tool-call",toolCallId:`h-${Y}`,toolName:Q.toolName||"tool",args:{},argsText:"{}",result:Q.done?{}:void 0})}})}function zZ0({conn:X,chatId:J,initialMessages:Q,hidden:Y,picksRef:W,setPick:G,activeCanvas:Z,selected:H,designRel:K,openComments:U,transcriptView:q,onSetTranscriptView:B,onPermissionRequest:N,onElicitationRequest:F}){let[D,_]=g0.useState({modes:null,configOptions:[]});g0.useEffect(()=>X.onCaps(_),[X]);let R=g0.useMemo(()=>Df(D.configOptions),[D.configOptions]),w=g0.useRef(!1);g0.useEffect(()=>{if(Y||w.current)return;w.current=!0;let I0=W.current;X.warm(J,I0.model,I0.effort,I0.mode)},[Y,X,J,W]);let M=g0.useRef(!1);g0.useEffect(()=>{if(M.current)return;let I0=(D.modes?.availableModes?.length??0)>0,T8=D.configOptions.length>0;if(!I0&&!T8)return;M.current=!0;let Z8=W.current;if(R.model&&Z8.model){let z0=cU(R.model.options).map((L8)=>L8.value),f0=bB(z0,Z8.model,R.model.currentValue);if(f0!==R.model.currentValue)X.setConfig(J,"model",f0)}if(R.effort&&Z8.effort){let z0=cU(R.effort.options).map((L8)=>L8.value),f0=bB(z0,Z8.effort,R.effort.currentValue);if(f0!==R.effort.currentValue)X.setConfig(J,"effort",f0)}if(I0&&Z8.mode){let z0=D.modes.availableModes.map((L8)=>L8.id),f0=bB(z0,Z8.mode,D.modes.currentModeId);if(f0!==D.modes.currentModeId)X.setMode(J,f0)}},[D,R]);let P=g0.useCallback((I0)=>{X.setMode(J,I0),G("mode",I0)},[X,J,G]),I=g0.useCallback((I0,T8)=>{X.setConfig(J,I0,T8),G(I0,T8)},[X,J,G]),k=g0.useRef({map:new Map,pending:new Set}),[$,C]=g0.useState(null),[y,f]=g0.useState(!1),h=g0.useRef(null),d=g0.useRef(!1);g0.useEffect(()=>{let I0=kf({canvas:Z,selected:H});C(I0),h.current=I0,f(!1),d.current=!1},[Z,H]);let n=g0.useCallback(()=>{f(!0),d.current=!0},[]),x=g0.useMemo(()=>If(X,()=>J,()=>W.current.model||null,()=>W.current.effort||null,()=>k.current,()=>d.current?null:h.current,()=>W.current.mode||null),[X,J,W]),m=gU(x,{initialMessages:Q}),[p,v]=g0.useState(null),r=g0.useMemo(()=>({chipName:(I0)=>Pf(k.current.map.get(I0)||""),openLightbox:v,designRel:K,transcriptView:q}),[K,q]),[a,c]=g0.useState([]);g0.useEffect(()=>X.onActivity(c),[X]);let[U0,o]=g0.useState([]);g0.useEffect(()=>X.onBackground(o),[X]);let Z0=g0.useRef({onPermissionRequest:N,onElicitationRequest:F});g0.useEffect(()=>{Z0.current={onPermissionRequest:N,onElicitationRequest:F}},[N,F]);let[e,N0]=g0.useState([]),K0=g0.useRef(new Set);g0.useEffect(()=>X.onPermission((I0)=>{Kx(K0,I0,Z0.current.onPermissionRequest),N0(I0)}),[X]);let u0=e[0]||null,Q8=g0.useCallback((I0)=>u0&&X.respondPermission(u0.id,I0),[X,u0]),[o0,_8]=g0.useState([]),A0=g0.useRef(new Set);g0.useEffect(()=>X.onElicitation((I0)=>{Kx(A0,I0,Z0.current.onElicitationRequest),_8(I0)}),[X]);let r0=o0[0]||null,P0=g0.useCallback((I0)=>r0&&X.respondElicitation(r0.id,I0),[X,r0]),[K8,F8]=g0.useState(null);g0.useEffect(()=>X.onError(F8),[X]);let D8=g0.useCallback(()=>{let I0=QA(m.thread.getState().messages);if(I0)m.thread.append(I0)},[m]),[W8,A8]=g0.useState(null);g0.useEffect(()=>X.onUsage(A8),[X]);let i8=g0.useMemo(()=>Mf({usage:W8}),[W8]),[P9,l0]=g0.useState(null),i0=i8.rateLimit&&(i8.rateLimit.status==="allowed_warning"||i8.rateLimit.status==="rejected")&&P9!==`${i8.rateLimit.type}:${i8.rateLimit.resetsAt}`,j0=g0.useCallback(()=>{if(i8.rateLimit)l0(`${i8.rateLimit.type}:${i8.rateLimit.resetsAt}`)},[i8.rateLimit]);return z(K_,{runtime:m,children:z(tU.Provider,{value:r,children:O("div",{className:"chat-panel",style:Y?{display:"none"}:void 0,children:[z(oG0,{tools:a,transcriptView:q,onSetTranscriptView:B}),z(fG0,{modes:D.modes,onSetMode:P}),O(U5.Root,{className:"chat-thread",children:[O(U5.Viewport,{className:"chat-feed",autoScroll:!0,children:[z(U5.Empty,{children:z(XZ0,{})}),z(U5.Messages,{components:{UserMessage:cG0,AssistantMessage:iG0}}),z(aG0,{parts:U0,viewMode:q}),z(rG0,{tools:a})]}),u0?z(zA,{request:u0,onRespond:Q8,queueLength:e.length}):r0?z(HA,{request:r0,onRespond:P0}):z(eG0,{error:K8,onRetry:D8}),z(JZ0,{openComments:U}),z(GZ0,{activeCanvas:Z,chatCtx:y?null:$,onCtxDismiss:n,picksRef:W,caps:{modes:D.modes,parsedOptions:R},onSetMode:P,onSetConfig:I,conn:X,chatId:J,attachmentsRef:k,usage:i8,showRateLimitBanner:i0,onDismissRateLimitBanner:j0})]}),p?z(pG0,{src:p,onClose:()=>v(null)}):null]})})})}function dB({activeCanvas:X,selected:J,designRel:Q,openComments:Y=0,width:W,resizing:G,onClose:Z,hidden:H=!1,onBusyChange:K,onFinished:U,onPermissionRequest:q,onElicitationRequest:B}){let[N,F]=g0.useState(SG0),D=g0.useRef(N);g0.useEffect(()=>{D.current=N,bG0(N)},[N]);let _=g0.useCallback((z0,f0)=>{F((L8)=>L8[z0]===f0?L8:{...L8,[z0]:f0})},[]),[R,w]=g0.useState(()=>{let z0=lB("maude-acp-transcript-view",sU);return qA.includes(z0)?z0:sU});g0.useEffect(()=>{Lx("maude-acp-transcript-view",R)},[R]);let[M,P]=g0.useState({available:null,reason:void 0}),I=g0.useCallback(()=>fetch("/_api/acp/status").then((z0)=>z0.json()).then((z0)=>P({available:z0.available,reason:z0.reason})).catch(()=>P({available:!1,reason:"Could not reach the Claude bridge."})),[]);g0.useEffect(()=>{I()},[I]);let{report:k,loading:$,refresh:C}=aU(M.available===!1),y=g0.useCallback(()=>{return C(),I()},[C,I]),[f,h]=g0.useState([]),d=g0.useRef(new Set),n=g0.useCallback(()=>{fetch("/_api/acp/chats").then((z0)=>z0.json()).then((z0)=>{if(!Array.isArray(z0))return;h(z0),d.current=new Set(z0.filter((f0)=>f0.renamed).map((f0)=>f0.id))}).catch(()=>{})},[]);g0.useEffect(()=>{n()},[n]);let x=g0.useRef(new Map),m=g0.useRef(new Map),p=g0.useRef(new Map),v=g0.useRef(new Map),[r,a]=g0.useState([]),[c,U0]=g0.useState(null),[o,Z0]=g0.useState({}),[e,N0]=g0.useState({}),[K0,u0]=g0.useState(!1),Q8=g0.useRef({onBusyChange:K,onFinished:U});g0.useEffect(()=>{Q8.current={onBusyChange:K,onFinished:U}},[K,U]);let o0=g0.useCallback((z0)=>{let f0=x.current.get(z0);if(f0)return f0;let L8=wf();L8.bindChat(z0,v.current.get(z0)||0),x.current.set(z0,L8),L8.onSessionInfo((L0)=>{if(L0.title&&!d.current.has(z0))N0((d0)=>({...d0,[z0]:L0.title}))});let n8=!1,k8=!1,q8=!1,w0=()=>{let L0=[...m.current.values()].some(Boolean);m.current.set(z0,k8||n8);let d0=[...m.current.values()].some(Boolean);if(L0!==d0)Q8.current.onBusyChange?.(d0)};return L8.onActivity((L0)=>{if(n8=L0.length>0,w0(),q8&&!n8&&!k8)q8=!1,Z0((d0)=>({...d0,[z0]:!1})),Q8.current.onFinished?.(),n()}),L8.onBusy((L0)=>{if(k8=L0,w0(),L0){q8=!1,Z0((d0)=>({...d0,[z0]:!0}));return}if(n8)q8=!0,n();else Z0((d0)=>({...d0,[z0]:!1})),Q8.current.onFinished?.(),n()}),L8},[n]),_8=g0.useCallback((z0,f0)=>{p.current.set(z0,f0||[]),o0(z0),a((L8)=>L8.includes(z0)?L8:[...L8,z0]),U0(z0)},[o0]),A0=g0.useCallback(()=>_8(Nx(),[]),[_8]),r0=g0.useCallback((z0)=>{if(!z0||z0===c)return;if(x.current.has(z0)){U0(z0);return}fetch(`/_api/acp/chat?id=${encodeURIComponent(z0)}`).then(async(f0)=>{let L8=Number(f0.headers.get("X-Maude-Chat-Seq")||0);return v.current.set(z0,Number.isFinite(L8)?L8:0),f0.json()}).then((f0)=>_8(z0,HZ0(f0))).catch(()=>{})},[c,_8]),P0=g0.useCallback((z0)=>{let f0=x.current.get(z0);if(f0)f0.close();x.current.delete(z0),m.current.delete(z0),p.current.delete(z0),v.current.delete(z0),Z0((L8)=>{let n8={...L8};return delete n8[z0],n8}),N0((L8)=>{if(!(z0 in L8))return L8;let n8={...L8};return delete n8[z0],n8}),fetch(`/_api/acp/chat?id=${encodeURIComponent(z0)}`,{method:"DELETE"}).catch(()=>{}).finally(n),a((L8)=>{let n8=L8.filter((k8)=>k8!==z0);if(z0===c)if(n8.length)U0(n8[n8.length-1]);else{let k8=Nx();return p.current.set(k8,[]),o0(k8),U0(k8),[k8]}return n8})},[c,o0,n]),K8=g0.useCallback((z0,f0)=>{return fetch(`/_api/acp/chat?id=${encodeURIComponent(z0)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(f0)}).then((L8)=>L8.ok?L8.json():null).catch(()=>null)},[]),[F8,D8]=g0.useState(null),[W8,A8]=g0.useState(null),[i8,P9]=g0.useState(""),l0=g0.useCallback((z0)=>{A8(z0.id),P9(z0.title==="New chat"?"":z0.title),D8(null)},[]),i0=g0.useCallback((z0)=>{let f0=i8.trim();if(A8(null),!f0)return;d.current.add(z0),N0((L8)=>({...L8,[z0]:f0})),K8(z0,{title:f0}).then(n)},[i8,K8,n]),j0=g0.useCallback((z0)=>{D8(null),K8(z0,{archived:!0}).then(()=>{n()})},[K8,n]),I0=g0.useCallback((z0)=>{D8(null),fetch(`/_api/acp/chat?id=${encodeURIComponent(z0)}`).then((f0)=>f0.json()).then((f0)=>{let L8=(Array.isArray(f0)?f0:[]).map((n8)=>{let k8=(n8.parts||[]).map((q8)=>q8.type==="text"?q8.text||"":q8.type==="tool"?`[${q8.toolName||"tool"}]`:"").join("");return`${n8.role==="user"?"User":"Claude"}: ${k8}`}).join(`
5566
5566
 
5567
5567
  `);return navigator.clipboard?.writeText(L8)}).catch(()=>{})},[]);g0.useEffect(()=>{A0();let z0=x.current;return()=>{for(let f0 of z0.values())f0.close()}},[]);let T8=g0.useMemo(()=>{let z0=new Set,f0=[];for(let L8 of r){if(z0.has(L8))continue;z0.add(L8);let n8=e[L8]||f.find((k8)=>k8.id===L8)?.title||"New chat";f0.push({id:L8,title:n8,open:!0})}for(let L8 of f){if(z0.has(L8.id))continue;z0.add(L8.id),f0.push(e[L8.id]?{...L8,title:e[L8.id]}:L8)}return f0},[f,r,e]),Z8=M.available!==!1;return O("aside",{className:`st-rpanel${G?" is-resizing":""}`,style:{...W?{width:W,flexBasis:W}:{},...H?{display:"none"}:{}},"aria-label":"Assistant","aria-hidden":H||void 0,children:[O("div",{className:"st-rp-tabs",children:[O("span",{className:"st-rp-tab is-active",children:[z(sz,{size:13})," Assistant"]}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close assistant",style:{marginLeft:"auto"},onClick:Z,children:z(RG0,{})})]}),Z8?O("div",{className:"chat-bar",children:[O("div",{className:"chat-switch",children:[O("button",{type:"button",className:"chat-switch-trigger",onClick:()=>u0((z0)=>!z0),"aria-haspopup":"listbox","aria-expanded":K0,children:[z("span",{className:`chat-dot ${o[c]?"chat-dot--busy":"chat-dot--idle"}`}),z("span",{className:"chat-switch-title",children:T8.find((z0)=>z0.id===c)?.title||"New chat"}),z("span",{className:"chat-switch-caret",children:"▾"})]}),K0?O(G0,{children:[z("div",{className:"chat-menu-backdrop",onClick:()=>{u0(!1),D8(null),A8(null)}}),z("div",{className:"chat-menu",role:"listbox",children:T8.map((z0)=>O("div",{className:`chat-menu-row${z0.id===c?" is-active":""}`,children:[W8===z0.id?z("input",{type:"text",className:"chat-menu-rename-input",value:i8,autoFocus:!0,onChange:(f0)=>P9(f0.target.value),onBlur:()=>i0(z0.id),onKeyDown:(f0)=>{if(f0.key==="Enter")i0(z0.id);else if(f0.key==="Escape")A8(null)}}):O("button",{type:"button",className:"chat-menu-open",onClick:()=>{r0(z0.id),u0(!1)},children:[z("span",{className:`chat-dot ${o[z0.id]?"chat-dot--busy":z0.open?"chat-dot--idle":"chat-dot--off"}`,title:o[z0.id]?"Running":z0.open?"Open":"Saved"}),z("span",{className:"chat-menu-title",children:z0.title})]}),O("div",{className:"chat-menu-overflow-wrap",children:[z("button",{type:"button",className:"chat-menu-more","aria-label":"More options",title:"More options","aria-haspopup":"menu","aria-expanded":F8===z0.id,onClick:()=>D8((f0)=>f0===z0.id?null:z0.id),children:"⋯"}),F8===z0.id?O("div",{className:"chat-menu-overflow",role:"menu","data-testid":"chat-overflow-menu",children:[z("button",{type:"button",role:"menuitem",onClick:()=>l0(z0),children:"Rename"}),z("button",{type:"button",role:"menuitem",onClick:()=>j0(z0.id),children:"Archive"}),z("button",{type:"button",role:"menuitem",onClick:()=>I0(z0.id),children:"Copy transcript"}),z("button",{type:"button",role:"menuitem",className:"chat-menu-overflow-danger",onClick:()=>{D8(null),P0(z0.id)},children:"Delete"})]}):null]})]},z0.id))})]}):null]}),z("button",{type:"button",className:"chat-newbtn",onClick:()=>{A0(),u0(!1)},title:"Start a new chat",children:"+ New"})]}):null,z("div",{className:"st-rp-body st-rp-body--chat",children:M.available===!1?z(ZZ0,{reason:M.reason,readiness:k,readinessLoading:$,onRecheck:y}):r.map((z0)=>{let f0=x.current.get(z0);if(!f0)return null;return z(zZ0,{conn:f0,chatId:z0,initialMessages:p.current.get(z0)||[],hidden:z0!==c,picksRef:D,setPick:_,activeCanvas:X,selected:J,designRel:Q,openComments:Y,transcriptView:R,onSetTranscriptView:w,onPermissionRequest:q,onElicitationRequest:B},z0)})})]})}var u6=x8(r8(),1);var KZ0={x:O(G0,{children:[z("line",{x1:"4.3",y1:"4.3",x2:"11.7",y2:"11.7"}),z("line",{x1:"11.7",y1:"4.3",x2:"4.3",y2:"11.7"})]}),file:O(G0,{children:[z("path",{d:"M4 2h5l3 3v9H4z"}),z("polyline",{points:"9 2 9 5 12 5"})]}),check:z("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),split:O(G0,{children:[z("line",{x1:"8",y1:"2.5",x2:"8",y2:"13.5"}),z("polyline",{points:"5 6 2.5 8 5 10"}),z("polyline",{points:"11 6 13.5 8 11 10"})]}),user:O(G0,{children:[z("circle",{cx:"8",cy:"5.5",r:"2.6"}),z("path",{d:"M3.5 13a4.5 4.5 0 0 1 9 0"})]}),users:O(G0,{children:[z("circle",{cx:"6",cy:"6",r:"2.2"}),z("path",{d:"M2.5 12.5a3.6 3.6 0 0 1 7 0"}),z("path",{d:"M10.5 4.2a2.2 2.2 0 0 1 0 4.1"}),z("path",{d:"M11 12.5a3.6 3.6 0 0 0-1.2-2.7"})]}),copy:O(G0,{children:[z("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1.2"}),z("path",{d:"M11 5V3.5a1 1 0 0 0-1-1H3.5a1 1 0 0 0-1 1V10a1 1 0 0 0 1 1H5"})]})};function MZ({name:X,size:J=16}){return z("svg",{width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:KZ0[X]})}function UZ0(){return O("span",{className:"st-brand",children:[z("span",{className:"st-brand-mark",children:z("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),z("span",{className:"st-brand-name",children:"Maude"})]})}function eU(X){return((X||"").split("/").pop()||X||"").replace(/\.(tsx|html|meta\.json|css|svg|json)$/i,"")}function VZ0(X){return/\.(tsx|html)$/i.test(X||"")}function wx(X){try{let J=Math.max(0,Math.floor((Date.now()-new Date(X).getTime())/1000));if(J<60)return"just now";let Q=Math.floor(J/60);if(Q<60)return`${Q}m ago`;let Y=Math.floor(Q/60);if(Y<24)return`${Y}h ago`;let W=Math.floor(Y/24);if(W===1)return"yesterday";if(W<7)return`${W} days ago`;return new Date(X).toLocaleDateString()}catch{return""}}var XV=(X,J,Q)=>Math.max(J,Math.min(Q,X));function tz({src:X,view:J,setView:Q,label:Y}){let W=u6.useRef(null),G=u6.useRef(null),[Z,H]=u6.useState(!1);function K(N){if(!X)return;N.preventDefault();let F=W.current.getBoundingClientRect(),D=N.clientX-F.left,_=N.clientY-F.top;Q((R)=>{let w=XV(R.scale*Math.exp(-N.deltaY*0.0015),0.25,8),M=w/R.scale;return{scale:w,x:D-(D-R.x)*M,y:_-(_-R.y)*M}})}function U(N){if(!X||N.button!==0)return;W.current.setPointerCapture(N.pointerId),G.current={x:N.clientX,y:N.clientY},H(!0)}function q(N){if(!G.current)return;let F=N.clientX-G.current.x,D=N.clientY-G.current.y;G.current={x:N.clientX,y:N.clientY},Q((_)=>({..._,x:_.x+F,y:_.y+D}))}function B(N){if(!G.current)return;G.current=null,H(!1);try{W.current.releasePointerCapture(N.pointerId)}catch{}}return z("div",{ref:W,className:"dv-viewport"+(Z?" is-panning":""),onWheel:K,onPointerDown:U,onPointerMove:q,onPointerUp:B,onPointerLeave:B,children:X?z("div",{className:"dv-frame-wrap",style:{transform:`translate(${J.x}px, ${J.y}px) scale(${J.scale})`},children:z("iframe",{className:"dv-frame",src:X,title:Y})}):z("div",{className:"dv-thumb-note",children:"No saved version of this canvas to compare yet."})})}function Ex({view:X,setView:J}){let Q=(Y)=>J((W)=>({...W,scale:XV(W.scale*Y,0.25,8)}));return O("div",{className:"dv-zoombar",role:"group","aria-label":"Zoom",children:[z("button",{type:"button",className:"dv-zoom-btn","aria-label":"Zoom out",onClick:()=>Q(0.8),children:"−"}),O("button",{type:"button",className:"dv-zoom-val",title:"Reset to 100%","aria-label":"Reset zoom",onClick:()=>J({scale:1,x:0,y:0}),children:[Math.round(X.scale*100),"%"]}),z("button",{type:"button",className:"dv-zoom-btn","aria-label":"Zoom in",onClick:()=>Q(1.25),children:"+"}),z("span",{className:"dv-zoom-sync",title:"Both sides are locked together",children:"locked"})]})}var ez=[{id:"mine",icon:"user",title:"Keep mine",desc:"Use your version. Their edits are set aside."},{id:"theirs",icon:"users",title:"Keep theirs",desc:"Use the published version. Your edits are set aside."},{id:"both",icon:"copy",title:"Keep both",rec:!0,desc:"Keep theirs and save yours as a copy. Nothing is lost."}];function DA({target:X,cfg:J,loadLog:Q,onResolve:Y,onRestore:W,onClose:G}){let[Z,H]=u6.useState("side"),[K,U]=u6.useState("both"),[q,B]=u6.useState({scale:1,x:0,y:0}),[N,F]=u6.useState(52),[D,_]=u6.useState(!1),R=u6.useRef(null),w=u6.useRef(null),M=X?.file,P=X?.beforeSha,[I,k]=u6.useState(P||"HEAD"),[$,C]=u6.useState(null);if(u6.useEffect(()=>{k(P||"HEAD")},[M,P]),u6.useEffect(()=>{if(!M||!Q){C(null);return}let c=!1;return(async()=>{let U0=await Q(M)||[];if(!c)C(U0)})(),()=>{c=!0}},[M,Q]),u6.useEffect(()=>{if(!X)return;let c=document.activeElement,U0=(o)=>{if(o.key==="Escape")o.preventDefault(),G()};return window.addEventListener("keydown",U0),R.current?.focus(),()=>{if(window.removeEventListener("keydown",U0),c instanceof HTMLElement)c.focus()}},[X,G]),!X)return null;let{file:y,conflict:f}=X,h=VZ0(y),d={thumbnail:!0,hideChrome:!0},n=h?Iz(y,J,d):null,x=h?Iz(y,J,{...d,sha:I}):null,m=!f&&h&&!!Q&&!!($&&$.length),p=I!=="HEAD"&&$?$.find((c)=>c.sha===I):null,v=p?wx(p.date):"last saved";function r(c){let U0=w.current?.getBoundingClientRect();if(!U0)return;F(XV((c.clientX-U0.left)/U0.width*100,4,96))}function a(c){c.preventDefault();let U0=(Z0)=>r(Z0),o=()=>{window.removeEventListener("pointermove",U0),window.removeEventListener("pointerup",o)};window.addEventListener("pointermove",U0),window.addEventListener("pointerup",o)}return z("div",{className:"st-scrim dv-scrim",role:"presentation",onMouseDown:(c)=>{if(c.target===c.currentTarget)G()},children:O("div",{className:"dv-sheet",role:"dialog","aria-modal":"true","aria-label":`${f?"Resolve":"Compare"} ${eU(y)}`,ref:R,tabIndex:-1,children:[O("div",{className:"dv-hd",children:[z(UZ0,{}),z("span",{className:"dv-title",children:f?"You both changed this canvas":"What changed"}),O("span",{className:"dv-file",children:[z(MZ,{name:"file",size:13})," ",eU(y)]}),z("span",{className:"dv-spacer"}),m&&O("label",{className:"dv-verpick",children:[z("span",{className:"dv-verpick-lbl",children:"Compare against"}),O("select",{className:"dv-verpick-sel",value:I,onChange:(c)=>k(c.target.value),"aria-label":`Saved version of ${eU(y)} to compare against`,children:[z("option",{value:"HEAD",children:"Last saved"}),$.map((c)=>z("option",{value:c.sha,children:`${c.message||"Saved version"} · ${wx(c.date)}`},c.sha))]})]}),!f&&h&&O("div",{className:"dv-seg",role:"group","aria-label":"Comparison mode",children:[z("button",{type:"button",className:"dv-seg-btn","aria-pressed":Z==="side",onClick:()=>H("side"),children:"Side by side"}),z("button",{type:"button",className:"dv-seg-btn","aria-pressed":Z==="overlay",onClick:()=>H("overlay"),children:"Overlay"})]}),z("button",{type:"button",className:"dv-close","aria-label":"Close",onClick:G,children:z(MZ,{name:"x",size:14})})]}),f?O(G0,{children:[z("div",{className:"dv-pick-intro",children:z("div",{className:"callout callout--info",children:O("span",{children:["While you were working, someone published their own changes to"," ",z("strong",{style:{color:"var(--fg-0)"},children:eU(y)}),". Pick which to keep — ",z("strong",{style:{color:"var(--fg-0)"},children:"Keep both"})," saves yours as a copy so nothing is lost."]})})}),O("div",{className:"dv-stage",children:[z(Ex,{view:q,setView:B}),O("div",{className:"dv-pair",children:[O("div",{className:"dv-col",children:[O("div",{className:"dv-col-hd",children:[O("span",{className:"dv-col-tag",children:[z(MZ,{name:"user",size:12})," Yours"]}),z("span",{className:"dv-col-who",children:"you · just now"})]}),z("div",{className:"dv-thumb ring-mine",children:z(tz,{src:n,view:q,setView:B,label:"Your version"})})]}),O("div",{className:"dv-col",children:[O("div",{className:"dv-col-hd",children:[O("span",{className:"dv-col-tag",children:[z(MZ,{name:"users",size:12})," Theirs"]}),z("span",{className:"dv-col-who",children:"published"})]}),z("div",{className:"dv-thumb ring-theirs",children:z(tz,{src:x,view:q,setView:B,label:"Published version"})})]})]})]}),z("div",{className:"dv-picker",role:"radiogroup","aria-label":"How to resolve",children:ez.map((c)=>O("button",{type:"button",className:"dv-pick"+(K===c.id?" is-rec":""),role:"radio","aria-checked":K===c.id,tabIndex:K===c.id?0:-1,onClick:()=>U(c.id),onKeyDown:(U0)=>{let o=U0.key==="ArrowRight"||U0.key==="ArrowDown"?1:U0.key==="ArrowLeft"||U0.key==="ArrowUp"?-1:0;if(!o)return;U0.preventDefault();let e=(ez.findIndex((N0)=>N0.id===K)+o+ez.length)%ez.length;U(ez[e].id),U0.currentTarget.parentElement?.children[e]?.focus()},children:[O("span",{className:"dv-pick-hd",children:[z(MZ,{name:c.icon,size:14}),z("span",{className:"dv-pick-title",children:c.title}),c.rec&&z("span",{className:"dv-pick-rec",children:"Default"})]}),z("span",{className:"dv-pick-desc",children:c.desc})]},c.id))}),O("div",{className:"dv-ft",children:[z("span",{className:"dv-note",children:"You can change your mind later — both versions stay in History."}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:G,disabled:D,children:"Cancel"}),O("button",{type:"button",className:"btn btn--primary btn--sm",disabled:D,onClick:async()=>{_(!0);try{await Y?.(K)}finally{_(!1)}},children:[z(MZ,{name:"check",size:14})," ",ez.find((c)=>c.id===K)?.title]})]})]}):O(G0,{children:[O("div",{className:"dv-stage",children:[z(Ex,{view:q,setView:B}),Z==="side"?O("div",{className:"dv-pair",children:[O("div",{className:"dv-col",children:[O("div",{className:"dv-col-hd",children:[z("span",{className:"dv-col-tag is-before",children:"Saved version"}),z("span",{className:"dv-col-who",children:v})]}),z("div",{className:"dv-thumb",children:z(tz,{src:x,view:q,setView:B,label:"Saved version"})})]}),O("div",{className:"dv-col",children:[O("div",{className:"dv-col-hd",children:[z("span",{className:"dv-col-tag is-after",children:"Your version"}),z("span",{className:"dv-col-who",children:"now · unsaved"})]}),z("div",{className:"dv-thumb is-after",children:z(tz,{src:n,view:q,setView:B,label:"Your version (now)"})})]})]}):O("div",{className:"dv-overlay",ref:w,style:{"--dv-split":`${N}%`},children:[z("div",{className:"dv-overlay-layer",children:z(tz,{src:x,view:q,setView:B,label:"Saved version"})}),z("div",{className:"dv-overlay-after",children:z(tz,{src:n,view:q,setView:B,label:"Your version"})}),z("span",{className:"dv-overlay-tag l",children:"Saved"}),z("span",{className:"dv-overlay-tag r",children:"Yours"}),z("div",{className:"dv-split",children:z("span",{className:"dv-split-handle",role:"slider","aria-label":"Drag to wipe between saved and your version","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(N),tabIndex:0,onPointerDown:a,onKeyDown:(c)=>{if(c.key==="ArrowLeft")F((U0)=>XV(U0-4,4,96));if(c.key==="ArrowRight")F((U0)=>XV(U0+4,4,96))},children:z(MZ,{name:"split",size:14})})})]})]}),O("div",{className:"dv-ft",children:[z("span",{className:"dv-note",children:Z==="side"?"A live rendered before & after — scroll to zoom, drag to pan. Both sides stay locked together.":"Drag the handle to wipe between the saved version and yours."}),W&&z("button",{type:"button",className:"btn btn--ghost btn--sm",disabled:D,onClick:async()=>{if(!window.confirm(`Restore the saved version of “${eU(y)}”? Your unsaved changes to it are discarded.`))return;_(!0);try{await W(y)}finally{_(!1)}},children:"Restore saved version"}),z("button",{type:"button",className:"btn btn--primary btn--sm",onClick:G,children:"Keep my version"})]})]})]})})}var g7=x8(r8(),1);var cB=/\.(tsx|html)$/i,iB=/\.meta\.json$/i,oB=/\.annotations\.svg$/i;function XK(X){return(String(X).split("/").pop()||String(X)).replace(oB,"").replace(iB,"").replace(/\.(tsx|html|css|svg|json)$/i,"")}function Px(X){if(iB.test(X))return"Layout & settings";if(oB.test(X))return"Annotations";return XK(X)}function Rx(X,J){let Q=String(X).replace(/^\/+|\/+$/g,""),Y=`${(J||".design").replace(/^\/+|\/+$/g,"")}/`;return Q.startsWith(Y)?Q.slice(Y.length):Q}function qZ0(X,J){return Rx(X,J).replace(/\//g,"-").replace(/\s+/g,"_").replace(cB,"").replace(/^\.+/,"").toLowerCase()}function Tx(X,J){let Q=X.filter((B)=>cB.test(B.path)),Y=new Map,W=new Map;for(let B of Q)Y.set(B.path.replace(cB,""),B),W.set(qZ0(B.path,J),B);let G=new Map,Z=new Set,H=(B,N)=>{let F=G.get(B.path);if(F)F.push(N);else G.set(B.path,[N]);Z.add(N.path)};for(let B of X)if(iB.test(B.path)){let N=Y.get(B.path.replace(iB,""));if(N)H(N,B)}else if(oB.test(B.path)){let N=W.get(Rx(B.path,J).replace(oB,"").toLowerCase());if(N)H(N,B)}let K=(B,N)=>XK(B.primary.path).localeCompare(XK(N.primary.path)),U=Q.map((B)=>({key:B.path,kind:"canvas",primary:B,supporting:G.get(B.path)??[]})).sort(K),q=X.filter((B)=>!cB.test(B.path)&&!Z.has(B.path)).map((B)=>({key:B.path,kind:"other",primary:B,supporting:[]})).sort(K);return{canvasUnits:U,otherUnits:q}}var Ix={modified:"M",added:"A",deleted:"D",untracked:"U"},kx={M:"Modified",A:"Added",D:"Deleted",U:"Untracked"};function QX({name:X,size:J=16,className:Q}){let Y={save:O(G0,{children:[z("path",{d:"M3 3h8l2 2v8H3z"}),z("polyline",{points:"5 3 5 6 10 6"}),z("rect",{x:"5.5",y:"9",width:"5",height:"3.5"})]}),publish:O(G0,{children:[z("line",{x1:"8",y1:"13",x2:"8",y2:"3.5"}),z("polyline",{points:"4.5 7 8 3.5 11.5 7"}),z("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),download:O(G0,{children:[z("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),z("polyline",{points:"4.5 7 8 10.5 11.5 7"}),z("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),history:O(G0,{children:[z("path",{d:"M3.2 8a5 5 0 1 1 1.4 3.5"}),z("polyline",{points:"3.2 11.4 3.2 8 6.6 8"}),z("polyline",{points:"8 5.5 8 8 10 9.3"})]}),undo:O(G0,{children:[z("path",{d:"M5.5 6H10a3.4 3.4 0 0 1 0 6.8H6.2"}),z("polyline",{points:"5.5 3.6 3 6 5.5 8.4"})]}),diff:O(G0,{children:[z("rect",{x:"2.5",y:"3",width:"4.5",height:"10",rx:"1"}),z("rect",{x:"9",y:"3",width:"4.5",height:"10",rx:"1"})]}),file:O(G0,{children:[z("path",{d:"M4 2h5l3 3v9H4z"}),z("polyline",{points:"9 2 9 5 12 5"})]}),folder:z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),check:z("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),chevron:z("polyline",{points:"6 4 10 8 6 12"})}[X];return z("svg",{className:Q,width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Y})}function Cx({kind:X}){return z("span",{className:"gp-badge","data-kind":X,title:`${kx[X]} — unsaved`,"aria-label":`${kx[X]}, unsaved`,children:X})}function BZ0({state:X,onChange:J,ariaLabel:Q}){let Y=g7.useRef(null);return g7.useEffect(()=>{if(Y.current)Y.current.indeterminate=X==="some"},[X]),z("input",{ref:Y,type:"checkbox",className:"gp-check",checked:X==="all",onChange:J,"aria-label":Q})}function NZ0(X){try{let J=new Date(X).getTime(),Q=Math.max(0,Math.floor((Date.now()-J)/1000));if(Q<60)return"just now";let Y=Math.floor(Q/60);if(Y<60)return`${Y}m ago`;let W=Math.floor(Y/60);if(W<24)return`${W}h ago`;let G=Math.floor(W/24);if(G===1)return"yesterday";if(G<7)return`${G} days ago`;return new Date(X).toLocaleDateString()}catch{return""}}function OA({status:X,project:J,width:Q,resizing:Y,onClose:W,onCommit:G,onDiscard:Z,onPublish:H,onGetLatest:K,loadLog:U,onOpenCanvas:q,onOpenDiff:B,activeCanvas:N,onPreviewVersion:F,designRel:D=".design",readOnly:_=!1,historyOnly:R=!1,cloudManaged:w=!1,historySource:M="local",cloudHistory:P=null}){let I=R||w,k=M==="cloud",[$,C]=g7.useState(I?"history":"changes");g7.useEffect(()=>{if(I)C("history")},[I]);let[y,f]=g7.useState(""),[h,d]=g7.useState(()=>new Set),[n,x]=g7.useState(()=>new Set),[m,p]=g7.useState(null),[v,r]=g7.useState(null),[a,c]=g7.useState(null),[U0,o]=g7.useState(!1),[Z0,e]=g7.useState(void 0),[N0,K0]=g7.useState(!1),u0=g7.useRef(null),Q8=!!(N&&F),o0=N||"",_8=N?XK(N):"",A0=X?.files??[],r0=A0.map((w0)=>`${w0.path}:${w0.status}`).join("|");g7.useEffect(()=>{d((w0)=>{let L0=new Set(A0.map((V8)=>V8.path)),d0=new Set;for(let V8 of w0)if(L0.has(V8))d0.add(V8);return d0.size===w0.size?w0:d0})},[r0]);let P0=g7.useMemo(()=>A0.map((w0)=>w0.path).filter((w0)=>!h.has(w0)),[A0,h]),{canvasUnits:K8,otherUnits:F8}=g7.useMemo(()=>Tx(A0,D),[A0,D]),D8=K8.length>0&&F8.length>0,W8=(w0)=>{let L0=[w0.primary,...w0.supporting],d0=L0.filter((V8)=>!h.has(V8.path)).length;return d0===0?"none":d0===L0.length?"all":"some"},A8=(w0)=>{let L0=[w0.primary,...w0.supporting].map((V8)=>V8.path),d0=W8(w0)==="all";d((V8)=>{let O8=new Set(V8);for(let a8 of L0)if(d0)O8.add(a8);else O8.delete(a8);return O8})},i8=(w0)=>x((L0)=>{let d0=new Set(L0);if(d0.has(w0))d0.delete(w0);else d0.add(w0);return d0}),P9=(w0)=>{let L0=w0.primary,d0=W8(w0),V8=w0.supporting.length>0,O8=n.has(w0.key),a8=XK(L0.path),E8=[L0,...w0.supporting].map((N9)=>N9.path);return O("div",{className:"gp-unit",children:[O("div",{className:"gp-file gp-unit-hd"+(!_&&d0!=="none"?" is-checked":""),children:[!_&&z(BZ0,{state:d0,ariaLabel:`Include ${a8}${V8?" and its supporting files":""} in this version`,onChange:()=>A8(w0)}),z(Cx,{kind:Ix[L0.status]}),O("button",{type:"button",className:"gp-file-text",title:L0.path,onClick:()=>q?.(L0.path),children:[z("span",{className:"gp-file-name",children:a8}),z("span",{className:"gp-file-path",children:V8?`${L0.path} · +${w0.supporting.length} supporting`:L0.path})]}),V8&&z("button",{type:"button",className:"gp-disclose"+(O8?" is-open":""),"aria-expanded":O8,"aria-label":O8?`Hide supporting files for ${a8}`:`Show supporting files for ${a8}`,onClick:()=>i8(w0.key),children:z(QX,{name:"chevron",size:14})}),w0.kind==="canvas"&&z("button",{type:"button",className:"gp-discard",title:"Compare before / after","aria-label":`Compare ${a8}`,onClick:()=>B?.(L0.path),children:z(QX,{name:"diff",size:14})}),!_&&z("button",{type:"button",className:"gp-discard",title:V8?"Discard this canvas and its supporting files":"Discard this change","aria-label":`Discard changes to ${a8}`,onClick:async()=>{let N9=V8?`Discard your changes to “${a8}” and its supporting files? This can't be undone.`:`Discard your changes to “${a8}”? This can't be undone.`;if(!window.confirm(N9))return;await l0("discard",()=>Z(E8))},children:z(QX,{name:"undo",size:14})})]}),V8&&O8&&z("div",{className:"gp-support",role:"group","aria-label":`Supporting files for ${a8}`,children:w0.supporting.map((N9)=>O("div",{className:"gp-support-row",title:N9.path,children:[z(Cx,{kind:Ix[N9.status]}),O("span",{className:"gp-support-text",children:[z("span",{className:"gp-file-name",children:Px(N9.path)}),z("span",{className:"gp-file-path",children:N9.path})]})]},N9.path))})]},w0.key)};g7.useEffect(()=>{if(u0.current)u0.current.indeterminate=P0.length>0&&P0.length<A0.length},[P0.length,A0.length]);async function l0(w0,L0,d0){p(w0),r(null);try{let V8=await L0()||{};if(V8.ok){if(d0)r(d0);return e(void 0),V8}if(V8.authRequired)r({variant:"info",text:V8.error||"Sign in with GitHub to publish."});else if(V8.conflict)r(w0==="getLatest"?{variant:"info",title:"You both changed this",text:"Pick what to keep in the window that just opened."}:{variant:"warn",title:"Publish didn't go through",text:"The shared project moved on while you were working. Get the latest, then publish yours on top.",getLatest:!0});else if(w0==="publish"&&/protected branch|GH006/i.test(V8.error||""))r({variant:"warn",title:"This branch is protected",text:"It needs a pull request. Switch to a draft, then use “Add to Shared version” to open one."});else r({variant:"error",text:V8.error||"Something went wrong."});return V8}finally{p(null)}}function i0(){C("history")}g7.useEffect(()=>{if($!=="history")return;if(Z0===o0)return;let w0=!1;return o(!0),(async()=>{let L0=await U(o0||void 0);if(w0)return;K0(L0==null),c(L0??[]),e(o0),o(!1)})(),()=>{w0=!0}},[$,o0,Z0,U]);let j0=()=>{K0(!1),e(void 0)};g7.useEffect(()=>{K0(!1),e(void 0)},[M]);function I0(){d((w0)=>w0.size===0?new Set(A0.map((L0)=>L0.path)):new Set)}let T8=A0.length,Z8=k?P?.project??P?.hubHost??null:J,z0=k?P?.branch??"":X?.branch||"main",f0=X?.unpushed||0,L8=y.trim().length>0&&P0.length>0&&!m,n8=X&&X.repo===!1,k8=T8===0,q8=O("div",{className:"gp-publishbar",children:[O("button",{type:"button",className:"btn btn--primary gp-publish","data-testid":"git-publish","data-tour":"publish",disabled:!!m,onClick:()=>l0("publish",H,{variant:"success",text:"Published — your team can Get latest."}),children:[z(QX,{name:"publish",size:15})," Publish changes"]}),z("span",{className:"gp-hint",style:{textAlign:"center"},children:f0>0?`Sends your ${f0} saved version${f0===1?"":"s"} to the shared project so the team can get them.`:"Sends your saved versions to the shared project so the team can get them."})]});return O("aside",{className:"st-rpanel gp-panel"+(Y?" is-resizing":""),style:Q?{width:Q,flexBasis:Q}:void 0,"aria-label":I?"History":"Changes","data-testid":"git-panel",children:[O("div",{className:"gp-head",children:[O("div",{className:"gp-panel-hd",children:[z("span",{className:"gp-panel-title",children:I?"History":"Changes"}),!I&&T8>0&&O("span",{className:"gp-count",children:[T8," unsaved"]}),z("span",{className:"gp-spacer"}),O("span",{className:"gp-draft","data-testid":"git-panel-repo",title:k?"The cloud project these versions belong to":"Your project and shared draft",children:[z(QX,{name:"folder",size:12}),Z8?O(G0,{children:[z("b",{children:Z8}),z0?z("span",{className:"gp-sep",children:"/"}):null]}):null,z0]}),z("button",{type:"button",className:"gp-x","aria-label":"Close",onClick:W,children:"×"})]}),!I&&O("div",{className:"gp-tabs",role:"tablist","aria-label":"Changes and history",children:[z("button",{type:"button",role:"tab","aria-selected":$==="changes",className:"gp-tab"+($==="changes"?" is-active":""),onClick:()=>C("changes"),children:"Changes"}),z("button",{type:"button",role:"tab","aria-selected":$==="history",className:"gp-tab"+($==="history"?" is-active":""),onClick:i0,children:"History"})]}),w&&O("div",{className:"gp-cloud-note",role:"status","data-testid":"git-cloud-managed",children:[z(QX,{name:"check",size:13})," Cloud is saving — changes sync automatically. Disconnect to commit locally."]})]}),v&&z("div",{className:"gp-pad",children:O("div",{className:`callout callout--${v.variant}`,role:"status","aria-live":"polite",children:[O("div",{className:"gp-callout-col",children:[O("span",{children:[v.title&&z("strong",{style:{display:"block",marginBottom:"var(--space-1)",color:"var(--fg-0)"},children:v.title}),v.text]}),v.getLatest&&z("div",{className:"gp-callout-actions",children:O("button",{type:"button",className:"btn btn--sm","data-testid":"git-get-latest",disabled:!!m,onClick:()=>l0("getLatest",K,{variant:"success",text:"Up to date with everyone."}),children:[z(QX,{name:"download",size:13})," Get latest"]})})]}),z("button",{type:"button",className:"gp-x","aria-label":"Dismiss",onClick:()=>r(null),children:"×"})]})}),$==="changes"&&!I?n8?O("div",{className:"gp-empty",children:[z("span",{className:"gp-empty-glyph",children:z(QX,{name:"folder",size:24})}),z("h3",{children:"Not versioned yet"}),z("p",{children:"Once this is a Maude project, your changes show up here to Save and Publish."})]}):k8?f0>0?O(G0,{children:[O("div",{className:"gp-empty",children:[z("span",{className:"gp-empty-glyph gp-empty-glyph--publish",children:z(QX,{name:"publish",size:24})}),O("h3",{children:[f0," version",f0===1?"":"s"," ready to publish"]}),z("p",{children:"Everything's saved, but your work isn't shared yet. Publish it so the team can Get latest."}),O("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:i0,children:[z(QX,{name:"history",size:14})," View History"]})]}),!_&&q8]}):O("div",{className:"gp-empty",children:[z("span",{className:"gp-empty-glyph",children:z(QX,{name:"check",size:26})}),z("h3",{children:"Nothing to save"}),z("p",{children:"Every change is saved. When you edit a canvas, it shows up here."}),!_&&X?.remoteAhead?O("button",{type:"button",className:"btn btn--ghost btn--sm","data-testid":"git-get-latest","data-tour":"pull",disabled:!!m,onClick:()=>l0("getLatest",K,{variant:"success",text:"Up to date with everyone."}),children:[z(QX,{name:"download",size:14})," Get latest"]}):O("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:i0,children:[z(QX,{name:"history",size:14})," View History"]})]}):O(G0,{children:[!_&&X?.remoteAhead&&z("div",{className:"gp-pad",children:O("div",{className:"callout callout--info gp-nudge",role:"status",children:[z("span",{className:"gp-dot-pulse","aria-hidden":"true"}),O("span",{className:"gp-nudge-text",children:[O("b",{children:[X.behind," new change",X.behind===1?"":"s"," from your team."]})," ",z("span",{children:"Get the latest before you publish yours."})]}),O("button",{type:"button",className:"btn btn--sm",disabled:!!m,onClick:()=>l0("getLatest",K,{variant:"success",text:"Up to date with everyone."}),children:[z(QX,{name:"download",size:14})," Get latest"]})]})}),O("div",{className:"gp-list",role:"group","aria-label":"Unsaved changes",children:[D8&&K8.length>0&&O("div",{className:"gp-group-hd",children:["Canvases",O("span",{className:"gp-group-count",children:["· ",K8.length]})]}),K8.map(P9),F8.length>0&&O(G0,{children:[D8&&O("div",{className:"gp-group-hd",children:["Other files",O("span",{className:"gp-group-count",children:["· ",F8.length]})]}),F8.map(P9)]})]}),!_&&O("div",{className:"gp-compose",children:[O("label",{className:"gp-selectall",children:[z("input",{ref:u0,type:"checkbox",className:"gp-check",checked:P0.length===A0.length&&A0.length>0,onChange:I0,"aria-label":"Select all changed files"}),P0.length," of ",T8," selected"]}),z("textarea",{className:"gp-msg","data-testid":"git-commit-message",placeholder:"Describe what changed in this version…","aria-label":"Describe what changed in this version",rows:2,value:y,onChange:(w0)=>f(w0.target.value)}),O("div",{className:"gp-compose-actions",children:[O("button",{type:"button",className:"btn btn--primary gp-save","data-tour":"save-local",disabled:!L8,"aria-disabled":!L8,onClick:async()=>{if((await l0("save",()=>G(y.trim(),P0),{variant:"success",text:"Version saved."}))?.ok)f("")},children:[z(QX,{name:"save",size:15})," Save version"]}),z("button",{type:"button",className:"btn btn--ghost btn--sm","data-testid":"git-save-all",disabled:!y.trim()||!!m,title:"Save every change",onClick:async()=>{if((await l0("saveAll",()=>G(y.trim(),void 0),{variant:"success",text:"Version saved."}))?.ok)f("")},children:"Save all"})]}),!L8&&z("span",{className:"gp-hint",children:"Type a message and pick at least one file to save a version."})]}),!_&&q8,_&&z("p",{className:"gp-hint gp-ro-hint",children:"Save and publish your work from your terminal — this view is read-only."})]}):O("div",{className:"gp-history",role:"list","aria-label":Q8?`Saved versions of ${_8}`:"Version history",children:[Q8&&O("p",{className:"gp-history-scope",children:["Saved versions of ",z("b",{children:_8})," — pick one to preview."]}),U0?z("div",{className:"gp-empty",children:z("p",{children:"Loading history…"})}):N0?z("div",{className:"gp-pad",children:z("div",{className:"callout callout--warning",role:"status","aria-live":"polite","data-testid":"git-history-unreachable",children:O("div",{className:"gp-callout-col",children:[O("span",{children:[z("strong",{style:{display:"block",marginBottom:"var(--space-1)",color:"var(--fg-0)"},children:"Couldn’t reach the cloud history."}),"Your work is still being saved — this is only the list of versions."]}),z("div",{className:"gp-callout-actions",children:z("button",{type:"button",className:"btn btn--sm","data-testid":"git-history-retry",onClick:j0,children:"Retry"})})]})})}):!a||a.length===0?O("div",{className:"gp-empty",children:[z("span",{className:"gp-empty-glyph",children:z(QX,{name:"history",size:24})}),k?O(G0,{children:[z("h3",{children:"No versions yet"}),O("p",{children:["The cloud is saving this project",Q8?`. Versions of ${_8} appear here as you work.`:". Versions appear here as you work."]})]}):O(G0,{children:[z("h3",{children:"No saved versions yet"}),z("p",{children:Q8?`Save a version of ${_8} and it'll show up here.`:"Save a version and it'll show up here."})]})]}):a.map((w0)=>{let L0=O(G0,{children:[z("span",{className:"gp-version-rail",children:z("span",{className:"gp-version-node"})}),O("span",{className:"gp-version-body",children:[z("span",{className:"gp-version-msg",children:w0.message||"(no message)"}),O("span",{className:"gp-version-meta",children:[w0.author," · ",w0.sha.slice(0,7)]})]}),z("span",{className:"gp-version-when",children:NZ0(w0.date)})]});return Q8?O("button",{type:"button",className:"gp-version gp-version--clickable",onClick:()=>F(w0.sha),title:`Preview ${_8} at this saved version`,children:[L0,O("span",{className:"gp-version-cue","aria-hidden":"true",children:[z(QX,{name:"diff",size:13})," Preview"]})]},w0.sha):z("div",{className:"gp-version",role:"listitem",children:L0},w0.sha)}),!Q8&&a&&a.length>0&&z("p",{className:"gp-history-hint",children:"Open a canvas to preview a saved version."})]})]})}var h4=x8(r8(),1);var MA="maude-sync-consent";function FZ0(X){try{let Q=JSON.parse(localStorage.getItem(MA)||"{}")[X];return Q&&typeof Q==="object"?Q:null}catch{return null}}function $x(X,J){try{let Q=JSON.parse(localStorage.getItem(MA)||"{}");Q[X]={choice:J,at:Date.now()},localStorage.setItem(MA,JSON.stringify(Q))}catch{}}function LZ0(X){try{let J=new URL(X).hostname;return J==="localhost"||J==="::1"||/^127\./.test(J)||J==="[::1]"}catch{return!1}}function _A({status:X,cloud:J}){let Q=typeof X?.url==="string"?X.url:null,[Y,W]=h4.useState(!1),[G,Z]=h4.useState(!1),[H,K]=h4.useState(""),U=!J&&Q&&!LZ0(Q)&&!Y&&!FZ0(Q);h4.useEffect(()=>{if(!U)return;let F=(D)=>{if(D.key==="Escape")D.preventDefault()};return window.addEventListener("keydown",F,!0),()=>window.removeEventListener("keydown",F,!0)},[U]);let q=h4.useCallback(()=>{if(Q)$x(Q,"accepted");W(!0)},[Q]),B=h4.useCallback(async()=>{Z(!0),K("");let F=!1;try{let _=await(await fetch("/_api/sync/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({syncFiles:!1,propagateDeletes:!1})})).json().catch(()=>null);if(F=_?.ok===!0,!F)K(_?.detail||"The limited mode could not be saved — try again.")}catch{K("Maude could not reach the sync service — try again.")}if(Z(!1),F){if(Q)$x(Q,"limited");W(!0)}},[Q]);if(!U)return null;let N=Q;try{N=new URL(Q).host}catch{}return z("div",{className:"st-scrim","data-testid":"sync-consent",children:O("div",{className:"st-dialog st-consent",role:"dialog","aria-modal":"true","aria-labelledby":"sync-consent-title",children:[z("div",{className:"st-dialog-hd",children:O("span",{className:"st-dialog-title",id:"sync-consent-title",children:["This project syncs with ",N]})}),O("div",{className:"st-dialog-bd",children:[z("p",{children:"Since your last update, syncing covers more than canvases. With this workspace:"}),O("ul",{className:"st-consent-list",children:[O("li",{children:[z("strong",{children:"The whole design folder mirrors both ways"})," — stylesheets, docs and code modules, not only canvases."]}),O("li",{children:[z("strong",{children:"Deleting a file here deletes it there"})," (and the other way round). Replaced copies are kept in the Sync panel's Trash, and bulk removals pause for confirmation."]}),X?.sharedDoc&&O("li",{children:[z("strong",{children:"Your live editing buffer is the shared object"})," — edits stream to the workspace as you type, not as saved copies."]})]}),z("p",{className:"st-consent-fine",children:"You can change either choice any time in the Sync panel's Settings. Only sync with workspaces you operate or trust."}),H&&z("p",{className:"st-consent-note",role:"status","aria-live":"polite",children:H})]}),O("div",{className:"st-dialog-ft",children:[z("button",{type:"button",className:"btn btn--ghost","data-testid":"sync-consent-limit",disabled:G,onClick:B,children:G?"Saving…":"Sync canvases only"}),z("button",{type:"button",className:"btn btn--primary","data-testid":"sync-consent-accept",disabled:G,onClick:q,children:"Keep syncing everything"})]})]})})}var u9=x8(r8(),1);var DZ0=1e4,OZ0={pending:"syncing",connected:"synced","auth-rejected":"refused"},Sx={"rate-limit":"rate limited","not-authorized":"not authorized","invalid-token":"sign-in expired",generic:"refused by the hub"};function bx({item:X}){let J=P6(X.slug,"(unnamed)"),Q=OZ0[X.state]||"syncing",Y=X.state==="auth-rejected"?Sx[X.reason]||Sx.generic:null;return O("li",{className:"sp-row is-"+X.state,"data-testid":"sync-row-"+X.slug,children:[z("span",{className:"sp-row-dot","aria-hidden":"true"}),z("span",{className:"sp-row-name",title:J,children:J}),z("span",{className:"sp-row-state",children:Y?`refused — ${Y}`:Q})]})}function MZ0(X,J){for(let Q of J){let Y=Q.replace(/\//g,"-");if(X===Y||X.startsWith(Y+"-"))return Q}return null}var nB=(X)=>typeof X==="number"&&Number.isInteger(X)&&X>=0;function _Z0(X){if(!Array.isArray(X))return[];return X.filter((J)=>J&&typeof J.slug==="string"&&typeof J.state==="string")}function AZ0(X){if(!X||typeof X!=="object")return null;if(![X.total,X.done,X.pushed,X.skipped,X.failedCount].every(nB))return null;let J=Array.isArray(X.failures)?X.failures.filter((Q)=>Q&&typeof Q.key==="string"):[];return{...X,failures:J}}function wZ0(X){if(!X||typeof X!=="object")return null;if(![X.synced,X.pulled,X.conflicts].every(nB))return null;return X}function EZ0(X){if(!Array.isArray(X))return[];return X.filter((J)=>J&&typeof J.id==="string"&&typeof J.text==="string")}var yx={conflict:"conflict — older copy in Trash below",stuck:"stuck","referenced-but-unoffered":"referenced, never received","local-only":"only on this machine",pushing:"uploading…","on-hub":"on the workspace",durable:"backed up","at-peer":"reached a teammate","ui-healed":"healed",everywhere:"everywhere"},PZ0=new Set(["conflict","stuck","referenced-but-unoffered","local-only"]);function RZ0(X){let J=[],Q=[];if(X&&typeof X==="object"&&!Array.isArray(X)){for(let[Y,W]of Object.entries(X)){if(typeof Y!=="string"||typeof W!=="string")continue;(PZ0.has(W)?J:Q).push([Y,W])}J.sort((Y,W)=>Y[0].localeCompare(W[0])),Q.sort((Y,W)=>Y[0].localeCompare(W[0]))}return{attention:J,fine:Q}}var TZ0={conflict:"conflict loser",removed:"removed by sync",moved:"moved elsewhere",deleted:"deleted",migration:"migration backup",unknown:"parked"};function jx(X){if(!Number.isFinite(X)||X<0)return"0 B";if(X<1024)return`${X} B`;if(X<1048576)return`${(X/1024).toFixed(0)} kB`;return`${(X/1048576).toFixed(1)} MB`}function IZ0(X){if(!Number.isFinite(X)||X<=0)return"unknown age";let J=Math.floor((Date.now()-X)/86400000);if(J<=0)return"today";if(J===1)return"yesterday";if(J<30)return`${J} d ago`;return`${Math.floor(J/30)} mo ago`}function kZ0(X){try{return new URL(X).host}catch{return"workspace"}}function CZ0(X){let J=String(X??"").replace(/[\p{Cc}\p{Cf}]/gu,"").replace(/\s+/g," ").trim();return J.length>600?`${J.slice(0,600)}…`:J}var AA="maude-sync-notice-ack";function $Z0(X){try{let Q=JSON.parse(localStorage.getItem(AA)||"{}")[X];return Array.isArray(Q)?Q.filter((Y)=>typeof Y==="string"):[]}catch{return[]}}function SZ0(X,J){try{let Q=JSON.parse(localStorage.getItem(AA)||"{}"),Y=Array.isArray(Q[X])?Q[X]:[];if(!Y.includes(J))Y.push(J);Q[X]=Y,localStorage.setItem(AA,JSON.stringify(Q))}catch{}}function wA({status:X,project:J,groupPaths:Q=[],cloud:Y=null,resizing:W,onClose:G}){let Z=Tz(X,{project:J}),[H,K]=u9.useState(!1),[U,q]=u9.useState(!1),[B,N]=u9.useState(""),F=u9.useRef([]);u9.useEffect(()=>()=>{for(let j0 of F.current)clearTimeout(j0);F.current=[]},[]);let D=u9.useCallback(async()=>{if(H||U)return;K(!0),N("");let j0=null,I0={};try{j0=await fetch("/_api/sync/resync",{method:"POST"}),I0=await j0.json().catch(()=>({}))}catch{}if(K(!1),!j0)N("Maude could not reach the sync service.");else if(j0.status===409)N("Already restarting — give it a moment.");else if(!j0.ok||!I0.ok)N(I0.detail||"Resync could not start.");else if(I0.sync&&!I0.sync.syncing)N(I0.sync.detail||"");q(!0),F.current.push(setTimeout(()=>q(!1),DZ0))},[H,U]),_=u9.useCallback(async()=>{try{await fetch("/_api/sync/cancel-assets",{method:"POST"})}catch{}},[]),R=_Z0(X?.items),w=nB(X?.itemsTruncated)?X.itemsTruncated:0,M=AZ0(X?.assets),P=M?.failures||[],I=wZ0(X?.files),k=u9.useMemo(()=>RZ0(X?.files?.delivery),[X?.files?.delivery]),[$,C]=u9.useState(null),[y,f]=u9.useState(!1),[h,d]=u9.useState("");u9.useEffect(()=>{let j0=!1;return fetch("/_api/sync/settings").then((I0)=>I0.ok?I0.json():null).then((I0)=>{if(!j0&&I0&&typeof I0==="object")C(I0.settings??null)}).catch(()=>{}),()=>{j0=!0}},[]);let n=u9.useCallback(async(j0)=>{f(!0),d("");let I0=null;try{I0=await(await fetch("/_api/sync/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(j0)})).json().catch(()=>null)}catch{}if(f(!1),!I0||I0.ok!==!0){d(HU(I0?.detail,"The setting could not be saved."));return}C(I0.settings),d(I0.applied?"Saved — sync is restarting with the new setting.":"Saved — applies the next time sync restarts.")},[]),[x,m]=u9.useState(null),[p,v]=u9.useState(null),[r,a]=u9.useState(!1),[c,U0]=u9.useState("");u9.useEffect(()=>{let j0=!1;return fetch("/_api/sync/ownership").then((I0)=>I0.ok?I0.json():null).then((I0)=>{if(!j0&&I0&&typeof I0.mode==="string")m(I0)}).catch(()=>{}),()=>{j0=!0}},[]);let o=u9.useCallback(async(j0)=>{a(!0),U0("");let I0=null;try{I0=await(await fetch("/_api/sync/ownership",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:j0})})).json().catch(()=>null)}catch{}if(a(!1),v(null),!I0||I0.ok!==!0){U0(HU(I0?.detail,"The ownership change did not complete."));return}U0(j0==="adopt"?`Done — .design/ is workspace-owned now. ${I0.untracked??0} file(s) untracked (still on disk, staged as deletions — commit when ready).`:"Done — unlinked and repo-owned again. Commit .design/ when you are ready.");try{let T8=await fetch("/_api/sync/ownership"),Z8=T8.ok?await T8.json():null;if(Z8&&typeof Z8.mode==="string")m(Z8)}catch{}},[]),[Z0,e]=u9.useState(null),[N0,K0]=u9.useState(!1),[u0,Q8]=u9.useState(""),[o0,_8]=u9.useState(!1),A0=u9.useCallback(async()=>{try{let j0=await fetch("/_api/sync/trash"),I0=j0.ok?await j0.json():null;if(I0&&Array.isArray(I0.entries))e(I0)}catch{}},[]);u9.useEffect(()=>{A0()},[A0]);let r0=u9.useCallback(async(j0,I0)=>{K0(!0),Q8("");let T8=null;try{T8=await(await fetch("/_api/sync/trash",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(j0)})).json().catch(()=>null)}catch{}if(K0(!1),_8(!1),!T8||T8.ok!==!0)Q8(HU(T8?.detail,"That did not complete."));else Q8(I0(T8));A0()},[A0]),P0=typeof X?.url==="string"?X.url:"",[K8,F8]=u9.useState(0),D8=u9.useMemo(()=>{let j0=$Z0(P0);return EZ0(X?.notices).filter((I0)=>!j0.includes(I0.id))},[X?.notices,P0,K8]),W8=u9.useCallback((j0)=>{SZ0(P0,j0),F8((I0)=>I0+1)},[P0]),{attention:A8,byGroup:i8}=u9.useMemo(()=>{let j0=R.filter((Z8)=>Z8.state==="auth-rejected"),I0=R.filter((Z8)=>Z8.state!=="auth-rejected"),T8=new Map;for(let Z8 of I0){let z0=MZ0(Z8.slug,Q)??"canvases";if(!T8.has(z0))T8.set(z0,[]);T8.get(z0).push(Z8)}return{attention:j0,byGroup:T8}},[R,Q]),P9=X?.docs,l0=P9&&[P9.synced,P9.pending,P9.rejected].every(nB)?P9:null,i0=l0&&[`${l0.synced} synced`,l0.pending>0?`${l0.pending} syncing`:null,l0.rejected>0?`${l0.rejected} refused`:null].filter(Boolean).join(" · ");return O("aside",{className:"st-rpanel sp-panel"+(W?" is-resizing":""),"aria-label":"Sync","data-testid":"sync-panel",children:[O("div",{className:"gp-head",children:[O("div",{className:"gp-panel-hd",children:[z("span",{className:"gp-panel-title",children:"Sync"}),i0&&z("span",{className:"gp-count",children:i0}),z("span",{className:"gp-spacer"}),!Y&&z("button",{type:"button",className:"sp-resync","data-testid":"sync-resync",onClick:D,disabled:H||U,title:"Re-check every canvas and asset against the workspace",children:H?"Resyncing…":"Resync"}),z("button",{type:"button",className:"gp-x","aria-label":"Close",onClick:G,children:"×"})]}),B&&z("div",{className:"sp-resync-note",role:"status","aria-live":"polite",children:HU(B,"")}),Z&&O("div",{className:"sp-note",role:"status","aria-live":"polite",children:[z("span",{className:"sp-note-dot is-"+Z.phase,"aria-hidden":"true"}),O("span",{children:[Z.title,Z.next?` ${Z.next}`:""]})]})]}),O("div",{className:"sp-body",children:[D8.length>0&&z("section",{"aria-label":"Notices","data-testid":"sync-notices",children:D8.map((j0)=>O("div",{className:"sp-notice","data-testid":`sync-notice-${j0.id}`,children:[z("p",{className:"sp-notice-text",children:CZ0(j0.text)}),z("button",{type:"button",className:"sp-notice-dismiss","data-testid":`sync-notice-dismiss-${j0.id}`,onClick:()=>W8(j0.id),title:"Got it — don't show this again for this hub on this machine",children:"Got it"})]},j0.id))}),R.length===0&&!M&&z("div",{className:"gp-empty",children:z("p",{children:"No per-file detail yet — it arrives with the first sync report after this panel shipped. If this persists, restart Maude."})}),A8.length>0&&O("section",{"aria-label":"Needs attention",children:[z("div",{className:"gp-sect-label sp-sect-attention",children:"Needs attention"}),z("ul",{className:"sp-list",children:A8.map((j0)=>z(bx,{item:j0},j0.slug))})]}),[...i8.entries()].map(([j0,I0])=>O("section",{"aria-label":j0,children:[O("div",{className:"gp-sect-label",children:[j0," ",z("span",{className:"gp-group-count",children:I0.length})]}),z("ul",{className:"sp-list",children:I0.map((T8)=>z(bx,{item:T8},T8.slug))})]},j0)),w>0&&O("div",{className:"sp-truncated",children:["+",w," more synced canvas",w===1?"":"es"," not listed."]}),M&&O("section",{"aria-label":"Assets","data-testid":"sync-assets",children:[O("div",{className:"gp-sect-label",children:["assets ",z("span",{className:"gp-group-count",children:M.total})]}),O("div",{className:"sp-assets-line",children:[M.finished?`${M.pushed} pushed · ${M.skipped} already there`+(M.failedCount>0?` · ${M.failedCount} failed`:""):`Pushing assets — ${M.done} of ${M.total}…`,!M.finished&&z("button",{type:"button",className:"sp-assets-cancel","data-testid":"sync-assets-cancel",onClick:_,children:"Cancel"})]}),!M.finished&&M.active&&O("div",{className:"sp-assets-active",title:P6(M.active,""),children:["↑ ",P6(M.active,"")]}),M.failedCount>0&&O("ul",{className:"sp-list",children:[P.map((j0)=>O("li",{className:"sp-row is-auth-rejected",children:[z("span",{className:"sp-row-dot","aria-hidden":"true"}),z("span",{className:"sp-row-name",title:P6(j0.key,"(unnamed)"),children:P6(j0.key,"(unnamed)")}),z("span",{className:"sp-row-state",children:P6(j0.reason,"failed")})]},j0.key)),M.failedCount>P.length&&O("li",{className:"sp-truncated",children:["+",M.failedCount-P.length," more failed. All retry on the next launch."]})]}),M.failedCount>0&&M.finished&&z("div",{className:"sp-assets-retry",children:"Failed assets retry on the next launch."})]}),I&&O("section",{"aria-label":"Project files","data-testid":"sync-files",children:[O("div",{className:"gp-sect-label",children:["project files ",z("span",{className:"gp-group-count",children:I.synced})]}),z("div",{className:"sp-assets-line",children:`${I.synced} synced`+(I.pulled>0?` · ${I.pulled} pulled`:"")}),I.conflicts>0&&O("div",{className:"sp-assets-retry","data-testid":"sync-files-conflicts",children:[I.conflicts," conflict",I.conflicts===1?"":"s"," — the older copies are kept in Trash, below."]}),Array.isArray(I.held)&&I.held.map((j0)=>O("div",{className:"sp-assets-retry","data-testid":`sync-held-${j0.kind}`,children:[z("strong",{children:"sync paused — nothing was removed."})," ",j0.detail,j0.paths?.length>0&&O("details",{className:"sp-held-paths",children:[O("summary",{children:[j0.count," file",j0.count===1?"":"s"]}),O("ul",{children:[j0.paths.slice(0,50).map((I0)=>z("li",{children:I0},I0)),j0.paths.length>50&&O("li",{children:["…and ",j0.paths.length-50," more"]})]})]})]},j0.kind)),k.attention.length>0&&O("ul",{className:"sp-list","data-testid":"sync-delivery-attention",children:[k.attention.slice(0,50).map(([j0,I0])=>O("li",{className:"sp-row is-auth-rejected",children:[z("span",{className:"sp-row-dot","aria-hidden":"true"}),z("span",{className:"sp-row-name",title:P6(j0,"(unnamed)"),children:P6(j0,"(unnamed)")}),z("span",{className:"sp-row-state",children:yx[I0]||I0})]},j0)),k.attention.length>50&&O("li",{className:"sp-truncated",children:["…and ",k.attention.length-50," more"]})]}),k.fine.length>0&&O("details",{className:"sp-held-paths","data-testid":"sync-delivery-fine",children:[O("summary",{children:[k.fine.length," file",k.fine.length===1?"":"s"," delivered"]}),O("ul",{children:[k.fine.slice(0,200).map(([j0,I0])=>O("li",{children:[P6(j0,"(unnamed)")," — ",yx[I0]||I0]},j0)),k.fine.length>200&&O("li",{children:["…and ",k.fine.length-200," more"]})]})]})]}),Z0&&Z0.total>0&&O("section",{"aria-label":"Trash","data-testid":"sync-trash",children:[O("div",{className:"gp-sect-label",children:["trash ",z("span",{className:"gp-group-count",children:Z0.total})]}),O("div",{className:"sp-assets-line",children:[Z0.total," file",Z0.total===1?"":"s"," kept instead of deleted (",jx(Z0.bytes),") — replaced copies, conflict losers and remote deletions land here, in .design/_trash/."]}),O("ul",{className:"sp-list","data-testid":"sync-trash-list",children:[Z0.entries.slice(0,50).map((j0)=>O("li",{className:"sp-row",children:[z("span",{className:"sp-row-name",title:P6(j0.trashRel,"(unnamed)"),children:P6(j0.sourceRel??j0.trashRel.replace(/^_trash\//,""),"(unnamed)")}),O("span",{className:"sp-row-state",children:[TZ0[j0.reason]||j0.reason," · ",IZ0(j0.at)]}),j0.sourceRel&&z("button",{type:"button",className:"sp-assets-cancel","data-testid":`sync-trash-restore-${j0.sourceRel}`,disabled:N0,onClick:()=>r0({action:"restore",trashRel:j0.trashRel},(I0)=>I0.restoredTo?`Restored to ${I0.restoredTo}.`:"Restored."),children:"Restore"})]},j0.trashRel)),Z0.total>50&&O("li",{className:"sp-truncated",children:["…and ",Z0.total-50," more in .design/_trash/"]})]}),!o0?z("div",{className:"sp-assets-line",children:z("button",{type:"button",className:"sp-assets-cancel","data-testid":"sync-trash-prune",disabled:N0,onClick:()=>_8(!0),children:"Remove copies older than 30 days…"})}):O("div",{className:"sp-assets-retry","data-testid":"sync-trash-prune-confirm",children:["Permanently delete every parked copy older than 30 days? This cannot be undone."," ",z("button",{type:"button",className:"sp-assets-cancel","data-testid":"sync-trash-prune-yes",disabled:N0,onClick:()=>r0({action:"prune",olderThanDays:30},(j0)=>`Removed ${j0.pruned} file${j0.pruned===1?"":"s"} (${jx(j0.bytes)}); ${j0.kept} kept.`),children:N0?"Removing…":"Delete them"})," ",z("button",{type:"button",className:"sp-assets-cancel",disabled:N0,onClick:()=>_8(!1),children:"Cancel"})]}),u0&&z("div",{className:"sp-resync-note",role:"status","aria-live":"polite",children:u0})]}),$&&O("section",{"aria-label":"Sync settings","data-testid":"sync-settings",children:[z("div",{className:"gp-sect-label",children:"settings"}),O("label",{className:"sp-setting","data-testid":"sync-setting-syncFiles",children:[z("input",{type:"checkbox",checked:$.syncFiles,disabled:y,onChange:(j0)=>n({syncFiles:j0.target.checked})}),O("span",{children:["Sync project files",z("small",{children:"The whole design folder mirrors both ways, not just canvases."})]})]}),O("label",{className:"sp-setting","data-testid":"sync-setting-propagateDeletes",children:[z("input",{type:"checkbox",checked:$.propagateDeletes,disabled:y,onChange:(j0)=>n({propagateDeletes:j0.target.checked})}),O("span",{children:["Propagate deletions",z("small",{children:"Removing a file here removes it everywhere; replaced copies are kept in Trash."})]})]}),O("label",{className:"sp-setting sp-setting-select","data-testid":"sync-setting-firstAnchor",children:[O("span",{children:["First-link conflicts",z("small",{children:"When both sides have content the first time a project links."})]}),O("select",{value:$.resolveFirstAnchor,disabled:y,onChange:(j0)=>n({resolveFirstAnchor:j0.target.value}),children:[z("option",{value:"ask",children:"Keep asking"}),z("option",{value:"keep-local",children:"Keep this machine's"}),z("option",{value:"keep-cloud",children:"Keep the workspace's"})]})]}),h&&z("div",{className:"sp-resync-note",role:"status","aria-live":"polite",children:h})]}),x&&!Y&&x.git&&O("section",{"aria-label":"Ownership","data-testid":"sync-ownership",children:[z("div",{className:"gp-sect-label",children:"ownership"}),O("div",{className:"sp-assets-line","data-testid":"sync-ownership-mode",children:[x.mode==="hub-owned"&&"Workspace-owned — .design/ is gitignored and mirrored by the workspace.",x.mode==="repo-owned"&&"Repo-owned — .design/ is committed with this repository.",x.mode==="hybrid"&&`Two owners — git commits .design/ (${x.trackedCount} file${x.trackedCount===1?"":"s"}) AND a workspace mirrors it. A git pull and a sync pass can each undo the other.`]}),p===null&&x.linked&&x.mode!=="hub-owned"&&z("div",{className:"sp-assets-line",children:z("button",{type:"button",className:"sp-assets-cancel","data-testid":"sync-ownership-adopt",disabled:r,onClick:()=>v("adopt"),children:"Hand .design/ to the workspace…"})}),p===null&&x.mode==="hub-owned"&&z("div",{className:"sp-assets-line",children:z("button",{type:"button",className:"sp-assets-cancel","data-testid":"sync-ownership-detach",disabled:r,onClick:()=>v("detach"),children:"Take .design/ back into this repo…"})}),p&&O("div",{className:"sp-assets-retry","data-testid":"sync-ownership-confirm",children:[p==="adopt"?z(G0,{children:"Stop committing .design/ and let the workspace mirror it. Nothing is deleted — every file stays on disk; git stops tracking them (staged as deletions, commit when ready)."}):O(G0,{children:["Disconnect from the workspace (",kZ0(x.hubUrl),") and take .design/ back into git. Every file is already on disk in full; commit the folder when you are ready."]})," ",z("button",{type:"button",className:"sp-assets-cancel","data-testid":"sync-ownership-confirm-yes",disabled:r,onClick:()=>o(p),children:r?"Working…":"Do it"})," ",z("button",{type:"button",className:"sp-assets-cancel",disabled:r,onClick:()=>v(null),children:"Cancel"})]}),c&&z("div",{className:"sp-resync-note",role:"status","aria-live":"polite",children:c})]})]})]})}var c7=x8(r8(),1);var NW=async(X,J)=>{let Q=await fetch(X,J),Y=await Q.json().catch(()=>({}));return{ok:Q.ok,status:Q.status,json:Y}};function EA(X,J){let Q,Y;try{Q=new URL(String(X)),Y=new URL(String(J??jZ0))}catch{return!1}if(!/^https?:$/.test(Q.protocol))return!1;if(Q.origin===Y.origin)return!0;let W=Q.hostname;return Q.protocol==="https:"&&!Q.port&&(Q.pathname===""||Q.pathname==="/")&&!Q.search&&!Q.hash&&(W===PA||W.endsWith(`.${PA}`))}function JV(X){if(!X)return Promise.resolve("failed");if(W9())return xf(X).then(()=>"ok",(J)=>/Refusing to open/i.test(String(J))?"refused":"failed");try{return window.open(X,"_blank","noopener"),Promise.resolve("ok")}catch{return Promise.resolve("failed")}}function bZ0(X){let J=/^maude:\/\/open\/([a-z0-9]+(?:-[a-z0-9]+)*)\/?\?(.*)$/.exec(String(X??""));if(!J)return null;if(J[1].length>40)return null;let Q=new URLSearchParams(J[2]).get("code")??"";if(!/^mhc_[0-9a-f]{16,128}$/.test(Q))return null;return{project:J[1],code:Q}}function yZ0(X,J){try{let Q=new URL(X);return`${Q.protocol}//${Q.host}`}catch{return`https://${J}.${PA}`}}var jZ0="https://cloud.maude.sh",PA="cloud.maude.sh",RA=(X)=>String(X??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").replace(/-{2,}/g,"-").slice(0,40).replace(/-+$/,""),IA=(X)=>{try{return new URL(X).hostname}catch{return""}};function TA(X,J){let Q=IA(X);if(!J||Q===J)return"";if(!Q.endsWith(`.${J}`))return"";return RA(Q.slice(0,-(J.length+1)).replace(/^view-/,""))}function vZ0({projectUrl:X,linkedHubUrl:J,linkedHubCredentialed:Q,cloudUrl:Y}){if(!J||!Q)return!1;let W=IA(Y),G=TA(J,W),Z=TA(X,W);if(G&&Z)return G===Z;try{return new URL(String(X)).origin===new URL(String(J)).origin}catch{return!1}}function fZ0({localProject:X,linkedHubUrl:J,linkedHubCredentialed:Q,cloudUrl:Y,claimed:W,resolved:G=!0}){if(!G)return"unknown";let Z=RA(W);if(!Z)return"unknown";let H=J?TA(J,IA(Y)):"";if(H&&Q)return H===Z?"linked":"mismatch";let K=RA(X);if(!K)return"unknown";if(K===Z)return"match";return(K.length<=Z.length?K:Z).length>=4&&(K.includes(Z)||Z.includes(K))?"similar":"mismatch"}function xZ0(X,J,Q){let Y=P6(X,"the workspace");if(Q){let G=Tz(Q,{project:Y});if(G){let Z=G.names.length?` (${G.names.join(", ")})`:"";return{text:G.title,title:`${G.title}${Z}${G.next?` — ${G.next}`:""}`}}}if(J?.syncing){let G=J.canvases??0;return{text:`Connecting to ${Y} — ${G} canvas${G===1?"":"es"}…`,title:`Opening ${G} canvas${G===1?"":"es"} against the ${Y} workspace. This line updates as they settle.`}}if(J?.reason==="nothing-syncable")return{text:`Connected to ${Y} — nothing to sync yet.`,title:P6(J.detail,"No canvases in this project are syncable yet.")};let W=P6(J?.detail,"restart Maude to start syncing.");return{text:`Connected to ${Y} — ${W}`,title:W}}function rB({size:X=15}){return z("svg",{width:X,height:X,viewBox:"0 0 32 32",fill:"currentColor","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z"})})}function bQ({name:X,size:J=15}){let Q={"chevron-up":z("polyline",{points:"3.5 10 8 5.5 12.5 10"}),check:z("polyline",{points:"3 8.5 6.5 12 13 4.5"}),external:O(G0,{children:[z("path",{d:"M6 3.5H3.2A.7.7 0 0 0 2.5 4.2v8.6a.7.7 0 0 0 .7.7h8.6a.7.7 0 0 0 .7-.7V10"}),z("line",{x1:"8",y1:"8",x2:"13",y2:"3"}),z("polyline",{points:"9.5 3 13 3 13 6.5"})]}),copy:O(G0,{children:[z("rect",{x:"5.5",y:"5.5",width:"7.5",height:"7.5",rx:"1.2"}),z("path",{d:"M3 10.5V3.2A.7.7 0 0 1 3.7 2.5H10"})]}),"arrow-right":O(G0,{children:[z("line",{x1:"2.5",y1:"8",x2:"12.5",y2:"8"}),z("polyline",{points:"9 4.5 12.5 8 9 11.5"})]}),link:O(G0,{children:[z("path",{d:"M6.5 9.5l3-3"}),z("path",{d:"M7.5 4.5l1-1a2.47 2.47 0 0 1 3.5 3.5l-1 1"}),z("path",{d:"M8.5 11.5l-1 1a2.47 2.47 0 0 1-3.5-3.5l1-1"})]}),signout:O(G0,{children:[z("path",{d:"M6.5 13.5H3.2a.7.7 0 0 1-.7-.7V3.2a.7.7 0 0 1 .7-.7h3.3"}),z("line",{x1:"13",y1:"8",x2:"6.5",y2:"8"}),z("polyline",{points:"10 5 13 8 10 11"})]})}[X];return z("svg",{width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Q})}function kA({syncStatus:X,onLinkedHub:J}){let[Q,Y]=c7.useState("loading"),[W,G]=c7.useState(null),[Z,H]=c7.useState(!1),[K,U]=c7.useState(null),[q,B]=c7.useState(null),[N,F]=c7.useState(""),[D,_]=c7.useState(null),[R,w]=c7.useState(""),[M,P]=c7.useState(!1),[I,k]=c7.useState(!1),[$,C]=c7.useState(""),[y,f]=c7.useState("https://cloud.maude.sh"),[h,d]=c7.useState({project:"",linkedHub:null,resolved:!1}),[n,x]=c7.useState(null),m=c7.useRef(null),p=c7.useRef(null),v=D?xZ0(D.project,D.sync,X):null;c7.useEffect(()=>{return NW("/_api/cloud/status").then((A0)=>{if(A0.json?.url)f(A0.json.url);if(d({project:A0.json?.project??"",linkedHub:A0.json?.linkedHub??null,resolved:!0}),J?.(A0.json?.linkedHub??null),A0.ok&&A0.json?.connected)G(A0.json.email),Y("in");else Y("out")}).catch(()=>{d((A0)=>({...A0,resolved:!0})),Y("out")}),()=>clearInterval(p.current)},[]),c7.useEffect(()=>{if(!W9())return;let A0=(P0)=>{let K8=bZ0(P0);if(!K8)return;x((F8)=>F8??K8)};y7("take_pending_deep_link").then((P0)=>P0&&A0(P0)).catch(()=>{});let r0=null;return DZ("maude://deep-link",A0).then((P0)=>{r0=P0}),()=>r0?.()},[]);async function r(){if(!n)return;F("deeplink"),w("");let A0=await NW("/_api/cloud/attach/code",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:n.code,project:n.project})});if(F(""),x(null),A0.ok&&A0.json?.ok)_({project:A0.json.project??n.project,sync:A0.json.sync}),a(A0.json.url);else w(A0.json?.error||"The workspace could not be connected.")}function a(A0){if(typeof A0==="string"&&A0)d((r0)=>({...r0,linkedHub:{url:A0,credentialed:!0}})),J?.({url:A0,credentialed:!0})}c7.useEffect(()=>{if(!n)return;let A0=(r0)=>{if(r0.key==="Escape")x(null)};return document.addEventListener("keydown",A0),()=>document.removeEventListener("keydown",A0)},[n]),c7.useEffect(()=>{if(!Z)return;let A0=(r0)=>{if(m.current&&!m.current.contains(r0.target))H(!1)};return document.addEventListener("mousedown",A0),()=>document.removeEventListener("mousedown",A0)},[Z]);async function c(){w("");let A0=await NW("/_api/cloud/signin/start",{method:"POST"});if(!A0.ok||!A0.json?.ok){w(A0.json?.error||"Maude Cloud could not be reached.");return}U(A0.json),C(""),JV(A0.json.verificationUrl).then((r0)=>C(r0==="ok"?"":r0)),p.current=setInterval(async()=>{let r0=await NW("/_api/cloud/signin/poll",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({deviceCode:A0.json.deviceCode})});if(r0.json?.pending)return;if(clearInterval(p.current),r0.ok&&r0.json?.ok)G(r0.json.email),Y("in"),U(null);else U(null),w(r0.json?.error||"The sign-in did not finish. Try again.")},(A0.json.interval??5)*1000)}function U0(){clearInterval(p.current),U(null)}async function o(){let A0=!Z;if(H(A0),A0&&q===null){let r0=await NW("/_api/cloud/projects");if(B(r0.ok&&r0.json?.ok?r0.json.projects:[]),!r0.ok&&r0.status===401)H(!1),Y("out"),G(null)}}async function Z0(A0){F(A0),_(null),w("");let r0=await NW("/_api/cloud/attach",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({project:A0})});if(F(""),r0.ok&&r0.json?.ok)_({project:r0.json.project??A0,sync:r0.json.sync}),a(r0.json.url);else w(r0.json?.error||"The workspace could not be connected.");H(!1)}async function e(){F("disconnect"),w("");let A0=await NW("/_api/cloud/detach",{method:"POST"});if(F(""),H(!1),A0.ok&&A0.json?.ok)d((r0)=>({...r0,linkedHub:null})),_(null),J?.(null);else w(A0.json?.error||"The workspace could not be disconnected.")}async function N0(){H(!1),await NW("/_api/cloud/signout",{method:"POST"}),G(null),B(null),Y("out")}function K0(A0,r0){if(!A0)return;navigator.clipboard?.writeText(A0).then(()=>{r0(!0),setTimeout(()=>r0(!1),1500)},()=>{})}let u0=()=>K0(K?.userCode,P),Q8=()=>K0(K?.verificationUrl,k);if(Q==="loading")return null;let o0=n?fZ0({localProject:h.project,linkedHubUrl:h.linkedHub?.url,linkedHubCredentialed:h.linkedHub?.credentialed,cloudUrl:y,claimed:n.project,resolved:h.resolved}):"unknown",_8=o0==="linked"||o0==="match";return O("div",{className:"gi-rail cb-rail",ref:m,"data-testid":"cloud-bar",children:[n&&h.resolved&&O("div",{className:"gi-modal",role:"dialog","aria-modal":"true","aria-label":`Connect this folder to ${n.project}`,children:[z("div",{className:"gi-scrim","aria-hidden":"true",onClick:()=>x(null)}),O("div",{className:"gi-dialog gi-dialog--code","data-testid":"cloud-deeplink-dialog",children:[O("div",{className:"gi-dc-head",children:[z("span",{className:"gi-dc-marks",children:z(bQ,{name:"link",size:24})}),O("h2",{children:["Connect to ",n.project,"?"]})]}),O("div",{className:"gi-dl-pair",children:[O("span",{className:"gi-dl-side",children:[z("span",{className:"gi-dl-lbl",children:"This folder"}),z("span",{className:"gi-dl-val","data-testid":"cloud-deeplink-local",children:h.project||"the open project"})]}),z("span",{className:"gi-dl-arrow","aria-hidden":"true",children:z(bQ,{name:"arrow-right",size:16})}),O("span",{className:"gi-dl-side",children:[z("span",{className:"gi-dl-lbl",children:"Cloud project"}),z("span",{className:"gi-dl-val",children:n.project})]})]}),O("p",{className:"gi-dl-what",children:["This folder’s ",z("code",{children:".design/"})," canvases will sync with the ",n.project," ","workspace. Nothing else in this repo is uploaded."]}),o0==="linked"&&O("p",{className:"gi-dl-note",children:["This folder is already linked to ",n.project," — connecting refreshes the link."]}),!_8&&O("div",{className:"gi-dl-warn","data-testid":"cloud-deeplink-mismatch",children:[z("strong",{children:o0==="similar"?O(G0,{children:[h.project," and ",n.project," are different workspaces."]}):o0==="unknown"?z(G0,{children:"Maude can’t tell which project this folder is."}):O(G0,{children:["This folder looks like ",h.project||"something else",", not"," ",n.project,"."]})}),O("span",{children:["Connecting will sync ",z("em",{children:"this folder’s"})," designs into ",n.project,". If you meant to work on ",n.project,", open its folder in Maude and press “Open in Maude” again. Don’t have it on this machine? It opens in"," ",EA(y,y)?z("a",{className:"gi-dc-link-a",href:y,rel:"noopener noreferrer",target:"_blank",onClick:(A0)=>{A0.preventDefault(),JV(y)},children:"your browser"}):"your browser","."]})]}),z("div",{className:"gi-dc-foot",children:!_8?O(G0,{children:[z("button",{type:"button",className:"btn",onClick:()=>x(null),"data-testid":"cloud-deeplink-dismiss",children:"Not now"}),z("button",{type:"button",className:"btn btn--ghost",disabled:N==="deeplink",onClick:r,"data-testid":"cloud-deeplink-connect",children:N==="deeplink"?"Connecting…":"Connect anyway"})]}):O(G0,{children:[z("button",{type:"button",className:"btn",disabled:N==="deeplink",onClick:r,"data-testid":"cloud-deeplink-connect",children:N==="deeplink"?"Connecting…":"Connect"}),z("button",{type:"button",className:"btn btn--ghost",onClick:()=>x(null),"data-testid":"cloud-deeplink-dismiss",children:"Not now"})]})})]})]}),Q==="out"&&O(G0,{children:[O("button",{type:"button",className:"btn btn--ghost btn--sm gi-rail-signin",onClick:c,"data-testid":"cloud-signin",children:[z(rB,{size:14})," Sign in to Maude Cloud"]}),R&&z("span",{className:"gi-rail-err",title:R,children:R})]}),Q==="in"&&O(G0,{children:[O("button",{type:"button",className:"gi-rail-account"+(Z?" is-open":""),"aria-expanded":Z,"aria-haspopup":"menu",onClick:o,title:`Maude Cloud — ${W??"connected"}`,"data-testid":"cloud-account",children:[z("span",{className:"gi-avatar gi-avatar--fallback","aria-hidden":"true",children:z(rB,{size:14})}),z("span",{className:"gi-rail-login",children:W??"Maude Cloud"}),z("span",{className:"gi-rail-caret",children:z(bQ,{name:"chevron-up",size:13})})]}),v&&z("span",{className:"gi-rail-hint",title:v.title,role:"status","aria-live":"polite","data-testid":"cloud-connect-note",children:v.text}),R&&z("span",{className:"gi-rail-err",title:R,children:R}),Z&&O("div",{className:"gi-menu",role:"menu","aria-label":"Maude Cloud",children:[O("div",{className:"gi-menu-hd",children:[z("span",{className:"gi-avatar gi-avatar--fallback","aria-hidden":"true",children:z(rB,{size:16})}),O("span",{className:"gi-menu-id",children:[z("span",{className:"gi-menu-name",children:"Maude Cloud"}),z("span",{className:"gi-menu-login",children:W??"connected"})]})]}),q===null&&z("div",{className:"gi-menu-item","aria-disabled":"true",children:"Loading projects…"}),Array.isArray(q)&&q.length===0&&z("div",{className:"gi-menu-item","aria-disabled":"true",children:"No projects yet — start one on the dashboard."}),Array.isArray(q)&&q.map((A0)=>A0.role==="viewer"?O("button",{type:"button",className:"gi-menu-item",role:"menuitem",onClick:()=>JV(yZ0(A0.url,A0.id)),title:"Viewing works in the browser. Editing in the app needs the member role — ask whoever runs the project.","data-testid":`cloud-project-${A0.id}`,children:[z(bQ,{name:"external",size:15})," View ",A0.name||A0.id," in the browser",z("span",{className:"gi-menu-login",style:{marginLeft:"auto"},children:"viewer"})]},A0.id):vZ0({projectUrl:A0.url,linkedHubUrl:h.linkedHub?.url,linkedHubCredentialed:h.linkedHub?.credentialed,cloudUrl:y})?O("div",{className:"gi-menu-item is-connected","data-testid":`cloud-project-${A0.id}`,children:[z(bQ,{name:"check",size:15})," ",A0.name||A0.id,z("span",{className:"gi-menu-login",style:{marginLeft:"auto"},children:"Connected"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",role:"menuitem",disabled:N==="disconnect",onClick:e,"aria-label":`Disconnect this folder from ${A0.name||A0.id}`,"data-testid":`cloud-disconnect-${A0.id}`,children:N==="disconnect"?"Disconnecting…":"Disconnect"})]},A0.id):O("button",{type:"button",className:"gi-menu-item",role:"menuitem",disabled:N===A0.id,onClick:()=>Z0(A0.id),title:`Connect this project to ${A0.url} (${A0.role})`,"data-testid":`cloud-project-${A0.id}`,children:[z(bQ,{name:"link",size:15})," ",N===A0.id?"Connecting…":`Connect ${A0.name||A0.id}`,z("span",{className:"gi-menu-login",style:{marginLeft:"auto"},children:A0.stateLabel})]},A0.id)),z("div",{className:"gi-menu-sep"}),O("button",{type:"button",className:"gi-menu-item",role:"menuitem",onClick:()=>JV(y),children:[z(bQ,{name:"external",size:15})," Open the dashboard"]}),O("button",{type:"button",className:"gi-menu-item gi-menu-item--danger",role:"menuitem",onClick:N0,children:[z(bQ,{name:"signout",size:15})," Sign out"]})]})]}),K&&O("div",{className:"gi-modal",role:"dialog","aria-modal":"true","aria-label":"Sign in to Maude Cloud",onKeyDown:(A0)=>{if(A0.key==="Escape")U0()},children:[z("div",{className:"gi-scrim","aria-hidden":"true",onClick:U0}),O("div",{className:"gi-dialog gi-dialog--code","data-testid":"cloud-device-dialog",children:[O("div",{className:"gi-dc-head",children:[z("span",{className:"gi-dc-marks",children:z(rB,{size:26})}),z("h2",{children:"Sign in to Maude Cloud"}),z("p",{children:"Confirm this code on your Maude Cloud dashboard to connect."})]}),O("div",{className:"gi-code",children:[z("span",{className:"gi-code-val","data-testid":"cloud-user-code",children:K.userCode}),O("button",{type:"button",className:"btn btn--ghost gi-code-copy",onClick:u0,"aria-label":"Copy the code",children:[z(bQ,{name:"copy",size:15})," ",M?"Copied":"Copy"]})]}),K.verificationUrl&&EA(K.verificationUrl,y)&&O("div",{className:"gi-dc-link",children:[z("span",{className:"gi-dc-link-lbl",children:$==="failed"?"Maude couldn’t open your browser. Open this address yourself:":"If your browser didn’t open, go to:"}),O("div",{className:"gi-dc-link-row",children:[z("a",{className:"gi-dc-url gi-dc-link-a",href:K.verificationUrl,rel:"noopener noreferrer",target:"_blank","data-testid":"cloud-signin-link",onClick:(A0)=>{A0.preventDefault(),JV(K.verificationUrl).then((r0)=>C(r0==="ok"?"":r0))},children:K.verificationUrl}),O("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:Q8,"aria-label":"Copy the link",children:[z(bQ,{name:"copy",size:14})," ",I?"Copied":"Copy link"]})]})]}),$==="refused"&&O("div",{className:"gi-dl-warn","data-testid":"cloud-signin-refused",children:[z("strong",{children:"Maude wouldn’t open that address."}),z("span",{children:"It isn’t a Maude Cloud address. Sign in on your dashboard instead."})]}),K.verificationUrl&&!EA(K.verificationUrl,y)&&O("div",{className:"gi-dl-warn","data-testid":"cloud-signin-badurl",children:[z("strong",{children:"Maude Cloud sent an address that doesn’t look right."}),z("span",{children:"Nothing was opened. Sign in on your dashboard directly instead of following it."})]}),O("div",{className:"gi-dc-status","aria-live":"polite",children:[z("span",{className:"gi-pulse","aria-hidden":"true"}),z("span",{children:"Waiting for you to confirm in the browser…"})]}),O("div",{className:"gi-dc-foot",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:U0,children:"Cancel"}),z("span",{className:"gi-dc-foot-note",children:"Nothing is stored until you confirm."})]})]})]})]})}var l6=x8(r8(),1);var _6=x8(r8(),1);function YX({name:X,size:J=16}){let Q={lock:O(G0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1.2"}),z("path",{d:"M5.5 7V5.2a2.5 2.5 0 0 1 5 0V7"})]}),globe:O(G0,{children:[z("circle",{cx:"8",cy:"8",r:"5.5"}),z("path",{d:"M2.5 8h11M8 2.5c1.7 1.5 2.6 3.5 2.6 5.5S9.7 12.5 8 13.5C6.3 12 5.4 10 5.4 8S6.3 3.5 8 2.5z"})]}),x:O(G0,{children:[z("line",{x1:"3.5",y1:"3.5",x2:"12.5",y2:"12.5"}),z("line",{x1:"12.5",y1:"3.5",x2:"3.5",y2:"12.5"})]}),check:z("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),plus:O(G0,{children:[z("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),z("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),invite:O(G0,{children:[z("circle",{cx:"6",cy:"5.5",r:"2.5"}),z("path",{d:"M2 13.5a4 4 0 0 1 8 0"}),z("line",{x1:"13",y1:"5",x2:"13",y2:"9"}),z("line",{x1:"11",y1:"7",x2:"15",y2:"7"})]}),download:O(G0,{children:[z("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),z("polyline",{points:"4.5 7 8 10.5 11.5 7"}),z("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),spinner:z("path",{d:"M8 2.2a5.8 5.8 0 1 0 5.8 5.8"}),laptop:O(G0,{children:[z("rect",{x:"3",y:"3.5",width:"10",height:"7",rx:"1"}),z("path",{d:"M1.5 13h13l-1.2-1.8H2.7z"})]})}[X];return z("svg",{width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:X==="spinner"?"cp-spin":void 0,children:Q})}var vx={new:["Create a new project","On GitHub, or just locally on your computer."],get:["Pull a local copy","Pick a project, choose where to save it, and open it here."],share:["Share this project","Invite a teammate by their GitHub username."]};function CA({view:X,identity:J,signedIn:Q,onClose:Y}){let[W,G]=vx[X]||vx.new;return O("div",{className:"cp-modal",role:"dialog","aria-modal":"true","aria-label":W,onKeyDown:(Z)=>{if(Z.key==="Escape")Y()},children:[z("div",{className:"cp-scrim","aria-hidden":"true",onClick:Y}),O("div",{className:"cp-dialog",children:[O("div",{className:"cp-dialog-hd",children:[O("span",{className:"cp-dialog-titles",children:[z("h2",{children:W}),z("p",{children:G})]}),z("button",{type:"button",className:"btn btn--icon","aria-label":"Close",onClick:Y,children:z(YX,{name:"x",size:15})})]}),X==="new"&&z(hZ0,{identity:J,signedIn:Q,onClose:Y}),X==="get"&&z(gZ0,{}),X==="share"&&z(mZ0,{onClose:Y})]})]})}function hZ0({identity:X,signedIn:J,onClose:Q}){let[Y,W]=_6.useState(""),[G,Z]=_6.useState(J?"github":"local"),[H,K]=_6.useState(!0),[U,q]=_6.useState(""),[B,N]=_6.useState(!1),[F,D]=_6.useState(""),[_,R]=_6.useState(""),w=G==="local",M=Y.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),P=X?.login||"you";async function I(){R(""),N(!0);try{D("Choose where to save it…");let k=await x4();if(!k){N(!1),D("");return}let $;if(w)D("Setting up your local project…"),$=await lf({name:Y,parentDir:k});else D("Creating your project on GitHub…"),$=await mB({name:Y,private:H,description:U,parentDir:k});if(!($.ok&&$.json?.ok)){R($.json?.error||"Couldn’t create the project. Try again."),N(!1),D("");return}D("Opening it in Maude…"),await q5($.json.path)}catch(k){R(String(k?.message||k||"Something went wrong creating the project.")),N(!1),D("")}}return O(G0,{children:[O("div",{className:"cp-body",children:[O("div",{className:"cp-field",children:[z("span",{className:"cp-field-label",children:"Where"}),O("div",{className:"seg cp-seg",role:"group","aria-label":"Where to create the project",children:[O("button",{type:"button","aria-pressed":!w,disabled:!J,title:J?void 0:"Sign in with GitHub first",onClick:()=>Z("github"),children:[z(YX,{name:"globe",size:14})," GitHub"]}),O("button",{type:"button","aria-pressed":w,onClick:()=>Z("local"),children:[z(YX,{name:"laptop",size:14})," This computer only"]})]}),z("span",{className:"cp-field-help",children:w?"A local git repo on your computer — no GitHub, no remote. You can publish it later.":J?"A repo on your GitHub account, cloned to your computer.":"Sign in with GitHub (bottom-left) to publish. For now you can create a local project."})]}),O("label",{className:"cp-field",children:[z("span",{className:"cp-field-label",children:"Project name"}),z("input",{className:"input cp-input",type:"text",value:Y,placeholder:"Acme Rebrand","aria-label":"Project name",onChange:(k)=>W(k.target.value)}),M&&z("span",{className:"cp-field-help",children:w?O(G0,{children:["Creates a project folder ",z("b",{children:M})]}):O(G0,{children:["Creates ",O("b",{children:["github.com/",P,"/",M]})]})})]}),!w&&O(G0,{children:[O("div",{className:"cp-field",children:[z("span",{className:"cp-field-label",children:"Who can see it"}),O("div",{className:"seg cp-seg",role:"group","aria-label":"Project visibility",children:[O("button",{type:"button","aria-pressed":H,onClick:()=>K(!0),children:[z(YX,{name:"lock",size:14})," Private"]}),O("button",{type:"button","aria-pressed":!H,onClick:()=>K(!1),children:[z(YX,{name:"globe",size:14})," Public"]})]}),z("span",{className:"cp-field-help",children:H?"Only you and people you invite. The safe default.":"Anyone on the internet can see this project."})]}),O("label",{className:"cp-field",children:[O("span",{className:"cp-field-label",children:["Description ",z("span",{className:"cp-optional",children:"optional"})]}),z("textarea",{className:"textarea cp-textarea",rows:2,value:U,placeholder:"What is this project for?","aria-label":"Project description",onChange:(k)=>q(k.target.value)})]})]}),_&&O("div",{className:"callout callout--error",children:[z("span",{className:"cp-cl-glyph",style:{color:"var(--status-error)"},children:z(YX,{name:"x"})}),z("span",{children:_})]})]}),O("div",{className:"cp-ft",children:[z("span",{className:"cp-spacer"}),z("button",{type:"button",className:"btn btn--ghost",onClick:Q,children:"Cancel"}),O("button",{type:"button",className:"btn btn--primary",onClick:I,disabled:B||!M,children:[z(YX,{name:"plus",size:15})," ",B?F||"Creating…":w?"Create local project":"Create project"]})]})]})}function gZ0(){let[X,J]=_6.useState(null),[Q,Y]=_6.useState(""),[W,G]=_6.useState(null),[Z,H]=_6.useState(""),[K,U]=_6.useState(null),[q,B]=_6.useState(!1);async function N(){if(!K)return;Y(""),B(!0);try{let D=await rU(K.path);if(!(D.ok&&D.json?.ok)){Y(D.json?.error||"Couldn’t set it up. Try again."),B(!1);return}await q5(K.path)}catch(D){Y(String(D?.message||D||"Couldn’t set it up.")),B(!1)}}_6.useEffect(()=>{(async()=>{let D=await hB();if(D.ok&&D.json?.ok)J(D.json.repos||[]);else Y(D.json?.error||"Couldn’t load your projects."),J([])})()},[]);async function F(D){Y(""),U(null),G(D.full_name);try{H("Choose a folder to save it in…");let _=await x4();if(!_){G(null),H("");return}H("Downloading your project…");let R=await gB({cloneUrl:D.clone_url,parentDir:_,name:D.name});if(!(R.ok&&R.json?.ok)){Y(R.json?.error||"Couldn’t download the project. Try again."),G(null),H("");return}if(R.json.hasDesign===!1){U({name:D.name,path:R.json.path}),G(null),H("");return}H("Opening it in Maude…"),await q5(R.json.path)}catch(_){Y(String(_?.message||_||"Something went wrong pulling the project.")),G(null),H("")}}if(K)return O(G0,{children:[O("div",{className:"cp-body",children:[O("div",{className:"callout callout--info",children:[z("span",{className:"cp-cl-glyph",style:{color:"var(--status-info)"},children:z(YX,{name:"download"})}),O("span",{children:[O("b",{style:{color:"var(--fg-0)"},children:["Got “",K.name,"” — it’s not a Maude project yet."]})," Saved to"," ",z("b",{children:K.path}),". Set up Maude in it to start designing (you can build a design system after)."]})]}),Q&&O("div",{className:"callout callout--error",children:[z("span",{className:"cp-cl-glyph",style:{color:"var(--status-error)"},children:z(YX,{name:"x"})}),z("span",{children:Q})]})]}),O("div",{className:"cp-ft",children:[z("span",{className:"cp-spacer"}),z("button",{type:"button",className:"btn btn--ghost",onClick:()=>U(null),disabled:q,children:"Not now"}),O("button",{type:"button",className:"btn btn--primary",onClick:N,disabled:q,children:[z(YX,{name:"download",size:15})," ",q?"Setting up…":"Set up Maude here"]})]})]});return O("div",{className:"cp-body cp-body--list",children:[Q&&O("div",{className:"callout callout--error",children:[z("span",{className:"cp-cl-glyph",style:{color:"var(--status-error)"},children:z(YX,{name:"x"})}),z("span",{children:Q})]}),X===null&&z("div",{className:"cp-field-help",children:"Loading your projects…"}),X&&X.length===0&&!Q&&z("div",{className:"cp-field-help",children:"No projects yet — create one to get started."}),X&&X.length>0&&z("div",{className:"cp-repolist",role:"group","aria-label":"Your projects",children:X.map((D)=>{let _=W===D.full_name;return O("button",{type:"button",className:"cp-repo"+(_?" is-busy":""),disabled:!!W,onClick:()=>F(D),children:[z(YX,{name:D.private?"lock":"globe",size:14}),O("span",{className:"cp-repo-tx",children:[z("span",{className:"cp-repo-name",children:D.name}),z("span",{className:"cp-repo-meta",children:_?Z||"Working…":`${D.owner} · updated ${new Date(D.updated_at).toLocaleDateString()}`})]}),z("span",{className:"cp-repo-go",children:_?z(YX,{name:"spinner",size:15}):z(YX,{name:"download",size:15})})]},D.full_name)})}),O("div",{className:"cp-field-help",children:["Pulls a fresh copy from GitHub to a folder you choose, then opens it. To open a folder you already have, use ",z("b",{children:"File ▸ Open Project"}),"."]})]})}function mZ0({onClose:X}){let[J,Q]=_6.useState(""),[Y,W]=_6.useState(!1),[G,Z]=_6.useState(""),[H,K]=_6.useState(null);async function U(){Z(""),W(!0);let q=await uf(J);if(W(!1),q.ok&&q.json?.ok)K(q.json.username);else Z(q.json?.error||"Couldn’t send the invite. Try again.")}return O(G0,{children:[O("div",{className:"cp-body",children:[O("div",{className:"cp-invite",children:[z("span",{className:"cp-invite-at","aria-hidden":"true",children:"@"}),z("input",{className:"input cp-invite-input",type:"text",value:J,placeholder:"github-username","aria-label":"GitHub username to invite",onChange:(q)=>Q(q.target.value)}),O("button",{type:"button",className:"btn btn--primary cp-invite-btn",onClick:U,disabled:Y||!J.trim(),children:[z(YX,{name:"invite",size:15})," ",Y?"Inviting…":"Invite"]})]}),H&&O("div",{className:"callout callout--success",children:[z("span",{className:"cp-cl-glyph",style:{color:"var(--status-success)"},children:z(YX,{name:"check"})}),O("span",{children:[O("b",{style:{color:"var(--fg-0)"},children:["Invited @",H,"."]})," They’ll get a GitHub email and can open this project once they accept."]})]}),G&&O("div",{className:"callout callout--error",children:[z("span",{className:"cp-cl-glyph",style:{color:"var(--status-error)"},children:z(YX,{name:"x"})}),z("span",{children:G})]})]}),O("div",{className:"cp-ft",children:[z("span",{className:"cp-spacer"}),z("button",{type:"button",className:"btn btn--primary",onClick:X,children:"Done"})]})]})}function _Z({name:X,size:J=16}){let Q={"chevron-up":z("polyline",{points:"3.5 10 8 5.5 12.5 10"}),external:O(G0,{children:[z("path",{d:"M6 3.5H3.2A.7.7 0 0 0 2.5 4.2v8.6a.7.7 0 0 0 .7.7h8.6a.7.7 0 0 0 .7-.7V10"}),z("line",{x1:"8",y1:"8",x2:"13",y2:"3"}),z("polyline",{points:"9.5 3 13 3 13 6.5"})]}),copy:O(G0,{children:[z("rect",{x:"5.5",y:"5.5",width:"7.5",height:"7.5",rx:"1.2"}),z("path",{d:"M3 10.5V3.2A.7.7 0 0 1 3.7 2.5H10"})]}),plus:O(G0,{children:[z("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),z("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),download:O(G0,{children:[z("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),z("polyline",{points:"4.5 7 8 10.5 11.5 7"}),z("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),invite:O(G0,{children:[z("circle",{cx:"6",cy:"5.5",r:"2.5"}),z("path",{d:"M2 13.5a4 4 0 0 1 8 0"}),z("line",{x1:"13",y1:"5",x2:"13",y2:"9"}),z("line",{x1:"11",y1:"7",x2:"15",y2:"7"})]}),signout:O(G0,{children:[z("path",{d:"M6.5 13.5H3.2a.7.7 0 0 1-.7-.7V3.2a.7.7 0 0 1 .7-.7h3.3"}),z("line",{x1:"13",y1:"8",x2:"6.5",y2:"8"}),z("polyline",{points:"10 5 13 8 10 11"})]})}[X];return z("svg",{width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Q})}function fx({size:X=16}){return z("svg",{width:X,height:X,viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:z("path",{d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.6 7.6 0 0 1 2-.27c.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"})})}function uZ0(X){let J=(X?.name||X?.login||"?").trim(),Q=J.split(/[\s_-]+/).filter(Boolean);return(Q.length>=2?Q[0][0]+Q[1][0]:J.slice(0,2)).toUpperCase()}function xx({identity:X,size:J=26}){return z("span",{className:"gi-avatar",style:{width:J,height:J},children:uZ0(X)})}function $A(){let X=W9(),[J,Q]=l6.useState("loading"),[Y,W]=l6.useState(null),[G,Z]=l6.useState(null),[H,K]=l6.useState(!1),[U,q]=l6.useState(""),[B,N]=l6.useState(!1),[F,D]=l6.useState(null),[_,R]=l6.useState(!1),w=l6.useRef(null),M=l6.useRef(null),P=l6.useRef(J);P.current=J,l6.useEffect(()=>{let C=!0;if(!X)return;return(async()=>{try{let y=await vB();if(!C)return;if(y){let f=await BW();for(let h=0;h<2&&C&&!(f.ok&&f.json?.ok);h+=1)await new Promise((d)=>setTimeout(d,800)),f=await BW();if(!C)return;if(f.ok&&f.json?.ok)W({login:f.json.login,name:f.json.name,avatar_url:f.json.avatar_url}),Q("in");else Q("out")}else Q("out")}catch{if(C)Q("out")}})(),()=>{C=!1,w.current?.then?.((y)=>y?.())}},[X]),l6.useEffect(()=>{if(!X)return;let C=hf(async(y)=>{W((h)=>h||{login:y,name:null,avatar_url:null}),Q("in");let f=await BW();if(f.ok&&f.json?.ok)W({login:f.json.login,name:f.json.name,avatar_url:f.json.avatar_url})});return()=>{C?.then?.((y)=>y?.())}},[X]),l6.useEffect(()=>{if(!X)return;let C=gf(()=>{if(P.current!=="loading")D("new")});return()=>{C?.then?.((y)=>y?.())}},[X]),l6.useEffect(()=>{if(!B)return;let C=(y)=>{if(M.current&&!M.current.contains(y.target))N(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[B]);async function I(){q(""),K(!0),Z(null);try{w.current=xB((f)=>Z(f));let C=await jB(),y=await BW();W(y.ok&&y.json?.ok?{login:y.json.login,name:y.json.name,avatar_url:y.json.avatar_url}:{login:C,name:null,avatar_url:null}),Q("in")}catch(C){q(String(C?.message||C||"Sign-in didn’t finish. Please try again."))}finally{K(!1),Z(null),w.current?.then?.((C)=>C?.()),w.current=null}}async function k(){N(!1);try{await ff()}catch{}W(null),Q("out")}function $(){if(!G?.user_code)return;navigator.clipboard?.writeText(G.user_code).then(()=>{R(!0),setTimeout(()=>R(!1),1500)},()=>{})}if(!X)return null;return O("div",{className:"gi-rail",ref:M,children:[J==="loading"&&z("span",{className:"gi-rail-hint",children:"Checking GitHub…"}),J==="out"&&O(G0,{children:[O("button",{type:"button",className:"btn btn--primary btn--sm gi-rail-signin",onClick:I,disabled:H,children:[z(fx,{size:15})," ",H?"Starting…":"Sign in with GitHub"]}),U&&z("span",{className:"gi-rail-err",title:U,children:U})]}),J==="in"&&O(G0,{children:[O("button",{type:"button",className:"gi-rail-account"+(B?" is-open":""),"aria-expanded":B,"aria-haspopup":"menu",onClick:()=>N((C)=>!C),title:`Signed in as @${Y?.login}`,children:[z(xx,{identity:Y}),O("span",{className:"gi-rail-login",children:["@",Y?.login]}),z("span",{className:"gi-rail-caret",children:z(_Z,{name:"chevron-up",size:13})})]}),B&&O("div",{className:"gi-menu",role:"menu","aria-label":"GitHub account",children:[O("div",{className:"gi-menu-hd",children:[z(xx,{identity:Y,size:32}),O("span",{className:"gi-menu-id",children:[z("span",{className:"gi-menu-name",children:Y?.name||Y?.login}),O("span",{className:"gi-menu-login",children:["@",Y?.login," · connected"]})]})]}),O("button",{type:"button",className:"gi-menu-item",role:"menuitem",onClick:()=>{N(!1),D("new")},children:[z(_Z,{name:"plus",size:15})," New project"]}),O("button",{type:"button",className:"gi-menu-item",role:"menuitem",onClick:()=>{N(!1),D("get")},children:[z(_Z,{name:"download",size:15})," Pull a local copy"]}),O("button",{type:"button",className:"gi-menu-item",role:"menuitem",onClick:()=>{N(!1),D("share")},children:[z(_Z,{name:"invite",size:15})," Share this project"]}),z("div",{className:"gi-menu-sep"}),O("button",{type:"button",className:"gi-menu-item gi-menu-item--danger",role:"menuitem",onClick:k,children:[z(_Z,{name:"signout",size:15})," Sign out"]})]})]}),G&&O("div",{className:"gi-modal",role:"dialog","aria-modal":"true","aria-label":"Sign in with GitHub",onKeyDown:(C)=>{if(C.key==="Escape")Z(null)},children:[z("div",{className:"gi-scrim","aria-hidden":"true",onClick:()=>Z(null)}),O("div",{className:"gi-dialog gi-dialog--code",children:[O("div",{className:"gi-dc-head",children:[z("span",{className:"gi-dc-marks",children:z(fx,{size:26})}),z("h2",{children:"Sign in with GitHub"}),z("p",{children:"Maude opened GitHub in your browser. Enter this code to connect your account."})]}),O("ol",{className:"gi-dc-steps",children:[O("li",{children:[z("span",{className:"gi-dc-step-n",children:"1"}),O("span",{className:"gi-dc-step-tx",children:["Go to ",z("span",{className:"gi-dc-url",children:(G.verification_uri||"github.com/login/device").replace(/^https?:\/\//,"")}),O("button",{type:"button",className:"btn btn--ghost btn--sm gi-dc-open",onClick:()=>fB().catch(()=>{}),children:[z(_Z,{name:"external",size:14})," Open it again"]})]})]}),O("li",{children:[z("span",{className:"gi-dc-step-n",children:"2"}),z("span",{className:"gi-dc-step-tx",children:"Enter this code to connect Maude"})]})]}),O("div",{className:"gi-code",children:[z("span",{className:"gi-code-val",children:G.user_code}),O("button",{type:"button",className:"btn btn--ghost gi-code-copy",onClick:$,"aria-label":"Copy the code",children:[z(_Z,{name:"copy",size:15})," ",_?"Copied":"Copy"]})]}),O("div",{className:"gi-dc-status","aria-live":"polite",children:[z("span",{className:"gi-pulse","aria-hidden":"true"}),z("span",{children:"Waiting for you to authorize in your browser…"})]}),O("div",{className:"gi-dc-foot",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:()=>Z(null),children:"Cancel"}),z("span",{className:"gi-dc-foot-note",children:"Nothing is stored until you authorize."})]})]})]}),F&&z(CA,{view:F,identity:Y,signedIn:J==="in",onClose:()=>D(null)})]})}var p9=x8(r8(),1);var hx=x8(r8(),1);function QV({open:X,onClose:J}){if(hx.useEffect(()=>{if(!X)return;let Q=(Y)=>Y.key==="Escape"&&J();return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[X,J]),!X)return null;return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Q)=>{if(Q.target===Q.currentTarget)J()},children:O("div",{className:"help-modal help-modal--wide",role:"dialog","aria-modal":"true","aria-labelledby":"intro-video-title",children:[O("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"intro-video-title",children:"Watch the intro"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:J,children:"×"})]}),z("div",{className:"help-modal-body intro-video-body",children:z("video",{className:"intro-video-el",src:"/_media/intro.mp4",controls:!0,autoPlay:!0,playsInline:!0})})]})})}function s9({name:X,size:J=16,className:Q}){let Y={check:z("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),"arrow-right":O(G0,{children:[z("line",{x1:"2.5",y1:"8",x2:"13",y2:"8"}),z("polyline",{points:"9 4 13 8 9 12"})]}),"chevron-right":z("polyline",{points:"6 3.5 10.5 8 6 12.5"}),"chevron-down":z("polyline",{points:"3.5 6 8 10.5 12.5 6"}),folder:z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),"folder-open":O(G0,{children:[z("path",{d:"M2 4.5h4l1.3 1.5H14"}),z("path",{d:"M2 6h12.5l-1.4 7H3.4z"})]}),lock:O(G0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1.2"}),z("path",{d:"M5.5 7V5.2a2.5 2.5 0 0 1 5 0V7"})]}),globe:O(G0,{children:[z("circle",{cx:"8",cy:"8",r:"5.5"}),z("path",{d:"M2.5 8h11M8 2.5c1.7 1.5 2.6 3.5 2.6 5.5S9.7 12.5 8 13.5C6.3 12 5.4 10 5.4 8S6.3 3.5 8 2.5z"})]}),plus:O(G0,{children:[z("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),z("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),download:O(G0,{children:[z("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),z("polyline",{points:"4.5 7 8 10.5 11.5 7"}),z("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),link:O(G0,{children:[z("path",{d:"M6.5 9.5 9.5 6.5"}),z("path",{d:"M7 4.5 8.4 3.1a2.6 2.6 0 0 1 3.7 3.7L10.7 8.2"}),z("path",{d:"M9 11.5 7.6 12.9a2.6 2.6 0 0 1-3.7-3.7L5.3 7.8"})]}),key:O(G0,{children:[z("circle",{cx:"5",cy:"5",r:"2.6"}),z("path",{d:"M6.9 6.9 13 13M11 11l1.4-1.4M9.2 9.2l1.6-1.6"})]}),server:O(G0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"4",rx:"1"}),z("rect",{x:"2.5",y:"9",width:"11",height:"4",rx:"1"}),z("circle",{cx:"5",cy:"5",r:"0.5",fill:"currentColor"}),z("circle",{cx:"5",cy:"11",r:"0.5",fill:"currentColor"})]}),x:O(G0,{children:[z("line",{x1:"3.5",y1:"3.5",x2:"12.5",y2:"12.5"}),z("line",{x1:"12.5",y1:"3.5",x2:"3.5",y2:"12.5"})]}),copy:O(G0,{children:[z("rect",{x:"5.5",y:"5.5",width:"7.5",height:"7.5",rx:"1.2"}),z("path",{d:"M3 10.5V3.2A.7.7 0 0 1 3.7 2.5H10"})]}),external:O(G0,{children:[z("path",{d:"M6 3.5H3.2A.7.7 0 0 0 2.5 4.2v8.6a.7.7 0 0 0 .7.7h8.6a.7.7 0 0 0 .7-.7V10"}),z("line",{x1:"8",y1:"8",x2:"13",y2:"3"}),z("polyline",{points:"9.5 3 13 3 13 6.5"})]}),back:z("polyline",{points:"10 3.5 5.5 8 10 12.5"}),spinner:z("path",{d:"M8 2.2a5.8 5.8 0 1 0 5.8 5.8"}),play:z("polygon",{points:"5 3.2 12.8 8 5 12.8",fill:"currentColor",stroke:"none"})}[X];return z("svg",{className:Q,width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Y})}function SA({size:X=18}){return z("svg",{width:X,height:X,viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:z("path",{d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.6 7.6 0 0 1 2-.27c.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"})})}function lZ0({size:X=30}){return z("span",{className:"ob-mark",style:{width:X,height:X},role:"img","aria-label":"maude",children:z("svg",{viewBox:"0 0 32 32",fill:"none",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})})}function pZ0({signedInAs:X}){return O("aside",{className:"ob-rail",children:[O("div",{className:"ob-rail-brand",children:[z(lZ0,{size:30}),z("span",{className:"ob-rail-wordmark",children:"maude"})]}),O("div",{className:"ob-rail-lede",children:[O("p",{className:"ob-rail-h",children:["Design together.",z("br",{}),"No setup, no terminal."]}),z("p",{children:"Open Maude, and you're in a real project in under two minutes — sharing canvases with your team as you go."})]}),X?O("div",{className:"ob-rail-signed",children:[z("span",{className:"ob-rail-signed-dot","aria-hidden":"true"}),O("span",{children:["Signed in as ",O("b",{children:["@",X]})]})]}):O("ul",{className:"ob-rail-reassure",children:[O("li",{children:[z("span",{className:"ob-rail-tick","aria-hidden":"true",children:z(s9,{name:"check",size:12})}),"Sign in once — Maude remembers you"]}),O("li",{children:[z("span",{className:"ob-rail-tick","aria-hidden":"true",children:z(s9,{name:"check",size:12})}),"Your work saves on its own"]}),O("li",{children:[z("span",{className:"ob-rail-tick","aria-hidden":"true",children:z(s9,{name:"check",size:12})}),"Invite anyone by their name"]})]}),z("div",{className:"ob-rail-foot",children:"You can change any of this later."})]})}function dZ0(){let[X,J]=p9.useState(!1);return p9.useEffect(()=>{let Q=!0;return sf().then((Y)=>{if(Q)J(!!Y)}).catch(()=>{}),()=>{Q=!1}},[]),O("label",{className:"ob-crash-optin",children:[z("input",{type:"checkbox",checked:X,onChange:(Q)=>{let Y=Q.target.checked;J(Y),tf(Y).catch(()=>J(!Y))}}),z("span",{children:"Send crash reports to help improve Maude. Optional — a crash writes a local log (stack trace + OS + version, no file contents) you can attach to an issue."})]})}function cZ0(){let{report:X,loading:J,refresh:Q}=aU();if(!X)return null;let Y=X.ready;return O("details",{className:"ob-readiness",children:[O("summary",{className:"ob-readiness-sum",children:[z("span",{className:`ob-readiness-dot ob-readiness-dot--${Y?"ok":"warn"}`,"aria-hidden":"true"}),z("span",{className:"ob-readiness-lede",children:Y?"AI editing is ready":"AI editing needs a couple of things"}),z("span",{className:"ob-readiness-hint",children:Y?"optional — view details":"optional · the rest of Maude works without it"})]}),O("div",{className:"ob-readiness-body",children:[z("p",{className:"ob-readiness-note",children:"Everything else — the canvas browser, version history, sharing — works right now. AI editing additionally pairs with a Claude Code you already have installed and runs on your own Pro/Max subscription."}),z(rz,{report:X,loading:J,refresh:Q})]})]})}function iZ0({onGithub:X,onLocal:J,onHub:Q,signing:Y,signedIn:W,identity:G}){let[Z,H]=p9.useState(!1);return O("main",{className:"ob-main",children:[O("header",{className:"ob-head",children:[z("span",{className:"ob-eyebrow",children:"Welcome"}),z("h1",{children:"How would you like to start?"}),z("p",{children:W?`You're signed in as @${G?.login||"GitHub"}. Open a project, or start a new one.`:"Most people sign in with GitHub — it's the simplest way to work with a team."}),O("button",{type:"button","data-testid":"onboarding-watch-intro",className:"ob-watch-intro",onClick:()=>H(!0),children:[z(s9,{name:"play",size:13})," Watch the intro"]})]}),z(QV,{open:Z,onClose:()=>H(!1)}),O("div",{className:"ob-doors",children:[O("button",{type:"button","data-testid":"ob-door-github",className:"ob-door ob-door--primary","aria-label":"Continue with GitHub — recommended",onClick:X,disabled:Y,children:[z("span",{className:"ob-door-icon ob-door-icon--gh",children:z(SA,{size:26})}),O("span",{className:"ob-door-tx",children:[O("span",{className:"ob-door-title",children:["Continue with GitHub",z("span",{className:"ob-door-tag",children:"Recommended"})]}),z("span",{className:"ob-door-sub",children:"Start a shared project, or open one a teammate shared with you."})]}),z("span",{className:"ob-door-cta",children:O("span",{className:"btn btn--primary ob-door-btn",children:[z(SA,{size:15})," ",Y?"Starting…":W?"Continue":"Sign in with GitHub"]})})]}),O("button",{type:"button","data-testid":"ob-door-local",className:"ob-door","aria-label":"Open a folder on this computer",onClick:J,children:[z("span",{className:"ob-door-icon",children:z(s9,{name:"folder-open",size:22})}),O("span",{className:"ob-door-tx",children:[z("span",{className:"ob-door-title",children:"Open a folder on this computer"}),z("span",{className:"ob-door-sub",children:"Already have a project folder? Open it and keep designing."})]}),z("span",{className:"ob-door-go","aria-hidden":"true",children:z(s9,{name:"chevron-right",size:16})})]}),O("button",{type:"button","data-testid":"ob-door-hub",className:"ob-door ob-door--advanced","aria-label":"Connect to a team hub — advanced",onClick:Q,children:[z("span",{className:"ob-door-icon ob-door-icon--quiet",children:z(s9,{name:"server",size:18})}),O("span",{className:"ob-door-tx",children:[O("span",{className:"ob-door-title",children:["Connect to a team hub ",z("span",{className:"ob-door-adv",children:"Advanced"})]}),z("span",{className:"ob-door-sub",children:"Your team runs its own Maude hub? Paste the link they gave you."})]}),z("span",{className:"ob-door-go","aria-hidden":"true",children:z(s9,{name:"chevron-right",size:15})})]})]}),z("p",{className:"ob-foot-note",children:"Browse, version, and collaborate — all in the app, no terminal."}),z(cZ0,{}),z(dZ0,{})]})}function aB({onBack:X}){return O("button",{type:"button","data-testid":"ob-back",className:"ob-back",onClick:X,children:[z(s9,{name:"back",size:14})," Back"]})}function oZ0({identity:X,onBack:J}){let[Q,Y]=p9.useState(null),[W,G]=p9.useState(""),[Z,H]=p9.useState(""),[K,U]=p9.useState(!1);p9.useEffect(()=>{(async()=>{let B=await hB();if(B.ok&&B.json?.ok)Y(B.json.repos||[]);else G(B.json?.error||"Couldn't load your projects."),Y([])})()},[]);async function q(B){G(""),H(B.full_name);try{let N=await x4();if(!N){H("");return}let F=await gB({cloneUrl:B.clone_url,parentDir:N,name:B.name});if(!(F.ok&&F.json?.ok)){G(F.json?.error||"Couldn't open that project."),H("");return}if(F.json.hasDesign===!1){let D=await rU(F.json.path);if(!(D.ok&&D.json?.ok)){G(D.json?.error||"Couldn't set it up."),H("");return}}await q5(F.json.path)}catch(N){G(String(N?.message||N||"Something went wrong opening the project.")),H("")}}if(K)return z(nZ0,{identity:X,onBack:()=>U(!1)});return O("main",{className:"ob-main",children:[z(aB,{onBack:J}),O("header",{className:"ob-head",children:[z("span",{className:"ob-eyebrow",children:"You're signed in"}),z("h1",{children:"Open a project, or start a new one"}),z("p",{children:"Pick up a shared project below, or create a fresh one — it's private until you invite someone."})]}),O("button",{type:"button","data-testid":"ob-github-create",className:"ob-create","aria-label":"Start a new project",onClick:()=>U(!0),children:[z("span",{className:"ob-create-icon",children:z(s9,{name:"plus",size:20})}),O("span",{className:"ob-create-tx",children:[z("span",{className:"ob-create-title",children:"Start a new project"}),z("span",{className:"ob-create-sub",children:"A blank, private project — you choose where it lives."})]}),O("span",{className:"btn btn--primary ob-create-btn",children:[z(s9,{name:"arrow-right",size:15})," Create"]})]}),z("div",{className:"ob-section-label",children:"Your projects"}),W&&O("div",{className:"callout callout--error ob-callout",children:[z("span",{className:"ob-callout-glyph",style:{color:"var(--status-error)"},children:z(s9,{name:"x"})}),z("span",{children:W})]}),Q===null&&z("div",{className:"ob-foot-note",children:"Loading your projects…"}),Q&&Q.length===0&&!W&&z("div",{className:"ob-foot-note",children:"No projects yet — create one to get started."}),Q&&Q.length>0&&z("div",{className:"ob-repolist",role:"group","aria-label":"Projects you can open",children:Q.map((B)=>{let N=Z===B.full_name;return O("button",{type:"button",className:"ob-repo",disabled:!!Z,onClick:()=>q(B),children:[z("span",{className:"ob-repo-icon",children:z(s9,{name:B.private?"lock":"globe",size:15})}),O("span",{className:"ob-repo-tx",children:[z("span",{className:"ob-repo-name",children:B.name}),z("span",{className:"ob-repo-meta",children:N?"Opening…":`${B.owner} · updated ${new Date(B.updated_at).toLocaleDateString()}`})]}),z("span",{className:"ob-repo-go",children:N?z(s9,{name:"spinner",size:16,className:"ob-spin"}):O(G0,{children:[z(s9,{name:"download",size:16})," Open"]})})]},B.full_name)})}),z("p",{className:"ob-foot-note",children:"Opening a project saves a copy on this computer and keeps it in sync."})]})}function nZ0({identity:X,onBack:J}){let[Q,Y]=p9.useState(""),[W,G]=p9.useState(!0),[Z,H]=p9.useState(!1),[K,U]=p9.useState(""),[q,B]=p9.useState(""),N=Q.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),F=X?.login||"you";async function D(){B(""),H(!0);try{U("Choose where to save it…");let _=await x4();if(!_){H(!1),U("");return}U("Creating your project on GitHub…");let R=await mB({name:Q,private:W,parentDir:_});if(!(R.ok&&R.json?.ok)){B(R.json?.error||"Couldn't create the project."),H(!1),U("");return}U("Opening it in Maude…"),await q5(R.json.path)}catch(_){B(String(_?.message||_||"Something went wrong creating the project.")),H(!1),U("")}}return O("main",{className:"ob-main",children:[z(aB,{onBack:J}),O("header",{className:"ob-head",children:[z("span",{className:"ob-eyebrow",children:"New project"}),z("h1",{children:"Start a new project"}),z("p",{children:"A private project, set up for you. You can invite people whenever you're ready."})]}),O("div",{className:"ob-form",children:[O("label",{className:"ob-field",children:[z("span",{className:"ob-field-label",children:"Project name"}),z("input",{className:"input ob-input",type:"text",value:Q,placeholder:"Acme Rebrand","aria-label":"Project name",onChange:(_)=>Y(_.target.value)}),N&&O("span",{className:"ob-foot-note",children:["Creates ",O("b",{children:["github.com/",F,"/",N]})]})]}),O("div",{className:"ob-field",children:[z("span",{className:"ob-field-label",children:"Who can see it"}),O("div",{className:"seg",role:"group","aria-label":"Project visibility",children:[O("button",{type:"button","aria-pressed":W,onClick:()=>G(!0),children:[z(s9,{name:"lock",size:14})," Private"]}),O("button",{type:"button","aria-pressed":!W,onClick:()=>G(!1),children:[z(s9,{name:"globe",size:14})," Public"]})]})]}),q&&O("div",{className:"callout callout--error ob-callout",children:[z("span",{className:"ob-callout-glyph",style:{color:"var(--status-error)"},children:z(s9,{name:"x"})}),z("span",{children:q})]}),z("div",{className:"ob-form-actions",children:O("button",{type:"button",className:"btn btn--primary",onClick:D,disabled:Z||!N,children:[z(s9,{name:"plus",size:15})," ",Z?K||"Creating…":"Create project"]})})]})]})}function rZ0({onBack:X}){let[J,Q]=p9.useState(!1),[Y,W]=p9.useState(""),[G,Z]=p9.useState(null);async function H(){W(""),Q(!0);try{let U=await x4();if(!U){Q(!1);return}try{await q5(U)}catch(q){Z(U),Q(!1)}}catch(U){W(String(U?.message||U||"Couldn't open that folder.")),Q(!1)}}async function K(){W(""),Q(!0);try{let U=await rU(G);if(!(U.ok&&U.json?.ok)){W(U.json?.error||"Couldn't set it up."),Q(!1);return}await q5(G)}catch(U){W(String(U?.message||U||"Couldn't set it up.")),Q(!1)}}return O("main",{className:"ob-main",children:[z(aB,{onBack:X}),O("header",{className:"ob-head",children:[z("span",{className:"ob-eyebrow",children:"From this computer"}),z("h1",{children:"Open a project folder"}),z("p",{children:"Choose a folder on your computer. We'll check it's a Maude project before opening."})]}),G?O(G0,{children:[O("div",{className:"callout callout--info ob-callout",children:[z("span",{className:"ob-callout-glyph",style:{color:"var(--status-info)"},children:z(s9,{name:"folder-open",size:15})}),z("span",{children:"That folder isn't a Maude project yet. Set up Maude in it to start designing (you can build a design system after)."})]}),Y&&O("div",{className:"callout callout--error ob-callout",children:[z("span",{className:"ob-callout-glyph",style:{color:"var(--status-error)"},children:z(s9,{name:"x"})}),z("span",{children:Y})]}),O("div",{className:"ob-form-actions",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:()=>Z(null),disabled:J,children:"Pick a different folder"}),O("button",{type:"button","data-testid":"ob-local-setup",className:"btn btn--primary",onClick:K,disabled:J,children:[z(s9,{name:"folder",size:15})," ",J?"Setting up…":"Set up Maude here"]})]})]}):O(G0,{children:[O("button",{type:"button","data-testid":"ob-local-choose",className:"ob-drop",onClick:H,disabled:J,"aria-label":"Choose a project folder",children:[z("span",{className:"ob-drop-glyph",children:z(s9,{name:"folder-open",size:34})}),z("span",{className:"ob-drop-title",children:J?"Opening…":"Choose a project folder"}),z("span",{className:"ob-drop-or",children:"click to browse"})]}),Y&&O("div",{className:"callout callout--error ob-callout",children:[z("span",{className:"ob-callout-glyph",style:{color:"var(--status-error)"},children:z(s9,{name:"x"})}),z("span",{children:Y})]}),O("p",{className:"ob-foot-note",children:["To open a project a teammate shared, use ",z("b",{children:"Continue with GitHub"})," instead."]})]})]})}function aZ0({onBack:X}){let[J,Q]=p9.useState(""),[Y,W]=p9.useState(""),[G,Z]=p9.useState(!1),[H,K]=p9.useState(""),[U,q]=p9.useState(null);async function B(){K(""),Z(!0);try{let N=await pf({url:J.trim(),token:Y.trim()});if(Z(!1),N.ok&&N.json?.ok)q(N.json);else K(N.json?.error||"Couldn't connect to the hub.")}catch(N){Z(!1),K(String(N?.message||N||"Couldn't connect to the hub."))}}return O("main",{className:"ob-main",children:[z(aB,{onBack:X}),O("header",{className:"ob-head",children:[z("span",{className:"ob-eyebrow",children:"Advanced"}),z("h1",{children:"Connect to a team hub"}),z("p",{children:"For teams running their own Maude hub. Paste the address and the access token your team gave you."})]}),O("div",{className:"ob-form",children:[O("label",{className:"ob-field",children:[z("span",{className:"ob-field-label",children:"Hub address"}),O("span",{className:"ob-field-wrap",children:[z(s9,{name:"server",size:14,className:"ob-field-pre"}),z("input",{className:"input ob-input",type:"text",value:J,placeholder:"https://hub.yourteam.dev","aria-label":"Hub address",onChange:(N)=>Q(N.target.value)})]})]}),O("label",{className:"ob-field",children:[z("span",{className:"ob-field-label",children:"Access token"}),O("span",{className:"ob-field-wrap",children:[z(s9,{name:"key",size:14,className:"ob-field-pre"}),z("input",{className:"input ob-input",type:"text",value:Y,placeholder:"paste the access token your team gave you","aria-label":"Access token",onChange:(N)=>W(N.target.value)})]})]}),H&&O("div",{className:"callout callout--error ob-callout",children:[z("span",{className:"ob-callout-glyph",style:{color:"var(--status-error)"},children:z(s9,{name:"x"})}),z("span",{children:H})]}),U?O("div",{className:"callout callout--success ob-callout",children:[z("span",{className:"ob-callout-glyph",style:{color:"var(--status-success)"},children:z(s9,{name:"check",size:15})}),O("span",{children:[O("b",{style:{color:"var(--fg-0)"},children:["Connected to ",U.url.replace(/^https?:\/\//,""),"."]})," ",U.healthy?"Your hub is reachable.":"Saved — we couldn’t reach it just now, but it’ll sync when it’s up."," Now open your team’s project with ",z("b",{children:"Continue with GitHub"})," or ",z("b",{children:"Open a folder"})," — it’ll sync to this hub automatically."]})]}):z("div",{className:"ob-form-actions",children:O("button",{type:"button",className:"btn btn--primary",onClick:B,disabled:G||!J.trim()||!Y.trim(),children:[z(s9,{name:"link",size:15})," ",G?"Connecting…":"Connect"]})})]}),O("p",{className:"ob-foot-note",children:["Most people use ",z("b",{children:"Continue with GitHub"})," — you only need a hub if your team runs one."]})]})}function sZ0({device:X,onClose:J}){let[Q,Y]=p9.useState(!1);function W(){if(!X?.user_code)return;navigator.clipboard?.writeText(X.user_code).then(()=>{Y(!0),setTimeout(()=>Y(!1),1500)},()=>{})}return O("div",{className:"gi-modal",role:"dialog","aria-modal":"true","aria-label":"Sign in with GitHub",onKeyDown:(G)=>{if(G.key==="Escape")J()},children:[z("div",{className:"gi-scrim","aria-hidden":"true",onClick:J}),O("div",{className:"gi-dialog gi-dialog--code","data-testid":"ob-device-modal",children:[O("div",{className:"gi-dc-head",children:[z("span",{className:"gi-dc-marks",children:z(SA,{size:26})}),z("h2",{children:"Sign in with GitHub"}),z("p",{children:"Maude opened GitHub in your browser. Enter the code there to connect — you'll grant Maude access to create and manage your project repos."})]}),O("ol",{className:"gi-dc-steps",children:[O("li",{children:[z("span",{className:"gi-dc-step-n",children:"1"}),O("span",{className:"gi-dc-step-tx",children:["Go to ",z("span",{className:"gi-dc-url",children:(X.verification_uri||"github.com/login/device").replace(/^https?:\/\//,"")}),O("button",{type:"button",className:"btn btn--ghost btn--sm gi-dc-open",onClick:()=>fB().catch(()=>{}),children:[z(s9,{name:"external",size:14})," Open it again"]})]})]}),O("li",{children:[z("span",{className:"gi-dc-step-n",children:"2"}),z("span",{className:"gi-dc-step-tx",children:"Enter this code to connect Maude"})]})]}),O("div",{className:"gi-code",children:[z("span",{className:"gi-code-val","data-testid":"ob-device-code",children:X.user_code}),O("button",{type:"button",className:"btn btn--ghost gi-code-copy",onClick:W,"aria-label":"Copy the code",children:[z(s9,{name:"copy",size:15})," ",Q?"Copied":"Copy"]})]}),O("div",{className:"gi-dc-status","aria-live":"polite",children:[z("span",{className:"gi-pulse","aria-hidden":"true"}),z("span",{children:"Waiting for you to authorize in your browser…"})]}),O("div",{className:"gi-dc-foot",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:J,children:"Cancel"}),z("span",{className:"gi-dc-foot-note",children:"Nothing is stored until you authorize."})]})]})]})}function bA(){let X=W9(),[J,Q]=p9.useState("welcome"),[Y,W]=p9.useState(null),[G,Z]=p9.useState(!1),[H,K]=p9.useState(!1),[U,q]=p9.useState(null),[B,N]=p9.useState(""),F=p9.useRef(null),D=p9.useRef(!1);p9.useEffect(()=>{let R=!0;if(!X)return;return(async()=>{try{if(await vB()){let w=await BW();if(R&&w.ok&&w.json?.ok)W({login:w.json.login,name:w.json.name}),Z(!0)}}catch{}})(),()=>{R=!1,F.current?.then?.((w)=>w?.())}},[X]);async function _(){if(G){Q("github");return}D.current=!1,N(""),K(!0),q(null);try{F.current=xB((M)=>q(M));let R=await jB();if(D.current)return;let w=await BW();W(w.ok&&w.json?.ok?{login:w.json.login,name:w.json.name}:{login:R}),Z(!0),Q("github")}catch(R){if(!D.current)N(String(R?.message||R||"Sign-in didn't finish. Please try again."))}finally{K(!1),q(null),F.current?.then?.((R)=>R?.()),F.current=null}}if(!X)return null;return O("div",{className:"ob-overlay","data-testid":"onboarding-wizard",role:"dialog","aria-modal":"true","aria-label":"Welcome to Maude",children:[O("div",{className:"ob-shell",children:[z(pZ0,{signedInAs:G?Y?.login:null}),J==="welcome"&&z(iZ0,{signing:H,signedIn:G,identity:Y,onGithub:_,onLocal:()=>Q("local"),onHub:()=>Q("hub")}),J==="github"&&z(oZ0,{identity:Y,onBack:()=>Q("welcome")}),J==="local"&&z(rZ0,{onBack:()=>Q("welcome")}),J==="hub"&&z(aZ0,{onBack:()=>Q("welcome")})]}),B&&J==="welcome"&&O("div",{className:"ob-toast callout callout--error",role:"alert",children:[z("span",{className:"ob-callout-glyph",style:{color:"var(--status-error)"},children:z(s9,{name:"x"})}),z("span",{children:B})]}),U&&z(sZ0,{device:U,onClose:()=>{D.current=!0,K(!1),q(null)}})]})}var JK=x8(r8(),1);async function tZ0(X){return new Promise((J,Q)=>{let Y=new FileReader;Y.onload=()=>J(Y.result),Y.onerror=()=>Q(Y.error||Error("file read failed")),Y.readAsArrayBuffer(X)})}async function eZ0(X){let J=await fetch("/_api/import-asset",{method:"POST",headers:{"X-Import-Kind":"svg"},body:X}),Q=await J.json().catch(()=>({}));if(!J.ok||!Q.ok)throw Error(Q.error||`import failed (HTTP ${J.status})`);let Y=await fetch("/_api/import-brand",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({assetPath:Q.path})}),W=await Y.json().catch(()=>({}));if(!Y.ok||!W.ok)throw Error(W.error||`extraction failed (HTTP ${Y.status})`);return W}function XH0({palette:X}){if(!X?.length)return z("p",{className:"brand-up-empty",children:"No color values could be extracted from this file."});return z("ul",{className:"brand-up-swatches","data-testid":"brand-up-palette",children:X.map((J)=>O("li",{className:"brand-up-swatch",title:J,children:[z("span",{className:"brand-up-swatch-chip",style:{background:J},"aria-hidden":"true"}),z("span",{className:"brand-up-swatch-value",children:J})]},J))})}function JH0({fonts:X}){if(!X?.length)return z("p",{className:"brand-up-empty",children:"No recognized font names found — this is normal (font names inside the logo's own text are stripped for safety before extraction; the design system's typography will still be researched from your brief)."});return z("ul",{className:"brand-up-fonts","data-testid":"brand-up-fonts",children:X.map((J)=>z("li",{className:"brand-up-font-chip",children:J},J))})}function yA({open:X,onClose:J}){let[Q,Y]=JK.useState(!1),[W,G]=JK.useState(null),[Z,H]=JK.useState(null),K=JK.useRef(null),U=async(F)=>{Y(!0),G(null),H(null);try{let D=await eZ0(F);H(D)}catch(D){G(D?.message||"upload failed")}finally{Y(!1)}},q=async()=>{Y(!0),G(null);try{let F=await OZ();if(!F?.bytes){Y(!1);return}await U(new Blob([new Uint8Array(F.bytes)]))}catch(F){G(F?.message||"open failed"),Y(!1)}},B=()=>K.current?.click(),N=async(F)=>{let D=F.target.files?.[0];if(F.target.value="",!D)return;let _=await tZ0(D);await U(new Blob([_]))};if(!X)return null;return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(F)=>{if(F.target===F.currentTarget)J()},children:O("div",{className:"help-modal brand-up-modal",role:"dialog","aria-modal":"true","aria-labelledby":"brand-up-modal-title",children:[O("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"brand-up-modal-title",children:"Bring my existing brand"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:J,children:"×"})]}),O("div",{className:"help-modal-body",children:[z("p",{className:"brand-up-note",children:"Upload your logo (SVG) and Maude will pull out its color palette to seed your design system — nothing here is final, you'll confirm every choice during setup."}),!Z&&O("div",{className:"brand-up-pick",children:[z("button",{type:"button",className:"btn btn--primary btn--sm","data-testid":"brand-up-pick-file",disabled:Q,onClick:W9()?q:B,children:Q?"Working…":"Choose logo file…"}),z("input",{ref:K,type:"file",accept:"image/svg+xml,.svg",style:{display:"none"},onChange:N})]}),W&&z("p",{className:"brand-up-error","data-testid":"brand-up-error",role:"alert",children:W}),Z&&O("div",{className:"brand-up-result","data-testid":"brand-up-result",children:[z("img",{className:"brand-up-preview",src:`/${Z.logoRasterRef||Z.logoRef}`,alt:"Uploaded logo preview"}),z("h4",{className:"brand-up-sechd",children:"Palette"}),z(XH0,{palette:Z.palette}),z("h4",{className:"brand-up-sechd",children:"Fonts"}),z(JH0,{fonts:Z.fonts}),O("p",{className:"brand-up-nextstep",children:["Next: run ",O("code",{children:["/design:setup-ds --from-brand ",Z.logoRef]})," in the AI chat (or your terminal) to build a design system seeded from this upload."]}),O("div",{className:"brand-up-actions",children:[z("button",{type:"button",className:"btn btn--primary btn--sm","data-testid":"brand-up-copy-command",onClick:()=>navigator.clipboard?.writeText(`/design:setup-ds --from-brand ${Z.logoRef}`),children:"Copy command"}),z("button",{type:"button",className:"btn btn--ghost btn--sm","data-testid":"brand-up-again",onClick:()=>{H(null),G(null)},children:"Upload a different file"})]})]})]})]})})}var QJ=x8(r8(),1);var QH0={imported:"imported","hidden-chars-dropped":"invisible characters removed","hidden-node-skipped":"hidden — not imported","text-normalized":"made readable (size or contrast)","geometry-clamped":"moved back into view","truncated-text":"text shortened to fit","truncated-attr":"name shortened","unmappable-type":"no Maude equivalent","unmappable-shape":"no Maude equivalent for this shape","bind-degraded-to-bbox":"arrow attached to the group outline","bind-dropped-self-connector":"connector pointed at itself — skipped","asset-pending":"image queued","asset-skipped":"image could not be fetched","asset-cap-reached":"image limit reached","jsx-cap-reached":"too large — trimmed","value-rejected":"a style value was not usable"},YH0=[{id:"frames",label:"Design frames",hint:"become editable canvases"},{id:"board",label:"FigJam board",hint:"becomes your whiteboard"},{id:"tokens",label:"Styles",hint:"become design tokens"}];function WH0({result:X}){if(!X)return null;let J=new Map;for(let W of X.dispositions??[]){let G=J.get(W.disposition)??[];G.push(W),J.set(W.disposition,G)}let Q=[...J.entries()].filter(([W])=>W!=="imported"),Y=J.get("imported")?.length??0;return O("div",{className:"st-figma-summary","data-testid":"figma-import-summary",children:[O("div",{className:"st-figma-summary-hd",children:[Y," imported",X.mode==="frames"&&X.frameCount?` · ${X.frameCount} frame(s)`:"",X.mode==="board"&&X.strokeCount?` · ${X.strokeCount} strokes`:"",X.mode==="tokens"&&X.count?` · ${X.count} tokens`:""]}),X.assets&&X.assets.pending>0&&O("div",{className:"st-figma-summary-row",children:["images & marks: ",X.assets.resolved," of ",X.assets.pending," fetched"]}),Q.length===0?z("div",{className:"st-figma-summary-row",children:"Everything came through cleanly."}):z("ul",{className:"st-figma-summary-list",children:Q.map(([W,G])=>O("li",{children:[z("span",{className:"st-figma-summary-kind",children:QH0[W]??W})," ",z("span",{className:"st-figma-summary-count",children:G.length}),O("span",{className:"st-figma-summary-ids",children:[G.slice(0,8).map((Z)=>Z.nodeId).join(", "),G.length>8?` +${G.length-8}`:""]})]},W))}),X.mode==="tokens"&&X.path&&O("div",{className:"st-figma-summary-row",children:["Saved. Turn it into a design system with"," ",z("code",{children:"maude design import-tokens"}),"."]})]})}function jA({onClose:X,onImported:J}){let[Q,Y]=QJ.useState(null),[W,G]=QJ.useState(""),[Z,H]=QJ.useState("frames"),[K,U]=QJ.useState(!1),[q,B]=QJ.useState(null),[N,F]=QJ.useState(null),D=QJ.useCallback(()=>{fetch("/_api/figma/status").then((M)=>M.ok?M.json():Promise.reject(Error("status"))).then((M)=>Y(Boolean(M?.configured))).catch(()=>Y(!1))},[]);QJ.useEffect(()=>{D()},[D]),QJ.useEffect(()=>{function M(P){if(P.key==="Escape"&&!K)P.preventDefault(),X?.()}return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[X,K]);let[_,R]=QJ.useState(!1);QJ.useEffect(()=>{if(_)return;if(/figma\.com\/board\//.test(W))H("board");else if(/figma\.com\/(design|file|proto)\//.test(W))H("frames")},[W,_]);async function w(M){if(K||!W.trim())return;U(!0),B(null),F(null);try{let P=await fetch("/_api/figma/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:W.trim(),mode:Z,dryRun:M})}),I=await P.json().catch(()=>({}));if(!P.ok||I.ok===!1){B(I.error||"Import failed.");return}if(F({...I,dryRun:M}),!M)J?.(I)}catch{B("Could not reach the local server.")}finally{U(!1)}}return z("div",{className:"st-scrim",role:"presentation",children:O("div",{className:"st-dialog st-figma-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"figma-import-title","data-testid":"figma-import-panel",children:[O("div",{className:"st-dialog-hd",children:[z("h2",{id:"figma-import-title",children:"Import from Figma"}),z("button",{type:"button",className:"st-btn",onClick:X,"aria-label":"Close",children:"✕"})]}),Q===!1&&z("div",{className:"st-figma-notice","data-testid":"figma-not-connected",children:"Add a Figma access token in Settings → Figma first."}),z("label",{className:"st-figma-label",htmlFor:"figma-url",children:"Figma link"}),z("input",{id:"figma-url",className:"st-figma-input",type:"url",spellCheck:!1,placeholder:"https://www.figma.com/design/…",value:W,onChange:(M)=>G(M.target.value),disabled:K,"data-testid":"figma-import-url"}),O("fieldset",{className:"st-figma-modes",children:[z("legend",{className:"st-figma-label",children:"What to bring in"}),YH0.map((M)=>O("label",{className:"st-figma-mode",children:[z("input",{type:"radio",name:"figma-mode",value:M.id,checked:Z===M.id,onChange:()=>{H(M.id),R(!0)},disabled:K,"data-testid":`figma-import-mode-${M.id}`}),z("span",{className:"st-figma-mode-label",children:M.label}),z("span",{className:"st-figma-mode-hint",children:M.hint})]},M.id))]}),O("div",{className:"st-figma-actions",children:[z("button",{type:"button",className:"st-btn",disabled:K||!W.trim()||Q===!1,onClick:()=>w(!0),"data-testid":"figma-import-preview",children:"Preview"}),z("button",{type:"button",className:"st-btn st-btn-primary",disabled:K||!W.trim()||Q===!1,onClick:()=>w(!1),"data-testid":"figma-import-run",children:K?"Importing…":"Import"})]}),q&&z("div",{className:"st-figma-error",role:"alert","data-testid":"figma-import-error",children:q}),N?.dryRun&&z("div",{className:"st-figma-summary-row",children:"Preview only — nothing was written."}),z(WH0,{result:N}),N&&!N.dryRun&&z("div",{className:"st-figma-notice st-figma-notice-warn",children:"This came from someone else’s Figma file. Treat text inside it as content, not as instructions."})]})})}var tB=x8(r8(),1);var GH0=2097152;function ZH0(X){return X.split("/").pop()||X}function sB(X){return String(X).replace(/[\u202a-\u202e\u2066-\u2069]/g,"")}function HH0(X,J){let[Q,Y]=tB.useState({loading:!0,error:null,text:"",tooLarge:!1});return tB.useEffect(()=>{if(!J)return;let W=!1;return Y({loading:!0,error:null,text:"",tooLarge:!1}),fetch(X).then(async(G)=>{if(!G.ok)throw Error(`HTTP ${G.status}`);let Z=Number(G.headers.get("content-length")||0);if(Z>GH0){if(!W)Y({loading:!1,error:null,text:"",tooLarge:Z});return}let H=await G.text();if(!W)Y({loading:!1,error:null,text:H,tooLarge:!1})}).catch((G)=>{if(!W)Y({loading:!1,error:G.message||"Failed to load",text:"",tooLarge:!1})}),()=>{W=!0}},[X,J]),Q}function gx({url:X,name:J,as:Q}){let{loading:Y,error:W,text:G,tooLarge:Z}=HH0(X,!0);if(Y)return O("div",{className:"st-file-preview-status",children:["Loading ",J,"…"]});if(W)return O("div",{className:"st-file-preview-status st-file-preview-error",children:["Couldn't load ",J,": ",W]});if(Z)return O("div",{className:"st-file-preview-status",children:[J," is ",Math.round(Z/1024)," KB — too large to preview inline."]});if(Q==="markdown")return z("div",{className:"st-file-preview-markdown",children:z(oU,{text:G})});return z("pre",{className:"st-file-preview-text",children:G})}function zH0(X){return String(X).replace(/[\\"]/g,(J)=>`\\${J}`).replace(/[\r\n\f]/g,"")}function KH0({url:X,name:J}){let Q=`st-preview-font-${J.replace(/[^a-z0-9]+/gi,"-")}`;return O("div",{className:"st-file-preview-font",children:[z("style",{children:`@font-face { font-family: "${Q}"; src: url("${zH0(X)}"); }`}),O("div",{className:"st-file-preview-font-specimen",style:{fontFamily:Q},children:[z("div",{className:"st-file-preview-font-lg",children:"The quick brown fox"}),z("div",{className:"st-file-preview-font-md",children:"jumps over the lazy dog"}),z("div",{className:"st-file-preview-font-sm",children:"ABCDEFGHIJKLM abcdefghijklm 0123456789"})]})]})}function mx({path:X,kind:J}){if(!X||!J)return null;let Q=`/${X}`,Y=sB(ZH0(X));return O("div",{className:"st-file-preview","data-kind":J,children:[z("h2",{className:"st-file-preview-header",children:sB(X)}),O("div",{className:"st-file-preview-body",children:[J==="markdown"&&z(gx,{url:Q,name:Y,as:"markdown"}),J==="text"&&z(gx,{url:Q,name:Y,as:"text"}),J==="image"&&z("div",{className:"st-file-preview-image-wrap",children:z("img",{src:Q,alt:`Preview: ${Y}`,className:"st-file-preview-image"})}),J==="video"&&z("video",{src:Q,controls:!0,className:"st-file-preview-media"},Q),J==="audio"&&z("audio",{src:Q,controls:!0,className:"st-file-preview-audio"},Q),J==="font"&&z(KH0,{url:Q,name:Y})]})]})}var FW=x8(r8(),1);function vA(X=!0){let[J,Q]=FW.useState(null),[Y,W]=FW.useState(X),G=FW.useCallback(()=>{return W(!0),fetch("/_api/setup-readiness").then((Z)=>Z.json()).then((Z)=>{return Q(Z&&Array.isArray(Z.items)?Z:null),W(!1),Z}).catch(()=>{return Q(null),W(!1),null})},[]);return FW.useEffect(()=>{if(!X)return;let Z=!0;return fetch("/_api/setup-readiness").then((H)=>H.json()).then((H)=>Z&&(Q(H&&Array.isArray(H.items)?H:null),W(!1))).catch(()=>Z&&(Q(null),W(!1))),()=>{Z=!1}},[X]),{report:J,loading:Y,refresh:G}}function UH0({present:X}){if(X)return z("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:z("polyline",{points:"3 8.4 6.4 11.8 13 4.4"})});return z("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:z("circle",{cx:"8",cy:"8",r:"5.5"})})}function VH0({report:X,loading:J,refresh:Q,onStartTour:Y,onBringBrand:W,onImportFigma:G}){return O("div",{className:"setup-cl",children:[z("ul",{className:"setup-cl-list",children:X?.items?.map((Z)=>O("li",{className:`setup-cl-row setup-cl-row--${Z.status}`,"data-testid":`setup-cl-row-${Z.id}`,children:[z("span",{className:"setup-cl-ic","aria-hidden":"true",children:z(UH0,{present:Z.status==="present"})}),O("span",{className:"setup-cl-tx",children:[z("span",{className:"setup-cl-label",children:Z.label}),z("span",{className:"setup-cl-detail",children:Z.detail})]})]},Z.id))}),O("div",{className:"setup-cl-foot",children:[Y&&z("button",{type:"button","data-testid":"setup-cl-start-tour",className:"btn btn--primary btn--sm",onClick:Y,children:"Start guided setup"}),W?z("button",{type:"button","data-testid":"onboarding-bring-brand",className:"btn btn--ghost btn--sm setup-cl-brand",onClick:W,children:"Bring my existing brand"}):z("a",{href:"https://maude.sh/docs/getting-started",target:"_blank",rel:"noreferrer noopener","data-testid":"onboarding-bring-brand",className:"btn btn--ghost btn--sm setup-cl-brand",children:"Bring my existing brand"}),G&&z("button",{type:"button","data-testid":"onboarding-import-figma",className:"btn btn--ghost btn--sm",onClick:G,children:"Import from Figma"}),Q&&z("button",{type:"button",className:"btn btn--ghost btn--sm setup-cl-recheck",onClick:Q,disabled:J,children:J?"Checking…":"Re-check"})]})]})}function fA({open:X,onClose:J,onStartTour:Q,onBringBrand:Y,onImportFigma:W}){let{report:G,loading:Z,refresh:H}=vA(X);if(FW.useEffect(()=>{if(!X)return;let K=(U)=>U.key==="Escape"&&J();return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[X,J]),!X)return null;return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(K)=>{if(K.target===K.currentTarget)J()},children:O("div",{className:"help-modal setup-cl-modal",role:"dialog","aria-modal":"true","aria-labelledby":"setup-cl-modal-title",children:[O("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"setup-cl-modal-title",children:"Quick setup"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:J,children:"×"})]}),O("div",{className:"help-modal-body",children:[z("p",{className:"setup-cl-note",children:"Empty → design system → first canvas → your first AI edit. Ask the Assistant to build each step, or take the guided tour to see where everything lives."}),G?z(VH0,{report:G,loading:Z,refresh:H,onStartTour:Q?()=>{J(),Q()}:void 0,onBringBrand:Y?()=>{J(),Y()}:void 0,onImportFigma:W?()=>{J(),W()}:void 0}):z("p",{className:"setup-cl-note",children:Z?"Checking…":"Couldn't reach the setup probe."})]})]})})}var X9=x8(r8(),1),yV=x8(J1(),1);var JN=x8(r8(),1);var eB=(...X)=>X.filter((J,Q,Y)=>{return Boolean(J)&&J.trim()!==""&&Y.indexOf(J)===Q}).join(" ").trim();var ux=(X)=>X.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var lx=(X)=>X.replace(/^([A-Z])|[\s-_]+(\w)/g,(J,Q,Y)=>Y?Y.toUpperCase():Q.toLowerCase());var xA=(X)=>{let J=lx(X);return J.charAt(0).toUpperCase()+J.slice(1)};var YV=x8(r8(),1);var XN={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var px=(X)=>{for(let J in X)if(J.startsWith("aria-")||J==="role"||J==="title")return!0;return!1};var QK=x8(r8(),1),qH0=QK.createContext({});var dx=()=>QK.useContext(qH0);var cx=YV.forwardRef(({color:X,size:J,strokeWidth:Q,absoluteStrokeWidth:Y,className:W="",children:G,iconNode:Z,...H},K)=>{let{size:U=24,strokeWidth:q=2,absoluteStrokeWidth:B=!1,color:N="currentColor",className:F=""}=dx()??{},D=Y??B?Number(Q??q)*24/Number(J??U):Q??q;return YV.createElement("svg",{ref:K,...XN,width:J??U??XN.width,height:J??U??XN.height,stroke:X??N,strokeWidth:D,className:eB("lucide",F,W),...!G&&!px(H)&&{"aria-hidden":"true"},...H},[...Z.map(([_,R])=>YV.createElement(_,R)),...Array.isArray(G)?G:[G]])});var M8=(X,J)=>{let Q=JN.forwardRef(({className:Y,...W},G)=>JN.createElement(cx,{ref:G,iconNode:J,className:eB(`lucide-${ux(xA(X))}`,`lucide-${X}`,Y),...W}));return Q.displayName=xA(X),Q};var BH0=[["path",{d:"m15 16 2.536-7.328a1.02 1.02 1 0 1 1.928 0L22 16",key:"xik6mr"}],["path",{d:"M15.697 14h5.606",key:"1stdlc"}],["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}]],WV=M8("a-large-small",BH0);var NH0=[["rect",{width:"6",height:"14",x:"2",y:"5",rx:"2",key:"dy24zr"}],["rect",{width:"6",height:"10",x:"16",y:"7",rx:"2",key:"13zkjt"}],["path",{d:"M12 2v20",key:"t6zp3m"}]],GV=M8("align-horizontal-justify-center",NH0);var FH0=[["rect",{width:"6",height:"14",x:"2",y:"5",rx:"2",key:"dy24zr"}],["rect",{width:"6",height:"10",x:"12",y:"7",rx:"2",key:"1ht384"}],["path",{d:"M22 2v20",key:"40qfg1"}]],ZV=M8("align-horizontal-justify-end",FH0);var LH0=[["rect",{width:"6",height:"14",x:"6",y:"5",rx:"2",key:"hsirpf"}],["rect",{width:"6",height:"10",x:"16",y:"7",rx:"2",key:"13zkjt"}],["path",{d:"M2 2v20",key:"1ivd8o"}]],HV=M8("align-horizontal-justify-start",LH0);var DH0=[["rect",{width:"6",height:"14",x:"3",y:"5",rx:"2",key:"j77dae"}],["rect",{width:"6",height:"10",x:"15",y:"7",rx:"2",key:"bq30hj"}],["path",{d:"M3 2v20",key:"1d2pfg"}],["path",{d:"M21 2v20",key:"p059bm"}]],YK=M8("align-horizontal-space-between",DH0);var OH0=[["rect",{width:"14",height:"6",x:"5",y:"16",rx:"2",key:"1i8z2d"}],["rect",{width:"10",height:"6",x:"7",y:"2",rx:"2",key:"ypihtt"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],zV=M8("align-vertical-justify-center",OH0);var MH0=[["rect",{width:"14",height:"6",x:"5",y:"12",rx:"2",key:"4l4tp2"}],["rect",{width:"10",height:"6",x:"7",y:"2",rx:"2",key:"ypihtt"}],["path",{d:"M2 22h20",key:"272qi7"}]],KV=M8("align-vertical-justify-end",MH0);var _H0=[["rect",{width:"14",height:"6",x:"5",y:"16",rx:"2",key:"1i8z2d"}],["rect",{width:"10",height:"6",x:"7",y:"6",rx:"2",key:"13squh"}],["path",{d:"M2 2h20",key:"1ennik"}]],UV=M8("align-vertical-justify-start",_H0);var AH0=[["path",{d:"M4 20h16",key:"14thso"}],["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}]],VV=M8("baseline",AH0);var wH0=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],qV=M8("bold",wH0);var EH0=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],LW=M8("braces",EH0);var PH0=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],BV=M8("chevron-down",PH0);var RH0=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],DW=M8("columns-3",RH0);var TH0=[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z",key:"1f1r0c"}]],NV=M8("diamond",TH0);var IH0=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],FV=M8("eye-off",IH0);var kH0=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],AZ=M8("eye",kH0);var CH0=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],LV=M8("image-plus",CH0);var $H0=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],DV=M8("italic",$H0);var SH0=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]],OV=M8("message-square-plus",SH0);var bH0=[["path",{d:"M5 12h14",key:"1ays0h"}]],MV=M8("minus",bH0);var yH0=[["path",{d:"m18 8 4 4-4 4",key:"1ak13k"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}]],_V=M8("move-horizontal",yH0);var jH0=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],AV=M8("plus",jH0);var vH0=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],wV=M8("rotate-ccw",vH0);var fH0=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],wZ=M8("rotate-cw",fH0);var xH0=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],OW=M8("rows-3",xH0);var hH0=[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]],EZ=M8("scissors",hH0);var gH0=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],EV=M8("scroll-text",gH0);var mH0=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],PV=M8("search",mH0);var uH0=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],MW=M8("sparkles",uH0);var lH0=[["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M5 17A12 12 0 0 1 17 5",key:"1okkup"}]],RV=M8("spline",lH0);var pH0=[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}]],_W=M8("square-dashed",pH0);var dH0=[["rect",{width:"20",height:"6",x:"2",y:"4",rx:"2",key:"qdearl"}],["rect",{width:"20",height:"6",x:"2",y:"14",rx:"2",key:"1xrn6j"}]],TV=M8("stretch-horizontal",dH0);var cH0=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],AW=M8("text-align-center",cH0);var iH0=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],wW=M8("text-align-end",iH0);var oH0=[["path",{d:"M3 5h18",key:"1u36vt"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 19h18",key:"awlh7x"}]],EW=M8("text-align-justify",oH0);var nH0=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],m5=M8("text-align-start",nH0);var rH0=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],IV=M8("type",rH0);var aH0=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],kV=M8("underline",aH0);var sH0=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],PW=M8("wand-sparkles",sH0);var tH0=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],CV=M8("x",tH0);var YJ=x8(r8(),1);var OX=x8(r8(),1);var RW=({as:X,size:J=14})=>z(X,{size:J,strokeWidth:1.75,style:{display:"block",flex:"none"}}),hA=(X)=>X.replace(/^--/,"").replace(/-/g," "),TW=(X,J,Q)=>{let Y=X;if(J!=null&&Y<J)Y=J;if(Q!=null&&Y>Q)Y=Q;return Y},eH0=(X)=>{if(!(X>0))return 2;if(X>=1)return 0;let J=String(X),Q=J.indexOf(".");return Q===-1?0:J.length-Q-1},WK=(X,J)=>{let Q=eH0(J);return Number(X.toFixed(Q))};function gA({getBase:X,min:J,max:Q,step:Y=1,onInput:W,onCommit:G,sensitivity:Z=1,sides:H}){return(K)=>{if(K.button!==0)return;let U=K.clientX,q=Number.parseFloat(X())||0,B=!1,N=q,F=(R)=>{if(!H)return;if(R.altKey&&R.shiftKey)return H.all;if(R.altKey)return H.pair;return},D=(R)=>{let w=R.clientX-U;if(!B&&Math.abs(w)<3)return;if(!B)B=!0,document.body.classList.add("st-scrubbing");R.preventDefault();let M=H?1:R.shiftKey?10:R.altKey?0.1:1;N=WK(TW(q+w*Y*Z*M,J,Q),Y),W?.(N,F(R))},_=(R)=>{if(document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",_),!B)return;document.body.classList.remove("st-scrubbing"),G?.(N,F(R))};document.addEventListener("pointermove",D),document.addEventListener("pointerup",_)}}function Xz0({getBase:X,min:J,max:Q,step:Y=1,onInput:W,onCommit:G,sensitivity:Z=1,sides:H}){return OX.useCallback(gA({getBase:X,min:J,max:Q,step:Y,onInput:W,onCommit:G,sensitivity:Z,sides:H}),[X,J,Q,Y,W,G,Z,H])}function WX({value:X,min:J,max:Q,step:Y=1,lead:W,scrub:G=!0,steppers:Z=!0,unitSlot:H,sensitivity:K=1,sides:U,format:q,parse:B,onInput:N,onCommit:F,ariaLabel:D,className:_=""}){let R=OX.useRef(null),w=OX.useCallback((h)=>q?q(h):String(WK(Number(h)||0,Y)),[q,Y]),M=(h)=>(typeof h==="number"?h:Number.parseFloat(h))||0;OX.useEffect(()=>{if(R.current&&document.activeElement!==R.current)R.current.value=w(X)},[X,w]);let P=(h,d)=>{let n=WK(TW(h,J,Q),Y);if(R.current)R.current.value=w(n);F?.(n,d)},k=Xz0({getBase:()=>R.current?R.current.value:M(X),min:J,max:Q,step:Y,sensitivity:K,sides:U,onInput:(h,d)=>{let n=WK(TW(h,J,Q),Y);if(R.current)R.current.value=w(n);N?.(n,d)},onCommit:P}),$=(h,d)=>P(M(R.current?.value??X)+h*Y*d),C=(h)=>{let d=h.shiftKey?10:1;if(h.key==="ArrowUp")h.preventDefault(),$(1,d);else if(h.key==="ArrowDown")h.preventDefault(),$(-1,d);else if(h.key==="PageUp")h.preventDefault(),$(1,10);else if(h.key==="PageDown")h.preventDefault(),$(-1,10);else if(h.key==="Home"&&J!=null)h.preventDefault(),P(J);else if(h.key==="End"&&Q!=null)h.preventDefault(),P(Q);else if(h.key==="Enter")h.currentTarget.blur()},y=(h)=>{let d=h.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===d)d.select()})},f=(h)=>{let d=String(h.currentTarget.value).trim();if(d==="")return;let n=B?B(d):Number.parseFloat(d);if(n==null||Number.isNaN(n)){h.currentTarget.value=w(X);return}P(n)};return O("div",{className:`st-cp-num ${_}`.trim(),children:[G?z("span",{className:"st-cp-numlead st-cp-handle",role:"presentation","aria-hidden":"true",title:"Drag to change · Shift ×10 · Alt fine",onPointerDown:k,children:W??z("span",{className:"st-cp-grip"})}):W?z("span",{className:"st-cp-numlead","aria-hidden":"true",children:W}):null,z("input",{ref:R,className:"st-cp-numin",role:"spinbutton","aria-label":D,"aria-valuenow":M(X),"aria-valuemin":J,"aria-valuemax":Q,defaultValue:w(X),inputMode:"decimal",onFocus:y,onKeyDown:C,onBlur:f}),Z?O("span",{className:"st-cp-step",children:[z("button",{type:"button",className:"st-cp-stepb",tabIndex:-1,"aria-label":`increase ${D||"value"}`,onClick:()=>$(1,1),children:"▲"}),z("button",{type:"button",className:"st-cp-stepb",tabIndex:-1,"aria-label":`decrease ${D||"value"}`,onClick:()=>$(-1,1),children:"▼"})]}):null,H??null]})}function Jz0({value:X,min:J=0,max:Q=1,step:Y=0.01,onInput:W,onCommit:G,ariaLabel:Z}){let H=OX.useRef(null),K=TW(X??(J<0?0:J),J,Q),U=Q-J||1,q=(K-J)/U,B=J<0&&Q>0?(0-J)/U:0,N=Math.min(q,B),F=Math.abs(q-B),D=(w)=>{let M=H.current?.getBoundingClientRect();if(!M||M.width===0)return K;let P=TW((w-M.left)/M.width,0,1);return WK(J+P*U,Y)};return z("div",{className:"st-cp-slider",children:O("div",{ref:H,className:"st-cp-track",role:"slider",tabIndex:0,"aria-label":Z,"aria-valuemin":J,"aria-valuemax":Q,"aria-valuenow":K,onPointerDown:(w)=>{if(w.button!==0)return;w.preventDefault(),H.current?.focus();let M=D(w.clientX);W?.(M);let P=(k)=>{M=D(k.clientX),W?.(M)},I=()=>{document.removeEventListener("pointermove",P),document.removeEventListener("pointerup",I),G?.(M)};document.addEventListener("pointermove",P),document.addEventListener("pointerup",I)},onKeyDown:(w)=>{let M=w.shiftKey?10:1,P=null;if(w.key==="ArrowRight"||w.key==="ArrowUp")P=K+Y*M;else if(w.key==="ArrowLeft"||w.key==="ArrowDown")P=K-Y*M;else if(w.key==="PageUp")P=K+Y*10;else if(w.key==="PageDown")P=K-Y*10;else if(w.key==="Home")P=J;else if(w.key==="End")P=Q;if(P!=null)w.preventDefault(),G?.(WK(TW(P,J,Q),Y))},children:[J<0&&Q>0?z("span",{className:"st-cp-zero",style:{left:`${B*100}%`}}):null,z("span",{className:"st-cp-fill",style:{left:`${N*100}%`,width:`${F*100}%`}}),z("span",{className:"st-cp-thumb",style:{left:`${q*100}%`}})]})})}function TJ({value:X,min:J=0,max:Q=1,step:Y=0.01,unit:W="",onInput:G,onCommit:Z,ariaLabel:H}){let K=X??(J<0?0:J);return O("div",{className:"st-cp-sfield",children:[z(Jz0,{value:K,min:J,max:Q,step:Y,onInput:G,onCommit:Z,ariaLabel:H}),z(WX,{className:"st-cp-num--compact",value:K,min:J,max:Q,step:Y,scrub:!1,steppers:!1,unitSlot:W?z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:W}):null,onInput:G,onCommit:Z,ariaLabel:H})]})}function QN({value:X,units:J,onChange:Q,ariaLabel:Y}){return z("select",{className:"st-cp-unitsel","aria-label":Y,value:X,onChange:(W)=>Q(W.target.value),children:J.map((W)=>z("option",{value:W,children:W},W))})}function YN({value:X,options:J,onChange:Q,ariaLabel:Y}){return z("div",{className:"st-cp-seg",role:"radiogroup","aria-label":Y,children:J.map((W)=>{let G=typeof W==="string"?W:W.value,Z=typeof W==="string"?W:W.label??W.value;return z("button",{type:"button",role:"radio","aria-checked":X===G,className:`st-cp-segbtn${X===G?" is-active":""}`,onClick:()=>Q(G),children:Z},G)})})}function IW({value:X,options:J,onChange:Q,ariaLabel:Y,mini:W=!1}){return z("select",{className:`st-cp-nsel${W?" st-cp-nsel--mini":""}`,"aria-label":Y,value:X,onChange:(G)=>Q(G.target.value),children:J.map((G)=>{let Z=typeof G==="string"?G:G.value,H=typeof G==="string"?G:G.label??G.value;return z("option",{value:Z,children:H},Z)})})}function yQ({checked:X,onChange:J,label:Q,ariaLabel:Y}){return O("label",{className:"st-cp-toggle",children:[z("input",{type:"checkbox",className:"st-cp-switch",checked:!!X,"aria-label":Y||Q,onChange:(W)=>J(W.target.checked)}),Q?z("span",{className:"st-cp-toggle-lbl",children:Q}):null]})}function mA({value:X,options:J,ariaLabel:Q,onChange:Y}){return z("div",{className:"st-cp-iconseg",role:"radiogroup","aria-label":Q,children:J.map((W)=>z("button",{type:"button",role:"radio","aria-checked":X===W.value,"aria-label":W.label,title:W.label,className:X===W.value?"is-active":"",onClick:()=>Y(W.value),children:W.node},W.value))})}function ix({value:X,options:J,ariaLabel:Q,onToggle:Y}){return z("div",{className:"st-cp-iconseg",role:"group","aria-label":Q,children:J.map((W)=>z("button",{type:"button","aria-pressed":!!X[W.value],"aria-label":W.label,title:W.label,onClick:()=>Y(W.value),children:W.node},W.value))})}var Qz0=["tl","tc","tr","cl","cc","cr","bl","bc","br"];function ox({value:X,onChange:J,ariaLabel:Q="alignment"}){return z("div",{className:"st-cp-alignpad",role:"radiogroup","aria-label":Q,children:Qz0.map((Y)=>z("button",{type:"button",role:"radio","aria-checked":X===Y,"aria-label":`align ${Y}`,className:X===Y?"is-active":"",onClick:()=>J(Y)},Y))})}function nx({value:X,onChange:J,ariaLabel:Q="rotation"}){let Y=OX.useRef(null),W=(K,U)=>{let q=Y.current?.getBoundingClientRect();if(!q)return X;let B=Math.round(Math.atan2(U-(q.top+q.height/2),K-(q.left+q.width/2))*180/Math.PI);if(B<0)B+=360;return B},G=(K)=>{if(K.button!==0)return;K.preventDefault(),document.body.classList.add("st-scrubbing","st-scrubbing--dial"),J(W(K.clientX,K.clientY));let U=(B)=>J(W(B.clientX,B.clientY)),q=()=>{document.removeEventListener("pointermove",U),document.removeEventListener("pointerup",q),document.body.classList.remove("st-scrubbing","st-scrubbing--dial")};document.addEventListener("pointermove",U),document.addEventListener("pointerup",q)},Z=X??0,H=(K)=>{let U=K.shiftKey?10:1,q=null;if(K.key==="ArrowRight"||K.key==="ArrowUp")q=Z+U;else if(K.key==="ArrowLeft"||K.key==="ArrowDown")q=Z-U;else if(K.key==="PageUp")q=Z+15;else if(K.key==="PageDown")q=Z-15;else if(K.key==="Home")q=0;else if(K.key==="End")q=360;if(q!=null)K.preventDefault(),J(TW(q,0,360))};return z("button",{ref:Y,type:"button",className:"st-cp-dial",role:"slider","aria-label":Q,"aria-valuemin":0,"aria-valuemax":360,"aria-valuenow":Z,"aria-valuetext":`${Z}°`,title:"drag to rotate · arrows to nudge",onPointerDown:G,onKeyDown:H,children:z("span",{className:"st-cp-dial-needle",style:{"--angle":`${X}deg`}})})}function rx({title:X,defaultOpen:J=!0,onReset:Q,right:Y,children:W}){let[G,Z]=OX.useState(J);return O("section",{className:"st-cp-sec",children:[O("div",{className:"st-cp-sechd-row",children:[O("button",{type:"button",className:"st-cp-sechd","aria-expanded":G,onClick:()=>Z((H)=>!H),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:z(RW,{as:BV,size:12})}),X]}),Y??null,Q?z("button",{type:"button",className:"st-cp-secreset","aria-label":`reset ${X} section`,title:`reset ${X}`,onClick:Q,children:z(RW,{as:wV,size:12})}):null]}),z("div",{className:`st-cp-sec-anim${G?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:W})})]})}function $V({swatch:X,displayValue:J,bound:Q,alpha:Y,visible:W,ariaLabel:G,onValue:Z,onAlpha:H,onVisible:K}){return O("span",{className:"st-cp-cf",children:[X,z("input",{className:`st-cp-cf-in${Q?" is-bound":""}`,"aria-label":G,value:J,onChange:(U)=>Z?.(U.target.value),onFocus:(U)=>U.currentTarget.select(),readOnly:!Z}),H?z("input",{className:"st-cp-cf-alpha","aria-label":`${G||"colour"} alpha`,value:`${Y}`,onChange:(U)=>H(TW(Number.parseFloat(U.target.value)||0,0,100)),onFocus:(U)=>U.currentTarget.select()}):null,K?z("button",{type:"button",className:`st-cp-cf-eye${W?"":" is-off"}`,"aria-pressed":W,"aria-label":`${G||"colour"} visibility`,onClick:()=>K(!W),children:W?z(RW,{as:AZ}):z(RW,{as:FV})}):null]})}function WN({value:X,tokens:J,ariaLabel:Q,lead:Y,unit:W,unitSlot:G,min:Z=0,max:H,step:K=1,onChange:U}){let[q,B]=OX.useState(!1),[N,F]=OX.useState(""),D=OX.useRef(null),_=typeof X==="string"&&X.startsWith("var("),R=_?X.replace(/^var\(\s*|\s*\)$/g,""):"",w=_?J.find((P)=>P.name===R)?.value??"":"";OX.useEffect(()=>{if(!q){F("");return}let P=(I)=>{if(!D.current?.contains(I.target))B(!1)};return document.addEventListener("pointerdown",P,!0),()=>document.removeEventListener("pointerdown",P,!0)},[q]);let M=N?J.filter((P)=>hA(P.name).includes(N)||(P.value||"").toLowerCase().includes(N)):J;return O("div",{className:"st-cp-tokfield",children:[_?O("div",{className:"st-cp-boundchip",title:`${R} = ${w}`,children:[Y?z("span",{className:"st-cp-boundchip-lead","aria-hidden":"true",children:Y}):null,z("span",{className:"st-cp-boundchip-name",children:hA(R)}),z("button",{type:"button",className:"st-cp-boundchip-x","aria-label":"detach token",title:"detach — back to a raw value",onClick:()=>U(Number.parseFloat(w)||0),children:z(RW,{as:CV,size:12})})]}):z(WX,{value:typeof X==="number"?X:0,min:Z,max:H,step:K,ariaLabel:Q,lead:Y,steppers:!1,unitSlot:G??(W?z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:W}):null),onCommit:(P)=>U(P)}),O("span",{ref:D,style:{position:"relative",display:"inline-flex"},children:[z("button",{type:"button",className:`st-cp-tokbtn${_?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":q,"aria-label":`${Q} — bind a design token`,title:"bind a design token",onClick:()=>B((P)=>!P),children:z(RW,{as:NV,size:13})}),q?O("div",{className:"st-cp-pop",role:"dialog","aria-label":"design tokens",style:{left:"auto",right:0},children:[O("div",{className:"st-cp-pop-search",children:[z(RW,{as:PV,size:12}),z("input",{value:N,onChange:(P)=>F(P.target.value.toLowerCase()),placeholder:"Search variables","aria-label":"search variables"})]}),M.length?M.map((P)=>O("button",{type:"button",className:`st-cp-pop-row${R===P.name?" is-on":""}`,onClick:()=>{U(`var(${P.name})`),B(!1)},children:[z("span",{className:"st-cp-pop-name",children:hA(P.name)}),z("span",{className:"st-cp-pop-val",children:P.value})]},P.name)):z("div",{className:"st-cp-pop-empty",children:"No match"})]}):null]})]})}function ax({corners:X,lead:J,onCorners:Q}){let[Y,W]=OX.useState(!1),G=(H)=>Q({tl:H,tr:H,bl:H,br:H}),Z=(H)=>O("label",{className:"st-cp-corner",children:[z("span",{className:`st-cp-cnr st-cp-cnr--${H}`,"aria-hidden":"true"}),z("input",{"aria-label":`${H} radius`,value:X[H],onChange:(K)=>Q({...X,[H]:Number.parseFloat(K.target.value)||0}),onFocus:(K)=>K.currentTarget.select()})]});return O("div",{className:"st-cp-radius",children:[O("div",{className:"st-cp-radius-main",children:[z(WX,{value:X.tl,min:0,max:200,ariaLabel:"border-radius",lead:J,steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(H)=>Y?Q({...X,tl:H}):G(H)}),z("button",{type:"button",className:`st-cp-splitbtn${Y?" is-on":""}`,"aria-pressed":Y,"aria-label":"detach corners",title:"detach corners — edit each independently",onClick:()=>W((H)=>!H),children:z(RW,{as:_W,size:14})})]}),Y?O("div",{className:"st-cp-corners",children:[Z("tl"),Z("tr"),Z("bl"),Z("br")]}):null]})}var Yz0=[0.25,0.5,1,1.5,2,4],Wz0=["fade","slide","wipe","flip","clock-wipe","none"],Gz0={None:null,Mono:{saturation:0,contrast:1.05},Warm:{hue:-12,saturation:1.15,brightness:1.03},Cool:{hue:12,saturation:1.05,brightness:0.98},Punch:{contrast:1.18,saturation:1.25}};function sx(X){if(!X)return{};let J={},Q=String(X).trim(),Y=/^([a-z-]+)\(([^)]*)\)\s*/,W={brightness:"brightness",contrast:"contrast",saturate:"saturation","hue-rotate":"hue",sepia:"sepia",grayscale:"grayscale",invert:"invert"};while(Q.length){let G=Q.match(Y);if(!G||!W[G[1]])return null;let Z=Number.parseFloat(G[2]);if(!Number.isFinite(Z))return null;J[W[G[1]]]=Z,Q=Q.slice(G[0].length)}return J}function Zz0({tabs:X,active:J,onPick:Q}){return z("div",{className:"tlci-tabs",role:"tablist",children:X.map((Y)=>z("button",{type:"button",role:"tab","aria-selected":J===Y,className:`tlci-tab${J===Y?" is-on":""}`,"data-testid":`timeline-inspector-tab-${Y.toLowerCase()}`,onClick:()=>Q(Y),children:Y},Y))})}function GN({mode:X="clip",clipLabel:J="",mediaProps:Q=null,kind:Y="video",transition:W=null,textValue:G=null,x:Z=200,y:H=200,onVerb:K,onClose:U}){let q=X==="transition"?["Transition"]:G!=null&&Y!=="video"&&Y!=="audio"?["Text","Speed"]:Y==="audio"?["Speed","Audio"]:G!=null?["Speed","Audio","Crop","Grade","Text"]:["Speed","Audio","Crop","Grade"],[B,N]=YJ.useState(q[0]),[F,D]=YJ.useState({x:Z,y:H}),_=YJ.useRef(null);YJ.useEffect(()=>{let p=(v)=>{if(v.key==="Escape")v.stopPropagation(),U?.()};return window.addEventListener("keydown",p,!0),()=>window.removeEventListener("keydown",p,!0)},[U]);let R=YJ.useCallback((p)=>{if(p.target.closest("button, input, select"))return;p.preventDefault();let v={x:p.clientX,y:p.clientY,px:F.x,py:F.y},r=(c)=>D({x:v.px+c.clientX-v.x,y:v.py+c.clientY-v.y}),a=()=>{window.removeEventListener("pointermove",r),window.removeEventListener("pointerup",a)};window.addEventListener("pointermove",r),window.addEventListener("pointerup",a)},[F]),w=Q?.playbackRate??1,M=Q?.muted?0:Q?.volume??1,P=Q?.framing??null,I=sx(Q?.filter),k=I==null,[$,C]=YJ.useState(I??{}),[y,f]=YJ.useState(P??{scale:1,x:0,y:0}),[h,d]=YJ.useState(W?.dur??15);YJ.useEffect(()=>{C(sx(Q?.filter)??{}),f(Q?.framing??{scale:1,x:0,y:0})},[Q]),YJ.useEffect(()=>{d(W?.dur??15)},[W]);let n=(p)=>{C(p);let v=Object.entries(p).some(([r,a])=>r==="brightness"||r==="contrast"||r==="saturation"?a!==1:a!==0);K?.("grade",{grade:v?p:null})},x=(p)=>{f(p),K?.("framing",{framing:p.scale===1&&p.x===0&&p.y===0?null:p})},m=(p,v,r,a,c,U0)=>O("label",{className:"tlci-row",children:[z("span",{className:"tlci-lbl",children:p}),z(TJ,{value:$[v]??U0,min:r,max:a,step:c,onCommit:(o)=>n({...$,[v]:o}),ariaLabel:p})]},v);return O("div",{ref:_,className:"tlci",style:{left:F.x,top:F.y},role:"dialog","aria-label":`Adjust ${J||"clip"}`,"data-testid":"timeline-inspector",onPointerDown:(p)=>p.stopPropagation(),children:[O("div",{className:"tlci-head",onPointerDown:R,children:[z("span",{className:"tlci-title",children:J||(X==="transition"?"Transition":"Clip")}),z("button",{type:"button",className:"tlci-x","aria-label":"Close",onClick:U,children:"×"})]}),z(Zz0,{tabs:q,active:B,onPick:N}),B==="Speed"&&O("div",{className:"tlci-body",role:"tabpanel",children:[z("div",{className:"tlci-presets",children:Yz0.map((p)=>O("button",{type:"button",className:`tlci-chip${w===p?" is-on":""}`,"data-testid":`timeline-speed-${String(p).replace(".","_")}`,onClick:()=>K?.("speed",{rate:p}),children:[p,"×"]},p))}),O("label",{className:"tlci-row",children:[z("span",{className:"tlci-lbl",children:"Custom"}),z(WX,{value:w,min:0.1,max:16,step:0.05,onCommit:(p)=>K?.("speed",{rate:p}),ariaLabel:"Playback rate"})]}),z("p",{className:"tlci-note",children:"Duration recomputes; the cut ripples to stay gapless."})]}),B==="Audio"&&O("div",{className:"tlci-body",role:"tabpanel",children:[O("label",{className:"tlci-row",children:[z("span",{className:"tlci-lbl",children:"Muted"}),z(yQ,{checked:!!Q?.muted,onChange:(p)=>K?.("audio",{muted:p}),ariaLabel:"Mute clip"})]}),O("label",{className:"tlci-row",children:[z("span",{className:"tlci-lbl",children:"Volume"}),z(TJ,{value:M,min:0,max:1,step:0.05,onCommit:(p)=>K?.("audio",{volume:p}),ariaLabel:"Clip volume"})]}),Y==="video"?z("button",{type:"button",className:"tlci-btn","data-testid":"timeline-detach-audio",onClick:()=>K?.("detach-audio",{}),children:"Detach audio"}):null]}),B==="Crop"&&O("div",{className:"tlci-body",role:"tabpanel",children:[O("label",{className:"tlci-row",children:[z("span",{className:"tlci-lbl",children:"Scale"}),z(WX,{value:y.scale,min:1,max:8,step:0.05,onCommit:(p)=>x({...y,scale:p}),ariaLabel:"Crop scale"})]}),O("label",{className:"tlci-row",children:[z("span",{className:"tlci-lbl",children:"X %"}),z(WX,{value:y.x,min:-100,max:100,step:1,onCommit:(p)=>x({...y,x:p}),ariaLabel:"Crop x offset"})]}),O("label",{className:"tlci-row",children:[z("span",{className:"tlci-lbl",children:"Y %"}),z(WX,{value:y.y,min:-100,max:100,step:1,onCommit:(p)=>x({...y,y:p}),ariaLabel:"Crop y offset"})]}),O("div",{className:"tlci-presets",children:[z("button",{type:"button",className:"tlci-chip",onClick:()=>x({scale:1,x:0,y:0}),children:"Reset"}),z("button",{type:"button",className:"tlci-chip",onClick:()=>x({...y,scale:1.2}),children:"1.2×"}),z("button",{type:"button",className:"tlci-chip",onClick:()=>x({...y,scale:1.5}),children:"1.5×"})]})]}),B==="Grade"&&z("div",{className:"tlci-body",role:"tabpanel",children:k?z("p",{className:"tlci-note","data-testid":"timeline-grade-readonly",children:"This clip carries a hand-written filter — edit it in code."}):O(G0,{children:[z("div",{className:"tlci-presets",children:Object.entries(Gz0).map(([p,v])=>z("button",{type:"button",className:"tlci-chip","data-testid":`timeline-grade-${p.toLowerCase()}`,onClick:()=>n(v?{...v}:{}),children:p},p))}),m("Brightness","brightness",0.2,2,0.01,1),m("Contrast","contrast",0.2,2,0.01,1),m("Saturation","saturation",0,2,0.01,1),m("Hue","hue",-180,180,1,0),m("Sepia","sepia",0,1,0.01,0),m("Grayscale","grayscale",0,1,0.01,0),z("p",{className:"tlci-note",children:"Preview applies on the paused frame (WKWebView filter ceiling); exports are exact."})]})}),B==="Text"&&O("div",{className:"tlci-body",role:"tabpanel",children:[z("textarea",{className:"tlci-textarea","data-testid":"timeline-inspector-text",defaultValue:G||"",rows:4,placeholder:Y==="placeholder"?"Generation prompt…":"Title text…",onKeyDown:(p)=>p.stopPropagation()}),z("button",{type:"button",className:"tlci-btn","data-testid":"timeline-inspector-text-apply",onClick:(p)=>{let v=p.currentTarget.closest(".tlci-body")?.querySelector("textarea")?.value;if(v&&v.trim())K?.("set-text",{text:v})},children:"Apply text"}),z("p",{className:"tlci-note",children:Y==="placeholder"?"Updates the generation prompt on the slate.":"Rewrites the title text in the composition."})]}),B==="Transition"&&O("div",{className:"tlci-body",role:"tabpanel",children:[z("div",{className:"tlci-presets","data-testid":"timeline-transition-grid",children:Wz0.map((p)=>z("button",{type:"button",className:"tlci-chip","data-testid":`timeline-transition-${p}`,onClick:()=>K?.("transition",{presentation:p}),children:p},p))}),O("label",{className:"tlci-row",children:[z("span",{className:"tlci-lbl",children:"Frames"}),z(WX,{value:h,min:1,max:120,step:1,onCommit:(p)=>{d(p),K?.("transition",{durationInFrames:p})},ariaLabel:"Transition duration"})]}),z("button",{type:"button",className:"tlci-btn","data-testid":"timeline-transition-remove",onClick:()=>{K?.("remove-transition",{}),U?.()},children:"Remove transition (hard cut)"})]})]})}function tx({fps:X,totalFrames:J,clips:Q,movingIndex:Y,playhead:W}){let G=new Set([0,J]),Z=Math.max(1,Math.round(X||30));for(let H=0;H<=J;H+=Z)G.add(H);if((Q||[]).forEach((H,K)=>{if(K===Y)return;let U=Number.isFinite(H?.from)?H.from:0,q=Number.isFinite(H?.duration)?H.duration:0;G.add(U),G.add(U+q)}),Number.isFinite(W))G.add(W);return[...G].filter((H)=>H>=0&&H<=J).sort((H,K)=>H-K)}function uA(X,J,Q){if(!(Q>0))return X;let Y=X,W=Q+1;for(let G of J||[]){let Z=Math.abs(X-G);if(Z<=Q&&Z<W)Y=G,W=Z}return Y}var Hz0=/[\u202a-\u202e\u2066-\u2069\u200b-\u200f\u2060\u00ad\ufeff\u0000-\u001f\u007f-\u009f]/g;function ZN(X,J=120){if(typeof X!=="string")return null;return X.replace(Hz0,"").trim().slice(0,J).trim()||null}function lA(X,J={}){if(!Array.isArray(X)||X.length===0)return null;let{artboardId:Q=null,total:Y=0}=J,W=(Array.isArray(Q)?Q:[Q]).filter(Boolean);for(let G of W){let Z=X.find((H)=>H.artboardId===G);if(Z)return Z.id}for(let G of W){let Z=X.find((H)=>H.id===G);if(Z)return Z.id}if(Y>0){let G=X.filter((Z)=>Z.durationInFrames===Y);if(G.length===1)return G[0].id}return X[0].id}function GK(X,J){if(!Array.isArray(X)||X.length===0)return null;return X.find((Q)=>Q.id===J)??X[0]}var ZK=new Map,kW=new Map,pA=0,dA=[],zz0=2,ex=160;function Xh(){while(pA<zz0&&dA.length){let X=dA.shift();pA+=1,(window.requestIdleCallback||((Q)=>setTimeout(Q,40)))(()=>{X().catch(()=>{}).finally(()=>{pA-=1,Xh()})})}}function Jh(X){return new Promise((J)=>{dA.push(()=>X().then(J,()=>J(null))),Xh()})}function Qh(X,J){let Q=String(X).match(/([a-f0-9]{8,})\.[a-z0-9]+$/i)?.[1]?.slice(0,12);if(Q)return`${Q}-${J}`;let Y=5381;for(let W=0;W<X.length;W+=1)Y=(Y<<5)+Y+X.charCodeAt(W)>>>0;return`h${Y.toString(16)}-${J}`}async function Yh(X){try{let J=await fetch(`/_api/timeline-media?key=${encodeURIComponent(X)}`);if(!J.ok)return null;let Q=await J.json();return Q?.ok&&Q.data&&typeof Q.data==="object"?Q.data:null}catch{return null}}function Wh(X,J){fetch(`/_api/timeline-media?key=${encodeURIComponent(X)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(J)}).catch(()=>{})}function cA(X){if(X<90)return 1;if(X<200)return 3;if(X<340)return 5;return 7}async function Gh(X,J){let Q=document.createElement("video");Q.muted=!0,Q.playsInline=!0,Q.preload="auto",Q.crossOrigin="anonymous",Q.style.cssText="position:fixed;left:-9999px;top:-9999px;width:2px;height:2px;opacity:0;pointer-events:none;",document.body.appendChild(Q),Q.src=X;try{Q.load()}catch{}try{await new Promise((Y,W)=>{let G=setTimeout(()=>W(Error("metadata timeout")),J),Z=()=>{clearTimeout(G),Y()};Q.addEventListener("loadedmetadata",Z,{once:!0}),Q.addEventListener("canplay",Z,{once:!0}),Q.addEventListener("error",()=>W(Error(`video error (${Q.error?.code??"?"})`)),{once:!0})})}catch(Y){throw Q.remove(),Y}return Q}async function iA(X){let J;try{J=await Gh(X,6000)}catch{return null}let Q=J.duration;return J.remove(),Number.isFinite(Q)&&Q>0?Q:null}function SV(X,J,Q=3){let Y=Number.isFinite(J)&&J>0?J:Q;return Math.max(1,Math.round(X*Y))}async function Kz0(X,J){let Q;try{Q=await Gh(X,8000)}catch(K){throw console.warn("[timeline] filmstrip extraction failed for",X,K?.message||K),K}let Y=Q.duration;if(!Number.isFinite(Y)||Y<=0)throw Error("no duration");let W=(Q.videoHeight||9)/(Q.videoWidth||16),G=document.createElement("canvas");G.width=ex,G.height=Math.max(2,Math.round(ex*W));let Z=G.getContext("2d"),H=[];try{for(let K=0;K<J;K+=1){let U=(K+0.5)/J*Y;await new Promise((q,B)=>{let N=setTimeout(()=>B(Error("seek timeout")),6000);Q.addEventListener("seeked",()=>{clearTimeout(N),q()},{once:!0}),Q.currentTime=Math.min(Y-0.01,Math.max(0,U))}),Z.drawImage(Q,0,0,G.width,G.height),H.push(G.toDataURL("image/jpeg",0.55))}}catch(K){if(H.length===0)try{await new Promise((U,q)=>{if(Q.readyState>=2){U();return}let B=setTimeout(()=>q(Error("data timeout")),4000);Q.addEventListener("loadeddata",()=>{clearTimeout(B),U()},{once:!0})}),Z.drawImage(Q,0,0,G.width,G.height),H.push(G.toDataURL("image/jpeg",0.55))}catch{throw Q.remove(),console.warn("[timeline] filmstrip seek+poster both failed for",X,K?.message||K),K}while(H.length<J)H.push(H[H.length-1])}Q.removeAttribute("src");try{Q.load()}catch{}return Q.remove(),H}async function Uz0(X,J=400){let Q=await fetch(X);if(!Q.ok)throw Error(`fetch ${Q.status}`);let Y=await Q.arrayBuffer(),W=window.AudioContext||window.webkitAudioContext;if(!W)throw Error("no AudioContext");let G=new W;try{let H=(await G.decodeAudioData(Y)).getChannelData(0),K=Math.max(1,Math.floor(H.length/J)),U=[];for(let q=0;q<J;q+=1){let B=0,N=q*K,F=Math.min(H.length,N+K),D=Math.max(1,Math.floor((F-N)/64));for(let _=N;_<F;_+=D){let R=Math.abs(H[_]);if(R>B)B=R}U.push(Math.round(B*100)/100)}return U}finally{G.close?.().catch?.(()=>{})}}function Zh(X,J){let Q=Qh(X,`s${J}`),Y=ZK.get(Q);if(Y?.strip)return Promise.resolve(Y.strip);if(kW.has(Q))return kW.get(Q);let W=(async()=>{let G=await Yh(Q);if(Array.isArray(G?.strip))return ZK.set(Q,{strip:G.strip}),G.strip;let Z=await Jh(()=>Kz0(X,J));if(!Z)return null;return ZK.set(Q,{strip:Z}),Wh(Q,{strip:Z}),Z})().finally(()=>kW.delete(Q));return kW.set(Q,W),W}function Hh(X){let J=Qh(X,"peaks"),Q=ZK.get(J);if(Q?.peaks)return Promise.resolve(Q.peaks);if(kW.has(J))return kW.get(J);let Y=(async()=>{let W=await Yh(J);if(Array.isArray(W?.peaks))return ZK.set(J,{peaks:W.peaks}),W.peaks;let G=await Jh(()=>Uz0(X));if(!G)return null;return ZK.set(J,{peaks:G}),Wh(J,{peaks:G}),G})().finally(()=>kW.delete(J));return kW.set(J,Y),Y}function zh(X){if(!X?.length)return"";let J=X.length,Q=[],Y=[];for(let W=0;W<J;W+=1){let G=W/(J-1)*100,Z=Math.max(0.04,Math.min(1,X[W]))*5;Q.push(`${G.toFixed(2)} ${(6-Z).toFixed(2)}`),Y.unshift(`${G.toFixed(2)} ${(6+Z).toFixed(2)}`)}return`M${Q.join(" L")} L${Y.join(" L")} Z`}function oA(X,J){let Q=Math.max(1,X||1),Y=Math.max(1,J||1);return Q/Y}var HN=40;function nA(X,J,Q){let Y=oA(J,Q),W=Number(X);if(!Number.isFinite(W)||W<=0)return Y;return Math.min(HN,Math.max(Y,W))}function Kh(X,J){return X*J}function bV(X,J){return J>0?X/J:0}function Uh(X,J,Q,Y){let W=Kh(Q,X)-Y;return Math.max(0,Kh(Q,J)-W)}function Vh(X,J,Q=56){let Y=Math.max(1,Math.round(J||30)),W=[1,5,10,Y,5*Y,10*Y,30*Y,60*Y];for(let G of W)if(G*X>=Q)return G;return W[W.length-1]}function qh(X,J){let Q=Math.max(1,Math.round(J||30));if(X%Q===0)return`${X/Q}s`;return`${X}f`}var rA=1.5;var MX=x8(r8(),1);function IJ(X){return()=>{if(typeof console<"u")console.warn(`[context-menu] TODO: ${X}`)}}function zN(X,J){return{id:`export-${J}`,label:X,shortcut:J==="selection"?"⌘E":void 0,onSelect:()=>{let Q={scope:J};try{window.dispatchEvent(new CustomEvent("maude:open-export",{detail:Q}))}catch{}}}}var iu0={element:[[{id:"add-comment",label:"Add comment",shortcut:"C",onSelect:IJ("add-comment")},{id:"copy-css",label:"Copy CSS",shortcut:"⌘⇧C",onSelect:IJ("copy-css")},{id:"copy-id",label:"Copy data-cd-id",onSelect:IJ("copy-id")},{id:"inspect",label:"Inspect",shortcut:"⌥I",onSelect:IJ("inspect")}],[zN("Export selection…","selection")],[{id:"hide",label:"Hide",shortcut:"⌘⇧H",onSelect:IJ("hide")},{id:"lock",label:"Lock",shortcut:"⌘⇧L",onSelect:IJ("lock")}]],"artboard-chrome":[[{id:"rename",label:"Rename",shortcut:"↵",onSelect:IJ("rename-artboard")},{id:"duplicate",label:"Duplicate",shortcut:"⌘D",onSelect:IJ("duplicate-artboard")}],[zN("Export this artboard…","artboard")],[{id:"fit-one",label:"Fit just this artboard",onSelect:IJ("fit-one")},{id:"reset-pos",label:"Reset position",onSelect:IJ("reset-artboard-pos")}]],world:[[{id:"paste-artboard",label:"Paste artboard",shortcut:"⌘V",onSelect:IJ("paste-artboard")},{id:"fit-view",label:"Fit to view",shortcut:"1",onSelect:IJ("fit-view")},{id:"reset-view",label:"Reset view",shortcut:"⌘0",onSelect:IJ("reset-view")}],[zN("Export project (ZIP)…","project-raw"),zN("Export canvas as separate…","canvas-as-separate")]],overlay:[]},ou0=MX.createContext(null),Vz0=`
@@ -5650,7 +5650,7 @@ ${B.block}`:q,F=[],D=new Map;for await(let _ of X.prompt(N,J(),K,Q?.(),Y?.(),Z?.
5650
5650
 
5651
5651
  > Maude ${p.app.maudeVersion} · ${p.app.platform} ${p.app.arch} · ${p.app.surface}
5652
5652
  > Local report bundle: \`${a?.dir??".design/_reports/"}\` (attach its files here)`),o=`${tz0}?title=${c}&body=${U0}&labels=report`;if(W9())try{await nU(o)}catch{window.open(o,"_blank","noopener")}else window.open(o,"_blank","noopener");I({fallbackDir:a?.dir??null}),W("done")}catch{$("Saving the local bundle failed too — please file the issue by hand.")}}let m=G.trim().length>0;return z("div",{className:"st-scrim",onClick:h,"data-testid":"report-bug-dialog",children:O("div",{className:"st-dialog rb-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"rb-title",onClick:(p)=>p.stopPropagation(),children:[O("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",id:"rb-title",children:"Report a bug"}),z("button",{type:"button",className:"st-iconbtn",onClick:h,"aria-label":"Close",children:"×"})]}),O("div",{className:"st-dialog-bd rb-body",children:[Y==="describe"&&O(G0,{children:[z("label",{className:"rb-label",htmlFor:"rb-desc",children:"What happened? What did you expect instead?"}),z("textarea",{id:"rb-desc",className:"textarea","data-testid":"report-bug-description",rows:5,autoFocus:!0,value:G,onChange:(p)=>Z(p.target.value),placeholder:"e.g. Clicking Export → PNG shows a spinner forever…"}),z("p",{className:"rb-hint",children:"Next you'll see exactly what gets attached — nothing is sent until you approve it."}),O("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:h,children:"Cancel"}),z("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-preview",disabled:!m,onClick:()=>W("preview"),children:"Review & attach"})]})]}),Y==="preview"&&O(G0,{children:[O("div",{className:"rb-section",children:[O("div",{className:"rb-section-hd",children:[O("span",{children:["Screenshots (",U.length,")"]}),O("span",{className:"rb-hd-actions",children:[U.length<Bw&&z("button",{type:"button",className:"rb-link","data-testid":"report-bug-attach",onClick:f,children:"Attach screenshot…"}),U.length>0&&z("button",{type:"button",className:`rb-link${w?" is-on":""}`,"data-testid":"report-bug-redact",onClick:()=>M((p)=>!p),children:w?"Done redacting":"Redact…"})]})]}),O("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 (",ez0(H?.app?.platform),") and attach or paste (⌘V) it here."]}),_&&z("p",{className:"rb-hint","data-testid":"report-bug-shell-pending",children:"Capturing the Maude window…"}),U.length===0&&!_?O("p",{className:"rb-hint",children:["No screenshot attached yet — up to ",Bw,"."]}):O(G0,{children:[w&&z("p",{className:"rb-hint",children:"Drag over anything private — it ships as solid black."}),z("div",{className:"rb-shots",children:U.map((p,v)=>z(QK0,{shot:p,redacting:w,onRects:(r)=>q((a)=>a.map((c,U0)=>U0===v?{...c,rects:r}:c)),onRemove:()=>{URL.revokeObjectURL(p.url),q((r)=>r.filter((a,c)=>c!==v))}},p.url))})]})]}),O("div",{className:"rb-section",children:[z("div",{className:"rb-section-hd",children:z("span",{children:"Included with the report"})}),O("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:!0,disabled:!0}),O("span",{children:["Maude ",H?.app?.maudeVersion??"…"," · ",H?.app?.platform??"…"," ",H?.app?.arch??""," · ",W9()?"desktop app":"browser"]})]}),Q&&O("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.activeCanvas,onChange:(p)=>D({...F,activeCanvas:p.target.checked})}),O("span",{children:["Active canvas path — ",z("code",{children:Q})]})]}),H?.context?.projectName&&O("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.projectName,onChange:(p)=>D({...F,projectName:p.target.checked})}),O("span",{children:["Project name — ",z("code",{children:H.context.projectName})]})]}),H?.logs?.serverLogTail?O("label",{className:"rb-check",children:[z("input",{type:"checkbox","data-testid":"report-bug-consent-logs",checked:F.logTail,onChange:(p)=>D({...F,logTail:p.target.checked})}),O("span",{children:["Recent server log (",H.logs.serverLogTail.split(`
5653
- `).length," lines, paths & secrets scrubbed) —"," ",O("details",{className:"rb-details",children:[z("summary",{children:"view"}),z("pre",{className:"rb-log",children:H.logs.serverLogTail})]})]})]}):null,W9()&&B.length>0&&O("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.crashLogs,onChange:(p)=>D({...F,crashLogs:p.target.checked})}),O("span",{children:["Crash logs (",B.length,") — ",z("code",{children:B.map((p)=>p.name).join(", ")})]})]})]}),O("p",{className:"rb-hint",children:["Your description and the system info above become a"," ",z("strong",{children:"public GitHub issue"}),"; screenshots and logs go to a private repository only maintainers can open."]}),O("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("describe"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-send",onClick:n,children:"Send report"})]})]}),Y==="sending"&&z("p",{className:"rb-hint",children:"Sending your report…"}),Y==="done"&&O(G0,{children:[P?.issueUrl?O("p",{children:["Thank you — your report is filed as"," ",O("button",{type:"button",className:"rb-link","data-testid":"report-bug-issue-link",onClick:()=>{if(W9())nU(P.issueUrl).catch(()=>navigator.clipboard?.writeText(P.issueUrl));else window.open(P.issueUrl,"_blank","noopener")},children:["report #",P.issueNumber]})," ","on the public Maude issue tracker. Screenshots and logs stay in a private repository only maintainers can open — the issue links to them."]}):O("p",{children:["The bundle is saved locally",P?.fallbackDir?O(G0,{children:[" ","at ",z("code",{children:P.fallbackDir})]}):null," ","and a prefilled GitHub issue was opened — attach the bundle files there."]}),z("footer",{className:"rb-actions",children:z("button",{type:"button",className:"st-btn rb-primary",onClick:h,children:"Done"})})]}),Y==="fallback"&&O(G0,{children:[z("p",{className:"rb-error","data-testid":"report-bug-error",children:k}),z("p",{className:"rb-hint",children:"You can save the report locally instead and file it on GitHub yourself — the prefilled issue carries the text; screenshots stay on this machine unless you attach them by hand."}),O("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("preview"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary",onClick:x,children:"Save locally & open GitHub"})]})]})]})]})})}var GJ=x8(r8(),1);function fh(X){if(typeof X!=="string")return null;let J=X.match(/^(\d+)\.(\d+)\.(\d+)/);return J?[Number(J[1]),Number(J[2]),Number(J[3])]:null}function xh(X,J){let Q=fh(X),Y=fh(J);if(!Q)return!1;if(!Y)return!0;for(let W=0;W<3;W++)if(Q[W]!==Y[W])return Q[W]>Y[W];return!1}function hh(X,J){if(!Array.isArray(X))return[];return X.filter((Q)=>Q&&(Q.version==null||xh(Q.version,J)))}function gh(X,J){let Q=J;if(Array.isArray(X)){for(let Y of X)if(Y&&Y.version&&xh(Y.version,Q))Q=Y.version}return Q}var Nw="mdcc-whatsnew-seen",Fw="mdcc-whatsnew-toast-dismissed";function YK0(X){return typeof X==="string"&&/^https?:\/\//i.test(X)}function WK0(X){try{let J=localStorage.getItem(Nw);if(J)return J;localStorage.setItem(Nw,X)}catch{}return X}function GK0(){try{return localStorage.getItem(Fw)}catch{return null}}function mh(X){let[J,Q]=GJ.useState([]),[Y,W]=GJ.useState(X),[G,Z]=GJ.useState(()=>WK0(X)),[H,K]=GJ.useState(()=>GK0()),[U,q]=GJ.useState(!1);GJ.useEffect(()=>{let M=!1,P=()=>{fetch("/_api/whats-new").then(($)=>$.json()).then(($)=>{if(M)return;if(Q(Array.isArray($?.entries)?$.entries:[]),typeof $?.version==="string")W($.version)}).catch(()=>{})};P();let I=()=>P(),k=()=>{if(document.visibilityState==="visible")P()};return window.addEventListener("focus",I),document.addEventListener("visibilitychange",k),()=>{M=!0,window.removeEventListener("focus",I),document.removeEventListener("visibilitychange",k)}},[]);let B=hh(J,G),N=B.length>0&&H!==Y&&!U,F=B[0]??null,D=GJ.useCallback(()=>{let M=gh(J,Y);Z(M),K(Y);try{localStorage.setItem(Nw,M),localStorage.setItem(Fw,Y)}catch{}},[J,Y]),_=GJ.useCallback(()=>{K(Y);try{localStorage.setItem(Fw,Y)}catch{}},[Y]),R=GJ.useCallback(()=>q(!0),[]),w=GJ.useCallback(()=>{q(!1),D()},[D]);return{entries:J,unseen:B,feedVersion:Y,panelOpen:U,openPanel:R,closePanel:w,showToast:N,toastEntry:F,dismissToast:_,markAllSeen:D}}function uh({wn:X}){if(!X.showToast||!X.toastEntry)return null;let J=X.toastEntry,Q=X.unseen.length;return O("div",{className:"st-toast",role:"status","aria-live":"polite",children:[z("button",{type:"button",className:"st-toast-close","aria-label":"Dismiss",onClick:X.dismissToast,children:"×"}),O("div",{className:"st-toast-hd",children:[z("span",{"aria-hidden":"true",children:"✦"}),"What's new",J.version?` · v${J.version}`:""]}),z("div",{className:"st-toast-title",children:J.title}),z("div",{className:"st-toast-txt",children:J.summary}),O("div",{className:"st-toast-actions",children:[z("button",{type:"button",className:"btn btn--primary btn--sm",onClick:X.openPanel,children:Q>1?`See all (${Q})`:"Details"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X.dismissToast,children:"Dismiss"})]})]})}function lh({wn:X,onStartTour:J}){let{panelOpen:Q,closePanel:Y}=X;if(GJ.useEffect(()=>{if(!Q)return;function G(Z){if(Z.key==="Escape")Y()}return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[Q,Y]),!Q)return null;let W=new Set(X.unseen.map((G)=>G.id));return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)Y()},children:O("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[O("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"mdcc-wn-title",children:"✦ What’s new in maude"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:Y,children:"×"})]}),z("div",{className:"mdcc-wn-panel__body",children:X.entries.length===0?z("p",{className:"mdcc-wn-empty",children:"Nothing new yet."}):z("ul",{className:"mdcc-wn-list",children:X.entries.map((G)=>O("li",{className:"mdcc-wn-item"+(W.has(G.id)?" is-unseen":""),children:[O("div",{className:"mdcc-wn-item__hd",children:[z("span",{className:"mdcc-wn-kind mdcc-wn-kind--"+G.kind,children:G.kind}),z("span",{className:"mdcc-wn-item__title",children:G.title}),z("span",{className:"mdcc-wn-item__ver",children:G.version?`v${G.version}`:"next"})]}),z("p",{className:"mdcc-wn-item__summary",children:G.summary}),YK0(G.learnMore)&&z("a",{className:"mdcc-wn-item__more",href:G.learnMore,target:"_blank",rel:"noreferrer",children:"Learn more →"}),J&&Array.isArray(G.tour)&&G.tour.length>0&&z("button",{type:"button",className:"mdcc-wn-item__tour",onClick:()=>{Y(),J(G.tour)},children:"▶ Take tour"})]},G.id))})})]})})}var Y7=({as:X,size:J=14})=>z(X,{size:J,strokeWidth:1.75,style:{display:"block"}}),ee="mdcc-usage-tour-seen",X00="mdcc-collab-tour-seen",c8="__system__",j00="mdcc-theme",J00="mdcc-show-hidden",Q00="mdcc-sections-expanded",Y00="maude-cp-mode",W00="mdcc-sidebar-open",G00="mdcc-minimap-visible",Z00="mdcc-zoomctl-visible",H00="mdcc-annotations-visible";var N20=30000;function F20(X){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(X)}).catch(()=>{})}catch{}}var GT=[{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"}],$K={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",sync:"right",assistant:"right"},z00="mdcc-panel-sides",K00="mdcc-layers-mode";function U00({side:X,width:J,open:Q,ids:Y,activeId:W,onPick:G,children:Z,labels:H=null}){return O("div",{className:"st-dockslot st-dockslot--"+X+(Q?"":" is-collapsed"),style:{width:Q?J:0,flexBasis:Q?J:0},children:[Q&&Y.length>1&&z("div",{className:"st-docktabs",role:"tablist","aria-label":X+" panels",children:Y.map((K)=>z("button",{type:"button",role:"tab","aria-selected":W===K,className:"st-docktab"+(W===K?" is-active":""),onClick:()=>G(K),children:H?.[K]||(GT.find((U)=>U.id===K)||{}).label||K},K))}),Z]})}var GQ=/\.(tsx|html?)$/i,L20=[[/\.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 ZT(X){for(let[J,Q]of L20)if(J.test(X))return Q;return null}function PF(X){return X.replace(/^\.[^/]+\//,"").replace(GQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}var HT="1.0.8";function V00(X,J){let Q=()=>{try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(X,{body:J})}catch{}};if(W9()){y7("send_notification",{title:X,body:J}).catch(Q);return}Q()}function D20(){if(typeof window>"u")return"dark";try{let X=localStorage.getItem(j00);if(X==="light"||X==="dark")return X}catch{}return"dark"}function XH(X,J){if(typeof window>"u")return J;try{let Q=localStorage.getItem(X);if(Q==="1")return!0;if(Q==="0")return!1}catch{}return J}function JT(X,J){if(typeof window>"u")return J;try{let Q=localStorage.getItem(X);return Q?JSON.parse(Q):J}catch{return J}}function O20(X){if(X.kind==="runtime")return!1;if(X.label==="Design system")return!1;return!0}function JH(X){return X.split("/").pop()}function l8(X,J=!1,Q){if(typeof document>"u")return;let Y=document.getElementById("st-op-toast");if(!Y)Y=document.createElement("div"),Y.id="st-op-toast",Y.setAttribute("role","status"),Y.style.cssText="position:fixed;left:50%;bottom:64px;transform:translateX(-50%);z-index:80;display:flex;align-items:center;gap:10px;max-width:440px;padding:8px 14px;border-radius:8px;font:12px/1.45 var(--font-mono,monospace);box-shadow:0 8px 28px rgba(0,0,0,.34);pointer-events:none;opacity:0;transition:opacity 140ms ease;",document.body.appendChild(Y);Y.style.background=J?"#1d3524":"#3a1d1d",Y.style.color=J?"#b7e4c0":"#f1b8b8",Y.textContent="";let W=document.createElement("span");if(W.textContent=X,Y.appendChild(W),Q){let G=document.createElement("button");G.type="button",G.textContent=Q.label,G.style.cssText="pointer-events:auto;background:none;border:0;text-decoration:underline;color:inherit;font:inherit;cursor:pointer;padding:0;",G.onclick=()=>{Q.onClick(),Y.style.opacity="0",Y.style.pointerEvents="none"},Y.appendChild(G)}Y.style.opacity="1",Y.style.pointerEvents=Q?"auto":"none",clearTimeout(l8._t),l8._t=setTimeout(()=>{Y.style.opacity="0",Y.style.pointerEvents="none"},Q?6000:3200)}var q00="maude-mode-hint-seen";function M20(X=!1){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(q00)==="1")return}catch{return}if(document.getElementById("st-browse-hint"))return;let J=document.createElement("div");J.id="st-browse-hint",J.setAttribute("role","status"),J.style.cssText="position:fixed;left:50%;bottom:64px;transform:translateX(-50%);z-index:81;display:flex;align-items:center;gap:10px;max-width:520px;padding:10px 14px;border-radius:10px;font:12px/1.5 var(--font-ui,system-ui,sans-serif);background:var(--surface-2,#1b1e24);color:var(--text-1,#e7eaf0);border:1px solid var(--border-1,#333a45);box-shadow:0 10px 34px rgba(0,0,0,.42);opacity:0;transition:opacity 160ms ease;";let Q='<kbd style="padding:1px 6px;border-radius:5px;border:1px solid var(--border-1,#333a45);background:var(--surface-3,#262b33);font-family:var(--font-mono,monospace)">V</kbd>';J.innerHTML=(X?`<span>Your mock is <strong>live</strong> — click things to try it. Press ${Q} to select &amp; inspect.</span>`:"<span>You’re in <strong>Edit</strong> — click selects, like Figma. "+"Switch to <strong>Preview</strong> in the toolbar to use the live mock.</span>")+'<button type="button" aria-label="Dismiss" style="background:none;border:none;color:inherit;'+'cursor:pointer;font-size:15px;line-height:1;opacity:.65;padding:2px">×</button>';let Y=()=>{try{localStorage.setItem(q00,"1")}catch{}J.style.opacity="0",setTimeout(()=>J.remove(),200),document.removeEventListener("keydown",W,!0)},W=(G)=>{if((G.key==="v"||G.key==="V")&&!G.metaKey&&!G.ctrlKey&&!G.altKey)Y()};if(J.querySelector("button")?.addEventListener("click",Y),X)document.addEventListener("keydown",W,!0);document.body.appendChild(J),requestAnimationFrame(()=>{J.style.opacity="1"}),setTimeout(Y,9000)}function pW(X){return X.replace(GQ,"")}function _20(X){return X.replace(GQ,"")}function A20(X){let J=new Map;for(let G of X){if(!GQ.test(G.name))continue;let Z=_20(G.name);if(!J.has(Z)||/\.tsx$/i.test(G.name))J.set(Z,G)}let Q=new Map,Y=[];for(let G of X){if(GQ.test(G.name))continue;let Z=null;for(let H of J.keys()){if(G.name===H)continue;if(G.name.startsWith(`${H}.`)){if(!Z||H.length>Z.length)Z=H}}if(Z){let H=Q.get(Z)||[];H.push(G),Q.set(Z,H)}else Y.push(G)}let W=[];for(let[G,Z]of J){let H=(Q.get(G)||[]).sort((K,U)=>K.name.localeCompare(U.name));W.push({primary:Z,sidecars:H,orphan:!1})}return W.sort((G,Z)=>G.primary.name.localeCompare(Z.primary.name)),Y.sort((G,Z)=>G.name.localeCompare(Z.name)),{canvases:W,orphans:Y.map((G)=>({primary:G,sidecars:[],orphan:!0}))}}function w20(X,J,Q){let Y={};for(let W of Q||[]){let Z=(W.startsWith(J)?W.slice(J.length).replace(/^\/+/,""):W).split("/").filter(Boolean),H=Y;for(let K of Z)H=H[K]=H[K]||{};H._files=H._files||[]}for(let W of X){let Z=(W.startsWith(J)?W.slice(J.length).replace(/^\/+/,""):W).split("/"),H=Y;for(let K=0;K<Z.length;K++){let U=Z[K];if(K===Z.length-1)H._files=H._files||[],H._files.push({name:U,path:W});else H[U]=H[U]||{},H=H[U]}}return Y}function v00(X,J){if(!J)return X;let Q=J.toLowerCase(),Y={},W=!1,G=Object.keys(X).filter((Z)=>Z!=="_files");for(let Z of G){let H=v00(X[Z],J);if(H)Y[Z]=H,W=!0}if(X._files){let Z=X._files.filter((H)=>H.name.toLowerCase().includes(Q)||H.path.toLowerCase().includes(Q));if(Z.length)Y._files=Z,W=!0}return W?Y:null}function wF(X){return(X||[]).filter((J)=>J.status!=="resolved").length}function E20(X){if(!X)return"";let J=new Date(X).getTime();if(!J)return"";let Q=Math.max(0,Math.floor((Date.now()-J)/1000));if(Q<60)return Q+"s";let Y=Math.floor(Q/60);if(Y<60)return Y+"m";let W=Math.floor(Y/60);if(W<24)return W+"h";let G=Math.floor(W/24);if(G<7)return G+"d";return new Date(X).toLocaleDateString()}function f00(X){let J=0,Q=0,Y=0;for(let W of Object.values(X||{}))for(let G of W||[])if(J++,G.status==="resolved")Y++;else Q++;return{all:J,open:Q,resolved:Y}}function RF({d:X,size:J=14,color:Q}){return z("svg",{width:J,height:J,viewBox:"0 0 24 24",fill:"none",stroke:Q||"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{flex:"none"},children:z("path",{d:X})})}var P20={"chevron-down":z("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":z("polyline",{points:"6 3.5 10.5 8 6 12.5"}),file:O(G0,{children:[z("path",{d:"M4 2h5l3 3v9H4z"}),z("polyline",{points:"9 2 9 5 12 5"})]}),folder:z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),"folder-plus":O(G0,{children:[z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),z("path",{d:"M8 7.5v3.5M6.25 9.25h3.5"})]}),lock:O(G0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015 0v2"})]}),unlock:O(G0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015-.7"})]}),search:O(G0,{children:[z("circle",{cx:"7",cy:"7",r:"4"}),z("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:O(G0,{children:[z("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),z("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),check:z("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),x:O(G0,{children:[z("line",{x1:"4.3",y1:"4.3",x2:"11.7",y2:"11.7"}),z("line",{x1:"11.7",y1:"4.3",x2:"4.3",y2:"11.7"})]}),sun:O(G0,{children:[z("circle",{cx:"8",cy:"8",r:"2.6"}),z("line",{x1:"8",y1:"1.5",x2:"8",y2:"3"}),z("line",{x1:"8",y1:"13",x2:"8",y2:"14.5"}),z("line",{x1:"1.5",y1:"8",x2:"3",y2:"8"}),z("line",{x1:"13",y1:"8",x2:"14.5",y2:"8"}),z("line",{x1:"3.4",y1:"3.4",x2:"4.4",y2:"4.4"}),z("line",{x1:"11.6",y1:"11.6",x2:"12.6",y2:"12.6"}),z("line",{x1:"12.6",y1:"3.4",x2:"11.6",y2:"4.4"}),z("line",{x1:"4.4",y1:"11.6",x2:"3.4",y2:"12.6"})]}),moon:z("path",{d:"M12.5 9.6A5 5 0 1 1 7 3a4 4 0 0 0 5.5 6.6z"}),sparkle:z("path",{d:"M8 1.8l1.4 4.8L14 8l-4.6 1.4L8 14.2l-1.4-4.8L2 8l4.6-1.4z",fill:"currentColor",stroke:"none"}),megaphone:O(G0,{children:[z("path",{d:"M2 6.7 11 4v8L2 9.3z"}),z("path",{d:"M11 5.2a2.4 2.4 0 0 1 0 5.6"}),z("path",{d:"M4.3 9.5v2.3a1.2 1.2 0 0 0 2.4 0v-1.7"})]}),bug:O(G0,{children:[z("circle",{cx:"8",cy:"9",r:"3.6"}),z("circle",{cx:"8",cy:"4.4",r:"1.3"}),z("path",{d:"M6.2 3.4 5.2 2M9.8 3.4l1-1.4"}),z("path",{d:"M4.6 7.6H2.2M4.6 9H2.2M4.6 10.6H2.5M11.4 7.6h2.4M11.4 9h2.4M11.4 10.6h2.3"})]}),"panel-left":O(G0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("line",{x1:"6.4",y1:"3",x2:"6.4",y2:"13"})]}),resolve:O(G0,{children:[z("circle",{cx:"8",cy:"8",r:"5.6"}),z("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:O(G0,{children:[z("path",{d:"M3.2 8a5 5 0 1 1 1.4 3.5"}),z("polyline",{points:"3.2 11.4 3.2 8 6.6 8"})]}),layers:O(G0,{children:[z("polygon",{points:"8 2.2 13.8 5.5 8 8.8 2.2 5.5"}),z("polyline",{points:"2.2 9 8 12.3 13.8 9"})]}),box:z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.2"}),type:O(G0,{children:[z("polyline",{points:"4 4 12 4"}),z("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:O(G0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"3"}),z("line",{x1:"6",y1:"8",x2:"10",y2:"8"})]}),input:O(G0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"1.2"}),z("line",{x1:"5",y1:"8",x2:"5",y2:"8"})]}),link:O(G0,{children:[z("path",{d:"M6.5 9.5a2.5 2.5 0 0 1 0-3.5l1.5-1.5a2.5 2.5 0 0 1 3.5 3.5l-1 1"}),z("path",{d:"M9.5 6.5a2.5 2.5 0 0 1 0 3.5l-1.5 1.5a2.5 2.5 0 0 1-3.5-3.5l1-1"})]}),list:O(G0,{children:[z("line",{x1:"6",y1:"4.5",x2:"13",y2:"4.5"}),z("line",{x1:"6",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6",y1:"11.5",x2:"13",y2:"11.5"}),z("circle",{cx:"3.2",cy:"4.5",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"8",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"11.5",r:"0.8",fill:"currentColor"})]}),eye:O(G0,{children:[z("path",{d:"M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z"}),z("circle",{cx:"8",cy:"8",r:"2"})]}),eyedropper:O(G0,{children:[z("path",{d:"M11 2.6a1.7 1.7 0 0 1 2.4 2.4l-1.2 1.2-2.4-2.4z"}),z("path",{d:"M9.5 4.6 4 10.1V12h1.9l5.5-5.5"})]}),"p-corner":z("path",{d:"M3.5 12.5V7a3.5 3.5 0 0 1 3.5-3.5h5.5"}),"p-opacity":O(G0,{children:[z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.5"}),z("path",{d:"M3 8h10M8 3v10",strokeWidth:"0.9",opacity:"0.55"})]}),"p-lineheight":O(G0,{children:[z("line",{x1:"6.5",y1:"4",x2:"13",y2:"4"}),z("line",{x1:"6.5",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6.5",y1:"12",x2:"13",y2:"12"}),z("path",{d:"M3.2 4.6 3.2 11.4M2 6 3.2 4.5 4.4 6M2 10 3.2 11.5 4.4 10"})]}),"p-letterspacing":O(G0,{children:[z("path",{d:"M3 4v8M13 4v8"}),z("path",{d:"M6 11.5 8 5l2 6.5M6.7 9.3h2.6",strokeWidth:"1.1"})]}),"p-gap":O(G0,{children:[z("rect",{x:"2",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("rect",{x:"10.4",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("path",{d:"M6.8 8h2.4M7.4 6.9 6.4 8l1 1.1M8.6 6.9 9.6 8l-1 1.1",strokeWidth:"1"})]}),"p-border":z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"}),"p-size":O(G0,{children:[z("path",{d:"M3 13 6.6 3l3.6 10"}),z("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":O(G0,{children:[z("path",{d:"M6.3 4A6.7 6.7 0 0 1 8 3.5C12 3.5 14.5 8 14.5 8a12 12 0 0 1-2 2.4M4.4 5.3A12 12 0 0 0 1.5 8S4 12.5 8 12.5a6.5 6.5 0 0 0 2.1-.35"}),z("line",{x1:"2.5",y1:"2.5",x2:"13.5",y2:"13.5"})]}),sliders:O(G0,{children:[z("line",{x1:"3",y1:"5",x2:"13",y2:"5"}),z("circle",{cx:"6",cy:"5",r:"1.7",fill:"currentColor"}),z("line",{x1:"3",y1:"11",x2:"13",y2:"11"}),z("circle",{cx:"10",cy:"11",r:"1.7",fill:"currentColor"})]}),code:O(G0,{children:[z("polyline",{points:"6 5 3 8 6 11"}),z("polyline",{points:"10 5 13 8 10 11"})]}),download:O(G0,{children:[z("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),z("polyline",{points:"4.5 7 8 10.5 11.5 7"}),z("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),reload:O(G0,{children:[z("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),z("path",{d:"M14 2v3.33h-3.33"})]}),help:O(G0,{children:[z("circle",{cx:"8",cy:"8",r:"6"}),z("path",{d:"M6.3 6.2a1.8 1.8 0 1 1 2.3 1.9c-.5.2-.6.5-.6 1v.3"}),z("line",{x1:"8",y1:"11.4",x2:"8",y2:"11.5"})]}),image:O(G0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("circle",{cx:"6",cy:"6.3",r:"1.1"}),z("path",{d:"M3 12l3-2.8 2.2 1.8 2.4-3L13.5 12"})]}),vector:O(G0,{children:[z("path",{d:"M3.6 11.2C6 5 10 5 12.4 11.2"}),z("rect",{x:"1.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"11.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"6.7",y:"2.6",width:"2.6",height:"2.6",rx:"0.4"})]}),presentation:O(G0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"7.4",rx:"1"}),z("line",{x1:"8",y1:"10.4",x2:"8",y2:"13"}),z("line",{x1:"5.6",y1:"13.4",x2:"10.4",y2:"13.4"})]}),archive:O(G0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"3",rx:"0.8"}),z("path",{d:"M3.6 6v6.2a1 1 0 0 0 1 1h6.8a1 1 0 0 0 1-1V6"}),z("line",{x1:"6.6",y1:"8.8",x2:"9.4",y2:"8.8"})]}),external:O(G0,{children:[z("path",{d:"M11 8.5V12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h3.5"}),z("polyline",{points:"9.5 3 13 3 13 6.5"}),z("line",{x1:"13",y1:"3",x2:"7.6",y2:"8.4"})]}),share:O(G0,{children:[z("circle",{cx:"4",cy:"8",r:"1.9"}),z("circle",{cx:"11.6",cy:"3.6",r:"1.9"}),z("circle",{cx:"11.6",cy:"12.4",r:"1.9"}),z("line",{x1:"5.7",y1:"7",x2:"9.9",y2:"4.6"}),z("line",{x1:"5.7",y1:"9",x2:"9.9",y2:"11.4"})]}),pen:O(G0,{children:[z("path",{d:"M3 13l.8-3L10.6 3.2a1.1 1.1 0 0 1 1.6 0l.6.6a1.1 1.1 0 0 1 0 1.6L6 12.2z"}),z("line",{x1:"9.6",y1:"4.2",x2:"11.8",y2:"6.4"})]}),square:z("rect",{x:"3.5",y:"3.5",width:"9",height:"9",rx:"1"})};function R20({open:X,onClose:J,actions:Q}){let[Y,W]=u.useState(""),[G,Z]=u.useState(0),H=u.useRef(null);u.useEffect(()=>{if(X)W(""),Z(0)},[X]),u.useEffect(()=>{H.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[G]);let K=u.useMemo(()=>{let q=Y.trim().toLowerCase();if(!q)return Q;return Q.filter((B)=>B.label.toLowerCase().includes(q)||B.group&&B.group.toLowerCase().includes(q))},[Y,Q]);if(u.useEffect(()=>{if(G>=K.length)Z(0)},[K.length,G]),!X)return null;let U=(q)=>{J(),q.run()};return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(q)=>{if(q.target===q.currentTarget)J()},children:O("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[O("div",{className:"st-pal-search",children:[z(E9,{name:"search",size:18}),z("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(q)=>W(q.target.value),onKeyDown:(q)=>{if(q.key==="Escape")q.preventDefault(),J();else if(q.key==="ArrowDown")q.preventDefault(),Z((B)=>Math.min(K.length-1,B+1));else if(q.key==="ArrowUp")q.preventDefault(),Z((B)=>Math.max(0,B-1));else if(q.key==="Enter"){if(q.preventDefault(),K[G])U(K[G])}}}),z(wX,{children:"⌘K"})]}),z("div",{className:"st-pal-list",ref:H,children:K.length===0?z("div",{className:"st-pal-empty",children:"No matching command."}):K.map((q,B)=>{let N=q.group&&(B===0||K[B-1].group!==q.group)?z("div",{className:"st-pal-group",children:q.group},"g-"+q.group):null;return O(G0,{children:[N,O("button",{type:"button",className:"st-pal-item"+(B===G?" is-active":""),onMouseEnter:()=>Z(B),onClick:()=>U(q),children:[z("span",{className:"st-pal-icon",children:z(E9,{name:q.icon,size:15})}),z("span",{className:"st-pal-label",children:q.label}),q.kbd?z("span",{className:"st-pal-kbd",children:z(wX,{children:q.kbd})}):null]})]},q.id)})})]})})}function E9({name:X,size:J=16,className:Q}){return z("svg",{className:Q,width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:P20[X]})}function T20(X){if(!X||typeof X!=="string")return"?";let J=X.trim().split(/[\s._-]+/).filter(Boolean);if(!J.length)return"?";if(J.length===1)return J[0].slice(0,2).toUpperCase();return((J[0][0]||"")+(J[J.length-1][0]||"")).toUpperCase()||"?"}function B00({initials:X,hue:J,title:Q,pulse:Y}){return z("span",{className:"st-avatar"+(Y?" is-pulsing":""),style:{"--av-hue":J},"data-tip":Q,"aria-label":Q,children:X})}function wX({children:X}){return z("span",{className:"kbd",children:X})}function N00(X,{min:J,max:Q,def:Y}){let W=u.useCallback((K)=>Math.min(Q,Math.max(J,K)),[J,Q]),[G,Z]=u.useState(()=>{try{let K=parseInt(localStorage.getItem(X)||"",10);return Number.isFinite(K)?W(K):Y}catch{return Y}});u.useEffect(()=>{try{localStorage.setItem(X,String(G))}catch{}},[X,G]);let H=u.useCallback((K)=>Z((U)=>W(typeof K==="function"?K(U):K)),[W]);return{w:G,setW:H,min:J,max:Q,def:Y}}function F00({label:X,size:J,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:K,def:U}=J,q=W==="rtl"?-1:1;return z("div",{className:"st-grip"+(Y?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":X,"aria-valuemin":H,"aria-valuemax":K,"aria-valuenow":Math.round(G),onPointerDown:Q,onDoubleClick:()=>Z(U),onKeyDown:(B)=>{let N=B.shiftKey?24:8;if(B.key==="ArrowRight")B.preventDefault(),Z((F)=>F+N*q);else if(B.key==="ArrowLeft")B.preventDefault(),Z((F)=>F-N*q);else if(B.key==="Home")B.preventDefault(),Z(H);else if(B.key==="End")B.preventDefault(),Z(K)},children:O("svg",{className:"st-grip-dots",viewBox:"0 0 6 18","aria-hidden":"true",children:[z("circle",{cx:"3",cy:"3",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"9",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"15",r:"1.1",fill:"currentColor"})]})})}var QT=[{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}],L00={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},I20=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],j3=[{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}],k20="2x",D00=[{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}],C20="auto",$20={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 S20(X){let J=String(X||"").split(".").pop()?.toLowerCase();return $20[J]||"application/octet-stream"}function b20({designRel:X,onPick:J,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[Z,H]=u.useState(null),[K,U]=u.useState(!1),[q,B]=u.useState(null),[N,F]=u.useState(()=>new Set),[D,_]=u.useState({}),[R,w]=u.useState(W?"artboard":"annotation");u.useEffect(()=>{let x=!0;return fetch("/_api/assets").then((m)=>m.json()).then((m)=>{if(!x)return;let p=m.ok?m.assets:[];H(p),_((v)=>{let r={...v};for(let a of p)r[a.path]=a.kind;return r})}).catch(()=>x&&H([])),()=>{x=!1}},[]),u.useEffect(()=>{let x=(m)=>{if(m.key==="Escape")m.stopPropagation(),Q()};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[Q]);let M=Array.from(N).some((x)=>(D[x]||"image")!=="image"),P=!W||M,I=!W?"No artboard on this canvas":M?"Video/audio can only be added as annotations":"";u.useEffect(()=>{if(P&&R==="artboard")w("annotation")},[P,R]);let k=(x)=>{F((m)=>{let p=new Set(m);if(p.has(x))p.delete(x);else p.add(x);return p})},$=async(x)=>{let m=await fetch("/_api/asset",{method:"POST",headers:{"content-type":x.type||"application/octet-stream"},body:x}),p=await m.json().catch(()=>({}));if(m.ok&&p.path)return{ok:!0,path:p.path};return{ok:!1,error:p.error||`upload failed (HTTP ${m.status})`}},C=async(x)=>{if(!x)return;U(!0),B(null);let m=await $(x);if(U(!1),m.ok)J(m.path);else B(m.error)},y=(x)=>{if(typeof x==="string"&&x.startsWith("video/"))return"video";if(typeof x==="string"&&x.startsWith("audio/"))return"audio";return"image"},f=async(x)=>{if(!x.length)return;U(!0),B(null);let m=await Promise.all(x.map((r)=>$(r).then((a)=>({...a,file:r}))));U(!1);let p=m.filter((r)=>r.ok),v=m.length-p.length;if(v>0)B(`${v} of ${m.length} uploads failed`);if(p.length)_((r)=>{let a={...r};for(let c of p)a[c.path]=y(c.file.type);return a}),F((r)=>{let a=new Set(r);for(let c of p)a.add(c.path);return a})},h=async()=>{U(!0),B(null);try{if(Y){let p=(await nf()||[]).map((v)=>new File([new Uint8Array(v.bytes)],v.name,{type:S20(v.name)}));if(U(!1),p.length)await f(p);return}let x=await OZ();if(x?.bytes){await C(new Blob([new Uint8Array(x.bytes)]));return}}catch(x){B(x?.message||"open failed")}U(!1)},d=()=>{if(W9()){h();return}let x=document.createElement("input");if(x.type="file",x.accept="image/*,video/*",Y)x.multiple=!0;x.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(x);let m=()=>{if(x.isConnected)x.remove()};window.addEventListener("focus",()=>setTimeout(m,300),{once:!0}),x.addEventListener("change",()=>{let p=x.files?Array.from(x.files):[];if(m(),!p.length)return;if(Y)f(p);else C(p[0])}),x.click()},n=(x)=>`/${X}/${x}`;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(x)=>{if(x.target===x.currentTarget)Q()},children:O("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[O("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Choose media"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:Q,children:z(E9,{name:"x",size:15})})]}),O("div",{className:"st-dialog-bd",children:[O("div",{className:"st-ap-toolbar",children:[z("button",{type:"button",className:"st-btn",onClick:d,disabled:K,children:K?"Uploading…":"Upload…"}),q&&z("span",{className:"st-ap-err",children:q})]}),z("div",{className:"st-ap-grid",children:Z==null?z("div",{className:"st-ap-empty",children:"Loading…"}):Z.length===0?z("div",{className:"st-ap-empty",children:"No assets yet — upload one."}):Z.map((x)=>{let m=Y&&N.has(x.path);return O("button",{type:"button",className:"st-ap-cell","data-selected":m?"true":void 0,"aria-pressed":Y?m:void 0,title:`${x.name} · ${Math.max(1,Math.round(x.size/1024))} KB`,onClick:()=>Y?k(x.path):J(x.path),children:[Y&&z("span",{className:"st-ap-check","aria-hidden":"true",children:m?z(E9,{name:"check",size:12}):null}),x.kind==="video"?z("video",{className:"st-ap-thumb",src:n(x.path),muted:!0,playsInline:!0}):z("img",{className:"st-ap-thumb",src:n(x.path),alt:x.name,loading:"lazy"}),z("span",{className:"st-ap-name",children:x.name})]},x.path)})})]}),Y&&N.size>0&&O("div",{className:"st-dialog-ft st-ap-confirm",children:[O("span",{className:"st-ap-count",children:[N.size," selected"]}),O("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":R==="artboard",disabled:P,onClick:()=>w("artboard"),children:"Add to artboard"}),z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":R==="annotation",onClick:()=>w("annotation"),children:"Add as annotation"})]}),P&&z("span",{className:"st-ap-dest-note",children:I}),z("span",{className:"st-ap-confirm-spacer"}),z("button",{type:"button",className:"btn btn--ghost",onClick:Q,children:"Cancel"}),z("button",{type:"button",className:"btn btn--primary",onClick:()=>G?.(Array.from(N),R),children:"Insert"})]})]})})}function TF(X,J){let Q=URL.createObjectURL(J),Y=document.createElement("a");Y.href=Q,Y.download=X||"export",document.body.appendChild(Y),Y.click(),Y.remove(),setTimeout(()=>URL.revokeObjectURL(Q),1e4)}function y20({mode:X,initialScope:J,activePath:Q,hasComps:Y=!1,comps:W=[],activeArtboardId:G=null,selection:Z=null,exportLane:H="local",onBrowserCapture:K=null,onClose:U}){let q=u.useCallback((P0)=>H==="none"&&!P0.handoff&&P0.format!=="zip"&&!wS.has(P0.format)||H!=="local"&&P0.format==="canva",[H]),[B,N]=u.useState(X==="handoff"?"shadcn":"png"),[F,D]=u.useState(()=>J&&FS("png",J)?J:yO("png")),[_,R]=u.useState(2),[w,M]=u.useState(k20),[P,I]=u.useState(!0),[k,$]=u.useState(!1),[C,y]=u.useState(!1),[f,h]=u.useState(!1),[d,n]=u.useState(C20),[x,m]=u.useState(!0),[p,v]=u.useState(!1),[r,a]=u.useState(null),[c,U0]=u.useState([]),o=QT.find((P0)=>P0.id===B)||QT[0],Z0=o.handoff?[]:jO(o.format),e=900,N0=3600,K0=GK(W,lA(W,{artboardId:G})),u0=K0?.durationInFrames||0,Q8=K0?.fps||30,o0=o.temporal&&u0>900,_8=o.temporal&&u0>3600;u.useEffect(()=>{if(Z0.length&&!Z0.includes(F))D(yO(o.format))},[Z0,F,o.format]),u.useEffect(()=>{if(H!=="remote")return;fetch("/_api/export-warmup").catch(()=>{})},[H]);let A0=u.useCallback(()=>{fetch("/_api/export-history").then((P0)=>P0.json()).then((P0)=>U0(Array.isArray(P0?.history)?P0.history.slice(0,6):[])).catch(()=>{})},[]);u.useEffect(()=>{A0()},[A0]),u.useEffect(()=>{function P0(K8){if(K8.key==="Escape")K8.preventDefault(),U()}return window.addEventListener("keydown",P0),()=>window.removeEventListener("keydown",P0)},[U]);async function r0(){if(o.handoff){let D8=`/design:handoff ${Q&&Q!==c8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(D8)}catch{}a({ok:!0,msg:`Copied: ${D8} — run it in Claude Code.`});return}if(q(o)){a({ok:!1,msg:"This format needs the render service, which this workspace doesn’t have configured."});return}v(!0),a(null);let P0=o.temporal?{scale:_}:{};if(o.format==="png"){let F8=j3.find((D8)=>D8.id===w)||j3[1];if(F8.kind==="dpi")P0.dpi=F8.value;else P0.scale=F8.value}if(o.format==="mp4"||o.format==="webm")P0.audio=x;if(_8)P0.maxFrames=u0;if(o.format==="pdf"){P0.pdfPrint={includeBleed:P,marks:{crop:C,registration:f}};let F8=D00.find((D8)=>D8.id===d)?.value;if(F8!==void 0)P0.dpi=F8}if(G)P0.artboardId=G;if(Z?.selector)P0.selection=Z;if(Q&&Q!==c8)P0.canvasFile=Q;if(zU.has(o.format)&&O2({exportLane:H,format:o.format,scope:F,artboardId:P0.artboardId})&&typeof K==="function")try{let F8=mO(P0);a({ok:!0,msg:"Capturing…"});let D8=await K({format:o.format,artboardIds:[P0.artboardId],scale:F8,onProgress:(A8,i8)=>a({ok:!0,msg:`Capturing ${A8}/${i8}…`})}),W8=await gO(D8,o.format);for(let A8 of W8)TF(A8.name,A8.blob);for(let A8 of W8)await uO({format:o.format,scope:F,filename:A8.name});v(!1),a({ok:!0,msg:`Saved ${W8.map((A8)=>A8.name).join(", ")} to your downloads.`});return}catch(F8){if(H!=="remote"){a({ok:!1,msg:`Capture failed: ${F8&&F8.message||F8}`}),v(!1);return}}if(O2({exportLane:H,format:o.format,scope:F})&&o.format==="pptx"&&typeof K==="function")try{a({ok:!0,msg:"Capturing artboards…"});let F8=Q&&Q!==c8?JH(Q).replace(/\.[^.]+$/,""):"export",{filename:D8,blob:W8}=await hO({capture:K,name:F8,onProgress:(A8,i8)=>a({ok:!0,msg:`Capturing ${A8}/${i8}…`}),onAssemble:()=>a({ok:!0,msg:"Assembling deck…"})});TF(D8,W8),await uO({format:o.format,scope:F,filename:D8}),v(!1),a({ok:!0,msg:`Saved ${D8} to your downloads.`});return}catch(F8){if(H!=="remote"){a({ok:!1,msg:`Deck export failed: ${F8&&F8.message||F8}`}),v(!1);return}}if(H==="none"&&zU.has(o.format)){a({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."}),v(!1);return}try{let F8=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:o.format,scope:F,options:P0})});if(!F8.ok){a({ok:!1,msg:await F8.text()||`Export failed (${F8.status})`}),v(!1);return}U()}catch(F8){a({ok:!1,msg:F8&&F8.message?F8.message:String(F8)}),v(!1)}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(P0)=>{if(P0.target===P0.currentTarget)U()},children:O("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[O("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Export & handoff"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:U,children:z(E9,{name:"x",size:15})})]}),O("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:Q&&Q!==c8?`Format · ${pW(JH(Q))}`:"Format"}),z("div",{className:"st-fmt-grid",children:QT.filter((P0)=>!P0.temporal||Y).map((P0)=>O("button",{type:"button","data-testid":`export-format-${P0.id}`,className:"st-fmt"+(P0.id===B?" is-on":""),disabled:q(P0),title:q(P0)?"Needs the render service — not configured on this workspace":void 0,onClick:()=>{N(P0.id),a(null)},children:[z(E9,{name:P0.icon,size:16}),z("span",{className:"st-fmt-name",children:P0.label}),z("span",{className:"st-fmt-sub",children:P0.sub})]},P0.id))}),H==="none"&&O("div",{className:"st-dialog-note","data-testid":"export-lane-note",children:["PNG and SVG of the active artboard — and the PPTX deck — export right here in your browser; ZIP and AI handoff work too. PDF, video and other multi-artboard exports need the render service, which this workspace doesn't have configured — use the desktop app, or ask your admin to add the ",z("code",{children:" maude-render"})," service (see the self-hosting docs)."]}),!o.handoff&&O("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-scope",children:"Scope"}),z("select",{id:"st-export-scope","data-testid":"export-scope",className:"st-select",value:F,onChange:(P0)=>D(P0.target.value),children:Z0.map((P0)=>z("option",{value:P0,children:L00[P0]},P0))})]}),!o.handoff&&o.format==="png"&&O("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-size",children:"Resolution"}),z("select",{id:"st-export-size",className:"st-select",value:w,onChange:(P0)=>M(P0.target.value),children:j3.map((P0)=>z("option",{value:P0.id,children:P0.label},P0.id))})]}),!o.handoff&&o.format==="png"&&z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let P0=j3.find((F8)=>F8.id===w)||j3[1],K8=P0.kind==="dpi"?P0.value/96:P0.value;return`${P0.label} ≈ ${Math.round(1440*K8)}×${Math.round(900*K8)} for a 1440×900 artboard.`})()}),!o.handoff&&o.temporal&&O("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-temporal-size",children:"Resolution"}),z("select",{id:"st-export-temporal-size",className:"st-select",value:_,onChange:(P0)=>R(Number(P0.target.value)),children:I20.map((P0)=>z("option",{value:P0.value,children:P0.label},P0.value))})]}),!o.handoff&&o.temporal&&O("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[_,"× the artboard's native resolution (e.g. 960×540 → ",960*_,"×",540*_,")."]}),o0&&O("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: ",u0," frames (≈",Math.round(u0/Q8),"s).",_8?` Exceeds the default ${"3600"}-frame export cap — exporting raises the cap to the full length for this run.`:""," ","If the fast renderer falls back to frame-by-frame capture this can take several minutes; 2× resolution (≈720–1080p) is recommended for memory headroom."]}),!o.handoff&&o.format==="pdf"&&O(G0,{children:[O("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-dpi",children:"Image quality"}),z("select",{id:"st-export-pdf-dpi",className:"st-select",value:d,onChange:(P0)=>n(P0.target.value),children:D00.map((P0)=>z("option",{value:P0.id,children:P0.label},P0.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:"The page stays vector; this only sets the capture density for raster content on it (dropped photos, large-format art)."}),z("div",{className:"st-dialog-row",children:O("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-bleed",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-pdf-bleed",type:"checkbox",checked:P,onChange:(P0)=>I(P0.target.checked)}),"Include bleed"]})}),z("div",{className:"st-dialog-row",children:O("button",{type:"button",className:"st-dialog-lbl",style:{background:"none",border:0,padding:0,cursor:"pointer"},onClick:()=>$((P0)=>!P0),"aria-expanded":k,children:[k?"▾":"▸"," Marks"]})}),k&&O("div",{style:{padding:"0 12px 4px",display:"flex",flexDirection:"column",gap:6},children:[O("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:C,onChange:(P0)=>y(P0.target.checked)}),"Crop marks"]}),O("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:f,onChange:(P0)=>h(P0.target.checked)}),"Registration marks"]})]}),O("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:["Bleed and marks apply to print (",z("code",{children:'kind="print"'}),") artboards only.",F==="canvas-as-separate"?" One PDF page per artboard.":""]})]}),!o.handoff&&(o.format==="mp4"||o.format==="webm")&&z("div",{className:"st-dialog-row",children:O("label",{className:"st-dialog-lbl",htmlFor:"st-export-audio",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-audio",type:"checkbox",checked:x,onChange:(P0)=>m(P0.target.checked)}),"Export with audio"]})}),o.handoff&&O("div",{className:"callout callout--info",style:{fontSize:12},children:["Hands the active canvas off to production. Copies"," ",z("span",{className:"st-mono",children:"/design:handoff <path>"})," — run it in Claude Code to emit a ready-to-drop production component next to the canvas."]}),r&&z("div",{className:"callout "+(r.ok?"callout--success":"callout--error"),style:{fontSize:12},"data-testid":"export-status","data-ok":r.ok?"1":"0",children:r.msg}),c.length>0&&O("div",{className:"st-export-recent","data-testid":"export-recent",children:[z("div",{className:"st-rp-hd",children:"Recent"}),c.map((P0,K8)=>O("div",{className:"st-export-recent-row",children:[O("span",{children:[String(P0.format||"").toUpperCase()," ·"," ",L00[P0.scope]||P0.scope]}),z("span",{className:"st-mono",children:P0.filename})]},K8))]})]}),O("div",{className:"st-dialog-ft",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:U,children:"Cancel"}),O("button",{type:"button",className:"btn btn--primary","data-testid":"export-submit",disabled:p,onClick:r0,children:[z(E9,{name:"download",size:14}),o.handoff?"Copy handoff command":p?"Exporting…":`Export ${o.label}`]})]})]})})}var CF=12,$F=16;function j20({name:X,depth:J,defaultOpen:Q,children:Y,dirPath:W,drag:G,menu:Z}){let[H,K]=u.useState(Q),U=G?G.dropProps(W,!0,()=>K(!0)):{},q=G?.overDir===W,B=G?G.dragProps(W,!0):{},N=G?.draggedPath===W,F=G?.busyPath===W,D=O("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${PF(W)}`,"aria-expanded":H,"aria-dropeffect":G?"move":void 0,"aria-busy":F||void 0,tabIndex:-1,className:"st-row"+(q?" is-drop-target":"")+(N?" is-dragging":"")+(F?" is-busy":""),style:{paddingLeft:CF+J*$F+"px"},onClick:()=>K((_)=>!_),onContextMenu:Z?(_)=>Z.openAt(_,{kind:"dir",dirPath:W}):void 0,...B,...U,children:[z("span",{className:"st-row-glyph",children:z(E9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:X})]});return O(G0,{children:[Z?O("div",{className:"st-row-wrap",role:"none",children:[D,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${PF(W)}`,title:`Folder actions — ${X}`,"aria-label":`Folder actions for ${X}`,"aria-haspopup":"menu",onClick:(_)=>Z.openAt(_,{kind:"dir",dirPath:W}),children:z(RF,{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})})]}):D,H&&Y]})}function v20({name:X,dsName:J,depth:Q,defaultOpen:Y,active:W,onOpenSystem:G,children:Z}){let[H,K]=u.useState(Y);return O(G0,{children:[O("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:CF+Q*$F+"px"},role:"treeitem","aria-expanded":H,children:[z("button",{type:"button",className:"st-ds-chev",onClick:()=>K((U)=>!U),"aria-label":H?"Collapse design system":"Expand design system",title:H?"Collapse":"Expand",children:z(E9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),O("button",{type:"button",className:"st-ds-open",onClick:()=>G(J),"aria-label":`Open ${J} design system view`,title:"Open the design system view",children:[z("span",{className:"st-row-glyph",children:z(E9,{name:"folder",size:13})}),z("span",{className:"st-row-name",children:X})]})]}),H&&Z]})}function IF({file:X,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,onDelete:G,openCount:Z,depth:H,kind:K,sidecar:U,dirty:q,experimentalKind:B,drag:N,menu:F}){let D=X.path===J||X.path===Q,_=GQ.test(X.name),R=!_&&K!=="runtime"?ZT(X.name):null,w=!_&&!R,M=_?pW(X.name):X.name,P=_&&typeof G==="function"&&K!=="runtime",I=_&&!U&&K!=="runtime"&&typeof N<"u",k=I?N.dragProps(X.path,!0):{},$=N?.draggedPath===X.path,C=N?.busyPath===X.path,y=I&&typeof F<"u",f=X.path.split("/").slice(0,-1).join("/"),h=_?"canvas-row-"+X.path.replace(/^\.[^/]+\//,"").replace(GQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,d=O("button",{type:"button",role:"treeitem","data-testid":h,"aria-selected":D,"aria-disabled":w?"true":void 0,"aria-busy":C||void 0,tabIndex:D?0:-1,className:"st-row"+(D?" is-sel":"")+(K==="runtime"?" is-muted":"")+($?" is-dragging":"")+(C?" is-busy":""),style:{paddingLeft:CF+H*$F+"px"},title:X.path+(Z?` — ${Z} open`:w?" (file index only)":""),onClick:()=>{if(_)Y(X.path);else if(R)W?.(X.path)},onContextMenu:y?(n)=>F.openAt(n,{kind:"file",path:X.path,dir:f}):void 0,...k,children:[z("span",{className:"st-row-glyph",children:z(E9,{name:"file",size:13})}),z("span",{className:"st-row-name",children:M}),B==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),B==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),q&&z("span",{className:"st-git-badge","data-kind":q,title:`Unsaved (${q})`,"aria-label":`Unsaved, ${q}`,children:q}),Z>0&&z("span",{className:"st-row-badge",children:Z})]});if(!P&&!y)return d;return O("div",{className:"st-row-wrap",role:"none",children:[d,y&&z("button",{type:"button",className:"st-row-menu-btn"+(P?" has-delete-sibling":""),"data-testid":`tree-row-menu-${PF(X.path)}`,title:`Move ${M}…`,"aria-label":`Actions for ${M}`,"aria-haspopup":"menu",onClick:(n)=>F.openAt(n,{kind:"file",path:X.path,dir:f}),children:z(RF,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})}),P&&z("button",{type:"button",className:"st-row-del",title:`Delete ${M}`,"aria-label":`Delete canvas ${M}`,onClick:(n)=>{n.stopPropagation(),G(X.path,M)},children:z(RF,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})}function f20({primary:X,sidecars:J,depth:Q,kind:Y,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,showHidden:q,forceOpen:B,dirtyByPath:N,experimentalKind:F,drag:D,menu:_}){let R=N?.get(X.path),w=J.length>0,[M,P]=u.useState(!1),I=B||M,k=X.path===W;if(!(w&&q))return z(IF,{file:X,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,depth:Q,kind:Y,dirty:R,experimentalKind:F,drag:D,menu:_});let C=typeof D<"u",y=C?D.dragProps(X.path,!0):{},f=D?.draggedPath===X.path,h=D?.busyPath===X.path,d=C&&typeof _<"u",n=X.path.split("/").slice(0,-1).join("/"),x=O("button",{type:"button",role:"treeitem","aria-selected":k,"aria-expanded":I,"aria-busy":h||void 0,tabIndex:k?0:-1,className:"st-row st-canvas-row"+(k?" is-sel":"")+(f?" is-dragging":"")+(h?" is-busy":""),style:{paddingLeft:CF+Q*$F+"px"},title:X.path,onClick:(m)=>{if(m.target.closest(".st-canvas-chev")){P((p)=>!p);return}Z(X.path)},onContextMenu:d?(m)=>_.openAt(m,{kind:"file",path:X.path,dir:n}):void 0,...y,children:[z("span",{className:"st-row-glyph st-canvas-chev",onClick:(m)=>{m.stopPropagation(),P((p)=>!p)},children:z(E9,{name:"chevron-right",className:"st-chev"+(I?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:pW(X.name)}),F==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),F==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),R&&z("span",{className:"st-git-badge","data-kind":R,title:`Unsaved (${R})`,"aria-label":`Unsaved, ${R}`,children:R}),U>0&&z("span",{className:"st-row-badge",children:U})]});return O(G0,{children:[d?O("div",{className:"st-row-wrap",role:"none",children:[x,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${PF(X.path)}`,title:`Move ${pW(X.name)}…`,"aria-label":`Actions for ${pW(X.name)}`,"aria-haspopup":"menu",onClick:(m)=>_.openAt(m,{kind:"file",path:X.path,dir:n}),children:z(RF,{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})})]}):x,I&&J.map((m)=>z(IF,{file:m,activePath:W,previewPath:G,onOpen:Z,onPreview:H,openCount:0,depth:Q+1,kind:Y,sidecar:!0},m.path))]})}function x00({node:X,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z=1,kind:H,showHidden:K,search:U,dsFolders:q,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:D,canvasKinds:_,dirPath:R="",drag:w,menu:M}){let P=Object.keys(X).filter((d)=>d!=="_files").sort(),I=X._files||[],{canvases:k,orphans:$}=u.useMemo(()=>A20(I),[I]),{mediaOrphans:C,metaOrphans:y}=u.useMemo(()=>{let d=[],n=[];for(let x of $){let m=ZT(x.primary.name);(m==="image"||m==="video"||m==="audio"||m==="font"?d:n).push(x)}return{mediaOrphans:d,metaOrphans:n}},[$]),f=!!(U&&U.trim()),h=u.useMemo(()=>{if(!q||Z!==1)return null;let d=new Map;for(let n of q)d.set(n.folder,n);return d},[q,Z]);return O(G0,{children:[k.map((d)=>{let n=f&&d.sidecars.some((x)=>{let m=U.toLowerCase();return x.name.toLowerCase().includes(m)||x.path.toLowerCase().includes(m)});return z(f20,{primary:d.primary,sidecars:d.sidecars,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,onDelete:F,openCount:wF(G[d.primary.path]),depth:Z,kind:H,showHidden:K,forceOpen:n,dirtyByPath:D,experimentalKind:_?.[d.primary.path],drag:w,menu:M},d.primary.path)}),C.map((d)=>z(IF,{file:d.primary,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,openCount:wF(G[d.primary.path]),depth:Z,kind:H},d.primary.path)),K&&y.map((d)=>z(IF,{file:d.primary,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,openCount:wF(G[d.primary.path]),depth:Z,kind:H},d.primary.path)),P.map((d)=>{let n=h?.get(d),x=R?`${R}/${d}`:d,m=z(x00,{node:X[d],activePath:J,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z+1,kind:H,showHidden:K,search:U,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:D,canvasKinds:_,dirPath:x,drag:w,menu:M});if(n&&N)return z(v20,{name:d,dsName:n.name,depth:Z,defaultOpen:!0,active:J===c8&&n.name===B,onOpenSystem:N,children:m},d);return z(j20,{name:d,depth:Z,defaultOpen:!0,dirPath:x,drag:w,menu:M,children:m},d)})]})}var _F={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function x20(X){if(X.kind==="project")return _F.project;if(X.kind==="runtime")return _F.runtime;if(X.label==="Design system")return _F.ds;if(X.label==="UI kit")return _F.canvas;return{title:X.label.toUpperCase(),pillFromCount:!0}}function h20({readOnly:X=!1,cloud:J,groups:Q,activePath:Y,previewPath:W,activeDsName:G,onOpen:Z,onPreview:H,onOpenSystem:K,wsConnected:U,search:q,setSearch:B,commentsByFile:N,showHidden:F,sectionsExpanded:D,onToggleSection:_,onNewBoard:R,onDeleteBoard:w,onRefresh:M,refreshing:P,collapsed:I,onCollapse:k,width:$,resizing:C,dirtyByPath:y,project:f,gitBranch:h,remoteSync:d,onGetLatest:n,canvasKinds:x,onMoveCanvas:m,onNewFolder:p,onDeleteFolder:v,syncStatus:r,onLinkedHub:a,savingIsManaged:c=!1}){let U0=u.useMemo(()=>{if(!q)return Q;return Q.map((i0)=>({...i0,tree:v00(i0.tree,q),filtered:!!q}))},[Q,q]),o=TS(m),Z0=PS(),e=u.useMemo(()=>{let i0=[];for(let j0 of Q){if(j0.label==="Design system"||j0.kind!=="canvas")continue;let I0=j0.fullPath.replace(/^\.[^/]+\//,"")||j0.fullPath;i0.push({path:j0.fullPath,label:I0});for(let T8 of j0.dirs||[])i0.push({path:T8,label:T8.replace(/^\.[^/]+\//,"")})}return i0},[Q]),N0=Z0.state?.extra,K0=N0?.kind==="file"?[{id:"move-to",label:"Move to…",onSelect:()=>Z0.showMoveTo()}]:N0?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{Z0.close();let i0=window.prompt("New folder name:");if(i0?.trim())p(N0.dirPath,i0.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{Z0.close(),v(N0.dirPath,N0.dirPath.split("/").pop())}}]:[],u0=N0?.kind==="file"?e.filter((i0)=>i0.path!==N0.dir):[],[Q8,o0]=u.useState(!1),[_8,A0]=u.useState("board"),[r0,P0]=u.useState(""),[K8,F8]=u.useState(""),[D8,W8]=u.useState(!1),A8=u.useMemo(()=>Q.find((i0)=>i0.kind==="canvas"&&i0.label!=="Design system")?.fullPath,[Q]),i8=u.useCallback(async()=>{let i0=r0.trim();if(!i0||D8)return;if(W8(!0),F8(""),_8==="folder"){if(!A8){W8(!1),F8("no canvas group to create a folder in");return}let I0=await p(A8,i0);if(W8(!1),I0?.ok)o0(!1),P0("");else F8(I0?.error||"could not create folder");return}let j0=await R(i0);if(W8(!1),j0?.ok)o0(!1),P0("");else F8(j0?.error||"could not create board")},[r0,D8,R,p,_8,A8]),P9=u.useMemo(()=>{let i0=0;for(let j0 of Q)for(let I0 of j0.paths||[])if(GQ.test(I0))i0++;return i0},[Q]),l0=u.useMemo(()=>{let i0=0;for(let j0 of U0)for(let I0 of j0.paths||[])if(GQ.test(I0))i0++;return i0},[U0]);return O("nav",{className:"st-sidebar"+(I?" is-collapsed":"")+(C?" is-resizing":""),style:I||!$?void 0:{width:$,flexBasis:$},"aria-label":"Files","data-tour":"sidebar",children:[O("div",{className:"st-sb-hd",children:[z("span",{className:"st-sb-title",children:"Files"}),O("div",{className:"st-sb-hd-actions",children:[!X&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":Q8&&_8==="board",onClick:()=>{F8(""),A0("board"),o0((i0)=>_8==="board"?!i0:!0)},children:z(E9,{name:"plus",size:15})}),!X&&A8&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":Q8&&_8==="folder",onClick:()=>{F8(""),A0("folder"),o0((i0)=>_8==="folder"?!i0:!0)},children:z(E9,{name:"folder-plus",size:15})}),M&&z("button",{type:"button",className:"st-iconbtn st-refresh"+(P?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":P||void 0,disabled:P,onClick:()=>M(),children:z(E9,{name:"reload",size:15})}),O("span",{className:"st-live","data-tip":U?"live · file index synced":"reconnecting…",children:[z("span",{className:"st-live-dot"+(U?" is-connected":""),"aria-hidden":"true"}),l0," / ",P9]}),k&&z("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:k,children:z(E9,{name:"panel-left",size:15})})]})]}),Q8?O("div",{className:"st-newboard",children:[z("input",{type:"text",autoFocus:!0,placeholder:_8==="folder"?"folder name…":"brief board name…",value:r0,maxLength:60,disabled:D8,"aria-label":_8==="folder"?"New folder name":"New brief board name",onChange:(i0)=>P0(i0.target.value),onKeyDown:(i0)=>{if(i0.key==="Enter")i0.preventDefault(),i8();else if(i0.key==="Escape")i0.preventDefault(),o0(!1),P0(""),F8("")}}),z("button",{type:"button",className:"st-newboard-go",disabled:D8||!r0.trim(),"data-tip":"Create · Enter","aria-label":_8==="folder"?"Create folder":"Create brief board",onClick:i8,children:D8?"…":"↵"})]}):null,K8?z("div",{className:"st-newboard-err",role:"alert",children:K8}):null,z("div",{className:"st-search",children:O("div",{className:"st-search-box",children:[z(E9,{name:"search",size:13}),z("input",{type:"search","data-testid":"canvas-search",placeholder:"Search canvases…",value:q,onChange:(i0)=>B(i0.target.value),onKeyDown:(i0)=>{if(i0.key==="Escape")if(i0.preventDefault(),q)B("");else i0.currentTarget.blur()},"aria-label":"Filter files"}),q?z("button",{className:"st-search-clear",onClick:()=>B(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):z(wX,{children:"/"})]})}),z("div",{className:"st-tree",role:"tree","aria-label":"Project file tree","data-testid":"canvas-list",children:U0.map((i0)=>{if(!F&&!q&&i0.kind==="runtime")return null;let j0=x20(i0),I0=(i0.paths||[]).filter((d0)=>GQ.test(d0)).length,T8=j0.pill||(j0.pillFromDsCount?String(i0.dsFolders?.length||0):null)||(j0.pillFromCount?String(I0||i0.paths?.length||0):null),Z8=i0.tree&&Object.keys(i0.tree).length>0,z0=i0.label==="Design system",f0=i0.kind==="project";if(!F&&!q&&f0&&I0===0)return null;let L8=O20(i0),n8=D[i0.label],k8=!!q||(n8===void 0?L8:n8),q8=!z0&&i0.kind==="canvas"&&!X,w0=q8?o.dropProps(i0.fullPath,!0):{},L0=o.overDir===i0.fullPath;return O("div",{className:"st-tree-section",children:[O("button",{type:"button",className:"st-tree-sec-hd"+(L0?" is-drop-target":""),onClick:()=>_(i0.label,L8),"aria-expanded":k8,"aria-dropeffect":q8?"move":void 0,title:k8?"Collapse section":"Expand section",...w0,children:[z(E9,{name:"chevron-right",className:"st-chev"+(k8?" is-open":""),size:13}),z("span",{className:"st-sec-name",children:j0.title}),T8&&z("span",{className:"st-pill",children:T8})]}),k8&&(Z8?z(x00,{node:i0.tree,activePath:Y,previewPath:W,onOpen:Z,onPreview:H,commentsByFile:N,depth:1,kind:i0.kind,showHidden:F,search:q,dsFolders:i0.dsFolders,activeDsName:G,onOpenSystem:z0?K:void 0,onDelete:z0||X?void 0:w,dirtyByPath:y,canvasKinds:x,dirPath:i0.fullPath,drag:!z0&&i0.kind==="canvas"&&!X?o:void 0,menu:!z0&&i0.kind==="canvas"&&!X?Z0:void 0}):z("div",{className:"st-tree-empty",children:q?"No matches.":"Empty."}))]},i0.label)})}),z(RS,{state:Z0.state,onClose:Z0.close,rootItems:K0,destinations:u0,onPickDestination:(i0)=>m(N0.path,i0)}),!c&&z(Ww,{project:f,liveBranch:h,remoteSync:d,onGetLatest:n}),J===null?z(kA,{syncStatus:r,onLinkedHub:a}):null,z($A,{})]})}function g20({shown:X,onExpand:J,onSearch:Q}){return z("div",{className:"st-rail"+(X?" is-shown":""),children:O("div",{className:"st-rail-inner",children:[z("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:J,children:z(E9,{name:"panel-left",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:z(E9,{name:"search",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:J,children:z(E9,{name:"folder",size:15})})]})})}function m20({open:X,onClose:J,onStartTour:Q}){if(u.useEffect(()=>{if(!X)return;function Y(W){if(W.key==="Escape")J()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[X,J]),!X)return null;return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:O("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[O("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),O("span",{className:"sku",children:["MAUDE-DEV-SRV / v",HT]}),Q&&z("button",{type:"button",className:"mdcc-tour__back",style:{marginLeft:"auto"},onClick:Q,children:"▶ Take the tour"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:J,children:"×"})]}),O("div",{className:"help-modal-body",children:[O("details",{open:!0,children:[z("summary",{children:"Canvas selection & tools"}),O("ul",{children:[O("li",{children:[z("kbd",{children:"V"})," ",z("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),O("li",{children:[z("kbd",{children:"H"})," ",z("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),O("li",{children:[z("kbd",{children:"C"})," ",z("span",{children:"comment tool — hover paints, click drops a pin"})]}),O("li",{children:[z("kbd",{children:"⌘"})," + hover ",z("span",{children:"preview deepest element under cursor"})]}),O("li",{children:[z("kbd",{children:"⌘"})," + click ",z("span",{children:"select that element (replace)"})]}),O("li",{children:[z("kbd",{children:"⌘⇧"})," + click ",z("span",{children:"add deepest to selection (multi)"})]}),O("li",{children:["right-click ",z("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),O("li",{children:[z("kbd",{children:"Esc"})," in canvas ",z("span",{children:"clear selection + close menu"})]})]})]}),O("details",{children:[z("summary",{children:"Annotation tools"}),O("ul",{children:[O("li",{children:[z("kbd",{children:"B"})," ",z("span",{children:"pen — freehand stroke"})]}),O("li",{children:[z("kbd",{children:"R"})," ",z("span",{children:"rectangle — drag to define corners"})]}),O("li",{children:[z("kbd",{children:"O"})," ",z("span",{children:"ellipse — drag from center outward"})]}),O("li",{children:[z("kbd",{children:"A"})," ",z("span",{children:"arrow — drag tail → tip"})]}),O("li",{children:[z("kbd",{children:"E"})," ",z("span",{children:"eraser — click or drag over strokes to remove"})]}),O("li",{children:[z("kbd",{children:"V"})," + click stroke ",z("span",{children:"select annotation (Shift+click to multi)"})]}),O("li",{children:[z("kbd",{children:"V"})," + drag empty ",z("span",{children:"marquee-select strokes that overlap"})]}),O("li",{children:["double-click rect/ellipse ",z("span",{children:"add text inside the shape"})]}),O("li",{children:["arrow keys ",z("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),O("li",{children:[z("kbd",{children:"Backspace"})," ",z("span",{children:"delete selected annotations"})]}),O("li",{children:[z("kbd",{children:"⇧P"})," ",z("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),O("details",{children:[z("summary",{children:"Canvas & panels"}),O("ul",{children:[O("li",{children:["click in tree ",z("span",{children:"open canvas (replaces the active one)"})]}),O("li",{children:["File ▸ Close canvas ",z("span",{children:"clear the stage"})]}),O("li",{children:[z("kbd",{children:"⌘R"})," ",z("span",{children:"reload canvas"})]}),O("li",{children:[z("kbd",{children:"/"})," ",z("span",{children:"focus search"})]}),O("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"comments panel"})]}),O("li",{children:[z("kbd",{children:"⌘⇧I"})," ",z("span",{children:"inspector"})]}),O("li",{children:[z("kbd",{children:"?"})," ",z("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),O("details",{children:[z("summary",{children:"Slash commands"}),O("ul",{className:"cmds",children:[O("li",{children:[O("code",{children:['/design:edit "',z("i",{children:"feedback"}),'"']}),z("span",{children:"edit + 4-iter multi-axis loop"})]}),O("li",{children:[O("code",{children:['/design:edit "',z("i",{children:"…"}),'" --perfect']}),z("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),O("li",{children:[O("code",{children:['/design:edit "',z("i",{children:"…"}),'" --no-critic']}),z("span",{children:"raw edit, skip loop"})]}),O("li",{children:[O("code",{children:['/design:edit "',z("i",{children:"…"}),'" --opt-out=',z("i",{children:"scope"})]}),z("span",{children:"override DS scope (palette/aesthetic/full)"})]}),O("li",{children:[O("code",{children:['/design:new "',z("i",{children:"Name"}),'" "',z("i",{children:"brief"}),'"']}),z("span",{children:"scaffold canvas"})]}),O("li",{children:[O("code",{children:['/design:new "',z("i",{children:"…"}),'" --opt-out=aesthetic']}),z("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),O("li",{children:[z("code",{children:"/design:critic"}),z("span",{children:"review panel (routed)"})]}),O("li",{children:[z("code",{children:"/design:critic --all"}),z("span",{children:"10-critic sweep"})]}),O("li",{children:[z("code",{children:"/design:critic --agent signature-moment-critic"}),z("span",{children:"aspiration axis only"})]}),O("li",{children:[z("code",{children:"/design:rollback"}),z("span",{children:"undo last edit"})]}),O("li",{children:[z("code",{children:"/design:screenshot"}),z("span",{children:"capture canvas"})]}),O("li",{children:[z("code",{children:"/design:setup-docs"}),z("span",{children:"refresh README + INDEX"})]}),O("li",{children:[z("code",{children:"/design:handoff"}),z("span",{children:"migrate to apps/"})]})]})]}),O("details",{children:[z("summary",{children:"Opt-out scope"}),O("ul",{children:[O("li",{children:[z("strong",{children:"palette"})," ",z("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),O("li",{children:[z("strong",{children:"aesthetic"})," ",z("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),O("li",{children:[z("strong",{children:"full"})," ",z("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),O("li",{children:[z("em",{children:"A11y enforced at every scope"})," ",z("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),O("li",{children:["Persisted on canvas's ",z("code",{children:".meta.json"})," ",z("code",{children:"opt_out_scope"})," field — subsequent ",z("code",{children:"/design:edit"})," iterations inherit."]}),z("li",{children:'Inferred from brief ("modern", "vibrant", "off-system") with one-shot AskUserQuestion before iter-1 critics fire.'})]})]}),O("details",{children:[z("summary",{children:"Auto-critic loop"}),O("ul",{children:[O("li",{children:[z("strong",{children:"Default"})," ",z("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),O("li",{children:[z("strong",{children:"--perfect"})," ",z("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),O("li",{children:[z("strong",{children:"--perfect --all"})," ",z("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),O("li",{children:["Exit: ",z("code",{children:"solid"})," · ",z("code",{children:"stable-but-bland"})," · ",z("code",{children:"max-reached"})," ","· ",z("code",{children:"divergent"})]}),O("li",{children:[z("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),O("li",{children:["When ",z("code",{children:"opt_out_scope ∈ {aesthetic, full}"}),": iter-1 checkpoint fires — pick (a) run loop, (b) skip auto-loop and review iter 1, (c) a11y-only check."]})]})]}),O("details",{children:[z("summary",{children:"Pin-to-element flow"}),O("ol",{children:[z("li",{children:"Open a canvas"}),O("li",{children:[z("kbd",{children:"⌘"}),"+click element"]}),z("li",{children:"Status bar shows ● selector"}),O("li",{children:["Run"," ",O("code",{children:['/design:edit "',z("i",{children:"change just this"}),'"']})]}),O("li",{children:["Reload iframe (",z("kbd",{children:"⌘R"}),")"]})]})]}),O("details",{children:[z("summary",{children:"Comments"}),O("ol",{children:[O("li",{children:[z("kbd",{children:"⌘"}),"+click element, then ",z("kbd",{children:"⌘C"})," ",z("span",{children:"or ⌘⇧+click"})]}),z("li",{children:"Numbered pin appears on canvas"}),O("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"opens panel — All / Open / Resolved"})]}),O("li",{children:["Click row in panel ",z("span",{children:"jumps to that file + pin"})]}),O("li",{children:["Claude reads ",z("code",{children:"_comments/<slug>.json"})," on next ",z("code",{children:"/design"})]})]})]})]})]})})}var YT=[{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 u20({kbd:X,alt:J}){let Q=(Y,W)=>z("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>z(wX,{children:G},`${G}-${Z}`))},W);return O("span",{className:"so-combos",children:[Q(X,"main"),J?J.split(" / ").map((Y)=>O(G0,{children:[z("span",{className:"so-or",children:"/"}),Q(Y,Y)]},Y)):null]})}function l20({open:X,onClose:J}){if(u.useEffect(()=>{if(!X)return;function Y(W){if(W.key==="Escape")W.preventDefault(),J()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[X,J]),!X)return null;let Q=YT.reduce((Y,W)=>Y+W.items.length,0);return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:O("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[O("div",{className:"so-overlay-hd",children:[z("span",{className:"so-title",children:"Keyboard shortcuts"}),O("span",{className:"so-trigger",children:["press ",z(wX,{children:"?"})," to open"]})]}),z("div",{className:"so-columns",children:YT.map((Y)=>O("section",{className:"so-section so-section--"+Y.id,children:[z("h3",{className:"so-section-hd",children:Y.label}),z("dl",{className:"so-list",children:Y.items.map((W)=>O("div",{className:"so-pair",children:[z("dt",{children:W.label}),z("dd",{children:z(u20,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),O("div",{className:"so-overlay-ft",children:[O("span",{children:["close with ",z(wX,{children:"Esc"})]}),O("span",{className:"so-count",children:[Q," bindings · ",YT.length," groups"]})]})]})})}var p20=["File","Edit","View","Selection","Tools","Help"];function h00(X){u.useEffect(()=>{function J(Y){if(Y.key==="Escape")X()}function Q(Y){if(!Y.target.closest(".st-dropdown, .st-menu"))X()}return window.addEventListener("keydown",J),window.addEventListener("mousedown",Q),()=>{window.removeEventListener("keydown",J),window.removeEventListener("mousedown",Q)}},[X])}function d20({panels:X,onToggle:J,onClose:Q,onZoom:Y,hasCanvas:W}){return h00(Q),O("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[z("div",{className:"st-dd-hd",children:"Panels"}),X.map((G)=>O("button",{type:"button",role:"menuitem",className:"st-dd-item"+(G.checked?" is-on":""),"aria-disabled":G.disabled?"true":void 0,title:G.hint||void 0,onClick:()=>{if(G.disabled){if(G.href)window.open(G.href,"_blank","noopener,noreferrer"),Q();return}J(G.id),Q()},children:[O("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check",children:G.checked?z(E9,{name:"check",size:13}):null}),z("span",{children:G.label}),G.phase?z("span",{className:"st-dd-phase",children:G.phase}):null]}),G.shortcut?z(wX,{children:G.shortcut}):null]},G.id)),z("div",{className:"st-dd-sep"}),z("div",{className:"st-dd-hd",children:"Zoom"}),[{op:"in",label:"Zoom In",shortcut:"⌘ +"},{op:"out",label:"Zoom Out",shortcut:"⌘ −"},{op:"fit",label:"Fit to Screen",shortcut:"⌘ 0"},{op:"actual",label:"Actual Size · 100 %",shortcut:"⌘ 1"}].map((G)=>O("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":W?void 0:"true",onClick:()=>{if(!W)return;Y?.(G.op),Q()},children:[O("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:G.label})]}),z(wX,{children:G.shortcut})]},G.label))]})}function yK({label:X,left:J,header:Q,items:Y,onAction:W,onClose:G}){return h00(G),O("div",{className:"st-dropdown",role:"menu","aria-label":X,style:{left:J},children:[Q?z("div",{className:"st-dd-hd",children:Q}):null,Y.map((Z,H)=>Z.sep?z("div",{className:"st-dd-sep"},"s"+H):O("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":Z.disabled?"true":void 0,onClick:()=>{if(Z.disabled)return;W(Z.id),G()},children:[O("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:Z.label})]}),Z.shortcut?z(wX,{children:Z.shortcut}):null]},Z.id))]})}function c20({onAction:X,onClose:J}){return z(yK,{label:"Help",left:320,onAction:X,onClose:J,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"},...W9()?[{id:"collab-tour",label:"How sharing works"}]:[],...W9()?[{id:"quick-setup",label:"Quick setup"}]:[],...W9()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function i20({onAction:X,onClose:J,readOnly:Q=!1}){return z(yK,{label:"Selection",left:214,onAction:X,onClose:J,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},...Q?[]:[{id:"select-all-annotations",label:"Select all annotations",shortcut:"⌘ ⇧ A"}]]})}function o20({onAction:X,onClose:J,readOnly:Q=!1}){let Y=[{id:"browse",label:"Browse (interact)",shortcut:""},{id:"move",label:"Select",shortcut:"V"},{id:"hand",label:"Hand",shortcut:"H"},...Q?[]:[{id:"comment",label:"Comment",shortcut:"C"},{id:"pen",label:"Pen",shortcut:"B"},{id:"rect",label:"Rect",shortcut:"R"},{id:"ellipse",label:"Ellipse",shortcut:"O"},{id:"sticky",label:"Sticky",shortcut:"N"},{id:"arrow",label:"Arrow",shortcut:"A"},{id:"text",label:"Text",shortcut:"T"},{id:"eraser",label:"Eraser",shortcut:"E"}]];return z(yK,{label:"Tools",left:290,header:"Tool palette",onAction:X,onClose:J,items:Y})}function n20({onAction:X,onClose:J,hasCanvas:Q,readOnly:Y=!1}){return z(yK,{label:"File",left:40,onAction:X,onClose:J,items:Y?[{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!Q},{id:"close",label:"Close canvas",disabled:!Q}]:[{id:"new",label:"New canvas…",shortcut:"N"},{id:"assemble",label:"Assemble dropped clips → video",disabled:!Q},{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"generate",label:"Generate with AI…"},{id:"settings",label:"Settings…",shortcut:"⌘,"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!Q},{id:"close",label:"Close canvas",disabled:!Q}]})}function r20({onAction:X,onClose:J,hasCanvas:Q,readOnly:Y=!1}){if(Y)return z(yK,{label:"Edit",left:90,onAction:X,onClose:J,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"}]});return z(yK,{label:"Edit",left:90,onAction:X,onClose:J,items:[{id:"undo",label:"Undo",shortcut:"⌘Z"},{id:"redo",label:"Redo",shortcut:"⇧⌘Z"},{sep:!0},{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},{id:"select-all-annotations",label:"Select all annotations",shortcut:"⇧⌘A"},...Q?[{sep:!0},{id:"new-artboard:desktop",label:"New artboard: Desktop"},{id:"new-artboard:laptop",label:"New artboard: Laptop"},{id:"new-artboard:tablet",label:"New artboard: Tablet"},{id:"new-artboard:mobile",label:"New artboard: Mobile"},{id:"new-artboard:print-a4",label:"New artboard: A4 (print)"},{id:"new-artboard:print-letter",label:"New artboard: Letter (print)"}]:[]]})}function a20({activePath:X,project:J,cloud:Q,tabsCount:Y,openMenu:W,setOpenMenu:G,commentsPanelOpen:Z,onToggleComments:H,changesOpen:K,changesCount:U,onToggleChanges:q,onOpenSystem:B,sidebarOpen:N,onToggleSidebar:F,showHidden:D,onToggleShowHidden:_,onOpenHelp:R,onOpenShortcuts:w,onReportBug:M,onStartTour:P,onStartCollabTour:I,annotationsVisible:k,onToggleAnnotations:$,minimapVisible:C,onToggleMinimap:y,zoomCtlVisible:f,onToggleZoomCtl:h,presentMode:d,onTogglePresent:n,printGuidesVisible:x,onTogglePrintGuides:m,postToActiveCanvas:p,onOpenWhatsNew:v,onOpenReadiness:r,onOpenQuickSetup:a,onWatchIntro:c,whatsNewCount:U0,exportCenter:o,artboardCount:Z0=0,presence:e=null,inspectorOpen:N0,inspectorTab:K0,onToggleInspector:u0,autoOpenInspector:Q8,onToggleAutoOpenInspector:o0,onOpenLayers:_8,timelineOpen:A0,onToggleTimeline:r0,hasComps:P0=!1,assistantOpen:K8,onToggleAssistant:F8,assistantBusy:D8,assistantUnseen:W8,onNewCanvas:A8,onAssembleVideo:i8,onOpenExport:P9,onOpenSettings:l0,onOpenGenerate:i0,onReload:j0,onCloseCanvas:I0,onInsertArtboard:T8,readOnly:Z8=!1}){let z0=X===c8,f0=z0?"SYSTEM":X?"CANVAS":"IDLE",L8=z0?z("b",{children:"design system"}):X?O(G0,{children:[X.split("/").slice(0,-1).join("/"),"/",z("b",{children:pW(JH(X))})]}):z("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),n8=new Set(Q?["autoopen"]:["assistant","autoopen"]),k8=[{id:"tree",label:"Project Tree",shortcut:"T",checked:N,disabled:!1},{id:"changes",label:Q?"History":U>0?`Changes · ${U} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:K,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:Z,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:D,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:N0&&K0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:N0,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!Q8,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:P0?"video":void 0,checked:A0,disabled:!1},...W9()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:K8,disabled:!1}]:Q?[{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:k,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:C,disabled:!X||z0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:f,disabled:!X||z0},{id:"present",label:"Presentation Mode",shortcut:"",checked:d,disabled:!X||z0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:x,disabled:!X||z0}].filter((L0)=>!Z8||!n8.has(L0.id)),q8=["file","edit","view","selection","tools","help"];function w0(L0){if(q8.includes(L0))G(W===L0?null:L0)}return u.useEffect(()=>{if(!W||!q8.includes(W))return;let L0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function d0(V8){let O8=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!O8.length)return;let a8=O8.indexOf(document.activeElement);if(V8.key==="ArrowDown")V8.preventDefault(),O8[(a8+1)%O8.length].focus();else if(V8.key==="ArrowUp")V8.preventDefault(),O8[(a8-1+O8.length)%O8.length].focus();else if(V8.key==="Home")V8.preventDefault(),O8[0].focus();else if(V8.key==="End")V8.preventDefault(),O8[O8.length-1].focus();else if(V8.key==="ArrowRight"||V8.key==="ArrowLeft"){V8.preventDefault();let E8=V8.key==="ArrowRight"?1:-1,N9=q8.indexOf(W);G(q8[(N9+E8+q8.length)%q8.length])}else if(V8.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",d0),()=>{clearTimeout(L0),window.removeEventListener("keydown",d0)}},[W,G]),O("header",{className:"st-menubar",role:"menubar","aria-label":"Application menubar","data-testid":"menubar",children:[O("span",{className:"st-brand","data-tour":"brand",children:[z("span",{className:"st-brand-mark",children:z("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),z("span",{className:"st-brand-name",children:"maude"})]}),Q?O("span",{className:"st-cloudback","data-testid":"cloud-back",children:[Q.dashboardUrl?z("a",{className:"st-cloudback-link",href:Q.dashboardUrl,title:"Back to your projects",children:"← Dashboard"}):null,Q.projectName?z("span",{className:"st-cloudback-project","data-testid":"cloud-project-name",children:Q.projectName}):null]}):null,z("nav",{className:"st-menus","aria-label":"Application menus","data-tour":"menus",children:p20.map((L0)=>{let d0=L0.toLowerCase(),V8=q8.includes(d0),O8=V8||d0==="help";return z("button",{type:"button",className:"st-menu",role:"menuitem","data-tour":d0==="help"?"help":void 0,"aria-haspopup":V8?"menu":void 0,"aria-expanded":V8?W===d0:void 0,onClick:()=>w0(d0),onMouseEnter:()=>{if(W!==null&&V8)G(d0)},children:L0},d0)})}),W==="file"&&z(n20,{readOnly:Z8,hasCanvas:!!X,onAction:(L0)=>{if(L0==="new")A8?.();else if(L0==="assemble")i8?.();else if(L0==="export")P9?.("export");else if(L0==="handoff")P9?.("handoff");else if(L0==="generate")i0?.();else if(L0==="settings")l0?.();else if(L0==="reload")j0?.();else if(L0==="close")I0?.()},onClose:()=>G(null)}),W==="edit"&&z(r20,{readOnly:Z8,hasCanvas:!!X&&!z0,onAction:(L0)=>{if(L0==="undo")p({dgn:"undo"});else if(L0==="redo")p({dgn:"redo"});else if(L0==="deselect-all")p({dgn:"selection-clear"});else if(L0==="select-all-annotations")p({dgn:"annotation-select-all"});else if(L0.startsWith("new-artboard:"))T8?.(L0.slice(13))},onClose:()=>G(null)}),W==="view"&&z(d20,{panels:k8,onToggle:(L0)=>{if(L0==="tree")F();else if(L0==="changes")q();else if(L0==="comments")H();else if(L0==="hidden")_();else if(L0==="annotate")$();else if(L0==="inspector")u0();else if(L0==="autoopen")o0?.();else if(L0==="timeline")r0?.();else if(L0==="assistant")F8?.();else if(L0==="layers")_8?.();else if(L0==="minimap")y?.();else if(L0==="zoomctl")h?.();else if(L0==="present")n?.();else if(L0==="print-guides")m?.()},onZoom:(L0)=>p({dgn:"zoom",op:L0}),hasCanvas:!!X&&!z0,onClose:()=>G(null)}),W==="selection"&&z(i20,{readOnly:Z8,onAction:(L0)=>{if(L0==="deselect-all")p({dgn:"selection-clear"});else if(L0==="select-all-annotations")p({dgn:"annotation-select-all"})},onClose:()=>G(null)}),W==="tools"&&z(o20,{readOnly:Z8,onAction:(L0)=>p({dgn:"tool-set",tool:L0}),onClose:()=>G(null)}),W==="help"&&z(c20,{onAction:(L0)=>{if(L0==="shortcuts")w?.();else if(L0==="help")R?.();else if(L0==="report-bug")M?.();else if(L0==="tour")P?.();else if(L0==="collab-tour")I?.();else if(L0==="quick-setup")a?.();else if(L0==="readiness")r?.();else if(L0==="whatsnew")v?.();else if(L0==="watch-intro")c?.()},onClose:()=>G(null)}),O("div",{className:"st-mb-right","data-tour":"status",children:[e?z("div",{className:"st-presence",children:e}):null,Z8&&z("span",{className:"st-stamp st-stamp--viewonly","data-testid":"view-only-stamp","data-tip":Q?.user?`${Q.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"}),Q?.user?O("span",{className:"st-cloudwho","data-testid":"cloud-account",children:[z("span",{className:"st-cloudwho-email",title:Q.role?`Signed in as ${Q.user} — ${Q.role}`:Q.user,children:Q.user}),z("form",{method:"post",action:"/auth/browser/signout",className:"st-cloudwho-form",children:z("button",{type:"submit",className:"st-cloudwho-out","data-testid":"cloud-signout",title:"Sign out of this project",children:"Sign out"})})]}):null,W9()&&!Z8&&z("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":K8?"true":"false","data-busy":D8?"true":"false","data-unseen":W8?"true":"false","aria-label":`Assistant${D8?" — working":W8?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:F8,children:z(E9,{name:"sparkle",size:15})}),o&&z(Ch,{center:o}),z("button",{type:"button",className:"st-reportbug","data-testid":"report-bug-toggle","aria-label":"Report a bug","data-tip":"Report a bug",onClick:M,children:z(E9,{name:"bug",size:15})}),z("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":U0>0?"true":"false","aria-label":`What's new${U0>0?` — ${U0} unseen`:""}`,"data-tip":"What's new",onClick:v,children:z(E9,{name:"megaphone",size:15})}),z("span",{className:"st-stamp",children:f0}),z("span",{className:"st-mb-file",title:X||"",children:L8}),z("span",{className:"st-mb-sep"}),O("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[z("span",{className:"st-dot",style:{background:"var(--accent)"}}),Z0," ARTBOARDS"]}),z("span",{className:"st-mb-sep"}),z("span",{className:"st-mb-proj",children:J||"maude"})]})]})}function s20({tabs:X,activePath:J,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:K,onIframeLoad:U,showQuickSetup:q,onStartQuickSetup:B,previewPath:N}){let F=u.useRef(null);return u.useEffect(()=>{if(N)F.current?.focus()},[N]),O("div",{className:"viewport st-stage","data-tour":"viewport",children:[N&&z("div",{ref:F,className:"st-file-preview-overlay",role:"region","aria-label":`Preview: ${sB(JH(N))}`,tabIndex:0,children:z(mx,{path:N,kind:ZT(JH(N))})}),X.length===0&&!N&&O("div",{className:"st-empty",children:[O("div",{className:"st-empty-brand",children:[z("span",{className:"st-brand-mark",children:z("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),z("span",{className:"st-empty-wm",children:"maude"}),O("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(Z||"MAUDE").toUpperCase()," / v",HT," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),z("div",{className:"st-empty-title",children:"Nothing open yet"}),O("div",{className:"st-empty-body",children:["← Pick a screen from the list on the left, or open ",z("strong",{children:"Design system"})," above it to see your colors, type, and components.",z("br",{}),z("br",{}),z("strong",{children:"To select something on the canvas:"})," hold ",z(wX,{children:"⌘"})," and hover to preview an element, click to select it — ",z(wX,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",W9()?O(G0,{children:[z("br",{}),z("br",{}),"Claude can see whatever's selected when you ask for a change in the Assistant panel, so pointing is often faster than describing it."]}):null]}),q&&z("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:B,children:"Start quick setup"})]}),X.map((D)=>{if(D.path===c8)return z("div",{className:"system-view"+(D.path===J?" active":""),children:z(GB0,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},D.path);return z("iframe",{ref:(_)=>Q(D.path,_),src:Iz(D.path,H),className:D.path===J?"active":"","data-path":D.path,"data-testid":D.path===J?"canvas-frame":void 0,onLoad:()=>U?.(D.path),...H?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},D.path)}),K&&K===J&&z("div",{className:"st-canvas-loading","aria-hidden":"true",children:O("div",{className:"st-skel-card",children:[z("div",{className:"st-skel-cap st-mono",children:"compiling canvas…"}),z("span",{className:"skel st-skel-thumb"}),z("span",{className:"skel st-skel-line",style:{width:"72%"}}),z("span",{className:"skel st-skel-line",style:{width:"46%"}})]})})]})}var t20=["color","space","radius","shadow","leading","weight","motion","font","other"],e20={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function XB0(X){return X==="color"}function JB0({tokens:X,tokenGroups:J,tokensPath:Q}){if(!X||X.length===0)return O("section",{className:"sv-section sv-section-tokens",children:[O("h2",{children:["tokens",z("span",{className:"sv-h-num",children:"0"})]}),z("div",{className:"sv-empty",children:O("p",{children:["No tokens parsed from"," ",Q?z("code",{children:Q}):"the configured tokens file",". Does the file exist and contain CSS custom properties (",z("code",{children:"--name: value;"}),")?"]})})]});let Y=J||{},W=Array.from(new Set([...t20,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return z(G0,{children:W.map((G)=>{let Z=Y[G],H=XB0(G);return O("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[O("h2",{children:["tokens · ",e20[G]||G,z("span",{className:"sv-h-num",children:Z.length})]}),z("div",{className:"sv-tokens-ladder",children:Z.map((K)=>O("div",{className:"sv-tok-cell",children:[H?z("div",{className:"sv-tok-swatch",style:{background:K.value}}):null,O("div",{className:"sv-tok-meta",children:[z("code",{className:"sv-tok-name",children:K.name}),z("span",{className:"sv-tok-value",children:K.value||"—"})]})]},K.name+"|"+K.value))})]},G)})})}function QB0(X,J){let Q=X.name.match(/^--(?:type|fs|text)-(.+)$/);if(!Q)return null;let Y=Q[1];return(J||[]).find((W)=>/^--(?:lh|leading|line-height)-/.test(W.name)&&W.name.endsWith("-"+Y))?.value??null}function YB0(X){if(!X?.length)return;let J=["body","sans","display","text","family"];for(let Q of J){let Y=X.find((W)=>W.name.includes(Q));if(Y)return Y.value}return X[0].value}function WB0({tokenGroups:X}){let J=X?.fontsize||[];if(J.length===0)return null;let Q=X?.leading||[],Y=YB0(X?.font);return O("section",{className:"sv-section sv-section-type",children:[O("h2",{children:["type · ladder",z("span",{className:"sv-h-num",children:J.length})]}),z("div",{className:"sv-type-list",children:J.map((W)=>{let G=QB0(W,Q),Z={fontSize:W.value};if(G)Z.lineHeight=G;if(Y)Z.fontFamily=Y;return O("div",{className:"sv-type-row",children:[z("code",{className:"sv-type-tok",children:W.name}),z("span",{className:"sv-type-sample",style:Z,children:"The catalog is the system."})]},W.name)})})]})}function GB0({data:X,onOpen:J,cfg:Q,onSelectDs:Y}){if(!X)return z("div",{className:"sv-empty",children:z("p",{children:"Loading design system…"})});let{previewGallery:W,uiKitsGallery:G,systemDir:Z,tokens:H,tokenGroups:K,tokensPath:U,ds:q,availableDesignSystems:B}=X,N=(!W||!W.length)&&(!G||!G.length),F=Array.isArray(B)&&B.length>1,D=q?.name??B?.[0]?.name??"";return O("div",{className:"sv",children:[O("header",{className:"sv-header",children:[z("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),z("span",{className:"sv-title",children:"design system view"}),F?O("label",{className:"sv-ds-picker",children:[z("span",{className:"sv-ds-picker-label",children:"DS"}),z("select",{value:D,onChange:(_)=>Y&&Y(_.target.value),children:B.map((_)=>z("option",{value:_.name,children:_.name},_.name))})]}):null,z("span",{className:"sv-loc",children:z("code",{children:Z})})]}),q?.description?z("p",{className:"sv-ds-description",children:q.description}):null,z(JB0,{tokens:H,tokenGroups:K,tokensPath:U}),z(WB0,{tokenGroups:K}),N?z("div",{className:"sv-empty",children:O("p",{children:["No ",z("code",{children:"preview/"})," or ",z("code",{children:"ui_kits/"})," folders found under"," ",z("code",{children:Z}),"."]})}):O(G0,{children:[z(O00,{title:"preview",items:W,onOpen:J,kind:"preview",cfg:Q}),z(O00,{title:"ui kits",items:G,onOpen:J,kind:"ui_kits",cfg:Q})]})]})}function O00({title:X,items:J,onOpen:Q,kind:Y,cfg:W}){if(!J||J.length===0)return null;return O("section",{className:"sv-section",children:[O("h2",{children:[X," ",z("span",{className:"sv-count",children:J.length})]}),z("div",{className:"sv-previews sv-previews-"+Y,children:J.map((G)=>O("article",{className:"sv-preview-card",onClick:()=>Q(G.path),children:[z("div",{className:"sv-preview-frame",children:z("iframe",{src:Iz(G.path,W,{thumbnail:!0}),title:G.label,scrolling:"no",...W?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),O("div",{className:"sv-preview-foot",children:[z("strong",{children:G.label}),z("code",{children:G.path})]})]},G.path))})]})}function ZB0({activePath:X,selected:J,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,syncProject:K,syncOpen:U=!1,onOpenSync:q,changesCount:B=0,unpushed:N=0,savingIsManaged:F=!1,changesOpen:D=!1,onOpenChanges:_,version:R}){let w=X===c8,M=J&&J.selector?J.selector+(J.text?` — "${J.text.slice(0,60)}"`:""):"",P=J&&J.dom_path?J.dom_path.join(" > "):J?J.selector:"",I=W==="dark"?"light":"dark",k=(()=>{let C=Tz(H,{project:K});if(!C)return null;let y=C.names.length?` (${C.names.join(", ")})`:"";return{online:C.online,label:C.label,title:`${C.title}${y}${C.next?` — ${C.next}`:""}`}})(),$=k&&O(G0,{children:[z("span",{className:"st-sb-sync-dot"+(k.online?" is-online":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:"hub sync"}),z("span",{className:"val",title:k.title,children:k.label})]});return O("footer",{className:"st-statusbar",role:"contentinfo","data-testid":"statusbar",children:[O("span",{className:"st-sb-slot st-sb-active",role:"group","aria-label":"Active file",children:[z("span",{className:"lead","aria-hidden":"true"}),z("span",{className:"lbl",children:"active"}),z("span",{className:"val",title:X||"",children:w?"▦ design system":X||"—"})]}),X&&J&&J.selector&&!w&&O("span",{className:"st-sb-slot st-sb-sel",role:"group","aria-label":"Selected element",children:[z("span",{className:"lbl",children:"selected"}),z("span",{className:"val",title:P,children:M}),z("button",{type:"button",className:"st-sb-sel-clear",onClick:Z,"data-tip":"Clear · Esc inside iframe","data-tip-pos":"top","aria-label":"Clear selection",children:"×"})]}),O("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[z("span",{className:"lbl",children:"comments"}),O("span",{className:"val",children:[Y," open"]})]}),_&&O("button",{type:"button",className:"st-sb-slot st-sb-changes"+(D?" is-open":"")+(B>0?" has-changes":N>0?" has-unpushed":""),onClick:_,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":D,children:[z("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),z("span",{className:"lbl",children:"changes"}),z("span",{className:"val",children:F?"cloud saving":B>0?`${B} unsaved`:N>0?`${N} to publish`:"all saved"})]}),z("span",{className:"st-sb-spacer"}),O("span",{className:"st-sb-slot",role:"group","aria-label":"Connection",children:[z("span",{className:"st-live-dot"+(Q?" is-connected":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:Q?"live":"reconnecting"})]}),k&&(q?z("button",{type:"button",className:"st-sb-slot st-sb-sync st-sb-sync--btn"+(U?" is-open":""),onClick:q,"data-testid":"open-sync","data-tip":"Open Sync panel","data-tip-pos":"top","aria-label":"Open Sync panel","aria-pressed":U,children:$}):z("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:$})),R&&z("span",{className:"st-sb-slot st-sb-version",role:"group","aria-label":"Maude version",children:O("span",{className:"val","data-testid":"statusbar-version",children:["v",R]})}),O("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${I} theme`,"data-tip-pos":"top","aria-label":`Switch to ${I} theme`,children:[z(E9,{name:W==="dark"?"sun":"moon",size:13}),I]})]})}function HB0({commentsByFile:X,filter:J,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:K,width:U,resizing:q}){let B=f00(X),N=Object.keys(X||{}).sort(),F=[];for(let D of N){let _=X[D]||[],R=_.filter((M)=>{if(J==="open")return M.status!=="resolved";if(J==="resolved")return M.status==="resolved";return!0});if(R.length===0)continue;let w=_.filter((M)=>M.selector);F.push({file:D,comments:R.map((M)=>({...M,n:w.findIndex((P)=>P.id===M.id)+1}))})}return O("aside",{className:"st-rpanel"+(q?" is-resizing":""),style:U?{width:U,flexBasis:U}:void 0,"aria-label":"Comments",children:[z("div",{className:"st-rp-tabs st-rp-tabs--filters",children:O("div",{className:"st-cm-filters",role:"tablist",children:[O("button",{type:"button",className:"st-cm-filter"+(J==="all"?" is-active":""),role:"tab","aria-selected":J==="all",onClick:()=>Q("all"),children:["All · ",B.all]}),O("button",{type:"button",className:"st-cm-filter"+(J==="open"?" is-active":""),role:"tab","aria-selected":J==="open",onClick:()=>Q("open"),children:["Open · ",B.open]}),O("button",{type:"button",className:"st-cm-filter"+(J==="resolved"?" is-active":""),role:"tab","aria-selected":J==="resolved",onClick:()=>Q("resolved"),children:["Resolved · ",B.resolved]})]})}),z("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:F.length===0?O("div",{className:"st-rp-empty",children:[O("p",{children:["No comments ",J!=="all"?`with status “${J}”`:"yet","."]}),O("p",{children:["Open a canvas, hold ",z(wX,{children:"⌘"})," and click an element, then press ",z(wX,{children:"C"})," — or hold ",z(wX,{children:"⌘⇧"})," and click directly."]})]}):F.map((D)=>O(G0,{children:[O("button",{type:"button",className:"st-cm-group-hd",onClick:()=>G(D.file,null),title:D.file,children:[z("span",{children:pW(JH(D.file))}),z("span",{className:"st-mono",children:D.comments.length})]}),D.comments.map((_)=>O("div",{className:"st-comment"+(_.status==="resolved"?" is-resolved":"")+(_.id===W?" is-active":""),onClick:()=>G(D.file,_.id),children:[O("div",{className:"st-comment-hd",children:[z("span",{className:"st-pin st-pin--inline",children:_.n||"·"}),z("span",{className:"st-comment-time",children:E20(_.created)})]}),z("div",{className:"st-comment-txt",children:_.text}),O("div",{className:"st-comment-foot",children:[z("span",{className:"st-comment-sel",title:(_.dom_path||[]).join(" > "),children:_.selector||"—"}),Z&&H&&K?O("span",{className:"st-mini-act",children:[_.status==="resolved"?z("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(R)=>{R.stopPropagation(),H(_.id)},children:z(E9,{name:"reopen",size:14})}):z("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(R)=>{R.stopPropagation(),Z(_.id)},children:z(E9,{name:"resolve",size:14})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(R)=>{R.stopPropagation(),K(_.id)},children:z(E9,{name:"x",size:14})})]}):null]})]},_.id))]},D.file))})]})}var zB0={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 KB0({cloud:X}){let J=X?.role||null,[Q,Y]=u.useState(!1);if(!J||Q)return null;let W=`maude-cloud-role-seen:${J}`,G=!1;try{G=localStorage.getItem(W)==="1"}catch{}if(G)return null;let Z=zB0[J];if(!Z)return null;return O("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info","data-testid":"cloud-role-banner",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:Z}),z("button",{type:"button",className:"btn btn--ghost btn--sm","data-testid":"cloud-role-banner-dismiss",onClick:()=>{Y(!0);try{localStorage.setItem(W,"1")}catch{}},children:"Got it"})]})}function UB0({update:X,onDismiss:J}){let[Q,Y]=u.useState(!1);if(!X)return null;let W=X.version?` (v${X.version})`:"";return O("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),O("span",{children:["Maude updated",W," · restart to apply"]}),z("button",{type:"button",className:"btn btn--primary btn--sm",disabled:Q,onClick:()=>{Y(!0),af().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:J,children:"Later"})]})}function VB0({status:X}){let[J,Q]=u.useState(null);if(!X||X.linked===!1)return null;if(X.notSyncable)return null;let{state:Y,queuedOps:W,flash:G,conflicts:Z}=X,H=G==="synced",K=Y==="offline"||Y==="offline-long",U=X.docs?.rejected??0,q=Array.isArray(Z)?[...Z].reverse().find((D)=>D.kind==="cold-start-diverged"):null;if(!K&&!H&&!q&&U===0)return null;let B,N,F;if(H)B="success",N="Synced with hub",F=`${Y}:flash`;else if(K){let D=Z&&Z.length>0?` (${Z.length} conflict notice(s))`:"";if(Y==="offline-long")B="error",N=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${D}`;else B="warn",N=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${D}`;F=`${Y}:offline`}else if(q){if(q.snapshotFailed)B="error",N=`Diverged on ${q.slug}: kept local — the history snapshot FAILED, so the overwrite was refused. Check disk space / .design/_history write access.`;else B="warn",N=`Diverged on ${q.slug}: kept the ${q.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${q.slug}`;F=`diverged:${q.slug}:${q.at}`}else B="warn",N=`${U} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,F=`rejected:${U}`;if(J===F)return null;return O("div",{role:"status","aria-live":"polite",className:`st-banner st-banner--${B}`,children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:N}),z("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(F),children:"×"})]})}var qB0=["block","inline-block","flex","inline-flex","grid","inline","none"],M00=["px","%","fr","em","auto","min-content","max-content"];var BB0=["auto","stretch","flex-start","center","flex-end","baseline"];var _00=["300","400","500","600","700","800"],A00=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],w00=["none","solid","dashed","dotted","double"],E00=["px","rem","em","%","vw","vh","auto"],P00=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),WT={"font-size":{node:z(Y7,{as:WV,size:12})},"line-height":{node:z(Y7,{as:VV,size:12})},"letter-spacing":{node:z(Y7,{as:_V,size:12})},gap:{node:z(Y7,{as:YK,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:z(Y7,{as:RV,size:12})},"border-width":{node:z(Y7,{as:MV,size:12})}};var R00=["static","relative","absolute","fixed","sticky"],NB0=["normal","italic","oblique"],T00=["none","uppercase","lowercase","capitalize"];var I00=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],FB0=["fill","contain","cover","none","scale-down"];var k00=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],C00=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],_5={desktop:{label:"Desktop",width:1440,height:1024},laptop:{label:"Laptop",width:1280,height:800},tablet:{label:"Tablet",width:834,height:1194},mobile:{label:"Mobile",width:390,height:844}},SK=null;function kF(X){if(!X)return"";if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();try{if(!SK)SK=document.createElement("canvas").getContext("2d");if(!SK)return"";SK.fillStyle="#000000",SK.fillStyle=X;let J=SK.fillStyle;if(/^#[0-9a-f]{6}$/i.test(J))return J.toLowerCase();let Q=J.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(Q)return`#${[Q[1],Q[2],Q[3]].map((Y)=>Number(Y).toString(16).padStart(2,"0")).join("")}`}catch{}return""}var n4=(X)=>Math.min(1,Math.max(0,X));function AF(X){let J=/^#?([0-9a-f]{6})$/i.exec(X||"");if(!J)return{r:0,g:0,b:0};let Q=Number.parseInt(J[1],16);return{r:Q>>16&255,g:Q>>8&255,b:Q&255}}function v3({r:X,g:J,b:Q}){return`#${[X,J,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function f3({r:X,g:J,b:Q}){X/=255,J/=255,Q/=255;let Y=Math.max(X,J,Q),W=Math.min(X,J,Q),G=Y-W,Z=0;if(G){if(Y===X)Z=(J-Q)/G%6;else if(Y===J)Z=(Q-X)/G+2;else Z=(X-J)/G+4;if(Z*=60,Z<0)Z+=360}return{h:Z,s:Y?G/Y:0,v:Y}}function bK({h:X,s:J,v:Q}){let Y=Q*J,W=Y*(1-Math.abs(X/60%2-1)),G=Q-Y,Z=0,H=0,K=0;if(X<60)[Z,H,K]=[Y,W,0];else if(X<120)[Z,H,K]=[W,Y,0];else if(X<180)[Z,H,K]=[0,Y,W];else if(X<240)[Z,H,K]=[0,W,Y];else if(X<300)[Z,H,K]=[W,0,Y];else[Z,H,K]=[Y,0,W];return{r:(Z+G)*255,g:(H+G)*255,b:(K+G)*255}}function Z7(X){if(!X)return"";let J=/^(-?\d*\.?\d+)px$/.exec(X);return J?`${Math.round(Number.parseFloat(J[1]))}px`:X}function gQ(X){if(!X)return{n:"",unit:"px"};let J=X.trim(),Q=/^(-?\d*\.?\d+)\s*(px|rem|em|%|vw|vh)?$/.exec(J);if(Q)return{n:Q[1],unit:Q[2]||"px"};if(J==="auto")return{n:"",unit:"auto"};return{n:J,unit:""}}function $00(X,J){if(!X||Array.isArray(X)||Array.isArray(J)||!J)return X;if(!X.id&&!J.id){let Q=(Y)=>typeof Y.selector==="string"&&Y.selector.startsWith("[data-dc-screen=");if(Q(X)&&Q(J)&&X.selector===J.selector&&X.file===J.file)return{...X,authored:X.authored??J.authored,computed:X.computed??J.computed,customStyles:X.customStyles??J.customStyles,attrs:X.attrs??J.attrs,artboardId:X.artboardId??J.artboardId,worldW:X.worldW??J.worldW,worldH:X.worldH??J.worldH};return X}if(!X.id||X.id!==J.id)return X;return{...X,authored:X.authored??J.authored,computed:X.computed??J.computed,customStyles:X.customStyles??J.customStyles,attrs:X.attrs??J.attrs,photoKind:X.photoKind??J.photoKind,photoAsset:X.photoAsset??J.photoAsset}}function g00(X,J){return(X?J?.canvasDesignSystems?.[X]:null)||J?.defaultDesignSystem||J?.designSystems?.[0]?.name||null}function LB0(X){let J={};for(let Z of X.matchAll(/(--[a-z0-9-]+)\s*:\s*([^;}]+)/gi))if(!(Z[1]in J))J[Z[1]]=Z[2].trim();let Q={};for(let Z of Object.keys(J)){let H=J[Z],K=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(H);Q[Z]=K&&J[K[1]]?J[K[1]]:H}let Y=Object.keys(J),W=(Z)=>Y.filter((H)=>Z.test(H)),G=(Z)=>/^(#[0-9a-f]{3,8}|rgba?\(|hsla?\(|oklch\(|oklab\(|lab\(|lch\(|hwb\(|color\()/i.test(Z)||/^(transparent|currentcolor|white|black|red|green|blue|gray|grey|orange|yellow|purple|pink|cyan|magenta|teal|navy|maroon|olive|lime|aqua|silver|gold)$/i.test(Z);return{color:Y.filter((Z)=>G(Q[Z])),space:W(/^--space-/),radius:W(/^--radius-/),type:W(/^--type-/),shadow:W(/^--shadow-/),lh:W(/^--lh-/),vals:Q}}function m00(X,J,Q){let Y=X?.designSystems||[],W=Y.map((H)=>`${H.name}:${H.tokensCssRel}`).join("|"),[G,Z]=u.useState([]);return u.useEffect(()=>{if(!Y.length)return;let H=!1;return Promise.all(Y.map(async(K)=>{if(!K.tokensCssRel)return null;try{let U=await fetch(`/${J}/${K.tokensCssRel}`),q=U.ok?await U.text():"";return{name:K.name,...LB0(q)}}catch{return null}})).then((K)=>{if(H)return;let U=K.filter(Boolean);U.sort((q,B)=>q.name===Q?-1:B.name===Q?1:0),Z(U)}),()=>{H=!0}},[W,J,Q]),G}function u00({seed:X,label:J,onApply:Q}){let[Y,W]=u.useState(()=>f3(AF(X||"#000000"))),G=u.useRef(Y);G.current=Y;let Z=u.useRef(null),H=u.useRef(null),K=u.useRef(X);u.useEffect(()=>{if(X&&X!==K.current)K.current=X,W(f3(AF(X)))},[X]);let U=v3(bK(Y)),q=(M)=>{M.preventDefault();let P=Z.current?.getBoundingClientRect();if(!P)return;let I=G.current.h,k=(C)=>{W({h:I,s:n4((C.clientX-P.left)/P.width),v:n4(1-(C.clientY-P.top)/P.height)})};k(M);let $=()=>{document.removeEventListener("pointermove",k),document.removeEventListener("pointerup",$),Q(v3(bK(G.current)))};document.addEventListener("pointermove",k),document.addEventListener("pointerup",$)},B=(M)=>{M.preventDefault();let P=H.current?.getBoundingClientRect();if(!P)return;let{s:I,v:k}=G.current,$=(y)=>{W({h:n4((y.clientX-P.left)/P.width)*360,s:I,v:k})};$(M);let C=()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",C),Q(v3(bK(G.current)))};document.addEventListener("pointermove",$),document.addEventListener("pointerup",C)},N=(M)=>{let P={...G.current,...M};W(P),Q(v3(bK(P)))},F=(M)=>{let P=M.shiftKey?0.1:0.02,k={ArrowLeft:[-P,0],ArrowRight:[P,0],ArrowUp:[0,P],ArrowDown:[0,-P]}[M.key];if(!k)return;M.preventDefault(),N({s:n4(G.current.s+k[0]),v:n4(G.current.v+k[1])})},D=(M)=>{let P=M.shiftKey?20:2,k={ArrowLeft:-P,ArrowRight:P}[M.key];if(k==null)return;M.preventDefault(),N({h:Math.min(360,Math.max(0,G.current.h+k))})},_=async()=>{try{let M=window.EyeDropper;if(!M)return;let P=await new M().open();if(P?.sRGBHex)W(f3(AF(P.sRGBHex))),Q(P.sRGBHex)}catch{}},R=bK(Y),w=(M)=>{let P={...R,...M},I=f3({r:n4(P.r/255)*255,g:n4(P.g/255)*255,b:n4(P.b/255)*255});W(I),Q(v3(bK(I)))};return O("div",{className:"st-cp-cpick",children:[O("div",{className:"st-cp-cpick-hexrow",children:[z("span",{className:"st-cp-cpick-hexsw",style:{background:U}}),z("input",{className:"st-cp-cpick-hex",type:"text",value:U,"aria-label":J?`${J} hex value`:"hex value",onChange:(M)=>{let P=M.target.value;if(/^#?[0-9a-f]{6}$/i.test(P))W(f3(AF(P)))},onKeyDown:(M)=>{if(M.key==="Enter")Q(M.currentTarget.value)},onBlur:(M)=>Q(M.currentTarget.value),onFocus:(M)=>M.currentTarget.select()})]}),O("button",{type:"button",ref:Z,className:"st-cp-cpick-sv","aria-label":J?`${J} saturation and value`:"saturation and value",style:{background:`hsl(${Y.h} 100% 50%)`},onPointerDown:q,onKeyDown:F,children:[z("span",{className:"st-cp-cpick-svwhite"}),z("span",{className:"st-cp-cpick-svblack"}),z("span",{className:"st-cp-cpick-knob",style:{left:`${Y.s*100}%`,top:`${(1-Y.v)*100}%`,background:U}})]}),O("div",{className:"st-cp-cpick-controls",children:[window.EyeDropper?z("button",{type:"button",className:"st-cp-cpick-eye","aria-label":"pick from screen",title:"eyedropper",onClick:_,children:z(E9,{name:"eyedropper",size:14})}):null,z("span",{className:"st-cp-cpick-preview",style:{background:U},"aria-hidden":"true"}),z("button",{type:"button",ref:H,className:"st-cp-cpick-hue","aria-label":J?`${J} hue`:"hue",onPointerDown:B,onKeyDown:D,children:z("span",{className:"st-cp-cpick-huethumb",style:{left:`${Y.h/360*100}%`}})})]}),z("div",{className:"st-cp-cpick-rgb",children:["r","g","b"].map((M)=>O("label",{className:"st-cp-cpick-rgbf",children:[z("input",{"aria-label":M.toUpperCase(),value:Math.round(R[M]),onChange:(P)=>w({[M]:n4((Number.parseFloat(P.target.value)||0)/255)*255}),onFocus:(P)=>P.currentTarget.select()}),z("span",{children:M.toUpperCase()})]},M))})]})}function EF({kind:X,groups:J,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:K}){let[U,q]=u.useState(!1),[B,N]=u.useState(null),[F,D]=u.useState("custom"),[_,R]=u.useState(""),w=u.useRef(null),M=u.useRef(null),P=typeof Q==="string"&&/var\(\s*--/.test(Q),I=(a)=>Q===`var(${a})`,k=(a)=>a.replace(/^--/,"").replace(/-/g," "),$=J||[],C=$.reduce((a,c)=>a+(c.names?.length||0),0),y=$.length>1,f=_.trim().toLowerCase(),h=!f?$:$.map((a)=>({...a,names:(a.names||[]).filter((c)=>k(c).toLowerCase().includes(f)||c.toLowerCase().includes(f)||(a.vals?.[c]||"").toLowerCase().includes(f))})).filter((a)=>a.names.length);u.useEffect(()=>{if(!U){R("");return}let a=()=>{let Z0=w.current?.getBoundingClientRect();if(!Z0)return;let e=224,N0=300,K0=Math.min(Z0.right-e,window.innerWidth-e-8);if(K0<8)K0=8;let Q8=window.innerHeight-Z0.bottom>N0+8?Z0.bottom+4:Math.max(8,Z0.top-N0-4);N({left:K0,top:Q8,width:e,maxHeight:N0})};a();let c=(Z0)=>{if(M.current?.contains(Z0.target)||w.current?.contains(Z0.target))return;q(!1)},U0=(Z0)=>{if(Z0.key==="Escape")q(!1)},o=(Z0)=>{if(M.current?.contains(Z0.target))return;a()};return document.addEventListener("pointerdown",c,!0),document.addEventListener("keydown",U0),window.addEventListener("resize",a),document.addEventListener("scroll",o,!0),()=>{document.removeEventListener("pointerdown",c,!0),document.removeEventListener("keydown",U0),window.removeEventListener("resize",a),document.removeEventListener("scroll",o,!0)}},[U]),u.useEffect(()=>{if(!U||!B||!M.current)return;let a=M.current.getBoundingClientRect(),c=B.left-a.left,U0=B.top-a.top;if(Math.abs(c)>0.5||Math.abs(U0)>0.5)N((o)=>o?{...o,left:o.left+c,top:o.top+U0}:o)},[U,B]);let d=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,n=(a,c,U0)=>{if(H&&a&&a!==H&&U0&&!d.test(U0))Y(U0);else Y(`var(${c})`);q(!1)},x=(a)=>{let c=(a||"").trim();if(c)Y(c)},m=O("div",{className:"st-cp-pop-search",children:[z(E9,{name:"search",size:12}),z("input",{value:_,onChange:(a)=>R(a.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),p=(a)=>a.map((c)=>O("div",{className:"st-cp-pop-group",children:[y?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((U0)=>O("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${I(U0)?" is-on":""}`,onClick:()=>n(c.ds,U0,c.vals?.[U0]),children:[z("span",{className:"st-cp-pop-cswatch",style:{background:c.vals?.[U0]||"transparent"},"aria-hidden":"true"}),z("span",{className:"st-cp-pop-name",children:k(U0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[U0]||""})]},`${c.ds}:${U0}`))})]},c.ds)),v=(a)=>a.map((c)=>O("div",{className:"st-cp-pop-group",children:[y?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((U0)=>O("button",{type:"button",className:`st-cp-pop-row${I(U0)?" is-on":""}`,onClick:()=>n(c.ds,U0,c.vals?.[U0]),children:[z("span",{className:"st-cp-pop-name",children:k(U0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[U0]||""})]},`${c.ds}:${U0}`))})]},c.ds)),r=z("div",{className:"st-cp-pop-empty",children:"No match"});return O(G0,{children:[G!==void 0?z("button",{type:"button",ref:w,className:`${K||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${P&&!K?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>q((a)=>!a),children:z("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):z("button",{type:"button",ref:w,className:`st-cp-tokbtn${P?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>q((a)=>!a),children:z("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),U&&B?b00.createPortal(z("div",{ref:M,className:"maude st-cp-pop","data-theme":typeof document<"u"&&document.documentElement.getAttribute("data-theme")||"dark",role:"dialog","aria-label":W||"design tokens",style:{left:B.left,top:B.top,width:B.width,maxHeight:B.maxHeight},children:X==="color"?O(G0,{children:[O("div",{className:"st-cp-poptabs",role:"tablist",children:[z("button",{type:"button",role:"tab","aria-selected":F==="custom",className:`st-cp-poptab${F==="custom"?" is-active":""}`,onClick:()=>D("custom"),children:"Custom"}),z("button",{type:"button",role:"tab","aria-selected":F==="vars",className:`st-cp-poptab${F==="vars"?" is-active":""}`,onClick:()=>D("vars"),children:"Variables"})]}),F==="custom"?z(u00,{seed:Z||kF(Q)||"#000000",onApply:x}):!C?z("div",{className:"st-cp-pop-empty",children:"No color tokens"}):O(G0,{children:[m,h.length?p(h):r]})]}):!C?z("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):O(G0,{children:[m,h.length?v(h):r]})}),document.body):null]})}function S00({label:X,tracks:J,editable:Q,onChange:Y}){let W=(K,U)=>{let q=J[K];Y(J.map((B,N)=>N===K?ZU.has(U)?{value:0,unit:U}:{value:q.value||1,unit:U}:B))},G=(K,U)=>{Y(J.map((q,B)=>B===K?{...q,value:U}:q))},Z=()=>Y([...J,{value:1,unit:"fr"}]),H=(K)=>Y(J.filter((U,q)=>q!==K));return O("div",{className:"st-cp-gridtracks",children:[O("div",{className:"st-cp-gridtracks-hd",children:[z("span",{className:"st-cp-gridtracks-label",children:X}),z("button",{type:"button",className:"st-btn st-cp-gridtracks-add",disabled:!Q,onClick:Z,children:"+ Track"})]}),J.length===0?O("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",X.toLowerCase(),"."]}):J.map((K,U)=>{let q=ZU.has(K.unit);return O("div",{className:"st-cp-gridtrack-row",children:[q?z(IW,{value:K.unit,ariaLabel:`${X} track ${U+1}`,options:M00.map((B)=>({value:B,label:B})),onChange:(B)=>W(U,B)}):z(WX,{value:K.value,min:K.unit==="fr"?0.1:0,step:K.unit==="fr"?0.1:1,ariaLabel:`${X} track ${U+1} value`,lead:String(U+1),unitSlot:z(QN,{value:K.unit,units:M00,ariaLabel:`${X} track ${U+1} unit`,onChange:(B)=>W(U,B)}),onCommit:(B)=>G(U,B)}),z("button",{type:"button",className:"st-btn st-cp-gridtrack-remove","aria-label":`remove ${X} track ${U+1}`,disabled:!Q||J.length<=1,onClick:()=>H(U),children:"×"})]},U)})]})}function DB0({el:X,cfg:J,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let K=!!X.id,U=X.computed||{},[q,B]=u.useState({a:{},c:{},t:{}});u.useEffect(()=>{B({a:{},c:{},t:{}})},[X.id]);let N=(X0,_0)=>{let B0={...X0||{}};for(let[S0,t0]of Object.entries(_0))if(t0===null)delete B0[S0];else B0[S0]=t0;return B0},F=N(X.authored,q.a),D=N(X.customStyles,q.c),_=N(X.attrs,q.t),R=(X0,_0)=>B((B0)=>({...B0,a:{...B0.a,[X0]:_0}})),w=(X0,_0)=>B((B0)=>({...B0,c:{...B0.c,[X0]:_0}})),M=(X0,_0)=>B((B0)=>({...B0,t:{...B0.t,[X0]:_0}})),P=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),I=g00(X.file,J),k=m00(J,P,I),$=(X0)=>k.map((_0)=>({ds:_0.name,names:_0[X0]||[],vals:_0.vals})).filter((_0)=>_0.names.length),[C,y]=u.useState({}),[f,h]=u.useState({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),d=Object.keys(D).length>0||Object.keys(_).length>0;u.useEffect(()=>{if(d)h((X0)=>X0.Advanced?X0:{...X0,Advanced:!0})},[X.id,d]);let n=(F.position||Z7(U.position)||"static")!=="static";u.useEffect(()=>{if(n)h((X0)=>X0["d:Position"]?X0:{...X0,"d:Position":!0})},[X.id,n]);let x=H,[m,p]=u.useState({});async function v(X0,_0,B0){y((S0)=>({...S0,[B0]:"saving"}));try{let S0=await fetch(X0,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(_0)}),t0=await S0.json().catch(()=>({}));y((j8)=>({...j8,[B0]:!S0.ok||!t0.ok?`err:${t0&&t0.error||`HTTP ${S0.status}`}`:"saved"}))}catch(S0){y((t0)=>({...t0,[B0]:`err:${S0&&S0.message?S0.message:String(S0)}`}))}}let r=(X0,_0)=>{if(!Q||!X.id)return;Q({id:X.id,artboardId:X.artboardId??null,index:X.index??0,prop:X0,value:_0})},a=(X0,_0,B0,S0)=>{Y?.({op:X0,canvas:X.file,id:X.id,key:_0,before:B0==null||B0===""?null:B0,after:S0==null||S0===""?null:S0})},c=(X0,_0)=>{let B0=(_0||"").trim();if(!K||!B0)return;let S0=F[X0]??null;if(B0===(S0??"").trim())return;r(X0,B0),R(X0,B0),v("/_api/edit-css",{canvas:X.file,id:X.id,property:X0,value:B0},X0),a("css",X0,S0,B0)},U0=(X0,_0)=>{let B0=(_0||"").trim(),S0=X0.trim();if(!K||!S0||!B0)return;let t0=D[S0]??null;r(S0,B0),w(S0,B0),v("/_api/edit-css",{canvas:X.file,id:X.id,property:S0,value:B0},S0),a("css",S0,t0,B0)},o=(X0,_0)=>{let B0=(X0||"").trim(),S0=(_0||"").trim();if(!K||!B0||!S0)return;let t0=_[B0]??null;M(B0,S0),v("/_api/edit-attr",{canvas:X.file,id:X.id,attr:B0,value:S0},`@${B0}`),a("attr",B0,t0,S0)},Z0=(X0)=>{if(!K)return;let _0=F[X0]??null;r(X0,null),R(X0,null),v("/_api/edit-css",{canvas:X.file,id:X.id,property:X0,reset:!0},X0),a("css",X0,_0,null)},e=(X0)=>{if(!K)return;let _0=D[X0]??null;r(X0,null),w(X0,null),v("/_api/edit-css",{canvas:X.file,id:X.id,property:X0,reset:!0},X0),a("css",X0,_0,null)},N0=(X0)=>{if(!K)return;let _0=_[X0]??null;M(X0,null),v("/_api/edit-attr",{canvas:X.file,id:X.id,attr:X0,reset:!0},`@${X0}`),a("attr",X0,_0,null)},K0={display:X.parentDisplay,flexDirection:X.parentFlexDirection},u0=(X0,_0)=>{if(!K)return;let B0=Math.round((X0==="width"?X.bounds?.w:X.bounds?.h)||0),S0=_S(X0,_0,K0,B0);for(let t0 of S0.reset)if(F[t0])Z0(t0);for(let[t0,j8]of S0.set)c(t0,j8)},Q8=X.parentDisplay==="flex"||X.parentDisplay==="inline-flex",o0=(X0)=>{let _0=MS(X0,F,U,K0);return O("div",{className:"st-cp-moderow",children:[z("span",{className:"st-cp-modelabel",children:X0==="width"?"Width sizing":"Height sizing"}),z("div",{className:"st-cp-modeseg",role:"group","aria-label":`${X0} sizing mode`,children:z(YN,{value:_0,ariaLabel:`${X0} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(B0)=>u0(X0,B0)})})]},`mode-${X0}`)},_8=["flex-start","center","flex-end"],A0=["flex-start","center","flex-end"],r0=["t","c","b"],P0=["l","c","r"],K8=()=>{let X0=!(F["flex-direction"]||Z7(U["flex-direction"])||"row").startsWith("column"),_0=Math.max(0,_8.indexOf(F["justify-content"]||Z7(U["justify-content"])||"flex-start")),B0=F["align-items"]||Z7(U["align-items"])||"stretch",S0=B0==="stretch"?1:Math.max(0,A0.indexOf(B0)),[t0,j8]=X0?[_0,S0]:[S0,_0];return r0[j8]+P0[t0]},F8=(X0)=>{let _0=r0.indexOf(X0[0]),B0=P0.indexOf(X0[1]),S0=!(F["flex-direction"]||Z7(U["flex-direction"])||"row").startsWith("column"),[t0,j8]=S0?[B0,_0]:[_0,B0];c("justify-content",_8[t0]),c("align-items",A0[j8])},D8=(X0)=>{if(!(X0.metaKey||X0.ctrlKey)||X0.altKey)return;let _0=X0.key.toLowerCase();if(_0==="z")X0.preventDefault(),G?.(X0.shiftKey?"redo":"undo");else if(_0==="y")X0.preventDefault(),G?.("redo")},W8=(X0)=>{let _0=F[X0];if(!_0)return"inherit";return/var\(\s*--/.test(_0)?"bound":"raw"};if(!K)return O("div",{className:"st-cp",children:[z("div",{className:"st-cp-id",children:z("span",{className:"st-cp-idtag",children:X.tag||"element"})}),O("div",{className:"st-css-disabled",children:["This selection has no stable element id (a legacy canvas, or a non-element target). Edit it with ",z("code",{children:"/design:edit"}),"."]})]});let A8={bound:"token-bound",raw:"raw override",inherit:"inherited"},i8=(X0)=>z("span",{className:`st-cp-prov st-cp-prov--${X0}`,role:"img","aria-label":A8[X0]}),P9=(X0,_0)=>{let B0=_0??W8(X0),S0=C[X0],t0=typeof S0==="string"&&S0.startsWith("err:")?S0.slice(4):"",j8=t0?" is-err":S0==="saved"?" is-saved":S0==="saving"?" is-saving":"",g8=!!F[X0],t8=t0?`error: ${t0}`:g8?`${A8[B0]} · double-click to reset`:A8[B0];return z("button",{type:"button",className:`st-cp-prov st-cp-prov--${B0}${j8}${g8?" is-resettable":""}`,"aria-label":t8,title:t8,tabIndex:g8?0:-1,onDoubleClick:g8?()=>Z0(X0):void 0,onKeyDown:g8?(G9)=>{if(G9.key==="Backspace"||G9.key==="Delete")G9.preventDefault(),Z0(X0)}:void 0})},l0=(X0,_0,B0,S0)=>{let t0=B0===void 0&&!F[X0],j8=S0??X0;return O("div",{className:`st-cp-row${t0?" is-unset":""}`,children:[P9(X0,B0),z("label",{className:"st-cp-label",title:j8,children:j8}),z("div",{className:"st-cp-ctl",children:_0})]},X0)},i0={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"]},j0=(X0)=>{(i0[X0]||[]).forEach((_0)=>{if(F[_0])Z0(_0)})},I0=(X0,_0)=>{let B0=(i0[X0]||[]).some((S0)=>F[S0]);return O("section",{className:"st-cp-sec",children:[O("div",{className:"st-cp-sechd-row",children:[O("button",{type:"button",className:"st-cp-sechd","aria-expanded":!!f[X0],onClick:()=>h((S0)=>({...S0,[X0]:!S0[X0]})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:f[X0]?"▾":"▸"}),X0]}),z("button",{type:"button",className:`st-cp-secreset${B0?"":" is-quiet"}`,"aria-label":`reset ${X0} section to original`,title:`reset ${X0}`,disabled:!B0,onClick:()=>j0(X0),children:z(Y7,{as:wZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${f[X0]?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:_0})})]},X0)},T8=(X0,_0,B0,S0=!0)=>{let t0=`d:${X0}`,j8=f[t0]===void 0?S0:f[t0],g8=_0.some((t8)=>F[t8]);return O("section",{className:"st-cp-sec",children:[O("div",{className:"st-cp-sechd-row",children:[O("button",{type:"button",className:"st-cp-sechd","aria-expanded":j8,onClick:()=>h((t8)=>({...t8,[t0]:!j8})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:j8?"▾":"▸"}),X0]}),z("button",{type:"button",className:`st-cp-secreset${g8?"":" is-quiet"}`,"aria-label":`reset ${X0} to original`,title:`reset ${X0}`,disabled:!g8,onClick:()=>_0.forEach((t8)=>{if(F[t8])Z0(t8)}),children:z(Y7,{as:wZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${j8?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:B0})})]},t0)},Z8=(X0)=>z("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!m[X0],"aria-label":m[X0]?`${X0} — fewer options`:`${X0} — more options`,title:m[X0]?"fewer":"more",onClick:()=>p((_0)=>({..._0,[X0]:!_0[X0]})),children:m[X0]?"▴":"···"}),z0=(X0,_0)=>O("select",{className:"st-cp-nsel","aria-label":X0,value:_0.includes(F[X0])?F[X0]:"",onChange:(B0)=>c(X0,B0.target.value),children:[z("option",{value:"",disabled:!0,children:Z7(U[X0])||"—"}),_0.map((B0)=>z("option",{value:B0,children:B0},B0))]}),f0=(X0)=>$(X0).flatMap((_0)=>(_0.names||[]).map((B0)=>({name:B0,value:_0.vals?.[B0]||""}))),L8=(X0,_0)=>z(mA,{value:F[X0]||Z7(U[X0])||_0[0].value,ariaLabel:X0,options:_0,onChange:(B0)=>c(X0,B0)}),n8=(X0,_0,B0={})=>{let S0=gQ(F[X0]??""),t0=P00.has(X0),j8=F[X0]??"",g8=typeof j8==="string"&&/var\(\s*--/.test(j8),t8=t0?"":S0.unit&&S0.unit!=="auto"?S0.unit:"px",G9=Number.parseFloat(gQ(Z7(U[X0])??"").n)||0,w9=S0.n!==""&&S0.n!=null?Number.parseFloat(S0.n)||0:G9,F7=WT[X0];return z(WN,{value:g8?j8:w9,tokens:f0(_0),ariaLabel:X0,min:B0.min??0,lead:F7?F7.node??F7.t:void 0,unitSlot:t0?null:z(QN,{units:E00,value:S0.unit||"px",ariaLabel:`${X0} unit`,onChange:(g9)=>c(X0,g9==="auto"?"auto":`${S0.n||"0"}${g9}`)}),onChange:(g9)=>c(X0,typeof g9==="string"?g9:t0?`${g9}`:`${g9}${t8}`)})},k8=()=>{let X0=(t0)=>Number.parseFloat(gQ(F[t0]??F["border-radius"]??Z7(U[t0])??Z7(U["border-radius"])??"0").n)||0,_0={tl:X0("border-top-left-radius"),tr:X0("border-top-right-radius"),bl:X0("border-bottom-left-radius"),br:X0("border-bottom-right-radius")},B0=(t0)=>{if(t0.tl===t0.tr&&t0.tr===t0.bl&&t0.bl===t0.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((g8)=>{if(F[g8])Z0(g8)}),c("border-radius",`${t0.tl}px`);else c("border-top-left-radius",`${t0.tl}px`),c("border-top-right-radius",`${t0.tr}px`),c("border-bottom-left-radius",`${t0.bl}px`),c("border-bottom-right-radius",`${t0.br}px`)},S0=WT["border-radius"];return z(ax,{corners:_0,lead:S0?S0.node??S0.t:void 0,onCorners:B0})},q8=()=>O("div",{className:"st-cp-border",children:[b9("border-width",null,{fixedUnit:"px"}),O("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:w00.includes(F["border-style"])?F["border-style"]:"",onChange:(X0)=>c("border-style",X0.target.value),children:[z("option",{value:"",disabled:!0,children:"style"}),w00.map((X0)=>z("option",{value:X0,children:X0},X0))]}),z(EF,{kind:"color",groups:$("color"),current:F["border-color"],activeDs:I,swatchBg:U["border-color"]||F["border-color"]||"",seedHex:kF(U["border-color"]||F["border-color"])||"#000000",onPick:(X0)=>c("border-color",X0),label:"border colour"})]}),w0=()=>{let X0=F.transform||Z7(U.transform)||"",_0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(X0),B0=((_0?Number.parseFloat(_0[1]):0)%360+360)%360,S0=(t0)=>{let j8=(t0%360+360)%360,g8=(F.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();c("transform",`${g8?`${g8} `:""}rotate(${j8}deg)`.trim())};return O("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[z(nx,{value:B0,onChange:S0}),z(WX,{value:B0,min:0,max:360,ariaLabel:"rotation",lead:z(Y7,{as:wZ}),steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:S0})]})},L0=()=>{let X0=F.filter||Z7(U.filter)||"",_0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(X0),B0=_0?Number.parseFloat(_0[1]):0;return z(WX,{value:B0,min:0,ariaLabel:"filter blur",unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(t0)=>{let j8=(F.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();c("filter",t0>0?`${j8?`${j8} `:""}blur(${t0}px)`.trim():j8||"none")}})},d0=()=>{let X0=F.opacity,_0=X0!=null&&X0!==""?Number.parseFloat(X0):Number.parseFloat(Z7(U.opacity))||1,B0=Math.round((Number.isNaN(_0)?1:_0)*100);return z(TJ,{value:B0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(S0)=>r("opacity",String(S0/100)),onCommit:(S0)=>c("opacity",String(S0/100))},`opacity:${X0??""}`)},V8=()=>{let X0=Number.parseInt(F["font-weight"]||Z7(U["font-weight"])||"400",10)>=600,_0=(F["font-style"]||Z7(U["font-style"]))==="italic",B0=/underline/.test(F["text-decoration"]||Z7(U["text-decoration"])||"");return z(ix,{value:{b:X0,i:_0,u:B0},ariaLabel:"text style",options:[{value:"b",node:z(Y7,{as:qV}),label:"Bold"},{value:"i",node:z(Y7,{as:DV}),label:"Italic"},{value:"u",node:z(Y7,{as:kV}),label:"Underline"}],onToggle:(S0)=>{if(S0==="b")c("font-weight",X0?"400":"700");else if(S0==="i")c("font-style",_0?"normal":"italic");else c("text-decoration",B0?"none":"underline")}})},O8=[{value:"row",node:z(Y7,{as:DW}),label:"Row"},{value:"column",node:z(Y7,{as:OW}),label:"Column"}],a8=[{value:"flex-start",node:z(Y7,{as:HV}),label:"Start"},{value:"center",node:z(Y7,{as:GV}),label:"Center"},{value:"flex-end",node:z(Y7,{as:ZV}),label:"End"},{value:"space-between",node:z(Y7,{as:YK}),label:"Space between"}],E8=[{value:"flex-start",node:z(Y7,{as:UV}),label:"Start"},{value:"center",node:z(Y7,{as:zV}),label:"Center"},{value:"flex-end",node:z(Y7,{as:KV}),label:"End"},{value:"stretch",node:z(Y7,{as:TV}),label:"Stretch"}],N9=[{value:"left",node:z(Y7,{as:m5}),label:"Left"},{value:"center",node:z(Y7,{as:AW}),label:"Center"},{value:"right",node:z(Y7,{as:wW}),label:"Right"},{value:"justify",node:z(Y7,{as:EW}),label:"Justify"}],Y9=[{value:"visible",node:z(Y7,{as:AZ}),label:"Visible"},{value:"hidden",node:z(Y7,{as:EZ}),label:"Hidden"},{value:"scroll",node:z(Y7,{as:EV}),label:"Scroll"}],e7=(X0,_0)=>{let B0=$(_0);return B0.length?z(EF,{kind:"value",groups:B0,current:F[X0],activeDs:I,onPick:(S0)=>c(X0,S0),label:`${X0} design token`}):null},E0=(X0)=>{let _0=X0.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===_0)_0.select()})},h8=(X0,_0)=>{if(X0.key!=="ArrowUp"&&X0.key!=="ArrowDown")return!1;X0.preventDefault();let B0=X0.shiftKey?10:1,S0=X0.key==="ArrowUp"?1:-1,t0=(Number.parseFloat(X0.currentTarget.value)||0)+S0*B0;return X0.currentTarget.value=String(t0),_0(t0),!0},F9=(X0)=>z("input",{className:"st-cp-fin","aria-label":X0,defaultValue:F[X0]??"",placeholder:Z7(U[X0])||"—",onFocus:E0,onKeyDown:(_0)=>{if(_0.key==="Enter")_0.currentTarget.blur()},onBlur:(_0)=>c(X0,_0.currentTarget.value)},`${X0}:${F[X0]??""}`),b9=(X0,_0,B0={})=>{let S0=gQ(F[X0]??""),t0=P00.has(X0),j8=t0?"":B0.fixedUnit||(S0.unit&&S0.unit!=="auto"?S0.unit:"px"),g8=WT[X0],t8=Number.parseFloat(gQ(Z7(U[X0])??"").n)||0,G9=S0.n!==""&&S0.n!=null?Number.parseFloat(S0.n)||0:t8;return O(G0,{children:[z(WX,{value:G9,min:B0.min??0,step:1,ariaLabel:X0,lead:g8?g8.node??g8.t:void 0,onCommit:(w9)=>c(X0,t0?`${w9}`:`${w9}${j8}`),unitSlot:t0||B0.fixedUnit?null:z(QN,{units:E00,value:S0.unit||"px",ariaLabel:`${X0} unit`,onChange:(w9)=>c(X0,w9==="auto"?"auto":`${S0.n||"0"}${w9}`)})},`${X0}:${F[X0]??""}`),e7(X0,_0)]})},l7=(X0)=>{let _0=U[X0]||F[X0]||"",B0=F[X0]??"",S0=typeof B0==="string"&&/var\(\s*--/.test(B0),t0=S0?B0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):B0;return z($V,{swatch:z(EF,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:$("color"),current:F[X0],activeDs:I,swatchBg:_0,seedHex:kF(U[X0]||F[X0])||"#000000",onPick:(j8)=>c(X0,j8),label:`${X0} colour`}),displayValue:t0,bound:S0,ariaLabel:X0,onValue:(j8)=>c(X0,j8)})},c6=(X0,_0)=>{let B0=null,S0=_0.unitless?"":"px",t0=(t8)=>_0.unitless?`${t8}`:`${t8}${S0}`,j8=(t8,G9,w9)=>{for(let F7 of G9??[X0])w9(F7,t0(t8))},g8=gA({getBase:()=>B0?.value??"0",min:_0.min??0,step:1,sides:_0.sides,onInput:(t8,G9)=>{if(B0)B0.value=String(t8);if(G9){let w9=B0?.closest(".st-cp-box");for(let F7 of G9){if(F7===X0)continue;let g9=w9?.querySelector(`.st-cp-boxv[aria-label="${F7}"]`);if(g9)g9.value=String(t8)}}j8(t8,G9,r)},onCommit:(t8,G9)=>j8(t8,G9,c)});return{onPointerDown:(t8)=>{B0=t8.currentTarget,g8(t8)}}},p8=(X0,_0)=>{let B0=F[X0],S0=B0!=null&&B0!==""?gQ(B0).n||B0:gQ(Z7(U[X0])??"").n||"0",t0=!B0||B0==="0"||B0==="0px"||B0==="auto",j8=X0.split("-").pop(),g8=j8==="top"||j8==="bottom"?[`${_0}-top`,`${_0}-bottom`]:[`${_0}-left`,`${_0}-right`],t8=[`${_0}-top`,`${_0}-right`,`${_0}-bottom`,`${_0}-left`];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${_0[0]}${X0.split("-").pop()[0]}${t0?" is-zero":""}`,"aria-label":X0,defaultValue:S0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...c6(X0,{sides:{pair:g8,all:t8}}),onFocus:E0,onKeyDown:(G9)=>{if(h8(G9,(w9)=>c(X0,`${w9}px`)))return;if(G9.key==="Enter")G9.currentTarget.blur()},onBlur:(G9)=>{let w9=G9.currentTarget.value.trim();if(!w9)return;let F7=/[a-z%]/i.test(w9)?w9:`${w9}px`;c(X0,F7)}},`${X0}:${B0??""}`)},H7=(X0)=>{let _0=F[X0],B0=_0!=null&&_0!==""&&_0!=="auto"?gQ(_0).n||_0:gQ(Z7(U[X0])??"").n||"",S0=!_0||_0==="auto"||_0==="0"||_0==="0px",t0=X0==="top"||X0==="bottom"?["top","bottom"]:["left","right"],j8=["top","right","bottom","left"];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${X0[0]}${S0?" is-zero":""}`,"aria-label":X0,defaultValue:B0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...c6(X0,{sides:{pair:t0,all:j8},min:-1/0}),onFocus:E0,onKeyDown:(g8)=>{if(h8(g8,(t8)=>c(X0,`${t8}px`)))return;if(g8.key==="Enter")g8.currentTarget.blur()},onBlur:(g8)=>{let t8=g8.currentTarget.value.trim();if(!t8)return;let G9=/[a-z%]/i.test(t8)?t8:`${t8}px`;c(X0,G9)}},`${X0}:${_0??""}`)},z7=Object.entries(D),P7=Object.entries(_),T9=()=>{let X0=(X.tag||"").toLowerCase(),B0=X0==="img"||X0==="video"||X0==="picture"||X0==="svg"||X0==="canvas"||!!F["object-fit"]||!!F["object-position"]||!!F["aspect-ratio"],S0=(X0==="img"||X0==="video")&&!!X.attrs?.src&&!!W;return{showMedia:B0,canReplace:S0}},S6=(X0)=>O(G0,{children:[X0&&z("div",{className:"st-cp-mediabtn",children:z("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>W(X),children:"Replace…"})}),l0("object-fit",z0("object-fit",FB0)),l0("object-position",F9("object-position")),l0("aspect-ratio",O("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:C00.includes(F["aspect-ratio"])?F["aspect-ratio"]:"",onChange:(_0)=>{let B0=_0.target.value;if(c("aspect-ratio",B0),B0&&B0!=="auto"&&F.height)Z0("height")},children:[z("option",{value:"",disabled:!0,children:Z7(U["aspect-ratio"])||"—"}),C00.map((_0)=>z("option",{value:_0,children:_0},_0))]}))]});return O("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:D8,children:[O("div",{className:"st-cp-id",children:[O("span",{className:"st-cp-idtag",children:[X.tag||"element",X.classes?O("span",{className:"st-cp-idcls",children:[".",X.classes.split(/\s+/)[0]]}):null]}),z("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:z(mA,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:z(Y7,{as:LW,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:z(Y7,{as:PW,size:12}),label:"Designer — Figma vocabulary"}],onChange:x})})]}),Z==="designer"?O(G0,{children:[T8("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let X0=(F.display||Z7(U.display)||"").trim();return X0==="flex"||X0==="inline-flex"?O(G0,{children:[l0("flex-direction",L8("flex-direction",O8),void 0,"Direction"),l0("align-items",z(ox,{value:K8(),onChange:F8,ariaLabel:"auto-layout alignment"}),W8("align-items"),"Alignment"),l0("gap",n8("gap","space"),void 0,"Gap"),O("div",{className:"st-cp-modes",children:[o0("width"),o0("height")]}),O("div",{className:"st-cp-box","aria-label":"padding",children:[O("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[i8(W8("padding-top")),"padding"]}),p8("padding-top","padding"),p8("padding-right","padding"),p8("padding-bottom","padding"),p8("padding-left","padding")]}),z("div",{className:"st-cp-clustermore-row",children:Z8("Auto layout")}),m["Auto layout"]?l0("flex-wrap",z(yQ,{checked:/^wrap/.test(F["flex-wrap"]||Z7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(B0)=>c("flex-wrap",B0?"wrap":"nowrap")}),W8("flex-wrap"),"Wrap"):null]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>c("display","flex"),children:"+ Auto layout (flex)"})})()),T8("Size",["width","height","min-width","max-width","min-height","max-height"],O(G0,{children:[l0("width",b9("width"),void 0,"Width"),l0("height",b9("height"),void 0,"Height"),z("div",{className:"st-cp-clustermore-row",children:Z8("Size")}),m.Size?O(G0,{children:[l0("min-width",b9("min-width"),void 0,"Min width"),l0("max-width",b9("max-width"),void 0,"Max width"),l0("min-height",b9("min-height"),void 0,"Min height"),l0("max-height",b9("max-height"),void 0,"Max height")]}):null]})),T8("Position",["position","top","right","bottom","left","z-index"],O(G0,{children:[l0("position",z0("position",R00),void 0,"Position"),O("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[O("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[i8(W8("top")),"inset"]}),H7("top"),H7("right"),H7("bottom"),H7("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||Z7(U.position)||"static"})]}),(F.position||Z7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,z("div",{className:"st-cp-clustermore-row",children:Z8("Position")}),m.Position?l0("z-index",b9("z-index"),void 0,"Layer order"):null]}),!1),T8("Fill",["background-color"],l0("background-color",l7("background-color"),void 0,"Fill")),T8("Stroke",["border-width","border-style","border-color"],l0("border",q8(),W8("border-width"),"Stroke")),T8("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],l0("border-radius",k8(),W8("border-radius"),"Corner radius")),T8("Effects",["box-shadow","filter","mix-blend-mode"],O(G0,{children:[l0("box-shadow",e7("box-shadow","shadow")||F9("box-shadow"),void 0,"Shadow"),l0("filter",L0(),W8("filter"),"Blur"),l0("mix-blend-mode",z0("mix-blend-mode",k00),void 0,"Blend")]})),T8("Opacity",["opacity"],l0("opacity",d0(),void 0,"Opacity")),T8("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],O(G0,{children:[l0("font-family",z0("font-family",A00),void 0,"Font"),l0("color",l7("color"),void 0,"Color"),l0("font-size",n8("font-size","type"),void 0,"Size"),l0("font-weight",z0("font-weight",_00),void 0,"Weight"),l0("line-height",b9("line-height","lh"),void 0,"Line height"),l0("text-align",L8("text-align",N9),void 0,"Align"),z("div",{className:"st-cp-clustermore-row",children:Z8("Text")}),m.Text?O(G0,{children:[l0("letter-spacing",b9("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),l0("font-style",z0("font-style",NB0),void 0,"Style"),l0("text-transform",z0("text-transform",T00),void 0,"Case"),l0("white-space",z0("white-space",I00),void 0,"Whitespace")]}):null]})),T8("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],O("div",{className:"st-cp-box","aria-label":"margin",children:[O("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[i8(W8("margin-top")),"margin"]}),p8("margin-top","margin"),p8("margin-right","margin"),p8("margin-bottom","margin"),p8("margin-left","margin")]})),(()=>{let{showMedia:X0,canReplace:_0}=T9();return X0?T8("Media",["object-fit","object-position","aspect-ratio"],S6(_0)):null})()]}):O(G0,{children:[I0("Layout",(()=>{let X0=(F.display||Z7(U.display)||"").trim(),_0=X0==="flex"||X0==="inline-flex",B0=X0==="grid"||X0==="inline-grid";return O(G0,{children:[l0("display",z0("display",qB0)),_0?O(G0,{children:[l0("flex-direction",L8("flex-direction",O8)),l0("flex-wrap",z(yQ,{checked:/^wrap/.test(F["flex-wrap"]||Z7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(S0)=>c("flex-wrap",S0?"wrap":"nowrap")}),W8("flex-wrap"))]}):null,_0||B0?O(G0,{children:[l0("align-items",L8("align-items",E8)),l0("justify-content",L8("justify-content",a8)),l0("gap",n8("gap","space"))]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>c("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let X0=(F.display||Z7(U.display)||"").trim();if(!(X0==="grid"||X0==="inline-grid"))return null;let B0=F["grid-template-columns"]||"",S0=F["grid-template-rows"]||"",t0=vO(B0),j8=vO(S0),g8=t0.length>0||!B0.trim(),t8=j8.length>0||!S0.trim();return I0("Grid",O(G0,{children:[g8?z(S00,{label:"Columns",tracks:t0,editable:K,onChange:(G9)=>c("grid-template-columns",fO(G9))}):O("div",{className:"st-cp-note",children:["Columns use ",z("code",{children:B0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),t8?z(S00,{label:"Rows",tracks:j8,editable:K,onChange:(G9)=>c("grid-template-rows",fO(G9))}):O("div",{className:"st-cp-note",children:["Rows use ",z("code",{children:S0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),I0("Position",O(G0,{children:[l0("position",z0("position",R00)),O("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[O("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[i8(W8("top")),"inset"]}),H7("top"),H7("right"),H7("bottom"),H7("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||Z7(U.position)||"static"})]}),(F.position||Z7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,l0("z-index",b9("z-index"))]})),(X.parentDisplay==="grid"||X.parentDisplay==="inline-grid")&&I0("Grid item",O(G0,{children:[O("div",{className:"st-cp-note",children:["Manual cell placement — ",z("code",{children:"start / end"})," or ",z("code",{children:"start / span N"}),"."]}),l0("grid-column",F9("grid-column")),l0("grid-row",F9("grid-row"))]})),I0("Typography",O(G0,{children:[l0("font-family",z0("font-family",A00)),l0("color",l7("color")),l0("font-size",n8("font-size","type")),l0("font-weight",z0("font-weight",_00)),l0("line-height",b9("line-height","lh")),l0("letter-spacing",b9("letter-spacing",null,{min:-1/0})),l0("text-align",L8("text-align",N9)),l0("font-style",V8(),W8("font-style")),l0("text-transform",z0("text-transform",T00)),l0("white-space",z0("white-space",I00))]})),I0("Spacing",z(G0,{children:O("div",{className:"st-cp-box","aria-label":"margin and padding",children:[O("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[i8(W8("margin-top")),"margin"]}),p8("margin-top","margin"),p8("margin-right","margin"),p8("margin-bottom","margin"),p8("margin-left","margin"),O("div",{className:"st-cp-boxpad",children:[O("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[i8(W8("padding-top")),"padding"]}),p8("padding-top","padding"),p8("padding-right","padding"),p8("padding-bottom","padding"),p8("padding-left","padding"),O("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(F.width)||X.bounds?.w||0)," × ",Math.round(Number.parseFloat(F.height)||X.bounds?.h||0)]})]})]})})),I0("Size",O(G0,{children:[O("div",{className:"st-cp-modes",children:[o0("width"),o0("height")]}),l0("width",b9("width")),l0("height",b9("height")),l0("min-width",b9("min-width")),l0("max-width",b9("max-width")),l0("min-height",b9("min-height")),l0("max-height",b9("max-height")),l0("overflow",L8("overflow",Y9)),Q8?O(G0,{children:[z("div",{className:"st-cp-subhd",children:"In flex parent"}),l0("align-self",z0("align-self",BB0)),l0("flex-grow",b9("flex-grow",null,{unitless:!0})),l0("flex-shrink",b9("flex-shrink",null,{unitless:!0})),l0("flex-basis",b9("flex-basis"))]}):null]})),(()=>{let{showMedia:X0,canReplace:_0}=T9();return X0?I0("Media",S6(_0)):null})(),I0("Appearance",O(G0,{children:[l0("background-color",l7("background-color")),l0("border-radius",k8(),W8("border-radius")),l0("border",q8(),W8("border-width")),l0("box-shadow",e7("box-shadow","shadow")||F9("box-shadow")),l0("filter",L0(),W8("filter")),l0("mix-blend-mode",z0("mix-blend-mode",k00)),l0("opacity",d0()),l0("rotation",w0(),W8("transform")),l0("transform",F9("transform")),l0("transform-origin",F9("transform-origin"))]})),(()=>{let X0=Object.entries(C).find(([,_0])=>typeof _0==="string"&&_0.startsWith("err:"));return X0?O("div",{className:"st-cp-save is-err",role:"status",children:[z(E9,{name:"x",size:12}),X0[0],": ",X0[1].slice(4)]}):null})(),I0("Advanced",O("div",{className:"st-cp-advbody",children:[z7.length?O(G0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),z7.map(([X0,_0])=>O("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:X0,"aria-label":`custom property ${X0} name`}),z("input",{className:"st-cp-fin",defaultValue:_0,"aria-label":`${X0} value`,onKeyDown:(B0)=>{if(B0.key==="Enter")B0.currentTarget.blur()},onBlur:(B0)=>U0(X0,B0.currentTarget.value)},`cs:${X0}:${_0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${X0}`,title:"remove",onClick:()=>e(X0),children:z(E9,{name:"x",size:11})})]},`cs:${X0}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add CSS property"}),z(OB0,{commit:U0}),z("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),P7.length?O(G0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),P7.map(([X0,_0])=>O("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:X0,"aria-label":`attribute ${X0} name`}),z("input",{className:"st-cp-fin",defaultValue:_0,"aria-label":`${X0} value`,onKeyDown:(B0)=>{if(B0.key==="Enter")B0.currentTarget.blur()},onBlur:(B0)=>o(X0,B0.currentTarget.value)},`at:${X0}:${_0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${X0}`,title:"remove",onClick:()=>N0(X0),children:z(E9,{name:"x",size:11})})]},`at:${X0}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),z(MB0,{commit:o})]}))]}),O("div",{className:"st-cp-legend",children:[O("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),O("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),O("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},X.id)}function OB0({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return O("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom property name",placeholder:"property",value:J,onChange:(Z)=>Q(Z.target.value)}),z("input",{className:"st-cp-fin","aria-label":"custom property value",placeholder:"value",value:Y,onChange:(Z)=>W(Z.target.value),onKeyDown:(Z)=>{if(Z.key==="Enter")G()},onBlur:G})]})}function MB0({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return O("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom attribute name",placeholder:"data-…",value:J,onChange:(Z)=>Q(Z.target.value)}),z("input",{className:"st-cp-fin","aria-label":"custom attribute value",placeholder:"value",value:Y,onChange:(Z)=>W(Z.target.value),onKeyDown:(Z)=>{if(Z.key==="Enter")G()},onBlur:G})]})}var _B0={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function AB0(X,J,Q,Y){if(!Array.isArray(X)||J===Q)return X;let W=JSON.parse(JSON.stringify(X)),G=null,Z=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===J)return G=K[U],K.splice(U,1),!0;if(K[U].children&&Z(K[U].children))return!0}return!1};if(Z(W),!G)return X;let H=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===Q){if(Y==="inside-start"||Y==="inside-end")if(K[U].children=K[U].children||[],Y==="inside-start")K[U].children.unshift(G);else K[U].children.push(G);else K.splice(Y==="before"?U:U+1,0,G);return!0}if(K[U].children&&H(K[U].children))return!0}return!1};return H(W)?W:X}var wB0=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function l00({node:X,depth:J,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:q,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:D,onToggleLock:_,onRename:R}){let w=`${X.id}:${X.index}`,M=X.children&&X.children.length>0,P=W.has(w),I=!!X.synthetic,k=!I&&F?F[X.id]:null,$=!I&&!!D?.has(w),[C,y]=u.useState(!1),[f,h]=u.useState(""),d=!I&&X.id===Q&&(Y==null||X.index===Y),n=G?.has(w)?G.get(w):!!X.hidden,x=!!q&&!I&&!$,m=()=>{y(!1);let r=f.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!r||r===(X.dcElement??""))return;R?.(X,r)},p=N?.key===w,v=p?{transform:`translate(${N.dx}px, ${N.dy}px)`,opacity:0.9,zIndex:20,position:"relative",pointerEvents:"none",cursor:"grabbing",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.28)"}:null;return O(G0,{children:[O("div",{className:"st-layer st-layer--row"+(d?" is-sel":"")+(n?" is-hidden":"")+(I?" is-group":"")+(k?" is-instance":"")+($?" is-locked":""),style:{paddingLeft:6+J*14,...v},role:"treeitem","aria-selected":I?void 0:d,"aria-expanded":M?!P:void 0,"aria-grabbed":x?p:void 0,tabIndex:0,title:I?`${X.tag} · group (unstamped wrapper)`:`${X.tag} · ${X.type}${R?" · F2 to rename":""}`,"data-layer-key":w,onClick:()=>I?M&&Z(w):H(X),onMouseEnter:()=>!I&&K(X),onMouseLeave:()=>K(null),onPointerDown:x?(r)=>B(r,X,w):void 0,onKeyDown:(r)=>{if(r.key==="Enter"||r.key===" ")if(r.preventDefault(),I)M&&Z(w);else H(X);else if(r.key==="F2"&&R&&!I)r.preventDefault(),h(X.dcElement||X.label||""),y(!0)},children:[M?z("button",{type:"button",className:"st-layer-caret","aria-label":P?"Expand":"Collapse",onClick:(r)=>{r.stopPropagation(),Z(w)},children:P?"▸":"▾"}):z("span",{className:"st-layer-caret","aria-hidden":"true"}),k?z("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:k.root?"◆":"◇"}):z(E9,{name:_B0[X.type]||"box",size:12,className:"st-layer-ticon"}),C?z("input",{className:"st-layer-rename",value:f,autoFocus:!0,"aria-label":`Rename ${X.label}`,onFocus:(r)=>r.target.select(),onChange:(r)=>h(r.target.value),onClick:(r)=>r.stopPropagation(),onPointerDown:(r)=>r.stopPropagation(),onBlur:m,onKeyDown:(r)=>{if(r.stopPropagation(),r.key==="Enter")m();else if(r.key==="Escape")y(!1)}}):z("span",{className:"st-layer-label",onDoubleClick:R&&!I?(r)=>{r.stopPropagation(),h(X.dcElement||X.label||""),y(!0)}:void 0,children:X.label}),z("span",{className:"st-layer-type",children:k?k.component:X.type}),_&&!I?z("button",{type:"button",className:"st-layer-lock","aria-label":$?`Unlock ${X.label}`:`Lock ${X.label}`,"aria-pressed":$,title:$?"Unlock":"Lock",onClick:(r)=>{r.stopPropagation(),_(w)},children:z(E9,{name:$?"lock":"unlock",size:12})}):null,U&&!I?z("button",{type:"button",className:"st-layer-eye","aria-label":n?`Show ${X.label}`:`Hide ${X.label}`,"aria-pressed":n,title:n?"Show":"Hide",onClick:(r)=>{r.stopPropagation(),U(X)},children:z(E9,{name:n?"eye-off":"eye",size:13})}):null]}),M&&!P?X.children.map((r,a)=>z(l00,{node:r,depth:J+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:q,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:D,onToggleLock:_,onRename:R},`${r.id}:${r.index}`)):null]})}function EB0({el:X}){let J=X?.computed||{},Q=X?.authored||{},Y=(U)=>{let q=Q[U];if(q&&/var\(\s*--/.test(q))return q.replace(/^var\(\s*|\s*\)$/g,"");return J[U]||q||""},W=(U,q)=>{let B=J[q]||Q[q];if(!B)return null;return O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:U}),O("div",{className:"st-swatch-row",children:[z("span",{className:"st-insp-swatch",style:{background:B},"aria-hidden":"true"}),z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Y(q)})]})]},U)},G=J["border-radius"]&&J["border-radius"]!=="0px",Z=G?gQ(J["border-radius"]).n||J["border-radius"]:null,H=J["font-size"]||J["font-weight"]?[J["font-size"],J["font-weight"]].filter(Boolean).join(" / "):null;if(!(J["background-color"]||J.color||G||H))return null;return O(G0,{children:[G?O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Radius"}),O("div",{className:"st-insp-fields",children:[O("span",{className:"st-fmini",style:{flex:"0 0 auto",maxWidth:84},children:[z("span",{className:"st-mtag",children:"r"}),z("input",{value:Z,readOnly:!0,"aria-label":"border radius"})]}),z("span",{className:"st-insp-unit",children:"px"})]})]}):null,W("Fill","background-color"),W("Text","color"),H?O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Font"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:H})})]}):null]})}function p00(X){if(X.artboardId)return X.artboardId;let J=/^\[data-dc-screen="([^"]+)"\]$/.exec(X.selector||"");return J?J[1]:null}var PB0=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],RB0=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function TB0({el:X,cfg:J,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let K=p00(X),U=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),q=g00(X.file,J),B=m00(J,U,q),N=(v)=>B.map((r)=>({ds:r.name,names:r[v]||[],vals:r.vals})).filter((r)=>r.names.length),F=(v)=>N(v).flatMap((r)=>(r.names||[]).map((a)=>({name:a,value:r.vals?.[a]||""}))),D=(v)=>{let r=/^var\(\s*(--[\w-]+)\s*\)$/.exec(v||"");if(!r)return v||"";for(let a of B){let c=a.vals?.[r[1]];if(c)return c}return""},_=Number.isFinite(X.worldW)?X.worldW:Number.isFinite(X.bounds?.w)?X.bounds.w:null,R=Number.isFinite(X.worldH)?X.worldH:Number.isFinite(X.bounds?.h)?X.bounds.h:null,w=(v,r)=>{if(!K)return;let a=Number.isFinite(v)&&v>0?Math.round(v):void 0,c=Number.isFinite(r)&&r>0?Math.round(r):void 0;if(a==null&&c==null)return;Q?.(K,a,c)},M=Object.entries(_5).find(([,v])=>v.width===_&&v.height===R)?.[0],P=Object.entries(_5).find(([,v])=>v.width===_)?.[0],I=X.attrs?.["data-dc-fixed"]==="true",k=X.attrs?.["data-dc-bg"]??"",$=X.attrs?.["data-dc-padding"]??"",C=X.attrs?.["data-dc-layout"]??"",y=X.attrs?.["data-dc-gap"]??"",f=X.attrs?.["data-dc-kind"]||"digital",h=null;try{h=X.attrs?.["data-dc-print"]?JSON.parse(X.attrs["data-dc-print"]):null}catch{}let d=(v)=>{if(!K)return;let r=null;if(v==="print"&&!h){let a={paper:"a4"};try{let c=D2(a);if(c)r={defaults:a,widthPx:c.widthPx,heightPx:c.heightPx}}catch{}}if(G?.(K,v==="digital"?null:v,r),v==="web"&&I)Y?.(K,!1,void 0)},n=(v)=>{if(!K)return;let r={paper:"a4",...h,...v},a;try{a=D2(r)}catch{return}Q?.(K,a.widthPx,a.heightPx),Z?.(K,r)},x=(v,r)=>{if(!K)return;let a=Number.isFinite(r)?r:R,c=v&&Number.isFinite(a)?Math.round(a):void 0;Y?.(K,v,c)},m=(v)=>{let r=LS(I,v);if(r.kind==="resize")w(null,r.height);else if(r.kind==="promote-to-fixed")x(!0,r.height)},p=(v)=>{if(!K)return;W?.(K,v)};return O("section",{className:"st-cp-sec",children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Artboard"})}),O("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[z(WX,{value:_??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(v)=>w(v,null)}),z(WX,{value:R??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:I,onCommit:m})]}),z("div",{style:{padding:"0 12px 8px"},children:f==="print"?O("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:h?.paper??"",onChange:(v)=>n({paper:v.currentTarget.value}),children:[z("option",{value:"",disabled:!0,children:"Paper size…"}),L2.map((v)=>O("option",{value:v.id,children:[v.label," — ",v.width,"×",v.height,v.unit]},v.id))]}):f==="web"?O("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:P??"",onChange:(v)=>{let r=_5[v.currentTarget.value];if(r)w(r.width,null)},children:[z("option",{value:"",disabled:!0,children:P?`${_5[P].label} — ≤ ${_5[P].width}px`:"Breakpoint…"}),Object.entries(_5).map(([v,r])=>O("option",{value:v,children:[r.label," — ≤ ",r.width,"px breakpoint"]},v))]}):O("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:M??"",onChange:(v)=>{let r=_5[v.currentTarget.value];if(r)w(r.width,r.height)},children:[z("option",{value:"",disabled:!0,children:M?_5[M].label:"Preset size…"}),Object.entries(_5).map(([v,r])=>O("option",{value:v,children:[r.label," — ",r.width,"×",r.height]},v))]})}),z("div",{style:{padding:"0 12px 8px"},children:z(YN,{value:I?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(v)=>x(v==="fixed")})}),z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Kind"})}),z("div",{style:{padding:"0 12px 8px"},children:z(IW,{value:f,ariaLabel:"artboard kind",options:RB0.map(([v,r])=>({value:v,label:r})),onChange:d})}),f!=="print"&&K&&H?z("div",{style:{padding:"0 12px 8px"},children:O("select",{className:"st-cp-nsel","aria-label":"duplicate artboard at breakpoint width",value:"",onChange:(v)=>{let r=_5[v.currentTarget.value];if(r)H(K,r.width);v.currentTarget.value=""},children:[z("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(_5).map(([v,r])=>O("option",{value:v,children:[r.label," — ",r.width,"px"]},v))]})}):null,f==="print"?O(G0,{children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Print"})}),z("div",{style:{padding:"0 12px 8px"},children:z(YN,{value:h?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(v)=>n({orientation:v})})}),z("div",{style:{padding:"0 12px 8px"},children:z(WX,{value:Number.isFinite(h?.bleedMm)?h.bleedMm:3,min:0,step:0.5,ariaLabel:"bleed, millimeters",lead:"B",steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"mm"}),onCommit:(v)=>n({bleedMm:v})})})]}):null,z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Style"})}),O("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let v=D(k),r=/var\(\s*--/.test(k),a=r?k.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):k;return z($V,{swatch:z(EF,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:N("color"),current:k,activeDs:q,swatchBg:v,seedHex:kF(v)||"#000000",onPick:(c)=>p({background:c||null}),label:"artboard background colour"}),displayValue:a,bound:r,ariaLabel:"artboard background",onValue:(c)=>p({background:(c||"").trim()||null})})})(),z(IW,{value:C,ariaLabel:"artboard body layout",options:PB0.map(([v,r])=>({value:v,label:r})),onChange:(v)=>p({layout:v||null})}),O("div",{style:{display:"flex",gap:8},children:[z(WN,{value:/^var\(/.test($)?$:Number.parseFloat($)||0,tokens:F("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(v)=>p({padding:typeof v==="string"?v:v>0?v:null})}),z(WN,{value:/^var\(/.test(y)?y:Number.parseFloat(y)||0,tokens:F("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(v)=>p({gap:typeof v==="string"?v:v>0?v:null})})]})]})]})}var zT=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,IB0=new RegExp(zT.source,"gi");function kB0(X){if(!X||Array.isArray(X))return null;if(X.photoAsset)return X.photoAsset;let J=X.html||"";if((X.tag||"").toLowerCase()!=="img"){let W=[...new Set(J.match(IB0)||[])],G=[...new Set([...J.matchAll(/data-photo-asset="([^"]+)"/g)].map((Z)=>Z[1]))];if(G.length===1)return G[0];if(G.length===0&&W.length===1&&/<img/i.test(J))return W[0];return null}let Q=/data-photo-asset="([^"]+)"/.exec(J);if(Q)return Q[1];let Y=zT.exec(`${X.attrs?.src||""} ${J}`);return Y?Y[0]:null}function CB0({testId:X,selected:J,onClose:Q,layersTree:Y,componentMap:W,lockedKeys:G,onToggleLock:Z,onDetachInstance:H,canvasFile:K,onSelectLayer:U,onHoverLayer:q,onReorderLayer:B,layersBusyRef:N,cfg:F,onOptimistic:D,onRecordEdit:_,onReplaceMedia:R,onResizeArtboard:w,onSetArtboardHug:M,onSetArtboardStyle:P,onSetArtboardKind:I,onSetArtboardPrint:k,onDuplicateArtboard:$,onUndoRedo:C,editScope:y,tab:f,onTabChange:h,width:d,resizing:n,photoSel:x,photoRev:m,onPhotoEdit:p,onPhotoRemoveBackground:v,onPhotoRecordEdit:r,onPhotoUndoRedo:a,layersOnly:c=!1,hideLayersTab:U0=!1,cpMode:o,onSetCpMode:Z0}){let[e,N0]=u.useState("inspect"),K0=c?"layers":f??e,u0=(w0)=>{N0(w0),h?.(w0)},[Q8,o0]=u.useState(()=>new Set),[_8,A0]=u.useState(()=>new Map);u.useEffect(()=>{let w0=Array.isArray(J)?J[0]:J,L0=w0?.id;if(!L0||!Y?.nodes)return;let d0=w0.index,V8=null,O8=[];if(function a8(E8,N9){for(let Y9 of E8||[]){let e7=`${Y9.id}:${Y9.index}`;if(!Y9.synthetic&&Y9.id===L0&&(d0==null||Y9.index===d0))return V8=e7,O8.push(...N9),!0;if(Y9.children&&Y9.children.length&&a8(Y9.children,[...N9,e7]))return!0}return!1}(Y.nodes,[]),!V8)return;if(O8.length)o0((a8)=>{let E8=!1,N9=new Set(a8);for(let Y9 of O8)if(N9.delete(Y9))E8=!0;return E8?N9:a8});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${V8}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[J,Y]);let r0=(w0)=>{let L0=`${w0.id}:${w0.index}`;return _8.has(L0)?_8.get(L0):!!w0.hidden},[P0,K8]=u.useState(null),[F8,D8]=u.useState(""),W8=(w0,L0)=>{if(!K||!w0?.id)return;fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:K,id:w0.id,attr:"data-dc-element",value:L0})}).then((d0)=>d0.json().catch(()=>({}))).then((d0)=>{if(!d0.ok)return;_?.({op:"attr",canvas:K,id:w0.id,key:"data-dc-element",before:w0.dcElement??null,after:L0})}).catch(()=>{})},A8=B?(w0,L0,d0)=>{if(N?.current)return;if(w0?.synthetic||L0?.synthetic)return;let V8=d0==="before"?`before ${L0.label}`:d0==="after"?`after ${L0.label}`:`into ${L0.label}`;D8(`Moved ${w0.label} ${V8}`),B(w0.id,L0.id,d0,{idIndex:w0.index,refIndex:L0.index})}:void 0,i8=()=>{let w0=[];return function L0(d0,V8,O8){(d0||[]).forEach((a8,E8)=>{if(w0.push({node:a8,depth:V8,parentNode:O8,siblings:d0,pos:E8}),a8.children&&a8.children.length&&!Q8.has(`${a8.id}:${a8.index}`))L0(a8.children,V8+1,a8)})}(Y?.nodes,0,null),w0},P9=(w0)=>{if(w0.key!=="ArrowUp"&&w0.key!=="ArrowDown")return;if(!Z8)return;let L0=i8(),d0=L0.findIndex((E8)=>E8.node.id===Z8.id&&E8.node.index===Z8.index);if(d0<0)return;let V8=w0.key==="ArrowDown"?1:-1,O8=L0[d0];if(!w0.altKey){let E8=L0[d0+V8];if(E8)w0.preventDefault(),U?.(E8.node);return}if(!A8||!Array.isArray(O8.siblings))return;w0.preventDefault();let a8=(E8)=>E8&&E8.children&&E8.children.length&&!Q8.has(`${E8.id}:${E8.index}`);if(!w0.shiftKey){if(V8<0&&O8.pos>0)A8(O8.node,O8.siblings[O8.pos-1],"before");else if(V8>0&&O8.pos<O8.siblings.length-1)A8(O8.node,O8.siblings[O8.pos+1],"after");return}if(V8>0){let E8=O8.siblings[O8.pos+1];if(E8)A8(O8.node,E8,a8(E8)?"inside-start":"after");else if(O8.parentNode)A8(O8.node,O8.parentNode,"after")}else{let E8=O8.siblings[O8.pos-1];if(E8)A8(O8.node,E8,a8(E8)?"inside-end":"before");else if(O8.parentNode)A8(O8.node,O8.parentNode,"before")}},l0=u.useRef(null),i0=u.useRef(null),j0=(w0,L0,d0)=>{if(!A8||w0.button!==0||w0.metaKey||w0.ctrlKey||w0.shiftKey||w0.altKey)return;if(N?.current)return;let{clientX:V8,clientY:O8}=w0,a8=new Set([d0]);(function p8(H7){(H7.children||[]).forEach((z7)=>{a8.add(`${z7.id}:${z7.index}`),p8(z7)})})(L0);let E8=14,N9=6,Y9=[];(function p8(H7,z7){(H7||[]).forEach((P7)=>{let T9=`${P7.id}:${P7.index}`;if(Y9.push({node:P7,key:T9,id:P7.id,depth:z7,tag:P7.tag}),P7.children&&P7.children.length&&!Q8.has(T9))p8(P7.children,z7+1)})})(Y?.nodes,0);let e7=new Map(Y9.map((p8)=>[p8.key,p8])),E0=!1,h8=(p8)=>{if(!E0){if(Math.hypot(p8.clientX-V8,p8.clientY-O8)<4)return;E0=!0}let H7=p8.clientX-V8,z7=p8.clientY-O8,P7=null,T9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((X0)=>({rect:X0.getBoundingClientRect(),it:e7.get(X0.getAttribute("data-layer-key"))})).filter((X0)=>X0.it&&X0.it.key!==d0);if(T9.length){let X0=T9[0].rect.left,_0=T9[0].rect.right,B0=T9.length;for(let L7=0;L7<T9.length;L7++)if(p8.clientY<T9[L7].rect.top+T9[L7].rect.height/2){B0=L7;break}let S0=T9[B0-1]?.it||null,t0=T9[B0]?.it||null,j8=Math.round((p8.clientX-X0-N9)/E8),g8=S0?S0.depth+(wB0.has(S0.tag)?0:1):0,t8=t0?t0.depth:0,G9=Math.max(t8,Math.min(j8,g8)),w9=null,F7="before",g9=0;if(!S0){if(t0)w9=t0,F7="before",g9=t0.depth}else if(G9>S0.depth)w9=S0,F7="inside-start",g9=S0.depth+1;else if(G9===S0.depth)w9=S0,F7="after",g9=S0.depth;else{for(let L7=B0-1;L7>=0;L7--)if(T9[L7].it.depth===G9){w9=T9[L7].it;break}if(!w9)w9=S0;F7="after",g9=G9}if(w9&&w9.key!==d0&&!a8.has(w9.key)){let L7=S0?T9[B0-1].rect.bottom:T9[0].rect.top,mX=X0+N9+g9*E8;P7={refId:w9.id,position:F7,node:w9.node,y:L7,left:mX,w:Math.max(24,_0-mX)}}}let S6={key:d0,node:L0,dx:H7,dy:z7,target:P7};l0.current=S6,K8(S6)},F9=()=>{window.removeEventListener("pointermove",h8),window.removeEventListener("pointerup",l7),window.removeEventListener("keydown",c6,!0)},b9=()=>{let p8=(H7)=>{H7.preventDefault(),H7.stopImmediatePropagation(),document.removeEventListener("click",p8,!0)};document.addEventListener("click",p8,!0),setTimeout(()=>document.removeEventListener("click",p8,!0),300)},l7=()=>{F9();let p8=l0.current;if(l0.current=null,K8(null),E0&&p8?.target)b9(),A8(p8.node,p8.target.node,p8.target.position)},c6=(p8)=>{if(p8.key!=="Escape")return;if(p8.preventDefault(),p8.stopImmediatePropagation(),F9(),l0.current=null,K8(null),E0)b9()};window.addEventListener("pointermove",h8),window.addEventListener("pointerup",l7),window.addEventListener("keydown",c6,!0)},I0=(w0)=>o0((L0)=>{let d0=new Set(L0);if(d0.has(w0))d0.delete(w0);else d0.add(w0);return d0}),T8=(w0)=>{let L0=`${w0.id}:${w0.index}`,d0=r0(w0),V8=!d0;if(A0((O8)=>new Map(O8).set(L0,V8)),D?.({id:w0.id,artboardId:Y?.artboardId??null,index:w0.index,prop:"display",value:V8?"none":null}),!K||!w0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(V8?{canvas:K,id:w0.id,property:"display",value:"none"}:{canvas:K,id:w0.id,property:"display",reset:!0})}).catch(()=>{}),_?.({op:"css",canvas:K,id:w0.id,key:"display",before:d0?"none":null,after:V8?"none":null})},Z8=Array.isArray(J)?J[0]:J,z0=x?{asset:x.asset,kind:"annotation-image"}:(()=>{let w0=kB0(Z8);return w0?{asset:w0,kind:"artboard-img"}:null})(),f0=z0?.kind==="annotation-image",L8=(w0)=>{if(!(w0.metaKey||w0.ctrlKey)||w0.altKey)return;let L0=w0.key.toLowerCase();if(L0==="z")w0.preventDefault(),a?.(w0.shiftKey?"redo":"undo");else if(L0==="y")w0.preventDefault(),a?.("redo")},n8=f0?"photo":K0==="photo"&&!z0?"inspect":K0,k8=(w0,L0,d0)=>O("button",{type:"button",className:"st-rp-tab"+(n8===w0?" is-active":""),onClick:()=>u0(w0),children:[z(E9,{name:d0,size:14}),L0]}),q8=Z8?.bounds||null;return O("aside",{className:"st-rpanel"+(n?" is-resizing":""),style:d?{width:d,flexBasis:d}:void 0,"aria-label":"Inspector","data-tour":"inspector","data-testid":X,children:[O("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:c?{display:"none"}:void 0,children:[f0?k8("photo","Photo","image"):O(G0,{children:[k8("inspect","Inspect","sliders"),!U0&&k8("layers","Layers","layers"),k8("css","CSS","code"),z0?k8("photo","Photo","image"):null]}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:Q,children:z(E9,{name:"x",size:14})})]}),Z8?.id&&!(Array.isArray(J)&&J.length>1)&&y?O("div",{className:`st-scope st-scope--${y.scope}`,title:y.scope==="shared"?`Editing this element's style changes ${y.affects} place${y.affects===1?"":"s"}${y.componentName?` (component ${y.componentName})`:""}. Move/resize a whole instance to keep it local.`:"This edit affects only this element.",children:[z("span",{className:"st-scope-dot","aria-hidden":"true"}),y.scope==="shared"?`Shared${y.componentName?` · ${y.componentName}`:""} · edits ${y.affects} place${y.affects===1?"":"s"}`:"Local · this element only",y.scope==="shared"&&H?z("button",{type:"button",className:"st-scope-detach",title:"Clone this component for this instance only — edits stop affecting the other places",onClick:()=>H(Z8.id,Z8.index),children:"Detach"}):null]}):null,z("div",{className:"st-rp-body",children:n8==="photo"&&z0?z("div",{onKeyDown:L8,children:z(_h,{asset:z0.asset,ColorPicker:u00,StIcon:E9,onEdit:(w0)=>p?.(z0.asset,w0),onRemoveBackground:v,onRecordEdit:(w0,L0)=>r?.(z0.asset,w0,L0)},`${z0.asset}:${m??0}`)}):!Z8&&!(n8==="layers"&&Y?.nodes?.length)?z("div",{className:"st-rp-empty",children:O("p",{children:["Press ",z(wX,{children:"V"}),", then click an element to select it — or ",z(wX,{children:"⌘"}),"-click straight from Browse."]})}):Z8&&n8==="inspect"?O(G0,{children:[z("div",{className:"st-rp-hd",children:Z8.selector||Z8.tag||"element"}),O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Pos"}),O("div",{className:"st-insp-fields",children:[O("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"X"}),z("input",{value:q8?Math.round(q8.x):"—",readOnly:!0,"aria-label":"x position"})]}),O("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"Y"}),z("input",{value:q8?Math.round(q8.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Size"}),O("div",{className:"st-insp-fields",children:[O("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"W"}),z("input",{value:q8?Math.round(q8.w):"—",readOnly:!0,"aria-label":"width"})]}),O("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"H"}),z("input",{value:q8?Math.round(q8.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Tag"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:Z8.tag||"—"})})]}),Z8.classes?O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Class"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Z8.classes})})]}):null,z(EB0,{el:Z8})]}):n8==="layers"?O(G0,{children:[O("div",{className:"st-rp-hd",children:["Layers",Y?.nodes?.length?"":" · ancestry"]}),Y?.nodes?.length?O(G0,{children:[A8?z("div",{className:"st-rp-hint","aria-hidden":"true",children:"Drag or ↑/↓ select · Alt+↑/↓ move · Alt+Shift+↑/↓ move across"}):null,z("div",{role:"tree","aria-label":"Artboard layers",tabIndex:0,ref:i0,onKeyDown:P9,children:Y.nodes.map((w0,L0)=>z(l00,{node:w0,depth:0,selectedId:Z8?.id,selectedIndex:Z8?.index,collapsed:Q8,hiddenOverride:_8,onToggle:I0,onSelect:(d0)=>{U?.(d0),i0.current?.focus()},onHover:(d0)=>q?.(d0),onToggleVisibility:T8,onReorder:A8,onRowPointerDown:j0,dragState:P0,componentMap:W,lockedKeys:G,onToggleLock:Z,onRename:W8},`${w0.id}:${w0.index}`))}),P0?.target?z("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:P0.target.left,top:P0.target.y-1,width:P0.target.w}}):null,z("div",{className:"sr-only",role:"status","aria-live":"polite",children:F8})]}):Z8&&Array.isArray(Z8.dom_path)&&Z8.dom_path.length?Z8.dom_path.map((w0,L0)=>O("div",{className:"st-layer"+(L0===Z8.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+L0*12},children:[z(E9,{name:"square",size:13}),w0]},L0)):z("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!Z8.id&&p00(Z8)?z(TB0,{el:Z8,cfg:F,onResizeArtboard:w,onSetArtboardHug:M,onSetArtboardStyle:P,onSetArtboardKind:I,onSetArtboardPrint:k,onDuplicateArtboard:$}):z(DB0,{el:Z8,cfg:F,onOptimistic:D,onRecordEdit:_,onReplaceMedia:R,onUndoRedo:C,mode:o,onSetMode:Z0})})]})}function $B0(){let[X,J]=u.useState([]),[Q,Y]=u.useState("Design"),[W,G]=u.useState([]),[Z,H]=u.useState(null),[K,U]=u.useState(null),q=u.useCallback((j)=>{U(j)},[]),[B,N]=u.useState(null),F=u.useRef(null);u.useEffect(()=>{F.current=B},[B]);let[D,_]=u.useState(null);u.useEffect(()=>{let j=Array.isArray(B)?B.length===1?B[0]:null:B,b=j&&typeof j.id==="string"?j.id:null;if(!b||!Z){_(null);return}let t=new AbortController,W0=new URLSearchParams({canvas:Z,id:b});return fetch(`/_api/edit-scope?${W0}`,{signal:t.signal}).then((F0)=>F0.ok?F0.json():null).then((F0)=>{if(F0?.ok)_(F0)}).catch(()=>{}),()=>t.abort()},[B,Z]);let R=u.useRef(0),w=u.useRef([]),M=u.useCallback((j)=>{if(!j?.id||!j.file)return;for(let b of w.current)clearTimeout(b);w.current=[50,450,1200,2500,5000].map((b)=>setTimeout(()=>{let t=F.current,W0=Array.isArray(t)?t[0]:t;if(!W0||W0.id!==j.id||W0.file!==j.file)return;let F0=m8.current.get(j.file);if(!F0?.contentWindow)return;try{F0.contentWindow.postMessage({dgn:"select-by-id",id:j.id,artboardId:j.artboardId??null,index:j.index??0},"*")}catch{}},b))},[]),P=u.useRef([]),I=u.useCallback((j,b)=>{if(!j||!b)return;for(let t of P.current)clearTimeout(t);P.current=[50,450,1200,2500,5000].map((t)=>setTimeout(()=>{let W0=F.current,F0=Array.isArray(W0)?W0[0]:W0;if(!F0||F0.artboardId!==j||F0.file!==b)return;let q0=m8.current.get(b);if(!q0?.contentWindow)return;try{q0.contentWindow.postMessage({dgn:"select-by-id",artboardId:j},"*")}catch{}},t))},[]),k=u.useRef(null),$=u.useRef(null),C=u.useRef(null),y=u.useRef(null),f=u.useRef(!1),h=u.useRef(null),[d,n]=u.useState(null),[x,m]=u.useState(null),p=u.useRef({canvas:null,at:0});u.useEffect(()=>{if(!Z||!d)return;let j=Date.now(),b=p.current;if(b.canvas===Z&&j-b.at<1500)return;p.current={canvas:Z,at:j},fetch(`/_api/component-map?canvas=${encodeURIComponent(Z)}`).then((t)=>t.json()).then((t)=>{if(t?.ok&&t.map&&typeof t.map==="object")m(t.map);else m(null)}).catch(()=>m(null))},[Z,d]);let[v,r]=u.useState(!1),[a,c]=u.useState(null),[U0,o]=u.useState(null),[Z0,e]=u.useState(null),[N0,K0]=u.useState(null),[u0,Q8]=u.useState(null),[o0,_8]=u.useState(!1),[A0,r0]=u.useState(!1),[P0,K8]=u.useState(null),[F8,D8]=u.useState(""),[W8,A8]=u.useState(null),[i8,P9]=u.useState(null),l0=u.useRef(null),i0=N00("maude-sb-w",{min:200,max:420,def:252}),j0=N00("maude-rp-w",{min:260,max:480,def:304}),[I0,T8]=u.useState(null),Z8=u.useRef(null);u.useEffect(()=>{if(!I0)return;let j=(t)=>{let W0=Z8.current?.getBoundingClientRect();if(!W0)return;if(I0==="sb")i0.setW(t.clientX-W0.left);else j0.setW(W0.right-t.clientX)},b=()=>T8(null);return window.addEventListener("pointermove",j),window.addEventListener("pointerup",b),()=>{window.removeEventListener("pointermove",j),window.removeEventListener("pointerup",b)}},[I0,i0.setW,j0.setW]);let z0=u.useCallback((j)=>{clearTimeout(l0.current),l0.current=setTimeout(()=>{P9((b)=>b===j?null:b)},2500)},[]);u.useEffect(()=>{if(!i8)return;let j=setTimeout(()=>P9(null),15000);return()=>clearTimeout(j)},[i8]);let[f0,L8]=u.useState({designRel:".design",cloud:void 0}),n8=!!f0.cloud,k8=!f0.cloud&&!!Z0?.credentialed,q8=n8||k8,w0=q8?0:N0?.files?.length||0,L0=u.useRef(q8);L0.current=q8;let d0=!!f0.readOnly,V8=u.useCallback(()=>{fetch("/_config").then((j)=>j.json()).then((j)=>{let b=(j.designRoot||".design").replace(/^\/+|\/+$/g,"");L8((t)=>({...t,designRel:b,tokensCssRel:j.tokensCssRel,designSystems:j.designSystems,canvasOrigin:j.canvasOrigin,readOnly:!!j.readOnly,canvasToken:j.canvasToken,version:j.version,cloud:j.cloud??null,exportLane:j.exportLane}))}).catch(()=>{})},[]);u.useEffect(()=>{V8()},[V8]),u.useEffect(()=>{let j=!1;return fetch("/_sync-status").then((b)=>b.json()).then((b)=>{if(j||!b||b.linked===!1)return;o(b)}).catch(()=>{}),()=>{j=!0}},[]),u.useEffect(()=>{if(q8){K0(null);return}let j=!1;return fetch("/_api/git/status").then((b)=>b.json()).then((b)=>{if(!j&&b)K0(b)}).catch(()=>{}),()=>{j=!0}},[q8]);let[O8,a8]=u.useState({}),[E8,N9]=u.useState(null),[Y9,e7]=u.useState(!1),[E0,h8]=u.useState("open"),[F9,b9]=u.useState(D20),[l7,c6]=u.useState(()=>{return JT(Y00,"advanced")==="designer"?"designer":"advanced"});u.useEffect(()=>{try{localStorage.setItem(Y00,JSON.stringify(l7))}catch{}},[l7]);let[p8,H7]=u.useState(null),[z7,P7]=u.useState(()=>XH(W00,!0)),[T9,S6]=u.useState(()=>XH(J00,!1)),[X0,_0]=u.useState(()=>JT(Q00,{})),[B0,S0]=u.useState(!1),[t0,j8]=u.useState(!1);u.useEffect(()=>{if(!W9())return;let j=mf(()=>j8(!0));return()=>{j.then((b)=>b()).catch(()=>{})}},[]);let[g8,t8]=u.useState(!1),[G9,w9]=u.useState(!1),[F7,g9]=u.useState(!1),[L7,mX]=u.useState(!1),[mQ,uQ]=u.useState(!1),{report:ZQ}=vA(W9()),[HQ,k9]=u.useState(!1),[X6,lQ]=u.useState(!1),[D7,A6]=u.useState(null),[EX,A5]=u.useState(!1),[j7,KX]=u.useState(!1),[PX,v7]=u.useState(!1),[r4,H6]=u.useState(!1),[C9,RX]=u.useState(()=>JT(z00,$K)),[I9,l9]=u.useState(()=>{try{let j=localStorage.getItem(K00);if(j==="separate"||j==="in-inspector")return j}catch{}return"separate"}),[i6,zQ]=u.useState(!1),[J6,vJ]=u.useState([]),[HJ,TX]=u.useState(0),[w5,uX]=u.useState(!1),[E5,a4]=u.useState(!1),[i,Q0]=u.useState(!1),[D0,v0]=u.useState(1),[T0,H8]=u.useState(216),[Y8,V9]=u.useState(null),[s8,o6]=u.useState([]),[lX,b6]=u.useState([]),[P5,pQ]=u.useState([]),[R5,s4]=u.useState(0),T5=u.useRef(0);u.useEffect(()=>{T5.current=HJ},[HJ]);let[o9,UX]=u.useState(null),fJ=u.useRef(null);u.useEffect(()=>{fJ.current=o9},[o9]);let f7=u.useMemo(()=>lA(J6,{artboardId:[o9,Y8],total:R5}),[J6,o9,Y8,R5]),P8=u.useRef(null);u.useEffect(()=>{P8.current=f7},[f7]);let y9=u.useMemo(()=>GK(J6,f7)?.fps||30,[J6,f7]),[j9,pX]=u.useState(null),[VX,dW]=u.useState(0),y6=u.useCallback((j,b)=>{if(/concurrent edit|changed since it was read/i.test(b||""))l8("Timeline changed — reloaded, try again."),dW((t)=>t+1);else l8(`${j}: ${b||"failed"}`)},[]),[zJ,I5]=u.useState(!1),[jK,t4]=u.useState(!1),[vK,KJ]=u.useState(!1),cW=u.useRef(zJ);u.useEffect(()=>{if(cW.current=zJ,zJ){KJ(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[zJ]);let QH=u.useCallback(()=>{if(!cW.current||document.hidden)KJ(!0),V00("Claude finished","Your assistant turn is ready in Maude.")},[]),xJ=u.useRef(0),e4=u.useCallback(()=>{if(!cW.current||document.hidden){KJ(!0);let j=Date.now();if(j-xJ.current<N20)return;xJ.current=j,V00("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[k5,KQ]=u.useState("inspect"),[fK,XY]=u.useState(null),hJ=u.useRef({undo:[],redo:[]}),[xK,hK]=u.useState(0),[gJ,iW]=u.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),YH=u.useRef(gJ);u.useEffect(()=>{YH.current=gJ;try{localStorage.setItem("maude-auto-open-inspector",gJ?"1":"0")}catch{}},[gJ]);let WH=u.useRef(!1);u.useEffect(()=>{WH.current=PX||Y9||o0||A0||zJ},[PX,Y9,o0,A0,zJ]);let oW=u.useRef({open:{},side:$K});oW.current={open:{tree:z7,layers:r4,inspector:PX,comments:Y9,changes:o0,sync:A0,assistant:zJ},side:C9};let dQ=u.useCallback((j,b)=>{if(j==="tree")P7(b);else if(j==="layers")H6(b);else if(j==="inspector")v7(b);else if(j==="comments")e7(b);else if(j==="changes")_8(b);else if(j==="sync")r0(b);else if(j==="assistant")I5(b)},[]),nW=u.useCallback((j)=>oW.current.side?.[j]||$K[j],[]),IX=u.useCallback((j)=>{let b=nW(j);dQ(j,!0);for(let t of GT)if(t.id!==j&&nW(t.id)===b)dQ(t.id,!1)},[dQ,nW]),C5=u.useCallback((j)=>{if(oW.current.open?.[j])dQ(j,!1);else IX(j)},[IX,dQ]),mJ=IX,z6=C5,cQ=u.useCallback((j)=>{if(!YH.current)return;if(d0)return;if(!j||!j.id)return;if(WH.current)return;mJ("inspector"),KQ("css")},[mJ,d0]),UQ=u.useCallback(()=>zQ((j)=>!j),[]),VQ=mh(HT),JY=Ph({enabled:f0.cloud===null||f0.exportLane==="remote"}),[QY,rW]=u.useState(!1),[dX,GH]=u.useState(!1);u.useEffect(()=>{if(!W9())return;let j=!0;return df().then((b)=>{if(!j)return;if(rW(!!b),!b&&!XH(X00,!1))GH(!0)}).catch(()=>{}),()=>{j=!1}},[]);let YY=u.useCallback(()=>{GH(!1);try{localStorage.setItem(X00,"1")}catch{}},[]),[gK,ZH]=u.useState(null);u.useEffect(()=>{if(!W9())return;let j;return rf((b)=>ZH(b&&typeof b==="object"?b:{})).then((b)=>{j=b}).catch(()=>{}),()=>{try{j?.()}catch{}}},[]);let[qQ,HH]=u.useState(null),[$5,aW]=u.useState(()=>!XH(ee,!1)),S5=u.useCallback((j)=>{HH(Array.isArray(j)&&j.length?j:null)},[]),mK={setup:(j)=>{if(!j)return;if((j.canvas||j.requireSelection)&&W.length===0)IX("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [role="treeitem"]')?.click()}catch{}},80);if(j.inspector||j.tab||j.requireSelection)mJ("inspector");if(j.tab)KQ(j.tab);if(j.changes)mJ("changes")}},sW=u.useCallback(()=>{aW(!1);try{localStorage.setItem(ee,"1")}catch{}},[]),[BQ,zH]=u.useState(()=>XH(H00,!0)),[KH,uK]=u.useState(!1),[uJ,UH]=u.useState(()=>XH(G00,!1)),[j6,qX]=u.useState(()=>XH(Z00,!1)),[n6,tW]=u.useState(!1),[lK,lJ]=u.useState(!1),[iQ,NQ]=u.useState(0),[oQ,eW]=u.useState(null),[XG,WY]=u.useState(!1),nQ=u.useRef(null),GY=u.useRef(null),m8=u.useRef(new Map),S8=u.useCallback((j)=>{let b=Z?m8.current.get(Z):null;if(!b||!b.contentWindow)return;try{b.contentWindow.postMessage(j,"*")}catch{}},[Z]),ZY=u.useRef(0),cX=u.useCallback(({format:j,artboardIds:b=null,scale:t=1,onProgress:W0,timeoutMs:F0=120000})=>new Promise((q0,k0)=>{let l=Z?m8.current.get(Z):null;if(!l||!l.contentWindow){k0(Error("no active canvas to capture"));return}let M0=l.contentWindow;ZY.current+=1;let O0=`cap-${Date.now().toString(36)}-${ZY.current}`,c0=!1,z8=(M9,k7)=>{if(c0)return;c0=!0,window.removeEventListener("message",B8),clearTimeout(Q6),M9(k7)},B8=(M9)=>{if(M9.source!==M0)return;let k7=M9.data;if(!k7||k7.id!==O0)return;if(k7.dgn==="export-capture-progress")W0?.(k7.current,k7.total);else if(k7.dgn==="export-capture-done")z8(q0,Array.isArray(k7.items)?k7.items:[]);else if(k7.dgn==="export-capture-error")z8(k0,Error(k7.message||"capture failed"))},Q6=setTimeout(()=>z8(k0,Error("capture timed out — the canvas did not answer")),F0);window.addEventListener("message",B8);try{M0.postMessage({dgn:"export-capture",id:O0,format:j,artboardIds:b,scale:t},"*")}catch(M9){z8(k0,M9)}}),[Z]),H0=u.useCallback((j,b)=>S8({dgn:"photo-preview",asset:j,edit:b}),[S8]),pK=u.useCallback((j,b,t)=>{hJ.current.undo.push({asset:j,before:b,after:t}),hJ.current.redo.length=0},[]),rQ=u.useCallback((j)=>{let b=j?hJ.current.redo:hJ.current.undo;if(!b.length)return!1;let t=b.pop();(j?hJ.current.undo:hJ.current.redo).push(t);let W0=(j?t.after:t.before)||{};return H0(t.asset,W0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(t.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(W0)}).catch(()=>{}),hK((F0)=>F0+1),!0},[H0]),JG=u.useCallback(async(j)=>{S8({dgn:"photo-busy",asset:j,busy:!0});try{let b=await fetch(`/${j.replace(/^\/+/,"")}`);if(!b.ok)return null;let t=await b.blob(),{removeBackground:W0}=await Promise.resolve().then(() => (te(),se)),F0=await W0(t),q0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":F0.type||"image/png"},body:F0}),k0=await q0.json().catch(()=>({}));if(q0.ok&&k0.path)return{maskAsset:k0.path};return null}catch(b){return console.error("[photo] background removal failed",b),null}finally{S8({dgn:"photo-busy",asset:j,busy:!1})}},[S8]);u.useEffect(()=>{let j=(W0)=>Array.from(W0.dataTransfer?.types??[]).includes("Files"),b=(W0)=>{if(j(W0))W0.preventDefault()},t=(W0)=>{if(j(W0))W0.preventDefault()};return document.addEventListener("dragover",b),document.addEventListener("drop",t),()=>{document.removeEventListener("dragover",b),document.removeEventListener("drop",t)}},[]);let R7=u.useRef({});R7.current={open:i6,comps:J6,frame:HJ,total:R5,playing:w5,compId:f7,muted:i,loop:E5,sequences:s8,post:S8,canvas:Z};let O7=u.useRef({undo:[],redo:[]}),T7=u.useCallback((j,b,t)=>{if(typeof b!=="number")return;if(O7.current.undo.push({canvas:j,seq:b,label:t}),O7.current.redo=[],O7.current.undo.length>50)O7.current.undo.shift()},[]),aQ=u.useCallback((j)=>{let b=O7.current,t=j==="undo"?b.undo:b.redo,W0=j==="undo"?b.redo:b.undo,F0=R7.current.canvas,q0=-1;for(let l=t.length-1;l>=0;l--)if(t[l].canvas===F0){q0=l;break}if(q0<0){l8(j==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let k0=t[q0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:k0.canvas,seq:k0.seq,dir:j})}).then((l)=>l.json().catch(()=>({}))).then((l)=>{if(t.splice(q0,1),l?.ok)W0.push(k0),l8(`${j==="undo"?"Undid":"Redid"}: ${k0.label}`,!0);else l8(`${j==="undo"?"Undo":"Redo"} skipped: ${l?.error||"failed"}`)}).catch(()=>l8(`${j==="undo"?"Undo":"Redo"} failed: network error`))},[]),w6=u.useCallback((j,b)=>{let t=j?.ok&&Array.isArray(j.clips)?j.clips.filter((W0)=>W0.kind==="sequence"):[];if(b==null)return null;if(typeof b==="object")return(b.stableId?t.find((W0)=>W0.stableId===b.stableId):null)||(Number.isInteger(b.index)?t[b.index]:null)||null;if(typeof b==="string")return t.find((W0)=>W0.stableId===b)||null;return t[b]||null},[]),HY=u.useCallback((j)=>{let b=R7.current.canvas;if(!b||b===c8)return;let t=fJ.current||void 0,W0=`/_api/comp-clips?canvas=${encodeURIComponent(b)}${t?`&artboardId=${encodeURIComponent(t)}`:""}`;fetch(W0).then((F0)=>F0.json().catch(()=>({}))).then((F0)=>{let q0=w6(F0,j);if(!q0?.stableId)return null;return fetch("/_api/remove-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:b,artboardId:t,stableId:q0.stableId,contentHash:q0.contentHash})})}).then((F0)=>F0?F0.json():null).then((F0)=>{if(F0&&!F0.ok)console.warn("[remove-clip]",F0.error||"failed"),y6("Remove refused",F0.error);else if(F0?.ok){if(l8("Clip removed.",!0),F0.seq!=null)T7(b,F0.seq,"remove clip");pX(null)}}).catch(()=>l8("Remove failed: network error"))},[w6,T7]),FQ=u.useCallback((j,b,t)=>{let W0=R7.current.canvas;if(!W0||W0===c8)return;let F0=fJ.current||void 0,q0=`/_api/comp-clips?canvas=${encodeURIComponent(W0)}${F0?`&artboardId=${encodeURIComponent(F0)}`:""}`;fetch(q0).then((k0)=>k0.json().catch(()=>({}))).then((k0)=>{let l=k0?.ok&&Array.isArray(k0.clips)?k0.clips:[],M0=j?.transition?l.find((O0)=>O0.kind==="transition"&&O0.stableId===j.stableId)||null:w6(k0,j);if(!M0?.stableId)return null;return fetch("/_api/clip-edit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:W0,artboardId:F0,stableId:M0.stableId,contentHash:M0.contentHash,verb:b,...t})})}).then((k0)=>k0?k0.json():null).then((k0)=>{if(k0&&!k0.ok)console.warn("[clip-edit]",b,k0.error||"failed"),y6(`${b} refused`,k0.error);else if(k0?.ok){let l={speed:"set speed","trim-in":"trim in-point",audio:"clip audio","detach-audio":"detach audio",framing:"crop clip",grade:"grade clip",transition:"edit transition",split:"split clip","insert-transition":"add transition","remove-transition":"remove transition","set-text":"edit text","to-overlay":"move to overlay layer","to-storyline":"move to storyline","layer-order":"reorder layers"};if(l8(`Applied: ${l[b]||b}.`,!0),k0.seq!=null)T7(W0,k0.seq,l[b]||b)}}).catch(()=>l8(`${b} failed: network error`))},[w6,T7,y6]),[pJ,zY]=u.useState(null),dJ=u.useCallback((j,b="")=>new Promise((t)=>{zY({title:j,value:b,resolve:t})}),[]),a0=u.useCallback((j)=>{zY((b)=>{return b?.resolve?.(j),null})},[]),iX=u.useCallback((j,b)=>{let t=R7.current.canvas;if(!t||t===c8||!b||!String(b).trim())return;I7({type:"comments-add",payload:{file:t,text:String(b).trim(),selector:"",dom_path:[],tag:"",classes:"",bounds:null,html_excerpt:"",timeline:j}}),l8("Comment added.",!0)},[]);R7.current.selected=j9,R7.current.setSelected=pX,R7.current.removeClip=HY,R7.current.clipVerb=FQ,R7.current.addComment=iX,R7.current.askText=dJ,u.useEffect(()=>{let j=(b)=>{let t=R7.current;if(!t.open||!t.comps?.length)return;let W0=b.target,F0=W0?.tagName;if(F0==="INPUT"&&W0?.type!=="range")return;if(F0==="TEXTAREA"||F0==="SELECT"||W0?.isContentEditable)return;let q0=GK(t.comps,t.compId)?.fps||30,k0=Math.max(1,t.total),l=(O0)=>{let c0=Math.max(0,Math.min(k0-1,Math.round(O0)));TX(c0),uX(!1),t.post({dgn:"timeline-seek",frame:c0,id:t.compId})},M0=()=>{let O0=new Set([0,k0-1]);for(let c0 of t.sequences||[]){O0.add(c0.from);for(let z8 of c0.keyframes||[])O0.add(z8.from),O0.add(z8.to)}return[...O0].filter((c0)=>c0>=0&&c0<k0).sort((c0,z8)=>c0-z8)};if((b.metaKey||b.ctrlKey)&&(b.key==="z"||b.key==="Z")){b.preventDefault(),aQ(b.shiftKey?"redo":"undo");return}if(b.key==="Escape"){if(t.selected!=null)b.preventDefault(),t.setSelected?.(null);return}if((b.key==="Delete"||b.key==="Backspace")&&t.selected!=null){b.preventDefault(),t.removeClip?.({stableId:t.selected});return}if((b.metaKey||b.ctrlKey)&&(b.key==="b"||b.key==="B")){b.preventDefault();let O0=t.selected!=null?{stableId:t.selected}:null;if(!O0){let c0=t.sequences||[],z8=c0.find((B8)=>B8.series&&t.frame>=B8.from&&t.frame<B8.from+B8.duration)||c0.find((B8)=>t.frame>=B8.from&&t.frame<B8.from+B8.duration);if(z8?.stableId)O0={stableId:z8.stableId}}if(O0)t.clipVerb?.(O0,"split",{atFrame:t.frame});else l8("Nothing under the playhead to split.");return}if(b.key===" "||b.code==="Space")if(b.preventDefault(),t.playing)uX(!1),t.post({dgn:"timeline-pause",id:t.compId});else uX(!0),t.post({dgn:"timeline-mute",muted:t.muted,id:t.compId}),t.post({dgn:"timeline-loop",loop:t.loop,id:t.compId}),t.post({dgn:"timeline-play",id:t.compId});else if(b.key==="ArrowRight")b.preventDefault(),l(t.frame+(b.shiftKey?q0:1));else if(b.key==="ArrowLeft")b.preventDefault(),l(t.frame-(b.shiftKey?q0:1));else if(b.key==="Home")b.preventDefault(),l(0);else if(b.key==="End")b.preventDefault(),l(k0-1);else if(b.key==="."){b.preventDefault();let O0=M0().find((c0)=>c0>t.frame);if(O0!=null)l(O0)}else if(b.key===","){b.preventDefault();let O0=M0().reverse().find((c0)=>c0<t.frame);if(O0!=null)l(O0)}};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[]),u.useEffect(()=>{vJ([]),TX(0),uX(!1),pX(null),UX(null);let j=setTimeout(()=>S8({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(j)},[Z,S8]);let[b5,n0]=u.useState(""),[LQ,s0]=u.useState([]),[QG,KY]=u.useState([]);u.useEffect(()=>{if(!i6||J6.length===0||!Z||Z===c8){n0(""),s0([]);return}let j=!0;return fetch(`/_api/canvas-source?file=${encodeURIComponent(Z)}`).then((b)=>b.ok?b.json():null).then((b)=>{if(j&&b?.ok&&typeof b.source==="string")n0(b.source)}).catch(()=>{}),()=>{j=!1}},[i6,J6,Z,VX]),u.useEffect(()=>{if(!i6||!Z||Z===c8||!b5){s0([]),KY([]);return}let j=!0,b=o9||void 0,t=`/_api/comp-clips?canvas=${encodeURIComponent(Z)}${b?`&artboardId=${encodeURIComponent(b)}`:""}`;return fetch(t).then((W0)=>W0.ok?W0.json():null).then((W0)=>{if(!j)return;let F0=W0?.ok&&Array.isArray(W0.clips)?W0.clips:[];s0(F0.filter((q0)=>q0.kind==="sequence")),KY(F0.filter((q0)=>q0.kind==="transition"))}).catch(()=>{}),()=>{j=!1}},[i6,Z,b5,o9,VX]),u.useEffect(()=>{if(!b5){o6([]),b6([]),pQ([]),s4(0);return}let j=Y8??B?.artboardId??null,t=(j&&J6.find((q0)=>q0.artboardId===j||q0.id===j)||J6[0])?.durationInFrames||0,W0=Nh(b5,t,j);UX(W0.artboardId??j??null);let F0=W0.sequences.map((q0,k0)=>{let l=LQ[k0];if(!l)return q0;return{...q0,stableId:l.stableId,contentHash:l.contentHash,mediaProps:l.mediaProps??null,placeholder:l.placeholder??null,mediaTag:l.mediaTag??q0.mediaTag,mediaSrc:l.mediaSrc??q0.mediaSrc,replaceable:!!(l.mediaCdId||l.mediaArrayRef),layers:Array.isArray(l.layers)?l.layers:[],hidden:!!l.hidden}});o6(F0),b6(W0.audio||[]),pQ(W0.transitions||[]),s4(W0.total)},[b5,LQ,B,J6,Y8]);let UY=u.useCallback(()=>{zH((j)=>{let b=!j,t=Z?m8.current.get(Z):null;if(t&&t.contentWindow)try{t.contentWindow.postMessage({dgn:"view-annotations",visible:b},"*")}catch{}return b})},[Z]),BX=u.useCallback((j)=>{for(let b of m8.current.values())try{b.contentWindow.postMessage({dgn:"view-chrome",...j},"*")}catch{}},[]),VY=u.useCallback(()=>{UH((j)=>{let b=!j;return BX({minimap:b}),b})},[BX]),qY=u.useCallback(()=>{qX((j)=>{let b=!j;return BX({zoom:b}),b})},[BX]),sQ=u.useCallback(()=>{tW((j)=>{let b=!j;return BX({present:b}),b})},[BX]),tQ=u.useCallback(()=>{tW(!1),BX({present:!1})},[BX]),YG=u.useCallback(()=>{if(!Z||Z===c8)return;lJ((j)=>{let b=!j;return S8({dgn:"view-chrome",print:b}),fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{overlays:{print:b}}})}).catch(()=>{}),b})},[Z,S8]);u.useEffect(()=>{let j=!1;return fetch("/_api/git-user").then((b)=>b.json()).then((b)=>{if(j)return;let t=b&&typeof b.name==="string"?b.name.trim():"";if(t)eW(t)}).catch(()=>{}),()=>{j=!0}},[]),u.useEffect(()=>{if(!Z||Z===c8){NQ(0),lJ(!1);return}let j=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(Z)).then((b)=>b.json()).then((b)=>{if(j)return;let t=Array.isArray(b?.artboards)?b.artboards.length:0;NQ(t),lJ(b?.overlays?.print===!0),X4(new Set(Array.isArray(b?.locked)?b.locked:[]))}).catch(()=>{if(!j)NQ(0),lJ(!1),X4(new Set)}),()=>{j=!0}},[Z]),u.useEffect(()=>{if(!Z||Z===c8||!Y8)return;let j=setTimeout(()=>{S8({dgn:"request-layers",artboardId:Y8})},250);return()=>clearTimeout(j)},[Z,Y8,S8]);let[eQ,X4]=u.useState(()=>new Set),WG=u.useCallback((j)=>{if(!Z||Z===c8)return;X4((b)=>{let t=new Set(b);if(t.has(j))t.delete(j);else t.add(j);let W0=[...t];return fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{locked:W0}})}).catch(()=>{}),S8({dgn:"locked-set",locked:W0}),t})},[Z,S8]);u.useEffect(()=>{if(!Z||Z===c8)return;S8({dgn:"locked-set",locked:[...eQ]})},[eQ,Z,S8]),u.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",F9),localStorage.setItem(j00,F9)}catch{}for(let j of m8.current.values())try{j.contentWindow.postMessage({dgn:"theme",theme:F9},"*")}catch{}},[F9]),u.useEffect(()=>{try{localStorage.setItem(W00,z7?"1":"0")}catch{}},[z7]),u.useEffect(()=>{try{localStorage.setItem(J00,T9?"1":"0")}catch{}},[T9]),u.useEffect(()=>{try{localStorage.setItem(Q00,JSON.stringify(X0))}catch{}},[X0]),u.useEffect(()=>{try{localStorage.setItem(G00,uJ?"1":"0")}catch{}},[uJ]),u.useEffect(()=>{try{localStorage.setItem(Z00,j6?"1":"0")}catch{}},[j6]),u.useEffect(()=>{try{localStorage.setItem(H00,BQ?"1":"0")}catch{}},[BQ]),u.useEffect(()=>{let j=!1;return fetch("/_api/ui-prefs").then((b)=>b.ok?b.json():Promise.reject(Error(`HTTP ${b.status}`))).then((b)=>{if(j||!b||typeof b!=="object")return;if(b.theme==="light"||b.theme==="dark")b9(b.theme);if(typeof b.minimap==="boolean")UH(b.minimap);if(typeof b.zoom==="boolean")qX(b.zoom);if(typeof b.annotations==="boolean")zH(b.annotations);if(typeof b.autoOpenInspector==="boolean")iW(b.autoOpenInspector);if(b.panelSides&&typeof b.panelSides==="object")RX({...$K,...b.panelSides});if(b.layersMode==="separate"||b.layersMode==="in-inspector")l9(b.layersMode)}).catch(()=>{}).finally(()=>{if(!j)uK(!0)}),()=>{j=!0}},[]),u.useEffect(()=>{if(!KH)return;F20({theme:F9,minimap:uJ,zoom:j6,annotations:BQ,autoOpenInspector:gJ,panelSides:C9,layersMode:I9})},[KH,F9,uJ,j6,BQ,gJ,C9,I9]),u.useEffect(()=>{try{localStorage.setItem(z00,JSON.stringify(C9))}catch{}},[C9]),u.useEffect(()=>{try{localStorage.setItem(K00,I9)}catch{}},[I9]);let GG=u.useCallback((j,b)=>{_0((t)=>{let W0=t[j],F0=W0===void 0?b:W0;return{...t,[j]:!F0}})},[]),J4=u.useCallback(()=>{b9((j)=>j==="dark"?"light":"dark")},[]),W7=u.useCallback(async()=>{try{let b=await(await fetch("/_index-data")).json();Y(b.project||"Design");let t=b.groups.map((W0)=>({...W0,tree:w20(W0.paths,W0.stripPrefix,W0.dirs)}));J(t),L8((W0)=>({...W0,canvasDesignSystems:b.canvasDesignSystems??{},canvasKinds:b.canvasKinds??{}}))}catch(j){console.error("failed to load tree",j)}},[]);u.useEffect(()=>{W7()},[W7]);let cJ=u.useCallback(async(j)=>{try{let b=j?`/_system-data?ds=${encodeURIComponent(j)}`:"/_system-data",t=await fetch(b);if(!t.ok){console.error("failed to load system-data",t.status);return}let W0=await t.json();if(!j&&W0?.defaultDesignSystem&&!W0.ds){A8(W0);let F0=await fetch(`/_system-data?ds=${encodeURIComponent(W0.defaultDesignSystem)}`);if(F0.ok)A8(await F0.json());return}A8(W0)}catch(b){console.error("failed to load system-data",b)}},[]),BY=u.useCallback(async()=>{try{let b=await(await fetch("/_comments-all")).json();a8(b||{})}catch(j){console.error("failed to load comments",j)}},[]);u.useEffect(()=>{BY()},[BY]),u.useEffect(()=>{let j=null;function b(){let t=location.protocol==="https:"?"wss:":"ws:",W0=new WebSocket(t+"//"+location.host+"/_ws");GY.current=W0,W0.addEventListener("open",()=>{r(!0),clearInterval(j),j=setInterval(()=>{if(W0.readyState===WebSocket.OPEN)W0.send('{"type":"ping"}')},25000)}),W0.addEventListener("close",()=>{r(!1),clearInterval(j),setTimeout(b,1000)}),W0.addEventListener("error",()=>{}),W0.addEventListener("message",(F0)=>{try{let q0=JSON.parse(F0.data);if(q0.type==="snapshot"&&q0.state)N((k0)=>$00(q0.state.selected,k0));else if(q0.type==="selected"){if(Date.now()-R.current<2000)return;let k0=q0.selected,l=Array.isArray(k0)?k0[0]:k0,M0=F.current,O0=Array.isArray(M0)?M0[0]:M0;if(N((c0)=>$00(k0,c0)),l?.id&&l.file&&(!O0||O0.id!==l.id||O0.file!==l.file))M(l)}else if(q0.type==="comments"&&typeof q0.file==="string")a8((k0)=>({...k0,[q0.file]:q0.comments||[]}));else if(q0.type==="ai-activity"&&typeof q0.file==="string"){if(WY(!0),nQ.current)clearTimeout(nQ.current);nQ.current=setTimeout(()=>WY(!1),8000);for(let k0 of m8.current.values())try{k0.contentWindow.postMessage({dgn:"ai-activity",file:q0.file,entry:q0.entry},"*")}catch{}}else if(q0.type==="export:job"&&q0.payload)JY.upsert(q0.payload);else if(q0.type==="sync:status"&&q0.payload)o(q0.payload);else if(q0.type==="canvas-list-update"){if(W7(),q0.payload?.action==="moved"&&q0.payload.fromRel&&q0.payload.rel){let k0=(f0?.designRel||f0?.designRoot||".design").replace(/^\/+|\/+$/g,""),l=`${k0}/${q0.payload.fromRel}`,M0=`${k0}/${q0.payload.rel}`;G((O0)=>O0.map((c0)=>c0.path===l?{path:M0}:c0)),H((O0)=>O0===l?M0:O0)}}else if(q0.type==="config-updated")V8();else if(q0.type==="acp-focus"){if(W9())mJ("assistant")}else if(q0.type==="git-status"&&q0.payload){if(!L0.current)K0(q0.payload)}else if(q0.type==="git-lifecycle"&&q0.payload){c(q0.payload);for(let k0 of m8.current.values())try{k0.contentWindow.postMessage({dgn:"git-lifecycle",payload:q0.payload},"*")}catch{}}}catch{}})}return b(),()=>{if(clearInterval(j),GY.current)GY.current.close()}},[W7,V8]);function I7(j){let b=GY.current;try{if(b&&b.readyState===1)b.send(JSON.stringify(j))}catch{}}let NX=u.useCallback(async()=>{if(L0.current)return;try{let j=await fetch("/_api/git/status");if(j.ok)K0(await j.json())}catch{}},[]),kX=u.useCallback(async()=>{if(L0.current)return;try{let j=await fetch("/_api/git/status?remote=1");if(!j.ok)return;let b=await j.json();if(b&&b.repo!==!1)Q8({remoteAhead:!!b.remoteAhead,behind:b.behind||0})}catch{}},[]),FX=u.useCallback(async(j,b)=>{try{let t=await fetch(j,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b||{})}),W0=await t.json().catch(()=>({}));return{ok:t.ok,...W0}}catch(t){return{ok:!1,error:"Network error — is the project still open?"}}},[]),ZG=u.useCallback(async(j,b)=>{let t=await FX("/_api/git/commit",{message:j,files:b});if(t.ok)await NX();return t},[FX,NX]),NY=u.useCallback(async(j)=>{let b=await FX("/_api/git/discard",{files:j});if(b.ok)await NX();return b},[FX,NX]),HG=u.useCallback(async()=>{let j=await FX("/_api/git/push",{});if(j.ok)await NX(),kX();return j},[FX,NX,kX]),FY=u.useCallback(async()=>{let j=await FX("/_api/git/pull",{});if(j.ok)await NX(),kX();if(j.conflict&&Array.isArray(j.files)&&j.files.length)K8({file:j.files[0],conflict:!0});return j},[FX,NX,kX]),zG=u.useCallback(async(j)=>{let b=await FX("/_api/git/resolve",{choice:j});if(b.ok)await NX(),kX();return b},[FX,NX,kX]),LY=u.useCallback(async(j)=>{try{let b="/_api/git/log?limit=40"+(j?`&path=${encodeURIComponent(j)}`:""),t=await fetch(b);if(!t.ok)return[];return(await t.json()).entries||[]}catch{return[]}},[]),[KG,UG]=u.useState(null),VG=u.useCallback(async(j)=>{try{let b="/_api/cloud/history?limit=40"+(j?`&path=${encodeURIComponent(j)}`:""),t=await fetch(b);if(!t.ok)return null;let W0=await t.json();if(!W0?.ok)return null;return UG({branch:W0.branch??null,project:W0.project??null,hubHost:W0.hubHost??null}),W0.entries||[]}catch{return null}},[]),qG=u.useMemo(()=>{let j={modified:"M",added:"A",deleted:"D",untracked:"U"},b=new Map;if(q8)return b;for(let t of N0?.files||[])b.set(t.path,j[t.status]);return b},[N0,q8]);u.useEffect(()=>{if(q8){Q8(null);return}if(N0?.repo===!1)return;kX();let j=setInterval(kX,o0?60000:120000);return()=>clearInterval(j)},[q8,N0?.repo,o0,kX]);let K6=u.useCallback((j)=>{if(G((b)=>{for(let t of b)if(t.path!==j)m8.current.delete(t.path);return[{path:j}]}),H(j),N9(null),U(null),j!==c8)P9(j)},[]),DY=u.useRef(!1);u.useEffect(()=>{if(DY.current)return;if(!f0.cloud)return;if(W.length>0)return;if(!X.length)return;let j=null;for(let b of X){for(let t of b.paths||[]){if(!GQ.test(t))continue;if(/(^|\/)system\//.test(t))continue;j=t;break}if(j)break}if(!j)return;DY.current=!0,K6(j)},[f0.cloud,X,W.length,K6]);let iJ=u.useCallback((j)=>{let b=typeof j==="string"?j:void 0;if(b)cJ(b);else if(!W8)cJ();K6(c8)},[W8,cJ,K6]);u.useEffect(()=>{I7({type:"tabs",tabs:W.map((j)=>j.path).filter((j)=>j!==c8)})},[W]),u.useEffect(()=>{if(Z&&Z!==c8)I7({type:"active",file:Z});else if(Z===c8)I7({type:"active",file:""});else I7({type:"active",file:""})},[Z]);let Q4=u.useCallback((j)=>{G((b)=>{let t=b.findIndex((F0)=>F0.path===j);if(t<0)return b;let W0=b.filter((F0)=>F0.path!==j);if(j===Z)if(W0.length===0)H(null);else H(W0[Math.max(0,t-1)].path);return W0}),m8.current.delete(j),P9((b)=>b===j?null:b)},[Z]),UJ=u.useCallback(()=>{if(!Z||Z===c8){if(Z===c8)cJ();return}let j=m8.current.get(Z);if(j)j.src=j.src},[Z,cJ]),OY=u.useCallback(()=>W7(),[W7]),[BG,MY]=u.useState(!1),Y4=u.useRef(!1),W4=u.useCallback(async()=>{if(Y4.current)return;Y4.current=!0,MY(!0);try{await Promise.all([W7(),new Promise((j)=>setTimeout(j,550))])}finally{Y4.current=!1,MY(!1)}},[W7]);u.useEffect(()=>{let j=null,b=()=>{if(j)clearTimeout(j);j=setTimeout(()=>{j=null,OY()},150)};return window.addEventListener("focus",b),()=>{if(window.removeEventListener("focus",b),j)clearTimeout(j)}},[OY]);let NG=u.useCallback(async(j)=>{try{let b=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j,kind:"brief-board"})}),t=await b.json().catch(()=>({}));if(!b.ok||!t.ok)return{ok:!1,error:t.error||`create failed (${b.status})`};return await W7(),K6(t.file),{ok:!0,file:t.file}}catch(b){return{ok:!1,error:b instanceof Error?b.message:"network error"}}},[W7,K6]),_Y=u.useCallback(async()=>{let j=await dJ("New video name");if(!j)return;let t=(await dJ("Size — 1920x1080 (landscape), 1080x1920 (portrait), 1080x1080 (square), or custom WxH","1920x1080")||"1920x1080").toLowerCase().match(/(\d{2,5})\s*[x×]\s*(\d{2,5})/),W0=t?Number(t[1]):1920,F0=t?Number(t[2]):1080,q0=Math.max(1,Math.min(60,Number(await dJ("Frames per second","30"))||30));try{let k0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j,kind:"video-comp",clips:[],fps:q0,width:W0,height:F0})}),l=await k0.json().catch(()=>({}));if(!k0.ok||!l.ok){l8(`New video failed: ${l.error||`error ${k0.status}`}`);return}await W7(),K6(l.file),zQ(!0),l8("New video created — drop clips on the timeline to start the cut.",!0)}catch(k0){l8(`New video failed: ${k0 instanceof Error?k0.message:"network error"}`)}},[W7,K6,dJ]),FG=u.useCallback(async()=>{if(!Z||Z===c8)return;try{let j=await fetch(`/_api/annotations?file=${encodeURIComponent(Z)}`),b=j.ok?await j.text():"",t=[];if(b){let l=new DOMParser().parseFromString(b,"image/svg+xml");for(let M0 of l.querySelectorAll('[data-tool="mediaref"]')){let O0=M0.getAttribute("data-src");if(!O0)continue;t.push({src:O0,mediaKind:M0.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(t.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let F0=`${pW(JH(Z)).replace(/\.tsx$/i,"")} Video`,q0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:F0,kind:"video-comp",clips:t})}),k0=await q0.json().catch(()=>({}));if(!q0.ok||!k0.ok){window.alert(`Assemble failed: ${k0.error||`error ${q0.status}`}`);return}await W7(),K6(k0.file)}catch(j){window.alert(`Assemble failed: ${j instanceof Error?j.message:"network error"}`)}},[Z,W7,K6]),G4=u.useCallback(({accept:j,resolveTarget:b})=>{let t=Z,W0=o9||void 0,F0=document.createElement("input");F0.type="file",F0.accept=j,F0.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(F0);let q0=()=>{if(F0.isConnected)F0.remove()};window.addEventListener("focus",()=>setTimeout(q0,300),{once:!0}),F0.addEventListener("change",()=>{let k0=F0.files?.[0];if(q0(),!k0)return;let l=`/_api/comp-clips?canvas=${encodeURIComponent(t)}${W0?`&artboardId=${encodeURIComponent(W0)}`:""}`;fetch(l).then((M0)=>M0.json().catch(()=>({}))).then((M0)=>{let O0=b(M0);if(!O0)return l8("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":k0.type||"application/octet-stream"},body:k0}).then((c0)=>c0.json().catch(()=>({}))).then((c0)=>{if(!c0?.path)return l8(`Upload failed: ${c0?.error||"unknown error"}`),null;if(O0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:t,arrayName:O0.arrayRef.arrayName,index:O0.arrayRef.index,field:O0.arrayRef.field,value:c0.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:t,id:O0.cdId,attr:"src",value:c0.path})})})}).then((M0)=>M0?M0.json():null).then((M0)=>{if(M0&&!M0.ok)l8(`Replace refused: ${M0.error||"failed"}`);else if(M0&&M0.ok){if(l8("Media replaced.",!0),M0.seq!=null)T7(t,M0.seq,"replace media")}}).catch(()=>l8("Replace failed: network error"))}),F0.click()},[Z,o9,T7]),LG=u.useCallback(async(j,b)=>{if(!window.confirm(`Move “${b}” to trash?
5653
+ `).length," lines, paths & secrets scrubbed) —"," ",O("details",{className:"rb-details",children:[z("summary",{children:"view"}),z("pre",{className:"rb-log",children:H.logs.serverLogTail})]})]})]}):null,W9()&&B.length>0&&O("label",{className:"rb-check",children:[z("input",{type:"checkbox",checked:F.crashLogs,onChange:(p)=>D({...F,crashLogs:p.target.checked})}),O("span",{children:["Crash logs (",B.length,") — ",z("code",{children:B.map((p)=>p.name).join(", ")})]})]})]}),O("p",{className:"rb-hint",children:["Your description and the system info above become a"," ",z("strong",{children:"public GitHub issue"}),"; screenshots and logs go to a private repository only maintainers can open."]}),O("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("describe"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary","data-testid":"report-bug-send",onClick:n,children:"Send report"})]})]}),Y==="sending"&&z("p",{className:"rb-hint",children:"Sending your report…"}),Y==="done"&&O(G0,{children:[P?.issueUrl?O("p",{children:["Thank you — your report is filed as"," ",O("button",{type:"button",className:"rb-link","data-testid":"report-bug-issue-link",onClick:()=>{if(W9())nU(P.issueUrl).catch(()=>navigator.clipboard?.writeText(P.issueUrl));else window.open(P.issueUrl,"_blank","noopener")},children:["report #",P.issueNumber]})," ","on the public Maude issue tracker. Screenshots and logs stay in a private repository only maintainers can open — the issue links to them."]}):O("p",{children:["The bundle is saved locally",P?.fallbackDir?O(G0,{children:[" ","at ",z("code",{children:P.fallbackDir})]}):null," ","and a prefilled GitHub issue was opened — attach the bundle files there."]}),z("footer",{className:"rb-actions",children:z("button",{type:"button",className:"st-btn rb-primary",onClick:h,children:"Done"})})]}),Y==="fallback"&&O(G0,{children:[z("p",{className:"rb-error","data-testid":"report-bug-error",children:k}),z("p",{className:"rb-hint",children:"You can save the report locally instead and file it on GitHub yourself — the prefilled issue carries the text; screenshots stay on this machine unless you attach them by hand."}),O("footer",{className:"rb-actions",children:[z("button",{type:"button",className:"st-btn",onClick:()=>W("preview"),children:"Back"}),z("button",{type:"button",className:"st-btn rb-primary",onClick:x,children:"Save locally & open GitHub"})]})]})]})]})})}var GJ=x8(r8(),1);function fh(X){if(typeof X!=="string")return null;let J=X.match(/^(\d+)\.(\d+)\.(\d+)/);return J?[Number(J[1]),Number(J[2]),Number(J[3])]:null}function xh(X,J){let Q=fh(X),Y=fh(J);if(!Q)return!1;if(!Y)return!0;for(let W=0;W<3;W++)if(Q[W]!==Y[W])return Q[W]>Y[W];return!1}function hh(X,J){if(!Array.isArray(X))return[];return X.filter((Q)=>Q&&(Q.version==null||xh(Q.version,J)))}function gh(X,J){let Q=J;if(Array.isArray(X)){for(let Y of X)if(Y&&Y.version&&xh(Y.version,Q))Q=Y.version}return Q}var Nw="mdcc-whatsnew-seen",Fw="mdcc-whatsnew-toast-dismissed";function YK0(X){return typeof X==="string"&&/^https?:\/\//i.test(X)}function WK0(X){try{let J=localStorage.getItem(Nw);if(J)return J;localStorage.setItem(Nw,X)}catch{}return X}function GK0(){try{return localStorage.getItem(Fw)}catch{return null}}function mh(X){let[J,Q]=GJ.useState([]),[Y,W]=GJ.useState(X),[G,Z]=GJ.useState(()=>WK0(X)),[H,K]=GJ.useState(()=>GK0()),[U,q]=GJ.useState(!1);GJ.useEffect(()=>{let M=!1,P=()=>{fetch("/_api/whats-new").then(($)=>$.json()).then(($)=>{if(M)return;if(Q(Array.isArray($?.entries)?$.entries:[]),typeof $?.version==="string")W($.version)}).catch(()=>{})};P();let I=()=>P(),k=()=>{if(document.visibilityState==="visible")P()};return window.addEventListener("focus",I),document.addEventListener("visibilitychange",k),()=>{M=!0,window.removeEventListener("focus",I),document.removeEventListener("visibilitychange",k)}},[]);let B=hh(J,G),N=B.length>0&&H!==Y&&!U,F=B[0]??null,D=GJ.useCallback(()=>{let M=gh(J,Y);Z(M),K(Y);try{localStorage.setItem(Nw,M),localStorage.setItem(Fw,Y)}catch{}},[J,Y]),_=GJ.useCallback(()=>{K(Y);try{localStorage.setItem(Fw,Y)}catch{}},[Y]),R=GJ.useCallback(()=>q(!0),[]),w=GJ.useCallback(()=>{q(!1),D()},[D]);return{entries:J,unseen:B,feedVersion:Y,panelOpen:U,openPanel:R,closePanel:w,showToast:N,toastEntry:F,dismissToast:_,markAllSeen:D}}function uh({wn:X}){if(!X.showToast||!X.toastEntry)return null;let J=X.toastEntry,Q=X.unseen.length;return O("div",{className:"st-toast",role:"status","aria-live":"polite",children:[z("button",{type:"button",className:"st-toast-close","aria-label":"Dismiss",onClick:X.dismissToast,children:"×"}),O("div",{className:"st-toast-hd",children:[z("span",{"aria-hidden":"true",children:"✦"}),"What's new",J.version?` · v${J.version}`:""]}),z("div",{className:"st-toast-title",children:J.title}),z("div",{className:"st-toast-txt",children:J.summary}),O("div",{className:"st-toast-actions",children:[z("button",{type:"button",className:"btn btn--primary btn--sm",onClick:X.openPanel,children:Q>1?`See all (${Q})`:"Details"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:X.dismissToast,children:"Dismiss"})]})]})}function lh({wn:X,onStartTour:J}){let{panelOpen:Q,closePanel:Y}=X;if(GJ.useEffect(()=>{if(!Q)return;function G(Z){if(Z.key==="Escape")Y()}return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[Q,Y]),!Q)return null;let W=new Set(X.unseen.map((G)=>G.id));return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(G)=>{if(G.target===G.currentTarget)Y()},children:O("div",{className:"mdcc-wn-panel",role:"dialog","aria-modal":"true","aria-labelledby":"mdcc-wn-title",children:[O("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"mdcc-wn-title",children:"✦ What’s new in maude"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:Y,children:"×"})]}),z("div",{className:"mdcc-wn-panel__body",children:X.entries.length===0?z("p",{className:"mdcc-wn-empty",children:"Nothing new yet."}):z("ul",{className:"mdcc-wn-list",children:X.entries.map((G)=>O("li",{className:"mdcc-wn-item"+(W.has(G.id)?" is-unseen":""),children:[O("div",{className:"mdcc-wn-item__hd",children:[z("span",{className:"mdcc-wn-kind mdcc-wn-kind--"+G.kind,children:G.kind}),z("span",{className:"mdcc-wn-item__title",children:G.title}),z("span",{className:"mdcc-wn-item__ver",children:G.version?`v${G.version}`:"next"})]}),z("p",{className:"mdcc-wn-item__summary",children:G.summary}),YK0(G.learnMore)&&z("a",{className:"mdcc-wn-item__more",href:G.learnMore,target:"_blank",rel:"noreferrer",children:"Learn more →"}),J&&Array.isArray(G.tour)&&G.tour.length>0&&z("button",{type:"button",className:"mdcc-wn-item__tour",onClick:()=>{Y(),J(G.tour)},children:"▶ Take tour"})]},G.id))})})]})})}var Y7=({as:X,size:J=14})=>z(X,{size:J,strokeWidth:1.75,style:{display:"block"}}),ee="mdcc-usage-tour-seen",X00="mdcc-collab-tour-seen",c8="__system__",j00="mdcc-theme",J00="mdcc-show-hidden",Q00="mdcc-sections-expanded",Y00="maude-cp-mode",W00="mdcc-sidebar-open",G00="mdcc-minimap-visible",Z00="mdcc-zoomctl-visible",H00="mdcc-annotations-visible";var N20=30000;function F20(X){try{fetch("/_api/ui-prefs",{method:"POST",headers:{"content-type":"text/plain"},body:JSON.stringify(X)}).catch(()=>{})}catch{}}var GT=[{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"}],$K={tree:"left",layers:"left",inspector:"right",comments:"right",changes:"right",sync:"right",assistant:"right"},z00="mdcc-panel-sides",K00="mdcc-layers-mode";function U00({side:X,width:J,open:Q,ids:Y,activeId:W,onPick:G,children:Z,labels:H=null}){return O("div",{className:"st-dockslot st-dockslot--"+X+(Q?"":" is-collapsed"),style:{width:Q?J:0,flexBasis:Q?J:0},children:[Q&&Y.length>1&&z("div",{className:"st-docktabs",role:"tablist","aria-label":X+" panels",children:Y.map((K)=>z("button",{type:"button",role:"tab","aria-selected":W===K,className:"st-docktab"+(W===K?" is-active":""),onClick:()=>G(K),children:H?.[K]||(GT.find((U)=>U.id===K)||{}).label||K},K))}),Z]})}var GQ=/\.(tsx|html?)$/i,L20=[[/\.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 ZT(X){for(let[J,Q]of L20)if(J.test(X))return Q;return null}function PF(X){return X.replace(/^\.[^/]+\//,"").replace(GQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,"")}var HT="1.0.11";function V00(X,J){let Q=()=>{try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification(X,{body:J})}catch{}};if(W9()){y7("send_notification",{title:X,body:J}).catch(Q);return}Q()}function D20(){if(typeof window>"u")return"dark";try{let X=localStorage.getItem(j00);if(X==="light"||X==="dark")return X}catch{}return"dark"}function XH(X,J){if(typeof window>"u")return J;try{let Q=localStorage.getItem(X);if(Q==="1")return!0;if(Q==="0")return!1}catch{}return J}function JT(X,J){if(typeof window>"u")return J;try{let Q=localStorage.getItem(X);return Q?JSON.parse(Q):J}catch{return J}}function O20(X){if(X.kind==="runtime")return!1;if(X.label==="Design system")return!1;return!0}function JH(X){return X.split("/").pop()}function l8(X,J=!1,Q){if(typeof document>"u")return;let Y=document.getElementById("st-op-toast");if(!Y)Y=document.createElement("div"),Y.id="st-op-toast",Y.setAttribute("role","status"),Y.style.cssText="position:fixed;left:50%;bottom:64px;transform:translateX(-50%);z-index:80;display:flex;align-items:center;gap:10px;max-width:440px;padding:8px 14px;border-radius:8px;font:12px/1.45 var(--font-mono,monospace);box-shadow:0 8px 28px rgba(0,0,0,.34);pointer-events:none;opacity:0;transition:opacity 140ms ease;",document.body.appendChild(Y);Y.style.background=J?"#1d3524":"#3a1d1d",Y.style.color=J?"#b7e4c0":"#f1b8b8",Y.textContent="";let W=document.createElement("span");if(W.textContent=X,Y.appendChild(W),Q){let G=document.createElement("button");G.type="button",G.textContent=Q.label,G.style.cssText="pointer-events:auto;background:none;border:0;text-decoration:underline;color:inherit;font:inherit;cursor:pointer;padding:0;",G.onclick=()=>{Q.onClick(),Y.style.opacity="0",Y.style.pointerEvents="none"},Y.appendChild(G)}Y.style.opacity="1",Y.style.pointerEvents=Q?"auto":"none",clearTimeout(l8._t),l8._t=setTimeout(()=>{Y.style.opacity="0",Y.style.pointerEvents="none"},Q?6000:3200)}var q00="maude-mode-hint-seen";function M20(X=!1){if(typeof document>"u"||typeof localStorage>"u")return;try{if(localStorage.getItem(q00)==="1")return}catch{return}if(document.getElementById("st-browse-hint"))return;let J=document.createElement("div");J.id="st-browse-hint",J.setAttribute("role","status"),J.style.cssText="position:fixed;left:50%;bottom:64px;transform:translateX(-50%);z-index:81;display:flex;align-items:center;gap:10px;max-width:520px;padding:10px 14px;border-radius:10px;font:12px/1.5 var(--font-ui,system-ui,sans-serif);background:var(--surface-2,#1b1e24);color:var(--text-1,#e7eaf0);border:1px solid var(--border-1,#333a45);box-shadow:0 10px 34px rgba(0,0,0,.42);opacity:0;transition:opacity 160ms ease;";let Q='<kbd style="padding:1px 6px;border-radius:5px;border:1px solid var(--border-1,#333a45);background:var(--surface-3,#262b33);font-family:var(--font-mono,monospace)">V</kbd>';J.innerHTML=(X?`<span>Your mock is <strong>live</strong> — click things to try it. Press ${Q} to select &amp; inspect.</span>`:"<span>You’re in <strong>Edit</strong> — click selects, like Figma. "+"Switch to <strong>Preview</strong> in the toolbar to use the live mock.</span>")+'<button type="button" aria-label="Dismiss" style="background:none;border:none;color:inherit;'+'cursor:pointer;font-size:15px;line-height:1;opacity:.65;padding:2px">×</button>';let Y=()=>{try{localStorage.setItem(q00,"1")}catch{}J.style.opacity="0",setTimeout(()=>J.remove(),200),document.removeEventListener("keydown",W,!0)},W=(G)=>{if((G.key==="v"||G.key==="V")&&!G.metaKey&&!G.ctrlKey&&!G.altKey)Y()};if(J.querySelector("button")?.addEventListener("click",Y),X)document.addEventListener("keydown",W,!0);document.body.appendChild(J),requestAnimationFrame(()=>{J.style.opacity="1"}),setTimeout(Y,9000)}function pW(X){return X.replace(GQ,"")}function _20(X){return X.replace(GQ,"")}function A20(X){let J=new Map;for(let G of X){if(!GQ.test(G.name))continue;let Z=_20(G.name);if(!J.has(Z)||/\.tsx$/i.test(G.name))J.set(Z,G)}let Q=new Map,Y=[];for(let G of X){if(GQ.test(G.name))continue;let Z=null;for(let H of J.keys()){if(G.name===H)continue;if(G.name.startsWith(`${H}.`)){if(!Z||H.length>Z.length)Z=H}}if(Z){let H=Q.get(Z)||[];H.push(G),Q.set(Z,H)}else Y.push(G)}let W=[];for(let[G,Z]of J){let H=(Q.get(G)||[]).sort((K,U)=>K.name.localeCompare(U.name));W.push({primary:Z,sidecars:H,orphan:!1})}return W.sort((G,Z)=>G.primary.name.localeCompare(Z.primary.name)),Y.sort((G,Z)=>G.name.localeCompare(Z.name)),{canvases:W,orphans:Y.map((G)=>({primary:G,sidecars:[],orphan:!0}))}}function w20(X,J,Q){let Y={};for(let W of Q||[]){let Z=(W.startsWith(J)?W.slice(J.length).replace(/^\/+/,""):W).split("/").filter(Boolean),H=Y;for(let K of Z)H=H[K]=H[K]||{};H._files=H._files||[]}for(let W of X){let Z=(W.startsWith(J)?W.slice(J.length).replace(/^\/+/,""):W).split("/"),H=Y;for(let K=0;K<Z.length;K++){let U=Z[K];if(K===Z.length-1)H._files=H._files||[],H._files.push({name:U,path:W});else H[U]=H[U]||{},H=H[U]}}return Y}function v00(X,J){if(!J)return X;let Q=J.toLowerCase(),Y={},W=!1,G=Object.keys(X).filter((Z)=>Z!=="_files");for(let Z of G){let H=v00(X[Z],J);if(H)Y[Z]=H,W=!0}if(X._files){let Z=X._files.filter((H)=>H.name.toLowerCase().includes(Q)||H.path.toLowerCase().includes(Q));if(Z.length)Y._files=Z,W=!0}return W?Y:null}function wF(X){return(X||[]).filter((J)=>J.status!=="resolved").length}function E20(X){if(!X)return"";let J=new Date(X).getTime();if(!J)return"";let Q=Math.max(0,Math.floor((Date.now()-J)/1000));if(Q<60)return Q+"s";let Y=Math.floor(Q/60);if(Y<60)return Y+"m";let W=Math.floor(Y/60);if(W<24)return W+"h";let G=Math.floor(W/24);if(G<7)return G+"d";return new Date(X).toLocaleDateString()}function f00(X){let J=0,Q=0,Y=0;for(let W of Object.values(X||{}))for(let G of W||[])if(J++,G.status==="resolved")Y++;else Q++;return{all:J,open:Q,resolved:Y}}function RF({d:X,size:J=14,color:Q}){return z("svg",{width:J,height:J,viewBox:"0 0 24 24",fill:"none",stroke:Q||"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{flex:"none"},children:z("path",{d:X})})}var P20={"chevron-down":z("polyline",{points:"3.5 6 8 10.5 12.5 6"}),"chevron-right":z("polyline",{points:"6 3.5 10.5 8 6 12.5"}),file:O(G0,{children:[z("path",{d:"M4 2h5l3 3v9H4z"}),z("polyline",{points:"9 2 9 5 12 5"})]}),folder:z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),"folder-plus":O(G0,{children:[z("path",{d:"M2 4.5h4l1.3 1.5H14V13H2z"}),z("path",{d:"M8 7.5v3.5M6.25 9.25h3.5"})]}),lock:O(G0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015 0v2"})]}),unlock:O(G0,{children:[z("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1"}),z("path",{d:"M5.5 7V5a2.5 2.5 0 015-.7"})]}),search:O(G0,{children:[z("circle",{cx:"7",cy:"7",r:"4"}),z("line",{x1:"10",y1:"10",x2:"13.5",y2:"13.5"})]}),plus:O(G0,{children:[z("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),z("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]}),check:z("polyline",{points:"3 8.2 6.4 11.5 13 4.2"}),x:O(G0,{children:[z("line",{x1:"4.3",y1:"4.3",x2:"11.7",y2:"11.7"}),z("line",{x1:"11.7",y1:"4.3",x2:"4.3",y2:"11.7"})]}),sun:O(G0,{children:[z("circle",{cx:"8",cy:"8",r:"2.6"}),z("line",{x1:"8",y1:"1.5",x2:"8",y2:"3"}),z("line",{x1:"8",y1:"13",x2:"8",y2:"14.5"}),z("line",{x1:"1.5",y1:"8",x2:"3",y2:"8"}),z("line",{x1:"13",y1:"8",x2:"14.5",y2:"8"}),z("line",{x1:"3.4",y1:"3.4",x2:"4.4",y2:"4.4"}),z("line",{x1:"11.6",y1:"11.6",x2:"12.6",y2:"12.6"}),z("line",{x1:"12.6",y1:"3.4",x2:"11.6",y2:"4.4"}),z("line",{x1:"4.4",y1:"11.6",x2:"3.4",y2:"12.6"})]}),moon:z("path",{d:"M12.5 9.6A5 5 0 1 1 7 3a4 4 0 0 0 5.5 6.6z"}),sparkle:z("path",{d:"M8 1.8l1.4 4.8L14 8l-4.6 1.4L8 14.2l-1.4-4.8L2 8l4.6-1.4z",fill:"currentColor",stroke:"none"}),megaphone:O(G0,{children:[z("path",{d:"M2 6.7 11 4v8L2 9.3z"}),z("path",{d:"M11 5.2a2.4 2.4 0 0 1 0 5.6"}),z("path",{d:"M4.3 9.5v2.3a1.2 1.2 0 0 0 2.4 0v-1.7"})]}),bug:O(G0,{children:[z("circle",{cx:"8",cy:"9",r:"3.6"}),z("circle",{cx:"8",cy:"4.4",r:"1.3"}),z("path",{d:"M6.2 3.4 5.2 2M9.8 3.4l1-1.4"}),z("path",{d:"M4.6 7.6H2.2M4.6 9H2.2M4.6 10.6H2.5M11.4 7.6h2.4M11.4 9h2.4M11.4 10.6h2.3"})]}),"panel-left":O(G0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("line",{x1:"6.4",y1:"3",x2:"6.4",y2:"13"})]}),resolve:O(G0,{children:[z("circle",{cx:"8",cy:"8",r:"5.6"}),z("polyline",{points:"5.4 8 7.2 9.9 10.6 6"})]}),reopen:O(G0,{children:[z("path",{d:"M3.2 8a5 5 0 1 1 1.4 3.5"}),z("polyline",{points:"3.2 11.4 3.2 8 6.6 8"})]}),layers:O(G0,{children:[z("polygon",{points:"8 2.2 13.8 5.5 8 8.8 2.2 5.5"}),z("polyline",{points:"2.2 9 8 12.3 13.8 9"})]}),box:z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.2"}),type:O(G0,{children:[z("polyline",{points:"4 4 12 4"}),z("line",{x1:"8",y1:"4",x2:"8",y2:"12"})]}),button:O(G0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"3"}),z("line",{x1:"6",y1:"8",x2:"10",y2:"8"})]}),input:O(G0,{children:[z("rect",{x:"2.5",y:"5",width:"11",height:"6",rx:"1.2"}),z("line",{x1:"5",y1:"8",x2:"5",y2:"8"})]}),link:O(G0,{children:[z("path",{d:"M6.5 9.5a2.5 2.5 0 0 1 0-3.5l1.5-1.5a2.5 2.5 0 0 1 3.5 3.5l-1 1"}),z("path",{d:"M9.5 6.5a2.5 2.5 0 0 1 0 3.5l-1.5 1.5a2.5 2.5 0 0 1-3.5-3.5l1-1"})]}),list:O(G0,{children:[z("line",{x1:"6",y1:"4.5",x2:"13",y2:"4.5"}),z("line",{x1:"6",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6",y1:"11.5",x2:"13",y2:"11.5"}),z("circle",{cx:"3.2",cy:"4.5",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"8",r:"0.8",fill:"currentColor"}),z("circle",{cx:"3.2",cy:"11.5",r:"0.8",fill:"currentColor"})]}),eye:O(G0,{children:[z("path",{d:"M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z"}),z("circle",{cx:"8",cy:"8",r:"2"})]}),eyedropper:O(G0,{children:[z("path",{d:"M11 2.6a1.7 1.7 0 0 1 2.4 2.4l-1.2 1.2-2.4-2.4z"}),z("path",{d:"M9.5 4.6 4 10.1V12h1.9l5.5-5.5"})]}),"p-corner":z("path",{d:"M3.5 12.5V7a3.5 3.5 0 0 1 3.5-3.5h5.5"}),"p-opacity":O(G0,{children:[z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1.5"}),z("path",{d:"M3 8h10M8 3v10",strokeWidth:"0.9",opacity:"0.55"})]}),"p-lineheight":O(G0,{children:[z("line",{x1:"6.5",y1:"4",x2:"13",y2:"4"}),z("line",{x1:"6.5",y1:"8",x2:"13",y2:"8"}),z("line",{x1:"6.5",y1:"12",x2:"13",y2:"12"}),z("path",{d:"M3.2 4.6 3.2 11.4M2 6 3.2 4.5 4.4 6M2 10 3.2 11.5 4.4 10"})]}),"p-letterspacing":O(G0,{children:[z("path",{d:"M3 4v8M13 4v8"}),z("path",{d:"M6 11.5 8 5l2 6.5M6.7 9.3h2.6",strokeWidth:"1.1"})]}),"p-gap":O(G0,{children:[z("rect",{x:"2",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("rect",{x:"10.4",y:"4.5",width:"3.6",height:"7",rx:"0.6"}),z("path",{d:"M6.8 8h2.4M7.4 6.9 6.4 8l1 1.1M8.6 6.9 9.6 8l-1 1.1",strokeWidth:"1"})]}),"p-border":z("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"}),"p-size":O(G0,{children:[z("path",{d:"M3 13 6.6 3l3.6 10"}),z("path",{d:"M4.3 9.6h4.6"})]}),"eye-off":O(G0,{children:[z("path",{d:"M6.3 4A6.7 6.7 0 0 1 8 3.5C12 3.5 14.5 8 14.5 8a12 12 0 0 1-2 2.4M4.4 5.3A12 12 0 0 0 1.5 8S4 12.5 8 12.5a6.5 6.5 0 0 0 2.1-.35"}),z("line",{x1:"2.5",y1:"2.5",x2:"13.5",y2:"13.5"})]}),sliders:O(G0,{children:[z("line",{x1:"3",y1:"5",x2:"13",y2:"5"}),z("circle",{cx:"6",cy:"5",r:"1.7",fill:"currentColor"}),z("line",{x1:"3",y1:"11",x2:"13",y2:"11"}),z("circle",{cx:"10",cy:"11",r:"1.7",fill:"currentColor"})]}),code:O(G0,{children:[z("polyline",{points:"6 5 3 8 6 11"}),z("polyline",{points:"10 5 13 8 10 11"})]}),download:O(G0,{children:[z("line",{x1:"8",y1:"2.5",x2:"8",y2:"10"}),z("polyline",{points:"4.5 7 8 10.5 11.5 7"}),z("polyline",{points:"3 12.8 3 13.6 13 13.6 13 12.8"})]}),reload:O(G0,{children:[z("path",{d:"M14 8a6 6 0 1 1-2-4.47L14 5.33"}),z("path",{d:"M14 2v3.33h-3.33"})]}),help:O(G0,{children:[z("circle",{cx:"8",cy:"8",r:"6"}),z("path",{d:"M6.3 6.2a1.8 1.8 0 1 1 2.3 1.9c-.5.2-.6.5-.6 1v.3"}),z("line",{x1:"8",y1:"11.4",x2:"8",y2:"11.5"})]}),image:O(G0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),z("circle",{cx:"6",cy:"6.3",r:"1.1"}),z("path",{d:"M3 12l3-2.8 2.2 1.8 2.4-3L13.5 12"})]}),vector:O(G0,{children:[z("path",{d:"M3.6 11.2C6 5 10 5 12.4 11.2"}),z("rect",{x:"1.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"11.7",y:"9.8",width:"2.6",height:"2.6",rx:"0.4"}),z("rect",{x:"6.7",y:"2.6",width:"2.6",height:"2.6",rx:"0.4"})]}),presentation:O(G0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"7.4",rx:"1"}),z("line",{x1:"8",y1:"10.4",x2:"8",y2:"13"}),z("line",{x1:"5.6",y1:"13.4",x2:"10.4",y2:"13.4"})]}),archive:O(G0,{children:[z("rect",{x:"2.5",y:"3",width:"11",height:"3",rx:"0.8"}),z("path",{d:"M3.6 6v6.2a1 1 0 0 0 1 1h6.8a1 1 0 0 0 1-1V6"}),z("line",{x1:"6.6",y1:"8.8",x2:"9.4",y2:"8.8"})]}),external:O(G0,{children:[z("path",{d:"M11 8.5V12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h3.5"}),z("polyline",{points:"9.5 3 13 3 13 6.5"}),z("line",{x1:"13",y1:"3",x2:"7.6",y2:"8.4"})]}),share:O(G0,{children:[z("circle",{cx:"4",cy:"8",r:"1.9"}),z("circle",{cx:"11.6",cy:"3.6",r:"1.9"}),z("circle",{cx:"11.6",cy:"12.4",r:"1.9"}),z("line",{x1:"5.7",y1:"7",x2:"9.9",y2:"4.6"}),z("line",{x1:"5.7",y1:"9",x2:"9.9",y2:"11.4"})]}),pen:O(G0,{children:[z("path",{d:"M3 13l.8-3L10.6 3.2a1.1 1.1 0 0 1 1.6 0l.6.6a1.1 1.1 0 0 1 0 1.6L6 12.2z"}),z("line",{x1:"9.6",y1:"4.2",x2:"11.8",y2:"6.4"})]}),square:z("rect",{x:"3.5",y:"3.5",width:"9",height:"9",rx:"1"})};function R20({open:X,onClose:J,actions:Q}){let[Y,W]=u.useState(""),[G,Z]=u.useState(0),H=u.useRef(null);u.useEffect(()=>{if(X)W(""),Z(0)},[X]),u.useEffect(()=>{H.current?.querySelector(".st-pal-item.is-active")?.scrollIntoView({block:"nearest"})},[G]);let K=u.useMemo(()=>{let q=Y.trim().toLowerCase();if(!q)return Q;return Q.filter((B)=>B.label.toLowerCase().includes(q)||B.group&&B.group.toLowerCase().includes(q))},[Y,Q]);if(u.useEffect(()=>{if(G>=K.length)Z(0)},[K.length,G]),!X)return null;let U=(q)=>{J(),q.run()};return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(q)=>{if(q.target===q.currentTarget)J()},children:O("div",{className:"st-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[O("div",{className:"st-pal-search",children:[z(E9,{name:"search",size:18}),z("input",{autoFocus:!0,placeholder:"Type a command or search…",value:Y,"aria-label":"Command search",onChange:(q)=>W(q.target.value),onKeyDown:(q)=>{if(q.key==="Escape")q.preventDefault(),J();else if(q.key==="ArrowDown")q.preventDefault(),Z((B)=>Math.min(K.length-1,B+1));else if(q.key==="ArrowUp")q.preventDefault(),Z((B)=>Math.max(0,B-1));else if(q.key==="Enter"){if(q.preventDefault(),K[G])U(K[G])}}}),z(wX,{children:"⌘K"})]}),z("div",{className:"st-pal-list",ref:H,children:K.length===0?z("div",{className:"st-pal-empty",children:"No matching command."}):K.map((q,B)=>{let N=q.group&&(B===0||K[B-1].group!==q.group)?z("div",{className:"st-pal-group",children:q.group},"g-"+q.group):null;return O(G0,{children:[N,O("button",{type:"button",className:"st-pal-item"+(B===G?" is-active":""),onMouseEnter:()=>Z(B),onClick:()=>U(q),children:[z("span",{className:"st-pal-icon",children:z(E9,{name:q.icon,size:15})}),z("span",{className:"st-pal-label",children:q.label}),q.kbd?z("span",{className:"st-pal-kbd",children:z(wX,{children:q.kbd})}):null]})]},q.id)})})]})})}function E9({name:X,size:J=16,className:Q}){return z("svg",{className:Q,width:J,height:J,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:P20[X]})}function T20(X){if(!X||typeof X!=="string")return"?";let J=X.trim().split(/[\s._-]+/).filter(Boolean);if(!J.length)return"?";if(J.length===1)return J[0].slice(0,2).toUpperCase();return((J[0][0]||"")+(J[J.length-1][0]||"")).toUpperCase()||"?"}function B00({initials:X,hue:J,title:Q,pulse:Y}){return z("span",{className:"st-avatar"+(Y?" is-pulsing":""),style:{"--av-hue":J},"data-tip":Q,"aria-label":Q,children:X})}function wX({children:X}){return z("span",{className:"kbd",children:X})}function N00(X,{min:J,max:Q,def:Y}){let W=u.useCallback((K)=>Math.min(Q,Math.max(J,K)),[J,Q]),[G,Z]=u.useState(()=>{try{let K=parseInt(localStorage.getItem(X)||"",10);return Number.isFinite(K)?W(K):Y}catch{return Y}});u.useEffect(()=>{try{localStorage.setItem(X,String(G))}catch{}},[X,G]);let H=u.useCallback((K)=>Z((U)=>W(typeof K==="function"?K(U):K)),[W]);return{w:G,setW:H,min:J,max:Q,def:Y}}function F00({label:X,size:J,onPointerDown:Q,active:Y,dir:W="ltr"}){let{w:G,setW:Z,min:H,max:K,def:U}=J,q=W==="rtl"?-1:1;return z("div",{className:"st-grip"+(Y?" is-active":""),role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":X,"aria-valuemin":H,"aria-valuemax":K,"aria-valuenow":Math.round(G),onPointerDown:Q,onDoubleClick:()=>Z(U),onKeyDown:(B)=>{let N=B.shiftKey?24:8;if(B.key==="ArrowRight")B.preventDefault(),Z((F)=>F+N*q);else if(B.key==="ArrowLeft")B.preventDefault(),Z((F)=>F-N*q);else if(B.key==="Home")B.preventDefault(),Z(H);else if(B.key==="End")B.preventDefault(),Z(K)},children:O("svg",{className:"st-grip-dots",viewBox:"0 0 6 18","aria-hidden":"true",children:[z("circle",{cx:"3",cy:"3",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"9",r:"1.1",fill:"currentColor"}),z("circle",{cx:"3",cy:"15",r:"1.1",fill:"currentColor"})]})})}var QT=[{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}],L00={selection:"Current selection",artboard:"Active artboard","canvas-as-separate":"Canvas · artboards separate","project-raw":"Whole project (raw)"},I20=[{value:1,label:"1× (native)"},{value:2,label:"2× (retina)"},{value:3,label:"3× (max)"}],j3=[{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}],k20="2x",D00=[{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}],C20="auto",$20={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 S20(X){let J=String(X||"").split(".").pop()?.toLowerCase();return $20[J]||"application/octet-stream"}function b20({designRel:X,onPick:J,onClose:Q,multiple:Y=!1,hasArtboardAnchor:W=!1,onPickMany:G}){let[Z,H]=u.useState(null),[K,U]=u.useState(!1),[q,B]=u.useState(null),[N,F]=u.useState(()=>new Set),[D,_]=u.useState({}),[R,w]=u.useState(W?"artboard":"annotation");u.useEffect(()=>{let x=!0;return fetch("/_api/assets").then((m)=>m.json()).then((m)=>{if(!x)return;let p=m.ok?m.assets:[];H(p),_((v)=>{let r={...v};for(let a of p)r[a.path]=a.kind;return r})}).catch(()=>x&&H([])),()=>{x=!1}},[]),u.useEffect(()=>{let x=(m)=>{if(m.key==="Escape")m.stopPropagation(),Q()};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[Q]);let M=Array.from(N).some((x)=>(D[x]||"image")!=="image"),P=!W||M,I=!W?"No artboard on this canvas":M?"Video/audio can only be added as annotations":"";u.useEffect(()=>{if(P&&R==="artboard")w("annotation")},[P,R]);let k=(x)=>{F((m)=>{let p=new Set(m);if(p.has(x))p.delete(x);else p.add(x);return p})},$=async(x)=>{let m=await fetch("/_api/asset",{method:"POST",headers:{"content-type":x.type||"application/octet-stream"},body:x}),p=await m.json().catch(()=>({}));if(m.ok&&p.path)return{ok:!0,path:p.path};return{ok:!1,error:p.error||`upload failed (HTTP ${m.status})`}},C=async(x)=>{if(!x)return;U(!0),B(null);let m=await $(x);if(U(!1),m.ok)J(m.path);else B(m.error)},y=(x)=>{if(typeof x==="string"&&x.startsWith("video/"))return"video";if(typeof x==="string"&&x.startsWith("audio/"))return"audio";return"image"},f=async(x)=>{if(!x.length)return;U(!0),B(null);let m=await Promise.all(x.map((r)=>$(r).then((a)=>({...a,file:r}))));U(!1);let p=m.filter((r)=>r.ok),v=m.length-p.length;if(v>0)B(`${v} of ${m.length} uploads failed`);if(p.length)_((r)=>{let a={...r};for(let c of p)a[c.path]=y(c.file.type);return a}),F((r)=>{let a=new Set(r);for(let c of p)a.add(c.path);return a})},h=async()=>{U(!0),B(null);try{if(Y){let p=(await nf()||[]).map((v)=>new File([new Uint8Array(v.bytes)],v.name,{type:S20(v.name)}));if(U(!1),p.length)await f(p);return}let x=await OZ();if(x?.bytes){await C(new Blob([new Uint8Array(x.bytes)]));return}}catch(x){B(x?.message||"open failed")}U(!1)},d=()=>{if(W9()){h();return}let x=document.createElement("input");if(x.type="file",x.accept="image/*,video/*",Y)x.multiple=!0;x.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(x);let m=()=>{if(x.isConnected)x.remove()};window.addEventListener("focus",()=>setTimeout(m,300),{once:!0}),x.addEventListener("change",()=>{let p=x.files?Array.from(x.files):[];if(m(),!p.length)return;if(Y)f(p);else C(p[0])}),x.click()},n=(x)=>`/${X}/${x}`;return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(x)=>{if(x.target===x.currentTarget)Q()},children:O("div",{className:"st-dialog st-asset-picker",role:"dialog","aria-modal":"true","aria-label":"Choose media",children:[O("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Choose media"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:Q,children:z(E9,{name:"x",size:15})})]}),O("div",{className:"st-dialog-bd",children:[O("div",{className:"st-ap-toolbar",children:[z("button",{type:"button",className:"st-btn",onClick:d,disabled:K,children:K?"Uploading…":"Upload…"}),q&&z("span",{className:"st-ap-err",children:q})]}),z("div",{className:"st-ap-grid",children:Z==null?z("div",{className:"st-ap-empty",children:"Loading…"}):Z.length===0?z("div",{className:"st-ap-empty",children:"No assets yet — upload one."}):Z.map((x)=>{let m=Y&&N.has(x.path);return O("button",{type:"button",className:"st-ap-cell","data-selected":m?"true":void 0,"aria-pressed":Y?m:void 0,title:`${x.name} · ${Math.max(1,Math.round(x.size/1024))} KB`,onClick:()=>Y?k(x.path):J(x.path),children:[Y&&z("span",{className:"st-ap-check","aria-hidden":"true",children:m?z(E9,{name:"check",size:12}):null}),x.kind==="video"?z("video",{className:"st-ap-thumb",src:n(x.path),muted:!0,playsInline:!0}):z("img",{className:"st-ap-thumb",src:n(x.path),alt:x.name,loading:"lazy"}),z("span",{className:"st-ap-name",children:x.name})]},x.path)})})]}),Y&&N.size>0&&O("div",{className:"st-dialog-ft st-ap-confirm",children:[O("span",{className:"st-ap-count",children:[N.size," selected"]}),O("div",{className:"st-ap-seg",role:"radiogroup","aria-label":"Insert as",children:[z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":R==="artboard",disabled:P,onClick:()=>w("artboard"),children:"Add to artboard"}),z("button",{type:"button",className:"st-ap-seg-btn","aria-pressed":R==="annotation",onClick:()=>w("annotation"),children:"Add as annotation"})]}),P&&z("span",{className:"st-ap-dest-note",children:I}),z("span",{className:"st-ap-confirm-spacer"}),z("button",{type:"button",className:"btn btn--ghost",onClick:Q,children:"Cancel"}),z("button",{type:"button",className:"btn btn--primary",onClick:()=>G?.(Array.from(N),R),children:"Insert"})]})]})})}function TF(X,J){let Q=URL.createObjectURL(J),Y=document.createElement("a");Y.href=Q,Y.download=X||"export",document.body.appendChild(Y),Y.click(),Y.remove(),setTimeout(()=>URL.revokeObjectURL(Q),1e4)}function y20({mode:X,initialScope:J,activePath:Q,hasComps:Y=!1,comps:W=[],activeArtboardId:G=null,selection:Z=null,exportLane:H="local",onBrowserCapture:K=null,onClose:U}){let q=u.useCallback((P0)=>H==="none"&&!P0.handoff&&P0.format!=="zip"&&!wS.has(P0.format)||H!=="local"&&P0.format==="canva",[H]),[B,N]=u.useState(X==="handoff"?"shadcn":"png"),[F,D]=u.useState(()=>J&&FS("png",J)?J:yO("png")),[_,R]=u.useState(2),[w,M]=u.useState(k20),[P,I]=u.useState(!0),[k,$]=u.useState(!1),[C,y]=u.useState(!1),[f,h]=u.useState(!1),[d,n]=u.useState(C20),[x,m]=u.useState(!0),[p,v]=u.useState(!1),[r,a]=u.useState(null),[c,U0]=u.useState([]),o=QT.find((P0)=>P0.id===B)||QT[0],Z0=o.handoff?[]:jO(o.format),e=900,N0=3600,K0=GK(W,lA(W,{artboardId:G})),u0=K0?.durationInFrames||0,Q8=K0?.fps||30,o0=o.temporal&&u0>900,_8=o.temporal&&u0>3600;u.useEffect(()=>{if(Z0.length&&!Z0.includes(F))D(yO(o.format))},[Z0,F,o.format]),u.useEffect(()=>{if(H!=="remote")return;fetch("/_api/export-warmup").catch(()=>{})},[H]);let A0=u.useCallback(()=>{fetch("/_api/export-history").then((P0)=>P0.json()).then((P0)=>U0(Array.isArray(P0?.history)?P0.history.slice(0,6):[])).catch(()=>{})},[]);u.useEffect(()=>{A0()},[A0]),u.useEffect(()=>{function P0(K8){if(K8.key==="Escape")K8.preventDefault(),U()}return window.addEventListener("keydown",P0),()=>window.removeEventListener("keydown",P0)},[U]);async function r0(){if(o.handoff){let D8=`/design:handoff ${Q&&Q!==c8?Q:"<canvas>.tsx"}`;try{await navigator.clipboard?.writeText(D8)}catch{}a({ok:!0,msg:`Copied: ${D8} — run it in Claude Code.`});return}if(q(o)){a({ok:!1,msg:"This format needs the render service, which this workspace doesn’t have configured."});return}v(!0),a(null);let P0=o.temporal?{scale:_}:{};if(o.format==="png"){let F8=j3.find((D8)=>D8.id===w)||j3[1];if(F8.kind==="dpi")P0.dpi=F8.value;else P0.scale=F8.value}if(o.format==="mp4"||o.format==="webm")P0.audio=x;if(_8)P0.maxFrames=u0;if(o.format==="pdf"){P0.pdfPrint={includeBleed:P,marks:{crop:C,registration:f}};let F8=D00.find((D8)=>D8.id===d)?.value;if(F8!==void 0)P0.dpi=F8}if(G)P0.artboardId=G;if(Z?.selector)P0.selection=Z;if(Q&&Q!==c8)P0.canvasFile=Q;if(zU.has(o.format)&&O2({exportLane:H,format:o.format,scope:F,artboardId:P0.artboardId})&&typeof K==="function")try{let F8=mO(P0);a({ok:!0,msg:"Capturing…"});let D8=await K({format:o.format,artboardIds:[P0.artboardId],scale:F8,onProgress:(A8,i8)=>a({ok:!0,msg:`Capturing ${A8}/${i8}…`})}),W8=await gO(D8,o.format);for(let A8 of W8)TF(A8.name,A8.blob);for(let A8 of W8)await uO({format:o.format,scope:F,filename:A8.name});v(!1),a({ok:!0,msg:`Saved ${W8.map((A8)=>A8.name).join(", ")} to your downloads.`});return}catch(F8){if(H!=="remote"){a({ok:!1,msg:`Capture failed: ${F8&&F8.message||F8}`}),v(!1);return}}if(O2({exportLane:H,format:o.format,scope:F})&&o.format==="pptx"&&typeof K==="function")try{a({ok:!0,msg:"Capturing artboards…"});let F8=Q&&Q!==c8?JH(Q).replace(/\.[^.]+$/,""):"export",{filename:D8,blob:W8}=await hO({capture:K,name:F8,onProgress:(A8,i8)=>a({ok:!0,msg:`Capturing ${A8}/${i8}…`}),onAssemble:()=>a({ok:!0,msg:"Assembling deck…"})});TF(D8,W8),await uO({format:o.format,scope:F,filename:D8}),v(!1),a({ok:!0,msg:`Saved ${D8} to your downloads.`});return}catch(F8){if(H!=="remote"){a({ok:!1,msg:`Deck export failed: ${F8&&F8.message||F8}`}),v(!1);return}}if(H==="none"&&zU.has(o.format)){a({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."}),v(!1);return}try{let F8=await fetch("/_api/export-jobs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({format:o.format,scope:F,options:P0})});if(!F8.ok){a({ok:!1,msg:await F8.text()||`Export failed (${F8.status})`}),v(!1);return}U()}catch(F8){a({ok:!1,msg:F8&&F8.message?F8.message:String(F8)}),v(!1)}}return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(P0)=>{if(P0.target===P0.currentTarget)U()},children:O("div",{className:"st-dialog",role:"dialog","aria-modal":"true","aria-label":"Export and handoff",children:[O("div",{className:"st-dialog-hd",children:[z("span",{className:"st-dialog-title",children:"Export & handoff"}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close",onClick:U,children:z(E9,{name:"x",size:15})})]}),O("div",{className:"st-dialog-bd",children:[z("div",{className:"st-rp-hd",children:Q&&Q!==c8?`Format · ${pW(JH(Q))}`:"Format"}),z("div",{className:"st-fmt-grid",children:QT.filter((P0)=>!P0.temporal||Y).map((P0)=>O("button",{type:"button","data-testid":`export-format-${P0.id}`,className:"st-fmt"+(P0.id===B?" is-on":""),disabled:q(P0),title:q(P0)?"Needs the render service — not configured on this workspace":void 0,onClick:()=>{N(P0.id),a(null)},children:[z(E9,{name:P0.icon,size:16}),z("span",{className:"st-fmt-name",children:P0.label}),z("span",{className:"st-fmt-sub",children:P0.sub})]},P0.id))}),H==="none"&&O("div",{className:"st-dialog-note","data-testid":"export-lane-note",children:["PNG and SVG of the active artboard — and the PPTX deck — export right here in your browser; ZIP and AI handoff work too. PDF, video and other multi-artboard exports need the render service, which this workspace doesn't have configured — use the desktop app, or ask your admin to add the ",z("code",{children:" maude-render"})," service (see the self-hosting docs)."]}),!o.handoff&&O("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-scope",children:"Scope"}),z("select",{id:"st-export-scope","data-testid":"export-scope",className:"st-select",value:F,onChange:(P0)=>D(P0.target.value),children:Z0.map((P0)=>z("option",{value:P0,children:L00[P0]},P0))})]}),!o.handoff&&o.format==="png"&&O("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-size",children:"Resolution"}),z("select",{id:"st-export-size",className:"st-select",value:w,onChange:(P0)=>M(P0.target.value),children:j3.map((P0)=>z("option",{value:P0.id,children:P0.label},P0.id))})]}),!o.handoff&&o.format==="png"&&z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:(()=>{let P0=j3.find((F8)=>F8.id===w)||j3[1],K8=P0.kind==="dpi"?P0.value/96:P0.value;return`${P0.label} ≈ ${Math.round(1440*K8)}×${Math.round(900*K8)} for a 1440×900 artboard.`})()}),!o.handoff&&o.temporal&&O("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-temporal-size",children:"Resolution"}),z("select",{id:"st-export-temporal-size",className:"st-select",value:_,onChange:(P0)=>R(Number(P0.target.value)),children:I20.map((P0)=>z("option",{value:P0.value,children:P0.label},P0.value))})]}),!o.handoff&&o.temporal&&O("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:[_,"× the artboard's native resolution (e.g. 960×540 → ",960*_,"×",540*_,")."]}),o0&&O("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: ",u0," frames (≈",Math.round(u0/Q8),"s).",_8?` Exceeds the default ${"3600"}-frame export cap — exporting raises the cap to the full length for this run.`:""," ","If the fast renderer falls back to frame-by-frame capture this can take several minutes; 2× resolution (≈720–1080p) is recommended for memory headroom."]}),!o.handoff&&o.format==="pdf"&&O(G0,{children:[O("div",{className:"st-dialog-row",children:[z("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-dpi",children:"Image quality"}),z("select",{id:"st-export-pdf-dpi",className:"st-select",value:d,onChange:(P0)=>n(P0.target.value),children:D00.map((P0)=>z("option",{value:P0.id,children:P0.label},P0.id))})]}),z("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:"The page stays vector; this only sets the capture density for raster content on it (dropped photos, large-format art)."}),z("div",{className:"st-dialog-row",children:O("label",{className:"st-dialog-lbl",htmlFor:"st-export-pdf-bleed",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-pdf-bleed",type:"checkbox",checked:P,onChange:(P0)=>I(P0.target.checked)}),"Include bleed"]})}),z("div",{className:"st-dialog-row",children:O("button",{type:"button",className:"st-dialog-lbl",style:{background:"none",border:0,padding:0,cursor:"pointer"},onClick:()=>$((P0)=>!P0),"aria-expanded":k,children:[k?"▾":"▸"," Marks"]})}),k&&O("div",{style:{padding:"0 12px 4px",display:"flex",flexDirection:"column",gap:6},children:[O("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:C,onChange:(P0)=>y(P0.target.checked)}),"Crop marks"]}),O("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12},children:[z("input",{type:"checkbox",checked:f,onChange:(P0)=>h(P0.target.checked)}),"Registration marks"]})]}),O("div",{className:"st-mono",style:{fontSize:11,color:"var(--fg-3)"},children:["Bleed and marks apply to print (",z("code",{children:'kind="print"'}),") artboards only.",F==="canvas-as-separate"?" One PDF page per artboard.":""]})]}),!o.handoff&&(o.format==="mp4"||o.format==="webm")&&z("div",{className:"st-dialog-row",children:O("label",{className:"st-dialog-lbl",htmlFor:"st-export-audio",style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[z("input",{id:"st-export-audio",type:"checkbox",checked:x,onChange:(P0)=>m(P0.target.checked)}),"Export with audio"]})}),o.handoff&&O("div",{className:"callout callout--info",style:{fontSize:12},children:["Hands the active canvas off to production. Copies"," ",z("span",{className:"st-mono",children:"/design:handoff <path>"})," — run it in Claude Code to emit a ready-to-drop production component next to the canvas."]}),r&&z("div",{className:"callout "+(r.ok?"callout--success":"callout--error"),style:{fontSize:12},"data-testid":"export-status","data-ok":r.ok?"1":"0",children:r.msg}),c.length>0&&O("div",{className:"st-export-recent","data-testid":"export-recent",children:[z("div",{className:"st-rp-hd",children:"Recent"}),c.map((P0,K8)=>O("div",{className:"st-export-recent-row",children:[O("span",{children:[String(P0.format||"").toUpperCase()," ·"," ",L00[P0.scope]||P0.scope]}),z("span",{className:"st-mono",children:P0.filename})]},K8))]})]}),O("div",{className:"st-dialog-ft",children:[z("button",{type:"button",className:"btn btn--ghost",onClick:U,children:"Cancel"}),O("button",{type:"button",className:"btn btn--primary","data-testid":"export-submit",disabled:p,onClick:r0,children:[z(E9,{name:"download",size:14}),o.handoff?"Copy handoff command":p?"Exporting…":`Export ${o.label}`]})]})]})})}var CF=12,$F=16;function j20({name:X,depth:J,defaultOpen:Q,children:Y,dirPath:W,drag:G,menu:Z}){let[H,K]=u.useState(Q),U=G?G.dropProps(W,!0,()=>K(!0)):{},q=G?.overDir===W,B=G?G.dragProps(W,!0):{},N=G?.draggedPath===W,F=G?.busyPath===W,D=O("button",{type:"button",role:"treeitem","data-testid":`tree-folder-${PF(W)}`,"aria-expanded":H,"aria-dropeffect":G?"move":void 0,"aria-busy":F||void 0,tabIndex:-1,className:"st-row"+(q?" is-drop-target":"")+(N?" is-dragging":"")+(F?" is-busy":""),style:{paddingLeft:CF+J*$F+"px"},onClick:()=>K((_)=>!_),onContextMenu:Z?(_)=>Z.openAt(_,{kind:"dir",dirPath:W}):void 0,...B,...U,children:[z("span",{className:"st-row-glyph",children:z(E9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:X})]});return O(G0,{children:[Z?O("div",{className:"st-row-wrap",role:"none",children:[D,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${PF(W)}`,title:`Folder actions — ${X}`,"aria-label":`Folder actions for ${X}`,"aria-haspopup":"menu",onClick:(_)=>Z.openAt(_,{kind:"dir",dirPath:W}),children:z(RF,{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})})]}):D,H&&Y]})}function v20({name:X,dsName:J,depth:Q,defaultOpen:Y,active:W,onOpenSystem:G,children:Z}){let[H,K]=u.useState(Y);return O(G0,{children:[O("div",{className:"st-row st-ds-folder"+(W?" is-sel":""),style:{paddingLeft:CF+Q*$F+"px"},role:"treeitem","aria-expanded":H,children:[z("button",{type:"button",className:"st-ds-chev",onClick:()=>K((U)=>!U),"aria-label":H?"Collapse design system":"Expand design system",title:H?"Collapse":"Expand",children:z(E9,{name:"chevron-right",className:"st-chev"+(H?" is-open":""),size:13})}),O("button",{type:"button",className:"st-ds-open",onClick:()=>G(J),"aria-label":`Open ${J} design system view`,title:"Open the design system view",children:[z("span",{className:"st-row-glyph",children:z(E9,{name:"folder",size:13})}),z("span",{className:"st-row-name",children:X})]})]}),H&&Z]})}function IF({file:X,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,onDelete:G,openCount:Z,depth:H,kind:K,sidecar:U,dirty:q,experimentalKind:B,drag:N,menu:F}){let D=X.path===J||X.path===Q,_=GQ.test(X.name),R=!_&&K!=="runtime"?ZT(X.name):null,w=!_&&!R,M=_?pW(X.name):X.name,P=_&&typeof G==="function"&&K!=="runtime",I=_&&!U&&K!=="runtime"&&typeof N<"u",k=I?N.dragProps(X.path,!0):{},$=N?.draggedPath===X.path,C=N?.busyPath===X.path,y=I&&typeof F<"u",f=X.path.split("/").slice(0,-1).join("/"),h=_?"canvas-row-"+X.path.replace(/^\.[^/]+\//,"").replace(GQ,"").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""):void 0,d=O("button",{type:"button",role:"treeitem","data-testid":h,"aria-selected":D,"aria-disabled":w?"true":void 0,"aria-busy":C||void 0,tabIndex:D?0:-1,className:"st-row"+(D?" is-sel":"")+(K==="runtime"?" is-muted":"")+($?" is-dragging":"")+(C?" is-busy":""),style:{paddingLeft:CF+H*$F+"px"},title:X.path+(Z?` — ${Z} open`:w?" (file index only)":""),onClick:()=>{if(_)Y(X.path);else if(R)W?.(X.path)},onContextMenu:y?(n)=>F.openAt(n,{kind:"file",path:X.path,dir:f}):void 0,...k,children:[z("span",{className:"st-row-glyph",children:z(E9,{name:"file",size:13})}),z("span",{className:"st-row-name",children:M}),B==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),B==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),q&&z("span",{className:"st-git-badge","data-kind":q,title:`Unsaved (${q})`,"aria-label":`Unsaved, ${q}`,children:q}),Z>0&&z("span",{className:"st-row-badge",children:Z})]});if(!P&&!y)return d;return O("div",{className:"st-row-wrap",role:"none",children:[d,y&&z("button",{type:"button",className:"st-row-menu-btn"+(P?" has-delete-sibling":""),"data-testid":`tree-row-menu-${PF(X.path)}`,title:`Move ${M}…`,"aria-label":`Actions for ${M}`,"aria-haspopup":"menu",onClick:(n)=>F.openAt(n,{kind:"file",path:X.path,dir:f}),children:z(RF,{d:"M12 6a1 1 0 100-2 1 1 0 000 2zM12 13a1 1 0 100-2 1 1 0 000 2zM12 20a1 1 0 100-2 1 1 0 000 2z",size:12})}),P&&z("button",{type:"button",className:"st-row-del",title:`Delete ${M}`,"aria-label":`Delete canvas ${M}`,onClick:(n)=>{n.stopPropagation(),G(X.path,M)},children:z(RF,{d:"M3 6h18 M8 6V4h8v2 M6 6l1 14h10l1-14 M10 11v6 M14 11v6",size:12})})]})}function f20({primary:X,sidecars:J,depth:Q,kind:Y,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,showHidden:q,forceOpen:B,dirtyByPath:N,experimentalKind:F,drag:D,menu:_}){let R=N?.get(X.path),w=J.length>0,[M,P]=u.useState(!1),I=B||M,k=X.path===W;if(!(w&&q))return z(IF,{file:X,activePath:W,previewPath:G,onOpen:Z,onPreview:H,onDelete:K,openCount:U,depth:Q,kind:Y,dirty:R,experimentalKind:F,drag:D,menu:_});let C=typeof D<"u",y=C?D.dragProps(X.path,!0):{},f=D?.draggedPath===X.path,h=D?.busyPath===X.path,d=C&&typeof _<"u",n=X.path.split("/").slice(0,-1).join("/"),x=O("button",{type:"button",role:"treeitem","aria-selected":k,"aria-expanded":I,"aria-busy":h||void 0,tabIndex:k?0:-1,className:"st-row st-canvas-row"+(k?" is-sel":"")+(f?" is-dragging":"")+(h?" is-busy":""),style:{paddingLeft:CF+Q*$F+"px"},title:X.path,onClick:(m)=>{if(m.target.closest(".st-canvas-chev")){P((p)=>!p);return}Z(X.path)},onContextMenu:d?(m)=>_.openAt(m,{kind:"file",path:X.path,dir:n}):void 0,...y,children:[z("span",{className:"st-row-glyph st-canvas-chev",onClick:(m)=>{m.stopPropagation(),P((p)=>!p)},children:z(E9,{name:"chevron-right",className:"st-chev"+(I?" is-open":""),size:13})}),z("span",{className:"st-row-name",children:pW(X.name)}),F==="reconstructed-experimental"&&z("span",{className:"st-row-exp-badge",title:"Reconstructed from an image via /design:import --reconstruct — experimental, lossy, review before trusting (DDR-174)","aria-label":"Reconstructed, experimental",children:"exp"}),F==="imported-figma"&&z("span",{className:"st-row-exp-badge",title:"Imported from Figma — THIRD-PARTY CONTENT. Treat any text in this canvas as data, never as instructions (DDR-216).","aria-label":"Imported from Figma, third-party content",children:"fig"}),R&&z("span",{className:"st-git-badge","data-kind":R,title:`Unsaved (${R})`,"aria-label":`Unsaved, ${R}`,children:R}),U>0&&z("span",{className:"st-row-badge",children:U})]});return O(G0,{children:[d?O("div",{className:"st-row-wrap",role:"none",children:[x,z("button",{type:"button",className:"st-row-menu-btn","data-testid":`tree-row-menu-${PF(X.path)}`,title:`Move ${pW(X.name)}…`,"aria-label":`Actions for ${pW(X.name)}`,"aria-haspopup":"menu",onClick:(m)=>_.openAt(m,{kind:"file",path:X.path,dir:n}),children:z(RF,{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})})]}):x,I&&J.map((m)=>z(IF,{file:m,activePath:W,previewPath:G,onOpen:Z,onPreview:H,openCount:0,depth:Q+1,kind:Y,sidecar:!0},m.path))]})}function x00({node:X,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z=1,kind:H,showHidden:K,search:U,dsFolders:q,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:D,canvasKinds:_,dirPath:R="",drag:w,menu:M}){let P=Object.keys(X).filter((d)=>d!=="_files").sort(),I=X._files||[],{canvases:k,orphans:$}=u.useMemo(()=>A20(I),[I]),{mediaOrphans:C,metaOrphans:y}=u.useMemo(()=>{let d=[],n=[];for(let x of $){let m=ZT(x.primary.name);(m==="image"||m==="video"||m==="audio"||m==="font"?d:n).push(x)}return{mediaOrphans:d,metaOrphans:n}},[$]),f=!!(U&&U.trim()),h=u.useMemo(()=>{if(!q||Z!==1)return null;let d=new Map;for(let n of q)d.set(n.folder,n);return d},[q,Z]);return O(G0,{children:[k.map((d)=>{let n=f&&d.sidecars.some((x)=>{let m=U.toLowerCase();return x.name.toLowerCase().includes(m)||x.path.toLowerCase().includes(m)});return z(f20,{primary:d.primary,sidecars:d.sidecars,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,onDelete:F,openCount:wF(G[d.primary.path]),depth:Z,kind:H,showHidden:K,forceOpen:n,dirtyByPath:D,experimentalKind:_?.[d.primary.path],drag:w,menu:M},d.primary.path)}),C.map((d)=>z(IF,{file:d.primary,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,openCount:wF(G[d.primary.path]),depth:Z,kind:H},d.primary.path)),K&&y.map((d)=>z(IF,{file:d.primary,activePath:J,previewPath:Q,onOpen:Y,onPreview:W,openCount:wF(G[d.primary.path]),depth:Z,kind:H},d.primary.path)),P.map((d)=>{let n=h?.get(d),x=R?`${R}/${d}`:d,m=z(x00,{node:X[d],activePath:J,previewPath:Q,onOpen:Y,onPreview:W,commentsByFile:G,depth:Z+1,kind:H,showHidden:K,search:U,activeDsName:B,onOpenSystem:N,onDelete:F,dirtyByPath:D,canvasKinds:_,dirPath:x,drag:w,menu:M});if(n&&N)return z(v20,{name:d,dsName:n.name,depth:Z,defaultOpen:!0,active:J===c8&&n.name===B,onOpenSystem:N,children:m},d);return z(j20,{name:d,depth:Z,defaultOpen:!0,dirPath:x,drag:w,menu:M,children:m},d)})]})}var _F={project:{title:"PROJECT",pillFromCount:!1},ds:{title:"DESIGN SYSTEM",pillFromDsCount:!0},canvas:{title:"UI CANVASES",pillFromCount:!0},runtime:{title:"RUNTIME · GITIGNORED",pillFromCount:!0}};function x20(X){if(X.kind==="project")return _F.project;if(X.kind==="runtime")return _F.runtime;if(X.label==="Design system")return _F.ds;if(X.label==="UI kit")return _F.canvas;return{title:X.label.toUpperCase(),pillFromCount:!0}}function h20({readOnly:X=!1,cloud:J,groups:Q,activePath:Y,previewPath:W,activeDsName:G,onOpen:Z,onPreview:H,onOpenSystem:K,wsConnected:U,search:q,setSearch:B,commentsByFile:N,showHidden:F,sectionsExpanded:D,onToggleSection:_,onNewBoard:R,onDeleteBoard:w,onRefresh:M,refreshing:P,collapsed:I,onCollapse:k,width:$,resizing:C,dirtyByPath:y,project:f,gitBranch:h,remoteSync:d,onGetLatest:n,canvasKinds:x,onMoveCanvas:m,onNewFolder:p,onDeleteFolder:v,syncStatus:r,onLinkedHub:a,savingIsManaged:c=!1}){let U0=u.useMemo(()=>{if(!q)return Q;return Q.map((i0)=>({...i0,tree:v00(i0.tree,q),filtered:!!q}))},[Q,q]),o=TS(m),Z0=PS(),e=u.useMemo(()=>{let i0=[];for(let j0 of Q){if(j0.label==="Design system"||j0.kind!=="canvas")continue;let I0=j0.fullPath.replace(/^\.[^/]+\//,"")||j0.fullPath;i0.push({path:j0.fullPath,label:I0});for(let T8 of j0.dirs||[])i0.push({path:T8,label:T8.replace(/^\.[^/]+\//,"")})}return i0},[Q]),N0=Z0.state?.extra,K0=N0?.kind==="file"?[{id:"move-to",label:"Move to…",onSelect:()=>Z0.showMoveTo()}]:N0?.kind==="dir"?[{id:"new-folder-here",label:"New folder here",onSelect:()=>{Z0.close();let i0=window.prompt("New folder name:");if(i0?.trim())p(N0.dirPath,i0.trim())}},{id:"delete-folder",label:"Delete folder",destructive:!0,onSelect:()=>{Z0.close(),v(N0.dirPath,N0.dirPath.split("/").pop())}}]:[],u0=N0?.kind==="file"?e.filter((i0)=>i0.path!==N0.dir):[],[Q8,o0]=u.useState(!1),[_8,A0]=u.useState("board"),[r0,P0]=u.useState(""),[K8,F8]=u.useState(""),[D8,W8]=u.useState(!1),A8=u.useMemo(()=>Q.find((i0)=>i0.kind==="canvas"&&i0.label!=="Design system")?.fullPath,[Q]),i8=u.useCallback(async()=>{let i0=r0.trim();if(!i0||D8)return;if(W8(!0),F8(""),_8==="folder"){if(!A8){W8(!1),F8("no canvas group to create a folder in");return}let I0=await p(A8,i0);if(W8(!1),I0?.ok)o0(!1),P0("");else F8(I0?.error||"could not create folder");return}let j0=await R(i0);if(W8(!1),j0?.ok)o0(!1),P0("");else F8(j0?.error||"could not create board")},[r0,D8,R,p,_8,A8]),P9=u.useMemo(()=>{let i0=0;for(let j0 of Q)for(let I0 of j0.paths||[])if(GQ.test(I0))i0++;return i0},[Q]),l0=u.useMemo(()=>{let i0=0;for(let j0 of U0)for(let I0 of j0.paths||[])if(GQ.test(I0))i0++;return i0},[U0]);return O("nav",{className:"st-sidebar"+(I?" is-collapsed":"")+(C?" is-resizing":""),style:I||!$?void 0:{width:$,flexBasis:$},"aria-label":"Files","data-tour":"sidebar",children:[O("div",{className:"st-sb-hd",children:[z("span",{className:"st-sb-title",children:"Files"}),O("div",{className:"st-sb-hd-actions",children:[!X&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New blank brief board","aria-label":"New blank brief board","aria-expanded":Q8&&_8==="board",onClick:()=>{F8(""),A0("board"),o0((i0)=>_8==="board"?!i0:!0)},children:z(E9,{name:"plus",size:15})}),!X&&A8&&z("button",{type:"button",className:"st-iconbtn","data-tip":"New folder","aria-label":"New folder","data-testid":"tree-new-folder","aria-expanded":Q8&&_8==="folder",onClick:()=>{F8(""),A0("folder"),o0((i0)=>_8==="folder"?!i0:!0)},children:z(E9,{name:"folder-plus",size:15})}),M&&z("button",{type:"button",className:"st-iconbtn st-refresh"+(P?" is-spinning":""),"data-tip":"Refresh files · ⇧⌘R","aria-label":"Refresh files","aria-busy":P||void 0,disabled:P,onClick:()=>M(),children:z(E9,{name:"reload",size:15})}),O("span",{className:"st-live","data-tip":U?"live · file index synced":"reconnecting…",children:[z("span",{className:"st-live-dot"+(U?" is-connected":""),"aria-hidden":"true"}),l0," / ",P9]}),k&&z("button",{type:"button",className:"st-iconbtn","aria-label":"Collapse sidebar","data-tip":"Collapse sidebar · T",onClick:k,children:z(E9,{name:"panel-left",size:15})})]})]}),Q8?O("div",{className:"st-newboard",children:[z("input",{type:"text",autoFocus:!0,placeholder:_8==="folder"?"folder name…":"brief board name…",value:r0,maxLength:60,disabled:D8,"aria-label":_8==="folder"?"New folder name":"New brief board name",onChange:(i0)=>P0(i0.target.value),onKeyDown:(i0)=>{if(i0.key==="Enter")i0.preventDefault(),i8();else if(i0.key==="Escape")i0.preventDefault(),o0(!1),P0(""),F8("")}}),z("button",{type:"button",className:"st-newboard-go",disabled:D8||!r0.trim(),"data-tip":"Create · Enter","aria-label":_8==="folder"?"Create folder":"Create brief board",onClick:i8,children:D8?"…":"↵"})]}):null,K8?z("div",{className:"st-newboard-err",role:"alert",children:K8}):null,z("div",{className:"st-search",children:O("div",{className:"st-search-box",children:[z(E9,{name:"search",size:13}),z("input",{type:"search","data-testid":"canvas-search",placeholder:"Search canvases…",value:q,onChange:(i0)=>B(i0.target.value),onKeyDown:(i0)=>{if(i0.key==="Escape")if(i0.preventDefault(),q)B("");else i0.currentTarget.blur()},"aria-label":"Filter files"}),q?z("button",{className:"st-search-clear",onClick:()=>B(""),"data-tip":"Clear · Esc","aria-label":"Clear search",children:"×"}):z(wX,{children:"/"})]})}),z("div",{className:"st-tree",role:"tree","aria-label":"Project file tree","data-testid":"canvas-list",children:U0.map((i0)=>{if(!F&&!q&&i0.kind==="runtime")return null;let j0=x20(i0),I0=(i0.paths||[]).filter((d0)=>GQ.test(d0)).length,T8=j0.pill||(j0.pillFromDsCount?String(i0.dsFolders?.length||0):null)||(j0.pillFromCount?String(I0||i0.paths?.length||0):null),Z8=i0.tree&&Object.keys(i0.tree).length>0,z0=i0.label==="Design system",f0=i0.kind==="project";if(!F&&!q&&f0&&I0===0)return null;let L8=O20(i0),n8=D[i0.label],k8=!!q||(n8===void 0?L8:n8),q8=!z0&&i0.kind==="canvas"&&!X,w0=q8?o.dropProps(i0.fullPath,!0):{},L0=o.overDir===i0.fullPath;return O("div",{className:"st-tree-section",children:[O("button",{type:"button",className:"st-tree-sec-hd"+(L0?" is-drop-target":""),onClick:()=>_(i0.label,L8),"aria-expanded":k8,"aria-dropeffect":q8?"move":void 0,title:k8?"Collapse section":"Expand section",...w0,children:[z(E9,{name:"chevron-right",className:"st-chev"+(k8?" is-open":""),size:13}),z("span",{className:"st-sec-name",children:j0.title}),T8&&z("span",{className:"st-pill",children:T8})]}),k8&&(Z8?z(x00,{node:i0.tree,activePath:Y,previewPath:W,onOpen:Z,onPreview:H,commentsByFile:N,depth:1,kind:i0.kind,showHidden:F,search:q,dsFolders:i0.dsFolders,activeDsName:G,onOpenSystem:z0?K:void 0,onDelete:z0||X?void 0:w,dirtyByPath:y,canvasKinds:x,dirPath:i0.fullPath,drag:!z0&&i0.kind==="canvas"&&!X?o:void 0,menu:!z0&&i0.kind==="canvas"&&!X?Z0:void 0}):z("div",{className:"st-tree-empty",children:q?"No matches.":"Empty."}))]},i0.label)})}),z(RS,{state:Z0.state,onClose:Z0.close,rootItems:K0,destinations:u0,onPickDestination:(i0)=>m(N0.path,i0)}),!c&&z(Ww,{project:f,liveBranch:h,remoteSync:d,onGetLatest:n}),J===null?z(kA,{syncStatus:r,onLinkedHub:a}):null,z($A,{})]})}function g20({shown:X,onExpand:J,onSearch:Q}){return z("div",{className:"st-rail"+(X?" is-shown":""),children:O("div",{className:"st-rail-inner",children:[z("button",{type:"button",className:"st-iconbtn","aria-label":"Expand sidebar",title:"Expand sidebar (T)",onClick:J,children:z(E9,{name:"panel-left",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Search",title:"Search (/)",onClick:Q,children:z(E9,{name:"search",size:15})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Files",title:"Files",onClick:J,children:z(E9,{name:"folder",size:15})})]})})}function m20({open:X,onClose:J,onStartTour:Q}){if(u.useEffect(()=>{if(!X)return;function Y(W){if(W.key==="Escape")J()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[X,J]),!X)return null;return z("div",{className:"help-modal-backdrop",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:O("div",{className:"help-modal",role:"dialog","aria-modal":"true","aria-labelledby":"help-modal-title",children:[O("header",{className:"help-modal-hd",children:[z("span",{className:"title",id:"help-modal-title",children:"Help · shortcuts & commands"}),O("span",{className:"sku",children:["MAUDE-DEV-SRV / v",HT]}),Q&&z("button",{type:"button",className:"mdcc-tour__back",style:{marginLeft:"auto"},onClick:Q,children:"▶ Take the tour"}),z("button",{type:"button",className:"help-modal-close","aria-label":"Close (Esc)",onClick:J,children:"×"})]}),O("div",{className:"help-modal-body",children:[O("details",{open:!0,children:[z("summary",{children:"Canvas selection & tools"}),O("ul",{children:[O("li",{children:[z("kbd",{children:"V"})," ",z("span",{children:"move tool — Cmd+click to select, Cmd+Shift to multi"})]}),O("li",{children:[z("kbd",{children:"H"})," ",z("span",{children:"hand tool — bare drag pans (no Space needed)"})]}),O("li",{children:[z("kbd",{children:"C"})," ",z("span",{children:"comment tool — hover paints, click drops a pin"})]}),O("li",{children:[z("kbd",{children:"⌘"})," + hover ",z("span",{children:"preview deepest element under cursor"})]}),O("li",{children:[z("kbd",{children:"⌘"})," + click ",z("span",{children:"select that element (replace)"})]}),O("li",{children:[z("kbd",{children:"⌘⇧"})," + click ",z("span",{children:"add deepest to selection (multi)"})]}),O("li",{children:["right-click ",z("span",{children:"context menu (Copy CSS / Fit / Reset...)"})]}),O("li",{children:[z("kbd",{children:"Esc"})," in canvas ",z("span",{children:"clear selection + close menu"})]})]})]}),O("details",{children:[z("summary",{children:"Annotation tools"}),O("ul",{children:[O("li",{children:[z("kbd",{children:"B"})," ",z("span",{children:"pen — freehand stroke"})]}),O("li",{children:[z("kbd",{children:"R"})," ",z("span",{children:"rectangle — drag to define corners"})]}),O("li",{children:[z("kbd",{children:"O"})," ",z("span",{children:"ellipse — drag from center outward"})]}),O("li",{children:[z("kbd",{children:"A"})," ",z("span",{children:"arrow — drag tail → tip"})]}),O("li",{children:[z("kbd",{children:"E"})," ",z("span",{children:"eraser — click or drag over strokes to remove"})]}),O("li",{children:[z("kbd",{children:"V"})," + click stroke ",z("span",{children:"select annotation (Shift+click to multi)"})]}),O("li",{children:[z("kbd",{children:"V"})," + drag empty ",z("span",{children:"marquee-select strokes that overlap"})]}),O("li",{children:["double-click rect/ellipse ",z("span",{children:"add text inside the shape"})]}),O("li",{children:["arrow keys ",z("span",{children:"nudge selected annotation 1 unit (Shift = 10)"})]}),O("li",{children:[z("kbd",{children:"Backspace"})," ",z("span",{children:"delete selected annotations"})]}),O("li",{children:[z("kbd",{children:"⇧P"})," ",z("span",{children:"presentation — hide annotations for clean screenshot"})]})]})]}),O("details",{children:[z("summary",{children:"Canvas & panels"}),O("ul",{children:[O("li",{children:["click in tree ",z("span",{children:"open canvas (replaces the active one)"})]}),O("li",{children:["File ▸ Close canvas ",z("span",{children:"clear the stage"})]}),O("li",{children:[z("kbd",{children:"⌘R"})," ",z("span",{children:"reload canvas"})]}),O("li",{children:[z("kbd",{children:"/"})," ",z("span",{children:"focus search"})]}),O("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"comments panel"})]}),O("li",{children:[z("kbd",{children:"⌘⇧I"})," ",z("span",{children:"inspector"})]}),O("li",{children:[z("kbd",{children:"?"})," ",z("span",{children:"keyboard-shortcuts cheat sheet"})]})]})]}),O("details",{children:[z("summary",{children:"Slash commands"}),O("ul",{className:"cmds",children:[O("li",{children:[O("code",{children:['/design:edit "',z("i",{children:"feedback"}),'"']}),z("span",{children:"edit + 4-iter multi-axis loop"})]}),O("li",{children:[O("code",{children:['/design:edit "',z("i",{children:"…"}),'" --perfect']}),z("span",{children:"8-iter polish (4.5/5 aspiration)"})]}),O("li",{children:[O("code",{children:['/design:edit "',z("i",{children:"…"}),'" --no-critic']}),z("span",{children:"raw edit, skip loop"})]}),O("li",{children:[O("code",{children:['/design:edit "',z("i",{children:"…"}),'" --opt-out=',z("i",{children:"scope"})]}),z("span",{children:"override DS scope (palette/aesthetic/full)"})]}),O("li",{children:[O("code",{children:['/design:new "',z("i",{children:"Name"}),'" "',z("i",{children:"brief"}),'"']}),z("span",{children:"scaffold canvas"})]}),O("li",{children:[O("code",{children:['/design:new "',z("i",{children:"…"}),'" --opt-out=aesthetic']}),z("span",{children:"scaffold off-system canvas (gradients/radii/type free)"})]}),O("li",{children:[z("code",{children:"/design:critic"}),z("span",{children:"review panel (routed)"})]}),O("li",{children:[z("code",{children:"/design:critic --all"}),z("span",{children:"10-critic sweep"})]}),O("li",{children:[z("code",{children:"/design:critic --agent signature-moment-critic"}),z("span",{children:"aspiration axis only"})]}),O("li",{children:[z("code",{children:"/design:rollback"}),z("span",{children:"undo last edit"})]}),O("li",{children:[z("code",{children:"/design:screenshot"}),z("span",{children:"capture canvas"})]}),O("li",{children:[z("code",{children:"/design:setup-docs"}),z("span",{children:"refresh README + INDEX"})]}),O("li",{children:[z("code",{children:"/design:handoff"}),z("span",{children:"migrate to apps/"})]})]})]}),O("details",{children:[z("summary",{children:"Opt-out scope"}),O("ul",{children:[O("li",{children:[z("strong",{children:"palette"})," ",z("span",{children:"default — tokens + rootClass kept; local namespace overrides colors only. DS aesthetic still enforced."})]}),O("li",{children:[z("strong",{children:"aesthetic"})," ",z("span",{children:"palette + gradients/off-ladder radii/alt type/decorative SVG flags allowed."})]}),O("li",{children:[z("strong",{children:"full"})," ",z("span",{children:"DS treated as advisory. Type/radii/aesthetic up to canvas."})]}),O("li",{children:[z("em",{children:"A11y enforced at every scope"})," ",z("span",{children:"contrast, focus, semantics, motion, touch targets — never relaxed."})]}),O("li",{children:["Persisted on canvas's ",z("code",{children:".meta.json"})," ",z("code",{children:"opt_out_scope"})," field — subsequent ",z("code",{children:"/design:edit"})," iterations inherit."]}),z("li",{children:'Inferred from brief ("modern", "vibrant", "off-system") with one-shot AskUserQuestion before iter-1 critics fire.'})]})]}),O("details",{children:[z("summary",{children:"Auto-critic loop"}),O("ul",{children:[O("li",{children:[z("strong",{children:"Default"})," ",z("span",{children:"4 iter · aspiration ≥ 4.0 · stable-but-bland exit"})]}),O("li",{children:[z("strong",{children:"--perfect"})," ",z("span",{children:"8 iter · aspiration ≥ 4.5 · broader divergence tolerance"})]}),O("li",{children:[z("strong",{children:"--perfect --all"})," ",z("span",{children:"every critic incl. aspiration · portfolio-grade"})]}),O("li",{children:["Exit: ",z("code",{children:"solid"})," · ",z("code",{children:"stable-but-bland"})," · ",z("code",{children:"max-reached"})," ","· ",z("code",{children:"divergent"})]}),O("li",{children:[z("em",{children:"stable-but-bland"})," = correctness clean, aspiration plateau — surface for review with lowest 2 axes named"]}),O("li",{children:["When ",z("code",{children:"opt_out_scope ∈ {aesthetic, full}"}),": iter-1 checkpoint fires — pick (a) run loop, (b) skip auto-loop and review iter 1, (c) a11y-only check."]})]})]}),O("details",{children:[z("summary",{children:"Pin-to-element flow"}),O("ol",{children:[z("li",{children:"Open a canvas"}),O("li",{children:[z("kbd",{children:"⌘"}),"+click element"]}),z("li",{children:"Status bar shows ● selector"}),O("li",{children:["Run"," ",O("code",{children:['/design:edit "',z("i",{children:"change just this"}),'"']})]}),O("li",{children:["Reload iframe (",z("kbd",{children:"⌘R"}),")"]})]})]}),O("details",{children:[z("summary",{children:"Comments"}),O("ol",{children:[O("li",{children:[z("kbd",{children:"⌘"}),"+click element, then ",z("kbd",{children:"⌘C"})," ",z("span",{children:"or ⌘⇧+click"})]}),z("li",{children:"Numbered pin appears on canvas"}),O("li",{children:[z("kbd",{children:"⌘⇧M"})," ",z("span",{children:"opens panel — All / Open / Resolved"})]}),O("li",{children:["Click row in panel ",z("span",{children:"jumps to that file + pin"})]}),O("li",{children:["Claude reads ",z("code",{children:"_comments/<slug>.json"})," on next ",z("code",{children:"/design"})]})]})]})]})]})})}var YT=[{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 u20({kbd:X,alt:J}){let Q=(Y,W)=>z("span",{className:"so-combo",children:Y.split(" ").map((G,Z)=>z(wX,{children:G},`${G}-${Z}`))},W);return O("span",{className:"so-combos",children:[Q(X,"main"),J?J.split(" / ").map((Y)=>O(G0,{children:[z("span",{className:"so-or",children:"/"}),Q(Y,Y)]},Y)):null]})}function l20({open:X,onClose:J}){if(u.useEffect(()=>{if(!X)return;function Y(W){if(W.key==="Escape")W.preventDefault(),J()}return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[X,J]),!X)return null;let Q=YT.reduce((Y,W)=>Y+W.items.length,0);return z("div",{className:"st-scrim",role:"presentation",onMouseDown:(Y)=>{if(Y.target===Y.currentTarget)J()},children:O("div",{className:"so-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",children:[O("div",{className:"so-overlay-hd",children:[z("span",{className:"so-title",children:"Keyboard shortcuts"}),O("span",{className:"so-trigger",children:["press ",z(wX,{children:"?"})," to open"]})]}),z("div",{className:"so-columns",children:YT.map((Y)=>O("section",{className:"so-section so-section--"+Y.id,children:[z("h3",{className:"so-section-hd",children:Y.label}),z("dl",{className:"so-list",children:Y.items.map((W)=>O("div",{className:"so-pair",children:[z("dt",{children:W.label}),z("dd",{children:z(u20,{kbd:W.kbd,alt:W.alt})})]},W.label))})]},Y.id))}),O("div",{className:"so-overlay-ft",children:[O("span",{children:["close with ",z(wX,{children:"Esc"})]}),O("span",{className:"so-count",children:[Q," bindings · ",YT.length," groups"]})]})]})})}var p20=["File","Edit","View","Selection","Tools","Help"];function h00(X){u.useEffect(()=>{function J(Y){if(Y.key==="Escape")X()}function Q(Y){if(!Y.target.closest(".st-dropdown, .st-menu"))X()}return window.addEventListener("keydown",J),window.addEventListener("mousedown",Q),()=>{window.removeEventListener("keydown",J),window.removeEventListener("mousedown",Q)}},[X])}function d20({panels:X,onToggle:J,onClose:Q,onZoom:Y,hasCanvas:W}){return h00(Q),O("div",{className:"st-dropdown",role:"menu","aria-label":"View",style:{left:152},children:[z("div",{className:"st-dd-hd",children:"Panels"}),X.map((G)=>O("button",{type:"button",role:"menuitem",className:"st-dd-item"+(G.checked?" is-on":""),"aria-disabled":G.disabled?"true":void 0,title:G.hint||void 0,onClick:()=>{if(G.disabled){if(G.href)window.open(G.href,"_blank","noopener,noreferrer"),Q();return}J(G.id),Q()},children:[O("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check",children:G.checked?z(E9,{name:"check",size:13}):null}),z("span",{children:G.label}),G.phase?z("span",{className:"st-dd-phase",children:G.phase}):null]}),G.shortcut?z(wX,{children:G.shortcut}):null]},G.id)),z("div",{className:"st-dd-sep"}),z("div",{className:"st-dd-hd",children:"Zoom"}),[{op:"in",label:"Zoom In",shortcut:"⌘ +"},{op:"out",label:"Zoom Out",shortcut:"⌘ −"},{op:"fit",label:"Fit to Screen",shortcut:"⌘ 0"},{op:"actual",label:"Actual Size · 100 %",shortcut:"⌘ 1"}].map((G)=>O("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":W?void 0:"true",onClick:()=>{if(!W)return;Y?.(G.op),Q()},children:[O("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:G.label})]}),z(wX,{children:G.shortcut})]},G.label))]})}function yK({label:X,left:J,header:Q,items:Y,onAction:W,onClose:G}){return h00(G),O("div",{className:"st-dropdown",role:"menu","aria-label":X,style:{left:J},children:[Q?z("div",{className:"st-dd-hd",children:Q}):null,Y.map((Z,H)=>Z.sep?z("div",{className:"st-dd-sep"},"s"+H):O("button",{type:"button",role:"menuitem",className:"st-dd-item","aria-disabled":Z.disabled?"true":void 0,onClick:()=>{if(Z.disabled)return;W(Z.id),G()},children:[O("span",{className:"st-dd-lead",children:[z("span",{className:"st-dd-check"}),z("span",{children:Z.label})]}),Z.shortcut?z(wX,{children:Z.shortcut}):null]},Z.id))]})}function c20({onAction:X,onClose:J}){return z(yK,{label:"Help",left:320,onAction:X,onClose:J,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"},...W9()?[{id:"collab-tour",label:"How sharing works"}]:[],...W9()?[{id:"quick-setup",label:"Quick setup"}]:[],...W9()?[{id:"readiness",label:"Check AI editing readiness…"}]:[],{id:"whatsnew",label:"What's new"}]})}function i20({onAction:X,onClose:J,readOnly:Q=!1}){return z(yK,{label:"Selection",left:214,onAction:X,onClose:J,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},...Q?[]:[{id:"select-all-annotations",label:"Select all annotations",shortcut:"⌘ ⇧ A"}]]})}function o20({onAction:X,onClose:J,readOnly:Q=!1}){let Y=[{id:"browse",label:"Browse (interact)",shortcut:""},{id:"move",label:"Select",shortcut:"V"},{id:"hand",label:"Hand",shortcut:"H"},...Q?[]:[{id:"comment",label:"Comment",shortcut:"C"},{id:"pen",label:"Pen",shortcut:"B"},{id:"rect",label:"Rect",shortcut:"R"},{id:"ellipse",label:"Ellipse",shortcut:"O"},{id:"sticky",label:"Sticky",shortcut:"N"},{id:"arrow",label:"Arrow",shortcut:"A"},{id:"text",label:"Text",shortcut:"T"},{id:"eraser",label:"Eraser",shortcut:"E"}]];return z(yK,{label:"Tools",left:290,header:"Tool palette",onAction:X,onClose:J,items:Y})}function n20({onAction:X,onClose:J,hasCanvas:Q,readOnly:Y=!1}){return z(yK,{label:"File",left:40,onAction:X,onClose:J,items:Y?[{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!Q},{id:"close",label:"Close canvas",disabled:!Q}]:[{id:"new",label:"New canvas…",shortcut:"N"},{id:"assemble",label:"Assemble dropped clips → video",disabled:!Q},{id:"export",label:"Export…",shortcut:"⇧⌘E"},{id:"handoff",label:"Handoff to production",shortcut:"⇧⌘H"},{sep:!0},{id:"generate",label:"Generate with AI…"},{id:"settings",label:"Settings…",shortcut:"⌘,"},{sep:!0},{id:"reload",label:"Reload canvas",shortcut:"⌘R",disabled:!Q},{id:"close",label:"Close canvas",disabled:!Q}]})}function r20({onAction:X,onClose:J,hasCanvas:Q,readOnly:Y=!1}){if(Y)return z(yK,{label:"Edit",left:90,onAction:X,onClose:J,items:[{id:"deselect-all",label:"Deselect all",shortcut:"Esc"}]});return z(yK,{label:"Edit",left:90,onAction:X,onClose:J,items:[{id:"undo",label:"Undo",shortcut:"⌘Z"},{id:"redo",label:"Redo",shortcut:"⇧⌘Z"},{sep:!0},{id:"deselect-all",label:"Deselect all",shortcut:"Esc"},{id:"select-all-annotations",label:"Select all annotations",shortcut:"⇧⌘A"},...Q?[{sep:!0},{id:"new-artboard:desktop",label:"New artboard: Desktop"},{id:"new-artboard:laptop",label:"New artboard: Laptop"},{id:"new-artboard:tablet",label:"New artboard: Tablet"},{id:"new-artboard:mobile",label:"New artboard: Mobile"},{id:"new-artboard:print-a4",label:"New artboard: A4 (print)"},{id:"new-artboard:print-letter",label:"New artboard: Letter (print)"}]:[]]})}function a20({activePath:X,project:J,cloud:Q,tabsCount:Y,openMenu:W,setOpenMenu:G,commentsPanelOpen:Z,onToggleComments:H,changesOpen:K,changesCount:U,onToggleChanges:q,onOpenSystem:B,sidebarOpen:N,onToggleSidebar:F,showHidden:D,onToggleShowHidden:_,onOpenHelp:R,onOpenShortcuts:w,onReportBug:M,onStartTour:P,onStartCollabTour:I,annotationsVisible:k,onToggleAnnotations:$,minimapVisible:C,onToggleMinimap:y,zoomCtlVisible:f,onToggleZoomCtl:h,presentMode:d,onTogglePresent:n,printGuidesVisible:x,onTogglePrintGuides:m,postToActiveCanvas:p,onOpenWhatsNew:v,onOpenReadiness:r,onOpenQuickSetup:a,onWatchIntro:c,whatsNewCount:U0,exportCenter:o,artboardCount:Z0=0,presence:e=null,inspectorOpen:N0,inspectorTab:K0,onToggleInspector:u0,autoOpenInspector:Q8,onToggleAutoOpenInspector:o0,onOpenLayers:_8,timelineOpen:A0,onToggleTimeline:r0,hasComps:P0=!1,assistantOpen:K8,onToggleAssistant:F8,assistantBusy:D8,assistantUnseen:W8,onNewCanvas:A8,onAssembleVideo:i8,onOpenExport:P9,onOpenSettings:l0,onOpenGenerate:i0,onReload:j0,onCloseCanvas:I0,onInsertArtboard:T8,readOnly:Z8=!1}){let z0=X===c8,f0=z0?"SYSTEM":X?"CANVAS":"IDLE",L8=z0?z("b",{children:"design system"}):X?O(G0,{children:[X.split("/").slice(0,-1).join("/"),"/",z("b",{children:pW(JH(X))})]}):z("span",{style:{color:"var(--u-fg-3)"},children:"no canvas open"}),n8=new Set(Q?["autoopen"]:["assistant","autoopen"]),k8=[{id:"tree",label:"Project Tree",shortcut:"T",checked:N,disabled:!1},{id:"changes",label:Q?"History":U>0?`Changes · ${U} unsaved`:"Changes",shortcut:"⌘ ⇧ G",checked:K,disabled:!1},{id:"comments",label:"Comments Sidebar",shortcut:"⌘ ⇧ M",checked:Z,disabled:!1},{id:"hidden",label:"Show hidden files",shortcut:"H",checked:D,disabled:!1},{id:"layers",label:"Layers",shortcut:"",checked:N0&&K0==="layers",disabled:!1},{id:"inspector",label:"Inspector",shortcut:"⌘ ⇧ I",checked:N0,disabled:!1},{id:"autoopen",label:"Auto-open Inspector on select",shortcut:"",checked:!!Q8,disabled:!1},{id:"timeline",label:"Timeline",shortcut:"⌘ ⇧ T",phase:P0?"video":void 0,checked:A0,disabled:!1},...W9()?[{id:"assistant",label:"Assistant",shortcut:"⌘ ⇧ A",checked:K8,disabled:!1}]:Q?[{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:k,disabled:!1},{id:"minimap",label:"Minimap",shortcut:"",checked:C,disabled:!X||z0},{id:"zoomctl",label:"Zoom controls",shortcut:"",checked:f,disabled:!X||z0},{id:"present",label:"Presentation Mode",shortcut:"",checked:d,disabled:!X||z0},{id:"print-guides",label:"Show print guides",shortcut:"",checked:x,disabled:!X||z0}].filter((L0)=>!Z8||!n8.has(L0.id)),q8=["file","edit","view","selection","tools","help"];function w0(L0){if(q8.includes(L0))G(W===L0?null:L0)}return u.useEffect(()=>{if(!W||!q8.includes(W))return;let L0=setTimeout(()=>{document.querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')?.focus()},0);function d0(V8){let O8=[...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')];if(!O8.length)return;let a8=O8.indexOf(document.activeElement);if(V8.key==="ArrowDown")V8.preventDefault(),O8[(a8+1)%O8.length].focus();else if(V8.key==="ArrowUp")V8.preventDefault(),O8[(a8-1+O8.length)%O8.length].focus();else if(V8.key==="Home")V8.preventDefault(),O8[0].focus();else if(V8.key==="End")V8.preventDefault(),O8[O8.length-1].focus();else if(V8.key==="ArrowRight"||V8.key==="ArrowLeft"){V8.preventDefault();let E8=V8.key==="ArrowRight"?1:-1,N9=q8.indexOf(W);G(q8[(N9+E8+q8.length)%q8.length])}else if(V8.key==="Escape")document.querySelector('.st-menu[aria-expanded="true"]')?.focus()}return window.addEventListener("keydown",d0),()=>{clearTimeout(L0),window.removeEventListener("keydown",d0)}},[W,G]),O("header",{className:"st-menubar",role:"menubar","aria-label":"Application menubar","data-testid":"menubar",children:[O("span",{className:"st-brand","data-tour":"brand",children:[z("span",{className:"st-brand-mark",children:z("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),z("span",{className:"st-brand-name",children:"maude"})]}),Q?O("span",{className:"st-cloudback","data-testid":"cloud-back",children:[Q.dashboardUrl?z("a",{className:"st-cloudback-link",href:Q.dashboardUrl,title:"Back to your projects",children:"← Dashboard"}):null,Q.projectName?z("span",{className:"st-cloudback-project","data-testid":"cloud-project-name",children:Q.projectName}):null]}):null,z("nav",{className:"st-menus","aria-label":"Application menus","data-tour":"menus",children:p20.map((L0)=>{let d0=L0.toLowerCase(),V8=q8.includes(d0),O8=V8||d0==="help";return z("button",{type:"button",className:"st-menu",role:"menuitem","data-tour":d0==="help"?"help":void 0,"aria-haspopup":V8?"menu":void 0,"aria-expanded":V8?W===d0:void 0,onClick:()=>w0(d0),onMouseEnter:()=>{if(W!==null&&V8)G(d0)},children:L0},d0)})}),W==="file"&&z(n20,{readOnly:Z8,hasCanvas:!!X,onAction:(L0)=>{if(L0==="new")A8?.();else if(L0==="assemble")i8?.();else if(L0==="export")P9?.("export");else if(L0==="handoff")P9?.("handoff");else if(L0==="generate")i0?.();else if(L0==="settings")l0?.();else if(L0==="reload")j0?.();else if(L0==="close")I0?.()},onClose:()=>G(null)}),W==="edit"&&z(r20,{readOnly:Z8,hasCanvas:!!X&&!z0,onAction:(L0)=>{if(L0==="undo")p({dgn:"undo"});else if(L0==="redo")p({dgn:"redo"});else if(L0==="deselect-all")p({dgn:"selection-clear"});else if(L0==="select-all-annotations")p({dgn:"annotation-select-all"});else if(L0.startsWith("new-artboard:"))T8?.(L0.slice(13))},onClose:()=>G(null)}),W==="view"&&z(d20,{panels:k8,onToggle:(L0)=>{if(L0==="tree")F();else if(L0==="changes")q();else if(L0==="comments")H();else if(L0==="hidden")_();else if(L0==="annotate")$();else if(L0==="inspector")u0();else if(L0==="autoopen")o0?.();else if(L0==="timeline")r0?.();else if(L0==="assistant")F8?.();else if(L0==="layers")_8?.();else if(L0==="minimap")y?.();else if(L0==="zoomctl")h?.();else if(L0==="present")n?.();else if(L0==="print-guides")m?.()},onZoom:(L0)=>p({dgn:"zoom",op:L0}),hasCanvas:!!X&&!z0,onClose:()=>G(null)}),W==="selection"&&z(i20,{readOnly:Z8,onAction:(L0)=>{if(L0==="deselect-all")p({dgn:"selection-clear"});else if(L0==="select-all-annotations")p({dgn:"annotation-select-all"})},onClose:()=>G(null)}),W==="tools"&&z(o20,{readOnly:Z8,onAction:(L0)=>p({dgn:"tool-set",tool:L0}),onClose:()=>G(null)}),W==="help"&&z(c20,{onAction:(L0)=>{if(L0==="shortcuts")w?.();else if(L0==="help")R?.();else if(L0==="report-bug")M?.();else if(L0==="tour")P?.();else if(L0==="collab-tour")I?.();else if(L0==="quick-setup")a?.();else if(L0==="readiness")r?.();else if(L0==="whatsnew")v?.();else if(L0==="watch-intro")c?.()},onClose:()=>G(null)}),O("div",{className:"st-mb-right","data-tour":"status",children:[e?z("div",{className:"st-presence",children:e}):null,Z8&&z("span",{className:"st-stamp st-stamp--viewonly","data-testid":"view-only-stamp","data-tip":Q?.user?`${Q.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"}),Q?.user?O("span",{className:"st-cloudwho","data-testid":"cloud-account",children:[z("span",{className:"st-cloudwho-email",title:Q.role?`Signed in as ${Q.user} — ${Q.role}`:Q.user,children:Q.user}),z("form",{method:"post",action:"/auth/browser/signout",className:"st-cloudwho-form",children:z("button",{type:"submit",className:"st-cloudwho-out","data-testid":"cloud-signout",title:"Sign out of this project",children:"Sign out"})})]}):null,W9()&&!Z8&&z("button",{type:"button",className:"st-assistant","data-testid":"assistant-toggle","data-active":K8?"true":"false","data-busy":D8?"true":"false","data-unseen":W8?"true":"false","aria-label":`Assistant${D8?" — working":W8?" — new reply":""}`,"data-tip":"Assistant ⌘⇧A",onClick:F8,children:z(E9,{name:"sparkle",size:15})}),o&&z(Ch,{center:o}),z("button",{type:"button",className:"st-reportbug","data-testid":"report-bug-toggle","aria-label":"Report a bug","data-tip":"Report a bug",onClick:M,children:z(E9,{name:"bug",size:15})}),z("button",{type:"button",className:"st-whatsnew","data-tour":"whatsnew","data-unseen":U0>0?"true":"false","aria-label":`What's new${U0>0?` — ${U0} unseen`:""}`,"data-tip":"What's new",onClick:v,children:z(E9,{name:"megaphone",size:15})}),z("span",{className:"st-stamp",children:f0}),z("span",{className:"st-mb-file",title:X||"",children:L8}),z("span",{className:"st-mb-sep"}),O("span",{className:"st-mb-count","data-tip":"Artboards in the open canvas",children:[z("span",{className:"st-dot",style:{background:"var(--accent)"}}),Z0," ARTBOARDS"]}),z("span",{className:"st-mb-sep"}),z("span",{className:"st-mb-proj",children:J||"maude"})]})]})}function s20({tabs:X,activePath:J,registerIframe:Q,systemData:Y,onOpenFromSystem:W,onSelectDs:G,project:Z,cfg:H,loadingPath:K,onIframeLoad:U,showQuickSetup:q,onStartQuickSetup:B,previewPath:N}){let F=u.useRef(null);return u.useEffect(()=>{if(N)F.current?.focus()},[N]),O("div",{className:"viewport st-stage","data-tour":"viewport",children:[N&&z("div",{ref:F,className:"st-file-preview-overlay",role:"region","aria-label":`Preview: ${sB(JH(N))}`,tabIndex:0,children:z(mx,{path:N,kind:ZT(JH(N))})}),X.length===0&&!N&&O("div",{className:"st-empty",children:[O("div",{className:"st-empty-brand",children:[z("span",{className:"st-brand-mark",children:z("svg",{viewBox:"0 0 32 32",width:"100%",height:"100%",fill:"none","aria-hidden":"true",children:z("path",{d:"M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z",fill:"currentColor"})})}),z("span",{className:"st-empty-wm",children:"maude"}),O("span",{className:"st-empty-sub st-mono",children:["CANVAS · ",(Z||"MAUDE").toUpperCase()," / v",HT," / localhost:",typeof window<"u"?window.location.port:"4399"]})]}),z("div",{className:"st-empty-title",children:"Nothing open yet"}),O("div",{className:"st-empty-body",children:["← Pick a screen from the list on the left, or open ",z("strong",{children:"Design system"})," above it to see your colors, type, and components.",z("br",{}),z("br",{}),z("strong",{children:"To select something on the canvas:"})," hold ",z(wX,{children:"⌘"})," and hover to preview an element, click to select it — ",z(wX,{children:"⌘⇧"}),"+click selects more than one. Right-click for more options.",W9()?O(G0,{children:[z("br",{}),z("br",{}),"Claude can see whatever's selected when you ask for a change in the Assistant panel, so pointing is often faster than describing it."]}):null]}),q&&z("button",{type:"button","data-testid":"st-empty-start-quick-setup",className:"btn btn--primary st-empty-quick-setup",onClick:B,children:"Start quick setup"})]}),X.map((D)=>{if(D.path===c8)return z("div",{className:"system-view"+(D.path===J?" active":""),children:z(GB0,{data:Y,onOpen:W,cfg:H,onSelectDs:G})},D.path);return z("iframe",{ref:(_)=>Q(D.path,_),src:Iz(D.path,H),className:D.path===J?"active":"","data-path":D.path,"data-testid":D.path===J?"canvas-frame":void 0,onLoad:()=>U?.(D.path),...H?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin",allow:"clipboard-write"}:{}},D.path)}),K&&K===J&&z("div",{className:"st-canvas-loading","aria-hidden":"true",children:O("div",{className:"st-skel-card",children:[z("div",{className:"st-skel-cap st-mono",children:"compiling canvas…"}),z("span",{className:"skel st-skel-thumb"}),z("span",{className:"skel st-skel-line",style:{width:"72%"}}),z("span",{className:"skel st-skel-line",style:{width:"46%"}})]})})]})}var t20=["color","space","radius","shadow","leading","weight","motion","font","other"],e20={color:"colors",space:"spacing",radius:"radii",shadow:"shadows",leading:"leading",weight:"weights",motion:"motion",font:"font stacks",other:"other"};function XB0(X){return X==="color"}function JB0({tokens:X,tokenGroups:J,tokensPath:Q}){if(!X||X.length===0)return O("section",{className:"sv-section sv-section-tokens",children:[O("h2",{children:["tokens",z("span",{className:"sv-h-num",children:"0"})]}),z("div",{className:"sv-empty",children:O("p",{children:["No tokens parsed from"," ",Q?z("code",{children:Q}):"the configured tokens file",". Does the file exist and contain CSS custom properties (",z("code",{children:"--name: value;"}),")?"]})})]});let Y=J||{},W=Array.from(new Set([...t20,...Object.keys(Y)])).filter((G)=>Y[G]?.length);return z(G0,{children:W.map((G)=>{let Z=Y[G],H=XB0(G);return O("section",{className:"sv-section sv-section-tokens sv-section-"+G,children:[O("h2",{children:["tokens · ",e20[G]||G,z("span",{className:"sv-h-num",children:Z.length})]}),z("div",{className:"sv-tokens-ladder",children:Z.map((K)=>O("div",{className:"sv-tok-cell",children:[H?z("div",{className:"sv-tok-swatch",style:{background:K.value}}):null,O("div",{className:"sv-tok-meta",children:[z("code",{className:"sv-tok-name",children:K.name}),z("span",{className:"sv-tok-value",children:K.value||"—"})]})]},K.name+"|"+K.value))})]},G)})})}function QB0(X,J){let Q=X.name.match(/^--(?:type|fs|text)-(.+)$/);if(!Q)return null;let Y=Q[1];return(J||[]).find((W)=>/^--(?:lh|leading|line-height)-/.test(W.name)&&W.name.endsWith("-"+Y))?.value??null}function YB0(X){if(!X?.length)return;let J=["body","sans","display","text","family"];for(let Q of J){let Y=X.find((W)=>W.name.includes(Q));if(Y)return Y.value}return X[0].value}function WB0({tokenGroups:X}){let J=X?.fontsize||[];if(J.length===0)return null;let Q=X?.leading||[],Y=YB0(X?.font);return O("section",{className:"sv-section sv-section-type",children:[O("h2",{children:["type · ladder",z("span",{className:"sv-h-num",children:J.length})]}),z("div",{className:"sv-type-list",children:J.map((W)=>{let G=QB0(W,Q),Z={fontSize:W.value};if(G)Z.lineHeight=G;if(Y)Z.fontFamily=Y;return O("div",{className:"sv-type-row",children:[z("code",{className:"sv-type-tok",children:W.name}),z("span",{className:"sv-type-sample",style:Z,children:"The catalog is the system."})]},W.name)})})]})}function GB0({data:X,onOpen:J,cfg:Q,onSelectDs:Y}){if(!X)return z("div",{className:"sv-empty",children:z("p",{children:"Loading design system…"})});let{previewGallery:W,uiKitsGallery:G,systemDir:Z,tokens:H,tokenGroups:K,tokensPath:U,ds:q,availableDesignSystems:B}=X,N=(!W||!W.length)&&(!G||!G.length),F=Array.isArray(B)&&B.length>1,D=q?.name??B?.[0]?.name??"";return O("div",{className:"sv",children:[O("header",{className:"sv-header",children:[z("span",{className:"sv-sku",children:"MAUDE-DSN/01"}),z("span",{className:"sv-title",children:"design system view"}),F?O("label",{className:"sv-ds-picker",children:[z("span",{className:"sv-ds-picker-label",children:"DS"}),z("select",{value:D,onChange:(_)=>Y&&Y(_.target.value),children:B.map((_)=>z("option",{value:_.name,children:_.name},_.name))})]}):null,z("span",{className:"sv-loc",children:z("code",{children:Z})})]}),q?.description?z("p",{className:"sv-ds-description",children:q.description}):null,z(JB0,{tokens:H,tokenGroups:K,tokensPath:U}),z(WB0,{tokenGroups:K}),N?z("div",{className:"sv-empty",children:O("p",{children:["No ",z("code",{children:"preview/"})," or ",z("code",{children:"ui_kits/"})," folders found under"," ",z("code",{children:Z}),"."]})}):O(G0,{children:[z(O00,{title:"preview",items:W,onOpen:J,kind:"preview",cfg:Q}),z(O00,{title:"ui kits",items:G,onOpen:J,kind:"ui_kits",cfg:Q})]})]})}function O00({title:X,items:J,onOpen:Q,kind:Y,cfg:W}){if(!J||J.length===0)return null;return O("section",{className:"sv-section",children:[O("h2",{children:[X," ",z("span",{className:"sv-count",children:J.length})]}),z("div",{className:"sv-previews sv-previews-"+Y,children:J.map((G)=>O("article",{className:"sv-preview-card",onClick:()=>Q(G.path),children:[z("div",{className:"sv-preview-frame",children:z("iframe",{src:Iz(G.path,W,{thumbnail:!0}),title:G.label,scrolling:"no",...W?.canvasOrigin?{sandbox:"allow-scripts allow-same-origin"}:{}})}),O("div",{className:"sv-preview-foot",children:[z("strong",{children:G.label}),z("code",{children:G.path})]})]},G.path))})]})}function ZB0({activePath:X,selected:J,wsConnected:Q,openCount:Y,theme:W,onToggleTheme:G,onClearSelected:Z,syncStatus:H,syncProject:K,syncOpen:U=!1,onOpenSync:q,changesCount:B=0,unpushed:N=0,savingIsManaged:F=!1,changesOpen:D=!1,onOpenChanges:_,version:R}){let w=X===c8,M=J&&J.selector?J.selector+(J.text?` — "${J.text.slice(0,60)}"`:""):"",P=J&&J.dom_path?J.dom_path.join(" > "):J?J.selector:"",I=W==="dark"?"light":"dark",k=(()=>{let C=Tz(H,{project:K});if(!C)return null;let y=C.names.length?` (${C.names.join(", ")})`:"";return{online:C.online,label:C.label,title:`${C.title}${y}${C.next?` — ${C.next}`:""}`}})(),$=k&&O(G0,{children:[z("span",{className:"st-sb-sync-dot"+(k.online?" is-online":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:"hub sync"}),z("span",{className:"val",title:k.title,children:k.label})]});return O("footer",{className:"st-statusbar",role:"contentinfo","data-testid":"statusbar",children:[O("span",{className:"st-sb-slot st-sb-active",role:"group","aria-label":"Active file",children:[z("span",{className:"lead","aria-hidden":"true"}),z("span",{className:"lbl",children:"active"}),z("span",{className:"val",title:X||"",children:w?"▦ design system":X||"—"})]}),X&&J&&J.selector&&!w&&O("span",{className:"st-sb-slot st-sb-sel",role:"group","aria-label":"Selected element",children:[z("span",{className:"lbl",children:"selected"}),z("span",{className:"val",title:P,children:M}),z("button",{type:"button",className:"st-sb-sel-clear",onClick:Z,"data-tip":"Clear · Esc inside iframe","data-tip-pos":"top","aria-label":"Clear selection",children:"×"})]}),O("span",{className:"st-sb-slot",role:"group","aria-label":"Open comments",children:[z("span",{className:"lbl",children:"comments"}),O("span",{className:"val",children:[Y," open"]})]}),_&&O("button",{type:"button",className:"st-sb-slot st-sb-changes"+(D?" is-open":"")+(B>0?" has-changes":N>0?" has-unpushed":""),onClick:_,"data-testid":"open-changes","data-tip":"Open Changes · ⌘⇧G","data-tip-pos":"top","aria-label":"Open Changes panel","aria-pressed":D,children:[z("span",{className:"st-sb-changes-dot","aria-hidden":"true"}),z("span",{className:"lbl",children:"changes"}),z("span",{className:"val",children:F?"cloud saving":B>0?`${B} unsaved`:N>0?`${N} to publish`:"all saved"})]}),z("span",{className:"st-sb-spacer"}),O("span",{className:"st-sb-slot",role:"group","aria-label":"Connection",children:[z("span",{className:"st-live-dot"+(Q?" is-connected":""),"aria-hidden":"true"}),z("span",{className:"lbl",children:Q?"live":"reconnecting"})]}),k&&(q?z("button",{type:"button",className:"st-sb-slot st-sb-sync st-sb-sync--btn"+(U?" is-open":""),onClick:q,"data-testid":"open-sync","data-tip":"Open Sync panel","data-tip-pos":"top","aria-label":"Open Sync panel","aria-pressed":U,children:$}):z("span",{className:"st-sb-slot st-sb-sync",role:"group","aria-label":"Hub sync",children:$})),R&&z("span",{className:"st-sb-slot st-sb-version",role:"group","aria-label":"Maude version",children:O("span",{className:"val","data-testid":"statusbar-version",children:["v",R]})}),O("button",{type:"button",className:"st-sb-theme",onClick:G,"data-tip":`Switch to ${I} theme`,"data-tip-pos":"top","aria-label":`Switch to ${I} theme`,children:[z(E9,{name:W==="dark"?"sun":"moon",size:13}),I]})]})}function HB0({commentsByFile:X,filter:J,setFilter:Q,activePath:Y,focusedId:W,onJump:G,onResolve:Z,onReopen:H,onDelete:K,width:U,resizing:q}){let B=f00(X),N=Object.keys(X||{}).sort(),F=[];for(let D of N){let _=X[D]||[],R=_.filter((M)=>{if(J==="open")return M.status!=="resolved";if(J==="resolved")return M.status==="resolved";return!0});if(R.length===0)continue;let w=_.filter((M)=>M.selector);F.push({file:D,comments:R.map((M)=>({...M,n:w.findIndex((P)=>P.id===M.id)+1}))})}return O("aside",{className:"st-rpanel"+(q?" is-resizing":""),style:U?{width:U,flexBasis:U}:void 0,"aria-label":"Comments",children:[z("div",{className:"st-rp-tabs st-rp-tabs--filters",children:O("div",{className:"st-cm-filters",role:"tablist",children:[O("button",{type:"button",className:"st-cm-filter"+(J==="all"?" is-active":""),role:"tab","aria-selected":J==="all",onClick:()=>Q("all"),children:["All · ",B.all]}),O("button",{type:"button",className:"st-cm-filter"+(J==="open"?" is-active":""),role:"tab","aria-selected":J==="open",onClick:()=>Q("open"),children:["Open · ",B.open]}),O("button",{type:"button",className:"st-cm-filter"+(J==="resolved"?" is-active":""),role:"tab","aria-selected":J==="resolved",onClick:()=>Q("resolved"),children:["Resolved · ",B.resolved]})]})}),z("div",{className:"st-rp-body",style:{gap:"var(--space-4)"},children:F.length===0?O("div",{className:"st-rp-empty",children:[O("p",{children:["No comments ",J!=="all"?`with status “${J}”`:"yet","."]}),O("p",{children:["Open a canvas, hold ",z(wX,{children:"⌘"})," and click an element, then press ",z(wX,{children:"C"})," — or hold ",z(wX,{children:"⌘⇧"})," and click directly."]})]}):F.map((D)=>O(G0,{children:[O("button",{type:"button",className:"st-cm-group-hd",onClick:()=>G(D.file,null),title:D.file,children:[z("span",{children:pW(JH(D.file))}),z("span",{className:"st-mono",children:D.comments.length})]}),D.comments.map((_)=>O("div",{className:"st-comment"+(_.status==="resolved"?" is-resolved":"")+(_.id===W?" is-active":""),onClick:()=>G(D.file,_.id),children:[O("div",{className:"st-comment-hd",children:[z("span",{className:"st-pin st-pin--inline",children:_.n||"·"}),z("span",{className:"st-comment-time",children:E20(_.created)})]}),z("div",{className:"st-comment-txt",children:_.text}),O("div",{className:"st-comment-foot",children:[z("span",{className:"st-comment-sel",title:(_.dom_path||[]).join(" > "),children:_.selector||"—"}),Z&&H&&K?O("span",{className:"st-mini-act",children:[_.status==="resolved"?z("button",{type:"button",className:"st-iconbtn","aria-label":"Reopen",onClick:(R)=>{R.stopPropagation(),H(_.id)},children:z(E9,{name:"reopen",size:14})}):z("button",{type:"button",className:"st-iconbtn","aria-label":"Resolve",onClick:(R)=>{R.stopPropagation(),Z(_.id)},children:z(E9,{name:"resolve",size:14})}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Delete",onClick:(R)=>{R.stopPropagation(),K(_.id)},children:z(E9,{name:"x",size:14})})]}):null]})]},_.id))]},D.file))})]})}var zB0={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 KB0({cloud:X}){let J=X?.role||null,[Q,Y]=u.useState(!1);if(!J||Q)return null;let W=`maude-cloud-role-seen:${J}`,G=!1;try{G=localStorage.getItem(W)==="1"}catch{}if(G)return null;let Z=zB0[J];if(!Z)return null;return O("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info","data-testid":"cloud-role-banner",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:Z}),z("button",{type:"button",className:"btn btn--ghost btn--sm","data-testid":"cloud-role-banner-dismiss",onClick:()=>{Y(!0);try{localStorage.setItem(W,"1")}catch{}},children:"Got it"})]})}function UB0({update:X,onDismiss:J}){let[Q,Y]=u.useState(!1);if(!X)return null;let W=X.version?` (v${X.version})`:"";return O("div",{role:"status","aria-live":"polite",className:"st-banner st-banner--info",children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),O("span",{children:["Maude updated",W," · restart to apply"]}),z("button",{type:"button",className:"btn btn--primary btn--sm",disabled:Q,onClick:()=>{Y(!0),af().catch(()=>Y(!1))},children:Q?"Restarting…":"Restart now"}),z("button",{type:"button",className:"btn btn--ghost btn--sm",onClick:J,children:"Later"})]})}function VB0({status:X}){let[J,Q]=u.useState(null);if(!X||X.linked===!1)return null;if(X.notSyncable)return null;let{state:Y,queuedOps:W,flash:G,conflicts:Z}=X,H=G==="synced",K=Y==="offline"||Y==="offline-long",U=X.docs?.rejected??0,q=Array.isArray(Z)?[...Z].reverse().find((D)=>D.kind==="cold-start-diverged"):null;if(!K&&!H&&!q&&U===0)return null;let B,N,F;if(H)B="success",N="Synced with hub",F=`${Y}:flash`;else if(K){let D=Z&&Z.length>0?` (${Z.length} conflict notice(s))`:"";if(Y==="offline-long")B="error",N=`Long offline — ${W} edit(s) queued. Consider \`git commit && git push\` as backup.${D}`;else B="warn",N=`Working offline · ${W} edit(s) queued · will sync when the hub reconnects.${D}`;F=`${Y}:offline`}else if(q){if(q.snapshotFailed)B="error",N=`Diverged on ${q.slug}: kept local — the history snapshot FAILED, so the overwrite was refused. Check disk space / .design/_history write access.`;else B="warn",N=`Diverged on ${q.slug}: kept the ${q.winner==="local"?"local (newer)":"hub"} version — the other is snapshotted in history → /design:rollback ${q.slug}`;F=`diverged:${q.slug}:${q.at}`}else B="warn",N=`${U} canvas(es) not syncing — the hub rejected auth. Details: maude design status`,F=`rejected:${U}`;if(J===F)return null;return O("div",{role:"status","aria-live":"polite",className:`st-banner st-banner--${B}`,children:[z("span",{className:"st-banner-dot","aria-hidden":"true"}),z("span",{children:N}),z("button",{type:"button",className:"st-banner-close","aria-label":"Dismiss",title:"Dismiss",onClick:()=>Q(F),children:"×"})]})}var qB0=["block","inline-block","flex","inline-flex","grid","inline","none"],M00=["px","%","fr","em","auto","min-content","max-content"];var BB0=["auto","stretch","flex-start","center","flex-end","baseline"];var _00=["300","400","500","600","700","800"],A00=["inherit","system-ui","sans-serif","serif","monospace","Inter","Inter Tight","JetBrains Mono"],w00=["none","solid","dashed","dotted","double"],E00=["px","rem","em","%","vw","vh","auto"],P00=new Set(["line-height","opacity","font-weight","z-index","flex-grow","flex-shrink","order"]),WT={"font-size":{node:z(Y7,{as:WV,size:12})},"line-height":{node:z(Y7,{as:VV,size:12})},"letter-spacing":{node:z(Y7,{as:_V,size:12})},gap:{node:z(Y7,{as:YK,size:12})},width:{t:"W"},height:{t:"H"},"max-width":{t:"W"},"border-radius":{node:z(Y7,{as:RV,size:12})},"border-width":{node:z(Y7,{as:MV,size:12})}};var R00=["static","relative","absolute","fixed","sticky"],NB0=["normal","italic","oblique"],T00=["none","uppercase","lowercase","capitalize"];var I00=["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"],FB0=["fill","contain","cover","none","scale-down"];var k00=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],C00=["auto","1 / 1","4 / 3","3 / 2","16 / 9","21 / 9","3 / 4","2 / 3","9 / 16"],_5={desktop:{label:"Desktop",width:1440,height:1024},laptop:{label:"Laptop",width:1280,height:800},tablet:{label:"Tablet",width:834,height:1194},mobile:{label:"Mobile",width:390,height:844}},SK=null;function kF(X){if(!X)return"";if(/^#[0-9a-f]{6}$/i.test(X))return X.toLowerCase();try{if(!SK)SK=document.createElement("canvas").getContext("2d");if(!SK)return"";SK.fillStyle="#000000",SK.fillStyle=X;let J=SK.fillStyle;if(/^#[0-9a-f]{6}$/i.test(J))return J.toLowerCase();let Q=J.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(Q)return`#${[Q[1],Q[2],Q[3]].map((Y)=>Number(Y).toString(16).padStart(2,"0")).join("")}`}catch{}return""}var n4=(X)=>Math.min(1,Math.max(0,X));function AF(X){let J=/^#?([0-9a-f]{6})$/i.exec(X||"");if(!J)return{r:0,g:0,b:0};let Q=Number.parseInt(J[1],16);return{r:Q>>16&255,g:Q>>8&255,b:Q&255}}function v3({r:X,g:J,b:Q}){return`#${[X,J,Q].map((Y)=>Math.round(Y).toString(16).padStart(2,"0")).join("")}`}function f3({r:X,g:J,b:Q}){X/=255,J/=255,Q/=255;let Y=Math.max(X,J,Q),W=Math.min(X,J,Q),G=Y-W,Z=0;if(G){if(Y===X)Z=(J-Q)/G%6;else if(Y===J)Z=(Q-X)/G+2;else Z=(X-J)/G+4;if(Z*=60,Z<0)Z+=360}return{h:Z,s:Y?G/Y:0,v:Y}}function bK({h:X,s:J,v:Q}){let Y=Q*J,W=Y*(1-Math.abs(X/60%2-1)),G=Q-Y,Z=0,H=0,K=0;if(X<60)[Z,H,K]=[Y,W,0];else if(X<120)[Z,H,K]=[W,Y,0];else if(X<180)[Z,H,K]=[0,Y,W];else if(X<240)[Z,H,K]=[0,W,Y];else if(X<300)[Z,H,K]=[W,0,Y];else[Z,H,K]=[Y,0,W];return{r:(Z+G)*255,g:(H+G)*255,b:(K+G)*255}}function Z7(X){if(!X)return"";let J=/^(-?\d*\.?\d+)px$/.exec(X);return J?`${Math.round(Number.parseFloat(J[1]))}px`:X}function gQ(X){if(!X)return{n:"",unit:"px"};let J=X.trim(),Q=/^(-?\d*\.?\d+)\s*(px|rem|em|%|vw|vh)?$/.exec(J);if(Q)return{n:Q[1],unit:Q[2]||"px"};if(J==="auto")return{n:"",unit:"auto"};return{n:J,unit:""}}function $00(X,J){if(!X||Array.isArray(X)||Array.isArray(J)||!J)return X;if(!X.id&&!J.id){let Q=(Y)=>typeof Y.selector==="string"&&Y.selector.startsWith("[data-dc-screen=");if(Q(X)&&Q(J)&&X.selector===J.selector&&X.file===J.file)return{...X,authored:X.authored??J.authored,computed:X.computed??J.computed,customStyles:X.customStyles??J.customStyles,attrs:X.attrs??J.attrs,artboardId:X.artboardId??J.artboardId,worldW:X.worldW??J.worldW,worldH:X.worldH??J.worldH};return X}if(!X.id||X.id!==J.id)return X;return{...X,authored:X.authored??J.authored,computed:X.computed??J.computed,customStyles:X.customStyles??J.customStyles,attrs:X.attrs??J.attrs,photoKind:X.photoKind??J.photoKind,photoAsset:X.photoAsset??J.photoAsset}}function g00(X,J){return(X?J?.canvasDesignSystems?.[X]:null)||J?.defaultDesignSystem||J?.designSystems?.[0]?.name||null}function LB0(X){let J={};for(let Z of X.matchAll(/(--[a-z0-9-]+)\s*:\s*([^;}]+)/gi))if(!(Z[1]in J))J[Z[1]]=Z[2].trim();let Q={};for(let Z of Object.keys(J)){let H=J[Z],K=/^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(H);Q[Z]=K&&J[K[1]]?J[K[1]]:H}let Y=Object.keys(J),W=(Z)=>Y.filter((H)=>Z.test(H)),G=(Z)=>/^(#[0-9a-f]{3,8}|rgba?\(|hsla?\(|oklch\(|oklab\(|lab\(|lch\(|hwb\(|color\()/i.test(Z)||/^(transparent|currentcolor|white|black|red|green|blue|gray|grey|orange|yellow|purple|pink|cyan|magenta|teal|navy|maroon|olive|lime|aqua|silver|gold)$/i.test(Z);return{color:Y.filter((Z)=>G(Q[Z])),space:W(/^--space-/),radius:W(/^--radius-/),type:W(/^--type-/),shadow:W(/^--shadow-/),lh:W(/^--lh-/),vals:Q}}function m00(X,J,Q){let Y=X?.designSystems||[],W=Y.map((H)=>`${H.name}:${H.tokensCssRel}`).join("|"),[G,Z]=u.useState([]);return u.useEffect(()=>{if(!Y.length)return;let H=!1;return Promise.all(Y.map(async(K)=>{if(!K.tokensCssRel)return null;try{let U=await fetch(`/${J}/${K.tokensCssRel}`),q=U.ok?await U.text():"";return{name:K.name,...LB0(q)}}catch{return null}})).then((K)=>{if(H)return;let U=K.filter(Boolean);U.sort((q,B)=>q.name===Q?-1:B.name===Q?1:0),Z(U)}),()=>{H=!0}},[W,J,Q]),G}function u00({seed:X,label:J,onApply:Q}){let[Y,W]=u.useState(()=>f3(AF(X||"#000000"))),G=u.useRef(Y);G.current=Y;let Z=u.useRef(null),H=u.useRef(null),K=u.useRef(X);u.useEffect(()=>{if(X&&X!==K.current)K.current=X,W(f3(AF(X)))},[X]);let U=v3(bK(Y)),q=(M)=>{M.preventDefault();let P=Z.current?.getBoundingClientRect();if(!P)return;let I=G.current.h,k=(C)=>{W({h:I,s:n4((C.clientX-P.left)/P.width),v:n4(1-(C.clientY-P.top)/P.height)})};k(M);let $=()=>{document.removeEventListener("pointermove",k),document.removeEventListener("pointerup",$),Q(v3(bK(G.current)))};document.addEventListener("pointermove",k),document.addEventListener("pointerup",$)},B=(M)=>{M.preventDefault();let P=H.current?.getBoundingClientRect();if(!P)return;let{s:I,v:k}=G.current,$=(y)=>{W({h:n4((y.clientX-P.left)/P.width)*360,s:I,v:k})};$(M);let C=()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",C),Q(v3(bK(G.current)))};document.addEventListener("pointermove",$),document.addEventListener("pointerup",C)},N=(M)=>{let P={...G.current,...M};W(P),Q(v3(bK(P)))},F=(M)=>{let P=M.shiftKey?0.1:0.02,k={ArrowLeft:[-P,0],ArrowRight:[P,0],ArrowUp:[0,P],ArrowDown:[0,-P]}[M.key];if(!k)return;M.preventDefault(),N({s:n4(G.current.s+k[0]),v:n4(G.current.v+k[1])})},D=(M)=>{let P=M.shiftKey?20:2,k={ArrowLeft:-P,ArrowRight:P}[M.key];if(k==null)return;M.preventDefault(),N({h:Math.min(360,Math.max(0,G.current.h+k))})},_=async()=>{try{let M=window.EyeDropper;if(!M)return;let P=await new M().open();if(P?.sRGBHex)W(f3(AF(P.sRGBHex))),Q(P.sRGBHex)}catch{}},R=bK(Y),w=(M)=>{let P={...R,...M},I=f3({r:n4(P.r/255)*255,g:n4(P.g/255)*255,b:n4(P.b/255)*255});W(I),Q(v3(bK(I)))};return O("div",{className:"st-cp-cpick",children:[O("div",{className:"st-cp-cpick-hexrow",children:[z("span",{className:"st-cp-cpick-hexsw",style:{background:U}}),z("input",{className:"st-cp-cpick-hex",type:"text",value:U,"aria-label":J?`${J} hex value`:"hex value",onChange:(M)=>{let P=M.target.value;if(/^#?[0-9a-f]{6}$/i.test(P))W(f3(AF(P)))},onKeyDown:(M)=>{if(M.key==="Enter")Q(M.currentTarget.value)},onBlur:(M)=>Q(M.currentTarget.value),onFocus:(M)=>M.currentTarget.select()})]}),O("button",{type:"button",ref:Z,className:"st-cp-cpick-sv","aria-label":J?`${J} saturation and value`:"saturation and value",style:{background:`hsl(${Y.h} 100% 50%)`},onPointerDown:q,onKeyDown:F,children:[z("span",{className:"st-cp-cpick-svwhite"}),z("span",{className:"st-cp-cpick-svblack"}),z("span",{className:"st-cp-cpick-knob",style:{left:`${Y.s*100}%`,top:`${(1-Y.v)*100}%`,background:U}})]}),O("div",{className:"st-cp-cpick-controls",children:[window.EyeDropper?z("button",{type:"button",className:"st-cp-cpick-eye","aria-label":"pick from screen",title:"eyedropper",onClick:_,children:z(E9,{name:"eyedropper",size:14})}):null,z("span",{className:"st-cp-cpick-preview",style:{background:U},"aria-hidden":"true"}),z("button",{type:"button",ref:H,className:"st-cp-cpick-hue","aria-label":J?`${J} hue`:"hue",onPointerDown:B,onKeyDown:D,children:z("span",{className:"st-cp-cpick-huethumb",style:{left:`${Y.h/360*100}%`}})})]}),z("div",{className:"st-cp-cpick-rgb",children:["r","g","b"].map((M)=>O("label",{className:"st-cp-cpick-rgbf",children:[z("input",{"aria-label":M.toUpperCase(),value:Math.round(R[M]),onChange:(P)=>w({[M]:n4((Number.parseFloat(P.target.value)||0)/255)*255}),onFocus:(P)=>P.currentTarget.select()}),z("span",{children:M.toUpperCase()})]},M))})]})}function EF({kind:X,groups:J,current:Q,onPick:Y,label:W,swatchBg:G,seedHex:Z,activeDs:H,swatchClassName:K}){let[U,q]=u.useState(!1),[B,N]=u.useState(null),[F,D]=u.useState("custom"),[_,R]=u.useState(""),w=u.useRef(null),M=u.useRef(null),P=typeof Q==="string"&&/var\(\s*--/.test(Q),I=(a)=>Q===`var(${a})`,k=(a)=>a.replace(/^--/,"").replace(/-/g," "),$=J||[],C=$.reduce((a,c)=>a+(c.names?.length||0),0),y=$.length>1,f=_.trim().toLowerCase(),h=!f?$:$.map((a)=>({...a,names:(a.names||[]).filter((c)=>k(c).toLowerCase().includes(f)||c.toLowerCase().includes(f)||(a.vals?.[c]||"").toLowerCase().includes(f))})).filter((a)=>a.names.length);u.useEffect(()=>{if(!U){R("");return}let a=()=>{let Z0=w.current?.getBoundingClientRect();if(!Z0)return;let e=224,N0=300,K0=Math.min(Z0.right-e,window.innerWidth-e-8);if(K0<8)K0=8;let Q8=window.innerHeight-Z0.bottom>N0+8?Z0.bottom+4:Math.max(8,Z0.top-N0-4);N({left:K0,top:Q8,width:e,maxHeight:N0})};a();let c=(Z0)=>{if(M.current?.contains(Z0.target)||w.current?.contains(Z0.target))return;q(!1)},U0=(Z0)=>{if(Z0.key==="Escape")q(!1)},o=(Z0)=>{if(M.current?.contains(Z0.target))return;a()};return document.addEventListener("pointerdown",c,!0),document.addEventListener("keydown",U0),window.addEventListener("resize",a),document.addEventListener("scroll",o,!0),()=>{document.removeEventListener("pointerdown",c,!0),document.removeEventListener("keydown",U0),window.removeEventListener("resize",a),document.removeEventListener("scroll",o,!0)}},[U]),u.useEffect(()=>{if(!U||!B||!M.current)return;let a=M.current.getBoundingClientRect(),c=B.left-a.left,U0=B.top-a.top;if(Math.abs(c)>0.5||Math.abs(U0)>0.5)N((o)=>o?{...o,left:o.left+c,top:o.top+U0}:o)},[U,B]);let d=/url\(|image-set\(|cross-fade\(|element\(|expression\(|@import|javascript:/i,n=(a,c,U0)=>{if(H&&a&&a!==H&&U0&&!d.test(U0))Y(U0);else Y(`var(${c})`);q(!1)},x=(a)=>{let c=(a||"").trim();if(c)Y(c)},m=O("div",{className:"st-cp-pop-search",children:[z(E9,{name:"search",size:12}),z("input",{value:_,onChange:(a)=>R(a.target.value),placeholder:"Search variables","aria-label":"search variables",autoFocus:!0})]}),p=(a)=>a.map((c)=>O("div",{className:"st-cp-pop-group",children:[y?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((U0)=>O("button",{type:"button",className:`st-cp-pop-row st-cp-pop-crow${I(U0)?" is-on":""}`,onClick:()=>n(c.ds,U0,c.vals?.[U0]),children:[z("span",{className:"st-cp-pop-cswatch",style:{background:c.vals?.[U0]||"transparent"},"aria-hidden":"true"}),z("span",{className:"st-cp-pop-name",children:k(U0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[U0]||""})]},`${c.ds}:${U0}`))})]},c.ds)),v=(a)=>a.map((c)=>O("div",{className:"st-cp-pop-group",children:[y?z("div",{className:"st-cp-pop-ds",children:c.ds}):null,z("div",{className:"st-cp-pop-list",children:c.names.map((U0)=>O("button",{type:"button",className:`st-cp-pop-row${I(U0)?" is-on":""}`,onClick:()=>n(c.ds,U0,c.vals?.[U0]),children:[z("span",{className:"st-cp-pop-name",children:k(U0)}),z("span",{className:"st-cp-pop-val",children:c.vals?.[U0]||""})]},`${c.ds}:${U0}`))})]},c.ds)),r=z("div",{className:"st-cp-pop-empty",children:"No match"});return O(G0,{children:[G!==void 0?z("button",{type:"button",ref:w,className:`${K||"st-cp-swatch st-cp-swatch--mini st-cp-swatch--trigger"}${P&&!K?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a colour",title:Q||"pick a colour",onClick:()=>q((a)=>!a),children:z("span",{style:{position:"absolute",inset:0,background:G||"transparent"}})}):z("button",{type:"button",ref:w,className:`st-cp-tokbtn${P?" is-bound":""}`,"aria-haspopup":"dialog","aria-expanded":U,"aria-label":W||"pick a design token",title:"design tokens",onClick:()=>q((a)=>!a),children:z("span",{className:"st-cp-tokbtn-glyph","aria-hidden":"true"})}),U&&B?b00.createPortal(z("div",{ref:M,className:"maude st-cp-pop","data-theme":typeof document<"u"&&document.documentElement.getAttribute("data-theme")||"dark",role:"dialog","aria-label":W||"design tokens",style:{left:B.left,top:B.top,width:B.width,maxHeight:B.maxHeight},children:X==="color"?O(G0,{children:[O("div",{className:"st-cp-poptabs",role:"tablist",children:[z("button",{type:"button",role:"tab","aria-selected":F==="custom",className:`st-cp-poptab${F==="custom"?" is-active":""}`,onClick:()=>D("custom"),children:"Custom"}),z("button",{type:"button",role:"tab","aria-selected":F==="vars",className:`st-cp-poptab${F==="vars"?" is-active":""}`,onClick:()=>D("vars"),children:"Variables"})]}),F==="custom"?z(u00,{seed:Z||kF(Q)||"#000000",onApply:x}):!C?z("div",{className:"st-cp-pop-empty",children:"No color tokens"}):O(G0,{children:[m,h.length?p(h):r]})]}):!C?z("div",{className:"st-cp-pop-empty",children:"No tokens for this property"}):O(G0,{children:[m,h.length?v(h):r]})}),document.body):null]})}function S00({label:X,tracks:J,editable:Q,onChange:Y}){let W=(K,U)=>{let q=J[K];Y(J.map((B,N)=>N===K?ZU.has(U)?{value:0,unit:U}:{value:q.value||1,unit:U}:B))},G=(K,U)=>{Y(J.map((q,B)=>B===K?{...q,value:U}:q))},Z=()=>Y([...J,{value:1,unit:"fr"}]),H=(K)=>Y(J.filter((U,q)=>q!==K));return O("div",{className:"st-cp-gridtracks",children:[O("div",{className:"st-cp-gridtracks-hd",children:[z("span",{className:"st-cp-gridtracks-label",children:X}),z("button",{type:"button",className:"st-btn st-cp-gridtracks-add",disabled:!Q,onClick:Z,children:"+ Track"})]}),J.length===0?O("div",{className:"st-cp-note",children:["No explicit tracks — add one to start defining ",X.toLowerCase(),"."]}):J.map((K,U)=>{let q=ZU.has(K.unit);return O("div",{className:"st-cp-gridtrack-row",children:[q?z(IW,{value:K.unit,ariaLabel:`${X} track ${U+1}`,options:M00.map((B)=>({value:B,label:B})),onChange:(B)=>W(U,B)}):z(WX,{value:K.value,min:K.unit==="fr"?0.1:0,step:K.unit==="fr"?0.1:1,ariaLabel:`${X} track ${U+1} value`,lead:String(U+1),unitSlot:z(QN,{value:K.unit,units:M00,ariaLabel:`${X} track ${U+1} unit`,onChange:(B)=>W(U,B)}),onCommit:(B)=>G(U,B)}),z("button",{type:"button",className:"st-btn st-cp-gridtrack-remove","aria-label":`remove ${X} track ${U+1}`,disabled:!Q||J.length<=1,onClick:()=>H(U),children:"×"})]},U)})]})}function DB0({el:X,cfg:J,onOptimistic:Q,onRecordEdit:Y,onReplaceMedia:W,onUndoRedo:G,mode:Z,onSetMode:H}){let K=!!X.id,U=X.computed||{},[q,B]=u.useState({a:{},c:{},t:{}});u.useEffect(()=>{B({a:{},c:{},t:{}})},[X.id]);let N=(X0,_0)=>{let B0={...X0||{}};for(let[S0,t0]of Object.entries(_0))if(t0===null)delete B0[S0];else B0[S0]=t0;return B0},F=N(X.authored,q.a),D=N(X.customStyles,q.c),_=N(X.attrs,q.t),R=(X0,_0)=>B((B0)=>({...B0,a:{...B0.a,[X0]:_0}})),w=(X0,_0)=>B((B0)=>({...B0,c:{...B0.c,[X0]:_0}})),M=(X0,_0)=>B((B0)=>({...B0,t:{...B0.t,[X0]:_0}})),P=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),I=g00(X.file,J),k=m00(J,P,I),$=(X0)=>k.map((_0)=>({ds:_0.name,names:_0[X0]||[],vals:_0.vals})).filter((_0)=>_0.names.length),[C,y]=u.useState({}),[f,h]=u.useState({Layout:!0,Position:!0,Typography:!0,Spacing:!0,Size:!0,Media:!0,Appearance:!0,Advanced:!1}),d=Object.keys(D).length>0||Object.keys(_).length>0;u.useEffect(()=>{if(d)h((X0)=>X0.Advanced?X0:{...X0,Advanced:!0})},[X.id,d]);let n=(F.position||Z7(U.position)||"static")!=="static";u.useEffect(()=>{if(n)h((X0)=>X0["d:Position"]?X0:{...X0,"d:Position":!0})},[X.id,n]);let x=H,[m,p]=u.useState({});async function v(X0,_0,B0){y((S0)=>({...S0,[B0]:"saving"}));try{let S0=await fetch(X0,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(_0)}),t0=await S0.json().catch(()=>({}));y((j8)=>({...j8,[B0]:!S0.ok||!t0.ok?`err:${t0&&t0.error||`HTTP ${S0.status}`}`:"saved"}))}catch(S0){y((t0)=>({...t0,[B0]:`err:${S0&&S0.message?S0.message:String(S0)}`}))}}let r=(X0,_0)=>{if(!Q||!X.id)return;Q({id:X.id,artboardId:X.artboardId??null,index:X.index??0,prop:X0,value:_0})},a=(X0,_0,B0,S0)=>{Y?.({op:X0,canvas:X.file,id:X.id,key:_0,before:B0==null||B0===""?null:B0,after:S0==null||S0===""?null:S0})},c=(X0,_0)=>{let B0=(_0||"").trim();if(!K||!B0)return;let S0=F[X0]??null;if(B0===(S0??"").trim())return;r(X0,B0),R(X0,B0),v("/_api/edit-css",{canvas:X.file,id:X.id,property:X0,value:B0},X0),a("css",X0,S0,B0)},U0=(X0,_0)=>{let B0=(_0||"").trim(),S0=X0.trim();if(!K||!S0||!B0)return;let t0=D[S0]??null;r(S0,B0),w(S0,B0),v("/_api/edit-css",{canvas:X.file,id:X.id,property:S0,value:B0},S0),a("css",S0,t0,B0)},o=(X0,_0)=>{let B0=(X0||"").trim(),S0=(_0||"").trim();if(!K||!B0||!S0)return;let t0=_[B0]??null;M(B0,S0),v("/_api/edit-attr",{canvas:X.file,id:X.id,attr:B0,value:S0},`@${B0}`),a("attr",B0,t0,S0)},Z0=(X0)=>{if(!K)return;let _0=F[X0]??null;r(X0,null),R(X0,null),v("/_api/edit-css",{canvas:X.file,id:X.id,property:X0,reset:!0},X0),a("css",X0,_0,null)},e=(X0)=>{if(!K)return;let _0=D[X0]??null;r(X0,null),w(X0,null),v("/_api/edit-css",{canvas:X.file,id:X.id,property:X0,reset:!0},X0),a("css",X0,_0,null)},N0=(X0)=>{if(!K)return;let _0=_[X0]??null;M(X0,null),v("/_api/edit-attr",{canvas:X.file,id:X.id,attr:X0,reset:!0},`@${X0}`),a("attr",X0,_0,null)},K0={display:X.parentDisplay,flexDirection:X.parentFlexDirection},u0=(X0,_0)=>{if(!K)return;let B0=Math.round((X0==="width"?X.bounds?.w:X.bounds?.h)||0),S0=_S(X0,_0,K0,B0);for(let t0 of S0.reset)if(F[t0])Z0(t0);for(let[t0,j8]of S0.set)c(t0,j8)},Q8=X.parentDisplay==="flex"||X.parentDisplay==="inline-flex",o0=(X0)=>{let _0=MS(X0,F,U,K0);return O("div",{className:"st-cp-moderow",children:[z("span",{className:"st-cp-modelabel",children:X0==="width"?"Width sizing":"Height sizing"}),z("div",{className:"st-cp-modeseg",role:"group","aria-label":`${X0} sizing mode`,children:z(YN,{value:_0,ariaLabel:`${X0} sizing`,options:[{value:"fixed",label:"fixed"},{value:"hug",label:"hug"},{value:"fill",label:"fill"}],onChange:(B0)=>u0(X0,B0)})})]},`mode-${X0}`)},_8=["flex-start","center","flex-end"],A0=["flex-start","center","flex-end"],r0=["t","c","b"],P0=["l","c","r"],K8=()=>{let X0=!(F["flex-direction"]||Z7(U["flex-direction"])||"row").startsWith("column"),_0=Math.max(0,_8.indexOf(F["justify-content"]||Z7(U["justify-content"])||"flex-start")),B0=F["align-items"]||Z7(U["align-items"])||"stretch",S0=B0==="stretch"?1:Math.max(0,A0.indexOf(B0)),[t0,j8]=X0?[_0,S0]:[S0,_0];return r0[j8]+P0[t0]},F8=(X0)=>{let _0=r0.indexOf(X0[0]),B0=P0.indexOf(X0[1]),S0=!(F["flex-direction"]||Z7(U["flex-direction"])||"row").startsWith("column"),[t0,j8]=S0?[B0,_0]:[_0,B0];c("justify-content",_8[t0]),c("align-items",A0[j8])},D8=(X0)=>{if(!(X0.metaKey||X0.ctrlKey)||X0.altKey)return;let _0=X0.key.toLowerCase();if(_0==="z")X0.preventDefault(),G?.(X0.shiftKey?"redo":"undo");else if(_0==="y")X0.preventDefault(),G?.("redo")},W8=(X0)=>{let _0=F[X0];if(!_0)return"inherit";return/var\(\s*--/.test(_0)?"bound":"raw"};if(!K)return O("div",{className:"st-cp",children:[z("div",{className:"st-cp-id",children:z("span",{className:"st-cp-idtag",children:X.tag||"element"})}),O("div",{className:"st-css-disabled",children:["This selection has no stable element id (a legacy canvas, or a non-element target). Edit it with ",z("code",{children:"/design:edit"}),"."]})]});let A8={bound:"token-bound",raw:"raw override",inherit:"inherited"},i8=(X0)=>z("span",{className:`st-cp-prov st-cp-prov--${X0}`,role:"img","aria-label":A8[X0]}),P9=(X0,_0)=>{let B0=_0??W8(X0),S0=C[X0],t0=typeof S0==="string"&&S0.startsWith("err:")?S0.slice(4):"",j8=t0?" is-err":S0==="saved"?" is-saved":S0==="saving"?" is-saving":"",g8=!!F[X0],t8=t0?`error: ${t0}`:g8?`${A8[B0]} · double-click to reset`:A8[B0];return z("button",{type:"button",className:`st-cp-prov st-cp-prov--${B0}${j8}${g8?" is-resettable":""}`,"aria-label":t8,title:t8,tabIndex:g8?0:-1,onDoubleClick:g8?()=>Z0(X0):void 0,onKeyDown:g8?(G9)=>{if(G9.key==="Backspace"||G9.key==="Delete")G9.preventDefault(),Z0(X0)}:void 0})},l0=(X0,_0,B0,S0)=>{let t0=B0===void 0&&!F[X0],j8=S0??X0;return O("div",{className:`st-cp-row${t0?" is-unset":""}`,children:[P9(X0,B0),z("label",{className:"st-cp-label",title:j8,children:j8}),z("div",{className:"st-cp-ctl",children:_0})]},X0)},i0={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"]},j0=(X0)=>{(i0[X0]||[]).forEach((_0)=>{if(F[_0])Z0(_0)})},I0=(X0,_0)=>{let B0=(i0[X0]||[]).some((S0)=>F[S0]);return O("section",{className:"st-cp-sec",children:[O("div",{className:"st-cp-sechd-row",children:[O("button",{type:"button",className:"st-cp-sechd","aria-expanded":!!f[X0],onClick:()=>h((S0)=>({...S0,[X0]:!S0[X0]})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:f[X0]?"▾":"▸"}),X0]}),z("button",{type:"button",className:`st-cp-secreset${B0?"":" is-quiet"}`,"aria-label":`reset ${X0} section to original`,title:`reset ${X0}`,disabled:!B0,onClick:()=>j0(X0),children:z(Y7,{as:wZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${f[X0]?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:_0})})]},X0)},T8=(X0,_0,B0,S0=!0)=>{let t0=`d:${X0}`,j8=f[t0]===void 0?S0:f[t0],g8=_0.some((t8)=>F[t8]);return O("section",{className:"st-cp-sec",children:[O("div",{className:"st-cp-sechd-row",children:[O("button",{type:"button",className:"st-cp-sechd","aria-expanded":j8,onClick:()=>h((t8)=>({...t8,[t0]:!j8})),children:[z("span",{className:"st-cp-caret","aria-hidden":"true",children:j8?"▾":"▸"}),X0]}),z("button",{type:"button",className:`st-cp-secreset${g8?"":" is-quiet"}`,"aria-label":`reset ${X0} to original`,title:`reset ${X0}`,disabled:!g8,onClick:()=>_0.forEach((t8)=>{if(F[t8])Z0(t8)}),children:z(Y7,{as:wZ,size:12})})]}),z("div",{className:`st-cp-sec-anim${j8?" is-open":""}`,children:z("div",{className:"st-cp-sec-inner",children:B0})})]},t0)},Z8=(X0)=>z("button",{type:"button",className:"st-cp-clustermore","aria-expanded":!!m[X0],"aria-label":m[X0]?`${X0} — fewer options`:`${X0} — more options`,title:m[X0]?"fewer":"more",onClick:()=>p((_0)=>({..._0,[X0]:!_0[X0]})),children:m[X0]?"▴":"···"}),z0=(X0,_0)=>O("select",{className:"st-cp-nsel","aria-label":X0,value:_0.includes(F[X0])?F[X0]:"",onChange:(B0)=>c(X0,B0.target.value),children:[z("option",{value:"",disabled:!0,children:Z7(U[X0])||"—"}),_0.map((B0)=>z("option",{value:B0,children:B0},B0))]}),f0=(X0)=>$(X0).flatMap((_0)=>(_0.names||[]).map((B0)=>({name:B0,value:_0.vals?.[B0]||""}))),L8=(X0,_0)=>z(mA,{value:F[X0]||Z7(U[X0])||_0[0].value,ariaLabel:X0,options:_0,onChange:(B0)=>c(X0,B0)}),n8=(X0,_0,B0={})=>{let S0=gQ(F[X0]??""),t0=P00.has(X0),j8=F[X0]??"",g8=typeof j8==="string"&&/var\(\s*--/.test(j8),t8=t0?"":S0.unit&&S0.unit!=="auto"?S0.unit:"px",G9=Number.parseFloat(gQ(Z7(U[X0])??"").n)||0,w9=S0.n!==""&&S0.n!=null?Number.parseFloat(S0.n)||0:G9,F7=WT[X0];return z(WN,{value:g8?j8:w9,tokens:f0(_0),ariaLabel:X0,min:B0.min??0,lead:F7?F7.node??F7.t:void 0,unitSlot:t0?null:z(QN,{units:E00,value:S0.unit||"px",ariaLabel:`${X0} unit`,onChange:(g9)=>c(X0,g9==="auto"?"auto":`${S0.n||"0"}${g9}`)}),onChange:(g9)=>c(X0,typeof g9==="string"?g9:t0?`${g9}`:`${g9}${t8}`)})},k8=()=>{let X0=(t0)=>Number.parseFloat(gQ(F[t0]??F["border-radius"]??Z7(U[t0])??Z7(U["border-radius"])??"0").n)||0,_0={tl:X0("border-top-left-radius"),tr:X0("border-top-right-radius"),bl:X0("border-bottom-left-radius"),br:X0("border-bottom-right-radius")},B0=(t0)=>{if(t0.tl===t0.tr&&t0.tr===t0.bl&&t0.bl===t0.br)["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].forEach((g8)=>{if(F[g8])Z0(g8)}),c("border-radius",`${t0.tl}px`);else c("border-top-left-radius",`${t0.tl}px`),c("border-top-right-radius",`${t0.tr}px`),c("border-bottom-left-radius",`${t0.bl}px`),c("border-bottom-right-radius",`${t0.br}px`)},S0=WT["border-radius"];return z(ax,{corners:_0,lead:S0?S0.node??S0.t:void 0,onCorners:B0})},q8=()=>O("div",{className:"st-cp-border",children:[b9("border-width",null,{fixedUnit:"px"}),O("select",{className:"st-cp-nsel st-cp-nsel--mini","aria-label":"border-style",value:w00.includes(F["border-style"])?F["border-style"]:"",onChange:(X0)=>c("border-style",X0.target.value),children:[z("option",{value:"",disabled:!0,children:"style"}),w00.map((X0)=>z("option",{value:X0,children:X0},X0))]}),z(EF,{kind:"color",groups:$("color"),current:F["border-color"],activeDs:I,swatchBg:U["border-color"]||F["border-color"]||"",seedHex:kF(U["border-color"]||F["border-color"])||"#000000",onPick:(X0)=>c("border-color",X0),label:"border colour"})]}),w0=()=>{let X0=F.transform||Z7(U.transform)||"",_0=/rotate\(\s*(-?\d+(?:\.\d+)?)deg\s*\)/.exec(X0),B0=((_0?Number.parseFloat(_0[1]):0)%360+360)%360,S0=(t0)=>{let j8=(t0%360+360)%360,g8=(F.transform||"").replace(/\s*rotate\([^)]*\)\s*/g," ").trim();c("transform",`${g8?`${g8} `:""}rotate(${j8}deg)`.trim())};return O("div",{className:"st-cp-num",style:{border:0,background:"transparent",gap:"var(--space-2)"},children:[z(nx,{value:B0,onChange:S0}),z(WX,{value:B0,min:0,max:360,ariaLabel:"rotation",lead:z(Y7,{as:wZ}),steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"°"}),onCommit:S0})]})},L0=()=>{let X0=F.filter||Z7(U.filter)||"",_0=/blur\(\s*(-?\d+(?:\.\d+)?)px\s*\)/.exec(X0),B0=_0?Number.parseFloat(_0[1]):0;return z(WX,{value:B0,min:0,ariaLabel:"filter blur",unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"px"}),onCommit:(t0)=>{let j8=(F.filter||"").replace(/\s*blur\([^)]*\)\s*/g," ").trim();c("filter",t0>0?`${j8?`${j8} `:""}blur(${t0}px)`.trim():j8||"none")}})},d0=()=>{let X0=F.opacity,_0=X0!=null&&X0!==""?Number.parseFloat(X0):Number.parseFloat(Z7(U.opacity))||1,B0=Math.round((Number.isNaN(_0)?1:_0)*100);return z(TJ,{value:B0,min:0,max:100,step:1,unit:"%",ariaLabel:"opacity",onInput:(S0)=>r("opacity",String(S0/100)),onCommit:(S0)=>c("opacity",String(S0/100))},`opacity:${X0??""}`)},V8=()=>{let X0=Number.parseInt(F["font-weight"]||Z7(U["font-weight"])||"400",10)>=600,_0=(F["font-style"]||Z7(U["font-style"]))==="italic",B0=/underline/.test(F["text-decoration"]||Z7(U["text-decoration"])||"");return z(ix,{value:{b:X0,i:_0,u:B0},ariaLabel:"text style",options:[{value:"b",node:z(Y7,{as:qV}),label:"Bold"},{value:"i",node:z(Y7,{as:DV}),label:"Italic"},{value:"u",node:z(Y7,{as:kV}),label:"Underline"}],onToggle:(S0)=>{if(S0==="b")c("font-weight",X0?"400":"700");else if(S0==="i")c("font-style",_0?"normal":"italic");else c("text-decoration",B0?"none":"underline")}})},O8=[{value:"row",node:z(Y7,{as:DW}),label:"Row"},{value:"column",node:z(Y7,{as:OW}),label:"Column"}],a8=[{value:"flex-start",node:z(Y7,{as:HV}),label:"Start"},{value:"center",node:z(Y7,{as:GV}),label:"Center"},{value:"flex-end",node:z(Y7,{as:ZV}),label:"End"},{value:"space-between",node:z(Y7,{as:YK}),label:"Space between"}],E8=[{value:"flex-start",node:z(Y7,{as:UV}),label:"Start"},{value:"center",node:z(Y7,{as:zV}),label:"Center"},{value:"flex-end",node:z(Y7,{as:KV}),label:"End"},{value:"stretch",node:z(Y7,{as:TV}),label:"Stretch"}],N9=[{value:"left",node:z(Y7,{as:m5}),label:"Left"},{value:"center",node:z(Y7,{as:AW}),label:"Center"},{value:"right",node:z(Y7,{as:wW}),label:"Right"},{value:"justify",node:z(Y7,{as:EW}),label:"Justify"}],Y9=[{value:"visible",node:z(Y7,{as:AZ}),label:"Visible"},{value:"hidden",node:z(Y7,{as:EZ}),label:"Hidden"},{value:"scroll",node:z(Y7,{as:EV}),label:"Scroll"}],e7=(X0,_0)=>{let B0=$(_0);return B0.length?z(EF,{kind:"value",groups:B0,current:F[X0],activeDs:I,onPick:(S0)=>c(X0,S0),label:`${X0} design token`}):null},E0=(X0)=>{let _0=X0.currentTarget;requestAnimationFrame(()=>{if(document.activeElement===_0)_0.select()})},h8=(X0,_0)=>{if(X0.key!=="ArrowUp"&&X0.key!=="ArrowDown")return!1;X0.preventDefault();let B0=X0.shiftKey?10:1,S0=X0.key==="ArrowUp"?1:-1,t0=(Number.parseFloat(X0.currentTarget.value)||0)+S0*B0;return X0.currentTarget.value=String(t0),_0(t0),!0},F9=(X0)=>z("input",{className:"st-cp-fin","aria-label":X0,defaultValue:F[X0]??"",placeholder:Z7(U[X0])||"—",onFocus:E0,onKeyDown:(_0)=>{if(_0.key==="Enter")_0.currentTarget.blur()},onBlur:(_0)=>c(X0,_0.currentTarget.value)},`${X0}:${F[X0]??""}`),b9=(X0,_0,B0={})=>{let S0=gQ(F[X0]??""),t0=P00.has(X0),j8=t0?"":B0.fixedUnit||(S0.unit&&S0.unit!=="auto"?S0.unit:"px"),g8=WT[X0],t8=Number.parseFloat(gQ(Z7(U[X0])??"").n)||0,G9=S0.n!==""&&S0.n!=null?Number.parseFloat(S0.n)||0:t8;return O(G0,{children:[z(WX,{value:G9,min:B0.min??0,step:1,ariaLabel:X0,lead:g8?g8.node??g8.t:void 0,onCommit:(w9)=>c(X0,t0?`${w9}`:`${w9}${j8}`),unitSlot:t0||B0.fixedUnit?null:z(QN,{units:E00,value:S0.unit||"px",ariaLabel:`${X0} unit`,onChange:(w9)=>c(X0,w9==="auto"?"auto":`${S0.n||"0"}${w9}`)})},`${X0}:${F[X0]??""}`),e7(X0,_0)]})},l7=(X0)=>{let _0=U[X0]||F[X0]||"",B0=F[X0]??"",S0=typeof B0==="string"&&/var\(\s*--/.test(B0),t0=S0?B0.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):B0;return z($V,{swatch:z(EF,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:$("color"),current:F[X0],activeDs:I,swatchBg:_0,seedHex:kF(U[X0]||F[X0])||"#000000",onPick:(j8)=>c(X0,j8),label:`${X0} colour`}),displayValue:t0,bound:S0,ariaLabel:X0,onValue:(j8)=>c(X0,j8)})},c6=(X0,_0)=>{let B0=null,S0=_0.unitless?"":"px",t0=(t8)=>_0.unitless?`${t8}`:`${t8}${S0}`,j8=(t8,G9,w9)=>{for(let F7 of G9??[X0])w9(F7,t0(t8))},g8=gA({getBase:()=>B0?.value??"0",min:_0.min??0,step:1,sides:_0.sides,onInput:(t8,G9)=>{if(B0)B0.value=String(t8);if(G9){let w9=B0?.closest(".st-cp-box");for(let F7 of G9){if(F7===X0)continue;let g9=w9?.querySelector(`.st-cp-boxv[aria-label="${F7}"]`);if(g9)g9.value=String(t8)}}j8(t8,G9,r)},onCommit:(t8,G9)=>j8(t8,G9,c)});return{onPointerDown:(t8)=>{B0=t8.currentTarget,g8(t8)}}},p8=(X0,_0)=>{let B0=F[X0],S0=B0!=null&&B0!==""?gQ(B0).n||B0:gQ(Z7(U[X0])??"").n||"0",t0=!B0||B0==="0"||B0==="0px"||B0==="auto",j8=X0.split("-").pop(),g8=j8==="top"||j8==="bottom"?[`${_0}-top`,`${_0}-bottom`]:[`${_0}-left`,`${_0}-right`],t8=[`${_0}-top`,`${_0}-right`,`${_0}-bottom`,`${_0}-left`];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--${_0[0]}${X0.split("-").pop()[0]}${t0?" is-zero":""}`,"aria-label":X0,defaultValue:S0,title:"drag to scrub · alt = symmetric · alt+shift = all sides",...c6(X0,{sides:{pair:g8,all:t8}}),onFocus:E0,onKeyDown:(G9)=>{if(h8(G9,(w9)=>c(X0,`${w9}px`)))return;if(G9.key==="Enter")G9.currentTarget.blur()},onBlur:(G9)=>{let w9=G9.currentTarget.value.trim();if(!w9)return;let F7=/[a-z%]/i.test(w9)?w9:`${w9}px`;c(X0,F7)}},`${X0}:${B0??""}`)},H7=(X0)=>{let _0=F[X0],B0=_0!=null&&_0!==""&&_0!=="auto"?gQ(_0).n||_0:gQ(Z7(U[X0])??"").n||"",S0=!_0||_0==="auto"||_0==="0"||_0==="0px",t0=X0==="top"||X0==="bottom"?["top","bottom"]:["left","right"],j8=["top","right","bottom","left"];return z("input",{className:`st-cp-boxv st-cp-scrub st-cp-boxv--i${X0[0]}${S0?" is-zero":""}`,"aria-label":X0,defaultValue:B0,placeholder:"auto",title:"drag to scrub · alt = axis pair · alt+shift = all sides · type auto",...c6(X0,{sides:{pair:t0,all:j8},min:-1/0}),onFocus:E0,onKeyDown:(g8)=>{if(h8(g8,(t8)=>c(X0,`${t8}px`)))return;if(g8.key==="Enter")g8.currentTarget.blur()},onBlur:(g8)=>{let t8=g8.currentTarget.value.trim();if(!t8)return;let G9=/[a-z%]/i.test(t8)?t8:`${t8}px`;c(X0,G9)}},`${X0}:${_0??""}`)},z7=Object.entries(D),P7=Object.entries(_),T9=()=>{let X0=(X.tag||"").toLowerCase(),B0=X0==="img"||X0==="video"||X0==="picture"||X0==="svg"||X0==="canvas"||!!F["object-fit"]||!!F["object-position"]||!!F["aspect-ratio"],S0=(X0==="img"||X0==="video")&&!!X.attrs?.src&&!!W;return{showMedia:B0,canReplace:S0}},S6=(X0)=>O(G0,{children:[X0&&z("div",{className:"st-cp-mediabtn",children:z("button",{type:"button",className:"st-btn st-cp-replace",onClick:()=>W(X),children:"Replace…"})}),l0("object-fit",z0("object-fit",FB0)),l0("object-position",F9("object-position")),l0("aspect-ratio",O("select",{className:"st-cp-nsel","aria-label":"aspect-ratio",value:C00.includes(F["aspect-ratio"])?F["aspect-ratio"]:"",onChange:(_0)=>{let B0=_0.target.value;if(c("aspect-ratio",B0),B0&&B0!=="auto"&&F.height)Z0("height")},children:[z("option",{value:"",disabled:!0,children:Z7(U["aspect-ratio"])||"—"}),C00.map((_0)=>z("option",{value:_0,children:_0},_0))]}))]});return O("div",{className:`st-cp${Z==="designer"?" st-cp--designer":""}`,"data-tour":"css-panel",onKeyDown:D8,children:[O("div",{className:"st-cp-id",children:[O("span",{className:"st-cp-idtag",children:[X.tag||"element",X.classes?O("span",{className:"st-cp-idcls",children:[".",X.classes.split(/\s+/)[0]]}):null]}),z("span",{className:"st-cp-idmode","data-tour":"cp-mode",children:z(mA,{value:Z,ariaLabel:"panel vocabulary mode",options:[{value:"advanced",node:z(Y7,{as:LW,size:12}),label:"Advanced — raw CSS"},{value:"designer",node:z(Y7,{as:PW,size:12}),label:"Designer — Figma vocabulary"}],onChange:x})})]}),Z==="designer"?O(G0,{children:[T8("Auto layout",["display","flex-direction","flex-wrap","align-items","justify-content","gap","padding-top","padding-right","padding-bottom","padding-left"],(()=>{let X0=(F.display||Z7(U.display)||"").trim();return X0==="flex"||X0==="inline-flex"?O(G0,{children:[l0("flex-direction",L8("flex-direction",O8),void 0,"Direction"),l0("align-items",z(ox,{value:K8(),onChange:F8,ariaLabel:"auto-layout alignment"}),W8("align-items"),"Alignment"),l0("gap",n8("gap","space"),void 0,"Gap"),O("div",{className:"st-cp-modes",children:[o0("width"),o0("height")]}),O("div",{className:"st-cp-box","aria-label":"padding",children:[O("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[i8(W8("padding-top")),"padding"]}),p8("padding-top","padding"),p8("padding-right","padding"),p8("padding-bottom","padding"),p8("padding-left","padding")]}),z("div",{className:"st-cp-clustermore-row",children:Z8("Auto layout")}),m["Auto layout"]?l0("flex-wrap",z(yQ,{checked:/^wrap/.test(F["flex-wrap"]||Z7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(B0)=>c("flex-wrap",B0?"wrap":"nowrap")}),W8("flex-wrap"),"Wrap"):null]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>c("display","flex"),children:"+ Auto layout (flex)"})})()),T8("Size",["width","height","min-width","max-width","min-height","max-height"],O(G0,{children:[l0("width",b9("width"),void 0,"Width"),l0("height",b9("height"),void 0,"Height"),z("div",{className:"st-cp-clustermore-row",children:Z8("Size")}),m.Size?O(G0,{children:[l0("min-width",b9("min-width"),void 0,"Min width"),l0("max-width",b9("max-width"),void 0,"Max width"),l0("min-height",b9("min-height"),void 0,"Min height"),l0("max-height",b9("max-height"),void 0,"Max height")]}):null]})),T8("Position",["position","top","right","bottom","left","z-index"],O(G0,{children:[l0("position",z0("position",R00),void 0,"Position"),O("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[O("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[i8(W8("top")),"inset"]}),H7("top"),H7("right"),H7("bottom"),H7("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||Z7(U.position)||"static"})]}),(F.position||Z7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,z("div",{className:"st-cp-clustermore-row",children:Z8("Position")}),m.Position?l0("z-index",b9("z-index"),void 0,"Layer order"):null]}),!1),T8("Fill",["background-color"],l0("background-color",l7("background-color"),void 0,"Fill")),T8("Stroke",["border-width","border-style","border-color"],l0("border",q8(),W8("border-width"),"Stroke")),T8("Corner radius",["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"],l0("border-radius",k8(),W8("border-radius"),"Corner radius")),T8("Effects",["box-shadow","filter","mix-blend-mode"],O(G0,{children:[l0("box-shadow",e7("box-shadow","shadow")||F9("box-shadow"),void 0,"Shadow"),l0("filter",L0(),W8("filter"),"Blur"),l0("mix-blend-mode",z0("mix-blend-mode",k00),void 0,"Blend")]})),T8("Opacity",["opacity"],l0("opacity",d0(),void 0,"Opacity")),T8("Text",["font-family","color","font-size","font-weight","line-height","text-align","letter-spacing","font-style","text-transform","white-space"],O(G0,{children:[l0("font-family",z0("font-family",A00),void 0,"Font"),l0("color",l7("color"),void 0,"Color"),l0("font-size",n8("font-size","type"),void 0,"Size"),l0("font-weight",z0("font-weight",_00),void 0,"Weight"),l0("line-height",b9("line-height","lh"),void 0,"Line height"),l0("text-align",L8("text-align",N9),void 0,"Align"),z("div",{className:"st-cp-clustermore-row",children:Z8("Text")}),m.Text?O(G0,{children:[l0("letter-spacing",b9("letter-spacing",null,{min:-1/0}),void 0,"Letter spacing"),l0("font-style",z0("font-style",NB0),void 0,"Style"),l0("text-transform",z0("text-transform",T00),void 0,"Case"),l0("white-space",z0("white-space",I00),void 0,"Whitespace")]}):null]})),T8("Spacing",["margin-top","margin-right","margin-bottom","margin-left"],O("div",{className:"st-cp-box","aria-label":"margin",children:[O("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[i8(W8("margin-top")),"margin"]}),p8("margin-top","margin"),p8("margin-right","margin"),p8("margin-bottom","margin"),p8("margin-left","margin")]})),(()=>{let{showMedia:X0,canReplace:_0}=T9();return X0?T8("Media",["object-fit","object-position","aspect-ratio"],S6(_0)):null})()]}):O(G0,{children:[I0("Layout",(()=>{let X0=(F.display||Z7(U.display)||"").trim(),_0=X0==="flex"||X0==="inline-flex",B0=X0==="grid"||X0==="inline-grid";return O(G0,{children:[l0("display",z0("display",qB0)),_0?O(G0,{children:[l0("flex-direction",L8("flex-direction",O8)),l0("flex-wrap",z(yQ,{checked:/^wrap/.test(F["flex-wrap"]||Z7(U["flex-wrap"])||""),label:"wrap items",ariaLabel:"flex-wrap",onChange:(S0)=>c("flex-wrap",S0?"wrap":"nowrap")}),W8("flex-wrap"))]}):null,_0||B0?O(G0,{children:[l0("align-items",L8("align-items",E8)),l0("justify-content",L8("justify-content",a8)),l0("gap",n8("gap","space"))]}):z("button",{type:"button",className:"st-cp-makeflex",disabled:!K,onClick:()=>c("display","flex"),children:"+ Auto layout (flex)"})]})})()),(()=>{let X0=(F.display||Z7(U.display)||"").trim();if(!(X0==="grid"||X0==="inline-grid"))return null;let B0=F["grid-template-columns"]||"",S0=F["grid-template-rows"]||"",t0=vO(B0),j8=vO(S0),g8=t0.length>0||!B0.trim(),t8=j8.length>0||!S0.trim();return I0("Grid",O(G0,{children:[g8?z(S00,{label:"Columns",tracks:t0,editable:K,onChange:(G9)=>c("grid-template-columns",fO(G9))}):O("div",{className:"st-cp-note",children:["Columns use ",z("code",{children:B0})," — not editable as tracks here (repeat()/ minmax()/subgrid); use /design:edit for these."]}),t8?z(S00,{label:"Rows",tracks:j8,editable:K,onChange:(G9)=>c("grid-template-rows",fO(G9))}):O("div",{className:"st-cp-note",children:["Rows use ",z("code",{children:S0})," — not editable as tracks here (repeat()/minmax()/ subgrid); use /design:edit for these."]})]}))})(),I0("Position",O(G0,{children:[l0("position",z0("position",R00)),O("div",{className:"st-cp-box st-cp-box--inset","aria-label":"position inset (top / right / bottom / left)",children:[O("span",{className:"st-cp-boxtag st-cp-boxtag--i",children:[i8(W8("top")),"inset"]}),H7("top"),H7("right"),H7("bottom"),H7("left"),z("div",{className:"st-cp-boxcore st-cp-boxcore--pos",children:F.position||Z7(U.position)||"static"})]}),(F.position||Z7(U.position)||"static")==="static"?z("div",{className:"st-cp-note",children:"top / right / bottom / left apply once position is relative, absolute, fixed, or sticky"}):null,l0("z-index",b9("z-index"))]})),(X.parentDisplay==="grid"||X.parentDisplay==="inline-grid")&&I0("Grid item",O(G0,{children:[O("div",{className:"st-cp-note",children:["Manual cell placement — ",z("code",{children:"start / end"})," or ",z("code",{children:"start / span N"}),"."]}),l0("grid-column",F9("grid-column")),l0("grid-row",F9("grid-row"))]})),I0("Typography",O(G0,{children:[l0("font-family",z0("font-family",A00)),l0("color",l7("color")),l0("font-size",n8("font-size","type")),l0("font-weight",z0("font-weight",_00)),l0("line-height",b9("line-height","lh")),l0("letter-spacing",b9("letter-spacing",null,{min:-1/0})),l0("text-align",L8("text-align",N9)),l0("font-style",V8(),W8("font-style")),l0("text-transform",z0("text-transform",T00)),l0("white-space",z0("white-space",I00))]})),I0("Spacing",z(G0,{children:O("div",{className:"st-cp-box","aria-label":"margin and padding",children:[O("span",{className:"st-cp-boxtag st-cp-boxtag--m",children:[i8(W8("margin-top")),"margin"]}),p8("margin-top","margin"),p8("margin-right","margin"),p8("margin-bottom","margin"),p8("margin-left","margin"),O("div",{className:"st-cp-boxpad",children:[O("span",{className:"st-cp-boxtag st-cp-boxtag--p",children:[i8(W8("padding-top")),"padding"]}),p8("padding-top","padding"),p8("padding-right","padding"),p8("padding-bottom","padding"),p8("padding-left","padding"),O("div",{className:"st-cp-boxcore",children:[Math.round(Number.parseFloat(F.width)||X.bounds?.w||0)," × ",Math.round(Number.parseFloat(F.height)||X.bounds?.h||0)]})]})]})})),I0("Size",O(G0,{children:[O("div",{className:"st-cp-modes",children:[o0("width"),o0("height")]}),l0("width",b9("width")),l0("height",b9("height")),l0("min-width",b9("min-width")),l0("max-width",b9("max-width")),l0("min-height",b9("min-height")),l0("max-height",b9("max-height")),l0("overflow",L8("overflow",Y9)),Q8?O(G0,{children:[z("div",{className:"st-cp-subhd",children:"In flex parent"}),l0("align-self",z0("align-self",BB0)),l0("flex-grow",b9("flex-grow",null,{unitless:!0})),l0("flex-shrink",b9("flex-shrink",null,{unitless:!0})),l0("flex-basis",b9("flex-basis"))]}):null]})),(()=>{let{showMedia:X0,canReplace:_0}=T9();return X0?I0("Media",S6(_0)):null})(),I0("Appearance",O(G0,{children:[l0("background-color",l7("background-color")),l0("border-radius",k8(),W8("border-radius")),l0("border",q8(),W8("border-width")),l0("box-shadow",e7("box-shadow","shadow")||F9("box-shadow")),l0("filter",L0(),W8("filter")),l0("mix-blend-mode",z0("mix-blend-mode",k00)),l0("opacity",d0()),l0("rotation",w0(),W8("transform")),l0("transform",F9("transform")),l0("transform-origin",F9("transform-origin"))]})),(()=>{let X0=Object.entries(C).find(([,_0])=>typeof _0==="string"&&_0.startsWith("err:"));return X0?O("div",{className:"st-cp-save is-err",role:"status",children:[z(E9,{name:"x",size:12}),X0[0],": ",X0[1].slice(4)]}):null})(),I0("Advanced",O("div",{className:"st-cp-advbody",children:[z7.length?O(G0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom CSS properties"}),z7.map(([X0,_0])=>O("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:X0,"aria-label":`custom property ${X0} name`}),z("input",{className:"st-cp-fin",defaultValue:_0,"aria-label":`${X0} value`,onKeyDown:(B0)=>{if(B0.key==="Enter")B0.currentTarget.blur()},onBlur:(B0)=>U0(X0,B0.currentTarget.value)},`cs:${X0}:${_0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${X0}`,title:"remove",onClick:()=>e(X0),children:z(E9,{name:"x",size:11})})]},`cs:${X0}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add CSS property"}),z(OB0,{commit:U0}),z("div",{className:"st-cp-note",children:"applied as-is — not token-bound"}),P7.length?O(G0,{children:[z("div",{className:"st-cp-advgrp",children:"Custom HTML attributes"}),P7.map(([X0,_0])=>O("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin st-cp-fin--ro",readOnly:!0,value:X0,"aria-label":`attribute ${X0} name`}),z("input",{className:"st-cp-fin",defaultValue:_0,"aria-label":`${X0} value`,onKeyDown:(B0)=>{if(B0.key==="Enter")B0.currentTarget.blur()},onBlur:(B0)=>o(X0,B0.currentTarget.value)},`at:${X0}:${_0}`),z("button",{type:"button",className:"st-cp-kvx","aria-label":`remove ${X0}`,title:"remove",onClick:()=>N0(X0),children:z(E9,{name:"x",size:11})})]},`at:${X0}`))]}):null,z("div",{className:"st-cp-advgrp",children:"Add HTML attribute"}),z(MB0,{commit:o})]}))]}),O("div",{className:"st-cp-legend",children:[O("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--bound","aria-hidden":"true"}),"token"]}),O("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--raw","aria-hidden":"true"}),"override"]}),O("span",{children:[z("i",{className:"st-cp-prov st-cp-prov--inherit","aria-hidden":"true"}),"inherited"]})]})]},X.id)}function OB0({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return O("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom property name",placeholder:"property",value:J,onChange:(Z)=>Q(Z.target.value)}),z("input",{className:"st-cp-fin","aria-label":"custom property value",placeholder:"value",value:Y,onChange:(Z)=>W(Z.target.value),onKeyDown:(Z)=>{if(Z.key==="Enter")G()},onBlur:G})]})}function MB0({commit:X}){let[J,Q]=u.useState(""),[Y,W]=u.useState(""),G=()=>{if(J.trim()&&Y.trim())X(J.trim(),Y),Q(""),W("")};return O("div",{className:"st-cp-kv",children:[z("input",{className:"st-cp-fin","aria-label":"custom attribute name",placeholder:"data-…",value:J,onChange:(Z)=>Q(Z.target.value)}),z("input",{className:"st-cp-fin","aria-label":"custom attribute value",placeholder:"value",value:Y,onChange:(Z)=>W(Z.target.value),onKeyDown:(Z)=>{if(Z.key==="Enter")G()},onBlur:G})]})}var _B0={button:"button",heading:"type",text:"type",input:"input",form:"input",image:"image",link:"link",list:"list",nav:"layers",box:"box",group:"folder"};function AB0(X,J,Q,Y){if(!Array.isArray(X)||J===Q)return X;let W=JSON.parse(JSON.stringify(X)),G=null,Z=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===J)return G=K[U],K.splice(U,1),!0;if(K[U].children&&Z(K[U].children))return!0}return!1};if(Z(W),!G)return X;let H=(K)=>{for(let U=0;U<K.length;U++){if(K[U].id===Q){if(Y==="inside-start"||Y==="inside-end")if(K[U].children=K[U].children||[],Y==="inside-start")K[U].children.unshift(G);else K[U].children.push(G);else K.splice(Y==="before"?U:U+1,0,G);return!0}if(K[U].children&&H(K[U].children))return!0}return!1};return H(W)?W:X}var wB0=new Set(["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"]);function l00({node:X,depth:J,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:q,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:D,onToggleLock:_,onRename:R}){let w=`${X.id}:${X.index}`,M=X.children&&X.children.length>0,P=W.has(w),I=!!X.synthetic,k=!I&&F?F[X.id]:null,$=!I&&!!D?.has(w),[C,y]=u.useState(!1),[f,h]=u.useState(""),d=!I&&X.id===Q&&(Y==null||X.index===Y),n=G?.has(w)?G.get(w):!!X.hidden,x=!!q&&!I&&!$,m=()=>{y(!1);let r=f.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!r||r===(X.dcElement??""))return;R?.(X,r)},p=N?.key===w,v=p?{transform:`translate(${N.dx}px, ${N.dy}px)`,opacity:0.9,zIndex:20,position:"relative",pointerEvents:"none",cursor:"grabbing",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.28)"}:null;return O(G0,{children:[O("div",{className:"st-layer st-layer--row"+(d?" is-sel":"")+(n?" is-hidden":"")+(I?" is-group":"")+(k?" is-instance":"")+($?" is-locked":""),style:{paddingLeft:6+J*14,...v},role:"treeitem","aria-selected":I?void 0:d,"aria-expanded":M?!P:void 0,"aria-grabbed":x?p:void 0,tabIndex:0,title:I?`${X.tag} · group (unstamped wrapper)`:`${X.tag} · ${X.type}${R?" · F2 to rename":""}`,"data-layer-key":w,onClick:()=>I?M&&Z(w):H(X),onMouseEnter:()=>!I&&K(X),onMouseLeave:()=>K(null),onPointerDown:x?(r)=>B(r,X,w):void 0,onKeyDown:(r)=>{if(r.key==="Enter"||r.key===" ")if(r.preventDefault(),I)M&&Z(w);else H(X);else if(r.key==="F2"&&R&&!I)r.preventDefault(),h(X.dcElement||X.label||""),y(!0)},children:[M?z("button",{type:"button",className:"st-layer-caret","aria-label":P?"Expand":"Collapse",onClick:(r)=>{r.stopPropagation(),Z(w)},children:P?"▸":"▾"}):z("span",{className:"st-layer-caret","aria-hidden":"true"}),k?z("span",{className:"st-layer-inst-glyph","aria-hidden":"true",children:k.root?"◆":"◇"}):z(E9,{name:_B0[X.type]||"box",size:12,className:"st-layer-ticon"}),C?z("input",{className:"st-layer-rename",value:f,autoFocus:!0,"aria-label":`Rename ${X.label}`,onFocus:(r)=>r.target.select(),onChange:(r)=>h(r.target.value),onClick:(r)=>r.stopPropagation(),onPointerDown:(r)=>r.stopPropagation(),onBlur:m,onKeyDown:(r)=>{if(r.stopPropagation(),r.key==="Enter")m();else if(r.key==="Escape")y(!1)}}):z("span",{className:"st-layer-label",onDoubleClick:R&&!I?(r)=>{r.stopPropagation(),h(X.dcElement||X.label||""),y(!0)}:void 0,children:X.label}),z("span",{className:"st-layer-type",children:k?k.component:X.type}),_&&!I?z("button",{type:"button",className:"st-layer-lock","aria-label":$?`Unlock ${X.label}`:`Lock ${X.label}`,"aria-pressed":$,title:$?"Unlock":"Lock",onClick:(r)=>{r.stopPropagation(),_(w)},children:z(E9,{name:$?"lock":"unlock",size:12})}):null,U&&!I?z("button",{type:"button",className:"st-layer-eye","aria-label":n?`Show ${X.label}`:`Hide ${X.label}`,"aria-pressed":n,title:n?"Show":"Hide",onClick:(r)=>{r.stopPropagation(),U(X)},children:z(E9,{name:n?"eye-off":"eye",size:13})}):null]}),M&&!P?X.children.map((r,a)=>z(l00,{node:r,depth:J+1,selectedId:Q,selectedIndex:Y,collapsed:W,hiddenOverride:G,onToggle:Z,onSelect:H,onHover:K,onToggleVisibility:U,onReorder:q,onRowPointerDown:B,dragState:N,componentMap:F,lockedKeys:D,onToggleLock:_,onRename:R},`${r.id}:${r.index}`)):null]})}function EB0({el:X}){let J=X?.computed||{},Q=X?.authored||{},Y=(U)=>{let q=Q[U];if(q&&/var\(\s*--/.test(q))return q.replace(/^var\(\s*|\s*\)$/g,"");return J[U]||q||""},W=(U,q)=>{let B=J[q]||Q[q];if(!B)return null;return O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:U}),O("div",{className:"st-swatch-row",children:[z("span",{className:"st-insp-swatch",style:{background:B},"aria-hidden":"true"}),z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Y(q)})]})]},U)},G=J["border-radius"]&&J["border-radius"]!=="0px",Z=G?gQ(J["border-radius"]).n||J["border-radius"]:null,H=J["font-size"]||J["font-weight"]?[J["font-size"],J["font-weight"]].filter(Boolean).join(" / "):null;if(!(J["background-color"]||J.color||G||H))return null;return O(G0,{children:[G?O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Radius"}),O("div",{className:"st-insp-fields",children:[O("span",{className:"st-fmini",style:{flex:"0 0 auto",maxWidth:84},children:[z("span",{className:"st-mtag",children:"r"}),z("input",{value:Z,readOnly:!0,"aria-label":"border radius"})]}),z("span",{className:"st-insp-unit",children:"px"})]})]}):null,W("Fill","background-color"),W("Text","color"),H?O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Font"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:H})})]}):null]})}function p00(X){if(X.artboardId)return X.artboardId;let J=/^\[data-dc-screen="([^"]+)"\]$/.exec(X.selector||"");return J?J[1]:null}var PB0=[["","Block (default)"],["flex-col","Flex ↓ (column)"],["flex-row","Flex → (row)"],["grid","Grid"]],RB0=[["digital","Digital"],["print","Print"],["web","Web"],["video","Video"]];function TB0({el:X,cfg:J,onResizeArtboard:Q,onSetArtboardHug:Y,onSetArtboardStyle:W,onSetArtboardKind:G,onSetArtboardPrint:Z,onDuplicateArtboard:H}){let K=p00(X),U=(J?.designRel||J?.designRoot||".design").replace(/^\/+|\/+$/g,""),q=g00(X.file,J),B=m00(J,U,q),N=(v)=>B.map((r)=>({ds:r.name,names:r[v]||[],vals:r.vals})).filter((r)=>r.names.length),F=(v)=>N(v).flatMap((r)=>(r.names||[]).map((a)=>({name:a,value:r.vals?.[a]||""}))),D=(v)=>{let r=/^var\(\s*(--[\w-]+)\s*\)$/.exec(v||"");if(!r)return v||"";for(let a of B){let c=a.vals?.[r[1]];if(c)return c}return""},_=Number.isFinite(X.worldW)?X.worldW:Number.isFinite(X.bounds?.w)?X.bounds.w:null,R=Number.isFinite(X.worldH)?X.worldH:Number.isFinite(X.bounds?.h)?X.bounds.h:null,w=(v,r)=>{if(!K)return;let a=Number.isFinite(v)&&v>0?Math.round(v):void 0,c=Number.isFinite(r)&&r>0?Math.round(r):void 0;if(a==null&&c==null)return;Q?.(K,a,c)},M=Object.entries(_5).find(([,v])=>v.width===_&&v.height===R)?.[0],P=Object.entries(_5).find(([,v])=>v.width===_)?.[0],I=X.attrs?.["data-dc-fixed"]==="true",k=X.attrs?.["data-dc-bg"]??"",$=X.attrs?.["data-dc-padding"]??"",C=X.attrs?.["data-dc-layout"]??"",y=X.attrs?.["data-dc-gap"]??"",f=X.attrs?.["data-dc-kind"]||"digital",h=null;try{h=X.attrs?.["data-dc-print"]?JSON.parse(X.attrs["data-dc-print"]):null}catch{}let d=(v)=>{if(!K)return;let r=null;if(v==="print"&&!h){let a={paper:"a4"};try{let c=D2(a);if(c)r={defaults:a,widthPx:c.widthPx,heightPx:c.heightPx}}catch{}}if(G?.(K,v==="digital"?null:v,r),v==="web"&&I)Y?.(K,!1,void 0)},n=(v)=>{if(!K)return;let r={paper:"a4",...h,...v},a;try{a=D2(r)}catch{return}Q?.(K,a.widthPx,a.heightPx),Z?.(K,r)},x=(v,r)=>{if(!K)return;let a=Number.isFinite(r)?r:R,c=v&&Number.isFinite(a)?Math.round(a):void 0;Y?.(K,v,c)},m=(v)=>{let r=LS(I,v);if(r.kind==="resize")w(null,r.height);else if(r.kind==="promote-to-fixed")x(!0,r.height)},p=(v)=>{if(!K)return;W?.(K,v)};return O("section",{className:"st-cp-sec",children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Artboard"})}),O("div",{style:{display:"flex",gap:8,padding:"4px 12px"},children:[z(WX,{value:_??0,min:1,ariaLabel:"artboard width",lead:"W",steppers:!1,onCommit:(v)=>w(v,null)}),z(WX,{value:R??0,min:1,ariaLabel:"artboard height",lead:"H",steppers:!1,scrub:I,onCommit:m})]}),z("div",{style:{padding:"0 12px 8px"},children:f==="print"?O("select",{className:"st-cp-nsel","aria-label":"artboard paper preset",value:h?.paper??"",onChange:(v)=>n({paper:v.currentTarget.value}),children:[z("option",{value:"",disabled:!0,children:"Paper size…"}),L2.map((v)=>O("option",{value:v.id,children:[v.label," — ",v.width,"×",v.height,v.unit]},v.id))]}):f==="web"?O("select",{className:"st-cp-nsel","aria-label":"artboard breakpoint preset",value:P??"",onChange:(v)=>{let r=_5[v.currentTarget.value];if(r)w(r.width,null)},children:[z("option",{value:"",disabled:!0,children:P?`${_5[P].label} — ≤ ${_5[P].width}px`:"Breakpoint…"}),Object.entries(_5).map(([v,r])=>O("option",{value:v,children:[r.label," — ≤ ",r.width,"px breakpoint"]},v))]}):O("select",{className:"st-cp-nsel","aria-label":"artboard size preset",value:M??"",onChange:(v)=>{let r=_5[v.currentTarget.value];if(r)w(r.width,r.height)},children:[z("option",{value:"",disabled:!0,children:M?_5[M].label:"Preset size…"}),Object.entries(_5).map(([v,r])=>O("option",{value:v,children:[r.label," — ",r.width,"×",r.height]},v))]})}),z("div",{style:{padding:"0 12px 8px"},children:z(YN,{value:I?"fixed":"hug",ariaLabel:"artboard height sizing mode",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"}],onChange:(v)=>x(v==="fixed")})}),z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Kind"})}),z("div",{style:{padding:"0 12px 8px"},children:z(IW,{value:f,ariaLabel:"artboard kind",options:RB0.map(([v,r])=>({value:v,label:r})),onChange:d})}),f!=="print"&&K&&H?z("div",{style:{padding:"0 12px 8px"},children:O("select",{className:"st-cp-nsel","aria-label":"duplicate artboard at breakpoint width",value:"",onChange:(v)=>{let r=_5[v.currentTarget.value];if(r)H(K,r.width);v.currentTarget.value=""},children:[z("option",{value:"",disabled:!0,children:"Duplicate at width…"}),Object.entries(_5).map(([v,r])=>O("option",{value:v,children:[r.label," — ",r.width,"px"]},v))]})}):null,f==="print"?O(G0,{children:[z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Print"})}),z("div",{style:{padding:"0 12px 8px"},children:z(YN,{value:h?.orientation??"portrait",ariaLabel:"paper orientation",options:[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"}],onChange:(v)=>n({orientation:v})})}),z("div",{style:{padding:"0 12px 8px"},children:z(WX,{value:Number.isFinite(h?.bleedMm)?h.bleedMm:3,min:0,step:0.5,ariaLabel:"bleed, millimeters",lead:"B",steppers:!1,unitSlot:z("span",{className:"st-cp-numsuffix","aria-hidden":"true",children:"mm"}),onCommit:(v)=>n({bleedMm:v})})})]}):null,z("div",{className:"st-cp-sechd-row",children:z("span",{className:"st-cp-sechd",children:"Style"})}),O("div",{style:{padding:"4px 12px 8px",display:"flex",flexDirection:"column",gap:8},children:[(()=>{let v=D(k),r=/var\(\s*--/.test(k),a=r?k.replace(/^var\(\s*|\s*\)$/g,"").replace(/^--/,"").replace(/-/g," "):k;return z($V,{swatch:z(EF,{kind:"color",swatchClassName:"st-cp-cf-sw",groups:N("color"),current:k,activeDs:q,swatchBg:v,seedHex:kF(v)||"#000000",onPick:(c)=>p({background:c||null}),label:"artboard background colour"}),displayValue:a,bound:r,ariaLabel:"artboard background",onValue:(c)=>p({background:(c||"").trim()||null})})})(),z(IW,{value:C,ariaLabel:"artboard body layout",options:PB0.map(([v,r])=>({value:v,label:r})),onChange:(v)=>p({layout:v||null})}),O("div",{style:{display:"flex",gap:8},children:[z(WN,{value:/^var\(/.test($)?$:Number.parseFloat($)||0,tokens:F("space"),ariaLabel:"artboard padding",lead:"Pad",min:0,onChange:(v)=>p({padding:typeof v==="string"?v:v>0?v:null})}),z(WN,{value:/^var\(/.test(y)?y:Number.parseFloat(y)||0,tokens:F("space"),ariaLabel:"artboard gap",lead:"Gap",min:0,onChange:(v)=>p({gap:typeof v==="string"?v:v>0?v:null})})]})]})]})}var zT=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,IB0=new RegExp(zT.source,"gi");function kB0(X){if(!X||Array.isArray(X))return null;if(X.photoAsset)return X.photoAsset;let J=X.html||"";if((X.tag||"").toLowerCase()!=="img"){let W=[...new Set(J.match(IB0)||[])],G=[...new Set([...J.matchAll(/data-photo-asset="([^"]+)"/g)].map((Z)=>Z[1]))];if(G.length===1)return G[0];if(G.length===0&&W.length===1&&/<img/i.test(J))return W[0];return null}let Q=/data-photo-asset="([^"]+)"/.exec(J);if(Q)return Q[1];let Y=zT.exec(`${X.attrs?.src||""} ${J}`);return Y?Y[0]:null}function CB0({testId:X,selected:J,onClose:Q,layersTree:Y,componentMap:W,lockedKeys:G,onToggleLock:Z,onDetachInstance:H,canvasFile:K,onSelectLayer:U,onHoverLayer:q,onReorderLayer:B,layersBusyRef:N,cfg:F,onOptimistic:D,onRecordEdit:_,onReplaceMedia:R,onResizeArtboard:w,onSetArtboardHug:M,onSetArtboardStyle:P,onSetArtboardKind:I,onSetArtboardPrint:k,onDuplicateArtboard:$,onUndoRedo:C,editScope:y,tab:f,onTabChange:h,width:d,resizing:n,photoSel:x,photoRev:m,onPhotoEdit:p,onPhotoRemoveBackground:v,onPhotoRecordEdit:r,onPhotoUndoRedo:a,layersOnly:c=!1,hideLayersTab:U0=!1,cpMode:o,onSetCpMode:Z0}){let[e,N0]=u.useState("inspect"),K0=c?"layers":f??e,u0=(w0)=>{N0(w0),h?.(w0)},[Q8,o0]=u.useState(()=>new Set),[_8,A0]=u.useState(()=>new Map);u.useEffect(()=>{let w0=Array.isArray(J)?J[0]:J,L0=w0?.id;if(!L0||!Y?.nodes)return;let d0=w0.index,V8=null,O8=[];if(function a8(E8,N9){for(let Y9 of E8||[]){let e7=`${Y9.id}:${Y9.index}`;if(!Y9.synthetic&&Y9.id===L0&&(d0==null||Y9.index===d0))return V8=e7,O8.push(...N9),!0;if(Y9.children&&Y9.children.length&&a8(Y9.children,[...N9,e7]))return!0}return!1}(Y.nodes,[]),!V8)return;if(O8.length)o0((a8)=>{let E8=!1,N9=new Set(a8);for(let Y9 of O8)if(N9.delete(Y9))E8=!0;return E8?N9:a8});requestAnimationFrame(()=>{try{document.querySelector(`.st-layer--row[data-layer-key="${V8}"]`)?.scrollIntoView({block:"nearest"})}catch{}})},[J,Y]);let r0=(w0)=>{let L0=`${w0.id}:${w0.index}`;return _8.has(L0)?_8.get(L0):!!w0.hidden},[P0,K8]=u.useState(null),[F8,D8]=u.useState(""),W8=(w0,L0)=>{if(!K||!w0?.id)return;fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:K,id:w0.id,attr:"data-dc-element",value:L0})}).then((d0)=>d0.json().catch(()=>({}))).then((d0)=>{if(!d0.ok)return;_?.({op:"attr",canvas:K,id:w0.id,key:"data-dc-element",before:w0.dcElement??null,after:L0})}).catch(()=>{})},A8=B?(w0,L0,d0)=>{if(N?.current)return;if(w0?.synthetic||L0?.synthetic)return;let V8=d0==="before"?`before ${L0.label}`:d0==="after"?`after ${L0.label}`:`into ${L0.label}`;D8(`Moved ${w0.label} ${V8}`),B(w0.id,L0.id,d0,{idIndex:w0.index,refIndex:L0.index})}:void 0,i8=()=>{let w0=[];return function L0(d0,V8,O8){(d0||[]).forEach((a8,E8)=>{if(w0.push({node:a8,depth:V8,parentNode:O8,siblings:d0,pos:E8}),a8.children&&a8.children.length&&!Q8.has(`${a8.id}:${a8.index}`))L0(a8.children,V8+1,a8)})}(Y?.nodes,0,null),w0},P9=(w0)=>{if(w0.key!=="ArrowUp"&&w0.key!=="ArrowDown")return;if(!Z8)return;let L0=i8(),d0=L0.findIndex((E8)=>E8.node.id===Z8.id&&E8.node.index===Z8.index);if(d0<0)return;let V8=w0.key==="ArrowDown"?1:-1,O8=L0[d0];if(!w0.altKey){let E8=L0[d0+V8];if(E8)w0.preventDefault(),U?.(E8.node);return}if(!A8||!Array.isArray(O8.siblings))return;w0.preventDefault();let a8=(E8)=>E8&&E8.children&&E8.children.length&&!Q8.has(`${E8.id}:${E8.index}`);if(!w0.shiftKey){if(V8<0&&O8.pos>0)A8(O8.node,O8.siblings[O8.pos-1],"before");else if(V8>0&&O8.pos<O8.siblings.length-1)A8(O8.node,O8.siblings[O8.pos+1],"after");return}if(V8>0){let E8=O8.siblings[O8.pos+1];if(E8)A8(O8.node,E8,a8(E8)?"inside-start":"after");else if(O8.parentNode)A8(O8.node,O8.parentNode,"after")}else{let E8=O8.siblings[O8.pos-1];if(E8)A8(O8.node,E8,a8(E8)?"inside-end":"before");else if(O8.parentNode)A8(O8.node,O8.parentNode,"before")}},l0=u.useRef(null),i0=u.useRef(null),j0=(w0,L0,d0)=>{if(!A8||w0.button!==0||w0.metaKey||w0.ctrlKey||w0.shiftKey||w0.altKey)return;if(N?.current)return;let{clientX:V8,clientY:O8}=w0,a8=new Set([d0]);(function p8(H7){(H7.children||[]).forEach((z7)=>{a8.add(`${z7.id}:${z7.index}`),p8(z7)})})(L0);let E8=14,N9=6,Y9=[];(function p8(H7,z7){(H7||[]).forEach((P7)=>{let T9=`${P7.id}:${P7.index}`;if(Y9.push({node:P7,key:T9,id:P7.id,depth:z7,tag:P7.tag}),P7.children&&P7.children.length&&!Q8.has(T9))p8(P7.children,z7+1)})})(Y?.nodes,0);let e7=new Map(Y9.map((p8)=>[p8.key,p8])),E0=!1,h8=(p8)=>{if(!E0){if(Math.hypot(p8.clientX-V8,p8.clientY-O8)<4)return;E0=!0}let H7=p8.clientX-V8,z7=p8.clientY-O8,P7=null,T9=[].slice.call(document.querySelectorAll(".st-layer--row[data-layer-key]")).map((X0)=>({rect:X0.getBoundingClientRect(),it:e7.get(X0.getAttribute("data-layer-key"))})).filter((X0)=>X0.it&&X0.it.key!==d0);if(T9.length){let X0=T9[0].rect.left,_0=T9[0].rect.right,B0=T9.length;for(let L7=0;L7<T9.length;L7++)if(p8.clientY<T9[L7].rect.top+T9[L7].rect.height/2){B0=L7;break}let S0=T9[B0-1]?.it||null,t0=T9[B0]?.it||null,j8=Math.round((p8.clientX-X0-N9)/E8),g8=S0?S0.depth+(wB0.has(S0.tag)?0:1):0,t8=t0?t0.depth:0,G9=Math.max(t8,Math.min(j8,g8)),w9=null,F7="before",g9=0;if(!S0){if(t0)w9=t0,F7="before",g9=t0.depth}else if(G9>S0.depth)w9=S0,F7="inside-start",g9=S0.depth+1;else if(G9===S0.depth)w9=S0,F7="after",g9=S0.depth;else{for(let L7=B0-1;L7>=0;L7--)if(T9[L7].it.depth===G9){w9=T9[L7].it;break}if(!w9)w9=S0;F7="after",g9=G9}if(w9&&w9.key!==d0&&!a8.has(w9.key)){let L7=S0?T9[B0-1].rect.bottom:T9[0].rect.top,mX=X0+N9+g9*E8;P7={refId:w9.id,position:F7,node:w9.node,y:L7,left:mX,w:Math.max(24,_0-mX)}}}let S6={key:d0,node:L0,dx:H7,dy:z7,target:P7};l0.current=S6,K8(S6)},F9=()=>{window.removeEventListener("pointermove",h8),window.removeEventListener("pointerup",l7),window.removeEventListener("keydown",c6,!0)},b9=()=>{let p8=(H7)=>{H7.preventDefault(),H7.stopImmediatePropagation(),document.removeEventListener("click",p8,!0)};document.addEventListener("click",p8,!0),setTimeout(()=>document.removeEventListener("click",p8,!0),300)},l7=()=>{F9();let p8=l0.current;if(l0.current=null,K8(null),E0&&p8?.target)b9(),A8(p8.node,p8.target.node,p8.target.position)},c6=(p8)=>{if(p8.key!=="Escape")return;if(p8.preventDefault(),p8.stopImmediatePropagation(),F9(),l0.current=null,K8(null),E0)b9()};window.addEventListener("pointermove",h8),window.addEventListener("pointerup",l7),window.addEventListener("keydown",c6,!0)},I0=(w0)=>o0((L0)=>{let d0=new Set(L0);if(d0.has(w0))d0.delete(w0);else d0.add(w0);return d0}),T8=(w0)=>{let L0=`${w0.id}:${w0.index}`,d0=r0(w0),V8=!d0;if(A0((O8)=>new Map(O8).set(L0,V8)),D?.({id:w0.id,artboardId:Y?.artboardId??null,index:w0.index,prop:"display",value:V8?"none":null}),!K||!w0.id)return;fetch("/_api/edit-css",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(V8?{canvas:K,id:w0.id,property:"display",value:"none"}:{canvas:K,id:w0.id,property:"display",reset:!0})}).catch(()=>{}),_?.({op:"css",canvas:K,id:w0.id,key:"display",before:d0?"none":null,after:V8?"none":null})},Z8=Array.isArray(J)?J[0]:J,z0=x?{asset:x.asset,kind:"annotation-image"}:(()=>{let w0=kB0(Z8);return w0?{asset:w0,kind:"artboard-img"}:null})(),f0=z0?.kind==="annotation-image",L8=(w0)=>{if(!(w0.metaKey||w0.ctrlKey)||w0.altKey)return;let L0=w0.key.toLowerCase();if(L0==="z")w0.preventDefault(),a?.(w0.shiftKey?"redo":"undo");else if(L0==="y")w0.preventDefault(),a?.("redo")},n8=f0?"photo":K0==="photo"&&!z0?"inspect":K0,k8=(w0,L0,d0)=>O("button",{type:"button",className:"st-rp-tab"+(n8===w0?" is-active":""),onClick:()=>u0(w0),children:[z(E9,{name:d0,size:14}),L0]}),q8=Z8?.bounds||null;return O("aside",{className:"st-rpanel"+(n?" is-resizing":""),style:d?{width:d,flexBasis:d}:void 0,"aria-label":"Inspector","data-tour":"inspector","data-testid":X,children:[O("div",{className:"st-rp-tabs","data-tour":"inspector-tabs",style:c?{display:"none"}:void 0,children:[f0?k8("photo","Photo","image"):O(G0,{children:[k8("inspect","Inspect","sliders"),!U0&&k8("layers","Layers","layers"),k8("css","CSS","code"),z0?k8("photo","Photo","image"):null]}),z("button",{type:"button",className:"st-iconbtn","aria-label":"Close inspector",style:{marginLeft:"auto"},onClick:Q,children:z(E9,{name:"x",size:14})})]}),Z8?.id&&!(Array.isArray(J)&&J.length>1)&&y?O("div",{className:`st-scope st-scope--${y.scope}`,title:y.scope==="shared"?`Editing this element's style changes ${y.affects} place${y.affects===1?"":"s"}${y.componentName?` (component ${y.componentName})`:""}. Move/resize a whole instance to keep it local.`:"This edit affects only this element.",children:[z("span",{className:"st-scope-dot","aria-hidden":"true"}),y.scope==="shared"?`Shared${y.componentName?` · ${y.componentName}`:""} · edits ${y.affects} place${y.affects===1?"":"s"}`:"Local · this element only",y.scope==="shared"&&H?z("button",{type:"button",className:"st-scope-detach",title:"Clone this component for this instance only — edits stop affecting the other places",onClick:()=>H(Z8.id,Z8.index),children:"Detach"}):null]}):null,z("div",{className:"st-rp-body",children:n8==="photo"&&z0?z("div",{onKeyDown:L8,children:z(_h,{asset:z0.asset,ColorPicker:u00,StIcon:E9,onEdit:(w0)=>p?.(z0.asset,w0),onRemoveBackground:v,onRecordEdit:(w0,L0)=>r?.(z0.asset,w0,L0)},`${z0.asset}:${m??0}`)}):!Z8&&!(n8==="layers"&&Y?.nodes?.length)?z("div",{className:"st-rp-empty",children:O("p",{children:["Press ",z(wX,{children:"V"}),", then click an element to select it — or ",z(wX,{children:"⌘"}),"-click straight from Browse."]})}):Z8&&n8==="inspect"?O(G0,{children:[z("div",{className:"st-rp-hd",children:Z8.selector||Z8.tag||"element"}),O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Pos"}),O("div",{className:"st-insp-fields",children:[O("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"X"}),z("input",{value:q8?Math.round(q8.x):"—",readOnly:!0,"aria-label":"x position"})]}),O("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"Y"}),z("input",{value:q8?Math.round(q8.y):"—",readOnly:!0,"aria-label":"y position"})]})]})]}),O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Size"}),O("div",{className:"st-insp-fields",children:[O("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"W"}),z("input",{value:q8?Math.round(q8.w):"—",readOnly:!0,"aria-label":"width"})]}),O("span",{className:"st-fmini",children:[z("span",{className:"st-mtag",children:"H"}),z("input",{value:q8?Math.round(q8.h):"—",readOnly:!0,"aria-label":"height"})]})]})]}),O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Tag"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-0)"},children:Z8.tag||"—"})})]}),Z8.classes?O("div",{className:"st-insp-row",children:[z("span",{className:"st-insp-label",children:"Class"}),z("div",{className:"st-insp-fields",children:z("span",{className:"st-mono",style:{fontSize:11,color:"var(--fg-1)"},children:Z8.classes})})]}):null,z(EB0,{el:Z8})]}):n8==="layers"?O(G0,{children:[O("div",{className:"st-rp-hd",children:["Layers",Y?.nodes?.length?"":" · ancestry"]}),Y?.nodes?.length?O(G0,{children:[A8?z("div",{className:"st-rp-hint","aria-hidden":"true",children:"Drag or ↑/↓ select · Alt+↑/↓ move · Alt+Shift+↑/↓ move across"}):null,z("div",{role:"tree","aria-label":"Artboard layers",tabIndex:0,ref:i0,onKeyDown:P9,children:Y.nodes.map((w0,L0)=>z(l00,{node:w0,depth:0,selectedId:Z8?.id,selectedIndex:Z8?.index,collapsed:Q8,hiddenOverride:_8,onToggle:I0,onSelect:(d0)=>{U?.(d0),i0.current?.focus()},onHover:(d0)=>q?.(d0),onToggleVisibility:T8,onReorder:A8,onRowPointerDown:j0,dragState:P0,componentMap:W,lockedKeys:G,onToggleLock:Z,onRename:W8},`${w0.id}:${w0.index}`))}),P0?.target?z("div",{className:"st-layer-divider","aria-hidden":"true",style:{left:P0.target.left,top:P0.target.y-1,width:P0.target.w}}):null,z("div",{className:"sr-only",role:"status","aria-live":"polite",children:F8})]}):Z8&&Array.isArray(Z8.dom_path)&&Z8.dom_path.length?Z8.dom_path.map((w0,L0)=>O("div",{className:"st-layer"+(L0===Z8.dom_path.length-1?" is-sel":""),style:{paddingLeft:8+L0*12},children:[z(E9,{name:"square",size:13}),w0]},L0)):z("div",{className:"st-rp-empty",children:"Select an element (⌘-click in the canvas) to see its layer tree."})]}):!Z8.id&&p00(Z8)?z(TB0,{el:Z8,cfg:F,onResizeArtboard:w,onSetArtboardHug:M,onSetArtboardStyle:P,onSetArtboardKind:I,onSetArtboardPrint:k,onDuplicateArtboard:$}):z(DB0,{el:Z8,cfg:F,onOptimistic:D,onRecordEdit:_,onReplaceMedia:R,onUndoRedo:C,mode:o,onSetMode:Z0})})]})}function $B0(){let[X,J]=u.useState([]),[Q,Y]=u.useState("Design"),[W,G]=u.useState([]),[Z,H]=u.useState(null),[K,U]=u.useState(null),q=u.useCallback((j)=>{U(j)},[]),[B,N]=u.useState(null),F=u.useRef(null);u.useEffect(()=>{F.current=B},[B]);let[D,_]=u.useState(null);u.useEffect(()=>{let j=Array.isArray(B)?B.length===1?B[0]:null:B,b=j&&typeof j.id==="string"?j.id:null;if(!b||!Z){_(null);return}let t=new AbortController,W0=new URLSearchParams({canvas:Z,id:b});return fetch(`/_api/edit-scope?${W0}`,{signal:t.signal}).then((F0)=>F0.ok?F0.json():null).then((F0)=>{if(F0?.ok)_(F0)}).catch(()=>{}),()=>t.abort()},[B,Z]);let R=u.useRef(0),w=u.useRef([]),M=u.useCallback((j)=>{if(!j?.id||!j.file)return;for(let b of w.current)clearTimeout(b);w.current=[50,450,1200,2500,5000].map((b)=>setTimeout(()=>{let t=F.current,W0=Array.isArray(t)?t[0]:t;if(!W0||W0.id!==j.id||W0.file!==j.file)return;let F0=m8.current.get(j.file);if(!F0?.contentWindow)return;try{F0.contentWindow.postMessage({dgn:"select-by-id",id:j.id,artboardId:j.artboardId??null,index:j.index??0},"*")}catch{}},b))},[]),P=u.useRef([]),I=u.useCallback((j,b)=>{if(!j||!b)return;for(let t of P.current)clearTimeout(t);P.current=[50,450,1200,2500,5000].map((t)=>setTimeout(()=>{let W0=F.current,F0=Array.isArray(W0)?W0[0]:W0;if(!F0||F0.artboardId!==j||F0.file!==b)return;let q0=m8.current.get(b);if(!q0?.contentWindow)return;try{q0.contentWindow.postMessage({dgn:"select-by-id",artboardId:j},"*")}catch{}},t))},[]),k=u.useRef(null),$=u.useRef(null),C=u.useRef(null),y=u.useRef(null),f=u.useRef(!1),h=u.useRef(null),[d,n]=u.useState(null),[x,m]=u.useState(null),p=u.useRef({canvas:null,at:0});u.useEffect(()=>{if(!Z||!d)return;let j=Date.now(),b=p.current;if(b.canvas===Z&&j-b.at<1500)return;p.current={canvas:Z,at:j},fetch(`/_api/component-map?canvas=${encodeURIComponent(Z)}`).then((t)=>t.json()).then((t)=>{if(t?.ok&&t.map&&typeof t.map==="object")m(t.map);else m(null)}).catch(()=>m(null))},[Z,d]);let[v,r]=u.useState(!1),[a,c]=u.useState(null),[U0,o]=u.useState(null),[Z0,e]=u.useState(null),[N0,K0]=u.useState(null),[u0,Q8]=u.useState(null),[o0,_8]=u.useState(!1),[A0,r0]=u.useState(!1),[P0,K8]=u.useState(null),[F8,D8]=u.useState(""),[W8,A8]=u.useState(null),[i8,P9]=u.useState(null),l0=u.useRef(null),i0=N00("maude-sb-w",{min:200,max:420,def:252}),j0=N00("maude-rp-w",{min:260,max:480,def:304}),[I0,T8]=u.useState(null),Z8=u.useRef(null);u.useEffect(()=>{if(!I0)return;let j=(t)=>{let W0=Z8.current?.getBoundingClientRect();if(!W0)return;if(I0==="sb")i0.setW(t.clientX-W0.left);else j0.setW(W0.right-t.clientX)},b=()=>T8(null);return window.addEventListener("pointermove",j),window.addEventListener("pointerup",b),()=>{window.removeEventListener("pointermove",j),window.removeEventListener("pointerup",b)}},[I0,i0.setW,j0.setW]);let z0=u.useCallback((j)=>{clearTimeout(l0.current),l0.current=setTimeout(()=>{P9((b)=>b===j?null:b)},2500)},[]);u.useEffect(()=>{if(!i8)return;let j=setTimeout(()=>P9(null),15000);return()=>clearTimeout(j)},[i8]);let[f0,L8]=u.useState({designRel:".design",cloud:void 0}),n8=!!f0.cloud,k8=!f0.cloud&&!!Z0?.credentialed,q8=n8||k8,w0=q8?0:N0?.files?.length||0,L0=u.useRef(q8);L0.current=q8;let d0=!!f0.readOnly,V8=u.useCallback(()=>{fetch("/_config").then((j)=>j.json()).then((j)=>{let b=(j.designRoot||".design").replace(/^\/+|\/+$/g,"");L8((t)=>({...t,designRel:b,tokensCssRel:j.tokensCssRel,designSystems:j.designSystems,canvasOrigin:j.canvasOrigin,readOnly:!!j.readOnly,canvasToken:j.canvasToken,version:j.version,cloud:j.cloud??null,exportLane:j.exportLane}))}).catch(()=>{})},[]);u.useEffect(()=>{V8()},[V8]),u.useEffect(()=>{let j=!1;return fetch("/_sync-status").then((b)=>b.json()).then((b)=>{if(j||!b||b.linked===!1)return;o(b)}).catch(()=>{}),()=>{j=!0}},[]),u.useEffect(()=>{if(q8){K0(null);return}let j=!1;return fetch("/_api/git/status").then((b)=>b.json()).then((b)=>{if(!j&&b)K0(b)}).catch(()=>{}),()=>{j=!0}},[q8]);let[O8,a8]=u.useState({}),[E8,N9]=u.useState(null),[Y9,e7]=u.useState(!1),[E0,h8]=u.useState("open"),[F9,b9]=u.useState(D20),[l7,c6]=u.useState(()=>{return JT(Y00,"advanced")==="designer"?"designer":"advanced"});u.useEffect(()=>{try{localStorage.setItem(Y00,JSON.stringify(l7))}catch{}},[l7]);let[p8,H7]=u.useState(null),[z7,P7]=u.useState(()=>XH(W00,!0)),[T9,S6]=u.useState(()=>XH(J00,!1)),[X0,_0]=u.useState(()=>JT(Q00,{})),[B0,S0]=u.useState(!1),[t0,j8]=u.useState(!1);u.useEffect(()=>{if(!W9())return;let j=mf(()=>j8(!0));return()=>{j.then((b)=>b()).catch(()=>{})}},[]);let[g8,t8]=u.useState(!1),[G9,w9]=u.useState(!1),[F7,g9]=u.useState(!1),[L7,mX]=u.useState(!1),[mQ,uQ]=u.useState(!1),{report:ZQ}=vA(W9()),[HQ,k9]=u.useState(!1),[X6,lQ]=u.useState(!1),[D7,A6]=u.useState(null),[EX,A5]=u.useState(!1),[j7,KX]=u.useState(!1),[PX,v7]=u.useState(!1),[r4,H6]=u.useState(!1),[C9,RX]=u.useState(()=>JT(z00,$K)),[I9,l9]=u.useState(()=>{try{let j=localStorage.getItem(K00);if(j==="separate"||j==="in-inspector")return j}catch{}return"separate"}),[i6,zQ]=u.useState(!1),[J6,vJ]=u.useState([]),[HJ,TX]=u.useState(0),[w5,uX]=u.useState(!1),[E5,a4]=u.useState(!1),[i,Q0]=u.useState(!1),[D0,v0]=u.useState(1),[T0,H8]=u.useState(216),[Y8,V9]=u.useState(null),[s8,o6]=u.useState([]),[lX,b6]=u.useState([]),[P5,pQ]=u.useState([]),[R5,s4]=u.useState(0),T5=u.useRef(0);u.useEffect(()=>{T5.current=HJ},[HJ]);let[o9,UX]=u.useState(null),fJ=u.useRef(null);u.useEffect(()=>{fJ.current=o9},[o9]);let f7=u.useMemo(()=>lA(J6,{artboardId:[o9,Y8],total:R5}),[J6,o9,Y8,R5]),P8=u.useRef(null);u.useEffect(()=>{P8.current=f7},[f7]);let y9=u.useMemo(()=>GK(J6,f7)?.fps||30,[J6,f7]),[j9,pX]=u.useState(null),[VX,dW]=u.useState(0),y6=u.useCallback((j,b)=>{if(/concurrent edit|changed since it was read/i.test(b||""))l8("Timeline changed — reloaded, try again."),dW((t)=>t+1);else l8(`${j}: ${b||"failed"}`)},[]),[zJ,I5]=u.useState(!1),[jK,t4]=u.useState(!1),[vK,KJ]=u.useState(!1),cW=u.useRef(zJ);u.useEffect(()=>{if(cW.current=zJ,zJ){KJ(!1);try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch{}}},[zJ]);let QH=u.useCallback(()=>{if(!cW.current||document.hidden)KJ(!0),V00("Claude finished","Your assistant turn is ready in Maude.")},[]),xJ=u.useRef(0),e4=u.useCallback(()=>{if(!cW.current||document.hidden){KJ(!0);let j=Date.now();if(j-xJ.current<N20)return;xJ.current=j,V00("Maude needs your input","Claude is waiting on an approval or a question in Maude.")}},[]),[k5,KQ]=u.useState("inspect"),[fK,XY]=u.useState(null),hJ=u.useRef({undo:[],redo:[]}),[xK,hK]=u.useState(0),[gJ,iW]=u.useState(()=>{try{return localStorage.getItem("maude-auto-open-inspector")!=="0"}catch{return!0}}),YH=u.useRef(gJ);u.useEffect(()=>{YH.current=gJ;try{localStorage.setItem("maude-auto-open-inspector",gJ?"1":"0")}catch{}},[gJ]);let WH=u.useRef(!1);u.useEffect(()=>{WH.current=PX||Y9||o0||A0||zJ},[PX,Y9,o0,A0,zJ]);let oW=u.useRef({open:{},side:$K});oW.current={open:{tree:z7,layers:r4,inspector:PX,comments:Y9,changes:o0,sync:A0,assistant:zJ},side:C9};let dQ=u.useCallback((j,b)=>{if(j==="tree")P7(b);else if(j==="layers")H6(b);else if(j==="inspector")v7(b);else if(j==="comments")e7(b);else if(j==="changes")_8(b);else if(j==="sync")r0(b);else if(j==="assistant")I5(b)},[]),nW=u.useCallback((j)=>oW.current.side?.[j]||$K[j],[]),IX=u.useCallback((j)=>{let b=nW(j);dQ(j,!0);for(let t of GT)if(t.id!==j&&nW(t.id)===b)dQ(t.id,!1)},[dQ,nW]),C5=u.useCallback((j)=>{if(oW.current.open?.[j])dQ(j,!1);else IX(j)},[IX,dQ]),mJ=IX,z6=C5,cQ=u.useCallback((j)=>{if(!YH.current)return;if(d0)return;if(!j||!j.id)return;if(WH.current)return;mJ("inspector"),KQ("css")},[mJ,d0]),UQ=u.useCallback(()=>zQ((j)=>!j),[]),VQ=mh(HT),JY=Ph({enabled:f0.cloud===null||f0.exportLane==="remote"}),[QY,rW]=u.useState(!1),[dX,GH]=u.useState(!1);u.useEffect(()=>{if(!W9())return;let j=!0;return df().then((b)=>{if(!j)return;if(rW(!!b),!b&&!XH(X00,!1))GH(!0)}).catch(()=>{}),()=>{j=!1}},[]);let YY=u.useCallback(()=>{GH(!1);try{localStorage.setItem(X00,"1")}catch{}},[]),[gK,ZH]=u.useState(null);u.useEffect(()=>{if(!W9())return;let j;return rf((b)=>ZH(b&&typeof b==="object"?b:{})).then((b)=>{j=b}).catch(()=>{}),()=>{try{j?.()}catch{}}},[]);let[qQ,HH]=u.useState(null),[$5,aW]=u.useState(()=>!XH(ee,!1)),S5=u.useCallback((j)=>{HH(Array.isArray(j)&&j.length?j:null)},[]),mK={setup:(j)=>{if(!j)return;if((j.canvas||j.requireSelection)&&W.length===0)IX("tree"),setTimeout(()=>{try{document.querySelector('.st-sidebar [role="treeitem"]')?.click()}catch{}},80);if(j.inspector||j.tab||j.requireSelection)mJ("inspector");if(j.tab)KQ(j.tab);if(j.changes)mJ("changes")}},sW=u.useCallback(()=>{aW(!1);try{localStorage.setItem(ee,"1")}catch{}},[]),[BQ,zH]=u.useState(()=>XH(H00,!0)),[KH,uK]=u.useState(!1),[uJ,UH]=u.useState(()=>XH(G00,!1)),[j6,qX]=u.useState(()=>XH(Z00,!1)),[n6,tW]=u.useState(!1),[lK,lJ]=u.useState(!1),[iQ,NQ]=u.useState(0),[oQ,eW]=u.useState(null),[XG,WY]=u.useState(!1),nQ=u.useRef(null),GY=u.useRef(null),m8=u.useRef(new Map),S8=u.useCallback((j)=>{let b=Z?m8.current.get(Z):null;if(!b||!b.contentWindow)return;try{b.contentWindow.postMessage(j,"*")}catch{}},[Z]),ZY=u.useRef(0),cX=u.useCallback(({format:j,artboardIds:b=null,scale:t=1,onProgress:W0,timeoutMs:F0=120000})=>new Promise((q0,k0)=>{let l=Z?m8.current.get(Z):null;if(!l||!l.contentWindow){k0(Error("no active canvas to capture"));return}let M0=l.contentWindow;ZY.current+=1;let O0=`cap-${Date.now().toString(36)}-${ZY.current}`,c0=!1,z8=(M9,k7)=>{if(c0)return;c0=!0,window.removeEventListener("message",B8),clearTimeout(Q6),M9(k7)},B8=(M9)=>{if(M9.source!==M0)return;let k7=M9.data;if(!k7||k7.id!==O0)return;if(k7.dgn==="export-capture-progress")W0?.(k7.current,k7.total);else if(k7.dgn==="export-capture-done")z8(q0,Array.isArray(k7.items)?k7.items:[]);else if(k7.dgn==="export-capture-error")z8(k0,Error(k7.message||"capture failed"))},Q6=setTimeout(()=>z8(k0,Error("capture timed out — the canvas did not answer")),F0);window.addEventListener("message",B8);try{M0.postMessage({dgn:"export-capture",id:O0,format:j,artboardIds:b,scale:t},"*")}catch(M9){z8(k0,M9)}}),[Z]),H0=u.useCallback((j,b)=>S8({dgn:"photo-preview",asset:j,edit:b}),[S8]),pK=u.useCallback((j,b,t)=>{hJ.current.undo.push({asset:j,before:b,after:t}),hJ.current.redo.length=0},[]),rQ=u.useCallback((j)=>{let b=j?hJ.current.redo:hJ.current.undo;if(!b.length)return!1;let t=b.pop();(j?hJ.current.undo:hJ.current.redo).push(t);let W0=(j?t.after:t.before)||{};return H0(t.asset,W0),fetch(`/_api/photo-edit?asset=${encodeURIComponent(t.asset)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(W0)}).catch(()=>{}),hK((F0)=>F0+1),!0},[H0]),JG=u.useCallback(async(j)=>{S8({dgn:"photo-busy",asset:j,busy:!0});try{let b=await fetch(`/${j.replace(/^\/+/,"")}`);if(!b.ok)return null;let t=await b.blob(),{removeBackground:W0}=await Promise.resolve().then(() => (te(),se)),F0=await W0(t),q0=await fetch("/_api/asset",{method:"POST",headers:{"content-type":F0.type||"image/png"},body:F0}),k0=await q0.json().catch(()=>({}));if(q0.ok&&k0.path)return{maskAsset:k0.path};return null}catch(b){return console.error("[photo] background removal failed",b),null}finally{S8({dgn:"photo-busy",asset:j,busy:!1})}},[S8]);u.useEffect(()=>{let j=(W0)=>Array.from(W0.dataTransfer?.types??[]).includes("Files"),b=(W0)=>{if(j(W0))W0.preventDefault()},t=(W0)=>{if(j(W0))W0.preventDefault()};return document.addEventListener("dragover",b),document.addEventListener("drop",t),()=>{document.removeEventListener("dragover",b),document.removeEventListener("drop",t)}},[]);let R7=u.useRef({});R7.current={open:i6,comps:J6,frame:HJ,total:R5,playing:w5,compId:f7,muted:i,loop:E5,sequences:s8,post:S8,canvas:Z};let O7=u.useRef({undo:[],redo:[]}),T7=u.useCallback((j,b,t)=>{if(typeof b!=="number")return;if(O7.current.undo.push({canvas:j,seq:b,label:t}),O7.current.redo=[],O7.current.undo.length>50)O7.current.undo.shift()},[]),aQ=u.useCallback((j)=>{let b=O7.current,t=j==="undo"?b.undo:b.redo,W0=j==="undo"?b.redo:b.undo,F0=R7.current.canvas,q0=-1;for(let l=t.length-1;l>=0;l--)if(t[l].canvas===F0){q0=l;break}if(q0<0){l8(j==="undo"?"Nothing to undo on this timeline.":"Nothing to redo.");return}let k0=t[q0];fetch("/_api/reorder-revert",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:k0.canvas,seq:k0.seq,dir:j})}).then((l)=>l.json().catch(()=>({}))).then((l)=>{if(t.splice(q0,1),l?.ok)W0.push(k0),l8(`${j==="undo"?"Undid":"Redid"}: ${k0.label}`,!0);else l8(`${j==="undo"?"Undo":"Redo"} skipped: ${l?.error||"failed"}`)}).catch(()=>l8(`${j==="undo"?"Undo":"Redo"} failed: network error`))},[]),w6=u.useCallback((j,b)=>{let t=j?.ok&&Array.isArray(j.clips)?j.clips.filter((W0)=>W0.kind==="sequence"):[];if(b==null)return null;if(typeof b==="object")return(b.stableId?t.find((W0)=>W0.stableId===b.stableId):null)||(Number.isInteger(b.index)?t[b.index]:null)||null;if(typeof b==="string")return t.find((W0)=>W0.stableId===b)||null;return t[b]||null},[]),HY=u.useCallback((j)=>{let b=R7.current.canvas;if(!b||b===c8)return;let t=fJ.current||void 0,W0=`/_api/comp-clips?canvas=${encodeURIComponent(b)}${t?`&artboardId=${encodeURIComponent(t)}`:""}`;fetch(W0).then((F0)=>F0.json().catch(()=>({}))).then((F0)=>{let q0=w6(F0,j);if(!q0?.stableId)return null;return fetch("/_api/remove-sequence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:b,artboardId:t,stableId:q0.stableId,contentHash:q0.contentHash})})}).then((F0)=>F0?F0.json():null).then((F0)=>{if(F0&&!F0.ok)console.warn("[remove-clip]",F0.error||"failed"),y6("Remove refused",F0.error);else if(F0?.ok){if(l8("Clip removed.",!0),F0.seq!=null)T7(b,F0.seq,"remove clip");pX(null)}}).catch(()=>l8("Remove failed: network error"))},[w6,T7]),FQ=u.useCallback((j,b,t)=>{let W0=R7.current.canvas;if(!W0||W0===c8)return;let F0=fJ.current||void 0,q0=`/_api/comp-clips?canvas=${encodeURIComponent(W0)}${F0?`&artboardId=${encodeURIComponent(F0)}`:""}`;fetch(q0).then((k0)=>k0.json().catch(()=>({}))).then((k0)=>{let l=k0?.ok&&Array.isArray(k0.clips)?k0.clips:[],M0=j?.transition?l.find((O0)=>O0.kind==="transition"&&O0.stableId===j.stableId)||null:w6(k0,j);if(!M0?.stableId)return null;return fetch("/_api/clip-edit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:W0,artboardId:F0,stableId:M0.stableId,contentHash:M0.contentHash,verb:b,...t})})}).then((k0)=>k0?k0.json():null).then((k0)=>{if(k0&&!k0.ok)console.warn("[clip-edit]",b,k0.error||"failed"),y6(`${b} refused`,k0.error);else if(k0?.ok){let l={speed:"set speed","trim-in":"trim in-point",audio:"clip audio","detach-audio":"detach audio",framing:"crop clip",grade:"grade clip",transition:"edit transition",split:"split clip","insert-transition":"add transition","remove-transition":"remove transition","set-text":"edit text","to-overlay":"move to overlay layer","to-storyline":"move to storyline","layer-order":"reorder layers"};if(l8(`Applied: ${l[b]||b}.`,!0),k0.seq!=null)T7(W0,k0.seq,l[b]||b)}}).catch(()=>l8(`${b} failed: network error`))},[w6,T7,y6]),[pJ,zY]=u.useState(null),dJ=u.useCallback((j,b="")=>new Promise((t)=>{zY({title:j,value:b,resolve:t})}),[]),a0=u.useCallback((j)=>{zY((b)=>{return b?.resolve?.(j),null})},[]),iX=u.useCallback((j,b)=>{let t=R7.current.canvas;if(!t||t===c8||!b||!String(b).trim())return;I7({type:"comments-add",payload:{file:t,text:String(b).trim(),selector:"",dom_path:[],tag:"",classes:"",bounds:null,html_excerpt:"",timeline:j}}),l8("Comment added.",!0)},[]);R7.current.selected=j9,R7.current.setSelected=pX,R7.current.removeClip=HY,R7.current.clipVerb=FQ,R7.current.addComment=iX,R7.current.askText=dJ,u.useEffect(()=>{let j=(b)=>{let t=R7.current;if(!t.open||!t.comps?.length)return;let W0=b.target,F0=W0?.tagName;if(F0==="INPUT"&&W0?.type!=="range")return;if(F0==="TEXTAREA"||F0==="SELECT"||W0?.isContentEditable)return;let q0=GK(t.comps,t.compId)?.fps||30,k0=Math.max(1,t.total),l=(O0)=>{let c0=Math.max(0,Math.min(k0-1,Math.round(O0)));TX(c0),uX(!1),t.post({dgn:"timeline-seek",frame:c0,id:t.compId})},M0=()=>{let O0=new Set([0,k0-1]);for(let c0 of t.sequences||[]){O0.add(c0.from);for(let z8 of c0.keyframes||[])O0.add(z8.from),O0.add(z8.to)}return[...O0].filter((c0)=>c0>=0&&c0<k0).sort((c0,z8)=>c0-z8)};if((b.metaKey||b.ctrlKey)&&(b.key==="z"||b.key==="Z")){b.preventDefault(),aQ(b.shiftKey?"redo":"undo");return}if(b.key==="Escape"){if(t.selected!=null)b.preventDefault(),t.setSelected?.(null);return}if((b.key==="Delete"||b.key==="Backspace")&&t.selected!=null){b.preventDefault(),t.removeClip?.({stableId:t.selected});return}if((b.metaKey||b.ctrlKey)&&(b.key==="b"||b.key==="B")){b.preventDefault();let O0=t.selected!=null?{stableId:t.selected}:null;if(!O0){let c0=t.sequences||[],z8=c0.find((B8)=>B8.series&&t.frame>=B8.from&&t.frame<B8.from+B8.duration)||c0.find((B8)=>t.frame>=B8.from&&t.frame<B8.from+B8.duration);if(z8?.stableId)O0={stableId:z8.stableId}}if(O0)t.clipVerb?.(O0,"split",{atFrame:t.frame});else l8("Nothing under the playhead to split.");return}if(b.key===" "||b.code==="Space")if(b.preventDefault(),t.playing)uX(!1),t.post({dgn:"timeline-pause",id:t.compId});else uX(!0),t.post({dgn:"timeline-mute",muted:t.muted,id:t.compId}),t.post({dgn:"timeline-loop",loop:t.loop,id:t.compId}),t.post({dgn:"timeline-play",id:t.compId});else if(b.key==="ArrowRight")b.preventDefault(),l(t.frame+(b.shiftKey?q0:1));else if(b.key==="ArrowLeft")b.preventDefault(),l(t.frame-(b.shiftKey?q0:1));else if(b.key==="Home")b.preventDefault(),l(0);else if(b.key==="End")b.preventDefault(),l(k0-1);else if(b.key==="."){b.preventDefault();let O0=M0().find((c0)=>c0>t.frame);if(O0!=null)l(O0)}else if(b.key===","){b.preventDefault();let O0=M0().reverse().find((c0)=>c0<t.frame);if(O0!=null)l(O0)}};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[]),u.useEffect(()=>{vJ([]),TX(0),uX(!1),pX(null),UX(null);let j=setTimeout(()=>S8({dgn:"timeline-request-comps"}),60);return()=>clearTimeout(j)},[Z,S8]);let[b5,n0]=u.useState(""),[LQ,s0]=u.useState([]),[QG,KY]=u.useState([]);u.useEffect(()=>{if(!i6||J6.length===0||!Z||Z===c8){n0(""),s0([]);return}let j=!0;return fetch(`/_api/canvas-source?file=${encodeURIComponent(Z)}`).then((b)=>b.ok?b.json():null).then((b)=>{if(j&&b?.ok&&typeof b.source==="string")n0(b.source)}).catch(()=>{}),()=>{j=!1}},[i6,J6,Z,VX]),u.useEffect(()=>{if(!i6||!Z||Z===c8||!b5){s0([]),KY([]);return}let j=!0,b=o9||void 0,t=`/_api/comp-clips?canvas=${encodeURIComponent(Z)}${b?`&artboardId=${encodeURIComponent(b)}`:""}`;return fetch(t).then((W0)=>W0.ok?W0.json():null).then((W0)=>{if(!j)return;let F0=W0?.ok&&Array.isArray(W0.clips)?W0.clips:[];s0(F0.filter((q0)=>q0.kind==="sequence")),KY(F0.filter((q0)=>q0.kind==="transition"))}).catch(()=>{}),()=>{j=!1}},[i6,Z,b5,o9,VX]),u.useEffect(()=>{if(!b5){o6([]),b6([]),pQ([]),s4(0);return}let j=Y8??B?.artboardId??null,t=(j&&J6.find((q0)=>q0.artboardId===j||q0.id===j)||J6[0])?.durationInFrames||0,W0=Nh(b5,t,j);UX(W0.artboardId??j??null);let F0=W0.sequences.map((q0,k0)=>{let l=LQ[k0];if(!l)return q0;return{...q0,stableId:l.stableId,contentHash:l.contentHash,mediaProps:l.mediaProps??null,placeholder:l.placeholder??null,mediaTag:l.mediaTag??q0.mediaTag,mediaSrc:l.mediaSrc??q0.mediaSrc,replaceable:!!(l.mediaCdId||l.mediaArrayRef),layers:Array.isArray(l.layers)?l.layers:[],hidden:!!l.hidden}});o6(F0),b6(W0.audio||[]),pQ(W0.transitions||[]),s4(W0.total)},[b5,LQ,B,J6,Y8]);let UY=u.useCallback(()=>{zH((j)=>{let b=!j,t=Z?m8.current.get(Z):null;if(t&&t.contentWindow)try{t.contentWindow.postMessage({dgn:"view-annotations",visible:b},"*")}catch{}return b})},[Z]),BX=u.useCallback((j)=>{for(let b of m8.current.values())try{b.contentWindow.postMessage({dgn:"view-chrome",...j},"*")}catch{}},[]),VY=u.useCallback(()=>{UH((j)=>{let b=!j;return BX({minimap:b}),b})},[BX]),qY=u.useCallback(()=>{qX((j)=>{let b=!j;return BX({zoom:b}),b})},[BX]),sQ=u.useCallback(()=>{tW((j)=>{let b=!j;return BX({present:b}),b})},[BX]),tQ=u.useCallback(()=>{tW(!1),BX({present:!1})},[BX]),YG=u.useCallback(()=>{if(!Z||Z===c8)return;lJ((j)=>{let b=!j;return S8({dgn:"view-chrome",print:b}),fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{overlays:{print:b}}})}).catch(()=>{}),b})},[Z,S8]);u.useEffect(()=>{let j=!1;return fetch("/_api/git-user").then((b)=>b.json()).then((b)=>{if(j)return;let t=b&&typeof b.name==="string"?b.name.trim():"";if(t)eW(t)}).catch(()=>{}),()=>{j=!0}},[]),u.useEffect(()=>{if(!Z||Z===c8){NQ(0),lJ(!1);return}let j=!1;return fetch("/_api/canvas-meta?file="+encodeURIComponent(Z)).then((b)=>b.json()).then((b)=>{if(j)return;let t=Array.isArray(b?.artboards)?b.artboards.length:0;NQ(t),lJ(b?.overlays?.print===!0),X4(new Set(Array.isArray(b?.locked)?b.locked:[]))}).catch(()=>{if(!j)NQ(0),lJ(!1),X4(new Set)}),()=>{j=!0}},[Z]),u.useEffect(()=>{if(!Z||Z===c8||!Y8)return;let j=setTimeout(()=>{S8({dgn:"request-layers",artboardId:Y8})},250);return()=>clearTimeout(j)},[Z,Y8,S8]);let[eQ,X4]=u.useState(()=>new Set),WG=u.useCallback((j)=>{if(!Z||Z===c8)return;X4((b)=>{let t=new Set(b);if(t.has(j))t.delete(j);else t.add(j);let W0=[...t];return fetch("/_api/canvas-meta",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,patch:{locked:W0}})}).catch(()=>{}),S8({dgn:"locked-set",locked:W0}),t})},[Z,S8]);u.useEffect(()=>{if(!Z||Z===c8)return;S8({dgn:"locked-set",locked:[...eQ]})},[eQ,Z,S8]),u.useEffect(()=>{try{document.documentElement.setAttribute("data-theme",F9),localStorage.setItem(j00,F9)}catch{}for(let j of m8.current.values())try{j.contentWindow.postMessage({dgn:"theme",theme:F9},"*")}catch{}},[F9]),u.useEffect(()=>{try{localStorage.setItem(W00,z7?"1":"0")}catch{}},[z7]),u.useEffect(()=>{try{localStorage.setItem(J00,T9?"1":"0")}catch{}},[T9]),u.useEffect(()=>{try{localStorage.setItem(Q00,JSON.stringify(X0))}catch{}},[X0]),u.useEffect(()=>{try{localStorage.setItem(G00,uJ?"1":"0")}catch{}},[uJ]),u.useEffect(()=>{try{localStorage.setItem(Z00,j6?"1":"0")}catch{}},[j6]),u.useEffect(()=>{try{localStorage.setItem(H00,BQ?"1":"0")}catch{}},[BQ]),u.useEffect(()=>{let j=!1;return fetch("/_api/ui-prefs").then((b)=>b.ok?b.json():Promise.reject(Error(`HTTP ${b.status}`))).then((b)=>{if(j||!b||typeof b!=="object")return;if(b.theme==="light"||b.theme==="dark")b9(b.theme);if(typeof b.minimap==="boolean")UH(b.minimap);if(typeof b.zoom==="boolean")qX(b.zoom);if(typeof b.annotations==="boolean")zH(b.annotations);if(typeof b.autoOpenInspector==="boolean")iW(b.autoOpenInspector);if(b.panelSides&&typeof b.panelSides==="object")RX({...$K,...b.panelSides});if(b.layersMode==="separate"||b.layersMode==="in-inspector")l9(b.layersMode)}).catch(()=>{}).finally(()=>{if(!j)uK(!0)}),()=>{j=!0}},[]),u.useEffect(()=>{if(!KH)return;F20({theme:F9,minimap:uJ,zoom:j6,annotations:BQ,autoOpenInspector:gJ,panelSides:C9,layersMode:I9})},[KH,F9,uJ,j6,BQ,gJ,C9,I9]),u.useEffect(()=>{try{localStorage.setItem(z00,JSON.stringify(C9))}catch{}},[C9]),u.useEffect(()=>{try{localStorage.setItem(K00,I9)}catch{}},[I9]);let GG=u.useCallback((j,b)=>{_0((t)=>{let W0=t[j],F0=W0===void 0?b:W0;return{...t,[j]:!F0}})},[]),J4=u.useCallback(()=>{b9((j)=>j==="dark"?"light":"dark")},[]),W7=u.useCallback(async()=>{try{let b=await(await fetch("/_index-data")).json();Y(b.project||"Design");let t=b.groups.map((W0)=>({...W0,tree:w20(W0.paths,W0.stripPrefix,W0.dirs)}));J(t),L8((W0)=>({...W0,canvasDesignSystems:b.canvasDesignSystems??{},canvasKinds:b.canvasKinds??{}}))}catch(j){console.error("failed to load tree",j)}},[]);u.useEffect(()=>{W7()},[W7]);let cJ=u.useCallback(async(j)=>{try{let b=j?`/_system-data?ds=${encodeURIComponent(j)}`:"/_system-data",t=await fetch(b);if(!t.ok){console.error("failed to load system-data",t.status);return}let W0=await t.json();if(!j&&W0?.defaultDesignSystem&&!W0.ds){A8(W0);let F0=await fetch(`/_system-data?ds=${encodeURIComponent(W0.defaultDesignSystem)}`);if(F0.ok)A8(await F0.json());return}A8(W0)}catch(b){console.error("failed to load system-data",b)}},[]),BY=u.useCallback(async()=>{try{let b=await(await fetch("/_comments-all")).json();a8(b||{})}catch(j){console.error("failed to load comments",j)}},[]);u.useEffect(()=>{BY()},[BY]),u.useEffect(()=>{let j=null;function b(){let t=location.protocol==="https:"?"wss:":"ws:",W0=new WebSocket(t+"//"+location.host+"/_ws");GY.current=W0,W0.addEventListener("open",()=>{r(!0),clearInterval(j),j=setInterval(()=>{if(W0.readyState===WebSocket.OPEN)W0.send('{"type":"ping"}')},25000)}),W0.addEventListener("close",()=>{r(!1),clearInterval(j),setTimeout(b,1000)}),W0.addEventListener("error",()=>{}),W0.addEventListener("message",(F0)=>{try{let q0=JSON.parse(F0.data);if(q0.type==="snapshot"&&q0.state)N((k0)=>$00(q0.state.selected,k0));else if(q0.type==="selected"){if(Date.now()-R.current<2000)return;let k0=q0.selected,l=Array.isArray(k0)?k0[0]:k0,M0=F.current,O0=Array.isArray(M0)?M0[0]:M0;if(N((c0)=>$00(k0,c0)),l?.id&&l.file&&(!O0||O0.id!==l.id||O0.file!==l.file))M(l)}else if(q0.type==="comments"&&typeof q0.file==="string")a8((k0)=>({...k0,[q0.file]:q0.comments||[]}));else if(q0.type==="ai-activity"&&typeof q0.file==="string"){if(WY(!0),nQ.current)clearTimeout(nQ.current);nQ.current=setTimeout(()=>WY(!1),8000);for(let k0 of m8.current.values())try{k0.contentWindow.postMessage({dgn:"ai-activity",file:q0.file,entry:q0.entry},"*")}catch{}}else if(q0.type==="export:job"&&q0.payload)JY.upsert(q0.payload);else if(q0.type==="sync:status"&&q0.payload)o(q0.payload);else if(q0.type==="canvas-list-update"){if(W7(),q0.payload?.action==="moved"&&q0.payload.fromRel&&q0.payload.rel){let k0=(f0?.designRel||f0?.designRoot||".design").replace(/^\/+|\/+$/g,""),l=`${k0}/${q0.payload.fromRel}`,M0=`${k0}/${q0.payload.rel}`;G((O0)=>O0.map((c0)=>c0.path===l?{path:M0}:c0)),H((O0)=>O0===l?M0:O0)}}else if(q0.type==="config-updated")V8();else if(q0.type==="acp-focus"){if(W9())mJ("assistant")}else if(q0.type==="git-status"&&q0.payload){if(!L0.current)K0(q0.payload)}else if(q0.type==="git-lifecycle"&&q0.payload){c(q0.payload);for(let k0 of m8.current.values())try{k0.contentWindow.postMessage({dgn:"git-lifecycle",payload:q0.payload},"*")}catch{}}}catch{}})}return b(),()=>{if(clearInterval(j),GY.current)GY.current.close()}},[W7,V8]);function I7(j){let b=GY.current;try{if(b&&b.readyState===1)b.send(JSON.stringify(j))}catch{}}let NX=u.useCallback(async()=>{if(L0.current)return;try{let j=await fetch("/_api/git/status");if(j.ok)K0(await j.json())}catch{}},[]),kX=u.useCallback(async()=>{if(L0.current)return;try{let j=await fetch("/_api/git/status?remote=1");if(!j.ok)return;let b=await j.json();if(b&&b.repo!==!1)Q8({remoteAhead:!!b.remoteAhead,behind:b.behind||0})}catch{}},[]),FX=u.useCallback(async(j,b)=>{try{let t=await fetch(j,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b||{})}),W0=await t.json().catch(()=>({}));return{ok:t.ok,...W0}}catch(t){return{ok:!1,error:"Network error — is the project still open?"}}},[]),ZG=u.useCallback(async(j,b)=>{let t=await FX("/_api/git/commit",{message:j,files:b});if(t.ok)await NX();return t},[FX,NX]),NY=u.useCallback(async(j)=>{let b=await FX("/_api/git/discard",{files:j});if(b.ok)await NX();return b},[FX,NX]),HG=u.useCallback(async()=>{let j=await FX("/_api/git/push",{});if(j.ok)await NX(),kX();return j},[FX,NX,kX]),FY=u.useCallback(async()=>{let j=await FX("/_api/git/pull",{});if(j.ok)await NX(),kX();if(j.conflict&&Array.isArray(j.files)&&j.files.length)K8({file:j.files[0],conflict:!0});return j},[FX,NX,kX]),zG=u.useCallback(async(j)=>{let b=await FX("/_api/git/resolve",{choice:j});if(b.ok)await NX(),kX();return b},[FX,NX,kX]),LY=u.useCallback(async(j)=>{try{let b="/_api/git/log?limit=40"+(j?`&path=${encodeURIComponent(j)}`:""),t=await fetch(b);if(!t.ok)return[];return(await t.json()).entries||[]}catch{return[]}},[]),[KG,UG]=u.useState(null),VG=u.useCallback(async(j)=>{try{let b="/_api/cloud/history?limit=40"+(j?`&path=${encodeURIComponent(j)}`:""),t=await fetch(b);if(!t.ok)return null;let W0=await t.json();if(!W0?.ok)return null;return UG({branch:W0.branch??null,project:W0.project??null,hubHost:W0.hubHost??null}),W0.entries||[]}catch{return null}},[]),qG=u.useMemo(()=>{let j={modified:"M",added:"A",deleted:"D",untracked:"U"},b=new Map;if(q8)return b;for(let t of N0?.files||[])b.set(t.path,j[t.status]);return b},[N0,q8]);u.useEffect(()=>{if(q8){Q8(null);return}if(N0?.repo===!1)return;kX();let j=setInterval(kX,o0?60000:120000);return()=>clearInterval(j)},[q8,N0?.repo,o0,kX]);let K6=u.useCallback((j)=>{if(G((b)=>{for(let t of b)if(t.path!==j)m8.current.delete(t.path);return[{path:j}]}),H(j),N9(null),U(null),j!==c8)P9(j)},[]),DY=u.useRef(!1);u.useEffect(()=>{if(DY.current)return;if(!f0.cloud)return;if(W.length>0)return;if(!X.length)return;let j=null;for(let b of X){for(let t of b.paths||[]){if(!GQ.test(t))continue;if(/(^|\/)system\//.test(t))continue;j=t;break}if(j)break}if(!j)return;DY.current=!0,K6(j)},[f0.cloud,X,W.length,K6]);let iJ=u.useCallback((j)=>{let b=typeof j==="string"?j:void 0;if(b)cJ(b);else if(!W8)cJ();K6(c8)},[W8,cJ,K6]);u.useEffect(()=>{I7({type:"tabs",tabs:W.map((j)=>j.path).filter((j)=>j!==c8)})},[W]),u.useEffect(()=>{if(Z&&Z!==c8)I7({type:"active",file:Z});else if(Z===c8)I7({type:"active",file:""});else I7({type:"active",file:""})},[Z]);let Q4=u.useCallback((j)=>{G((b)=>{let t=b.findIndex((F0)=>F0.path===j);if(t<0)return b;let W0=b.filter((F0)=>F0.path!==j);if(j===Z)if(W0.length===0)H(null);else H(W0[Math.max(0,t-1)].path);return W0}),m8.current.delete(j),P9((b)=>b===j?null:b)},[Z]),UJ=u.useCallback(()=>{if(!Z||Z===c8){if(Z===c8)cJ();return}let j=m8.current.get(Z);if(j)j.src=j.src},[Z,cJ]),OY=u.useCallback(()=>W7(),[W7]),[BG,MY]=u.useState(!1),Y4=u.useRef(!1),W4=u.useCallback(async()=>{if(Y4.current)return;Y4.current=!0,MY(!0);try{await Promise.all([W7(),new Promise((j)=>setTimeout(j,550))])}finally{Y4.current=!1,MY(!1)}},[W7]);u.useEffect(()=>{let j=null,b=()=>{if(j)clearTimeout(j);j=setTimeout(()=>{j=null,OY()},150)};return window.addEventListener("focus",b),()=>{if(window.removeEventListener("focus",b),j)clearTimeout(j)}},[OY]);let NG=u.useCallback(async(j)=>{try{let b=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j,kind:"brief-board"})}),t=await b.json().catch(()=>({}));if(!b.ok||!t.ok)return{ok:!1,error:t.error||`create failed (${b.status})`};return await W7(),K6(t.file),{ok:!0,file:t.file}}catch(b){return{ok:!1,error:b instanceof Error?b.message:"network error"}}},[W7,K6]),_Y=u.useCallback(async()=>{let j=await dJ("New video name");if(!j)return;let t=(await dJ("Size — 1920x1080 (landscape), 1080x1920 (portrait), 1080x1080 (square), or custom WxH","1920x1080")||"1920x1080").toLowerCase().match(/(\d{2,5})\s*[x×]\s*(\d{2,5})/),W0=t?Number(t[1]):1920,F0=t?Number(t[2]):1080,q0=Math.max(1,Math.min(60,Number(await dJ("Frames per second","30"))||30));try{let k0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j,kind:"video-comp",clips:[],fps:q0,width:W0,height:F0})}),l=await k0.json().catch(()=>({}));if(!k0.ok||!l.ok){l8(`New video failed: ${l.error||`error ${k0.status}`}`);return}await W7(),K6(l.file),zQ(!0),l8("New video created — drop clips on the timeline to start the cut.",!0)}catch(k0){l8(`New video failed: ${k0 instanceof Error?k0.message:"network error"}`)}},[W7,K6,dJ]),FG=u.useCallback(async()=>{if(!Z||Z===c8)return;try{let j=await fetch(`/_api/annotations?file=${encodeURIComponent(Z)}`),b=j.ok?await j.text():"",t=[];if(b){let l=new DOMParser().parseFromString(b,"image/svg+xml");for(let M0 of l.querySelectorAll('[data-tool="mediaref"]')){let O0=M0.getAttribute("data-src");if(!O0)continue;t.push({src:O0,mediaKind:M0.getAttribute("data-media-kind")==="audio"?"audio":"video"})}}if(t.length===0){window.alert("Drop video/audio clips on the canvas first, then assemble them into a video.");return}let F0=`${pW(JH(Z)).replace(/\.tsx$/i,"")} Video`,q0=await fetch("/_api/canvas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:F0,kind:"video-comp",clips:t})}),k0=await q0.json().catch(()=>({}));if(!q0.ok||!k0.ok){window.alert(`Assemble failed: ${k0.error||`error ${q0.status}`}`);return}await W7(),K6(k0.file)}catch(j){window.alert(`Assemble failed: ${j instanceof Error?j.message:"network error"}`)}},[Z,W7,K6]),G4=u.useCallback(({accept:j,resolveTarget:b})=>{let t=Z,W0=o9||void 0,F0=document.createElement("input");F0.type="file",F0.accept=j,F0.style.cssText="position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none",document.body.appendChild(F0);let q0=()=>{if(F0.isConnected)F0.remove()};window.addEventListener("focus",()=>setTimeout(q0,300),{once:!0}),F0.addEventListener("change",()=>{let k0=F0.files?.[0];if(q0(),!k0)return;let l=`/_api/comp-clips?canvas=${encodeURIComponent(t)}${W0?`&artboardId=${encodeURIComponent(W0)}`:""}`;fetch(l).then((M0)=>M0.json().catch(()=>({}))).then((M0)=>{let O0=b(M0);if(!O0)return l8("No replaceable media here (its src is computed) — edit via chat."),null;return fetch("/_api/asset",{method:"POST",headers:{"Content-Type":k0.type||"application/octet-stream"},body:k0}).then((c0)=>c0.json().catch(()=>({}))).then((c0)=>{if(!c0?.path)return l8(`Upload failed: ${c0?.error||"unknown error"}`),null;if(O0.arrayRef)return fetch("/_api/edit-array-src",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:t,arrayName:O0.arrayRef.arrayName,index:O0.arrayRef.index,field:O0.arrayRef.field,value:c0.path})});return fetch("/_api/edit-attr",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({canvas:t,id:O0.cdId,attr:"src",value:c0.path})})})}).then((M0)=>M0?M0.json():null).then((M0)=>{if(M0&&!M0.ok)l8(`Replace refused: ${M0.error||"failed"}`);else if(M0&&M0.ok){if(l8("Media replaced.",!0),M0.seq!=null)T7(t,M0.seq,"replace media")}}).catch(()=>l8("Replace failed: network error"))}),F0.click()},[Z,o9,T7]),LG=u.useCallback(async(j,b)=>{if(!window.confirm(`Move “${b}” to trash?
5654
5654
 
5655
5655
  Its annotations, history and comments move with it. `+"You can restore it from .design/_trash/."))return;try{let W0=await fetch(`/_api/canvas?file=${encodeURIComponent(j)}`,{method:"DELETE"}),F0=await W0.json().catch(()=>({}));if(!W0.ok||!F0.ok){window.alert(`Could not delete: ${F0.error||`error ${W0.status}`}`);return}if(await W7(),Z===j)G([]),H(null)}catch(W0){window.alert(`Delete failed: ${W0 instanceof Error?W0.message:"network error"}`)}},[W7,Z]),DG=u.useCallback(async function j(b,t){try{let W0=await fetch("/_api/fs-move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:b,toDir:t})}),F0=await W0.json().catch(()=>({}));if(!W0.ok||!F0.ok)return l8(`Could not move: ${F0.error||`error ${W0.status}`}`),{ok:!1,error:F0.error};let q0=(f0?.designRel||f0?.designRoot||".design").replace(/^\/+|\/+$/g,""),k0=`${q0}/${F0.fromRel}`,l=`${q0}/${F0.toRel}`;await W7(),G((O0)=>O0.map((c0)=>c0.path===k0?{path:l}:c0)),H((O0)=>O0===k0?l:O0);let M0=k0.split("/").slice(0,-1).join("/");return l8(`Moved to ${F0.toRel.split("/").slice(0,-1).join("/")||"."}`,!0,{label:"Undo",onClick:()=>{j(l,M0)}}),{ok:!0}}catch(W0){return l8(`Move failed: ${W0 instanceof Error?W0.message:"network error"}`),{ok:!1,error:"network error"}}},[W7,f0]),OG=u.useCallback(async(j,b)=>{try{let t=await fetch("/_api/fs-mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parent:j,name:b})}),W0=await t.json().catch(()=>({}));if(!t.ok||!W0.ok){let F0=W0.error||`error ${t.status}`;return l8(`Could not create folder: ${F0}`),{ok:!1,error:F0}}return await W7(),{ok:!0,dir:W0.dir}}catch(t){let W0=t instanceof Error?t.message:"network error";return l8(`Create folder failed: ${W0}`),{ok:!1,error:W0}}},[W7]),MG=u.useCallback(async(j,b)=>{if(!window.confirm(`Delete folder "${b}"?
5656
5656