@codeyam-editor/codeyam-editor 0.1.3 → 0.1.5

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.
Files changed (66) hide show
  1. package/npm/cloud-branch-switch.js +1 -1
  2. package/npm/cloud.js +1693 -96
  3. package/npm/container.js +14 -0
  4. package/npm/disk-pressure.js +167 -0
  5. package/npm/editor-dev.js +107 -15
  6. package/npm/editor.js +97 -37
  7. package/npm/fleet-auth-health.js +75 -0
  8. package/npm/fleet-auth.js +6 -1
  9. package/npm/fleet-build-data.js +130 -0
  10. package/npm/fleet-cleanup.js +145 -7
  11. package/npm/fleet-destroy-safety.js +55 -0
  12. package/npm/fleet-effect-status.js +33 -32
  13. package/npm/fleet-host.js +74 -0
  14. package/npm/fleet-job-badge.js +46 -2
  15. package/npm/fleet-launchd.js +171 -0
  16. package/npm/fleet-live-status.js +123 -0
  17. package/npm/fleet-plans.js +231 -0
  18. package/npm/fleet-prewarm.js +165 -0
  19. package/npm/fleet-public-url.js +160 -0
  20. package/npm/fleet-queue.js +38 -1
  21. package/npm/fleet-reconcile.js +100 -1
  22. package/npm/fleet-reset.js +298 -13
  23. package/npm/fleet-roster.js +6 -8
  24. package/npm/fleet-self-update.js +142 -0
  25. package/npm/fleet-setup-steps.js +105 -0
  26. package/npm/fleet-sleep-status.js +33 -0
  27. package/npm/fleet-strand.js +150 -0
  28. package/npm/fleet-stuck-status.js +111 -0
  29. package/npm/fleet-vm-access.js +234 -0
  30. package/npm/fleet-vm-readiness.js +104 -0
  31. package/npm/fleet-vm-slugs.js +116 -0
  32. package/npm/google-ingress.js +211 -0
  33. package/npm/ingress-invoke.js +292 -0
  34. package/npm/launch-config.js +310 -4
  35. package/npm/scenario-check.js +684 -33
  36. package/npm/scenario-handlers.js +94 -12
  37. package/npm/scenario-metrics.js +116 -1
  38. package/npm/scenario-mocks.js +20 -0
  39. package/npm/scenario-playwright.js +366 -29
  40. package/npm/script-drift.js +81 -0
  41. package/npm/utils.js +453 -43
  42. package/npm/vm-urls.js +69 -8
  43. package/package.json +5 -5
  44. package/ui/dist/assets/ContainerInspector-D7VZkkaj.js +2 -0
  45. package/ui/dist/assets/EditorShell-DHhIaotd.css +1 -0
  46. package/ui/dist/assets/EditorShell-r-796N_W.js +191 -0
  47. package/ui/dist/assets/{Markdown-BHBqz-Mj.js → Markdown-BoLHHFXH.js} +1 -1
  48. package/ui/dist/assets/ProjectLauncherScreen-Ck-XWkQN.js +1 -0
  49. package/ui/dist/assets/ScenarioDataPanel-B9iDSUpA.js +5 -0
  50. package/ui/dist/assets/ScenarioDataPanelFullPage-CBLTGC4-.js +1 -0
  51. package/ui/dist/assets/ScenarioRenderer-BhLfT-nX.js +21 -0
  52. package/ui/dist/assets/StepsSimulator-BFldWyoX.js +1 -0
  53. package/ui/dist/assets/index-CIXZkwfB.css +1 -0
  54. package/ui/dist/assets/{index-KDFAgt2e.js → index-QsOiOG9x.js} +9 -9
  55. package/ui/dist/assets/useEvents-DHkLJZR4.js +1 -0
  56. package/ui/dist/codeyam-mark.svg +4 -0
  57. package/ui/dist/codeyam-wordmark.svg +5 -0
  58. package/ui/dist/index.html +2 -2
  59. package/ui/dist/assets/ContainerInspector-C8EkH4PP.js +0 -2
  60. package/ui/dist/assets/EditorShell-CGsBSA6u.js +0 -186
  61. package/ui/dist/assets/ScenarioDataPanel-nuLXJzLf.js +0 -5
  62. package/ui/dist/assets/ScenarioDataPanelFullPage-Bnghtj8a.js +0 -1
  63. package/ui/dist/assets/ScenarioRenderer-B_Za9jL8.js +0 -1
  64. package/ui/dist/assets/StepsSimulator-CRtmlyNZ.js +0 -1
  65. package/ui/dist/assets/index-Bih6HJ_u.css +0 -1
  66. package/ui/dist/assets/useEvents-DggWrtHe.js +0 -1
@@ -0,0 +1,191 @@
1
+ var Ty=Object.defineProperty;var Py=(t,s,n)=>s in t?Ty(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var it=(t,s,n)=>Py(t,typeof s!="symbol"?s+"":s,n);import{j as e}from"./markdown-v0F0UEt3.js";import{b as l,c as Vt,R as He}from"./react-CSS0HapR.js";import{n as Da,i as It,a as La,b as Wn,c as Or,d as yi,r as Oy,s as Ay}from"./useEvents-DHkLJZR4.js";import{S as Ry,a$ as qn,a8 as Bs,b0 as yt,b1 as At,b2 as Ey,b3 as Tn,b4 as Nl,b5 as My,b6 as Yr,u as Iy,b7 as Cl,b8 as Tl,b9 as Pl,ba as Ol,a3 as Dy,bb as Ly,bc as Fy,bd as zy,be as $y,a4 as By,bf as Hy,f as Kr,bg as Wy,e as Fa,bh as qy,bi as Gy,bj as Uy,i as Vy,bk as vi,bl as Yy,bm as Ky,a9 as Jy,a7 as Xy,bn as Qy,bo as Zy,bp as ev,bq as tv,A as sv,br as nv}from"./ScenarioDataPanel-B9iDSUpA.js";import{e as rv,a as av,g as za,d as ov,l as K,p as _s,i as gn,t as iv,u as lv}from"./index-QsOiOG9x.js";import{M as vt}from"./Markdown-BoLHHFXH.js";function $a(){return e.jsxs("div",{style:{padding:"var(--spacing-lg, 16px)"},children:[e.jsx("h3",{style:{margin:0,color:"var(--text-primary)"},children:"Design exploration"}),e.jsx("p",{style:{color:"var(--text-secondary)",fontSize:"var(--text-sm, 14px)",lineHeight:1.5,marginTop:"var(--spacing-sm, 8px)"},children:"Generating mockups — they'll appear here as the agent writes them."})]})}const A3=Object.freeze(Object.defineProperty({__proto__:null,MockupGridEmptyState:$a},Symbol.toStringTag,{value:"Module"}));function Jr({onRunTests:t,disabled:s,currentRunner:n}){return s?e.jsxs("span",{className:"text-xs font-medium text-[var(--text-dim)] inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-block h-3 w-3 animate-spin rounded-full border-2 border-current border-r-transparent"}),n?`Running ${n}…`:"Running…"]}):e.jsx("span",{role:"button",tabIndex:0,onClick:r=>{r.stopPropagation(),t()},onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.stopPropagation(),t())},className:"text-xs font-medium text-[var(--accent-active)] hover:underline cursor-pointer",children:"Run Tests"})}const R3=Object.freeze(Object.defineProperty({__proto__:null,RunTestsButton:Jr},Symbol.toStringTag,{value:"Module"}));function Al({passed:t,failed:s,notRun:n}){const r=t+s+n;if(r===0)return null;const a=2,o=[{count:t,color:"var(--accent-green)"},{count:s,color:"var(--accent-red)"},{count:n,color:"var(--text-dim)"}].filter(u=>u.count>0),i=o.map(u=>Math.max(u.count/r*100,a)),c=i.reduce((u,h)=>u+h,0),d=i.map(u=>u/c*100);return e.jsx("div",{className:"h-1.5 flex-1 rounded-full bg-[var(--bg-input)] overflow-hidden max-w-32",children:e.jsx("div",{className:"h-full flex",children:o.map((u,h)=>e.jsx("div",{className:"h-full transition-all",style:{width:`${d[h]}%`,background:u.color}},u.color))})})}const E3=Object.freeze(Object.defineProperty({__proto__:null,TestBar:Al},Symbol.toStringTag,{value:"Module"}));function Ba({tests:t,loading:s,refreshing:n,onRunTests:r,currentRunner:a}){const o=t.total>0,i=t.discovered>0,c=t.discovered>t.total?t.discovered-t.total:0;return s?e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsx("div",{className:"h-1.5 w-16 rounded-full bg-[var(--bg-input)] animate-pulse"}),e.jsx("span",{className:"text-xs text-[var(--text-dim)]",children:n?"Running tests…":"Loading tests…"})]}):o?e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsx(Al,{passed:t.passed,failed:t.failed,notRun:c}),e.jsxs("span",{className:"text-xs font-medium text-[var(--accent-green)]",children:[t.passed," passed"]}),t.failed>0&&e.jsxs("span",{className:"text-xs font-medium text-[var(--accent-red)]",children:["· ",t.failed," failed"]}),t.ignored>0&&e.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:["· ",t.ignored," skipped"]}),c>0&&e.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:["· ",c," not run"]}),r&&e.jsx(Jr,{onRunTests:r,disabled:n,currentRunner:a})]}):i?e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:[t.discovered," ",t.discovered===1?"test":"tests"," (not run)"]}),r&&e.jsx(Jr,{onRunTests:r})]}):e.jsx("span",{className:"text-xs text-[var(--text-dim)]",children:"No tests"})}const M3=Object.freeze(Object.defineProperty({__proto__:null,AppTestSummary:Ba},Symbol.toStringTag,{value:"Module"}));function Rl({tests:t,loading:s,refreshing:n,onRunTests:r,currentRunner:a}){return e.jsxs("div",{className:"px-5 pb-5 pt-2 flex items-center gap-5 border-t border-[var(--border-default)]",children:[e.jsx(Ba,{tests:t,loading:s,refreshing:n,onRunTests:r,currentRunner:a}),e.jsx("span",{className:"text-[var(--text-dim)] group-hover:text-[var(--accent-active)] transition ml-auto text-sm",children:"→"})]})}const I3=Object.freeze(Object.defineProperty({__proto__:null,AppCardFooter:Rl},Symbol.toStringTag,{value:"Module"}));function Ha({type:t}){const s=t==="web";return e.jsx("span",{className:`rounded px-1.5 py-0.5 text-xs font-medium ${s?"bg-[var(--accent-blue)]/20 text-[var(--accent-blue)]":"bg-[var(--accent-purple)]/20 text-[var(--accent-purple)]"}`,children:s?"web":"backend"})}const D3=Object.freeze(Object.defineProperty({__proto__:null,AppTypeBadge:Ha},Symbol.toStringTag,{value:"Module"}));function El({app:t}){return e.jsxs("div",{className:"px-5 pt-5 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:t.name}),e.jsx(Ha,{type:t.type})]}),t.description?e.jsx("p",{className:"text-sm text-[var(--text-muted)] leading-relaxed",children:t.description}):null]})}const L3=Object.freeze(Object.defineProperty({__proto__:null,AppCardHeader:El},Symbol.toStringTag,{value:"Module"}));function at(t,s){if(t.startsWith("http"))return t;const n=`/api/screenshots/${t}`;return typeof s=="number"?`${n}?cb=${s}`:n}function Ml({thumbnails:t}){return e.jsx("div",{className:"flex gap-2 overflow-hidden",children:t.map((s,n)=>e.jsx("img",{src:at(s.path,s.cacheBuster),alt:"",className:"h-20 w-32 rounded border border-[var(--border-default)] object-cover object-top"},`${s.path}:${n}`))})}const F3=Object.freeze(Object.defineProperty({__proto__:null,ThumbnailStrip:Ml},Symbol.toStringTag,{value:"Module"}));function Il({thumbnails:t}){return e.jsx("div",{className:"px-5 py-3 flex-1",children:t.length>0?e.jsx(Ml,{thumbnails:t.slice(0,4)}):e.jsx("div",{className:"h-20"})})}const z3=Object.freeze(Object.defineProperty({__proto__:null,AppCardScenarioStrip:Il},Symbol.toStringTag,{value:"Module"}));function Dl({stats:t,onClick:s,testsLoading:n,testsRefreshing:r,onRunTests:a,currentRunner:o}){const{app:i,tests:c,scenarios:d}=t;return e.jsxs("button",{onClick:s,className:"group flex w-full cursor-pointer flex-col rounded-lg border border-[var(--border-default)] bg-[var(--bg-card)] text-left transition hover:border-[var(--accent-active)]/40 hover:bg-[var(--bg-surface)]",children:[e.jsx(El,{app:i}),e.jsx(Il,{thumbnails:d.thumbnails}),e.jsx(Rl,{tests:c,loading:n,refreshing:r,onRunTests:a,currentRunner:o})]})}const $3=Object.freeze(Object.defineProperty({__proto__:null,AppCard:Dl},Symbol.toStringTag,{value:"Module"})),Jt={apps:[],isSingleApp:!1,onSelectApps:()=>{},onSelectApp:()=>{},onSelectRoute:()=>{}};function Xt(){const[t,s]=l.useState({}),n=l.useRef({});return l.useEffect(()=>{let r=!1;const a=async()=>{try{const i=await fetch("/api/editor-dev-server");if(!i.ok)return;const c=await i.json();if(r)return;const d=typeof c.scenariosVersion=="number"?c.scenariosVersion:void 0,u=typeof c.plansVersion=="number"?c.plansVersion:void 0,h=typeof c.testsVersion=="number"?c.testsVersion:void 0,p=typeof c.claimsVersion=="number"?c.claimsVersion:void 0,m=typeof c.sourceVersion=="number"?c.sourceVersion:void 0,f=typeof c.liveReloadEnabled=="boolean"?c.liveReloadEnabled:void 0;(d!==n.current.scenariosVersion||u!==n.current.plansVersion||h!==n.current.testsVersion||p!==n.current.claimsVersion||m!==n.current.sourceVersion||f!==n.current.liveReloadEnabled)&&(n.current={scenariosVersion:d,plansVersion:u,testsVersion:h,claimsVersion:p,sourceVersion:m,liveReloadEnabled:f},s(n.current))}catch{}};a();const o=setInterval(a,500);return()=>{r=!0,clearInterval(o)}},[]),t}function cv(t){const[s,n]=l.useState({status:"idle"}),{scenariosVersion:r}=Xt();return l.useEffect(()=>{if(!t){n({status:"idle"});return}let a=!1;return n({status:"loading"}),(async()=>{try{const o=await fetch(`/api/entities/${t}`);if(a)return;if(o.status===404){n({status:"not-found"});return}if(!o.ok){n({status:"error",message:`HTTP ${o.status}`});return}const i=await o.json(),c={...i,scenarios:Array.isArray(i.scenarios)?i.scenarios.map(Da):[]};n({status:"loaded",entity:c})}catch(o){if(a)return;n({status:"error",message:o instanceof Error?o.message:"Failed to load entity"})}})(),()=>{a=!0}},[t,r]),s}function bn({message:t}){return e.jsx("div",{className:"px-5 py-8 text-center text-[var(--accent-red)]",children:t})}const B3=Object.freeze(Object.defineProperty({__proto__:null,AppDetailContentError:bn},Symbol.toStringTag,{value:"Module"}));function Xr(){return e.jsx("div",{className:"px-5 py-8 text-center text-[var(--text-dim)]",children:"Loading routes..."})}const H3=Object.freeze(Object.defineProperty({__proto__:null,AppDetailContentLoading:Xr},Symbol.toStringTag,{value:"Module"}));function dv(t){return t.kind==="function"?"Functions don't have visual scenarios. Coverage for this function lives in its unit tests.":t.kind==="component"?`No component scenarios for ${t.displayName}. Create one with \`codeyam-editor editor register\` or capture from the live preview.`:"No scenarios for this entity yet."}function Ll({entityRef:t,onNavigate:s}){return e.jsxs("button",{type:"button",onClick:()=>s(t.hash),className:"w-full rounded-lg border border-[var(--border-subtle)] bg-[var(--bg-card)] p-3 text-left transition hover:border-[var(--border-default)]",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"rounded-md border border-[var(--border-subtle)] bg-[var(--bg-page)] px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-[var(--text-dim)]",children:t.kind}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:t.name})]}),e.jsx("p",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:t.filePath})]})}const W3=Object.freeze(Object.defineProperty({__proto__:null,EntityRefCard:Ll},Symbol.toStringTag,{value:"Module"}));function xn({refs:t,onNavigate:s}){return e.jsx("ul",{className:"grid grid-cols-1 gap-1",children:t.map(n=>e.jsx("li",{children:e.jsx(Ll,{entityRef:n,onNavigate:s})},n.hash))})}const q3=Object.freeze(Object.defineProperty({__proto__:null,EntityRefList:xn},Symbol.toStringTag,{value:"Module"}));function uv(t,s,n){const[r,a]=l.useState(!1),[o,i]=l.useState(""),[c,d]=l.useState(!1),u=l.useCallback(()=>{a(!0),i(s)},[s]),h=l.useCallback(()=>{a(!1)},[]),p=l.useCallback(async()=>{if(!(!o.trim()||c)){d(!0);try{const m=await fetch(`/api/scenarios/${encodeURIComponent(t)}`);if(!m.ok)throw new Error(`HTTP ${m.status}`);const f=await m.json();f.name=o.trim(),await fetch(`/api/scenarios/${encodeURIComponent(t)}`,{method:"DELETE"}),await fetch("/api/scenarios",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)}),a(!1),n()}catch{}finally{d(!1)}}},[o,c,t,n]);return{renaming:r,renameName:o,renameSaving:c,setRenameName:i,startRename:u,cancelRename:h,submitRename:p}}function hv(t,s,n){const[r,a]=l.useState(!1),o=l.useCallback(async i=>{if(i.stopPropagation(),!!confirm(`Delete scenario "${s}"?`)){a(!0);try{await fetch(`/api/scenarios/${encodeURIComponent(t)}`,{method:"DELETE"}),n()}catch{}finally{a(!1)}}},[s,t,n]);return{deleting:r,handleDelete:o}}function pv({mocks:t,seeds:s}){const n=[];return t>0&&n.push(`${t} ${t===1?"mock":"mocks"} overridden`),s>0&&n.push(`${s} ${s===1?"seed":"seeds"} overridden`),n.length===0?null:n.join(" · ")}function Fl({overrideCounts:t}){const s=t?pv(t):null;return s?e.jsx("div",{className:"text-xs text-[var(--text-dim)] mt-1",children:s}):null}const G3=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRowOverrideBadge:Fl},Symbol.toStringTag,{value:"Module"})),mv=new Set(["Desktop"]);function zl({scenario:t,isSelected:s}){const n=t.dimensions.length>0&&!(t.dimensions.length===1&&mv.has(t.dimensions[0]));return e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:`text-base font-medium truncate ${s?"text-[var(--accent-active)]":"text-[var(--text-primary)]"}`,children:t.name}),t.description?e.jsx("div",{className:"text-sm text-[var(--text-secondary)] mt-1 whitespace-pre-line",children:t.description}):null,e.jsx(Fl,{overrideCounts:t.overrideCounts}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[n?e.jsx("span",{className:"text-xs text-[var(--text-dim)]",children:t.dimensions.join(", ")}):null,t.componentName?e.jsx("span",{className:"text-xs text-[var(--accent-purple)]",children:t.componentName}):null]})]})}const U3=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRowMeta:zl},Symbol.toStringTag,{value:"Module"}));function $l({screenshotPath:t,cacheBuster:s}){const[n,r]=l.useState(!1);return t&&!n?e.jsx("img",{src:at(t,s),alt:"",className:"h-[180px] w-[288px] rounded border border-[var(--border-subtle)] bg-[var(--bg-card)] object-cover object-top shrink-0",onError:()=>r(!0)}):e.jsx("div",{className:"h-[180px] w-[288px] rounded border border-[var(--border-subtle)] bg-[var(--bg-card)] shrink-0 flex items-center justify-center",children:e.jsx("span",{className:"text-[10px] text-[var(--text-dim)]",children:"No preview"})})}const V3=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRowThumbnail:$l},Symbol.toStringTag,{value:"Module"}));function Bl({onViewData:t,onRename:s,onDelete:n,deleting:r}){return e.jsxs("div",{className:"flex items-center gap-4 mt-2",children:[e.jsx("button",{onClick:t,className:"text-xs text-[var(--accent-active)] hover:opacity-70 cursor-pointer bg-transparent border-none p-0",children:"View / Edit Data"}),e.jsx("button",{onClick:s,className:"text-xs text-[var(--text-dim)] hover:text-[var(--text-primary)] cursor-pointer bg-transparent border-none p-0",children:"Rename"}),e.jsx("button",{onClick:n,disabled:r,className:"text-xs text-red-400/60 hover:text-red-400 cursor-pointer bg-transparent border-none p-0",children:"Delete"})]})}const Y3=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRowActions:Bl},Symbol.toStringTag,{value:"Module"}));function Hl({name:t,saving:s,onChange:n,onSubmit:r,onCancel:a}){return e.jsxs("form",{className:"flex items-center gap-2",onSubmit:r,onClick:o=>o.stopPropagation(),children:[e.jsx("input",{type:"text",value:t,onChange:o=>n(o.target.value),className:"flex-1 px-2 py-1.5 text-sm bg-[var(--bg-input)] text-[var(--text-primary)] border border-[var(--border-default)] rounded outline-none focus:border-[var(--accent-active)] min-w-0",autoFocus:!0,disabled:s}),e.jsx("button",{type:"submit",disabled:s||!t.trim(),className:"px-3 py-1.5 text-xs bg-[var(--accent-active)] text-[var(--bg-base)] rounded hover:opacity-90 disabled:opacity-40 cursor-pointer border-none",children:s?"...":"Save"}),e.jsx("button",{type:"button",onClick:a,className:"px-3 py-1.5 text-xs text-[var(--text-dim)] hover:text-[var(--text-primary)] cursor-pointer bg-transparent border-none",children:"Cancel"})]})}const K3=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRenameForm:Hl},Symbol.toStringTag,{value:"Module"}));function Wl({scenario:t,isSelected:s,onSelect:n,onViewData:r,onScenariosChanged:a,children:o}){const i=uv(t.slug,t.name,a),{deleting:c,handleDelete:d}=hv(t.slug,t.name,a);return e.jsxs("div",{onClick:i.renaming?void 0:n,className:`rounded-lg p-3 text-left transition cursor-pointer ${s?"bg-[#1a2e1a] border border-[var(--accent-active)]/40":"bg-[var(--bg-card)] border border-transparent hover:bg-[var(--bg-input)]"}`,style:{opacity:c?.4:1},children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx($l,{screenshotPath:t.screenshotPaths[0]??null,cacheBuster:t.screenshotCapturedAtMs}),e.jsx("div",{className:"flex-1 min-w-0",children:i.renaming?e.jsx(Hl,{name:i.renameName,saving:i.renameSaving,onChange:i.setRenameName,onSubmit:u=>{u.preventDefault(),i.submitRename()},onCancel:i.cancelRename}):e.jsxs(e.Fragment,{children:[e.jsx(zl,{scenario:t,isSelected:s}),s&&e.jsx(Bl,{onViewData:u=>{u.stopPropagation(),r()},onRename:u=>{u.stopPropagation(),i.startRename()},onDelete:d,deleting:c})]})})]}),o&&e.jsx("div",{className:"mt-3 cursor-default",onClick:u=>u.stopPropagation(),children:o})]})}const J3=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRow:Wl},Symbol.toStringTag,{value:"Module"}));function ql(){return e.jsx("div",{className:"rounded-xl border border-dashed border-[var(--border-default)] px-4 py-5 text-sm text-[var(--text-dim)]",children:"No scenarios registered for this route yet."})}const X3=Object.freeze(Object.defineProperty({__proto__:null,RouteScenarioEmptyState:ql},Symbol.toStringTag,{value:"Module"}));function Wa({scenarios:t,selectedSlug:s,onSelectScenario:n,onScenariosChanged:r}){const[a,o]=l.useState(null);return t.length===0?e.jsx(ql,{}):e.jsx("div",{className:"grid grid-cols-1 gap-2",children:t.map(i=>e.jsx(Wl,{scenario:i,isSelected:i.slug===s,onSelect:()=>{a&&a!==i.slug&&o(null),n(i.slug)},onViewData:()=>o(a===i.slug?null:i.slug),onScenariosChanged:r,children:a===i.slug&&e.jsx(Ry,{variant:"inline",slug:i.slug,scenarioName:i.name,onClose:()=>o(null)})},i.slug))})}const Q3=Object.freeze(Object.defineProperty({__proto__:null,RouteScenarioList:Wa},Symbol.toStringTag,{value:"Module"})),fv="This component renders no other tracked components.",gv="This component imports no tracked functions.",bv="Not called from any tracked entity. This may be a public export, an unused function, or a function whose callers haven't been re-analyzed yet.";function Gl({activeTab:t,entity:s,componentRefs:n,functionRefs:r,selectedSlug:a,onSelectScenario:o,onNavigateToEntity:i,onScenariosChanged:c}){return e.jsxs("div",{className:"flex-1 overflow-auto px-5 py-4",children:[t==="scenarios"&&(s.scenarios.length===0?e.jsx(ks,{copy:dv(s)}):e.jsx(Wa,{scenarios:s.scenarios,selectedSlug:a,onSelectScenario:o,onScenariosChanged:c})),t==="components"&&(n.length===0?e.jsx(ks,{copy:fv}):e.jsx(xn,{refs:n,onNavigate:i})),t==="functions"&&(r.length===0?e.jsx(ks,{copy:gv}):e.jsx(xn,{refs:r,onNavigate:i})),t==="callers"&&(s.callers.length===0?e.jsx(ks,{copy:bv}):e.jsx(xn,{refs:s.callers,onNavigate:i}))]})}function ks({copy:t}){return e.jsx("p",{className:"text-xs italic text-[var(--text-dim)]",children:t})}const Z3=Object.freeze(Object.defineProperty({__proto__:null,EmptyTabCopy:ks,EntityDetailContent:Gl},Symbol.toStringTag,{value:"Module"}));function xv(t){return typeof t!="string"&&typeof t.onClick=="function"}function yv(t){return typeof t=="string"?t:t.label}function vv(t,s){(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),s())}function Ul({segments:t}){if(t.length===0)return null;const s=t.length-1;return e.jsx("span",{className:"text-sm",style:{color:"var(--text-muted)"},children:t.map((n,r)=>{const a=yv(n),o=r===s,i=!o&&xv(n);return e.jsxs("span",{children:[e.jsx("span",{style:{color:"var(--text-dim)"},children:" / "}),i?e.jsx("button",{type:"button",onClick:n.onClick,onKeyDown:c=>vv(c,n.onClick),className:"cursor-pointer hover:text-[var(--text-primary)] transition",style:{color:"inherit",background:"none",padding:0},children:a}):e.jsx("span",{style:o?{color:"var(--text-primary)"}:void 0,children:a})]},r)})})}const e4=Object.freeze(Object.defineProperty({__proto__:null,BreadcrumbNav:Ul},Symbol.toStringTag,{value:"Module"}));function Gn({apps:t,selectedApp:s,selectedRouteEntity:n,currentEntity:r,isSingleApp:a,onSelectApps:o,onSelectApp:i,onSelectRoute:c}){const d=[];if(!a&&t.length>0&&d.push({label:"Apps",onClick:o}),s){const h=n!==null||r!=null;a&&!h||d.push({label:s.name,onClick:()=>i(s.dir)})}return n!==null&&r!=null&&n?d.push({label:n.displayName,onClick:()=>c(n.route)}):n&&d.push({label:n.displayName}),r&&d.push({label:r.displayName}),e.jsx(Ul,{segments:d})}const t4=Object.freeze(Object.defineProperty({__proto__:null,EntityBreadcrumb:Gn},Symbol.toStringTag,{value:"Module"}));function Vl({entity:t,app:s=null,routeEntity:n=null,navContext:r=Jt}){var o;const a=t.kind==="component"?"Component":"Function";return e.jsxs("header",{className:"border-b border-[var(--border-subtle)] px-5 py-3",children:[e.jsx("div",{className:"mb-1",children:e.jsx(Gn,{apps:r.apps,selectedApp:s,selectedRouteEntity:n,currentEntity:t,isSingleApp:r.isSingleApp,onSelectApps:r.onSelectApps,onSelectApp:r.onSelectApp,onSelectRoute:r.onSelectRoute})}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"rounded-md border border-[var(--border-subtle)] bg-[var(--bg-card)] px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-[var(--text-dim)]",children:a}),e.jsx("h2",{className:"text-base font-semibold text-[var(--text-primary)]",children:t.displayName})]}),e.jsx("p",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:t.filePath}),((o=t.glossaryEntry)==null?void 0:o.description)&&e.jsx("p",{className:"mt-2 text-xs text-[var(--text-secondary)]",children:t.glossaryEntry.description})]})}const s4=Object.freeze(Object.defineProperty({__proto__:null,EntityDetailHeader:Vl},Symbol.toStringTag,{value:"Module"})),jv=["scenarios","components","functions"];function qa({activeTab:t,onTabChange:s,scenarioCount:n,componentCount:r=0,functionCount:a=0,callersCount:o=0,tabs:i=jv}){const c={scenarios:"Scenarios",components:"Components",functions:"Functions",callers:"Callers"},d={scenarios:n,components:r,functions:a,callers:o};return e.jsx("div",{className:"flex w-full border-t border-b border-[var(--border-default)]",children:i.map(u=>e.jsxs("button",{onClick:()=>s(u),className:`cursor-pointer px-4 py-2 font-mono text-xs font-medium uppercase tracking-wider transition border-b-2 ${t===u?"text-[var(--accent-active)] border-[var(--accent-active)]":"text-[var(--text-dim)] border-transparent hover:text-[var(--text-muted)]"}`,type:"button",children:[c[u]," (",d[u],")"]},u))})}const n4=Object.freeze(Object.defineProperty({__proto__:null,RouteEntityTabs:qa},Symbol.toStringTag,{value:"Module"})),wv=["scenarios","components","functions"],_v=["scenarios","callers"];function Yl({app:t=null,navContext:s=Jt,routeEntity:n=null,entity:r,selectedSlug:a,onSelectScenario:o,onNavigateToEntity:i,onScenariosChanged:c}){const[d,u]=l.useState("scenarios"),{componentRefs:h,functionRefs:p}=l.useMemo(()=>{const f=[],b=[];for(const g of r.directImports)g.kind==="function"?b.push(g):f.push(g);return{componentRefs:f,functionRefs:b}},[r.directImports]),m=r.kind==="function"?_v:wv;return e.jsxs("div",{className:"flex flex-col",children:[e.jsx(Vl,{app:t,navContext:s,routeEntity:n,entity:r}),e.jsx(qa,{activeTab:d,onTabChange:u,scenarioCount:r.scenarios.length,componentCount:h.length,functionCount:p.length,callersCount:r.callers.length,tabs:m}),e.jsx(Gl,{activeTab:d,entity:r,componentRefs:h,functionRefs:p,selectedSlug:a,onSelectScenario:o,onNavigateToEntity:i,onScenariosChanged:c})]})}const r4=Object.freeze(Object.defineProperty({__proto__:null,EntityDetail:Yl},Symbol.toStringTag,{value:"Module"}));function Hs(t,s){const n=`${t}:${s}`;let r=2166136261;for(let a=0;a<n.length;a++)r^=n.charCodeAt(a),r=Math.imul(r,16777619);return(r>>>0).toString(16).padStart(8,"0")}function Qt(t){return(t.split("/").pop()??t).replace(/\.[^.]+$/,"")}function kv(t,s){const n=[],r=[];for(const a of t){const o=Qt(a);/^[A-Z]/.test(o)&&!o.startsWith("use")?n.push(a):r.push(a)}return{componentImports:n,functionImports:r}}function Kl({ancestor:t,onNavigateToEntity:s}){const n=s?()=>s(Hs(t.filePath,Qt(t.filePath))):void 0;return e.jsxs("div",{role:"button",tabIndex:0,onClick:n,onKeyDown:r=>{n&&(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),n())},className:"cursor-pointer rounded-md border border-[var(--border-subtle)] bg-[var(--bg-card)] px-3 py-2 transition hover:border-[var(--border-default)]",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--text-primary)]",children:t.displayName}),e.jsx("p",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:t.filePath})]})}const a4=Object.freeze(Object.defineProperty({__proto__:null,LayoutChainCard:Kl},Symbol.toStringTag,{value:"Module"}));function Jl({layoutChain:t,onNavigateToEntity:s}){return t.length===0?null:e.jsxs("section",{className:"border-b border-[var(--border-subtle)] px-5 py-3",children:[e.jsx("h3",{className:"mb-2 text-xs font-medium uppercase tracking-wide text-[var(--text-dim)]",children:"Layout chain"}),e.jsx("div",{className:"flex flex-col gap-1",children:t.map(n=>e.jsx(Kl,{ancestor:n,onNavigateToEntity:s},`${n.kind}:${n.filePath}`))})]})}const o4=Object.freeze(Object.defineProperty({__proto__:null,LayoutChainSection:Jl},Symbol.toStringTag,{value:"Module"}));function Sv({importPath:t,derivedName:s,allScenarios:n,routeEntities:r}){const a=n.filter(i=>i.scenarioType==="component"&&(i.pageFilePath===t||i.componentName===s)),o=r.filter(i=>i.directImports.length===1&&i.directImports[0]===t&&Qt(i.directImports[0])===s);if(o.length===1){const i=o[0].scenarios,c=[...a];for(const d of i)c.some(u=>u.slug===d.slug)||c.push(d);return c}return a}function yn(t){const s=[];for(const n of t.split("/"))n===""||n==="."||(n===".."?s.pop():s.push(n));return s.join("/")}function Nv(t){const s=new Map;for(const[n,r]of Object.entries(t)){const a=yn(n),o=Qt(a),i=Hs(a,o);s.has(i)||s.set(i,{hash:i,filePath:a,entityName:o,imports:r.imports.map(yn),importedBy:r.importedBy.map(yn)})}return s}function Cv(t,s){if(!t)return null;const n=yn(s);for(const r of t.values())if(r.filePath===n)return r;return null}function Xl(t,s){if(!t)return[];const n=[];for(const r of s){const a=Cv(t,r);a&&n.push(a)}return n}function Tv(t,s){return t.find(n=>n.pageFilePath===s)??null}function Ql(t){const s=t.split("/"),n=s.pop()??t,r=s.join("/");return{fileName:n,dirPath:r}}function Zl({displayName:t,entity:s,isNavigable:n}){return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-lg font-semibold text-[var(--text-secondary)]",children:t}),s?e.jsx("span",{className:"rounded bg-[var(--bg-input)] px-1.5 py-0.5 font-mono text-[9px] text-[var(--text-dim)]",children:s.hash.slice(0,8)}):null,n?e.jsx("span",{className:"ml-auto text-[10px] text-[var(--text-dim)]",children:"→"}):null]})}const i4=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyCardHeader:Zl},Symbol.toStringTag,{value:"Module"}));function ec({scenarios:t,onSelectScenario:s}){return t.length===0?e.jsx("p",{className:"mt-1 text-[10px] text-[var(--text-dim)]",children:"No scenarios"}):e.jsxs("div",{className:"mt-2 flex flex-row gap-1.5",children:[t.slice(0,4).map(n=>{const r=n.screenshotPaths[0]??null;return e.jsxs("button",{type:"button",onClick:a=>{a.stopPropagation(),s(n.slug)},className:"flex w-[192px] shrink-0 flex-col gap-1 transition",children:[e.jsx("div",{className:"rounded border border-[var(--border-subtle)] bg-[var(--bg-card)] transition hover:border-[var(--border-default)]",children:r?e.jsx("img",{src:at(r),alt:n.name,className:"h-[120px] w-[192px] rounded object-cover object-top",onError:a=>{a.currentTarget.style.visibility="hidden"}}):e.jsx("div",{className:"flex h-[120px] w-[192px] items-center justify-center rounded",children:e.jsx("span",{className:"text-[8px] text-[var(--text-dim)]",children:"--"})})}),e.jsx("span",{className:"w-full truncate text-center text-[10px] text-[var(--text-secondary)]",children:n.name})]},n.slug)}),t.length>4&&e.jsx("div",{className:"flex h-[120px] items-center px-1",children:e.jsxs("span",{className:"text-[10px] text-[var(--text-dim)]",children:["+",t.length-4]})})]})}const l4=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyScenarioStrip:ec},Symbol.toStringTag,{value:"Module"}));function tc({importPath:t,entity:s,scenarios:n,onNavigate:r,onSelectScenario:a}){const{fileName:o,dirPath:i}=Ql(t),c=(s==null?void 0:s.entityName)??o.replace(/\.[^.]+$/,"");return e.jsxs("div",{role:r?"button":void 0,tabIndex:r?0:void 0,onClick:r??void 0,onKeyDown:r?d=>{(d.key==="Enter"||d.key===" ")&&r()}:void 0,className:`rounded-lg border border-[var(--border-subtle)] bg-[var(--bg-card)] p-3 transition hover:border-[var(--border-default)] ${r?"cursor-pointer":""}`,children:[e.jsx(Zl,{displayName:c,entity:s,isNavigable:r!==null}),e.jsxs("p",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:[i,"/"]}),e.jsx(ec,{scenarios:n,onSelectScenario:a})]})}const c4=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyCard:tc},Symbol.toStringTag,{value:"Module"}));function sc(){return e.jsx("p",{className:"py-4 text-center text-xs text-[var(--text-dim)]",children:"No dependencies found"})}const d4=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyEmptyState:sc},Symbol.toStringTag,{value:"Module"}));function nc({directImports:t,entityLookup:s,allScenarios:n,routeEntities:r,onNavigateToRoute:a,onNavigateToEntity:o,onSelectScenario:i}){const c=l.useMemo(()=>Xl(s,t),[s,t]);return t.length===0?e.jsx(sc,{}):e.jsx("div",{className:"grid grid-cols-1 gap-1",children:t.map(d=>{const u=c.find(g=>g.filePath===d)??null,h=(u==null?void 0:u.entityName)??Qt(d),p=Sv({importPath:d,derivedName:h,allScenarios:n??[],routeEntities:r??[]}),m=Tv(r??[],d),f=Hs(d,h),b=m?()=>a(m.route):o?()=>o(f):null;return e.jsx(tc,{importPath:d,entity:u,scenarios:p,onNavigate:b,onSelectScenario:i},d)})})}const u4=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyList:nc},Symbol.toStringTag,{value:"Module"}));function Pv(t,s,n){const r=new Set,a=t.replace(/\.(ts|tsx)$/,"");r.add(`${a}.test.ts`),r.add(`${a}.test.tsx`);const o=s.get(t);if(o!=null&&o.importedBy)for(const c of o.importedBy)/\.test\.(ts|tsx)$/.test(c)&&r.add(c);return n.flatMap(c=>c.tests).filter(c=>r.has(c.file))}function rc({status:t}){return t==="passed"?e.jsx("span",{className:"mt-0.5 text-xs text-[var(--accent-green)]",children:"✓"}):t==="failed"?e.jsx("span",{className:"mt-0.5 text-xs text-[var(--accent-red)]",children:"✗"}):e.jsx("span",{className:"mt-0.5 text-xs text-[var(--text-dim)]",children:"○"})}const h4=Object.freeze(Object.defineProperty({__proto__:null,TestStatusIcon:rc},Symbol.toStringTag,{value:"Module"}));function ac({test:t}){const s=t.description.length>0;return e.jsxs("div",{className:"flex items-start gap-2 py-1",children:[e.jsx(rc,{status:t.status}),e.jsx("div",{children:s?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:t.description}),e.jsx("p",{className:"font-mono text-xs text-[var(--text-dim)]",children:t.key})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:t.key}),e.jsx("p",{className:"text-xs italic text-[var(--text-dim)]",children:"no description"})]})})]})}const p4=Object.freeze(Object.defineProperty({__proto__:null,TestItem:ac},Symbol.toStringTag,{value:"Module"}));function oc({importPath:t,entityName:s,tests:n,onNavigate:r}){const{dirPath:a}=Ql(t);return e.jsxs("div",{role:r?"button":void 0,tabIndex:r?0:void 0,onClick:r??void 0,onKeyDown:r?o=>{(o.key==="Enter"||o.key===" ")&&r()}:void 0,className:`rounded-lg border border-[var(--border-subtle)] bg-[var(--bg-card)] p-3 transition hover:border-[var(--border-default)] ${r?"cursor-pointer":""}`,children:[e.jsx("p",{className:"text-sm font-medium text-[var(--text-primary)]",children:s}),e.jsxs("p",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:[a,"/"]}),e.jsx("div",{className:"mt-2",children:n.length>0?e.jsx("div",{className:"space-y-0.5",children:n.map((o,i)=>e.jsx(ac,{test:o},`${o.file}:${o.key??o.line??i}`))}):e.jsx("p",{className:"text-xs text-[var(--text-dim)] italic",children:"No tests"})})]})}const m4=Object.freeze(Object.defineProperty({__proto__:null,RouteFunctionCard:oc},Symbol.toStringTag,{value:"Module"}));function ic(){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"No function imports found"}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-dim)]",children:"This component only imports other components"})]})}const f4=Object.freeze(Object.defineProperty({__proto__:null,RouteFunctionEmptyState:ic},Symbol.toStringTag,{value:"Module"}));function lc({functionImports:t,entityLookup:s,testGroups:n,onNavigateToEntity:r}){const a=l.useMemo(()=>Xl(s,t),[s,t]);return t.length===0?e.jsx(ic,{}):e.jsx("div",{className:"grid grid-cols-1 gap-1",children:t.map(o=>{const i=a.find(h=>h.filePath===o)??null,c=(i==null?void 0:i.entityName)??Qt(o),d=Pv(o,s,n),u=r?()=>r(Hs(o,c)):null;return e.jsx(oc,{importPath:o,entityName:c,tests:d,onNavigate:u},o)})})}const g4=Object.freeze(Object.defineProperty({__proto__:null,RouteFunctionList:lc},Symbol.toStringTag,{value:"Module"}));function cc({activeTab:t,routeEntity:s,componentImports:n,functionImports:r,testGroups:a,selectedSlug:o,entityLookup:i,allScenarios:c,routeEntities:d,onSelectScenario:u,onNavigateToRoute:h,onNavigateToEntity:p,onScenariosChanged:m}){return e.jsxs("div",{className:"flex-1 overflow-auto px-5 py-4",children:[t==="scenarios"&&e.jsx(Wa,{scenarios:s.scenarios,selectedSlug:o,onSelectScenario:u,onScenariosChanged:m}),t==="components"&&e.jsx(nc,{directImports:n,entityLookup:i,allScenarios:c,routeEntities:d,onNavigateToRoute:h,onNavigateToEntity:p,onSelectScenario:u}),t==="functions"&&e.jsx(lc,{functionImports:r,entityLookup:i,testGroups:a,onNavigateToEntity:p})]})}const b4=Object.freeze(Object.defineProperty({__proto__:null,RouteEntityDetailContent:cc},Symbol.toStringTag,{value:"Module"}));function dc({displayName:t,pageFilePath:s,app:n=null,routeEntity:r=null,navContext:a=Jt}){return e.jsxs("div",{className:"px-5 py-4",children:[e.jsx("div",{className:"mb-2",children:e.jsx(Gn,{apps:a.apps,selectedApp:n,selectedRouteEntity:r,isSingleApp:a.isSingleApp,onSelectApps:a.onSelectApps,onSelectApp:a.onSelectApp,onSelectRoute:a.onSelectRoute})}),e.jsx("h2",{className:"text-xl font-medium text-[var(--text-primary)]",children:t}),s?e.jsx("p",{className:"mt-1 font-mono text-xs text-[var(--text-dim)]",children:s}):null]})}const x4=Object.freeze(Object.defineProperty({__proto__:null,RouteEntityDetailHeader:dc},Symbol.toStringTag,{value:"Module"}));function uc({app:t=null,navContext:s=Jt,routeEntity:n,selectedSlug:r,entityLookup:a,allScenarios:o,routeEntities:i,testGroups:c,onSelectScenario:d,onNavigateToRoute:u,onNavigateToEntity:h,onScenariosChanged:p}){const[m,f]=l.useState("scenarios"),{componentImports:b,functionImports:g}=l.useMemo(()=>kv(n.directImports),[n.directImports]);return e.jsxs("div",{className:"flex flex-col",children:[e.jsx(dc,{app:t,navContext:s,routeEntity:n,displayName:n.displayName,pageFilePath:n.pageFilePath}),e.jsx(Jl,{layoutChain:n.layoutChain??[],onNavigateToEntity:h}),e.jsx(qa,{activeTab:m,onTabChange:f,scenarioCount:n.scenarios.length,componentCount:b.length,functionCount:g.length}),e.jsx(cc,{activeTab:m,routeEntity:n,componentImports:b,functionImports:g,testGroups:c,selectedSlug:r,entityLookup:a,allScenarios:o,routeEntities:i,onSelectScenario:d,onNavigateToRoute:u,onNavigateToEntity:h,onScenariosChanged:p})]})}const y4=Object.freeze(Object.defineProperty({__proto__:null,RouteEntityDetail:uc},Symbol.toStringTag,{value:"Module"}));function hc(){return e.jsx("div",{className:"px-5 py-8 text-center text-[var(--text-dim)]",children:"No routes discovered yet."})}const v4=Object.freeze(Object.defineProperty({__proto__:null,RouteListEmptyState:hc},Symbol.toStringTag,{value:"Module"}));function Ar(t){const s=rv(t);if(s)return{selectedAppDir:s,selectedEntityHash:null};const n=av(t);return n?{selectedAppDir:null,selectedEntityHash:n}:{selectedAppDir:null,selectedEntityHash:null}}function Rr(t){return`/apps/${t}`}function Ov(t){return`/entities/${t}`}function Qr(t){return t.pageFilePath?Hs(t.pageFilePath,Qt(t.pageFilePath)):null}function pc(t){const s=Qr(t);return s===null?null:Ov(s)}function Ga({href:t,onNavigate:s,children:n,...r}){return e.jsx("a",{...r,href:t,onClick:a=>{a.button===0&&!a.metaKey&&!a.ctrlKey&&!a.shiftKey&&!a.altKey&&(a.preventDefault(),s())},children:n})}const j4=Object.freeze(Object.defineProperty({__proto__:null,NavLink:Ga},Symbol.toStringTag,{value:"Module"}));function mc({scenario:t,onSelect:s}){const n=t.screenshotPaths[0]??null,[r,a]=l.useState(!1),o=n&&!r;return e.jsxs("button",{type:"button",onClick:s,className:`relative text-left w-full${s?" cursor-pointer group/thumb":""}`,children:[o?e.jsx("img",{src:at(n),alt:t.name,className:"aspect-[16/10] w-full rounded border border-[var(--border-subtle)] bg-[var(--bg-card)] object-cover object-top transition group-hover/thumb:border-[var(--text-dim)]",onError:()=>a(!0)}):e.jsx("div",{className:"aspect-[16/10] w-full rounded border border-[var(--border-subtle)] bg-[var(--bg-card)] flex items-center justify-center transition group-hover/thumb:border-[var(--text-dim)]",children:e.jsx("span",{className:"text-[10px] text-[var(--text-dim)]",children:"No preview"})}),t.dimensions.length>0?e.jsx("span",{className:"absolute bottom-1 right-1 rounded bg-black/60 px-1 py-0.5 text-[8px] text-white",children:t.dimensions[0]}):null,e.jsx("p",{className:"mt-1 truncate text-[10px] text-[var(--text-dim)]",children:t.name})]})}const w4=Object.freeze(Object.defineProperty({__proto__:null,RouteListCardThumbnail:mc},Symbol.toStringTag,{value:"Module"}));function fc({routeEntity:t,onSelectRoute:s,onSelectScenario:n}){const r=t.scenarios.length,a=pc(t),o="group flex w-full cursor-pointer items-center gap-2 text-left",i=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)] group-hover:text-[var(--text-primary)] transition",children:t.displayName}),e.jsx("span",{className:"font-mono text-xs text-[var(--text-dim)]",children:t.route}),r>0?e.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:["[",r,"]"]}):null,e.jsx("span",{className:"ml-auto text-xs text-[var(--text-dim)] group-hover:text-[var(--text-muted)] transition",children:"›"})]});return e.jsxs("div",{className:"mb-4",children:[a?e.jsx(Ga,{href:a,onNavigate:()=>s(t.route),className:o,children:i}):e.jsx("button",{onClick:()=>s(t.route),className:o,type:"button",children:i}),r>0?e.jsx("div",{className:"mt-2 grid grid-cols-3 gap-2",children:t.scenarios.map(c=>e.jsx(mc,{scenario:c,onSelect:n?()=>n(c.slug):void 0},c.slug))}):e.jsx("p",{className:"mt-1 text-[10px] text-[var(--text-dim)]",children:"No scenarios yet"})]})}const _4=Object.freeze(Object.defineProperty({__proto__:null,RouteListCard:fc},Symbol.toStringTag,{value:"Module"}));function gc({label:t="Pages"}={}){return e.jsx("div",{className:"mb-3",children:e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-[var(--text-dim)]",children:t})})}const k4=Object.freeze(Object.defineProperty({__proto__:null,RouteListSectionHeader:gc},Symbol.toStringTag,{value:"Module"}));function Zr({label:t,routeEntities:s,onSelectRoute:n,onSelectScenario:r,className:a}){return e.jsxs("div",{className:a,children:[e.jsx(gc,{label:t}),e.jsx("div",{children:s.map(o=>e.jsx(fc,{routeEntity:o,onSelectRoute:n,onSelectScenario:r},o.route))})]})}const S4=Object.freeze(Object.defineProperty({__proto__:null,RouteListSection:Zr},Symbol.toStringTag,{value:"Module"}));function bc({routeEntities:t,onSelectRoute:s,onSelectScenario:n}){if(t.length===0)return e.jsx(hc,{});const r=t.filter(o=>(o.kind??"application")==="application"),a=t.filter(o=>o.kind==="component");return e.jsxs("div",{className:"px-5 py-5",children:[r.length>0&&e.jsx(Zr,{label:"Pages",routeEntities:r,onSelectRoute:s,onSelectScenario:n}),a.length>0&&e.jsx(Zr,{label:"Components",routeEntities:a,onSelectRoute:s,onSelectScenario:n,className:r.length>0?"mt-8":void 0})]})}const N4=Object.freeze(Object.defineProperty({__proto__:null,RouteList:bc},Symbol.toStringTag,{value:"Module"}));function xc({feature:t,passed:s,failed:n,total:r}){return e.jsxs("div",{className:"px-5 py-2 flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:t}),e.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:[r," test",r!==1?"s":""]}),r>0&&e.jsxs("span",{className:`text-xs font-medium ${n>0?"text-[var(--accent-red)]":"text-[var(--accent-green)]"}`,children:[s,"/",r]})]})}const C4=Object.freeze(Object.defineProperty({__proto__:null,TestGroupHeader:xc},Symbol.toStringTag,{value:"Module"}));function yc({test:t}){const s=(t.description??"").length>0,n=t.status==="passed"?"text-[var(--accent-green)]":t.status==="failed"?"text-[var(--accent-red)]":"text-[var(--text-dim)]",r=t.status==="passed"?"✓":t.status==="failed"?"✗":"○";return e.jsxs("div",{className:"flex items-start gap-2 py-1 px-3",children:[e.jsx("span",{className:`text-xs leading-5 ${n}`,children:r}),e.jsx("div",{className:"min-w-0",children:s?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs text-[var(--text-secondary)] truncate",children:t.description}),e.jsx("p",{className:"font-mono text-[10px] text-[var(--text-dim)] truncate",children:t.key})]}):e.jsx("p",{className:"text-xs text-[var(--text-secondary)] truncate",children:t.key})})]})}const T4=Object.freeze(Object.defineProperty({__proto__:null,TestGroupRow:yc},Symbol.toStringTag,{value:"Module"}));function vc({groups:t}){return t.length===0?e.jsx("div",{className:"px-5 py-8 text-center text-[var(--text-dim)]",children:"No tests found."}):e.jsx("div",{className:"py-3",children:t.map(s=>{const n=s.tests.filter(o=>o.status==="passed").length,r=s.tests.filter(o=>o.status==="failed").length,a=s.tests.length;return e.jsxs("div",{className:"mb-1",children:[e.jsx(xc,{feature:s.feature,passed:n,failed:r,total:a}),e.jsx("div",{className:"px-5 pb-2",children:s.tests.map((o,i)=>e.jsx(yc,{test:o},`${o.file}-${o.key??o.line??i}`))})]},s.feature)})})}const P4=Object.freeze(Object.defineProperty({__proto__:null,TestGroupList:vc},Symbol.toStringTag,{value:"Module"}));function jc({app:t=null,navContext:s=Jt,isWeb:n,routeEntities:r,routesLoading:a,routesError:o,selectedEntityHash:i,selectedRouteEntity:c,testGroups:d,selectedSlug:u,entityLookup:h,allScenarios:p,onSelectScenario:m,onSelectRoute:f,onSelectEntity:b,onBackToRoutes:g,onScenariosChanged:v}){const x=cv(i&&!c?i:null);return n?a?e.jsx(Xr,{}):o?e.jsx(bn,{message:o}):c?e.jsx(uc,{app:t,navContext:s,routeEntity:c,selectedSlug:u,entityLookup:h,allScenarios:p,routeEntities:r,testGroups:d,onSelectScenario:m,onNavigateToRoute:f,onNavigateToEntity:b,onScenariosChanged:v}):i?x.status==="loading"||x.status==="idle"?e.jsx(Xr,{}):x.status==="not-found"?e.jsx(bn,{message:"Entity not found. The dependency graph may need to be refreshed."}):x.status==="error"?e.jsx(bn,{message:x.message}):e.jsx(Yl,{app:t,navContext:s,routeEntity:c,entity:x.entity,selectedSlug:u,onSelectScenario:m,onNavigateToEntity:b??(()=>{}),onScenariosChanged:v}):e.jsx(bc,{routeEntities:r,onSelectRoute:f,onSelectScenario:m}):e.jsx(vc,{groups:d})}const O4=Object.freeze(Object.defineProperty({__proto__:null,AppDetailContent:jc},Symbol.toStringTag,{value:"Module"}));function Ua({coverage:t,prefix:s,testId:n,className:r,onClick:a}){if(!t||t.totalLines===0)return null;const o=`${Math.round(t.percent)}% coverage`,i=e.jsxs(e.Fragment,{children:[s??"",o]}),c=`${t.hitLines}/${t.totalLines} lines covered`;return a?e.jsx("span",{role:"button",tabIndex:0,className:r??"text-xs font-medium text-[var(--accent-active)] hover:underline cursor-pointer","data-testid":n??"coverage-badge",title:c,onClick:d=>{d.stopPropagation(),a()},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.stopPropagation(),d.preventDefault(),a())},children:i}):e.jsx("span",{className:r??"text-xs font-medium text-[var(--text-secondary)]","data-testid":n??"coverage-badge",title:c,children:i})}const A4=Object.freeze(Object.defineProperty({__proto__:null,CoverageBadge:Ua},Symbol.toStringTag,{value:"Module"}));function wc({app:t,showDetail:s,navContext:n=Jt,stats:r,testsLoading:a,testsRefreshing:o,onRunTests:i,currentRunner:c,coverage:d,onCoverageClick:u}){if(s)return null;const h=!!(d&&d.totalLines>0);return e.jsxs("div",{className:"px-5 py-4 border-b border-[var(--border-default)]",children:[e.jsx("div",{className:"mb-2",children:e.jsx(Gn,{apps:n.apps,selectedApp:t,selectedRouteEntity:null,isSingleApp:n.isSingleApp,onSelectApps:n.onSelectApps,onSelectApp:n.onSelectApp,onSelectRoute:n.onSelectRoute})}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:"text-lg font-medium text-[var(--text-primary)]",children:t.name}),e.jsx(Ha,{type:t.type})]}),h?e.jsx(Ua,{coverage:d,testId:"app-detail-coverage",onClick:u}):null]}),t.description?e.jsx("p",{className:"text-sm text-[var(--text-muted)] mt-1",children:t.description}):null,r?e.jsx("div",{className:"mt-3",children:e.jsx(Ba,{tests:r.tests,loading:a,refreshing:o,onRunTests:i,currentRunner:c})}):null]})}const R4=Object.freeze(Object.defineProperty({__proto__:null,AppDetailHeader:wc},Symbol.toStringTag,{value:"Module"}));function _c({name:t,id:s,capabilitiesTally:n,expanded:r,onToggle:a}){const o=t??s;return e.jsxs("button",{type:"button",onClick:a,className:"flex w-full items-center gap-2 text-left text-xs text-[var(--text-secondary)] hover:text-[var(--text-primary)]","data-testid":"stack-summary","aria-expanded":r,children:[e.jsx("span",{className:`inline-block transition-transform ${r?"rotate-90":""}`,children:"▶"}),e.jsxs("span",{className:"font-medium text-[var(--text-primary)]",children:["Stack",o?` — ${o}`:""]}),t&&s?e.jsxs("span",{className:"text-[var(--text-dim)]",children:["(",s,")"]}):null,e.jsxs("span",{className:"text-[var(--text-dim)]",children:["— ",n]})]})}const E4=Object.freeze(Object.defineProperty({__proto__:null,AppStackPanelSummary:_c},Symbol.toStringTag,{value:"Module"})),ea=["layout-web","interactions-click","interactions-touch-gestures","native-haptics","native-geolocation","native-clipboard","native-network","native-storage","routing","http-mocks","real-device"],kc={"layout-web":{label:"Web layout",description:"Visual layout and styling rendered in the web preview"},"interactions-click":{label:"Click interactions",description:"Pointer / click-driven UI behavior"},"interactions-touch-gestures":{label:"Touch gestures",description:"Swipe, pinch, and other multi-touch gestures"},"native-haptics":{label:"Haptic feedback",description:"Vibration / tactile feedback APIs"},"native-geolocation":{label:"Geolocation",description:"Device location APIs"},"native-clipboard":{label:"Clipboard",description:"Native copy / paste access"},"native-network":{label:"Network status",description:"Connectivity / reachability APIs"},"native-storage":{label:"Persistent storage",description:"On-device persistence (preferences, local DB, secure store). A 'manual' state here flags real-device verification — it does NOT mean the web preview can't be seeded; the editor still seeds storage from the adapter"},routing:{label:"Routing",description:"Navigation between screens / pages"},"http-mocks":{label:"HTTP mocking",description:"Network requests intercepted and replayed from scenarios"},"real-device":{label:"Real-device behavior",description:"Behavior that only manifests on a physical device or native build"}},Sc={verified:{label:"Verified",badgeClass:"bg-[var(--accent-green)]/20 text-[var(--accent-green)]",meaning:"The editor's scenarios actually exercise this — a regression fails a test."},stubbed:{label:"Stubbed",badgeClass:"bg-[var(--accent-orange)]/20 text-[var(--accent-orange)]",meaning:"No-op'd in web preview (e.g. a native API logged to console). Tests don't fail, but nothing is really verified — check on a real device."},manual:{label:"Manual",badgeClass:"bg-[var(--accent-blue)]/20 text-[var(--accent-blue)]",meaning:"Must be checked by hand on a real device or native build target. This is orthogonal to seeding: the editor still seeds this into the web preview — 'manual' only flags the real-device check."},"not-applicable":{label:"N/A",badgeClass:"bg-[var(--bg-subtle)] text-[var(--text-dim)]",meaning:"This stack doesn't expose the capability."}};function Av(t){var s;return((s=kc[t])==null?void 0:s.label)??t}function Rv(t,s){var a,o;const n=(a=kc[t])==null?void 0:a.description,r=((o=Sc[s])==null?void 0:o.meaning)??"";return n?`${n}. ${r}`:r}function Nc({capabilities:t,defaultExpanded:s=!1}){const[n,r]=l.useState(s),a=ea.filter(c=>c in t),o=Object.keys(t).filter(c=>!ea.includes(c)),i={verified:0,stubbed:0,manual:0,"not-applicable":0};for(const c of a){const d=t[c];d in i&&(i[d]+=1)}return e.jsxs("div",{className:"px-5 py-2","data-testid":"capabilities-panel",children:[e.jsxs("button",{type:"button",onClick:()=>r(c=>!c),className:"flex w-full items-center gap-2 text-left text-xs text-[var(--text-secondary)] hover:text-[var(--text-primary)]","data-testid":"capabilities-summary","aria-expanded":n,children:[e.jsx("span",{className:`inline-block transition-transform ${n?"rotate-90":""}`,children:"▶"}),e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:"Stack capabilities"}),e.jsxs("span",{className:"text-[var(--text-dim)]",children:["— ",i.verified," verified · ",i.stubbed," stubbed ·"," ",i.manual," manual · ",i["not-applicable"]," n/a"]})]}),n?e.jsxs("div",{className:"mt-2 space-y-1","data-testid":"capabilities-rows",children:[a.map(c=>e.jsx(ta,{token:c,state:t[c]},c)),o.length>0?e.jsxs("div",{className:"mt-3","data-testid":"capabilities-unknown-group",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs font-medium text-[var(--accent-warn)]",children:[e.jsx("span",{title:"These tokens aren't recognized — likely typos",children:"⚠"}),"Unknown capabilities"]}),o.map(c=>e.jsx(ta,{token:c,state:t[c],unknown:!0},c))]}):null]}):null]})}function ta({token:t,state:s,unknown:n}){const r=Sc[s],a=n?"This token isn't recognized — may be a typo.":Rv(t,s);return e.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs","data-testid":`capability-row-${t}`,children:[e.jsxs("span",{className:"flex items-center gap-1 text-[var(--text-secondary)]",children:[Av(t),e.jsx("span",{className:"cursor-help text-[var(--text-dim)]",title:a,"aria-label":a,children:"ⓘ"})]}),e.jsx("span",{className:`rounded px-1.5 py-0.5 ${(r==null?void 0:r.badgeClass)??"bg-[var(--bg-subtle)] text-[var(--text-dim)]"}`,children:(r==null?void 0:r.label)??s})]})}const M4=Object.freeze(Object.defineProperty({__proto__:null,AppCapabilitiesPanel:Nc,CapabilityRow:ta},Symbol.toStringTag,{value:"Module"}));function Cc({capabilities:t}){return t&&Object.keys(t).length>0?e.jsx(Nc,{capabilities:t,defaultExpanded:!1}):e.jsxs("div",{className:"text-xs text-[var(--text-dim)]","data-testid":"stack-capabilities-empty-hint",children:["Capabilities not declared. Run"," ",e.jsx("code",{className:"rounded bg-[var(--bg-subtle)] px-1 py-0.5 text-[var(--text-secondary)]",children:"codeyam-editor editor capabilities-list"})," ","to learn more."]})}const I4=Object.freeze(Object.defineProperty({__proto__:null,AppStackCapabilitiesSlot:Cc},Symbol.toStringTag,{value:"Module"}));function Tc({fields:t,capabilities:s}){return e.jsxs("div",{className:"mt-2 space-y-2","data-testid":"stack-body",children:[t.description?e.jsx("p",{className:"text-xs text-[var(--text-secondary)]","data-testid":"stack-description",children:t.description}):null,t.technologies.length>0?e.jsx("ul",{className:"flex flex-wrap gap-1","data-testid":"stack-technologies",children:t.technologies.map(n=>e.jsx("li",{className:"rounded bg-[var(--bg-subtle)] px-1.5 py-0.5 text-[10px] text-[var(--text-secondary)]",children:n},n))}):null,t.commands.length>0?e.jsx("dl",{className:"space-y-0.5 text-xs","data-testid":"stack-commands",children:t.commands.map(({key:n,value:r})=>e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("dt",{className:"w-10 text-[var(--text-dim)]",children:n}),e.jsx("dd",{className:"text-[var(--text-secondary)]",children:e.jsx("code",{className:"rounded bg-[var(--bg-subtle)] px-1 py-0.5",children:r})})]},n))}):null,t.routingSummary?e.jsxs("div",{className:"text-xs text-[var(--text-secondary)]","data-testid":"stack-routing",children:[e.jsx("span",{className:"text-[var(--text-dim)]",children:"routing"})," ",t.routingSummary]}):null,e.jsx("div",{className:"border-t border-[var(--border-subtle)] pt-2",children:e.jsx(Cc,{capabilities:s})})]})}const D4=Object.freeze(Object.defineProperty({__proto__:null,AppStackPanelBody:Tc},Symbol.toStringTag,{value:"Module"}));function Pc({skip:t=!1}={}){const[s,n]=l.useState(null);return l.useEffect(()=>{if(t)return;let r=!1;return fetch("/api/project-stack").then(a=>a.ok?a.json():{}).then(a=>{r||n(a&&typeof a=="object"&&!Array.isArray(a)?a:{})}).catch(()=>{r||n({})}),()=>{r=!0}},[t]),s}const Ev=["dev","test","build"];function Ct(t){return typeof t=="string"&&t.length>0?t:null}function Oc(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function Mv(t){return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}function Iv(t){const s=Oc(t);if(!s)return[];const n=[];for(const r of Ev){const a=Ct(s[r]);a&&n.push({key:r,value:a})}return n}function Dv(t){const s=Oc(t);if(!s)return null;const n=Ct(s.type);if(!n)return null;const r=Ct(s.pagesDir)??Ct(s.isolationRoute)??Ct(s.componentManifest);return r?`${n} (${r})`:n}function Lv(t){const s=t.capabilities;return!s||typeof s!="object"||Array.isArray(s)?null:s}function Fv(t){if(!t||Object.keys(t).length===0)return"capabilities not declared";const s={verified:0,stubbed:0,manual:0,"not-applicable":0};for(const n of ea){const r=t[n];r&&r in s&&(s[r]+=1)}return`${s.verified} verified · ${s.stubbed} stubbed · ${s.manual} manual · ${s["not-applicable"]} n/a`}function zv(t){return t?{id:Ct(t.id),name:Ct(t.name),description:Ct(t.description),technologies:Mv(t.technologies),commands:Iv(t.commands),routingSummary:Dv(t.routing)}:{id:null,name:null,description:null,technologies:[],commands:[],routingSummary:null}}function Ac({stack:t,defaultExpanded:s=!1}){const n=t!==void 0,[r,a]=l.useState(s),o=Pc({skip:n}),i=n?t:o;if(!i||Object.keys(i).length===0)return null;const c=zv(i),d=Lv(i);return e.jsxs("div",{className:"px-5 py-2","data-testid":"stack-panel",children:[e.jsx(_c,{name:c.name,id:c.id,capabilitiesTally:Fv(d),expanded:r,onToggle:()=>a(u=>!u)}),r?e.jsx(Tc,{fields:c,capabilities:d}):null]})}const L4=Object.freeze(Object.defineProperty({__proto__:null,AppStackPanel:Ac},Symbol.toStringTag,{value:"Module"}));function Rc({app:t,navContext:s=Jt,routeEntities:n,routesLoading:r,routesError:a,selectedEntityHash:o,selectedRouteEntity:i,testGroups:c,selectedSlug:d,entityLookup:u,allScenarios:h,onSelectScenario:p,onSelectRoute:m,onSelectEntity:f,onBackToRoutes:b,onScenariosChanged:g,coverage:v,showProjectBand:x,onCoverageClick:y,stats:w,testsLoading:j,testsRefreshing:k,onRunTests:S,currentRunner:N}){const T=t.type==="web",A=!!x&&!i;return e.jsxs("div",{children:[A?e.jsx(Ac,{}):null,e.jsx(wc,{app:t,showDetail:!!(i||o),navContext:s,stats:w,testsLoading:j,testsRefreshing:k,onRunTests:S,currentRunner:N,coverage:A?v:void 0,onCoverageClick:y}),e.jsx(jc,{app:t,navContext:s,isWeb:T,routeEntities:n,routesLoading:r,routesError:a,selectedEntityHash:o??null,selectedRouteEntity:i,testGroups:c,selectedSlug:d,entityLookup:u,allScenarios:h,onSelectScenario:p,onSelectRoute:m,onSelectEntity:f,onBackToRoutes:b,onScenariosChanged:g})]})}const F4=Object.freeze(Object.defineProperty({__proto__:null,AppDetail:Rc},Symbol.toStringTag,{value:"Module"}));function Ec(t){const s=new Date(t);if(isNaN(s.getTime()))return t;const n=new Date,r=n.getTime()-s.getTime(),a=Math.floor(r/6e4),o=Math.floor(r/36e5),i=Math.floor(r/864e5);return a<1?"just now":a<60?`${a}m ago`:o<24?`${o}h ago`:i<7?`${i}d ago`:s.toLocaleDateString("en-US",{month:"short",day:"numeric",year:s.getFullYear()!==n.getFullYear()?"numeric":void 0})}function Mc(t){switch(t){case"feature":return"text-[#D7FF63]";case"fix":return"text-red-400";case"refactor":return"text-purple-400";case"milestone":return"text-yellow-400";default:return"text-gray-400"}}function z4(t){let s=0,n=0,r=0;for(const a of t)a.status==="added"?s++:a.status==="deleted"?r++:n++;return{added:s,modified:n,deleted:r}}function Va({total:t,passed:s,failed:n}){if(t===0)return null;const r=n>0?"text-[var(--accent-red)]":"text-[var(--accent-green)]";return e.jsxs("span",{className:`text-xs ${r}`,children:[s,"/",t," passed"]})}const $4=Object.freeze(Object.defineProperty({__proto__:null,TestResultsBadge:Va},Symbol.toStringTag,{value:"Module"})),$v=192;function Ya({children:t,variant:s="compact",maxHeight:n=$v}){const r=l.useRef(null),[a,o]=l.useState(!1),[i,c]=l.useState(!1);return l.useEffect(()=>{const d=r.current;if(!d)return;const u=()=>c(d.scrollHeight>n);u();const h=new ResizeObserver(u);return h.observe(d),()=>h.disconnect()},[t,n]),e.jsxs("div",{children:[e.jsxs("div",{ref:r,style:{maxHeight:a?"none":`${n}px`,overflow:"hidden",position:"relative"},children:[e.jsx(vt,{variant:s,children:t}),!a&&i&&e.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"2rem",background:"linear-gradient(transparent, var(--bg-card))",pointerEvents:"none"}})]}),i&&e.jsx("button",{onClick:()=>o(d=>!d),className:"text-xs cursor-pointer mt-1",style:{color:"var(--accent-blue)",background:"none",border:"none",padding:0},children:a?"Show less":"Show more"})]})}const B4=Object.freeze(Object.defineProperty({__proto__:null,CollapsibleMarkdown:Ya},Symbol.toStringTag,{value:"Module"}));function Ka({screenshots:t,onSelect:s}){return t.length===0?null:e.jsx("div",{className:"flex flex-wrap gap-2",children:t.map((n,r)=>{const a=!!s&&!!n.screenshotPath,o=n.screenshotPath?e.jsx("img",{src:at(n.screenshotPath,n.screenshotCapturedAtMs),alt:n.name,className:"h-16 w-24 rounded border border-[var(--border-default)] object-cover"}):e.jsx("div",{className:"flex h-16 w-24 items-center justify-center rounded border border-dashed border-[var(--border-default)] text-xs text-[var(--text-dim)]",children:"No shot"});return e.jsxs("div",{className:"text-center",children:[a?e.jsx("button",{type:"button",onClick:()=>s==null?void 0:s(n),"aria-label":`Preview ${n.name}`,className:"block cursor-pointer rounded transition hover:ring-2 hover:ring-[var(--accent-primary)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--accent-primary)]",children:o}):o,e.jsx("p",{className:"mt-0.5 text-xs text-[var(--text-dim)] truncate w-24",children:n.name})]},`${n.screenshotPath??"missing"}:${n.name}:${r}`)})})}const H4=Object.freeze(Object.defineProperty({__proto__:null,ScenarioThumbnailGrid:Ka},Symbol.toStringTag,{value:"Module"}));function Ic({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"11",cy:"11",r:"7"}),e.jsx("path",{d:"m20 20-3.5-3.5"})]})}function Dc({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"8",y:"2",width:"8",height:"4",rx:"1"}),e.jsx("path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"}),e.jsx("path",{d:"M9 12h6"}),e.jsx("path",{d:"M9 16h6"})]})}function Ws({size:t=20}){return e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z"})})}function Yt({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),e.jsx("path",{d:"M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"}),e.jsx("path",{d:"M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"})]})}function Ce({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}function qs({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]})}function Ze({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z"}),e.jsx("path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z"}),e.jsx("path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0"}),e.jsx("path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"})]})}function Un({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("line",{x1:"4",y1:"21",x2:"4",y2:"14"}),e.jsx("line",{x1:"4",y1:"10",x2:"4",y2:"3"}),e.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"3"}),e.jsx("line",{x1:"20",y1:"21",x2:"20",y2:"16"}),e.jsx("line",{x1:"20",y1:"12",x2:"20",y2:"3"}),e.jsx("line",{x1:"1",y1:"14",x2:"7",y2:"14"}),e.jsx("line",{x1:"9",y1:"8",x2:"15",y2:"8"}),e.jsx("line",{x1:"17",y1:"16",x2:"23",y2:"16"})]})}function Vn({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("polyline",{points:"4 17 10 11 4 5"}),e.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function Pt({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2"}),e.jsx("line",{x1:"2",y1:"10",x2:"22",y2:"10"})]})}function jt({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("line",{x1:"18",y1:"20",x2:"18",y2:"10"}),e.jsx("line",{x1:"12",y1:"20",x2:"12",y2:"4"}),e.jsx("line",{x1:"6",y1:"20",x2:"6",y2:"14"})]})}function Ie({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("line",{x1:"8",y1:"13",x2:"16",y2:"13"}),e.jsx("line",{x1:"8",y1:"17",x2:"16",y2:"17"})]})}function Gs({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),e.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})}function Dt({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"}),e.jsx("polyline",{points:"3.27 6.96 12 12.01 20.73 6.96"}),e.jsx("line",{x1:"12",y1:"22.08",x2:"12",y2:"12"})]})}function Ja({size:t=20}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M18 8a6 6 0 0 0-12 0c0 7-3 9-3 9h18s-3-2-3-9"}),e.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}const W4=Object.freeze(Object.defineProperty({__proto__:null,BellIcon:Ja,BoxIcon:Dt,CardIcon:Pt,ChartIcon:jt,CloudIcon:Ws,DatabaseIcon:Yt,DocIcon:Ie,ExploreIcon:Ic,GlobeIcon:Gs,LockIcon:Ce,MailIcon:qs,PlansIcon:Dc,RocketIcon:Ze,SetupIcon:Un,TerminalIcon:Vn},Symbol.toStringTag,{value:"Module"})),Bv=[{key:"box",label:"General"},{key:"cloud",label:"Hosting"},{key:"database",label:"Data"},{key:"lock",label:"Accounts / security"},{key:"mail",label:"Email"},{key:"card",label:"Payments"},{key:"chart",label:"Analytics"},{key:"doc",label:"Docs / legal"},{key:"globe",label:"Domain / web"},{key:"bell",label:"Notifications"},{key:"rocket",label:"Release"}],Hv={add:{title:"Add a setup topic",lead:"Have something this list doesn't cover yet? Add it and it becomes part of your setup checklist.",submit:"Add topic",submitting:"Adding…"},ask:{title:"Ask about a service or topic",lead:"Tell us what you're curious about. We'll add it to your setup list so the assistant can explain it and help you set it up.",submit:"Add & ask",submitting:"Adding…"}};function Lc({intent:t="add",onSubmit:s,onCancel:n}){const r=Hv[t],[a,o]=l.useState(""),[i,c]=l.useState(""),[d,u]=l.useState("box"),[h,p]=l.useState(!1),[m,f]=l.useState(null),b=a.trim(),g=b.length>0&&!h,v=async x=>{if(x.preventDefault(),!g){b.length===0&&f("Please enter a name.");return}p(!0),f(null);try{await s({name:b,desc:i.trim(),icon:d})}catch(y){f(y instanceof Error?y.message:"Something went wrong."),p(!1)}};return e.jsxs("div",{className:"learn-screen",children:[e.jsx("div",{className:"atf-backdrop",role:"presentation",onClick:n}),e.jsxs("div",{className:"atf-modal",role:"dialog","aria-modal":"true","aria-label":r.title,children:[e.jsx("div",{className:"atf-title",children:r.title}),e.jsx("p",{className:"atf-lead",children:r.lead}),e.jsxs("form",{onSubmit:v,children:[e.jsxs("label",{className:"atf-field",children:[e.jsx("span",{className:"atf-label",children:"Name"}),e.jsx("input",{className:"atf-input",type:"text",value:a,autoFocus:!0,placeholder:t==="ask"?"e.g. Cloudflare, a regional payment processor…":"e.g. Error monitoring, a custom step…",onChange:x=>o(x.target.value)})]}),e.jsxs("label",{className:"atf-field",children:[e.jsxs("span",{className:"atf-label",children:["What is it for? ",e.jsx("span",{className:"atf-optional",children:"(optional)"})]}),e.jsx("textarea",{className:"atf-input atf-textarea",value:i,rows:2,placeholder:"One line on what this is for.",onChange:x=>c(x.target.value)})]}),e.jsxs("label",{className:"atf-field",children:[e.jsx("span",{className:"atf-label",children:"Icon"}),e.jsx("select",{className:"atf-input",value:d,onChange:x=>u(x.target.value),children:Bv.map(x=>e.jsx("option",{value:x.key,children:x.label},x.key))})]}),m?e.jsx("div",{className:"atf-error",role:"alert",children:m}):null,e.jsxs("div",{className:"atf-actions",children:[e.jsx("button",{type:"button",className:"atf-btn atf-btn-ghost",onClick:n,disabled:h,children:"Cancel"}),e.jsx("button",{type:"submit",className:"atf-btn atf-btn-primary",disabled:!g,children:h?r.submitting:r.submit})]})]})]})]})}const q4=Object.freeze(Object.defineProperty({__proto__:null,AddTopicForm:Lc},Symbol.toStringTag,{value:"Module"}));function Fc({onAdd:t,onAsk:s}){return e.jsxs("div",{className:"setup-addrow",children:[e.jsx("div",{className:"setup-addrow-copy",children:"Don't see what you need? Add an off-list service or topic — or ask the assistant about one."}),e.jsxs("div",{className:"setup-addrow-btns",children:[e.jsx("button",{type:"button",className:"setup-addbtn",onClick:t,children:"+ Add a topic"}),e.jsx("button",{type:"button",className:"setup-addbtn setup-addbtn-ask",onClick:s,children:"Ask the AI about a service"})]})]})}const G4=Object.freeze(Object.defineProperty({__proto__:null,SetupAddTopicRow:Fc},Symbol.toStringTag,{value:"Module"}));function Wv(){const[t,s]=l.useState(null);l.useEffect(()=>{let r=!1;return(async()=>{try{const a=await fetch("/api/setup-concepts");if(!a.ok)throw new Error(`HTTP ${a.status}`);const o=await a.json();r||s(Array.isArray(o)?o:[])}catch{r||s([])}})(),()=>{r=!0}},[]);const n=l.useMemo(()=>{const r=new Map;for(const a of t??[])r.set(a.key,a);return r},[t]);return{concepts:t,byKey:r=>n.get(r)}}const qv={concepts:[],byKey:()=>{}},Yn=l.createContext(qv);function zc({children:t}){const s=Wv();return e.jsx(Yn.Provider,{value:s,children:t})}function $c(){return l.useContext(Yn)}function Bc(t){return l.useContext(Yn).byKey(t)}const U4=Object.freeze(Object.defineProperty({__proto__:null,ConceptsContext:Yn,ConceptsProvider:zc,useConcept:Bc,useConceptIndex:$c},Symbol.toStringTag,{value:"Module"}));function vn({k:t,children:s}){const n=Bc(t),[r,a]=l.useState(null),o=l.useRef(null),i=l.useRef(null),c=l.useId(),d=r!==null,u=()=>{var p;const h=(p=o.current)==null?void 0:p.getBoundingClientRect();h&&a({top:h.bottom+6,left:h.left})};return l.useEffect(()=>{if(!d)return;const h=m=>{var b,g;const f=m.target;!((b=o.current)!=null&&b.contains(f))&&!((g=i.current)!=null&&g.contains(f))&&a(null)},p=m=>{m.key==="Escape"&&a(null)};return document.addEventListener("mousedown",h),document.addEventListener("keydown",p),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",p)}},[d]),n?e.jsxs("span",{className:"concept-term-wrap",children:[e.jsx("button",{type:"button",ref:o,className:"concept-term","aria-expanded":d,"aria-controls":d?c:void 0,onClick:()=>d?a(null):u(),children:s}),d&&r?Vt.createPortal(e.jsxs("div",{ref:i,className:"concept-popover",id:c,role:"dialog",style:{top:r.top,left:r.left},children:[e.jsx("span",{className:"concept-popover-term",children:n.term}),n.category?e.jsx("span",{className:"concept-popover-cat",children:n.category}):null,e.jsx("div",{className:"concept-popover-body",children:e.jsx(vt,{variant:"compact",children:n.body})})]}),document.body):null]}):e.jsx(e.Fragment,{children:s})}const V4=Object.freeze(Object.defineProperty({__proto__:null,ConceptTerm:vn},Symbol.toStringTag,{value:"Module"}));function Hc(t){const s=t.evidence[0];return s?`found ${s.value} in ${s.source}`:t.source==="declared"?"declared by the agent":"detected in this project"}function Wc({service:t,onDismiss:s,onAddCredential:n}){var i;const r=(((i=t.envVars)==null?void 0:i.length)??0)>0,a=r&&!t.credentialPresent,o=r&&t.credentialPresent;return e.jsxs("div",{className:"detected-service",children:[e.jsx("span",{className:"ds-tag",children:t.source}),e.jsx("span",{className:"ds-name",children:t.name}),e.jsx("span",{className:"ds-why",children:Hc(t)}),o?e.jsx("span",{className:"ds-key-set","data-testid":`ds-key-set-${t.key}`,children:"Key set"}):null,a&&n?e.jsx("button",{type:"button",className:"ds-add-key",onClick:()=>n(t),"aria-label":`Add key for ${t.name}`,children:"Add key"}):null,s?e.jsx("button",{type:"button",className:"ds-dismiss",onClick:()=>s(t.key),"aria-label":`Dismiss ${t.name}`,children:"Dismiss"}):null]})}const Y4=Object.freeze(Object.defineProperty({__proto__:null,DetectedServiceRow:Wc,evidenceSummary:Hc},Symbol.toStringTag,{value:"Module"})),Gv={terminal:Vn,cloud:Ws,database:Yt,lock:Ce,mail:qs,card:Pt,chart:jt,doc:Ie,globe:Gs,box:Dt,bell:Ja,rocket:Ze};function Uv(t){return Gv[t]??Un}function Vv(t){return t==="done"?"trow done":t==="next"||t==="in-progress"?"trow next":"trow soon"}function Yv(t){return t==="done"?"set up":t==="in-progress"?"in progress":t==="next"?"next":"explore"}function sa({topics:t,detectedServices:s,onBack:n,onOpenHosting:r,onOpenTopic:a,onOpenLibraries:o,onDismissService:i,onAddCredential:c,onCreateTopic:d,onOpenConcepts:u}){const h=g=>{g.key==="hosting"?r():a==null||a(g.key)},p=new Map;for(const g of s??[]){if(g.status==="dismissed")continue;const v=p.get(g.topic)??[];v.push(g),p.set(g.topic,v)}const[m,f]=l.useState(null),b=async g=>{if(!d)return;const v=await d(g);f(null),a==null||a(v.key)};return e.jsxs("div",{className:"learn-screen",children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:n,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:n,children:"Home"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Setup"})]}),e.jsx("div",{className:"h",children:"Setup"}),e.jsx("div",{className:"hsub",children:"The things this kind of app eventually needs, explained simply. Learn about each, set it up here, and see what's already configured. No rush."}),u?e.jsxs("div",{className:"concepts-nudge",children:["New to terms like ",e.jsx(vn,{k:"hosting",children:"hosting"}),", a"," ",e.jsx(vn,{k:"domain",children:"domain"}),", or"," ",e.jsx(vn,{k:"ssl-https",children:"HTTPS"}),"? Tap any underlined word for a plain-language explainer, or"," ",e.jsx("button",{type:"button",className:"concepts-nudge-link",onClick:u,children:"browse what these words mean"}),"."]}):null,e.jsx("div",{className:"tlist",children:t===null?Array.from({length:5}).map((g,v)=>e.jsxs("div",{className:"trow soon","aria-hidden":"true",children:[e.jsx("div",{className:"tic"}),e.jsxs("div",{className:"tbody",children:[e.jsx("div",{className:"tn",children:" "}),e.jsx("div",{className:"td",children:" "})]})]},v)):t.map(g=>{const v=Uv(g.icon),x=p.get(g.key)??[];return e.jsxs("div",{className:"trow-group",children:[e.jsxs("button",{type:"button",className:Vv(g.status),onClick:()=>h(g),children:[e.jsx("div",{className:"tic",children:e.jsx(v,{size:20})}),e.jsxs("div",{className:"tbody",children:[e.jsx("div",{className:"tn",children:g.name}),e.jsx("div",{className:"td",children:g.desc})]}),e.jsx("span",{className:"tt",children:Yv(g.status)}),e.jsx("span",{className:"arrow",children:"→"})]}),x.length>0?e.jsx("div",{className:"detected-services",children:x.map(y=>e.jsx(Wc,{service:y,onDismiss:i,onAddCredential:c},y.key))}):null]},g.key)})}),o&&e.jsxs("div",{className:"setup-libraries-section",children:[e.jsx("div",{className:"seclabel",children:"Libraries"}),e.jsxs("button",{type:"button",className:"trow",onClick:o,children:[e.jsx("div",{className:"tic",children:e.jsx(Dt,{size:20})}),e.jsxs("div",{className:"tbody",children:[e.jsx("div",{className:"tn",children:"Libraries you depend on"}),e.jsx("div",{className:"td",children:"Every third-party library your app pulls in — what it is, its version, and how to update it."})]}),e.jsx("span",{className:"tt",children:"auto"}),e.jsx("span",{className:"arrow",children:"→"})]})]}),d?e.jsx(Fc,{onAdd:()=>f("add"),onAsk:()=>f("ask")}):null,m&&d?e.jsx(Lc,{intent:m,onSubmit:b,onCancel:()=>f(null)}):null]})}const K4=Object.freeze(Object.defineProperty({__proto__:null,LearnSetupScreen:sa},Symbol.toStringTag,{value:"Module"}));function Ts({command:t,writer:s}){const{copied:n,copy:r}=qn({writer:s});return e.jsxs("div",{className:"rl-cmd",children:[e.jsx("code",{className:"rl-cmd-text",children:t}),e.jsx("button",{type:"button",className:"rl-copy",onClick:()=>{r(t).catch(()=>{})},"aria-label":`Copy command: ${t}`,children:n?"Copied!":"Copy"})]})}const J4=Object.freeze(Object.defineProperty({__proto__:null,RunLocallyCommandRow:Ts},Symbol.toStringTag,{value:"Module"}));function Kv(t){return t==="dev"?"dev":t==="transitive"?"transitive":"direct"}function qc({lib:t,copyWriter:s}){return e.jsxs("div",{className:"lib-row",children:[e.jsxs("div",{className:"lib-head",children:[e.jsx("span",{className:"lib-name",children:t.name}),e.jsx("span",{className:"lib-version",children:t.version||"—"}),e.jsx("span",{className:`lib-kind ${t.kind}`,children:Kv(t.kind)}),t.outdated&&e.jsx("span",{className:"lib-outdated",title:"A newer version is available",children:"outdated"})]}),t.description?e.jsx("div",{className:"lib-desc",children:t.description}):e.jsx("div",{className:"lib-desc muted",children:"A library this project depends on. No description on file yet."}),e.jsxs("div",{className:"lib-meta",children:[t.category&&e.jsx("span",{className:"lib-tag",children:t.category}),t.license&&e.jsxs("span",{className:"lib-license",children:["License: ",t.license]}),t.homepage&&e.jsx("a",{className:"lib-docs",href:t.homepage,target:"_blank",rel:"noreferrer",children:"Docs ↗"})]}),e.jsx(Ts,{command:t.updateCommand,writer:s})]})}const X4=Object.freeze(Object.defineProperty({__proto__:null,LibraryRow:qc},Symbol.toStringTag,{value:"Module"}));function Jv(t,s){return s?`${t.name} ${t.description??""} ${t.category??""}`.toLowerCase().includes(s):!0}function Gc({group:t,query:s,forceOpen:n,copyWriter:r}){const[a,o]=l.useState(t.libraries.length<=8),i=t.libraries.filter(d=>Jv(d,s));if(s&&i.length===0)return null;const c=n||a;return e.jsxs("section",{className:"lib-group",children:[e.jsxs("button",{type:"button",className:"lib-group-head","aria-expanded":c,onClick:()=>o(d=>!d),children:[e.jsx("span",{className:"lib-group-icon",children:e.jsx(Dt,{size:18})}),e.jsx("span",{className:"lib-group-title",children:t.ecosystem}),e.jsxs("span",{className:"lib-group-count",children:[i.length," ",i.length===1?"library":"libraries"]}),e.jsx("span",{className:"lib-group-path",children:t.manifestPath}),e.jsx("span",{className:"lib-group-chevron",children:c?"▾":"▸"})]}),c&&e.jsx("div",{className:"lib-rows",children:i.map(d=>e.jsx(qc,{lib:d,copyWriter:r},d.name))})]})}const Q4=Object.freeze(Object.defineProperty({__proto__:null,LibraryGroupSection:Gc},Symbol.toStringTag,{value:"Module"}));function Uc({groups:t,onBack:s,copyWriter:n}){const[r,a]=l.useState(""),o=r.trim().toLowerCase(),i=l.useMemo(()=>(t??[]).reduce((c,d)=>c+d.libraries.length,0),[t]);return e.jsxs("div",{className:"learn-screen libraries-screen",children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:s,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:s,children:"Home"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("button",{type:"button",onClick:s,children:"Setup"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Libraries"})]}),e.jsx("div",{className:"h",children:"Libraries"}),e.jsx("div",{className:"hsub",children:"These are the third-party libraries your app uses — code other people wrote that you depend on instead of building it yourself. You didn't configure most of these; they came along with the tools you're using. This list is read straight from your project's manifests, so it's always up to date."}),t===null?e.jsx("div",{className:"lib-loading","aria-hidden":"true",children:"Reading your project's libraries…"}):t.length===0?e.jsxs("div",{className:"lib-empty",children:[e.jsx("div",{className:"lib-empty-title",children:"No libraries yet"}),e.jsx("div",{className:"lib-empty-body",children:"This project doesn't declare any third-party libraries in a manifest we recognize (package.json, Cargo.toml, requirements.txt, Podfile). When it does, they'll show up here automatically."})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"lib-searchbar",children:e.jsx("input",{type:"search",className:"lib-search",placeholder:`Search ${i} libraries…`,value:r,onChange:c=>a(c.target.value),"aria-label":"Search libraries"})}),e.jsx("div",{className:"lib-groups",children:t.map(c=>e.jsx(Gc,{group:c,query:o,forceOpen:o.length>0,copyWriter:n},c.manifestPath))})]})]})}const Z4=Object.freeze(Object.defineProperty({__proto__:null,LibrariesCatalogScreen:Uc},Symbol.toStringTag,{value:"Module"})),Xv={singular:"item",plural:"items",pluralCap:"Items",field:"name",fields:"name, description, image",fieldsTitleCase:"Name, description, and image",currentCount:0,exampleSuggestions:["Add user accounts","Track saves per item","Remember people's preferences"]},Qv={supabaseProject:"your-app",connectedOn:"today",describedOn:"today"};function Zv(t){return[{title:`A ${t.singular} table`,caption:`${t.fieldsTitleCase}, ready to edit.`,where:"database"},{title:`Saved ${t.plural} tied to each person`,caption:"Their list is remembered between visits and devices.",where:"database"},{title:`An admin screen to add & edit ${t.plural}`,caption:"A simple form, no code, changes go live instantly.",where:"/admin"},{title:`Your current ${t.plural} copied in`,caption:`The ${t.currentCount} ${t.plural} already in your app become real, editable data.`,where:"migration"}]}function ej(t){return`Store ${t.plural} (${t.fields}) and which ${t.plural} each person saved. Let me add and edit ${t.plural} from an admin screen.`}function ut(t,s,n){return e.jsx("svg",{viewBox:"0 0 24 24",width:t,height:t,fill:"none",stroke:"currentColor",strokeWidth:s,strokeLinecap:"round",strokeLinejoin:"round",children:n})}function Kt({size:t=16}){return ut(t,1.9,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 2 4 5v6c0 5 3.5 8 8 9 4.5-1 8-4 8-9V5z"}),e.jsx("path",{d:"m9 12 2 2 4-4"})]}))}function Kn({size:t=16}){return ut(t,2,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M10 13a5 5 0 0 0 7 0l3-3a5 5 0 0 0-7-7l-1.5 1.5"}),e.jsx("path",{d:"M14 11a5 5 0 0 0-7 0l-3 3a5 5 0 0 0 7 7l1.5-1.5"})]}))}function Jn({size:t=16}){return ut(t,1.8,e.jsx("path",{d:"M4 7h16M4 12h16M4 17h10"}))}function Es({size:t=16}){return ut(t,1.8,e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),e.jsx("path",{d:"M3 9h18"})]}))}function Vc({size:t=16}){return ut(t,2,e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"9"}),e.jsx("path",{d:"M12 16v-4M12 8h.01"})]}))}function Yc({size:t=16}){return ut(t,2,e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-4 4V5a2 2 0 0 1 2-2h13a2 2 0 0 1 2 2z"}))}function Kc({size:t=16}){return ut(t,2,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 2 3 7v10l9 5 9-5V7z"}),e.jsx("path",{d:"M3 7l9 5 9-5M12 12v10"})]}))}function Jc({size:t=16}){return ut(t,2,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 7v5l3 2"}),e.jsx("circle",{cx:"12",cy:"12",r:"9"})]}))}function na({size:t=13}){return ut(t,2,e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"9"}),e.jsx("path",{d:"m15 9-6 6M9 9l6 6"})]}))}function Oe({size:t=13}){return ut(t,2.5,e.jsx("path",{d:"m5 12 5 5L20 6"}))}function Xa({size:t=16}){return e.jsxs("svg",{viewBox:"0 0 24 24",width:t,height:t,fill:"none",stroke:"currentColor",strokeWidth:2,className:"rd-spin",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",strokeOpacity:".3"}),e.jsx("path",{d:"M21 12a9 9 0 0 0-9-9",strokeLinecap:"round"})]})}const e5=Object.freeze(Object.defineProperty({__proto__:null,ChatIcon:Yc,CheckGlyph:Oe,ClockIcon:Jc,CubeIcon:Kc,InfoCircleIcon:Vc,LinkIcon:Kn,ListLinesIcon:Jn,ScreenIcon:Es,ShieldCheckIcon:Kt,SpinnerIcon:Xa,XCircleIcon:na},Symbol.toStringTag,{value:"Module"})),tj="Good question. We'll explain this plainly as we go, and you can ask anything at any step. Nothing happens until you say go.",sj=[{keywords:["free","cost","pay","price"],answer:"Yes, it's genuinely free to start. Vercel's free tier comfortably covers an app like yours with no credit card. If it ever grew into heavy traffic we'd tell you long before any cost."},{keywords:["domain","url","address","name"],answer:"You can. You'll launch on a free link like your-app.vercel.app today, then connect your own address whenever you're ready. We'll walk you through it."},{keywords:["move","switch","leave","lock"],answer:"You're never locked in. Your app and its code stay yours, and you can move to another host at any time."},{keywords:["safe","secure","break","data"],answer:"It's safe. Going live doesn't change your app or your data, it just makes a copy reachable by a link. You can take it offline again anytime."}];function nj(t){const s=t.toLowerCase();for(const n of sj)if(n.keywords.some(r=>s.includes(r)))return n.answer;return tj}const rj={"clerk.freeTier":{value:"50,000 monthly active users free (Clerk bills by MAU)",verified:"2026-06",source:"https://clerk.com/pricing",staleness:"high"},"auth0.freeTier":{value:"25,000 monthly active users free, then paid from ~$35/mo",verified:"2026-06",source:"https://auth0.com/pricing",staleness:"med"},"resend.free":{value:"3,000 emails/mo and 100/day free",verified:"2026-06",source:"https://resend.com/pricing",staleness:"med"},"vercel.hobby":{value:"Hobby is free for non-commercial use; commercial needs Pro (~$20/user/mo)",verified:"2026-06",source:"https://vercel.com/pricing",staleness:"med"},"supabase.free":{value:"Free projects pause after ~1 week idle and have no automatic backups (Pro adds 7-day)",verified:"2026-06",source:"https://supabase.com/pricing",staleness:"med"},"netlify.free":{value:"New accounts use a monthly-credit model (legacy accounts: ~100GB/mo bandwidth)",verified:"2026-06",source:"https://www.netlify.com/pricing/",staleness:"med"},"cloudflarePages.free":{value:"Unlimited static bandwidth and requests on the free plan",verified:"2026-06",source:"https://pages.cloudflare.com/",staleness:"med"},"netlifyForms.free":{value:"100 submissions/mo",verified:"2026-06",source:"https://www.netlify.com/pricing/",staleness:"med"},"flyio.pricing":{value:"Pay-as-you-go; no standing always-free allowance since Oct 2024",verified:"2026-06",source:"https://fly.io/docs/about/pricing/",staleness:"low"},"stripe.usCardFee":{value:"2.9% + 30¢",verified:"2026-06",source:"https://stripe.com/pricing",staleness:"low"},"appleDeveloper.fee":{value:"$99 / year",verified:"2026-06",source:"https://developer.apple.com/support/compare-memberships/",staleness:"low"},"googlePlay.fee":{value:"$25 once",verified:"2026-06",source:"https://support.google.com/googleplay/android-developer/answer/6112435",staleness:"low"},"appStore.commission":{value:"15–30% (15% under the Small Business Program and on subscriptions after year one)",verified:"2026-06",source:"https://developer.apple.com/app-store/small-business-program/",staleness:"med"},"googlePlay.commission":{value:"15–30% (15% on the first $1M/year and on all subscriptions)",verified:"2026-06",source:"https://support.google.com/googleplay/android-developer/answer/112622",staleness:"med"},"chromeStore.fee":{value:"$5",verified:"2026-06",source:"https://developer.chrome.com/docs/webstore/register/",staleness:"low"},"playStore.closedTestGate":{value:"Personal accounts (created after 2023-11-13) need ≥12 testers opted in for 14 continuous days before production",verified:"2026-06",source:"https://support.google.com/googleplay/android-developer/answer/14151465",staleness:"med"},"appleScreenshots.iphone":{value:"6.9″ 1320×2868 (older 6.7″/6.5″ accepted as a fallback)",verified:"2026-06",source:"https://developer.apple.com/help/app-store-connect/reference/screenshot-specifications/",staleness:"med"},"appleScreenshots.ipad":{value:"13″ 2064×2752 (legacy 12.9″ 2048×2732 accepted)",verified:"2026-06",source:"https://developer.apple.com/help/app-store-connect/reference/screenshot-specifications/",staleness:"med"},"registry.twoFactor":{value:"npm enforces 2FA for publishing (required on high-impact packages); crates.io, PyPI, and RubyGems all support 2FA and increasingly require it for publishing",verified:"2026-06",source:"https://docs.npmjs.com/requiring-2fa-for-package-publishing-and-settings-modification",staleness:"med"},"registry.oidc":{value:"PyPI and npm support OIDC “trusted publishing” — CI authenticates with a short-lived identity, no long-lived token. Caveat: npm trusted publishing cannot perform a package's first publish; that initial release still needs a token",verified:"2026-06",source:"https://docs.pypi.org/trusted-publishers/",staleness:"med"},"supplyChain.signedReleases":{value:"npm publishes provenance attestations (Sigstore) for packages built in trusted CI, and PyPI attaches PEP 740 attestations on trusted-publisher uploads — both verifiable back to the source commit and workflow",verified:"2026-06",source:"https://docs.npmjs.com/generating-provenance-statements",staleness:"med"}};function re(t){return rj[t]}const aj=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function oj(t){const s=/^(\d{4})-(\d{2})$/.exec(t);if(!s)return t;const n=Number(s[2])-1;return n<0||n>11?t:`${aj[n]} ${s[1]}`}function ij(t,s){const n=/^(\d{4})-(\d{2})$/.exec(t);if(!n)return 0;const r=Number(n[1]),a=Number(n[2])-1,o=(s.getFullYear()-r)*12+(s.getMonth()-a);return o<0?0:o}const lj=12;function cj(t,s){return t.staleness==="low"?!1:ij(t.verified,s)>lj}function Rt({fact:t,asOf:s=new Date}){if(t.staleness==="low")return null;const n=cj(t,s);return e.jsxs("span",{className:"fact-fresh"+(n?" stale":""),title:`Source: ${t.source}`,children:[n?"needs re-check · ":"verified ",oj(t.verified)]})}const t5=Object.freeze(Object.defineProperty({__proto__:null,FactFreshness:Rt},Symbol.toStringTag,{value:"Module"}));function Te({size:t=15,color:s="var(--green-300)"}){return e.jsx("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",stroke:s,strokeWidth:"2.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M3 8.4l3 3 7-7.4"})})}function Xn(){return e.jsx("div",{className:"pv-logo",children:e.jsx("svg",{width:"26",height:"22",viewBox:"0 0 26 22",fill:"#0a0a0a","aria-hidden":"true",children:e.jsx("path",{d:"M13 0l13 22H0z"})})})}function Xc(){return e.jsx("div",{className:"journey",children:e.jsxs("div",{className:"jrow",children:[e.jsxs("div",{className:"jcol",children:[e.jsx("div",{className:"jtile",children:"💻"}),e.jsx("div",{className:"jlbl",children:"Your computer"}),e.jsx("div",{className:"jsub",children:"Only you can see it"})]}),e.jsxs("div",{className:"jconn",children:[e.jsx("span",{className:"jpacket"}),e.jsx("span",{children:"→"})]}),e.jsxs("div",{className:"jcol",children:[e.jsx("div",{className:"jtile lime",children:"☁️"}),e.jsx("div",{className:"jlbl",children:"Hosting"}),e.jsx("div",{className:"jsub",children:"A home on the internet"})]}),e.jsxs("div",{className:"jconn",children:[e.jsx("span",{className:"jpacket",style:{animationDelay:"1.8s"}}),e.jsx("span",{children:"→"})]}),e.jsxs("div",{className:"jcol",children:[e.jsx("div",{className:"jtile",children:"🌍"}),e.jsx("div",{className:"jlbl",children:"Anyone, anywhere"}),e.jsx("div",{className:"jsub",children:"Opens with a link"})]})]})})}function Qc(){const t=re("vercel.hobby");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"reasons",children:[e.jsxs("div",{className:"reason",children:[e.jsx(Te,{}),e.jsxs("span",{children:[e.jsx("b",{children:"Free to start."})," No credit card, no surprise bills for an app this size."]})]}),e.jsxs("div",{className:"reason",children:[e.jsx(Te,{}),e.jsxs("span",{children:[e.jsx("b",{children:"Built for how your app is made."})," It deploys the way your app already works, so it just runs."]})]}),e.jsxs("div",{className:"reason",children:[e.jsx(Te,{}),e.jsxs("span",{children:[e.jsx("b",{children:"Your own web address later."})," Launch on a free link today, add a custom domain whenever you like."]})]})]}),e.jsxs("p",{className:"reason-foot",children:["One catch worth knowing: ",t.value,". So the free link is perfect for trying it out and sharing, but once your app is charging money you'll want the paid tier.",e.jsx(Rt,{fact:t})]})]})}function Zc(){return e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"Free tier"}),e.jsx("span",{className:"chip",children:"Custom domain later"}),e.jsx("span",{className:"chip",children:"~5 min to set up"})]})}function ed(){const[t,s]=l.useState(!1);return e.jsxs("div",{children:[e.jsxs("button",{type:"button",className:"alt-toggle",onClick:()=>s(n=>!n),children:[t?"Hide other options":"Vercel not for you? See other options",e.jsx("span",{className:"chev",style:{transform:t?"rotate(180deg)":"none"},children:"⌄"})]}),t?e.jsxs("div",{className:"alts",children:[e.jsxs("div",{className:"altcard",children:[e.jsx("div",{className:"altmark",style:{background:"linear-gradient(140deg,#16a3a3,#0d6e6e)"},children:"N"}),e.jsxs("div",{className:"altbody",children:[e.jsx("div",{className:"altname",children:"Netlify"}),e.jsx("div",{className:"altdesc",children:"Also free to start and very similar to set up. A solid pick if you'd rather use it."})]}),e.jsx("button",{type:"button",className:"altpick",children:"Use this"})]}),e.jsxs("div",{className:"altcard",children:[e.jsx("div",{className:"altmark",style:{background:"linear-gradient(140deg,#f6821f,#c25e0a)"},children:"C"}),e.jsxs("div",{className:"altbody",children:[e.jsx("div",{className:"altname",children:"Cloudflare Pages"}),e.jsx("div",{className:"altdesc",children:"Best if you expect heavy worldwide traffic. A little more to learn up front."})]}),e.jsx("button",{type:"button",className:"altpick",children:"Use this"})]})]}):null]})}const dj=[{t:'What does "going live" actually do?',a:"It puts a copy of your app on the internet at a web address, so anyone you share the link with can open it. Your version on your computer keeps working exactly as before."},{t:"Can I undo it or take it offline?",a:"Anytime. You can unpublish with one click, and it goes back to running only on your computer. Nothing is permanent."},{t:"Do I need to understand servers?",a:"No. That's the whole point of letting us set it up. We handle the technical parts and explain each step in plain language as it happens."}];function td(){const[t,s]=l.useState(-1);return e.jsx("div",{className:"faq",children:dj.map((n,r)=>e.jsxs("div",{className:"faqitem",children:[e.jsxs("button",{type:"button",className:"faqq"+(t===r?" open":""),onClick:()=>s(t===r?-1:r),children:[n.t,e.jsx("span",{className:"chev",children:"⌄"})]}),t===r?e.jsx("div",{className:"faqa",children:n.a}):null]},n.t))})}function sd(){const[t,s]=l.useState(""),[n,r]=l.useState(null),a=o=>{r(nj(o)),s("")};return e.jsxs("div",{className:"ask",children:[e.jsxs("div",{className:"askrow",children:[e.jsx("input",{value:t,onChange:o=>s(o.target.value),onKeyDown:o=>{o.key==="Enter"&&t.trim()&&a(t)},placeholder:'Ask anything, e.g. "Is it really free?" or "Can I use my own domain?"'}),e.jsx("button",{type:"button",onClick:()=>t.trim()&&a(t),"aria-label":"Ask",children:"↑"})]}),e.jsx("div",{className:"asknote",children:"Ask before you commit to anything."}),n?e.jsxs("div",{className:"askans",children:[e.jsx("span",{className:"askav",children:"‹Y"}),e.jsx("div",{className:"at",children:n})]}):null]})}const s5=Object.freeze(Object.defineProperty({__proto__:null,Alts:ed,AskBox:sd,Check:Te,Chips:Zc,Faq:td,Journey:Xc,Reasons:Qc,VercelMark:Xn},Symbol.toStringTag,{value:"Module"}));function Qn({initial:t,color:s}){return e.jsx("div",{className:"altmark",style:{background:s,width:46,height:46},children:t})}function Qa({provider:t}){return e.jsxs("div",{className:"provcard"+(t.bestFit?" best":""),children:[e.jsx(Qn,{initial:t.initial,color:t.color}),e.jsxs("div",{className:"provbody",children:[e.jsxs("div",{className:"provtop",children:[e.jsx("span",{className:"provname",children:t.name}),t.bestFit?e.jsx("span",{className:"bestfit",children:"Best fit"}):null]}),e.jsx("div",{className:"provdesc",children:t.description}),e.jsx("div",{className:"reasons",children:t.reasons.map(s=>e.jsxs("div",{className:"reason",children:[e.jsx(Te,{}),e.jsxs("span",{children:[e.jsx("b",{children:s.lead})," ",s.rest]})]},s.lead))}),e.jsx("div",{className:"chips",children:t.chips.map(s=>e.jsx("span",{className:"chip",children:s},s))})]})]})}function nd({alts:t}){const[s,n]=l.useState(!1);return t.length===0?null:e.jsxs("div",{children:[e.jsxs("button",{type:"button",className:"alt-toggle",onClick:()=>n(r=>!r),children:[s?"Hide other options":"Not for you? See other options",e.jsx("span",{className:"chev",style:{transform:s?"rotate(180deg)":"none"},children:"⌄"})]}),s?e.jsx("div",{className:"alts",children:t.map(r=>e.jsxs("div",{className:"altcard",children:[e.jsx("div",{className:"altmark",style:{background:r.color},children:r.initial}),e.jsxs("div",{className:"altbody",children:[e.jsx("div",{className:"altname",children:r.name}),e.jsx("div",{className:"altdesc",children:r.description})]}),e.jsx("button",{type:"button",className:"altpick",children:"Use this"})]},r.name))}):null]})}function De({items:t}){return t.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"seclabel",style:{marginTop:34},children:"FAQ"}),e.jsx(Za,{items:t})]})}function Za({items:t}){const[s,n]=l.useState(-1);return t.length===0?null:e.jsx("div",{className:"faq",children:t.map((r,a)=>e.jsxs("div",{className:"faqitem",children:[e.jsxs("button",{type:"button",className:"faqq"+(s===a?" open":""),onClick:()=>n(s===a?-1:a),children:[r.q,e.jsx("span",{className:"chev",children:"⌄"})]}),s===a?e.jsx("div",{className:"faqa",children:r.a}):null]},r.q))})}const n5=Object.freeze(Object.defineProperty({__proto__:null,Alternatives:nd,FaqSection:De,ProviderCard:Qa,ProviderMark:Qn,TopicFaq:Za},Symbol.toStringTag,{value:"Module"})),uj={"real-data":[{id:"wire-real-database",label:"Wire up a real database",body:"Help me move off seed/mock data onto a real persistence layer. Read `.codeyam/stack.json` and the current data shapes, recommend a database that fits this stack (and my hosting), then scaffold the connection, the schema/migrations matching my existing data shapes, and the data-access layer. Offer to migrate the current seeded data over so nothing is lost."}],accounts:[{id:"add-auth",label:"Add authentication",body:"Help me add real sign-in. Recommend an auth approach for this stack (hosted provider vs. self-rolled), wire the sign-up/sign-in/sign-out flow, protect the routes that need a session, and expose the current user to the app. Tell me which provider/console steps I must do myself."}],emails:[{id:"setup-transactional-email",label:"Set up transactional email",body:"Help me send real transactional email (verification, password reset, receipts). Pick a provider that fits the stack, wire the send API with the key in env/secrets (never hard-coded), template the messages, and give me a way to fire a test send. Note the DNS/domain-verification steps I'll complete with my provider."}],payments:[{id:"integrate-payments",label:"Integrate payments",body:"Help me accept payments. Wire the checkout flow for a provider that fits the stack (Stripe is the usual default), handle the webhook that confirms payment server-side, and gate the paid outcome on it. Keep keys in secrets and use test mode first; I'll connect my real account."}],"analytics-monitoring":[{id:"add-analytics-monitoring",label:"Add analytics & monitoring",body:"Help me add product analytics and uptime/error monitoring. Install and initialize tools that fit the stack, instrument a few key events and the error boundary, and confirm data is flowing. Keep any keys in env/secrets and respect the privacy choices the app already makes."}],legal:[{id:"draft-legal-pages",label:"Draft privacy & terms pages",body:"Draft a privacy policy and terms of service grounded in what the app actually does — scan the code for what data is collected and which third parties (analytics, payments, email) receive it. Render them as real pages/routes in the app and link them from the footer."}],"data-safety":[{id:"complete-data-safety",label:"Complete the data-safety review",body:"Inventory what data this app and its dependencies collect, store, and transmit, and to whom. Produce an honest data-safety summary I can use for a disclosure form or privacy page, and flag anything collected that the app doesn't actually need."}],publish:[{id:"publish-static-site",label:"Deploy the static site",body:"Help me publish this static build. Confirm the production build command and output directory, pick a static host that fits, wire the deploy (config file or CLI), and do a first deploy so I get a live URL. Note any account/DNS steps I complete in the host's dashboard."}],"custom-domain":[{id:"setup-custom-domain",label:"Set up a custom domain",body:"Help me put the app on a custom domain. Tell me exactly which DNS records to add for my host (A/AAAA/CNAME), update any in-app config that hard-codes the URL, and make sure HTTPS/cert provisioning is handled. I'll add the records at my registrar; give me the precise values."}],forms:[{id:"wire-form-handling",label:"Wire up form handling",body:"Help me make the site's forms actually submit. Pick an approach that fits a static/SSR site (a forms service or a serverless endpoint), wire the submission, add validation and a success/error state, and add basic spam protection. Confirm a test submission arrives where I expect."}],"analytics-seo":[{id:"improve-seo-analytics",label:"Improve SEO & analytics",body:"Help me improve SEO and add analytics. Audit and fix per-page titles, meta descriptions, Open Graph tags, a sitemap and robots.txt, then wire a privacy-respecting analytics tool. Show me before/after on the key pages."}],"staging-preview":[{id:"setup-preview-deploys",label:"Set up preview deploys",body:"Help me get a prod-like preview URL for changes before they hit prod. Wire per-branch / per-PR preview deploys on my host (or a shared staging environment if previews aren't available), and make sure previews use safe, non-prod data and secrets. Tell me the host dashboard step I do myself."}]},hj={"deploy-target":[{id:"setup-deploy-target",label:"Set up a deploy target",body:"Help me deploy this service. Read stack.json, recommend a target that fits (container host, PaaS, serverless), write the deploy config (Dockerfile/Procfile/platform file), wire required env/secrets, and do a first deploy that passes a health check. Note which dashboard/billing steps I do myself."}],"database-backups":[{id:"configure-db-backups",label:"Configure database backups",body:"Help me make the database recoverable. Set up automated backups (provider-managed if available, else a scheduled dump), define a retention window, and — critically — give me a documented, tested RESTORE procedure. A backup nobody has restored isn't a backup; walk me through one restore."}],secrets:[{id:"setup-secrets",label:"Set up secrets management",body:"Audit the repo for hard-coded secrets and any committed to git history, move them to a proper secrets mechanism for this stack/host, wire the app to read them from the environment, and add a committed `.env.example` documenting the required keys without their values."}],"api-auth":[{id:"add-api-auth",label:"Add API authentication",body:"Help me secure the API. Pick an auth scheme that fits (API keys, JWT, OAuth/session), add the middleware that enforces it, protect the routes that need it while leaving public ones open, and return correct 401/403 responses. Add a quick way for me to test an authed request."}],"cors-origins":[{id:"configure-cors",label:"Configure CORS",body:"Help me set CORS correctly. Identify which front-end origins must call this API, configure an allow-list (not a blanket wildcard when credentials are involved), set the allowed methods/headers, and verify a preflight request succeeds from an allowed origin and is rejected from an unlisted one."}],"background-jobs":[{id:"add-background-jobs",label:"Add background jobs",body:"Help me move slow or scheduled work off the request path. Pick a queue/worker approach that fits the stack, wire a worker process, move one real slow operation into a job as the worked example, and add retry and failure handling."}],"logging-monitoring":[{id:"setup-logging-monitoring",label:"Set up logging & monitoring",body:"Help me make this service observable. Add structured logging with request ids, wire error tracking and an uptime/health check, and set up at least one alert for the failure I'd most want to know about. Keep any keys in secrets."}],"api-docs":[{id:"generate-api-docs",label:"Generate API reference docs",body:"Help me produce API reference docs. Read stack.json to tell which shape this is: for a running HTTP service, generate/curate an OpenAPI (Swagger) spec from the routes and serve a docs UI; for a published library, generate reference docs from the public API and doc comments. Wire it so the docs regenerate as the API changes."}],"staging-environment":[{id:"standup-staging",label:"Stand up a staging environment",body:"Help me create a prod-like staging environment with its own data and secrets, a way to rehearse migrations before prod, and a clear promote-to-prod path. Wire the config so deploys can target staging first."}]},pj={"redirects-404":[{id:"configure-redirects-404",label:"Configure redirects & a 404 page",body:"Help me handle redirects and not-found. Add the redirect rules in the form my host expects (e.g. `_redirects`, `netlify.toml`, `vercel.json`, or framework config — read stack.json/host), migrate any old paths I tell you about, and add a real styled 404 page wired to the site's layout."}],"performance-images":[{id:"optimize-images",label:"Optimize images & performance",body:"Audit the site's images and obvious performance wins: convert/serve modern formats, add width/height and lazy-loading, generate responsive sizes where the framework supports it, and flag oversized assets. Make the changes and tell me the rough before/after weight."}],"comments-search":[{id:"add-comments-search",label:"Add comments or search",body:"Help me add a comments widget and/or client-side search to the static site. Pick an approach that needs no backend (a hosted comments service; a prebuilt search index), wire it into the relevant pages/layout, and confirm it renders and works in the preview."}],"deploy-previews":[{id:"setup-deploy-previews",label:"Set up deploy previews",body:"Help me get a preview URL for every branch/PR of this static site. Wire the host's deploy-preview feature (or equivalent config), confirm the build runs for previews, and make sure preview builds don't leak production-only config."}]},mj={"publish-registry":[{id:"prepare-registry-publish",label:"Prepare a registry publish",body:"Help me publish to the right registry for this stack (npm, crates.io, PyPI, …). Verify the package metadata (name, version, license, description, entry points), make sure only the intended files ship (ignore/include lists), do a dry-run pack and show me what's in it, and outline the auth/token step I do myself before the real publish."}],"versioning-changelog":[{id:"setup-versioning-changelog",label:"Set up versioning & changelog",body:"Help me adopt a clear versioning + changelog workflow. Establish semver for this project, set up a changelog (Keep a Changelog or a conventional-commits generator), and give me a single command to cut a release that bumps the version, updates the changelog, and tags."}],"install-docs":[{id:"write-install-docs",label:"Write install docs",body:"Write clear install/quick-start docs for this tool: the one-line install per supported method (the registry, a binary download, from source), a copy-pasteable first-run example, and the prerequisites. Put it in the README (and docs site if there is one) and verify the commands actually work as written."}],"release-builds":[{id:"setup-release-builds",label:"Set up cross-platform builds",body:"Help me produce release binaries. Set up the build matrix for the targets I care about (OS/arch), wire it into CI so a tag produces attached artifacts, and add checksums. Tell me about any signing/notarization steps (esp. macOS/Windows) I must do with my own credentials."}],"shell-completions":[{id:"generate-completions",label:"Generate shell completions",body:"Help me ship shell completions. Generate completion scripts for bash, zsh, and fish from the CLI's argument definitions (most arg frameworks can emit these), wire a command or build step that regenerates them, and document where users install each."}],"cli-ux":[{id:"polish-cli-ux",label:"Polish the CLI UX",body:"Audit the command-line UX and improve it: consistent and helpful `--help` output, clear actionable error messages with non-zero exit codes, `--version`, sensible defaults, and respect for NO_COLOR / piped output. Make the changes and show me a few before/after invocations."}],"supply-chain":[{id:"harden-supply-chain",label:"Harden the supply chain",body:"Help me harden the release supply chain: pin and audit dependencies, add a lockfile-checked CI step, generate an SBOM, and set up artifact signing/provenance for releases. Walk me through any key-management step that has to be mine."}],"pre-release-channel":[{id:"setup-prerelease-channel",label:"Set up a pre-release channel",body:"Help me offer a pre-release (next/beta) channel testers can opt into WITHOUT moving the stable `latest`. Set up the pre-release version scheme and the publish flag/tag for it on this registry, and document the one command to cut a pre-release and how users install it."}]},fj={"readme-license":[{id:"write-readme-license",label:"Write the README & pick a license",body:"Help me give this package a strong README and a license. Write a README with a one-line description, install, a minimal usage example, and a features/API summary drawn from the actual public API. Recommend a license that fits my intent (permissive vs. copyleft), add the LICENSE file, and set the license field in the package manifest."}],"changelog-ci":[{id:"setup-changelog-ci",label:"Set up changelog & release CI",body:"Help me automate releases. Add a changelog workflow and a CI pipeline that, on a version tag, runs tests, builds, and publishes to the registry. Keep the publish token in CI secrets and show me the one action I take to trigger a release."}],"semver-policy":[{id:"document-semver-policy",label:"Document a versioning policy",body:"Help me define and document a semver policy: what counts as a breaking change for THIS package's public API, the deprecation path before removals, and the support window. Write it into the docs and, if feasible, add a public-API surface check that flags an accidental breaking change in review."}],examples:[{id:"add-examples-doctests",label:"Add runnable examples & doctests",body:"Help me add examples that can't rot. Write runnable examples for the main entry points, turn the key README snippets into doctests/tested examples where the language supports it, and wire them into CI so a broken example fails the build."}],"pre-release-versions":[{id:"setup-prerelease-versions",label:"Set up pre-release versions",body:"Help me publish pre-release versions (alpha/beta/rc) that early adopters opt into WITHOUT moving the stable `latest`. Set up the pre-release version scheme and the registry tag/flag for it, and document the cut command and how users install a pre-release."}]},gj={"dev-accounts":[],"store-assets":[{id:"generate-mobile-store-assets",label:"Generate store screenshots & icon",body:"Help me produce the App Store / Play Store assets: the app icon at the required sizes, device-frame screenshots for each required display size, and the feature graphic. Use the app's existing icon/branding as the source and generate or resize to the EXACT per-store dimensions; flag any size I'll need to capture from a running device."}],"store-listing":[{id:"draft-mobile-listing",label:"Draft the store listing copy",body:"Draft the store listing from what the app actually does: title, subtitle, the short and full descriptions, keywords, and the what's-new text. Keep within each store's character limits and avoid the copy patterns (keyword stuffing, competitor names) that draw rejections."}],"testing-distribution":[{id:"prep-testflight",label:"Prep a TestFlight upload",body:"Help me get a build to TestFlight. Before any iOS build, run the MOBILE_SETUP.md iOS pre-flight checks (a missing platform SDK surfaces in seconds via `xcrun simctl list devices available`; surface the 8–12 GB / 10–30 min `xcodebuild -downloadPlatform iOS` cost to me BEFORE kicking it off). Then produce the archive, confirm the bundle id / signing, and walk me through the App Store Connect upload and adding internal testers."},{id:"prep-play-internal",label:"Set up Play internal testing",body:"Help me ship an internal-testing track on Google Play. Produce a signed AAB, confirm the applicationId and version code are bumped, and prepare the internal-testing release notes and the tester list. I'll create the track in the Play Console myself; prep the artifact and metadata."},{id:"prep-store-review",label:"Get ready for store review",body:"Run a pre-review checklist across both stores: privacy/data-safety answers match the code, required usage-description strings are present (iOS Info.plist), no debug/placeholder content ships, deep links and permissions actually work, and the listing matches the build. Give me a pass/fail list so I submit only when it's clean."}],"push-notifications":[{id:"wire-push",label:"Wire up push notifications",body:"Help me add push notifications end to end for this stack: register for the OS push token, wire the credentials (APNs key for iOS, FCM for Android), add the client-side receive/handle code, and give me a way to send a test notification. Note which credential steps I must do in the Apple/Firebase consoles myself."}],"crash-reporting":[{id:"add-crash-reporting",label:"Add a crash reporter",body:"Help me add crash and error reporting (e.g. Sentry/Crashlytics — pick what fits the stack). Install and initialize the SDK, wire source-map / dSYM upload so stack traces symbolicate, and trigger a test crash to confirm it lands in the dashboard."}],"in-app-purchases":[{id:"scaffold-iap",label:"Scaffold in-app purchases",body:"Help me scaffold in-app purchases/subscriptions for this stack: add the purchasing library, define the product ids, wire the buy + restore + receipt-validation flow, and gate the paid feature behind entitlement. I'll create the products in App Store Connect / Play Console myself; build the client and server-side pieces."}],"app-privacy":[{id:"fill-privacy-form",label:"Fill out the data-safety form",body:"Help me answer Apple's App Privacy and Google's Data Safety questionnaires accurately. Scan the code and dependencies (SDKs frequently collect data you didn't write code for) to determine what data is actually collected, why, and whether it's linked to identity or used for tracking, then give me the exact answers to enter."}],"app-review":[{id:"pre-review-checklist",label:"Run a pre-review checklist",body:"Audit the app against the guideline issues that most often cause rejection: a working demo account if login is required, no broken links, permission prompts with clear purpose strings, no private APIs, and a complete privacy answer set. Give me a checklist with what's done and what still needs fixing."}]},bj={"share-testing":[{id:"zip-load-unpacked",label:"Zip a load-unpacked build",body:'Help me hand a tester an unpacked build they can side-load. Produce the production build, confirm `manifest.json` sits at the ROOT of the zipped output (not nested under a build folder — that is the #1 load-unpacked mistake), zip the build directory, and write a two-line tester instruction: open chrome://extensions, enable Developer mode, click "Load unpacked" (or drag the zip). Call out that this build does NOT auto-update — testers re-load a new zip each time.'},{id:"unlisted-listing",label:"Set up an unlisted listing",body:"Help me prepare an unlisted (private-link) Chrome Web Store upload. Assemble everything that can be readied before the manual upload: the packaged zip, a version bump in `manifest.json`, the icon set and screenshots the listing requires, and a short description. Explain the one-time paid developer-account requirement and that an unlisted item STILL goes through Google's review — unlisted only hides it from search, it is not an instant private channel. I'll do the actual upload and account steps myself; prep the rest."},{id:"self-host-crx",label:"Self-host a .crx + update_url",body:"Help me self-host a packed `.crx` with auto-updates. Pack the `.crx`, generate the `update.xml` update manifest, and wire `update_url` into `manifest.json` pointing at where I'll host it. Be explicit that this path is really for MANAGED / enterprise force-install (via policy): Chrome blocks off-store `.crx` installs for ordinary user profiles, so this is not a substitute for the Web Store for normal users."}],"store-accounts":[],"store-assets":[{id:"generate-store-assets",label:"Prepare the store assets",body:"Help me assemble the Chrome Web Store listing assets: the 128px store icon, the screenshots (1280×800 or 640×400), and any promo tiles. Use the extension's existing icons/branding as the source, generate or resize what's missing to the exact required dimensions, and draft the short + detailed listing descriptions from what the extension actually does."}],"permissions-justification":[{id:"draft-permission-justifications",label:"Draft permission justifications",body:'Read the `permissions` and `host_permissions` in `manifest.json`, then for EACH one draft the single-sentence justification the Web Store review requires ("why does this extension need it"). Flag any permission you can\'t tie to actual code — an unused permission is a common rejection reason, so propose removing it.'}],"oauth-verification":[{id:"prep-oauth-consent",label:"Prep the OAuth consent materials",body:"Help me get ready for Google's OAuth verification. Inventory the OAuth scopes the extension requests, separate sensitive/restricted scopes from basic ones, and draft the scope-justification text and the data-usage explanation the consent-screen review asks for. I'll submit in the Cloud console myself; prepare everything that goes into it."}],"privacy-policy":[{id:"draft-privacy-policy",label:"Draft a privacy policy",body:'Draft a privacy policy for this extension grounded in what it ACTUALLY does: scan the code for what data it reads, stores, or transmits and to where. Write a policy that honestly reflects that (including "collects nothing" if true), and save it somewhere I can host and link from the store listing.'}],"single-purpose-listing":[{id:"write-single-purpose",label:"Write the single-purpose description",body:"The Web Store requires a clear single purpose. From the code and manifest, articulate the extension's one narrow purpose in a sentence, then write a listing description that stays consistent with it. Flag any feature that reads as scope-creep beyond that single purpose (a common rejection reason) so I can decide whether to cut or re-frame it."}],"manifest-versioning":[{id:"bump-and-version",label:"Bump the version & set a scheme",body:"Help me manage the extension version. Bump the `version` in `manifest.json` correctly (4-part dot-separated, monotonically increasing — the store rejects a re-used or lower version), and if I don't have one, propose a simple versioning convention and a one-command way to bump it for each submission."}],"submit-review":[{id:"pre-submission-audit",label:"Run a pre-submission audit",body:`Before I submit, audit the package against the common rejection causes: manifest at the zip root, version bumped, every permission justified and used, a reachable privacy policy, listing assets at the right dimensions, and the single-purpose description consistent. Give me a checked/failed list so I only hit "Submit" when it's clean.`}]},xj={hosting:[{id:"deploy-and-go-live",label:"Deploy & go live",body:"Help me deploy this app and get a live URL. Read stack.json to find the build command and output, recommend a host that fits the stack, wire the deploy config (and any required env/secrets), and do a first deploy. Confirm the deployed URL actually serves the app, and tell me which account/billing steps I complete in the host's dashboard."}]},yj={"run-locally":[{id:"get-it-running",label:"Get it running on my machine",body:"Help me run this app on my own machine, outside the Live Preview. Read `.codeyam/stack.json` to learn the stack, confirm or install the prerequisites it needs, run the install step and then the project's configured run/build command, and fix any errors that come up so it actually starts. If it serves on a port, tell me the URL to open. If this project is a browser extension, build it and walk me through loading it unpacked (open chrome://extensions, enable Developer mode, and Load unpacked on the built output directory)."}]},vj={...uj,...hj,...pj,...mj,...fj,...gj,...bj,...xj,...yj};function rd(t){return vj[t]??[]}function jj({topicName:t,goal:s}){const n=[];return n.push("You are helping inside the user's actual codeyam project — this is real work in a real repository, not a hypothetical."),n.push("Before doing anything, read `.codeyam/stack.json` and the relevant source and config files so your help fits this project's stack. Prefer concrete edits and commands over generic advice."),n.push(""),n.push(`You're helping with **${t}** — specifically: **${s.label}**.`),n.push(""),n.push(s.body),n.push(""),n.push("Walk me through it and make the changes you safely can in my project, asking before anything destructive."),n.join(`
2
+ `)}function Ot({assistKey:t,topicName:s,goalId:n,buttonLabel:r}){const a=rd(t).find(c=>c.id===n),[o,i]=l.useState(!1);return a?e.jsxs("div",{className:"setup-goal-assist mt-4",children:[e.jsx("button",{type:"button",className:"w-full rounded-lg bg-[var(--blue-300)] px-4 py-2.5 text-sm font-semibold text-[var(--text-on-accent)] transition-opacity hover:opacity-90","aria-pressed":o,onClick:()=>i(c=>!c),children:r}),o&&e.jsx("div",{className:"mt-3 rounded-md border border-[var(--border-subtle)] bg-[var(--bg-deep)]",children:e.jsx(Bs,{chatName:`setup-${t}-${a.id}`,prompt:jj({topicName:s,goal:a}),height:360,onClose:()=>i(!1)})})]}):null}const r5=Object.freeze(Object.defineProperty({__proto__:null,SetupGoalAssist:Ot},Symbol.toStringTag,{value:"Module"}));function de({assistKey:t,topicName:s}){const n=rd(t);return n.length===0?null:e.jsx(e.Fragment,{children:n.map(r=>e.jsx(Ot,{assistKey:t,topicName:s,goalId:r.id,buttonLabel:`Ask AI to help: ${r.label}`},r.id))})}const a5=Object.freeze(Object.defineProperty({__proto__:null,SetupGoalAssistList:de},Symbol.toStringTag,{value:"Module"})),wj=1800;function ad({entity:t,onConnect:s}){const[n,r]=l.useState(!1),a=()=>{n||(r(!0),window.setTimeout(s,wj))};return e.jsxs("div",{className:"rd-content",children:[e.jsxs("div",{className:"rd-shead",children:[e.jsx("div",{className:"rd-badge",children:e.jsx(Yt,{size:25})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"rd-title",children:["Use real data ",e.jsx("span",{className:"rd-pill",children:"Not set up"})]}),e.jsxs("div",{className:"rd-via",children:["powered by ",e.jsx("b",{children:"Supabase"})]}),e.jsxs("p",{className:"rd-lead",children:["Right now your ",t.plural," live inside the code, and anything people save resets when they leave. To remember things for good, your app needs a database. CodeYam uses Supabase."]})]})]}),e.jsxs("div",{className:"rd-explain",children:[e.jsxs("div",{className:"rd-eh",children:[e.jsx("span",{className:"rd-q",children:"?"}),"New to Supabase? Here's the short version"]}),e.jsxs("div",{className:"rd-lede",children:[e.jsx("b",{children:"Supabase is your app's memory."})," It's a database — a secure, organised place your app stores everything it needs to remember: your"," ",t.plural,", who saved what, people's profiles. Think of a smart filing cabinet your app can read from and write to in an instant."]}),e.jsxs("div",{className:"rd-erows",children:[e.jsxs("div",{className:"rd-erow",children:[e.jsx("div",{className:"rd-en",children:e.jsx(Yt,{size:16})}),e.jsxs("div",{className:"rd-et",children:[e.jsx("b",{children:"It remembers everything"}),e.jsxs("span",{children:["Your ",t.plural,", saved lists, and profiles are kept safe"," ",e.jsx("em",{children:"even after everyone closes the app"}),", instead of resetting."]})]})]}),e.jsxs("div",{className:"rd-erow",children:[e.jsx("div",{className:"rd-en",children:e.jsx(Ce,{size:16})}),e.jsxs("div",{className:"rd-et",children:[e.jsx("b",{children:"It keeps data private"}),e.jsxs("span",{children:["Built-in rules decide who can see what, so"," ",e.jsx("em",{children:"one person can't read another's"})," saved ",t.plural," or details."]})]})]}),e.jsxs("div",{className:"rd-erow",children:[e.jsx("div",{className:"rd-en",children:e.jsx(Es,{size:16})}),e.jsxs("div",{className:"rd-et",children:[e.jsx("b",{children:"It's yours to edit"}),e.jsxs("span",{children:["Change a ",t.singular," in a simple screen and it updates"," ",e.jsx("em",{children:"everywhere, instantly"}),", with no developer involved."]})]})]})]}),e.jsxs("div",{className:"rd-why",children:[e.jsxs("div",{className:"rd-wh",children:[e.jsx(Kt,{size:15}),"Why CodeYam picks Supabase for you"]}),[{lead:"Free to start, no card needed.",rest:"A generous free tier covers a new app comfortably. You only pay if it grows popular, and you'll see it coming."},{lead:"Built on standard Postgres.",rest:"Your core data lives in a standard Postgres database, so it's portable and easy to export — moving it elsewhere is straightforward. (Auth, file storage, and row-level security are Supabase-specific.)"},{lead:"Little for you to manage.",rest:`No servers to run or patch, and paid tiers keep automatic daily backups. One caveat on the free tier: ${re("supabase.free").value} — so keep your own export and plan to upgrade before launch.`}].map(o=>e.jsxs("div",{className:"rd-whyrow",children:[e.jsx("span",{className:"rd-wc",children:e.jsx(Oe,{size:11})}),e.jsxs("p",{children:[e.jsx("b",{children:o.lead})," ",o.rest]})]},o.lead))]})]}),e.jsxs("div",{className:"rd-connect",children:[e.jsx("div",{className:"rd-ct",children:"Connect or create your Supabase project"}),e.jsx("div",{className:"rd-cd",children:"A new window opens on Supabase. If you already have an account, sign in. If not, you'll make one — it's free and takes a few minutes. CodeYam links to it and holds the keys, so you never touch a server."}),e.jsx("button",{type:"button",className:"rd-cbtn",onClick:a,disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(Xa,{size:16}),"Opening Supabase…"]}):e.jsxs(e.Fragment,{children:[e.jsx(Kn,{size:16}),"Connect Supabase"]})}),e.jsxs("div",{className:"rd-reassure",children:[e.jsxs("span",{children:[e.jsx(Oe,{size:13}),"Free to start, no card needed"]}),e.jsxs("span",{children:[e.jsx(Oe,{size:13}),"Takes about 3 minutes"]}),e.jsxs("span",{children:[e.jsx(Oe,{size:13}),"Disconnect any time"]})]})]}),e.jsx("div",{className:"rd-uplabel",children:"Then, once you're connected"}),e.jsxs("div",{className:"rd-locked",children:[e.jsxs("div",{className:"rd-lrow",children:[e.jsx("div",{className:"rd-ln",children:e.jsx(Jn,{size:15})}),e.jsxs("div",{className:"rd-lt",children:[e.jsx("b",{children:"Tell us what to remember"}),e.jsxs("span",{children:['A sentence in plain language, like "store ',t.plural,' and which ones each person saved."']})]}),e.jsx("span",{className:"rd-lk",children:e.jsx(Ce,{size:15})})]}),e.jsxs("div",{className:"rd-lrow",children:[e.jsx("div",{className:"rd-ln",children:e.jsx(Es,{size:15})}),e.jsxs("div",{className:"rd-lt",children:[e.jsx("b",{children:"CodeYam builds your data & admin screen"}),e.jsxs("span",{children:["A ",t.singular," table, saved lists, and a simple screen to add or edit ",t.plural," — each a plan you preview before it ships."]})]}),e.jsx("span",{className:"rd-lk",children:e.jsx(Ce,{size:15})})]})]}),e.jsx("div",{className:"rd-uplabel",children:"Common questions"}),e.jsx(Za,{items:[{q:"What happens to my data if I stop paying or leave?",a:`Your data is in standard Postgres, so you can export it at any time and take it with you. On Supabase's free tier, ${re("supabase.free").value}, so keep your own export and don't rely on it for anything you can't lose. Paid tiers add automatic daily backups, and because the core is Postgres, moving to another host later is straightforward.`},{q:"Is my data really safe on the free tier?",a:"It's secure, but the free tier is meant for building and trying things, not for production data you can't afford to lose. Free projects pause when idle and have no automatic backups, so upgrade to a paid tier (or keep regular exports) before real people depend on it."}]}),e.jsx(de,{assistKey:"real-data",topicName:"Use real data"})]})}const o5=Object.freeze(Object.defineProperty({__proto__:null,RealDataNotConnected:ad},Symbol.toStringTag,{value:"Module"}));function Ss({tone:t,icon:s,title:n,subtitle:r,children:a}){return e.jsxs("div",{className:`rd-zone rd-z-${t}`,children:[e.jsxs("div",{className:"rd-zhd",children:[e.jsx("div",{className:"rd-zn",children:s}),e.jsxs("div",{className:"rd-ztext",children:[e.jsx("div",{className:"rd-zt",children:n}),e.jsx("div",{className:"rd-zs",children:r})]})]}),a]})}const i5=Object.freeze(Object.defineProperty({__proto__:null,RealDataZone:Ss},Symbol.toStringTag,{value:"Module"}));function od({entity:t,connection:s,onPlan:n}){const[r,a]=l.useState(new Set),[o,i]=l.useState(!1),c=Zv(t),d=ej(t),u=p=>{a(m=>{const f=new Set(m);return f.has(p)?f.delete(p):f.add(p),f})},h=()=>{o||(i(!0),n==null||n())};return e.jsxs("div",{className:"rd-content",children:[e.jsxs("div",{className:"rd-shead",children:[e.jsx("div",{className:"rd-badge",children:e.jsx(Yt,{size:25})}),e.jsxs("div",{children:[e.jsx("h1",{className:"rd-title",children:"Use real data"}),e.jsxs("div",{className:"rd-via",children:["powered by ",e.jsx("b",{children:"Supabase"})," · a secure database used by modern apps"]}),e.jsxs("p",{className:"rd-lead",children:["Move your ",t.plural," out of the code and into a database, so you (or a teammate) can add and edit them without a developer, and so each person's saved list is remembered for good."]})]})]}),e.jsxs(Ss,{tone:"learn",icon:e.jsx(Vc,{size:16}),title:"Understand it first",subtitle:"No jargon — here's what a database actually does for you.",children:[e.jsxs("p",{children:["A database is just a ",e.jsx("b",{children:"labelled place your app remembers things"})," — like a spreadsheet it can read and write instantly. Today your"," ",t.plural," are typed into the code, so changing one means changing the app."]}),e.jsxs("p",{children:["Move them into a database and a ",t.singular," becomes"," ",e.jsx("b",{children:"data you can edit"})," from a simple screen. Update a ",t.field," ","once and it changes everywhere, instantly."]}),e.jsxs("div",{className:"rd-ba",children:[e.jsxs("div",{className:"rd-bx2 rd-now",children:[e.jsx("div",{className:"rd-batag",children:"Now · in the code"}),e.jsxs("div",{className:"rd-baln",children:[e.jsx(na,{size:13}),"A developer edits ",t.plural]}),e.jsxs("div",{className:"rd-baln",children:[e.jsx(na,{size:13}),"Saves reset on refresh"]})]}),e.jsx("div",{className:"rd-arrowmid",children:"→"}),e.jsxs("div",{className:"rd-bx2 rd-next",children:[e.jsx("div",{className:"rd-batag",children:"After · in a database"}),e.jsxs("div",{className:"rd-baln",children:[e.jsx(Oe,{size:13}),"You edit ",t.plural," yourself"]}),e.jsxs("div",{className:"rd-baln",children:[e.jsx(Oe,{size:13}),"Saves last forever"]})]})]})]}),e.jsxs(Ss,{tone:"tell",icon:e.jsx(Yc,{size:16}),title:"Tell CodeYam what to remember",subtitle:"Describe it in plain words. This is the instruction it follows.",children:[e.jsxs("div",{className:"rd-field",children:[e.jsx("span",{className:"rd-edit",children:"Edit"}),d]}),e.jsx("div",{className:"rd-examples",children:t.exampleSuggestions.map((p,m)=>e.jsxs("button",{type:"button",className:"rd-ex"+(r.has(m)?" added":""),onClick:()=>u(m),children:[e.jsx("span",{className:"rd-plus",children:r.has(m)?"✓":"+"}),p]},p))})]}),e.jsx(Ss,{tone:"build",icon:e.jsx(Kc,{size:16}),title:"What CodeYam will build",subtitle:`${c.length} changes, each previewable before it ships.`,children:e.jsx("div",{className:"rd-builds",children:c.map(p=>e.jsxs("div",{className:"rd-bitem",children:[e.jsx("div",{className:"rd-bx",children:e.jsx(Oe,{size:13})}),e.jsxs("div",{className:"rd-bmain",children:[e.jsx("b",{children:p.title}),e.jsx("span",{children:p.caption})]}),e.jsx("span",{className:"rd-where",children:p.where})]},p.title))})}),e.jsx(Ss,{tone:"track",icon:e.jsx(Jc,{size:16}),title:"Track what's done",subtitle:"So you always know where you left off, even weeks later.",children:e.jsxs("div",{className:"rd-tl",children:[e.jsxs("div",{className:"rd-te",children:[e.jsxs("div",{className:"rd-tdot",children:[e.jsx("div",{className:"rd-nd done",children:e.jsx(Oe,{size:12})}),e.jsx("div",{className:"rd-tline"})]}),e.jsxs("div",{className:"rd-tc",children:[e.jsxs("div",{className:"rd-tt",children:["Connected a Supabase project"," ",e.jsx("span",{className:"rd-when",children:s.connectedOn})]}),e.jsxs("div",{className:"rd-td",children:['Project "',s.supabaseProject,`" linked. CodeYam holds the keys — you don't manage servers.`]})]})]}),e.jsxs("div",{className:"rd-te",children:[e.jsxs("div",{className:"rd-tdot",children:[e.jsx("div",{className:"rd-nd done",children:e.jsx(Oe,{size:12})}),e.jsx("div",{className:"rd-tline"})]}),e.jsxs("div",{className:"rd-tc",children:[e.jsxs("div",{className:"rd-tt",children:["Described what to store"," ",e.jsx("span",{className:"rd-when",children:s.describedOn})]}),e.jsxs("div",{className:"rd-td",children:[t.pluralCap," and per-person saved lists. You can refine this above anytime."]})]})]}),e.jsxs("div",{className:"rd-te is-todo",children:[e.jsx("div",{className:"rd-tdot",children:e.jsx("div",{className:"rd-nd now",children:"3"})}),e.jsxs("div",{className:"rd-tc",children:[e.jsxs("div",{className:"rd-tt",children:["Plan & build the ",c.length," changes"]}),e.jsx("div",{className:"rd-td",children:"Next step. Nothing is built or charged until you do this."})]})]})]})}),e.jsxs("div",{className:"rd-foot",children:[e.jsx("button",{type:"button",className:"rd-cta"+(o?" done":""),onClick:h,disabled:o,children:o?"Added to your plans ✓":e.jsxs(e.Fragment,{children:["Plan these ",c.length," changes"," ",e.jsx("span",{className:"rd-ar",children:"→"})]})}),e.jsxs("div",{className:"rd-fnote",children:["They'll land in your ",e.jsx("b",{children:"Plan"})," tab. Your live app keeps working on its current data until they ship."]})]})]})}const l5=Object.freeze(Object.defineProperty({__proto__:null,RealDataConnected:od},Symbol.toStringTag,{value:"Module"}));function id(){const[t,s]=l.useState(null),n=l.useCallback(async()=>{try{const a=await fetch("/api/setup-services");if(!a.ok)throw new Error(`HTTP ${a.status}`);const o=await a.json();s(Array.isArray(o)?o:[])}catch{s([])}},[]);l.useEffect(()=>{n()},[n]);const r=l.useCallback(a=>{s(o=>o&&o.map(i=>i.key===a?{...i,status:"dismissed"}:i)),fetch(`/api/setup-services/${encodeURIComponent(a)}/dismiss`,{method:"POST"}).catch(()=>{n()})},[n]);return{services:t,dismiss:r,refetch:n}}function Us({topic:t}){const{services:s}=id();if(!s)return null;const n=s.find(a=>a.topic===t&&a.status!=="dismissed");if(!n)return null;const r=n.evidence.map(a=>a.value).join(", ");return e.jsxs("div",{className:"wired-provider",role:"note",children:[e.jsxs("div",{className:"wired-provider-title",children:[e.jsx("b",{children:n.name})," is already wired in this project"]}),e.jsx("div",{className:"wired-provider-detail",children:r?`We found ${r} in your project — here's how to finish setting it up.`:"Here's how to finish setting it up."})]})}const c5=Object.freeze(Object.defineProperty({__proto__:null,WiredProviderBanner:Us},Symbol.toStringTag,{value:"Module"}));function ld({onBack:t,onComplete:s,entity:n=Xv,connection:r=Qv,initialConnected:a=!1}){const[o,i]=l.useState(a);return e.jsxs("div",{className:"real-data-screen",children:[e.jsxs("div",{className:"rd-crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:t,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:t,children:"Home"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("button",{type:"button",onClick:t,children:"Setup"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Real data"})]}),e.jsx(Us,{topic:"real-data"}),o?e.jsx(od,{entity:n,connection:r,onPlan:s}):e.jsx(ad,{entity:n,onConnect:()=>i(!0)})]})}const d5=Object.freeze(Object.defineProperty({__proto__:null,RealDataScreen:ld},Symbol.toStringTag,{value:"Module"})),Zn={entitySingular:"item",entityPlural:"items",savedThings:"saved items",purchaseNoun:"purchase"},_j=800;function ji(t){switch(t){case"ready":return"ready";case"error":return"error";case"connected":case"provisioning":return"provisioning";default:return"provisioning"}}function eo(t,s){const[n,r]=l.useState("idle"),[a,o]=l.useState(null),[i,c]=l.useState(null),d=l.useRef(null),u=l.useCallback(()=>{d.current!==null&&(clearInterval(d.current),d.current=null)},[]),h=l.useCallback(b=>{var v,x;const g=ji(b.status);g==="ready"?(u(),o({label:((v=b.result)==null?void 0:v.label)??"",value:((x=b.result)==null?void 0:x.value)??""}),r("ready")):g==="error"?(u(),c(b.message??"Connection failed."),r("error")):r("provisioning")},[u]),p=l.useCallback(async()=>{try{const b=await fetch(`/api/setup/connection-status?topic=${encodeURIComponent(t)}`);if(!b.ok)return;h(await b.json())}catch{}},[t,h]),m=l.useCallback(b=>{u(),c(null),o(null),r("connecting"),(async()=>{try{const v=await(await fetch("/api/setup/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topic:t,provider:s,credential:b})})).json().catch(()=>({}));h(v),ji(v.status)==="provisioning"&&(d.current=setInterval(()=>void p(),_j))}catch(g){u(),c(g instanceof Error?g.message:"Connection failed."),r("error")}})()},[t,s,h,p,u]),f=l.useCallback(()=>{u(),r("idle"),o(null),c(null)},[u]);return l.useEffect(()=>u,[u]),{stage:n,result:a,error:i,connect:m,reset:f}}const kj="accounts";function Sj(t){switch(t){case"clerk":return"Clerk";case"supabase_auth":return"Supabase Auth";default:return t}}function cd({provider:t,app:s=Zn,startedOn:n="recently",onComplete:r}){const{stage:a,result:o,error:i,connect:c,reset:d}=eo(kj,t),[u,h]=l.useState(""),p=Sj(t);return a==="ready"?e.jsxs(e.Fragment,{children:[o&&(o.label||o.value)&&e.jsxs("div",{className:"url-card",role:"status",children:[e.jsx("span",{className:"ucglobe",children:"✅"}),e.jsxs("div",{children:[e.jsx("div",{className:"uc-l",children:o.label||"Connected"}),e.jsx("div",{className:"uc-u",children:o.value})]})]}),e.jsx(no,{app:s,startedOn:n,onComplete:r})]}):a==="error"?e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"real-error",role:"alert",children:[e.jsxs("div",{className:"real-error-title",children:["Couldn’t connect ",p]}),e.jsx("div",{className:"real-error-msg",children:i})]}),e.jsx("button",{type:"button",className:"auth-btn",onClick:()=>{h(""),d()},children:"Try again"})]}):a==="connecting"||a==="provisioning"?e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"deploy-head",children:[e.jsx("div",{className:"deploy-spin"}),e.jsxs("div",{children:[e.jsxs("div",{className:"deploy-t",children:["Setting up ",p]}),e.jsx("div",{className:"deploy-d",children:a==="connecting"?`Connecting to ${p}…`:"Provisioning your sign-in keys…"})]})]}),e.jsx("div",{className:"dep-bar",children:e.jsx("div",{className:"dep-bar-indeterminate"})})]}):e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"ph",children:["Connect ",p]}),e.jsxs("div",{className:"psub",children:["Paste your ",p," secret key to wire real accounts into your app. CodeYam holds the key and injects it into the running app — you never touch a server."]}),e.jsxs("div",{className:"connect-box",children:[e.jsxs("label",{className:"real-token-label",htmlFor:"accounts-secret-key",children:[p," secret key"]}),e.jsx("input",{id:"accounts-secret-key",type:"password",className:"real-token-input",placeholder:`Paste your ${p} secret key`,value:u,onChange:m=>h(m.target.value)}),e.jsxs("button",{type:"button",className:"auth-btn",disabled:u.trim().length===0,onClick:()=>c(u.trim()),children:["Connect ",p]})]}),e.jsx("div",{className:"reassure",children:"🔒 Your key is stored locally and never shown."})]})}const u5=Object.freeze(Object.defineProperty({__proto__:null,AccountsRealConnect:cd},Symbol.toStringTag,{value:"Module"})),Nj=1800;function er({config:t,onConnect:s}){const[n,r]=l.useState(!1),[a,o]=l.useState(!1),[i,c]=l.useState(null),d=()=>{n||(r(!0),window.setTimeout(s,Nj))},u=t.connectColor==="green"?{"--connect":"var(--green)"}:void 0;return e.jsxs("div",{className:"su-wrap",children:[e.jsxs("div",{className:"su-shead",children:[e.jsx("div",{className:"su-badge",children:t.badge}),e.jsxs("div",{children:[e.jsxs("h1",{className:"su-title",children:[t.title," ",e.jsx("span",{className:"su-chip notset",children:"Not set up"})]}),e.jsxs("div",{className:"su-via",children:["powered by ",e.jsx("b",{children:t.providerName})]}),e.jsx("p",{className:"su-lead",children:t.lead})]})]}),e.jsxs("div",{className:"su-explain",children:[e.jsxs("div",{className:"su-eh",children:[e.jsx("span",{className:"su-q",children:"?"}),t.explainerHeading]}),e.jsx("div",{className:"su-lede",children:t.lede}),e.jsx("div",{className:"su-erows",children:t.explainerRows.map(h=>e.jsxs("div",{className:"su-erow",children:[e.jsx("div",{className:"su-en",children:h.icon}),e.jsxs("div",{className:"su-et",children:[e.jsx("b",{children:h.title}),e.jsx("span",{children:h.desc})]})]},h.title))}),e.jsxs("div",{className:"su-why",children:[e.jsxs("div",{className:"su-wh",children:[e.jsx(Kt,{size:15}),t.whyHeading]}),t.whyRows.map(h=>e.jsxs("div",{className:"su-whyrow",children:[e.jsx("span",{className:"su-wc",children:e.jsx(Oe,{size:11})}),e.jsxs("p",{children:[e.jsx("b",{children:h.lead})," ",h.rest]})]},h.lead))]})]}),e.jsxs("div",{className:"su-connect",style:u,children:[e.jsx("div",{className:"su-ct",children:t.connectTitle}),e.jsx("div",{className:"su-cd",children:t.connectDesc}),e.jsx("button",{type:"button",className:"su-cbtn",onClick:d,disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(Xa,{size:16}),"Opening ",t.providerName,"…"]}):e.jsxs(e.Fragment,{children:[e.jsx(Kn,{size:16}),t.connectButtonLabel]})}),e.jsx("div",{className:"su-reassure",children:t.reassure.map(h=>e.jsxs("span",{children:[e.jsx(Oe,{size:13}),h]},h))})]}),t.alternatives&&t.alternatives.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"su-alt-toggle",onClick:()=>o(h=>!h),children:[a?"Hide other options":t.altToggleLabel," ",e.jsx("span",{className:"su-chev"+(a?" open":""),children:"⌄"})]}),a?e.jsx("div",{className:"su-alts",children:t.alternatives.map(h=>e.jsxs("div",{className:"su-altrow",children:[e.jsx("div",{className:"su-altmark",style:{background:h.color},children:h.monogram}),e.jsxs("div",{className:"su-altbody",children:[e.jsx("div",{className:"su-altname",children:h.name}),e.jsx("div",{className:"su-altdesc",children:h.desc}),h.factKey?e.jsxs("div",{className:"su-altfact",children:[re(h.factKey).value,e.jsx(Rt,{fact:re(h.factKey)})]}):null]}),e.jsx("button",{type:"button",className:"su-altpick"+(i===h.name?" picked":""),onClick:()=>c(h.name),children:i===h.name?"Selected ✓":"Use this"})]},h.name))}):null]}):null,e.jsx("div",{className:"su-uplabel",children:t.lockedLabel}),e.jsx("div",{className:"su-locked",children:t.lockedSteps.map(h=>e.jsxs("div",{className:"su-lrow",children:[e.jsx("div",{className:"su-ln",children:h.icon}),e.jsxs("div",{className:"su-lt",children:[e.jsx("b",{children:h.title}),e.jsx("span",{children:h.desc})]}),e.jsx("span",{className:"su-lk",children:e.jsx(Ce,{size:15})})]},h.title))}),t.faq&&t.faq.length>0?e.jsx(De,{items:t.faq}):null,t.assistKey?e.jsx(de,{assistKey:t.assistKey,topicName:t.title}):null]})}const h5=Object.freeze(Object.defineProperty({__proto__:null,SetupNotConnected:er},Symbol.toStringTag,{value:"Module"}));function tr({children:t}){return e.jsx("div",{className:"su-steps",children:t})}function ct({state:t,num:s,title:n,pill:r,desc:a,children:o}){return e.jsxs("div",{className:"su-step",children:[e.jsxs("div",{className:"su-rail",children:[e.jsx("div",{className:"su-node "+t,children:t==="done"?e.jsx(Oe,{size:15}):s}),e.jsx("div",{className:"su-line"})]}),e.jsxs("div",{className:"su-scon",children:[e.jsxs("div",{className:"su-stitle",children:[n,r?e.jsx("span",{className:"su-pill",children:r}):null]}),e.jsx("div",{className:"su-sdesc",children:a}),o]})]})}function to({monogram:t,name:s,detail:n,monogramStyle:r}){return e.jsxs("div",{className:"su-acct",children:[e.jsx("div",{className:"su-av",style:r,children:t}),e.jsxs("div",{className:"su-ainfo",children:[e.jsx("b",{children:s}),e.jsx("span",{children:n})]}),e.jsx("button",{type:"button",className:"su-chg",children:"Change"})]})}function dd({methods:t,initialSelected:s}){const[n,r]=l.useState(()=>new Set(s)),a=o=>r(i=>{const c=new Set(i);return c.has(o)?c.delete(o):c.add(o),c});return e.jsx("div",{className:"su-methods",children:t.map(o=>e.jsxs("button",{type:"button",className:"su-mchip"+(n.has(o.key)?" on":""),onClick:()=>a(o.key),"aria-pressed":n.has(o.key),children:[e.jsx("span",{className:"su-ck",children:e.jsx(Oe,{size:11})}),o.icon,o.label]},o.key))})}function sr({children:t}){return e.jsxs("div",{className:"su-field",children:[e.jsx("span",{className:"su-edit",children:"Edit"}),t]})}function ud({examples:t}){const[s,n]=l.useState(new Set),r=a=>n(o=>{const i=new Set(o);return i.has(a)?i.delete(a):i.add(a),i});return e.jsx("div",{className:"su-examples",children:t.map((a,o)=>e.jsxs("button",{type:"button",className:"su-ex"+(s.has(o)?" added":""),onClick:()=>r(o),children:[e.jsx("span",{className:"su-plus",children:s.has(o)?"✓":"+"}),a]},a))})}function nr({items:t}){return e.jsx("div",{className:"su-builds",children:t.map(s=>e.jsxs("div",{className:"su-bitem",children:[e.jsx("div",{className:"su-bx",children:e.jsx(Oe,{size:13})}),e.jsxs("div",{className:"su-bmain",children:[e.jsx("b",{children:s.title}),e.jsx("span",{children:s.caption})]}),e.jsx("span",{className:"su-where",children:s.where})]},s.title))})}function rr({accent:t,icon:s,children:n}){const r={"--note-accent":t==="amber"?"var(--amber)":"var(--blue)"};return e.jsxs("div",{className:"su-note",style:r,children:[s,e.jsx("p",{children:n})]})}function ar({label:t,note:s,onPlan:n}){const[r,a]=l.useState(!1),o=()=>{r||(a(!0),n==null||n())};return e.jsxs("div",{className:"su-foot",children:[e.jsx("button",{type:"button",className:"su-cta",onClick:o,disabled:r,children:r?"Added to your plans ✓":e.jsxs(e.Fragment,{children:[t," ",e.jsx("span",{className:"su-ar",children:"→"})]})}),e.jsx("div",{className:"su-fnote",children:s})]})}const p5=Object.freeze(Object.defineProperty({__proto__:null,BuildList:nr,ControlNote:rr,EditableField:sr,ExampleChips:ud,MethodChips:dd,SetupAccountRow:to,SetupPlanFooter:ar,SetupStep:ct,SetupStepper:tr},Symbol.toStringTag,{value:"Module"}));function hs(t,s,n){return e.jsx("svg",{viewBox:"0 0 24 24",width:t,height:t,fill:"none",stroke:"currentColor",strokeWidth:s,strokeLinecap:"round",strokeLinejoin:"round",children:n})}function Pn({size:t=16}){return hs(t,1.7,e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"8",r:"3.5"}),e.jsx("path",{d:"M5 20a7 7 0 0 1 14 0"})]}))}function hd({size:t=16}){return hs(t,1.8,e.jsx("path",{d:"M5 12h14M12 5l7 7-7 7"}))}function so({size:t=16}){return hs(t,1.8,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M22 2 11 13"}),e.jsx("path",{d:"M22 2 15 22l-4-9-9-4z"})]}))}function pd({size:t=16}){return hs(t,1.8,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 9v4M12 17h.01"}),e.jsx("path",{d:"M10.3 4.3 2.6 18a1.5 1.5 0 0 0 1.3 2.2h16.2a1.5 1.5 0 0 0 1.3-2.2L13.7 4.3a1.5 1.5 0 0 0-2.6 0z"})]}))}function ra({size:t=16}){return hs(t,1.8,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"m22 7-10 6L2 7"}),e.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2"})]}))}function md({size:t=16}){return e.jsx("svg",{viewBox:"0 0 24 24",width:t,height:t,fill:"currentColor",children:e.jsx("path",{d:"M21.35 11.1H12v2.9h5.35c-.25 1.45-1.7 4.25-5.35 4.25-3.2 0-5.85-2.65-5.85-5.9s2.65-5.9 5.85-5.9c1.85 0 3.05.8 3.75 1.45l2.55-2.45C16.6 3.6 14.55 2.7 12 2.7 6.95 2.7 2.9 6.75 2.9 12s4.05 9.3 9.1 9.3c5.25 0 8.7-3.7 8.7-8.9 0-.6-.05-1.05-.35-1.3z"})})}function fd({size:t=16}){return e.jsx("svg",{viewBox:"0 0 24 24",width:t,height:t,fill:"currentColor",children:e.jsx("path",{d:"M16.4 12.8c0-2.2 1.8-3.3 1.9-3.3-1-1.5-2.6-1.7-3.2-1.7-1.4-.1-2.6.8-3.3.8-.7 0-1.7-.8-2.8-.8-1.4 0-2.8.8-3.5 2.1-1.5 2.6-.4 6.5 1.1 8.6.7 1 1.6 2.2 2.7 2.1 1.1 0 1.5-.7 2.8-.7s1.6.7 2.8.7c1.1 0 1.9-1 2.6-2.1.8-1.2 1.2-2.3 1.2-2.4-.1 0-2.3-.9-2.3-3.4zM14.2 6.3c.6-.7 1-1.7.9-2.7-.9 0-2 .6-2.6 1.3-.6.6-1.1 1.6-.9 2.6 1 .1 2-.5 2.6-1.2z"})})}function gd({size:t=16}){return hs(t,1.8,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 3 3 8l9 5 9-5-9-5z"}),e.jsx("path",{d:"M3 8v5l9 5 9-5V8"})]}))}const m5=Object.freeze(Object.defineProperty({__proto__:null,AppleGlyph:fd,ArrowRightIcon:hd,GoogleGlyph:md,GraduationIcon:gd,MagicLinkIcon:ra,PaperPlaneIcon:so,PersonIcon:Pn,WarningTriangleIcon:pd},Symbol.toStringTag,{value:"Module"}));function Cj(t){return{accent:"blue",assistKey:"accounts",badge:e.jsx(Pn,{size:25}),title:"Let people sign in",providerName:"Supabase",connectColor:"lime",lead:`Right now everyone using your app is anonymous, so a ${t.entitySingular} they save vanishes the moment they close the tab. Give people their own account and their ${t.savedThings} and settings follow them on any device. CodeYam uses Supabase.`,explainerHeading:"New to accounts? Here's the short version",lede:e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"An account is how your app knows who someone is."})," Instead of every visitor being a stranger, each person gets a private space — their"," ",t.savedThings,", their profile — that they can reach from any phone or laptop by signing in. Supabase is the secure tech that handles the signing-in part for you."]}),explainerRows:[{icon:e.jsx(Pn,{size:16}),title:"Everything stays tied to them",desc:e.jsxs(e.Fragment,{children:["Their ",t.savedThings," and profile are remembered"," ",e.jsx("em",{children:"even after they close the app"}),", instead of resetting."]})},{icon:e.jsx(hd,{size:16}),title:"It follows them across devices",desc:e.jsxs(e.Fragment,{children:["Sign in on a phone, see the same ",t.savedThings," on a laptop,"," ",e.jsx("em",{children:"anywhere they sign in"}),"."]})},{icon:e.jsx(Ce,{size:16}),title:"It keeps private things private",desc:e.jsxs(e.Fragment,{children:["Accounts let you say ",e.jsx("em",{children:'"only this person can see their data,"'})," ","which you'll want before real money or personal info is involved."]})}],whyHeading:"Why CodeYam picks Supabase for you",whyRows:[{lead:"Free to start, no card needed.",rest:"A generous free tier covers a new app comfortably. You only pay once you have a lot of users, and you'll see it coming."},{lead:"Security handled for you.",rest:"Passwords, Google and Apple sign-in, and resets are managed by Supabase, so the risky parts aren't yours to get right. Social logins do need a one-time developer setup with each provider — see the FAQ below."},{lead:"Nothing for you to manage.",rest:"No servers, no security patches. CodeYam handles the wiring, you just decide who gets to sign in."}],connectTitle:"Connect or create your Supabase project",connectDesc:"A new window opens on Supabase. If you already have an account, sign in. If not, you'll make one — it's free and takes a few minutes. CodeYam links to it and holds the keys, so you never touch a server.",connectButtonLabel:"Connect Supabase",reassure:["Free to start, no card needed","Takes about 3 minutes","Disconnect any time"],altToggleLabel:"Supabase not for you? See other options",alternatives:[{monogram:"C",color:"linear-gradient(140deg,#6c47ff,#4b2fcc)",name:"Clerk",desc:"Polished sign-in screens and user management out of the box. A great pick if you want the slickest ready-made experience.",factKey:"clerk.freeTier"},{monogram:"A",color:"linear-gradient(140deg,#eb5424,#b53a13)",name:"Auth0",desc:"A long-established choice with deep enterprise controls. Worth it if you'll need that later, a little more to set up.",factKey:"auth0.freeTier"}],lockedLabel:"Then, once you're connected",lockedSteps:[{icon:e.jsx(Jn,{size:15}),title:"Choose how people sign in",desc:`Google, Apple, email, magic link — pick as many as you like. Then say when to ask, like "only when someone saves an ${t.entitySingular}."`},{icon:e.jsx(Es,{size:15}),title:"CodeYam builds your sign-in screens",desc:`A sign-in screen, a "sign in to save" prompt, per-person ${t.savedThings}, and a profile menu — each a plan you preview before it ships.`}],faq:[{q:"Do Google and Apple sign-in need extra setup?",a:`Yes — each social login is registered with that provider, so Google and Apple sign-in need OAuth credentials created in the provider's developer console (a one-time setup CodeYam walks you through). "Sign in with Apple" also requires a paid Apple Developer account (${re("appleDeveloper.fee").value}). Email and magic-link sign-in have no such requirement, so they're the quickest way to launch.`},{q:"Can I add more sign-in options later?",a:"Yes. You can start with just email or a magic link and add Google, Apple, or others whenever you're ready — each is its own small plan you preview before it ships."}]}}const Tj=[{key:"google",label:"Google",icon:e.jsx(md,{size:15})},{key:"apple",label:"Apple",icon:e.jsx(fd,{size:15})},{key:"email",label:"Email",icon:e.jsx(ra,{size:15})},{key:"magic",label:"Magic link",icon:e.jsx(ra,{size:15})}];function no({app:t,startedOn:s,onComplete:n}){const r=[{title:"A sign-in & sign-up screen",caption:"Google, Apple, and email, matched to your app's look.",where:"/signin"},{title:'A "sign in to save" prompt',caption:"Shown the first time someone taps save or buy, never before.",where:`/${t.entitySingular}`},{title:`Each person's own ${t.savedThings}`,caption:"Their list follows them on phone, laptop, anywhere they sign in.",where:"/saved"},{title:"A profile & sign-out menu",caption:"So people can manage their account and leave safely.",where:"/profile"}];return e.jsxs("div",{className:"su-wrap",children:[e.jsxs("div",{className:"su-shead",children:[e.jsx("div",{className:"su-badge",children:e.jsx(Pn,{size:25})}),e.jsxs("div",{children:[e.jsx("h1",{className:"su-title",children:"Let people sign in"}),e.jsxs("div",{className:"su-via",children:["powered by ",e.jsx("b",{children:"Supabase"})," · the sign-in tech behind modern apps"]}),e.jsxs("p",{className:"su-lead",children:["Give people their own account so their ",t.savedThings," and settings follow them on any device. CodeYam builds the screens and handles the security, you just decide who gets in."]})]})]}),e.jsxs("div",{className:"su-remember",children:[e.jsx("span",{className:"su-rdot"}),e.jsxs("div",{className:"su-widget-body",children:[e.jsxs("b",{children:["You started this on ",s,"."]}),e.jsx("span",{children:"Sign-in methods are chosen — one step left before you can plan it."})]}),e.jsx("span",{className:"su-ago",children:"resumed today"})]}),e.jsxs("div",{className:"su-learn",children:[e.jsxs("div",{className:"su-lhd",children:[e.jsx(gd,{size:15}),'What "accounts" actually means']}),e.jsxs("p",{children:["Right now everyone using your app is ",e.jsx("b",{children:"anonymous"})," — nothing they do is tied to them, so a saved ",t.entitySingular," disappears when they close the tab."]}),e.jsxs("p",{children:["Accounts give each person a ",e.jsx("b",{children:"private space"}),": their own"," ",t.savedThings,`, their profile. It also lets you say "only this person can see their data," which you'll want before real money or personal info is involved.`]})]}),e.jsx("div",{className:"su-seclabel",children:"Set it up"}),e.jsxs(tr,{children:[e.jsx(ct,{state:"done",num:1,title:"How should people sign in?",pill:"Chosen",desc:"Pick as many as you like. Most apps offer one tap with Google or Apple, plus email as a fallback.",children:e.jsx(dd,{methods:Tj,initialSelected:["google","apple","email"]})}),e.jsx(ct,{state:"done",num:2,title:"When should people be asked to sign in?",desc:"Plain language is fine — this is the instruction CodeYam follows.",children:e.jsxs(sr,{children:["Let people ",e.jsx("b",{children:"browse freely"})," without an account. Only ask them to sign in when they ",e.jsxs("b",{children:["save an ",t.entitySingular]})," or"," ",e.jsxs("b",{children:["buy a ",t.purchaseNoun]}),"."]})}),e.jsx(ct,{state:"todo",num:3,title:"What CodeYam will build",desc:"Four changes. Each becomes a plan you can preview, reorder, or drop before it ships.",children:e.jsx(nr,{items:r})})]}),e.jsxs(rr,{accent:"blue",icon:e.jsx(Ce,{size:17}),children:[e.jsx("b",{children:"Nothing is locked down yet."})," People keep using your app exactly as they do now until you plan and build these. You can preview every screen first."]}),e.jsx(ar,{label:"Plan these 4 changes",note:e.jsxs(e.Fragment,{children:["They'll land in your ",e.jsx("b",{children:"Plan"})," tab, ready to build after your current session."]}),onPlan:n})]})}function bd({onBack:t,onComplete:s,app:n=Zn,initialConnected:r=!1,startedOn:a="recently",connector:o}){const[i,c]=l.useState(r),d=!!o&&!i;return e.jsxs("div",{className:"setup-screen accent-blue",children:[e.jsxs("div",{className:"su-crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:t,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:t,children:"Setup"}),e.jsx("span",{className:"sep",children:"/"}),e.jsx("b",{children:"Accounts & sign-in"})]}),e.jsx(Us,{topic:"accounts"}),i?e.jsx(no,{app:n,startedOn:a,onComplete:s}):d?e.jsx(cd,{provider:o.provider,app:n,startedOn:a,onComplete:s}):e.jsx(er,{config:Cj(n),onConnect:()=>c(!0)})]})}const f5=Object.freeze(Object.defineProperty({__proto__:null,AccountsConnected:no,AccountsScreen:bd},Symbol.toStringTag,{value:"Module"})),Pj="hello@your-app.com",Oj={monogram:"R",name:"Your app",detail:"you@your-app.com · re_live_…"};function Aj(t){return{accent:"amber",assistKey:"emails",badge:e.jsx(qs,{size:25}),title:"Send emails from your app",providerName:"Resend",connectColor:"green",lead:"Right now your app can't email anyone. To send things like receipts, sign-in links, and welcome notes, it needs an email service — the part that actually delivers messages. CodeYam uses Resend.",explainerHeading:"New to Resend? Here's the short version",lede:e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Resend is the part that actually sends your email."})," When your app needs to email someone, Resend takes the message and makes sure it lands in their inbox, not the spam folder, from an address that looks like you."]}),explainerRows:[{icon:e.jsx(so,{size:16}),title:"It sends reliably",desc:e.jsxs(e.Fragment,{children:["Receipts, password resets, and welcome notes go out"," ",e.jsx("em",{children:"the instant your app asks"}),", from your own address."]})},{icon:e.jsx(Kt,{size:16}),title:"It stays out of spam",desc:e.jsxs(e.Fragment,{children:["Resend handles the technical reputation work behind the scenes, so your emails ",e.jsx("em",{children:"actually arrive"})," instead of vanishing."]})},{icon:e.jsx(jt,{size:16}),title:"It shows you what happened",desc:e.jsxs(e.Fragment,{children:["See what was sent, delivered, or opened ",e.jsx("em",{children:"in one simple log"}),", so you're never guessing if a message went through."]})}],whyHeading:"Why CodeYam picks Resend for you",whyRows:[{lead:"Free to start, no card needed.",rest:`Resend's free tier gives you ${re("resend.free").value} — plenty for a new app, and the daily cap is the one to watch on launch day. You only pay once you send more.`},{lead:"Use your own address.",rest:"Send from your own domain so it looks like you, not a robot or a no-reply. This needs a one-time domain verification (a few DNS records) — see the steps below."},{lead:"Nothing to wire up.",rest:"CodeYam connects it and writes the emails for you. You just say what each one should say."}],connectTitle:"Connect or create your Resend account",connectDesc:"A new window opens on Resend. If you already have an account, sign in. If not, you'll make one — it's free and takes a few minutes. CodeYam links to it and holds the keys, so you never touch a server.",connectButtonLabel:"Connect Resend",reassure:["Free to start, no card needed","Connecting takes minutes — verifying your domain in DNS can take longer","Disconnect any time"],altToggleLabel:"Resend not for you? See other options",alternatives:[{monogram:"P",color:"#ffd400",name:"Postmark",desc:"Built for receipts and sign-in links, with a reputation for landing in the inbox fast. A great pick if reliable delivery matters most."},{monogram:"SG",color:"#1a82e2",name:"SendGrid",desc:"A long-established service that scales to very high volume. Handy if you already have an account you'd rather reuse."},{monogram:"SES",color:"#ff9900",name:"Amazon SES",desc:"The cheapest once you're sending a lot, with a little more setup. Best for high volume when you want to trim cost."}],lockedLabel:"Then, once you're connected",lockedSteps:[{icon:e.jsx(Kt,{size:15}),title:"Verify your sending domain",desc:"Add a few DNS records (SPF, DKIM, DMARC) so providers trust your mail. This can take from a few minutes to a few hours to take effect — until it does, you can only send from Resend's test address, not your own domain."},{icon:e.jsx(Jn,{size:15}),title:"Tell us which emails to send",desc:`Plain language, like "a receipt after each ${t.purchaseNoun}, and a welcome note on sign-up."`},{icon:e.jsx(Es,{size:15}),title:"CodeYam writes and wires each email",desc:"The wording, the design, and when it sends — each a plan you preview before a single message goes out."}],faq:[{q:"Why are my emails going to spam?",a:"Almost always because your sending domain isn't verified yet. Until you add the SPF, DKIM, and DMARC DNS records Resend gives you, inbox providers can't confirm the mail is really from you, so they filter it. Verifying your own domain — and sending from it rather than a free inbox address like gmail.com — is what gets you reliably into the inbox."},{q:"Do I need my own domain to send email?",a:"To send from your own address (hello@your-app.com) and stay out of spam, yes — you verify a domain you own. Before that's set up you can still send from Resend's shared test address to try the flow, but real launch email should go from your verified domain."}]}}function xd({app:t,verifiedAddress:s,account:n,onComplete:r}){const a=[{title:"A welcome email",caption:"Sent the moment someone signs up, in your voice.",where:"on sign-up"},{title:`A receipt & ${t.purchaseNoun} email`,caption:`With the ${t.entitySingular} details and a ${t.purchaseNoun}, after each purchase.`,where:"on purchase"},{title:"A password reset link",caption:"A secure, single-use link when someone asks to reset.",where:"on request"},{title:"A simple sent log",caption:"See what was sent, delivered, or opened, in one screen.",where:"/emails"}];return e.jsxs("div",{className:"su-wrap",children:[e.jsxs("div",{className:"su-shead",children:[e.jsx("div",{className:"su-badge",children:e.jsx(qs,{size:25})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"su-title",children:["Send emails from your app"," ",e.jsxs("span",{className:"su-chip connected",children:[e.jsx(Oe,{size:11}),"Connected"]})]}),e.jsxs("div",{className:"su-via",children:["powered by ",e.jsx("b",{children:"Resend"})]}),e.jsx("p",{className:"su-lead",children:"Your app can send email now. Tell CodeYam which emails to send, in plain language, and it writes and wires each one. You preview every message before a single one goes out."})]})]}),e.jsxs("div",{className:"su-statusbar",children:[e.jsx("div",{className:"su-widget-ic",children:e.jsx(Kt,{size:16})}),e.jsxs("div",{className:"su-widget-body",children:[e.jsx("b",{children:"Your sending address is verified"}),e.jsxs("span",{children:["Emails go out from ",e.jsx("code",{children:s}),", so they look like you, not a robot."]})]}),e.jsx("button",{type:"button",className:"su-chg",children:"Manage"})]}),e.jsxs(tr,{children:[e.jsx(ct,{state:"done",num:1,title:"Connect your Resend account",pill:"Connected",desc:"CodeYam holds the keys and does the wiring — you never touch a server or a config file.",children:e.jsx(to,{monogram:n.monogram,name:n.name,detail:n.detail,monogramStyle:{background:"#ffd400",color:"#1a1a1a"}})}),e.jsxs(ct,{state:"done",num:2,title:"Which emails should your app send?",desc:"Plain language is fine — this is what shapes the emails below.",children:[e.jsxs(sr,{children:["A ",e.jsx("b",{children:"welcome note"})," when someone signs up, a"," ",e.jsxs("b",{children:["receipt with their ",t.purchaseNoun]})," after a purchase, and a"," ",e.jsx("b",{children:"password reset link"})," when they ask for one."]}),e.jsx(ud,{examples:[`A reminder the day before an ${t.entitySingular}`,`A note when an ${t.entitySingular} is cancelled`,`A monthly "what's on" roundup`]})]}),e.jsx(ct,{state:"todo",num:3,title:"What CodeYam will build",desc:"Four emails, each a plan you can preview, reword, or drop before it ever sends.",children:e.jsx(nr,{items:a})})]}),e.jsxs(rr,{accent:"amber",icon:e.jsx(so,{size:17}),children:[e.jsx("b",{children:"No email sends yet."})," These four are built as drafts so you can read every word and see how each looks. When it feels right, turn them on and your app starts emailing."]}),e.jsx(ar,{label:"Plan these 4 emails",note:e.jsxs(e.Fragment,{children:["They'll land in your ",e.jsx("b",{children:"Plan"})," tab, previewable before anything sends, and easy to reword anytime."]}),onPlan:r})]})}function yd({onBack:t,onComplete:s,app:n=Zn,initialConnected:r=!1,verifiedAddress:a=Pj,account:o=Oj}){const[i,c]=l.useState(r);return e.jsxs("div",{className:"setup-screen accent-amber",children:[e.jsxs("div",{className:"su-crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:t,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:t,children:"Setup"}),e.jsx("span",{className:"sep",children:"/"}),e.jsx("b",{children:"Sending emails"})]}),e.jsx(Us,{topic:"emails"}),i?e.jsx(xd,{app:n,verifiedAddress:a,account:o,onComplete:s}):e.jsx(er,{config:Aj(n),onConnect:()=>c(!0)})]})}const g5=Object.freeze(Object.defineProperty({__proto__:null,EmailsConnected:xd,EmailsScreen:yd},Symbol.toStringTag,{value:"Module"}));function ae({icon:t,title:s,meta:n,onBack:r,crumbLabel:a,assistKey:o}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:r,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:r,children:"Home"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("button",{type:"button",onClick:r,children:"Setup"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:a??s})]}),e.jsxs("div",{className:"htitle",children:[e.jsx("div",{className:"hic",children:t}),e.jsxs("div",{children:[e.jsx("div",{className:"h",children:s}),e.jsx("div",{className:"hmeta",children:n})]})]})]})}function Tt({topic:t,step:s,onBack:n}){return e.jsxs("div",{className:"crumbs",children:[n?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"back",onClick:n,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:n,children:t})]}):e.jsx("span",{children:t}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:s})]})}function gt({steps:t,currentKey:s}){const n=t.findIndex(r=>r.key===s);return e.jsx("div",{className:"flowbar",children:t.map((r,a)=>e.jsxs("span",{style:{display:"contents"},children:[a>0?e.jsx("span",{className:"fsep"}):null,e.jsxs("span",{className:"fstep"+(a<n?" done":a===n?" active":""),children:[e.jsx("span",{className:"fn",children:a<n?"✓":a+1}),r.label]})]},r.key))})}function he({label:t,note:s,onComplete:n}){return e.jsxs("div",{className:"cta-wrap",children:[e.jsxs("button",{type:"button",className:"cta",onClick:n,children:[e.jsx("span",{className:"ce",children:"✓"})," ",t]}),e.jsx("div",{className:"cta-note",children:s})]})}const b5=Object.freeze(Object.defineProperty({__proto__:null,SetupCompleteCta:he,SetupDetailHeader:ae,SetupFlowBar:gt,SetupSubCrumb:Tt},Symbol.toStringTag,{value:"Module"}));function an(t){return[{key:"connect",label:t.flowLabels[0]},{key:"provision",label:t.flowLabels[1]},{key:"ready",label:t.flowLabels[2]}]}function ro({config:t,provider:s,onBack:n,onComplete:r}){const{stage:a,result:o,error:i,connect:c,reset:d}=eo(t.key,s),[u,h]=l.useState("");return a==="idle"?e.jsxs(e.Fragment,{children:[e.jsx(Tt,{topic:t.crumbLabel??t.title,step:t.flowLabels[0],onBack:n}),e.jsx(gt,{steps:an(t),currentKey:"connect"}),e.jsxs("div",{className:"panel",children:[e.jsx("div",{className:"ph",children:t.connect.heading}),e.jsx("div",{className:"psub",children:t.connect.sub}),e.jsxs("div",{className:"connect-box",children:[e.jsxs("div",{className:"cbtitle",children:[e.jsx(Qn,{initial:t.recommended.initial,color:t.recommended.color}),e.jsxs("div",{children:[e.jsxs("div",{className:"cbt",children:["Connect ",t.recommended.name]}),e.jsxs("div",{className:"cbd",children:["Paste a ",t.recommended.name," API token to connect your real account."]})]})]}),e.jsx("label",{className:"real-token-label",htmlFor:"real-token",children:"API token"}),e.jsx("input",{id:"real-token",type:"password",className:"real-token-input",placeholder:`Paste your ${t.recommended.name} token`,value:u,onChange:p=>h(p.target.value)}),e.jsx("button",{type:"button",className:"auth-btn",disabled:u.trim().length===0,onClick:()=>c(u.trim()),children:t.connect.continueLabel})]}),e.jsxs("div",{className:"reassure",children:["🔒 ",t.connect.reassure]})]})]}):a==="error"?e.jsxs(e.Fragment,{children:[e.jsx(Tt,{topic:t.crumbLabel??t.title,step:t.flowLabels[0],onBack:n}),e.jsx(gt,{steps:an(t),currentKey:"connect"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"real-error",role:"alert",children:[e.jsx("div",{className:"real-error-title",children:"Couldn’t connect"}),e.jsx("div",{className:"real-error-msg",children:i})]}),e.jsx("button",{type:"button",className:"auth-btn",onClick:()=>{h(""),d()},children:"Try again"})]})]}):a==="ready"?e.jsxs(e.Fragment,{children:[e.jsx(Tt,{topic:t.crumbLabel??t.title,step:t.flowLabels[2]}),e.jsx(gt,{steps:an(t),currentKey:"ready"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"live-hero",children:[e.jsx("div",{className:"lh-em",children:"🎉"}),e.jsx("div",{className:"lh-t",children:t.ready.title}),e.jsx("div",{className:"lh-d",children:t.ready.desc})]}),e.jsxs("div",{className:"url-card",children:[e.jsx("span",{className:"ucglobe",children:"✅"}),e.jsxs("div",{children:[e.jsx("div",{className:"uc-l",children:(o==null?void 0:o.label)||t.ready.resultLabel}),e.jsx("div",{className:"uc-u",children:(o==null?void 0:o.value)||t.ready.resultValue})]})]}),e.jsxs("div",{className:"live-foot",children:[e.jsxs("span",{className:"done-pill",children:[e.jsx(Te,{})," ",t.ready.donePill]}),e.jsx("button",{type:"button",className:"lf-back",onClick:()=>r==null?void 0:r(),children:"Back to Setup"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Tt,{topic:t.crumbLabel??t.title,step:t.flowLabels[1]}),e.jsx(gt,{steps:an(t),currentKey:"provision"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"deploy-head",children:[e.jsx("div",{className:"deploy-spin"}),e.jsxs("div",{children:[e.jsx("div",{className:"deploy-t",children:t.provisionTitle}),e.jsx("div",{className:"deploy-d",children:a==="connecting"?`Connecting to ${t.recommended.name}…`:t.provisionDesc})]})]}),e.jsx("div",{className:"dep-bar",children:e.jsx("div",{className:"dep-bar-indeterminate"})})]})]})}const x5=Object.freeze(Object.defineProperty({__proto__:null,RealSetupFlow:ro},Symbol.toStringTag,{value:"Module"})),Rj={monogram:"AC",name:"Your app",detail:"you@your-app.com · acct_…"};function Ej(t){return{accent:"indigo",assistKey:"payments",badge:e.jsx(Pt,{size:25}),title:"Accept payments",providerName:"Stripe",connectColor:"lime",lead:"You'd like people to be able to pay inside your app. To move money safely, apps don't handle cards themselves — they hand that part to a trusted service. CodeYam uses Stripe.",explainerHeading:"New to Stripe? Here's the short version",lede:e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Stripe is the part that actually moves the money."})," Think of it as the card machine and the bank, run by someone else, so you never have to touch a customer's card details yourself."]}),explainerRows:[{icon:e.jsx(Ce,{size:16}),title:"It takes the payment safely",desc:e.jsxs(e.Fragment,{children:["The buyer types their card into ",e.jsx("em",{children:"Stripe's"})," secure screen, not yours. Sensitive numbers never sit in your app."]})},{icon:e.jsx(Pt,{size:16}),title:"It charges the card",desc:e.jsxs(e.Fragment,{children:["Stripe talks to the banks and approves the payment in"," ",e.jsx("em",{children:"a few seconds"}),", then tells your app it went through."]})},{icon:e.jsx(jt,{size:16}),title:"It pays you",desc:e.jsxs(e.Fragment,{children:["The money lands in ",e.jsx("em",{children:"your bank account"}),", usually within a couple of days. You can watch every sale from your dashboard."]})}],whyHeading:"What it costs",whyRows:[{lead:"It's free to start.",rest:`No monthly fee. Stripe keeps a small cut of each sale (${re("stripe.usCardFee").value} for US cards; international cards and currency conversion cost more, and a disputed charge carries a fee), so you only pay when you actually get paid. It's trusted by millions of businesses, from corner shops to Amazon.`}],connectTitle:"Connect or create your Stripe account",connectDesc:"A new window opens on Stripe. If you already have an account, sign in. If not, you'll make one — it's free and takes a few minutes. CodeYam links to it; we never see card numbers.",connectButtonLabel:"Connect Stripe",reassure:["Start in test mode, no real card or bank details needed yet","Connecting takes minutes — activating live payments takes longer","Disconnect any time"],altToggleLabel:"Selling internationally or digital goods? See tax-handling options",alternatives:[{monogram:"LS",color:"linear-gradient(140deg,#ffc233,#e0a000)",name:"Lemon Squeezy",desc:"Acts as the merchant of record, so it collects and remits sales tax/VAT for you worldwide. A strong pick for digital goods or selling outside the US, in exchange for a higher per-sale fee."},{monogram:"P",color:"linear-gradient(140deg,#1b6dff,#0b46c4)",name:"Paddle",desc:"Also a merchant of record handling global tax compliance and invoicing. Built for software and subscriptions where you'd rather not track tax rules in dozens of countries."}],lockedLabel:"Then, once you're connected",lockedSteps:[{icon:e.jsx(Kt,{size:15}),title:"Activate live payments",desc:"Test mode works right away, but before you can charge a real card Stripe has to verify your business: legal entity, a bank account to pay out to, and sometimes tax info. That review can take a day or two, so it's worth starting early — going live is not just flipping a switch."},{icon:e.jsx(Kn,{size:15}),title:"Tell us what you're selling",desc:`A sentence in plain language, like "${t.entitySingular} ${t.purchaseNoun}s, $10 to $45."`},{icon:e.jsx(Pt,{size:15}),title:"CodeYam builds your checkout",desc:`A "Get ${t.purchaseNoun}s" button, a payment screen, and an emailed receipt — each one a plan you preview before it ships.`}]}}function Mj(t){return{key:"payments",connector:{provider:"stripe"},Icon:Pt,title:"Accept payments",crumbLabel:"Payments",meta:"Foundation · about 10 minutes",leads:[{text:"Connect a real Stripe Sandbox so you can run the whole purchase flow against test cards."}],recommendLabel:"Recommended for your app",recommended:{...{initial:"S",color:"linear-gradient(140deg,#635bff,#4b45c6)",name:"Stripe"},bestFit:!0,description:"The payments tech behind millions of apps. Start in a Sandbox with test cards, go live once your business is activated.",reasons:[],chips:["Test cards","Sample products","No real money in Sandbox"]},alternatives:[],ctaLabel:"Set up payments with Stripe",ctaNote:"Nothing charges a real card in a Sandbox.",faq:[],flowLabels:["Connect","Provision","Ready"],connect:{heading:"Connect your Stripe Sandbox",sub:"Create or open a Sandbox in your Stripe Dashboard, then paste that Sandbox's restricted test key (rk_test_…).",grants:["Create sample test products and prices in the Sandbox","Read back the Sandbox so we can link you to it"],continueLabel:"Connect Stripe Sandbox",reassure:"We only accept a test key (rk_test_…). Live keys are rejected — live needs Stripe business activation first."},provisionTitle:"Setting up your Sandbox store",provisionDesc:`Creating sample ${t.purchaseNoun} products and prices in your Stripe Sandbox…`,provisionSteps:["Validating your Sandbox key","Creating sample products","Adding test prices"],ready:{title:"Your Stripe Sandbox is ready",desc:"Sample products and prices are set up. Open the Sandbox to see them and run a test purchase.",resultLabel:"Stripe sandbox",resultValue:"dashboard.stripe.com/test/products",donePill:"Payments connected in test mode"}}}function vd(){const[t,s]=l.useState("test");return e.jsxs("div",{className:"su-modebar",children:[e.jsx("div",{className:"su-widget-ic",children:e.jsx(pd,{size:16})}),e.jsxs("div",{className:"su-widget-body",children:[e.jsx("b",{children:t==="test"?"You're in test mode":"You're live"}),e.jsx("span",{children:t==="test"?"Use test cards to try the whole flow. No real money moves until you switch to live — and live needs Stripe to verify your business first (legal entity, bank account, sometimes tax info), which can take a day or two.":"Real cards are charged now. Every sale moves real money to your account."})]}),e.jsxs("div",{className:"su-seg",children:[e.jsx("button",{type:"button",className:t==="test"?"on":"",onClick:()=>s("test"),children:"Test"}),e.jsx("button",{type:"button",className:"live"+(t==="live"?" on":""),onClick:()=>s("live"),children:"Live"})]})]})}function jd({app:t,account:s,onComplete:n}){const r=[{title:`A "Get ${t.purchaseNoun}s" button`,caption:`Added to each ${t.entitySingular} so people can buy in one tap.`,where:`/${t.entitySingular}`},{title:"A checkout screen",caption:"Card payment, Apple Pay, and Google Pay, hosted by Stripe.",where:"/checkout"},{title:`An emailed receipt & ${t.purchaseNoun}`,caption:`Stripe sends the card payment receipt automatically; CodeYam adds your own branded confirmation with the ${t.purchaseNoun} (this is the Sending-emails topic, not Stripe).`,where:"email"},{title:"A simple sales view",caption:"See what sold and refund with one click, in your dashboard.",where:"/sales"}];return e.jsxs("div",{className:"su-wrap",children:[e.jsxs("div",{className:"su-shead",children:[e.jsx("div",{className:"su-badge",children:e.jsx(Pt,{size:25})}),e.jsxs("div",{children:[e.jsx("h1",{className:"su-title",children:"Accept payments"}),e.jsxs("div",{className:"su-via",children:["powered by ",e.jsx("b",{children:"Stripe"})," · the payments tech behind millions of apps"]}),e.jsxs("p",{className:"su-lead",children:["Let people pay inside your app — buy a ",t.purchaseNoun,", leave a tip, subscribe. CodeYam handles the wiring; you just describe what you're selling and preview every screen before it goes live."]})]})]}),e.jsx(vd,{}),e.jsxs(tr,{children:[e.jsx(ct,{state:"done",num:1,title:"Connect your Stripe account",pill:"Connected",desc:"CodeYam never sees your customers' card numbers — Stripe handles that part.",children:e.jsx(to,{monogram:s.monogram,name:s.name,detail:s.detail})}),e.jsx(ct,{state:"done",num:2,title:"What are you selling?",desc:"Plain language is fine — this is what shapes the screens below.",children:e.jsxs(sr,{children:[t.entitySingular," ",t.purchaseNoun,"s, one-off purchases from"," ",e.jsx("b",{children:"$10 to $45"}),". Buyers get a ",t.purchaseNoun," by email."]})}),e.jsx(ct,{state:"todo",num:3,title:"What CodeYam will build",desc:"Four small changes. Each becomes a plan you can preview, reorder, or drop before it ships.",children:e.jsx(nr,{items:r})})]}),e.jsxs(rr,{accent:"amber",icon:e.jsx(Ce,{size:17}),children:[e.jsx("b",{children:"Nothing charges a real card yet."})," These four changes build in test mode so you can click through the whole purchase. When it feels right, switch to live and your store is open."]}),e.jsx(ar,{label:"Plan these 4 changes",note:e.jsxs(e.Fragment,{children:["They'll land in your ",e.jsx("b",{children:"Plan"})," tab, ready to build after your current session, and previewable before anything ships."]}),onPlan:n})]})}function wd({onBack:t,onComplete:s,app:n=Zn,initialConnected:r=!1,account:a=Rj,connector:o}){const[i,c]=l.useState(r);let d;return o&&i?d=e.jsx(ro,{config:Mj(n),provider:o.provider,onBack:()=>c(!1),onComplete:s}):i?d=e.jsx(jd,{app:n,account:a,onComplete:s}):d=e.jsx(er,{config:Ej(n),onConnect:()=>c(!0)}),e.jsxs("div",{className:"setup-screen accent-indigo",children:[e.jsxs("div",{className:"su-crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:t,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:t,children:"Setup"}),e.jsx("span",{className:"sep",children:"/"}),e.jsx("b",{children:"Payments"})]}),e.jsx(Us,{topic:"payments"}),d]})}const y5=Object.freeze(Object.defineProperty({__proto__:null,ModeBar:vd,PaymentsConnected:jd,PaymentsScreen:wd},Symbol.toStringTag,{value:"Module"}));function Le({config:t,onBack:s,onComplete:n}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(t.Icon,{size:26}),title:t.title,crumbLabel:t.crumbLabel,meta:t.meta,onBack:s,assistKey:t.key}),t.leads.map(r=>e.jsx("p",{className:"lead"+(r.dim?" dim":""),children:r.text},r.text)),t.sections.map(r=>e.jsxs("div",{children:[e.jsx("div",{className:"seclabel",children:r.heading}),r.body?e.jsx("p",{className:"lead dim",children:r.body}):null,r.bullets?e.jsx("div",{className:"reasons",children:r.bullets.map(a=>e.jsxs("div",{className:"reason",children:[e.jsx(Te,{}),e.jsxs("span",{children:[a.lead?e.jsxs("b",{children:[a.lead," "]}):null,a.text]})]},a.text))}):null]},r.heading)),t.options&&t.options.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"seclabel",children:t.optionsLabel??"Your options"}),t.options.map(r=>e.jsx(Qa,{provider:r},r.name))]}):null,e.jsx(De,{items:t.faq}),e.jsx(de,{assistKey:t.key,topicName:t.title}),e.jsx(he,{label:t.doneLabel,note:t.doneNote??"You can revisit this anytime.",onComplete:()=>{n==null||n(),s()}})]})}const v5=Object.freeze(Object.defineProperty({__proto__:null,TeachSetupScreen:Le},Symbol.toStringTag,{value:"Module"})),Ij={key:"analytics-monitoring",Icon:jt,title:"Analytics & monitoring",crumbLabel:"Analytics",meta:"Recommended · about 10 minutes",leads:[{text:"Two different questions, two different tools. Analytics tells you what people do in your app — which pages they visit, where they drop off. Monitoring tells you when something breaks — the errors real users hit before they email you."},{text:"You don't need both on day one, but adding them early means you're never flying blind once people show up.",dim:!0}],sections:[{heading:"Analytics — understand usage",bullets:[{lead:"See what's used.",text:"Which features people actually open, and which they ignore."},{lead:"Find drop-off.",text:"Where people get stuck or leave, so you know what to fix."},{lead:"Privacy-first options exist.",text:"Lightweight analytics can skip cookies entirely and respect visitors."}]},{heading:"Monitoring — catch errors early",bullets:[{lead:"Know before they tell you.",text:"Get alerted when real users hit an error, with the details to fix it."},{lead:"See the full picture.",text:"What the user did, on what device, and the exact line that failed."}]}],optionsLabel:"Popular tools",options:[{initial:"P",color:"linear-gradient(140deg,#1d4ed8,#1e3a8a)",name:"PostHog",bestFit:!0,description:"Product analytics, session replay, and feature flags in one free-to-start tool. A great all-rounder for understanding usage.",reasons:[{lead:"Generous free tier.",rest:"Plenty for a new app's traffic."},{lead:"More than page views.",rest:"Funnels, replays, and flags when you're ready."},{lead:"Session replay is metered.",rest:"Its free quota of recordings is modest — fine for spot-checking, but it's billed past the cap, so leave always-on replay off until you need it."}],chips:["Analytics","Free tier","Privacy options"]},{initial:"S",color:"linear-gradient(140deg,#362d59,#1b1633)",name:"Sentry",description:"The standard for error monitoring. Catches exceptions with the context to reproduce and fix them fast.",reasons:[{lead:"Real-user errors.",rest:"See failures as they happen in production."},{lead:"Free to start.",rest:"A free tier that covers early traffic."}],chips:["Monitoring","Free tier","Alerts"]}],faq:[{q:"Do I need analytics AND monitoring?",a:"They answer different questions. Analytics is about behavior (what people do); monitoring is about health (what's breaking). Many apps add a lightweight analytics tool first, then error monitoring as traffic grows."},{q:"Will this slow my app down or hurt privacy?",a:"Modern tools are tiny and load in the background. Privacy-first analytics options avoid cookies and personal data entirely — a good default if you'd rather not show a consent banner."}],doneLabel:"Mark analytics & monitoring as set up"};function _d({onBack:t,onComplete:s}){return e.jsx(Le,{config:Ij,onBack:t,onComplete:s})}const j5=Object.freeze(Object.defineProperty({__proto__:null,AnalyticsMonitoringScreen:_d},Symbol.toStringTag,{value:"Module"})),Dj={key:"legal",Icon:Ie,title:"Privacy & legal",crumbLabel:"Legal",meta:"Recommended · about 20 minutes",leads:[{text:"Once real people use your app, a little legal groundwork protects both them and you. The good news: for most apps it's two short documents and a couple of small habits — not a lawyer on retainer."},{text:"This is guidance, not legal advice. If you handle sensitive data or money at scale, it's worth a professional review.",dim:!0}],sections:[{heading:"The two documents most apps need",bullets:[{lead:"Privacy policy —",text:"what information you collect, why, and what you do with it. Required the moment you collect emails or use analytics."},{lead:"Terms of service —",text:"the rules for using your app: what's allowed, what you promise, and what you don't. It sets expectations and limits your liability."}]},{heading:"Good habits that matter",bullets:[{lead:"Collect only what you need.",text:"Less data means less risk and a simpler policy."},{lead:"Say it in plain language.",text:"A clear, honest policy beats dense legalese for trust and compliance."},{lead:"Add a cookie/consent notice",text:"if you use analytics or tracking, especially for visitors in the EU. You can often skip the banner entirely by picking a cookieless analytics tool — see Analytics & monitoring."},{lead:"Honor data requests.",text:"Under GDPR and CCPA, people can ask to see, export, or delete the data you hold on them. Keep a simple way to remove an account and its data — this is where Accounts, Payments, and your database meet."}]},{heading:"Getting the documents",body:"You don't have to write these from scratch. Generators produce a solid starting policy from a short questionnaire — but check what's actually free. GetTerms and privacypolicies.com have genuinely free basic tiers; Termly and iubenda are freemium and gate some clauses (or removal of their attribution) behind a paid plan. Paste the result into a /privacy and /terms page and link them in your footer."}],faq:[{q:"Do I really need this for a small app?",a:"If you collect any personal data — even just email sign-ups or analytics — a privacy policy is expected and often legally required. Terms are optional but strongly recommended once people rely on your app."},{q:"Where do the pages go?",a:"Add two simple pages, usually /privacy and /terms, and link them from your footer and your sign-up screen. They don't need fancy design — clarity is what counts."}],doneLabel:"Mark privacy & legal as handled"};function kd({onBack:t,onComplete:s}){return e.jsx(Le,{config:Dj,onBack:t,onComplete:s})}const w5=Object.freeze(Object.defineProperty({__proto__:null,LegalScreen:kd},Symbol.toStringTag,{value:"Module"}));function Sd({config:t,onBack:s,onSetup:n}){return e.jsxs(e.Fragment,{children:[e.jsx(ae,{icon:e.jsx(t.Icon,{size:26}),title:t.title,crumbLabel:t.crumbLabel,meta:t.meta,onBack:s,assistKey:t.key}),t.leads.map(r=>e.jsx("p",{className:"lead"+(r.dim?" dim":""),children:r.text},r.text)),e.jsx("div",{className:"seclabel",children:t.recommendLabel}),e.jsx(Qa,{provider:t.recommended}),e.jsx(nd,{alts:t.alternatives}),e.jsxs("div",{className:"cta-wrap",children:[e.jsx("button",{type:"button",className:"cta",onClick:n,children:t.ctaLabel}),e.jsx("div",{className:"cta-note",children:t.ctaNote})]}),e.jsx(De,{items:t.faq}),e.jsx(de,{assistKey:t.key,topicName:t.title})]})}const _5=Object.freeze(Object.defineProperty({__proto__:null,SimulatedSetupOverview:Sd},Symbol.toStringTag,{value:"Module"})),wi=1100,Lj=700;function ao(t){return[{key:"connect",label:t.flowLabels[0]},{key:"provision",label:t.flowLabels[1]},{key:"ready",label:t.flowLabels[2]}]}function Nd({config:t,onBack:s,onContinue:n}){return e.jsxs(e.Fragment,{children:[e.jsx(Tt,{topic:t.crumbLabel??t.title,step:t.flowLabels[0],onBack:s}),e.jsx(gt,{steps:ao(t),currentKey:"connect"}),e.jsxs("div",{className:"panel",children:[e.jsx("div",{className:"ph",children:t.connect.heading}),e.jsx("div",{className:"psub",children:t.connect.sub}),e.jsxs("div",{className:"connect-box",children:[e.jsxs("div",{className:"cbtitle",children:[e.jsx(Qn,{initial:t.recommended.initial,color:t.recommended.color}),e.jsxs("div",{children:[e.jsxs("div",{className:"cbt",children:["Sign in with ",t.recommended.name]}),e.jsxs("div",{className:"cbd",children:["We'll open ",t.recommended.name," in a new tab and bring you right back."]})]})]}),e.jsx("div",{className:"grant",children:t.connect.grants.map(r=>e.jsxs("div",{className:"grantrow",children:[e.jsx(Te,{color:"var(--blue-300)"}),e.jsx("span",{children:r})]},r))}),e.jsx("button",{type:"button",className:"auth-btn",onClick:n,children:t.connect.continueLabel}),e.jsxs("div",{className:"auth-row",children:[e.jsx("button",{type:"button",className:"auth-ghost",onClick:n,children:"I already have an account"}),e.jsx("button",{type:"button",className:"auth-ghost",onClick:n,children:"Create one for me"})]})]}),e.jsxs("div",{className:"reassure",children:["🔒 ",t.connect.reassure]})]})]})}function Cd({config:t,onDone:s}){const n=t.provisionSteps,[r,a]=l.useState(0),o=l.useRef(s);o.current=s,l.useEffect(()=>{const c=[];for(let d=1;d<=n.length;d++)c.push(setTimeout(()=>a(d),d*wi));return c.push(setTimeout(()=>o.current(),n.length*wi+Lj)),()=>c.forEach(clearTimeout)},[n.length]);const i=Math.round(r/n.length*100);return e.jsxs(e.Fragment,{children:[e.jsx(Tt,{topic:t.crumbLabel??t.title,step:t.flowLabels[1]}),e.jsx(gt,{steps:ao(t),currentKey:"provision"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"deploy-head",children:[e.jsx("div",{className:"deploy-spin"}),e.jsxs("div",{children:[e.jsx("div",{className:"deploy-t",children:t.provisionTitle}),e.jsx("div",{className:"deploy-d",children:t.provisionDesc})]})]}),e.jsx("div",{className:"dep-bar",children:e.jsx("div",{style:{width:i+"%"}})}),e.jsx("div",{className:"dep-steps",children:n.map((c,d)=>e.jsxs("div",{className:"dep-step "+(d<r?"done":d===r?"active":"todo"),children:[e.jsx("div",{className:"dot",children:d<r?e.jsx(Te,{size:12,color:"#0a0a0a"}):null}),e.jsx("div",{className:"sl",children:c})]},c))})]})]})}function Td({config:t,onFinish:s}){return e.jsxs(e.Fragment,{children:[e.jsx(Tt,{topic:t.crumbLabel??t.title,step:t.flowLabels[2]}),e.jsx(gt,{steps:ao(t),currentKey:"ready"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"live-hero",children:[e.jsx("div",{className:"lh-em",children:"🎉"}),e.jsx("div",{className:"lh-t",children:t.ready.title}),e.jsx("div",{className:"lh-d",children:t.ready.desc})]}),e.jsxs("div",{className:"url-card",children:[e.jsx("span",{className:"ucglobe",children:"✅"}),e.jsxs("div",{children:[e.jsx("div",{className:"uc-l",children:t.ready.resultLabel}),e.jsx("div",{className:"uc-u",children:t.ready.resultValue})]})]}),e.jsxs("div",{className:"live-foot",children:[e.jsxs("span",{className:"done-pill",children:[e.jsx(Te,{})," ",t.ready.donePill]}),e.jsx("button",{type:"button",className:"lf-back",onClick:s,children:"Back to Setup"})]})]})]})}const k5=Object.freeze(Object.defineProperty({__proto__:null,SimulatedConnect:Nd,SimulatedProvision:Cd,SimulatedReady:Td},Symbol.toStringTag,{value:"Module"}));function Vs({config:t,onBack:s,onComplete:n}){const[r,a]=l.useState("overview");let o;return r==="overview"?o=e.jsx(Sd,{config:t,onBack:s,onSetup:()=>a("connect")}):t.connector?o=e.jsx(ro,{config:t,provider:t.connector.provider,onBack:()=>a("overview"),onComplete:()=>{n==null||n(),s()}}):r==="connect"?o=e.jsx(Nd,{config:t,onBack:()=>a("overview"),onContinue:()=>a("provision")}):r==="provision"?o=e.jsx(Cd,{config:t,onDone:()=>a("ready")}):o=e.jsx(Td,{config:t,onFinish:()=>{n==null||n(),s()}}),e.jsx("div",{className:"hosting-screen",children:o})}const S5=Object.freeze(Object.defineProperty({__proto__:null,SimulatedSetupScreen:Vs},Symbol.toStringTag,{value:"Module"})),Fj={key:"publish",Icon:Ws,title:"Publish the site",crumbLabel:"Publish",meta:"Foundation · about 10 minutes",leads:[{text:"Your site is a set of files that, right now, live on your computer. Publishing builds those files and copies them to the internet, so anyone with the link can open your pages."},{text:"Static sites are perfect for this — there's no server to run, just files served fast from everywhere. Hosting them is usually free.",dim:!0}],recommendLabel:"Recommended for your site",recommended:{initial:"C",color:"linear-gradient(140deg,#f6821f,#c25e0a)",name:"Cloudflare Pages",bestFit:!0,description:"Built for static sites: connect once, and every change you push is built and published automatically. Free with no bandwidth ceiling.",reasons:[{lead:"Free, with no traffic ceiling.",rest:`${re("cloudflarePages.free").value}, so a sudden traffic spike won't cost you.`},{lead:"Auto-publish on every change.",rest:"Push an update and it rebuilds and goes live on its own."},{lead:"Fast everywhere.",rest:"Your pages are served from Cloudflare's global network, close to your visitors."}],chips:["Free tier","Unlimited bandwidth","Global CDN"]},alternatives:[{initial:"N",color:"linear-gradient(140deg,#16a3a3,#0d6e6e)",name:"Netlify",description:`Also built for static sites with automatic publishing. ${re("netlify.free").value} — plenty for a personal or small site.`},{initial:"V",color:"linear-gradient(140deg,#0a0a0a,#000)",name:"Vercel",description:"Also free and excellent for static sites, especially if you later add dynamic pages. Very similar to set up."},{initial:"G",color:"linear-gradient(140deg,#24292f,#0d1117)",name:"GitHub Pages",description:"Free hosting straight from a GitHub repo. Great if your code already lives there and your needs are simple — but it has no built-in form handling and a stricter build environment."}],ctaLabel:"☁️ Publish with Cloudflare Pages",ctaNote:"We'll publish this site only. Nothing goes live until the build finishes.",faq:[{q:'What does "building" the site mean?',a:"Building turns your source files into the finished pages a browser shows — combining templates, optimizing images, and bundling styles. The host does this for you each time you publish."},{q:"Do I have to republish every time I change something?",a:"No. Once connected, the host watches for changes and republishes automatically. You make an edit, and a minute later it's live."},{q:"Is it really free?",a:`For a typical static site, yes. Cloudflare Pages: ${re("cloudflarePages.free").value.toLowerCase()}, so traffic spikes won't cost you. Netlify's free tier: ${re("netlify.free").value.toLowerCase()}. You'd only pay if you needed advanced features.`}],flowLabels:["Connect","Build","Live"],connect:{heading:"🔗 Connect your Cloudflare account",sub:"This free account hosts your live site. You'll create it in a few clicks if you don't have one.",grants:["Publish this one site","Rebuild it when you make changes","Nothing else — your other sites stay untouched"],continueLabel:"Continue with Cloudflare",reassure:"We only publish this site. You can unpublish or disconnect anytime."},provisionTitle:"Building and publishing…",provisionDesc:"This usually takes under a minute. You can keep working — we'll let you know.",provisionSteps:["Building your pages","Optimizing images and styles","Uploading to the network","Giving it a web address"],ready:{title:"Your site is live",desc:"Anyone with this link can open your site right now.",resultLabel:"Your link",resultValue:"your-site.pages.dev",donePill:"Publishing is now set up"}};function Pd({onBack:t,onComplete:s}){return e.jsx(Vs,{config:Fj,onBack:t,onComplete:s})}const N5=Object.freeze(Object.defineProperty({__proto__:null,PublishScreen:Pd},Symbol.toStringTag,{value:"Module"})),zj={key:"custom-domain",Icon:Gs,title:"Custom domain",crumbLabel:"Domain",meta:"Optional · about 15 minutes",leads:[{text:"Right now your site lives at a free address like your-site.netlify.app. A custom domain swaps that for your own — yourname.com — which looks more professional and is easier to remember."},{text:"You buy a domain once a year, then point it at your site. We'll handle the technical part (DNS) and turn on the padlock (HTTPS) for you.",dim:!0}],recommendLabel:"Recommended registrar",recommended:{initial:"C",color:"linear-gradient(140deg,#f6821f,#c25e0a)",name:"Cloudflare Registrar",bestFit:!0,description:"Buy your domain at cost with no markup, with DNS that's fast and easy to point at your site.",reasons:[{lead:"At-cost pricing.",rest:"No upsells or inflated renewal fees — you pay what the domain costs."},{lead:"Easy to point at your site.",rest:"A couple of records and your domain shows your pages."},{lead:"Free HTTPS.",rest:"The padlock that tells visitors your site is secure, set up for you."}],chips:["At-cost","Free HTTPS","~15 min to set up"]},alternatives:[{initial:"N",color:"linear-gradient(140deg,#1a1a1a,#000)",name:"Namecheap",description:"A popular, affordable registrar with a friendly dashboard. A solid alternative if you prefer it."},{initial:"P",color:"linear-gradient(140deg,#00a98f,#007a68)",name:"Porkbun",description:"Low prices and free extras like WHOIS privacy. Great value for a personal site."}],ctaLabel:"🌐 Set up a custom domain",ctaNote:"We'll guide you through buying and connecting your domain.",faq:[{q:"What is DNS?",a:`DNS is the internet's address book. It maps your domain name (yourname.com) to where your site actually lives. "Pointing" your domain means adding a couple of records so the address book sends visitors to your pages. You'll usually set up both the root (yourname.com, via an A or ALIAS record) and the www version (www.yourname.com, via a CNAME) — most registrars cover both in a couple of clicks.`},{q:"What is HTTPS / the padlock?",a:"HTTPS encrypts the connection between your visitors and your site, and shows a padlock in the browser. It's expected today, and your host turns it on automatically once your domain is connected."},{q:"How much does a domain cost?",a:"Most common domains run roughly $10–15 per year. You renew yearly to keep it. Some endings (.io, .ai) cost more; a plain .com is usually the safe, affordable pick."}],flowLabels:["Choose","Connect","Live"],connect:{heading:"🔗 Point your domain at your site",sub:"We'll add the DNS records that connect your new domain to your published site, then turn on HTTPS.",grants:["Add records that point this domain at your site","Request a free HTTPS certificate","Nothing else — we won't change your other domains"],continueLabel:"Connect my domain",reassure:"You own the domain. We only add the records needed to show your site."},provisionTitle:"Connecting your domain…",provisionDesc:"DNS can take a few minutes to spread, but usually it's quick. We'll let you know.",provisionSteps:["Adding your DNS records","Waiting for them to take effect","Issuing your HTTPS certificate","Pointing the domain at your site"],ready:{title:"Your domain is live",desc:"Your site now opens at your own secure web address.",resultLabel:"Your address",resultValue:"https://your-name.com",donePill:"Custom domain is now set up"}};function Od({onBack:t,onComplete:s}){return e.jsx(Vs,{config:zj,onBack:t,onComplete:s})}const C5=Object.freeze(Object.defineProperty({__proto__:null,CustomDomainScreen:Od},Symbol.toStringTag,{value:"Module"})),$j={key:"data-safety",Icon:Yt,title:"Data backups & deletion",crumbLabel:"Data safety",meta:"Recommended · about 15 minutes",leads:[{text:"Once real people trust your app with their data, two responsibilities follow: keep it safe so a bad day doesn't lose it, and give people control over it. Both are small, one-time habits — not a second job."},{text:"This is guidance, not legal advice. If you handle sensitive data or operate at scale, a professional review is worth it.",dim:!0}],sections:[{heading:"Back up your data",bullets:[{lead:"Turn on automated backups.",text:"Most managed databases take daily snapshots on paid tiers — switch them on and confirm the retention window. A backup you've never restored is a guess, so test a restore once."},{lead:"Mind the free tier.",text:"Free database tiers often pause or expire after inactivity and may not back up at all. If real users depend on the data, that's the signal to move to a paid plan."},{lead:"Keep a copy you control.",text:"An occasional export you store yourself protects you even if the provider's account or project goes away."}]},{heading:"Honor delete & export requests",body:"Under GDPR and CCPA, people can ask to see, export, or permanently delete the data you hold on them — and you're expected to be able to do it. This is where Accounts, Payments, and your database meet.",bullets:[{lead:"Make deletion possible.",text:"Have one reliable way to remove an account and the records tied to it — orders, profile, analytics identifiers. Remember backups and third-party tools (email, payments) hold copies too."},{lead:"Make export easy.",text:"Be able to hand someone a copy of their data in a common format. A simple admin action or even a manual query is enough to start."},{lead:"Write down your retention.",text:"Decide how long you keep data and say so in your privacy policy — see Privacy & legal."}]}],faq:[{q:"Isn't my database already backed up?",a:"Don't assume so. Paid tiers usually offer daily snapshots but they're often off by default; free tiers frequently have none and can pause. Check the dashboard and turn backups on explicitly."},{q:"Do small apps really get deletion requests?",a:"It only takes one. The obligation applies the moment you store personal data, so it's far easier to build a simple delete-and-export path early than to scramble when the first request arrives."}],doneLabel:"Mark data backups & deletion as handled"};function Ad({onBack:t,onComplete:s}){return e.jsx(Le,{config:$j,onBack:t,onComplete:s})}const T5=Object.freeze(Object.defineProperty({__proto__:null,DataSafetyScreen:Ad},Symbol.toStringTag,{value:"Module"})),Bj={key:"forms",Icon:qs,title:"Contact & forms",crumbLabel:"Forms",meta:"Optional · about 10 minutes",leads:[{text:"A static site has no server to receive a contact form, so the form needs somewhere to send messages. A form service catches submissions and emails them to you — no backend required."},{text:"You keep your simple, fast static site and still hear from visitors. Most services are free for the volume a small site sees.",dim:!0}],recommendLabel:"Recommended for your site",recommended:{initial:"F",color:"linear-gradient(140deg,#e5422b,#b02f1d)",name:"Formspree",bestFit:!0,description:"Point your form at a Formspree address and submissions arrive in your inbox. The simplest way to add a contact form.",reasons:[{lead:"No backend to build.",rest:"Your existing HTML form just works — only the destination changes."},{lead:"Spam filtering included.",rest:"Built-in protection so you're not flooded with junk."},{lead:"Free to start.",rest:"A monthly free allowance that suits a small site."}],chips:["Free tier","No backend","Spam protection"]},alternatives:[{initial:"N",color:"linear-gradient(140deg,#16a3a3,#0d6e6e)",name:"Netlify Forms",description:`Built in if you publish with Netlify — add one attribute to your form and you're done. Great if you're already there, though its free tier caps submissions at ${re("netlifyForms.free").value}.`},{initial:"W",color:"linear-gradient(140deg,#7c3aed,#5b21b6)",name:"Web3Forms",description:"A fully free, no-account form endpoint — paste an access key and submissions email straight to you. Good when you want zero cost and no dashboard."},{initial:"B",color:"linear-gradient(140deg,#3b82f6,#1d4ed8)",name:"Basin",description:"A privacy-friendly form backend with a clean dashboard. A solid alternative to Formspree."}],ctaLabel:"✉️ Set up forms with Formspree",ctaNote:"We'll connect your contact form only. Messages go straight to you.",faq:[{q:"How can a static site receive form submissions?",a:"The form posts to the service's address instead of a server you run. The service receives the message, screens it for spam, and forwards it to your email. Your site stays a set of static files."},{q:"Will I get spam?",a:"Far less than you'd fear. These services include spam filtering and a honeypot, and you can add a captcha if needed. Most junk is stopped before it reaches you."},{q:"Where do the messages go?",a:"To whatever email you choose. You can also forward them to a spreadsheet or a tool like Slack if you'd rather not use your inbox."}],flowLabels:["Connect","Verify","Ready"],connect:{heading:"🔗 Connect your Formspree account",sub:"This free account catches your form submissions. You'll create it in a few clicks if you don't have one.",grants:["Receive submissions from this site's form","Forward them to your email","Nothing else — no access to the rest of your site"],continueLabel:"Continue with Formspree",reassure:"We only connect this one form. You can disconnect it anytime."},provisionTitle:"Setting up your form…",provisionDesc:"This takes under a minute. We'll bring you right back.",provisionSteps:["Creating your form endpoint","Turning on spam protection","Pointing your contact form at it","Sending a test message"],ready:{title:"Your form is ready",desc:"Visitors can now message you, and submissions land in your inbox.",resultLabel:"Submissions go to",resultValue:"you@your-name.com",donePill:"Contact & forms are now set up"}};function Rd({onBack:t,onComplete:s}){return e.jsx(Vs,{config:Bj,onBack:t,onComplete:s})}const P5=Object.freeze(Object.defineProperty({__proto__:null,FormsScreen:Rd},Symbol.toStringTag,{value:"Module"})),Hj={key:"analytics-seo",Icon:jt,title:"Analytics & SEO",crumbLabel:"Analytics & SEO",meta:"Recommended · about 15 minutes",leads:[{text:"Two jobs that help people find and understand your site. Analytics tells you who's visiting and what they read. SEO — search engine optimization — helps your pages show up when someone searches for what you offer."},{text:"For a static site, most of this is a handful of one-time additions to your pages. Do them once and they keep working.",dim:!0}],sections:[{heading:"SEO — get found in search",bullets:[{lead:"Page titles and descriptions.",text:"Give each page a clear <title> and meta description — this is what shows in search results."},{lead:"A sitemap.",text:"A simple sitemap.xml lists your pages so search engines can find them all."},{lead:"Social cards.",text:"Open Graph tags make your links look great when shared on social media, with a title, image, and summary."},{lead:"Submit to Search Console.",text:"Tell Google your site exists and see which searches bring people in."}]},{heading:"Analytics — know your visitors",bullets:[{lead:"Count visits, respect privacy.",text:"A lightweight analytics script shows traffic without cookies or personal data."},{lead:"See what resonates.",text:"Which pages people read, where they come from, and what they ignore."}]}],optionsLabel:"Privacy-friendly analytics",options:[{initial:"C",color:"linear-gradient(140deg,#f6821f,#c25e0a)",name:"Cloudflare Web Analytics",bestFit:!0,description:"Free, cookie-free visitor analytics you can turn on without paying for a service. No consent banner, no personal data.",reasons:[{lead:"Genuinely free.",rest:"No trial clock — the core visitor analytics are free to use."},{lead:"Cookie-free.",rest:"Privacy-friendly by default, so no consent popup."}],chips:["Free","Cookie-free","No banner"]},{initial:"P",color:"linear-gradient(140deg,#5850ec,#3730a3)",name:"Plausible",description:"A tiny, cookie-free analytics script with a single clear dashboard. Paid after a free trial.",reasons:[{lead:"No cookies.",rest:"Privacy-friendly by default, so no annoying consent popup."},{lead:"Paid after a trial.",rest:"Free to try, then a monthly subscription — worth it for the polished dashboard."}],chips:["Cookie-free","Lightweight","Paid after trial"]},{initial:"F",color:"linear-gradient(140deg,#f59e0b,#b45309)",name:"Fathom",description:"Another privacy-first, fast analytics option with a clean dashboard. Paid after a free trial, like Plausible.",reasons:[{lead:"Privacy-first.",rest:"No personal data collected."},{lead:"Paid after a trial.",rest:"Free to try, then a flat monthly fee."}],chips:["Privacy-first","Fast","Paid after trial"]}],faq:[{q:"What's the single most important SEO step?",a:"Clear, unique page titles and descriptions. They're what search engines and people read first. After that, a sitemap and submitting to Google Search Console make the biggest difference."},{q:"Do I need analytics that uses cookies?",a:"No. Cookie-free tools count visits without cookies or personal data, so you get the insight without a consent banner or privacy headaches. Cloudflare Web Analytics is free; Plausible and Fathom are paid after a trial but add a more polished dashboard."}],doneLabel:"Mark analytics & SEO as set up"};function Ed({onBack:t,onComplete:s}){return e.jsx(Le,{config:Hj,onBack:t,onComplete:s})}const O5=Object.freeze(Object.defineProperty({__proto__:null,AnalyticsSeoScreen:Ed},Symbol.toStringTag,{value:"Module"})),Wj={key:"redirects-404",Icon:Gs,title:"Redirects & 404 page",crumbLabel:"Redirects & 404",meta:"Recommended · about 10 minutes",leads:[{text:"A static site serves files exactly as they're named, so a visitor who mistypes a URL or follows an old link hits a blank, unstyled error. A custom 404 page and a few redirect rules keep people on your site instead of bouncing."},{text:"These are one-time files you add to your project. Your host reads them at deploy and applies them to every request — nothing runs at request time.",dim:!0}],sections:[{heading:"A custom 404 page",bullets:[{lead:"Make the dead end friendly.",text:"Add a 404.html (Netlify, GitHub Pages) or a 404 route (most generators) with your site's header, a search box or link home, and a clear 'page not found' message."},{lead:"Match your brand.",text:"The default host error page looks broken. A styled 404 reassures visitors the site is fine — they just took a wrong turn."}]},{heading:"Redirects — don't break old links",bullets:[{lead:"Keep old URLs working.",text:"When you rename or move a page, add a redirect from the old path to the new one so bookmarks and search results still land somewhere useful."},{lead:"One rules file.",text:"A _redirects file (Netlify/Cloudflare Pages) or a netlify.toml / vercel.json block lists each from → to rule. A permanent move uses a 301 so search engines update."}]},{heading:"Trailing slashes & headers",bullets:[{lead:"Pick one URL shape.",text:"Decide whether pages live at /about or /about/ and redirect the other form to it — serving both splits your SEO and confuses analytics."},{lead:"Custom headers (optional).",text:"A _headers file lets you set caching and security headers per path without a server — useful once the basics are in place."}]}],faq:[{q:"Why doesn't my custom 404 show up?",a:"Each host has its own convention for the not-found file — a 404.html at the site root for GitHub Pages and Netlify, a 404 page/route for most generators. If yours isn't appearing, check your host's docs for the exact filename and location it expects."},{q:"When should a redirect be permanent (301) vs temporary (302)?",a:"Use a permanent 301 when a page has truly moved for good — search engines then transfer the old page's ranking to the new URL. Use a temporary 302 for short-lived redirects, like pointing to a promo page for a week."},{q:"Do I have to choose trailing slash or no trailing slash?",a:"It's worth deciding once. Serving the same page at both /about and /about/ means search engines may treat them as duplicates. Pick one and redirect the other — your generator usually has a single setting for this."}],doneLabel:"Mark redirects & 404 as set up"};function Md({onBack:t,onComplete:s}){return e.jsx(Le,{config:Wj,onBack:t,onComplete:s})}const A5=Object.freeze(Object.defineProperty({__proto__:null,RedirectsNotFoundScreen:Md},Symbol.toStringTag,{value:"Module"})),qj={key:"performance-images",Icon:Ze,title:"Performance & images",crumbLabel:"Performance",meta:"Recommended · about 15 minutes",leads:[{text:"A static site is already fast to serve, so its speed comes down to weight — and images are almost always the heaviest thing on the page. Get images right and most performance worries disappear."},{text:"Most of this is set up once: a build step that optimizes images and a host that caches them. After that every new page benefits automatically.",dim:!0}],sections:[{heading:"Images — the biggest win",bullets:[{lead:"Use modern formats.",text:"Serve WebP or AVIF instead of JPEG/PNG — often half the size at the same quality. Most generators have an image component or plugin that does this at build time."},{lead:"Size them to fit.",text:"Don't ship a 4000px photo into a 600px slot. Generate a few sizes and let the browser pick with srcset, so phones download a small version."},{lead:"Lazy-load below the fold.",text:`Add loading="lazy" to images that aren't visible on first paint so the page becomes interactive before they all download.`}]},{heading:"Caching & delivery",bullets:[{lead:"Let the CDN do the work.",text:"Static hosts like Netlify, Vercel, and Cloudflare Pages serve your files from a global edge network, so visitors download from a server near them."},{lead:"Cache static assets hard.",text:"Fingerprinted files (style.abc123.css) can be cached for a year — set long cache headers so repeat visits load instantly. Your generator usually fingerprints automatically."}]},{heading:"Check your work",bullets:[{lead:"Measure, don't guess.",text:"Run Lighthouse (built into Chrome DevTools) or PageSpeed Insights to see your real numbers and the few changes that would help most."}]}],faq:[{q:"What's the single biggest speed win for a static site?",a:"Optimizing images — converting to WebP/AVIF, sizing them for where they're shown, and lazy-loading the ones below the fold. Images are usually the heaviest part of a page, so this moves the needle more than anything else."},{q:"Do I need a separate CDN?",a:"Usually not. The major static hosts — Netlify, Vercel, Cloudflare Pages, GitHub Pages — already serve your site from a global edge network. A separate CDN only helps if you're hosting the files yourself on a single server."},{q:"How do I know if my site is fast enough?",a:"Run Lighthouse in Chrome DevTools or paste your URL into PageSpeed Insights. Both give you a score plus a prioritized list of fixes. Aim for the green range; chasing a perfect 100 rarely matters for visitors."}],doneLabel:"Mark performance & images as set up"};function Id({onBack:t,onComplete:s}){return e.jsx(Le,{config:qj,onBack:t,onComplete:s})}const R5=Object.freeze(Object.defineProperty({__proto__:null,PerformanceImagesScreen:Id},Symbol.toStringTag,{value:"Module"})),Gj={key:"comments-search",Icon:Ie,title:"Comments & search",crumbLabel:"Comments & search",meta:"Optional · about 15 minutes",leads:[{text:"A static site has no server, but it can still feel interactive. A comments widget lets readers reply without you running anything, and a client-side search index lets them find pages instantly — both work as a drop-in script."},{text:"Neither needs a backend or a database. The comments live in a third-party service or your GitHub Discussions; the search index is built from your pages at deploy time.",dim:!0}],sections:[{heading:"Comments without a backend",bullets:[{lead:"A widget does the work.",text:"Drop a small script into your post template. The service stores and renders the thread; your page just hosts it."},{lead:"Decide who can post.",text:"GitHub-based options (Giscus, Utterances) ask readers to sign in with GitHub — great for a dev audience, less so for a general one. Hosted services accept anyone."}]},{heading:"Search across your pages",bullets:[{lead:"Build the index at deploy.",text:"A tool like Pagefind crawls your built HTML and produces a small static index. The search box loads it in the browser — no server query, no API."},{lead:"Keep it lightweight.",text:"Client-side search only loads the slice of the index it needs, so even a large site stays fast. For a huge catalog, a hosted search service is the next step up."}]}],optionsLabel:"Comment widgets",options:[{initial:"G",color:"linear-gradient(140deg,#6e40c9,#4c2889)",name:"Giscus",bestFit:!0,description:"Comments backed by your repo's GitHub Discussions — free, open-source, no ads, and no separate account to manage. Readers sign in with GitHub.",reasons:[{lead:"No service to pay for.",rest:"The threads live in your own GitHub Discussions, so there's no subscription and nothing to host."},{lead:"Privacy-friendly.",rest:"No tracking or ads — a clean fit for a personal or project site."}],chips:["Free","Open-source","GitHub login"]},{initial:"D",color:"linear-gradient(140deg,#2e9fff,#1f6fd0)",name:"Disqus",description:"The best-known hosted comments widget. Anyone can post and it's quick to add, but the free tier shows ads and loads more script.",reasons:[{lead:"Anyone can comment.",rest:"No GitHub account needed, so it suits a general audience."},{lead:"Ads on the free tier.",rest:"Removing ads and tracking means upgrading to a paid plan."}],chips:["Hosted","Open to all","Ads on free tier"]},{initial:"U",color:"linear-gradient(140deg,#24292f,#57606a)",name:"Utterances",description:"A tiny widget that stores each thread as a GitHub Issue. Even simpler than Giscus, though Discussions (Giscus) is the more modern home for comments.",reasons:[{lead:"Featherweight.",rest:"One script, threads stored as GitHub Issues."},{lead:"GitHub login.",rest:"Readers comment with their GitHub account."}],chips:["Free","Open-source","GitHub login"]}],faq:[{q:"How can a static site have comments with no backend?",a:"The comments aren't stored on your site — a third-party widget stores and renders them. Your page embeds a small script that talks to the service (or to your GitHub Discussions). Your site stays a set of static files."},{q:"Does search really work without a server?",a:"Yes. A tool like Pagefind builds a static search index from your pages when you deploy. The search box downloads just the part of the index it needs and runs the query in the browser — no server or API call."},{q:"Should I require GitHub sign-in to comment?",a:"It depends on your audience. For a developer or project site, GitHub-based comments (Giscus, Utterances) cut spam to near zero. For a general audience, a hosted widget that lets anyone post will get more participation."}],doneLabel:"Mark comments & search as set up"};function Dd({onBack:t,onComplete:s}){return e.jsx(Le,{config:Gj,onBack:t,onComplete:s})}const E5=Object.freeze(Object.defineProperty({__proto__:null,CommentsSearchScreen:Dd},Symbol.toStringTag,{value:"Module"}));function ee({children:t}){return e.jsx("div",{className:"reasons",children:t})}function O({lead:t,children:s}){return e.jsxs("div",{className:"reason",children:[e.jsx(Te,{}),e.jsxs("span",{children:[e.jsx("b",{children:t})," ",s]})]})}function oo({spaced:t=!1,children:s}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"seclabel",style:t?{marginTop:24}:void 0,children:"Keep a changelog"}),e.jsxs(ee,{children:[e.jsxs(O,{lead:"One CHANGELOG.md, grouped by version.",children:["Follow the ",e.jsx("b",{children:"Keep a Changelog"})," convention: Added / Changed / Fixed / Removed under each release, newest first. Write it for the person deciding whether to upgrade."]}),e.jsxs(O,{lead:"Or generate it from your commits.",children:["If you write ",e.jsx("b",{children:"Conventional Commits"})," (",e.jsx("code",{children:"feat:"}),","," ",e.jsx("code",{children:"fix:"}),", ",e.jsx("code",{children:"feat!:"})," for breaking), tools like release-please or git-cliff assemble the changelog — and even the next version number — for you."]}),s]})]})}function or(){return e.jsxs("div",{className:"asknote",style:{marginTop:14},children:["Publishing to ",e.jsx("b",{children:"Firefox Add-ons (AMO)"})," or ",e.jsx("b",{children:"Edge Add-ons"})," follows an analogous path — a developer account, store assets, and a review — with its own console. The steps below are written for the Chrome Web Store.",e.jsx("br",{}),e.jsx("b",{children:"Fees differ:"})," the"," ",e.jsx("b",{children:re("chromeStore.fee").value})," registration fee is Chrome-only and one-time — Firefox AMO and Edge Add-ons charge no developer fee."]})}const M5=Object.freeze(Object.defineProperty({__proto__:null,ChangelogSection:oo,ReqItem:O,ReqList:ee,StoreAlternativesNote:or},Symbol.toStringTag,{value:"Module"})),is={crates:{kind:"crates",name:"crates.io",ecosystem:"Rust",publishCommand:"cargo publish",installCommand:"cargo add <name>",packagePage:"https://crates.io/crates/<name>"},npm:{kind:"npm",name:"npm",ecosystem:"Node.js",publishCommand:"npm publish",installCommand:"npm install <name>",packagePage:"https://www.npmjs.com/package/<name>"},pypi:{kind:"pypi",name:"PyPI",ecosystem:"Python",publishCommand:"python -m build && python -m twine upload dist/*",installCommand:"pip install <name>",packagePage:"https://pypi.org/project/<name>",note:"twine only uploads — `python -m build` has to produce the dist/ artifacts first. `uv build` then `uv publish` is the modern single-toolchain alternative."},rubygems:{kind:"rubygems",name:"RubyGems",ecosystem:"Ruby",publishCommand:"gem push <name>-<version>.gem",installCommand:"gem install <name>",packagePage:"https://rubygems.org/gems/<name>",note:"`gem build <name>.gemspec` packages the .gem first; `gem push` uploads it."},homebrew:{kind:"homebrew",name:"Homebrew",ecosystem:"macOS / Linux CLI",publishCommand:"open a formula PR to your tap (later: brew bump-formula-pr)",installCommand:"brew install <name>",packagePage:"https://formulae.brew.sh/formula/<name>",note:"Homebrew distributes binaries — it isn't a peer package registry. The initial release is a formula in your own tap repo (or a PR to homebrew-core); `brew bump-formula-pr` only bumps a formula that already exists."}},Uj=[is.crates,is.npm,is.pypi,is.rubygems,is.homebrew];function Ld(t){return is[t]}function Fd({registry:t,onBack:s,onComplete:n}){const r=t?Ld(t):null;return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Dt,{size:26}),title:"Publish to a registry",meta:"Foundation · about 20 minutes",onBack:s,assistKey:"publish-registry"}),e.jsxs("p",{className:"lead",children:["This kind of project doesn't go live at a web address — it ships to a"," ",e.jsx("b",{children:"package registry"}),", where people install it with a single command or add it as a dependency. Publishing is how your work reaches its users."]}),r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"seclabel",children:["Your registry: ",r.name," (",r.ecosystem,")"]}),e.jsxs(ee,{children:[e.jsxs(O,{lead:`Publish with \`${r.publishCommand}\`.`,children:["From a clean, committed working tree, this packages the release and uploads it to ",r.name,". Get an account and an API token first.",r.note?e.jsxs(e.Fragment,{children:[" ",r.note]}):null]}),e.jsx(O,{lead:`Users then run \`${r.installCommand}\`.`,children:"Once published, anyone can install your package with one command — no clone, no build from source."}),e.jsxs(O,{lead:"Your package gets a public page.",children:[r.name," hosts a page at"," ",e.jsx("code",{children:r.packagePage})," — the link you share so people can find, install, and trust the package."]})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Before your first publish"}),e.jsxs(ee,{children:[e.jsxs(O,{lead:"Claim the name before someone else does.",children:["The package name is first-come, first-served and is your public identity — squatting is common on crates.io and PyPI. If the bare name is taken (or to protect a brand), publish under a namespace: an npm scope (",e.jsx("code",{children:"@you/tool"}),") or an org account."]}),e.jsxs(O,{lead:"Turn on two-factor auth — registries expect it.",children:[re("registry.twoFactor").value,"."," ",e.jsx(Rt,{fact:re("registry.twoFactor")})," A token alone often isn't enough; set up 2FA before the release deadline, not during it."]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:r.publishCommand}),e.jsx("span",{className:"chip",children:"Tokened account"}),e.jsx("span",{className:"chip",children:"Public package page"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"seclabel",children:"Pick your registry"}),e.jsx(ee,{children:Uj.map(a=>e.jsxs(O,{lead:`${a.name} — ${a.ecosystem}.`,children:["Publish with ",e.jsx("code",{children:a.publishCommand}),"; users install with"," ",e.jsx("code",{children:a.installCommand}),".",a.note?e.jsxs(e.Fragment,{children:[" ",a.note]}):null]},a.kind))}),e.jsx("div",{className:"asknote",style:{marginTop:14},children:"Every registry follows the same shape: an account with an API token, one publish command, and a public package page you share. Match the registry to your toolchain."})]}),e.jsx(de,{assistKey:"publish-registry",topicName:"Publish to a registry"}),e.jsx(he,{label:"My package is published",note:"You can publish new versions anytime, but you can never re-publish a version once it's released — crates.io is yank-only (the release stays, just hidden from new resolves), and PyPI can delete a release but can never reuse that version number or filename. Get the first one right.",onComplete:()=>{n==null||n(),s()}})]})}const I5=Object.freeze(Object.defineProperty({__proto__:null,PublishRegistryScreen:Fd},Symbol.toStringTag,{value:"Module"}));function zd({onBack:t,onComplete:s}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Ie,{size:26}),title:"Versioning & changelog",meta:"About 20 minutes",onBack:t,assistKey:"versioning-changelog"}),e.jsxs("p",{className:"lead",children:["A version number is a promise. ",e.jsx("b",{children:"Semantic versioning"})," (MAJOR.MINOR.PATCH) lets people upgrade with confidence: a patch is safe, a minor adds features, a major may break them."]}),e.jsx("div",{className:"seclabel",children:"The three numbers"}),e.jsxs(ee,{children:[e.jsx(O,{lead:"PATCH (1.2.x) — bug fixes only.",children:"Nothing user-visible changes except that something broken now works. Always safe to take."}),e.jsx(O,{lead:"MINOR (1.x.0) — new, backward-compatible features.",children:"Existing usage keeps working; there's just more available."}),e.jsx(O,{lead:"MAJOR (x.0.0) — breaking changes.",children:"You removed or changed something people relied on. Bumping major is how you warn them."}),e.jsxs(O,{lead:"Before 1.0.0 (0.x) — anything may break.",children:["The most-missed rule for new tools: while you're on a"," ",e.jsx("code",{children:"0.x"})," version, semver lets a ",e.jsx("i",{children:"minor"})," bump break things. Releasing 1.0.0 is the moment you commit to the stability promise above — don't ship it until you're ready to keep it."]})]}),e.jsx(oo,{spaced:!0,children:e.jsxs(O,{lead:"Tag each release in git.",children:["A ",e.jsx("code",{children:"v1.2.0"}),' tag ties the version to the exact commit, so a report against "1.2.0" is reproducible. Make the tag the trigger: pushing it kicks off the CI release job that publishes that same version to the registry and attaches the binaries — so the git tag, the published version, and the release artifacts can never disagree.']})}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"MAJOR.MINOR.PATCH"}),e.jsx("span",{className:"chip",children:"CHANGELOG.md"}),e.jsx("span",{className:"chip",children:"git tag vX.Y.Z"})]}),e.jsx(de,{assistKey:"versioning-changelog",topicName:"Versioning & changelog"}),e.jsx(he,{label:"My versioning scheme is set",note:"Pick the scheme once; every future release just follows the same rules.",onComplete:()=>{s==null||s(),t()}})]})}const D5=Object.freeze(Object.defineProperty({__proto__:null,VersioningChangelogScreen:zd},Symbol.toStringTag,{value:"Module"}));function $d({registry:t,onBack:s,onComplete:n}){const r=t?Ld(t):null;return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Ie,{size:26}),title:"Install docs",meta:"About 30 minutes · writing time",onBack:s,assistKey:"install-docs"}),e.jsxs("p",{className:"lead",children:["Your README is the front page of the package. A new user decides whether to try it in the first few lines, so lead with the"," ",e.jsx("b",{children:"install command"})," and a tiny working example."]}),e.jsx("div",{className:"seclabel",children:"A good README opens with"}),e.jsxs(ee,{children:[e.jsx(O,{lead:r?`The install command — \`${r.installCommand}\`.`:"The exact install command.",children:"One copy-pasteable line. Don't make people guess the package name or the registry it lives on."}),e.jsxs(O,{lead:"A real first command to run.",children:["For a CLI, show an actual invocation — a quickstart like"," ",e.jsx("code",{children:"yourtool init"})," and the always-works"," ",e.jsx("code",{children:"yourtool --help"})," — not a library-style code snippet. The smallest thing that does something real; people skim, so show, don't describe."]}),e.jsx(O,{lead:"Supported platforms or versions.",children:"Which OSes, language versions, or runtimes you support, so users know before they install whether it'll work for them."}),e.jsxs(O,{lead:"Badges and a link to the package page.",children:["A version / build / license badge row at the top signals the package is current and maintained, and a link to its"," ",r?r.name:"registry"," page (",e.jsx("code",{children:r?r.packagePage:"the registry listing"}),") gives readers the canonical source."]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"Install line first"}),e.jsx("span",{className:"chip",children:"Real command, not a snippet"}),e.jsx("span",{className:"chip",children:"Badges + package link"}),e.jsx("span",{className:"chip",children:r?r.name:"Any registry"})]}),e.jsx(de,{assistKey:"install-docs",topicName:"Install docs"}),e.jsx(he,{label:"My install docs are ready",note:"Docs evolve with the project — update the README whenever the install or usage changes.",onComplete:()=>{n==null||n(),s()}})]})}const L5=Object.freeze(Object.defineProperty({__proto__:null,InstallDocsScreen:$d},Symbol.toStringTag,{value:"Module"}));function Bd({onBack:t,onComplete:s}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Ze,{size:26}),title:"Release builds",meta:"About 45 minutes · CI setup",onBack:t,assistKey:"release-builds"}),e.jsxs("p",{className:"lead",children:["Not everyone installs from a registry — many people just want a binary they can run. ",e.jsx("b",{children:"Cross-platform release builds"})," produce that binary for each operating system, so users download one file and go."]}),e.jsx("div",{className:"seclabel",children:"What to produce"}),e.jsxs(ee,{children:[e.jsx(O,{lead:"One binary per target platform.",children:"Typically macOS (Intel + Apple Silicon), Linux (x86_64 + arm64), and Windows. Build each in its own job rather than cross-compiling blindly."}),e.jsx(O,{lead:"Sign and notarize the binaries.",children:"The biggest real-world gap: an unsigned download is quarantined by macOS Gatekeeper and flagged by Windows SmartScreen, so users see a scary warning instead of your tool. Sign (and notarize on macOS) as part of the release job, or distribute via Homebrew/winget where the channel handles trust."}),e.jsxs(O,{lead:"Build on a git tag, in CI.",children:["A push of ",e.jsx("code",{children:"v1.2.0"})," triggers the release workflow, so binaries always match a real, tagged version — no laptop builds. A tool like ",e.jsx("code",{children:"cargo-dist"}),", ",e.jsx("code",{children:"goreleaser"}),", or electron-builder wires up the whole matrix-build-sign-publish flow instead of you hand-writing it."]}),e.jsxs(O,{lead:"Attach them to a GitHub Release.",children:["Upload the binaries (and their checksums) to the tagged"," ",e.jsx("b",{children:"GitHub Release"})," — the common path — so the download links live next to the changelog. A package channel (Homebrew tap, winget) is the usual alternative."]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"macOS · Linux · Windows"}),e.jsx("span",{className:"chip",children:"Signed + notarized"}),e.jsx("span",{className:"chip",children:"Tag-triggered CI"}),e.jsx("span",{className:"chip",children:"GitHub Releases"}),e.jsx("span",{className:"chip",children:"Checksums"})]}),e.jsx(de,{assistKey:"release-builds",topicName:"Release builds"}),e.jsx(he,{label:"My release builds are set up",note:"Once the workflow exists, every future tag produces binaries automatically.",onComplete:()=>{s==null||s(),t()}})]})}const F5=Object.freeze(Object.defineProperty({__proto__:null,ReleaseBuildsScreen:Bd},Symbol.toStringTag,{value:"Module"}));function Hd({onBack:t,onComplete:s}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Vn,{size:26}),title:"Shell completions",meta:"About 30 minutes · polish",onBack:t,assistKey:"shell-completions"}),e.jsx("p",{className:"lead",children:"Tab completion is the difference between a tool people tolerate and one they enjoy. Press Tab and the shell offers your subcommands and flags — no need to remember exact spellings."}),e.jsx("div",{className:"seclabel",children:"How it works"}),e.jsxs(ee,{children:[e.jsxs(O,{lead:"Generate a completion script per shell.",children:["Most CLI frameworks emit completion scripts for ",e.jsx("code",{children:"bash"}),","," ",e.jsx("code",{children:"zsh"}),", ",e.jsx("code",{children:"fish"}),", and PowerShell from your command definitions — you don't hand-write them."]}),e.jsxs(O,{lead:"Ship a `completions` subcommand.",children:["A ",e.jsx("code",{children:"yourtool completions zsh"})," command lets users (and your install docs) print the script for their shell on demand."]}),e.jsx(O,{lead:"Document where each shell loads them.",children:"Each shell reads completions from its own directory. A short table in your README saves users the lookup."}),e.jsxs(O,{lead:"Generate a man page from the same source.",children:["The sibling polish step: most CLI frameworks also emit a"," ",e.jsx("code",{children:"man"})," page from your command definitions, so"," ",e.jsx("code",{children:"man yourtool"})," works the way completions do — generated, not hand-written."]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"bash · zsh · fish"}),e.jsx("span",{className:"chip",children:"Generated, not hand-written"}),e.jsx("span",{className:"chip",children:"completions subcommand"})]}),e.jsx(de,{assistKey:"shell-completions",topicName:"Shell completions"}),e.jsx(he,{label:"My shell completions are ready",note:"Completions regenerate from your commands — they stay in sync as the CLI grows.",onComplete:()=>{s==null||s(),t()}})]})}const z5=Object.freeze(Object.defineProperty({__proto__:null,ShellCompletionsScreen:Hd},Symbol.toStringTag,{value:"Module"}));function Wd({onBack:t,onComplete:s}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Vn,{size:26}),title:"Command-line UX",meta:"About 30 minutes · the interface contract",onBack:t,assistKey:"cli-ux"}),e.jsx("p",{className:"lead",children:"A CLI's interface isn't its code — it's how it behaves at the prompt. The same four conventions show up in every tool people trust, because both a human and a shell script read your tool through them."}),e.jsx("div",{className:"seclabel",children:"The conventions every CLI follows"}),e.jsxs(ee,{children:[e.jsx(O,{lead:"`--help` and `-h` always work, on every subcommand.",children:"The first thing anyone types at an unfamiliar tool. Each subcommand gets its own help with a one-line summary, usage, and examples — not just the top-level command."}),e.jsx(O,{lead:"`--version` prints a single line and exits 0.",children:"Scripts and bug reports parse it; keep it to just the version string so it stays machine-readable."}),e.jsxs(O,{lead:"Exit codes mean something.",children:[e.jsx("code",{children:"0"})," for success, non-zero for failure — and ideally distinct codes for distinct failures. This is how"," ",e.jsx("code",{children:"cmd && next"})," and CI know whether to continue, so an error that exits 0 silently breaks every script wrapping you."]}),e.jsx(O,{lead:"Results on stdout, diagnostics on stderr.",children:`Stdout is the data a user pipes into the next command; progress, warnings, and errors go to stderr so they don't corrupt that pipe. Getting this backwards is the most common reason a tool "doesn't work in a pipeline."`})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"--help · --version"}),e.jsx("span",{className:"chip",children:"Meaningful exit codes"}),e.jsx("span",{className:"chip",children:"stdout = data, stderr = noise"})]}),e.jsx(de,{assistKey:"cli-ux",topicName:"Command-line UX"}),e.jsx(he,{label:"My command-line UX is solid",note:"Nail the contract first; shell completions and man pages are the polish on top of it.",onComplete:()=>{s==null||s(),t()}})]})}const $5=Object.freeze(Object.defineProperty({__proto__:null,CliUxScreen:Wd},Symbol.toStringTag,{value:"Module"}));function qd({onBack:t,onComplete:s}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Ce,{size:26}),title:"Security & supply chain",meta:"About 45 minutes · trust",onBack:t,assistKey:"supply-chain"}),e.jsx("p",{className:"lead",children:"The moment you publish, your code becomes a dependency in someone else's build — and your security becomes part of theirs. A few habits make what you ship trustworthy: audit what you depend on, catch known vulnerabilities before release, and sign the release so users can verify it's really yours."}),e.jsx("div",{className:"seclabel",children:"What a published artifact owes its users"}),e.jsxs(ee,{children:[e.jsxs(O,{lead:"Audit your own dependencies.",children:["Run ",e.jsx("code",{children:"cargo audit"})," (Rust) or ",e.jsx("code",{children:"npm audit"})," /"," ",e.jsx("code",{children:"pip-audit"})," in CI so a known-vulnerable transitive dependency fails the build instead of shipping. Wire it into the same workflow that runs your tests."]}),e.jsx(O,{lead:"Scan continuously, not just once.",children:"New CVEs are disclosed against dependencies you already shipped. A scanner like Dependabot or Renovate opens update PRs as advisories land, so you're patching on the advisory's clock, not discovering it from a user's bug report."}),e.jsxs(O,{lead:"Publish an SBOM.",children:["A Software Bill of Materials lists every component and version in your release. Downstream users — especially in regulated shops — scan it to decide whether your release is safe to adopt. Most toolchains generate one (",e.jsx("code",{children:"cargo sbom"}),", ",e.jsx("code",{children:"npm sbom"}),","," ",e.jsx("code",{children:"syft"}),")."]}),e.jsxs(O,{lead:"Sign your releases so they can be verified.",children:[re("supplyChain.signedReleases").value,"."," ",e.jsx(Rt,{fact:re("supplyChain.signedReleases")})," ","Pair that with published checksums (and a ",e.jsx("code",{children:"cosign"})," signature for binaries) so an install can prove it got exactly what you built."]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"audit in CI"}),e.jsx("span",{className:"chip",children:"SBOM per release"}),e.jsx("span",{className:"chip",children:"Signed & verifiable"})]}),e.jsx(de,{assistKey:"supply-chain",topicName:"Security & supply chain"}),e.jsx(he,{label:"My supply chain is covered",note:"Wire audit + signing into CI once; every future release inherits it automatically.",onComplete:()=>{s==null||s(),t()}})]})}const B5=Object.freeze(Object.defineProperty({__proto__:null,SupplyChainScreen:qd},Symbol.toStringTag,{value:"Module"}));function Gd({onBack:t,onComplete:s}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Ie,{size:26}),title:"Examples & doctests",meta:"About 40 minutes · adoption",onBack:t,assistKey:"examples"}),e.jsxs("p",{className:"lead",children:["Reference docs say what each function does; ",e.jsx("b",{children:"examples"})," show how the pieces fit together to do something real. Most people copy a working example before they ever read the API reference — it's the single biggest thing you can add to make a library easy to adopt."]}),e.jsx("div",{className:"seclabel",children:"What to ship"}),e.jsxs(ee,{children:[e.jsxs(O,{lead:"Runnable examples, not snippets in a README.",children:["Put complete programs in an ",e.jsx("code",{children:"examples/"})," directory that build and run as-is (",e.jsx("code",{children:"cargo run --example quickstart"}),"). A snippet a user has to assemble themselves is a snippet that's subtly wrong."]}),e.jsx(O,{lead:"Start with the one-minute quickstart.",children:"The first example should be the shortest path from install to a result. Show the 80% use case end to end before any advanced configuration — that's the example most people will actually run."}),e.jsxs(O,{lead:"Make the docs themselves runnable with doctests.",children:["A doctest is an example embedded in a doc comment that the test runner actually executes (",e.jsx("code",{children:"cargo test --doc"}),", Python's"," ",e.jsx("code",{children:"doctest"}),"). It means the snippet in your reference can't silently rot — if the API changes, the doctest fails CI."]}),e.jsxs(O,{lead:"Run examples and doctests in CI.",children:["An example that no longer compiles is worse than none — it tells users the library is unmaintained. Build the ",e.jsx("code",{children:"examples/"})," and run the doctests on every commit so a broken one fails the build."]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"examples/ directory"}),e.jsx("span",{className:"chip",children:"One-minute quickstart"}),e.jsx("span",{className:"chip",children:"Doctests run in CI"})]}),e.jsx(de,{assistKey:"examples",topicName:"Examples & doctests"}),e.jsx(he,{label:"My examples & doctests are ready",note:"Tie them into CI once; a broken example then fails the build instead of misleading a new user.",onComplete:()=>{s==null||s(),t()}})]})}const H5=Object.freeze(Object.defineProperty({__proto__:null,ExamplesScreen:Gd},Symbol.toStringTag,{value:"Module"}));function Ud({onBack:t,onComplete:s}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Ie,{size:26}),title:"API docs",meta:"Foundation · about 30 minutes",onBack:t,assistKey:"api-docs"}),e.jsxs("p",{className:"lead",children:["For a library, the public API ",e.jsx("i",{children:"is"})," the product — so its reference docs matter as much as the code. The trick is to"," ",e.jsx("b",{children:"generate docs from the source"}),", so they can't drift out of date."]}),e.jsx("div",{className:"seclabel",children:"Generate, don't hand-write"}),e.jsxs(ee,{children:[e.jsx(O,{lead:"Doc comments on every public item.",children:"Document each exported function, type, and field where it's defined. The generator turns those comments into the reference site."}),e.jsxs(O,{lead:"A generator for your language.",children:[e.jsx("code",{children:"docs.rs"})," for Rust, ",e.jsx("code",{children:"TypeDoc"})," for TypeScript,"," ",e.jsx("code",{children:"Sphinx"})," (or the more modern"," ",e.jsx("code",{children:"MkDocs + mkdocstrings"}),") for Python — each reads your source and produces a browsable site."]}),e.jsx(O,{lead:"Publish on every release.",children:"Many registries (docs.rs) build docs automatically on publish; for others, a CI step deploys them. Either way, the live docs track the released version."})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"docs.rs · TypeDoc · Sphinx"}),e.jsx("span",{className:"chip",children:"From doc comments"}),e.jsx("span",{className:"chip",children:"Auto-built on publish"})]}),e.jsx(de,{assistKey:"api-docs",topicName:"API docs"}),e.jsx(he,{label:"My API docs are published",note:"Because they're generated from source, the docs refresh themselves on every release.",onComplete:()=>{s==null||s(),t()}})]})}const W5=Object.freeze(Object.defineProperty({__proto__:null,ApiDocsScreen:Ud},Symbol.toStringTag,{value:"Module"})),Vj={key:"api-docs",Icon:Ie,title:"API docs",crumbLabel:"API docs",meta:"Foundation · about 8 minutes",leads:[{text:"Your service speaks HTTP, but a URL alone tells a caller nothing about which routes exist, what to send, or what comes back. API docs are that contract — one machine-readable description of every endpoint that humans can read and tools can consume."},{text:"The standard is OpenAPI (the spec format Swagger tools read). One OpenAPI document becomes browsable docs, a try-it console, and client code — all from the same source of truth.",dim:!0}],sections:[{heading:"What goes in the docs",bullets:[{lead:"Every route.",text:"The method and path (GET /orders, POST /orders/{id}/refund), what each one does, and which need authentication."},{lead:"Request & response shapes.",text:"The fields, types, and examples for what a caller sends and what they get back — including the error responses, not just the happy path."},{lead:"Auth.",text:"How a caller proves who they are — the API key header or bearer token your endpoints expect."}]},{heading:"Generate it, don't hand-maintain it",bullets:[{lead:"From your code.",text:"Most frameworks emit the OpenAPI spec from the routes you already wrote — FastAPI and NestJS produce it automatically; Express adds it with a plugin. The docs can't drift from the code because they come from the code."},{lead:"Or author it by hand.",text:"For a small or contract-first API you can write the OpenAPI YAML yourself. It's more work to keep in sync, so reserve it for when you're designing the API before building it."}]},{heading:"Serve it so people can use it",bullets:[{lead:"An interactive console.",text:"Swagger UI, Redoc, or Scalar turn the spec into a browsable page with a try-it form — a caller can hit a real endpoint without writing any code first."},{lead:"Keep it from drifting.",text:"Regenerate the spec in CI and fail the build if it changes unexpectedly, so the published docs always match the deployed API."}]}],faq:[{q:"Isn't this the same as the library 'API docs'?",a:"No. A library's API docs (docs.rs, TypeDoc, Sphinx) describe code others import into their own program. A service's API docs describe HTTP endpoints others call over the network — different audience, different format. OpenAPI/Swagger is the service one."},{q:"Swagger or OpenAPI — what's the difference?",a:"OpenAPI is the specification (the document format). Swagger is the family of tools — Swagger UI, Swagger Editor — that read and render an OpenAPI document. You write OpenAPI; you view it with Swagger UI (or Redoc, or Scalar)."},{q:"Do I have to write the spec by hand?",a:"Usually not. If your framework can emit OpenAPI from your route definitions, let it — generated docs stay in sync automatically. Hand-authoring is for contract-first designs where the spec comes before the implementation."}],doneLabel:"Mark API docs as set up",doneNote:"Generate the spec from your code where you can — auto-generated docs can't fall out of sync with the API."};function Vd({onBack:t,onComplete:s}){return e.jsx(Le,{config:Vj,onBack:t,onComplete:s})}const q5=Object.freeze(Object.defineProperty({__proto__:null,BackendApiDocsScreen:Vd},Symbol.toStringTag,{value:"Module"}));function Yd({onBack:t,onComplete:s}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Ie,{size:26}),title:"Versioning policy",meta:"About 20 minutes · a decision",onBack:t,assistKey:"semver-policy"}),e.jsxs("p",{className:"lead",children:["Other people's code depends on yours. A breaking change you ship quietly breaks their builds. A written ",e.jsx("b",{children:"versioning policy"})," is the promise that makes your library safe to depend on."]}),e.jsx("div",{className:"seclabel",children:"Decide and write down"}),e.jsxs(ee,{children:[e.jsx(O,{lead:"What counts as a breaking change.",children:"Removing or renaming a public item, changing a signature, tightening accepted input. Anything a user's code could rely on is part of the contract."}),e.jsx(O,{lead:"How you signal it.",children:"Breaking changes mean a MAJOR bump. Spell out that the public API is covered and what's explicitly *not* (internal modules, anything marked unstable)."}),e.jsx(O,{lead:"Your deprecation path.",children:"Mark an item deprecated for at least one minor release before removing it, so users get a warning and time to migrate — not a surprise."}),e.jsxs(O,{lead:"Let a tool catch breaks for you.",children:["You don't have to spot every breaking change by eye:"," ",e.jsx("code",{children:"cargo-semver-checks"})," (Rust) and"," ",e.jsx("code",{children:"api-extractor"})," (TypeScript) diff your public API against the last release and fail CI when a change needs a MAJOR bump."]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"Public API = the contract"}),e.jsx("span",{className:"chip",children:"Breaking → MAJOR"}),e.jsx("span",{className:"chip",children:"Deprecate before removing"})]}),e.jsx(de,{assistKey:"semver-policy",topicName:"Versioning policy"}),e.jsx(he,{label:"My versioning policy is set",note:"Write it in the README once; it guides every release decision afterward.",onComplete:()=>{s==null||s(),t()}})]})}const G5=Object.freeze(Object.defineProperty({__proto__:null,SemverPolicyScreen:Yd},Symbol.toStringTag,{value:"Module"}));function Kd({onBack:t,onComplete:s}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Ie,{size:26}),title:"Readme & license",meta:"About 30 minutes",onBack:t,assistKey:"readme-license"}),e.jsxs("p",{className:"lead",children:["Two files decide whether someone adopts your library: the"," ",e.jsx("b",{children:"README"})," tells them what it does, and the ",e.jsx("b",{children:"license"}),` tells them whether they're allowed to use it. Skip the license and the legal default is "all rights reserved" — nobody can.`]}),e.jsx("div",{className:"seclabel",children:"A README that earns trust"}),e.jsxs(ee,{children:[e.jsx(O,{lead:"One sentence: what it is and who it's for.",children:"The first line should let a reader decide in seconds whether to keep reading."}),e.jsx(O,{lead:"Install + a minimal example.",children:'The fastest path from "interested" to "it works on my machine".'})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Pick a license"}),e.jsxs(ee,{children:[e.jsx(O,{lead:"Permissive (MIT, Apache-2.0) — easiest to adopt.",children:"Lets people use your library in almost any project. Apache-2.0 also grants patent rights, which some companies require."}),e.jsxs(O,{lead:"Library copyleft (LGPL, MPL-2.0) — share changes, not callers.",children:["For a library, the relevant copyleft is ",e.jsx("b",{children:"LGPL"})," or"," ",e.jsx("b",{children:"MPL-2.0"}),": changes to your code stay open, but code that merely links to or imports it doesn't have to be. Full ",e.jsx("b",{children:"GPL"})," forces every consumer to be GPL too, which usually kills adoption for a library — reach for it only on purpose."]})]}),e.jsx(ee,{children:e.jsxs(O,{lead:"Declare the license in your package manifest, too.",children:["A LICENSE file alone isn't enough — set the ",e.jsx("code",{children:"license"})," field in your manifest (",e.jsx("code",{children:"Cargo.toml"}),", ",e.jsx("code",{children:"package.json"}),","," ",e.jsx("code",{children:"pyproject.toml"}),") so the registry detects and displays it on the package page."]})}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"README first line"}),e.jsx("span",{className:"chip",children:"LICENSE file + manifest field"}),e.jsx("span",{className:"chip",children:"MIT · Apache-2.0 · LGPL/MPL"})]}),e.jsx(de,{assistKey:"readme-license",topicName:"Readme & license"}),e.jsx(he,{label:"My readme & license are in place",note:"A LICENSE file is a one-time decision that unblocks everyone who wants to use your work.",onComplete:()=>{s==null||s(),t()}})]})}const U5=Object.freeze(Object.defineProperty({__proto__:null,ReadmeLicenseScreen:Kd},Symbol.toStringTag,{value:"Module"}));function Jd({onBack:t,onComplete:s}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(jt,{size:26}),title:"Changelog & CI",meta:"About 40 minutes · automation",onBack:t,assistKey:"changelog-ci"}),e.jsx("p",{className:"lead",children:"A changelog tells people what changed before they upgrade; CI makes sure every release is tested and published the same way. Together they turn releasing from a careful manual ritual into a tagged, repeatable step."}),e.jsx(oo,{}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Automate the release"}),e.jsxs(ee,{children:[e.jsx(O,{lead:"CI runs tests on every change.",children:"A green pipeline is the precondition for any release — no publishing from an untested commit."}),e.jsxs(O,{lead:"A tag triggers publish.",children:["Pushing ",e.jsx("code",{children:"v1.2.0"})," runs the release job: test, build, and publish to the registry. The version published always matches the tag."]}),e.jsxs(O,{lead:"Give CI a way to authenticate.",children:["The release job needs publish credentials. The classic path is a registry token in a CI secret (",e.jsx("code",{children:"CARGO_REGISTRY_TOKEN"}),","," ",e.jsx("code",{children:"NPM_TOKEN"}),"). The current best practice is"," ",e.jsx("b",{children:"OIDC trusted publishing"}),": ",re("registry.oidc").value,"."," ",e.jsx(Rt,{fact:re("registry.oidc")})]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"CHANGELOG.md"}),e.jsx("span",{className:"chip",children:"Tests on every push"}),e.jsx("span",{className:"chip",children:"Tag → publish"}),e.jsx("span",{className:"chip",children:"OIDC or token"})]}),e.jsx(de,{assistKey:"changelog-ci",topicName:"Changelog & CI"}),e.jsx(he,{label:"My changelog & CI are set up",note:"Once the pipeline exists, releasing is just pushing a tag — the rest runs itself.",onComplete:()=>{s==null||s(),t()}})]})}const V5=Object.freeze(Object.defineProperty({__proto__:null,ChangelogCiScreen:Jd},Symbol.toStringTag,{value:"Module"})),Yj=re("flyio.pricing"),Kj={key:"deploy-target",connector:{provider:"render"},Icon:Ws,title:"Deploy target",meta:"Foundation · about 10 minutes",leads:[{text:"Right now your service only runs on your machine. A deploy target is where it runs for real — always on, with a public endpoint other apps can call."},{text:"You don't need to manage servers. A container host runs your service the way it already works locally; we'll walk through each step.",dim:!0}],recommendLabel:"Recommended for your service",recommended:{initial:"F",color:"linear-gradient(140deg,#7c4dff,#5b2ecc)",name:"Fly.io",bestFit:!0,description:"A container host that runs your service close to your users — a good fit when low latency or running near your data matters. A simple, standard home for a long-running API.",reasons:[{lead:"Pricing.",rest:Yj.value},{lead:"Runs your container as-is.",rest:"It behaves just like it does locally — no proprietary runtime to learn."},{lead:"A public endpoint included.",rest:"Your service gets an HTTPS URL other apps can call right away."}],chips:["Edge / low-latency","Always-on","~5 min to set up"]},alternatives:[{initial:"R",color:"linear-gradient(140deg,#22c55e,#15803d)",name:"Render",description:"Beginner-friendly: connect your repo and every git push deploys. Managed Postgres lives in the same dashboard, so your DB and service sit side by side. A good first deploy if you don't need edge locality."},{initial:"R",color:"linear-gradient(140deg,#6366f1,#4338ca)",name:"Railway",description:"Also git-push to deploy with managed Postgres in-dashboard. Quick to wire up a service plus its database; usage-based pricing once you're past the starter allowance."},{initial:"S",color:"linear-gradient(140deg,#f59e0b,#b45309)",name:"Serverless",description:"Spins up per request and scales to zero. Cheapest when traffic is spiky — but a long-running, stateful service that holds database connection pools fits it poorly: each cold start reconnects, and execution limits cut off long requests."},{initial:"V",color:"linear-gradient(140deg,#16a3a3,#0d6e6e)",name:"Virtual machine",description:"A full server you control end to end. Most flexible, but you own patching, scaling, and uptime yourself."}],ctaLabel:"📦 Deploy to a container host",ctaNote:"We'll deploy this one service. Nothing else is touched.",faq:[{q:"What does deploying actually do?",a:"It packages your service into a container, runs it on an always-on host, and gives it a public endpoint. Your local copy keeps working exactly as before."},{q:"Do I need to understand servers?",a:"No. The container host handles the machines, networking, and restarts. You ship your service and get back a URL."},{q:"Can I take it down?",a:"Anytime. You can stop or delete the deployment with one action and it goes back to running only on your machine."},{q:"Will it reach my database once it's deployed?",a:"Only after you point it there. The deployed service reads DATABASE_URL from its host's secret store — set that to your managed database's connection string (see the Real data step), not the localhost URL you use on your machine."}],flowLabels:["Connect","Deploy","Go live"],connect:{heading:"🔗 Connect your container host",sub:"This account holds your running service. If you don't have one yet, you'll create it in a few clicks.",grants:["Create one app to run your service","Give it a public endpoint","Nothing else — we can't touch your other resources"],continueLabel:"Continue with Fly.io",reassure:"We only ask for what's needed to run this one service. You can disconnect anytime."},provisionTitle:"Putting your service online…",provisionDesc:"This usually takes under a minute. We'll let you know when the endpoint is live.",provisionSteps:["Building your container image","Pushing it to the host","Assigning a public endpoint","Starting the service"],ready:{title:"Your service is live",desc:"It's running on a container host and reachable at this endpoint.",resultLabel:"Service endpoint",resultValue:"your-service.onrender.com",donePill:"Deploy target is now set up"}};function Xd({onBack:t,onComplete:s}){return e.jsx(Vs,{config:Kj,onBack:t,onComplete:s})}const Y5=Object.freeze(Object.defineProperty({__proto__:null,DeployTargetScreen:Xd},Symbol.toStringTag,{value:"Module"})),Jj={key:"database-backups",Icon:Yt,title:"Backups & migrations",crumbLabel:"Backups",meta:"Foundation · about 10 minutes",leads:[{text:"Once a real database holds data people care about, two things keep it safe: backups, so a bad deploy or a dropped table is recoverable, and migrations, so changing the database's shape never loses what's already stored."},{text:"Most managed databases take automated backups for you — your job is to know how far back they reach and to practice restoring one before you need it.",dim:!0}],sections:[{heading:"Backups: the safety net",bullets:[{lead:"Automated daily backups —",text:"your host snapshots the whole database on a schedule, with no action from you."},{lead:"Point-in-time recovery —",text:"rewind the database to any moment (e.g. just before a bad migration), not just to last night's snapshot."},{lead:"Test the restore —",text:"a backup you've never restored is a guess. Restore one into a scratch database once so you know the steps work."}]},{heading:"Migrations: changing the shape safely",bullets:[{lead:"Versioned, in source control —",text:"each change to the schema is a small, ordered file checked in with your code, so every environment applies the same steps."},{lead:"Run on deploy —",text:"the migration runs as part of shipping, before the new code serves traffic, so the database and the code always match."},{lead:"Forward-only and reversible —",text:"prefer additive changes (add a column, backfill, then drop the old one) so a rollback never strands data."}]}],faq:[{q:"Doesn't my database host already back up for me?",a:"Usually yes — but the retention window varies, and free tiers often keep little or nothing. Check how many days you can recover, and whether point-in-time recovery is included or a paid add-on."},{q:"What's the difference between a backup and a migration?",a:"A backup protects the data you already have. A migration changes the structure that holds it (new tables, new columns). You need both: migrations to evolve the schema, backups in case a migration — or anything else — goes wrong."},{q:"Can I just edit the database by hand when I need a change?",a:"It works once, then bites you: other environments drift, and there's no record of what changed. A migration file makes the change repeatable and reviewable, and runs the same way everywhere."}],doneLabel:"Mark backups & migrations as set up",doneNote:"Confirm your backup retention window and run your first migration on deploy — you can revisit both anytime."};function Qd({onBack:t,onComplete:s}){return e.jsx(Le,{config:Jj,onBack:t,onComplete:s})}const K5=Object.freeze(Object.defineProperty({__proto__:null,DatabaseBackupsScreen:Qd},Symbol.toStringTag,{value:"Module"}));function Xj(){const[t,s]=l.useState(null);return l.useEffect(()=>{let n=!1;return(async()=>{try{const r=await fetch("/api/setup-env");if(!r.ok)throw new Error(`HTTP ${r.status}`);const a=await r.json();n||s(a)}catch{n||s(null)}})(),()=>{n=!0}},[]),{env:t}}const Qj={heading:"The secrets a service usually needs",bullets:[{lead:"DATABASE_URL —",text:"the connection string for your managed database."},{lead:"JWT_SECRET / API keys —",text:"the values that sign tokens and authenticate callers."},{lead:"Third-party keys —",text:"Stripe, email, or other provider credentials your service calls."}]};function Zd(t,s){const n=[...t,...s];return n.length===0?Qj:{heading:"This project's secrets",bullets:n.map(r=>({lead:`${r} —`,text:s.includes(r)?"needed by a service this project already uses; set its value in your host's secret store.":"from your .env.example; set its value in your host's secret store, never in source control."}))}}function eu(t,s){return{key:"secrets",Icon:Ce,title:"Secrets & config",crumbLabel:"Secrets",meta:"Foundation · about 5 minutes",leads:[{text:"Your service needs passwords, API keys, and connection strings to do its job — but those must never live in your code. You set them once per environment, and the host hands them to your service at runtime."},{text:"The names come from your .env.example; the real values stay in your host's secret store, never in source control.",dim:!0}],sections:[Zd(t,s),{heading:"How it works",bullets:[{lead:"One set per environment.",text:"Development, staging, and production each get their own values, so a test key can't leak into production."},{lead:"Set, don't commit.",text:"You paste each value into the host's secret store once. Rotating a key later is a one-field change, no redeploy of code."}]}],faq:[{q:"Why not just put them in a config file?",a:"A committed secret is a leaked secret — anyone with repo access (or a fork, or git history) has it forever. Secret stores keep values out of source and let you rotate without a code change."},{q:"How does my service read them?",a:"The host injects each secret as an environment variable at runtime. Your code reads them the same way it reads your local .env — nothing app-side changes between environments."}],doneLabel:"Mark secrets as set up",doneNote:"You can add or rotate individual secrets anytime without touching code."}}function tu({onBack:t,onComplete:s}){const{env:n}=Xj(),r=eu((n==null?void 0:n.envKeys)??[],(n==null?void 0:n.serviceEnvVars)??[]);return e.jsx(Le,{config:r,onBack:t,onComplete:s})}const J5=Object.freeze(Object.defineProperty({__proto__:null,SecretsScreen:tu,buildConfig:eu,secretsSection:Zd},Symbol.toStringTag,{value:"Module"})),Zj={key:"api-auth",Icon:Ce,title:"API authentication",crumbLabel:"API auth",meta:"Foundation · about 8 minutes",leads:[{text:"An open endpoint is a public endpoint. Authentication decides who may call your service, and rate limiting decides how often — together they keep your API from being abused or accidentally hammered."},{text:"A service authenticates callers — other services, scripts, partners — not interactive human logins.",dim:!0}],sections:[{heading:"Who may call — two kinds of credential",bullets:[{lead:"Static API keys.",text:"An opaque secret string each caller sends on every request. Simple to issue; you revoke a leaked one server-side. Best for trusted clients you control."},{lead:"Signed tokens (JWT).",text:"A bearer token that carries claims (who, what scope) and expires on its own, so a leaked one stops working without a server lookup. Best when callers come and go or need scoped access."}]},{heading:"How often — rate limiting",bullets:[{lead:"Per-key limits.",text:"Cap authenticated callers per window — e.g. 100 / minute. Fixed-window is simplest; token-bucket smooths bursts by refilling allowance steadily instead of resetting on a hard clock edge. Either way overflow gets a clean 429 Too Many Requests instead of taking the service down."},{lead:"Limit unauthenticated traffic too.",text:"Throttle by client IP before auth runs, so a flood of un-keyed requests can't exhaust the service trying to log in or hammer public routes."}]},{heading:"Verifying it's really them — request signing",bullets:[{lead:"HMAC signatures.",text:"For service-to-service and webhooks, the caller signs each request body with a shared secret (the Stripe-webhook / AWS-style scheme) and you verify the signature — proving the payload wasn't tampered with, not just that a key was presented."},{lead:"mTLS (optional).",text:"For high-trust internal calls, both sides present certificates so the connection itself authenticates the caller before any request is read."}]},{heading:"Sensible defaults",body:"Start with API keys or short-lived JWTs, per-key limits with an IP limit on unauthenticated routes, and a 429 on overflow. Keep keys and signing secrets in your secret store so you can rotate them without a redeploy."}],faq:[{q:"Keys or OAuth?",a:"For service-to-service calls, API keys or signed tokens are simpler and enough. Reach for OAuth when third parties act on behalf of your users, not just for machine callers."},{q:"Where do limits live?",a:"Usually at the edge or in middleware, keyed by the caller's API key. That way a noisy client is throttled before it reaches your handlers."}],doneLabel:"Mark API auth as set up",doneNote:"Start strict — loosening a limit later is easy; tightening one after launch is harder."};function su({onBack:t,onComplete:s}){return e.jsx(Le,{config:Zj,onBack:t,onComplete:s})}const X5=Object.freeze(Object.defineProperty({__proto__:null,ApiAuthScreen:su},Symbol.toStringTag,{value:"Module"})),e0={key:"cors-origins",Icon:Gs,title:"Allowed origins (CORS)",crumbLabel:"CORS",meta:"Common · about 5 minutes",leads:[{text:"If a website running in someone's browser calls your API, the browser first checks whether your API allows that website. CORS — Cross-Origin Resource Sharing — is how your API answers 'yes, this origin is allowed.' Get it wrong and the browser blocks the call before your code ever sees it."},{text:"This only affects browser calls. Requests from your own server, a mobile app, or a tool like curl aren't subject to CORS at all.",dim:!0}],sections:[{heading:"What an 'origin' is",bullets:[{lead:"Scheme + host + port —",text:"https://app.example.com is one origin; http://app.example.com and https://example.com are different origins."},{lead:"You list the ones you trust —",text:"your API replies with an Access-Control-Allow-Origin header naming the sites permitted to read its responses."},{lead:"Don't reflect everything —",text:"allowing every origin (a wildcard) defeats the point and breaks cookies/credentials. List the specific front-ends you control."}]},{heading:"Getting it right per environment",bullets:[{lead:"Local + production differ.",text:"http://localhost:5173 in development, https://your-app.com in production — both go on the allow-list, ideally read from config, not hard-coded."},{lead:"Credentials need extra care.",text:"If the browser sends cookies or an auth header, you must name the exact origin (no wildcard) and set the allow-credentials flag."},{lead:"Preflight is automatic.",text:"For anything beyond a simple GET, the browser sends an OPTIONS 'preflight' first. Your CORS layer answers it — you rarely write that by hand."}]}],faq:[{q:"I got a 'blocked by CORS policy' error — what does it mean?",a:"The browser asked your API whether the current website is allowed, and your API didn't say yes for that origin. Add the website's exact origin (scheme, host, and port) to your allow-list and the call will go through."},{q:"Why not just allow all origins with a wildcard?",a:"A wildcard lets any site on the internet call your API from a user's browser, and it can't be combined with cookies or credentials. List the specific front-ends you own instead."},{q:"My API works from curl but not the browser — why?",a:"CORS is a browser rule, not a server rule. curl and your own backend ignore it; only browser JavaScript is gated. That's why a missing origin shows up only once a web front-end calls the API."}],doneLabel:"Mark allowed origins as set up",doneNote:"Add each front-end's origin to the allow-list per environment — you can adjust the list anytime without a code change beyond config."};function nu({onBack:t,onComplete:s}){return e.jsx(Le,{config:e0,onBack:t,onComplete:s})}const Q5=Object.freeze(Object.defineProperty({__proto__:null,CorsOriginsScreen:nu},Symbol.toStringTag,{value:"Module"})),t0={key:"background-jobs",Icon:Ze,title:"Background jobs",crumbLabel:"Background jobs",meta:"Common · about 10 minutes",leads:[{text:"Some work shouldn't happen while a user waits for a response — sending a welcome email, resizing an upload, calling a slow third-party API, or running a nightly cleanup. Background jobs move that work onto a queue so your API answers immediately and the work happens just after."},{text:"A job runner gives you three things a plain request can't: it retries on failure, it survives a restart, and it can run on a schedule.",dim:!0}],sections:[{heading:"What you'd push to the background",bullets:[{lead:"Anything slow —",text:"emails, webhooks, image/video processing, report generation. The user gets an instant 'on its way' instead of a spinner."},{lead:"Anything scheduled —",text:"nightly cleanup, daily digests, expiring old sessions. A cron-style timer enqueues the job for you."},{lead:"Anything that can fail and retry —",text:"a flaky external API is fine in a job: it retries with backoff instead of failing the user's request."}]},{heading:"How a job queue works",bullets:[{lead:"Enqueue, don't block.",text:"Your endpoint adds a job to the queue and returns. The caller doesn't wait for the work to finish."},{lead:"A worker picks it up.",text:"A separate worker process pulls jobs off the queue and runs them — you scale workers independently of your API."},{lead:"Retries with backoff.",text:"If a job throws, the runner re-runs it after a growing delay, up to a limit, then parks it in a dead-letter queue for you to inspect."}]}],faq:[{q:"Can't I just run the work in the request and not worry about a queue?",a:"For something instant, yes. But slow work makes every caller wait, and a crash mid-request loses the work with no retry. A queue keeps responses fast and makes the work durable."},{q:"Do I need a separate server for workers?",a:"Not necessarily — a worker can be a second process on the same host. What matters is that it's separate from the web process, so a burst of jobs doesn't slow down serving requests."},{q:"What happens if a job keeps failing?",a:"After the retry limit it lands in a dead-letter queue: it stops retrying, and you get a record to investigate instead of an infinite loop or silent loss."}],doneLabel:"Mark background jobs as set up",doneNote:"Start with one job — a welcome email is a good first move — then add scheduled and retrying jobs as you need them."};function ru({onBack:t,onComplete:s}){return e.jsx(Le,{config:t0,onBack:t,onComplete:s})}const Z5=Object.freeze(Object.defineProperty({__proto__:null,BackgroundJobsScreen:ru},Symbol.toStringTag,{value:"Module"})),s0={key:"logging-monitoring",Icon:jt,title:"Logging & monitoring",crumbLabel:"Monitoring",meta:"Foundation · about 8 minutes",leads:[{text:"A service has no screen to glance at — observability is how you know it's alive and well. You wire up logs, metrics, alerts, and uptime checks once, then you find out about problems before your users do."},{text:"You don't have to build this yourself — hosts and tools provide it; you decide what to watch.",dim:!0}],sections:[{heading:"The four things to watch",bullets:[{lead:"Logs.",text:"A searchable record of what happened — every request, error, and warning. The first place you look when something breaks."},{lead:"Metrics.",text:"Numbers over time: request rate, error rate, latency. They show trends a single log line can't."},{lead:"Alerts.",text:"Rules that page you when a metric crosses a line, so you don't have to stare at dashboards."},{lead:"Uptime checks.",text:"An outside service pings a health endpoint on a schedule and tells you the moment the service stops responding."}]},{heading:"Tools that do this for you",bullets:[{lead:"Errors —",text:"Sentry captures every exception with the stack trace and the request that caused it."},{lead:"Metrics & dashboards —",text:"Grafana + Prometheus (self-hosted), or Datadog / Better Stack (managed) for request-rate, error-rate, and latency graphs."},{lead:"Logs —",text:"Axiom or Loki to search structured logs, or your host's built-in log viewer to start."},{lead:"Uptime —",text:"UptimeRobot or Better Stack pings your /health endpoint and alerts you the moment it stops answering."}]},{heading:"One standard to instrument with",body:"Instrument your service with OpenTelemetry — the vendor-neutral standard for emitting logs, metrics, and traces. You add it once, then point it at whichever backend above you choose, and you can switch tools later without re-instrumenting your code."},{heading:"A good starting point",body:"Ship structured logs, expose request-rate / error-rate / latency metrics, add one error-rate alert, and point an uptime check at a /health endpoint. That covers the most common 3am surprises."}],faq:[{q:"Isn't this overkill for a small service?",a:"Even one error-rate alert and an uptime check pay for themselves the first time the service goes down while you're asleep. Start small; add detail as you grow."},{q:"What's a health endpoint?",a:"A tiny route (often /health) that returns 200 when the service can serve traffic. Uptime checks and load balancers ping it to decide if the service is alive."}],doneLabel:"Mark monitoring as set up",doneNote:"Start with logs, one alert, and an uptime check — you can always add more signals later."};function au({onBack:t,onComplete:s}){return e.jsx(Le,{config:s0,onBack:t,onComplete:s})}const eT=Object.freeze(Object.defineProperty({__proto__:null,LoggingMonitoringScreen:au},Symbol.toStringTag,{value:"Module"}));function aa({onBack:t,onComplete:s}){const n=[{q:"Is a preview the same build as production?",a:"If you wire it up right, yes — a preview deploy runs the same build command and the same framework output as production, just on a throwaway URL. That's the whole point: what you click on the preview is what ships. Where it can differ is data and secrets — a preview usually points at a staging database, not prod — so test behavior on the preview, but don't trust preview data as if it were live."},{q:"Can I share it without making it public?",a:"Yes. Most hosts let you password-protect a preview or restrict it to your team's accounts, so you can hand a reviewer or a client a working link before the production domain points anywhere. Protect previews by default if the build exposes anything you wouldn't want indexed — search engines and link unfurlers will otherwise crawl an open preview URL."},{q:"Do I need a separate staging environment too?",a:"Per-branch previews are throwaway and rebuilt on every push. A longer-lived staging environment is the complement: one stable URL, its own data, that behaves like prod and stays up between deploys — useful for QA sign-off, demos, and integrations that need a fixed address. Many teams use preview deploys for review and one staging environment as the final gate before production."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Ze,{size:26}),title:"Staging & preview deploys",meta:"About 15 minutes · then automatic on every push",onBack:t,assistKey:"staging-preview"}),e.jsx("p",{className:"lead",children:"Before you point your real domain at anything, give yourself a prod-like URL to test on and share. Most hosts can build one for you on every push, so you and your reviewers see the exact build that will go live — without anyone touching production."}),e.jsx("div",{className:"seclabel",children:"Per-branch preview deploys"}),e.jsxs(ee,{children:[e.jsxs(O,{lead:"Get a URL for every branch or pull request.",children:["Hosts like ",e.jsx("b",{children:"Vercel"})," and ",e.jsx("b",{children:"Netlify"})," build a fresh deploy each time you push and give it its own URL. The preview runs the same build as production, so it's the real thing on a throwaway address — not a local approximation."]}),e.jsx(O,{lead:"Review the change on the preview, not on prod.",children:"Open the preview URL for the branch, click through the actual change, and only merge once it looks right. This is where you catch a broken build or a layout regression before it can reach a visitor."})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"A shared staging environment"}),e.jsxs(ee,{children:[e.jsx(O,{lead:"Keep one stable, prod-like URL with its own data.",children:"A longer-lived staging environment behaves like production — same build, its own database and config — but stays up between deploys. It's the fixed address QA, demos, and integrations point at while per-branch previews come and go."}),e.jsx(O,{lead:"Promote the same build to production.",children:"When staging looks right, promote that build to production rather than rebuilding from scratch. What you signed off on is what ships, so going live is a flip of the switch, not a fresh roll of the dice."})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Share it privately"}),e.jsxs(ee,{children:[e.jsx(O,{lead:"Password-protect or restrict the preview.",children:"So you can hand a working link to a client or teammate before going public, protect the preview with a password or limit it to your team's accounts. Most hosts offer this as a one-click setting per deploy."}),e.jsx(O,{lead:"Keep previews out of search.",children:"A protected preview won't get indexed or unfurled. Turn protection on by default if the build shows anything you wouldn't want a crawler to find before launch day."})]}),e.jsx(De,{items:n}),e.jsx(de,{assistKey:"staging-preview",topicName:"Staging & preview deploys"}),e.jsx(he,{label:"I've set up staging & previews",note:"From here, every push gives you a prod-like URL to test and share before anything reaches your real domain.",onComplete:()=>{s==null||s(),t()}})]})}const tT=Object.freeze(Object.defineProperty({__proto__:null,StagingPreviewScreen:aa},Symbol.toStringTag,{value:"Module"}));function ou({onBack:t,onComplete:s}){const n=[{q:"Why not just point staging at the production database?",a:"Because a staging environment exists to let you break things safely, and the fastest way to lose that is to share prod's data. A bad migration, a destructive test, or a runaway job on staging would then corrupt or leak real customer data. Staging gets its own database — ideally seeded from a sanitized copy of prod so it's realistic — and its own secrets, so nothing you do there can touch production."},{q:"What does staging actually catch that local doesn't?",a:"The things that only exist once you deploy: the real migration running against a populated database, environment variables and secrets resolved the production way, the actual platform's networking and timeouts, and the deploy pipeline itself. Local runs against a tiny dev database and your own machine's config — staging runs the same pipeline you'll run for prod, so a green deploy there is real evidence prod will be green too."},{q:"How do I get a build from staging to production?",a:"Promote the exact artifact you validated rather than rebuilding for prod. Run the migration on staging first, confirm the service is healthy, then promote that same build to production and run the same migration there. Because staging already rehearsed every step, the production deploy is a repeat of something that just worked — not a first attempt under pressure."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Ze,{size:26}),title:"Staging environment",meta:"About 30 minutes · a one-time environment to stand up",onBack:t,assistKey:"staging-environment"}),e.jsx("p",{className:"lead",children:"A staging environment is a full, prod-like copy of your service you can deploy to and exercise before anything reaches real users. It runs the same pipeline as production but has its own data and secrets — so a deploy there is a rehearsal, not a gamble."}),e.jsx("div",{className:"seclabel",children:"Make it prod-like, but isolated"}),e.jsxs(ee,{children:[e.jsx(O,{lead:"Give staging its own database and secrets.",children:"Never point staging at production data. Stand up a separate database — ideally seeded from a sanitized copy of prod so it's realistic — and a separate set of secrets, so anything you break on staging can't touch a real customer."}),e.jsx(O,{lead:"Run the same deploy pipeline as production.",children:"Deploy to staging with the exact build and release steps you'll use for prod. The value is in the sameness: if the pipeline is green on staging, that's real evidence it'll be green on production."})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Rehearse the risky parts"}),e.jsxs(ee,{children:[e.jsx(O,{lead:"Run schema migrations on staging first.",children:"A migration against a populated database is where deploys most often go wrong. Run it on staging — with prod-like data volume — and you find the slow lock or the bad backfill before it's holding up real traffic."}),e.jsx(O,{lead:"Spin up a per-branch environment when you need one.",children:"For a risky change, an ephemeral environment built just for that branch lets you test it in isolation and tear it down afterward — the backend analog of a per-branch preview deploy."})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Promote to production"}),e.jsx(ee,{children:e.jsx(O,{lead:"Ship the build you already validated.",children:"When staging is healthy, promote that same build to production rather than rebuilding. Run the migration on prod just as you rehearsed on staging — going live becomes a repeat of something that just worked."})}),e.jsx(De,{items:n}),e.jsx(de,{assistKey:"staging-environment",topicName:"Staging environment"}),e.jsx(he,{label:"I've set up a staging environment",note:"From here, every change can be deployed and exercised on staging — migrations and all — before you promote it to production.",onComplete:()=>{s==null||s(),t()}})]})}const sT=Object.freeze(Object.defineProperty({__proto__:null,StagingEnvironmentScreen:ou},Symbol.toStringTag,{value:"Module"}));function oa({onBack:t,onComplete:s}){const n=[{q:"Will a pre-release accidentally become what everyone installs?",a:"Not if you publish it correctly. A plain install (`install pkg`) resolves the `latest` tag, and a pre-release is published under a different tag — `next` or `beta` — so it never moves `latest`. On top of that, a semver pre-release version like `1.2.0-rc.1` is excluded from normal version ranges by default, so a dependent on `^1.1.0` won't auto-adopt it. You have to opt in twice to get a pre-release, which is the whole point."},{q:"How does a tester actually get the pre-release?",a:"They opt in explicitly. For a package, that's installing the tag — `install pkg@next` — or pinning the exact pre-release version. For a binary, it's downloading the build attached to a GitHub pre-release rather than the latest stable release. Either way it's a deliberate choice, so the people on the pre-release channel are exactly the people who asked to test it."},{q:"How do I promote a pre-release to stable?",a:"When the pre-release has held up, cut the stable version (drop the `-rc.1` suffix, e.g. `1.2.0`) and publish it to `latest` — or mark the GitHub release as the latest, not a pre-release. Everyone on a normal install picks it up from there. The pre-release channel keeps running for the next round; promoting one build to stable doesn't shut it down."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Ze,{size:26}),title:"Pre-release channel",meta:"About 15 minutes · then one extra command per pre-release",onBack:t,assistKey:"pre-release-channel"}),e.jsxs("p",{className:"lead",children:["A pre-release lets people test the next version before it's stable — without changing what everyone gets by default. You publish it on a separate channel, testers opt in, and your ",e.jsx("code",{children:"latest"})," stays exactly where it is until you're ready to promote."]}),e.jsx("div",{className:"seclabel",children:"Publish on a separate channel"}),e.jsxs(ee,{children:[e.jsxs(O,{lead:"Use a next / beta tag instead of latest.",children:["Publish the pre-release under a dist-tag like ",e.jsx("code",{children:"next"})," or"," ",e.jsx("code",{children:"beta"})," (npm), a ",e.jsx("code",{children:"--pre"})," flag on other registries, or a GitHub ",e.jsx("b",{children:"pre-release"})," for binaries. A normal install still resolves ",e.jsx("code",{children:"latest"}),", so the default install is untouched."]}),e.jsxs(O,{lead:"Tag a semver pre-release version.",children:["Version it with a pre-release identifier — ",e.jsx("code",{children:"1.2.0-rc.1"}),","," ",e.jsx("code",{children:"1.2.0-beta.2"}),". Semver excludes these from ordinary version ranges, so a dependent on ",e.jsx("code",{children:"^1.1.0"})," won't pull it in by accident. It takes a deliberate opt-in to land on a pre-release."]})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Let testers opt in"}),e.jsxs(ee,{children:[e.jsxs(O,{lead:"Tell testers the one install command.",children:["A tester installs the channel explicitly — ",e.jsx("code",{children:"install pkg@next"})," ","— or downloads the build attached to the GitHub pre-release. The people on the channel are exactly the ones who asked to be there."]}),e.jsx(O,{lead:"Gather feedback before it's everyone's problem.",children:"Because the pre-release reaches only opt-in testers, a rough edge gets caught by people who expect a rough edge — not by your whole user base on a normal install."})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Promote to stable"}),e.jsx(ee,{children:e.jsxs(O,{lead:"Cut the stable version when it holds up.",children:["Drop the pre-release suffix (",e.jsx("code",{children:"1.2.0-rc.1"})," →"," ",e.jsx("code",{children:"1.2.0"}),") and publish it to ",e.jsx("code",{children:"latest"}),", or mark the GitHub release as latest. Everyone on a normal install picks it up — and the channel stays open for the next round."]})}),e.jsx(De,{items:n}),e.jsx(de,{assistKey:"pre-release-channel",topicName:"Pre-release channel"}),e.jsx(he,{label:"I've set up a pre-release channel",note:"From here, testers can opt into the next version on its own tag while your latest stays stable until you promote.",onComplete:()=>{s==null||s(),t()}})]})}const nT=Object.freeze(Object.defineProperty({__proto__:null,PreReleaseScreen:oa},Symbol.toStringTag,{value:"Module"})),n0={"real-data":ld,accounts:bd,emails:yd,payments:wd,"analytics-monitoring":_d,legal:kd,"data-safety":Ad,publish:Pd,"custom-domain":Od,forms:Rd,"analytics-seo":Ed,"redirects-404":Md,"performance-images":Id,"comments-search":Dd,"publish-registry":Fd,"versioning-changelog":zd,"install-docs":$d,"release-builds":Bd,"shell-completions":Hd,"cli-ux":Wd,"api-docs":Ud,examples:Gd,"semver-policy":Yd,"readme-license":Kd,"supply-chain":qd,"changelog-ci":Jd,"deploy-target":Xd,"database-backups":Qd,secrets:tu,"api-auth":su,"cors-origins":nu,"background-jobs":ru,"logging-monitoring":au,"staging-preview":aa,"deploy-previews":aa,"staging-environment":ou,"pre-release-channel":oa,"pre-release-versions":oa};function iu({onBack:t,topicKey:s,topicName:n,topicDesc:r}){const a=(n==null?void 0:n.trim())||"This setup step",o=(r==null?void 0:r.trim())||"There isn't a guided screen for this step here yet. You can still set it up — check the project's setup notes — and we'll add a walkthrough soon.";return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Un,{size:26}),title:a,meta:"Guided screen coming soon",onBack:t,assistKey:s??""}),e.jsx("p",{className:"lead",children:o}),e.jsx("div",{className:"cta-wrap",children:e.jsx("button",{type:"button",className:"cta",onClick:t,children:"Back to Setup"})})]})}function lu({topicKey:t,topicName:s,topicDesc:n,isBackend:r=!1,onBack:a,onComplete:o}){const i=t==="api-docs"&&r?Vd:n0[t];return i?e.jsx(i,{onBack:a,onComplete:()=>o==null?void 0:o(t)}):e.jsx(iu,{onBack:a,topicKey:t,topicName:s,topicDesc:n})}const rT=Object.freeze(Object.defineProperty({__proto__:null,SetupTopicPlaceholder:iu,SetupTopicRouter:lu},Symbol.toStringTag,{value:"Module"}));function cu({onBack:t}){const{concepts:s}=$c(),[n,r]=l.useState(""),[a,o]=l.useState(null),i=l.useMemo(()=>{const c=n.trim().toLowerCase();return!c||!s?s??[]:s.filter(d=>[d.term,d.category,...d.aka].join(" ").toLowerCase().includes(c))},[s,n]);return e.jsxs("div",{className:"learn-screen concepts-glossary",children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:t,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:t,children:"Setup"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"What these words mean"})]}),e.jsx("div",{className:"h",children:"What these words mean"}),e.jsx("div",{className:"hsub",children:"Plain-language explainers for the terms you'll run into while setting up your app. No jargon — just what each thing is, whether you need it, and what it costs."}),e.jsx("input",{type:"search",className:"concept-search",placeholder:"Search terms…",value:n,onChange:c=>r(c.target.value),"aria-label":"Search terms"}),e.jsx("div",{className:"tlist",children:s===null?Array.from({length:6}).map((c,d)=>e.jsx("div",{className:"trow soon","aria-hidden":"true",children:e.jsxs("div",{className:"tbody",children:[e.jsx("div",{className:"tn",children:" "}),e.jsx("div",{className:"td",children:" "})]})},d)):i.length===0?e.jsxs("div",{className:"concept-empty",children:['No terms match "',n,'".']}):i.map(c=>{const d=a===c.key;return e.jsxs("div",{className:"concept-row",children:[e.jsxs("button",{type:"button",className:"trow soon","aria-expanded":d,onClick:()=>o(d?null:c.key),children:[e.jsxs("div",{className:"tbody",children:[e.jsx("div",{className:"tn",children:c.term}),c.category?e.jsx("div",{className:"td",children:c.category}):null]}),e.jsx("span",{className:"arrow",children:d?"−":"+"})]}),d?e.jsx("div",{className:"concept-row-body",children:e.jsx(vt,{variant:"compact",children:c.body})}):null]},c.key)})})]})}const aT=Object.freeze(Object.defineProperty({__proto__:null,ConceptsGlossaryScreen:cu},Symbol.toStringTag,{value:"Module"})),Ms="your-app.vercel.app",r0=[{key:"connect",label:"Connect"},{key:"deploying",label:"Deploy"},{key:"live",label:"Go live"}];function io({onBack:t}){return e.jsx(ae,{icon:e.jsx(Ws,{size:26}),title:"Hosting & going live",crumbLabel:"Hosting",meta:"Foundation · about 10 minutes",onBack:t,assistKey:"hosting"})}function us({stage:t}){return e.jsx(gt,{steps:r0,currentKey:t})}const oT=Object.freeze(Object.defineProperty({__proto__:null,FlowBar:us,HSHeader:io,HS_URL:Ms},Symbol.toStringTag,{value:"Module"}));function a0(){const[t,s]=l.useState(null);return l.useEffect(()=>{let n=!1;return(async()=>{try{const r=await fetch("/api/hosting-target");if(!r.ok)throw new Error(`HTTP ${r.status}`);const a=await r.json();n||s(a)}catch{n||s(null)}})(),()=>{n=!0}},[]),{target:t}}function du({onBack:t,onSetup:s}){const{target:n}=a0(),r=(n==null?void 0:n.detectedHost)??null;return e.jsxs(e.Fragment,{children:[e.jsx(io,{onBack:t}),e.jsxs("p",{className:"lead",children:["Right now your app only runs on ",e.jsx("b",{children:"your computer"}),". Hosting puts it online so anyone can open it with a link, like renting a small plot of land where your app lives."]}),e.jsx("p",{className:"lead dim",children:"You don't need to understand servers. We'll set it up for you and explain each step in plain language."}),e.jsx(Xc,{}),r&&e.jsxs("div",{className:"hosting-detected",role:"note",children:[e.jsxs("div",{className:"hosting-detected-title",children:["This project is already configured for ",e.jsx("b",{children:r.name})]}),e.jsxs("div",{className:"hosting-detected-detail",children:["We found ",e.jsx("code",{children:r.evidence})," in your project — let's use"," ",r.name,".",(n==null?void 0:n.buildCommand)&&e.jsxs(e.Fragment,{children:[" ","It builds with ",e.jsx("code",{children:n.buildCommand}),n.outputDir&&e.jsxs(e.Fragment,{children:[" ","into ",e.jsx("code",{children:n.outputDir})]}),"."]})]})]}),e.jsx("div",{className:"seclabel",children:r?"Or start fresh with our recommendation":"Recommended for your app"}),e.jsxs("div",{className:"provcard best",children:[e.jsx(Xn,{}),e.jsxs("div",{className:"provbody",children:[e.jsxs("div",{className:"provtop",children:[e.jsx("span",{className:"provname",children:"Vercel"}),e.jsx("span",{className:"bestfit",children:"Best fit"})]}),e.jsx("div",{className:"provdesc",children:"Free to start, fast, and it works the way your app is already built. Most people in your spot pick this."}),e.jsx(Qc,{}),e.jsx(Zc,{})]})]}),e.jsx(ed,{}),e.jsxs("div",{className:"cta-wrap",children:[e.jsxs("button",{type:"button",className:"cta",onClick:s,children:[e.jsx("span",{className:"ce",children:"☁️"})," Set up hosting with Vercel"]}),e.jsx("div",{className:"cta-note",children:"We'll walk you through every step. Nothing goes live until you say so."})]}),e.jsx("div",{className:"seclabel",style:{marginTop:34},children:"FAQ"}),e.jsx(td,{}),e.jsx(sd,{}),e.jsx(de,{assistKey:"hosting",topicName:"Hosting & going live"})]})}const iT=Object.freeze(Object.defineProperty({__proto__:null,HostingOverviewGuided:du},Symbol.toStringTag,{value:"Module"}));function uu({onBack:t,onContinue:s,tokenMode:n=!1}){const[r,a]=l.useState("");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:t,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:t,children:"Hosting"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Connect Vercel"})]}),e.jsx(us,{stage:"connect"}),e.jsxs("div",{className:"panel",children:[e.jsx("div",{className:"ph",children:"🔗 Connect your Vercel account"}),e.jsx("div",{className:"psub",children:"This is a free account that holds your live app. If you don't have one yet, you'll make it in a few clicks, no setup required."}),e.jsxs("div",{className:"connect-box",children:[e.jsxs("div",{className:"cbtitle",children:[e.jsx(Xn,{}),e.jsxs("div",{children:[e.jsx("div",{className:"cbt",children:"Sign in with Vercel"}),e.jsx("div",{className:"cbd",children:n?"Paste a Vercel access token to deploy your real app.":"We'll open Vercel in a new tab and bring you right back."})]})]}),n?e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"real-token-label",htmlFor:"hosting-token",children:"Vercel access token"}),e.jsx("input",{id:"hosting-token",type:"password",className:"real-token-input",placeholder:"Paste your Vercel token",value:r,onChange:o=>a(o.target.value)}),e.jsxs("button",{type:"button",className:"auth-btn",disabled:r.trim().length===0,onClick:()=>s(r.trim()),children:[e.jsx("svg",{width:"17",height:"15",viewBox:"0 0 26 22",fill:"#fff","aria-hidden":"true",children:e.jsx("path",{d:"M13 0l13 22H0z"})}),"Deploy with Vercel"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grant",children:[e.jsxs("div",{className:"grantrow",children:[e.jsx(Te,{color:"var(--blue-300)"}),e.jsx("span",{children:"Create one project to hold your app"})]}),e.jsxs("div",{className:"grantrow",children:[e.jsx(Te,{color:"var(--blue-300)"}),e.jsx("span",{children:"Publish updates when you choose to go live"})]}),e.jsxs("div",{className:"grantrow",children:[e.jsx(Te,{color:"var(--blue-300)"}),e.jsx("span",{children:"Nothing else. We can't touch your other accounts or files"})]})]}),e.jsxs("button",{type:"button",className:"auth-btn",onClick:()=>s(),children:[e.jsx("svg",{width:"17",height:"15",viewBox:"0 0 26 22",fill:"#fff","aria-hidden":"true",children:e.jsx("path",{d:"M13 0l13 22H0z"})}),"Continue with Vercel"]}),e.jsxs("div",{className:"auth-row",children:[e.jsx("button",{type:"button",className:"auth-ghost",onClick:()=>s(),children:"I already have an account"}),e.jsx("button",{type:"button",className:"auth-ghost",onClick:()=>s(),children:"Create one for me"})]})]})]}),e.jsx("div",{className:"reassure",children:"🔒 We only ask for what's needed to put this one app online. You can disconnect at any time from settings."})]})]})}const lT=Object.freeze(Object.defineProperty({__proto__:null,HostingConnectStep:uu},Symbol.toStringTag,{value:"Module"})),on=["Packaging up your app","Uploading it to Vercel","Giving it a web address","Turning it on"],_i=1100,o0=700;function hu({onDone:t}){const[s,n]=l.useState(0),r=l.useRef(t);r.current=t,l.useEffect(()=>{const o=[];for(let i=1;i<=on.length;i++)o.push(setTimeout(()=>n(i),i*_i));return o.push(setTimeout(()=>r.current(),on.length*_i+o0)),()=>o.forEach(clearTimeout)},[]);const a=Math.round(s/on.length*100);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("span",{children:"Hosting"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Going live"})]}),e.jsx(us,{stage:"deploying"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"deploy-head",children:[e.jsx("div",{className:"deploy-spin"}),e.jsxs("div",{children:[e.jsx("div",{className:"deploy-t",children:"Putting your app online…"}),e.jsx("div",{className:"deploy-d",children:"This usually takes under a minute. You can keep working, we'll let you know."})]})]}),e.jsx("div",{className:"dep-bar",children:e.jsx("div",{style:{width:a+"%"}})}),e.jsx("div",{className:"dep-steps",children:on.map((o,i)=>e.jsxs("div",{className:"dep-step "+(i<s?"done":i===s?"active":"todo"),children:[e.jsx("div",{className:"dot",children:i<s?e.jsx(Te,{size:12,color:"#0a0a0a"}):null}),e.jsx("div",{className:"sl",children:o})]},o))})]})]})}const cT=Object.freeze(Object.defineProperty({__proto__:null,HostingDeployStep:hu},Symbol.toStringTag,{value:"Module"})),i0="hosting";function pu({provider:t,credential:s,onDone:n,onRetry:r}){const{stage:a,result:o,error:i,connect:c}=eo(i0,t),d=l.useRef(!1);l.useEffect(()=>{d.current||(d.current=!0,c(s))},[c,s]);const u=l.useRef(n);return u.current=n,l.useEffect(()=>{a==="ready"&&o&&u.current(o.value)},[a,o]),a==="error"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("span",{children:"Hosting"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Going live"})]}),e.jsx(us,{stage:"deploying"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"real-error",role:"alert",children:[e.jsx("div",{className:"real-error-title",children:"Couldn’t put your app online"}),e.jsx("div",{className:"real-error-msg",children:i})]}),e.jsx("button",{type:"button",className:"auth-btn",onClick:r,children:"Try again"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("span",{children:"Hosting"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Going live"})]}),e.jsx(us,{stage:"deploying"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"deploy-head",children:[e.jsx("div",{className:"deploy-spin"}),e.jsxs("div",{children:[e.jsx("div",{className:"deploy-t",children:"Putting your app online…"}),e.jsx("div",{className:"deploy-d",children:a==="connecting"?"Connecting to your hosting account…":"Building and publishing your app. This usually takes under a minute."})]})]}),e.jsx("div",{className:"dep-bar",children:e.jsx("div",{className:"dep-bar-indeterminate"})})]})]})}const dT=Object.freeze(Object.defineProperty({__proto__:null,HostingRealDeployStep:pu},Symbol.toStringTag,{value:"Module"})),l0=1600;function mu(t){const[s,n]=l.useState(!1),r=l.useRef(null),a=l.useCallback(()=>{var o;try{(o=navigator.clipboard)==null||o.writeText(t)}catch{}n(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>n(!1),l0)},[t]);return{copied:s,copy:a}}function fu({onFinish:t,liveUrl:s}){const n=s??Ms,r=s??"https://"+Ms,{copied:a,copy:o}=mu(r);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("span",{children:"Hosting"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Live"})]}),e.jsx(us,{stage:"live"}),e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"live-hero",children:[e.jsx("div",{className:"lh-em",children:"🎉"}),e.jsx("div",{className:"lh-t",children:"Your app is live"}),e.jsx("div",{className:"lh-d",children:"Anyone with this link can open your app right now."})]}),e.jsxs("div",{className:"url-card",children:[e.jsx("span",{className:"ucglobe",children:"🌍"}),e.jsxs("div",{children:[e.jsx("div",{className:"uc-l",children:"Your link"}),e.jsx("div",{className:"uc-u",children:n})]}),e.jsxs("div",{className:"uc-actions",children:[e.jsx("button",{type:"button",className:"btn-copy",onClick:o,children:a?"✓ Copied":"Copy link"}),e.jsx("button",{type:"button",className:"btn-visit",disabled:!s,onClick:s?()=>window.open(s,"_blank","noopener"):void 0,children:"Visit →"})]})]}),e.jsxs("div",{className:"domain-row",children:[e.jsx("span",{className:"dre",children:"🏷️"}),e.jsxs("div",{children:[e.jsx("div",{className:"drt",children:"Want your own web address?"}),e.jsx("div",{className:"drd",children:"Connect a custom domain. Optional, and you can do it anytime."})]}),e.jsx("button",{type:"button",className:"drbtn",children:"Add a domain"})]}),e.jsxs("div",{className:"live-foot",children:[e.jsxs("span",{className:"done-pill",children:[e.jsx(Te,{})," Hosting is now set up"]}),e.jsx("button",{type:"button",className:"lf-back",onClick:t,children:"Back to Setup"})]})]})]})}const uT=Object.freeze(Object.defineProperty({__proto__:null,HostingLiveStep:fu},Symbol.toStringTag,{value:"Module"}));function gu({onBack:t,onRedeploy:s}){const{copied:n,copy:r}=mu("https://"+Ms),[a,o]=l.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsx(io,{onBack:t}),e.jsxs("div",{className:"conn-card",children:[e.jsx(Xn,{}),e.jsxs("div",{className:"conn-body",children:[e.jsxs("div",{className:"conn-top",children:[e.jsx("span",{className:"conn-name",children:"Connected to Vercel"}),e.jsxs("span",{className:"conn-live",children:[e.jsx("span",{className:"lbdot"}),"Live"]})]}),e.jsxs("div",{className:"conn-acct",children:["Account ",e.jsx("b",{children:"your-app"})," · connected today"]})]}),e.jsx("button",{type:"button",className:"conn-disc",children:"Disconnect"})]}),e.jsx("div",{className:"seclabel",children:"Your live app"}),e.jsxs("div",{className:"url-card",children:[e.jsx("span",{className:"ucglobe",children:"🌍"}),e.jsxs("div",{children:[e.jsx("div",{className:"uc-l",children:"Your link"}),e.jsx("div",{className:"uc-u",children:Ms})]}),e.jsxs("div",{className:"uc-actions",children:[e.jsx("button",{type:"button",className:"btn-copy",onClick:r,children:n?"✓ Copied":"Copy link"}),e.jsx("button",{type:"button",className:"btn-visit",children:"Visit →"})]})]}),e.jsx("div",{className:"seclabel",style:{marginTop:28},children:"Latest deploy"}),e.jsxs("div",{className:"dep-card",children:[e.jsxs("div",{className:"depc-row",children:[e.jsx("span",{className:"depc-dot"}),e.jsxs("div",{className:"depc-main",children:[e.jsx("div",{className:"depc-t",children:"Live · deployed 2 minutes ago"}),e.jsx("div",{className:"depc-d",children:"Built and published from your latest changes."})]}),e.jsx("button",{type:"button",className:"depc-btn",onClick:s,children:"Redeploy"})]}),e.jsxs("div",{className:"depc-toggle",children:[e.jsxs("div",{children:[e.jsx("div",{className:"depc-tt",children:"Publish changes automatically"}),e.jsx("div",{className:"depc-td",children:"When you make changes, we'll put them live for you. Turn this off to publish by hand."})]}),e.jsx("span",{className:"toggle"+(a?" on":""),onClick:()=>o(i=>!i),role:"switch","aria-checked":a,tabIndex:0,children:e.jsx("span",{})})]})]})]})}const hT=Object.freeze(Object.defineProperty({__proto__:null,HostingOverviewConnected:gu},Symbol.toStringTag,{value:"Module"}));function bu({direction:t="guided",onBack:s,onComplete:n,connector:r}){const[a,o]=l.useState("overview"),[i,c]=l.useState(""),[d,u]=l.useState(void 0),h=r!==void 0;let p;return a==="overview"?p=t==="connected"?e.jsx(gu,{onBack:s,onRedeploy:()=>o("deploying")}):e.jsx(du,{onBack:s,onSetup:()=>o("connect")}):a==="connect"?p=e.jsx(uu,{onBack:()=>o("overview"),tokenMode:h,onContinue:m=>{h&&c(m??""),o("deploying")}}):a==="deploying"?p=h?e.jsx(pu,{provider:r.provider,credential:i,onDone:m=>{u(m),o(t==="connected"?"overview":"live")},onRetry:()=>o("connect")}):e.jsx(hu,{onDone:()=>o(t==="connected"?"overview":"live")}):p=e.jsx(fu,{liveUrl:d,onFinish:()=>{n==null||n(),s()}}),e.jsx("div",{className:"hosting-screen",children:p})}const pT=Object.freeze(Object.defineProperty({__proto__:null,HostingScreen:bu},Symbol.toStringTag,{value:"Module"}));function xu({recipe:t,onBack:s,onMarkDone:n,copyWriter:r}){return e.jsxs("div",{className:"learn-screen run-locally-screen",children:[e.jsxs("div",{className:"crumbs",children:[e.jsx("button",{type:"button",className:"back",onClick:s,"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:s,children:"Home"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("button",{type:"button",onClick:s,children:"Setup"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Run it locally"})]}),e.jsx("div",{className:"h",children:"Run it locally"}),e.jsx("div",{className:"hsub",children:"Right now your app runs inside this editor's Live Preview. Running it on your own machine lets you debug with your own tools, show it offline, or hand it to a teammate. Here's how, for this exact project."}),t===null?e.jsx("div",{className:"rl-loading","aria-hidden":"true",children:"Loading run instructions…"}):e.jsxs("div",{className:"rl-sections",children:[t.prereqs.length>0&&e.jsxs("section",{className:"rl-sec",children:[e.jsx("div",{className:"seclabel",children:"Prerequisites"}),e.jsx("ul",{className:"rl-prereqs",children:t.prereqs.map(a=>e.jsxs("li",{className:"rl-prereq",children:[e.jsx("span",{className:"rl-prereq-label",children:a.label}),e.jsx("span",{className:"rl-prereq-detail",children:a.detail})]},a.label))})]}),t.install&&e.jsxs("section",{className:"rl-sec",children:[e.jsx("div",{className:"seclabel",children:"Install"}),e.jsx(Ts,{command:t.install,writer:r})]}),e.jsxs("section",{className:"rl-sec",children:[e.jsx("div",{className:"seclabel",children:t.runLabel||"Run"}),e.jsx(Ts,{command:t.run,writer:r})]}),t.loadSteps&&e.jsxs("section",{className:"rl-sec",children:[e.jsx("div",{className:"seclabel",children:t.loadSteps.label}),e.jsx("ol",{className:"rl-load-steps",children:t.loadSteps.steps.map(a=>e.jsx("li",{className:"rl-load-step",children:a},a))}),t.loadTarget&&e.jsxs("div",{className:"rl-load-target",children:[e.jsx("div",{className:"rl-load-target-label",children:t.loadTarget.label}),e.jsx(Ts,{command:t.loadTarget.path,writer:r})]})]}),t.reachableAt&&e.jsxs("section",{className:"rl-sec",children:[e.jsx("div",{className:"seclabel",children:"Open it"}),e.jsxs("div",{className:"rl-reachable",children:["Once it's running, open"," ",e.jsx("a",{className:"rl-url",href:t.reachableAt,target:"_blank",rel:"noreferrer",children:t.reachableAt}),"."]})]}),t.notes.length>0&&e.jsxs("section",{className:"rl-sec",children:[e.jsx("div",{className:"seclabel",children:"Notes"}),e.jsx("ul",{className:"rl-notes",children:t.notes.map(a=>e.jsx("li",{className:"rl-note",children:a},a))})]}),e.jsx(de,{assistKey:"run-locally",topicName:"Run it locally"}),n&&e.jsx("div",{className:"cta-wrap",children:e.jsx("button",{type:"button",className:"cta",onClick:n,children:"Got it — mark as done"})})]})]})}const mT=Object.freeze(Object.defineProperty({__proto__:null,RunLocallyScreen:xu},Symbol.toStringTag,{value:"Module"}));function yu({onBack:t,onComplete:s}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Ce,{size:26}),title:"Store accounts",meta:"Foundation · about 15 minutes",onBack:t,assistKey:"store-accounts"}),e.jsxs("p",{className:"lead",children:["To publish your extension, you first register as a developer with the"," ",e.jsx("b",{children:"Chrome Web Store"}),". This is a one-time setup that gives you a dashboard for uploading, updating, and managing your listing."]}),e.jsx("p",{className:"lead dim",children:"It's not the same as a regular Google account upgrade — there's a one-time registration fee and a short profile to fill in."}),e.jsx("div",{className:"seclabel",children:"What you'll do"}),e.jsxs(ee,{children:[e.jsxs(O,{lead:"Pay the one-time developer fee.",children:["The Chrome Web Store charges a single"," ",e.jsx("b",{children:re("chromeStore.fee").value})," registration fee per account — not per extension. There's no recurring cost."]}),e.jsx(O,{lead:"Complete your developer profile.",children:"A public display name and a contact email. The email is verified and used for store communications and review notices."}),e.jsx(O,{lead:"Verify your identity and payment profile.",children:"Paying the fee requires a verified Google payment profile, and you must verify your contact information (email, and sometimes a phone number) before you can publish. Do this early — an unverified account can't push a listing live."}),e.jsx(O,{lead:"Decide on a publisher identity.",children:"You can publish under your own name or a group publisher. Group publishers are worth it if a team will manage the listing."})]}),e.jsx(or,{}),e.jsx(he,{label:"I've registered my developer account",note:"You only need to do this once. The next steps reuse the same account.",onComplete:()=>{s==null||s(),t()}})]})}const fT=Object.freeze(Object.defineProperty({__proto__:null,StoreAccountsScreen:yu},Symbol.toStringTag,{value:"Module"}));function vu({onBack:t,onComplete:s}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Dt,{size:26}),title:"Store assets",meta:"About 30 minutes · design time",onBack:t,assistKey:"store-assets"}),e.jsxs("p",{className:"lead",children:["Your store listing needs a set of images at ",e.jsx("b",{children:"exact dimensions"}),". The store rejects assets that are the wrong size, so it's worth getting these right before you submit."]}),e.jsx("div",{className:"seclabel",children:"Required"}),e.jsxs(ee,{children:[e.jsx(O,{lead:"Store icon — 128×128 PNG.",children:"The icon shown in the store and in the user's toolbar. Use a transparent or solid background; avoid tiny text."}),e.jsx(O,{lead:"At least one screenshot — 1280×800 or 640×400.",children:"Show your extension in action. The first screenshot is the one most users actually look at, so lead with your strongest."})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Recommended"}),e.jsxs(ee,{children:[e.jsx(O,{lead:"Small promo tile — 440×280.",children:"Shown in store listings and search results. A clean tile noticeably improves install rates."}),e.jsx(O,{lead:"Marquee promo tile — 1400×560.",children:"Only used if the store features your extension, but worth having ready."})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"PNG or JPEG"}),e.jsx("span",{className:"chip",children:"No misleading imagery"}),e.jsx("span",{className:"chip",children:"Up to 5 screenshots"})]}),e.jsx(de,{assistKey:"store-assets",topicName:"Store assets"}),e.jsx(he,{label:"My store assets are ready",note:"You can update assets later — a new upload doesn't restart the whole review.",onComplete:()=>{s==null||s(),t()}})]})}const gT=Object.freeze(Object.defineProperty({__proto__:null,ExtensionAssetsScreen:vu},Symbol.toStringTag,{value:"Module"})),ju={storage:"Save the user's settings and data between sessions.",activeTab:"Act on the current tab only when the user clicks your extension — no broad access. Prefer this over a host permission whenever the work starts from a user click; it sidesteps the host-permission review entirely.",scripting:"Inject the scripts that make your extension work on a page.",tabs:"Read tab titles and URLs to coordinate behaviour across open tabs.",cookies:"Read or set cookies for the sites your extension supports.",notifications:"Show desktop notifications the user has opted into.",contextMenus:"Add your own items to the right-click menu.",alarms:"Schedule background work at set intervals.",bookmarks:"Read or organise the user's bookmarks.",history:"Read or clear the user's browsing history.",downloads:"Start or manage file downloads on the user's behalf.",clipboardWrite:"Copy text to the clipboard when the user asks.",webRequest:"Observe network requests to filter or modify them.",webRequestBlocking:"Block or redirect requests synchronously. MV2-only — in Manifest V3 use declarativeNetRequest instead; this permission alone can fail the review on a new submission.",declarativeNetRequest:"Block or modify network requests via static rules — the MV3 replacement for blocking webRequest.",identity:"Sign the user in with their existing Google account. Heads-up: requesting OAuth scopes triggers a separate Google security/verification review that can take weeks — start it early.",debugger:"Attach to the DevTools protocol. High-risk: reviewers scrutinise this closely and it's rejected unless the core feature genuinely needs it.",nativeMessaging:"Talk to a companion app installed on the user's machine. Near-automatic deep review — expect extra scrutiny and a longer timeline.",offscreen:"Run an offscreen document for DOM work a service worker can't do (audio, clipboard, parsing).",management:"Read or manage the user's other installed extensions. High-risk — justify narrowly or reviewers reject it.",proxy:"Control the browser's proxy settings. High-risk; expect close review.",tabCapture:"Capture the visible tab's audio/video — only after the user starts capture from your UI.",desktopCapture:"Capture the screen, a window, or a tab the user picks. Must be user-initiated each time."};function Is(t){const s=t.trim();return s.includes("://")||s.startsWith("*")||s==="<all_urls>"}function c0(t){const s=t.trim();return s==="<all_urls>"?!0:Is(s)?s.replace(/^\*?:\/\//,"").split("/")[0]==="*":!1}function d0(t){const s=t.trim();return s==="<all_urls>"?"Run on every site the user visits. Only request this if your extension truly needs it — reviewers scrutinise it closely.":c0(s)?`Run on a very broad set of sites (${s}). Reviewers treat broad host access like <all_urls> — narrow it to the exact origins you need, or use activeTab instead.`:Is(s)?`Run only on the specific sites this pattern matches (${s}).`:ju[s]??"Explain, in one plain sentence, exactly what this permission lets your extension do for the user."}function u0(t){const s=t.trim();return Is(s)||s in ju}const h0=["storage","activeTab","scripting","https://api.example.com/*"];function ia({perm:t}){return e.jsxs("div",{className:"reason",children:[e.jsx(Te,{}),e.jsxs("span",{children:[e.jsx("b",{children:e.jsx("code",{children:t})})," ",d0(t),u0(t)?null:e.jsx("span",{className:"bestfit",style:{marginLeft:8},children:"needs your wording"})]})]},t)}function wu({permissions:t=h0,onBack:s,onComplete:n}){const r=t.filter(Is),a=t.filter(o=>!Is(o));return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Ce,{size:26}),title:"Permissions",meta:"About 20 minutes · often missed",onBack:s,assistKey:"permissions-justification"}),e.jsxs("p",{className:"lead",children:["The store asks you to justify ",e.jsx("b",{children:"every permission"})," your extension requests. A clear, honest reason for each one is the difference between a smooth review and a rejection."]}),e.jsxs("p",{className:"lead dim",children:["These are read from your ",e.jsx("code",{children:"manifest.json"}),". Review the suggested justification for each and tighten it to match what your extension actually does."]}),e.jsxs("div",{className:"asknote",style:{marginTop:4},children:[e.jsx("b",{children:"Single-purpose policy:"})," every permission must serve your extension's one stated purpose. Unrelated permissions get rejected even when each is individually justified — it's one of the top rejection causes."]}),e.jsx("div",{className:"seclabel",children:"API permissions you request"}),a.length===0?e.jsx("p",{className:"lead dim",children:"Your manifest requests no API permissions to justify here."}):e.jsx("div",{className:"reasons",children:a.map(o=>e.jsx(ia,{perm:o},o))}),e.jsx("div",{className:"seclabel",children:"Host permissions"}),r.length===0?e.jsx("p",{className:"lead dim",children:"Your manifest requests no host permissions — the easiest possible review on this axis."}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"lead dim",children:["Host permissions are submitted in a ",e.jsx("b",{children:"separate field"})," on the dashboard and scrutinised the hardest — narrow them to the exact origins you need."]}),e.jsx("div",{className:"reasons",children:r.map(o=>e.jsx(ia,{perm:o},o))})]}),t.length===0&&e.jsx("p",{className:"lead dim",children:"Your manifest requests no special permissions — there's nothing to justify. That's the easiest possible review."}),e.jsx("div",{className:"asknote",style:{marginTop:14},children:"Rule of thumb: if you can't explain why a permission helps the user, remove it. Fewer permissions means a faster review and more installs."}),e.jsx(de,{assistKey:"permissions-justification",topicName:"Permissions"}),e.jsx(he,{label:"My permissions are justified",note:"Reviewers read these. Vague or copy-pasted reasons are the most common rejection.",onComplete:()=>{n==null||n(),s()}})]})}const bT=Object.freeze(Object.defineProperty({__proto__:null,PermissionRow:ia,PermissionsJustificationScreen:wu},Symbol.toStringTag,{value:"Module"}));function _u({onBack:t,onComplete:s}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Ie,{size:26}),title:"Privacy policy",meta:"About 20 minutes · disclosure required for every extension",onBack:t,assistKey:"privacy-policy"}),e.jsxs("p",{className:"lead",children:["A privacy policy at a public URL is required for any extension that accesses user data. Separately, ",e.jsx("b",{children:"every"})," extension must complete the data-use disclosure in the dashboard — even one that collects nothing has to declare that. Mismatches between the policy and the disclosure get flagged."]}),e.jsx("p",{className:"lead dim",children:`Even if you collect almost nothing, you still declare that — "we don't collect personal data" is a valid, common policy.`}),e.jsx("div",{className:"seclabel",children:'The "Privacy practices" tab'}),e.jsxs("p",{className:"lead dim",children:["The disclosure lives on the dashboard's ",e.jsx("b",{children:"Privacy practices"})," tab. You can't submit until you check its three mandatory certifications:"]}),e.jsxs(ee,{children:[e.jsx(O,{lead:"You don't sell or transfer data to third parties",children:"outside of approved use cases."}),e.jsx(O,{lead:"You don't use or transfer data for purposes unrelated",children:"to your extension's single purpose."}),e.jsx(O,{lead:"You don't use or transfer data to determine creditworthiness",children:"or for lending purposes."})]}),e.jsx("div",{className:"seclabel",children:"Your policy must cover"}),e.jsxs(ee,{children:[e.jsx(O,{lead:"What you collect.",children:"List the categories of data — settings, content the user enters, usage analytics — in plain terms."}),e.jsx(O,{lead:"Why you collect it.",children:"Tie each category to a feature. The store cross-checks this against your permission justifications."}),e.jsx(O,{lead:"Where it goes.",children:"Whether data stays on the device, syncs to the user's account, or is sent to a server you run or a third party."}),e.jsx(O,{lead:"How users can reach you.",children:"A contact method for privacy questions or deletion requests."})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"Hosted at a public URL"}),e.jsx("span",{className:"chip",children:"Linked in the dashboard"}),e.jsx("span",{className:"chip",children:"Matches your data disclosure"})]}),e.jsx(de,{assistKey:"privacy-policy",topicName:"Privacy policy"}),e.jsx(he,{label:"My privacy policy is published and linked",note:"Keep the policy URL live — a dead link can get the listing taken down later.",onComplete:()=>{s==null||s(),t()}})]})}const xT=Object.freeze(Object.defineProperty({__proto__:null,ExtensionPrivacyPolicyScreen:_u},Symbol.toStringTag,{value:"Module"}));function ku({onBack:t,onComplete:s}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Ce,{size:26}),title:"OAuth & sign-in verification",meta:"Days to weeks · a separate review from the store listing",onBack:t,assistKey:"oauth-verification"}),e.jsxs("p",{className:"lead",children:["If your extension signs users in with Google, the OAuth"," ",e.jsx("b",{children:"consent screen"})," goes through its own verification — separate from, and slower than, the Chrome Web Store listing review. Plan for it early; it's the step that surprises people the week they hoped to launch."]}),e.jsx("p",{className:"lead dim",children:"This only applies if you request Google account access. Sign-in handled entirely by your own backend, or no sign-in at all, skips this gate completely."}),e.jsxs("div",{className:"asknote",style:{marginTop:4},children:[e.jsx("b",{children:"Two reviews, two timelines:"})," the store reviews your extension listing; Google separately reviews the ",e.jsx("b",{children:"OAuth consent screen"})," tied to your Cloud project. Approval on one is not approval on the other."]}),e.jsx("div",{className:"seclabel",children:"How long depends on the scopes you ask for"}),e.jsxs(ee,{children:[e.jsx(O,{lead:"Non-sensitive scopes (email, profile).",children:"Basic sign-in. No verification wait — your consent screen works for everyone as soon as you publish it."}),e.jsx(O,{lead:"Sensitive scopes (Gmail, Drive, Calendar).",children:"Require app verification. Expect a multi-day to multi-week review and a justification for why you need each scope."}),e.jsx(O,{lead:"Restricted scopes (full mailbox, all files).",children:"Pull in an annual third-party security assessment that can run weeks and cost real money. Avoid unless your product truly needs them."})]}),e.jsx("div",{className:"seclabel",children:"Before you submit for verification"}),e.jsxs(ee,{children:[e.jsx(O,{lead:"Request the narrowest scope that works.",children:"Drop from a restricted scope to a sensitive one, or a sensitive one to a non-sensitive one, wherever your feature allows — it's the single biggest lever on review time."}),e.jsx(O,{lead:"Verify your domain and publish a privacy policy.",children:"Verified ownership of every domain on the consent screen and a live policy URL are prerequisites — the same policy your listing needs."}),e.jsx(O,{lead:"Match scopes to your permission justifications.",children:"Reviewers cross-check the OAuth scopes against the case you make on the Permissions topic. Inconsistencies stall both reviews."})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"Separate from the store review"}),e.jsx("span",{className:"chip",children:"Sensitive scopes = verification"}),e.jsx("span",{className:"chip",children:"Restricted scopes = security assessment"})]}),e.jsx(de,{assistKey:"oauth-verification",topicName:"OAuth & sign-in verification"}),e.jsx(he,{label:"My OAuth scopes and consent screen are ready",note:"Start verification as early as you can — it runs in parallel with everything else and is the most common launch-day surprise.",onComplete:()=>{s==null||s(),t()}})]})}const yT=Object.freeze(Object.defineProperty({__proto__:null,OAuthVerificationScreen:ku},Symbol.toStringTag,{value:"Module"}));function Su({onBack:t,onComplete:s}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Ie,{size:26}),title:"Single purpose & listing quality",meta:"About 30 minutes · two of the top rejection causes",onBack:t,assistKey:"single-purpose-listing"}),e.jsxs("p",{className:"lead",children:["Every extension must have a ",e.jsx("b",{children:"single, narrow purpose"}),", and your listing has to describe it clearly. Bundling unrelated features, or a vague/keyword-stuffed listing, are among the most common reasons a submission gets rejected — both before you ever reach a human reviewer and during manual review."]}),e.jsx("p",{className:"lead dim",children:"Write your one-sentence purpose first. Everything else — permissions, the description, the category — should follow from it."}),e.jsx("div",{className:"seclabel",children:"The single-purpose policy"}),e.jsxs(ee,{children:[e.jsx(O,{lead:"One narrow purpose, stated in a sentence.",children:`"Save articles to read later," not "a toolkit for productivity." If you can't say it in one sentence, it's probably two extensions.`}),e.jsx(O,{lead:"No unrelated functionality.",children:"A second, tangential feature — even a useful one — gets the whole extension rejected. Ship it separately if it doesn't serve the one purpose."}),e.jsx(O,{lead:"Permissions trace back to that purpose.",children:"Every permission you request should obviously serve the stated purpose, which is exactly what the Permissions topic asks you to justify."})]}),e.jsx("div",{className:"seclabel",children:"Listing quality"}),e.jsxs(ee,{children:[e.jsx(O,{lead:"A description that says what it does, not what it's like.",children:"Lead with the purpose and the concrete value. Reviewers and users both bounce off generic marketing copy."}),e.jsx(O,{lead:"The right category.",children:"Pick the category that matches the purpose. A mismatched category is a flag and hurts discovery."}),e.jsx(O,{lead:"No keyword stuffing or misleading claims.",children:`Repeated keywords in the title/description, fake "official" branding, or features you don't actually have are explicit policy violations.`})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"One sentence, one purpose"}),e.jsx("span",{className:"chip",children:"Description matches behavior"}),e.jsx("span",{className:"chip",children:"Honest title & category"})]}),e.jsx(de,{assistKey:"single-purpose-listing",topicName:"Single purpose & listing quality"}),e.jsx(he,{label:"My purpose is narrow and my listing reflects it",note:"Re-read your listing as a skeptical reviewer: does it promise exactly what the extension does, and nothing more?",onComplete:()=>{s==null||s(),t()}})]})}const vT=Object.freeze(Object.defineProperty({__proto__:null,SinglePurposeListingScreen:Su},Symbol.toStringTag,{value:"Module"}));function Nu({onBack:t,onComplete:s}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Dt,{size:26}),title:"Manifest & versioning",meta:"About 15 minutes · enforced before review even starts",onBack:t,assistKey:"manifest-versioning"}),e.jsxs("p",{className:"lead",children:["Your ",e.jsx("code",{children:"manifest.json"})," has to satisfy a few hard rules before the store will accept an upload at all — these checks run"," ",e.jsx("b",{children:"before"})," any human review. Getting them right means your Submit step goes through on the first try instead of bouncing."]}),e.jsx("p",{className:"lead dim",children:"These are mechanical, not judgment calls — but each one rejects the upload outright, with an error that isn't always obvious."}),e.jsx("div",{className:"seclabel",children:"The rules the store enforces"}),e.jsxs(ee,{children:[e.jsxs(O,{lead:"Manifest V3 is required.",children:[e.jsx("code",{children:'"manifest_version": 3'}),". V2 is no longer accepted for new uploads — a service worker replaces the old background page, and blocking ",e.jsx("code",{children:"webRequest"})," is gone."]}),e.jsxs(O,{lead:"The version must strictly increase on every upload.",children:["Bump ",e.jsx("code",{children:"version"})," for each upload — the store rejects a re-used or lower number. This is the most common upload failure: forgetting to bump after a fix."]}),e.jsxs(O,{lead:"Use a valid version format.",children:["One to four dot-separated integers (e.g. ",e.jsx("code",{children:"1.2.0"}),"). Each part is compared numerically, so ",e.jsx("code",{children:"1.10"})," is newer than"," ",e.jsx("code",{children:"1.9"}),"."]})]}),e.jsx("div",{className:"seclabel",children:"Worth setting deliberately"}),e.jsxs(ee,{children:[e.jsx(O,{lead:"minimum_chrome_version.",children:"Set it to the oldest Chrome you actually support. The store won't offer the extension to older browsers — sparing those users a version that would break for them."}),e.jsxs(O,{lead:"Keep name, description, and icons in sync.",children:["The manifest's ",e.jsx("code",{children:"name"}),"/",e.jsx("code",{children:"description"})," seed your listing, and the icon set here is what the store and toolbar render."]})]}),e.jsxs("div",{className:"chips",children:[e.jsx("span",{className:"chip",children:"manifest_version: 3"}),e.jsx("span",{className:"chip",children:"version strictly increases"}),e.jsx("span",{className:"chip",children:"minimum_chrome_version set"})]}),e.jsx(de,{assistKey:"manifest-versioning",topicName:"Manifest & versioning"}),e.jsx(he,{label:"My manifest is MV3 and the version is bumped",note:"Bumping the version is the easiest step to forget — make it part of your build, not a manual afterthought.",onComplete:()=>{s==null||s(),t()}})]})}const jT=Object.freeze(Object.defineProperty({__proto__:null,ManifestVersioningScreen:Nu},Symbol.toStringTag,{value:"Module"}));function Cu({onBack:t,onComplete:s}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Ze,{size:26}),title:"Submit for review",meta:"About 15 minutes · then a review wait",onBack:t,assistKey:"submit-review"}),e.jsx("p",{className:"lead",children:"Last step: package your extension, upload it, and submit for review. Once you submit, the Chrome Web Store checks your listing against its policies before it goes public."}),e.jsx("div",{className:"seclabel",children:"Packaging & submitting"}),e.jsxs(ee,{children:[e.jsx(O,{lead:"Build and zip the extension.",children:"Produce your production build and zip its folder — the zip is what you upload, not the source repository."}),e.jsxs(O,{lead:"Put manifest.json at the zip root.",children:["The ",e.jsx("code",{children:"manifest.json"})," must sit at the top level of the zip, not inside a nested folder. Zipping the parent directory instead of its contents is a top first-upload failure."]}),e.jsx(O,{lead:"Upload and fill in the listing.",children:"Drop the zip into the dashboard, then complete the description, category, assets, and the data-use disclosure."}),e.jsx(O,{lead:"Choose visibility and rollout.",children:"At submit time you pick the distribution — public, unlisted, or private — and can stage a percentage rollout to release gradually."}),e.jsx(O,{lead:"Submit for review.",children:"Once everything validates, submit. You can't edit a submission while it's under review — but you can keep developing and submit a new version, and a rejection doesn't lose your draft."})]}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"What to expect"}),e.jsxs(ee,{children:[e.jsx(O,{lead:"Timelines vary — hours to weeks.",children:"Many reviews clear in hours to a few days, but a new publisher account, broad host permissions, remote code, or OAuth scopes can push it to weeks. Plan for the longer end if any of those apply."}),e.jsx(O,{lead:"Rejections come with a reason.",children:"If it's rejected, the store says why. The usual culprits are permission justifications and the privacy policy — both covered in the earlier steps."})]}),e.jsx(or,{}),e.jsx(de,{assistKey:"submit-review",topicName:"Submit for review"}),e.jsx(he,{label:"I've submitted for review",note:"Once approved, your store listing link is what you share to install the extension.",onComplete:()=>{s==null||s(),t()}})]})}const wT=Object.freeze(Object.defineProperty({__proto__:null,SubmitReviewScreen:Cu},Symbol.toStringTag,{value:"Module"})),p0=[{q:"Can my testers just double-click a file to install it?",a:"Not for the load-unpacked path — Chrome blocks installing extensions from a double-clicked file outside the Web Store. Each tester opens the browser's extensions page, turns on Developer mode, and chooses “Load unpacked” on the folder. If you want a one-click install link, use an unlisted Web Store listing instead."},{q:"Will the extension update itself for my testers?",a:"Only the unlisted Web Store listing auto-updates — you upload a new version and Chrome pushes it to everyone with the link. A load-unpacked build never auto-updates: you re-send the zip and each tester reloads it. A self-hosted .crx can auto-update via its update_url, but that path is really for managed/enterprise installs."},{q:`Do I need the ${re("chromeStore.fee").value} developer account just to share with my team?`,a:`Not for the zip / load-unpacked handoff — that needs no account at all. You only need the one-time ${re("chromeStore.fee").value} developer account if you want the unlisted-listing path (link-shareable, auto-updating, and trusted by Chrome).`}];function Tu({onBack:t,onComplete:s}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{icon:e.jsx(Ze,{size:26}),title:"Share with testers",meta:"About 10 minutes · no public listing",onBack:t,assistKey:"share-testing"}),e.jsx("p",{className:"lead",children:"Want a few people to try your extension before it's public? You don't have to go through the Chrome Web Store review. There are three ways to hand a build to testers — from a zip you email today, to a private store listing that auto-updates, to a self-hosted package for managed fleets. Pick by how many testers you have and whether they need updates."}),e.jsx("div",{className:"seclabel",children:"Load unpacked (zip handoff)"}),e.jsxs(ee,{children:[e.jsx(O,{lead:"Build, zip, and send it.",children:"Produce your production build and zip the output folder. Each tester opens the browser's extensions page, enables Developer mode, and chooses “Load unpacked” on the unzipped folder. No account, no review — it works the moment they load it."}),e.jsxs(O,{lead:"Put manifest.json at the zip root.",children:["The ",e.jsx("code",{children:"manifest.json"})," must sit at the top level of the unzipped folder, not inside a nested directory — the same gotcha that trips up store uploads."]}),e.jsxs(O,{lead:"Know the trade-offs.",children:["There is ",e.jsx("b",{children:"no auto-update"})," — to ship a fix you re-send the zip and testers reload it. Chrome also shows a persistent “disable developer-mode extensions” warning, which can confuse non-technical testers. Best for a handful of trusted people on a short loop."]})]}),e.jsx(Ot,{assistKey:"share-testing",topicName:"Share with testers",goalId:"zip-load-unpacked",buttonLabel:'Ask AI to help with the "Load Unpacked (Zip Handoff)" goal'}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Unlisted / private Web Store listing"}),e.jsxs(ee,{children:[e.jsxs(O,{lead:"Upload to the store, but hide it.",children:["You still upload to the Chrome Web Store, but set visibility to"," ",e.jsx("b",{children:"Unlisted"})," (link-shareable, not discoverable in search) or"," ",e.jsx("b",{children:"Private"})," (restricted to named testers). Anyone with the link installs in one click — no Developer mode, no warning."]}),e.jsx(O,{lead:"It auto-updates and is trusted by Chrome.",children:"Push a new version and the store delivers it to every tester automatically. Because it's a real store install, Chrome trusts it — none of the unpacked-build friction."}),e.jsxs(O,{lead:"It still needs the one-time developer account.",children:["An unlisted listing requires the same"," ",e.jsx("b",{children:re("chromeStore.fee").value})," developer registration as a public one (see the ",e.jsx("b",{children:"Store accounts"})," topic). An unlisted listing also still goes through review — it just isn't publicly discoverable once approved."]})]}),e.jsx(Ot,{assistKey:"share-testing",topicName:"Share with testers",goalId:"unlisted-listing",buttonLabel:'Ask AI to help with the "Unlisted / Private Web Store Listing" goal'}),e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Self-hosted .crx + update_url (advanced)"}),e.jsxs(ee,{children:[e.jsxs(O,{lead:"Host the packed .crx and an update manifest.",children:["Pack the extension to a ",e.jsx("code",{children:".crx"}),", host it alongside an update manifest, and point the manifest's ",e.jsx("code",{children:"update_url"})," at it. This is the only path that needs no store account at all."]}),e.jsxs(O,{lead:"Chrome blocks off-store .crx for ordinary users.",children:["For a normal browser profile, Chrome refuses to install an off-store",e.jsx("code",{children:".crx"}),". This path really exists for"," ",e.jsx("b",{children:"managed / enterprise"})," force-install via admin policy (e.g. a company's device management) — not for casual beta testers."]})]}),e.jsx(Ot,{assistKey:"share-testing",topicName:"Share with testers",goalId:"self-host-crx",buttonLabel:'Ask AI to help with the "Self-Hosted .crx + update_url (Advanced)" goal'}),e.jsx(De,{items:p0}),e.jsx(or,{}),e.jsx(he,{label:"I've shared a build with testers",note:"When you're ready for the public store, the store-accounts → submit-for-review chain takes it the rest of the way.",onComplete:()=>{s==null||s(),t()}})]})}const _T=Object.freeze(Object.defineProperty({__proto__:null,ExtensionDistributionScreen:Tu},Symbol.toStringTag,{value:"Module"}));function Et({tone:t="cost",title:s,children:n}){const r=t==="wait"?"⏳":t==="size"?"⬇":"$";return e.jsxs("div",{className:"sd-callout "+t,children:[e.jsx("span",{className:"sd-callout-ic","aria-hidden":"true",children:r}),e.jsxs("div",{children:[e.jsx("div",{className:"sd-callout-t",children:s}),e.jsx("div",{className:"sd-callout-b",children:n})]})]})}function Ye({store:t,badge:s,children:n}){const r=t==="ios"?"Apple App Store":"Google Play",a=t==="ios"?"":"▶";return e.jsxs("div",{className:"sd-store "+t,children:[e.jsx("div",{className:"sd-store-mark","aria-hidden":"true",children:a}),e.jsxs("div",{className:"sd-store-body",children:[e.jsxs("div",{className:"sd-store-top",children:[e.jsx("span",{className:"sd-store-name",children:r}),e.jsx("span",{className:"sd-store-badge",children:s})]}),e.jsx("div",{className:"sd-store-desc",children:n})]})]})}function Lt({items:t}){return e.jsx("div",{className:"sd-checks",children:t.map((s,n)=>e.jsxs("div",{className:"sd-check",children:[e.jsx(Te,{}),e.jsx("span",{children:s})]},n))})}const kT=Object.freeze(Object.defineProperty({__proto__:null,CheckList:Lt,CostCallout:Et,StoreCard:Ye},Symbol.toStringTag,{value:"Module"}));function Zt(t){return t==="ios"||t==="both"}function ps(t){return t==="android"||t==="both"}const m0=["swift","swiftui","ios","uikit"],f0=["kotlin","android","jetpack-compose"];function g0(t){if(!t)return"both";const s=t.platforms;if(Array.isArray(s)){const r=s.some(o=>String(o).toLowerCase().includes("ios")),a=s.some(o=>String(o).toLowerCase().includes("android"));if(r&&!a)return"ios";if(a&&!r)return"android";if(r||a)return"both"}const n=String(t.framework??"").toLowerCase();if(n){const r=m0.some(o=>n.includes(o)),a=f0.some(o=>n.includes(o));if(r&&!a)return"ios";if(a&&!r)return"android"}return"both"}function Pu({platform:t="both",onBack:s,onComplete:n}){const r=Zt(t),a=ps(t),o=[{q:"Do I really have to pay before I can ship?",a:"Yes — there's no free tier for publishing to the stores. Apple charges $99/year and Google a one-time $25. You can build and test for free; the fee is the gate to actually listing the app."},{q:"How long does verification take?",a:"Anywhere from a few hours to several days for identity checks. The slow part is organisation/business verification — and if you need a brand-new D-U-N-S number for Apple, that alone can take up to ~2 weeks. Start it well before your planned launch."},{q:"Why is my Play account stuck in closed testing?",a:"Personal Google Play accounts created after 2023-11-13 must run a closed test with at least 12 testers opted in for 14 continuous days before they can request production access. If your tester count drops below 12, the 14-day clock resets. Organisation accounts are generally not subject to this."},{q:"Do I need a Mac to ship an iOS app?",a:"Practically, yes — building, signing, and uploading an iOS build needs Xcode, which only runs on macOS. You can write the code anywhere, but the final build and submission step expects a Mac (or a cloud Mac/CI service)."},{q:"Can I publish to just one store first?",a:"Absolutely. Many teams ship to one platform to start. Enrol only in the account you need now — you can add the other later without redoing anything."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{onBack:s,icon:e.jsx(Ce,{size:26}),title:"Developer accounts",meta:"One-time setup · paid · about 20 minutes",assistKey:"dev-accounts"}),e.jsx("p",{className:"lead",children:"Before an app can reach the stores, you have to enrol as a developer with each company you ship to. This is the account that owns your app, signs your builds, and gets paid out — so it's worth doing carefully and once."}),e.jsxs(Et,{tone:"cost",title:"These accounts cost money up front",children:["Plan for this before you start — there's no free tier for publishing.",r&&a?" Together that's $99 the first year plus a one-time $25.":""]}),e.jsx("div",{className:"seclabel",children:"What to set up"}),r?e.jsxs(Ye,{store:"ios",badge:re("appleDeveloper.fee").value,children:["Enrol in the ",e.jsx("b",{children:"Apple Developer Program"})," at developer.apple.com. The membership renews yearly; let it lapse and your apps are pulled from sale. Enrolling as an organisation needs a D-U-N-S number — if you don't already have one, issuance can take ",e.jsx("b",{children:"up to ~2 weeks"}),", so start this well before your planned launch."]}):null,a?e.jsxs(Ye,{store:"android",badge:re("googlePlay.fee").value,children:["Register for the ",e.jsx("b",{children:"Google Play Console"})," at play.google.com/console. The fee is one-time, not yearly. ",re("playStore.closedTestGate").value," ","— and if your tester count drops below 12, the 14-day clock resets. Organisation accounts are generally not subject to this gate. Factor the closed-test window into your timeline."]}):null,e.jsx(Et,{tone:"wait",title:"Verification isn't instant",children:"Identity and (for organisations) business verification can take anywhere from a few hours to several days. Get this out of the way before you're ready to ship, not the night before."}),e.jsx(De,{items:o}),e.jsx(he,{label:"Mark developer accounts as set up",note:"Do this once you've enrolled and your account is verified.",onComplete:()=>n==null?void 0:n()})]})}const ST=Object.freeze(Object.defineProperty({__proto__:null,DevAccountsScreen:Pu},Symbol.toStringTag,{value:"Module"}));function Ou({platform:t="both",onBack:s,onComplete:n}){const r=Zt(t),a=ps(t),o=[{q:"Do my screenshots have to be the exact pixel sizes?",a:"For the required sets, yes — App Store Connect rejects the wrong dimensions. Capture on the 6.9″ iPhone simulator (1320×2868) and Apple scales that master down for the smaller phones; the older 6.7″/6.5″ sizes are still accepted if that's all you have."},{q:"Why does my Google Play listing keep getting rejected?",a:"The most common cause is a missing feature graphic (1024×500) — it's mandatory and easy to forget — or placeholder/lorem-ipsum screens. Make sure the 512×512 icon, the feature graphic, and at least two real phone screenshots are all uploaded."},{q:"Do I need separate icons for each store?",a:"Yes, at different sizes: a 1024×1024 master for the App Store and a 512×512 icon for Google Play. Both must be square PNGs with no transparency and no pre-rounded corners — the stores round them for you."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{onBack:s,icon:e.jsx(Dt,{size:26}),title:"Store assets",meta:"Design work · about 1–2 hours",assistKey:"store-assets"}),e.jsx("p",{className:"lead",children:"Every store listing needs artwork: a high-resolution app icon, a set of screenshots, and some promo imagery. The stores reject submissions with the wrong sizes or placeholder art, so it's worth getting these right before you submit."}),e.jsx("div",{className:"seclabel",children:"The essentials, everywhere"}),e.jsx(Lt,{items:[e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"App icon"})," — a square PNG with no transparency and no rounded corners (the stores round them for you). Apple wants a 1024×1024 master; Google Play wants a 512×512 icon — export both, not one size everywhere."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Screenshots"})," — captured on the exact device sizes each store asks for, not scaled-up phone shots."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"No placeholder art"}),' — "lorem ipsum" screens and stock icons are the most common rejection reason.']})]}),e.jsx("div",{className:"seclabel",children:"Per store"}),r?e.jsxs(Ye,{store:"ios",badge:re("appleScreenshots.iphone").value,children:["The App Store's primary iPhone set is now the ",e.jsx("b",{children:"6.9″ (1320×2868)"})," ","size — capture on that simulator and Apple scales the master down for smaller phones. The older 6.7″/6.5″ sizes (1290×2796, 1242×2688) are still accepted as a fallback. If your app supports iPad, also provide the ",re("appleScreenshots.ipad").value," master. App previews (short videos) are optional but help conversion."]}):null,a?e.jsxs(Ye,{store:"android",badge:"512×512 icon + feature graphic",children:["Google Play needs a ",e.jsx("b",{children:"512×512"})," icon (not the 1024×1024 iOS master), a 1024×500 ",e.jsx("b",{children:"feature graphic"})," (the banner at the top of your listing — easy to forget), and at least two phone screenshots. The feature graphic is mandatory; the listing won't publish without it."]}):null,e.jsx(De,{items:o}),e.jsx(de,{assistKey:"store-assets",topicName:"Store assets"}),e.jsx(he,{label:"Mark store assets as ready",note:"Do this once your icon and screenshots are exported at the right sizes.",onComplete:()=>n==null?void 0:n()})]})}const NT=Object.freeze(Object.defineProperty({__proto__:null,StoreAssetsScreen:Ou},Symbol.toStringTag,{value:"Module"}));function Au({platform:t="both",onBack:s,onComplete:n}){const r=Zt(t),a=ps(t);return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{onBack:s,icon:e.jsx(Ie,{size:26}),title:"Store listing",meta:"Writing + forms · about 45 minutes",assistKey:"store-listing"}),e.jsx("p",{className:"lead",children:"The listing is how people decide whether to install. It's your title and subtitle, the description, a category, and a keyword set — plus the privacy disclosures the stores now require. The writing sells; the privacy form is a hard gate."}),e.jsx("div",{className:"seclabel",children:"Write these"}),e.jsx(Lt,{items:[e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Title & subtitle"})," — clear over clever. The first few words are what shows in search results."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Description"})," — lead with what the app does and who it's for; keep the keyword-stuffing out, both stores penalise it."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Category"})," — pick the one your app actually fits; it affects where you rank."]})]}),e.jsx("div",{className:"seclabel",children:"Privacy is required now"}),r?e.jsxs(Ye,{store:"ios",badge:"Nutrition labels",children:["Apple's ",e.jsx("b",{children:'privacy "nutrition labels"'})," ask you to declare exactly what data your app collects and how it's used. You fill these in App Store Connect; they show on your listing. Misdeclaring is grounds for removal, so answer them honestly."]}):null,a?e.jsxs(Ye,{store:"android",badge:"Data safety form",children:["Google Play's ",e.jsx("b",{children:"Data safety"})," form covers the same ground — collection, sharing, and security practices. It's mandatory; the listing can't go live until it's complete and consistent with what your app actually does."]}):null,e.jsx(de,{assistKey:"store-listing",topicName:"Store listing"}),e.jsx(he,{label:"Mark store listing as drafted",note:"Do this once your copy is written and the privacy form is filled in.",onComplete:()=>n==null?void 0:n()})]})}const CT=Object.freeze(Object.defineProperty({__proto__:null,StoreListingScreen:Au},Symbol.toStringTag,{value:"Module"}));function Ru({platform:t="both",onBack:s,onComplete:n}){const r=Zt(t),a=ps(t),o=[{q:"How long does the first store review really take?",a:"Once you're set up, per-update reviews are fast — Apple usually within a day, Google often within hours. The slow one is a new Google Play account's first production-access approval, which can take ~7 days on top of the closed-testing gate. Plan your launch date around that first approval, not the steady-state speed."},{q:"Why is my Play app stuck before I can go to production?",a:re("playStore.closedTestGate").value+" — and the 14-day clock resets if the tester count drops below 12. Organisation accounts are generally not subject to this gate."},{q:"How many testers can I have?",a:"On TestFlight, up to 100 internal testers (your team) and up to 10,000 external testers. On Google Play, internal testing is a small email list, while closed/open tracks scale much larger."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{onBack:s,icon:e.jsx(Ze,{size:26}),title:"Testing & distribution",meta:"Build + review · hours to days",assistKey:"testing-distribution"}),e.jsx("p",{className:"lead",children:"Before you release to everyone, you put a build in front of a small group of testers, then submit that build for the store's review. Both steps use the store's own tooling — you don't email APKs around."}),e.jsxs(Et,{tone:"size",title:"First native build pulls a large SDK",children:["Producing a real device build downloads the platform toolchain — often",e.jsx("b",{children:" 8–12 GB"})," and ",e.jsx("b",{children:"10–30 minutes"})," the first time. Run the iOS pre-flight checks in ",e.jsx("code",{children:"MOBILE_SETUP.md"})," before you kick it off so a missing platform SDK surfaces in seconds, not ten minutes in."]}),e.jsx("div",{className:"seclabel",children:"Get a build to testers"}),r?e.jsxs(e.Fragment,{children:[e.jsxs(Ye,{store:"ios",badge:"TestFlight",children:["Upload to ",e.jsx("b",{children:"TestFlight"})," from Xcode or your CI. Internal testers (up to 100 on your team) get builds instantly; ",e.jsx("b",{children:"external testers go up to 10,000"}),` and go through a lighter "beta" review first. This is also how you sanity-check the exact binary you'll submit.`]}),e.jsx(Ot,{assistKey:"testing-distribution",topicName:"Testing & distribution",goalId:"prep-testflight",buttonLabel:"Ask AI to help: Prep a TestFlight upload"})]}):null,a?e.jsxs(e.Fragment,{children:[e.jsxs(Ye,{store:"android",badge:"Internal testing",children:["Use a Play Console ",e.jsx("b",{children:"internal testing"})," track for instant distribution to a list of tester emails. Promote the same build up through closed → open → production tracks as your confidence grows. Note the production gate: ",re("playStore.closedTestGate").value," ","(the 14-day clock resets below 12). Organisation accounts are generally not subject to this."]}),e.jsx(Ot,{assistKey:"testing-distribution",topicName:"Testing & distribution",goalId:"prep-play-internal",buttonLabel:"Ask AI to help: Set up Play internal testing"})]}):null,e.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Get ready for store review"}),e.jsx("p",{className:"lead",children:"Before you submit, run a pre-review pass across the stores you target: your privacy / data-safety answers match what the code actually does, the required usage-description strings are present, no debug or placeholder content ships, and deep links and permissions really work. Submitting a clean build is the fastest way through review."}),e.jsxs(Et,{tone:"wait",title:"Review takes real time",children:["Store review is a human process. Once you're established, per-update reviews are quick — Apple typically within a day, Google often within hours. The slow one is a ",e.jsx("b",{children:"new Google Play account's first production-access approval (~7 days)"}),", separate from and on top of the closed-testing gate. Build that first approval into your launch date — you can't rush it."]}),e.jsx(Ot,{assistKey:"testing-distribution",topicName:"Testing & distribution",goalId:"prep-store-review",buttonLabel:"Ask AI to help: Get ready for store review"}),e.jsx(De,{items:o}),e.jsx(he,{label:"Mark testing & distribution as set up",note:"Do this once a build is on a test track and you know the review path.",onComplete:()=>n==null?void 0:n()})]})}const TT=Object.freeze(Object.defineProperty({__proto__:null,TestingDistributionScreen:Ru},Symbol.toStringTag,{value:"Module"}));function Eu({platform:t="both",onBack:s,onComplete:n}){const r=Zt(t),a=ps(t),o=[{q:"Can I test push on the iOS simulator?",a:"Partly. Xcode 14+/macOS 13+ simulators can receive a payload you drag onto them, but real end-to-end APNs delivery is unreliable on the simulator. Verify real delivery on a physical device before you rely on it."},{q:"Why aren't my notifications showing up?",a:"The most common reason is that the user never granted permission — on iOS notifications are off until they explicitly opt in, and Android 13+ also needs a runtime permission prompt. Check the permission state first, then your APNs key / FCM token wiring."},{q:"Do I have to add push before I launch?",a:"No — push is optional. If your app doesn't need to reach people while it's closed, skip it. You can add APNs/FCM later without resubmitting the rest of your setup."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{onBack:s,icon:e.jsx(Ja,{size:26}),title:"Push notifications",meta:"Optional · about 1 hour",assistKey:"push-notifications"}),e.jsx("p",{className:"lead",children:"Push lets your app reach people when it's closed. Each platform has its own delivery service you register with — you don't send notifications directly, you hand them to Apple or Google to deliver."}),e.jsx("div",{className:"seclabel",children:"The delivery services"}),r?e.jsxs(Ye,{store:"ios",badge:"APNs",children:["Apple's ",e.jsx("b",{children:"Push Notification service (APNs)"}),". You create an APNs key or certificate in your developer account and register your app's capability in Xcode. On iOS the user must explicitly grant permission — notifications are off until they say yes."]}):null,a?e.jsxs(Ye,{store:"android",badge:"FCM",children:["Google's ",e.jsx("b",{children:"Firebase Cloud Messaging (FCM)"}),". Add the Firebase config to your app and use the FCM token to target a device. Android 13+ also requires a runtime permission prompt, so don't assume delivery without it."]}):null,e.jsx("div",{className:"seclabel",children:"Get this right"}),e.jsx(Lt,{items:[e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Ask at the right moment."})," Prompt for permission when the value is obvious, not on first launch — a denied prompt is hard to recover."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Make them opt-in and useful."})," Noisy notifications get your app muted or uninstalled."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Test on a real device."})," Push is unreliable on the iOS simulator — Xcode 14+/macOS 13+ can receive a dropped payload, but verify real delivery on a physical device."]})]}),e.jsx(De,{items:o}),e.jsx(de,{assistKey:"push-notifications",topicName:"Push notifications"}),e.jsx(he,{label:"Mark push notifications as set up",note:"Optional — skip it if your app doesn't need to reach people when closed.",onComplete:()=>n==null?void 0:n()})]})}const PT=Object.freeze(Object.defineProperty({__proto__:null,PushNotificationsScreen:Eu},Symbol.toStringTag,{value:"Module"}));function Mu({platform:t="both",onBack:s,onComplete:n}){return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{onBack:s,icon:e.jsx(jt,{size:26}),title:"Crash reporting",meta:"Recommended · about 30 minutes",assistKey:"crash-reporting"}),e.jsx("p",{className:"lead",children:"Once real people run your app, some of them will hit crashes you never saw in testing — on devices and OS versions you don't own. Crash reporting captures those automatically so you find out before the one-star reviews do."}),e.jsx("div",{className:"seclabel",children:"What you'll get"}),e.jsx(Lt,{items:[e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Stack traces"})," pointing at the exact line that failed, grouped so you see which crash hits the most people first."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Device context"})," — OS version, model, and steps — so you can reproduce instead of guessing."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Trends over time"})," so you can tell whether a release made things better or worse."]})]}),e.jsx("div",{className:"seclabel",children:"Common tools"}),e.jsxs("p",{className:"lead dim",children:[e.jsx("b",{children:"Firebase Crashlytics"})," (free, works on both platforms) and"," ",e.jsx("b",{children:"Sentry"})," (crashes plus broader error monitoring) are the usual starting points. Both drop in as an SDK; pick one and wire it once."]}),e.jsxs("div",{className:"sd-callout size",children:[e.jsx("span",{className:"sd-callout-ic","aria-hidden":"true",children:"⬇"}),e.jsxs("div",{children:[e.jsx("div",{className:"sd-callout-t",children:"Upload your symbols, or reports are noise"}),e.jsx("div",{className:"sd-callout-b",children:"Release builds are stripped, so a raw crash is unreadable hex. Upload the debug symbols (dSYMs on iOS, mapping files on Android) on every release — most SDKs automate this in CI — or your stack traces won't point at real code."})]})]}),e.jsx(de,{assistKey:"crash-reporting",topicName:"Crash reporting"}),e.jsx(he,{label:"Mark crash reporting as set up",note:"Do this once an SDK is wired in and symbol upload is part of your release.",onComplete:()=>n==null?void 0:n()})]})}const OT=Object.freeze(Object.defineProperty({__proto__:null,CrashReportingScreen:Mu},Symbol.toStringTag,{value:"Module"}));function Iu({platform:t="both",onBack:s,onComplete:n}){const r=Zt(t),a=ps(t),o=[{q:"Can't I just use Stripe like on the web?",a:"Not for digital goods consumed in the app — unlocking features, virtual currency, subscriptions. Those must go through the store's billing, and shipping a side payment link for them is one of the most common rejections. Stripe is fine for real-world goods and services (a ride, a physical product, an in-person class)."},{q:"Why is the commission lower in some cases?",a:"Both stores drop to 15% for most small developers — Apple's Small Business Program (under ~$1M/year) and Google's first $1M/year — and for subscriptions (Apple after the subscriber's first year, Google from day one). Above those thresholds the standard rate is 30%."},{q:"How do I test a purchase without being charged?",a:"Both stores have sandbox testers: Apple uses Sandbox Apple IDs in App Store Connect, Google uses license-test accounts in the Play Console. Purchases run end-to-end against test billing so you can verify the unlock flow without real money."},{q:"Do I have to verify the purchase on a server?",a:"For anything worth protecting, yes. Validate the store receipt / purchase token server-side before granting entitlements — a client-only check is trivially bypassed. Both platforms publish server-side verification APIs."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{onBack:s,icon:e.jsx(Pt,{size:26}),title:"In-app purchases & subscriptions",meta:"When you sell inside the app · about 30 minutes",assistKey:"in-app-purchases"}),e.jsxs("p",{className:"lead",children:["Selling anything digital inside your app — a subscription, a feature unlock, in-app currency — doesn't work like web checkout. The stores require you to use ",e.jsx("i",{children:"their"})," billing, take a cut, and reject apps that route around it. Getting this right early saves a painful rewrite later."]}),e.jsx(Et,{tone:"cost",title:"The store takes a commission on every sale",children:"Budget for it in your pricing from the start — the cut comes off the top of every transaction, before you see a cent."}),e.jsx("div",{className:"seclabel",children:"What you'll wire up"}),r?e.jsxs(Ye,{store:"ios",badge:re("appStore.commission").value,children:["Use ",e.jsx("b",{children:"StoreKit"})," (StoreKit 2 is the current API) to define products in App Store Connect and present the native purchase sheet. Apple's cut is ",re("appStore.commission").value,"."," ",e.jsx(Rt,{fact:re("appStore.commission")})]}):null,a?e.jsxs(Ye,{store:"android",badge:re("googlePlay.commission").value,children:["Use the ",e.jsx("b",{children:"Google Play Billing Library"})," to define products in the Play Console and launch the billing flow. Google's service fee is"," ",re("googlePlay.commission").value,"."," ",e.jsx(Rt,{fact:re("googlePlay.commission")})]}):null,e.jsx("div",{className:"seclabel",children:"The rule that gets apps rejected"}),e.jsx(Lt,{items:[e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Digital goods must use store billing."}),' Subscriptions, feature unlocks, virtual currency — all of it goes through StoreKit / Play Billing. A Stripe link or "pay on our website" prompt for these is a rejection.']}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Physical goods and real-world services don't."})," A ride, a shipped product, an in-person class — bill those however you like; the stores explicitly don't want their cut of those."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Verify entitlements server-side."})," Validate the receipt or purchase token on your backend before unlocking — never trust the client alone."]})]}),e.jsx(De,{items:o}),e.jsx(de,{assistKey:"in-app-purchases",topicName:"In-app purchases & subscriptions"}),e.jsx(he,{label:"Mark in-app purchases as set up",note:"Do this once your products are defined and a sandbox purchase unlocks the right entitlement.",onComplete:()=>n==null?void 0:n()})]})}const AT=Object.freeze(Object.defineProperty({__proto__:null,InAppPurchasesScreen:Iu},Symbol.toStringTag,{value:"Module"}));function Du({platform:t="both",onBack:s,onComplete:n}){const r=Zt(t),a=[{q:"Do I need a privacy policy even if I collect almost nothing?",a:"Yes. Both stores require a reachable privacy policy URL for essentially every app — even a trivial one. It has to be live before you submit, and it must match what your app actually does. A dead link or a mismatch is a rejection."},{q:"Why do I have to let people delete their account in the app?",a:"Both Apple and Google require that apps which let you create an account also let you delete it — and the data tied to it — from inside the app (a web link is allowed alongside, but the in-app path must exist). It's a hard review gate, not a nicety."},{q:"What exactly counts as 'tracking' for the iOS prompt?",a:"Linking a user's data with data from other companies' apps or sites for advertising or sharing with data brokers. If you do that, you must show the App Tracking Transparency prompt and only track if they allow it. Plain first-party analytics usually isn't 'tracking' in Apple's sense — but the store privacy questionnaire still has to be answered honestly."},{q:"Is the privacy questionnaire the same as the privacy policy?",a:"No — they're two things. The store's privacy questionnaire (Apple's 'privacy nutrition label', Google's Data safety form) is a structured declaration you fill in at submission; the privacy policy is your own hosted page. Both have to agree with each other and with the app's real behavior."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{onBack:s,icon:e.jsx(Ce,{size:26}),title:"App privacy & tracking",meta:"Submission gate · about 30 minutes",assistKey:"app-privacy"}),e.jsx("p",{className:"lead",children:`A build that runs perfectly still gets held at review if its privacy story isn't in order. These gates are about what you tell users you do with their data — and the stores check them on every submission, so it's worth handling before you hit "submit," not after a rejection.`}),e.jsx("div",{className:"seclabel",children:"The gates that apply everywhere"}),e.jsx(Lt,{items:[e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"A live privacy policy URL."})," Host a policy that matches what the app actually collects, and make sure the link resolves — a dead link is an instant rejection."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"In-app account deletion."})," If users can create an account, they must be able to delete it — and its data — from inside the app. Both stores require this path to exist."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"An honest privacy declaration."})," Fill in Apple's privacy label and Google's Data safety form to match reality; a mismatch with your policy or your code is a rejection."]})]}),r?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"seclabel",children:"iOS only — the tracking prompt"}),e.jsxs(Et,{tone:"wait",title:"App Tracking Transparency is its own gate",children:["If your app tracks users across other companies' apps and sites — for ads or to share with data brokers — iOS requires the"," ",e.jsx("b",{children:"App Tracking Transparency"}),' prompt before any of it, and you may only track users who tap "Allow." Declare your tracking honestly; tracking without the prompt is a rejection (and, if shipped, an enforcement risk).']})]}):null,e.jsx(De,{items:a}),e.jsx(de,{assistKey:"app-privacy",topicName:"App privacy & tracking"}),e.jsx(he,{label:"Mark app privacy as set up",note:"Do this once your policy URL is live, account deletion works in-app, and the store privacy forms are filled in.",onComplete:()=>n==null?void 0:n()})]})}const RT=Object.freeze(Object.defineProperty({__proto__:null,AppPrivacyScreen:Du},Symbol.toStringTag,{value:"Module"}));function Lu({platform:t="both",onBack:s,onComplete:n}){const r=[{q:"How long does review actually take?",a:"Apple is often a day or less now; Google can be a few hours to a few days, and longer for a brand-new account or a sensitive permission. The killer isn't the queue — it's the round-trips. Every rejection restarts the clock, so the way to ship fast is to not get rejected."},{q:"What's the most common avoidable rejection?",a:"Incomplete or inaccurate metadata and missing reviewer access. If a feature is behind a login, the reviewer needs a working demo account (or a documented way in) — otherwise they can't test it and they reject. Screenshots that don't match the app and broken support/privacy links are close behind."},{q:"What does 'minimum functionality' mean?",a:"Apple in particular rejects apps that are too thin — a repackaged website, a static brochure, or something that could just be a web page. The app needs to do something that justifies being an app. If it's borderline, add real native value before submitting."},{q:"I got rejected — now what?",a:"Read the exact guideline they cite, fix that specific thing, and reply in Resolution Center / the Play policy console with what you changed. Don't resubmit blind. If you genuinely disagree, you can respond or appeal — but a clean, targeted fix is almost always faster than arguing."}];return e.jsxs("div",{className:"hosting-screen",children:[e.jsx(ae,{onBack:s,icon:e.jsx(Ie,{size:26}),title:"Getting through review",meta:"Before you submit · about 20 minutes",assistKey:"app-review"}),e.jsx("p",{className:"lead",children:"Every store submission goes through a human (and automated) review, and it's where launches slip by weeks. The good news: almost every rejection is avoidable and predictable. Knock these out before you submit and most apps clear review on the first try."}),e.jsx(Et,{tone:"wait",title:"Rejections cost round-trips, not just time",children:"Each rejection sends you back to the end of the queue. Front-loading the common reasons is the single biggest thing you can do to ship on schedule."}),e.jsx("div",{className:"seclabel",children:"Clear these before submitting"}),e.jsx(Lt,{items:[e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Complete, accurate metadata."})," Real screenshots that match the current app, a truthful description, and working support and privacy URLs. Placeholder or mismatched assets get rejected."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"A demo account for the reviewer."})," Anything behind a login needs working credentials (or a documented bypass) in the review notes — otherwise the reviewer can't test it and rejects."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Enough functionality to be an app."})," Especially on iOS, a thin wrapper around a website or a static brochure gets rejected for minimum functionality. Make sure it does something app-worthy."]}),e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Honest permissions and data use."})," Every permission you request needs a clear in-context reason, and your store privacy declaration has to match what the app does."]})]}),e.jsx(De,{items:r}),e.jsx(de,{assistKey:"app-review",topicName:"Getting through review"}),e.jsx(he,{label:"Mark review readiness as set up",note:"Do this once your metadata is complete, a reviewer demo account is in the notes, and permissions are all justified.",onComplete:()=>n==null?void 0:n()})]})}const ET=Object.freeze(Object.defineProperty({__proto__:null,AppReviewScreen:Lu},Symbol.toStringTag,{value:"Module"}));function lo({status:t}){const s=t==="added"?"var(--accent-green)":t==="deleted"?"var(--accent-red)":"var(--accent-blue)",n=t==="added"?"+":t==="deleted"?"-":"~";return e.jsx("span",{className:"font-mono text-xs font-semibold",style:{color:s,minWidth:"0.75rem",textAlign:"center"},children:n})}const MT=Object.freeze(Object.defineProperty({__proto__:null,FileStatusIndicator:lo},Symbol.toStringTag,{value:"Module"})),b0=5e3,ki=50;function x0(){const[t,s]=l.useState([]),[n,r]=l.useState(0),[a,o]=l.useState(null),[i,c]=l.useState(!0),[d,u]=l.useState(!1),[h,p]=l.useState(null),m=l.useRef("idle"),f=l.useRef([]),b=l.useRef(null);l.useEffect(()=>{f.current=t},[t]),l.useEffect(()=>{b.current=a},[a]);const g=l.useCallback(async()=>{if(m.current==="idle"){m.current="initial",c(!0),p(null);try{const y=await fetch(`/api/history?limit=${ki}`);if(!y.ok)throw new Error(`HTTP ${y.status}`);const w=await y.json();s(w.entries??[]),r(w.total??0),o(w.nextCursor??null),w.error&&p(w.error)}catch(y){p(y instanceof Error?y.message:"Failed to load history")}finally{c(!1),m.current="idle"}}},[]),v=l.useCallback(async()=>{var w;if(m.current!=="idle")return;const y=(w=f.current[0])==null?void 0:w.commit.sha;if(!y){await g();return}m.current="poll";try{const j=await fetch(`/api/history?since=${encodeURIComponent(y)}`);if(!j.ok)throw new Error(`HTTP ${j.status}`);const k=await j.json(),S=new Set(f.current.map(T=>T.commit.sha)),N=(k.entries??[]).filter(T=>!S.has(T.commit.sha));N.length>0&&(s(T=>[...N,...T]),r(T=>T+N.length))}catch(j){p(j instanceof Error?j.message:"Failed to poll history")}finally{m.current="idle"}},[g]),x=l.useCallback(async()=>{if(m.current!=="idle")return;const y=b.current;if(y){m.current="more",u(!0);try{const w=await fetch(`/api/history?limit=${ki}&before=${encodeURIComponent(y)}`);if(!w.ok)throw new Error(`HTTP ${w.status}`);const j=await w.json();s(k=>[...k,...j.entries??[]]),o(j.nextCursor??null),typeof j.total=="number"&&r(j.total)}catch(w){p(w instanceof Error?w.message:"Failed to load more commits")}finally{u(!1),m.current="idle"}}},[]);return l.useEffect(()=>{g();const y=setInterval(()=>{v()},b0);return()=>clearInterval(y)},[g,v]),{rows:t,total:n,hasMore:a!==null,loading:i,loadingMore:d,error:h,loadMore:x,reload:g}}const Er={rows:[],total:0,truncated:!1,repo:null,screenshotsRepoRelDir:"",loading:!1,error:null};function y0(t){const[s,n]=l.useState(Er),r=(t==null?void 0:t.from)??null,a=(t==null?void 0:t.to)??null;return l.useEffect(()=>{if(r===null||a===null){n(Er);return}let o=!1;n(c=>({...c,loading:!0,error:null}));const i=new URLSearchParams({from:r,to:a});return fetch(`/api/history?${i.toString()}`).then(async c=>{if(!c.ok)throw new Error(`HTTP ${c.status}`);return await c.json()}).then(c=>{o||n({rows:c.entries??[],total:c.total??0,truncated:!!c.truncated,repo:c.repo??null,screenshotsRepoRelDir:c.screenshotsRepoRelDir??"",loading:!1,error:c.error??null})}).catch(c=>{o||n({...Er,error:c instanceof Error?c.message:"Failed to load range"})}),()=>{o=!0}},[r,a]),s}function Fu(t){const s=new Map;return t.forEach((n,r)=>{var o;const a=((o=n.entry)==null?void 0:o.scenarioScreenshots)??[];for(const i of a)s.has(i.name)||s.set(i.name,r)}),s}const v0=[/\.test\.[jt]sx?$/,/\.spec\.[jt]sx?$/,/__tests__\//,/tests?\//];function co(t){return t.filter(s=>v0.some(n=>n.test(s.path)))}function j0(t){const s={},n={total:0,passed:0,failed:0},r=new Set,a=new Set,o=new Set,i=[];let c=0,d=0;for(const u of t){if(!u.entry){d++;continue}c++;const h=u.entry.type||"other";s[h]=(s[h]??0)+1,u.commit.authorName&&r.add(u.commit.authorName),u.entry.testResults&&(n.total+=u.entry.testResults.total,n.passed+=u.entry.testResults.passed,n.failed+=u.entry.testResults.failed);for(const p of co(u.entry.modifiedFiles??[]))o.add(p.path);for(const p of u.entry.scenarioScreenshots??[])a.has(p.name)||(a.add(p.name),i.push(p))}return{totalChanges:c,byType:s,testFilesTouched:o.size,testTotals:n,screenshots:i,contributors:[...r],hiddenCommitOnlyCount:d}}const w0=[{key:"all-time",label:"All time"},{key:"last-24h",label:"Last 24 hours"},{key:"last-3d",label:"Last 3 days"},{key:"last-week",label:"Last week"},{key:"last-month",label:"Last month"}],ln=864e5;function _0(t,s){const n=s.toISOString();switch(t){case"last-24h":return{from:new Date(s.getTime()-ln).toISOString(),to:n};case"last-3d":return{from:new Date(s.getTime()-3*ln).toISOString(),to:n};case"last-week":return{from:new Date(s.getTime()-7*ln).toISOString(),to:n};case"last-month":return{from:new Date(s.getTime()-30*ln).toISOString(),to:n};case"all-time":case"custom":return null}}function k0(t){const s=new Date(t.from),n=new Date(t.to);if(isNaN(s.getTime())||isNaN(n.getTime()))return`${t.from} – ${t.to}`;const r=h=>h.toLocaleDateString("en-US",{month:"short"}),a=r(s),o=s.getDate(),i=s.getFullYear(),c=r(n),d=n.getDate(),u=n.getFullYear();return i===u&&s.getMonth()===n.getMonth()?`${a} ${o} – ${d}, ${u}`:i===u?`${a} ${o} – ${c} ${d}, ${u}`:`${a} ${o}, ${i} – ${c} ${d}, ${u}`}function zu({commit:t}){return e.jsxs("div",{className:"rounded-lg border px-4 py-3",style:{borderColor:"var(--border-default)",background:"var(--bg-card)"},children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",style:{color:"var(--text-dim)"},children:[e.jsx("span",{className:"font-mono uppercase tracking-wide",style:{color:"var(--text-muted)"},children:"commit"}),e.jsx("span",{className:"font-mono",style:{color:"var(--text-secondary)"},children:t.shortSha}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:Ec(t.timestamp)}),t.authorName&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:t.authorName})]})]}),e.jsx("p",{className:"mt-1 text-sm truncate",style:{color:"var(--text-primary)"},children:t.subject})]})}const IT=Object.freeze(Object.defineProperty({__proto__:null,CommitOnlyHistoryRow:zu},Symbol.toStringTag,{value:"Module"}));function ir({entry:t,commit:s,onSelectScreenshot:n}){const r=co(t.modifiedFiles??[]);return e.jsxs("div",{className:"rounded-lg border",style:{borderColor:"var(--border-default)",background:"var(--bg-card)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3",style:{borderBottom:"1px solid var(--border-subtle)"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:`text-xs font-medium uppercase tracking-wide ${Mc(t.type)}`,children:t.type}),e.jsx("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:Ec(t.timestamp)}),s&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:"·"}),e.jsx("span",{className:"font-mono text-xs",style:{color:"var(--text-secondary)"},children:s.shortSha}),s.authorName&&e.jsxs("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:["· ",s.authorName]})]})]}),e.jsx("h3",{className:"text-sm font-semibold",style:{color:"var(--text-primary)"},children:t.title})]}),e.jsxs("div",{className:"px-4 py-3 flex flex-col gap-3",children:[t.userRequest&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium mb-1",style:{color:"var(--text-muted)"},children:"Prompt"}),e.jsx(Ya,{children:t.userRequest})]}),(t.scenarioScreenshots??[]).length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium mb-1",style:{color:"var(--text-muted)"},children:"Screenshots"}),e.jsx(Ka,{screenshots:t.scenarioScreenshots??[],onSelect:n})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("p",{className:"text-xs font-medium",style:{color:"var(--text-muted)"},children:"Tests"}),t.testResults&&e.jsx(Va,{total:t.testResults.total,passed:t.testResults.passed,failed:t.testResults.failed})]}),r.length>0?e.jsx("ul",{className:"flex flex-col gap-0.5",children:r.map(a=>e.jsxs("li",{className:"flex items-center gap-1.5",children:[e.jsx(lo,{status:a.status}),e.jsx("span",{className:"font-mono text-xs truncate",style:{color:"var(--text-secondary)"},children:a.path})]},a.path))}):e.jsx("p",{className:"text-xs",style:{color:"var(--text-dim)"},children:"No test files changed"})]})]})]})}const DT=Object.freeze(Object.defineProperty({__proto__:null,HistoryEntryCard:ir},Symbol.toStringTag,{value:"Module"}));function $u({selection:t,onChange:s,now:n=new Date}){const[r,a]=l.useState(""),[o,i]=l.useState(""),c=u=>{s({preset:u,range:_0(u,n)})},d=(u,h)=>{a(u),i(h),u&&h&&s({preset:"custom",range:{from:new Date(`${u}T00:00:00Z`).toISOString(),to:new Date(`${h}T23:59:59Z`).toISOString()}})};return e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[w0.map(u=>{const h=t.preset===u.key;return e.jsx("button",{type:"button",onClick:()=>c(u.key),"aria-pressed":h,className:`rounded border px-2.5 py-1 text-xs transition ${h?"border-[var(--accent-primary)] text-[var(--text-primary)]":"border-[var(--border-default)] text-[var(--text-muted)] hover:bg-[var(--bg-subtle)]"}`,children:u.label},u.key)}),e.jsx("span",{className:"mx-1 text-xs text-[var(--text-dim)]",children:"or"}),e.jsxs("label",{className:"flex items-center gap-1 text-xs text-[var(--text-dim)]",children:["From",e.jsx("input",{type:"date","aria-label":"Custom range start",value:r,onChange:u=>d(u.target.value,o),className:"rounded border border-[var(--border-default)] bg-transparent px-1.5 py-0.5 text-xs text-[var(--text-primary)]"})]}),e.jsxs("label",{className:"flex items-center gap-1 text-xs text-[var(--text-dim)]",children:["To",e.jsx("input",{type:"date","aria-label":"Custom range end",value:o,onChange:u=>d(r,u.target.value),className:"rounded border border-[var(--border-default)] bg-transparent px-1.5 py-0.5 text-xs text-[var(--text-primary)]"})]})]})}const LT=Object.freeze(Object.defineProperty({__proto__:null,HistoryRangeSelector:$u},Symbol.toStringTag,{value:"Module"}));function S0(t){const{rangeLabel:s,summary:n,rows:r,repo:a,screenshotsRepoRelDir:o}=t,i=(a==null?void 0:a.rawUrlTemplate)??null,c=[];c.push(`# Change digest — ${s}`),c.push(""),c.push(N0(n)),n.hiddenCommitOnlyCount>0&&(c.push(""),c.push(`_${n.hiddenCommitOnlyCount} non-journaled commit${n.hiddenCommitOnlyCount===1?"":"s"} hidden._`));const d=r.filter(u=>u.entry!==null);for(const u of d){const h=u.entry;c.push(""),c.push(`## ${h.title}`),c.push(""),c.push(`- **Type:** ${h.type}`),c.push(`- **Commit:** \`${u.commit.shortSha}\``),h.description&&(c.push(""),c.push(h.description));const p=co(h.modifiedFiles??[]);if(p.length>0){c.push(""),c.push("**Test files:**");for(const f of p)c.push(`- \`${f.path}\``)}const m=h.scenarioScreenshots??[];if(m.length>0)if(c.push(""),i)for(const f of m){if(!f.screenshotPath)continue;const b=i.replace("{sha}",u.commit.sha).replace("{path}",C0(o,f.screenshotPath));c.push(`![${f.name}](${b})`)}else{c.push("**Screenshots (local only):**");for(const f of m)c.push(`- ${f.name}`)}}return c.join(`
3
+ `)}function N0(t){const s=[];s.push(`**${t.totalChanges}** change${t.totalChanges===1?"":"s"}`);const n=Object.entries(t.byType).map(([r,a])=>`${a} ${r}`);return n.length>0&&s.push(n.join(", ")),s.push(`${t.testFilesTouched} test file${t.testFilesTouched===1?"":"s"}`),t.testTotals.total>0&&s.push(`${t.testTotals.passed}/${t.testTotals.total} tests passed`),s.push(`${t.screenshots.length} screenshot${t.screenshots.length===1?"":"s"}`),s.join(" · ")}function C0(t,s){const n=t.replace(/\/+$/,""),r=s.replace(/^\/+/,"");return n?`${n}/${r}`:r}function Bu({summary:t}){return e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs",children:[e.jsxs("span",{className:"text-[var(--text-primary)]",children:[t.totalChanges," change",t.totalChanges===1?"":"s"]}),Object.entries(t.byType).map(([s,n])=>e.jsxs("span",{className:Mc(s),children:[n," ",s]},s)),e.jsxs("span",{className:"text-[var(--text-muted)]",children:[t.testFilesTouched," test file",t.testFilesTouched===1?"":"s"]}),e.jsx(Va,{total:t.testTotals.total,passed:t.testTotals.passed,failed:t.testTotals.failed}),e.jsxs("span",{className:"text-[var(--text-muted)]",children:[t.screenshots.length," screenshot",t.screenshots.length===1?"":"s"]}),t.contributors.length>0&&e.jsx("span",{className:"text-[var(--text-dim)]",children:t.contributors.join(", ")})]})}const FT=Object.freeze(Object.defineProperty({__proto__:null,HistoryDigestStatRow:Bu},Symbol.toStringTag,{value:"Module"}));function Hu({rangeLabel:t,summary:s,rows:n,repo:r,screenshotsRepoRelDir:a,truncated:o,onPreviewScreenshot:i}){const[c,d]=l.useState(!1),u=Fu(n),h=async()=>{const p=S0({rangeLabel:t,summary:s,rows:n,repo:r,screenshotsRepoRelDir:a});try{await navigator.clipboard.writeText(p),d(!0),setTimeout(()=>d(!1),2e3)}catch{}};return s.totalChanges===0?e.jsxs("div",{children:[e.jsx(la,{rangeLabel:t,onCopy:h,copied:c}),e.jsxs("div",{className:"py-10 text-center text-[var(--text-dim)]",children:[e.jsx("p",{children:"No changes in this window."}),s.hiddenCommitOnlyCount>0&&e.jsxs("p",{className:"mt-2 text-xs",children:[s.hiddenCommitOnlyCount," non-journaled commit",s.hiddenCommitOnlyCount===1?"":"s"," hidden."]})]})]}):e.jsxs("div",{children:[e.jsx(la,{rangeLabel:t,onCopy:h,copied:c}),e.jsx(Bu,{summary:s}),s.hiddenCommitOnlyCount>0&&e.jsxs("p",{className:"mb-3 text-xs text-[var(--text-dim)]",children:[s.hiddenCommitOnlyCount," non-journaled commit",s.hiddenCommitOnlyCount===1?"":"s"," hidden from this digest."]}),o&&e.jsxs("p",{className:"mb-3 text-xs text-[var(--accent-yellow,#eab308)]",children:["Showing the ",n.length," most recent changes in this window — narrow the range to see the rest."]}),s.screenshots.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"mb-1 text-xs font-medium text-[var(--text-muted)]",children:"Screenshots"}),e.jsx(Ka,{screenshots:s.screenshots,onSelect:i?p=>i({...p,isLatest:u.get(p.name)===T0(n,p.name)}):void 0})]}),e.jsx("div",{className:"flex flex-col gap-3",children:n.map((p,m)=>p.entry?e.jsx(ir,{entry:p.entry,commit:p.commit,onSelectScreenshot:i?f=>i({...f,isLatest:u.get(f.name)===m}):void 0},p.commit.sha):null)})]})}function la({rangeLabel:t,onCopy:s,copied:n}){return e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-sm font-semibold text-[var(--text-primary)]",children:t}),e.jsx("button",{type:"button",onClick:s,className:"rounded border border-[var(--border-default)] px-2.5 py-1 text-xs text-[var(--text-muted)] hover:bg-[var(--bg-subtle)]",children:n?"Copied!":"Copy summary"})]})}function T0(t,s){return t.findIndex(n=>{var r;return(((r=n.entry)==null?void 0:r.scenarioScreenshots)??[]).some(a=>a.name===s)})}const zT=Object.freeze(Object.defineProperty({__proto__:null,DigestHeader:la,HistoryDigest:Hu},Symbol.toStringTag,{value:"Module"}));function lr({children:t,testId:s}){return e.jsx("div",{className:"overflow-y-auto px-4 py-4",style:{maxHeight:"calc(100vh - 110px)"},"data-testid":s,children:t})}const $T=Object.freeze(Object.defineProperty({__proto__:null,TabScrollPanel:lr},Symbol.toStringTag,{value:"Module"}));function Wu({onPreviewScreenshot:t}={}){const[s,n]=l.useState({preset:"all-time",range:null});return e.jsxs(lr,{children:[e.jsx($u,{selection:s,onChange:n}),s.range?e.jsx(P0,{range:s.range,onPreviewScreenshot:t}):e.jsx(O0,{onPreviewScreenshot:t})]})}function P0({range:t,onPreviewScreenshot:s}){const{rows:n,truncated:r,repo:a,screenshotsRepoRelDir:o,loading:i,error:c}=y0(t);if(i)return e.jsx("div",{className:"py-12 text-center text-[var(--text-muted)]",children:"Loading digest..."});if(c)return e.jsxs("div",{className:"py-12 text-center text-[var(--accent-red)]",children:["Failed to load digest: ",c]});const d=j0(n);return e.jsx(Hu,{rangeLabel:k0(t),summary:d,rows:n,repo:a,screenshotsRepoRelDir:o,truncated:r,onPreviewScreenshot:s})}function O0({onPreviewScreenshot:t}){const{rows:s,total:n,hasMore:r,loading:a,loadingMore:o,error:i,loadMore:c}=x0();if(a)return e.jsx("div",{className:"py-12 text-center text-[var(--text-muted)]",children:"Loading history..."});if(i&&s.length===0)return e.jsxs("div",{className:"py-12 text-center text-[var(--accent-red)]",children:["Failed to load history: ",i]});if(s.length===0)return e.jsxs("div",{className:"py-12 text-center text-[var(--text-dim)]",children:[e.jsx("p",{children:"No commits yet."}),e.jsx("p",{className:"mt-2 text-sm",children:"Commits and journal entries will appear here as you build features."})]});const d=Math.max(n,s.length),u=Fu(s);return e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"mb-3 text-xs",style:{color:"var(--text-dim)"},children:[s.length," of ",d," commit",d===1?"":"s"]}),e.jsx("div",{className:"flex flex-col gap-3",children:s.map((h,p)=>h.entry?e.jsx(ir,{entry:h.entry,commit:h.commit,onSelectScreenshot:t?m=>t({...m,isLatest:u.get(m.name)===p}):void 0},h.commit.sha):e.jsx(zu,{commit:h.commit},h.commit.sha))}),r?e.jsx("div",{className:"mt-4 flex justify-center",children:e.jsx("button",{type:"button",onClick:()=>void c(),disabled:o,className:"rounded border border-[var(--border)] px-3 py-1 text-sm text-[var(--text-muted)] hover:bg-[var(--bg-subtle)] disabled:opacity-50",children:o?"Loading...":"Load older commits"})}):null]})}const BT=Object.freeze(Object.defineProperty({__proto__:null,HistoryTab:Wu},Symbol.toStringTag,{value:"Module"})),A0="I came to the Build tab to find the AI waiting for me but never saw any of the idle notifications — no sound, no orange dot on the Build tab, no idle banner. Please diagnose using the trace below.\n\nStart with the **UI idle trace** section: a single `debounce-cancelled` line with a `trigger` field identifies which silent path killed the 1500ms debounce before `debounce-resolved` could fire. Cross-reference with the **Rust idle trace** and **editor-server.log** sections to confirm the backend actually sent `agent-idle` and to see the timing.";function R0(){const t=typeof Notification<"u"?Notification.permission:"unknown",s=typeof document<"u"&&typeof document.hasFocus=="function"?document.hasFocus():!1,n=typeof document<"u"?document.hidden:!1;let r=null;try{r=typeof localStorage<"u"?localStorage.getItem("codeyam.idleDebug"):null}catch{}const a=typeof navigator<"u"?navigator.userAgent:"unknown";return{notificationPermission:t,hasFocus:s,hidden:n,idleDebug:r,userAgent:a}}function Si(t){return t.length===0?"_(no events in window)_":`\`\`\`jsonl
4
+ ${t.map(n=>JSON.stringify(n)).join(`
5
+ `)}
6
+ \`\`\``}function Mr(t,s){return t.trim().length===0?`_(${s} empty)_`:`\`\`\`
7
+ ${t}
8
+ \`\`\``}function E0(t){var v,x,y;const{bundle:s,browser:n,uiBufferText:r,prompt:a,agentName:o}=t,i=(s==null?void 0:s.now)??new Date().toISOString(),c=(s==null?void 0:s.session)??za(),d=(s==null?void 0:s.windowMinutes)??10,u=((v=s==null?void 0:s.environment)==null?void 0:v.editorVersion)??"unknown",h=((x=s==null?void 0:s.environment)==null?void 0:x.platform)??"unknown",p=((y=s==null?void 0:s.environment)==null?void 0:y.projectDir)??"unknown",m=(a??A0).trim(),f=[`- Notification.permission: ${n.notificationPermission}`,`- document.hasFocus(): ${n.hasFocus}`,`- document.hidden: ${n.hidden}`,`- localStorage.codeyam.idleDebug: ${n.idleDebug===null?"(unset)":JSON.stringify(n.idleDebug)}`,`- userAgent: ${n.userAgent}`].join(`
9
+ `),b=s&&s.truncations.length>0?`> **Truncations:** ${s.truncations.join("; ")}`:"";return["# CodeYam Notification Debug Bundle","",m,"","---","",`**Captured:** ${i}`,`**UI session:** ${c} (window: last ${d} minutes)`,`**Editor version:** ${u}`,`**Platform:** ${h}`,`**Project:** ${p}`,o?`**Agent:** ${o}`:null,"","**Browser state:**",f,"",b,"","## UI idle trace (persisted)","",Si((s==null?void 0:s.uiTrace)??[]),"","## UI idle trace (in-memory ring buffer — may be ahead of persisted)","",Mr(r,"in-memory buffer"),"","## Rust idle trace","",Si((s==null?void 0:s.rustTrace)??[]),"","## editor-server.log (filtered to idle= within window)","",Mr((s==null?void 0:s.editorServerLog)??"","editor-server.log"),"","## dev-server.log (last lines)","",Mr((s==null?void 0:s.devServerLog)??"","dev-server.log"),""].filter(w=>w!==null).join(`
10
+ `)}async function M0(t={}){const s=encodeURIComponent(za());let n=null,r=null;try{const c=await fetch(`/api/idle-trace/bundle?session=${s}&minutes=10`);c.ok?n=await c.json():r=`HTTP ${c.status}`}catch(c){r=c instanceof Error?c.message:String(c)}const a=R0(),o=ov({agentName:t.agentName});return{markdown:E0({bundle:n,browser:a,uiBufferText:o,prompt:t.prompt,agentName:t.agentName}),bundle:n,error:r}}const I0=1500;function D0(t=I0){const[s,n]=l.useState(null),r=l.useRef(null),a=l.useCallback((o,i)=>{r.current!==null&&clearTimeout(r.current),n(o),r.current=setTimeout(()=>{n(null),r.current=null},i??t)},[t]);return l.useEffect(()=>()=>{r.current!==null&&(clearTimeout(r.current),r.current=null)},[]),{label:s,flash:a}}const L0=2500;function qu({agentName:t}){const[s,n]=l.useState(!1),{label:r,flash:a}=D0(L0),o=async()=>{n(!0);const{markdown:i,bundle:c,error:d}=await M0({agentName:t});try{await navigator.clipboard.writeText(i);const u=((c==null?void 0:c.uiTrace.length)??0)+((c==null?void 0:c.rustTrace.length)??0),h=Math.round(i.length/1024*10)/10,p=d?`Copied (offline — ${u} events, ${h} KB)`:`Copied ${u} events · ${h} KB`;a(p)}catch{a("Copy failed")}finally{n(!1)}};return e.jsx("button",{onClick:()=>void o(),disabled:s,className:"text-left text-[11px] px-2 py-1 rounded cursor-pointer transition-colors font-medium",style:{background:"transparent",color:"var(--text-secondary)"},"data-testid":"notification-debug-copy",children:r??(s?"Gathering bundle…":"Debug Notifications")})}const HT=Object.freeze(Object.defineProperty({__proto__:null,DebugNotificationsButton:qu},Symbol.toStringTag,{value:"Module"})),Ir={sound:"soft-double-tap",systemNotification:!0,idleOnStop:!1,idleOnNotification:!0},F0=[{id:"soft-double-tap",label:"Soft double tap"},{id:"gentle-chime",label:"Gentle chime"},{id:"warm-ding",label:"Warm ding"},{id:"mellow-two-tone",label:"Mellow two-tone"},{id:"triangle-bell",label:"Triangle bell"},{id:"off",label:"No sound"}],Gu="codeyam-editor-notifications";function Uu(){try{const t=localStorage.getItem(Gu);if(!t)return Ir;const s=JSON.parse(t);return{...Ir,...s}}catch{return Ir}}function Vu(t){localStorage.setItem(Gu,JSON.stringify(t))}const z0={"soft-double-tap":t=>([0,.12].forEach(s=>{const n=t.createOscillator(),r=t.createGain();n.connect(r),r.connect(t.destination),n.type="sine",n.frequency.value=392,r.gain.setValueAtTime(.25,t.currentTime+s),r.gain.exponentialRampToValueAtTime(.01,t.currentTime+s+.1),n.start(t.currentTime+s),n.stop(t.currentTime+s+.1)}),{count:2,longestStopSec:.22}),"gentle-chime":t=>{const s=t.createOscillator(),n=t.createGain();return s.connect(n),n.connect(t.destination),s.type="sine",s.frequency.setValueAtTime(523,t.currentTime),s.frequency.setValueAtTime(659,t.currentTime+.15),n.gain.setValueAtTime(.3,t.currentTime),n.gain.exponentialRampToValueAtTime(.01,t.currentTime+.4),s.start(),s.stop(t.currentTime+.4),{count:1,longestStopSec:.4}},"warm-ding":t=>{const s=t.createOscillator(),n=t.createGain();return s.connect(n),n.connect(t.destination),s.type="sine",s.frequency.value=330,n.gain.setValueAtTime(.35,t.currentTime),n.gain.exponentialRampToValueAtTime(.01,t.currentTime+.6),s.start(),s.stop(t.currentTime+.6),{count:1,longestStopSec:.6}},"mellow-two-tone":t=>{const s=t.createOscillator(),n=t.createGain();return s.connect(n),n.connect(t.destination),s.type="sine",s.frequency.setValueAtTime(294,t.currentTime),s.frequency.setValueAtTime(440,t.currentTime+.18),n.gain.setValueAtTime(.3,t.currentTime),n.gain.exponentialRampToValueAtTime(.01,t.currentTime+.5),s.start(),s.stop(t.currentTime+.5),{count:1,longestStopSec:.5}},"triangle-bell":t=>{const s=t.createOscillator(),n=t.createGain();return s.connect(n),n.connect(t.destination),s.type="triangle",s.frequency.value=523,n.gain.setValueAtTime(.4,t.currentTime),n.gain.exponentialRampToValueAtTime(.01,t.currentTime+.8),s.start(),s.stop(t.currentTime+.8),{count:1,longestStopSec:.8}}};function Dr(t,s){const n=s;K(t,{name:n==null?void 0:n.name,message:n==null?void 0:n.message})}function Yu(t){if(t==="off")return;K("audio-playsound-entered",{soundId:t});let s;try{s=new AudioContext}catch(r){Dr("audio-context-failed",r);return}K("audio-context-created",{state:s.state});const n=()=>{let r;try{r=z0[t](s)}catch(a){Dr("audio-context-failed",a),s.close().catch(()=>{});return}K("audio-oscillators-scheduled",{soundId:t,count:r.count,longestStopSec:r.longestStopSec}),setTimeout(()=>{s.close().then(()=>K("audio-context-closed")).catch(()=>{})},(r.longestStopSec+.1)*1e3)};s.state==="running"?n():s.state==="suspended"?(K("audio-context-resume-attempted"),s.resume().then(()=>{K("audio-context-resume-ok",{state:s.state}),n()},r=>{Dr("audio-context-resume-failed",r),s.close().catch(()=>{})})):(K("audio-context-failed",{name:"UnexpectedState",message:`AudioContext state "${s.state}"`}),s.close().catch(()=>{}))}function ca({label:t,checked:s,onChange:n,className:r}){return e.jsxs("label",{className:`flex items-center gap-2 cursor-pointer${r?` ${r}`:""}`,children:[e.jsx("input",{type:"checkbox",checked:s,onChange:a=>n(a.target.checked),className:"accent-green-500"}),e.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:t})]})}const WT=Object.freeze(Object.defineProperty({__proto__:null,IdleTriggerCheckbox:ca},Symbol.toStringTag,{value:"Module"}));function uo({settings:t,onChange:s}){const n=t.idleOnStop??!1,r=t.idleOnNotification??!0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] mb-1.5",style:{color:"var(--text-muted)"},children:"Notification sound"}),e.jsx("div",{className:"flex flex-col gap-0.5",children:F0.map(a=>e.jsx("button",{onClick:()=>{s({...t,sound:a.id}),a.id!=="off"&&Yu(a.id)},className:"text-left text-[11px] px-2 py-1 rounded cursor-pointer transition-colors",style:{background:t.sound===a.id?"var(--bg-input)":"transparent",color:t.sound===a.id?"var(--text-primary)":"var(--text-secondary)"},children:a.label},a.id))})]}),e.jsxs("div",{className:"pt-2",style:{borderTop:"1px solid var(--border-default)"},children:[e.jsx("div",{className:"text-[11px] mb-1.5",style:{color:"var(--text-muted)"},children:"Trigger idle on"}),e.jsx(ca,{label:"Claude stops",checked:n,onChange:a=>s({...t,idleOnStop:a})}),e.jsx(ca,{label:"Claude sends a notification",checked:r,onChange:a=>s({...t,idleOnNotification:a}),className:"mt-1"})]}),e.jsxs("div",{className:"pt-2",style:{borderTop:"1px solid var(--border-default)"},children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.systemNotification,onChange:a=>{const o=a.target.checked;s({...t,systemNotification:o}),o&&typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},className:"accent-green-500"}),e.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"System notification"})]}),e.jsx("div",{className:"text-[10px] mt-1 ml-5",style:{color:"var(--text-dim)"},children:"Shows when tab is not visible"}),typeof Notification<"u"&&Notification.permission==="denied"&&e.jsx("div",{className:"text-[10px] mt-1 ml-5",style:{color:"var(--accent-red, #ef4444)"},children:"Notifications are blocked. Click the lock icon in your address bar → Site settings → Notifications → Allow"})]})]})}const qT=Object.freeze(Object.defineProperty({__proto__:null,NotificationSettingsControls:uo},Symbol.toStringTag,{value:"Module"}));function Ku({settings:t,onChange:s,agentName:n}){const[r,a]=l.useState(!1),o=l.useRef(null),i=t.idleOnStop??!1,c=t.idleOnNotification??!0,d=t.sound!=="off"||t.systemNotification||i||c;return l.useEffect(()=>{if(!r)return;const u=h=>{o.current&&!o.current.contains(h.target)&&a(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[r]),e.jsxs("div",{className:"h-7 flex items-center px-3 text-xs shrink-0",style:{background:"var(--bg-nav)",borderTop:"1px solid var(--border-default)"},children:[e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"relative",ref:o,children:[e.jsx("button",{onClick:()=>{a(!r),typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},className:"cursor-pointer transition-colors",style:{color:d?"var(--accent-green)":"var(--text-dim)",fontSize:"11px"},children:d?"Notifications On":"Notifications Off"}),r&&e.jsxs("div",{className:"absolute bottom-full right-0 mb-2 w-56 rounded-lg shadow-xl p-3 flex flex-col gap-3 z-50",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx(uo,{settings:t,onChange:s}),e.jsx("div",{className:"pt-2",style:{borderTop:"1px solid var(--border-default)"},children:e.jsx(qu,{agentName:n})})]})]})]})}const GT=Object.freeze(Object.defineProperty({__proto__:null,NotificationSettingsPopover:Ku},Symbol.toStringTag,{value:"Module"})),Ju="codeyam-editor-notifications-prompted",$0="codeyam-editor-notifications";function Xu(){try{localStorage.setItem(Ju,"1")}catch{}}function B0(){try{return localStorage.getItem(Ju)!==null||localStorage.getItem($0)!==null}catch{return!0}}function Qu({settings:t,onChange:s}){const[n,r]=l.useState(()=>!B0());if(!n)return null;const a=()=>{Xu(),r(!1)},o=()=>{s({...t,systemNotification:!0}),typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission(),a()};return e.jsxs("div",{className:"rounded-lg px-4 py-2.5 mb-3 flex items-center gap-3",style:{background:"var(--surface-card)",border:"1px solid var(--lime-300)"},children:[e.jsx("span",{"aria-hidden":"true",style:{fontSize:15,lineHeight:1,color:"var(--lime-300)"},children:"🔔"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--text-strong)"},children:"Get notified when Claude finishes"}),e.jsx("span",{style:{fontSize:"12px",color:"var(--text-faint)",marginLeft:8},children:"We'll ping you when the agent stops or pauses."})]}),e.jsx("button",{onClick:o,className:"shrink-0 cursor-pointer transition-colors",style:{background:"var(--action-bg)",color:"var(--action-fg)",fontSize:"12.5px",fontWeight:600,borderRadius:9,padding:"7px 14px"},children:"Enable"}),e.jsx("button",{onClick:a,className:"shrink-0 cursor-pointer",style:{color:"var(--text-faint)",fontSize:"12px"},children:"Not now"})]})}const UT=Object.freeze(Object.defineProperty({__proto__:null,NotificationSetupBanner:Qu},Symbol.toStringTag,{value:"Module"}));function H0(){const[t,s]=l.useState(null);return l.useEffect(()=>{fetch("/api/editor-setup-answers").then(n=>{if(!n.ok)throw new Error(`HTTP ${n.status}`);return n.json()}).then(n=>{s(n!==null)}).catch(()=>{s(!1)})},[]),{saved:t}}function Zu({projectDescription:t}){return e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Building your project…"}),e.jsx("blockquote",{className:"mt-4 border-l-2 border-[var(--accent-active)] pl-4 text-sm italic text-[var(--text-dim)]",children:t}),e.jsxs("p",{className:"mt-6 text-sm text-[var(--text-dim)]",children:["Your app will appear here as it’s built. The agent is scaffolding it now on the ",e.jsx("strong",{children:"Build"})," tab — open it to follow along."]})]})}const VT=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewEmptyStateBuildingPanel:Zu},Symbol.toStringTag,{value:"Module"}));function eh(){return e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-xl font-semibold",children:"No app scaffolded yet"}),e.jsxs("p",{className:"mt-4 text-sm text-[var(--text-dim)]",children:["Your project hasn’t been scaffolded yet. Open the"," ",e.jsx("strong",{children:"Build"})," tab to start building."]})]})}const YT=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewEmptyStateNoAppPanel:eh},Symbol.toStringTag,{value:"Module"}));function th({onClick:t}){return e.jsx("button",{type:"button",onClick:t,"data-testid":"app-overview-empty-open-build",className:"mt-6 inline-flex items-center gap-2 rounded border border-[var(--accent-active)] bg-[var(--accent-active)] px-4 py-2 text-xs font-medium uppercase tracking-wide text-black transition-colors hover:bg-[var(--accent-active)]/90 cursor-pointer",children:"Open Build tab"})}const KT=Object.freeze(Object.defineProperty({__proto__:null,OpenBuildTabButton:th},Symbol.toStringTag,{value:"Module"}));function sh({projectDescription:t,onOpenBuildTab:s}){const n=t!==null&&t.trim().length>0;return e.jsxs("div",{className:"mx-auto max-w-2xl px-5 py-12 text-[var(--text-primary)]",children:[n?e.jsx(Zu,{projectDescription:t}):e.jsx(eh,{}),e.jsx(th,{onClick:s})]})}const JT=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewEmptyState:sh},Symbol.toStringTag,{value:"Module"}));function nh({stats:t,onSelectApp:s,testsLoading:n,testsRefreshing:r,onRunTests:a,currentRunner:o}){return e.jsx("div",{className:"flex flex-col gap-4",children:t.map(i=>e.jsx(Dl,{stats:i,onClick:()=>s(i.app.dir),testsLoading:n,testsRefreshing:r,onRunTests:a,currentRunner:o},i.app.dir))})}const XT=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewGrid:nh},Symbol.toStringTag,{value:"Module"}));function rh({projectTitle:t,coverage:s,onCoverageClick:n}){return e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)]",children:t}),e.jsx(Ua,{coverage:s,testId:"app-overview-coverage",onClick:n})]})}const QT=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewHeader:rh},Symbol.toStringTag,{value:"Module"})),W0=26,q0=19,G0={1:"Plan",2:"Explore",3:"Confirm",4:"Prepare",5:"Seed Data",6:"Live Preview Loop",7:"Verify Prototype",8:"Confirm Mode",9:"Demo",10:"Interactive Test",11:"Deconstruct",12:"Extract TDD",13:"Glossary",14:"Dependency Graph",15:"Isolation Routes",16:"Component Scenarios",17:"Curate Scenarios",18:"App Scenarios",19:"Present",20:"Reconcile",21:"Journal",22:"Pre-Commit Sync",23:"Finalize",24:"Commit",25:"Push",26:"Feature Complete"},U0={1:"Plan",2:"Explore",3:"Confirm Plan",4:"Prepare",5:"Prototype",6:"Confirm Mode",7:"Demo",8:"Deconstruct",9:"Extract TDD",10:"Glossary",11:"Dependency Graph",12:"Present",13:"Reconcile",14:"Journal",15:"Pre-Commit Sync",16:"Finalize",17:"Commit",18:"Push",19:"Feature Complete"},V0={1:"Plan the feature and confirm the approach with the user before writing any code.",2:"Map out all the files you'll need to read or modify; check for reference implementations.",3:"Repeat the plan back to the user and gate on explicit approval before any code is written.",4:"Prepare the project environment and dependencies for prototyping.",5:"Wire up API routes and seed the database with realistic, demo-rich data.",6:"Iterate on the prototype with the live preview — navigate, edit, verify.",7:"Verify the prototype's routes, images, and client errors before presenting.",8:"Confirm or switch the workflow mode before the demo.",9:"Capture and show a verified live-preview demonstration of the change.",10:"Hand the live preview to the user for interactive testing and get approval.",11:"Read the code and plan all component and function extractions.",12:"Extract components and functions via TDD; cover library functions with multiple tests.",13:"Register every new test and glossary entry produced in the prior step.",14:"Rebuild the dependency graph after extraction.",15:"Create isolation routes for every visual component.",16:"Register and capture component-level scenarios for every visual component.",17:"Curate the existing app-scenario set — review, consolidate, dedup, and edit in place — before registering new scenarios.",18:"Create app-level scenarios that show full pages with realistic data.",19:"Final approval gate — recapture screenshots and present a summary of all work to the user.",20:"Run the audit gate, reconcile any registry/glossary drift until clean.",21:"Create or update the journal entry documenting what was built.",22:"Sync local state with the remote so the next commit lands on a merged tree.",23:"Finalize the session — run the full suite once.",24:"Commit all changes to git.",25:"Push the branch to the remote repository.",26:"Fire the feature-complete modal — the cycle ends here."},Y0={1:"Plan the feature and confirm the approach with the user before writing any code.",2:"Map out all the files you'll need to read or modify; check for reference implementations.",3:"Repeat the plan back to the user and gate on explicit approval before any code is written.",4:"Prepare the project environment.",5:"Build the feature. Tests come at the Deconstruct cluster.",6:"Confirm or switch the workflow mode before the demo.",7:"Show the prototype results and gate on the user's yes/iterate decision before any verification work.",8:"Read the code and plan all function/method/helper extractions.",9:"Extract functions/methods/helpers via TDD; every change must have a red-if-reverted test.",10:"Register every new test and glossary entry produced in the prior step.",11:"Rebuild the dependency graph after extraction.",12:"Present the /results page with architecture diagram, tests, and changed files.",13:"Run the audit gate, reconcile any registry/glossary drift until clean.",14:"Author the session narrative against post-Verify code, then create the journal entry.",15:"Sync local state with the remote so the next commit lands on a merged tree.",16:"Finalize the session — run the full suite once.",17:"Commit all changes to git.",18:"Push the branch to the remote repository.",19:"Fire the feature-complete modal — the cycle ends here."};function ht(t){return t==="backend"?"backend":"ui"}function ho(t,s){return(ht(s)==="backend"?U0:G0)[t]??"?"}function K0(t,s){return(ht(s)==="backend"?Y0:V0)[t]??""}function po(t){return ht(t)==="backend"?q0:W0}function ah(t){return ht(t)==="backend"?"Backend Flow":"UI Flow"}function oh(t,s){const n=ht(s);return{description:K0(t,n),label:ho(t,n),prefix:ah(n),totalSteps:po(n)}}const J0={1:"Understanding your idea",2:"Looking through your project",3:"Confirming the approach with you",4:"Preparing your workspace",5:"Adding sample data",6:"Building your app",7:"Checking the prototype",8:"Confirming the next step with you",9:"Showing you the result",10:"Trying it out together",11:"Reading the code carefully",12:"Adding tests",13:"Documenting the building blocks",14:"Mapping connections in your code",15:"Setting up isolation routes",16:"Capturing component snapshots",17:"Curating existing snapshots",18:"Capturing whole-page snapshots",19:"Showing you the final review",20:"Reconciling everything",21:"Writing a journal entry",22:"Syncing with the latest",23:"Finalizing the build",24:"Saving your changes",25:"Pushing your work",26:"All done"},X0={1:"Understanding your idea",2:"Looking through your project",3:"Confirming the approach with you",4:"Preparing your workspace",5:"Building your app",6:"Confirming the next step with you",7:"Showing you the result",8:"Reading the code carefully",9:"Adding tests",10:"Documenting the building blocks",11:"Mapping connections in your code",12:"Showing you the final review",13:"Reconciling everything",14:"Finalizing the build",15:"Writing a journal entry",16:"Syncing with the latest",17:"Saving your changes",18:"Pushing your work",19:"All done"},Q0=[{phaseId:"understand",phaseLabel:"Understanding your idea",phaseSteps:[1,2,3]},{phaseId:"setup",phaseLabel:"Setting things up",phaseSteps:[4,5]},{phaseId:"build",phaseLabel:"Building your app",phaseSteps:[6,7,8,9,10]},{phaseId:"tidy",phaseLabel:"Making the code maintainable",phaseSteps:[11,12,13,14,15,16,17,18]},{phaseId:"review",phaseLabel:"Final Review",phaseSteps:[19,20,21,22,23]},{phaseId:"save",phaseLabel:"Saving your work",phaseSteps:[24,25,26]}],Z0=[{phaseId:"understand",phaseLabel:"Understanding your idea",phaseSteps:[1,2,3]},{phaseId:"setup",phaseLabel:"Setting things up",phaseSteps:[4]},{phaseId:"build",phaseLabel:"Building your app",phaseSteps:[5,6,7]},{phaseId:"tidy",phaseLabel:"Making the code maintainable",phaseSteps:[8,9,10,11]},{phaseId:"review",phaseLabel:"Final Review",phaseSteps:[12,13,14,15,16]},{phaseId:"save",phaseLabel:"Saving your work",phaseSteps:[17,18,19]}];function ew(t,s){return(ht(s)==="backend"?X0:J0)[t]??""}function tw(t){return ht(t)==="backend"?Z0:Q0}const sw={building:{stat:"Building now",sub:"in progress",color:"var(--green-300)",attn:!1},"needs-input":{stat:"Needs you",sub:"your okay",color:"var(--amber-300)",attn:!0},waiting:{stat:"Waiting for you",sub:"paused",color:"var(--amber-300)",attn:!0}};function mo({isBuilding:t,buildingLabel:s,buildingStepLabel:n,buildingStepIndicator:r=null,buildingStatus:a="building",buildingProgress:o=null,buildingMode:i,lastBuiltLabel:c,onOpenBuilding:d,onStartNewFeature:u}){const h=s||"your latest change",p=sw[a];return t?e.jsxs("button",{type:"button",className:"drow building"+(p.attn?" attn":""),onClick:d,children:[e.jsx("div",{className:"dspin"}),e.jsxs("div",{className:"dmain",children:[e.jsxs("div",{className:"dname",children:["What's building"," ",e.jsx("span",{className:"livedot"+(p.attn?" warn":"")})]}),e.jsx("div",{className:"ddesc",children:a==="building"?e.jsxs(e.Fragment,{children:["Building ",e.jsx("b",{children:h}),n?e.jsxs(e.Fragment,{children:[" — ",n.toLowerCase(),"."]}):"."]}):a==="needs-input"?e.jsxs(e.Fragment,{children:[e.jsx("b",{children:h}),n?e.jsxs(e.Fragment,{children:[" — ",n.toLowerCase(),"."]}):"."," ","It needs your okay to keep going."]}):e.jsxs(e.Fragment,{children:[e.jsx("b",{children:h}),n?e.jsxs(e.Fragment,{children:[" — ",n.toLowerCase(),"."]}):"."," ","Paused, waiting for you to pick it back up."]})}),i||r?e.jsxs("div",{className:"bstep",children:[i?e.jsx("span",{className:"bflow",children:ah(i)}):null,r]}):null,a==="building"?e.jsx("div",{className:"bbar",children:e.jsx("div",{className:"bbar-fill",style:{width:o!=null?`${Math.round(o*100)}%`:"12%"}})}):null]}),e.jsxs("div",{className:"dright",children:[e.jsxs("div",{className:"dmeta",children:[e.jsx("span",{className:"stat",style:{color:p.color},children:p.stat}),p.sub]}),e.jsx("span",{className:"arr",children:"→"})]})]}):e.jsxs("button",{type:"button",className:"drow ready",onClick:u??d,children:[e.jsx("div",{className:"dic ic-ready",children:e.jsx(Ze,{size:19})}),e.jsxs("div",{className:"dmain",children:[e.jsx("div",{className:"dname",children:"Ready to build?"}),e.jsx("div",{className:"ddesc",children:c?e.jsxs(e.Fragment,{children:["You last built ",e.jsx("b",{children:c}),"."]}):e.jsx(e.Fragment,{children:"Describe a change and I'll build it."})})]}),e.jsx("div",{className:"dright",children:e.jsx("span",{className:"cta-pill",children:"Build a new feature →"})})]})}const ZT=Object.freeze(Object.defineProperty({__proto__:null,BuildingDoor:mo},Symbol.toStringTag,{value:"Module"}));function ih({isBuilding:t,buildingLabel:s,buildingStepLabel:n,buildingStepIndicator:r=null,buildingStatus:a="building",buildingProgress:o=null,buildingMode:i,onOpenBuilding:c,onResetBuild:d}){return t?e.jsx("section",{"data-testid":"home-build-status-section",className:"mt-6 mb-6",children:e.jsx("div",{className:"home-landing",children:e.jsxs("div",{className:"doorrows",children:[e.jsx(mo,{isBuilding:t,buildingLabel:s,buildingStepLabel:n,buildingStepIndicator:r,buildingStatus:a,buildingProgress:o,buildingMode:i,onOpenBuilding:c,onStartNewFeature:c}),e.jsx("div",{className:"bstatus-foot",children:e.jsx("button",{type:"button","data-testid":"build-status-reset",onClick:d,className:"bstatus-reset",children:"Cancel build & reset everything"})})]})})}):null}const eP=Object.freeze(Object.defineProperty({__proto__:null,HomeBuildStatusSection:ih},Symbol.toStringTag,{value:"Module"}));async function nw(t){try{t.description&&await fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectDescription:t.description,allowOverwrite:!0})});const s={appFormats:t.appFormats,techStackId:t.techStackId,designApproach:t.designApproach};t.defaultDevice&&(s.defaultDevice=t.defaultDevice),await fetch("/api/editor-setup-answers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})}catch{}}const Ni=["product-type","description","tech-stack","notifications","design-approach"];function rw(t){return t==="files"||t==="chat"?[...Ni,"design-details"]:Ni}const lh="codeyam.questionnaire.draft";function fo(t){return`${lh}:${t}`}function aw(t){if(t===null||typeof t!="object")return!1;const s=t;if(typeof s.step!="number"||!Number.isFinite(s.step)||typeof s.savedAt!="string"||s.designChatLaunched!==void 0&&typeof s.designChatLaunched!="boolean")return!1;const n=s.answers;if(n===null||typeof n!="object")return!1;const r=n;return!(!Array.isArray(r.appFormats)||!r.appFormats.every(a=>typeof a=="string")||typeof r.description!="string"||r.techStackId!==null&&typeof r.techStackId!="string"||r.designApproach!==null&&typeof r.designApproach!="string"||r.defaultDevice!==null&&typeof r.defaultDevice!="string")}function Lr(t){try{const s=localStorage.getItem(fo(t));if(s===null)return null;const n=JSON.parse(s);return aw(n)?n:null}catch{return null}}function ow(t,s){try{localStorage.setItem(fo(t),JSON.stringify(s))}catch{}}function iw(t){try{localStorage.removeItem(fo(t))}catch{}}function lw(){try{localStorage.removeItem(lh)}catch{}}function cw(){const[t,s]=l.useState([]);return l.useEffect(()=>{fetch("/api/editor-stacks").then(n=>n.json()).then(s).catch(()=>{})},[]),{techStacks:t}}function dw(){const[t,s]=l.useState({projectDir:null,loaded:!1});return l.useEffect(()=>{let n=!1;return fetch("/api/codeyam-server-identity").then(r=>r.ok?r.json():null).then(r=>{if(n)return;const a=r&&typeof r=="object"&&typeof r.projectDir=="string"?r.projectDir:null;s({projectDir:a,loaded:!0})}).catch(()=>{n||s({projectDir:null,loaded:!0})}),()=>{n=!0}},[]),t}function ch({dragActive:t,inputRef:s,onDragOver:n,onDragLeave:r,onDrop:a,onFilePick:o}){return e.jsxs("label",{onDragOver:n,onDragLeave:r,onDrop:a,style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"var(--spacing-xl, 32px)",border:`2px dashed ${t?"var(--accent-active)":"var(--border-default)"}`,borderRadius:12,background:t?"var(--bg-elevated, rgba(255,255,255,0.03))":"var(--bg-input)",cursor:"pointer",textAlign:"center",gap:"var(--spacing-xs, 4px)"},children:[e.jsx("input",{ref:s,type:"file",multiple:!0,onChange:o,style:{display:"none"}}),e.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-primary)",fontWeight:500},children:"Drop files here, or click to choose"}),e.jsx("div",{style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:"PNG, JPG, PDF, Markdown — anything that describes your design"})]})}const tP=Object.freeze(Object.defineProperty({__proto__:null,DesignAssetDropLabel:ch},Symbol.toStringTag,{value:"Module"}));function dh({pending:t,onDescriptionChange:s,onRemove:n}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-xs, 4px)",padding:"var(--spacing-sm, 8px)",border:"1px solid var(--border-default)",borderRadius:8,background:"var(--bg-input)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-primary)",fontWeight:500},children:t.file.name}),e.jsx("button",{type:"button",onClick:()=>n(t.id),style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)",background:"transparent",border:"none",cursor:"pointer"},children:"Remove"})]}),e.jsx("textarea",{value:t.description,onChange:r=>s(t.id,r.target.value),placeholder:"What does this file show? (optional)",rows:2,style:{width:"100%",padding:"var(--spacing-sm, 8px)",background:"var(--bg-default)",border:"1px solid var(--border-default)",borderRadius:6,color:"var(--text-primary)",fontSize:"var(--text-xs, 12px)",resize:"vertical",outline:"none",fontFamily:"inherit"}})]})}const sP=Object.freeze(Object.defineProperty({__proto__:null,PendingFileCard:dh},Symbol.toStringTag,{value:"Module"}));function uh({pending:t,onDescriptionChange:s,onRemove:n}){return t.length===0?null:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-sm, 8px)",marginTop:"var(--spacing-md, 12px)"},children:t.map(r=>e.jsx(dh,{pending:r,onDescriptionChange:s,onRemove:n},r.id))})}const nP=Object.freeze(Object.defineProperty({__proto__:null,PendingFileList:uh},Symbol.toStringTag,{value:"Module"}));function hh({message:t}){return t?e.jsx("div",{style:{marginTop:"var(--spacing-sm, 8px)",color:"var(--accent-danger, #f87171)",fontSize:"var(--text-xs, 12px)"},children:t}):null}const rP=Object.freeze(Object.defineProperty({__proto__:null,AssetSaveErrorMessage:hh},Symbol.toStringTag,{value:"Module"}));function ph({filenames:t}){return!t||t.length===0?null:e.jsxs("div",{style:{marginTop:"var(--spacing-sm, 8px)",color:"var(--text-secondary)",fontSize:"var(--text-xs, 12px)"},children:["Added ",t.length," file",t.length===1?"":"s","."]})}const aP=Object.freeze(Object.defineProperty({__proto__:null,AssetSaveSuccessMessage:ph},Symbol.toStringTag,{value:"Module"}));function mh({disabled:t,submitting:s,onClick:n}){return e.jsx("button",{type:"button",onClick:n,disabled:t,style:{marginTop:"var(--spacing-md, 12px)",padding:"var(--spacing-sm, 8px) var(--spacing-md, 12px)",background:t?"var(--bg-input)":"var(--accent-active)",color:t?"var(--text-muted)":"var(--text-on-accent, white)",border:t?"1px solid var(--border-default)":"1px solid var(--accent-active)",borderRadius:6,fontSize:"var(--text-sm, 14px)",fontWeight:500,cursor:t?"not-allowed":"pointer"},children:s?"Saving…":"Save assets"})}const oP=Object.freeze(Object.defineProperty({__proto__:null,SaveAssetsButton:mh},Symbol.toStringTag,{value:"Module"})),Ci=1024*1024*1024;function go({onAssetsSaved:t}){const[s,n]=l.useState([]),[r,a]=l.useState(!1),[o,i]=l.useState(null),[c,d]=l.useState(null),[u,h]=l.useState(!1),p=l.useRef(null),m=l.useCallback(x=>{d(null);const y=x.filter(w=>w.size>Ci?(d(`${w.name} is larger than the ${Ci/(1024*1024*1024)}GB safety ceiling`),!1):!0);n(w=>[...w,...y.map(j=>({id:`${j.name}-${j.size}-${Math.random().toString(36).slice(2)}`,file:j,description:""}))])},[]),f=l.useCallback(x=>{x.target.files&&m(Array.from(x.target.files)),x.target.value=""},[m]),b=l.useCallback((x,y)=>{n(w=>w.map(j=>j.id===x?{...j,description:y}:j))},[]),g=l.useCallback(x=>{n(y=>y.filter(w=>w.id!==x))},[]),v=l.useCallback(async()=>{if(s.length!==0){a(!0),d(null);try{const x=new FormData;for(const k of s)x.append("description",k.description),x.append("file",k.file,k.file.name);const y=await fetch("/api/editor-design-assets",{method:"POST",body:x});if(!y.ok)throw new Error(y.status===413?"That file is too large to add.":`Could not save assets (status ${y.status}).`);const j=(await y.json()).written??s.map(k=>k.file.name);i(j),n([]),t==null||t(j)}catch(x){d(x instanceof Error?x.message:String(x))}finally{a(!1)}}},[s,t]);return e.jsxs(e.Fragment,{children:[e.jsx(ch,{dragActive:u,inputRef:p,onDragOver:x=>{x.preventDefault(),h(!0)},onDragLeave:()=>h(!1),onDrop:x=>{x.preventDefault(),h(!1),m(Array.from(x.dataTransfer.files))},onFilePick:f}),e.jsx(uh,{pending:s,onDescriptionChange:b,onRemove:g}),e.jsx(hh,{message:c}),e.jsx(ph,{filenames:o}),e.jsx(mh,{disabled:s.length===0||r,submitting:r,onClick:v})]})}const iP=Object.freeze(Object.defineProperty({__proto__:null,DesignAssetDropZone:go},Symbol.toStringTag,{value:"Module"}));function xt({title:t,subtitle:s,children:n}){return e.jsxs("div",{children:[e.jsx("h2",{style:{fontSize:"var(--text-xl, 22px)",fontWeight:700,color:"var(--text-primary)",marginBottom:"var(--spacing-xs, 4px)"},children:t}),e.jsx("p",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-muted)",marginBottom:"var(--spacing-lg, 24px)"},children:s}),n]})}const lP=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireStepPanel:xt},Symbol.toStringTag,{value:"Module"}));function fh({onAssetsSaved:t}){return e.jsx(xt,{title:"Add your design files",subtitle:"Drop in anything: brand assets, mockups, references. Tell us briefly what each one shows.",children:e.jsx(go,{onAssetsSaved:t})})}const cP=Object.freeze(Object.defineProperty({__proto__:null,DesignAddAssetsStep:fh},Symbol.toStringTag,{value:"Module"}));function ls({label:t,description:s,selected:n,onClick:r,multi:a}){return e.jsxs("button",{onClick:r,style:{display:"flex",alignItems:"center",gap:"var(--spacing-md, 12px)",width:"100%",textAlign:"left",padding:"var(--spacing-sm, 8px) var(--spacing-md, 12px)",background:"var(--bg-input)",border:n?"1.5px solid var(--accent-active)":"1px solid var(--border-default)",borderRadius:8,cursor:"pointer",transition:"border-color 0.15s"},children:[e.jsx(gh,{selected:n,multi:a}),e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:"var(--text-sm, 14px)",fontWeight:500,color:"var(--text-primary)"},children:t}),s&&e.jsx("span",{style:{display:"block",fontSize:"var(--text-xs, 12px)",color:"var(--text-muted)",marginTop:2},children:s})]})]})}function gh({selected:t,multi:s}){return e.jsx("span",{style:{width:16,height:16,borderRadius:s?3:"50%",border:t?"none":"1.5px solid var(--text-dim)",background:t?"var(--accent-active)":"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:t&&e.jsx("span",{style:{color:"#000",fontSize:11,fontWeight:700,lineHeight:1},children:"✓"})})}const dP=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireOptionCard:ls,QuestionnaireOptionIndicator:gh},Symbol.toStringTag,{value:"Module"})),uw=[{id:"files",label:"I have design files and/or a design system",description:"Add screenshots, mockups, brand guides — anything that defines the look you want."},{id:"chat",label:"I need help on this, can we chat about it?",description:"After setup we'll generate mockups against curated moodboards and you pick a direction."},{id:"skip",label:"I'm not too worried about design, can we start building?",description:"Skip design for now. You can revisit it any time."}];function bh({selected:t,onSelect:s}){return e.jsx(xt,{title:"How should we approach design?",subtitle:"Pick whichever feels right — you can always change direction later.",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-sm, 8px)"},children:uw.map(n=>e.jsx(ls,{label:n.label,description:n.description,selected:t===n.id,onClick:()=>s(n.id)},n.id))})})}const uP=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireDesignApproachStep:bh},Symbol.toStringTag,{value:"Module"}));function xh(){const[t,s]=l.useState(()=>Uu());l.useEffect(()=>{Xu()},[]);const n=a=>{s(a),Vu(a)},r=()=>{n({...t,systemNotification:!0}),typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()};return e.jsx(xt,{title:"Want to be notified when Claude finishes?",subtitle:"Building can take a while. Turn on a sound or a system notification and we'll ping you when the agent stops or pauses — so you can step away while it works.",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-md, 12px)"},children:[e.jsx("button",{onClick:r,className:"text-left px-3 py-2 rounded cursor-pointer transition-colors",style:{background:t.systemNotification?"var(--bg-input)":"var(--accent-green, #16a34a)",color:t.systemNotification?"var(--text-primary)":"#fff",fontSize:"var(--text-sm, 14px)",fontWeight:600,border:"1px solid var(--border-default)"},children:t.systemNotification?"System notifications enabled":"Enable notifications"}),e.jsx("div",{className:"flex flex-col gap-3 rounded p-3",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:e.jsx(uo,{settings:t,onChange:n})}),e.jsx("p",{style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-dim)"},children:'This is optional — you can skip it and change it any time from the "Notifications" control in the footer.'})]})})}const hP=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireNotificationsStep:xh},Symbol.toStringTag,{value:"Module"}));function hw(t,s){const n=l.useRef(s);l.useEffect(()=>{n.current=s},[s]),l.useEffect(()=>{if(!t)return;let r=!1,a=null;const o=async()=>{try{const c=await(await fetch("/api/editor-design-state")).json();!r&&c.active&&n.current(c.active)}catch{}finally{r||(a=window.setTimeout(o,3e3))}};return o(),()=>{r=!0,a!==null&&window.clearTimeout(a)}},[t])}function yh({providerLabel:t,preparing:s,onLaunch:n,variant:r="chat"}){const a=r==="files"?e.jsxs(e.Fragment,{children:["Click the button below to start a design session with ",t,"."," ",t," will turn the assets you added above into HTML mockups you can compare and iterate on."]}):e.jsxs(e.Fragment,{children:["Click the button below to launch a chat window with ",t," so that ",t," can generate some design options for you to consider and iterate on."]}),o=r==="files"?e.jsxs(e.Fragment,{children:[t," reads the design assets you added in the"," ",e.jsx("strong",{children:"Add your design files"})," step above — keep adding more any time and ",t," will fold them in."]}):e.jsxs(e.Fragment,{children:[t," will ask whether you have any design assets — logos, screenshots, brand guides, or inspiration. You can add them any time from the ",e.jsx("strong",{children:"Add assets"})," panel in the Live Preview on the right (drag-and-drop or browse)."]}),i=r==="files"?"Start a design session":`Launch ${t} Design Chat`;return e.jsxs("div",{children:[e.jsx("p",{style:{margin:"0 0 var(--spacing-md, 12px)",fontSize:"var(--text-md, 15px)",lineHeight:1.5,color:"var(--text-primary)"},children:a}),e.jsx("p",{style:{margin:"0 0 var(--spacing-lg, 16px)",fontSize:"var(--text-sm, 14px)",lineHeight:1.5,color:"var(--text-secondary)"},children:o}),e.jsx("button",{onClick:n,disabled:s,style:{background:s?"var(--bg-surface)":"var(--accent-active)",border:"none",color:s?"var(--text-dim)":"#000",padding:"var(--spacing-sm, 8px) var(--spacing-lg, 16px)",borderRadius:6,cursor:s?"not-allowed":"pointer",fontSize:"var(--text-sm, 14px)",fontWeight:600},children:s?"Preparing design moodboards…":i})]})}const pP=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireDesignChatLaunchPanel:yh},Symbol.toStringTag,{value:"Module"}));function da({description:t,launched:s,onLaunched:n,onDesignSelected:r,onPreviewUrl:a,variant:o="chat"}){const[i,c]=l.useState({kind:"preparing"}),{config:d}=yt(),u=At(d==null?void 0:d.provider),h=l.useRef(s),p=o==="chat"||s;l.useEffect(()=>{if(p)return a==null||a("/design-exploration"),()=>{a==null||a(null)}},[a,p]),l.useEffect(()=>{let v=!1;return(async()=>{try{const x=!h.current,[y,w,j]=await Promise.all([fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectDescription:t,allowOverwrite:!0})}),fetch("/api/editor-design-systems-install",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"}),x?fetch("/api/editor-design-reset",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"}):Promise.resolve(null)]);if(!w.ok){const k=await w.text().catch(()=>`${w.status}`);throw new Error(k||`install failed: ${w.status}`)}if(j&&!j.ok){const k=await j.text().catch(()=>`${j.status}`);throw new Error(k||`design-reset failed: ${j.status}`)}y.ok||console.warn("[QuestionnaireDesignChatStep] editor-project-info failed; skill will prompt for description",y.status),v||c({kind:"ready"})}catch(x){v||c({kind:"error",message:x instanceof Error?x.message:String(x)})}})(),()=>{v=!0}},[t]),hw(s,r);const m=i.kind==="preparing",f=o==="files"?"Turn your assets into a mockup":"Explore design directions",b=o==="files"?"Start a design session and the agent will turn the assets you uploaded into HTML mockups — pick one by number from the Live Preview.":"Chat with the agent, share any design assets, then pick a mockup by number from the Live Preview.",g=o==="files"?"Try Skip instead, or keep uploading assets and try again.":"Try the Files or Skip approach instead.";return e.jsx(xt,{title:f,subtitle:b,children:s?e.jsx(Bs,{chatName:"initial-design",slashCommand:"/codeyam-design",height:420}):i.kind==="error"?e.jsxs("div",{style:{padding:"var(--spacing-md, 12px)",marginBottom:"var(--spacing-sm, 8px)",borderRadius:8,background:"var(--bg-danger-soft, rgba(248,113,113,0.12))",color:"var(--accent-danger, #f87171)",fontSize:"var(--text-sm, 14px)"},children:["Couldn't prepare design moodboards: ",i.message,". ",g]}):e.jsx(yh,{providerLabel:u,preparing:m,onLaunch:n,variant:o})})}const mP=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireDesignChatStep:da},Symbol.toStringTag,{value:"Module"})),pw=[{id:"Desktop",label:"Desktop",description:"Standard desktop browser viewport"},{id:"Tablet",label:"Tablet",description:"Tablet-sized portrait viewport"},{id:"Mobile",label:"Mobile",description:"Phone-sized portrait viewport"}];function vh({selected:t,onSelect:s}){return e.jsx("div",{style:{marginTop:"var(--spacing-xl, 32px)"},children:e.jsx(xt,{title:"Where will this web app primarily be viewed?",subtitle:"This sets the default viewport for every scenario captured in your project.",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-sm, 8px)"},children:pw.map(n=>e.jsx(ls,{label:n.label,description:n.description,selected:t===n.id,onClick:()=>s(n.id)},n.id))})})})}const fP=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireDeviceSelector:vh},Symbol.toStringTag,{value:"Module"}));function bo(){return e.jsx("div",{style:{padding:"var(--spacing-sm, 8px) var(--spacing-lg, 16px)",background:"var(--bg-surface)",borderBottom:"1px solid var(--border-subtle)",fontSize:"var(--text-sm, 14px)",color:"var(--text-muted)"},children:"Before we dive in, help us comprehend what you want to build better."})}const gP=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireIntroBanner:bo},Symbol.toStringTag,{value:"Module"}));function jh({step:t,canAdvance:s,isFinalStep:n,isAdvancing:r,onBack:a,onNext:o,onFinish:i}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-md, 12px)",marginTop:"var(--spacing-lg, 24px)"},children:[t>1&&e.jsx("button",{onClick:a,style:{background:"none",border:"1px solid var(--border-default)",color:"var(--text-secondary)",padding:"var(--spacing-sm, 8px) var(--spacing-lg, 16px)",borderRadius:6,cursor:"pointer",fontSize:"var(--text-sm, 14px)"},children:"← Back"}),n?e.jsx("button",{onClick:i,disabled:!s,style:{background:s?"var(--accent-active)":"var(--bg-surface)",border:"none",color:s?"#000":"var(--text-dim)",padding:"var(--spacing-sm, 8px) var(--spacing-lg, 16px)",borderRadius:6,cursor:s?"pointer":"not-allowed",fontSize:"var(--text-sm, 14px)",fontWeight:600},children:"FINISH →"}):e.jsx("button",{onClick:o,disabled:!s||r,style:{background:s?"var(--accent-active)":"var(--bg-surface)",border:"none",color:s?"#000":"var(--text-dim)",padding:"var(--spacing-sm, 8px) var(--spacing-lg, 16px)",borderRadius:6,cursor:s&&!r?"pointer":"not-allowed",fontSize:"var(--text-sm, 14px)",fontWeight:600,opacity:r?.7:1},children:r?"…":"NEXT →"})]})}const bP=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireNavButtons:jh},Symbol.toStringTag,{value:"Module"}));function wh({currentStep:t,stepLabels:s,onStepClick:n}){return e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-xs, 4px)",paddingTop:"var(--spacing-lg, 24px)"},children:s.map((r,a)=>{const o=a+1,i=o===t,c=o<t;return e.jsx("button",{onClick:()=>{c&&n(o)},style:{background:"none",border:"none",cursor:c?"pointer":"default",padding:"var(--spacing-xs, 4px) 0",fontSize:"var(--text-sm, 14px)",color:i?"var(--text-primary)":c?"var(--text-secondary)":"var(--text-dim)",fontWeight:i?500:400,textAlign:"left",transition:"color 0.15s"},children:r},o)})})}const xP=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireStepNav:wh},Symbol.toStringTag,{value:"Module"}));function mw(t,s,n){if(s.length===0||s.includes("other"))return"Strong";let r=!1,a=!1;const o=(n||"").toLowerCase();["swift","swiftui","healthkit","jetpack","native ios","ios native","android native","kotlin native","objective-c"].some(c=>o.includes(c))&&(a=!0);for(const c of s)c==="web"?t.naturalShape==="web"&&t.id!=="chrome-extension-react"&&(r=!0):c==="static"?t.naturalShape==="static-site"&&(r=!0):c==="mobile"?(t.naturalShape==="mobile-hybrid"||t.naturalShape==="native-mobile")&&(r=!0):c==="chrome-extension"&&t.id==="chrome-extension-react"&&(r=!0);return r?a&&(t.id==="expo-react-native"||t.id==="capacitor-vite-react")?"Adjacent":"Strong":"Mismatch"}const fw=[{id:"web",label:"Website/Web App"},{id:"static",label:"Static Website"},{id:"desktop",label:"Desktop App"},{id:"chrome-extension",label:"Chrome Extension"},{id:"mobile",label:"Mobile App"},{id:"other",label:"Other"}],gw={"product-type":"What Type Of Product Do You Want To Build?",description:"Describe Your Product","tech-stack":"Do You Have A Preferred Tech Stack?",notifications:"Notifications","design-approach":"How Should We Approach Design","design-details":"Design Details"},Ti=560,bw=960;function _h(t){const{projectDir:s,loaded:n}=dw(),r=l.useRef(!1);return l.useEffect(()=>{n&&!r.current&&(r.current=!0,lw())},[n]),n?e.jsx(kh,{...t,projectDir:s}):e.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"auto"},children:e.jsx(bo,{})})}function kh({onComplete:t,onPreviewUrl:s,projectDir:n}){const[r,a]=l.useState(()=>{const R=n?Lr(n):null;return R?R.step:1}),[o,i]=l.useState(()=>{const R=n?Lr(n):null;return(R==null?void 0:R.answers)??{appFormats:[],description:"",techStackId:null,designApproach:null,defaultDevice:null}}),[c,d]=l.useState(null),[u,h]=l.useState(!1),[p,m]=l.useState(()=>{const R=n?Lr(n):null;return(R==null?void 0:R.designChatLaunched)??!1}),f=l.useRef(p),{techStacks:b}=cw(),g=rw(o.designApproach),v=g[r-1],x=r===g.length,y=g.map(R=>gw[R]);l.useEffect(()=>{r>g.length&&a(g.length)},[r,g.length]);const w=l.useRef(!0);l.useEffect(()=>{if(w.current){w.current=!1;return}n!==null&&ow(n,{step:r,answers:o,designChatLaunched:p,savedAt:new Date().toISOString()})},[r,o,p,n]);const j=l.useCallback(()=>{m(!0)},[]),[k,S]=l.useState(f.current?{state:"pending"}:{state:"ready",active:null});l.useEffect(()=>{if(!f.current)return;let R=!1;return(async()=>{try{const P=await(await fetch("/api/editor-design-state")).json();R||S({state:"ready",active:P.active??null})}catch{R||S({state:"ready",active:null})}})(),()=>{R=!0}},[]);const N=l.useCallback(R=>{i(D=>{const P=D.appFormats.includes(R),$=P?D.appFormats.filter(U=>U!==R):[...D.appFormats,R],F=R==="web"&&P?null:D.defaultDevice;return{...D,appFormats:$,defaultDevice:F}})},[]),T=l.useCallback(R=>{i(D=>({...D,defaultDevice:R}))},[]),A=l.useCallback(R=>{i(D=>({...D,designApproach:D.designApproach===R?null:R}))},[]),_=l.useCallback(async()=>{await nw(o),n!==null&&iw(n),t==null||t(o)},[o,t,n]),M=l.useRef(!1);l.useEffect(()=>{M.current||k.state==="ready"&&v==="design-details"&&(o.designApproach==="chat"||o.designApproach==="files")&&c!==null&&c!==k.active&&(M.current=!0,_())},[v,o.designApproach,c,_,k]);const I=l.useCallback(()=>{a(R=>R+1)},[]),H=o.appFormats.includes("web"),z=(()=>{switch(v){case"product-type":return o.appFormats.length>0&&(!H||o.defaultDevice!==null);case"description":return o.description.trim().length>0;case"notifications":return!0;case"design-approach":return o.designApproach!==null;case"design-details":return o.designApproach==="chat"?c!==null:!0;default:return!0}})(),G=v==="description"?bw:v==="design-details"&&(o.designApproach==="chat"||o.designApproach==="files"&&p)?"100%":Ti;return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"auto"},children:[e.jsx(bo,{}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",padding:"var(--spacing-xl, 32px)"},children:[e.jsxs("div",{style:{maxWidth:G},children:[v==="product-type"&&e.jsxs(e.Fragment,{children:[e.jsx(xt,{title:"What type of product do you want to build?",subtitle:"Select as many as you need.",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-sm, 8px)"},children:fw.map(R=>e.jsx(ls,{label:R.label,selected:o.appFormats.includes(R.id),onClick:()=>N(R.id),multi:!0},R.id))})}),H&&e.jsx(vh,{selected:o.defaultDevice,onSelect:T})]}),v==="description"&&e.jsx(xt,{title:"Describe your product",subtitle:"What are you building? This helps us set up the right starting point.",children:e.jsx("textarea",{value:o.description,onChange:R=>i(D=>({...D,description:R.target.value})),placeholder:"e.g. A task management app for remote teams with real-time collaboration...",style:{width:"100%",minHeight:180,padding:"var(--spacing-md, 12px)",background:"var(--bg-input)",border:"1px solid var(--border-default)",borderRadius:8,color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",resize:"vertical",outline:"none",fontFamily:"inherit"}})}),v==="tech-stack"&&(()=>{const R=b.map(P=>{const $=mw(P,o.appFormats,o.description);let F=P.name,U=P.description;return $==="Strong"?U=P.reasonStrong||P.description:$==="Adjacent"?(F=`${P.name} (Recommended — Closest Fit)`,U=P.reasonAdjacent||P.description):$==="Mismatch"&&(F=`${P.name} (Mismatch — Pivot Required)`,U=P.reasonMismatch||P.description),{stack:P,fit:$,label:F,description:U}}),D=R.filter(P=>P.fit!=="Mismatch"||u);return e.jsxs(xt,{title:"Do you have a preferred tech stack?",subtitle:"Choose a starting template, or let CodeYam decide.",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-sm, 8px)"},children:[e.jsx(ls,{label:"Let CodeYam decide",description:"We'll pick the best stack based on your product",selected:o.techStackId===null,onClick:()=>i(P=>({...P,techStackId:null}))}),D.map(({stack:P,label:$,description:F})=>e.jsx(ls,{label:$,description:F,selected:o.techStackId===P.id,onClick:()=>i(U=>({...U,techStackId:P.id}))},P.id))]}),R.some(P=>P.fit==="Mismatch")&&e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"var(--spacing-md, 12px)"},children:e.jsx("button",{type:"button",onClick:()=>h(P=>!P),style:{background:"none",border:"none",color:"var(--accent-active)",cursor:"pointer",fontSize:"var(--text-xs, 12px)",textDecoration:"underline",padding:0},children:u?"Hide incompatible stacks":"Show all stacks"})})]})})(),v==="notifications"&&e.jsx(xh,{}),v==="design-approach"&&e.jsx(bh,{selected:o.designApproach,onSelect:A}),v==="design-details"&&o.designApproach==="files"&&e.jsxs(e.Fragment,{children:[e.jsx(fh,{}),e.jsx(da,{description:o.description,launched:p,onLaunched:j,onDesignSelected:d,onPreviewUrl:s,variant:"files"})]}),v==="design-details"&&o.designApproach==="chat"&&e.jsx(da,{description:o.description,launched:p,onLaunched:j,onDesignSelected:d,onPreviewUrl:s})]}),e.jsxs("div",{style:{maxWidth:Ti},children:[e.jsx(jh,{step:r,canAdvance:z,isFinalStep:x,onBack:()=>a(R=>R-1),onNext:()=>{z&&I()},onFinish:_}),e.jsx(wh,{currentStep:r,stepLabels:y,onStepClick:a})]})]})]})}const yP=Object.freeze(Object.defineProperty({__proto__:null,NewProjectQuestionnaire:_h,NewProjectQuestionnaireInner:kh},Symbol.toStringTag,{value:"Module"}));function Sh({projectTitle:t,projectDescription:s,stats:n,coverage:r,onSelectApp:a,configLoading:o,scenariosLoading:i,testsLoading:c,testsRefreshing:d,onRunTests:u,currentRunner:h,stepState:p,onPreviewUrl:m,onComplete:f,onOpenBuildTab:b,onCoverageClick:g,isBuilding:v=!1,buildingLabel:x,buildingStepLabel:y,buildingStepIndicator:w,buildingStatus:j,buildingProgress:k,onResetBuild:S}){const{saved:N}=H0();return n.length===0?o||i||N===null?null:!p&&!N?e.jsx(_h,{onPreviewUrl:m,onComplete:f}):e.jsx(sh,{projectDescription:s??null,onOpenBuildTab:b??(()=>{})}):e.jsxs("div",{className:"px-5 py-5",children:[e.jsx(rh,{projectTitle:t,coverage:r,onCoverageClick:g}),e.jsx(ih,{isBuilding:v,buildingLabel:x,buildingStepLabel:y,buildingStepIndicator:w,buildingStatus:j,buildingProgress:k,buildingMode:p==null?void 0:p.mode,onOpenBuilding:b??(()=>{}),onResetBuild:S??(()=>{})}),e.jsx(nh,{stats:n,onSelectApp:a,testsLoading:c,testsRefreshing:d,onRunTests:u,currentRunner:h})]})}const vP=Object.freeze(Object.defineProperty({__proto__:null,AppOverview:Sh},Symbol.toStringTag,{value:"Module"}));function Nh({sessionContent:t,stepIndicator:s}){return e.jsxs("div",{className:"flex flex-col h-full",children:[s,t]})}const jP=Object.freeze(Object.defineProperty({__proto__:null,BuildTabLayout:Nh},Symbol.toStringTag,{value:"Module"}));function Ch({activeTab:t,buildTab:s,footer:n,resultsPanel:r,minimizedResults:a,resultsMode:o}){return e.jsxs("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:t==="build"?"visible":"hidden",pointerEvents:t==="build"?"auto":"none"},children:[e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsx("div",{style:{flex:o==="full"?"0 0 50%":"1 1 auto",minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"},children:s}),o==="full"?r:null,o==="minimized"?a:null]}),n]})}const wP=Object.freeze(Object.defineProperty({__proto__:null,BuildTabPaneLayout:Ch},Symbol.toStringTag,{value:"Module"}));function xw(t=!1){return{title:"Session Ready to Resume",description:t?"CodeYam saved this build session while it was waiting on the next workflow action. Review the current feature and step below, then click resume when you're ready to continue.":"CodeYam found a saved build session for this feature. Review the current feature and step below, then click resume when you're ready to continue.",buttonLabel:"Resume Session",providersLabel:null}}function yw(t,s){const n=At(t),r=At(s);return{title:"Saved Handoff Ready",description:`A ${n} build session is still in progress for this feature. CodeYam saved the workflow state so ${r} can continue from the same step instead of starting over.`,buttonLabel:"Continue with Saved Handoff",providersLabel:`${n} to ${r}`}}function vw({resumeMode:t,previousProvider:s,currentProvider:n,awaitingUserInput:r=!1}){return t!=="handoff"||s==null||n==null||s===n?xw(r):yw(s,n)}function Th({label:t,onContinue:s}){return e.jsx("button",{onClick:s,className:"w-full px-4 py-2 text-sm rounded transition-colors cursor-pointer font-medium",style:{background:"var(--accent-active, #D7FF63)",color:"var(--text-on-accent, #0F0F0F)"},children:t})}const _P=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoveryActionButton:Th},Symbol.toStringTag,{value:"Module"}));function Ph({children:t}){return e.jsx("div",{className:"flex items-center justify-center h-full",role:"dialog","aria-modal":"true",style:{background:"var(--bg-deep)",color:"var(--text-secondary)"},children:e.jsx("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:t})})}const kP=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoveryDialog:Ph},Symbol.toStringTag,{value:"Module"}));function Oh({description:t,title:s}){return e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3",style:{color:"var(--text-primary)"},children:s}),e.jsx("p",{className:"text-sm mb-4",style:{color:"var(--text-muted)"},children:t})]})}const SP=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoveryHeader:Oh},Symbol.toStringTag,{value:"Module"}));function jn({label:t,rowClassName:s,value:n}){return e.jsxs("div",{className:s,children:[e.jsxs("span",{style:{color:"var(--text-muted)"},children:[t,":"]})," ",e.jsx("span",{style:{color:"var(--text-primary)"},children:n})]})}const NP=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoverySummaryRow:jn},Symbol.toStringTag,{value:"Module"}));function Ah({featureName:t,editorStep:s,editorStepLabel:n,providersLabel:r}){return e.jsxs("div",{className:"rounded p-3 mb-5 text-sm",style:{background:"var(--bg-deep)"},children:[t&&e.jsx(jn,{label:"Feature",value:t,rowClassName:"mb-1"}),s!=null&&n&&e.jsx(jn,{label:"Step",value:`${s} (${n})`}),r&&e.jsx(jn,{label:"Providers",value:r,rowClassName:"mt-1"})]})}const CP=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoverySummary:Ah},Symbol.toStringTag,{value:"Module"}));function jw(t){const s=l.useCallback(n=>{n.key==="Enter"&&(n.preventDefault(),t())},[t]);l.useEffect(()=>(window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)),[s])}function Rh({featureName:t,editorStep:s,workflowMode:n,previousProvider:r,currentProvider:a,resumeMode:o,awaitingUserInput:i=!1,onContinue:c}){const d=vw({resumeMode:o,previousProvider:r,currentProvider:a,awaitingUserInput:i}),u=s==null?null:ho(s,n);return jw(c),e.jsxs(Ph,{children:[e.jsx(Oh,{title:d.title,description:d.description}),e.jsx(Ah,{featureName:t,editorStep:s,editorStepLabel:u,providersLabel:d.providersLabel}),e.jsx(Th,{label:d.buttonLabel,onContinue:c})]})}const TP=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecovery:Rh},Symbol.toStringTag,{value:"Module"}));function Eh({awaitingUserInput:t,currentProvider:s,editorStep:n,featureName:r,onContinue:a,previousProvider:o,resumeMode:i,workflowMode:c}){return e.jsx(Rh,{featureName:r,editorStep:n,workflowMode:c,previousProvider:o,currentProvider:s,resumeMode:i,awaitingUserInput:t,onContinue:a})}const PP=Object.freeze(Object.defineProperty({__proto__:null,BuildTabRecoveryPanel:Eh},Symbol.toStringTag,{value:"Module"}));function ww({sessionDecision:t,sessionInfo:s,buildLaunchGateArmed:n,stepState:r}){return{recoveryFeatureName:(r==null?void 0:r.feature)??(s==null?void 0:s.feature)??null,recoveryStep:(r==null?void 0:r.step)??(s==null?void 0:s.step)??null,recoveryMode:(r==null?void 0:r.mode)??(s==null?void 0:s.mode)??null,showTerminal:!n&&(t==="continue"||t==="fresh"||t==="no-session")&&(r!==null||s!==null),shouldResumeSameProvider:t==="continue"&&(s==null?void 0:s.resumeMode)==="resume"}}const wn=8e3,_w="agent-banner-ready",kw="agent-auth-required";let On=!1,An=!1,bt=[],Pi=!1,kt=null,Nt=null,_n=!1;function Sw(){Pi||typeof window>"u"||(Pi=!0,window.addEventListener(_w,()=>{const t=!An;if(t){An=!0;const s=bt;bt=[];for(const n of s)n("banner")}if(_n&&(_n=!1,Nt&&kt===null)){K("dispatch-rename-after-auth",{label:Nt.label,reason:"first-observed-frame-after-auth"}),kt=Nt,Tn(Nt.label,Nt.send);return}kt&&(K("dispatch-rename-reapply",{label:kt.label,reason:t?"first-observed-frame":"second-observed-frame"}),Tn(kt.label,kt.send))}),window.addEventListener(kw,()=>{_n=!0,K("agent-auth-required-observed",{});const t=bt;bt=[];for(const s of t)s("auth-required")}))}Sw();function Nw(){return An?Promise.resolve("banner"):new Promise(t=>{let s=!1;const n=a=>{s||(s=!0,clearTimeout(r),t(a))};bt.push(n);const r=setTimeout(()=>{if(s)return;s=!0;const a=bt.indexOf(n);a>=0&&bt.splice(a,1),t("fallback")},wn)})}async function Mh(t,s,n=0,r=Ey,a=!1){if(On){K("dispatch-rename-suppressed",{caller:s,label:t});return}On=!0,Nt={label:t,send:r},K("dispatch-rename",{phase:"queued",caller:s,label:t,fallbackMs:wn,postReadyDelayMs:n});const o=await Nw();if(o==="auth-required"){K("dispatch-rename-deferred-for-auth",{caller:s,label:t});return}if(a&&o==="fallback"){K("dispatch-rename-skipped-no-banner",{caller:s,label:t,fallbackMs:wn});return}n>0&&await new Promise(i=>setTimeout(i,n)),o==="fallback"&&K("dispatch-rename-fallback",{caller:s,label:t,fallbackMs:wn}),K("dispatch-rename",{phase:"fired",caller:s,label:t,source:o,postReadyDelayMs:n}),kt={label:t,send:r},Tn(t,r)}function Cw(){On=!1,An=!1,bt=[],kt=null,Nt=null,_n=!1}function Tw(){On=!1,bt=[],Nt=null}const Pw="Editor";function Ow({provider:t,agentStartMode:s,currentFeature:n}){const r=l.useRef(!1);l.useEffect(()=>{if(!(r.current||t!=="claude"||s!=="fresh")){if(n!==null){r.current=!0;return}r.current=!0,Mh(Pw,"build-session-seed",Nl,void 0,!0)}},[t,s,n])}function Ih({snippet:t,onRetry:s,onDismiss:n}){return e.jsx("div",{"data-testid":"build-tab-startup-error",className:"border-b border-red-500/30 bg-red-950/40 text-red-100 px-4 py-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm mb-1",children:"Claude didn't start"}),e.jsx("pre",{"data-testid":"build-tab-startup-error-snippet",className:"font-mono text-xs whitespace-pre-wrap break-words bg-black/40 text-red-50 px-2 py-1 rounded max-h-40 overflow-auto",children:t})]}),e.jsxs("div",{className:"flex items-start gap-2 shrink-0",children:[e.jsx("button",{type:"button",onClick:s,"data-testid":"build-tab-startup-error-retry",className:"px-3 py-1.5 rounded bg-red-500 text-white text-sm font-medium cursor-pointer hover:bg-red-400",children:"Retry"}),e.jsx("button",{type:"button",onClick:n,"data-testid":"build-tab-startup-error-dismiss","aria-label":"Dismiss",title:"Dismiss",className:"px-2 py-1.5 rounded text-red-200 text-sm cursor-pointer hover:bg-red-900/40",children:"×"})]})]})})}const OP=Object.freeze(Object.defineProperty({__proto__:null,BuildTabStartupError:Ih},Symbol.toStringTag,{value:"Module"}));function xo(t,s,n){l.useEffect(()=>{const r=o=>{const i=o.target;t.current&&t.current.contains(i)||n!=null&&n.current&&n.current.contains(i)||s()},a=o=>{o.key==="Escape"&&s()};return document.addEventListener("mousedown",r),document.addEventListener("keydown",a),()=>{document.removeEventListener("mousedown",r),document.removeEventListener("keydown",a)}},[t,s,n])}function Dh(t=768){const s=`(max-width: ${t-.02}px)`,[n,r]=l.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(s).matches);return l.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const a=window.matchMedia(s);r(a.matches);const o=i=>r(i.matches);return a.addEventListener("change",o),()=>a.removeEventListener("change",o)},[s]),n}const Lh=[{label:"Remote Control",send:"/remote-control",submit:!0},{label:"Codeyam Editor",send:"/codeyam-editor",submit:!0},{label:"Clear",send:"/clear",submit:!0},{label:"Cancel (ESC)",send:"\x1B",submit:!1}];function Fh({defaultOpen:t=!1}){return Dh()?e.jsx(zh,{defaultOpen:t}):null}function zh({defaultOpen:t=!1}){const{config:s}=yt(),[n,r]=l.useState(t),a=l.useRef(null),o=l.useRef(null),i=l.useCallback(()=>r(!1),[]);xo(a,i,o);const c=s&&s.mobileTerminalCommands.length>0?s.mobileTerminalCommands:Lh,d=l.useCallback(u=>{u.submit?My(u.send):Yr(u.send),r(!1)},[]);return e.jsxs("div",{className:"absolute top-2 right-2 z-20 flex flex-col items-end",children:[e.jsx("button",{ref:o,type:"button","data-testid":"mobile-command-menu-toggle","aria-haspopup":"menu","aria-expanded":n,"aria-label":"Terminal commands",onClick:()=>r(u=>!u),className:"rounded-full bg-gray-800/90 px-3 py-1.5 text-xs font-medium text-gray-100 shadow-lg ring-1 ring-white/10 backdrop-blur active:bg-gray-700",children:"⌨ Commands"}),n&&e.jsx("div",{ref:a,role:"menu","data-testid":"mobile-command-menu-popup",className:"mt-1 min-w-[10rem] overflow-hidden rounded-lg bg-gray-800 py-1 shadow-xl ring-1 ring-white/10",children:c.map((u,h)=>e.jsx("button",{type:"button",role:"menuitem","data-testid":`mobile-command-${h}`,onClick:()=>d(u),className:"block w-full px-4 py-2 text-left text-sm text-gray-100 active:bg-gray-700",children:u.label},`${u.label}-${h}`))})]})}const AP=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_MOBILE_TERMINAL_COMMANDS:Lh,MobileTerminalCommandMenu:Fh,MobileTerminalCommandMenuPanel:zh},Symbol.toStringTag,{value:"Module"})),Aw=1e3;let ua=0;function cn(){ua=Date.now()}function Rw(){return ua===0?1/0:Date.now()-ua}function Ew(){return Rw()<Aw}function Rn(){window.focus()}function $h(t,s,n=50){const r=l.useRef(s);r.current=s,l.useEffect(()=>{const a=t.current;if(!a)return;let o=null;const i=new ResizeObserver(c=>{o&&clearTimeout(o);const d=c[0];d&&(o=setTimeout(()=>{r.current(d)},n))});return i.observe(a),()=>{o&&clearTimeout(o),i.disconnect()}},[t,n])}const En=20*1024*1024,Mw=3e4,Bh=3e3;function Hh(t){return new Promise((s,n)=>{const r=new FileReader;r.onload=()=>{const a=r.result;if(typeof a!="string"){n(new Error("Unexpected FileReader result"));return}const o=a.indexOf(",");s(o===-1?a:a.slice(o+1))},r.onerror=()=>n(r.error??new Error("read failed")),r.readAsDataURL(t)})}function Iw(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`drop-${Date.now()}-${Math.random().toString(36).slice(2)}`}function Wh(t){return/^[A-Za-z0-9._/\-]+$/.test(t)?t:`"${t.replace(/(["\\$`])/g,"\\$1")}"`}function qh(t){const s=t.items;if(!s||s.length===0||typeof s[0].webkitGetAsEntry!="function")return!1;for(const r of Array.from(s)){const a=r.webkitGetAsEntry();if(a&&a.isDirectory)return!0}return!1}function Dw({wsRef:t,insertInput:s}){const[n,r]=l.useState(!1),[a,o]=l.useState(null),i=l.useRef(new Map),c=l.useRef(0);l.useEffect(()=>{if(a===null)return;const w=window.setTimeout(()=>o(null),Bh);return()=>window.clearTimeout(w)},[a]);const d=l.useCallback(w=>{o(w)},[]),u=l.useCallback((w,j)=>{const k=i.current.get(w);k&&(i.current.delete(w),k.resolve(j))},[]),h=l.useCallback((w,j)=>{const k=i.current.get(w);k&&(i.current.delete(w),k.reject(j))},[]),p=l.useCallback(w=>{for(const[,j]of i.current)j.reject(w);i.current.clear()},[]),m=l.useCallback(async w=>{if(w.size>En)throw new Error(`File too large (max ${En/(1024*1024)} MB)`);const j=t.current;if(!j||j.readyState!==WebSocket.OPEN)throw new Error("Not connected — try again in a moment");const k=await Hh(w),S=Iw(),N=new Promise((T,A)=>{const _=window.setTimeout(()=>{i.current.delete(S)&&A(new Error("Timed out waiting for save to complete"))},Mw);i.current.set(S,{resolve:M=>{window.clearTimeout(_),T(M)},reject:M=>{window.clearTimeout(_),A(new Error(M))}})});return j.send(JSON.stringify({type:"drop",id:S,name:w.name||"unnamed",mime:w.type||"application/octet-stream",data:k})),N},[t]),f=l.useCallback(async w=>{if(w.length===0)return;const j=[];for(const k of w)try{j.push(await m(k))}catch(S){const N=S instanceof Error?S.message:String(S);d(`Attach failed: ${N}`);return}s(j.map(Wh).join(" ")+" ")},[m,d,s]),b=l.useCallback(w=>{w.dataTransfer.types.includes("Files")&&(w.preventDefault(),c.current+=1,r(!0))},[]),g=l.useCallback(w=>{w.dataTransfer.types.includes("Files")&&w.preventDefault()},[]),v=l.useCallback(w=>{w.dataTransfer.types.includes("Files")&&(c.current=Math.max(0,c.current-1),c.current===0&&r(!1))},[]),x=l.useCallback(async w=>{if(!w.dataTransfer.types.includes("Files"))return;if(w.preventDefault(),c.current=0,r(!1),qh(w.dataTransfer)){d("Folder drops are not supported — drag individual files instead");return}const j=Array.from(w.dataTransfer.files).filter(k=>k.size>0);await f(j)},[f,d]),y=l.useCallback(async w=>{var S;const j=(S=w.clipboardData)==null?void 0:S.items;if(!j)return;const k=[];for(const N of Array.from(j))if(N.kind==="file"&&N.type.startsWith("image/")){const T=N.getAsFile();T&&k.push(T)}k.length!==0&&(w.preventDefault(),await f(k))},[f]);return{dragActive:n,errorToast:a,dropHandlers:{onDragEnter:b,onDragOver:g,onDragLeave:v,onDrop:x},pasteHandler:y,resolveDrop:u,rejectDrop:h,cancelAllDrops:p,showError:d}}function Gh(t){const[s,n]=l.useState(0);l.useEffect(()=>{if(s===0)return;const a=window.setTimeout(()=>n(0),t);return()=>window.clearTimeout(a)},[s,t]);const r=l.useCallback(()=>{n(a=>a+1)},[]);return[s>0,r]}function Uh(){return e.jsx("div",{"data-testid":"terminal-drop-overlay",style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(30, 30, 30, 0.85)",color:"#D7FF63",fontFamily:"'IBM Plex Mono', monospace",fontSize:14,border:"2px dashed #D7FF63",borderRadius:6,pointerEvents:"none",zIndex:5},children:"Drop file to attach"})}const RP=Object.freeze(Object.defineProperty({__proto__:null,TerminalDropOverlay:Uh},Symbol.toStringTag,{value:"Module"}));function Vh({message:t}){return e.jsx("div",{"data-testid":"terminal-drop-toast",style:{position:"absolute",bottom:12,left:"50%",transform:"translateX(-50%)",background:"#3a1f1f",color:"#ff9494",border:"1px solid #7a3939",borderRadius:4,padding:"6px 12px",fontFamily:"'IBM Plex Mono', monospace",fontSize:12,zIndex:6,pointerEvents:"none"},children:t})}const EP=Object.freeze(Object.defineProperty({__proto__:null,TerminalDropToast:Vh},Symbol.toStringTag,{value:"Module"}));function yo(){return e.jsx("div",{"data-testid":"terminal-copied-toast",style:{position:"absolute",bottom:12,left:"50%",transform:"translateX(-50%)",background:"#1f3a23",color:"#94ff94",border:"1px solid #397a39",borderRadius:4,padding:"6px 12px",fontFamily:"'IBM Plex Mono', monospace",fontSize:12,zIndex:6,pointerEvents:"none"},children:"Copied"})}const MP=Object.freeze(Object.defineProperty({__proto__:null,TerminalCopiedToast:yo},Symbol.toStringTag,{value:"Module"})),Oi=15;function Yh({provider:t,agentStartMode:s,sessionId:n,onAgentIdle:r,onAgentActive:a,onUserInput:o,onStartupFailed:i,onStartupFailedCleared:c,suppressReconnectOnStopBuilding:d=!1}){if(It())return null;const u=l.useRef(null),h=l.useRef(null),p=l.useRef(null),m=l.useRef(null),f=l.useRef(!1),b=l.useRef(s??"fresh"),g=l.useRef(n??null),[v,x]=l.useState({kind:"connecting"}),[y,w]=l.useState(0),[j,k]=Gh(1200);l.useEffect(()=>{b.current=s??"fresh",g.current=n??null},[s,n]);const S=l.useRef(r);S.current=r;const N=l.useRef(a);N.current=a;const T=l.useRef(o);T.current=o;const A=l.useRef(i);A.current=i;const _=l.useRef(c);_.current=c;const M=Dw({wsRef:m,insertInput:z=>{var G,R;((G=m.current)==null?void 0:G.readyState)===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"input",data:z})),cn(),(R=T.current)==null||R.call(T)}}),I=l.useRef(M);I.current=M;const H=l.useCallback(z=>{var G;return((G=m.current)==null?void 0:G.readyState)===WebSocket.OPEN?(m.current.send(JSON.stringify({type:"input",data:z})),!0):!1},[]);return Iy(H,v.kind==="open"),$h(u,()=>{var z;p.current&&h.current&&(p.current.fit(),((z=m.current)==null?void 0:z.readyState)===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"resize",cols:h.current.cols,rows:h.current.rows})))}),l.useEffect(()=>{if(!u.current||f.current)return;f.current=!0;const z=new Cl.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'IBM Plex Mono', monospace",rightClickSelectsWord:!1,theme:{background:"#1e1e1e",foreground:"#cccccc",cursor:"#D7FF63",selectionBackground:"#264f78"}}),G=new Tl.FitAddon;z.loadAddon(G),z.open(u.current),h.current=z,p.current=G;const R=Pl(z,u.current,{onError:C=>I.current.showError(C),onCopy:()=>k()}),D=Ol(z,{sendInput:C=>{var E,B;((E=m.current)==null?void 0:E.readyState)===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"input",data:C})),cn(),(B=T.current)==null||B.call(T)}});requestAnimationFrame(()=>{G.fit(),z.focus()});let P=!1,$=0,F=null;function U(){try{const C=new WebSocket(Ly({provider:t,mode:b.current,sessionId:g.current??void 0,cols:z.cols,rows:z.rows}));m.current=C,C.binaryType="arraybuffer",C.onmessage=E=>{var B,se,q,ce;if(E.data instanceof ArrayBuffer)z.write(new Uint8Array(E.data));else if(typeof E.data=="string")try{const W=JSON.parse(E.data);if(W.type==="error"){P=!0,x({kind:"server-error",message:Fy(W)});return}if(W.type==="session-id")b.current="resume",g.current=W.sessionId??null;else if(W.type==="agent-idle"||W.type==="claude-idle"){const oe=typeof W.source=="string"?W.source:void 0;K("ws-message-received",{type:W.type,source:oe}),(B=S.current)==null||B.call(S,oe)}else if(W.type==="agent-active"||W.type==="claude-active")K("ws-message-received-active",{type:W.type}),(se=N.current)==null||se.call(N);else if(W.type==="idle-diag"){const{site:oe,event:fe,...xe}=W;K(`rust:${fe??"unknown"}`,{site:oe,...xe})}else W.type==="drop-complete"?I.current.resolveDrop(String(W.id??""),String(W.path??"")):W.type==="drop-error"?I.current.rejectDrop(String(W.id??""),String(W.message??"drop failed")):W.type==="startup-failed"?(q=A.current)==null||q.call(A,String(W.snippet??"")):W.type==="startup-failed-cleared"?(ce=_.current)==null||ce.call(_):W.type==="agent-banner-ready"?(K("agent-banner-ready",{}),window.dispatchEvent(new CustomEvent("agent-banner-ready"))):W.type==="agent-auth-required"?(K("agent-auth-required",{}),window.dispatchEvent(new CustomEvent("agent-auth-required"))):W.type==="agent-auth-resolved"&&(K("agent-auth-resolved",{}),window.dispatchEvent(new CustomEvent("agent-auth-resolved")))}catch{}},C.onopen=()=>{$=0,x({kind:"open"}),K("ws-open"),C.send(JSON.stringify({type:"resize",cols:z.cols,rows:z.rows}));try{typeof localStorage<"u"&&localStorage.getItem("codeyam.idleDebug")==="1"&&(C.send(JSON.stringify({type:"enable-idle-diag",sessionId:za()})),K("idle-diag-enabled"))}catch{}},C.onerror=()=>{},C.onclose=async()=>{if(K("ws-close",{reconnectAttempts:$}),I.current.cancelAllDrops("Not connected"),P){x(B=>B.kind==="server-error"?B:{kind:"ended"}),z.writeln(`\r
11
+ \x1B[90m[Terminal session ended]\x1B[0m`);return}const E=await zy();if(!P){if(!E){x({kind:"server-stopped"}),F==null||F(),F=$y(2e3,()=>{P||window.location.reload()});return}if($<Oi){const B=$<4?1e3*Math.pow(2,$):1e4;$++,x({kind:"reconnecting",attempt:$,maxAttempts:Oi}),setTimeout(()=>{P||U()},B)}else x({kind:"failed"})}}}catch{x({kind:"failed"})}}try{G.fit()}catch{}U();let J=0;const Z=1e3;function te(){var E;const C=Date.now();C-J>=Z&&((E=m.current)==null?void 0:E.readyState)===WebSocket.OPEN&&(m.current.send(JSON.stringify({type:"browser-activity"})),J=C)}document.addEventListener("mousemove",te),document.addEventListener("keydown",te),document.addEventListener("mousedown",te),z.onData(C=>{var E,B;((E=m.current)==null?void 0:E.readyState)===WebSocket.OPEN?m.current.send(JSON.stringify({type:"input",data:C})):w(se=>se+1),cn(),(B=T.current)==null||B.call(T)});const ie=u.current;function V(C){var W,oe,fe,xe;const E=C,B=(W=E.clipboardData)==null?void 0:W.items;if(B){for(const ne of Array.from(B))if(ne.kind==="file"&&ne.type.startsWith("image/")){C.preventDefault(),C.stopPropagation(),I.current.pasteHandler(E);return}}const se=((oe=E.clipboardData)==null?void 0:oe.getData("text"))??"";if(!se)return;C.preventDefault(),C.stopPropagation();const q=se.replace(/\r\n/g,"\r").replace(/\n/g,"\r"),ce=z.modes.bracketedPasteMode?`\x1B[200~${q}\x1B[201~`:q;((fe=m.current)==null?void 0:fe.readyState)===WebSocket.OPEN?m.current.send(JSON.stringify({type:"input",data:ce})):w(ne=>ne+1),cn(),(xe=T.current)==null||xe.call(T)}ie.addEventListener("paste",V,!0);function le(C){var se,q;const E=C.detail;if(!E)return;((se=m.current)==null?void 0:se.readyState)===WebSocket.OPEN?((q=m.current)==null||q.send(JSON.stringify({type:"input",data:E})),K("terminal-send-input",{len:E.length,firstChars:E.slice(0,16),wsOpen:!0,dropped:!1})):K("terminal-send-input",{len:E.length,firstChars:E.slice(0,16),wsOpen:!1,dropped:!0})}window.addEventListener("terminal-send-input",le);function me(){Rn(),z.focus()}window.addEventListener("terminal-focus",me);function Q(){var C;P=!0,(C=m.current)==null||C.close(),x({kind:"ended"}),z.reset()}return d&&window.addEventListener("build-session-stopped",Q),()=>{var C;P=!0,F==null||F(),F=null,document.removeEventListener("mousemove",te),document.removeEventListener("keydown",te),document.removeEventListener("mousedown",te),window.removeEventListener("terminal-send-input",le),window.removeEventListener("terminal-focus",me),d&&window.removeEventListener("build-session-stopped",Q),ie.removeEventListener("paste",V,!0),D(),(C=m.current)==null||C.close(),R(),z.dispose(),f.current=!1}},[t]),e.jsxs("div",{className:"relative flex-1 flex flex-col",style:{minHeight:0},"data-terminal-emulator":!0,onDragEnter:M.dropHandlers.onDragEnter,onDragOver:M.dropHandlers.onDragOver,onDragLeave:M.dropHandlers.onDragLeave,onDrop:M.dropHandlers.onDrop,onPaste:M.pasteHandler,children:[e.jsx("div",{ref:u,className:"flex-1",style:{background:"#1e1e1e",minHeight:0,paddingTop:3,paddingLeft:3},onClick:()=>{var z;Rn(),(z=h.current)==null||z.focus()}}),M.dragActive&&e.jsx(Uh,{}),M.errorToast&&e.jsx(Vh,{message:M.errorToast}),j&&e.jsx(yo,{}),e.jsx(Dy,{status:v,pulseKey:y,onRefresh:()=>window.location.reload()})]})}const IP=Object.freeze(Object.defineProperty({__proto__:null,TerminalEmulator:Yh},Symbol.toStringTag,{value:"Module"}));function Kh({onAgentActive:t,onAgentIdle:s,onUserInput:n,provider:r,sessionId:a,shouldResumeSameProvider:o,currentFeature:i}){const[c,d]=l.useState(null),[u,h]=l.useState(0);Ow({provider:r,agentStartMode:o?"resume":"fresh",currentFeature:i}),l.useEffect(()=>()=>{Cw()},[]);const p=l.useCallback(b=>{d(b)},[]),m=l.useCallback(()=>{d(null)},[]),f=l.useCallback(()=>{d(null),h(b=>b+1)},[]);return e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[c!==null&&e.jsx(Ih,{snippet:c,onRetry:f,onDismiss:m}),e.jsxs("div",{className:"relative flex flex-col flex-1 min-h-0",children:[e.jsx(Yh,{provider:r,agentStartMode:o?"resume":"fresh",sessionId:o?a:null,onAgentIdle:s,onAgentActive:t,onUserInput:n,onStartupFailed:p,onStartupFailedCleared:m,suppressReconnectOnStopBuilding:!0},u),e.jsx(Fh,{}),e.jsx("div",{className:"absolute top-2 left-2 z-20 md:left-auto md:right-2",children:e.jsx(By,{className:"rounded-full bg-gray-800/90 px-3 py-1.5 shadow-lg ring-1 ring-white/10 backdrop-blur"})})]})]})}const DP=Object.freeze(Object.defineProperty({__proto__:null,BuildTabTerminalSession:Kh},Symbol.toStringTag,{value:"Module"}));function Lw(){for(var t=arguments.length,s=new Array(t),n=0;n<t;n++)s[n]=arguments[n];return l.useMemo(()=>r=>{s.forEach(a=>a(r))},s)}const cr=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ms(t){const s=Object.prototype.toString.call(t);return s==="[object Window]"||s==="[object global]"}function vo(t){return"nodeType"in t}function We(t){var s,n;return t?ms(t)?t:vo(t)&&(s=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?s:window:window}function jo(t){const{Document:s}=We(t);return t instanceof s}function Ys(t){return ms(t)?!1:t instanceof We(t).HTMLElement}function Jh(t){return t instanceof We(t).SVGElement}function fs(t){return t?ms(t)?t.document:vo(t)?jo(t)?t:Ys(t)||Jh(t)?t.ownerDocument:document:document:document}const dt=cr?l.useLayoutEffect:l.useEffect;function wo(t){const s=l.useRef(t);return dt(()=>{s.current=t}),l.useCallback(function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return s.current==null?void 0:s.current(...r)},[])}function Fw(){const t=l.useRef(null),s=l.useCallback((r,a)=>{t.current=setInterval(r,a)},[]),n=l.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[s,n]}function Ds(t,s){s===void 0&&(s=[t]);const n=l.useRef(t);return dt(()=>{n.current!==t&&(n.current=t)},s),n}function Ks(t,s){const n=l.useRef();return l.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...s])}function Mn(t){const s=wo(t),n=l.useRef(null),r=l.useCallback(a=>{a!==n.current&&(s==null||s(a,n.current)),n.current=a},[]);return[n,r]}function ha(t){const s=l.useRef();return l.useEffect(()=>{s.current=t},[t]),s.current}let Fr={};function Js(t,s){return l.useMemo(()=>{if(s)return s;const n=Fr[t]==null?0:Fr[t]+1;return Fr[t]=n,t+"-"+n},[t,s])}function Xh(t){return function(s){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return r.reduce((o,i)=>{const c=Object.entries(i);for(const[d,u]of c){const h=o[d];h!=null&&(o[d]=h+t*u)}return o},{...s})}}const cs=Xh(1),Ls=Xh(-1);function zw(t){return"clientX"in t&&"clientY"in t}function _o(t){if(!t)return!1;const{KeyboardEvent:s}=We(t.target);return s&&t instanceof s}function $w(t){if(!t)return!1;const{TouchEvent:s}=We(t.target);return s&&t instanceof s}function pa(t){if($w(t)){if(t.touches&&t.touches.length){const{clientX:s,clientY:n}=t.touches[0];return{x:s,y:n}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:s,clientY:n}=t.changedTouches[0];return{x:s,y:n}}}return zw(t)?{x:t.clientX,y:t.clientY}:null}const Fs=Object.freeze({Translate:{toString(t){if(!t)return;const{x:s,y:n}=t;return"translate3d("+(s?Math.round(s):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:s,scaleY:n}=t;return"scaleX("+s+") scaleY("+n+")"}},Transform:{toString(t){if(t)return[Fs.Translate.toString(t),Fs.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:s,duration:n,easing:r}=t;return s+" "+n+"ms "+r}}}),Ai="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Bw(t){return t.matches(Ai)?t:t.querySelector(Ai)}const Hw={display:"none"};function Ww(t){let{id:s,value:n}=t;return He.createElement("div",{id:s,style:Hw},n)}function qw(t){let{id:s,announcement:n,ariaLiveType:r="assertive"}=t;const a={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return He.createElement("div",{id:s,style:a,role:"status","aria-live":r,"aria-atomic":!0},n)}function Gw(){const[t,s]=l.useState("");return{announce:l.useCallback(r=>{r!=null&&s(r)},[]),announcement:t}}const Qh=l.createContext(null);function Uw(t){const s=l.useContext(Qh);l.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(t)},[t,s])}function Vw(){const[t]=l.useState(()=>new Set),s=l.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[l.useCallback(r=>{let{type:a,event:o}=r;t.forEach(i=>{var c;return(c=i[a])==null?void 0:c.call(i,o)})},[t]),s]}const Yw={draggable:`
12
+ To pick up a draggable item, press the space bar.
13
+ While dragging, use the arrow keys to move the item.
14
+ Press space again to drop the item in its new position, or press escape to cancel.
15
+ `},Kw={onDragStart(t){let{active:s}=t;return"Picked up draggable item "+s.id+"."},onDragOver(t){let{active:s,over:n}=t;return n?"Draggable item "+s.id+" was moved over droppable area "+n.id+".":"Draggable item "+s.id+" is no longer over a droppable area."},onDragEnd(t){let{active:s,over:n}=t;return n?"Draggable item "+s.id+" was dropped over droppable area "+n.id:"Draggable item "+s.id+" was dropped."},onDragCancel(t){let{active:s}=t;return"Dragging was cancelled. Draggable item "+s.id+" was dropped."}};function Jw(t){let{announcements:s=Kw,container:n,hiddenTextDescribedById:r,screenReaderInstructions:a=Yw}=t;const{announce:o,announcement:i}=Gw(),c=Js("DndLiveRegion"),[d,u]=l.useState(!1);if(l.useEffect(()=>{u(!0)},[]),Uw(l.useMemo(()=>({onDragStart(p){let{active:m}=p;o(s.onDragStart({active:m}))},onDragMove(p){let{active:m,over:f}=p;s.onDragMove&&o(s.onDragMove({active:m,over:f}))},onDragOver(p){let{active:m,over:f}=p;o(s.onDragOver({active:m,over:f}))},onDragEnd(p){let{active:m,over:f}=p;o(s.onDragEnd({active:m,over:f}))},onDragCancel(p){let{active:m,over:f}=p;o(s.onDragCancel({active:m,over:f}))}}),[o,s])),!d)return null;const h=He.createElement(He.Fragment,null,He.createElement(Ww,{id:r,value:a.draggable}),He.createElement(qw,{id:c,announcement:i}));return n?Vt.createPortal(h,n):h}var Se;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(Se||(Se={}));function In(){}function Ri(t,s){return l.useMemo(()=>({sensor:t,options:s??{}}),[t,s])}function Xw(){for(var t=arguments.length,s=new Array(t),n=0;n<t;n++)s[n]=arguments[n];return l.useMemo(()=>[...s].filter(r=>r!=null),[...s])}const rt=Object.freeze({x:0,y:0});function Zh(t,s){return Math.sqrt(Math.pow(t.x-s.x,2)+Math.pow(t.y-s.y,2))}function ep(t,s){let{data:{value:n}}=t,{data:{value:r}}=s;return n-r}function Qw(t,s){let{data:{value:n}}=t,{data:{value:r}}=s;return r-n}function Ei(t){let{left:s,top:n,height:r,width:a}=t;return[{x:s,y:n},{x:s+a,y:n},{x:s,y:n+r},{x:s+a,y:n+r}]}function tp(t,s){if(!t||t.length===0)return null;const[n]=t;return n[s]}function Mi(t,s,n){return s===void 0&&(s=t.left),n===void 0&&(n=t.top),{x:s+t.width*.5,y:n+t.height*.5}}const Zw=t=>{let{collisionRect:s,droppableRects:n,droppableContainers:r}=t;const a=Mi(s,s.left,s.top),o=[];for(const i of r){const{id:c}=i,d=n.get(c);if(d){const u=Zh(Mi(d),a);o.push({id:c,data:{droppableContainer:i,value:u}})}}return o.sort(ep)},e_=t=>{let{collisionRect:s,droppableRects:n,droppableContainers:r}=t;const a=Ei(s),o=[];for(const i of r){const{id:c}=i,d=n.get(c);if(d){const u=Ei(d),h=a.reduce((m,f,b)=>m+Zh(u[b],f),0),p=Number((h/4).toFixed(4));o.push({id:c,data:{droppableContainer:i,value:p}})}}return o.sort(ep)};function t_(t,s){const n=Math.max(s.top,t.top),r=Math.max(s.left,t.left),a=Math.min(s.left+s.width,t.left+t.width),o=Math.min(s.top+s.height,t.top+t.height),i=a-r,c=o-n;if(r<a&&n<o){const d=s.width*s.height,u=t.width*t.height,h=i*c,p=h/(d+u-h);return Number(p.toFixed(4))}return 0}const s_=t=>{let{collisionRect:s,droppableRects:n,droppableContainers:r}=t;const a=[];for(const o of r){const{id:i}=o,c=n.get(i);if(c){const d=t_(c,s);d>0&&a.push({id:i,data:{droppableContainer:o,value:d}})}}return a.sort(Qw)};function n_(t,s,n){return{...t,scaleX:s&&n?s.width/n.width:1,scaleY:s&&n?s.height/n.height:1}}function sp(t,s){return t&&s?{x:t.left-s.left,y:t.top-s.top}:rt}function r_(t){return function(n){for(var r=arguments.length,a=new Array(r>1?r-1:0),o=1;o<r;o++)a[o-1]=arguments[o];return a.reduce((i,c)=>({...i,top:i.top+t*c.y,bottom:i.bottom+t*c.y,left:i.left+t*c.x,right:i.right+t*c.x}),{...n})}}const a_=r_(1);function o_(t){if(t.startsWith("matrix3d(")){const s=t.slice(9,-1).split(/, /);return{x:+s[12],y:+s[13],scaleX:+s[0],scaleY:+s[5]}}else if(t.startsWith("matrix(")){const s=t.slice(7,-1).split(/, /);return{x:+s[4],y:+s[5],scaleX:+s[0],scaleY:+s[3]}}return null}function i_(t,s,n){const r=o_(s);if(!r)return t;const{scaleX:a,scaleY:o,x:i,y:c}=r,d=t.left-i-(1-a)*parseFloat(n),u=t.top-c-(1-o)*parseFloat(n.slice(n.indexOf(" ")+1)),h=a?t.width/a:t.width,p=o?t.height/o:t.height;return{width:h,height:p,top:u,right:d+h,bottom:u+p,left:d}}const l_={ignoreTransform:!1};function gs(t,s){s===void 0&&(s=l_);let n=t.getBoundingClientRect();if(s.ignoreTransform){const{transform:u,transformOrigin:h}=We(t).getComputedStyle(t);u&&(n=i_(n,u,h))}const{top:r,left:a,width:o,height:i,bottom:c,right:d}=n;return{top:r,left:a,width:o,height:i,bottom:c,right:d}}function Ii(t){return gs(t,{ignoreTransform:!0})}function c_(t){const s=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:s,bottom:n,width:s,height:n}}function d_(t,s){return s===void 0&&(s=We(t).getComputedStyle(t)),s.position==="fixed"}function u_(t,s){s===void 0&&(s=We(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(a=>{const o=s[a];return typeof o=="string"?n.test(o):!1})}function dr(t,s){const n=[];function r(a){if(s!=null&&n.length>=s||!a)return n;if(jo(a)&&a.scrollingElement!=null&&!n.includes(a.scrollingElement))return n.push(a.scrollingElement),n;if(!Ys(a)||Jh(a)||n.includes(a))return n;const o=We(t).getComputedStyle(a);return a!==t&&u_(a,o)&&n.push(a),d_(a,o)?n:r(a.parentNode)}return t?r(t):n}function np(t){const[s]=dr(t,1);return s??null}function zr(t){return!cr||!t?null:ms(t)?t:vo(t)?jo(t)||t===fs(t).scrollingElement?window:Ys(t)?t:null:null}function rp(t){return ms(t)?t.scrollX:t.scrollLeft}function ap(t){return ms(t)?t.scrollY:t.scrollTop}function ma(t){return{x:rp(t),y:ap(t)}}var Ne;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Ne||(Ne={}));function op(t){return!cr||!t?!1:t===document.scrollingElement}function ip(t){const s={x:0,y:0},n=op(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},r={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},a=t.scrollTop<=s.y,o=t.scrollLeft<=s.x,i=t.scrollTop>=r.y,c=t.scrollLeft>=r.x;return{isTop:a,isLeft:o,isBottom:i,isRight:c,maxScroll:r,minScroll:s}}const h_={x:.2,y:.2};function p_(t,s,n,r,a){let{top:o,left:i,right:c,bottom:d}=n;r===void 0&&(r=10),a===void 0&&(a=h_);const{isTop:u,isBottom:h,isLeft:p,isRight:m}=ip(t),f={x:0,y:0},b={x:0,y:0},g={height:s.height*a.y,width:s.width*a.x};return!u&&o<=s.top+g.height?(f.y=Ne.Backward,b.y=r*Math.abs((s.top+g.height-o)/g.height)):!h&&d>=s.bottom-g.height&&(f.y=Ne.Forward,b.y=r*Math.abs((s.bottom-g.height-d)/g.height)),!m&&c>=s.right-g.width?(f.x=Ne.Forward,b.x=r*Math.abs((s.right-g.width-c)/g.width)):!p&&i<=s.left+g.width&&(f.x=Ne.Backward,b.x=r*Math.abs((s.left+g.width-i)/g.width)),{direction:f,speed:b}}function m_(t){if(t===document.scrollingElement){const{innerWidth:o,innerHeight:i}=window;return{top:0,left:0,right:o,bottom:i,width:o,height:i}}const{top:s,left:n,right:r,bottom:a}=t.getBoundingClientRect();return{top:s,left:n,right:r,bottom:a,width:t.clientWidth,height:t.clientHeight}}function lp(t){return t.reduce((s,n)=>cs(s,ma(n)),rt)}function f_(t){return t.reduce((s,n)=>s+rp(n),0)}function g_(t){return t.reduce((s,n)=>s+ap(n),0)}function b_(t,s){if(s===void 0&&(s=gs),!t)return;const{top:n,left:r,bottom:a,right:o}=s(t);np(t)&&(a<=0||o<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const x_=[["x",["left","right"],f_],["y",["top","bottom"],g_]];class ko{constructor(s,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=dr(n),a=lp(r);this.rect={...s},this.width=s.width,this.height=s.height;for(const[o,i,c]of x_)for(const d of i)Object.defineProperty(this,d,{get:()=>{const u=c(r),h=a[o]-u;return this.rect[d]+h},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ps{constructor(s){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=s}add(s,n,r){var a;(a=this.target)==null||a.addEventListener(s,n,r),this.listeners.push([s,n,r])}}function y_(t){const{EventTarget:s}=We(t);return t instanceof s?t:fs(t)}function $r(t,s){const n=Math.abs(t.x),r=Math.abs(t.y);return typeof s=="number"?Math.sqrt(n**2+r**2)>s:"x"in s&&"y"in s?n>s.x&&r>s.y:"x"in s?n>s.x:"y"in s?r>s.y:!1}var Qe;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Qe||(Qe={}));function Di(t){t.preventDefault()}function v_(t){t.stopPropagation()}var ue;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(ue||(ue={}));const cp={start:[ue.Space,ue.Enter],cancel:[ue.Esc],end:[ue.Space,ue.Enter,ue.Tab]},j_=(t,s)=>{let{currentCoordinates:n}=s;switch(t.code){case ue.Right:return{...n,x:n.x+25};case ue.Left:return{...n,x:n.x-25};case ue.Down:return{...n,y:n.y+25};case ue.Up:return{...n,y:n.y-25}}};class So{constructor(s){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=s;const{event:{target:n}}=s;this.props=s,this.listeners=new Ps(fs(n)),this.windowListeners=new Ps(We(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Qe.Resize,this.handleCancel),this.windowListeners.add(Qe.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Qe.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:n}=this.props,r=s.node.current;r&&b_(r),n(rt)}handleKeyDown(s){if(_o(s)){const{active:n,context:r,options:a}=this.props,{keyboardCodes:o=cp,coordinateGetter:i=j_,scrollBehavior:c="smooth"}=a,{code:d}=s;if(o.end.includes(d)){this.handleEnd(s);return}if(o.cancel.includes(d)){this.handleCancel(s);return}const{collisionRect:u}=r.current,h=u?{x:u.left,y:u.top}:rt;this.referenceCoordinates||(this.referenceCoordinates=h);const p=i(s,{active:n,context:r.current,currentCoordinates:h});if(p){const m=Ls(p,h),f={x:0,y:0},{scrollableAncestors:b}=r.current;for(const g of b){const v=s.code,{isTop:x,isRight:y,isLeft:w,isBottom:j,maxScroll:k,minScroll:S}=ip(g),N=m_(g),T={x:Math.min(v===ue.Right?N.right-N.width/2:N.right,Math.max(v===ue.Right?N.left:N.left+N.width/2,p.x)),y:Math.min(v===ue.Down?N.bottom-N.height/2:N.bottom,Math.max(v===ue.Down?N.top:N.top+N.height/2,p.y))},A=v===ue.Right&&!y||v===ue.Left&&!w,_=v===ue.Down&&!j||v===ue.Up&&!x;if(A&&T.x!==p.x){const M=g.scrollLeft+m.x,I=v===ue.Right&&M<=k.x||v===ue.Left&&M>=S.x;if(I&&!m.y){g.scrollTo({left:M,behavior:c});return}I?f.x=g.scrollLeft-M:f.x=v===ue.Right?g.scrollLeft-k.x:g.scrollLeft-S.x,f.x&&g.scrollBy({left:-f.x,behavior:c});break}else if(_&&T.y!==p.y){const M=g.scrollTop+m.y,I=v===ue.Down&&M<=k.y||v===ue.Up&&M>=S.y;if(I&&!m.x){g.scrollTo({top:M,behavior:c});return}I?f.y=g.scrollTop-M:f.y=v===ue.Down?g.scrollTop-k.y:g.scrollTop-S.y,f.y&&g.scrollBy({top:-f.y,behavior:c});break}}this.handleMove(s,cs(Ls(p,this.referenceCoordinates),f))}}}handleMove(s,n){const{onMove:r}=this.props;s.preventDefault(),r(n)}handleEnd(s){const{onEnd:n}=this.props;s.preventDefault(),this.detach(),n()}handleCancel(s){const{onCancel:n}=this.props;s.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}So.activators=[{eventName:"onKeyDown",handler:(t,s,n)=>{let{keyboardCodes:r=cp,onActivation:a}=s,{active:o}=n;const{code:i}=t.nativeEvent;if(r.start.includes(i)){const c=o.activatorNode.current;return c&&t.target!==c?!1:(t.preventDefault(),a==null||a({event:t.nativeEvent}),!0)}return!1}}];function Li(t){return!!(t&&"distance"in t)}function Fi(t){return!!(t&&"delay"in t)}class No{constructor(s,n,r){var a;r===void 0&&(r=y_(s.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=s,this.events=n;const{event:o}=s,{target:i}=o;this.props=s,this.events=n,this.document=fs(i),this.documentListeners=new Ps(this.document),this.listeners=new Ps(r),this.windowListeners=new Ps(We(i)),this.initialCoordinates=(a=pa(o))!=null?a:rt,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:s,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(s.move.name,this.handleMove,{passive:!1}),this.listeners.add(s.end.name,this.handleEnd),s.cancel&&this.listeners.add(s.cancel.name,this.handleCancel),this.windowListeners.add(Qe.Resize,this.handleCancel),this.windowListeners.add(Qe.DragStart,Di),this.windowListeners.add(Qe.VisibilityChange,this.handleCancel),this.windowListeners.add(Qe.ContextMenu,Di),this.documentListeners.add(Qe.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Fi(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(Li(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(s,n){const{active:r,onPending:a}=this.props;a(r,s,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:s}=this,{onStart:n}=this.props;s&&(this.activated=!0,this.documentListeners.add(Qe.Click,v_,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Qe.SelectionChange,this.removeTextSelection),n(s))}handleMove(s){var n;const{activated:r,initialCoordinates:a,props:o}=this,{onMove:i,options:{activationConstraint:c}}=o;if(!a)return;const d=(n=pa(s))!=null?n:rt,u=Ls(a,d);if(!r&&c){if(Li(c)){if(c.tolerance!=null&&$r(u,c.tolerance))return this.handleCancel();if($r(u,c.distance))return this.handleStart()}if(Fi(c)&&$r(u,c.tolerance))return this.handleCancel();this.handlePending(c,u);return}s.cancelable&&s.preventDefault(),i(d)}handleEnd(){const{onAbort:s,onEnd:n}=this.props;this.detach(),this.activated||s(this.props.active),n()}handleCancel(){const{onAbort:s,onCancel:n}=this.props;this.detach(),this.activated||s(this.props.active),n()}handleKeydown(s){s.code===ue.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const w_={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Co extends No{constructor(s){const{event:n}=s,r=fs(n.target);super(s,w_,r)}}Co.activators=[{eventName:"onPointerDown",handler:(t,s)=>{let{nativeEvent:n}=t,{onActivation:r}=s;return!n.isPrimary||n.button!==0?!1:(r==null||r({event:n}),!0)}}];const __={move:{name:"mousemove"},end:{name:"mouseup"}};var fa;(function(t){t[t.RightClick=2]="RightClick"})(fa||(fa={}));class k_ extends No{constructor(s){super(s,__,fs(s.event.target))}}k_.activators=[{eventName:"onMouseDown",handler:(t,s)=>{let{nativeEvent:n}=t,{onActivation:r}=s;return n.button===fa.RightClick?!1:(r==null||r({event:n}),!0)}}];const Br={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class S_ extends No{constructor(s){super(s,Br)}static setup(){return window.addEventListener(Br.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(Br.move.name,s)};function s(){}}}S_.activators=[{eventName:"onTouchStart",handler:(t,s)=>{let{nativeEvent:n}=t,{onActivation:r}=s;const{touches:a}=n;return a.length>1?!1:(r==null||r({event:n}),!0)}}];var Os;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(Os||(Os={}));var Dn;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(Dn||(Dn={}));function N_(t){let{acceleration:s,activator:n=Os.Pointer,canScroll:r,draggingRect:a,enabled:o,interval:i=5,order:c=Dn.TreeOrder,pointerCoordinates:d,scrollableAncestors:u,scrollableAncestorRects:h,delta:p,threshold:m}=t;const f=T_({delta:p,disabled:!o}),[b,g]=Fw(),v=l.useRef({x:0,y:0}),x=l.useRef({x:0,y:0}),y=l.useMemo(()=>{switch(n){case Os.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case Os.DraggableRect:return a}},[n,a,d]),w=l.useRef(null),j=l.useCallback(()=>{const S=w.current;if(!S)return;const N=v.current.x*x.current.x,T=v.current.y*x.current.y;S.scrollBy(N,T)},[]),k=l.useMemo(()=>c===Dn.TreeOrder?[...u].reverse():u,[c,u]);l.useEffect(()=>{if(!o||!u.length||!y){g();return}for(const S of k){if((r==null?void 0:r(S))===!1)continue;const N=u.indexOf(S),T=h[N];if(!T)continue;const{direction:A,speed:_}=p_(S,T,y,s,m);for(const M of["x","y"])f[M][A[M]]||(_[M]=0,A[M]=0);if(_.x>0||_.y>0){g(),w.current=S,b(j,i),v.current=_,x.current=A;return}}v.current={x:0,y:0},x.current={x:0,y:0},g()},[s,j,r,g,o,i,JSON.stringify(y),JSON.stringify(f),b,u,k,h,JSON.stringify(m)])}const C_={x:{[Ne.Backward]:!1,[Ne.Forward]:!1},y:{[Ne.Backward]:!1,[Ne.Forward]:!1}};function T_(t){let{delta:s,disabled:n}=t;const r=ha(s);return Ks(a=>{if(n||!r||!a)return C_;const o={x:Math.sign(s.x-r.x),y:Math.sign(s.y-r.y)};return{x:{[Ne.Backward]:a.x[Ne.Backward]||o.x===-1,[Ne.Forward]:a.x[Ne.Forward]||o.x===1},y:{[Ne.Backward]:a.y[Ne.Backward]||o.y===-1,[Ne.Forward]:a.y[Ne.Forward]||o.y===1}}},[n,s,r])}function P_(t,s){const n=s!=null?t.get(s):void 0,r=n?n.node.current:null;return Ks(a=>{var o;return s==null?null:(o=r??a)!=null?o:null},[r,s])}function O_(t,s){return l.useMemo(()=>t.reduce((n,r)=>{const{sensor:a}=r,o=a.activators.map(i=>({eventName:i.eventName,handler:s(i.handler,r)}));return[...n,...o]},[]),[t,s])}var zs;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(zs||(zs={}));var ga;(function(t){t.Optimized="optimized"})(ga||(ga={}));const zi=new Map;function A_(t,s){let{dragging:n,dependencies:r,config:a}=s;const[o,i]=l.useState(null),{frequency:c,measure:d,strategy:u}=a,h=l.useRef(t),p=v(),m=Ds(p),f=l.useCallback(function(x){x===void 0&&(x=[]),!m.current&&i(y=>y===null?x:y.concat(x.filter(w=>!y.includes(w))))},[m]),b=l.useRef(null),g=Ks(x=>{if(p&&!n)return zi;if(!x||x===zi||h.current!==t||o!=null){const y=new Map;for(let w of t){if(!w)continue;if(o&&o.length>0&&!o.includes(w.id)&&w.rect.current){y.set(w.id,w.rect.current);continue}const j=w.node.current,k=j?new ko(d(j),j):null;w.rect.current=k,k&&y.set(w.id,k)}return y}return x},[t,o,n,p,d]);return l.useEffect(()=>{h.current=t},[t]),l.useEffect(()=>{p||f()},[n,p]),l.useEffect(()=>{o&&o.length>0&&i(null)},[JSON.stringify(o)]),l.useEffect(()=>{p||typeof c!="number"||b.current!==null||(b.current=setTimeout(()=>{f(),b.current=null},c))},[c,p,f,...r]),{droppableRects:g,measureDroppableContainers:f,measuringScheduled:o!=null};function v(){switch(u){case zs.Always:return!1;case zs.BeforeDragging:return n;default:return!n}}}function dp(t,s){return Ks(n=>t?n||(typeof s=="function"?s(t):t):null,[s,t])}function R_(t,s){return dp(t,s)}function E_(t){let{callback:s,disabled:n}=t;const r=wo(s),a=l.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(r)},[r,n]);return l.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function ur(t){let{callback:s,disabled:n}=t;const r=wo(s),a=l.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(r)},[n]);return l.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function M_(t){return new ko(gs(t),t)}function $i(t,s,n){s===void 0&&(s=M_);const[r,a]=l.useState(null);function o(){a(d=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=d??n)!=null?u:null}const h=s(t);return JSON.stringify(d)===JSON.stringify(h)?d:h})}const i=E_({callback(d){if(t)for(const u of d){const{type:h,target:p}=u;if(h==="childList"&&p instanceof HTMLElement&&p.contains(t)){o();break}}}}),c=ur({callback:o});return dt(()=>{o(),t?(c==null||c.observe(t),i==null||i.observe(document.body,{childList:!0,subtree:!0})):(c==null||c.disconnect(),i==null||i.disconnect())},[t]),r}function I_(t){const s=dp(t);return sp(t,s)}const Bi=[];function D_(t){const s=l.useRef(t),n=Ks(r=>t?r&&r!==Bi&&t&&s.current&&t.parentNode===s.current.parentNode?r:dr(t):Bi,[t]);return l.useEffect(()=>{s.current=t},[t]),n}function L_(t){const[s,n]=l.useState(null),r=l.useRef(t),a=l.useCallback(o=>{const i=zr(o.target);i&&n(c=>c?(c.set(i,ma(i)),new Map(c)):null)},[]);return l.useEffect(()=>{const o=r.current;if(t!==o){i(o);const c=t.map(d=>{const u=zr(d);return u?(u.addEventListener("scroll",a,{passive:!0}),[u,ma(u)]):null}).filter(d=>d!=null);n(c.length?new Map(c):null),r.current=t}return()=>{i(t),i(o)};function i(c){c.forEach(d=>{const u=zr(d);u==null||u.removeEventListener("scroll",a)})}},[a,t]),l.useMemo(()=>t.length?s?Array.from(s.values()).reduce((o,i)=>cs(o,i),rt):lp(t):rt,[t,s])}function Hi(t,s){s===void 0&&(s=[]);const n=l.useRef(null);return l.useEffect(()=>{n.current=null},s),l.useEffect(()=>{const r=t!==rt;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?Ls(t,n.current):rt}function F_(t){l.useEffect(()=>{if(!cr)return;const s=t.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of s)n==null||n()}},t.map(s=>{let{sensor:n}=s;return n}))}function z_(t,s){return l.useMemo(()=>t.reduce((n,r)=>{let{eventName:a,handler:o}=r;return n[a]=i=>{o(i,s)},n},{}),[t,s])}function up(t){return l.useMemo(()=>t?c_(t):null,[t])}const Wi=[];function $_(t,s){s===void 0&&(s=gs);const[n]=t,r=up(n?We(n):null),[a,o]=l.useState(Wi);function i(){o(()=>t.length?t.map(d=>op(d)?r:new ko(s(d),d)):Wi)}const c=ur({callback:i});return dt(()=>{c==null||c.disconnect(),i(),t.forEach(d=>c==null?void 0:c.observe(d))},[t]),a}function B_(t){if(!t)return null;if(t.children.length>1)return t;const s=t.children[0];return Ys(s)?s:t}function H_(t){let{measure:s}=t;const[n,r]=l.useState(null),a=l.useCallback(u=>{for(const{target:h}of u)if(Ys(h)){r(p=>{const m=s(h);return p?{...p,width:m.width,height:m.height}:m});break}},[s]),o=ur({callback:a}),i=l.useCallback(u=>{const h=B_(u);o==null||o.disconnect(),h&&(o==null||o.observe(h)),r(h?s(h):null)},[s,o]),[c,d]=Mn(i);return l.useMemo(()=>({nodeRef:c,rect:n,setRef:d}),[n,c,d])}const W_=[{sensor:Co,options:{}},{sensor:So,options:{}}],q_={current:{}},kn={draggable:{measure:Ii},droppable:{measure:Ii,strategy:zs.WhileDragging,frequency:ga.Optimized},dragOverlay:{measure:gs}};class As extends Map{get(s){var n;return s!=null&&(n=super.get(s))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(s=>{let{disabled:n}=s;return!n})}getNodeFor(s){var n,r;return(n=(r=this.get(s))==null?void 0:r.node.current)!=null?n:void 0}}const G_={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new As,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:In},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:kn,measureDroppableContainers:In,windowRect:null,measuringScheduled:!1},U_={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:In,draggableNodes:new Map,over:null,measureDroppableContainers:In},hr=l.createContext(U_),hp=l.createContext(G_);function V_(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new As}}}function Y_(t,s){switch(s.type){case Se.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case Se.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:s.coordinates.x-t.draggable.initialCoordinates.x,y:s.coordinates.y-t.draggable.initialCoordinates.y}}};case Se.DragEnd:case Se.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Se.RegisterDroppable:{const{element:n}=s,{id:r}=n,a=new As(t.droppable.containers);return a.set(r,n),{...t,droppable:{...t.droppable,containers:a}}}case Se.SetDroppableDisabled:{const{id:n,key:r,disabled:a}=s,o=t.droppable.containers.get(n);if(!o||r!==o.key)return t;const i=new As(t.droppable.containers);return i.set(n,{...o,disabled:a}),{...t,droppable:{...t.droppable,containers:i}}}case Se.UnregisterDroppable:{const{id:n,key:r}=s,a=t.droppable.containers.get(n);if(!a||r!==a.key)return t;const o=new As(t.droppable.containers);return o.delete(n),{...t,droppable:{...t.droppable,containers:o}}}default:return t}}function K_(t){let{disabled:s}=t;const{active:n,activatorEvent:r,draggableNodes:a}=l.useContext(hr),o=ha(r),i=ha(n==null?void 0:n.id);return l.useEffect(()=>{if(!s&&!r&&o&&i!=null){if(!_o(o)||document.activeElement===o.target)return;const c=a.get(i);if(!c)return;const{activatorNode:d,node:u}=c;if(!d.current&&!u.current)return;requestAnimationFrame(()=>{for(const h of[d.current,u.current]){if(!h)continue;const p=Bw(h);if(p){p.focus();break}}})}},[r,s,a,i,o]),null}function J_(t,s){let{transform:n,...r}=s;return t!=null&&t.length?t.reduce((a,o)=>o({transform:a,...r}),n):n}function X_(t){return l.useMemo(()=>({draggable:{...kn.draggable,...t==null?void 0:t.draggable},droppable:{...kn.droppable,...t==null?void 0:t.droppable},dragOverlay:{...kn.dragOverlay,...t==null?void 0:t.dragOverlay}}),[t==null?void 0:t.draggable,t==null?void 0:t.droppable,t==null?void 0:t.dragOverlay])}function Q_(t){let{activeNode:s,measure:n,initialRect:r,config:a=!0}=t;const o=l.useRef(!1),{x:i,y:c}=typeof a=="boolean"?{x:a,y:a}:a;dt(()=>{if(!i&&!c||!s){o.current=!1;return}if(o.current||!r)return;const u=s==null?void 0:s.node.current;if(!u||u.isConnected===!1)return;const h=n(u),p=sp(h,r);if(i||(p.x=0),c||(p.y=0),o.current=!0,Math.abs(p.x)>0||Math.abs(p.y)>0){const m=np(u);m&&m.scrollBy({top:p.y,left:p.x})}},[s,i,c,r,n])}const pp=l.createContext({...rt,scaleX:1,scaleY:1});var St;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(St||(St={}));const Z_=l.memo(function(s){var n,r,a,o;let{id:i,accessibility:c,autoScroll:d=!0,children:u,sensors:h=W_,collisionDetection:p=s_,measuring:m,modifiers:f,...b}=s;const g=l.useReducer(Y_,void 0,V_),[v,x]=g,[y,w]=Vw(),[j,k]=l.useState(St.Uninitialized),S=j===St.Initialized,{draggable:{active:N,nodes:T,translate:A},droppable:{containers:_}}=v,M=N!=null?T.get(N):null,I=l.useRef({initial:null,translated:null}),H=l.useMemo(()=>{var _e;return N!=null?{id:N,data:(_e=M==null?void 0:M.data)!=null?_e:q_,rect:I}:null},[N,M]),z=l.useRef(null),[G,R]=l.useState(null),[D,P]=l.useState(null),$=Ds(b,Object.values(b)),F=Js("DndDescribedBy",i),U=l.useMemo(()=>_.getEnabled(),[_]),J=X_(m),{droppableRects:Z,measureDroppableContainers:te,measuringScheduled:ie}=A_(U,{dragging:S,dependencies:[A.x,A.y],config:J.droppable}),V=P_(T,N),le=l.useMemo(()=>D?pa(D):null,[D]),me=ze(),Q=R_(V,J.draggable.measure);Q_({activeNode:N!=null?T.get(N):null,config:me.layoutShiftCompensation,initialRect:Q,measure:J.draggable.measure});const C=$i(V,J.draggable.measure,Q),E=$i(V?V.parentElement:null),B=l.useRef({activatorEvent:null,active:null,activeNode:V,collisionRect:null,collisions:null,droppableRects:Z,draggableNodes:T,draggingNode:null,draggingNodeRect:null,droppableContainers:_,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),se=_.getNodeFor((n=B.current.over)==null?void 0:n.id),q=H_({measure:J.dragOverlay.measure}),ce=(r=q.nodeRef.current)!=null?r:V,W=S?(a=q.rect)!=null?a:C:null,oe=!!(q.nodeRef.current&&q.rect),fe=I_(oe?null:C),xe=up(ce?We(ce):null),ne=D_(S?se??V:null),je=$_(ne),et=J_(f,{transform:{x:A.x-fe.x,y:A.y-fe.y,scaleX:1,scaleY:1},activatorEvent:D,active:H,activeNodeRect:C,containerNodeRect:E,draggingNodeRect:W,over:B.current.over,overlayNodeRect:q.rect,scrollableAncestors:ne,scrollableAncestorRects:je,windowRect:xe}),wt=le?cs(le,A):null,Ft=L_(ne),_t=Hi(Ft),xs=Hi(Ft,[C]),we=cs(et,_t),Ke=W?a_(W,et):null,Ae=H&&Ke?p({active:H,collisionRect:Ke,droppableRects:Z,droppableContainers:U,pointerCoordinates:wt}):null,es=tp(Ae,"id"),[qe,ts]=l.useState(null),ys=oe?et:cs(et,xs),ss=n_(ys,(o=qe==null?void 0:qe.rect)!=null?o:null,C),zt=l.useRef(null),pt=l.useCallback((_e,ke)=>{let{sensor:ge,options:Ge}=ke;if(z.current==null)return;const pe=T.get(z.current);if(!pe)return;const ve=_e.nativeEvent,L=new ge({active:z.current,activeNode:pe,event:ve,options:Ge,context:B,onAbort(ye){if(!T.get(ye))return;const{onDragAbort:Re}=$.current,be={id:ye};Re==null||Re(be),y({type:"onDragAbort",event:be})},onPending(ye,$e,Re,be){if(!T.get(ye))return;const{onDragPending:Je}=$.current,Ee={id:ye,constraint:$e,initialCoordinates:Re,offset:be};Je==null||Je(Ee),y({type:"onDragPending",event:Ee})},onStart(ye){const $e=z.current;if($e==null)return;const Re=T.get($e);if(!Re)return;const{onDragStart:be}=$.current,Ue={activatorEvent:ve,active:{id:$e,data:Re.data,rect:I}};Vt.unstable_batchedUpdates(()=>{be==null||be(Ue),k(St.Initializing),x({type:Se.DragStart,initialCoordinates:ye,active:$e}),y({type:"onDragStart",event:Ue}),R(zt.current),P(ve)})},onMove(ye){x({type:Se.DragMove,coordinates:ye})},onEnd:st(Se.DragEnd),onCancel:st(Se.DragCancel)});zt.current=L;function st(ye){return async function(){const{active:Re,collisions:be,over:Ue,scrollAdjustedTranslate:Je}=B.current;let Ee=null;if(Re&&Je){const{cancelDrop:nt}=$.current;Ee={activatorEvent:ve,active:Re,collisions:be,delta:Je,over:Ue},ye===Se.DragEnd&&typeof nt=="function"&&await Promise.resolve(nt(Ee))&&(ye=Se.DragCancel)}z.current=null,Vt.unstable_batchedUpdates(()=>{x({type:ye}),k(St.Uninitialized),ts(null),R(null),P(null),zt.current=null;const nt=ye===Se.DragEnd?"onDragEnd":"onDragCancel";if(Ee){const Bt=$.current[nt];Bt==null||Bt(Ee),y({type:nt,event:Ee})}})}}},[T]),vs=l.useCallback((_e,ke)=>(ge,Ge)=>{const pe=ge.nativeEvent,ve=T.get(Ge);if(z.current!==null||!ve||pe.dndKit||pe.defaultPrevented)return;const L={active:ve};_e(ge,ke.options,L)===!0&&(pe.dndKit={capturedBy:ke.sensor},z.current=Ge,pt(ge,ke))},[T,pt]),tt=O_(h,vs);F_(h),dt(()=>{C&&j===St.Initializing&&k(St.Initialized)},[C,j]),l.useEffect(()=>{const{onDragMove:_e}=$.current,{active:ke,activatorEvent:ge,collisions:Ge,over:pe}=B.current;if(!ke||!ge)return;const ve={active:ke,activatorEvent:ge,collisions:Ge,delta:{x:we.x,y:we.y},over:pe};Vt.unstable_batchedUpdates(()=>{_e==null||_e(ve),y({type:"onDragMove",event:ve})})},[we.x,we.y]),l.useEffect(()=>{const{active:_e,activatorEvent:ke,collisions:ge,droppableContainers:Ge,scrollAdjustedTranslate:pe}=B.current;if(!_e||z.current==null||!ke||!pe)return;const{onDragOver:ve}=$.current,L=Ge.get(es),st=L&&L.rect.current?{id:L.id,rect:L.rect.current,data:L.data,disabled:L.disabled}:null,ye={active:_e,activatorEvent:ke,collisions:ge,delta:{x:pe.x,y:pe.y},over:st};Vt.unstable_batchedUpdates(()=>{ts(st),ve==null||ve(ye),y({type:"onDragOver",event:ye})})},[es]),dt(()=>{B.current={activatorEvent:D,active:H,activeNode:V,collisionRect:Ke,collisions:Ae,droppableRects:Z,draggableNodes:T,draggingNode:ce,draggingNodeRect:W,droppableContainers:_,over:qe,scrollableAncestors:ne,scrollAdjustedTranslate:we},I.current={initial:W,translated:Ke}},[H,V,Ae,Ke,T,ce,W,Z,_,qe,ne,we]),N_({...me,delta:A,draggingRect:Ke,pointerCoordinates:wt,scrollableAncestors:ne,scrollableAncestorRects:je});const $t=l.useMemo(()=>({active:H,activeNode:V,activeNodeRect:C,activatorEvent:D,collisions:Ae,containerNodeRect:E,dragOverlay:q,draggableNodes:T,droppableContainers:_,droppableRects:Z,over:qe,measureDroppableContainers:te,scrollableAncestors:ne,scrollableAncestorRects:je,measuringConfiguration:J,measuringScheduled:ie,windowRect:xe}),[H,V,C,D,Ae,E,q,T,_,Z,qe,te,ne,je,J,ie,xe]),Fe=l.useMemo(()=>({activatorEvent:D,activators:tt,active:H,activeNodeRect:C,ariaDescribedById:{draggable:F},dispatch:x,draggableNodes:T,over:qe,measureDroppableContainers:te}),[D,tt,H,C,x,F,T,qe,te]);return He.createElement(Qh.Provider,{value:w},He.createElement(hr.Provider,{value:Fe},He.createElement(hp.Provider,{value:$t},He.createElement(pp.Provider,{value:ss},u)),He.createElement(K_,{disabled:(c==null?void 0:c.restoreFocus)===!1})),He.createElement(Jw,{...c,hiddenTextDescribedById:F}));function ze(){const _e=(G==null?void 0:G.autoScrollEnabled)===!1,ke=typeof d=="object"?d.enabled===!1:d===!1,ge=S&&!_e&&!ke;return typeof d=="object"?{...d,enabled:ge}:{enabled:ge}}}),e1=l.createContext(null),qi="button",t1="Draggable";function s1(t){let{id:s,data:n,disabled:r=!1,attributes:a}=t;const o=Js(t1),{activators:i,activatorEvent:c,active:d,activeNodeRect:u,ariaDescribedById:h,draggableNodes:p,over:m}=l.useContext(hr),{role:f=qi,roleDescription:b="draggable",tabIndex:g=0}=a??{},v=(d==null?void 0:d.id)===s,x=l.useContext(v?pp:e1),[y,w]=Mn(),[j,k]=Mn(),S=z_(i,s),N=Ds(n);dt(()=>(p.set(s,{id:s,key:o,node:y,activatorNode:j,data:N}),()=>{const A=p.get(s);A&&A.key===o&&p.delete(s)}),[p,s]);const T=l.useMemo(()=>({role:f,tabIndex:g,"aria-disabled":r,"aria-pressed":v&&f===qi?!0:void 0,"aria-roledescription":b,"aria-describedby":h.draggable}),[r,f,g,v,b,h.draggable]);return{active:d,activatorEvent:c,activeNodeRect:u,attributes:T,isDragging:v,listeners:r?void 0:S,node:y,over:m,setNodeRef:w,setActivatorNodeRef:k,transform:x}}function n1(){return l.useContext(hp)}const r1="Droppable",a1={timeout:25};function o1(t){let{data:s,disabled:n=!1,id:r,resizeObserverConfig:a}=t;const o=Js(r1),{active:i,dispatch:c,over:d,measureDroppableContainers:u}=l.useContext(hr),h=l.useRef({disabled:n}),p=l.useRef(!1),m=l.useRef(null),f=l.useRef(null),{disabled:b,updateMeasurementsFor:g,timeout:v}={...a1,...a},x=Ds(g??r),y=l.useCallback(()=>{if(!p.current){p.current=!0;return}f.current!=null&&clearTimeout(f.current),f.current=setTimeout(()=>{u(Array.isArray(x.current)?x.current:[x.current]),f.current=null},v)},[v]),w=ur({callback:y,disabled:b||!i}),j=l.useCallback((T,A)=>{w&&(A&&(w.unobserve(A),p.current=!1),T&&w.observe(T))},[w]),[k,S]=Mn(j),N=Ds(s);return l.useEffect(()=>{!w||!k.current||(w.disconnect(),p.current=!1,w.observe(k.current))},[k,w]),l.useEffect(()=>(c({type:Se.RegisterDroppable,element:{id:r,key:o,disabled:n,node:k,rect:m,data:N}}),()=>c({type:Se.UnregisterDroppable,key:o,id:r})),[r]),l.useEffect(()=>{n!==h.current.disabled&&(c({type:Se.SetDroppableDisabled,id:r,key:o,disabled:n}),h.current.disabled=n)},[r,o,n,c]),{active:i,rect:m,isOver:(d==null?void 0:d.id)===r,node:k,over:d,setNodeRef:S}}function $s(t,s,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(s,1)[0]),r}function i1(t,s){return t.reduce((n,r,a)=>{const o=s.get(r);return o&&(n[a]=o),n},Array(t.length))}function dn(t){return t!==null&&t>=0}function l1(t,s){if(t===s)return!0;if(t.length!==s.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==s[n])return!1;return!0}function c1(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const mp=t=>{let{rects:s,activeIndex:n,overIndex:r,index:a}=t;const o=$s(s,r,n),i=s[a],c=o[a];return!c||!i?null:{x:c.left-i.left,y:c.top-i.top,scaleX:c.width/i.width,scaleY:c.height/i.height}},un={scaleX:1,scaleY:1},d1=t=>{var s;let{activeIndex:n,activeNodeRect:r,index:a,rects:o,overIndex:i}=t;const c=(s=o[n])!=null?s:r;if(!c)return null;if(a===n){const u=o[i];return u?{x:0,y:n<i?u.top+u.height-(c.top+c.height):u.top-c.top,...un}:null}const d=u1(o,a,n);return a>n&&a<=i?{x:0,y:-c.height-d,...un}:a<n&&a>=i?{x:0,y:c.height+d,...un}:{x:0,y:0,...un}};function u1(t,s,n){const r=t[s],a=t[s-1],o=t[s+1];return r?n<s?a?r.top-(a.top+a.height):o?o.top-(r.top+r.height):0:o?o.top-(r.top+r.height):a?r.top-(a.top+a.height):0:0}const fp="Sortable",gp=He.createContext({activeIndex:-1,containerId:fp,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:mp,disabled:{draggable:!1,droppable:!1}});function h1(t){let{children:s,id:n,items:r,strategy:a=mp,disabled:o=!1}=t;const{active:i,dragOverlay:c,droppableRects:d,over:u,measureDroppableContainers:h}=n1(),p=Js(fp,n),m=c.rect!==null,f=l.useMemo(()=>r.map(S=>typeof S=="object"&&"id"in S?S.id:S),[r]),b=i!=null,g=i?f.indexOf(i.id):-1,v=u?f.indexOf(u.id):-1,x=l.useRef(f),y=!l1(f,x.current),w=v!==-1&&g===-1||y,j=c1(o);dt(()=>{y&&b&&h(f)},[y,f,b,h]),l.useEffect(()=>{x.current=f},[f]);const k=l.useMemo(()=>({activeIndex:g,containerId:p,disabled:j,disableTransforms:w,items:f,overIndex:v,useDragOverlay:m,sortedRects:i1(f,d),strategy:a}),[g,p,j.draggable,j.droppable,w,f,v,d,m,a]);return He.createElement(gp.Provider,{value:k},s)}const p1=t=>{let{id:s,items:n,activeIndex:r,overIndex:a}=t;return $s(n,r,a).indexOf(s)},m1=t=>{let{containerId:s,isSorting:n,wasDragging:r,index:a,items:o,newIndex:i,previousItems:c,previousContainerId:d,transition:u}=t;return!u||!r||c!==o&&a===i?!1:n?!0:i!==a&&s===d},f1={duration:200,easing:"ease"},bp="transform",g1=Fs.Transition.toString({property:bp,duration:0,easing:"linear"}),b1={roleDescription:"sortable"};function x1(t){let{disabled:s,index:n,node:r,rect:a}=t;const[o,i]=l.useState(null),c=l.useRef(n);return dt(()=>{if(!s&&n!==c.current&&r.current){const d=a.current;if(d){const u=gs(r.current,{ignoreTransform:!0}),h={x:d.left-u.left,y:d.top-u.top,scaleX:d.width/u.width,scaleY:d.height/u.height};(h.x||h.y)&&i(h)}}n!==c.current&&(c.current=n)},[s,n,r,a]),l.useEffect(()=>{o&&i(null)},[o]),o}function y1(t){let{animateLayoutChanges:s=m1,attributes:n,disabled:r,data:a,getNewIndex:o=p1,id:i,strategy:c,resizeObserverConfig:d,transition:u=f1}=t;const{items:h,containerId:p,activeIndex:m,disabled:f,disableTransforms:b,sortedRects:g,overIndex:v,useDragOverlay:x,strategy:y}=l.useContext(gp),w=v1(r,f),j=h.indexOf(i),k=l.useMemo(()=>({sortable:{containerId:p,index:j,items:h},...a}),[p,a,j,h]),S=l.useMemo(()=>h.slice(h.indexOf(i)),[h,i]),{rect:N,node:T,isOver:A,setNodeRef:_}=o1({id:i,data:k,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...d}}),{active:M,activatorEvent:I,activeNodeRect:H,attributes:z,setNodeRef:G,listeners:R,isDragging:D,over:P,setActivatorNodeRef:$,transform:F}=s1({id:i,data:k,attributes:{...b1,...n},disabled:w.draggable}),U=Lw(_,G),J=!!M,Z=J&&!b&&dn(m)&&dn(v),te=!x&&D,ie=te&&Z?F:null,le=Z?ie??(c??y)({rects:g,activeNodeRect:H,activeIndex:m,overIndex:v,index:j}):null,me=dn(m)&&dn(v)?o({id:i,items:h,activeIndex:m,overIndex:v}):j,Q=M==null?void 0:M.id,C=l.useRef({activeId:Q,items:h,newIndex:me,containerId:p}),E=h!==C.current.items,B=s({active:M,containerId:p,isDragging:D,isSorting:J,id:i,index:j,items:h,newIndex:C.current.newIndex,previousItems:C.current.items,previousContainerId:C.current.containerId,transition:u,wasDragging:C.current.activeId!=null}),se=x1({disabled:!B,index:j,node:T,rect:N});return l.useEffect(()=>{J&&C.current.newIndex!==me&&(C.current.newIndex=me),p!==C.current.containerId&&(C.current.containerId=p),h!==C.current.items&&(C.current.items=h)},[J,me,p,h]),l.useEffect(()=>{if(Q===C.current.activeId)return;if(Q!=null&&C.current.activeId==null){C.current.activeId=Q;return}const ce=setTimeout(()=>{C.current.activeId=Q},50);return()=>clearTimeout(ce)},[Q]),{active:M,activeIndex:m,attributes:z,data:k,rect:N,index:j,newIndex:me,items:h,isOver:A,isSorting:J,isDragging:D,listeners:R,node:T,overIndex:v,over:P,setNodeRef:U,setActivatorNodeRef:$,setDroppableNodeRef:_,setDraggableNodeRef:G,transform:se??le,transition:q()};function q(){if(se||E&&C.current.newIndex===j)return g1;if(!(te&&!_o(I)||!u)&&(J||B))return Fs.Transition.toString({...u,property:bp})}}function v1(t,s){var n,r;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(n=t==null?void 0:t.draggable)!=null?n:s.draggable,droppable:(r=t==null?void 0:t.droppable)!=null?r:s.droppable}}function Ln(t){if(!t)return!1;const s=t.data.current;return!!(s&&"sortable"in s&&typeof s.sortable=="object"&&"containerId"in s.sortable&&"items"in s.sortable&&"index"in s.sortable)}const j1=[ue.Down,ue.Right,ue.Up,ue.Left],w1=(t,s)=>{let{context:{active:n,collisionRect:r,droppableRects:a,droppableContainers:o,over:i,scrollableAncestors:c}}=s;if(j1.includes(t.code)){if(t.preventDefault(),!n||!r)return;const d=[];o.getEnabled().forEach(p=>{if(!p||p!=null&&p.disabled)return;const m=a.get(p.id);if(m)switch(t.code){case ue.Down:r.top<m.top&&d.push(p);break;case ue.Up:r.top>m.top&&d.push(p);break;case ue.Left:r.left>m.left&&d.push(p);break;case ue.Right:r.left<m.left&&d.push(p);break}});const u=e_({collisionRect:r,droppableRects:a,droppableContainers:d});let h=tp(u,"id");if(h===(i==null?void 0:i.id)&&u.length>1&&(h=u[1].id),h!=null){const p=o.get(n.id),m=o.get(h),f=m?a.get(m.id):null,b=m==null?void 0:m.node.current;if(b&&f&&p&&m){const v=dr(b).some((S,N)=>c[N]!==S),x=xp(p,m),y=_1(p,m),w=v||!x?{x:0,y:0}:{x:y?r.width-f.width:0,y:y?r.height-f.height:0},j={x:f.left,y:f.top};return w.x&&w.y?j:Ls(j,w)}}}};function xp(t,s){return!Ln(t)||!Ln(s)?!1:t.data.current.sortable.containerId===s.data.current.sortable.containerId}function _1(t,s){return!Ln(t)||!Ln(s)||!xp(t,s)?!1:t.data.current.sortable.index<s.data.current.sortable.index}function Mt(t,s=Date.now()){if(!t)return"unknown";const n=Date.parse(t);if(Number.isNaN(n))return t;const r=Math.round((s-n)/1e3);if(r<60)return"just now";const a=Math.round(r/60);if(a<60)return`${a}m ago`;const o=Math.round(a/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}function To({title:t,filePath:s}){return e.jsxs("div",{className:"px-3 py-2 border-b border-[var(--border-subtle)]",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--text-primary)] break-words",children:t}),e.jsx("div",{"data-testid":"plan-expanded-header-file-path",className:"mt-0.5 text-xs font-mono text-[var(--text-dim)] break-all",children:s})]})}const LP=Object.freeze(Object.defineProperty({__proto__:null,PlanExpandedHeader:To},Symbol.toStringTag,{value:"Module"}));function bs(){const[t,s]=l.useState(()=>Date.now());return l.useEffect(()=>{const n=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(n)},[]),t}function yp(t){return{dead:t.sessionAlive===!1}}function vp({claim:t,staleFetch:s=!1}){const n=bs(),{dead:r}=yp(t),a=t.claimedBy.agentProvider??"agent",o=r?" (inactive)":"",i=Mt(t.claimedBy.startedAt,n),c=t.source==="local"?`● this session · started ${i}`:t.source==="same-machine"?`claimed by ${a}@${t.claimedBy.machine} (same machine) · ${i}`:`claimed by ${a}@${t.claimedBy.machine} · ${i}`;return e.jsxs("span",{"data-testid":`plan-row-claim-badge-${t.slug}`,title:`Source: ${t.source}${o}${s?" (data may be stale)":""}`,className:"text-[10px] font-medium whitespace-nowrap px-1.5 py-0.5 rounded border",style:{borderColor:"var(--accent-orange)",backgroundColor:"color-mix(in srgb, var(--accent-orange) 12%, transparent)",color:"var(--text-primary)"},children:[c,o]})}const FP=Object.freeze(Object.defineProperty({__proto__:null,PlanRowClaimBadge:vp},Symbol.toStringTag,{value:"Module"}));function k1(){const[t,s]=l.useState(!1),[n,r]=l.useState(null);return{updatePlan:l.useCallback(async(o,i)=>{s(!0),r(null);try{const c=await fetch(`/api/plans/${o}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(i)});if(!c.ok){const d=await c.json().catch(()=>({}));throw new Error(d.error??`HTTP ${c.status}`)}}catch(c){const d=c instanceof Error?c.message:"Failed to save plan";throw r(d),c instanceof Error?c:new Error(d)}finally{s(!1)}},[]),saving:t,error:n}}function jp({slug:t,onClose:s}){return e.jsx("div",{className:"px-3 py-2 border-t border-[var(--border-subtle)]",children:e.jsx(Bs,{chatName:`edit-plan-${t}`,slashCommand:`/codeyam-edit-plan ${t}`,height:360,onClose:s})})}const zP=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedChat:jp},Symbol.toStringTag,{value:"Module"}));function wp({titleDraft:t,bodyDraft:s,saving:n,error:r,onTitleChange:a,onBodyChange:o,onSave:i,onCancel:c}){const d=Math.min(20,Math.max(8,s.split(`
16
+ `).length));return e.jsxs("div",{className:"border-t border-[var(--border-subtle)] px-3 py-2 flex flex-col gap-2",children:[e.jsx("input",{type:"text",value:t,onChange:u=>a(u.target.value),"aria-label":"Plan title",className:"w-full px-2 py-1 text-sm rounded border border-[var(--border-subtle)] bg-[var(--bg-input,transparent)] text-[var(--text-primary)]"}),e.jsx("textarea",{value:s,onChange:u=>o(u.target.value),"aria-label":"Plan body",rows:d,className:"w-full px-2 py-1 text-xs rounded border border-[var(--border-subtle)] bg-[var(--bg-input,transparent)] text-[var(--text-primary)] font-mono resize-y"}),r&&e.jsx("p",{className:"text-xs text-[var(--accent-red)]",role:"alert",children:r}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:c,disabled:n,className:"px-2.5 py-1 text-xs rounded border border-[var(--border-default)] bg-transparent text-[var(--text-muted)] hover:text-[var(--text-primary)] cursor-pointer disabled:opacity-60",children:"Cancel"}),e.jsx("button",{type:"button",onClick:i,disabled:n,className:"px-2.5 py-1 text-xs rounded border border-[var(--accent-active)] bg-[var(--accent-active)] text-black hover:bg-[var(--accent-active)]/90 cursor-pointer disabled:opacity-60",children:n?"Saving…":"Save"})]})]})}const $P=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedEdit:wp},Symbol.toStringTag,{value:"Module"}));function _p({onClick:t}){return e.jsx("button",{type:"button",onClick:t,className:"px-2.5 py-1 text-xs rounded border border-[var(--border-default)] bg-transparent text-[var(--text-muted)] hover:text-[var(--text-primary)] cursor-pointer",children:"Edit"})}const BP=Object.freeze(Object.defineProperty({__proto__:null,PlanRowEditButton:_p},Symbol.toStringTag,{value:"Module"}));function kp({providerLabel:t,onClick:s}){return e.jsxs("button",{type:"button",onClick:s,className:"flex items-center gap-1.5 px-2.5 py-1 rounded border text-xs cursor-pointer transition-colors border-[var(--border-default)] bg-transparent text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:border-[var(--accent-active)]/40",title:`Open a chat with ${t} seeded with this plan's contents`,children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),"Edit with ",t]})}const HP=Object.freeze(Object.defineProperty({__proto__:null,PlanRowEditChatButton:kp},Symbol.toStringTag,{value:"Module"}));function Sp({dep:t}){const s=t.title===null,n=t.satisfied?"completed":s?"missing":"blocked",r=t.satisfied?{borderColor:"var(--border-subtle)",color:"var(--text-dim)"}:{borderColor:"var(--accent-warn, #c08a2c)",color:"var(--accent-warn, #c08a2c)"};return e.jsxs("li",{"data-testid":`plan-row-dep-${t.slug}`,className:"text-sm flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded border whitespace-nowrap",style:r,children:n}),e.jsx("span",{className:t.satisfied?"text-[var(--text-dim)] truncate":"text-[var(--text-primary)] truncate",children:s?`missing: ${t.slug}`:t.title})]})}const WP=Object.freeze(Object.defineProperty({__proto__:null,PlanRowDependencyEntry:Sp},Symbol.toStringTag,{value:"Module"}));function Np({dependencies:t}){return e.jsxs("div",{"data-testid":"plan-row-deps",className:"px-3 py-2 border-b border-[var(--border-subtle)]",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-[var(--text-dim)] mb-1.5",children:"Depends on"}),e.jsx("ul",{className:"flex flex-col gap-1",children:t.map(s=>e.jsx(Sp,{dep:s},s.slug))})]})}const qP=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedDependencies:Np},Symbol.toStringTag,{value:"Module"}));function Cp({title:t,filePath:s,body:n,providerLabel:r,onEdit:a,onChat:o,dependencies:i}){return e.jsxs("div",{className:"border-t border-[var(--border-subtle)]",children:[e.jsx(To,{title:t,filePath:s}),i&&i.length>0&&e.jsx(Np,{dependencies:i}),e.jsx("div",{className:"px-3 py-2 max-h-[40vh] overflow-y-auto",children:e.jsx(vt,{variant:"compact",children:n})}),e.jsxs("div",{className:"flex gap-2 justify-end px-3 py-2 border-t border-[var(--border-subtle)]",children:[e.jsx(_p,{onClick:a}),e.jsx(kp,{providerLabel:r,onClick:o})]})]})}const GP=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedView:Cp},Symbol.toStringTag,{value:"Module"}));function Tp({plan:t,dependencies:s}){const[n,r]=l.useState("view"),[a,o]=l.useState(t.title),[i,c]=l.useState(t.body),{updatePlan:d,saving:u,error:h}=k1(),{config:p}=yt(),m=At(p==null?void 0:p.provider);return l.useEffect(()=>{o(t.title),c(t.body),r("view")},[t.slug]),n==="chat"?e.jsx(jp,{slug:t.slug,onClose:()=>r("view")}):n==="edit"?e.jsx(wp,{titleDraft:a,bodyDraft:i,saving:u,error:h,onTitleChange:o,onBodyChange:c,onSave:async()=>{try{await d(t.slug,{title:a,body:i}),r("view")}catch{}},onCancel:()=>{o(t.title),c(t.body),r("view")}}):e.jsx(Cp,{title:t.title,filePath:t.filePath,body:t.body,providerLabel:m,onEdit:()=>r("edit"),onChat:()=>r("chat"),dependencies:s})}const UP=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedBody:Tp},Symbol.toStringTag,{value:"Module"})),Pp="Building is in progress, please wait for it to complete before starting a new build session.";function Op({slug:t,onRun:s,launching:n=!1,blocked:r=!1,onBlockedClick:a}){const o=h=>{if(h.stopPropagation(),!n){if(r){a==null||a();return}s(t)}},i="text-[10px] uppercase tracking-wide px-2 py-0.5 rounded border border-[var(--accent)] text-[var(--accent)] cursor-pointer hover:bg-[var(--accent)] hover:text-[var(--surface-bg)] disabled:opacity-60 disabled:cursor-not-allowed transition",c=" opacity-60 cursor-not-allowed hover:bg-transparent hover:text-[var(--accent)]",d=n,u=r&&!n;return e.jsx("button",{type:"button",onClick:o,disabled:d,"data-testid":`plan-run-${t}`,title:u?Pp:void 0,className:i+(u?c:""),children:n?"Launching…":"Run"})}const VP=Object.freeze(Object.defineProperty({__proto__:null,PlanRunButton:Op},Symbol.toStringTag,{value:"Module"}));function Po({plan:t,expanded:s,onToggle:n,onRun:r,launching:a=!1,blocked:o=!1,onBlockedClick:i,position:c,dragHandleRef:d,dragHandleAttributes:u,dragHandleListeners:h,sortableRef:p,sortableStyle:m,isDragging:f=!1,unsatisfiedDepCount:b=0,unsatisfiedDepTooltip:g,dependencies:v,claim:x,staleFetch:y=!1,expandedBodyVariant:w="full"}){const j=k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),n())};return e.jsxs("li",{ref:p,style:m,className:`border border-[var(--border-subtle)] rounded-lg bg-[var(--bg-surface,transparent)] ${f?"opacity-60 shadow-lg":""}`,children:[e.jsxs("div",{role:"button",tabIndex:0,onClick:n,onKeyDown:j,className:"w-full text-left px-3 py-2 flex items-center justify-between gap-3 bg-transparent cursor-pointer",children:[d&&e.jsx("span",{ref:d,"data-testid":`plan-drag-${t.slug}`,"aria-label":"Reorder plan",...u??{},...h??{},onClick:k=>k.stopPropagation(),className:"cursor-grab active:cursor-grabbing text-[var(--text-dim)] select-none leading-none px-1 -ml-1",children:"⋮⋮"}),typeof c=="number"&&e.jsxs("span",{className:"text-xs text-[var(--text-dim)] tabular-nums min-w-[1.25rem]",children:[c,"."]}),e.jsx("span",{className:"flex-1 min-w-0 truncate text-sm text-[var(--text-primary)]",children:t.title}),r&&e.jsx(Op,{slug:t.slug,onRun:r,launching:a,blocked:o,onBlockedClick:i}),e.jsx("span",{className:"text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded border border-[var(--border-subtle)] text-[var(--text-dim)]",children:t.mode}),b>0&&e.jsxs("span",{"data-testid":`plan-row-blocked-${t.slug}`,title:g,className:"text-[10px] whitespace-nowrap px-1.5 py-0.5 rounded border border-[var(--border-subtle)] text-[var(--text-dim)] inline-flex items-center gap-1",children:["🔒 blocked · ",b," dep",b===1?"":"s"]}),x&&e.jsx(vp,{claim:x,staleFetch:y}),e.jsx("span",{className:"text-[10px] text-[var(--text-dim)] whitespace-nowrap",children:Mt(t.createdAt)})]}),s&&(w==="view"?e.jsxs("div",{className:"border-t border-[var(--border-subtle)]",children:[e.jsx(To,{title:t.title,filePath:t.filePath}),e.jsx("div",{className:"px-3 py-2 max-h-[40vh] overflow-y-auto",children:e.jsx(vt,{variant:"compact",children:t.body})})]}):e.jsx(Tp,{plan:t,dependencies:v}))]})}const YP=Object.freeze(Object.defineProperty({__proto__:null,PlanRow:Po},Symbol.toStringTag,{value:"Module"}));function Ap({plan:t,position:s,expanded:n,onToggle:r,onRun:a,launching:o,blocked:i,onBlockedClick:c,draggable:d,unsatisfiedDepCount:u,unsatisfiedDepTooltip:h,dependencies:p,claim:m,staleFetch:f}){const{attributes:b,listeners:g,setNodeRef:v,setActivatorNodeRef:x,transform:y,transition:w,isDragging:j}=y1({id:t.slug,disabled:!d}),k={transform:Fs.Transform.toString(y),transition:w};return e.jsx(Po,{plan:t,expanded:n,onToggle:r,onRun:a,launching:o,blocked:i,onBlockedClick:c,position:s,sortableRef:v,sortableStyle:k,isDragging:j,dragHandleRef:d?x:void 0,dragHandleAttributes:d?b:void 0,dragHandleListeners:d?g:void 0,unsatisfiedDepCount:u,unsatisfiedDepTooltip:h,dependencies:p,claim:m,staleFetch:f})}const KP=Object.freeze(Object.defineProperty({__proto__:null,SortablePlanRow:Ap},Symbol.toStringTag,{value:"Module"}));function pr({plans:t,loading:s,error:n,onRun:r,launchingSlug:a,launchError:o,blocked:i=!1,onBlockedClick:c,onReorder:d,depAnnotationsBySlug:u,dependenciesBySlug:h,claimsBySlug:p,staleFetch:m}){const[f,b]=l.useState(null),[g,v]=l.useState(null),[x,y]=l.useState(null);l.useEffect(()=>{v(null)},[t]);const w=g??t,j=w.length;return e.jsxs("div",{className:"mt-6",children:[e.jsxs("h3",{className:"text-xs font-medium uppercase tracking-wide text-[var(--text-dim)]",children:["Queued Changes (",j,")"]}),o&&e.jsxs("p",{className:"mt-2 text-sm text-[var(--accent-red)]",children:["Failed to launch plan: ",o]}),x&&e.jsxs("p",{className:"mt-2 text-sm text-[var(--accent-red)]",children:["Failed to reorder plans: ",x]}),e.jsx(Rp,{plans:w,loading:s,error:n,expandedSlug:f,onToggle:k=>b(S=>S===k?null:k),onRun:r,launchingSlug:a??null,blocked:i,onBlockedClick:c,depAnnotationsBySlug:u,dependenciesBySlug:h,claimsBySlug:p,staleFetch:m,onReorder:d?async k=>{v(k),y(null);try{await d(k.map(S=>S.slug))}catch(S){v(null),y(S instanceof Error?S.message:"Unknown error")}}:void 0})]})}function Rp({plans:t,loading:s,error:n,expandedSlug:r,onToggle:a,onRun:o,launchingSlug:i,blocked:c,onBlockedClick:d,onReorder:u,depAnnotationsBySlug:h,dependenciesBySlug:p,claimsBySlug:m,staleFetch:f}){const b=Xw(Ri(Co,{activationConstraint:{distance:4}}),Ri(So,{coordinateGetter:w1})),g=l.useMemo(()=>t.map(y=>y.slug),[t]);if(s)return e.jsx("p",{className:"mt-3 text-sm text-[var(--text-muted)]",children:"Loading plans…"});if(n)return e.jsxs("p",{className:"mt-3 text-sm text-[var(--accent-red)]",children:["Failed to load plans: ",n]});if(t.length===0)return e.jsx("p",{className:"mt-3 text-sm text-[var(--text-dim)]",children:"No plans yet. Click PLAN NEXT CHANGE to create one."});const v=y=>{const{active:w,over:j}=y;if(!j||w.id===j.id||!u)return;const k=t.findIndex(N=>N.slug===w.id),S=t.findIndex(N=>N.slug===j.id);k===-1||S===-1||u($s(t,k,S))},x=e.jsx("ul",{className:"mt-3 flex flex-col gap-2","data-testid":"plan-list",children:t.map((y,w)=>{const j=h==null?void 0:h[y.slug],k=m==null?void 0:m.get(y.slug);return e.jsx(Ap,{plan:y,position:w+1,expanded:r===y.slug,onToggle:()=>a(y.slug),onRun:o,launching:i===y.slug,blocked:c,onBlockedClick:d,draggable:!!u,unsatisfiedDepCount:j==null?void 0:j.count,unsatisfiedDepTooltip:j==null?void 0:j.tooltip,dependencies:p==null?void 0:p[y.slug],claim:k,staleFetch:f},y.slug)})});return u?e.jsx(Z_,{sensors:b,collisionDetection:Zw,onDragEnd:v,children:e.jsx(h1,{items:g,strategy:d1,children:x})}):x}const JP=Object.freeze(Object.defineProperty({__proto__:null,QueuedChangesBody:Rp,QueuedChangesSection:pr},Symbol.toStringTag,{value:"Module"}));function Ep({awaitingPlanLaunchChoice:t,configLoading:s,sessionLoading:n,sessionDecision:r,sessionInfo:a,buildLaunchGateArmed:o,stepState:i,provider:c,onContinueSession:d,onAgentIdle:u,onAgentActive:h,onUserInput:p,pendingPlans:m,pendingPlansLoading:f,pendingPlansError:b,onLaunchPlan:g,launchingSlug:v,launchError:x,onReorderPlans:y,isAgentBuilding:w}){const{recoveryFeatureName:j,recoveryStep:k,recoveryMode:S,showTerminal:N,shouldResumeSameProvider:T}=ww({sessionDecision:r,sessionInfo:a,buildLaunchGateArmed:o,stepState:i});return r==="pending"?e.jsx(Eh,{featureName:j,editorStep:k,workflowMode:S,currentProvider:c,previousProvider:(a==null?void 0:a.provider)??null,resumeMode:(a==null?void 0:a.resumeMode)??"fresh",awaitingUserInput:(a==null?void 0:a.awaitingUserInput)??!1,onContinue:d}):t&&m.length>0&&a===null&&i===null?e.jsx(lr,{children:e.jsx(pr,{plans:m,loading:f,error:b,onRun:A=>{var M;const _=((M=m.find(I=>I.slug===A))==null?void 0:M.title)??A;g(A,_)},launchingSlug:v,launchError:x,blocked:w,onReorder:y})}):N?e.jsx(Kh,{provider:c,shouldResumeSameProvider:T,sessionId:(a==null?void 0:a.sessionId)??null,onAgentIdle:u,onAgentActive:h,onUserInput:p,currentFeature:(i==null?void 0:i.feature)??null}):r==="no-session"&&i===null?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-slate-500 space-y-4 px-10 text-center",children:[e.jsx("div",{className:"text-lg font-medium text-slate-400",children:"Ready to build"}),e.jsx("p",{className:"max-w-md",children:"Your first session will start automatically. You can queue changes or wait for the project to initialize."})]}):null}const XP=Object.freeze(Object.defineProperty({__proto__:null,BuildTabSessionContent:Ep},Symbol.toStringTag,{value:"Module"}));function S1(t){return t?{step:t.step??0,feature:t.feature??null,startedAt:t.startedAt??"",mode:ht(t.mode),slug:t.slug??null}:null}const N1=3e3;function Xs(){const[t,s]=l.useState(null),[n,r]=l.useState(!0),a=l.useRef(null),o=l.useRef(null),i=l.useCallback(()=>{fetch("/api/step").then(c=>c.json()).then(c=>{const d=S1(c),u=JSON.stringify(d);u!==o.current&&(o.current=u,s(d)),r(!1)}).catch(()=>{r(!1)})},[]);return l.useEffect(()=>(i(),a.current=setInterval(i,N1),()=>{a.current&&clearInterval(a.current)}),[i]),{stepState:t,loading:n,refetch:i}}const Be={hasSession:!1,resumeMode:"fresh",provider:null,feature:null,step:null,mode:null,label:null,sessionId:null,awaitingUserInput:!1,reopenResults:!1,preview:null,agentBrokerLive:!1,resultsShown:!1};function C1(t){return{hasSession:(t==null?void 0:t.hasSession)??Be.hasSession,resumeMode:(t==null?void 0:t.resumeMode)??Be.resumeMode,provider:(t==null?void 0:t.provider)??Be.provider,feature:(t==null?void 0:t.feature)??Be.feature,step:(t==null?void 0:t.step)??Be.step,mode:(t==null?void 0:t.mode)==null?Be.mode:ht(t.mode),label:(t==null?void 0:t.label)??Be.label,sessionId:(t==null?void 0:t.sessionId)??Be.sessionId,awaitingUserInput:(t==null?void 0:t.awaitingUserInput)??Be.awaitingUserInput,reopenResults:(t==null?void 0:t.reopenResults)??Be.reopenResults,preview:(t==null?void 0:t.preview)??Be.preview,agentBrokerLive:(t==null?void 0:t.agentBrokerLive)??Be.agentBrokerLive,resultsShown:(t==null?void 0:t.resultsShown)??Be.resultsShown}}function Oo(t){const s=t==null?void 0:t.pollIntervalMs,[n,r]=l.useState(null),[a,o]=l.useState(!0),i=l.useCallback(async()=>{o(!0);try{const d=await(await fetch("/api/session-info")).json();r(C1(d))}catch{r(c=>c??Be)}finally{o(!1)}},[]);return l.useEffect(()=>{i()},[i]),l.useEffect(()=>{if(s==null||s<=0)return;const c=setInterval(()=>{i()},s);return()=>clearInterval(c)},[s,i]),{sessionInfo:n,loading:a,refetch:i}}const T1=5e3;function P1(){const[t,s]=l.useState(null),[n,r]=l.useState(!0),a=l.useRef(null);return l.useEffect(()=>{const o=()=>{fetch("/api/prompt").then(i=>i.json()).then(i=>{s(i.prompt??null),r(!1)}).catch(()=>r(!1))};return o(),a.current=setInterval(o,T1),()=>{a.current&&clearInterval(a.current)}},[]),{prompt:t,loading:n}}function O1({currentDecision:t,sessionInfo:s,sessionLoading:n,attachedSessionId:r=null}){return n||!s?t:t==="continue"&&s.hasSession?"continue":t==="fresh"&&s.hasSession&&s.resumeMode==="resume"?"fresh":s.resumeMode==="resume"&&s.hasSession&&r!=null&&s.sessionId===r?"continue":s.resumeMode==="resume"||s.resumeMode==="handoff"?"pending":"fresh"}let Sn=null;const A1=1e4;function R1(){Sn=Date.now()}function E1(){if(Sn==null)return!1;const t=Date.now()-Sn;return Sn=null,t<=A1}const Ao="codeyam.buildTab.attachedSessionId";function M1(t){try{window.sessionStorage.setItem(Ao,t)}catch{}}function I1(){try{return window.sessionStorage.getItem(Ao)}catch{return null}}function D1(){try{window.sessionStorage.removeItem(Ao)}catch{}}function L1({sessionLoading:t,sessionInfo:s,onSessionDetected:n}){const r=l.useRef(!1),a=l.useRef(void 0);a.current===void 0&&(a.current=I1());const[o,i]=l.useState(()=>E1()?"fresh":"no-session");l.useEffect(()=>{i(d=>O1({currentDecision:d,sessionInfo:s,sessionLoading:t,attachedSessionId:a.current??null})),!t&&s&&(s.resumeMode==="resume"||s.resumeMode==="handoff")&&!r.current&&n&&(r.current=!0,n())},[t,s,n]),l.useEffect(()=>{if(s){if(!s.hasSession){D1(),a.current=null;return}s.sessionId&&(o==="continue"||o==="fresh")&&(M1(s.sessionId),a.current=s.sessionId)}},[o,s]);const c=l.useCallback(()=>{i("continue")},[]);return{sessionDecision:o,handleContinueSession:c}}function F1(){const t=document.activeElement;return t===null||t===document.body||t===document.documentElement||t instanceof HTMLElement&&t.dataset.navTab==="true"}function z1(t,s,n,r=0){return t>=n.left-r&&t<=n.right+r&&s>=n.top-r&&s<=n.bottom+r}function Gi(t){Rn(),t.blur(),window.dispatchEvent(new Event("terminal-focus")),queueMicrotask(()=>{document.activeElement instanceof HTMLIFrameElement&&window.dispatchEvent(new Event("terminal-focus"))})}function $1(t){const s=l.useRef(!1);l.useEffect(()=>{if(!t)return;function n(){if(!s.current&&F1()){s.current=!0;try{Rn(),window.dispatchEvent(new Event("terminal-focus"))}finally{s.current=!1}}}function r(){queueMicrotask(n)}function a(i){const c=document.activeElement;c instanceof HTMLIFrameElement&&i.target!==c&&Gi(c)}function o(i){const c=document.activeElement;if(!(c instanceof HTMLIFrameElement))return;const d=c.getBoundingClientRect();z1(i.clientX,i.clientY,d,1)||Gi(c)}return document.addEventListener("focusout",r),window.addEventListener("focus",r),document.addEventListener("visibilitychange",r),document.addEventListener("mouseup",r),document.addEventListener("pointerdown",a,!0),document.addEventListener("mousedown",a,!0),document.addEventListener("click",a,!0),document.addEventListener("pointermove",o,{capture:!0,passive:!0}),()=>{document.removeEventListener("focusout",r),window.removeEventListener("focus",r),document.removeEventListener("visibilitychange",r),document.removeEventListener("mouseup",r),document.removeEventListener("pointerdown",a,!0),document.removeEventListener("mousedown",a,!0),document.removeEventListener("click",a,!0),document.removeEventListener("pointermove",o,{capture:!0})}},[t])}function B1({sessionLoading:t,sessionInfo:s,onRestorePreview:n}){const r=l.useRef(!1);l.useEffect(()=>{t||!(s!=null&&s.preview)||s.resumeMode!=="resume"&&s.resumeMode!=="handoff"||r.current||(r.current=!0,n==null||n(s.preview))},[n,s,t])}function H1(t){const s=l.useRef(t);l.useEffect(()=>{t&&t!==s.current&&(Tn(t),s.current=t)},[t])}function W1(t,s,n){l.useEffect(()=>{if(!s)return;const r=a=>{t.current&&!t.current.contains(a.target)&&n()};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[t,s,n])}function Mp({displayName:t,hasPrompt:s,expanded:n,onToggle:r}){return s?e.jsxs("button",{onClick:r,className:"flex items-center gap-1 cursor-pointer transition-colors min-w-0",style:{color:"var(--text-secondary)"},children:[e.jsx("span",{className:"font-medium truncate",children:t}),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",className:`shrink-0 transition-transform ${n?"rotate-180":""}`,children:e.jsx("path",{d:"M2 4l3 3 3-3"})})]}):e.jsx("span",{className:"font-medium truncate",style:{color:"var(--text-secondary)"},children:t})}const QP=Object.freeze(Object.defineProperty({__proto__:null,FeatureNameButton:Mp},Symbol.toStringTag,{value:"Module"}));function Ip({prompt:t}){return e.jsx("div",{style:{background:"var(--bg-input)",borderBottom:"1px solid var(--border-default)",maxHeight:"16rem",overflowY:"auto",padding:"0 0.75rem 0.75rem"},children:e.jsx(vt,{variant:"compact",children:t})})}const ZP=Object.freeze(Object.defineProperty({__proto__:null,PromptDropdownPanel:Ip},Symbol.toStringTag,{value:"Module"}));function Dp({currentStep:t,isExpanded:s,mode:n,onToggle:r=()=>{},stepNum:a}){const o=a===t,i=a<t,{description:c,label:d}=oh(a,n);return e.jsxs("div",{onClick:r,className:"cursor-pointer",children:[e.jsxs("div",{className:"w-full px-3 py-1 flex items-center gap-2 text-left transition-colors",style:{color:o?"var(--accent-active)":i?"var(--text-secondary)":"var(--text-muted)",fontWeight:o?500:void 0},onMouseEnter:u=>u.currentTarget.style.background="var(--bg-input)",onMouseLeave:u=>u.currentTarget.style.background="transparent",children:[e.jsxs("span",{className:"w-5 text-right tabular-nums shrink-0",children:[a,"."]}),e.jsx("span",{className:"flex-1",children:d}),c&&e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",className:`shrink-0 opacity-40 transition-transform ${s?"rotate-180":""}`,children:e.jsx("path",{d:"M2 4l3 3 3-3"})})]}),s&&c&&e.jsx("div",{className:"px-3 pb-1.5 pl-10",children:e.jsx("p",{className:"text-[10px] m-0 leading-relaxed",style:{color:"var(--text-dim)"},children:c})})]},a)}const eO=Object.freeze(Object.defineProperty({__proto__:null,StepIndicatorDropdownItem:Dp},Symbol.toStringTag,{value:"Module"}));function Lp({step:t,feature:s,mode:n,projectTitle:r,userPrompt:a}){const[o,i]=l.useState(!1),[c,d]=l.useState(null),[u,h]=l.useState(!1),[p,m]=l.useState(null),f=l.useRef(null),b=l.useRef(null),g=l.useRef(null),v=l.useRef(null);l.useLayoutEffect(()=>{if(!o)return;const T=()=>{var _;const A=(_=b.current)==null?void 0:_.getBoundingClientRect();A&&m({top:A.bottom+4,right:window.innerWidth-A.right})};return T(),window.addEventListener("resize",T),window.addEventListener("scroll",T,!0),()=>{window.removeEventListener("resize",T),window.removeEventListener("scroll",T,!0)}},[o]),l.useEffect(()=>{if(!o)return;const T=A=>{var M,I;const _=A.target;(M=f.current)!=null&&M.contains(_)||(I=g.current)!=null&&I.contains(_)||i(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[o]),W1(v,u,l.useCallback(()=>h(!1),[]));const x=s&&t>0,y=s||"New Working Session",w=ht(n),j=oh(t,w),k=x?j.label:null,S=j.totalSteps,N=j.prefix;return t===0?e.jsxs("div",{className:"h-8 flex items-center justify-between px-3 text-xs shrink-0 select-none",style:{background:"var(--bg-input)",borderBottom:"1px solid var(--border-default)"},children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"truncate",style:{color:"var(--text-dim)"},children:r||"New Project"}),e.jsx("span",{style:{color:"var(--text-dim)",opacity:.5},children:">"}),e.jsx("span",{className:"font-medium truncate",style:{color:"var(--text-muted)"},children:y})]}),e.jsx("span",{style:{color:"var(--text-dim)"},children:s?"Starting…":"Waiting for session"})]}):e.jsxs("div",{className:"shrink-0",ref:v,children:[e.jsxs("div",{className:"h-8 flex items-center justify-between px-3 text-xs select-none",style:{background:"var(--bg-input)",borderBottom:u?"none":"1px solid var(--border-default)"},children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"truncate",style:{color:"var(--text-dim)"},children:r||"New Project"}),e.jsx("span",{style:{color:"var(--text-dim)",opacity:.5},children:">"}),e.jsx(Mp,{displayName:y,hasPrompt:!!a,expanded:u,onToggle:()=>h(T=>!T)})]}),x&&e.jsxs("div",{className:"relative",ref:f,children:[e.jsxs("button",{ref:b,onClick:()=>i(T=>!T),className:"flex items-center gap-1.5 cursor-pointer transition-colors",style:{color:"var(--text-secondary)"},children:[e.jsx("span",{style:{color:"var(--text-dim)"},children:"::"}),e.jsxs("span",{children:[N," ",t,e.jsxs("span",{style:{color:"var(--text-dim)"},children:[" / ",S]}),": ",k]}),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",className:`transition-transform ${o?"rotate-180":""}`,children:e.jsx("path",{d:"M2 4l3 3 3-3"})})]}),o&&p&&Vt.createPortal(e.jsx("div",{ref:g,className:"w-52 rounded-lg shadow-lg py-1",style:{position:"fixed",top:p.top,right:p.right,zIndex:60,background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:Array.from({length:S},(T,A)=>A+1).map(T=>{const A=c===T;return e.jsx(Dp,{currentStep:t,isExpanded:A,mode:w,onToggle:()=>d(A?null:T),stepNum:T},T)})}),document.body)]})]}),u&&a&&e.jsx(Ip,{prompt:a})]})}const tO=Object.freeze(Object.defineProperty({__proto__:null,StepIndicatorBar:Lp},Symbol.toStringTag,{value:"Module"}));function Fp({awaitingPlanLaunchChoice:t,buildLaunchGateArmed:s,isActive:n,onSessionDetected:r,onAgentIdle:a,onAgentActive:o,onUserInput:i,provider:c,onRestorePreview:d,pendingPlans:u,pendingPlansLoading:h,pendingPlansError:p,onLaunchPlan:m,launchingSlug:f,launchError:b,onReorderPlans:g,isAgentBuilding:v}){const{stepState:x}=Xs(),{config:y,loading:w}=yt(),{prompt:j}=P1(),{sessionInfo:k,loading:S}=Oo(),{sessionDecision:N,handleContinueSession:T}=L1({sessionLoading:S,sessionInfo:k,onSessionDetected:r});return $1(n),B1({sessionLoading:S,sessionInfo:k,onRestorePreview:d}),H1((x==null?void 0:x.feature)??null),e.jsx(Nh,{stepIndicator:e.jsx(Lp,{step:(x==null?void 0:x.step)??0,feature:(x==null?void 0:x.feature)??null,mode:(x==null?void 0:x.mode)??"ui",projectTitle:(y==null?void 0:y.projectTitle)??null,userPrompt:j}),sessionContent:e.jsx(Ep,{awaitingPlanLaunchChoice:t,buildLaunchGateArmed:s,configLoading:w,sessionLoading:S,sessionDecision:N,sessionInfo:k,stepState:x,provider:c,onContinueSession:T,onAgentIdle:a,onAgentActive:o,onUserInput:i,pendingPlans:u,pendingPlansLoading:h,pendingPlansError:p,onLaunchPlan:m,launchingSlug:f,launchError:b,onReorderPlans:g,isAgentBuilding:v})})}const sO=Object.freeze(Object.defineProperty({__proto__:null,BuildTab:Fp},Symbol.toStringTag,{value:"Module"}));function Ro({screenshotPath:t,cacheBuster:s,alt:n,className:r="",title:a}){const[o,i]=l.useState("loading"),[c,d]=l.useState(!1),u=l.useRef(null),h=t?at(t,s):"",p=()=>{i("success"),d(!0)},m=()=>{i("error"),d(!1)};return l.useEffect(()=>{i("loading"),d(!1);const f=u.current;f!=null&&f.complete&&(f.naturalHeight!==0?(i("success"),d(!0)):(i("error"),d(!1)))},[h]),t?e.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",title:a,children:[e.jsx("img",{ref:u,src:h,alt:n,onLoad:p,onError:m,className:r||"max-w-full max-h-full object-contain",style:{visibility:c?"visible":"hidden",position:c?"relative":"absolute"}}),o==="loading"&&e.jsx("div",{className:"absolute inset-0 bg-gray-100 animate-pulse rounded flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),o==="error"&&e.jsxs("div",{className:"absolute inset-0 border-2 border-dashed border-gray-300 bg-gray-50 rounded flex flex-col items-center justify-center text-xs gap-1",children:[e.jsx("span",{className:"text-2xl text-gray-400",children:"📷"}),e.jsx("span",{className:"text-gray-400 whitespace-nowrap",children:"No Screenshot"})]})]}):e.jsx("div",{className:"w-full h-full border-2 border-dashed border-gray-300 bg-gray-50 rounded flex flex-col items-center justify-center text-xs gap-1",title:a,children:e.jsx("span",{className:"text-2xl text-gray-400",children:"📷"})})}const nO=Object.freeze(Object.defineProperty({__proto__:null,SafeScreenshot:Ro},Symbol.toStringTag,{value:"Module"}));function zp({refreshing:t,onRefresh:s,onClose:n,minimizeMode:r=!1}){return e.jsxs("div",{className:"shrink-0 px-4 py-2 bg-[var(--bg-card)] border-b border-[var(--border-default)] flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("h2",{className:"text-sm font-semibold text-[var(--text-primary)] m-0",children:"Working Session Results"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:s,disabled:t,className:"text-[var(--text-muted)] hover:text-[var(--text-secondary)] text-xs leading-none px-2 py-1 border border-[var(--border-default)] rounded disabled:opacity-50",title:"Refresh session data",children:t?"…":"↻"}),e.jsx("button",{onClick:n,className:"text-[var(--text-muted)] hover:text-[var(--text-secondary)] text-lg leading-none px-1",title:r?"Minimize results panel":"Close results panel",children:r?"▾":"✕"})]})]})}const rO=Object.freeze(Object.defineProperty({__proto__:null,SessionResultsPanelHeader:zp},Symbol.toStringTag,{value:"Module"}));function Ns(t,s){if(t.length===0)return{selectedIndex:-1,scenario:null};if("direction"in s){const r=s.direction==="next"?1:-1,a=(s.selectedIndex+r+t.length)%t.length;return{selectedIndex:a,scenario:t[a]}}if("slug"in s){const r=t.findIndex(a=>a.slug===s.slug);return r>=0?{selectedIndex:r,scenario:t[r]}:Ns(t,{defaultSelection:!0,selectedIndex:s.selectedIndex})}const n=Math.min(s.selectedIndex??0,t.length-1);return{selectedIndex:n,scenario:t[n]}}function Fn(t,s){if(!s)return{headline:t,collapsed:[]};const n=[],r=[];for(const a of t)a.demonstratesNew?n.push(a):r.push(a);return{headline:n,collapsed:r}}function q1(t){return t==null?"":typeof t=="string"?t:typeof t=="object"&&typeof t.name=="string"?t.name:String(t)}const G1="no-isolation-harness";function $p(t){var s;return t.coverageStatus==="reason"&&((s=t.untestabilityReason)==null?void 0:s.kind)===G1}const U1="/api/editor-session-summary",V1=3e3;function Bp(t=V1){const[s,n]=l.useState(null),[r,a]=l.useState(!0),[o,i]=l.useState(!1),c=l.useCallback(async()=>{i(!0);try{const d=await fetch(U1);d.ok&&n(await d.json())}catch{}i(!1),a(!1)},[]);return l.useEffect(()=>{c()},[c]),l.useEffect(()=>{if(t<=0)return;const d=window.setInterval(c,t);return()=>window.clearInterval(d)},[c,t]),{summary:s,loading:r,refreshing:o,refresh:c}}function Hp({onClose:t,onSelectScenario:s,previewSlug:n=null,minimizeMode:r=!1}){var j;const{summary:a,loading:o,refreshing:i,refresh:c}=Bp(),[d,u]=l.useState(0),h=l.useMemo(()=>a?[...a.application,...a.components]:[],[a]),p=l.useMemo(()=>n&&h.some(k=>k.slug===n)?n:null,[h,n]),m=p??((j=h[d])==null?void 0:j.slug);l.useEffect(()=>{if(!p)return;const k=h.findIndex(S=>S.slug===p);k>=0&&k!==d&&u(k)},[h,p,d]);const f=l.useCallback(k=>{h.length!==0&&(document.activeElement instanceof HTMLIFrameElement||Ew()||(k.key==="ArrowRight"?(k.preventDefault(),u(S=>{const N=Ns(h,{direction:"next",selectedIndex:S});return N.scenario&&(s==null||s(N.scenario.slug,N.scenario.url)),N.selectedIndex})):k.key==="ArrowLeft"&&(k.preventDefault(),u(S=>{const N=Ns(h,{direction:"previous",selectedIndex:S});return N.scenario&&(s==null||s(N.scenario.slug,N.scenario.url)),N.selectedIndex}))))},[h,s]);l.useEffect(()=>(window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)),[f]);const b=l.useRef(!1);if(l.useEffect(()=>{if(b.current||h.length===0)return;b.current=!0;const k=Ns(h,{defaultSelection:!0,selectedIndex:d});k.scenario&&(s==null||s(k.scenario.slug,k.scenario.url))},[h,s,d]),o)return e.jsx("div",{className:"flex-1 flex items-center justify-center p-8 bg-[var(--bg-deep)]",children:e.jsx("div",{className:"animate-spin w-6 h-6 border-2 border-[var(--border-default)] border-t-[#005c75] rounded-full"})});if(!a)return e.jsx("div",{className:"flex-1 flex items-center justify-center p-8 bg-[var(--bg-deep)]",children:e.jsx("div",{className:"text-sm text-[var(--text-muted)]",children:"No session data available."})});const g=a.application.length+a.components.length,v=a.hubDominated??!1,x=Fn(a.application,v),y=Fn(a.components,v),w=(k,S)=>{var T,A;const N=Ns(h,{slug:k,selectedIndex:d});N.selectedIndex>=0&&u(N.selectedIndex),s==null||s(((T=N.scenario)==null?void 0:T.slug)??k,((A=N.scenario)==null?void 0:A.url)??S)};return e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col bg-[var(--bg-deep)]",style:{borderTop:"2px solid #005c75"},children:[e.jsx(zp,{refreshing:i,onRefresh:c,onClose:t,minimizeMode:r}),e.jsxs("div",{className:"flex-1 overflow-auto p-4 space-y-4",children:[a.userPrompt&&e.jsx(Wp,{text:a.userPrompt}),e.jsxs(Cs,{title:"Application",icon:"🌐",count:x.headline.length,impactedCount:x.collapsed.length,empty:g===0?"No scenarios in this session":void 0,children:[x.headline.length>0&&e.jsx(Gp,{scenarios:x.headline,selectedSlug:m,onSelect:w}),e.jsx(ba,{scenarios:x.collapsed,selectedSlug:m,onSelect:w})]}),e.jsxs(Cs,{title:"Components",icon:"🧩",count:y.headline.length,impactedCount:y.collapsed.length,children:[y.headline.length>0&&e.jsx(qp,{scenarios:y.headline,selectedSlug:m,onSelect:w}),e.jsx(ba,{scenarios:y.collapsed,selectedSlug:m,onSelect:w})]}),e.jsx(Cs,{title:"Functions",icon:"⚙️",count:a.functions.length,children:a.functions.length>0&&e.jsx(Vp,{functions:a.functions})}),e.jsx(Cs,{title:"Modified Files",icon:"📄",count:a.modifiedFiles.length,children:a.modifiedFiles.length>0&&e.jsx(Yp,{files:a.modifiedFiles})})]})]})}function Wp({text:t}){const[s,n]=l.useState(!1),r=t.split(`
17
+ `)[0],a=t.includes(`
18
+ `)||t.length>120;return e.jsxs("div",{className:"px-1 pb-2",children:[e.jsx("div",{className:"text-[10px] font-semibold text-[var(--text-muted)] uppercase tracking-wide mb-1",children:"User Request"}),s?e.jsxs("div",{children:[e.jsx(vt,{variant:"compact",children:t}),a&&e.jsx("button",{onClick:()=>n(!1),className:"text-[#D7FF63] hover:underline text-xs mt-1",children:"Show less"})]}):e.jsxs("div",{className:"text-xs text-[var(--text-secondary)] leading-relaxed",children:[r.slice(0,120),a&&e.jsx("button",{onClick:()=>n(!0),className:"text-[#D7FF63] hover:underline ml-1 text-xs",children:"Read more..."})]})]})}function Cs({title:t,icon:s,count:n,impactedCount:r=0,empty:a,children:o}){const i=n+r;return e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border-default)] rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 border-b border-[var(--border-subtle)] bg-[var(--bg-input)] flex items-center gap-2",children:[e.jsx("span",{className:"text-xs",children:s}),e.jsx("span",{className:"text-xs font-semibold text-[var(--text-primary)]",children:t}),e.jsxs("span",{className:"text-[10px] text-[var(--text-muted)]",children:["(",n,r>0?` +${r} impacted`:"",")"]})]}),e.jsx("div",{className:"p-3",children:i===0?e.jsx("div",{className:"text-xs text-[var(--text-muted)] italic",children:a||`No ${t.toLowerCase()} in this session`}):o})]})}function zn({scenarios:t,selectedSlug:s,onSelect:n}){return e.jsx("div",{className:"overflow-x-auto",children:e.jsx("div",{className:"flex gap-2",style:{minWidth:"min-content"},children:t.map(r=>e.jsx(Up,{scenario:r,isSelected:r.slug===s,onSelect:n},r.slug))})})}function ba({scenarios:t,selectedSlug:s,onSelect:n}){const[r,a]=l.useState(!1);return t.length===0?null:e.jsxs("div",{className:"mt-3 pt-3 border-t border-[var(--border-subtle)]",children:[e.jsxs("button",{onClick:()=>a(o=>!o),className:"text-[11px] text-[var(--text-muted)] hover:text-[var(--text-secondary)] flex items-center gap-1",children:[e.jsx("span",{children:r?"▾":"▸"}),e.jsxs("span",{children:[t.length," more impacted by hub-file changes (not recaptured this session)"]})]}),r&&e.jsx("div",{className:"mt-2",children:e.jsx(zn,{scenarios:t,selectedSlug:s,onSelect:n})})]})}function qp({scenarios:t,selectedSlug:s,onSelect:n}){const r={};for(const i of t){const c=i.componentName||"Unknown";r[c]||(r[c]=[]),r[c].push(i)}const a=Object.keys(r).sort(),o=t.some($p);return e.jsxs("div",{className:"space-y-3",children:[o&&e.jsx("div",{className:"text-[10px] leading-snug text-[var(--text-muted)] bg-[var(--bg-input)] border border-[var(--border-subtle)] rounded px-2 py-1.5",children:"This stack has no component isolation harness, so leaf components are verified inside the full app scenarios rather than in isolation."}),a.map(i=>e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-medium text-[var(--text-secondary)] mb-1",children:i}),e.jsx(zn,{scenarios:r[i],selectedSlug:s,onSelect:n})]},i))]})}function Gp({scenarios:t,selectedSlug:s,onSelect:n}){if(!t.some(i=>i.routeName))return e.jsx(zn,{scenarios:t,selectedSlug:s,onSelect:n});const a={};for(const i of t){const c=i.routeName||"Other";a[c]||(a[c]=[]),a[c].push(i)}const o=Object.keys(a).sort();return e.jsx("div",{className:"space-y-3",children:o.map(i=>e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-medium text-[var(--text-secondary)] mb-1",children:i}),e.jsx(zn,{scenarios:a[i],selectedSlug:s,onSelect:n})]},i))})}function Up({scenario:t,isSelected:s,onSelect:n}){var o;const r=t.name.replace(/\s*\[.*\]\s*$/,"").trim(),a=$p(t);return e.jsxs("div",{className:"shrink-0 cursor-pointer group",onClick:()=>n==null?void 0:n(t.slug,t.url),title:t.name,children:[e.jsx("div",{className:`w-24 h-24 rounded overflow-hidden transition-colors ${s?"border-2 border-[#005c75] shadow-md":"border border-[var(--border-default)] group-hover:border-[#005c75]"}`,style:{background:"#e8edf1"},children:t.screenshotPaths.length>0?e.jsx(Ro,{screenshotPath:t.screenshotPaths[0],cacheBuster:t.screenshotCapturedAtMs??void 0,alt:t.name,className:"w-full h-full object-cover object-top"}):t.coverageStatus==="needs-isolated-scenario"?e.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center gap-1 px-1 text-center",title:"Backed only by a unit test — capture an isolated scenario so this component is viewable in the editor.",children:[e.jsx("span",{className:"text-amber-500 text-lg leading-none",children:"⚠"}),e.jsx("span",{className:"text-[8px] leading-tight text-amber-700",children:"needs isolated scenario"})]}):t.coverageStatus==="reason"?e.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center gap-1 px-1 text-center",title:t.untestabilityReason?`${t.untestabilityReason.kind}: ${t.untestabilityReason.justification}`:"Covered by a recorded untestability reason.",children:[e.jsx("span",{className:"text-[var(--text-muted)] text-lg leading-none",children:"🧪"}),e.jsx("span",{className:"text-[8px] leading-tight text-[var(--text-muted)]",children:((o=t.untestabilityReason)==null?void 0:o.kind)??"test-backed"})]}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-[var(--text-muted)] text-lg",children:"📷"})}),e.jsx("div",{className:`mt-1 text-[10px] truncate w-24 ${s?"text-[#005c75] font-medium":"text-[var(--text-secondary)] group-hover:text-[#005c75]"}`,children:r}),a&&e.jsx("div",{className:"mt-0.5 w-24 text-[9px] leading-tight text-[var(--text-muted)]",children:"Covered via app scenarios — no isolation harness"})]})}function Vp({functions:t}){return e.jsx("div",{className:"divide-y divide-gray-100 -mx-3 -mb-3",children:t.map(s=>e.jsxs("div",{className:"px-3 py-2",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-[10px] text-[var(--text-muted)] mt-0.5 shrink-0",children:"fn"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-medium text-[var(--text-primary)]",children:s.name}),s.description&&e.jsx("div",{className:"text-[10px] text-[var(--text-muted)] mt-0.5",children:s.description}),e.jsx("div",{className:"text-[10px] text-[var(--text-muted)] font-mono mt-0.5",children:s.filePath})]})]}),s.tests.length>0&&e.jsx("div",{className:"ml-5 mt-1.5 space-y-0.5",children:s.tests.map((n,r)=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-green-500 text-[10px]",children:"✓"}),e.jsx("span",{className:"text-[10px] text-[var(--text-secondary)]",children:q1(n)})]},r))}),s.testFile&&s.tests.length===0&&e.jsx("div",{className:"ml-5 mt-1 text-[10px] text-[var(--text-muted)] font-mono",children:s.testFile})]},`${s.filePath}::${s.name}`))})}function Yp({files:t}){return e.jsx("div",{className:"divide-y divide-gray-100 -mx-3 -mb-3",children:t.map(s=>e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2",children:[e.jsx(lo,{status:s.status}),e.jsx("span",{className:"text-xs text-[var(--text-secondary)] font-mono truncate",children:s.path})]},s.path))})}const aO=Object.freeze(Object.defineProperty({__proto__:null,ApplicationGroups:Gp,CollapsedImpactedScenarios:ba,ComponentGroups:qp,FilesList:Yp,FunctionsList:Vp,ScenarioThumbnail:Up,Section:Cs,SessionResultsPanel:Hp,UserPrompt:Wp},Symbol.toStringTag,{value:"Module"}));function Kp({onExpand:t}){const{summary:s}=Bp(),n=(s==null?void 0:s.hubDominated)??!1,r=Fn((s==null?void 0:s.application)??[],n),a=Fn((s==null?void 0:s.components)??[],n),o=r.headline.length+a.headline.length,i=r.collapsed.length+a.collapsed.length;return e.jsxs("button",{type:"button",onClick:t,title:"Expand working session results",className:"shrink-0 w-full flex items-center gap-2 px-4 py-1.5 text-left bg-[var(--bg-card)] hover:bg-[var(--bg-input)] transition-colors",style:{borderTop:"2px solid #005c75"},children:[e.jsx("span",{className:"text-[var(--text-muted)] text-xs leading-none",children:"▴"}),e.jsx("span",{className:"text-xs font-semibold text-[var(--text-primary)]",children:"Working Session Results"}),e.jsxs("span",{className:"text-[11px] text-[var(--text-muted)]",children:[o," new",i>0?` · ${i} impacted`:""]})]})}const oO=Object.freeze(Object.defineProperty({__proto__:null,MinimizedSessionResults:Kp},Symbol.toStringTag,{value:"Module"}));function Y1(t,s){return(t==null?void 0:t.mode)!=="ui"?!1:(t==null?void 0:t.slug)==="feature-complete"||!!s}const K1=new Set(["ui-present","backend-present"]);function Jp(t){return!!(t!=null&&t.slug)&&K1.has(t.slug)}function J1({stepState:t,resultsShown:s,featureCompleteActive:n,userExpanded:r}){return n?"hidden":Jp(t)?(t==null?void 0:t.mode)==="ui"?"full":"hidden":Y1(t,s)?r?"full":"minimized":"hidden"}function Xp({awaitingPlanLaunchChoice:t,buildLaunchGateArmed:s,buildActivated:n,activeTab:r,onSessionDetected:a,onSelectScenario:o,previewSlug:i=null,showResultsCommandKey:c,hideResultsCommandKey:d,onAgentIdle:u,onAgentActive:h,onUserInput:p,notifSettings:m,onSettingsChange:f,provider:b,onRestorePreview:g,pendingPlans:v,pendingPlansLoading:x,pendingPlansError:y,onLaunchPlan:w,launchingSlug:j,launchError:k,onReorderPlans:S,isAgentBuilding:N,featureCompleteActive:T}){const{stepState:A}=Xs(),{sessionInfo:_}=Oo({pollIntervalMs:15e3}),[M,I]=l.useState(!1),[H,z]=l.useState(!1),[G,R]=l.useState(0),D=(_==null?void 0:_.resultsShown)??!1;l.useEffect(()=>{D||(z(!1),I(!1))},[D]),l.useEffect(()=>{c&&(z(!1),I(!0),R(Z=>Z+1))},[c]),l.useEffect(()=>{d&&I(!1)},[d]);const P=Jp(A),$=J1({stepState:A,resultsShown:D,featureCompleteActive:T,userExpanded:M}),F=P&&H?"hidden":$,U=l.useCallback(()=>{P?z(!0):I(!1)},[P]),J=l.useCallback(()=>{I(!0),R(Z=>Z+1)},[]);return n?e.jsx(Ch,{activeTab:r,resultsMode:F,buildTab:e.jsx(Fp,{awaitingPlanLaunchChoice:t,buildLaunchGateArmed:s,isActive:r==="build",onSessionDetected:a,onAgentIdle:u,onAgentActive:h,onUserInput:p,provider:b,onRestorePreview:g,pendingPlans:v,pendingPlansLoading:x,pendingPlansError:y,onLaunchPlan:w,launchingSlug:j,launchError:k,onReorderPlans:S,isAgentBuilding:N}),resultsPanel:e.jsx(Hp,{onClose:U,onSelectScenario:o,previewSlug:i,minimizeMode:!P},G),minimizedResults:e.jsx(Kp,{onExpand:J}),footer:e.jsx(Ku,{settings:m,onChange:f,agentName:b})}):null}const iO=Object.freeze(Object.defineProperty({__proto__:null,BuildTabPane:Xp},Symbol.toStringTag,{value:"Module"})),X1=e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M5.50742 6.94462H6.6669C6.89825 6.94462 7.12013 6.85463 7.28372 6.69444C7.44731 6.53426 7.53921 6.317 7.53921 6.09047C7.53921 5.86394 7.44731 5.64668 7.28372 5.4865C7.12013 5.32631 6.89825 5.23633 6.6669 5.23633H5.51133C5.27997 5.23633 5.05809 5.32631 4.8945 5.4865C4.73091 5.64668 4.639 5.86394 4.639 6.09047C4.639 6.20264 4.61644 6.31372 4.57261 6.41735C4.52877 6.52098 4.46451 6.61513 4.38351 6.69444C4.3025 6.77376 4.20634 6.83668 4.1005 6.8796C3.99467 6.92253 3.88124 6.94462 3.76668 6.94462H2.61111C2.38009 6.94462 2.15851 7.03435 1.99498 7.19412C1.83144 7.35389 1.7393 7.57066 1.73878 7.79687C1.73878 8.02307 1.64715 8.24003 1.48398 8.40016C1.32081 8.56029 1.09944 8.6505 0.868421 8.65101C0.637744 8.65202 0.416859 8.74245 0.25411 8.90253C0.0913609 9.0626 -2.30897e-06 9.27929 0 9.50516C-5.79344e-07 9.73086 0.0914247 9.94733 0.254229 10.1071C0.417033 10.2669 0.637923 10.3569 0.868421 10.3574C1.09944 10.3579 1.32081 10.4481 1.48398 10.6082C1.64715 10.7684 1.73878 10.9853 1.73878 11.2115C1.73878 11.4381 1.83069 11.6553 1.99429 11.8155C2.15788 11.9757 2.37976 12.0657 2.61111 12.0657H3.76668C3.9977 12.0657 4.21928 12.1554 4.38282 12.3152C4.54635 12.475 4.63848 12.6917 4.639 12.9179C4.639 13.1445 4.73091 13.3617 4.8945 13.5219C5.05809 13.6821 5.27997 13.7721 5.51133 13.7721H6.6669C6.78136 13.7721 6.8947 13.75 7.00043 13.707C7.10615 13.6641 7.20218 13.6011 7.28303 13.5218C7.36388 13.4424 7.42794 13.3483 7.47157 13.2447C7.51519 13.141 7.53753 13.03 7.53727 12.9179C7.53727 12.6919 7.44556 12.4751 7.28234 12.3153C7.11911 12.1555 6.89773 12.0657 6.6669 12.0657H5.50937C5.27836 12.0652 5.05698 11.975 4.89381 11.8148C4.73064 11.6547 4.639 11.4377 4.639 11.2115C4.639 10.985 4.5471 10.7678 4.38351 10.6076C4.21991 10.4474 3.99804 10.3574 3.76668 10.3574H2.59745C2.36929 10.3574 2.15025 10.2697 1.98746 10.1132C1.82468 9.95667 1.73117 9.74381 1.72707 9.52044C1.72707 9.52044 1.72707 9.52045 1.72707 9.50516C1.72707 9.50516 1.72707 9.49369 1.72707 9.48796C1.73117 9.26459 1.82468 9.05173 1.98746 8.89519C2.15025 8.73866 2.36929 8.65097 2.59745 8.65101H3.76668C3.99804 8.65101 4.21991 8.56102 4.38351 8.40084C4.5471 8.24065 4.639 8.0234 4.639 7.79687C4.639 7.57117 4.73043 7.35468 4.89324 7.19491C5.05604 7.03514 5.27692 6.94513 5.50742 6.94462Z",fill:"currentColor"}),e.jsx("path",{d:"M17.1351 5.27098C16.9037 5.27098 16.6818 5.36096 16.5183 5.52115C16.3547 5.68133 16.2628 5.89859 16.2628 6.12512V7.83152C16.2628 7.94368 16.2402 8.05475 16.1964 8.15838C16.1525 8.26201 16.0883 8.35618 16.0073 8.43549C15.9263 8.51481 15.8301 8.57771 15.7243 8.62064C15.6184 8.66356 15.505 8.68566 15.3904 8.68566C15.1594 8.68616 14.938 8.77637 14.7749 8.9365C14.6117 9.09663 14.5201 9.31361 14.5201 9.53981C14.5196 9.76602 14.4274 9.98278 14.2639 10.1426C14.1003 10.3023 13.8788 10.392 13.6477 10.392C13.4167 10.392 13.1951 10.3023 13.0316 10.1426C12.8681 9.98278 12.7759 9.76602 12.7754 9.53981C12.7754 9.31361 12.6838 9.09663 12.5206 8.9365C12.3574 8.77637 12.1361 8.68616 11.9051 8.68566C11.7905 8.68566 11.6771 8.66356 11.5712 8.62064C11.4654 8.57771 11.3692 8.51481 11.2882 8.43549C11.2072 8.35618 11.143 8.26201 11.0991 8.15838C11.0553 8.05475 11.0327 7.94368 11.0327 7.83152V6.13086C11.0383 6.01542 11.0199 5.90007 10.9786 5.7918C10.9374 5.68352 10.8741 5.58458 10.7926 5.50095C10.7112 5.41732 10.6132 5.35074 10.5047 5.30526C10.3962 5.25977 10.2794 5.23633 10.1614 5.23633C10.0434 5.23633 9.92656 5.25977 9.81805 5.30526C9.70955 5.35074 9.61161 5.41732 9.53015 5.50095C9.44869 5.58458 9.38541 5.68352 9.34414 5.7918C9.30287 5.90007 9.28446 6.01542 9.29004 6.13086V7.83724C9.29004 8.06345 9.38168 8.28041 9.54485 8.44054C9.70802 8.60067 9.9294 8.69089 10.1604 8.6914C10.3918 8.6914 10.6136 8.78138 10.7772 8.94157C10.9408 9.10175 11.0327 9.31901 11.0327 9.54554C11.0332 9.77174 11.1254 9.98851 11.2889 10.1483C11.4525 10.308 11.674 10.3978 11.9051 10.3978C12.1351 10.3983 12.3556 10.4877 12.5186 10.6466C12.6816 10.8055 12.7739 11.021 12.7754 11.2462V12.966C12.7754 13.1922 12.8671 13.4091 13.0302 13.5693C13.1934 13.7294 13.4148 13.8196 13.6458 13.8201C13.8771 13.8201 14.099 13.7301 14.2626 13.5699C14.4262 13.4097 14.5181 13.1925 14.5181 12.966V11.2596C14.5181 11.0334 14.6097 10.8164 14.7729 10.6563C14.9361 10.4961 15.1575 10.4059 15.3885 10.4054C15.6195 10.4054 15.8411 10.3157 16.0046 10.1559C16.1682 9.99616 16.2603 9.77938 16.2608 9.55318C16.2608 9.32664 16.3527 9.10939 16.5163 8.9492C16.6799 8.78902 16.9018 8.69904 17.1331 8.69904C17.3641 8.69853 17.5855 8.60832 17.7487 8.44819C17.9119 8.28806 18.0035 8.07109 18.0035 7.84488V6.13086C18.0043 6.01853 17.9824 5.90715 17.9392 5.80311C17.8959 5.69907 17.8321 5.6044 17.7515 5.52453C17.6708 5.44466 17.5748 5.38115 17.4691 5.33764C17.3633 5.29414 17.2498 5.27148 17.1351 5.27098Z",fill:"currentColor"})]}),Q1=e.jsx("path",{d:"M28.609 14.209C27.883 14.209 27.2597 14.0807 26.739 13.824C26.2183 13.5673 25.793 13.2337 25.463 12.823C25.1403 12.4123 24.902 11.965 24.748 11.481C24.594 10.997 24.517 10.5313 24.517 10.084V9.842C24.517 9.34333 24.594 8.852 24.748 8.368C24.9093 7.884 25.155 7.444 25.485 7.048C25.815 6.652 26.233 6.33667 26.739 6.102C27.2523 5.86 27.8573 5.739 28.554 5.739C29.28 5.739 29.9107 5.871 30.446 6.135C30.9887 6.39167 31.4213 6.75833 31.744 7.235C32.0667 7.70433 32.261 8.25433 32.327 8.885H30.754C30.6953 8.51833 30.5633 8.21033 30.358 7.961C30.16 7.70433 29.907 7.51367 29.599 7.389C29.291 7.257 28.9427 7.191 28.554 7.191C28.158 7.191 27.806 7.26067 27.498 7.4C27.19 7.532 26.9333 7.72267 26.728 7.972C26.5227 8.22133 26.365 8.51467 26.255 8.852C26.1523 9.18933 26.101 9.56333 26.101 9.974C26.101 10.37 26.1523 10.7367 26.255 11.074C26.365 11.4113 26.5263 11.7083 26.739 11.965C26.9517 12.2143 27.212 12.4087 27.52 12.548C27.8353 12.6873 28.1983 12.757 28.609 12.757C29.2103 12.757 29.7163 12.6103 30.127 12.317C30.545 12.0163 30.798 11.5983 30.886 11.063H32.459C32.3857 11.635 32.1913 12.1593 31.876 12.636C31.5607 13.1127 31.128 13.494 30.578 13.78C30.028 14.066 29.3717 14.209 28.609 14.209ZM36.5271 14.209C35.9991 14.209 35.5334 14.1247 35.1301 13.956C34.7268 13.7873 34.3858 13.56 34.1071 13.274C33.8284 12.9807 33.6158 12.6507 33.4691 12.284C33.3298 11.9173 33.2601 11.536 33.2601 11.14V10.909C33.2601 10.4983 33.3334 10.1097 33.4801 9.743C33.6341 9.369 33.8504 9.039 34.1291 8.753C34.4151 8.45967 34.7598 8.23233 35.1631 8.071C35.5664 7.90233 36.0211 7.818 36.5271 7.818C37.0331 7.818 37.4878 7.90233 37.8911 8.071C38.2944 8.23233 38.6354 8.45967 38.9141 8.753C39.2001 9.039 39.4164 9.369 39.5631 9.743C39.7098 10.1097 39.7831 10.4983 39.7831 10.909V11.14C39.7831 11.536 39.7098 11.9173 39.5631 12.284C39.4238 12.6507 39.2148 12.9807 38.9361 13.274C38.6574 13.56 38.3164 13.7873 37.9131 13.956C37.5098 14.1247 37.0478 14.209 36.5271 14.209ZM36.5271 12.9C36.9011 12.9 37.2164 12.8193 37.4731 12.658C37.7298 12.4893 37.9241 12.2657 38.0561 11.987C38.1881 11.701 38.2541 11.3783 38.2541 11.019C38.2541 10.6523 38.1844 10.3297 38.0451 10.051C37.9131 9.765 37.7151 9.54133 37.4511 9.38C37.1944 9.21133 36.8864 9.127 36.5271 9.127C36.1678 9.127 35.8561 9.21133 35.5921 9.38C35.3354 9.54133 35.1374 9.765 34.9981 10.051C34.8588 10.3297 34.7891 10.6523 34.7891 11.019C34.7891 11.3783 34.8551 11.701 34.9871 11.987C35.1264 12.2657 35.3244 12.4893 35.5811 12.658C35.8378 12.8193 36.1531 12.9 36.5271 12.9ZM43.5969 14.198C43.1789 14.198 42.7939 14.121 42.4419 13.967C42.0899 13.813 41.7856 13.5967 41.5289 13.318C41.2723 13.0393 41.0743 12.7167 40.9349 12.35C40.7956 11.976 40.7259 11.5727 40.7259 11.14V10.909C40.7259 10.4837 40.7919 10.084 40.9239 9.71C41.0633 9.336 41.2539 9.00967 41.4959 8.731C41.7453 8.45233 42.0423 8.236 42.3869 8.082C42.7389 7.92067 43.1276 7.84 43.5529 7.84C44.0223 7.84 44.4329 7.94267 44.7849 8.148C45.1443 8.346 45.4303 8.64667 45.6429 9.05C45.8556 9.45333 45.9729 9.95933 45.9949 10.568L45.5439 10.04V5.97H47.0729V14H45.8629V11.459H46.1269C46.1049 12.0677 45.9803 12.5773 45.7529 12.988C45.5256 13.3913 45.2249 13.6957 44.8509 13.901C44.4843 14.099 44.0663 14.198 43.5969 14.198ZM43.9379 12.911C44.2386 12.911 44.5136 12.845 44.7629 12.713C45.0123 12.5737 45.2103 12.3757 45.3569 12.119C45.5109 11.855 45.5879 11.547 45.5879 11.195V10.755C45.5879 10.403 45.5109 10.1097 45.3569 9.875C45.2029 9.633 45.0013 9.44967 44.7519 9.325C44.5026 9.193 44.2313 9.127 43.9379 9.127C43.6079 9.127 43.3146 9.20767 43.0579 9.369C42.8086 9.523 42.6106 9.743 42.4639 10.029C42.3246 10.315 42.2549 10.6487 42.2549 11.03C42.2549 11.4113 42.3283 11.745 42.4749 12.031C42.6216 12.3097 42.8196 12.526 43.0689 12.68C43.3256 12.834 43.6153 12.911 43.9379 12.911ZM51.4863 14.209C50.973 14.209 50.522 14.121 50.1333 13.945C49.752 13.769 49.433 13.5343 49.1763 13.241C48.927 12.9403 48.7363 12.6067 48.6043 12.24C48.4797 11.8733 48.4173 11.4993 48.4173 11.118V10.909C48.4173 10.513 48.4797 10.1317 48.6043 9.765C48.7363 9.391 48.927 9.061 49.1763 8.775C49.433 8.48167 49.7483 8.25067 50.1223 8.082C50.4963 7.906 50.929 7.818 51.4203 7.818C52.0657 7.818 52.6047 7.961 53.0373 8.247C53.4773 8.52567 53.8073 8.896 54.0273 9.358C54.2473 9.81267 54.3573 10.304 54.3573 10.832V11.382H49.0663V10.447H53.4003L52.9273 10.909C52.9273 10.5277 52.8723 10.2013 52.7623 9.93C52.6523 9.65867 52.4837 9.44967 52.2563 9.303C52.0363 9.15633 51.7577 9.083 51.4203 9.083C51.083 9.083 50.797 9.16 50.5623 9.314C50.3277 9.468 50.148 9.69167 50.0233 9.985C49.906 10.271 49.8473 10.6157 49.8473 11.019C49.8473 11.393 49.906 11.7267 50.0233 12.02C50.1407 12.306 50.3203 12.5333 50.5623 12.702C50.8043 12.8633 51.1123 12.944 51.4863 12.944C51.8603 12.944 52.1647 12.8707 52.3993 12.724C52.634 12.57 52.7843 12.383 52.8503 12.163H54.2583C54.1703 12.5737 54.0017 12.933 53.7523 13.241C53.503 13.549 53.184 13.7873 52.7953 13.956C52.414 14.1247 51.9777 14.209 51.4863 14.209ZM57.2956 10.931L54.8756 5.97H56.4816L58.3296 9.853L57.9776 9.743H59.0226L58.6486 9.853L60.3316 5.97H61.8496L59.6166 10.931H57.2956ZM57.6916 14V10.689H59.2206V14H57.6916ZM66.0534 14V12.229H65.8004V10.26C65.8004 9.91533 65.7161 9.65867 65.5474 9.49C65.3788 9.32133 65.1184 9.237 64.7664 9.237C64.5831 9.237 64.3631 9.24067 64.1064 9.248C63.8498 9.25533 63.5894 9.26633 63.3254 9.281C63.0688 9.28833 62.8378 9.29933 62.6324 9.314V8.016C62.8011 8.00133 62.9918 7.98667 63.2044 7.972C63.4171 7.95733 63.6334 7.95 63.8534 7.95C64.0808 7.94267 64.2934 7.939 64.4914 7.939C65.1074 7.939 65.6171 8.01967 66.0204 8.181C66.4311 8.34233 66.7391 8.59533 66.9444 8.94C67.1571 9.28467 67.2634 9.73567 67.2634 10.293V14H66.0534ZM64.1284 14.154C63.6958 14.154 63.3144 14.077 62.9844 13.923C62.6618 13.769 62.4088 13.549 62.2254 13.263C62.0494 12.977 61.9614 12.6323 61.9614 12.229C61.9614 11.789 62.0678 11.4297 62.2804 11.151C62.5004 10.8723 62.8048 10.6633 63.1934 10.524C63.5894 10.3847 64.0514 10.315 64.5794 10.315H65.9654V11.228H64.5574C64.2054 11.228 63.9341 11.316 63.7434 11.492C63.5601 11.6607 63.4684 11.8807 63.4684 12.152C63.4684 12.4233 63.5601 12.6433 63.7434 12.812C63.9341 12.9807 64.2054 13.065 64.5574 13.065C64.7701 13.065 64.9644 13.0283 65.1404 12.955C65.3238 12.8743 65.4741 12.7423 65.5914 12.559C65.7161 12.3683 65.7858 12.1117 65.8004 11.789L66.1744 12.218C66.1378 12.636 66.0351 12.988 65.8664 13.274C65.7051 13.56 65.4778 13.78 65.1844 13.934C64.8984 14.0807 64.5464 14.154 64.1284 14.154ZM68.9012 14V8.027H70.1112V10.59H70.0012C70.0012 9.98867 70.0782 9.48633 70.2322 9.083C70.3862 8.67233 70.6136 8.36433 70.9142 8.159C71.2222 7.94633 71.6036 7.84 72.0582 7.84H72.1242C72.5862 7.84 72.9676 7.94633 73.2682 8.159C73.5762 8.36433 73.8036 8.67233 73.9502 9.083C74.1042 9.48633 74.1812 9.98867 74.1812 10.59H73.7962C73.7962 9.98867 73.8732 9.48633 74.0272 9.083C74.1886 8.67233 74.4196 8.36433 74.7202 8.159C75.0282 7.94633 75.4096 7.84 75.8642 7.84H75.9302C76.3922 7.84 76.7772 7.94633 77.0852 8.159C77.3932 8.36433 77.6242 8.67233 77.7782 9.083C77.9396 9.48633 78.0202 9.98867 78.0202 10.59V14H76.4912V10.447C76.4912 10.073 76.3959 9.776 76.2052 9.556C76.0146 9.32867 75.7432 9.215 75.3912 9.215C75.0392 9.215 74.7569 9.33233 74.5442 9.567C74.3316 9.79433 74.2252 10.1023 74.2252 10.491V14H72.6962V10.447C72.6962 10.073 72.6009 9.776 72.4102 9.556C72.2196 9.32867 71.9482 9.215 71.5962 9.215C71.2442 9.215 70.9619 9.33233 70.7492 9.567C70.5366 9.79433 70.4302 10.1023 70.4302 10.491V14H68.9012Z",fill:"currentColor"});function $n({className:t="h-5",markOnly:s=!1}){return e.jsxs("svg",{className:t,viewBox:s?"0 0 19 20":"0 0 79 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",role:"img","aria-label":s?"CodeYam":"CodeYam Editor",children:[X1,!s&&Q1]})}const lO=Object.freeze(Object.defineProperty({__proto__:null,CyLogo:$n},Symbol.toStringTag,{value:"Module"}));function Qp({name:t}){const s={width:13,height:13,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"},n=t.toLowerCase(),r=n.includes("landscape"),a=n.includes("iphone"),o=n.includes("ipad");return n.includes("laptop")?e.jsxs("svg",{...s,children:[e.jsx("path",{d:"M4 6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8H4V6z"}),e.jsx("path",{d:"M2 18h20"})]}):n.includes("desktop")||n.includes("monitor")?e.jsxs("svg",{...s,children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("path",{d:"M8 21h8M12 17v4"})]}):n.includes("tablet")||n.includes("ipad")?r?e.jsxs("svg",{...s,children:[e.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2"}),o?e.jsx("path",{d:"M5 12h.01"}):e.jsx("path",{d:"M18 12h.01"})]}):e.jsxs("svg",{...s,children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2"}),o?e.jsx("path",{d:"M12 5h.01"}):e.jsx("path",{d:"M12 18h.01"})]}):n.includes("phone")||n.includes("iphone")||n.includes("mobile")?r?e.jsxs("svg",{...s,children:[e.jsx("rect",{x:"2",y:"7",width:"20",height:"10",rx:a?3:2}),a?e.jsx("path",{d:"M5 9.5v5"}):e.jsx("path",{d:"M18 12h.01"})]}):e.jsxs("svg",{...s,children:[e.jsx("rect",{x:"7",y:"2",width:"10",height:"20",rx:a?3:2}),a?e.jsx("path",{d:"M10 4.5h4"}):e.jsx("path",{d:"M12 18h.01"})]}):e.jsx("span",{className:"text-xs",children:t})}const cO=Object.freeze(Object.defineProperty({__proto__:null,DeviceIcon:Qp},Symbol.toStringTag,{value:"Module"})),Ui=["·","✢","✳","✶","✻","✽"],Z1=160;function Bn({testId:t="nav-build-dot-active",ariaLabel:s="Build in progress"}={}){const[n,r]=l.useState(0);return l.useEffect(()=>{const a=window.setInterval(()=>r(o=>(o+1)%Ui.length),Z1);return()=>window.clearInterval(a)},[]),e.jsx("span",{"data-testid":t,"aria-label":s,className:"mr-1 inline-block w-3 text-center text-[#D7FF63] leading-none text-[11px] tabular-nums",children:Ui[n]})}const dO=Object.freeze(Object.defineProperty({__proto__:null,BuildSpinner:Bn},Symbol.toStringTag,{value:"Module"}));function Zp({size:t=16}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]})}const uO=Object.freeze(Object.defineProperty({__proto__:null,EnvelopeIcon:Zp},Symbol.toStringTag,{value:"Module"}));function em({onNavigateToBuild:t,onDismiss:s}){return l.useEffect(()=>(K("banner-mounted",{}),()=>{K("banner-unmounted",{})}),[]),e.jsx("div",{className:"bg-black border-t border-[#333] px-4 py-1.5 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-lg border border-[#FF8B43]/60 bg-[#2a1500] shrink-0",children:[e.jsxs("button",{type:"button",onClick:t,className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-[#FF8B43] shrink-0"}),e.jsxs("span",{className:"text-sm text-[#FF8B43]",children:["Claude is waiting for you."," ",e.jsx("span",{className:"text-[#FF8B43] font-medium underline",children:"Build."})]})]}),e.jsx("button",{type:"button",onClick:n=>{n.stopPropagation(),s()},className:"p-0.5 text-[#FF8B43]/60 hover:text-[#FF8B43] transition-colors cursor-pointer",title:"Dismiss",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",children:e.jsx("path",{d:"M3 3l8 8M11 3l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})})}const hO=Object.freeze(Object.defineProperty({__proto__:null,IdleBanner:em},Symbol.toStringTag,{value:"Module"}));function lt(){const t=()=>{typeof window<"u"&&window.dispatchEvent(new Event("terminal-focus"))};t();const s=requestAnimationFrame(t),n=setTimeout(t,50);return()=>{cancelAnimationFrame(s),clearTimeout(n)}}const ek=[{key:"home",label:"Home"},{key:"plan",label:"Plan"},{key:"build",label:"Build"},{key:"history",label:"History"}];function Vi(){if(typeof document>"u")return;const t=document.activeElement;t instanceof HTMLElement&&t.blur()}function tm({activeTab:t,onTabChange:s,onSendTranscript:n,buildIdle:r=!1,isAgentBuilding:a=!1,planIdle:o=!1,planActive:i=!1,bannerVisible:c=!1,onDismissIdleBanner:d,buildDisabled:u=!1,showLogo:h=!0}){const p=c&&t!=="build",m=r,f=a&&!r,b=f?"green":m?"orange":"none",g=l.useRef(b);l.useEffect(()=>{g.current!==b&&(K("build-tab-dot-change",{from:g.current,to:b}),g.current=b)},[b]);const v=o,x=i&&!o,y=x?"green":v?"orange":"none",w=l.useRef(y);return l.useEffect(()=>{w.current!==y&&(K("plan-tab-dot-change",{from:w.current,to:y}),w.current=y)},[y]),e.jsxs("div",{className:"shrink-0",children:[e.jsxs("div",{className:"@container bg-black h-10 flex items-center px-4 gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[h&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx($n,{className:"h-5 text-white shrink-0 @max-[440px]:hidden"}),e.jsx($n,{markOnly:!0,className:"h-5 text-white shrink-0 hidden @max-[440px]:block"})]}),e.jsx("span",{className:"text-[#8E8E8E] text-sm shrink-0",children:"/"})]}),e.jsx("div",{className:"flex items-center gap-1",children:ek.map(j=>j.key==="build"&&u?e.jsx("button",{type:"button","data-nav-tab":"true","data-testid":"nav-build-disabled",title:"Connect your provider account on the Home tab to enable Build",onClick:()=>{s("home"),Vi()},className:"px-2.5 py-2.5 text-sm text-[#5A5A5A] cursor-not-allowed font-light whitespace-nowrap",children:j.label},j.key):e.jsxs(Ga,{href:_s(j.key),"data-nav-tab":"true",onNavigate:()=>{s(j.key),Vi(),j.key==="build"&&lt()},className:`px-2.5 py-2.5 text-sm transition-colors cursor-pointer inline-flex items-center whitespace-nowrap ${t===j.key?"text-[#D7FF63] font-medium":"text-[#8E8E8E] hover:text-white font-light"}`,children:[j.key==="build"&&f&&e.jsx(Bn,{}),j.key==="build"&&m&&e.jsx("span",{"data-testid":"nav-build-dot-idle",className:"mr-1 inline-block w-2 h-2 rounded-full bg-[#FF8B43]"}),j.key==="plan"&&x&&e.jsx(Bn,{testId:"nav-plan-dot-active",ariaLabel:"Planning in progress"}),j.key==="plan"&&v&&e.jsx("span",{"data-testid":"nav-plan-dot-idle",className:"mr-1 inline-block w-2 h-2 rounded-full bg-[#FF8B43]"}),j.label]},j.key))})]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:n,className:"p-1.5 rounded-md transition-colors cursor-pointer text-[#8E8E8E] hover:text-white",title:"Send Session Feedback",children:e.jsx(Zp,{})}),!1]}),p&&e.jsx(em,{onNavigateToBuild:()=>s("build"),onDismiss:d??(()=>{})})]})}const pO=Object.freeze(Object.defineProperty({__proto__:null,EditorNavBar:tm},Symbol.toStringTag,{value:"Module"}));function sm({projectTitle:t}){const s=typeof t=="string"&&t.trim().length>0;return e.jsxs("div",{"data-tauri-drag-region":!0,"data-testid":"desktop-title-bar",className:"shrink-0 bg-black h-9 flex items-center justify-center gap-2 px-4 select-none",children:[e.jsx($n,{className:"h-5 text-white shrink-0"}),s&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[#8E8E8E] text-sm shrink-0",children:"/"}),e.jsx("span",{className:"text-white text-sm truncate max-w-[60%]",children:t})]})]})}const mO=Object.freeze(Object.defineProperty({__proto__:null,DesktopTitleBar:sm},Symbol.toStringTag,{value:"Module"}));function Eo({target:t,onStored:s,onClose:n}){const[r,a]=l.useState(""),[o,i]=l.useState(!1),[c,d]=l.useState(null),[u,h]=l.useState(!1),p=l.useCallback(async()=>{if(r.trim()){i(!0),d(null),h(!1);try{const m=await fetch("/api/setup/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topic:t.topic,provider:"passthrough",credential:r.trim(),credential_fields:{envVar:t.envVar}})});if(!m.ok){if(Hy(m.status)==="transient"){h(!0),d(`The editor was briefly unreachable (HTTP ${m.status}). Your key wasn't rejected — try again.`);return}const b=await m.json().catch(()=>({}));d(b.error??`Could not store the key (HTTP ${m.status}).`);return}const f=await m.json().catch(()=>({}));if(f.success===!1||f.status==="error"){d(f.message??f.error??"The key was rejected.");return}a(""),s()}catch{h(!0),d("Could not reach the editor to store the key. Try again.")}finally{i(!1)}}},[r,t,s]);return e.jsx("div",{"data-testid":"app-service-credential-modal",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:e.jsxs("div",{className:"w-[28rem] max-w-[90vw] rounded-lg border border-[#3A3A3A] bg-[#161616] p-5 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("h2",{className:"text-base font-semibold text-white",children:["Add your ",t.serviceName," API key"]}),e.jsx("button",{"data-testid":"app-service-credential-close",onClick:n,className:"text-[#8E8E8E] hover:text-white cursor-pointer","aria-label":"Close",children:"✕"})]}),e.jsxs("p",{className:"text-sm text-[#8E8E8E]",children:["The key is stored in",e.jsx("code",{className:"mx-1 text-[#D7FF63]",children:".codeyam/setup-connections.json"}),"(owner-only, gitignored) and injected into your app as",e.jsx("code",{className:"mx-1 text-[#D7FF63]",children:t.envVar})," — never committed."]}),t.docsUrl?e.jsx("a",{href:t.docsUrl,target:"_blank",rel:"noreferrer",className:"inline-block text-sm text-[#7EA6FF] hover:underline",children:"Where to find this key →"}):null,e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"password",value:r,onChange:m=>a(m.target.value),placeholder:`${t.serviceName} API key`,className:"flex-1 min-w-0 px-2 py-1.5 rounded bg-black border border-[#3A3A3A] text-white text-sm"}),e.jsx("button",{onClick:()=>void p(),disabled:o||!r.trim(),className:"px-3 py-1.5 text-sm rounded-md bg-[#D7FF63] text-black font-medium cursor-pointer disabled:opacity-50",children:o?"Saving…":"Save"})]}),c?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-[#FF8B43]",children:c}),u?e.jsx("button",{"data-testid":"app-service-credential-retry",onClick:()=>void p(),disabled:o||!r.trim(),className:"px-3 py-1.5 text-sm rounded-md border border-[#3A3A3A] text-white font-medium cursor-pointer disabled:opacity-50",children:o?"Saving…":"Retry"}):null]}):null]})})}const fO=Object.freeze(Object.defineProperty({__proto__:null,AppServiceCredentialModal:Eo},Symbol.toStringTag,{value:"Module"}));function tk(t,s){for(const n of t.filesByDirectory)for(const r of n.files)if(r.filePath===s)return r;return null}function nm(t){return t>=80?"#16a34a":t>=50?"#eab308":"#dc2626"}function Qs({coverage:t}){const s=Math.max(0,Math.min(100,t.percent)),n=nm(s);return e.jsxs("div",{className:"flex items-center gap-2 min-w-[140px]","data-testid":"coverage-bar",children:[e.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-gray-200 overflow-hidden",children:e.jsx("div",{"data-testid":"coverage-bar-fill",className:"h-full rounded-full",style:{width:`${s}%`,backgroundColor:n}})}),e.jsxs("span",{className:"text-xs font-mono tabular-nums",style:{color:n},children:[Math.round(s),"%"]})]})}const gO=Object.freeze(Object.defineProperty({__proto__:null,CoverageBar:Qs},Symbol.toStringTag,{value:"Module"}));function rm({file:t,onSelectFile:s}){return e.jsxs("li",{className:"flex items-center gap-3 py-2","data-testid":"coverage-details-directory-file-row",children:[e.jsx("button",{type:"button",onClick:()=>s(t),className:"flex-1 min-w-0 text-left text-xs text-gray-700 truncate hover:underline cursor-pointer",children:t.filePath}),e.jsx(Qs,{coverage:t.coverage})]})}const bO=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsDirectoryFileRow:rm},Symbol.toStringTag,{value:"Module"}));function am({group:t,onSelectFile:s}){return e.jsxs("details",{"data-testid":"coverage-details-directory-group",children:[e.jsxs("summary",{className:"cursor-pointer text-sm font-medium text-gray-800",children:[t.directory||"(root)"," ·"," ",e.jsxs("span",{className:"text-gray-500",children:[t.files.length," file",t.files.length===1?"":"s"]})]}),e.jsx("ul",{className:"divide-y divide-gray-100 mt-2",children:t.files.map(n=>e.jsx(rm,{file:n,onSelectFile:s},n.filePath))})]})}const xO=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsDirectoryGroup:am},Symbol.toStringTag,{value:"Module"}));function om({directories:t,onSelectFile:s}){return t.length===0?null:e.jsxs("section",{className:"bg-white border border-gray-200 rounded-lg p-4","data-testid":"coverage-details-directories-section",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 m-0 mb-2",children:"By directory"}),e.jsx("div",{className:"flex flex-col gap-3",children:t.map(n=>e.jsx(am,{group:n,onSelectFile:s},n.directory||"(root)"))})]})}const yO=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsDirectoriesSection:om},Symbol.toStringTag,{value:"Module"}));function im({entry:t,onSelectFile:s}){return e.jsxs("li",{className:"flex items-center gap-3 py-2","data-testid":"coverage-details-entry-row",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("button",{type:"button",onClick:()=>s(t.filePath),className:"text-sm font-medium text-gray-900 truncate text-left hover:underline cursor-pointer",children:t.name}),e.jsx("div",{className:"text-xs text-gray-500 truncate",children:t.filePath}),t.linkedTests.length>0&&e.jsxs("div",{className:"text-xs text-gray-400 truncate",children:[t.linkedTests.length," linked test",t.linkedTests.length===1?"":"s"]})]}),e.jsx(Qs,{coverage:{percent:t.percent,hitLines:t.hitLines,totalLines:t.totalLines}})]})}const vO=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsEntryRow:im},Symbol.toStringTag,{value:"Module"}));function lm({entries:t,onSelectFile:s}){return e.jsxs("section",{className:"bg-white border border-gray-200 rounded-lg p-4","data-testid":"coverage-details-entries-section",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 m-0 mb-2",children:"By glossary entry"}),t.length===0?e.jsx("p",{className:"text-xs text-gray-500","data-testid":"coverage-details-entries-empty",children:"No glossary entries have coverage data yet."}):e.jsx("ul",{className:"divide-y divide-gray-100",children:t.map(n=>e.jsx(im,{entry:n,onSelectFile:s},`${n.filePath}::${n.name}`))})]})}const jO=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsEntriesSection:lm},Symbol.toStringTag,{value:"Module"}));function cm({file:t}){return e.jsxs("li",{className:"flex items-center gap-3 py-2","data-testid":"orphaned-file-row",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("div",{className:"text-xs text-gray-500 truncate",children:t.filePath})}),e.jsx("span",{className:"text-[10px] uppercase tracking-wide text-gray-400",title:"Coverage at file level — no glossary entry maps to this file.",children:"file-level"}),e.jsx(Qs,{coverage:t.coverage})]})}const wO=Object.freeze(Object.defineProperty({__proto__:null,OrphanedFileRow:cm},Symbol.toStringTag,{value:"Module"}));function dm({files:t,onSelectFile:s}){return t.length===0?null:e.jsxs("section",{className:"bg-white border border-gray-200 rounded-lg p-4","data-testid":"coverage-details-orphaned-section",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 m-0 mb-2",children:"Orphaned files"}),e.jsxs("div",{className:"text-xs text-gray-500 mb-2",children:[t.length," file",t.length===1?"":"s"," with coverage but no glossary entry."]}),e.jsx("ul",{className:"divide-y divide-gray-100",children:t.map(n=>e.jsx("div",{onClick:()=>s(n.filePath),role:"button",tabIndex:0,className:"cursor-pointer",onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),s(n.filePath))},children:e.jsx(cm,{file:n})},n.filePath))})]})}const _O=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsOrphanedSection:dm},Symbol.toStringTag,{value:"Module"}));function um({line:t,hits:s}){const n=s>0;return e.jsxs("li",{className:"flex items-center gap-3 py-1 font-mono text-xs","data-testid":n?"coverage-line-hit":"coverage-line-miss",children:[e.jsx("span",{className:"w-12 text-right text-gray-400",children:t}),e.jsx("span",{className:n?"px-2 py-0.5 rounded bg-green-100 text-green-800":"px-2 py-0.5 rounded bg-red-100 text-red-800",children:n?`×${s}`:"miss"})]})}const kO=Object.freeze(Object.defineProperty({__proto__:null,CoverageLineRow:um},Symbol.toStringTag,{value:"Module"}));function hm({file:t,onBack:s}){const n=Object.entries(t.lines).map(([r,a])=>({line:Number(r),hits:a})).sort((r,a)=>r.line-a.line);return e.jsxs("div",{"data-testid":"coverage-file-drilldown",className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("button",{type:"button",onClick:s,className:"text-xs font-medium text-[var(--accent-active)] hover:underline cursor-pointer","data-testid":"coverage-file-drilldown-back",children:"← Back"}),e.jsx("div",{className:"text-sm font-medium text-gray-900 truncate mt-1",children:t.filePath})]}),e.jsx(Qs,{coverage:t.coverage})]}),n.length===0?e.jsx("p",{className:"text-xs text-gray-500",children:"No instrumented lines in this file."}):e.jsx("ul",{className:"divide-y divide-gray-100 max-h-[50vh] overflow-y-auto","data-testid":"coverage-file-drilldown-lines",children:n.map(({line:r,hits:a})=>e.jsx(um,{line:r,hits:a},r))})]})}const SO=Object.freeze(Object.defineProperty({__proto__:null,CoverageFileDrilldown:hm},Symbol.toStringTag,{value:"Module"}));function pm({title:t,aggregate:s,aggregateTestId:n}){return e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h2",{className:"text-sm font-semibold text-gray-900 m-0",children:t}),s&&s.totalLines>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-gray-500",children:[s.hitLines,"/",s.totalLines," lines"]}),e.jsxs("span",{className:"text-xs font-semibold",style:{color:nm(s.percent)},"data-testid":n,children:[Math.round(s.percent),"% overall"]})]})]})}const NO=Object.freeze(Object.defineProperty({__proto__:null,CoverageSectionHeader:pm},Symbol.toStringTag,{value:"Module"}));function mm({warnings:t}){return t.length===0?null:e.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-4","data-testid":"coverage-warnings-banner",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-amber-600 text-lg leading-none mt-0.5","aria-hidden":"true",children:"!"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-sm font-semibold text-amber-800 m-0",children:"Coverage Warnings"}),e.jsx("ul",{className:"mt-1 space-y-1 text-sm text-amber-700 list-none p-0 m-0",children:t.map((s,n)=>e.jsx("li",{className:"break-words",children:s},n))})]})]})})}const CO=Object.freeze(Object.defineProperty({__proto__:null,CoverageWarningsBanner:mm},Symbol.toStringTag,{value:"Module"}));function fm({onClose:t,fetchDetails:s=sk,initialData:n}){const[r,a]=l.useState(n??null),[o,i]=l.useState(null),[c,d]=l.useState(null);l.useEffect(()=>{if(n)return;let p=!1;return s().then(m=>{p||a(m)}).catch(m=>{p||i(m instanceof Error?m.message:String(m))}),()=>{p=!0}},[s,n]);const u=l.useCallback(p=>{p.key==="Escape"&&(p.preventDefault(),c?d(null):t())},[t,c]);l.useEffect(()=>(window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)),[u]);const h=p=>{if(!r)return;const m=tk(r,p);m&&d(m)};return e.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},"data-testid":"coverage-details-modal",onClick:t,children:e.jsxs("div",{className:"max-w-3xl w-full mx-4 p-6 rounded-lg bg-[var(--bg-card)] max-h-[90vh] overflow-y-auto",onClick:p=>p.stopPropagation(),children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] m-0",children:"Project coverage"}),e.jsx("button",{type:"button",onClick:t,className:"text-sm text-[var(--text-muted)] hover:text-[var(--text-primary)] cursor-pointer","data-testid":"coverage-details-modal-close","aria-label":"Close",children:"✕"})]}),o&&e.jsxs("p",{className:"text-sm text-red-700","data-testid":"coverage-details-modal-error",children:["Failed to load coverage details: ",o]}),!r&&!o&&e.jsx("p",{className:"text-sm text-[var(--text-muted)]","data-testid":"coverage-details-modal-loading",children:"Loading coverage details…"}),r&&c&&e.jsx(hm,{file:c,onBack:()=>d(null)}),r&&!c&&e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(pm,{title:"Overall",aggregate:r.projectWide,aggregateTestId:"coverage-details-modal-aggregate"}),r.coverageWarnings.length>0&&e.jsx(mm,{warnings:r.coverageWarnings}),e.jsx(lm,{entries:r.entries,onSelectFile:h}),e.jsx(dm,{files:r.orphanedFiles,onSelectFile:h}),e.jsx(om,{directories:r.filesByDirectory,onSelectFile:d})]})]})})}function sk(){return fetch("/api/coverage/details").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()})}const TO=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsModal:fm},Symbol.toStringTag,{value:"Module"}));function nk(t,s){const n=t.filter(r=>!gn(r.route));if(n.length>0){if(n.length===1){const r=n[0],a=r.scenarios.filter(o=>!gn(o.url));if(a.length>1)return a.map((o,i)=>({key:o.slug||`scn-${i}`,name:o.name,route:r.route||null,scenarioSlug:o.slug,screenshotPath:o.screenshotPaths[0]??null,screenshotCb:o.screenshotCapturedAtMs??null}))}return n.map((r,a)=>{const o=r.scenarios.find(c=>c.screenshotPaths.length>0),i=o??r.scenarios[0];return{key:r.route||`route-${a}`,name:r.displayName||r.route||"Page",route:r.route||null,scenarioSlug:(i==null?void 0:i.slug)??null,screenshotPath:(o==null?void 0:o.screenshotPaths[0])??null,screenshotCb:(o==null?void 0:o.screenshotCapturedAtMs)??null}})}return s.filter(r=>r.scenarioType==="application"&&r.url&&!gn(r.url)).map((r,a)=>({key:r.slug||`scn-${a}`,name:r.name,route:r.url,scenarioSlug:r.slug,screenshotPath:r.screenshotPaths[0]??null,screenshotCb:r.screenshotCapturedAtMs??null}))}function gm({items:t,maxVisible:s=6,onSelect:n,onOpenAll:r}){const a=t.slice(0,s),o=t.length-a.length;return e.jsxs("div",{className:"exdoor",children:[e.jsxs("button",{type:"button",className:"exhead",onClick:r,children:[e.jsx("div",{className:"dic",children:e.jsx(Ic,{size:20})}),e.jsxs("div",{className:"grow",children:[e.jsx("div",{className:"dname",children:"Explore your app"}),e.jsx("div",{className:"ddesc",children:"Every page of your app. Click one to see it live."})]}),e.jsx("span",{className:"open",children:"Open all →"})]}),e.jsxs("div",{className:"rail",children:[a.length===0?e.jsx("div",{className:"railempty",children:"No pages registered yet — they'll appear here as you build."}):a.map(i=>e.jsxs("button",{type:"button",className:"pcard",onClick:()=>n(i),children:[e.jsx("div",{className:"pthumb",children:i.screenshotPath?e.jsx("img",{className:"pshot",src:at(i.screenshotPath,i.screenshotCb??void 0),alt:`${i.name} preview`,loading:"lazy"}):e.jsx("div",{className:"pnopreview",children:"No preview"})}),e.jsx("div",{className:"pname",children:i.name})]},i.key)),o>0?e.jsx("div",{className:"allcard",children:e.jsxs("button",{type:"button",className:"alltile",onClick:r,children:[e.jsxs("span",{className:"n",children:["+",o]}),e.jsx("span",{className:"l",children:o===1?"page":"pages"})]})}):null]})]})}const PO=Object.freeze(Object.defineProperty({__proto__:null,ExploreRail:gm},Symbol.toStringTag,{value:"Module"})),Nn=5;function bm({admin:t,isBuilding:s,buildingLabel:n,buildingStepLabel:r,buildingStepIndicator:a=null,buildingStatus:o="building",buildingProgress:i=null,lastBuiltLabel:c,plansCount:d,learnDoneCount:u,exploreSlot:h,onOpenBuilding:p,onStartNewFeature:m,onOpenPlans:f,onOpenLearn:b}){const g=Math.max(0,Math.min(Nn,u)),v=Array.from({length:Nn},(x,y)=>y<g);return e.jsxs("div",{className:"doorrows",children:[h,e.jsxs("button",{type:"button",className:"drow",onClick:f,children:[e.jsx("div",{className:"dic ic-plan",children:e.jsx(Dc,{size:19})}),e.jsxs("div",{className:"dmain",children:[e.jsx("div",{className:"dname",children:"Plans"}),e.jsx("div",{className:"ddesc",children:"Changes you've described, waiting to build next."})]}),e.jsxs("div",{className:"dright",children:[e.jsxs("div",{className:"dmeta",children:[e.jsxs("span",{className:"stat",children:[d," queued"]}),"to build"]}),e.jsx("span",{className:"arr",children:"→"})]})]}),e.jsx(mo,{isBuilding:s,buildingLabel:n,buildingStepLabel:r,buildingStepIndicator:a,buildingStatus:o,buildingProgress:i,lastBuiltLabel:c,onOpenBuilding:p,onStartNewFeature:m}),t?e.jsxs("button",{type:"button",className:"drow quiet",onClick:b,children:[e.jsx("div",{className:"dic ic-learn",children:e.jsx(Un,{size:19})}),e.jsxs("div",{className:"dmain",children:[e.jsx("div",{className:"dname",children:"Setup"}),e.jsx("div",{className:"ddesc",children:"Hosting, real data, security, emails. The things every app eventually needs."})]}),e.jsxs("div",{className:"dright",children:[e.jsxs("div",{className:"dmeta",children:[e.jsxs("span",{className:"stat",children:[g," of ",Nn," set up"]}),e.jsx("span",{className:"lines",children:v.map((x,y)=>e.jsx("span",{className:x?"ln done":"ln"},y))})]}),e.jsx("span",{className:"arr",children:"→"})]})]}):null]})}const OO=Object.freeze(Object.defineProperty({__proto__:null,DoorRows:bm,LEARN_TOPIC_COUNT:Nn},Symbol.toStringTag,{value:"Module"}));function xm({projectTitle:t,app:s,routeEntities:n,allScenarios:r,admin:a,isBuilding:o,buildingLabel:i,buildingStepLabel:c,buildingStepIndicator:d,buildingStatus:u,buildingProgress:h,lastBuiltLabel:p,plansCount:m,learnDoneCount:f,onSelectScenario:b,onOpenAllSimulations:g,onOpenBuilding:v,onStartNewFeature:x,onOpenPlans:y,onOpenLearn:w,onBackToProjects:j,launcherUrl:k,projectCount:S=0}){const N=l.useMemo(()=>nk(n,r),[n,r]),T=!!k||S>=2,[A,_]=l.useState(!1),M=async()=>{if(k){window.location.href=k;return}if(!A){_(!0);try{const z=await fetch("/api/launcher/ensure",{method:"POST"}),G=await z.json().catch(()=>({}));if(z.ok&&typeof G.url=="string"){window.location.href=G.url;return}_(!1)}catch{_(!1)}}},I=(t==null?void 0:t.trim())||s.name||"Your project",H=z=>{z.scenarioSlug?b(z.scenarioSlug):g()};return e.jsxs("div",{className:"home-landing",children:[j||T?e.jsxs("div",{className:"crumbs",children:[T?e.jsx("button",{type:"button",className:"back",disabled:A,onClick:()=>{M()},children:A?"Opening launcher…":"‹ All projects"}):null,j?e.jsx("button",{type:"button",className:"back",onClick:j,children:"‹ Projects"}):null]}):null,e.jsx("div",{className:"hello",children:"Welcome back"}),e.jsx("div",{className:"project",children:I}),e.jsx("div",{className:"seclabel",children:"Your project"}),e.jsx(bm,{admin:a,isBuilding:o,buildingLabel:i,buildingStepLabel:c,buildingStepIndicator:d,buildingStatus:u,buildingProgress:h,lastBuiltLabel:p,plansCount:m,learnDoneCount:f,exploreSlot:e.jsx(gm,{items:N,onSelect:H,onOpenAll:g}),onOpenBuilding:v,onStartNewFeature:x,onOpenPlans:y,onOpenLearn:w})]})}const AO=Object.freeze(Object.defineProperty({__proto__:null,HomeLanding:xm},Symbol.toStringTag,{value:"Module"})),rk={provider:"vercel"},ym={"dev-accounts":Pu,"store-assets":Ou,"store-listing":Au,"testing-distribution":Ru,"push-notifications":Eu,"crash-reporting":Mu,"in-app-purchases":Iu,"app-privacy":Du,"app-review":Lu};function Yi(t){return t in ym}function ak(){const[t,s]=l.useState(null),n=l.useCallback(async()=>{try{const o=await fetch("/api/setup-topics");if(!o.ok)throw new Error(`HTTP ${o.status}`);const i=await o.json();s(Array.isArray(i)?i:[])}catch{s([])}},[]);l.useEffect(()=>{n()},[n]);const r=l.useCallback((o,i)=>{s(c=>c&&c.map(d=>d.key===o?{...d,status:i}:d)),fetch("/api/setup-status",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:o,status:i})}).catch(()=>{n()})},[n]),a=l.useCallback(async o=>{const i=await fetch("/api/setup-topics",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:o.name,desc:o.desc??"",icon:o.icon??""})});if(!i.ok){const d=await i.json().catch(()=>null);throw new Error(d&&typeof d.error=="string"&&d.error||`HTTP ${i.status}`)}const c=await i.json();return await n(),{key:c.key,existed:!!c.existed}},[n]);return{topics:t,setStatus:r,addTopic:a}}function ok(){const[t,s]=l.useState(null);return l.useEffect(()=>{let n=!1;return(async()=>{try{const r=await fetch("/api/setup-libraries");if(!r.ok)throw new Error(`HTTP ${r.status}`);const a=await r.json();n||s(Array.isArray(a)?a:[])}catch{n||s([])}})(),()=>{n=!0}},[]),{groups:t}}function ik(){const[t,s]=l.useState(null);return l.useEffect(()=>{let n=!1;return(async()=>{try{const r=await fetch("/api/local-run-recipe");if(!r.ok)throw new Error(`HTTP ${r.status}`);const a=await r.json();n||s(a)}catch{n||s(null)}})(),()=>{n=!0}},[]),{recipe:t}}const lk=new Set(["share-testing","store-accounts","store-assets","permissions-justification","oauth-verification","privacy-policy","single-purpose-listing","manifest-versioning","submit-review"]);function vm({appDetailProps:t,appOverviewProps:s,selectedApp:n,projectTitle:r,admin:a,isBuilding:o,buildingLabel:i,buildingStepLabel:c,buildingStepIndicator:d,buildingStatus:u,buildingProgress:h,lastBuiltLabel:p,plansCount:m,onNavigateToPlan:f,onNavigateToBuild:b,onBackToProjects:g,launcherUrl:v,projectCount:x}){const[y,w]=l.useState(!1),j=()=>w(!0),k=()=>w(!1),[S,N]=l.useState("landing"),[T,A]=l.useState(null),[_,M]=l.useState(null),{topics:I,setStatus:H,addTopic:z}=ak(),G=(I==null?void 0:I.filter(C=>C.status==="done").length)??0,{services:R,dismiss:D,refetch:P}=id(),[$,F]=l.useState(null),U=l.useCallback(C=>{var B;const E=(B=C.envVars)==null?void 0:B[0];E&&F({serviceName:C.name,envVar:E,topic:C.topic,docsUrl:C.docsUrl})},[]),{recipe:J}=ik(),Z=g0(Pc()),{groups:te}=ok(),ie=(I==null?void 0:I.some(C=>C.key==="dev-accounts"))??!1,V=(I==null?void 0:I.some(C=>C.key==="deploy-target"))??!1,le=C=>{C==="run-locally"?N("run-locally"):ie&&Yi(C)?(M(C),N("mobile-setup")):lk.has(C)?N(C):Yi(C)?(M(C),N("mobile-setup")):(A(C),N("topic"))},me=!!(t.selectedRouteEntity||t.selectedEntityHash);let Q;if(!n)Q=e.jsx(Sh,{...s,onCoverageClick:j},"app-overview");else if(me||S==="detail"){const C=S==="detail"&&!me;Q=e.jsxs(e.Fragment,{children:[C?e.jsx("div",{className:"home-landing",style:{padding:"20px 28px 0"},children:e.jsxs("div",{className:"crumbs",style:{marginBottom:0},children:[e.jsx("button",{type:"button",className:"back",onClick:()=>N("landing"),"aria-label":"Back",children:"←"}),e.jsx("button",{type:"button",onClick:()=>N("landing"),children:"Home"}),e.jsx("span",{className:"sep",children:"›"}),e.jsx("b",{children:"Explore your app"})]})}):null,e.jsx(Rc,{app:n,...t,onCoverageClick:j})]})}else if(S==="learn")Q=e.jsx(sa,{topics:I,detectedServices:R,onBack:()=>N("landing"),onOpenHosting:()=>N("hosting"),onOpenTopic:le,onOpenLibraries:()=>N("libraries"),onDismissService:D,onAddCredential:U,onCreateTopic:z,onOpenConcepts:()=>N("concepts")});else if(S==="libraries")Q=e.jsx(Uc,{groups:te,onBack:()=>N("learn")});else if(S==="concepts")Q=e.jsx(cu,{onBack:()=>N("learn")});else if(S==="hosting")Q=e.jsx(bu,{connector:rk,onBack:()=>N("learn"),onComplete:()=>H("hosting","done")});else if(S==="run-locally")Q=e.jsx(xu,{recipe:J,onBack:()=>N("learn"),onMarkDone:()=>{H("run-locally","done"),N("learn")}});else if(S==="share-testing")Q=e.jsx(Tu,{onBack:()=>N("learn"),onComplete:()=>H("share-testing","done")});else if(S==="store-accounts")Q=e.jsx(yu,{onBack:()=>N("learn"),onComplete:()=>H("store-accounts","done")});else if(S==="store-assets")Q=e.jsx(vu,{onBack:()=>N("learn"),onComplete:()=>H("store-assets","done")});else if(S==="permissions-justification")Q=e.jsx(wu,{onBack:()=>N("learn"),onComplete:()=>H("permissions-justification","done")});else if(S==="oauth-verification")Q=e.jsx(ku,{onBack:()=>N("learn"),onComplete:()=>H("oauth-verification","done")});else if(S==="privacy-policy")Q=e.jsx(_u,{onBack:()=>N("learn"),onComplete:()=>H("privacy-policy","done")});else if(S==="single-purpose-listing")Q=e.jsx(Su,{onBack:()=>N("learn"),onComplete:()=>H("single-purpose-listing","done")});else if(S==="manifest-versioning")Q=e.jsx(Nu,{onBack:()=>N("learn"),onComplete:()=>H("manifest-versioning","done")});else if(S==="submit-review")Q=e.jsx(Cu,{onBack:()=>N("learn"),onComplete:()=>H("submit-review","done")});else if(S==="topic"&&T){const C=(I==null?void 0:I.find(E=>E.key===T))??null;Q=e.jsx(lu,{topicKey:T,topicName:C==null?void 0:C.name,topicDesc:C==null?void 0:C.desc,isBackend:V,onBack:()=>N("learn"),onComplete:E=>H(E,"done")})}else if(S==="mobile-setup"&&_){const C=ym[_];Q=C?e.jsx(C,{platform:Z,onBack:()=>N("learn"),onComplete:()=>H(_,"done")}):e.jsx(sa,{topics:I,detectedServices:R,onBack:()=>N("landing"),onOpenHosting:()=>N("hosting"),onOpenTopic:le,onDismissService:D,onAddCredential:U})}else Q=e.jsx(xm,{app:n,projectTitle:r,routeEntities:t.routeEntities,allScenarios:t.allScenarios,admin:a,isBuilding:o,buildingLabel:i,buildingStepLabel:c,buildingStepIndicator:d,buildingStatus:u,buildingProgress:h,lastBuiltLabel:p,plansCount:m,learnDoneCount:G,onSelectScenario:t.onSelectScenario,onOpenAllSimulations:()=>N("detail"),onOpenBuilding:b,onStartNewFeature:b,onOpenPlans:f,onOpenLearn:()=>N("learn"),onBackToProjects:g,launcherUrl:v,projectCount:x});return e.jsxs(zc,{children:[Q,y&&e.jsx(fm,{onClose:k}),$?e.jsx(Eo,{target:$,onStored:()=>{F(null),P()},onClose:()=>F(null)}):null]})}const RO=Object.freeze(Object.defineProperty({__proto__:null,EditorShellHomeTabContent:vm},Symbol.toStringTag,{value:"Module"}));function jm({activeTab:t,awaitingPlanLaunchChoice:s,buildLaunchGateArmed:n,buildActivated:r,hideResultsCommandKey:a,onSelectScenario:o,onSessionDetected:i,previewSlug:c,showResultsCommandKey:d,onAgentIdle:u,onAgentActive:h,onUserInput:p,notifSettings:m,onSettingsChange:f,provider:b,onRestorePreview:g,pendingPlans:v,pendingPlansLoading:x,pendingPlansError:y,onLaunchPlan:w,launchingSlug:j,launchError:k,onReorderPlans:S,isAgentBuilding:N,featureCompleteActive:T}){return r?e.jsx(Xp,{awaitingPlanLaunchChoice:s,buildLaunchGateArmed:n,buildActivated:r,activeTab:t,onSessionDetected:i,onSelectScenario:o,previewSlug:c,showResultsCommandKey:d,hideResultsCommandKey:a,onAgentIdle:u,onAgentActive:h,onUserInput:p,notifSettings:m,onSettingsChange:f,provider:b,onRestorePreview:g,pendingPlans:v,pendingPlansLoading:x,pendingPlansError:y,onLaunchPlan:w,launchingSlug:j,launchError:k,onReorderPlans:S,isAgentBuilding:N,featureCompleteActive:T}):null}const EO=Object.freeze(Object.defineProperty({__proto__:null,EditorShellBuildLayer:jm},Symbol.toStringTag,{value:"Module"}));function wm({onMouseDown:t}){return e.jsx("div",{onMouseDown:t,className:"shrink-0 flex items-center justify-center group",style:{width:12,cursor:"col-resize",background:"var(--bg-surface)",borderLeft:"1px solid var(--border-default)",borderRight:"1px solid var(--border-default)"},children:e.jsx("div",{className:"w-0.5 h-8 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",style:{background:"var(--text-dim)"}})})}const MO=Object.freeze(Object.defineProperty({__proto__:null,PanelDivider:wm},Symbol.toStringTag,{value:"Module"})),ck=[{key:"editor",label:"Editor"},{key:"preview",label:"Preview"}];function _m({active:t,onChange:s,isAgentBuilding:n=!1,buildIdle:r=!1}){const a=n&&!r,o=r;return e.jsx("div",{"data-testid":"mobile-pane-switcher",className:"shrink-0 flex w-full",style:{background:"var(--bg-nav)",borderTop:"1px solid var(--border-default)",paddingBottom:"env(safe-area-inset-bottom)"},children:ck.map(i=>{const c=t===i.key;return e.jsxs("button",{"data-testid":`mobile-pane-switcher-${i.key}`,onClick:()=>s(i.key),"aria-pressed":c,className:`flex-1 flex items-center justify-center gap-1 h-12 text-sm border-t-2 transition-colors cursor-pointer ${c?"text-[#D7FF63] border-[#D7FF63] font-medium":"text-[#8E8E8E] border-transparent font-light"}`,children:[i.key==="editor"&&a&&e.jsx(Bn,{}),i.key==="editor"&&o&&e.jsx("span",{"data-testid":"mobile-pane-switcher-dot-idle",className:"mr-1 inline-block w-2 h-2 rounded-full bg-[#FF8B43]"}),i.label]},i.key)})})}const IO=Object.freeze(Object.defineProperty({__proto__:null,MobilePaneSwitcher:_m},Symbol.toStringTag,{value:"Module"}));function km({isCollapsed:t,leftPane:s,onResizeStart:n,previewPane:r,splitRef:a,isNarrow:o,mobilePane:i,onMobilePaneChange:c,isAgentBuilding:d=!1,buildIdle:u=!1}){return o?e.jsxs("div",{ref:a,className:"fixed inset-0 flex flex-col",style:{background:"var(--bg-surface)"},children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:`absolute inset-0 flex ${i==="editor"?"":"hidden"}`,children:s}),e.jsx("div",{className:`absolute inset-0 flex ${i==="preview"?"":"hidden"}`,children:r})]}),e.jsx(_m,{active:i,onChange:c,isAgentBuilding:d,buildIdle:u})]}):e.jsxs("div",{ref:a,className:"fixed inset-0 flex",style:{background:"var(--bg-surface)"},children:[!t&&e.jsxs(e.Fragment,{children:[s,e.jsx(wm,{onMouseDown:n})]}),r]})}const DO=Object.freeze(Object.defineProperty({__proto__:null,EditorShellLayout:km},Symbol.toStringTag,{value:"Module"}));function Sm(){const[t,s]=l.useState([]),[n,r]=l.useState(!0),[a,o]=l.useState(null),{plansVersion:i}=Xt(),c=l.useCallback(async()=>{r(!0),o(null);try{const d=await fetch("/api/plans");if(!d.ok)throw new Error(`HTTP ${d.status}`);const u=await d.json();s(Array.isArray(u)?u.map(h=>({...h,dependsOn:Array.isArray(h.dependsOn)?h.dependsOn:[]})):[])}catch(d){o(d instanceof Error?d.message:"Failed to load plans")}finally{r(!1)}},[]);return l.useEffect(()=>{c()},[c,i]),{plans:t,loading:n,error:a,refetch:c}}function dk(){const[t,s]=l.useState([]),[n,r]=l.useState(!0),[a,o]=l.useState(null),{plansVersion:i,claimsVersion:c}=Xt(),d=l.useCallback(async()=>{r(!0),o(null);try{const u=await fetch("/api/plan-claims");if(!u.ok)throw new Error(`HTTP ${u.status}`);const h=await u.json();s(Array.isArray(h)?h:[])}catch(u){o(u instanceof Error?u.message:"Failed to load plan claims")}finally{r(!1)}},[]);return l.useEffect(()=>{d()},[d,i,c]),{claims:t,loading:n,error:a,refetch:d}}function uk(){const[t,s]=l.useState(null),{claimsVersion:n}=Xt(),r=l.useCallback(async()=>{try{const a=await fetch("/api/plan-claims/sync-status");if(!a.ok)return;const o=await a.json();s(o)}catch{}},[]);return l.useEffect(()=>{r()},[r,n]),l.useEffect(()=>{const a=setInterval(()=>void r(),1e4);return()=>clearInterval(a)},[r]),{status:t}}function hk(){const[t,s]=l.useState(null),n=l.useCallback(async()=>{try{const r=await fetch("/api/server/staleness");if(!r.ok)return;const a=await r.json();s(a)}catch{}},[]);return l.useEffect(()=>{n()},[n]),l.useEffect(()=>{const r=setInterval(()=>void n(),6e4);return()=>clearInterval(r)},[n]),{staleness:t}}const Hr="codeyam-editor editor plan-claims-status",pk="git push origin HEAD";function Nm(t,s){switch(t){case"credential":return{message:"Plan tracking isn't reaching the remote — git credentials need refreshing. Run the command below from a shell to wake the credential helper.",command:pk};case"network":return{message:"Plan tracking can't reach the remote (network failure). Check connectivity, then run the command below for details.",command:Hr};case"git-spawn":return{message:"Plan tracking can't launch git. Run the command below for the failing invocation.",command:Hr};default:return{message:`Plan tracking is failing (${s} failed ticks). Teammates' in-flight plans may not appear. Run the command below for details.`,command:Hr}}}function Cm({status:t}){const{copied:s,copy:n}=qn(),r=(t==null?void 0:t.consecutiveFailures)??0;if((t==null?void 0:t.enabled)===!1||r<3)return null;const{message:a,command:o}=Nm(t==null?void 0:t.lastErrorCategory,r);return e.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-3","data-testid":"plan-claim-sync-banner",role:"alert",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-amber-600 text-lg leading-none mt-0.5","aria-hidden":"true",children:"!"}),e.jsxs("div",{className:"flex-1 min-w-0 text-sm text-amber-800",children:[a," ",e.jsx("code",{className:"text-xs",children:o})," ",e.jsx("button",{type:"button",className:"underline text-amber-700 hover:text-amber-900",onClick:()=>void n(o),children:s?"Copied":"Copy command"})]})]})})}const LO=Object.freeze(Object.defineProperty({__proto__:null,PlanClaimSyncBanner:Cm,planClaimSyncBannerContent:Nm},Symbol.toStringTag,{value:"Module"})),Ki="codeyam-editor editor restart-server";function Mo({staleness:t,backendOutOfDate:s=!1}){var i;const{copied:n,copy:r}=qn(),a=!!(t!=null&&t.stale);if(!a&&!s)return null;const o=((i=t==null?void 0:t.info)==null?void 0:i.minutesStale)??0;return e.jsx("div",{className:"rounded-lg p-3","data-testid":"server-staleness-banner",role:"alert",style:{background:"rgba(239, 111, 111, 0.08)",border:"0.5px solid rgba(239, 111, 111, 0.3)"},children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-lg leading-none mt-0.5","aria-hidden":"true",style:{color:"var(--red-300)"},children:"!"}),e.jsxs("div",{className:"flex-1 min-w-0 text-sm",style:{color:"var(--text-body)"},children:[a?e.jsxs(e.Fragment,{children:["The editor-server is running a stale binary (rebuilt ",o," min ago). Restart it to pick up the latest plan tracking fixes."]}):e.jsx(e.Fragment,{children:"The editor-server is out of date — it's running an older build that can't drive the Build tab. Restart it to reconnect."})," ","Run"," ",e.jsx("code",{className:"text-xs",style:{color:"var(--text-strong)"},children:Ki}),"."," ",e.jsx("button",{type:"button",className:"underline",style:{color:"var(--red-300)"},onClick:()=>void r(Ki),children:n?"Copied":"Copy command"})]})]})})}const FO=Object.freeze(Object.defineProperty({__proto__:null,ServerStalenessBanner:Mo},Symbol.toStringTag,{value:"Module"}));function mk(t){const s=new Map;for(const n of t){const r=s.get(n.slug);(!r||r.source!=="local"&&n.source==="local")&&s.set(n.slug,n)}return s}function fk(t,s){return t.filter(n=>n.source==="local"||!s.has(n.slug))}function Tm(t=10){const[s,n]=l.useState([]),[r,a]=l.useState(!0),[o,i]=l.useState(null),c=l.useCallback(async()=>{a(!0),i(null);try{const d=await fetch(`/api/plans/completed?limit=${t}`);if(!d.ok)throw new Error(`HTTP ${d.status}`);const u=await d.json();n(Array.isArray(u)?u:[])}catch(d){i(d instanceof Error?d.message:"Failed to load completed plans")}finally{a(!1)}},[t]);return l.useEffect(()=>{c()},[c]),{plans:s,loading:r,error:o,refetch:c}}function Pm(){const[t,s]=l.useState(()=>new Set),[n,r]=l.useState(!0),[a,o]=l.useState(null),i=l.useCallback(async()=>{r(!0),o(null);try{const c=await fetch("/api/plans/completed/slugs");if(!c.ok)throw new Error(`HTTP ${c.status}`);const d=await c.json(),u=Array.isArray(d==null?void 0:d.slugs)?d.slugs:[];s(new Set(u.filter(h=>typeof h=="string")))}catch(c){o(c instanceof Error?c.message:"Failed to load completed plan slugs")}finally{r(!1)}},[]);return l.useEffect(()=>{i()},[i]),{slugs:t,loading:n,error:a,refetch:i}}function gk(t,s,n){const r=new Map(s.map(a=>[a.slug,a]));return t.dependsOn.map(a=>{var o;return{slug:a,title:((o=r.get(a))==null?void 0:o.title)??null,satisfied:n.has(a)}})}function Om(t){return t.filter(s=>!s.satisfied)}function Am(t){const{slugs:s}=Pm();return l.useMemo(()=>{const n={},r={};for(const a of t){const o=a.dependsOn??[];if(o.length===0)continue;const i=gk({...a,dependsOn:o},t,s);r[a.slug]=i;const c=Om(i);c.length!==0&&(n[a.slug]={count:c.length,tooltip:c.map(d=>d.title??`missing: ${d.slug}`).join(", ")})}return{annotationsBySlug:n,dependenciesBySlug:r}},[t,s])}let ds={hasActiveSession:!1,isAgentBuilding:!1,stepStateFeature:null};function mr(t){ds={...ds,...t}}function bk(){return ds}function xk(){return ds.hasActiveSession||ds.isAgentBuilding||!!ds.stepStateFeature}const yk=500;async function vk(){var t;try{const s=await fetch("/api/config");if(!s.ok)return!0;const n=await s.json();return((t=n==null?void 0:n.providerAuth)==null?void 0:t.state)==="authenticated"}catch{return!0}}async function Io(){let t=!1,s;try{const n=await fetch("/api/session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear"})});s=n.status,n.ok&&(t=!0)}catch{}t&&mr({hasActiveSession:!1,isAgentBuilding:!1,stepStateFeature:null}),K("clear-editor-session",{ok:t,...s!==void 0?{status:s}:{},snapshotReset:t})}async function jk(){let t=!1,s;try{const n=await fetch("/api/stop-building",{method:"POST",headers:{"Content-Type":"application/json"}});s=n.status,n.ok&&(t=!0)}catch{}t&&mr({hasActiveSession:!1,isAgentBuilding:!1,stepStateFeature:null}),K("stop-building",{ok:t,...s!==void 0?{status:s}:{},snapshotReset:t})}async function wk(){let t=!1,s;try{const n=await fetch("/api/reset-everything",{method:"POST",headers:{"Content-Type":"application/json"}});s=n.status,n.ok&&(t=!0)}catch{}t&&mr({hasActiveSession:!1,isAgentBuilding:!1,stepStateFeature:null}),K("reset-everything",{ok:t,...s!==void 0?{status:s}:{},snapshotReset:t})}async function Do(t={}){const s=bk(),n=t.caller??"unknown",r=t.bypassLiveGuard===!0;if(xk()&&!r){K("launch-editor-skill",{caller:n,suppressed:!0,snapshot:s,bypassLiveGuard:!1});return}Tw(),K("launch-editor-skill",{caller:n,suppressed:!1,snapshot:s,bypassLiveGuard:r}),t.provider!=="gemini"&&(Mh(t.renameLabel??"Editor",n,Nl),Yr("/clear\r"),await new Promise(a=>setTimeout(()=>{Yr("/codeyam-editor\r"),a()},yk)))}async function _k(t={}){if(await Io(),!await vk()){K("launch-editor-skill",{caller:t.caller??"unknown",suppressed:!0,reason:"provider-not-authenticated"}),console.warn("[launchEditorWorkflow] provider not authenticated; aborting launch (the terminal gate would refuse the PTY).");return}await Do(t)}function Lo(t,s=!1,n=s){const r=iv(t),a=s&&r==="build"?"home":r,[o,i]=l.useState(a==="build"),[c,d]=l.useState(a==="plan");l.useEffect(()=>{a==="build"&&i(!0),a==="plan"&&d(!0)},[a]),l.useEffect(()=>{n&&r==="build"&&window.history.replaceState(null,"",_s("home"))},[n,r]);const u=l.useCallback(m=>{if(s&&m==="build"){window.history.pushState(null,"",_s("home"));return}window.history.pushState(null,"",_s(m)),m==="build"&&i(!0),m==="plan"&&d(!0)},[s]),h=l.useCallback(()=>{s||(window.history.pushState(null,"",_s("build")),i(!0))},[s]),p=l.useCallback(()=>{i(!1)},[]);return{activeTab:a,buildActivated:o,planActivated:c,navigateToTab:u,showBuildTab:h,deactivateBuild:p}}function Rm(){const{showBuildTab:t}=Lo(typeof window>"u"?"/":window.location.pathname),{config:s}=yt(),[n,r]=l.useState(null),[a,o]=l.useState(null),i=l.useCallback(async(c,d)=>{if(n)return!1;o(null),r(c);try{try{await Io(),R1()}catch{}const u=await fetch(`/api/plans/${encodeURIComponent(c)}/select`,{method:"POST"});if(!u.ok){let h=`HTTP ${u.status}`;try{const p=await u.json();p!=null&&p.error&&(h=p.error)}catch{}throw new Error(h)}t()}catch(u){return o(u instanceof Error?u.message:"Failed to launch plan"),r(null),!1}return r(null),Do({caller:"plan-launcher",renameLabel:d,provider:s==null?void 0:s.provider,bypassLiveGuard:!0}).catch(u=>{o(u instanceof Error?u.message:"Failed to launch plan")}),!0},[n,t,s==null?void 0:s.provider]);return{launchingSlug:n,error:a,launchPlan:i}}function Em(t){return{reorderPlans:l.useCallback(async n=>{const r=await fetch("/api/plans/reorder",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slugs:n})});if(!r.ok){const a=await r.json().catch(()=>({}));throw new Error(a.error??`HTTP ${r.status}`)}t==null||t()},[t])}}const kk={describe:"Claude Code will remember your plans and suggest them once the current building session is over.",prototype:"Build a working prototype with the agent. When it's right, formalize into Build to decompose, test, and ship."};function Mm({subTab:t="describe"}={}){return e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-medium text-[var(--text-primary)]",children:"Plan your next move"}),e.jsx("p",{className:"mt-1 text-sm text-[var(--text-dim)]",children:kk[t]})]})}const zO=Object.freeze(Object.defineProperty({__proto__:null,PlanTabHeader:Mm},Symbol.toStringTag,{value:"Module"}));function Im({onClose:t}){const s=n=>{n.target===n.currentTarget&&t()};return e.jsx("div",{"data-testid":"plan-run-blocked-modal",onClick:s,className:"absolute inset-0 z-10 flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},children:e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"Build in progress"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:Pp}),e.jsx("div",{className:"flex flex-col gap-3",children:e.jsx("button",{onClick:t,"data-testid":"plan-run-blocked-ok",className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition",style:{background:"var(--accent-active)",color:"var(--bg-deep)"},type:"button",children:"OK"})})]})})}const $O=Object.freeze(Object.defineProperty({__proto__:null,PlanRunBlockedModal:Im},Symbol.toStringTag,{value:"Module"}));function Dm({claim:t,onCancel:s,onConfirm:n}){const r=bs(),a=t.claimedBy.agentProvider??"agent",o=t.claimedBy.currentStep??"unknown",i=t.sessionAlive===!1,c=i?"Previous session (no longer running)":"Another session is working on this plan",d=i?"Reclaim and run":"Run anyway";l.useEffect(()=>{const h=p=>{p.key==="Escape"&&s()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[s]);const u=h=>{h.target===h.currentTarget&&s()};return e.jsx("div",{"data-testid":"plan-run-foreign-claim-modal",onClick:u,className:"absolute inset-0 z-10 flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},children:e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{"data-testid":"plan-foreign-claim-heading",className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:c}),e.jsxs("div",{className:"text-sm text-[var(--text-muted)] mb-4 flex flex-col gap-1",children:[e.jsxs("span",{"data-testid":"plan-foreign-claim-identity",children:["claimed by ",a,"@",t.claimedBy.machine]}),e.jsxs("span",{children:["started ",Mt(t.claimedBy.startedAt,r)]}),e.jsxs("span",{"data-testid":"plan-foreign-claim-step",children:["on step ",o," (",Mt(t.currentStepEnteredAt,r)," on step)"]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:s,"data-testid":"plan-run-foreign-claim-cancel",className:"flex-1 px-4 py-2.5 rounded-md text-sm font-medium transition",style:{background:"var(--bg-elevated, transparent)",border:"1px solid var(--border-default)",color:"var(--text-primary)"},type:"button",children:"Cancel"}),e.jsx("button",{onClick:n,"data-testid":"plan-run-foreign-claim-confirm",className:"flex-1 px-4 py-2.5 rounded-md text-sm font-medium transition",style:{background:"var(--accent-warn, #c08a2c)",color:"var(--bg-deep)"},type:"button",children:d})]})]})})}const BO=Object.freeze(Object.defineProperty({__proto__:null,PlanRunForeignClaimModal:Dm},Symbol.toStringTag,{value:"Module"}));function Lm({deps:t,onClose:s}){const n=r=>{r.target===r.currentTarget&&s()};return e.jsx("div",{"data-testid":"plan-run-dependencies-modal",onClick:n,className:"absolute inset-0 z-10 flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},children:e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"Prerequisite plans not yet built"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:"This plan depends on the following changes that have not yet been built. Run them first, then come back to this one."}),e.jsx("ul",{className:"flex flex-col gap-1.5 mb-4",children:t.map(r=>e.jsx("li",{"data-testid":`plan-dep-${r.slug}`,className:"text-sm text-[var(--text-primary)]",children:r.title===null?e.jsxs("span",{className:"text-[var(--text-muted)]",children:["missing: ",r.slug," — was the prerequisite plan deleted?"]}):r.title},r.slug))}),e.jsx("div",{className:"flex flex-col gap-3",children:e.jsx("button",{onClick:s,"data-testid":"plan-run-dependencies-ok",className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition",style:{background:"var(--accent-active)",color:"var(--bg-deep)"},type:"button",children:"OK"})})]})})}const HO=Object.freeze(Object.defineProperty({__proto__:null,PlanRunDependenciesModal:Lm},Symbol.toStringTag,{value:"Module"})),Sk=[{id:"describe",label:"Describe A Plan"},{id:"prototype",label:"Prototype A Plan"}];function Fm({active:t,onChange:s}){return e.jsx("div",{className:"mt-3 flex items-center gap-1 border-b border-[var(--border-subtle)]",role:"tablist","data-testid":"plan-sub-tabs",children:Sk.map(n=>{const r=n.id===t;return e.jsx("button",{type:"button",role:"tab","aria-selected":r,"data-testid":`plan-sub-tab-${n.id}`,onClick:()=>s(n.id),className:"px-2.5 py-2 text-sm transition-colors cursor-pointer border-b -mb-px "+(r?"text-[var(--accent-active)] border-[var(--accent-active)] font-medium":"text-[var(--text-dim)] border-transparent hover:text-[var(--text-primary)] font-light"),children:n.label},n.id)})})}const WO=Object.freeze(Object.defineProperty({__proto__:null,PlanSubTabs:Fm},Symbol.toStringTag,{value:"Module"}));function zm({onClose:t}){return e.jsx(Bs,{chatName:"prototype",slashCommand:"/codeyam-prototype",height:480,onClose:t})}const qO=Object.freeze(Object.defineProperty({__proto__:null,PrototypeAgentChat:zm},Symbol.toStringTag,{value:"Module"})),$m="Building is in-process. Prototyping is only available when building is not ongoing. Please wait for the current building session to complete before prototyping.";function Bm(){return e.jsxs("div",{"data-testid":"prototype-building-banner",className:"mt-3 rounded border px-4 py-3 text-sm",style:{background:"var(--bg-surface)",borderColor:"var(--border-default)",color:"var(--text-muted)"},children:[e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:"Build in progress."})," ",$m]})}const GO=Object.freeze(Object.defineProperty({__proto__:null,PROTOTYPE_BUILDING_IN_PROGRESS_MESSAGE:$m,PrototypeBuildingInProgressBanner:Bm},Symbol.toStringTag,{value:"Module"}));function xa({open:t,disabled:s=!1,onToggle:n}){const r="mt-3 inline-flex items-center gap-2 rounded border px-3 py-1.5 text-xs font-medium uppercase tracking-wide transition-colors",a=s?"border-[var(--border-default)] text-[var(--text-dim)] cursor-not-allowed":"border-[var(--accent-active)] text-[var(--accent-active)] hover:bg-[var(--accent-active)] hover:text-black cursor-pointer";return e.jsx("button",{type:"button",onClick:s?void 0:n,disabled:s,"aria-disabled":s,title:s?"Building is in progress.":t?"Close Prototype":"Start Prototyping","data-testid":"start-prototyping",className:`${r} ${a}`,children:t?"Close Prototype":"Start Prototyping"})}const UO=Object.freeze(Object.defineProperty({__proto__:null,StartPrototypingButton:xa},Symbol.toStringTag,{value:"Module"})),ya=800;function Rs(t){window.dispatchEvent(new CustomEvent("miniagent-send-input",{detail:t}))}function Nk(t){return new Promise(s=>{let n=!1;const r=()=>{n||(n=!0,window.removeEventListener("miniagent-output",r),clearTimeout(a),s())},a=setTimeout(r,t);window.addEventListener("miniagent-output",r,{once:!0})})}const Hm='The user has clicked "Finish and Formalize in Build". Stop prototyping. Write a plan file at .codeyam/plans/<slug>.md describing what was prototyped. Use frontmatter with `mode: ui` and `step: 11` (or `mode: backend` and `step: 8` for backend mode) and `source: prototype`. Pick a kebab-case slug that matches the feature you prototyped. Once the Write succeeds, run `codeyam-editor editor launch-plan <slug>` to switch the UI to the Build tab, then output "Done — opening Build to finalize." and stop.';function Wm({disabled:t=!1,onClick:s}={}){const[n,r]=l.useState(!1),a=l.useRef(!1),o=async()=>{if(!(t||a.current)){a.current=!0,r(!0);try{Rs(Hm),await Nk(ya),Rs("\r"),s==null||s()}finally{a.current=!1,r(!1)}}},i=t||n;return e.jsx("button",{type:"button",onClick:o,disabled:i,"data-testid":"finish-and-formalize",className:"mt-3 inline-flex items-center gap-2 rounded border px-3 py-1.5 text-xs font-medium uppercase tracking-wide transition-colors "+(i?"border-[var(--border-default)] text-[var(--text-dim)] cursor-not-allowed":"border-[var(--accent-active)] text-[var(--accent-active)] hover:bg-[var(--accent-active)] hover:text-black cursor-pointer"),children:"Finish and Formalize in Build"})}const VO=Object.freeze(Object.defineProperty({__proto__:null,FINISH_AND_FORMALIZE_INSTRUCTION:Hm,FinishAndFormalizeButton:Wm},Symbol.toStringTag,{value:"Module"}));function qm(t,s){return`Launches a chat window with ${t} to ${s==="describe"?"describe your plan":"start prototyping"}.`}function Fo({providerLabel:t,kind:s}){return e.jsx("p",{className:"mt-2 text-xs text-[var(--text-dim)]","data-testid":`plan-chat-launch-caption-${s}`,children:qm(t,s)})}const YO=Object.freeze(Object.defineProperty({__proto__:null,PlanChatLaunchCaption:Fo,planChatLaunchCaptionText:qm},Symbol.toStringTag,{value:"Module"}));function Gm({isAgentBuilding:t,onLaunched:s,launchSignal:n=0}){const[r,a]=l.useState(!1),[o,i]=l.useState(!1),{config:c}=yt(),d=At(c==null?void 0:c.provider),u=l.useRef(s);u.current=s;const h=l.useRef(n);l.useEffect(()=>{var f;n!==h.current&&(h.current=n,i(!1),a(!1),(f=u.current)==null||f.call(u))},[n]);const p=()=>{if(t)return;const f=!r;f&&lt(),a(f)},m=()=>{a(!1)};return t?e.jsxs("div",{"data-testid":"prototype-pane",children:[e.jsx(Bm,{}),e.jsx(xa,{open:!1,disabled:!0,onToggle:()=>{}})]}):e.jsxs("div",{"data-testid":"prototype-pane",children:[e.jsx(xa,{open:r,onToggle:p}),!r&&e.jsx(Fo,{providerLabel:d,kind:"prototype"}),r&&e.jsxs(e.Fragment,{children:[e.jsx(zm,{onClose:m}),e.jsx(Wm,{disabled:o,onClick:()=>i(!0)}),o&&e.jsx("p",{className:"mt-2 text-xs text-[var(--text-dim)]","data-testid":"prototype-awaiting-formalize",children:"Waiting for the agent to write the plan file…"})]})]})}const KO=Object.freeze(Object.defineProperty({__proto__:null,PrototypePane:Gm},Symbol.toStringTag,{value:"Module"}));function Um({open:t,onToggle:s}){return e.jsx("button",{type:"button",onClick:s,className:"mt-3 inline-flex items-center gap-2 rounded border border-[var(--accent-active)] px-3 py-1.5 text-xs font-medium uppercase tracking-wide text-[var(--accent-active)] hover:bg-[var(--accent-active)] hover:text-black transition-colors cursor-pointer","data-testid":"plan-next-change",children:t?"Close Planner":"Plan Next Change"})}const JO=Object.freeze(Object.defineProperty({__proto__:null,PlanNextChangeButton:Um},Symbol.toStringTag,{value:"Module"}));function Vm({onClose:t}){return e.jsx(Bs,{chatName:"plan",slashCommand:"/codeyam-plan",height:360,onClose:t})}const XO=Object.freeze(Object.defineProperty({__proto__:null,PlanAuthoringChat:Vm},Symbol.toStringTag,{value:"Module"}));function Ym({providerLabel:t,chatOpen:s,onChatToggle:n,onChatClose:r}){return e.jsxs("div",{"data-testid":"describe-pane",children:[e.jsx(Um,{open:s,onToggle:n}),!s&&e.jsx(Fo,{providerLabel:t,kind:"describe"}),s&&e.jsx(Vm,{onClose:r})]})}const QO=Object.freeze(Object.defineProperty({__proto__:null,DescribePane:Ym},Symbol.toStringTag,{value:"Module"}));function Km({claim:t}){const s=bs(),n=t.claimedBy.agentProvider??"agent",r=t.claimedBy.machine,a=t.claimedBy.currentStep??null,o=Mt(t.currentStepEnteredAt,s),i=Mt(t.claimedBy.startedAt,s),{dead:c}=yp(t);return e.jsxs("li",{className:"flex flex-col gap-1 rounded border border-[var(--border-subtle)] px-3 py-2","data-testid":`in-flight-row-${t.slug}`,"data-session-alive":c?"false":void 0,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-sm text-[var(--text-default)]",children:t.title}),e.jsx("span",{className:"text-[10px] uppercase tracking-wide text-[var(--text-dim)]","data-testid":`in-flight-source-${t.slug}`,children:t.source})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-[var(--text-muted)]",children:[e.jsxs("span",{"data-testid":`plan-claim-identity-${t.slug}`,children:["claimed by ",n,"@",r]}),a&&e.jsxs("span",{"data-testid":`plan-claim-step-${t.slug}`,children:["step ",a," · ",o," on step"]}),e.jsxs("span",{"data-testid":`plan-claim-started-${t.slug}`,children:["started ",i]}),c&&e.jsx("span",{className:"text-[var(--text-muted)]",children:"(inactive)"})]})]})}const ZO=Object.freeze(Object.defineProperty({__proto__:null,InFlightPlanRow:Km},Symbol.toStringTag,{value:"Module"}));function Jm({claims:t}){return t.length===0?null:e.jsxs("div",{className:"mt-6","data-testid":"in-flight-section",children:[e.jsxs("h3",{className:"text-xs font-medium uppercase tracking-wide text-[var(--text-dim)]",children:["In Flight (",t.length,")"]}),e.jsx("ul",{className:"mt-3 flex flex-col gap-2","data-testid":"in-flight-list",children:t.map(s=>e.jsx(Km,{claim:s},`${s.slug}:${s.claimedBy.machine}:${s.claimedBy.sessionId}:${s.claimedBy.pid}:${s.claimedBy.startedAt}`))})]})}const e6=Object.freeze(Object.defineProperty({__proto__:null,InFlightSection:Jm},Symbol.toStringTag,{value:"Module"})),Ck=5e3;function Tk(){const[t,s]=l.useState([]),[n,r]=l.useState(null),[a,o]=l.useState(null),[i,c]=l.useState(!0),[d,u]=l.useState(null),h=l.useRef(!1),p=l.useCallback(async()=>{c(!0),u(null);try{const b=await fetch("/api/branch-queue/status");if(!b.ok)throw new Error(`HTTP ${b.status}`);const g=await b.json();if(h.current)return;s(Array.isArray(g.entries)?g.entries:[]),r(g.branch??null),o(g.remote??null)}catch(b){if(h.current)return;u(b instanceof Error?b.message:"Failed to load branch queue"),s([])}finally{h.current||c(!1)}},[]);l.useEffect(()=>{h.current=!1,p();const b=setInterval(()=>{p()},Ck);return()=>{h.current=!0,clearInterval(b)}},[p]);const m=l.useCallback(async(b,g,v)=>{const x={uuid:b,priority:g};typeof v=="number"&&(x.expectedPriority=v);const y=await fetch("/api/branch-queue/set-priority",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(x)});if(!y.ok){const w=await y.text().catch(()=>"");throw new Error(`set-priority ${y.status}: ${w}`)}await p()},[p]),f=l.useCallback(async b=>{const g=await fetch("/api/branch-queue/release",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({uuid:b})});if(!g.ok){const v=await g.text().catch(()=>"");throw new Error(`release ${g.status}: ${v}`)}await p()},[p]);return{entries:t,branch:n,remote:a,loading:i,error:d,setPriority:m,release:f,refetch:p}}function Pk(){const[t,s]=l.useState(null),[n,r]=l.useState(null),a=l.useCallback(c=>{s(c)},[]),o=l.useCallback(c=>{r(c)},[]),i=l.useCallback(()=>{s(null),r(null)},[]);return{dragSourceUuid:t,dragOverUuid:n,beginDrag:a,hoverOver:o,reset:i}}function Ok(t,s){const n=new Map(s.map(i=>[i.uuid,i])),r=[],a=new Set;for(const i of t.order){const c=n.get(i.uuid);c&&(r.push(c),a.add(i.uuid))}for(const i of s)a.has(i.uuid)||(r.push(i),a.add(i.uuid));const o=new Set;for(const i of t.releasedUuids)n.has(i)&&o.add(i);return{order:r,releasedUuids:o}}const Ak=new Set;function Wr(t,s){return t??{order:[...s],releasedUuids:new Set}}function Rk(){const[t,s]=l.useState(null),n=l.useCallback(h=>t?t.order:h,[t]),r=l.useCallback((h,p,m)=>{s(f=>{const b=Wr(f,m),g=b.order.findIndex(x=>x.uuid===h),v=b.order.findIndex(x=>x.uuid===p);return g===-1||v===-1||g===v?b:{...b,order:$s(b.order,g,v)}})},[]),a=l.useCallback((h,p,m)=>{s(f=>{const b=Wr(f,m),g=b.order.findIndex(x=>x.uuid===h);if(g===-1)return b;const v=g-p;return v<0||v>=b.order.length?b:{...b,order:$s(b.order,g,v)}})},[]),o=l.useCallback((h,p)=>{s(m=>{const f=Wr(m,p),b=new Set(f.releasedUuids);return b.has(h)?b.delete(h):b.add(h),{...f,releasedUuids:b}})},[]),i=l.useCallback(h=>{s(p=>p?Ok(p,h):null)},[]),c=l.useCallback(()=>s(null),[]),d=l.useCallback(h=>t?t.releasedUuids.size>0||t.order.length!==h.length?!0:t.order.some((p,m)=>{var f;return p.uuid!==((f=h[m])==null?void 0:f.uuid)}):!1,[t]),u=l.useCallback(h=>{var g,v;if(!t)return 0;const p=t.releasedUuids,m=h.filter(x=>!p.has(x.uuid)),f=t.order.filter(x=>!p.has(x.uuid));let b=0;for(let x=0;x<f.length;x++)((g=f[x])==null?void 0:g.uuid)!==((v=m[x])==null?void 0:v.uuid)&&b++;return b},[t]);return{isActive:t!==null,displayEntries:n,releasedUuids:(t==null?void 0:t.releasedUuids)??Ak,isDirty:d,reorderedCount:u,releasedCount:(t==null?void 0:t.releasedUuids.size)??0,moveByDrag:r,nudge:a,toggleRelease:o,reconcile:i,reset:c}}const Ek=10;function Mk(t,s,n){const r=new Map(n.map(d=>[d.uuid,d])),a=n.filter(d=>s.has(d.uuid)).map(d=>d.uuid),o=t.filter(d=>!s.has(d.uuid)),i=o.length,c=[];return o.forEach((d,u)=>{const h=r.get(d.uuid);if(!h)return;const p=(i-u)*Ek;h.meta.priority!==p&&c.push({uuid:d.uuid,priority:p,expectedPriority:h.meta.priority})}),{releases:a,priorities:c}}function Xm({priority:t,uuid:s,onNudge:n}){const r=t===0?"priority 0":t>0?`priority +${t}`:`priority ${t}`;return e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] rounded border border-[var(--border-subtle)] px-2 py-1 text-[var(--text-muted)]","data-testid":`commit-queue-priority-chip-${s}`,children:[e.jsx("button",{type:"button",className:"text-[var(--text-dim)] hover:text-[var(--text-default)] px-0.5","data-testid":`commit-queue-nudge-down-${s}`,onClick:()=>void n(-1),"aria-label":"Lower priority",children:"−"}),e.jsx("span",{"data-testid":`commit-queue-priority-value-${s}`,children:r}),e.jsx("button",{type:"button",className:"text-[var(--text-dim)] hover:text-[var(--text-default)] px-0.5","data-testid":`commit-queue-nudge-up-${s}`,onClick:()=>void n(1),"aria-label":"Raise priority",children:"+"})]})}const t6=Object.freeze(Object.defineProperty({__proto__:null,CommitQueuePriorityChip:Xm},Symbol.toStringTag,{value:"Module"}));function Qm({uuid:t,markedForRelease:s,onToggle:n}){return s?e.jsx("button",{type:"button",className:"text-xs px-2 py-1 rounded border border-[var(--border-subtle)] text-[var(--text-dim)] hover:text-[var(--text-default)] cursor-pointer","data-testid":`commit-queue-undo-release-${t}`,onClick:n,title:"Keep this entry in the queue",children:"Undo remove"}):e.jsx("button",{type:"button",className:"opacity-0 group-hover:opacity-100 transition-opacity text-xs px-2 py-1 rounded border border-[var(--border-subtle)] text-[var(--text-dim)] hover:border-[var(--accent-danger)] hover:text-[var(--accent-danger)] cursor-pointer","data-testid":`commit-queue-release-${t}`,onClick:n,title:"Mark this entry for removal",children:"Force release"})}const s6=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueReleaseButton:Qm},Symbol.toStringTag,{value:"Module"}));function Zm({entry:t,isHead:s}){const n=bs(),r=t.meta.agentProvider??"agent",a=t.meta.machine,o=t.meta.currentStep??null,i=Mt(t.meta.startedAt??t.committerDate,n);return e.jsxs("div",{className:"flex-1 flex flex-col gap-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-medium text-[var(--text-default)] truncate",children:[r,"@",a]}),s&&e.jsx("span",{className:"text-[10px] uppercase tracking-wide text-[var(--accent-strong)]","data-testid":`commit-queue-head-marker-${t.uuid}`,children:"← head"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-[var(--text-muted)]",children:[o&&e.jsxs("span",{"data-testid":`commit-queue-step-${t.uuid}`,children:["step ",o]}),e.jsxs("span",{"data-testid":`commit-queue-started-${t.uuid}`,children:["started ",i]}),e.jsxs("span",{"data-testid":`commit-queue-pid-${t.uuid}`,children:["pid ",t.meta.pid]})]})]})}const n6=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueRowIdentity:Zm},Symbol.toStringTag,{value:"Module"}));function ef({entry:t,position:s,isHead:n,markedForRelease:r,onPriorityNudge:a,onToggleRelease:o,onDragStart:i,onDragOver:c,onDrop:d,isDragging:u,isDragOver:h}){return e.jsxs("li",{"data-testid":`commit-queue-row-${t.uuid}`,draggable:!0,onDragStart:p=>{p.dataTransfer.effectAllowed="move",p.dataTransfer.setData("text/plain",t.uuid),i()},onDragOver:p=>{p.preventDefault(),p.dataTransfer.dropEffect="move",c()},onDrop:p=>{p.preventDefault(),d()},"data-marked-for-release":r||void 0,className:`group flex items-center gap-3 rounded border px-3 py-2 ${n?"border-[var(--accent-strong)]":"border-[var(--border-subtle)]"} ${u?"opacity-40":""} ${h?"ring-2 ring-[var(--accent-strong)]":""} ${r?"opacity-50 line-through":""}`,children:[e.jsx("span",{"aria-hidden":!0,className:"cursor-grab select-none text-[var(--text-dim)] hover:text-[var(--text-default)]",title:"Drag to reorder","data-testid":`commit-queue-drag-${t.uuid}`,children:"⋮⋮"}),e.jsxs("span",{className:"text-xs font-mono text-[var(--text-dim)] w-6 text-right","data-testid":`commit-queue-position-${t.uuid}`,children:[s,"."]}),e.jsx(Zm,{entry:t,isHead:n}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Xm,{priority:t.meta.priority,uuid:t.uuid,onNudge:a}),e.jsx(Qm,{uuid:t.uuid,markedForRelease:r,onToggle:o})]})]})}const r6=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueRow:ef},Symbol.toStringTag,{value:"Module"}));function tf({reorderedCount:t,releasedCount:s,saving:n,onSave:r,onCancel:a}){const o=[];t>0&&o.push(`${t} reordered`),s>0&&o.push(`${s} to remove`);const i=o.join(" · ")||"Unsaved changes";return e.jsxs("div",{"data-testid":"commit-queue-save-bar",className:"mt-3 flex items-center justify-between gap-3 border-t border-[var(--accent-strong)] pt-3",children:[e.jsx("span",{className:"text-xs text-[var(--text-muted)]","data-testid":"commit-queue-save-summary",children:i}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button","data-testid":"commit-queue-cancel",onClick:a,disabled:n,className:"text-xs px-3 py-1 rounded border border-[var(--border-subtle)] text-[var(--text-dim)] hover:text-[var(--text-default)] disabled:opacity-50 cursor-pointer",children:"Cancel"}),e.jsx("button",{type:"button","data-testid":"commit-queue-save",onClick:r,disabled:n,className:"text-xs px-3 py-1 rounded bg-[var(--accent-strong)] font-medium text-white hover:opacity-90 disabled:opacity-50 cursor-pointer",children:n?"Saving…":"Save"})]})]})}const a6=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueSaveBar:tf},Symbol.toStringTag,{value:"Module"}));function sf({entriesOverride:t,branchOverride:s}={}){const n=Tk(),r=t!==void 0,a=t??n.entries,o=s??n.branch,i=Pk(),c=Rk(),{reconcile:d}=c,[u,h]=l.useState(null),[p,m]=l.useState(!1);if(l.useEffect(()=>{r||d(a)},[a,d,r]),!r&&n.loading&&a.length===0||a.length===0)return null;const f=c.displayEntries(a),b=c.isDirty(a),g=j=>{var N;const k=i.dragSourceUuid,S=(N=f[j])==null?void 0:N.uuid;i.reset(),!(k===null||!S||k===S)&&c.moveByDrag(k,S,a)},v=(j,k)=>{c.nudge(j.uuid,k,a)},x=j=>{c.toggleRelease(j.uuid,a)},y=()=>{h(null),c.reset()},w=async()=>{const{releases:j,priorities:k}=Mk(f,new Set(c.releasedUuids),a);h(null),m(!0);try{if(!r){for(const S of j)await n.release(S);for(const S of k)await n.setPriority(S.uuid,S.priority,S.expectedPriority);await n.refetch()}c.reset()}catch(S){h(S instanceof Error?S.message:"Failed to save changes")}finally{m(!1)}};return e.jsxs("div",{className:"mt-6","data-testid":"commit-queue-section",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsxs("h3",{className:"text-xs font-medium uppercase tracking-wide text-[var(--text-dim)]",children:["Commit Queue (",f.length,")"]}),o&&e.jsx("span",{className:"text-[11px] text-[var(--text-dim)]","data-testid":"commit-queue-branch",children:o})]}),u&&e.jsx("div",{className:"mt-2 text-xs text-[var(--accent-danger)]","data-testid":"commit-queue-error",children:u}),e.jsx("ol",{className:"mt-3 flex flex-col gap-2","data-testid":"commit-queue-list",children:f.map((j,k)=>e.jsx(ef,{entry:j,position:k+1,isHead:k===0,markedForRelease:c.releasedUuids.has(j.uuid),onPriorityNudge:S=>v(j,S),onToggleRelease:()=>x(j),onDragStart:()=>i.beginDrag(j.uuid),onDragOver:()=>i.hoverOver(j.uuid),onDrop:()=>g(k),isDragging:i.dragSourceUuid===j.uuid,isDragOver:i.dragOverUuid===j.uuid&&i.dragSourceUuid!==j.uuid},j.uuid))}),b&&e.jsx(tf,{reorderedCount:c.reorderedCount(a),releasedCount:c.releasedCount,saving:p,onSave:w,onCancel:y})]})}const o6=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueSection:sf},Symbol.toStringTag,{value:"Module"}));function Ik(t){const[s,n]=l.useState(null),[r,a]=l.useState(!0),[o,i]=l.useState(null);return l.useEffect(()=>{let c=!1;return(async()=>{a(!0),i(null);try{const d=new Date(new Date(t).getTime()-1).toISOString(),u=await fetch(`/api/journal?since=${encodeURIComponent(d)}`);if(!u.ok)throw new Error(`HTTP ${u.status}`);const p=((await u.json()).entries??[]).find(m=>m.timestamp===t)??null;c||n(p)}catch(d){c||(n(null),i(d instanceof Error?d.message:"Failed to load journal entry"))}finally{c||a(!1)}})(),()=>{c=!0}},[t]),{entry:s,loading:r,error:o}}function nf({journalTimestamp:t}){const{entry:s,loading:n,error:r}=Ik(t);return n?e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Loading journal entry…"}):r?e.jsxs("p",{className:"text-sm text-[var(--accent-red)]",children:["Failed to load journal entry: ",r]}):s?e.jsx(ir,{entry:s}):e.jsx("p",{className:"text-sm text-[var(--text-dim)]",children:"No journal entry found for this plan yet."})}const i6=Object.freeze(Object.defineProperty({__proto__:null,CompletedPlanExpandedBody:nf},Symbol.toStringTag,{value:"Module"}));function rf({plan:t,expanded:s,onToggle:n}){return e.jsxs("li",{className:"border border-[var(--border-subtle)] rounded-lg",children:[e.jsxs("button",{type:"button",onClick:n,className:"w-full text-left px-3 py-2 flex items-center justify-between gap-3 bg-transparent cursor-pointer","data-testid":"completed-plan-row",children:[e.jsx("span",{className:"flex-1 min-w-0 truncate text-sm text-[var(--text-primary)]",children:t.title}),e.jsx("span",{className:"text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded border border-[var(--border-subtle)] text-[var(--text-dim)]",children:t.mode}),e.jsx("span",{className:"text-[10px] text-[var(--text-dim)] whitespace-nowrap",children:Mt(t.completedAt)}),t.completedBy&&e.jsxs("span",{className:"text-[10px] text-[var(--text-dim)] whitespace-nowrap","data-testid":`completed-plan-by-${t.slug}`,children:["completed by ",t.completedBy.agentProvider??"agent","@",t.completedBy.machine]}),e.jsx("span",{className:"text-xs text-[var(--text-dim)] whitespace-nowrap","data-testid":"completed-plan-row-chevron",children:s?"▼":"▶"})]}),s&&e.jsx("div",{className:"px-3 py-2 border-t border-[var(--border-subtle)]","data-testid":"completed-plan-row-body",children:e.jsx(nf,{journalTimestamp:t.journalTimestamp})})]})}const l6=Object.freeze(Object.defineProperty({__proto__:null,CompletedPlanRow:rf},Symbol.toStringTag,{value:"Module"}));function af({plans:t,loading:s,error:n}){const[r,a]=l.useState(null),o=t.length;return e.jsxs("div",{className:"mt-6",children:[e.jsxs("h3",{className:"text-xs font-medium uppercase tracking-wide text-[var(--text-dim)]",children:["Completed Plans (",o,")"]}),e.jsx(of,{plans:t,loading:s,error:n,expandedSlug:r,onToggle:i=>a(c=>c===i?null:i)})]})}function of({plans:t,loading:s,error:n,expandedSlug:r,onToggle:a}){return s?e.jsx("p",{className:"mt-3 text-sm text-[var(--text-muted)]",children:"Loading completed plans…"}):n?e.jsxs("p",{className:"mt-3 text-sm text-[var(--accent-red)]",children:["Failed to load completed plans: ",n]}):t.length===0?e.jsx("p",{className:"mt-3 text-sm text-[var(--text-dim)]",children:"Plans you complete will appear here."}):e.jsx("ul",{className:"mt-3 flex flex-col gap-2","data-testid":"recent-plans-list",children:t.map(o=>e.jsx(rf,{plan:o,expanded:r===o.slug,onToggle:()=>a(o.slug)},o.slug))})}const c6=Object.freeze(Object.defineProperty({__proto__:null,RecentPlansBody:of,RecentPlansSection:af},Symbol.toStringTag,{value:"Module"}));function lf({chatOpen:t,onChatOpenChange:s,isActive:n=!0,isAgentBuilding:r=!1,launchingSlug:a,launchError:o,onLaunchPlan:i,initialSubTab:c="describe",prototypeLaunchSignal:d=0}={}){const{plans:u,loading:h,error:p,refetch:m}=Sm(),{claims:f}=dk(),{slugs:b}=Pm(),{status:g}=uk(),{staleness:v}=hk(),x=((g==null?void 0:g.consecutiveFailures)??0)>=3,{plans:y,loading:w,error:j}=Tm(),{config:k}=yt(),S=At(k==null?void 0:k.provider),N=i!==void 0,T=Rm(),A=N?a??null:T.launchingSlug,_=N?o??null:T.error,[M,I]=l.useState(!1),[H,z]=l.useState(!1),[G,R]=l.useState(null),[D,P]=l.useState(null),$=l.useMemo(()=>mk(f),[f]),F=l.useMemo(()=>fk(f,b),[f,b]),[U,J]=l.useState(c),Z=t!==void 0,te=Z?t:M,ie=q=>{Z||I(q),s==null||s(q)},V=()=>{ie(!1),m()},le=()=>{const q=!te;q&&lt(),ie(q)};l.useEffect(()=>{if(!(!n||!te))return lt()},[n,te]);const{annotationsBySlug:me,dependenciesBySlug:Q}=Am(u),C=q=>{var W;const ce=((W=u.find(oe=>oe.slug===q))==null?void 0:W.title)??q;if(i){i(q,ce);return}T.launchPlan(q,ce)},E=q=>{const ce=Om(Q[q]??[]);if(ce.length>0){R(ce);return}const W=$.get(q);if(W&&W.source!=="local"){P(W);return}C(q)},B=()=>{const q=D;if(q){if(P(null),q.sessionAlive===!1){fetch(`/api/plan-claims/${encodeURIComponent(q.slug)}/reclaim`,{method:"POST"}).catch(()=>{}).finally(()=>C(q.slug));return}C(q.slug)}},{reorderPlans:se}=Em(m);return e.jsxs(lr,{testId:"plan-tab",children:[e.jsx(Mm,{subTab:U}),e.jsx(Fm,{active:U,onChange:J}),U==="describe"&&e.jsx(Ym,{providerLabel:S,chatOpen:te,onChatToggle:le,onChatClose:V}),U==="prototype"&&e.jsx(Gm,{isAgentBuilding:r,onLaunched:()=>J("describe"),launchSignal:d}),e.jsx(Mo,{staleness:v}),e.jsx(Cm,{status:g}),e.jsx(pr,{plans:u,loading:h,error:p,onRun:E,launchingSlug:A,launchError:_,blocked:r,onBlockedClick:()=>z(!0),onReorder:se,depAnnotationsBySlug:me,dependenciesBySlug:Q,claimsBySlug:$,staleFetch:x}),e.jsx(Jm,{claims:F}),e.jsx(sf,{}),e.jsx(af,{plans:y,loading:w,error:j}),H&&e.jsx(Im,{onClose:()=>z(!1)}),G&&!H&&e.jsx(Lm,{deps:G,onClose:()=>R(null)}),D&&e.jsx(Dm,{claim:D,onCancel:()=>P(null),onConfirm:B})]})}const d6=Object.freeze(Object.defineProperty({__proto__:null,PlanTab:lf},Symbol.toStringTag,{value:"Module"}));function cf({activeTab:t,planActivated:s,chatOpen:n,onChatOpenChange:r,isAgentBuilding:a=!1,launchingPlanSlug:o,planLaunchError:i,onLaunchPlan:c,prototypeLaunchSignal:d=0}){return s?e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:t==="plan"?"visible":"hidden",pointerEvents:t==="plan"?"auto":"none"},children:e.jsx(lf,{chatOpen:n,onChatOpenChange:r,isActive:t==="plan",isAgentBuilding:a,launchingSlug:o,launchError:i,onLaunchPlan:c,prototypeLaunchSignal:d})}):null}const u6=Object.freeze(Object.defineProperty({__proto__:null,EditorShellPlanLayer:cf},Symbol.toStringTag,{value:"Module"})),Dk="desktop",Ji="codeyam:isDesktopApp";function Lk(t=typeof window<"u"?window:void 0){var o,i,c;if(!t)return!1;try{if(((o=t.sessionStorage)==null?void 0:o.getItem(Ji))==="1")return!0}catch{}const n=new URLSearchParams(((i=t.location)==null?void 0:i.search)??"").get(Dk)==="1",r=typeof t.__TAURI__<"u",a=n||r;if(a)try{(c=t.sessionStorage)==null||c.setItem(Ji,"1")}catch{}return a}function df({visible:t,children:s}){return e.jsx("div",{className:"absolute inset-0 flex flex-col overflow-auto",style:{visibility:t?"visible":"hidden"},children:s})}const h6=Object.freeze(Object.defineProperty({__proto__:null,TabPane:df},Symbol.toStringTag,{value:"Module"}));function uf({activeTab:t,children:s}){const n=["home","build","plan","history","settings"];return e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:n.map(r=>e.jsx(df,{visible:t===r,children:s[r]},r))})}const p6=Object.freeze(Object.defineProperty({__proto__:null,LeftPanel:uf},Symbol.toStringTag,{value:"Module"}));function hf({title:t}){return e.jsx("div",{className:"flex h-full items-center justify-center",style:{color:"var(--text-dim)"},children:e.jsxs("p",{className:"text-sm",children:[t," — coming soon"]})})}const m6=Object.freeze(Object.defineProperty({__proto__:null,PlaceholderPane:hf},Symbol.toStringTag,{value:"Module"}));function pf({activeTab:t,appTabContent:s,leftWidth:n,onPreviewScreenshot:r}){const a=t!=="build"&&t!=="plan",[o,i]=l.useState(!1);return l.useEffect(()=>{t==="history"&&i(!0)},[t]),e.jsx("div",{className:"absolute inset-0 flex flex-col",style:{visibility:a?"visible":"hidden",pointerEvents:a?"auto":"none"},children:e.jsx(uf,{activeTab:t,width:n,children:{home:s,build:null,plan:null,history:o?e.jsx(Wu,{onPreviewScreenshot:r}):null,settings:e.jsx(hf,{title:"Settings"})}})})}const f6=Object.freeze(Object.defineProperty({__proto__:null,EditorShellTabLayer:pf},Symbol.toStringTag,{value:"Module"}));function mf({plans:t,onPickPlan:s,launchingSlug:n,planError:r,onSubmitPrompt:a,submittingPrompt:o,promptError:i,onStartBlank:c,pendingPlansLoading:d,pendingPlansError:u,isAgentBuilding:h}){const[p,m]=l.useState(""),{annotationsBySlug:f,dependenciesBySlug:b}=Am(t),g=p.trim(),v=g.length>0,x=o||n!==null,y=()=>{x||(v?a(g):c())},w=j=>{(j.metaKey||j.ctrlKey)&&j.key==="Enter"&&(j.preventDefault(),y())};return e.jsx("div",{className:"absolute inset-0 z-[60] flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},"data-testid":"build-launch-modal",children:e.jsxs("div",{className:"max-w-lg w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"What do you want to build?"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:t.length>0?"Pick a queued plan to run, or describe a new build and kick it off directly.":"Describe what you want to build, or just start a session."}),t.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"max-h-48 overflow-y-auto mb-3","data-testid":"build-launch-modal-plan-list",children:e.jsx(pr,{plans:t,loading:d,error:u,onRun:j=>{var S;const k=((S=t.find(N=>N.slug===j))==null?void 0:S.title)??j;s(j,k)},launchingSlug:n,launchError:r,blocked:h,depAnnotationsBySlug:f,dependenciesBySlug:b})}),e.jsxs("div",{className:"flex items-center gap-3 my-4 text-xs text-[var(--text-dim)]","aria-hidden":"true",children:[e.jsx("span",{className:"flex-1 h-px bg-[var(--border-subtle)]"}),e.jsx("span",{children:"or"}),e.jsx("span",{className:"flex-1 h-px bg-[var(--border-subtle)]"})]})]}),e.jsx("p",{className:"text-xs uppercase tracking-wide text-[var(--text-dim)] mb-2",children:"Describe what you want to build"}),e.jsx("textarea",{value:p,onChange:j=>m(j.target.value),onKeyDown:w,rows:4,disabled:o||n!==null,placeholder:"e.g. Add a dark-mode toggle to the settings page",className:"w-full px-3 py-2 rounded-md text-sm resize-y disabled:opacity-50 disabled:cursor-not-allowed",style:{background:"var(--bg-deep, #0e0e0e)",color:"var(--text-primary)",border:"1px solid var(--border-default)"},"data-testid":"build-launch-modal-textarea"}),i&&e.jsx("p",{className:"mt-2 text-xs",style:{color:"var(--text-danger, #ff6b6b)"},"data-testid":"build-launch-modal-prompt-error",children:i}),e.jsx("div",{className:"mt-4 flex items-center justify-end gap-2",children:e.jsx("button",{type:"button",onClick:y,disabled:x,className:"px-4 py-2 rounded-md text-sm font-medium transition cursor-pointer disabled:cursor-not-allowed disabled:opacity-50",style:{background:"var(--accent-active, #D7FF63)",color:"var(--text-on-accent, #fff)",border:"1px solid transparent"},"data-testid":"build-launch-modal-submit",children:o?"Starting…":v?"Start build":"Start Building"})}),e.jsx("p",{className:"mt-3 text-center text-xs text-[var(--text-dim)]",children:"Cmd/Ctrl+Enter submits"})]})})}const g6=Object.freeze(Object.defineProperty({__proto__:null,BuildLaunchModal:mf},Symbol.toStringTag,{value:"Module"}));function ff({onCreateNewPlan:t,onViewPlans:s}){return e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},"data-testid":"plan-complete-dialog",children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"Plan Saved!"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-6",children:"Your plan has been committed. Start another plan, or head back to see the list."}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("button",{onClick:t,className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition cursor-pointer",style:{background:"var(--accent-active)",color:"var(--bg-deep)"},type:"button",children:"Create New Plan"}),e.jsx("button",{onClick:s,className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition cursor-pointer",style:{background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)"},type:"button",children:"View Plans"})]})]})}const b6=Object.freeze(Object.defineProperty({__proto__:null,PlanCompleteDialog:ff},Symbol.toStringTag,{value:"Module"}));function gf({onCreateNewPlan:t,onViewPlans:s}){return e.jsx("div",{className:"absolute inset-0 z-[60] flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},children:e.jsx(ff,{onCreateNewPlan:t,onViewPlans:s})})}const x6=Object.freeze(Object.defineProperty({__proto__:null,PlanCompleteTransition:gf},Symbol.toStringTag,{value:"Module"}));function Fk(t){return!t||!(t instanceof Element)?!1:!!t.closest("[data-terminal-emulator], .xterm")}function zk(t){return!t||!(t instanceof Element)?!1:!!t.closest("[data-post-push-modal]")}function bf({onStartNextFeature:t,onContinueInSession:s,onStopBuilding:n,onSendTranscript:r,onSelectPlan:a,pendingPlanCount:o=0}){const i=o>0&&a,c={background:"var(--accent-active)",color:"var(--bg-deep)"},d={background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)"},u={background:"transparent",color:"var(--accent-danger, #f87171)",border:"1px solid var(--accent-danger, #f87171)"};return e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"Feature Complete!"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-6",children:"Your changes have been committed and pushed. You can start a new feature with a fresh context, or continue working in the current session."}),e.jsxs("div",{className:"flex flex-col gap-3",children:[i&&e.jsx("button",{onClick:a,className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition cursor-pointer",style:c,type:"button",children:"Select A Plan"}),e.jsx("button",{onClick:t,className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition cursor-pointer",style:i?d:c,type:"button",children:"Start Next Feature"}),e.jsx("button",{onClick:s,className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition cursor-pointer",style:d,type:"button",children:"Continue in Current Session"}),e.jsx("button",{onClick:n,className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition cursor-pointer",style:u,type:"button","data-testid":"post-push-stop-building",children:"Stop Building"}),r&&e.jsx("button",{onClick:r,className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition cursor-pointer",style:{background:"transparent",color:"var(--text-dim)",border:"1px solid var(--border-default)"},type:"button",children:"Send Session Feedback"})]}),e.jsx("p",{className:"mt-4 text-center text-xs text-[var(--text-dim)]",children:i?"Press Enter to pick a queued plan":"Press Enter to start a new feature with a fresh context"})]})}const y6=Object.freeze(Object.defineProperty({__proto__:null,PostPushTransitionDialog:bf},Symbol.toStringTag,{value:"Module"}));function xf({onStartNextFeature:t,onContinueInSession:s,onStopBuilding:n,onSendTranscript:r,onSelectPlan:a,pendingPlanCount:o=0}){const i=l.useCallback(c=>{if(c.key!=="Enter"||Fk(c.target))return;const d=c.target===document.body||c.target===document.documentElement||c.target===document;!zk(c.target)&&!d||(c.preventDefault(),o>0&&a?a():t())},[a,t,o]);return l.useEffect(()=>(window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)),[i]),e.jsx("div",{className:"absolute inset-0 z-[60] flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},"data-post-push-modal":!0,children:e.jsx(bf,{onStartNextFeature:t,onContinueInSession:s,onStopBuilding:n,onSendTranscript:r,onSelectPlan:a,pendingPlanCount:o})})}const v6=Object.freeze(Object.defineProperty({__proto__:null,PostPushTransition:xf},Symbol.toStringTag,{value:"Module"}));function yf({plans:t,onSelect:s,onCancel:n,launchingSlug:r,error:a}){const[o,i]=l.useState(null),c=l.useMemo(()=>{const h={};for(const p of t)h[p.slug]=p;return h},[t]),d=l.useCallback(h=>{const p=c[h];p&&s(p.slug,p.title)},[s,c]),u=l.useCallback(h=>{if(h.key==="Escape"){h.preventDefault(),n();return}h.key==="Enter"&&t.length>0&&!r&&(h.preventDefault(),s(t[0].slug,t[0].title))},[r,n,s,t]);return l.useEffect(()=>(window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)),[u]),t.length===0?null:e.jsx("div",{className:"absolute inset-0 z-[60] flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},"data-testid":"select-plan-modal",children:e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"Select A Plan"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:"Pick a queued plan to run next. Its body primes the editor workflow in a fresh session."}),e.jsx("ul",{className:"flex flex-col gap-2 max-h-[50vh] overflow-y-auto mb-2",children:t.map((h,p)=>e.jsx(Po,{plan:h,position:p+1,expanded:o===h.slug,onToggle:()=>i(m=>m===h.slug?null:h.slug),onRun:d,launching:r===h.slug,expandedBodyVariant:"view"},h.slug))}),a&&e.jsx("p",{className:"text-xs mb-3",style:{color:"var(--text-danger, #ff6b6b)"},"data-testid":"select-plan-error",children:a}),e.jsx("button",{type:"button",onClick:n,className:"w-full px-4 py-2 rounded-md text-sm font-medium transition cursor-pointer",style:{background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)"},children:"Cancel"}),e.jsx("p",{className:"mt-3 text-center text-xs text-[var(--text-dim)]",children:"Press Enter to launch the first plan, Escape to cancel"})]})})}const j6=Object.freeze(Object.defineProperty({__proto__:null,SelectPlanModal:yf},Symbol.toStringTag,{value:"Module"}));function vf({activeTab:t,onSendTranscript:s,appTabContent:n,awaitingPlanLaunchChoice:r,buildActivated:a,planActivated:o,buildIdle:i=!1,isAgentBuilding:c=!1,planActive:d=!1,planIdle:u=!1,bannerVisible:h=!1,onDismissIdleBanner:p,hideResultsCommandKey:m,leftWidth:f,fullWidth:b=!1,navigateToTab:g,onAgentActive:v,onAgentIdle:x,onUserInput:y,notifSettings:w,onSettingsChange:j,provider:k,onContinueInSession:S,onRestorePreview:N,onResultsScenarioSelect:T,previewSlug:A=null,onSessionDetected:_,onStartNextFeature:M,onStopBuilding:I,showPostPushModal:H,completionModalPermitted:z=!0,showResultsCommandKey:G,planChatOpen:R,onPlanChatOpenChange:D,showPlanCompleteModal:P,onCreateNewPlan:$,onViewPlans:F,pendingPlans:U,onSelectPlan:J,selectPlanOpen:Z,onPickPlan:te,onCancelSelectPlan:ie,launchingPlanSlug:V,planLaunchError:le,prototypeLaunchSignal:me=0,showBuildLaunchModal:Q=!1,buildLaunchGateArmed:C=!1,onSubmitBuildPrompt:E,submittingBuildPrompt:B=!1,buildPromptError:se=null,onStartBlankBuild:q,pendingPlansLoading:ce,pendingPlansError:W,onReorderPlans:oe,buildDisabled:fe=!1,onPreviewScreenshot:xe,projectTitle:ne=null}){const je=Lk();return e.jsxs("div",{className:`${b?"flex-1 w-full min-w-0":"shrink-0"} flex flex-col overflow-hidden`,style:b?{background:"var(--bg-deep)"}:{width:f,background:"var(--bg-deep)"},children:[je&&e.jsx(sm,{projectTitle:ne}),e.jsx(tm,{activeTab:t,onTabChange:g,onSendTranscript:s,buildIdle:i,isAgentBuilding:c,planActive:d,planIdle:u,bannerVisible:h,onDismissIdleBanner:p,buildDisabled:fe,showLogo:!je}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:[e.jsx(jm,{awaitingPlanLaunchChoice:r,buildLaunchGateArmed:C,buildActivated:a,activeTab:t,onSessionDetected:_,onSelectScenario:T,previewSlug:A,showResultsCommandKey:G,hideResultsCommandKey:m,onAgentIdle:x,onAgentActive:v,onUserInput:y,notifSettings:w,onSettingsChange:j,provider:k,onRestorePreview:N,pendingPlans:U,pendingPlansLoading:ce,pendingPlansError:W,onLaunchPlan:te,launchingSlug:V,launchError:le,onReorderPlans:oe,isAgentBuilding:c,featureCompleteActive:H}),e.jsx(cf,{activeTab:t,planActivated:o,chatOpen:R,onChatOpenChange:D,isAgentBuilding:c,launchingPlanSlug:V,planLaunchError:le,onLaunchPlan:te,prototypeLaunchSignal:me}),e.jsx(pf,{activeTab:t,appTabContent:n,leftWidth:f,onPreviewScreenshot:xe}),H&&z&&t==="build"&&!Z?e.jsx(xf,{onStartNextFeature:M,onContinueInSession:S,onStopBuilding:I,onSendTranscript:s,onSelectPlan:J,pendingPlanCount:U.length}):null,Z&&t==="build"?e.jsx(yf,{plans:U,onSelect:te,onCancel:ie,launchingSlug:V,error:le}):null,Q&&t==="build"&&!H&&E&&q?e.jsx(mf,{plans:U,onPickPlan:te,launchingSlug:V,planError:le,onSubmitPrompt:E,submittingPrompt:B,promptError:se,onStartBlank:q,pendingPlansLoading:ce,pendingPlansError:W,isAgentBuilding:c}):null,P&&t==="plan"?e.jsx(gf,{onCreateNewPlan:$,onViewPlans:F}):null]})]})}const w6=Object.freeze(Object.defineProperty({__proto__:null,EditorShellLeftPane:vf},Symbol.toStringTag,{value:"Module"})),Xi=5173;function zo(t){if(t.startsWith("http"))try{return new URL(t).pathname}catch{return t}return t.split("?")[0]??t}function jf(t){return t?parseInt(t.port||(t.protocol==="https:"?"443":"80"),10):0}function wf(t,{appPort:s,currentPort:n,previewOrigin:r}){return t.startsWith("http")?t:r?`${r}${t}`:n===s?t:`http://localhost:${s}${t}`}function _f(t,s,n,r,a){if(n&&n.length>0)return wf(n,{appPort:r,currentPort:s,previewOrigin:a});const o=`/scenario/${t}`;return a?`${a}${o}`:s===Xi?o:`http://localhost:${Xi}${o}`}async function Qi(t,s=null){try{const n={pid:t};s&&(n.url=s),await fetch("/api/editor-iframe-loaded",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}catch{}}async function $k(t){try{await fetch("/api/editor-iframe-error",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({error:t})})}catch{}}async function Bk(t){try{await fetch("/api/editor-iframe-banner",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({seedError:t})})}catch{}}function Hk(t,s,n,r,a){const o=t-a*2,i=s-a*2;return o<=0||i<=0?1:Math.min(1,o/n,i/r)}const Wk=32;function qk({currentHeight:t,currentWidth:s,isFilled:n}){const[r,a]=l.useState(null),o=l.useRef(null),i=l.useRef(null),c=l.useCallback(h=>{const p=h.getBoundingClientRect();a({width:p.width,height:p.height})},[]),d=l.useCallback(h=>{if(o.current&&(o.current.disconnect(),o.current=null),i.current=h,!h){a(null);return}c(h);const p=new ResizeObserver(()=>{const m=i.current;m&&c(m)});p.observe(h),o.current=p},[c]),u=n||!r?1:Hk(r.width,r.height,s,t,Wk);return{containerRef:d,containerSize:r,scale:u}}const Gk={kind:"iframe",fallbackKind:null,fallbackPort:null,loading:!1},Zi=[400,800,1500,3e3];function kf(){const[t,s]=l.useState({kind:"iframe",fallbackKind:null,fallbackPort:null,loading:!0});return l.useEffect(()=>{let n=!1,r,a=0;const o=()=>{const d=Zi[Math.min(a,Zi.length-1)];a+=1,r=setTimeout(c,d)},i=()=>{s(d=>d.loading?Gk:d),o()},c=()=>{fetch("/api/project-stack").then(d=>d.ok?d.json():{}).then(d=>{n||(Uk(d)?s(Vk(d)):i())}).catch(()=>{n||i()})};return c(),()=>{n=!0,r&&clearTimeout(r)}},[]),t}function Uk(t){return!!t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length>0}function Vk(t){const s=t&&typeof t=="object"&&"preview"in t?t.preview:null;if(!s||typeof s!="object")return{kind:"iframe",fallbackKind:null,fallbackPort:null,loading:!1};const n=s;return{kind:Yk(n.kind),fallbackKind:Kk(n.fallbackKind),fallbackPort:typeof n.fallbackPort=="number"?n.fallbackPort:null,loading:!1}}function Yk(t){return t==="simulator-ios"?"simulator-ios":t==="simulator-android"?"simulator-android":"iframe"}function Kk(t){return t==="iframe"||t==="simulator-ios"||t==="simulator-android"?t:null}function Jk(t,s){const n=(t==null?void 0:t.screenshotPaths)??[];if(n.length===0)return null;if(s){const r=`--${s.toLowerCase()}.png`,a=n.find(o=>o.toLowerCase().endsWith(r));if(a)return a}return n[0]??null}function Xk(t,s,n){switch(t){case 1:case 2:return"Setting up...";case 3:return`Building — ${s} files modified, ${n} tests modified`;case 4:return"Verifying — running tests...";case 5:return"Ready for review";case 6:return"Refactoring...";case 7:case 8:return"Finalizing...";case 9:return"Ready for approval";case 10:return"Complete";default:return""}}async function va(){const t=Date.now();try{const s=await fetch("/api/editor-session-summary"),n=Date.now()-t;return s.ok?{ok:!0,data:await s.json(),statusCode:s.status,durationMs:n,error:null}:{ok:!1,data:null,statusCode:s.status,durationMs:n,error:`HTTP ${s.status}`}}catch(s){return{ok:!1,data:null,statusCode:null,durationMs:Date.now()-t,error:s instanceof Error?s.message:String(s)}}}const Qk=50,Zk={status:"loading",lastSuccessAt:null,lastErrorAt:null,lastErrorMessage:null,fetchCount:0,errorCount:0};function eS(t,s,n){return{status:s.ok?"connected":"disconnected",lastSuccessAt:s.ok?n:t.lastSuccessAt,lastErrorAt:s.ok?t.lastErrorAt:n,lastErrorMessage:s.ok?t.lastErrorMessage:s.error,fetchCount:t.fetchCount+1,errorCount:t.errorCount+(s.ok?0:1)}}function tS(t,s){return{timestamp:s,success:t.ok,statusCode:t.statusCode,durationMs:t.durationMs,error:t.error}}function sS(t,s){return[s,...t].slice(0,Qk)}function nS(){const[t,s]=l.useState(Zk),[n,r]=l.useState([]),a=l.useCallback(i=>{const c=Date.now();r(d=>sS(d,tS(i,c))),s(d=>eS(d,i,c))},[]),o=l.useCallback(()=>{s(i=>({...i,status:"polling"}))},[]);return{connectionState:t,fetchLog:n,recordFetch:a,markPolling:o}}async function rS(t){try{const r=await fetch("/api/test-results");if(r.ok&&(await r.json()).running)return{kind:"busy"}}catch{}const s={tests:[t.name]};t.file&&(s.changedFiles=[t.file]);let n;try{n=await fetch("/api/test-results/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})}catch(r){return{kind:"error",message:r instanceof Error?r.message:String(r)}}if(n.ok)return{kind:"accepted"};try{const r=await n.json();if(typeof r.message=="string"&&r.message.trim())return{kind:"error",message:r.message}}catch{}return{kind:"error",message:`Couldn't start the run (HTTP ${n.status}).`}}function aS(t,s){if(!t.narrative)return null;for(const n of t.narrative.changes)for(const r of n.tests)if(r.name===s)return{lastRunAt:r.lastRunAt,status:r.status??"unknown"};return null}async function oS(t,s,n){const r=n.intervalMs??2e3,a=n.nowMs??(()=>Date.now()),o=n.sleep??(c=>new Promise(d=>setTimeout(d,c))),i=a()+n.timeoutMs;for(;;){const c=await va();if(c.ok&&c.data){const d=aS(c.data,t.name);if(d!=null&&d.lastRunAt&&Date.parse(d.lastRunAt)>s)return{kind:"completed",status:d.status,summary:c.data}}if(a()>=i)return{kind:"timeout"};await o(r)}}function iS(t){return!t||t<=0?3e4:Math.max(3e4,t*2)}function lS({onSummaryUpdate:t,getLastDurationMs:s}){const[n,r]=l.useState(null),a=l.useCallback(o=>{const i=o.name;r({name:i,state:{phase:"verifying"}});const c=Date.now();(async()=>{const d=await rS(o);if(d.kind==="busy"){r({name:i,state:{phase:"busy"}});return}if(d.kind==="error"){r({name:i,state:{phase:"error",message:d.message}});return}const u=iS(s()),h=await oS(o,c,{timeoutMs:u});h.kind==="completed"?(t(h.summary),r(null)):r({name:i,state:{phase:"timeout"}})})()},[t,s]);return{active:n,onRerun:a}}function cS(t){switch(t.status){case"connected":return{dotClass:"bg-green-500",label:"Connected",labelClass:"text-green-400"};case"polling":return{dotClass:"bg-yellow-400 animate-pulse",label:"Polling...",labelClass:"text-yellow-400"};case"disconnected":return{dotClass:"bg-red-500",label:"Disconnected",labelClass:"text-red-400"};case"loading":default:return{dotClass:"bg-[var(--text-muted)]",label:"Connecting...",labelClass:"text-[var(--text-muted)]"}}}function Sf({state:t}){const s=bs(),{dotClass:n,label:r,labelClass:a}=cS(t);return e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[11px] font-medium","data-testid":"connection-status-badge",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${n}`,"data-testid":"connection-status-dot"}),e.jsx("span",{className:a,"data-testid":"connection-status-label",children:r}),t.lastSuccessAt!=null&&e.jsxs("span",{className:"text-[var(--text-muted)]","data-testid":"connection-status-updated",children:["Updated ",Kr(t.lastSuccessAt,s)]})]})}const _6=Object.freeze(Object.defineProperty({__proto__:null,BackendConnectionStatusBadge:Sf},Symbol.toStringTag,{value:"Module"}));function Nf({feature:t,connectionState:s,statusChip:n,userPrompt:r}){return e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border-default)] rounded-lg p-5",children:[e.jsx("h1",{className:"text-lg font-semibold text-[var(--text-primary)] m-0",children:t||"Working Session Results"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[e.jsx(Sf,{state:s}),n&&e.jsx("span",{className:"ml-auto text-[11px] px-2 py-0.5 bg-[var(--bg-input)] border border-[var(--border-subtle)] text-[var(--text-secondary)] rounded-full","data-testid":"status-chip",children:n})]}),r&&e.jsxs("details",{className:"mt-3 pt-3 border-t border-[var(--border-subtle)] group","data-testid":"user-prompt-section",children:[e.jsxs("summary",{className:"text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wide cursor-pointer select-none list-none",children:[e.jsx("span",{className:"group-open:hidden",children:"Your request ▸"}),e.jsx("span",{className:"hidden group-open:inline",children:"Your request ▾"})]}),e.jsx("div",{className:"mt-2 bg-[var(--bg-input)] border border-[var(--border-subtle)] rounded-md p-3",children:e.jsx(Ya,{children:r})})]})]})}const k6=Object.freeze(Object.defineProperty({__proto__:null,BackendResultsHeader:Nf},Symbol.toStringTag,{value:"Module"}));function dS(t,s=[]){var o;const n=[],r=[];let a=0;for(const i of t.changes)for(const c of i.tests){if(c.verified===!1){a+=1;continue}const d=c.status??"unknown",u={headline:(o=c.description)!=null&&o.trim()?c.description:c.name,name:c.name,file:c.file,status:d,failureMessage:c.failureMessage,change:i.title,lastRunAt:c.lastRunAt,lastRunKind:c.lastRunKind,recentStatuses:c.recentStatuses,exercises:s.filter(h=>h.tests.includes(c.name)),example:c.example};d==="passing"?n.push(u):r.push(u)}return{worksNow:n,inProgress:r,unverifiedCount:a}}function uS(t){if(!t||t.length<2)return!1;const s=t.some(r=>r.status==="pass"),n=t.some(r=>r.status==="fail");return s&&n}function hS(t){if(t==null||t===0)return"";const s=Math.abs(t),n=t>0?"slower":"faster";return`${s}s ${n} than the previous run`}function Cf({status:t}){switch(t){case"passing":return e.jsx("span",{className:"text-green-500 text-xs mt-0.5 shrink-0",children:"✓"});case"failing":return e.jsx("span",{className:"text-red-500 text-xs mt-0.5 shrink-0",children:"✗"});case"running":return e.jsx("span",{className:"text-[#D7FF63] text-xs mt-0.5 shrink-0 animate-spin",children:"◠"});default:return e.jsx("span",{className:"text-gray-400 text-xs mt-0.5 shrink-0",children:"●"})}}const S6=Object.freeze(Object.defineProperty({__proto__:null,NarrativeTestStatusIcon:Cf},Symbol.toStringTag,{value:"Module"})),el="font-mono text-[11px] text-[var(--text-primary)] whitespace-pre-wrap break-words min-w-0",tl="w-0 text-[10px] font-semibold uppercase tracking-wide text-[var(--text-muted)] align-top pr-3 py-1 whitespace-nowrap";function Tf({example:t}){return e.jsxs("div",{"data-testid":"behavior-example",children:[e.jsx("table",{className:"w-full border-collapse",children:e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsx("td",{className:tl,children:"Input"}),e.jsx("td",{className:`${el} py-1`,"data-testid":"example-input",children:t.input})]}),e.jsxs("tr",{children:[e.jsx("td",{className:tl,children:"Output"}),e.jsx("td",{className:`${el} py-1`,"data-testid":"example-output",children:t.output})]})]})}),t.note&&e.jsx("p",{className:"text-[10px] text-[var(--text-muted)] mt-1 mb-0 italic","data-testid":"example-note",children:t.note})]})}const N6=Object.freeze(Object.defineProperty({__proto__:null,BehaviorExampleTable:Tf},Symbol.toStringTag,{value:"Module"})),pS="text-[10px] font-semibold uppercase tracking-wide text-[var(--text-muted)] mb-1";function mS(t){switch(t.phase){case"busy":return"Tests are already running — try again once they finish.";case"error":return t.message;case"timeout":return"Couldn't confirm — check test results.";default:return null}}function Pf({rerun:t={phase:"idle"},onRerun:s,disabled:n=!1,disabledReason:r}){const a=t.phase==="verifying",o=mS(t),i=t.phase==="error",c=n||a;return e.jsxs("div",{"data-testid":"evidence-rerun",children:[e.jsx("div",{className:pS,children:"Re-run"}),e.jsxs("button",{type:"button",onClick:s,disabled:c,title:n?r:void 0,"aria-busy":a,"data-testid":"rerun-button",className:"inline-flex items-center gap-1.5 text-[11px] px-2 py-1 rounded border border-[var(--border-default)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:border-[var(--text-muted)] disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer",children:[a&&e.jsx("span",{className:"inline-block w-3 h-3 border-2 border-[var(--border-default)] border-t-[#005c75] rounded-full animate-spin"}),a?"Verifying…":"Re-run this test"]}),o&&e.jsx("p",{className:`text-[11px] mt-1 m-0 ${i?"text-red-600":"text-[var(--text-muted)]"}`,"data-testid":"rerun-note",children:o})]})}const C6=Object.freeze(Object.defineProperty({__proto__:null,RerunSection:Pf},Symbol.toStringTag,{value:"Module"}));function fS(t){return t==="passing"?"passed":t==="failing"?"failed":"ran"}function gS(t){switch(t){case"full":return"full run";case"changed":return"changed-files run";case"targeted":return"targeted run"}}function Of(t){var r;const s=t.status==="failing"&&!!t.failureMessage,n=(((r=t.recentStatuses)==null?void 0:r.length)??0)>0;return!!t.lastRunAt||t.exercises.length>0||s||!!t.example||n}const ws="text-[10px] font-semibold uppercase tracking-wide text-[var(--text-muted)] mb-1";function Af({behavior:t,rerun:s={phase:"idle"},onRerun:n,disabled:r=!1,disabledReason:a}){const o=bs(),i=t.status==="failing"&&!!t.failureMessage;return e.jsxs("div",{className:"mt-2 ml-5 space-y-3","data-testid":"behavior-evidence-drawer",children:[t.lastRunAt&&e.jsxs("div",{"data-testid":"evidence-verified",children:[e.jsx("div",{className:ws,children:"Verified"}),e.jsxs("p",{className:"text-[11px] text-[var(--text-secondary)] m-0",children:[fS(t.status)," ",Kr(Date.parse(t.lastRunAt),o),t.lastRunKind&&e.jsxs("span",{className:"text-[var(--text-muted)]",children:[" (",gS(t.lastRunKind),")"]})]})]}),t.example&&e.jsxs("div",{"data-testid":"evidence-example",children:[e.jsx("div",{className:ws,children:"Example"}),e.jsx(Tf,{example:t.example})]}),t.recentStatuses&&t.recentStatuses.length>0&&e.jsxs("div",{"data-testid":"evidence-recent-runs",children:[e.jsx("div",{className:ws,children:"Recent runs"}),e.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:[...t.recentStatuses].reverse().map((c,d)=>e.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${c.status==="pass"?"bg-green-500":c.status==="fail"?"bg-red-500":"bg-[var(--text-dim)]"}`,title:`${c.status} · ${Kr(Date.parse(c.at),o)}`,"data-testid":`recent-run-dot-${c.status}`},`${c.at}-${d}`))})]}),t.exercises.length>0&&e.jsxs("div",{"data-testid":"evidence-exercises",children:[e.jsx("div",{className:ws,children:"Exercises"}),e.jsx("ul",{className:"list-none p-0 m-0 space-y-1",children:t.exercises.map(c=>e.jsxs("li",{className:"text-[11px] text-[var(--text-secondary)] flex items-center gap-x-1.5",children:[e.jsx("span",{className:"font-mono text-[var(--text-primary)]",children:c.name}),e.jsx("span",{className:"text-[var(--text-dim)]",children:"·"}),e.jsx("span",{className:"font-mono text-[var(--text-dim)] min-w-0 truncate",children:c.filePath}),c.coverage&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[var(--text-dim)]",children:"·"}),e.jsxs("span",{className:"text-[var(--text-muted)]",children:[Math.round(c.coverage.percent),"% covered"]})]})]},c.name))})]}),i&&e.jsxs("div",{"data-testid":"evidence-failure",children:[e.jsx("div",{className:ws,children:"Failure"}),e.jsx("div",{className:"p-2 bg-red-50 border border-red-200 rounded text-[11px] font-mono text-red-700 whitespace-pre-wrap overflow-x-auto","data-testid":"failure-message",children:t.failureMessage})]}),e.jsx(Pf,{rerun:s,onRerun:n,disabled:r,disabledReason:a})]})}const T6=Object.freeze(Object.defineProperty({__proto__:null,BehaviorEvidenceDrawer:Af,hasDrawerContent:Of},Symbol.toStringTag,{value:"Module"}));function Rf({behavior:t,rerun:s}){var h,p;const[n,r]=l.useState(!1),a=Of(t),o=uS(t.recentStatuses),i=((h=s==null?void 0:s.active)==null?void 0:h.name)===t.name,c=i?s.active.state:{phase:"idle"},d=c.phase==="verifying",u=((p=s==null?void 0:s.active)==null?void 0:p.state.phase)==="verifying"&&!i;return e.jsx("div",{"data-testid":"behavior-item",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Cf,{status:d?"running":t.status}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start gap-1.5",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-sm text-[var(--text-primary)] leading-relaxed",children:[t.headline,o&&e.jsx("span",{className:"ml-1.5 align-middle inline-block px-1.5 py-0.5 rounded text-[10px] font-medium text-[var(--text-muted)] bg-[var(--bg-surface)] border border-[var(--border-default)]",title:"Recent runs mix passes and failures — this behavior is intermittently failing","data-testid":"flaky-chip",children:"flaky?"})]}),e.jsxs("div",{className:"flex items-center gap-x-1.5 mt-1 text-[11px]",children:[e.jsx("span",{className:"text-[var(--text-muted)] font-mono min-w-0 truncate",children:t.name}),t.file&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[var(--text-dim)] shrink-0",children:"·"}),e.jsx("span",{className:"text-[var(--text-dim)] font-mono min-w-0 truncate",children:t.file})]}),t.change&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[var(--text-dim)] shrink-0",children:"·"}),e.jsx("span",{className:"text-[var(--text-muted)] opacity-70 shrink-0",children:t.change})]})]})]}),a&&e.jsx("button",{className:"shrink-0 text-[var(--text-muted)] hover:text-[var(--text-primary)] cursor-pointer text-[10px] leading-none mt-1 px-1",onClick:()=>r(!n),"aria-expanded":n,"aria-label":n?"Hide evidence":"Show evidence","data-testid":"toggle-evidence-drawer",children:n?"▾":"▸"})]}),a&&n&&e.jsx(Af,{behavior:t,rerun:c,onRerun:s?()=>s.onRerun(t):void 0,disabled:u,disabledReason:"Verifying another behavior…"})]})]})})}const P6=Object.freeze(Object.defineProperty({__proto__:null,BehaviorItem:Rf},Symbol.toStringTag,{value:"Module"}));function ja({label:t,behaviors:s,tone:n,rerun:r}){if(s.length===0)return null;const a=n==="positive"?"text-green-500":"text-[var(--text-secondary)]";return e.jsxs("section",{className:"space-y-3","data-testid":"behavior-group",children:[e.jsxs("h2",{className:`text-xs font-semibold uppercase tracking-wide m-0 ${a}`,"data-testid":"behavior-group-heading",children:[t," (",s.length,")"]}),e.jsx("div",{className:"space-y-4",children:s.map(o=>e.jsx(Rf,{behavior:o,rerun:r},`${o.change}:${o.name}`))})]})}const O6=Object.freeze(Object.defineProperty({__proto__:null,BehaviorGroup:ja},Symbol.toStringTag,{value:"Module"}));function Ef({narrative:t,functions:s=[],rerun:n}){const{worksNow:r,inProgress:a,unverifiedCount:o}=dS(t,s);return e.jsxs("div",{className:"space-y-6","data-testid":"behavior-gallery",children:[t.summary&&e.jsx("p",{className:"text-sm text-[var(--text-primary)] leading-relaxed m-0",children:t.summary}),e.jsxs("div",{className:`space-y-6${t.summary?" pt-4 border-t border-[var(--border-subtle)]":""}`,children:[e.jsx(ja,{label:"Works now",behaviors:r,tone:"positive",rerun:n}),e.jsx(ja,{label:"In progress",behaviors:a,tone:"pending",rerun:n}),o>0&&e.jsxs("p",{className:"text-[11px] text-[var(--text-muted)] m-0","data-testid":"unverified-footnote",children:[o," test",o===1?"":"s"," not yet found in source."]})]})]})}const A6=Object.freeze(Object.defineProperty({__proto__:null,BehaviorGallery:Ef},Symbol.toStringTag,{value:"Module"}));function Mf({step:t}){const s=t>=3;return e.jsx("div",{className:"text-sm text-[var(--text-muted)]","data-testid":"behavior-gallery-empty",children:s?e.jsx("span",{"data-testid":"behavior-gallery-building",children:"Building…"}):e.jsx("span",{"data-testid":"behavior-gallery-prebuild",children:"The build will describe what it’s creating here as it works."})})}const R6=Object.freeze(Object.defineProperty({__proto__:null,BehaviorGalleryEmptyState:Mf},Symbol.toStringTag,{value:"Module"}));function bS(t){return t.filter(Boolean).join(" · ")}function xS(t){if(!t)return"";const s=Math.round(t.global.percent);if(t.previousGlobal==null)return`coverage ${s}%`;const n=Math.round(t.global.percent-t.previousGlobal);if(n===0)return`coverage ${s}% (±0)`;const r=n>0?"+":"−";return`coverage ${s}% (${r}${Math.abs(n)})`}function If({stats:t,thresholds:s,trendDeltaSecs:n}){if(!t)return null;const r=t.runners.length||t.per_runner.length,a=t.per_runner.filter(i=>i.duration_ms!=null).map(i=>`${i.name} ${Math.round(i.duration_ms/1e3)}s`),o=bS([`${r} runner${r===1?"":"s"}`,`${t.passed} passed`,t.failed>0?`${t.failed} failed`:"",...a,xS(s),hS(n)]);return e.jsx("p",{className:"text-[11px] text-[var(--text-muted)] font-mono m-0","data-testid":"run-evidence-line",children:o})}const E6=Object.freeze(Object.defineProperty({__proto__:null,RunEvidenceLine:If},Symbol.toStringTag,{value:"Module"})),yS=new Set([3,4,6]),vS=5e3;function Df(){const[t,s]=l.useState(null),[n,r]=l.useState(!0),{connectionState:a,recordFetch:o,markPolling:i}=nS(),c=l.useRef(null),d=l.useRef(null);d.current=t;const u=lS({onSummaryUpdate:s,getLastDurationMs:l.useCallback(()=>{var f,b;return(b=(f=d.current)==null?void 0:f.testRunnerStats)==null?void 0:b.duration_ms},[])});if(l.useEffect(()=>{async function f(){const b=await va();o(b),b.ok&&b.data&&s(b.data),r(!1)}return f(),()=>{c.current&&clearInterval(c.current)}},[o]),l.useEffect(()=>(c.current&&(clearInterval(c.current),c.current=null),t!=null&&t.step&&yS.has(t.step)&&(c.current=setInterval(async()=>{i();const f=await va();o(f),f.ok&&f.data&&s(f.data)},vS)),()=>{c.current&&clearInterval(c.current)}),[t==null?void 0:t.step,o,i]),n)return e.jsx("div",{className:"min-h-screen bg-[var(--bg-deep)] flex items-center justify-center",children:e.jsx("div",{className:"animate-spin w-6 h-6 border-2 border-[var(--border-default)] border-t-[#005c75] rounded-full"})});if(!t)return e.jsx("div",{className:"min-h-screen bg-[var(--bg-deep)] flex items-center justify-center text-[var(--text-muted)] text-sm",children:"No session data available."});const h=t.step??0,p=t.functions.reduce((f,b)=>f+b.tests.length,0),m=Xk(h,t.modifiedFiles.length,p);return e.jsx("div",{className:"min-h-screen bg-[var(--bg-deep)] p-6",children:e.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[e.jsx(Nf,{feature:t.feature,connectionState:a,statusChip:m,userPrompt:t.userPrompt}),e.jsx(If,{stats:t.testRunnerStats,thresholds:t.coverageThresholds,trendDeltaSecs:t.suiteTrendDeltaSecs}),e.jsx("div",{className:"bg-[var(--bg-card)] border border-[var(--border-default)] rounded-lg p-5",children:t.narrative?e.jsx(Ef,{narrative:t.narrative,functions:t.functions,rerun:u}):e.jsx(Mf,{step:h})})]})})}const M6=Object.freeze(Object.defineProperty({__proto__:null,BackendResultsPage:Df},Symbol.toStringTag,{value:"Module"}));function Lf(){return e.jsx("div",{className:"flex-1 flex flex-col min-w-0 overflow-auto",style:{background:"var(--bg-deep)"},children:e.jsx(Df,{})})}const I6=Object.freeze(Object.defineProperty({__proto__:null,BackendResultsPanelView:Lf},Symbol.toStringTag,{value:"Module"}));function Ff({onClose:t}){const[s,n]=l.useState(""),r=l.useRef(null);return l.useEffect(()=>{var a;(a=r.current)==null||a.focus()},[]),l.useEffect(()=>{const a=o=>{o.key==="Escape"&&t()};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[t]),e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onMouseDown:a=>{a.target===a.currentTarget&&t()},children:e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-1",children:"Create New State"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:"Describe the state you want Claude to build."}),e.jsx("textarea",{ref:r,value:s,onChange:a=>n(a.target.value),placeholder:"e.g. Empty inbox with a friendly empty-state illustration",rows:5,className:"w-full px-3 py-2 text-sm rounded mb-4 resize-none focus:outline-none",style:{background:"var(--bg-input)",border:"1px solid var(--border-default)",color:"var(--text-primary)"}}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 rounded-md text-sm transition cursor-pointer",style:{background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)"},children:"Cancel"}),e.jsx("button",{type:"button",disabled:!0,title:"Coming soon",className:"px-4 py-2 rounded-md text-sm font-medium opacity-50 cursor-not-allowed",style:{background:"var(--accent-active)",color:"var(--bg-deep)"},children:"Send to Claude"})]})]})})}const D6=Object.freeze(Object.defineProperty({__proto__:null,CreateStatePlaceholderModal:Ff},Symbol.toStringTag,{value:"Module"}));function zf(){const[t,s]=l.useState(null),n=l.useRef(!0),r=l.useCallback(async()=>{try{const a=await fetch("/api/editor-design-assets");if(!a.ok)return;const o=await a.json();n.current&&s(Array.isArray(o.assets)?o.assets:[])}catch{}},[]);return l.useEffect(()=>(n.current=!0,r(),()=>{n.current=!1}),[r]),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",style:{padding:"var(--spacing-lg, 16px)",gap:"var(--spacing-md, 12px)",overflow:"auto"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"var(--text-md, 15px)",fontWeight:600,color:"var(--text-primary)",marginBottom:"var(--spacing-xs, 4px)"},children:"Add design assets"}),e.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-secondary)",lineHeight:1.5},children:"Drag design assets onto codeyam-editor, or browse to add them — logos, screenshots, brand guides, inspiration. The agent reads whatever you add and folds it into the mockups."})]}),e.jsx(go,{onAssetsSaved:r}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-sm, 8px)"},children:[e.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",fontWeight:600,color:"var(--text-primary)"},children:"Added assets"}),t===null?e.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-secondary)"},children:"Loading…"}):t.length===0?e.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-secondary)"},children:"No assets added yet."}):t.map(a=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-xs, 4px)",padding:"var(--spacing-sm, 8px)",border:"1px solid var(--border-default)",borderRadius:8,background:"var(--bg-input)"},children:[e.jsx("span",{style:{fontSize:"var(--text-sm, 14px)",fontWeight:500,color:"var(--text-primary)"},children:a.filename}),a.description.trim().length>0&&e.jsx("span",{style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:a.description})]},a.filename))]})]})}const L6=Object.freeze(Object.defineProperty({__proto__:null,DesignAssetsView:zf},Symbol.toStringTag,{value:"Module"}));function jS(t,s){var c;const n=[],r=Object.entries(s.vars).filter(([,d])=>d&&d.trim());if(r.length>0){const d=r.map(([u,h])=>` ${u}: ${h};`).join(`
19
+ `);n.push(`:root {
20
+ ${d}
21
+ }`)}if(s.primaryFont){const d=sl(s.primaryFont,s.primaryFontStack);n.push(`body, p, li, span, button, input, textarea, select, label { font-family: ${d} !important; }`)}if(s.secondaryFont){const d=sl(s.secondaryFont,s.secondaryFontStack);n.push(`h1, h2, h3, h4, h5, h6, .heading, [class*="title"], [class*="headline"] { font-family: ${d} !important; }`)}const a=n.length>0?`<style data-codeyam-overrides="1">
22
+ ${n.join(`
23
+
24
+ `)}
25
+ </style>`:"",o=s.fontsHref?`<link rel="preconnect" href="https://fonts.googleapis.com">
26
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
27
+ <link rel="stylesheet" href="${s.fontsHref}" data-codeyam-fonts="1">`:"";if(!a&&!o)return t;const i=t.search(/<\/head\s*>/i);if(i===-1){const d=t.search(/<body[^>]*>/i);if(d===-1)return`${o}
28
+ ${a}
29
+ ${t}`;const u=d+(((c=t.match(/<body[^>]*>/i))==null?void 0:c[0].length)??0);return`${t.slice(0,u)}
30
+ ${o}
31
+ ${a}
32
+ ${t.slice(u)}`}return`${t.slice(0,i)}
33
+ ${o}
34
+ ${a}
35
+ ${t.slice(i)}`}function sl(t,s){const n=/\s/.test(t)?`"${t}"`:t,r=(s==null?void 0:s.trim())||"system-ui, sans-serif";return`${n}, ${r}`}const wS={vars:{},primaryFont:null,secondaryFont:null,primaryFontStack:null,secondaryFontStack:null};function fr(t){return t.replace(/^\d{1,2}-/,"").replace(/-mockup\.html$/i,"").replace(/\.html$/i,"")}function _S(t,s){if(t===null||t.length!==s.length)return!1;for(let n=0;n<t.length;n++)if(t[n].filename!==s[n].filename||t[n].url!==s[n].url||t[n].name!==s[n].name)return!1;return!0}const kS="\x1B[200~",SS="\x1B[201~";function NS(t,s=CS){const n=t.replace(/\r\n/g,"\r").replace(/\n/g,"\r"),r=`${kS}${n}${SS}`;return s(r),new Promise(a=>{setTimeout(()=>{s("\r"),a()},Wy)})}function CS(t){window.dispatchEvent(new CustomEvent("miniagent-send-input",{detail:t}))}function TS({feedbackByFilename:t,mockupFilenames:s}){const n={};for(const o of s){const i=t[o];if(!i)continue;const c=typeof i.rating=="number",d=i.comment.trim().length>0;!c&&!d||(n[o]={rating:c?i.rating:null,comment:i.comment.trim()})}return Object.keys(n).length===0?"Iterate: before regenerating anything, first ask the user in the chat which of these designs (if any) are close enough to keep and just tweak — and let them know that every other design will be discarded and redesigned fresh. Wait for their reply before writing any mockup. No per-card feedback was provided, so let their answer guide what to keep vs. redesign from scratch.":`Iterate: before regenerating anything, first ask the user in the chat which of these designs (if any) are close enough to keep and just tweak — and let them know that every other design will be discarded and redesigned fresh from the feedback below. Wait for their reply before writing any mockup.
36
+
37
+ Once they answer: for designs they choose to keep, refine them in place using their specific feedback, keeping the same numeric prefix and design system. For every other design, redesign it fresh from the feedback — each redesign must directly address the specific comment and rating for that card (a pointed comment is a concrete instruction the redesign must visibly resolve; a low rating means change direction further). For fresh redesigns, weigh the rating and comment to decide whether to keep the same design system with a new layout, or swap in a different system from .codeyam/design/design_systems/ — avoid duplicating a system already used by a kept card. When you change a slot's design system, delete the old NN-*.html file before writing the new NN-<newsystem>-mockup.html so each slot has exactly one file. Keep numeric filename prefixes stable so slots don't move.
38
+
39
+ Per-card feedback (rating is 1-100 or null; comment may be empty):
40
+
41
+ \`\`\`json
42
+ `+JSON.stringify(n,null,2)+"\n```"}const PS=9e4;function OS(t){return!!(t.agentRespondedAfterDispatch||AS(t.snapshotFilenames,t.latestFilenames))}function AS(t,s){if(t.length!==s.length)return!0;const n=[...t].sort(),r=[...s].sort();for(let a=0;a<n.length;a++)if(n[a]!==r[a])return!0;return!1}function RS(t){const s={},n={},r=t.split(`
43
+ `);let a=!1,o=[];for(const i of r){const c=i.trim();if(/^```/.test(c)){a=!a;continue}if(a)continue;const d=/^(#{1,6})\s+(.+)$/.exec(c);if(d){const b=d[1].length;o=o.slice(0,b-1),o[b-1]=d[2].trim();continue}if(!c.startsWith("|"))continue;const u=c.split("|").map(b=>b.trim());if(u.length<3)continue;const h=u[1].replace(/`/g,"").trim(),p=u[2].replace(/`/g,"").trim();if(!/^--[A-Za-z0-9_-]+$/.test(h)||!ES(p))continue;const m=o.filter(Boolean).join(" / "),f=$f(m)?n:s;h in f||(f[h]=p)}return{light:s,dark:n}}function $f(t){return/\bdark[\s-]?mode\b|\bdark\b\s*(palette|variant|theme)?/i.test(t)}function ES(t){return!!(/^#[0-9a-fA-F]{3,8}$/.test(t)||/^rgba?\(/i.test(t)||/^hsla?\(/i.test(t)||/^oklch\(/i.test(t))}const MS=["Background","Surface","Text","Primary","Secondary","Accent"],IS={Background:[/^--bg(-default|-page|-canvas|-base)?$/,/^--page(-bg)?$/,/^--canvas$/,/^--background$/,/^--light-linen$/,/^--paper$/,/^--body-bg$/,/-canvas$/,/-page-bg$/],Surface:[/^--bg-surface$/,/^--surface(-1|-elevated)?$/,/^--card(-bg)?$/,/^--bg-elevated$/,/^--marketplace-gray$/,/^--panel(-bg)?$/,/^--cream$/,/-surface$/,/-porcelain-surface$/],Text:[/^--text(-primary|-default)?$/,/^--fg(-default)?$/,/^--foreground$/,/^--ink$/,/^--pitch-black$/,/^--body-text$/,/^--ink-text$/,/-ink-text$/,/-graphite-text$/],Primary:[/^--primary$/,/^--accent(-primary)?$/,/^--brand(-primary)?$/,/^--creator-pink$/,/^--palette-1$/,/^--lime$/,/^--burgundy$/,/-amethyst-accent$/,/-accent$/],Secondary:[/^--secondary$/,/^--accent-secondary$/,/^--brand-secondary$/,/^--sunshine-yellow$/,/^--palette-2$/,/^--sage$/,/^--sky-blue$/,/-sky-blue-highlight$/,/-highlight$/],Accent:[/^--accent(-tertiary|-highlight)?$/,/^--highlight$/,/^--lime-glow$/,/^--lime-deep$/,/^--firecracker-orange$/,/^--sky-blue$/,/^--gold$/,/^--palette-3$/,/-detail$/]};function DS(t){const s=[],n=t.split(`
44
+ `);let r=!1,a="",o=0,i=null,c=[];for(let d=0;d<n.length;d++){const h=n[d].trim();if(!r){const p=/^(#{1,6})\s+(.+)$/.exec(h);if(p){const f=p[1].length;c=c.slice(0,f-1),c[f-1]=p[2].trim(),i=p[2].trim();continue}const m=/^```(\w*)/.exec(h);m&&(r=!0,a=m[1].toLowerCase(),o=d+1);continue}if(h==="```"){if(a==="css"||a===""){const p=n.slice(o,d).join(`
45
+ `);for(const m of FS(p)){const f=c.filter(Boolean).join(" / "),b=LS(m.selector)||$f(f);s.push({selector:m.selector,heading:i,isDark:b,vars:m.vars})}}r=!1,a=""}}return s}function LS(t){return/\[data-theme[~|*$^]?="?dark"?\]/.test(t)}function FS(t){const s=[],n=/(:root[^\{]*?)\{([\s\S]*?)\}/g;let r;for(;(r=n.exec(t))!==null;){const a=r[1].trim(),o=r[2],i={},c=/(--[A-Za-z0-9_-]+)\s*:\s*([^;\n]+?)\s*(?:;|$)/g;let d;for(;(d=c.exec(o))!==null;){const u=d[1],h=d[2].replace(/\/\*.*?\*\//g,"").trim();h&&(i[u]=h)}Object.keys(i).length>0&&s.push({selector:a,vars:i})}return s}function zS(t,s){const n=IS[s];for(const r of Object.keys(t))for(const a of n)if(a.test(r))return{cssVar:r,value:t[r]};return{cssVar:null,value:null}}function $S(t){const s=/\[data-palette[~|*$^]?="?([^"\]]+)"?\]/.exec(t);return s?s[1].split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" "):null}function BS(t){if(!t)return"Default";let s=t.replace(/\(.+?\)/g,"");return s=s.replace(/\bpalette\b/i,"").replace(/\bmode\b/i,""),/\bdark\b/i.test(s)?"Default":(s=s.replace(/\bdark\b/i,""),s=s.replace(/\blight\b/i,""),s=s.trim().replace(/\s+/g," "),s||"Default")}function nl(t){const s=MS.map(n=>{const{cssVar:r,value:a}=zS(t,n);return{label:n,cssVar:r,value:a}});return{vars:t,slots:s}}function $o(t){const s=DS(t),n=new Map,r=new Map,a=[];for(const o of s){const c=$S(o.selector)??BS(o.heading);a.includes(c)||a.push(c),o.isDark?r.has(c)||r.set(c,o.vars):n.has(c)||n.set(c,o.vars)}if(n.size===0){const o=RS(t);o.light&&Object.keys(o.light).length>0&&(a.unshift("Default"),n.set("Default",o.light),o.dark&&Object.keys(o.dark).length>0&&r.set("Default",o.dark))}return a.map(o=>{const i=n.get(o);if(!i)return null;const c=r.get(o)??null;return{name:o,light:nl(i),dark:c?nl(c):null}}).filter(o=>o!==null)}function HS(t){const s=Object.keys(t);if(s.length===0)return{};const n=Wf(t),r={};for(const a of s){const o=t[a];if(!o||!o.trim())continue;const i=n.get(a)??null;r[a]=GS(o,i)}return r}const Bf="#0f1115",WS="#181b21",Hf="#e8eaed";function qS(t){const s=Wf(t);let n=null,r=null;for(const[a,o]of s){const i=t[a];!i||!i.trim()||(o==="Background"&&n===null&&(n=i),o==="Text"&&r===null&&(r=i))}return{bg:n??Bf,text:r??Hf}}function Wf(t){var i;const n=["```css",":root {",Object.entries(t).map(([c,d])=>` ${c}: ${d};`).join(`
46
+ `),"}","```"].join(`
47
+ `),r=$o(n),a=new Map,o=((i=r[0])==null?void 0:i.light.slots)??[];for(const c of o)c.cssVar&&a.set(c.cssVar,c.label);return a}function GS(t,s){switch(s){case"Background":return Bf;case"Surface":return WS;case"Text":return Hf;case"Primary":case"Secondary":case"Accent":return rl(t);default:return rl(t)}}function rl(t){const s=US(t.trim());if(!s)return t;const{h:n,s:r,l:a}=VS(s.r,s.g,s.b),{r:o,g:i,b:c}=YS(n,r,1-a),d=u=>u.toString(16).padStart(2,"0");return s.a!=null&&s.a<1?`rgba(${o}, ${i}, ${c}, ${s.a})`:`#${d(o)}${d(i)}${d(c)}`}function US(t){const s=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t);if(s){let r=s[1];return r.length===3&&(r=r.split("").map(a=>a+a).join("")),{r:parseInt(r.slice(0,2),16),g:parseInt(r.slice(2,4),16),b:parseInt(r.slice(4,6),16)}}const n=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/i.exec(t);return n?{r:qr(parseInt(n[1],10)),g:qr(parseInt(n[2],10)),b:qr(parseInt(n[3],10)),a:n[4]!=null?parseFloat(n[4]):void 0}:null}function qr(t){return Math.max(0,Math.min(255,t))}function VS(t,s,n){const r=t/255,a=s/255,o=n/255,i=Math.max(r,a,o),c=Math.min(r,a,o),d=(i+c)/2;let u=0,h=0;if(i!==c){const p=i-c;switch(h=d>.5?p/(2-i-c):p/(i+c),i){case r:u=(a-o)/p+(a<o?6:0);break;case a:u=(o-r)/p+2;break;default:u=(r-a)/p+4;break}u/=6}return{h:u,s:h,l:d}}function YS(t,s,n){if(s===0){const i=Math.round(n*255);return{r:i,g:i,b:i}}const r=(i,c,d)=>{let u=d;return u<0&&(u+=1),u>1&&(u-=1),u<1/6?i+(c-i)*6*u:u<1/2?c:u<2/3?i+(c-i)*(2/3-u)*6:i},a=n<.5?n*(1+s):n+s-n*s,o=2*n-a;return{r:Math.round(r(o,a,t+1/3)*255),g:Math.round(r(o,a,t)*255),b:Math.round(r(o,a,t-1/3)*255)}}function KS(t){const[s,n]=l.useState({}),r=l.useRef(!0);return l.useEffect(()=>(r.current=!0,()=>{r.current=!1}),[]),l.useEffect(()=>{if(!t)return;const a=new Set,o=t.map(i=>fr(i.filename)).filter(i=>a.has(i)?!1:(a.add(i),!(i in s)));o.length!==0&&(async()=>{var i,c,d;for(const u of o)try{const h=await fetch(`/api/editor-design-systems/${u}`);if(!h.ok)continue;const p=await h.json().catch(()=>null);if(!(p!=null&&p.content)){r.current&&n(v=>({...v,[u]:null}));continue}const m=$o(p.content),f=((c=(i=m[0])==null?void 0:i.dark)==null?void 0:c.vars)??null,b=((d=m[0])==null?void 0:d.light.vars)??null,g=f&&Object.keys(f).length>0?f:b&&Object.keys(b).length>0?HS(b):null;r.current&&n(v=>({...v,[u]:g}))}catch{r.current&&n(h=>({...h,[u]:null}))}})()},[t,s]),s}function JS(){const[t,s]=l.useState([]);return l.useEffect(()=>{let n=!1;async function r(){try{const o=await fetch("/api/editor-mockups-history");if(!o.ok)return;const i=await o.json();n||s(Array.isArray(i)?i:[])}catch{}}r();const a=window.setInterval(r,4e3);return()=>{n=!0,window.clearInterval(a)}},[]),t}function qf({round:t,onRestore:s,restoring:n=!1}){if(!t||!t.mockups||t.mockups.length===0)return e.jsx($a,{});const r=t.feedback??{};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-md, 14px)"},children:[s&&e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{type:"button",onClick:s,disabled:n,style:{padding:"6px 14px",background:"transparent",color:"var(--accent-active, #D7FF63)",border:"1px solid var(--accent-active, #D7FF63)",borderRadius:6,fontSize:"var(--text-sm, 13px)",fontWeight:500,cursor:n?"default":"pointer",opacity:n?.6:1},children:n?"Bringing back…":"Bring back this round"})}),e.jsx("div",{"data-mockup-archived-round":!0,style:{display:"grid",gridTemplateColumns:"1fr 1fr",columnGap:"var(--spacing-lg, 16px)",rowGap:"var(--spacing-xl, 28px)"},children:t.mockups.map((a,o)=>{const i=r[a.filename],c=o+1,d=a.name.replace(/^\d{1,2}-/,"").replace(/-/g," ");return e.jsxs("div",{style:{display:"flex",flexDirection:"column",border:"1px solid var(--border-default)",borderRadius:12,overflow:"hidden",background:"var(--bg-surface)"},children:[e.jsxs("div",{style:{padding:"var(--spacing-sm, 10px) var(--spacing-md, 14px)",display:"flex",alignItems:"center",gap:6,color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)"},children:[e.jsx("span",{style:{fontWeight:700,color:"var(--text-muted)"},children:String(c).padStart(2,"0")}),e.jsx("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",style:{textTransform:"capitalize",fontWeight:500,color:"var(--text-primary)",textDecoration:"none"},children:d})]}),e.jsx("iframe",{src:a.url,title:a.name,sandbox:"",style:{width:"100%",aspectRatio:"1 / 1",border:"none",pointerEvents:"none",background:"var(--bg-card, #1a1a1a)"}}),i&&(typeof i.rating=="number"||i.comment.trim().length>0)&&e.jsxs("div",{style:{padding:"var(--spacing-sm, 10px) var(--spacing-md, 14px)",borderTop:"1px solid var(--border-default)",display:"flex",flexDirection:"column",gap:4,fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:[typeof i.rating=="number"&&e.jsxs("div",{children:[e.jsxs("span",{style:{color:"var(--text-muted)"},children:["Rating ·"," "]}),e.jsxs("span",{style:{color:"var(--text-primary)"},children:[i.rating,"/100"]})]}),i.comment.trim().length>0&&e.jsxs("div",{style:{lineHeight:1.4},children:[e.jsxs("span",{style:{color:"var(--text-muted)"},children:["Note ·"," "]}),e.jsx("span",{style:{color:"var(--text-primary)"},children:i.comment})]})]})]},a.filename)})})]})}const F6=Object.freeze(Object.defineProperty({__proto__:null,MockupArchivedRoundView:qf},Symbol.toStringTag,{value:"Module"})),Bo=[{family:"Archivo",category:"sans",weights:[400,500,600,700]},{family:"DM Sans",category:"sans",weights:[400,500,700]},{family:"Inter",category:"sans",weights:[400,500,600,700]},{family:"Karla",category:"sans",weights:[400,500,700]},{family:"Manrope",category:"sans",weights:[400,500,700]},{family:"Nunito",category:"sans",weights:[400,600,700]},{family:"Plus Jakarta Sans",category:"sans",weights:[400,500,700]},{family:"Public Sans",category:"sans",weights:[400,500,700]},{family:"Roboto",category:"sans",weights:[400,500,700]},{family:"Work Sans",category:"sans",weights:[400,500,700]},{family:"Cormorant Garamond",category:"serif",weights:[400,500,700]},{family:"Crimson Pro",category:"serif",weights:[400,600,700]},{family:"Fraunces",category:"serif",weights:[400,600,700]},{family:"Lora",category:"serif",weights:[400,500,700]},{family:"Merriweather",category:"serif",weights:[400,700]},{family:"Playfair Display",category:"serif",weights:[400,600,700]},{family:"Source Serif 4",category:"serif",weights:[400,600,700]},{family:"Abril Fatface",category:"display",weights:[400]},{family:"Bebas Neue",category:"display",weights:[400]},{family:"Bricolage Grotesque",category:"display",weights:[400,600,800]},{family:"Chakra Petch",category:"display",weights:[400,600,700]},{family:"Lexend",category:"display",weights:[400,500,700]},{family:"Outfit",category:"display",weights:[400,600,800]},{family:"Rubik",category:"display",weights:[400,500,700]},{family:"Space Grotesk",category:"display",weights:[400,500,700]},{family:"Syne",category:"display",weights:[400,600,800]},{family:"Unbounded",category:"display",weights:[400,600,800]},{family:"Fira Code",category:"mono",weights:[400,500,700]},{family:"IBM Plex Mono",category:"mono",weights:[400,500,600]},{family:"JetBrains Mono",category:"mono",weights:[400,500,700]},{family:"Space Mono",category:"mono",weights:[400,700]}],XS={sans:"Sans-serif",serif:"Serif",display:"Display",mono:"Monospace"};function Gf(t){const s=new Set,n=[];for(const r of t){if(!r||s.has(r))continue;s.add(r);const a=Bo.find(c=>c.family===r),o=(a==null?void 0:a.weights)??[400,700],i=r.replace(/ /g,"+");n.push(`family=${i}:wght@${o.join(";")}`)}return n.length===0?"":`https://fonts.googleapis.com/css2?${n.join("&")}&display=swap`}function QS(t,s,n){const r={},a=al(t,n),o=al(s,n),i=new Map;for(const c of a)c.cssVar&&i.set(c.label,c.cssVar);for(const c of o){if(!c.value)continue;const d=i.get(c.label)??c.cssVar;d&&(r[d]=c.value)}return r}function al(t,s){return t?s==="dark"&&t.dark?t.dark.slots:t.light.slots:[]}function ZS(t,s,n){var a,o;return s!=="dark"?n:{...((o=(a=t[0])==null?void 0:a.dark)==null?void 0:o.vars)??{},...n}}function eN(t,s){const[n,r]=l.useState({kind:"loading"});return l.useEffect(()=>{let a=!1;return r({kind:"loading"}),(async()=>{try{const[o,i]=await Promise.all([fetch(t),fetch(`/api/editor-design-systems/${s}`)]),c=await o.text();let d="";if(i.ok){const u=await i.json().catch(()=>null);d=(u==null?void 0:u.content)??""}if(a)return;r({kind:"ready",html:c,palettes:$o(d)})}catch(o){a||r({kind:"error",message:o instanceof Error?o.message:String(o)})}})(),()=>{a=!0}},[t,s]),n}function Uf(t,s,n){l.useEffect(()=>{if(!t)return;const r=o=>{var c;const i=o.target;(c=s.current)!=null&&c.contains(i)||n()},a=o=>{o.key==="Escape"&&n()};return document.addEventListener("mousedown",r),document.addEventListener("keydown",a),()=>{document.removeEventListener("mousedown",r),document.removeEventListener("keydown",a)}},[t,s,n])}function hn(t,s,n){return{name:t,light:ol(s),dark:n?ol(n):null}}function ol(t){const s=[{label:"Background",cssVar:"--bg-default",value:t.bg},{label:"Surface",cssVar:"--bg-surface",value:t.surface},{label:"Text",cssVar:"--text-primary",value:t.text},{label:"Primary",cssVar:"--accent-primary",value:t.primary},{label:"Secondary",cssVar:"--accent-secondary",value:t.secondary},{label:"Accent",cssVar:"--accent-highlight",value:t.accent}],n={};for(const r of s)r.cssVar&&r.value&&(n[r.cssVar]=r.value);return{vars:n,slots:s}}function tN(){return[hn("Lime Bright",{bg:"#F4F4EE",surface:"#FFFFFF",text:"#0F0F0F",primary:"#D7FF63",secondary:"#9DA48F",accent:"#FF6B5C"},{bg:"#14160F",surface:"#25251F",text:"#F1EFEA",primary:"#D7FF63",secondary:"#4D5247",accent:"#FF6B5C"}),hn("Warm Cream",{bg:"#EFE9DA",surface:"#F8F3E7",text:"#3B2F1C",primary:"#C44536",secondary:"#7A9E7E",accent:"#EAA64A"},{bg:"#1F1A11",surface:"#2A2418",text:"#EFE9DA",primary:"#E07767",secondary:"#A9CBA9",accent:"#EAA64A"}),hn("Cool Mono",{bg:"#F5F6F8",surface:"#FFFFFF",text:"#101218",primary:"#2B2D3A",secondary:"#8B8FA3",accent:"#5C8DFF"},{bg:"#0E1016",surface:"#181B23",text:"#E9EBF2",primary:"#E9EBF2",secondary:"#8B8FA3",accent:"#7CA0FF"}),hn("Bold Pop",{bg:"#FFF8F0",surface:"#FFFFFF",text:"#181818",primary:"#FF3D7F",secondary:"#3DD2FF",accent:"#FFD60A"},{bg:"#161113",surface:"#1F1A1D",text:"#FFF8F0",primary:"#FF3D7F",secondary:"#3DD2FF",accent:"#FFD60A"})]}function Vf({palettes:t,activeName:s,theme:n,onApply:r}){const a=(()=>{const o=new Set(t.map(c=>c.name.toLowerCase())),i=tN().filter(c=>!o.has(c.name.toLowerCase()));return[...t,...i]})();return e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:a.map(o=>{const i=n==="dark"&&o.dark?o.dark:o.light,c=o.name===s;return e.jsx("button",{type:"button",onClick:()=>r(o),"aria-pressed":c,"aria-label":`Apply ${o.name} palette`,title:o.name,style:{padding:4,border:c?"2px solid var(--accent-active, #D7FF63)":"1px solid var(--border-default)",borderRadius:8,background:"var(--bg-elevated)",cursor:"pointer"},children:e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 18px)",gridTemplateRows:"repeat(2, 18px)",gap:2},children:i.slots.map(d=>e.jsx("span",{title:d.label,style:{width:18,height:18,borderRadius:4,border:"1px solid var(--border-default)",background:d.value??"transparent"}},d.label))})},o.name)})})}const z6=Object.freeze(Object.defineProperty({__proto__:null,ColorPalettePicker:Vf},Symbol.toStringTag,{value:"Module"}));function Yf({slots:t,values:s,onChange:n}){return e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:"8px 16px"},children:t.map(r=>{const a=!r.cssVar,o=r.cssVar?s[r.cssVar]??r.value??"":"",i=sN(o);return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"70px 1fr 80px",alignItems:"center",gap:6,opacity:a?.4:1,minWidth:0},children:[e.jsx("span",{style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-primary)",fontWeight:500},children:r.label}),e.jsx("input",{type:"color","aria-label":`${r.label} color`,disabled:a,value:i,onChange:c=>{r.cssVar&&n(r.cssVar,c.target.value)},style:{width:"100%",height:28,border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-elevated)",cursor:a?"not-allowed":"pointer"}}),e.jsx("input",{type:"text","aria-label":`${r.label} hex`,disabled:a,value:o,onChange:c=>{r.cssVar&&n(r.cssVar,c.target.value)},spellCheck:!1,style:{padding:"4px 6px",fontSize:"var(--text-xs, 12px)",fontFamily:"var(--font-mono, monospace)",border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-elevated)",color:"var(--text-primary)"}})]},r.label)})})}function sN(t){const s=t.trim();return/^#[0-9a-fA-F]{6}$/.test(s)?s.toLowerCase():/^#[0-9a-fA-F]{3}$/.test(s)?`#${s[1]}${s[1]}${s[2]}${s[2]}${s[3]}${s[3]}`.toLowerCase():"#000000"}const $6=Object.freeze(Object.defineProperty({__proto__:null,ColorSwatchEditor:Yf},Symbol.toStringTag,{value:"Module"}));function wa({children:t}){return e.jsx("h4",{style:{margin:"0 0 8px",fontFamily:"var(--font-mono, 'IBM Plex Mono', monospace)",fontSize:11,fontWeight:500,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.08em"},children:t})}const B6=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizePanelSectionHeading:wa},Symbol.toStringTag,{value:"Module"}));function Kf({palettes:t,activeName:s,theme:n,slots:r,vars:a,onApplyPalette:o,onColorChange:i}){return e.jsxs("div",{role:"menu",style:{padding:"var(--spacing-md, 12px)",background:"var(--bg-surface)",borderBottom:"1px solid var(--border-default)",display:"flex",flexDirection:"column",gap:12},children:[e.jsxs("div",{children:[e.jsx(wa,{children:"Palettes"}),e.jsx(Vf,{palettes:t,activeName:s,theme:n,onApply:o})]}),e.jsxs("div",{children:[e.jsx(wa,{children:"Individual colors"}),e.jsx(Yf,{slots:r,values:a,onChange:i})]})]})}const H6=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizeColorsPanel:Kf},Symbol.toStringTag,{value:"Module"}));function Jf({message:t}){return e.jsx("div",{style:{padding:"var(--spacing-md, 12px)",color:"var(--accent-danger, #f87171)",fontSize:"var(--text-sm, 14px)"},children:t})}const W6=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizeErrorBanner:Jf},Symbol.toStringTag,{value:"Module"}));let il=!1;function nN(){if(il||typeof document>"u")return;il=!0;const t=Gf(Bo.map(n=>n.family));if(!t)return;const s=document.createElement("link");s.rel="stylesheet",s.href=t,s.dataset.codeyamFontPreviews="1",document.head.appendChild(s)}function _a({label:t,value:s,onChange:n,hint:r}){const[a,o]=l.useState(!1),i=l.useRef(null),c=l.useRef(null),d=l.useRef(null);l.useEffect(()=>{nN()},[]);const u=l.useCallback(()=>o(!1),[]);Uf(a,d,u);const h={sans:[],serif:[],display:[],mono:[]};for(const p of Bo)h[p.category].push(p);return e.jsxs("div",{ref:d,style:{display:"flex",flexDirection:"column",gap:4,fontSize:"var(--text-xs, 12px)",color:"var(--text-primary)",position:"relative"},children:[e.jsx("span",{style:{fontFamily:"var(--font-mono, 'IBM Plex Mono', monospace)",fontSize:11,fontWeight:500,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)"},children:t}),r&&e.jsx("span",{style:{color:"var(--text-secondary)",fontStyle:"italic"},children:r}),e.jsxs("button",{ref:i,type:"button","aria-haspopup":"listbox","aria-expanded":a,onClick:()=>o(p=>!p),style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:6,padding:"6px 10px",background:"var(--bg-elevated)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderRadius:6,fontSize:"var(--text-sm, 14px)",fontFamily:s?`"${s}", system-ui, sans-serif`:"inherit",cursor:"pointer",textAlign:"left"},children:[e.jsx("span",{children:s??"System default"}),e.jsx("span",{"aria-hidden":!0,style:{opacity:.6},children:"▾"})]}),a&&e.jsxs("div",{ref:c,role:"listbox",style:{position:"absolute",top:"100%",left:0,right:0,marginTop:4,zIndex:20,background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:8,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",maxHeight:320,overflowY:"auto",padding:4},children:[e.jsx(ka,{family:null,label:"System default",isActive:s===null,onPick:()=>{n(null),o(!1)}}),Object.keys(h).map(p=>e.jsxs("div",{children:[e.jsx("div",{style:{padding:"6px 10px 2px",fontSize:"var(--text-xs, 11px)",color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:700},children:XS[p]}),h[p].map(m=>e.jsx(ka,{family:m.family,label:m.family,isActive:s===m.family,onPick:()=>{n(m.family),o(!1)}},m.family))]},p))]})]})}function ka({family:t,label:s,isActive:n,onPick:r}){return e.jsx("button",{type:"button",role:"option","aria-selected":n,onClick:r,style:{display:"block",width:"100%",padding:"8px 10px",background:n?"var(--bg-elevated)":"transparent",color:"var(--text-primary)",border:"none",borderRadius:4,fontSize:16,fontFamily:t?`"${t}", system-ui, sans-serif`:"inherit",textAlign:"left",cursor:"pointer"},children:s})}const q6=Object.freeze(Object.defineProperty({__proto__:null,FontOptionRow:ka,FontPicker:_a},Symbol.toStringTag,{value:"Module"}));function Xf({primaryFont:t,secondaryFont:s,onPrimaryChange:n,onSecondaryChange:r}){return e.jsxs("div",{role:"menu",style:{padding:"var(--spacing-md, 12px)",background:"var(--bg-surface)",borderBottom:"1px solid var(--border-default)",display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsx(_a,{label:"Headings",value:s,onChange:r}),e.jsx(_a,{label:"Body text",value:t,onChange:n})]})}const G6=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizeFontsPanel:Xf},Symbol.toStringTag,{value:"Module"}));function Ho(t){const s=/<meta\b[^>]*>/gi;let n;for(;(n=s.exec(t))!==null;){const r=n[0];if(!/name=["']codeyam-viewport["']/i.test(r))continue;const a=/content=["']([^"']+)["']/i.exec(r);if(!a)continue;const o=a[1].toLowerCase().trim();return o==="desktop"||o==="tablet"||o==="mobile"?o:null}return null}function rN(t,s){const{vars:n,bg:r,text:a}=aN(s),o=Object.entries(n).filter(([,p])=>p&&p.trim());if(o.length===0)return t;const i=[`:root {
48
+ `+o.map(([p,m])=>` ${p}: ${m};`).join(`
49
+ `)+`
50
+ }`,":root { color-scheme: dark; }"];r&&r.trim()&&a&&a.trim()&&i.push(`html, body { background: ${r}; color: ${a}; }`);const c=`<style data-codeyam-dark="1">${i.join(`
51
+ `)}</style>`;if(t.search(/<\/head\s*>/i)===-1)return`${c}
52
+ ${t}`;const u=oN(t),h=u.search(/<\/head\s*>/i);return`${u.slice(0,h)}
53
+ ${c}
54
+ ${u.slice(h)}`}function aN(t){return t&&typeof t=="object"&&"vars"in t&&typeof t.vars=="object"?t:{vars:t}}function oN(t){const s=/<html\b([^>]*)>/i,n=s.exec(t);if(!n)return t;let r=n[1];/\bdata-theme\s*=/.test(r)||(r+=' data-theme="dark"');const a=/\bclass\s*=\s*("|')([\s\S]*?)\1/,o=a.exec(r);if(o){const i=o[2].split(/\s+/).filter(Boolean);if(!i.includes("dark")){const c=[...i,"dark"].join(" ");r=r.replace(a,`class=${o[1]}${c}${o[1]}`)}}else r+=' class="dark"';return t.replace(s,`<html${r}>`)}function Qf({html:t,srcDoc:s,theme:n,mockupUrl:r,mockupName:a}){const o=Ho(t)??"desktop",i=o==="mobile"||o==="tablet",c=o==="mobile"?390:o==="tablet"?834:null;return e.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto",background:i?"#1a1a1a":"white",backgroundImage:i?"radial-gradient(circle, rgba(255,255,255,0.07) 1px, transparent 1px)":void 0,backgroundSize:i?"12px 12px":void 0,display:"flex",justifyContent:"center"},children:e.jsx("iframe",{title:`Customize preview: ${a}`,srcDoc:s,sandbox:"",style:{width:i&&c?`${c}px`:"100%",height:"100%",minHeight:800,border:"none",background:"white",flexShrink:0}},`${r}-${n}`)})}const U6=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizePreviewArea:Qf},Symbol.toStringTag,{value:"Module"}));function Wo({theme:t,onToggle:s,size:n=28}){return e.jsx("button",{type:"button",onClick:s,"aria-label":t==="light"?"Switch to dark mode":"Switch to light mode","aria-pressed":t==="dark",title:t==="light"?"Dark mode":"Light mode",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:n,height:n,background:"var(--bg-card, #1a1a1a)",border:"1px solid var(--border-default)",borderRadius:6,cursor:"pointer",color:"var(--text-primary)",padding:0,fontSize:14,lineHeight:1},children:t==="light"?"☾":"☀"})}const V6=Object.freeze(Object.defineProperty({__proto__:null,MockupCardThemeToggleButton:Wo},Symbol.toStringTag,{value:"Module"}));function pn(t){return{height:28,padding:"0 8px",background:t?"#555":"#3a3a3a",color:t?"#ffffff":"#d1d5db",border:"none",borderRadius:4,fontSize:11,fontFamily:"var(--font-mono, 'IBM Plex Mono', monospace)",fontWeight:400,letterSpacing:"0.04em",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4}}function Zf({systemName:t,openMenu:s,theme:n,hasDark:r,saving:a,toolbarRef:o,onBack:i,onToggleMenu:c,onToggleTheme:d,onReset:u,onSave:h}){return e.jsxs("div",{ref:o,style:{display:"flex",alignItems:"center",gap:8,padding:"0 8px",height:40,borderBottom:"1px solid #3d3d3d",background:"#2d2d2d",flexWrap:"nowrap"},children:[e.jsx("button",{type:"button",onClick:i,"aria-label":"Back to mockups",style:{...pn(!1),background:"transparent"},children:"← Back"}),e.jsxs("span",{style:{color:"#9ca3af",fontSize:13,fontFamily:"'IBM Plex Sans', system-ui, sans-serif",fontWeight:400,marginRight:4},children:["Customize: ",t]}),e.jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":s==="fonts",onClick:()=>c("fonts"),style:pn(s==="fonts"),children:["Fonts ",e.jsx("span",{"aria-hidden":!0,style:{opacity:.7},children:"▾"})]}),e.jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":s==="colors",onClick:()=>c("colors"),style:pn(s==="colors"),children:["Colors ",e.jsx("span",{"aria-hidden":!0,style:{opacity:.7},children:"▾"})]}),e.jsx("button",{type:"button",onClick:u,style:{...pn(!1),background:"transparent",color:"#9ca3af"},children:"Reset"}),e.jsx("div",{style:{flex:1}}),r&&e.jsx(Wo,{theme:n,onToggle:d,size:28}),e.jsx("button",{type:"button",onClick:h,disabled:a,style:{height:28,padding:"0 10px",background:"var(--accent-active, #D7FF63)",color:"var(--text-on-accent, #0F0F0F)",border:"none",borderRadius:4,fontSize:11,fontFamily:"var(--font-mono, 'IBM Plex Mono', monospace)",fontWeight:500,letterSpacing:"0.04em",cursor:a?"wait":"pointer",opacity:a?.7:1},children:a?"SAVING…":"SAVE"})]})}const Y6=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizeToolbar:Zf},Symbol.toStringTag,{value:"Module"}));function eg({mockup:t,systemName:s,initial:n,onBack:r,onSave:a,saving:o=!1}){var A;const i=eN(t.url,s),[c,d]=l.useState(n),[u,h]=l.useState(null),[p,m]=l.useState("light"),[f,b]=l.useState(null),g=l.useRef(null),v=l.useCallback(()=>b(null),[]);Uf(f!==null,g,v);const x=l.useMemo(()=>{const _=[];return c.primaryFont&&_.push(c.primaryFont),c.secondaryFont&&_.push(c.secondaryFont),_.length===0?null:Gf(_)},[c.primaryFont,c.secondaryFont]),y=l.useMemo(()=>i.kind!=="ready"?c.vars:ZS(i.palettes,p,c.vars),[i,c.vars,p]),w=l.useMemo(()=>i.kind!=="ready"?"":jS(i.html,{...c,vars:y,fontsHref:x}),[i,c,y,x]),j=l.useCallback(_=>{h(_.name);const M=i.kind==="ready"?i.palettes[0]:void 0,I=QS(M,_,p);d(H=>({...H,vars:{...H.vars,...I}}))},[i,p]),k=l.useCallback((_,M)=>{h(null),d(I=>({...I,vars:{...I.vars,[_]:M}}))},[]),S=l.useCallback(()=>{d({vars:{},primaryFont:null,secondaryFont:null,primaryFontStack:null,secondaryFontStack:null}),h(null)},[]),N=l.useMemo(()=>{if(i.kind!=="ready"||i.palettes.length===0)return[{label:"Background",cssVar:"--bg-default",value:null},{label:"Surface",cssVar:"--bg-surface",value:null},{label:"Text",cssVar:"--text-primary",value:null},{label:"Primary",cssVar:"--accent-primary",value:null},{label:"Secondary",cssVar:"--accent-secondary",value:null},{label:"Accent",cssVar:"--accent-highlight",value:null}];const _=i.palettes[0];return p==="dark"&&_.dark?_.dark.slots:_.light.slots},[i,p]),T=i.kind==="ready"&&!!((A=i.palettes[0])!=null&&A.dark);return e.jsxs("div",{"data-testid":"mockup-customize-view",className:"flex-1 flex flex-col min-w-0",style:{overflow:"hidden",position:"relative"},children:[e.jsxs("div",{ref:g,children:[e.jsx(Zf,{systemName:s,openMenu:f,theme:p,hasDark:T,saving:o,toolbarRef:{current:null},onBack:()=>r(c),onToggleMenu:_=>b(M=>M===_?null:_),onToggleTheme:()=>m(_=>_==="light"?"dark":"light"),onReset:S,onSave:()=>a(c)}),f==="fonts"&&e.jsx(Xf,{primaryFont:c.primaryFont,secondaryFont:c.secondaryFont,onPrimaryChange:_=>d(M=>({...M,primaryFont:_})),onSecondaryChange:_=>d(M=>({...M,secondaryFont:_}))}),f==="colors"&&e.jsx(Kf,{palettes:i.kind==="ready"?i.palettes:[],activeName:u,theme:p,slots:N,vars:c.vars,onApplyPalette:j,onColorChange:k})]}),i.kind==="error"&&e.jsx(Jf,{message:i.message}),i.kind==="loading"?e.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto",background:"white",padding:"var(--spacing-lg, 16px)",color:"var(--text-secondary)"},children:"Loading mockup…"}):i.kind==="ready"?e.jsx(Qf,{html:i.html,srcDoc:w,theme:p,mockupUrl:t.url,mockupName:t.name}):null]})}const K6=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizeView:eg},Symbol.toStringTag,{value:"Module"})),iN={desktop:{w:1440,h:900},tablet:{w:834,h:1112},mobile:{w:390,h:844}},ll="desktop",lN=1280,cN=1280,dN="#1a1a1a",uN="radial-gradient(circle, rgba(255,255,255,0.07) 1px, transparent 1px)",hN="12px 12px";function pN(t,s,n,r){if(t<=0||s<=0||n<=0||r<=0)return{scale:0,offsetX:0,offsetY:0};const a=Math.min(t/n,s/r),o=n*a,i=r*a;return{scale:a,offsetX:Math.max(0,(t-o)/2),offsetY:Math.max(0,(s-i)/2)}}function tg(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M4.5 2.5h-2v7h7v-2"}),e.jsx("path",{d:"M7 2.5h2.5V5"}),e.jsx("path",{d:"M9.5 2.5L5.5 6.5"})]})}function sg({displayNumber:t,formattedName:s,theme:n,showThemeToggle:r,busy:a,openInNewTabUrl:o,onToggleTheme:i,onChoose:c,onCustomize:d}){return e.jsxs("div",{style:{padding:"var(--spacing-sm, 10px) var(--spacing-md, 14px)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",minWidth:0},children:[e.jsx("span",{style:{fontWeight:700,color:"var(--text-muted)"},children:String(t).padStart(2,"0")}),o?e.jsxs("a",{href:o,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ${s} in new tab`,title:"Open in new tab",onClick:u=>u.stopPropagation(),style:{display:"inline-flex",alignItems:"center",gap:4,minWidth:0,color:"var(--text-primary)",textDecoration:"none"},children:[e.jsx("span",{style:{textTransform:"capitalize",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s}),e.jsx("span",{style:{display:"inline-flex",alignItems:"center",color:"var(--text-muted)",lineHeight:1,flexShrink:0},children:e.jsx(tg,{})})]}):e.jsx("span",{style:{textTransform:"capitalize",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-xs, 8px)",flexShrink:0},children:[r&&e.jsx(Wo,{theme:n,onToggle:i}),e.jsx("button",{type:"button",onClick:d,disabled:a,style:{padding:"6px 14px",background:"var(--bg-card, #1a1a1a)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderRadius:6,fontSize:"var(--text-xs, 12px)",fontWeight:500,cursor:a?"wait":"pointer",opacity:a?.6:1},children:"Customize"}),e.jsx("button",{type:"button",onClick:c,disabled:a,style:{padding:"6px 14px",background:"var(--accent-active, #7c3aed)",color:"var(--text-on-accent, #fff)",border:"1px solid transparent",borderRadius:6,fontSize:"var(--text-xs, 12px)",fontWeight:600,cursor:a?"wait":"pointer",opacity:a?.6:1,boxShadow:a?"none":"0 0 0 3px color-mix(in srgb, var(--accent-active, #7c3aed) 30%, transparent), 0 2px 6px color-mix(in srgb, var(--accent-active, #7c3aed) 40%, transparent)"},children:"Select"})]})]})}const J6=Object.freeze(Object.defineProperty({__proto__:null,MockupCardFooter:sg,OpenInNewTabIcon:tg},Symbol.toStringTag,{value:"Module"})),mN=700;function fN({srcDoc:t,url:s,theme:n,scale:r,hasContent:a}){const[o,i]=l.useState(!1),[c,d]=l.useState(!1),u=l.useRef([]);l.useEffect(()=>{i(!1),d(!1);const f=window.setTimeout(()=>d(!0),mN);return()=>window.clearTimeout(f)},[t,s,n]);const h=()=>{const f=window.requestAnimationFrame(()=>{const b=window.requestAnimationFrame(()=>i(!0));u.current.push(b)});u.current.push(f)};l.useEffect(()=>()=>{u.current.forEach(f=>window.cancelAnimationFrame(f)),u.current=[]},[]);const p=o&&r>0;return{handleIframeLoad:h,visible:p,showSkeleton:!a||!p||!c}}function Me({widthPct:t,heightPx:s,variant:n="surface"}){const r=n==="overlay"?"linear-gradient(90deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.12) 45%, rgba(255,255,255,0.04) 90%)":"linear-gradient(90deg, var(--bg-surface) 0%, var(--border-default) 45%, var(--bg-surface) 90%)";return e.jsx("div",{style:{width:`${t}%`,height:s,borderRadius:4,background:r,backgroundSize:"200% 100%",animation:"mockup-skeleton-shimmer 1.6s linear infinite",opacity:n==="surface"?.85:1}})}const X6=Object.freeze(Object.defineProperty({__proto__:null,SkeletonBar:Me},Symbol.toStringTag,{value:"Module"}));function ng(){return e.jsxs("div",{"aria-label":"Loading mockup",style:{position:"absolute",inset:0,padding:"10%",display:"flex",flexDirection:"column",gap:"5%"},children:[e.jsx("style",{children:`
55
+ @keyframes mockup-skeleton-shimmer {
56
+ 0% { background-position: -200% 0; }
57
+ 100% { background-position: 200% 0; }
58
+ }
59
+ `}),e.jsx(Me,{widthPct:45,heightPx:14,variant:"overlay"}),e.jsx(Me,{widthPct:70,heightPx:10,variant:"overlay"}),e.jsx("div",{style:{height:"6%"}}),e.jsx(Me,{widthPct:100,heightPx:32,variant:"overlay"}),e.jsxs("div",{style:{display:"flex",gap:"4%"},children:[e.jsx(Me,{widthPct:48,heightPx:48,variant:"overlay"}),e.jsx(Me,{widthPct:48,heightPx:48,variant:"overlay"})]}),e.jsx(Me,{widthPct:88,heightPx:10,variant:"overlay"}),e.jsx(Me,{widthPct:60,heightPx:10,variant:"overlay"})]})}const Q6=Object.freeze(Object.defineProperty({__proto__:null,MockupSkeletonOverlay:ng},Symbol.toStringTag,{value:"Module"}));function qo({html:t,url:s,title:n,viewport:r,theme:a,darkVars:o}){const i=l.useRef(null),[c,d]=l.useState(0),[u,h]=l.useState(0),p=iN[r];l.useEffect(()=>{const j=i.current;if(!j)return;const k=()=>{const N=j.clientWidth,T=j.clientHeight;N>0&&d(N),T>0&&h(T)};if(k(),typeof ResizeObserver>"u")return;const S=new ResizeObserver(k);return S.observe(j),()=>S.disconnect()},[]);const{scale:m,offsetX:f,offsetY:b}=pN(c,u,p.w,p.h),g=t&&a==="dark"&&o?rN(t,{vars:o,...qS(o)}):t,{handleIframeLoad:v,visible:x,showSkeleton:y}=fN({srcDoc:g,url:s,theme:a,scale:m,hasContent:t!==null}),w=()=>window.open(s,"_blank","noopener,noreferrer");return e.jsxs("div",{ref:i,onClick:w,style:{position:"relative",width:"100%",aspectRatio:`${lN} / ${cN}`,overflow:"hidden",cursor:"pointer",backgroundColor:dN,backgroundImage:uN,backgroundSize:hN},children:[t!==null&&e.jsx("iframe",{src:g?void 0:s,srcDoc:g??void 0,title:n,sandbox:"",onLoad:v,style:{width:p.w,height:p.h,border:"none",background:"white",transform:m>0?`scale(${m})`:"scale(0)",transformOrigin:"top left",pointerEvents:"none",position:"absolute",top:b,left:f,visibility:x?"visible":"hidden"}},a),y&&e.jsx(ng,{})]})}const Z6=Object.freeze(Object.defineProperty({__proto__:null,MockupCardPreviewSlot:qo},Symbol.toStringTag,{value:"Module"})),gN=`
60
+ .mockup-feedback-slider {
61
+ -webkit-appearance: none;
62
+ appearance: none;
63
+ background: transparent;
64
+ height: 18px;
65
+ padding: 0;
66
+ margin: 0;
67
+ cursor: pointer;
68
+ }
69
+ .mockup-feedback-slider:focus { outline: none; }
70
+ .mockup-feedback-slider::-webkit-slider-runnable-track {
71
+ height: 4px;
72
+ background: #4a4a4a;
73
+ border-radius: 2px;
74
+ }
75
+ .mockup-feedback-slider::-moz-range-track {
76
+ height: 4px;
77
+ background: #4a4a4a;
78
+ border-radius: 2px;
79
+ border: none;
80
+ }
81
+ .mockup-feedback-slider::-moz-range-progress {
82
+ background: #4a4a4a;
83
+ height: 4px;
84
+ border-radius: 2px;
85
+ }
86
+ .mockup-feedback-slider::-webkit-slider-thumb {
87
+ -webkit-appearance: none;
88
+ appearance: none;
89
+ width: 14px;
90
+ height: 14px;
91
+ border-radius: 50%;
92
+ background: #5a5a5a;
93
+ border: none;
94
+ margin-top: -5px;
95
+ cursor: pointer;
96
+ transition: background 120ms ease;
97
+ }
98
+ .mockup-feedback-slider::-moz-range-thumb {
99
+ width: 14px;
100
+ height: 14px;
101
+ border-radius: 50%;
102
+ background: #5a5a5a;
103
+ border: none;
104
+ cursor: pointer;
105
+ transition: background 120ms ease;
106
+ }
107
+ .mockup-feedback-slider[data-rated="true"]::-webkit-slider-runnable-track {
108
+ /* Two stacked layers: a grey overlay that masks the right portion of
109
+ * the track from progress% onward, and a full-width red-amber-keylime
110
+ * rainbow underneath. The visible filled portion is the slice of the
111
+ * rainbow up to the thumb position. */
112
+ background:
113
+ linear-gradient(
114
+ to right,
115
+ transparent 0%,
116
+ transparent var(--mockup-feedback-progress, 0%),
117
+ #4a4a4a var(--mockup-feedback-progress, 0%),
118
+ #4a4a4a 100%
119
+ ),
120
+ linear-gradient(
121
+ to right,
122
+ rgb(239, 68, 68) 0%,
123
+ rgb(251, 191, 36) 50%,
124
+ rgb(215, 255, 99) 100%
125
+ );
126
+ }
127
+ .mockup-feedback-slider[data-rated="true"]::-moz-range-track {
128
+ background: linear-gradient(
129
+ to right,
130
+ rgb(239, 68, 68) 0%,
131
+ rgb(251, 191, 36) 50%,
132
+ rgb(215, 255, 99) 100%
133
+ );
134
+ }
135
+ .mockup-feedback-slider[data-rated="true"]::-moz-range-progress {
136
+ /* Firefox draws ::-moz-range-progress on top of ::-moz-range-track,
137
+ * so the progress layer would otherwise hide the rainbow below it.
138
+ * Leave it transparent so the rainbow shows through up to the value. */
139
+ background: transparent;
140
+ }
141
+ .mockup-feedback-slider[data-rated="true"]::-webkit-slider-thumb {
142
+ background: var(--mockup-feedback-color, var(--accent-active, #D7FF63));
143
+ }
144
+ .mockup-feedback-slider[data-rated="true"]::-moz-range-thumb {
145
+ background: var(--mockup-feedback-color, var(--accent-active, #D7FF63));
146
+ }
147
+ `,bN=`
148
+ .mockup-feedback-comment {
149
+ width: 100%;
150
+ padding: var(--spacing-sm, 8px) var(--spacing-sm, 10px);
151
+ background: var(--bg-card, #1a1a1a);
152
+ color: var(--text-primary);
153
+ border: 1px solid var(--border-default);
154
+ border-radius: 6px;
155
+ font-size: var(--text-xs, 12px);
156
+ line-height: 1.4;
157
+ resize: vertical;
158
+ box-sizing: border-box;
159
+ min-height: 56px;
160
+ outline: none;
161
+ }
162
+ .mockup-feedback-comment:focus,
163
+ .mockup-feedback-comment:focus-visible {
164
+ border-color: var(--text-primary, #ffffff);
165
+ outline: none;
166
+ box-shadow: 0 0 0 1px var(--text-primary, #ffffff);
167
+ }
168
+ `;function rg({comment:t,onCommentChange:s}){return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:bN}),e.jsx("textarea",{value:t,onChange:n=>s(n.target.value),placeholder:"What do you like or would like to change? (optional)",rows:3,className:"mockup-feedback-comment"})]})}const eA=Object.freeze(Object.defineProperty({__proto__:null,MockupFeedbackCommentBox:rg},Symbol.toStringTag,{value:"Module"})),ag=[239,68,68],Sa=[251,191,36],og=[215,255,99];function xN(t){const s=Math.max(1,Math.min(100,t));let n,r,a;s<=50?(n=ag,r=Sa,a=(s-1)/49):(n=Sa,r=og,a=(s-50)/50);const o=Math.round(n[0]+(r[0]-n[0])*a),i=Math.round(n[1]+(r[1]-n[1])*a),c=Math.round(n[2]+(r[2]-n[2])*a);return`rgb(${o}, ${i}, ${c})`}`${ag.join(", ")}${Sa.join(", ")}${og.join(", ")}`;function ig(){return e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3z"}),e.jsx("path",{d:"M17 2h2.5a2.5 2.5 0 0 1 2.5 2.5v6A2.5 2.5 0 0 1 19.5 13H17"})]})}function lg(){return e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3z"}),e.jsx("path",{d:"M7 22H4.5a2.5 2.5 0 0 1-2.5-2.5v-6A2.5 2.5 0 0 1 4.5 11H7"})]})}const tA=Object.freeze(Object.defineProperty({__proto__:null,ThumbDownIcon:ig,ThumbUpIcon:lg},Symbol.toStringTag,{value:"Module"}));function cg({rating:t,onRatingChange:s}){const n=t!=null,r=n&&t<=33,a=n&&t>=67;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-sm, 10px)"},children:[e.jsx("span",{"aria-hidden":"true",style:{color:r?"var(--text-primary)":"var(--text-muted)",display:"inline-flex",alignItems:"center"},children:e.jsx(ig,{})}),e.jsx("input",{type:"range",min:1,max:100,step:1,value:t??50,onPointerDown:()=>{n||s(50)},onChange:o=>s(Number(o.target.value)),"aria-label":"Rate this mockup from 1 to 100",className:"mockup-feedback-slider","data-rated":n?"true":"false",style:{flex:1,"--mockup-feedback-progress":`${t??0}%`,"--mockup-feedback-color":n?xN(t):"var(--accent-active, #D7FF63)"}}),e.jsx("span",{"aria-hidden":"true",style:{color:a?"var(--text-primary)":"var(--text-muted)",display:"inline-flex",alignItems:"center"},children:e.jsx(lg,{})})]})}const sA=Object.freeze(Object.defineProperty({__proto__:null,MockupFeedbackRatingSlider:cg},Symbol.toStringTag,{value:"Module"})),dg={rating:null,comment:""};function ug({value:t,onChange:s}){return e.jsxs("div",{"data-mockup-feedback":!0,style:{padding:"var(--spacing-sm, 10px) var(--spacing-md, 14px)",borderTop:"1px solid var(--border-default)",display:"flex",flexDirection:"column",gap:"var(--spacing-sm, 10px)",background:"var(--bg-surface)"},children:[e.jsx("style",{children:gN}),e.jsx(cg,{rating:t.rating,onRatingChange:n=>s({...t,rating:n})}),e.jsx(rg,{comment:t.comment,onCommentChange:n=>s({...t,comment:n})})]})}const nA=Object.freeze(Object.defineProperty({__proto__:null,EMPTY_FEEDBACK:dg,MockupCardFeedback:ug},Symbol.toStringTag,{value:"Module"}));function hg({mockup:t,displayNumber:s,onChoose:n,onCustomize:r,busy:a=!1,darkVars:o=null,feedback:i,onFeedbackChange:c}){const[d,u]=l.useState(null),[h,p]=l.useState(ll),[m,f]=l.useState("light");if(l.useEffect(()=>{if(!t)return;let g=!1;return(async()=>{try{const v=await fetch(t.url);if(!v.ok)return;const x=await v.text();if(g)return;u(x),p(Ho(x)??ll)}catch{}})(),()=>{g=!0}},[t==null?void 0:t.url]),!t)return e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:160,border:"1px dashed var(--border-default)",borderRadius:12,background:"var(--bg-surface)",color:"var(--text-muted)",fontSize:"var(--text-sm, 14px)"},children:"No mockup to preview"});const b=t.name.replace(/^\d{1,2}-/,"").replace(/-/g," ");return e.jsxs("div",{style:{position:"relative",display:"flex",flexDirection:"column",border:"1px solid var(--border-default)",borderRadius:12,overflow:"hidden",background:"var(--bg-surface)"},children:[e.jsx(sg,{displayNumber:s,formattedName:b,theme:m,showThemeToggle:!!o,busy:a,openInNewTabUrl:t.url,onToggleTheme:()=>f(g=>g==="light"?"dark":"light"),onChoose:()=>n==null?void 0:n(t),onCustomize:()=>r==null?void 0:r(t)}),e.jsx(qo,{html:d,url:t.url,title:t.name,viewport:h,theme:m,darkVars:o}),c&&e.jsx(ug,{value:i??dg,onChange:c})]})}const rA=Object.freeze(Object.defineProperty({__proto__:null,MockupCard:hg},Symbol.toStringTag,{value:"Module"}));function pg({displayNumber:t}){return e.jsxs("div",{"data-mockup-placeholder":!0,"aria-label":"The AI is designing this mockup",style:{position:"relative",display:"flex",flexDirection:"column",border:"1px solid var(--border-default)",borderRadius:12,overflow:"hidden",background:"var(--bg-surface)"},children:[e.jsx("style",{children:`
169
+ @keyframes mockup-skeleton-shimmer {
170
+ 0% { background-position: -200% 0; }
171
+ 100% { background-position: 200% 0; }
172
+ }
173
+ `}),e.jsxs("div",{style:{position:"relative",width:"100%",aspectRatio:"1 / 1",overflow:"hidden",background:"var(--bg-elevated, #141414)",padding:"10%",display:"flex",flexDirection:"column",gap:"5%"},children:[e.jsx(Me,{widthPct:45,heightPx:14}),e.jsx(Me,{widthPct:70,heightPx:10}),e.jsx("div",{style:{height:"6%"}}),e.jsx(Me,{widthPct:100,heightPx:32}),e.jsxs("div",{style:{display:"flex",gap:"4%"},children:[e.jsx(Me,{widthPct:48,heightPx:48}),e.jsx(Me,{widthPct:48,heightPx:48})]}),e.jsx(Me,{widthPct:88,heightPx:10}),e.jsx(Me,{widthPct:60,heightPx:10})]}),e.jsx("div",{style:{padding:"var(--spacing-sm, 8px) var(--spacing-md, 12px)",display:"flex",alignItems:"center",gap:"var(--spacing-sm, 8px)"},children:e.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:6,color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",minWidth:0},children:[e.jsx("span",{style:{fontWeight:700,color:"var(--text-muted)"},children:String(t).padStart(2,"0")}),e.jsx("span",{style:{color:"var(--text-secondary)",fontStyle:"italic"},"data-testid":"mockup-placeholder-label",children:"The AI is designing this mockup…"})]})})]})}const aA=Object.freeze(Object.defineProperty({__proto__:null,MockupPlaceholderCard:pg},Symbol.toStringTag,{value:"Module"}));function mg({slots:t,darkVarsBySystem:s,busyFilename:n,feedbackByFilename:r,onFeedbackChange:a,onChoose:o,onCustomize:i}){return e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",columnGap:"var(--spacing-lg, 16px)",rowGap:"var(--spacing-xl, 28px)"},children:t.map(c=>c.mockup?e.jsx(hg,{mockup:c.mockup,displayNumber:c.number,onChoose:o,onCustomize:i,busy:n===c.mockup.filename,darkVars:s[fr(c.mockup.filename)]??null,feedback:r==null?void 0:r[c.mockup.filename],onFeedbackChange:a?d=>a(c.mockup.filename,d):void 0},`mockup-${c.mockup.filename}`):e.jsx(pg,{displayNumber:c.number},`placeholder-${c.number}`))})}const oA=Object.freeze(Object.defineProperty({__proto__:null,MockupGrid:mg},Symbol.toStringTag,{value:"Module"}));function fg(){return e.jsxs("div",{"data-mockup-generating-overlay":!0,style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"var(--spacing-md, 14px)",zIndex:5,background:"var(--bg-overlay, rgba(15,17,21,0.45))",backdropFilter:"blur(1px)",borderRadius:12,pointerEvents:"auto"},children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:"w-12 h-12 border-4 border-primary/20 border-t-primary rounded-full animate-spin"})}),e.jsx("div",{style:{color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",fontWeight:500},children:"Generating new designs…"})]})}const iA=Object.freeze(Object.defineProperty({__proto__:null,MockupGridGeneratingOverlay:fg},Symbol.toStringTag,{value:"Module"}));function gg(){return e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M9 18h6"}),e.jsx("path",{d:"M10 22h4"}),e.jsx("path",{d:"M12 2a7 7 0 0 0-4 12.74V17a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1v-2.26A7 7 0 0 0 12 2z"})]})}function bg(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M18 6L6 18"}),e.jsx("path",{d:"M6 6l12 12"})]})}function xg({onDismiss:t}){return e.jsxs("div",{role:"note","data-mockup-info-banner":!0,style:{display:"flex",alignItems:"flex-start",gap:"var(--spacing-md, 14px)",padding:"var(--spacing-md, 14px) var(--spacing-md, 16px)",border:"1px solid var(--accent-active, #D7FF63)",borderRadius:12,background:"rgba(215, 255, 99, 0.04)"},children:[e.jsx("span",{"aria-hidden":"true",style:{color:"var(--accent-active, #D7FF63)",display:"inline-flex",alignItems:"center",flexShrink:0,paddingTop:1},children:e.jsx(gg,{})}),e.jsxs("p",{style:{flex:1,margin:0,color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",lineHeight:1.5},children:[e.jsx("strong",{style:{fontWeight:700},children:"Not sure which to pick?"})," ","Rate these designs and jot a quick note. We'll refine them into a fresh round — no need to choose yet."]}),e.jsx("button",{type:"button",onClick:t,"aria-label":"Dismiss tip",title:"Dismiss",style:{flexShrink:0,padding:4,background:"transparent",color:"var(--text-muted)",border:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:e.jsx(bg,{})})]})}const lA=Object.freeze(Object.defineProperty({__proto__:null,CloseIcon:bg,LightbulbIcon:gg,MockupGridInfoBanner:xg},Symbol.toStringTag,{value:"Module"}));function yg(){return e.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M21 12a9 9 0 1 1-3.36-7"}),e.jsx("polyline",{points:"21 4 21 10 15 10"})]})}function vg({feedbackCount:t,busy:s,onIterate:n}){const r=t===0?"Add a rating or note above, then iterate.":t===1?"1 card has feedback — iterate to refresh the round.":`${t} cards have feedback — iterate to refresh the round.`;return e.jsxs("div",{style:{marginTop:"var(--spacing-md, 12px)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"var(--spacing-md, 16px)",padding:"var(--spacing-md, 16px) var(--spacing-lg, 20px)",border:"1px solid var(--border-default)",borderRadius:12,background:"var(--bg-card, #1a1a1a)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-md, 14px)",minWidth:0},children:[e.jsx("span",{"aria-hidden":"true",style:{color:"var(--accent-active, #D7FF63)",display:"inline-flex",alignItems:"center",flexShrink:0},children:e.jsx(yg,{})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0},children:[e.jsx("span",{style:{color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",fontWeight:600,lineHeight:1.3},children:"Ready for the next round?"}),e.jsx("span",{style:{color:"var(--text-muted)",fontSize:"var(--text-xs, 12px)",lineHeight:1.4,marginTop:2},children:r})]})]}),e.jsx("button",{type:"button",onClick:n,disabled:s,"data-mockup-iterate":!0,style:{flexShrink:0,padding:"10px 22px",background:"var(--accent-active, #D7FF63)",color:"var(--text-on-accent, #0F0F0F)",border:"1px solid var(--accent-active, #D7FF63)",borderRadius:8,fontSize:"var(--text-sm, 14px)",fontWeight:600,cursor:s?"wait":"pointer",opacity:s?.6:1},children:s?"Sending…":"Iterate"})]})}const cA=Object.freeze(Object.defineProperty({__proto__:null,MockupGridIterateButton:vg,RefreshCycleIcon:yg},Symbol.toStringTag,{value:"Module"}));function jg(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("polyline",{points:"15 18 9 12 15 6"})})}function wg(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("polyline",{points:"9 18 15 12 9 6"})})}function _g({archivedRoundsNewestFirst:t,selected:s,onSelect:n}){if(!t||t.length===0)return null;const a=[...[...t].reverse(),"current"],o=a.length,i=a.indexOf(s),c=i===-1?o-1:i,d=s==="current",u=c>0,h=c<o-1,p=d?`Round ${o} of ${o} · Current`:`Round ${c+1} of ${o} · Archived`;return e.jsxs("div",{"data-mockup-round-pager":!0,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"var(--spacing-sm, 10px)",padding:"var(--spacing-xs, 6px) var(--spacing-md, 14px)",border:"1px solid var(--border-default)",borderRadius:10,background:"var(--bg-card, #1a1a1a)"},children:[e.jsx(Na,{ariaLabel:"Previous round",disabled:!u,onClick:()=>u&&n(a[c-1]),icon:e.jsx(jg,{})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-md, 12px)",fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:[e.jsx("span",{style:{fontWeight:500,color:"var(--text-primary)"},children:p}),!d&&e.jsx("button",{type:"button",onClick:()=>n("current"),style:{padding:"4px 10px",background:"transparent",color:"var(--accent-active, #D7FF63)",border:"1px solid var(--accent-active, #D7FF63)",borderRadius:6,fontSize:"var(--text-xs, 11px)",fontWeight:500,cursor:"pointer"},children:"Return to current"})]}),e.jsx(Na,{ariaLabel:"Next round",disabled:!h,onClick:()=>h&&n(a[c+1]),icon:e.jsx(wg,{})})]})}function Na({ariaLabel:t,disabled:s,onClick:n,icon:r}){return e.jsx("button",{type:"button",onClick:n,disabled:s,"aria-label":t,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:28,height:28,background:"transparent",color:s?"var(--text-dim, #666)":"var(--text-primary)",border:"1px solid var(--border-default)",borderRadius:6,cursor:s?"default":"pointer",opacity:s?.5:1,padding:0},children:r})}const dA=Object.freeze(Object.defineProperty({__proto__:null,ChevronLeftIcon:jg,ChevronRightIcon:wg,MockupRoundPager:_g,PagerArrowButton:Na},Symbol.toStringTag,{value:"Module"}));function kg({mockup:t,busy:s,onCancel:n,onConfirm:r}){l.useEffect(()=>{const o=i=>{i.key==="Escape"&&!s&&n()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[s,n]);const a=t.name.replace(/^\d{1,2}-/,"").replace(/-/g," ");return e.jsx("div",{role:"presentation",onClick:n,style:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(2px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:200,padding:24},children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Ready to start building?",onClick:o=>o.stopPropagation(),style:{background:"var(--bg-elevated, #141414)",border:"1px solid var(--border-default)",borderRadius:12,padding:24,width:"min(440px, 100%)",display:"flex",flexDirection:"column",gap:16,fontFamily:"'IBM Plex Mono', monospace",boxShadow:"0 20px 60px rgba(0,0,0,0.5)"},children:[e.jsx("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:8,overflow:"hidden",aspectRatio:"16 / 9",background:"#1a1a1a",position:"relative"},children:e.jsx("iframe",{src:t.url,title:`${a} thumbnail`,sandbox:"",style:{width:1440,height:900,border:"none",background:"white",transform:"scale(0.305)",transformOrigin:"top left",pointerEvents:"none",position:"absolute",top:0,left:0}})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[e.jsx("h2",{style:{margin:0,color:"var(--text-primary)",fontSize:16,fontWeight:600},children:"Ready to start building?"}),e.jsxs("p",{style:{margin:0,color:"var(--text-secondary)",fontSize:13,textTransform:"capitalize"},children:["Using ",e.jsx("strong",{style:{color:"var(--text-primary)"},children:a})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[e.jsx("button",{type:"button",onClick:n,disabled:s,style:{padding:"8px 16px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)",borderRadius:6,fontSize:13,fontWeight:500,cursor:s?"wait":"pointer",opacity:s?.5:1,fontFamily:"inherit"},children:"Cancel"}),e.jsx("button",{type:"button",onClick:r,disabled:s,style:{padding:"8px 18px",background:"var(--accent-active, #D7FF63)",color:"var(--text-on-accent, #0F0F0F)",border:"1px solid var(--accent-active, #D7FF63)",borderRadius:6,fontSize:13,fontWeight:600,cursor:s?"wait":"pointer",opacity:s?.7:1,fontFamily:"inherit"},children:s?"Starting…":"Start building"})]})]})})}const uA=Object.freeze(Object.defineProperty({__proto__:null,StartBuildingConfirmModal:kg},Symbol.toStringTag,{value:"Module"}));function Sg({onDesignConfirmed:t}={}){const[s,n]=l.useState(null),[r,a]=l.useState(null),[o,i]=l.useState(null),[c,d]=l.useState(null),[u,h]=l.useState(null),[p,m]=l.useState(null),[f,b]=l.useState({}),[g,v]=l.useState({}),[x,y]=l.useState(!1),[w,j]=l.useState(!1),k=l.useRef([]),S=l.useRef(!1),N=l.useRef(!1),[T,A]=l.useState(null),[_,M]=l.useState(()=>typeof window>"u"?!1:window.sessionStorage.getItem("mockup-grid-tip-dismissed")==="1"),[I,H]=l.useState("current"),z=JS(),G=l.useRef(null),R=KS(s),D=l.useRef(!0),P=l.useCallback(async()=>{try{const[C,E]=await Promise.all([fetch("/api/editor-mockups"),fetch("/api/editor-mockups-target")]),B=await C.json(),se=await E.json();D.current&&(n(q=>_S(q,B)||S.current&&B.length<k.current.length?q:B),a(q=>q===se.count?q:se.count))}catch(C){D.current&&i(C instanceof Error?C.message:String(C))}},[]);l.useEffect(()=>{D.current=!0,P();const C=window.setInterval(P,4e3);return()=>{D.current=!1,window.clearInterval(C)}},[P]),l.useEffect(()=>{let C=!1;return(async()=>{try{const E=await fetch("/api/editor-mockups-feedback");if(!E.ok)return;const B=await E.json();if(C||!B||typeof B!="object"||Array.isArray(B))return;const se={};for(const[q,ce]of Object.entries(B)){if(!ce||typeof ce!="object")continue;const W=ce;W.rating!=null&&typeof W.rating!="number"||W.comment!=null&&typeof W.comment!="string"||(se[q]={rating:typeof W.rating=="number"?W.rating:null,comment:typeof W.comment=="string"?W.comment:""})}v(se)}catch{}})(),()=>{C=!0}},[]);const $=l.useCallback((C,E)=>{v(B=>{const se={...B,[C]:E};return G.current!=null&&window.clearTimeout(G.current),G.current=window.setTimeout(()=>{fetch("/api/editor-mockups-feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(se)}).catch(()=>{})},400),se})},[]);l.useEffect(()=>()=>{G.current!=null&&window.clearTimeout(G.current)},[]);const F=l.useCallback(()=>{if(!s)return;const C=s.map(B=>B.filename);k.current=C,N.current=!1,j(!1),y(!0),H("current");const E=TS({feedbackByFilename:g,mockupFilenames:C});(async()=>{try{await fetch("/api/editor-mockups-archive",{method:"POST"})}catch{}await NS(E),D.current&&(N.current=!0,v({}),fetch("/api/editor-mockups-feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}).catch(()=>{}))})()},[g,s]);l.useEffect(()=>{S.current=x},[x]),l.useEffect(()=>{if(!x)return;const C=()=>{N.current&&j(!0)};return window.addEventListener("miniagent-output",C),()=>window.removeEventListener("miniagent-output",C)},[x]),l.useEffect(()=>{if(!x)return;const C=window.setTimeout(()=>{D.current&&y(!1)},PS);return()=>window.clearTimeout(C)},[x]),l.useEffect(()=>{x&&OS({snapshotFilenames:k.current,latestFilenames:(s??[]).map(C=>C.filename),agentRespondedAfterDispatch:w})&&y(!1)},[x,s,w]);const U=l.useCallback(async C=>{A(C);try{const E=await fetch("/api/editor-mockups-restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({round:C})});if(!E.ok){const B=await E.text().catch(()=>`${E.status}`);throw new Error(B||`restore failed: ${E.status}`)}D.current&&(H("current"),P())}catch(E){D.current&&i(E instanceof Error?E.message:String(E))}finally{D.current&&A(null)}},[P]),J=l.useCallback(C=>{m(C)},[]),Z=l.useCallback(async()=>{if(!p)return;const C=p;d(C.filename);try{const E=await fetch("/api/editor-design-select",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:C.filename})});if(!E.ok){const B=await E.text().catch(()=>`${E.status}`);throw new Error(B||`select failed: ${E.status}`)}D.current&&(m(null),t==null||t())}catch(E){i(E instanceof Error?E.message:String(E))}finally{D.current&&d(null)}},[p,t]),te=l.useCallback(C=>{const E=fr(C.filename);h({mockup:C,systemName:E})},[]),ie=l.useCallback(C=>{u&&b(E=>({...E,[u.mockup.filename]:C})),h(null)},[u]),V=l.useCallback(async C=>{if(u){d(u.mockup.filename);try{const E=await fetch("/api/editor-design-select",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:u.mockup.filename,overrides:{vars:C.vars,primaryFont:C.primaryFont,secondaryFont:C.secondaryFont}})});if(!E.ok){const B=await E.text().catch(()=>`${E.status}`);throw new Error(B||`select failed: ${E.status}`)}b(B=>({...B,[u.mockup.filename]:C})),h(null),t==null||t()}catch(E){i(E instanceof Error?E.message:String(E))}finally{D.current&&d(null)}}},[u,t]);if(u)return e.jsx(eg,{mockup:u.mockup,systemName:u.systemName,initial:f[u.mockup.filename]??wS,onBack:ie,onSave:V,saving:c===u.mockup.filename});if(!s)return e.jsx("div",{style:{padding:"var(--spacing-lg, 16px)"},children:e.jsx("div",{style:{color:"var(--text-secondary)"},children:"Loading design mockups…"})});const le=s.reduce((C,E)=>{const B=/^(\d{1,2})-/.exec(E.filename);return B?Math.max(C,parseInt(B[1],10)):C},0),me=Math.max(r??0,le);if(me===0)return e.jsx($a,{});const Q=Array.from({length:me},(C,E)=>{const B=E+1,se=String(B).padStart(2,"0"),q=s.find(ce=>ce.filename.startsWith(`${se}-`))??null;return{number:B,mockup:q}});return e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",style:{padding:"var(--spacing-lg, 16px)",gap:"var(--spacing-md, 12px)",overflow:"auto"},children:[!_&&e.jsx(xg,{onDismiss:()=>{M(!0),typeof window<"u"&&window.sessionStorage.setItem("mockup-grid-tip-dismissed","1")}}),e.jsx(_g,{archivedRoundsNewestFirst:z.map(C=>C.round),selected:I,onSelect:H}),o&&e.jsx("div",{style:{padding:"var(--spacing-sm, 8px) var(--spacing-md, 12px)",borderRadius:8,background:"var(--bg-danger-soft, rgba(248,113,113,0.12))",color:"var(--accent-danger, #f87171)",fontSize:"var(--text-sm, 14px)"},children:o}),I==="current"?e.jsxs("div",{style:{position:"relative",display:"flex",flexDirection:"column",gap:"var(--spacing-md, 12px)"},children:[e.jsxs("div",{style:x?{opacity:.4,pointerEvents:"none"}:void 0,children:[e.jsx(mg,{slots:Q,darkVarsBySystem:R,busyFilename:c,feedbackByFilename:g,onFeedbackChange:$,onChoose:J,onCustomize:te}),s.length>0&&e.jsx("div",{style:{marginTop:"var(--spacing-md, 12px)"},children:e.jsx(vg,{feedbackCount:Object.values(g).filter(C=>typeof C.rating=="number"||C.comment.trim().length>0).length,busy:x,onIterate:F})})]}),x&&e.jsx(fg,{})]}):(()=>{const C=z.find(E=>E.round===I);return C?e.jsx(qf,{round:C,onRestore:()=>U(C.round),restoring:T===C.round}):e.jsx("div",{style:{padding:"var(--spacing-md, 14px)",color:"var(--text-secondary)",fontSize:"var(--text-sm, 14px)"},children:"Loading archived round…"})})(),p&&e.jsx(kg,{mockup:p,busy:c===p.filename,onCancel:()=>m(null),onConfirm:Z})]})}const hA=Object.freeze(Object.defineProperty({__proto__:null,DesignExplorationView:Sg,systemNameFromFilename:fr},Symbol.toStringTag,{value:"Module"}));function Ng({onDesignConfirmed:t}){const[s,n]=l.useState("assets"),r=l.useRef(!0),a=l.useRef(0);return l.useEffect(()=>{r.current=!0;const o=async()=>{try{const d=await(await fetch("/api/editor-design-active-tab")).json();if(!r.current)return;d.tab!==null&&d.nonce!==null&&d.nonce>a.current&&(a.current=d.nonce,n(d.tab))}catch{}};o();const i=window.setInterval(o,4e3);return()=>{r.current=!1,window.clearInterval(i)}},[]),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[e.jsx("div",{role:"tablist",style:{display:"flex",gap:"var(--spacing-xs, 4px)",padding:"var(--spacing-sm, 8px) var(--spacing-md, 12px)",borderBottom:"1px solid var(--border-default)"},children:[{id:"assets",label:"Add assets"},{id:"mockups",label:"Mockups"}].map(({id:o,label:i})=>{const c=s===o;return e.jsx("button",{type:"button",role:"tab","aria-selected":c,onClick:()=>n(o),style:{padding:"var(--spacing-xs, 4px) var(--spacing-md, 12px)",borderRadius:6,border:"none",cursor:"pointer",fontSize:"var(--text-sm, 14px)",fontWeight:500,background:c?"var(--accent-active)":"transparent",color:c?"var(--text-on-accent, white)":"var(--text-secondary)"},children:i},o)})}),s==="assets"?e.jsx(zf,{}):e.jsx(Sg,{onDesignConfirmed:t})]})}const pA=Object.freeze(Object.defineProperty({__proto__:null,DesignChatPreviewPane:Ng},Symbol.toStringTag,{value:"Module"}));function Cg({deviceLabel:t}){return e.jsxs("div",{role:"note",className:"flex items-center gap-2 border-b border-l-4 px-3 py-2 text-sm",style:{background:"var(--bg-surface)",borderColor:"var(--border-default)",borderLeftColor:"var(--accent-primary)",color:"var(--text-primary)"},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-primary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:"shrink-0",children:[e.jsx("rect",{x:"3",y:"4",width:"7",height:"16",rx:"1"}),e.jsx("rect",{x:"14",y:"4",width:"7",height:"16",rx:"1"}),e.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"22",strokeDasharray:"2 2"})]}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"font-semibold",children:"Live mirror — not interactive."})," ",e.jsxs("span",{style:{color:"var(--text-dim)"},children:["Tap and type directly in the ",t," window."]})]})]})}const mA=Object.freeze(Object.defineProperty({__proto__:null,NativeMirrorNotice:Cg},Symbol.toStringTag,{value:"Module"}));function Ca(t){const s=t.replace(/\s*\[[^\]]*\]\s*$/,""),n=s.indexOf(" - ");return n===-1?{pageName:null,stateName:s}:{pageName:s.slice(0,n),stateName:s.slice(n+3)}}function Tg(t){return La(t)?t.componentName??Ca(t.name).pageName:Ca(t.name).pageName}function Go(t){return Ca(t.name).stateName}function Pg({isCollapsed:t,onToggle:s}){return e.jsx("button",{onClick:s,className:`p-1.5 rounded transition-colors cursor-pointer ${t?"text-white bg-[#666] hover:bg-[#777]":"text-gray-500 hover:text-gray-300"}`,title:t?"Show editor":"Hide editor",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t?e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M13 17l5-5-5-5"}),e.jsx("path",{d:"M6 17l5-5-5-5"})]}):e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M11 17l-5-5 5-5"}),e.jsx("path",{d:"M18 17l-5-5 5-5"})]})})})}const fA=Object.freeze(Object.defineProperty({__proto__:null,CollapseToggleButton:Pg},Symbol.toStringTag,{value:"Module"}));function Ta({label:t,value:s,disabled:n,onCommit:r}){const[a,o]=l.useState(String(s));l.useEffect(()=>{o(String(s))},[s]);const i=()=>{const c=Number.parseInt(a,10);if(!Number.isFinite(c)||c<=0){o(String(s));return}c!==s&&r(c)};return e.jsxs("label",{className:`flex items-center gap-0.5 px-1 py-0.5 rounded bg-[#2A2929] text-xs ${n?"opacity-50 cursor-not-allowed":""}`,children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-500 select-none",children:t}),e.jsx("input",{type:"text",inputMode:"numeric",value:a,disabled:n,"aria-label":t==="H"?"Height":"Width",onChange:c=>o(c.target.value.replace(/[^0-9]/g,"")),onBlur:i,onKeyDown:c=>{c.key==="Enter"?(i(),c.target.blur()):c.key==="Escape"&&(o(String(s)),c.target.blur())},className:"w-8 bg-transparent text-gray-200 text-center text-[11px] font-mono focus:outline-none disabled:cursor-not-allowed [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"})]})}const gA=Object.freeze(Object.defineProperty({__proto__:null,DimensionInput:Ta},Symbol.toStringTag,{value:"Module"}));function Og({isFilled:t,onToggle:s}){return e.jsx("button",{onClick:s,className:`p-1.5 rounded transition-colors cursor-pointer ${t?"text-white bg-[#555]":"text-gray-500 hover:text-gray-300"}`,title:t?"Exit fullscreen":"Fill page with preview",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t?e.jsxs(e.Fragment,{children:[e.jsx("polyline",{points:"4 14 10 14 10 20"}),e.jsx("polyline",{points:"20 10 14 10 14 4"}),e.jsx("line",{x1:"14",y1:"10",x2:"21",y2:"3"}),e.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]}):e.jsxs(e.Fragment,{children:[e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("polyline",{points:"9 21 3 21 3 15"}),e.jsx("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),e.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})})})}const bA=Object.freeze(Object.defineProperty({__proto__:null,FillPreviewButton:Og},Symbol.toStringTag,{value:"Module"}));function Ag({previewUrl:t}){return e.jsx("button",{onClick:()=>{t&&window.open(t,"_blank")},className:"p-1.5 rounded text-gray-500 hover:text-gray-300 transition-colors cursor-pointer",title:"Open preview in new window",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})})}const xA=Object.freeze(Object.defineProperty({__proto__:null,OpenInNewTabButton:Ag},Symbol.toStringTag,{value:"Module"}));function Rg(){return e.jsx("button",{onClick:()=>Fa(),className:"p-1.5 rounded text-gray-500 hover:text-gray-300 transition-colors cursor-pointer",title:"Refresh preview","aria-label":"Refresh preview",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"23 4 23 10 17 10"}),e.jsx("polyline",{points:"1 20 1 14 7 14"}),e.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]})})}const yA=Object.freeze(Object.defineProperty({__proto__:null,RefreshPreviewButton:Rg},Symbol.toStringTag,{value:"Module"}));function Eg(t){const s=new Map;for(const n of t){const r=n.url??"Uncategorized",a=s.get(r)??[];a.push(n),s.set(r,a)}return Array.from(s.entries()).map(([n,r])=>({route:n,scenarios:r})).sort((n,r)=>n.route==="Uncategorized"?1:r.route==="Uncategorized"?-1:n.route.localeCompare(r.route))}function yN(t,s){const n=s.trim().toLowerCase();return n?t.filter(r=>{const a=(r.url??"").toLowerCase(),o=r.name.toLowerCase(),i=(r.componentName??"").toLowerCase();return a.includes(n)||o.includes(n)||i.includes(n)}):t}function Mg({tab:t,hasQuery:s}){return s?e.jsx("p",{className:"text-xs text-gray-500 px-2 py-6 text-center",children:"No matches for your search."}):e.jsxs("p",{className:"text-xs text-gray-500 px-2 py-6 text-center",children:["No ",t==="pages"?"pages":"components"," yet."]})}const vA=Object.freeze(Object.defineProperty({__proto__:null,PagePickerEmptyMessage:Mg},Symbol.toStringTag,{value:"Module"}));function Ig({scenario:t,active:s,onClick:n}){const r=t.screenshotPaths[0],a=Go(t);return e.jsxs("button",{onClick:n,className:`w-32 text-left rounded border transition-colors cursor-pointer ${s?"border-[#007a99] bg-[#1a2a30]":"border-[#3d3d3d] bg-[#1a1a1a] hover:border-[#555]"}`,title:t.name,children:[e.jsx("div",{className:"aspect-[4/3] w-full overflow-hidden rounded-t border-b border-[#3d3d3d] bg-[#0f0f0f] flex items-center justify-center",children:r?e.jsx("img",{src:at(r),alt:t.name,className:"w-full h-full object-cover"}):e.jsx("span",{className:"text-[10px] text-gray-600",children:"No screenshot"})}),e.jsx("div",{className:"px-2 py-1 text-[11px] text-gray-200 truncate",children:a})]})}const jA=Object.freeze(Object.defineProperty({__proto__:null,PagePickerScenarioThumbnail:Ig},Symbol.toStringTag,{value:"Module"}));function Dg({group:t,currentSlug:s,onSelect:n}){const r=t.scenarios[0]?Tg(t.scenarios[0]):null;return e.jsxs("div",{className:"mb-4 last:mb-0",children:[e.jsxs("div",{className:"flex items-baseline gap-1.5 mb-1.5 px-1",children:[e.jsx("span",{className:"text-xs font-semibold text-gray-200 truncate",children:r??t.route}),r?e.jsx("span",{className:"text-[10px] text-gray-500 font-mono truncate",children:t.route}):null]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.scenarios.map(a=>e.jsx(Ig,{scenario:a,active:a.slug===s,onClick:()=>n(a.slug)},a.slug))})]})}const wA=Object.freeze(Object.defineProperty({__proto__:null,PagePickerRouteSection:Dg},Symbol.toStringTag,{value:"Module"}));function Pa({label:t,active:s,count:n,onClick:r}){return e.jsxs("button",{onClick:r,className:`flex items-center gap-1.5 px-2 py-1 rounded text-[10px] font-semibold tracking-wider cursor-pointer transition-colors ${s?"text-white bg-[#3a3a3a]":"text-gray-500 hover:text-gray-300"}`,children:[t,e.jsx("span",{className:`text-[10px] font-mono px-1 rounded ${s?"bg-[#555] text-gray-200":"bg-[#2a2a2a] text-gray-500"}`,children:n})]})}const _A=Object.freeze(Object.defineProperty({__proto__:null,PagePickerTabButton:Pa},Symbol.toStringTag,{value:"Module"}));function Lg({scenarioGroups:t,currentSlug:s,onSelect:n,onClose:r,triggerRef:a}){const[o,i]=l.useState("pages"),[c,d]=l.useState(""),u=l.useRef(null),h=l.useRef(null);l.useEffect(()=>{var x;(x=h.current)==null||x.focus()},[]),xo(u,r,a);const p=l.useMemo(()=>t.flatMap(x=>x.scenarios),[t]),m=l.useMemo(()=>yN(p,c),[p,c]),f=l.useMemo(()=>m.filter(Wn),[m]),b=l.useMemo(()=>m.filter(La),[m]),g=o==="pages"?f:b,v=l.useMemo(()=>Eg(g),[g]);return e.jsxs("div",{ref:u,className:"absolute top-full left-0 mt-1 bg-[#222] border border-[#3d3d3d] rounded-lg shadow-2xl z-50 w-[560px] max-h-[480px] flex flex-col",role:"dialog",children:[e.jsxs("div",{className:"flex items-center border-b border-[#3d3d3d] px-2 py-1.5 gap-2",children:[e.jsx(Pa,{label:"PAGES",active:o==="pages",count:f.length,onClick:()=>i("pages")}),e.jsx(Pa,{label:"COMPONENTS",active:o==="components",count:b.length,onClick:()=>i("components")}),e.jsx("div",{className:"flex-1"}),e.jsx("input",{ref:h,value:c,onChange:x=>d(x.target.value),placeholder:"Search…",className:"w-48 px-2 py-1 text-xs bg-[#1a1a1a] border border-[#3d3d3d] rounded text-gray-200 focus:outline-none focus:border-[#007a99]"}),e.jsx("button",{onClick:r,"aria-label":"Close",className:"p-1 text-gray-500 hover:text-gray-200 cursor-pointer",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),e.jsx("div",{className:"overflow-y-auto p-3 flex-1 min-h-0",children:v.length===0?e.jsx(Mg,{tab:o,hasQuery:c.trim().length>0}):v.map(x=>e.jsx(Dg,{group:x,currentSlug:s,onSelect:y=>{n(y),r()}},x.route))})]})}const kA=Object.freeze(Object.defineProperty({__proto__:null,PagePickerDropdown:Lg},Symbol.toStringTag,{value:"Module"}));function Fg(){return e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),e.jsx("path",{d:"M14 3v6h6"})]})}function zg(){return e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1"})]})}function Uo({className:t}){return e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:t??"opacity-70 shrink-0 text-gray-400",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})}const SA=Object.freeze(Object.defineProperty({__proto__:null,ComponentGlyph:zg,DropdownChevron:Uo,PageGlyph:Fg},Symbol.toStringTag,{value:"Module"}));function $g({currentScenario:t,isOpen:s,onClick:n,buttonRef:r}){const a=t?La(t):!1,o=(t==null?void 0:t.screenshotPaths[0])??null,i=t?a?t.componentName??t.name:Tg(t)??t.url??t.name:"Select a page";return e.jsxs("button",{ref:r,onClick:n,className:`flex items-center gap-1.5 max-w-[260px] pl-0.5 pr-1.5 py-0.5 rounded transition-colors cursor-pointer text-xs ${t?"text-gray-200":"text-gray-500"} ${s?"bg-[#555]":"hover:bg-[#4a4a4a]"}`,title:i,"aria-haspopup":"menu","aria-expanded":s,children:[e.jsxs("span",{className:"flex items-center gap-0.5 bg-[#1f1f1f] border border-[#3d3d3d] rounded p-0.5",children:[e.jsx("span",{className:"w-6 h-4 overflow-hidden rounded-sm bg-[#0f0f0f] flex items-center justify-center text-gray-500",children:o?e.jsx("img",{src:at(o),alt:"",className:"w-full h-full object-cover"}):a?e.jsx(zg,{}):e.jsx(Fg,{})}),e.jsx(Uo,{})]}),e.jsx("span",{className:"truncate",children:i})]})}const NA=Object.freeze(Object.defineProperty({__proto__:null,PagePill:$g},Symbol.toStringTag,{value:"Module"}));function vN(t,s){const n=t.url??"Uncategorized",r=s.find(a=>a.route===n);return(r==null?void 0:r.scenarios)??[t]}function Bg({scenario:t,active:s,onClick:n}){const r=t.screenshotPaths[0];return e.jsxs("button",{onClick:n,className:`flex items-center gap-2 w-full px-2 py-1.5 text-left transition-colors cursor-pointer ${s?"bg-[#1a2a30]":"hover:bg-[#2a2a2a]"}`,children:[e.jsx("div",{className:"w-10 h-7 shrink-0 rounded overflow-hidden border border-[#3d3d3d] bg-[#0f0f0f] flex items-center justify-center",children:r?e.jsx("img",{src:at(r),alt:"",className:"w-full h-full object-cover"}):null}),e.jsx("div",{className:`text-xs truncate flex-1 min-w-0 ${s?"text-white":"text-gray-200"}`,children:Go(t)})]})}const CA=Object.freeze(Object.defineProperty({__proto__:null,StatesDropdownRow:Bg},Symbol.toStringTag,{value:"Module"}));function Hg({currentScenario:t,scenarioGroups:s,onSelect:n,onCreateNew:r,onClose:a,triggerRef:o}){const i=l.useRef(null);xo(i,a,o);const c=l.useMemo(()=>vN(t,s),[t,s]);return e.jsxs("div",{ref:i,className:"absolute top-full right-0 mt-1 bg-[#222] border border-[#3d3d3d] rounded-lg shadow-2xl z-50 w-72 max-h-[400px] flex flex-col",role:"menu",children:[e.jsx("div",{className:"overflow-y-auto py-1 flex-1 min-h-0",children:c.map(d=>e.jsx(Bg,{scenario:d,active:d.slug===t.slug,onClick:()=>{n(d.slug),a()}},d.slug))}),e.jsx("button",{onClick:()=>{r(),a()},className:"border-t border-[#3d3d3d] px-3 py-2 text-left text-[11px] font-mono tracking-wide text-[var(--accent-active)] hover:bg-[var(--accent-active)]/10 cursor-pointer",children:"+ CREATE NEW STATE"})]})}const TA=Object.freeze(Object.defineProperty({__proto__:null,StatesDropdown:Hg},Symbol.toStringTag,{value:"Module"}));function Wg({label:t,disabled:s,isOpen:n,onClick:r,buttonRef:a}){return e.jsxs("button",{ref:a,onClick:()=>{s||r()},disabled:s,className:`flex items-center gap-1.5 max-w-[200px] h-7 px-2.5 rounded transition-colors text-xs ${s?"bg-[#3a3a3a] text-gray-600 cursor-not-allowed":n?"bg-[#444] text-gray-200 cursor-pointer":"bg-[#3a3a3a] text-gray-200 hover:bg-[#444] cursor-pointer"}`,title:s?"No active state":t,"aria-haspopup":"menu","aria-expanded":n,children:[e.jsx("span",{className:"truncate",children:t}),e.jsx(Uo,{className:"opacity-70 shrink-0"})]})}const PA=Object.freeze(Object.defineProperty({__proto__:null,StatesPillButton:Wg},Symbol.toStringTag,{value:"Module"}));function qg({viewport:t,isActive:s,onSelect:n}){return e.jsx("button",{onClick:n,className:`p-1 rounded transition-colors cursor-pointer ${s?"text-white bg-[#555]":"text-gray-500 hover:text-gray-300"}`,title:`${t.name} (${t.width}×${t.height})`,children:e.jsx(Qp,{name:t.name})})}const OA=Object.freeze(Object.defineProperty({__proto__:null,ViewportPresetButton:qg},Symbol.toStringTag,{value:"Module"}));function Gg({viewports:t,active:s,onChange:n,currentWidth:r,currentHeight:a,previewUrl:o,isCollapsed:i,onToggleCollapsed:c,isFilled:d,onToggleFilled:u,containerWidth:h,containerHeight:p,onCustomSizeChange:m,currentScenario:f,scenarioGroups:b,onShowScenarioPreview:g,onCreateStateRequest:v,isNarrow:x=!1}){const[y,w]=l.useState(!1),[j,k]=l.useState(!1),S=l.useRef(null),N=l.useRef(null),T=d&&h?Math.round(h):r,A=d&&p?Math.round(p):a,_=f?Go(f):"No state",M=!f;return e.jsxs("div",{className:"bg-[#2d2d2d] border-b border-[#3d3d3d] shrink-0 h-10 grid grid-cols-[1fr_auto_1fr] items-center px-2",children:[e.jsx("div",{className:"justify-self-start",children:!x&&e.jsx(Pg,{isCollapsed:i,onToggle:c})}),e.jsxs("div",{className:`flex items-center gap-2 justify-self-center ${x?"min-w-0 overflow-x-auto":""}`,children:[e.jsxs("div",{className:"relative flex items-center bg-[#3a3a3a] rounded h-7 px-1 gap-1",children:[e.jsx($g,{currentScenario:f,isOpen:y,onClick:()=>{w(I=>!I),k(!1)},buttonRef:S}),y&&e.jsx(Lg,{scenarioGroups:b,currentSlug:(f==null?void 0:f.slug)??null,onSelect:g,onClose:()=>w(!1),triggerRef:S}),e.jsx("span",{className:"w-px h-5 bg-[#555] mx-1 shrink-0","aria-hidden":"true"}),t.map(I=>e.jsx(qg,{viewport:I,isActive:!d&&s===I.name,onSelect:()=>{d&&u(),n(I.name)}},I.name)),e.jsx(Og,{isFilled:d,onToggle:u}),e.jsx(Ta,{label:"H",value:A,disabled:d,onCommit:I=>m(r,I)}),e.jsx(Ta,{label:"W",value:T,disabled:d,onCommit:I=>m(I,a)}),e.jsx(Rg,{}),e.jsx(Ag,{previewUrl:o})]}),e.jsx("div",{className:"flex items-center gap-2 shrink-0",children:e.jsxs("div",{className:"relative",children:[e.jsx(Wg,{label:_,disabled:M,isOpen:j,onClick:()=>{k(I=>!I),w(!1)},buttonRef:N}),j&&f&&e.jsx(Hg,{currentScenario:f,scenarioGroups:b,onSelect:g,onCreateNew:v,onClose:()=>k(!1),triggerRef:N})]})})]}),e.jsx("div",{"aria-hidden":"true"})]})}const AA=Object.freeze(Object.defineProperty({__proto__:null,NavigationBar:Gg},Symbol.toStringTag,{value:"Module"}));function Ug(){return e.jsxs("div",{style:{padding:"3rem 1rem",textAlign:"center",color:"var(--text-muted)"},children:[e.jsx("h2",{style:{fontSize:"1.125rem",fontWeight:600,color:"var(--text-secondary)",margin:"0 0 0.5rem 0"},children:"No plan loaded"}),e.jsx("p",{style:{margin:0,fontSize:"0.875rem"},children:"Ask the AI to draft a plan, or pick one from the Plan tab."})]})}const RA=Object.freeze(Object.defineProperty({__proto__:null,PlanPreviewEmptyState:Ug},Symbol.toStringTag,{value:"Module"}));function Vg({title:t}){return e.jsx("h1",{style:{fontSize:"1.5rem",fontWeight:600,color:"var(--text-primary)",margin:"0 0 1rem 0",paddingBottom:"0.75rem",borderBottom:"1px solid var(--border-subtle)"},children:t})}const EA=Object.freeze(Object.defineProperty({__proto__:null,PlanPreviewHeader:Vg},Symbol.toStringTag,{value:"Module"})),cl={prompt:null,title:null};function Yg(){const[t,s]=l.useState(cl),[n,r]=l.useState(!0);return l.useEffect(()=>{let a=!1;return(async()=>{try{const i=await(await fetch("/api/prompt")).json();a||s({prompt:i.prompt??null,title:i.title??null})}catch{a||s(cl)}finally{a||r(!1)}})(),()=>{a=!0}},[]),{...t,loading:n}}function Kg(){const{prompt:t,title:s,loading:n}=Yg();return e.jsx("div",{className:"flex-1 flex flex-col min-w-0 overflow-auto",style:{background:"var(--bg-deep)"},children:e.jsx("div",{style:{padding:"1.5rem 2rem",maxWidth:"880px",width:"100%",margin:"0 auto"},children:n?null:t?e.jsxs(e.Fragment,{children:[s?e.jsx(Vg,{title:s}):null,e.jsx(vt,{children:t})]}):e.jsx(Ug,{})})})}const MA=Object.freeze(Object.defineProperty({__proto__:null,PlanPreviewPanelView:Kg},Symbol.toStringTag,{value:"Module"}));function Jg({message:t}){return e.jsx("span",{style:{color:"var(--text-dim)"},children:t})}const IA=Object.freeze(Object.defineProperty({__proto__:null,PreviewEmptyState:Jg},Symbol.toStringTag,{value:"Module"}));function Xg({hasDevServerConfigured:t}){const s=t?"Starting your app…":"Your app will display here once set up";return e.jsx("div",{"data-testid":"preview-waiting-placeholder",style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",color:"var(--text-dim)"},children:e.jsx("span",{children:s})})}const DA=Object.freeze(Object.defineProperty({__proto__:null,PreviewWaitingPlaceholder:Xg},Symbol.toStringTag,{value:"Module"}));function jN(t,s,n){const r=[t];return s&&r.push(`reload:${s}`),n&&r.push(`command:${n}`),r.join("::")}function Qg({currentWidth:t,currentHeight:s,isFilled:n,scale:r}){const a=e.jsx("div",{className:"w-full h-full border border-dashed rounded flex items-center justify-center text-center px-6",style:{borderColor:"var(--border-default)",background:"var(--bg-surface)",color:"var(--text-dim)"},children:e.jsxs("div",{className:"text-sm leading-relaxed",children:[e.jsx("div",{className:"font-medium",children:"Live Preview unavailable"}),e.jsxs("div",{className:"opacity-70 mt-1",children:[t,"×",s]})]})});return n?a:e.jsx("div",{className:"shadow-[0_10px_30px_rgba(0,0,0,0.45)]",style:{width:t,height:s,transform:r<1?`scale(${r})`:void 0,transformOrigin:"center center",flexShrink:0},children:a})}const Zg=l.forwardRef(function({currentHeight:s,currentWidth:n,isFilled:r,previewUrl:a,scale:o,reloadNonce:i,commandNonce:c,onLoad:d,onError:u},h){if(It())return e.jsx(Qg,{currentWidth:n,currentHeight:s,isFilled:r,scale:o});const p=jN(a,i,c),m=()=>{u&&u("iframe error event")};return r?e.jsx("iframe",{ref:h,src:a,title:"Live Preview",className:"w-full h-full border-none",style:{background:"var(--bg-deep)"},onLoad:d,onError:m},p):e.jsx("div",{className:"shadow-[0_10px_30px_rgba(0,0,0,0.45)]",style:{width:n,height:s,transform:o<1?`scale(${o})`:void 0,transformOrigin:"center center",flexShrink:0},children:e.jsx("iframe",{ref:h,src:a,title:"Live Preview",style:{width:"100%",height:"100%",border:"none",background:"var(--bg-deep)"},onLoad:d,onError:m},p)})}),LA=Object.freeze(Object.defineProperty({__proto__:null,EmbeddedPreviewPlaceholder:Qg,PreviewFrame:Zg},Symbol.toStringTag,{value:"Module"}));function wN(t,s){const n=l.useRef(!1);l.useEffect(()=>{n.current||t&&t.startCommand&&(t.intendedRunning||t.status==="stopped"&&(n.current=!0,s()))},[t,s])}function _N(t,s){const[n,r]=l.useState(!1),a=l.useCallback(()=>{n?(r(!1),t.deactivate(),t.clearSelection()):(r(!0),t.activate())},[n,t]);return l.useEffect(()=>{n&&(r(!1),t.clearSelection())},[s]),{isActive:n,toggle:a}}function kN(t,s){const[n,r]=l.useState(t),a=l.useRef(null);return l.useEffect(()=>{if(t!==!1){a.current!==null&&(window.clearTimeout(a.current),a.current=null),r(t);return}if(a.current===null)return a.current=window.setTimeout(()=>{a.current=null,r(!1)},s),()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null)}},[t,s]),n}function SN(t,s=!0,n="running"){const r=l.useRef(null),a=l.useRef(!1),[o,i]=l.useState(0),c=l.useRef(null);l.useEffect(()=>{t!=null&&(r.current!=null&&t!==r.current?(a.current=!1,i(h=>h+1)):r.current==null&&(a.current?s&&Qi(t,c.current):i(h=>h+1)),r.current=t)},[t,s]);const d=l.useCallback(h=>{a.current=!0,h&&(c.current=h),s&&t!=null&&Qi(t,h??c.current)},[t,s]),u=l.useCallback(h=>{s&&$k(h)},[s]);return{reloadNonce:o,handleIframeLoad:d,handleIframeError:u}}const NN=1500,CN=2e3,TN=3e3,PN=2;function ON(){return typeof window>"u"?!1:window.location.pathname.startsWith("/scenario/")?!0:It()}function AN(t,s=!1){const n=ON(),[r,a]=l.useState(n?!0:null),[o,i]=l.useState(null),[c,d]=l.useState(0),[u,h]=l.useState(0),p=l.useRef(null),m=l.useRef(null),f=l.useRef(null),b=l.useRef(!1),g=l.useRef(t),v=l.useRef(s);l.useEffect(()=>{g.current=t},[t]),l.useEffect(()=>{v.current=s},[s]);const x=l.useCallback(()=>{m.current!=null&&(clearTimeout(m.current),m.current=null)},[]),y=l.useCallback(async()=>{if(b.current||v.current)return;const S=g.current;if(!S)return;f.current&&f.current.abort();const N=new AbortController;f.current=N;const T=setTimeout(()=>N.abort(),TN);let A=!1;try{await fetch(S,{mode:"no-cors",cache:"no-store",signal:N.signal}),A=!0}catch{A=!1}finally{clearTimeout(T)}if(!b.current){if(i(Date.now()),A){if(d(0),p.current!==!0){const _=p.current===!1;p.current=!0,a(!0),_&&h(M=>M+1)}}else d(_=>{const M=_+1;return M>=PN&&p.current!==!1&&(p.current=!1,a(!1)),M});w()}},[]),w=l.useCallback(()=>{if(b.current)return;x();const S=p.current===!0?CN:NN;m.current=setTimeout(()=>{m.current=null,y()},S)},[x,y]),j=l.useCallback(()=>{x(),y()},[x,y]);l.useEffect(()=>{if(!n)return b.current=!1,y(),()=>{b.current=!0,x(),f.current&&(f.current.abort(),f.current=null)}},[y,x,n]),l.useEffect(()=>{n||y()},[t,y,n]);const k=l.useRef(s);return l.useEffect(()=>{if(n)return;const S=k.current;k.current=s,S&&!s&&y()},[s,y,n]),{healthy:r,lastProbeAt:o,failedProbeCount:c,reloadNonce:u,invalidate:j}}const dl={loaded:!1,stalledRequests:0,fastRequests:0,longestStallMs:0,tailReadFailedReason:null};function RN(t){const{active:s,trigger:n}=t,[r,a]=l.useState(dl),o=l.useRef(null),i=l.useCallback(()=>{var d;(d=o.current)==null||d.abort();const c=new AbortController;o.current=c,fetch("/api/dev-server-recent-requests",{signal:c.signal}).then(u=>{if(!u.ok)throw new Error(`HTTP ${u.status}`);return u.json()}).then(u=>{if(c.signal.aborted)return;const p=(u.stalls??[]).reduce((m,f)=>Math.max(m,f.durationMs??0),0);a({loaded:!0,stalledRequests:u.stalledRequests??0,fastRequests:u.fastRequests??0,longestStallMs:p,tailReadFailedReason:u.tailReadFailedReason??null})}).catch(u=>{c.signal.aborted||a({loaded:!0,stalledRequests:0,fastRequests:0,longestStallMs:0,tailReadFailedReason:u instanceof Error?u.message:"fetch failed"})})},[]);return l.useEffect(()=>{var c;if(!s){a(dl),(c=o.current)==null||c.abort();return}return i(),()=>{var d;(d=o.current)==null||d.abort()}},[s,n,i]),r}function EN(t){return!t||!t.loaded||t.tailReadFailedReason?null:t.stalledRequests>0?`Recent requests took up to ${Math.max(1,Math.round(t.longestStallMs/1e3))}s — the dev server is responding, just slowly. Check the dev-server log for what's blocking the render.`:t.fastRequests===0?"No recent activity in the dev-server log — the dev server may have stopped accepting connections. Restart it if this persists.":null}function MN({liveIframeHealthy:t,previewReachable:s}){return t===!0||s===!0}function IN({hasDevServerConfigured:t,hasServed:s}){return!t||s}const DN=2e3;function LN(t,s){const[n,r]=l.useState(0),a=l.useRef(t),o=l.useRef(s),i=l.useRef(0);return l.useEffect(()=>{const c=a.current,d=o.current;if(a.current=t,o.current=s,!(s===!1)||!(t===!0)||!(c===!1&&t===!0)&&!(d===!0&&s===!1))return;const f=Date.now();f-i.current<DN||(i.current=f,r(b=>b+1))},[t,s]),n}const mn={windowMs:1e4,threshold:4,ringBufferSize:16};function FN({pidNonce:t,probeNonce:s,draftNonce:n,windowMs:r=mn.windowMs,threshold:a=mn.threshold}){const[o,i]=l.useState(!1),[c,d]=l.useState([]),[u,h]=l.useState(0),p=l.useRef(!1),m=l.useRef(t),f=l.useRef(s),b=l.useRef(n),g=l.useCallback(x=>{const y=Date.now(),w=y-r;let j=[];d(S=>{const N=S.filter(T=>T.timestampMs>=w);return N.push({reason:x,timestampMs:y}),N.length>mn.ringBufferSize&&N.splice(0,N.length-mn.ringBufferSize),j=N,N});const k=j.filter(S=>S.timestampMs>=w).length;if(!p.current&&k>=a){p.current=!0,i(!0);return}p.current||h(S=>S+1)},[r,a]);l.useEffect(()=>{t!==m.current&&(m.current=t,g("pid"))},[t,g]),l.useEffect(()=>{s!==f.current&&(f.current=s,g("probe"))},[s,g]),l.useEffect(()=>{n!==b.current&&(b.current=n,g("draft"))},[n,g]);const v=l.useCallback(()=>{p.current=!1,i(!1),d([]),h(x=>x+1)},[]);return{tripped:o,recentReloads:c,gatedNonce:u,reset:v}}function zN(t,s,n=Fa){const r=l.useRef(void 0);l.useEffect(()=>{if(!s){r.current=t;return}if(typeof t=="number"){if(r.current===void 0){r.current=t;return}t>r.current&&(r.current=t,n())}},[t,s,n])}const ul=20,$N="codeyam-error-capture";function BN(t,s=0){const[n,r]=l.useState([]),a=l.useCallback(()=>r([]),[]);return l.useEffect(()=>{r([])},[s]),l.useEffect(()=>{function o(i){const c=i.data;if(!c||c.source!==$N)return;const d=t.current;if(d&&i.source!==d.contentWindow)return;const u=c.payload;!u||typeof u!="object"||!u.dedupeKey||r(h=>{const p=h.findIndex(f=>f.dedupeKey===u.dedupeKey);if(p>=0){const f=h.slice();return f[p]={...f[p],count:f[p].count+1,timestampMs:u.timestampMs},f}const m=[...h,{...u,count:1}];return m.length>ul?m.slice(m.length-ul):m})}return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},[t]),{errors:n,clear:a}}const Gr=[500,1e3,2e3];async function HN(t){try{const n=await(await fetch(`/api/probe-url?url=${encodeURIComponent(t)}`)).json();return{status:typeof(n==null?void 0:n.status)=="number"?n.status:null}}catch{return{status:null}}}async function WN(){try{const s=await(await fetch("/api/dev-server-log/slice?lines=40")).json();return Array.isArray(s==null?void 0:s.lines)?s.lines:[]}catch{return[]}}function qN(t,s){const[n,r]=l.useState({status:null,clickThroughBroken:!1,logLines:[],loading:!1});return l.useEffect(()=>{if(!t){r({status:null,clickThroughBroken:!1,logLines:[],loading:!1});return}let a=!1;return r({status:null,clickThroughBroken:!1,logLines:[],loading:!0}),(async()=>{const o=1+Gr.length;let i=null;for(let d=0;d<o;d++){if(a)return;const{status:u}=await HN(t);if(a)return;if(i=u,u===null||u<500){r({status:u,clickThroughBroken:!1,logLines:[],loading:!1});return}d<Gr.length&&await new Promise(h=>setTimeout(h,Gr[d]))}const c=await WN();a||r({status:i,clickThroughBroken:!0,logLines:c,loading:!1})})(),()=>{a=!0}},[t,s]),n}function eb({url:t,status:s,logLines:n,onRetry:r}){return e.jsx("div",{role:"alert","data-testid":"iframe-click-through-error-card",className:"absolute inset-0 z-20 flex items-center justify-center bg-zinc-950/85 p-6",children:e.jsxs("div",{className:"max-w-2xl w-full rounded-md border border-red-700 bg-zinc-900 text-zinc-100 shadow-xl",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-red-800 flex justify-between items-start",children:[e.jsxs("div",{className:"flex-1 min-w-0 pr-4",children:[e.jsxs("div",{className:"text-sm font-semibold text-red-300",children:["Scenario render failed (HTTP ",s,")"]}),e.jsx("div",{className:"mt-1 text-xs text-zinc-400 break-all",children:t}),e.jsx("div",{className:"mt-2 text-xs text-zinc-300",children:"The iframe URL returned a server error. This is a bug — capture and click should always agree. Check the dev-server log below and refresh once the underlying error is fixed."})]}),e.jsx("button",{type:"button",onClick:r,className:"flex-shrink-0 px-2.5 py-1 text-xs rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:"Retry"})]}),e.jsx("div",{className:"px-5 py-4 max-h-72 overflow-auto font-mono text-[11px] leading-snug text-zinc-300 whitespace-pre-wrap",children:n.length>0?n.join(`
174
+ `):e.jsxs("span",{className:"text-zinc-500 italic",children:["No dev-server log lines available — see"," ",e.jsx("code",{children:".codeyam/logs/dev-server.log"}),"."]})})]})})}const FA=Object.freeze(Object.defineProperty({__proto__:null,IframeClickThroughErrorCard:eb},Symbol.toStringTag,{value:"Module"}));function GN(t){if(t===null||!t.startCommand)return{isRestarting:!1,isFailed:!1,isStarting:!1,isStopped:!1};const s=t.status==="failed",n=!s&&t.status!=="running"&&t.intendedRunning&&(t.restartCount??0)>0,r=!s&&t.intendedRunning&&t.status!=="running"&&(t.restartCount??0)===0,a=t.status==="stopped"&&!t.intendedRunning;return{isRestarting:n,isFailed:s,isStarting:r,isStopped:a}}const UN=20;function VN(t){const{hasDevServerConfigured:s,probeHealthy:n,backendIframeHealthy:r,isStarting:a,isRestarting:o,isFailed:i,isStopped:c,isPrePrototype:d,withinStartupGrace:u,previewReachable:h,hasEverServed:p}=t;return s?i?"crashed":r===!0||h===!0||n===!0&&r!==!1?null:d?"scaffolding":c?p?"stopped":null:o?"restarting":a||u||!p?null:n===!1?"reconnecting":r===!1&&n===!0?"disconnected":n===null?"probing":"reconnecting":null}function YN(t){return t===null||t.status!=="running"?!1:t.liveIframeHealthy!==!1}const KN=5,JN=3;function XN(t,s){return t===null||t<=0?!1:t<=(s==="backend"?JN:KN)}const hl="Setting up your project",pl="Preparing your project — the preview will appear once it's ready.",QN={1:"Aligning on the plan with you.",2:"Aligning on the plan with you.",3:"Aligning on the plan with you.",4:"Preparing the project environment.",5:"Wiring routes and seeding sample data."},ZN={1:"Aligning on the plan with you.",2:"Aligning on the plan with you.",3:"Preparing the project environment."};function e2(t,s){return t===null?{title:hl,body:pl}:{title:hl,body:(s==="backend"?ZN:QN)[t]??pl}}function tb({restartCount:t}){return e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-12 h-12 border-4 border-primary/20 border-t-primary rounded-full animate-spin"}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-[10px] font-bold text-primary",children:t>0?`#${t}`:""})]})}const zA=Object.freeze(Object.defineProperty({__proto__:null,RestartSpinner:tb},Symbol.toStringTag,{value:"Module"})),t2={probing:{title:"Checking Live Preview",body:"Probing the dev server before showing the iframe…",spinner:!0},starting:{title:"Starting Dev Server",body:"Waiting for the development server to start…",spinner:!0},restarting:{title:"Dev Server Restarting",body:"The Live Preview server crashed unexpectedly. CodeYam is automatically recovering it…",spinner:!0},reconnecting:{title:"Reconnecting Live Preview",body:"Waiting for the dev server to respond…",spinner:!0},disconnected:{title:"Preview Disconnected",body:"The dev server is running, but the preview lost its connection after a restart. Reload the preview to reconnect — there's no need to restart the dev server.",spinner:!1},stopped:{title:"Dev Server Not Running",body:"Starting automatically…",spinner:!1},crashed:{title:"Dev Server Crashed",body:"Recovery is taking longer than usual.",spinner:!1},scaffolding:{title:"Setting up your project",body:"Preparing your project — the preview will appear once it's ready.",spinner:!0}};function sb({variant:t,restartCount:s=0,showRetry:n=!1,onRetry:r,bodyOverride:a}){const{title:o,body:i,spinner:c}=t2[t],d=a??i,u=t==="disconnected",h=!!r&&(u||n),p=u?"Reload preview":"Retry now";return e.jsx("div",{"data-testid":"preview-unhealthy-overlay","data-variant":t,className:"absolute inset-0 bg-white/90 dark:bg-gray-900/90 backdrop-blur-sm flex flex-col items-center justify-center z-50 animate-in fade-in duration-300",children:e.jsxs("div",{className:"flex flex-col items-center space-y-4 text-center max-w-md p-6",children:[c?e.jsx(tb,{restartCount:s}):e.jsx("div",{className:"w-12 h-12 rounded-full bg-gray-200 dark:bg-gray-700 flex items-center justify-center",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-6 h-6 text-gray-500 dark:text-gray-400","aria-hidden":"true",children:[e.jsx("rect",{x:"6",y:"5",width:"4",height:"14",rx:"1"}),e.jsx("rect",{x:"14",y:"5",width:"4",height:"14",rx:"1"})]})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:o}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:d})]}),h&&r&&e.jsx("button",{type:"button",onClick:r,className:"mt-2 px-4 py-1.5 text-sm font-medium rounded border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800",children:p})]})})}const $A=Object.freeze(Object.defineProperty({__proto__:null,PreviewUnhealthyOverlay:sb},Symbol.toStringTag,{value:"Module"}));function s2(t){return t.slice().reverse().map(s=>{const n=s.filename!=null?`
175
+ at ${s.filename}${s.lineno!=null?`:${s.lineno}`:""}${s.colno!=null?`:${s.colno}`:""}`:"",r=s.stack?`
176
+ ${s.stack}`:"",a=s.count>1?` (×${s.count})`:"";return`[${s.type}]${a} ${s.message}${n}${r}`}).join(`
177
+
178
+ `)}function n2(t){if(t.length===0)return"no reloads recorded";const s={};for(const n of t)s[n.reason]=(s[n.reason]??0)+1;return Object.entries(s).map(([n,r])=>`${n}×${r}`).join(", ")}function nb({count:t,onExpand:s,onClear:n}){const r=`${t} ${t===1?"Error":"Errors"}`;return e.jsx("div",{"data-testid":"preview-error-badge",className:"absolute bottom-3 right-3 z-50 pointer-events-auto",children:e.jsxs("div",{className:"flex items-center gap-1.5 rounded-full shadow-lg border border-red-300 dark:border-red-800 bg-white dark:bg-gray-900",style:{background:"var(--bg-surface, rgba(255,255,255,0.97))"},children:[e.jsxs("button",{type:"button",onClick:s,"aria-label":`Expand ${r}`,className:"cursor-pointer flex items-center gap-1.5 pl-2.5 pr-2 py-1 text-xs font-medium text-red-700 dark:text-red-300 hover:bg-red-50 dark:hover:bg-red-950/40 rounded-l-full",children:[e.jsx("span",{"aria-hidden":"true",className:"inline-block h-1.5 w-1.5 rounded-full bg-red-600"}),e.jsx("span",{children:r}),e.jsx("span",{"aria-hidden":"true",className:"text-gray-400",children:"›"})]}),e.jsx("button",{type:"button",onClick:n,"aria-label":"Dismiss errors",className:"cursor-pointer px-2 py-1 text-xs text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 rounded-r-full",children:"✕"})]})})}const BA=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorBadge:nb},Symbol.toStringTag,{value:"Module"}));function rb({headline:t,tripped:s,onClear:n,closeAriaLabel:r="Dismiss errors"}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 px-4 py-3 border-b border-red-200 dark:border-red-900",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-red-700 dark:text-red-300",children:t}),e.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:s?"Iframe frozen on its last load attempt. Copy the errors below, fix the code, then click Retry.":"Errors recorded from the running app. Copy them below to share with Claude."})]}),e.jsx("button",{type:"button",onClick:n,className:"cursor-pointer text-xs text-gray-400 hover:text-gray-600 dark:hover:text-gray-200","aria-label":r,children:"✕"})]})}const HA=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorOverlayHeader:rb},Symbol.toStringTag,{value:"Module"}));function ab({error:t,expanded:s,onToggle:n}){return e.jsxs("li",{className:"rounded border border-red-200 dark:border-red-900 bg-red-50/60 dark:bg-red-950/30",children:[e.jsxs("button",{type:"button",onClick:n,className:"w-full flex items-start gap-2 text-left px-2 py-1.5 hover:bg-red-100/60 dark:hover:bg-red-900/30",children:[e.jsx("span",{className:"mt-0.5 text-red-500","aria-hidden":"true",children:s?"▾":"▸"}),e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"font-mono text-[10px] uppercase tracking-wide text-red-500 dark:text-red-400 mr-2",children:t.type}),e.jsx("span",{className:"text-gray-900 dark:text-gray-100 break-words",children:t.message}),t.count>1&&e.jsxs("span",{className:"ml-2 text-gray-500",children:["×",t.count]}),t.filename&&e.jsxs("span",{className:"block text-[11px] text-gray-500 mt-0.5 truncate",children:[t.filename,t.lineno!=null?`:${t.lineno}`:"",t.colno!=null?`:${t.colno}`:""]})]})]}),s&&t.stack&&e.jsx("pre",{className:"px-3 pb-2 text-[11px] font-mono text-gray-700 dark:text-gray-300 whitespace-pre-wrap break-words",children:t.stack})]})}const WA=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorRow:ab},Symbol.toStringTag,{value:"Module"}));function ob({errors:t,emptyHint:s}){const[n,r]=l.useState(null);return t.length===0?e.jsx("ul",{className:"flex-1 overflow-auto px-2 py-2 space-y-1 text-xs",children:e.jsx("li",{className:"text-gray-500 px-2 py-3",children:s??"No runtime errors captured yet."})}):e.jsx("ul",{className:"flex-1 overflow-auto px-2 py-2 space-y-1 text-xs",children:t.slice().reverse().map(a=>e.jsx(ab,{error:a,expanded:n===a.dedupeKey,onToggle:()=>r(n===a.dedupeKey?null:a.dedupeKey)},a.dedupeKey))})}const qA=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorList:ob},Symbol.toStringTag,{value:"Module"}));function ib({canCopy:t,reasonsSummary:s,copyState:n,onCopy:r,onCopyForClaude:a,onRetry:o}){return e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-3 py-2 border-t border-red-200 dark:border-red-900 bg-gray-50 dark:bg-gray-900/40",children:[e.jsx("button",{type:"button",onClick:r,disabled:!t,className:"px-2.5 py-1 text-xs rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50 cursor-pointer disabled:cursor-not-allowed",children:"Copy errors"}),e.jsx("button",{type:"button",onClick:a,disabled:!t,className:"px-2.5 py-1 text-xs rounded bg-red-600 text-white hover:bg-red-700 disabled:opacity-50 cursor-pointer disabled:cursor-not-allowed",children:"Copy and ask Claude"}),e.jsx("button",{type:"button",onClick:o,className:"px-2.5 py-1 text-xs rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:"Retry"}),e.jsxs("span",{className:"ml-auto text-[11px] text-gray-500",children:["Reloads in last 10s: ",s,n==="copied"&&e.jsx("span",{className:"ml-2 text-emerald-600",children:"copied ✓"}),n==="failed"&&e.jsx("span",{className:"ml-2 text-red-500",children:"copy blocked"})]})]})}const GA=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorOverlayFooter:ib},Symbol.toStringTag,{value:"Module"})),r2=`Fix this error in the live preview. Here is what the captured runtime error reported:
179
+
180
+ `;function lb({tripped:t,errors:s,recentReloads:n,serverHealthy:r,onRetry:a,onClear:o}){const[i,c]=l.useState("idle"),[d,u]=l.useState(!0),h=l.useMemo(()=>s2(s),[s]),p=l.useMemo(()=>n2(n),[n]);if(l.useEffect(()=>{s.length===0&&u(!0)},[s.length]),!t&&s.length===0)return null;const m=r&&!t,f=m&&d&&s.length>0,b=t?`Live Preview paused — ${s.length} error${s.length===1?"":"s"} captured`:`${s.length} runtime error${s.length===1?"":"s"} captured`;async function g(v){const x=await qy(v+h);c(x?"copied":"failed"),setTimeout(()=>c("idle"),1500)}return f?e.jsx("div",{"data-testid":"preview-error-overlay","data-tripped":"false","data-collapsed":"true",className:"absolute inset-0 z-50 pointer-events-none",children:e.jsx(nb,{count:s.length,onExpand:()=>u(!1),onClear:o})}):e.jsx("div",{"data-testid":"preview-error-overlay","data-tripped":t?"true":"false","data-collapsed":"false",className:"absolute inset-0 z-50 flex flex-col items-stretch p-4 pointer-events-none",children:e.jsxs("div",{className:"mx-auto w-full max-w-2xl rounded-lg shadow-lg pointer-events-auto flex flex-col",style:{background:"var(--bg-surface, rgba(255,255,255,0.97))",border:"1px solid var(--border-default, #ef4444)",maxHeight:"100%"},children:[e.jsx(rb,{headline:b,tripped:t,onClear:m?()=>u(!0):o,closeAriaLabel:m?"Minimize errors":"Dismiss errors"}),e.jsx(ob,{errors:s,emptyHint:t?`Breaker tripped before any runtime error was reported. Reasons in window: ${p}.`:null}),e.jsx(ib,{canCopy:s.length>0,reasonsSummary:p,copyState:i,onCopy:()=>g(""),onCopyForClaude:()=>g(r2),onRetry:a})]})})}const UA=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorOverlay:lb},Symbol.toStringTag,{value:"Module"}));function cb({previewUrl:t}){const s=l.useMemo(()=>{try{return new URL(t,window.location.origin).searchParams.get("_codeyam_scenario")}catch{return null}},[t]);return s?e.jsxs("div",{className:"absolute top-2 left-2 z-30 flex items-center gap-1.5 px-2 py-1 rounded bg-black/60 backdrop-blur-sm border border-white/10 shadow-lg pointer-events-none select-none",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse"}),e.jsxs("span",{className:"text-[10px] font-medium text-white/90 tracking-wide uppercase",children:["Scenario: ",s]})]}):null}const VA=Object.freeze(Object.defineProperty({__proto__:null,ActiveScenarioOverlay:cb},Symbol.toStringTag,{value:"Module"}));function db(){return e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-800",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-red-500 animate-pulse"}),e.jsx("h3",{className:"text-sm font-bold text-gray-900 dark:text-gray-100 uppercase tracking-tight",children:"Dev Server Crash Recovery Failed"})]}),e.jsx("div",{className:"text-[10px] text-gray-500 dark:text-gray-400 font-medium",children:"LAST 50 LOG LINES"})]})}const YA=Object.freeze(Object.defineProperty({__proto__:null,CrashLogHeader:db},Symbol.toStringTag,{value:"Module"}));function ub({logs:t}){return e.jsx("div",{className:"flex-1 bg-black p-4 font-mono text-[11px] leading-relaxed overflow-y-auto text-gray-300",children:t.length>0?t.map((s,n)=>e.jsx("div",{className:"whitespace-pre-wrap break-all border-l-2 border-gray-800 pl-3 mb-1",children:s},n)):e.jsx("div",{className:"italic text-gray-600",children:"No logs captured..."})})}const KA=Object.freeze(Object.defineProperty({__proto__:null,CrashLogViewer:ub},Symbol.toStringTag,{value:"Module"}));function hb({text:t,label:s="Copy",copiedLabel:n="Copied!",writer:r,className:a="shrink-0 px-3 py-1.5 text-xs font-medium rounded-md bg-red-600 hover:bg-red-700 disabled:bg-red-300 disabled:cursor-not-allowed text-white transition-colors"}){const{copied:o,copy:i}=qn({writer:r});return e.jsx("button",{type:"button",onClick:()=>{i(t)},disabled:t.length===0,className:a,children:o?n:s})}const JA=Object.freeze(Object.defineProperty({__proto__:null,CopyButton:hb},Symbol.toStringTag,{value:"Module"}));function pb(){return e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-red-800 dark:text-red-300 font-medium mb-1",children:"CodeYam was unable to restart the dev server after several attempts."}),e.jsx("p",{className:"text-xs text-red-700/80 dark:text-red-400/80",children:"Copy the logs and share them with Claude to investigate the underlying bug."})]})}const XA=Object.freeze(Object.defineProperty({__proto__:null,CrashLogFooterMessage:pb},Symbol.toStringTag,{value:"Module"}));function mb({logs:t,copyWriter:s}){return e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-950/30 border-t border-red-100 dark:border-red-900/50",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx(pb,{}),e.jsx(hb,{text:t.join(`
181
+ `),label:"Copy logs",writer:s})]})})}const QA=Object.freeze(Object.defineProperty({__proto__:null,CrashLogFooter:mb},Symbol.toStringTag,{value:"Module"}));function fb({logs:t}){return e.jsxs("div",{className:"absolute inset-0 bg-white dark:bg-gray-900 flex flex-col z-[60] overflow-hidden",children:[e.jsx(db,{}),e.jsx(ub,{logs:t}),e.jsx(mb,{logs:t})]})}const ZA=Object.freeze(Object.defineProperty({__proto__:null,DevServerCrashLog:fb},Symbol.toStringTag,{value:"Module"})),ml=20;function a2(t){if(!t)return null;try{return new Date(t).toLocaleTimeString()}catch{return null}}function gb({lastError:t,failureCount:s,failedAtMs:n,holder:r,onRetry:a,onReap:o}){const[i,c]=l.useState(!1),d=t.split(`
182
+ `),u=d.length>ml,h=i||!u?d:d.slice(d.length-ml),p=a2(n);return e.jsxs("div",{"data-testid":"dev-server-failed-panel",className:"absolute inset-0 bg-white dark:bg-gray-900 flex flex-col z-[60] overflow-hidden",children:[e.jsxs("header",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:["Dev server failed to start after ",s," ",s===1?"attempt":"attempts"]}),p&&e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:["Last attempt: ",p]}),r&&e.jsxs("div",{"data-testid":"dev-server-failed-holder",className:"mt-3 rounded border border-amber-300 dark:border-amber-700 bg-amber-50 dark:bg-amber-900/30 px-3 py-2 text-xs text-amber-900 dark:text-amber-100",children:[e.jsxs("div",{children:["Port ",e.jsx("span",{className:"font-semibold",children:r.port})," is held by:"]}),e.jsxs("div",{className:"mt-1 font-mono",children:["PID ",r.pid," — ",r.command]})]})]}),e.jsx("pre",{"data-testid":"dev-server-failed-error",className:"flex-1 overflow-auto px-6 py-4 m-0 font-mono text-xs leading-relaxed text-gray-800 dark:text-gray-200 whitespace-pre-wrap",children:h.join(`
183
+ `)}),e.jsxs("footer",{className:"px-6 py-3 border-t border-gray-200 dark:border-gray-700 flex items-center justify-between gap-3",children:[u?e.jsx("button",{type:"button",onClick:()=>c(m=>!m),className:"text-xs text-gray-600 dark:text-gray-300 underline hover:text-gray-900 dark:hover:text-gray-100",children:i?"Show less":`Show all ${d.length} lines`}):e.jsx("span",{}),e.jsxs("div",{className:"flex items-center gap-2",children:[r&&o&&e.jsx("button",{type:"button","data-testid":"dev-server-failed-reap",onClick:o,className:"px-4 py-1.5 text-sm font-medium rounded border border-amber-500 text-amber-700 dark:text-amber-200 hover:bg-amber-100 dark:hover:bg-amber-900/50",children:"Kill orphan and retry"}),e.jsx("button",{type:"button","data-testid":"dev-server-failed-retry",onClick:a,className:"px-4 py-1.5 text-sm font-medium rounded bg-blue-600 text-white hover:bg-blue-700",children:"Retry"})]})]})]})}const eR=Object.freeze(Object.defineProperty({__proto__:null,DevServerFailedPanel:gb},Symbol.toStringTag,{value:"Module"}));function bb({diagnostic:t,onRetry:s}){const{expectedPort:n,actualPort:r,appName:a,currentStartCommand:o,remediation:i}=t;return e.jsxs("div",{"data-testid":"preview-port-mismatch-card",className:"absolute inset-0 bg-white dark:bg-gray-900 flex flex-col z-[60] overflow-auto",children:[e.jsxs("header",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:"Dev server port conflict"}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:[a," bound port"," ",e.jsx("span",{className:"font-semibold",children:r}),", but the editor needs the app on port"," ",e.jsx("span",{className:"font-semibold",children:n})," so its reverse proxy (mocking, capture) can sit in front."]})]}),e.jsxs("div",{className:"flex-1 px-6 py-4 text-sm text-gray-800 dark:text-gray-200 space-y-3",children:[e.jsx("p",{children:i}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400 mb-1",children:"Current start command"}),e.jsx("pre",{className:"m-0 font-mono text-xs leading-relaxed whitespace-pre-wrap rounded bg-gray-100 dark:bg-gray-800 px-3 py-2",children:o||"(none configured)"})]})]}),e.jsx("footer",{className:"px-6 py-3 border-t border-gray-200 dark:border-gray-700 flex items-center justify-end",children:e.jsx("button",{type:"button","data-testid":"preview-port-mismatch-retry",onClick:s,className:"px-4 py-1.5 text-sm font-medium rounded bg-blue-600 text-white hover:bg-blue-700",children:"Retry"})})]})}const tR=Object.freeze(Object.defineProperty({__proto__:null,PreviewPortMismatchCard:bb},Symbol.toStringTag,{value:"Module"})),fl=48,o2=100,i2=320,l2=192;function c2({containerHeight:t,containerWidth:s,viewportHeight:n,viewportWidth:r}){if(!(r!=null&&n!=null&&s!=null&&t!=null&&r>0&&n>0&&s>0&&t>0))return{width:i2,height:l2,hasViewport:!1};const o=s-fl*2,i=t-fl*2-o2,c=Math.min(1,o/r,i/n);return{width:Math.round(r*c),height:Math.round(n*c),hasViewport:!0}}function Oa({containerHeight:t,containerWidth:s,heading:n="The app is being edited",onDismiss:r,scenarioName:a,screenshotPath:o,subtext:i="Live preview will load when the build agent is idle",viewportHeight:c,viewportWidth:d}){const{width:u,height:h,hasViewport:p}=c2({containerWidth:s,containerHeight:t,viewportWidth:d,viewportHeight:c}),m={width:u,height:h,...p?{overflowY:"auto"}:{}};return e.jsx("div",{className:"absolute inset-0 bg-white/90 dark:bg-gray-900/90 backdrop-blur-sm flex flex-col items-center justify-center z-50 animate-in fade-in duration-300",children:e.jsxs("div",{className:"flex flex-col items-center space-y-4 text-center p-6",children:[e.jsx("div",{className:"rounded-lg overflow-hidden border border-gray-200 dark:border-gray-700 shadow-md",style:m,children:e.jsx(Ro,{screenshotPath:o??void 0,alt:a??"Scenario preview",className:p?"w-full h-auto":"max-w-full max-h-full object-contain"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:n}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:i})]}),e.jsx("button",{onClick:r,className:"text-xs text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:"Dismiss"})]})})}const sR=Object.freeze(Object.defineProperty({__proto__:null,BuildingPreviewOverlay:Oa},Symbol.toStringTag,{value:"Module"}));function xb({isActive:t,onToggle:s,interactionAvailable:n=!0}){return e.jsx("button",{onClick:n?s:void 0,disabled:!n,title:n?t?"Exit Debug Mode":"Debug Mode":"Click-to-select is unavailable for this stack's preview (served from a separate origin)",className:"absolute z-50",style:{bottom:16,right:16,width:40,height:40,borderRadius:"50%",border:t?"2px solid var(--accent-blue)":"1px solid var(--border-default)",background:t?"var(--accent-blue)":"var(--bg-surface)",color:t?"#000":"var(--text-secondary)",cursor:n?"pointer":"not-allowed",display:"none",alignItems:"center",justifyContent:"center",opacity:n?t?1:.6:.35,transition:"all 0.15s ease",fontSize:18},onMouseEnter:r=>{n&&(r.currentTarget.style.opacity="1")},onMouseLeave:r=>{n&&(t||(r.currentTarget.style.opacity="0.6"))},children:t?"✕":"🔍"})}const nR=Object.freeze(Object.defineProperty({__proto__:null,DebugModeButton:xb},Symbol.toStringTag,{value:"Module"}));function d2(){const[t,s]=l.useState(null),n=l.useCallback(async(a,o)=>{try{const i=await fetch("/api/open-in-editor",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:a,line:o})}),c=await i.json().catch(()=>({}));if(!i.ok||(c==null?void 0:c.success)!==!0){s({message:(c==null?void 0:c.error)??`HTTP ${i.status}`,command:(c==null?void 0:c.command)??null});return}s(null)}catch(i){s({message:i instanceof Error?i.message:String(i),command:null})}},[]),r=l.useCallback(()=>s(null),[]);return{openInEditor:n,lastError:t,clearError:r}}function yb({tag:t,id:s,className:n,text:r,detectionMethod:a,previewUrl:o}){return e.jsxs("div",{className:"flex-1 flex flex-col gap-3 min-w-0",children:[e.jsx("div",{className:"rounded overflow-hidden flex-1",style:{background:"var(--bg-deep)",border:"1px solid var(--border-default)",minHeight:200,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("div",{style:{color:"var(--text-secondary)",fontSize:12},children:[e.jsxs("div",{className:"text-center",style:{color:"var(--text-secondary)"},children:["Preview: ",o.split("/").pop()]}),e.jsxs("div",{className:"mt-2 p-3 rounded",style:{background:"var(--bg-surface)",border:"1px dashed var(--border-default)",fontSize:11,fontFamily:"monospace"},children:["<",t,s?` id="${s}"`:"",n?` class="${n.slice(0,40)}"`:"",">",e.jsx("br",{}),r.slice(0,60),r.length>60?"...":""]})]})}),e.jsxs("div",{style:{fontSize:11,color:"var(--text-secondary)"},children:["Detected via: ",a]})]})}const rR=Object.freeze(Object.defineProperty({__proto__:null,DebugModalElementPreview:yb},Symbol.toStringTag,{value:"Module"}));function vb({ancestors:t,onOpenInEditor:s}){return t.length===0?e.jsx("div",{style:{color:"var(--text-secondary)",fontSize:12,fontStyle:"italic"},children:"No component ancestry available."}):e.jsx("ul",{className:"flex flex-col gap-1",style:{listStyle:"none",padding:0,margin:0},children:t.map((n,r)=>{const a=n.sourceFile&&n.lineNumber?`${n.sourceFile}:${n.lineNumber}`:n.sourceFile??"(unknown source)",o=!!n.sourceFile;return e.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 rounded",style:{background:"var(--bg-deep)"},children:[e.jsx("span",{style:{color:"var(--text-primary)",fontWeight:600,fontSize:12},children:n.componentName??"<anonymous>"}),e.jsx("span",{style:{color:"var(--text-secondary)",fontFamily:"monospace",fontSize:11,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a}),o&&e.jsx("button",{onClick:()=>s(n.sourceFile,n.lineNumber),className:"px-2 py-0.5 rounded text-xs",style:{background:"transparent",border:"1px solid var(--border-default)",color:"var(--accent-blue)",cursor:"pointer",fontSize:11},children:"Open in editor"})]},`${n.componentName??"anon"}-${r}`)})})}const aR=Object.freeze(Object.defineProperty({__proto__:null,DebugAncestryList:vb},Symbol.toStringTag,{value:"Module"}));function jb({ancestors:t,onOpenInEditor:s}){const[n,r]=l.useState(t.length>1);return t.length===0?null:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("button",{onClick:()=>r(a=>!a),className:"text-left",style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:12,cursor:"pointer",padding:0},children:[n?"▾":"▸"," Component ancestry (",t.length,")"]}),n&&e.jsx(vb,{ancestors:t,onOpenInEditor:s})]})}const oR=Object.freeze(Object.defineProperty({__proto__:null,DebugAncestrySection:jb},Symbol.toStringTag,{value:"Module"}));function wb({propsNames:t}){if(t.length===0)return null;const s=()=>{var n;(n=navigator.clipboard)==null||n.writeText(t.join(", "))};return e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsx("span",{style:{color:"var(--text-secondary)",fontSize:12},children:"props:"}),t.map(n=>e.jsx("span",{onClick:s,className:"px-1.5 py-0.5 rounded",style:{background:"var(--bg-deep)",color:"var(--text-primary)",fontFamily:"monospace",fontSize:11,cursor:"pointer"},title:"Click to copy prop names",children:n},n))]})}const iR=Object.freeze(Object.defineProperty({__proto__:null,DebugPropsChips:wb},Symbol.toStringTag,{value:"Module"}));function _b({componentDisplay:t,sourceDisplay:s,tag:n,id:r,boundingBox:a,feedback:o,onFeedbackChange:i,creating:c,hasComponentName:d,ancestors:u,propsNames:h,onOpenInEditor:p,onGoToIsolated:m,onCreatePlan:f,onClose:b}){const g=c||!o.trim();return e.jsxs("div",{className:"flex-1 flex flex-col gap-3 min-w-0",children:[e.jsx("h3",{style:{color:"var(--text-primary)",fontSize:16,fontWeight:600,margin:0},children:t}),s&&e.jsx("div",{className:"px-2 py-1 rounded",style:{background:"var(--bg-deep)",fontSize:12,fontFamily:"monospace",color:"var(--accent-blue)"},children:s}),e.jsxs("div",{className:"flex flex-col gap-1",style:{color:"var(--text-secondary)",fontSize:12},children:[e.jsxs("div",{children:["Element: <",n,">",r?` #${r}`:""]}),e.jsxs("div",{children:["Position: ",Math.round(a.x),", ",Math.round(a.y)," (",Math.round(a.width),"x",Math.round(a.height),")"]})]}),e.jsx(wb,{propsNames:h}),e.jsx(jb,{ancestors:u,onOpenInEditor:p}),e.jsx("textarea",{value:o,onChange:v=>i(v.target.value),placeholder:"Describe the issue or desired change...",className:"flex-1 p-2 rounded resize-none",style:{background:"var(--bg-deep)",border:"1px solid var(--border-default)",color:"var(--text-primary)",fontSize:13,minHeight:80,outline:"none"}}),e.jsxs("div",{className:"flex gap-2",children:[d&&e.jsx("button",{onClick:m,className:"px-3 py-1.5 rounded text-sm",style:{background:"var(--bg-deep)",border:"1px solid var(--border-default)",color:"var(--text-primary)",cursor:"pointer"},children:"Go to Isolated Component"}),e.jsx("button",{onClick:f,disabled:g,className:"px-3 py-1.5 rounded text-sm flex-1",style:{background:g?"var(--bg-deep)":"var(--accent-blue)",border:"none",color:g?"var(--text-secondary)":"#000",cursor:g?"not-allowed":"pointer",fontWeight:600},children:c?"Creating...":"Create Fix Plan"}),e.jsx("button",{onClick:b,className:"px-3 py-1.5 rounded text-sm",style:{background:"transparent",border:"1px solid var(--border-default)",color:"var(--text-secondary)",cursor:"pointer"},children:"Cancel"})]})]})}const lR=Object.freeze(Object.defineProperty({__proto__:null,DebugModalInfoPanel:_b},Symbol.toStringTag,{value:"Module"}));function kb({error:t,onDismiss:s}){return e.jsxs("div",{onClick:n=>n.stopPropagation(),className:"fixed bottom-4 left-1/2 px-3 py-2 rounded",style:{transform:"translateX(-50%)",background:"var(--bg-surface)",border:"1px solid var(--accent-red, #f85149)",color:"var(--text-primary)",fontSize:12,zIndex:60,maxWidth:520},children:[e.jsxs("div",{children:["Open in editor failed: ",t.message]}),t.command&&e.jsx("div",{style:{fontFamily:"monospace",fontSize:11,marginTop:4},children:t.command}),e.jsx("button",{onClick:s,className:"mt-1",style:{background:"transparent",border:"none",color:"var(--accent-blue)",cursor:"pointer",fontSize:11,padding:0},children:"Dismiss"})]})}const cR=Object.freeze(Object.defineProperty({__proto__:null,OpenInEditorErrorToast:kb},Symbol.toStringTag,{value:"Module"}));function Sb({element:t,previewUrl:s,onClose:n,onGoToIsolated:r,onCreatePlan:a}){const[o,i]=l.useState(""),[c,d]=l.useState(!1),{openInEditor:u,lastError:h,clearError:p}=d2(),m=async()=>{d(!0);try{await a(o,t)}finally{d(!1)}},f=t.componentName??`<${t.element.tag}>`,b=t.sourceFile?`${t.sourceFile}${t.lineNumber?`:${t.lineNumber}`:""}`:null;return e.jsxs("div",{className:"absolute inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0, 0, 0, 0.7)"},onClick:n,children:[e.jsxs("div",{className:"flex gap-4 p-6 rounded-lg max-w-3xl w-full mx-4",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",maxHeight:"80vh"},onClick:g=>g.stopPropagation(),children:[e.jsx(yb,{tag:t.element.tag,id:t.element.id,className:t.element.className,text:t.element.text,detectionMethod:t.detectionMethod,previewUrl:s}),e.jsx(_b,{componentDisplay:f,sourceDisplay:b,tag:t.element.tag,id:t.element.id,boundingBox:t.element.boundingBox,feedback:o,onFeedbackChange:i,creating:c,hasComponentName:!!t.componentName,ancestors:t.ancestors,propsNames:t.propsNames,onOpenInEditor:u,onGoToIsolated:()=>r(t.componentName),onCreatePlan:m,onClose:n})]}),h&&e.jsx(kb,{error:h,onDismiss:p})]})}const dR=Object.freeze(Object.defineProperty({__proto__:null,DebugModal:Sb},Symbol.toStringTag,{value:"Module"}));function Nb(){return e.jsx("div",{className:"absolute z-40 px-2 py-1 rounded",style:{bottom:8,right:8,background:"var(--bg-surface)",border:"1px solid var(--accent-blue)",color:"var(--accent-blue)",fontSize:11,fontWeight:600,pointerEvents:"none",fontFamily:"system-ui"},"data-testid":"debug-freeze-pill",children:"Debug — frozen"})}const uR=Object.freeze(Object.defineProperty({__proto__:null,DebugFreezePill:Nb},Symbol.toStringTag,{value:"Module"}));function Cb({hoveredElement:t}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute inset-0 z-40",style:{border:"3px solid var(--accent-blue)",cursor:"crosshair",pointerEvents:"none"}}),t&&e.jsx("div",{className:"absolute z-40 px-2 py-1 rounded",style:{top:8,left:8,background:"var(--accent-blue)",color:"#000",fontSize:12,fontWeight:600,pointerEvents:"none"},children:t.componentName??`<${t.element.tag}>`}),e.jsx(Nb,{})]})}const hR=Object.freeze(Object.defineProperty({__proto__:null,DebugOverlay:Cb},Symbol.toStringTag,{value:"Module"}));function Tb(){return e.jsx("div",{className:"absolute z-40 pointer-events-none",style:{top:0,left:0,right:0,bottom:0,border:"2px solid var(--accent-blue, #D7FF63)",borderRadius:4,boxSizing:"border-box"},children:e.jsx("div",{style:{position:"absolute",top:0,left:16,padding:"2px 8px",background:"var(--accent-blue, #D7FF63)",color:"#000",fontSize:10,fontWeight:700,fontFamily:"system-ui, -apple-system, sans-serif",borderRadius:"0 0 4px 4px",letterSpacing:.5},children:"INSPECT MODE"})})}const pR=Object.freeze(Object.defineProperty({__proto__:null,InspectModeRibbon:Tb},Symbol.toStringTag,{value:"Module"}));function u2(t,s,n){const{width:r,maxHeight:a,gap:o}=n,i=t.y+t.height+o,c=i+a>s.height,d=c?Math.max(o,t.y-a-o):i,u=Math.max(o,Math.min(t.x,s.width-r-o));return{top:d,left:u,placedAbove:c}}function Pb({onDismiss:t}){return e.jsx("div",{onClick:t,style:{position:"fixed",inset:0,zIndex:999998,background:"transparent"}})}const mR=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardBackdrop:Pb},Symbol.toStringTag,{value:"Module"}));function Ob({match:t,onOpen:s}){return e.jsxs("button",{onClick:()=>s(t),style:{width:"100%",textAlign:"left",padding:"6px 8px",background:"rgba(88, 166, 255, 0.12)",color:"inherit",border:"1px solid rgba(88, 166, 255, 0.4)",borderRadius:4,cursor:"pointer",fontFamily:"monospace",fontSize:11},children:[e.jsx("div",{style:{fontWeight:600},children:t.endpoint}),e.jsx("div",{style:{opacity:.85},children:t.jsonPath})]})}const fR=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardMatchButton:Ob},Symbol.toStringTag,{value:"Module"}));function Ab({matches:t,onOpen:s}){return e.jsx("ul",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:6},children:t.map((n,r)=>e.jsx("li",{children:e.jsx(Ob,{match:n,onOpen:s})},`${n.endpoint}${n.jsonPath}${r}`))})}const gR=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardMatchList:Ab},Symbol.toStringTag,{value:"Module"}));function Rb({clickedText:t,matches:s,corpusEmpty:n,onOpenInPanel:r}){return e.jsxs("div",{style:{padding:"8px 12px"},children:[e.jsxs("div",{style:{opacity:.7,marginBottom:6,wordBreak:"break-all"},children:["Clicked: ",e.jsx("code",{children:Eb(t,120)||"(empty)"})]}),n?e.jsx("div",{style:{opacity:.85},children:"No mocks were consumed on this page load yet."}):s.length===0?e.jsx("div",{style:{opacity:.85},children:"No direct mock value matches — this value may be computed or concatenated."}):e.jsx(Ab,{matches:s,onOpen:r})]})}function Eb(t,s){return t.length<=s?t:t.slice(0,s-1)+"…"}const bR=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardBody:Rb,truncate:Eb},Symbol.toStringTag,{value:"Module"}));function Mb({onDismiss:t}){return e.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid var(--border-muted, #374151)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{fontWeight:600},children:"Data source"}),e.jsx("button",{onClick:t,"aria-label":"Dismiss",style:{background:"transparent",color:"inherit",border:"none",cursor:"pointer",fontSize:14,lineHeight:1},children:"×"})]})}const xR=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardHeader:Mb},Symbol.toStringTag,{value:"Module"})),gl=320,bl=320,h2=8;function Ib({clickedText:t,matches:s,anchor:n,onOpenInPanel:r,onDismiss:a,corpusEmpty:o}){l.useEffect(()=>{function h(p){p.key==="Escape"&&a()}return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[a]);const i=typeof window<"u"?window.innerHeight:800,c=typeof window<"u"?window.innerWidth:1200,{top:d,left:u}=u2(n,{width:c,height:i},{width:gl,maxHeight:bl,gap:h2});return e.jsxs(e.Fragment,{children:[e.jsx(Pb,{onDismiss:a}),e.jsxs("div",{style:{position:"fixed",top:d,left:u,width:gl,maxHeight:bl,zIndex:999999,background:"var(--bg-surface, #1f2937)",color:"var(--text-primary, #f3f4f6)",border:"1px solid var(--border-muted, #374151)",borderRadius:8,boxShadow:"0 10px 30px rgba(0,0,0,0.5)",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:12,overflow:"auto"},role:"dialog","aria-label":"Mock data source inspector",children:[e.jsx(Mb,{onDismiss:a}),e.jsx(Rb,{clickedText:t,matches:s,corpusEmpty:o,onOpenInPanel:r})]})]})}const yR=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCard:Ib},Symbol.toStringTag,{value:"Module"}));function Db({healthy:t,reason:s}){const n=t===!0?"healthy":t===!1?"unhealthy":"unknown",a={healthy:{bg:"#1f3a24",border:"#2f6b3a",dot:"#4ade80",label:"Live"},unhealthy:{bg:"#3a1f1f",border:"#6b2f2f",dot:"#f87171",label:"Stale"},unknown:{bg:"#2a2a2a",border:"#444",dot:"#9ca3af",label:"—"}}[n];return e.jsxs("div",{role:"status","aria-label":`Live preview iframe: ${n}`,title:n==="healthy"?"Live Preview iframe is healthy and matches the running dev server.":n==="unhealthy"?s?`Live Preview iframe is stale: ${s}`:"Live Preview iframe is stale and out of sync with the dev server.":"Live Preview iframe health unknown.",style:{position:"absolute",top:8,right:8,display:"inline-flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:999,backgroundColor:a.bg,border:`1px solid ${a.border}`,color:"#fff",fontSize:11,fontFamily:"monospace",zIndex:30,pointerEvents:"auto"},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:a.dot,boxShadow:n==="healthy"?`0 0 6px ${a.dot}`:void 0}}),e.jsx("span",{children:a.label})]})}const vR=Object.freeze(Object.defineProperty({__proto__:null,LiveIframeHealthPill:Db},Symbol.toStringTag,{value:"Module"}));function xl(t){if(!t||typeof t!="object")return null;const s=t;return{componentName:s.componentName??null,sourceFile:s.sourceFile??null,lineNumber:s.lineNumber??null,detectionMethod:s.detectionMethod??"dom-heuristics",ancestors:Array.isArray(s.ancestors)?s.ancestors:[],propsNames:Array.isArray(s.propsNames)?s.propsNames:[],element:s.element}}function p2(t){const[s,n]=l.useState(!1),[r,a]=l.useState(null),[o,i]=l.useState(null),c=l.useRef(!1),d=l.useCallback(m=>{const f=t.current;f!=null&&f.contentWindow&&f.contentWindow.postMessage({type:m},"*")},[t]),u=l.useCallback(()=>{n(!0),a(null),i(null),d("codeyam:debug:activate")},[d]),h=l.useCallback(()=>{n(!1),a(null),i(null),d("codeyam:debug:deactivate")},[d]),p=l.useCallback(()=>{i(null)},[]);return l.useEffect(()=>{function m(f){!f.data||typeof f.data.type!="string"||(f.data.type==="codeyam:debug:hover"?a(xl(f.data.payload)):f.data.type==="codeyam:debug:selected"&&i(xl(f.data.payload)))}return window.addEventListener("message",m),()=>window.removeEventListener("message",m)},[]),l.useEffect(()=>{c.current&&!s&&(c.current=!1),s&&(c.current=!0)},[s]),{isActive:s,hoveredElement:r,selectedElement:o,activate:u,deactivate:h,clearSelection:p}}const m2=/^\/api\/mock-panel(\/.*)?$/;function f2(t,s){return t.toUpperCase()!=="GET"?!1:m2.test(s)}function g2(t){return Array.isArray(t)?t.filter(s=>s.consumedThisPageLoad&&!f2(s.method,s.pathPattern)).map(s=>({endpoint:`${s.method} ${s.pathPattern}`,body:s.body})):[]}async function b2(t,s,n){return(await fetch("/api/debug/create-plan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:t,componentName:s.componentName,sourceFile:s.sourceFile,lineNumber:s.lineNumber,detectionMethod:s.detectionMethod,element:s.element,previewUrl:n})})).json()}const x2=12;function y2(t,s,n){if(s.length===0)return[];const r=[];return Aa(t,s,n,"$",0,new Set,r),r}function v2(t,s){const n=[];for(const o of t)for(const i of y2(o.body,s,o.endpoint))n.push(i);const r=new Set,a=[];for(const o of n){const i=`${o.endpoint}\0${o.jsonPath}`;r.has(i)||(r.add(i),a.push(o))}return a.sort((o,i)=>{const c=i.matchedValue.length-o.matchedValue.length;return c!==0?c:i.pathDepth-o.pathDepth}),a}function Aa(t,s,n,r,a,o,i){if(t==null)return;const c=typeof t;if(c==="string"||c==="number"||c==="boolean"){String(t)===s&&i.push({endpoint:n,jsonPath:r,matchedValue:String(t),pathDepth:a});return}if(!(a>=x2)&&!o.has(t)){if(o.add(t),Array.isArray(t))for(let d=0;d<t.length;d++)Aa(t[d],s,n,`${r}[${d}]`,a+1,o,i);else if(c==="object")for(const[d,u]of Object.entries(t))Aa(u,s,n,`${r}.${d}`,a+1,o,i);o.delete(t)}}function yl(t,s){return(s==null?void 0:s.previewOrigin)??(t==null?void 0:t.previewOrigin)??null}function j2(t,s){if(!t||!/^https?:\/\//i.test(t))return!0;const n=typeof window<"u"?window.location.origin:null;if(!n)return!1;try{return new URL(t).origin===n}catch{return!0}}const w2={backgroundColor:"#1e1e1e",backgroundImage:"conic-gradient(#262626 25%, #1e1e1e 0 50%, #262626 0 75%, #1e1e1e 0)",backgroundSize:"16px 16px"};function Lb({buildingScenarioName:t,buildingScenarioSlug:s,buildingScreenshotPath:n,containerHeight:r,containerRef:a,containerWidth:o,currentHeight:i,currentWidth:c,emptyStateMessage:d,isFilled:u,onDismissBuildingOverlay:h,historicalScreenshotPath:p,historicalScenarioName:m,historicalHeading:f,historicalSubtext:b,onDismissHistoricalPreview:g,previewSlug:v,previewUrl:x,previewOrigin:y,scale:w,commandNonce:j}){var $e,Re;const k=!!m&&!s,S=!!s||k,N=l.useRef(null),T=a??N,A=l.useRef(null),{status:_,restart:M}=Gy();wN(_,M);const{isRestarting:I,isFailed:H,isStarting:z,isStopped:G}=GN(_),{stepState:R}=Xs(),D=XN((R==null?void 0:R.step)??null,(R==null?void 0:R.mode)??"ui"),P=(_==null?void 0:_.liveIframeHealthy)!==void 0,{reloadNonce:$,handleIframeLoad:F,handleIframeError:U}=SN((_==null?void 0:_.pid)??null,P,_==null?void 0:_.status),J=(_==null?void 0:_.status)==="failed",{healthy:Z,failedProbeCount:te,reloadNonce:ie,invalidate:V}=AN(x,J),le=kN(_==null?void 0:_.liveIframeHealthy,750),me=LN(Z,le),[Q,C]=l.useState(0);l.useEffect(()=>Uy(()=>{C(be=>be+1)}),[]),zN(_==null?void 0:_.sourceVersion,_==null?void 0:_.liveReloadEnabled);const E=FN({pidNonce:$,probeNonce:ie+me,draftNonce:Q}),B=E.gatedNonce,{errors:se,clear:q}=BN(A,B),ce=qN(x,B),W=l.useCallback(()=>{E.reset(),q(),V()},[E,q,V]),oe=l.useCallback(()=>Fa(),[]),fe=(_==null?void 0:_.devServerStartedSecsAgo)??null,xe=fe!==null&&fe<UN,ne=!!(_!=null&&_.startCommand),je=MN({liveIframeHealthy:le,previewReachable:($e=_==null?void 0:_.previewProbe)==null?void 0:$e.reachable}),[et,wt]=l.useState(!1);l.useEffect(()=>{je&&!et&&wt(!0)},[je,et]);const Ft=je||et,_t=IN({hasDevServerConfigured:ne,hasServed:Ft}),xs=_t?x:"about:blank",we=VN({hasDevServerConfigured:ne,probeHealthy:Z,backendRunning:(_==null?void 0:_.status)==="running",backendIframeHealthy:le,isStarting:z,isRestarting:I,isFailed:H,isStopped:G,isPrePrototype:D,withinStartupGrace:xe,previewReachable:((Re=_==null?void 0:_.previewProbe)==null?void 0:Re.reachable)===!0,hasEverServed:Ft}),Ke=l.useRef(void 0);l.useEffect(()=>{var Ue;if(Ke.current===we)return;const be=Ke.current;Ke.current=we,console.debug(`[preview-overlay] ${be===void 0?"(init)":be??"none"} → ${we??"none"}`,{status:_==null?void 0:_.status,intendedRunning:_==null?void 0:_.intendedRunning,restartCount:_==null?void 0:_.restartCount,pid:_==null?void 0:_.pid,liveIframeHealthy:_==null?void 0:_.liveIframeHealthy,previewProbeReachable:(Ue=_==null?void 0:_.previewProbe)==null?void 0:Ue.reachable,devServerStartedSecsAgo:fe,withinStartupGrace:xe,probeHealthy:Z,isStarting:z,isRestarting:I,isFailed:H,isStopped:G})},[we,_,fe,xe,Z,z,I,H,G]);const Ae=_==null?void 0:_.portDiagnostic,es=(Ae==null?void 0:Ae.conflict)===!0,qe=we==="scaffolding"?e2((R==null?void 0:R.step)??null,(R==null?void 0:R.mode)??"ui").body:void 0,ts=RN({active:we==="reconnecting",trigger:te}),ys=we==="reconnecting"?EN(ts):null,ss=qe??ys??void 0,zt=te>=10,{isActive:pt,hoveredElement:vs,selectedElement:tt,activate:$t,deactivate:Fe,clearSelection:ze}=p2(A),_e=l.useCallback(()=>{pt?Fe():$t()},[pt,$t,Fe]),{entries:ke}=Vy(v??null),{isActive:ge,toggle:Ge}=_N({activate:$t,deactivate:Fe,clearSelection:ze},$);l.useEffect(()=>(vi({isActive:ge,previewSlug:v??null}),()=>{vi({isActive:!1,previewSlug:null})}),[ge,v]),l.useEffect(()=>Yy(()=>{Ge()}),[Ge]);const pe=ge&&tt?tt.element.text.trim():"",ve=l.useMemo(()=>g2(ke),[ke]),L=l.useMemo(()=>!ge||!pe?[]:v2(ve,pe),[ge,pe,ve]),st=l.useCallback(async be=>{ze(),Fe();try{const Je=await(await fetch("/api/scenarios")).json(),Ee=Array.isArray(Je)?Je.find(nt=>nt.componentName===be):null;if(Ee!=null&&Ee.slug){const nt=jf(window.location),Bt=_f(Ee.slug,nt,null,0,y);window.history.pushState(null,"",Bt);return}}catch{}window.history.pushState(null,"","/entities")},[ze,Fe,y]),ye=l.useCallback(async(be,Ue)=>{try{await b2(be,Ue,x),ze(),Fe()}catch(Je){console.error("Failed to create debug plan:",Je)}},[x,ze,Fe]);return e.jsx("div",{ref:T,className:`relative flex-1 flex overflow-hidden ${u?"":"items-center justify-center p-8"}`,style:u?{backgroundColor:"#fff"}:w2,children:x?e.jsxs(e.Fragment,{children:[e.jsx(Zg,{ref:A,currentHeight:i,currentWidth:c,isFilled:u,previewUrl:xs,scale:w,reloadNonce:B,onLoad:()=>{_t&&F(x)},onError:U}),!_t&&e.jsx(Xg,{hasDevServerConfigured:ne}),e.jsx(cb,{previewUrl:x}),e.jsx(Db,{healthy:le,reason:(_==null?void 0:_.iframeLastError)??null}),pt&&e.jsx(Cb,{hoveredElement:vs}),ge&&e.jsx(Tb,{}),tt&&!ge&&e.jsx(Sb,{element:tt,previewUrl:x,onClose:ze,onGoToIsolated:st,onCreatePlan:ye}),tt&&ge&&e.jsx(Ib,{clickedText:pe,matches:L,anchor:tt.element.boundingBox,corpusEmpty:ve.length===0,onOpenInPanel:be=>{Ky({routeKey:be.endpoint,jsonPath:be.jsonPath}),ze()},onDismiss:ze}),!S&&e.jsx(xb,{isActive:pt,onToggle:_e,interactionAvailable:j2(y)}),J?e.jsx(gb,{lastError:(_==null?void 0:_.lastError)??(_==null?void 0:_.lastExit)??"(no error message captured)",failureCount:(_==null?void 0:_.failureCount)??0,failedAtMs:_==null?void 0:_.failedAtMs,holder:_==null?void 0:_.holder,onRetry:M,onReap:async()=>{await fetch("/api/editor-dev-server/reap",{method:"POST",headers:{"Content-Type":"application/json"}})}}):es&&Ae?e.jsx(bb,{diagnostic:Ae,onRetry:M}):we&&(we==="crashed"?e.jsx(fb,{logs:(_==null?void 0:_.logs)??[]}):e.jsx(sb,{variant:we,restartCount:(_==null?void 0:_.restartCount)??0,showRetry:zt,onRetry:we==="disconnected"?oe:V,bodyOverride:ss})),e.jsx(lb,{tripped:E.tripped,errors:se,recentReloads:E.recentReloads,serverHealthy:YN(_),onRetry:W,onClear:q}),ce.clickThroughBroken&&ce.status!==null&&e.jsx(eb,{url:x,status:ce.status,logLines:ce.logLines,onRetry:W}),s&&h&&e.jsx(Oa,{containerHeight:r,containerWidth:o,onDismiss:h,scenarioName:t??null,screenshotPath:n??null,viewportHeight:i,viewportWidth:c}),k&&g&&e.jsx(Oa,{containerHeight:r,containerWidth:o,heading:f??void 0,subtext:b??void 0,onDismiss:g,scenarioName:m??null,screenshotPath:p??null,viewportHeight:i,viewportWidth:c})]}):e.jsx(Jg,{message:d})})}const jR=Object.freeze(Object.defineProperty({__proto__:null,PreviewCanvas:Lb},Symbol.toStringTag,{value:"Module"}));function Fb({prompt:t}){const[s,n]=l.useState(!0);return e.jsxs("section",{"aria-label":"What you asked for",style:{border:"1px solid var(--border-subtle)",borderRadius:"8px",padding:"0.875rem 1rem",marginBottom:"1.5rem",background:"var(--bg-elevated)",fontFamily:"'IBM Plex Mono', monospace"},children:[e.jsxs("button",{type:"button",onClick:()=>n(r=>!r),"aria-expanded":s,style:{width:"100%",background:"transparent",border:"none",padding:0,margin:0,color:"var(--text-muted)",fontSize:"0.75rem",fontWeight:500,textAlign:"left",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between",fontFamily:"inherit"},children:[e.jsx("span",{children:"What you asked for"}),e.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",transition:"transform 150ms ease",transform:s?"rotate(0deg)":"rotate(-90deg)",color:"var(--text-muted)",fontSize:"0.75rem"},children:"▾"})]}),s?e.jsx("div",{style:{marginTop:"0.625rem",fontFamily:"ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",color:"var(--text-secondary)",fontSize:"0.8125rem",lineHeight:1.55},children:e.jsx(vt,{children:t})}):null]})}const wR=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupDescriptionCard:Fb},Symbol.toStringTag,{value:"Module"}));function zb({html:t,viewport:s}){return e.jsxs("div",{children:[e.jsx("div",{style:{color:"var(--text-muted)",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.625rem"},children:"Your chosen design"}),e.jsx("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:"6px",overflow:"hidden"},children:e.jsx(qo,{html:t,url:"",title:"Chosen design",viewport:s,theme:"light",darkVars:null})})]})}const _R=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupChosenMockup:zb},Symbol.toStringTag,{value:"Module"}));function $b({assets:t}){return e.jsxs("div",{children:[e.jsx("div",{style:{color:"var(--text-muted)",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.625rem"},children:"Design assets you added"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",fontFamily:"ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"},children:t.map(s=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",padding:"0.5rem 0.625rem",border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-input)"},children:[e.jsx("span",{style:{fontSize:"0.8125rem",fontWeight:500,color:"var(--text-primary)"},children:s.filename}),s.description.trim().length>0&&e.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:s.description})]},s.filename))})]})}const kR=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupDesignAssetList:$b},Symbol.toStringTag,{value:"Module"}));function Bb({mockupHtml:t,mockupViewport:s,assets:n}){const r=t!==null,a=n.length>0;return!r&&!a?null:e.jsxs("section",{"aria-label":"Your chosen design",style:{border:"1px solid var(--border-subtle)",borderRadius:"8px",padding:"0.875rem 1rem",marginBottom:"1.5rem",background:"var(--bg-elevated)",fontFamily:"'IBM Plex Mono', monospace"},children:[r&&e.jsx("div",{style:{marginBottom:a?"1rem":0},children:e.jsx(zb,{html:t,viewport:s})}),a&&e.jsx($b,{assets:n})]})}const SR=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupDesignCard:Bb},Symbol.toStringTag,{value:"Module"}));function Hb(){return e.jsxs("header",{style:{marginBottom:"1.5rem",fontFamily:"'IBM Plex Mono', monospace"},children:[e.jsxs("h1",{style:{fontSize:"1.125rem",fontWeight:600,color:"var(--text-primary)",margin:"0 0 0.5rem 0",display:"flex",alignItems:"baseline",gap:"0.5rem"},children:[e.jsx("span",{"aria-hidden":"true",style:{color:"var(--text-muted)",letterSpacing:"-0.1em"},children:"::"}),"Setting up your project…"]}),e.jsx("p",{style:{margin:0,color:"var(--text-muted)",fontSize:"0.8125rem"},children:"This usually takes a few minutes."})]})}const NR=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupHeader:Hb},Symbol.toStringTag,{value:"Module"}));function _2(t,s){if(t.phaseSteps.length===0)return"pending";const n=t.phaseSteps[0],r=t.phaseSteps[t.phaseSteps.length-1];return s>r?"complete":s>=n?"active":"pending"}const Ra="#D7FF63",k2="var(--text-muted)";function Wb({status:t}){return t==="complete"?e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18","aria-hidden":"true",style:{flexShrink:0,display:"block"},children:[e.jsx("circle",{cx:"9",cy:"9",r:"7.5",fill:"none",stroke:"#FFFFFF",strokeWidth:"1.5"}),e.jsx("path",{d:"M5.5 9.2 L8 11.5 L12.5 6.5",fill:"none",stroke:"#FFFFFF",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})]}):t==="active"?e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",role:"img","aria-label":"In progress",style:{flexShrink:0,display:"block",animation:"codeyam-setup-spin 1.1s linear infinite"},children:[e.jsx("circle",{cx:"9",cy:"9",r:"7.5",fill:"none",stroke:Ra,strokeWidth:"1.5",opacity:"0.25"}),e.jsx("path",{d:"M9 1.5 A 7.5 7.5 0 0 1 16.5 9",fill:"none",stroke:Ra,strokeWidth:"1.75",strokeLinecap:"round"})]}):e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18","aria-hidden":"true",style:{flexShrink:0,display:"block"},children:e.jsx("circle",{cx:"9",cy:"9",r:"7.5",fill:"none",stroke:k2,strokeWidth:"1.5"})})}function qb({phase:t,status:s}){const n=s==="active"?Ra:s==="complete"?"var(--text-primary)":"var(--text-muted)";return e.jsxs("li",{"data-phase-id":t.phaseId,"data-phase-status":s,style:{display:"flex",alignItems:"center",gap:"0.625rem"},children:[e.jsx(Wb,{status:s}),e.jsx("span",{style:{color:n,fontSize:"0.8125rem",fontFamily:"'IBM Plex Mono', monospace",fontWeight:s==="active"?600:400,letterSpacing:"0.01em"},children:t.phaseLabel})]})}const CR=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupProgressRow:qb,StatusIndicator:Wb},Symbol.toStringTag,{value:"Module"}));function Gb({currentStep:t,mode:s}){const n=tw(s);return e.jsx("section",{"aria-label":"Progress",style:{marginBottom:"0.5rem"},children:e.jsx("ol",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:"0.875rem"},children:n.map(r=>{const a=_2(r,t);return e.jsx(qb,{phase:r,status:a},r.phaseId)})})})}const TR=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupProgressList:Gb},Symbol.toStringTag,{value:"Module"}));function S2(t){let s=t;const n=s.match(/^Feature: [^\n]*\n\nProject context: /);return n?s=s.slice(n[0].length):s.startsWith("Project context: ")&&(s=s.slice(17)),s.endsWith(`
184
+ `)&&(s=s.slice(0,-1)),s}function Ub({prompt:t,currentStep:s,mode:n,mockupHtml:r=null,mockupViewport:a="desktop",assets:o=[]}){return e.jsxs("div",{style:{background:"var(--bg-elevated, #141414)",border:"1px solid var(--border-subtle)",borderRadius:"12px",padding:"1.5rem 1.75rem",maxWidth:"520px"},children:[e.jsx(Hb,{}),e.jsx(Fb,{prompt:S2(t)}),e.jsx(Bb,{mockupHtml:r,mockupViewport:a,assets:o}),e.jsx(Gb,{currentStep:s,mode:n})]})}const PR=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupPreviewView:Ub},Symbol.toStringTag,{value:"Module"}));function N2(){const[t,s]=l.useState(null),[n,r]=l.useState("desktop"),[a,o]=l.useState([]);return l.useEffect(()=>{let i=!1;async function c(){try{const u=await fetch("/api/editor-design-selection");if(!u.ok)return;const h=await u.json();if(!h||typeof h.filename!="string"||!h.filename)return;const p=await fetch("/api/editor-design-selected-mockup");if(!p.ok)return;const m=await p.text();if(i||!m)return;s(m),r(Ho(m)??"desktop")}catch{}}async function d(){try{const u=await fetch("/api/editor-design-assets");if(!u.ok)return;const h=await u.json();!i&&Array.isArray(h.assets)&&o(h.assets)}catch{}}return c(),d(),()=>{i=!0}},[]),{mockupHtml:t,mockupViewport:n,assets:a}}function Vb(){const{prompt:t}=Yg(),{stepState:s}=Xs(),{mockupHtml:n,mockupViewport:r,assets:a}=N2();return e.jsx("div",{className:"flex-1 flex flex-col min-w-0 overflow-auto",style:{background:"var(--bg-deep)"},children:e.jsx("div",{style:{padding:"1.5rem 2rem",maxWidth:"880px",width:"100%",margin:"0 auto"},children:e.jsx(Ub,{prompt:t??"",currentStep:(s==null?void 0:s.step)??1,mode:(s==null?void 0:s.mode)??"ui",mockupHtml:n,mockupViewport:r,assets:a})})})}const OR=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupPreviewPane:Vb},Symbol.toStringTag,{value:"Module"}));function Yb({error:t,onRetry:s}){return e.jsxs("div",{role:"alert",className:"flex items-center justify-between gap-3 border-b border-[var(--accent-red)] bg-[var(--accent-red)]/10 px-4 py-2 text-sm text-[var(--accent-red)]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-semibold",children:"Seed failed — DB state is unknown"}),e.jsx("div",{className:"truncate text-xs opacity-90",children:t})]}),s?e.jsx("button",{type:"button",onClick:s,className:"shrink-0 rounded border border-[var(--accent-red)] px-2 py-1 text-xs hover:bg-[var(--accent-red)] hover:text-white",children:"Retry"}):null]})}const AR=Object.freeze(Object.defineProperty({__proto__:null,SeedErrorBanner:Yb},Symbol.toStringTag,{value:"Module"}));function Kb({label:t="Loading scenario..."}={}){return e.jsx("div",{role:"status","aria-live":"polite",className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-[var(--bg-deep)]/90 backdrop-blur-sm text-[var(--text-muted)]",children:t})}const RR=Object.freeze(Object.defineProperty({__proto__:null,SeedLoadingOverlay:Kb},Symbol.toStringTag,{value:"Module"}));function C2(t){return t.state==="preflight-running"||t.state==="booting-simulator"||t.state==="simulator-booted"||t.state==="building-app"}function Jb({stderrTail:t,onClose:s}){return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.6)"},onClick:s,children:e.jsxs("div",{className:"max-w-2xl w-full max-h-[80vh] overflow-auto rounded p-4 font-mono text-xs",style:{background:"var(--bg-elevated)",color:"var(--text-primary)"},onClick:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("strong",{children:"Build logs (stderr tail)"}),e.jsx("button",{type:"button",onClick:s,className:"opacity-70 hover:opacity-100",children:"✕"})]}),e.jsx("pre",{className:"whitespace-pre-wrap",children:t||"(no stderr captured)"})]})})}const ER=Object.freeze(Object.defineProperty({__proto__:null,BuildLogsModal:Jb},Symbol.toStringTag,{value:"Module"})),T2=1500;function Xb({stackId:t,pollMs:s=T2,onStateChange:n}){const[r,a]=l.useState({state:"idle"}),[o,i]=l.useState(!1),[c,d]=l.useState(!1),u=l.useRef(n);u.current=n,l.useEffect(()=>{let m=!1,f=!0;const b=async()=>{var v;try{const x=await fetch("/api/simulator-status");if(!x.ok)return;const y=await x.json();if(m||!f)return;const{history:w,...j}=y;a(j),(v=u.current)==null||v.call(u,j)}catch{}};b();const g=window.setInterval(b,s);return()=>{m=!0,f=!1,window.clearInterval(g)}},[s]);const h=l.useCallback(async()=>{if(!o){i(!0);try{const m=t?JSON.stringify({stack_id:t}):"{}";await fetch("/api/start-simulator",{method:"POST",headers:{"content-type":"application/json"},body:m})}finally{i(!1)}}},[t,o]),p=o||C2(r);return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 text-sm border-b",style:{background:"var(--bg-deep)",color:"var(--text-primary)"},children:[e.jsx("button",{type:"button",onClick:h,disabled:p,className:"px-3 py-1 rounded font-medium disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"var(--accent)",color:"var(--bg-deep)"},children:r.state==="app-launched"?"Restart simulator":"Start simulator"}),e.jsx(Qb,{status:r}),r.state==="build-failed"?e.jsx("button",{type:"button",onClick:()=>d(!0),className:"text-xs underline opacity-80 hover:opacity-100",children:"see logs"}):null,c&&r.state==="build-failed"?e.jsx(Jb,{stderrTail:r.stderrTail,onClose:()=>d(!1)}):null]})}function Qb({status:t}){const s=Zb(t);return e.jsx("span",{className:"text-xs opacity-80","data-testid":"simulator-status-pill",children:s})}function Zb(t){switch(t.state){case"idle":return"No simulator running";case"preflight-running":return"Pre-flight checks…";case"preflight-failed":return`Pre-flight failed: ${t.check} — ${t.message}`;case"booting-simulator":return`Booting ${t.device}…`;case"simulator-booted":return`Simulator booted (${t.name})`;case"building-app":return`Building (${ex(t.elapsedSec)})…`;case"build-failed":return"Build failed";case"app-launched":return`App running ▸${t.appBundleId!=="com.codeyam.android"?" (host proxy active)":""}`;case"stopped":return t.reason.kind==="user-requested"?"Stopped":t.reason.kind==="editor-server-shutdown"?"Editor server shut down":t.reason.code!=null?`Stopped (exit ${t.reason.code})`:"Stopped"}}function ex(t){if(t<60)return`${t}s`;const s=Math.floor(t/60),n=t%60;return`${s}m ${n.toString().padStart(2,"0")}s`}const MR=Object.freeze(Object.defineProperty({__proto__:null,SimulatorLauncherControls:Xb,StatusPill:Qb,formatElapsed:ex,pillText:Zb},Symbol.toStringTag,{value:"Module"}));function Cn({src:t,caption:s,currentHeight:n,currentWidth:r,isFilled:a,scale:o}){const i=s?e.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 px-3 py-2 text-center text-xs font-medium text-white/90 bg-black/55 backdrop-blur-sm",children:s}):null;return a?e.jsxs("div",{className:"relative w-full h-full",children:[e.jsx("img",{src:t,alt:"Simulator / Emulator preview",className:"w-full h-full object-contain",style:{background:"var(--bg-deep)"}}),i]}):e.jsxs("div",{className:"relative shadow-[0_10px_30px_rgba(0,0,0,0.45)]",style:{width:r,height:n,transform:o<1?`scale(${o})`:void 0,transformOrigin:"center center",flexShrink:0},children:[e.jsx("img",{src:t,alt:"Simulator / Emulator preview",style:{width:"100%",height:"100%",background:"var(--bg-deep)",objectFit:"contain"}}),i]})}const IR=Object.freeze(Object.defineProperty({__proto__:null,DeviceFrameImage:Cn},Symbol.toStringTag,{value:"Module"}));function Hn({currentWidth:t,currentHeight:s,isFilled:n,scale:r,title:a,hint:o}){const i=e.jsx("div",{className:"w-full h-full border border-dashed rounded flex items-center justify-center text-center px-6",style:{borderColor:"var(--border-default)",background:"var(--bg-surface)",color:"var(--text-dim)"},children:e.jsxs("div",{className:"text-sm leading-relaxed",children:[e.jsx("div",{className:"font-medium",children:a}),e.jsx("div",{className:"opacity-70 mt-1",children:o})]})});return n?i:e.jsx("div",{className:"shadow-[0_10px_30px_rgba(0,0,0,0.45)]",style:{width:t,height:s,transform:r<1?`scale(${r})`:void 0,transformOrigin:"center center",flexShrink:0},children:i})}const DR=Object.freeze(Object.defineProperty({__proto__:null,SimulatorFrameNotice:Hn},Symbol.toStringTag,{value:"Module"}));function tx({currentWidth:t,currentHeight:s,isFilled:n,scale:r,variant:a}){const o=a==="xcode-missing"?"Xcode/Android tooling not detected":"No simulator / emulator running",i=a==="xcode-missing"?"Install Xcode or Android SDK + command line tools, then boot a device.":"Boot a simulator or emulator to see the live preview.";return e.jsx(Hn,{currentWidth:t,currentHeight:s,isFilled:n,scale:r,title:o,hint:i})}const LR=Object.freeze(Object.defineProperty({__proto__:null,NoBootedSimulatorPlaceholder:tx},Symbol.toStringTag,{value:"Module"})),P2=1500;function sx(t=P2){const[s,n]=l.useState({available:!1,loading:!0});return l.useEffect(()=>{let r=!1;const a=()=>{fetch("/api/preview-capture-status").then(i=>i.ok?i.json():{available:!1}).then(i=>{r||n({available:(i==null?void 0:i.available)===!0,loading:!1})}).catch(()=>{r||n(i=>({available:i.available,loading:!1}))})};a();const o=window.setInterval(a,t);return()=>{r=!0,window.clearInterval(o)}},[t]),s}const O2=700;function nx({currentHeight:t,currentWidth:s,isFilled:n,scale:r,pollMs:a=O2,onError:o,deviceLabel:i="iOS Simulator",scenarioScreenshotSrc:c=null}){const[d,u]=l.useState(0),[h,p]=l.useState({kind:"loading"}),m=l.useRef(o);m.current=o;const f=sx();if(l.useEffect(()=>{if(c)return;let g=!1;const v=window.setInterval(()=>{g||u(x=>x+1)},a);return()=>{g=!0,window.clearInterval(v)}},[a,c]),l.useEffect(()=>{if(c)return;let g=!1;return fetch(`/api/simulator-frame?t=${d}`,{method:"HEAD"}).then(async v=>{var y;if(g)return;if(v.ok){p({kind:"ok"});return}if(v.status===503){const w=await A2(v);if(g)return;(typeof(w==null?void 0:w.error)=="string"?w.error:"").includes("xcode")?p({kind:"xcode-missing"}):p({kind:"no-device"});return}const x=`simulator frame request failed (${v.status})`;p({kind:"capture-failed",message:x}),(y=m.current)==null||y.call(m,x)}).catch(v=>{var y;if(g)return;const x=v instanceof Error?v.message:"simulator frame request errored";p({kind:"capture-failed",message:x}),(y=m.current)==null||y.call(m,x)}),()=>{g=!0}},[d,c]),c)return e.jsx(Cn,{src:c,caption:`Captured scenario frame — start the ${i} to interact live.`,currentWidth:s,currentHeight:t,isFilled:n,scale:r});if(h.kind==="no-device"||h.kind==="xcode-missing")return!f.loading&&f.available?e.jsx(Cn,{src:"/api/preview-capture",caption:`Last captured frame — start the ${i} to interact live.`,currentWidth:s,currentHeight:t,isFilled:n,scale:r}):e.jsx(tx,{currentWidth:s,currentHeight:t,isFilled:n,scale:r,variant:h.kind});if(h.kind==="loading")return e.jsx(Hn,{currentWidth:s,currentHeight:t,isFilled:n,scale:r,title:`Connecting to the ${i}…`,hint:"Waiting for the first live frame."});if(h.kind==="capture-failed")return e.jsx(Hn,{currentWidth:s,currentHeight:t,isFilled:n,scale:r,title:"Live preview frame unavailable",hint:`Your app is still running — interact with it directly in the ${i} window.`});const b=`/api/simulator-frame?t=${d}`;return e.jsx(Cn,{src:b,currentWidth:s,currentHeight:t,isFilled:n,scale:r})}async function A2(t){try{return await t.json()}catch{return null}}const FR=Object.freeze(Object.defineProperty({__proto__:null,SimulatorPreviewFrame:nx},Symbol.toStringTag,{value:"Module"}));function rx({emptyStateMessage:t,projectSetupInProgress:s,previewSlug:n,previewUrl:r,viewports:a,activeViewport:o,onViewportChange:i,isCollapsed:c,onToggleCollapsed:d,isFilled:u,onToggleFilled:h,currentWidth:p,currentHeight:m,onCustomSizeChange:f,buildingScenarioSlug:b,buildingScreenshotPath:g,buildingScenarioName:v,onDismissBuildingOverlay:x,historicalScreenshotPath:y,historicalScenarioName:w,historicalHeading:j,historicalSubtext:k,onDismissHistoricalPreview:S,previewSeeding:N,previewSeedError:T,onRetrySeed:A,currentScenario:_,scenarioGroups:M,onShowScenarioPreview:I,commandNonce:H,previewOrigin:z,isNarrow:G=!1,onDesignConfirmed:R}){const[D,P]=l.useState(!1),{containerRef:$,containerSize:F,scale:U}=qk({currentHeight:m,currentWidth:p,isFilled:u}),J=kf();l.useEffect(()=>{It()||Bk(T??null)},[T]);const Z=Jk(_,o),te=Z?at(Z):null,ie=r?zo(r):"",V=ie==="/results"||ie.startsWith("/results/"),le=ie==="/plan-preview",me=ie==="/design-exploration";return le?e.jsx(Kg,{}):V?e.jsx(Lf,{}):me?e.jsx(Ng,{onDesignConfirmed:R}):s&&!r&&!J.loading&&!Or(J.kind)?e.jsx(Vb,{}):e.jsxs("div",{"data-preview-pane":"true",className:"flex-1 flex flex-col min-w-0",children:[e.jsx(Gg,{viewports:a,active:o,onChange:i,currentWidth:p,currentHeight:m,previewUrl:r,isCollapsed:c,onToggleCollapsed:d,isFilled:u,onToggleFilled:h,containerWidth:(F==null?void 0:F.width)??null,containerHeight:(F==null?void 0:F.height)??null,onCustomSizeChange:f,currentScenario:_??null,scenarioGroups:M??[],onShowScenarioPreview:I??(()=>{}),onCreateStateRequest:()=>P(!0),isNarrow:G}),T?e.jsx(Yb,{error:T,onRetry:A}):null,e.jsxs("div",{className:"relative flex-1 flex flex-col min-h-0",children:[Or(J.kind)?e.jsxs(e.Fragment,{children:[e.jsx(Xb,{}),e.jsx(Cg,{deviceLabel:yi(J.kind)}),e.jsx("div",{ref:$,className:"relative flex-1 flex overflow-hidden items-center justify-center p-8",style:{backgroundColor:"#1e1e1e"},children:e.jsx(nx,{currentHeight:m,currentWidth:p,isFilled:u,scale:U,deviceLabel:yi(J.kind),scenarioScreenshotSrc:te})})]}):e.jsx(Lb,{containerRef:$,containerHeight:F==null?void 0:F.height,containerWidth:F==null?void 0:F.width,currentHeight:m,currentWidth:p,emptyStateMessage:t??"Select a scenario to preview",isFilled:u,previewSlug:n,previewUrl:r,previewOrigin:z,scale:U,buildingScenarioSlug:b,buildingScreenshotPath:g,buildingScenarioName:v,onDismissBuildingOverlay:x,historicalScreenshotPath:y,historicalScenarioName:w,historicalHeading:j,historicalSubtext:k,onDismissHistoricalPreview:S,commandNonce:H}),N?e.jsx(Kb,{label:Or(J.kind)?"Loading scenario on device…":void 0}):null]}),D?e.jsx(Ff,{onClose:()=>P(!1)}):null]})}const zR=Object.freeze(Object.defineProperty({__proto__:null,PreviewPanel:rx},Symbol.toStringTag,{value:"Module"})),Ea="reset";function ax({busy:t,onCancel:s,onConfirm:n}){const[r,a]=l.useState(""),o=r.trim().toLowerCase()===Ea;return l.useEffect(()=>{const i=c=>{c.key==="Escape"&&!t&&s()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t,s]),e.jsx("div",{role:"presentation",onClick:()=>{t||s()},style:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(2px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:200,padding:24},children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Cancel build and reset everything?",onClick:i=>i.stopPropagation(),style:{background:"var(--bg-elevated, #141414)",border:"1px solid var(--border-default)",borderRadius:12,padding:24,width:"min(440px, 100%)",display:"flex",flexDirection:"column",gap:16,fontFamily:"'IBM Plex Mono', monospace",boxShadow:"0 20px 60px rgba(0,0,0,0.5)"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx("h2",{style:{margin:0,color:"var(--text-primary)",fontSize:16,fontWeight:600},children:"Cancel build & reset everything?"}),e.jsxs("p",{style:{margin:0,color:"var(--text-secondary)",fontSize:13},children:["This stops the current build, clears the editor session, and"," ",e.jsx("strong",{style:{color:"var(--accent-red)"},children:"permanently discards uncommitted code changes"})," ","(back to the current commit). This cannot be undone."]})]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:6,color:"var(--text-secondary)",fontSize:12},children:["Type ",e.jsx("strong",{style:{color:"var(--text-primary)"},children:Ea})," to confirm",e.jsx("input",{type:"text",value:r,disabled:t,autoFocus:!0,"data-testid":"reset-confirm-input",onChange:i=>a(i.target.value),style:{padding:"8px 10px",background:"var(--bg-input, #0f0f0f)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderRadius:6,fontSize:13,fontFamily:"inherit"}})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[e.jsx("button",{type:"button",onClick:s,disabled:t,style:{padding:"8px 16px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)",borderRadius:6,fontSize:13,fontWeight:500,cursor:t?"wait":"pointer",opacity:t?.5:1,fontFamily:"inherit"},children:"Cancel"}),e.jsx("button",{type:"button",onClick:n,disabled:t||!o,"data-testid":"reset-confirm-button",style:{padding:"8px 18px",background:"var(--accent-red, #ff5c5c)",color:"#fff",border:"1px solid var(--accent-red, #ff5c5c)",borderRadius:6,fontSize:13,fontWeight:600,cursor:t?"wait":o?"pointer":"not-allowed",opacity:t||!o?.5:1,fontFamily:"inherit"},children:t?"Resetting…":"Reset everything"})]})]})})}const $R=Object.freeze(Object.defineProperty({__proto__:null,RESET_CONFIRM_WORD:Ea,ResetBuildConfirmModal:ax},Symbol.toStringTag,{value:"Module"}));function R2(){const[t,s]=l.useState([]),[n,r]=l.useState(!0),[a,o]=l.useState(null),{scenariosVersion:i}=Xt(),c=l.useCallback(async()=>{r(!0),o(null);try{const u=await fetch("/api/scenarios");if(!u.ok)throw new Error(`HTTP ${u.status}`);const h=(await u.json()).map(Da);s(Eg(h))}catch(u){o(u instanceof Error?u.message:"Failed to load scenarios")}finally{r(!1)}},[]);l.useEffect(()=>{c()},[c,i]);const d=t.reduce((u,h)=>u+h.scenarios.length,0);return{groups:t,loading:n,error:a,totalScenarios:d,reload:c}}function E2(){const[t,s]=l.useState([]),[n,r]=l.useState(!0),[a,o]=l.useState(null),{scenariosVersion:i}=Xt(),c=l.useCallback(async()=>{r(!0),o(null);try{const d=await fetch("/api/app-route-entities");if(!d.ok)throw new Error(`HTTP ${d.status}`);const u=await d.json();s(Array.isArray(u)?u.map(h=>({...h,scenarios:Array.isArray(h==null?void 0:h.scenarios)?h.scenarios.map(Da):[]})):[])}catch(d){o(d instanceof Error?d.message:"Failed to load app routes"),s([])}finally{r(!1)}},[]);return l.useEffect(()=>{c()},[c,i]),{routeEntities:t,loading:n,error:a,reload:c}}function vl(t){const s=new Map;for(const n of t){const r=M2(n.path);let a=s.get(r);a||(a=[],s.set(r,a));for(const o of n.tests)a.push({...o,file:n.path})}return Array.from(s.entries()).map(([n,r])=>({feature:n,tests:r})).filter(n=>n.tests.length>0).sort((n,r)=>n.feature.localeCompare(r.feature))}function M2(t){const n=t.replace(/\\/g,"/").replace(/^\.\//,"").split("/").filter(r=>r.length>0);return n.length===0?"Other":n[0]==="crates"&&n.length>=2?`crates/${n[1]}`:t==="(no-file)"?"(no-file)":n[0]}function ox(t,s){if(s===".")return t;const n=s.endsWith("/")?s:`${s}/`;return t.map(r=>({feature:r.feature,tests:r.tests.filter(a=>a.file.startsWith(n))})).filter(r=>r.tests.length>0)}function ix(t,s,n){return n==="backend"?[]:t.map(r=>({...r,scenarios:r.scenarios.filter(Wn)})).filter(r=>r.scenarios.length>0)}function lx(t){let s=0,n=0,r=0,a=0,o=0;for(const i of t)for(const c of i.tests)o+=1,s+=1,c.status==="passed"?n+=1:c.status==="skipped"?a+=1:c.status==="failed"&&(r+=1);return{total:s,passed:n,failed:r,ignored:a,discovered:o}}function I2(t){return t.reduce((s,n)=>s+n.scenarios.length,0)}const D2=3e3;function L2(){const[t,s]=l.useState([]),[n,r]=l.useState(!0),[a,o]=l.useState(!1),[i,c]=l.useState(null),[d,u]=l.useState(!1),[h,p]=l.useState(null),[m,f]=l.useState(null),[b,g]=l.useState(null),v=l.useRef(null),x=l.useRef(null),y=l.useRef(!1),w=l.useRef(null),{testsVersion:j}=Xt(),k=l.useCallback(async(I=!1)=>{var R;(R=v.current)==null||R.abort();const H=new AbortController;v.current=H;const{signal:z}=H;I&&(y.current=!0,o(!0));const G=!I&&w.current!==null;G||(r(!0),c(null));try{if(!I&&!G)try{const F=await fetch("/api/test-results/summary",{signal:z});if(F.ok){const U=await F.json();U.running?p(U.currentRunner??null):U.stats&&(f(U.stats),g(U.coverage??null))}}catch{}let D,P;if(G){D=w.current;const F=await fetch("/api/test-results",{signal:z});if(!F.ok)throw new Error(`test-results: HTTP ${F.status}`);P=await F.json()}else if(I){const F=await fetch("/api/test-results/refresh",{method:"POST",signal:z});if(!F.ok)throw new Error(`test-results: HTTP ${F.status}`);P=await F.json(),D=w.current??[]}else{const[F,U]=await Promise.all([fetch("/api/tests",{signal:z}),fetch("/api/test-results",{signal:z})]);if(!F.ok)throw new Error(`tests: HTTP ${F.status}`);if(!U.ok)throw new Error(`test-results: HTTP ${U.status}`);D=vl(await F.json()),P=await U.json(),w.current=D}if(p(P.currentRunner??null),P.running&&y.current){x.current=setTimeout(()=>k(!1),D2);return}const $=y.current;if(y.current=!1,$){const F=await fetch("/api/tests",{signal:z});F.ok&&(D=vl(await F.json()),w.current=D)}s(D),u(P.cached??!1),g(P.coverage??null),f(null),r(!1),o(!1)}catch(D){if(D instanceof DOMException&&D.name==="AbortError")return;y.current=!1,c(D instanceof Error?D.message:"Failed to load tests"),r(!1),o(!1)}},[]);l.useEffect(()=>(w.current=null,k(),()=>{var I;(I=v.current)==null||I.abort(),x.current&&clearTimeout(x.current)}),[k,j]);const{total:S,passed:N,failed:T,ignored:A,discovered:_}=l.useMemo(()=>lx(t),[t]),M=l.useCallback(()=>{y.current||k(!0)},[k]);return{groups:t,loading:n,refreshing:a,error:i,cached:d,currentRunner:h,summaryStats:m,coverage:b,totalTests:S,passedTests:N,failedTests:T,ignoredTests:A,discoveredTests:_,reload:k,refresh:M}}function Vo(t,s){return t.filter(n=>n.appDir===s)}function cx(t,s){return s?t.find(n=>n.route===s)??null:null}function dx(t,s,n,r=null){const a=ix(t,s,n);return $2(a,r)}function F2(t){const s=t.filter(o=>o.defaultScenarioSlug);if(s.length===0)return null;const n=s.find(o=>o.route==="/"&&o.defaultScenarioSlug);if(n!=null&&n.defaultScenarioSlug)return n.defaultScenarioSlug;const r=s.find(o=>o.defaultScenarioSlug&&o.scenarios.some(i=>Ma(i)));if(r!=null&&r.defaultScenarioSlug)return r.defaultScenarioSlug;const a=[...s].sort((o,i)=>o.route.length-i.route.length||o.route.localeCompare(i.route))[0];return(a==null?void 0:a.defaultScenarioSlug)??null}function z2(t){return(t==null?void 0:t.defaultScenarioSlug)??null}function ux(t,s,n=null){const r=t.find(a=>a.type==="web");return r?dx(s,r.dir,r.type,n):null}function $2(t,s){const n=t.flatMap(d=>d.scenarios.filter(u=>Wn(u)).map(u=>({route:d.route,scenario:u})));if(n.length===0)return null;const r=fn(n.filter(({route:d,scenario:u})=>d==="/"&&Ma(u)),s);if(r)return r.scenario.slug;const a=fn(n.filter(({route:d})=>d==="/"),s);if(a)return a.scenario.slug;const o=fn(n.filter(({scenario:d})=>Ma(d)),s);if(o)return o.scenario.slug;const i=Math.min(...n.map(({route:d})=>d.length)),c=fn(n.filter(({route:d})=>d.length===i),s);return(c==null?void 0:c.scenario.slug)??null}function fn(t,s){return t.find(({scenario:n})=>B2(n,s))??t[0]??null}function B2(t,s){return s?t.dimensions.length===0||t.dimensions.includes(s):!0}function Ma(t){return/\bhome\b/i.test(t.name)}function jl(t){return new Set(t.flatMap(s=>s.scenarios.map(n=>n.slug)))}function Ur({selectedApp:t,appRouteEntities:s,scenarioGroups:n,defaultScreenSize:r=null}){return t?F2(s)??dx(n,t.dir,t.type,r):null}function H2({apps:t,hasExplicitAppSelection:s,scenarioGroups:n,defaultScreenSize:r=null}){return s||t.length===0||n.length===0?null:ux(t,n,r)}function wl(t){return z2(t)}function W2({apps:t,routeEntities:s,selectedApp:n,appRouteEntities:r}){if(n)return r;const a=t.find(o=>o.type==="web");return a?Vo(s,a.dir):[]}function q2({previewRouteEntities:t,selectedRouteEntity:s}){var r;if(s!=null&&s.route)return s.route;if(t.length===0)return null;const n=t.find(a=>a.route==="/");return n?n.route:((r=[...t].sort((a,o)=>a.route.length-o.route.length||a.route.localeCompare(o.route))[0])==null?void 0:r.route)??null}function G2({previewRouteEntities:t,path:s}){var r;const n=zo(s);return((r=cx(t,n))==null?void 0:r.defaultScenarioSlug)??null}function U2(t){return t.startsWith("/scenario/")||gn(t)}function V2(t){return U2(t)?!1:t==="/"||t==="/apps"||t==="/apps/"}function Y2(t,s,n=""){const r=Ar(n),[a,o]=l.useState(r.selectedAppDir),[i,c]=l.useState(r.selectedEntityHash);l.useEffect(()=>{const y=Ar(n);o(w=>w===y.selectedAppDir?w:y.selectedAppDir),c(w=>w===y.selectedEntityHash?w:y.selectedEntityHash)},[n]),l.useEffect(()=>{if(typeof window>"u"||t.length!==1)return;const y=Ar(n);if(y.selectedAppDir||y.selectedEntityHash||!V2(n))return;const w=Rr(t[0].dir);`${window.location.pathname}${window.location.search}`!==w&&(window.history.replaceState({},"",w),o(t[0].dir))},[t,n]);const d=l.useMemo(()=>i?s.find(y=>Qr(y)===i)??null:null,[s,i]),u=l.useMemo(()=>a?t.find(y=>y.dir===a)??null:d?t.find(y=>y.dir===d.appDir)??null:i?t.find(y=>y.type==="web")??t[0]??null:null,[t,a,d,i]),h=l.useMemo(()=>u?Vo(s,u.dir):[],[s,u]),p=l.useMemo(()=>i?d:null,[i,d]);function m(y){if(typeof window>"u")return;const w=`${window.location.pathname}${window.location.search}`;y!==w&&window.history.pushState({},"",y)}function f(y){o(y),c(null),m(Rr(y))}function b(){o(null),c(null),m("/apps")}function g(y){const w=h.find(S=>S.route===y);if(!w)return;const j=Qr(w),k=pc(w);!j||!k||(c(j),m(k))}function v(y){c(y),m(`/entities/${y}`)}function x(){c(null),m(a?Rr(a):"/apps")}return{selectedApp:u,appRouteEntities:h,selectedEntityHash:i,selectedRouteEntity:p,selectApp:f,deselectApp:b,selectRoute:g,selectEntity:v,deselectRoute:x}}function K2(t,s,n,r,a="",o=null,i=!0,c){const[d,u]=l.useState(null),h=l.useRef(!1),p=l.useRef(!1),{selectedApp:m,appRouteEntities:f,selectedEntityHash:b,selectedRouteEntity:g,selectApp:v,deselectApp:x,selectRoute:y,selectEntity:w,deselectRoute:j}=Y2(t,s,a),k=l.useMemo(()=>jl(f),[f]),S=l.useMemo(()=>jl(g?[g]:[]),[g]),N=l.useMemo(()=>Ur({selectedApp:m,appRouteEntities:f,scenarioGroups:n,defaultScreenSize:o}),[f,o,n,m]),T=l.useMemo(()=>wl(g),[g]),A=l.useMemo(()=>m?ox(r,m.dir):[],[r,m]);l.useEffect(()=>{if(h.current)return;if(c!=null&&c.current){h.current=!0;return}if(!i)return;const R=H2({apps:t,scenarioGroups:n,hasExplicitAppSelection:!!m,defaultScreenSize:o});R&&(u(R),h.current=!0)},[t,o,n,m,i,c]),l.useEffect(()=>{if(m){if(p.current){p.current=!1;return}if(g){if(!T||d&&S.has(d))return;u(T);return}N&&(d&&k.has(d)||u(N))}},[N,T,d,m,k,g,S]);function _(R){v(R);const D=t.find($=>$.dir===R);if(!D)return;const P=Ur({selectedApp:D,appRouteEntities:Vo(s,D.dir),scenarioGroups:n,defaultScreenSize:o});u(P)}function M(){x(),u(ux(t,n,o))}function I(R){y(R);const D=wl(cx(f,R));u(D)}const H=l.useCallback(R=>{p.current=!0,u(R)},[]);function z(){if(j(),!m)return;const R=Ur({selectedApp:m,appRouteEntities:f,scenarioGroups:n,defaultScreenSize:o});R&&u(R)}function G(R){w(R)}return{selectedApp:m,appRouteEntities:f,appTestGroups:A,selectedEntityHash:b,selectedRouteEntity:g,previewSlug:d,setPreviewSlug:u,setPreviewSlugExplicit:H,selectApp:_,deselectApp:M,selectRoute:I,selectEntity:G,deselectRoute:z}}const J2=1e3;function X2(t,s){const n=l.useRef(t);n.current=t;const r=l.useRef(s);r.current=s;const a=l.useRef(null),o=l.useRef(null);l.useEffect(()=>{let i=!0;async function c(){var d;if(i){try{const u=a.current,h=u===null?"/api/editor-commands":`/api/editor-commands?since=${u}`,p=await fetch(h);if(p.ok){const m=await p.json();typeof m.seq=="number"&&(a.current=m.seq),m.bootId&&(o.current===null?o.current=m.bootId:o.current!==m.bootId&&(o.current=m.bootId,(d=r.current)==null||d.call(r)));for(const f of m.commands??[])n.current(f)}}catch{}i&&setTimeout(c,J2)}}return c(),()=>{i=!1}},[])}function Q2(){const[t,s]=l.useState({}),[n,r]=l.useState(!0),[a,o]=l.useState(null);l.useEffect(()=>{let c=!1;return fetch("/api/dependency-graph").then(d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);return d.json()}).then(d=>{if(c)return;const u="files"in d?d.files:d;s(u),r(!1)}).catch(d=>{c||(o(d.message),r(!1))}),()=>{c=!0}},[]);const i=l.useMemo(()=>Nv(t),[t]);return{graph:t,entityLookup:i,loading:n,error:a}}const Z2=["/apps","/entities","/app","/build","/history","/settings","/plan"];function hx(t){if(!t)return!1;const s=zo(t);return Z2.some(n=>s===n||s.startsWith(`${n}/`))}function eC(t,s,n){const r=typeof window<"u"?jf(window.location):0;let a="";if(Oy(t)==="component"?a=_f(t.slug,r,t.url,s,n):t.url&&(a=wf(t.url,{appPort:s,currentPort:r,previewOrigin:n})),a&&!hx(a))try{const o=!a.startsWith("http"),i=typeof window<"u"?window.location.origin:"http://localhost",c=new URL(a,i);return c.searchParams.set("_codeyam_scenario",t.slug),o?c.pathname+c.search+c.hash:c.toString()}catch{return a}return a}function tC(t){return t==="/design-exploration"}function sC(t,s,n){return t.startsWith("http")||t?t:n?`${n}/results`:`http://127.0.0.1:${s}/results`}function nC(t,s,n){return t.startsWith("http")||t?t:n?`${n}/plan-preview`:`http://127.0.0.1:${s}/plan-preview`}function px(t,s){if(!s)return null;for(const n of t)for(const r of n.scenarios)if(r.slug===s||r.id===s)return r;return null}function rC({directPreviewPath:t,fallbackPreviewPath:s,previewKind:n,selectedScenario:r,port:a,previewOrigin:o}){return n==="blank"?"":t&&(n==="application"||n==="results"||n==="plan-preview")?n==="results"?sC(t,a,o):n==="plan-preview"?nC(t,a,o):t.startsWith("http")||tC(t)?t:o?`${o}${t}`:`http://127.0.0.1:${a}${t}`:r?eC({slug:r.slug,scenarioType:r.scenarioType,componentName:r.componentName,url:r.url},a,o):s?s.startsWith("http")?s:o?`${o}${s}`:`http://127.0.0.1:${a}${s}`:""}function aC(t,s=Date.now()){const n=t.includes("?")?"&":"?";return`${t}${n}_cb=${s}`}function Ia(t,s){if(!t)return null;for(const n of s)for(const r of n.scenarios)if(r.slug===t)return r;return null}function oC({apps:t,appRouteEntities:s,directPreviewPath:n,fallbackPort:r,previewKind:a,previewOrigin:o,previewSlug:i,routeEntities:c,scenarioGroups:d,selectedApp:u,selectedRouteEntity:h}){const p=px(d,i),m=W2({apps:t,routeEntities:c,selectedApp:u,appRouteEntities:s}),f=q2({previewRouteEntities:m,selectedRouteEntity:h});let b="blank";a==="plan-preview"&&n?b="plan-preview":a==="results"&&n?b="results":a==="application"&&n?b="application":p?b=Wn(p)?"application":"component":f&&(b="application");const g=rC({directPreviewPath:n,fallbackPreviewPath:f,previewKind:b,selectedScenario:p,port:r,previewOrigin:o});return{selectedScenario:p,previewRouteEntities:m,fallbackPreviewPath:f,resolvedPreviewKind:b,basePreviewUrl:g}}function iC({allowEditorRoutePreview:t,command:s,configLoaded:n,previewRouteEntities:r,scenarioGroups:a,scenarioDeferAvailable:o=!1}){const i=s.dimension??null,c=!!s.dimension,d=s.commandNonce;if(s.scenarioSlug??s.scenarioId){const g=s.scenarioSlug??s.scenarioId,v=px(a,g);return v?{clearCustomSize:c,scenarioSlug:v.slug,type:"show-scenario",viewportName:i,commandNonce:d}:o?{clearCustomSize:c,type:"defer",viewportName:i,commandNonce:d}:s.path?{clearCustomSize:c,path:s.path,previewKind:"application",previewSlug:null,preserveDirectPreviewPathOnSlugChange:!0,type:"show-path",viewportName:i,commandNonce:d}:{clearCustomSize:c,scenarioSlug:g,type:"show-scenario",viewportName:i,commandNonce:d}}if(!s.path)return{clearCustomSize:c,type:"refresh",viewportName:i,commandNonce:d};const u=s.path,h=u.startsWith("http")?new URL(u).pathname:u.split("?")[0]??u,p=h==="/results"||h.startsWith("/results/"),m=h==="/plan-preview",f=hx(u);if(m)return{clearCustomSize:c,path:u,previewKind:"plan-preview",previewSlug:null,preserveDirectPreviewPathOnSlugChange:!1,type:"show-path",viewportName:i,commandNonce:d};if(p)return{clearCustomSize:c,path:u,previewKind:"results",previewSlug:null,preserveDirectPreviewPathOnSlugChange:!1,type:"show-path",viewportName:i,commandNonce:d};if(f&&!t)return{clearCustomSize:c,type:n?"ignore":"defer",viewportName:i,commandNonce:d};if(f&&t)return{clearCustomSize:c,path:u,previewKind:"application",previewSlug:null,preserveDirectPreviewPathOnSlugChange:!0,type:"show-path",viewportName:i,commandNonce:d};const b=G2({previewRouteEntities:r,path:u});return b?{clearCustomSize:c,scenarioSlug:b,type:"show-scenario",viewportName:i,commandNonce:d}:{clearCustomSize:c,path:u,previewKind:"application",previewSlug:null,preserveDirectPreviewPathOnSlugChange:!1,type:"show-path",viewportName:i,commandNonce:d}}function lC(t,s,n,r,a){const o=r.dimensions;return o.length===0||o.includes(t)&&s===null&&n===null?null:o.find(i=>a.some(c=>c.name===i))??o[0]}const cC=[{name:"Desktop",width:1440,height:900},{name:"Laptop",width:1024,height:768},{name:"Tablet",width:768,height:1024},{name:"Mobile",width:375,height:667}];function dC(t,s){const n=Object.entries(t);if(n.length===0)return cC;const r=n.map(([a,o])=>({name:a,width:o.width,height:o.height}));if(s){const a=r.findIndex(o=>o.name===s);if(a>0){const[o]=r.splice(a,1);r.unshift(o)}}return r}function uC({isInIframe:t,hydrated:s=!0,persistedPath:n,previewKind:r,resolvedViewport:a,selectedScenario:o}){l.useEffect(()=>{t||!s||fetch("/api/editor-preview-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:r==="blank"?null:r,path:n,scenarioSlug:(o==null?void 0:o.slug)??null,scenarioId:(o==null?void 0:o.id)??null,dimension:a.name,width:a.width,height:a.height})}).catch(()=>{})},[s,t,n,r,a.height,a.name,a.width,o==null?void 0:o.id,o==null?void 0:o.slug])}function hC({isInIframe:t,onActivated:s,previewKind:n,previewMedium:r,scenariosLoaded:a,selectedScenario:o}){const[i,c]=l.useState(!1),[d,u]=l.useState(null);return l.useEffect(()=>{if(!a||t)return;if(Ay({isInIframe:t,previewKind:n,previewMedium:r,selectedScenario:o})){fetch("/api/editor-deactivate-scenario",{method:"POST"}).catch(()=>{});return}if(!o||o.scenarioType!=="application")return;let h=!1;return c(!0),u(null),fetch("/api/editor-activate-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:o.slug})}).then(async p=>{const m=await p.json().catch(()=>null);if(!h){if(!m||m.success===!1||m.seedError||m.deviceSeedError){u(m&&(m.seedError||m.deviceSeedError||m.error)||"scenario activation failed");return}s()}}).catch(p=>{h||u(p instanceof Error?p.message:String(p))}).finally(()=>{h||c(!1)}),()=>{h=!0}},[t,s,n,r,a,o==null?void 0:o.componentName,o==null?void 0:o.scenarioType,o==null?void 0:o.slug]),{seeding:i,seedError:d}}const pC=3;function mC({apps:t,appRouteEntities:s,configLoaded:n,defaultScreenSize:r,hydrated:a=!0,port:o,previewMedium:i,previewOrigin:c,projectTitle:d,previewSlug:u,routeEntities:h,scenarioGroups:p,scenariosLoaded:m,screenSizes:f,selectedApp:b,selectedRouteEntity:g,setPreviewSlug:v}){const[x,y]=l.useState(r??"Desktop"),w=l.useRef(!1),[j,k]=l.useState(null),[S,N]=l.useState(null),[T,A]=l.useState(null),[_,M]=l.useState(null),[I,H]=l.useState(()=>Date.now()),[z,G]=l.useState(0),R=l.useRef(null),D=l.useRef(!1),P=l.useMemo(()=>dC(f,r),[r,f]);l.useEffect(()=>{w.current||r&&(y(r),w.current=!0)},[r]);const $=l.useMemo(()=>j!==null&&S!==null?{name:"Custom",width:j,height:S}:P.find(oe=>oe.name===x)??P[0]??{name:"Desktop",width:1440,height:900},[x,S,j,P]),F=It(),U=d==="CodeYam Editor",{basePreviewUrl:J,fallbackPreviewPath:Z,previewRouteEntities:te,resolvedPreviewKind:ie,selectedScenario:V}=l.useMemo(()=>oC({apps:t,appRouteEntities:s,directPreviewPath:T,fallbackPort:o,previewKind:_,previewOrigin:c,previewSlug:u,routeEntities:h,scenarioGroups:p,selectedApp:b,selectedRouteEntity:g}),[t,s,T,o,_,c,u,h,p,b,g]),le=l.useMemo(()=>J?aC(J,I):"",[J,I]),me=l.useCallback(oe=>{y(oe),k(null),N(null)},[]),Q=l.useCallback((oe,fe)=>{k(oe),N(fe)},[]),C=l.useCallback(oe=>{v(oe),A(null),M(null),H(Date.now());const fe=Ia(oe,p);if(!fe)return;const xe=lC(x,j,S,fe,P);xe!==null&&(y(xe),k(null),N(null))},[x,S,j,p,v,P]),E=l.useCallback((oe,fe)=>{const xe=(fe==null?void 0:fe.retriesLeft)??pC,ne=iC({allowEditorRoutePreview:U,command:oe,configLoaded:n,previewRouteEntities:te,scenarioGroups:p,scenarioDeferAvailable:xe>0});if(ne.viewportName&&y(ne.viewportName),ne.clearCustomSize&&(k(null),N(null)),ne.type==="show-scenario"){C(ne.scenarioSlug),G(je=>je+1);return}if(ne.type==="defer"){R.current={command:oe,retriesLeft:xe};return}if(ne.type==="refresh"){H(Date.now()),G(je=>je+1);return}ne.type!=="ignore"&&(ne.type==="show-path"&&(M(ne.previewKind),A(ne.path),D.current=ne.preserveDirectPreviewPathOnSlugChange,typeof ne.previewSlug=="string"?v(ne.previewSlug):ne.previewSlug===null&&v(null)),H(Date.now()),G(je=>je+1))},[n,U,te,p,v,C]);l.useEffect(()=>{if(!n)return;const oe=R.current;oe&&(R.current=null,E(oe.command,{retriesLeft:oe.retriesLeft-1}))},[n,p,E]),l.useEffect(()=>{if(!(!u||T===null)){if(D.current){D.current=!1;return}A(null),M(null),H(Date.now())}},[T,u]);const B=l.useMemo(()=>ie==="results"||ie==="plan-preview"?T:ie==="application"?T??(V==null?void 0:V.url)??Z:null,[T,Z,ie,V==null?void 0:V.url]),se=l.useCallback(()=>{H(Date.now())},[]);uC({isInIframe:F,hydrated:a,persistedPath:B,previewKind:ie,resolvedViewport:$,selectedScenario:V?{id:V.id??null,slug:V.slug}:null});const{seeding:q,seedError:ce}=hC({isInIframe:F,onActivated:se,previewKind:ie,previewMedium:i,scenariosLoaded:m,selectedScenario:V?{slug:V.slug,scenarioType:V.scenarioType,componentName:V.componentName??null}:null}),W=l.useCallback(oe=>{A(oe),M(oe?"application":null),H(Date.now())},[]);return{viewports:P,resolvedViewport:$,previewUrl:le,handleViewportChange:me,handleCustomSizeChange:Q,showScenarioPreview:C,handlePreviewCommand:E,setPreviewPath:W,previewSeeding:q,previewSeedError:ce,commandNonce:z}}function fC({isInIframe:t,scenariosLoaded:s,restoredRef:n,onAdopt:r,onHydrated:a,onSettledEmpty:o}){const i=l.useRef(!1),c=l.useRef(!1),d=l.useRef(null),u=l.useRef(s);u.current=s;const h=l.useRef(r),p=l.useRef(a),m=l.useRef(o);h.current=r,p.current=a,m.current=o;const f=l.useCallback(()=>{if(c.current||!u.current||n.current)return;const b=d.current;b&&(c.current=!0,n.current=!0,h.current(b))},[n]);l.useEffect(()=>{t||i.current||(i.current=!0,fetch("/api/editor-preview-state").then(b=>b.json()).then(b=>{b&&(b.scenarioSlug||b.path)&&(d.current=b,f())}).catch(()=>{}).finally(()=>{var b;p.current(),!c.current&&!d.current&&((b=m.current)==null||b.call(m))}))},[t,f]),l.useEffect(()=>{f()},[s,f])}function gC({restoredRef:t,initiallySettled:s=!1,apply:n}){const r=l.useRef(s),a=l.useRef(null),o=l.useRef(n);o.current=n;const i=l.useCallback(u=>{t.current||(u.scenarioSlug||u.path)&&(t.current=!0,o.current(u))},[t]),c=l.useCallback(u=>{if(!t.current){if(!r.current){a.current=u;return}i(u)}},[i,t]),d=l.useCallback(()=>{r.current=!0;const u=a.current;a.current=null,u&&i(u)},[i]);return{requestRestore:c,onAdoptSettledEmpty:d}}function bC(t,{handlePreviewCommand:s,handleCustomSizeChange:n}){!t.scenarioSlug&&!t.path||(s({...t.scenarioSlug?{scenarioSlug:t.scenarioSlug}:{},...t.path?{path:t.path}:{},...t.dimension?{dimension:t.dimension}:{}}),t.dimension==="Custom"&&typeof t.width=="number"&&typeof t.height=="number"&&n(t.width,t.height))}function xC(){const[t,s]=l.useState(!1),n=l.useCallback(()=>{s(!0)},[]),r=l.useCallback(()=>{},[]),a=l.useCallback(()=>{},[]),o=l.useCallback(()=>{s(!1)},[]);return{showPostPushModal:t,onFeatureCompleteCommand:n,onAgentIdle:r,onAgentActive:a,dismissModal:o}}function mx(t){return t===null||t.slug===null||t.slug==="feature-complete"}function yC({showPostPushModal:t,stepState:s,dismissModal:n}){const r=l.useRef(!1);l.useEffect(()=>{if(!t){r.current=!1;return}if(mx(s)){r.current=!0;return}r.current&&(s==null?void 0:s.slug)!=null&&(n(),r.current=!1)},[t,s,n])}function vC(){const[t,s]=l.useState(!1),n=l.useCallback(()=>{s(!0)},[]),r=l.useCallback(()=>{s(!1)},[]);return{showPlanCompleteModal:t,onPlanCompleteCommand:n,dismissPlanCompleteModal:r}}function jC(){const{showBuildTab:t}=Lo(typeof window>"u"?"/":window.location.pathname),{config:s}=yt(),[n,r]=l.useState(!1),[a,o]=l.useState(null),i=l.useCallback(async c=>{if(n)return!1;o(null),r(!0);try{try{await Io()}catch{}const d=await fetch("/api/build/start-from-prompt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:c})});if(!d.ok){let u=`HTTP ${d.status}`;try{const h=await d.json();h!=null&&h.error&&(u=h.error)}catch{}throw new Error(u)}return t(),await Do({provider:s==null?void 0:s.provider}),!0}catch(d){return o(d instanceof Error?d.message:"Failed to launch build"),!1}finally{r(!1)}},[n,t,s==null?void 0:s.provider]);return{launching:n,error:a,launchPrompt:i}}function wC({onTransitionToLive:t}){const[s,n]=l.useState(!1),[r,a]=l.useState(null),o=l.useRef(!1),i=l.useRef(null),c=l.useRef(t);c.current=t;const d=l.useCallback(()=>{o.current=!0,n(!0)},[]),u=l.useCallback(()=>{o.current=!1,n(!1);const m=i.current;m&&(i.current=null,a(null),c.current(m))},[]),h=l.useCallback(m=>o.current?(i.current=m,a(m),!0):!1,[]),p=l.useCallback(()=>{i.current=null,a(null)},[]);return{isAgentBuilding:s,isAgentBuildingRef:o,buildingScenarioSlug:r,onAgentIdle:u,onAgentActive:d,guardScenarioSelect:h,clearBuildingOverlay:p}}function _C({chatOpen:t}){const[s,n]=l.useState(!1),[r,a]=l.useState(!1);return l.useEffect(()=>{function o(d){const u=d.detail;return(u==null?void 0:u.chatName)==="plan"}function i(d){o(d)&&(n(!0),a(!1))}function c(d){o(d)&&(n(!1),a(!0))}return window.addEventListener("miniagent-agent-active",i),window.addEventListener("miniagent-agent-idle",c),()=>{window.removeEventListener("miniagent-agent-active",i),window.removeEventListener("miniagent-agent-idle",c)}},[]),l.useEffect(()=>{t||(n(!1),a(!1))},[t]),{planActive:s,planIdle:r}}function kC(t,s,n){return t.map(r=>{const a=ox(s,r.dir),o=ix(n,r.dir,r.type),{total:i,passed:c,failed:d,ignored:u,discovered:h}=lx(a),p=I2(o);return{app:r,tests:{total:i,passed:c,failed:d,ignored:u,discovered:h},scenarios:{total:p,thumbnails:SC(o)}}})}function SC(t){const s=[];for(const n of t)for(const r of n.scenarios)if(r.screenshotPaths.length>0&&s.push({path:r.screenshotPaths[0],cacheBuster:r.screenshotCapturedAtMs}),s.length>=6)return s;return s}function NC(t,s){return t==null?null:Math.min(1,Math.max(.04,t/po(s)))}function CC(t,s){return t==null||t===0?null:`${t} / ${po(s)}: ${ho(t,s)}`}const TC="Your app will display here once set up.",PC="Loading your app…",OC="Setting up your project…",AC="Select a scenario to preview",RC="No preview is available for this project.";function EC({configLoading:t,hasNoApps:s,hasStepState:n,hasPreviewableApp:r,setupInProgress:a,hasCaptureFrame:o}){return t?PC:a&&!o?OC:s&&!n?TC:r?AC:RC}const MC=["web","mobile"];function IC(t){return MC.includes(t)}function DC(t,s){return s?{scenarioSlug:t,path:s}:{scenarioSlug:t}}function LC(t,s){return t==="needs-login"&&!s}function FC(t,s){if(!t)return null;for(const n of s)for(const r of n.scenarios)if(r.name===t)return r;return null}const zC="The app is being edited",$C="Live preview will load when the build agent is idle",BC="Showing a saved version",HC="This is a past version of this scenario";function WC({shot:t,isLatest:s,liveScenario:n,isAgentBuilding:r}){if(s&&n&&!r)return{kind:"live",slug:n.slug};const[a,o]=r?[zC,$C]:[BC,HC];return{kind:"historical",screenshotPath:t.screenshotPath??null,scenarioName:t.name,heading:a,subtext:o}}function fx(t){return!t.hasActiveSession&&!t.isAgentBuilding&&!t.showPostPushModal&&t.launchingPlanSlug===null&&!t.submittingBuildPrompt&&!t.stepStateFeature&&!t.buildLaunchModalDismissed}function qC(t){return t.activeTab==="build"&&fx(t)}function GC(t,s,n){const[r,a]=l.useState(!1),o=l.useCallback(()=>{a(!0)},[]),i=l.useCallback(c=>{a(!1),s(c)},[s]);return l.useEffect(()=>{r&&(t||(a(!1),n==null||n(),s("build")))},[r,t,s,n]),{arm:o,navigateToTabUser:i,pendingBuildNav:r}}const UC=4e3,VC=2;function gx({state:t,provider:s,credsPresent:n=!0,reason:r=null,expiresAt:a=null,probeInFlight:o=!1,probeAttempts:i=0,backendOutOfDate:c=!1,sessionOngoing:d=!1,onAuthenticated:u,onAuthorized:h}){const[p,m]=l.useState(!1),[f,b]=l.useState(!1),g=At(s),[v,x]=l.useState(!1);l.useEffect(()=>{if(t!=="unknown"){x(!1);return}const k=window.setTimeout(()=>x(!0),UC);return()=>window.clearTimeout(k)},[t]);const y=l.useCallback(()=>{m(!1),u(),h==null||h()},[u,h]),w=l.useCallback(async()=>{b(!0);try{await fetch("/api/auth/refresh-cache",{method:"POST"}),u()}catch{}finally{b(!1)}},[u]);if(t==="authenticated")return null;const j=p?e.jsx(Xy,{provider:s,onAuthenticated:y,onClose:()=>m(!1)}):null;return t==="unknown"?!(r==="probe-timeout"&&i>=VC)&&(o||!v)||c?null:e.jsxs("div",{"data-testid":"provider-auth-checking","data-auth-card":!0,className:"m-4 rounded-lg border border-[#3A3A3A] bg-[#1E1E1E] p-5 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{"data-testid":"provider-auth-checking-spinner","aria-hidden":"true",className:"h-4 w-4 rounded-full border-2 border-[#8E8E8E] border-t-transparent animate-spin"}),e.jsxs("p",{className:"text-sm text-[#8E8E8E]",children:["Checking your ",g," account… If this takes more than a few seconds, your token may need refresh."]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("button",{onClick:()=>m(!0),"data-testid":"provider-auth-checking-retry",className:"px-3 py-2 text-sm rounded-md bg-[#D7FF63] text-black font-medium cursor-pointer",children:"Authenticate"}),e.jsx("button",{onClick:()=>void w(),"data-testid":"provider-auth-checking-recheck",disabled:f,className:"px-3 py-2 text-sm rounded-md border border-[#3A3A3A] text-white cursor-pointer disabled:opacity-50",children:f?"Rechecking…":"Already logged in? Recheck"})]}),j]}):e.jsx(Jy,{provider:s,credsPresent:n,reason:r,expiresAt:a,sessionOngoing:d,onAuthenticated:u,onAuthorized:h})}const BR=Object.freeze(Object.defineProperty({__proto__:null,ProviderAuthGate:gx},Symbol.toStringTag,{value:"Module"})),YC=300,_l=150;function KC(t){const[s,n]=l.useState(null),r=l.useRef(!1),[a,o]=l.useState(!1),i=l.useCallback(()=>{var u;return((u=t.current)==null?void 0:u.clientWidth)??1200},[t]),c=s??Math.floor(i()/2),d=l.useCallback(u=>{u.preventDefault(),r.current=!0,o(!0)},[]);return l.useEffect(()=>{const u=p=>{var g;if(!r.current)return;const m=((g=t.current)==null?void 0:g.getBoundingClientRect().left)??0,f=p.clientX-m,b=i();f<_l?n(0):f>b-_l?n(b):n(Math.max(YC,f))},h=()=>{r.current&&(r.current=!1,o(!1))};return document.addEventListener("mousemove",u),document.addEventListener("mouseup",h),()=>{document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",h)}},[t,i]),{leftWidth:c,isDragging:a,handleMouseDown:d}}const JC=3e3;function XC({hot:t,isInIframe:s,reload:n=()=>window.location.reload(),sustainedDisconnectMs:r=JC}){return()=>{}}function QC(){l.useEffect(()=>XC({hot:void 0,isInIframe:It()}),[])}const ZC=5e3;function kl(t){return new Promise(s=>{let n=!1;const r=()=>{n||(n=!0,window.removeEventListener("miniagent-agent-idle",a),clearTimeout(o),s())},a=i=>{const c=i.detail;(c==null?void 0:c.chatName)==="plan"&&r()},o=setTimeout(r,t);window.addEventListener("miniagent-agent-idle",a)})}function e3(t){return Qy()?Promise.resolve():new Promise(s=>{let n=!1;const r=()=>{n||(n=!0,window.removeEventListener("miniagent-ws-open",r),clearTimeout(a),s())},a=setTimeout(r,t);window.addEventListener("miniagent-ws-open",r,{once:!0})})}async function t3(){await e3(ZC),Rs("\x1B"),await kl(ya),Rs("/clear\r"),await kl(ya),Rs("/codeyam-plan\r")}function s3(){fetch("/api/clear-build-agent-session",{method:"POST"}).catch(()=>{})}function n3(t){const s=l.useRef(null),n=l.useRef(null);l.useEffect(()=>{if(typeof document>"u")return;n.current||(n.current=document.createElement("canvas"),n.current.width=64,n.current.height=64);const r=document.querySelector('link[rel="icon"]');if(!r){K("favicon-redraw",{idle:t,hasIcon:!1});return}if(s.current||(s.current=r.href),!t){r.href=s.current,K("favicon-restore",{});return}K("favicon-redraw",{idle:!0,hasIcon:!0});const a=new Image;a.crossOrigin="anonymous",a.onload=()=>{const o=n.current,i=o.getContext("2d");i.clearRect(0,0,64,64);const c=56,d=(64-c)/2;i.drawImage(a,d,d,c,c);const u=12,h=64-u-1,p=u+1;i.beginPath(),i.arc(h,p,u,0,2*Math.PI),i.fillStyle="#ef4444",i.fill(),r.href=o.toDataURL("image/png")},a.src=s.current},[t]),l.useEffect(()=>()=>{if(typeof document>"u")return;const r=document.querySelector('link[rel="icon"]');r&&s.current&&(r.href=s.current)},[])}const r3=120*1e3,bx=1500;class a3{constructor(s,n,r=K){it(this,"deferred",!1);it(this,"userActiveSinceLastOutput",!1);it(this,"lastActivitySource",null);it(this,"lastActivityAt",null);it(this,"lastNotificationTime",null);it(this,"actions");it(this,"env");it(this,"now");it(this,"log");this.actions=s,this.env=n,this.now=n.now??(()=>Date.now()),this.log=r}reportUserActivity(s){this.userActiveSinceLastOutput=!0,this.lastActivitySource=s,this.lastActivityAt=this.now()}resetActivityFlag(){this.userActiveSinceLastOutput=!1}onIdle(s,n){this.deferred=!1;const r=this.env.hasBrowserFocus(),a=this.lastNotificationTime===null?null:this.now()-this.lastNotificationTime,o=this.lastActivityAt===null?null:this.now()-this.lastActivityAt,i={buildTabActive:n,hasBrowserFocus:r,msSinceLastNotification:a,userActiveSinceLastOutput:this.userActiveSinceLastOutput,lastActivitySource:this.lastActivitySource,msSinceLastActivity:o},c=o!==null&&o<bx;if(n&&r&&c)return this.userActiveSinceLastOutput=!1,this.log("suppressed-user-active",i),"suppressed";if(a!==null&&a<r3)return this.log("cooldown",i),"cooldown";const d=this.notify(s);return this.log(d==="played"?"notify-played":"notify-played-no-sound",i),d}onBuildTabChange(s,n){return!s&&this.deferred?(this.deferred=!1,this.notify(n),!0):!1}onActive(){const s=this.deferred;this.deferred=!1,this.log("on-active",{hadDeferred:s}),this.actions.closeSystemNotification(),this.log("system-notification-closed-on-active",{hadDeferred:s})}onUserEngagement(){const s=this.deferred;return this.deferred=!1,s}get isDeferred(){return this.deferred}notify(s){const n=!!(s!=null&&s.sound)&&s.sound!=="off";n?(this.actions.playSound(s.sound),this.log("sound-played",{soundId:s.sound})):this.log("sound-skipped-off",{});const r=this.env.hasBrowserFocus(),a=typeof Notification<"u"?Notification.permission:"unknown";return!r&&(s!=null&&s.systemNotification)?this.env.hasNotificationPermission()?(this.actions.showSystemNotification(),this.log("system-notification-shown",{notificationPermission:a})):this.log("system-notification-skipped-no-permission",{notificationPermission:a}):r&&this.log("system-notification-skipped-focus",{notificationPermission:a}),this.lastNotificationTime=this.now(),n?"played":"played-no-sound"}}function o3(t,s){return new a3({playSound:Yu,showSystemNotification:()=>{if(typeof Notification>"u"||Notification.permission!=="granted")return;s.current&&s.current.close();const n=t.current,r=new Notification(`${n} is ready for you`,{body:`${n} has finished and is waiting for your input.`,tag:"build-agent-idle"});r.onclick=()=>{window.focus(),r.close(),s.current=null},s.current=r},closeSystemNotification:()=>{typeof Notification>"u"||s.current&&(s.current.close(),s.current=null)}},{hasBrowserFocus:()=>document.hasFocus(),hasNotificationPermission:()=>typeof Notification<"u"&&Notification.permission==="granted"})}function i3(t,s){return t==="hook-stop"?s.idleOnStop:s.idleOnNotification}const l3=600*1e3,c3=3e3;function d3({agentName:t,isBuildTabActive:s,isAgentBuilding:n,buildSessionLive:r,featureCompleteKey:a,navigateToTab:o,onAgentIdleImmediate:i,onAgentActiveImmediate:c}){const d=l.useRef(t);d.current=t;const u=l.useRef(s);u.current=s;const h=l.useRef(i);h.current=i;const p=l.useRef(c);p.current=c;const[m,f]=l.useState(Uu),[b,g]=l.useState(!1),v=l.useRef(!1);v.current=b;const x=l.useRef(!1),y=l.useRef(null),w=l.useRef(null),j=l.useRef(null),k=l.useRef(typeof document<"u"&&document.hidden?Date.now():null),S=l.useRef(null),N=l.useRef(r??!1);N.current=r??!1,n3(b),j.current||(j.current=o3(d,w));const T=l.useCallback(P=>{f(P),Vu(P)},[]),A=l.useCallback(P=>{y.current!==null&&(clearTimeout(y.current),y.current=null,K("debounce-cancelled",{trigger:P}))},[]),_=l.useCallback(P=>{v.current&&K("idle-cleared",{trigger:P}),g(!1),v.current=!1,S.current=null,w.current&&(w.current.close(),w.current=null)},[]),M=l.useCallback(P=>{var $;if(!i3(P,m)){K("idle-suppressed-by-pref",{source:P});return}K("ws-idle-received",{buildTabActive:u.current,source:P}),($=h.current)==null||$.call(h),A("re-arm-on-idle"),y.current=setTimeout(()=>{var Z;y.current=null;const F=k.current,U=F===null?null:Date.now()-F,J=F!==null&&Date.now()-F>l3;K("debounce-resolved",{suppressedForOvernight:J,msHidden:U,buildTabActive:u.current}),J||(Z=j.current)==null||Z.onIdle(m,u.current),g(!0),v.current=!0,S.current=Date.now(),x.current=!1,K("agent-currently-idle-set",{suppressedForOvernight:J}),u.current&&lt()},bx)},[m,A]),I=l.useCallback(()=>{var P,$,F;(P=p.current)==null||P.call(p),A("agent-active"),($=j.current)==null||$.onActive(),(F=j.current)==null||F.resetActivityFlag(),v.current&&N.current&&S.current!==null&&Date.now()-S.current>c3&&_("remote-resume")},[A,_]),H=l.useCallback(()=>{var P,$;A("user-input"),v.current&&((P=j.current)==null||P.onUserEngagement(),($=j.current)==null||$.reportUserActivity("terminal-input"),x.current=!0,_("user-input"))},[A,_]),z=l.useCallback(P=>{var $;P==="build"&&(A("navigate-build"),v.current&&(($=j.current)==null||$.onUserEngagement(),x.current=!0,_("navigate-build"))),o(P)},[o,A,_]),G=l.useCallback(()=>{var P;A("dismiss-banner"),(P=j.current)==null||P.onUserEngagement(),x.current=!0,_("dismiss-banner")},[A,_]),R=l.useCallback(()=>{var P;A("stop-building"),(P=j.current)==null||P.onUserEngagement(),x.current=!0,_("stop-building")},[A,_]);l.useEffect(()=>{function P(){var V;v.current&&(x.current||(A("ack-notification"),(V=j.current)==null||V.onUserEngagement(),x.current=!0,K("notification-acknowledged",{trigger:"user-return"})))}function $(V){var le;v.current&&u.current&&document.hasFocus()&&(document.hidden||((le=j.current)==null||le.onUserEngagement(),x.current=!0,_(V)))}function F(V){var le;document.hasFocus()&&P(),(le=j.current)==null||le.reportUserActivity(V)}const U=()=>F("mousemove"),J=()=>F("mousedown"),Z=()=>F("keydown");function te(){document.hidden?k.current===null&&(k.current=Date.now()):(k.current=null,P(),$("tab-visible-on-build"))}function ie(){var V;P(),$("window-focus-on-build"),(V=j.current)==null||V.reportUserActivity("focus")}return window.addEventListener("focus",ie),document.addEventListener("visibilitychange",te),document.addEventListener("mousemove",U),document.addEventListener("mousedown",J),document.addEventListener("keydown",Z),()=>{A("unmount"),window.removeEventListener("focus",ie),document.removeEventListener("visibilitychange",te),document.removeEventListener("mousemove",U),document.removeEventListener("mousedown",J),document.removeEventListener("keydown",Z)}},[A,_]);const D=l.useRef(a??0);return l.useEffect(()=>{var F;const P=a??0;if(P===D.current)return;D.current=P;const $=u.current&&document.hasFocus();K("feature-complete-fast-path",{skipBecauseWatching:$}),!$&&((F=j.current)==null||F.onIdle(m,!1),g(!0),v.current=!0,S.current=Date.now(),x.current=!1)},[a,m]),l.useEffect(()=>{var P,$;if((P=j.current)==null||P.onBuildTabChange(s,m),s)return v.current&&typeof document<"u"&&document.hasFocus()&&!document.hidden&&(($=j.current)==null||$.onUserEngagement(),x.current=!0,_("build-tab-active-on-focus")),lt()},[s,m,_]),{buildIdle:b,bannerVisible:b,notifSettings:m,handleSettingsChange:T,handleAgentIdle:M,handleAgentActive:I,handleUserInput:H,handleNavigateToTab:z,dismissIdleBanner:G,clearIdleForStopBuilding:R}}const u3=1e4;function h3(t){const{isAgentBuilding:s,submittingBuildPrompt:n,launchingPlanSlug:r,sessionInfo:a,refetchSessionInfo:o}=t,[i,c]=l.useState(!1),d=l.useRef(!1),u=l.useCallback((h,p)=>{d.current!==h&&(K("build-session-live-change",{from:d.current,to:h,trigger:p}),d.current=h,c(h))},[]);return l.useEffect(()=>{s&&u(!0,"agent-active")},[s,u]),l.useEffect(()=>{n&&u(!0,"launch-prompt")},[n,u]),l.useEffect(()=>{r!==null&&u(!0,"launch-plan")},[r,u]),l.useEffect(()=>{((a==null?void 0:a.resumeMode)==="resume"||(a==null?void 0:a.resumeMode)==="handoff")&&u(!0,"resumable-session-detected")},[a,u]),l.useEffect(()=>{(a==null?void 0:a.agentBrokerLive)===!0&&u(!0,"broker-live-detected")},[a,u]),l.useEffect(()=>{a&&!a.hasSession&&!a.agentBrokerLive&&u(!1,"session-ended")},[a,u]),l.useEffect(()=>{if(!i)return;const h=setInterval(()=>{o()},u3);return()=>clearInterval(h)},[i,o]),{buildSessionLive:i,transitionBuildSessionLive:u}}function Sl(t){const{isAgentBuilding:s,trigger:n,transitionBuildSessionLive:r}=t;if(s){K("build-session-live-suppress-clear",{trigger:n,reason:"agent-still-active"});return}r(!1,n)}const p3=new Set(["ui-confirm-plan","backend-confirm-plan","present-live","backend-confirm","ui-present","backend-present"]);function m3(t,s){return t&&p3.has(t)?"needs-input":s?"waiting":"building"}function f3(){const[t,s]=l.useState({loading:!1,error:null,downloaded:!1}),n=l.useCallback(async a=>{s({loading:!0,error:null,downloaded:!1});try{const i=await(await fetch("/api/editor-transcript-package")).json();if(!i.success){s({loading:!1,error:i.error||"Failed to package transcript",downloaded:!1});return}let c=i.content;a!=null&&a.trim()&&(c=`## User Notes
185
+
186
+ ${a.trim()}
187
+
188
+ ${c}`);const d=new Blob([c],{type:"text/markdown"}),u=URL.createObjectURL(d),h=document.createElement("a");h.href=u,h.download=i.filename,document.body.appendChild(h),h.click(),document.body.removeChild(h),URL.revokeObjectURL(u),s({loading:!1,error:null,downloaded:!0})}catch(o){s({loading:!1,error:o instanceof Error?o.message:"Network error",downloaded:!1})}},[]),r=l.useCallback(()=>{s({loading:!1,error:null,downloaded:!1})},[]);return{...t,sendTranscript:n,reset:r}}function g3(t,s){var o;const n="feedback@codeyam.com",r=encodeURIComponent(`CodeYam Session Feedback: ${t||"Session"}`+(s!=null&&s.category?` [${s.category}]`:"")),a=encodeURIComponent([((o=s==null?void 0:s.note)==null?void 0:o.trim())||"(no note)","","(Please attach the downloaded transcript file.)"].join(`
189
+
190
+ `));return`mailto:${n}?subject=${r}&body=${a}`}const b3=["bug","suggestion","question","praise"];function xx({featureName:t,onClose:s}){const[n,r]=l.useState(""),[a,o]=l.useState(null),[i,c]=l.useState(!1),{loading:d,error:u,downloaded:h,sendTranscript:p}=f3(),m=l.useCallback(()=>{p(n)},[p,n]),f=l.useCallback(()=>{navigator.clipboard.writeText("feedback@codeyam.com").then(()=>{c(!0),setTimeout(()=>c(!1),2e3)})},[]),b=l.useCallback(g=>{o(v=>v===g?null:g)},[]);return e.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"Send Session Transcript"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:"Download your session transcript and send it to the CodeYam team for feedback or debugging."}),e.jsxs("div",{className:"mb-3",children:[e.jsx("span",{className:"block text-xs text-[var(--text-muted)] mb-1.5",children:"Tag (optional)"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:b3.map(g=>{const v=a===g;return e.jsx("button",{type:"button","aria-pressed":v,onClick:()=>b(g),className:"px-2.5 py-1 rounded-full text-xs transition cursor-pointer",style:{background:v?"var(--accent-active)":"transparent",color:v?"var(--bg-deep)":"var(--text-secondary)",border:"1px solid var(--border-default)"},children:g},g)})})]}),e.jsx("textarea",{value:n,onChange:g=>r(g.target.value),placeholder:"What's on your mind? (optional)",className:"w-full h-20 px-3 py-2 text-sm rounded-md mb-4 resize-none",style:{background:"var(--bg-input, var(--bg-deep))",color:"var(--text-primary)",border:"1px solid var(--border-default)"}}),u&&e.jsx("p",{className:"text-sm text-red-400 mb-3",children:u}),e.jsxs("div",{className:"flex flex-col gap-3",children:[h?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-green-400 text-center",children:"Transcript downloaded!"}),e.jsx("a",{href:g3(t,{note:n,category:a}),className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition text-center block",style:{background:"var(--accent-active)",color:"var(--bg-deep)"},children:"Open Email Client"}),e.jsx("button",{onClick:f,className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition",style:{background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)"},type:"button",children:i?"Copied!":"Copy Email Address"}),e.jsx("p",{className:"text-xs text-[var(--text-dim)] text-center",children:"Attach the downloaded file to your email"})]}):e.jsx("button",{onClick:m,disabled:d,className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition",style:{background:"var(--accent-active)",color:"var(--bg-deep)",opacity:d?.6:1},type:"button",children:d?"Packaging transcript...":"Download Transcript"}),e.jsx("button",{onClick:s,className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition",style:{background:"transparent",color:"var(--text-secondary)",border:h?"none":"1px solid var(--border-default)"},type:"button",children:h?"Done":"Cancel"})]})]})}const HR=Object.freeze(Object.defineProperty({__proto__:null,SendTranscriptModal:xx},Symbol.toStringTag,{value:"Module"}));function yx({sha:t,onClick:s}){if(!t)return null;const n=t.slice(0,6),r="font-mono text-[11px] leading-none px-1.5 py-0.5 rounded border border-white/5 bg-black/55 backdrop-blur-sm hover:bg-black/75";return e.jsx("div",{className:`fixed bottom-1 left-1 z-30 ${s?"":"pointer-events-none"}`,style:{paddingBottom:"env(safe-area-inset-bottom)"},children:s?e.jsx("button",{type:"button",onClick:s,"data-testid":"build-sha-badge",title:t,"aria-label":`Build commit ${t}`,className:`cursor-pointer ${r}`,style:{color:"var(--text-secondary)"},children:n}):e.jsx("span",{"data-testid":"build-sha-badge",title:t,"aria-label":`Build commit ${t}`,className:r,style:{color:"var(--text-secondary)"},children:n})})}const WR=Object.freeze(Object.defineProperty({__proto__:null,BuildShaBadge:yx},Symbol.toStringTag,{value:"Module"}));function x3(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/raw-terminal`}function vx(){if(It())return null;const t=l.useRef(null),s=l.useRef(null),n=l.useRef(null),r=l.useRef(null),a=l.useRef(!1),[o,i]=l.useState(!1),[c,d]=Gh(1200);function u(h){const p=r.current;(p==null?void 0:p.readyState)===WebSocket.OPEN&&p.send(new TextEncoder().encode(h))}return $h(t,()=>{if(n.current&&s.current){n.current.fit();const h=r.current;(h==null?void 0:h.readyState)===WebSocket.OPEN&&h.send(JSON.stringify({type:"resize",cols:s.current.cols,rows:s.current.rows}))}}),l.useEffect(()=>{if(!t.current||a.current)return;a.current=!0;const h=new Cl.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'IBM Plex Mono', monospace",rightClickSelectsWord:!1,theme:{background:"#1e1e1e",foreground:"#cccccc",cursor:"#D7FF63",selectionBackground:"#264f78"}}),p=new Tl.FitAddon;h.loadAddon(p),h.open(t.current),s.current=h,n.current=p;const m=Pl(h,t.current,{onCopy:()=>d()}),f=Ol(h,{sendInput:u});requestAnimationFrame(()=>{p.fit(),h.focus()});const b=new WebSocket(x3());return r.current=b,b.binaryType="arraybuffer",b.onmessage=g=>{g.data instanceof ArrayBuffer&&h.write(new Uint8Array(g.data))},b.onopen=()=>{b.send(JSON.stringify({type:"resize",cols:h.cols,rows:h.rows}))},b.onclose=()=>{i(!0),h.writeln(`\r
191
+ \x1B[90m[Shell session ended]\x1B[0m`)},h.onData(u),()=>{var g;(g=r.current)==null||g.close(),f(),m(),h.dispose(),a.current=!1}},[]),e.jsxs("div",{className:"relative flex-1 flex flex-col",style:{minHeight:0},children:[e.jsx("div",{ref:t,className:"flex-1",style:{background:"#1e1e1e",minHeight:0,paddingTop:3,paddingLeft:3},onClick:()=>{var h;return(h=s.current)==null?void 0:h.focus()}}),o&&e.jsx("div",{role:"alert",className:"absolute bottom-2 left-2 rounded px-2 py-1 text-[11px]",style:{background:"var(--bg-card)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)"},children:"Shell disconnected — close and reopen for a fresh shell."}),c&&e.jsx(yo,{})]})}const qR=Object.freeze(Object.defineProperty({__proto__:null,RawTerminalEmulator:vx},Symbol.toStringTag,{value:"Module"}));function jx({isOpen:t,onClose:s}){return l.useEffect(()=>{if(!t)return;const n=r=>{r.key==="Escape"&&s()};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[t,s]),t?e.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"raw-terminal-modal-title",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onMouseDown:n=>{n.target===n.currentTarget&&s()},children:e.jsxs("div",{className:"flex flex-col rounded-lg shadow-xl",style:{width:"80vw",height:"80vh",maxWidth:1200,maxHeight:800,background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-[var(--border-default)]",children:[e.jsx("h2",{id:"raw-terminal-modal-title",className:"text-sm font-semibold text-[var(--text-primary)] m-0",children:"Terminal"}),e.jsx("button",{type:"button",onClick:s,"data-testid":"raw-terminal-modal-close","aria-label":"Close terminal",className:"text-sm text-[var(--text-muted)] hover:text-[var(--text-primary)] cursor-pointer",children:"✕"})]}),e.jsx("div",{className:"flex-1 flex flex-col",style:{minHeight:0},children:e.jsx(vx,{})})]})}):null}const GR=Object.freeze(Object.defineProperty({__proto__:null,RawTerminalModal:jx},Symbol.toStringTag,{value:"Module"}));function y3(){const[t,s]=l.useState(!1),[n,r]=l.useState(null),[a,o]=l.useState(null),i=l.useRef(0);l.useEffect(()=>{if(a===null)return;const m=window.setTimeout(()=>o(null),Bh);return()=>window.clearTimeout(m)},[a]);const c=l.useRef(null),d=l.useCallback(()=>r(null),[]),u=l.useCallback(async m=>{if(m.length!==0){for(const f of m)if(f.size>En){o(`${f.name} is larger than the ${En/(1024*1024)} MB cap`);return}try{const f=await Promise.all(m.map(async x=>({filename:x.name||"unnamed",contentBase64:await Hh(x)}))),b=await fetch("/api/editor-upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:f})});if(!b.ok){const x=await b.json().then(y=>y.error).catch(()=>null);throw new Error(x??`Upload failed: ${b.status}`)}const v=(await b.json()).written??[];if(v.length===0)throw new Error("Upload returned no saved files");r(v)}catch(f){o(f instanceof Error?f.message:String(f))}}},[]),h=l.useCallback(()=>{var m;(m=c.current)==null||m.click()},[]),p=l.useCallback(m=>{const f=m.target,b=Array.from(f.files??[]).filter(g=>g.size>0);f.value="",u(b)},[u]);return l.useEffect(()=>{const m=x=>{var y,w;return!!((w=(y=x.dataTransfer)==null?void 0:y.types)!=null&&w.includes("Files"))},f=x=>{m(x)&&(x.preventDefault(),i.current+=1,s(!0))},b=x=>{m(x)&&x.preventDefault()},g=x=>{m(x)&&(i.current=Math.max(0,i.current-1),i.current===0&&s(!1))},v=x=>{var w;if(!m(x))return;if(x.defaultPrevented){i.current=0,s(!1);return}if(x.preventDefault(),i.current=0,s(!1),x.dataTransfer&&qh(x.dataTransfer)){o("Folder drops are not supported — drag individual files instead");return}const y=Array.from(((w=x.dataTransfer)==null?void 0:w.files)??[]).filter(j=>j.size>0);u(y)};return window.addEventListener("dragenter",f),window.addEventListener("dragover",b),window.addEventListener("dragleave",g),window.addEventListener("drop",v),()=>{window.removeEventListener("dragenter",f),window.removeEventListener("dragover",b),window.removeEventListener("dragleave",g),window.removeEventListener("drop",v)}},[u]),{dragActive:t,pendingPaths:n,error:a,clearPending:d,openPicker:h,fileInputRef:c,handlePickerChange:p}}function wx({visible:t}){return t?e.jsx("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)",pointerEvents:"none"},"data-testid":"global-file-drop-overlay","aria-hidden":"true",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 px-10 py-8 rounded-xl text-center",style:{border:"2px dashed var(--accent-active, #D7FF63)",background:"rgba(0, 0, 0, 0.30)"},children:[e.jsx("span",{className:"text-2xl font-semibold text-[var(--text-primary)]",children:"Drop files to add them to this session"}),e.jsx("span",{className:"text-sm text-[var(--text-muted)]",children:"Saved to .codeyam/uploads/ — then hand them to the agent"})]})}):null}const UR=Object.freeze(Object.defineProperty({__proto__:null,GlobalFileDropOverlay:wx},Symbol.toStringTag,{value:"Module"}));function _x({message:t}){return e.jsx("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-[80] px-4 py-2 rounded-md text-sm",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",color:"var(--text-danger, #ff6b6b)"},"data-testid":"global-file-drop-error",children:t})}const VR=Object.freeze(Object.defineProperty({__proto__:null,GlobalFileDropToast:_x},Symbol.toStringTag,{value:"Module"}));function kx({paths:t,onClose:s}){const{sendToAgent:n,agentReady:r}=Zy(),[a,o]=l.useState(!1),i=l.useCallback(h=>{h.key==="Escape"&&(h.preventDefault(),s())},[s]);l.useEffect(()=>(window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)),[i]);const c=t.map(Wh).join(" "),d=l.useCallback(()=>{n(c+" ")&&s()},[n,c,s]),u=l.useCallback(()=>{var h;(h=navigator.clipboard)==null||h.writeText(c).then(()=>{o(!0),window.setTimeout(()=>o(!1),1500)},()=>{})},[c]);return e.jsx("div",{className:"fixed inset-0 z-[75] flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},"data-testid":"file-drop-confirm-modal",children:e.jsxs("div",{className:"max-w-lg w-full mx-4 p-6 rounded-lg",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:t.length===1?"File added":`${t.length} files added`}),e.jsxs("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:["Saved to your project. Hand the path",t.length===1?"":"s"," to the agent so it can read"," ",t.length===1?"it":"them","."]}),e.jsx("ul",{className:"mb-4 max-h-48 overflow-y-auto rounded-md p-3 text-xs font-mono",style:{background:"var(--bg-deep, #0e0e0e)",border:"1px solid var(--border-subtle)",color:"var(--text-primary)"},"data-testid":"file-drop-confirm-paths",children:t.map(h=>e.jsx("li",{className:"truncate py-0.5",children:h},h))}),!r&&e.jsx("p",{className:"mb-3 text-xs",style:{color:"var(--text-dim)"},"data-testid":"file-drop-confirm-no-agent-hint",children:"Start or focus a session to hand the file to the agent."}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:u,className:"px-4 py-2 rounded-md text-sm font-medium transition cursor-pointer",style:{background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)"},"data-testid":"file-drop-confirm-copy",children:a?"Copied":"Copy path"}),e.jsx("button",{type:"button",onClick:s,className:"px-4 py-2 rounded-md text-sm font-medium transition cursor-pointer",style:{background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)"},"data-testid":"file-drop-confirm-done",children:"Done"}),e.jsx("button",{type:"button",onClick:d,disabled:!r,className:"px-4 py-2 rounded-md text-sm font-medium transition cursor-pointer disabled:cursor-not-allowed disabled:opacity-50",style:{background:"var(--accent-active, #D7FF63)",color:"var(--text-on-accent, #fff)",border:"1px solid transparent"},"data-testid":"file-drop-confirm-tell-agent",children:"Tell the agent"})]}),e.jsx("p",{className:"mt-3 text-center text-xs text-[var(--text-dim)]",children:"Escape closes · files stay in .codeyam/uploads/"})]})})}const YR=Object.freeze(Object.defineProperty({__proto__:null,FileDropConfirmModal:kx},Symbol.toStringTag,{value:"Module"}));let Vr=null;function v3(t){if(typeof t!="object"||t===null)return null;const s=t.buildCommitSha;return typeof s!="string"||s===""||s==="unknown"?null:s}async function j3(){try{const t=await fetch("/api/health");return t.ok?v3(await t.json()):null}catch{return null}}function w3(){const[t,s]=l.useState(null);return l.useEffect(()=>{let n=!0;return Vr||(Vr=j3()),Vr.then(r=>{n&&s(r)}),()=>{n=!1}},[]),{sha:t}}function _3(){var gi,bi,xi;QC();const{sha:t}=w3(),s=lv(),{state:n,provider:r,credsPresent:a,reason:o,expiresAt:i,probeInFlight:c,probeAttempts:d,backendFieldAbsent:u,refresh:h}=ev(),{sessionInfo:p,refetch:m}=Oo({pollIntervalMs:15e3}),f=(p==null?void 0:p.agentBrokerLive)??!1,b=LC(n,f),{activeTab:g,buildActivated:v,planActivated:x,navigateToTab:y,showBuildTab:w,deactivateBuild:j}=Lo(s,b,n==="needs-login"&&!f),[k,S]=l.useState(!1),N=l.useCallback(()=>{S(!0)},[]),{arm:T,navigateToTabUser:A}=GC(b,y,N),_=l.useCallback(()=>A("build"),[A]),[M,I]=l.useState(!1),[H,z]=l.useState(!1),G=It(),[R,D]=l.useState(G),P=l.useRef(!1),$=l.useCallback(()=>D(!0),[]),[F,U]=l.useState(G),[J,Z]=l.useState(0),[te,ie]=l.useState(0),[V,le]=l.useState(0),[me,Q]=l.useState(0),[C,E]=l.useState(null),{showPostPushModal:B,onFeatureCompleteCommand:se,onAgentIdle:q,onAgentActive:ce,dismissModal:W}=xC(),{showPlanCompleteModal:oe,onPlanCompleteCommand:fe,dismissPlanCompleteModal:xe}=vC(),[ne,je]=l.useState(!1),[et,wt]=l.useState(!1),[Ft,_t]=l.useState(!1),[xs,we]=l.useState(!1),[Ke,Ae]=l.useState(!1),[es,qe]=l.useState(!1),ts=l.useCallback(()=>{_t(!0)},[]),ys=l.useCallback(()=>{_t(!1)},[]),{plans:ss,loading:zt,error:pt,refetch:vs}=Sm(),{plans:tt}=Tm(),{reorderPlans:$t}=Em(vs),{launchPlan:Fe,launchingSlug:ze,error:_e}=Rm(),{launchPrompt:ke,launching:ge,error:Ge}=jC(),[pe,ve]=l.useState(null),{stepState:L,refetch:st}=Xs();yC({showPostPushModal:B,stepState:L,dismissModal:W});const ye=l.useRef(null),{leftWidth:$e,handleMouseDown:Re}=KC(ye),be=Dh(768),[Ue,Je]=l.useState("editor"),Ee=l.useCallback(Y=>{Je(Y),Y==="editor"&&(lt(),typeof window<"u"&&window.dispatchEvent(new Event("resize")))},[]),nt=be?((gi=ye.current)==null?void 0:gi.clientWidth)??(typeof window<"u"?window.innerWidth:$e):$e,{entityLookup:Bt}=Q2(),{groups:gr,loading:Yo,refreshing:Ko,currentRunner:Jo,coverage:Xo,refresh:Qo}=L2(),{groups:Xe,loading:Zs,reload:en}=R2(),{routeEntities:Zo,loading:Sx,error:Nx}=E2(),{config:X,apps:mt,loading:br,refetch:ns}=yt(),Cx=kf(),rs=l.useMemo(()=>kC(mt,gr,Xe),[mt,Xe,gr]),Tx=l.useCallback(()=>{I(Y=>!Y)},[]),Px=l.useCallback(()=>{z(Y=>!Y)},[]),{selectedApp:Ht,appRouteEntities:ei,appTestGroups:Ox,selectedEntityHash:Ax,selectedRouteEntity:ti,previewSlug:Wt,setPreviewSlugExplicit:Rx,selectApp:xr,deselectApp:yr,selectRoute:vr,selectEntity:Ex,deselectRoute:Mx}=K2(mt,Zo,Xe,gr,s,(X==null?void 0:X.defaultScreenSize)??null,F,P),{viewports:Ix,resolvedViewport:jr,previewUrl:Dx,handleViewportChange:Lx,handleCustomSizeChange:wr,showScenarioPreview:as,handlePreviewCommand:Ve,setPreviewPath:_r,previewSeeding:Fx,previewSeedError:zx,commandNonce:$x}=mC({apps:mt,appRouteEntities:ei,configLoaded:!br,hydrated:R,port:(X==null?void 0:X.port)??5173,previewMedium:Cx.kind,previewOrigin:yl(X,Ht),projectTitle:(X==null?void 0:X.projectTitle)??null,routeEntities:Zo,screenSizes:(X==null?void 0:X.screenSizes)??{},defaultScreenSize:(X==null?void 0:X.defaultScreenSize)??null,scenarioGroups:Xe,scenariosLoaded:!Zs,selectedApp:Ht,selectedRouteEntity:ti,previewSlug:Wt,setPreviewSlug:Rx}),{isAgentBuilding:qt,isAgentBuildingRef:kr,buildingScenarioSlug:Sr,onAgentIdle:si,onAgentActive:ni,guardScenarioSelect:ri,clearBuildingOverlay:ot}=wC({onTransitionToLive:as}),{planActive:Bx,planIdle:Hx}=_C({chatOpen:ne}),Nr=(p==null?void 0:p.resumeMode)==="resume"||(p==null?void 0:p.resumeMode)==="handoff",{buildSessionLive:js,transitionBuildSessionLive:Gt}=h3({isAgentBuilding:qt,submittingBuildPrompt:ge,launchingPlanSlug:ze,sessionInfo:p,refetchSessionInfo:m});l.useEffect(()=>{mr({hasActiveSession:Nr,isAgentBuilding:qt,stepStateFeature:(L==null?void 0:L.feature)??null})},[Nr,qt,L==null?void 0:L.feature]),l.useEffect(()=>{const Y=X==null?void 0:X.projectTitle;document.title=typeof Y=="string"&&Y.length>0?`CodeYam: ${Y}`:"CodeYam"},[X==null?void 0:X.projectTitle]);const Wx=l.useCallback(()=>{q(),si()},[q,si]),qx=l.useCallback(()=>{ce(),ni()},[ce,ni]),tn=(X==null?void 0:X.provider)??tv,Gx=At(tn),{buildIdle:sn,bannerVisible:Ux,notifSettings:ai,handleSettingsChange:oi,handleAgentIdle:Vx,handleAgentActive:Yx,handleUserInput:Kx,handleNavigateToTab:Jx,dismissIdleBanner:Xx,clearIdleForStopBuilding:nn}=d3({agentName:Gx,isBuildTabActive:g==="build",isAgentBuilding:qt,buildSessionLive:js,featureCompleteKey:V,navigateToTab:A,onAgentIdleImmediate:Wx,onAgentActiveImmediate:qx}),ii=l.useMemo(()=>m3(L==null?void 0:L.slug,sn),[L==null?void 0:L.slug,sn]),li=L?ew(L.step,L.mode):null,ci=l.useMemo(()=>NC(L==null?void 0:L.step,L==null?void 0:L.mode),[L==null?void 0:L.step,L==null?void 0:L.mode]),di=L?CC(L.step,L.mode):null,Qx=((bi=tt[0])==null?void 0:bi.title)??null,ui=l.useCallback(Y=>{ve(null),!ri(Y)&&as(Y)},[ri,as]),Zx=l.useCallback(Y=>{const Pe=FC(Y.name,Xe),Ut=WC({shot:{name:Y.name,screenshotPath:Y.screenshotPath},isLatest:Y.isLatest,liveScenario:Pe,isAgentBuilding:qt});if(Ut.kind==="live"){ve(null),as(Ut.slug);return}ve({screenshotPath:Ut.screenshotPath,scenarioName:Ut.scenarioName,heading:Ut.heading,subtext:Ut.subtext})},[qt,Xe,as]),ey=l.useCallback(()=>{ve(null)},[]),os=l.useMemo(()=>Ia(Sr,Xe),[Sr,Xe]),ty=((xi=os==null?void 0:os.screenshotPaths)==null?void 0:xi[0])??null,sy=(os==null?void 0:os.name)??null,ny=l.useCallback(Y=>{switch(Y.type){case"preview":("scenarioSlug"in Y||"scenarioId"in Y)&&en(),Ve(Y);break;case"showResults":ot(),en(),Z(Pe=>Pe+1),(L==null?void 0:L.mode)==="backend"&&Ve({path:"/results",dimension:"Desktop"});break;case"hideResults":ie(Pe=>Pe+1);break;case"featureComplete":ot(),se(),le(Pe=>Pe+1),ns(),st(),Sl({isAgentBuilding:kr.current,trigger:"feature-complete",transitionBuildSessionLive:Gt});break;case"planComplete":fe(),ns(),Sl({isAgentBuilding:kr.current,trigger:"plan-complete",transitionBuildSessionLive:Gt});break;case"launchPlan":Fe(Y.slug,Y.title),Q(Pe=>Pe+1);break;case"requestCredential":E({serviceName:Y.serviceName,envVar:Y.envVar,topic:Y.topic,docsUrl:Y.docsUrl});break}},[ot,Ve,kr,Fe,se,fe,ns,st,en,L,Gt]);X2(ny,l.useCallback(()=>{window.location.reload()},[]));const rn=(L==null?void 0:L.slug)==="ui-confirm-plan"||(L==null?void 0:L.slug)==="backend-confirm-plan",Cr=l.useRef(null);l.useEffect(()=>{if(!L||!rn){Cr.current=null;return}Cr.current!==L.step&&(Cr.current=L.step,Ve({path:"/plan-preview",dimension:"Desktop"}))},[L,rn,Ve]);const Tr=l.useRef(null);l.useEffect(()=>{if(!L||L.mode!=="backend"||L.step<2||rn){Tr.current=null;return}Tr.current!==L.step&&(Tr.current=L.step,Ve({path:"/results",dimension:"Desktop"}))},[L,rn,Ve]);const Pr=l.useRef(!1);l.useEffect(()=>{(L==null?void 0:L.slug)==="ui-confirm-plan"?Pr.current=!0:Pr.current&&(Pr.current=!1,_r(null))},[L,_r]);const ry=l.useCallback(async()=>{W(),await _k({provider:tn,renameLabel:(L==null?void 0:L.feature)??void 0,caller:"post-push-modal",bypassLiveGuard:!0}),lt()},[W,tn,L]),ay=l.useCallback(()=>{W(),lt()},[W]),oy=l.useCallback(async()=>{window.dispatchEvent(new CustomEvent("build-session-stopped")),await jk(),W(),y("home"),j(),Gt(!1,"stop-building"),ot(),nn(),m()},[W,y,j,Gt,ot,nn,m]),iy=l.useCallback(async()=>{qe(!0),window.dispatchEvent(new CustomEvent("build-session-stopped")),await wk(),qe(!1),Ae(!1),y("home"),j(),Gt(!1,"reset-everything"),ot(),nn(),m()},[y,j,Gt,ot,nn,m]),ly=l.useCallback(()=>{je(!0),t3(),xe(),lt()},[xe]),cy=l.useCallback(()=>{je(!1),s3(),xe()},[xe]),dy=l.useCallback(()=>{wt(!0)},[]),uy=l.useCallback(()=>{wt(!1)},[]),hy=l.useCallback(async(Y,Pe)=>{await Fe(Y,Pe)&&(wt(!1),S(!0),W(),m())},[Fe,W,m]),py=l.useCallback(async Y=>{await ke(Y)&&(S(!0),m())},[ke,m]),my=l.useCallback(()=>{S(!0)},[]),hi={hasActiveSession:Nr,isAgentBuilding:qt,showPostPushModal:B,launchingPlanSlug:ze,submittingBuildPrompt:ge,stepStateFeature:(L==null?void 0:L.feature)??null,buildLaunchModalDismissed:k},fy=fx(hi),pi=qC({activeTab:g,...hi}),gy=pi||et;l.useEffect(()=>{g==="build"&&m()},[g,m]),l.useEffect(()=>{g==="home"&&(ns(),h())},[g,ns,h]);const by=l.useCallback(async(Y,Pe)=>{ot(),Ve(DC(Y,Pe))},[ot,Ve]),xy=l.useCallback(Y=>{Ve({...Y.scenarioSlug?{scenarioSlug:Y.scenarioSlug}:{},...Y.path?{path:Y.path}:{},...Y.dimension?{dimension:Y.dimension}:{}})},[Ve]),{requestRestore:yy,onAdoptSettledEmpty:mi}=gC({restoredRef:P,initiallySettled:G,apply:xy}),vy=l.useCallback(Y=>{bC(Y,{handlePreviewCommand:Ve,handleCustomSizeChange:wr})},[wr,Ve]),jy=l.useCallback(()=>{mi(),U(!0)},[mi]);fC({isInIframe:G,scenariosLoaded:!Zs,restoredRef:P,onAdopt:vy,onHydrated:$,onSettledEmpty:jy});const wy=l.useMemo(()=>({apps:mt,isSingleApp:mt.length===1,onSelectApps:yr,onSelectApp:xr,onSelectRoute:vr}),[mt,yr,xr,vr]),_y=l.useMemo(()=>Ht?rs.find(Y=>Y.app.dir===Ht.dir)??null:null,[rs,Ht]),ky=e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{padding:"12px 28px 0"},children:e.jsx(Mo,{staleness:null,backendOutOfDate:u})}),e.jsx(gx,{state:n,provider:r,credsPresent:a,reason:o,expiresAt:i,probeInFlight:c,probeAttempts:d,backendOutOfDate:u,sessionOngoing:f,onAuthenticated:h,onAuthorized:_}),rs.length>0&&e.jsx("div",{style:{padding:"10px 28px 0"},children:e.jsx(Qu,{settings:ai,onChange:oi})}),e.jsx(vm,{selectedApp:Ht,projectTitle:(X==null?void 0:X.projectTitle)??null,admin:(X==null?void 0:X.admin)??!1,isBuilding:js,buildingLabel:(L==null?void 0:L.feature)??null,buildingStepLabel:li,buildingStepIndicator:di,buildingStatus:ii,buildingProgress:ci,lastBuiltLabel:Qx,plansCount:ss.length,onNavigateToPlan:()=>y("plan"),onNavigateToBuild:()=>A("build"),onBackToProjects:mt.length>1?yr:void 0,launcherUrl:(X==null?void 0:X.launcherUrl)??null,projectCount:(X==null?void 0:X.projectCount)??0,appDetailProps:{navContext:wy,routeEntities:ei,routesLoading:Sx,routesError:Nx,selectedEntityHash:Ax,selectedRouteEntity:ti,testGroups:Ox,selectedSlug:Wt,entityLookup:Bt,allScenarios:Xe.flatMap(Y=>Y.scenarios),onSelectScenario:ui,onSelectRoute:vr,onSelectEntity:Ex,onBackToRoutes:Mx,onScenariosChanged:en,coverage:Xo,showProjectBand:mt.length===1,stats:_y,testsLoading:Yo,testsRefreshing:Ko,onRunTests:Qo,currentRunner:Jo},appOverviewProps:{projectTitle:(X==null?void 0:X.projectTitle)??"Project",projectDescription:(X==null?void 0:X.projectDescription)??null,stats:rs,coverage:Xo,onSelectApp:xr,configLoading:br,scenariosLoading:Zs,testsLoading:Yo,testsRefreshing:Ko,onRunTests:Qo,currentRunner:Jo,stepState:L,onPreviewUrl:_r,onComplete:async()=>{await ns(),console.info("[EditorShell] questionnaire complete; arming pending build-nav",{providerAuthState:n,buildBlocked:b}),T()},onOpenBuildTab:()=>A("build"),isBuilding:js,buildingLabel:(L==null?void 0:L.feature)??null,buildingStepLabel:li,buildingStepIndicator:di,buildingStatus:ii,buildingProgress:ci,onResetBuild:()=>Ae(!0)}})]}),Sy=rs.some(Y=>IC(Y.app.type)),Ny=Xe.reduce((Y,Pe)=>Y+Pe.scenarios.length,0),fi=!!L&&!Zs&&Ny===0,Cy=sx(),ft=y3();return e.jsx(sv,{children:e.jsxs(nv,{openPicker:ft.openPicker,children:[e.jsx(km,{splitRef:ye,isCollapsed:M,onResizeStart:Re,isNarrow:be,mobilePane:Ue,onMobilePaneChange:Ee,isAgentBuilding:js,buildIdle:sn,leftPane:e.jsx(vf,{activeTab:g,onSendTranscript:ts,appTabContent:ky,awaitingPlanLaunchChoice:gy,buildActivated:v,planActivated:x,buildIdle:sn,isAgentBuilding:js,planActive:Bx,planIdle:Hx,bannerVisible:Ux,onDismissIdleBanner:Xx,hideResultsCommandKey:te,leftWidth:nt,fullWidth:be,navigateToTab:Jx,onAgentActive:Yx,onAgentIdle:Vx,onUserInput:Kx,notifSettings:ai,onSettingsChange:oi,provider:tn,onRestorePreview:yy,onResultsScenarioSelect:by,previewSlug:Wt,onSessionDetected:w,showPostPushModal:B,completionModalPermitted:mx(L),onStartNextFeature:ry,onContinueInSession:ay,onStopBuilding:oy,showResultsCommandKey:J,planChatOpen:ne,onPlanChatOpenChange:je,showPlanCompleteModal:oe,onCreateNewPlan:ly,onViewPlans:cy,pendingPlans:ss,onSelectPlan:dy,selectPlanOpen:et,onPickPlan:hy,onCancelSelectPlan:uy,launchingPlanSlug:ze,planLaunchError:_e,prototypeLaunchSignal:me,showBuildLaunchModal:pi,buildLaunchGateArmed:fy,onSubmitBuildPrompt:py,submittingBuildPrompt:ge,buildPromptError:Ge,onStartBlankBuild:my,pendingPlansLoading:zt,pendingPlansError:pt,onReorderPlans:$t,buildDisabled:b,onPreviewScreenshot:Zx,projectTitle:(X==null?void 0:X.projectTitle)??null}),previewPane:e.jsx(rx,{emptyStateMessage:EC({configLoading:br,hasNoApps:rs.length===0,hasStepState:!!L,hasPreviewableApp:Sy,setupInProgress:fi,hasCaptureFrame:Cy.available}),projectSetupInProgress:fi,previewSlug:Wt,previewUrl:Dx,viewports:Ix,activeViewport:jr.name,onViewportChange:Lx,isCollapsed:M,onToggleCollapsed:Tx,isNarrow:be,isFilled:H,onToggleFilled:Px,currentWidth:jr.width,currentHeight:jr.height,onCustomSizeChange:wr,buildingScenarioSlug:Sr,buildingScreenshotPath:ty,buildingScenarioName:sy,onDismissBuildingOverlay:ot,historicalScreenshotPath:(pe==null?void 0:pe.screenshotPath)??null,historicalScenarioName:(pe==null?void 0:pe.scenarioName)??null,historicalHeading:(pe==null?void 0:pe.heading)??null,historicalSubtext:(pe==null?void 0:pe.subtext)??null,onDismissHistoricalPreview:ey,previewSeeding:Fx,previewSeedError:zx,onRetrySeed:()=>{Wt&&as(Wt)},currentScenario:Ia(Wt,Xe),scenarioGroups:Xe,onShowScenarioPreview:ui,commandNonce:$x,previewOrigin:yl(X,Ht),onDesignConfirmed:()=>A("build")})}),Ft?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},children:e.jsx(xx,{featureName:(L==null?void 0:L.feature)??null,onClose:ys})}):null,e.jsx(jx,{isOpen:xs,onClose:()=>we(!1)}),e.jsx(yx,{sha:t,onClick:()=>we(!0)}),e.jsx(wx,{visible:ft.dragActive}),e.jsx("input",{ref:ft.fileInputRef,type:"file",multiple:!0,onChange:ft.handlePickerChange,style:{display:"none"},"data-testid":"global-file-picker-input"}),ft.error?e.jsx(_x,{message:ft.error}):null,ft.pendingPaths?e.jsx(kx,{paths:ft.pendingPaths,onClose:ft.clearPending}):null,Ke?e.jsx(ax,{busy:es,onCancel:()=>Ae(!1),onConfirm:()=>void iy()}):null,C?e.jsx(Eo,{target:C,onStored:()=>E(null),onClose:()=>E(null)}):null]})})}const KR=Object.freeze(Object.defineProperty({__proto__:null,EditorShell:_3},Symbol.toStringTag,{value:"Module"}));export{xm as $,Cs as A,Up as B,Ya as C,Ts as D,O as E,kx as F,of as G,bb as H,Cm as I,Na as J,mg as K,sa as L,$a as M,Ga as N,eg as O,rx as P,Rp as Q,tb as R,Ka as S,Va as T,Wp as U,Zf as V,Qf as W,Xf as X,Kf as Y,Wo as Z,sg as _,Yn as a,wg as a$,Vp as a0,_a as a1,ka as a2,us as a3,Yp as a4,gb as a5,Ng as a6,zf as a7,go as a8,Et as a9,yg as aA,Qc as aB,gh as aC,Qn as aD,Dc as aE,tg as aF,qs as aG,Ce as aH,gg as aI,Xc as aJ,du as aK,gu as aL,fu as aM,pu as aN,hu as aO,uu as aP,io as aQ,Gs as aR,td as aS,Ic as aT,ks as aU,Qg as aV,Ie as aW,Yt as aX,Ws as aY,bg as aZ,Zc as a_,qp as aa,Yf as ab,Vf as ac,ba as ad,Lt as ae,Gp as af,oo as ag,De as ah,Za as ai,Qa as aj,Rt as ak,nd as al,cb as am,Xn as an,lg as ao,ig as ap,Vn as aq,yo as ar,Le as as,or as at,Vs as au,Sd as av,Un as aw,Ze as ax,ee as ay,Rg as az,cu as b,rm as b$,jg as b0,Te as b1,jt as b2,Pt as b3,Dt as b4,Ja as b5,sd as b6,ed as b7,Xg as b8,Me as b9,nb as bA,ab as bB,ob as bC,ib as bD,rb as bE,lb as bF,sb as bG,fb as bH,ub as bI,db as bJ,pb as bK,mb as bL,hb as bM,gm as bN,ih as bO,rh as bP,nh as bQ,th as bR,eh as bS,Zu as bT,sh as bU,Il as bV,El as bW,Al as bX,Jr as bY,Rl as bZ,um as b_,Ab as ba,Ob as bb,Mb as bc,Rb as bd,Pb as be,Ib as bf,eb as bg,Tb as bh,Kb as bi,Yb as bj,Zp as bk,Bl as bl,Hl as bm,$l as bn,Fl as bo,zl as bp,Ro as bq,mo as br,bm as bs,ql as bt,gc as bu,Zr as bv,hc as bw,fc as bx,yx as by,Bn as bz,z4 as c,Qm as c$,am as c0,om as c1,dm as c2,im as c3,lm as c4,hm as c5,fm as c6,cm as c7,pm as c8,mm as c9,Ff as cA,Hg as cB,Lg as cC,$g as cD,Gg as cE,zh as cF,Fh as cG,Vh as cH,Uh as cI,vx as cJ,jx as cK,Yh as cL,gf as cM,ff as cN,yf as cO,bf as cP,xf as cQ,_x as cR,wx as cS,mf as cT,lr as cU,nf as cV,rf as cW,af as cX,Ap as cY,Zm as cZ,tf as c_,Qs as ca,Cf as cb,If as cc,Mf as cd,Tf as ce,Pf as cf,Af as cg,Rf as ch,ja as ci,Ef as cj,Sf as ck,Nf as cl,Df as cm,Kp as cn,zp as co,Hp as cp,Fg as cq,Uo as cr,zg as cs,Bg as ct,Dg as cu,Ig as cv,Mg as cw,Pa as cx,qg as cy,Wg as cz,vn as d,uc as d$,Xm as d0,ef as d1,sf as d2,Km as d3,Jm as d4,pr as d5,Lm as d6,Dm as d7,Im as d8,Op as d9,Og as dA,xn as dB,Ll as dC,Vl as dD,Gl as dE,Yl as dF,_3 as dG,Ta as dH,Pg as dI,Ml as dJ,rc as dK,yc as dL,vc as dM,xc as dN,df as dO,Dp as dP,Lp as dQ,Wl as dR,Wa as dS,mc as dT,bc as dU,qa as dV,dc as dW,lc as dX,ic as dY,oc as dZ,cc as d_,Cp as da,wp as db,Np as dc,jp as dd,Tp as de,kp as df,_p as dg,Sp as dh,vp as di,Po as dj,To as dk,Fo as dl,Bm as dm,Wm as dn,xa as dp,zm as dq,Gm as dr,Ym as ds,Fm as dt,Vm as du,Um as dv,Mm as dw,lf as dx,hf as dy,Ag as dz,Mc as e,da as e$,ec as e0,nc as e1,sc as e2,Zl as e3,tc as e4,Jl as e5,Kl as e6,Ba as e7,ta as e8,Cc as e9,Ub as eA,Vg as eB,Ug as eC,Kg as eD,Lf as eE,Zg as eF,Jg as eG,Lb as eH,Ip as eI,wm as eJ,ls as eK,jh as eL,vh as eM,bo as eN,Sg as eO,_g as eP,pg as eQ,vg as eR,xg as eS,fg as eT,cg as eU,rg as eV,ug as eW,qo as eX,hg as eY,qf as eZ,yh as e_,Tc as ea,_c as eb,Ac as ec,Nc as ed,wc as ee,Xr as ef,bn as eg,jc as eh,xt as ei,wh as ej,Cg as ek,Hn as el,tx as em,Xb as en,Jb as eo,Db as ep,qb as eq,Gb as er,$b as es,zb as et,Bb as eu,Fb as ev,Hb as ew,ax as ex,kg as ey,Vb as ez,Ec as f,xu as f$,xh as f0,bh as f1,fh as f2,kh as f3,_h as f4,uf as f5,Lu as f6,Du as f7,Iu as f8,Mu as f9,kd as fA,_d as fB,wd as fC,yd as fD,bd as fE,au as fF,ru as fG,nu as fH,su as fI,tu as fJ,Qd as fK,Xd as fL,ld as fM,oa as fN,ou as fO,aa as fP,Tu as fQ,Cu as fR,Nu as fS,Su as fT,ku as fU,_u as fV,ia as fW,wu as fX,vu as fY,yu as fZ,Us as f_,Eu as fa,Ru as fb,Au as fc,Ou as fd,Pu as fe,Jd as ff,Kd as fg,Yd as fh,Vd as fi,Ud as fj,Gd as fk,qd as fl,Wd as fm,Hd as fn,Bd as fo,$d as fp,zd as fq,Fd as fr,Dd as fs,Id as ft,Md as fu,Ed as fv,Rd as fw,Od as fx,Pd as fy,Ad as fz,Rr as g,Dl as g$,bu as g0,lu as g1,Fc as g2,Lc as g3,qc as g4,Gc as g5,Uc as g6,ca as g7,qu as g8,Qu as g9,tm as gA,Qp as gB,$n as gC,kb as gD,Nb as gE,wb as gF,jb as gG,vb as gH,Cb as gI,_b as gJ,yb as gK,Sb as gL,xb as gM,Oa as gN,Gn as gO,Ul as gP,Ha as gQ,Kh as gR,Ih as gS,Ep as gT,Eh as gU,Ch as gV,Xp as gW,Nh as gX,Fp as gY,Sh as gZ,Rc as g_,uo as ga,Ku as gb,zu as gc,la as gd,$u as ge,Bu as gf,Hu as gg,ir as gh,Wu as gi,lo as gj,Mp as gk,_m as gl,pf as gm,cf as gn,vf as go,km as gp,jm as gq,vm as gr,Ah as gs,jn as gt,Rh as gu,Oh as gv,Ph as gw,Th as gx,em as gy,sm as gz,ac as h,IP as h$,Wc as h0,Eo as h1,gx as h2,ph as h3,hh as h4,mh as h5,uh as h6,dh as h7,ch as h8,er as h9,Oe as hA,Yc as hB,pd as hC,Pn as hD,so as hE,ra as hF,gd as hG,md as hH,hd as hI,fd as hJ,Cn as hK,nx as hL,m5 as hM,n5 as hN,e5 as hO,c5 as hP,OA as hQ,D5 as hR,F3 as hS,TT as hT,h4 as hU,$4 as hV,p4 as hW,T4 as hX,P4 as hY,C4 as hZ,E3 as h_,ro as ha,Ss as hb,ad as hc,od as hd,vd as he,jd as hf,xd as hg,no as hh,ar as hi,rr as hj,nr as hk,ud as hl,sr as hm,dd as hn,to as ho,ct as hp,tr as hq,na as hr,Xa as hs,Kt as ht,Es as hu,Jn as hv,Kn as hw,Vc as hx,Kc as hy,Jc as hz,Ua as i,X3 as i$,EP as i0,RP as i1,MP as i2,v5 as i3,$T as i4,h6 as i5,B5 as i6,wT as i7,CT as i8,NT as i9,r5 as iA,M5 as iB,b5 as iC,G4 as iD,rO as iE,aO as iF,FO as iG,HR as iH,G5 as iI,j6 as iJ,RR as iK,AR as iL,J5 as iM,H4 as iN,V3 as iO,G3 as iP,U3 as iQ,Y3 as iR,J3 as iS,K3 as iT,oP as iU,nO as iV,R3 as iW,mT as iX,J4 as iY,E6 as iZ,Q3 as i_,fT as ia,eO as ib,tO as ic,PA as id,CA as ie,TA as ig,UO as ih,uA as ii,tT as ij,sT as ik,KP as il,X6 as im,vT as io,FR as ip,MR as iq,DR as ir,S5 as is,_5 as it,k5 as iu,z5 as iv,rT as iw,p5 as ix,h5 as iy,a5 as iz,xx as j,tR as j$,k4 as j0,S4 as j1,v4 as j2,w4 as j3,_4 as j4,N4 as j5,g4 as j6,f4 as j7,m4 as j8,n4 as j9,dP as jA,hP as jB,bP as jC,gP as jD,fP as jE,mP as jF,pP as jG,uP as jH,PT as jI,N5 as jJ,I5 as jK,BR as jL,KO as jM,GO as jN,qO as jO,ZP as jP,CR as jQ,TR as jR,PR as jS,OR as jT,NR as jU,SR as jV,kR as jW,wR as jX,_R as jY,DA as jZ,$A as j_,x4 as ja,b4 as jb,y4 as jc,l4 as jd,u4 as je,d4 as jf,i4 as jg,c4 as jh,zA as ji,$R as jj,C6 as jk,F5 as jl,yA as jm,A5 as jn,c6 as jo,x5 as jp,i5 as jq,d5 as jr,o5 as js,l5 as jt,U5 as ju,GR as jv,qR as jw,JP as jx,lP as jy,xP as jz,Ye as k,yP as k$,zR as k0,LA as k1,WA as k2,HA as k3,GA as k4,UA as k5,qA as k6,BA as k7,IA as k8,jR as k9,b6 as kA,LO as kB,YO as kC,XO as kD,m6 as kE,bT as kF,R5 as kG,nP as kH,sP as kI,y5 as kJ,MO as kK,SA as kL,NA as kM,_A as kN,jA as kO,wA as kP,vA as kQ,kA as kR,wO as kS,xA as kT,cR as kU,KT as kV,yT as kW,UT as kX,GT as kY,qT as kZ,LR as k_,nT as ka,y6 as kb,v6 as kc,zO as kd,d6 as ke,WO as kf,BO as kg,HO as kh,VP as ki,$O as kj,GP as kk,$P as kl,qP as km,zP as kn,UP as ko,HP as kp,BP as kq,WP as kr,FP as ks,YP as kt,MA as ku,EA as kv,RA as kw,JO as kx,LP as ky,x6 as kz,Qb as l,uT as l$,AA as l0,j4 as l1,mA as l2,S6 as l3,Q6 as l4,dA as l5,aA as l6,cA as l7,lA as l8,iA as l9,Q4 as lA,Z4 as lB,w5 as lC,p6 as lD,K4 as lE,o4 as lF,a4 as lG,L5 as lH,gR as lI,fR as lJ,xR as lK,bR as lL,mR as lM,yR as lN,pR as lO,e6 as lP,ZO as lQ,AT as lR,FA as lS,WT as lT,hO as lU,s5 as lV,oT as lW,pT as lX,dT as lY,iT as lZ,hT as l_,A3 as la,oA as lb,tA as lc,sA as ld,eA as le,K6 as lf,Y6 as lg,U6 as lh,B6 as li,G6 as lj,W6 as lk,H6 as ll,V6 as lm,Z6 as ln,J6 as lo,nA as lp,rA as lq,F6 as lr,AP as ls,kT as lt,IO as lu,oO as lv,jT as lw,eT as lx,vR as ly,X4 as lz,Wb as m,Y5 as m$,cT as m0,lT as m1,W4 as m2,AO as m3,eP as m4,BT as m5,LT as m6,DT as m7,FT as m8,zT as m9,DO as mA,RO as mB,EO as mC,KR as mD,NP as mE,CP as mF,SP as mG,kP as mH,_P as mI,TP as mJ,pO as mK,OO as mL,gA as mM,cO as mN,IR as mO,eR as mP,ZA as mQ,ST as mR,Y4 as mS,mO as mT,hA as mU,pA as mV,L6 as mW,iP as mX,tP as mY,cP as mZ,QO as m_,VR as ma,UR as mb,P5 as mc,q6 as md,VO as me,bA as mf,MT as mg,YR as mh,QP as mi,t5 as mj,xT as mk,_T as ml,gT as mm,PO as mn,H5 as mo,uO as mp,q3 as mq,W3 as mr,s4 as ms,Z3 as mt,r4 as mu,t4 as mv,g5 as mw,f6 as mx,u6 as my,w6 as mz,Td as n,sO as n$,iR as n0,hR as n1,HT as n2,nR as n3,lR as n4,rR as n5,dR as n6,uR as n7,oR as n8,aR as n9,U4 as nA,V4 as nB,l6 as nC,i6 as nD,o6 as nE,a6 as nF,n6 as nG,r6 as nH,s6 as nI,t6 as nJ,IT as nK,E5 as nL,$6 as nM,z6 as nN,B4 as nO,fA as nP,$5 as nQ,V5 as nR,sR as nS,ZT as nT,DP as nU,OP as nV,XP as nW,PP as nX,wP as nY,iO as nZ,jP as n_,K5 as na,T5 as nb,lO as nc,C5 as nd,D6 as ne,OT as nf,KA as ng,YA as nh,XA as ni,QA as nj,CO as nk,NO as nl,kO as nm,SO as nn,_O as no,TO as np,vO as nq,jO as nr,xO as ns,bO as nt,yO as nu,gO as nv,A4 as nw,Q5 as nx,JA as ny,aT as nz,Cd as o,dO as o0,WR as o1,ER as o2,g6 as o3,e4 as o4,P6 as o5,O6 as o6,R6 as o7,A6 as o8,N6 as o9,B3 as oA,O4 as oB,F4 as oC,z3 as oD,L3 as oE,I3 as oF,$3 as oG,M4 as oH,W5 as oI,X5 as oJ,O5 as oK,j5 as oL,q4 as oM,VA as oN,f5 as oO,u5 as oP,Xv as oQ,Qv as oR,Zn as oS,T6 as oa,Z5 as ob,I6 as oc,M6 as od,k6 as oe,_6 as of,q5 as og,aP as oh,rP as oi,D3 as oj,M3 as ok,E4 as ol,D4 as om,L4 as on,I4 as oo,fO as op,ET as oq,RT as or,QT as os,XT as ot,YT as ou,VT as ov,JT as ow,vP as ox,R4 as oy,H3 as oz,Ql as p,Nd as q,at as r,iu as s,Tt as t,gt as u,ae as v,he as w,de as x,Ot as y,Mo as z};