@codeyam-editor/codeyam-editor 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/npm/agent-cli-install.js +102 -0
- package/npm/cloud.js +50 -53
- package/npm/editor.js +23 -0
- package/npm/fleet-add-failure.js +53 -2
- package/npm/fleet-auth.js +17 -1
- package/npm/launch-config.js +20 -3
- package/npm/launcher-boot-log.js +57 -0
- package/npm/operator-host-disk.js +44 -0
- package/npm/scenario-check.js +172 -1
- package/npm/scenario-metrics.js +101 -0
- package/npm/scenario-playwright.js +77 -5
- package/npm/utils.js +140 -21
- package/package.json +5 -5
- package/ui/dist/assets/{ContainerInspector-9w8TlRwl.js → ContainerInspector-Ceop11Fv.js} +1 -1
- package/ui/dist/assets/EditorShell-DjI5cEF_.js +366 -0
- package/ui/dist/assets/ScenarioDataPanel-D-nWT7xD.js +21 -0
- package/ui/dist/assets/{ScenarioDataPanelFullPage-DkysGs6X.js → ScenarioDataPanelFullPage-ZNFZcTQU.js} +1 -1
- package/ui/dist/assets/ScenarioRenderer-BW6QLGFW.js +26 -0
- package/ui/dist/assets/index-B3SMxYUB.css +1 -0
- package/ui/dist/assets/{index-CqKB9WVm.js → index-ClrdYzlw.js} +6 -6
- package/ui/dist/index.html +2 -2
- package/ui/dist/assets/EditorShell-CmEoMxKh.js +0 -366
- package/ui/dist/assets/ScenarioDataPanel-BM7COEfv.js +0 -21
- package/ui/dist/assets/ScenarioRenderer-M3HRiuEn.js +0 -26
- package/ui/dist/assets/index-Bk0fHYF3.css +0 -1
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
var tR=Object.defineProperty;var nR=(e,n,s)=>n in e?tR(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s;var on=(e,n,s)=>nR(e,typeof n!="symbol"?n+"":n,s);import{j as t}from"./markdown-C9tbsVHX.js";import{b as l,c as as,R as At}from"./react-nrLBr15I.js";import{r as sR,i as $c,n as zc,a as en,b as co,C as rR,c as vi,d as ji,s as aR}from"./useEvents-DNb1olaj.js";import{bC as dg,y as ug,bD as Bc,x as Lt,bE as oR,bF as iR,bG as lR,bH as cR,au as qt,bI as Qe,bJ as dR,bK as pg,bL as uR,bM as pR,bN as uo,S as hR,bO as St,bP as hg,bQ as el,bR as fR,bS as mR,bT as gR,bU as xR,bV as bR,bW as yR,bX as Wc,at as fg,bY as vR,bZ as po,b_ as Sn,b$ as jR,c0 as wR,c1 as br,c2 as _R,c3 as yr,c4 as mg,c5 as gg,c6 as Hc,c7 as Ma,c8 as SR,c9 as kR,ca as xn,cb as NR,u as CR,cc as TR,cd as qc,ce as Uc,cf as Yc,cg as Gc,ch as Vc,ci as gh,cj as PR,ck as OR,cl as RR,cm as ER,cn as AR,co as xh,aq as MR,ap as IR,ao as DR,cp as LR,cq as FR,cr as $R,cs as vr,ct as ia,cu as jr,cv as zR,b as BR,cw as xg,cx as wr,cy as WR,cz as HR,cA as bh,cB as bg,cC as Kc,cD as yh,cE as qR,cF as UR,f as tl,cG as YR,cH as GR,cI as VR,cJ as KR,cK as JR,e as Jc,cL as XR,cM as QR,k as ZR,cN as vh,cO as eE,cP as tE,cQ as nE,cR as sE,cS as jh,cT as rE,av as aE,cU as oE,cV as wh,cW as iE,cX as lE,A as cE,F as dE}from"./ScenarioDataPanel-D-nWT7xD.js";import{a as uE,e as pE,b as hE,c as Xc,i as yg,l as pe,g as Qc,d as fE,f as mE,r as gE,p as cn,t as xE,u as bE,P as os,w as yE,h as vE,s as _h,j as jE,k as wE}from"./index-ClrdYzlw.js";import{C as tt,a as ct,u as ho,c as fo,d as _E}from"./useServerIdentity-CVuHTzjg.js";import{C as cs}from"./CyLogo-BIbFVvgW.js";import{M as Ft}from"./Markdown-BaLq9qkt.js";function Ns({href:e,onNavigate:n,children:s,...r}){return t.jsx("a",{...r,href:e,onClick:a=>{a.button===0&&!a.metaKey&&!a.ctrlKey&&!a.shiftKey&&!a.altKey&&(a.preventDefault(),n())},children:s})}const lG=Object.freeze(Object.defineProperty({__proto__:null,NavLink:Ns},Symbol.toStringTag,{value:"Module"}));function SE(e,n){const s=typeof(e==null?void 0:e.reason)=="string"&&e.reason?e.reason:`Sharing could not start (${n}).`,r=typeof(e==null?void 0:e.nextAction)=="string"?e.nextAction:"";return r?`${s} What to do: ${r}`:s}let nl=null;const sl=new Set;function wi(e){nl=e;for(const n of sl)n(e)}async function kE(){const e=await fetch("/api/support-share");if(!e.ok)throw new Error(`support-share request failed (${e.status})`);return await e.json()}function NE(e){return e!=null&&e.active?5e3:3e4}function vg(){const[e,n]=l.useState(nl),[s,r]=l.useState(!1),[a,o]=l.useState(null),i=l.useCallback(async()=>{try{wi(await kE())}catch{}},[]);l.useEffect(()=>(sl.add(n),nl||i(),()=>{sl.delete(n)}),[i]);const c=(e==null?void 0:e.active)??!1;l.useEffect(()=>{const p=window.setInterval(()=>void i(),NE(e));return()=>window.clearInterval(p)},[c,i]);const d=l.useCallback(async p=>{r(!0),o(null);try{const h=await fetch("/api/support-share/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({durationSecs:p})}),f=await h.json();if(!h.ok){o(SE(f,h.status));return}wi(f)}catch(h){o(h instanceof Error?h.message:String(h))}finally{r(!1)}},[]),u=l.useCallback(async()=>{r(!0),o(null);try{const p=await fetch("/api/support-share/stop",{method:"POST"}),h=await p.json();if(!p.ok){o((h==null?void 0:h.error)??`Sharing could not stop (${p.status}).`);return}wi(h)}catch(p){o(p instanceof Error?p.message:String(p))}finally{r(!1)}},[]);return{status:e,busy:s,error:a,start:d,stop:u}}function jg({href:e,onNavigate:n}){const{status:s}=vg();return s!=null&&s.active?t.jsxs(Ns,{href:e,"data-nav-tab":"true","data-testid":"nav-support-sharing-pill",onNavigate:n,className:"mr-1 inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-[11.5px] font-medium whitespace-nowrap cursor-pointer @max-[520px]:hidden",style:{background:"color-mix(in srgb, var(--accent-green) 18%, transparent)",color:"var(--accent-green)",border:"1px solid color-mix(in srgb, var(--accent-green) 45%, transparent)"},title:"CodeYam support can open this editor. Open Settings to stop sharing.",children:[t.jsx("span",{"aria-hidden":"true",className:"inline-block h-1.5 w-1.5 rounded-full",style:{background:"var(--accent-green)"}}),"Sharing with support"]}):null}const cG=Object.freeze(Object.defineProperty({__proto__:null,SupportSharingPill:jg},Symbol.toStringTag,{value:"Module"}));function Rs({children:e}){return t.jsx("p",{className:"text-[12.5px] leading-relaxed mt-1",style:{color:"var(--text-muted)"},children:e})}const dG=Object.freeze(Object.defineProperty({__proto__:null,SettingsNote:Rs},Symbol.toStringTag,{value:"Module"}));function CE(e){if(!Number.isFinite(e)||e<60)return"less than a minute";const n=Math.floor(e/3600),s=Math.floor(e%3600/60);return n>0?`${n}h ${s}m`:`${s}m`}function wg(e){return new Date(e*1e3).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}function _g({event:e}){if(!e||e.event!=="stopped"&&e.event!=="expired")return null;const n=e.event==="expired"?"when its time ran out":"when you stopped it";return t.jsxs("p",{className:"mt-4 text-[12px]",style:{color:"var(--text-dim)"},children:["Sharing ended at ",wg(e.atUnix),", ",n,"."]})}const uG=Object.freeze(Object.defineProperty({__proto__:null,SupportShareLastEvent:_g},Symbol.toStringTag,{value:"Module"})),mo="bg-white/[0.035] border border-white/[0.06]",Mr=`flex items-center gap-0.5 rounded-[10px] ${mo} p-[3px] shrink-0`,TE=`inline-flex items-center rounded-[9px] ${mo} p-[3px] shrink-0`;function $s(e,n="text"){return`${n==="icon"?"flex h-7 w-9 items-center justify-center rounded-[7px]":n==="compact"?"px-3 py-1 text-[12.5px] rounded-md":"flex items-center gap-1.5 px-3 py-1 text-[13px] font-medium rounded-[7px]"} cursor-pointer transition ${e?"bg-white/[0.11] text-[var(--text-primary)]":"text-[var(--text-muted)] hover:text-[var(--text-primary)]"}`}function go({options:e,value:n,onChange:s,disabled:r=!1,ariaLabel:a}){return t.jsx("div",{className:`${Mr} self-start`,role:a?"radiogroup":void 0,"aria-label":a,children:e.map(o=>{const i=o.value===n;return t.jsx("button",{type:"button",role:a?"radio":void 0,"aria-checked":a?i:void 0,title:o.hint,disabled:r,onClick:()=>s(o.value),className:$s(i),children:o.label},o.value)})})}const pG=Object.freeze(Object.defineProperty({__proto__:null,SegmentedPicker:go},Symbol.toStringTag,{value:"Module"})),PE={3600:"1 hour",14400:"4 hours",86400:"24 hours"},OE=[3600,14400,86400];function Sg({status:e,busy:n,duration:s,onDurationChange:r,onStart:a}){const i=(e.durationsSecs.length?e.durationsSecs:OE).map(c=>({value:String(c),label:PE[c]??`${c/3600} hours`}));return t.jsxs(t.Fragment,{children:[t.jsx(Rs,{children:"CodeYam support will be able to see and use this editor until you stop sharing or the time runs out. Use it when you want us to look at a problem with you."}),e.privateError&&t.jsxs("p",{className:"mt-3 text-[12.5px] leading-relaxed",role:"alert",style:{color:"var(--accent-orange)"},children:["Sharing has stopped, but GitHub did not confirm the codespace is private again (",e.privateError,"). Open the Ports tab in your codespace and set the editor’s row back to Private."]}),t.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-3",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-[11.5px] mb-1.5",style:{color:"var(--text-muted)"},children:"Share for"}),t.jsx(go,{options:i,value:s,onChange:r,disabled:n,ariaLabel:"Share for"})]}),t.jsx("button",{type:"button",className:"self-end rounded-md px-3.5 py-1.5 text-[13px] font-medium transition-opacity disabled:opacity-50 cursor-pointer disabled:cursor-default",style:{background:"var(--accent-active, #D7FF63)",color:"var(--text-on-accent, #000)"},disabled:n,onClick:a,children:n?"Starting…":"Share with support"})]}),t.jsx(_g,{event:e.lastEvent})]})}const hG=Object.freeze(Object.defineProperty({__proto__:null,SupportShareIdle:Sg},Symbol.toStringTag,{value:"Module"}));function kg({status:e,busy:n,onStop:s}){return t.jsxs(t.Fragment,{children:[t.jsx(Rs,{children:"One more step. The editor couldn’t open your codespace to support by itself, so GitHub needs you to do it once:"}),t.jsxs("ol",{className:"mt-3 list-decimal pl-5 space-y-1.5 text-[12.5px] leading-relaxed",style:{color:"var(--text-secondary)"},children:[t.jsxs("li",{children:["In your codespace window, open the ",t.jsx("strong",{children:"Ports"})," tab next to the Terminal tab."]}),t.jsxs("li",{children:["Right-click the row whose ",t.jsx("strong",{children:"Port"})," column says"," ",t.jsx("strong",{children:e.port}),"."]}),t.jsxs("li",{children:["Choose ",t.jsx("strong",{children:"Port Visibility"})," → ",t.jsx("strong",{children:"Public"}),", then confirm GitHub’s warning."]})]}),t.jsxs("div",{className:"mt-3 flex items-center gap-2 text-[12.5px]",style:{color:"var(--text-muted)"},children:[t.jsx("span",{"aria-hidden":"true",className:"inline-block h-3 w-3 rounded-full border-2 animate-spin",style:{borderColor:"var(--text-muted)",borderTopColor:"transparent"}}),"Waiting for GitHub to confirm… The link appears here once it does."]}),e.autoError&&t.jsxs("details",{className:"mt-3 text-[12px]",style:{color:"var(--text-dim)"},children:[t.jsx("summary",{className:"cursor-pointer",children:"Why the editor couldn’t do this itself"}),t.jsx("p",{className:"mt-1 font-mono break-words",children:e.autoError})]}),t.jsx("div",{className:"mt-4",children:t.jsx("button",{type:"button",className:"rounded-md px-3 py-1.5 text-[13px] transition-colors disabled:opacity-50 cursor-pointer disabled:cursor-default",style:{border:"1px solid var(--border-default)",color:"var(--text-primary)"},disabled:n,onClick:s,children:n?"Cancelling…":"Cancel sharing"})})]})}const fG=Object.freeze(Object.defineProperty({__proto__:null,SupportShareGuided:kg},Symbol.toStringTag,{value:"Module"}));function RE(e){const[n,s]=l.useState(()=>Math.floor(Date.now()/1e3));return l.useEffect(()=>{const r=window.setInterval(()=>s(Math.floor(Date.now()/1e3)),1e3);return()=>window.clearInterval(r)},[e]),n}const Sh="rounded-md px-3 py-1.5 text-[13px] transition-colors disabled:opacity-50 cursor-pointer disabled:cursor-default";function Ng({status:e,busy:n,onStop:s}){const r=RE(!0),[a,o]=l.useState(!1),i=e.expiresAtUnix??r,c=async()=>{if(e.shareUrl)try{await navigator.clipboard.writeText(e.shareUrl),o(!0),window.setTimeout(()=>o(!1),2e3)}catch{o(!1)}};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-2 rounded-full",style:{background:"var(--accent-green)"}}),t.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:"You’re sharing with CodeYam support"})]}),t.jsxs(Rs,{children:["Sharing ends in ",CE(i-r)," (at ",wg(i),"). Send this link to CodeYam support:"]}),t.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[t.jsx("input",{readOnly:!0,value:e.shareUrl??"","aria-label":"Share link",className:"min-w-0 flex-1 rounded-md px-2.5 py-1.5 text-[12px] font-mono",style:{background:"var(--bg-input)",border:"1px solid var(--border-default)",color:"var(--text-secondary)"},onFocus:d=>d.currentTarget.select()}),t.jsx("button",{type:"button",className:Sh,style:{border:"1px solid var(--border-default)",color:"var(--text-primary)"},onClick:()=>void c(),disabled:!e.shareUrl,children:a?"Copied":"Copy link"})]}),t.jsx("div",{className:"mt-4",children:t.jsx("button",{type:"button",className:Sh,style:{border:"1px solid var(--accent-red, #ef4444)",color:"var(--accent-red, #ef4444)"},disabled:n,onClick:s,children:n?"Stopping…":"Stop sharing"})})]})}const mG=Object.freeze(Object.defineProperty({__proto__:null,SupportShareActive:Ng},Symbol.toStringTag,{value:"Module"}));function Cg({status:e,busy:n,duration:s,onDurationChange:r,onStart:a,onStop:o}){return e?e.available?e.active&&e.waitingForPublic?t.jsx(kg,{status:e,busy:n,onStop:o}):e.active?t.jsx(Ng,{status:e,busy:n,onStop:o}):t.jsx(Sg,{status:e,busy:n,duration:s,onDurationChange:r,onStart:a}):t.jsx(Rs,{children:"Sharing with CodeYam support is available when this editor runs in GitHub Codespaces. Open your project in a codespace to use it."}):t.jsx(Rs,{children:"Checking whether sharing is available…"})}const gG=Object.freeze(Object.defineProperty({__proto__:null,SupportShareState:Cg},Symbol.toStringTag,{value:"Module"}));function Tg(){const{status:e,busy:n,error:s,start:r,stop:a}=vg(),[o,i]=l.useState("14400");return t.jsxs("section",{className:"mt-6 rounded-xl px-5 py-5",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},"data-testid":"support-sharing-section",children:[t.jsx("h3",{className:"text-[14px] font-medium",style:{color:"var(--text-primary)"},children:"Share with CodeYam support"}),t.jsx(Cg,{status:e,busy:n,duration:o,onDurationChange:i,onStart:()=>void r(Number(o)),onStop:()=>void a()}),s&&t.jsx("p",{className:"mt-3 text-[12.5px] leading-relaxed",role:"alert",style:{color:"var(--accent-red, #ef4444)"},children:s})]})}const xG=Object.freeze(Object.defineProperty({__proto__:null,SupportSharingSection:Tg},Symbol.toStringTag,{value:"Module"}));function Zc({message:e,style:n}){return e?t.jsx("div",{role:"alert",style:{fontSize:12.5,color:"var(--accent-danger, #f87171)",...n},children:e}):null}const bG=Object.freeze(Object.defineProperty({__proto__:null,AttachErrorNotice:Zc},Symbol.toStringTag,{value:"Module"}));function xo({onPickFiles:e,onPickFolder:n,children:s,ariaLabel:r,fileInputLabel:a,title:o,className:i,style:c,disabled:d=!1,testId:u,fileInputTestId:p,folderInputTestId:h,placement:f="below"}){const[m,g]=l.useState(!1),x=l.useRef(null),b=l.useRef(null),y=l.useRef(null);return t.jsxs("span",{style:{position:"relative",display:"inline-flex",flex:"none"},children:[t.jsx("button",{ref:x,type:"button","aria-label":r,"aria-haspopup":"menu","aria-expanded":m,title:o,disabled:d,onClick:()=>g(v=>!v),"data-testid":u,className:i,style:c,children:s}),t.jsx("input",{ref:b,type:"file",multiple:!0,hidden:!0,"aria-label":a,"data-testid":p,onChange:v=>{e(v.target.files),v.target.value=""}}),t.jsx("input",{ref:y,type:"file",...dg,hidden:!0,"data-testid":h,onChange:v=>{n(v.target.files),v.target.value=""}}),m&&t.jsx(ug,{onChooseFiles:()=>{var v;return(v=b.current)==null?void 0:v.click()},onChooseFolder:()=>{var v;return(v=y.current)==null?void 0:v.click()},onClose:()=>g(!1),triggerRef:x,placement:f})]})}const yG=Object.freeze(Object.defineProperty({__proto__:null,AttachMenuButton:xo},Symbol.toStringTag,{value:"Module"}));function Pg({onCheck:e}){const{phase:n,attempts:s,retry:r}=Bc(e);return t.jsx("div",{"data-testid":"provider-auth-server-unreachable",className:"m-4",children:t.jsx(Lt,{severity:"error",testId:"provider-auth-server-unreachable-notice",headline:"Lost contact with the editor",explanation:"This page can't reach the editor right now. The editor may have been closed, or the connection may just be slow. Nothing you were working on is lost.",nextAction:"If the editor was closed, start it again — this page reconnects by itself once the editor answers, so you don't need to keep clicking. Check now only checks early.",actions:[{label:"Check now",onClick:r,pending:n==="pending",pendingLabel:"Checking…",testId:"provider-auth-server-unreachable-check"}],actionFeedback:n==="unchanged"?t.jsxs("span",{"data-testid":"provider-auth-server-unreachable-unchanged",children:["Checked just now — the editor still isn’t answering",s>1?` (${s} tries)`:"","."]}):null})})}const vG=Object.freeze(Object.defineProperty({__proto__:null,ProviderAuthServerUnreachableNotice:Pg},Symbol.toStringTag,{value:"Module"}));function rl({state:e}){return t.jsx("p",{className:"mt-3 text-sm text-[var(--text-dim)]","data-testid":`suggested-plans-${e}`,children:e==="loading"?"Loading…":"No suggestions waiting"})}const jG=Object.freeze(Object.defineProperty({__proto__:null,SuggestedPlansStatusLine:rl},Symbol.toStringTag,{value:"Module"})),kh="px-2 py-1 rounded border border-[var(--border-subtle)] disabled:opacity-40 hover:text-[var(--text-primary)]";function Og({start:e,end:n,total:s,canPrev:r,canNext:a,onPrev:o,onNext:i}){return t.jsxs("div",{className:"mt-3 flex items-center gap-3 text-xs text-[var(--text-muted)]","data-testid":"suggested-plans-pager",children:[t.jsx("button",{type:"button",className:kh,disabled:!r,onClick:o,children:"Prev"}),t.jsxs("span",{"data-testid":"suggested-plans-range",children:[e+1,"–",n," of ",s]}),t.jsx("button",{type:"button",className:kh,disabled:!a,onClick:i,children:"Next"})]})}const wG=Object.freeze(Object.defineProperty({__proto__:null,SuggestedPlansPager:Og},Symbol.toStringTag,{value:"Module"})),EE=5e3,Nh=50;function AE(){const[e,n]=l.useState([]),[s,r]=l.useState(0),[a,o]=l.useState(null),[i,c]=l.useState(!0),[d,u]=l.useState(!1),[p,h]=l.useState(null),f=l.useRef("idle"),m=l.useRef([]),g=l.useRef(null);l.useEffect(()=>{m.current=e},[e]),l.useEffect(()=>{g.current=a},[a]);const x=l.useCallback(async()=>{if(f.current==="idle"){f.current="initial",c(!0),h(null);try{const v=await fetch(`/api/history?limit=${Nh}`);if(!v.ok)throw new Error(`HTTP ${v.status}`);const j=await v.json();n(j.entries??[]),r(j.total??0),o(j.nextCursor??null),j.error&&h(j.error)}catch(v){h(v instanceof Error?v.message:"Failed to load history")}finally{c(!1),f.current="idle"}}},[]),b=l.useCallback(async()=>{var j;if(f.current!=="idle")return;const v=(j=m.current[0])==null?void 0:j.commit.sha;if(!v){await x();return}f.current="poll";try{const _=await fetch(`/api/history?since=${encodeURIComponent(v)}`);if(!_.ok)throw new Error(`HTTP ${_.status}`);const w=await _.json(),k=new Set(m.current.map(N=>N.commit.sha)),S=(w.entries??[]).filter(N=>!k.has(N.commit.sha));S.length>0&&(n(N=>[...S,...N]),r(N=>N+S.length))}catch(_){h(_ instanceof Error?_.message:"Failed to poll history")}finally{f.current="idle"}},[x]),y=l.useCallback(async()=>{if(f.current!=="idle")return;const v=g.current;if(v){f.current="more",u(!0);try{const j=await fetch(`/api/history?limit=${Nh}&before=${encodeURIComponent(v)}`);if(!j.ok)throw new Error(`HTTP ${j.status}`);const _=await j.json();n(w=>[...w,..._.entries??[]]),o(_.nextCursor??null),typeof _.total=="number"&&r(_.total)}catch(j){h(j instanceof Error?j.message:"Failed to load more commits")}finally{u(!1),f.current="idle"}}},[]);return l.useEffect(()=>{x();const v=setInterval(()=>{b()},EE);return()=>clearInterval(v)},[x,b]),{rows:e,total:s,hasMore:a!==null,loading:i,loadingMore:d,error:p,loadMore:y,reload:x}}function Tn(){const[e,n]=l.useState({}),s=l.useRef({});return l.useEffect(()=>oR(r=>{if(!r.ok)return;const a=r.data,o=typeof a.scenariosVersion=="number"?a.scenariosVersion:void 0,i=typeof a.plansVersion=="number"?a.plansVersion:void 0,c=typeof a.manualTestsVersion=="number"?a.manualTestsVersion:void 0,d=typeof a.testsVersion=="number"?a.testsVersion:void 0,u=typeof a.claimsVersion=="number"?a.claimsVersion:void 0,p=typeof a.sourceVersion=="number"?a.sourceVersion:void 0,h=typeof a.liveReloadEnabled=="boolean"?a.liveReloadEnabled:void 0;(o!==s.current.scenariosVersion||i!==s.current.plansVersion||c!==s.current.manualTestsVersion||d!==s.current.testsVersion||u!==s.current.claimsVersion||p!==s.current.sourceVersion||h!==s.current.liveReloadEnabled)&&(s.current={scenariosVersion:o,plansVersion:i,manualTestsVersion:c,testsVersion:d,claimsVersion:u,sourceVersion:p,liveReloadEnabled:h},n(s.current))}),[]),e}function Ir(){const[e,n]=l.useState([]),[s,r]=l.useState(!0),[a,o]=l.useState(null),{plansVersion:i}=Tn(),c=l.useRef(!1),d=l.useCallback(async()=>{c.current||r(!0),o(null);try{const u=await fetch("/api/plans");if(!u.ok)throw new Error(`HTTP ${u.status}`);const p=await u.json();n(Array.isArray(p)?p.map(h=>({...h,dependsOn:Array.isArray(h.dependsOn)?h.dependsOn:[]})):[]),c.current=!0}catch(u){o(u instanceof Error?u.message:"Failed to load plans")}finally{r(!1)}},[]);return l.useEffect(()=>{d()},[d,i]),{plans:e,loading:s,error:a,refetch:d}}function ed(e=10){const[n,s]=l.useState([]),[r,a]=l.useState(!0),[o,i]=l.useState(null),c=l.useRef(!1),d=l.useCallback(async()=>{c.current||a(!0),i(null);try{const u=await fetch(`/api/plans/completed?limit=${e}`);if(!u.ok)throw new Error(`HTTP ${u.status}`);const p=await u.json();s(Array.isArray(p)?p:[]),c.current=!0}catch(u){i(u instanceof Error?u.message:"Failed to load completed plans")}finally{a(!1)}},[e]);return l.useEffect(()=>{d()},[d]),{plans:n,loading:r,error:o,refetch:d}}function td(){const[e,n]=l.useState(()=>new Set),[s,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:[];n(new Set(u.filter(p=>typeof p=="string")))}catch(c){o(c instanceof Error?c.message:"Failed to load completed plan slugs")}finally{r(!1)}},[]);return l.useEffect(()=>{i()},[i]),{slugs:e,loading:s,error:a,refetch:i}}function Rg(e){const n=new Map;return e.forEach((s,r)=>{var o;const a=((o=s.entry)==null?void 0:o.scenarioScreenshots)??[];for(const i of a)n.has(i.name)||n.set(i.name,r)}),n}const ME="unknown";function xa(e){const n=e.getFullYear(),s=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${n}-${s}-${r}`}function IE(e,n){const s=xa(n),r=new Date(n.getFullYear(),n.getMonth(),n.getDate()-1),a=xa(e);if(a===s)return"Today";if(a===xa(r))return"Yesterday";const i=`${e.toLocaleDateString("en-US",{month:"short"})} ${e.getDate()}`;return e.getFullYear()===n.getFullYear()?i:`${i}, ${e.getFullYear()}`}function DE(e,n,s=new Date){const r=new Map;return e.forEach((a,o)=>{const i=new Date(n(a)),c=!isNaN(i.getTime()),d=c?xa(i):ME;let u=r.get(d);u||(u={key:d,label:c?IE(i,s):"Unknown date",items:[]},r.set(d,u)),u.items.push({row:a,index:o})}),[...r.values()]}const LE=/\s*\[(skip ci|ci skip)\]/gi,Ch=/^plan\s*:\s*/i,Th=/^ignore proposed plan\s+/i,FE=/^chore(\([^)]*\))?\s*:/i,$E=/^write \d+ proposed plans?$/i,zE=/^(triage|reorder|prune|clean( up)?|remove|delete|rename|renumber|sync|tidy)\b.*\b(plans?|queue)\b/i;function Eg(e){return e.replace(LE,"").trim()}function BE(e){const n=Eg(e);if(Ch.test(n)){const s=n.replace(Ch,"").trim();return Th.test(s)?{kind:"plan-ignored",title:s.replace(Th,"").trim()}:$E.test(s)||zE.test(s)?{kind:"maintenance",title:n}:{kind:"plan-added",title:s}}return FE.test(n)&&/codeyam/i.test(n)?{kind:"maintenance",title:n}:{kind:"change",title:n}}function WE(e){return e.toLowerCase()==="chore"?"Maintenance":e}function ks(e){return{fields:Object.fromEntries(e.fields.map(n=>[n.key,n.value])),body:e.body}}function HE(e,n){return!e||!n?!1:JSON.stringify(ks(e))!==JSON.stringify(n)}function nd(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function qE(e){return e&&(e.split(/[\\/]/).pop()??"").replace(/\.[^.]+$/,"")||null}function Ph(e,n){const s=n.trim().toLowerCase();if(!s)return!1;if(e.title.trim().toLowerCase()===s)return!0;const r=nd(n);return r!==""&&(e.slug===r||qE(e.filePath)===r)}function UE({title:e,setAside:n,pending:s,completed:r,completedSlugs:a,builtTitles:o}){const i=s.find(h=>Ph(h,e)),c=r.find(h=>Ph(h,e)),d=i??c??null,u=a.has(nd(e))||o.has(e.trim().toLowerCase());let p=null;return n?p="set-aside":i?p="queued":(c||u)&&(p="built"),{status:p,slug:(d==null?void 0:d.slug)??null,body:(d==null?void 0:d.body)??null}}function sd(e){const n=new Date(e);if(isNaN(n.getTime()))return e;const s=new Date,r=s.getTime()-n.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`:n.toLocaleDateString("en-US",{month:"short",day:"numeric",year:n.getFullYear()!==s.getFullYear()?"numeric":void 0})}function Ag(e){switch(e){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 _G(e){let n=0,s=0,r=0;for(const a of e)a.status==="added"?n++:a.status==="deleted"?r++:s++;return{added:n,modified:s,deleted:r}}function Mg({commit:e}){const n=Eg(e.subject),s=[n,e.authorName].filter(Boolean).join(" · ");return t.jsxs("div",{"data-testid":"history-commit-row",title:s,className:"flex items-center gap-2.5 px-3.5 py-1.5 text-[13px]",children:[t.jsx("span",{"aria-hidden":!0,className:"h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--text-dim)]"}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--text-secondary)]",children:n}),t.jsx("span",{className:"shrink-0 font-mono text-xs text-[var(--text-dim)]",children:e.shortSha}),t.jsx("span",{className:"shrink-0 text-xs text-[var(--text-dim)] tabular-nums",children:sd(e.timestamp)})]})}const SG=Object.freeze(Object.defineProperty({__proto__:null,CommitOnlyHistoryRow:Mg},Symbol.toStringTag,{value:"Module"})),YE=[/\.test\.[jt]sx?$/,/\.spec\.[jt]sx?$/,/__tests__\//,/tests?\//];function rd(e){return e.filter(n=>YE.some(s=>s.test(n.path)))}function GE(e){return e.replace(/```[\s\S]*?```/g," ").replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/`([^`]*)`/g,"$1").replace(/^\s{0,3}(#{1,6}|>|[-*+]|\d+\.)\s+/gm,"").replace(/(\*\*|__)(.*?)\1/g,"$2").replace(/(^|\s)[*_]([^*_\s][^*_]*?)[*_](?=\s|$|[.,!?:;])/g,"$1$2").replace(/\s+/g," ").trim()}const VE=192;function bo({children:e,variant:n="compact",maxHeight:s=VE,moreLabel:r="Show more",lessLabel:a="Show less",fadeColor:o="var(--bg-card)"}){const i=l.useRef(null),[c,d]=l.useState(!1),[u,p]=l.useState(!1);return l.useEffect(()=>{const h=i.current;if(!h)return;const f=()=>p(h.scrollHeight>s);f();const m=new ResizeObserver(f);return m.observe(h),()=>m.disconnect()},[e,s]),t.jsxs("div",{children:[t.jsxs("div",{ref:i,style:{maxHeight:c?"none":`${s}px`,overflow:"hidden",position:"relative"},children:[t.jsx(Ft,{variant:n,children:e}),!c&&u&&t.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"2rem",background:`linear-gradient(transparent, ${o})`,pointerEvents:"none"}})]}),u&&t.jsx("button",{onClick:()=>d(h=>!h),className:"text-xs cursor-pointer mt-1",style:{color:"var(--accent-blue)",background:"none",border:"none",padding:0},children:c?a:r})]})}const kG=Object.freeze(Object.defineProperty({__proto__:null,CollapsibleMarkdown:bo},Symbol.toStringTag,{value:"Module"}));function yo({total:e,passed:n,failed:s,noun:r}){if(e===0)return null;const a=s>0?"text-[var(--accent-red)]":"text-[var(--accent-green)]";return t.jsxs("span",{className:`text-xs ${a}`,children:[n,"/",e," ",r?`${r} `:"","passed"]})}const NG=Object.freeze(Object.defineProperty({__proto__:null,TestResultsBadge:yo},Symbol.toStringTag,{value:"Module"}));function vo({status:e}){const n=e==="added"?"var(--accent-green)":e==="deleted"?"var(--accent-red)":"var(--text-muted)",s=e==="added"?"+":e==="deleted"?"-":"~";return t.jsx("span",{className:"font-mono text-xs font-semibold",style:{color:n,minWidth:"0.75rem",textAlign:"center"},children:s})}const CG=Object.freeze(Object.defineProperty({__proto__:null,FileStatusIndicator:vo},Symbol.toStringTag,{value:"Module"}));function ds(e,n){if(e.startsWith("http"))return e;const s=`/api/screenshots/${e}`;return typeof n=="number"?`${s}?cb=${n}`:s}function kt({screenshotPath:e,cacheBuster:n,alt:s,className:r="",title:a,loading:o="eager"}){const[i,c]=l.useState("loading"),[d,u]=l.useState(!1),p=l.useRef(null),h=e?ds(e,n):"",f=()=>{c("success"),u(!0)},m=()=>{c("error"),u(!1)};return l.useEffect(()=>{c("loading"),u(!1);const g=p.current;g!=null&&g.complete&&(g.naturalHeight!==0?(c("success"),u(!0)):(c("error"),u(!1)))},[h]),e?t.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",title:a,children:[t.jsx("img",{ref:p,src:h,alt:s,loading:o,decoding:"async",onLoad:f,onError:m,className:r||"max-w-full max-h-full object-contain",style:{opacity:d?1:0,position:d?"relative":"absolute"}}),i==="loading"&&t.jsx("div",{className:"absolute inset-0 bg-[var(--bg-card)] animate-pulse rounded flex items-center justify-center",children:t.jsx("svg",{className:"w-8 h-8 text-[var(--text-dim)]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.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"})})}),i==="error"&&t.jsxs("div",{className:"absolute inset-0 border border-[var(--border-subtle)] bg-[var(--bg-card)] rounded flex flex-col items-center justify-center text-xs gap-1",children:[t.jsx("span",{className:"text-2xl opacity-40 grayscale",children:"📷"}),t.jsx("span",{className:"text-[var(--text-dim)] whitespace-nowrap",children:"No Screenshot"})]})]}):t.jsx("div",{className:"w-full h-full border border-[var(--border-subtle)] bg-[var(--bg-card)] rounded flex flex-col items-center justify-center text-xs gap-1",title:a,children:t.jsx("span",{className:"text-2xl opacity-40 grayscale",children:"📷"})})}const TG=Object.freeze(Object.defineProperty({__proto__:null,SafeScreenshot:kt},Symbol.toStringTag,{value:"Module"})),Ig=4,Dg="flex items-center justify-center overflow-hidden rounded-md border border-white/10 bg-[var(--bg-surface)]";function Lg({shot:e,onSelect:n}){const s=t.jsx("div",{className:`${Dg} h-16 w-24`,children:t.jsx(kt,{screenshotPath:e.screenshotPath,cacheBuster:e.screenshotCapturedAtMs??void 0,alt:""})});return!n||!e.screenshotPath?t.jsx("div",{className:"shrink-0","data-testid":"history-lead-thumbnail",children:s}):t.jsx("button",{type:"button",tabIndex:-1,"aria-hidden":!0,"data-testid":"history-lead-thumbnail",onClick:()=>n(e),className:"block shrink-0 cursor-pointer rounded-md transition hover:ring-2 hover:ring-[var(--accent-primary)]",children:s})}function Fg({screenshots:e,onSelect:n}){if(e.length===0)return null;const s=e.slice(0,Ig),r=e.length-s.length;return t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[s.map((a,o)=>{const i=t.jsx("div",{className:`${Dg} h-[42px] w-16`,children:t.jsx(kt,{screenshotPath:a.screenshotPath,cacheBuster:a.screenshotCapturedAtMs??void 0,alt:a.name})}),c=`${a.screenshotPath??"missing"}:${a.name}:${o}`;return n&&a.screenshotPath?t.jsx("button",{type:"button",onClick:()=>n(a),"aria-label":`Preview ${a.name}`,title:a.name,className:"block shrink-0 cursor-pointer rounded-md transition hover:ring-2 hover:ring-[var(--accent-primary)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--accent-primary)]",children:i},c):t.jsx("div",{title:a.name,className:"shrink-0",children:i},c)}),r>0&&t.jsxs("span",{className:"ml-1 shrink-0 text-xs text-[var(--text-dim)]",children:["+",r," ",r===1?"screen":"screens"]})]})}const PG=Object.freeze(Object.defineProperty({__proto__:null,HistoryLeadThumbnail:Lg,HistoryScreensStrip:Fg,STRIP_LIMIT:Ig},Symbol.toStringTag,{value:"Module"}));function jo({entry:e,commit:n,onSelectScreenshot:s,defaultExpanded:r=!1}){const[a,o]=l.useState(r),i=rd(e.modifiedFiles??[]),c=e.scenarioScreenshots??[],d=e.userRequest?GE(e.userRequest):"",u=!!e.userRequest||i.length>0,p=e.userRequest?"Show the full prompt":"Show test files",h=e.userRequest?"Hide the full prompt":"Hide test files";return t.jsxs("div",{"data-testid":"history-entry-card",className:"flex gap-3.5 rounded-xl border border-white/10 bg-white/[0.025] p-3.5",children:[c.length>0&&t.jsx(Lg,{shot:c[0],onSelect:s}),t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-xs leading-5 text-[var(--text-dim)]",children:[t.jsx("span",{"data-testid":"history-entry-type",className:`rounded bg-white/[0.06] px-1.5 font-medium capitalize ${Ag(e.type)}`,children:WE(e.type)}),n&&t.jsx("span",{className:"font-mono text-[var(--text-secondary)]",children:n.shortSha}),t.jsxs("span",{children:["· ",sd(e.timestamp)]}),(n==null?void 0:n.authorName)&&t.jsxs("span",{children:["· ",n.authorName]})]}),t.jsx("h3",{className:"text-[15px] font-medium leading-snug text-[var(--text-primary)]",children:e.title}),d&&!a&&t.jsx("p",{"data-testid":"history-entry-summary",className:"line-clamp-2 text-[13px] leading-relaxed text-[var(--text-secondary)]",children:d}),a&&t.jsxs("div",{className:"flex flex-col gap-2","data-testid":"history-entry-details",children:[e.userRequest&&t.jsx(bo,{children:e.userRequest}),i.length>0&&t.jsx(zg,{files:i})]}),u&&t.jsx("button",{type:"button",onClick:()=>o(f=>!f),className:"self-start cursor-pointer text-xs text-[var(--text-muted)] hover:text-[var(--accent-active)]",children:a?h:p}),t.jsx($g,{screenshots:c,hasTestFiles:i.length>0,testResults:e.testResults,onSelectScreenshot:s})]})]})}function $g({screenshots:e,hasTestFiles:n,testResults:s,onSelectScreenshot:r}){const a=s?t.jsx(yo,{total:s.total,passed:s.passed,failed:s.failed,noun:"tests"}):null;return e.length===0?t.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2",children:[t.jsxs("p",{className:"text-xs text-[var(--text-dim)]",children:["No screens changed",n?"":" · No test files changed"]}),a]}):t.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-between gap-x-3 gap-y-1.5",children:[t.jsx(Fg,{screenshots:e,onSelect:r}),a&&t.jsx("span",{className:"shrink-0",children:a})]})}function zg({files:e}){return t.jsxs("div",{children:[t.jsx("p",{className:"mb-1 text-xs font-medium text-[var(--text-muted)]",children:"Test files"}),t.jsx("ul",{className:"flex flex-col gap-0.5",children:e.map(n=>t.jsxs("li",{className:"flex items-center gap-1.5",children:[t.jsx(vo,{status:n.status}),t.jsx("span",{className:"truncate font-mono text-xs text-[var(--text-secondary)]",children:n.path})]},n.path))})]})}const OG=Object.freeze(Object.defineProperty({__proto__:null,CardFooter:$g,HistoryEntryCard:jo,TestFileList:zg},Symbol.toStringTag,{value:"Module"}));function Bg({label:e,children:n}){return t.jsxs("section",{"data-testid":"history-day-group","aria-label":e,children:[t.jsx("h2",{className:"mb-2 text-[11px] font-medium uppercase tracking-[0.08em] text-[var(--text-dim)]",children:e}),t.jsx("div",{className:"flex flex-col gap-2",children:n})]})}const RG=Object.freeze(Object.defineProperty({__proto__:null,HistoryDayGroup:Bg},Symbol.toStringTag,{value:"Module"}));function Dr({expanded:e,testId:n}){return t.jsx("span",{"aria-hidden":"true","data-testid":n,className:"inline-block shrink-0 text-xs leading-none text-[var(--text-dim)] transition-transform "+(e?"rotate-180":"rotate-0"),children:"⌄"})}const EG=Object.freeze(Object.defineProperty({__proto__:null,PlanDisclosureChevron:Dr},Symbol.toStringTag,{value:"Module"})),Wg="You'll be able to run a plan once the current build finishes.",KE="This plan is waiting on earlier plans that haven't finished yet.",JE="Another session is already working on this plan.";function XE(e){switch(e){case"building":return Wg;case"dependencies":return KE;case"claimed":return JE}}function Hg({message:e}){return t.jsx("span",{"aria-hidden":"true","data-testid":"plan-run-blocked-tooltip",className:"absolute bottom-full right-0 z-20 mb-2 w-max max-w-[15rem] rounded-lg border border-[var(--border-subtle)] bg-[var(--bg-card)] px-3 py-2 text-left text-[11px] normal-case tracking-normal leading-snug text-[var(--text-secondary)] shadow-lg",children:e})}const AG=Object.freeze(Object.defineProperty({__proto__:null,PlanRunBlockedTooltip:Hg},Symbol.toStringTag,{value:"Module"}));function ad({slug:e,onRun:n,launching:s=!1,blockedReason:r=null}){const a=g=>{g.stopPropagation(),!s&&n(e)},o="text-[10px] uppercase tracking-wide px-2 py-0.5 rounded border cursor-pointer disabled:opacity-60 disabled:cursor-not-allowed transition",i=" border-[var(--accent-primary)] text-[var(--accent-primary)] hover:bg-[var(--accent-primary)] hover:text-[var(--surface-bg)]",c=" border-[var(--border-default)] text-[var(--text-dim)] cursor-not-allowed hover:bg-transparent",d=s,u=r!==null&&!s,[p,h]=l.useState(!1),f=r?XE(r):null,m=u&&p;return t.jsxs("button",{type:"button",onClick:a,onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),onFocus:()=>h(!0),onBlur:()=>h(!1),disabled:d,"data-testid":`plan-run-${e}`,"aria-label":u&&f?`Run — ${f}`:void 0,className:"relative "+o+(u?c:i),children:[s?"Launching…":"Run",m&&f?t.jsx(Hg,{message:f}):null]})}const MG=Object.freeze(Object.defineProperty({__proto__:null,PlanRunButton:ad},Symbol.toStringTag,{value:"Module"})),QE={queued:"Queued",built:"Built","set-aside":"Set aside"},ZE={queued:"border-[var(--accent-active)] text-[var(--accent-active)]",built:"border-white/15 text-[var(--text-secondary)]","set-aside":"border-white/10 text-[var(--text-dim)]"};function qg({status:e}){return t.jsx("span",{"data-testid":"history-plan-status",className:`shrink-0 rounded-full border px-2 py-px text-[11px] leading-4 ${ZE[e]}`,children:QE[e]})}function Ug({commit:e,title:n,setAside:s,plan:r,onRunPlan:a}){const[o,i]=l.useState(!1),c=`${s?"Plan set aside":"Plan added"}: ${n}`,d=r.status==="queued"?r.slug:null;return t.jsxs("div",{"data-testid":"history-plan-row",children:[t.jsxs("button",{type:"button",onClick:()=>i(u=>!u),"aria-expanded":o,title:[c,e.authorName].filter(Boolean).join(" · "),className:"flex w-full cursor-pointer items-center gap-2.5 rounded-md px-3.5 py-1.5 text-left text-[13px] hover:bg-white/[0.03]",children:[t.jsx("span",{"aria-hidden":!0,className:"h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--text-muted)]"}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--text-secondary)]",children:c}),r.status&&t.jsx(qg,{status:r.status}),t.jsx("span",{className:"shrink-0 font-mono text-xs text-[var(--text-dim)]",children:e.shortSha}),t.jsx("span",{className:"shrink-0 text-xs text-[var(--text-dim)] tabular-nums",children:sd(e.timestamp)}),t.jsx(Dr,{expanded:o,testId:"history-plan-chevron"})]}),o&&t.jsxs("div",{"data-testid":"history-plan-details",className:"mt-1 mb-2 ml-7 mr-3.5 flex flex-col gap-3 rounded-lg border border-white/10 bg-white/[0.02] p-3.5",children:[r.body?t.jsx(Ft,{variant:"document",children:r.body}):t.jsx("p",{className:"text-xs text-[var(--text-dim)]",children:"This plan's file is no longer in the queue."}),d&&a&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ad,{slug:d,onRun:u=>a(u,n)}),t.jsx("span",{className:"text-xs text-[var(--text-dim)]",children:"Start building this plan now."})]})]})]})}const IG=Object.freeze(Object.defineProperty({__proto__:null,HistoryPlanStatusChip:qg,PlanHistoryRow:Ug},Symbol.toStringTag,{value:"Module"}));function Yg(e,n,s){const r=n?n.filter(o=>o.entry).length:-1,a=n?n.length:-1;l.useEffect(()=>{e(a<0?void 0:{builds:r,commits:a,total:s})},[e,r,a,s])}const eA=20;function Gg({onPreviewScreenshot:e,onRunPlan:n,onCounts:s}){const{rows:r,total:a,hasMore:o,loading:i,loadingMore:c,error:d,loadMore:u}=AE(),{plans:p}=Ir(),{plans:h}=ed(eA),{slugs:f}=td(),[m,g]=l.useState(!1),x=l.useMemo(()=>r.map(N=>({row:N,commitKind:N.entry?null:BE(N.commit.subject)})),[r]),b=m?0:x.filter(N=>{var C;return((C=N.commitKind)==null?void 0:C.kind)==="maintenance"}).length,y=l.useMemo(()=>m?r:x.filter(N=>{var C;return((C=N.commitKind)==null?void 0:C.kind)!=="maintenance"}).map(N=>N.row),[m,r,x]);Yg(s,i||r.length===0?null:y,a===void 0?void 0:Math.max(y.length,a-b));const v=l.useMemo(()=>new Set(r.flatMap(N=>N.entry?[N.entry.title.trim().toLowerCase()]:[])),[r]);if(i)return t.jsx("div",{className:"py-12 text-center text-[var(--text-muted)]",children:"Loading history..."});if(d&&r.length===0)return t.jsx("div",{className:"py-12",children:t.jsx(tt,{text:`Failed to load history: ${d}`,className:"text-sm text-[var(--accent-red)]",rowClassName:"justify-center"})});if(r.length===0)return t.jsxs("div",{className:"py-12 text-center text-[var(--text-dim)]",children:[t.jsx("p",{children:"No commits yet."}),t.jsx("p",{className:"mt-2 text-sm",children:"Commits and journal entries will appear here as you build features."})]});const j=x.filter(N=>{var C;return((C=N.commitKind)==null?void 0:C.kind)==="maintenance"}).length,_=m?x:x.filter(N=>{var C;return((C=N.commitKind)==null?void 0:C.kind)!=="maintenance"}),w=Rg(_.map(N=>N.row)),k=DE(_,N=>N.row.commit.timestamp),S=({row:N,commitKind:C},T)=>{if(N.entry)return t.jsx(jo,{entry:N.entry,commit:N.commit,onSelectScreenshot:e?P=>e({...P,isLatest:w.get(P.name)===T}):void 0},N.commit.sha);if((C==null?void 0:C.kind)==="plan-added"||(C==null?void 0:C.kind)==="plan-ignored"){const P=C.kind==="plan-ignored";return t.jsx(Ug,{commit:N.commit,title:C.title,setAside:P,plan:UE({title:C.title,setAside:P,pending:p,completed:h,completedSlugs:f,builtTitles:v}),onRunPlan:n},N.commit.sha)}return t.jsx(Mg,{commit:N.commit},N.commit.sha)};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col gap-6",children:[k.length===0&&t.jsx("p",{className:"py-8 text-center text-sm text-[var(--text-dim)]",children:"Only maintenance commits so far."}),k.map(N=>t.jsx(Bg,{label:N.label,children:N.items.map(({row:C,index:T})=>S(C,T))},N.key))]}),t.jsxs("div",{className:"mt-5 flex flex-col items-center gap-3",children:[o?t.jsx("button",{type:"button",onClick:()=>void u(),disabled:c,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:c?"Loading...":"Load older commits"}):null,j>0&&t.jsx("button",{type:"button",onClick:()=>g(N=>!N),"aria-pressed":m,"data-testid":"history-maintenance-toggle",className:"cursor-pointer text-xs text-[var(--text-dim)] hover:text-[var(--text-secondary)]",children:m?`Hide maintenance commits (${j})`:`Show maintenance commits (${j})`})]})]})}const DG=Object.freeze(Object.defineProperty({__proto__:null,HistoryLiveList:Gg},Symbol.toStringTag,{value:"Module"})),tA="dec[ií]me|dec[ií]|escrib[ií]|escrib[ií]me|respond[eé]|respondeme|respondéme|pon[eé]|mand[aá]me|say|reply|type|answer|send|tell me",nA=new RegExp(`\\b(?:${tA})\\s+(?:with\\s+|con\\s+)?["“]([^"”\\n]{1,40})["”]`,"gi");function sA(e){const n=[];let s=0;for(const r of e.matchAll(nA)){const a=r.index??0,o=a+r[0].length-r[1].length-2;o>s&&n.push({kind:"text",value:e.slice(s,o)}),n.push({kind:"reply",value:r[1]}),s=a+r[0].length}return s<e.length&&n.push({kind:"text",value:e.slice(s)}),n}const Lr=l.createContext(null);function lr(e){var r;const n=(r=e.title)==null?void 0:r.trim();if(n)return n;const s=e.name.replace(/^\d{1,2}-/,"").replace(/-/g," ").trim();return!s||/^off\s?catalog$/i.test(s)?"Custom design":s}const Vg=["keep","iterate","versions","replace"],Kg=[2,3,4],od=/```design-plan\s*([\s\S]*?)```/,Jg="Design plan:",Xg={verb:"replace"};function Qg(e,n){const s=/^(\d{1,2})-/.exec(e);return s?parseInt(s[1],10):n+1}function rA(e){const n=e&&typeof e=="object"?e:{verb:e},s=Vg.find(a=>a===n.verb);if(!s)return Xg;if(s!=="versions")return{verb:s};const r=Kg.find(a=>a===n.count)??2;return{verb:s,count:r}}function Zg(e){try{const n=JSON.parse(e);return!n||typeof n!="object"||Array.isArray(n)?null:Object.fromEntries(Object.entries(n).map(([s,r])=>[s,rA(r)]))}catch{return null}}function id(e){return e.replace(od,"").trim()}function aA(e){const n=od.exec(e);return n?{suggestion:Zg(n[1])??{},text:id(e)}:null}function oA(e,n){return e.map((s,r)=>{const a=n==null?void 0:n[s.filename];return{filename:s.filename,number:Qg(s.filename,r),name:lr(s),decision:a??Xg,suggested:a!==void 0}})}function iA(e,n,s,r){return e.map(a=>a.filename===n?{...a,decision:s==="versions"?{verb:s,count:r??a.decision.count??2}:{verb:s},suggested:!1}:a)}function lA(e){return e.verb==="versions"?`MULTIPLE VERSIONS x${e.count??2}`:e.verb.toUpperCase()}function cA(e,n){const s=e.map(o=>`#${o.number} ${o.name} (${o.filename}): ${lA(o.decision)}`),r=Object.fromEntries(e.map(o=>[o.filename,o.decision])),a=n.trim();return[`${Jg} ${s.join("; ")}.`,...a?[`My note: ${a}`]:[],"```design-plan",JSON.stringify(r),"```"].join(`
|
|
2
|
+
`)}function dA(e,n){switch(n.verb){case"keep":return`Keep #${e}`;case"iterate":return`Iterate #${e}`;case"versions":return`${n.count??2} versions of #${e}`;case"replace":return`Replace #${e}`}}function uA(e){var i;const n=e.trim();if(!n.startsWith(Jg))return null;const s=od.exec(n),r=s?Zg(s[1]):null;if(!r)return null;const a=Object.entries(r).map(([c,d],u)=>({number:Qg(c,u),d})).sort((c,d)=>c.number-d.number).map(({number:c,d})=>dA(c,d)).join(" · "),o=((i=/My note: ([\s\S]*?)\s*```design-plan/.exec(n))==null?void 0:i[1].trim())??"";return{summary:a,note:o}}const Ia=42,ex={sliders:{},words:[],text:""};function _r(e){return`${e.left}|${e.right}`}function tx(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&"sliders"in e&&"words"in e&&"text"in e}function nx(e){return tx(e)?e:ex}function pA(e,n,s){const r={...e.sliders};return s===50?delete r[_r(n)]:r[_r(n)]=Math.max(0,Math.min(100,Math.round(s))),{...e,sliders:r}}function Oh(e,n,s){const r=n.trim();if(!r)return e;const a=e.words.includes(r)?e.words.filter(o=>o!==r):[...e.words,r].slice(-s);return{...e,words:a}}function hA(e,n){return{...e,text:n}}function fA(e,n){return e.flatMap(s=>{const r=n.sliders[_r(s)];return r===void 0?[]:r<Ia?[s.left.toLowerCase()]:r>100-Ia?[s.right.toLowerCase()]:[]})}function sx(e){return Object.keys(e.sliders).length>0||e.words.length>0||e.text.trim().length>0}function rx(e,n){const s=[...fA(e,n),...n.words.map(a=>a.toLowerCase())],r=n.text.trim();return r&&s.push(`“${r}”`),s.join(", ")}const ba="Nothing",mA={picks:{},notes:{}};function ax(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&"picks"in e&&"notes"in e}function ox(e){return ax(e)?e:mA}function gA(e,n,s){const r=e.picks[n]??[];let a;return r.includes(s)?a=r.filter(o=>o!==s):s===ba?a=[ba]:a=[...r.filter(o=>o!==ba),s],{...e,picks:{...e.picks,[n]:a}}}function xA(e,n,s){return{...e,notes:{...e.notes,[n]:s}}}function bA(e){return Object.values(e.picks).some(n=>n.length>0)||Object.values(e.notes).some(n=>n.trim().length>0)}function yA(e,n){return e.flatMap(s=>{const r=(n.picks[s.file]??[]).map(o=>o.toLowerCase()),a=(n.notes[s.file]??"").trim();return a&&r.push(`“${a}”`),r.length?[`${s.label}: ${r.join(", ")}`]:[]}).join("; ")}function vA(e){return`/api/editor-design-user-file?path=${encodeURIComponent(e)}`}const Cn="__idk",jA={answers:{},own:{}},wA=3,_A=6,SA=["Layout","Colors","Type","Illustrations","Mood"],kA=/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;function Ve(e){return typeof e=="string"?e.trim():""}function NA(e){if(!Array.isArray(e))return[];const n=new Set,s=[];for(const r of e){const a=typeof r=="string"?r.trim():Ve(r==null?void 0:r.label);if(!a||n.has(a))continue;n.add(a);const o=typeof r=="object"&&r?Ve(r.detail):"";s.push(o?{label:a,detail:o}:{label:a})}return s}function cr(e){return Array.isArray(e)?[...new Set(e.map(Ve).filter(Boolean))]:[]}function CA(e){if(!Array.isArray(e))return[];const n=[];for(const s of e){const[r,a,o]=Array.isArray(s)?[Ve(s[0]),Ve(s[1]),Ve(s[2])]:[Ve(s==null?void 0:s.label),Ve(s==null?void 0:s.hex),Ve(s==null?void 0:s.detail)];!r||!kA.test(a)||n.some(i=>i.label===r)||n.push(o?{label:r,hex:a,detail:o}:{label:r,hex:a})}return n}function Rh(e){if(!Array.isArray(e))return[];const n=[];for(const s of e){const r=Array.isArray(s)?{left:s[0],right:s[1],value:s[2]}:s,a=Ve(r==null?void 0:r.left),o=Ve(r==null?void 0:r.right);if(!a||!o)continue;const i=typeof r.value=="number"?Math.max(0,Math.min(100,r.value)):50;n.push({left:a,right:o,value:i})}return n}function TA(e){if(!Array.isArray(e))return[];const n=[];for(const s of e){const r=s??{},a=typeof s=="string"?s.trim():Ve(r.file);if(!a||n.some(c=>c.file===a))continue;const o=Ve(r.label)||a.split("/").pop().replace(/\.[^.]+$/,""),i=Ve(r.placeholder)||void 0;n.push({file:a,label:o,sees:Ve(r.sees),...i?{placeholder:i}:{}})}return n}function PA(e){if(!e||typeof e!="object")return null;const n=e,s=Ve(n.id),r=Ve(n.title);if(!s||!r)return null;const a=Ve(n.why),o=NA(n.options),i=Ve(n.ownPlaceholder)||void 0;if(n.type==="palette"){const c=CA(n.options);if(c.length>0)return{id:s,type:"palette",title:r,why:a,options:c,ownPlaceholder:i}}if(n.type==="personality"){const c=Rh(n.sliders),d=cr(n.words);if(c.length>0||d.length>0){const u=typeof n.maxWords=="number"&&n.maxWords>=1?Math.floor(n.maxWords):_A;return{id:s,type:"personality",title:r,why:a,sliders:c,moreSliders:Rh(n.moreSliders),words:d,moreWords:cr(n.moreWords).filter(p=>!d.includes(p)),maxWords:u,textPlaceholder:Ve(n.textPlaceholder)||void 0}}}if(n.type==="refs"){const c=TA(n.images);if(c.length>0){const d=cr(n.parts);return{id:s,type:"refs",title:r,why:a,images:c,parts:d.length?d:SA}}}if(n.type==="multi"&&o.length>0){const c=typeof n.max=="number"&&n.max>=1?Math.floor(n.max):wA;return{id:s,type:"multi",title:r,why:a,options:o,max:c,ownPlaceholder:i}}return n.type!=="free"&&o.length>0?{id:s,type:"single",title:r,why:a,options:o,ownPlaceholder:i}:{id:s,type:"free",title:r,why:a,placeholder:Ve(n.placeholder)||void 0}}function OA(e){if(!e||typeof e!="object")return null;const n=e;if(!Array.isArray(n.questions))return null;const s=new Set,r=[];for(const i of n.questions){const c=PA(i);!c||s.has(c.id)||(s.add(c.id),r.push(c))}if(r.length===0)return null;const a={},o=n.defaults&&typeof n.defaults=="object"?n.defaults:{};for(const i of r){if(i.type==="free")continue;const c=o[i.id];if(i.type==="personality"){const u=cr(Array.isArray(c)?c:c==null?void 0:c.words).slice(0,i.maxWords);u.length&&(a[i.id]={...ex,words:u});continue}if(i.type==="refs"){const u={},p=c&&typeof c=="object"&&!Array.isArray(c)?c:{};for(const h of i.images){const f=cr(p[h.file]).filter(m=>i.parts.includes(m));f.length&&(u[h.file]=f)}Object.keys(u).length&&(a[i.id]={picks:u,notes:{}});continue}const d=new Set(i.options.map(u=>u.label));if((i.type==="single"||i.type==="palette")&&typeof c=="string"&&d.has(c)&&(a[i.id]=c),i.type==="multi"&&Array.isArray(c)){const u=c.filter(p=>typeof p=="string"&&d.has(p)).slice(0,i.max);u.length&&(a[i.id]=u)}}return{title:Ve(n.title)||"Quick questions before I design this",lede:Ve(n.lede),questions:r,defaults:a}}function Fr(e,n){const s=n.answers[e.id],r=(n.own[e.id]??"").trim();return e.type==="free"?typeof s=="string"&&s.trim().length>0:s===Cn?!0:e.type==="personality"?tx(s)&&sx(s):e.type==="refs"?ax(s)&&bA(s):Array.isArray(s)&&s.length>0||r.length>0}function wo(e){return e.questions.filter(n=>n.type!=="free")}function ix(e,n){return wo(e).filter(s=>Fr(s,n)).length}function RA(e,n){var s;return((s=wo(e).find(r=>!Fr(r,n)))==null?void 0:s.id)??null}function EA(e,n){const s=wo(e).length;return s===0?AA(e,n):ix(e,n)>=Math.min(2,s)}function AA(e,n){return e.questions.some(s=>s.type==="free"&&Fr(s,n))}function MA(e){return e.type==="multi"||e.type==="single"||e.type==="palette"?e.options.length:0}function IA(e,n,s,r){const a=Array.isArray(e.answers[n])?e.answers[n]:[];r<1&&(r=Number.MAX_SAFE_INTEGER);const o=a.includes(s)?a.filter(i=>i!==s):[...a,s].slice(-r);return{...e,answers:{...e.answers,[n]:o}}}function DA(e,n,s){const r={...e.own,[n.id]:s},a={...e.answers};return a[n.id]===Cn&&(a[n.id]=[]),{answers:a,own:r}}function LA(e,n){const s={...e.answers},r={...e.own};return s[n]===Cn?delete s[n]:(s[n]=Cn,delete r[n]),{answers:s,own:r}}function FA(e,n,s){return{...e,answers:{...e.answers,[n]:s}}}function $A(e,n,s){return{...e,answers:{...e.answers,[n]:s}}}function zA(e,n){const s={};for(const r of e.questions)if(r.type==="free"){const a=n.answers[r.id];typeof a=="string"&&a&&(s[r.id]=a)}else if(e.defaults[r.id]!==void 0){const a=e.defaults[r.id];s[r.id]=typeof a=="string"?[a]:a}else s[r.id]=Cn;return{answers:s,own:{}}}function BA(e,n){if(!Fr(e,n))return null;const s=n.answers[e.id],r=(n.own[e.id]??"").trim();return s===Cn?"Not sure, decide for me":e.type==="free"?s.trim():e.type==="personality"?rx([...e.sliders,...e.moreSliders],nx(s)):e.type==="refs"?yA(e.images,ox(s)):[...Array.isArray(s)?s:[],...r?[r]:[]].join(", ")}function WA(e,n){const s={},r={},a=[];for(const o of e.questions){const i=BA(o,n);if(i===null)continue;const c=n.answers[o.id];s[o.id]=typeof c=="string"?c.trim():c??[];const d=(n.own[o.id]??"").trim();d&&o.type!=="free"&&c!==Cn&&(r[o.id]=d),a.push({id:o.id,title:o.title,answer:i})}return{answers:s,own:r,summary:a}}const ld="I answered the questions in the preview. Read .codeyam/design/answers.json and continue.\r",HA="Before you design, ask me one more follow-up question here in the chat.\r";function qA(e){if(!Array.isArray(e))return;const n=e.flatMap(s=>{if(!s||typeof s!="object")return[];const r=s;if(typeof r.question!="string"||!Array.isArray(r.options))return[];const a=r.options.flatMap(o=>{if(!o||typeof o!="object")return[];const i=o;return typeof i.label=="string"?[{label:i.label,description:typeof i.description=="string"?i.description:""}]:[]});return a.length===0?[]:[{question:r.question,header:typeof r.header=="string"?r.header:"",multiSelect:r.multiSelect===!0,options:a}]});return n.length>0?n:void 0}const Sr={available:!1,working:!1,messages:[]},UA=new Set(["user","agent","activity"]);function lx(e){if(!e||typeof e!="object")return Sr;const n=e,s=Array.isArray(n.messages)?n.messages.flatMap(a=>{if(!a||typeof a!="object")return[];const o=a;return typeof o.id!="string"||typeof o.role!="string"||!UA.has(o.role)?[]:[{id:o.id,role:o.role,text:typeof o.text=="string"?o.text:"",items:Array.isArray(o.items)?o.items.filter(i=>typeof i=="string"):[]}]}):[],r=qA(n.question);return{available:n.available===!0,working:n.working===!0,messages:s,...r?{question:r}:{}}}function YA(e){return e.trim()===ld.trim()}function GA(e){const n=ld.trim();return e.some(s=>s.role==="user"&&s.text.trim().endsWith(n))}function VA(e){const n=e.join(", ");return`I added ${e.length===1?"a file":`${e.length} files`} to .codeyam/design/user_files/: ${n}. Take a look and use ${e.length===1?"it":"them"}.`}const KA=/^I added (?:a file|\d+ files) to \.codeyam\/design\/user_files\/: (.+?)\. Take a look and use (?:it|them)\.(?:\s+([\s\S]*))?$/,JA=/^([\s\S]*?)\s*I added (?:a file|\d+ files) to \.codeyam\/design\/user_files\/: (.+?)\. Take a look and use (?:it|them)\.$/;function XA(e){const n=e.trim(),s=KA.exec(n);if(s)return{names:s[1].split(", "),rest:(s[2]??"").trim()};const r=JA.exec(n);return r?{names:r[2].split(", "),rest:r[1].trim()}:null}function cx(e){const n=e.trim();if(!n.startsWith("Iterate:"))return null;const s=/```json\s*([\s\S]*?)```/.exec(n);if(!s)return{designs:0};try{const r=JSON.parse(s[1]);return{designs:Object.keys(r).length}}catch{return{designs:0}}}function cd(e){return/\?[\s"'”’)\]*_]*$/.test(id(e))}function dd(e){return`${e.replace(/\s*\n\s*/g," ").trim()}\r`}function QA(e){const n=[],s=/\*\*([^*]+)\*\*|`([^`]+)`/g;let r=0;for(const a of e.matchAll(s))a.index>r&&n.push({kind:"text",value:e.slice(r,a.index)}),n.push(a[1]!==void 0?{kind:"bold",value:a[1]}:{kind:"code",value:a[2]}),r=a.index+a[0].length;return r<e.length&&n.push({kind:"text",value:e.slice(r)}),n}function ZA(e){return e.split(/\n\s*\n/).map(n=>n.trim()).filter(n=>n.length>0)}function eM(e){const n=[];let s=[],r=null;const a=()=>{const o=s.join(`
|
|
3
|
+
`).trim();o&&n.push({kind:"text",value:o}),s=[]};for(const o of e.split(`
|
|
4
|
+
`))/^\s*```/.test(o)?r===null?(a(),r=[]):(n.push({kind:"code",value:r.join(`
|
|
5
|
+
`)}),r=null):r!==null?r.push(o):s.push(o);return r!==null&&n.push({kind:"code",value:r.join(`
|
|
6
|
+
`).trimEnd()}),a(),n}let ud=new Set,Da=null,dx=0;const al=new Set;function ux(){dx+=1;for(const e of al)e()}function tM(e){ud=new Set(e),ux()}function Eh(e){Da=e,ux()}function nM(e){return ud.has(e)}function sM(){return Da!==null}function rM(e){Da&&ud.has(e)&&Da(e)}function aM(e){return al.add(e),()=>al.delete(e)}function oM(){return dx}let pd=new Set,La=null,px=0;const ol=new Set;function Ah(e,n){pd=new Set(e),La=n,px+=1;for(const s of ol)s()}function iM(e){return La!==null&&pd.has(e)}function lM(e){La&&pd.has(e)&&La(e)}function cM(e){return ol.add(e),()=>ol.delete(e)}function dM(){return px}const uM=/\b(?:design|dise(?:ñ|n)o)\s*#?\s*(\d{1,2})(?![\d])/gi;function pM(e){const n=[];let s=0;for(const r of e.matchAll(uM)){const a=r.index??0;a>s&&n.push({kind:"text",value:e.slice(s,a)}),n.push({kind:"design",value:r[0],number:parseInt(r[1],10)}),s=a+r[0].length}return s<e.length&&n.push({kind:"text",value:e.slice(s)}),n}const hM=/^:?-+:?$/;function _i(e){const n=[];let s="",r=!1;for(const a of e.trim())a==="`"&&(r=!r),a==="|"&&!r?(n.push(s.trim()),s=""):s+=a;return n.push(s.trim()),e.trim().startsWith("|")&&n.shift(),e.trim().endsWith("|")&&n.pop(),n}function fM(e){const n=e.split(`
|
|
7
|
+
`).map(o=>o.trim());if(n.length<2||n.some(o=>!o.includes("|")))return null;const s=_i(n[0]),r=_i(n[1]);if(r.length!==s.length||!r.every(o=>hM.test(o)))return null;const a=n.slice(2).map(o=>{const i=_i(o).slice(0,s.length);for(;i.length<s.length;)i.push("");return i});return{header:s,rows:a}}const mM=/^(\s*)([-*•]|\d+[.)])\s+(.*)$/;function gM(e){const n=[];for(const s of e.split(`
|
|
8
|
+
`)){const r=mM.exec(s),a=n[n.length-1];if(r){const o={text:r[3],depth:Math.min(2,Math.floor(r[1].length/2))};(a==null?void 0:a.kind)==="list"?a.items.push(o):n.push({kind:"list",ordered:/\d/.test(r[2]),items:[o]})}else(a==null?void 0:a.kind)==="text"?a.text+=`
|
|
9
|
+
${s}`:n.push({kind:"text",text:s})}return n}const xM=/https?:\/\/[^\s<>"'`]+/g,bM=/[.,;:!?)\]}»]+$/;function yM(e){const n=[];let s=0;for(const r of e.matchAll(xM)){const a=r.index??0,o=r[0].replace(bM,"");a>s&&n.push({kind:"text",value:e.slice(s,a)}),n.push({kind:"link",value:o}),s=a+o.length}return s<e.length&&n.push({kind:"text",value:e.slice(s)}),n.length?n:[{kind:"text",value:e}]}let Fa=null,ya=0;const il=new Set,hx=()=>il.forEach(e=>e());function vM(){return Fa}function jM(e){return il.add(e),()=>il.delete(e)}function wM(e){return ya===0?!1:(Fa=e,hx(),!0)}function fx(){Fa!==null&&(Fa=null,hx())}function _M(){return ya+=1,()=>{ya-=1,ya===0&&fx()}}function mx({href:e,children:n}){return t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",onClick:s=>{s.metaKey||s.ctrlKey||s.shiftKey||s.altKey||s.button!==0||wM(e)&&s.preventDefault()},className:"underline decoration-white/30 underline-offset-2 hover:decoration-white/70 cursor-pointer",style:{color:"inherit",overflowWrap:"anywhere"},children:n??e})}const LG=Object.freeze(Object.defineProperty({__proto__:null,ChatLink:mx},Symbol.toStringTag,{value:"Module"}));function gx({code:e}){return t.jsxs("div",{"data-testid":"design-chat-code-block",style:{margin:"2px 0 8px",borderRadius:8,border:"1px solid rgba(255,255,255,.06)",background:"rgba(0,0,0,.18)",display:"flex",alignItems:"flex-start",gap:8,padding:"8px 8px 8px 10px"},children:[t.jsx("pre",{style:{flex:1,minWidth:0,margin:0,fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:11.5,lineHeight:1.6,color:"#9a9a9a",maxHeight:168,overflowY:"auto",whiteSpace:"pre-wrap",overflowWrap:"anywhere",userSelect:"text"},children:e}),t.jsx(ct,{text:e,label:"Copy",copiedLabel:"✓ Copied",className:"shrink-0 px-2.5 py-1 text-xs font-medium rounded-md bg-[var(--accent-active)] text-[var(--text-on-accent,#111)] hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed transition-opacity cursor-pointer"})]})}const FG=Object.freeze(Object.defineProperty({__proto__:null,DesignChatCodeBlock:gx},Symbol.toStringTag,{value:"Module"}));function ll({text:e,showMark:n=!0,bright:s=!1,warning:r=!1,tint:a}){return t.jsxs("div",{"data-testid":"design-chat-agent","data-warning":r?"true":void 0,"data-tint":a??void 0,style:{color:r?"#e5c454":a??(s?"#e8e8e8":"#a2a2a2"),maxWidth:"96%",transition:"color 300ms"},children:[n&&t.jsx("div",{style:{color:"var(--accent-active, #D7FF63)",marginBottom:5,display:"flex"},children:t.jsx(cs,{markOnly:!0,className:"h-3.5"})}),eM(id(e)).map((o,i,c)=>{var d;return o.kind==="code"?t.jsx(gx,{code:o.value},i):t.jsx(SM,{text:o.value,bright:s,leadsCode:((d=c[i+1])==null?void 0:d.kind)==="code"},i)})]})}function SM({text:e,bright:n=!1,leadsCode:s=!1}){const r=ZA(e);return t.jsx(t.Fragment,{children:r.map((a,o)=>{const i=fM(a);if(i)return t.jsx(NM,{table:i},o);const c=gM(a);return c.map((d,u)=>{if(d.kind==="list")return t.jsx(kM,{ordered:d.ordered,items:d.items,bright:n},`${o}-${u}`);const p=s&&o===r.length-1&&u===c.length-1&&/:\s*$/.test(d.text);return t.jsx("p",{"data-instruction":p?"true":void 0,style:{margin:"0 0 6px",whiteSpace:"pre-wrap",overflowWrap:"anywhere",...p?{color:"var(--accent-active, #D7FF63)",fontWeight:600}:null},children:t.jsx($a,{text:d.text,bright:n})},`${o}-${u}`)})})})}function kM({ordered:e,items:n,bright:s}){const r=e?"ol":"ul";return t.jsx(r,{style:{margin:"0 0 8px",paddingLeft:"1.2em",listStyleType:e?"decimal":"disc"},children:n.map((a,o)=>t.jsx("li",{style:{marginLeft:`${a.depth*1.1}em`,marginBottom:3,listStyleType:a.depth>0?"circle":void 0,overflowWrap:"anywhere"},children:t.jsx($a,{text:a.text,bright:s})},o))})}function NM({table:e}){const n={padding:"4px 10px",textAlign:"left",verticalAlign:"top"};return t.jsx("div",{style:{overflowX:"auto",margin:"2px 0 8px"},children:t.jsxs("table",{style:{borderCollapse:"collapse",fontSize:"0.95em"},children:[t.jsx("thead",{children:t.jsx("tr",{style:{borderBottom:"1px solid rgba(255,255,255,.14)"},children:e.header.map((s,r)=>t.jsx("th",{style:{...n,color:"#d6d6d6",fontWeight:500},children:t.jsx($a,{text:s})},r))})}),t.jsx("tbody",{children:e.rows.map((s,r)=>t.jsx("tr",{style:{borderBottom:"1px solid rgba(255,255,255,.06)"},children:s.map((a,o)=>t.jsx("td",{style:n,children:t.jsx($a,{text:a})},o))},r))})]})})}const Mh={fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:"0.92em",padding:"0 4px",borderRadius:4,background:"rgba(255,255,255,.06)",color:"#c9c9c9"};function xx({value:e}){return l.useSyncExternalStore(aM,oM),!nM(e)||!sM()?t.jsx("code",{style:Mh,children:e}):t.jsx("button",{type:"button",onClick:()=>rM(e),title:"Open this scenario in the preview",style:{...Mh,border:"none",cursor:"pointer",color:"var(--accent-active, #D7FF63)",textDecoration:"underline",textUnderlineOffset:2,textDecorationColor:"rgba(215,255,99,.45)"},children:e})}function $a({text:e,bright:n=!1}){return t.jsx(t.Fragment,{children:QA(e).map((s,r)=>s.kind==="bold"?t.jsx("strong",{style:n?{color:"#ffffff",fontWeight:600}:{color:"#d6d6d6",fontWeight:500},children:t.jsx(Ih,{text:s.value})},r):s.kind==="code"?t.jsx(xx,{value:s.value},r):t.jsx("span",{children:t.jsx(Ih,{text:s.value})},r))})}function Ih({text:e}){return t.jsx(t.Fragment,{children:yM(e).map((n,s)=>n.kind==="link"?t.jsx(mx,{href:n.value},s):t.jsx(bx,{text:n.value},s))})}function bx({text:e}){const n=l.useContext(Lr);return n?t.jsx(t.Fragment,{children:sA(e).map((s,r)=>s.kind==="reply"?t.jsx("button",{type:"button","aria-label":`Reply ${s.value}`,title:`Send "${s.value}"`,onClick:()=>n(s.value),style:{display:"inline-flex",alignItems:"center",margin:"0 1px",padding:"0 8px",borderRadius:999,border:"1px solid rgba(215,255,99,.45)",background:"rgba(215,255,99,.08)",color:"var(--accent-active, #D7FF63)",font:"inherit",fontWeight:500,lineHeight:1.5,cursor:"pointer"},children:s.value},r):t.jsx(cl,{text:s.value},r))}):t.jsx(cl,{text:e})}function cl({text:e}){return l.useSyncExternalStore(cM,dM),t.jsx(t.Fragment,{children:pM(e).map((n,s)=>n.kind==="design"&&iM(n.number)?t.jsx("button",{type:"button",onClick:()=>lM(n.number),title:"Open this design",style:{background:"none",border:"none",padding:0,font:"inherit",cursor:"pointer",color:"var(--accent-active, #D7FF63)",textDecoration:"underline",textUnderlineOffset:2,textDecorationColor:"rgba(215,255,99,.45)"},children:n.value},s):n.value)})}const $G=Object.freeze(Object.defineProperty({__proto__:null,CodeRun:xx,DesignChatAgentMessage:ll,DesignRefs:cl,QuickReplies:bx},Symbol.toStringTag,{value:"Module"}));function yx({serviceName:e,onAsk:n}){const[s,r]=l.useState("");return t.jsxs("form",{className:"xsvc-row-ask",onSubmit:a=>{a.preventDefault();const o=s.trim();n(o?`About ${e}: ${o}`:`Tell me about ${e} in this project.`),r("")},children:[t.jsx("input",{className:"xsvc-row-ask-input","aria-label":`Ask about ${e}`,placeholder:`Ask about ${e}…`,value:s,onChange:a=>r(a.target.value)}),t.jsx("button",{type:"submit",className:"xsvc-setup-btn",children:"Ask"})]})}const zG=Object.freeze(Object.defineProperty({__proto__:null,ServiceAskField:yx},Symbol.toStringTag,{value:"Module"})),Ln=300,Dh=.85,vx="codeyam:results-panel-height";function CM(){try{const e=Number(window.localStorage.getItem(vx));return Number.isFinite(e)&&e>=Ln?e:Ln}catch{return Ln}}function Lh(e){try{window.localStorage.setItem(vx,String(Math.round(e)))}catch{}}function jx({children:e}){const[n,s]=l.useState(CM),r=l.useRef(null),a=o=>{var m,g;o.preventDefault();const i=o.clientY,c=n,d=((g=(m=r.current)==null?void 0:m.parentElement)==null?void 0:g.getBoundingClientRect().height)||window.innerHeight,u=Math.max(Ln,d*Dh);let p=c;const h=x=>{p=Math.min(u,Math.max(Ln,c+(i-x.clientY))),s(p)},f=()=>{window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",f),document.body.style.cursor="",Lh(p)};document.body.style.cursor="row-resize",window.addEventListener("pointermove",h),window.addEventListener("pointerup",f)};return t.jsxs("div",{ref:r,"data-testid":"build-pane-results",style:{position:"relative",flex:"0 0 auto",height:n,maxHeight:`${Dh*100}%`,minHeight:0,display:"flex",flexDirection:"column"},children:[t.jsx("div",{role:"separator","aria-orientation":"horizontal","aria-label":"Resize the results panel",title:"Drag to resize","data-testid":"results-panel-resize",onPointerDown:a,onDoubleClick:()=>{s(Ln),Lh(Ln)},className:"group absolute left-0 right-0 z-10 flex justify-center",style:{top:-4,height:9,cursor:"row-resize"},children:t.jsx("span",{"aria-hidden":"true",className:"mt-[3px] h-[3px] w-10 rounded-full bg-white/0 transition-colors group-hover:bg-white/30"})}),e]})}const BG=Object.freeze(Object.defineProperty({__proto__:null,RESULTS_PANEL_MIN_HEIGHT:Ln,ResizableResultsPanel:jx},Symbol.toStringTag,{value:"Module"})),it="#FF8B43",za="waiting on you",Ba="Waiting on you";function wx({title:e,body:n,nextAction:s,actionLabel:r,onAction:a,pending:o=!1,feedback:i,variant:c}){const{projectDir:d,inContainer:u,loaded:p}=ho(),h=iR({headline:e,explanation:n,nextAction:s,connection:p?lR(d,u):null});return t.jsx("div",{"data-testid":"preview-unhealthy-overlay","data-variant":c,className:"absolute inset-0 z-50 flex items-center justify-center p-6 animate-in fade-in duration-300",style:{background:"var(--bg-deep, #1b1b1b)"},children:t.jsxs("div",{role:"alert","aria-label":e,"data-testid":"preview-unhealthy-notice",className:"flex max-w-xs flex-col items-center text-center",children:[t.jsx("span",{"aria-hidden":"true",style:{width:8,height:8,borderRadius:"50%",background:it,marginBottom:12}}),t.jsx("h3",{className:"text-[14px] font-medium text-[var(--text-primary)]",children:e}),t.jsx("p",{className:"mt-1.5 text-[12.5px] leading-relaxed text-[var(--text-muted)]",children:n}),a&&t.jsx("button",{type:"button","data-testid":"preview-unhealthy-overlay-retry",onClick:a,disabled:o,className:"mt-4 rounded-lg px-4 py-1.5 text-[12.5px] font-medium transition-opacity hover:opacity-90 disabled:opacity-60",style:{background:"var(--accent-active, #D7FF63)",color:"#1a1a1a"},children:o?"Checking…":r}),i&&t.jsx("p",{className:"mt-2 text-[11.5px] text-[var(--text-muted)]",children:i}),t.jsx(ct,{text:h,label:"Copy details",copiedLabel:"Copied",variant:"subtle",className:"mt-3 text-[11.5px] text-[var(--text-dim)] underline underline-offset-2 hover:text-[var(--text-secondary)]"})]})})}const WG=Object.freeze(Object.defineProperty({__proto__:null,PreviewStuckPanel:wx},Symbol.toStringTag,{value:"Module"}));function _x({title:e,body:n}){return t.jsxs("section",{"data-testid":"plan-preview-card","aria-label":`Plan: ${e}`,style:{border:"1px solid rgba(255,255,255,.14)",background:"rgba(255,255,255,.04)",borderRadius:10,padding:"12px 14px",marginBottom:10},children:[t.jsx("div",{style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:10.5,letterSpacing:".1em",textTransform:"uppercase",color:"var(--text-dim)",marginBottom:4},children:"The plan"}),t.jsx("div",{style:{fontSize:14,fontWeight:600,color:"var(--text-primary)",marginBottom:6},children:e}),t.jsx("div",{style:{maxHeight:260,overflowY:"auto",fontSize:12.5,color:"var(--text-secondary)"},children:t.jsx(Ft,{variant:"document",children:n})})]})}const HG=Object.freeze(Object.defineProperty({__proto__:null,PlanPreviewCard:_x},Symbol.toStringTag,{value:"Module"}));function Ht({size:e=16}){return t.jsx("span",{"aria-hidden":"true","data-testid":"design-session-spinner",className:"animate-spin",style:{display:"inline-block",flex:"none",width:e,height:e,borderRadius:"50%",border:`${e>=24?3:2}px solid rgba(111,255,0,.18)`,borderTopColor:"var(--working)"}})}const qG=Object.freeze(Object.defineProperty({__proto__:null,DesignSessionSpinner:Ht},Symbol.toStringTag,{value:"Module"}));function qn({variant:e="sequence"}){return e==="pulse"?t.jsx("span",{"aria-hidden":"true","data-testid":"loading-dots","data-variant":"pulse",className:"animate-pulse motion-reduce:animate-none",style:{display:"inline-flex",marginLeft:1},children:"..."}):t.jsxs("span",{"aria-hidden":"true","data-testid":"loading-dots","data-variant":"sequence",className:"cy-loading-dots",style:{display:"inline-flex",marginLeft:1},children:[t.jsx("style",{children:`
|
|
10
|
+
@keyframes cy-loading-dot {
|
|
11
|
+
0%, 20% { opacity: .15; }
|
|
12
|
+
40%, 70% { opacity: 1; }
|
|
13
|
+
100% { opacity: .15; }
|
|
14
|
+
}
|
|
15
|
+
.cy-loading-dots > i {
|
|
16
|
+
font-style: normal;
|
|
17
|
+
opacity: .15;
|
|
18
|
+
animation: cy-loading-dot 1.4s infinite ease-in-out both;
|
|
19
|
+
}
|
|
20
|
+
.cy-loading-dots > i:nth-child(2) { animation-delay: .2s; }
|
|
21
|
+
.cy-loading-dots > i:nth-child(3) { animation-delay: .4s; }
|
|
22
|
+
@media (prefers-reduced-motion: reduce) {
|
|
23
|
+
.cy-loading-dots > i { animation: none; opacity: .6; }
|
|
24
|
+
}
|
|
25
|
+
`}),t.jsx("i",{children:"."}),t.jsx("i",{children:"."}),t.jsx("i",{children:"."})]})}const UG=Object.freeze(Object.defineProperty({__proto__:null,LoadingDots:qn},Symbol.toStringTag,{value:"Module"}));function Wa({name:e}){return t.jsxs("div",{role:"status","data-testid":"formalize-handoff",style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:10,padding:24,textAlign:"center",background:"var(--bg-deep, #1e1e1e)"},children:[t.jsx(Ht,{size:18}),t.jsxs("div",{style:{fontSize:15,fontWeight:500,color:"var(--text-primary)"},children:["Preparing to finalize ",e?t.jsx("span",{children:e}):"your prototype",t.jsx(qn,{})]}),t.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)",maxWidth:420,lineHeight:1.5},children:"The agent is writing the plan. Build opens on its own when it's ready."})]})}const YG=Object.freeze(Object.defineProperty({__proto__:null,FormalizeHandoffPanel:Wa},Symbol.toStringTag,{value:"Module"}));function Sx(e){const n=e.trim().toLowerCase().replace(/^[a-z]+:\/\//,"").replace(/[/?#].*$/,"").replace(/^www\./,"");return/^[a-z0-9-]+(\.[a-z0-9-]+)*\.[a-z]{2,}$/.test(n)?n:null}function kx({onSave:e}){const[n,s]=l.useState(!1),[r,a]=l.useState(""),[o,i]=l.useState(null),[c,d]=l.useState(!1);if(!n)return t.jsx("button",{type:"button",className:"xsvc-setup-alt",onClick:()=>s(!0),children:"I already have one"});const u=async p=>{p.preventDefault();const h=Sx(r);if(!h){i("Enter a domain like elcarot.com");return}d(!0);try{await e(h)}catch(f){i(f instanceof Error?f.message:"Couldn't save it. Try again."),d(!1)}};return t.jsxs("form",{className:"xsvc-domain-form",onSubmit:p=>void u(p),children:[t.jsx("input",{autoFocus:!0,"aria-label":"Your domain",className:"xsvc-domain-input",placeholder:"yourdomain.com",value:r,onChange:p=>{a(p.target.value),i(null)}}),t.jsx("button",{type:"submit",className:"xsvc-setup-btn",disabled:c,children:c?"Saving…":"Save"}),o&&t.jsx("span",{role:"alert",className:"xsvc-domain-error",children:o})]})}const GG=Object.freeze(Object.defineProperty({__proto__:null,DomainCardEntry:kx,normalizeDomainInput:Sx},Symbol.toStringTag,{value:"Module"}));function _o({login:e,onSubmitCode:n,onOpenTerminal:s}){const[r,a]=l.useState(""),o=r.trim(),i=()=>{o&&(n(o),a(""))};return t.jsxs("div",{role:"group","aria-label":"The agent is waiting for you to sign in","data-testid":"design-chat-terminal-login",style:{border:"1px solid rgba(255,139,67,.4)",background:"rgba(255,139,67,.06)",borderRadius:10,padding:"10px 12px",display:"flex",flexDirection:"column",gap:8,fontSize:13,color:"var(--text-secondary)"},children:[t.jsx("span",{style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:10.5,letterSpacing:".1em",textTransform:"uppercase",color:it},children:"Needs you to sign in"}),t.jsx("div",{style:{color:"var(--text-primary)",fontWeight:500},children:"Sign in to continue"}),t.jsx("div",{style:{lineHeight:1.45},children:e.url?"Open the sign-in page, sign in, then paste the code it shows here.":"Sign in from the terminal, then paste the code the sign-in page shows here."}),e.url&&t.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:{alignSelf:"flex-start",padding:"5px 12px",borderRadius:8,background:"var(--accent-active, #D7FF63)",color:"#141414",fontSize:12.5,fontWeight:500,textDecoration:"none"},children:"Open the sign-in page"}),t.jsxs("div",{style:{display:"flex",gap:6},children:[t.jsx("input",{type:"text","aria-label":"Sign-in code",placeholder:"Paste the code",value:r,onChange:c=>a(c.target.value),onKeyDown:c=>{c.key==="Enter"&&i()},style:{flex:1,minWidth:0,padding:"5px 8px",borderRadius:8,border:"1px solid rgba(255,255,255,.14)",background:"rgba(0,0,0,.2)",color:"var(--text-primary)",fontSize:12.5}}),t.jsx("button",{type:"button",onClick:i,disabled:!o,style:{padding:"5px 12px",borderRadius:8,border:"1px solid rgba(255,255,255,.14)",background:"transparent",color:o?"var(--text-primary)":"var(--text-muted)",fontSize:12.5,cursor:o?"pointer":"default"},children:"Send code"})]}),t.jsx("div",{style:{display:"flex",fontSize:11.5},children:t.jsx("button",{type:"button",onClick:s,style:{marginLeft:"auto",background:"none",border:"none",padding:0,color:"var(--text-secondary)",textDecoration:"underline",cursor:"pointer",fontSize:11.5},children:"Open Terminal"})})]})}const VG=Object.freeze(Object.defineProperty({__proto__:null,DesignChatTerminalLogin:_o},Symbol.toStringTag,{value:"Module"}));function Nx({sessionName:e,onCancel:n,onConfirm:s}){return l.useEffect(()=>{const r=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[n]),t.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:t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":`Close this ${e}?`,"data-testid":"close-session-confirm",onClick:r=>r.stopPropagation(),style:{background:"var(--bg-elevated, #141414)",border:"1px solid var(--border-default)",borderRadius:12,padding:24,width:"min(420px, 100%)",display:"flex",flexDirection:"column",gap:12,boxShadow:"0 20px 60px rgba(0,0,0,0.5)"},children:[t.jsxs("div",{style:{fontSize:15,fontWeight:600,color:"var(--text-primary)"},children:["Close this ",e,"?"]}),t.jsx("div",{style:{fontSize:13,lineHeight:1.5,color:"var(--text-secondary)"},children:"The chat closes and you go back to the start of this tab. What you asked for stays in the box, so you can pick it up again."}),t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[t.jsx("button",{type:"button",onClick:n,autoFocus:!0,style:{padding:"6px 14px",borderRadius:8,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-primary)",fontSize:13,cursor:"pointer"},children:"Keep working"}),t.jsx("button",{type:"button",onClick:s,style:{padding:"6px 14px",borderRadius:8,border:"1px solid var(--accent-danger, #f87171)",background:"transparent",color:"var(--accent-danger, #f87171)",fontSize:13,cursor:"pointer"},children:"Close session"})]})]})})}const KG=Object.freeze(Object.defineProperty({__proto__:null,CloseSessionConfirmModal:Nx},Symbol.toStringTag,{value:"Module"})),Rn="#8ab4f8";function TM(e){for(const n of e??[]){const s=/\b(\d+)\s+(?:shells?|background (?:tasks?|shells?)|tasks?)\s+still running/i.exec(n);if(s)return Number(s[1])}return 0}function Cx(e){if(e<60)return`${e}s`;const n=Math.floor(e/60);return n<60?`${n}m ${e%60}s`:`${Math.floor(n/60)}h ${n%60}m`}const Tx="Check on the background task and continue where you left off.";function Px({since:e,onCheck:n}){const[s,r]=l.useState(()=>Date.now());l.useEffect(()=>{const o=window.setInterval(()=>r(Date.now()),1e3);return()=>window.clearInterval(o)},[]);const a=Math.max(0,Math.floor((s-e)/1e3));return t.jsxs("div",{role:"status","data-testid":"agent-chat-background-task",style:{border:`1px solid ${Rn}55`,background:`${Rn}12`,borderRadius:10,padding:"9px 12px",fontSize:12.5,color:Rn,display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[t.jsx("span",{"aria-hidden":"true",style:{width:7,height:7,borderRadius:"50%",background:Rn,flex:"none"}}),t.jsxs("span",{style:{flex:1,minWidth:0},children:["Waiting for a background task (",Cx(a),"). The agent goes on by itself when it finishes."]}),n&&t.jsx("button",{type:"button",onClick:n,className:"hover:opacity-90",style:{border:`1px solid ${Rn}88`,background:"transparent",color:Rn,borderRadius:8,padding:"3px 10px",fontSize:12,cursor:"pointer"},children:"Check on it"})]})}const JG=Object.freeze(Object.defineProperty({__proto__:null,BackgroundTaskCard:Px,CHECK_BACKGROUND_TASK:Tx},Symbol.toStringTag,{value:"Module"}));function Fh(e){return/^\s*API Error\b/i.test(e)}const PM="Continue where you left off.";function Ox({text:e}){const n=l.useContext(Lr);return t.jsxs("div",{"data-testid":"agent-error-reply",role:"status",style:{border:"1px solid rgba(255,255,255,.14)",background:"rgba(255,255,255,.045)",borderRadius:10,padding:"12px 14px",display:"flex",flexDirection:"column",gap:6},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"var(--text-primary)",fontSize:13},children:[t.jsx("span",{"aria-hidden":"true",style:{width:7,height:7,borderRadius:"50%",background:it,flex:"none"}}),"The connection to the agent dropped"]}),t.jsx("div",{style:{color:"var(--text-muted)",fontSize:12.5},children:"It stopped before finishing, so nothing is running now. Ask it to pick up where it left off."}),n&&t.jsx("button",{type:"button",onClick:()=>n(PM),className:"hover:opacity-90",style:{alignSelf:"flex-start",marginTop:4,padding:"5px 14px",borderRadius:8,border:"none",background:"var(--accent-active, #D7FF63)",color:"#1a1a1a",fontSize:12.5,fontWeight:500,cursor:"pointer"},children:"Continue"}),t.jsx("div",{style:{color:"var(--text-dim)",fontSize:11.5,marginTop:2},children:e})]})}const XG=Object.freeze(Object.defineProperty({__proto__:null,AgentErrorReply:Ox},Symbol.toStringTag,{value:"Module"}));function Rx({row:e,ideaTotal:n}){var o;const s=((o=e.evidenceIds)==null?void 0:o.length)??0,r=e.evidenceSessions??0,a=(i,c)=>`${i} ${c}${i===1?"":"s"}`;return t.jsxs("span",{className:"text-[11px] text-[var(--text-muted)]","data-testid":`feature-idea-evidence-${e.id}`,children:["Backed by ",a(s,"observation")," across"," ",a(r,"session"),e.ideaRank!==void 0&&n?t.jsxs("span",{className:"text-[var(--text-dim)]",children:[" ","· #",e.ideaRank," of ",n," feature ideas"]}):null]})}const QG=Object.freeze(Object.defineProperty({__proto__:null,FeatureIdeaEvidence:Rx},Symbol.toStringTag,{value:"Module"}));function Ex({id:e,note:n}){return n?t.jsx("p",{className:"text-[11px] text-[var(--text-dim)] mt-1","data-testid":`codeyam-improvement-decision-${e}`,children:n}):null}const ZG=Object.freeze(Object.defineProperty({__proto__:null,CodeyamImprovementDecisionNote:Ex},Symbol.toStringTag,{value:"Module"}));function Ax({spaced:e,children:n}){return t.jsxs("div",{className:e?"mt-3":void 0,"data-testid":"codeyam-improvements-decided",children:[t.jsx("p",{className:"text-[10px] uppercase tracking-wider mb-1 text-[var(--text-dim)]",children:"Already sent or dismissed"}),t.jsx("p",{className:"text-xs text-[var(--text-muted)] leading-relaxed mb-2",children:"These kept happening after you sent or dismissed them. Copy sends an updated report with the new count."}),t.jsx("ul",{className:"flex flex-col gap-2",children:n})]})}const eV=Object.freeze(Object.defineProperty({__proto__:null,DecidedCodeyamImprovements:Ax},Symbol.toStringTag,{value:"Module"}));function Mx({count:e}){return e<=0?null:t.jsxs("div",{className:"text-[10px] leading-snug text-[var(--text-muted)]","data-testid":"generated-glue-count",children:[e," generated isolation ",e===1?"file":"files"," changed — not product components, so not shown."]})}const tV=Object.freeze(Object.defineProperty({__proto__:null,GeneratedGlueNotice:Mx},Symbol.toStringTag,{value:"Module"}));function OM(e,n,s){if(n==="route-unwired"){const r=`scripts/gcp/vm-ingress.sh ${s??"<N>"} up`;return{headline:"This preview's host isn't routing the session handoff",explanation:"The editor tried to hand this preview a session, but the preview's host sends the handoff to the app instead of the editor. Nothing in the browser can fix that.",nextAction:`Whoever runs this deployment needs to route the handoff to the editor. On a CodeYam fleet VM, an operator runs ${r} (see docs/fleet-operations.md).`,command:r,offerReconnect:!1,feedback:null}}return{headline:"This preview has no editor session",explanation:e==="never-authenticated"?"The editor never handed this preview a session, so its live data can't load. No restart signed it out.":"The editor no longer recognizes this preview's session, so its live data can't load.",nextAction:"Ask the editor to reconnect this preview. Reloading the preview alone won't help — only the editor can hand it a session.",command:null,offerReconnect:!0,feedback:n==="failed"?"The editor couldn't reconnect this preview. Reload the editor tab itself (not the preview) and try again.":null}}function Ix({reason:e,reconnect:n,vmNumber:s,onReconnect:r}){const a=OM(e,n,s),o=a.command?t.jsxs(t.Fragment,{children:[a.nextAction.slice(0,a.nextAction.indexOf(a.command)),t.jsx("code",{children:a.command}),a.nextAction.slice(a.nextAction.indexOf(a.command)+a.command.length)]}):a.nextAction;return t.jsx(Lt,{severity:"warning",testId:"session-lost-notice",headline:a.headline,explanation:a.explanation,nextAction:o,nextActionText:a.nextAction,actions:a.offerReconnect?[{label:"Ask the editor to reconnect this preview",onClick:()=>r==null?void 0:r(),testId:"session-lost-reconnect",pending:n==="pending",pendingLabel:"Asking the editor…"}]:void 0,actionFeedback:a.feedback})}const nV=Object.freeze(Object.defineProperty({__proto__:null,SessionLostFramedNotice:Ix},Symbol.toStringTag,{value:"Module"})),RM={feature:"Feature",fix:"Fix",debt:"Tech debt"};function Dx({id:e,category:n}){return n===void 0?null:t.jsx("span",{className:"inline-block self-start px-1.5 py-px rounded border text-[10px] font-semibold uppercase tracking-wide border-[var(--border-default)] text-[var(--text-secondary)]","data-testid":`proposed-plan-category-${e}`,"data-category":n,children:RM[n]})}const sV=Object.freeze(Object.defineProperty({__proto__:null,ProposalCategoryTag:Dx},Symbol.toStringTag,{value:"Module"})),Fn="text-[10px] uppercase tracking-wide px-2 py-0.5 rounded border cursor-pointer disabled:opacity-60 disabled:cursor-not-allowed transition",Lx=" border-[var(--accent-primary)] text-[var(--accent-primary)] hover:bg-[var(--accent-primary)] hover:text-[var(--surface-bg)]",Ha=" border-[var(--border-default)] text-[var(--text-muted)] hover:text-[var(--text-primary)]",Fx=" border-[var(--accent-danger,#f87171)] text-[var(--accent-danger,#f87171)] hover:bg-[var(--accent-danger,#f87171)] hover:text-[var(--surface-bg)]";function $x({id:e,copied:n,confirming:s,busyAction:r,hasReport:a,copyFailed:o,canIgnore:i=!0,onCopy:c,onRequestIgnore:d,onConfirmIgnore:u,onCancelIgnore:p}){if(n)return t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-[var(--accent-success,#4ade80)]","data-testid":`codeyam-improvement-copied-${e}`,children:"Copied — thanks!"});if(r==="ignore")return t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-[var(--text-muted)]",children:"Discarding…"});if(s)return t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:"Discard?"}),t.jsx("button",{type:"button",className:Fn+Fx,onClick:u,"data-testid":`codeyam-improvement-confirm-ignore-${e}`,children:"Discard"}),t.jsx("button",{type:"button",className:Fn+Ha,onClick:p,"data-testid":`codeyam-improvement-keep-${e}`,children:"Keep"})]});const h=r!==void 0;return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:Fn+Lx,disabled:h||!a,onClick:c,"data-testid":`codeyam-improvement-copy-${e}`,children:o?"Copy blocked":"Copy"}),i&&t.jsx("button",{type:"button",className:Fn+Ha,disabled:h,onClick:d,"data-testid":`codeyam-improvement-ignore-${e}`,children:"Ignore"})]})}const rV=Object.freeze(Object.defineProperty({__proto__:null,CodeyamImprovementRowActions:$x},Symbol.toStringTag,{value:"Module"}));function dl(e){return!!e.decidedAt&&(e.status==="copied"||e.status==="ignored")}function EM(e){const n=e.status==="copied"?"Copied":e.status==="ignored"?"Ignored":null;if(!n)return null;const s=e.decidedAt?AM(e.decidedAt):null,r=s?`${n} ${s}`:n,a=e.sightingsAtDecision===void 0?0:Math.max(0,(e.sightings??0)-e.sightingsAtDecision);return a===0?r:`${r} · seen ${a} more ${a===1?"time":"times"} since`}function AM(e){const n=new Date(e);return Number.isNaN(n.getTime())?null:n.toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:"UTC"})}function hd(e){return(e??0)>=2}function zx({id:e,sightings:n}){return hd(n)?t.jsxs("span",{className:"text-[11px] text-[var(--text-dim)]","data-testid":`codeyam-improvement-sightings-${e}`,children:["Seen in ",n," sessions"]}):null}const aV=Object.freeze(Object.defineProperty({__proto__:null,CodeyamImprovementSightings:zx,isRecurringImprovement:hd},Symbol.toStringTag,{value:"Module"}));function Bx(e){if(e.category)return e.category;if(e.kind==="feature")return"feature";if(e.kind==="tech-debt")return"debt"}function MM(e){return e>=4?"high":e===3?"medium":"low"}const IM={low:"Low Severity",medium:"Medium Severity",high:"High Severity"},DM={low:"Low Value",medium:"Medium Value",high:"High Value"};function LM(e){return e.source==="deferred-deliverable"||e.source==="feature-synthesis"||Bx(e)==="feature"?"value":"severity"}const FM={low:"var(--accent-yellow)",medium:"var(--accent-orange)",high:"var(--accent-red)"},$M={low:"color-mix(in srgb, var(--accent-green) 50%, white)",medium:"var(--accent-green)",high:"color-mix(in srgb, var(--accent-green) 70%, black)"};function fd({id:e,severity:n,kind:s="severity"}){if(n===void 0)return null;const r=MM(n),a=s==="value";return t.jsx("span",{className:"inline-block self-start px-1.5 py-px rounded text-[10px] font-semibold uppercase tracking-wide",style:{background:(a?$M:FM)[r],color:"var(--text-on-accent)"},"data-testid":`proposed-plan-severity-${e}`,"data-severity":n,"data-severity-tier":r,"data-grade-kind":s,children:(a?DM:IM)[r]})}const oV=Object.freeze(Object.defineProperty({__proto__:null,ProposedPlanSeverityBadge:fd},Symbol.toStringTag,{value:"Module"}));function Wx({row:e,report:n,busyAction:s,confirming:r,error:a,onCopied:o,onRequestIgnore:i,onConfirmIgnore:c,onCancelIgnore:d,writer:u}){const{failed:p,copy:h}=fo({writer:u}),f=hd(e.sightings),m=dl(e),g=m?EM(e):null,[x,b]=l.useState(!1),y=m?x:e.status==="copied";return t.jsxs("li",{className:"p-2.5 rounded-md flex flex-col gap-1.5",style:{background:"var(--bg-deep)",border:"1px solid var(--border-subtle)"},"data-testid":`codeyam-improvement-${e.id}`,"data-status":e.status??"pending",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm text-[var(--text-primary)] leading-snug",children:e.title}),e.reason&&t.jsx("p",{className:"text-xs text-[var(--text-muted)] leading-relaxed mt-0.5",children:e.reason}),(e.severity!==void 0||f)&&t.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[e.severity!==void 0&&t.jsx(fd,{id:e.id,severity:e.severity,kind:"severity"}),t.jsx(zx,{id:e.id,sightings:e.sightings})]}),t.jsx(Ex,{id:e.id,note:g})]}),!(m&&e.status==="ignored")&&t.jsx("div",{className:"shrink-0 flex items-center gap-1.5 pt-0.5",children:t.jsx($x,{id:e.id,copied:y,confirming:r,busyAction:s,hasReport:!!n,copyFailed:p,canIgnore:!m,onCopy:()=>{n&&h(n).then(v=>{v&&(m&&b(!0),o())})},onRequestIgnore:i,onConfirmIgnore:c,onCancelIgnore:d})})]}),r&&t.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:"It won't be offered again."}),t.jsx(tt,{text:a,copyText:a,testId:`codeyam-improvement-error-${e.id}`})]})}const iV=Object.freeze(Object.defineProperty({__proto__:null,CodeyamImprovementRow:Wx},Symbol.toStringTag,{value:"Module"}));function Hx({count:e,expanded:n,onToggle:s,children:r,decided:a=null}){const o=e>0?`View all CodeYam improvements (${e})`:"View CodeYam improvements already sent or dismissed";return t.jsxs("div",{className:"mt-2",children:[t.jsx("button",{type:"button",className:"text-xs text-[var(--text-muted)] hover:text-[var(--text-primary)] underline underline-offset-2","aria-expanded":n,"data-testid":"codeyam-improvements-view-all",onClick:s,children:n?"Hide CodeYam improvements":o}),n&&t.jsxs("div",{className:"mt-2","data-testid":"codeyam-improvements-tracked",children:[e>0&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-xs text-[var(--text-muted)] leading-relaxed mb-2",children:"These are rough edges CodeYam has hit in earlier sessions too. Copy any you'd like to send."}),t.jsx("ul",{className:"flex flex-col gap-2",children:r})]}),a&&t.jsx(Ax,{spaced:e>0,children:a})]})]})}const lV=Object.freeze(Object.defineProperty({__proto__:null,TrackedCodeyamImprovements:Hx},Symbol.toStringTag,{value:"Module"})),zM={margin:"10px 12px 0",padding:"8px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,.14)",background:"rgba(255,255,255,.04)",color:"var(--text-secondary)",fontSize:12.5,lineHeight:1.45,display:"flex",gap:8,alignItems:"flex-start"},BM={background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",padding:0,fontSize:14,lineHeight:1};function ul({children:e,onDismiss:n,testId:s,role:r}){return t.jsxs("div",{role:r,"data-testid":s,style:zM,children:[t.jsx("span",{style:{flex:1},children:e}),t.jsx("button",{type:"button","aria-label":"Dismiss",onClick:n,style:BM,children:"×"})]})}const cV=Object.freeze(Object.defineProperty({__proto__:null,AgentChatNotice:ul},Symbol.toStringTag,{value:"Module"}));function $r({width:e,height:n,scale:s,filled:r=!1,className:a,children:o}){const i=s<1?s:1;return t.jsx("div",{"data-scaled-viewport":"outer",className:r?"w-full h-full":void 0,style:r?void 0:{width:e*i,height:n*i,flexShrink:0,position:"relative"},children:t.jsx("div",{"data-scaled-viewport":"inner",className:r?"w-full h-full":a,style:r?void 0:{width:e,height:n,transform:i<1?`scale(${i})`:void 0,transformOrigin:"top left"},children:o})})}const dV=Object.freeze(Object.defineProperty({__proto__:null,ScaledViewport:$r},Symbol.toStringTag,{value:"Module"})),$h="Next valid action: ";function WM(e){const n=e.split(`
|
|
26
|
+
`).map(r=>r.trim()).find(r=>r.startsWith($h)),s=n==null?void 0:n.slice($h.length).trim();return s||null}function md({failure:e}){const n=WM(e),s=n?`To clear it, run: ${n}`:"Copy this report and hand it to the operator; the details below name the queue entry to release.";return t.jsx(Lt,{severity:"warning",testId:"proposed-plans-head-release-warning",className:"mt-2 flex flex-col gap-2 rounded border border-l-4 px-3 py-2 text-xs",headline:"Commit-queue slot still held",explanation:"The plan was written and pushed, but this machine could not give up its place at the front of the commit queue. Other machines wait behind it until it is cleared.",nextAction:n?t.jsxs(t.Fragment,{children:["To clear it, run ",t.jsx("code",{className:"font-mono",children:n})]}):s,nextActionText:s,diagnostics:e})}const uV=Object.freeze(Object.defineProperty({__proto__:null,HeadReleaseWarning:md},Symbol.toStringTag,{value:"Module"})),HM={keep:"Keep",iterate:"Iterate",versions:"Multiple versions",replace:"Replace"},qM={keep:"Carry it into the next round unchanged",iterate:"Refine it in place, applying its notes",versions:"Make several variations of it",replace:"Redesign this slot from scratch"},zh=e=>({padding:"3px 9px",borderRadius:999,border:`1px solid ${e?"var(--accent-active, #D7FF63)":"rgba(255,255,255,.14)"}`,background:e?"rgba(215,255,99,.14)":"transparent",color:e?"var(--text-primary)":"var(--text-secondary)",fontSize:12,cursor:"pointer"});function qx({row:e,onChoose:n,disabled:s=!1}){const{decision:r}=e;return t.jsxs("div",{"data-testid":"design-decision-row",style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6,minWidth:0},children:[t.jsx("span",{style:{color:"rgba(255,255,255,.45)",fontVariantNumeric:"tabular-nums"},children:String(e.number).padStart(2,"0")}),t.jsx("span",{style:{color:"var(--text-primary)",overflowWrap:"anywhere"},children:e.name}),e.suggested&&t.jsx("span",{"data-testid":"design-decision-suggested",style:{fontSize:10.5,color:"var(--accent-active, #D7FF63)",whiteSpace:"nowrap"},children:"suggested"})]}),t.jsx("div",{role:"group","aria-label":`What to do with ${e.name}`,style:{display:"flex",flexWrap:"wrap",gap:5},children:Vg.map(a=>t.jsx("button",{type:"button","aria-pressed":r.verb===a,title:qM[a],disabled:s,onClick:()=>n(a),style:zh(r.verb===a),children:HM[a]},a))}),r.verb==="versions"&&t.jsxs("div",{role:"group","aria-label":`How many versions of ${e.name}`,style:{display:"flex",alignItems:"center",gap:5,fontSize:12},children:["How many?",Kg.map(a=>t.jsx("button",{type:"button","aria-pressed":r.count===a,disabled:s,onClick:()=>n("versions",a),style:{...zh(r.count===a),minWidth:28},children:a},a))]})]})}const pV=Object.freeze(Object.defineProperty({__proto__:null,DesignDecisionRow:qx},Symbol.toStringTag,{value:"Module"}));function gd({href:e=typeof window<"u"?window.location.href:""}){return t.jsx("div",{"data-testid":"embedded-terminal-notice",className:"w-full h-full flex items-center justify-center text-center px-6",style:{background:"var(--bg-deep)",color:"var(--text-dim)"},children:t.jsxs("div",{className:"text-sm leading-relaxed",children:[t.jsx("div",{className:"font-medium",children:"The agent terminal is off inside an embedded preview"}),t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"inline-block mt-2 underline",style:{color:"var(--text-primary)"},children:"Open in a new tab"})]})})}const hV=Object.freeze(Object.defineProperty({__proto__:null,EmbeddedTerminalNotice:gd},Symbol.toStringTag,{value:"Module"})),UM={spawned:"Started the agent's terminal",reattached:"Reconnected to an agent that was already running","prompt-written":"Typed the startup command","banner-ready":"The agent showed it was ready","prompt-accepted":"The agent accepted its prompt","prompt-rejected":"The agent rejected its prompt","startup-failed":"The agent failed to start","worker-ack":"The agent confirmed it is working"},Bh={"inject-initial":"The editor typed /codeyam-editor","inject-retry":"The editor typed /codeyam-editor again","ui-escape":"The Build tab pressed Esc","ui-clear":"The Build tab typed /clear","ui-skill":"The Build tab typed /codeyam-editor"};function YM(e){if(e.event==="prompt-written"&&e.kind&&Bh[e.kind])return Bh[e.kind];const n=UM[e.event]??e.event,s=e.reason??e.kind;return s?`${n} (${s})`:n}function Ux({events:e}){return t.jsx("ol",{"data-testid":"build-launch-log",className:"mt-2 space-y-1 rounded border border-[var(--border)] p-3 text-xs text-[var(--text-dim)]",children:e.length===0?t.jsx("li",{children:"Nothing was recorded for this launch."}):e.map((n,s)=>t.jsxs("li",{children:[t.jsx("span",{className:"font-mono text-[var(--text-muted)]",children:new Date(n.ts).toLocaleTimeString()})," ",YM(n)]},`${n.ts}-${s}`))})}const fV=Object.freeze(Object.defineProperty({__proto__:null,BuildLaunchLog:Ux},Symbol.toStringTag,{value:"Module"}));function Yx(){return t.jsxs("div",{className:"rounded border border-dashed border-[var(--border-default)] bg-[var(--bg-card)] px-3 py-2 text-xs text-[var(--text-secondary)] leading-relaxed",children:[t.jsx("span",{className:"font-semibold text-[var(--text-primary)]",children:"Nothing on this page is linked to content yet."})," ","Its template has no content markers, so its text can't be edited by clicking it — use the side panel instead. To make it editable here, add the ",t.jsx("code",{className:"font-mono",children:"data-cms-entry"})," and"," ",t.jsx("code",{className:"font-mono",children:"data-cms-field"})," attributes from the “Content markers” table in @codeyam/cms's CMS_SETUP.md."]})}const mV=Object.freeze(Object.defineProperty({__proto__:null,SiteContentNoMarkersHint:Yx},Symbol.toStringTag,{value:"Module"}));function GM(e){const n={};for(const s of e.collections??[])n[s.id]=Object.fromEntries(s.fields.map(r=>[r.name,{label:r.label,type:r.type}]));return n}function Wh(e,n){if(e){const s=e.indexOf("/");if(s>0&&s<e.length-1)return{collection:e.slice(0,s),slug:e.slice(s+1)}}return n}function Si(e,n){return!!e&&!!n&&e.collection===n.collection&&e.slug===n.slug}function VM(e,n){return e==="list"?n.split(",").map(s=>s.trim()).filter(Boolean):n}const KM=new Set(["text","textarea"]);function JM(e){return e.kind==="body"?"body":e.kind==="html"?"field":e.kind!=="field"?null:e.type&&!KM.has(e.type)?"field":null}function XM(e,n,s,r){return n==="body"?{...e,body:String(r)}:{...e,fields:{...e.fields,[s]:r}}}function QM(e){return e===1?"1 editable region":`${e} editable regions`}function Hh(e,n){return{x:e.x*n,y:e.y*n,width:e.width*n,height:e.height*n}}function Gx({on:e,onChange:n}){return t.jsxs("button",{type:"button",role:"switch","aria-checked":e,onClick:()=>n==null?void 0:n(!e),className:`flex items-center gap-1.5 px-2.5 py-0.5 rounded-full border ${e?"border-[var(--accent-primary)] text-[var(--accent-primary)] bg-[var(--lime-soft)]":"border-[var(--border-default)] text-[var(--text-secondary)]"}`,children:[t.jsx("span",{"aria-hidden":!0,className:`relative inline-block w-5 h-3 rounded-full ${e?"bg-[var(--accent-primary)]":"bg-[var(--border-default)]"}`,children:t.jsx("span",{className:"absolute top-0.5 w-2 h-2 rounded-full bg-[var(--bg-deep)]",style:{left:e?10:2}})}),"Edit on page"]})}const gV=Object.freeze(Object.defineProperty({__proto__:null,SiteContentEditSwitch:Gx},Symbol.toStringTag,{value:"Module"}));function Vx({address:e,editOnPage:n,regionCount:s,screenSizes:r,screenSize:a,onEditOnPageChange:o,onScreenSizeChange:i}){return t.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-dim)]",children:[t.jsx("span",{className:"flex-1 truncate font-mono",children:e}),n!==void 0?t.jsx(Gx,{on:n,onChange:o}):null,n&&s!==null?t.jsx("span",{className:"px-2.5 py-0.5 rounded-full border border-[var(--border-default)] text-[var(--text-secondary)]",children:QM(s)}):null,t.jsx("select",{value:a,"aria-label":"Screen size",onChange:c=>i==null?void 0:i(c.target.value),className:"text-xs px-1.5 py-0.5 rounded bg-[var(--bg-input)] border border-[var(--border-subtle)] text-[var(--text-secondary)]",children:r.map(c=>t.jsx("option",{value:c.name,children:c.name},c.name))})]})}const xV=Object.freeze(Object.defineProperty({__proto__:null,SiteContentPreviewHeader:Vx},Symbol.toStringTag,{value:"Module"}));function ZM({anchor:e,paneWidth:n,paneHeight:s,width:r,estimatedHeight:a}){const o=Math.min(r,Math.max(260,n-16)),i=Math.max(8,Math.min(e.x,n-o-8)),c=e.y+e.height+10,d=e.y-10-a,u=c+a<=s?c:d>=0?d:Math.max(8,Math.min(e.y,s-a-8));return{left:i,top:u,width:o}}function Kx({saving:e=!1,onSave:n,onCancel:s}){return t.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-t border-[var(--border-subtle)]",children:[t.jsx("span",{className:"text-xs text-[var(--text-dim)]",children:"Esc to cancel · ⌘S to save"}),t.jsxs("span",{className:"flex gap-2",children:[t.jsx("button",{type:"button",onClick:s,className:"text-xs px-2.5 py-1 rounded text-[var(--text-secondary)] hover:bg-[var(--bg-card)]",children:"Cancel"}),t.jsx("button",{type:"button",disabled:e,onClick:n,className:"text-xs px-3 py-1 rounded font-semibold bg-[var(--accent-primary)] text-[var(--text-on-accent)] disabled:opacity-60",children:e?"Saving…":"Save"})]})]})}const bV=Object.freeze(Object.defineProperty({__proto__:null,SiteContentPopoverFooter:Kx},Symbol.toStringTag,{value:"Module"}));function xd({anchor:e,paneWidth:n,paneHeight:s,width:r=460,estimatedHeight:a=200,title:o,meta:i,saving:c=!1,error:d,onSave:u,onCancel:p,children:h}){const f=ZM({anchor:e,paneWidth:n,paneHeight:s,width:r,estimatedHeight:a});return t.jsxs("div",{role:"dialog","aria-label":`Edit ${o}`,className:"absolute z-10 rounded-lg border border-[var(--border-default)] bg-[var(--bg-surface)] shadow-2xl",style:f,onKeyDown:m=>{m.key==="Escape"?(m.preventDefault(),p()):(m.metaKey||m.ctrlKey)&&m.key.toLowerCase()==="s"&&(m.preventDefault(),u())},children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-3 px-3 py-2 border-b border-[var(--border-subtle)]",children:[t.jsx("span",{className:"text-sm font-semibold text-[var(--text-primary)]",children:o}),i?t.jsx("span",{className:"text-xs font-mono text-[var(--text-dim)] truncate",children:i}):null]}),t.jsx("div",{className:"p-3",children:h}),t.jsx(tt,{text:d,rowClassName:"px-3 pb-2"}),t.jsx(Kx,{saving:c,onSave:u,onCancel:p})]})}const yV=Object.freeze(Object.defineProperty({__proto__:null,SiteContentAnchoredPopover:xd},Symbol.toStringTag,{value:"Module"})),Kt="w-full text-sm px-2 py-1.5 rounded bg-[var(--bg-input)] border border-[var(--border-subtle)] text-[var(--text-primary)]";function bd({def:e,value:n,onChange:s}){const r=Array.isArray(n)?n.join(", "):n??"",a=`sc-field-${e.name}`;switch(e.type){case"textarea":case"html":return t.jsx("textarea",{id:a,value:r,rows:e.type==="html"?5:3,onChange:o=>s(o.target.value),className:`${Kt} ${e.type==="html"?"font-mono text-xs":""}`});case"date":return t.jsx("input",{id:a,type:"date",value:r.slice(0,10),onChange:o=>s(o.target.value),className:Kt});case"list":return t.jsx("input",{id:a,value:r,placeholder:"Comma-separated",onChange:o=>s(o.target.value.split(",").map(i=>i.trim()).filter(Boolean)),className:Kt});case"image":return t.jsx("input",{id:a,value:r,placeholder:"/images/…",onChange:o=>s(o.target.value),className:`${Kt} font-mono text-xs`});default:return t.jsx("input",{id:a,value:r,onChange:o=>s(o.target.value),className:Kt})}}const vV=Object.freeze(Object.defineProperty({__proto__:null,SiteContentFieldInput:bd,siteContentInputClass:Kt},Symbol.toStringTag,{value:"Module"}));function Jx({anchor:e,paneWidth:n,paneHeight:s,def:r,entryLabel:a,initialValue:o,saving:i,error:c,onSave:d,onCancel:u}){const[p,h]=l.useState(o);return t.jsx(xd,{anchor:e,paneWidth:n,paneHeight:s,width:r.type==="html"?480:320,estimatedHeight:r.type==="html"?260:150,title:r.label??r.name,meta:[r.type??"text",a].filter(Boolean).join(" · "),saving:i,error:c,onSave:()=>d(p??""),onCancel:u,children:t.jsx(bd,{def:r,value:p,onChange:h})})}const jV=Object.freeze(Object.defineProperty({__proto__:null,SiteContentFieldPopover:Jx},Symbol.toStringTag,{value:"Module"}));function eI(e,n){const s=new Set(e.map(a=>a.name)),r=Object.keys(n.fields).filter(a=>!s.has(a)).map(a=>({name:a,type:"text"}));return[...e,...r]}function tI(e,n,s,r,a){return e.slice(0,n)+r+e.slice(n,s)+a+e.slice(s)}function nI({saveStatus:e,saveError:n,dirty:s,modified:r}){return e==="saving"?"Saving…":e==="error"?n??"Save failed":s?"Unsaved changes":e==="saved"?"Saved · refreshing preview":r?"Saved · not committed yet":"No changes"}const sI=[{label:"B",title:"Bold",before:"**",after:"**"},{label:"I",title:"Italic",before:"_",after:"_"},{label:"H2",title:"Heading",before:`
|
|
27
|
+
## `,after:""},{label:"•",title:"List item",before:`
|
|
28
|
+
- `,after:""},{label:"Link",title:"Link",before:"[",after:"](https://)"}];function yd({body:e,label:n="Body",onChange:s}){const r=l.useRef(null);return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[t.jsx("span",{className:"flex-1 text-xs font-medium text-[var(--text-secondary)]",children:n}),sI.map(a=>t.jsx("button",{type:"button",title:a.title,onClick:()=>{const o=r.current;o&&(s==null||s(tI(e,o.selectionStart,o.selectionEnd,a.before,a.after)))},className:"text-xs px-1.5 py-0.5 rounded text-[var(--text-secondary)] hover:bg-[var(--bg-card)]",children:a.label},a.title))]}),t.jsx("textarea",{ref:r,value:e,rows:12,"aria-label":"Body",onChange:a=>s==null?void 0:s(a.target.value),className:`${Kt} font-mono text-xs leading-relaxed`})]})}const wV=Object.freeze(Object.defineProperty({__proto__:null,SiteContentBodyEditor:yd},Symbol.toStringTag,{value:"Module"}));function Xx({anchor:e,paneWidth:n,paneHeight:s,file:r,initialBody:a,saving:o,error:i,onSave:c,onCancel:d}){const[u,p]=l.useState(a);return t.jsx(xd,{anchor:e,paneWidth:n,paneHeight:s,width:520,estimatedHeight:380,title:"Body",meta:r?`markdown · ${r}`:"markdown",saving:o,error:i,onSave:()=>c(u),onCancel:d,children:t.jsx(yd,{body:u,label:null,onChange:p})})}const _V=Object.freeze(Object.defineProperty({__proto__:null,SiteContentBodyPopover:Xx},Symbol.toStringTag,{value:"Module"})),vd="rounded ring-2 ring-[var(--accent-primary)] ring-offset-2 ring-offset-[var(--bg-deep)]";function Qx({inputId:e,label:n,required:s=!1,editingInPreview:r=!1,children:a}){return t.jsxs("div",{className:r?vd:void 0,children:[t.jsxs("label",{htmlFor:e,className:"flex text-xs font-medium text-[var(--text-secondary)] mb-1",children:[t.jsxs("span",{className:"flex-1",children:[n,s?t.jsx("span",{className:"text-[var(--accent-red)]",children:" *"}):null]}),r?t.jsx("span",{className:"text-[var(--accent-primary)]",children:"● editing in preview"}):null]}),a]})}const SV=Object.freeze(Object.defineProperty({__proto__:null,EDITING_IN_PREVIEW_RING:vd,SiteContentFieldRow:Qx},Symbol.toStringTag,{value:"Module"})),rI={reconnecting:{testId:"build-tab-reconnecting",headline:"Reconnecting to your running build…",explanation:"Your build kept running while this page was away. You’ll be back in the same session in a moment — nothing is restarted or sent again."},starting:{testId:"build-tab-starting",headline:"Starting your build…",explanation:"The agent is starting for your build request. It keeps going even if you close this tab."},interrupted:{testId:"build-tab-interrupted",headline:"Your build was interrupted",explanation:"A build was started for this project, but it is no longer running. Resume it or start again from here."}};function Zx({phase:e}){const n=rI[e];return t.jsxs("div",{"data-testid":n.testId,className:"flex flex-col items-center justify-center h-full text-slate-500 space-y-4 px-10 text-center",children:[t.jsx("div",{className:"text-lg font-medium text-slate-400",children:n.headline}),t.jsx("p",{className:"max-w-md",children:n.explanation})]})}const kV=Object.freeze(Object.defineProperty({__proto__:null,BuildTabConnectionPhasePanel:Zx},Symbol.toStringTag,{value:"Module"}));function eb(){return t.jsxs("div",{role:"note",className:"text-xs px-3 py-2 rounded border border-[var(--border-subtle)] bg-[var(--bg-card)] text-[var(--text-secondary)]",children:["Page addresses are guessed and every field is shown as plain text, because this site's ",t.jsx("code",{children:"@codeyam/cms"})," does not describe its content yet. Upgrading ",t.jsx("code",{children:"@codeyam/cms"})," to a version with the content manifest fixes both."]})}const NV=Object.freeze(Object.defineProperty({__proto__:null,SiteContentInferredNotice:eb},Symbol.toStringTag,{value:"Module"}));function tb({onKeepEditing:e,onDiscard:n}){return t.jsxs("div",{role:"alertdialog","aria-label":"Unsaved changes",className:"absolute inset-x-0 top-0 p-4 rounded border border-[var(--border-default)] bg-[var(--bg-surface)] shadow-lg z-10",children:[t.jsx("div",{className:"text-sm font-medium text-[var(--text-primary)] mb-1",children:"You have unsaved changes"}),t.jsx("div",{className:"text-xs text-[var(--text-secondary)] mb-3",children:"Leaving this page now throws away the edits you have not saved."}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{type:"button",onClick:e,className:"text-xs font-medium px-2.5 py-1 rounded bg-[var(--accent-primary)] text-[var(--text-on-accent)]",children:"Keep editing"}),t.jsx("button",{type:"button",onClick:n,className:"text-xs px-2.5 py-1 rounded text-[var(--accent-red)] hover:bg-[var(--bg-card)]",children:"Discard changes"})]})]})}const CV=Object.freeze(Object.defineProperty({__proto__:null,SiteContentUnsavedDialog:tb},Symbol.toStringTag,{value:"Module"}));function nb({building:e,title:n,reason:s}){return t.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-6 text-center",children:t.jsxs("div",{className:"max-w-sm text-sm text-[var(--text-secondary)]",children:[t.jsx("div",{className:"font-medium text-[var(--text-primary)] mb-1",children:e?"Building your new page…":n}),e?"The site is restarting so it can serve the new page. This usually takes a few seconds.":s??"The site shows it inside other pages rather than at its own address."]})})}const TV=Object.freeze(Object.defineProperty({__proto__:null,SiteContentPreviewEmpty:nb},Symbol.toStringTag,{value:"Module"}));function sb({saveStatus:e,saveError:n,dirty:s,modified:r}){const a=nI({saveStatus:e,saveError:n,dirty:s,modified:r});return t.jsxs("div",{className:"flex items-center gap-3 pt-2 border-t border-[var(--border-subtle)]",children:[e==="error"?t.jsx(tt,{text:a,rowClassName:"flex-1"}):t.jsx("span",{role:"status",className:`flex-1 text-xs ${s?"text-[var(--accent-orange)]":"text-[var(--text-dim)]"}`,children:a}),t.jsx("button",{type:"submit",disabled:!s||e==="saving",className:"text-sm font-medium px-3 py-1.5 rounded bg-[var(--accent-primary)] text-[var(--text-on-accent)] disabled:opacity-40",children:"Save"})]})}const PV=Object.freeze(Object.defineProperty({__proto__:null,SiteContentSaveBar:sb},Symbol.toStringTag,{value:"Module"}));function rb({title:e,file:n,fields:s,draft:r,dirty:a,modified:o,saveStatus:i="idle",saveError:c,editingInPreview:d=null,onChange:u,onSave:p}){const h=(f,m)=>u==null?void 0:u({...r,fields:{...r.fields,[f]:m}});return t.jsxs("form",{className:"flex flex-col gap-3 min-h-0",onSubmit:f=>{f.preventDefault(),p==null||p()},onKeyDown:f=>{(f.metaKey||f.ctrlKey)&&f.key.toLowerCase()==="s"&&(f.preventDefault(),p==null||p())},children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold text-[var(--text-primary)] truncate",children:e}),t.jsx("div",{className:"text-xs font-mono text-[var(--text-dim)] truncate",children:n})]}),t.jsxs("div",{className:"flex flex-col gap-2.5 overflow-y-auto pr-1",children:[eI(s,r).map(f=>t.jsx(Qx,{inputId:`sc-field-${f.name}`,label:f.label??f.name,required:f.required,editingInPreview:d===f.name,children:t.jsx(bd,{def:f,value:r.fields[f.name],onChange:m=>h(f.name,m)})},f.name)),t.jsx("div",{className:d==="body"?vd:void 0,children:t.jsx(yd,{body:r.body,onChange:f=>u==null?void 0:u({...r,body:f})})})]}),t.jsx(sb,{saveStatus:i,saveError:c,dirty:a,modified:o})]})}const OV=Object.freeze(Object.defineProperty({__proto__:null,SiteContentEntryEditor:rb},Symbol.toStringTag,{value:"Module"}));function ab({entry:e,active:n,onSelect:s}){return t.jsxs("button",{type:"button","aria-current":n?"true":void 0,onClick:()=>s==null?void 0:s(e.slug),className:`w-full text-left px-2 py-1.5 rounded transition ${n?"bg-[var(--bg-card)]":"hover:bg-[var(--bg-card)]"}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"flex-1 truncate text-sm text-[var(--text-primary)]",children:e.title}),e.modified?t.jsx("span",{title:"Uncommitted changes","aria-label":"modified",className:"w-1.5 h-1.5 rounded-full bg-[var(--accent-orange)]"}):null]}),t.jsxs("div",{className:"text-xs text-[var(--text-dim)] truncate",children:[e.date?`${e.date.slice(0,10)} · `:"",e.slug]})]})}const RV=Object.freeze(Object.defineProperty({__proto__:null,SiteContentEntryRow:ab},Symbol.toStringTag,{value:"Module"}));function ob({collection:e,active:n,onSelect:s}){const r=e.entries.some(a=>a.modified);return t.jsxs("button",{type:"button","aria-current":n?"true":void 0,onClick:()=>s==null?void 0:s(e.id),className:`w-full flex items-center gap-2 px-2 py-1.5 rounded text-sm text-left transition ${n?"bg-[var(--bg-card)] text-[var(--text-primary)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-card)]"}`,children:[t.jsx("span",{className:"flex-1 truncate",children:e.label}),r?t.jsx("span",{title:"Has uncommitted changes",className:"w-1.5 h-1.5 rounded-full bg-[var(--accent-orange)]"}):null,e.kind!=="singleton"?t.jsx("span",{className:"text-xs tabular-nums text-[var(--text-dim)]",children:e.entries.length}):null]})}const EV=Object.freeze(Object.defineProperty({__proto__:null,SiteContentCollectionRow:ob},Symbol.toStringTag,{value:"Module"}));function aI(e,n,s){const r=n.trim().toLowerCase();return e.filter(a=>!r||a.title.toLowerCase().includes(r)||a.slug.toLowerCase().includes(r)).slice().sort((a,o)=>s==="title"?a.title.localeCompare(o.title):(o.date??"").localeCompare(a.date??""))}function oI(e){return[{heading:"Collections",items:e.filter(n=>n.kind!=="singleton")},{heading:"Site",items:e.filter(n=>n.kind==="singleton")}].filter(n=>n.items.length>0)}function ib({collections:e,selectedId:n,onSelect:s}){return t.jsx("nav",{"aria-label":"Content collections",className:"flex flex-col gap-4",children:oI(e).map(r=>t.jsxs("div",{children:[t.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-[var(--text-dim)] mb-1.5 px-2",children:r.heading}),t.jsx("ul",{className:"flex flex-col",children:r.items.map(a=>t.jsx("li",{children:t.jsx(ob,{collection:a,active:a.id===n,onSelect:s})},a.id))})]},r.heading))})}const AV=Object.freeze(Object.defineProperty({__proto__:null,SiteContentCollectionList:ib},Symbol.toStringTag,{value:"Module"}));function lb({testId:e}){return t.jsx("div",{"data-testid":e,className:"px-3 py-2 text-sm text-gray-400",children:"Getting the design agent ready…"})}const MV=Object.freeze(Object.defineProperty({__proto__:null,DesignAgentPreparing:lb},Symbol.toStringTag,{value:"Module"}));function cb({requestedAt:e}){const n=e?new Date(e):null;return!n||Number.isNaN(n.getTime())?null:t.jsxs("p",{className:"mt-2 text-xs text-[var(--text-muted)]",children:["Build request saved ",n.toLocaleString(),"."]})}const IV=Object.freeze(Object.defineProperty({__proto__:null,BuildRequestSavedNote:cb},Symbol.toStringTag,{value:"Module"}));function iI(e,n){const s=[...e.stateHistory].reverse().find(a=>a.state==="dispatching");if(!s)return null;const r=Date.parse(s.at);return Number.isNaN(r)?null:Math.max(0,Math.floor((n-r)/1e3))}function lI(e){const n=(a,o)=>`${a} ${o}${a===1?"":"s"}`;if(e<60)return n(e,"second");if(e>=3600){const a=Math.floor(e/3600),o=Math.floor(e%3600/60);return o===0?n(a,"hour"):`${n(a,"hour")} ${n(o,"minute")}`}const s=Math.floor(e/60),r=e%60;return r===0?n(s,"minute"):`${n(s,"minute")} ${n(r,"second")}`}function cI(e,n,s=null){const r=n==null?"a while":lI(n);return e&&s?{headline:"The editor can’t hear from the build agent",explanation:s,nextAction:"Open the build terminal to follow the agent’s work. Retrying will not fix this."}:e?{headline:"The build agent hasn’t started",explanation:`The agent was started ${r} ago but hasn’t accepted its first instruction. It may still be starting — if it does, your build picks up on its own.`,nextAction:"Retry the launch. If an agent is already running it is reused, so this never starts a second one."}:{headline:"The build agent is taking longer than usual",explanation:`The agent was started ${r} ago and hasn’t accepted its first instruction yet. Nothing has been stopped; it’s still starting.`,nextAction:"Keep waiting, or open the build terminal to see what the agent is doing."}}function jd(e){return e==="delayed"||e==="launch-timeout"}function wd({state:e,waitSeconds:n,onOpenTerminal:s,onRetry:r,retryPending:a=!1,retryMessage:o=null,onViewLog:i,launchLog:c=null,cause:d=null}){if(!jd(e))return null;const u=e==="launch-timeout",p=cI(u,n,d),h=[];return u&&r&&h.push({label:"Retry launch",onClick:r,pending:a,pendingLabel:"Retrying…",variant:"primary",testId:"build-launch-retry"}),s&&h.push({label:"Open the build terminal",onClick:s,variant:u?"secondary":"primary",testId:"build-launch-open-terminal"}),u&&i&&h.push({label:"View launch log",onClick:i,variant:"secondary",testId:"build-launch-view-log"}),t.jsx("div",{"data-testid":"build-launch-status-banner","data-state":e,children:t.jsx(Lt,{severity:u?"error":"warning",testId:"build-launch-status-notice",headline:p.headline,explanation:p.explanation,nextAction:p.nextAction,actions:h,actionFeedback:o||c?t.jsxs(t.Fragment,{children:[o?t.jsx("span",{"data-testid":"build-launch-retry-message",children:o}):null,c?t.jsx(Ux,{events:c}):null]}):null})})}const DV=Object.freeze(Object.defineProperty({__proto__:null,BuildLaunchStatusBanner:wd},Symbol.toStringTag,{value:"Module"}));function db({message:e,onRetry:n,retrying:s=!1}){return t.jsx("div",{style:{marginBottom:"var(--spacing-md, 12px)",textAlign:"left"},children:t.jsx(Lt,{severity:"error",testId:"questionnaire-submit-error",headline:"Your answers weren't saved, so the build hasn't started",explanation:"Everything you entered is still here.",nextAction:"Try again. If it keeps failing, copy this report and send it to whoever set up this editor.",diagnostics:e,actions:[{label:"Retry",onClick:n,pending:s,pendingLabel:"Retrying…",variant:"primary"}]})})}const LV=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireSubmitErrorBanner:db},Symbol.toStringTag,{value:"Module"})),qh="M1.2 0 L5 3 L8.8 0 L10 1.4 L5 5.4 L0 1.4 z",la=3,dI=1.6,uI=7,pI=9,hI=14.4;function ub({collapsed:e=!1}){const n=e?`translate(${la} ${uI}) scale(1 -1)`:`translate(${la} ${dI})`,s=e?`translate(${la} ${pI})`:`translate(${la} ${hI}) scale(1 -1)`;return t.jsxs("svg",{viewBox:"0 0 16 16",className:"w-[15px] h-[15px]",fill:"currentColor","aria-hidden":"true",children:[t.jsx("path",{d:qh,transform:n}),t.jsx("path",{d:qh,transform:s})]})}const FV=Object.freeze(Object.defineProperty({__proto__:null,CollapseAllIcon:ub},Symbol.toStringTag,{value:"Module"}));function pb(){const e="M2 2 h4.5 v1.6 h-2.9 v2.9 h-1.6 z";return t.jsx("svg",{viewBox:"0 0 16 16",className:"w-[15px] h-[15px]",fill:"currentColor","aria-hidden":"true",children:[0,90,180,270].map(n=>t.jsx("path",{d:e,transform:`rotate(${n} 8 8)`},n))})}const $V=Object.freeze(Object.defineProperty({__proto__:null,FullScreenIcon:pb},Symbol.toStringTag,{value:"Module"}));function pl({label:e,onClick:n,pressed:s,children:r}){return t.jsx("button",{type:"button",onClick:n,"aria-label":e,title:e,"aria-pressed":s,className:"flex h-8 w-8 items-center justify-center rounded-lg transition text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:bg-white/[0.08]",children:r})}const zV=Object.freeze(Object.defineProperty({__proto__:null,ToolbarIconButton:pl},Symbol.toStringTag,{value:"Module"}));function hb({onOpenGallery:e,allCollapsed:n=!1,onToggleAll:s}){return!s&&!e?null:t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s?t.jsx(pl,{label:n?"Open all sections":"Close all sections",onClick:s,pressed:n,children:t.jsx(ub,{collapsed:n})}):null,e?t.jsx(pl,{label:"Full screen",onClick:e,children:t.jsx(pb,{})}):null]})}const BV=Object.freeze(Object.defineProperty({__proto__:null,RouteViewControls:hb},Symbol.toStringTag,{value:"Module"}));function fb({reason:e,providerLabel:n}){return t.jsx("p",{className:"text-xs text-[#FFD778]/70 mt-1",children:e==="waived-by-grant"?t.jsxs(t.Fragment,{children:["This step normally asks for your approval, but you chose to skip these check-ins for this piece of work — ",n," was meant to keep going. Continue picks the work back up; to be asked again, run"," ",t.jsx("code",{className:"font-mono",children:"codeyam-editor editor check-in-revoke"}),"."]}):e==="disabled-in-config"?t.jsxs(t.Fragment,{children:["This step normally asks for your approval, but this project has that check-in turned off in its workflow settings — ",n," was meant to keep going. Continue picks the work back up without you having to type."]}):t.jsxs(t.Fragment,{children:["This step doesn't ask anything of you — ",n," was meant to keep going. Continue picks the work back up without you having to type."]})})}const WV=Object.freeze(Object.defineProperty({__proto__:null,TurnEndedOffGateReasonBody:fb},Symbol.toStringTag,{value:"Module"}));function _d({envVar:e}){return t.jsxs("p",{className:"text-sm text-[#8E8E8E]",children:["The key is stored in",t.jsx("code",{className:"mx-1 text-[#D7FF63]",children:".codeyam/setup-connections.json"}),"(owner-only, gitignored) and injected into your app as",t.jsx("code",{className:"mx-1 text-[#D7FF63]",children:e})," — never committed."]})}const HV=Object.freeze(Object.defineProperty({__proto__:null,CredentialStorageNote:_d},Symbol.toStringTag,{value:"Module"}));function Sd({href:e}){return t.jsx("a",{href:e,target:"_blank",rel:"noreferrer",className:"inline-block text-sm text-[#7EA6FF] hover:underline",children:"Where to find this key →"})}const qV=Object.freeze(Object.defineProperty({__proto__:null,CredentialDocsLink:Sd},Symbol.toStringTag,{value:"Module"}));function mb({serviceName:e,envVar:n,onBack:s}){return t.jsxs("div",{"data-testid":"credential-request-saved",className:"space-y-3",children:[t.jsx("p",{className:"text-base text-[#D7FF63] font-medium",children:"Saved ✓"}),t.jsxs("p",{className:"text-sm text-[#CFCFCF]",children:["Your ",e," key is available to your app as",t.jsx("code",{className:"mx-1 text-[#D7FF63]",children:n}),". The agent has been told it's saved — you don't need to paste it into the chat."]}),t.jsx("button",{"data-testid":"credential-request-back",onClick:s,className:"px-3 py-1.5 text-sm rounded-md bg-[#D7FF63] text-black font-medium cursor-pointer",children:"Back to preview"})]})}const UV=Object.freeze(Object.defineProperty({__proto__:null,CredentialRequestSaved:mb},Symbol.toStringTag,{value:"Module"}));function kd({target:e,onStored:n}){const[s,r]=l.useState(""),[a,o]=l.useState(!1),[i,c]=l.useState(!1),[d,u]=l.useState(null),[p,h]=l.useState(!1),f=l.useCallback(async()=>{if(s.trim()){c(!0),u(null),h(!1);try{const g=await fetch("/api/setup/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topic:e.topic,provider:"passthrough",credential:s.trim(),credential_fields:{envVar:e.envVar}})});if(!g.ok){if(cR(g.status)==="transient"){h(!0),u(`The editor was briefly unreachable (HTTP ${g.status}). Your key wasn't rejected — try again.`);return}const b=await g.json().catch(()=>({}));u(b.error??`Could not store the key (HTTP ${g.status}).`);return}const x=await g.json().catch(()=>({}));if(x.success===!1||x.status==="error"){u(x.message??x.error??"The key was rejected.");return}r(""),n()}catch{h(!0),u("Could not reach the editor to store the key. Try again.")}finally{c(!1)}}},[s,e,n]),m=g=>{g.preventDefault(),f()};return t.jsxs("form",{"data-testid":"app-service-credential-form",onSubmit:m,className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{"data-testid":"app-service-credential-input",type:a?"text":"password",value:s,onChange:g=>r(g.target.value),placeholder:`${e.serviceName} API key`,autoFocus:!0,autoComplete:"off",spellCheck:!1,className:"flex-1 min-w-0 px-2 py-1.5 rounded bg-black border border-[#3A3A3A] text-white text-sm"}),t.jsx("button",{type:"button","data-testid":"app-service-credential-reveal",onClick:()=>o(g=>!g),className:"px-2 py-1.5 text-xs rounded-md border border-[#3A3A3A] text-[#8E8E8E] hover:text-white cursor-pointer",children:a?"Hide":"Show"}),t.jsx("button",{type:"submit",disabled:i||!s.trim(),className:"px-3 py-1.5 text-sm rounded-md bg-[#D7FF63] text-black font-medium cursor-pointer disabled:opacity-50",children:i?"Saving…":"Save"})]}),d?t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-sm text-[#FF8B43]",children:d}),p?t.jsx("button",{type:"button","data-testid":"app-service-credential-retry",onClick:()=>void f(),disabled:i||!s.trim(),className:"px-3 py-1.5 text-sm rounded-md border border-[#3A3A3A] text-white font-medium cursor-pointer disabled:opacity-50",children:i?"Saving…":"Retry"}):null]}):null]})}const YV=Object.freeze(Object.defineProperty({__proto__:null,AppServiceCredentialForm:kd},Symbol.toStringTag,{value:"Module"}));function gb({message:e,hint:n,onRetry:s}){return t.jsxs("div",{role:"alert",style:{padding:"var(--spacing-md, 12px)",marginBottom:"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:[t.jsxs("div",{children:["Couldn't prepare design moodboards: ",e,". ",n]}),t.jsx("button",{type:"button",onClick:s,style:{marginTop:"var(--spacing-sm, 8px)",background:"transparent",border:"1px solid currentColor",color:"inherit",padding:"var(--spacing-xs, 4px) var(--spacing-md, 12px)",borderRadius:6,cursor:"pointer",fontSize:"var(--text-sm, 14px)",fontWeight:600},children:"Try again"})]})}const GV=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireDesignPrepareErrorBanner:gb},Symbol.toStringTag,{value:"Module"})),hl="Waiting for the agent to write the plan file…";function fl(e){return`${e}-awaiting-formalize`}function Nd({kind:e,inline:n=!1}){return n?t.jsx("span",{"data-testid":fl(e),children:hl}):t.jsx("p",{className:"mt-2 text-xs text-[var(--text-dim)]","data-testid":fl(e),children:hl})}const VV=Object.freeze(Object.defineProperty({__proto__:null,AWAITING_FORMALIZE_CAPTION_TEXT:hl,AwaitingFormalizeCaption:Nd,awaitingFormalizeCaptionTestId:fl},Symbol.toStringTag,{value:"Module"}));function xb({sectionTitle:e,headlineCount:n,refreshedCount:s}){return n>0||s<=0?null:t.jsxs("div",{className:"text-xs text-[var(--text-muted)] italic",children:["No ",e.toLowerCase()," demonstrate this work yet — the"," ",s," below were refreshed because a shared file changed."]})}const KV=Object.freeze(Object.defineProperty({__proto__:null,OnlyRefreshedNotice:xb},Symbol.toStringTag,{value:"Module"}));function bb({message:e}){return t.jsx("div",{className:"flex h-full items-center justify-center px-10",children:t.jsx(Lt,{severity:"error",testId:"build-launch-error",headline:"The session did not start",explanation:e,nextAction:"Run the plan again from the Plan tab or the completion menu. If it keeps failing, copy this report and send it to whoever set up this machine."})})}const JV=Object.freeze(Object.defineProperty({__proto__:null,BuildTabLaunchError:bb},Symbol.toStringTag,{value:"Module"}));function fI(e,n){return e?e.kind==="resume"?n?"Resuming…":`Resume session ${e.sessionId.slice(0,8)}`:n?"Starting…":"Start a new build session":"Checking…"}function yb({mode:e,recovering:n=!1,recovered:s=!1,onRecover:r,onKeepForLater:a}){return s?t.jsx("p",{"data-testid":"interrupted-build-recovered",className:"mt-6 text-sm font-medium text-[var(--accent-active)]",children:(e==null?void 0:e.kind)==="resume"?"Resuming your session — follow along on the Build tab.":"Your new build session is starting — follow along on the Build tab."}):t.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3",children:[t.jsx("button",{type:"button","data-testid":"interrupted-build-recover",onClick:r,disabled:!e||n,className:"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 disabled:cursor-not-allowed disabled:opacity-60",children:fI(e,n)}),t.jsx("button",{type:"button","data-testid":"interrupted-build-keep",onClick:a,disabled:n,className:"rounded px-3 py-2 text-xs font-medium uppercase tracking-wide text-[var(--text-dim)] hover:text-[var(--text-primary)] cursor-pointer disabled:cursor-not-allowed",children:"Keep for later"})]})}const XV=Object.freeze(Object.defineProperty({__proto__:null,InterruptedBuildActions:yb},Symbol.toStringTag,{value:"Module"}));function vb({changedFiles:e,moreChangedFiles:n=0,resuming:s}){return t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:"mt-6 text-xs font-medium uppercase tracking-wide text-[var(--text-muted)]",children:"What may already have changed"}),e.length===0?t.jsx("p",{"data-testid":"interrupted-build-no-changes",className:"mt-2 text-sm text-[var(--text-dim)]",children:"No files have changed since you made this request."}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"mt-2 text-sm text-[var(--text-dim)]",children:s?"The interrupted build may have partly done this work. The resumed session remembers making these changes.":"The interrupted build may have partly done this work. The new session is told to check these files before redoing anything."}),t.jsx("ul",{"data-testid":"interrupted-build-changed-files",className:"mt-2 max-h-48 overflow-y-auto rounded border border-[var(--border-subtle)] px-3 py-2 font-mono text-xs",children:e.map(r=>t.jsxs("li",{className:"flex justify-between gap-4 py-0.5",children:[t.jsx("span",{className:"truncate",children:r.path}),t.jsx("span",{className:"shrink-0 text-[var(--text-muted)]",children:r.change==="uncommitted"?"not saved to git":"committed"})]},r.path))}),n>0?t.jsxs("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:["…and ",n," more."]}):null]})]})}const QV=Object.freeze(Object.defineProperty({__proto__:null,InterruptedBuildChangedFiles:vb},Symbol.toStringTag,{value:"Module"}));function jb({mode:e}){return t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:"mt-6 text-xs font-medium uppercase tracking-wide text-[var(--text-muted)]",children:"What happens next"}),t.jsx("p",{"data-testid":"interrupted-build-mode",className:"mt-2 text-sm text-[var(--text-primary)]",children:e?e.kind==="resume"?"The same agent session continues where it stopped, with its full history.":`A new agent session starts with your original request. ${e.reason} The new session is told the previous attempt was interrupted, so it inspects the current files before redoing work.`:"Checking whether the previous session can be continued…"})]})}const ZV=Object.freeze(Object.defineProperty({__proto__:null,InterruptedBuildNextStep:jb},Symbol.toStringTag,{value:"Module"}));function wb({brief:e,designReferencePath:n=null,requestedAt:s=null}){const r=s?new Date(s):null,a=r&&!Number.isNaN(r.getTime())?r.toLocaleString():null;return t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:"mt-6 text-xs font-medium uppercase tracking-wide text-[var(--text-muted)]",children:["What you asked for",a?` · ${a}`:""]}),t.jsx("blockquote",{"data-testid":"interrupted-build-brief",className:"mt-2 border-l-2 border-[var(--accent-active)] pl-4 text-sm italic text-[var(--text-dim)]",children:e}),n?t.jsxs("p",{className:"mt-2 text-xs text-[var(--text-muted)]",children:["Design reference: ",t.jsx("code",{children:n})]}):null]})}const eK=Object.freeze(Object.defineProperty({__proto__:null,InterruptedBuildRequestSummary:wb},Symbol.toStringTag,{value:"Module"}));function _b({brief:e,designReferencePath:n=null,requestedAt:s=null,interruptionReason:r=null,mode:a,changedFiles:o,moreChangedFiles:i=0,recovering:c=!1,recovered:d=!1,error:u=null,onRecover:p,onKeepForLater:h}){return t.jsxs("section",{"data-testid":"interrupted-build-panel",className:"text-[var(--text-primary)]",children:[t.jsx("h2",{className:"text-xl font-semibold",children:"Your build was interrupted"}),t.jsxs("p",{className:"mt-2 text-sm text-[var(--text-dim)]",children:["The agent stopped before it finished.",r?` ${r}`:""," Nothing will restart until you choose to."]}),t.jsx(wb,{brief:e,designReferencePath:n,requestedAt:s}),t.jsx(vb,{changedFiles:o,moreChangedFiles:i,resuming:(a==null?void 0:a.kind)==="resume"}),t.jsx(jb,{mode:a}),u?t.jsx("p",{"data-testid":"interrupted-build-error",className:"mt-3 text-sm text-[var(--status-error,#f87171)]",children:u}):null,t.jsx(yb,{mode:a,recovering:c,recovered:d,onRecover:p,onKeepForLater:h})]})}const tK=Object.freeze(Object.defineProperty({__proto__:null,InterruptedBuildPanel:_b},Symbol.toStringTag,{value:"Module"}));function mI(e){const[n,s]=l.useState(null),[r,a]=l.useState(!1),[o,i]=l.useState(!1),[c,d]=l.useState(null),u=l.useRef(!1);l.useEffect(()=>{if(!e)return;let h=!1;return fetch(`/api/editor-build-requests/${e}/recovery`).then(f=>{if(!f.ok)throw new Error(`HTTP ${f.status}`);return f.json()}).then(f=>{h||s(f)}).catch(()=>{h||d("Couldn’t load the details of the interrupted build.")}),()=>{h=!0}},[e]);const p=l.useCallback(()=>{!e||u.current||(u.current=!0,a(!0),d(null),fetch(`/api/editor-build-requests/${e}/recover`,{method:"POST"}).then(async h=>{const f=await h.json().catch(()=>({}));if(!h.ok)throw new Error(f.error??`HTTP ${h.status}`);i(!0)}).catch(h=>{d(`Couldn’t start the recovery: ${h.message}`),u.current=!1}).finally(()=>a(!1)))},[e]);return{details:n,recovering:r,recovered:o,error:c,recover:p}}const Sb="codeyam.interruptedBuild.keptForLater";function kb(e){try{return window.localStorage.getItem(Sb)===e}catch{return!1}}function gI(e){try{window.localStorage.setItem(Sb,e)}catch{}}function Cd({request:e,onRecovered:n,onKeptForLater:s}){var u,p;const{details:r,recovering:a,recovered:o,error:i,recover:c}=mI(e.id),d=l.useRef(!1);return l.useEffect(()=>{!o||d.current||(d.current=!0,n==null||n())},[o,n]),t.jsx(_b,{brief:e.brief,designReferencePath:((u=e.designReference)==null?void 0:u.path)??null,requestedAt:e.createdAt,interruptionReason:((p=e.interruption)==null?void 0:p.reason)??null,mode:(r==null?void 0:r.mode)??null,changedFiles:(r==null?void 0:r.changedFiles)??[],moreChangedFiles:(r==null?void 0:r.moreChangedFiles)??0,recovering:a,recovered:o,error:i,onRecover:c,onKeepForLater:()=>{gI(e.id),s==null||s()}})}const nK=Object.freeze(Object.defineProperty({__proto__:null,InterruptedBuildRecovery:Cd},Symbol.toStringTag,{value:"Module"})),xI=1;function Nb({maxHeight:e,fadeColor:n="var(--bg-surface)",testId:s,children:r}){const a=l.useRef(null),o=l.useRef(null),[i,c]=l.useState(!1),[d,u]=l.useState(!1),p=l.useCallback(()=>{const h=a.current;if(!h)return;const f=h.scrollHeight-h.clientHeight;c(f>0),u(h.scrollTop>=f-xI)},[]);return l.useEffect(()=>{p();const h=new ResizeObserver(p);return a.current&&h.observe(a.current),o.current&&h.observe(o.current),()=>h.disconnect()},[p,r]),t.jsxs("div",{style:{position:"relative"},children:[t.jsx("div",{ref:a,"data-testid":s,onScroll:p,className:"overflow-y-auto",style:{maxHeight:`${e}px`},tabIndex:i?0:void 0,children:t.jsx("div",{ref:o,children:r})}),i&&!d&&t.jsx("div",{"aria-hidden":!0,"data-testid":s?`${s}-fade`:void 0,style:{position:"absolute",bottom:0,left:0,right:0,height:"2rem",background:`linear-gradient(transparent, ${n})`,pointerEvents:"none"}})]})}const sK=Object.freeze(Object.defineProperty({__proto__:null,ScrollFadeRegion:Nb},Symbol.toStringTag,{value:"Module"})),bI={"no-surface":"No surface for this yet","no-mock-seam":"No way to mock this yet","real-process":"Needs two live processes","real-external":"Needs a real external system"},yI=["no-surface","no-mock-seam"];function Td(e){return yI.includes(e)}function Cb({barrier:e}){const n=Td(e);return t.jsx("span",{className:`mtest-barrier ${n?"gap":"inherent"}`,"data-barrier":e,children:bI[e]})}const rK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestBarrierTag:Cb,isCodeyamGap:Td},Symbol.toStringTag,{value:"Module"}));function Tb({summary:e}){if(e.total===0||e.unsimulated===0)return null;const{total:n,unsimulated:s,gaps:r,inherent:a,unclassified:o}=e;return t.jsxs("div",{className:"mtest-gaps","data-testid":"manual-tests-gap-summary","data-total":n,"data-unsimulated":s,"data-gaps":r,"data-inherent":a,"data-unclassified":o,children:[t.jsxs("span",{className:"mtest-gaps-headline",children:[s," of ",n," test",n===1?"":"s"," ",s===1?"has":"have"," no simulation"]}),r>0?t.jsxs("span",{className:"mtest-barrier gap",children:[r," codeyam could show"]}):null,a>0?t.jsxs("span",{className:"mtest-barrier inherent",children:[a," need",a===1?"s":""," a real process or system"]}):null,o>0?t.jsxs("span",{className:"mtest-barrier unclassified",children:[o," unclassified"]}):null]})}const aK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestGapSummary:Tb},Symbol.toStringTag,{value:"Module"})),Pb="/codeyam-plan",Ob="/codeyam-prototype",qa="/codeyam-chat",vI="/codeyam-design";function Es(e,n){const s=kr(n);return s?`${e} ${s}`:e}function kr(e){return e.replace(/\s+/g," ").trim()}function ml(e,n,s){const r=s.trim();return r?`${e} returned ${n}: ${r}`:`${e} returned ${n} with an empty response body`}const Uh="/api/editor-design-systems-install";async function gl(){const e=await fetch(Uh,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"});if(!e.ok){const n=await e.text().catch(()=>"");throw new Error(ml(Uh,e.status,n))}}let Cs=[],jI=0;function Pd(e){const n=jI++;return Cs.push({id:n,chatName:e}),()=>{Cs=Cs.filter(s=>s.id!==n)}}function Rb(){return Cs.length>0?Cs[Cs.length-1].chatName:null}function Eb({onClose:e,seedText:n}){l.useEffect(()=>Pd("design-tweak"),[]);const[s,r]=l.useState(!1);return l.useEffect(()=>{let a=!0;return gl().catch(()=>{}).finally(()=>{a&&r(!0)}),()=>{a=!1}},[]),s?t.jsx(qt,{chatName:"design-tweak",slashCommand:`${vI} ${n}`,seedText:n,height:360,onClose:e,beforeRelaunch:gl}):t.jsx(lb,{testId:"design-tweak-chat-preparing"})}const oK=Object.freeze(Object.defineProperty({__proto__:null,DesignTweakChat:Eb},Symbol.toStringTag,{value:"Module"}));function Ab(){return t.jsx("p",{"data-testid":"design-switch-plan-explainer",style:{margin:0,color:"var(--text-secondary)",fontSize:13},children:"Your app already exists, so this adds a plan to your queue describing the switch: which colors and fonts change and which screens use them. Nothing in the app changes until you run it."})}const iK=Object.freeze(Object.defineProperty({__proto__:null,DesignSwitchPlanExplainer:Ab},Symbol.toStringTag,{value:"Module"}));function Mb({onClick:e}){return t.jsx("button",{type:"button","data-testid":"plan-tweak-designs",onClick:e,style:{marginTop:"var(--spacing-md, 12px)",padding:"10px 16px",borderRadius:8,border:"1px solid var(--accent-active, #D7FF63)",background:"transparent",color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",cursor:"pointer"},children:"Tweak these designs"})}const lK=Object.freeze(Object.defineProperty({__proto__:null,TweakDesignsButton:Mb},Symbol.toStringTag,{value:"Module"}));function Ib({count:e,selected:n}){const s=e===1?"":"s",r=n?`, with ${n} selected`:", none selected yet";return t.jsx("p",{"data-testid":"plan-design-context-note",style:{margin:"8px 0 0",fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:`Your request will mention the ${e} design${s} on screen${r}, so you can refer to them by number or name.`})}const cK=Object.freeze(Object.defineProperty({__proto__:null,DesignContextNote:Ib},Symbol.toStringTag,{value:"Module"}));function Db({title:e,onClick:n}){return t.jsxs("button",{type:"button",className:"mtest-delete","data-testid":"manual-test-delete",onClick:n,title:`Delete "${e}" — removes the test, not just its check`,"aria-label":`Delete "${e}"`,children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M3 6h18M8 6V4a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v2M19 6l-1 14a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1L5 6"})}),"Delete"]})}const dK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestDeleteButton:Db},Symbol.toStringTag,{value:"Module"}));function Lb({busy:e,onCancel:n,onConfirm:s}){return t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[t.jsx("button",{type:"button",onClick:n,disabled:e,style:{padding:"8px 16px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)",borderRadius:6,fontSize:13,fontWeight:500,cursor:e?"wait":"pointer",opacity:e?.5:1,fontFamily:"inherit"},children:"Cancel"}),t.jsx("button",{type:"button",onClick:s,disabled:e,"data-testid":"manual-test-delete-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:e?"wait":"pointer",opacity:e?.5:1,fontFamily:"inherit"},children:e?"Deleting…":"Delete test"})]})}const uK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestDeleteConfirmActions:Lb},Symbol.toStringTag,{value:"Module"}));function Fb({completed:e}){return e?t.jsx("p",{style:{margin:0,color:"var(--accent-red, #ff5c5c)",fontSize:13},"data-testid":"manual-test-delete-receipt-warning",children:"This test was verified. Its receipt — who confirmed it, and when — is deleted with it."}):null}const pK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestDeleteReceiptWarning:Fb},Symbol.toStringTag,{value:"Module"}));function $b({title:e}){return t.jsxs(t.Fragment,{children:[t.jsx("h2",{style:{margin:0,color:"var(--text-primary)",fontSize:16,fontWeight:600},children:"Delete manual test?"}),t.jsx("p",{style:{margin:0,color:"var(--text-primary)",fontSize:13},children:e}),t.jsx("p",{style:{margin:0,color:"var(--text-secondary)",fontSize:13},children:"This removes the test from the repo and stages the deletion in git. Nothing is committed — the removal lands with your next commit. If the test was never committed, it is gone for good."})]})}const hK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestDeleteConfirmHeader:$b},Symbol.toStringTag,{value:"Module"}));function us(){const[e,n]=l.useState(()=>Date.now());return l.useEffect(()=>{const s=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(s)},[]),e}function Un(e,n=Date.now()){if(!e)return"unknown";const s=Date.parse(e);if(Number.isNaN(s))return e;const r=Math.round((n-s)/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 Od({uuid:e,markedForRelease:n,onToggle:s,alwaysVisible:r=!1}){if(n)return t.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-${e}`,onClick:s,title:"Keep this entry in the queue",children:"Undo remove"});const a=r?"":"opacity-0 group-hover:opacity-100 transition-opacity ";return t.jsx("button",{type:"button",className:`${a}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-${e}`,onClick:s,title:"Mark this entry for removal",children:"Force release"})}const fK=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueReleaseButton:Od},Symbol.toStringTag,{value:"Module"}));function zb({entry:e,markedForRelease:n,onToggleRelease:s}){const r=us(),a=e.meta,o=a.startedAt??e.committerDate,i=[{key:"machine",label:"machine",value:a.machine},{key:"agent",label:"agent",value:a.agentProvider??"agent"},{key:"version",label:"editor version",value:a.codeyamEditorVersion??"unknown"},{key:"session",label:"session",value:a.sessionId},{key:"pid",label:"pid",value:String(a.pid)},{key:"step",label:"step",value:a.currentStep??"unknown"},{key:"started",label:"started",value:`${o} (${Un(o,r)})`},{key:"ref",label:"ref",value:e.refName},{key:"uuid",label:"uuid",value:e.uuid}];return t.jsxs("div",{className:"w-full","data-testid":`commit-queue-details-${e.uuid}`,children:[t.jsx("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs",children:i.map(c=>t.jsxs("div",{className:"contents",children:[t.jsx("dt",{className:"text-[var(--text-dim)]",children:c.label}),t.jsx("dd",{className:"font-mono break-all text-[var(--text-default)]","data-testid":`commit-queue-detail-${c.key}-${e.uuid}`,children:c.value})]},c.key))}),t.jsx("div",{className:"mt-3",children:t.jsx(Od,{uuid:e.uuid,markedForRelease:n,onToggle:s,alwaysVisible:!0})})]})}const mK=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueRowDetails:zb},Symbol.toStringTag,{value:"Module"}));function Bb({state:e}){return t.jsx("div",{style:{padding:"var(--spacing-lg, 16px)",color:"var(--text-secondary)",fontSize:"var(--text-sm, 14px)"},children:e==="resolving"?"Finding the active round…":"No active round."})}const gK=Object.freeze(Object.defineProperty({__proto__:null,DesignRoundEmptyState:Bb},Symbol.toStringTag,{value:"Module"}));function Wb({providerLabel:e,open:n,onClick:s}){return t.jsxs("button",{type:"button",onClick:s,"aria-expanded":n,className:"mtest-ask"+(n?" open":""),"data-testid":"manual-test-ask",title:`Ask ${e} how to run this test, or have it fix the test`,children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.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"})}),"Ask about this test"]})}const xK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestAskChatButton:Wb},Symbol.toStringTag,{value:"Module"}));function Hb(e){return e.cliInstalled&&e.pluginInstalled&&e.projectInitialized}function wI(e){return e.cliInstalled||e.projectInitialized}function xl({note:e}){return e?t.jsx("p",{className:"xsvc-broker-note",children:e}):null}function qb({broker:e,category:n,onStart:s}){const r=n.toLowerCase();return!e.cliInstalled||!e.pluginInstalled?t.jsxs("div",{className:"xsvc-broker xsvc-broker-blocked",children:[t.jsxs("div",{className:"xsvc-broker-head",children:["Set up ",r," with ",e.name]}),t.jsxs("p",{className:"xsvc-broker-body",children:[e.cliInstalled?`The ${e.name} CLI is installed, but its projects plugin is not.`:`The ${e.name} CLI is not installed on this machine.`," ","Install it and this page will offer to set up ",r," for you. This installs software on your computer; it creates nothing on your"," ",e.name," account and costs nothing."]}),t.jsx("code",{className:"xsvc-broker-cmd",children:e.installHint}),t.jsx(xl,{note:e.note})]}):e.projectInitialized?t.jsxs("div",{className:"xsvc-broker",children:[t.jsxs("div",{className:"xsvc-broker-head",children:["Set up ",r," with ",e.name]}),t.jsxs("p",{className:"xsvc-broker-body",children:[e.projectName?`This project is connected to ${e.name} as "${e.projectName}".`:`This project is connected to ${e.name}.`," ",e.resourceCount>0?`${e.resourceCount} service${e.resourceCount===1?"":"s"} already provisioned.`:"Nothing provisioned through it yet."," ","Opening a session hands the work to the agent, which shows you every command and waits for a yes before running it."]}),t.jsx(xl,{note:e.note}),t.jsx("button",{type:"button",className:"xsvc-broker-go",onClick:s,disabled:!Hb(e),children:"Start setup"})]}):t.jsxs("div",{className:"xsvc-broker",children:[t.jsxs("div",{className:"xsvc-broker-head",children:["Set up ",r," with ",e.name]}),t.jsxs("p",{className:"xsvc-broker-body",children:["This project has not been connected to ",e.name," yet. The first step creates a project on your ",e.name," account and writes its records into this repository. A browser window may open for you to sign in."]}),t.jsx("p",{className:"xsvc-broker-body",children:"Nothing runs until you approve it: the session shows you each command and waits for a yes before running it, one command at a time."}),t.jsx("button",{type:"button",className:"xsvc-broker-go",onClick:s,children:"Start setup"})]})}const bK=Object.freeze(Object.defineProperty({__proto__:null,BrokerNote:xl,ProvisionWithBrokerCta:qb},Symbol.toStringTag,{value:"Module"}));function Ub({title:e,onClose:n,children:s}){return t.jsxs("div",{role:"dialog","aria-label":e,children:[t.jsxs("div",{className:"xsvc-chatdock-head",children:[t.jsx("span",{children:e}),t.jsx("button",{type:"button",className:"xsvc-chatdock-close",onClick:n,children:"Close ✕"})]}),s]})}const yK=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesChatDock:Ub},Symbol.toStringTag,{value:"Module"}));function Yb({onClose:e,slashCommand:n,seedText:s}){const r=l.useRef(null);return l.useEffect(()=>{const a=r.current;a&&typeof a.scrollIntoView=="function"&&a.scrollIntoView({block:"nearest",behavior:"smooth"})},[]),t.jsx("div",{ref:r,children:t.jsx(qt,{chatName:"manual-tests",slashCommand:n,seedText:s,height:360,onClose:e})})}const vK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestsChat:Yb},Symbol.toStringTag,{value:"Module"}));function _I(e){const n=new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function Gb({steps:e}){const[n,s]=l.useState(!1),r=e.length>1,a=n?e:e.slice(0,1);return t.jsxs(t.Fragment,{children:[t.jsx("ol",{className:"mtest-steps",children:a.map((o,i)=>t.jsx("li",{children:o},i))}),r?t.jsx("button",{type:"button",className:"mtest-disclose",onClick:()=>s(o=>!o),"aria-expanded":n,children:n?"Show less":`Show all ${e.length} steps`}):null]})}const jK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestSteps:Gb},Symbol.toStringTag,{value:"Module"}));function bl({surface:e,slot:n,onOpenUncovered:s}){if(e.kind==="scenario"){if(n==="context")return null;const r=e.scenarioType==="component";return t.jsxs("a",{className:"mtest-open primary",href:uE(e.slug),target:"_blank",rel:"noopener noreferrer",title:e.reason,children:["Open scenario",t.jsx("span",{className:"sname",children:e.name}),r?t.jsx("span",{className:"stype",children:"component"}):null,t.jsxs("svg",{className:"ext",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),t.jsx("polyline",{points:"15 3 21 3 21 9"}),t.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})]})}return n==="action"?null:e.kind==="uncovered"?t.jsxs("div",{className:"mtest-uncovered",children:[t.jsx("span",{className:"lbl",children:"No scenario yet"}),t.jsx("span",{className:"uname",children:e.name}),t.jsx("span",{className:"ufile",children:e.file}),s?t.jsx("button",{type:"button",className:"mtest-uncovered-cta",onClick:()=>s(e.name),children:"Find it in Explore →"}):null]}):t.jsxs("div",{className:"mtest-nosurface",children:[e.barrier?t.jsx(Cb,{barrier:e.barrier}):null,t.jsx("span",{className:"note",children:e.note}),e.barrierDetail?t.jsx("span",{className:"bdetail",children:e.barrierDetail}):null]})}const wK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestSurfaceControl:bl},Symbol.toStringTag,{value:"Module"})),Yh=["#7a4f6d","#4f6a7a","#6d7a4f","#7a5f4f","#5f4f7a","#4f7a63"];function Vb(e){const n=e.trim().toLowerCase();let s=0;for(let r=0;r<n.length;r+=1)s=(s+n.charCodeAt(r)*(r+1))%1e5;return Yh[s%Yh.length]}function So({author:e}){const n=e.email?`${e.name} <${e.email}>`:e.name;return t.jsx("span",{"data-testid":"plan-author-avatar",title:n,"aria-label":`Author: ${n}`,style:{backgroundColor:Vb(e.email)},className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-[10px] font-medium uppercase tracking-tight text-white/90 select-none",children:e.initials})}const _K=Object.freeze(Object.defineProperty({__proto__:null,PlanAuthorAvatar:So,avatarTone:Vb},Symbol.toStringTag,{value:"Module"}));function Rd({test:e,onToggle:n,onOpenUncovered:s,onAskAbout:r,onDelete:a,askProviderLabel:o,chatOpen:i=!1,chatSlot:c,busy:d=!1,departing:u=!1}){const p=e.status==="completed";return t.jsxs("div",{className:"mtest-row"+(p?" done":"")+(u?" leaving":"")+(u==="pinned"?" pinned":""),"data-testid":"manual-test-row","data-test-id":e.id,"data-departing":u?u==="pinned"?"pinned":"true":void 0,children:[t.jsx("label",{className:"mtest-check",children:t.jsx("input",{type:"checkbox",checked:p,disabled:d,onChange:h=>n(e.id,h.target.checked),"aria-label":`Mark "${e.title}" verified`})}),t.jsxs("div",{className:"mtest-main",children:[t.jsx("div",{className:"mtest-title",children:e.title}),t.jsx("div",{className:"mtest-intent",children:e.intent}),t.jsx(bl,{surface:e.surface,slot:"action"}),t.jsx(Gb,{steps:e.steps}),t.jsxs("div",{className:"mtest-expected",children:[t.jsx("span",{className:"lbl",children:"Expected"})," ",e.expected]}),t.jsx(bl,{surface:e.surface,slot:"context",onOpenUncovered:s}),r||a?t.jsxs("div",{className:"mtest-ask-row",children:[r?t.jsx(Wb,{providerLabel:o??Qe(null),open:i,onClick:()=>r(e.id)}):null,a?t.jsx(Db,{title:e.title,onClick:()=>a(e.id)}):null]}):null,p&&e.completion?t.jsxs("div",{className:"mtest-receipt","data-testid":"manual-test-receipt",children:[t.jsx(So,{author:{name:e.completion.completedByName,email:e.completion.completedByEmail,initials:e.completion.completedByInitials??"?"}}),"verified ",_I(e.completion.completedAt)]}):null,c?t.jsx("div",{className:"mtest-row-chat","data-testid":"manual-test-row-chat",children:c}):null]})]})}const SK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRow:Rd},Symbol.toStringTag,{value:"Module"}));function Kb({tests:e,busyIds:n,onToggle:s,onOpenUncovered:r,onAskAboutTest:a,onDeleteTest:o,askProviderLabel:i,openTestChatId:c=null,testChatSlot:d}){const[u,p]=l.useState(!1),h=new Set(n);return e.length===0?null:t.jsxs("div",{className:"mtest-completed",children:[t.jsxs("button",{type:"button",className:"mtest-disclose",onClick:()=>p(f=>!f),"aria-expanded":u,"data-testid":"home-testing-completed-toggle",children:[u?"Hide":"Show"," ",e.length," completed"]}),u?t.jsx("div",{className:"mtest-list",children:e.map(f=>t.jsx(Rd,{test:f,onToggle:s,onOpenUncovered:r,onAskAbout:a,onDelete:o,askProviderLabel:i,chatOpen:c===f.id,chatSlot:c===f.id?d:null,busy:h.has(f.id)},f.id))}):null]})}const kK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestCompletedGroup:Kb},Symbol.toStringTag,{value:"Module"}));function Jb({status:e}){return e?e.neverGenerated?t.jsx("span",{className:"mtest-count","data-testid":"manual-tests-count-line",children:"No tests generated yet"}):e.lastGeneratedShaUnreachable?t.jsx("span",{className:"mtest-count warn","data-testid":"manual-tests-count-line",title:"The commit the last generation was anchored to is no longer reachable — a rebase or squash dropped it.",children:"Anchor commit is gone — regenerate to re-anchor"}):e.commitsSince==null?t.jsx("span",{className:"mtest-count","data-testid":"manual-tests-count-line",children:"Commits since last generated: unknown"}):t.jsx("span",{className:"mtest-count","data-testid":"manual-tests-count-line",children:e.commitsSince===0?"Up to date — 0 commits since tests were last generated":`${e.commitsSince} commit${e.commitsSince===1?"":"s"} since tests were last generated`}):null}const NK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestCountLine:Jb},Symbol.toStringTag,{value:"Module"}));function va({value:e,label:n,detail:s,checked:r,enabled:a=!0,disabled:o=!1,onSelect:i}){return t.jsxs("label",{className:"mtest-range-opt"+(a?"":" disabled"),children:[t.jsx("input",{type:"radio",name:"mtest-range-choice",checked:r,disabled:o||!a,onChange:i}),t.jsx("span",{className:"mtest-range-opt-lbl",children:n}),s?t.jsx("span",{className:"mtest-range-opt-detail",children:s}):null]})}const CK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRangeOption:va},Symbol.toStringTag,{value:"Module"})),SI=[10,25];function kI(e,n){switch(e){case"marker":return n.defaultRange?{range:n.defaultRange,label:"since tests were last generated",adHoc:!1}:null;case"count-10":case"count-25":{const s=e==="count-10"?10:25;return{range:`HEAD~${s}..HEAD`,label:`last ${s} commits`,adHoc:!0}}case"commit":return n.selectedCommit?{range:`${n.selectedCommit.shortSha}..HEAD`,label:`since “${n.selectedCommit.subject}”`,adHoc:!0}:null;case"custom":{const s=n.customRange.trim();return s?{range:s,label:s,adHoc:!0}:null}}}function Xb({choice:e,onChoose:n,hasDefaultRange:s,commitCount:r=null,commitsLoaded:a,disabled:o=!1}){const i=s?r!=null?`${r} commit${r===1?"":"s"}`:"":"no anchor — nothing has been generated yet";return t.jsxs("div",{className:"mtest-range-opts",children:[t.jsx(va,{value:"marker",label:"Since tests were last generated",detail:i,checked:e==="marker",enabled:s,disabled:o,onSelect:()=>n("marker")}),SI.map(c=>{const d=c===10?"count-10":"count-25";return t.jsx(va,{value:d,label:`Last ${c} commits`,checked:e===d,disabled:o,onSelect:()=>n(d)},d)}),t.jsx(va,{value:"commit",label:"Since a specific change…",detail:a?"":"no commits loaded",checked:e==="commit",enabled:a,disabled:o,onSelect:()=>n("commit")})]})}const TK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRangeOptions:Xb},Symbol.toStringTag,{value:"Module"}));function NI(e,n=Date.now()){const s=new Date(e).getTime();if(Number.isNaN(s))return"";const r=Math.floor((n-s)/864e5);if(r<=0)return"today";if(r===1)return"yesterday";if(r<30)return`${r} days ago`;const a=Math.round(r/30);return a===1?"1 month ago":`${a} months ago`}function Qb({commit:e,selected:n,disabled:s=!1,onSelect:r}){return t.jsxs("button",{type:"button",className:"mtest-range-commit"+(n?" selected":""),onClick:r,disabled:s,"aria-pressed":n,children:[t.jsx("span",{className:"mtest-range-commit-subject",children:e.subject}),t.jsxs("span",{className:"mtest-range-commit-meta",children:[e.shortSha," · ",NI(e.timestamp)]})]})}const PK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRangeCommitRow:Qb},Symbol.toStringTag,{value:"Module"}));function Zb({commits:e,hiddenCount:n=0,selectedSha:s,onSelect:r,disabled:a=!1}){return t.jsxs(t.Fragment,{children:[e.length>0?t.jsx("div",{className:"mtest-range-commits","data-testid":"manual-tests-commits",children:e.map(o=>t.jsx(Qb,{commit:o,selected:s===o.sha,disabled:a,onSelect:()=>r(o.sha)},o.sha))}):null,n>0?t.jsxs("span",{className:"mtest-range-hidden",children:[n," bookkeeping commit",n===1?"":"s"," hidden"]}):null]})}const OK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRangeCommitList:Zb},Symbol.toStringTag,{value:"Module"}));function ey({value:e,onChange:n,onSubmit:s,onCancel:r,disabled:a=!1}){return t.jsxs("div",{className:"mtest-range-field",children:[t.jsx("label",{className:"mtest-range-lbl",htmlFor:"mtest-range-input",children:"Range"}),t.jsx("input",{id:"mtest-range-input",className:"mtest-range-input",type:"text",value:e,spellCheck:!1,autoComplete:"off",placeholder:"e.g. main..HEAD",onChange:o=>n(o.target.value),onKeyDown:o=>{o.key==="Enter"&&s(),o.key==="Escape"&&(r==null||r())},disabled:a})]})}const RK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRangeCustomField:ey},Symbol.toStringTag,{value:"Module"}));function ty({resolved:e,awaitingCommit:n}){const s=e==null?n?"Pick a change to generate from.":"Name a range to generate from.":e.adHoc?"This run won’t move the last-generated marker.":"The usual run — moves the marker when it finishes.";return t.jsx("span",{className:"mtest-range-hint",children:s})}const EK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRangeHint:ty},Symbol.toStringTag,{value:"Module"}));function ny({canGenerate:e,onGenerate:n,onShowCustom:s,showCustomButton:r,onCancel:a,disabled:o=!1}){return t.jsxs("div",{className:"mtest-range-actions",children:[r?t.jsx("button",{type:"button",className:"mtest-btn subtle",onClick:s,disabled:o,children:"Type a range"}):null,a?t.jsx("button",{type:"button",className:"mtest-btn subtle",onClick:a,disabled:o,children:"Cancel"}):null,t.jsx("button",{type:"button",className:"mtest-btn primary",onClick:n,disabled:o||!e,"data-testid":"manual-tests-range-generate",children:"Generate"})]})}const AK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRangeActions:ny},Symbol.toStringTag,{value:"Module"}));function CI(e){return/^chore: update codeyam state\b/i.test(e.trim())}function sy({defaultRange:e,commitCount:n,recentCommits:s=[],onGenerate:r,onCancel:a,disabled:o=!1,initialChoice:i,initialSelectedSha:c=null}){const[d,u]=l.useState(i??(e?"marker":"commit")),[p,h]=l.useState(c??null),[f,m]=l.useState(""),[g,x]=l.useState(!1),b=s.filter(_=>!CI(_.subject)),y=s.find(_=>_.sha===p)??null,v=kI(d,{defaultRange:e,selectedCommit:y,customRange:f}),j=()=>{v&&!o&&r(v)};return t.jsxs("div",{className:"mtest-range","data-testid":"manual-tests-range",children:[t.jsx("div",{className:"mtest-range-title",children:"Which commits should it read?"}),t.jsx(Xb,{choice:d,onChoose:u,hasDefaultRange:e!=null,commitCount:n??null,commitsLoaded:s.length>0,disabled:o}),d==="commit"?t.jsx(Zb,{commits:b,hiddenCount:s.length-b.length,selectedSha:p,onSelect:h,disabled:o}):null,g?t.jsx(ey,{value:f,onChange:_=>{m(_),u("custom")},onSubmit:j,onCancel:a,disabled:o}):null,t.jsxs("div",{className:"mtest-range-foot",children:[t.jsx(ty,{resolved:v,awaitingCommit:d==="commit"}),t.jsx(ny,{canGenerate:v!=null,onGenerate:j,onShowCustom:()=>x(!0),showCustomButton:!g,onCancel:a,disabled:o})]})]})}const MK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestRangeControl:sy},Symbol.toStringTag,{value:"Module"}));function ry({range:e}){return e?t.jsxs("span",{className:"mtest-adhoc","data-testid":"manual-tests-adhoc-note",children:["Last run: ",e]}):null}const IK=Object.freeze(Object.defineProperty({__proto__:null,ManualTestAdHocNote:ry},Symbol.toStringTag,{value:"Module"}));function ay({id:e,written:n,confirming:s,busyAction:r,onWrite:a,onRequestIgnore:o,onConfirmIgnore:i,onCancelIgnore:c}){if(n)return t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-[var(--accent-success,#4ade80)]","data-testid":`proposed-plan-planned-${e}`,children:"Planned ✓"});const d=r!==void 0;return r==="ignore"?t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-[var(--text-muted)]","data-testid":`proposed-plan-discarding-${e}`,children:"Discarding…"}):s?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:"Discard?"}),t.jsx("button",{type:"button",className:Fn+Fx,disabled:d,onClick:i,"data-testid":`proposed-plan-confirm-ignore-${e}`,children:"Discard"}),t.jsx("button",{type:"button",className:Fn+Ha,onClick:c,"data-testid":`proposed-plan-keep-${e}`,children:"Keep"})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:Fn+Lx,disabled:d,onClick:a,"data-testid":`proposed-plan-write-${e}`,children:r==="write"?"Planning…":"Plan"}),t.jsx("button",{type:"button",className:Fn+Ha,disabled:d,onClick:o,"data-testid":`proposed-plan-ignore-${e}`,children:"Ignore"})]})}const DK=Object.freeze(Object.defineProperty({__proto__:null,ProposedPlanRowActions:ay},Symbol.toStringTag,{value:"Module"}));function Ed({row:e,ideaTotal:n,busyAction:s,confirming:r,error:a,onWrite:o,onRequestIgnore:i,onConfirmIgnore:c,onCancelIgnore:d}){const u=Bx(e);return t.jsxs("li",{className:"p-2.5 rounded-md flex flex-col gap-1.5",style:{background:"var(--bg-deep)",border:"1px solid var(--border-subtle)"},"data-testid":`proposed-plan-${e.id}`,"data-status":e.status??"pending",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm text-[var(--text-primary)] leading-snug",children:e.title}),e.reason&&t.jsx("p",{className:"text-xs text-[var(--text-muted)] leading-relaxed mt-0.5",children:e.reason}),e.source==="deferred-deliverable"&&t.jsx("p",{className:"text-[10px] uppercase tracking-wide text-[var(--text-dim)] mt-1",children:"Left out of this build"}),e.source==="refactor"&&t.jsx("p",{className:"text-[10px] uppercase tracking-wide text-[var(--text-dim)] mt-1","data-testid":`proposed-plan-refactor-label-${e.id}`,children:"Refactor · measured by CodeYam"}),(e.severity!==void 0||u!==void 0)&&t.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[t.jsx(fd,{id:e.id,severity:e.severity,kind:LM(e)}),t.jsx(Dx,{id:e.id,category:u}),e.source==="feature-synthesis"&&t.jsx(Rx,{row:e,ideaTotal:n})]})]}),t.jsx("div",{className:"shrink-0 flex items-center gap-1.5 pt-0.5",children:t.jsx(ay,{id:e.id,written:e.status==="written",confirming:r,busyAction:s,onWrite:o,onRequestIgnore:i,onConfirmIgnore:c,onCancelIgnore:d})})]}),r&&t.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:"It won't be offered again."}),t.jsx(tt,{text:a&&`${a} — try Plan again, or Ignore it.`,copyText:a,testId:`proposed-plan-error-${e.id}`})]})}const LK=Object.freeze(Object.defineProperty({__proto__:null,FeatureCompleteProposedPlanRow:Ed},Symbol.toStringTag,{value:"Module"}));function As(e){return e.source==="codeyam-improvement"}function TI(e){return e.kind?e.kind==="feature":e.source==="deferred-deliverable"||e.source==="feature-synthesis"||e.category==="feature"}const PI=2;function Gh(e){const n=e.severity??PI;return Math.max(e.sightings??0,1)*n}function Ad(e){const n=d=>d.rank??Number.POSITIVE_INFINITY,s=[...e].sort((d,u)=>{if(n(d)!==n(u))return n(d)<n(u)?-1:1;const p=(u.severity??0)-(d.severity??0);return p!==0?p:(u.sightings??0)-(d.sightings??0)}),r=s.flatMap((d,u)=>As(d)?[u]:[]),a=r.map(d=>s[d]).sort((d,u)=>Gh(u)-Gh(d)||(u.severity??0)-(d.severity??0));r.forEach((d,u)=>{s[d]=a[u]});const o=d=>d.source==="deferred-deliverable"?[0,0]:d.source==="feature-synthesis"?[1,d.ideaRank??Number.POSITIVE_INFINITY]:[2,0],i=s.flatMap((d,u)=>!As(d)&&TI(d)?[u]:[]),c=i.map(d=>s[d]).sort((d,u)=>{const[p,h]=o(d),[f,m]=o(u);return p-f||(h===m?0:h<m?-1:1)});return i.forEach((d,u)=>{s[d]=c[u]}),s}function oy(e){return e.some(n=>n.spotlighted)?{surfaced:e.filter(n=>n.spotlighted),tracked:e.filter(n=>!n.spotlighted)}:{surfaced:[...e],tracked:[]}}function iy({count:e,providerLabel:n,expanded:s,onToggle:r,children:a}){return t.jsxs("div",{className:"mt-2",children:[t.jsx("button",{type:"button",className:"text-xs text-[var(--text-muted)] hover:text-[var(--text-primary)] underline underline-offset-2","aria-expanded":s,"data-testid":"proposed-plans-view-all",onClick:r,children:s?"Hide plans being considered":`View all plans being considered (${e})`}),s&&t.jsxs("div",{className:"mt-2","data-testid":"proposed-plans-tracked",children:[t.jsxs("p",{className:"text-xs text-[var(--text-muted)] leading-relaxed mb-2",children:[n," is tracking these plans but doesn't consider them worthy of bringing to your attention yet — you can plan them if you want."]}),t.jsx("ul",{className:"flex flex-col gap-2",children:a})]})]})}const FK=Object.freeze(Object.defineProperty({__proto__:null,TrackedProposedPlans:iy},Symbol.toStringTag,{value:"Module"}));function ly({rows:e,providerLabel:n="The agent",busyActions:s,errorsById:r,headReleaseFailure:a=null,initiallyExpanded:o=!1,onWrite:i,onIgnore:c}){const[d,u]=l.useState(null),[p,h]=l.useState(o),f=Ad(e.filter(y=>y.status!=="ignored"&&y.status!=="retired"&&!As(y)));if(f.length===0&&!a)return null;const{surfaced:m,tracked:g}=oy(f),x=f.filter(y=>y.source==="feature-synthesis").length,b=y=>t.jsx(Ed,{row:y,ideaTotal:x,busyAction:s[y.id],confirming:d===y.id,error:r[y.id],onWrite:()=>i(y.id),onRequestIgnore:()=>u(y.id),onConfirmIgnore:()=>{u(null),c(y.id)},onCancelIgnore:()=>u(null)},y.id);return t.jsxs("div",{className:"mb-4","data-testid":"feature-complete-proposed-plans",children:[m.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-[10px] uppercase tracking-wider mb-2 text-[var(--text-dim)]",children:"Suggested plans"}),t.jsx("ul",{className:"flex flex-col gap-2",children:m.map(b)})]}),g.length>0&&t.jsx(iy,{count:g.length,providerLabel:n,expanded:p,onToggle:()=>h(y=>!y),children:g.map(b)}),a&&t.jsx(md,{failure:a})]})}const $K=Object.freeze(Object.defineProperty({__proto__:null,FeatureCompleteProposedPlans:ly},Symbol.toStringTag,{value:"Module"}));function cy(e){return(e.status??"pending")==="pending"&&!As(e)}function OI(e,n,s){const r=Math.max(0,Math.ceil(e/s)-1),a=Math.min(Math.max(n,0),r),o=a*s;return{page:a,lastPage:r,start:o,end:Math.min(o+s,e)}}const yl=10;function dy({rows:e,loaded:n,listError:s,busyActions:r,errorsById:a,headReleaseFailure:o=null,initialPage:i=0,initialConfirmingId:c=null,onWrite:d,onIgnore:u}){const[p,h]=l.useState(i),[f,m]=l.useState(c),g=Ad(e.filter(cy)),x=g.length,b=OI(x,p,yl),y=g.slice(b.start,b.end),v=g.filter(_=>_.source==="feature-synthesis").length,j=s?t.jsx(tt,{text:`Failed to load suggested plans: ${s}`,className:"text-sm text-[var(--accent-red)]",rowClassName:"mt-3"}):null;return n?t.jsxs("div",{"data-testid":"suggested-plans-body",children:[j,x===0?t.jsx(rl,{state:"empty"}):t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"mt-3 flex flex-col gap-2",children:y.map(_=>t.jsx(Ed,{row:_,ideaTotal:v,busyAction:r[_.id],confirming:f===_.id,error:a[_.id],onWrite:()=>d(_.id),onRequestIgnore:()=>m(_.id),onConfirmIgnore:()=>{m(null),u(_.id)},onCancelIgnore:()=>m(null)},_.id))}),x>yl&&t.jsx(Og,{start:b.start,end:b.end,total:x,canPrev:b.page>0,canNext:b.page<b.lastPage,onPrev:()=>h(b.page-1),onNext:()=>h(b.page+1)})]}),o&&t.jsx(md,{failure:o})]}):t.jsx("div",{"data-testid":"suggested-plans-body",children:j??t.jsx(rl,{state:"loading"})})}const zK=Object.freeze(Object.defineProperty({__proto__:null,SUGGESTED_PLANS_PAGE_SIZE:yl,SuggestedPlansList:dy},Symbol.toStringTag,{value:"Module"}));function RI(e,n){const s=new Map(n.map(r=>[r.id,r]));return e.map(r=>{const a=s.get(r.id);return a?{...r,status:a.status,planSlug:a.planSlug}:r})}const EI={write:"plan",ignore:"ignore",copied:"record the copy of"};function AI(e){const n=uy(e.length>0);return{...n,rows:RI(e,n.rows)}}function uy(e){const{plansVersion:n}=Tn(),[s,r]=l.useState([]),[a,o]=l.useState({}),[i,c]=l.useState({}),[d,u]=l.useState(null),[p,h]=l.useState(!1),[f,m]=l.useState(null),g=l.useCallback(async()=>{try{const b=await fetch("/api/proposed-plans");if(!b.ok)throw new Error(`HTTP ${b.status}`);const y=await b.json();r(y.proposals??[]),h(!0),m(null)}catch(b){m(b instanceof Error?b.message:String(b))}},[]);l.useEffect(()=>{e&&g()},[g,e,n]);const x=l.useCallback(async(b,y)=>{o(v=>({...v,[b]:y})),c(({[b]:v,...j})=>j);try{const v=await fetch(`/api/proposed-plans/${encodeURIComponent(b)}/${y}`,{method:"POST"});if(!v.ok){const _=await v.json().catch(()=>({}));throw new Error(_.error??`HTTP ${v.status}`)}const j=await v.json().catch(()=>({}));j.headReleaseFailure&&u(j.headReleaseFailure),await g()}catch(v){const j=EI[y],_=v instanceof Error?v.message:String(v);c(w=>({...w,[b]:`Could not ${j} this suggestion: ${_}`}))}finally{o(({[b]:v,...j})=>j)}},[g]);return{rows:s,loaded:p,listError:f,busyActions:a,errorsById:i,headReleaseFailure:d,write:b=>x(b,"write"),ignore:b=>x(b,"ignore"),markCopied:b=>x(b,"copied")}}function zs({title:e,count:n,expanded:s,onToggle:r,testId:a}){return t.jsxs("button",{type:"button",onClick:r,"aria-expanded":s,"data-testid":a,className:"flex w-full items-center gap-2 bg-transparent py-1 text-left cursor-pointer group",children:[t.jsx("span",{"aria-hidden":"true",className:"text-[var(--text-dim)] text-xs leading-none transition-transform group-hover:text-[var(--text-primary)] "+(s?"rotate-0":"-rotate-90"),children:"⌄"}),t.jsx("span",{className:"text-sm text-[var(--text-primary)] "+(s?"font-medium":"font-normal"),children:e}),n!==void 0&&t.jsxs("span",{className:"text-sm text-[var(--text-dim)]",children:["(",n,")"]})]})}const BK=Object.freeze(Object.defineProperty({__proto__:null,PlanSectionHeader:zs},Symbol.toStringTag,{value:"Module"}));function py({initiallyExpanded:e=!1}){const[n,s]=l.useState(e),r=uy(n),a=r.loaded?r.rows.filter(cy).length:void 0;return t.jsxs("div",{className:"mt-5 border-t border-[var(--border-subtle)] pt-5",children:[t.jsx(zs,{title:"View plans suggested by the agent",count:a,expanded:n,onToggle:()=>s(o=>!o),testId:"suggested-plans-header"}),n&&t.jsx(dy,{rows:r.rows,loaded:r.loaded,listError:r.listError,busyActions:r.busyActions,errorsById:r.errorsById,headReleaseFailure:r.headReleaseFailure,onWrite:o=>void r.write(o),onIgnore:o=>void r.ignore(o)})]})}const WK=Object.freeze(Object.defineProperty({__proto__:null,SuggestedPlansSection:py},Symbol.toStringTag,{value:"Module"}));function hy({rows:e,reports:n,busyActions:s,errorsById:r,onCopied:a,onIgnore:o,writer:i,initiallyExpanded:c=!1}){const[d,u]=l.useState(null),[p,h]=l.useState(c),f=e.filter(As),m=f.filter(dl),g=Ad(f.filter(v=>!dl(v)&&v.status!=="ignored"&&v.status!=="fixed"));if(g.length===0&&m.length===0)return null;const{surfaced:x,tracked:b}=oy(g),y=v=>t.jsx(Wx,{row:v,report:n[v.id],busyAction:s[v.id],confirming:d===v.id,error:r[v.id],onCopied:()=>a(v.id),onRequestIgnore:()=>u(v.id),onConfirmIgnore:()=>{u(null),o(v.id)},onCancelIgnore:()=>u(null),writer:i},v.id);return t.jsxs("div",{className:"mb-4","data-testid":"feature-complete-codeyam-improvements",children:[t.jsx("p",{className:"text-[10px] uppercase tracking-wider mb-1 text-[var(--text-dim)]",children:"CodeYam Improvements"}),t.jsx("p",{className:"text-xs text-[var(--text-muted)] leading-relaxed mb-2",children:"These are rough edges in CodeYam itself, not changes to your app. If you don't mind clicking Copy and sending them to the CodeYam team, that would be really helpful."}),x.length>0&&t.jsx("ul",{className:"flex flex-col gap-2",children:x.map(y)}),(b.length>0||m.length>0)&&t.jsx(Hx,{count:b.length,expanded:p,onToggle:()=>h(v=>!v),decided:m.length>0?m.map(y):null,children:b.map(y)})]})}const HK=Object.freeze(Object.defineProperty({__proto__:null,FeatureCompleteCodeyamImprovements:hy},Symbol.toStringTag,{value:"Module"}));function fy({label:e,entries:n,labelColor:s,entryColor:r,labelTestId:a,entryTestId:o,entryKeyPrefix:i}){return n.length===0?null:t.jsxs("div",{children:[t.jsx("p",{className:"text-[10px] uppercase tracking-wider mb-1",style:{color:s},"data-testid":a,children:e}),t.jsx("ul",{className:"list-disc pl-4 flex flex-col gap-1",children:n.map(c=>t.jsx("li",{className:"text-xs leading-relaxed",style:{color:r},"data-testid":o,children:c},`${i}-${c}`))})]})}const qK=Object.freeze(Object.defineProperty({__proto__:null,FeatureCompleteBannerSection:fy},Symbol.toStringTag,{value:"Module"})),my="Help me figure out what to do next.";function gy({onSubmitPrompt:e,disabled:n}){return t.jsx("div",{className:"mt-4 pt-3 border-t border-[var(--border-subtle)] text-center",children:t.jsx("button",{type:"button",onClick:()=>e(my),disabled:n,className:"text-xs underline underline-offset-2 text-[var(--text-muted)] hover:text-[var(--text-primary)] transition cursor-pointer disabled:cursor-not-allowed disabled:opacity-50","data-testid":"build-launch-modal-not-sure",children:"Not sure what you need? Help me figure it out"})})}const UK=Object.freeze(Object.defineProperty({__proto__:null,NOT_SURE_PROMPT:my,NotSurePrompt:gy},Symbol.toStringTag,{value:"Module"}));function xy({severeWarnings:e}){return e.length===0?null:t.jsx("div",{className:"mb-3 p-3 rounded-md flex flex-col gap-2.5",style:{background:"var(--bg-deep)",border:"1px solid var(--border-default)"},"data-testid":"feature-complete-banner",children:t.jsx(fy,{label:"Read this first",entries:e,labelColor:"var(--accent-danger, #f87171)",entryColor:"var(--accent-danger, #f87171)",labelTestId:"feature-complete-warnings-label",entryTestId:"feature-complete-warning",entryKeyPrefix:"warning"})})}const YK=Object.freeze(Object.defineProperty({__proto__:null,FeatureCompleteBanner:xy},Symbol.toStringTag,{value:"Module"}));function by({summary:e}){return t.jsxs("div",{className:"mb-6","data-testid":"feature-complete-summary",children:[t.jsx("p",{className:"text-[11px] uppercase tracking-wider text-[var(--green-300)] mb-1",children:"Feature complete"}),t.jsxs("h2",{className:"flex items-start gap-2 text-lg font-semibold text-[var(--text-primary)] mb-3",children:[t.jsx("svg",{"data-testid":"feature-complete-check","aria-hidden":"true",width:"18",height:"18",viewBox:"0 0 16 16",fill:"none",stroke:"var(--green-300)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 mt-[5px]",children:t.jsx("path",{d:"M3 8.5l3.2 3.2L13 4.8"})}),t.jsx("span",{children:e.title})]}),t.jsx(xy,{severeWarnings:e.severeWarnings??[]}),e.summary&&t.jsx(Ft,{variant:"compact",children:e.summary})]})}const GK=Object.freeze(Object.defineProperty({__proto__:null,FeatureCompleteSummary:by},Symbol.toStringTag,{value:"Module"})),Bs={backgroundColor:"#2d2d2d",backgroundImage:"radial-gradient(circle, rgba(255,255,255,.16) .7px, transparent 1.1px)",backgroundSize:"12px 12px"},MI={...Bs,margin:"8px 8px 8px 0",borderRadius:14,border:"1px solid var(--border-default)",boxShadow:"0 1px 0 rgba(255,255,255,.04) inset, 0 10px 30px rgba(0,0,0,.35)",overflow:"hidden"};function vl({message:e="No page selected."}){return t.jsx("div",{"data-testid":"agent-html-empty",className:"w-full h-full flex items-center justify-center text-sm",style:{...Bs,color:"rgba(255,255,255,.5)"},children:e})}const VK=Object.freeze(Object.defineProperty({__proto__:null,AgentHtmlEmptyState:vl},Symbol.toStringTag,{value:"Module"}));function yy({warnings:e}){return e.length===0?null:t.jsx("ul",{className:"px-3 py-2 border-b text-xs opacity-80 list-disc list-inside",children:e.map(n=>t.jsx("li",{children:n},n))})}const KK=Object.freeze(Object.defineProperty({__proto__:null,AgentHtmlLintWarnings:yy},Symbol.toStringTag,{value:"Module"}));function vy({title:e,onBackToApp:n}){return t.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 py-2 border-b text-sm",children:[t.jsx("span",{className:"font-medium truncate",title:e,children:e}),t.jsx("button",{type:"button",onClick:n,className:"shrink-0 px-2 py-1 rounded border text-xs",children:"Back to app"})]})}const JK=Object.freeze(Object.defineProperty({__proto__:null,AgentHtmlPaneHeader:vy},Symbol.toStringTag,{value:"Module"})),Vh=5173;function Ms(e){if(e.startsWith("http"))try{return new URL(e).pathname}catch{return e}return e.split("?")[0]??e}function ko(e){return e?parseInt(e.port||(e.protocol==="https:"?"443":"80"),10):0}function No(e,{appPort:n,currentPort:s,previewOrigin:r}){return e.startsWith("http")?e:r?`${r}${e}`:s===n?e:`http://localhost:${n}${e}`}function jy(e,n,s,r,a){if(s&&s.length>0)return No(s,{appPort:r,currentPort:n,previewOrigin:a});const o=`/scenario/${e}`;return a?`${a}${o}`:n===Vh?o:`http://localhost:${Vh}${o}`}const II=["/apps","/entities","/app","/build","/history","/settings","/plan"];function wy(e){if(!e)return!1;const n=Ms(e);return II.some(s=>n===s||n.startsWith(`${s}/`))}function _y(e,n,s){const r=typeof window<"u"?ko(window.location):0;let a="";if(sR(e)==="component"?a=jy(e.slug,r,e.url,n,s):e.url&&(a=No(e.url,{appPort:n,currentPort:r,previewOrigin:s})),a&&!wy(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",e.slug),o?c.pathname+c.search+c.hash:c.toString()}catch{return a}return a}const dr="/credential-request",Sy="/setup-terminal",ky="/setup-browser";function Md(e){return e==="/design-exploration"||e==="/design-round"||e===dr||e===Sy||e===ky||Id(e)}function Id(e){const n=e.split("?")[0]??e;return n==="/agent-html"||n.startsWith("/agent-html/")}function Ny(e){const n=e.split("?")[0]??e;if(!n.startsWith("/agent-html/"))return null;const s=n.slice(12);return s.length>0?s:null}function DI(e){const n=Ny(e);return n?`/api/editor-preview-html/${n}.html`:null}function LI(e,n,s){return e.startsWith("http")||e?e:s?`${s}/results`:`http://127.0.0.1:${n}/results`}function FI(e,n,s){return e.startsWith("http")||e?e:s?`${s}/plan-preview`:`http://127.0.0.1:${n}/plan-preview`}function Cy(e,n){if(!n)return null;for(const s of e)for(const r of s.scenarios)if(r.slug===n||r.id===n)return r;return null}function $I({directPreviewPath:e,fallbackPreviewPath:n,previewKind:s,selectedScenario:r,port:a,previewOrigin:o}){return s==="blank"?"":e&&(s==="application"||s==="results"||s==="plan-preview"||s==="agent-html")?s==="results"?LI(e,a,o):s==="plan-preview"?FI(e,a,o):e.startsWith("http")||Md(e)?e:o?`${o}${e}`:`http://127.0.0.1:${a}${e}`:r?_y({slug:r.slug,scenarioType:r.scenarioType,componentName:r.componentName,url:r.url},a,o):n?n.startsWith("http")?n:o?`${o}${n}`:`http://127.0.0.1:${a}${n}`:""}function zI(e,n=Date.now()){const s=e.includes("?")?"&":"?";return`${e}${s}_cb=${n}`}function BI(e,n){const[s,r]=l.useState(null),[a,o]=l.useState(!1);return l.useEffect(()=>{if(o(!1),!e){r(null);return}let i=!1;return fetch("/api/editor-preview-html").then(c=>{if(!c.ok)throw new Error(`listing ${c.status}`);return c.json()}).then(c=>{if(i||!Array.isArray(c))return;const d=c.find(u=>u.name===e)??null;r(d),o(d===null)}).catch(()=>{}),()=>{i=!0}},[e,n]),{entry:s,missing:a}}function Ty({previewPath:e,onBackToApp:n,commandNonce:s}){const r=Ny(e),a=DI(e),{entry:o,missing:i}=BI(r,s);if(!r||!a)return t.jsx(vl,{});const c=()=>{fetch("/api/dev-mode-preview-nav",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:"/",dimension:"Desktop"})}).catch(()=>{})},d=(o==null?void 0:o.title)??r,u=(o==null?void 0:o.url)??a;return t.jsxs("div",{className:"w-full h-full flex flex-col",children:[t.jsx(vy,{title:d,onBackToApp:n??c}),t.jsx(yy,{warnings:(o==null?void 0:o.warnings)??[]}),i?t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(vl,{message:"No preview yet"})}):t.jsx("iframe",{src:u,title:d,sandbox:"allow-scripts",className:"flex-1 w-full border-0 bg-white"},u)]})}const XK=Object.freeze(Object.defineProperty({__proto__:null,AgentHtmlPreviewPane:Ty},Symbol.toStringTag,{value:"Module"}));function sr({color:e,testId:n,title:s,pulse:r=!1}){return t.jsx("span",{"data-testid":n,title:s,style:{backgroundColor:e},className:`mr-1.5 inline-block w-2 h-2 rounded-full ${r?"animate-pulse":""}`})}const QK=Object.freeze(Object.defineProperty({__proto__:null,NavTabDot:sr},Symbol.toStringTag,{value:"Module"}));function Py({busy:e,onCancel:n,onConfirm:s}){return t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[t.jsx("button",{type:"button",onClick:n,disabled:e,style:{padding:"8px 16px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)",borderRadius:6,fontSize:13,fontWeight:500,cursor:e?"wait":"pointer",opacity:e?.5:1,fontFamily:"inherit"},children:"Cancel"}),t.jsx("button",{type:"button",onClick:s,disabled:e,"data-testid":"plan-delete-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:e?"wait":"pointer",opacity:e?.5:1,fontFamily:"inherit"},children:e?"Deleting…":"Delete plan"})]})}const ZK=Object.freeze(Object.defineProperty({__proto__:null,PlanDeleteConfirmActions:Py},Symbol.toStringTag,{value:"Module"}));function Oy({dependents:e}){if(e.length===0)return null;const n=e.length===1;return t.jsxs("div",{"data-testid":"plan-delete-dependents",style:{display:"flex",flexDirection:"column",gap:6,padding:"10px 12px",border:"1px solid var(--accent-red, #ff5c5c)",borderRadius:6},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:8},children:[t.jsxs("span",{style:{color:"var(--accent-red)",fontSize:12},children:[e.length," queued plan",n?"":"s"," depend",n?"s":""," ","on this one and will stay blocked"]}),t.jsx(ct,{variant:"subtle",ariaLabel:"Copy the list of blocked plans",text:e.map(s=>`${s.title} (${s.slug})`).join(`
|
|
29
|
+
`)})]}),t.jsx("ul",{style:{margin:0,paddingLeft:18,color:"var(--text-secondary)",fontSize:12},children:e.map(s=>t.jsx("li",{children:s.title},s.slug))})]})}const eJ=Object.freeze(Object.defineProperty({__proto__:null,PlanDeleteDependentsWarning:Oy},Symbol.toStringTag,{value:"Module"}));function Ry({title:e,filePath:n}){return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsx("h2",{style:{margin:0,color:"var(--text-primary)",fontSize:16,fontWeight:600},children:"Delete queued plan?"}),t.jsx("p",{style:{margin:0,color:"var(--text-primary)",fontSize:13},children:e}),t.jsx("p",{style:{margin:0,color:"var(--text-muted)",fontSize:12},"data-testid":"plan-delete-file-path",children:n}),t.jsx("p",{style:{margin:0,color:"var(--text-secondary)",fontSize:13},children:"This removes the plan file and any co-located assets, and stages the deletion in git. Nothing is committed — the removal lands with your next commit."})]})}const tJ=Object.freeze(Object.defineProperty({__proto__:null,PlanDeleteConfirmHeader:Ry},Symbol.toStringTag,{value:"Module"}));function Ey({title:e,slug:n,filePath:s,dependents:r,busy:a,error:o,onCancel:i,onConfirm:c}){return l.useEffect(()=>{const d=u=>{u.key==="Escape"&&!a&&i()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[a,i]),t.jsx("div",{role:"presentation",onClick:()=>{a||i()},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:t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Delete queued plan?","data-slug":n,onClick:d=>d.stopPropagation(),style:{background:"var(--bg-elevated, #141414)",border:"1px solid var(--border-default)",borderRadius:12,padding:24,width:"min(460px, 100%)",display:"flex",flexDirection:"column",gap:16,fontFamily:"'IBM Plex Mono', monospace",boxShadow:"0 20px 60px rgba(0,0,0,0.5)"},children:[t.jsx(Ry,{title:e,filePath:s}),t.jsx(Oy,{dependents:r}),o&&t.jsx(Lt,{severity:"error",testId:"plan-delete-error",headline:"The plan wasn't deleted",explanation:"CodeYam asked the editor to remove this plan and the request came back with an error. The plan is still queued and nothing on disk was changed.",nextAction:"Try Delete plan again. If it keeps failing, copy this report — the plan file may have been moved or removed outside the editor.",diagnostics:o}),t.jsx(Py,{busy:a,onCancel:i,onConfirm:c})]})})}const nJ=Object.freeze(Object.defineProperty({__proto__:null,PlanDeleteConfirmModal:Ey},Symbol.toStringTag,{value:"Module"}));function Ay({onClick:e,disabled:n}){return t.jsx("button",{type:"button",onClick:e,disabled:n,className:"px-2.5 py-1 text-xs rounded border border-[var(--border-default)] bg-transparent text-[var(--accent-red)] hover:border-[var(--accent-red)] disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer",children:"Delete"})}const sJ=Object.freeze(Object.defineProperty({__proto__:null,PlanRowDeleteButton:Ay},Symbol.toStringTag,{value:"Module"})),WI="editor",HI="preview";function qI(e){if(!e)return null;let n;try{n=new URL(e)}catch{return null}const s=n.hostname.split(".");if(s.length<3||s[1]!==WI)return null;const r=[s[0],HI,...s.slice(2)].join(".");return`${n.protocol}//${r}`}async function UI(e,n=4e3){if(!e)return"unknown";const s=new AbortController,r=setTimeout(()=>s.abort(),n);try{return await fetch(e,{credentials:"include",mode:"no-cors",redirect:"follow",signal:s.signal}),"answers"}catch{return s.signal.aborted?"unknown":"absent"}finally{clearTimeout(r)}}function Ua(e){return`codeyam-editor editor config-override previewOrigin ${e}`}function Dd(e,n=!0){const s=qI(e),[r,a]=l.useState(!1);return l.useEffect(()=>{if(!n||!s){a(!1);return}let o=!1;return UI(s).then(i=>{o||a(i==="answers")}),()=>{o=!0}},[n,s]),r&&s?s:null}function YI(e){return`This editor is running on ${e.provider}, which can serve the preview on a public address — it just needs to be told which port to front. Add the block below to ${e.file}, or run this, which adds it for you after confirming: ${e.setupCommand}`}function GI(e){return e?"Nothing to do, and nothing you did caused this — this machine is one we run, and a preview host is being provisioned for it automatically. The preview will move to it on its own, without a restart or a reload.":"Not something you can change from here: a dedicated preview host has to be provisioned for this machine — a preview subdomain alongside the editor's — and the preview will move to it on its own. Copy this report and send it to whoever set the machine up."}function My({onDismiss:e,hint:n=null,onManagedFleetVm:s=!1,editorOrigin:r}){const a=r??(typeof window<"u"?window.location.origin:null),o=Dd(a),i=o!==null,c=i?`A preview host for this machine already exists and is answering: ${o}. Point the preview at it with:
|
|
30
|
+
|
|
31
|
+
${Ua(o)}
|
|
32
|
+
|
|
33
|
+
It takes effect immediately — the editor reloads its config in place, so no restart is needed.
|
|
34
|
+
|
|
35
|
+
If the preview then comes up blank, open ${o} in its own tab once and sign in there. Access is granted per address, and the sign-in page refuses to load inside a frame — so the first visit has to be a normal tab, and it only has to happen once.`:n?YI(n):GI(s);return t.jsx(Lt,{severity:"warning",testId:"preview-dedicated-origin-notice",className:"flex w-full flex-col gap-3 border-b border-l-4 px-4 py-3 text-sm",headline:i?"The preview is not using this machine's preview host":"No dedicated preview origin is provisioned",explanation:i?"This app is set to preview from its own origin, and this machine has one — but the preview is still being served from the /__codeyam_preview subpath, so deep links and reloads may mis-route.":"This app is set to preview from its own origin, but this host has none that your browser can reach — so the preview is still being served from the /__codeyam_preview subpath. It works, but deep links and reloads may mis-route.",nextAction:c,diagnostics:i?Ua(o):(n==null?void 0:n.stanza)??void 0,actions:[{label:"Dismiss",onClick:e,variant:"secondary",ariaLabel:"Dismiss preview origin notice",testId:"preview-dedicated-origin-notice-dismiss"}]})}const rJ=Object.freeze(Object.defineProperty({__proto__:null,PreviewDedicatedOriginNotice:My},Symbol.toStringTag,{value:"Module"}));function Iy({title:e,body:n,spinner:s,restartCount:r,variant:a}){return t.jsx("div",{"data-testid":"preview-unhealthy-overlay","data-variant":a,className:"absolute inset-0 flex flex-col items-center justify-center z-50 animate-in fade-in duration-300",style:{background:"var(--bg-deep, #1b1b1b)"},children:t.jsxs("div",{className:"flex max-w-xs flex-col items-center p-6 text-center",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[s?t.jsx("span",{"aria-hidden":"true","data-testid":"preview-waiting-spinner",className:"h-3 w-3 shrink-0 animate-spin rounded-full border-[1.5px] border-[rgba(255,255,255,.12)] border-t-[var(--working)]"}):t.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"h-3 w-3 shrink-0 text-[var(--text-muted)]","aria-hidden":"true",children:[t.jsx("rect",{x:"6",y:"5",width:"4",height:"14",rx:"1"}),t.jsx("rect",{x:"14",y:"5",width:"4",height:"14",rx:"1"})]}),t.jsx("h3",{className:"text-[13.5px] font-medium text-[var(--text-secondary)]",children:e}),r>0&&t.jsxs("span",{className:"text-[11.5px] text-[var(--text-dim)]",children:["#",r]})]}),t.jsx("p",{className:"mt-1.5 text-[12px] leading-relaxed text-[var(--text-dim)]",children:n})]})})}const aJ=Object.freeze(Object.defineProperty({__proto__:null,PreviewWaitingOverlay:Iy},Symbol.toStringTag,{value:"Module"}));function ft({widthPct:e,heightPx:n,variant:s="surface"}){const r=s==="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 t.jsx("div",{style:{width:`${e}%`,height:n,borderRadius:4,background:r,backgroundSize:"200% 100%",animation:"mockup-skeleton-shimmer 1.6s linear infinite",opacity:s==="surface"?.85:1}})}const oJ=Object.freeze(Object.defineProperty({__proto__:null,SkeletonBar:ft},Symbol.toStringTag,{value:"Module"}));function Co(){return t.jsx("style",{children:`
|
|
36
|
+
@keyframes mockup-skeleton-shimmer {
|
|
37
|
+
0% { background-position: -200% 0; }
|
|
38
|
+
100% { background-position: 200% 0; }
|
|
39
|
+
}
|
|
40
|
+
`})}const iJ=Object.freeze(Object.defineProperty({__proto__:null,SkeletonShimmerKeyframes:Co},Symbol.toStringTag,{value:"Module"}));function Dy(){return t.jsx("li",{"aria-hidden":"true",className:"border border-[var(--border-subtle)] rounded-lg bg-[var(--bg-surface,transparent)]",children:t.jsxs("div",{className:"px-3 py-2 flex items-center justify-between gap-3",children:[t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx(ft,{widthPct:42,heightPx:14})}),t.jsx(ft,{widthPct:6,heightPx:12})]})})}function Ld({count:e,testId:n,label:s="Loading plans"}){return t.jsxs(t.Fragment,{children:[t.jsx(Co,{}),t.jsxs("div",{role:"status","aria-busy":"true",children:[t.jsx("span",{className:"sr-only",children:s}),t.jsx("ul",{className:"mt-3 flex flex-col gap-2","data-testid":n??"plan-row-skeleton-list",children:Array.from({length:Math.max(e,1)},(r,a)=>t.jsx(Dy,{},a))})]})]})}const lJ=Object.freeze(Object.defineProperty({__proto__:null,PlanRowSkeleton:Dy,PlanRowSkeletonList:Ld},Symbol.toStringTag,{value:"Module"}));function Ly({count:e}){return t.jsx("div",{style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:e===1?"1 file queued":`${e} files queued`})}const cJ=Object.freeze(Object.defineProperty({__proto__:null,PendingFileCountLine:Ly},Symbol.toStringTag,{value:"Module"}));function Fy({fileInputRef:e,folderInputRef:n,onFolderPick:s}){const[r,a]=l.useState(!1),o=l.useRef(null);return t.jsxs("div",{style:{position:"relative",marginTop:"var(--spacing-xs, 4px)",marginBottom:"var(--spacing-sm, 8px)"},children:[t.jsx("input",{ref:n,type:"file",...dg,onChange:s,style:{display:"none"}}),t.jsx("button",{ref:o,type:"button","aria-haspopup":"menu","aria-expanded":r,onClick:()=>a(i=>!i),style:{padding:0,fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)",background:"transparent",border:"none",cursor:"pointer",textDecoration:"underline"},children:"or choose files or a folder ▾"}),r&&t.jsx(ug,{onChooseFiles:()=>{var i;return(i=e.current)==null?void 0:i.click()},onChooseFolder:()=>{var i;return(i=n.current)==null?void 0:i.click()},onClose:()=>a(!1),triggerRef:o})]})}const dJ=Object.freeze(Object.defineProperty({__proto__:null,ChooseAssetsButton:Fy},Symbol.toStringTag,{value:"Module"}));function $y({value:e}){const[n,s]=l.useState(!1),r=async a=>{a.stopPropagation();try{await navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),2e3)}catch{}};return t.jsx("button",{type:"button",onClick:r,"data-testid":"copy-path-button",title:n?"Copied":`Copy ${e}`,"aria-label":n?"Copied":`Copy ${e}`,className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded border border-[var(--border-default)] bg-[var(--bg-card)] text-[10px] leading-none text-[var(--text-dim)] hover:text-[var(--text-primary)] cursor-pointer transition-colors",children:n?"✓":"⧉"})}const uJ=Object.freeze(Object.defineProperty({__proto__:null,CopyPathButton:$y},Symbol.toStringTag,{value:"Module"}));function zy({slug:e,count:n,tooltip:s}){return n<=0?null:t.jsxs("span",{"data-testid":`plan-row-blocked-${e}`,title:s,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 · ",n," dep",n===1?"":"s"]})}const pJ=Object.freeze(Object.defineProperty({__proto__:null,PlanRowBlockedChip:zy},Symbol.toStringTag,{value:"Module"}));function Fd({children:e,testId:n}){return t.jsx("span",{"data-testid":n,className:"text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded border border-[var(--border-default)] bg-[var(--bg-card)] text-[var(--text-dim)]",children:e})}const hJ=Object.freeze(Object.defineProperty({__proto__:null,PlanRowTag:Fd},Symbol.toStringTag,{value:"Module"}));function $d({mode:e}){return t.jsx(Fd,{children:e})}const fJ=Object.freeze(Object.defineProperty({__proto__:null,PlanModeBadge:$d},Symbol.toStringTag,{value:"Module"}));function zd({title:e,timestamp:n,tone:s="primary"}){return t.jsxs("span",{className:"flex items-baseline gap-2 min-w-0",children:[t.jsx("span",{className:"min-w-0 truncate text-sm "+(s==="muted"?"text-[var(--text-muted)]":"text-[var(--text-primary)]"),children:e}),t.jsx("span",{className:"shrink-0 text-[10px] text-[var(--text-dim)] whitespace-nowrap",children:Un(n)})]})}const mJ=Object.freeze(Object.defineProperty({__proto__:null,PlanRowTitleWithAge:zd},Symbol.toStringTag,{value:"Module"}));function By({slug:e,handleRef:n,attributes:s,listeners:r}){return t.jsx("span",{ref:n,"data-testid":`plan-drag-${e}`,"aria-label":"Reorder plan",...s??{},...r??{},onClick:a=>a.stopPropagation(),className:"cursor-grab active:cursor-grabbing text-[var(--text-dim)] select-none leading-none px-1 -ml-1",children:"⋮⋮"})}const gJ=Object.freeze(Object.defineProperty({__proto__:null,PlanRowDragHandle:By},Symbol.toStringTag,{value:"Module"}));function Wy({slug:e,identity:n,step:s,age:r,dead:a}){return t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-[var(--text-muted)]",children:[t.jsxs("span",{"data-testid":`plan-claim-identity-${e}`,children:["claimed by ",n]}),s&&t.jsx("span",{"data-testid":`plan-claim-step-${e}`,children:s}),t.jsxs("span",{"data-testid":`plan-claim-started-${e}`,children:["started ",r]}),a&&t.jsx("span",{className:"text-[var(--text-muted)]",children:"(inactive)"})]})}const xJ=Object.freeze(Object.defineProperty({__proto__:null,InFlightPlanRowMeta:Wy},Symbol.toStringTag,{value:"Module"}));function Hy({slug:e,title:n,timestamp:s,position:r,author:a,dragHandleRef:o,dragHandleAttributes:i,dragHandleListeners:c}){return t.jsxs(t.Fragment,{children:[o&&t.jsx(By,{slug:e,handleRef:o,attributes:i,listeners:c}),typeof r=="number"&&t.jsxs("span",{className:"text-xs text-[var(--text-dim)] tabular-nums min-w-[1.25rem]",children:[r,"."]}),a&&t.jsx(So,{author:a}),t.jsx("span",{className:"flex-1 min-w-0",children:t.jsx(zd,{title:n,timestamp:s})})]})}const bJ=Object.freeze(Object.defineProperty({__proto__:null,PlanRowIdentity:Hy},Symbol.toStringTag,{value:"Module"}));function qy(e){return{dead:e.sessionAlive===!1}}function Uy({claim:e,staleFetch:n=!1}){const s=us(),{dead:r}=qy(e),a=e.claimedBy.agentProvider??"agent",o=r?" (inactive)":"",i=Un(e.claimedBy.startedAt,s),c=e.source==="local"?`● this session · started ${i}`:e.source==="same-machine"?`claimed by ${a}@${e.claimedBy.machine} (same machine) · ${i}`:`claimed by ${a}@${e.claimedBy.machine} · ${i}`;return t.jsxs("span",{"data-testid":`plan-row-claim-badge-${e.slug}`,title:`Source: ${e.source}${o}${n?" (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 yJ=Object.freeze(Object.defineProperty({__proto__:null,PlanRowClaimBadge:Uy},Symbol.toStringTag,{value:"Module"}));function VI({isAgentBuilding:e=!1,unsatisfiedDepCount:n=0,claim:s}){return e?"building":n>0?"dependencies":s&&s.source!=="local"?"claimed":null}function Yy({slug:e,mode:n,expanded:s,onRun:r,launching:a=!1,blocked:o=!1,unsatisfiedDepCount:i=0,unsatisfiedDepTooltip:c,claim:d,staleFetch:u=!1}){return t.jsxs(t.Fragment,{children:[t.jsx($d,{mode:n}),t.jsx(zy,{slug:e,count:i,tooltip:c}),d&&t.jsx(Uy,{claim:d,staleFetch:u}),r&&t.jsx(ad,{slug:e,onRun:r,launching:a,blockedReason:VI({isAgentBuilding:o,unsatisfiedDepCount:i,claim:d})}),t.jsx(Dr,{expanded:s,testId:`plan-row-chevron-${e}`})]})}const vJ=Object.freeze(Object.defineProperty({__proto__:null,PlanRowControls:Yy},Symbol.toStringTag,{value:"Module"}));function Ya({children:e,tone:n,spacing:s="normal",testId:r}){const a=n==="error"?"text-[var(--accent-red)]":"text-[var(--text-muted)]",o=s==="tight"?"mt-2":"mt-3";return t.jsx("p",{"data-testid":r,className:`${o} text-sm ${a}`,children:e})}const jJ=Object.freeze(Object.defineProperty({__proto__:null,PlanSectionStatus:Ya},Symbol.toStringTag,{value:"Module"}));function To(e=dR){const[n,s]=l.useState(null),r=l.useCallback(d=>(s(d.error),d.files),[]),a=l.useCallback(async d=>r(await pg(d,e)),[r,e]),o=l.useCallback(d=>r(uR(d,e)),[r,e]),i=l.useCallback(d=>r(pR(d,e)),[r,e]),c=l.useCallback(()=>s(null),[]);return{fromDrop:a,fromFileInput:o,fromFolderInput:i,error:n,clearError:c}}function KI(e){return e.split("/").slice(-2).join("/")}const jl="#6b6b70",JI={doc:["#2F6FEB","Word document"],docx:["#2F6FEB","Word document"],pdf:["#E5484D","PDF"],xls:["#1F9D55","Spreadsheet"],xlsx:["#1F9D55","Spreadsheet"],csv:["#1F9D55","Spreadsheet"],ppt:["#E8712A","Presentation"],pptx:["#E8712A","Presentation"],key:["#E8712A","Presentation"],fig:["#A259FF","Figma file"],sketch:["#E8A33A","Sketch file"],md:["#56657A","Markdown"],txt:[jl,"Text"]},XI=new Set(["png","jpg","jpeg","gif","webp","svg","avif"]);function QI(e){return e<1024*1024?`${Math.max(1,Math.round(e/1024))} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function ZI(e,n){const s=e.lastIndexOf("."),r=s>0&&s<e.length-1?e.slice(s+1).toLowerCase():"",a=QI(n);if(XI.has(r))return{ext:r.slice(0,4),color:jl,kind:"Image",size:a,isImage:!0};const o=JI[r];return o?{ext:r.slice(0,4),color:o[0],kind:o[1],size:a,isImage:!1}:{ext:r?r.slice(0,4):"file",color:jl,kind:r?`${r.toUpperCase()} file`:"File",size:a,isImage:!1}}function Gy(e){const[n,s]=l.useState(null);return l.useEffect(()=>{if(!e||typeof URL.createObjectURL!="function"){s(null);return}const r=URL.createObjectURL(e);return s(r),()=>URL.revokeObjectURL(r)},[e]),n}function zr({file:e,name:n=e.name,onRemove:s}){const r=ZI(e.name,e.size),a=Gy(r.isImage?e:null);return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:8,maxWidth:230,padding:4,borderRadius:9,background:"#232325",border:"1px solid rgba(255,255,255,.12)",boxShadow:"0 1px 0 rgba(255,255,255,.06) inset, 0 3px 8px rgba(0,0,0,.22)",fontSize:12,color:"var(--text-primary)"},children:[a?t.jsx("span",{"aria-hidden":"true",style:{flex:"none",width:28,height:28,borderRadius:5,background:`center / cover url("${a}")`}}):t.jsx("span",{"aria-hidden":"true","data-testid":"file-type-icon",style:{flex:"none",position:"relative",width:22,height:28,borderRadius:"3px 7px 3px 3px",background:r.color,display:"grid",placeItems:"end center",paddingBottom:3,fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:6.5,fontWeight:600,letterSpacing:".02em",color:"#fff",textTransform:"uppercase",overflow:"hidden"},children:r.ext}),t.jsxs("span",{style:{display:"flex",flexDirection:"column",minWidth:0,lineHeight:1.2},children:[t.jsx("span",{title:n,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontWeight:500},children:KI(n)}),t.jsxs("span",{style:{fontSize:10.5,color:"#a8a8ae"},children:[r.kind," · ",r.size]})]}),t.jsx("button",{type:"button","aria-label":`Remove ${n}`,onClick:s,style:{flex:"none",width:20,height:20,borderRadius:5,border:"none",background:"none",color:"#a8a8ae",cursor:"pointer",fontSize:13},children:"×"})]})}const wJ=Object.freeze(Object.defineProperty({__proto__:null,OnboardingFileChip:zr},Symbol.toStringTag,{value:"Module"})),Kh=84,Jh=320;function Ws({value:e,onChange:n,testId:s,placeholder:r="Describe the change you want",onSubmit:a,canSubmit:o=!0,files:i=[],onAddFiles:c,onRemoveFile:d,busy:u=!1,error:p=null,minHeight:h=Kh}){const f=l.useRef(null),[m,g]=l.useState(!1),x=To(),b=j=>{j.length>0&&(c==null||c(j))},y=p??x.error;l.useLayoutEffect(()=>{const j=f.current;if(!j)return;j.style.height="auto";const _=Math.min(Jh,Math.max(h,j.scrollHeight));j.style.height=`${_}px`,j.style.overflowY=j.scrollHeight>Jh?"auto":"hidden"},[e,h]);const v=u?`Saving ${i.length===1?i[0].relativePath:`${i.length} files`}…`:i.length>0?`${i.length} file${i.length>1?"s":""} attached`:"Drop files, folders, or screenshots";return t.jsxs("div",{className:"mt-4",children:[y&&t.jsx("div",{role:"alert",className:"mb-1.5 text-xs text-[var(--accent-danger,#f87171)]",children:y}),t.jsxs("div",{"data-testid":`${s}-box`,"data-dragging":m?"true":"false",onDragOver:j=>{c&&(j.preventDefault(),g(!0))},onDragLeave:j=>{j.currentTarget.contains(j.relatedTarget)||g(!1)},onDrop:j=>{c&&(j.preventDefault(),g(!1),j.dataTransfer&&x.fromDrop(j.dataTransfer).then(b))},className:`rounded-2xl border bg-[var(--bg-input)] transition-colors focus-within:border-[var(--line-strong)] ${m?"border-dashed border-[var(--accent-active)]":"border-[rgba(255,255,255,.09)]"}`,children:[t.jsx("textarea",{ref:f,value:e,onChange:j=>n(j.target.value),onKeyDown:j=>{!a||u||j.key!=="Enter"||j.shiftKey||j.nativeEvent.isComposing||(j.preventDefault(),a())},onPaste:j=>{var w;if(!c)return;const _=Array.from(((w=j.clipboardData)==null?void 0:w.files)??[]);_.length!==0&&(j.preventDefault(),x.clearError(),c(uo(_)))},placeholder:r,rows:h<Kh?1:3,disabled:u,"data-testid":s,"aria-label":r,style:{minHeight:h},className:"block w-full resize-none bg-transparent px-4 pt-3.5 pb-1 text-sm leading-relaxed text-[var(--text-primary)] placeholder:text-[var(--text-dim)] focus:outline-none"}),i.length>0&&t.jsx("div",{"aria-label":"Attached files","data-testid":`${s}-attachments`,className:`flex flex-wrap gap-1.5 px-3 pt-1.5 ${u?"opacity-60":""}`,children:i.map(({file:j,relativePath:_},w)=>t.jsx(zr,{file:j,name:_,onRemove:()=>d==null?void 0:d(w)},`${_}-${w}`))}),(c||a)&&t.jsxs("div",{className:"flex items-center gap-2 px-3 pt-2 pb-3",children:[c&&t.jsxs(t.Fragment,{children:[t.jsx(xo,{onPickFiles:j=>b(x.fromFileInput(j)),onPickFolder:j=>b(x.fromFolderInput(j)),disabled:u,ariaLabel:"Add files",title:"Add files, a folder, or screenshots",testId:`${s}-add-files`,fileInputTestId:`${s}-file-input`,folderInputTestId:`${s}-folder-input`,className:"grid h-8 w-8 flex-none place-items-center rounded-lg border border-[var(--line-strong)] bg-[rgba(255,255,255,.07)] text-lg leading-none text-[var(--text-primary)] cursor-pointer transition-colors hover:border-white/[0.35] hover:bg-[rgba(255,255,255,.16)] disabled:cursor-not-allowed",children:t.jsx("span",{"aria-hidden":"true",children:"+"})}),t.jsx("span",{className:"min-w-0 truncate text-xs text-[var(--text-dim)]",children:v})]}),t.jsx("span",{className:"flex-1"}),a&&t.jsx("button",{type:"button",onClick:a,disabled:u||!o,"aria-label":"Send",title:"Send (Enter)","data-testid":`${s}-send`,className:"grid h-9 w-9 flex-none place-items-center rounded-[10px] bg-[var(--accent-active)] text-[var(--text-on-accent)] transition-opacity hover:opacity-90 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50",children:t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M12.5 3.5v4a2 2 0 0 1-2 2H3.5M6 7l-2.5 2.5L6 12"})})})]})]})]})}const _J=Object.freeze(Object.defineProperty({__proto__:null,ChangeDescriptionInput:Ws},Symbol.toStringTag,{value:"Module"})),Vy=t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M6 9.5l6 6 6-6"})}),Ky=t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:t.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"})}),Jy=t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z"}),t.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),Xy=t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3 3l18 18M10.6 10.6a3 3 0 0 0 4.2 4.2M9.9 5.2A9.6 9.6 0 0 1 12 5c6.5 0 10 7 10 7a15.4 15.4 0 0 1-3.3 4M6.2 6.2A15.5 15.5 0 0 0 2 12s3.5 7 10 7a9.7 9.7 0 0 0 3.1-.5"})}),Qy=t.jsxs("svg",{width:"26",height:"26",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M12 3a9 9 0 1 0 9 9"}),t.jsx("path",{d:"M12 3v9l6 3"}),t.jsx("path",{d:"M16 4h5V9"})]}),SJ=Object.freeze(Object.defineProperty({__proto__:null,CHAT_ICON:Ky,CHEVRON_ICON:Vy,EMPTY_MARK_ICON:Qy,EYE_ICON:Jy,EYE_OFF_ICON:Xy},Symbol.toStringTag,{value:"Module"}));async function Bd(e){const n=new FormData;for(const a of e)n.append("path",a.relativePath),n.append("description",a.description),n.append("file",a.file,a.file.name);const s=await fetch("/api/editor-design-assets",{method:"POST",body:n});if(!s.ok)throw new Error(s.status===413?"That file is too large to add.":`Could not save assets (status ${s.status}).`);return(await s.json()).written??e.map(a=>a.relativePath)}async function Po(e){const n=Date.now();return await Bd(e.map(({file:s,relativePath:r},a)=>({id:`attach-${n}-${a}`,file:s,relativePath:r,description:""}))),VA(e.map(s=>s.relativePath))}function eD(e,n){if(!n.has(e))return e;const s=e.lastIndexOf("/"),r=e.slice(0,s+1),a=e.slice(s+1),o=a.lastIndexOf("."),i=o>0?a.slice(0,o):a,c=o>0?a.slice(o):"";let d=2;for(;n.has(`${r}${i}-${d}${c}`);)d+=1;return`${r}${i}-${d}${c}`}function Oo(){const[e,n]=l.useState([]),[s,r]=l.useState(!1),[a,o]=l.useState(null);return{files:e,addFiles:d=>n(u=>{const p=new Set(u.map(f=>f.relativePath)),h=[...u];for(const f of d){const m=eD(f.relativePath,p);p.add(m),h.push({file:f.file,relativePath:m})}return h}),removeFile:d=>n(u=>u.filter((p,h)=>h!==d)),clear:()=>n([]),saving:s,error:a,save:async()=>{if(o(null),e.length===0)return"";r(!0);try{return await Po(e)}catch(d){return o(d instanceof Error?d.message:"Couldn't add those files."),null}finally{r(!1)}}}}function Wd({draft:e,onDraftChange:n,onSubmit:s,onAsk:r,placeholder:a,testId:o}){const i=l.useRef(null),c=Oo(),d=()=>{var u;if(c.files.length===0){(u=i.current)==null||u.requestSubmit();return}c.save().then(p=>{p!==null&&(c.clear(),r==null||r([p,e.trim()].filter(Boolean).join(" ")))})};return t.jsx("form",{ref:i,onSubmit:s,children:t.jsx(Ws,{value:e,onChange:n,testId:o,placeholder:a,onSubmit:d,files:c.files,onAddFiles:c.addFiles,onRemoveFile:c.removeFile,busy:c.saving,error:c.error,minHeight:40})})}const kJ=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesComposer:Wd},Symbol.toStringTag,{value:"Module"})),tD=[{prompt:"Import my services from .env",label:"Import from .env"},{prompt:"Scan package.json and Cargo.toml for services",label:t.jsx(t.Fragment,{children:"Scan package.json & Cargo.toml"})},{prompt:"Help me add a service manually",label:"Add one manually"}];function Zy({draft:e,onDraftChange:n,onSubmit:s,onAsk:r,brokerStarter:a}){return t.jsx("div",{className:"xsvc-empty-wrap",children:t.jsxs("div",{className:"xsvc-empty-card",children:[t.jsx("div",{className:"xsvc-empty-mark","aria-hidden":"true",children:Qy}),t.jsx("h2",{children:"No external services mapped yet"}),t.jsx("p",{children:"Tell the AI what this project relies on and it keeps everything organized: it tracks renewals, flags missing keys, and answers questions about your stack."}),t.jsxs("div",{className:"xsvc-chat-hero",children:[t.jsxs("div",{className:"xsvc-lead",children:[Ky,"Chat with the AI"]}),t.jsx(Wd,{draft:e,onDraftChange:n,onSubmit:s,onAsk:r,placeholder:"e.g. We use Anthropic for the AI, Vercel for hosting, and our domain is codeyam.com",testId:"xsvc-empty-input"}),t.jsxs("div",{className:"xsvc-chips",children:[tD.map(o=>t.jsxs("button",{type:"button",className:"xsvc-chip",onClick:()=>r==null?void 0:r(o.prompt),children:[t.jsx("span",{className:"g",children:"↳"}),o.label]},o.prompt)),a?t.jsxs("button",{type:"button",className:"xsvc-chip",onClick:a.onSelect,children:[t.jsx("span",{className:"g",children:"✦"}),a.label]}):null]})]})]})})}const NJ=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesEmptyState:Zy},Symbol.toStringTag,{value:"Module"})),ze=({children:e})=>t.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e}),Xh={vercel:t.jsx(ze,{children:t.jsx("path",{d:"M12 4l8 14H4z",fill:"currentColor",stroke:"none"})}),netlify:t.jsxs(ze,{children:[t.jsx("path",{d:"M12 3l9 9-9 9-9-9z"}),t.jsx("path",{d:"M12 8v8M8 12h8"})]}),cloudflare:t.jsx(ze,{children:t.jsx("path",{d:"M6 16h11a3 3 0 0 0 .3-6A5 5 0 0 0 8 9.2 4 4 0 0 0 6 16z"})}),fly:t.jsxs(ze,{children:[t.jsx("circle",{cx:"12",cy:"10",r:"6"}),t.jsx("path",{d:"M9 15l-1 5 4-2 4 2-1-5"})]}),github:t.jsxs(ze,{children:[t.jsx("circle",{cx:"12",cy:"12",r:"8"}),t.jsx("path",{d:"M9 20v-3c0-1 .5-1.6 1-2-2.3-.3-3.8-1.2-3.8-4a3 3 0 0 1 .8-2 2.8 2.8 0 0 1 .1-2s.8-.2 2.2.9a8 8 0 0 1 4 0c1.4-1.1 2.2-.9 2.2-.9a2.8 2.8 0 0 1 .1 2 3 3 0 0 1 .8 2c0 2.8-1.5 3.7-3.8 4 .5.4 1 1 1 2v3"})]}),anthropic:t.jsx(ze,{children:t.jsx("path",{d:"M12 4v16M4 12h16M6.3 6.3l11.4 11.4M17.7 6.3L6.3 17.7"})}),neon:t.jsx(ze,{children:t.jsx("path",{d:"M5 19V5l14 14V5"})}),stripe:t.jsx(ze,{children:t.jsx("path",{d:"M6 8.5c0-1.4 1.5-2.5 3.5-2.5S13 6.8 13.4 8M6 15.5c0 1.4 1.5 2.5 3.5 2.5S13 17.2 13.4 16M9.5 6v12"})})},Qh={"Code hosting":t.jsxs(ze,{children:[t.jsx("circle",{cx:"6",cy:"7",r:"2.4"}),t.jsx("circle",{cx:"6",cy:"17",r:"2.4"}),t.jsx("circle",{cx:"17",cy:"9",r:"2.4"}),t.jsx("path",{d:"M6 9.4v5.2M17 11.4c0 3-3 3.6-6 4.2"})]}),"Package registry":t.jsxs(ze,{children:[t.jsx("path",{d:"M12 3l8 4.2v9.6L12 21l-8-4.2V7.2z"}),t.jsx("path",{d:"M4 7.2l8 4.3 8-4.3M12 11.5V21"})]}),"Cloud platform":t.jsx(ze,{children:t.jsx("path",{d:"M7 18h10a3.6 3.6 0 0 0 .3-7.2A5.6 5.6 0 0 0 6.8 9.6 3.9 3.9 0 0 0 7 18z"})}),"AI provider":t.jsxs(ze,{children:[t.jsx("path",{d:"M12 3v3.5M12 17.5V21M3 12h3.5M17.5 12H21"}),t.jsx("path",{d:"M6.3 6.3l2.5 2.5M15.2 15.2l2.5 2.5M17.7 6.3l-2.5 2.5M8.8 15.2l-2.5 2.5"}),t.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),"Cache & queue":t.jsxs(ze,{children:[t.jsx("path",{d:"M4 7h16M4 12h16M4 17h16"}),t.jsx("circle",{cx:"8",cy:"7",r:"1.3",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14",cy:"12",r:"1.3",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"10",cy:"17",r:"1.3",fill:"currentColor",stroke:"none"})]}),"Storage & media":t.jsxs(ze,{children:[t.jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"2"}),t.jsx("circle",{cx:"9",cy:"10",r:"1.8"}),t.jsx("path",{d:"M4 17l4.5-4.5L13 17M13 14l2.5-2.5L20 16"})]}),Messaging:t.jsx(ze,{children:t.jsx("path",{d:"M21 14a2 2 0 0 1-2 2H8l-4 4V5a2 2 0 0 1 2-2h13a2 2 0 0 1 2 2z"})}),Search:t.jsxs(ze,{children:[t.jsx("circle",{cx:"10.5",cy:"10.5",r:"6"}),t.jsx("path",{d:"M15 15l5 5"})]}),Containers:t.jsxs(ze,{children:[t.jsx("rect",{x:"3",y:"10",width:"5",height:"5",rx:"0.8"}),t.jsx("rect",{x:"9.5",y:"10",width:"5",height:"5",rx:"0.8"}),t.jsx("rect",{x:"9.5",y:"4.5",width:"5",height:"5",rx:"0.8"}),t.jsx("path",{d:"M3 17.5c3 2.5 12 2.5 15.5-3a3.4 3.4 0 0 0 2.5.4"})]}),"CI/CD":t.jsxs(ze,{children:[t.jsx("path",{d:"M4 12a8 8 0 0 1 13.7-5.6M20 12a8 8 0 0 1-13.7 5.6"}),t.jsx("path",{d:"M17 3v4h-4M7 21v-4h4"})]}),Domain:t.jsxs(ze,{children:[t.jsx("circle",{cx:"12",cy:"12",r:"8.5"}),t.jsx("path",{d:"M3.5 12h17M12 3.5c2.5 2.3 2.5 14.7 0 17M12 3.5c-2.5 2.3-2.5 14.7 0 17"})]}),Hosting:t.jsxs(ze,{children:[t.jsx("rect",{x:"3.5",y:"4.5",width:"17",height:"6",rx:"1.5"}),t.jsx("rect",{x:"3.5",y:"13.5",width:"17",height:"6",rx:"1.5"}),t.jsx("path",{d:"M7 7.5h.01M7 16.5h.01"})]}),Payments:t.jsxs(ze,{children:[t.jsx("rect",{x:"3",y:"5.5",width:"18",height:"13",rx:"2"}),t.jsx("path",{d:"M3 9.5h18"})]}),Database:t.jsxs(ze,{children:[t.jsx("ellipse",{cx:"12",cy:"6",rx:"7",ry:"2.8"}),t.jsx("path",{d:"M5 6v12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8V6"}),t.jsx("path",{d:"M5 12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8"})]}),"Database ORM":t.jsxs(ze,{children:[t.jsx("ellipse",{cx:"12",cy:"6",rx:"7",ry:"2.8"}),t.jsx("path",{d:"M5 6v12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8V6"}),t.jsx("path",{d:"M5 12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8"})]}),"Backend platform":t.jsxs(ze,{children:[t.jsx("ellipse",{cx:"12",cy:"6",rx:"7",ry:"2.8"}),t.jsx("path",{d:"M5 6v12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8V6"}),t.jsx("path",{d:"M5 12c0 1.5 3.1 2.8 7 2.8s7-1.3 7-2.8"})]}),Authentication:t.jsxs(ze,{children:[t.jsx("circle",{cx:"9",cy:"9",r:"4"}),t.jsx("path",{d:"M12 12l7 7M16 16l2-2M18.5 13.5l1.5 1.5"})]}),"Transactional email":t.jsxs(ze,{children:[t.jsx("rect",{x:"3",y:"5.5",width:"18",height:"13",rx:"2"}),t.jsx("path",{d:"M3.5 7l8.5 6 8.5-6"})]}),"Product analytics":t.jsxs(ze,{children:[t.jsx("path",{d:"M4 20V4M4 20h16"}),t.jsx("path",{d:"M8 16v-3M12 16V8M16 16v-6"})]}),"Error monitoring":t.jsxs(ze,{children:[t.jsx("path",{d:"M12 3l8 4v5c0 5-3.5 8-8 9-4.5-1-8-4-8-9V7z"}),t.jsx("path",{d:"M12 8.5v4M12 15.5h.01"})]})},nD={vercel:{fg:"#ffffff",bg:"rgba(255,255,255,0.10)"},github:{fg:"#ffffff",bg:"rgba(255,255,255,0.10)"},resend:{fg:"#ffffff",bg:"rgba(255,255,255,0.10)"},anthropic:{fg:"#d97757",bg:"rgba(217,119,87,0.14)"},neon:{fg:"#00e599",bg:"rgba(0,229,153,0.13)"},stripe:{fg:"#635bff",bg:"rgba(99,91,255,0.15)"},netlify:{fg:"#32e6e2",bg:"rgba(50,230,226,0.13)"},cloudflare:{fg:"#f38020",bg:"rgba(243,128,32,0.14)"},fly:{fg:"#8b5cf6",bg:"rgba(139,92,246,0.14)"},gitlab:{fg:"#fc6d26",bg:"rgba(252,109,38,0.14)"},openai:{fg:"#ffffff",bg:"rgba(255,255,255,0.10)"},aws:{fg:"#ff9900",bg:"rgba(255,153,0,0.13)"},gcp:{fg:"#4285f4",bg:"rgba(66,133,244,0.14)"},supabase:{fg:"#3ecf8e",bg:"rgba(62,207,142,0.13)"},firebase:{fg:"#ffca28",bg:"rgba(255,202,40,0.13)"},mongodb:{fg:"#00ed64",bg:"rgba(0,237,100,0.12)"},redis:{fg:"#ff4438",bg:"rgba(255,68,56,0.13)"},docker:{fg:"#2496ed",bg:"rgba(36,150,237,0.14)"},twilio:{fg:"#f22f46",bg:"rgba(242,47,70,0.13)"},slack:{fg:"#e01e5a",bg:"rgba(224,30,90,0.13)"},algolia:{fg:"#5468ff",bg:"rgba(84,104,255,0.14)"},cloudinary:{fg:"#3448c5",bg:"rgba(52,72,197,0.16)"},sentry:{fg:"#a07cff",bg:"rgba(160,124,255,0.14)"},posthog:{fg:"#f9bd2b",bg:"rgba(249,189,43,0.13)"},clerk:{fg:"#6c47ff",bg:"rgba(108,71,255,0.15)"}};function ev(e){return e&&nD[e]||null}function tv({providerId:e,category:n}){return e&&Xh[e]?Xh[e]:n&&Qh[n]?Qh[n]:null}const CJ=Object.freeze(Object.defineProperty({__proto__:null,G:ze,ProviderLogo:tv,providerBrand:ev},Symbol.toStringTag,{value:"Module"}));function nv(e){return e.length<=10?"•".repeat(Math.max(e.length,6)):`${e.slice(0,6)}••••••••••${e.slice(-4)}`}function Hd({apiKey:e}){const[n,s]=l.useState(!1);return t.jsxs("div",{className:"xsvc-detrow",children:[t.jsx("span",{className:"xsvc-detlabel",children:"API key"}),t.jsxs("button",{type:"button",className:"xsvc-keyval",onClick:()=>s(r=>!r),"aria-label":n?"Hide API key":"Reveal API key",title:n?"Click to hide":"Click to reveal",children:[t.jsx("span",{className:"mono",children:n?e:nv(e)}),t.jsx("span",{className:"eye","aria-hidden":"true",children:n?Xy:Jy})]})]})}const TJ=Object.freeze(Object.defineProperty({__proto__:null,ApiKeyField:Hd,maskKey:nv},Symbol.toStringTag,{value:"Module"}));function qd({svc:e,category:n,expanded:s,onToggle:r,onAction:a,onAsk:o}){var d,u,p;const i=tv({providerId:e.providerId,category:e.category}),c=ev(e.providerId);return t.jsxs("div",{className:`xsvc-rowwrap${s?" open":""}`,children:[t.jsxs("div",{className:`xsvc-row${e.attn?" attn":""}${e.pending?" pending":""}`,role:"button",tabIndex:0,"aria-expanded":s,onClick:r,onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),r())},children:[t.jsx("div",{className:`xsvc-tile t-${e.tone??"lime"}`,style:c?{background:c.bg,color:c.fg}:void 0,children:i??e.monogram??e.name.slice(0,1).toUpperCase()}),t.jsxs("div",{className:"xsvc-rmain",children:[t.jsxs("div",{className:"xsvc-rname",children:[e.name,(d=e.tags)==null?void 0:d.filter(h=>h.kind!=="origin").map((h,f)=>t.jsx("span",{className:`xsvc-tag ${h.kind}`,children:h.text},f))]}),t.jsx("div",{className:"xsvc-rdesc",children:e.desc})]}),t.jsxs("div",{className:"xsvc-rright",children:[n?t.jsx("span",{className:"xsvc-rcat",children:n}):null,e.actionLabel?t.jsx("button",{type:"button",className:"xsvc-addkey",onClick:h=>{h.stopPropagation(),e.actionKey&&a&&a(e.actionKey)},children:e.actionLabel}):t.jsxs("div",{className:"xsvc-rmeta",children:[e.metaBig?t.jsx("div",{className:"big",children:e.metaBig}):null,e.metaLil?t.jsx("div",{className:"lil",children:e.metaLil}):null]}),t.jsx("span",{className:`xsvc-arr${s?" down":""}`,"aria-hidden":"true",children:Vy})]})]}),s?t.jsxs("div",{className:"xsvc-detail",children:[(u=e.detail)==null?void 0:u.map((h,f)=>t.jsxs("div",{className:"xsvc-detrow",children:[t.jsx("span",{className:"xsvc-detlabel",children:h.label}),t.jsx("span",{className:`xsvc-detval${h.mono?" mono":""}`,children:h.value})]},f)),e.apiKey?t.jsx(Hd,{apiKey:e.apiKey}):null,!((p=e.detail)!=null&&p.length)&&!e.apiKey?t.jsx("div",{className:"xsvc-detrow",children:t.jsx("span",{className:"xsvc-detval",children:e.desc})}):null,o?t.jsx(yx,{serviceName:e.name,onAsk:o}):null]}):null]})}const PJ=Object.freeze(Object.defineProperty({__proto__:null,ServiceRow:qd},Symbol.toStringTag,{value:"Module"})),sD="pending:custom-domain";function sv({groups:e,onAction:n,onSaveDomain:s,onAsk:r}){const[a,o]=l.useState(null),i=e.flatMap(u=>u.items.map((p,h)=>({svc:p,category:p.category??u.label,key:`${u.label}:${p.name}:${h}`}))),c=[...i.filter(u=>!u.svc.pending&&u.svc.attn),...i.filter(u=>!u.svc.pending&&!u.svc.attn)],d=i.filter(u=>u.svc.pending);return t.jsxs("div",{className:"xsvc-groups",children:[c.length>0&&t.jsxs("section",{className:"xsvc-group","aria-label":"In use",children:[t.jsxs("div",{className:"xsvc-group-head",children:[t.jsx("span",{className:"xsvc-seclabel",children:"In use"}),t.jsxs("span",{className:"xsvc-seccount",children:[c.length," ",c.length===1?"service":"services"]})]}),t.jsx("div",{className:"xsvc-rows",children:c.map(({svc:u,category:p,key:h})=>t.jsx(qd,{svc:u,category:p,expanded:a===h,onToggle:()=>o(f=>f===h?null:h),onAction:n,onAsk:r},h))})]}),d.length>0&&t.jsxs("section",{className:"xsvc-group","aria-label":"Not set up yet",children:[t.jsxs("div",{className:"xsvc-group-head",children:[t.jsx("span",{className:"xsvc-seclabel",children:"Not set up yet"}),t.jsx("span",{className:"xsvc-seccount",children:"add when you need them"})]}),t.jsx("div",{className:"xsvc-setup-grid",children:d.map(({svc:u,category:p,key:h})=>t.jsxs("div",{"data-testid":"xsvc-setup-card",className:"xsvc-setup-card",children:[t.jsx("div",{className:"xsvc-setup-name",children:p}),t.jsx("div",{className:"xsvc-setup-desc",children:u.name}),u.actionLabel?t.jsxs("button",{type:"button",className:"xsvc-setup-btn",onClick:()=>{u.actionKey&&n&&n(u.actionKey)},children:[t.jsx("span",{children:u.actionLabel}),t.jsx("span",{"aria-hidden":"true",children:" →"})]}):null,u.actionKey===sD&&s?t.jsx(kx,{onSave:s}):null]},h))})]})]})}const OJ=Object.freeze(Object.defineProperty({__proto__:null,ExternalServiceGroupList:sv},Symbol.toStringTag,{value:"Module"}));function Ud({sort:e,onSortChange:n}){return t.jsxs("div",{className:"xsvc-toolbar",children:[t.jsx("span",{className:"xsvc-sortlbl",children:"Sort by"}),t.jsxs("div",{className:"xsvc-seg",children:[t.jsx("button",{type:"button",className:e==="type"?"on":"",onClick:()=>n("type"),children:"Type"}),t.jsx("button",{type:"button",className:e==="provider"?"on":"",onClick:()=>n("provider"),children:"Provider"})]})]})}const RJ=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesSortToolbar:Ud},Symbol.toStringTag,{value:"Module"})),rD=["When does codeyam.com renew?","What's my monthly spend?","Anything missing a key?"];function rv({onPick:e}){return t.jsx("span",{className:"xsvc-chips",children:rD.map(n=>t.jsx("button",{type:"button",className:"xsvc-chip",onClick:()=>e(n),children:n},n))})}const EJ=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesSuggestionChips:rv},Symbol.toStringTag,{value:"Module"}));function av({draft:e,onDraftChange:n,onSubmit:s,onAsk:r,chatSlot:a,bare:o=!1}){const i=!a&&e.trim()==="";return t.jsxs("div",{className:o?"xsvc-askcard xsvc-askcard-bare":"xsvc-askcard",children:[t.jsx(Wd,{draft:e,onDraftChange:n,onSubmit:s,onAsk:r,placeholder:"Ask the AI about your domains, keys, subscriptions…",testId:"xsvc-ask-input"}),i?t.jsx("div",{className:"xsvc-ask-suggestions",children:t.jsx(rv,{onPick:c=>{n(c),r==null||r(c)}})}):null,a?t.jsx("div",{className:"xsvc-ask-chat",children:a}):null]})}const AJ=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesAskCard:av},Symbol.toStringTag,{value:"Module"}));function ov({shots:e,initialIndex:n=0,onSelect:s,onClose:r}){const a=e.length-1,o=l.useCallback(g=>Math.max(0,Math.min(a,g)),[a]),[i,c]=l.useState(()=>o(n)),d=l.useCallback(g=>c(x=>o(x+g)),[o]),u=l.useCallback(g=>{g.key==="Escape"?(g.preventDefault(),r()):g.key==="ArrowLeft"?(g.preventDefault(),d(-1)):g.key==="ArrowRight"&&(g.preventDefault(),d(1))},[r,d]);if(l.useEffect(()=>(window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)),[u]),e.length===0)return null;const p=e[i],h=i===0,f=i===a,m="flex h-14 w-14 flex-none items-center justify-center rounded-full border-2 border-[var(--border-subtle)] bg-[var(--bg-card)] text-3xl text-[var(--text-primary)] transition hover:border-[var(--text-primary)] hover:bg-[var(--bg-surface)] disabled:cursor-default disabled:opacity-25 disabled:hover:border-[var(--border-subtle)] disabled:hover:bg-[var(--bg-card)]";return t.jsx("div",{className:"fixed inset-0 z-[70] flex flex-col",style:{background:"rgba(30, 30, 30, 0.90)"},role:"dialog","aria-label":"Scenario gallery","data-testid":"scenario-gallery-modal",onClick:r,children:t.jsxs("div",{className:"flex flex-1 min-h-0 flex-col px-6 py-4",onClick:g=>g.stopPropagation(),children:[t.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"truncate text-[11px] font-semibold tracking-widest uppercase text-[var(--text-dim)]",children:p.routeLabel}),t.jsx("p",{className:"truncate text-lg font-semibold text-[var(--text-primary)]",children:p.name})]}),t.jsxs("span",{className:"flex-none text-xs font-semibold tracking-widest uppercase text-[var(--text-dim)]",children:[i+1," / ",e.length]}),t.jsx("button",{type:"button",onClick:r,"aria-label":"Close gallery",className:"flex-none text-sm text-[var(--text-muted)] hover:text-[var(--text-primary)] cursor-pointer",children:"✕"})]}),t.jsxs("div",{className:"flex min-h-0 flex-1 items-center gap-4",children:[t.jsx("button",{type:"button",onClick:()=>d(-1),disabled:h,"aria-label":"Previous scenario",className:m,children:"‹"}),t.jsx("button",{type:"button",onClick:()=>{s(p.slug),r()},"aria-label":`Open ${p.name} live`,className:"flex min-h-0 flex-1 cursor-pointer items-center justify-center self-stretch",children:t.jsx("div",{className:"flex max-h-[80vh] max-w-[90vw] items-center justify-center",children:t.jsx(kt,{screenshotPath:p.screenshotPath??void 0,cacheBuster:p.screenshotCapturedAtMs??void 0,alt:p.name,className:"max-h-[80vh] max-w-[90vw] object-contain"})})}),t.jsx("button",{type:"button",onClick:()=>d(1),disabled:f,"aria-label":"Next scenario",className:m,children:"›"})]}),t.jsx("div",{className:"mt-4 flex justify-center",children:t.jsx("button",{type:"button",onClick:()=>{s(p.slug),r()},className:"rounded bg-[var(--lime-300)] px-4 py-2 font-semibold text-black transition hover:brightness-110",children:"Open Live Preview"})})]})})}const MJ=Object.freeze(Object.defineProperty({__proto__:null,ScenarioGalleryModal:ov},Symbol.toStringTag,{value:"Module"}));function iv({reason:e}){const{headline:n,detail:s}=lv(e);return t.jsxs("div",{className:"py-4 text-sm text-[var(--text-dim)]",children:[t.jsx("p",{className:"text-[var(--text-secondary)]",children:n}),s?t.jsx("p",{className:"mt-1",children:s}):null]})}function lv(e){switch(e.kind){case"no-component-scenarios":return{headline:"No components yet.",detail:"Capture a component scenario and it will appear here — a scenario is what marks a component as browsable."};case"missing-from-glossary":return{headline:`${e.count} component ${ys(e.count,"scenario")} name ${ys(e.count,"a component","components")} not in the glossary${Zh(e.examples)}.`,detail:"Deconstruct or register those components so they can be surfaced here."};case"not-visual-components":return{headline:`${e.count} ${ys(e.count,"component")} matched glossary ${ys(e.count,"entry","entries")} but ${ys(e.count,"is","are")} not recognized as visual ${ys(e.count,"component","components")}${Zh(e.examples)}.`,detail:"Check `components.fileExtensions` in .codeyam/stack.json — a stack whose components are not .tsx/.jsx must list its own extensions."}}}function ys(e,n,s){return e===1?n:s??`${n}s`}function Zh(e){return e.length===0?"":` (e.g. ${e.join(", ")})`}const IJ=Object.freeze(Object.defineProperty({__proto__:null,ComponentSurfaceReasonNote:iv,describeReason:lv},Symbol.toStringTag,{value:"Module"})),aD="Good question. We'll explain this plainly as we go, and you can ask anything at any step. Nothing happens until you say go.",oD=[{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 iD(e){const n=e.toLowerCase();for(const s of oD)if(s.keywords.some(r=>n.includes(r)))return s.answer;return aD}const lD={"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 Te(e){return lD[e]}const cD=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function dD(e){const n=/^(\d{4})-(\d{2})$/.exec(e);if(!n)return e;const s=Number(n[2])-1;return s<0||s>11?e:`${cD[s]} ${n[1]}`}function uD(e,n){const s=/^(\d{4})-(\d{2})$/.exec(e);if(!s)return 0;const r=Number(s[1]),a=Number(s[2])-1,o=(n.getFullYear()-r)*12+(n.getMonth()-a);return o<0?0:o}const pD=12;function hD(e,n){return e.staleness==="low"?!1:uD(e.verified,n)>pD}function Yn({fact:e,asOf:n=new Date}){if(e.staleness==="low")return null;const s=hD(e,n);return t.jsxs("span",{className:"fact-fresh"+(s?" stale":""),title:`Source: ${e.source}`,children:[s?"needs re-check · ":"verified ",dD(e.verified)]})}const DJ=Object.freeze(Object.defineProperty({__proto__:null,FactFreshness:Yn},Symbol.toStringTag,{value:"Module"}));function lt({size:e=15,color:n="var(--green-300)"}){return t.jsx("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:n,strokeWidth:"2.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M3 8.4l3 3 7-7.4"})})}function Ro(){return t.jsx("div",{className:"pv-logo",children:t.jsx("svg",{width:"26",height:"22",viewBox:"0 0 26 22",fill:"#0a0a0a","aria-hidden":"true",children:t.jsx("path",{d:"M13 0l13 22H0z"})})})}function cv(){return t.jsx("div",{className:"journey",children:t.jsxs("div",{className:"jrow",children:[t.jsxs("div",{className:"jcol",children:[t.jsx("div",{className:"jtile",children:"💻"}),t.jsx("div",{className:"jlbl",children:"Your computer"}),t.jsx("div",{className:"jsub",children:"Only you can see it"})]}),t.jsxs("div",{className:"jconn",children:[t.jsx("span",{className:"jpacket"}),t.jsx("span",{children:"→"})]}),t.jsxs("div",{className:"jcol",children:[t.jsx("div",{className:"jtile lime",children:"☁️"}),t.jsx("div",{className:"jlbl",children:"Hosting"}),t.jsx("div",{className:"jsub",children:"A home on the internet"})]}),t.jsxs("div",{className:"jconn",children:[t.jsx("span",{className:"jpacket",style:{animationDelay:"1.8s"}}),t.jsx("span",{children:"→"})]}),t.jsxs("div",{className:"jcol",children:[t.jsx("div",{className:"jtile",children:"🌍"}),t.jsx("div",{className:"jlbl",children:"Anyone, anywhere"}),t.jsx("div",{className:"jsub",children:"Opens with a link"})]})]})})}function dv(){const e=Te("vercel.hobby");return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"reasons",children:[t.jsxs("div",{className:"reason",children:[t.jsx(lt,{}),t.jsxs("span",{children:[t.jsx("b",{children:"Free to start."})," No credit card, no surprise bills for an app this size."]})]}),t.jsxs("div",{className:"reason",children:[t.jsx(lt,{}),t.jsxs("span",{children:[t.jsx("b",{children:"Built for how your app is made."})," It deploys the way your app already works, so it just runs."]})]}),t.jsxs("div",{className:"reason",children:[t.jsx(lt,{}),t.jsxs("span",{children:[t.jsx("b",{children:"Your own web address later."})," Launch on a free link today, add a custom domain whenever you like."]})]})]}),t.jsxs("p",{className:"reason-foot",children:["One catch worth knowing: ",e.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.",t.jsx(Yn,{fact:e})]})]})}function uv(){return t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"Free tier"}),t.jsx("span",{className:"chip",children:"Custom domain later"}),t.jsx("span",{className:"chip",children:"~5 min to set up"})]})}function pv(){const[e,n]=l.useState(!1);return t.jsxs("div",{children:[t.jsxs("button",{type:"button",className:"alt-toggle",onClick:()=>n(s=>!s),children:[e?"Hide other options":"Vercel not for you? See other options",t.jsx("span",{className:"chev",style:{transform:e?"rotate(180deg)":"none"},children:"⌄"})]}),e?t.jsxs("div",{className:"alts",children:[t.jsxs("div",{className:"altcard",children:[t.jsx("div",{className:"altmark",style:{background:"linear-gradient(140deg,#16a3a3,#0d6e6e)"},children:"N"}),t.jsxs("div",{className:"altbody",children:[t.jsx("div",{className:"altname",children:"Netlify"}),t.jsx("div",{className:"altdesc",children:"Also free to start and very similar to set up. A solid pick if you'd rather use it."})]}),t.jsx("button",{type:"button",className:"altpick",children:"Use this"})]}),t.jsxs("div",{className:"altcard",children:[t.jsx("div",{className:"altmark",style:{background:"linear-gradient(140deg,#f6821f,#c25e0a)"},children:"C"}),t.jsxs("div",{className:"altbody",children:[t.jsx("div",{className:"altname",children:"Cloudflare Pages"}),t.jsx("div",{className:"altdesc",children:"Best if you expect heavy worldwide traffic. A little more to learn up front."})]}),t.jsx("button",{type:"button",className:"altpick",children:"Use this"})]})]}):null]})}const fD=[{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 hv(){const[e,n]=l.useState(-1);return t.jsx("div",{className:"faq",children:fD.map((s,r)=>t.jsxs("div",{className:"faqitem",children:[t.jsxs("button",{type:"button",className:"faqq"+(e===r?" open":""),onClick:()=>n(e===r?-1:r),children:[s.t,t.jsx("span",{className:"chev",children:"⌄"})]}),e===r?t.jsx("div",{className:"faqa",children:s.a}):null]},s.t))})}function fv(){const[e,n]=l.useState(""),[s,r]=l.useState(null),a=o=>{r(iD(o)),n("")};return t.jsxs("div",{className:"ask",children:[t.jsxs("div",{className:"askrow",children:[t.jsx("input",{value:e,onChange:o=>n(o.target.value),onKeyDown:o=>{o.key==="Enter"&&e.trim()&&a(e)},placeholder:'Ask anything, e.g. "Is it really free?" or "Can I use my own domain?"'}),t.jsx("button",{type:"button",onClick:()=>e.trim()&&a(e),"aria-label":"Ask",children:"↑"})]}),t.jsx("div",{className:"asknote",children:"Ask before you commit to anything."}),s?t.jsxs("div",{className:"askans",children:[t.jsx("span",{className:"askav",children:"‹Y"}),t.jsx("div",{className:"at",children:s})]}):null]})}const LJ=Object.freeze(Object.defineProperty({__proto__:null,Alts:pv,AskBox:fv,Check:lt,Chips:uv,Faq:hv,Journey:cv,Reasons:dv,VercelMark:Ro},Symbol.toStringTag,{value:"Module"})),mD={"chrome.devConsole":{url:"https://chrome.google.com/webstore/devconsole",label:"Open the Chrome Web Store developer dashboard"},"chrome.register":{url:Te("chromeStore.fee").source,label:"Chrome Web Store registration guide"},"google.oauthConsent":{url:"https://console.cloud.google.com/apis/credentials/consent",label:"Open the OAuth consent screen (Google Cloud console)"},"firefox.amoDevHub":{url:"https://addons.mozilla.org/developers/",label:"Firefox Add-ons (AMO) developer hub"},"edge.partnerDashboard":{url:"https://partner.microsoft.com/dashboard/microsoftedge",label:"Edge Add-ons partner dashboard"}};function gD(e){return mD[e]}function Xt({linkKey:e,label:n}){const s=gD(e);return t.jsxs("a",{className:"setup-extlink",href:s.url,target:"_blank",rel:"noreferrer noopener",children:[t.jsx("span",{className:"setup-extlink-label",children:n??s.label}),t.jsx("span",{className:"setup-extlink-glyph","aria-hidden":"true",children:"↗"})]})}function Se({children:e}){return t.jsx("div",{className:"reasons",children:e})}function $({lead:e,children:n}){return t.jsxs("div",{className:"reason",children:[t.jsx(lt,{}),t.jsxs("span",{children:[t.jsx("b",{children:e})," ",n]})]})}function Yd({spaced:e=!1,children:n}){return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"seclabel",style:e?{marginTop:24}:void 0,children:"Keep a changelog"}),t.jsxs(Se,{children:[t.jsxs($,{lead:"One CHANGELOG.md, grouped by version.",children:["Follow the ",t.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."]}),t.jsxs($,{lead:"Or generate it from your commits.",children:["If you write ",t.jsx("b",{children:"Conventional Commits"})," (",t.jsx("code",{children:"feat:"}),","," ",t.jsx("code",{children:"fix:"}),", ",t.jsx("code",{children:"feat!:"})," for breaking), tools like release-please or git-cliff assemble the changelog — and even the next version number — for you."]}),n]})]})}function Eo(){return t.jsxs("div",{className:"setup-note",style:{marginTop:14},children:[t.jsxs("p",{children:["Publishing to ",t.jsx("b",{children:"Firefox Add-ons (AMO)"})," or ",t.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."]}),t.jsxs("p",{children:[t.jsx("b",{children:"Fees differ:"})," the"," ",t.jsx("b",{children:Te("chromeStore.fee").value})," registration fee is Chrome-only and one-time — Firefox AMO and Edge Add-ons charge no developer fee."]}),t.jsxs("div",{className:"setup-note-links",children:[t.jsx(Xt,{linkKey:"firefox.amoDevHub"}),t.jsx(Xt,{linkKey:"edge.partnerDashboard"})]})]})}const FJ=Object.freeze(Object.defineProperty({__proto__:null,ChangelogSection:Yd,ReqItem:$,ReqList:Se,SetupExternalLink:Xt,StoreAlternativesNote:Eo},Symbol.toStringTag,{value:"Module"}));function ki(e){const n=pE(e);if(n)return{selectedAppDir:n,selectedEntityHash:null};const s=hE(e);return s?{selectedAppDir:null,selectedEntityHash:s}:{selectedAppDir:null,selectedEntityHash:null}}function Ni(e){return`${Xc()}/apps/${e}`}function mv(e){return`${Xc()}/entities/${e}`}function Br(e,n){const s=`${e}:${n}`;let r=2166136261;for(let a=0;a<s.length;a++)r^=s.charCodeAt(a),r=Math.imul(r,16777619);return(r>>>0).toString(16).padStart(8,"0")}function ps(e){return(e.split("/").pop()??e).replace(/\.[^.]+$/,"")}function wl(e){if(!e.pageFilePath)return null;const n=e.entityName??ps(e.pageFilePath);return Br(e.pageFilePath,n)}function gv(e){const n=wl(e);return n===null?null:mv(n)}function xv({scenario:e,onSelect:n}){const s=e.screenshotPaths[0]??null;return t.jsxs("button",{type:"button",onClick:n,className:`relative text-left w-full${n?" cursor-pointer group/thumb":""}`,children:[t.jsx("div",{className:"aspect-[16/10] w-full flex items-center justify-center overflow-hidden rounded border border-[var(--line-strong)] bg-[var(--bg-card)] transition group-hover/thumb:border-[var(--text-muted)]",style:{contentVisibility:"auto",containIntrinsicSize:"auto 160px"},children:t.jsx(kt,{screenshotPath:s??void 0,alt:e.name,loading:"lazy"})}),e.dimensions.length>0?t.jsx("span",{className:"absolute bottom-1 right-1 rounded bg-black/60 px-1 py-0.5 text-[8px] text-white",children:e.dimensions[0]}):null,t.jsx("p",{className:"mt-1.5 truncate text-[13px] text-[var(--text-dim)]",children:e.name})]})}const $J=Object.freeze(Object.defineProperty({__proto__:null,RouteListCardThumbnail:xv},Symbol.toStringTag,{value:"Module"}));function bv({routeEntity:e,variant:n}){const s=e.scenarios.length;return n==="explore"?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-sm font-bold uppercase tracking-wider text-[var(--text-primary)] group-hover:underline",children:e.displayName}),s>0?t.jsxs("span",{className:"text-sm text-[var(--text-dim)]",children:["(",s,")"]}):null]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)] group-hover:text-[var(--text-primary)] transition",children:e.displayName}),t.jsx("span",{className:"font-mono text-xs text-[var(--text-dim)]",children:e.route}),s>0?t.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:["[",s,"]"]}):null,t.jsx("span",{className:"ml-auto text-xs text-[var(--text-dim)] group-hover:text-[var(--text-muted)] transition",children:"›"})]})}const zJ=Object.freeze(Object.defineProperty({__proto__:null,RouteListCardHeading:bv},Symbol.toStringTag,{value:"Module"}));function yv({collapsed:e,onToggle:n,disclosable:s}){return s?t.jsx("button",{type:"button",onClick:n,"aria-label":e?"Expand group":"Collapse group",className:"shrink-0 w-5 text-[var(--text-dim)] hover:text-[var(--text-primary)] transition text-xs",children:e?"▸":"▾"}):t.jsx("span",{className:"shrink-0 w-5"})}const BJ=Object.freeze(Object.defineProperty({__proto__:null,RouteGroupDisclosure:yv},Symbol.toStringTag,{value:"Module"})),ef={2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4",5:"grid-cols-5"};function Gd({routeEntity:e,onSelectRoute:n,onSelectScenario:s,columns:r=4,defaultCollapsed:a=!1,collapsed:o,onToggleCollapsed:i,headingVariant:c="default"}){const d=e.scenarios.length,[u,p]=l.useState(a),h=o!==void 0&&i!==void 0,f=h?o:u,m=h?i:()=>p(_=>!_),g=gv(e),x=c==="explore",b=x?"group flex min-w-0 cursor-pointer items-baseline gap-2 text-left":"group flex flex-1 min-w-0 cursor-pointer items-center gap-2 text-left",y=t.jsx(bv,{routeEntity:e,variant:c}),v=t.jsx(yv,{collapsed:f,onToggle:m,disclosable:d>0}),j=g?t.jsx(Ns,{href:g,onNavigate:()=>n(e.route),className:b,children:y}):t.jsx("button",{onClick:()=>n(e.route),className:b,type:"button",children:y});return t.jsxs("div",{className:"mb-10 border-b border-[var(--border-subtle)] pb-8",children:[t.jsx("div",{className:"flex items-center gap-2",children:x?t.jsxs(t.Fragment,{children:[j,v]}):t.jsxs(t.Fragment,{children:[v,j]})}),d>0&&!f?t.jsx("div",{className:`mt-4 grid gap-x-5 gap-y-9 ${ef[r]??ef[4]}`,children:e.scenarios.map(_=>t.jsx(xv,{scenario:_,onSelect:s?()=>s(_.slug):void 0},_.slug))}):d===0?t.jsx("p",{className:`mt-1 text-[10px] text-[var(--text-dim)]${x?"":" pl-7"}`,children:"No scenarios yet"}):null]})}const WJ=Object.freeze(Object.defineProperty({__proto__:null,RouteListCard:Gd},Symbol.toStringTag,{value:"Module"}));function vv({active:e,onChange:n,counts:s}){const r=(a,o)=>{const i=e===a,c=s==null?void 0:s[a];return t.jsxs("button",{type:"button",role:"tab","aria-selected":i,onClick:()=>n(a),title:c!=null?`${c} ${c===1?"simulation":"simulations"}`:void 0,className:$s(i),children:[o,c!=null?t.jsx("span",{"aria-hidden":"true","data-testid":`route-kind-count-${a}`,className:`text-xs font-normal tabular-nums ${i?"text-[var(--text-secondary)]":"text-[var(--text-dim)]"}`,children:c}):null]})};return t.jsxs("div",{role:"tablist","aria-label":"Simulation kind",className:Mr,children:[r("pages","Pages"),r("components","Components")]})}const HJ=Object.freeze(Object.defineProperty({__proto__:null,RouteKindToggle:vv},Symbol.toStringTag,{value:"Module"}));function Vd(){return t.jsxs("svg",{viewBox:"0 0 16 16",className:"w-[15px] h-[15px]",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":"true",children:[t.jsx("circle",{cx:"7",cy:"7",r:"4.5"}),t.jsx("path",{d:"M10.4 10.4 L14 14"})]})}const qJ=Object.freeze(Object.defineProperty({__proto__:null,SearchIcon:Vd},Symbol.toStringTag,{value:"Module"}));function jv({value:e,onChange:n,scopeLabel:s}){return t.jsxs("div",{className:"relative min-w-0 flex-1",children:[t.jsx("span",{className:"pointer-events-none absolute left-4 top-1/2 -translate-y-1/2 text-[var(--text-dim)]",children:t.jsx(Vd,{})}),t.jsx("input",{type:"search",value:e,onChange:r=>n(r.target.value),placeholder:`Search ${s}`,"aria-label":`Search ${s}`,className:`w-full rounded-[10px] ${mo} py-2.5 pl-11 pr-4 text-sm text-[var(--text-secondary)] placeholder:text-[var(--text-dim)] focus:border-[var(--lime-300)] focus:outline-none`})]})}const UJ=Object.freeze(Object.defineProperty({__proto__:null,RouteSearchField:jv},Symbol.toStringTag,{value:"Module"}));function xD(e){const n=[];for(const s of e)for(const r of s.scenarios)for(const a of r.dimensions)n.includes(a)||n.push(a);return n}function bD(e,n){return n===null?e:e.map(s=>({...s,scenarios:s.scenarios.filter(r=>r.dimensions.includes(n))})).filter(s=>s.scenarios.length>0)}function yD(e){const n=e.toLowerCase();return/(tablet|ipad)/.test(n)?"tablet":/(mobile|phone|android|pixel)/.test(n)?"phone":"desktop"}function wv({kind:e,size:n=16}){const s={viewBox:"0 0 24 24",width:n,height:n,fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0};return e==="phone"?t.jsxs("svg",{...s,children:[t.jsx("rect",{x:"7.5",y:"3",width:"9",height:"18",rx:"2"}),t.jsx("path",{d:"M11 17.5h2"})]}):e==="tablet"?t.jsxs("svg",{...s,children:[t.jsx("rect",{x:"5",y:"3",width:"14",height:"18",rx:"2"}),t.jsx("path",{d:"M11 17.5h2"})]}):t.jsxs("svg",{...s,children:[t.jsx("rect",{x:"3",y:"4.5",width:"18",height:"12",rx:"1.5"}),t.jsx("path",{d:"M9 20h6M12 16.5V20"})]})}function _v({dimensions:e,active:n,onChange:s}){return e.length<2?null:t.jsx("div",{role:"group","aria-label":"Screen size",className:Mr,children:e.map(r=>{const a=r===n;return t.jsx("button",{type:"button","aria-label":r,title:a?`${r} (click to show all sizes)`:r,"aria-pressed":a,onClick:()=>s(a?null:r),className:$s(a,"icon"),children:t.jsx(wv,{kind:yD(r)})},r)})})}const YJ=Object.freeze(Object.defineProperty({__proto__:null,DimensionDeviceIcon:wv,RouteDimensionFilter:_v},Symbol.toStringTag,{value:"Module"}));function Sv({columns:e}){const a=(12-(e-1)*1.6)/e;return t.jsx("svg",{viewBox:"0 0 16 16",className:"w-[15px] h-[15px]",fill:"currentColor","aria-hidden":"true",children:Array.from({length:e},(o,i)=>t.jsx("rect",{x:2+i*(a+1.6),y:3,width:a,height:10,rx:.7},i))})}const GJ=Object.freeze(Object.defineProperty({__proto__:null,GridColumnsIcon:Sv},Symbol.toStringTag,{value:"Module"}));function kv({columns:e,onChange:n,options:s=[2,3,4,5]}){return t.jsx("div",{role:"group","aria-label":"Thumbnails per row",title:"Thumbnails per row",className:Mr,children:s.map(r=>t.jsx("button",{type:"button",onClick:()=>n(r),"aria-label":`${r} per row`,"aria-pressed":e===r,className:$s(e===r,"icon"),children:t.jsx(Sv,{columns:r})},r))})}const VJ=Object.freeze(Object.defineProperty({__proto__:null,GridDensityControl:kv},Symbol.toStringTag,{value:"Module"}));function Ci(e){const n=[];for(const s of e)for(const r of s.scenarios)n.push({slug:r.slug,name:r.name,routeLabel:s.route||s.displayName,screenshotPath:r.screenshotPaths[0]??null,screenshotCapturedAtMs:r.screenshotCapturedAtMs??null});return n}function vD(e){const[n,s]=l.useState(()=>new Set),r=l.useMemo(()=>e.filter(d=>d.disclosable).map(d=>d.key),[e]),a=l.useCallback(d=>n.has(d),[n]),o=l.useCallback(d=>{s(u=>{const p=new Set(u);return p.has(d)?p.delete(d):p.add(d),p})},[]),i=r.length>0&&r.every(d=>n.has(d)),c=l.useCallback(()=>{s(d=>r.length>0&&r.every(p=>d.has(p))?new Set:new Set(r))},[r]);return{isCollapsed:a,toggle:o,toggleAll:c,allCollapsed:i,canToggleAll:r.length>0}}function tf(e,n){return e.route??e.displayName??String(n)}function Nv({pages:e,components:n,componentSurfaceReason:s=null,onSelectRoute:r,onSelectScenario:a}){const[o,i]=l.useState("pages"),[c,d]=l.useState(4),[u,p]=l.useState(""),[h,f]=l.useState(null),[m,g]=l.useState(!1),x=o==="components",b=x?n:e,y=l.useMemo(()=>Ci(b),[b]),v=y.length>0&&!!a,j=l.useMemo(()=>xD(b),[b]),_=h!==null&&j.includes(h)?h:null,w=l.useMemo(()=>{const C=bD(b,_),T=u.trim().toLowerCase();return T?C.filter(P=>P.displayName.toLowerCase().includes(T)):C},[b,_,u]),k=l.useMemo(()=>w.map((C,T)=>({key:tf(C,T),disclosable:C.scenarios.length>0})),[w]),S=vD(k),N=l.useMemo(()=>({pages:Ci(e).length,components:Ci(n).length}),[e,n]);return t.jsxs("div",{children:[m&&v?t.jsx(ov,{shots:y,onSelect:C=>a==null?void 0:a(C),onClose:()=>g(!1)}):null,t.jsxs("div",{"data-testid":"route-list-toolbar",className:"flex flex-wrap items-center gap-3 mb-9",children:[t.jsx(vv,{active:o,onChange:i,counts:N}),t.jsx("div",{className:"w-full max-w-[280px] min-w-[180px] flex-1 flex",children:t.jsx(jv,{value:u,onChange:p,scopeLabel:x?"components":"pages"})}),t.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[t.jsx(_v,{dimensions:j,active:_,onChange:f}),t.jsx(kv,{columns:c,onChange:d}),t.jsx("span",{"aria-hidden":"true",className:"mx-1 h-6 w-px bg-white/[0.1]"}),t.jsx(hb,{onOpenGallery:v?()=>g(!0):void 0,allCollapsed:S.allCollapsed,onToggleAll:S.canToggleAll?S.toggleAll:void 0})]})]}),w.length>0?w.map((C,T)=>{const P=tf(C,T);return t.jsx(Gd,{routeEntity:C,onSelectRoute:r,onSelectScenario:a,columns:c,collapsed:S.isCollapsed(P),onToggleCollapsed:()=>S.toggle(P),headingVariant:"explore"},P)}):b.length>0?t.jsxs("p",{className:"text-sm text-[var(--text-dim)] py-4",children:["No ",x?"components":"pages"," match “",u.trim(),"”."]}):x&&s?t.jsx(iv,{reason:s}):t.jsxs("p",{className:"text-sm text-[var(--text-dim)] py-4",children:["No ",x?"components":"pages"," yet."]})]})}const KJ=Object.freeze(Object.defineProperty({__proto__:null,RouteListTabs:Nv},Symbol.toStringTag,{value:"Module"}));function Kd(e,n){const s=e.url??"Uncategorized",r=n.find(o=>o.route===s),a=(r==null?void 0:r.scenarios)??[e];if(!e.url&&e.componentName){const o=a.filter(i=>i.componentName===e.componentName);return o.length?o:[e]}return a}function _l(e){const n=e.replace(/\s*\[[^\]]*\]\s*$/,""),s=n.indexOf(" - ");return s===-1?{pageName:null,stateName:n}:{pageName:n.slice(0,s),stateName:n.slice(s+3)}}function Cv(e){return $c(e)?e.componentName??_l(e.name).pageName:_l(e.name).pageName}function Ao(e){return _l(e.name).stateName}function Tv({currentScenario:e,scenarioGroups:n,onSelect:s,onCreateNew:r,onClose:a}){const[i,c]=l.useState(()=>({x:typeof window<"u"?Math.max(16,window.innerWidth-320-24):800,y:64})),d=l.useRef(null),u=m=>{d.current={dx:m.clientX-i.x,dy:m.clientY-i.y},m.currentTarget.setPointerCapture(m.pointerId)},p=m=>{d.current&&c({x:m.clientX-d.current.dx,y:m.clientY-d.current.dy})},h=m=>{d.current=null,m.currentTarget.releasePointerCapture(m.pointerId)},f=l.useMemo(()=>Kd(e,n),[e,n]);return t.jsxs("div",{className:"fixed z-50 flex flex-col rounded-xl border border-[#3d3d3d] bg-[#1b1b1b] shadow-2xl",style:{left:i.x,top:i.y,width:320,maxHeight:"70vh"},role:"dialog","aria-label":"Scenarios",children:[t.jsxs("div",{onPointerDown:u,onPointerMove:p,onPointerUp:h,className:"flex items-center justify-between px-3 py-2 border-b border-[#3d3d3d] cursor-move select-none",children:[t.jsx("span",{className:"text-[11px] font-mono font-semibold tracking-widest text-gray-300",children:"SCENARIOS"}),t.jsx("button",{type:"button",onClick:a,onPointerDown:m=>m.stopPropagation(),"aria-label":"Close scenarios",className:"text-gray-400 hover:text-white text-lg leading-none px-1 cursor-pointer",children:"×"})]}),t.jsx("div",{className:"overflow-y-auto p-2 flex flex-col gap-2 flex-1 min-h-0",children:f.map(m=>{const g=m.slug===e.slug,x=m.screenshotPaths[0];return t.jsxs("button",{type:"button",onClick:()=>s(m.slug),className:`flex items-center gap-3 w-full p-2 rounded-lg text-left transition-colors cursor-pointer border ${g?"border-[var(--lime-300)] bg-[#1a2a30]":"border-[#333] hover:bg-[#242424]"}`,children:[t.jsx("div",{className:"w-24 h-16 shrink-0 rounded-md overflow-hidden border border-[#3d3d3d] bg-[#0f0f0f] flex items-center justify-center",children:x?t.jsx("img",{src:ds(x),alt:"",className:"w-full h-full object-cover"}):t.jsx("span",{className:"text-[10px] text-gray-600",children:"No preview"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-[11px] text-gray-500 truncate",children:m.url??"component"}),t.jsx("div",{className:`text-sm font-medium truncate ${g?"text-white":"text-gray-200"}`,children:Ao(m)})]})]},m.slug)})}),t.jsx("button",{type:"button",onClick:r,className:"border-t border-[#3d3d3d] px-3 py-2.5 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 JJ=Object.freeze(Object.defineProperty({__proto__:null,LivePageScenariosModal:Tv},Symbol.toStringTag,{value:"Module"})),hs={apps:[],isSingleApp:!1,onSelectApps:()=>{},onSelectApp:()=>{},onSelectRoute:()=>{}};function jD(e){const[n,s]=l.useState({status:"idle"}),{scenariosVersion:r}=Tn();return l.useEffect(()=>{if(!e){s({status:"idle"});return}let a=!1;return s({status:"loading"}),(async()=>{try{const o=await fetch(`/api/entities/${e}`);if(a)return;if(o.status===404){s({status:"not-found"});return}if(!o.ok){s({status:"error",message:`HTTP ${o.status}`});return}const i=await o.json(),c={...i,scenarios:Array.isArray(i.scenarios)?i.scenarios.map(zc):[]};s({status:"loaded",entity:c})}catch(o){if(a)return;s({status:"error",message:o instanceof Error?o.message:"Failed to load entity"})}})(),()=>{a=!0}},[e,r]),n}function ja({message:e}){return t.jsx("div",{className:"px-5 py-8",children:t.jsx(tt,{text:e,className:"text-sm text-[var(--accent-red)]",rowClassName:"justify-center"})})}const XJ=Object.freeze(Object.defineProperty({__proto__:null,AppDetailContentError:ja},Symbol.toStringTag,{value:"Module"}));function Sl(){return t.jsx("div",{className:"px-5 py-8 text-center text-[var(--text-dim)]",children:"Loading routes..."})}const QJ=Object.freeze(Object.defineProperty({__proto__:null,AppDetailContentLoading:Sl},Symbol.toStringTag,{value:"Module"}));function wD(e){return e.kind==="function"?"Functions don't have visual scenarios. Coverage for this function lives in its unit tests.":e.kind==="component"?`No component scenarios for ${e.displayName}. Create one with \`codeyam-editor editor register\` or capture from the live preview.`:"No scenarios for this entity yet."}function Pv({entityRef:e,onNavigate:n}){return t.jsxs("button",{type:"button",onClick:()=>n(e.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:[t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.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:e.kind}),t.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:e.name})]}),t.jsx("p",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:e.filePath})]})}const ZJ=Object.freeze(Object.defineProperty({__proto__:null,EntityRefCard:Pv},Symbol.toStringTag,{value:"Module"}));function wa({refs:e,onNavigate:n}){return t.jsx("ul",{className:"grid grid-cols-1 gap-1",children:e.map(s=>t.jsx("li",{children:t.jsx(Pv,{entityRef:s,onNavigate:n})},s.hash))})}const eX=Object.freeze(Object.defineProperty({__proto__:null,EntityRefList:wa},Symbol.toStringTag,{value:"Module"}));function _D(e,n,s){const[r,a]=l.useState(!1),[o,i]=l.useState(""),[c,d]=l.useState(!1),u=l.useCallback(()=>{a(!0),i(n)},[n]),p=l.useCallback(()=>{a(!1)},[]),h=l.useCallback(async()=>{if(!(!o.trim()||c)){d(!0);try{const f=await fetch(`/api/scenarios/${encodeURIComponent(e)}`);if(!f.ok)throw new Error(`HTTP ${f.status}`);const m=await f.json();m.name=o.trim(),await fetch(`/api/scenarios/${encodeURIComponent(e)}`,{method:"DELETE"}),await fetch("/api/scenarios",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)}),a(!1),s()}catch{}finally{d(!1)}}},[o,c,e,s]);return{renaming:r,renameName:o,renameSaving:c,setRenameName:i,startRename:u,cancelRename:p,submitRename:h}}function SD(e,n,s){const[r,a]=l.useState(!1),o=l.useCallback(async i=>{if(i.stopPropagation(),!!confirm(`Delete scenario "${n}"?`)){a(!0);try{await fetch(`/api/scenarios/${encodeURIComponent(e)}`,{method:"DELETE"}),s()}catch{}finally{a(!1)}}},[n,e,s]);return{deleting:r,handleDelete:o}}function kD({mocks:e,seeds:n}){const s=[];return e>0&&s.push(`${e} ${e===1?"mock":"mocks"} overridden`),n>0&&s.push(`${n} ${n===1?"seed":"seeds"} overridden`),s.length===0?null:s.join(" · ")}function Ov({overrideCounts:e}){const n=e?kD(e):null;return n?t.jsx("div",{className:"text-xs text-[var(--text-dim)] mt-1",children:n}):null}const tX=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRowOverrideBadge:Ov},Symbol.toStringTag,{value:"Module"})),ND=new Set(["Desktop"]);function Rv(e){var n,s;return(n=e.componentName)!=null&&n.trim()?`Isolated ${e.componentName.trim()} component`:(s=e.url)!=null&&s.trim()?`Renders ${e.url.trim()}`:e.scenarioType==="component"?"Component scenario":"Application scenario"}function Ev({scenario:e,isSelected:n}){var r;const s=e.dimensions.length>0&&!(e.dimensions.length===1&&ND.has(e.dimensions[0]));return t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:`text-base font-medium truncate ${n?"text-[var(--accent-active)]":"text-[var(--text-primary)]"}`,children:e.name}),(r=e.description)!=null&&r.trim()?t.jsx("div",{className:"text-sm text-[var(--text-secondary)] mt-1 whitespace-pre-line",children:e.description}):t.jsx("div",{className:"text-sm text-[var(--text-dim)] italic mt-1",children:Rv(e)}),t.jsx(Ov,{overrideCounts:e.overrideCounts}),t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s?t.jsx("span",{className:"text-xs text-[var(--text-dim)]",children:e.dimensions.join(", ")}):null,e.componentName?t.jsx("span",{className:"text-xs text-[var(--accent-purple)]",children:e.componentName}):null]})]})}const nX=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRowMeta:Ev,deriveRowLabel:Rv},Symbol.toStringTag,{value:"Module"}));function Av({screenshotPath:e,cacheBuster:n}){return t.jsx("div",{className:"h-[180px] w-[288px] shrink-0 flex items-center justify-center overflow-hidden rounded border border-[var(--border-subtle)] bg-[var(--bg-surface)]",children:t.jsx(kt,{screenshotPath:e??void 0,cacheBuster:n??void 0,alt:""})})}const sX=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRowThumbnail:Av},Symbol.toStringTag,{value:"Module"}));function Mv({onViewData:e,onRename:n,onDelete:s,deleting:r}){return t.jsxs("div",{className:"flex items-center gap-4 mt-2",children:[t.jsx("button",{onClick:e,className:"text-xs text-[var(--accent-active)] hover:opacity-70 cursor-pointer bg-transparent border-none p-0",children:"View / Edit Data"}),t.jsx("button",{onClick:n,className:"text-xs text-[var(--text-dim)] hover:text-[var(--text-primary)] cursor-pointer bg-transparent border-none p-0",children:"Rename"}),t.jsx("button",{onClick:s,disabled:r,className:"text-xs text-red-400/60 hover:text-red-400 cursor-pointer bg-transparent border-none p-0 disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:text-red-400/60",children:"Delete"})]})}const rX=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRowActions:Mv},Symbol.toStringTag,{value:"Module"}));function Iv({name:e,saving:n,onChange:s,onSubmit:r,onCancel:a}){return t.jsxs("form",{className:"flex items-center gap-2",onSubmit:r,onClick:o=>o.stopPropagation(),children:[t.jsx("input",{type:"text",value:e,onChange:o=>s(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:n}),t.jsx("button",{type:"submit",disabled:n||!e.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:n?"...":"Save"}),t.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 aX=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRenameForm:Iv},Symbol.toStringTag,{value:"Module"}));function Dv({scenario:e,isSelected:n,onSelect:s,onViewData:r,onScenariosChanged:a,children:o}){const i=_D(e.slug,e.name,a),{deleting:c,handleDelete:d}=SD(e.slug,e.name,a);return t.jsxs("div",{onClick:i.renaming?void 0:s,className:`rounded-lg p-3 text-left transition cursor-pointer ${n?"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:[t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx(Av,{screenshotPath:e.screenshotPaths[0]??null,cacheBuster:e.screenshotCapturedAtMs}),t.jsx("div",{className:"flex-1 min-w-0",children:i.renaming?t.jsx(Iv,{name:i.renameName,saving:i.renameSaving,onChange:i.setRenameName,onSubmit:u=>{u.preventDefault(),i.submitRename()},onCancel:i.cancelRename}):t.jsxs(t.Fragment,{children:[t.jsx(Ev,{scenario:e,isSelected:n}),n&&t.jsx(Mv,{onViewData:u=>{u.stopPropagation(),r()},onRename:u=>{u.stopPropagation(),i.startRename()},onDelete:d,deleting:c})]})})]}),o&&t.jsx("div",{className:"mt-3 cursor-default",onClick:u=>u.stopPropagation(),children:o})]})}const oX=Object.freeze(Object.defineProperty({__proto__:null,ScenarioRow:Dv},Symbol.toStringTag,{value:"Module"}));function Lv(){return t.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 iX=Object.freeze(Object.defineProperty({__proto__:null,RouteScenarioEmptyState:Lv},Symbol.toStringTag,{value:"Module"}));function Jd({scenarios:e,selectedSlug:n,onSelectScenario:s,onScenariosChanged:r}){const[a,o]=l.useState(null);return e.length===0?t.jsx(Lv,{}):t.jsx("div",{className:"grid grid-cols-1 gap-2",children:e.map(i=>t.jsx(Dv,{scenario:i,isSelected:i.slug===n,onSelect:()=>{a&&a!==i.slug&&o(null),s(i.slug)},onViewData:()=>o(a===i.slug?null:i.slug),onScenariosChanged:r,children:a===i.slug&&t.jsx(hR,{variant:"inline",slug:i.slug,scenarioName:i.name,onClose:()=>o(null)})},i.slug))})}const lX=Object.freeze(Object.defineProperty({__proto__:null,RouteScenarioList:Jd},Symbol.toStringTag,{value:"Module"})),CD="This component renders no other tracked components.",TD="This component imports no tracked functions.",PD="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 Fv({activeTab:e,entity:n,componentRefs:s,functionRefs:r,selectedSlug:a,onSelectScenario:o,onNavigateToEntity:i,onScenariosChanged:c}){return t.jsxs("div",{className:"flex-1 overflow-auto px-5 py-4",children:[e==="scenarios"&&(n.scenarios.length===0?t.jsx(rr,{copy:wD(n)}):t.jsx(Jd,{scenarios:n.scenarios,selectedSlug:a,onSelectScenario:o,onScenariosChanged:c})),e==="components"&&(s.length===0?t.jsx(rr,{copy:CD}):t.jsx(wa,{refs:s,onNavigate:i})),e==="functions"&&(r.length===0?t.jsx(rr,{copy:TD}):t.jsx(wa,{refs:r,onNavigate:i})),e==="callers"&&(n.callers.length===0?t.jsx(rr,{copy:PD}):t.jsx(wa,{refs:n.callers,onNavigate:i}))]})}function rr({copy:e}){return t.jsx("p",{className:"text-xs italic text-[var(--text-dim)]",children:e})}const cX=Object.freeze(Object.defineProperty({__proto__:null,EmptyTabCopy:rr,EntityDetailContent:Fv},Symbol.toStringTag,{value:"Module"}));function OD(e){return typeof e!="string"&&typeof e.onClick=="function"}function RD(e){return typeof e=="string"?e:e.label}function ED(e,n){(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),n())}function $v({segments:e}){if(e.length===0)return null;const n=e.length-1;return t.jsx("span",{className:"text-sm",style:{color:"var(--text-muted)"},children:e.map((s,r)=>{const a=RD(s),o=r===n,i=!o&&OD(s);return t.jsxs("span",{children:[t.jsx("span",{style:{color:"var(--text-dim)"},children:" / "}),i?t.jsx("button",{type:"button",onClick:s.onClick,onKeyDown:c=>ED(c,s.onClick),className:"cursor-pointer hover:text-[var(--text-primary)] transition",style:{color:"inherit",background:"none",padding:0},children:a}):t.jsx("span",{style:o?{color:"var(--text-primary)"}:void 0,children:a})]},r)})})}const dX=Object.freeze(Object.defineProperty({__proto__:null,BreadcrumbNav:$v},Symbol.toStringTag,{value:"Module"}));function Mo({apps:e,selectedApp:n,selectedRouteEntity:s,currentEntity:r,isSingleApp:a,onSelectApps:o,onSelectApp:i,onSelectRoute:c}){const d=[];if(!a&&e.length>0&&d.push({label:"Apps",onClick:o}),n){const p=s!==null||r!=null;a&&!p||d.push({label:n.name,onClick:()=>i(n.dir)})}return s!==null&&r!=null&&s?d.push({label:s.displayName,onClick:()=>c(s.route)}):s&&d.push({label:s.displayName}),r&&d.push({label:r.displayName}),t.jsx($v,{segments:d})}const uX=Object.freeze(Object.defineProperty({__proto__:null,EntityBreadcrumb:Mo},Symbol.toStringTag,{value:"Module"}));function zv({entity:e,app:n=null,routeEntity:s=null,navContext:r=hs}){var o;const a=e.kind==="component"?"Component":"Function";return t.jsxs("header",{className:"border-b border-[var(--border-subtle)] px-5 py-3",children:[t.jsx("div",{className:"mb-1",children:t.jsx(Mo,{apps:r.apps,selectedApp:n,selectedRouteEntity:s,currentEntity:e,isSingleApp:r.isSingleApp,onSelectApps:r.onSelectApps,onSelectApp:r.onSelectApp,onSelectRoute:r.onSelectRoute})}),t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.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}),t.jsx("h2",{className:"text-base font-semibold text-[var(--text-primary)]",children:e.displayName})]}),t.jsx("p",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:e.filePath}),((o=e.glossaryEntry)==null?void 0:o.description)&&t.jsx("p",{className:"mt-2 text-xs text-[var(--text-secondary)]",children:e.glossaryEntry.description})]})}const pX=Object.freeze(Object.defineProperty({__proto__:null,EntityDetailHeader:zv},Symbol.toStringTag,{value:"Module"})),AD=["scenarios","components","functions"];function Xd({activeTab:e,onTabChange:n,scenarioCount:s,componentCount:r=0,functionCount:a=0,callersCount:o=0,tabs:i=AD}){const c={scenarios:"Scenarios",components:"Components",functions:"Functions",callers:"Callers"},d={scenarios:s,components:r,functions:a,callers:o};return t.jsx("div",{className:"flex w-full border-t border-b border-[var(--border-default)]",children:i.map(u=>t.jsxs("button",{onClick:()=>n(u),className:`cursor-pointer px-4 py-2 font-mono text-xs font-medium uppercase tracking-wider transition border-b-2 ${e===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 hX=Object.freeze(Object.defineProperty({__proto__:null,RouteEntityTabs:Xd},Symbol.toStringTag,{value:"Module"})),MD=["scenarios","components","functions"],ID=["scenarios","callers"];function Bv({app:e=null,navContext:n=hs,routeEntity:s=null,entity:r,selectedSlug:a,onSelectScenario:o,onNavigateToEntity:i,onScenariosChanged:c}){const[d,u]=l.useState("scenarios"),{componentRefs:p,functionRefs:h}=l.useMemo(()=>{const m=[],g=[];for(const x of r.directImports)x.kind==="function"?g.push(x):m.push(x);return{componentRefs:m,functionRefs:g}},[r.directImports]),f=r.kind==="function"?ID:MD;return t.jsxs("div",{className:"flex flex-col",children:[t.jsx(zv,{app:e,navContext:n,routeEntity:s,entity:r}),t.jsx(Xd,{activeTab:d,onTabChange:u,scenarioCount:r.scenarios.length,componentCount:p.length,functionCount:h.length,callersCount:r.callers.length,tabs:f}),t.jsx(Fv,{activeTab:d,entity:r,componentRefs:p,functionRefs:h,selectedSlug:a,onSelectScenario:o,onNavigateToEntity:i,onScenariosChanged:c})]})}const fX=Object.freeze(Object.defineProperty({__proto__:null,EntityDetail:Bv},Symbol.toStringTag,{value:"Module"}));function DD(e){const n=[],s=[];for(const r of e)yg(r.url)||(r.scenarioType==="component"?s.push(r):n.push(r));return{application:n,component:s}}function Wv({scenario:e,onPreview:n}){const s=e.screenshotPaths.length>0,[r,a]=l.useState(!1),o=s&&!r;return t.jsxs("div",{className:`rounded-lg border border-[var(--border-default)] bg-[var(--bg-surface)] p-3 ${n?"cursor-pointer hover:border-[var(--border-subtle)]":""}`,onClick:n,children:[o?t.jsx("img",{src:ds(e.screenshotPaths[0],e.screenshotCapturedAtMs),alt:e.name,className:"mb-2 w-full rounded border border-[var(--border-default)]",onError:()=>a(!0)}):t.jsx("div",{className:"mb-2 flex h-32 items-center justify-center rounded border border-dashed border-[var(--border-default)] text-sm text-[var(--text-dim)]",children:"No screenshot"}),t.jsx("p",{className:"text-sm font-medium text-[var(--text-secondary)]",children:e.name}),t.jsxs("div",{className:"mt-1 flex gap-1",children:[e.hasMocks&&t.jsx("span",{className:"rounded bg-[var(--accent-blue)]/20 px-1.5 py-0.5 text-xs text-[var(--accent-blue)]",children:"mocks"}),e.hasSeed&&t.jsx("span",{className:"rounded bg-[var(--accent-purple)]/20 px-1.5 py-0.5 text-xs text-[var(--accent-purple)]",children:"seed"}),e.dimensions.map(i=>t.jsx("span",{className:"rounded bg-[var(--bg-input)] px-1.5 py-0.5 text-xs text-[var(--text-muted)]",children:i},i))]})]})}const mX=Object.freeze(Object.defineProperty({__proto__:null,ScenarioCard:Wv},Symbol.toStringTag,{value:"Module"}));function kl({label:e,scenarios:n,onSelectScenario:s,className:r}){return t.jsxs("section",{className:r,children:[t.jsx("h3",{className:"mb-3 text-xs font-semibold uppercase tracking-wide text-[var(--text-muted)]",children:e}),t.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",children:n.map(a=>t.jsx(Wv,{scenario:a,onPreview:()=>s(a.slug)},a.slug))})]})}const gX=Object.freeze(Object.defineProperty({__proto__:null,ScenarioTypeSection:kl},Symbol.toStringTag,{value:"Module"}));function Hv({feature:e,passed:n,failed:s,total:r}){return t.jsxs("div",{className:"px-5 py-2 flex items-center gap-3",children:[t.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:e}),t.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:[r," test",r!==1?"s":""]}),r>0&&t.jsxs("span",{className:`text-xs font-medium ${s>0?"text-[var(--accent-red)]":"text-[var(--accent-green)]"}`,children:[n,"/",r]})]})}const xX=Object.freeze(Object.defineProperty({__proto__:null,TestGroupHeader:Hv},Symbol.toStringTag,{value:"Module"}));function qv({test:e}){const n=(e.description??"").length>0,s=e.status==="passed"?"text-[var(--accent-green)]":e.status==="failed"?"text-[var(--accent-red)]":"text-[var(--text-dim)]",r=e.status==="passed"?"✓":e.status==="failed"?"✗":"○";return t.jsxs("div",{className:"flex items-start gap-2 py-1 px-3",children:[t.jsx("span",{className:`text-xs leading-5 ${s}`,children:r}),t.jsx("div",{className:"min-w-0",children:n?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-xs text-[var(--text-secondary)] truncate",children:e.description}),t.jsx("p",{className:"font-mono text-[10px] text-[var(--text-dim)] truncate",children:e.key})]}):t.jsx("p",{className:"text-xs text-[var(--text-secondary)] truncate",children:e.key})})]})}const bX=Object.freeze(Object.defineProperty({__proto__:null,TestGroupRow:qv},Symbol.toStringTag,{value:"Module"}));function Uv({groups:e}){return e.length===0?t.jsx("div",{className:"px-5 py-8 text-center text-[var(--text-dim)]",children:"No tests found."}):t.jsx("div",{className:"py-3",children:e.map(n=>{const s=n.tests.filter(o=>o.status==="passed").length,r=n.tests.filter(o=>o.status==="failed").length,a=n.tests.length;return t.jsxs("div",{className:"mb-1",children:[t.jsx(Hv,{feature:n.feature,passed:s,failed:r,total:a}),t.jsx("div",{className:"px-5 pb-2",children:n.tests.map((o,i)=>t.jsx(qv,{test:o},`${o.file}-${o.key??o.line??i}`))})]},n.feature)})})}const yX=Object.freeze(Object.defineProperty({__proto__:null,TestGroupList:Uv},Symbol.toStringTag,{value:"Module"}));function Yv({allScenarios:e,testGroups:n,onSelectScenario:s}){const{application:r,component:a}=DD(e),o=r.length>0||a.length>0;return t.jsxs("div",{className:"px-5 py-5",children:[o?t.jsxs(t.Fragment,{children:[r.length>0&&t.jsx(kl,{label:"Application",scenarios:r,onSelectScenario:s}),a.length>0&&t.jsx(kl,{label:"Component",scenarios:a,onSelectScenario:s,className:r.length>0?"mt-8":void 0})]}):t.jsx("p",{className:"text-sm text-[var(--text-dim)]",children:"No scenarios yet"}),t.jsx("div",{className:"mt-8",children:t.jsx(Uv,{groups:n})})]})}const vX=Object.freeze(Object.defineProperty({__proto__:null,NonWebAppDetail:Yv},Symbol.toStringTag,{value:"Module"}));function LD(e,n){const s=[],r=[];for(const a of e){const o=ps(a);/^[A-Z]/.test(o)&&!o.startsWith("use")?s.push(a):r.push(a)}return{componentImports:s,functionImports:r}}function Gv({ancestor:e,onNavigateToEntity:n}){const s=n?()=>n(Br(e.filePath,ps(e.filePath))):void 0;return t.jsxs("div",{role:"button",tabIndex:0,onClick:s,onKeyDown:r=>{s&&(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),s())},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:[t.jsx("p",{className:"text-sm font-medium text-[var(--text-primary)]",children:e.displayName}),t.jsx("p",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:e.filePath})]})}const jX=Object.freeze(Object.defineProperty({__proto__:null,LayoutChainCard:Gv},Symbol.toStringTag,{value:"Module"}));function Vv({layoutChain:e,onNavigateToEntity:n}){return e.length===0?null:t.jsxs("section",{className:"border-b border-[var(--border-subtle)] px-5 py-3",children:[t.jsx("h3",{className:"mb-2 text-xs font-medium uppercase tracking-wide text-[var(--text-dim)]",children:"Layout chain"}),t.jsx("div",{className:"flex flex-col gap-1",children:e.map(s=>t.jsx(Gv,{ancestor:s,onNavigateToEntity:n},`${s.kind}:${s.filePath}`))})]})}const wX=Object.freeze(Object.defineProperty({__proto__:null,LayoutChainSection:Vv},Symbol.toStringTag,{value:"Module"}));function FD({importPath:e,derivedName:n,allScenarios:s,routeEntities:r}){const a=s.filter(i=>i.scenarioType==="component"&&(i.pageFilePath===e||i.componentName===n)),o=r.filter(i=>i.directImports.length===1&&i.directImports[0]===e&&ps(i.directImports[0])===n);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 _a(e){const n=[];for(const s of e.split("/"))s===""||s==="."||(s===".."?n.pop():n.push(s));return n.join("/")}function $D(e){const n=new Map;for(const[s,r]of Object.entries(e)){const a=_a(s),o=ps(a),i=Br(a,o);n.has(i)||n.set(i,{hash:i,filePath:a,entityName:o,imports:r.imports.map(_a),importedBy:r.importedBy.map(_a)})}return n}function zD(e,n){if(!e)return null;const s=_a(n);for(const r of e.values())if(r.filePath===s)return r;return null}function Kv(e,n){if(!e)return[];const s=[];for(const r of n){const a=zD(e,r);a&&s.push(a)}return s}function BD(e,n){return e.find(s=>s.pageFilePath===n)??null}function Jv(e){const n=e.split("/"),s=n.pop()??e,r=n.join("/");return{fileName:s,dirPath:r}}function Xv({displayName:e,entity:n,isNavigable:s}){return t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"text-lg font-semibold text-[var(--text-secondary)]",children:e}),n?t.jsx("span",{className:"rounded bg-[var(--bg-input)] px-1.5 py-0.5 font-mono text-[9px] text-[var(--text-dim)]",children:n.hash.slice(0,8)}):null,s?t.jsx("span",{className:"ml-auto text-[10px] text-[var(--text-dim)]",children:"→"}):null]})}const _X=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyCardHeader:Xv},Symbol.toStringTag,{value:"Module"}));function Qv({scenarios:e,onSelectScenario:n}){return e.length===0?t.jsx("p",{className:"mt-1 text-[10px] text-[var(--text-dim)]",children:"No scenarios"}):t.jsxs("div",{className:"mt-2 flex flex-row gap-1.5",children:[e.slice(0,4).map(s=>{const r=s.screenshotPaths[0]??null;return t.jsxs("button",{type:"button",onClick:a=>{a.stopPropagation(),n(s.slug)},className:"flex w-[192px] shrink-0 flex-col gap-1 transition",children:[t.jsx("div",{className:"flex h-[120px] w-[192px] items-center justify-center overflow-hidden rounded border border-[var(--border-subtle)] bg-[var(--bg-card)] transition hover:border-[var(--border-default)]",children:t.jsx(kt,{screenshotPath:r??void 0,alt:s.name})}),t.jsx("span",{className:"w-full truncate text-center text-[10px] text-[var(--text-secondary)]",children:s.name})]},s.slug)}),e.length>4&&t.jsx("div",{className:"flex h-[120px] items-center px-1",children:t.jsxs("span",{className:"text-[10px] text-[var(--text-dim)]",children:["+",e.length-4]})})]})}const SX=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyScenarioStrip:Qv},Symbol.toStringTag,{value:"Module"}));function Zv({importPath:e,entity:n,scenarios:s,onNavigate:r,onSelectScenario:a}){const{fileName:o,dirPath:i}=Jv(e),c=(n==null?void 0:n.entityName)??o.replace(/\.[^.]+$/,"");return t.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:[t.jsx(Xv,{displayName:c,entity:n,isNavigable:r!==null}),t.jsxs("p",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:[i,"/"]}),t.jsx(Qv,{scenarios:s,onSelectScenario:a})]})}const kX=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyCard:Zv},Symbol.toStringTag,{value:"Module"}));function ej(){return t.jsx("p",{className:"py-4 text-center text-xs text-[var(--text-dim)]",children:"No dependencies found"})}const NX=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyEmptyState:ej},Symbol.toStringTag,{value:"Module"}));function tj({directImports:e,entityLookup:n,allScenarios:s,routeEntities:r,onNavigateToRoute:a,onNavigateToEntity:o,onSelectScenario:i}){const c=l.useMemo(()=>Kv(n,e),[n,e]);return e.length===0?t.jsx(ej,{}):t.jsx("div",{className:"grid grid-cols-1 gap-1",children:e.map(d=>{const u=c.find(x=>x.filePath===d)??null,p=(u==null?void 0:u.entityName)??ps(d),h=FD({importPath:d,derivedName:p,allScenarios:s??[],routeEntities:r??[]}),f=BD(r??[],d),m=Br(d,p),g=f?()=>a(f.route):o?()=>o(m):null;return t.jsx(Zv,{importPath:d,entity:u,scenarios:h,onNavigate:g,onSelectScenario:i},d)})})}const CX=Object.freeze(Object.defineProperty({__proto__:null,RouteDependencyList:tj},Symbol.toStringTag,{value:"Module"}));function WD(e,n,s){const r=new Set,a=e.replace(/\.(ts|tsx)$/,"");r.add(`${a}.test.ts`),r.add(`${a}.test.tsx`);const o=n.get(e);if(o!=null&&o.importedBy)for(const c of o.importedBy)/\.test\.(ts|tsx)$/.test(c)&&r.add(c);return s.flatMap(c=>c.tests).filter(c=>r.has(c.file))}function nj({status:e}){return e==="passed"?t.jsx("span",{className:"mt-0.5 text-xs text-[var(--accent-green)]",children:"✓"}):e==="failed"?t.jsx("span",{className:"mt-0.5 text-xs text-[var(--accent-red)]",children:"✗"}):t.jsx("span",{className:"mt-0.5 text-xs text-[var(--text-dim)]",children:"○"})}const TX=Object.freeze(Object.defineProperty({__proto__:null,TestStatusIcon:nj},Symbol.toStringTag,{value:"Module"}));function sj({test:e}){const n=e.description.length>0;return t.jsxs("div",{className:"flex items-start gap-2 py-1",children:[t.jsx(nj,{status:e.status}),t.jsx("div",{children:n?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:e.description}),t.jsx("p",{className:"font-mono text-xs text-[var(--text-dim)]",children:e.key})]}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:e.key}),t.jsx("p",{className:"text-xs italic text-[var(--text-dim)]",children:"no description"})]})})]})}const PX=Object.freeze(Object.defineProperty({__proto__:null,TestItem:sj},Symbol.toStringTag,{value:"Module"}));function rj({importPath:e,entityName:n,tests:s,onNavigate:r}){const{dirPath:a}=Jv(e);return t.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:[t.jsx("p",{className:"text-sm font-medium text-[var(--text-primary)]",children:n}),t.jsxs("p",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:[a,"/"]}),t.jsx("div",{className:"mt-2",children:s.length>0?t.jsx("div",{className:"space-y-0.5",children:s.map((o,i)=>t.jsx(sj,{test:o},`${o.file}:${o.key??o.line??i}`))}):t.jsx("p",{className:"text-xs text-[var(--text-dim)] italic",children:"No tests"})})]})}const OX=Object.freeze(Object.defineProperty({__proto__:null,RouteFunctionCard:rj},Symbol.toStringTag,{value:"Module"}));function aj(){return t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"No function imports found"}),t.jsx("p",{className:"mt-1 text-xs text-[var(--text-dim)]",children:"This component only imports other components"})]})}const RX=Object.freeze(Object.defineProperty({__proto__:null,RouteFunctionEmptyState:aj},Symbol.toStringTag,{value:"Module"}));function oj({functionImports:e,entityLookup:n,testGroups:s,onNavigateToEntity:r}){const a=l.useMemo(()=>Kv(n,e),[n,e]);return e.length===0?t.jsx(aj,{}):t.jsx("div",{className:"grid grid-cols-1 gap-1",children:e.map(o=>{const i=a.find(p=>p.filePath===o)??null,c=(i==null?void 0:i.entityName)??ps(o),d=WD(o,n,s),u=r?()=>r(Br(o,c)):null;return t.jsx(rj,{importPath:o,entityName:c,tests:d,onNavigate:u},o)})})}const EX=Object.freeze(Object.defineProperty({__proto__:null,RouteFunctionList:oj},Symbol.toStringTag,{value:"Module"}));function ij({activeTab:e,routeEntity:n,componentImports:s,functionImports:r,testGroups:a,selectedSlug:o,entityLookup:i,allScenarios:c,routeEntities:d,onSelectScenario:u,onNavigateToRoute:p,onNavigateToEntity:h,onScenariosChanged:f}){return t.jsxs("div",{className:"flex-1 overflow-auto px-5 py-4",children:[e==="scenarios"&&t.jsx(Jd,{scenarios:n.scenarios,selectedSlug:o,onSelectScenario:u,onScenariosChanged:f}),e==="components"&&t.jsx(tj,{directImports:s,entityLookup:i,allScenarios:c,routeEntities:d,onNavigateToRoute:p,onNavigateToEntity:h,onSelectScenario:u}),e==="functions"&&t.jsx(oj,{functionImports:r,entityLookup:i,testGroups:a,onNavigateToEntity:h})]})}const AX=Object.freeze(Object.defineProperty({__proto__:null,RouteEntityDetailContent:ij},Symbol.toStringTag,{value:"Module"}));function lj({displayName:e,pageFilePath:n,app:s=null,routeEntity:r=null,navContext:a=hs}){return t.jsxs("div",{className:"px-5 py-4",children:[t.jsx("div",{className:"mb-2",children:t.jsx(Mo,{apps:a.apps,selectedApp:s,selectedRouteEntity:r,isSingleApp:a.isSingleApp,onSelectApps:a.onSelectApps,onSelectApp:a.onSelectApp,onSelectRoute:a.onSelectRoute})}),t.jsx("h2",{className:"text-xl font-medium text-[var(--text-primary)]",children:e}),n?t.jsx("p",{className:"mt-1 font-mono text-xs text-[var(--text-dim)]",children:n}):null]})}const MX=Object.freeze(Object.defineProperty({__proto__:null,RouteEntityDetailHeader:lj},Symbol.toStringTag,{value:"Module"}));function cj({app:e=null,navContext:n=hs,routeEntity:s,selectedSlug:r,entityLookup:a,allScenarios:o,routeEntities:i,testGroups:c,onSelectScenario:d,onNavigateToRoute:u,onNavigateToEntity:p,onScenariosChanged:h}){const[f,m]=l.useState("scenarios"),{componentImports:g,functionImports:x}=l.useMemo(()=>LD(s.directImports),[s.directImports]);return t.jsxs("div",{className:"flex flex-col",children:[t.jsx(lj,{app:e,navContext:n,routeEntity:s,displayName:s.displayName,pageFilePath:s.pageFilePath}),t.jsx(Vv,{layoutChain:s.layoutChain??[],onNavigateToEntity:p}),t.jsx(Xd,{activeTab:f,onTabChange:m,scenarioCount:s.scenarios.length,componentCount:g.length,functionCount:x.length}),t.jsx(ij,{activeTab:f,routeEntity:s,componentImports:g,functionImports:x,testGroups:c,selectedSlug:r,entityLookup:a,allScenarios:o,routeEntities:i,onSelectScenario:d,onNavigateToRoute:u,onNavigateToEntity:p,onScenariosChanged:h})]})}const IX=Object.freeze(Object.defineProperty({__proto__:null,RouteEntityDetail:cj},Symbol.toStringTag,{value:"Module"}));function dj(){return t.jsx("div",{className:"px-5 py-8 text-center text-[var(--text-dim)]",children:"No routes discovered yet."})}const DX=Object.freeze(Object.defineProperty({__proto__:null,RouteListEmptyState:dj},Symbol.toStringTag,{value:"Module"}));function uj({label:e="Pages"}={}){return t.jsx("div",{className:"mb-3",children:t.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-[var(--text-dim)]",children:e})})}const LX=Object.freeze(Object.defineProperty({__proto__:null,RouteListSectionHeader:uj},Symbol.toStringTag,{value:"Module"}));function Nl({label:e,routeEntities:n,onSelectRoute:s,onSelectScenario:r,className:a}){return t.jsxs("div",{className:a,children:[t.jsx(uj,{label:e}),t.jsx("div",{children:n.map(o=>t.jsx(Gd,{routeEntity:o,onSelectRoute:s,onSelectScenario:r},o.route))})]})}const FX=Object.freeze(Object.defineProperty({__proto__:null,RouteListSection:Nl},Symbol.toStringTag,{value:"Module"}));function pj({providerLabel:e,chatOpen:n,onToggleChat:s}){const r=n?"border-[var(--accent-active)] bg-[var(--accent-active)]/15 text-[var(--accent-active)]":"border-[var(--border-default)] bg-transparent text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:border-[var(--accent-active)]/40";return t.jsxs("button",{type:"button",onClick:s,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 rounded border text-xs cursor-pointer transition-colors ${r}`,title:`Open a chat with ${e} to investigate why this page is not shown`,children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.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"})}),n?"Close":`Investigate with ${e}`]})}const $X=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPageInvestigateButton:pj},Symbol.toStringTag,{value:"Module"}));function hj({displayName:e,path:n}){return t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm text-[var(--text-primary)] truncate",children:e}),t.jsx("p",{className:"text-xs font-mono text-[var(--text-dim)] truncate",children:n})]})}const zX=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPageRowSummary:hj},Symbol.toStringTag,{value:"Module"}));function HD(e,n){return n==="scaffold"?[`The page \`${e}\` is marked \`untestabilityReason.kind = scaffold\` in the glossary, so it is intentionally excluded from the App tab's product route list.`,"Confirm that marking is correct: read the file and decide whether it is genuinely a scaffold / dev-only shim rather than product surface.","If it IS a real product route, remove the scaffold marking and register it properly (deconstruct it into the glossary and capture at least one scenario for it). If the marking is correct, say so and explain in one line why — no changes needed."].join(`
|
|
41
|
+
|
|
42
|
+
`):[`The page \`${e}\` is discovered on disk but has NO glossary entry, so codeyam cannot tell whether it is product surface — it is excluded from the App tab's route list until it is registered.`,"Investigate whether it is a real product route.","If it IS product surface, deconstruct and register it in the glossary and capture at least one scenario for it so it appears in the route list. If it is instead a scaffold or dev-only shim, add it to the glossary marked `untestabilityReason.kind = scaffold` with a justification."].join(`
|
|
43
|
+
|
|
44
|
+
`)}function qD({path:e,reason:n}){return["You are helping inside the user's actual codeyam project — this is real work in a real repository, not a hypothetical.","Before doing anything, read `.codeyam/stack.json` and the page file itself so your fix fits this project's stack.",HD(e,n),"Propose the concrete change and, once the user agrees, make it. Prefer real edits and commands over generic advice."].join(`
|
|
45
|
+
|
|
46
|
+
`)}function fj(e){return e.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}function mj({page:e}){const[n,s]=l.useState(!1),{config:r}=St(),a=Qe(r==null?void 0:r.provider);return t.jsxs("div",{className:"border border-[var(--border-subtle)] rounded mb-2",children:[t.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[t.jsx(hj,{displayName:e.displayName,path:e.path}),t.jsx(pj,{providerLabel:a,chatOpen:n,onToggleChat:()=>s(o=>!o)})]}),n&&t.jsx("div",{className:"px-3 py-2 border-t border-[var(--border-subtle)]",children:t.jsx(qt,{chatName:`fix-unsurfaced-${fj(e.path)}`,prompt:qD({path:e.path,reason:e.reason}),height:360,onClose:()=>s(!1)})})]})}const BX=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPageRow:mj,chatSlug:fj},Symbol.toStringTag,{value:"Module"}));function gj({label:e,pages:n}){return n.length===0?null:t.jsxs("div",{className:"mb-4",children:[t.jsx("p",{className:"mb-2 text-xs text-[var(--text-dim)]",children:e}),n.map(s=>t.jsx(mj,{page:s},s.path))]})}const WX=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPageGroup:gj},Symbol.toStringTag,{value:"Module"}));function xj({count:e,collapsed:n,onToggle:s}){return t.jsxs("button",{type:"button",onClick:s,className:"mb-3 flex items-center gap-2 cursor-pointer group","aria-expanded":!n,children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`text-[var(--text-dim)] transition-transform ${n?"":"rotate-90"}`,children:t.jsx("path",{d:"M9 18l6-6-6-6"})}),t.jsxs("p",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-[var(--text-dim)] group-hover:text-[var(--text-primary)]",children:["Not shown (",e,")"]})]})}const HX=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPagesSectionHeader:xj},Symbol.toStringTag,{value:"Module"})),UD=[{reason:"missing-from-glossary",label:"Missing from glossary"},{reason:"scaffold",label:"Marked as scaffold"}];function bj({pages:e}){const[n,s]=l.useState(!0);return e.length===0?null:t.jsxs("div",{className:"mt-8",children:[t.jsx(xj,{count:e.length,collapsed:n,onToggle:()=>s(r=>!r)}),!n&&t.jsx("div",{children:UD.map(({reason:r,label:a})=>t.jsx(gj,{label:a,pages:e.filter(o=>o.reason===r)},r))})]})}const qX=Object.freeze(Object.defineProperty({__proto__:null,UnsurfacedPagesSection:bj},Symbol.toStringTag,{value:"Module"}));function yj({routeEntities:e,unsurfacedPages:n=[],componentSurfaceReason:s=null,onSelectRoute:r,onSelectScenario:a,tabbed:o=!1}){if(e.length===0&&n.length===0)return t.jsx(dj,{});const i=e.filter(d=>(d.kind??"application")==="application"),c=e.filter(d=>d.kind==="component");return o?t.jsx("div",{className:"px-5 pb-5",children:t.jsx(Nv,{pages:i,components:c,componentSurfaceReason:s,onSelectRoute:r,onSelectScenario:a})}):t.jsxs("div",{className:"px-5 py-5",children:[e.length===0&&t.jsx("p",{className:"text-sm text-[var(--text-dim)]",children:"No routes are being shown — every discovered page was excluded. See below."}),i.length>0&&t.jsx(Nl,{label:"Pages",routeEntities:i,onSelectRoute:r,onSelectScenario:a}),c.length>0&&t.jsx(Nl,{label:"Components",routeEntities:c,onSelectRoute:r,onSelectScenario:a,className:i.length>0?"mt-8":void 0}),t.jsx(bj,{pages:n})]})}const UX=Object.freeze(Object.defineProperty({__proto__:null,RouteList:yj},Symbol.toStringTag,{value:"Module"}));function Qd({app:e=null,navContext:n=hs,isWeb:s,routeEntities:r,unsurfacedPages:a,componentSurfaceReason:o,routesLoading:i,routesError:c,selectedEntityHash:d,selectedRouteEntity:u,testGroups:p,selectedSlug:h,entityLookup:f,allScenarios:m,onSelectScenario:g,onSelectRoute:x,onSelectEntity:b,onBackToRoutes:y,onScenariosChanged:v,routeListTabbed:j=!1}){const _=jD(d&&!u?d:null);return s?i?t.jsx(Sl,{}):c?t.jsx(ja,{message:c}):u?t.jsx(cj,{app:e,navContext:n,routeEntity:u,selectedSlug:h,entityLookup:f,allScenarios:m,routeEntities:r,testGroups:p,onSelectScenario:g,onNavigateToRoute:x,onNavigateToEntity:b,onScenariosChanged:v}):d?_.status==="loading"||_.status==="idle"?t.jsx(Sl,{}):_.status==="not-found"?t.jsx(ja,{message:"Entity not found. The dependency graph may need to be refreshed."}):_.status==="error"?t.jsx(ja,{message:_.message}):t.jsx(Bv,{app:e,navContext:n,routeEntity:u,entity:_.entity,selectedSlug:h,onSelectScenario:g,onNavigateToEntity:b??(()=>{}),onScenariosChanged:v}):t.jsx(yj,{routeEntities:r,unsurfacedPages:a,componentSurfaceReason:o,onSelectRoute:x,onSelectScenario:g,tabbed:j}):t.jsx(Yv,{allScenarios:m,testGroups:p,onSelectScenario:g})}const YX=Object.freeze(Object.defineProperty({__proto__:null,AppDetailContent:Qd},Symbol.toStringTag,{value:"Module"}));function vj({children:e}){return t.jsx("div",{style:{display:"flex",alignItems:"center",minHeight:40,margin:"0 0 16px",fontFamily:'"IBM Plex Sans", sans-serif',WebkitFontSmoothing:"antialiased"},children:t.jsx("h2",{className:"home-sectitle",style:{color:"var(--text-strong)",margin:0},children:e})})}const GX=Object.freeze(Object.defineProperty({__proto__:null,ExploreSectionHeading:vj},Symbol.toStringTag,{value:"Module"})),YD={id:"simulations",label:"Simulations"},GD={id:"site-content",label:"Site Content"},VD={id:"setup",label:"Setup"};function jj({active:e,onChange:n,showSetup:s=!1,showSiteContent:r=!1,children:a}){const o=[YD,...r?[GD]:[],...s?[VD]:[]];return o.length===1?t.jsx("div",{children:a}):t.jsxs("div",{children:[t.jsx("div",{role:"tablist","aria-label":"Explore your app",className:"flex items-center gap-6 border-b border-[var(--border-subtle)] mb-5",children:o.map(i=>{const c=i.id===e;return t.jsx("button",{type:"button",role:"tab","aria-selected":c,onClick:()=>n(i.id),className:`font-sans text-xs font-semibold tracking-wide uppercase pb-2 -mb-px border-b-2 transition ${c?"text-[var(--text-primary)] border-[var(--text-primary)]":"text-[var(--text-dim)] border-transparent hover:text-[var(--text-secondary)]"}`,children:i.label},i.id)})}),t.jsx("div",{role:"tabpanel",children:a})]})}const VX=Object.freeze(Object.defineProperty({__proto__:null,HomeExploreTabs:jj},Symbol.toStringTag,{value:"Module"}));async function vs(e){const n=await e.json().catch(()=>({}));if(!e.ok)throw new Error(n.error??`Request failed (${e.status})`);return n}function nf(e,n,s,r){return fetch("/api/site-content/entry",{method:e,headers:{"Content-Type":"application/json"},body:JSON.stringify({collection:n,slug:s,fields:r.fields,body:r.body})})}const yn={async entry(e,n){const s=new URLSearchParams({collection:e,slug:n});return vs(await fetch(`/api/site-content/entry?${s}`))},async save(e,n,s){return vs(await nf("PUT",e,n,s))},async savePartial(e,n,s,r){return vs(await fetch("/api/site-content/entry",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({collection:e,slug:n,fields:s,body:r})}))},async saveSetting(e,n){await vs(await fetch("/api/site-content/setting",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:e,value:n})}))},async create(e,n,s){return vs(await nf("POST",e,n,s))},async goLive(){await vs(await fetch("/api/site-content/live",{method:"POST"}))},async restartDevServer(){await fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"restart",waitForHealthy:!0})})}};function KD({manifest:e,open:n,entry:s,draft:r,onEntrySaved:a,onSaved:o,onError:i,onOpenCollection:c}){const[d,u]=l.useState(!0),[p,h]=l.useState(null),[f,m]=l.useState(null),[g,x]=l.useState(),b=l.useRef(null),y=l.useMemo(()=>GM(e),[e]),v=(k,S)=>{var C;const N=(C=e.collections)==null?void 0:C.find(T=>T.id===(k==null?void 0:k.collection));return(N==null?void 0:N.fields.find(T=>T.name===S.field))??{name:S.field,label:S.label,type:S.kind==="html"?"html":S.type}},j=async(k,S)=>{if(Si(k,n)&&r)return{value:S?r.fields[S]:r.body,file:s==null?void 0:s.file};const N=await yn.entry(k.collection,k.slug),C=ks(N);return{value:S?C.fields[S]:C.body,file:N.file}},_=async(k,S,N,C)=>{if(k==="setting"){await yn.saveSetting(N,Array.isArray(C)?C.join(", "):C);return}if(!S)throw new Error("This text isn't linked to an entry, so there is nowhere to save it.");const P=k==="body"?await yn.savePartial(S.collection,S.slug,{},String(C)):await yn.savePartial(S.collection,S.slug,{[N]:C});Si(S,n)&&a(P,R=>XM(R,k,N,C))},w=()=>{b.current=null,h(null),m(null)};return{onPage:d,onPageChange:k=>{u(k),w()},fields:y,scrollY:g,popover:p,editingField:f,onSelect:k=>{var T;if(k.kind==="nav"){const P=(T=e.collections)==null?void 0:T.find(R=>R.id==="navigation"||R.id==="nav");P&&c(P.id);return}const S=k.kind==="setting"?null:Wh(k.entry,n);b.current={sel:k,ref:S},x(k.scrollY),m(Si(S,n)?k.kind==="body"?"body":k.field:null);const N=JM(k);if(!S||!k.rect||!N)return;const C=k.rect;if(N==="body")j(S,null).then(({value:P,file:R})=>h({kind:"body",rect:C,file:R,body:String(P??"")}),P=>i(String(P)));else{const P=v(S,k);j(S,k.field).then(({value:R})=>h({kind:"field",rect:C,def:P,entryLabel:`${S.collection}/${S.slug}`,value:R}),R=>i(String(R)))}},onCommit:k=>{const S=k.kind==="setting"?null:Wh(k.entry,n),N=S?v(S,{kind:k.kind,entry:k.entry,field:k.field}):void 0;x(k.scrollY),m(null),_(k.kind,S,k.field,VM(N==null?void 0:N.type,k.value)).then(o,C=>i(C instanceof Error?C.message:String(C)))},onCancel:w,onPopoverSave:k=>{const S=b.current;!S||!p||(h({...p,saving:!0,error:void 0}),_(S.sel.kind,S.ref,S.sel.field,k).then(()=>{w(),o()},N=>h(C=>C&&{...C,saving:!1,error:N instanceof Error?N.message:String(N)})))}}}function Cl(e,n){return(n==null?void 0:n.previewOrigin)??(e==null?void 0:e.previewOrigin)??null}function Zd(e,n){if(!e||!/^https?:\/\//i.test(e))return!0;const s=typeof window<"u"?window.location.origin:null;if(!s)return!1;try{return new URL(e).origin===s}catch{return!0}}function wj(e){return e!=null&&e.fields.some(n=>n.name==="name")?"name":"title"}function _j(e){const n=wj(e);return((e==null?void 0:e.fields)??[]).filter(s=>s.required&&s.name!==n)}function JD(e,n,s){return!e.title.trim()||!n||_j(s).some(r=>!String(e.fields[r.name]??"").trim())}function XD(e,n){return e==="pages"?`/${n}/`:`/${e}/${n}/`}async function QD(e,n,s=fetch){const r=`http://127.0.0.1:${e}${n}`;try{const o=await(await s(`/api/probe-url?url=${encodeURIComponent(r)}`)).json();return!!(o!=null&&o.ok)}catch{return!1}}async function sf(e,n,s,{fetchImpl:r=fetch,delayMs:a=1e3,sleep:o=i=>new Promise(c=>setTimeout(c,i))}={}){for(let i=0;i<s;i+=1){if(await QD(e,n,r))return!0;i<s-1&&await o(a)}return!1}function Sj({label:e,entries:n,selectedSlug:s,search:r="",sort:a="date",onSearchChange:o,onSortChange:i,onSelect:c,onNew:d}){const u=aI(n,r,a);return t.jsxs("div",{className:"flex flex-col gap-2 min-h-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h3",{className:"flex-1 text-sm font-semibold text-[var(--text-primary)]",children:e}),t.jsx("button",{type:"button",onClick:d,className:"text-xs font-medium px-2 py-1 rounded border border-[var(--border-default)] text-[var(--text-primary)] hover:bg-[var(--bg-card)]",children:"+ New page"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"search",value:r,placeholder:"Search","aria-label":`Search ${e}`,onChange:p=>o==null?void 0:o(p.target.value),className:"flex-1 min-w-0 text-sm px-2 py-1 rounded bg-[var(--bg-input)] border border-[var(--border-subtle)] text-[var(--text-primary)]"}),t.jsxs("select",{value:a,"aria-label":"Sort entries",onChange:p=>i==null?void 0:i(p.target.value),className:"text-xs px-1.5 py-1 rounded bg-[var(--bg-input)] border border-[var(--border-subtle)] text-[var(--text-secondary)]",children:[t.jsx("option",{value:"date",children:"Newest"}),t.jsx("option",{value:"title",children:"A–Z"})]})]}),t.jsxs("ul",{className:"flex flex-col overflow-y-auto",children:[u.map(p=>t.jsx("li",{children:t.jsx(ab,{entry:p,active:p.slug===s,onSelect:c})},p.slug)),u.length===0?t.jsx("li",{className:"px-2 py-3 text-xs text-[var(--text-dim)]",children:r.trim()?"No entries match.":"No entries yet."}):null]})]})}const KX=Object.freeze(Object.defineProperty({__proto__:null,SiteContentEntryList:Sj},Symbol.toStringTag,{value:"Module"}));function kj({collections:e,draft:n,derivedSlug:s,creating:r=!1,error:a,onChange:o,onCreate:i,onCancel:c}){const d=e.find(f=>f.id===n.collectionId),u=_j(d),p=n.slug??s,h=JD(n,p,d);return t.jsxs("form",{className:"flex flex-col gap-3 max-w-lg",onSubmit:f=>{f.preventDefault(),h||i==null||i()},children:[t.jsx("h3",{className:"text-base font-semibold text-[var(--text-primary)]",children:"New page"}),t.jsxs("label",{className:"text-xs font-medium text-[var(--text-secondary)]",children:["Collection",t.jsx("select",{value:n.collectionId,onChange:f=>o==null?void 0:o({...n,collectionId:f.target.value}),className:`${Kt} mt-1`,children:e.filter(f=>f.kind!=="singleton").map(f=>t.jsx("option",{value:f.id,children:f.singular??f.label},f.id))})]}),t.jsxs("label",{className:"text-xs font-medium text-[var(--text-secondary)]",children:["Title",t.jsx("input",{value:n.title,autoFocus:!0,onChange:f=>o==null?void 0:o({...n,title:f.target.value}),className:`${Kt} mt-1`})]}),t.jsxs("label",{className:"text-xs font-medium text-[var(--text-secondary)]",children:["Address",t.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[t.jsxs("span",{className:"text-xs font-mono text-[var(--text-dim)]",children:["/",n.collectionId==="pages"?"":`${n.collectionId}/`]}),t.jsx("input",{value:p,onChange:f=>o==null?void 0:o({...n,slug:f.target.value}),className:`${Kt} font-mono text-xs`})]})]}),u.map(f=>t.jsxs("label",{className:"text-xs font-medium text-[var(--text-secondary)]",children:[f.label??f.name,t.jsx("span",{className:"text-[var(--accent-red)]",children:" *"}),t.jsx("input",{type:f.type==="date"?"date":"text",value:String(n.fields[f.name]??""),onChange:m=>o==null?void 0:o({...n,fields:{...n.fields,[f.name]:m.target.value}}),className:`${Kt} mt-1`})]},f.name)),t.jsx(tt,{text:a}),t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx("button",{type:"submit",disabled:h||r,className:"text-sm font-medium px-3 py-1.5 rounded bg-[var(--accent-primary)] text-[var(--text-on-accent)] disabled:opacity-40",children:r?"Creating…":"Create"}),t.jsx("button",{type:"button",onClick:c,className:"text-sm px-3 py-1.5 rounded text-[var(--text-secondary)] hover:bg-[var(--bg-card)]",children:"Cancel"})]})]})}const JX=Object.freeze(Object.defineProperty({__proto__:null,SiteContentNewEntry:kj},Symbol.toStringTag,{value:"Module"}));function ZD(e,n){return e<=0||n<=0?1:Math.min(1,e/n)}function eL(e,{enabled:n,fields:s,scrollY:r,onSelect:a,onCommit:o,onCancel:i}){const[c,d]=l.useState(null),[u,p]=l.useState(null),h=l.useRef({onSelect:a,onCommit:o,onCancel:i});h.current={onSelect:a,onCommit:o,onCancel:i};const f=l.useCallback(b=>{var y,v;(v=(y=e.current)==null?void 0:y.contentWindow)==null||v.postMessage(b,"*")},[e]),m=l.useCallback(b=>{n?f({type:"codeyam:content-edit:activate",fields:s,scrollY:b?r:void 0}):(f({type:"codeyam:content-edit:deactivate"}),p(null))},[n,s,r,f]);l.useEffect(()=>{m(!1)},[n,s,f]),l.useEffect(()=>{function b(y){var _,w,k,S,N,C,T,P;const v=(_=e.current)==null?void 0:_.contentWindow;if(!v||y.source!==v)return;const j=y.data;if(!(!j||typeof j.type!="string"))switch(j.type){case"codeyam:content-edit:regions":d(((w=j.payload)==null?void 0:w.count)??0);break;case"codeyam:content-edit:select":{const R=j.payload;p(R),(S=(k=h.current).onSelect)==null||S.call(k,R);break}case"codeyam:content-edit:commit":p(null),(C=(N=h.current).onCommit)==null||C.call(N,j.payload);break;case"codeyam:content-edit:cancel":p(null),(P=(T=h.current).onCancel)==null||P.call(T);break}}return window.addEventListener("message",b),()=>window.removeEventListener("message",b)},[e]);const g=l.useCallback(()=>{p(null),f({type:"codeyam:content-edit:cancel"})},[f]),x=l.useCallback(()=>{d(null),p(null),m(!0)},[m]);return{regionCount:c,selection:u,clearSelection:g,handleFrameLoad:x}}const tL={};function Nj({url:e,displayPath:n,emptyTitle:s="This entry has no page of its own",urlReason:r,urlGuessed:a=!1,reloadNonce:o=0,building:i=!1,screenSizes:c,screenSize:d,onScreenSizeChange:u,editOnPage:p,onEditOnPageChange:h,editFields:f=tL,editScrollY:m,editPopover:g=null,onEditSelect:x,onEditCommit:b,onEditCancel:y,onEditPopoverSave:v}){const j=l.useRef(null),_=l.useRef(null),[w,k]=l.useState({width:0,height:0}),S=c.find(R=>R.name===d)??c[0]??{name:"Desktop",width:1440,height:900},N=ZD(w.width,S.width),C=!!e&&!i,T=eL(_,{enabled:!!p&&C,fields:f,scrollY:m,onSelect:x,onCommit:b,onCancel:y});l.useEffect(()=>{const R=j.current;if(!R||typeof ResizeObserver>"u")return;const I=new ResizeObserver(([A])=>k({width:A.contentRect.width,height:A.contentRect.height}));return I.observe(R),()=>I.disconnect()},[]);const P=()=>{T.clearSelection(),y==null||y()};return t.jsxs("div",{className:"flex flex-col gap-2 min-h-0 h-full",children:[t.jsx(Vx,{address:e?`${n??e}${a?" (guessed)":""}`:"No page",editOnPage:C?p:void 0,regionCount:T.regionCount,screenSizes:c,screenSize:S.name,onEditOnPageChange:h,onScreenSizeChange:u}),C&&p&&T.regionCount===0?t.jsx(Yx,{}):null,t.jsxs("div",{ref:j,className:"relative flex-1 min-h-[320px] overflow-hidden rounded border border-[var(--border-subtle)] bg-[var(--bg-deep)]",children:[C?t.jsx("iframe",{ref:_,src:e,title:"Page preview",onLoad:T.handleFrameLoad,style:{width:S.width,height:S.height,border:"none",background:"white",transform:`scale(${N})`,transformOrigin:"top left"}},`${e}#${o}`):t.jsx(nb,{building:i,title:s,reason:r}),C&&(g==null?void 0:g.kind)==="body"?t.jsx(Xx,{anchor:Hh(g.rect,N),paneWidth:w.width,paneHeight:w.height,file:g.file,initialBody:g.body,saving:g.saving,error:g.error,onSave:R=>v==null?void 0:v(R),onCancel:P},`body-${o}`):null,C&&(g==null?void 0:g.kind)==="field"?t.jsx(Jx,{anchor:Hh(g.rect,N),paneWidth:w.width,paneHeight:w.height,def:g.def,entryLabel:g.entryLabel,initialValue:g.value,saving:g.saving,error:g.error,onSave:R=>v==null?void 0:v(R),onCancel:P},`field-${g.def.name}-${o}`):null]})]})}const XX=Object.freeze(Object.defineProperty({__proto__:null,SiteContentPreview:Nj},Symbol.toStringTag,{value:"Module"}));function Cj({manifest:e,selectedCollectionId:n,selectedSlug:s,entry:r,draft:a,dirty:o=!1,saveStatus:i="idle",saveError:c,newEntry:d,newEntryDerivedSlug:u="",newEntryCreating:p=!1,newEntryError:h,pendingSwitch:f=!1,search:m="",sort:g="date",previewUrl:x,previewReloadNonce:b=0,previewBuilding:y=!1,screenSizes:v,screenSize:j,onSelectCollection:_,onSelectEntry:w,onSearchChange:k,onSortChange:S,onDraftChange:N,onSave:C,onStartNew:T,onNewEntryChange:P,onCreate:R,onCancelNew:I,onConfirmSwitch:A,onCancelSwitch:O,onScreenSizeChange:W,edit:D}){const Y=e.collections??[],H=Y.find(M=>M.id===n)??null,E=(H==null?void 0:H.entries.find(M=>M.slug===s))??null,U=e.source==="inferred";return t.jsxs("div",{className:"flex flex-col gap-3",children:[U?t.jsx(eb,{}):null,t.jsxs("div",{className:"grid gap-4 min-h-[560px]",style:{gridTemplateColumns:"240px minmax(320px, 400px) minmax(0, 1fr)"},children:[t.jsxs("div",{className:"flex flex-col gap-4 min-h-0 border-r border-[var(--border-subtle)] pr-3",children:[t.jsx(ib,{collections:Y,selectedId:n,onSelect:_}),H&&H.kind!=="singleton"?t.jsx(Sj,{label:H.label,entries:H.entries,selectedSlug:s,search:m,sort:g,onSearchChange:k,onSortChange:S,onSelect:w,onNew:T}):null]}),t.jsxs("div",{className:"relative min-h-0",children:[d?t.jsx(kj,{collections:Y,draft:d,derivedSlug:u,creating:p,error:h,onChange:P,onCreate:R,onCancel:I}):r&&a?t.jsx(rb,{title:(E==null?void 0:E.title)??r.slug,file:r.file,fields:(H==null?void 0:H.fields)??[],draft:a,dirty:o,modified:r.modified,saveStatus:i,saveError:c,editingInPreview:(D==null?void 0:D.editingField)??null,onChange:N,onSave:C}):t.jsx("div",{className:"text-sm text-[var(--text-dim)] pt-8 text-center",children:"Pick a page on the left to edit it, or add a new one."}),f?t.jsx(tb,{onKeepEditing:O,onDiscard:A}):null]}),t.jsx(Nj,{url:d?null:x,displayPath:E==null?void 0:E.url,emptyTitle:d||!E?"Nothing to preview yet":"This entry has no page of its own",urlReason:d?"The preview appears once the page is created.":E?E.urlReason:"Pick a page to preview it here.",urlGuessed:U,reloadNonce:b,building:y,screenSizes:v,screenSize:j,onScreenSizeChange:W,editOnPage:D==null?void 0:D.onPage,onEditOnPageChange:D==null?void 0:D.onPageChange,editFields:D==null?void 0:D.fields,editScrollY:D==null?void 0:D.scrollY,editPopover:D==null?void 0:D.popover,onEditSelect:D==null?void 0:D.onSelect,onEditCommit:D==null?void 0:D.onCommit,onEditCancel:D==null?void 0:D.onCancel,onEditPopoverSave:D==null?void 0:D.onPopoverSave})]})]})}const QX=Object.freeze(Object.defineProperty({__proto__:null,SiteContentPanel:Cj},Symbol.toStringTag,{value:"Module"}));function Tj({manifest:e,refresh:n,selectedApp:s}){var L;const{config:r}=St(),a=(s==null?void 0:s.port)??(r==null?void 0:r.port)??3e3,o=Cl(r,s),i=q=>No(q,{appPort:a,currentPort:typeof window<"u"?ko(window.location):0,previewOrigin:o}),c=Object.entries((r==null?void 0:r.screenSizes)??{}).map(([q,se])=>({name:q,width:se.width,height:se.height})),d=(r==null?void 0:r.defaultScreenSize)??"Desktop",u=e.collections??[],[p,h]=l.useState({collectionId:((L=u.find(q=>q.kind!=="singleton"))==null?void 0:L.id)??"",slug:null}),[f,m]=l.useState(null),[g,x]=l.useState(null),[b,y]=l.useState("idle"),[v,j]=l.useState(),[_,w]=l.useState(null),[k,S]=l.useState(null),[N,C]=l.useState(!1),[T,P]=l.useState(),[R,I]=l.useState(""),[A,O]=l.useState("date"),[W,D]=l.useState(d),[Y,H]=l.useState(0),[E,U]=l.useState(!1),M=l.useRef(!1);l.useEffect(()=>{M.current||(M.current=!0,yn.goLive().then(()=>H(q=>q+1),()=>{}))},[]);const J=HE(f,g),ne=l.useCallback(async q=>{if(h(q),S(null),y("idle"),j(void 0),I(""),!q.slug){m(null),x(null);return}try{const se=await yn.entry(q.collectionId,q.slug);m(se),x(ks(se))}catch(se){m(null),x(null),j(String(se))}},[]),oe=q=>{J?w(q):ne(q)},ae=async()=>{if(!(!f||!g||!J)){y("saving");try{const q=await yn.save(f.collection,f.slug,g);m(q),x(ks(q)),y("saved"),H(se=>se+1),n()}catch(q){y("error"),j(q instanceof Error?q.message:String(q))}}},G=k?nd(k.title):"",ie=async()=>{if(!k)return;const q=k.slug??G,se=wj(u.find(fe=>fe.id===k.collectionId));C(!0),P(void 0);try{const fe=await yn.create(k.collectionId,q,{fields:{[se]:k.title,...k.fields},body:""});await n(),S(null),h({collectionId:fe.collection,slug:fe.slug}),m(fe),x(ks(fe));const we=XD(fe.collection,q);await sf(a,we,3)||(U(!0),await yn.restartDevServer(),await sf(a,we,30),U(!1)),H(De=>De+1)}catch(fe){P(fe instanceof Error?fe.message:String(fe))}finally{C(!1)}},le=KD({manifest:e,open:f?{collection:f.collection,slug:f.slug}:null,entry:f,draft:g,onEntrySaved:(q,se)=>{m(q),x(fe=>se(fe??ks(q)))},onSaved:()=>{y("saved"),j(void 0),H(q=>q+1),n()},onError:q=>{y("error"),j(q)},onOpenCollection:q=>oe({collectionId:q,slug:null})}),Z=u.find(q=>q.id===p.collectionId),z=Z==null?void 0:Z.entries.find(q=>q.slug===p.slug);return t.jsx(Cj,{manifest:e,selectedCollectionId:p.collectionId,selectedSlug:p.slug,entry:f,draft:g,dirty:J,saveStatus:b,saveError:v,newEntry:k,newEntryDerivedSlug:G,newEntryCreating:N,newEntryError:T,pendingSwitch:_!==null,search:R,sort:A,previewUrl:z!=null&&z.url?i(z.url):null,previewReloadNonce:Y,previewBuilding:E,screenSizes:c,screenSize:W,onSelectCollection:q=>oe({collectionId:q,slug:null}),onSelectEntry:q=>oe({collectionId:p.collectionId,slug:q}),onSearchChange:I,onSortChange:O,onDraftChange:q=>{x(q),b!=="saving"&&y("idle")},onSave:()=>void ae(),onStartNew:()=>S({collectionId:p.collectionId,title:"",slug:null,fields:{}}),onNewEntryChange:S,onCreate:()=>void ie(),onCancelNew:()=>S(null),onConfirmSwitch:()=>{const q=_;w(null),q&&ne(q)},onCancelSwitch:()=>w(null),onScreenSizeChange:D,edit:le})}const ZX=Object.freeze(Object.defineProperty({__proto__:null,SiteContentPanelConnected:Tj},Symbol.toStringTag,{value:"Module"}));function nL(){const[e,n]=l.useState(null),s=l.useCallback(async()=>{try{const r=await fetch("/api/site-content");if(!r.ok){n({detected:!1});return}n(await r.json())}catch{n({detected:!1})}},[]);return l.useEffect(()=>{s()},[s]),{manifest:e,refresh:s}}function Pj({appDetailProps:e,selectedApp:n,setupSlot:s}){var c,d;const[r,a]=l.useState("simulations"),o=nL(),i=!!((c=o.manifest)!=null&&c.detected);return t.jsx("div",{style:{padding:"14px 10% 50px"},children:t.jsxs("div",{style:{width:"100%",maxWidth:2200,marginInline:"auto",borderTop:"0.5px solid var(--line-subtle)",paddingTop:26},children:[t.jsx(vj,{children:"Explore your app"}),t.jsxs(jj,{active:r,onChange:a,showSetup:!!s,showSiteContent:i,children:[r==="simulations"?t.jsx("div",{className:"-mx-5",children:t.jsx(Qd,{...e,app:n,isWeb:(n==null?void 0:n.type)==="web",selectedEntityHash:e.selectedEntityHash??null,routeListTabbed:!0})}):null,r==="site-content"&&((d=o.manifest)!=null&&d.detected)?t.jsx(Tj,{manifest:o.manifest,refresh:o.refresh,selectedApp:n}):null,r==="setup"?s:null]})]})})}const eQ=Object.freeze(Object.defineProperty({__proto__:null,HomeExploreSection:Pj},Symbol.toStringTag,{value:"Module"}));function Ce({icon:e,title:n,meta:s,onBack:r,crumbLabel:a,assistKey:o}){return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"crumbs",children:[t.jsx("button",{type:"button",className:"back",onClick:r,"aria-label":"Back",children:"←"}),t.jsx("button",{type:"button",onClick:r,children:"Home"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("button",{type:"button",onClick:r,children:"Setup"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("b",{children:a??n})]}),t.jsxs("div",{className:"htitle",children:[t.jsx("div",{className:"hic",children:e}),t.jsxs("div",{children:[t.jsx("div",{className:"h",children:n}),t.jsx("div",{className:"hmeta",children:s})]})]})]})}function $n({topic:e,step:n,onBack:s}){return t.jsxs("div",{className:"crumbs",children:[s?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"back",onClick:s,"aria-label":"Back",children:"←"}),t.jsx("button",{type:"button",onClick:s,children:e})]}):t.jsx("span",{children:e}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("b",{children:n})]})}function wn({steps:e,currentKey:n}){const s=e.findIndex(r=>r.key===n);return t.jsx("div",{className:"flowbar",children:e.map((r,a)=>t.jsxs("span",{style:{display:"contents"},children:[a>0?t.jsx("span",{className:"fsep"}):null,t.jsxs("span",{className:"fstep"+(a<s?" done":a===s?" active":""),children:[t.jsx("span",{className:"fn",children:a<s?"✓":a+1}),r.label]})]},r.key))})}function Re({label:e,note:n,status:s,onComplete:r,onRevert:a,onBack:o,doneLabel:i="Completed"}){const[c,d]=l.useState(!1);return s==="done"||c?t.jsx("div",{className:"cta-wrap",children:t.jsxs("div",{className:"cta-done",children:[t.jsxs("span",{className:"cta-done-check",children:[t.jsx("span",{className:"ce",children:"✓"})," ",i]}),t.jsxs("div",{className:"cta-done-actions",children:[o?t.jsx("button",{type:"button",className:"lf-back",onClick:o,children:"Back to Setup"}):null,a?t.jsx("button",{type:"button",className:"cta-revert",onClick:()=>{a(),d(!1)},children:"Mark as not complete"}):null]})]})}):t.jsxs("div",{className:"cta-wrap",children:[t.jsxs("button",{type:"button",className:"cta",onClick:()=>{r(),d(!0)},children:[t.jsx("span",{className:"ce",children:"✓"})," ",e]}),t.jsx("div",{className:"cta-note",children:n})]})}const tQ=Object.freeze(Object.defineProperty({__proto__:null,SetupCompleteCta:Re,SetupDetailHeader:Ce,SetupFlowBar:wn,SetupSubCrumb:$n},Symbol.toStringTag,{value:"Module"}));function Io({initial:e,color:n}){return t.jsx("div",{className:"altmark",style:{background:n,width:46,height:46},children:e})}function eu({provider:e}){return t.jsxs("div",{className:"provcard"+(e.bestFit?" best":""),children:[t.jsx(Io,{initial:e.initial,color:e.color}),t.jsxs("div",{className:"provbody",children:[t.jsxs("div",{className:"provtop",children:[t.jsx("span",{className:"provname",children:e.name}),e.bestFit?t.jsx("span",{className:"bestfit",children:"Best fit"}):null]}),t.jsx("div",{className:"provdesc",children:e.description}),t.jsx("div",{className:"reasons",children:e.reasons.map(n=>t.jsxs("div",{className:"reason",children:[t.jsx(lt,{}),t.jsxs("span",{children:[t.jsx("b",{children:n.lead})," ",n.rest]})]},n.lead))}),t.jsx("div",{className:"chips",children:e.chips.map(n=>t.jsx("span",{className:"chip",children:n},n))})]})]})}function Oj({alts:e}){const[n,s]=l.useState(!1);return e.length===0?null:t.jsxs("div",{children:[t.jsxs("button",{type:"button",className:"alt-toggle",onClick:()=>s(r=>!r),children:[n?"Hide other options":"Not for you? See other options",t.jsx("span",{className:"chev",style:{transform:n?"rotate(180deg)":"none"},children:"⌄"})]}),n?t.jsx("div",{className:"alts",children:e.map(r=>t.jsxs("div",{className:"altcard",children:[t.jsx("div",{className:"altmark",style:{background:r.color},children:r.initial}),t.jsxs("div",{className:"altbody",children:[t.jsx("div",{className:"altname",children:r.name}),t.jsx("div",{className:"altdesc",children:r.description})]}),t.jsx("button",{type:"button",className:"altpick",children:"Use this"})]},r.name))}):null]})}function yt({items:e}){return e.length===0?null:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"seclabel",style:{marginTop:34},children:"FAQ"}),t.jsx(Rj,{items:e})]})}function Rj({items:e}){const[n,s]=l.useState(-1);return e.length===0?null:t.jsx("div",{className:"faq",children:e.map((r,a)=>t.jsxs("div",{className:"faqitem",children:[t.jsxs("button",{type:"button",className:"faqq"+(n===a?" open":""),onClick:()=>s(n===a?-1:a),children:[r.q,t.jsx("span",{className:"chev",children:"⌄"})]}),n===a?t.jsx("div",{className:"faqa",children:r.a}):null]},r.q))})}const nQ=Object.freeze(Object.defineProperty({__proto__:null,Alternatives:Oj,FaqSection:yt,ProviderCard:eu,ProviderMark:Io,TopicFaq:Rj},Symbol.toStringTag,{value:"Module"}));function tu({icon:e,title:n,meta:s,crumbLabel:r,assistKey:a,onBack:o,lead:i,illustration:c,chatPrompt:d,onChatWithAI:u,faqs:p}){return t.jsxs("div",{className:"hosting-screen setup-topic",children:[t.jsx(Ce,{icon:e,title:n,meta:s,crumbLabel:r,onBack:o,assistKey:a}),t.jsx("div",{className:"lead",children:i}),c,t.jsx("div",{className:"cta-wrap",children:t.jsx("button",{type:"button",className:"cta",onClick:()=>u==null?void 0:u(d),children:"Chat with the AI about this"})}),t.jsx(yt,{items:p})]})}const sQ=Object.freeze(Object.defineProperty({__proto__:null,SetupTopicPage:tu},Symbol.toStringTag,{value:"Module"}));function ts({before:e,after:n}){return t.jsxs("div",{className:"setup-ill ill-split",children:[t.jsxs("div",{className:"isplit",children:[t.jsx("div",{className:"isplit-tag",children:e.tag}),e.items.map(s=>t.jsxs("div",{className:"isplit-row",children:[t.jsx("span",{className:"mk",children:"✕"}),t.jsx("span",{children:s})]},s))]}),t.jsx("div",{className:"isplit-arrow",children:"→"}),t.jsxs("div",{className:"isplit after",children:[t.jsx("div",{className:"isplit-tag",children:n.tag}),n.items.map(s=>t.jsxs("div",{className:"isplit-row",children:[t.jsx("span",{className:"mk",children:"✓"}),t.jsx("span",{children:s})]},s))]})]})}function ns({rows:e}){return t.jsx("div",{className:"setup-ill",children:t.jsx("div",{className:"ill-stack",children:e.map(n=>t.jsxs("div",{className:n.lime?"istack-row lime":"istack-row",children:[t.jsx("span",{className:"istack-emoji",children:n.emoji}),t.jsx("span",{className:"istack-lbl",children:n.label}),n.sub?t.jsx("span",{className:"istack-sub",children:n.sub}):null]},n.label))})})}function ss({center:e,satellites:n}){return t.jsx("div",{className:"setup-ill",children:t.jsxs("div",{className:"ill-orbit",children:[t.jsxs("div",{className:"iorbit-center",children:[t.jsx("div",{className:"iorbit-tile",children:e.emoji}),t.jsx("div",{className:"iorbit-lbl",children:e.label})]}),t.jsx("div",{className:"iorbit-sats",children:n.map(s=>t.jsx("div",{className:"iorbit-sat",children:s},s))})]})})}function Sa({bars:e}){return t.jsx("div",{className:"setup-ill",children:t.jsx("div",{className:"ill-bars",children:e.map(n=>t.jsxs("div",{className:n.lime?"ibar lime":"ibar",children:[t.jsx("div",{className:"ibar-fill",style:{height:`${n.pct}%`}}),t.jsx("div",{className:"ibar-lbl",children:n.label})]},n.label))})})}function On({emoji:e,caption:n,chips:s}){return t.jsxs("div",{className:"setup-ill",children:[t.jsxs("div",{className:"ill-emblem",children:[t.jsx("div",{className:"iemblem-tile",children:e}),t.jsx("div",{className:"iemblem-chips",children:s.map(r=>t.jsx("span",{className:"iemblem-chip",children:r},r))})]}),t.jsx("div",{className:"ill-cap",children:n})]})}function Tl({channels:e}){return t.jsx("div",{className:"setup-ill",children:t.jsx("div",{className:"ill-channels",children:e.map(n=>t.jsxs("div",{className:n.on?"ichan on":"ichan",children:[t.jsx("div",{className:"ichan-lbl",children:n.label}),t.jsx("div",{className:"ichan-track",children:Array.from({length:n.dots}).map((s,r)=>t.jsxs(l.Fragment,{children:[r>0?t.jsx("span",{className:"ichan-line"}):null,t.jsx("span",{className:"ichan-dot"})]},r))})]},n.label))})})}const rQ=Object.freeze(Object.defineProperty({__proto__:null,SetupBars:Sa,SetupChannels:Tl,SetupEmblem:On,SetupOrbit:ss,SetupSplit:ts,SetupStack:ns},Symbol.toStringTag,{value:"Module"}));function En({nodes:e}){return t.jsx("div",{className:"journey",children:t.jsx("div",{className:"jrow",children:e.map((n,s)=>t.jsxs(l.Fragment,{children:[t.jsxs("div",{className:"jcol",children:[t.jsx("div",{className:n.lime?"jtile lime":"jtile",children:n.emoji}),t.jsx("div",{className:"jlbl",children:n.label}),t.jsx("div",{className:"jsub",children:n.sub})]}),s===e.length-1?null:t.jsxs("div",{className:"jconn",children:[t.jsx("span",{className:"jpacket"}),t.jsx("span",{children:"→"})]})]},n.label))})})}const aQ=Object.freeze(Object.defineProperty({__proto__:null,SetupJourney:En},Symbol.toStringTag,{value:"Module"}));function Ej(e){var a;const n=Object.values(((a=e.tests)==null?void 0:a.byRunner)??{}),s=n.reduce((o,i)=>o+(i.passed??0),0),r=n.reduce((o,i)=>o+(i.failed??0),0);return{total:s+r,passed:s,failed:r}}function Aj(e){const n=e??[];return{changed:n.filter(s=>s.status==="changed"),created:n.filter(s=>s.status==="new"),unchanged:n.filter(s=>s.status!=="changed"&&s.status!=="new")}}const sL=5e3,rf={headSha:null,branch:null};function rL(){const[e,n]=l.useState([]),[s,r]=l.useState(rf),[a,o]=l.useState(!0),[i,c]=l.useState(null),d=l.useRef(!1),u=l.useCallback(async h=>{if(!d.current){d.current=!0,h&&o(!0);try{const f=await fetch("/api/reviews");if(!f.ok)throw new Error(`HTTP ${f.status}`);const m=await f.json();n(m.reviews??[]),r(m.repoState??rf),c(m.error??null)}catch(f){c(f instanceof Error?f.message:"Failed to load reviews")}finally{h&&o(!1),d.current=!1}}},[]),p=l.useCallback(()=>u(!0),[u]);return l.useEffect(()=>{u(!0);const h=setInterval(()=>{u(!1)},sL);return()=>clearInterval(h)},[u]),{reviews:e,repoState:s,loading:a,error:i,reload:p}}function aL(e,n){var r;const s=(r=e.pr)==null?void 0:r.headRef;return!!s&&!!n.branch&&n.branch===s}function In({label:e,children:n}){return t.jsxs("div",{className:"mb-2",children:[t.jsx("p",{className:"text-xs font-medium mb-1",style:{color:"var(--text-muted)"},children:e}),t.jsx("div",{className:"mt-0.5",children:n})]})}const oQ=Object.freeze(Object.defineProperty({__proto__:null,LabeledSection:In},Symbol.toStringTag,{value:"Module"}));function Mj({files:e}){return e.length===0?null:t.jsx("div",{className:"max-h-32 overflow-y-auto",children:e.map(n=>t.jsxs("p",{className:"font-mono text-xs text-[var(--text-muted)]",children:[t.jsx(vo,{status:n.status})," ",n.path]},n.path))})}const iQ=Object.freeze(Object.defineProperty({__proto__:null,ModifiedFilesList:Mj},Symbol.toStringTag,{value:"Module"}));function oL(e){switch(e){case"blocker":return{bg:"var(--accent-red)",fg:"#fff"};case"concern":return{bg:"var(--accent-orange)",fg:"#111"};case"praise":return{bg:"var(--accent-green)",fg:"#111"};case"nit":default:return{bg:"var(--bg-subtle)",fg:"var(--text-muted)"}}}function Ij({finding:e}){const n=oL(e.severity),s=e.file&&(e.line!=null?`${e.file}:${e.line}`:e.file);return t.jsxs("div",{className:"flex flex-col gap-1 rounded border px-3 py-2",style:{borderColor:"var(--border-subtle)",background:"var(--bg-card)"},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide",style:{background:n.bg,color:n.fg},children:e.severity}),s&&t.jsx("span",{className:"font-mono text-xs truncate",style:{color:"var(--text-secondary)"},children:s})]}),t.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:e.comment})]})}const lQ=Object.freeze(Object.defineProperty({__proto__:null,ReviewFindingRow:Ij},Symbol.toStringTag,{value:"Module"}));function iL(e){switch(e){case"changed":return{bg:"var(--accent-orange)",fg:"#111",label:"changed"};case"new":return{bg:"var(--accent-green)",fg:"#111",label:"new"};case"unchanged":default:return{bg:"var(--bg-subtle)",fg:"var(--text-muted)",label:e}}}function Pl({label:e,path:n,onPreview:s}){const r=`${e} capture`,a=!!n&&!!s;return t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[t.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wide",style:{color:"var(--text-dim)"},children:e}),t.jsx("button",{type:"button",disabled:!a,onClick:a?()=>s(n,r):void 0,className:"relative h-32 w-full overflow-hidden rounded border p-0",style:{borderColor:"var(--border-subtle)",background:"var(--bg-subtle)",cursor:a?"zoom-in":"default"},title:a?"Click to view full size":void 0,children:t.jsx(kt,{screenshotPath:n,alt:r})})]})}function Dj({pair:e,walkable:n,headRef:s,prNumber:r,onPreviewImage:a}){const o=iL(e.status),i=e.status==="new",c=e.diffRatio!=null?`${(e.diffRatio*100).toFixed(1)}% changed`:null;return t.jsxs("div",{className:"flex flex-col gap-2 rounded-lg border p-3",style:{borderColor:"var(--border-default)",background:"var(--bg-card)"},children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-mono text-xs font-medium",style:{color:"var(--text-primary)"},children:e.slug}),t.jsx("span",{className:"rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide",style:{background:o.bg,color:o.fg},children:o.label}),e.beforeStale&&t.jsx("span",{"data-testid":"before-stale-badge",className:"rounded px-1.5 py-0.5 text-[10px] font-medium",style:{background:"var(--bg-subtle)",color:"var(--accent-orange)"},title:"The before capture was already stale at the merge base — treat the comparison with caution.",children:"before stale"}),c&&t.jsx("span",{className:"text-[10px]",style:{color:"var(--text-dim)"},children:c})]}),t.jsxs("div",{className:"flex gap-2",children:[!i&&t.jsx(Pl,{label:"Before",path:e.beforePath,onPreview:a}),t.jsx(Pl,{label:"After",path:e.afterPath,onPreview:a})]}),e.note&&t.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:e.note}),n?t.jsx("a",{href:`/scenario/${encodeURIComponent(e.slug)}`,"data-testid":"view-live-link",className:"self-start rounded border px-2 py-1 text-xs",style:{borderColor:"var(--border-default)",color:"var(--accent-blue)"},children:"View live →"}):t.jsxs("p",{"data-testid":"walk-hint",className:"text-[11px]",style:{color:"var(--text-dim)"},children:["Check out the PR to walk this scenario live",r!=null?t.jsxs(t.Fragment,{children:[" — ",t.jsxs("span",{className:"font-mono",children:["gh pr checkout ",r]})]}):s?t.jsxs(t.Fragment,{children:[" — ",t.jsxs("span",{className:"font-mono",children:["git checkout ",s]})]}):null]})]})}const cQ=Object.freeze(Object.defineProperty({__proto__:null,CapturePane:Pl,ScenarioComparisonRow:Dj},Symbol.toStringTag,{value:"Module"}));function Lj({scenarios:e,walkable:n,headRef:s,prNumber:r,onPreviewImage:a}){const[o,i]=l.useState(!1),{changed:c,created:d,unchanged:u}=Aj(e);if((e??[]).length===0)return t.jsx(In,{label:"Impacted scenarios",children:t.jsx("p",{className:"text-xs",style:{color:"var(--text-dim)"},children:"No UI-impacting scenarios — this digest leads with tests and blast radius below."})});const p=h=>t.jsx(Dj,{pair:h,walkable:n,headRef:s,prNumber:r,onPreviewImage:a},h.slug);return t.jsx(In,{label:"Impacted scenarios",children:t.jsxs("div",{className:"flex flex-col gap-2",children:[c.map(p),d.map(p),u.length>0&&t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>i(h=>!h),"data-testid":"toggle-unchanged",className:"self-start text-xs",style:{color:"var(--accent-blue)"},children:[o?"Hide":"Show"," ",u.length," unchanged downstream scenario",u.length===1?"":"s"]}),o&&u.map(p)]})]})})}const dQ=Object.freeze(Object.defineProperty({__proto__:null,ScenarioImpactSection:Lj},Symbol.toStringTag,{value:"Module"}));function Fj({review:e,repoState:n,onPreviewImage:s}){var d,u,p,h,f,m,g,x,b;const r=Ej(e),a=aL(e,n),o=e.findings??[],i=((d=e.tests)==null?void 0:d.added)??[],c=(((u=e.blastRadius)==null?void 0:u.changedFiles)??[]).map(y=>({path:y,status:"modified"}));return t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[((p=e.pr)==null?void 0:p.number)!=null&&t.jsxs("span",{className:"font-mono text-xs",style:{color:"var(--text-secondary)"},children:["#",e.pr.number]}),((h=e.pr)==null?void 0:h.author)&&t.jsxs("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:["by ",e.pr.author]}),((f=e.pr)==null?void 0:f.url)&&t.jsx("a",{href:e.pr.url,target:"_blank",rel:"noreferrer",className:"text-xs",style:{color:"var(--accent-blue)"},children:"View PR ↗"}),e.postedCommentUrl&&t.jsx("a",{href:e.postedCommentUrl,target:"_blank",rel:"noreferrer",className:"text-xs",style:{color:"var(--accent-blue)"},children:"Posted comment ↗"})]}),((m=e.pr)==null?void 0:m.title)&&t.jsx("h3",{className:"text-sm font-semibold",style:{color:"var(--text-primary)"},children:e.pr.title})]}),t.jsx(Lj,{scenarios:e.scenarios??[],walkable:a,headRef:(g=e.pr)==null?void 0:g.headRef,prNumber:(x=e.pr)==null?void 0:x.number,onPreviewImage:s}),e.narrative&&t.jsx(In,{label:"What this PR does",children:t.jsx(bo,{children:e.narrative})}),t.jsx(In,{label:"Tests",children:t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(yo,{total:r.total,passed:r.passed,failed:r.failed}),i.length>0?t.jsx("ul",{className:"flex flex-col gap-1.5",children:i.map((y,v)=>t.jsxs("li",{className:"flex flex-col",children:[t.jsx("span",{className:"font-mono text-xs",style:{color:"var(--text-secondary)"},children:y.name??y.file??"test"}),y.description&&t.jsx("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:y.description})]},y.file??y.name??v))}):t.jsx("p",{className:"text-xs",style:{color:"var(--text-dim)"},children:"No new tests added."})]})}),o.length>0&&t.jsx(In,{label:`Findings (${o.length})`,children:t.jsx("div",{className:"flex flex-col gap-2",children:o.map((y,v)=>t.jsx(Ij,{finding:y},`${y.file??"f"}-${v}`))})}),((b=e.alignment)==null?void 0:b.summary)&&t.jsx(In,{label:"Codeyam alignment",children:t.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:e.alignment.summary})}),c.length>0&&t.jsx(In,{label:"Changed files",children:t.jsx(Mj,{files:c})})]})}const uQ=Object.freeze(Object.defineProperty({__proto__:null,ReviewDetailCard:Fj},Symbol.toStringTag,{value:"Module"}));function lL(e){const n=e.findings??[];return{blocker:n.filter(s=>s.severity==="blocker").length,concern:n.filter(s=>s.severity==="concern").length,total:n.length}}function cL(e){return e==null?null:new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function $j({review:e,repoState:n,expanded:s,onToggle:r}){var d,u,p;if(e.parseError)return t.jsxs("div",{className:"rounded-lg border p-4",style:{borderColor:"var(--accent-red)",background:"var(--bg-card)"},children:[t.jsxs("p",{className:"text-sm font-medium",style:{color:"var(--accent-red)"},children:[e.id,": could not read digest"]}),t.jsx(tt,{text:e.parseError,copyText:`${e.id}: could not read digest
|
|
47
|
+
${e.parseError??""}`,className:"text-xs text-[var(--text-dim)]",rowClassName:"mt-1"})]});const a=Aj(e.scenarios),o=lL(e),i=Ej(e),c=cL(e.createdAtMs);return t.jsxs("div",{className:"rounded-lg border",style:{borderColor:"var(--border-default)",background:"var(--bg-card)"},children:[t.jsxs("button",{type:"button",onClick:r,className:"flex w-full flex-col gap-2 px-4 py-3 text-left",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[((d=e.pr)==null?void 0:d.number)!=null&&t.jsxs("span",{className:"font-mono text-xs",style:{color:"var(--text-secondary)"},children:["#",e.pr.number]}),t.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--text-primary)"},children:((u=e.pr)==null?void 0:u.title)??e.id}),((p=e.pr)==null?void 0:p.author)&&t.jsxs("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:["by ",e.pr.author]}),c&&t.jsxs("span",{className:"text-xs",style:{color:"var(--text-dim)"},children:["· ",c]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs",children:[t.jsxs("span",{style:{color:"var(--accent-orange)"},children:[a.changed.length," changed"]}),t.jsxs("span",{style:{color:"var(--accent-green)"},children:[a.created.length," new"]}),t.jsxs("span",{style:{color:"var(--text-dim)"},children:[a.unchanged.length," unchanged"]}),o.total>0&&t.jsxs("span",{style:{color:"var(--text-muted)"},children:[o.blocker>0&&`${o.blocker} blocker · `,o.concern>0&&`${o.concern} concern · `,o.total," finding",o.total===1?"":"s"]}),i.total>0&&t.jsxs("span",{style:{color:i.failed>0?"var(--accent-red)":"var(--accent-green)"},children:[i.passed,"/",i.total," passed"]})]})]}),s&&t.jsx("div",{className:"px-4 pb-4 pt-1",style:{borderTop:"1px solid var(--border-subtle)"},children:t.jsx(Fj,{review:e,repoState:n})})]})}const pQ=Object.freeze(Object.defineProperty({__proto__:null,ReviewCard:$j},Symbol.toStringTag,{value:"Module"}));function zj({deviceLabel:e,actions:n}){return t.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:[t.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:[t.jsx("rect",{x:"2",y:"4",width:"20",height:"14",rx:"2"}),t.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9"}),t.jsx("line",{x1:"8",y1:"22",x2:"16",y2:"22"}),t.jsx("line",{x1:"12",y1:"18",x2:"12",y2:"22"})]}),t.jsxs("span",{className:"min-w-0",children:[t.jsxs("span",{className:"font-semibold",children:["Web preview — no ",e," running."]})," ",t.jsx("span",{style:{color:"var(--text-dim)"},children:"Boot a simulator for native fidelity (gestures, haptics, native storage)."})]}),n?t.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-3",children:n}):null]})}const hQ=Object.freeze(Object.defineProperty({__proto__:null,WebFallbackNotice:zj},Symbol.toStringTag,{value:"Module"}));function Bj({previewOrigin:e,onRecheck:n}){const s=()=>{window.open(e,"_blank","noopener")};return t.jsx("div",{role:"dialog","aria-label":"Preview sign-in required",className:"absolute inset-0 z-40 flex items-center justify-center p-8",style:{background:"var(--bg-surface)"},children:t.jsxs("div",{className:"flex max-w-md flex-col items-start gap-4 rounded-lg border border-l-4 p-6",style:{background:"var(--bg-base)",borderColor:"var(--border-default)",borderLeftColor:"var(--accent-primary)",color:"var(--text-primary)"},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-primary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:"shrink-0",children:[t.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2"}),t.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),t.jsx("span",{className:"text-base font-semibold",children:"Sign in to see the Live Preview"})]}),t.jsx("p",{className:"text-sm",style:{color:"var(--text-dim)"},children:"This preview runs on a separate secured host that needs its own sign-in. Sign-in can’t happen inside this frame, so open the preview host in a new tab, sign in, then reload."}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("button",{type:"button",onClick:s,className:"rounded px-3 py-2 text-sm font-medium",style:{background:"var(--accent-primary)",color:"var(--bg-base)"},children:"Open preview to sign in"}),t.jsx("button",{type:"button",onClick:n,className:"rounded border px-3 py-2 text-sm",style:{borderColor:"var(--border-default)",color:"var(--text-primary)"},children:"I’ve signed in — reload preview"})]})]})})}const fQ=Object.freeze(Object.defineProperty({__proto__:null,PreviewSignInNotice:Bj},Symbol.toStringTag,{value:"Module"}));function Wj({onReload:e,onReconnect:n,visible:s=!0,reason:r="lost",framed:a=!1,reconnect:o="idle",vmNumber:i=null}){return s?!a&&r==="lost"?t.jsx("div",{"data-testid":"session-lost-banner",className:"fixed inset-0 z-50 flex items-start justify-center bg-black/70 p-3",children:t.jsx("div",{className:"w-full max-w-2xl rounded-lg",style:{background:"var(--surface-page)"},children:t.jsx(Lt,{severity:"warning",testId:"session-lost-notice",headline:"This tab was signed out of the editor",explanation:"The editor no longer recognizes this tab's session — usually because it restarted. It tried to sign back in automatically and couldn't, so this page has stopped updating.",nextAction:"Reload this tab to get a fresh session. Nothing you've built is lost.",actions:[{label:"Reload this tab",onClick:e,testId:"session-lost-banner-reload"}]})})}):t.jsx("div",{"data-testid":"session-lost-strip",className:"pointer-events-none fixed inset-x-0 bottom-0 z-50 flex justify-center p-3",children:t.jsx("div",{className:"pointer-events-auto w-full max-w-2xl rounded-lg",style:{background:"var(--surface-page)"},children:a?t.jsx(Ix,{reason:r,reconnect:o,vmNumber:i,onReconnect:n}):t.jsx(Lt,{severity:"warning",testId:"session-lost-notice",headline:"This tab has no editor session",explanation:"None of this tab's requests to the editor have been accepted, so its live data can't load. No restart signed it out — it never had a session on this address.",nextAction:"Open the editor from its own address, or reload this tab.",actions:[{label:"Reload this tab",onClick:e,testId:"session-lost-banner-reload"}]})})}):null}const mQ=Object.freeze(Object.defineProperty({__proto__:null,SessionLostBanner:Wj},Symbol.toStringTag,{value:"Module"}));function nu(){return t.jsxs("div",{style:{padding:"var(--spacing-lg, 16px)"},children:[t.jsx("h3",{style:{margin:0,color:"var(--text-primary)"},children:"Design exploration"}),t.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 gQ=Object.freeze(Object.defineProperty({__proto__:null,MockupGridEmptyState:nu},Symbol.toStringTag,{value:"Module"}));function Ol({onRunTests:e,disabled:n,currentRunner:s}){return n?t.jsxs("span",{className:"text-xs font-medium text-[var(--text-dim)] inline-flex items-center gap-1.5",children:[t.jsx("span",{className:"inline-block h-3 w-3 animate-spin rounded-full border-2 border-current border-r-transparent"}),s?`Running ${s}…`:"Running…"]}):t.jsx("span",{role:"button",tabIndex:0,onClick:r=>{r.stopPropagation(),e()},onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.stopPropagation(),e())},className:"text-xs font-medium text-[var(--accent-active)] hover:underline cursor-pointer",children:"Run Tests"})}const xQ=Object.freeze(Object.defineProperty({__proto__:null,RunTestsButton:Ol},Symbol.toStringTag,{value:"Module"}));function Hj({passed:e,failed:n,notRun:s}){const r=e+n+s;if(r===0)return null;const a=2,o=[{count:e,color:"var(--accent-green)"},{count:n,color:"var(--accent-red)"},{count:s,color:"var(--text-dim)"}].filter(u=>u.count>0),i=o.map(u=>Math.max(u.count/r*100,a)),c=i.reduce((u,p)=>u+p,0),d=i.map(u=>u/c*100);return t.jsx("div",{className:"h-1.5 flex-1 rounded-full bg-[var(--bg-input)] overflow-hidden max-w-32",children:t.jsx("div",{className:"h-full flex",children:o.map((u,p)=>t.jsx("div",{className:"h-full transition-all",style:{width:`${d[p]}%`,background:u.color}},u.color))})})}const bQ=Object.freeze(Object.defineProperty({__proto__:null,TestBar:Hj},Symbol.toStringTag,{value:"Module"}));function su({tests:e,loading:n,refreshing:s,onRunTests:r,currentRunner:a}){const o=e.total>0,i=e.discovered>0,c=e.discovered>e.total?e.discovered-e.total:0;return n?t.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[t.jsx("div",{className:"h-1.5 w-16 rounded-full bg-[var(--bg-input)] animate-pulse"}),t.jsx("span",{className:"text-xs text-[var(--text-dim)]",children:s?"Running tests…":"Loading tests…"})]}):o?t.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[t.jsx(Hj,{passed:e.passed,failed:e.failed,notRun:c}),t.jsxs("span",{className:"text-xs font-medium text-[var(--accent-green)]",children:[e.passed," passed"]}),e.failed>0&&t.jsxs("span",{className:"text-xs font-medium text-[var(--accent-red)]",children:["· ",e.failed," failed"]}),e.ignored>0&&t.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:["· ",e.ignored," skipped"]}),c>0&&t.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:["· ",c," not run"]}),r&&t.jsx(Ol,{onRunTests:r,disabled:s,currentRunner:a})]}):i?t.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[t.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:[e.discovered," ",e.discovered===1?"test":"tests"," (not run)"]}),r&&t.jsx(Ol,{onRunTests:r})]}):t.jsx("span",{className:"text-xs text-[var(--text-dim)]",children:"No tests"})}const yQ=Object.freeze(Object.defineProperty({__proto__:null,AppTestSummary:su},Symbol.toStringTag,{value:"Module"}));function qj({tests:e,loading:n,refreshing:s,onRunTests:r,currentRunner:a}){return t.jsxs("div",{className:"px-5 pb-5 pt-2 flex items-center gap-5 border-t border-[var(--border-default)]",children:[t.jsx(su,{tests:e,loading:n,refreshing:s,onRunTests:r,currentRunner:a}),t.jsx("span",{className:"text-[var(--text-dim)] group-hover:text-[var(--accent-active)] transition ml-auto text-sm",children:"→"})]})}const vQ=Object.freeze(Object.defineProperty({__proto__:null,AppCardFooter:qj},Symbol.toStringTag,{value:"Module"}));function ru({type:e}){const n=e==="web";return t.jsx("span",{className:`rounded px-1.5 py-0.5 text-xs font-medium ${n?"bg-[var(--accent-blue)]/20 text-[var(--accent-blue)]":"bg-[var(--accent-purple)]/20 text-[var(--accent-purple)]"}`,children:n?"web":"backend"})}const jQ=Object.freeze(Object.defineProperty({__proto__:null,AppTypeBadge:ru},Symbol.toStringTag,{value:"Module"}));function Uj({app:e}){return t.jsxs("div",{className:"px-5 pt-5 pb-2",children:[t.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[t.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:e.name}),t.jsx(ru,{type:e.type})]}),e.description?t.jsx("p",{className:"text-sm text-[var(--text-muted)] leading-relaxed",children:e.description}):null]})}const wQ=Object.freeze(Object.defineProperty({__proto__:null,AppCardHeader:Uj},Symbol.toStringTag,{value:"Module"}));function Yj({thumbnails:e}){return t.jsx("div",{className:"flex gap-2 overflow-hidden",children:e.map((n,s)=>t.jsx("div",{className:"h-20 w-32 shrink-0 flex items-center justify-center overflow-hidden rounded border border-[var(--border-default)] bg-[var(--bg-surface)]",children:t.jsx(kt,{screenshotPath:n.path,cacheBuster:n.cacheBuster??void 0,alt:""})},`${n.path}:${s}`))})}const _Q=Object.freeze(Object.defineProperty({__proto__:null,ThumbnailStrip:Yj},Symbol.toStringTag,{value:"Module"}));function Gj({thumbnails:e}){return t.jsx("div",{className:"px-5 py-3 flex-1",children:e.length>0?t.jsx(Yj,{thumbnails:e.slice(0,4)}):t.jsx("div",{className:"h-20"})})}const SQ=Object.freeze(Object.defineProperty({__proto__:null,AppCardScenarioStrip:Gj},Symbol.toStringTag,{value:"Module"}));function Vj({stats:e,onClick:n,testsLoading:s,testsRefreshing:r,onRunTests:a,currentRunner:o}){const{app:i,tests:c,scenarios:d}=e;return t.jsxs("button",{onClick:n,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:[t.jsx(Uj,{app:i}),t.jsx(Gj,{thumbnails:d.thumbnails}),t.jsx(qj,{tests:c,loading:s,refreshing:r,onRunTests:a,currentRunner:o})]})}const kQ=Object.freeze(Object.defineProperty({__proto__:null,AppCard:Vj},Symbol.toStringTag,{value:"Module"}));function au({coverage:e,prefix:n,testId:s,className:r,onClick:a}){if(!e||e.totalLines===0)return null;const o=`${Math.round(e.percent)}% coverage`,i=t.jsxs(t.Fragment,{children:[n??"",o]}),c=`${e.hitLines}/${e.totalLines} lines covered`;return a?t.jsx("span",{role:"button",tabIndex:0,className:r??"text-xs font-medium text-[var(--accent-active)] hover:underline cursor-pointer","data-testid":s??"coverage-badge",title:c,onClick:d=>{d.stopPropagation(),a()},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.stopPropagation(),d.preventDefault(),a())},children:i}):t.jsx("span",{className:r??"text-xs font-medium text-[var(--text-secondary)]","data-testid":s??"coverage-badge",title:c,children:i})}const NQ=Object.freeze(Object.defineProperty({__proto__:null,CoverageBadge:au},Symbol.toStringTag,{value:"Module"}));function Kj({app:e,showDetail:n,navContext:s=hs,stats:r,testsLoading:a,testsRefreshing:o,onRunTests:i,currentRunner:c,coverage:d,onCoverageClick:u}){if(n)return null;const p=!!(d&&d.totalLines>0);return t.jsxs("div",{className:"px-5 py-4 border-b border-[var(--border-default)]",children:[t.jsx("div",{className:"mb-2",children:t.jsx(Mo,{apps:s.apps,selectedApp:e,selectedRouteEntity:null,isSingleApp:s.isSingleApp,onSelectApps:s.onSelectApps,onSelectApp:s.onSelectApp,onSelectRoute:s.onSelectRoute})}),t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("h2",{className:"text-lg font-medium text-[var(--text-primary)]",children:e.name}),t.jsx(ru,{type:e.type})]}),p?t.jsx(au,{coverage:d,testId:"app-detail-coverage",onClick:u}):null]}),e.description?t.jsx("p",{className:"text-sm text-[var(--text-muted)] mt-1",children:e.description}):null,r?t.jsx("div",{className:"mt-3",children:t.jsx(su,{tests:r.tests,loading:a,refreshing:o,onRunTests:i,currentRunner:c})}):null]})}const CQ=Object.freeze(Object.defineProperty({__proto__:null,AppDetailHeader:Kj},Symbol.toStringTag,{value:"Module"}));function Jj({name:e,id:n,capabilitiesTally:s,expanded:r,onToggle:a}){const o=e??n;return t.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:[t.jsx("span",{className:`inline-block transition-transform ${r?"rotate-90":""}`,children:"▶"}),t.jsxs("span",{className:"font-medium text-[var(--text-primary)]",children:["Stack",o?` — ${o}`:""]}),e&&n?t.jsxs("span",{className:"text-[var(--text-dim)]",children:["(",n,")"]}):null,t.jsxs("span",{className:"text-[var(--text-dim)]",children:["— ",s]})]})}const TQ=Object.freeze(Object.defineProperty({__proto__:null,AppStackPanelSummary:Jj},Symbol.toStringTag,{value:"Module"})),Rl=["layout-web","interactions-click","interactions-touch-gestures","native-haptics","native-geolocation","native-clipboard","native-network","native-storage","routing","http-mocks","real-device"],Xj={"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"}},Qj={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 dL(e){var n;return((n=Xj[e])==null?void 0:n.label)??e}function uL(e,n){var a,o;const s=(a=Xj[e])==null?void 0:a.description,r=((o=Qj[n])==null?void 0:o.meaning)??"";return s?`${s}. ${r}`:r}function Zj({capabilities:e,defaultExpanded:n=!1}){const[s,r]=l.useState(n),a=Rl.filter(c=>c in e),o=Object.keys(e).filter(c=>!Rl.includes(c)),i={verified:0,stubbed:0,manual:0,"not-applicable":0};for(const c of a){const d=e[c];d in i&&(i[d]+=1)}return t.jsxs("div",{className:"px-5 py-2","data-testid":"capabilities-panel",children:[t.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":s,children:[t.jsx("span",{className:`inline-block transition-transform ${s?"rotate-90":""}`,children:"▶"}),t.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:"Stack capabilities"}),t.jsxs("span",{className:"text-[var(--text-dim)]",children:["— ",i.verified," verified · ",i.stubbed," stubbed ·"," ",i.manual," manual · ",i["not-applicable"]," n/a"]})]}),s?t.jsxs("div",{className:"mt-2 space-y-1","data-testid":"capabilities-rows",children:[a.map(c=>t.jsx(El,{token:c,state:e[c]},c)),o.length>0?t.jsxs("div",{className:"mt-3","data-testid":"capabilities-unknown-group",children:[t.jsxs("div",{className:"flex items-center gap-1 text-xs font-medium text-[var(--accent-warn)]",children:[t.jsx("span",{title:"These tokens aren't recognized — likely typos",children:"⚠"}),"Unknown capabilities"]}),o.map(c=>t.jsx(El,{token:c,state:e[c],unknown:!0},c))]}):null]}):null]})}function El({token:e,state:n,unknown:s}){const r=Qj[n],a=s?"This token isn't recognized — may be a typo.":uL(e,n);return t.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs","data-testid":`capability-row-${e}`,children:[t.jsxs("span",{className:"flex items-center gap-1 text-[var(--text-secondary)]",children:[dL(e),t.jsx("span",{className:"cursor-help text-[var(--text-dim)]",title:a,"aria-label":a,children:"ⓘ"})]}),t.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)??n})]})}const PQ=Object.freeze(Object.defineProperty({__proto__:null,AppCapabilitiesPanel:Zj,CapabilityRow:El},Symbol.toStringTag,{value:"Module"}));function ew({capabilities:e}){return e&&Object.keys(e).length>0?t.jsx(Zj,{capabilities:e,defaultExpanded:!1}):t.jsxs("div",{className:"text-xs text-[var(--text-dim)]","data-testid":"stack-capabilities-empty-hint",children:["Capabilities not declared. Run"," ",t.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 OQ=Object.freeze(Object.defineProperty({__proto__:null,AppStackCapabilitiesSlot:ew},Symbol.toStringTag,{value:"Module"}));function tw({fields:e,capabilities:n}){return t.jsxs("div",{className:"mt-2 space-y-2","data-testid":"stack-body",children:[e.description?t.jsx("p",{className:"text-xs text-[var(--text-secondary)]","data-testid":"stack-description",children:e.description}):null,e.technologies.length>0?t.jsx("ul",{className:"flex flex-wrap gap-1","data-testid":"stack-technologies",children:e.technologies.map(s=>t.jsx("li",{className:"rounded bg-[var(--bg-subtle)] px-1.5 py-0.5 text-[10px] text-[var(--text-secondary)]",children:s},s))}):null,e.commands.length>0?t.jsx("dl",{className:"space-y-0.5 text-xs","data-testid":"stack-commands",children:e.commands.map(({key:s,value:r})=>t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("dt",{className:"w-10 text-[var(--text-dim)]",children:s}),t.jsx("dd",{className:"text-[var(--text-secondary)]",children:t.jsx("code",{className:"rounded bg-[var(--bg-subtle)] px-1 py-0.5",children:r})})]},s))}):null,e.routingSummary?t.jsxs("div",{className:"text-xs text-[var(--text-secondary)]","data-testid":"stack-routing",children:[t.jsx("span",{className:"text-[var(--text-dim)]",children:"routing"})," ",e.routingSummary]}):null,t.jsx("div",{className:"border-t border-[var(--border-subtle)] pt-2",children:t.jsx(ew,{capabilities:n})})]})}const RQ=Object.freeze(Object.defineProperty({__proto__:null,AppStackPanelBody:tw},Symbol.toStringTag,{value:"Module"}));function nw({skip:e=!1}={}){const[n,s]=l.useState(null);return l.useEffect(()=>{if(e)return;let r=!1;return fetch("/api/project-stack").then(a=>a.ok?a.json():{}).then(a=>{r||s(a&&typeof a=="object"&&!Array.isArray(a)?a:{})}).catch(()=>{r||s({})}),()=>{r=!0}},[e]),n}const pL=["dev","test","build"];function zn(e){return typeof e=="string"&&e.length>0?e:null}function sw(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function hL(e){return Array.isArray(e)?e.filter(n=>typeof n=="string"):[]}function fL(e){const n=sw(e);if(!n)return[];const s=[];for(const r of pL){const a=zn(n[r]);a&&s.push({key:r,value:a})}return s}function mL(e){const n=sw(e);if(!n)return null;const s=zn(n.type);if(!s)return null;const r=zn(n.pagesDir)??zn(n.isolationRoute)??zn(n.componentManifest);return r?`${s} (${r})`:s}function gL(e){const n=e.capabilities;return!n||typeof n!="object"||Array.isArray(n)?null:n}function xL(e){if(!e||Object.keys(e).length===0)return"capabilities not declared";const n={verified:0,stubbed:0,manual:0,"not-applicable":0};for(const s of Rl){const r=e[s];r&&r in n&&(n[r]+=1)}return`${n.verified} verified · ${n.stubbed} stubbed · ${n.manual} manual · ${n["not-applicable"]} n/a`}function bL(e){return e?{id:zn(e.id),name:zn(e.name),description:zn(e.description),technologies:hL(e.technologies),commands:fL(e.commands),routingSummary:mL(e.routing)}:{id:null,name:null,description:null,technologies:[],commands:[],routingSummary:null}}function rw({stack:e,defaultExpanded:n=!1}){const s=e!==void 0,[r,a]=l.useState(n),o=nw({skip:s}),i=s?e:o;if(!i||Object.keys(i).length===0)return null;const c=bL(i),d=gL(i);return t.jsxs("div",{className:"px-5 py-2","data-testid":"stack-panel",children:[t.jsx(Jj,{name:c.name,id:c.id,capabilitiesTally:xL(d),expanded:r,onToggle:()=>a(u=>!u)}),r?t.jsx(tw,{fields:c,capabilities:d}):null]})}const EQ=Object.freeze(Object.defineProperty({__proto__:null,AppStackPanel:rw},Symbol.toStringTag,{value:"Module"}));function aw({app:e,navContext:n=hs,routeEntities:s,unsurfacedPages:r,componentSurfaceReason:a,routesLoading:o,routesRefreshing:i,routesError:c,selectedEntityHash:d,selectedRouteEntity:u,testGroups:p,selectedSlug:h,entityLookup:f,allScenarios:m,onSelectScenario:g,onSelectRoute:x,onSelectEntity:b,onBackToRoutes:y,onScenariosChanged:v,coverage:j,showProjectBand:_,onCoverageClick:w,stats:k,testsLoading:S,testsRefreshing:N,onRunTests:C,currentRunner:T}){const P=e.type==="web",R=!!_&&!u;return t.jsxs("div",{children:[R?t.jsx(rw,{}):null,t.jsx(Kj,{app:e,showDetail:!!(u||d),navContext:n,stats:k,testsLoading:S,testsRefreshing:N,onRunTests:C,currentRunner:T,coverage:R?j:void 0,onCoverageClick:w}),t.jsx(Qd,{app:e,navContext:n,isWeb:P,routeEntities:s,unsurfacedPages:r,componentSurfaceReason:a,routesLoading:o,routesRefreshing:i,routesError:c,selectedEntityHash:d??null,selectedRouteEntity:u,testGroups:p,selectedSlug:h,entityLookup:f,allScenarios:m,onSelectScenario:g,onSelectRoute:x,onSelectEntity:b,onBackToRoutes:y,onScenariosChanged:v})]})}const AQ=Object.freeze(Object.defineProperty({__proto__:null,AppDetail:aw},Symbol.toStringTag,{value:"Module"}));function ow({screenshots:e,onSelect:n}){return e.length===0?null:t.jsx("div",{className:"flex flex-wrap gap-2",children:e.map((s,r)=>{const a=!!n&&!!s.screenshotPath,o=t.jsx("div",{className:"flex h-16 w-24 items-center justify-center overflow-hidden rounded border border-[var(--border-default)] bg-[var(--bg-surface)]",children:t.jsx(kt,{screenshotPath:s.screenshotPath,cacheBuster:s.screenshotCapturedAtMs??void 0,alt:s.name})});return t.jsxs("div",{className:"text-center",children:[a?t.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(s),"aria-label":`Preview ${s.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,t.jsx("p",{className:"mt-0.5 text-xs text-[var(--text-dim)] truncate w-24",children:s.name})]},`${s.screenshotPath??"missing"}:${s.name}:${r}`)})})}const MQ=Object.freeze(Object.defineProperty({__proto__:null,ScenarioThumbnailGrid:ow},Symbol.toStringTag,{value:"Module"})),yL="calc(100vh - 110px)";function Jt({children:e,testId:n,fill:s=!1}){return t.jsx("div",{className:s?"flex min-h-0 flex-1 flex-col overflow-y-auto px-2":"overflow-y-auto px-4 py-4",style:s?void 0:{maxHeight:yL},"data-testid":n,children:e})}const IQ=Object.freeze(Object.defineProperty({__proto__:null,TabScrollPanel:Jt},Symbol.toStringTag,{value:"Module"}));function iw(){const{reviews:e,repoState:n,loading:s,error:r}=rL(),[a,o]=l.useState(null);return s?t.jsx(Jt,{children:t.jsx("div",{className:"py-12 text-center text-[var(--text-muted)]",children:"Loading reviews..."})}):r&&e.length===0?t.jsx(Jt,{children:t.jsx("div",{className:"py-12",children:t.jsx(tt,{text:`Failed to load reviews: ${r}`,className:"text-sm text-[var(--accent-red)]",rowClassName:"justify-center"})})}):e.length===0?t.jsx(Jt,{children:t.jsxs("div",{className:"py-12 text-center text-[var(--text-dim)]",children:[t.jsx("p",{children:"No PR digests yet."}),t.jsxs("p",{className:"mt-2 text-sm",children:["Run"," ",t.jsx("span",{className:"font-mono",style:{color:"var(--text-secondary)"},children:"/codeyam-review-pr"})," ","to digest an incoming pull request."]})]})}):t.jsx(Jt,{children:t.jsx("div",{className:"flex flex-col gap-3",children:e.map(i=>t.jsx($j,{review:i,repoState:n,expanded:a===i.id,onToggle:()=>o(c=>c===i.id?null:i.id)},i.id))})})}const DQ=Object.freeze(Object.defineProperty({__proto__:null,ReviewsTab:iw},Symbol.toStringTag,{value:"Module"}));function vL({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("circle",{cx:"11",cy:"11",r:"7"}),t.jsx("path",{d:"m20 20-3.5-3.5"})]})}function jL({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("rect",{x:"8",y:"2",width:"8",height:"4",rx:"1"}),t.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"}),t.jsx("path",{d:"M9 12h6"}),t.jsx("path",{d:"M9 16h6"})]})}function is({size:e=20}){return t.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z"})})}function Wr({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),t.jsx("path",{d:"M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"}),t.jsx("path",{d:"M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"})]})}function et({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),t.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}function Hs({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),t.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]})}function ot({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.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"}),t.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"}),t.jsx("path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0"}),t.jsx("path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"})]})}function ou({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("line",{x1:"4",y1:"21",x2:"4",y2:"14"}),t.jsx("line",{x1:"4",y1:"10",x2:"4",y2:"3"}),t.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"12"}),t.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"3"}),t.jsx("line",{x1:"20",y1:"21",x2:"20",y2:"16"}),t.jsx("line",{x1:"20",y1:"12",x2:"20",y2:"3"}),t.jsx("line",{x1:"1",y1:"14",x2:"7",y2:"14"}),t.jsx("line",{x1:"9",y1:"8",x2:"15",y2:"8"}),t.jsx("line",{x1:"17",y1:"16",x2:"23",y2:"16"})]})}function Is({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("polyline",{points:"4 17 10 11 4 5"}),t.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function kn({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2"}),t.jsx("line",{x1:"2",y1:"10",x2:"22",y2:"10"})]})}function Qt({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("line",{x1:"18",y1:"20",x2:"18",y2:"10"}),t.jsx("line",{x1:"12",y1:"20",x2:"12",y2:"4"}),t.jsx("line",{x1:"6",y1:"20",x2:"6",y2:"14"})]})}function Xe({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),t.jsx("polyline",{points:"14 2 14 8 20 8"}),t.jsx("line",{x1:"8",y1:"13",x2:"16",y2:"13"}),t.jsx("line",{x1:"8",y1:"17",x2:"16",y2:"17"})]})}function Wn({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"12",r:"10"}),t.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),t.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 Mt({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.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"}),t.jsx("polyline",{points:"3.27 6.96 12 12.01 20.73 6.96"}),t.jsx("line",{x1:"12",y1:"22.08",x2:"12",y2:"12"})]})}function iu({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M18 8a6 6 0 0 0-12 0c0 7-3 9-3 9h18s-3-2-3-9"}),t.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}const LQ=Object.freeze(Object.defineProperty({__proto__:null,BellIcon:iu,BoxIcon:Mt,CardIcon:kn,ChartIcon:Qt,CloudIcon:is,DatabaseIcon:Wr,DocIcon:Xe,ExploreIcon:vL,GlobeIcon:Wn,LockIcon:et,MailIcon:Hs,PlansIcon:jL,RocketIcon:ot,SetupIcon:ou,TerminalIcon:Is},Symbol.toStringTag,{value:"Module"})),wL=[{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"}],_L={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 lw({intent:e="add",onSubmit:n,onCancel:s}){const r=_L[e],[a,o]=l.useState(""),[i,c]=l.useState(""),[d,u]=l.useState("box"),[p,h]=l.useState(!1),[f,m]=l.useState(null),g=a.trim(),x=g.length>0&&!p,b=async y=>{if(y.preventDefault(),!x){g.length===0&&m("Please enter a name.");return}h(!0),m(null);try{await n({name:g,desc:i.trim(),icon:d})}catch(v){m(v instanceof Error?v.message:"Something went wrong."),h(!1)}};return t.jsxs("div",{className:"learn-screen",children:[t.jsx("div",{className:"atf-backdrop",role:"presentation",onClick:s}),t.jsxs("div",{className:"atf-modal",role:"dialog","aria-modal":"true","aria-label":r.title,children:[t.jsx("div",{className:"atf-title",children:r.title}),t.jsx("p",{className:"atf-lead",children:r.lead}),t.jsxs("form",{onSubmit:b,children:[t.jsxs("label",{className:"atf-field",children:[t.jsx("span",{className:"atf-label",children:"Name"}),t.jsx("input",{className:"atf-input",type:"text",value:a,autoFocus:!0,placeholder:e==="ask"?"e.g. Cloudflare, a regional payment processor…":"e.g. Error monitoring, a custom step…",onChange:y=>o(y.target.value)})]}),t.jsxs("label",{className:"atf-field",children:[t.jsxs("span",{className:"atf-label",children:["What is it for? ",t.jsx("span",{className:"atf-optional",children:"(optional)"})]}),t.jsx("textarea",{className:"atf-input atf-textarea",value:i,rows:2,placeholder:"One line on what this is for.",onChange:y=>c(y.target.value)})]}),t.jsxs("label",{className:"atf-field",children:[t.jsx("span",{className:"atf-label",children:"Icon"}),t.jsx("select",{className:"atf-input",value:d,onChange:y=>u(y.target.value),children:wL.map(y=>t.jsx("option",{value:y.key,children:y.label},y.key))})]}),f?t.jsx("div",{className:"atf-error",children:t.jsx(tt,{text:f,className:""})}):null,t.jsxs("div",{className:"atf-actions",children:[t.jsx("button",{type:"button",className:"atf-btn atf-btn-ghost",onClick:s,disabled:p,children:"Cancel"}),t.jsx("button",{type:"submit",className:"atf-btn atf-btn-primary",disabled:!x,children:p?r.submitting:r.submit})]})]})]})]})}const FQ=Object.freeze(Object.defineProperty({__proto__:null,AddTopicForm:lw},Symbol.toStringTag,{value:"Module"}));function cw({onAdd:e,onAsk:n}){return t.jsxs("div",{className:"setup-addrow",children:[t.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."}),t.jsxs("div",{className:"setup-addrow-btns",children:[t.jsx("button",{type:"button",className:"setup-addbtn",onClick:e,children:"+ Add a topic"}),t.jsx("button",{type:"button",className:"setup-addbtn setup-addbtn-ask",onClick:n,children:"Ask the AI about a service"})]})]})}const $Q=Object.freeze(Object.defineProperty({__proto__:null,SetupAddTopicRow:cw},Symbol.toStringTag,{value:"Module"}));function SL(){const[e,n]=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||n(Array.isArray(o)?o:[])}catch{r||n([])}})(),()=>{r=!0}},[]);const s=l.useMemo(()=>{const r=new Map;for(const a of e??[])r.set(a.key,a);return r},[e]);return{concepts:e,byKey:r=>s.get(r)}}const kL={concepts:[],byKey:()=>{}},Do=l.createContext(kL);function dw({children:e}){const n=SL();return t.jsx(Do.Provider,{value:n,children:e})}function uw(){return l.useContext(Do)}function pw(e){return l.useContext(Do).byKey(e)}const zQ=Object.freeze(Object.defineProperty({__proto__:null,ConceptsContext:Do,ConceptsProvider:dw,useConcept:pw,useConceptIndex:uw},Symbol.toStringTag,{value:"Module"}));function ka({k:e,children:n}){const s=pw(e),[r,a]=l.useState(null),o=l.useRef(null),i=l.useRef(null),c=l.useId(),d=r!==null,u=()=>{var h;const p=(h=o.current)==null?void 0:h.getBoundingClientRect();p&&a({top:p.bottom+6,left:p.left})};return l.useEffect(()=>{if(!d)return;const p=f=>{var g,x;const m=f.target;!((g=o.current)!=null&&g.contains(m))&&!((x=i.current)!=null&&x.contains(m))&&a(null)},h=f=>{f.key==="Escape"&&a(null)};return document.addEventListener("mousedown",p),document.addEventListener("keydown",h),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",h)}},[d]),s?t.jsxs("span",{className:"concept-term-wrap",children:[t.jsx("button",{type:"button",ref:o,className:"concept-term","aria-expanded":d,"aria-controls":d?c:void 0,onClick:()=>d?a(null):u(),children:n}),d&&r?as.createPortal(t.jsxs("div",{ref:i,className:"concept-popover",id:c,role:"dialog",style:{top:r.top,left:r.left},children:[t.jsx("span",{className:"concept-popover-term",children:s.term}),s.category?t.jsx("span",{className:"concept-popover-cat",children:s.category}):null,t.jsx("div",{className:"concept-popover-body",children:t.jsx(Ft,{variant:"compact",children:s.body})})]}),document.body):null]}):t.jsx(t.Fragment,{children:n})}const BQ=Object.freeze(Object.defineProperty({__proto__:null,ConceptTerm:ka},Symbol.toStringTag,{value:"Module"}));function hw(e){const n=e.evidence[0];return n?`found ${n.value} in ${n.source}`:e.source==="declared"?"declared by the agent":"detected in this project"}function fw({service:e,onDismiss:n,onAddCredential:s}){var i;const r=(((i=e.envVars)==null?void 0:i.length)??0)>0,a=r&&!e.credentialPresent,o=r&&e.credentialPresent;return t.jsxs("div",{className:"detected-service",children:[t.jsx("span",{className:"ds-tag",children:e.source}),t.jsx("span",{className:"ds-name",children:e.name}),t.jsx("span",{className:"ds-why",children:hw(e)}),o?t.jsx("span",{className:"ds-key-set","data-testid":`ds-key-set-${e.key}`,children:"Key set"}):null,a&&s?t.jsx("button",{type:"button",className:"ds-add-key",onClick:()=>s(e),"aria-label":`Add key for ${e.name}`,children:"Add key"}):null,n?t.jsx("button",{type:"button",className:"ds-dismiss",onClick:()=>n(e.key),"aria-label":`Dismiss ${e.name}`,children:"Dismiss"}):null]})}const WQ=Object.freeze(Object.defineProperty({__proto__:null,DetectedServiceRow:fw,evidenceSummary:hw},Symbol.toStringTag,{value:"Module"})),NL={terminal:Is,cloud:is,database:Wr,lock:et,mail:Hs,card:kn,chart:Qt,doc:Xe,globe:Wn,box:Mt,bell:iu,rocket:ot};function CL(e){return NL[e]??ou}function TL(e){return e==="done"?"trow done":e==="next"||e==="in-progress"?"trow next":"trow soon"}function PL(e){return e==="done"?"set up":e==="in-progress"?"in progress":e==="next"?"next":"explore"}function Na({topics:e,detectedServices:n,onBack:s,onOpenHosting:r,onOpenTopic:a,onOpenLibraries:o,onDismissService:i,onAddCredential:c,onCreateTopic:d,onOpenConcepts:u}){const p=x=>{x.key==="hosting"?r():a==null||a(x.key)},h=new Map;for(const x of n??[]){if(x.status==="dismissed")continue;const b=h.get(x.topic)??[];b.push(x),h.set(x.topic,b)}const[f,m]=l.useState(null),g=async x=>{if(!d)return;const b=await d(x);m(null),a==null||a(b.key)};return t.jsxs("div",{className:"learn-screen",children:[t.jsxs("div",{className:"crumbs",children:[t.jsx("button",{type:"button",className:"back",onClick:s,"aria-label":"Back",children:"←"}),t.jsx("button",{type:"button",onClick:s,children:"Home"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("b",{children:"Setup"})]}),t.jsx("div",{className:"h",children:"Setup"}),t.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?t.jsxs("div",{className:"concepts-nudge",children:["New to terms like ",t.jsx(ka,{k:"hosting",children:"hosting"}),", a"," ",t.jsx(ka,{k:"domain",children:"domain"}),", or"," ",t.jsx(ka,{k:"ssl-https",children:"HTTPS"}),"? Tap any underlined word for a plain-language explainer, or"," ",t.jsx("button",{type:"button",className:"concepts-nudge-link",onClick:u,children:"browse what these words mean"}),"."]}):null,t.jsx("div",{className:"tlist",children:e===null?Array.from({length:5}).map((x,b)=>t.jsxs("div",{className:"trow soon","aria-hidden":"true",children:[t.jsx("div",{className:"tic"}),t.jsxs("div",{className:"tbody",children:[t.jsx("div",{className:"tn",children:" "}),t.jsx("div",{className:"td",children:" "})]})]},b)):e.map(x=>{const b=CL(x.icon),y=h.get(x.key)??[];return t.jsxs("div",{className:"trow-group",children:[t.jsxs("button",{type:"button",className:TL(x.status),onClick:()=>p(x),children:[t.jsx("div",{className:"tic",children:t.jsx(b,{size:20})}),t.jsxs("div",{className:"tbody",children:[t.jsx("div",{className:"tn",children:x.name}),t.jsx("div",{className:"td",children:x.desc})]}),t.jsx("span",{className:"tt",children:PL(x.status)}),t.jsx("span",{className:"arrow",children:"→"})]}),y.length>0?t.jsx("div",{className:"detected-services",children:y.map(v=>t.jsx(fw,{service:v,onDismiss:i,onAddCredential:c},v.key))}):null]},x.key)})}),o&&t.jsxs("div",{className:"setup-libraries-section",children:[t.jsx("div",{className:"seclabel",children:"Libraries"}),t.jsxs("button",{type:"button",className:"trow",onClick:o,children:[t.jsx("div",{className:"tic",children:t.jsx(Mt,{size:20})}),t.jsxs("div",{className:"tbody",children:[t.jsx("div",{className:"tn",children:"Libraries you depend on"}),t.jsx("div",{className:"td",children:"Every third-party library your app pulls in — what it is, its version, and how to update it."})]}),t.jsx("span",{className:"tt",children:"auto"}),t.jsx("span",{className:"arrow",children:"→"})]})]}),d?t.jsx(cw,{onAdd:()=>m("add"),onAsk:()=>m("ask")}):null,f&&d?t.jsx(lw,{intent:f,onSubmit:g,onCancel:()=>m(null)}):null]})}const HQ=Object.freeze(Object.defineProperty({__proto__:null,LearnSetupScreen:Na},Symbol.toStringTag,{value:"Module"}));function ur({command:e,writer:n}){const{copied:s,copy:r}=fo({writer:n});return t.jsxs("div",{className:"rl-cmd",children:[t.jsx("code",{className:"rl-cmd-text",children:e}),t.jsx("button",{type:"button",className:"rl-copy",onClick:()=>{r(e).catch(()=>{})},"aria-label":`Copy command: ${e}`,children:s?"Copied!":"Copy"})]})}const qQ=Object.freeze(Object.defineProperty({__proto__:null,RunLocallyCommandRow:ur},Symbol.toStringTag,{value:"Module"}));function OL(e){return e==="dev"?"dev":e==="transitive"?"transitive":"direct"}function mw({lib:e,copyWriter:n}){return t.jsxs("div",{className:"lib-row",children:[t.jsxs("div",{className:"lib-head",children:[t.jsx("span",{className:"lib-name",children:e.name}),t.jsx("span",{className:"lib-version",children:e.version||"—"}),t.jsx("span",{className:`lib-kind ${e.kind}`,children:OL(e.kind)}),e.outdated&&t.jsx("span",{className:"lib-outdated",title:"A newer version is available",children:"outdated"})]}),e.description?t.jsx("div",{className:"lib-desc",children:e.description}):t.jsx("div",{className:"lib-desc muted",children:"A library this project depends on. No description on file yet."}),t.jsxs("div",{className:"lib-meta",children:[e.category&&t.jsx("span",{className:"lib-tag",children:e.category}),e.license&&t.jsxs("span",{className:"lib-license",children:["License: ",e.license]}),e.homepage&&t.jsx("a",{className:"lib-docs",href:e.homepage,target:"_blank",rel:"noreferrer",children:"Docs ↗"})]}),t.jsx(ur,{command:e.updateCommand,writer:n})]})}const UQ=Object.freeze(Object.defineProperty({__proto__:null,LibraryRow:mw},Symbol.toStringTag,{value:"Module"}));function RL(e,n){return n?`${e.name} ${e.description??""} ${e.category??""}`.toLowerCase().includes(n):!0}function gw({group:e,query:n,forceOpen:s,copyWriter:r}){const[a,o]=l.useState(e.libraries.length<=8),i=e.libraries.filter(d=>RL(d,n));if(n&&i.length===0)return null;const c=s||a;return t.jsxs("section",{className:"lib-group",children:[t.jsxs("button",{type:"button",className:"lib-group-head","aria-expanded":c,onClick:()=>o(d=>!d),children:[t.jsx("span",{className:"lib-group-icon",children:t.jsx(Mt,{size:18})}),t.jsx("span",{className:"lib-group-title",children:e.ecosystem}),t.jsxs("span",{className:"lib-group-count",children:[i.length," ",i.length===1?"library":"libraries"]}),t.jsx("span",{className:"lib-group-path",children:e.manifestPath}),t.jsx("span",{className:"lib-group-chevron",children:c?"▾":"▸"})]}),c&&t.jsx("div",{className:"lib-rows",children:i.map(d=>t.jsx(mw,{lib:d,copyWriter:r},d.name))})]})}const YQ=Object.freeze(Object.defineProperty({__proto__:null,LibraryGroupSection:gw},Symbol.toStringTag,{value:"Module"}));function xw({groups:e,onBack:n,copyWriter:s}){const[r,a]=l.useState(""),o=r.trim().toLowerCase(),i=l.useMemo(()=>(e??[]).reduce((c,d)=>c+d.libraries.length,0),[e]);return t.jsxs("div",{className:"learn-screen libraries-screen",children:[t.jsxs("div",{className:"crumbs",children:[t.jsx("button",{type:"button",className:"back",onClick:n,"aria-label":"Back",children:"←"}),t.jsx("button",{type:"button",onClick:n,children:"Home"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("button",{type:"button",onClick:n,children:"Setup"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("b",{children:"Libraries"})]}),t.jsx("div",{className:"h",children:"Libraries"}),t.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."}),e===null?t.jsx("div",{className:"lib-loading","aria-hidden":"true",children:"Reading your project's libraries…"}):e.length===0?t.jsxs("div",{className:"lib-empty",children:[t.jsx("div",{className:"lib-empty-title",children:"No libraries yet"}),t.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."})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"lib-searchbar",children:t.jsx("input",{type:"search",className:"lib-search",placeholder:`Search ${i} libraries…`,value:r,onChange:c=>a(c.target.value),"aria-label":"Search libraries"})}),t.jsx("div",{className:"lib-groups",children:e.map(c=>t.jsx(gw,{group:c,query:o,forceOpen:o.length>0,copyWriter:s},c.manifestPath))})]})]})}const GQ=Object.freeze(Object.defineProperty({__proto__:null,LibrariesCatalogScreen:xw},Symbol.toStringTag,{value:"Module"}));function lu(e){switch(e){case"real-data":return t.jsx(ts,{before:{tag:"Now · in the code",items:["Resets on refresh","A developer must edit"]},after:{tag:"After · in a database",items:["Saved for good","You edit it yourself"]}});case"performance-images":return t.jsx(ts,{before:{tag:"Heavy",items:["Full-size images","Slow first paint"]},after:{tag:"Optimized",items:["Right-sized & lazy","Fast on any device"]}});case"cli-ux":return t.jsx(ts,{before:{tag:"Cryptic",items:["Confusing errors","Guess the flags"]},after:{tag:"Polished",items:["Clear help & output","Helpful messages"]}});case"forms":return t.jsx(ts,{before:{tag:"Without setup",items:["Submissions lost","Spam gets through"]},after:{tag:"With setup",items:["Reliably delivered","Spam filtered out"]}});case"custom-domain":return t.jsx(ts,{before:{tag:"Default link",items:["Generic address","Hard to remember"]},after:{tag:"Your domain",items:["yourname.com","Secure & trusted"]}});case"accounts":return t.jsx(ss,{center:{emoji:"🔑",label:"Sign-in"},satellites:["✉️ Email link","🔵 Google","🍎 Apple","🔒 Password"]});case"emails":return t.jsx(ss,{center:{emoji:"✉️",label:"Your app sends"},satellites:["👋 Welcome","🔑 Password reset","🧾 Receipt","🔔 Notification"]});case"api-auth":return t.jsx(ss,{center:{emoji:"🛡️",label:"Your API"},satellites:["🎟️ API key","🪪 Token","⛔ Revoke anytime"]});case"cors-origins":return t.jsx(ss,{center:{emoji:"🚦",label:"Your API"},satellites:["✅ your-site.com","✅ app.your-site.com","⛔ everyone else"]});case"comments-search":return t.jsx(ss,{center:{emoji:"📚",label:"Your content"},satellites:["🔍 Fast search","💬 Comments","🛡️ Moderation"]});case"analytics-monitoring":return t.jsx(Sa,{bars:[{label:"Visits",pct:62},{label:"Signups",pct:40},{label:"Active",pct:78,lime:!0},{label:"Errors",pct:16}]});case"analytics-seo":return t.jsx(Sa,{bars:[{label:"Search",pct:70,lime:!0},{label:"Direct",pct:45},{label:"Social",pct:30},{label:"Referral",pct:22}]});case"logging-monitoring":return t.jsx(Sa,{bars:[{label:"Mon",pct:30},{label:"Tue",pct:44},{label:"Wed",pct:88,lime:!0},{label:"Thu",pct:36},{label:"Fri",pct:52}]});case"database-backups":return t.jsx(ns,{rows:[{emoji:"🗄️",label:"Live data",sub:"The real thing"},{emoji:"💾",label:"Daily backup",sub:"Safe copy",lime:!0},{emoji:"💾",label:"Yesterday",sub:"Restore point"},{emoji:"💾",label:"Last week",sub:"Restore point"}]});case"release-builds":return t.jsx(ns,{rows:[{emoji:"🧾",label:"Your source",sub:"One codebase"},{emoji:"🍎",label:"macOS build",sub:"Ready to run",lime:!0},{emoji:"🪟",label:"Windows build",sub:"Ready to run"},{emoji:"🐧",label:"Linux build",sub:"Ready to run"}]});case"staging-environment":return t.jsx(ns,{rows:[{emoji:"🏭",label:"Production",sub:"Real users"},{emoji:"🏗️",label:"Staging",sub:"Rehearse here",lime:!0},{emoji:"💻",label:"Local",sub:"Your machine"}]});case"publish-registry":return t.jsx(ns,{rows:[{emoji:"📦",label:"your-package",sub:"v1.2.0",lime:!0},{emoji:"🏷️",label:"Registry",sub:"Public listing"},{emoji:"⬇️",label:"npm install",sub:"One command"}]});case"semver-policy":return t.jsx(ns,{rows:[{emoji:"🟥",label:"Major · 2.0.0",sub:"May break"},{emoji:"🟨",label:"Minor · 1.3.0",sub:"New features"},{emoji:"🟩",label:"Patch · 1.2.1",sub:"Safe fix",lime:!0}]});case"versioning-changelog":return t.jsx(ns,{rows:[{emoji:"🆕",label:"v1.3.0",sub:"Added, fixed",lime:!0},{emoji:"📝",label:"v1.2.0",sub:"Changed"},{emoji:"📝",label:"v1.1.0",sub:"Fixed"}]});case"pre-release-channel":return t.jsx(Tl,{channels:[{label:"Stable",dots:5},{label:"Beta",dots:5,on:!0}]});case"pre-release-versions":return t.jsx(Tl,{channels:[{label:"latest",dots:4},{label:"next",dots:4,on:!0}]});case"legal":return t.jsx(On,{emoji:"⚖️",caption:"Clear, honest, above board",chips:["Privacy policy","Terms of service","Plain language"]});case"data-safety":return t.jsx(On,{emoji:"🛡️",caption:"Collect less, protect the rest",chips:["Minimize","Encrypt","Declare clearly"]});case"supply-chain":return t.jsx(On,{emoji:"🔗",caption:"Trust the code you depend on",chips:["Scan for risk","Pin versions","Verify builds"]});case"secrets":return t.jsx(On,{emoji:"🔑",caption:"Out of the code, in a safe store",chips:["Never committed","Easy to rotate","Per-environment"]});case"readme-license":return t.jsx(On,{emoji:"📖",caption:"The first things visitors read",chips:["What it is","How to use it","What's allowed"]});case"install-docs":return t.jsx(On,{emoji:"📘",caption:"From zero to running, fast",chips:["Install","First example","Common task"]});case"examples":return t.jsx(On,{emoji:"🧩",caption:"Show it solving real tasks",chips:["Runnable","Real use cases","Copy & tweak"]});case"publish":return t.jsx(En,{nodes:[{emoji:"💻",label:"Your computer",sub:"Only you see it"},{emoji:"☁️",label:"Published",sub:"A home online",lime:!0},{emoji:"🌍",label:"Anyone, anywhere",sub:"Opens with a link"}]});case"deploy-target":return t.jsx(En,{nodes:[{emoji:"📦",label:"Your app",sub:"Ready to ship"},{emoji:"🎯",label:"Deploy target",sub:"Where it runs",lime:!0},{emoji:"🔁",label:"Ship anytime",sub:"One repeatable step"}]});case"deploy-previews":return t.jsx(En,{nodes:[{emoji:"✏️",label:"A change",sub:"Not public yet"},{emoji:"🔗",label:"Preview link",sub:"See it live",lime:!0},{emoji:"🚀",label:"Publish",sub:"Once it's right"}]});case"staging-preview":return t.jsx(En,{nodes:[{emoji:"🧪",label:"A change",sub:"Not public yet"},{emoji:"🔗",label:"Preview link",sub:"Share & try it",lime:!0},{emoji:"🚀",label:"Ship it",sub:"Only once it's right"}]});case"background-jobs":return t.jsx(En,{nodes:[{emoji:"⏳",label:"Slow work",sub:"Blocks the user"},{emoji:"📮",label:"Queued",sub:"Runs in the background",lime:!0},{emoji:"✅",label:"Done later",sub:"App stays fast"}]});case"changelog-ci":return t.jsx(En,{nodes:[{emoji:"🧑💻",label:"You merge",sub:"That's the trigger"},{emoji:"🤖",label:"CI runs",sub:"Build · test · notes",lime:!0},{emoji:"🚀",label:"Released",sub:"Every time"}]});case"payments":return t.jsx(ss,{center:{emoji:"💳",label:"Secure checkout"},satellites:["💳 One-off","🔁 Subscriptions","🧾 Receipts","↩️ Refunds"]});case"shell-completions":return t.jsx(ts,{before:{tag:"Without",items:["Memorize flags","Typos & retries"]},after:{tag:"With completions",items:["Tab to complete","Commands & options"]}});default:return null}}const VQ=Object.freeze(Object.defineProperty({__proto__:null,illustrationForTopic:lu},Symbol.toStringTag,{value:"Module"})),EL="Right now your app's information lives inside the code, so anything people enter disappears when they reload. A real database gives your app a memory: what people save stays saved — safely, and for good.",AL=[{q:"What is a database, really?",a:"A labelled place your app remembers things — like a spreadsheet it can read from and write to instantly. Instead of resetting when someone reloads, everything they saved is still there next time."},{q:"Do I have to run or manage a server?",a:"No. The database is hosted for you, so there's nothing to install, patch, or keep online. You connect it once and codeyam holds the keys — you never touch a server."},{q:"Is people's data kept private?",a:"Yes. Access rules decide who can see and change what, so one person can't read another person's information. You set the rules in plain terms and the database enforces them."},{q:"What does it cost to start?",a:"You can start on a free tier that comfortably covers a new app — no card needed. You only pay once the app grows popular, and you'll see it coming before you do."},{q:"Can I move my data somewhere else later?",a:"Yes. Your core data lives in a standard database, so it's yours to export and move whenever you like — you're never locked in."}],ML=["You are helping inside my actual codeyam project — this is real work in a real repository, not a hypothetical.","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.","","I want to set up **real data** — move my app's information out of the code and into a real database so it's saved for good, with private per-user access.","","Walk me through it and make the changes you safely can in my project: pick a suitable database for my stack, wire the connection, define the tables my app needs, and set up basic access rules. Ask me before anything destructive."].join(`
|
|
48
|
+
`);function bw({onBack:e,onChatWithAI:n}){return t.jsx(tu,{icon:t.jsx(Wr,{size:26}),title:"Use real data",crumbLabel:"Real data",meta:"Foundation · about 10 minutes",assistKey:"real-data",onBack:e,lead:EL,illustration:lu("real-data"),chatPrompt:ML,onChatWithAI:n,faqs:AL})}const KQ=Object.freeze(Object.defineProperty({__proto__:null,RealDataScreen:bw},Symbol.toStringTag,{value:"Module"})),Lo={entitySingular:"item",entityPlural:"items",savedThings:"saved items",purchaseNoun:"purchase"},IL=800;function af(e){switch(e){case"ready":return"ready";case"error":return"error";case"connected":case"provisioning":return"provisioning";default:return"provisioning"}}function cu(e,n){const[s,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)},[]),p=l.useCallback(g=>{var b,y;const x=af(g.status);x==="ready"?(u(),o({label:((b=g.result)==null?void 0:b.label)??"",value:((y=g.result)==null?void 0:y.value)??""}),r("ready")):x==="error"?(u(),c(g.message??"Connection failed."),r("error")):r("provisioning")},[u]),h=l.useCallback(async()=>{try{const g=await fetch(`/api/setup/connection-status?topic=${encodeURIComponent(e)}`);if(!g.ok)return;p(await g.json())}catch{}},[e,p]),f=l.useCallback(g=>{u(),c(null),o(null),r("connecting"),(async()=>{try{const b=await(await fetch("/api/setup/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topic:e,provider:n,credential:g})})).json().catch(()=>({}));p(b),af(b.status)==="provisioning"&&(d.current=setInterval(()=>void h(),IL))}catch(x){u(),c(x instanceof Error?x.message:"Connection failed."),r("error")}})()},[e,n,p,h,u]),m=l.useCallback(()=>{u(),r("idle"),o(null),c(null)},[u]);return l.useEffect(()=>u,[u]),{stage:s,result:a,error:i,connect:f,reset:m}}const DL="accounts";function LL(e){switch(e){case"clerk":return"Clerk";case"supabase_auth":return"Supabase Auth";default:return e}}function yw({provider:e,app:n=Lo,startedOn:s="recently",onComplete:r}){const{stage:a,result:o,error:i,connect:c,reset:d}=cu(DL,e),[u,p]=l.useState(""),h=LL(e);return a==="ready"?t.jsxs(t.Fragment,{children:[o&&(o.label||o.value)&&t.jsxs("div",{className:"url-card",role:"status",children:[t.jsx("span",{className:"ucglobe",children:"✅"}),t.jsxs("div",{children:[t.jsx("div",{className:"uc-l",children:o.label||"Connected"}),t.jsx("div",{className:"uc-u",children:o.value})]})]}),t.jsx(xu,{app:n,startedOn:s,onComplete:r})]}):a==="error"?t.jsxs("div",{className:"panel",children:[t.jsxs("div",{className:"real-error",role:"alert",children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"real-error-title",children:["Couldn’t connect ",h]}),t.jsx(ct,{variant:"icon",text:`Couldn’t connect ${h}: ${i}`})]}),t.jsx("div",{className:"real-error-msg",children:i})]}),t.jsx("button",{type:"button",className:"auth-btn",onClick:()=>{p(""),d()},children:"Try again"})]}):a==="connecting"||a==="provisioning"?t.jsxs("div",{className:"panel",children:[t.jsxs("div",{className:"deploy-head",children:[t.jsx("div",{className:"deploy-spin"}),t.jsxs("div",{children:[t.jsxs("div",{className:"deploy-t",children:["Setting up ",h]}),t.jsx("div",{className:"deploy-d",children:a==="connecting"?`Connecting to ${h}…`:"Provisioning your sign-in keys…"})]})]}),t.jsx("div",{className:"dep-bar",children:t.jsx("div",{className:"dep-bar-indeterminate"})})]}):t.jsxs("div",{className:"panel",children:[t.jsxs("div",{className:"ph",children:["Connect ",h]}),t.jsxs("div",{className:"psub",children:["Paste your ",h," 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."]}),t.jsxs("div",{className:"connect-box",children:[t.jsxs("label",{className:"real-token-label",htmlFor:"accounts-secret-key",children:[h," secret key"]}),t.jsx("input",{id:"accounts-secret-key",type:"password",className:"real-token-input",placeholder:`Paste your ${h} secret key`,value:u,onChange:f=>p(f.target.value)}),t.jsxs("button",{type:"button",className:"auth-btn",disabled:u.trim().length===0,onClick:()=>c(u.trim()),children:["Connect ",h]})]}),t.jsx("div",{className:"reassure",children:"🔒 Your key is stored locally and never shown."})]})}const JQ=Object.freeze(Object.defineProperty({__proto__:null,AccountsRealConnect:yw},Symbol.toStringTag,{value:"Module"}));function hn(e,n,s){return t.jsx("svg",{viewBox:"0 0 24 24",width:e,height:e,fill:"none",stroke:"currentColor",strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round",children:s})}function Ds({size:e=16}){return hn(e,1.9,t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M12 2 4 5v6c0 5 3.5 8 8 9 4.5-1 8-4 8-9V5z"}),t.jsx("path",{d:"m9 12 2 2 4-4"})]}))}function du({size:e=16}){return hn(e,2,t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M10 13a5 5 0 0 0 7 0l3-3a5 5 0 0 0-7-7l-1.5 1.5"}),t.jsx("path",{d:"M14 11a5 5 0 0 0-7 0l-3 3a5 5 0 0 0 7 7l1.5-1.5"})]}))}function uu({size:e=16}){return hn(e,1.8,t.jsx("path",{d:"M4 7h16M4 12h16M4 17h10"}))}function pu({size:e=16}){return hn(e,1.8,t.jsxs(t.Fragment,{children:[t.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),t.jsx("path",{d:"M3 9h18"})]}))}function FL({size:e=16}){return hn(e,2,t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"12",cy:"12",r:"9"}),t.jsx("path",{d:"M12 16v-4M12 8h.01"})]}))}function $L({size:e=16}){return hn(e,2,t.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 zL({size:e=16}){return hn(e,2,t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M12 2 3 7v10l9 5 9-5V7z"}),t.jsx("path",{d:"M3 7l9 5 9-5M12 12v10"})]}))}function BL({size:e=16}){return hn(e,2,t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M12 7v5l3 2"}),t.jsx("circle",{cx:"12",cy:"12",r:"9"})]}))}function WL({size:e=13}){return hn(e,2,t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"12",cy:"12",r:"9"}),t.jsx("path",{d:"m15 9-6 6M9 9l6 6"})]}))}function ls({size:e=13}){return hn(e,2.5,t.jsx("path",{d:"m5 12 5 5L20 6"}))}function vw({size:e=16}){return t.jsxs("svg",{viewBox:"0 0 24 24",width:e,height:e,fill:"none",stroke:"currentColor",strokeWidth:2,className:"rd-spin",children:[t.jsx("circle",{cx:"12",cy:"12",r:"9",strokeOpacity:".3"}),t.jsx("path",{d:"M21 12a9 9 0 0 0-9-9",strokeLinecap:"round"})]})}const XQ=Object.freeze(Object.defineProperty({__proto__:null,ChatIcon:$L,CheckGlyph:ls,ClockIcon:BL,CubeIcon:zL,InfoCircleIcon:FL,LinkIcon:du,ListLinesIcon:uu,ScreenIcon:pu,ShieldCheckIcon:Ds,SpinnerIcon:vw,XCircleIcon:WL},Symbol.toStringTag,{value:"Module"})),HL={"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."}]},qL={"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."}]},UL={"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."}]},YL={"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."}]},GL={"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."}]},VL={"dev-accounts":[{id:"guide-dev-enrollment",label:"Guide me through developer enrollment",body:"Guide me through enrolling as a developer with Apple and/or Google — advice and a checklist, not performing the paid identity work for me. Help me decide individual vs. organisation enrollment; walk the Apple D-U-N-S lookup/registration and how long it takes (issuance can run up to ~2 weeks); plan the timeline so identity/business verification isn't the launch blocker; and explain the Google Play closed-testing gate (12 testers opted in for 14 continuous days, for personal accounts created after 2023-11-13). Produce a checklist and the decisions I need to make, and be explicit that I complete the actual paid enrollment and identity verification myself in the Apple/Google consoles."}],"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."}]},KL={"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":[{id:"prep-developer-account",label:"Prep my developer account",body:"Help me get ready to register as a Chrome Web Store developer. I'll pay the one-time fee and verify my identity myself — you can't do those. What you CAN do: draft a short public developer display name and the contact-email blurb the profile asks for, based on this project; explain individual vs group publisher and recommend one for my situation; and lay out the registration steps in order with the exact console URL so I can click through and complete them. Be explicit about which steps are manual."}],"extension-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.`}]},JL={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."}]},XL={"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)."}]},QL={...HL,...qL,...UL,...YL,...GL,...VL,...KL,...JL,...XL};function jw(e){return QL[e]??[]}function ZL({topicName:e,goal:n}){const s=[];return s.push("You are helping inside the user's actual codeyam project — this is real work in a real repository, not a hypothetical."),s.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."),s.push(""),s.push(`You're helping with **${e}** — specifically: **${n.label}**.`),s.push(""),s.push(n.body),s.push(""),s.push("Walk me through it and make the changes you safely can in my project, asking before anything destructive."),s.join(`
|
|
49
|
+
`)}function Hn({assistKey:e,topicName:n,goalId:s,buttonLabel:r}){const a=jw(e).find(c=>c.id===s),[o,i]=l.useState(!1);return a?t.jsxs("div",{className:"setup-goal-assist mt-4",children:[t.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&&t.jsx("div",{className:"mt-3 rounded-md border border-[var(--border-subtle)] bg-[var(--bg-deep)]",children:t.jsx(qt,{chatName:`setup-${e}-${a.id}`,prompt:ZL({topicName:n,goal:a}),height:360,onClose:()=>i(!1)})})]}):null}const QQ=Object.freeze(Object.defineProperty({__proto__:null,SetupGoalAssist:Hn},Symbol.toStringTag,{value:"Module"}));function Pe({assistKey:e,topicName:n}){const s=jw(e);return s.length===0?null:t.jsx(t.Fragment,{children:s.map(r=>t.jsx(Hn,{assistKey:e,topicName:n,goalId:r.id,buttonLabel:`Ask AI to help: ${r.label}`},r.id))})}const ZQ=Object.freeze(Object.defineProperty({__proto__:null,SetupGoalAssistList:Pe},Symbol.toStringTag,{value:"Module"})),e4=1800;function Fo({config:e,onConnect:n}){const[s,r]=l.useState(!1),[a,o]=l.useState(!1),[i,c]=l.useState(null),d=()=>{s||(r(!0),window.setTimeout(n,e4))},u=e.connectColor==="green"?{"--connect":"var(--green)"}:void 0;return t.jsxs("div",{className:"su-wrap",children:[t.jsxs("div",{className:"su-shead",children:[t.jsx("div",{className:"su-badge",children:e.badge}),t.jsxs("div",{children:[t.jsxs("h1",{className:"su-title",children:[e.title," ",t.jsx("span",{className:"su-chip notset",children:"Not set up"})]}),t.jsxs("div",{className:"su-via",children:["powered by ",t.jsx("b",{children:e.providerName})]}),t.jsx("p",{className:"su-lead",children:e.lead})]})]}),t.jsxs("div",{className:"su-explain",children:[t.jsxs("div",{className:"su-eh",children:[t.jsx("span",{className:"su-q",children:"?"}),e.explainerHeading]}),t.jsx("div",{className:"su-lede",children:e.lede}),t.jsx("div",{className:"su-erows",children:e.explainerRows.map(p=>t.jsxs("div",{className:"su-erow",children:[t.jsx("div",{className:"su-en",children:p.icon}),t.jsxs("div",{className:"su-et",children:[t.jsx("b",{children:p.title}),t.jsx("span",{children:p.desc})]})]},p.title))}),t.jsxs("div",{className:"su-why",children:[t.jsxs("div",{className:"su-wh",children:[t.jsx(Ds,{size:15}),e.whyHeading]}),e.whyRows.map(p=>t.jsxs("div",{className:"su-whyrow",children:[t.jsx("span",{className:"su-wc",children:t.jsx(ls,{size:11})}),t.jsxs("p",{children:[t.jsx("b",{children:p.lead})," ",p.rest]})]},p.lead))]})]}),t.jsxs("div",{className:"su-connect",style:u,children:[t.jsx("div",{className:"su-ct",children:e.connectTitle}),t.jsx("div",{className:"su-cd",children:e.connectDesc}),t.jsx("button",{type:"button",className:"su-cbtn",onClick:d,disabled:s,children:s?t.jsxs(t.Fragment,{children:[t.jsx(vw,{size:16}),"Opening ",e.providerName,"…"]}):t.jsxs(t.Fragment,{children:[t.jsx(du,{size:16}),e.connectButtonLabel]})}),t.jsx("div",{className:"su-reassure",children:e.reassure.map(p=>t.jsxs("span",{children:[t.jsx(ls,{size:13}),p]},p))})]}),e.alternatives&&e.alternatives.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",className:"su-alt-toggle",onClick:()=>o(p=>!p),children:[a?"Hide other options":e.altToggleLabel," ",t.jsx("span",{className:"su-chev"+(a?" open":""),children:"⌄"})]}),a?t.jsx("div",{className:"su-alts",children:e.alternatives.map(p=>t.jsxs("div",{className:"su-altrow",children:[t.jsx("div",{className:"su-altmark",style:{background:p.color},children:p.monogram}),t.jsxs("div",{className:"su-altbody",children:[t.jsx("div",{className:"su-altname",children:p.name}),t.jsx("div",{className:"su-altdesc",children:p.desc}),p.factKey?t.jsxs("div",{className:"su-altfact",children:[Te(p.factKey).value,t.jsx(Yn,{fact:Te(p.factKey)})]}):null]}),t.jsx("button",{type:"button",className:"su-altpick"+(i===p.name?" picked":""),onClick:()=>c(p.name),children:i===p.name?"Selected ✓":"Use this"})]},p.name))}):null]}):null,t.jsx("div",{className:"su-uplabel",children:e.lockedLabel}),t.jsx("div",{className:"su-locked",children:e.lockedSteps.map(p=>t.jsxs("div",{className:"su-lrow",children:[t.jsx("div",{className:"su-ln",children:p.icon}),t.jsxs("div",{className:"su-lt",children:[t.jsx("b",{children:p.title}),t.jsx("span",{children:p.desc})]}),t.jsx("span",{className:"su-lk",children:t.jsx(et,{size:15})})]},p.title))}),e.faq&&e.faq.length>0?t.jsx(yt,{items:e.faq}):null,e.assistKey?t.jsx(Pe,{assistKey:e.assistKey,topicName:e.title}):null]})}const eZ=Object.freeze(Object.defineProperty({__proto__:null,SetupNotConnected:Fo},Symbol.toStringTag,{value:"Module"}));function $o({children:e}){return t.jsx("div",{className:"su-steps",children:e})}function dn({state:e,num:n,title:s,pill:r,desc:a,children:o}){return t.jsxs("div",{className:"su-step",children:[t.jsxs("div",{className:"su-rail",children:[t.jsx("div",{className:"su-node "+e,children:e==="done"?t.jsx(ls,{size:15}):n}),t.jsx("div",{className:"su-line"})]}),t.jsxs("div",{className:"su-scon",children:[t.jsxs("div",{className:"su-stitle",children:[s,r?t.jsx("span",{className:"su-pill",children:r}):null]}),t.jsx("div",{className:"su-sdesc",children:a}),o]})]})}function hu({monogram:e,name:n,detail:s,monogramStyle:r}){return t.jsxs("div",{className:"su-acct",children:[t.jsx("div",{className:"su-av",style:r,children:e}),t.jsxs("div",{className:"su-ainfo",children:[t.jsx("b",{children:n}),t.jsx("span",{children:s})]}),t.jsx("button",{type:"button",className:"su-chg",children:"Change"})]})}function ww({methods:e,initialSelected:n}){const[s,r]=l.useState(()=>new Set(n)),a=o=>r(i=>{const c=new Set(i);return c.has(o)?c.delete(o):c.add(o),c});return t.jsx("div",{className:"su-methods",children:e.map(o=>t.jsxs("button",{type:"button",className:"su-mchip"+(s.has(o.key)?" on":""),onClick:()=>a(o.key),"aria-pressed":s.has(o.key),children:[t.jsx("span",{className:"su-ck",children:t.jsx(ls,{size:11})}),o.icon,o.label]},o.key))})}function zo({children:e}){return t.jsxs("div",{className:"su-field",children:[t.jsx("span",{className:"su-edit",children:"Edit"}),e]})}function _w({examples:e}){const[n,s]=l.useState(new Set),r=a=>s(o=>{const i=new Set(o);return i.has(a)?i.delete(a):i.add(a),i});return t.jsx("div",{className:"su-examples",children:e.map((a,o)=>t.jsxs("button",{type:"button",className:"su-ex"+(n.has(o)?" added":""),onClick:()=>r(o),children:[t.jsx("span",{className:"su-plus",children:n.has(o)?"✓":"+"}),a]},a))})}function Bo({items:e}){return t.jsx("div",{className:"su-builds",children:e.map(n=>t.jsxs("div",{className:"su-bitem",children:[t.jsx("div",{className:"su-bx",children:t.jsx(ls,{size:13})}),t.jsxs("div",{className:"su-bmain",children:[t.jsx("b",{children:n.title}),t.jsx("span",{children:n.caption})]}),t.jsx("span",{className:"su-where",children:n.where})]},n.title))})}function Wo({accent:e,icon:n,children:s}){const r={"--note-accent":e==="amber"?"var(--amber)":"var(--blue)"};return t.jsxs("div",{className:"su-note",style:r,children:[n,t.jsx("p",{children:s})]})}function Ho({label:e,note:n,onPlan:s}){const[r,a]=l.useState(!1),o=()=>{r||(a(!0),s==null||s())};return t.jsxs("div",{className:"su-foot",children:[t.jsx("button",{type:"button",className:"su-cta",onClick:o,disabled:r,children:r?"Added to your plans ✓":t.jsxs(t.Fragment,{children:[e," ",t.jsx("span",{className:"su-ar",children:"→"})]})}),t.jsx("div",{className:"su-fnote",children:n})]})}const tZ=Object.freeze(Object.defineProperty({__proto__:null,BuildList:Bo,ControlNote:Wo,EditableField:zo,ExampleChips:_w,MethodChips:ww,SetupAccountRow:hu,SetupPlanFooter:Ho,SetupStep:dn,SetupStepper:$o},Symbol.toStringTag,{value:"Module"}));function qs(e,n,s){return t.jsx("svg",{viewBox:"0 0 24 24",width:e,height:e,fill:"none",stroke:"currentColor",strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round",children:s})}function Ga({size:e=16}){return qs(e,1.7,t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"12",cy:"8",r:"3.5"}),t.jsx("path",{d:"M5 20a7 7 0 0 1 14 0"})]}))}function Sw({size:e=16}){return qs(e,1.8,t.jsx("path",{d:"M5 12h14M12 5l7 7-7 7"}))}function fu({size:e=16}){return qs(e,1.8,t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M22 2 11 13"}),t.jsx("path",{d:"M22 2 15 22l-4-9-9-4z"})]}))}function kw({size:e=16}){return qs(e,1.8,t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M12 9v4M12 17h.01"}),t.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 Al({size:e=16}){return qs(e,1.8,t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"m22 7-10 6L2 7"}),t.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2"})]}))}function Nw({size:e=16}){return t.jsx("svg",{viewBox:"0 0 24 24",width:e,height:e,fill:"currentColor",children:t.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 Cw({size:e=16}){return t.jsx("svg",{viewBox:"0 0 24 24",width:e,height:e,fill:"currentColor",children:t.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 Tw({size:e=16}){return qs(e,1.8,t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M12 3 3 8l9 5 9-5-9-5z"}),t.jsx("path",{d:"M3 8v5l9 5 9-5V8"})]}))}const nZ=Object.freeze(Object.defineProperty({__proto__:null,AppleGlyph:Cw,ArrowRightIcon:Sw,GoogleGlyph:Nw,GraduationIcon:Tw,MagicLinkIcon:Al,PaperPlaneIcon:fu,PersonIcon:Ga,WarningTriangleIcon:kw},Symbol.toStringTag,{value:"Module"})),t4=[1e3,2e3,4e3,8e3];async function mu(e,n,s=t4){for(let r=0;;r++){try{const a=await(n?fetch(e,n):fetch(e));if(!(a.status>=500)||r>=s.length)return a}catch(a){if(r>=s.length)throw a}await new Promise(a=>setTimeout(a,s[r]))}}function gu(){const[e,n]=l.useState(null),s=l.useCallback(async()=>{try{const a=await mu("/api/setup-services");if(!a.ok)throw new Error(`HTTP ${a.status}`);const o=await a.json();n(Array.isArray(o)?o:[])}catch{n([])}},[]);l.useEffect(()=>{s()},[s]);const r=l.useCallback(a=>{n(o=>o&&o.map(i=>i.key===a?{...i,status:"dismissed"}:i)),fetch(`/api/setup-services/${encodeURIComponent(a)}/dismiss`,{method:"POST"}).catch(()=>{s()})},[s]);return{services:e,dismiss:r,refetch:s}}function qo({topic:e}){const{services:n}=gu();if(!n)return null;const s=n.find(a=>a.topic===e&&a.status!=="dismissed");if(!s)return null;const r=s.evidence.map(a=>a.value).join(", ");return t.jsxs("div",{className:"wired-provider",role:"note",children:[t.jsxs("div",{className:"wired-provider-title",children:[t.jsx("b",{children:s.name})," is already wired in this project"]}),t.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 sZ=Object.freeze(Object.defineProperty({__proto__:null,WiredProviderBanner:qo},Symbol.toStringTag,{value:"Module"}));function n4(e){return{accent:"blue",assistKey:"accounts",badge:t.jsx(Ga,{size:25}),title:"Let people sign in",providerName:"Supabase",connectColor:"lime",lead:`Right now everyone using your app is anonymous, so a ${e.entitySingular} they save vanishes the moment they close the tab. Give people their own account and their ${e.savedThings} and settings follow them on any device. CodeYam uses Supabase.`,explainerHeading:"New to accounts? Here's the short version",lede:t.jsxs(t.Fragment,{children:[t.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"," ",e.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:t.jsx(Ga,{size:16}),title:"Everything stays tied to them",desc:t.jsxs(t.Fragment,{children:["Their ",e.savedThings," and profile are remembered"," ",t.jsx("em",{children:"even after they close the app"}),", instead of resetting."]})},{icon:t.jsx(Sw,{size:16}),title:"It follows them across devices",desc:t.jsxs(t.Fragment,{children:["Sign in on a phone, see the same ",e.savedThings," on a laptop,"," ",t.jsx("em",{children:"anywhere they sign in"}),"."]})},{icon:t.jsx(et,{size:16}),title:"It keeps private things private",desc:t.jsxs(t.Fragment,{children:["Accounts let you say ",t.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:t.jsx(uu,{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 ${e.entitySingular}."`},{icon:t.jsx(pu,{size:15}),title:"CodeYam builds your sign-in screens",desc:`A sign-in screen, a "sign in to save" prompt, per-person ${e.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 (${Te("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 s4=[{key:"google",label:"Google",icon:t.jsx(Nw,{size:15})},{key:"apple",label:"Apple",icon:t.jsx(Cw,{size:15})},{key:"email",label:"Email",icon:t.jsx(Al,{size:15})},{key:"magic",label:"Magic link",icon:t.jsx(Al,{size:15})}];function xu({app:e,startedOn:n,onComplete:s}){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:`/${e.entitySingular}`},{title:`Each person's own ${e.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 t.jsxs("div",{className:"su-wrap",children:[t.jsxs("div",{className:"su-shead",children:[t.jsx("div",{className:"su-badge",children:t.jsx(Ga,{size:25})}),t.jsxs("div",{children:[t.jsx("h1",{className:"su-title",children:"Let people sign in"}),t.jsxs("div",{className:"su-via",children:["powered by ",t.jsx("b",{children:"Supabase"})," · the sign-in tech behind modern apps"]}),t.jsxs("p",{className:"su-lead",children:["Give people their own account so their ",e.savedThings," and settings follow them on any device. CodeYam builds the screens and handles the security, you just decide who gets in."]})]})]}),t.jsxs("div",{className:"su-remember",children:[t.jsx("span",{className:"su-rdot"}),t.jsxs("div",{className:"su-widget-body",children:[t.jsxs("b",{children:["You started this on ",n,"."]}),t.jsx("span",{children:"Sign-in methods are chosen — one step left before you can plan it."})]}),t.jsx("span",{className:"su-ago",children:"resumed today"})]}),t.jsxs("div",{className:"su-learn",children:[t.jsxs("div",{className:"su-lhd",children:[t.jsx(Tw,{size:15}),'What "accounts" actually means']}),t.jsxs("p",{children:["Right now everyone using your app is ",t.jsx("b",{children:"anonymous"})," — nothing they do is tied to them, so a saved ",e.entitySingular," disappears when they close the tab."]}),t.jsxs("p",{children:["Accounts give each person a ",t.jsx("b",{children:"private space"}),": their own"," ",e.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.`]})]}),t.jsx("div",{className:"su-seclabel",children:"Set it up"}),t.jsxs($o,{children:[t.jsx(dn,{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:t.jsx(ww,{methods:s4,initialSelected:["google","apple","email"]})}),t.jsx(dn,{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:t.jsxs(zo,{children:["Let people ",t.jsx("b",{children:"browse freely"})," without an account. Only ask them to sign in when they ",t.jsxs("b",{children:["save an ",e.entitySingular]})," or"," ",t.jsxs("b",{children:["buy a ",e.purchaseNoun]}),"."]})}),t.jsx(dn,{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:t.jsx(Bo,{items:r})})]}),t.jsxs(Wo,{accent:"blue",icon:t.jsx(et,{size:17}),children:[t.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."]}),t.jsx(Ho,{label:"Plan these 4 changes",note:t.jsxs(t.Fragment,{children:["They'll land in your ",t.jsx("b",{children:"Plan"})," tab, ready to build after your current session."]}),onPlan:s})]})}function Pw({onBack:e,onComplete:n,app:s=Lo,initialConnected:r=!1,startedOn:a="recently",connector:o}){const[i,c]=l.useState(r),d=!!o&&!i;return t.jsxs("div",{className:"setup-screen accent-blue",children:[t.jsxs("div",{className:"su-crumbs",children:[t.jsx("button",{type:"button",className:"back",onClick:e,"aria-label":"Back",children:"←"}),t.jsx("button",{type:"button",onClick:e,children:"Setup"}),t.jsx("span",{className:"sep",children:"/"}),t.jsx("b",{children:"Accounts & sign-in"})]}),t.jsx(qo,{topic:"accounts"}),i?t.jsx(xu,{app:s,startedOn:a,onComplete:n}):d?t.jsx(yw,{provider:o.provider,app:s,startedOn:a,onComplete:n}):t.jsx(Fo,{config:n4(s),onConnect:()=>c(!0)})]})}const rZ=Object.freeze(Object.defineProperty({__proto__:null,AccountsConnected:xu,AccountsScreen:Pw},Symbol.toStringTag,{value:"Module"})),r4="hello@your-app.com",a4={monogram:"R",name:"Your app",detail:"you@your-app.com · re_live_…"};function o4(e){return{accent:"amber",assistKey:"emails",badge:t.jsx(Hs,{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:t.jsxs(t.Fragment,{children:[t.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:t.jsx(fu,{size:16}),title:"It sends reliably",desc:t.jsxs(t.Fragment,{children:["Receipts, password resets, and welcome notes go out"," ",t.jsx("em",{children:"the instant your app asks"}),", from your own address."]})},{icon:t.jsx(Ds,{size:16}),title:"It stays out of spam",desc:t.jsxs(t.Fragment,{children:["Resend handles the technical reputation work behind the scenes, so your emails ",t.jsx("em",{children:"actually arrive"})," instead of vanishing."]})},{icon:t.jsx(Qt,{size:16}),title:"It shows you what happened",desc:t.jsxs(t.Fragment,{children:["See what was sent, delivered, or opened ",t.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 ${Te("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:t.jsx(Ds,{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:t.jsx(uu,{size:15}),title:"Tell us which emails to send",desc:`Plain language, like "a receipt after each ${e.purchaseNoun}, and a welcome note on sign-up."`},{icon:t.jsx(pu,{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 Ow({app:e,verifiedAddress:n,account:s,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 & ${e.purchaseNoun} email`,caption:`With the ${e.entitySingular} details and a ${e.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 t.jsxs("div",{className:"su-wrap",children:[t.jsxs("div",{className:"su-shead",children:[t.jsx("div",{className:"su-badge",children:t.jsx(Hs,{size:25})}),t.jsxs("div",{children:[t.jsxs("h1",{className:"su-title",children:["Send emails from your app"," ",t.jsxs("span",{className:"su-chip connected",children:[t.jsx(ls,{size:11}),"Connected"]})]}),t.jsxs("div",{className:"su-via",children:["powered by ",t.jsx("b",{children:"Resend"})]}),t.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."})]})]}),t.jsxs("div",{className:"su-statusbar",children:[t.jsx("div",{className:"su-widget-ic",children:t.jsx(Ds,{size:16})}),t.jsxs("div",{className:"su-widget-body",children:[t.jsx("b",{children:"Your sending address is verified"}),t.jsxs("span",{children:["Emails go out from ",t.jsx("code",{children:n}),", so they look like you, not a robot."]})]}),t.jsx("button",{type:"button",className:"su-chg",children:"Manage"})]}),t.jsxs($o,{children:[t.jsx(dn,{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:t.jsx(hu,{monogram:s.monogram,name:s.name,detail:s.detail,monogramStyle:{background:"#ffd400",color:"#1a1a1a"}})}),t.jsxs(dn,{state:"done",num:2,title:"Which emails should your app send?",desc:"Plain language is fine — this is what shapes the emails below.",children:[t.jsxs(zo,{children:["A ",t.jsx("b",{children:"welcome note"})," when someone signs up, a"," ",t.jsxs("b",{children:["receipt with their ",e.purchaseNoun]})," after a purchase, and a"," ",t.jsx("b",{children:"password reset link"})," when they ask for one."]}),t.jsx(_w,{examples:[`A reminder the day before an ${e.entitySingular}`,`A note when an ${e.entitySingular} is cancelled`,`A monthly "what's on" roundup`]})]}),t.jsx(dn,{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:t.jsx(Bo,{items:a})})]}),t.jsxs(Wo,{accent:"amber",icon:t.jsx(fu,{size:17}),children:[t.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."]}),t.jsx(Ho,{label:"Plan these 4 emails",note:t.jsxs(t.Fragment,{children:["They'll land in your ",t.jsx("b",{children:"Plan"})," tab, previewable before anything sends, and easy to reword anytime."]}),onPlan:r})]})}function Rw({onBack:e,onComplete:n,app:s=Lo,initialConnected:r=!1,verifiedAddress:a=r4,account:o=a4}){const[i,c]=l.useState(r);return t.jsxs("div",{className:"setup-screen accent-amber",children:[t.jsxs("div",{className:"su-crumbs",children:[t.jsx("button",{type:"button",className:"back",onClick:e,"aria-label":"Back",children:"←"}),t.jsx("button",{type:"button",onClick:e,children:"Setup"}),t.jsx("span",{className:"sep",children:"/"}),t.jsx("b",{children:"Sending emails"})]}),t.jsx(qo,{topic:"emails"}),i?t.jsx(Ow,{app:s,verifiedAddress:a,account:o,onComplete:n}):t.jsx(Fo,{config:o4(s),onConnect:()=>c(!0)})]})}const aZ=Object.freeze(Object.defineProperty({__proto__:null,EmailsConnected:Ow,EmailsScreen:Rw},Symbol.toStringTag,{value:"Module"}));function ca(e){return[{key:"connect",label:e.flowLabels[0]},{key:"provision",label:e.flowLabels[1]},{key:"ready",label:e.flowLabels[2]}]}function bu({config:e,provider:n,onBack:s,onComplete:r,onRevert:a}){const{stage:o,result:i,error:c,connect:d,reset:u}=cu(e.key,n),[p,h]=l.useState("");return o==="idle"?t.jsxs(t.Fragment,{children:[t.jsx($n,{topic:e.crumbLabel??e.title,step:e.flowLabels[0],onBack:s}),t.jsx(wn,{steps:ca(e),currentKey:"connect"}),t.jsxs("div",{className:"panel",children:[t.jsx("div",{className:"ph",children:e.connect.heading}),t.jsx("div",{className:"psub",children:e.connect.sub}),t.jsxs("div",{className:"connect-box",children:[t.jsxs("div",{className:"cbtitle",children:[t.jsx(Io,{initial:e.recommended.initial,color:e.recommended.color}),t.jsxs("div",{children:[t.jsxs("div",{className:"cbt",children:["Connect ",e.recommended.name]}),t.jsxs("div",{className:"cbd",children:["Paste a ",e.recommended.name," API token to connect your real account."]})]})]}),t.jsx("label",{className:"real-token-label",htmlFor:"real-token",children:"API token"}),t.jsx("input",{id:"real-token",type:"password",className:"real-token-input",placeholder:`Paste your ${e.recommended.name} token`,value:p,onChange:f=>h(f.target.value)}),t.jsx("button",{type:"button",className:"auth-btn",disabled:p.trim().length===0,onClick:()=>d(p.trim()),children:e.connect.continueLabel})]}),t.jsxs("div",{className:"reassure",children:["🔒 ",e.connect.reassure]})]})]}):o==="error"?t.jsxs(t.Fragment,{children:[t.jsx($n,{topic:e.crumbLabel??e.title,step:e.flowLabels[0],onBack:s}),t.jsx(wn,{steps:ca(e),currentKey:"connect"}),t.jsxs("div",{className:"panel",children:[t.jsxs("div",{className:"real-error",role:"alert",children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsx("div",{className:"real-error-title",children:"Couldn’t connect"}),t.jsx(ct,{variant:"icon",text:`Couldn’t connect: ${c}`})]}),t.jsx("div",{className:"real-error-msg",children:c})]}),t.jsx("button",{type:"button",className:"auth-btn",onClick:()=>{h(""),u()},children:"Try again"})]})]}):o==="ready"?t.jsxs(t.Fragment,{children:[t.jsx($n,{topic:e.crumbLabel??e.title,step:e.flowLabels[2]}),t.jsx(wn,{steps:ca(e),currentKey:"ready"}),t.jsxs("div",{className:"panel",children:[t.jsxs("div",{className:"live-hero",children:[t.jsx("div",{className:"lh-em",children:"🎉"}),t.jsx("div",{className:"lh-t",children:e.ready.title}),t.jsx("div",{className:"lh-d",children:e.ready.desc})]}),t.jsxs("div",{className:"url-card",children:[t.jsx("span",{className:"ucglobe",children:"✅"}),t.jsxs("div",{children:[t.jsx("div",{className:"uc-l",children:(i==null?void 0:i.label)||e.ready.resultLabel}),t.jsx("div",{className:"uc-u",children:(i==null?void 0:i.value)||e.ready.resultValue})]})]}),t.jsxs("div",{className:"live-foot",children:[t.jsxs("span",{className:"done-pill",children:[t.jsx(lt,{})," ",e.ready.donePill]}),t.jsx("button",{type:"button",className:"lf-back",onClick:()=>r==null?void 0:r(),children:"Back to Setup"}),a?t.jsx("button",{type:"button",className:"lf-revert",onClick:a,children:"Mark as not complete"}):null]})]})]}):t.jsxs(t.Fragment,{children:[t.jsx($n,{topic:e.crumbLabel??e.title,step:e.flowLabels[1]}),t.jsx(wn,{steps:ca(e),currentKey:"provision"}),t.jsxs("div",{className:"panel",children:[t.jsxs("div",{className:"deploy-head",children:[t.jsx("div",{className:"deploy-spin"}),t.jsxs("div",{children:[t.jsx("div",{className:"deploy-t",children:e.provisionTitle}),t.jsx("div",{className:"deploy-d",children:o==="connecting"?`Connecting to ${e.recommended.name}…`:e.provisionDesc})]})]}),t.jsx("div",{className:"dep-bar",children:t.jsx("div",{className:"dep-bar-indeterminate"})})]})]})}const oZ=Object.freeze(Object.defineProperty({__proto__:null,RealSetupFlow:bu},Symbol.toStringTag,{value:"Module"})),i4={monogram:"AC",name:"Your app",detail:"you@your-app.com · acct_…"};function l4(e){return{accent:"indigo",assistKey:"payments",badge:t.jsx(kn,{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:t.jsxs(t.Fragment,{children:[t.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:t.jsx(et,{size:16}),title:"It takes the payment safely",desc:t.jsxs(t.Fragment,{children:["The buyer types their card into ",t.jsx("em",{children:"Stripe's"})," secure screen, not yours. Sensitive numbers never sit in your app."]})},{icon:t.jsx(kn,{size:16}),title:"It charges the card",desc:t.jsxs(t.Fragment,{children:["Stripe talks to the banks and approves the payment in"," ",t.jsx("em",{children:"a few seconds"}),", then tells your app it went through."]})},{icon:t.jsx(Qt,{size:16}),title:"It pays you",desc:t.jsxs(t.Fragment,{children:["The money lands in ",t.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 (${Te("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:t.jsx(Ds,{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:t.jsx(du,{size:15}),title:"Tell us what you're selling",desc:`A sentence in plain language, like "${e.entitySingular} ${e.purchaseNoun}s, $10 to $45."`},{icon:t.jsx(kn,{size:15}),title:"CodeYam builds your checkout",desc:`A "Get ${e.purchaseNoun}s" button, a payment screen, and an emailed receipt — each one a plan you preview before it ships.`}]}}function c4(e){return{key:"payments",connector:{provider:"stripe"},Icon:kn,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 ${e.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 Ew(){const[e,n]=l.useState("test");return t.jsxs("div",{className:"su-modebar",children:[t.jsx("div",{className:"su-widget-ic",children:t.jsx(kw,{size:16})}),t.jsxs("div",{className:"su-widget-body",children:[t.jsx("b",{children:e==="test"?"You're in test mode":"You're live"}),t.jsx("span",{children:e==="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."})]}),t.jsxs("div",{className:"su-seg",children:[t.jsx("button",{type:"button",className:e==="test"?"on":"",onClick:()=>n("test"),children:"Test"}),t.jsx("button",{type:"button",className:"live"+(e==="live"?" on":""),onClick:()=>n("live"),children:"Live"})]})]})}function Aw({app:e,account:n,onComplete:s}){const r=[{title:`A "Get ${e.purchaseNoun}s" button`,caption:`Added to each ${e.entitySingular} so people can buy in one tap.`,where:`/${e.entitySingular}`},{title:"A checkout screen",caption:"Card payment, Apple Pay, and Google Pay, hosted by Stripe.",where:"/checkout"},{title:`An emailed receipt & ${e.purchaseNoun}`,caption:`Stripe sends the card payment receipt automatically; CodeYam adds your own branded confirmation with the ${e.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 t.jsxs("div",{className:"su-wrap",children:[t.jsxs("div",{className:"su-shead",children:[t.jsx("div",{className:"su-badge",children:t.jsx(kn,{size:25})}),t.jsxs("div",{children:[t.jsx("h1",{className:"su-title",children:"Accept payments"}),t.jsxs("div",{className:"su-via",children:["powered by ",t.jsx("b",{children:"Stripe"})," · the payments tech behind millions of apps"]}),t.jsxs("p",{className:"su-lead",children:["Let people pay inside your app — buy a ",e.purchaseNoun,", leave a tip, subscribe. CodeYam handles the wiring; you just describe what you're selling and preview every screen before it goes live."]})]})]}),t.jsx(Ew,{}),t.jsxs($o,{children:[t.jsx(dn,{state:"done",num:1,title:"Connect your Stripe account",pill:"Connected",desc:"CodeYam never sees your customers' card numbers — Stripe handles that part.",children:t.jsx(hu,{monogram:n.monogram,name:n.name,detail:n.detail})}),t.jsx(dn,{state:"done",num:2,title:"What are you selling?",desc:"Plain language is fine — this is what shapes the screens below.",children:t.jsxs(zo,{children:[e.entitySingular," ",e.purchaseNoun,"s, one-off purchases from"," ",t.jsx("b",{children:"$10 to $45"}),". Buyers get a ",e.purchaseNoun," by email."]})}),t.jsx(dn,{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:t.jsx(Bo,{items:r})})]}),t.jsxs(Wo,{accent:"amber",icon:t.jsx(et,{size:17}),children:[t.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."]}),t.jsx(Ho,{label:"Plan these 4 changes",note:t.jsxs(t.Fragment,{children:["They'll land in your ",t.jsx("b",{children:"Plan"})," tab, ready to build after your current session, and previewable before anything ships."]}),onPlan:s})]})}function Mw({onBack:e,onComplete:n,onRevert:s,app:r=Lo,initialConnected:a=!1,account:o=i4,connector:i}){const[c,d]=l.useState(a);let u;return i&&c?u=t.jsx(bu,{config:c4(r),provider:i.provider,onBack:()=>d(!1),onComplete:n,onRevert:s}):c?u=t.jsx(Aw,{app:r,account:o,onComplete:n}):u=t.jsx(Fo,{config:l4(r),onConnect:()=>d(!0)}),t.jsxs("div",{className:"setup-screen accent-indigo",children:[t.jsxs("div",{className:"su-crumbs",children:[t.jsx("button",{type:"button",className:"back",onClick:e,"aria-label":"Back",children:"←"}),t.jsx("button",{type:"button",onClick:e,children:"Setup"}),t.jsx("span",{className:"sep",children:"/"}),t.jsx("b",{children:"Payments"})]}),t.jsx(qo,{topic:"payments"}),u]})}const iZ=Object.freeze(Object.defineProperty({__proto__:null,ModeBar:Ew,PaymentsConnected:Aw,PaymentsScreen:Mw},Symbol.toStringTag,{value:"Module"}));function Nt({config:e,onBack:n,onComplete:s,status:r,onRevert:a}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(e.Icon,{size:26}),title:e.title,crumbLabel:e.crumbLabel,meta:e.meta,onBack:n,assistKey:e.key}),e.leads.map(o=>t.jsx("p",{className:"lead"+(o.dim?" dim":""),children:o.text},o.text)),e.sections.map(o=>t.jsxs("div",{children:[t.jsx("div",{className:"seclabel",children:o.heading}),o.body?t.jsx("p",{className:"lead dim",children:o.body}):null,o.bullets?t.jsx("div",{className:"reasons",children:o.bullets.map(i=>t.jsxs("div",{className:"reason",children:[t.jsx(lt,{}),t.jsxs("span",{children:[i.lead?t.jsxs("b",{children:[i.lead," "]}):null,i.text]})]},i.text))}):null]},o.heading)),e.options&&e.options.length>0?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"seclabel",children:e.optionsLabel??"Your options"}),e.options.map(o=>t.jsx(eu,{provider:o},o.name))]}):null,t.jsx(yt,{items:e.faq}),t.jsx(Pe,{assistKey:e.key,topicName:e.title}),t.jsx(Re,{label:e.doneLabel,note:e.doneNote??"You can revisit this anytime.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const lZ=Object.freeze(Object.defineProperty({__proto__:null,TeachSetupScreen:Nt},Symbol.toStringTag,{value:"Module"})),d4={key:"analytics-monitoring",Icon:Qt,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 Iw({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Nt,{config:d4,onBack:e,onComplete:n,status:s,onRevert:r})}const cZ=Object.freeze(Object.defineProperty({__proto__:null,AnalyticsMonitoringScreen:Iw},Symbol.toStringTag,{value:"Module"})),u4={key:"legal",Icon:Xe,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 Dw({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Nt,{config:u4,onBack:e,onComplete:n,status:s,onRevert:r})}const dZ=Object.freeze(Object.defineProperty({__proto__:null,LegalScreen:Dw},Symbol.toStringTag,{value:"Module"}));function Lw({config:e,onBack:n,onSetup:s}){return t.jsxs(t.Fragment,{children:[t.jsx(Ce,{icon:t.jsx(e.Icon,{size:26}),title:e.title,crumbLabel:e.crumbLabel,meta:e.meta,onBack:n,assistKey:e.key}),e.leads.map(r=>t.jsx("p",{className:"lead"+(r.dim?" dim":""),children:r.text},r.text)),t.jsx("div",{className:"seclabel",children:e.recommendLabel}),t.jsx(eu,{provider:e.recommended}),t.jsx(Oj,{alts:e.alternatives}),t.jsxs("div",{className:"cta-wrap",children:[t.jsx("button",{type:"button",className:"cta",onClick:s,children:e.ctaLabel}),t.jsx("div",{className:"cta-note",children:e.ctaNote})]}),t.jsx(yt,{items:e.faq}),t.jsx(Pe,{assistKey:e.key,topicName:e.title})]})}const uZ=Object.freeze(Object.defineProperty({__proto__:null,SimulatedSetupOverview:Lw},Symbol.toStringTag,{value:"Module"})),of=1100,p4=700;function yu(e){return[{key:"connect",label:e.flowLabels[0]},{key:"provision",label:e.flowLabels[1]},{key:"ready",label:e.flowLabels[2]}]}function Fw({config:e,onBack:n,onContinue:s}){return t.jsxs(t.Fragment,{children:[t.jsx($n,{topic:e.crumbLabel??e.title,step:e.flowLabels[0],onBack:n}),t.jsx(wn,{steps:yu(e),currentKey:"connect"}),t.jsxs("div",{className:"panel",children:[t.jsx("div",{className:"ph",children:e.connect.heading}),t.jsx("div",{className:"psub",children:e.connect.sub}),t.jsxs("div",{className:"connect-box",children:[t.jsxs("div",{className:"cbtitle",children:[t.jsx(Io,{initial:e.recommended.initial,color:e.recommended.color}),t.jsxs("div",{children:[t.jsxs("div",{className:"cbt",children:["Sign in with ",e.recommended.name]}),t.jsxs("div",{className:"cbd",children:["We'll open ",e.recommended.name," in a new tab and bring you right back."]})]})]}),t.jsx("div",{className:"grant",children:e.connect.grants.map(r=>t.jsxs("div",{className:"grantrow",children:[t.jsx(lt,{color:"var(--blue-300)"}),t.jsx("span",{children:r})]},r))}),t.jsx("button",{type:"button",className:"auth-btn",onClick:s,children:e.connect.continueLabel}),t.jsxs("div",{className:"auth-row",children:[t.jsx("button",{type:"button",className:"auth-ghost",onClick:s,children:"I already have an account"}),t.jsx("button",{type:"button",className:"auth-ghost",onClick:s,children:"Create one for me"})]})]}),t.jsxs("div",{className:"reassure",children:["🔒 ",e.connect.reassure]})]})]})}function $w({config:e,onDone:n}){const s=e.provisionSteps,[r,a]=l.useState(0),o=l.useRef(n);o.current=n,l.useEffect(()=>{const c=[];for(let d=1;d<=s.length;d++)c.push(setTimeout(()=>a(d),d*of));return c.push(setTimeout(()=>o.current(),s.length*of+p4)),()=>c.forEach(clearTimeout)},[s.length]);const i=Math.round(r/s.length*100);return t.jsxs(t.Fragment,{children:[t.jsx($n,{topic:e.crumbLabel??e.title,step:e.flowLabels[1]}),t.jsx(wn,{steps:yu(e),currentKey:"provision"}),t.jsxs("div",{className:"panel",children:[t.jsxs("div",{className:"deploy-head",children:[t.jsx("div",{className:"deploy-spin"}),t.jsxs("div",{children:[t.jsx("div",{className:"deploy-t",children:e.provisionTitle}),t.jsx("div",{className:"deploy-d",children:e.provisionDesc})]})]}),t.jsx("div",{className:"dep-bar",children:t.jsx("div",{style:{width:i+"%"}})}),t.jsx("div",{className:"dep-steps",children:s.map((c,d)=>t.jsxs("div",{className:"dep-step "+(d<r?"done":d===r?"active":"todo"),children:[t.jsx("div",{className:"dot",children:d<r?t.jsx(lt,{size:12,color:"#0a0a0a"}):null}),t.jsx("div",{className:"sl",children:c})]},c))})]})]})}function zw({config:e,onFinish:n,onRevert:s}){return t.jsxs(t.Fragment,{children:[t.jsx($n,{topic:e.crumbLabel??e.title,step:e.flowLabels[2]}),t.jsx(wn,{steps:yu(e),currentKey:"ready"}),t.jsxs("div",{className:"panel",children:[t.jsxs("div",{className:"live-hero",children:[t.jsx("div",{className:"lh-em",children:"🎉"}),t.jsx("div",{className:"lh-t",children:e.ready.title}),t.jsx("div",{className:"lh-d",children:e.ready.desc})]}),t.jsxs("div",{className:"url-card",children:[t.jsx("span",{className:"ucglobe",children:"✅"}),t.jsxs("div",{children:[t.jsx("div",{className:"uc-l",children:e.ready.resultLabel}),t.jsx("div",{className:"uc-u",children:e.ready.resultValue})]})]}),t.jsxs("div",{className:"live-foot",children:[t.jsxs("span",{className:"done-pill",children:[t.jsx(lt,{})," ",e.ready.donePill]}),t.jsx("button",{type:"button",className:"lf-back",onClick:n,children:"Back to Setup"}),s?t.jsx("button",{type:"button",className:"lf-revert",onClick:s,children:"Mark as not complete"}):null]})]})]})}const pZ=Object.freeze(Object.defineProperty({__proto__:null,SimulatedConnect:Fw,SimulatedProvision:$w,SimulatedReady:zw},Symbol.toStringTag,{value:"Module"}));function Hr({config:e,onBack:n,onComplete:s,onRevert:r}){const[a,o]=l.useState("overview");let i;return a==="overview"?i=t.jsx(Lw,{config:e,onBack:n,onSetup:()=>o("connect")}):e.connector?i=t.jsx(bu,{config:e,provider:e.connector.provider,onBack:()=>o("overview"),onComplete:()=>{s==null||s(),n()},onRevert:r?()=>{r(),n()}:void 0}):a==="connect"?i=t.jsx(Fw,{config:e,onBack:()=>o("overview"),onContinue:()=>o("provision")}):a==="provision"?i=t.jsx($w,{config:e,onDone:()=>o("ready")}):i=t.jsx(zw,{config:e,onFinish:()=>{s==null||s(),n()},onRevert:r?()=>{r(),n()}:void 0}),t.jsx("div",{className:"hosting-screen",children:i})}const hZ=Object.freeze(Object.defineProperty({__proto__:null,SimulatedSetupScreen:Hr},Symbol.toStringTag,{value:"Module"})),h4={key:"publish",Icon:is,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:`${Te("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. ${Te("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: ${Te("cloudflarePages.free").value.toLowerCase()}, so traffic spikes won't cost you. Netlify's free tier: ${Te("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 Bw({onBack:e,onComplete:n,onRevert:s}){return t.jsx(Hr,{config:h4,onBack:e,onComplete:n,onRevert:s})}const fZ=Object.freeze(Object.defineProperty({__proto__:null,PublishScreen:Bw},Symbol.toStringTag,{value:"Module"})),f4={key:"custom-domain",Icon:Wn,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 Ww({onBack:e,onComplete:n,onRevert:s}){return t.jsx(Hr,{config:f4,onBack:e,onComplete:n,onRevert:s})}const mZ=Object.freeze(Object.defineProperty({__proto__:null,CustomDomainScreen:Ww},Symbol.toStringTag,{value:"Module"})),m4={key:"data-safety",Icon:Wr,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 Hw({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Nt,{config:m4,onBack:e,onComplete:n,status:s,onRevert:r})}const gZ=Object.freeze(Object.defineProperty({__proto__:null,DataSafetyScreen:Hw},Symbol.toStringTag,{value:"Module"})),g4={key:"forms",Icon:Hs,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 ${Te("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 qw({onBack:e,onComplete:n,onRevert:s}){return t.jsx(Hr,{config:g4,onBack:e,onComplete:n,onRevert:s})}const xZ=Object.freeze(Object.defineProperty({__proto__:null,FormsScreen:qw},Symbol.toStringTag,{value:"Module"})),x4={key:"analytics-seo",Icon:Qt,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 Uw({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Nt,{config:x4,onBack:e,onComplete:n,status:s,onRevert:r})}const bZ=Object.freeze(Object.defineProperty({__proto__:null,AnalyticsSeoScreen:Uw},Symbol.toStringTag,{value:"Module"})),b4={key:"redirects-404",Icon:Wn,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 Yw({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Nt,{config:b4,onBack:e,onComplete:n,status:s,onRevert:r})}const yZ=Object.freeze(Object.defineProperty({__proto__:null,RedirectsNotFoundScreen:Yw},Symbol.toStringTag,{value:"Module"})),y4={key:"performance-images",Icon:ot,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 Gw({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Nt,{config:y4,onBack:e,onComplete:n,status:s,onRevert:r})}const vZ=Object.freeze(Object.defineProperty({__proto__:null,PerformanceImagesScreen:Gw},Symbol.toStringTag,{value:"Module"})),v4={key:"comments-search",Icon:Xe,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 Vw({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Nt,{config:v4,onBack:e,onComplete:n,status:s,onRevert:r})}const jZ=Object.freeze(Object.defineProperty({__proto__:null,CommentsSearchScreen:Vw},Symbol.toStringTag,{value:"Module"})),_s={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."}},j4=[_s.crates,_s.npm,_s.pypi,_s.rubygems,_s.homebrew];function Kw(e){return _s[e]}function Jw({registry:e,onBack:n,onComplete:s,status:r,onRevert:a}){const o=e?Kw(e):null;return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(Mt,{size:26}),title:"Publish to a registry",meta:"Foundation · about 20 minutes",onBack:n,assistKey:"publish-registry"}),t.jsxs("p",{className:"lead",children:["This kind of project doesn't go live at a web address — it ships to a"," ",t.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."]}),o?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"seclabel",children:["Your registry: ",o.name," (",o.ecosystem,")"]}),t.jsxs(Se,{children:[t.jsxs($,{lead:`Publish with \`${o.publishCommand}\`.`,children:["From a clean, committed working tree, this packages the release and uploads it to ",o.name,". Get an account and an API token first.",o.note?t.jsxs(t.Fragment,{children:[" ",o.note]}):null]}),t.jsx($,{lead:`Users then run \`${o.installCommand}\`.`,children:"Once published, anyone can install your package with one command — no clone, no build from source."}),t.jsxs($,{lead:"Your package gets a public page.",children:[o.name," hosts a page at"," ",t.jsx("code",{children:o.packagePage})," — the link you share so people can find, install, and trust the package."]})]}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Before your first publish"}),t.jsxs(Se,{children:[t.jsxs($,{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 (",t.jsx("code",{children:"@you/tool"}),") or an org account."]}),t.jsxs($,{lead:"Turn on two-factor auth — registries expect it.",children:[Te("registry.twoFactor").value,"."," ",t.jsx(Yn,{fact:Te("registry.twoFactor")})," A token alone often isn't enough; set up 2FA before the release deadline, not during it."]})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:o.publishCommand}),t.jsx("span",{className:"chip",children:"Tokened account"}),t.jsx("span",{className:"chip",children:"Public package page"})]})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"seclabel",children:"Pick your registry"}),t.jsx(Se,{children:j4.map(i=>t.jsxs($,{lead:`${i.name} — ${i.ecosystem}.`,children:["Publish with ",t.jsx("code",{children:i.publishCommand}),"; users install with"," ",t.jsx("code",{children:i.installCommand}),".",i.note?t.jsxs(t.Fragment,{children:[" ",i.note]}):null]},i.kind))}),t.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."})]}),t.jsx(Pe,{assistKey:"publish-registry",topicName:"Publish to a registry"}),t.jsx(Re,{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.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const wZ=Object.freeze(Object.defineProperty({__proto__:null,PublishRegistryScreen:Jw},Symbol.toStringTag,{value:"Module"}));function Xw({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(Xe,{size:26}),title:"Versioning & changelog",meta:"About 20 minutes",onBack:e,assistKey:"versioning-changelog"}),t.jsxs("p",{className:"lead",children:["A version number is a promise. ",t.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."]}),t.jsx("div",{className:"seclabel",children:"The three numbers"}),t.jsxs(Se,{children:[t.jsx($,{lead:"PATCH (1.2.x) — bug fixes only.",children:"Nothing user-visible changes except that something broken now works. Always safe to take."}),t.jsx($,{lead:"MINOR (1.x.0) — new, backward-compatible features.",children:"Existing usage keeps working; there's just more available."}),t.jsx($,{lead:"MAJOR (x.0.0) — breaking changes.",children:"You removed or changed something people relied on. Bumping major is how you warn them."}),t.jsxs($,{lead:"Before 1.0.0 (0.x) — anything may break.",children:["The most-missed rule for new tools: while you're on a"," ",t.jsx("code",{children:"0.x"})," version, semver lets a ",t.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."]})]}),t.jsx(Yd,{spaced:!0,children:t.jsxs($,{lead:"Tag each release in git.",children:["A ",t.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.']})}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"MAJOR.MINOR.PATCH"}),t.jsx("span",{className:"chip",children:"CHANGELOG.md"}),t.jsx("span",{className:"chip",children:"git tag vX.Y.Z"})]}),t.jsx(Pe,{assistKey:"versioning-changelog",topicName:"Versioning & changelog"}),t.jsx(Re,{label:"My versioning scheme is set",note:"Pick the scheme once; every future release just follows the same rules.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:e})]})}const _Z=Object.freeze(Object.defineProperty({__proto__:null,VersioningChangelogScreen:Xw},Symbol.toStringTag,{value:"Module"}));function Qw({registry:e,onBack:n,onComplete:s,status:r,onRevert:a}){const o=e?Kw(e):null;return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(Xe,{size:26}),title:"Install docs",meta:"About 30 minutes · writing time",onBack:n,assistKey:"install-docs"}),t.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"," ",t.jsx("b",{children:"install command"})," and a tiny working example."]}),t.jsx("div",{className:"seclabel",children:"A good README opens with"}),t.jsxs(Se,{children:[t.jsx($,{lead:o?`The install command — \`${o.installCommand}\`.`:"The exact install command.",children:"One copy-pasteable line. Don't make people guess the package name or the registry it lives on."}),t.jsxs($,{lead:"A real first command to run.",children:["For a CLI, show an actual invocation — a quickstart like"," ",t.jsx("code",{children:"yourtool init"})," and the always-works"," ",t.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."]}),t.jsx($,{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."}),t.jsxs($,{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"," ",o?o.name:"registry"," page (",t.jsx("code",{children:o?o.packagePage:"the registry listing"}),") gives readers the canonical source."]})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"Install line first"}),t.jsx("span",{className:"chip",children:"Real command, not a snippet"}),t.jsx("span",{className:"chip",children:"Badges + package link"}),t.jsx("span",{className:"chip",children:o?o.name:"Any registry"})]}),t.jsx(Pe,{assistKey:"install-docs",topicName:"Install docs"}),t.jsx(Re,{label:"My install docs are ready",note:"Docs evolve with the project — update the README whenever the install or usage changes.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const SZ=Object.freeze(Object.defineProperty({__proto__:null,InstallDocsScreen:Qw},Symbol.toStringTag,{value:"Module"}));function Zw({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(ot,{size:26}),title:"Release builds",meta:"About 45 minutes · CI setup",onBack:e,assistKey:"release-builds"}),t.jsxs("p",{className:"lead",children:["Not everyone installs from a registry — many people just want a binary they can run. ",t.jsx("b",{children:"Cross-platform release builds"})," produce that binary for each operating system, so users download one file and go."]}),t.jsx("div",{className:"seclabel",children:"What to produce"}),t.jsxs(Se,{children:[t.jsx($,{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."}),t.jsx($,{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."}),t.jsxs($,{lead:"Build on a git tag, in CI.",children:["A push of ",t.jsx("code",{children:"v1.2.0"})," triggers the release workflow, so binaries always match a real, tagged version — no laptop builds. A tool like ",t.jsx("code",{children:"cargo-dist"}),", ",t.jsx("code",{children:"goreleaser"}),", or electron-builder wires up the whole matrix-build-sign-publish flow instead of you hand-writing it."]}),t.jsxs($,{lead:"Attach them to a GitHub Release.",children:["Upload the binaries (and their checksums) to the tagged"," ",t.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."]})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"macOS · Linux · Windows"}),t.jsx("span",{className:"chip",children:"Signed + notarized"}),t.jsx("span",{className:"chip",children:"Tag-triggered CI"}),t.jsx("span",{className:"chip",children:"GitHub Releases"}),t.jsx("span",{className:"chip",children:"Checksums"})]}),t.jsx(Pe,{assistKey:"release-builds",topicName:"Release builds"}),t.jsx(Re,{label:"My release builds are set up",note:"Once the workflow exists, every future tag produces binaries automatically.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:e})]})}const kZ=Object.freeze(Object.defineProperty({__proto__:null,ReleaseBuildsScreen:Zw},Symbol.toStringTag,{value:"Module"}));function e_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(Is,{size:26}),title:"Shell completions",meta:"About 30 minutes · polish",onBack:e,assistKey:"shell-completions"}),t.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."}),t.jsx("div",{className:"seclabel",children:"How it works"}),t.jsxs(Se,{children:[t.jsxs($,{lead:"Generate a completion script per shell.",children:["Most CLI frameworks emit completion scripts for ",t.jsx("code",{children:"bash"}),","," ",t.jsx("code",{children:"zsh"}),", ",t.jsx("code",{children:"fish"}),", and PowerShell from your command definitions — you don't hand-write them."]}),t.jsxs($,{lead:"Ship a `completions` subcommand.",children:["A ",t.jsx("code",{children:"yourtool completions zsh"})," command lets users (and your install docs) print the script for their shell on demand."]}),t.jsx($,{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."}),t.jsxs($,{lead:"Generate a man page from the same source.",children:["The sibling polish step: most CLI frameworks also emit a"," ",t.jsx("code",{children:"man"})," page from your command definitions, so"," ",t.jsx("code",{children:"man yourtool"})," works the way completions do — generated, not hand-written."]})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"bash · zsh · fish"}),t.jsx("span",{className:"chip",children:"Generated, not hand-written"}),t.jsx("span",{className:"chip",children:"completions subcommand"})]}),t.jsx(Pe,{assistKey:"shell-completions",topicName:"Shell completions"}),t.jsx(Re,{label:"My shell completions are ready",note:"Completions regenerate from your commands — they stay in sync as the CLI grows.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:e})]})}const NZ=Object.freeze(Object.defineProperty({__proto__:null,ShellCompletionsScreen:e_},Symbol.toStringTag,{value:"Module"}));function t_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(Is,{size:26}),title:"Command-line UX",meta:"About 30 minutes · the interface contract",onBack:e,assistKey:"cli-ux"}),t.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."}),t.jsx("div",{className:"seclabel",children:"The conventions every CLI follows"}),t.jsxs(Se,{children:[t.jsx($,{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."}),t.jsx($,{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."}),t.jsxs($,{lead:"Exit codes mean something.",children:[t.jsx("code",{children:"0"})," for success, non-zero for failure — and ideally distinct codes for distinct failures. This is how"," ",t.jsx("code",{children:"cmd && next"})," and CI know whether to continue, so an error that exits 0 silently breaks every script wrapping you."]}),t.jsx($,{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."`})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"--help · --version"}),t.jsx("span",{className:"chip",children:"Meaningful exit codes"}),t.jsx("span",{className:"chip",children:"stdout = data, stderr = noise"})]}),t.jsx(Pe,{assistKey:"cli-ux",topicName:"Command-line UX"}),t.jsx(Re,{label:"My command-line UX is solid",note:"Nail the contract first; shell completions and man pages are the polish on top of it.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:e})]})}const CZ=Object.freeze(Object.defineProperty({__proto__:null,CliUxScreen:t_},Symbol.toStringTag,{value:"Module"}));function n_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(et,{size:26}),title:"Security & supply chain",meta:"About 45 minutes · trust",onBack:e,assistKey:"supply-chain"}),t.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."}),t.jsx("div",{className:"seclabel",children:"What a published artifact owes its users"}),t.jsxs(Se,{children:[t.jsxs($,{lead:"Audit your own dependencies.",children:["Run ",t.jsx("code",{children:"cargo audit"})," (Rust) or ",t.jsx("code",{children:"npm audit"})," /"," ",t.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."]}),t.jsx($,{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."}),t.jsxs($,{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 (",t.jsx("code",{children:"cargo sbom"}),", ",t.jsx("code",{children:"npm sbom"}),","," ",t.jsx("code",{children:"syft"}),")."]}),t.jsxs($,{lead:"Sign your releases so they can be verified.",children:[Te("supplyChain.signedReleases").value,"."," ",t.jsx(Yn,{fact:Te("supplyChain.signedReleases")})," ","Pair that with published checksums (and a ",t.jsx("code",{children:"cosign"})," signature for binaries) so an install can prove it got exactly what you built."]})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"audit in CI"}),t.jsx("span",{className:"chip",children:"SBOM per release"}),t.jsx("span",{className:"chip",children:"Signed & verifiable"})]}),t.jsx(Pe,{assistKey:"supply-chain",topicName:"Security & supply chain"}),t.jsx(Re,{label:"My supply chain is covered",note:"Wire audit + signing into CI once; every future release inherits it automatically.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:e})]})}const TZ=Object.freeze(Object.defineProperty({__proto__:null,SupplyChainScreen:n_},Symbol.toStringTag,{value:"Module"}));function s_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(Xe,{size:26}),title:"Examples & doctests",meta:"About 40 minutes · adoption",onBack:e,assistKey:"examples"}),t.jsxs("p",{className:"lead",children:["Reference docs say what each function does; ",t.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."]}),t.jsx("div",{className:"seclabel",children:"What to ship"}),t.jsxs(Se,{children:[t.jsxs($,{lead:"Runnable examples, not snippets in a README.",children:["Put complete programs in an ",t.jsx("code",{children:"examples/"})," directory that build and run as-is (",t.jsx("code",{children:"cargo run --example quickstart"}),"). A snippet a user has to assemble themselves is a snippet that's subtly wrong."]}),t.jsx($,{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."}),t.jsxs($,{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 (",t.jsx("code",{children:"cargo test --doc"}),", Python's"," ",t.jsx("code",{children:"doctest"}),"). It means the snippet in your reference can't silently rot — if the API changes, the doctest fails CI."]}),t.jsxs($,{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 ",t.jsx("code",{children:"examples/"})," and run the doctests on every commit so a broken one fails the build."]})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"examples/ directory"}),t.jsx("span",{className:"chip",children:"One-minute quickstart"}),t.jsx("span",{className:"chip",children:"Doctests run in CI"})]}),t.jsx(Pe,{assistKey:"examples",topicName:"Examples & doctests"}),t.jsx(Re,{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.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:e})]})}const PZ=Object.freeze(Object.defineProperty({__proto__:null,ExamplesScreen:s_},Symbol.toStringTag,{value:"Module"}));function r_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(Xe,{size:26}),title:"API docs",meta:"Foundation · about 30 minutes",onBack:e,assistKey:"api-docs"}),t.jsxs("p",{className:"lead",children:["For a library, the public API ",t.jsx("i",{children:"is"})," the product — so its reference docs matter as much as the code. The trick is to"," ",t.jsx("b",{children:"generate docs from the source"}),", so they can't drift out of date."]}),t.jsx("div",{className:"seclabel",children:"Generate, don't hand-write"}),t.jsxs(Se,{children:[t.jsx($,{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."}),t.jsxs($,{lead:"A generator for your language.",children:[t.jsx("code",{children:"docs.rs"})," for Rust, ",t.jsx("code",{children:"TypeDoc"})," for TypeScript,"," ",t.jsx("code",{children:"Sphinx"})," (or the more modern"," ",t.jsx("code",{children:"MkDocs + mkdocstrings"}),") for Python — each reads your source and produces a browsable site."]}),t.jsx($,{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."})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"docs.rs · TypeDoc · Sphinx"}),t.jsx("span",{className:"chip",children:"From doc comments"}),t.jsx("span",{className:"chip",children:"Auto-built on publish"})]}),t.jsx(Pe,{assistKey:"api-docs",topicName:"API docs"}),t.jsx(Re,{label:"My API docs are published",note:"Because they're generated from source, the docs refresh themselves on every release.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:e})]})}const OZ=Object.freeze(Object.defineProperty({__proto__:null,ApiDocsScreen:r_},Symbol.toStringTag,{value:"Module"})),w4={key:"api-docs",Icon:Xe,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 a_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Nt,{config:w4,onBack:e,onComplete:n,status:s,onRevert:r})}const RZ=Object.freeze(Object.defineProperty({__proto__:null,BackendApiDocsScreen:a_},Symbol.toStringTag,{value:"Module"}));function o_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(Xe,{size:26}),title:"Versioning policy",meta:"About 20 minutes · a decision",onBack:e,assistKey:"semver-policy"}),t.jsxs("p",{className:"lead",children:["Other people's code depends on yours. A breaking change you ship quietly breaks their builds. A written ",t.jsx("b",{children:"versioning policy"})," is the promise that makes your library safe to depend on."]}),t.jsx("div",{className:"seclabel",children:"Decide and write down"}),t.jsxs(Se,{children:[t.jsx($,{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."}),t.jsx($,{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)."}),t.jsx($,{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."}),t.jsxs($,{lead:"Let a tool catch breaks for you.",children:["You don't have to spot every breaking change by eye:"," ",t.jsx("code",{children:"cargo-semver-checks"})," (Rust) and"," ",t.jsx("code",{children:"api-extractor"})," (TypeScript) diff your public API against the last release and fail CI when a change needs a MAJOR bump."]})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"Public API = the contract"}),t.jsx("span",{className:"chip",children:"Breaking → MAJOR"}),t.jsx("span",{className:"chip",children:"Deprecate before removing"})]}),t.jsx(Pe,{assistKey:"semver-policy",topicName:"Versioning policy"}),t.jsx(Re,{label:"My versioning policy is set",note:"Write it in the README once; it guides every release decision afterward.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:e})]})}const EZ=Object.freeze(Object.defineProperty({__proto__:null,SemverPolicyScreen:o_},Symbol.toStringTag,{value:"Module"}));function i_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(Xe,{size:26}),title:"Readme & license",meta:"About 30 minutes",onBack:e,assistKey:"readme-license"}),t.jsxs("p",{className:"lead",children:["Two files decide whether someone adopts your library: the"," ",t.jsx("b",{children:"README"})," tells them what it does, and the ",t.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.`]}),t.jsx("div",{className:"seclabel",children:"A README that earns trust"}),t.jsxs(Se,{children:[t.jsx($,{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."}),t.jsx($,{lead:"Install + a minimal example.",children:'The fastest path from "interested" to "it works on my machine".'})]}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Pick a license"}),t.jsxs(Se,{children:[t.jsx($,{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."}),t.jsxs($,{lead:"Library copyleft (LGPL, MPL-2.0) — share changes, not callers.",children:["For a library, the relevant copyleft is ",t.jsx("b",{children:"LGPL"})," or"," ",t.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 ",t.jsx("b",{children:"GPL"})," forces every consumer to be GPL too, which usually kills adoption for a library — reach for it only on purpose."]})]}),t.jsx(Se,{children:t.jsxs($,{lead:"Declare the license in your package manifest, too.",children:["A LICENSE file alone isn't enough — set the ",t.jsx("code",{children:"license"})," field in your manifest (",t.jsx("code",{children:"Cargo.toml"}),", ",t.jsx("code",{children:"package.json"}),","," ",t.jsx("code",{children:"pyproject.toml"}),") so the registry detects and displays it on the package page."]})}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"README first line"}),t.jsx("span",{className:"chip",children:"LICENSE file + manifest field"}),t.jsx("span",{className:"chip",children:"MIT · Apache-2.0 · LGPL/MPL"})]}),t.jsx(Pe,{assistKey:"readme-license",topicName:"Readme & license"}),t.jsx(Re,{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.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:e})]})}const AZ=Object.freeze(Object.defineProperty({__proto__:null,ReadmeLicenseScreen:i_},Symbol.toStringTag,{value:"Module"}));function l_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(Qt,{size:26}),title:"Changelog & CI",meta:"About 40 minutes · automation",onBack:e,assistKey:"changelog-ci"}),t.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."}),t.jsx(Yd,{}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Automate the release"}),t.jsxs(Se,{children:[t.jsx($,{lead:"CI runs tests on every change.",children:"A green pipeline is the precondition for any release — no publishing from an untested commit."}),t.jsxs($,{lead:"A tag triggers publish.",children:["Pushing ",t.jsx("code",{children:"v1.2.0"})," runs the release job: test, build, and publish to the registry. The version published always matches the tag."]}),t.jsxs($,{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 (",t.jsx("code",{children:"CARGO_REGISTRY_TOKEN"}),","," ",t.jsx("code",{children:"NPM_TOKEN"}),"). The current best practice is"," ",t.jsx("b",{children:"OIDC trusted publishing"}),": ",Te("registry.oidc").value,"."," ",t.jsx(Yn,{fact:Te("registry.oidc")})]})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"CHANGELOG.md"}),t.jsx("span",{className:"chip",children:"Tests on every push"}),t.jsx("span",{className:"chip",children:"Tag → publish"}),t.jsx("span",{className:"chip",children:"OIDC or token"})]}),t.jsx(Pe,{assistKey:"changelog-ci",topicName:"Changelog & CI"}),t.jsx(Re,{label:"My changelog & CI are set up",note:"Once the pipeline exists, releasing is just pushing a tag — the rest runs itself.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:e})]})}const MZ=Object.freeze(Object.defineProperty({__proto__:null,ChangelogCiScreen:l_},Symbol.toStringTag,{value:"Module"})),_4=Te("flyio.pricing"),S4={key:"deploy-target",connector:{provider:"render"},Icon:is,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:_4.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 c_({onBack:e,onComplete:n,onRevert:s}){return t.jsx(Hr,{config:S4,onBack:e,onComplete:n,onRevert:s})}const IZ=Object.freeze(Object.defineProperty({__proto__:null,DeployTargetScreen:c_},Symbol.toStringTag,{value:"Module"})),k4={key:"database-backups",Icon:Wr,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 d_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Nt,{config:k4,onBack:e,onComplete:n,status:s,onRevert:r})}const DZ=Object.freeze(Object.defineProperty({__proto__:null,DatabaseBackupsScreen:d_},Symbol.toStringTag,{value:"Module"}));function N4(){const[e,n]=l.useState(null);return l.useEffect(()=>{let s=!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();s||n(a)}catch{s||n(null)}})(),()=>{s=!0}},[]),{env:e}}const C4={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 u_(e,n){const s=[...e,...n];return s.length===0?C4:{heading:"This project's secrets",bullets:s.map(r=>({lead:`${r} —`,text:n.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 p_(e,n){return{key:"secrets",Icon:et,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:[u_(e,n),{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 h_({onBack:e,onComplete:n,status:s,onRevert:r}){const{env:a}=N4(),o=p_((a==null?void 0:a.envKeys)??[],(a==null?void 0:a.serviceEnvVars)??[]);return t.jsx(Nt,{config:o,onBack:e,onComplete:n,status:s,onRevert:r})}const LZ=Object.freeze(Object.defineProperty({__proto__:null,SecretsScreen:h_,buildConfig:p_,secretsSection:u_},Symbol.toStringTag,{value:"Module"})),T4={key:"api-auth",Icon:et,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 f_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Nt,{config:T4,onBack:e,onComplete:n,status:s,onRevert:r})}const FZ=Object.freeze(Object.defineProperty({__proto__:null,ApiAuthScreen:f_},Symbol.toStringTag,{value:"Module"})),P4={key:"cors-origins",Icon:Wn,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 m_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Nt,{config:P4,onBack:e,onComplete:n,status:s,onRevert:r})}const $Z=Object.freeze(Object.defineProperty({__proto__:null,CorsOriginsScreen:m_},Symbol.toStringTag,{value:"Module"})),O4={key:"background-jobs",Icon:ot,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 g_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Nt,{config:O4,onBack:e,onComplete:n,status:s,onRevert:r})}const zZ=Object.freeze(Object.defineProperty({__proto__:null,BackgroundJobsScreen:g_},Symbol.toStringTag,{value:"Module"})),R4={key:"logging-monitoring",Icon:Qt,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 x_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsx(Nt,{config:R4,onBack:e,onComplete:n,status:s,onRevert:r})}const BZ=Object.freeze(Object.defineProperty({__proto__:null,LoggingMonitoringScreen:x_},Symbol.toStringTag,{value:"Module"}));function Ml({onBack:e,onComplete:n,status:s,onRevert:r}){const a=[{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 t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(ot,{size:26}),title:"Staging & preview deploys",meta:"About 15 minutes · then automatic on every push",onBack:e,assistKey:"staging-preview"}),t.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."}),t.jsx("div",{className:"seclabel",children:"Per-branch preview deploys"}),t.jsxs(Se,{children:[t.jsxs($,{lead:"Get a URL for every branch or pull request.",children:["Hosts like ",t.jsx("b",{children:"Vercel"})," and ",t.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."]}),t.jsx($,{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."})]}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"A shared staging environment"}),t.jsxs(Se,{children:[t.jsx($,{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."}),t.jsx($,{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."})]}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Share it privately"}),t.jsxs(Se,{children:[t.jsx($,{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."}),t.jsx($,{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."})]}),t.jsx(yt,{items:a}),t.jsx(Pe,{assistKey:"staging-preview",topicName:"Staging & preview deploys"}),t.jsx(Re,{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.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:e})]})}const WZ=Object.freeze(Object.defineProperty({__proto__:null,StagingPreviewScreen:Ml},Symbol.toStringTag,{value:"Module"}));function b_({onBack:e,onComplete:n,status:s,onRevert:r}){const a=[{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 t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(ot,{size:26}),title:"Staging environment",meta:"About 30 minutes · a one-time environment to stand up",onBack:e,assistKey:"staging-environment"}),t.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."}),t.jsx("div",{className:"seclabel",children:"Make it prod-like, but isolated"}),t.jsxs(Se,{children:[t.jsx($,{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."}),t.jsx($,{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."})]}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Rehearse the risky parts"}),t.jsxs(Se,{children:[t.jsx($,{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."}),t.jsx($,{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."})]}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Promote to production"}),t.jsx(Se,{children:t.jsx($,{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."})}),t.jsx(yt,{items:a}),t.jsx(Pe,{assistKey:"staging-environment",topicName:"Staging environment"}),t.jsx(Re,{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.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:e})]})}const HZ=Object.freeze(Object.defineProperty({__proto__:null,StagingEnvironmentScreen:b_},Symbol.toStringTag,{value:"Module"}));function Il({onBack:e,onComplete:n,status:s,onRevert:r}){const a=[{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 t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(ot,{size:26}),title:"Pre-release channel",meta:"About 15 minutes · then one extra command per pre-release",onBack:e,assistKey:"pre-release-channel"}),t.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 ",t.jsx("code",{children:"latest"})," stays exactly where it is until you're ready to promote."]}),t.jsx("div",{className:"seclabel",children:"Publish on a separate channel"}),t.jsxs(Se,{children:[t.jsxs($,{lead:"Use a next / beta tag instead of latest.",children:["Publish the pre-release under a dist-tag like ",t.jsx("code",{children:"next"})," or"," ",t.jsx("code",{children:"beta"})," (npm), a ",t.jsx("code",{children:"--pre"})," flag on other registries, or a GitHub ",t.jsx("b",{children:"pre-release"})," for binaries. A normal install still resolves ",t.jsx("code",{children:"latest"}),", so the default install is untouched."]}),t.jsxs($,{lead:"Tag a semver pre-release version.",children:["Version it with a pre-release identifier — ",t.jsx("code",{children:"1.2.0-rc.1"}),","," ",t.jsx("code",{children:"1.2.0-beta.2"}),". Semver excludes these from ordinary version ranges, so a dependent on ",t.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."]})]}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Let testers opt in"}),t.jsxs(Se,{children:[t.jsxs($,{lead:"Tell testers the one install command.",children:["A tester installs the channel explicitly — ",t.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."]}),t.jsx($,{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."})]}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Promote to stable"}),t.jsx(Se,{children:t.jsxs($,{lead:"Cut the stable version when it holds up.",children:["Drop the pre-release suffix (",t.jsx("code",{children:"1.2.0-rc.1"})," →"," ",t.jsx("code",{children:"1.2.0"}),") and publish it to ",t.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."]})}),t.jsx(yt,{items:a}),t.jsx(Pe,{assistKey:"pre-release-channel",topicName:"Pre-release channel"}),t.jsx(Re,{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.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:e})]})}const qZ=Object.freeze(Object.defineProperty({__proto__:null,PreReleaseScreen:Il},Symbol.toStringTag,{value:"Module"}));function Ee(e,n){return["You are helping inside my actual codeyam project — this is real work in a real repository, not a hypothetical.","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.","",`I want to set up **${e}**. ${n}`,"","Walk me through it and make the changes you safely can in my project, asking me before anything destructive."].join(`
|
|
50
|
+
`)}const E4={"staging-preview":{Icon:ot,title:"Staging & preview deploys",crumbLabel:"Staging & previews",meta:"Recommended · about 5 minutes",lead:"Get a private link for every change before it goes public. You (or a teammate) can open the app exactly as it will ship, try it, and share it for feedback — without touching what real visitors see.",journey:[{emoji:"🧪",label:"A change",sub:"Not public yet"},{emoji:"🔗",label:"Preview link",sub:"Share and try it",lime:!0},{emoji:"🚀",label:"Ship it",sub:"Only once it's right"}],chatPrompt:Ee("staging & preview deploys","I want a private preview URL for each change and a staging environment I can share before anything goes public."),faqs:[{q:"How is a preview different from the live app?",a:"A preview is a private copy of one specific change, at its own link. Real visitors never see it — you use it to check and share a change before it becomes the live app everyone sees."},{q:"Do I need a separate staging environment too?",a:"A per-change preview covers most feedback. A longer-lived staging environment is useful when you want a stable, shareable place that mirrors production for testing over time — you can have both."},{q:"Will previews affect real data?",a:"No. Previews are isolated, so trying things in one can't change what real visitors see or the data they rely on."}]},"custom-domain":{Icon:Wn,title:"Custom domain",meta:"Optional · about 10 minutes",lead:"Put your app on your own web address instead of the default link. Visitors see a name that's yours — easier to remember, trust, and share.",journey:[{emoji:"🔗",label:"Default link",sub:"Works, but generic"},{emoji:"🌐",label:"Your domain",sub:"yourname.com",lime:!0},{emoji:"🤝",label:"People trust it",sub:"Easy to remember"}],chatPrompt:Ee("a custom domain","I want my app to live on my own web address. Help me point a domain I own (or pick one) at my app and set it up so it loads securely."),faqs:[{q:"Do I need to buy a domain first?",a:"Yes — you register the name you want with any domain registrar (usually a few dollars a year). After that, you point it at your app once and it's live on your address."},{q:"Is it secure (https)?",a:"Yes. A security certificate is set up for your domain automatically, so visitors get the padlock and an encrypted connection with nothing to manage."},{q:"Can I keep the old link too?",a:"Yes. The default link keeps working; your custom domain is an additional, friendlier front door."}]},accounts:{Icon:et,title:"Accounts & sign-in",meta:"Foundation · about 10 minutes",lead:"Let people create an account and sign in safely, so the app can remember who they are and keep each person's things private to them.",journey:[{emoji:"🙋",label:"A visitor",sub:"Anonymous"},{emoji:"🔑",label:"Signs in",sub:"Safely, once",lime:!0},{emoji:"🗂️",label:"Their own space",sub:"Private to them"}],chatPrompt:Ee("accounts & sign-in","I want people to be able to sign up and log in securely, so the app knows who each person is and keeps their data private."),faqs:[{q:"Do I have to handle passwords myself?",a:"No. Sign-in is handled by a trusted service, so passwords are stored and checked securely for you — you never keep raw passwords, and you can offer options like email links or Google sign-in."},{q:"How does the app keep one person's data private?",a:"Once someone signs in, the app knows which records are theirs and only shows those. Access rules enforce it, so one person can never see another's information."},{q:"Can people sign in with Google or email?",a:"Yes. You can offer several ways to sign in — email link, password, or providers like Google — and add more later without changing the rest of the app."}]},emails:{Icon:Hs,title:"Sending emails",meta:"Recommended · about 5 minutes",lead:"Send the everyday emails an app needs — a welcome, a password reset, a receipt — reliably, so they land in the inbox instead of spam.",journey:[{emoji:"⚡",label:"Something happens",sub:"A signup, a reset"},{emoji:"✉️",label:"An email is sent",sub:"Automatically",lime:!0},{emoji:"📥",label:"In their inbox",sub:"Not spam"}],chatPrompt:Ee("sending emails","I want my app to send transactional emails (welcome, password reset, receipts) reliably so they reach the inbox."),faqs:[{q:"Why not just send email from my own server?",a:"Mail sent that way usually lands in spam. A dedicated sending service builds the reputation and authentication that gets your emails delivered to the inbox."},{q:"What emails will my app actually send?",a:"The common ones: a welcome or verification message, password resets, and receipts or notifications. You add more as your app grows."},{q:"Can I design how the emails look?",a:"Yes. Emails use templates you can style to match your app, with the person's details filled in automatically."}]},payments:{Icon:kn,title:"Accept payments",meta:"Optional · about 15 minutes",lead:"Charge for your product or service safely. People pay with a card and the money reaches you — you never handle or store card numbers yourself.",journey:[{emoji:"🛒",label:"They want to buy",sub:"Product or plan"},{emoji:"💳",label:"Pay securely",sub:"Card handled for you",lime:!0},{emoji:"💰",label:"You get paid",sub:"Money reaches you"}],chatPrompt:Ee("accepting payments","I want to charge for my product or service — one-off payments or subscriptions — with card details handled securely by a payment provider."),faqs:[{q:"Is it safe to take card payments?",a:"Yes. A payment provider collects and stores the card details on secure, certified systems. Your app never sees or stores a card number, which keeps you safe and compliant."},{q:"One-off payments or subscriptions?",a:"Both. You can charge once for a purchase or set up recurring subscriptions — the provider handles renewals, receipts, and failed-payment retries."},{q:"What does it cost?",a:"Providers take a small percentage per transaction with no monthly fee to start, so you only pay when you actually get paid."}]},"analytics-monitoring":{Icon:Qt,title:"Analytics & monitoring",crumbLabel:"Analytics",meta:"Recommended · about 5 minutes",lead:"See how people use your app and catch errors early. Instead of guessing, you get simple numbers on what's used — and an alert when something breaks.",journey:[{emoji:"👀",label:"People use the app",sub:"Every day"},{emoji:"📊",label:"You see what happens",sub:"Usage and errors",lime:!0},{emoji:"🛠️",label:"Fix it early",sub:"Before it spreads"}],chatPrompt:Ee("analytics & monitoring","I want to see how people use my app and get alerted when errors happen, so I can catch problems early."),faqs:[{q:"What's the difference between analytics and monitoring?",a:"Analytics tells you what people do — which pages and features they use. Monitoring watches for errors and slowdowns and alerts you when something breaks. You usually want both."},{q:"Is this respectful of privacy?",a:"You can use privacy-friendly analytics that measure usage without tracking individuals, and keep error reports free of personal data. It's about patterns, not spying."},{q:"Will it slow my app down?",a:"No. These tools are lightweight and load in the background, so visitors don't notice them."}]},"database-backups":{Icon:Mt,title:"Data backups & deletion",crumbLabel:"Backups & deletion",meta:"Recommended · about 10 minutes",lead:"Keep safe copies of your data so nothing is lost, and be able to honor a person's request to export or delete their information.",journey:[{emoji:"🗄️",label:"Your data",sub:"The real thing"},{emoji:"💾",label:"Backed up",sub:"Safe copies",lime:!0},{emoji:"♻️",label:"Restore or delete",sub:"On request"}],chatPrompt:Ee("data backups & deletion","I want regular backups of my data plus a way to export or delete a person's information when they ask (GDPR/CCPA)."),faqs:[{q:"How often should I back up?",a:"Automatic daily backups cover most apps, with the ability to restore to a recent point if something goes wrong. Keep your own periodic export too, especially on free tiers."},{q:"Why do I need export and delete?",a:"Privacy laws like GDPR and CCPA give people the right to get a copy of their data or have it deleted. Being able to honor those requests keeps you compliant and trustworthy."},{q:"Does deleting one person's data break anything?",a:"Handled properly, no. Their records are removed while shared data stays intact, so the app keeps working for everyone else."}]},legal:{Icon:Xe,title:"Privacy & legal",meta:"Recommended · about 10 minutes",lead:"Give your app the basics it needs to be trustworthy and above-board: a privacy policy and terms, written in plain language, that say what you collect and how you use it.",journey:[{emoji:"❓",label:"What do you collect?",sub:"People wonder"},{emoji:"📄",label:"Privacy & terms",sub:"Clear answers",lime:!0},{emoji:"✅",label:"Trusted & compliant",sub:"Above board"}],chatPrompt:Ee("privacy & legal","I want a plain-language privacy policy and terms of service that match what my app actually collects and does."),faqs:[{q:"Do I really need a privacy policy?",a:"If your app collects any personal data — even just emails — most laws and app stores require one. It also builds trust by being upfront about what you do with people's information."},{q:"Can I just copy someone else's?",a:"It's better to generate one that matches what your app actually collects and uses. A copied policy that doesn't fit your app can be misleading and legally risky."},{q:"Is this legal advice?",a:"No — these are sensible defaults to get you started. For anything high-stakes, have a professional review the final wording."}]},forms:{Icon:Xe,title:"Forms",meta:"Optional · about 5 minutes",lead:"Collect what people type — a contact message, a signup, feedback — and make sure it actually reaches you, cleanly and without spam.",journey:[{emoji:"⌨️",label:"They fill it in",sub:"A message, a signup"},{emoji:"📨",label:"It reaches you",sub:"Clean, no spam",lime:!0},{emoji:"📬",label:"You follow up",sub:"Nothing lost"}],chatPrompt:Ee("forms","I want the forms in my app (contact, signup, feedback) to reliably deliver what people submit to me, with basic validation and spam protection."),faqs:[{q:"Where do form submissions go?",a:"You choose — an email to you, a saved record, or both. The important part is that nothing gets silently dropped."},{q:"How do I keep out spam?",a:"Basic protection like a hidden check or a light challenge blocks most automated spam without annoying real people."},{q:"Can I require certain fields?",a:"Yes. Validation makes sure required fields are filled and formatted correctly before a submission goes through, so you get usable information."}]},"data-safety":{Icon:et,title:"Data safety",meta:"Recommended · about 10 minutes",lead:"Be clear and careful about the information your app handles: collect only what you need, keep it protected, and be able to explain exactly what you store and why.",journey:[{emoji:"📥",label:"You collect data",sub:"Only what's needed"},{emoji:"🔒",label:"Kept protected",sub:"Access controlled",lime:!0},{emoji:"📋",label:"Explained clearly",sub:"Nothing hidden"}],chatPrompt:Ee("data safety","I want to review what personal data my app collects and stores, minimize it, protect it, and be able to declare it clearly (e.g. for an app store data-safety form)."),faqs:[{q:"What counts as sensitive data?",a:"Anything that identifies a person — names, emails, location, payment details — plus anything private they share. The safest rule is to collect only what your app truly needs."},{q:"Why declare what I collect?",a:"App stores and privacy laws expect an honest summary of what you collect and why. A clear declaration builds trust and avoids removal or fines."},{q:"How is the data protected?",a:"It's encrypted in transit and at rest, and access rules limit who and what can read it — so even stored data isn't freely readable."}]},secrets:{Icon:et,title:"Secrets & API keys",crumbLabel:"Secrets",meta:"Foundation · about 5 minutes",lead:"Keep the keys and passwords your app depends on out of the code and in a safe place, so they're never exposed and easy to rotate.",journey:[{emoji:"🔑",label:"Keys & passwords",sub:"Your app needs them"},{emoji:"🗝️",label:"In a safe store",sub:"Never in code",lime:!0},{emoji:"🔄",label:"Easy to rotate",sub:"One place to change"}],chatPrompt:Ee("secrets & API keys","I want my app's secrets (API keys, tokens, passwords) kept out of the code in a secure store, and easy to rotate."),faqs:[{q:"Why can't I just put keys in the code?",a:"Anything in the code can leak — through your repository, your build, or the browser. Secrets belong in a separate secure store the app reads at runtime, never in the source."},{q:"What is 'rotating' a key?",a:"Replacing a secret with a fresh one — routine hygiene, or urgent if one leaks. When secrets live in one store, rotating is a single change with no code edit."},{q:"Do different environments need different keys?",a:"Usually yes. Test and production use separate keys so a mistake in testing can't touch real data or real charges."}]},publish:{Icon:ot,title:"Publish & go live",meta:"Foundation · about 10 minutes",lead:"Take your app from running only on your machine to a real link anyone can open. You don't need to understand servers — it's set up for you.",journey:[{emoji:"💻",label:"Your computer",sub:"Only you can see it"},{emoji:"☁️",label:"Published",sub:"A home online",lime:!0},{emoji:"🌍",label:"Anyone, anywhere",sub:"Opens with a link"}],chatPrompt:Ee("publishing my app","I want to put my app online so anyone can open it with a link."),faqs:[{q:"Do I need to understand servers?",a:"No. Publishing is handled for you — you connect a host once and your app goes live on a link, with nothing to run or maintain yourself."},{q:"Is there a cost to publish?",a:"You can start on a free tier that comfortably covers a new app. You only pay once it grows, and you'll see it coming."},{q:"Can I use my own web address?",a:"Yes. You launch on a free link today and can add a custom domain whenever you like."}]},"analytics-seo":{Icon:Wn,title:"Analytics & SEO",meta:"Recommended · about 10 minutes",lead:"Help people find your app and understand what they do once they arrive. Good SEO gets you into search results; analytics shows you what's working.",journey:[{emoji:"🔎",label:"People search",sub:"For what you offer"},{emoji:"📈",label:"Found & measured",sub:"Ranked and tracked",lime:!0},{emoji:"🎯",label:"You improve",sub:"Based on real data"}],chatPrompt:Ee("analytics & SEO","I want my app to show up well in search results and to see how visitors find and use it."),faqs:[{q:"What actually helps SEO?",a:"Clear titles and descriptions, fast pages, sensible links, and a sitemap search engines can read. Most of it is set-and-forget once configured."},{q:"How is this different from analytics-only?",a:"SEO is about being found; analytics is about understanding what happens after. Together they close the loop from discovery to improvement."},{q:"Can I do this privately?",a:"Yes. Privacy-friendly analytics measure traffic and behavior in aggregate without tracking individuals."}]},"comments-search":{Icon:Mt,title:"Comments & search",meta:"Optional · about 15 minutes",lead:"Let people discuss your content and find things quickly. Comments add a conversation; search helps visitors get to what they want in seconds.",journey:[{emoji:"📚",label:"Lots of content",sub:"Hard to navigate"},{emoji:"🔍",label:"Search & comments",sub:"Find and discuss",lime:!0},{emoji:"💬",label:"People engage",sub:"And stick around"}],chatPrompt:Ee("comments & search","I want visitors to be able to search my content and leave comments."),faqs:[{q:"Do I have to build search myself?",a:"No. A search service indexes your content and returns fast, typo-tolerant results, which is far better than a hand-rolled search."},{q:"How do I keep comments civil?",a:"You can require sign-in, add moderation, and filter spam, so the conversation stays useful without constant babysitting."},{q:"Will search slow my app down?",a:"No. Search runs on a dedicated service, so results are fast even as your content grows."}]},"performance-images":{Icon:ot,title:"Performance & images",crumbLabel:"Performance",meta:"Recommended · about 10 minutes",lead:"Make your app fast, especially its images. Faster pages feel better, keep people around, and rank higher — and images are usually the biggest win.",journey:[{emoji:"🐌",label:"Heavy pages",sub:"Slow to load"},{emoji:"🗜️",label:"Optimized",sub:"Right-sized images",lime:!0},{emoji:"⚡",label:"Fast for everyone",sub:"On any device"}],chatPrompt:Ee("performance & images","I want my app to load fast — especially by optimizing and right-sizing images and cutting anything that slows pages down."),faqs:[{q:"Why are images such a big deal?",a:"Images are usually the heaviest thing on a page. Right-sizing and compressing them, and loading them only when needed, is the single biggest speed win."},{q:"How do I know if my app is slow?",a:"A quick performance check gives you a score plus a prioritized list of fixes. Aim for the green range; chasing a perfect score rarely matters."},{q:"Will optimizing hurt image quality?",a:"No, when done right. Modern formats keep images looking sharp at a fraction of the size."}]},"background-jobs":{Icon:Mt,title:"Background jobs",meta:"Optional · about 15 minutes",lead:"Do slow or scheduled work out of the way of the person waiting — sending a batch of emails, resizing uploads, running a nightly task — so the app stays snappy.",journey:[{emoji:"⏳",label:"Slow work",sub:"Blocks the user"},{emoji:"📮",label:"Queued",sub:"Runs in the background",lime:!0},{emoji:"✅",label:"Done later",sub:"App stays fast"}],chatPrompt:Ee("background jobs","I want to run slow or scheduled work (emails, image processing, nightly tasks) in the background so requests stay fast."),faqs:[{q:"When do I need background jobs?",a:"Whenever work takes more than a moment — sending many emails, processing files, or anything on a schedule. Doing it inline makes people wait or times out."},{q:"What if a job fails?",a:"A queue retries failed jobs and keeps a record, so a temporary hiccup doesn't silently drop work."},{q:"Can I run tasks on a schedule?",a:"Yes. You can run jobs at set times — nightly cleanups, weekly digests — without anyone triggering them."}]},"logging-monitoring":{Icon:Qt,title:"Logging & monitoring",crumbLabel:"Logging",meta:"Recommended · about 10 minutes",lead:"Know what your app is doing and hear about problems fast. Logs record what happened; monitoring alerts you when something breaks or slows down.",journey:[{emoji:"🌫️",label:"Something breaks",sub:"You don't know"},{emoji:"📡",label:"Logged & watched",sub:"Alerts you fast",lime:!0},{emoji:"🔧",label:"You fix it",sub:"Before users notice"}],chatPrompt:Ee("logging & monitoring","I want centralized logs and alerts so I hear about errors and slowdowns quickly and can trace what happened."),faqs:[{q:"Aren't logs just noise?",a:"Structured logs, searchable in one place, turn noise into answers — you can trace exactly what happened around an error instead of guessing."},{q:"What should alert me?",a:"Errors, crashes, and unusual slowness. Good alerting tells you about real problems without crying wolf."},{q:"Does this expose user data?",a:"It shouldn't. Logs are set up to avoid capturing personal or secret data, so they're safe to keep and search."}]},"cors-origins":{Icon:Wn,title:"CORS & allowed origins",crumbLabel:"CORS",meta:"Foundation · about 5 minutes",lead:"Decide which websites are allowed to call your app's API. Set it too open and anyone can use your backend; too strict and your own site breaks.",journey:[{emoji:"🌐",label:"Requests arrive",sub:"From many sites"},{emoji:"🚦",label:"Origins checked",sub:"Allow the right ones",lime:!0},{emoji:"🛡️",label:"Safe & working",sub:"Your site only"}],chatPrompt:Ee("CORS & allowed origins","I want to configure which origins are allowed to call my API — permissive enough for my own site, strict enough to keep others out."),faqs:[{q:"What is an 'origin'?",a:"The website an API request comes from. CORS rules say which origins your API will answer, so only your app (and any you approve) can use it from a browser."},{q:"Why not just allow everything?",a:"Allowing every origin lets any site call your API from a user's browser, which can be abused. Listing the ones you actually use is safer."},{q:"My site's requests are being blocked — why?",a:"Usually the origin isn't on the allow list, or a preflight check isn't handled. Adding your origin and allowing the right methods fixes it."}]},"api-auth":{Icon:et,title:"API authentication",crumbLabel:"API auth",meta:"Foundation · about 10 minutes",lead:"Make sure only the right callers can use your API. Each request proves who it is with a key or token, so your backend isn't open to the world.",journey:[{emoji:"📨",label:"A request",sub:"Who's calling?"},{emoji:"🎟️",label:"Proves identity",sub:"Key or token",lime:!0},{emoji:"✅",label:"Allowed in",sub:"Only if valid"}],chatPrompt:Ee("API authentication","I want my API to require a key or token so only authorized callers can use it, with a safe way to issue and revoke access."),faqs:[{q:"Keys or tokens — what's the difference?",a:"An API key is a simple secret for server-to-server use. Tokens (like JWTs) carry identity and expire, which fits user-facing apps. Many APIs use both."},{q:"How do I revoke access?",a:"Issue credentials you can turn off individually, so if one leaks you disable just that key without affecting everyone else."},{q:"Is an API key enough on its own?",a:"For internal use, often yes. For sensitive actions, combine it with per-user permissions so a valid key can't do more than it should."}]},"deploy-target":{Icon:is,title:"Deploy target",meta:"Foundation · about 10 minutes",lead:"Choose where your app runs when it's live and wire it up once. After that, shipping an update is a single, repeatable step.",journey:[{emoji:"📦",label:"Your app",sub:"Ready to ship"},{emoji:"🎯",label:"A deploy target",sub:"Where it runs",lime:!0},{emoji:"🔁",label:"Ship anytime",sub:"One repeatable step"}],chatPrompt:Ee("a deploy target","I want to pick where my app runs in production for my stack and set up a repeatable way to deploy to it."),faqs:[{q:"How do I pick a target?",a:"It depends on your stack — some hosts specialize in certain frameworks or containers. The goal is a place that runs your app well with the least setup."},{q:"What makes deploys repeatable?",a:"Wiring the target once so every deploy runs the same build and release steps, which removes surprises and lets you ship confidently."},{q:"Can I move hosts later?",a:"Yes, especially if your app is packaged in a standard way. Choosing a portable setup keeps your options open."}]},"deploy-previews":{Icon:ot,title:"Deploy previews",meta:"Recommended · about 5 minutes",lead:"Get a private link for every change before it's public, so you can see the site exactly as it will ship and share it for feedback.",journey:[{emoji:"✏️",label:"A change",sub:"Not public yet"},{emoji:"🔗",label:"Preview link",sub:"See it live",lime:!0},{emoji:"🚀",label:"Publish",sub:"Once it's right"}],chatPrompt:Ee("deploy previews","I want a private preview link generated for each change so I can review and share the site before it goes public."),faqs:[{q:"How is a preview different from the live site?",a:"A preview is a private build of one change at its own link. Visitors never see it — it's for checking and sharing before it becomes the public site."},{q:"Do previews cost extra?",a:"Usually they're included with hosting and clean themselves up, so you get the safety net without ongoing cost or clutter."},{q:"Can I share a preview with a client?",a:"Yes. Send the preview link and they see the exact change, with no effect on the live site."}]},"staging-environment":{Icon:is,title:"Staging environment",crumbLabel:"Staging",meta:"Recommended · about 15 minutes",lead:"A full, prod-like copy of your app with its own data, where you can rehearse changes and migrations safely before promoting them to production.",journey:[{emoji:"🧱",label:"A real change",sub:"Risky in prod"},{emoji:"🏗️",label:"Try it in staging",sub:"Prod-like, own data",lime:!0},{emoji:"⬆️",label:"Promote",sub:"Confidently to prod"}],chatPrompt:Ee("a staging environment","I want a production-like staging environment with its own data where I can rehearse changes and migrations before promoting to production."),faqs:[{q:"How is staging different from a preview?",a:"A preview is a throwaway link for one change. Staging is a stable, long-lived environment that mirrors production — ideal for testing data migrations and integrations over time."},{q:"Does staging need its own data?",a:"Yes. Separate, realistic data lets you rehearse safely without touching real users' information."},{q:"What does 'promote' mean?",a:"Moving a verified change from staging to production in a controlled step, so what you tested is exactly what ships."}]},"publish-registry":{Icon:Mt,title:"Publish to a registry",crumbLabel:"Publish package",meta:"Foundation · about 10 minutes",lead:"Make your package installable by others. Publishing to a registry means anyone can add it to their project with a single install command.",journey:[{emoji:"📦",label:"Your package",sub:"On your machine"},{emoji:"🏷️",label:"Published",sub:"To a registry",lime:!0},{emoji:"⬇️",label:"Others install it",sub:"One command"}],chatPrompt:Ee("publishing to a registry","I want to publish my package to the right registry for my ecosystem so others can install it, with sensible metadata and access set up."),faqs:[{q:"Which registry should I use?",a:"The standard one for your language or ecosystem, so people can install with the tool they already use. codeyam can pick the right one for your stack."},{q:"What metadata matters?",a:"A clear name, description, version, license, and links. Good metadata helps people find and trust your package."},{q:"Can I publish privately?",a:"Yes. Registries support private or scoped packages when you only want your team to install it."}]},"readme-license":{Icon:Xe,title:"README & license",meta:"Foundation · about 10 minutes",lead:"Give your project the two things every visitor looks for first: a README that explains what it is and how to use it, and a license that says what people may do with it.",journey:[{emoji:"❓",label:"What is this?",sub:"Visitors wonder"},{emoji:"📖",label:"README & license",sub:"Clear answers",lime:!0},{emoji:"🤝",label:"People use it",sub:"With confidence"}],chatPrompt:Ee("a README & license","I want a clear README that explains what my project is and how to use it, plus an appropriate open-source license."),faqs:[{q:"What should a README cover?",a:"What the project does, how to install and use it, a quick example, and where to get help. First-time visitors decide in seconds, so lead with the essentials."},{q:"Which license should I pick?",a:"It depends on how open you want to be. Permissive licenses let people do almost anything; copyleft ones require sharing changes. codeyam can suggest one for your goals."},{q:"Do I really need a license?",a:"Yes — without one, others legally can't reuse your code. A license removes that doubt and sets clear terms."}]},"semver-policy":{Icon:Mt,title:"Versioning policy",crumbLabel:"Versioning",meta:"Foundation · about 5 minutes",lead:"Number your releases so people know what to expect. A clear policy tells users when an update is safe and when it might break something.",journey:[{emoji:"🔢",label:"You release",sub:"Again and again"},{emoji:"📐",label:"Versioned clearly",sub:"Major.minor.patch",lime:!0},{emoji:"😌",label:"Users upgrade safely",sub:"No surprises"}],chatPrompt:Ee("a versioning policy","I want to adopt a clear version-numbering policy (like semver) so users know when an update is a safe fix versus a breaking change."),faqs:[{q:"What does major.minor.patch mean?",a:"Patch is a safe bug fix, minor adds features without breaking anything, and major may break existing use. The numbers set expectations at a glance."},{q:"When do I bump the major version?",a:"Only when you change or remove something people depend on. Reserving major bumps for real breaks keeps upgrades low-stress."},{q:"Do I have to follow semver exactly?",a:"It's the widely understood default, so following it means fewer surprises. You can adapt it, but document whatever policy you choose."}]},"versioning-changelog":{Icon:Xe,title:"Versioning & changelog",crumbLabel:"Changelog",meta:"Recommended · about 5 minutes",lead:"Keep a running list of what changed in each release, so users can see what's new, what's fixed, and what to watch out for before they upgrade.",journey:[{emoji:"🔁",label:"You ship changes",sub:"Every release"},{emoji:"📝",label:"Recorded",sub:"In a changelog",lime:!0},{emoji:"👀",label:"Users know",sub:"What changed & why"}],chatPrompt:Ee("a changelog","I want to maintain a clear changelog of what changes in each release so users can see what's new, fixed, or breaking."),faqs:[{q:"What goes in a changelog?",a:"Grouped notes per version — added, changed, fixed, and removed — written for the people who use your project, not raw commit messages."},{q:"Can it be generated automatically?",a:"Partly. Structured commits or release notes can draft the changelog for you; a human pass keeps it readable."},{q:"Why not just use commit history?",a:"Commits are for developers. A changelog is a curated, user-facing summary that's far easier to scan before upgrading."}]},"changelog-ci":{Icon:Xe,title:"Changelog & CI",meta:"Recommended · about 10 minutes",lead:"Automate the boring parts of releasing: let your pipeline build, test, and assemble release notes so shipping a version is reliable and repeatable.",journey:[{emoji:"🧑💻",label:"You merge a change",sub:"That's the trigger"},{emoji:"🤖",label:"CI runs",sub:"Build, test, notes",lime:!0},{emoji:"🚀",label:"Released",sub:"Reliably, every time"}],chatPrompt:Ee("changelog & CI","I want a CI pipeline that builds, tests, and helps assemble release notes so releasing a version is automated and reliable."),faqs:[{q:"What is CI, simply?",a:"Continuous integration: an automated pipeline that builds and tests every change, so problems are caught early and releases are consistent."},{q:"How does it help the changelog?",a:"CI can gather release notes from your changes and publish them alongside the build, so the changelog stays current without manual effort."},{q:"Is this overkill for a small project?",a:"Even a minimal pipeline that runs tests on every change pays off quickly by catching breakage before your users do."}]},"install-docs":{Icon:Xe,title:"Install & usage docs",crumbLabel:"Docs",meta:"Recommended · about 10 minutes",lead:"Show people how to install and use your project, with copy-paste steps and a working example. Good docs are the difference between adoption and abandonment.",journey:[{emoji:"🤔",label:"How do I use this?",sub:"Newcomers ask"},{emoji:"📘",label:"Clear docs",sub:"Install & examples",lime:!0},{emoji:"🚀",label:"Up and running",sub:"In minutes"}],chatPrompt:Ee("install & usage docs","I want clear installation and usage documentation with copy-paste steps and a working example so people can get started fast."),faqs:[{q:"What makes docs good?",a:"A fast path from zero to a working example, exact commands people can copy, and answers to the first questions they'll hit. Show, don't just tell."},{q:"How much is enough to start?",a:"Install, a minimal usage example, and one common task. You can expand as questions come in."},{q:"Where should docs live?",a:"Start in the README so they're the first thing visitors see; move to a docs site once there's more than a page or two."}]},examples:{Icon:Mt,title:"Examples",meta:"Optional · about 10 minutes",lead:"Give people runnable examples that show your project solving real tasks. A working sample teaches faster than paragraphs of explanation.",journey:[{emoji:"📄",label:"Just docs",sub:"Abstract"},{emoji:"🧩",label:"Runnable examples",sub:"Real tasks",lime:!0},{emoji:"💡",label:"It clicks",sub:"People get it fast"}],chatPrompt:Ee("examples","I want a set of runnable examples that show my project solving real tasks, so people learn it by seeing it work."),faqs:[{q:"How many examples do I need?",a:"A few that cover the most common uses beat a dozen niche ones. Start with the tasks people ask about most."},{q:"Should examples be runnable?",a:"Ideally yes — a sample people can run and tweak teaches far faster than a snippet they have to assemble themselves."},{q:"Where do examples belong?",a:"In an examples folder or a docs section, linked from the README so newcomers find them immediately."}]},"release-builds":{Icon:ot,title:"Release builds",meta:"Foundation · about 10 minutes",lead:"Turn your source into the finished artifacts people actually download and run — for each platform — in a repeatable, trustworthy way.",journey:[{emoji:"🧾",label:"Your source",sub:"Not yet packaged"},{emoji:"🏭",label:"Built for release",sub:"Every platform",lime:!0},{emoji:"⬇️",label:"People run it",sub:"Ready to download"}],chatPrompt:Ee("release builds","I want a repeatable way to produce release artifacts for each platform my project targets, ready for people to download and run."),faqs:[{q:"Why not just share the source?",a:"Most users want something ready to run, not to build it themselves. Release builds give them a finished artifact for their platform."},{q:"How do I build for multiple platforms?",a:"An automated pipeline can produce builds for each target in one go, so you don't need every platform on your own machine."},{q:"How do people trust a build?",a:"Publishing checksums or signatures lets people verify a download is genuine and unmodified."}]},"shell-completions":{Icon:Is,title:"Shell completions",crumbLabel:"Completions",meta:"Optional · about 5 minutes",lead:"Let your command-line tool autocomplete its own commands and options, so users tab through it instead of memorizing flags.",journey:[{emoji:"⌨️",label:"They type",sub:"And guess flags"},{emoji:"⇥",label:"Tab completes",sub:"Commands & options",lime:!0},{emoji:"😎",label:"Faster, no memorizing",sub:"It just flows"}],chatPrompt:Ee("shell completions","I want my CLI to provide tab-completion for its commands and options across common shells, with simple install instructions."),faqs:[{q:"Which shells should I support?",a:"The common ones your users have — typically bash, zsh, and fish. Most CLI frameworks can generate completions for all of them."},{q:"How do users enable them?",a:"Usually one command that installs the completion file for their shell. Clear instructions make it a one-time step."},{q:"Do completions stay in sync with my commands?",a:"When generated from your CLI's own definitions, yes — they update as your commands change, so they never drift."}]},"cli-ux":{Icon:Is,title:"CLI experience",crumbLabel:"CLI UX",meta:"Recommended · about 10 minutes",lead:"Make your command-line tool a pleasure to use: clear help, helpful errors, sensible defaults, and output that reads well. Good CLI UX earns loyal users.",journey:[{emoji:"😕",label:"Cryptic tool",sub:"Confusing errors"},{emoji:"✨",label:"Polished CLI",sub:"Clear help & output",lime:!0},{emoji:"❤️",label:"Users love it",sub:"And recommend it"}],chatPrompt:Ee("the CLI experience","I want to polish my CLI's usability — clear help text, helpful error messages, sensible defaults, and readable output."),faqs:[{q:"What separates a good CLI from a bad one?",a:"Discoverable help, errors that say how to fix the problem, sensible defaults, and output that's easy to read or pipe. Small touches add up."},{q:"Should output be colored?",a:"Color helps readability but should degrade gracefully when piped or unsupported, so scripts and plain terminals still work."},{q:"How important are good error messages?",a:"Very. An error that names the problem and the fix turns a frustrated user into a productive one."}]},"supply-chain":{Icon:et,title:"Supply-chain security",crumbLabel:"Supply chain",meta:"Recommended · about 10 minutes",lead:"Keep the code you depend on trustworthy. Know what's in your dependencies, catch known vulnerabilities, and make sure what you ship is what you built.",journey:[{emoji:"📥",label:"Dependencies",sub:"Code you didn't write"},{emoji:"🔍",label:"Checked & pinned",sub:"Scanned for risk",lime:!0},{emoji:"🛡️",label:"Trustworthy ship",sub:"What you built"}],chatPrompt:Ee("supply-chain security","I want to know what's in my dependencies, catch known vulnerabilities, pin versions, and verify that what I ship is what I built."),faqs:[{q:"Why worry about dependencies?",a:"Most of your app is code you didn't write. A vulnerability or tampered package upstream becomes your problem, so keeping an eye on them matters."},{q:"How do I catch vulnerabilities?",a:"Automated scanning flags known issues in your dependencies and suggests safe upgrades, ideally on every change."},{q:"What does 'pinning' mean?",a:"Locking exact dependency versions so builds are reproducible and a surprise update can't quietly change what you ship."}]},"pre-release-channel":{Icon:ot,title:"Pre-release channel",crumbLabel:"Pre-release",meta:"Optional · about 10 minutes",lead:"Give testers a next/beta version to opt into, so you can trial changes with willing users before they reach everyone on the stable release.",journey:[{emoji:"🧪",label:"A risky change",sub:"Needs real testing"},{emoji:"📡",label:"Beta channel",sub:"Opt-in testers",lime:!0},{emoji:"✅",label:"Then stable",sub:"For everyone"}],chatPrompt:Ee("a pre-release channel","I want a next/beta channel that testers can opt into, so I can trial changes before promoting them to the stable release."),faqs:[{q:"How is a beta channel different from just releasing?",a:"Only users who opt in get pre-releases, and the stable channel keeps moving separately — so testing new changes never disrupts everyone else."},{q:"Who uses pre-releases?",a:"Willing testers and power users who want early features and don't mind rough edges, giving you real feedback before a wide launch."},{q:"Does this move my 'latest'?",a:"No. Pre-releases are tagged separately, so people installing the default still get the stable version."}]},"pre-release-versions":{Icon:ot,title:"Pre-release versions",crumbLabel:"Pre-release",meta:"Optional · about 10 minutes",lead:"Publish next/beta versions of your package that testers can install on purpose, without moving the default that everyone else gets.",journey:[{emoji:"🧪",label:"A new version",sub:"Not ready for all"},{emoji:"🏷️",label:"Tagged pre-release",sub:"Opt-in install",lime:!0},{emoji:"✅",label:"Promote to latest",sub:"When it's proven"}],chatPrompt:Ee("pre-release versions","I want to publish beta/next versions of my package under a separate tag so testers can opt in without changing what the default install gets."),faqs:[{q:"How do testers get a pre-release?",a:"They install a specific tag (like `next` or `beta`) on purpose. The plain install keeps returning your stable version."},{q:"How do I mark a version as pre-release?",a:"Use a pre-release version number and publish it under a separate tag, so registries don't treat it as the latest stable."},{q:"When do I promote it?",a:"Once it's proven with testers, you republish it as the stable latest — the same build, now the default."}]}},A4={"real-data":bw,accounts:Pw,emails:Rw,payments:Mw,"analytics-monitoring":Iw,legal:Dw,"data-safety":Hw,publish:Bw,"custom-domain":Ww,forms:qw,"analytics-seo":Uw,"redirects-404":Yw,"performance-images":Gw,"comments-search":Vw,"publish-registry":Jw,"versioning-changelog":Xw,"install-docs":Qw,"release-builds":Zw,"shell-completions":e_,"cli-ux":t_,"api-docs":r_,examples:s_,"semver-policy":o_,"readme-license":i_,"supply-chain":n_,"changelog-ci":l_,"deploy-target":c_,"database-backups":d_,secrets:h_,"api-auth":f_,"cors-origins":m_,"background-jobs":g_,"logging-monitoring":x_,"staging-preview":Ml,"deploy-previews":Ml,"staging-environment":b_,"pre-release-channel":Il,"pre-release-versions":Il};function y_({onBack:e,topicKey:n,topicName:s,topicDesc:r}){const a=(s==null?void 0:s.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 t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(ou,{size:26}),title:a,meta:"Guided screen coming soon",onBack:e,assistKey:n??""}),t.jsx("p",{className:"lead",children:o}),t.jsx("div",{className:"cta-wrap",children:t.jsx("button",{type:"button",className:"cta",onClick:e,children:"Back to Setup"})})]})}function v_({topicKey:e,topicName:n,topicDesc:s,isBackend:r=!1,onBack:a,onComplete:o,onChatWithAI:i}){const c=E4[e];if(c)return t.jsx(tu,{icon:t.jsx(c.Icon,{size:26}),title:c.title,crumbLabel:c.crumbLabel,meta:c.meta,assistKey:e,onBack:a,lead:c.lead,illustration:lu(e)??t.jsx(En,{nodes:c.journey}),chatPrompt:c.chatPrompt,onChatWithAI:i,faqs:c.faqs});const d=e==="api-docs"&&r?a_:A4[e];return d?t.jsx(d,{onBack:a,onComplete:()=>o==null?void 0:o(e),onChatWithAI:i}):t.jsx(y_,{onBack:a,topicKey:e,topicName:n,topicDesc:s})}const UZ=Object.freeze(Object.defineProperty({__proto__:null,SetupTopicPlaceholder:y_,SetupTopicRouter:v_},Symbol.toStringTag,{value:"Module"}));function j_({onBack:e}){const{concepts:n}=uw(),[s,r]=l.useState(""),[a,o]=l.useState(null),i=l.useMemo(()=>{const c=s.trim().toLowerCase();return!c||!n?n??[]:n.filter(d=>[d.term,d.category,...d.aka].join(" ").toLowerCase().includes(c))},[n,s]);return t.jsxs("div",{className:"learn-screen concepts-glossary",children:[t.jsxs("div",{className:"crumbs",children:[t.jsx("button",{type:"button",className:"back",onClick:e,"aria-label":"Back",children:"←"}),t.jsx("button",{type:"button",onClick:e,children:"Setup"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("b",{children:"What these words mean"})]}),t.jsx("div",{className:"h",children:"What these words mean"}),t.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."}),t.jsx("input",{type:"search",className:"concept-search",placeholder:"Search terms…",value:s,onChange:c=>r(c.target.value),"aria-label":"Search terms"}),t.jsx("div",{className:"tlist",children:n===null?Array.from({length:6}).map((c,d)=>t.jsx("div",{className:"trow soon","aria-hidden":"true",children:t.jsxs("div",{className:"tbody",children:[t.jsx("div",{className:"tn",children:" "}),t.jsx("div",{className:"td",children:" "})]})},d)):i.length===0?t.jsxs("div",{className:"concept-empty",children:['No terms match "',s,'".']}):i.map(c=>{const d=a===c.key;return t.jsxs("div",{className:"concept-row",children:[t.jsxs("button",{type:"button",className:"trow soon","aria-expanded":d,onClick:()=>o(d?null:c.key),children:[t.jsxs("div",{className:"tbody",children:[t.jsx("div",{className:"tn",children:c.term}),c.category?t.jsx("div",{className:"td",children:c.category}):null]}),t.jsx("span",{className:"arrow",children:d?"−":"+"})]}),d?t.jsx("div",{className:"concept-row-body",children:t.jsx(Ft,{variant:"compact",children:c.body})}):null]},c.key)})})]})}const YZ=Object.freeze(Object.defineProperty({__proto__:null,ConceptsGlossaryScreen:j_},Symbol.toStringTag,{value:"Module"}));function M4(e){const n=(e??"").split("·").map(a=>a.trim()).filter(Boolean);if(n.length===0)return{tally:"",attention:null};const[s,...r]=n;return{tally:s,attention:r.length>0?r.join(" · "):null}}function w_({summary:e}){const{tally:n,attention:s}=M4(e);return n?t.jsxs("p",{className:"xsvc-count xsvc-count-row",children:[t.jsx("b",{children:n}),s?t.jsxs(t.Fragment,{children:[" · ",t.jsx("span",{className:"attn",children:s})]}):null]}):null}const GZ=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesSummary:w_},Symbol.toStringTag,{value:"Module"}));function __({summary:e,sort:n,onSortChange:s}){return t.jsxs("div",{className:"xsvc-listbar",children:[t.jsx(w_,{summary:e}),t.jsx(Ud,{sort:n,onSortChange:s})]})}const VZ=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesListBar:__},Symbol.toStringTag,{value:"Module"})),I4="All providers";function D4(e,n){const s=e??[];return n==="type"?s.filter(r=>r.items.length>0):[{label:I4,items:s.flatMap(r=>r.items.map(a=>a.category?a:{...a,category:r.label})).slice().sort((r,a)=>r.name.localeCompare(a.name))}]}function S_({groups:e,loading:n=!1,summary:s,onBack:r,onOpenChat:a,onAction:o,defaultSort:i="type",chatSlot:c,embedded:d=!1,brokerStarter:u,onSaveDomain:p}){const h=Array.isArray(e)&&e.some(j=>j.items.length>0),[f,m]=l.useState(i),[g,x]=l.useState(""),b=l.useRef(null),y=j=>{j.preventDefault(),a==null||a(g.trim()||void 0)},v=h?D4(e,f):[];return t.jsx("div",{className:d?"xsvc xsvc-embedded":"xsvc",children:t.jsxs("div",{className:"xsvc-scroll",children:[d?null:t.jsx("div",{className:"xsvc-crumbs",children:t.jsx("button",{type:"button",className:"xsvc-back",onClick:r,"aria-label":"Back to Home",children:"‹ Home"})}),t.jsxs("div",{className:"xsvc-head",children:[d?null:t.jsxs("div",{className:"xsvc-titlerow",children:[t.jsx("h1",{children:"External Services"}),h?t.jsx("span",{className:"xsvc-count",children:s??"Every outside service, in one place."}):null]}),d||!h?t.jsx("p",{className:d?"xsvc-sub xsvc-sub-lead":"xsvc-sub",children:"Every outside service this project depends on: domains, hosting, API keys, payments, and the database. Anything it talks to that lives beyond its own code."}):null]}),h?t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:b,"aria-hidden":"true"}),t.jsx(av,{draft:g,onDraftChange:x,onSubmit:y,onAsk:a,chatSlot:c,bare:d}),t.jsx("div",{className:"xsvc-divider",role:"presentation"}),d?t.jsx(__,{summary:s,sort:f,onSortChange:m}):t.jsx(Ud,{sort:f,onSortChange:m}),t.jsx(sv,{groups:v,onAction:o,onSaveDomain:p,onAsk:a?j=>{var _,w;x(j),a(j),(w=(_=b.current)==null?void 0:_.scrollIntoView)==null||w.call(_,{behavior:"smooth",block:"start"})}:void 0})]}):n?t.jsx("p",{"data-testid":"xsvc-loading",role:"status",className:"xsvc-sub",children:"Loading services…"}):t.jsx(Zy,{draft:g,onDraftChange:x,onSubmit:y,onAsk:a,brokerStarter:u})]})})}const KZ=Object.freeze(Object.defineProperty({__proto__:null,ApiKeyField:Hd,ExternalServicesScreen:S_,ServiceRow:qd},Symbol.toStringTag,{value:"Module"})),Nr="your-app.vercel.app",L4=[{key:"connect",label:"Connect"},{key:"deploying",label:"Deploy"},{key:"live",label:"Go live"}];function vu({onBack:e}){return t.jsx(Ce,{icon:t.jsx(is,{size:26}),title:"Hosting & going live",crumbLabel:"Hosting",meta:"Foundation · about 10 minutes",onBack:e,assistKey:"hosting"})}function Ls({stage:e}){return t.jsx(wn,{steps:L4,currentKey:e})}const JZ=Object.freeze(Object.defineProperty({__proto__:null,FlowBar:Ls,HSHeader:vu,HS_URL:Nr},Symbol.toStringTag,{value:"Module"}));function F4(){const[e,n]=l.useState(null);return l.useEffect(()=>{let s=!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();s||n(a)}catch{s||n(null)}})(),()=>{s=!0}},[]),{target:e}}function k_({onBack:e,onSetup:n}){const{target:s}=F4(),r=(s==null?void 0:s.detectedHost)??null;return t.jsxs(t.Fragment,{children:[t.jsx(vu,{onBack:e}),t.jsxs("p",{className:"lead",children:["Right now your app only runs on ",t.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."]}),t.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."}),t.jsx(cv,{}),r&&t.jsxs("div",{className:"hosting-detected",role:"note",children:[t.jsxs("div",{className:"hosting-detected-title",children:["This project is already configured for ",t.jsx("b",{children:r.name})]}),t.jsxs("div",{className:"hosting-detected-detail",children:["We found ",t.jsx("code",{children:r.evidence})," in your project — let's use"," ",r.name,".",(s==null?void 0:s.buildCommand)&&t.jsxs(t.Fragment,{children:[" ","It builds with ",t.jsx("code",{children:s.buildCommand}),s.outputDir&&t.jsxs(t.Fragment,{children:[" ","into ",t.jsx("code",{children:s.outputDir})]}),"."]})]})]}),t.jsx("div",{className:"seclabel",children:r?"Or start fresh with our recommendation":"Recommended for your app"}),t.jsxs("div",{className:"provcard best",children:[t.jsx(Ro,{}),t.jsxs("div",{className:"provbody",children:[t.jsxs("div",{className:"provtop",children:[t.jsx("span",{className:"provname",children:"Vercel"}),t.jsx("span",{className:"bestfit",children:"Best fit"})]}),t.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."}),t.jsx(dv,{}),t.jsx(uv,{})]})]}),t.jsx(pv,{}),t.jsxs("div",{className:"cta-wrap",children:[t.jsxs("button",{type:"button",className:"cta",onClick:n,children:[t.jsx("span",{className:"ce",children:"☁️"})," Set up hosting with Vercel"]}),t.jsx("div",{className:"cta-note",children:"We'll walk you through every step. Nothing goes live until you say so."})]}),t.jsx("div",{className:"seclabel",style:{marginTop:34},children:"FAQ"}),t.jsx(hv,{}),t.jsx(fv,{}),t.jsx(Pe,{assistKey:"hosting",topicName:"Hosting & going live"})]})}const XZ=Object.freeze(Object.defineProperty({__proto__:null,HostingOverviewGuided:k_},Symbol.toStringTag,{value:"Module"}));function N_({onBack:e,onContinue:n,tokenMode:s=!1}){const[r,a]=l.useState("");return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"crumbs",children:[t.jsx("button",{type:"button",className:"back",onClick:e,"aria-label":"Back",children:"←"}),t.jsx("button",{type:"button",onClick:e,children:"Hosting"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("b",{children:"Connect Vercel"})]}),t.jsx(Ls,{stage:"connect"}),t.jsxs("div",{className:"panel",children:[t.jsx("div",{className:"ph",children:"🔗 Connect your Vercel account"}),t.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."}),t.jsxs("div",{className:"connect-box",children:[t.jsxs("div",{className:"cbtitle",children:[t.jsx(Ro,{}),t.jsxs("div",{children:[t.jsx("div",{className:"cbt",children:"Sign in with Vercel"}),t.jsx("div",{className:"cbd",children:s?"Paste a Vercel access token to deploy your real app.":"We'll open Vercel in a new tab and bring you right back."})]})]}),s?t.jsxs(t.Fragment,{children:[t.jsx("label",{className:"real-token-label",htmlFor:"hosting-token",children:"Vercel access token"}),t.jsx("input",{id:"hosting-token",type:"password",className:"real-token-input",placeholder:"Paste your Vercel token",value:r,onChange:o=>a(o.target.value)}),t.jsxs("button",{type:"button",className:"auth-btn",disabled:r.trim().length===0,onClick:()=>n(r.trim()),children:[t.jsx("svg",{width:"17",height:"15",viewBox:"0 0 26 22",fill:"#fff","aria-hidden":"true",children:t.jsx("path",{d:"M13 0l13 22H0z"})}),"Deploy with Vercel"]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grant",children:[t.jsxs("div",{className:"grantrow",children:[t.jsx(lt,{color:"var(--blue-300)"}),t.jsx("span",{children:"Create one project to hold your app"})]}),t.jsxs("div",{className:"grantrow",children:[t.jsx(lt,{color:"var(--blue-300)"}),t.jsx("span",{children:"Publish updates when you choose to go live"})]}),t.jsxs("div",{className:"grantrow",children:[t.jsx(lt,{color:"var(--blue-300)"}),t.jsx("span",{children:"Nothing else. We can't touch your other accounts or files"})]})]}),t.jsxs("button",{type:"button",className:"auth-btn",onClick:()=>n(),children:[t.jsx("svg",{width:"17",height:"15",viewBox:"0 0 26 22",fill:"#fff","aria-hidden":"true",children:t.jsx("path",{d:"M13 0l13 22H0z"})}),"Continue with Vercel"]}),t.jsxs("div",{className:"auth-row",children:[t.jsx("button",{type:"button",className:"auth-ghost",onClick:()=>n(),children:"I already have an account"}),t.jsx("button",{type:"button",className:"auth-ghost",onClick:()=>n(),children:"Create one for me"})]})]})]}),t.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 QZ=Object.freeze(Object.defineProperty({__proto__:null,HostingConnectStep:N_},Symbol.toStringTag,{value:"Module"})),da=["Packaging up your app","Uploading it to Vercel","Giving it a web address","Turning it on"],lf=1100,$4=700;function C_({onDone:e}){const[n,s]=l.useState(0),r=l.useRef(e);r.current=e,l.useEffect(()=>{const o=[];for(let i=1;i<=da.length;i++)o.push(setTimeout(()=>s(i),i*lf));return o.push(setTimeout(()=>r.current(),da.length*lf+$4)),()=>o.forEach(clearTimeout)},[]);const a=Math.round(n/da.length*100);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"crumbs",children:[t.jsx("span",{children:"Hosting"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("b",{children:"Going live"})]}),t.jsx(Ls,{stage:"deploying"}),t.jsxs("div",{className:"panel",children:[t.jsxs("div",{className:"deploy-head",children:[t.jsx("div",{className:"deploy-spin"}),t.jsxs("div",{children:[t.jsx("div",{className:"deploy-t",children:"Putting your app online…"}),t.jsx("div",{className:"deploy-d",children:"This usually takes under a minute. You can keep working, we'll let you know."})]})]}),t.jsx("div",{className:"dep-bar",children:t.jsx("div",{style:{width:a+"%"}})}),t.jsx("div",{className:"dep-steps",children:da.map((o,i)=>t.jsxs("div",{className:"dep-step "+(i<n?"done":i===n?"active":"todo"),children:[t.jsx("div",{className:"dot",children:i<n?t.jsx(lt,{size:12,color:"#0a0a0a"}):null}),t.jsx("div",{className:"sl",children:o})]},o))})]})]})}const ZZ=Object.freeze(Object.defineProperty({__proto__:null,HostingDeployStep:C_},Symbol.toStringTag,{value:"Module"})),z4="hosting";function T_({provider:e,credential:n,onDone:s,onRetry:r}){const{stage:a,result:o,error:i,connect:c}=cu(z4,e),d=l.useRef(!1);l.useEffect(()=>{d.current||(d.current=!0,c(n))},[c,n]);const u=l.useRef(s);return u.current=s,l.useEffect(()=>{a==="ready"&&o&&u.current(o.value)},[a,o]),a==="error"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"crumbs",children:[t.jsx("span",{children:"Hosting"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("b",{children:"Going live"})]}),t.jsx(Ls,{stage:"deploying"}),t.jsxs("div",{className:"panel",children:[t.jsxs("div",{className:"real-error",role:"alert",children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsx("div",{className:"real-error-title",children:"Couldn’t put your app online"}),t.jsx(ct,{variant:"icon",text:`Couldn’t put your app online: ${i}`})]}),t.jsx("div",{className:"real-error-msg",children:i})]}),t.jsx("button",{type:"button",className:"auth-btn",onClick:r,children:"Try again"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"crumbs",children:[t.jsx("span",{children:"Hosting"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("b",{children:"Going live"})]}),t.jsx(Ls,{stage:"deploying"}),t.jsxs("div",{className:"panel",children:[t.jsxs("div",{className:"deploy-head",children:[t.jsx("div",{className:"deploy-spin"}),t.jsxs("div",{children:[t.jsx("div",{className:"deploy-t",children:"Putting your app online…"}),t.jsx("div",{className:"deploy-d",children:a==="connecting"?"Connecting to your hosting account…":"Building and publishing your app. This usually takes under a minute."})]})]}),t.jsx("div",{className:"dep-bar",children:t.jsx("div",{className:"dep-bar-indeterminate"})})]})]})}const eee=Object.freeze(Object.defineProperty({__proto__:null,HostingRealDeployStep:T_},Symbol.toStringTag,{value:"Module"})),B4=1600;function P_(e){const{copied:n,copy:s}=fo({resetMs:B4}),r=l.useCallback(()=>{s(e)},[s,e]);return{copied:n,copy:r}}function O_({onFinish:e,liveUrl:n}){const s=n??Nr,r=n??"https://"+Nr,{copied:a,copy:o}=P_(r);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"crumbs",children:[t.jsx("span",{children:"Hosting"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("b",{children:"Live"})]}),t.jsx(Ls,{stage:"live"}),t.jsxs("div",{className:"panel",children:[t.jsxs("div",{className:"live-hero",children:[t.jsx("div",{className:"lh-em",children:"🎉"}),t.jsx("div",{className:"lh-t",children:"Your app is live"}),t.jsx("div",{className:"lh-d",children:"Anyone with this link can open your app right now."})]}),t.jsxs("div",{className:"url-card",children:[t.jsx("span",{className:"ucglobe",children:"🌍"}),t.jsxs("div",{children:[t.jsx("div",{className:"uc-l",children:"Your link"}),t.jsx("div",{className:"uc-u",children:s})]}),t.jsxs("div",{className:"uc-actions",children:[t.jsx("button",{type:"button",className:"btn-copy",onClick:o,children:a?"✓ Copied":"Copy link"}),t.jsx("button",{type:"button",className:"btn-visit",disabled:!n,onClick:n?()=>window.open(n,"_blank","noopener"):void 0,children:"Visit →"})]})]}),t.jsxs("div",{className:"domain-row",children:[t.jsx("span",{className:"dre",children:"🏷️"}),t.jsxs("div",{children:[t.jsx("div",{className:"drt",children:"Want your own web address?"}),t.jsx("div",{className:"drd",children:"Connect a custom domain. Optional, and you can do it anytime."})]}),t.jsx("button",{type:"button",className:"drbtn",children:"Add a domain"})]}),t.jsxs("div",{className:"live-foot",children:[t.jsxs("span",{className:"done-pill",children:[t.jsx(lt,{})," Hosting is now set up"]}),t.jsx("button",{type:"button",className:"lf-back",onClick:e,children:"Back to Setup"})]})]})]})}const tee=Object.freeze(Object.defineProperty({__proto__:null,HostingLiveStep:O_},Symbol.toStringTag,{value:"Module"}));function R_({onBack:e,onRedeploy:n}){const{copied:s,copy:r}=P_("https://"+Nr),[a,o]=l.useState(!0);return t.jsxs(t.Fragment,{children:[t.jsx(vu,{onBack:e}),t.jsxs("div",{className:"conn-card",children:[t.jsx(Ro,{}),t.jsxs("div",{className:"conn-body",children:[t.jsxs("div",{className:"conn-top",children:[t.jsx("span",{className:"conn-name",children:"Connected to Vercel"}),t.jsxs("span",{className:"conn-live",children:[t.jsx("span",{className:"lbdot"}),"Live"]})]}),t.jsxs("div",{className:"conn-acct",children:["Account ",t.jsx("b",{children:"your-app"})," · connected today"]})]}),t.jsx("button",{type:"button",className:"conn-disc",children:"Disconnect"})]}),t.jsx("div",{className:"seclabel",children:"Your live app"}),t.jsxs("div",{className:"url-card",children:[t.jsx("span",{className:"ucglobe",children:"🌍"}),t.jsxs("div",{children:[t.jsx("div",{className:"uc-l",children:"Your link"}),t.jsx("div",{className:"uc-u",children:Nr})]}),t.jsxs("div",{className:"uc-actions",children:[t.jsx("button",{type:"button",className:"btn-copy",onClick:r,children:s?"✓ Copied":"Copy link"}),t.jsx("button",{type:"button",className:"btn-visit",children:"Visit →"})]})]}),t.jsx("div",{className:"seclabel",style:{marginTop:28},children:"Latest deploy"}),t.jsxs("div",{className:"dep-card",children:[t.jsxs("div",{className:"depc-row",children:[t.jsx("span",{className:"depc-dot"}),t.jsxs("div",{className:"depc-main",children:[t.jsx("div",{className:"depc-t",children:"Live · deployed 2 minutes ago"}),t.jsx("div",{className:"depc-d",children:"Built and published from your latest changes."})]}),t.jsx("button",{type:"button",className:"depc-btn",onClick:n,children:"Redeploy"})]}),t.jsxs("div",{className:"depc-toggle",children:[t.jsxs("div",{children:[t.jsx("div",{className:"depc-tt",children:"Publish changes automatically"}),t.jsx("div",{className:"depc-td",children:"When you make changes, we'll put them live for you. Turn this off to publish by hand."})]}),t.jsx("span",{className:"toggle"+(a?" on":""),onClick:()=>o(i=>!i),role:"switch","aria-checked":a,tabIndex:0,children:t.jsx("span",{})})]})]})]})}const nee=Object.freeze(Object.defineProperty({__proto__:null,HostingOverviewConnected:R_},Symbol.toStringTag,{value:"Module"}));function E_({direction:e="guided",onBack:n,onComplete:s,connector:r,onOpenSharedBrowser:a}){const[o,i]=l.useState("overview"),[c,d]=l.useState(""),[u,p]=l.useState(void 0),h=r!==void 0;let f;return o==="overview"?f=e==="connected"?t.jsx(R_,{onBack:n,onRedeploy:()=>i("deploying")}):t.jsx(k_,{onBack:n,onSetup:()=>i("connect")}):o==="connect"?f=t.jsx(N_,{onBack:()=>i("overview"),tokenMode:h,onContinue:m=>{h&&d(m??""),i("deploying")}}):o==="deploying"?f=h?t.jsx(T_,{provider:r.provider,credential:c,onDone:m=>{p(m),i(e==="connected"?"overview":"live")},onRetry:()=>i("connect")}):t.jsx(C_,{onDone:()=>i(e==="connected"?"overview":"live")}):f=t.jsx(O_,{liveUrl:u,onFinish:()=>{s==null||s(),n()}}),t.jsxs("div",{className:"hosting-screen",children:[f,a&&t.jsxs("div",{className:"mt-3 flex items-center gap-2 text-[12px]",children:[t.jsx("button",{type:"button",className:"rounded px-3 py-1.5",style:{background:"var(--bg-card)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)",cursor:"pointer"},onClick:a,children:"Open shared browser →"}),t.jsx("span",{style:{color:"var(--text-secondary)"},children:"Walk the hosting console together — you and the assistant both drive."})]})]})}const see=Object.freeze(Object.defineProperty({__proto__:null,HostingScreen:E_},Symbol.toStringTag,{value:"Module"}));function A_({recipe:e,onBack:n,onMarkDone:s,status:r,onRevert:a,copyWriter:o}){return t.jsxs("div",{className:"learn-screen run-locally-screen",children:[t.jsxs("div",{className:"crumbs",children:[t.jsx("button",{type:"button",className:"back",onClick:n,"aria-label":"Back",children:"←"}),t.jsx("button",{type:"button",onClick:n,children:"Home"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("button",{type:"button",onClick:n,children:"Setup"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("b",{children:"Run it locally"})]}),t.jsx("div",{className:"h",children:"Run it locally"}),t.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."}),e===null?t.jsx("div",{className:"rl-loading","aria-hidden":"true",children:"Loading run instructions…"}):t.jsxs("div",{className:"rl-sections",children:[e.prereqs.length>0&&t.jsxs("section",{className:"rl-sec",children:[t.jsx("div",{className:"seclabel",children:"Prerequisites"}),t.jsx("ul",{className:"rl-prereqs",children:e.prereqs.map(i=>t.jsxs("li",{className:"rl-prereq",children:[t.jsx("span",{className:"rl-prereq-label",children:i.label}),t.jsx("span",{className:"rl-prereq-detail",children:i.detail})]},i.label))})]}),e.install&&t.jsxs("section",{className:"rl-sec",children:[t.jsx("div",{className:"seclabel",children:"Install"}),t.jsx(ur,{command:e.install,writer:o})]}),t.jsxs("section",{className:"rl-sec",children:[t.jsx("div",{className:"seclabel",children:e.runLabel||"Run"}),t.jsx(ur,{command:e.run,writer:o})]}),e.loadSteps&&t.jsxs("section",{className:"rl-sec",children:[t.jsx("div",{className:"seclabel",children:e.loadSteps.label}),t.jsx("ol",{className:"rl-load-steps",children:e.loadSteps.steps.map(i=>t.jsx("li",{className:"rl-load-step",children:i},i))}),e.loadTarget&&t.jsxs("div",{className:"rl-load-target",children:[t.jsx("div",{className:"rl-load-target-label",children:e.loadTarget.label}),t.jsx(ur,{command:e.loadTarget.path,writer:o})]})]}),e.reachableAt&&t.jsxs("section",{className:"rl-sec",children:[t.jsx("div",{className:"seclabel",children:"Open it"}),t.jsxs("div",{className:"rl-reachable",children:["Once it's running, open"," ",t.jsx("a",{className:"rl-url",href:e.reachableAt,target:"_blank",rel:"noreferrer",children:e.reachableAt}),"."]})]}),e.notes.length>0&&t.jsxs("section",{className:"rl-sec",children:[t.jsx("div",{className:"seclabel",children:"Notes"}),t.jsx("ul",{className:"rl-notes",children:e.notes.map(i=>t.jsx("li",{className:"rl-note",children:i},i))})]}),t.jsx(Pe,{assistKey:"run-locally",topicName:"Run it locally"}),s&&t.jsx(Re,{label:"Got it — mark as done",note:"You can revisit these steps anytime.",status:r,onComplete:()=>s(),onRevert:a,onBack:n})]})]})}const ree=Object.freeze(Object.defineProperty({__proto__:null,RunLocallyScreen:A_},Symbol.toStringTag,{value:"Module"}));function M_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(et,{size:26}),title:"Store accounts",meta:"Foundation · about 15 minutes",onBack:e,assistKey:"store-accounts"}),t.jsxs("p",{className:"lead",children:["To publish your extension, you first register as a developer with the"," ",t.jsx("b",{children:"Chrome Web Store"}),". This is a one-time setup that gives you a dashboard for uploading, updating, and managing your listing."]}),t.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."}),t.jsx(Xt,{linkKey:"chrome.devConsole"}),t.jsx("div",{className:"seclabel",children:"What you'll do"}),t.jsxs(Se,{children:[t.jsxs($,{lead:"Pay the one-time developer fee.",children:["The Chrome Web Store charges a single"," ",t.jsx("b",{children:Te("chromeStore.fee").value})," registration fee per account — not per extension. There's no recurring cost. The registration guide walks through the exact steps."]}),t.jsx($,{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."}),t.jsx($,{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."}),t.jsx($,{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."})]}),t.jsx(Xt,{linkKey:"chrome.register",label:"Read the Chrome Web Store registration guide"}),t.jsx(Eo,{}),t.jsx(Pe,{assistKey:"store-accounts",topicName:"Store accounts"}),t.jsx(Re,{label:"I've registered my developer account",note:"You only need to do this once. The next steps reuse the same account.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:e})]})}const aee=Object.freeze(Object.defineProperty({__proto__:null,StoreAccountsScreen:M_},Symbol.toStringTag,{value:"Module"}));function I_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(Mt,{size:26}),title:"Store assets",meta:"About 30 minutes · design time",onBack:e,assistKey:"extension-store-assets"}),t.jsxs("p",{className:"lead",children:["Your store listing needs a set of images at ",t.jsx("b",{children:"exact dimensions"}),". The store rejects assets that are the wrong size, so it's worth getting these right before you submit."]}),t.jsx("div",{className:"seclabel",children:"Required"}),t.jsxs(Se,{children:[t.jsx($,{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."}),t.jsx($,{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."})]}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Recommended"}),t.jsxs(Se,{children:[t.jsx($,{lead:"Small promo tile — 440×280.",children:"Shown in store listings and search results. A clean tile noticeably improves install rates."}),t.jsx($,{lead:"Marquee promo tile — 1400×560.",children:"Only used if the store features your extension, but worth having ready."})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"PNG or JPEG"}),t.jsx("span",{className:"chip",children:"No misleading imagery"}),t.jsx("span",{className:"chip",children:"Up to 5 screenshots"})]}),t.jsx(Xt,{linkKey:"chrome.devConsole",label:"Upload assets in the developer dashboard"}),t.jsx(Pe,{assistKey:"extension-store-assets",topicName:"Store assets"}),t.jsx(Re,{label:"My store assets are ready",note:"You can update assets later — a new upload doesn't restart the whole review.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:e})]})}const oee=Object.freeze(Object.defineProperty({__proto__:null,ExtensionAssetsScreen:I_},Symbol.toStringTag,{value:"Module"})),D_={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 Cr(e){const n=e.trim();return n.includes("://")||n.startsWith("*")||n==="<all_urls>"}function W4(e){const n=e.trim();return n==="<all_urls>"?!0:Cr(n)?n.replace(/^\*?:\/\//,"").split("/")[0]==="*":!1}function H4(e){const n=e.trim();return n==="<all_urls>"?"Run on every site the user visits. Only request this if your extension truly needs it — reviewers scrutinise it closely.":W4(n)?`Run on a very broad set of sites (${n}). Reviewers treat broad host access like <all_urls> — narrow it to the exact origins you need, or use activeTab instead.`:Cr(n)?`Run only on the specific sites this pattern matches (${n}).`:D_[n]??"Explain, in one plain sentence, exactly what this permission lets your extension do for the user."}function q4(e){const n=e.trim();return Cr(n)||n in D_}const U4=["storage","activeTab","scripting","https://api.example.com/*"];function Dl({perm:e}){return t.jsxs("div",{className:"reason",children:[t.jsx(lt,{}),t.jsxs("span",{children:[t.jsx("b",{children:t.jsx("code",{children:e})})," ",H4(e),q4(e)?null:t.jsx("span",{className:"bestfit",style:{marginLeft:8},children:"needs your wording"})]})]},e)}function L_({permissions:e=U4,onBack:n,onComplete:s,status:r,onRevert:a}){const o=e.filter(Cr),i=e.filter(c=>!Cr(c));return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(et,{size:26}),title:"Permissions",meta:"About 20 minutes · often missed",onBack:n,assistKey:"permissions-justification"}),t.jsxs("p",{className:"lead",children:["The store asks you to justify ",t.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."]}),t.jsxs("p",{className:"lead dim",children:["These are read from your ",t.jsx("code",{children:"manifest.json"}),". Review the suggested justification for each and tighten it to match what your extension actually does."]}),t.jsxs("div",{className:"asknote",style:{marginTop:4},children:[t.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."]}),t.jsx("div",{className:"seclabel",children:"API permissions you request"}),i.length===0?t.jsx("p",{className:"lead dim",children:"Your manifest requests no API permissions to justify here."}):t.jsx("div",{className:"reasons",children:i.map(c=>t.jsx(Dl,{perm:c},c))}),t.jsx("div",{className:"seclabel",children:"Host permissions"}),o.length===0?t.jsx("p",{className:"lead dim",children:"Your manifest requests no host permissions — the easiest possible review on this axis."}):t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"lead dim",children:["Host permissions are submitted in a ",t.jsx("b",{children:"separate field"})," on the dashboard and scrutinised the hardest — narrow them to the exact origins you need."]}),t.jsx("div",{className:"reasons",children:o.map(c=>t.jsx(Dl,{perm:c},c))})]}),e.length===0&&t.jsx("p",{className:"lead dim",children:"Your manifest requests no special permissions — there's nothing to justify. That's the easiest possible review."}),t.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."}),t.jsx(Xt,{linkKey:"chrome.devConsole",label:"Submit justifications in the developer dashboard"}),t.jsx(Pe,{assistKey:"permissions-justification",topicName:"Permissions"}),t.jsx(Re,{label:"My permissions are justified",note:"Reviewers read these. Vague or copy-pasted reasons are the most common rejection.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const iee=Object.freeze(Object.defineProperty({__proto__:null,PermissionRow:Dl,PermissionsJustificationScreen:L_},Symbol.toStringTag,{value:"Module"}));function F_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(Xe,{size:26}),title:"Privacy policy",meta:"About 20 minutes · disclosure required for every extension",onBack:e,assistKey:"privacy-policy"}),t.jsxs("p",{className:"lead",children:["A privacy policy at a public URL is required for any extension that accesses user data. Separately, ",t.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."]}),t.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.`}),t.jsx("div",{className:"seclabel",children:'The "Privacy practices" tab'}),t.jsxs("p",{className:"lead dim",children:["The disclosure lives on the dashboard's ",t.jsx("b",{children:"Privacy practices"})," tab. You can't submit until you check its three mandatory certifications:"]}),t.jsxs(Se,{children:[t.jsx($,{lead:"You don't sell or transfer data to third parties",children:"outside of approved use cases."}),t.jsx($,{lead:"You don't use or transfer data for purposes unrelated",children:"to your extension's single purpose."}),t.jsx($,{lead:"You don't use or transfer data to determine creditworthiness",children:"or for lending purposes."})]}),t.jsx("div",{className:"seclabel",children:"Your policy must cover"}),t.jsxs(Se,{children:[t.jsx($,{lead:"What you collect.",children:"List the categories of data — settings, content the user enters, usage analytics — in plain terms."}),t.jsx($,{lead:"Why you collect it.",children:"Tie each category to a feature. The store cross-checks this against your permission justifications."}),t.jsx($,{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."}),t.jsx($,{lead:"How users can reach you.",children:"A contact method for privacy questions or deletion requests."})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"Hosted at a public URL"}),t.jsx("span",{className:"chip",children:"Linked in the dashboard"}),t.jsx("span",{className:"chip",children:"Matches your data disclosure"})]}),t.jsx(Pe,{assistKey:"privacy-policy",topicName:"Privacy policy"}),t.jsx(Re,{label:"My privacy policy is published and linked",note:"Keep the policy URL live — a dead link can get the listing taken down later.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:e})]})}const lee=Object.freeze(Object.defineProperty({__proto__:null,ExtensionPrivacyPolicyScreen:F_},Symbol.toStringTag,{value:"Module"}));function $_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(et,{size:26}),title:"OAuth & sign-in verification",meta:"Days to weeks · a separate review from the store listing",onBack:e,assistKey:"oauth-verification"}),t.jsxs("p",{className:"lead",children:["If your extension signs users in with Google, the OAuth"," ",t.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."]}),t.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."}),t.jsxs("div",{className:"asknote",style:{marginTop:4},children:[t.jsx("b",{children:"Two reviews, two timelines:"})," the store reviews your extension listing; Google separately reviews the ",t.jsx("b",{children:"OAuth consent screen"})," tied to your Cloud project. Approval on one is not approval on the other."]}),t.jsx("div",{className:"seclabel",children:"How long depends on the scopes you ask for"}),t.jsxs(Se,{children:[t.jsx($,{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."}),t.jsx($,{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."}),t.jsx($,{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."})]}),t.jsx("div",{className:"seclabel",children:"Before you submit for verification"}),t.jsxs(Se,{children:[t.jsx($,{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."}),t.jsx($,{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."}),t.jsx($,{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."})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"Separate from the store review"}),t.jsx("span",{className:"chip",children:"Sensitive scopes = verification"}),t.jsx("span",{className:"chip",children:"Restricted scopes = security assessment"})]}),t.jsx(Xt,{linkKey:"google.oauthConsent"}),t.jsx(Pe,{assistKey:"oauth-verification",topicName:"OAuth & sign-in verification"}),t.jsx(Re,{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.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:e})]})}const cee=Object.freeze(Object.defineProperty({__proto__:null,OAuthVerificationScreen:$_},Symbol.toStringTag,{value:"Module"}));function z_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(Xe,{size:26}),title:"Single purpose & listing quality",meta:"About 30 minutes · two of the top rejection causes",onBack:e,assistKey:"single-purpose-listing"}),t.jsxs("p",{className:"lead",children:["Every extension must have a ",t.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."]}),t.jsx("p",{className:"lead dim",children:"Write your one-sentence purpose first. Everything else — permissions, the description, the category — should follow from it."}),t.jsx("div",{className:"seclabel",children:"The single-purpose policy"}),t.jsxs(Se,{children:[t.jsx($,{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.`}),t.jsx($,{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."}),t.jsx($,{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."})]}),t.jsx("div",{className:"seclabel",children:"Listing quality"}),t.jsxs(Se,{children:[t.jsx($,{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."}),t.jsx($,{lead:"The right category.",children:"Pick the category that matches the purpose. A mismatched category is a flag and hurts discovery."}),t.jsx($,{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.`})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"One sentence, one purpose"}),t.jsx("span",{className:"chip",children:"Description matches behavior"}),t.jsx("span",{className:"chip",children:"Honest title & category"})]}),t.jsx(Xt,{linkKey:"chrome.devConsole",label:"Edit the listing description in the developer dashboard"}),t.jsx(Pe,{assistKey:"single-purpose-listing",topicName:"Single purpose & listing quality"}),t.jsx(Re,{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?",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:e})]})}const dee=Object.freeze(Object.defineProperty({__proto__:null,SinglePurposeListingScreen:z_},Symbol.toStringTag,{value:"Module"}));function B_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(Mt,{size:26}),title:"Manifest & versioning",meta:"About 15 minutes · enforced before review even starts",onBack:e,assistKey:"manifest-versioning"}),t.jsxs("p",{className:"lead",children:["Your ",t.jsx("code",{children:"manifest.json"})," has to satisfy a few hard rules before the store will accept an upload at all — these checks run"," ",t.jsx("b",{children:"before"})," any human review. Getting them right means your Submit step goes through on the first try instead of bouncing."]}),t.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."}),t.jsx("div",{className:"seclabel",children:"The rules the store enforces"}),t.jsxs(Se,{children:[t.jsxs($,{lead:"Manifest V3 is required.",children:[t.jsx("code",{children:'"manifest_version": 3'}),". V2 is no longer accepted for new uploads — a service worker replaces the old background page, and blocking ",t.jsx("code",{children:"webRequest"})," is gone."]}),t.jsxs($,{lead:"The version must strictly increase on every upload.",children:["Bump ",t.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."]}),t.jsxs($,{lead:"Use a valid version format.",children:["One to four dot-separated integers (e.g. ",t.jsx("code",{children:"1.2.0"}),"). Each part is compared numerically, so ",t.jsx("code",{children:"1.10"})," is newer than"," ",t.jsx("code",{children:"1.9"}),"."]})]}),t.jsx("div",{className:"seclabel",children:"Worth setting deliberately"}),t.jsxs(Se,{children:[t.jsx($,{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."}),t.jsxs($,{lead:"Keep name, description, and icons in sync.",children:["The manifest's ",t.jsx("code",{children:"name"}),"/",t.jsx("code",{children:"description"})," seed your listing, and the icon set here is what the store and toolbar render."]})]}),t.jsxs("div",{className:"chips",children:[t.jsx("span",{className:"chip",children:"manifest_version: 3"}),t.jsx("span",{className:"chip",children:"version strictly increases"}),t.jsx("span",{className:"chip",children:"minimum_chrome_version set"})]}),t.jsx(Pe,{assistKey:"manifest-versioning",topicName:"Manifest & versioning"}),t.jsx(Re,{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.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:e})]})}const uee=Object.freeze(Object.defineProperty({__proto__:null,ManifestVersioningScreen:B_},Symbol.toStringTag,{value:"Module"}));function W_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(ot,{size:26}),title:"Submit for review",meta:"About 15 minutes · then a review wait",onBack:e,assistKey:"submit-review"}),t.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."}),t.jsx("div",{className:"seclabel",children:"Packaging & submitting"}),t.jsxs(Se,{children:[t.jsx($,{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."}),t.jsxs($,{lead:"Put manifest.json at the zip root.",children:["The ",t.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."]}),t.jsx($,{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."}),t.jsx($,{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."}),t.jsx($,{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."})]}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"What to expect"}),t.jsxs(Se,{children:[t.jsx($,{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."}),t.jsx($,{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."})]}),t.jsx(Xt,{linkKey:"chrome.devConsole",label:"Upload and submit in the developer dashboard"}),t.jsx(Eo,{}),t.jsx(Pe,{assistKey:"submit-review",topicName:"Submit for review"}),t.jsx(Re,{label:"I've submitted for review",note:"Once approved, your store listing link is what you share to install the extension.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:e})]})}const pee=Object.freeze(Object.defineProperty({__proto__:null,SubmitReviewScreen:W_},Symbol.toStringTag,{value:"Module"})),Y4=[{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 ${Te("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 ${Te("chromeStore.fee").value} developer account if you want the unlisted-listing path (link-shareable, auto-updating, and trusted by Chrome).`}];function H_({onBack:e,onComplete:n,status:s,onRevert:r}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{icon:t.jsx(ot,{size:26}),title:"Share with testers",meta:"About 10 minutes · no public listing",onBack:e,assistKey:"share-testing"}),t.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."}),t.jsx("div",{className:"seclabel",children:"Load unpacked (zip handoff)"}),t.jsxs(Se,{children:[t.jsx($,{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."}),t.jsxs($,{lead:"Put manifest.json at the zip root.",children:["The ",t.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."]}),t.jsxs($,{lead:"Know the trade-offs.",children:["There is ",t.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."]})]}),t.jsx(Hn,{assistKey:"share-testing",topicName:"Share with testers",goalId:"zip-load-unpacked",buttonLabel:'Ask AI to help with the "Load Unpacked (Zip Handoff)" goal'}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Unlisted / private Web Store listing"}),t.jsxs(Se,{children:[t.jsxs($,{lead:"Upload to the store, but hide it.",children:["You still upload to the Chrome Web Store, but set visibility to"," ",t.jsx("b",{children:"Unlisted"})," (link-shareable, not discoverable in search) or"," ",t.jsx("b",{children:"Private"})," (restricted to named testers). Anyone with the link installs in one click — no Developer mode, no warning."]}),t.jsx($,{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."}),t.jsxs($,{lead:"It still needs the one-time developer account.",children:["An unlisted listing requires the same"," ",t.jsx("b",{children:Te("chromeStore.fee").value})," developer registration as a public one (see the ",t.jsx("b",{children:"Store accounts"})," topic). An unlisted listing also still goes through review — it just isn't publicly discoverable once approved."]})]}),t.jsx(Xt,{linkKey:"chrome.devConsole",label:"Upload an unlisted build in the developer dashboard"}),t.jsx(Hn,{assistKey:"share-testing",topicName:"Share with testers",goalId:"unlisted-listing",buttonLabel:'Ask AI to help with the "Unlisted / Private Web Store Listing" goal'}),t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Self-hosted .crx + update_url (advanced)"}),t.jsxs(Se,{children:[t.jsxs($,{lead:"Host the packed .crx and an update manifest.",children:["Pack the extension to a ",t.jsx("code",{children:".crx"}),", host it alongside an update manifest, and point the manifest's ",t.jsx("code",{children:"update_url"})," at it. This is the only path that needs no store account at all."]}),t.jsxs($,{lead:"Chrome blocks off-store .crx for ordinary users.",children:["For a normal browser profile, Chrome refuses to install an off-store",t.jsx("code",{children:".crx"}),". This path really exists for"," ",t.jsx("b",{children:"managed / enterprise"})," force-install via admin policy (e.g. a company's device management) — not for casual beta testers."]})]}),t.jsx(Hn,{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'}),t.jsx(yt,{items:Y4}),t.jsx(Eo,{}),t.jsx(Re,{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.",status:s,onComplete:()=>n==null?void 0:n(),onRevert:r,onBack:e})]})}const hee=Object.freeze(Object.defineProperty({__proto__:null,ExtensionDistributionScreen:H_},Symbol.toStringTag,{value:"Module"}));function Gn({tone:e="cost",title:n,children:s}){const r=e==="wait"?"⏳":e==="size"?"⬇":"$";return t.jsxs("div",{className:"sd-callout "+e,children:[t.jsx("span",{className:"sd-callout-ic","aria-hidden":"true",children:r}),t.jsxs("div",{children:[t.jsx("div",{className:"sd-callout-t",children:n}),t.jsx("div",{className:"sd-callout-b",children:s})]})]})}function $t({store:e,badge:n,enrollUrl:s,enrollLabel:r,children:a}){const o=e==="ios"?"Apple App Store":"Google Play",i=e==="ios"?"":"▶";return t.jsxs("div",{className:"sd-store "+e,children:[t.jsx("div",{className:"sd-store-mark","aria-hidden":"true",children:i}),t.jsxs("div",{className:"sd-store-body",children:[t.jsxs("div",{className:"sd-store-top",children:[t.jsx("span",{className:"sd-store-name",children:o}),t.jsx("span",{className:"sd-store-badge",children:n})]}),t.jsx("div",{className:"sd-store-desc",children:a}),s&&t.jsx("a",{className:"sd-store-enroll",href:s,target:"_blank",rel:"noreferrer noopener",children:r??"Enrol →"})]})]})}function Vn({items:e}){return t.jsx("div",{className:"sd-checks",children:e.map((n,s)=>t.jsxs("div",{className:"sd-check",children:[t.jsx(lt,{}),t.jsx("span",{children:n})]},s))})}const fee=Object.freeze(Object.defineProperty({__proto__:null,CheckList:Vn,CostCallout:Gn,StoreCard:$t},Symbol.toStringTag,{value:"Module"}));function fs(e){return e==="ios"||e==="both"}function Us(e){return e==="android"||e==="both"}const cf=["swift","swiftui","ios","uikit"],df=["kotlin","android","jetpack-compose"];function uf(e,n){return e&&!n?"ios":n&&!e?"android":null}function G4(e){if(!e)return"both";const n=e.platforms;if(Array.isArray(n)){const a=n.some(i=>String(i).toLowerCase().includes("ios")),o=n.some(i=>String(i).toLowerCase().includes("android"));if(a&&!o)return"ios";if(o&&!a)return"android";if(a||o)return"both"}const s=String(e.framework??"").toLowerCase();if(s){const a=uf(cf.some(o=>s.includes(o)),df.some(o=>s.includes(o)));if(a)return a}const r=String(e.id??"").toLowerCase().split("-");if(r.some(Boolean)){const a=uf(cf.some(o=>r.includes(o)),df.some(o=>r.includes(o)));if(a)return a}return"both"}function q_({platform:e="both",onBack:n,onComplete:s,status:r,onRevert:a}){const o=fs(e),i=Us(e),c=[{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 t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{onBack:n,icon:t.jsx(et,{size:26}),title:"Developer accounts",meta:"One-time setup · paid · about 20 minutes",assistKey:"dev-accounts"}),t.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."}),t.jsxs(Gn,{tone:"cost",title:"These accounts cost money up front",children:["Plan for this before you start — there's no free tier for publishing.",o&&i?" Together that's $99 the first year plus a one-time $25.":""]}),t.jsx("div",{className:"seclabel",children:"What to set up"}),o?t.jsxs($t,{store:"ios",badge:Te("appleDeveloper.fee").value,enrollUrl:"https://developer.apple.com/programs/enroll/",enrollLabel:"Enrol in the Apple Developer Program →",children:["Enrol in the ",t.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 ",t.jsx("b",{children:"up to ~2 weeks"}),", so start this well before your planned launch."]}):null,i?t.jsxs($t,{store:"android",badge:Te("googlePlay.fee").value,enrollUrl:"https://play.google.com/console/signup",enrollLabel:"Open Google Play Console signup →",children:["Register for the ",t.jsx("b",{children:"Google Play Console"})," at play.google.com/console. The fee is one-time, not yearly. ",Te("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,t.jsx(Gn,{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."}),t.jsx(yt,{items:c}),t.jsx(Pe,{assistKey:"dev-accounts",topicName:"Developer accounts"}),t.jsx(Re,{label:"Mark developer accounts as set up",note:"Do this once you've enrolled and your account is verified.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const mee=Object.freeze(Object.defineProperty({__proto__:null,DevAccountsScreen:q_},Symbol.toStringTag,{value:"Module"}));function U_({platform:e="both",onBack:n,onComplete:s,status:r,onRevert:a}){const o=fs(e),i=Us(e),c=[{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 t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{onBack:n,icon:t.jsx(Mt,{size:26}),title:"Store assets",meta:"Design work · about 1–2 hours",assistKey:"store-assets"}),t.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."}),t.jsx("div",{className:"seclabel",children:"The essentials, everywhere"}),t.jsx(Vn,{items:[t.jsxs(t.Fragment,{children:[t.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."]}),t.jsxs(t.Fragment,{children:[t.jsx("b",{children:"Screenshots"})," — captured on the exact device sizes each store asks for, not scaled-up phone shots."]}),t.jsxs(t.Fragment,{children:[t.jsx("b",{children:"No placeholder art"}),' — "lorem ipsum" screens and stock icons are the most common rejection reason.']})]}),t.jsx("div",{className:"seclabel",children:"Per store"}),o?t.jsxs($t,{store:"ios",badge:Te("appleScreenshots.iphone").value,children:["The App Store's primary iPhone set is now the ",t.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 ",Te("appleScreenshots.ipad").value," master. App previews (short videos) are optional but help conversion."]}):null,i?t.jsxs($t,{store:"android",badge:"512×512 icon + feature graphic",children:["Google Play needs a ",t.jsx("b",{children:"512×512"})," icon (not the 1024×1024 iOS master), a 1024×500 ",t.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,t.jsx(yt,{items:c}),t.jsx(Pe,{assistKey:"store-assets",topicName:"Store assets"}),t.jsx(Re,{label:"Mark store assets as ready",note:"Do this once your icon and screenshots are exported at the right sizes.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const gee=Object.freeze(Object.defineProperty({__proto__:null,StoreAssetsScreen:U_},Symbol.toStringTag,{value:"Module"}));function Y_({platform:e="both",onBack:n,onComplete:s,status:r,onRevert:a}){const o=fs(e),i=Us(e);return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{onBack:n,icon:t.jsx(Xe,{size:26}),title:"Store listing",meta:"Writing + forms · about 45 minutes",assistKey:"store-listing"}),t.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."}),t.jsx("div",{className:"seclabel",children:"Write these"}),t.jsx(Vn,{items:[t.jsxs(t.Fragment,{children:[t.jsx("b",{children:"Title & subtitle"})," — clear over clever. The first few words are what shows in search results."]}),t.jsxs(t.Fragment,{children:[t.jsx("b",{children:"Description"})," — lead with what the app does and who it's for; keep the keyword-stuffing out, both stores penalise it."]}),t.jsxs(t.Fragment,{children:[t.jsx("b",{children:"Category"})," — pick the one your app actually fits; it affects where you rank."]})]}),t.jsx("div",{className:"seclabel",children:"Privacy is required now"}),o?t.jsxs($t,{store:"ios",badge:"Nutrition labels",children:["Apple's ",t.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,i?t.jsxs($t,{store:"android",badge:"Data safety form",children:["Google Play's ",t.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,t.jsx(Pe,{assistKey:"store-listing",topicName:"Store listing"}),t.jsx(Re,{label:"Mark store listing as drafted",note:"Do this once your copy is written and the privacy form is filled in.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const xee=Object.freeze(Object.defineProperty({__proto__:null,StoreListingScreen:Y_},Symbol.toStringTag,{value:"Module"}));function G_({platform:e="both",onBack:n,onComplete:s,status:r,onRevert:a}){const o=fs(e),i=Us(e),c=[{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:Te("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 t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{onBack:n,icon:t.jsx(ot,{size:26}),title:"Testing & distribution",meta:"Build + review · hours to days",assistKey:"testing-distribution"}),t.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."}),t.jsxs(Gn,{tone:"size",title:"First native build pulls a large SDK",children:["Producing a real device build downloads the platform toolchain — often",t.jsx("b",{children:" 8–12 GB"})," and ",t.jsx("b",{children:"10–30 minutes"})," the first time. Run the iOS pre-flight checks in ",t.jsx("code",{children:"MOBILE_SETUP.md"})," before you kick it off so a missing platform SDK surfaces in seconds, not ten minutes in."]}),t.jsx("div",{className:"seclabel",children:"Get a build to testers"}),o?t.jsxs(t.Fragment,{children:[t.jsxs($t,{store:"ios",badge:"TestFlight",children:["Upload to ",t.jsx("b",{children:"TestFlight"})," from Xcode or your CI. Internal testers (up to 100 on your team) get builds instantly; ",t.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.`]}),t.jsx(Hn,{assistKey:"testing-distribution",topicName:"Testing & distribution",goalId:"prep-testflight",buttonLabel:"Ask AI to help: Prep a TestFlight upload"})]}):null,i?t.jsxs(t.Fragment,{children:[t.jsxs($t,{store:"android",badge:"Internal testing",children:["Use a Play Console ",t.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: ",Te("playStore.closedTestGate").value," ","(the 14-day clock resets below 12). Organisation accounts are generally not subject to this."]}),t.jsx(Hn,{assistKey:"testing-distribution",topicName:"Testing & distribution",goalId:"prep-play-internal",buttonLabel:"Ask AI to help: Set up Play internal testing"})]}):null,t.jsx("div",{className:"seclabel",style:{marginTop:24},children:"Get ready for store review"}),t.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."}),t.jsxs(Gn,{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 ",t.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."]}),t.jsx(Hn,{assistKey:"testing-distribution",topicName:"Testing & distribution",goalId:"prep-store-review",buttonLabel:"Ask AI to help: Get ready for store review"}),t.jsx(yt,{items:c}),t.jsx(Re,{label:"Mark testing & distribution as set up",note:"Do this once a build is on a test track and you know the review path.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const bee=Object.freeze(Object.defineProperty({__proto__:null,TestingDistributionScreen:G_},Symbol.toStringTag,{value:"Module"}));function V_({platform:e="both",onBack:n,onComplete:s,status:r,onRevert:a}){const o=fs(e),i=Us(e),c=[{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 t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{onBack:n,icon:t.jsx(iu,{size:26}),title:"Push notifications",meta:"Optional · about 1 hour",assistKey:"push-notifications"}),t.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."}),t.jsx("div",{className:"seclabel",children:"The delivery services"}),o?t.jsxs($t,{store:"ios",badge:"APNs",children:["Apple's ",t.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,i?t.jsxs($t,{store:"android",badge:"FCM",children:["Google's ",t.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,t.jsx("div",{className:"seclabel",children:"Get this right"}),t.jsx(Vn,{items:[t.jsxs(t.Fragment,{children:[t.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."]}),t.jsxs(t.Fragment,{children:[t.jsx("b",{children:"Make them opt-in and useful."})," Noisy notifications get your app muted or uninstalled."]}),t.jsxs(t.Fragment,{children:[t.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."]})]}),t.jsx(yt,{items:c}),t.jsx(Pe,{assistKey:"push-notifications",topicName:"Push notifications"}),t.jsx(Re,{label:"Mark push notifications as set up",note:"Optional — skip it if your app doesn't need to reach people when closed.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const yee=Object.freeze(Object.defineProperty({__proto__:null,PushNotificationsScreen:V_},Symbol.toStringTag,{value:"Module"}));function K_({platform:e="both",onBack:n,onComplete:s,status:r,onRevert:a}){return t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{onBack:n,icon:t.jsx(Qt,{size:26}),title:"Crash reporting",meta:"Recommended · about 30 minutes",assistKey:"crash-reporting"}),t.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."}),t.jsx("div",{className:"seclabel",children:"What you'll get"}),t.jsx(Vn,{items:[t.jsxs(t.Fragment,{children:[t.jsx("b",{children:"Stack traces"})," pointing at the exact line that failed, grouped so you see which crash hits the most people first."]}),t.jsxs(t.Fragment,{children:[t.jsx("b",{children:"Device context"})," — OS version, model, and steps — so you can reproduce instead of guessing."]}),t.jsxs(t.Fragment,{children:[t.jsx("b",{children:"Trends over time"})," so you can tell whether a release made things better or worse."]})]}),t.jsx("div",{className:"seclabel",children:"Common tools"}),t.jsxs("p",{className:"lead dim",children:[t.jsx("b",{children:"Firebase Crashlytics"})," (free, works on both platforms) and"," ",t.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."]}),t.jsxs("div",{className:"sd-callout size",children:[t.jsx("span",{className:"sd-callout-ic","aria-hidden":"true",children:"⬇"}),t.jsxs("div",{children:[t.jsx("div",{className:"sd-callout-t",children:"Upload your symbols, or reports are noise"}),t.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."})]})]}),t.jsx(Pe,{assistKey:"crash-reporting",topicName:"Crash reporting"}),t.jsx(Re,{label:"Mark crash reporting as set up",note:"Do this once an SDK is wired in and symbol upload is part of your release.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const vee=Object.freeze(Object.defineProperty({__proto__:null,CrashReportingScreen:K_},Symbol.toStringTag,{value:"Module"}));function J_({platform:e="both",onBack:n,onComplete:s,status:r,onRevert:a}){const o=fs(e),i=Us(e),c=[{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 t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{onBack:n,icon:t.jsx(kn,{size:26}),title:"In-app purchases & subscriptions",meta:"When you sell inside the app · about 30 minutes",assistKey:"in-app-purchases"}),t.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 ",t.jsx("i",{children:"their"})," billing, take a cut, and reject apps that route around it. Getting this right early saves a painful rewrite later."]}),t.jsx(Gn,{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."}),t.jsx("div",{className:"seclabel",children:"What you'll wire up"}),o?t.jsxs($t,{store:"ios",badge:Te("appStore.commission").value,children:["Use ",t.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 ",Te("appStore.commission").value,"."," ",t.jsx(Yn,{fact:Te("appStore.commission")})]}):null,i?t.jsxs($t,{store:"android",badge:Te("googlePlay.commission").value,children:["Use the ",t.jsx("b",{children:"Google Play Billing Library"})," to define products in the Play Console and launch the billing flow. Google's service fee is"," ",Te("googlePlay.commission").value,"."," ",t.jsx(Yn,{fact:Te("googlePlay.commission")})]}):null,t.jsx("div",{className:"seclabel",children:"The rule that gets apps rejected"}),t.jsx(Vn,{items:[t.jsxs(t.Fragment,{children:[t.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.']}),t.jsxs(t.Fragment,{children:[t.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."]}),t.jsxs(t.Fragment,{children:[t.jsx("b",{children:"Verify entitlements server-side."})," Validate the receipt or purchase token on your backend before unlocking — never trust the client alone."]})]}),t.jsx(yt,{items:c}),t.jsx(Pe,{assistKey:"in-app-purchases",topicName:"In-app purchases & subscriptions"}),t.jsx(Re,{label:"Mark in-app purchases as set up",note:"Do this once your products are defined and a sandbox purchase unlocks the right entitlement.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const jee=Object.freeze(Object.defineProperty({__proto__:null,InAppPurchasesScreen:J_},Symbol.toStringTag,{value:"Module"}));function X_({platform:e="both",onBack:n,onComplete:s,status:r,onRevert:a}){const o=fs(e),i=[{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 t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{onBack:n,icon:t.jsx(et,{size:26}),title:"App privacy & tracking",meta:"Submission gate · about 30 minutes",assistKey:"app-privacy"}),t.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.`}),t.jsx("div",{className:"seclabel",children:"The gates that apply everywhere"}),t.jsx(Vn,{items:[t.jsxs(t.Fragment,{children:[t.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."]}),t.jsxs(t.Fragment,{children:[t.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."]}),t.jsxs(t.Fragment,{children:[t.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."]})]}),o?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"seclabel",children:"iOS only — the tracking prompt"}),t.jsxs(Gn,{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"," ",t.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,t.jsx(yt,{items:i}),t.jsx(Pe,{assistKey:"app-privacy",topicName:"App privacy & tracking"}),t.jsx(Re,{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.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const wee=Object.freeze(Object.defineProperty({__proto__:null,AppPrivacyScreen:X_},Symbol.toStringTag,{value:"Module"}));function Q_({platform:e="both",onBack:n,onComplete:s,status:r,onRevert:a}){const o=[{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 t.jsxs("div",{className:"hosting-screen",children:[t.jsx(Ce,{onBack:n,icon:t.jsx(Xe,{size:26}),title:"Getting through review",meta:"Before you submit · about 20 minutes",assistKey:"app-review"}),t.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."}),t.jsx(Gn,{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."}),t.jsx("div",{className:"seclabel",children:"Clear these before submitting"}),t.jsx(Vn,{items:[t.jsxs(t.Fragment,{children:[t.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."]}),t.jsxs(t.Fragment,{children:[t.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."]}),t.jsxs(t.Fragment,{children:[t.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."]}),t.jsxs(t.Fragment,{children:[t.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."]})]}),t.jsx(yt,{items:o}),t.jsx(Pe,{assistKey:"app-review",topicName:"Getting through review"}),t.jsx(Re,{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.",status:r,onComplete:()=>s==null?void 0:s(),onRevert:a,onBack:n})]})}const _ee=Object.freeze(Object.defineProperty({__proto__:null,AppReviewScreen:Q_},Symbol.toStringTag,{value:"Module"})),Ti={rows:[],total:0,truncated:!1,repo:null,screenshotsRepoRelDir:"",loading:!1,error:null};function V4(e){const[n,s]=l.useState(Ti),r=(e==null?void 0:e.from)??null,a=(e==null?void 0:e.to)??null;return l.useEffect(()=>{if(r===null||a===null){s(Ti);return}let o=!1;s(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||s({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||s({...Ti,error:c instanceof Error?c.message:"Failed to load range"})}),()=>{o=!0}},[r,a]),n}function K4(e){const n={},s={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 e){if(!u.entry){d++;continue}c++;const p=u.entry.type||"other";n[p]=(n[p]??0)+1,u.commit.authorName&&r.add(u.commit.authorName),u.entry.testResults&&(s.total+=u.entry.testResults.total,s.passed+=u.entry.testResults.passed,s.failed+=u.entry.testResults.failed);for(const h of rd(u.entry.modifiedFiles??[]))o.add(h.path);for(const h of u.entry.scenarioScreenshots??[])a.has(h.name)||(a.add(h.name),i.push(h))}return{totalChanges:c,byType:n,testFilesTouched:o.size,testTotals:s,screenshots:i,contributors:[...r],hiddenCommitOnlyCount:d}}const J4=[{key:"all-time",label:"All time",shortLabel:"All time"},{key:"last-24h",label:"Last 24 hours",shortLabel:"24h"},{key:"last-3d",label:"Last 3 days",shortLabel:"3 days"},{key:"last-week",label:"Last week",shortLabel:"Week"},{key:"last-month",label:"Last month",shortLabel:"Month"}],ua=864e5;function X4(e,n){const s=n.toISOString();switch(e){case"last-24h":return{from:new Date(n.getTime()-ua).toISOString(),to:s};case"last-3d":return{from:new Date(n.getTime()-3*ua).toISOString(),to:s};case"last-week":return{from:new Date(n.getTime()-7*ua).toISOString(),to:s};case"last-month":return{from:new Date(n.getTime()-30*ua).toISOString(),to:s};case"all-time":case"custom":return null}}function Q4(e){const n=new Date(e.from),s=new Date(e.to);if(isNaN(n.getTime())||isNaN(s.getTime()))return`${e.from} – ${e.to}`;const r=p=>p.toLocaleDateString("en-US",{month:"short"}),a=r(n),o=n.getDate(),i=n.getFullYear(),c=r(s),d=s.getDate(),u=s.getFullYear();return i===u&&n.getMonth()===s.getMonth()?`${a} ${o} – ${d}, ${u}`:i===u?`${a} ${o} – ${c} ${d}, ${u}`:`${a} ${o}, ${i} – ${c} ${d}, ${u}`}function Z_({selection:e,onChange:n,now:s=new Date,counts:r}){const[a,o]=l.useState(""),[i,c]=l.useState(""),[d,u]=l.useState(e.preset==="custom"),p=g=>{u(!1),n({preset:g,range:X4(g,s)})},h=(g,x)=>{o(g),c(x),g&&x&&n({preset:"custom",range:{from:new Date(`${g}T00:00:00Z`).toISOString(),to:new Date(`${x}T23:59:59Z`).toISOString()}})},f=e.preset==="custom"||d,m="rounded-md border border-white/10 bg-transparent px-1.5 py-0.5 text-xs text-[var(--text-primary)]";return t.jsxs("div",{className:"mb-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("div",{className:Mr,role:"group","aria-label":"Time range",children:J4.map(g=>{const x=e.preset===g.key;return t.jsx("button",{type:"button",title:g.label,onClick:()=>p(g.key),"aria-pressed":x,className:$s(x,"compact"),children:g.shortLabel},g.key)})}),t.jsx("button",{type:"button",onClick:()=>u(g=>!g),"aria-expanded":d,className:`cursor-pointer rounded-md px-2 py-1 text-[12.5px] transition ${f?"text-[var(--text-primary)]":"text-[var(--text-muted)] hover:text-[var(--text-primary)]"}`,children:"Pick dates"}),r&&t.jsx(Z4,{counts:r})]}),d&&t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-3",children:[t.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-[var(--text-dim)]",children:["From",t.jsx("input",{type:"date","aria-label":"Custom range start",value:a,onChange:g=>h(g.target.value,i),className:m})]}),t.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-[var(--text-dim)]",children:["To",t.jsx("input",{type:"date","aria-label":"Custom range end",value:i,onChange:g=>h(a,g.target.value),className:m})]})]})]})}function Z4({counts:e}){const{builds:n,commits:s,total:r}=e,a=r===void 0?s:Math.max(r,s),o=r===void 0?`${s} commit${s===1?"":"s"}`:`${s} of ${a} commit${a===1?"":"s"}`;return t.jsxs("p",{"data-testid":"history-count",className:"ml-auto text-xs text-[var(--text-dim)] tabular-nums",children:[n>0&&t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[n," build",n===1?"":"s"]}),t.jsx("span",{"aria-hidden":!0,children:" · "})]}),t.jsx("span",{children:o})]})}const See=Object.freeze(Object.defineProperty({__proto__:null,HistoryRangeSelector:Z_},Symbol.toStringTag,{value:"Module"}));function e3(e){const{rangeLabel:n,summary:s,rows:r,repo:a,screenshotsRepoRelDir:o}=e,i=(a==null?void 0:a.rawUrlTemplate)??null,c=[];c.push(`# Change digest — ${n}`),c.push(""),c.push(t3(s)),s.hiddenCommitOnlyCount>0&&(c.push(""),c.push(`_${s.hiddenCommitOnlyCount} non-journaled commit${s.hiddenCommitOnlyCount===1?"":"s"} hidden._`));const d=r.filter(u=>u.entry!==null);for(const u of d){const p=u.entry;c.push(""),c.push(`## ${p.title}`),c.push(""),c.push(`- **Type:** ${p.type}`),c.push(`- **Commit:** \`${u.commit.shortSha}\``),p.description&&(c.push(""),c.push(p.description));const h=rd(p.modifiedFiles??[]);if(h.length>0){c.push(""),c.push("**Test files:**");for(const m of h)c.push(`- \`${m.path}\``)}const f=p.scenarioScreenshots??[];if(f.length>0)if(c.push(""),i)for(const m of f){if(!m.screenshotPath)continue;const g=i.replace("{sha}",u.commit.sha).replace("{path}",n3(o,m.screenshotPath));c.push(``)}else{c.push("**Screenshots (local only):**");for(const m of f)c.push(`- ${m.name}`)}}return c.join(`
|
|
51
|
+
`)}function t3(e){const n=[];n.push(`**${e.totalChanges}** change${e.totalChanges===1?"":"s"}`);const s=Object.entries(e.byType).map(([r,a])=>`${a} ${r}`);return s.length>0&&n.push(s.join(", ")),n.push(`${e.testFilesTouched} test file${e.testFilesTouched===1?"":"s"}`),e.testTotals.total>0&&n.push(`${e.testTotals.passed}/${e.testTotals.total} tests passed`),n.push(`${e.screenshots.length} screenshot${e.screenshots.length===1?"":"s"}`),n.join(" · ")}function n3(e,n){const s=e.replace(/\/+$/,""),r=n.replace(/^\/+/,"");return s?`${s}/${r}`:r}function e0({summary:e}){return t.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs",children:[t.jsxs("span",{className:"text-[var(--text-primary)]",children:[e.totalChanges," change",e.totalChanges===1?"":"s"]}),Object.entries(e.byType).map(([n,s])=>t.jsxs("span",{className:Ag(n),children:[s," ",n]},n)),t.jsxs("span",{className:"text-[var(--text-muted)]",children:[e.testFilesTouched," test file",e.testFilesTouched===1?"":"s"]}),t.jsx(yo,{total:e.testTotals.total,passed:e.testTotals.passed,failed:e.testTotals.failed}),t.jsxs("span",{className:"text-[var(--text-muted)]",children:[e.screenshots.length," screenshot",e.screenshots.length===1?"":"s"]}),e.contributors.length>0&&t.jsx("span",{className:"text-[var(--text-dim)]",children:e.contributors.join(", ")})]})}const kee=Object.freeze(Object.defineProperty({__proto__:null,HistoryDigestStatRow:e0},Symbol.toStringTag,{value:"Module"}));function t0({rangeLabel:e,summary:n,rows:s,repo:r,screenshotsRepoRelDir:a,truncated:o,onPreviewScreenshot:i}){const[c,d]=l.useState(!1),u=Rg(s),p=async()=>{const h=e3({rangeLabel:e,summary:n,rows:s,repo:r,screenshotsRepoRelDir:a});try{await navigator.clipboard.writeText(h),d(!0),setTimeout(()=>d(!1),2e3)}catch{}};return n.totalChanges===0?t.jsxs("div",{children:[t.jsx(Ll,{rangeLabel:e,onCopy:p,copied:c}),t.jsxs("div",{className:"py-10 text-center text-[var(--text-dim)]",children:[t.jsx("p",{children:"No changes in this window."}),n.hiddenCommitOnlyCount>0&&t.jsxs("p",{className:"mt-2 text-xs",children:[n.hiddenCommitOnlyCount," non-journaled commit",n.hiddenCommitOnlyCount===1?"":"s"," hidden."]})]})]}):t.jsxs("div",{children:[t.jsx(Ll,{rangeLabel:e,onCopy:p,copied:c}),t.jsx(e0,{summary:n}),n.hiddenCommitOnlyCount>0&&t.jsxs("p",{className:"mb-3 text-xs text-[var(--text-dim)]",children:[n.hiddenCommitOnlyCount," non-journaled commit",n.hiddenCommitOnlyCount===1?"":"s"," hidden from this digest."]}),o&&t.jsxs("p",{className:"mb-3 text-xs text-[var(--accent-yellow,#eab308)]",children:["Showing the ",s.length," most recent changes in this window — narrow the range to see the rest."]}),n.screenshots.length>0&&t.jsxs("div",{className:"mb-4",children:[t.jsx("p",{className:"mb-1 text-xs font-medium text-[var(--text-muted)]",children:"Screenshots"}),t.jsx(ow,{screenshots:n.screenshots,onSelect:i?h=>i({...h,isLatest:u.get(h.name)===s3(s,h.name)}):void 0})]}),t.jsx("div",{className:"flex flex-col gap-3",children:s.map((h,f)=>h.entry?t.jsx(jo,{entry:h.entry,commit:h.commit,onSelectScreenshot:i?m=>i({...m,isLatest:u.get(m.name)===f}):void 0},h.commit.sha):null)})]})}function Ll({rangeLabel:e,onCopy:n,copied:s}){return t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsx("p",{className:"text-sm font-semibold text-[var(--text-primary)]",children:e}),t.jsx("button",{type:"button",onClick:n,className:"rounded border border-[var(--border-default)] px-2.5 py-1 text-xs text-[var(--text-muted)] hover:bg-[var(--bg-subtle)]",children:s?"Copied!":"Copy summary"})]})}function s3(e,n){return e.findIndex(s=>{var r;return(((r=s.entry)==null?void 0:r.scenarioScreenshots)??[]).some(a=>a.name===n)})}const Nee=Object.freeze(Object.defineProperty({__proto__:null,DigestHeader:Ll,HistoryDigest:t0},Symbol.toStringTag,{value:"Module"}));function n0(){return t.jsxs("div",{className:"mb-4",children:[t.jsx("h2",{className:"text-lg font-medium text-[var(--text-primary)]",children:"History"}),t.jsx("p",{className:"mt-1 text-sm text-[var(--text-dim)]",children:"Everything built in this project, newest first."})]})}function s0({onPreviewScreenshot:e,onRunPlan:n}={}){const[s,r]=l.useState({preset:"all-time",range:null}),[a,o]=l.useState(void 0);return t.jsxs(Jt,{children:[t.jsx(n0,{}),t.jsx(Z_,{selection:s,onChange:r,counts:a}),s.range?t.jsx(r3,{range:s.range,onPreviewScreenshot:e,onCounts:o}):t.jsx(Gg,{onPreviewScreenshot:e,onRunPlan:n,onCounts:o})]})}function r3({range:e,onPreviewScreenshot:n,onCounts:s}){const{rows:r,truncated:a,repo:o,screenshotsRepoRelDir:i,loading:c,error:d}=V4(e);if(Yg(s,c||d?null:r),c)return t.jsx("div",{className:"py-12 text-center text-[var(--text-muted)]",children:"Loading digest..."});if(d)return t.jsx("div",{className:"py-12",children:t.jsx(tt,{text:`Failed to load digest: ${d}`,className:"text-sm text-[var(--accent-red)]",rowClassName:"justify-center"})});const u=K4(r);return t.jsx(t0,{rangeLabel:Q4(e),summary:u,rows:r,repo:o,screenshotsRepoRelDir:i,truncated:a,onPreviewScreenshot:n})}const Cee=Object.freeze(Object.defineProperty({__proto__:null,HistoryTab:s0,HistoryTabHeader:n0},Symbol.toStringTag,{value:"Module"})),r0=1,ar={sound:"soft-double-tap",systemNotification:!0,idleOnStop:!0,idleOnNotification:!0,settingsVersion:r0},Fl=[{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"}],a0="codeyam-editor-notifications";function o0(){try{const e=localStorage.getItem(a0);if(!e)return ar;const n=JSON.parse(e),s={...ar,...n};return typeof(n==null?void 0:n.settingsVersion)!="number"&&(s.idleOnStop=ar.idleOnStop,s.settingsVersion=r0),s}catch{return ar}}function i0(e){localStorage.setItem(a0,JSON.stringify(e))}const a3={"soft-double-tap":e=>([0,.12].forEach(n=>{const s=e.createOscillator(),r=e.createGain();s.connect(r),r.connect(e.destination),s.type="sine",s.frequency.value=392,r.gain.setValueAtTime(.25,e.currentTime+n),r.gain.exponentialRampToValueAtTime(.01,e.currentTime+n+.1),s.start(e.currentTime+n),s.stop(e.currentTime+n+.1)}),{count:2,longestStopSec:.22}),"gentle-chime":e=>{const n=e.createOscillator(),s=e.createGain();return n.connect(s),s.connect(e.destination),n.type="sine",n.frequency.setValueAtTime(523,e.currentTime),n.frequency.setValueAtTime(659,e.currentTime+.15),s.gain.setValueAtTime(.3,e.currentTime),s.gain.exponentialRampToValueAtTime(.01,e.currentTime+.4),n.start(),n.stop(e.currentTime+.4),{count:1,longestStopSec:.4}},"warm-ding":e=>{const n=e.createOscillator(),s=e.createGain();return n.connect(s),s.connect(e.destination),n.type="sine",n.frequency.value=330,s.gain.setValueAtTime(.35,e.currentTime),s.gain.exponentialRampToValueAtTime(.01,e.currentTime+.6),n.start(),n.stop(e.currentTime+.6),{count:1,longestStopSec:.6}},"mellow-two-tone":e=>{const n=e.createOscillator(),s=e.createGain();return n.connect(s),s.connect(e.destination),n.type="sine",n.frequency.setValueAtTime(294,e.currentTime),n.frequency.setValueAtTime(440,e.currentTime+.18),s.gain.setValueAtTime(.3,e.currentTime),s.gain.exponentialRampToValueAtTime(.01,e.currentTime+.5),n.start(),n.stop(e.currentTime+.5),{count:1,longestStopSec:.5}},"triangle-bell":e=>{const n=e.createOscillator(),s=e.createGain();return n.connect(s),s.connect(e.destination),n.type="triangle",n.frequency.value=523,s.gain.setValueAtTime(.4,e.currentTime),s.gain.exponentialRampToValueAtTime(.01,e.currentTime+.8),n.start(),n.stop(e.currentTime+.8),{count:1,longestStopSec:.8}}};function Pi(e,n){const s=n;pe(e,{name:s==null?void 0:s.name,message:s==null?void 0:s.message})}function ju(e){if(e==="off")return;pe("audio-playsound-entered",{soundId:e});let n;try{n=new AudioContext}catch(r){Pi("audio-context-failed",r);return}pe("audio-context-created",{state:n.state});const s=()=>{let r;try{r=a3[e](n)}catch(a){Pi("audio-context-failed",a),n.close().catch(()=>{});return}pe("audio-oscillators-scheduled",{soundId:e,count:r.count,longestStopSec:r.longestStopSec}),setTimeout(()=>{n.close().then(()=>pe("audio-context-closed")).catch(()=>{})},(r.longestStopSec+.1)*1e3)};n.state==="running"?s():n.state==="suspended"?(pe("audio-context-resume-attempted"),n.resume().then(()=>{pe("audio-context-resume-ok",{state:n.state}),s()},r=>{Pi("audio-context-resume-failed",r),n.close().catch(()=>{})})):(pe("audio-context-failed",{name:"UnexpectedState",message:`AudioContext state "${n.state}"`}),n.close().catch(()=>{}))}function $l({label:e,checked:n,onChange:s,className:r}){return t.jsxs("label",{className:`flex items-center gap-2 cursor-pointer${r?` ${r}`:""}`,children:[t.jsx("input",{type:"checkbox",checked:n,onChange:a=>s(a.target.checked),className:"accent-green-500"}),t.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:e})]})}const Tee=Object.freeze(Object.defineProperty({__proto__:null,IdleTriggerCheckbox:$l},Symbol.toStringTag,{value:"Module"}));function l0({settings:e,onChange:n,providerLabel:s,soundAsSubmenu:r=!1}){var u;const a=e.idleOnStop??!0,o=e.idleOnNotification??!0,[i,c]=l.useState(!1),d=t.jsx("div",{className:"flex flex-col gap-0.5",children:Fl.map(p=>t.jsx("button",{onClick:()=>{n({...e,sound:p.id}),p.id!=="off"&&ju(p.id)},className:"text-left text-[11px] px-2 py-1 rounded cursor-pointer transition-colors whitespace-nowrap",style:{background:e.sound===p.id?"var(--bg-input)":"transparent",color:e.sound===p.id?"var(--text-primary)":"var(--text-secondary)"},children:p.label},p.id))});return t.jsxs(t.Fragment,{children:[r?t.jsxs("div",{className:"relative",children:[t.jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":i,"data-testid":"notification-sound-row",onClick:()=>c(p=>!p),className:"w-full flex items-center gap-2 text-[11px] px-2 py-1 rounded cursor-pointer transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-secondary)"},children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:"Sound"}),t.jsx("span",{className:"ml-auto truncate",style:{color:"var(--text-primary)"},children:((u=Fl.find(p=>p.id===e.sound))==null?void 0:u.label)??""}),t.jsx("span",{"aria-hidden":"true",children:"›"})]}),i&&t.jsx("div",{role:"menu","data-testid":"notification-sound-menu",className:"absolute right-full top-0 mr-2 rounded-lg shadow-xl p-2 z-50",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:d})]}):t.jsxs("div",{children:[t.jsx("div",{className:"text-[11px] mb-1.5",style:{color:"var(--text-muted)"},children:"Notification sound"}),d]}),t.jsxs("div",{className:"pt-2",style:{borderTop:"1px solid var(--border-default)"},children:[t.jsx("div",{className:"text-[11px] mb-1.5",style:{color:"var(--text-muted)"},children:"Trigger idle on"}),t.jsx($l,{label:`${s} stops`,checked:a,onChange:p=>n({...e,idleOnStop:p})}),t.jsx($l,{label:`${s} sends a notification`,checked:o,onChange:p=>n({...e,idleOnNotification:p}),className:"mt-1"})]}),t.jsxs("div",{className:"pt-2",style:{borderTop:"1px solid var(--border-default)"},children:[t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:e.systemNotification,onChange:p=>{const h=p.target.checked;n({...e,systemNotification:h}),h&&typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},className:"accent-green-500"}),t.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"System notification"})]}),t.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"&&t.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 Pee=Object.freeze(Object.defineProperty({__proto__:null,NotificationSettingsControls:l0},Symbol.toStringTag,{value:"Module"})),c0="codeyam-editor-notifications-prompted",o3="codeyam-editor-notifications";function d0(){try{localStorage.setItem(c0,"1")}catch{}}function i3(){try{return localStorage.getItem(c0)!==null||localStorage.getItem(o3)!==null}catch{return!0}}function u0({settings:e,onChange:n,providerLabel:s}){const[r,a]=l.useState(()=>!i3());if(!r)return null;const o=()=>{d0(),a(!1)},i=()=>{n({...e,systemNotification:!0}),typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission(),o()};return t.jsxs("div",{className:"rounded-lg px-4 py-2.5 mb-3 flex items-center gap-3",style:{background:"color-mix(in srgb, var(--blue-300) 7%, var(--surface-card))",border:"1px solid color-mix(in srgb, var(--blue-300) 45%, transparent)"},children:[t.jsx("svg",{"aria-hidden":"true",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--blue-300)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:t.jsx("path",{d:"M10 5a2 2 0 1 1 4 0a7 7 0 0 1 4 6v3a4 4 0 0 0 2 3H4a4 4 0 0 0 2-3v-3a7 7 0 0 1 4-6M9 17v1a3 3 0 0 0 6 0v-1"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--text-strong)"},children:["Get notified when ",s," finishes"]}),t.jsx("span",{style:{fontSize:"12px",color:"var(--text-faint)",marginLeft:8},children:"We'll ping you when the agent stops or pauses."})]}),t.jsx("button",{onClick:i,className:"shrink-0 cursor-pointer transition-colors",style:{background:"var(--blue-300)",color:"var(--surface-page)",fontSize:"12.5px",fontWeight:600,borderRadius:9,padding:"7px 14px"},children:"Enable"}),t.jsx("button",{onClick:o,className:"shrink-0 cursor-pointer",style:{color:"var(--text-faint)",fontSize:"12px"},children:"Not now"})]})}const Oee=Object.freeze(Object.defineProperty({__proto__:null,NotificationSetupBanner:u0},Symbol.toStringTag,{value:"Module"})),l3="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 c3(){const e=typeof Notification<"u"?Notification.permission:"unknown",n=typeof document<"u"&&typeof document.hasFocus=="function"?document.hasFocus():!1,s=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:e,hasFocus:n,hidden:s,idleDebug:r,userAgent:a}}function pf(e){return e.length===0?"_(no events in window)_":`\`\`\`jsonl
|
|
52
|
+
${e.map(s=>JSON.stringify(s)).join(`
|
|
53
|
+
`)}
|
|
54
|
+
\`\`\``}function Oi(e,n){return e.trim().length===0?`_(${n} empty)_`:`\`\`\`
|
|
55
|
+
${e}
|
|
56
|
+
\`\`\``}function d3(e){var b,y,v;const{bundle:n,browser:s,uiBufferText:r,prompt:a,agentName:o}=e,i=(n==null?void 0:n.now)??new Date().toISOString(),c=(n==null?void 0:n.session)??Qc(),d=(n==null?void 0:n.windowMinutes)??10,u=((b=n==null?void 0:n.environment)==null?void 0:b.editorVersion)??"unknown",p=((y=n==null?void 0:n.environment)==null?void 0:y.platform)??"unknown",h=((v=n==null?void 0:n.environment)==null?void 0:v.projectDir)??"unknown",f=(a??l3).trim(),m=[`- Notification.permission: ${s.notificationPermission}`,`- document.hasFocus(): ${s.hasFocus}`,`- document.hidden: ${s.hidden}`,`- localStorage.codeyam.idleDebug: ${s.idleDebug===null?"(unset)":JSON.stringify(s.idleDebug)}`,`- userAgent: ${s.userAgent}`].join(`
|
|
57
|
+
`),g=n&&n.truncations.length>0?`> **Truncations:** ${n.truncations.join("; ")}`:"";return["# CodeYam Notification Debug Bundle","",f,"","---","",`**Captured:** ${i}`,`**UI session:** ${c} (window: last ${d} minutes)`,`**Editor version:** ${u}`,`**Platform:** ${p}`,`**Project:** ${h}`,o?`**Agent:** ${o}`:null,"","**Browser state:**",m,"",g,"","## UI idle trace (persisted)","",pf((n==null?void 0:n.uiTrace)??[]),"","## UI idle trace (in-memory ring buffer — may be ahead of persisted)","",Oi(r,"in-memory buffer"),"","## Rust idle trace","",pf((n==null?void 0:n.rustTrace)??[]),"","## editor-server.log (filtered to idle= within window)","",Oi((n==null?void 0:n.editorServerLog)??"","editor-server.log"),"","## dev-server.log (last lines)","",Oi((n==null?void 0:n.devServerLog)??"","dev-server.log"),""].filter(j=>j!==null).join(`
|
|
58
|
+
`)}async function u3(e={}){const n=encodeURIComponent(Qc());let s=null,r=null;try{const c=await fetch(`/api/idle-trace/bundle?session=${n}&minutes=10`);c.ok?s=await c.json():r=`HTTP ${c.status}`}catch(c){r=c instanceof Error?c.message:String(c)}const a=c3(),o=fE({agentName:e.agentName});return{markdown:d3({bundle:s,browser:a,uiBufferText:o,prompt:e.prompt,agentName:e.agentName}),bundle:s,error:r}}const p3=1500;function h3(e=p3){const[n,s]=l.useState(null),r=l.useRef(null),a=l.useCallback((o,i)=>{r.current!==null&&clearTimeout(r.current),s(o),r.current=setTimeout(()=>{s(null),r.current=null},i??e)},[e]);return l.useEffect(()=>()=>{r.current!==null&&(clearTimeout(r.current),r.current=null)},[]),{label:n,flash:a}}const f3=2500;function p0({agentName:e}){const[n,s]=l.useState(!1),{label:r,flash:a}=h3(f3),o=async()=>{s(!0);const{markdown:i,bundle:c,error:d}=await u3({agentName:e});try{await navigator.clipboard.writeText(i);const u=((c==null?void 0:c.uiTrace.length)??0)+((c==null?void 0:c.rustTrace.length)??0),p=Math.round(i.length/1024*10)/10,h=d?`Copied (offline — ${u} events, ${p} KB)`:`Copied ${u} events · ${p} KB`;a(h)}catch{a("Copy failed")}finally{s(!1)}};return t.jsx("button",{onClick:()=>void o(),disabled:n,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??(n?"Gathering bundle…":"Debug Notifications")})}const Ree=Object.freeze(Object.defineProperty({__proto__:null,DebugNotificationsButton:p0},Symbol.toStringTag,{value:"Module"}));function h0(){const[e,n]=l.useState(null);return l.useEffect(()=>{fetch("/api/editor-setup-answers").then(s=>{if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}).then(s=>{n(s!==null)}).catch(()=>{n(!1)})},[]),{saved:e}}function m3(e){return e==="waiting-for-auth"||e==="dispatching"||e==="delayed"||e==="launch-timeout"||e==="unverified"}const g3=3e3;function Uo(){const[e,n]=l.useState(void 0),[s,r]=l.useState(0);l.useEffect(()=>{let o=!1;return fetch("/api/editor-build-requests/current").then(i=>{if(!i.ok)throw new Error(`HTTP ${i.status}`);return i.json()}).then(i=>{o||n(i.request??null)}).catch(()=>{o||n(null)}),()=>{o=!0}},[s]);const a=m3(e==null?void 0:e.state);return l.useEffect(()=>{if(!a)return;const o=setTimeout(()=>r(i=>i+1),g3);return()=>clearTimeout(o)},[a,e]),e}function f0({appStatsLength:e,configLoading:n,scenariosLoading:s,setupAnswersSaved:r,hasStepState:a}){return e===0&&!n&&!s&&r===!1&&!a}const x3={building:{headline:"Building your project…",explanation:"Your app will appear here as it’s built. The agent is working on it now on the Build tab — open it to follow along."},preparing:{headline:"Starting your build…",explanation:"Your answers are saved and the agent is starting. It keeps going even if you close this tab."},"waiting-for-auth":{headline:"Waiting for you to sign in",explanation:"Your build request is saved. The agent will start on its own as soon as you sign in to your AI provider — no need to come back to this page."},"launch-delayed":{headline:"Your build is taking longer to start",explanation:"Your answers are saved and the agent was started, but it hasn’t picked up its first instruction yet. Nothing has been stopped — it’s still starting."},"launch-timeout":{headline:"Your build hasn’t started yet",explanation:"Your answers are saved and the agent was started, but it still hasn’t picked up its first instruction. You can retry the launch — it never starts a second agent."},failed:{headline:"Your build couldn’t start",explanation:"Your answers are saved, but the agent could not be started. Open the Build tab to try again."},unconfirmed:{headline:"Build status unknown",explanation:"We can’t confirm build status right now — the editor couldn’t reach the process that runs the agent. Open the Build tab to check on it."},interrupted:{headline:"Your build was interrupted",explanation:"A build was started for this project, but it is no longer running. Open the Build tab to resume it or start again."},"not-started":{headline:"Build not started",explanation:"Your answers are saved, but no build is running yet. Open the Build tab to start building your app."}};function m0({projectDescription:e,status:n="not-started",buildRequestedAt:s=null,failureReason:r=null,launchRecovery:a=null}){const{headline:o,explanation:i}=x3[n];return t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:"text-xl font-semibold",children:o}),t.jsx("blockquote",{className:"mt-4 border-l-2 border-[var(--accent-active)] pl-4 text-sm italic text-[var(--text-dim)]",children:e}),t.jsx("p",{className:"mt-6 text-sm text-[var(--text-dim)]",children:i}),n==="failed"&&r?t.jsxs("p",{className:"mt-3 text-sm text-[var(--text-primary)]",children:[t.jsx("span",{className:"font-medium",children:"What went wrong:"})," ",r]}):null,a?t.jsx("div",{className:"mt-4",children:a}):null,t.jsx(cb,{requestedAt:s})]})}const Eee=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewEmptyStateBuildingPanel:m0},Symbol.toStringTag,{value:"Module"}));function g0(){return t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:"text-xl font-semibold",children:"No app scaffolded yet"}),t.jsxs("p",{className:"mt-4 text-sm text-[var(--text-dim)]",children:["Your project hasn’t been scaffolded yet. Open the"," ",t.jsx("strong",{children:"Build"})," tab to start building."]})]})}const Aee=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewEmptyStateNoAppPanel:g0},Symbol.toStringTag,{value:"Module"}));function x0({onClick:e}){return t.jsx("button",{type:"button",onClick:e,"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 Mee=Object.freeze(Object.defineProperty({__proto__:null,OpenBuildTabButton:x0},Symbol.toStringTag,{value:"Module"}));function b0({projectDescription:e,status:n="not-started",buildRequestedAt:s=null,failureReason:r=null,launchRecovery:a=null,onOpenBuildTab:o}){const i=e!==null&&e.trim().length>0;return t.jsxs("div",{className:"mx-auto max-w-2xl px-5 py-12 text-[var(--text-primary)]",children:[i?t.jsx(m0,{projectDescription:e,status:n,buildRequestedAt:s,failureReason:r,launchRecovery:a}):t.jsx(g0,{}),t.jsx(x0,{onClick:o})]})}const Iee=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewEmptyState:b0},Symbol.toStringTag,{value:"Module"})),b3={"launch-in-flight":"A launch is already under way — give it a moment.","worker-unknown":"The editor couldn’t check whether the agent is still running, so it didn’t start another. Try again shortly.","not-applicable":"This build is no longer waiting to start."};function y3(e){return b3[e??""]??"The retry didn’t start."}function y0(e){const n=(e==null?void 0:e.state)==="delayed"||(e==null?void 0:e.state)==="launch-timeout",[s,r]=l.useState(()=>Date.now()),[a,o]=l.useState(!1),[i,c]=l.useState(null),[d,u]=l.useState(null),p=(e==null?void 0:e.id)??null;l.useEffect(()=>{if(!n)return;const m=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(m)},[n]),l.useEffect(()=>{c(null),u(null)},[p,e==null?void 0:e.state]);const h=l.useCallback(()=>{p&&(o(!0),c(null),fetch(`/api/editor-build-requests/${p}/retry-launch`,{method:"POST"}).then(m=>m.json()).then(m=>{m.success||c(y3(m.outcome))}).catch(()=>c("The editor couldn’t be reached to retry.")).finally(()=>o(!1)))},[p]),f=l.useCallback(()=>{p&&fetch(`/api/editor-build-requests/${p}/launch-log`).then(m=>m.json()).then(m=>u(m.events??[])).catch(()=>u([]))},[p]);return{waitSeconds:e?iI(e,s):null,onRetry:h,retryPending:a,retryMessage:i,onViewLog:f,launchLog:d}}function v0({stats:e,onSelectApp:n,testsLoading:s,testsRefreshing:r,onRunTests:a,currentRunner:o}){return t.jsx("div",{className:"flex flex-col gap-4",children:e.map(i=>t.jsx(Vj,{stats:i,onClick:()=>n(i.app.dir),testsLoading:s,testsRefreshing:r,onRunTests:a,currentRunner:o},i.app.dir))})}const Dee=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewGrid:v0},Symbol.toStringTag,{value:"Module"}));function j0({projectTitle:e,coverage:n,onCoverageClick:s}){return t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)]",children:e}),t.jsx(au,{coverage:n,testId:"app-overview-coverage",onClick:s})]})}const Lee=Object.freeze(Object.defineProperty({__proto__:null,AppOverviewHeader:j0},Symbol.toStringTag,{value:"Module"}));function w0(){return t.jsxs("span",{className:"hbuild-dots","aria-hidden":"true",children:[t.jsx("span",{children:"."}),t.jsx("span",{children:"."}),t.jsx("span",{children:"."})]})}const Fee=Object.freeze(Object.defineProperty({__proto__:null,AnimatedEllipsis:w0},Symbol.toStringTag,{value:"Module"}));function _0({screenshotPath:e}){return t.jsx("span",{className:"hbuild-thumb",children:e?t.jsx(kt,{screenshotPath:e,alt:""}):t.jsx("span",{className:"hbuild-nothumb",children:"No preview yet"})})}const $ee=Object.freeze(Object.defineProperty({__proto__:null,BuildingCardThumbnail:_0},Symbol.toStringTag,{value:"Module"})),v3=28,j3=21,w3=4,_3=5,S3={1:"Plan",2:"Explore",3:"Confirm",4:"Prepare",5:"Seed Data",6:"Live Preview Loop",7:"Verify Prototype",8:"Confirm Mode",9:"Prepare Demo",10:"Approve Demo",11:"Deconstruct",12:"Extract TDD",13:"Glossary",14:"Dependency Graph",15:"Isolation Routes",16:"Component Coverage",17:"Register Scenarios",18:"Capture Scenarios",19:"Curate Scenarios",20:"App Scenarios",21:"Present",22:"Reconcile",23:"Journal",24:"Pre-Commit Sync",25:"Finalize",26:"Commit",27:"Push",28:"Feature Complete"},k3={1:"Plan",2:"Explore",3:"Confirm Plan",4:"Prepare",5:"Prototype",6:"Confirm Mode",7:"Approve Demo",8:"Deconstruct",9:"Extract TDD",10:"Test Tooling",11:"Glossary",12:"Dependency Graph",13:"Present",14:"Review",15:"Reconcile",16:"Journal",17:"Pre-Commit Sync",18:"Finalize",19:"Commit",20:"Push",21:"Feature Complete"},N3={1:"Triage",2:"Route",3:"Wrap Up",4:"Complete"},C3={1:"Ground",2:"Generate",3:"Iterate",4:"Resolve",5:"Return"},T3={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 extracted visual component.",16:"Decide per-component scenario coverage (multi-state or untestability) for every isolated component.",17:"Register component-level scenarios (one per state) for every visual component.",18:"Capture and verify component-level scenarios; gate on visual coverage before advancing.",19:"Curate the existing app-scenario set — review, consolidate, dedup, and edit in place — before registering new scenarios.",20:"Create app-level scenarios that show full pages with realistic data.",21:"Final approval gate — recapture screenshots and present a summary of all work to the user.",22:"Run the audit gate, reconcile any registry/glossary drift until clean.",23:"Create or update the journal entry documenting what was built.",24:"Sync local state with the remote so the next commit lands on a merged tree.",25:"Finalize the session — run the full suite once.",26:"Commit all changes to git.",27:"Push the branch to the remote repository.",28:"Fire the feature-complete modal — the cycle ends here."},P3={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:"Test-runner and tooling discipline for the backend extract-TDD loop.",11:"Register every new test and glossary entry produced in the prior step.",12:"Rebuild the dependency graph after extraction.",13:"Author the session narrative in full, then present the /results page with the behavior gallery, tests, and changed files.",14:"Review the results page with the user — summary, ways-to-test, weakened-test flag, audit status — and gate on the Save / Fast-Commit / change decision.",15:"Run the audit gate, reconcile any registry/glossary drift until clean.",16:"Re-validate the session narrative, reconciling only what changed since Present, then create the journal entry.",17:"Sync local state with the remote so the next commit lands on a merged tree.",18:"Finalize the session — run the full suite once.",19:"Commit all changes to git.",20:"Push the branch to the remote repository.",21:"Fire the feature-complete modal — the cycle ends here."},O3={1:"Read how legible the request is: a build, a clear non-build, or a request whose goal the user has not settled yet.",2:"Route the classified request: hand off to a build flow, work it directly, or orient a user who does not yet know what they want.",3:"Inventory what changed on disk and decide with the user what, if anything, to commit.",4:"Return the editor to the beginning state so a build or another assist request can start."},R3={1:"Establish what the surface being modified actually looks like today before generating any mockup.",2:"Generate the round's mockups as variations grounded in the current state.",3:"Dwell here: iterate with the user until they pick a direction or abandon the round.",4:"Resolve the round — attach the selected design to the work in flight, or archive and discard.",5:"Return control to the invoking context — the build session's prototype phase or the ad-hoc caller."},E3={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:"Checking component coverage",17:"Registering component snapshots",18:"Capturing component snapshots",19:"Curating existing snapshots",20:"Capturing whole-page snapshots",21:"Showing you the final review",22:"Reconciling everything",23:"Writing a journal entry",24:"Syncing with the latest",25:"Finalizing the build",26:"Saving your changes",27:"Pushing your work",28:"All done"},A3={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:"Setting up test tooling",11:"Documenting the building blocks",12:"Mapping connections in your code",13:"Putting together your results",14:"Showing you the final review",15:"Reconciling everything",16:"Writing a journal entry",17:"Syncing with the latest",18:"Finalizing the build",19:"Saving your changes",20:"Pushing your work",21:"All done"},M3={1:"Working out what you need",2:"Deciding how to help",3:"Checking this is what you wanted",4:"All done"},I3={1:"Learning what you like",2:"Sketching some options",3:"Refining the design with you",4:"Applying the design you picked",5:"Back to building"},D3=[{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,8,9,10]},{phaseId:"tidy",phaseLabel:"Making the code maintainable",phaseSteps:[11,12,13,14,15,16,17,18,19,20]},{phaseId:"review",phaseLabel:"Final Review",phaseSteps:[21,22,23,24,25]},{phaseId:"save",phaseLabel:"Saving your work",phaseSteps:[26,27,28]}],L3=[{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,12]},{phaseId:"review",phaseLabel:"Final Review",phaseSteps:[13,14,15,16,17,18]},{phaseId:"save",phaseLabel:"Saving your work",phaseSteps:[19,20,21]}],F3=[{phaseId:"assist-understand",phaseLabel:"Working out what you need",phaseSteps:[1]},{phaseId:"assist-act",phaseLabel:"Getting it done",phaseSteps:[2]},{phaseId:"assist-finish",phaseLabel:"Wrapping up",phaseSteps:[3,4]}],$3=[{phaseId:"design-understand",phaseLabel:"Learning what you like",phaseSteps:[1]},{phaseId:"design-explore",phaseLabel:"Exploring some looks",phaseSteps:[2,3]},{phaseId:"design-finish",phaseLabel:"Settling on a direction",phaseSteps:[4,5]}],z3={ui:S3,backend:k3,assist:N3,design:C3},B3={ui:T3,backend:P3,assist:O3,design:R3},W3={ui:v3,backend:j3,assist:w3,design:_3},H3={ui:"UI Flow",backend:"Backend Flow",assist:"Assist Flow",design:"Design Round"},q3=["ui","backend","assist","design"];function Ut(e){return q3.includes(e)?e:"ui"}function wu(e,n){return z3[Ut(n)][e]??"?"}function S0(e,n){return B3[Ut(n)][e]??""}function _u(e){return W3[Ut(e)]}function k0(e){return H3[Ut(e)]}function N0(e,n){const s=Ut(n);return{description:S0(e,s),label:wu(e,s),prefix:k0(s),totalSteps:_u(s)}}const U3={ui:E3,backend:A3,assist:M3,design:I3},Y3={ui:D3,backend:L3,assist:F3,design:$3};function C0(e,n){return U3[Ut(n)][e]??""}function Su(e){return Y3[Ut(e)]}function G3(e,n){const s=Su(n);return s.find(a=>a.phaseSteps.includes(e))??s[0]}function V3(e,n){var r;const s=Ut(n);return{...ku(e,s),phaseLabel:((r=G3(e,s))==null?void 0:r.phaseLabel)??"",description:S0(e,s)}}function ku(e,n){const s=Ut(n);return K3(C0(e,s),wu(e,s))}function K3(e,n){return e===""||e===n?{primary:e||n,secondary:null}:{primary:e,secondary:n}}function T0({position:e,phase:n,mode:s}){return!s&&!e?null:t.jsxs("span",{className:"hbuild-step",children:[s?t.jsx("span",{className:"hbuild-flow",children:k0(s)}):null,e?t.jsxs("span",{className:"hbuild-pos",children:["Step ",e,":"]}):null,n?t.jsx("span",{className:"hbuild-phase",children:n}):null]})}const zee=Object.freeze(Object.defineProperty({__proto__:null,BuildingStepLine:T0},Symbol.toStringTag,{value:"Module"})),J3={building:{state:"Working",ellipsis:!0,attn:!1},"needs-input":{state:Ba,ellipsis:!1,attn:!0},waiting:{state:Ba,ellipsis:!1,attn:!0}};function P0({feature:e,stepLabel:n,stepPosition:s=null,status:r="building",progress:a=null,mode:o,thumbnailPath:i=null,onOpen:c}){const d=J3[r],u=r==="building";return t.jsxs("button",{type:"button",className:"hbuild-card active"+(d.attn?" attn":""),onClick:c,children:[t.jsx(_0,{screenshotPath:i}),t.jsxs("span",{className:"hbuild-main",children:[t.jsxs("span",{className:"hbuild-title",children:[u?t.jsx("span",{className:"hbuild-spinner","aria-hidden":"true"}):null,e,t.jsxs("span",{className:"hbuild-state",children:[d.state,d.ellipsis?t.jsx(w0,{}):null]})]}),t.jsx(T0,{position:s,phase:n,mode:o}),u?t.jsx("span",{className:"hbuild-bar",children:t.jsx("span",{style:{width:a!=null?`${Math.round(a*100)}%`:"12%"}})}):null]}),t.jsxs("span",{className:"hbuild-cta",children:["Build ",t.jsx("span",{"aria-hidden":"true",children:"→"})]})]})}const Bee=Object.freeze(Object.defineProperty({__proto__:null,BuildingCardActive:P0},Symbol.toStringTag,{value:"Module"}));function O0({lastBuiltLabel:e,onStart:n}){return t.jsxs("button",{type:"button",className:"hbuild-card",onClick:n,children:[t.jsxs("span",{className:"hbuild-main",children:[t.jsx("span",{className:"hbuild-ready",children:"Ready to build?"}),e?t.jsxs("span",{className:"hbuild-last",children:["Your last build: ",t.jsx("b",{children:e})]}):null]}),t.jsxs("span",{className:"hbuild-cta",children:["Build ",t.jsx("span",{"aria-hidden":"true",children:"→"})]})]})}const Wee=Object.freeze(Object.defineProperty({__proto__:null,BuildingCardIdle:O0},Symbol.toStringTag,{value:"Module"}));function R0({onReset:e}){return t.jsxs("button",{type:"button","data-testid":"build-status-reset",onClick:e,className:"hbuild-reset",children:[t.jsx("span",{"aria-hidden":"true",children:"⊗"})," Reset build"]})}const Hee=Object.freeze(Object.defineProperty({__proto__:null,BuildResetLink:R0},Symbol.toStringTag,{value:"Module"}));function E0({onReset:e}){const[n,s]=l.useState(!1),r=l.useRef(null);return l.useEffect(()=>{if(!n)return;const a=i=>{var c;(c=r.current)!=null&&c.contains(i.target)||s(!1)},o=i=>{i.key==="Escape"&&s(!1)};return document.addEventListener("mousedown",a),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("keydown",o)}},[n]),t.jsxs("div",{className:"hbuild-menu",ref:r,children:[t.jsx("button",{type:"button",className:"hbuild-menu-btn","aria-label":"More build actions",title:"More build actions","aria-expanded":n,onClick:()=>s(a=>!a),children:t.jsx("span",{"aria-hidden":"true",children:"···"})}),n?t.jsx("div",{className:"hbuild-menu-pop","data-testid":"build-card-menu",children:t.jsx(R0,{onReset:()=>{s(!1),e()}})}):null]})}const qee=Object.freeze(Object.defineProperty({__proto__:null,BuildCardMenu:E0},Symbol.toStringTag,{value:"Module"}));function Nu({isBuilding:e,buildingLabel:n,buildingStepLabel:s,buildingStepPosition:r=null,buildingStatus:a="building",buildingProgress:o=null,buildingMode:i,thumbnailPath:c=null,lastBuiltLabel:d,onOpenBuilding:u,onStartNewFeature:p,onResetBuild:h}){return e?t.jsxs("div",{className:"hbuild-wrap"+(h?" has-menu":""),children:[t.jsx(P0,{feature:n||"your latest change",stepLabel:s,stepPosition:r,status:a,progress:o,mode:i,thumbnailPath:c,onOpen:u}),h?t.jsx(E0,{onReset:h}):null]}):t.jsx(O0,{lastBuiltLabel:d,onStart:p??u})}const Uee=Object.freeze(Object.defineProperty({__proto__:null,BuildingDoor:Nu},Symbol.toStringTag,{value:"Module"}));function A0({isBuilding:e,buildingLabel:n,buildingStepLabel:s,buildingStepPosition:r=null,buildingStatus:a="building",buildingProgress:o=null,buildingMode:i,onOpenBuilding:c,onResetBuild:d}){return e?t.jsx("section",{"data-testid":"home-build-status-section",className:"mt-6 mb-6",children:t.jsx(Nu,{isBuilding:e,buildingLabel:n,buildingStepLabel:s,buildingStepPosition:r,buildingStatus:a,buildingProgress:o,buildingMode:i,onOpenBuilding:c,onStartNewFeature:c,onResetBuild:d})}):null}const Yee=Object.freeze(Object.defineProperty({__proto__:null,HomeBuildStatusSection:A0},Symbol.toStringTag,{value:"Module"}));async function Ri(e,n){try{const s=await e.json();if(typeof s.error=="string"&&s.error)return`${n} failed (${e.status}): ${s.error}`}catch{}return`${n} failed (${e.status})`}function Ei(e,n){return fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}async function M0(e,n){const s=hg(),r=(o,i,c)=>(el({launchId:s,role:"build",event:"submit-failed",stage:o,httpStatus:c}),{ok:!1,launchId:s,error:i});let a;try{if(e.description){const u=await Ei("/api/editor-project-info",{projectDescription:e.description,allowOverwrite:!0});if(!u.ok)return r("project-info",await Ri(u,"Saving the description"),u.status)}const o={appFormats:e.appFormats,techStackId:e.techStackId,designApproach:e.designApproach};e.defaultDevice&&(o.defaultDevice=e.defaultDevice);const i=await Ei("/api/editor-setup-answers",o);if(!i.ok)return r("setup-answers",await Ri(i,"Saving the answers"),i.status);const c=await Ei("/api/editor-build-requests",n?{submissionKey:n}:{});if(!c.ok)return r("build-request",await Ri(c,"Recording the build request"),c.status);const d=await c.json();if(typeof d.requestId!="string"||!d.requestId)return r("build-request","The server did not return a request id",c.status);a=d.requestId}catch(o){return r("network",o instanceof Error?o.message:"Could not reach the editor")}return el({launchId:s,role:"build",event:"submitted"}),fR(s),{ok:!0,launchId:s,requestId:a}}function X3(e,n,s=()=>null){const[r,a]=l.useState(!1),[o,i]=l.useState(null),c=l.useRef(!1);return{submit:l.useCallback(async()=>{if(c.current)return;c.current=!0,a(!0),i(null);const u=await M0(e,s());if(c.current=!1,a(!1),!u.ok){i(u.error);return}n(u.requestId)},[e,n,s]),submitting:r,error:o}}const Q3={providerDeclared:!0,providerAuth:"authenticated"};function I0(e){return!e.providerDeclared||e.providerAuth!=="authenticated"}const hf=["prompt","notifications"];function Z3(e,n=Q3){const s=I0(n)?["provider",...hf]:hf;return e==="files"||e==="chat"?[...s,"design-details"]:s}const D0="codeyam.questionnaire.draft";function L0(e){return`${D0}:${e}`}function F0(e){if(e===null||typeof e!="object")return!1;const n=e;if(typeof n.step!="number"||!Number.isFinite(n.step)||typeof n.savedAt!="string"||n.designChatLaunched!==void 0&&typeof n.designChatLaunched!="boolean"||n.submissionKey!==void 0&&typeof n.submissionKey!="string")return!1;const s=n.answers;if(s===null||typeof s!="object")return!1;const r=s;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"||r.provider!==void 0&&r.provider!==null&&typeof r.provider!="string")}const Cu="/api/editor-questionnaire-draft";async function $0(){try{const e=await fetch(Cu);if(!e.ok)return null;const n=await e.json();return F0(n)?n:null}catch{return null}}function eF(e){try{const n=localStorage.getItem(L0(e));if(n===null)return null;const s=JSON.parse(n);return F0(s)?s:null}catch{return null}}function tF(e){try{localStorage.removeItem(L0(e))}catch{}}async function nF(e){const n=await $0();if(n!==null)return n;const s=eF(e);return s===null?null:(z0(s),tF(e),s)}function z0(e,n){try{fetch(Cu,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(async s=>{if(!s.ok||!n)return;const r=await s.json();typeof r.submissionKey=="string"&&r.submissionKey&&n(r.submissionKey)}).catch(()=>{})}catch{}}function ff(){try{fetch(Cu,{method:"DELETE"}).catch(()=>{})}catch{}}function sF(){try{localStorage.removeItem(D0)}catch{}}function Ai(e,n,s){return JSON.stringify({step:e,answers:n,designChatLaunched:s})}function rF(e,n,s,r){return e===null||e.savedAt<=n?null:{step:e.step,answers:s?r:e.answers,designChatLaunched:e.designChatLaunched??!1,savedAt:e.savedAt}}function aF(){const[e,n]=l.useState([]);return l.useEffect(()=>{fetch("/api/editor-stacks").then(s=>s.json()).then(n).catch(()=>{})},[]),{techStacks:e}}function oF(e){const n=e.toLowerCase();return/extension|chrome/.test(n)?"chrome-extension":/desktop|menu bar|mac app/.test(n)?"desktop":/\bapp\b|ios|android|phone|mobile/.test(n)?"mobile":"web"}const iF=1500;function lF(e,n,s){const[r,a]=l.useState(null),[o,i]=l.useState(!1),[c,d]=l.useState(null);return l.useEffect(()=>{const u=setTimeout(()=>i(!0),iF);return()=>clearTimeout(u)},[]),l.useEffect(()=>{r!==null||e===null||!(n!=="unknown"&&!s)&&!o||(a(I0({providerDeclared:e.providerDeclared,providerAuth:n})),e.providerDeclared&&d(e.provider))},[r,e,o,s,n]),{askForProvider:r,declaredProvider:c}}function cF({selected:e,authProvider:n,authState:s,probeInFlight:r,authReason:a=null}){return e===null||n!==e||r||s==="unknown"?"settling":s==="authenticated"?"connected":a==="credentials-not-persisted"?"signed-in-not-stored":"needs-login"}function dF(e,n){const[s,r]=l.useState(null),[a,o]=l.useState(!1),[i,c]=l.useState(null),d=l.useCallback(async()=>{try{const p=await fetch("/api/agent-readiness");if(!p.ok)return;r(await p.json())}catch{}},[]);l.useEffect(()=>{d()},[d,e]);const u=l.useCallback(async()=>{o(!0),c(null);try{const h=await(await fetch("/api/agent-install",{method:"POST"})).json();h.installed||c(h.detail??"The install did not complete.")}catch(p){c(p instanceof Error?p.message:String(p))}finally{o(!1),await d(),await(n==null?void 0:n())}},[n,d]);return{readiness:s,installing:a,installError:i,install:u,refresh:d}}function uF(e,n){l.useEffect(()=>{function s(r){if(r.metaKey||r.ctrlKey||r.altKey)return;const a=r.target;if(a){const i=a.tagName;if(i==="INPUT"||i==="TEXTAREA"||a.isContentEditable)return}const o=Number(r.key);!Number.isInteger(o)||o<1||o>e||(r.preventDefault(),n(o))}return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e,n])}function B0({badge:e,label:n,selected:s,dashed:r=!1,onClick:a,children:o}){return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:a,"aria-pressed":s,style:{width:"100%",display:"flex",alignItems:"center",gap:14,background:r?"transparent":s?"#2b2b2b":"var(--bg-input)",border:`1px ${r?"dashed":"solid"} ${s?"var(--accent-active)":"rgba(255,255,255,.09)"}`,borderRadius:14,padding:"16px 20px",fontSize:15.5,color:s?"var(--text-primary)":"var(--text-secondary)",textAlign:"left",cursor:"pointer",transition:".16s"},children:[t.jsx("span",{style:{flexShrink:0,width:22,height:22,display:"inline-flex",alignItems:"center",justifyContent:"center",fontFamily:"'IBM Plex Mono', monospace",fontSize:11,borderRadius:5,border:`1px solid ${s?"var(--accent-active)":"rgba(255,255,255,.09)"}`,background:s?"var(--accent-active)":"transparent",color:s?"var(--text-on-accent, #14170a)":"var(--text-dim)"},children:e}),n]}),o]})}const Gee=Object.freeze(Object.defineProperty({__proto__:null,OnboardingListItem:B0},Symbol.toStringTag,{value:"Module"}));function W0({provider:e,status:n,cliMissing:s,npmAvailable:r,installing:a,installError:o,onSignIn:i,onInstall:c,onContinueWithoutSignIn:d,storeDurability:u="unobserved",claudeLaunch:p={binaryMismatch:!1,configMissingAtLaunch:!1}}){const h=Qe(e),f=e==="claude"?mR(p,h):null,m=e==="claude"&&s&&r;return t.jsxs("div",{"data-testid":"provider-auth-status",style:{marginTop:18,padding:"16px 20px",borderRadius:14,border:"1px solid rgba(255,255,255,.09)",background:"var(--bg-input)",display:"flex",flexDirection:"column",gap:12},children:[t.jsx("span",{style:{fontSize:14,color:"var(--text-secondary)"},children:gR(n,h)}),n==="signed-in-not-stored"&&t.jsx("span",{style:{fontSize:13.5,color:"var(--text-muted)"},children:xR(u,h)}),f!==null&&t.jsx("span",{"data-testid":"provider-auth-launch-note",style:{fontSize:13.5,color:"var(--text-muted)"},children:f}),s&&t.jsxs("span",{style:{fontSize:13.5,color:"var(--text-muted)"},children:["The ",h," command-line tool isn't installed on this machine",r?".":", and npm isn't available to install it."]}),t.jsxs("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:[bR(n)&&t.jsx("button",{type:"button",onClick:i,style:{padding:"9px 18px",borderRadius:10,border:"1px solid var(--accent-active)",background:"var(--accent-active)",color:"var(--text-on-accent, #14170a)",fontSize:14,cursor:"pointer"},children:m?`Install and sign in to ${h}`:`Sign in to ${h}`}),s&&r&&t.jsx("button",{type:"button",onClick:c,disabled:a,style:{padding:"9px 18px",borderRadius:10,border:"1px solid rgba(255,255,255,.18)",background:"transparent",color:"var(--text-secondary)",fontSize:14,cursor:a?"default":"pointer"},children:a?"Installing…":`Install ${h}`}),yR(n)&&t.jsx("button",{type:"button",onClick:d,style:{padding:"9px 18px",borderRadius:10,border:"1px solid transparent",background:"transparent",color:"var(--text-muted)",fontSize:14,cursor:"pointer",textDecoration:"underline"},children:"Continue without signing in"})]}),o!==null&&t.jsx("span",{style:{fontSize:13,color:"var(--text-error, #ff8a8a)"},children:o})]})}const Vee=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireProviderAuthPanel:W0},Symbol.toStringTag,{value:"Module"})),Mi=[{id:"claude",badge:"1",how:"Sign in with your Anthropic account"},{id:"codex",badge:"2",how:"Paste an OpenAI API key"},{id:"gemini",badge:"3",how:"Paste a Google AI API key"},{id:"opencode",badge:"4",how:"Paste an API key"},{id:"muse",badge:"5",how:"Paste a Meta API key, or use your Meta account sign-in"}];function H0({selected:e,onSelect:n,onContinueWithoutSignIn:s,onSignedIn:r}){const a=Wc(),[o,i]=l.useState(!1),c=l.useCallback(()=>a.refresh(),[a]),{readiness:d,installing:u,installError:p,install:h}=dF(e,c);uF(Mi.length,b=>{n(Mi[b-1].id)});const f=d!==null&&d.provider===e,m=e!==null&&a.provider!==e,g=a.refresh;l.useEffect(()=>{if(!m)return;const b=window.setInterval(()=>void g(),1e3);return()=>window.clearInterval(b)},[m,g]);const x=cF({selected:e,authProvider:a.provider,authState:a.state,probeInFlight:a.probeInFlight,authReason:a.reason});return t.jsxs("div",{children:[t.jsx("h1",{style:{fontSize:34,fontWeight:600,letterSpacing:"-.02em",color:"var(--text-primary)",marginBottom:10},children:"Which AI should build this?"}),t.jsx("p",{style:{fontSize:14.5,color:"var(--text-muted)",marginBottom:34},children:"Pick the coding agent that writes your code. You can sign in now or later — you'll need to before the first build runs."}),t.jsxs("div",{style:{maxWidth:720,margin:"0 auto",display:"flex",flexDirection:"column",gap:9,textAlign:"left"},children:[Mi.map(b=>t.jsx(B0,{badge:b.badge,label:`${Qe(b.id)} — ${b.how}`,selected:e===b.id,onClick:()=>n(b.id)},b.id)),e!==null&&t.jsx(W0,{provider:e,status:x,cliMissing:f&&!d.agentInstalled,npmAvailable:f&&(d.npmAvailable||d.agentPackage===null),installing:u,installError:p,onSignIn:()=>i(!0),onInstall:()=>void h(),onContinueWithoutSignIn:s,storeDurability:a.storeDurability,claudeLaunch:a.claudeLaunch})]}),o&&e!==null&&t.jsx(fg,{provider:e,onAuthenticated:()=>{i(!1),vR(),r()},onClose:()=>i(!1)})]})}const Kee=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireProviderStep:H0},Symbol.toStringTag,{value:"Module"}));function pF({description:e,launched:n}){const[s,r]=l.useState({kind:"preparing"}),a=l.useRef(n),o=l.useRef(0),i=l.useCallback(async()=>{const c=++o.current,d=()=>o.current===c;r({kind:"preparing"});try{const u=!a.current,[p,h,f]=await Promise.all([fetch("/api/editor-project-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectDescription:e,allowOverwrite:!0})}),fetch("/api/editor-design-systems-install",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"}),u?fetch("/api/editor-design-reset",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"}):Promise.resolve(null)]);if(!h.ok){const m=await h.text().catch(()=>"");throw new Error(ml("/api/editor-design-systems-install",h.status,m))}if(f&&!f.ok){const m=await f.text().catch(()=>"");throw new Error(ml("/api/editor-design-reset",f.status,m))}p.ok||console.warn("[useDesignPrepare] editor-project-info failed; skill will prompt for description",p.status),d()&&r({kind:"ready"})}catch(u){d()&&r({kind:"error",message:u instanceof Error?u.message:String(u)})}},[e]);return l.useEffect(()=>(i(),()=>{o.current+=1}),[i]),{prepare:s,runPrepare:i}}function hF(e,n){const s=l.useRef(n);l.useEffect(()=>{s.current=n},[n]),l.useEffect(()=>{if(!e)return;let r=!1,a=null;const o=async()=>{try{const c=await(await fetch("/api/editor-design-state")).json();!r&&c.active&&s.current(c.active)}catch{}finally{r||(a=window.setTimeout(o,3e3))}};return o(),()=>{r=!0,a!==null&&window.clearTimeout(a)}},[e])}function q0(){const{sendToAgent:e,agentReady:n}=po();return{sendToAgent:l.useCallback(r=>{const a=Rb();return a?n?(Sn(r,a),!0):!1:e(r)},[e,n]),agentReady:n}}function Yo({view:e,onChange:n,className:s=""}){return t.jsx("div",{role:"group","aria-label":"View",className:`${TE} ${s}`,children:["chat","terminal"].map(r=>t.jsx("button",{type:"button","aria-pressed":e===r,onClick:()=>n(r),"data-testid":`chat-view-${r}`,className:$s(e===r,"compact"),children:r==="chat"?"Chat":"Terminal"},r))})}const Jee=Object.freeze(Object.defineProperty({__proto__:null,ChatTerminalToggle:Yo},Symbol.toStringTag,{value:"Module"}));function qr(e=!0){const[n,s]=l.useState(void 0),r=l.useRef(!0);return l.useEffect(()=>{if(!e)return;r.current=!0;const a=async()=>{try{const i=await fetch("/api/editor-design-round");if(!i.ok)return;const c=await i.json();if(!r.current)return;s(c.roundId??null)}catch{}};a();const o=window.setInterval(a,4e3);return()=>{r.current=!1,window.clearInterval(o)}},[e]),n}const fF=1500;function Tu(e,n="/api/editor-design-chat"){const[s,r]=l.useState(Sr);return l.useEffect(()=>{if(!e)return;let a=!1,o="";r(Sr);const i=async()=>{try{const d=await fetch(n);if(!d.ok)return;const u=await d.text();if(a||u===o)return;o=u,r(lx(JSON.parse(u)))}catch{}};i();const c=window.setInterval(()=>void i(),fF);return()=>{a=!0,window.clearInterval(c)}},[e,n]),s}function mf(e){return e.map(n=>`${n.filename}|${n.url}`).sort().join(`
|
|
59
|
+
`)}let Bn=null,zl=!1;const Bl=new Set;function Go(){for(const e of Bl)e()}function gf(){return Bn}function mF(e){Bn={...e,id:`iterate-${Date.now()}`,stage:"planning"},Go()}function Pu(){!Bn||Bn.stage==="designing"||(Bn={...Bn,stage:"designing"},Go())}function xf(){Bn&&(Bn=null,Go())}function gF(e){zl!==e&&(zl=e,Go())}function bf(){return zl}function U0(e){return Bl.add(e),()=>Bl.delete(e)}function Ou(){return l.useSyncExternalStore(U0,gf,gf)}function Y0(){return l.useSyncExternalStore(U0,bf,bf)}function xF(e){const n=l.useCallback(()=>jR(e),[e]);return l.useSyncExternalStore(wR,n,n)}const or=/^(\s*)[❯›▶]\s+(\S.*)$/,yf=/^\d+[.)]\s/,bF=/^[\s─━═╌┄▔▁-]{10,}$/;function Ru(e){if(!e)return null;const n=e.map(f=>f.replace(/\s+$/,""));let s=-1,r=0;for(let f=n.length-1;f>=0;f--){const m=or.exec(n[f]);if(m&&(m[1].length>=2||yf.test(m[2]))){s=f,r=m[1].length;break}}if(s<0)return null;const a=or.exec(n[s])[2];if(yf.test(a))return wF(n,s);const o=r+2,i=f=>{var g;if(((g=or.exec(f))==null?void 0:g[1].length)===r)return!0;const m=f.length-f.trimStart().length;return f.trim()!==""&&m===o};let c=s;for(;c>0&&i(n[c-1]);)c--;let d=s;for(let f=s+1;f<n.length;f++)if(n[f].trim()!=="")if(i(n[f]))d=f;else break;const u=[];for(let f=c;f<=d;f++){if(n[f].trim()==="")continue;const m=or.exec(n[f]),g=(m&&m[1].length===r?m[2]:n[f].trim()).replace(/\s{2,}/g," · ");u.push({label:g,selected:!!m&&m[1].length===r})}if(u.length<2)return null;const p=G0(n,c);if(p.length===0)return null;const h=n.slice(d+1).map(f=>f.trim()).filter(Boolean);return{text:K0(p),options:u,hint:V0(h)}}const yF=/^\s*←.*→\s*$/;function G0(e,n){const s=[];let r=0;for(let a=n-1;a>=0&&s.length<12;a--){const o=e[a];if(bF.test(o)||yF.test(o))break;if(o.trim()===""){if(++r>=2&&s.length>0)break;continue}r=0,s.unshift(o.trim().replace(vF,""))}return s}const vF=/^[│┃▎▌|]\s?/,jF=/[─━═╌┄]{6,}/;function V0(e){const n=e[0];return n!==void 0&&!jF.test(n)?n:null}const vf=/^(\s*)(?:[❯›▶]\s*)?(\d+[.)]\s+\S.*)$/;function wF(e,n){const s=h=>{const f=vf.exec(h);return f?h.indexOf(f[2]):-1},r=s(e[n]),a=h=>s(h)===r,o=h=>h.trim()===""||h.length-h.trimStart().length>r;let i=n;for(let h=n-1;h>=0;h--)if(a(e[h]))i=h;else if(!o(e[h]))break;let c=n;for(let h=n+1;h<e.length;h++)if(a(e[h]))c=h;else if(!o(e[h]))break;const d=[];for(let h=i;h<=c;h++){if(!a(e[h]))continue;const f=vf.exec(e[h]);d.push({label:f[2].trim().replace(/\s{2,}/g," · "),selected:or.test(e[h])})}if(d.length<2)return null;const u=G0(e,i);if(u.length===0)return null;const p=e.slice(c+1).filter(h=>!o(h)||h.trim()==="").map(h=>h.trim()).filter(Boolean);return{text:K0(u),options:d,hint:V0(p)}}function K0(e){return e.length<=1?e:[e[0],e.slice(1).join(" ")]}function J0(e){return/^type something/i.test(e.replace(/^\d+[.)]\s*/,""))}function Vo(e,n,s){return[...Ur(e,n).slice(0,-1),s,"\r"]}function Ur(e,n){const s=Math.max(0,e.options.findIndex(a=>a.selected)),r=n>s?"\x1B[B":"\x1B[A";return[...Array(Math.abs(n-s)).fill(r),"\r"]}let X0=null;const Wl=new Set;function jf(){return X0}function wf(e){X0=e;for(const n of Wl)n()}function _F(e){return Wl.add(e),()=>Wl.delete(e)}function SF(){return l.useSyncExternalStore(_F,jf,jf)}function bn(e,n){if(!n)return e;const s=e.includes("?")?"&":"?";return`${e}${s}round=${encodeURIComponent(n)}`}const kF=3e3;function Q0(e,n){const[s,r]=l.useState({ready:null,target:null});return l.useEffect(()=>{if(!n)return;let a=!1;const o=async()=>{try{const[c,d]=await Promise.all([fetch(bn("/api/editor-mockups",e)),fetch(bn("/api/editor-mockups-target",e))]);if(!c.ok||!d.ok)return;const u=await c.json(),p=await d.json();if(a)return;const h=Array.isArray(u)?u.length:0,f=typeof p.count=="number"?p.count:null;r(m=>m.ready===h&&m.target===f?m:{ready:h,target:f})}catch{}};o();const i=window.setInterval(()=>void o(),kF);return()=>{a=!0,window.clearInterval(i)}},[e,n]),s}function Ko(e,n){const s=[...e],r=n.filter(a=>!e.slice(a.after).some(o=>o.role==="user"&&CF(o.text,a.text)));for(const a of[...r].sort((o,i)=>i.after-o.after)){const o=e.slice(a.after).some(i=>i.role==="agent");s.splice(Math.min(a.after,s.length),0,{id:`${o?"sent":"pending"}-${a.id}`,role:"user",text:a.text,items:[]})}return s}function NF(e,n,s=n,r=[]){const a=[];let o=[],i=0;const c=new Map;for(const m of r)c.set(m.afterId,[...c.get(m.afterId)??[],m]);const d=m=>{for(const g of c.get(m)??[])o.push({role:"milestone",milestone:g});c.delete(m)};let u=e.length;for(;u>0&&e[u-1].role==="user"&&e[u-1].id.startsWith("pending-");)u--;let p=!1;const h=m=>{const g=`turn-${i++}`;let x=[],b=0;const y=v=>{x.length>0&&a.push({kind:"steps",id:b===0?`${g}-steps`:`${g}-steps-${b}`,items:x,live:v}),b++,x=[]};o.forEach(v=>{if(v.role==="activity")x.push(...v.items);else if(v.role==="agent")y(!1),a.push({kind:"reply",id:v.id,text:v.text});else if(v.role==="milestone"){y(!1);const{milestone:j}=v;a.push({kind:"milestone",id:`milestone-${j.id}`,text:j.text,detail:j.detail})}}),m?x.length>0?y(!0):a.push({kind:"working",id:`${g}-working`}):y(!1),o=[]};d(null),e.forEach((m,g)=>{if(m.role==="user"){if(o.length>0){const x=s&&g>=u;h(x),p=p||x}a.push({kind:"user",id:m.id,text:m.text,pending:m.id.startsWith("pending-")})}else o.push(m);d(m.id)});for(const m of[...c.keys()])d(m);const f=e.length>0&&e[e.length-1].role==="user";return(o.length>0||n&&f&&!p)&&h(n),a}function CF(e,n){const s=a=>a.replace(/\s+/g," ").trim(),r=s(n);return r!==""&&s(e).endsWith(r)}const un=16,vn={padding:`0 ${un}px 10px`,flex:"0 1 auto",minHeight:0,overflowY:"auto"};function Z0(e,n){if(!e)return[];const s=[];for(const r of Array.from(e.items)){if(r.kind!=="file")continue;const a=r.getAsFile();if(!a)continue;if(!a.type.startsWith("image/")){s.push(a);continue}const o=a.name.includes(".")?a.name.slice(a.name.lastIndexOf(".")):`.${a.type.slice(6)}`;s.push(new File([a],`pasted-${n}-${s.length+1}${o}`,{type:a.type}))}return s}function Eu({file:e,name:n=e.name,onRemove:s}){const r=Gy(e);return t.jsx("span",{role:"img","aria-label":n,title:n,"data-testid":"composer-image-preview",style:{position:"relative",display:"inline-block",width:64,height:64,borderRadius:8,border:"1px solid rgba(255,255,255,.12)",background:r?`center / cover no-repeat url("${r}")`:"#232325",boxShadow:"0 3px 8px rgba(0,0,0,.22)"},children:t.jsx("button",{type:"button","aria-label":`Remove ${n}`,onClick:s,style:{position:"absolute",top:-6,right:-6,width:18,height:18,borderRadius:"50%",border:"1px solid rgba(255,255,255,.2)",background:"#2a2a2c",color:"#d4d4d8",cursor:"pointer",fontSize:11,lineHeight:1,display:"grid",placeItems:"center",padding:0},children:"×"})})}const Xee=Object.freeze(Object.defineProperty({__proto__:null,ComposerImagePreview:Eu},Symbol.toStringTag,{value:"Module"})),_f=20,Sf=160;function Jo({onSend:e,disabled:n=!1,busyNote:s,awaiting:r=!1,draft:a,onDraftChange:o}){const[i,c]=l.useState(""),d=a??i,u=o??c,[p,h]=l.useState([]),[f,m]=l.useState(!1),[g,x]=l.useState(!1),b=l.useRef(null),y=To(),v=!n&&!f&&(d.trim().length>0||p.length>0),j=S=>{S.length>0&&h(N=>[...N,...S])},_=s??y.error;l.useLayoutEffect(()=>{const S=b.current;if(!S)return;S.style.height="auto";const N=Math.min(Math.max(S.scrollHeight,_f),Sf);S.style.height=`${N}px`,S.style.overflowY=S.scrollHeight>Sf?"auto":"hidden"},[d]);const w=async()=>{if(!v)return;m(!0);const S=await e(d.trim(),p);m(!1),S&&(u(""),h([]))},k=S=>{S.preventDefault(),x(!1),y.fromDrop(S.dataTransfer).then(j)};return t.jsxs("div",{style:{padding:`6px ${un}px 10px`,flex:"none"},children:[_&&t.jsx("div",{role:"alert",style:{fontSize:12,color:"var(--accent-danger, #f87171)",margin:"0 2px 6px"},children:_}),r&&t.jsx("style",{children:`
|
|
60
|
+
@keyframes cy-composer-await {
|
|
61
|
+
0%, 100% { box-shadow: 0 0 0 2px rgba(255,139,67,.04); }
|
|
62
|
+
50% { box-shadow: 0 0 0 3px rgba(255,139,67,.1); }
|
|
63
|
+
}
|
|
64
|
+
@media (prefers-reduced-motion: reduce) {
|
|
65
|
+
[data-testid="design-chat-composer"] { animation: none !important; }
|
|
66
|
+
}
|
|
67
|
+
`}),t.jsxs("div",{"data-testid":"design-chat-composer","data-awaiting":r?"true":"false",onDragOver:S=>{S.preventDefault(),x(!0)},onDragLeave:()=>x(!1),onDrop:k,style:{border:`1px solid ${g?"var(--accent-active, #D7FF63)":r?"rgba(255,139,67,.45)":"rgba(255,255,255,.12)"}`,boxShadow:r?"0 0 0 2px rgba(255,139,67,.04)":"none",animation:r?"cy-composer-await 2.4s ease-in-out infinite":void 0,transition:"border-color .2s, box-shadow .2s",borderRadius:12,background:"rgba(255,255,255,.03)",padding:"8px 10px",display:"flex",flexDirection:"column",gap:6},children:[t.jsx("textarea",{ref:b,"aria-label":"Message the design agent",placeholder:n?"Waiting for the agent…":r?"Type your answer…":"Reply, or ask for changes…",value:d,rows:1,onChange:S=>u(S.target.value),onPaste:S=>{const N=Z0(S.clipboardData,Date.now());N.length!==0&&(S.preventDefault(),y.clearError(),j(uo(N)))},onKeyDown:S=>{S.key==="Enter"&&!S.shiftKey&&!S.nativeEvent.isComposing&&(S.preventDefault(),w())},style:{width:"100%",resize:"none",background:"none",border:0,outline:"none",color:"var(--text-primary)",fontSize:13,lineHeight:1.45,fontFamily:"var(--font-chat)",minHeight:_f}}),p.length>0&&t.jsx("div",{"data-testid":"design-chat-attachments",style:{display:"flex",flexWrap:"wrap",alignItems:"flex-end",gap:8,paddingTop:6,opacity:f?.6:1},children:p.map(({file:S,relativePath:N},C)=>{const T=()=>h(P=>P.filter((R,I)=>I!==C));return S.type.startsWith("image/")?t.jsx(Eu,{file:S,name:N,onRemove:T},`${N}-${C}`):t.jsx(zr,{file:S,name:N,onRemove:T},`${N}-${C}`)})}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx(xo,{onPickFiles:S=>j(y.fromFileInput(S)),onPickFolder:S=>j(y.fromFolderInput(S)),ariaLabel:"Add files",title:"Add reference files or a folder",fileInputTestId:"design-chat-file-input",folderInputTestId:"design-chat-folder-input",placement:"above",className:"border border-white/[0.12] bg-transparent text-[var(--text-secondary)] transition-colors hover:border-white/[0.3] hover:bg-white/[0.1] hover:text-[var(--text-primary)]",style:{width:26,height:26,borderRadius:7,cursor:"pointer",display:"grid",placeItems:"center",fontSize:16,lineHeight:1},children:"+"}),t.jsx("span",{style:{fontSize:11.5,color:"rgba(255,255,255,.35)"},children:f&&p.length>0?`Uploading ${p.length===1?p[0].relativePath:`${p.length} files`}…`:p.length>0?`${p.length} file${p.length>1?"s":""} attached`:"Drop files or folders here too"}),t.jsx("span",{style:{flex:1}}),t.jsx("button",{type:"button","aria-label":"Send",disabled:!v,onClick:()=>void w(),style:{width:28,height:28,borderRadius:8,border:"none",display:"grid",placeItems:"center",cursor:v?"pointer":"default",background:v?"var(--accent-active, #D7FF63)":"rgba(255,255,255,.08)",color:v?"var(--text-on-accent, #111)":"rgba(255,255,255,.35)"},children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M8 13V3M3.5 7.5L8 3l4.5 4.5"})})})]})]})]})}const Qee=Object.freeze(Object.defineProperty({__proto__:null,DesignChatComposer:Jo},Symbol.toStringTag,{value:"Module"}));function eS({initialRows:e,onSend:n,disabled:s=!1}){const[r,a]=l.useState(e);return t.jsxs("div",{"data-testid":"design-chat-decision-card",style:{border:"1px solid rgba(215,255,99,.35)",background:"rgba(215,255,99,.05)",borderRadius:10,padding:"10px 12px",display:"flex",flexDirection:"column",gap:10,fontSize:13,color:"var(--text-secondary)"},children:[t.jsx("div",{style:{color:"var(--text-primary)",fontWeight:500},children:"What should happen to each design?"}),r.map(o=>t.jsx(qx,{row:o,disabled:s,onChoose:(i,c)=>a(d=>iA(d,o.filename,i,c))},o.filename)),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsx("button",{type:"button",disabled:s,onClick:()=>n(r),style:{padding:"6px 12px",borderRadius:8,border:"none",cursor:s?"default":"pointer",background:"var(--accent-active, #D7FF63)",color:"var(--text-on-accent, #111)",fontSize:12.5,fontWeight:600,opacity:s?.6:1},children:"Send choices"}),t.jsx("span",{style:{fontSize:11.5,color:"rgba(255,255,255,.4)"},children:"Anything typed below is sent with it."})]})]})}const Zee=Object.freeze(Object.defineProperty({__proto__:null,DesignChatDecisionCard:eS},Symbol.toStringTag,{value:"Module"})),kf="codeyam:turn-start:",Nf=new Map;function TF(e,n){const s=Nf.get(e);if(s!==void 0)return s;let r=n;try{const a=window.sessionStorage.getItem(kf+e),o=a===null?NaN:Number(a);Number.isFinite(o)?r=o:window.sessionStorage.setItem(kf+e,String(n))}catch{}return Nf.set(e,r),r}function tS({items:e,live:n=!1,mark:s,onOpenTerminal:r,timerKey:a}){const[o,i]=l.useState(!1),c=PF(n,a),d=n&&e.length>0?e.length-1:-1,u=d>=0?e.slice(0,d):e,p=l.useRef(null);return l.useEffect(()=>{var h,f;o&&((f=(h=p.current)==null?void 0:h.scrollIntoView)==null||f.call(h,{block:"nearest",behavior:"smooth"}))},[o]),t.jsxs("div",{ref:p,"data-testid":"design-chat-activity","data-live":n?"true":"false",style:{fontSize:12,color:"rgba(255,255,255,.4)"},children:[t.jsxs("button",{type:"button","aria-expanded":o,"aria-label":o?"Hide steps":"Show steps",onClick:()=>i(!o),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"inherit",fontSize:12,display:"flex",alignItems:s?"center":"flex-start",gap:8,textAlign:"left",maxWidth:"100%"},children:[t.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:8,transition:"transform 150ms",transform:o?"rotate(90deg)":"none"},children:"›"}),s,t.jsx("span",{children:`${e.length} step${e.length===1?"":"s"}`}),c!==null&&t.jsxs("span",{"data-testid":"design-chat-elapsed",style:{color:"rgba(255,255,255,.7)",fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:11.5},children:["(",Cx(c),")"]})]}),o&&u.length>0&&t.jsx("ol",{style:{margin:"6px 0 0",padding:"0 0 0 12px",borderLeft:"1px solid rgba(255,255,255,.1)",listStyle:"none",display:"flex",flexDirection:"column",gap:5},children:u.map((h,f)=>t.jsxs("li",{style:{display:"flex",alignItems:"flex-start",gap:8,whiteSpace:"pre-wrap",overflowWrap:"anywhere",color:n?"rgba(255,255,255,.32)":void 0},children:[n&&t.jsx("span",{"aria-hidden":"true",style:{flexShrink:0,width:12,display:"grid",placeItems:"center",marginTop:3},children:t.jsx("span",{style:{fontSize:10,lineHeight:1,color:"rgba(215,255,99,.55)"},children:"✓"})}),t.jsx("span",{children:h})]},f))}),d>=0&&t.jsxs("div",{"data-testid":"design-chat-current-step",style:{display:"flex",alignItems:"flex-start",gap:8,margin:o&&u.length>0?"5px 0 0":"6px 0 0",color:"rgba(255,255,255,.88)",overflowWrap:"anywhere"},children:[t.jsx("span",{"aria-hidden":"true",style:{flexShrink:0,width:8,display:"grid",placeItems:"center",marginTop:3},children:t.jsx(Ht,{size:10})}),t.jsxs("span",{children:[e[d].replace(/[.…]+$/,""),t.jsx(qn,{})]})]}),d>=0&&r&&t.jsxs("div",{"data-testid":"design-chat-terminal-hint",style:{margin:"4px 0 0 16px",fontSize:11.5,color:"rgba(255,255,255,.3)"},children:["To see exactly what's happening, switch to the"," ",t.jsx("button",{type:"button",onClick:r,className:"cursor-pointer hover:!text-[var(--text-primary)]",style:{background:"none",border:"none",padding:0,font:"inherit",color:"rgba(255,255,255,.5)",textDecoration:"underline",textUnderlineOffset:2,cursor:"pointer"},children:"terminal"})]})]})}function PF(e,n){const s=()=>n?TF(n,Date.now()):Date.now(),r=l.useRef(e?s():null),[a,o]=l.useState(e&&r.current!==null?Math.floor((Date.now()-r.current)/1e3):null);return l.useEffect(()=>{if(!e)return;r.current===null&&(r.current=s());const i=()=>o(Math.floor((Date.now()-(r.current??Date.now()))/1e3));i();const c=window.setInterval(i,1e3);return()=>window.clearInterval(c)},[e]),a}const ete=Object.freeze(Object.defineProperty({__proto__:null,DesignChatActivity:tS},Symbol.toStringTag,{value:"Module"}));function OF(e){let n=-1;for(const c of e.matchAll(/\?(?=[\s)"'»]|$)/g))n=c.index??-1;if(n<0)return e;const s=e.slice(0,n),r=s.lastIndexOf("¿"),a=Math.max(...[".","!","?",":",`
|
|
68
|
+
`].map(c=>s.lastIndexOf(c)));let o=r>a?r:a+1;for(;o<n&&/\s/.test(e[o]);)o+=1;const i=e.slice(o,n+1);return i.length<2||/[`*]/.test(i)?e:`${e.slice(0,o)}**${i}**${e.slice(n+1)}`}const RF=80;function EF(e,n,s){const r=n.slice(0,s).filter(i=>i.kind==="user"),a=r[r.length-1],o=a&&a.kind==="user"?a.text.replace(/\s+/g," ").trim().slice(0,40):"";return`${e}:${r.length}:${o}`}const AF=[];function Yr({messages:e,working:n,pending:s=[],emptyState:r,awaitingReply:a=!1,startingText:o="Starting the design agent…",waiting:i=!1,intro:c,milestones:d=AF,onOpenTerminal:u,timerScope:p,lastReplyBackground:h=!1}){var _;const f=l.useRef(null),m=l.useRef(!0),g=l.useMemo(()=>Ko(e,s),[e,s]),x=!i&&(n||g.some(w=>w.id.startsWith("pending-"))),b=!i&&n,y=l.useMemo(()=>NF(g,x,b,d),[g,x,b,d]);l.useLayoutEffect(()=>{const w=f.current;w&&m.current&&(w.scrollTop=w.scrollHeight)},[y]),l.useLayoutEffect(()=>{const w=f.current;w&&a&&(w.scrollTop=w.scrollHeight,m.current=!0)},[a]);const v=(_=[...y].reverse().find(w=>w.kind==="reply"))==null?void 0:_.id,j=y.length>0&&y[y.length-1].kind==="reply";return t.jsxs("div",{ref:f,"data-testid":"design-chat-feed",role:"log","aria-live":"polite",onScroll:w=>{const k=w.currentTarget;m.current=k.scrollHeight-k.scrollTop-k.clientHeight<RF},style:{flex:1,minHeight:96,overflow:"auto",display:"flex",flexDirection:"column",gap:12,padding:`14px ${un}px`,fontSize:13,lineHeight:1.6,fontFamily:"var(--font-chat)"},children:[c,y.length===0&&r,y.length===0&&!r&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,color:"var(--text-muted)",fontSize:13},children:[t.jsx(Ht,{}),o]}),y.map((w,k)=>{var C;const S=w.kind==="steps"&&!w.live&&((C=y[k+1])==null?void 0:C.kind)==="reply",N=w.kind==="reply"&&k>0&&y[k-1].kind==="steps";return w.kind==="reply"?j&&w.id===v&&Fh(w.text)?t.jsx(Ox,{text:w.text},w.id):a&&j&&w.id===v?t.jsxs("div",{"data-testid":"design-chat-awaiting",style:{border:"1px solid rgba(255,255,255,.14)",background:"rgba(255,255,255,.055)",borderRadius:10,padding:"10px 12px 4px"},children:[t.jsx(ll,{text:OF(w.text),showMark:!N,bright:!0}),t.jsxs("div",{style:{margin:"2px 0 6px",display:"flex",alignItems:"center",gap:7,fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:10.5,letterSpacing:".1em",textTransform:"uppercase",color:"#cfcfcf"},children:[t.jsx("span",{"aria-hidden":"true","data-testid":"design-chat-awaiting-dot",className:"animate-pulse motion-reduce:animate-none",style:{width:7,height:7,borderRadius:"50%",background:it,flex:"none"}}),"Waiting for your answer"]})]},w.id):t.jsx(ll,{text:w.text,showMark:!N,warning:Fh(w.text),tint:h&&w.id===v?Rn:void 0},w.id):w.kind==="steps"?t.jsx(tS,{items:w.items,live:w.live,onOpenTerminal:u,timerKey:p&&w.live?EF(p,y,k):void 0,mark:S?t.jsx("span",{style:{color:"var(--accent-active, #D7FF63)",display:"flex"},children:t.jsx(cs,{markOnly:!0,className:"h-3.5"})}):void 0},w.id):w.kind==="milestone"?t.jsxs("div",{"data-testid":"design-chat-milestone",role:"separator","aria-label":`Step ${w.detail} complete: ${w.text}`,style:{display:"flex",alignItems:"center",gap:12,margin:"8px 0 10px",fontSize:12.5},children:[t.jsxs("span",{style:{color:"var(--working)",whiteSpace:"nowrap",maxWidth:"80%",overflow:"hidden",textOverflow:"ellipsis"},children:[t.jsx("span",{"aria-hidden":"true",children:"✓ "}),t.jsxs("span",{style:{color:"rgba(255,255,255,.55)"},children:["Step ",w.detail,":"]})," ",t.jsx("span",{style:{color:"var(--text-primary)"},children:w.text})," · Complete!"]}),t.jsx("span",{"aria-hidden":"true",style:{flex:1,height:1,background:"rgba(255,255,255,.12)"}})]},w.id):w.kind==="working"?t.jsxs("div",{"data-testid":"design-chat-thinking",style:{display:"flex",alignItems:"center",gap:8,color:"rgba(255,255,255,.5)",fontSize:12.5},children:[t.jsx(Ht,{size:12}),t.jsxs("span",{children:["Working",t.jsx(qn,{})]})]},w.id):YA(w.text)?t.jsx("div",{"data-testid":"design-chat-answered",style:{borderLeft:"2px solid rgba(255,255,255,.14)",padding:"2px 0 2px 10px",color:"rgba(255,255,255,.45)"},children:"You answered the questions in the preview."},w.id):t.jsx("div",{"data-testid":"design-chat-user","data-pending":w.pending?"true":"false",style:{alignSelf:"flex-end",maxWidth:"88%",padding:"8px 10px",borderRadius:"12px 12px 4px 12px",background:"rgba(255,255,255,.06)",color:"#d6d6d6",whiteSpace:"pre-wrap",overflowWrap:"anywhere",opacity:w.pending?.75:1},children:t.jsx(nS,{text:w.text})},w.id)})]})}function nS({text:e}){const n=uA(e);if(n)return t.jsxs("span",{"data-testid":"design-chat-decision",children:[n.summary,n.note&&t.jsx("span",{style:{display:"block",marginTop:4},children:n.note})]});const s=cx(e);if(s)return t.jsxs("span",{"data-testid":"design-chat-iterate",children:["Make a new round from my feedback",s.designs>0&&t.jsxs("span",{style:{display:"block",marginTop:4,fontSize:11,color:"rgba(255,255,255,.5)"},children:["Ratings and notes on ",s.designs," ",s.designs===1?"design":"designs"]})]});const r=XA(e);return r?t.jsxs(t.Fragment,{children:[r.rest?t.jsx("div",{style:{marginBottom:6},children:r.rest}):null,t.jsx("div",{"data-testid":"design-chat-files",style:{display:"flex",flexWrap:"wrap",gap:6},children:r.names.map(a=>t.jsxs("span",{"data-testid":"design-chat-file",title:a,style:{display:"inline-flex",alignItems:"center",gap:4,maxWidth:"100%",whiteSpace:"nowrap",fontSize:11,padding:"1px 8px",borderRadius:999,border:"1px solid rgba(255,255,255,.14)",color:"rgba(255,255,255,.6)"},children:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:t.jsx("path",{d:"M13.5 7.5l-5.6 5.6a3.2 3.2 0 01-4.5-4.5l5.9-5.9a2.1 2.1 0 013 3l-5.9 5.9a1.1 1.1 0 01-1.5-1.5l5.3-5.3"})}),t.jsx("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:a})]},a))})]}):t.jsx(t.Fragment,{children:e})}const tte=Object.freeze(Object.defineProperty({__proto__:null,DesignChatFeed:Yr,UserMessageBody:nS},Symbol.toStringTag,{value:"Module"}));function sS({pick:e}){const n=e.number?`${String(e.number).padStart(2,"0")} ${e.name}`:e.name;return t.jsxs("div",{"data-testid":"design-chat-pick",style:{border:"1px solid rgba(215,255,99,.35)",background:"rgba(215,255,99,.07)",borderRadius:10,padding:"10px 12px",display:"flex",flexDirection:"column",gap:10,fontSize:13,color:"var(--text-secondary)"},children:[t.jsxs("div",{children:["You picked ",t.jsx("b",{style:{color:"var(--text-primary)",fontWeight:500},children:n}),". I'll turn it into your design system and the first screens of the app."]}),t.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[t.jsx("button",{type:"button",disabled:e.busy,onClick:e.confirm,style:{padding:"6px 12px",borderRadius:8,border:"none",cursor:e.busy?"default":"pointer",background:"var(--accent-active, #D7FF63)",color:"var(--text-on-accent, #111)",fontSize:12.5,fontWeight:600,opacity:e.busy?.6:1},children:e.busy?"Starting…":`Continue with ${e.name}`}),t.jsx("button",{type:"button",disabled:e.busy,onClick:e.cancel,style:{padding:"6px 12px",borderRadius:8,border:"1px solid rgba(255,255,255,.14)",background:"transparent",color:"var(--text-secondary)",fontSize:12.5,cursor:"pointer"},children:"Keep exploring"})]})]})}const nte=Object.freeze(Object.defineProperty({__proto__:null,DesignChatPickCard:sS},Symbol.toStringTag,{value:"Module"})),rS="border border-[rgba(255,255,255,.14)] outline-none focus:border-[#FF8B43] focus-visible:outline-none";function Au({onAnswer:e,attach:n,disabled:s=!1,autoFocus:r=!1,placeholder:a,ariaLabel:o,resetKey:i}){const[c,d]=l.useState(""),[u,p]=l.useState([]),[h,f]=l.useState(!1),[m,g]=l.useState(!1),x=To();l.useEffect(()=>{d(""),p([])},[i]);const b=w=>{w.length>0&&p(k=>[...k,...w])},y=s||h,v=!y&&(c.trim()!==""||u.length>0),j=async()=>{if(!v)return;let w=c.trim();if(u.length>0&&n){f(!0);const k=await n(u);if(f(!1),k===null)return;w=w?`${k} ${w}`:k}e(w),d(""),p([])},_=w=>{n&&(w.preventDefault(),g(!1),x.fromDrop(w.dataTransfer).then(b))};return t.jsxs("form",{onSubmit:w=>{w.preventDefault(),j()},onDragOver:w=>{n&&(w.preventDefault(),g(!0))},onDragLeave:()=>g(!1),onDrop:_,style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsxs("div",{style:{display:"flex",gap:6},children:[t.jsx("input",{type:"text",autoFocus:r,value:c,onChange:w=>d(w.target.value),onPaste:w=>{if(!n)return;const k=Z0(w.clipboardData,Date.now());k.length!==0&&(w.preventDefault(),x.clearError(),b(uo(k)))},disabled:y,placeholder:h?"Adding your files…":a,"aria-label":o,className:rS,style:{flex:1,minWidth:0,padding:"7px 10px",borderRadius:8,background:"rgba(0,0,0,.15)",color:"var(--text-primary)",fontSize:13,borderColor:m?"var(--accent-active, #D7FF63)":void 0}}),t.jsx("button",{type:"submit",disabled:!v,style:{padding:"7px 12px",borderRadius:8,border:"1px solid rgba(255,139,67,.5)",background:"transparent",color:"var(--text-primary)",fontSize:12.5,cursor:v?"pointer":"default",opacity:v?1:.5},children:"Answer"})]}),t.jsx(Zc,{message:x.error,style:{fontSize:12}}),u.length>0&&t.jsx("div",{"data-testid":"own-answer-attachments",style:{display:"flex",flexWrap:"wrap",alignItems:"flex-end",gap:8,opacity:h?.6:1},children:u.map(({file:w,relativePath:k},S)=>{const N=()=>p(C=>C.filter((T,P)=>P!==S));return w.type.startsWith("image/")?t.jsx(Eu,{file:w,name:k,onRemove:N},`${k}-${S}`):t.jsx(zr,{file:w,name:k,onRemove:N},`${k}-${S}`)})})]})}const ste=Object.freeze(Object.defineProperty({__proto__:null,OWN_ANSWER_FOCUS_CLASS:rS,OwnAnswerField:Au},Symbol.toStringTag,{value:"Module"})),Mu=1e4,Iu={border:"1px solid rgba(255,139,67,.6)",background:"rgba(255,139,67,.12)"};function Va(){return t.jsx("span",{"data-testid":"answer-sent-mark",style:{marginLeft:"auto",flexShrink:0,fontSize:11.5,fontWeight:500,color:it,whiteSpace:"nowrap"},children:"✓ Answer sent"})}const rte=Object.freeze(Object.defineProperty({__proto__:null,ANSWER_SENT_RELEASE_MS:Mu,ANSWER_SENT_STYLE:Iu,AnswerSentMark:Va},Symbol.toStringTag,{value:"Module"})),MF=90,Cf=e=>e.replace(/[\s*`]+/g,"");function pr(e,n){if(!n)return-1;const s=Cf(n.text.join(" "));return e.findIndex(r=>r.question.trim()!==""&&s.endsWith(Cf(r.question)))}function Du({questions:e,screenPrompt:n,send:s,onAnswered:r,onOpenTerminal:a,attach:o}){const[i,c]=l.useState(0),[d,u]=l.useState(null);l.useEffect(()=>{if(!d)return;const v=window.setTimeout(()=>u(null),Mu);return()=>window.clearTimeout(v)},[d]);const p=pr(e,n),h=p>=0?p:Math.min(i,e.length-1),f=e[h],m=(d==null?void 0:d.question)===f.question,g=v=>n&&p===h?n.options.findIndex(j=>v(j.label.replace(/^\d+[.)]\s*/,""))):-1,x=(v,j,_)=>{u({question:f.question,k:j}),c(h+1),r==null||r({text:_,last:h===e.length-1}),v.forEach((w,k)=>window.setTimeout(()=>s(w),k*MF))},b=v=>{const j=f.options[v].label,_=g(w=>w===j);x(n&&_>=0?Ur(n,_):[...Array(v).fill("\x1B[B"),"\r"],v,j)},y=v=>{const j=g(J0);x(n&&j>=0?Vo(n,j,v):[...Array(f.options.length).fill("\x1B[B"),v,"\r"],-1,v)};return t.jsxs("div",{role:"group","aria-label":"The agent is asking you a question","data-testid":"design-chat-question",style:{border:"1px solid rgba(255,139,67,.4)",background:"rgba(255,139,67,.06)",borderRadius:10,padding:"10px 12px",display:"flex",flexDirection:"column",gap:8,fontSize:13,color:"var(--text-secondary)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("span",{style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:10.5,letterSpacing:".1em",textTransform:"uppercase",color:it},children:f.header||"Question"}),e.length>1&&t.jsxs("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-muted)",fontVariantNumeric:"tabular-nums"},children:[h+1," of ",e.length]})]}),t.jsx("div",{style:{color:"var(--text-primary)",fontWeight:500,lineHeight:1.45},children:f.question}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[f.options.map((v,j)=>{const _=m&&(d==null?void 0:d.k)===j;return t.jsxs("button",{type:"button",disabled:m||f.multiSelect,"aria-pressed":_,onClick:()=>b(j),style:{textAlign:"left",padding:"7px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,.14)",background:"rgba(255,255,255,.02)",..._?Iu:{},color:"var(--text-primary)",cursor:m||f.multiSelect?"default":"pointer",opacity:m&&!_?.4:1,display:"flex",flexDirection:"column",gap:2},children:[t.jsxs("span",{style:{display:"flex",alignItems:"baseline",gap:8},children:[t.jsx("span",{style:{fontSize:13,fontWeight:500},children:v.label}),_&&t.jsx(Va,{})]}),v.description&&t.jsx("span",{style:{fontSize:12,color:"var(--text-muted)",lineHeight:1.4},children:v.description})]},v.label)}),m&&(d==null?void 0:d.k)===-1&&t.jsx("div",{style:{display:"flex",padding:"2px 2px 0"},children:t.jsx(Va,{})})]}),!f.multiSelect&&t.jsx(Au,{onAnswer:y,attach:o,disabled:m,resetKey:h,placeholder:"Something else in mind? Type your answer",ariaLabel:"Your own answer"}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:11.5},children:[f.multiSelect&&t.jsx("span",{style:{color:"var(--text-muted)"},children:"You can pick more than one here: choose them in the Terminal."}),t.jsx("button",{type:"button",onClick:a,style:{marginLeft:"auto",background:"none",border:"none",padding:0,color:"var(--text-secondary)",textDecoration:"underline",cursor:"pointer",fontSize:11.5,whiteSpace:"nowrap"},children:"Open Terminal"})]})]})}const ate=Object.freeze(Object.defineProperty({__proto__:null,DesignChatQuestionCard:Du,questionOnScreen:pr},Symbol.toStringTag,{value:"Module"})),IF=/\s*(Ready to submit your answers\?)\s*$/i;function DF(e){if(!e.includes("●"))return{items:[],tail:e};const n=IF.exec(e);return{items:(n?e.slice(0,n.index):e).split("●").map(a=>a.trim()).filter(Boolean).map(a=>{const o=a.lastIndexOf("→");return o<0?{question:a,answer:""}:{question:a.slice(0,o).trim(),answer:a.slice(o+1).trim()}}),tail:n?n[1]:""}}function Xo({prompt:e,onChoose:n,onAnswer:s,onOpenTerminal:r,attach:a}){const[o,i]=l.useState(null),[c,d]=l.useState(null),u=e.text.join("|");l.useEffect(()=>i(null),[u]),l.useEffect(()=>{if(o===null)return;const g=window.setTimeout(()=>i(null),Mu);return()=>window.clearTimeout(g)},[o]);const p=o!==null,h=g=>{c!==null&&(i(c),s(c,g),d(null))},f=e.options.some(g=>/submit answers/i.test(g.label)),m=DF(e.text[1]??"");return t.jsxs("div",{role:"group","aria-label":"The agent is waiting for an answer","data-testid":"design-chat-terminal-prompt",style:{border:f?"1px solid rgba(215,255,99,.45)":"1px solid rgba(255,139,67,.4)",background:f?"rgba(215,255,99,.05)":"rgba(255,139,67,.06)",borderRadius:10,padding:"10px 12px",display:"flex",flexDirection:"column",gap:8,fontSize:13,color:"var(--text-secondary)"},children:[t.jsx("span",{style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:10.5,letterSpacing:".1em",textTransform:"uppercase",color:f?"var(--accent-active)":it},children:f?"Last step: review and submit":"Needs your answer"}),t.jsx("div",{style:{color:"var(--text-primary)",fontWeight:500},children:e.text[0]}),m.items.length>0?t.jsxs(t.Fragment,{children:[t.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:6},children:m.items.map((g,x)=>t.jsxs("li",{style:{lineHeight:1.45},children:[t.jsx("div",{children:g.question}),g.answer&&t.jsxs("div",{style:{color:"var(--text-primary)",fontWeight:500},children:[t.jsx("span",{"aria-hidden":"true",children:"→ "}),t.jsx("span",{children:g.answer})]})]},x))}),m.tail&&t.jsx("div",{style:{color:"var(--text-primary)"},children:m.tail})]}):e.text[1]&&t.jsx("div",{style:{lineHeight:1.45},children:e.text[1]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,marginTop:2},children:e.options.map((g,x)=>{const b=o===x;return t.jsxs("button",{type:"button",disabled:p,"aria-current":g.selected?"true":void 0,"aria-pressed":b,onClick:()=>{if(J0(g.label)){d(x);return}i(x),n(x)},style:b?{display:"flex",alignItems:"baseline",gap:8,textAlign:"left",padding:"6px 10px",borderRadius:8,...Iu,color:"var(--text-primary)",fontSize:12.5,cursor:"default"}:f&&/submit answers/i.test(g.label)?{textAlign:"left",padding:"6px 10px",borderRadius:8,border:"1px solid var(--accent-active)",background:"var(--accent-active)",color:"var(--text-on-accent, #111)",fontWeight:500,fontSize:12.5,cursor:p?"default":"pointer",opacity:p?.4:1}:{textAlign:"left",padding:"6px 10px",borderRadius:8,border:`1px solid ${g.selected?"rgba(255,139,67,.5)":"rgba(255,255,255,.12)"}`,background:g.selected?"rgba(255,139,67,.1)":"transparent",color:"var(--text-primary)",fontSize:12.5,cursor:p?"default":"pointer",opacity:p?.4:1},children:[g.label,b&&t.jsx(Va,{})]},`${x}-${g.label}`)})}),c!==null&&t.jsx(Au,{autoFocus:!0,onAnswer:h,attach:a,disabled:p,placeholder:"Type your answer…",ariaLabel:"Your answer"}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:11.5},children:[e.hint&&t.jsx("span",{style:{color:"var(--text-muted)"},children:e.hint}),t.jsx("button",{type:"button",onClick:r,style:{marginLeft:"auto",background:"none",border:"none",padding:0,color:"var(--text-secondary)",textDecoration:"underline",cursor:"pointer",fontSize:11.5},children:"Open Terminal"})]})]})}const ote=Object.freeze(Object.defineProperty({__proto__:null,DesignChatTerminalPrompt:Xo},Symbol.toStringTag,{value:"Module"})),LF=[/Paste code here if prompted/i,/Use the url below to sign in/i],FF=["claude.com","claude.ai","anthropic.com"];function Lu(e){if(!e||!e.some(a=>LF.some(o=>o.test(a))))return null;const n=e.map(a=>a.trim()),s=n.findIndex(a=>a.startsWith("https://"));if(s<0)return{url:null};let r="";for(let a=s;a<n.length&&n[a]!==""&&!/\s/.test(n[a]);a++)r+=n[a];return{url:$F(r)?r:null}}function $F(e){try{const{protocol:n,hostname:s}=new URL(e);return n==="https:"&&FF.some(r=>s===r||s.endsWith(`.${r}`))}catch{return!1}}const aS=["Make them bolder","Try a darker version","Mix my two favorites","Show me 3 new directions"],oS=["Keep the ones you suggest","Keep my top-rated ones","Keep none, start fresh"];function iS({items:e,onPick:n}){return t.jsx("div",{"data-testid":"design-chat-suggestions",style:{display:"flex",flexWrap:"wrap",gap:6,padding:"0 12px 8px"},children:e.map(s=>t.jsx("button",{type:"button",onClick:()=>n(s),style:{fontSize:12,padding:"4px 10px",borderRadius:999,border:"1px solid rgba(255,255,255,.14)",background:"transparent",color:"var(--text-secondary)",cursor:"pointer"},children:s},s))})}const ite=Object.freeze(Object.defineProperty({__proto__:null,DesignChatSuggestions:iS,GALLERY_SUGGESTIONS:aS,ITERATE_SUGGESTIONS:oS},Symbol.toStringTag,{value:"Module"})),Ka="initial-design",lS=90,cS=6e3,dS=12e3;function uS({terminal:e}){var Z;const[n,s]=l.useState("chat"),r=Tu(!0);l.useEffect(()=>Pd(Ka),[]);const{sendToAgent:a,agentReady:o}=q0(),[i,c]=l.useState(null),[d,u]=l.useState(""),[p,h]=l.useState([]),f=l.useRef([]),m=z=>{const L=dd(z),q=br(a,L);return q?(f.current.push(q),w(),h(se=>[...se,{id:`${Date.now()}-${se.length}`,text:L.replace(/\r$/,""),after:r.messages.length}]),!0):!1},g=SF(),x=qr(),{ready:b}=Q0(x??void 0,x!==void 0),[y,v]=l.useState(!1);l.useEffect(()=>{if(r.available||!o){v(!1);return}const z=window.setTimeout(()=>v(!0),dS);return()=>window.clearTimeout(z)},[r.available,o]);const j=Ou(),_=j==null?void 0:j.id,w=()=>{(j==null?void 0:j.stage)==="planning"&&Pu()};l.useEffect(()=>{j&&h(z=>z.some(L=>L.id===j.id)?z:[...z,{id:j.id,text:j.prompt,after:r.messages.length}])},[_]);const k=Ko(r.messages,p).some(z=>z.id.startsWith("pending-")),S=xF(Ka),N=l.useMemo(()=>Ru(S),[S]),C=l.useMemo(()=>Lu(S),[S]),T=!!N||!!C,P=l.useRef([]);l.useEffect(()=>()=>{P.current.forEach(z=>window.clearTimeout(z)),P.current=[],f.current.forEach(z=>z()),f.current=[]},[]);const R=z=>z.forEach((L,q)=>{P.current.push(window.setTimeout(()=>a(L),q*lS))}),I=z=>{N&&R(Ur(N,z))},A=(z,L)=>{N&&R(Vo(N,z,L))},O=!T&&!r.question&&(r.working||k);l.useEffect(()=>{gF(O)},[O]),l.useEffect(()=>{if(!j||j.stage!=="planning"||!k||r.working||T)return;const z=window.setTimeout(()=>a("\r"),cS);return()=>window.clearTimeout(z)},[j,k,r.working,T,a]);const W=[...r.messages].reverse().find(z=>z.role==="user"),D=(j==null?void 0:j.stage)==="planning"&&W!==void 0&&cx(W.text)!==null&&((Z=r.messages[r.messages.length-1])==null?void 0:Z.role)==="agent",Y=!O&&o&&!g&&!T,H=r.messages[r.messages.length-1],E=Y&&(D||(H==null?void 0:H.role)==="agent"&&cd(H.text)),U=l.useMemo(()=>{var z;return D&&j&&j.designs.length>0?oA(j.designs,((z=aA((H==null?void 0:H.text)??""))==null?void 0:z.suggestion)??null):null},[D,j,H==null?void 0:H.text]),M=Y&&U!==null,J=Y?D?U?null:oS:!j&&(b??0)>0?aS:null:null,ne=async z=>{c(null);try{return await Po(z)}catch(L){return c(L instanceof Error?L.message:"Couldn't add those files."),null}},oe=async(z,L)=>{c(null);let q=z;if(L.length>0){const se=await ne(L);if(se===null)return!1;q=z?`${se} ${z}`:se}return m(q)},ae=r.messages.some(z=>z.role==="agent"),G=o?T?"waiting on you":!ae&&!y?"working":r.available?O?"working":"waiting on you":"running":"starting",ie=G==="working"||G==="starting",le=E||!!r.question||G==="waiting on you";return t.jsx(Lr.Provider,{value:z=>void m(z),children:t.jsxs("div",{"data-testid":"design-session-chat-pane",style:{display:"flex",flexDirection:"column",flex:1,minHeight:0,height:"100%"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderBottom:"1px solid rgba(255,255,255,.08)",flex:"none"},children:[t.jsx(Yo,{view:n,onChange:s}),t.jsxs("span",{"data-testid":"design-session-agent-status",style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:6,fontSize:12,color:le?it:ie?"var(--working)":"rgba(255,255,255,.45)"},children:[ie&&!le?t.jsx(Ht,{size:11}):t.jsx("span",{"aria-hidden":"true",className:le?"animate-pulse":void 0,style:{width:8,height:8,borderRadius:"50%",background:le?it:"rgba(255,255,255,.35)"}}),t.jsxs("span",{children:[le?Ba:G.charAt(0).toUpperCase()+G.slice(1),le?t.jsx(qn,{variant:"pulse"}):ie&&t.jsx(qn,{})]})]})]}),t.jsxs("div",{style:{position:"relative",flex:1,minHeight:0},children:[t.jsx("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column"},children:e}),n==="chat"&&t.jsxs("div",{"data-testid":"design-session-chat-view",style:{position:"absolute",inset:0,zIndex:1,display:"flex",flexDirection:"column",background:"var(--bg-deep, #141414)"},children:[t.jsx(Yr,{messages:r.messages,working:r.working,waiting:T,pending:p,awaitingReply:E,onOpenTerminal:()=>s("terminal"),emptyState:y?t.jsxs("div",{"data-testid":"design-chat-log-missing",style:{fontSize:13,color:"var(--text-muted)",display:"flex",flexDirection:"column",gap:8,alignItems:"flex-start"},children:["The chat can't read this session's messages yet. The agent is running: follow it in the terminal.",t.jsx("button",{type:"button",onClick:()=>s("terminal"),style:{padding:"5px 12px",borderRadius:8,border:"1px solid rgba(255,255,255,.14)",background:"transparent",color:"var(--text-primary)",fontSize:12.5,cursor:"pointer"},children:"Open Terminal"})]}):void 0}),r.question&&t.jsx("div",{style:vn,children:t.jsx(Du,{questions:r.question,screenPrompt:N,send:z=>void a(z),onOpenTerminal:()=>s("terminal"),attach:ne})}),C&&!N&&t.jsx("div",{style:vn,children:t.jsx(_o,{login:C,onSubmitCode:z=>R([z,"\r"]),onOpenTerminal:()=>s("terminal")})}),N&&!r.question&&t.jsx("div",{style:vn,children:t.jsx(Xo,{prompt:N,onChoose:I,onAnswer:A,onOpenTerminal:()=>s("terminal"),attach:ne})}),g&&t.jsx("div",{style:vn,children:t.jsx(sS,{pick:g})}),M&&t.jsx("div",{style:{padding:"0 12px 10px",maxHeight:"50%",overflowY:"auto",flex:"none"},children:t.jsx(eS,{initialRows:U,onSend:z=>{m(cA(z,d))&&u("")}},H==null?void 0:H.id)}),J&&t.jsx(iS,{items:J,onPick:z=>void m(z)}),t.jsx(Jo,{disabled:!o,busyNote:i,awaiting:E,draft:d,onDraftChange:u,onSend:oe})]})]})]})})}const lte=Object.freeze(Object.defineProperty({__proto__:null,CHAT_UNAVAILABLE_AFTER_MS:dS,DESIGN_SESSION_CHAT_NAME:Ka,DesignSessionChatPane:uS,ITERATE_NUDGE_AFTER_MS:cS,TERMINAL_KEY_GAP_MS:lS},Symbol.toStringTag,{value:"Module"}));function Hl({description:e,launched:n,onLaunched:s,onDesignSelected:r,onPreviewUrl:a,variant:o="chat"}){l.useEffect(()=>(a==null||a("/design-exploration"),()=>{a==null||a(null)}),[a]);const{prepare:i,runPrepare:c}=pF({description:e,launched:n}),[d,u]=l.useState(!1);return l.useEffect(()=>{i.kind==="ready"&&u(!0)},[i.kind]),l.useEffect(()=>{i.kind==="ready"&&!n&&s()},[i.kind,n,s]),hF(n,r),t.jsx("div",{"data-testid":"design-session-chat",style:{display:"flex",flexDirection:"column",flex:1,minHeight:0,height:"100%"},children:n&&d?t.jsx(uS,{terminal:t.jsx(qt,{chatName:Ka,slashCommand:"/codeyam-design",height:"100%",beforeRelaunch:gl})}):i.kind==="error"?t.jsx("div",{style:{margin:"var(--spacing-md, 12px)"},children:t.jsx(gb,{message:i.message,hint:"Or skip to build from the canvas on the right.",onRetry:()=>void c()})}):t.jsxs("div",{role:"status",style:{display:"flex",alignItems:"center",gap:10,padding:"16px 14px",fontSize:13,color:"var(--text-muted)"},children:[t.jsx("span",{"aria-hidden":"true",className:"animate-spin",style:{width:14,height:14,borderRadius:"50%",border:"2px solid rgba(199,240,74,.15)",borderTopColor:"var(--accent-active)"}}),o==="files"?"Reading your files and getting the design agent ready…":"Getting the design agent ready…"]})})}const cte=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireDesignChatStep:Hl},Symbol.toStringTag,{value:"Module"}));function Fu(){return t.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 dte=Object.freeze(Object.defineProperty({__proto__:null,QuestionnaireIntroBanner:Fu},Symbol.toStringTag,{value:"Module"}));function pS({progress:e,onBack:n,onNext:s,nextLabel:r="Next",nextEnabled:a=!0,hideFooter:o=!1,wide:i=!1,children:c}){return t.jsxs("div",{style:{position:"fixed",inset:0,zIndex:60,background:"var(--bg-deep)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[t.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center",padding:"14px 26px",flexShrink:0,zIndex:4},children:[t.jsx("span",{style:{color:"var(--text-primary)",display:"flex"},children:t.jsx(cs,{className:"h-5"})}),t.jsx("a",{href:"https://codeyam.com/guides",target:"_blank",rel:"noopener noreferrer",style:{marginLeft:"auto",fontSize:13,color:"var(--text-muted)",textDecoration:"none",cursor:"pointer"},children:"Help"}),t.jsx("div",{style:{position:"absolute",left:0,right:0,bottom:0,height:1.5,background:"rgba(255,255,255,.06)"},children:t.jsx("i",{"data-testid":"onboarding-progress-fill",style:{display:"block",height:"100%",width:`${Math.round(e*100)}%`,background:"var(--accent-active)",transition:"width .5s cubic-bezier(.2,.8,.2,1)"}})})]}),t.jsx("div",{style:{flex:1,minHeight:0,display:"flex",alignItems:"flex-start",justifyContent:"center",padding:"20px 26px 90px",overflowY:"auto",overscrollBehavior:"contain"},children:t.jsx("div",{style:{width:"100%",maxWidth:i?"none":940,textAlign:i?"left":"center",margin:i?0:"auto 0",flex:i?1:void 0,display:i?"flex":void 0,minHeight:0},children:c})}),!o&&t.jsxs("div",{style:{position:"absolute",left:0,right:0,bottom:0,display:"flex",alignItems:"center",padding:"34px 30px 22px",gap:14,pointerEvents:"none",background:"linear-gradient(to top, var(--bg-deep) 62%, rgba(30,30,30,0))"},children:[n&&t.jsx("button",{type:"button",onClick:n,style:{pointerEvents:"auto",background:"none",border:"none",padding:0,fontSize:13.5,color:"var(--text-dim)",cursor:"pointer"},children:"← Back"}),t.jsxs("button",{type:"button","data-testid":"onboarding-next",onClick:()=>{a&&s()},disabled:!a,style:{pointerEvents:"auto",marginLeft:"auto",background:a?"var(--accent-active)":"#2b2b2b",color:a?"var(--text-on-accent, #14170a)":"var(--text-dim)",border:"none",borderRadius:12,padding:"12px 20px",fontSize:14,fontWeight:700,cursor:a?"pointer":"not-allowed",transition:".18s"},children:[r," →"]})]})]})}const ute=Object.freeze(Object.defineProperty({__proto__:null,OnboardingShell:pS},Symbol.toStringTag,{value:"Module"})),hS=3,Ca=112,zF=.5;function fS({value:e,onChange:n,onSubmit:s,files:r,onAddFiles:a,onRemoveFile:o}){const i=l.useRef(null),[c,d]=l.useState(!1),u=To(),p=x=>{x.length>0&&a(x)},[h,f]=l.useState(!1),m=e.trim().length>=hS;l.useLayoutEffect(()=>{const x=i.current;if(!x)return;x.style.height="auto";const b=Math.max(Ca,Math.round(window.innerHeight*zF)),y=Math.min(b,Math.max(Ca,x.scrollHeight));x.style.height=`${y}px`,x.style.overflowY=x.scrollHeight>b?"auto":"hidden"},[e]),l.useEffect(()=>{const x=i.current;x&&(x.focus(),x.setSelectionRange(x.value.length,x.value.length))},[]);const g=()=>{m&&s(e)};return t.jsxs("div",{children:[t.jsxs("div",{"data-testid":"prompt-box","data-dragging":c?"true":"false",onDragOver:x=>{x.preventDefault(),d(!0)},onDragLeave:x=>{x.currentTarget.contains(x.relatedTarget)||d(!1)},onDrop:x=>{x.preventDefault(),d(!1),x.dataTransfer&&u.fromDrop(x.dataTransfer).then(p)},style:{textAlign:"left",background:c?"#2d3020":"var(--bg-input)",border:`1px ${c?"dashed":"solid"} ${c?"var(--accent-active)":h?"var(--line-strong)":"rgba(255,255,255,.09)"}`,borderRadius:16,transition:"border-color .15s, background .15s"},children:[t.jsx("textarea",{ref:i,value:e,onChange:x=>n(x.target.value),onFocus:()=>f(!0),onBlur:()=>f(!1),onKeyDown:x=>{x.key!=="Enter"||x.shiftKey||(x.preventDefault(),g())},onPaste:x=>{var y;const b=Array.from(((y=x.clipboardData)==null?void 0:y.files)??[]);b.length!==0&&(x.preventDefault(),u.clearError(),a(uo(b)))},placeholder:"Ask CodeYam to build...","aria-label":"Describe what you want to build",style:{display:"block",width:"100%",minHeight:Ca,resize:"none",background:"none",border:0,padding:"20px 22px 6px",fontSize:17,lineHeight:1.5,fontFamily:"inherit",color:"var(--text-primary)",outline:"none"}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 12px 12px"},children:[t.jsxs(xo,{onPickFiles:x=>p(u.fromFileInput(x)),onPickFolder:x=>p(u.fromFolderInput(x)),fileInputLabel:"Add files",title:"Specs, designs, brand assets, screenshots, or a whole folder",className:"border border-[var(--line-strong)] bg-white/[0.07] transition-colors hover:border-white/[0.35] hover:bg-white/[0.14]",style:{flex:"none",display:"inline-flex",alignItems:"center",gap:7,height:34,padding:"0 13px 0 10px",borderRadius:9,color:"var(--text-primary)",fontSize:13,fontWeight:500,cursor:"pointer"},children:[t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:"var(--accent-active)",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M13.5 7.5l-5.6 5.6a3.2 3.2 0 01-4.5-4.5l5.9-5.9a2.1 2.1 0 013 3l-5.9 5.9a1.1 1.1 0 01-1.5-1.5l5.3-5.3"})}),"Add files"]}),t.jsx("span",{style:{fontSize:12.5,color:"var(--text-muted)",minWidth:0},children:"Add every doc you have: specs, designs, brand assets, screenshots."}),t.jsx("span",{style:{flex:1}}),t.jsx("button",{type:"button",onClick:g,disabled:!m,"aria-label":"Start design session",title:"Start design session (Enter)",style:{flex:"none",width:36,height:36,borderRadius:10,border:"none",display:"grid",placeItems:"center",background:m?"var(--accent-active)":"rgba(255,255,255,.08)",color:m?"var(--text-on-accent)":"var(--text-dim)",cursor:m?"pointer":"not-allowed"},children:t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M3 8h10M8.5 3.5L13 8l-4.5 4.5"})})})]})]}),t.jsx(Zc,{message:u.error,style:{padding:"10px 2px 0"}}),r.length>0&&t.jsx("div",{"aria-label":"Attached files",style:{display:"flex",flexWrap:"wrap",gap:6,padding:"12px 2px 0"},children:r.map(({file:x,relativePath:b},y)=>t.jsx(zr,{file:x,name:b,onRemove:()=>o(y)},`${b}-${y}`))})]})}const pte=Object.freeze(Object.defineProperty({__proto__:null,MIN_IDEA_LENGTH:hS,OnboardingPromptBox:fS,PROMPT_MIN_HEIGHT:Ca},Symbol.toStringTag,{value:"Module"}));function mS({selectedName:e,onOpen:n,onClear:s}){return e?t.jsxs("div",{style:{marginTop:8,fontSize:12.5},children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:"Tech stack: "}),t.jsx("span",{style:{color:"var(--text-secondary)"},children:e}),t.jsx("button",{type:"button",onClick:n,style:Tf,children:"Change"}),t.jsx("button",{type:"button",onClick:s,style:Tf,children:"Clear"})]}):t.jsx("div",{style:{marginTop:8},children:t.jsx("button",{type:"button",onClick:n,"aria-expanded":!1,style:{background:"none",border:"none",padding:0,fontSize:12.5,fontFamily:"inherit",color:"var(--text-dim)",textDecoration:"underline",textUnderlineOffset:3,cursor:"pointer"},children:"I want a specific tech stack"})})}const Tf={background:"none",border:"none",padding:0,marginLeft:10,fontSize:12.5,fontFamily:"inherit",color:"var(--text-dim)",textDecoration:"underline",textUnderlineOffset:3,cursor:"pointer"},hte=Object.freeze(Object.defineProperty({__proto__:null,StackPickerCollapsed:mS},Symbol.toStringTag,{value:"Module"}));function gS({matches:e,totalStacks:n,query:s,selectedStackId:r,onChoose:a}){return e.length===0?t.jsx("p",{style:{margin:"10px 2px 0",fontSize:12.5,color:"var(--text-dim)"},children:n===0?"No stacks available yet. CodeYam will pick one for you.":`No stack matches “${s.trim()}”. CodeYam will pick one for you.`}):t.jsx("ul",{role:"listbox","aria-label":"Tech stacks",style:{listStyle:"none",margin:"8px 0 0",padding:0,maxHeight:188,overflowY:"auto"},children:e.map(o=>t.jsx("li",{children:t.jsxs("button",{type:"button",role:"option","aria-selected":o.id===r,onClick:()=>a(o),style:{display:"block",width:"100%",textAlign:"left",background:"transparent",border:"none",borderRadius:8,padding:"8px 12px",fontSize:13,fontFamily:"inherit",color:"var(--text-secondary)",cursor:"pointer"},children:[o.name,t.jsx("span",{style:{marginLeft:8,fontSize:11.5,color:"var(--text-dim)"},children:o.description})]})},o.id))})}const fte=Object.freeze(Object.defineProperty({__proto__:null,StackPickerResults:gS},Symbol.toStringTag,{value:"Module"}));function xS({stacks:e,selectedStackId:n,onSelectStack:s}){const[r,a]=l.useState(!1),[o,i]=l.useState(""),c=l.useRef(null),d=e.find(h=>h.id===n)??null;l.useEffect(()=>{var h;r&&((h=c.current)==null||h.focus())},[r]);const u=l.useMemo(()=>{const h=o.trim().toLowerCase();return h?e.filter(f=>f.name.toLowerCase().includes(h)||f.description.toLowerCase().includes(h)):e},[e,o]),p=h=>{s(h.id),i(""),a(!1)};return r?t.jsxs("div",{style:{marginTop:8},children:[t.jsx("input",{ref:c,type:"text",value:o,onChange:h=>i(h.target.value),onKeyDown:h=>{if(h.key==="Escape"){h.stopPropagation(),i(""),a(!1);return}if(h.key==="Enter"){h.preventDefault(),h.stopPropagation();const f=u[0];f&&p(f)}},placeholder:"Search stacks…","aria-label":"Search tech stacks",style:{width:"100%",background:"var(--bg-input)",border:"1px solid rgba(255,255,255,.09)",borderRadius:10,padding:"10px 14px",fontSize:13.5,fontFamily:"inherit",color:"var(--text-primary)",outline:"none"}}),t.jsx(gS,{matches:u,totalStacks:e.length,query:o,selectedStackId:n,onChoose:p})]}):t.jsx(mS,{selectedName:(d==null?void 0:d.name)??null,onOpen:()=>a(!0),onClear:()=>s(null)})}const mte=Object.freeze(Object.defineProperty({__proto__:null,OnboardingStackPicker:xS},Symbol.toStringTag,{value:"Module"})),bS=[{id:"mobile",label:"Mobile app"},{id:"web",label:"Web app"},{id:"static",label:"Website"},{id:"chrome-extension",label:"Chrome extension"},{id:"game",label:"Game"},{id:"other",label:"Other"}];function yS({appFormats:e,onToggleFormat:n}){return t.jsxs("div",{role:"group","aria-label":"What kind of thing",style:{display:"flex",flexWrap:"wrap",justifyContent:"center",gap:8,marginBottom:16},children:[t.jsx("style",{children:`
|
|
69
|
+
.cy-type-chip:not([aria-pressed="true"]):hover {
|
|
70
|
+
border-color: rgba(215,255,99,.55) !important;
|
|
71
|
+
color: var(--text-primary) !important;
|
|
72
|
+
background: rgba(215,255,99,.06) !important;
|
|
73
|
+
}
|
|
74
|
+
.cy-type-chip:focus-visible { outline: 2px solid var(--accent-active); outline-offset: 2px; }
|
|
75
|
+
`}),bS.map(({id:s,label:r})=>{const a=e.includes(s);return t.jsx("button",{type:"button",className:"cy-type-chip","aria-pressed":a,onClick:()=>n(s),style:{background:a?"var(--accent-active)":"rgba(255,255,255,.06)",border:`1px solid ${a?"var(--accent-active)":"rgba(255,255,255,.2)"}`,borderRadius:999,padding:"8px 16px",fontSize:13.5,fontWeight:a?600:500,color:a?"var(--text-on-accent, #14170a)":"rgba(255,255,255,.82)",cursor:"pointer",transition:"background .16s, border-color .16s, color .16s"},children:r},s)})]})}const gte=Object.freeze(Object.defineProperty({__proto__:null,OnboardingTypeChips:yS,PRODUCT_TYPES:bS},Symbol.toStringTag,{value:"Module"}));function vS({value:e,onChange:n,onSubmit:s,stacks:r=[],selectedStackId:a=null,onSelectStack:o,appFormats:i=[],onToggleFormat:c,files:d=[],onAddFiles:u,onRemoveFile:p}){return t.jsxs("div",{children:[t.jsx("h1",{style:{fontSize:34,fontWeight:600,letterSpacing:"-.02em",color:"var(--text-primary)",lineHeight:1.15,marginBottom:10},children:"What do you want to build?"}),t.jsxs("div",{style:{maxWidth:720,margin:"0 auto",textAlign:"left"},children:[t.jsx(yS,{appFormats:i,onToggleFormat:c??(()=>{})}),t.jsx(fS,{value:e,onChange:n,onSubmit:s,files:d,onAddFiles:u??(()=>{}),onRemoveFile:p??(()=>{})}),t.jsx(xS,{stacks:r,selectedStackId:a,onSelectStack:o??(()=>{})})]})]})}const xte=Object.freeze(Object.defineProperty({__proto__:null,OnboardingPromptStep:vS},Symbol.toStringTag,{value:"Module"}));function jS({sound:e,onChange:n}){return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[t.jsx("span",{style:{fontSize:12.5,color:"var(--text-dim)"},children:"Sound"}),t.jsx("select",{value:e,"aria-label":"Notification sound",onChange:s=>n(s.target.value),style:{background:"var(--bg-input)",border:"1px solid rgba(255,255,255,.09)",borderRadius:8,padding:"5px 9px",fontSize:12.5,fontFamily:"inherit",color:"var(--text-secondary)",outline:"none",cursor:"pointer"},children:Fl.map(s=>t.jsx("option",{value:s.id,children:s.label},s.id))})]})}const bte=Object.freeze(Object.defineProperty({__proto__:null,NotificationSoundSelect:jS},Symbol.toStringTag,{value:"Module"}));function wS({onBack:e,onNext:n}){const[s,r]=l.useState(()=>o0());l.useEffect(()=>{d0()},[]);function a(d){r(d),i0(d)}function o(){const d=s.sound==="off"?"soft-double-tap":s.sound;a({...s,systemNotification:!0,sound:d}),typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()}function i(){a({...s,systemNotification:!1,sound:"off"})}const c=s.systemNotification;return t.jsxs("div",{children:[t.jsx("h1",{style:{fontSize:34,fontWeight:600,letterSpacing:"-.02em",color:"var(--text-primary)",lineHeight:1.15,marginBottom:10},children:"Building takes a few minutes"}),t.jsx("p",{style:{fontSize:15,lineHeight:1.55,color:"var(--text-muted)",marginBottom:20},children:"I'll let you know the moment I need you."}),t.jsxs("div",{style:{maxWidth:720,margin:"0 auto",textAlign:"left"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,minHeight:46,padding:"0 14px 0 18px",background:"var(--bg-input)",border:"1px solid rgba(255,255,255,.09)",borderRadius:14},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,fontSize:14,color:"var(--text-secondary)",cursor:"pointer"},children:[t.jsx("input",{type:"checkbox",checked:c,onChange:d=>d.target.checked?o():i(),style:{width:15,height:15,accentColor:"var(--accent-active)",cursor:"pointer"}}),"Ping me when the build is done"]}),t.jsx("span",{style:{flex:1}}),c&&t.jsx(jS,{sound:s.sound,onChange:d=>{a({...s,sound:d}),d!=="off"&&ju(d)}})]}),(e||n)&&t.jsxs("div",{style:{display:"flex",alignItems:"center",marginTop:14},children:[e&&t.jsx("button",{type:"button",onClick:e,style:{background:"none",border:"none",padding:0,fontSize:13.5,color:"var(--text-dim)",cursor:"pointer"},children:"← Back"}),t.jsx("span",{style:{flex:1}}),n&&t.jsx("button",{type:"button","data-testid":"onboarding-notifications-next",onClick:n,style:{height:36,padding:"0 16px",borderRadius:10,border:"none",background:"var(--accent-active)",color:"var(--text-on-accent, #14170a)",fontSize:14,fontWeight:700,cursor:"pointer"},children:"Next →"})]})]})]})}const yte=Object.freeze(Object.defineProperty({__proto__:null,OnboardingNotificationsStep:wS},Symbol.toStringTag,{value:"Module"}));function _S(e){const{projectDir:n,loaded:s}=ho(),r=l.useRef(!1);l.useEffect(()=>{s&&!r.current&&(r.current=!0,sF())},[s]);const[a,o]=l.useState(void 0);return l.useEffect(()=>{if(!s)return;if(n===null){o(null);return}let i=!1;return nF(n).then(c=>{i||o(c)}).catch(()=>{i||o(null)}),()=>{i=!0}},[s,n]),!s||a===void 0?t.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"auto"},children:t.jsx(Fu,{})}):t.jsx(SS,{...e,projectDir:n,initialDraft:a})}function SS({onComplete:e,onPreviewUrl:n,projectDir:s,initialDraft:r,skipDesignSignal:a=0}){const[o,i]=l.useState(()=>r?r.step:1),[c,d]=l.useState(()=>(r==null?void 0:r.answers)??{appFormats:[],description:"",techStackId:null,designApproach:null,defaultDevice:"Desktop",provider:null}),[u,p]=l.useState(null),[h,f]=l.useState([]),[m,g]=l.useState(()=>(r==null?void 0:r.designChatLaunched)??!1),x=l.useRef(m),{techStacks:b}=aF(),{config:y,refetch:v}=St(),j=Wc(),{askForProvider:_,declaredProvider:w}=lF(y,j.state,j.probeInFlight);l.useEffect(()=>{w!==null&&d(ee=>ee.provider?ee:{...ee,provider:w})},[w]);const k=Z3(c.designApproach,{providerDeclared:!_,providerAuth:_?"needs-login":"authenticated"}),S=k[o-1],N=o===k.length;l.useEffect(()=>{_!==null&&o>k.length&&i(k.length)},[_,o,k.length]);const C=l.useRef(Ai(o,c,m)),T=l.useRef((r==null?void 0:r.savedAt)??""),P=l.useRef(!1),R=l.useRef((r==null?void 0:r.submissionKey)??null),I=l.useCallback(ee=>{R.current=ee},[]),A=l.useCallback(()=>R.current,[]),O=l.useRef(!0);l.useEffect(()=>{if(O.current){O.current=!1;return}if(s===null)return;const ee=Ai(o,c,m);if(ee===C.current)return;C.current=ee;const Q=new Date().toISOString();T.current=Q,z0({step:o,answers:c,designChatLaunched:m,savedAt:Q,submissionKey:R.current??void 0},I)},[o,c,m,s,I]);const W=l.useCallback(ee=>{P.current=!0,d(ee)},[]),D=l.useRef(c);l.useEffect(()=>{D.current=c},[c]);const Y=l.useCallback(ee=>{W(Q=>({...Q,provider:ee})),(async()=>{try{await fetch("/api/editor-provider",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:ee})})}catch{}await v(),await j.refresh()})()},[W,j,v]),H=l.useCallback(()=>{g(!0)},[]),[E,U]=l.useState(0),[M,J]=l.useState(x.current?{state:"pending"}:{state:"ready",active:null});l.useEffect(()=>{if(!x.current)return;let ee=!1;return(async()=>{try{const te=await(await fetch("/api/editor-design-state")).json();ee||J({state:"ready",active:te.active??null})}catch{ee||J({state:"ready",active:null})}})(),()=>{ee=!0}},[E]),l.useEffect(()=>{if(s===null)return;const ee=()=>{document.visibilityState==="visible"&&$0().then(Q=>{Q!=null&&Q.submissionKey&&(R.current=Q.submissionKey);const te=rF(Q,T.current,P.current,D.current);te!==null&&(T.current=te.savedAt,te.designChatLaunched&&!x.current&&(x.current=!0,J({state:"pending"}),U(he=>he+1)),C.current=Ai(te.step,te.answers,te.designChatLaunched),i(te.step),g(te.designChatLaunched),d(te.answers))})};return document.addEventListener("visibilitychange",ee),()=>document.removeEventListener("visibilitychange",ee)},[s]);const ne=l.useCallback(ee=>{d(Q=>({...Q,appFormats:Q.appFormats.includes(ee)?Q.appFormats.filter(te=>te!==ee):[...Q.appFormats,ee]}))},[]),oe=l.useCallback(ee=>{d(Q=>({...Q,techStackId:ee}))},[]),ae=l.useCallback(ee=>{f(Q=>[...Q,...ee])},[]),G=l.useCallback(ee=>{f(Q=>Q.filter((te,he)=>he!==ee))},[]),ie=l.useCallback(()=>{s!==null&&ff(),e==null||e(c)},[c,e,s]),{submit:le,submitting:Z,error:z}=X3(c,ie,A),L=z?t.jsx(db,{message:z,onRetry:()=>void le(),retrying:Z}):null,q=l.useRef(a);l.useEffect(()=>{if(a===q.current)return;q.current=a;const ee={...c,designApproach:"skip"};(async()=>(await M0(ee,A())).ok&&(s!==null&&ff(),e==null||e(ee)))()},[a,c,e,s,A]);const se=l.useRef(!1);l.useEffect(()=>{se.current||M.state==="ready"&&S==="design-details"&&(c.designApproach==="chat"||c.designApproach==="files")&&u!==null&&u!==M.active&&(se.current=!0,le())},[S,c.designApproach,u,le,M]);const fe=j.refresh,we=l.useCallback(()=>{S==="provider"&&fe(),i(ee=>ee+1)},[S,fe]),De=l.useCallback(()=>{i(ee=>ee-1)},[]),Fe=(()=>{switch(S){case"provider":return!!c.provider;case"prompt":return c.description.trim().length>2;case"notifications":return!0;case"design-details":return c.designApproach==="chat"?u!==null:!0;default:return!0}})(),Me=l.useCallback(ee=>{d(Q=>({...Q,description:ee,appFormats:Q.appFormats.length>0?Q.appFormats:[oF(ee)],designApproach:h.length>0?"files":"chat"})),h.length>0&&Bd(h.map(({file:Q,relativePath:te},he)=>({id:`prompt-${he}`,file:Q,relativePath:te,description:""}))).catch(Q=>{console.warn("[NewProjectQuestionnaire] could not save prompt files",Q)}),i(Q=>Q+1)},[h]);if(_===null)return t.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"auto"},children:t.jsx(Fu,{})});if(S){const ee=S==="design-details";if(ee)return t.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[L,t.jsx(Hl,{description:c.description,launched:m,onLaunched:H,onDesignSelected:p,onPreviewUrl:n,variant:c.designApproach==="files"?"files":"chat"})]});const Q=N?le:we;return t.jsxs(pS,{progress:k.length>1?(o-1)/(k.length-1):0,onBack:o>1?De:void 0,onNext:Q,nextEnabled:Fe&&!Z,hideFooter:S!=="provider",children:[L,t.jsxs("div",{style:{animation:"onboardingSlideIn .44s cubic-bezier(.2,.8,.2,1) both"},children:[S==="provider"&&t.jsx(H0,{selected:c.provider??null,onSelect:Y,onContinueWithoutSignIn:we,onSignedIn:we}),S==="prompt"&&t.jsx(vS,{value:c.description,onChange:te=>d(he=>({...he,description:te})),onSubmit:Me,stacks:b,selectedStackId:c.techStackId,onSelectStack:oe,appFormats:c.appFormats,onToggleFormat:ne,files:h,onAddFiles:ae,onRemoveFile:G}),S==="notifications"&&t.jsx(wS,{onBack:De,onNext:()=>{Z||Q()}}),ee&&t.jsx(Hl,{description:c.description,launched:m,onLaunched:H,onDesignSelected:p,onPreviewUrl:n,variant:c.designApproach==="files"?"files":"chat"})]},S)]})}return null}const vte=Object.freeze(Object.defineProperty({__proto__:null,NewProjectQuestionnaire:_S,NewProjectQuestionnaireInner:SS},Symbol.toStringTag,{value:"Module"}));function kS({projectTitle:e,projectDescription:n,stats:s,coverage:r,onSelectApp:a,configLoading:o,scenariosLoading:i,testsLoading:c,testsRefreshing:d,onRunTests:u,currentRunner:p,stepState:h,onPreviewUrl:f,onComplete:m,onOpenBuildTab:g,onCoverageClick:x,isBuilding:b=!1,buildingLabel:y,buildingStepLabel:v,buildingStepPosition:j,buildingStatus:_,buildingProgress:w,onResetBuild:k,emptyStateBuildStatus:S,skipDesignSignal:N=0}){const{saved:C}=h0(),T=Uo(),[P,R]=l.useState(null),I=y0(T);return s.length===0?o||i||C===null?null:f0({appStatsLength:s.length,configLoading:!!o,scenariosLoading:!!i,setupAnswersSaved:C,hasStepState:!!h})?t.jsx(_S,{onPreviewUrl:f,onComplete:m,skipDesignSignal:N}):(T==null?void 0:T.state)==="interrupted"&&P!==T.id&&!kb(T.id)?t.jsx("div",{className:"mx-auto max-w-2xl px-5 py-12",children:t.jsx(Cd,{request:T,onRecovered:g??(()=>{}),onKeptForLater:()=>R(T.id)})}):t.jsx(b0,{projectDescription:n??null,status:S,buildRequestedAt:(T==null?void 0:T.createdAt)??null,failureReason:(T==null?void 0:T.failureReason)??null,launchRecovery:T&&jd(T.state)?t.jsx(wd,{state:T.state,cause:T.failureReason??null,...I,onOpenTerminal:g}):null,onOpenBuildTab:g??(()=>{})}):t.jsx("div",{className:"px-5 py-5",children:t.jsxs("div",{style:{width:"100%",maxWidth:1e3,marginInline:"auto"},children:[t.jsx(j0,{projectTitle:e,coverage:r,onCoverageClick:x}),t.jsx(A0,{isBuilding:b,buildingLabel:y,buildingStepLabel:v,buildingStepPosition:j,buildingStatus:_,buildingProgress:w,buildingMode:h==null?void 0:h.mode,onOpenBuilding:g??(()=>{}),onResetBuild:k??(()=>{})}),t.jsx(v0,{stats:s,onSelectApp:a,testsLoading:c,testsRefreshing:d,onRunTests:u,currentRunner:p})]})})}const jte=Object.freeze(Object.defineProperty({__proto__:null,AppOverview:kS},Symbol.toStringTag,{value:"Module"}));function NS({sessionContent:e,stepIndicator:n}){return t.jsxs("div",{className:"flex flex-col h-full",children:[n,e]})}const wte=Object.freeze(Object.defineProperty({__proto__:null,BuildTabLayout:NS},Symbol.toStringTag,{value:"Module"}));function CS({activeTab:e,launchBanner:n=null,buildTab:s,resultsPanel:r,minimizedResults:a,resultsMode:o,badgeGutter:i=!0}){return t.jsxs("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:e==="build"?"visible":"hidden",pointerEvents:e==="build"?"auto":"none"},children:[n?t.jsx("div",{className:"shrink-0 p-2",children:n}):null,t.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[t.jsx("div",{style:{flex:"1 1 auto",minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"},children:s}),o==="full"?t.jsx(jx,{children:r}):null,o==="minimized"?a:null]}),i&&t.jsx("div",{"data-testid":"build-pane-badge-gutter","aria-hidden":"true",className:"h-6 shrink-0"})]})}const _te=Object.freeze(Object.defineProperty({__proto__:null,BuildTabPaneLayout:CS},Symbol.toStringTag,{value:"Module"}));function BF(e="build"){return{title:`CodeYam found a saved ${e} session`,description:"",buttonLabel:"Resume Session",providersLabel:null}}function WF(e,n){const s=Qe(e),r=Qe(n);return{title:"Saved Handoff Ready",description:`A ${s} 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:`${s} to ${r}`}}function HF({resumeMode:e,previousProvider:n,currentProvider:s,sessionKind:r="build"}){return e!=="handoff"||n==null||s==null||n===s?BF(r):WF(n,s)}const Pf=140;function qF(e){const n=e.trim();return n.startsWith("/")||n.startsWith("The session was interrupted.")}function UF(e){for(let n=e.length-1;n>=0;n--){const s=e[n];if(s.role!=="user"||!s.text.trim()||qF(s.text))continue;const r=s.text.replace(/\s+/g," ").trim();return r.length<=Pf?r:`${r.slice(0,Pf-1).trimEnd()}…`}return null}function YF(e){return e==="prototype"||e==="plan"||e==="chat"?e:"build"}function Ii(e,n){return`${e} ${n}${e===1?"":"s"} ago`}function GF(e){if(e==null||e<0)return null;if(e<60)return"just now";const n=Math.floor(e/60);if(n<60)return Ii(n,"minute");const s=Math.floor(n/60);return s<24?Ii(s,"hour"):Ii(Math.floor(s/24),"day")}function TS({label:e,onContinue:n}){return t.jsx("button",{onClick:n,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:e})}const Ste=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoveryActionButton:TS},Symbol.toStringTag,{value:"Module"}));function PS({children:e}){return t.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:t.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:e})})}const kte=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoveryDialog:PS},Symbol.toStringTag,{value:"Module"}));function OS({description:e,title:n}){return t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:"text-lg font-semibold mb-4",style:{color:"var(--text-primary)"},children:n}),e&&t.jsx("p",{className:"text-sm mb-4",style:{color:"var(--text-muted)"},children:e})]})}const Nte=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoveryHeader:OS},Symbol.toStringTag,{value:"Module"}));function Ss({label:e,rowClassName:n,value:s}){return t.jsxs("div",{className:n,children:[t.jsxs("span",{style:{color:"var(--text-muted)"},children:[e,":"]})," ",t.jsx("span",{style:{color:"var(--text-primary)"},children:s})]})}const Cte=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoverySummaryRow:Ss},Symbol.toStringTag,{value:"Module"}));function RS({featureName:e,editorStep:n,editorStepLabel:s,providersLabel:r,lastRequest:a=null,lastActive:o=null}){return!e&&(n==null||!s)&&!r&&!a&&!o?null:t.jsxs("div",{className:"rounded p-3 mb-5 text-sm flex flex-col gap-1",style:{background:"var(--bg-deep)"},children:[e&&t.jsx(Ss,{label:"Feature",value:e}),n!=null&&s&&t.jsx(Ss,{label:"Step",value:`${n} (${s})`}),a&&t.jsx(Ss,{label:"Last request",value:a}),o&&t.jsx(Ss,{label:"Last active",value:o}),r&&t.jsx(Ss,{label:"Providers",value:r})]})}const Tte=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecoverySummary:RS},Symbol.toStringTag,{value:"Module"}));function VF(e){const n=l.useCallback(s=>{s.key==="Enter"&&(s.preventDefault(),e())},[e]);l.useEffect(()=>(window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)),[n])}function KF(e){const[n,s]=l.useState(void 0);return l.useEffect(()=>{if(s(void 0),!e)return;let r=!1;return fetch(`/api/editor-agent-chat?session=${encodeURIComponent(e)}`).then(a=>a.ok?a.json():void 0).then(a=>{r||!a||s(a.available?UF(a.messages):null)}).catch(()=>{}),()=>{r=!0}},[e]),n}function ES({featureName:e,editorStep:n,workflowMode:s,previousProvider:r,currentProvider:a,resumeMode:o,sessionId:i=null,activity:c=null,idleSeconds:d=null,onContinue:u,onStartOver:p,onEmptySession:h}){const f=HF({resumeMode:o,previousProvider:r,currentProvider:a,sessionKind:YF(c)}),m=n==null?null:wu(n,s),g=KF(i);VF(u);const x=g===null&&!e&&n==null,b=l.useRef(!1);return l.useEffect(()=>{x&&h&&!b.current&&(b.current=!0,h())},[x,h]),t.jsxs(PS,{children:[t.jsx(OS,{title:f.title,description:f.description}),t.jsx(RS,{featureName:e,editorStep:n,editorStepLabel:m,providersLabel:f.providersLabel,lastRequest:g===null?"Nothing asked yet":g??null,lastActive:GF(d)}),t.jsx(TS,{label:f.buttonLabel,onContinue:u}),p&&t.jsx("button",{type:"button",onClick:p,className:"mt-3 w-full text-center text-xs underline underline-offset-2 cursor-pointer transition",style:{color:"var(--text-muted)"},children:"Start over"})]})}const Pte=Object.freeze(Object.defineProperty({__proto__:null,EditorSessionRecovery:ES},Symbol.toStringTag,{value:"Module"}));function AS({currentProvider:e,editorStep:n,featureName:s,onContinue:r,onStartOver:a,onEmptySession:o,previousProvider:i,resumeMode:c,workflowMode:d,sessionId:u,activity:p,idleSeconds:h}){return t.jsx(ES,{featureName:s,editorStep:n,workflowMode:d,previousProvider:i,currentProvider:e,resumeMode:c,sessionId:u,activity:p,idleSeconds:h,onContinue:r,onStartOver:a,onEmptySession:o})}const Ote=Object.freeze(Object.defineProperty({__proto__:null,BuildTabRecoveryPanel:AS},Symbol.toStringTag,{value:"Module"}));function ms(){let e=!1;const n=new Set;return{get:()=>e,set:s=>{if(e!==s){e=s;for(const r of n)r()}},subscribe:s=>(n.add(s),()=>n.delete(s))}}const $u=ms(),zu=ms(),MS=$u.get,Bu=$u.set,IS=$u.subscribe,ql=zu.get,Wu=zu.set,DS=zu.subscribe;function JF({sessionDecision:e,sessionInfo:n,buildLaunchGateArmed:s,stepState:r}){return{recoveryFeatureName:(r==null?void 0:r.feature)??(n==null?void 0:n.feature)??null,recoveryStep:(r==null?void 0:r.step)??(n==null?void 0:n.step)??null,recoveryMode:(r==null?void 0:r.mode)??(n==null?void 0:n.mode)??null,showTerminal:!s&&(e==="continue"||e==="fresh"||e==="no-session")&&(r!==null||n!==null),shouldResumeSameProvider:e==="continue"&&(n==null?void 0:n.resumeMode)==="resume"}}const LS="codeyam:chat-milestones:",Ul=new Map;function XF(e){const n=Ul.get(e);if(n)return n;try{const s=window.sessionStorage.getItem(LS+e);if(!s)return null;const r=JSON.parse(s);return Array.isArray(r.milestones)?(r.milestones=r.milestones.filter(a=>a&&"afterId"in a),Ul.set(e,r),r):null}catch{return null}}function Of(e,n){Ul.set(e,n);try{window.sessionStorage.setItem(LS+e,JSON.stringify(n))}catch{}}const FS="codeyam.buildChatExperimentalNoticeDismissed",QF="Chat is an experimental feature designed to make working with AI more intuitive and friendly. It is still experimental, though, so for now we recommend continuing to use the Terminal which shows the raw agent output";function ZF(){try{return window.localStorage.getItem(FS)==="1"}catch{return!1}}function e$(){try{window.localStorage.setItem(FS,"1")}catch{}}const Rf="linear-gradient(to right, transparent, var(--border-default) 20%, var(--border-default) 80%, transparent) 1";function Gr(e){return e==="top"?{borderTop:"1px solid",borderImage:Rf}:{borderBottom:"1px solid",borderImage:Rf}}function t$(e){for(const n of e??[]){if(!/Waiting for API response/i.test(n))continue;const s=/will retry in\s+([0-9hms ]+?)(?:\s*·|\s*$)/i.exec(n);return{retryIn:s?s[1].trim():null}}return null}const Ef="⏺",n$=/^[A-Za-z][\w.:-]*\(/,s$=/^\s*(⎿|[─━╭╰│]|[✻✶✳✢·*]\s|❯|>\s)/;function r$(e){const n=e??[];let s=-1;for(let i=n.length-1;i>=0;i--)if(n[i].startsWith(`${Ef} `)){s=i;break}if(s<0)return null;const r=n[s].slice(Ef.length+1);if(n$.test(r))return null;const a=[r.trimEnd()];for(let i=s+1;i<n.length;i++){const c=n[i];if(c.trim()===""){a.push("");continue}if(!c.startsWith(" ")||s$.test(c))break;a.push(c.slice(2).trimEnd())}return a.join(`
|
|
76
|
+
`).replace(/\n{3,}/g,`
|
|
77
|
+
|
|
78
|
+
`).trim()||null}function Di(e){return e.replace(/[*_`#>]/g,"").replace(/\s+/g," ").trim().toLowerCase()}function a$(e,n){if(!n)return e;const s=Di(n).slice(0,60);return!s||e.filter(a=>a.role==="agent").slice(-3).some(a=>Di(a.text).startsWith(s)||s.startsWith(Di(a.text).slice(0,60)))?e:[...e,{id:"live-reply",role:"agent",text:n,items:[]}]}const Hu=l.createContext(null);function $S({title:e,workflow:n=null,children:s}){const[r,a]=l.useState(0),o=l.useCallback(()=>(a(h=>h+1),()=>a(h=>h-1)),[]),i=(n==null?void 0:n.step)??0,c=(n==null?void 0:n.total)??0,d=(n==null?void 0:n.mode)??"",u=l.useMemo(()=>i>0?{step:i,total:c,mode:d}:null,[i,c,d]),p=l.useMemo(()=>({title:e,workflow:u,claim:o}),[e,u,o]);return t.jsx(Hu.Provider,{value:p,children:s(r>0)})}function zS(){const e=l.useContext(Hu),n=e==null?void 0:e.claim;return l.useLayoutEffect(()=>n?n():void 0,[n]),e?e.title:null}function BS(){var e;return((e=l.useContext(Hu))==null?void 0:e.workflow)??null}const Rte=Object.freeze(Object.defineProperty({__proto__:null,SessionHeaderProvider:$S,useSessionHeaderTitle:zS,useSessionWorkflow:BS},Symbol.toStringTag,{value:"Module"})),WS=15e3,o$=90;function i$(e,n){if(!n)return!1;const s=r=>`${r.text.join(`
|
|
79
|
+
`)}
|
|
80
|
+
${r.options.map(a=>a.label).join(`
|
|
81
|
+
`)}`;return s(e)===s(n)}const Af="waiting for a background task",Mf=Rn,l$=2e3,If=8e3;function Vr({renderTerminal:e,initialSessionId:n=null,height:s="100%",label:r,sessionName:a,onClose:o,footer:i,headerNote:c,handoff:d,intro:u,renderWrittenFile:p,onWaitingOnUser:h,onNeedsYouChange:f,startFreshOnNewRequest:m=!1,initialRequest:g=null,onWorkingChange:x,initialView:b="chat",experimentalNotice:y}){const[v,j]=l.useState(b),[_,w]=l.useState(ZF),k=()=>{w(!0),e$()},[S,N]=l.useState(!1),C=zS(),[T,P]=l.useState(n),[R,I]=l.useState(null),A=l.useRef(null),[O,W]=l.useState(!1),[D,Y]=l.useState(null),[H,E]=l.useState(null),[U,M]=l.useState(!1),J=l.useRef(m);J.current=m;const ne=l.useMemo(()=>({onSessionId:re=>{re&&P(re)},onNotice:Y,onScreen:I,onSender:re=>{A.current=re,W(!!re)},onReattached:re=>{re&&J.current&&M(!0)}}),[]),oe=l.useMemo(()=>e(ne),[ne,e]),ae=T?`/api/editor-agent-chat?session=${encodeURIComponent(T)}`:"",G=Tu(!!T,ae);l.useEffect(()=>{!U||!G.available||(M(!1),E({session:T,count:G.messages.length}))},[U,G.available,G.messages.length,T]);const ie=H&&H.session===T?H.count:null,le=l.useMemo(()=>ie===null?G.messages:G.messages.slice(ie),[G.messages,ie]),Z=re=>{var He;return((He=A.current)==null?void 0:He.call(A,re))??!1},[z,L]=l.useState(()=>g?[{id:"opening-request",text:g,after:0}]:[]),[q,se]=l.useState(null),fe=re=>{const He=dd(re);return br(Z,He)?(L(xt=>[...xt,{id:`${Date.now()}-${xt.length}`,text:He.replace(/\r$/,""),after:le.length}]),!0):!1},we=re=>void fe(re),De=async re=>{se(null);try{return await Po(re)}catch(He){return se(He instanceof Error?He.message:"Couldn't add those files."),null}},Fe=async(re,He)=>{se(null);let xt=re;if(He.length>0){const Dt=await De(He);if(Dt===null)return!1;xt=re?`${Dt} ${re}`:Dt}return fe(xt)},Me=l.useMemo(()=>Ko(le,z),[le,z]),ee=Me.length===0,[Q,te]=l.useState(!1),he=!G.available||ee;l.useEffect(()=>{if(!he||!O){te(!1);return}const re=window.setTimeout(()=>te(!0),WS);return()=>window.clearTimeout(re)},[he,O]);const ye=l.useMemo(()=>Ru(R),[R]),ve=l.useMemo(()=>G.working?a$(le,r$(R)):le,[G.working,le,R]),Ne=l.useMemo(()=>t$(R),[R]),de=l.useMemo(()=>TM(R),[R]),me=l.useMemo(()=>Lu(R),[R]),We=re=>re.forEach((He,xt)=>{window.setTimeout(()=>Z(He),xt*o$)}),[B,F]=l.useState(null),[X,ue]=l.useState(0),be=()=>{ye&&F(ye),ue(Date.now())},[xe,ke]=l.useState(!1);l.useEffect(()=>{if(!X)return;ke(!0);const re=window.setTimeout(()=>ke(!1),If);return()=>window.clearTimeout(re)},[X]);const qe=xe&&!!ye&&i$(ye,B),Le=!!ye&&!qe||!!me,Oe=re=>{ye&&(be(),We(Ur(ye,re)))},Ue=(re,He)=>{ye&&(be(),We(Vo(ye,re,He)))},dt=G.question?G.question.map(re=>re.question).join(`
|
|
82
|
+
`):null,[je,$e]=l.useState(null),[K,_e]=l.useState(!1);l.useEffect(()=>{if(je===null)return;_e(!1);const re=window.setTimeout(()=>_e(!0),If);return()=>window.clearTimeout(re)},[je]),l.useEffect(()=>{je!==null&&dt!==je&&$e(null)},[dt,je]);const V=K&&!!G.question&&!!ye&&pr(G.question,ye)>=0,ce=je!==null&&je===dt&&!V,Be=re=>{be(),re.last&&($e(dt),L(He=>[...He,{id:`answer-${Date.now()}`,text:re.text,after:le.length}]))},Ke=G.question&&!ce&&!(ye===null&&pr(G.question,B)>=0)?G.question:null,Ie=!!Ke&&!!ye&&pr(Ke,ye)<0,ut=Me.some(re=>re.id.startsWith("pending-")),Ze=!Le&&!Ke&&(G.working||ut),st=l.useMemo(()=>{for(let re=le.length-1;re>=0;re--){const He=le[re];if(He.role==="activity")for(let xt=He.items.length-1;xt>=0;xt--){const Dt=/^(?:Wrote|Edited) (.+)$/.exec(He.items[xt]);if(Dt)return Dt[1]}}return null},[le]),Ye=BS(),rt=G.messages.length>0?G.messages[G.messages.length-1].id:null,Je=l.useRef(rt);Je.current=rt;const[vt,jt]=l.useState([]),Yt=l.useRef(vt);Yt.current=vt;const Ct=l.useRef(null),Tt=l.useRef(null);l.useEffect(()=>{if(!T||Tt.current===T)return;Tt.current=T;const re=XF(T);re&&(Yt.current=re.milestones,jt(re.milestones),Ct.current=re.lastStep)},[T]),l.useEffect(()=>{if(T&&Tt.current!==T)return;const re=Ct.current;if(Ct.current=(Ye==null?void 0:Ye.step)??null,!Ye||re===null||Ye.step<=re){T&&Of(T,{milestones:Yt.current,lastStep:Ct.current});return}const He=Array.from({length:Ye.step-re},(Dt,ge)=>re+ge),xt=[...Yt.current,...He.map((Dt,ge)=>({id:`${Dt}-${Yt.current.length+ge}`,text:ku(Dt,Ye.mode).primary,detail:`${Dt}/${Ye.total}`,afterId:Je.current}))];jt(xt),T&&Of(T,{milestones:xt,lastStep:Ye.step})},[Ye,T]);const Kn=Ye?Math.min(1,Math.max(0,(Ye.step-1)/Ye.total)):null,Gt=le[le.length-1],Pn=O&&!Ze&&!Le&&(Gt==null?void 0:Gt.role)==="agent"&&cd(Gt.text),wt=!!d&&!Le&&!Ke,Jn=O&&!Le&&!wt&&!ee&&G.available&&!Ze&&de===0,[Pt,zt]=l.useState(!1);l.useEffect(()=>{if(!Jn){zt(!1);return}const re=window.setTimeout(()=>zt(!0),l$);return()=>window.clearTimeout(re)},[Jn]);const tn=O?Le?"waiting on you":wt?"working":ee?Q?"running":"starting":G.available?Ze?"working":de>0?Af:Pt?"waiting on you":"working":"running":"starting",Xn=O&&(!!Ke||Le),Ot=!wt&&(Pn||!!Ke||tn==="waiting on you"),fn=l.useRef(!1),nn=l.useRef(h);nn.current=h,l.useEffect(()=>{var re;Xn&&!fn.current&&((re=nn.current)==null||re.call(nn)),fn.current=Xn},[Xn]);const Ge=l.useRef(f);Ge.current=f,l.useEffect(()=>{var re;(re=Ge.current)==null||re.call(Ge,Ot)},[Ot]),l.useEffect(()=>()=>{var re;return(re=Ge.current)==null?void 0:re.call(Ge,!1)},[]);const Rt=!Ot&&(tn==="working"||tn==="starting"),mt=!Ot&&tn===Af,[sn,gt]=l.useState(null);l.useEffect(()=>{gt(mt?Date.now():null)},[mt]);const rn=O&&(Rt||mt),an=l.useRef(x);an.current=x,l.useEffect(()=>{var re;(re=an.current)==null||re.call(an,rn)},[rn]),l.useEffect(()=>()=>{var re;return(re=an.current)==null?void 0:re.call(an,!1)},[]);const Ks=Rt?t.jsx("span",{"data-testid":"agent-chat-status-mark","data-mark":"spinner",style:{display:"flex",flex:"none"},children:t.jsx(Ht,{size:11})}):t.jsx("span",{"aria-hidden":"true","data-testid":"agent-chat-status-mark","data-mark":"dot",className:Ot?"animate-pulse":void 0,style:{flex:"none",width:8,height:8,borderRadius:"50%",background:Ot?it:mt?Mf:"rgba(255,255,255,.35)"}}),na=t.jsxs("span",{"data-testid":"agent-chat-status","data-needs-you":Ot?"true":"false",style:{flex:"none",fontSize:12,fontWeight:400,color:Ot?it:Rt?"var(--working)":mt?Mf:"rgba(255,255,255,.45)",whiteSpace:"nowrap"},children:[Ot?Ba:tn.charAt(0).toUpperCase()+tn.slice(1),Ot?t.jsx(qn,{variant:"pulse"}):(Rt||mt)&&t.jsx(qn,{})]});return t.jsx(Lr.Provider,{value:we,children:t.jsxs("div",{role:"region","aria-label":r,"data-testid":"agent-chat-pane",style:{display:"flex",flexDirection:"column",height:s,minHeight:0,flex:s==="100%"?1:void 0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:`8px ${un}px`,...Gr("bottom"),flex:"none",position:"relative"},children:[Kn!==null&&t.jsx("div",{"aria-hidden":"true","data-testid":"agent-chat-progress","data-progress":Kn.toFixed(3),style:{position:"absolute",left:0,bottom:-1,height:2,width:`${Kn*100}%`,background:"var(--working)",borderRadius:"0 2px 2px 0",transition:"width 600ms ease",pointerEvents:"none"}}),C?t.jsx("div",{"data-testid":"agent-chat-session-title",style:{minWidth:0,flex:"0 1 auto"},children:C(Rt?{mark:null,label:null,note:c}:{mark:Ks,label:na,note:c})}):t.jsxs("span",{style:{display:"flex",flex:"none",flexDirection:"column",gap:2,minWidth:0},children:[t.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6},children:[Ks,na]}),c&&t.jsx("span",{style:{fontSize:11.5,color:"var(--text-muted)"},children:c})]}),t.jsx(Yo,{view:v,onChange:j,className:"ml-auto"}),o&&t.jsx("button",{type:"button","aria-label":"Close session",title:"Close session",onClick:()=>N(!0),className:"hover:bg-white/[0.06] hover:text-[var(--text-primary)]",style:{background:"none",border:"none",padding:4,marginRight:-4,borderRadius:6,color:"rgba(255,255,255,.45)",cursor:"pointer",display:"flex",alignItems:"center"},children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",children:t.jsx("path",{d:"M4 4l8 8M12 4l-8 8"})})}),o&&S&&t.jsx(Nx,{sessionName:a,onCancel:()=>N(!1),onConfirm:()=>{N(!1),o()}})]}),t.jsxs("div",{style:{position:"relative",flex:1,minHeight:0},children:[t.jsx("div",{"aria-hidden":"true","data-testid":"agent-chat-header-shadow",style:{position:"absolute",top:0,left:0,right:0,height:20,zIndex:2,pointerEvents:"none",background:"linear-gradient(to bottom, rgba(0,0,0,.5), rgba(0,0,0,0))"}}),t.jsx("div",{style:{position:"absolute",inset:0,zIndex:0,display:"flex",flexDirection:"column",paddingLeft:14},children:oe}),v==="chat"&&wt&&t.jsx("div",{"data-testid":"agent-chat-handoff",style:{position:"absolute",inset:0,zIndex:3},children:d}),v==="chat"&&(O||G.messages.length>0)&&t.jsxs("div",{"data-testid":"agent-chat-view",style:{position:"absolute",inset:0,zIndex:1,display:"flex",flexDirection:"column",background:"var(--bg-deep, #141414)"},children:[y&&!_&&t.jsx(ul,{role:"note",testId:"agent-chat-experimental-notice",onDismiss:k,children:y}),D&&t.jsx(ul,{role:"status",testId:"agent-chat-notice",onDismiss:()=>Y(null),children:D}),t.jsx(Yr,{messages:ve,working:G.working,waiting:Le,intro:u,pending:z,milestones:vt,timerScope:T,lastReplyBackground:mt,onOpenTerminal:()=>j("terminal"),awaitingReply:Pn,startingText:`Starting the ${a}…`,emptyState:Q?t.jsxs("div",{"data-testid":"agent-chat-log-missing",style:{fontSize:13,color:"var(--text-muted)",display:"flex",flexDirection:"column",gap:8,alignItems:"flex-start"},children:["The chat can't read this agent's messages. It is running: follow it in the terminal.",t.jsx("button",{type:"button",onClick:()=>j("terminal"),style:{padding:"5px 12px",borderRadius:8,border:"1px solid rgba(255,255,255,.14)",background:"transparent",color:"var(--text-primary)",fontSize:12.5,cursor:"pointer"},children:"Open Terminal"})]}):void 0}),mt&&sn!==null&&t.jsx("div",{"data-testid":"agent-chat-card-slot",style:vn,children:t.jsx(Px,{since:sn,onCheck:()=>void fe(Tx)})}),Ne&&t.jsx("div",{"data-testid":"agent-chat-card-slot",style:vn,children:t.jsxs("div",{role:"status","data-testid":"agent-chat-api-retry",style:{border:"1px solid rgba(239,111,111,.4)",background:"rgba(239,111,111,.08)",borderRadius:10,padding:"9px 12px",fontSize:12.5,color:"#ef8f8f",display:"flex",alignItems:"center",gap:8},children:[t.jsx("span",{"aria-hidden":"true",style:{width:7,height:7,borderRadius:"50%",background:"#ef6f6f",flex:"none"}}),t.jsxs("span",{children:["Can't reach the AI right now.",Ne.retryIn?` Retrying in ${Ne.retryIn}.`:" Retrying."," Check your network."]})]})}),Ke&&!Ie&&t.jsxs("div",{"data-testid":"agent-chat-card-slot",style:vn,children:[st&&p?p(st):null,t.jsx(Du,{questions:Ke,screenPrompt:ye,send:re=>void Z(re),onAnswered:Be,onOpenTerminal:()=>j("terminal"),attach:De})]}),me&&!ye&&t.jsx("div",{"data-testid":"agent-chat-card-slot",style:vn,children:t.jsx(_o,{login:me,onSubmitCode:re=>We([re,"\r"]),onOpenTerminal:()=>j("terminal")})}),ye&&!qe&&(!Ke||Ie)&&t.jsx("div",{"data-testid":"agent-chat-card-slot",style:vn,children:t.jsx(Xo,{prompt:ye,onChoose:Oe,onAnswer:Ue,onOpenTerminal:()=>j("terminal"),attach:De})}),t.jsx(Jo,{disabled:!O,busyNote:q,awaiting:Pn,onSend:Fe})]})]}),i&&t.jsx("div",{"data-testid":"agent-chat-footer",style:{flex:"none",padding:`0 ${un}px 10px`},children:i})]})})}const Ete=Object.freeze(Object.defineProperty({__proto__:null,AGENT_CHAT_UNAVAILABLE_AFTER_MS:WS,AgentChatPane:Vr},Symbol.toStringTag,{value:"Module"})),Ta=8e3,c$="agent-banner-ready",d$="agent-auth-required";let Ja=!1,Xa=!1,_n=[],Df=!1,An=null,Dn=null,Pa=!1;function u$(){Df||typeof window>"u"||(Df=!0,window.addEventListener(c$,()=>{const e=!Xa;if(e){Xa=!0;const n=_n;_n=[];for(const s of n)s("banner")}if(Pa&&(Pa=!1,Dn&&An===null)){pe("dispatch-rename-after-auth",{label:Dn.label,reason:"first-observed-frame-after-auth"}),An=Dn,yr(Dn.label,Dn.send,void 0,"rename-coordinator-after-auth");return}An&&(pe("dispatch-rename-reapply",{label:An.label,reason:e?"first-observed-frame":"second-observed-frame"}),yr(An.label,An.send,void 0,"rename-coordinator-reapply"))}),window.addEventListener(d$,()=>{Pa=!0,pe("agent-auth-required-observed",{});const e=_n;_n=[];for(const n of e)n("auth-required")}))}u$();function p$(){return Xa?Promise.resolve("banner"):new Promise(e=>{let n=!1;const s=a=>{n||(n=!0,clearTimeout(r),e(a))};_n.push(s);const r=setTimeout(()=>{if(n)return;n=!0;const a=_n.indexOf(s);a>=0&&_n.splice(a,1),e("fallback")},Ta)})}async function HS(e,n,s=0,r=_R,a=!1){if(Ja){pe("dispatch-rename-suppressed",{caller:n,label:e});return}Ja=!0,Dn={label:e,send:r},pe("dispatch-rename",{phase:"queued",caller:n,label:e,fallbackMs:Ta,postReadyDelayMs:s});const o=await p$();if(o==="auth-required"){pe("dispatch-rename-deferred-for-auth",{caller:n,label:e});return}if(a&&o==="fallback"){pe("dispatch-rename-skipped-no-banner",{caller:n,label:e,fallbackMs:Ta});return}s>0&&await new Promise(i=>setTimeout(i,s)),o==="fallback"&&pe("dispatch-rename-fallback",{caller:n,label:e,fallbackMs:Ta}),pe("dispatch-rename",{phase:"fired",caller:n,label:e,source:o,postReadyDelayMs:s}),An={label:e,send:r},yr(e,r,void 0,n)}function h$(){Ja=!1,Xa=!1,_n=[],An=null,Dn=null,Pa=!1}function f$(){Ja=!1,_n=[],Dn=null}const m$="Editor";function qS(e){return e??m$}function g$({provider:e,agentStartMode:n,currentFeature:s}){const r=l.useRef(!1);l.useEffect(()=>{if(!(r.current||!mg(e)||n!=="fresh")){if(s!==null){r.current=!0;return}r.current=!0,HS(qS(s),"build-session-seed",gg,void 0,!0)}},[e,n,s])}function Yl(e,n){const[s,r]=l.useState(e),a=l.useRef(null);return l.useEffect(()=>{if(e!==!1){a.current!==null&&(window.clearTimeout(a.current),a.current=null),r(e);return}if(a.current===null)return a.current=window.setTimeout(()=>{a.current=null,r(!1)},n),()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null)}},[e,n]),s}function x$(e,n){const[s,r]=l.useState(!1),a=l.useRef(null);return l.useEffect(()=>{if(!e){a.current!==null&&(window.clearTimeout(a.current),a.current=null),r(!1);return}if(a.current===null)return a.current=window.setTimeout(()=>{a.current=null,r(!0)},n),()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null)}},[e,n]),s}const b$=120*1e3,hr=1500;class y${constructor(n,s,r=pe){on(this,"deferred",!1);on(this,"userActiveSinceLastOutput",!1);on(this,"lastActivitySource",null);on(this,"lastActivityAt",null);on(this,"lastNotificationTime",null);on(this,"actions");on(this,"env");on(this,"now");on(this,"log");this.actions=n,this.env=s,this.now=s.now??(()=>Date.now()),this.log=r}reportUserActivity(n){this.userActiveSinceLastOutput=!0,this.lastActivitySource=n,this.lastActivityAt=this.now()}resetActivityFlag(){this.userActiveSinceLastOutput=!1}onIdle(n,s){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:s,hasBrowserFocus:r,msSinceLastNotification:a,userActiveSinceLastOutput:this.userActiveSinceLastOutput,lastActivitySource:this.lastActivitySource,msSinceLastActivity:o},c=o!==null&&o<hr;if(s&&r&&c)return this.userActiveSinceLastOutput=!1,this.log("suppressed-user-active",i),"suppressed";if(a!==null&&a<b$)return this.log("cooldown",i),"cooldown";const d=this.notify(n);return this.log(d==="played"?"notify-played":"notify-played-no-sound",i),d}onBuildTabChange(n,s){return!n&&this.deferred?(this.deferred=!1,this.notify(s),!0):!1}onActive(){const n=this.deferred;this.deferred=!1,this.log("on-active",{hadDeferred:n}),this.actions.closeSystemNotification(),this.log("system-notification-closed-on-active",{hadDeferred:n})}onUserEngagement(){const n=this.deferred;return this.deferred=!1,n}get isDeferred(){return this.deferred}notify(n){const s=!!(n!=null&&n.sound)&&n.sound!=="off";s?(this.actions.playSound(n.sound),this.log("sound-played",{soundId:n.sound})):this.log("sound-skipped-off",{});const r=this.env.hasBrowserFocus(),a=typeof Notification<"u"?Notification.permission:"unknown";return!r&&(n!=null&&n.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(),s?"played":"played-no-sound"}}function US({onDismiss:e,providerLabel:n}){return t.jsx("div",{className:"bg-black border-t border-[#333] px-4 py-2",children:t.jsxs("div",{className:"flex items-start gap-3 px-3 py-2 rounded-lg border border-[#FFB454]/60 bg-[#2a1f0d]",children:[t.jsx("span",{className:"w-2.5 h-2.5 mt-1.5 rounded-full bg-[#FFB454] shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("p",{className:"text-sm text-[#FFD199]",children:[n," needs"," ",t.jsx("span",{className:"font-medium",children:"your approval to continue"}),"."]}),t.jsx("p",{className:"text-xs text-[#FFD199]/70 mt-1",children:"The turn stopped on a prompt in the terminal below and won't continue until you answer it."})]}),t.jsx("button",{type:"button",onClick:e,className:"shrink-0 p-0.5 mt-1 text-[#FFD199]/60 hover:text-[#FFD199] transition-colors cursor-pointer",title:"Dismiss",children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",children:t.jsx("path",{d:"M3 3l8 8M11 3l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})})}const Ate=Object.freeze(Object.defineProperty({__proto__:null,BlockedBanner:US},Symbol.toStringTag,{value:"Module"}));function YS({snippet:e,onRetry:n,onDismiss:s,providerLabel:r}){return t.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:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"font-medium text-sm mb-1",children:[r," didn't start"]}),t.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:e})]}),t.jsxs("div",{className:"flex items-start gap-2 shrink-0",children:[t.jsx(ct,{variant:"subtle",text:e,label:"Copy",className:"shrink-0 px-3 py-1.5 rounded border border-red-500/50 text-red-100 text-sm font-medium hover:bg-red-900/40 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"}),t.jsx("button",{type:"button",onClick:n,"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"}),t.jsx("button",{type:"button",onClick:s,"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 Mte=Object.freeze(Object.defineProperty({__proto__:null,BuildTabStartupError:YS},Symbol.toStringTag,{value:"Module"}));function GS(e=768){const n=`(max-width: ${e-.02}px)`,[s,r]=l.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(n).matches);return l.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const a=window.matchMedia(n);r(a.matches);const o=i=>r(i.matches);return a.addEventListener("change",o),()=>a.removeEventListener("change",o)},[n]),s}const VS=[{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 KS({defaultOpen:e=!1,currentFeature:n=null}){return GS()?t.jsx(JS,{defaultOpen:e,currentFeature:n}):null}function JS({defaultOpen:e=!1,currentFeature:n=null}){const{config:s}=St(),[r,a]=l.useState(e),o=l.useRef(null),i=l.useRef(null),c=l.useCallback(()=>a(!1),[]);Hc(o,c,i);const d=s&&s.mobileTerminalCommands.length>0?s.mobileTerminalCommands:VS,u=l.useCallback(f=>{f.submit?Ma(f.send):SR(f.send),a(!1)},[]),p=l.useCallback(()=>{yr(qS(n),void 0,void 0,"mobile-command-menu"),a(!1)},[n]),h=mg(s==null?void 0:s.provider);return t.jsxs("div",{className:"absolute top-2 right-2 z-20 flex flex-col items-end",children:[t.jsx("button",{ref:i,type:"button","data-testid":"mobile-command-menu-toggle","aria-haspopup":"menu","aria-expanded":r,"aria-label":"Terminal commands",onClick:()=>a(f=>!f),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"}),r&&t.jsxs("div",{ref:o,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:[d.map((f,m)=>t.jsx("button",{type:"button",role:"menuitem","data-testid":`mobile-command-${m}`,onClick:()=>u(f),className:"block w-full px-4 py-2 text-left text-sm text-gray-100 active:bg-gray-700",children:f.label},`${f.label}-${m}`)),h&&t.jsx("button",{type:"button",role:"menuitem","data-testid":"mobile-command-rename-session",onClick:p,className:"block w-full px-4 py-2 text-left text-sm text-gray-100 active:bg-gray-700",children:"Rename Session"})]})]})}const Ite=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_MOBILE_TERMINAL_COMMANDS:VS,MobileTerminalCommandMenu:KS,MobileTerminalCommandMenuPanel:JS},Symbol.toStringTag,{value:"Module"}));function v$(e){const n=Math.floor(e/6e4);if(n<1)return"under a minute";if(n===1)return"1 minute";if(n<60)return`${n} minutes`;const s=Math.floor(n/60);return s===1?"over an hour":`over ${s} hours`}function XS({silentMs:e,onDismiss:n,providerLabel:s}){const{sendToAgent:r,agentReady:a}=po();return t.jsx("div",{className:"bg-black border-t border-[#333] px-4 py-2",children:t.jsxs("div",{className:"flex items-start gap-3 px-3 py-2 rounded-lg border border-[#FF5A5A]/60 bg-[#2a0d0d]",children:[t.jsx("span",{className:"w-2.5 h-2.5 mt-1.5 rounded-full bg-[#FF5A5A] shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("p",{className:"text-sm text-[#FF8B8B]",children:[s," has been mid-turn with no output for"," ",t.jsx("span",{className:"font-medium",children:v$(e)}),"."]}),t.jsxs("p",{className:"text-xs text-[#FF8B8B]/70 mt-1",children:["If you no longer see the input box, interrupt (Ctrl-C) to bring it back, then ask ",s," to resume. If you can still type,"," ",s," may just be on a long step."]})]}),t.jsx("button",{type:"button",disabled:!a,onClick:()=>r(""),className:"shrink-0 px-3 py-1.5 rounded-md text-sm font-medium border border-[#FF5A5A]/60 text-[#FF8B8B] hover:bg-[#FF5A5A]/15 disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer transition-colors",title:a?"Send Ctrl-C to interrupt the current turn":"No agent connected",children:"Interrupt (Ctrl-C)"}),t.jsx("button",{type:"button",onClick:n,className:"shrink-0 p-0.5 mt-1 text-[#FF8B8B]/60 hover:text-[#FF8B8B] transition-colors cursor-pointer",title:"Dismiss",children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",children:t.jsx("path",{d:"M3 3l8 8M11 3l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})})}const Dte=Object.freeze(Object.defineProperty({__proto__:null,StuckTurnBanner:XS},Symbol.toStringTag,{value:"Module"})),j$="codeyam.terminalScrollDebug";function w$(){var e;try{return typeof window<"u"&&((e=window.localStorage)==null?void 0:e.getItem(j$))==="1"}catch{return!1}}function Zs(e,n,s){if(w$())try{const r=n.buffer.active,a={trigger:e,ydisp:r.viewportY,ybase:r.baseY,rows:n.rows,cols:n.cols,containerHeight:(s==null?void 0:s.clientHeight)??null};console.log("[codeyam.terminalScroll]",a)}catch{}}function qu(e){const[n,s]=l.useState(0);l.useEffect(()=>{if(n===0)return;const a=window.setTimeout(()=>s(0),e);return()=>window.clearTimeout(a)},[n,e]);const r=l.useCallback(()=>{s(a=>a+1)},[]);return[n>0,r]}function _$(e=2e3){return new Promise(n=>{let s=!1,r=null;const a=i=>{if(!s){s=!0,clearTimeout(o);try{r==null||r.close()}catch{}n(i)}},o=setTimeout(()=>a(!1),e);try{const c=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/health`;r=new WebSocket(c),r.onmessage=()=>a(!0),r.onopen=()=>a(!0),r.onerror=()=>a(!1),r.onclose=()=>a(!1)}catch{a(!1)}})}function S$({session:e,attempts:n,max:s}){return e!=="stale"?"check-transport":n<s?"reacquire":"give-up"}async function Lf(e=1500){try{const n=await fetch("/api/session-info",{credentials:"same-origin",cache:"no-store",signal:AbortSignal.timeout(e)});if(!n.ok)return null;const s=await n.json();return k$(s==null?void 0:s.buildSessionExit)}catch{return null}}function k$(e){if(typeof e!="object"||e===null)return null;const n=e;return typeof n.sessionId!="string"||typeof n.reason!="string"?null:{sessionId:n.sessionId,pid:typeof n.pid=="number"?n.pid:0,signal:typeof n.signal=="string"?n.signal:null,signalNumber:typeof n.signalNumber=="number"?n.signalNumber:null,exitCode:typeof n.exitCode=="number"?n.exitCode:null,atUnixSecs:typeof n.atUnixSecs=="number"?n.atUnixSecs:0,origin:n.origin==="broker-initiated"?"broker-initiated":"external",reason:n.reason,externalDeath:n.externalDeath===!0,oomSignature:n.oomSignature===!0}}function N$({baseline:e,current:n}){return n?e===void 0?{kind:"transport"}:e===null?{kind:"process-death",report:n}:n.atUnixSecs!==e.atUnixSecs||n.pid!==e.pid?{kind:"process-death",report:n}:{kind:"transport"}:{kind:"transport"}}function Qo(){return t.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 Lte=Object.freeze(Object.defineProperty({__proto__:null,TerminalCopiedToast:Qo},Symbol.toStringTag,{value:"Module"}));function C$(e){return e==="waived-by-grant"||e==="disabled-in-config"?e:"not-a-check-in"}const T$=1e4;let jn=null;const Gl=new Set;function P$(e,n){if(!(!e&&(jn!=null&&jn.serverInjects)&&!jn.consumed)){jn={serverInjects:e,launchId:n,at:Date.now(),consumed:!1};for(const s of[...Gl])s()}}function O$(){jn=null}function QS(e,n){return e.serverInjects&&!e.consumed?(e.consumed=!0,{owner:"server",launchId:e.launchId,basis:n}):{owner:"browser",launchId:e.launchId,basis:n}}function R$(){const e=jn;return e?(Date.now()-e.at>T$&&(e.consumed=!0),QS(e,"open")):null}function E$(e){return new Promise(n=>{const s=()=>{jn&&(a(),n(QS(jn,"frame")))},r=setTimeout(()=>{a(),n({owner:"server",launchId:null,basis:"no-answer"})},e),a=()=>{clearTimeout(r),Gl.delete(s)};Gl.add(s)})}const A$=3,M$=2,I$=5e3;function ZS({provider:e,agentStartMode:n,sessionId:s,onAgentIdle:r,onAgentActive:a,onAgentBlocked:o,onAgentStuckTurn:i,onAgentTurnEndedOffGate:c,onUserInput:d,onStartupFailed:u,onStartupFailedCleared:p,suppressReconnectOnStopBuilding:h=!1,launchIntent:f=!1,reconnectingLabel:m,binding:g}){if(en())return t.jsx(gd,{});const x=l.useRef(null),b=l.useRef(null),y=l.useRef(null),v=l.useRef(null),{wsRef:j,wsStatus:_,setWsStatus:w,pulseKey:k,bumpPulse:S,dismissServerStopped:N,openSocket:C}=kR(),T=l.useRef(!1),P=l.useRef(n??"fresh"),R=l.useRef(s??null),I=l.useRef(f),A=l.useRef(null),[O,W]=qu(1200);l.useEffect(()=>{P.current=n??"fresh",R.current=s??null,I.current=f},[n,s,f]);const D=xn(r),Y=xn(a),H=xn(o),E=xn(i),U=xn(c),M=xn(d),J=xn(u),ne=xn(p),{drops:oe,dropCallbacksRef:ae,sendToAgent:G,acceptPickedFiles:ie}=NR({wsRef:j,insertInput:L=>{var q,se;((q=j.current)==null?void 0:q.readyState)===WebSocket.OPEN&&j.current.send(JSON.stringify({type:"input",data:L})),ia(),(se=M.current)==null||se.call(M)}});CR(G,_.kind==="open");const le=xn(g),Z=_.kind==="open";l.useEffect(()=>{var L,q;(q=(L=le.current)==null?void 0:L.onSender)==null||q.call(L,Z?G:null)},[G,Z]),TR(ie,_.kind==="open");const z=l.useCallback(()=>{v.current===null&&(v.current=requestAnimationFrame(()=>{var L;v.current=null,(L=b.current)==null||L.scrollToBottom()}))},[]);return qc(x,()=>{var we;const L=y.current,q=b.current,se=x.current;if(!L||!q)return;if(!jr(q,se)){Zs("resize-skipped-degenerate",q,se);return}const fe=gh(q.buffer.active);Zs("resize-before-fit",q,se),L.fit(),((we=j.current)==null?void 0:we.readyState)===WebSocket.OPEN&&j.current.send(JSON.stringify({type:"resize",cols:q.cols,rows:q.rows})),Zs("resize-after-fit",q,se),fe&&z()}),l.useEffect(()=>{if(!x.current||T.current)return;T.current=!0;const L=new Uc.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'IBM Plex Mono', monospace",scrollback:I$,rightClickSelectsWord:!1,theme:{background:"#1e1e1e",foreground:"#cccccc",cursor:"#D7FF63",selectionBackground:"#264f78"}}),q=new Yc.FitAddon;L.loadAddon(q),L.open(x.current),b.current=L;let se;y.current=q;const fe=Gc(L,x.current,{onError:F=>ae.current.showError(F),onCopy:()=>W()}),we=L.onScroll(()=>{Zs("scroll",L,x.current)}),De=Vc(L,{sendInput:F=>{var X,ue;((X=j.current)==null?void 0:X.readyState)===WebSocket.OPEN&&j.current.send(JSON.stringify({type:"input",data:F})),ia(),(ue=M.current)==null||ue.call(M)}});requestAnimationFrame(()=>{q.fit(),L.focus()});let Fe=!1,Me=0,ee=0,Q;const te=C({announceReconnectOnDismiss:!0,catchConnectErrors:!0,onBeforeConnect:()=>{Fe=!1,Q=void 0,Lf().then(F=>{Q=F})},buildUrl:()=>RR({provider:e,mode:P.current,sessionId:R.current??void 0,launch:I.current,launchId:I.current?A.current=ER(A.current):void 0,cols:L.cols,rows:L.rows,capture:LR()}),onMessage:F=>{var X,ue,be,xe,ke,qe,Le,Oe,Ue,dt,je,$e;if(F.data instanceof ArrayBuffer){const K=gh(L.buffer.active);L.write(new Uint8Array(F.data)),(X=le.current)!=null&&X.onScreen&&(se!==void 0&&window.clearTimeout(se),se=window.setTimeout(()=>{var _e,V;se=void 0,(V=(_e=le.current)==null?void 0:_e.onScreen)==null||V.call(_e,PR(L))},300)),K&&(Zs("replay-write",L,x.current),z())}else if(typeof F.data=="string")try{const K=JSON.parse(F.data);if(K.type==="error"){te.failWithServerError(K);return}if(K.type==="session-id")P$(K.serverInjectsLaunch===!0,A.current),(be=(ue=le.current)==null?void 0:ue.onSessionId)==null||be.call(ue,K.sessionId??null),P.current="resume",R.current=K.sessionId??null;else if(K.type==="session-notice")typeof K.text=="string"&&((ke=(xe=le.current)==null?void 0:xe.onNotice)==null||ke.call(xe,K.text));else if(K.type==="agent-idle"||K.type==="claude-idle"){const _e=typeof K.source=="string"?K.source:void 0;pe("ws-message-received",{type:K.type,source:_e}),(qe=D.current)==null||qe.call(D,_e),window.dispatchEvent(new CustomEvent("build-agent-idle",{detail:{source:_e}}))}else if(K.type==="agent-blocked"){const _e=typeof K.source=="string"?K.source:void 0;pe("ws-message-received-blocked",{type:K.type,source:_e}),(Le=H.current)==null||Le.call(H,_e)}else if(K.type==="agent-active"||K.type==="claude-active")pe("ws-message-received-active",{type:K.type}),(Oe=Y.current)==null||Oe.call(Y);else if(K.type==="agent-stuck-turn"){const _e=typeof K.silentMs=="number"?K.silentMs:0;if(pe("ws-message-received-stuck-turn",{silentMs:_e,source:typeof K.source=="string"?K.source:void 0}),OR(L.buffer.active,L.buffer.active.cursorY,L.cols,L.rows)){pe("stuck-turn-suppressed-input-box-visible",{silentMs:_e});return}(Ue=E.current)==null||Ue.call(E,_e)}else if(K.type==="agent-turn-ended-off-gate"){const _e=typeof K.step=="number"?K.step:0,V=typeof K.label=="string"?K.label:"",ce=C$(K.reason);pe("ws-message-received-turn-ended-off-gate",{step:_e,slug:typeof K.slug=="string"?K.slug:void 0,reason:ce}),(dt=U.current)==null||dt.call(U,{step:_e,label:V,reason:ce})}else if(K.type==="idle-diag"){const{site:_e,event:V,...ce}=K;pe(`rust:${V??"unknown"}`,{site:_e,...ce})}else K.type==="drop-complete"?ae.current.resolveDrop(String(K.id??""),String(K.path??"")):K.type==="drop-error"?ae.current.rejectDrop(String(K.id??""),String(K.message??"drop failed")):K.type==="startup-failed"?(je=J.current)==null||je.call(J,String(K.snippet??"")):K.type==="startup-failed-cleared"?($e=ne.current)==null||$e.call(ne):K.type==="agent-banner-ready"?(pe("agent-banner-ready",{}),window.dispatchEvent(new CustomEvent("agent-banner-ready"))):K.type==="agent-auth-required"?(pe("agent-auth-required",{}),window.dispatchEvent(new CustomEvent("agent-auth-required"))):K.type==="agent-auth-resolved"&&(pe("agent-auth-resolved",{}),window.dispatchEvent(new CustomEvent("agent-auth-resolved")))}catch{}},onOpen:F=>{Fe=!0,Me=0,ee=0,pe("ws-open"),F.send(JSON.stringify({type:"resize",cols:L.cols,rows:L.rows}));try{typeof localStorage<"u"&&localStorage.getItem("codeyam.idleDebug")==="1"&&(F.send(JSON.stringify({type:"enable-idle-diag",sessionId:Qc()})),pe("idle-diag-enabled"))}catch{}},onClose:({reconnectAttempts:F})=>{pe("ws-close",{reconnectAttempts:F}),O$(),ae.current.cancelAllDrops("Not connected")},onEnded:()=>{L.writeln(`\r
|
|
83
|
+
\x1B[90m[Terminal session ended]\x1B[0m`)},diagnoseClose:async F=>{const X=await Lf();if(F.isEnded())return!0;const ue=N$({baseline:Q,current:X});if(ue.kind==="process-death")return w({kind:"session-died",report:ue.report}),!0;if(Fe)Me=0;else{Me++;const be=await mE();if(F.isEnded())return!0;const xe=S$({session:be,attempts:ee,max:M$});if(xe==="reacquire"){ee++,w({kind:"session-stale"});const qe=await gE();return F.isEnded()?!0:qe?(Me=0,F.connect(),!0):(w({kind:"session-stale",canRetry:!0}),!0)}if(xe==="give-up")return w({kind:"session-stale",canRetry:!0}),!0;const ke=await _$();if(F.isEnded())return!0;if(!ke||Me>=A$)return w({kind:"edge-unreachable"}),!0}return!1}});try{q.fit()}catch{}te.connect();let he=0;const ye=1e3;function ve(){var X;const F=Date.now();F-he>=ye&&((X=j.current)==null?void 0:X.readyState)===WebSocket.OPEN&&(j.current.send(JSON.stringify({type:"browser-activity"})),he=F)}document.addEventListener("mousemove",ve),document.addEventListener("keydown",ve),document.addEventListener("mousedown",ve),L.onData(F=>{var X,ue;((X=j.current)==null?void 0:X.readyState)===WebSocket.OPEN?j.current.send(JSON.stringify({type:"input",data:F})):S(),ia(),(ue=M.current)==null||ue.call(M)});const Ne=x.current;function de(F){var qe,Le,Oe;const X=F,ue=FR(X.clipboardData);if(ue.length>0){F.preventDefault(),F.stopPropagation(),ae.current.handleImageFiles(ue);return}const be=((qe=X.clipboardData)==null?void 0:qe.getData("text"))??"";if(!be)return;F.preventDefault(),F.stopPropagation();const xe=be.replace(/\r\n/g,"\r").replace(/\n/g,"\r"),ke=L.modes.bracketedPasteMode?`\x1B[200~${xe}\x1B[201~`:xe;((Le=j.current)==null?void 0:Le.readyState)===WebSocket.OPEN?j.current.send(JSON.stringify({type:"input",data:ke})):S(),ia(),(Oe=M.current)==null||Oe.call(M)}Ne.addEventListener("paste",de,!0);function me(F){var be,xe;const X=F.detail;if(!X)return;((be=j.current)==null?void 0:be.readyState)===WebSocket.OPEN?((xe=j.current)==null||xe.send(JSON.stringify({type:"input",data:X})),pe("terminal-send-input",{len:X.length,firstChars:X.slice(0,16),wsOpen:!0,dropped:!1})):pe("terminal-send-input",{len:X.length,firstChars:X.slice(0,16),wsOpen:!1,dropped:!0})}window.addEventListener("terminal-send-input",me),AR();function We(){$R(x.current)||(vr(),L.focus())}window.addEventListener("terminal-focus",We);function B(){var F;te.end(),(F=j.current)==null||F.close(),w({kind:"ended"}),L.reset()}return h&&window.addEventListener("build-session-stopped",B),()=>{var F;te.dispose(),document.removeEventListener("mousemove",ve),document.removeEventListener("keydown",ve),document.removeEventListener("mousedown",ve),window.removeEventListener("terminal-send-input",me),zR(),window.removeEventListener("terminal-focus",We),h&&window.removeEventListener("build-session-stopped",B),Ne.removeEventListener("paste",de,!0),De(),we.dispose(),v.current!==null&&(cancelAnimationFrame(v.current),v.current=null),(F=j.current)==null||F.close(),fe(),L.dispose(),T.current=!1}},[e,z,C,S,w]),t.jsxs("div",{className:"relative flex-1 flex flex-col",style:{minHeight:0},"data-terminal-emulator":!0,onDragEnter:oe.dropHandlers.onDragEnter,onDragOver:oe.dropHandlers.onDragOver,onDragLeave:oe.dropHandlers.onDragLeave,onDrop:oe.dropHandlers.onDrop,onPaste:oe.pasteHandler,children:[t.jsx("div",{ref:x,className:"flex-1",tabIndex:-1,style:{background:"#1e1e1e",minHeight:0,paddingTop:3,paddingLeft:3,outline:"none"},onPointerDown:()=>{xh(x.current,()=>{var L;return(L=b.current)==null?void 0:L.focus()})},onClick:()=>{xh(x.current,()=>{var L;return(L=b.current)==null?void 0:L.focus()})}}),oe.dragActive&&t.jsx(MR,{}),oe.errorToast&&t.jsx(IR,{message:oe.errorToast}),O&&t.jsx(Qo,{}),t.jsx(DR,{status:_,pulseKey:k,onRefresh:()=>window.location.reload(),reconnectingLabel:m,onDismissServerStopped:N})]})}const Fte=Object.freeze(Object.defineProperty({__proto__:null,TerminalEmulator:ZS},Symbol.toStringTag,{value:"Module"}));function ek({step:e,label:n,onDismiss:s,providerLabel:r,reason:a="not-a-check-in"}){const{sendToAgent:o,agentReady:i}=po(),c=a!=="not-a-check-in";return t.jsx("div",{className:"bg-black border-t border-[#333] px-4 py-2",children:t.jsxs("div",{className:"flex items-start gap-3 px-3 py-2 rounded-lg border border-[#FFC53D]/60 bg-[#2a2000]",children:[t.jsx("span",{className:"w-2.5 h-2.5 mt-1.5 rounded-full bg-[#FFC53D] shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("p",{className:"text-sm text-[#FFD778]",children:[r," stopped at"," ",t.jsxs("span",{className:"font-medium",children:["step ",e,", ",n]})," ",c?"— a check-in that isn't pausing this cycle.":"— a step that isn't a decision point."]}),t.jsx(fb,{reason:a,providerLabel:r})]}),t.jsx("button",{type:"button",disabled:!i,onClick:()=>o("Continue.\r"),className:"shrink-0 px-3 py-1.5 rounded-md text-sm font-medium border border-[#FFC53D]/60 text-[#FFD778] hover:bg-[#FFC53D]/15 disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer transition-colors",title:i?`Tell ${r} to resume the workflow`:"No agent connected",children:"Continue"}),t.jsx("button",{type:"button",onClick:s,className:"shrink-0 p-0.5 mt-1 text-[#FFD778]/60 hover:text-[#FFD778] transition-colors cursor-pointer",title:"Dismiss",children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",children:t.jsx("path",{d:"M3 3l8 8M11 3l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})})}const $te=Object.freeze(Object.defineProperty({__proto__:null,TurnEndedOffGateBanner:ek},Symbol.toStringTag,{value:"Module"}));function tk({onAgentActive:e,onAgentIdle:n,onAgentBlocked:s,onUserInput:r,provider:a,sessionId:o,shouldResumeSameProvider:i,currentFeature:c,binding:d}){const[u,p]=l.useState(null),[h,f]=l.useState(0),[m,g]=l.useState(null),[x,b]=l.useState(!1),[y,v]=l.useState(!1),[j,_]=l.useState(null),[w,k]=l.useState(null),[S,N]=l.useState(!1),C=Yl(x,hr),T=x$(j!==null,hr),P=Yl(T,hr);g$({provider:a,agentStartMode:i?"resume":"fresh",currentFeature:c}),l.useEffect(()=>()=>{h$()},[]);const R=l.useCallback(E=>{p(E)},[]),I=l.useCallback(()=>{p(null)},[]),A=l.useCallback(()=>{p(null),f(E=>E+1)},[]),O=l.useCallback(E=>{g(null),b(!1),n(E)},[n]),W=l.useCallback(()=>{g(null),b(!1),_(null),e()},[e]),D=l.useCallback(E=>{g(null),b(!1),j===null&&N(!1),_(E),k(E)},[j]),Y=l.useCallback(E=>{g(null),_(null),x||v(!1),b(!0),s(E)},[s,x]),H=l.useCallback(()=>{g(null),_(null),N(!0),b(!1),r()},[r]);return t.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[u!==null&&t.jsx(YS,{snippet:u,onRetry:A,onDismiss:I,providerLabel:Qe(a)}),C===!0&&!y&&t.jsx(US,{onDismiss:()=>v(!0),providerLabel:Qe(a)}),m!==null&&t.jsx(XS,{silentMs:m,onDismiss:()=>g(null),providerLabel:Qe(a)}),P===!0&&!S&&w!==null&&t.jsx(ek,{step:w.step,label:w.label,reason:w.reason,onDismiss:()=>{N(!0),_(null)},providerLabel:Qe(a)}),t.jsxs("div",{className:"relative flex flex-col flex-1 min-h-0",children:[t.jsx(ZS,{provider:a,agentStartMode:i?"resume":"fresh",sessionId:i?o:null,onAgentIdle:O,onAgentActive:W,onAgentBlocked:Y,onAgentStuckTurn:g,onAgentTurnEndedOffGate:D,onUserInput:H,onStartupFailed:R,onStartupFailedCleared:I,suppressReconnectOnStopBuilding:!0,binding:d,launchIntent:!0,reconnectingLabel:"Reconnecting to your running build…"},h),t.jsx(KS,{currentFeature:c}),t.jsx("div",{className:"absolute top-2 left-2 z-20 md:left-auto md:right-2",children:t.jsx(BR,{className:"rounded-full bg-gray-800/90 px-3 py-1.5 shadow-lg ring-1 ring-white/10 backdrop-blur"})})]})]})}const zte=Object.freeze(Object.defineProperty({__proto__:null,BuildTabTerminalSession:tk},Symbol.toStringTag,{value:"Module"}));function _t(){const e=()=>{typeof window<"u"&&window.dispatchEvent(new Event("terminal-focus"))};e();const n=requestAnimationFrame(e),s=setTimeout(e,50);return()=>{cancelAnimationFrame(n),clearTimeout(s)}}function nk({onClick:e,disabled:n=!1}){const s="mt-3 inline-flex items-center gap-3 rounded-lg px-4 py-2.5 text-sm font-medium transition-opacity",r=n?"border border-[var(--border-default)] text-[var(--text-dim)] cursor-not-allowed":"bg-[var(--accent-active)] text-[var(--text-on-accent)] hover:opacity-90 cursor-pointer";return t.jsxs("button",{type:"button",onClick:n?void 0:e,disabled:n,"aria-disabled":n,"data-testid":"start-chat",className:`${s} ${r}`,children:["Start Chat",!n&&t.jsx("span",{"aria-hidden":"true",className:"text-base leading-none",children:"↓"})]})}const Bte=Object.freeze(Object.defineProperty({__proto__:null,StartChatButton:nk},Symbol.toStringTag,{value:"Module"}));function sk({draft:e,onDraftChange:n,onStart:s,providerLabel:r}){return t.jsxs(t.Fragment,{children:[t.jsx(Ws,{value:e,onChange:n,testId:"chat-describe-input",placeholder:"Ask anything about the project or CodeYam",onSubmit:s}),t.jsx(nk,{onClick:s}),t.jsxs("p",{className:"mt-2 text-xs text-[var(--text-dim)]",children:[r," reads the project's description, deliverables and scenarios before answering."]})]})}const Wte=Object.freeze(Object.defineProperty({__proto__:null,BuildChatLaunchPanel:sk},Symbol.toStringTag,{value:"Module"}));function Uu(e,n=""){const[s,r]=l.useState(n),[a,o]=l.useState(null),[i,c]=l.useState(null);return{draft:s,setDraft:r,seededCommand:a,seedText:i,open:d=>{const u=d?`${s} ${d}`:s;o(Es(e,u)),c(kr(u)||null)},close:()=>{o(null),c(null)},clearDraft:()=>r("")}}function Yu(e,n){const s=l.useRef(n);s.current=n;const r=l.useRef(e);l.useEffect(()=>{e!==r.current&&(r.current=e,s.current())},[e])}const Qa="chat";function rk({onClose:e,slashCommand:n,seedText:s,footer:r,headerNote:a,handoff:o}){return t.jsx(Vr,{label:"Chat agent",sessionName:"chat",onClose:e,footer:r,headerNote:a,handoff:o,onNeedsYouChange:Bu,onWorkingChange:Wu,renderTerminal:i=>t.jsx(qt,{chatName:Qa,slashCommand:n??qa,seedText:s,height:"100%",onClose:e,binding:i})})}const Hte=Object.freeze(Object.defineProperty({__proto__:null,BUILD_CHAT_CHAT_NAME:Qa,BuildChatAgentChat:rk},Symbol.toStringTag,{value:"Module"}));function ak(e){return xg("miniagent-output",e)}function Gu({question:e,children:n}){return t.jsxs("div",{"data-testid":"activity-exit-control",className:"flex items-center gap-2 text-xs",children:[t.jsx("span",{className:"text-[var(--text-dim)]",children:e}),t.jsx("div",{className:"inline-flex items-stretch divide-x divide-[var(--border-default)] rounded-md border border-[var(--border-default)] bg-[rgba(255,255,255,.02)]",children:n})]})}function Vu({testId:e,label:n,hint:s,disabled:r,onClick:a}){const o=`${e}-hint`;return t.jsxs("span",{className:"group relative flex",children:[t.jsx("button",{type:"button",onClick:a,disabled:r,"data-testid":e,"aria-describedby":o,className:"px-2.5 py-1 text-xs transition-colors "+(r?"text-[var(--text-dim)] cursor-not-allowed":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[rgba(255,255,255,.05)] cursor-pointer"),children:n}),t.jsx("span",{id:o,role:"tooltip",className:"pointer-events-none absolute right-0 bottom-full z-30 mb-1.5 hidden w-60 rounded-md border border-[var(--border-default)] bg-[var(--bg-deep,#141414)] px-2.5 py-2 text-left text-xs leading-snug text-[var(--text-secondary)] shadow-lg group-hover:block group-focus-within:block",children:s})]})}const qte=Object.freeze(Object.defineProperty({__proto__:null,ActivityExitControl:Gu,ExitOption:Vu},Symbol.toStringTag,{value:"Module"})),ok='The user has clicked "I\'m done". Stop the current activity now. Do NOT start anything new, do NOT write a plan file, do NOT commit, and do NOT run any `codeyam-editor editor advance`/`step` command. Leave any edits you made in the working tree exactly as they are. Summarize what happened in ONE line, then stop.';function Ku({chatName:e,disabled:n=!1,onDone:s}){const[r,a]=l.useState(!1),o=l.useRef(!1),i=async()=>{if(!(n||o.current)){o.current=!0,a(!0);try{Sn(ok,e),await ak(wr),Sn("\r",e),s==null||s()}finally{o.current=!1,a(!1)}}},c=n||r;return t.jsx(Vu,{testId:"activity-done",label:"I'm done",hint:"Just stops here. Your changes stay in the working tree as they are; no plan is written and nothing is committed.",disabled:c,onClick:i})}const Ute=Object.freeze(Object.defineProperty({__proto__:null,ACTIVITY_DONE_INSTRUCTION:ok,ActivityDoneButton:Ku},Symbol.toStringTag,{value:"Module"})),ik='The user has clicked "Finish and Formalize in Build". Stop prototyping. Write the plan BODY describing what was prototyped to a scratch file, then create the plan with `codeyam-editor editor plan-create --title "<feature name>" --mode ui --step 11 --source prototype --body-file <path>` (backend mode: `--mode backend --step 8`). Do NOT write the plan file yourself and do NOT hand-author frontmatter — plan-create derives the slug and stamps `createdAt`, which you have no clock to guess. It prints the path it wrote; take the slug from there and 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 Ju({chatName:e,disabled:n=!1,onClick:s}){const[r,a]=l.useState(!1),o=l.useRef(!1),i=async()=>{if(!(n||o.current)){o.current=!0,a(!0);try{Sn(ik,e),await ak(wr),Sn("\r",e),s==null||s()}finally{o.current=!1,a(!1)}}},c=n||r;return t.jsx(Vu,{testId:"finish-and-formalize",label:"Formalize in Build",hint:"Turns what you prototyped into a plan and opens it in Build, where it gets tests, scenarios and a commit.",disabled:c,onClick:i})}const Yte=Object.freeze(Object.defineProperty({__proto__:null,FINISH_AND_FORMALIZE_INSTRUCTION:ik,FinishAndFormalizeButton:Ju},Symbol.toStringTag,{value:"Module"}));function lk({escalatedToPrototype:e=!1,onDone:n,initialDraft:s="",initiallyOpen:r=!0,launchSignal:a=0,onLaunched:o}){const[i,c]=l.useState(r),d=Uu(qa,s),[u,p]=l.useState(!1),{config:h}=St(),f=Qe(h==null?void 0:h.provider);Yu(a,()=>{p(!1),d.close(),c(!1),o==null||o()});const m=()=>{d.open(),_t(),c(!0)},g=()=>{d.close(),c(!1)};return i?t.jsx("div",{"data-testid":"build-chat-pane",className:"flex min-h-0 flex-1 flex-col",children:t.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:t.jsx(rk,{headerNote:u?t.jsx(Nd,{kind:"chat",inline:!0}):void 0,handoff:u?t.jsx(Wa,{name:null}):void 0,onClose:g,slashCommand:d.seededCommand??void 0,seedText:d.seedText??void 0,footer:t.jsx("div",{className:"flex justify-end",children:t.jsxs(Gu,{question:e?"Done prototyping?":"Done chatting?",children:[t.jsx(Ku,{chatName:Qa,disabled:u,onDone:n}),e&&t.jsx(Ju,{chatName:Qa,disabled:u,onClick:()=>p(!0)})]})})})})}):t.jsx("div",{"data-testid":"build-chat-pane",className:"px-2 py-4",children:t.jsx(sk,{draft:d.draft,onDraftChange:d.setDraft,onStart:m,providerLabel:f})})}const Gte=Object.freeze(Object.defineProperty({__proto__:null,BuildChatPane:lk},Symbol.toStringTag,{value:"Module"})),Za="prototype";function ck({onClose:e,slashCommand:n,seedText:s,footer:r,headerNote:a,handoff:o}){return t.jsx(Vr,{label:"Prototype agent",sessionName:"prototype session",onClose:e,footer:r,headerNote:a,handoff:o,onNeedsYouChange:Bu,onWorkingChange:Wu,renderTerminal:i=>t.jsx(qt,{chatName:Za,slashCommand:n??Ob,seedText:s,height:"100%",onClose:e,binding:i})})}const Vte=Object.freeze(Object.defineProperty({__proto__:null,PROTOTYPE_CHAT_NAME:Za,PrototypeAgentChat:ck},Symbol.toStringTag,{value:"Module"})),dk="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 uk(){return t.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:[t.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:"Build in progress."})," ",dk]})}const Kte=Object.freeze(Object.defineProperty({__proto__:null,PROTOTYPE_BUILDING_IN_PROGRESS_MESSAGE:dk,PrototypeBuildingInProgressBanner:uk},Symbol.toStringTag,{value:"Module"}));function Vl({disabled:e=!1,onStart:n}){const s="mt-3 inline-flex items-center gap-3 rounded-lg px-4 py-2.5 text-sm font-medium transition-opacity",r=e?"border border-[var(--border-default)] text-[var(--text-dim)] cursor-not-allowed":"bg-[var(--accent-active)] text-[var(--text-on-accent)] hover:opacity-90 cursor-pointer";return t.jsxs("button",{type:"button",onClick:e?void 0:n,disabled:e,"aria-disabled":e,title:e?"Building is in progress.":void 0,"data-testid":"start-prototyping",className:`${s} ${r}`,children:["Start Prototyping",!e&&t.jsx("span",{"aria-hidden":"true",className:"text-base leading-none",children:"↓"})]})}const Jte=Object.freeze(Object.defineProperty({__proto__:null,StartPrototypingButton:Vl},Symbol.toStringTag,{value:"Module"}));function pk(e,n){return`Launches a chat window with ${e} to ${n==="describe"?"describe your plan":"start prototyping"}.`}function hk({providerLabel:e,kind:n}){return t.jsx("p",{className:"mt-2 text-xs text-[var(--text-dim)]","data-testid":`plan-chat-launch-caption-${n}`,children:pk(e,n)})}const Xte=Object.freeze(Object.defineProperty({__proto__:null,PlanChatLaunchCaption:hk,planChatLaunchCaptionText:pk},Symbol.toStringTag,{value:"Module"}));function fk({isAgentBuilding:e,featureName:n=null,onLaunched:s,onDone:r,initiallyOpen:a=!1,launchSignal:o=0,initialDraft:i=""}){const[c,d]=l.useState(a),u=Uu(Ob,i),[p,h]=l.useState(!1),f=Oo(),{config:m}=St(),g=Qe(m==null?void 0:m.provider);Yu(o,()=>{h(!1),d(!1),u.clearDraft(),f.clear(),s==null||s()});const x=v=>{u.open(v||void 0),_t(),d(!0)},b=()=>{if(!e){if(f.files.length===0){x("");return}f.save().then(v=>{v!==null&&x(v)})}},y=()=>{u.close(),d(!1)};return e&&p?t.jsx("div",{"data-testid":"prototype-pane",className:"flex min-h-0 flex-1 flex-col",children:t.jsx(Wa,{name:n})}):e?t.jsxs("div",{"data-testid":"prototype-pane",className:"px-2 py-4",children:[t.jsx(uk,{}),t.jsx(Vl,{disabled:!0,onStart:()=>{}})]}):c?t.jsx("div",{"data-testid":"prototype-pane",className:"flex min-h-0 flex-1 flex-col",children:t.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:t.jsx(ck,{headerNote:p?t.jsx(Nd,{kind:"prototype",inline:!0}):void 0,handoff:p?t.jsx(Wa,{name:null}):void 0,onClose:y,slashCommand:u.seededCommand??void 0,seedText:u.seedText??void 0,footer:t.jsx("div",{className:"flex justify-end",children:t.jsxs(Gu,{question:"Done prototyping?",children:[t.jsx(Ku,{chatName:Za,disabled:p,onDone:r}),t.jsx(Ju,{chatName:Za,disabled:p,onClick:()=>h(!0)})]})})})})}):t.jsxs("div",{"data-testid":"prototype-pane",className:"px-2 py-4",children:[t.jsx(Ws,{value:u.draft,onChange:u.setDraft,testId:"prototype-describe-input",placeholder:"Describe what you want to prototype",onSubmit:b,files:f.files,onAddFiles:f.addFiles,onRemoveFile:f.removeFile,busy:f.saving,error:f.error}),t.jsx(Vl,{onStart:b}),t.jsx(hk,{providerLabel:g,kind:"prototype"})]})}const Qte=Object.freeze(Object.defineProperty({__proto__:null,PrototypePane:fk},Symbol.toStringTag,{value:"Module"}));function mk(){return t.jsxs("div",{"data-testid":"formalize-intro",style:{border:"1px solid rgba(255,255,255,.1)",background:"rgba(255,255,255,.03)",borderRadius:10,padding:"10px 12px",display:"flex",gap:10,alignItems:"flex-start"},children:[t.jsx("span",{style:{color:"var(--accent-active, #D7FF63)",display:"flex",marginTop:3,flex:"none"},children:t.jsx(cs,{markOnly:!0,className:"h-3.5"})}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[t.jsx("span",{style:{color:"var(--text-primary)",fontWeight:500},children:"Formalizing your prototype"}),t.jsx("span",{style:{color:"var(--text-secondary)"},children:"The plan is written. Now the agent turns what you prototyped into finished work: it reads the code carefully, adds tests and scenarios for it, checks that everything passes, and commits it. Each step shows below, and it will ask you whenever it needs a decision."})]})]})}const Zte=Object.freeze(Object.defineProperty({__proto__:null,FormalizeIntro:mk},Symbol.toStringTag,{value:"Module"})),Xu=ms(),D$=Xu.get,Ff=Xu.set,L$=Xu.subscribe;function F$(){for(var e=arguments.length,n=new Array(e),s=0;s<e;s++)n[s]=arguments[s];return l.useMemo(()=>r=>{n.forEach(a=>a(r))},n)}const Zo=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ys(e){const n=Object.prototype.toString.call(e);return n==="[object Window]"||n==="[object global]"}function Qu(e){return"nodeType"in e}function It(e){var n,s;return e?Ys(e)?e:Qu(e)&&(n=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?n:window:window}function Zu(e){const{Document:n}=It(e);return e instanceof n}function Kr(e){return Ys(e)?!1:e instanceof It(e).HTMLElement}function gk(e){return e instanceof It(e).SVGElement}function Gs(e){return e?Ys(e)?e.document:Qu(e)?Zu(e)?e:Kr(e)||gk(e)?e.ownerDocument:document:document:document}const pn=Zo?l.useLayoutEffect:l.useEffect;function ep(e){const n=l.useRef(e);return pn(()=>{n.current=e}),l.useCallback(function(){for(var s=arguments.length,r=new Array(s),a=0;a<s;a++)r[a]=arguments[a];return n.current==null?void 0:n.current(...r)},[])}function $$(){const e=l.useRef(null),n=l.useCallback((r,a)=>{e.current=setInterval(r,a)},[]),s=l.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[n,s]}function Tr(e,n){n===void 0&&(n=[e]);const s=l.useRef(e);return pn(()=>{s.current!==e&&(s.current=e)},n),s}function Jr(e,n){const s=l.useRef();return l.useMemo(()=>{const r=e(s.current);return s.current=r,r},[...n])}function eo(e){const n=ep(e),s=l.useRef(null),r=l.useCallback(a=>{a!==s.current&&(n==null||n(a,s.current)),s.current=a},[]);return[s,r]}function Kl(e){const n=l.useRef();return l.useEffect(()=>{n.current=e},[e]),n.current}let Li={};function Xr(e,n){return l.useMemo(()=>{if(n)return n;const s=Li[e]==null?0:Li[e]+1;return Li[e]=s,e+"-"+s},[e,n])}function xk(e){return function(n){for(var s=arguments.length,r=new Array(s>1?s-1:0),a=1;a<s;a++)r[a-1]=arguments[a];return r.reduce((o,i)=>{const c=Object.entries(i);for(const[d,u]of c){const p=o[d];p!=null&&(o[d]=p+e*u)}return o},{...n})}}const Ts=xk(1),Pr=xk(-1);function z$(e){return"clientX"in e&&"clientY"in e}function tp(e){if(!e)return!1;const{KeyboardEvent:n}=It(e.target);return n&&e instanceof n}function B$(e){if(!e)return!1;const{TouchEvent:n}=It(e.target);return n&&e instanceof n}function Jl(e){if(B$(e)){if(e.touches&&e.touches.length){const{clientX:n,clientY:s}=e.touches[0];return{x:n,y:s}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:n,clientY:s}=e.changedTouches[0];return{x:n,y:s}}}return z$(e)?{x:e.clientX,y:e.clientY}:null}const Or=Object.freeze({Translate:{toString(e){if(!e)return;const{x:n,y:s}=e;return"translate3d("+(n?Math.round(n):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:n,scaleY:s}=e;return"scaleX("+n+") scaleY("+s+")"}},Transform:{toString(e){if(e)return[Or.Translate.toString(e),Or.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:n,duration:s,easing:r}=e;return n+" "+s+"ms "+r}}}),$f="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function W$(e){return e.matches($f)?e:e.querySelector($f)}const H$={display:"none"};function q$(e){let{id:n,value:s}=e;return At.createElement("div",{id:n,style:H$},s)}function U$(e){let{id:n,announcement:s,ariaLiveType:r="assertive"}=e;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 At.createElement("div",{id:n,style:a,role:"status","aria-live":r,"aria-atomic":!0},s)}function Y$(){const[e,n]=l.useState("");return{announce:l.useCallback(r=>{r!=null&&n(r)},[]),announcement:e}}const bk=l.createContext(null);function G$(e){const n=l.useContext(bk);l.useEffect(()=>{if(!n)throw new Error("useDndMonitor must be used within a children of <DndContext>");return n(e)},[e,n])}function V$(){const[e]=l.useState(()=>new Set),n=l.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[l.useCallback(r=>{let{type:a,event:o}=r;e.forEach(i=>{var c;return(c=i[a])==null?void 0:c.call(i,o)})},[e]),n]}const K$={draggable:`
|
|
84
|
+
To pick up a draggable item, press the space bar.
|
|
85
|
+
While dragging, use the arrow keys to move the item.
|
|
86
|
+
Press space again to drop the item in its new position, or press escape to cancel.
|
|
87
|
+
`},J$={onDragStart(e){let{active:n}=e;return"Picked up draggable item "+n.id+"."},onDragOver(e){let{active:n,over:s}=e;return s?"Draggable item "+n.id+" was moved over droppable area "+s.id+".":"Draggable item "+n.id+" is no longer over a droppable area."},onDragEnd(e){let{active:n,over:s}=e;return s?"Draggable item "+n.id+" was dropped over droppable area "+s.id:"Draggable item "+n.id+" was dropped."},onDragCancel(e){let{active:n}=e;return"Dragging was cancelled. Draggable item "+n.id+" was dropped."}};function X$(e){let{announcements:n=J$,container:s,hiddenTextDescribedById:r,screenReaderInstructions:a=K$}=e;const{announce:o,announcement:i}=Y$(),c=Xr("DndLiveRegion"),[d,u]=l.useState(!1);if(l.useEffect(()=>{u(!0)},[]),G$(l.useMemo(()=>({onDragStart(h){let{active:f}=h;o(n.onDragStart({active:f}))},onDragMove(h){let{active:f,over:m}=h;n.onDragMove&&o(n.onDragMove({active:f,over:m}))},onDragOver(h){let{active:f,over:m}=h;o(n.onDragOver({active:f,over:m}))},onDragEnd(h){let{active:f,over:m}=h;o(n.onDragEnd({active:f,over:m}))},onDragCancel(h){let{active:f,over:m}=h;o(n.onDragCancel({active:f,over:m}))}}),[o,n])),!d)return null;const p=At.createElement(At.Fragment,null,At.createElement(q$,{id:r,value:a.draggable}),At.createElement(U$,{id:c,announcement:i}));return s?as.createPortal(p,s):p}var nt;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(nt||(nt={}));function to(){}function zf(e,n){return l.useMemo(()=>({sensor:e,options:n??{}}),[e,n])}function Q$(){for(var e=arguments.length,n=new Array(e),s=0;s<e;s++)n[s]=arguments[s];return l.useMemo(()=>[...n].filter(r=>r!=null),[...n])}const Zt=Object.freeze({x:0,y:0});function yk(e,n){return Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2))}function vk(e,n){let{data:{value:s}}=e,{data:{value:r}}=n;return s-r}function Z$(e,n){let{data:{value:s}}=e,{data:{value:r}}=n;return r-s}function Bf(e){let{left:n,top:s,height:r,width:a}=e;return[{x:n,y:s},{x:n+a,y:s},{x:n,y:s+r},{x:n+a,y:s+r}]}function jk(e,n){if(!e||e.length===0)return null;const[s]=e;return s[n]}function Wf(e,n,s){return n===void 0&&(n=e.left),s===void 0&&(s=e.top),{x:n+e.width*.5,y:s+e.height*.5}}const ez=e=>{let{collisionRect:n,droppableRects:s,droppableContainers:r}=e;const a=Wf(n,n.left,n.top),o=[];for(const i of r){const{id:c}=i,d=s.get(c);if(d){const u=yk(Wf(d),a);o.push({id:c,data:{droppableContainer:i,value:u}})}}return o.sort(vk)},tz=e=>{let{collisionRect:n,droppableRects:s,droppableContainers:r}=e;const a=Bf(n),o=[];for(const i of r){const{id:c}=i,d=s.get(c);if(d){const u=Bf(d),p=a.reduce((f,m,g)=>f+yk(u[g],m),0),h=Number((p/4).toFixed(4));o.push({id:c,data:{droppableContainer:i,value:h}})}}return o.sort(vk)};function nz(e,n){const s=Math.max(n.top,e.top),r=Math.max(n.left,e.left),a=Math.min(n.left+n.width,e.left+e.width),o=Math.min(n.top+n.height,e.top+e.height),i=a-r,c=o-s;if(r<a&&s<o){const d=n.width*n.height,u=e.width*e.height,p=i*c,h=p/(d+u-p);return Number(h.toFixed(4))}return 0}const sz=e=>{let{collisionRect:n,droppableRects:s,droppableContainers:r}=e;const a=[];for(const o of r){const{id:i}=o,c=s.get(i);if(c){const d=nz(c,n);d>0&&a.push({id:i,data:{droppableContainer:o,value:d}})}}return a.sort(Z$)};function rz(e,n,s){return{...e,scaleX:n&&s?n.width/s.width:1,scaleY:n&&s?n.height/s.height:1}}function wk(e,n){return e&&n?{x:e.left-n.left,y:e.top-n.top}:Zt}function az(e){return function(s){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+e*c.y,bottom:i.bottom+e*c.y,left:i.left+e*c.x,right:i.right+e*c.x}),{...s})}}const oz=az(1);function iz(e){if(e.startsWith("matrix3d(")){const n=e.slice(9,-1).split(/, /);return{x:+n[12],y:+n[13],scaleX:+n[0],scaleY:+n[5]}}else if(e.startsWith("matrix(")){const n=e.slice(7,-1).split(/, /);return{x:+n[4],y:+n[5],scaleX:+n[0],scaleY:+n[3]}}return null}function lz(e,n,s){const r=iz(n);if(!r)return e;const{scaleX:a,scaleY:o,x:i,y:c}=r,d=e.left-i-(1-a)*parseFloat(s),u=e.top-c-(1-o)*parseFloat(s.slice(s.indexOf(" ")+1)),p=a?e.width/a:e.width,h=o?e.height/o:e.height;return{width:p,height:h,top:u,right:d+p,bottom:u+h,left:d}}const cz={ignoreTransform:!1};function Vs(e,n){n===void 0&&(n=cz);let s=e.getBoundingClientRect();if(n.ignoreTransform){const{transform:u,transformOrigin:p}=It(e).getComputedStyle(e);u&&(s=lz(s,u,p))}const{top:r,left:a,width:o,height:i,bottom:c,right:d}=s;return{top:r,left:a,width:o,height:i,bottom:c,right:d}}function Hf(e){return Vs(e,{ignoreTransform:!0})}function dz(e){const n=e.innerWidth,s=e.innerHeight;return{top:0,left:0,right:n,bottom:s,width:n,height:s}}function uz(e,n){return n===void 0&&(n=It(e).getComputedStyle(e)),n.position==="fixed"}function pz(e,n){n===void 0&&(n=It(e).getComputedStyle(e));const s=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(a=>{const o=n[a];return typeof o=="string"?s.test(o):!1})}function ei(e,n){const s=[];function r(a){if(n!=null&&s.length>=n||!a)return s;if(Zu(a)&&a.scrollingElement!=null&&!s.includes(a.scrollingElement))return s.push(a.scrollingElement),s;if(!Kr(a)||gk(a)||s.includes(a))return s;const o=It(e).getComputedStyle(a);return a!==e&&pz(a,o)&&s.push(a),uz(a,o)?s:r(a.parentNode)}return e?r(e):s}function _k(e){const[n]=ei(e,1);return n??null}function Fi(e){return!Zo||!e?null:Ys(e)?e:Qu(e)?Zu(e)||e===Gs(e).scrollingElement?window:Kr(e)?e:null:null}function Sk(e){return Ys(e)?e.scrollX:e.scrollLeft}function kk(e){return Ys(e)?e.scrollY:e.scrollTop}function Xl(e){return{x:Sk(e),y:kk(e)}}var at;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(at||(at={}));function Nk(e){return!Zo||!e?!1:e===document.scrollingElement}function Ck(e){const n={x:0,y:0},s=Nk(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-s.width,y:e.scrollHeight-s.height},a=e.scrollTop<=n.y,o=e.scrollLeft<=n.x,i=e.scrollTop>=r.y,c=e.scrollLeft>=r.x;return{isTop:a,isLeft:o,isBottom:i,isRight:c,maxScroll:r,minScroll:n}}const hz={x:.2,y:.2};function fz(e,n,s,r,a){let{top:o,left:i,right:c,bottom:d}=s;r===void 0&&(r=10),a===void 0&&(a=hz);const{isTop:u,isBottom:p,isLeft:h,isRight:f}=Ck(e),m={x:0,y:0},g={x:0,y:0},x={height:n.height*a.y,width:n.width*a.x};return!u&&o<=n.top+x.height?(m.y=at.Backward,g.y=r*Math.abs((n.top+x.height-o)/x.height)):!p&&d>=n.bottom-x.height&&(m.y=at.Forward,g.y=r*Math.abs((n.bottom-x.height-d)/x.height)),!f&&c>=n.right-x.width?(m.x=at.Forward,g.x=r*Math.abs((n.right-x.width-c)/x.width)):!h&&i<=n.left+x.width&&(m.x=at.Backward,g.x=r*Math.abs((n.left+x.width-i)/x.width)),{direction:m,speed:g}}function mz(e){if(e===document.scrollingElement){const{innerWidth:o,innerHeight:i}=window;return{top:0,left:0,right:o,bottom:i,width:o,height:i}}const{top:n,left:s,right:r,bottom:a}=e.getBoundingClientRect();return{top:n,left:s,right:r,bottom:a,width:e.clientWidth,height:e.clientHeight}}function Tk(e){return e.reduce((n,s)=>Ts(n,Xl(s)),Zt)}function gz(e){return e.reduce((n,s)=>n+Sk(s),0)}function xz(e){return e.reduce((n,s)=>n+kk(s),0)}function bz(e,n){if(n===void 0&&(n=Vs),!e)return;const{top:s,left:r,bottom:a,right:o}=n(e);_k(e)&&(a<=0||o<=0||s>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const yz=[["x",["left","right"],gz],["y",["top","bottom"],xz]];class np{constructor(n,s){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=ei(s),a=Tk(r);this.rect={...n},this.width=n.width,this.height=n.height;for(const[o,i,c]of yz)for(const d of i)Object.defineProperty(this,d,{get:()=>{const u=c(r),p=a[o]-u;return this.rect[d]+p},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class fr{constructor(n){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(s=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...s)})},this.target=n}add(n,s,r){var a;(a=this.target)==null||a.addEventListener(n,s,r),this.listeners.push([n,s,r])}}function vz(e){const{EventTarget:n}=It(e);return e instanceof n?e:Gs(e)}function $i(e,n){const s=Math.abs(e.x),r=Math.abs(e.y);return typeof n=="number"?Math.sqrt(s**2+r**2)>n:"x"in n&&"y"in n?s>n.x&&r>n.y:"x"in n?s>n.x:"y"in n?r>n.y:!1}var Wt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Wt||(Wt={}));function qf(e){e.preventDefault()}function jz(e){e.stopPropagation()}var Ae;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(Ae||(Ae={}));const Pk={start:[Ae.Space,Ae.Enter],cancel:[Ae.Esc],end:[Ae.Space,Ae.Enter,Ae.Tab]},wz=(e,n)=>{let{currentCoordinates:s}=n;switch(e.code){case Ae.Right:return{...s,x:s.x+25};case Ae.Left:return{...s,x:s.x-25};case Ae.Down:return{...s,y:s.y+25};case Ae.Up:return{...s,y:s.y-25}}};class sp{constructor(n){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=n;const{event:{target:s}}=n;this.props=n,this.listeners=new fr(Gs(s)),this.windowListeners=new fr(It(s)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Wt.Resize,this.handleCancel),this.windowListeners.add(Wt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Wt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:n,onStart:s}=this.props,r=n.node.current;r&&bz(r),s(Zt)}handleKeyDown(n){if(tp(n)){const{active:s,context:r,options:a}=this.props,{keyboardCodes:o=Pk,coordinateGetter:i=wz,scrollBehavior:c="smooth"}=a,{code:d}=n;if(o.end.includes(d)){this.handleEnd(n);return}if(o.cancel.includes(d)){this.handleCancel(n);return}const{collisionRect:u}=r.current,p=u?{x:u.left,y:u.top}:Zt;this.referenceCoordinates||(this.referenceCoordinates=p);const h=i(n,{active:s,context:r.current,currentCoordinates:p});if(h){const f=Pr(h,p),m={x:0,y:0},{scrollableAncestors:g}=r.current;for(const x of g){const b=n.code,{isTop:y,isRight:v,isLeft:j,isBottom:_,maxScroll:w,minScroll:k}=Ck(x),S=mz(x),N={x:Math.min(b===Ae.Right?S.right-S.width/2:S.right,Math.max(b===Ae.Right?S.left:S.left+S.width/2,h.x)),y:Math.min(b===Ae.Down?S.bottom-S.height/2:S.bottom,Math.max(b===Ae.Down?S.top:S.top+S.height/2,h.y))},C=b===Ae.Right&&!v||b===Ae.Left&&!j,T=b===Ae.Down&&!_||b===Ae.Up&&!y;if(C&&N.x!==h.x){const P=x.scrollLeft+f.x,R=b===Ae.Right&&P<=w.x||b===Ae.Left&&P>=k.x;if(R&&!f.y){x.scrollTo({left:P,behavior:c});return}R?m.x=x.scrollLeft-P:m.x=b===Ae.Right?x.scrollLeft-w.x:x.scrollLeft-k.x,m.x&&x.scrollBy({left:-m.x,behavior:c});break}else if(T&&N.y!==h.y){const P=x.scrollTop+f.y,R=b===Ae.Down&&P<=w.y||b===Ae.Up&&P>=k.y;if(R&&!f.x){x.scrollTo({top:P,behavior:c});return}R?m.y=x.scrollTop-P:m.y=b===Ae.Down?x.scrollTop-w.y:x.scrollTop-k.y,m.y&&x.scrollBy({top:-m.y,behavior:c});break}}this.handleMove(n,Ts(Pr(h,this.referenceCoordinates),m))}}}handleMove(n,s){const{onMove:r}=this.props;n.preventDefault(),r(s)}handleEnd(n){const{onEnd:s}=this.props;n.preventDefault(),this.detach(),s()}handleCancel(n){const{onCancel:s}=this.props;n.preventDefault(),this.detach(),s()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}sp.activators=[{eventName:"onKeyDown",handler:(e,n,s)=>{let{keyboardCodes:r=Pk,onActivation:a}=n,{active:o}=s;const{code:i}=e.nativeEvent;if(r.start.includes(i)){const c=o.activatorNode.current;return c&&e.target!==c?!1:(e.preventDefault(),a==null||a({event:e.nativeEvent}),!0)}return!1}}];function Uf(e){return!!(e&&"distance"in e)}function Yf(e){return!!(e&&"delay"in e)}class rp{constructor(n,s,r){var a;r===void 0&&(r=vz(n.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=n,this.events=s;const{event:o}=n,{target:i}=o;this.props=n,this.events=s,this.document=Gs(i),this.documentListeners=new fr(this.document),this.listeners=new fr(r),this.windowListeners=new fr(It(i)),this.initialCoordinates=(a=Jl(o))!=null?a:Zt,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:n,props:{options:{activationConstraint:s,bypassActivationConstraint:r}}}=this;if(this.listeners.add(n.move.name,this.handleMove,{passive:!1}),this.listeners.add(n.end.name,this.handleEnd),n.cancel&&this.listeners.add(n.cancel.name,this.handleCancel),this.windowListeners.add(Wt.Resize,this.handleCancel),this.windowListeners.add(Wt.DragStart,qf),this.windowListeners.add(Wt.VisibilityChange,this.handleCancel),this.windowListeners.add(Wt.ContextMenu,qf),this.documentListeners.add(Wt.Keydown,this.handleKeydown),s){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Yf(s)){this.timeoutId=setTimeout(this.handleStart,s.delay),this.handlePending(s);return}if(Uf(s)){this.handlePending(s);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(n,s){const{active:r,onPending:a}=this.props;a(r,n,this.initialCoordinates,s)}handleStart(){const{initialCoordinates:n}=this,{onStart:s}=this.props;n&&(this.activated=!0,this.documentListeners.add(Wt.Click,jz,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Wt.SelectionChange,this.removeTextSelection),s(n))}handleMove(n){var s;const{activated:r,initialCoordinates:a,props:o}=this,{onMove:i,options:{activationConstraint:c}}=o;if(!a)return;const d=(s=Jl(n))!=null?s:Zt,u=Pr(a,d);if(!r&&c){if(Uf(c)){if(c.tolerance!=null&&$i(u,c.tolerance))return this.handleCancel();if($i(u,c.distance))return this.handleStart()}if(Yf(c)&&$i(u,c.tolerance))return this.handleCancel();this.handlePending(c,u);return}n.cancelable&&n.preventDefault(),i(d)}handleEnd(){const{onAbort:n,onEnd:s}=this.props;this.detach(),this.activated||n(this.props.active),s()}handleCancel(){const{onAbort:n,onCancel:s}=this.props;this.detach(),this.activated||n(this.props.active),s()}handleKeydown(n){n.code===Ae.Esc&&this.handleCancel()}removeTextSelection(){var n;(n=this.document.getSelection())==null||n.removeAllRanges()}}const _z={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class ap extends rp{constructor(n){const{event:s}=n,r=Gs(s.target);super(n,_z,r)}}ap.activators=[{eventName:"onPointerDown",handler:(e,n)=>{let{nativeEvent:s}=e,{onActivation:r}=n;return!s.isPrimary||s.button!==0?!1:(r==null||r({event:s}),!0)}}];const Sz={move:{name:"mousemove"},end:{name:"mouseup"}};var Ql;(function(e){e[e.RightClick=2]="RightClick"})(Ql||(Ql={}));class kz extends rp{constructor(n){super(n,Sz,Gs(n.event.target))}}kz.activators=[{eventName:"onMouseDown",handler:(e,n)=>{let{nativeEvent:s}=e,{onActivation:r}=n;return s.button===Ql.RightClick?!1:(r==null||r({event:s}),!0)}}];const zi={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Nz extends rp{constructor(n){super(n,zi)}static setup(){return window.addEventListener(zi.move.name,n,{capture:!1,passive:!1}),function(){window.removeEventListener(zi.move.name,n)};function n(){}}}Nz.activators=[{eventName:"onTouchStart",handler:(e,n)=>{let{nativeEvent:s}=e,{onActivation:r}=n;const{touches:a}=s;return a.length>1?!1:(r==null||r({event:s}),!0)}}];var mr;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(mr||(mr={}));var no;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(no||(no={}));function Cz(e){let{acceleration:n,activator:s=mr.Pointer,canScroll:r,draggingRect:a,enabled:o,interval:i=5,order:c=no.TreeOrder,pointerCoordinates:d,scrollableAncestors:u,scrollableAncestorRects:p,delta:h,threshold:f}=e;const m=Pz({delta:h,disabled:!o}),[g,x]=$$(),b=l.useRef({x:0,y:0}),y=l.useRef({x:0,y:0}),v=l.useMemo(()=>{switch(s){case mr.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case mr.DraggableRect:return a}},[s,a,d]),j=l.useRef(null),_=l.useCallback(()=>{const k=j.current;if(!k)return;const S=b.current.x*y.current.x,N=b.current.y*y.current.y;k.scrollBy(S,N)},[]),w=l.useMemo(()=>c===no.TreeOrder?[...u].reverse():u,[c,u]);l.useEffect(()=>{if(!o||!u.length||!v){x();return}for(const k of w){if((r==null?void 0:r(k))===!1)continue;const S=u.indexOf(k),N=p[S];if(!N)continue;const{direction:C,speed:T}=fz(k,N,v,n,f);for(const P of["x","y"])m[P][C[P]]||(T[P]=0,C[P]=0);if(T.x>0||T.y>0){x(),j.current=k,g(_,i),b.current=T,y.current=C;return}}b.current={x:0,y:0},y.current={x:0,y:0},x()},[n,_,r,x,o,i,JSON.stringify(v),JSON.stringify(m),g,u,w,p,JSON.stringify(f)])}const Tz={x:{[at.Backward]:!1,[at.Forward]:!1},y:{[at.Backward]:!1,[at.Forward]:!1}};function Pz(e){let{delta:n,disabled:s}=e;const r=Kl(n);return Jr(a=>{if(s||!r||!a)return Tz;const o={x:Math.sign(n.x-r.x),y:Math.sign(n.y-r.y)};return{x:{[at.Backward]:a.x[at.Backward]||o.x===-1,[at.Forward]:a.x[at.Forward]||o.x===1},y:{[at.Backward]:a.y[at.Backward]||o.y===-1,[at.Forward]:a.y[at.Forward]||o.y===1}}},[s,n,r])}function Oz(e,n){const s=n!=null?e.get(n):void 0,r=s?s.node.current:null;return Jr(a=>{var o;return n==null?null:(o=r??a)!=null?o:null},[r,n])}function Rz(e,n){return l.useMemo(()=>e.reduce((s,r)=>{const{sensor:a}=r,o=a.activators.map(i=>({eventName:i.eventName,handler:n(i.handler,r)}));return[...s,...o]},[]),[e,n])}var Rr;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Rr||(Rr={}));var Zl;(function(e){e.Optimized="optimized"})(Zl||(Zl={}));const Gf=new Map;function Ez(e,n){let{dragging:s,dependencies:r,config:a}=n;const[o,i]=l.useState(null),{frequency:c,measure:d,strategy:u}=a,p=l.useRef(e),h=b(),f=Tr(h),m=l.useCallback(function(y){y===void 0&&(y=[]),!f.current&&i(v=>v===null?y:v.concat(y.filter(j=>!v.includes(j))))},[f]),g=l.useRef(null),x=Jr(y=>{if(h&&!s)return Gf;if(!y||y===Gf||p.current!==e||o!=null){const v=new Map;for(let j of e){if(!j)continue;if(o&&o.length>0&&!o.includes(j.id)&&j.rect.current){v.set(j.id,j.rect.current);continue}const _=j.node.current,w=_?new np(d(_),_):null;j.rect.current=w,w&&v.set(j.id,w)}return v}return y},[e,o,s,h,d]);return l.useEffect(()=>{p.current=e},[e]),l.useEffect(()=>{h||m()},[s,h]),l.useEffect(()=>{o&&o.length>0&&i(null)},[JSON.stringify(o)]),l.useEffect(()=>{h||typeof c!="number"||g.current!==null||(g.current=setTimeout(()=>{m(),g.current=null},c))},[c,h,m,...r]),{droppableRects:x,measureDroppableContainers:m,measuringScheduled:o!=null};function b(){switch(u){case Rr.Always:return!1;case Rr.BeforeDragging:return s;default:return!s}}}function Ok(e,n){return Jr(s=>e?s||(typeof n=="function"?n(e):e):null,[n,e])}function Az(e,n){return Ok(e,n)}function Mz(e){let{callback:n,disabled:s}=e;const r=ep(n),a=l.useMemo(()=>{if(s||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(r)},[r,s]);return l.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function ti(e){let{callback:n,disabled:s}=e;const r=ep(n),a=l.useMemo(()=>{if(s||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(r)},[s]);return l.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function Iz(e){return new np(Vs(e),e)}function Vf(e,n,s){n===void 0&&(n=Iz);const[r,a]=l.useState(null);function o(){a(d=>{if(!e)return null;if(e.isConnected===!1){var u;return(u=d??s)!=null?u:null}const p=n(e);return JSON.stringify(d)===JSON.stringify(p)?d:p})}const i=Mz({callback(d){if(e)for(const u of d){const{type:p,target:h}=u;if(p==="childList"&&h instanceof HTMLElement&&h.contains(e)){o();break}}}}),c=ti({callback:o});return pn(()=>{o(),e?(c==null||c.observe(e),i==null||i.observe(document.body,{childList:!0,subtree:!0})):(c==null||c.disconnect(),i==null||i.disconnect())},[e]),r}function Dz(e){const n=Ok(e);return wk(e,n)}const Kf=[];function Lz(e){const n=l.useRef(e),s=Jr(r=>e?r&&r!==Kf&&e&&n.current&&e.parentNode===n.current.parentNode?r:ei(e):Kf,[e]);return l.useEffect(()=>{n.current=e},[e]),s}function Fz(e){const[n,s]=l.useState(null),r=l.useRef(e),a=l.useCallback(o=>{const i=Fi(o.target);i&&s(c=>c?(c.set(i,Xl(i)),new Map(c)):null)},[]);return l.useEffect(()=>{const o=r.current;if(e!==o){i(o);const c=e.map(d=>{const u=Fi(d);return u?(u.addEventListener("scroll",a,{passive:!0}),[u,Xl(u)]):null}).filter(d=>d!=null);s(c.length?new Map(c):null),r.current=e}return()=>{i(e),i(o)};function i(c){c.forEach(d=>{const u=Fi(d);u==null||u.removeEventListener("scroll",a)})}},[a,e]),l.useMemo(()=>e.length?n?Array.from(n.values()).reduce((o,i)=>Ts(o,i),Zt):Tk(e):Zt,[e,n])}function Jf(e,n){n===void 0&&(n=[]);const s=l.useRef(null);return l.useEffect(()=>{s.current=null},n),l.useEffect(()=>{const r=e!==Zt;r&&!s.current&&(s.current=e),!r&&s.current&&(s.current=null)},[e]),s.current?Pr(e,s.current):Zt}function $z(e){l.useEffect(()=>{if(!Zo)return;const n=e.map(s=>{let{sensor:r}=s;return r.setup==null?void 0:r.setup()});return()=>{for(const s of n)s==null||s()}},e.map(n=>{let{sensor:s}=n;return s}))}function zz(e,n){return l.useMemo(()=>e.reduce((s,r)=>{let{eventName:a,handler:o}=r;return s[a]=i=>{o(i,n)},s},{}),[e,n])}function Rk(e){return l.useMemo(()=>e?dz(e):null,[e])}const Xf=[];function Bz(e,n){n===void 0&&(n=Vs);const[s]=e,r=Rk(s?It(s):null),[a,o]=l.useState(Xf);function i(){o(()=>e.length?e.map(d=>Nk(d)?r:new np(n(d),d)):Xf)}const c=ti({callback:i});return pn(()=>{c==null||c.disconnect(),i(),e.forEach(d=>c==null?void 0:c.observe(d))},[e]),a}function Wz(e){if(!e)return null;if(e.children.length>1)return e;const n=e.children[0];return Kr(n)?n:e}function Hz(e){let{measure:n}=e;const[s,r]=l.useState(null),a=l.useCallback(u=>{for(const{target:p}of u)if(Kr(p)){r(h=>{const f=n(p);return h?{...h,width:f.width,height:f.height}:f});break}},[n]),o=ti({callback:a}),i=l.useCallback(u=>{const p=Wz(u);o==null||o.disconnect(),p&&(o==null||o.observe(p)),r(p?n(p):null)},[n,o]),[c,d]=eo(i);return l.useMemo(()=>({nodeRef:c,rect:s,setRef:d}),[s,c,d])}const qz=[{sensor:ap,options:{}},{sensor:sp,options:{}}],Uz={current:{}},Oa={draggable:{measure:Hf},droppable:{measure:Hf,strategy:Rr.WhileDragging,frequency:Zl.Optimized},dragOverlay:{measure:Vs}};class gr extends Map{get(n){var s;return n!=null&&(s=super.get(n))!=null?s:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(n=>{let{disabled:s}=n;return!s})}getNodeFor(n){var s,r;return(s=(r=this.get(n))==null?void 0:r.node.current)!=null?s:void 0}}const Yz={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new gr,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:to},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Oa,measureDroppableContainers:to,windowRect:null,measuringScheduled:!1},Gz={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:to,draggableNodes:new Map,over:null,measureDroppableContainers:to},ni=l.createContext(Gz),Ek=l.createContext(Yz);function Vz(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new gr}}}function Kz(e,n){switch(n.type){case nt.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:n.initialCoordinates,active:n.active}};case nt.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:n.coordinates.x-e.draggable.initialCoordinates.x,y:n.coordinates.y-e.draggable.initialCoordinates.y}}};case nt.DragEnd:case nt.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case nt.RegisterDroppable:{const{element:s}=n,{id:r}=s,a=new gr(e.droppable.containers);return a.set(r,s),{...e,droppable:{...e.droppable,containers:a}}}case nt.SetDroppableDisabled:{const{id:s,key:r,disabled:a}=n,o=e.droppable.containers.get(s);if(!o||r!==o.key)return e;const i=new gr(e.droppable.containers);return i.set(s,{...o,disabled:a}),{...e,droppable:{...e.droppable,containers:i}}}case nt.UnregisterDroppable:{const{id:s,key:r}=n,a=e.droppable.containers.get(s);if(!a||r!==a.key)return e;const o=new gr(e.droppable.containers);return o.delete(s),{...e,droppable:{...e.droppable,containers:o}}}default:return e}}function Jz(e){let{disabled:n}=e;const{active:s,activatorEvent:r,draggableNodes:a}=l.useContext(ni),o=Kl(r),i=Kl(s==null?void 0:s.id);return l.useEffect(()=>{if(!n&&!r&&o&&i!=null){if(!tp(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 p of[d.current,u.current]){if(!p)continue;const h=W$(p);if(h){h.focus();break}}})}},[r,n,a,i,o]),null}function Xz(e,n){let{transform:s,...r}=n;return e!=null&&e.length?e.reduce((a,o)=>o({transform:a,...r}),s):s}function Qz(e){return l.useMemo(()=>({draggable:{...Oa.draggable,...e==null?void 0:e.draggable},droppable:{...Oa.droppable,...e==null?void 0:e.droppable},dragOverlay:{...Oa.dragOverlay,...e==null?void 0:e.dragOverlay}}),[e==null?void 0:e.draggable,e==null?void 0:e.droppable,e==null?void 0:e.dragOverlay])}function Zz(e){let{activeNode:n,measure:s,initialRect:r,config:a=!0}=e;const o=l.useRef(!1),{x:i,y:c}=typeof a=="boolean"?{x:a,y:a}:a;pn(()=>{if(!i&&!c||!n){o.current=!1;return}if(o.current||!r)return;const u=n==null?void 0:n.node.current;if(!u||u.isConnected===!1)return;const p=s(u),h=wk(p,r);if(i||(h.x=0),c||(h.y=0),o.current=!0,Math.abs(h.x)>0||Math.abs(h.y)>0){const f=_k(u);f&&f.scrollBy({top:h.y,left:h.x})}},[n,i,c,r,s])}const Ak=l.createContext({...Zt,scaleX:1,scaleY:1});var Mn;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Mn||(Mn={}));const e6=l.memo(function(n){var s,r,a,o;let{id:i,accessibility:c,autoScroll:d=!0,children:u,sensors:p=qz,collisionDetection:h=sz,measuring:f,modifiers:m,...g}=n;const x=l.useReducer(Kz,void 0,Vz),[b,y]=x,[v,j]=V$(),[_,w]=l.useState(Mn.Uninitialized),k=_===Mn.Initialized,{draggable:{active:S,nodes:N,translate:C},droppable:{containers:T}}=b,P=S!=null?N.get(S):null,R=l.useRef({initial:null,translated:null}),I=l.useMemo(()=>{var je;return S!=null?{id:S,data:(je=P==null?void 0:P.data)!=null?je:Uz,rect:R}:null},[S,P]),A=l.useRef(null),[O,W]=l.useState(null),[D,Y]=l.useState(null),H=Tr(g,Object.values(g)),E=Xr("DndDescribedBy",i),U=l.useMemo(()=>T.getEnabled(),[T]),M=Qz(f),{droppableRects:J,measureDroppableContainers:ne,measuringScheduled:oe}=Ez(U,{dragging:k,dependencies:[C.x,C.y],config:M.droppable}),ae=Oz(N,S),G=l.useMemo(()=>D?Jl(D):null,[D]),ie=dt(),le=Az(ae,M.draggable.measure);Zz({activeNode:S!=null?N.get(S):null,config:ie.layoutShiftCompensation,initialRect:le,measure:M.draggable.measure});const Z=Vf(ae,M.draggable.measure,le),z=Vf(ae?ae.parentElement:null),L=l.useRef({activatorEvent:null,active:null,activeNode:ae,collisionRect:null,collisions:null,droppableRects:J,draggableNodes:N,draggingNode:null,draggingNodeRect:null,droppableContainers:T,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),q=T.getNodeFor((s=L.current.over)==null?void 0:s.id),se=Hz({measure:M.dragOverlay.measure}),fe=(r=se.nodeRef.current)!=null?r:ae,we=k?(a=se.rect)!=null?a:Z:null,De=!!(se.nodeRef.current&&se.rect),Fe=Dz(De?null:Z),Me=Rk(fe?It(fe):null),ee=Lz(k?q??ae:null),Q=Bz(ee),te=Xz(m,{transform:{x:C.x-Fe.x,y:C.y-Fe.y,scaleX:1,scaleY:1},activatorEvent:D,active:I,activeNodeRect:Z,containerNodeRect:z,draggingNodeRect:we,over:L.current.over,overlayNodeRect:se.rect,scrollableAncestors:ee,scrollableAncestorRects:Q,windowRect:Me}),he=G?Ts(G,C):null,ye=Fz(ee),ve=Jf(ye),Ne=Jf(ye,[Z]),de=Ts(te,ve),me=we?oz(we,te):null,We=I&&me?h({active:I,collisionRect:me,droppableRects:J,droppableContainers:U,pointerCoordinates:he}):null,B=jk(We,"id"),[F,X]=l.useState(null),ue=De?te:Ts(te,Ne),be=rz(ue,(o=F==null?void 0:F.rect)!=null?o:null,Z),xe=l.useRef(null),ke=l.useCallback((je,$e)=>{let{sensor:K,options:_e}=$e;if(A.current==null)return;const V=N.get(A.current);if(!V)return;const ce=je.nativeEvent,Be=new K({active:A.current,activeNode:V,event:ce,options:_e,context:L,onAbort(Ie){if(!N.get(Ie))return;const{onDragAbort:Ze}=H.current,st={id:Ie};Ze==null||Ze(st),v({type:"onDragAbort",event:st})},onPending(Ie,ut,Ze,st){if(!N.get(Ie))return;const{onDragPending:rt}=H.current,Je={id:Ie,constraint:ut,initialCoordinates:Ze,offset:st};rt==null||rt(Je),v({type:"onDragPending",event:Je})},onStart(Ie){const ut=A.current;if(ut==null)return;const Ze=N.get(ut);if(!Ze)return;const{onDragStart:st}=H.current,Ye={activatorEvent:ce,active:{id:ut,data:Ze.data,rect:R}};as.unstable_batchedUpdates(()=>{st==null||st(Ye),w(Mn.Initializing),y({type:nt.DragStart,initialCoordinates:Ie,active:ut}),v({type:"onDragStart",event:Ye}),W(xe.current),Y(ce)})},onMove(Ie){y({type:nt.DragMove,coordinates:Ie})},onEnd:Ke(nt.DragEnd),onCancel:Ke(nt.DragCancel)});xe.current=Be;function Ke(Ie){return async function(){const{active:Ze,collisions:st,over:Ye,scrollAdjustedTranslate:rt}=L.current;let Je=null;if(Ze&&rt){const{cancelDrop:vt}=H.current;Je={activatorEvent:ce,active:Ze,collisions:st,delta:rt,over:Ye},Ie===nt.DragEnd&&typeof vt=="function"&&await Promise.resolve(vt(Je))&&(Ie=nt.DragCancel)}A.current=null,as.unstable_batchedUpdates(()=>{y({type:Ie}),w(Mn.Uninitialized),X(null),W(null),Y(null),xe.current=null;const vt=Ie===nt.DragEnd?"onDragEnd":"onDragCancel";if(Je){const jt=H.current[vt];jt==null||jt(Je),v({type:vt,event:Je})}})}}},[N]),qe=l.useCallback((je,$e)=>(K,_e)=>{const V=K.nativeEvent,ce=N.get(_e);if(A.current!==null||!ce||V.dndKit||V.defaultPrevented)return;const Be={active:ce};je(K,$e.options,Be)===!0&&(V.dndKit={capturedBy:$e.sensor},A.current=_e,ke(K,$e))},[N,ke]),Le=Rz(p,qe);$z(p),pn(()=>{Z&&_===Mn.Initializing&&w(Mn.Initialized)},[Z,_]),l.useEffect(()=>{const{onDragMove:je}=H.current,{active:$e,activatorEvent:K,collisions:_e,over:V}=L.current;if(!$e||!K)return;const ce={active:$e,activatorEvent:K,collisions:_e,delta:{x:de.x,y:de.y},over:V};as.unstable_batchedUpdates(()=>{je==null||je(ce),v({type:"onDragMove",event:ce})})},[de.x,de.y]),l.useEffect(()=>{const{active:je,activatorEvent:$e,collisions:K,droppableContainers:_e,scrollAdjustedTranslate:V}=L.current;if(!je||A.current==null||!$e||!V)return;const{onDragOver:ce}=H.current,Be=_e.get(B),Ke=Be&&Be.rect.current?{id:Be.id,rect:Be.rect.current,data:Be.data,disabled:Be.disabled}:null,Ie={active:je,activatorEvent:$e,collisions:K,delta:{x:V.x,y:V.y},over:Ke};as.unstable_batchedUpdates(()=>{X(Ke),ce==null||ce(Ie),v({type:"onDragOver",event:Ie})})},[B]),pn(()=>{L.current={activatorEvent:D,active:I,activeNode:ae,collisionRect:me,collisions:We,droppableRects:J,draggableNodes:N,draggingNode:fe,draggingNodeRect:we,droppableContainers:T,over:F,scrollableAncestors:ee,scrollAdjustedTranslate:de},R.current={initial:we,translated:me}},[I,ae,We,me,N,fe,we,J,T,F,ee,de]),Cz({...ie,delta:C,draggingRect:me,pointerCoordinates:he,scrollableAncestors:ee,scrollableAncestorRects:Q});const Oe=l.useMemo(()=>({active:I,activeNode:ae,activeNodeRect:Z,activatorEvent:D,collisions:We,containerNodeRect:z,dragOverlay:se,draggableNodes:N,droppableContainers:T,droppableRects:J,over:F,measureDroppableContainers:ne,scrollableAncestors:ee,scrollableAncestorRects:Q,measuringConfiguration:M,measuringScheduled:oe,windowRect:Me}),[I,ae,Z,D,We,z,se,N,T,J,F,ne,ee,Q,M,oe,Me]),Ue=l.useMemo(()=>({activatorEvent:D,activators:Le,active:I,activeNodeRect:Z,ariaDescribedById:{draggable:E},dispatch:y,draggableNodes:N,over:F,measureDroppableContainers:ne}),[D,Le,I,Z,y,E,N,F,ne]);return At.createElement(bk.Provider,{value:j},At.createElement(ni.Provider,{value:Ue},At.createElement(Ek.Provider,{value:Oe},At.createElement(Ak.Provider,{value:be},u)),At.createElement(Jz,{disabled:(c==null?void 0:c.restoreFocus)===!1})),At.createElement(X$,{...c,hiddenTextDescribedById:E}));function dt(){const je=(O==null?void 0:O.autoScrollEnabled)===!1,$e=typeof d=="object"?d.enabled===!1:d===!1,K=k&&!je&&!$e;return typeof d=="object"?{...d,enabled:K}:{enabled:K}}}),t6=l.createContext(null),Qf="button",n6="Draggable";function s6(e){let{id:n,data:s,disabled:r=!1,attributes:a}=e;const o=Xr(n6),{activators:i,activatorEvent:c,active:d,activeNodeRect:u,ariaDescribedById:p,draggableNodes:h,over:f}=l.useContext(ni),{role:m=Qf,roleDescription:g="draggable",tabIndex:x=0}=a??{},b=(d==null?void 0:d.id)===n,y=l.useContext(b?Ak:t6),[v,j]=eo(),[_,w]=eo(),k=zz(i,n),S=Tr(s);pn(()=>(h.set(n,{id:n,key:o,node:v,activatorNode:_,data:S}),()=>{const C=h.get(n);C&&C.key===o&&h.delete(n)}),[h,n]);const N=l.useMemo(()=>({role:m,tabIndex:x,"aria-disabled":r,"aria-pressed":b&&m===Qf?!0:void 0,"aria-roledescription":g,"aria-describedby":p.draggable}),[r,m,x,b,g,p.draggable]);return{active:d,activatorEvent:c,activeNodeRect:u,attributes:N,isDragging:b,listeners:r?void 0:k,node:v,over:f,setNodeRef:j,setActivatorNodeRef:w,transform:y}}function r6(){return l.useContext(Ek)}const a6="Droppable",o6={timeout:25};function i6(e){let{data:n,disabled:s=!1,id:r,resizeObserverConfig:a}=e;const o=Xr(a6),{active:i,dispatch:c,over:d,measureDroppableContainers:u}=l.useContext(ni),p=l.useRef({disabled:s}),h=l.useRef(!1),f=l.useRef(null),m=l.useRef(null),{disabled:g,updateMeasurementsFor:x,timeout:b}={...o6,...a},y=Tr(x??r),v=l.useCallback(()=>{if(!h.current){h.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{u(Array.isArray(y.current)?y.current:[y.current]),m.current=null},b)},[b]),j=ti({callback:v,disabled:g||!i}),_=l.useCallback((N,C)=>{j&&(C&&(j.unobserve(C),h.current=!1),N&&j.observe(N))},[j]),[w,k]=eo(_),S=Tr(n);return l.useEffect(()=>{!j||!w.current||(j.disconnect(),h.current=!1,j.observe(w.current))},[w,j]),l.useEffect(()=>(c({type:nt.RegisterDroppable,element:{id:r,key:o,disabled:s,node:w,rect:f,data:S}}),()=>c({type:nt.UnregisterDroppable,key:o,id:r})),[r]),l.useEffect(()=>{s!==p.current.disabled&&(c({type:nt.SetDroppableDisabled,id:r,key:o,disabled:s}),p.current.disabled=s)},[r,o,s,c]),{active:i,rect:f,isOver:(d==null?void 0:d.id)===r,node:w,over:d,setNodeRef:k}}function Er(e,n,s){const r=e.slice();return r.splice(s<0?r.length+s:s,0,r.splice(n,1)[0]),r}function l6(e,n){return e.reduce((s,r,a)=>{const o=n.get(r);return o&&(s[a]=o),s},Array(e.length))}function pa(e){return e!==null&&e>=0}function c6(e,n){if(e===n)return!0;if(e.length!==n.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!==n[s])return!1;return!0}function d6(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const Mk=e=>{let{rects:n,activeIndex:s,overIndex:r,index:a}=e;const o=Er(n,r,s),i=n[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}},ha={scaleX:1,scaleY:1},u6=e=>{var n;let{activeIndex:s,activeNodeRect:r,index:a,rects:o,overIndex:i}=e;const c=(n=o[s])!=null?n:r;if(!c)return null;if(a===s){const u=o[i];return u?{x:0,y:s<i?u.top+u.height-(c.top+c.height):u.top-c.top,...ha}:null}const d=p6(o,a,s);return a>s&&a<=i?{x:0,y:-c.height-d,...ha}:a<s&&a>=i?{x:0,y:c.height+d,...ha}:{x:0,y:0,...ha}};function p6(e,n,s){const r=e[n],a=e[n-1],o=e[n+1];return r?s<n?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 Ik="Sortable",Dk=At.createContext({activeIndex:-1,containerId:Ik,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Mk,disabled:{draggable:!1,droppable:!1}});function h6(e){let{children:n,id:s,items:r,strategy:a=Mk,disabled:o=!1}=e;const{active:i,dragOverlay:c,droppableRects:d,over:u,measureDroppableContainers:p}=r6(),h=Xr(Ik,s),f=c.rect!==null,m=l.useMemo(()=>r.map(k=>typeof k=="object"&&"id"in k?k.id:k),[r]),g=i!=null,x=i?m.indexOf(i.id):-1,b=u?m.indexOf(u.id):-1,y=l.useRef(m),v=!c6(m,y.current),j=b!==-1&&x===-1||v,_=d6(o);pn(()=>{v&&g&&p(m)},[v,m,g,p]),l.useEffect(()=>{y.current=m},[m]);const w=l.useMemo(()=>({activeIndex:x,containerId:h,disabled:_,disableTransforms:j,items:m,overIndex:b,useDragOverlay:f,sortedRects:l6(m,d),strategy:a}),[x,h,_.draggable,_.droppable,j,m,b,d,f,a]);return At.createElement(Dk.Provider,{value:w},n)}const f6=e=>{let{id:n,items:s,activeIndex:r,overIndex:a}=e;return Er(s,r,a).indexOf(n)},m6=e=>{let{containerId:n,isSorting:s,wasDragging:r,index:a,items:o,newIndex:i,previousItems:c,previousContainerId:d,transition:u}=e;return!u||!r||c!==o&&a===i?!1:s?!0:i!==a&&n===d},g6={duration:200,easing:"ease"},Lk="transform",x6=Or.Transition.toString({property:Lk,duration:0,easing:"linear"}),b6={roleDescription:"sortable"};function y6(e){let{disabled:n,index:s,node:r,rect:a}=e;const[o,i]=l.useState(null),c=l.useRef(s);return pn(()=>{if(!n&&s!==c.current&&r.current){const d=a.current;if(d){const u=Vs(r.current,{ignoreTransform:!0}),p={x:d.left-u.left,y:d.top-u.top,scaleX:d.width/u.width,scaleY:d.height/u.height};(p.x||p.y)&&i(p)}}s!==c.current&&(c.current=s)},[n,s,r,a]),l.useEffect(()=>{o&&i(null)},[o]),o}function v6(e){let{animateLayoutChanges:n=m6,attributes:s,disabled:r,data:a,getNewIndex:o=f6,id:i,strategy:c,resizeObserverConfig:d,transition:u=g6}=e;const{items:p,containerId:h,activeIndex:f,disabled:m,disableTransforms:g,sortedRects:x,overIndex:b,useDragOverlay:y,strategy:v}=l.useContext(Dk),j=j6(r,m),_=p.indexOf(i),w=l.useMemo(()=>({sortable:{containerId:h,index:_,items:p},...a}),[h,a,_,p]),k=l.useMemo(()=>p.slice(p.indexOf(i)),[p,i]),{rect:S,node:N,isOver:C,setNodeRef:T}=i6({id:i,data:w,disabled:j.droppable,resizeObserverConfig:{updateMeasurementsFor:k,...d}}),{active:P,activatorEvent:R,activeNodeRect:I,attributes:A,setNodeRef:O,listeners:W,isDragging:D,over:Y,setActivatorNodeRef:H,transform:E}=s6({id:i,data:w,attributes:{...b6,...s},disabled:j.draggable}),U=F$(T,O),M=!!P,J=M&&!g&&pa(f)&&pa(b),ne=!y&&D,oe=ne&&J?E:null,G=J?oe??(c??v)({rects:x,activeNodeRect:I,activeIndex:f,overIndex:b,index:_}):null,ie=pa(f)&&pa(b)?o({id:i,items:p,activeIndex:f,overIndex:b}):_,le=P==null?void 0:P.id,Z=l.useRef({activeId:le,items:p,newIndex:ie,containerId:h}),z=p!==Z.current.items,L=n({active:P,containerId:h,isDragging:D,isSorting:M,id:i,index:_,items:p,newIndex:Z.current.newIndex,previousItems:Z.current.items,previousContainerId:Z.current.containerId,transition:u,wasDragging:Z.current.activeId!=null}),q=y6({disabled:!L,index:_,node:N,rect:S});return l.useEffect(()=>{M&&Z.current.newIndex!==ie&&(Z.current.newIndex=ie),h!==Z.current.containerId&&(Z.current.containerId=h),p!==Z.current.items&&(Z.current.items=p)},[M,ie,h,p]),l.useEffect(()=>{if(le===Z.current.activeId)return;if(le!=null&&Z.current.activeId==null){Z.current.activeId=le;return}const fe=setTimeout(()=>{Z.current.activeId=le},50);return()=>clearTimeout(fe)},[le]),{active:P,activeIndex:f,attributes:A,data:w,rect:S,index:_,newIndex:ie,items:p,isOver:C,isSorting:M,isDragging:D,listeners:W,node:N,overIndex:b,over:Y,setNodeRef:U,setActivatorNodeRef:H,setDroppableNodeRef:T,setDraggableNodeRef:O,transform:q??G,transition:se()};function se(){if(q||z&&Z.current.newIndex===_)return x6;if(!(ne&&!tp(R)||!u)&&(M||L))return Or.Transition.toString({...u,property:Lk})}}function j6(e,n){var s,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(s=e==null?void 0:e.draggable)!=null?s:n.draggable,droppable:(r=e==null?void 0:e.droppable)!=null?r:n.droppable}}function so(e){if(!e)return!1;const n=e.data.current;return!!(n&&"sortable"in n&&typeof n.sortable=="object"&&"containerId"in n.sortable&&"items"in n.sortable&&"index"in n.sortable)}const w6=[Ae.Down,Ae.Right,Ae.Up,Ae.Left],_6=(e,n)=>{let{context:{active:s,collisionRect:r,droppableRects:a,droppableContainers:o,over:i,scrollableAncestors:c}}=n;if(w6.includes(e.code)){if(e.preventDefault(),!s||!r)return;const d=[];o.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const f=a.get(h.id);if(f)switch(e.code){case Ae.Down:r.top<f.top&&d.push(h);break;case Ae.Up:r.top>f.top&&d.push(h);break;case Ae.Left:r.left>f.left&&d.push(h);break;case Ae.Right:r.left<f.left&&d.push(h);break}});const u=tz({collisionRect:r,droppableRects:a,droppableContainers:d});let p=jk(u,"id");if(p===(i==null?void 0:i.id)&&u.length>1&&(p=u[1].id),p!=null){const h=o.get(s.id),f=o.get(p),m=f?a.get(f.id):null,g=f==null?void 0:f.node.current;if(g&&m&&h&&f){const b=ei(g).some((k,S)=>c[S]!==k),y=Fk(h,f),v=S6(h,f),j=b||!y?{x:0,y:0}:{x:v?r.width-m.width:0,y:v?r.height-m.height:0},_={x:m.left,y:m.top};return j.x&&j.y?_:Pr(_,j)}}}};function Fk(e,n){return!so(e)||!so(n)?!1:e.data.current.sortable.containerId===n.data.current.sortable.containerId}function S6(e,n){return!so(e)||!so(n)||!Fk(e,n)?!1:e.data.current.sortable.index<n.data.current.sortable.index}function k6(e,n,s){const r=new Map(n.map(a=>[a.slug,a]));return e.dependsOn.map(a=>{var o;return{slug:a,title:((o=r.get(a))==null?void 0:o.title)??null,satisfied:s.has(a)}})}function $k(e){return e.filter(n=>!n.satisfied)}function N6(e){const n=new Map(e.map((a,o)=>[a.slug,o])),s=new Map(e.map(a=>[a.slug,a])),r=(a,o)=>{var d;const i=[a],c=new Set;for(;i.length>0;){const u=i.pop();if(!c.has(u)){c.add(u);for(const p of((d=s.get(u))==null?void 0:d.dependsOn)??[]){if(p===o)return!0;s.has(p)&&i.push(p)}}}return!1};for(const[a,o]of e.entries())for(const i of o.dependsOn??[]){const c=n.get(i);if(c!==void 0&&c>a&&!r(i,o.slug))return{dependent:o,prerequisite:s.get(i)}}return null}function op({filePath:e}){return t.jsx("div",{className:"px-3 py-2 border-t border-[var(--border-subtle)]",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{"data-testid":"plan-expanded-header-file-path",className:"text-xs font-mono text-[var(--text-dim)] break-all",children:e}),t.jsx($y,{value:e})]})})}const ene=Object.freeze(Object.defineProperty({__proto__:null,PlanExpandedHeader:op},Symbol.toStringTag,{value:"Module"}));function ip({title:e}){return t.jsx("div",{"data-testid":"plan-expanded-title",className:"px-3 pt-2 text-sm font-medium text-[var(--text-primary)] break-words",children:e})}const tne=Object.freeze(Object.defineProperty({__proto__:null,PlanExpandedTitle:ip},Symbol.toStringTag,{value:"Module"}));function C6(){const[e,n]=l.useState(!1),[s,r]=l.useState(null);return{deletePlan:l.useCallback(async o=>{n(!0),r(null);try{const i=await fetch(`/api/plans/${encodeURIComponent(o)}`,{method:"DELETE"});if(!i.ok){const c=await i.json().catch(()=>({}));throw new Error(c.error??`HTTP ${i.status}`)}}catch(i){const c=i instanceof Error?i.message:"Failed to delete plan";throw r(c),i instanceof Error?i:new Error(c)}finally{n(!1)}},[]),deleting:e,error:s}}function T6(){const[e,n]=l.useState(!1),[s,r]=l.useState(null);return{updatePlan:l.useCallback(async(o,i)=>{n(!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{n(!1)}},[]),saving:e,error:s}}function P6(e,n){return n.filter(s=>s.slug!==e&&(s.dependsOn??[]).includes(e)).map(s=>({slug:s.slug,title:s.title}))}function zk({slug:e,onClose:n}){return t.jsx("div",{className:"px-3 py-2 border-t border-[var(--border-subtle)]",children:t.jsx(qt,{chatName:`edit-plan-${e}`,slashCommand:`/codeyam-edit-plan ${e}`,height:360,onClose:n})})}const nne=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedChat:zk},Symbol.toStringTag,{value:"Module"}));function Bk({titleDraft:e,bodyDraft:n,saving:s,error:r,onTitleChange:a,onBodyChange:o,onSave:i,onCancel:c}){const d=Math.min(20,Math.max(8,n.split(`
|
|
88
|
+
`).length));return t.jsxs("div",{className:"border-t border-[var(--border-subtle)] px-3 py-2 flex flex-col gap-2",children:[t.jsx("input",{type:"text",value:e,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)]"}),t.jsx("textarea",{value:n,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&&t.jsx(tt,{text:r,className:"text-xs text-[var(--accent-red)]"}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx("button",{type:"button",onClick:c,disabled:s,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"}),t.jsx("button",{type:"button",onClick:i,disabled:s,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:s?"Saving…":"Save"})]})]})}const sne=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedEdit:Bk},Symbol.toStringTag,{value:"Module"}));function Wk(e){const n=[];let s={title:null,lines:[]};const r=()=>{(s.title!==null||s.lines.some(a=>a.trim()))&&n.push(s)};for(const a of e.split(`
|
|
89
|
+
`)){const o=/^##\s+(.+?)\s*$/.exec(a);o?(r(),s={title:o[1],lines:[]}):s.lines.push(a)}return r(),n.map(a=>({title:a.title,body:a.lines.join(`
|
|
90
|
+
`)}))}function Hk({body:e}){const n=Wk(e),[s,r]=l.useState(()=>new Set([0])),a=o=>r(i=>{const c=new Set(i);return c.has(o)?c.delete(o):c.add(o),c});return t.jsx("div",{className:"flex flex-col",children:n.map((o,i)=>{const c=s.has(i);return o.title===null?t.jsx(Ft,{variant:"document",children:o.body},i):t.jsxs("section",{className:i>0?"border-t border-white/[.06]":"",children:[t.jsx("h2",{className:"m-0",children:t.jsxs("button",{type:"button","aria-expanded":c,onClick:()=>a(i),className:"group flex w-full items-center gap-2 py-2 text-left cursor-pointer",children:[t.jsx("span",{"aria-hidden":"true",className:"w-3 text-[10px] text-gray-500 group-hover:text-gray-300",children:c?"▾":"▸"}),t.jsx("span",{className:"text-[13px] font-medium text-gray-200 group-hover:text-white",children:o.title})]})}),c&&t.jsx("div",{className:"pb-3 pl-5",children:t.jsx(Ft,{variant:"document",children:o.body})})]},i)})})}const rne=Object.freeze(Object.defineProperty({__proto__:null,PlanDocument:Hk,splitPlanSections:Wk},Symbol.toStringTag,{value:"Module"}));function qk({onClick:e}){return t.jsx("button",{type:"button",onClick:e,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 ane=Object.freeze(Object.defineProperty({__proto__:null,PlanRowEditButton:qk},Symbol.toStringTag,{value:"Module"}));function Uk({providerLabel:e,onClick:n}){return t.jsxs("button",{type:"button",onClick:n,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 ${e} seeded with this plan's contents`,children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.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 ",e]})}const one=Object.freeze(Object.defineProperty({__proto__:null,PlanRowEditChatButton:Uk},Symbol.toStringTag,{value:"Module"}));function Yk({dep:e}){const n=!e.satisfied&&e.title===null,s=e.satisfied?"completed":n?"missing":"blocked",r=e.satisfied?{borderColor:"var(--border-subtle)",color:"var(--text-dim)"}:{borderColor:"var(--accent-warn, #c08a2c)",color:"var(--accent-warn, #c08a2c)"};return t.jsxs("li",{"data-testid":`plan-row-dep-${e.slug}`,className:"text-sm flex items-center gap-2",children:[t.jsx("span",{className:"text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded border whitespace-nowrap",style:r,children:s}),t.jsx("span",{className:e.satisfied?"text-[var(--text-dim)] truncate":"text-[var(--text-primary)] truncate",children:n?`missing: ${e.slug}`:e.title??e.slug})]})}const ine=Object.freeze(Object.defineProperty({__proto__:null,PlanRowDependencyEntry:Yk},Symbol.toStringTag,{value:"Module"}));function lp({dependencies:e}){return t.jsxs("div",{"data-testid":"plan-row-deps",className:"px-3 py-2 border-b border-[var(--border-subtle)]",children:[t.jsx("p",{className:"text-[10px] uppercase tracking-wide text-[var(--text-dim)] mb-1.5",children:"Depends on"}),t.jsx("ul",{className:"flex flex-col gap-1",children:e.map(n=>t.jsx(Yk,{dep:n},n.slug))})]})}const lne=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedDependencies:lp},Symbol.toStringTag,{value:"Module"}));function Gk({title:e,filePath:n,body:s,providerLabel:r,onEdit:a,onChat:o,onDelete:i,dependencies:c}){return t.jsxs("div",{className:"border-t border-[var(--border-subtle)]",children:[t.jsx(ip,{title:e}),c&&c.length>0&&t.jsx(lp,{dependencies:c}),t.jsx("div",{className:"px-4 py-2 max-h-[55vh] overflow-y-auto",children:t.jsx(Hk,{body:s})}),t.jsx(op,{filePath:n}),t.jsxs("div",{className:"flex gap-2 justify-between px-3 py-2 border-t border-[var(--border-subtle)]",children:[t.jsx(Ay,{onClick:i}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(qk,{onClick:a}),t.jsx(Uk,{providerLabel:r,onClick:o})]})]})]})}const cne=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedView:Gk},Symbol.toStringTag,{value:"Module"}));function Vk({plan:e,dependencies:n}){const[s,r]=l.useState("view"),[a,o]=l.useState(!1),[i,c]=l.useState(e.title),[d,u]=l.useState(e.body),{updatePlan:p,saving:h,error:f}=T6(),{deletePlan:m,deleting:g,error:x}=C6(),{plans:b}=Ir(),{config:y}=St(),v=Qe(y==null?void 0:y.provider);return l.useEffect(()=>{c(e.title),u(e.body),r("view"),o(!1)},[e.slug]),s==="chat"?t.jsx(zk,{slug:e.slug,onClose:()=>r("view")}):s==="edit"?t.jsx(Bk,{titleDraft:i,bodyDraft:d,saving:h,error:f,onTitleChange:c,onBodyChange:u,onSave:async()=>{try{await p(e.slug,{title:i,body:d}),r("view")}catch{}},onCancel:()=>{c(e.title),u(e.body),r("view")}}):t.jsxs(t.Fragment,{children:[t.jsx(Gk,{title:e.title,filePath:e.filePath,body:e.body,providerLabel:v,onEdit:()=>r("edit"),onChat:()=>r("chat"),onDelete:()=>o(!0),dependencies:n}),a&&t.jsx(Ey,{title:e.title,slug:e.slug,filePath:e.filePath,dependents:P6(e.slug,b),busy:g,error:x,onCancel:()=>o(!1),onConfirm:async()=>{try{await m(e.slug)}catch{}}})]})}const dne=Object.freeze(Object.defineProperty({__proto__:null,PlanRowExpandedBody:Vk},Symbol.toStringTag,{value:"Module"}));function cp({plan:e,expanded:n,onToggle:s,onRun:r,launching:a=!1,blocked:o=!1,position:i,dragHandleRef:c,dragHandleAttributes:d,dragHandleListeners:u,sortableRef:p,sortableStyle:h,isDragging:f=!1,unsatisfiedDepCount:m=0,unsatisfiedDepTooltip:g,dependencies:x,claim:b,staleFetch:y=!1,expandedBodyVariant:v="full",author:j}){const _=w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),s())};return t.jsxs("li",{ref:p,style:h,className:`border border-[var(--plan-row-border,var(--border-subtle))] rounded-lg bg-[var(--plan-row-bg,var(--bg-surface))] transition-colors hover:border-[var(--text-dim)] hover:bg-[var(--bg-card)] ${f?"opacity-60 shadow-lg":""}`,children:[t.jsxs("div",{role:"button",tabIndex:0,onClick:s,onKeyDown:_,className:"w-full text-left px-3 py-2 flex items-center justify-between gap-3 bg-transparent cursor-pointer",children:[t.jsx(Hy,{slug:e.slug,title:e.title,timestamp:e.createdAt,position:i,author:j,dragHandleRef:c,dragHandleAttributes:d,dragHandleListeners:u}),t.jsx(Yy,{slug:e.slug,mode:e.mode,expanded:n,onRun:r,launching:a,blocked:o,unsatisfiedDepCount:m,unsatisfiedDepTooltip:g,claim:b,staleFetch:y})]}),n&&(v==="view"?t.jsxs("div",{className:"border-t border-[var(--border-subtle)]",children:[t.jsx(ip,{title:e.title}),x&&x.length>0&&t.jsx(lp,{dependencies:x}),t.jsx("div",{className:"px-3 py-2 max-h-[40vh] overflow-y-auto",children:t.jsx(Ft,{variant:"compact",children:e.body})}),t.jsx(op,{filePath:e.filePath})]}):t.jsx(Vk,{plan:e,dependencies:x}))]})}const une=Object.freeze(Object.defineProperty({__proto__:null,PlanRow:cp},Symbol.toStringTag,{value:"Module"}));function Kk({plan:e,position:n,expanded:s,onToggle:r,onRun:a,launching:o,blocked:i,draggable:c,unsatisfiedDepCount:d,unsatisfiedDepTooltip:u,dependencies:p,claim:h,staleFetch:f,author:m}){const{attributes:g,listeners:x,setNodeRef:b,setActivatorNodeRef:y,transform:v,transition:j,isDragging:_}=v6({id:e.slug,disabled:!c}),w={transform:Or.Transform.toString(v),transition:j};return t.jsx(cp,{plan:e,expanded:s,onToggle:r,onRun:a,launching:o,blocked:i,position:n,sortableRef:b,sortableStyle:w,isDragging:_,dragHandleRef:c?y:void 0,dragHandleAttributes:c?g:void 0,dragHandleListeners:c?x:void 0,unsatisfiedDepCount:d,unsatisfiedDepTooltip:u,dependencies:p,claim:h,staleFetch:f,author:m})}const pne=Object.freeze(Object.defineProperty({__proto__:null,SortablePlanRow:Kk},Symbol.toStringTag,{value:"Module"}));function O6(e,n){const[s,r]=l.useState(null),[a,o]=l.useState(null);return l.useEffect(()=>{r(null)},[e]),{items:s??e,error:a,reorder:n?i=>{r(i),o(null),n(i).catch(c=>{r(null),o(c instanceof Error?c.message:"Unknown error")})}:null}}function si({plans:e,loading:n,error:s,onRun:r,launchingSlug:a,launchError:o,blocked:i=!1,onReorder:c,depAnnotationsBySlug:d,dependenciesBySlug:u,claimsBySlug:p,staleFetch:h,showAuthors:f=!1,skeletonCount:m=3}){const[g,x]=l.useState(null),{items:b,error:y,reorder:v}=O6(e,c?S=>c(S.map(N=>N.slug)):void 0),_=n&&b.length===0?m:b.length,[w,k]=l.useState(!0);return t.jsxs("div",{className:"mt-5 border-t border-[var(--border-subtle)] pt-5",children:[t.jsx(zs,{title:"Queued Plans",count:_,expanded:w,onToggle:()=>k(S=>!S),testId:"queued-plans-header"}),o&&t.jsxs(Ya,{tone:"error",spacing:"tight",children:["Failed to launch plan: ",o]}),y&&t.jsxs(Ya,{tone:"error",spacing:"tight",children:["Failed to reorder plans: ",y]}),w&&t.jsx(dp,{plans:b,loading:n,error:s,expandedSlug:g,onToggle:S=>x(N=>N===S?null:S),onRun:r,launchingSlug:a??null,blocked:i,depAnnotationsBySlug:d,dependenciesBySlug:u,claimsBySlug:p,staleFetch:h,onReorder:v??void 0,showAuthors:f,skeletonCount:m})]})}function dp({plans:e,loading:n,error:s,expandedSlug:r,onToggle:a,onRun:o,launchingSlug:i,blocked:c,onReorder:d,depAnnotationsBySlug:u,dependenciesBySlug:p,claimsBySlug:h,staleFetch:f,showAuthors:m=!1,skeletonCount:g=3}){const x=Q$(zf(ap,{activationConstraint:{distance:4}}),zf(sp,{coordinateGetter:_6})),b=l.useMemo(()=>e.map(k=>k.slug),[e]),[y,v]=l.useState(null),j=s?t.jsx(tt,{text:`Failed to load plans: ${s}`,className:"text-sm text-[var(--accent-red)]",rowClassName:"mt-3"}):null;if(n&&e.length===0)return t.jsx(Ld,{count:g});if(e.length===0)return j;const _=k=>{const{active:S,over:N}=k;if(!N||S.id===N.id||!d)return;const C=e.findIndex(I=>I.slug===S.id),T=e.findIndex(I=>I.slug===N.id);if(C===-1||T===-1)return;const P=Er(e,C,T),R=N6(P);if(R){v(`“${R.dependent.title}” depends on “${R.prerequisite.title}”, so it stays below it.`);return}d(P)},w=t.jsx("ul",{className:"mt-3 flex flex-col gap-2","data-testid":"plan-list",children:e.map((k,S)=>{const N=u==null?void 0:u[k.slug],C=h==null?void 0:h.get(k.slug);return t.jsx(Kk,{plan:k,position:S+1,expanded:r===k.slug,onToggle:()=>a(k.slug),onRun:o,launching:i===k.slug,blocked:c,draggable:!!d,unsatisfiedDepCount:N==null?void 0:N.count,unsatisfiedDepTooltip:N==null?void 0:N.tooltip,dependencies:p==null?void 0:p[k.slug],claim:C,staleFetch:f,author:m?k.author:void 0},k.slug)})});return d?t.jsxs(t.Fragment,{children:[j,y&&t.jsx(Ya,{tone:"error",spacing:"tight",children:t.jsx("span",{"data-testid":"plan-dependency-notice",children:y})}),t.jsx(e6,{sensors:x,collisionDetection:ez,onDragStart:()=>v(null),onDragEnd:_,children:t.jsx(h6,{items:b,strategy:u6,children:w})})]}):t.jsxs(t.Fragment,{children:[j,w]})}const hne=Object.freeze(Object.defineProperty({__proto__:null,QueuedChangesBody:dp,QueuedChangesSection:si},Symbol.toStringTag,{value:"Module"})),ec="build-reset-requested";function R6(){window.dispatchEvent(new CustomEvent(ec))}const tc="build-empty-session-close";function E6(){window.dispatchEvent(new CustomEvent(tc))}function Jk({awaitingPlanLaunchChoice:e,configLoading:n,sessionLoading:s,sessionDecision:r,sessionInfo:a,buildLaunchGateArmed:o,stepState:i,provider:c,onContinueSession:d,onStartOver:u,onAgentIdle:p,onAgentBlocked:h,onAgentActive:f,onUserInput:m,pendingPlans:g,pendingPlansLoading:x,pendingPlansError:b,onLaunchPlan:y,launchingSlug:v,launchError:j,onReorderPlans:_,isAgentBuilding:w,featureCompleteActive:k=!1,buildActivity:S="menu",chatEscalatedToPrototype:N=!1,onActivityDone:C,onPrototypeLaunched:T,prototypeLaunchSignal:P=0,connectionPhase:R=null}){var U;const I=l.useSyncExternalStore(L$,D$),A=()=>{Ff(!0),T==null||T()};l.useEffect(()=>{k&&Ff(!1)},[k]);const{recoveryFeatureName:O,recoveryStep:W,recoveryMode:D,showTerminal:Y,shouldResumeSameProvider:H}=JF({sessionDecision:r,sessionInfo:a,buildLaunchGateArmed:o,stepState:i}),E=r==="completed"&&!(a!=null&&a.cycleClosed);return r==="pending"||E?t.jsx(AS,{featureName:O,editorStep:W,workflowMode:D,currentProvider:c,previousProvider:(a==null?void 0:a.provider)??null,resumeMode:(a==null?void 0:a.resumeMode)??"fresh",sessionId:(a==null?void 0:a.sessionId)??null,activity:((U=a==null?void 0:a.liveBuildActivity)==null?void 0:U.activity)??null,idleSeconds:(a==null?void 0:a.sessionIdleSeconds)??null,onContinue:d,onStartOver:u??R6,onEmptySession:E6}):S==="prototype"?t.jsx(Jt,{testId:"build-activity-prototype",fill:!0,children:t.jsx(fk,{isAgentBuilding:w&&!k,featureName:(i==null?void 0:i.feature)??null,initiallyOpen:!0,onDone:C,onLaunched:A,launchSignal:P})}):S==="chat"?t.jsx(Jt,{testId:"build-activity-chat",fill:!0,children:t.jsx(lk,{escalatedToPrototype:N,onDone:C,onLaunched:A,launchSignal:P})}):e&&g.length>0&&a===null&&i===null?t.jsx(Jt,{children:t.jsx(si,{plans:g,loading:x,error:b,onRun:M=>{var ne;const J=((ne=g.find(oe=>oe.slug===M))==null?void 0:ne.title)??M;y(M,J)},launchingSlug:v,launchError:j,blocked:w,onReorder:_})}):Y?t.jsx(Vr,{label:"Build agent",sessionName:"build session",initialView:"terminal",experimentalNotice:QF,initialSessionId:H?(a==null?void 0:a.sessionId)??null:null,onWaitingOnUser:()=>h("chat-question"),onNeedsYouChange:Bu,onWorkingChange:Wu,intro:I?t.jsx(mk,{}):void 0,renderTerminal:M=>t.jsx(tk,{provider:c,shouldResumeSameProvider:H,sessionId:(a==null?void 0:a.sessionId)??null,onAgentIdle:p,onAgentBlocked:h,onAgentActive:f,onUserInput:m,currentFeature:(i==null?void 0:i.feature)??null,binding:M})}):j?t.jsx(bb,{message:j}):R?t.jsx(Zx,{phase:R}):r==="no-session"&&i===null?t.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-slate-500 space-y-4 px-10 text-center",children:[t.jsx("div",{className:"text-lg font-medium text-slate-400",children:"Ready to build"}),t.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 fne=Object.freeze(Object.defineProperty({__proto__:null,BuildTabSessionContent:Jk},Symbol.toStringTag,{value:"Module"}));function A6(e){return e?{step:e.step??0,feature:e.feature??null,startedAt:e.startedAt??"",...e.featureStartedAt?{featureStartedAt:e.featureStartedAt}:{},mode:Ut(e.mode),slug:e.slug??null,slugVisits:e.slugVisits??{}}:null}const M6=3e3;function Qr(){const[e,n]=l.useState(null),[s,r]=l.useState(!0),a=l.useRef(null),o=l.useRef(null),i=l.useCallback(()=>{fetch("/api/step").then(c=>{if(!c.ok)throw new Error(`HTTP ${c.status}`);return c.json()}).then(c=>{const d=A6(c),u=JSON.stringify(d);u!==o.current&&(o.current=u,n(d)),r(!1)}).catch(()=>{r(!1)})},[]);return l.useEffect(()=>(i(),a.current=setInterval(i,M6),()=>{a.current&&clearInterval(a.current)}),[i]),{stepState:e,loading:s,refetch:i}}const ht={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,cycleClosed:null,liveBuildActivity:null,sessionIdleSeconds:null};function I6(e){return{hasSession:(e==null?void 0:e.hasSession)??ht.hasSession,resumeMode:(e==null?void 0:e.resumeMode)??ht.resumeMode,provider:(e==null?void 0:e.provider)??ht.provider,feature:(e==null?void 0:e.feature)??ht.feature,step:(e==null?void 0:e.step)??ht.step,mode:(e==null?void 0:e.mode)==null?ht.mode:Ut(e.mode),label:(e==null?void 0:e.label)??ht.label,sessionId:(e==null?void 0:e.sessionId)??ht.sessionId,awaitingUserInput:(e==null?void 0:e.awaitingUserInput)??ht.awaitingUserInput,reopenResults:(e==null?void 0:e.reopenResults)??ht.reopenResults,preview:(e==null?void 0:e.preview)??ht.preview,agentBrokerLive:(e==null?void 0:e.agentBrokerLive)??ht.agentBrokerLive,brokerDaemonReachable:e==null?void 0:e.brokerDaemonReachable,resultsShown:(e==null?void 0:e.resultsShown)??ht.resultsShown,cycleClosed:(e==null?void 0:e.cycleClosed)??ht.cycleClosed,liveBuildActivity:(e==null?void 0:e.liveBuildActivity)??ht.liveBuildActivity,sessionIdleSeconds:(e==null?void 0:e.sessionIdleSeconds)??ht.sessionIdleSeconds}}function up(e){const n=e==null?void 0:e.pollIntervalMs,[s,r]=l.useState(null),[a,o]=l.useState(!0),i=l.useCallback(async()=>{o(!0);try{const c=await mu("/api/session-info");if(!c.ok)throw new Error(`HTTP ${c.status}`);const d=await c.json();r(I6(d))}catch{r(c=>c??ht)}finally{o(!1)}},[]);return l.useEffect(()=>{i()},[i]),l.useEffect(()=>{if(n==null||n<=0)return;const c=setInterval(()=>{i()},n);return()=>clearInterval(c)},[n,i]),{sessionInfo:s,loading:a,refetch:i}}const D6=5e3;function L6(){const[e,n]=l.useState(null),[s,r]=l.useState(!0),a=l.useRef(null);return l.useEffect(()=>{const o=()=>{fetch("/api/prompt").then(i=>i.json()).then(i=>{n(i.prompt??null),r(!1)}).catch(()=>r(!1))};return o(),a.current=setInterval(o,D6),()=>{a.current&&clearInterval(a.current)}},[]),{prompt:e,loading:s}}function F6({currentDecision:e,sessionInfo:n,sessionLoading:s,attachedSessionId:r=null,requestAttachLive:a=!1}){return s||!n?e:e==="continue"&&n.hasSession?"continue":e==="fresh"&&n.hasSession&&(n.resumeMode==="resume"||n.resumeMode==="completed")?"fresh":n.resumeMode==="completed"?"completed":a&&n.hasSession&&n.resumeMode!=="handoff"||n.resumeMode==="resume"&&n.hasSession&&r!=null&&n.sessionId===r?"continue":n.resumeMode==="resume"||n.resumeMode==="handoff"?"pending":"fresh"}let Ra=null;const $6=1e4,nc=new Set;function Xk(){Ra=Date.now();for(const e of[...nc])e()}function z6(e){return nc.add(e),()=>{nc.delete(e)}}function Zf(){if(Ra==null)return!1;const e=Date.now()-Ra;return Ra=null,e<=$6}const pp="codeyam.buildTab.attachedSessionId";function B6(e){try{window.sessionStorage.setItem(pp,e)}catch{}}function W6(){try{return window.sessionStorage.getItem(pp)}catch{return null}}function H6(){try{window.sessionStorage.removeItem(pp)}catch{}}function q6({sessionLoading:e,sessionInfo:n,requestAttachLive:s=!1}){const r=l.useRef(void 0);r.current===void 0&&(r.current=W6());const[a,o]=l.useState(()=>Zf()?"fresh":"no-session");l.useEffect(()=>z6(()=>{Zf(),o("fresh")}),[]),l.useEffect(()=>{o(c=>F6({currentDecision:c,sessionInfo:n,sessionLoading:e,attachedSessionId:r.current??null,requestAttachLive:s}))},[e,n,s]),l.useEffect(()=>{if(n){if(!n.hasSession){H6(),r.current=null;return}n.sessionId&&(a==="continue"||a==="fresh")&&(B6(n.sessionId),r.current=n.sessionId)}},[a,n]);const i=l.useCallback(()=>{o("continue")},[]);return{sessionDecision:a,handleContinueSession:i}}function U6(e,n){return e!=null&&e.worker?(e.state==="dispatching"||e.state==="delayed"||e.state==="launch-timeout"||e.state==="acknowledged"||e.state==="unverified")&&(n==null?void 0:n.agentBrokerLive)===!0:!1}function Y6(e,n){return e?e.state==="interrupted"?"interrupted":e.worker&&n===null&&(e.state==="acknowledged"||e.state==="unverified")?"reconnecting":e.state==="dispatching"||e.state==="delayed"||e.state==="launch-timeout"?"starting":null:null}function G6(){const e=window.getSelection();return!!e&&!e.isCollapsed&&e.toString().length>0}function sc(){const e=document.activeElement;return e===null||e===document.body||e===document.documentElement||e instanceof HTMLElement&&e.dataset.navTab==="true"}function rc(e,n,s,r=0){return e>=s.left-r&&e<=s.right+r&&n>=s.top-r&&n<=s.bottom+r}function ac(e){em(e,!0);let n=!1;const s=()=>{n||(n=!0,em(e,!1))};typeof requestAnimationFrame=="function"?(requestAnimationFrame(s),setTimeout(s,100)):queueMicrotask(s)}function em(e,n){const s=e;if(typeof s.inert=="boolean"){s.inert=n;return}n?e.setAttribute("inert",""):e.removeAttribute("inert")}function Bi(e){vr(),ac(e),e.blur(),_t(),queueMicrotask(()=>{document.activeElement===e&&(ac(e),e.blur(),_t())})}function V6(e){const n=l.useRef(!1),s=l.useRef(null);l.useEffect(()=>{if(!e)return;let r=!1;const a=()=>{r=!0},o=()=>{r=!1};function i(){if(!n.current&&!r&&sc()&&!G6()){n.current=!0;try{vr(),window.dispatchEvent(new Event("terminal-focus"))}finally{n.current=!1}}}function c(f){const m=f.relatedTarget;m instanceof HTMLElement&&m.dataset.navTab!=="true"||queueMicrotask(i)}function d(){const f=document.activeElement;f instanceof HTMLIFrameElement&&(s.current=f)}function u(f){const m=document.activeElement;if(m instanceof HTMLIFrameElement){if(f.target===m)return;Bi(m),h(m);return}const g=s.current;if(!g||f.target===g)return;const x=f;if(typeof x.clientX=="number"&&typeof x.clientY=="number"){const b=g.getBoundingClientRect();if(rc(x.clientX,x.clientY,b,1))return}Bi(g),h(g)}function p(f){const m=document.activeElement;if(!(m instanceof HTMLIFrameElement))return;s.current=m;const g=m.getBoundingClientRect();rc(f.clientX,f.clientY,g,1)||(Bi(m),h(m))}function h(f){requestAnimationFrame(()=>{document.activeElement!==f&&(sc()||(s.current=null))})}return document.addEventListener("pointerdown",a,!0),document.addEventListener("pointerup",o,!0),document.addEventListener("pointercancel",o,!0),window.addEventListener("blur",o),document.addEventListener("focusin",d),document.addEventListener("focusout",c),window.addEventListener("focus",c),document.addEventListener("visibilitychange",c),document.addEventListener("mouseup",c),document.addEventListener("pointerdown",u,!0),document.addEventListener("mousedown",u,!0),document.addEventListener("click",u,!0),document.addEventListener("pointermove",p,{capture:!0,passive:!0}),()=>{document.removeEventListener("pointerdown",a,!0),document.removeEventListener("pointerup",o,!0),document.removeEventListener("pointercancel",o,!0),window.removeEventListener("blur",o),document.removeEventListener("focusin",d),document.removeEventListener("focusout",c),window.removeEventListener("focus",c),document.removeEventListener("visibilitychange",c),document.removeEventListener("mouseup",c),document.removeEventListener("pointerdown",u,!0),document.removeEventListener("mousedown",u,!0),document.removeEventListener("click",u,!0),document.removeEventListener("pointermove",p,{capture:!0})}},[e])}function K6({sessionLoading:e,sessionInfo:n,onRestorePreview:s}){const r=l.useRef(!1);l.useEffect(()=>{e||!(n!=null&&n.preview)||n.resumeMode!=="resume"&&n.resumeMode!=="handoff"||r.current||(r.current=!0,s==null||s(n.preview))},[s,n,e])}function J6(e){const n=l.useRef(e),s=l.useRef(null);l.useEffect(()=>{e&&e!==n.current&&(n.current=e,s.current??(s.current=new AbortController),yr(e,void 0,void 0,"session-feature-rename",s.current.signal))},[e]),l.useEffect(()=>()=>{var r;(r=s.current)==null||r.abort()},[])}function X6(e,n){if(!e||!n)return null;const s=n[e]??0;return s<=1?null:s===2?"2nd pass":s===3?"3rd pass":`${s}th pass`}function Q6(e,n,s){l.useEffect(()=>{if(!n)return;const r=a=>{e.current&&!e.current.contains(a.target)&&s()};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[e,n,s])}function Qk({displayName:e,hasPrompt:n,expanded:s,onToggle:r}){return n?t.jsxs("button",{onClick:r,className:"flex items-center gap-1 cursor-pointer transition-colors min-w-0",style:{color:"var(--text-secondary)"},children:[t.jsx("span",{className:"font-medium truncate",children:e}),t.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 ${s?"rotate-180":""}`,children:t.jsx("path",{d:"M2 4l3 3 3-3"})})]}):t.jsx("span",{className:"font-medium truncate",style:{color:"var(--text-secondary)"},children:e})}const mne=Object.freeze(Object.defineProperty({__proto__:null,FeatureNameButton:Qk},Symbol.toStringTag,{value:"Module"}));function Zk({prompt:e}){return t.jsxs("div",{"data-testid":"prompt-dropdown-panel",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:12,boxShadow:"0 12px 32px rgba(0,0,0,.45)",maxHeight:"16rem",overflowY:"auto",padding:"12px 16px 14px",fontSize:12.5,lineHeight:1.6,color:"var(--text-secondary)"},children:[t.jsx("div",{style:{fontSize:10.5,letterSpacing:".08em",textTransform:"uppercase",color:"var(--text-dim)",marginBottom:4},children:"Your request"}),t.jsx(Ft,{variant:"compact",children:e})]})}const gne=Object.freeze(Object.defineProperty({__proto__:null,PromptDropdownPanel:Zk},Symbol.toStringTag,{value:"Module"}));function e1({label:e}){return e?t.jsx("span",{className:"rounded px-1.5 py-0.5",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",color:"var(--text-dim)"},children:e}):null}const xne=Object.freeze(Object.defineProperty({__proto__:null,RepeatPassMarker:e1},Symbol.toStringTag,{value:"Module"}));function t1({currentStep:e,isExpanded:n,mode:s,onToggle:r=()=>{},stepNum:a}){const o=a===e,i=a<e,{primary:c,secondary:d,phaseLabel:u,description:p}=V3(a,s);return t.jsxs("div",{onClick:r,className:"cursor-pointer",children:[t.jsxs("div",{className:"w-full px-3 py-0.5 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:h=>h.currentTarget.style.background="var(--bg-input)",onMouseLeave:h=>h.currentTarget.style.background="transparent",children:[t.jsxs("span",{className:"w-5 text-right tabular-nums shrink-0",children:[a,"."]}),t.jsx("span",{className:"flex-1 min-w-0 truncate",children:c}),d&&t.jsx("span",{className:"shrink-0 text-[10px]",style:{color:"var(--text-dim)",opacity:.7},children:d}),p&&t.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 ${n?"rotate-180":""}`,children:t.jsx("path",{d:"M2 4l3 3 3-3"})})]}),n&&p&&t.jsxs("div",{className:"px-3 pb-1.5 pl-10",children:[u&&t.jsx("p",{className:"text-[9px] m-0 mb-0.5 uppercase tracking-wide",style:{color:"var(--text-dim)",opacity:.7},children:u}),t.jsx("p",{className:"text-[10px] m-0 leading-relaxed",style:{color:"var(--text-dim)"},children:p})]})]},a)}const bne=Object.freeze(Object.defineProperty({__proto__:null,StepIndicatorDropdownItem:t1},Symbol.toStringTag,{value:"Module"}));function oc({step:e,feature:n,mode:s,userPrompt:r,slug:a=null,slugVisits:o,inline:i=!1,hideStep:c=!1,note:d,namePrefix:u,nameSuffix:p}){const[h,f]=l.useState(!1),[m,g]=l.useState(null),[x,b]=l.useState(!1),[y,v]=l.useState(null),j=l.useRef(null),_=l.useRef(null),w=l.useRef(null),k=l.useRef(null);l.useLayoutEffect(()=>{if(!h)return;const E=()=>{var M;const U=(M=_.current)==null?void 0:M.getBoundingClientRect();U&&v({top:U.bottom+4,left:U.left,right:window.innerWidth-U.right})};return E(),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0),()=>{window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[h]),l.useEffect(()=>{if(!h)return;const E=U=>{var J,ne;const M=U.target;(J=j.current)!=null&&J.contains(M)||(ne=w.current)!=null&&ne.contains(M)||f(!1)};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[h]),Q6(k,x,l.useCallback(()=>b(!1),[]));const S=c||i&&d?0:e,N=S>0,C=n||"New Working Session",T=Ut(s),P=N0(S,T),R=P.totalSteps,I=P.prefix,A=ku(S,T),O=N?A.primary:null,W=N?A.secondary:null,D=X6(a,o),Y=i?"flex flex-col items-start gap-0.5 min-w-0 text-[13px] select-none":"h-9 flex items-center justify-between px-4 text-[13px] shrink-0 select-none",H=E=>i||!E?void 0:Gr("bottom");return S===0?t.jsxs("div",{className:Y,style:H(!0),children:[t.jsxs("div",{className:"flex items-center gap-2.5 min-w-0 max-w-full",children:[u,t.jsx("span",{className:"font-medium truncate",style:{color:i?"var(--text-primary)":"var(--text-muted)"},children:C}),p]}),i&&d&&t.jsx("span",{"data-testid":"step-indicator-note",className:"text-[11.5px] truncate max-w-full",style:{color:"var(--text-muted)"},children:d}),!i&&t.jsx("span",{style:{color:"var(--text-dim)"},children:n?"Starting…":"Waiting for session"})]}):t.jsxs("div",{className:i?"relative min-w-0":"shrink-0",ref:k,children:[t.jsxs("div",{className:Y,style:H(!x),children:[t.jsxs("div",{className:"flex items-center gap-2.5 min-w-0 max-w-full",children:[u,t.jsx(Qk,{displayName:C,hasPrompt:!!r,expanded:x,onToggle:()=>b(E=>!E)}),p]}),N&&t.jsxs("div",{className:i?"relative min-w-0 max-w-full":"relative",ref:j,children:[t.jsxs("button",{ref:_,"data-testid":"step-indicator-step",onClick:()=>f(E=>!E),className:`flex items-center gap-1.5 cursor-pointer transition-colors ${i?"text-[11.5px] min-w-0 max-w-full":""}`,style:{color:i?"var(--text-muted)":"var(--text-secondary)"},children:[!i&&t.jsx("span",{style:{color:"var(--text-dim)"},children:"::"}),i?t.jsxs("span",{className:"truncate",children:["Step ",S,"/",R,": ",O]}):t.jsxs("span",{children:[I," ",S,t.jsxs("span",{style:{color:"var(--text-dim)"},children:[" / ",R]}),": ",O,W&&t.jsxs("span",{style:{color:"var(--text-dim)",opacity:.7},children:[" ","(",W,")"]})]}),t.jsx(e1,{label:D}),t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",className:`transition-transform ${h?"rotate-180":""}`,children:t.jsx("path",{d:"M2 4l3 3 3-3"})})]}),h&&y&&as.createPortal(t.jsx("div",{ref:w,className:"w-96 rounded-lg shadow-lg py-1 text-xs max-h-[70vh] overflow-y-auto",style:{position:"fixed",top:y.top,...i?{left:y.left}:{right:y.right},zIndex:60,background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:Array.from({length:R},(E,U)=>U+1).map(E=>{const U=m===E;return t.jsx(t1,{currentStep:S,isExpanded:U,mode:T,onToggle:()=>g(U?null:E),stepNum:E},E)})}),document.body)]})]}),x&&r&&t.jsx("div",{className:i?"absolute left-0 top-full z-30 mt-1 w-[min(560px,80vw)]":void 0,children:t.jsx(Zk,{prompt:r})})]})}const yne=Object.freeze(Object.defineProperty({__proto__:null,StepIndicatorBar:oc},Symbol.toStringTag,{value:"Module"}));function n1({awaitingPlanLaunchChoice:e,buildLaunchGateArmed:n,isActive:s,onAgentIdle:r,onAgentBlocked:a,onAgentActive:o,onUserInput:i,provider:c,onRestorePreview:d,pendingPlans:u,pendingPlansLoading:p,pendingPlansError:h,onLaunchPlan:f,launchingSlug:m,launchError:g,onReorderPlans:x,isAgentBuilding:b,featureCompleteActive:y,buildActivity:v,chatEscalatedToPrototype:j,onActivityDone:_,onPrototypeLaunched:w,prototypeLaunchSignal:k}){const{stepState:S}=Qr(),{loading:N}=St(),{prompt:C}=L6(),{sessionInfo:T,loading:P}=up(),R=Uo(),{sessionDecision:I,handleContinueSession:A}=q6({sessionLoading:P,sessionInfo:T,requestAttachLive:U6(R,T)}),O=Y6(R,T);V6(s),K6({sessionLoading:P,sessionInfo:T,onRestorePreview:d}),J6((S==null?void 0:S.feature)??null);const[W,D]=l.useState(null),Y=(R==null?void 0:R.state)==="interrupted"&&W!==R.id&&!kb(R.id),H={step:(S==null?void 0:S.step)??0,hideStep:v==="prototype"||v==="chat",feature:(S==null?void 0:S.feature)??null,mode:(S==null?void 0:S.mode)??"ui",userPrompt:C,slug:(S==null?void 0:S.slug)??null,slugVisits:S==null?void 0:S.slugVisits},E=!H.hideStep&&H.step>0?{step:H.step,total:N0(H.step,H.mode).totalSteps,mode:H.mode}:null;return t.jsx($S,{workflow:E,title:U=>t.jsx(oc,{...H,inline:!0,namePrefix:U.mark,nameSuffix:U.label,note:U.note}),children:U=>t.jsx(NS,{stepIndicator:U?null:t.jsx("div",{"data-testid":"build-tab-session-header",className:"shrink-0",style:{padding:`8px ${un}px`,...Gr("bottom")},children:t.jsx(oc,{...H,inline:!0})}),sessionContent:Y&&R?t.jsx(Jt,{testId:"build-interrupted-recovery",children:t.jsx("div",{className:"mx-auto max-w-2xl px-5 py-10",children:t.jsx(Cd,{request:R,onRecovered:()=>D(R.id),onKeptForLater:()=>D(R.id)})})}):t.jsx(Jk,{awaitingPlanLaunchChoice:e,buildLaunchGateArmed:n,configLoading:N,sessionLoading:P,sessionDecision:I,sessionInfo:T,stepState:S,provider:c,onContinueSession:A,onAgentIdle:r,onAgentBlocked:a,onAgentActive:o,onUserInput:i,pendingPlans:u,pendingPlansLoading:p,pendingPlansError:h,onLaunchPlan:f,launchingSlug:m,launchError:g,onReorderPlans:x,isAgentBuilding:b,featureCompleteActive:y,buildActivity:v,chatEscalatedToPrototype:j,onActivityDone:_,onPrototypeLaunched:w,prototypeLaunchSignal:k,connectionPhase:O})})})}const vne=Object.freeze(Object.defineProperty({__proto__:null,BuildTab:n1},Symbol.toStringTag,{value:"Module"}));function s1({refreshing:e,onRefresh:n,onClose:s,minimizeMode:r=!1}){return t.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:[t.jsxs("div",{className:"flex items-center gap-2",children:[r&&t.jsx("button",{onClick:s,className:"text-[var(--text-primary)] hover:text-[#D7FF63] text-lg leading-none px-1 -ml-1",title:"Minimize results panel",children:"▾"}),t.jsx("h2",{className:"text-sm font-semibold text-[var(--text-primary)] m-0",children:"Working Session Results"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:n,disabled:e,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:e?"…":"↻"}),!r&&t.jsx("button",{onClick:s,className:"text-[var(--text-muted)] hover:text-[var(--text-secondary)] text-lg leading-none px-1",title:"Close results panel",children:"✕"})]})]})}const jne=Object.freeze(Object.defineProperty({__proto__:null,SessionResultsPanelHeader:s1},Symbol.toStringTag,{value:"Module"}));function r1({scenarios:e,selectedSlug:n,onSelect:s}){if(e.length===0)return t.jsx("div",{className:"text-xs text-[var(--text-muted)]",children:"No screens changed in this session"});const r=e.findIndex(i=>i.slug===n),a=i=>{const c=r<0?i===1?-1:0:r,d=e[(c+i+e.length)%e.length];s(d.slug,d.url)},o=r>=0?e[r]:null;return t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"sticky -top-4 z-10 -mt-4 flex min-w-0 items-center gap-2 bg-[var(--bg-deep)] pt-4 pb-2 shadow-[0_10px_10px_-10px_rgba(0,0,0,.8)]",children:[t.jsx(ic,{label:"Previous screen",glyph:"‹",onClick:()=>a(-1)}),t.jsx("span",{"data-testid":"session-results-counter",className:"shrink-0 text-xs tabular-nums text-[var(--text-secondary)]",children:o?`${r+1} of ${e.length}`:`${e.length} screens`}),t.jsx(ic,{label:"Next screen",glyph:"›",onClick:()=>a(1)}),o&&t.jsx("span",{className:"min-w-0 truncate text-xs text-[var(--text-primary)]",children:o.name})]}),t.jsx("div",{className:"flex flex-wrap items-start gap-2.5",children:e.map(i=>t.jsx(a1,{scenario:i,selected:i.slug===n,onSelect:s},i.slug))})]})}function ic({label:e,glyph:n,onClick:s}){return t.jsx("button",{type:"button","aria-label":e,title:e,onClick:s,className:"grid h-7 w-7 shrink-0 place-items-center rounded-md border border-[var(--border-default)] text-base leading-none text-[var(--text-secondary)] cursor-pointer transition-colors hover:border-[var(--accent-active)] hover:text-[var(--accent-active)]",children:t.jsx("span",{"aria-hidden":"true",children:n})})}function a1({scenario:e,selected:n,onSelect:s}){return t.jsxs("button",{type:"button","data-testid":"session-results-shot","aria-pressed":n,title:e.name,onClick:()=>s(e.slug,e.url),className:"group flex w-[150px] shrink-0 cursor-pointer flex-col gap-1 text-left",children:[t.jsx("span",{className:`flex h-[100px] w-[150px] items-center justify-center overflow-hidden rounded bg-[var(--bg-surface)] transition-colors ${n?"border-2 border-[var(--accent-active)]":"border border-[var(--border-default)] group-hover:border-[var(--text-muted)]"}`,children:e.screenshotPaths.length>0?t.jsx(kt,{screenshotPath:e.screenshotPaths[0],cacheBuster:e.screenshotCapturedAtMs??void 0,alt:e.name,loading:"lazy"}):t.jsx("span",{className:"px-2 text-center text-[10px] leading-tight text-[var(--text-muted)]",children:Z6(e)})}),t.jsx("span",{className:`w-full truncate text-[11px] ${n?"text-[var(--text-primary)]":"text-[var(--text-secondary)]"}`,children:e.name})]})}function Z6(e){var n;return e.coverageStatus==="needs-isolated-scenario"?"needs isolated scenario":e.coverageStatus==="reason"?((n=e.untestabilityReason)==null?void 0:n.kind)??"test-backed":"no screenshot yet"}const wne=Object.freeze(Object.defineProperty({__proto__:null,ArrowButton:ic,GalleryTile:a1,SessionResultsGallery:r1},Symbol.toStringTag,{value:"Module"}));function hp({fn:e,testid:n}){return t.jsxs("div",{className:"flex items-start gap-2","data-testid":n,children:[t.jsx("span",{className:"text-[10px] text-[var(--text-muted)] mt-0.5 shrink-0",children:"fn"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-xs font-medium text-[var(--text-primary)]",children:e.name}),e.description&&t.jsx("div",{className:"text-[10px] text-[var(--text-muted)] mt-0.5",children:e.description}),t.jsx("div",{className:"text-[10px] text-[var(--text-muted)] font-mono mt-0.5",children:e.filePath})]})]})}const _ne=Object.freeze(Object.defineProperty({__proto__:null,FunctionChangeRow:hp},Symbol.toStringTag,{value:"Module"}));function fp(e){return e==null?"":typeof e=="string"?e:typeof e=="object"&&typeof e.name=="string"?e.name:String(e)}function eB(e){if(e!=null&&typeof e=="object"){const{description:n}=e;if(typeof n=="string"&&n.trim()!=="")return n}}function o1({userPrompt:e,functions:n,files:s}){const[r,a]=l.useState(!1);if(!e&&n.length===0&&s.length===0)return null;const o=[n.length>0&&tm(n.length,"function"),s.length>0&&tm(s.length,"file")].filter(Boolean);return t.jsxs("div",{className:"border-t border-[var(--border-subtle)] pt-3",children:[t.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>a(i=>!i),className:"flex items-center gap-1.5 text-[11px] text-[var(--text-muted)] cursor-pointer hover:text-[var(--text-secondary)]",children:[t.jsx("span",{"aria-hidden":"true",children:r?"▾":"▸"}),t.jsxs("span",{children:["Details",o.length>0?` · ${o.join(" · ")}`:""]})]}),r&&t.jsxs("div",{className:"mt-3 flex flex-col gap-4",children:[e&&t.jsx(i1,{text:e}),n.length>0&&t.jsx(lc,{title:"Functions",children:t.jsx(l1,{functions:n})}),s.length>0&&t.jsx(lc,{title:"Files",children:t.jsx(c1,{files:s})})]})]})}function lc({title:e,children:n}){return t.jsxs("div",{children:[t.jsx("div",{className:"mb-1 px-1 text-[10px] font-semibold uppercase tracking-wide text-[var(--text-muted)]",children:e}),n]})}function tm(e,n){return`${e} ${n}${e===1?"":"s"}`}function i1({text:e}){const[n,s]=l.useState(!1),r=e.split(`
|
|
91
|
+
`)[0],a=e.includes(`
|
|
92
|
+
`)||e.length>120;return t.jsxs("div",{className:"px-1",children:[t.jsx("div",{className:"text-[10px] font-semibold text-[var(--text-muted)] uppercase tracking-wide mb-1",children:"User Request"}),n?t.jsxs("div",{children:[t.jsx(Ft,{variant:"compact",children:e}),a&&t.jsx("button",{onClick:()=>s(!1),className:"text-[#D7FF63] hover:underline text-xs mt-1",children:"Show less"})]}):t.jsxs("div",{className:"text-xs text-[var(--text-secondary)] leading-relaxed",children:[r.slice(0,120),a&&t.jsx("button",{onClick:()=>s(!0),className:"text-[#D7FF63] hover:underline ml-1 text-xs",children:"Read more..."})]})]})}function l1({functions:e}){return t.jsx("div",{className:"divide-y divide-[var(--border-subtle)]",children:e.map(n=>t.jsxs("div",{className:"px-1 py-2",children:[t.jsx(hp,{fn:n}),n.tests.length>0&&t.jsx("div",{className:"ml-5 mt-1.5 space-y-0.5",children:n.tests.map((s,r)=>t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"text-green-500 text-[10px]",children:"✓"}),t.jsx("span",{className:"text-[10px] text-[var(--text-secondary)]",children:fp(s)})]},r))}),n.testFile&&n.tests.length===0&&t.jsx("div",{className:"ml-5 mt-1 text-[10px] text-[var(--text-muted)] font-mono",children:n.testFile})]},`${n.filePath}::${n.name}`))})}function c1({files:e}){return t.jsx("div",{className:"divide-y divide-[var(--border-subtle)]",children:e.map(n=>t.jsxs("div",{className:"px-1 py-1.5 flex items-center gap-2",children:[t.jsx(vo,{status:n.status}),t.jsx("span",{className:"text-xs text-[var(--text-secondary)] font-mono truncate",children:n.path})]},n.path))})}const Sne=Object.freeze(Object.defineProperty({__proto__:null,DetailsGroup:lc,FilesList:c1,FunctionsList:l1,SessionResultsDetails:o1,UserPrompt:i1},Symbol.toStringTag,{value:"Module"}));function ir(e,n){if(e.length===0)return{selectedIndex:-1,scenario:null};if("direction"in n){const r=n.direction==="next"?1:-1,a=(n.selectedIndex+r+e.length)%e.length;return{selectedIndex:a,scenario:e[a]}}if("slug"in n){const r=e.findIndex(a=>a.slug===n.slug);return r>=0?{selectedIndex:r,scenario:e[r]}:ir(e,{defaultSelection:!0,selectedIndex:n.selectedIndex})}const s=Math.min(n.selectedIndex??0,e.length-1);return{selectedIndex:s,scenario:e[s]}}function ro(e,n){if(!n)return{headline:e,collapsed:[]};const s=[],r=[];for(const a of e)a.demonstratesNew?s.push(a):r.push(a);return{headline:s,collapsed:r}}const tB="no-isolation-harness";function d1(e){var n;return e.coverageStatus==="reason"&&((n=e.untestabilityReason)==null?void 0:n.kind)===tB}const nB="/api/editor-session-summary",sB=3e3;function u1(e=sB){const[n,s]=l.useState(null),[r,a]=l.useState(!0),[o,i]=l.useState(!1),c=l.useCallback(async()=>{i(!0);try{const d=await fetch(nB);d.ok&&s(await d.json())}catch{}i(!1),a(!1)},[]);return l.useEffect(()=>{c()},[c]),l.useEffect(()=>{if(e<=0)return;const d=window.setInterval(c,e);return()=>window.clearInterval(d)},[c,e]),{summary:n,loading:r,refreshing:o,refresh:c}}function p1({onClose:e,onSelectScenario:n,previewSlug:s=null,minimizeMode:r=!1}){var k;const{summary:a,loading:o,refreshing:i,refresh:c}=u1(),[d,u]=l.useState(0),p=l.useMemo(()=>a?[...a.application,...a.components]:[],[a]),h=l.useMemo(()=>s&&p.some(S=>S.slug===s)?s:null,[p,s]),f=h??((k=p[d])==null?void 0:k.slug);l.useEffect(()=>{if(!h)return;const S=p.findIndex(N=>N.slug===h);S>=0&&S!==d&&u(S)},[p,h,d]);const m=l.useCallback(S=>{p.length!==0&&(document.activeElement instanceof HTMLIFrameElement||WR()||(S.key==="ArrowRight"?(S.preventDefault(),u(N=>{const C=ir(p,{direction:"next",selectedIndex:N});return C.scenario&&(n==null||n(C.scenario.slug,C.scenario.url)),C.selectedIndex})):S.key==="ArrowLeft"&&(S.preventDefault(),u(N=>{const C=ir(p,{direction:"previous",selectedIndex:N});return C.scenario&&(n==null||n(C.scenario.slug,C.scenario.url)),C.selectedIndex}))))},[p,n]);l.useEffect(()=>(window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)),[m]);const g=l.useRef(!1);if(l.useEffect(()=>{if(g.current||p.length===0)return;g.current=!0;const S=ir(p,{defaultSelection:!0,selectedIndex:d});S.scenario&&(n==null||n(S.scenario.slug,S.scenario.url))},[p,n,d]),o)return t.jsx("div",{className:"flex-1 flex items-center justify-center p-8 bg-[var(--bg-deep)]",children:t.jsx("div",{className:"animate-spin w-6 h-6 border-2 border-[var(--border-default)] border-t-[#005c75] rounded-full"})});if(!a)return t.jsx("div",{className:"flex-1 flex items-center justify-center p-8 bg-[var(--bg-deep)]",children:t.jsx("div",{className:"text-sm text-[var(--text-muted)]",children:"No session data available."})});const x=a.hubDominated??!1,b=ro(a.application,x),y=ro(a.components,x),v=[...b.headline,...y.headline],j=[...b.collapsed,...y.collapsed],_=v.some(d1),w=(S,N)=>{var T,P;const C=ir(p,{slug:S,selectedIndex:d});C.selectedIndex>=0&&u(C.selectedIndex),n==null||n(((T=C.scenario)==null?void 0:T.slug)??S,((P=C.scenario)==null?void 0:P.url)??N)};return t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col bg-[var(--bg-deep)]",style:{borderTop:"2px solid #005c75"},children:[t.jsx(s1,{refreshing:i,onRefresh:c,onClose:e,minimizeMode:r}),t.jsxs("div",{className:"flex-1 overflow-auto p-4 flex flex-col gap-4",children:[v.length===0&&j.length>0?t.jsx(xb,{sectionTitle:"screens",headlineCount:0,refreshedCount:j.length}):t.jsx(r1,{scenarios:v,selectedSlug:f,onSelect:w}),_&&t.jsx("div",{className:"text-[10px] leading-snug text-[var(--text-muted)]",children:"This stack has no component isolation harness, so leaf components are verified inside the full app scenarios rather than in isolation."}),t.jsx(Mx,{count:a.generatedGlueCount??0}),t.jsx(f1,{scenarios:j,selectedSlug:f,onSelect:w}),t.jsx(o1,{userPrompt:a.userPrompt,functions:a.functions,files:a.modifiedFiles})]})]})}function h1({scenarios:e,selectedSlug:n,onSelect:s}){return t.jsx("div",{className:"overflow-x-auto",children:t.jsx("div",{className:"flex gap-2",style:{minWidth:"min-content"},children:e.map(r=>t.jsx(m1,{scenario:r,isSelected:r.slug===n,onSelect:s},r.slug))})})}function f1({scenarios:e,selectedSlug:n,onSelect:s}){const[r,a]=l.useState(!1);return e.length===0?null:t.jsxs("div",{className:"mt-3 pt-3 border-t border-[var(--border-subtle)]",children:[t.jsxs("button",{onClick:()=>a(o=>!o),className:"text-[11px] text-[var(--text-muted)] hover:text-[var(--text-secondary)] flex items-center gap-1",children:[t.jsx("span",{children:r?"▾":"▸"}),t.jsxs("span",{children:["Also refreshed (",e.length,") — impacted by hub-file changes, not demonstrating this work"]})]}),r&&t.jsx("div",{className:"mt-2",children:t.jsx(h1,{scenarios:e,selectedSlug:n,onSelect:s})})]})}function m1({scenario:e,isSelected:n,onSelect:s}){var o;const r=e.name.replace(/\s*\[.*\]\s*$/,"").trim(),a=d1(e);return t.jsxs("div",{className:"shrink-0 cursor-pointer group",onClick:()=>s==null?void 0:s(e.slug,e.url),title:e.name,children:[t.jsx("div",{className:`w-24 h-24 rounded overflow-hidden flex items-center justify-center bg-[var(--bg-surface)] transition-colors ${n?"border-2 border-[#005c75] shadow-md":"border border-[var(--border-default)] group-hover:border-[#005c75]"}`,children:e.screenshotPaths.length>0?t.jsx(kt,{screenshotPath:e.screenshotPaths[0],cacheBuster:e.screenshotCapturedAtMs??void 0,alt:e.name}):e.coverageStatus==="needs-isolated-scenario"?t.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:[t.jsx("span",{className:"text-amber-500 text-lg leading-none",children:"⚠"}),t.jsx("span",{className:"text-[8px] leading-tight text-amber-700",children:"needs isolated scenario"})]}):e.coverageStatus==="reason"?t.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center gap-1 px-1 text-center",title:e.untestabilityReason?`${e.untestabilityReason.kind}: ${e.untestabilityReason.justification}`:"Covered by a recorded untestability reason.",children:[t.jsx("span",{className:"text-[var(--text-muted)] text-lg leading-none",children:"🧪"}),t.jsx("span",{className:"text-[8px] leading-tight text-[var(--text-muted)]",children:((o=e.untestabilityReason)==null?void 0:o.kind)??"test-backed"})]}):t.jsx("div",{className:"w-full h-full flex items-center justify-center text-[var(--text-muted)] text-lg",children:"📷"})}),t.jsx("div",{className:`mt-1 text-[10px] truncate w-24 ${n?"text-[#005c75] font-medium":"text-[var(--text-secondary)] group-hover:text-[#005c75]"}`,children:r}),a&&t.jsx("div",{className:"mt-0.5 w-24 text-[9px] leading-tight text-[var(--text-muted)]",children:"Covered via app scenarios — no isolation harness"})]})}const kne=Object.freeze(Object.defineProperty({__proto__:null,CollapsedImpactedScenarios:f1,ScenarioThumbnail:m1,ScenarioThumbnailStrip:h1,SessionResultsPanel:p1},Symbol.toStringTag,{value:"Module"})),g1=62;function x1({onExpand:e}){const{summary:n}=u1(),s=(n==null?void 0:n.hubDominated)??!1,r=ro((n==null?void 0:n.application)??[],s),a=ro((n==null?void 0:n.components)??[],s),o=[...r.headline,...a.headline],i=o.length,c=r.collapsed.length+a.collapsed.length,d=o.filter(u=>u.screenshotPaths.length>0);return t.jsxs("button",{type:"button",onClick:e,onWheel:u=>{u.deltaY>0&&e()},title:"Expand working session results",className:"group shrink-0 w-full flex flex-col gap-2.5 px-4 py-3 text-left bg-[var(--bg-card)] hover:bg-[var(--bg-input)] transition-colors",style:{borderTop:"2px solid #005c75"},children:[t.jsxs("span",{className:"flex w-full items-center gap-2",children:[t.jsx("span",{"data-testid":"minimized-results-chevron",className:"text-[var(--text-primary)] group-hover:text-[#D7FF63] text-lg leading-none px-1 -ml-1 transition-colors",children:"▴"}),t.jsx("span",{className:"text-[13px] font-semibold text-[var(--text-primary)]",children:"Working Session Results"}),t.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:[i," new",c>0?` · ${c} impacted`:""]}),t.jsx("span",{"data-testid":"minimized-results-open",className:"ml-auto text-xs font-medium px-2.5 py-1 rounded border border-[var(--border-default)] text-[var(--text-primary)] group-hover:border-[#D7FF63] group-hover:text-[#D7FF63] transition-colors",children:"View results"})]}),d.length>0&&t.jsx("span",{"data-testid":"minimized-results-peek",onScroll:e,className:"flex w-full flex-wrap items-start gap-2.5 overflow-x-hidden overflow-y-auto",style:{maxHeight:g1},children:d.map(u=>t.jsxs("span",{title:u.name,className:"flex w-[150px] shrink-0 flex-col gap-1",children:[t.jsx("span",{className:"flex h-[100px] w-[150px] items-center justify-center overflow-hidden rounded border border-[var(--border-default)] bg-[var(--bg-surface)]",children:t.jsx(kt,{screenshotPath:u.screenshotPaths[0],cacheBuster:u.screenshotCapturedAtMs??void 0,alt:u.name})}),t.jsx("span",{className:"w-full truncate text-[11px] text-[var(--text-secondary)]",children:u.name})]},u.slug))})]})}const Nne=Object.freeze(Object.defineProperty({__proto__:null,MINIMIZED_RESULTS_PEEK_HEIGHT:g1,MinimizedSessionResults:x1},Symbol.toStringTag,{value:"Module"}));function rB(e,n){return(e==null?void 0:e.mode)!=="ui"?!1:(e==null?void 0:e.slug)==="feature-complete"||!!n}const aB=new Set(["ui-present","backend-present"]);function b1(e){return!!(e!=null&&e.slug)&&aB.has(e.slug)}function oB({stepState:e,resultsShown:n,featureCompleteActive:s,userExpanded:r}){return s?"hidden":b1(e)?(e==null?void 0:e.mode)==="ui"?"full":"hidden":rB(e,n)?r?"full":"minimized":"hidden"}function y1({awaitingPlanLaunchChoice:e,buildLaunchGateArmed:n,buildActivated:s,activeTab:r,onSelectScenario:a,previewSlug:o=null,showResultsCommandKey:i,hideResultsCommandKey:c,onAgentIdle:d,onAgentBlocked:u,onAgentActive:p,onUserInput:h,provider:f,onRestorePreview:m,pendingPlans:g,pendingPlansLoading:x,pendingPlansError:b,onLaunchPlan:y,launchingSlug:v,launchError:j,onReorderPlans:_,isAgentBuilding:w,featureCompleteActive:k,buildActivity:S,chatEscalatedToPrototype:N,onActivityDone:C,onPrototypeLaunched:T,prototypeLaunchSignal:P}){const{stepState:R}=Qr(),{sessionInfo:I}=up({pollIntervalMs:15e3}),A=Uo(),O=y0(A),[W,D]=l.useState(!1),[Y,H]=l.useState(!1),[E,U]=l.useState(0),M=(I==null?void 0:I.resultsShown)??!1;l.useEffect(()=>{M||(H(!1),D(!1))},[M]),l.useEffect(()=>{i&&(H(!1),D(!0),U(ie=>ie+1))},[i]),l.useEffect(()=>{c&&D(!1)},[c]);const J=b1(R),ne=oB({stepState:R,resultsShown:M,featureCompleteActive:k,userExpanded:W}),oe=J&&Y?"hidden":ne,ae=l.useCallback(()=>{J?H(!0):D(!1)},[J]),G=l.useCallback(()=>{D(!0),U(ie=>ie+1)},[]);return s?t.jsx(CS,{activeTab:r,resultsMode:oe,badgeGutter:S!=="prototype"&&S!=="chat",launchBanner:A&&jd(A.state)?t.jsx(wd,{state:A.state,cause:A.failureReason??null,...O}):null,buildTab:t.jsx(n1,{awaitingPlanLaunchChoice:e,buildLaunchGateArmed:n,isActive:r==="build",onAgentIdle:d,onAgentBlocked:u,onAgentActive:p,onUserInput:h,provider:f,onRestorePreview:m,pendingPlans:g,pendingPlansLoading:x,pendingPlansError:b,onLaunchPlan:y,launchingSlug:v,launchError:j,onReorderPlans:_,isAgentBuilding:w,featureCompleteActive:k,buildActivity:S,chatEscalatedToPrototype:N,onActivityDone:C,onPrototypeLaunched:T,prototypeLaunchSignal:P}),resultsPanel:t.jsx(p1,{onClose:ae,onSelectScenario:a,previewSlug:o,minimizeMode:!J},E),minimizedResults:t.jsx(x1,{onExpand:G})}):null}const Cne=Object.freeze(Object.defineProperty({__proto__:null,BuildTabPane:y1},Symbol.toStringTag,{value:"Module"}));function v1({name:e,size:n=13}){const s={width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"},r=e.toLowerCase(),a=r.includes("landscape"),o=r.includes("iphone"),i=r.includes("ipad");return r.includes("laptop")?t.jsxs("svg",{...s,children:[t.jsx("path",{d:"M4 6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8H4V6z"}),t.jsx("path",{d:"M2 18h20"})]}):r.includes("desktop")||r.includes("monitor")?t.jsxs("svg",{...s,children:[t.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),t.jsx("path",{d:"M8 21h8M12 17v4"})]}):r.includes("tablet")||r.includes("ipad")?a?t.jsxs("svg",{...s,children:[t.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2"}),i?t.jsx("path",{d:"M5 12h.01"}):t.jsx("path",{d:"M18 12h.01"})]}):t.jsxs("svg",{...s,children:[t.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2"}),i?t.jsx("path",{d:"M12 5h.01"}):t.jsx("path",{d:"M12 18h.01"})]}):r.includes("phone")||r.includes("iphone")||r.includes("mobile")?a?t.jsxs("svg",{...s,children:[t.jsx("rect",{x:"2",y:"7",width:"20",height:"10",rx:o?3:2}),o?t.jsx("path",{d:"M5 9.5v5"}):t.jsx("path",{d:"M18 12h.01"})]}):t.jsxs("svg",{...s,children:[t.jsx("rect",{x:"7",y:"2",width:"10",height:"20",rx:o?3:2}),o?t.jsx("path",{d:"M10 4.5h4"}):t.jsx("path",{d:"M12 18h.01"})]}):t.jsx("span",{className:"text-xs",children:e})}const Tne=Object.freeze(Object.defineProperty({__proto__:null,DeviceIcon:v1},Symbol.toStringTag,{value:"Module"})),mp=ms(),gp=ms(),iB=mp.get,lB=mp.set,cB=mp.subscribe,dB=gp.get,uB=gp.set,pB=gp.subscribe,xp=ms(),bp=ms(),hB=xp.get,nm=xp.set,fB=xp.subscribe,mB=bp.get,sm=bp.set,gB=bp.subscribe;function xr({testId:e="nav-build-dot-active",ariaLabel:n="Build in progress"}={}){return t.jsx("span",{role:"img","data-testid":e,"aria-label":n,className:"mr-1.5 inline-flex items-center text-[var(--working)]",children:t.jsx(Ht,{size:10})})}const Pne=Object.freeze(Object.defineProperty({__proto__:null,BuildSpinner:xr},Symbol.toStringTag,{value:"Module"}));function j1({size:e=16}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M12 8v3"}),t.jsx("path",{d:"M12 14v.01"}),t.jsx("path",{d:"M18 4a3 3 0 0 1 3 3v8a3 3 0 0 1-3 3h-5l-5 3v-3H6a3 3 0 0 1-3-3V7a3 3 0 0 1 3-3z"})]})}const One=Object.freeze(Object.defineProperty({__proto__:null,FeedbackIcon:j1},Symbol.toStringTag,{value:"Module"}));function w1({size:e=16}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}const Rne=Object.freeze(Object.defineProperty({__proto__:null,GearIcon:w1},Symbol.toStringTag,{value:"Module"}));function _1({onNavigateToBuild:e,onDismiss:n,providerLabel:s}){return l.useEffect(()=>(pe("banner-mounted",{}),()=>{pe("banner-unmounted",{})}),[]),t.jsx("div",{className:"px-4 py-1.5 flex items-center justify-center",children:t.jsxs("div",{className:"pointer-events-auto flex items-center gap-2 px-3 py-1.5 rounded-lg border border-[#FF8B43]/60 bg-[#2a1500] shadow-lg shrink-0",children:[t.jsxs("button",{type:"button",onClick:e,className:"flex items-center gap-2 cursor-pointer",children:[t.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-[#FF8B43] shrink-0"}),t.jsxs("span",{className:"text-sm text-[#FF8B43]",children:[s," is ",za,"."," ",t.jsx("span",{className:"text-[#FF8B43] font-medium underline",children:"Build."})]})]}),t.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),n()},className:"p-0.5 text-[#FF8B43]/60 hover:text-[#FF8B43] transition-colors cursor-pointer",title:"Dismiss",children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",children:t.jsx("path",{d:"M3 3l8 8M11 3l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})})}const Ene=Object.freeze(Object.defineProperty({__proto__:null,IdleBanner:_1},Symbol.toStringTag,{value:"Module"}));function S1(e){return e.sound!=="off"}function xB(){typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()}function k1({settings:e,onChange:n,needsYou:s=!1,onGoToAgent:r,agentName:a,providerLabel:o}){const[i,c]=l.useState(!1),d=l.useRef(null),u=S1(e);l.useEffect(()=>{if(!i)return;const h=f=>{d.current&&!d.current.contains(f.target)&&c(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[i]);const p=u?s?`Notifications: ${o} is ${za}`:"Notifications":"Turn on notification sound";return t.jsxs("div",{className:"relative",ref:d,children:[t.jsxs("button",{type:"button","aria-label":p,"aria-pressed":u,"data-testid":"nav-notifications",onClick:()=>{if(xB(),!u){n({...e,sound:ar.sound});return}c(h=>!h)},className:`relative p-1.5 rounded-md transition-colors cursor-pointer inline-flex items-center hover:text-white ${u?"text-[#8E8E8E]":"text-[#5A5A5A]"}`,children:[t.jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M10 5a2 2 0 1 1 4 0a7 7 0 0 1 4 6v3a4 4 0 0 0 2 3H4a4 4 0 0 0 2-3v-3a7 7 0 0 1 4-6"}),t.jsx("path",{d:"M9 17v1a3 3 0 0 0 6 0v-1"}),!u&&t.jsx("path",{"data-testid":"nav-notifications-slash",d:"M3 3l18 18"})]}),s&&t.jsx("span",{"data-testid":"nav-notifications-dot","aria-hidden":"true",className:"absolute top-1 right-1 h-2 w-2 rounded-full ring-2 ring-[var(--bg-deep)]",style:{background:it}})]}),i&&t.jsxs("div",{className:"absolute top-full right-0 mt-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:[s&&t.jsxs("button",{type:"button","data-testid":"nav-notifications-waiting",onClick:()=>{c(!1),r==null||r()},className:"flex items-center gap-2 rounded-md px-2 py-1.5 text-left text-[12px] cursor-pointer transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-primary)",border:`1px solid ${it}55`},children:[t.jsx("span",{"aria-hidden":"true",className:"h-2 w-2 shrink-0 rounded-full",style:{background:it}}),t.jsxs("span",{className:"flex-1",children:[o," is ",za]}),t.jsx("span",{"aria-hidden":"true",style:{color:"var(--text-muted)"},children:"→"})]}),t.jsx(l0,{settings:e,onChange:n,providerLabel:o,soundAsSubmenu:!0}),t.jsx("div",{className:"pt-2",style:{borderTop:"1px solid var(--border-default)"},children:t.jsx(p0,{agentName:a})})]})]})}const Ane=Object.freeze(Object.defineProperty({__proto__:null,NotificationBell:k1,notificationsOn:S1},Symbol.toStringTag,{value:"Module"})),fa=it,bB=[{key:"home",label:"Home"},{key:"chat",label:"Chat"},{key:"plan",label:"Plan"},{key:"build",label:"Build"},{key:"history",label:"History"}];function js(){if(typeof document>"u")return;const e=document.activeElement;e instanceof HTMLElement&&e.blur()}function N1({activeTab:e,onTabChange:n,onSendTranscript:s,buildIdle:r=!1,agentBlocked:a=!1,isAgentBuilding:o=!1,planIdle:i=!1,planActive:c=!1,bannerVisible:d=!1,onDismissIdleBanner:u,buildDisabled:p=!1,showLogo:h=!0,projectTitle:f=null,notifSettings:m,onNotifSettingsChange:g,agentName:x,providerLabel:b}){const y=d&&e!=="build",v=l.useSyncExternalStore(IS,MS),j=l.useSyncExternalStore(DS,ql),_=r&&a&&!j,w=r&&!a&&!j||v&&!_,k=(o||j)&&!w&&!_,S=w||_,N=k?"green":_?"amber-pulse":w?"orange":"none",C=l.useRef(N);l.useEffect(()=>{C.current!==N&&(pe("build-tab-dot-change",{from:C.current,to:N}),C.current=N)},[N]);const T=l.useSyncExternalStore(cB,iB),P=l.useSyncExternalStore(pB,dB),R=l.useSyncExternalStore(fB,hB),I=l.useSyncExternalStore(gB,mB),A=T||i&&!P,O=(c||P)&&!A,W=O?"green":A?"orange":"none",D=l.useRef(W);return l.useEffect(()=>{D.current!==W&&(pe("plan-tab-dot-change",{from:D.current,to:W}),D.current=W)},[W]),t.jsxs("div",{className:"relative shrink-0",children:[t.jsxs("div",{className:"@container h-12 flex items-center px-[22px] gap-4 @max-[440px]:px-3 @max-[440px]:gap-2",style:Gr("bottom"),children:[t.jsx("div",{className:"flex-1 basis-0 flex items-center min-w-0",children:h&&t.jsxs(Ns,{href:cn("home"),"data-nav-tab":"true","data-testid":"nav-home","aria-label":f?`${f}: Home`:"Home","aria-current":e==="home"?"page":void 0,onNavigate:()=>{n("home"),js()},className:"flex items-center gap-2.5 min-w-0 cursor-pointer text-white hover:opacity-80 transition-opacity",children:[t.jsx(cs,{markOnly:!0,className:"h-5 text-white shrink-0"}),f&&t.jsx("span",{"data-testid":"nav-project-title",className:"text-sm truncate @max-[560px]:hidden",style:{color:e==="home"?"var(--text-primary)":"var(--text-secondary)"},children:f})]})}),t.jsx("div",{className:"flex items-center gap-1 shrink-0",children:bB.map(Y=>Y.key==="build"&&p?t.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:()=>{n("home"),js()},className:"px-2.5 @max-[520px]:px-1.5 py-2.5 text-sm text-[#5A5A5A] cursor-not-allowed font-light whitespace-nowrap",children:Y.label},Y.key):t.jsxs(Ns,{href:cn(Y.key),"data-nav-tab":"true",onNavigate:()=>{n(Y.key),js(),Y.key==="build"&&_t()},className:`px-2.5 @max-[520px]:px-1.5 @max-[440px]:px-1 @max-[320px]:px-0.5 py-2.5 text-sm transition-colors cursor-pointer inline-flex items-center whitespace-nowrap ${Y.key==="home"&&h?"@max-[400px]:hidden ":""}${e===Y.key?"text-white font-medium":"text-[#8E8E8E] hover:text-white font-light"}`,children:[Y.key==="build"&&k&&t.jsx(xr,{}),Y.key==="build"&&_&&t.jsx(sr,{color:fa,testId:"nav-build-dot-blocked",title:"Waiting on you — the turn stopped on a prompt and won't continue until you answer",pulse:!0}),Y.key==="build"&&w&&t.jsx(sr,{color:fa,testId:"nav-build-dot-idle",pulse:!0}),Y.key==="plan"&&O&&t.jsx(xr,{testId:"nav-plan-dot-active",ariaLabel:"Planning in progress"}),Y.key==="plan"&&A&&t.jsx(sr,{color:fa,testId:"nav-plan-dot-idle",pulse:!0}),Y.key==="chat"&&R&&!I&&t.jsx(xr,{testId:"nav-chat-dot-active",ariaLabel:"Chat in progress"}),Y.key==="chat"&&I&&t.jsx(sr,{color:fa,testId:"nav-chat-dot-idle",pulse:!0}),Y.label]},Y.key))}),t.jsxs("div",{className:"flex-1 basis-0 flex items-center justify-end gap-1",children:[t.jsx(jg,{href:cn("settings"),onNavigate:()=>{n("settings"),js()}}),m&&g&&t.jsx(k1,{settings:m,onChange:g,needsYou:S||A,onGoToAgent:()=>{n(S?"build":"plan"),js()},agentName:x,providerLabel:b}),t.jsxs("button",{type:"button",onClick:s,"aria-label":"Send feedback","data-testid":"nav-send-feedback",className:"group relative p-1.5 rounded-md transition-colors cursor-pointer text-[#8E8E8E] hover:text-white focus-visible:text-white inline-flex items-center @max-[400px]:hidden",children:[t.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute right-full top-1/2 -translate-y-1/2 mr-1 rounded-md bg-black px-2 py-1 text-xs whitespace-nowrap text-white opacity-0 transition-opacity duration-150 group-hover:opacity-100 group-focus-visible:opacity-100",children:"Send feedback"}),t.jsx(j1,{})]}),t.jsx(Ns,{href:cn("settings"),"data-nav-tab":"true",onNavigate:()=>{n("settings"),js()},className:`p-1.5 rounded-md transition-colors cursor-pointer inline-flex items-center ${e==="settings"?"text-white":"text-[#8E8E8E] hover:text-white"}`,title:"Settings",children:t.jsx(w1,{})})]})]}),y&&t.jsx("div",{"data-testid":"idle-banner-float",className:"pointer-events-none absolute left-0 right-0 top-full z-40",children:t.jsx(_1,{onNavigateToBuild:()=>n("build"),onDismiss:u??(()=>{}),providerLabel:b})})]})}const Mne=Object.freeze(Object.defineProperty({__proto__:null,EditorNavBar:N1},Symbol.toStringTag,{value:"Module"}));function C1({projectTitle:e}){const n=typeof e=="string"&&e.trim().length>0;return t.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:[t.jsx(cs,{className:"h-5 text-white shrink-0"}),n&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-[#8E8E8E] text-sm shrink-0",children:"/"}),t.jsx("span",{className:"text-white text-sm truncate max-w-[60%]",children:e})]})]})}const Ine=Object.freeze(Object.defineProperty({__proto__:null,DesktopTitleBar:C1},Symbol.toStringTag,{value:"Module"}));function yB(){const[e,n]=l.useState(!1),[s,r]=l.useState(""),[a,o]=l.useState(null),i=l.useCallback(()=>n(u=>!u),[]),c=l.useCallback(()=>n(!1),[]),d=l.useCallback(u=>(o(u.adHoc?u.label:null),n(!1),r(u.range),u.range),[]);return{open:e,seed:s,lastAdHocRange:a,toggle:i,close:c,accept:d}}function vB(e,n=25){const[s,r]=l.useState([]);return l.useEffect(()=>{if(!e||s.length>0)return;let a=!1;return(async()=>{try{const o=await fetch(`/api/history?limit=${n}`);if(!o.ok)return;const i=await o.json();if(a)return;r((i.entries??[]).map(c=>c.commit).filter(Boolean))}catch{}})(),()=>{a=!0}},[e,s.length,n]),s}function yp({target:e,onStored:n,onClose:s}){return t.jsx("div",{"data-testid":"app-service-credential-modal",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onMouseDown:r=>{r.target===r.currentTarget&&s()},children:t.jsxs("div",{className:"w-[28rem] max-w-[90vw] rounded-lg border border-[#3A3A3A] bg-[#161616] p-5 space-y-3",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("h2",{className:"text-base font-semibold text-white",children:["Add your ",e.serviceName," API key"]}),t.jsx("button",{"data-testid":"app-service-credential-close",onClick:s,className:"text-[#8E8E8E] hover:text-white cursor-pointer","aria-label":"Close",children:"✕"})]}),t.jsx(_d,{envVar:e.envVar}),e.docsUrl?t.jsx(Sd,{href:e.docsUrl}):null,t.jsx(kd,{target:e,onStored:n})]})})}const Dne=Object.freeze(Object.defineProperty({__proto__:null,AppServiceCredentialModal:yp},Symbol.toStringTag,{value:"Module"}));function jB(e,n){for(const s of e.filesByDirectory)for(const r of s.files)if(r.filePath===n)return r;return null}function T1(e){return e>=80?"#16a34a":e>=50?"#eab308":"#dc2626"}function Zr({coverage:e}){const n=Math.max(0,Math.min(100,e.percent)),s=T1(n);return t.jsxs("div",{className:"flex items-center gap-2 min-w-[140px]","data-testid":"coverage-bar",children:[t.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-gray-200 overflow-hidden",children:t.jsx("div",{"data-testid":"coverage-bar-fill",className:"h-full rounded-full",style:{width:`${n}%`,backgroundColor:s}})}),t.jsxs("span",{className:"text-xs font-mono tabular-nums",style:{color:s},children:[Math.round(n),"%"]})]})}const Lne=Object.freeze(Object.defineProperty({__proto__:null,CoverageBar:Zr},Symbol.toStringTag,{value:"Module"}));function P1({file:e,onSelectFile:n}){return t.jsxs("li",{className:"flex items-center gap-3 py-2","data-testid":"coverage-details-directory-file-row",children:[t.jsx("button",{type:"button",onClick:()=>n(e),className:"flex-1 min-w-0 text-left text-xs text-gray-700 truncate hover:underline cursor-pointer",children:e.filePath}),t.jsx(Zr,{coverage:e.coverage})]})}const Fne=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsDirectoryFileRow:P1},Symbol.toStringTag,{value:"Module"}));function O1({group:e,onSelectFile:n}){return t.jsxs("details",{"data-testid":"coverage-details-directory-group",children:[t.jsxs("summary",{className:"cursor-pointer text-sm font-medium text-gray-800",children:[e.directory||"(root)"," ·"," ",t.jsxs("span",{className:"text-gray-500",children:[e.files.length," file",e.files.length===1?"":"s"]})]}),t.jsx("ul",{className:"divide-y divide-gray-100 mt-2",children:e.files.map(s=>t.jsx(P1,{file:s,onSelectFile:n},s.filePath))})]})}const $ne=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsDirectoryGroup:O1},Symbol.toStringTag,{value:"Module"}));function R1({directories:e,onSelectFile:n}){return e.length===0?null:t.jsxs("section",{className:"bg-white border border-gray-200 rounded-lg p-4","data-testid":"coverage-details-directories-section",children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-900 m-0 mb-2",children:"By directory"}),t.jsx("div",{className:"flex flex-col gap-3",children:e.map(s=>t.jsx(O1,{group:s,onSelectFile:n},s.directory||"(root)"))})]})}const zne=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsDirectoriesSection:R1},Symbol.toStringTag,{value:"Module"}));function E1({entry:e,onSelectFile:n}){return t.jsxs("li",{className:"flex items-center gap-3 py-2","data-testid":"coverage-details-entry-row",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("button",{type:"button",onClick:()=>n(e.filePath),className:"text-sm font-medium text-gray-900 truncate text-left hover:underline cursor-pointer",children:e.name}),t.jsx("div",{className:"text-xs text-gray-500 truncate",children:e.filePath}),e.linkedTests.length>0&&t.jsxs("div",{className:"text-xs text-gray-400 truncate",children:[e.linkedTests.length," linked test",e.linkedTests.length===1?"":"s"]})]}),t.jsx(Zr,{coverage:{percent:e.percent,hitLines:e.hitLines,totalLines:e.totalLines}})]})}const Bne=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsEntryRow:E1},Symbol.toStringTag,{value:"Module"}));function A1({entries:e,onSelectFile:n}){return t.jsxs("section",{className:"bg-white border border-gray-200 rounded-lg p-4","data-testid":"coverage-details-entries-section",children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-900 m-0 mb-2",children:"By glossary entry"}),e.length===0?t.jsx("p",{className:"text-xs text-gray-500","data-testid":"coverage-details-entries-empty",children:"No glossary entries have coverage data yet."}):t.jsx("ul",{className:"divide-y divide-gray-100",children:e.map(s=>t.jsx(E1,{entry:s,onSelectFile:n},`${s.filePath}::${s.name}`))})]})}const Wne=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsEntriesSection:A1},Symbol.toStringTag,{value:"Module"}));function M1({file:e}){return t.jsxs("li",{className:"flex items-center gap-3 py-2","data-testid":"orphaned-file-row",children:[t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("div",{className:"text-xs text-gray-500 truncate",children:e.filePath})}),t.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"}),t.jsx(Zr,{coverage:e.coverage})]})}const Hne=Object.freeze(Object.defineProperty({__proto__:null,OrphanedFileRow:M1},Symbol.toStringTag,{value:"Module"}));function I1({files:e,onSelectFile:n}){return e.length===0?null:t.jsxs("section",{className:"bg-white border border-gray-200 rounded-lg p-4","data-testid":"coverage-details-orphaned-section",children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-900 m-0 mb-2",children:"Orphaned files"}),t.jsxs("div",{className:"text-xs text-gray-500 mb-2",children:[e.length," file",e.length===1?"":"s"," with coverage but no glossary entry."]}),t.jsx("ul",{className:"divide-y divide-gray-100",children:e.map(s=>t.jsx("div",{onClick:()=>n(s.filePath),role:"button",tabIndex:0,className:"cursor-pointer",onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),n(s.filePath))},children:t.jsx(M1,{file:s})},s.filePath))})]})}const qne=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsOrphanedSection:I1},Symbol.toStringTag,{value:"Module"}));function D1({line:e,hits:n}){const s=n>0;return t.jsxs("li",{className:"flex items-center gap-3 py-1 font-mono text-xs","data-testid":s?"coverage-line-hit":"coverage-line-miss",children:[t.jsx("span",{className:"w-12 text-right text-gray-400",children:e}),t.jsx("span",{className:s?"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:s?`×${n}`:"miss"})]})}const Une=Object.freeze(Object.defineProperty({__proto__:null,CoverageLineRow:D1},Symbol.toStringTag,{value:"Module"}));function L1({file:e,onBack:n}){const s=Object.entries(e.lines).map(([r,a])=>({line:Number(r),hits:a})).sort((r,a)=>r.line-a.line);return t.jsxs("div",{"data-testid":"coverage-file-drilldown",className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("button",{type:"button",onClick:n,className:"text-xs font-medium text-[var(--accent-active)] hover:underline cursor-pointer","data-testid":"coverage-file-drilldown-back",children:"← Back"}),t.jsx("div",{className:"text-sm font-medium text-gray-900 truncate mt-1",children:e.filePath})]}),t.jsx(Zr,{coverage:e.coverage})]}),s.length===0?t.jsx("p",{className:"text-xs text-gray-500",children:"No instrumented lines in this file."}):t.jsx("ul",{className:"divide-y divide-gray-100 max-h-[50vh] overflow-y-auto","data-testid":"coverage-file-drilldown-lines",children:s.map(({line:r,hits:a})=>t.jsx(D1,{line:r,hits:a},r))})]})}const Yne=Object.freeze(Object.defineProperty({__proto__:null,CoverageFileDrilldown:L1},Symbol.toStringTag,{value:"Module"}));function F1({title:e,aggregate:n,aggregateTestId:s}){return t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h2",{className:"text-sm font-semibold text-gray-900 m-0",children:e}),n&&n.totalLines>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"text-xs text-gray-500",children:[n.hitLines,"/",n.totalLines," lines"]}),t.jsxs("span",{className:"text-xs font-semibold",style:{color:T1(n.percent)},"data-testid":s,children:[Math.round(n.percent),"% overall"]})]})]})}const Gne=Object.freeze(Object.defineProperty({__proto__:null,CoverageSectionHeader:F1},Symbol.toStringTag,{value:"Module"}));function $1({warnings:e}){return e.length===0?null:t.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-4","data-testid":"coverage-warnings-banner",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-amber-600 text-lg leading-none mt-0.5","aria-hidden":"true",children:"!"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsx("h3",{className:"text-sm font-semibold text-amber-800 m-0",children:"Coverage Warnings"}),t.jsx(ct,{variant:"subtle",text:e.join(`
|
|
93
|
+
`),label:"Copy",className:"shrink-0 px-2 py-1 text-xs font-medium rounded border border-amber-300 text-amber-800 hover:bg-amber-100 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"})]}),t.jsx("ul",{className:"mt-1 space-y-1 text-sm text-amber-700 list-none p-0 m-0",children:e.map((n,s)=>t.jsx("li",{className:"break-words",children:n},s))})]})]})})}const Vne=Object.freeze(Object.defineProperty({__proto__:null,CoverageWarningsBanner:$1},Symbol.toStringTag,{value:"Module"}));function z1({onClose:e,fetchDetails:n=wB,initialData:s}){const[r,a]=l.useState(s??null),[o,i]=l.useState(null),[c,d]=l.useState(null);l.useEffect(()=>{if(s)return;let h=!1;return n().then(f=>{h||a(f)}).catch(f=>{h||i(f instanceof Error?f.message:String(f))}),()=>{h=!0}},[n,s]);const u=l.useCallback(h=>{h.key==="Escape"&&(h.preventDefault(),c?d(null):e())},[e,c]);l.useEffect(()=>(window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)),[u]);const p=h=>{if(!r)return;const f=jB(r,h);f&&d(f)};return t.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:e,children:t.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:h=>h.stopPropagation(),children:[t.jsxs("div",{className:"flex items-start justify-between gap-3 mb-4",children:[t.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] m-0",children:"Project coverage"}),t.jsx("button",{type:"button",onClick:e,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&&t.jsx(tt,{testId:"coverage-details-modal-error",text:`Failed to load coverage details: ${o}`,className:"text-sm text-red-700"}),!r&&!o&&t.jsx("p",{className:"text-sm text-[var(--text-muted)]","data-testid":"coverage-details-modal-loading",children:"Loading coverage details…"}),r&&c&&t.jsx(L1,{file:c,onBack:()=>d(null)}),r&&!c&&t.jsxs("div",{className:"flex flex-col gap-6",children:[t.jsx(F1,{title:"Overall",aggregate:r.projectWide,aggregateTestId:"coverage-details-modal-aggregate"}),r.coverageWarnings.length>0&&t.jsx($1,{warnings:r.coverageWarnings}),t.jsx(A1,{entries:r.entries,onSelectFile:p}),t.jsx(I1,{files:r.orphanedFiles,onSelectFile:p}),t.jsx(R1,{directories:r.filesByDirectory,onSelectFile:d})]})]})})}function wB(){return fetch("/api/coverage/details").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()})}const Kne=Object.freeze(Object.defineProperty({__proto__:null,CoverageDetailsModal:z1},Symbol.toStringTag,{value:"Module"}));function _B({launcherUrl:e,projectCount:n=0,fallback:s}){const[r,a]=l.useState(!1),o=l.useCallback(async()=>{if(e){window.location.href=e;return}if(!r){a(!0);try{const c=await fetch("/api/launcher/ensure",{method:"POST"}),d=await c.json().catch(()=>({}));if(c.ok&&typeof d.url=="string"){window.location.href=d.url;return}a(!1)}catch{a(!1)}}},[e,r]);return{goBack:!!e||n>=2?()=>{o()}:s,busy:r}}const cc=["#ef9f27","#85b7eb","#8b85ff","#ef6f6f","#9bd35a","#b48ead"];function SB(e){const n=e.split(/[\s_\-./]+/).map(s=>{var r;return(r=s.match(/[\p{L}\p{N}]/u))==null?void 0:r[0]}).filter(s=>!!s);return n.length===0?"?":n.slice(0,2).join("").toUpperCase()}function kB(e){let n=5381;for(const s of e.trim().toLowerCase())n=(n*33^s.codePointAt(0))>>>0;return cc[n%cc.length]}const NB=256;function CB(e,n,s){const r=Math.min(1,s/Math.max(e,n));return{width:Math.max(1,Math.round(e*r)),height:Math.max(1,Math.round(n*r))}}async function TB(e){if(typeof createImageBitmap!="function"||typeof document>"u")return e;try{const n=await createImageBitmap(e),{width:s,height:r}=CB(n.width,n.height,NB);if(s===n.width&&r===n.height&&e.size<256*1024)return n.close(),e;const a=document.createElement("canvas");a.width=s,a.height=r;const o=a.getContext("2d");return o?(o.drawImage(n,0,0,s,r),n.close(),await new Promise(c=>a.toBlob(c,"image/png"))??e):e}catch{return e}}const rm={version:0};async function PB(e){if(e.status===413)return"That image is too large. Try a smaller one.";try{return(await e.json()).error??`Request failed (${e.status})`}catch{return`Request failed (${e.status})`}}function OB(){const[e,n]=l.useState(rm),[s,r]=l.useState(null);l.useEffect(()=>{let d=!1;return mu("/api/project-icon").then(u=>u.ok?u.json():rm).then(u=>{d||n(u)}).catch(()=>{}),()=>{d=!0}},[]);const a=l.useCallback(async d=>{r(null);try{const u=await d;return u.ok?(n(await u.json()),!0):(r(await PB(u)),!1)}catch{return r("Couldn't reach the editor."),!1}},[]),o=l.useCallback(d=>a(fetch("/api/project-icon",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({color:d})})),[a]),i=l.useCallback(async d=>{const u=await TB(d);return a(fetch("/api/project-icon/image",{method:"PUT",headers:{"Content-Type":u.type||d.type},body:u}))},[a]),c=l.useCallback(()=>a(fetch("/api/project-icon",{method:"DELETE"})),[a]);return{icon:e,error:s,setColor:o,uploadImage:i,reset:c}}const RB="image/png,image/jpeg,image/webp,image/gif";function B1({name:e}){const{icon:n,error:s,setColor:r,uploadImage:a,reset:o}=OB(),[i,c]=l.useState(!1),d=l.useRef(null),u=l.useRef(null);l.useEffect(()=>{if(!i)return;const f=g=>{var x;(x=d.current)!=null&&x.contains(g.target)||c(!1)},m=g=>{g.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",f),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",m)}},[i]);const p=n.color??kB(e),h=!!n.color||!!n.image;return t.jsxs("div",{ref:d,className:"project-avatar",children:[t.jsxs("button",{type:"button",className:"pa-trigger","aria-label":"Edit project icon","aria-expanded":i,onClick:()=>c(f=>!f),children:[n.image?t.jsx("span",{"data-testid":"project-avatar",className:"pa-tile pa-image",children:t.jsx("img",{src:`/api/project-icon/image?v=${n.version}`,alt:`${e} logo`})}):t.jsx("span",{"data-testid":"project-avatar",className:"pa-tile",style:{background:p},children:SB(e)}),t.jsx("span",{className:"pa-edit","aria-hidden":"true",children:t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M4 20h4L18.5 9.5a2.8 2.8 0 0 0-4-4L4 16v4M13.5 6.5l4 4"})})})]}),i&&t.jsxs("div",{className:"pa-menu",role:"menu",children:[t.jsx("button",{type:"button",className:"pa-item",onClick:()=>{var f;return(f=u.current)==null?void 0:f.click()},children:"Upload logo"}),t.jsx("input",{ref:u,type:"file",accept:RB,hidden:!0,"data-testid":"project-avatar-file",onChange:f=>{var g;const m=(g=f.target.files)==null?void 0:g[0];f.target.value="",m&&a(m).then(x=>x&&c(!1))}}),t.jsx("div",{className:"pa-label",children:"Color"}),t.jsx("div",{className:"pa-swatches",children:cc.map(f=>t.jsx("button",{type:"button",className:"pa-swatch","aria-label":`Use color ${f}`,"aria-pressed":!n.image&&p===f,style:{background:f},onClick:()=>void r(f)},f))}),n.image&&t.jsx("div",{className:"pa-note",children:"A color shows when there is no logo."}),h&&t.jsx("button",{type:"button",className:"pa-item pa-muted",onClick:()=>void o().then(f=>f&&c(!1)),children:"Reset to initials"}),s&&t.jsx("div",{className:"pa-error",role:"alert",children:s})]})]})}const Jne=Object.freeze(Object.defineProperty({__proto__:null,ProjectAvatar:B1},Symbol.toStringTag,{value:"Module"}));function W1({title:e,onBack:n,backBusy:s=!1}){return t.jsxs("div",{className:"home-head",children:[n?t.jsx("button",{type:"button",className:"hback",onClick:n,disabled:s,"aria-label":"All projects",title:"All projects",children:"←"}):null,t.jsx(B1,{name:e}),t.jsx("h1",{className:"htitle",children:e})]})}const Xne=Object.freeze(Object.defineProperty({__proto__:null,HomeHeader:W1},Symbol.toStringTag,{value:"Module"}));function H1({title:e,emptyTitle:n,count:s,live:r=!1,attention:a=!1,onAdd:o,addLabel:i,children:c}){const d=s===0;return t.jsxs("div",{className:"home-sechead",children:[r?t.jsx("span",{className:"home-livedot"+(a?" warn":""),"data-testid":"home-section-live-dot"}):null,t.jsxs("h2",{className:"home-sectitle"+(d?" empty":""),children:[d?n??`No ${e}`:e,s!=null&&s>0?t.jsxs("span",{className:"count",children:[" (",s,")"]}):null]}),c,o?t.jsx("button",{type:"button",className:"home-secadd"+(d?"":" spacer"),onClick:o,"aria-label":i,title:i,children:"+"}):null]})}const Qne=Object.freeze(Object.defineProperty({__proto__:null,HomeSectionHeading:H1},Symbol.toStringTag,{value:"Module"}));function q1({isBuilding:e,buildingLabel:n,buildingStepLabel:s,buildingStepPosition:r=null,buildingStatus:a="building",buildingProgress:o=null,thumbnailPath:i=null,lastBuiltLabel:c,onOpenBuilding:d,onStartNewFeature:u,onResetBuild:p}){return t.jsxs("section",{"data-testid":"home-building-section",children:[t.jsx(H1,{title:"What's Building",live:e,attention:e&&a!=="building"}),t.jsx(Nu,{isBuilding:e,buildingLabel:n,buildingStepLabel:s,buildingStepPosition:r,buildingStatus:a,buildingProgress:o,thumbnailPath:i,lastBuiltLabel:c,onOpenBuilding:d,onStartNewFeature:u,onResetBuild:p})]})}const Zne=Object.freeze(Object.defineProperty({__proto__:null,HomeBuildingSection:q1},Symbol.toStringTag,{value:"Module"})),U1=3;function Y1({plans:e,loading:n,error:s,onRun:r,launchingSlug:a=null,blocked:o=!1,depAnnotationsBySlug:i,dependenciesBySlug:c,claimsBySlug:d,staleFetch:u,showAuthors:p=!1,onOpenPlans:h}){const[f,m]=l.useState(null),g=e.slice(0,U1),x=e.length>g.length;return t.jsxs("section",{className:"hsum-body","data-testid":"home-queued-plans-section",children:[t.jsx(dp,{plans:g,loading:n,error:s,expandedSlug:f,onToggle:b=>m(y=>y===b?null:b),onRun:r,launchingSlug:a,blocked:o,depAnnotationsBySlug:i,dependenciesBySlug:c,claimsBySlug:d,staleFetch:u,showAuthors:p}),t.jsxs("div",{className:"hsum-foot",children:[x?t.jsxs("button",{type:"button",className:"home-viewall",onClick:h,children:["View all ",t.jsx("span",{"aria-hidden":"true",children:"→"})]}):null,t.jsxs("button",{type:"button",className:"hsum-action",onClick:h,"aria-label":"Plan a new change",children:[t.jsx("span",{"aria-hidden":"true",children:"+"})," Add plan"]})]})]})}const ese=Object.freeze(Object.defineProperty({__proto__:null,HOME_QUEUED_PLAN_LIMIT:U1,HomeQueuedPlansSection:Y1},Symbol.toStringTag,{value:"Module"})),EB=550;function AB(e,n,s=EB){const r=e.filter(h=>h.status!=="completed"),[a,o]=l.useState([]),i=l.useRef(r),c=l.useRef(new Map),d=r.map(h=>h.id).join(" ");if(l.useEffect(()=>{const h=i.current;i.current=r;const f=new Set(r.map(b=>b.id)),m=c.current,g=new Set;m.forEach((b,y)=>{f.has(y)&&(clearTimeout(b),m.delete(y),g.add(y))});const x=h.map((b,y)=>{var v;return{test:b,before:((v=h[y+1])==null?void 0:v.id)??null}}).filter(({test:b})=>!f.has(b.id)&&!m.has(b.id));x.length===0&&g.size===0||(x.forEach(({test:b})=>{m.set(b.id,setTimeout(()=>{m.delete(b.id),o(y=>y.filter(v=>v.test.id!==b.id))},s))}),o(b=>[...b.filter(y=>!g.has(y.test.id)),...x]))},[d,s,r]),l.useEffect(()=>{const h=c.current;return()=>{h.forEach(f=>clearTimeout(f)),h.clear()}},[]),n){const h=new Set(n);return{pending:r.filter(f=>!h.has(f.id)),rows:e.filter(f=>f.status!=="completed"||h.has(f.id)),departingIds:n,pinned:!0}}if(a.length===0)return{pending:r,rows:r,departingIds:[],pinned:!1};const u=new Map(e.map(h=>[h.id,h])),p=[...r];return[...a].reverse().forEach(({test:h,before:f})=>{const m=f===null?-1:p.findIndex(g=>g.id===f);p.splice(m===-1?p.length:m,0,u.get(h.id)??h)}),{pending:r,rows:p,departingIds:a.map(h=>h.test.id),pinned:!1}}function MB(e){const n={total:e.length,simulated:0,unsimulated:0,gaps:0,inherent:0,unclassified:0};for(const{surface:s}of e){if(s.kind==="scenario"){n.simulated+=1;continue}n.unsimulated+=1,s.kind==="no-ui-surface"&&(s.barrier===void 0?n.unclassified+=1:Td(s.barrier)?n.gaps+=1:n.inherent+=1)}return n}function G1(e){return!e||e.neverGenerated||e.lastGeneratedShaUnreachable||e.commitsSince==null?!0:e.commitsSince>0}function V1({status:e,onGenerate:n,onAskForMore:s,disabled:r=!1,openChat:a=null,lastAdHocRange:o=null}){return t.jsxs("div",{className:"mtest-controls","data-testid":"home-testing-controls",children:[t.jsx(Jb,{status:e}),t.jsx(ry,{range:o}),t.jsxs("div",{className:"mtest-buttons",children:[t.jsx("button",{type:"button",className:"mtest-btn"+(G1(e)?" primary":"")+(a==="generate"?" open":""),onClick:n,disabled:r||!n,"aria-expanded":a==="generate",children:"Generate tests"}),t.jsx("button",{type:"button",className:"mtest-btn"+(a==="ask"?" open":""),onClick:s,disabled:r||!s,"aria-expanded":a==="ask",children:"Ask for more tests"})]})]})}const tse=Object.freeze(Object.defineProperty({__proto__:null,HomeTestingSectionControls:V1,shouldEmphasizeGenerate:G1},Symbol.toStringTag,{value:"Module"})),am=2;function K1({tests:e,status:n,loading:s=!1,error:r=null,busyIds:a=[],onToggle:o,onOpenUncovered:i,onGenerate:c,onAskForMore:d,blocked:u=!1,chatSlot:p,openChat:h=null,onAskAboutTest:f,onDeleteTest:m,askProviderLabel:g,openTestChatId:x=null,testChatSlot:b,departingIds:y,rangeSlot:v,lastAdHocRange:j=null}){const _=e.filter(A=>A.status==="completed"),w=new Set(a),[k,S]=l.useState(!1),{pending:N,rows:C,departingIds:T,pinned:P}=AB(e,y),R=new Set(T),I=k?C:C.slice(0,am);return t.jsxs("section",{className:"hsum-body","data-testid":"home-testing-section",children:[t.jsx(V1,{status:n,onGenerate:c,onAskForMore:d,disabled:u,openChat:h,lastAdHocRange:j}),v||null,p?t.jsx("div",{className:"mtest-chat",children:p}):null,s?t.jsx("div",{className:"mtest-placeholder","data-testid":"home-testing-loading",children:"Loading tests…"}):r?t.jsx("div",{className:"mtest-placeholder error","data-testid":"home-testing-error",children:r}):t.jsxs(t.Fragment,{children:[t.jsx(Tb,{summary:MB(e)}),C.length>0?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"mtest-list",children:I.map(A=>t.jsx(Rd,{test:A,onToggle:o,onOpenUncovered:i,onAskAbout:f,onDelete:m,askProviderLabel:g,chatOpen:x===A.id,chatSlot:x===A.id?b:null,busy:w.has(A.id),departing:R.has(A.id)&&(P?"pinned":!0)},A.id))}),N.length>am?t.jsx("button",{type:"button",className:"mtest-disclose",onClick:()=>S(A=>!A),"aria-expanded":k,"data-testid":"home-testing-show-all",children:k?"Show less":`Show all ${N.length} tests`}):null]}):t.jsx("div",{className:"mtest-placeholder","data-testid":"home-testing-empty",children:e.length>0?"Nothing left to verify.":"No manual tests yet."}),t.jsx(Kb,{tests:_,busyIds:a,onToggle:o,onOpenUncovered:i,onAskAboutTest:f,onDeleteTest:m,askProviderLabel:g,openTestChatId:x,testChatSlot:b})]})]})}const nse=Object.freeze(Object.defineProperty({__proto__:null,HomeTestingSection:K1},Symbol.toStringTag,{value:"Module"})),om={plans:"Queued plans",testing:"Testing",services:"External services"},im=["plans","services","testing"];function J1(){return t.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true",children:t.jsx("path",{d:"M4 6l4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}function X1({plans:e,testing:n,services:s,onAddPlan:r}){const[a,o]=l.useState(null),[i,c]=l.useState([]),d={plans:e,testing:n,services:s},u=p=>{o(h=>h===p?null:p),c(h=>h.includes(p)?h:[...h,p])};return t.jsxs("div",{className:"hsum","data-testid":"home-summary-strip",children:[t.jsx("div",{className:"hsum-tiles",children:im.map(p=>{const{tile:h}=d[p],f=p==="plans"&&h.empty,m=p==="plans"&&!h.empty,g=a===p;return t.jsxs("div",{className:"hsum-cell",children:[t.jsxs("button",{type:"button",className:"hsum-tile"+(g?" open":"")+(h.empty?" empty":""),"data-testid":`home-summary-tile-${p}`,onClick:f?r:()=>u(p),"aria-expanded":f?void 0:g,"aria-controls":f?void 0:`home-summary-panel-${p}`,children:[t.jsx("span",{className:"hsum-label",children:om[p]}),t.jsxs("span",{className:"hsum-headline",children:[h.attention?t.jsx("span",{className:"hsum-dot","aria-hidden":"true"}):null,h.headline]}),t.jsx("span",{className:"hsum-detail",children:h.detail}),t.jsx("span",{className:"hsum-icon","aria-hidden":"true",children:f?"+":t.jsx(J1,{})})]}),m&&t.jsxs("button",{type:"button",className:"hsum-add-plan",onClick:r,children:[t.jsx("span",{"aria-hidden":"true",children:"+"}),"Add plan"]})]},p)})}),im.map(p=>i.includes(p)?t.jsx("div",{id:`home-summary-panel-${p}`,className:"hsum-panel",role:"region","aria-label":om[p],hidden:a!==p,children:d[p].panel},p):null)]})}const sse=Object.freeze(Object.defineProperty({__proto__:null,Chevron:J1,HomeSummaryStrip:X1},Symbol.toStringTag,{value:"Module"})),IB={Domain:"blue",Hosting:"blue","Code hosting":"indigo","Package registry":"indigo","Cloud platform":"blue",Payments:"green",Database:"indigo","Database ORM":"indigo","Backend platform":"indigo","Cache & queue":"indigo",Authentication:"amber","AI provider":"lime","Transactional email":"lime","Product analytics":"lime","Storage & media":"lime",Messaging:"lime",Search:"lime",Containers:"indigo","CI/CD":"indigo","Error monitoring":"amber"},lm=["Domain","Hosting","Cloud platform","Code hosting","Package registry","Database","Database ORM","Backend platform","Cache & queue","Authentication","Payments","AI provider","Transactional email","Messaging","Storage & media","Search","Containers","CI/CD","Product analytics","Error monitoring"];function ea(e){return e.source==="pending"||e.confidence==="suggested"}function Q1(e){var s;if(ea(e))return"suggested";if(e.confidence==="inferred")return"found in code";const n=(s=e.evidence[0])==null?void 0:s.source;return n?n==="git remote"?"from git remote":n==="config file"?"from config":`from ${n}`:"declared"}function DB(e){var s;const n=e.trim().split(/\s+/).filter(Boolean);return n.length>=2?(n[0][0]+n[1][0]).toUpperCase():(((s=n[0])==null?void 0:s[0])??"?").toUpperCase()}function vp(e){return e.envVars.length>0&&!e.credentialPresent}function LB(e){if(e.note)return e.note;const n=e.evidence[0];if(!n)return e.category;const s=e.evidence.length>1?` · +${e.evidence.length-1} more`:"";return`${n.value} in ${n.source}${s}`}function FB(e){const n=[{label:"Category",value:e.category}];if(ea(e))return n.push({label:"Status",value:"Not set up yet"}),n.push({label:"Source",value:"Suggested — no evidence in this repo"}),n;n.push({label:"Origin",value:Q1(e)}),e.envVars.length>0&&n.push({label:"Env vars",value:e.envVars.join(", "),mono:!0}),n.push({label:e.credentialPresent?"Key":"Key status",value:e.credentialPresent?"Configured":"Not set yet"});for(const s of e.evidence.slice(0,4))n.push({label:"Detected in",value:`${s.value} · ${s.source}`,mono:!0});return e.docsUrl&&n.push({label:"Docs",value:e.docsUrl}),n}function $B(e){const n=[],s=ea(e);n.push({text:Q1(e),kind:"origin"}),s&&n.push({text:"not set up",kind:"miss"});const r=e.envVars[0];r&&n.push({text:r,kind:"env"}),e.envVars.length>0&&e.credentialPresent&&n.push({text:"Key set",kind:"set"});const a=vp(e),o=s?"Set up":a?"Add key":void 0;return{monogram:DB(e.name),providerId:e.key,category:e.category,tone:IB[e.category]??"lime",name:e.name,desc:LB(e),tags:n.length?n:void 0,actionLabel:o,actionKey:o?e.key:void 0,attn:a,pending:s,detail:FB(e)}}function cm(e){const n=lm.indexOf(e);return n===-1?lm.length:n}function zB(e){const n=(e??[]).filter(s=>s.status!=="dismissed"&&!ea(s));return{total:n.length,attention:n.filter(vp).length}}function BB(e){const n=(e??[]).filter(p=>p.status!=="dismissed");if(n.length===0)return{groups:[],summary:""};const s=new Map;for(const p of n){const h=s.get(p.category);h?h.push(p):s.set(p.category,[p])}const r=[...s.entries()].sort(([p],[h])=>cm(p)-cm(h)||p.localeCompare(h)).map(([p,h])=>({label:p,items:h.slice().sort((f,m)=>f.name.localeCompare(m.name)).map($B)})),a=n.filter(p=>!ea(p)),o=n.length-a.length,i=a.filter(vp).length,c=a.length===1?"service":"services",d=i>0?`${a.length} ${c} · ${i} need${i===1?"s":""} your attention`:`${a.length} ${c} detected`,u=o>0?`${d} · ${o} not set up yet`:d;return{groups:r,summary:u}}function dc(e,n,s){return e===1?n:s}function WB(e){return e.length===0?{headline:"Nothing queued",detail:"Plan the next change",empty:!0,attention:!1}:{headline:`${e.length} queued`,detail:`Next: ${e[0].title}`,empty:!1,attention:!1}}function HB(e,n){const s=e.filter(o=>o.status!=="completed").length,r=(n==null?void 0:n.commitsSince)??0,a=r>0?`${r} ${dc(r,"commit","commits")} since last run`:null;return e.length===0?{headline:"No tests yet",detail:"Generate checks from recent commits",empty:!0,attention:!1}:s===0?{headline:"Nothing left to verify",detail:a??"Up to date",empty:!1,attention:!1}:{headline:`${s} to verify`,detail:a??"Up to date",empty:!1,attention:!1}}function qB(e){const{total:n,attention:s}=zB(e);if(n===0)return{headline:"None mapped yet",detail:"Find what your app talks to",empty:!0,attention:!1};const r=`${n} ${dc(n,"service","services")} detected`;return s>0?{headline:`${s} ${dc(s,"needs","need")} a key`,detail:r,empty:!1,attention:!0}:{headline:r,detail:"Every key is set",empty:!1,attention:!1}}function Z1({projectTitle:e,app:n,isBuilding:s,buildingLabel:r,buildingStepLabel:a,buildingStepPosition:o,buildingStatus:i,buildingProgress:c,buildingThumbnailPath:d,lastBuiltLabel:u,plans:p,plansLoading:h=!1,plansError:f=null,onRunPlan:m,launchingSlug:g,planDepAnnotationsBySlug:x,planDependenciesBySlug:b,planClaimsBySlug:y,planStaleFetch:v,showPlanAuthors:j,manualTests:_=[],manualTestsStatus:w=null,manualTestsLoading:k=!1,manualTestsError:S=null,manualTestsBusyIds:N,onCompleteManualTest:C,onOpenUncoveredSurface:T,onGenerateTests:P,onAskForTests:R,manualTestsChatSlot:I,manualTestsChatOpen:A=null,manualTestsRangeSlot:O,manualTestsLastAdHocRange:W=null,onAskAboutTest:D,onDeleteManualTest:Y,manualTestAgentLabel:H,manualTestChatId:E=null,manualTestChatSlot:U,detectedServices:M=null,servicesSlot:J,onOpenBuilding:ne,onStartNewFeature:oe,onResetBuild:ae,onOpenPlans:G,onBackToProjects:ie,launcherUrl:le,projectCount:Z=0,banner:z}){const{goBack:L,busy:q}=_B({launcherUrl:le,projectCount:Z,fallback:ie}),se=(e==null?void 0:e.trim())||n.name||"Your project";return t.jsxs("div",{className:"home-landing",children:[z&&t.jsx("div",{className:"home-banner",children:z}),t.jsx(W1,{title:se,onBack:L,backBusy:q}),t.jsx("div",{className:"home-sec",children:t.jsx(q1,{isBuilding:s,buildingLabel:r,buildingStepLabel:a,buildingStepPosition:o,buildingStatus:i,buildingProgress:c,thumbnailPath:d,lastBuiltLabel:u,onOpenBuilding:ne,onStartNewFeature:oe,onResetBuild:ae})}),t.jsx(X1,{onAddPlan:G,plans:{tile:WB(p),panel:t.jsx(Y1,{plans:p,loading:h,error:f,onRun:m,launchingSlug:g,blocked:s,depAnnotationsBySlug:x,dependenciesBySlug:b,claimsBySlug:y,staleFetch:v,showAuthors:j,onOpenPlans:G})},testing:{tile:HB(_,w),panel:t.jsx(K1,{tests:_,status:w,loading:k,error:S,busyIds:N,onToggle:C??(()=>{}),onOpenUncovered:T,onGenerate:P,onAskForMore:R,blocked:s,chatSlot:I,openChat:A,rangeSlot:O,lastAdHocRange:W,onAskAboutTest:D,onDeleteTest:Y,askProviderLabel:H,openTestChatId:E,testChatSlot:U})},services:{tile:qB(M),panel:J}})]})}const rse=Object.freeze(Object.defineProperty({__proto__:null,HomeLanding:Z1},Symbol.toStringTag,{value:"Module"})),eN="/codeyam-manual-tests";function UB(e){return Es(eN,"")}function YB(e,n){const s=e.trim();if(!s)return UB();const r="".trim();return Es(eN,r?`range:${s} ${r}`:`range:${s}`)}function GB(e){const n=e==null?void 0:e.lastGeneratedSha;return n?`${n.slice(0,7)}..HEAD`:null}const VB="/codeyam-manual-test-help";function KB(e){return Es(VB,e)}function tN({id:e,onClose:n}){const s=l.useRef(null);return l.useEffect(()=>{const r=s.current;r&&typeof r.scrollIntoView=="function"&&r.scrollIntoView({block:"nearest",behavior:"smooth"})},[]),t.jsx("div",{ref:s,children:t.jsx(qt,{chatName:`manual-test-${e}`,slashCommand:KB(e),height:360,onClose:n})})}const ase=Object.freeze(Object.defineProperty({__proto__:null,ManualTestHelpChat:tN},Symbol.toStringTag,{value:"Module"}));function JB(){const[e,n]=l.useState([]),[s,r]=l.useState(null),[a,o]=l.useState(!0),[i,c]=l.useState(null),{manualTestsVersion:d}=Tn(),u=l.useRef(!1),p=l.useCallback(async()=>{u.current||o(!0),c(null);try{const[h,f]=await Promise.all([fetch("/api/manual-tests"),fetch("/api/manual-tests/status")]);if(!h.ok)throw new Error(`HTTP ${h.status}`);if(!f.ok)throw new Error(`HTTP ${f.status}`);const m=await h.json(),g=await f.json();n(Array.isArray(m)?m:[]),r(g),u.current=!0}catch(h){c(h instanceof Error?h.message:"Failed to load manual tests")}finally{o(!1)}},[]);return l.useEffect(()=>{p()},[p,d]),{tests:e,status:s,loading:a,error:i,refetch:p}}function XB(e){const[n,s]=l.useState({}),[r,a]=l.useState({}),[o,i]=l.useState(null);return{setCompleted:l.useCallback(async(d,u)=>{const p=u?"completed":"pending";i(null),s(h=>({...h,[d]:p})),a(h=>({...h,[d]:!0}));try{const h=u?"complete":"uncomplete",f=await fetch(`/api/manual-tests/${encodeURIComponent(d)}/${h}`,{method:"POST"});if(!f.ok)throw new Error(`HTTP ${f.status}`);await e(),s(m=>{const g={...m};return delete g[d],g})}catch(h){s(f=>{const m={...f};return delete m[d],m}),i(h instanceof Error?h.message:"Failed to update test")}finally{a(h=>{const f={...h};return delete f[d],f})}},[e]),overrides:n,inFlightIds:Object.keys(r),error:o}}function QB(){const[e,n]=l.useState(!1),[s,r]=l.useState(null);return{deleteTest:l.useCallback(async o=>{n(!0),r(null);try{const i=await fetch(`/api/manual-tests/${encodeURIComponent(o)}`,{method:"DELETE"});if(!i.ok){const c=await i.json().catch(()=>({}));throw new Error(c.error??`HTTP ${i.status}`)}}catch(i){const c=i instanceof Error?i.message:"Failed to delete test";throw r(c),i instanceof Error?i:new Error(c)}finally{n(!1)}},[]),deleting:e,error:s}}function nN({title:e,id:n,completed:s,busy:r,error:a,onCancel:o,onConfirm:i}){return l.useEffect(()=>{const c=d=>{d.key==="Escape"&&!r&&o()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[r,o]),t.jsx("div",{role:"presentation",onClick:()=>{r||o()},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:t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Delete manual test?","data-test-id":n,onClick:c=>c.stopPropagation(),style:{background:"var(--bg-elevated, #141414)",border:"1px solid var(--border-default)",borderRadius:12,padding:24,width:"min(460px, 100%)",display:"flex",flexDirection:"column",gap:16,fontFamily:"'IBM Plex Mono', monospace",boxShadow:"0 20px 60px rgba(0,0,0,0.5)"},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsx($b,{title:e}),t.jsx(Fb,{completed:s})]}),a&&t.jsx(Lt,{severity:"error",testId:"manual-test-delete-error",headline:"The test wasn't deleted",explanation:"CodeYam asked the editor to remove this test and the request came back with an error. The test is still in the list and nothing on disk was changed.",nextAction:"Try Delete test again. If it keeps failing, copy this report — the test file may have been moved or removed outside the editor.",diagnostics:a}),t.jsx(Lb,{busy:r,onCancel:o,onConfirm:i})]})})}const ose=Object.freeze(Object.defineProperty({__proto__:null,ManualTestDeleteConfirmModal:nN},Symbol.toStringTag,{value:"Module"}));function ZB(e,n){return Object.keys(n).length===0?e:e.map(s=>n[s.id]&&n[s.id]!==s.status?{...s,status:n[s.id]}:s)}function e8(){const[e,n]=l.useState(null),s=l.useCallback(async()=>{try{const r=await fetch("/api/service-brokers");if(!r.ok)throw new Error(`HTTP ${r.status}`);const a=await r.json();n(Array.isArray(a)?a:[])}catch{n([])}},[]);return l.useEffect(()=>{s()},[s]),{brokers:e,refetch:s}}function t8(e){return e.credentialPresent?" (key configured)":e.envVars.length>0?" (needs a key)":""}function n8(e,n){const s=(e??[]).filter(o=>o.status!=="dismissed"),r=s.length?`
|
|
94
|
+
|
|
95
|
+
Detected in this project so far:
|
|
96
|
+
${s.map(o=>`- ${o.name} (${o.category})${t8(o)}`).join(`
|
|
97
|
+
`)}`:`
|
|
98
|
+
|
|
99
|
+
No external services have been auto-detected in this project yet.`,a=n!=null&&n.trim()?`
|
|
100
|
+
|
|
101
|
+
The user opened this chat with the following message. Respond to it directly and helpfully as your FIRST reply, before anything else:
|
|
102
|
+
"${n.trim()}"`:`
|
|
103
|
+
|
|
104
|
+
Greet the user briefly and ask what they'd like to know or change about their external services.`;return["You are helping the user understand and manage this project's EXTERNAL SERVICES, ","the outside things it depends on: domains, hosting, API keys, payments (e.g. Stripe), ","databases, auth, transactional email, analytics, error monitoring, and any paid subscriptions.",r,`
|
|
105
|
+
|
|
106
|
+
Help with whatever they want here: what's wired up, what's missing an API key, `,"how to add or remove a service, and renewals or monthly cost. Those last two are NOT in ","the repo, so ASK the user rather than guessing. Be concise and concrete.",`
|
|
107
|
+
|
|
108
|
+
Whenever a service gets set up, or the user tells you about one this list is missing `,"(their domain, for instance), record it right away so this page shows it: ","`codeyam-editor editor declare-service --key <id> --name <name> --category <category> --topic <topic>` ","(for a domain: `--key custom-domain --name <the domain> --category Domain --topic custom-domain`).",a].join("")}const s8=`<!--
|
|
109
|
+
The seed prompt for a broker provisioning session, and the ONE place its text
|
|
110
|
+
lives. Two consumers substitute the same four placeholders into it:
|
|
111
|
+
|
|
112
|
+
* the UI, via \`ui/src/helpers/buildStripeProjectsChatPrompt.ts\`, which imports
|
|
113
|
+
this file with Vite's \`?raw\` (the same mechanism
|
|
114
|
+
\`ui/src/helpers/errorCaptureShim.test.ts\` uses to read a Rust crate's
|
|
115
|
+
JavaScript shim);
|
|
116
|
+
* the CLI, via \`include_str!\` in \`broker_session.rs\`, so
|
|
117
|
+
\`codeyam-editor editor broker-session\` emits a byte-identical seed.
|
|
118
|
+
|
|
119
|
+
Keeping the text here rather than in either consumer is the point. A prompt
|
|
120
|
+
that tells an agent when it may spend the user's money is not something to
|
|
121
|
+
maintain in two languages: a rule tightened in the UI copy and missed in the
|
|
122
|
+
CLI copy is a rule that silently does not apply to half the entry points.
|
|
123
|
+
|
|
124
|
+
Placeholders, all four required, each substituted verbatim:
|
|
125
|
+
{{CATEGORY}} what the user is setting up, e.g. "hosting"
|
|
126
|
+
{{PROBE_STATE}} what the broker probe found on this machine
|
|
127
|
+
{{RESOURCES}} what this broker has already provisioned
|
|
128
|
+
{{OPENING}} the agent's instruction for its very first reply
|
|
129
|
+
-->
|
|
130
|
+
You are helping the user set up **{{CATEGORY}}** for this project using Stripe
|
|
131
|
+
Projects, a provisioning CLI that creates real resources on the user's Stripe
|
|
132
|
+
account and can cost them real money.
|
|
133
|
+
|
|
134
|
+
## What is already true on this machine
|
|
135
|
+
|
|
136
|
+
{{PROBE_STATE}}
|
|
137
|
+
|
|
138
|
+
{{RESOURCES}}
|
|
139
|
+
|
|
140
|
+
## Rules
|
|
141
|
+
|
|
142
|
+
These are not suggestions, and they hold for every command in this session.
|
|
143
|
+
|
|
144
|
+
- **Hand off to the local skill.** \`stripe projects init\` writes a
|
|
145
|
+
\`stripe-projects\` skill into this repository. It is the authoritative
|
|
146
|
+
reference for every subsequent Stripe Projects command — use it rather than
|
|
147
|
+
your memory of the CLI's flags. Do not install the skill globally unless the
|
|
148
|
+
user explicitly asks for it; the repo-local skill is the default because it
|
|
149
|
+
changes nothing outside this checkout.
|
|
150
|
+
- **Environment variable NAMES only, never values.** You may say that
|
|
151
|
+
\`DATABASE_URL\` is set. You may never print, echo, log, or repeat what it is
|
|
152
|
+
set to, not even partially.
|
|
153
|
+
- **Never hand-edit \`.projects/\` or \`.env\`.** The CLI owns those files. If
|
|
154
|
+
something in them is wrong, fix it with a CLI command, not an editor.
|
|
155
|
+
- **Ask before anything irreversible.** Every command that creates, links,
|
|
156
|
+
upgrades, or removes a resource spends the user's money or changes their
|
|
157
|
+
account. Show the exact command you intend to run, say plainly what it will
|
|
158
|
+
create and what it will cost, and wait for an explicit yes. One approval
|
|
159
|
+
covers exactly one command — approval to install the CLI is not approval to
|
|
160
|
+
initialize the project, and neither is approval to provision anything.
|
|
161
|
+
- **A browser window means STOP.** The Stripe CLI opens a browser to
|
|
162
|
+
authenticate. When that happens, tell the user a browser window is waiting
|
|
163
|
+
for them and run nothing further until they confirm they have finished. Do
|
|
164
|
+
not poll, do not retry, and do not work around it.
|
|
165
|
+
- **Pass \`--json\` where the CLI supports it** and read the structured output
|
|
166
|
+
rather than parsing human-formatted text.
|
|
167
|
+
- **Never re-provision.** The resources listed above already exist. Adding a
|
|
168
|
+
second one because you did not read the list is the most expensive mistake
|
|
169
|
+
available to you here.
|
|
170
|
+
|
|
171
|
+
## Start here
|
|
172
|
+
|
|
173
|
+
{{OPENING}}
|
|
174
|
+
`;function r8(e){const n=e.indexOf("-->");return e.startsWith("<!--")&&n!==-1?e.slice(n+3).trimStart():e}function a8(e){const n=[`- ${e.name} CLI: ${e.cliInstalled?`installed${e.cliVersion?` (${e.cliVersion})`:""}`:`NOT installed. The user would install it with: ${e.installHint}`}`,`- Its \`projects\` plugin: ${e.pluginInstalled?"installed":"NOT installed"}`,`- This directory: ${e.projectInitialized?`initialized${e.projectName?` as "${e.projectName}"`:""}`:"NOT initialized — `stripe projects init` has not been run here"}`];return e.note&&n.push(`- Note from the probe: ${e.note}`),n.join(`
|
|
175
|
+
`)}function o8(e){const n=(e??[]).filter(s=>s.status!=="dismissed");return n.length===0?"This project has no external services recorded yet.":["Already recorded for this project — do NOT provision these again:",...n.map(s=>`- ${s.name} (${s.category})${s.credentialPresent?" — credential configured":s.envVars.length>0?` — needs ${s.envVars.join(", ")}`:""}`)].join(`
|
|
176
|
+
`)}function i8(e,n,s,r){const a=r!=null&&r.trim()?`The user opened this session with the following message. Respond to it directly as your FIRST reply, before anything else:
|
|
177
|
+
"${r.trim()}"`:`Tell the user in one or two sentences what you are about to do to set up ${n.toLowerCase()} for them, name the first command you would run, and ask whether to run it. Run nothing before they answer.`;return r8(s8).replace("{{CATEGORY}}",n.toLowerCase()).replace("{{PROBE_STATE}}",a8(e)).replace("{{RESOURCES}}",o8(s)).replace("{{OPENING}}",a)}function sN({onBack:e,embedded:n=!1,onServicesChanged:s}){const{services:r,refetch:a}=gu(),{brokers:o}=e8(),[i,c]=l.useState(!1),[d,u]=l.useState(void 0),[p,h]=l.useState(null),[f,m]=l.useState(null),[g,x]=l.useState(!1),{groups:b,summary:y}=l.useMemo(()=>BB(r),[r]),v=l.useMemo(()=>(o??[]).find(wI)??null,[o]),j=l.useMemo(()=>(o??[]).find(Hb)??null,[o]),_=()=>{c(!1),m(null),x(!1)},w=k=>{var C;const S=(r??[]).find(T=>T.key===k);if(!S)return;const N=(C=S.envVars)==null?void 0:C[0];if(!N){if(v){m({broker:v,category:S.category}),x(!1),u(void 0),c(!0);return}u(`Help me set up ${S.category.toLowerCase()} for this project`),c(!0);return}h({serviceName:S.name,envVar:N,topic:S.topic,docsUrl:S.docsUrl})};return t.jsxs("div",{className:"xsvc-connected",children:[t.jsx(S_,{groups:b,loading:r===null,summary:y,onBack:e,embedded:n,onOpenChat:k=>{m(null),x(!1),u(k),c(!0)},onAction:w,onSaveDomain:async k=>{if(!(await fetch("/api/setup-services/declare",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:"custom-domain",name:k,category:"Domain",topic:"custom-domain"})})).ok)throw new Error("Couldn't save the domain. Try again.");await a(),s==null||s()},brokerStarter:j?{label:`Set up with ${j.name}`,onSelect:()=>{m({broker:j,category:"External services"}),x(!1),u(void 0),c(!0)}}:void 0,chatSlot:i?t.jsx(Ub,{title:f?`Set up ${f.category.toLowerCase()} with ${f.broker.name}`:"Chat about your external services",onClose:_,children:f&&!g?t.jsx(qb,{broker:f.broker,category:f.category,onStart:()=>x(!0)}):t.jsx(qt,{chatName:f?`external-services-${f.broker.id}`:"external-services",prompt:f?i8(f.broker,f.category,r,d):n8(r,d),height:380,onClose:_})}):void 0}),p?t.jsx(yp,{target:p,onStored:()=>{h(null),a(),s==null||s()},onClose:()=>h(null)}):null]})}const ise=Object.freeze(Object.defineProperty({__proto__:null,ExternalServicesScreenConnected:sN},Symbol.toStringTag,{value:"Module"})),l8={provider:"vercel"},rN={"dev-accounts":q_,"store-assets":U_,"store-listing":Y_,"testing-distribution":G_,"push-notifications":V_,"crash-reporting":K_,"in-app-purchases":J_,"app-privacy":X_,"app-review":Q_};function dm(e){return e in rN}function c8(){const[e,n]=l.useState(null),s=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();n(Array.isArray(i)?i:[])}catch{n([])}},[]);l.useEffect(()=>{s()},[s]);const r=l.useCallback((o,i)=>{n(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(()=>{s()})},[s]),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 s(),{key:c.key,existed:!!c.existed}},[s]);return{topics:e,setStatus:r,addTopic:a}}function d8(){const[e,n]=l.useState(null);return l.useEffect(()=>{let s=!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();s||n(Array.isArray(a)?a:[])}catch{s||n([])}})(),()=>{s=!0}},[]),{groups:e}}function u8(){const[e,n]=l.useState(null);return l.useEffect(()=>{let s=!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();s||n(a)}catch{s||n(null)}})(),()=>{s=!0}},[]),{recipe:e}}function p8(e,n){if(n(),bg()){Ma(e);return}HR(bh).then(s=>{s?Ma(e):console.warn(`[setup-chat] Build terminal did not attach within ${bh}ms; prompt not sent`)})}const h8=new Set(["share-testing","store-accounts","store-assets","permissions-justification","oauth-verification","privacy-policy","single-purpose-listing","manifest-versioning","submit-review"]);function aN({notificationBanner:e,appDetailProps:n,appOverviewProps:s,selectedApp:r,projectTitle:a,admin:o,isBuilding:i,buildingLabel:c,buildingStepLabel:d,buildingStepPosition:u,buildingStatus:p,buildingProgress:h,buildingThumbnailPath:f,lastBuiltLabel:m,plans:g,plansLoading:x,plansError:b,onRunPlan:y,launchingSlug:v,planDepAnnotationsBySlug:j,planDependenciesBySlug:_,planClaimsBySlug:w,planStaleFetch:k,showPlanAuthors:S,onNavigateToPlan:N,onNavigateToBuild:C,onResetBuild:T,onBackToProjects:P,launcherUrl:R,projectCount:I,onOpenSetupBrowser:A}){const[O,W]=l.useState(!1),D=()=>W(!0),Y=()=>W(!1),{tests:H,status:E,loading:U,error:M,refetch:J}=JB(),{setCompleted:ne,overrides:oe,inFlightIds:ae}=XB(J),{deleteTest:G,deleting:ie,error:le}=QB(),[Z,z]=l.useState(null),L=H.find(V=>V.id===Z)??null,[q,se]=l.useState(null),fe=yB(),we=vB(fe.open),[De,Fe]=l.useState(null),{config:Me}=St(),ee=Qe(Me==null?void 0:Me.provider),[Q,te]=l.useState("landing"),[he,ye]=l.useState(null),[ve,Ne]=l.useState(null),{topics:de,setStatus:me,addTopic:We}=c8();de==null||de.filter(V=>V.status==="done").length;const B=V=>{var ce;return((ce=de==null?void 0:de.find(Be=>Be.key===V))==null?void 0:ce.status)??"available"},{services:F,dismiss:X,refetch:ue}=gu(),[be,xe]=l.useState(null),ke=l.useCallback(V=>{var Be;const ce=(Be=V.envVars)==null?void 0:Be[0];ce&&xe({serviceName:V.name,envVar:ce,topic:V.topic,docsUrl:V.docsUrl})},[]),{recipe:qe}=u8(),Le=G4(nw()),{groups:Oe}=d8(),Ue=(de==null?void 0:de.some(V=>V.key==="dev-accounts"))??!1,dt=(de==null?void 0:de.some(V=>V.key==="deploy-target"))??!1,je=V=>{V==="run-locally"?te("run-locally"):Ue&&dm(V)?(Ne(V),te("mobile-setup")):h8.has(V)?te(V):dm(V)?(Ne(V),te("mobile-setup")):(ye(V),te("topic"))},$e=!!(n.selectedRouteEntity||n.selectedEntityHash);let K,_e=!1;if(!r)K=t.jsx(kS,{...s,onCoverageClick:D},"app-overview");else if($e||Q==="detail"){const V=Q==="detail"&&!$e;K=t.jsxs(t.Fragment,{children:[V?t.jsx("div",{className:"home-landing",style:{padding:"20px 28px 0"},children:t.jsxs("div",{className:"crumbs",style:{marginBottom:0},children:[t.jsx("button",{type:"button",className:"back",onClick:()=>te("landing"),"aria-label":"Back",children:"←"}),t.jsx("button",{type:"button",onClick:()=>te("landing"),children:"Home"}),t.jsx("span",{className:"sep",children:"›"}),t.jsx("b",{children:"Explore your app"})]})}):null,t.jsx(aw,{app:r,...n,onCoverageClick:D})]})}else if(Q==="learn")K=t.jsx(Na,{topics:de,detectedServices:F,onBack:()=>te("landing"),onOpenHosting:()=>te("hosting"),onOpenTopic:je,onOpenLibraries:()=>te("libraries"),onDismissService:X,onAddCredential:ke,onCreateTopic:We,onOpenConcepts:()=>te("concepts")});else if(Q==="libraries")K=t.jsx(xw,{groups:Oe,onBack:()=>te("learn")});else if(Q==="concepts")K=t.jsx(j_,{onBack:()=>te("learn")});else if(Q==="hosting")K=t.jsx(E_,{connector:l8,onBack:()=>te("learn"),onComplete:()=>me("hosting","done"),onOpenSharedBrowser:A});else if(Q==="run-locally")K=t.jsx(A_,{recipe:qe,onBack:()=>te("learn"),status:B("run-locally"),onMarkDone:()=>me("run-locally","done"),onRevert:()=>me("run-locally","available")});else if(Q==="share-testing")K=t.jsx(H_,{onBack:()=>te("learn"),status:B("share-testing"),onComplete:()=>me("share-testing","done"),onRevert:()=>me("share-testing","available")});else if(Q==="store-accounts")K=t.jsx(M_,{onBack:()=>te("learn"),status:B("store-accounts"),onComplete:()=>me("store-accounts","done"),onRevert:()=>me("store-accounts","available")});else if(Q==="store-assets")K=t.jsx(I_,{onBack:()=>te("learn"),status:B("store-assets"),onComplete:()=>me("store-assets","done"),onRevert:()=>me("store-assets","available")});else if(Q==="permissions-justification")K=t.jsx(L_,{onBack:()=>te("learn"),status:B("permissions-justification"),onComplete:()=>me("permissions-justification","done"),onRevert:()=>me("permissions-justification","available")});else if(Q==="oauth-verification")K=t.jsx($_,{onBack:()=>te("learn"),status:B("oauth-verification"),onComplete:()=>me("oauth-verification","done"),onRevert:()=>me("oauth-verification","available")});else if(Q==="privacy-policy")K=t.jsx(F_,{onBack:()=>te("learn"),status:B("privacy-policy"),onComplete:()=>me("privacy-policy","done"),onRevert:()=>me("privacy-policy","available")});else if(Q==="single-purpose-listing")K=t.jsx(z_,{onBack:()=>te("learn"),status:B("single-purpose-listing"),onComplete:()=>me("single-purpose-listing","done"),onRevert:()=>me("single-purpose-listing","available")});else if(Q==="manifest-versioning")K=t.jsx(B_,{onBack:()=>te("learn"),status:B("manifest-versioning"),onComplete:()=>me("manifest-versioning","done"),onRevert:()=>me("manifest-versioning","available")});else if(Q==="submit-review")K=t.jsx(W_,{onBack:()=>te("learn"),status:B("submit-review"),onComplete:()=>me("submit-review","done"),onRevert:()=>me("submit-review","available")});else if(Q==="topic"&&he){const V=(de==null?void 0:de.find(ce=>ce.key===he))??null;K=t.jsx(v_,{topicKey:he,topicName:V==null?void 0:V.name,topicDesc:V==null?void 0:V.desc,isBackend:dt,onBack:()=>te("learn"),onComplete:ce=>me(ce,"done"),onChatWithAI:ce=>p8(ce,C)})}else if(Q==="mobile-setup"&&ve){const V=rN[ve];K=V?t.jsx(V,{platform:Le,onBack:()=>te("learn"),status:B(ve),onComplete:()=>me(ve,"done"),onRevert:()=>me(ve,"available")}):t.jsx(Na,{topics:de,detectedServices:F,onBack:()=>te("landing"),onOpenHosting:()=>te("hosting"),onOpenTopic:je,onDismissService:X,onAddCredential:ke})}else _e=!0,K=t.jsxs(t.Fragment,{children:[t.jsx(Z1,{banner:e,app:r,projectTitle:a,isBuilding:i,buildingLabel:c,buildingStepLabel:d,buildingStepPosition:u,buildingStatus:p,buildingProgress:h,buildingThumbnailPath:f,lastBuiltLabel:m,plans:g,plansLoading:x,plansError:b,onRunPlan:y,launchingSlug:v,planDepAnnotationsBySlug:j,planDependenciesBySlug:_,planClaimsBySlug:w,planStaleFetch:k,showPlanAuthors:S,manualTests:ZB(H,oe),manualTestsStatus:E,manualTestsLoading:U,manualTestsError:M,manualTestsBusyIds:ae,onCompleteManualTest:(V,ce)=>{ne(V,ce)},onGenerateTests:()=>{Fe(null),se(null),fe.toggle()},onAskForTests:()=>{Fe(null),fe.close(),se(V=>V==="ask"?null:"ask")},manualTestsChatOpen:fe.open?"generate":q,manualTestsLastAdHocRange:fe.lastAdHocRange,manualTestsRangeSlot:fe.open?t.jsx(sy,{defaultRange:GB(E),commitCount:(E==null?void 0:E.commitsSince)??null,recentCommits:we,onCancel:fe.close,onGenerate:V=>{fe.accept(V),se("generate")}}):null,manualTestsChatSlot:q?t.jsx(Yb,{slashCommand:q==="generate"?YB(fe.seed):void 0,onClose:()=>se(null)}):null,onAskAboutTest:V=>{se(null),Fe(ce=>ce===V?null:V)},onDeleteManualTest:V=>z(V),manualTestAgentLabel:ee,manualTestChatId:De,manualTestChatSlot:De?t.jsx(tN,{id:De,onClose:()=>Fe(null)}):null,detectedServices:F,servicesSlot:t.jsx(sN,{embedded:!0,onServicesChanged:()=>void ue()}),onOpenBuilding:C,onStartNewFeature:C,onResetBuild:T,onOpenPlans:N,onBackToProjects:P,launcherUrl:R,projectCount:I}),t.jsx(Pj,{appDetailProps:n,selectedApp:r,setupSlot:o?t.jsx(Na,{topics:de,detectedServices:F,onBack:()=>te("landing"),onOpenHosting:()=>te("hosting"),onOpenTopic:je,onOpenLibraries:()=>te("libraries"),onDismissService:X,onAddCredential:ke,onCreateTopic:We,onOpenConcepts:()=>te("concepts")}):void 0})]});return t.jsxs(dw,{children:[e&&!_e&&t.jsx("div",{style:{padding:"10px 28px 0"},children:e}),K,O&&t.jsx(z1,{onClose:Y}),be?t.jsx(yp,{target:be,onStored:()=>{xe(null),ue()},onClose:()=>xe(null)}):null,L?t.jsx(nN,{title:L.title,id:L.id,completed:L.status==="completed",busy:ie,error:le,onCancel:()=>z(null),onConfirm:()=>{G(L.id).then(()=>{z(null),J()}).catch(()=>{})}}):null]})}const lse=Object.freeze(Object.defineProperty({__proto__:null,EditorShellHomeTabContent:aN},Symbol.toStringTag,{value:"Module"}));function oN({activeTab:e,awaitingPlanLaunchChoice:n,buildLaunchGateArmed:s,buildActivated:r,hideResultsCommandKey:a,onSelectScenario:o,previewSlug:i,showResultsCommandKey:c,onAgentIdle:d,onAgentBlocked:u,onAgentActive:p,onUserInput:h,provider:f,onRestorePreview:m,pendingPlans:g,pendingPlansLoading:x,pendingPlansError:b,onLaunchPlan:y,launchingSlug:v,launchError:j,onReorderPlans:_,isAgentBuilding:w,featureCompleteActive:k,buildActivity:S,chatEscalatedToPrototype:N,onActivityDone:C,onPrototypeLaunched:T,prototypeLaunchSignal:P}){return r?t.jsx(y1,{awaitingPlanLaunchChoice:n,buildLaunchGateArmed:s,buildActivated:r,activeTab:e,onSelectScenario:o,previewSlug:i,showResultsCommandKey:c,hideResultsCommandKey:a,onAgentIdle:d,onAgentBlocked:u,onAgentActive:p,onUserInput:h,provider:f,onRestorePreview:m,pendingPlans:g,pendingPlansLoading:x,pendingPlansError:b,onLaunchPlan:y,launchingSlug:v,launchError:j,onReorderPlans:_,isAgentBuilding:w,featureCompleteActive:k,buildActivity:S,chatEscalatedToPrototype:N,onActivityDone:C,onPrototypeLaunched:T,prototypeLaunchSignal:P}):null}const cse=Object.freeze(Object.defineProperty({__proto__:null,EditorShellBuildLayer:oN},Symbol.toStringTag,{value:"Module"})),uc=24;function iN({onMouseDown:e,onReset:n,onNudge:s,isDragging:r=!1,valueNow:a,valueMax:o,valueMin:i}){const[c,d]=l.useState(!1),[u,p]=l.useState(!1),h=l.useRef(!1),f=c||u||r;return t.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize panels","aria-valuenow":a,"aria-valuemin":i,"aria-valuemax":o,tabIndex:0,title:"Drag to resize · double-click to reset","data-active":f?"true":"false",onMouseDown:m=>{h.current=!0,e(m)},onDoubleClick:n,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),onFocus:()=>p(!h.current),onBlur:()=>{h.current=!1,p(!1)},onKeyDown:m=>{s&&(m.key==="ArrowLeft"?(m.preventDefault(),s(-uc)):m.key==="ArrowRight"&&(m.preventDefault(),s(uc)))},className:"shrink-0 flex items-center justify-center",style:{position:"relative",width:12,cursor:"col-resize",outline:"none",background:f?"rgba(215,255,99,.07)":"var(--bg-deep)",transition:"background .15s"},children:t.jsx("div",{"data-testid":"panel-divider-grip",style:{width:4,height:f?52:36,borderRadius:99,background:f?"var(--accent-active)":"var(--line-strong)",transition:"background .15s, height .15s"}})})}const dse=Object.freeze(Object.defineProperty({__proto__:null,DIVIDER_KEYBOARD_STEP:uc,PanelDivider:iN},Symbol.toStringTag,{value:"Module"})),f8=[{key:"editor",label:"Editor"},{key:"preview",label:"Preview"}];function lN({active:e,onChange:n,isAgentBuilding:s=!1,buildIdle:r=!1}){const a=s&&!r,o=r;return t.jsx("div",{"data-testid":"mobile-pane-switcher",className:"shrink-0 flex w-full",style:{background:"var(--bg-deep)",...Gr("top"),paddingBottom:"env(safe-area-inset-bottom)"},children:f8.map(i=>{const c=e===i.key;return t.jsxs("button",{"data-testid":`mobile-pane-switcher-${i.key}`,onClick:()=>n(i.key),"aria-pressed":c,className:`flex-1 flex items-center justify-center gap-1 h-12 text-sm transition-colors cursor-pointer ${c?"text-white font-medium":"text-[#8E8E8E] hover:text-white font-light"}`,children:[i.key==="editor"&&a&&t.jsx(xr,{}),i.key==="editor"&&o&&t.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 use=Object.freeze(Object.defineProperty({__proto__:null,MobilePaneSwitcher:lN},Symbol.toStringTag,{value:"Module"}));function m8(e){return e.replace(/^https?:\/\//,"")}function pc({url:e}){const[n,s]=l.useState(0),r="grid h-7 w-7 shrink-0 place-items-center rounded-md text-[var(--text-muted)] hover:bg-white/10 hover:text-[var(--text-primary)] cursor-pointer";return t.jsxs("section",{"aria-label":"Web page","data-testid":"web-panel",className:"flex h-full min-h-0 w-full flex-col overflow-hidden rounded-xl border border-white/10 bg-[var(--bg-card)]",children:[t.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1.5 border-b border-white/[.06] px-2",children:[t.jsx("button",{type:"button","aria-label":"Reload",title:"Reload",onClick:()=>s(a=>a+1),className:r,children:t.jsx("span",{"aria-hidden":"true",children:"↻"})}),t.jsx("div",{className:"min-w-0 flex-1 truncate rounded-md bg-white/[.04] px-2.5 py-1 text-xs text-[var(--text-secondary)]",title:e,children:m8(e)}),t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer","aria-label":"Open in a new tab",title:"Open in a new tab",className:r,children:t.jsx("span",{"aria-hidden":"true",children:"↗"})}),t.jsx("button",{type:"button","aria-label":"Close",title:"Close",onClick:fx,className:r,children:t.jsx("span",{"aria-hidden":"true",children:"×"})})]}),t.jsxs("div",{className:"relative min-h-0 flex-1 bg-white",children:[t.jsxs("div",{"data-testid":"web-panel-blank-hint",className:"absolute inset-0 flex flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx("p",{className:"max-w-[300px] text-[13px] leading-relaxed text-neutral-500",children:"Still blank? Some sites can't be shown inside the editor."}),t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"rounded-lg bg-neutral-900 px-3.5 py-2 text-[13px] font-medium text-white hover:bg-neutral-700",children:"Open it in a new tab ↗"})]}),t.jsx("iframe",{src:e,title:e,className:"absolute inset-0 h-full w-full border-0 bg-transparent",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"},`${e}#${n}`)]})]})}const pse=Object.freeze(Object.defineProperty({__proto__:null,WebPanel:pc},Symbol.toStringTag,{value:"Module"}));function cN({isCollapsed:e,leftPane:n,onResizeStart:s,onResizeReset:r,onResizeNudge:a,isResizing:o=!1,leftWidth:i,leftWidthMin:c,previewPane:d,splitRef:u,isNarrow:p,mobilePane:h,onMobilePaneChange:f,isAgentBuilding:m=!1,buildIdle:g=!1,hidePreview:x=!1,onHomeLivePageBack:b}){const y=l.useSyncExternalStore(jM,vM);l.useEffect(()=>p?void 0:_M(),[p]);const v=j=>t.jsxs("div",{className:"relative flex min-w-0 flex-1",children:[j,y&&t.jsx("div",{className:"absolute inset-0 z-30 p-2",style:{background:"var(--bg-deep)"},children:t.jsx(pc,{url:y})})]});return p?t.jsxs("div",{ref:u,className:"fixed inset-0 flex flex-col",style:{background:"var(--bg-deep)"},children:[t.jsxs("div",{className:"flex-1 min-h-0 relative",children:[t.jsx("div",{className:`absolute inset-0 flex ${h==="editor"?"":"hidden"}`,children:n}),t.jsx("div",{className:`absolute inset-0 flex ${h==="preview"?"":"hidden"}`,children:d})]}),t.jsx(lN,{active:h,onChange:f,isAgentBuilding:m,buildIdle:g})]}):b?t.jsx("div",{ref:u,className:"fixed inset-0 flex",style:{background:"var(--bg-deep)"},children:v(d)}):x?t.jsxs("div",{ref:u,className:"fixed inset-0 flex",style:{background:"var(--bg-surface)"},children:[n,y&&t.jsx("div",{className:"w-[46%] min-w-[360px] shrink-0 p-2",style:{background:"var(--bg-deep)"},children:t.jsx(pc,{url:y})})]}):t.jsxs("div",{ref:u,className:"fixed inset-0 flex",style:{background:"var(--bg-deep)"},children:[!e&&t.jsxs(t.Fragment,{children:[n,t.jsx(iN,{onMouseDown:s,onReset:r,onNudge:a,isDragging:o,valueNow:i,valueMin:c})]}),v(d)]})}const hse=Object.freeze(Object.defineProperty({__proto__:null,EditorShellLayout:cN},Symbol.toStringTag,{value:"Module"}));function jp(){const[e,n]=l.useState([]),[s,r]=l.useState(!0),[a,o]=l.useState(null),{plansVersion:i,claimsVersion:c}=Tn(),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 p=await u.json();n(Array.isArray(p)?p:[])}catch(u){o(u instanceof Error?u.message:"Failed to load plan claims")}finally{r(!1)}},[]);return l.useEffect(()=>{d()},[d,i,c]),{claims:e,loading:s,error:a,refetch:d}}function wp(){const[e,n]=l.useState(null),{claimsVersion:s}=Tn(),r=l.useCallback(async()=>{try{const a=await fetch("/api/plan-claims/sync-status");if(!a.ok)return;const o=await a.json();n(o)}catch{}},[]);return l.useEffect(()=>{r()},[r,s]),l.useEffect(()=>{const a=setInterval(()=>void r(),1e4);return()=>clearInterval(a)},[r]),{status:e}}function g8(){const[e,n]=l.useState(null),s=l.useCallback(async()=>{try{const r=await fetch("/api/server/staleness");if(!r.ok)return;const a=await r.json();n(a)}catch{}},[]);return l.useEffect(()=>{s()},[s]),l.useEffect(()=>{const r=setInterval(()=>void s(),6e4);return()=>clearInterval(r)},[s]),{staleness:e}}const Wi="codeyam-editor editor plan-claims-status",x8="git push origin HEAD";function dN(e,n){switch(e){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:x8};case"network":return{message:"Plan tracking can't reach the remote (network failure). Check connectivity, then run the command below for details.",command:Wi};case"git-spawn":return{message:"Plan tracking can't launch git. Run the command below for the failing invocation.",command:Wi};default:return{message:`Plan tracking is failing (${n} failed ticks). Teammates' in-flight plans may not appear. Run the command below for details.`,command:Wi}}}function uN({status:e}){const n=(e==null?void 0:e.consecutiveFailures)??0;if((e==null?void 0:e.enabled)===!1||n<3)return null;const{message:s,command:r}=dN(e==null?void 0:e.lastErrorCategory,n);return t.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-3","data-testid":"plan-claim-sync-banner",role:"alert",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-amber-600 text-lg leading-none mt-0.5","aria-hidden":"true",children:"!"}),t.jsxs("div",{className:"flex-1 min-w-0 text-sm text-amber-800",children:[s," ",t.jsx("code",{className:"text-xs",children:r})," ",t.jsx(ct,{text:r,label:"Copy command",copiedLabel:"Copied",ariaLabel:"Copy the plan-tracking diagnostic command",className:"underline text-amber-700 hover:text-amber-900 disabled:opacity-50"})]})]})})}const fse=Object.freeze(Object.defineProperty({__proto__:null,PlanClaimSyncBanner:uN,planClaimSyncBannerContent:dN},Symbol.toStringTag,{value:"Module"})),um="codeyam-editor editor restart-server";function _p({staleness:e,backendOutOfDate:n=!1}){var a;const s=!!(e!=null&&e.stale);if(!s&&!n)return null;const r=((a=e==null?void 0:e.info)==null?void 0:a.minutesStale)??0;return t.jsx("div",{className:"mt-3 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:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-lg leading-none mt-0.5","aria-hidden":"true",style:{color:"var(--red-300)"},children:"!"}),t.jsxs("div",{className:"flex-1 min-w-0 text-sm",style:{color:"var(--text-body)"},children:[s?t.jsxs(t.Fragment,{children:["The editor is running an older version of itself (rebuilt"," ",r," min ago) and needs restarting to pick up the latest plan tracking fixes."]}):t.jsx(t.Fragment,{children:"The editor is running an older version of itself, which can’t drive the Build tab. Restarting it reconnects everything."})," ","Run"," ",t.jsx("code",{className:"text-xs",style:{color:"var(--text-strong)"},children:um}),"."," ",t.jsx(ct,{text:um,label:"Copy command",copiedLabel:"Copied",ariaLabel:"Copy the editor restart command",className:"underline disabled:opacity-50"})]})]})})}const mse=Object.freeze(Object.defineProperty({__proto__:null,ServerStalenessBanner:_p},Symbol.toStringTag,{value:"Module"}));function Sp(e){const n=new Map;for(const s of e){const r=n.get(s.slug);(!r||r.source!=="local"&&s.source==="local")&&n.set(s.slug,s)}return n}function b8(e){var s;const n=new Set;for(const r of e){const a=(s=r==null?void 0:r.email)==null?void 0:s.trim().toLowerCase();a&&n.add(a)}return n.size}function pN(e){return b8(e)>=2}function y8(e,n){return e.filter(s=>s.source==="local"||!n.has(s.slug))}function kp(e){const{slugs:n}=td();return l.useMemo(()=>{const s={},r={};for(const a of e){const o=a.dependsOn??[];if(o.length===0)continue;const i=k6({...a,dependsOn:o},e,n);r[a.slug]=i;const c=$k(i);c.length!==0&&(s[a.slug]={count:c.length,tooltip:c.map(d=>d.title??`missing: ${d.slug}`).join(", ")})}return{annotationsBySlug:s,dependenciesBySlug:r}},[e,n])}async function hN({send:e,waitForIdle:n,ceilingMs:s,payload:r,sendPayload:a=e}){const o=e("\x1B"),i=n(s);if(await o,await i,!r.endsWith("\r")){await a(r);return}await a(r.slice(0,-1)),await new Promise(c=>setTimeout(c,Kc)),await a("\r")}let Ps={hasActiveSession:!1,isAgentBuilding:!1,stepStateFeature:null};function ri(e){Ps={...Ps,...e}}function v8(){return Ps}function j8(){return Ps.hasActiveSession||Ps.isAgentBuilding||!!Ps.stepStateFeature}function pm(e){return xg("build-agent-idle",e)}const w8=5e3,hm=wr,fm="The session could not be started because the Build terminal never opened, so the launch commands had nowhere to go.";async function fN(){let e=!1,n;try{const s=await fetch("/api/session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear"})});n=s.status,s.ok&&(e=!0)}catch{}e&&ri({hasActiveSession:!1,isAgentBuilding:!1,stepStateFeature:null}),pe("clear-editor-session",{ok:e,...n!==void 0?{status:n}:{},snapshotReset:e})}async function _8(){let e=!1,n;try{const s=await fetch("/api/stop-building",{method:"POST",headers:{"Content-Type":"application/json"}});n=s.status,s.ok&&(e=!0)}catch{}e&&ri({hasActiveSession:!1,isAgentBuilding:!1,stepStateFeature:null}),pe("stop-building",{ok:e,...n!==void 0?{status:n}:{},snapshotReset:e})}async function S8(){let e=!1,n;try{const s=await fetch("/api/reset-everything",{method:"POST",headers:{"Content-Type":"application/json"}});n=s.status,s.ok&&(e=!0)}catch{}e&&ri({hasActiveSession:!1,isAgentBuilding:!1,stepStateFeature:null}),pe("reset-everything",{ok:e,...n!==void 0?{status:n}:{},snapshotReset:e})}function k8(e){return e==="gemini"||e==="opencode"||e==="muse"}async function mN(e={}){const n=v8(),s=e.caller??"unknown",r=e.bypassLiveGuard===!0;if(j8()&&!r){pe("launch-editor-skill",{caller:s,suppressed:!0,snapshot:n,bypassLiveGuard:!1});return}if(f$(),pe("launch-editor-skill",{caller:s,suppressed:!1,snapshot:n,bypassLiveGuard:r}),k8(e.provider))return;if(HS(e.renameLabel??"Editor",s,gg),e.serverOwnsLaunch){pe("launch-editor-skill",{caller:s,serverOwnsLaunch:!0});return}const a=R$()??await E$(w8);if(pe("launch-editor-skill-owner",{caller:s,owner:a.owner,basis:a.basis}),a.basis==="no-answer"&&!bg())throw pe("launch-editor-skill",{caller:s,suppressed:!1,droppedNoTerminal:!0}),new Error(fm);if(a.owner==="server")return;const o=a.launchId??hg(),i=(c,d,u)=>async p=>{await c(p),el({launchId:o,role:"build",event:"prompt-written",kind:d,command:u})};try{let c=Promise.resolve();const d=i(yh,"ui-clear","/clear");await hN({send:i(qR,"ui-escape"),sendPayload:u=>{const p=d(u);return c=pm(hm),p},waitForIdle:pm,ceilingMs:hm,payload:"/clear"}),await c,await i(yh,"ui-skill","/codeyam-editor")("/codeyam-editor")}catch(c){throw c instanceof UR?(pe("launch-editor-skill",{caller:s,suppressed:!1,droppedNoTerminal:!0}),new Error(fm)):c}}async function gN(e=1500){try{const n=await fetch("/api/session-info",{credentials:"same-origin",cache:"no-store",signal:AbortSignal.timeout(e)});if(!n.ok)return null;const s=await n.json();return typeof(s==null?void 0:s.agentBrokerLive)=="boolean"?s.agentBrokerLive:null}catch{return null}}function Np(e,n=!1,s=n){const r=xE(e),a=n&&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(()=>{s&&r==="build"&&window.history.replaceState(null,"",cn("home"))},[s,r]);const u=l.useCallback(f=>{if(n&&f==="build"){window.history.pushState(null,"",cn("home"));return}window.history.pushState(null,"",cn(f)),f==="build"&&i(!0),f==="plan"&&d(!0)},[n]),p=l.useCallback(()=>{n||(window.history.pushState(null,"",cn("build")),i(!0))},[n]),h=l.useCallback(()=>{i(!1)},[]);return{activeTab:a,buildActivated:o,planActivated:c,navigateToTab:u,showBuildTab:p,deactivateBuild:h}}const N8=15e3;function C8(e,n){const s=`/api/plans/${encodeURIComponent(e)}/select`;return n?`${s}?source=${encodeURIComponent(n)}`:s}function xN(e={}){const{launchAnchored:n=!1}=e,{showBuildTab:s}=Np(typeof window>"u"?"/":window.location.pathname),{config:r}=St(),[a,o]=l.useState(null),[i,c]=l.useState(null),d=l.useRef(null),u=l.useCallback(()=>{d.current!==null&&(clearTimeout(d.current),d.current=null)},[]),p=l.useCallback(()=>{u(),o(null)},[u]);l.useEffect(()=>{a!==null&&n&&p()},[a,n,p]),l.useEffect(()=>u,[u]);const h=l.useCallback(async(f,m,g)=>{if(a)return!1;c(null),o(f);let x=null;try{x=await gN();try{await fN(),Xk()}catch{}const b=await fetch(C8(f,g),{method:"POST"});if(!b.ok){let y=`HTTP ${b.status}`;try{const v=await b.json();v!=null&&v.error&&(y=v.error)}catch{}throw new Error(y)}s()}catch(b){return c(b instanceof Error?b.message:"Failed to launch plan"),p(),!1}return u(),d.current=setTimeout(()=>{d.current=null,o(null)},N8),mN({caller:"plan-launcher",renameLabel:m,provider:r==null?void 0:r.provider,bypassLiveGuard:!0,serverOwnsLaunch:x===!1}).catch(b=>{c(b instanceof Error?b.message:"Failed to launch plan")}),!0},[a,s,r==null?void 0:r.provider,p,u]);return{launchingSlug:a,error:i,launchPlan:h}}function bN({onClose:e}){const n=s=>{s.target===s.currentTarget&&e()};return t.jsx("div",{"data-testid":"plan-run-blocked-modal",onClick:n,className:"absolute inset-0 z-10 flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},children:t.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:[t.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"Build in progress"}),t.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:Wg}),t.jsx("div",{className:"flex flex-col gap-3",children:t.jsx("button",{onClick:e,"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 gse=Object.freeze(Object.defineProperty({__proto__:null,PlanRunBlockedModal:bN},Symbol.toStringTag,{value:"Module"}));function yN({deps:e,onClose:n}){const s=r=>{r.target===r.currentTarget&&n()};return t.jsx("div",{"data-testid":"plan-run-dependencies-modal",onClick:s,className:"absolute inset-0 z-10 flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},children:t.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:[t.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"Prerequisite plans not yet built"}),t.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."}),t.jsx("ul",{className:"flex flex-col gap-1.5 mb-4",children:e.map(r=>t.jsx("li",{"data-testid":`plan-dep-${r.slug}`,className:"text-sm text-[var(--text-primary)]",children:r.title===null?t.jsxs("span",{className:"text-[var(--text-muted)]",children:["missing: ",r.slug," — was the prerequisite plan deleted?"]}):r.title},r.slug))}),t.jsx("div",{className:"flex flex-col gap-3",children:t.jsx("button",{onClick:n,"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 xse=Object.freeze(Object.defineProperty({__proto__:null,PlanRunDependenciesModal:yN},Symbol.toStringTag,{value:"Module"}));function vN({claim:e,onCancel:n,onConfirm:s}){const r=us(),a=e.claimedBy.agentProvider??"agent",o=e.claimedBy.currentStep??"unknown",i=e.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 p=h=>{h.key==="Escape"&&n()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[n]);const u=p=>{p.target===p.currentTarget&&n()};return t.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:t.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:[t.jsx("h2",{"data-testid":"plan-foreign-claim-heading",className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:c}),t.jsxs("div",{className:"text-sm text-[var(--text-muted)] mb-4 flex flex-col gap-1",children:[t.jsxs("span",{"data-testid":"plan-foreign-claim-identity",children:["claimed by ",a,"@",e.claimedBy.machine]}),t.jsxs("span",{children:["started ",Un(e.claimedBy.startedAt,r)]}),t.jsxs("span",{"data-testid":"plan-foreign-claim-step",children:["on step ",o," (",Un(e.currentStepEnteredAt,r)," on step)"]})]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("button",{onClick:n,"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"}),t.jsx("button",{onClick:s,"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 bse=Object.freeze(Object.defineProperty({__proto__:null,PlanRunForeignClaimModal:vN},Symbol.toStringTag,{value:"Module"}));function ai({dependenciesBySlug:e,claimsBySlug:n,isAgentBuilding:s=!1,onLaunch:r}){const[a,o]=l.useState(!1),[i,c]=l.useState(null),[d,u]=l.useState(null),p=m=>{if(s){o(!0);return}const g=$k(e[m]??[]);if(g.length>0){c(g);return}const x=n.get(m);if(x&&x.source!=="local"){u(x);return}r(m)},h=()=>{const m=d;if(m){if(u(null),m.sessionAlive===!1){fetch(`/api/plan-claims/${encodeURIComponent(m.slug)}/reclaim`,{method:"POST"}).catch(()=>{}).finally(()=>r(m.slug));return}r(m.slug)}},f=t.jsxs(t.Fragment,{children:[a&&t.jsx(bN,{onClose:()=>o(!1)}),i&&t.jsx(yN,{deps:i,onClose:()=>c(null)}),d&&t.jsx(vN,{claim:d,onCancel:()=>u(null),onConfirm:h})]});return{requestRun:p,gateModals:f}}function T8(e){const n=/^(\d{1,2})-/.exec(e);return n?parseInt(n[1],10):null}function P8(e,n){if(!n)return null;const s=e?n.selectedMockup:n.filename;return typeof s=="string"&&s.length>0?s:null}function O8(e){return e?`.codeyam/design/rounds/${e}/`:".codeyam/design/project_mockups/"}function R8(e){if(e.designs.length===0)return"";const n=e.designs.map((a,o)=>`${T8(a)??o+1}: ${a}`).join(", "),s=e.roundId?`design round ${e.roundId}`:"project designs",r=e.selected??"none yet";return`(The user is looking at the ${s} in the preview. Designs by the number shown on each card: ${n}. Selected: ${r}. Files are in ${O8(e.roundId)})`}function E8(e){const n=qr(e),[s,r]=l.useState(null);return l.useEffect(()=>{if(!e||n===void 0){r(null);return}let a=!1;return(async()=>{try{const o=n?`/api/editor-mockups?round=${encodeURIComponent(n)}`:"/api/editor-mockups",i=n?"/api/editor-design-round":"/api/editor-design-selection",[c,d]=await Promise.all([fetch(o),fetch(i)]);if(!c.ok)return;const u=await c.json(),p=d.ok?await d.json():null;if(a)return;r({roundId:n,designs:Array.isArray(u)?u.map(h=>h.filename):[],selected:P8(n,p)})}catch{}})(),()=>{a=!0}},[e,n]),s}const jN="codeyam.";function A8(e){try{const n=window.sessionStorage.getItem(jN+e);if(n===null)return null;const s=Number.parseInt(n,10);return Number.isInteger(s)&&s>=0?s:null}catch{return null}}function M8(e,n){try{window.sessionStorage.setItem(jN+e,String(n))}catch{}}function mm(e,n,s=3){const r=l.useRef(void 0);return r.current===void 0&&(r.current=A8(e)),l.useEffect(()=>{n!==null&&M8(e,n)},[e,n]),r.current??s}function wN(e){return{reorderPlans:l.useCallback(async s=>{const r=await fetch("/api/plans/reorder",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slugs:s})});if(!r.ok){const a=await r.json().catch(()=>({}));throw new Error(a.error??`HTTP ${r.status}`)}e==null||e()},[e])}}function I8(){const[e,n]=l.useState(!1),s=qr();return l.useEffect(()=>{if(s===void 0)return;let r=!1;return(async()=>{try{const a=s?`/api/editor-mockups?round=${encodeURIComponent(s)}`:"/api/editor-mockups",o=await fetch(a);if(!o.ok)return;const i=await o.json();if(r)return;n(Array.isArray(i)&&i.length>0)}catch{}})(),()=>{r=!0}},[s]),e}function _N({onToggleDesigns:e,designsOpen:n}){return I8()?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-md, 12px)",marginTop:"var(--spacing-md, 12px)",padding:"10px 14px",borderRadius:10,border:"1px solid var(--border-default)",background:"var(--bg-card, #1a1a1a)"},children:[t.jsx("span",{style:{flex:1,fontSize:"var(--text-sm, 14px)",color:"var(--text-secondary)"},children:n?"Your designs are open in the preview. Close them to get the app back.":"Your designs are still here. Open them to compare, customize, or pick a different one."}),t.jsx("button",{type:"button",onClick:e,style:{padding:"6px 12px",borderRadius:8,border:"1px solid var(--accent-active, #D7FF63)",background:"transparent",color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",cursor:"pointer",whiteSpace:"nowrap"},children:n?"Close designs":"Open designs"})]}):null}const yse=Object.freeze(Object.defineProperty({__proto__:null,PlanDesignsReturnRow:_N},Symbol.toStringTag,{value:"Module"}));function D8(e){return`${e} will remember your plans and suggest them once the current building session is over.`}function SN({providerLabel:e}){return t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:"text-lg font-medium text-[var(--text-primary)]",children:"Plan your next move"}),t.jsx("p",{className:"mt-1 text-sm text-[var(--text-dim)]",children:D8(e)})]})}const vse=Object.freeze(Object.defineProperty({__proto__:null,PlanTabHeader:SN},Symbol.toStringTag,{value:"Module"}));function L8(e,n){const r=kr(e)||"(no request yet, ask the user what to change)";return kr(`Tweak: ${r} ${n}`)}const gm="plan";function kN({onClose:e,slashCommand:n=Pb,seedText:s}){l.useEffect(()=>Pd(gm),[]);const{plans:r}=Ir();return t.jsx(Vr,{label:"Plan agent",sessionName:"plan session",height:"min(620px, 68vh)",onClose:e,onNeedsYouChange:lB,onWorkingChange:uB,startFreshOnNewRequest:!0,initialRequest:s??null,renderWrittenFile:a=>{const o=r.find(i=>i.filePath.split("/").pop()===a);return o?t.jsx(_x,{title:o.title,body:o.body}):null},renderTerminal:a=>t.jsx(qt,{chatName:gm,slashCommand:n,seedText:s,height:"100%",onClose:e,binding:a})})}const jse=Object.freeze(Object.defineProperty({__proto__:null,PlanAuthoringChat:kN},Symbol.toStringTag,{value:"Module"}));function NN({chatOpen:e,onChatToggle:n,onChatClose:s,initialDraft:r="",planCompleteSignal:a=0,designContext:o=null}){const i=Uu(Pb,r),c=Oo();Yu(a,()=>{i.clearDraft(),c.clear()});const d=o?R8(o):"",u=(o==null?void 0:o.designs.length)??0,[p,h]=l.useState(null),f=p!==null,m=!e&&!f,g=y=>{const v=[y,d].filter(Boolean).join(" ");i.open(v||void 0),n()},x=()=>{if(e){n();return}if(c.files.length===0){g("");return}c.save().then(y=>{y!==null&&g(y)})},b=()=>{i.close(),s()};return t.jsxs("div",{"data-testid":"describe-pane",children:[m&&t.jsx(Ws,{value:i.draft,onChange:i.setDraft,testId:"plan-describe-input",onSubmit:x,files:c.files,onAddFiles:c.addFiles,onRemoveFile:c.removeFile,busy:c.saving,error:c.error}),m&&d&&t.jsx(Ib,{count:u,selected:(o==null?void 0:o.selected)??null}),m&&d&&t.jsx("div",{style:{display:"flex",gap:8,alignItems:"center"},children:t.jsx(Mb,{onClick:()=>h(L8(i.draft,d))})}),f&&t.jsx(Eb,{seedText:p,onClose:()=>h(null)}),e&&t.jsx(kN,{onClose:b,slashCommand:i.seededCommand??void 0,seedText:i.seedText??void 0})]})}const wse=Object.freeze(Object.defineProperty({__proto__:null,DescribePane:NN},Symbol.toStringTag,{value:"Module"}));function CN({claim:e}){const n=us(),s=e.claimedBy.agentProvider??"agent",r=e.claimedBy.machine,a=e.claimedBy.currentStep??null,o=Un(e.currentStepEnteredAt,n),i=Un(e.claimedBy.startedAt,n),{dead:c}=qy(e);return t.jsxs("li",{className:"flex flex-col gap-1 rounded-lg border border-[var(--border-subtle)] bg-[var(--bg-surface,transparent)] px-3 py-2","data-testid":`in-flight-row-${e.slug}`,"data-session-alive":c?"false":void 0,children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"font-medium text-sm text-[var(--text-default)]",children:e.title}),t.jsx(Fd,{testId:`in-flight-source-${e.slug}`,children:e.source})]}),t.jsx(Wy,{slug:e.slug,identity:`${s}@${r}`,step:a?`step ${a} · ${o} on step`:null,age:i,dead:c})]})}const _se=Object.freeze(Object.defineProperty({__proto__:null,InFlightPlanRow:CN},Symbol.toStringTag,{value:"Module"}));function TN({claims:e}){const[n,s]=l.useState(!1);return e.length===0?null:t.jsxs("div",{className:"mt-5 border-t border-[var(--border-subtle)] pt-5","data-testid":"in-flight-section",children:[t.jsx(zs,{title:"In Flight",count:e.length,expanded:n,onToggle:()=>s(r=>!r),testId:"in-flight-header"}),n&&t.jsx("ul",{className:"mt-3 flex flex-col gap-2","data-testid":"in-flight-list",children:e.map(r=>t.jsx(CN,{claim:r},`${r.slug}:${r.claimedBy.machine}:${r.claimedBy.sessionId}:${r.claimedBy.pid}:${r.claimedBy.startedAt}`))})]})}const Sse=Object.freeze(Object.defineProperty({__proto__:null,InFlightSection:TN},Symbol.toStringTag,{value:"Module"})),F8=5e3;function $8(){const[e,n]=l.useState([]),[s,r]=l.useState(null),[a,o]=l.useState(null),[i,c]=l.useState(!0),[d,u]=l.useState(null),p=l.useRef(!1),h=l.useCallback(async()=>{c(!0),u(null);try{const g=await fetch("/api/branch-queue/status");if(!g.ok)throw new Error(`HTTP ${g.status}`);const x=await g.json();if(p.current)return;n(Array.isArray(x.entries)?x.entries:[]),r(x.branch??null),o(x.remote??null)}catch(g){if(p.current)return;u(g instanceof Error?g.message:"Failed to load branch queue"),n([])}finally{p.current||c(!1)}},[]);l.useEffect(()=>{p.current=!1,h();const g=setInterval(()=>{document.visibilityState!=="hidden"&&h()},F8),x=()=>{document.visibilityState==="visible"&&h()};return document.addEventListener("visibilitychange",x),()=>{p.current=!0,clearInterval(g),document.removeEventListener("visibilitychange",x)}},[h]);const f=l.useCallback(async(g,x,b)=>{const y={uuid:g,priority:x};typeof b=="number"&&(y.expectedPriority=b);const v=await fetch("/api/branch-queue/set-priority",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(y)});if(!v.ok){const j=await v.text().catch(()=>"");throw new Error(`set-priority ${v.status}: ${j}`)}await h()},[h]),m=l.useCallback(async g=>{const x=await fetch("/api/branch-queue/release",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({uuid:g})});if(!x.ok){const b=await x.text().catch(()=>"");throw new Error(`release ${x.status}: ${b}`)}await h()},[h]);return{entries:e,branch:s,remote:a,loading:i,error:d,setPriority:f,release:m,refetch:h}}function z8(){const[e,n]=l.useState(null),[s,r]=l.useState(null),a=l.useCallback(c=>{n(c)},[]),o=l.useCallback(c=>{r(c)},[]),i=l.useCallback(()=>{n(null),r(null)},[]);return{dragSourceUuid:e,dragOverUuid:s,beginDrag:a,hoverOver:o,reset:i}}function B8(e,n){const s=new Map(n.map(i=>[i.uuid,i])),r=[],a=new Set;for(const i of e.order){const c=s.get(i.uuid);c&&(r.push(c),a.add(i.uuid))}for(const i of n)a.has(i.uuid)||(r.push(i),a.add(i.uuid));const o=new Set;for(const i of e.releasedUuids)s.has(i)&&o.add(i);return{order:r,releasedUuids:o}}const W8=new Set;function Hi(e,n){return e??{order:[...n],releasedUuids:new Set}}function H8(){const[e,n]=l.useState(null),s=l.useCallback(p=>e?e.order:p,[e]),r=l.useCallback((p,h,f)=>{n(m=>{const g=Hi(m,f),x=g.order.findIndex(y=>y.uuid===p),b=g.order.findIndex(y=>y.uuid===h);return x===-1||b===-1||x===b?g:{...g,order:Er(g.order,x,b)}})},[]),a=l.useCallback((p,h,f)=>{n(m=>{const g=Hi(m,f),x=g.order.findIndex(y=>y.uuid===p);if(x===-1)return g;const b=x-h;return b<0||b>=g.order.length?g:{...g,order:Er(g.order,x,b)}})},[]),o=l.useCallback((p,h)=>{n(f=>{const m=Hi(f,h),g=new Set(m.releasedUuids);return g.has(p)?g.delete(p):g.add(p),{...m,releasedUuids:g}})},[]),i=l.useCallback(p=>{n(h=>h?B8(h,p):null)},[]),c=l.useCallback(()=>n(null),[]),d=l.useCallback(p=>e?e.releasedUuids.size>0||e.order.length!==p.length?!0:e.order.some((h,f)=>{var m;return h.uuid!==((m=p[f])==null?void 0:m.uuid)}):!1,[e]),u=l.useCallback(p=>{var x,b;if(!e)return 0;const h=e.releasedUuids,f=p.filter(y=>!h.has(y.uuid)),m=e.order.filter(y=>!h.has(y.uuid));let g=0;for(let y=0;y<m.length;y++)((x=m[y])==null?void 0:x.uuid)!==((b=f[y])==null?void 0:b.uuid)&&g++;return g},[e]);return{isActive:e!==null,displayEntries:s,releasedUuids:(e==null?void 0:e.releasedUuids)??W8,isDirty:d,reorderedCount:u,releasedCount:(e==null?void 0:e.releasedUuids.size)??0,moveByDrag:r,nudge:a,toggleRelease:o,reconcile:i,reset:c}}const q8=10;function U8(e,n,s){const r=new Map(s.map(d=>[d.uuid,d])),a=s.filter(d=>n.has(d.uuid)).map(d=>d.uuid),o=e.filter(d=>!n.has(d.uuid)),i=o.length,c=[];return o.forEach((d,u)=>{const p=r.get(d.uuid);if(!p)return;const h=(i-u)*q8;p.meta.priority!==h&&c.push({uuid:d.uuid,priority:h,expectedPriority:p.meta.priority})}),{releases:a,priorities:c}}function PN({priority:e,uuid:n,onNudge:s}){const r=e===0?"priority 0":e>0?`priority +${e}`:`priority ${e}`;return t.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-${n}`,children:[t.jsx("button",{type:"button",className:"text-[var(--text-dim)] hover:text-[var(--text-default)] px-0.5","data-testid":`commit-queue-nudge-down-${n}`,onClick:()=>void s(-1),"aria-label":"Lower priority",children:"−"}),t.jsx("span",{"data-testid":`commit-queue-priority-value-${n}`,children:r}),t.jsx("button",{type:"button",className:"text-[var(--text-dim)] hover:text-[var(--text-default)] px-0.5","data-testid":`commit-queue-nudge-up-${n}`,onClick:()=>void s(1),"aria-label":"Raise priority",children:"+"})]})}const kse=Object.freeze(Object.defineProperty({__proto__:null,CommitQueuePriorityChip:PN},Symbol.toStringTag,{value:"Module"}));function ON({entry:e,isHead:n}){const s=us(),r=e.meta.agentProvider??"agent",a=e.meta.machine,o=e.meta.currentStep??null,i=Un(e.meta.startedAt??e.committerDate,s);return t.jsxs("div",{className:"flex-1 flex flex-col gap-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium text-[var(--text-default)] truncate",title:a,"data-testid":`commit-queue-machine-${e.uuid}`,children:a}),n&&t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-[var(--accent-strong)]","data-testid":`commit-queue-head-marker-${e.uuid}`,children:"← head"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-[var(--text-muted)]",children:[t.jsx("span",{"data-testid":`commit-queue-agent-${e.uuid}`,children:r}),o&&t.jsxs("span",{"data-testid":`commit-queue-step-${e.uuid}`,children:["step ",o]}),t.jsxs("span",{"data-testid":`commit-queue-started-${e.uuid}`,children:["started ",i]}),t.jsxs("span",{"data-testid":`commit-queue-pid-${e.uuid}`,children:["pid ",e.meta.pid]})]})]})}const Nse=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueRowIdentity:ON},Symbol.toStringTag,{value:"Module"}));function RN({entry:e,position:n,isHead:s,markedForRelease:r,expanded:a,onToggleExpanded:o,onPriorityNudge:i,onToggleRelease:c,onDragStart:d,onDragOver:u,onDrop:p,isDragging:h,isDragOver:f}){return t.jsxs("li",{"data-testid":`commit-queue-row-${e.uuid}`,draggable:!0,onDragStart:m=>{m.dataTransfer.effectAllowed="move",m.dataTransfer.setData("text/plain",e.uuid),d()},onDragOver:m=>{m.preventDefault(),m.dataTransfer.dropEffect="move",u()},onDrop:m=>{m.preventDefault(),p()},"data-marked-for-release":r||void 0,className:`group flex flex-wrap items-center gap-y-2 rounded border px-3 py-2 ${s?"border-[var(--accent-strong)]":"border-[var(--border-subtle)]"} ${h?"opacity-40":""} ${f?"ring-2 ring-[var(--accent-strong)]":""} ${r?"opacity-50 line-through":""}`,children:[t.jsxs("div",{className:"flex w-full min-w-0 flex-wrap items-center gap-3",children:[t.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-${e.uuid}`,children:"⋮⋮"}),t.jsxs("span",{className:"text-xs font-mono text-[var(--text-dim)] w-6 text-right","data-testid":`commit-queue-position-${e.uuid}`,children:[n,"."]}),t.jsxs("button",{type:"button",onClick:o,"aria-expanded":a,"data-testid":`commit-queue-toggle-${e.uuid}`,className:"flex min-w-0 flex-1 basis-48 items-center gap-2 bg-transparent text-left cursor-pointer",children:[t.jsx(ON,{entry:e,isHead:s}),t.jsx(Dr,{expanded:a,testId:`commit-queue-chevron-${e.uuid}`})]}),t.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:[t.jsx(PN,{priority:e.meta.priority,uuid:e.uuid,onNudge:i}),t.jsx(Od,{uuid:e.uuid,markedForRelease:r,onToggle:c})]})]}),a&&t.jsx("div",{className:"w-full border-t border-[var(--border-subtle)] pt-2",children:t.jsx(zb,{entry:e,markedForRelease:r,onToggleRelease:c})})]})}const Cse=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueRow:RN},Symbol.toStringTag,{value:"Module"}));function EN({reorderedCount:e,releasedCount:n,saving:s,onSave:r,onCancel:a}){const o=[];e>0&&o.push(`${e} reordered`),n>0&&o.push(`${n} to remove`);const i=o.join(" · ")||"Unsaved changes";return t.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:[t.jsx("span",{className:"text-xs text-[var(--text-muted)]","data-testid":"commit-queue-save-summary",children:i}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button","data-testid":"commit-queue-cancel",onClick:a,disabled:s,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"}),t.jsx("button",{type:"button","data-testid":"commit-queue-save",onClick:r,disabled:s,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:s?"Saving…":"Save"})]})]})}const Tse=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueSaveBar:EN},Symbol.toStringTag,{value:"Module"}));function AN({entriesOverride:e,branchOverride:n}={}){const s=$8(),r=e!==void 0,a=e??s.entries,o=n??s.branch,i=z8(),c=H8(),{reconcile:d}=c,[u,p]=l.useState(null),[h,f]=l.useState(!0),[m,g]=l.useState(!1),[x,b]=l.useState(null);if(l.useEffect(()=>{r||d(a)},[a,d,r]),!r&&s.loading&&a.length===0)return null;const y=c.isDirty(a);if(a.length===0||a.length===1&&!y)return null;const v=c.displayEntries(a),j=N=>{var P;const C=i.dragSourceUuid,T=(P=v[N])==null?void 0:P.uuid;i.reset(),!(C===null||!T||C===T)&&c.moveByDrag(C,T,a)},_=(N,C)=>{c.nudge(N.uuid,C,a)},w=N=>{c.toggleRelease(N.uuid,a)},k=()=>{p(null),c.reset()},S=async()=>{const{releases:N,priorities:C}=U8(v,new Set(c.releasedUuids),a);p(null),g(!0);try{if(!r){for(const T of N)await s.release(T);for(const T of C)await s.setPriority(T.uuid,T.priority,T.expectedPriority);await s.refetch()}c.reset()}catch(T){p(T instanceof Error?T.message:"Failed to save changes")}finally{g(!1)}};return t.jsxs("div",{className:"mt-6 border-t border-[var(--border-subtle)] pt-4","data-testid":"commit-queue-section",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx(zs,{title:"Commit Queue",count:v.length,expanded:h,onToggle:()=>f(N=>!N),testId:"commit-queue-header"}),o&&t.jsx("span",{className:"text-[11px] text-[var(--text-dim)]","data-testid":"commit-queue-branch",children:o})]}),u&&t.jsx("div",{className:"mt-2","data-testid":"commit-queue-error",children:t.jsx(tt,{text:u,className:"text-xs text-[var(--accent-danger)]"})}),h&&t.jsx("ol",{className:"mt-3 flex flex-col gap-2","data-testid":"commit-queue-list",children:v.map((N,C)=>t.jsx(RN,{entry:N,position:C+1,isHead:C===0,markedForRelease:c.releasedUuids.has(N.uuid),expanded:x===N.uuid,onToggleExpanded:()=>b(T=>T===N.uuid?null:N.uuid),onPriorityNudge:T=>_(N,T),onToggleRelease:()=>w(N),onDragStart:()=>i.beginDrag(N.uuid),onDragOver:()=>i.hoverOver(N.uuid),onDrop:()=>j(C),isDragging:i.dragSourceUuid===N.uuid,isDragOver:i.dragOverUuid===N.uuid&&i.dragSourceUuid!==N.uuid},N.uuid))}),y&&t.jsx(EN,{reorderedCount:c.reorderedCount(a),releasedCount:c.releasedCount,saving:m,onSave:S,onCancel:k})]})}const Pse=Object.freeze(Object.defineProperty({__proto__:null,CommitQueueSection:AN},Symbol.toStringTag,{value:"Module"}));function Y8(e){const[n,s]=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(e).getTime()-1).toISOString(),u=await fetch(`/api/journal?since=${encodeURIComponent(d)}`);if(!u.ok)throw new Error(`HTTP ${u.status}`);const h=((await u.json()).entries??[]).find(f=>f.timestamp===e)??null;c||s(h)}catch(d){c||(s(null),i(d instanceof Error?d.message:"Failed to load journal entry"))}finally{c||a(!1)}})(),()=>{c=!0}},[e]),{entry:n,loading:r,error:o}}function MN({journalTimestamp:e}){const{entry:n,loading:s,error:r}=Y8(e);return s?t.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Loading journal entry…"}):r?t.jsx(tt,{text:`Failed to load journal entry: ${r}`,className:"text-sm text-[var(--accent-red)]"}):n?t.jsx(jo,{entry:n,defaultExpanded:!0}):t.jsx("p",{className:"text-sm text-[var(--text-dim)]",children:"No journal entry found for this plan yet."})}const Ose=Object.freeze(Object.defineProperty({__proto__:null,CompletedPlanExpandedBody:MN},Symbol.toStringTag,{value:"Module"})),xm=160;function G8(e){if(!e)return"";let n=!1;for(const s of e.split(`
|
|
178
|
+
`)){const r=s.trim();if(r.startsWith("```")){n=!n;continue}if(n||!r||/^(#{1,6}\s|[-*+]\s|>\s|\||---$)/.test(r))continue;const a=r.replace(/`([^`]*)`/g,"$1").replace(/\*\*([^*]*)\*\*/g,"$1").replace(/\*([^*]*)\*/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").trim();if(a)return a.length>xm?`${a.slice(0,xm).trimEnd()}…`:a}return""}function IN({plan:e,expanded:n,onToggle:s,author:r}){const a=G8(e.body);return t.jsxs("li",{className:"border border-[var(--border-subtle)] rounded-lg bg-[var(--bg-surface,transparent)]",children:[t.jsxs("button",{type:"button",onClick:s,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:[r&&t.jsx(So,{author:r}),t.jsxs("span",{className:"flex-1 min-w-0",children:[t.jsx(zd,{title:e.title,timestamp:e.completedAt,tone:"muted"}),a&&t.jsx("span",{className:"mt-0.5 block truncate text-xs text-[var(--text-dim)]","data-testid":`completed-plan-excerpt-${e.slug}`,children:a})]}),t.jsx($d,{mode:e.mode}),t.jsx(Dr,{expanded:n,testId:"completed-plan-row-chevron"})]}),n&&t.jsx("div",{className:"px-3 py-2 border-t border-[var(--border-subtle)]","data-testid":"completed-plan-row-body",children:t.jsx(MN,{journalTimestamp:e.journalTimestamp})})]})}const Rse=Object.freeze(Object.defineProperty({__proto__:null,CompletedPlanRow:IN},Symbol.toStringTag,{value:"Module"}));function DN({plans:e,loading:n,error:s,showAuthors:r=!1,skeletonCount:a=3}){const[o,i]=l.useState(null),[c,d]=l.useState(!1),p=n&&e.length===0?a:e.length;return t.jsxs("div",{className:"mt-5 border-t border-[var(--border-subtle)] pt-5",children:[t.jsx(zs,{title:"Completed Plans",count:p,expanded:c,onToggle:()=>d(h=>!h),testId:"completed-plans-header"}),c&&t.jsx(LN,{plans:e,loading:n,error:s,expandedSlug:o,onToggle:h=>i(f=>f===h?null:h),showAuthors:r,skeletonCount:a})]})}function LN({plans:e,loading:n,error:s,expandedSlug:r,onToggle:a,showAuthors:o=!1,skeletonCount:i=3}){const c=s?t.jsx(tt,{text:`Failed to load completed plans: ${s}`,className:"text-sm text-[var(--accent-red)]",rowClassName:"mt-3"}):null;return n&&e.length===0?t.jsx(Ld,{count:i,testId:"recent-plans-skeleton-list",label:"Loading completed plans"}):e.length===0?c:t.jsxs(t.Fragment,{children:[c,t.jsx("ul",{className:"mt-3 flex flex-col gap-2","data-testid":"recent-plans-list",children:e.map(d=>t.jsx(IN,{plan:d,expanded:r===d.slug,onToggle:()=>a(d.slug),author:o?d.author:void 0},d.slug))})]})}const Ese=Object.freeze(Object.defineProperty({__proto__:null,RecentPlansBody:LN,RecentPlansSection:DN},Symbol.toStringTag,{value:"Module"}));function FN({chatOpen:e,onChatOpenChange:n,isActive:s=!0,isAgentBuilding:r=!1,launchingSlug:a,launchError:o,onLaunchPlan:i,planCompleteSignal:c=0,onToggleDesigns:d,designsOpen:u=!1}={}){const{plans:p,loading:h,error:f,refetch:m}=Ir(),{claims:g}=jp(),{slugs:x}=td(),{status:b}=wp(),{staleness:y}=g8(),v=((b==null?void 0:b.consecutiveFailures)??0)>=3,{plans:j,loading:_,error:w}=ed(),k=mm("plan-tab.queued-count",h?null:p.length),S=mm("plan-tab.completed-count",_?null:j.length),{config:N}=St(),C=Qe(N==null?void 0:N.provider),T=i!==void 0,P=xN(),R=T?a??null:P.launchingSlug,I=T?o??null:P.error,[A,O]=l.useState(!1),W=l.useMemo(()=>Sp(g),[g]),D=l.useMemo(()=>y8(g,x),[g,x]),Y=l.useMemo(()=>pN([...p.map(z=>z.author),...j.map(z=>z.author)]),[p,j]),H=e!==void 0,E=H?e:A,U=z=>{H||O(z),n==null||n(z)},M=()=>{U(!1),m()},J=()=>{const z=!E;z&&_t(),U(z)};l.useEffect(()=>{if(!(!s||!E))return _t()},[s,E]);const{annotationsBySlug:ne,dependenciesBySlug:oe}=kp(p),ae=E8(u),G=z=>{var q;const L=((q=p.find(se=>se.slug===z))==null?void 0:q.title)??z;if(i){i(z,L);return}P.launchPlan(z,L)},{requestRun:ie,gateModals:le}=ai({dependenciesBySlug:oe,claimsBySlug:W,isAgentBuilding:r,onLaunch:G}),{reorderPlans:Z}=wN(m);return t.jsxs(Jt,{testId:"plan-tab",children:[t.jsx(SN,{providerLabel:C}),d?t.jsx(_N,{onToggleDesigns:d,designsOpen:u}):null,t.jsx(NN,{chatOpen:E,onChatToggle:J,onChatClose:M,planCompleteSignal:c,designContext:ae}),t.jsx(_p,{staleness:y}),t.jsx(uN,{status:b}),t.jsx(si,{plans:p,loading:h,error:f,onRun:ie,launchingSlug:R,launchError:I,blocked:r,onReorder:Z,depAnnotationsBySlug:ne,dependenciesBySlug:oe,claimsBySlug:W,staleFetch:v,skeletonCount:k,showAuthors:Y}),t.jsx(py,{}),t.jsx(TN,{claims:D}),t.jsx(AN,{}),t.jsx(DN,{plans:j,loading:_,error:w,skeletonCount:S,showAuthors:Y}),le]})}const Ase=Object.freeze(Object.defineProperty({__proto__:null,PlanTab:FN},Symbol.toStringTag,{value:"Module"}));function $N({activeTab:e,planActivated:n,chatOpen:s,onChatOpenChange:r,isAgentBuilding:a=!1,launchingPlanSlug:o,planLaunchError:i,onLaunchPlan:c,planCompleteSignal:d=0,onToggleDesigns:u,designsOpen:p=!1}){return n?t.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:e==="plan"?"visible":"hidden",pointerEvents:e==="plan"?"auto":"none"},children:t.jsx(FN,{chatOpen:s,onChatOpenChange:r,isActive:e==="plan",isAgentBuilding:a,launchingSlug:o,launchError:i,onLaunchPlan:c,planCompleteSignal:d,onToggleDesigns:u,designsOpen:p})}):null}const Mse=Object.freeze(Object.defineProperty({__proto__:null,EditorShellPlanLayer:$N},Symbol.toStringTag,{value:"Module"}));function zN({projectTitle:e}){return t.jsxs("div",{"data-testid":"design-session-brand-row",style:{display:"flex",alignItems:"center",gap:9,padding:"14px 14px 10px",flex:"none"},children:[t.jsx("span",{"aria-hidden":"true",style:{width:28,height:28,borderRadius:7,background:"var(--accent-active)",color:"#1B1D26",display:"grid",placeItems:"center",flex:"none"},children:t.jsx(cs,{markOnly:!0,markTone:"inherit",className:"h-4"})}),t.jsx("span",{style:{fontWeight:500,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:(e==null?void 0:e.trim())||"New project"}),t.jsx("span",{style:{color:"var(--text-dim)",fontSize:13,flex:"none"},children:"/"}),t.jsx("span",{style:{color:"var(--text-muted)",fontSize:13,flex:"none"},children:"Design session"})]})}const Ise=Object.freeze(Object.defineProperty({__proto__:null,DesignSessionBrandRow:zN},Symbol.toStringTag,{value:"Module"})),V8="desktop",bm="codeyam:isDesktopApp";function K8(e=typeof window<"u"?window:void 0){var o,i,c;if(!e)return!1;try{if(((o=e.sessionStorage)==null?void 0:o.getItem(bm))==="1")return!0}catch{}const s=new URLSearchParams(((i=e.location)==null?void 0:i.search)??"").get(V8)==="1",r=typeof e.__TAURI__<"u",a=s||r;if(a)try{(c=e.sessionStorage)==null||c.setItem(bm,"1")}catch{}return a}const ym={renamed:{},deleted:[]},BN=e=>`codeyam.chat-history-edits:${e}`;function J8(e,n){return e.filter(s=>!n.deleted.includes(s.id)).map(s=>n.renamed[s.id]?{...s,title:n.renamed[s.id]}:s)}function X8(e){try{const n=window.localStorage.getItem(BN(e));if(!n)return ym;const s=JSON.parse(n);return{renamed:s.renamed&&typeof s.renamed=="object"?s.renamed:{},deleted:Array.isArray(s.deleted)?s.deleted:[]}}catch{return ym}}function Q8(e,n){try{window.localStorage.setItem(BN(e),JSON.stringify(n))}catch{}}function Z8(e){if(!e||typeof e!="object")return[];const n=e.sessions;return Array.isArray(n)?n.flatMap(s=>{if(!s||typeof s!="object")return[];const r=s;return typeof r.id!="string"||typeof r.title!="string"?[]:[{id:r.id,title:r.title,updatedAt:typeof r.updatedAt=="string"?r.updatedAt:""}]}):[]}function eW(e,n){var s;return((s=e.find(r=>!n.includes(r.id)))==null?void 0:s.id)??null}const tW=3e3;function nW(e){const[n,s]=l.useState([]);return l.useEffect(()=>{let r=!1,a="";const o=async()=>{try{const c=await fetch("/api/editor-chat-sessions");if(!c.ok)return;const d=await c.text();if(r||d===a)return;a=d,s(Z8(JSON.parse(d)))}catch{}};o();const i=window.setInterval(()=>void o(),tW);return()=>{r=!0,window.clearInterval(i)}},[e]),n}const hc=22,fc=14,vm=3;function sW(){const e=Array.from({length:fc},()=>Array(hc).fill(".")),n=10.6,s=vm+5.2,r=10.4,a=5.3;for(let i=vm;i<fc;i++)for(let c=0;c<hc;c++){const d=(c+.5-n)/r,u=(i+.5-s)/(a*(1-.22*d));d*d+u*u<=1&&(e[i][c]="b")}return[[0,8],[0,9],[0,12],[0,13],[1,9],[1,10],[1,11],[1,12],[2,10],[2,11]].forEach(([i,c])=>{e[i][c]="g"}),[[7,7],[8,7],[7,13],[8,13]].forEach(([i,c])=>{e[i][c]="e"}),[[10,9],[10,10],[10,11]].forEach(([i,c])=>{e[i][c]="m"}),[[10,8],[10,12]].forEach(([i,c])=>{e[i][c]="c"}),e}const rW=sW(),ln=10,Fs=12,WN={g:"#a9d94a",b:"#d7ff63",e:"#1b1d24",m:"#1b1d24",c:"#1b1d24"},aW=.35;function oi(e){const n=[];return rW.forEach((s,r)=>s.forEach((a,o)=>{if(!e.includes(a))return;const i=a==="c"?aW*ln:0;n.push({x:Fs+o*ln,y:Fs+r*ln-i,color:WN[a]})})),n}const oW=oi(["b","c","e","m"]).map(e=>({...e,y:Math.round((e.y-Fs)/ln)*ln+Fs,color:WN.b})),iW=oi(["g"]),lW=oi(["e"]),cW=oi(["m","c"]),dW=`
|
|
179
|
+
.pixel-yam-bob { transform-box: fill-box; transform-origin: 50% 100%; animation: pixel-yam-bob 2.4s ease-in-out infinite; }
|
|
180
|
+
.pixel-yam-blink { transform-box: fill-box; transform-origin: center; animation: pixel-yam-blink 4.2s infinite; }
|
|
181
|
+
.pixel-yam-look { transition: transform 180ms ease-out; }
|
|
182
|
+
@media (prefers-reduced-motion: reduce) { .pixel-yam-look { transition: none; } }
|
|
183
|
+
@keyframes pixel-yam-bob {
|
|
184
|
+
0%, 100% { transform: translateY(0) rotate(-3deg); }
|
|
185
|
+
50% { transform: translateY(-14px) rotate(3deg); }
|
|
186
|
+
}
|
|
187
|
+
@keyframes pixel-yam-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.12); } }
|
|
188
|
+
@media (prefers-reduced-motion: reduce) { .pixel-yam-bob, .pixel-yam-blink { animation: none; } }
|
|
189
|
+
`,uW=10,jm=240;function HN(e,n){const s=Math.hypot(e,n);if(s===0)return{x:0,y:0};const r=Math.min(s,jm)/jm*uW;return{x:e/s*r,y:n/s*r*.6}}function qN({width:e=72}){const n=`pixel-yam-goo-${l.useId().replace(/:/g,"")}`,s=l.useRef(null),r=l.useRef(null);l.useEffect(()=>{var d;if((d=window.matchMedia)!=null&&d.call(window,"(prefers-reduced-motion: reduce)").matches)return;const c=u=>{const p=s.current,h=r.current;if(!p||!h)return;const f=p.getBoundingClientRect(),m=HN(u.clientX-(f.left+f.width/2),u.clientY-(f.top+f.height/2));h.style.transform=`translate(${m.x.toFixed(1)}px, ${m.y.toFixed(1)}px)`};return window.addEventListener("pointermove",c),()=>window.removeEventListener("pointermove",c)},[]);const a=hc*ln+Fs*2,o=fc*ln+Fs*2,i=(c,d)=>t.jsx("g",{filter:`url(#${n})`,className:d,children:c.map(u=>t.jsx("rect",{x:u.x,y:u.y,width:ln+.5,height:ln+.5,fill:u.color},`${u.x}-${u.y}`))});return t.jsxs("svg",{ref:s,"data-testid":"pixel-yam",viewBox:`0 0 ${a} ${o}`,width:e,height:e*o/a,"aria-hidden":"true",style:{overflow:"visible"},children:[t.jsx("defs",{children:t.jsxs("filter",{id:n,x:"-20%",y:"-20%",width:"140%",height:"140%",colorInterpolationFilters:"sRGB",children:[t.jsx("feGaussianBlur",{in:"SourceGraphic",stdDeviation:ln*.3,result:"b"}),t.jsx("feColorMatrix",{in:"b",type:"matrix",values:"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 22 -10",result:"g"}),t.jsx("feComposite",{in:"SourceGraphic",in2:"g",operator:"atop"})]})}),t.jsx("style",{children:dW}),t.jsxs("g",{className:"pixel-yam-bob",children:[i(iW),i(oW),i(cW),t.jsx("g",{ref:r,className:"pixel-yam-look","data-testid":"pixel-yam-eyes",children:i(lW,"pixel-yam-blink")})]})]})}const Dse=Object.freeze(Object.defineProperty({__proto__:null,PixelYam:qN,lookOffset:HN},Symbol.toStringTag,{value:"Module"})),UN=["Which external services does this project need?","What is built and what is left?","What should I work on next?"];function YN({draft:e,onDraftChange:n,onSend:s,providerLabel:r,attachments:a}){return t.jsxs("div",{"data-testid":"chat-hero",className:"flex-1 min-h-0 flex flex-col",children:[t.jsx("div",{className:"flex-1 min-h-0 flex items-center justify-center overflow-y-auto px-4",children:t.jsxs("div",{className:"w-full max-w-[680px] py-10",children:[t.jsx("div",{className:"mb-5 flex justify-center",children:t.jsx(qN,{})}),t.jsx("h1",{className:"text-center text-2xl font-medium text-[var(--text-primary)]",children:"How can I help?"}),t.jsx("p",{className:"mt-2 text-center text-sm text-[var(--text-dim)]",children:"Ask about this project, what to build next, or which services to use. Nothing here changes your code."})]})}),t.jsxs("div",{"data-testid":"chat-hero-dock",className:"mx-auto w-full max-w-[760px] px-3 pb-4",children:[t.jsx("div",{className:"mb-3 flex flex-wrap justify-center gap-2",children:UN.map(o=>t.jsx("button",{type:"button",onClick:()=>n(o),"data-testid":"chat-hero-suggestion",className:"rounded-full border border-[var(--border-default)] px-3 py-1.5 text-xs text-[var(--text-dim)] hover:text-[var(--text-primary)] hover:border-[var(--text-dim)] cursor-pointer transition-colors",children:o},o))}),t.jsx(Ws,{value:e,onChange:n,onSubmit:s,canSubmit:e.trim()!=="",placeholder:`Ask ${r} anything`,minHeight:40,testId:"chat-hero-input",files:a.files,onAddFiles:a.addFiles,onRemoveFile:a.removeFile,busy:a.saving,error:a.error})]})]})}const Lse=Object.freeze(Object.defineProperty({__proto__:null,CHAT_HERO_SUGGESTIONS:UN,ChatHero:YN},Symbol.toStringTag,{value:"Module"})),GN="codeyam:chat-history-collapsed";function pW(){try{return window.localStorage.getItem(GN)==="1"}catch{return!1}}function hW(e){try{window.localStorage.setItem(GN,e?"1":"0")}catch{}}function VN({sessions:e,activeId:n,onSelect:s,onNewChat:r,liveId:a=null,liveStatus:o="idle",onDelete:i,onRename:c}){const[d,u]=l.useState(null),[p,h]=l.useState(null),[f,m]=l.useState(""),[g,x]=l.useState(pW),b=!!(i||c),y=()=>{x(_=>(hW(!_),!_))},v=f.trim().toLowerCase(),j=v?e.filter(_=>_.title.toLowerCase().includes(v)):e;return g?t.jsxs("aside",{"data-testid":"chat-history","data-collapsed":"true",className:"w-12 shrink-0 flex flex-col items-center gap-2 min-h-0 border-r border-[var(--border-subtle)] py-2",children:[t.jsx("button",{type:"button","aria-label":"Show chats",title:"Show chats",onClick:y,className:"grid h-8 w-8 place-items-center rounded-lg text-[var(--text-dim)] cursor-pointer hover:bg-white/[0.08] hover:text-[var(--text-primary)]",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:[t.jsx("rect",{x:"2",y:"2.5",width:"12",height:"11",rx:"2"}),t.jsx("path",{d:"M6 2.5v11"})]})}),t.jsx("button",{type:"button","aria-label":"New chat",title:"New chat",onClick:r,"data-testid":"chat-new",className:"grid h-8 w-8 place-items-center rounded-lg border border-[rgba(215,255,99,.3)] bg-[rgba(215,255,99,.08)] text-[var(--accent-active)] text-lg leading-none cursor-pointer hover:bg-[rgba(215,255,99,.14)]",children:t.jsx("span",{"aria-hidden":"true",children:"+"})})]}):t.jsxs("aside",{"data-testid":"chat-history",className:"w-[240px] shrink-0 flex flex-col min-h-0 border-r border-[var(--border-subtle)] p-2",children:[t.jsxs("div",{className:"flex items-center justify-between px-2 pt-1",children:[t.jsx("span",{className:"text-[13px] font-medium text-[var(--text-secondary)]",children:"Chats"}),t.jsx("button",{type:"button","aria-label":"Hide chats",title:"Hide chats",onClick:y,className:"grid h-7 w-7 place-items-center rounded-md text-[var(--text-dim)] cursor-pointer hover:bg-white/[0.08] hover:text-[var(--text-primary)]",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:[t.jsx("rect",{x:"2",y:"2.5",width:"12",height:"11",rx:"2"}),t.jsx("path",{d:"M6 2.5v11"})]})})]}),t.jsxs("button",{type:"button",onClick:r,"data-testid":"chat-new","aria-current":n===null?"true":void 0,className:"mt-2 flex items-center gap-2 rounded-lg border border-[rgba(215,255,99,.3)] bg-[rgba(215,255,99,.08)] px-3 py-1.5 text-[13px] font-medium text-[var(--accent-active)] cursor-pointer transition-colors hover:bg-[rgba(215,255,99,.14)]",children:[t.jsx("span",{"aria-hidden":"true",className:"text-[15px] leading-none",children:"+"}),"New chat"]}),t.jsxs("div",{className:"relative mt-2",children:[t.jsx("span",{className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-[var(--text-dim)]",children:t.jsx(Vd,{})}),t.jsx("input",{type:"search",value:f,onChange:_=>m(_.target.value),placeholder:"Search chats","aria-label":"Search chats",className:`w-full rounded-lg ${mo} py-1.5 pl-8 pr-3 text-[13px] text-[var(--text-secondary)] placeholder:text-[var(--text-dim)] outline-none focus:border-[var(--lime-300)]`})]}),t.jsx("div",{className:"mt-4 px-2 text-[11px] uppercase tracking-wider text-[var(--text-dim)]",children:"Recent"}),t.jsx("div",{className:"mt-1 flex-1 min-h-0 overflow-y-auto",children:e.length===0?t.jsx("p",{className:"px-3 py-2 text-xs text-[var(--text-dim)]",children:"Your chats will show up here."}):j.length===0?t.jsxs("p",{className:"px-3 py-2 text-xs text-[var(--text-dim)]",children:["No chats match “",f.trim(),"”."]}):j.map(_=>{const w=_.id===n,k=_.id===a;return t.jsxs("div",{className:`group relative flex items-center rounded-lg transition-colors ${w?"bg-white/[0.07]":"hover:bg-white/[0.04]"}`,children:[k&&t.jsx(KN,{status:o}),p===_.id&&c?t.jsx(XN,{initial:_.title,onDone:S=>{h(null),S&&S!==_.title&&c(_.id,S)}}):t.jsx("button",{type:"button",onClick:()=>s(_.id),title:_.title,"aria-current":w?"true":void 0,"data-testid":"chat-history-row",className:`block min-w-0 flex-1 truncate py-1.5 pr-1 text-[13px] text-left cursor-pointer transition-colors ${k?"pl-1.5":"pl-2"} ${w?"text-[var(--text-primary)]":"text-[var(--text-muted)] group-hover:text-[var(--text-secondary)]"}`,children:_.title}),b&&p!==_.id&&t.jsx("button",{type:"button","aria-label":"Chat options","aria-haspopup":"menu","aria-expanded":d===_.id,onClick:()=>u(S=>S===_.id?null:_.id),className:`mr-1 grid h-6 w-6 shrink-0 place-items-center rounded-md text-[var(--text-dim)] hover:bg-white/10 hover:text-[var(--text-primary)] cursor-pointer ${w||d===_.id?"":"opacity-0 group-hover:opacity-100 focus:opacity-100"}`,children:t.jsx("span",{"aria-hidden":"true",children:"⋯"})}),d===_.id&&t.jsx(JN,{onClose:()=>u(null),onRename:c?()=>{u(null),h(_.id)}:void 0,onDelete:i?()=>{u(null),i(_.id)}:void 0})]},_.id)})})]})}function KN({status:e}){return t.jsx("span",{"data-testid":"chat-history-live-dot","data-status":e,role:"img","aria-label":e==="needs-you"?"Waiting on you":e==="working"?"Working":"In progress",className:e==="idle"?"":"animate-pulse",style:{marginLeft:10,width:7,height:7,borderRadius:"50%",flex:"none",background:e==="needs-you"?it:"var(--working)"}})}function JN({onRename:e,onDelete:n,onClose:s}){const r=l.useRef(null);l.useEffect(()=>{const o=c=>{r.current&&!r.current.contains(c.target)&&s()},i=c=>{c.key==="Escape"&&s()};return document.addEventListener("mousedown",o),document.addEventListener("keydown",i),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("keydown",i)}},[s]);const a="block w-full rounded-md px-3 py-1.5 text-left text-xs cursor-pointer hover:bg-white/[.06]";return t.jsxs("div",{ref:r,role:"menu",className:"absolute right-1 top-full z-20 mt-1 w-32 rounded-lg border border-white/10 bg-[#1f1f1f] p-1 shadow-2xl",children:[e&&t.jsx("button",{type:"button",role:"menuitem",onClick:e,className:`${a} text-[var(--text-primary)]`,children:"Rename"}),n&&t.jsx("button",{type:"button",role:"menuitem",onClick:n,className:`${a} text-[var(--accent-danger,#f87171)]`,children:"Delete"})]})}function XN({initial:e,onDone:n}){const[s,r]=l.useState(e),a=l.useRef(!1),o=i=>{a.current||(a.current=!0,n(i))};return t.jsx("input",{autoFocus:!0,"aria-label":"Chat name",value:s,onChange:i=>r(i.target.value),onFocus:i=>i.target.select(),onBlur:()=>o(s.trim()),onKeyDown:i=>{i.key==="Enter"?o(s.trim()):i.key==="Escape"&&o(e)},className:"mx-1 my-0.5 min-w-0 flex-1 rounded-md border border-white/20 bg-transparent px-2 py-1 text-sm text-[var(--text-primary)] outline-none focus:border-white/40"})}const Fse=Object.freeze(Object.defineProperty({__proto__:null,ChatHistorySidebar:VN,LiveDot:KN,RenameField:XN,RowMenu:JN},Symbol.toStringTag,{value:"Module"})),fW=1500;function QN(e,n){const[s,r]=l.useState(Sr);return l.useEffect(()=>{if(r(Sr),!e)return;let a=!1,o="";const i=async()=>{try{const d=await fetch(`/api/editor-chat-session?id=${encodeURIComponent(e)}`);if(!d.ok)return;const u=await d.text();if(a||u===o)return;o=u,r(lx(JSON.parse(u)))}catch{}};i();const c=n?window.setInterval(()=>void i(),fW):void 0;return()=>{a=!0,c!==void 0&&window.clearInterval(c)}},[e,n]),s}const ZN=90,e2=15e3;function t2({chatKey:e,sessionId:n,question:s,onStatusChange:r}){const[a,o]=l.useState("chat"),[i,c]=l.useState(null),[d]=l.useState({chatKey:e,question:s}),[u,p]=l.useState(null),[h,f]=l.useState(s?[{id:`question-${e}`,text:s,after:0}]:[]),m=QN(n,!0),g=l.useCallback(E=>c(()=>E),[]),x=l.useRef(e);l.useEffect(()=>{e!==x.current&&(x.current=e,f([{id:`question-${e}`,text:s,after:0}]),p(Es(qa,s)))},[e,s]),l.useEffect(()=>{!u||!i||br(i,u)&&p(null)},[u,i]);const[b,y]=l.useState(!1);l.useEffect(()=>{if(y(!1),m.available)return;const E=window.setTimeout(()=>y(!0),e2);return()=>window.clearTimeout(E)},[m.available,e]);const[v,j]=l.useState(null),_=async(E,U)=>{if(!i)return!1;j(null);let M=E;if(U.length>0){let ne;try{ne=await Po(U)}catch(oe){return j(oe instanceof Error?oe.message:"Couldn't add those files."),!1}M=E?`${ne} ${E}`:ne}const J=dd(M);return br(i,J)?(f(ne=>[...ne,{id:`${Date.now()}-${ne.length}`,text:J.replace(/\r$/,""),after:m.messages.length}]),!0):!1},[w,k]=l.useState(null),S=l.useMemo(()=>Ru(w),[w]),N=l.useMemo(()=>Lu(w),[w]),C=!!S||!!N,T=E=>{i&&E.forEach((U,M)=>{window.setTimeout(()=>i(U),M*ZN)})},P=E=>{S&&T(Ur(S,E))},R=(E,U)=>{S&&T(Vo(S,E,U))},I=Ko(m.messages,h).some(E=>E.id.startsWith("pending-")),A=!C&&(m.working||I),O=m.messages[m.messages.length-1],W=C||!A&&(O==null?void 0:O.role)==="agent",D=!A&&!C&&(O==null?void 0:O.role)==="agent"&&cd(O.text),Y=A?"working":W?"needs-you":"idle",H=l.useRef(r);return H.current=r,l.useEffect(()=>{var E;(E=H.current)==null||E.call(H,Y)},[Y]),t.jsx(Lr.Provider,{value:E=>void _(E,[]),children:t.jsxs("div",{"data-testid":"chat-live",className:"flex-1 min-h-0 flex flex-col",children:[t.jsx("div",{className:"flex items-center justify-end px-4 py-2",children:t.jsx(Yo,{view:a,onChange:o})}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{"data-testid":"chat-live-terminal",className:"absolute inset-0 overflow-auto px-4",style:{visibility:a==="chat"?"hidden":"visible"},children:t.jsx("div",{className:"mx-auto w-full max-w-[860px]",children:t.jsx(qt,{chatName:"chat",slashCommand:Es(qa,d.question),seedText:d.question||void 0,height:520,onInputChannel:g,onScreen:k})})}),a==="chat"&&t.jsxs("div",{"data-testid":"chat-live-messages",className:"absolute inset-0 z-[1] flex flex-col",style:{background:"var(--bg-deep)"},children:[t.jsx("div",{className:"flex-1 min-h-0 flex justify-center",children:t.jsx("div",{className:"w-full max-w-[760px] min-h-0 flex flex-col",children:t.jsx(Yr,{messages:m.messages,working:A,waiting:C,pending:h,onOpenTerminal:()=>o("terminal")})})}),t.jsxs("div",{className:"mx-auto w-full max-w-[760px] pb-4",children:[S&&t.jsx("div",{className:"mb-2","data-testid":"chat-live-card-slot",style:{padding:`0 ${un}px`},children:t.jsx(Xo,{prompt:S,onChoose:P,onAnswer:R,onOpenTerminal:()=>o("terminal")})}),N&&!S&&t.jsx("div",{className:"mb-2","data-testid":"chat-live-card-slot",style:{padding:`0 ${un}px`},children:t.jsx(_o,{login:N,onSubmitCode:E=>T([E,"\r"]),onOpenTerminal:()=>o("terminal")})}),b&&!C&&t.jsxs("p",{"data-testid":"chat-log-missing",className:"mb-2 text-xs text-[var(--text-dim)]",style:{padding:`0 ${un}px`},children:["The chat can't read this conversation yet."," ",t.jsx("button",{type:"button",onClick:()=>o("terminal"),className:"underline cursor-pointer text-[var(--text-primary)]",children:"Open the terminal"})," ","to follow it there."]}),t.jsx(Jo,{disabled:!i,busyNote:v,awaiting:D,onSend:_},e)]})]})]})]})})}const $se=Object.freeze(Object.defineProperty({__proto__:null,CHAT_LOG_MISSING_AFTER_MS:e2,ChatLiveConversation:t2,TERMINAL_KEY_GAP_MS:ZN},Symbol.toStringTag,{value:"Module"}));function n2({sessionId:e,onNewChat:n,onContinue:s}){const r=QN(e,!1),a="rounded-lg bg-[var(--accent-active)] px-3 py-1.5 text-xs font-medium text-[var(--text-on-accent)] hover:opacity-90 cursor-pointer";return t.jsxs("div",{"data-testid":"chat-past",className:"flex-1 min-h-0 flex flex-col",children:[t.jsx("div",{className:"flex-1 min-h-0 flex justify-center",children:t.jsx("div",{className:"w-full max-w-[760px] min-h-0 flex flex-col",children:t.jsx(Yr,{messages:r.messages,working:!1,emptyState:t.jsx("p",{className:"text-sm text-[var(--text-dim)]",children:"Loading this chat…"})})})}),t.jsx("div",{className:"mx-auto w-full max-w-[760px] px-3 pb-4",children:t.jsx("div",{className:"flex items-center justify-between gap-3 rounded-2xl border border-[var(--border-subtle)] px-4 py-3 text-sm text-[var(--text-dim)]",children:s?t.jsxs(t.Fragment,{children:["Pick this chat up where it left off.",t.jsx("button",{type:"button",onClick:s,"data-testid":"chat-past-continue",className:a,children:"Continue this chat"})]}):t.jsxs(t.Fragment,{children:["This chat has ended.",t.jsx("button",{type:"button",onClick:n,"data-testid":"chat-past-new",className:a,children:"New chat"})]})})})]})}const zse=Object.freeze(Object.defineProperty({__proto__:null,ChatPastConversation:n2},Symbol.toStringTag,{value:"Module"}));function s2(){var I;const[e,n]=l.useState(""),[s,r]=l.useState(null),[a,o]=l.useState(!1),[i,c]=l.useState(null),d=nW(!0),u=Oo(),{config:p}=St(),h=Qe(p==null?void 0:p.provider),f=(p==null?void 0:p.projectTitle)??"project",[m,g]=l.useState(()=>X8(f)),x=A=>{g(A),Q8(f,A)},[b,y]=l.useState("idle");l.useEffect(()=>{nm(b==="working"),sm(b==="needs-you")},[b]),l.useEffect(()=>()=>{nm(!1),sm(!1)},[]);const v=s?s.resumeId??eW(d,s.knownIds):null,j=a?v:null,_=i!==null&&i!==j,w=a&&!_,k=J8(d,m),S=((I=k[0])==null?void 0:I.id)??null,N=i!==null&&i===S&&(!s||v===i),C=()=>{i&&(s||r({key:1,question:"",knownIds:[],resumeId:i}),o(!0),c(null))},T=A=>{r(O=>({key:((O==null?void 0:O.key)??0)+1,question:A,knownIds:d.map(W=>W.id)})),o(!0),n(""),c(null)},P=()=>{const A=kr(e);if(A){if(u.files.length===0){T(A);return}u.save().then(O=>{O!==null&&(u.clear(),T([O,A].filter(Boolean).join(" ")))})}},R=()=>{o(!1),c(null)};return t.jsxs("div",{"data-testid":"chat-tab",className:"flex-1 min-h-0 flex",style:{background:"var(--bg-deep)"},children:[t.jsx(VN,{sessions:k,activeId:_?i:j,onSelect:c,onNewChat:R,liveId:v,liveStatus:b,onRename:(A,O)=>x({...m,renamed:{...m.renamed,[A]:O}}),onDelete:A=>{x({...m,deleted:[...m.deleted,A]}),i===A&&c(null),j===A&&R()}}),t.jsxs("div",{className:"flex-1 min-w-0 min-h-0 flex flex-col",children:[s&&t.jsx("div",{className:"flex-1 min-h-0 flex-col",style:{display:w?"flex":"none"},children:t.jsx(t2,{chatKey:s.key,sessionId:v,question:s.question,onStatusChange:y})}),_&&t.jsx(n2,{sessionId:i,onNewChat:R,onContinue:N?C:void 0},i),!w&&!_&&t.jsx(YN,{draft:e,onDraftChange:n,onSend:P,providerLabel:h,attachments:u})]})]})}const Bse=Object.freeze(Object.defineProperty({__proto__:null,ChatTab:s2},Symbol.toStringTag,{value:"Module"}));function r2({activeTab:e}){const n=e==="chat",[s,r]=l.useState(n);return l.useEffect(()=>{n&&r(!0)},[n]),s?t.jsx("div",{className:"absolute inset-0 flex flex-col overflow-hidden",style:{visibility:n?"visible":"hidden",pointerEvents:n?"auto":"none"},children:t.jsx(s2,{})}):null}const Wse=Object.freeze(Object.defineProperty({__proto__:null,EditorShellChatLayer:r2},Symbol.toStringTag,{value:"Module"}));function a2({visible:e,children:n}){return t.jsx("div",{className:"absolute inset-0 flex flex-col overflow-auto",style:{visibility:e?"visible":"hidden"},children:n})}const Hse=Object.freeze(Object.defineProperty({__proto__:null,TabPane:a2},Symbol.toStringTag,{value:"Module"}));function o2({activeTab:e,children:n}){const s=["home","build","plan","history","reviews","settings"];return t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:s.map(r=>t.jsx(a2,{visible:e===r,children:n[r]},r))})}const qse=Object.freeze(Object.defineProperty({__proto__:null,LeftPanel:o2},Symbol.toStringTag,{value:"Module"}));function i2({label:e,description:n,checked:s,disabled:r=!1,onChange:a,children:o}){return t.jsxs("div",{className:"py-3.5",style:{borderTop:"1px solid var(--border-default)"},children:[t.jsxs("label",{className:`flex items-center gap-4 ${r?"cursor-default":"cursor-pointer"}`,children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"text-[13px] block",style:{color:"var(--text-primary)"},children:e}),t.jsx("span",{className:"text-[12px] block mt-0.5",style:{color:"var(--text-muted)"},children:n})]}),t.jsx("input",{type:"checkbox",checked:s,disabled:r,onChange:i=>a(i.target.checked),className:"peer sr-only"}),t.jsx("span",{"aria-hidden":"true","data-testid":"check-in-switch",className:"relative h-5 w-9 shrink-0 rounded-full transition-colors peer-focus-visible:ring-2 peer-focus-visible:ring-[var(--accent-active)] peer-disabled:opacity-50",style:{background:s?"var(--accent-active)":"rgba(255,255,255,.14)"},children:t.jsx("span",{className:"absolute top-0.5 h-4 w-4 rounded-full transition-all",style:{left:s?18:2,background:s?"#0f0f0f":"rgba(255,255,255,.75)"}})})]}),o]})}const Use=Object.freeze(Object.defineProperty({__proto__:null,CheckInToggleRow:i2},Symbol.toStringTag,{value:"Module"})),mW=[{value:"commit",label:"Commit",hint:"Run the full finalize, then commit."},{value:"fastCommit",label:"Fast commit",hint:"Defer the heavy finalize work; owed before merge."}];function l2({autoAction:e,branchState:n,disabled:s=!1,onChange:r}){return n.onPrimaryBranch?t.jsx("div",{className:"mt-2 ml-6",children:t.jsxs("p",{className:"text-[11px]",style:{color:"var(--text-dim)"},children:["Fast commit is disabled on"," ",n.primaryBranch??"the primary branch"," — this check-in will commit normally."]})}):t.jsxs("div",{className:"mt-2 ml-6",children:[t.jsx("div",{className:"text-[11px] mb-1",style:{color:"var(--text-muted)"},children:"When it runs on its own"}),t.jsx(go,{options:mW,value:e,onChange:r,disabled:s,ariaLabel:"Autonomous commit action"})]})}const Yse=Object.freeze(Object.defineProperty({__proto__:null,HardeningAutoAction:l2},Symbol.toStringTag,{value:"Module"})),c2={checkIns:{planAccepted:{pause:!0},prototypeCompleted:{pause:!0},hardeningCompleted:{pause:!0,autoAction:"commit"},push:{pause:!0}}};function wm(e){const n=(e==null?void 0:e.checkIns)??{},s=c2.checkIns;return{checkIns:{planAccepted:n.planAccepted??s.planAccepted,prototypeCompleted:n.prototypeCompleted??s.prototypeCompleted,hardeningCompleted:n.hardeningCompleted??s.hardeningCompleted,push:n.push??s.push}}}function gW(){const[e,n]=l.useState(c2),[s,r]=l.useState({currentBranch:null,primaryBranch:null,onPrimaryBranch:!1}),[a,o]=l.useState(!0),[i,c]=l.useState(!1),[d,u]=l.useState(null);l.useEffect(()=>{let h=!1;return(async()=>{var f;try{const m=await fetch("/api/config");if(!m.ok)throw new Error(`config request failed (${m.status})`);const g=await m.json();if(h)return;const x=(g==null?void 0:g.currentBranch)??null,b=((f=g==null?void 0:g.audit)==null?void 0:f.branchBaseRef)??null;n(wm(g==null?void 0:g.workflow)),r({currentBranch:x,primaryBranch:b,onPrimaryBranch:x!==null&&x===b})}catch(m){h||u(m instanceof Error?m.message:String(m))}finally{h||o(!1)}})(),()=>{h=!0}},[]);const p=l.useCallback(async(h,f)=>{const m=e;n(h),c(!0),u(null);try{const g=await fetch("/api/workflow-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:f,workflow:h})}),x=await g.json().catch(()=>({}));if(!g.ok||(x==null?void 0:x.success)===!1)throw new Error((x==null?void 0:x.message)??(x==null?void 0:x.error)??`save failed (${g.status})`);x!=null&&x.workflow&&n(wm(x.workflow))}catch(g){n(m),u(g instanceof Error?g.message:String(g))}finally{c(!1)}},[e]);return{settings:e,branchState:s,loading:a,saving:i,error:d,save:p}}const xW=[{key:"planAccepted",label:"Plan accepted",description:"Pause after the plan is written, before any code is built."},{key:"prototypeCompleted",label:"Prototype completed",description:"Pause once the prototype is demoable in the Live Preview."},{key:"hardeningCompleted",label:"Hardening completed",description:"Pause after tests, scenarios, and the audit are green."},{key:"push",label:"Push",description:"Pause before the branch is pushed to the remote."}],bW=[{value:"local",label:"This machine only"},{value:"project",label:"Whole project"}];function d2(){const[e,n]=l.useState("local"),{settings:s,branchState:r,loading:a,saving:o,error:i,save:c}=gW(),d=s.checkIns.hardeningCompleted;return t.jsxs("section",{className:"mt-6 rounded-xl",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 px-5 pt-5 pb-4",children:[t.jsxs("div",{className:"min-w-0 max-w-md",children:[t.jsx("h3",{className:"text-[14px] font-medium",style:{color:"var(--text-primary)"},children:"Workflow check-ins"}),t.jsx("p",{className:"text-[12.5px] leading-relaxed mt-1",style:{color:"var(--text-muted)"},children:"Switched on, the workflow pauses and asks you at that point. Switched off, it keeps going on its own."})]}),t.jsxs("div",{className:"shrink-0",children:[t.jsx("div",{className:"text-[11.5px] mb-1.5",style:{color:"var(--text-muted)"},children:"Apply to"}),t.jsx(go,{options:bW,value:e,onChange:n})]})]}),t.jsx("div",{className:"px-5 pb-2",children:xW.map(u=>{const p=s.checkIns[u.key];return t.jsx(i2,{label:u.label,description:u.description,checked:p.pause,disabled:a||o,onChange:h=>void c({checkIns:{...s.checkIns,[u.key]:{...p,pause:h}}},e),children:u.key==="hardeningCompleted"&&!d.pause&&t.jsx(l2,{autoAction:d.autoAction,branchState:r,disabled:o,onChange:h=>void c({checkIns:{...s.checkIns,hardeningCompleted:{...d,autoAction:h}}},e)})},u.key)})}),i&&t.jsxs("p",{className:"text-[12px] px-5 pb-4",role:"alert",style:{color:"var(--accent-red, #ef4444)"},children:["Could not save: ",i]})]})}const Gse=Object.freeze(Object.defineProperty({__proto__:null,WorkflowSettingsSection:d2},Symbol.toStringTag,{value:"Module"}));function u2(){return t.jsx("div",{className:"h-full overflow-y-auto px-6 py-8",children:t.jsxs("div",{className:"mx-auto w-full max-w-2xl",children:[t.jsx("h2",{className:"text-[18px] font-semibold",style:{color:"var(--text-primary)"},children:"Settings"}),t.jsx("p",{className:"mt-1 text-[13px]",style:{color:"var(--text-muted)"},children:"How the editor works with you on this project."}),t.jsx(d2,{}),t.jsx(Tg,{})]})})}const Vse=Object.freeze(Object.defineProperty({__proto__:null,SettingsTab:u2},Symbol.toStringTag,{value:"Module"}));function p2({activeTab:e,appTabContent:n,leftWidth:s,onPreviewScreenshot:r,onRunPlan:a}){const o=e!=="build"&&e!=="plan"&&e!=="chat",[i,c]=l.useState(!1),[d,u]=l.useState(!1),[p,h]=l.useState(!1);return l.useEffect(()=>{e==="history"&&c(!0),e==="reviews"&&u(!0),e==="settings"&&h(!0)},[e]),t.jsx("div",{className:"absolute inset-0 flex flex-col",style:{visibility:o?"visible":"hidden",pointerEvents:o?"auto":"none"},children:t.jsx(o2,{activeTab:e,width:s,children:{home:n,build:null,plan:null,history:i?t.jsx(s0,{onPreviewScreenshot:r,onRunPlan:a}):null,reviews:d?t.jsx(iw,{}):null,settings:p?t.jsx(u2,{}):null}})})}const Kse=Object.freeze(Object.defineProperty({__proto__:null,EditorShellTabLayer:p2},Symbol.toStringTag,{value:"Module"}));function h2(e){const{annotationsBySlug:n,dependenciesBySlug:s}=kp(e),{claims:r}=jp(),{status:a}=wp(),o=l.useMemo(()=>Sp(r),[r]),i=((a==null?void 0:a.consecutiveFailures)??0)>=3;return{annotationsBySlug:n,dependenciesBySlug:s,claimsBySlug:o,staleFetch:i}}function yW(e){const[n,s]=l.useState({}),r=e.join(`
|
|
190
|
+
`);return l.useEffect(()=>{if(r==="")return;let a=!1;for(const o of r.split(`
|
|
191
|
+
`))fetch(`/api/proposed-plans/${encodeURIComponent(o)}/report`).then(i=>i.ok?i.json():null).then(i=>{a||!(i!=null&&i.report)||s(c=>({...c,[o]:i.report}))}).catch(()=>{});return()=>{a=!0}},[r]),n}function vW(e){return!e||!(e instanceof Element)?!1:!!e.closest("[data-terminal-emulator], .xterm")}function jW(e){return!e||!(e instanceof Element)?!1:!!e.closest("[data-post-push-modal]")}function f2(e,n=!0){const s=l.useCallback(r=>{if(r.key!=="Enter"||!n||vW(r.target))return;const a=r.target===document.body||r.target===document.documentElement||r.target===document;!jW(r.target)&&!a||(r.preventDefault(),e())},[n,e]);l.useEffect(()=>(window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)),[s])}function wW(e){return[{id:"prototype",title:"Prototype",caption:`Try an idea fast with ${e}, harden it later`},{id:"plan",title:"Plan",caption:"Plan out a change, like a bug fix or a feature"},{id:"chat",title:"Chat",caption:`Ask ${e} about the project or CodeYam`}]}function m2({title:e,caption:n,icon:s,testId:r,onClick:a,disabled:o=!1}){const i=o?"":"group-hover:text-[var(--bg-deep)]";return t.jsxs("button",{type:"button",disabled:o,onClick:a,"data-testid":r,className:"group flex h-full w-full flex-col items-start rounded-md border border-[var(--border-default)] bg-[var(--bg-deep)] p-3 text-left transition "+(o?"cursor-not-allowed opacity-50":"cursor-pointer hover:border-[var(--accent-active)] hover:bg-[var(--accent-active)]"),children:[t.jsx("span",{className:"text-[var(--accent-active)] "+i,children:s}),t.jsx("span",{className:"mt-2 block text-sm font-medium text-[var(--text-primary)] "+i,children:e}),t.jsx("span",{className:"mt-0.5 block text-xs leading-snug text-[var(--text-muted)] "+i,children:n})]})}const Jse=Object.freeze(Object.defineProperty({__proto__:null,BuildActivityCard:m2},Symbol.toStringTag,{value:"Module"}));function g2({activity:e,size:n=20}){return t.jsxs("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e==="prototype"&&t.jsx("path",{d:"M13 3v7h6l-8 11v-7H5l8-11"}),e==="plan"&&t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M3.5 5.5l1.5 1.5l2.5-2.5"}),t.jsx("path",{d:"M3.5 11.5l1.5 1.5l2.5-2.5"}),t.jsx("path",{d:"M3.5 17.5l1.5 1.5l2.5-2.5"}),t.jsx("path",{d:"M11 6h9M11 12h9M11 18h9"})]}),e==="chat"&&t.jsx("path",{d:"M3 20l1.3-3.9c-2.3-3.4-1.4-7.9 2.1-10.4c3.5-2.5 8.6-2.3 11.8.5c3.3 2.8 3.7 7.3 1 10.5c-2.7 3.2-7.6 4.2-11.6 2.3L3 20"})]})}const Xse=Object.freeze(Object.defineProperty({__proto__:null,BuildActivityIcon:g2},Symbol.toStringTag,{value:"Module"}));function x2({providerLabel:e,onChoose:n,disabled:s=!1}){const r=wW(e);return t.jsx("div",{className:"grid grid-cols-3 gap-2","data-testid":"build-activity-menu",children:r.map(a=>t.jsx(m2,{title:a.title,caption:a.caption,icon:t.jsx(g2,{activity:a.id}),testId:`build-activity-${a.id}`,onClick:()=>n(a.id),disabled:s},a.id))})}const Qse=Object.freeze(Object.defineProperty({__proto__:null,BuildActivityMenu:x2},Symbol.toStringTag,{value:"Module"}));function _W({mode:e,hasPlans:n}){return e==="feature-complete"?{heading:"Feature Complete!",subtitle:"Your changes have been committed and pushed. Pick what to do next."}:{heading:"What do you want to do?",subtitle:n?"Run a queued plan, or pick one of the options below.":"Pick one of the options below to get started."}}function b2({mode:e,hasPlans:n,featureSummary:s}){if(e==="feature-complete"&&(s!=null&&s.title))return t.jsx(by,{summary:s});const{heading:r,subtitle:a}=_W({mode:e,hasPlans:n});return t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:r}),t.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:a})]})}const Zse=Object.freeze(Object.defineProperty({__proto__:null,BuildActivityModalHeading:b2},Symbol.toStringTag,{value:"Module"}));function y2({plans:e,loading:n,error:s,onRun:r,launchingSlug:a,launchError:o,blocked:i,depAnnotationsBySlug:c,dependenciesBySlug:d,claimsBySlug:u,staleFetch:p}){return e.length===0?null:t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-3 mb-4 text-xs text-[var(--text-dim)]","aria-hidden":"true",children:[t.jsx("span",{className:"flex-1 h-px bg-[var(--border-subtle)]"}),t.jsx("span",{children:"or"}),t.jsx("span",{className:"flex-1 h-px bg-[var(--border-subtle)]"})]}),t.jsx("div",{className:"mb-3","data-testid":"build-activity-modal-plan-list",style:{"--plan-row-bg":"var(--bg-deep)","--plan-row-border":"var(--border-default)"},children:t.jsx(si,{plans:e,loading:n,error:s,onRun:r,launchingSlug:a,launchError:o,blocked:i,depAnnotationsBySlug:c,dependenciesBySlug:d,claimsBySlug:u,staleFetch:p})})]})}const ere=Object.freeze(Object.defineProperty({__proto__:null,BuildActivityPlanList:y2},Symbol.toStringTag,{value:"Module"}));function v2({onContinueInSession:e,onStopBuilding:n,onSendTranscript:s}){return!e&&!n&&!s?null:t.jsxs("div",{className:"mt-4 pt-3 border-t border-[var(--border-subtle)] flex flex-col gap-2","data-testid":"feature-complete-actions",children:[e&&t.jsx("button",{type:"button",onClick:e,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:"Continue in Current Session"}),n&&t.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(--accent-danger, #f87171)",border:"1px solid var(--accent-danger, #f87171)"},"data-testid":"post-push-stop-building",children:"Stop Building"}),s&&t.jsx("button",{type:"button",onClick:s,className:"w-full px-4 py-2 rounded-md text-sm font-medium transition cursor-pointer",style:{background:"transparent",color:"var(--text-dim)",border:"1px solid var(--border-default)"},children:"Send Session Feedback"})]})}const tre=Object.freeze(Object.defineProperty({__proto__:null,FeatureCompleteActions:v2},Symbol.toStringTag,{value:"Module"})),SW=300;function j2({mode:e,providerLabel:n,plans:s,onPickPlan:r,launchingSlug:a,planError:o,pendingPlansLoading:i,pendingPlansError:c,isAgentBuilding:d,featureCycleComplete:u=!1,onChooseActivity:p,onSubmitPrompt:h,submittingPrompt:f=!1,featureSummary:m,onContinueInSession:g,onStopBuilding:x,onSendTranscript:b,onMinimize:y}){const{annotationsBySlug:v,dependenciesBySlug:j,claimsBySlug:_,staleFetch:w}=h2(s),k=e==="feature-complete",S=d&&!u,{requestRun:N,gateModals:C}=ai({dependenciesBySlug:j,claimsBySlug:_,isAgentBuilding:S,onLaunch:I=>{var O;const A=((O=s.find(W=>W.slug===I))==null?void 0:O.title)??I;r(I,A)}}),T=f||a!==null,P=AI(k?(m==null?void 0:m.proposedPlans)??[]:[]),R=yW(P.rows.filter(As).map(I=>I.id));return f2(l.useCallback(()=>p("prototype"),[p]),!T),t.jsxs("div",{className:"absolute inset-0 z-[60] flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},"data-testid":"build-activity-modal","data-post-push-modal":!0,children:[t.jsxs("div",{className:"max-w-lg w-full mx-4 p-6 rounded-lg max-h-[85vh] overflow-y-auto",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[t.jsx("div",{className:"mb-4",children:t.jsx(Nb,{maxHeight:SW,testId:"build-activity-narrative",children:t.jsx(b2,{mode:e,hasPlans:s.length>0,featureSummary:m})})}),t.jsx(ly,{rows:P.rows,providerLabel:n,busyActions:P.busyActions,errorsById:P.errorsById,headReleaseFailure:P.headReleaseFailure,onWrite:I=>void P.write(I),onIgnore:I=>void P.ignore(I)}),t.jsx(hy,{rows:P.rows,reports:R,busyActions:P.busyActions,errorsById:P.errorsById,onCopied:I=>void P.markCopied(I),onIgnore:I=>void P.ignore(I)}),t.jsxs("div",{children:[t.jsx(x2,{providerLabel:n,onChoose:p,disabled:T}),k&&t.jsx(v2,{onContinueInSession:g,onStopBuilding:x,onSendTranscript:b})]}),t.jsx("div",{className:"border-t border-[var(--border-subtle)] pt-4 mt-4",children:t.jsx(y2,{plans:s,loading:i,error:c,onRun:N,launchingSlug:a,launchError:o,blocked:S,depAnnotationsBySlug:v,dependenciesBySlug:j,claimsBySlug:_,staleFetch:w})}),t.jsxs("div",{children:[h&&t.jsx(gy,{onSubmitPrompt:h,disabled:T}),y&&t.jsx("div",{className:"mt-4 text-center",children:t.jsx("button",{type:"button",onClick:y,className:"text-xs underline underline-offset-2 text-[var(--text-muted)] hover:text-[var(--text-primary)] transition cursor-pointer","data-testid":"build-activity-minimize",children:"Back to what I was doing"})})]})]}),C]})}const nre=Object.freeze(Object.defineProperty({__proto__:null,BuildActivityModal:j2},Symbol.toStringTag,{value:"Module"}));function w2({onReopen:e,pendingPlanCount:n=0}){return t.jsxs("button",{type:"button",onClick:e,"data-testid":"build-activity-reopen-bar",className:"absolute bottom-0 left-0 right-0 z-[55] flex items-center justify-between px-4 py-2.5 text-sm transition cursor-pointer hover:opacity-90",style:{background:"var(--bg-surface)",borderTop:"1px solid var(--border-default)",color:"var(--text-secondary)"},children:[t.jsx("span",{children:"What do you want to do?"}),t.jsxs("span",{className:"flex items-center gap-2 text-xs text-[var(--text-dim)]",children:[n>0&&t.jsxs("span",{"data-testid":"build-activity-reopen-bar-count",children:[n," queued"]}),t.jsx("span",{"aria-hidden":"true",children:"↑"})]})]})}const sre=Object.freeze(Object.defineProperty({__proto__:null,BuildActivityReopenBar:w2},Symbol.toStringTag,{value:"Module"}));function _2({onCreateNewPlan:e,onContinueSession:n,onViewPlans:s}){return t.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:[t.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"Plan Saved!"}),t.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-6",children:"Your plan has been committed. Start a fresh plan, continue this session to write a related follow-up with the current context, or head back to see the list."}),t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx("button",{onClick:e,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"}),t.jsx("button",{onClick:n,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:"Continue with this planning session"}),t.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 rre=Object.freeze(Object.defineProperty({__proto__:null,PlanCompleteDialog:_2},Symbol.toStringTag,{value:"Module"}));function S2({onCreateNewPlan:e,onContinueSession:n,onViewPlans:s}){return t.jsx("div",{className:"absolute inset-0 z-[60] flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},children:t.jsx(_2,{onCreateNewPlan:e,onContinueSession:n,onViewPlans:s})})}const are=Object.freeze(Object.defineProperty({__proto__:null,PlanCompleteTransition:S2},Symbol.toStringTag,{value:"Module"}));function k2({plans:e,onSelect:n,onCancel:s,launchingSlug:r,error:a}){const[o,i]=l.useState(null),c=l.useMemo(()=>{const x={};for(const b of e)x[b.slug]=b;return x},[e]),{annotationsBySlug:d,dependenciesBySlug:u,claimsBySlug:p,staleFetch:h}=h2(e),{requestRun:f,gateModals:m}=ai({dependenciesBySlug:u,claimsBySlug:p,onLaunch:l.useCallback(x=>{const b=c[x];b&&n(b.slug,b.title)},[n,c])}),g=l.useCallback(x=>{x.key==="Escape"&&(x.preventDefault(),s())},[s]);return l.useEffect(()=>(window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)),[g]),f2(l.useCallback(()=>{e.length>0&&f(e[0].slug)},[e,f]),e.length>0&&!r),e.length===0?null:t.jsxs("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","data-post-push-modal":!0,children:[t.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:[t.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:"Select A Plan"}),t.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."}),t.jsx("ul",{className:"flex flex-col gap-2 max-h-[50vh] overflow-y-auto mb-2",children:e.map((x,b)=>{var y,v;return t.jsx(cp,{plan:x,position:b+1,expanded:o===x.slug,onToggle:()=>i(j=>j===x.slug?null:x.slug),onRun:f,launching:r===x.slug,unsatisfiedDepCount:(y=d[x.slug])==null?void 0:y.count,unsatisfiedDepTooltip:(v=d[x.slug])==null?void 0:v.tooltip,dependencies:u[x.slug],claim:p.get(x.slug),staleFetch:h,expandedBodyVariant:"view"},x.slug)})}),a&&t.jsx(tt,{testId:"select-plan-error",text:a,className:"text-xs text-[var(--text-danger)]",rowClassName:"mb-3"}),t.jsx("button",{type:"button",onClick:s,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"}),t.jsx("p",{className:"mt-3 text-center text-xs text-[var(--text-dim)]",children:"Press Enter to launch the first plan, Escape to cancel"})]}),m]})}const ore=Object.freeze(Object.defineProperty({__proto__:null,SelectPlanModal:k2},Symbol.toStringTag,{value:"Module"}));function N2({activeTab:e,onSendTranscript:n,appTabContent:s,awaitingPlanLaunchChoice:r,buildActivated:a,planActivated:o,buildIdle:i=!1,agentBlocked:c=!1,isAgentBuilding:d=!1,planActive:u=!1,planIdle:p=!1,bannerVisible:h=!1,onDismissIdleBanner:f,hideResultsCommandKey:m,leftWidth:g,fullWidth:x=!1,navigateToTab:b,onAgentActive:y,onAgentIdle:v,onAgentBlocked:j,onUserInput:_,notifSettings:w,onSettingsChange:k,provider:S,onContinueInSession:N,onRestorePreview:C,onResultsScenarioSelect:T,previewSlug:P=null,onStopBuilding:R,featureSummary:I,featureCycleComplete:A,showResultsCommandKey:O,planChatOpen:W,onPlanChatOpenChange:D,showPlanCompleteModal:Y,onCreateNewPlan:H,onContinueSession:E,onViewPlans:U,pendingPlans:M,onSelectPlan:J,selectPlanOpen:ne,onPickPlan:oe,onCancelSelectPlan:ae,launchingPlanSlug:G,planLaunchError:ie,prototypeLaunchSignal:le=0,planCompleteSignal:Z=0,showBuildLaunchModal:z=!1,buildLaunchGateArmed:L=!1,buildActivity:q="menu",buildActivityMinimized:se=!1,chatEscalatedToPrototype:fe=!1,onChooseActivity:we,onNavigateToPlanTab:De,onToggleDesigns:Fe,designsOpen:Me=!1,onActivityDone:ee,onPrototypeLaunched:Q,onMinimizeActivityModal:te,onReopenActivityModal:he,onSubmitBuildPrompt:ye,submittingBuildPrompt:ve=!1,buildPromptError:Ne=null,pendingPlansLoading:de,pendingPlansError:me,onReorderPlans:We,buildDisabled:B=!1,onPreviewScreenshot:F,onRunHistoryPlan:X,projectTitle:ue=null,designSession:be=!1}){const xe=K8(),ke=A,qe=e==="build"&&!ne&&!se&&(ke||z),Le=Oe=>{if(Oe==="plan"){De==null||De();return}we==null||we(Oe)};return t.jsxs("div",{className:`${x?"flex-1 w-full min-w-0":"shrink-0"} flex flex-col overflow-hidden`,style:x?{background:"var(--bg-deep)"}:{width:g,background:"var(--bg-deep)"},children:[xe&&t.jsx(C1,{projectTitle:ue}),be?t.jsx(zN,{projectTitle:ue}):t.jsx(N1,{activeTab:e,onTabChange:b,onSendTranscript:n,buildIdle:i,agentBlocked:c,isAgentBuilding:d,planActive:u,planIdle:p,bannerVisible:h,onDismissIdleBanner:f,buildDisabled:B,showLogo:!xe,projectTitle:ue,notifSettings:w,onNotifSettingsChange:k,agentName:S,providerLabel:Qe(S)}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:[t.jsx(oN,{awaitingPlanLaunchChoice:r,buildLaunchGateArmed:L,buildActivated:a,activeTab:e,onSelectScenario:T,previewSlug:P,showResultsCommandKey:O,hideResultsCommandKey:m,onAgentIdle:v,onAgentBlocked:j,onAgentActive:y,onUserInput:_,provider:S,onRestorePreview:C,pendingPlans:M,pendingPlansLoading:de,pendingPlansError:me,onLaunchPlan:(Oe,Ue)=>oe(Oe,Ue,"build-tab"),launchingSlug:G,launchError:ie,onReorderPlans:We,isAgentBuilding:d,featureCompleteActive:A,buildActivity:q,chatEscalatedToPrototype:fe,onActivityDone:ee,onPrototypeLaunched:Q,prototypeLaunchSignal:le}),t.jsx($N,{activeTab:e,planActivated:o,chatOpen:W,onChatOpenChange:D,isAgentBuilding:d,launchingPlanSlug:G,planLaunchError:ie,onLaunchPlan:(Oe,Ue)=>oe(Oe,Ue,"plan-tab"),planCompleteSignal:Z,onToggleDesigns:Fe,designsOpen:Me}),t.jsx(r2,{activeTab:e}),t.jsx(p2,{activeTab:e,appTabContent:s,leftWidth:g,onPreviewScreenshot:F,onRunPlan:X}),ne&&e==="build"?t.jsx(k2,{plans:M,onSelect:(Oe,Ue)=>oe(Oe,Ue,"select-plan-modal"),onCancel:ae,launchingSlug:G,error:ie}):null,qe?t.jsx(j2,{mode:ke?"feature-complete":"cold",providerLabel:Qe(S),plans:M,onPickPlan:(Oe,Ue)=>oe(Oe,Ue,"build-activity-modal"),launchingSlug:G,planError:ie,pendingPlansLoading:de,pendingPlansError:me,isAgentBuilding:d,featureCycleComplete:A,onChooseActivity:Le,onSubmitPrompt:ye,submittingPrompt:ve,featureSummary:I,onContinueInSession:ke?N:void 0,onStopBuilding:ke?R:void 0,onSendTranscript:ke?n:void 0,onMinimize:te}):null,se&&e==="build"&&he?t.jsx(w2,{onReopen:he,pendingPlanCount:M.length}):null,Y&&e==="plan"?t.jsx(S2,{onCreateNewPlan:H,onContinueSession:E,onViewPlans:U}):null]})]})}const ire=Object.freeze(Object.defineProperty({__proto__:null,EditorShellLeftPane:N2},Symbol.toStringTag,{value:"Module"}));function C2({onOpenDesigns:e,onDismiss:n}){return t.jsxs("div",{role:"status",style:{position:"absolute",top:12,right:12,zIndex:20,display:"flex",alignItems:"center",gap:10,padding:"8px 10px 8px 14px",borderRadius:999,border:"1px solid var(--accent-active, #D7FF63)",background:"var(--bg-card, #1a1a1a)",boxShadow:"0 8px 20px rgba(0, 0, 0, 0.45)",fontSize:"var(--text-sm, 14px)",color:"var(--text-primary)"},children:[t.jsx("button",{type:"button",onClick:e,style:{border:"none",background:"transparent",color:"inherit",font:"inherit",cursor:"pointer",padding:0,textDecoration:"underline",textUnderlineOffset:3},children:"Go back to Designs"}),t.jsx("button",{type:"button",onClick:n,"aria-label":"Dismiss",style:{border:"none",background:"transparent",color:"var(--text-secondary)",cursor:"pointer",fontSize:16,lineHeight:1,padding:2},children:"×"})]})}const lre=Object.freeze(Object.defineProperty({__proto__:null,DesignReturnPill:C2},Symbol.toStringTag,{value:"Module"}));async function _m(e,n=null){try{const s={pid:e};n&&(s.url=n),await fetch("/api/editor-iframe-loaded",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})}catch{}}async function kW(e){try{await fetch("/api/editor-iframe-error",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({error:e})})}catch{}}async function NW(e){try{await fetch("/api/editor-iframe-banner",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({seedError:e})})}catch{}}async function CW(e){try{await fetch("/api/editor-inspector-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({frozen:e})})}catch{}}async function TW(e){try{await fetch("/api/editor-iframe-auth-needed",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({previewOrigin:e})})}catch{}}async function PW(e){try{await fetch("/api/editor-preview-escape",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({escapedPath:e})})}catch{}}function OW(e,n,s,r,a){const o=e,i=n-a*2;return o<=0||i<=0?1:Math.min(1,o/s,i/r)}const RW=32;function EW({currentHeight:e,currentWidth:n,isFilled:s}){const[r,a]=l.useState(null),o=l.useRef(null),i=l.useRef(null),c=l.useCallback(p=>{const h=p.getBoundingClientRect();a({width:h.width,height:h.height})},[]),d=l.useCallback(p=>{if(o.current&&(o.current.disconnect(),o.current=null),i.current=p,!p){a(null);return}c(p);const h=new ResizeObserver(()=>{const f=i.current;f&&c(f)});h.observe(p),o.current=h},[c]),u=s||!r?1:OW(r.width,r.height,n,e,RW);return{containerRef:d,containerSize:r,scale:u}}const mc={kind:"iframe",fallbackKind:null,fallbackPort:null,nativeWebPreview:!1,loading:!1},Sm=[400,800,1500,3e3];function T2(){const[e,n]=l.useState({...mc,loading:!0});return l.useEffect(()=>{let s=!1,r,a=0;const o=()=>{const d=Sm[Math.min(a,Sm.length-1)];a+=1,r=setTimeout(c,d)},i=()=>{n(d=>d.loading?mc:d),o()},c=()=>{fetch("/api/project-stack").then(d=>d.ok?d.json():{}).then(d=>{s||(AW(d)?n(MW(d)):i())}).catch(()=>{s||i()})};return c(),()=>{s=!0,r&&clearTimeout(r)}},[]),e}function AW(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length>0}function MW(e){const n=e&&typeof e=="object"&&"preview"in e?e.preview:null;if(!n||typeof n!="object")return mc;const s=n;return{kind:IW(s.kind),fallbackKind:DW(s.fallbackKind),fallbackPort:typeof s.fallbackPort=="number"?s.fallbackPort:null,nativeWebPreview:s.nativeWebPreview===!0,loading:!1}}function IW(e){return e==="simulator-ios"?"simulator-ios":e==="simulator-android"?"simulator-android":"iframe"}function DW(e){return e==="iframe"||e==="simulator-ios"||e==="simulator-android"?e:null}const LW="codeyam:client-routing-detected";function FW(e){const[n,s]=l.useState(!1);return l.useEffect(()=>{if(!e)return;function r(a){var o;a.origin===window.location.origin&&((o=a.data)==null?void 0:o.type)===LW&&s(!0)}return window.addEventListener("message",r),()=>window.removeEventListener("message",r)},[e]),n}const $W=700;function P2({pollMs:e=$W,paused:n=!1,onError:s}={}){const[r,a]=l.useState(0),[o,i]=l.useState({kind:"loading"}),c=l.useRef(s);return c.current=s,l.useEffect(()=>{if(n)return;let d=!1;const u=window.setInterval(()=>{d||a(p=>p+1)},e);return()=>{d=!0,window.clearInterval(u)}},[e,n]),l.useEffect(()=>{if(n)return;let d=!1;return fetch(`/api/simulator-frame?t=${r}`,{method:"HEAD"}).then(async u=>{var h;if(d)return;if(u.ok){i({kind:"ok"});return}if(u.status===503){const f=await zW(u);if(d)return;(typeof(f==null?void 0:f.error)=="string"?f.error:"").includes("xcode")?i({kind:"xcode-missing"}):i({kind:"no-device"});return}const p=`simulator frame request failed (${u.status})`;i({kind:"capture-failed",message:p}),(h=c.current)==null||h.call(c,p)}).catch(u=>{var h;if(d)return;const p=u instanceof Error?u.message:"simulator frame request errored";i({kind:"capture-failed",message:p}),(h=c.current)==null||h.call(c,p)}),()=>{d=!0}},[r,n]),{state:o,isBooted:o.kind==="ok",frameToken:r}}async function zW(e){try{return await e.json()}catch{return null}}function BW(e,n){const s=(e==null?void 0:e.screenshotPaths)??[];if(s.length===0)return null;if(n){const r=`--${n.toLowerCase()}.png`,a=s.find(o=>o.toLowerCase().endsWith(r));if(a)return a}return s[0]??null}function WW(e,n,s){switch(e){case 1:case 2:return"Setting up...";case 3:return`Building — ${n} files modified, ${s} 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 gc(){const e=Date.now();try{const n=await fetch("/api/editor-session-summary"),s=Date.now()-e;return n.ok?{ok:!0,data:await n.json(),statusCode:n.status,durationMs:s,error:null}:{ok:!1,data:null,statusCode:n.status,durationMs:s,error:`HTTP ${n.status}`}}catch(n){return{ok:!1,data:null,statusCode:null,durationMs:Date.now()-e,error:n instanceof Error?n.message:String(n)}}}const HW=50,qW={status:"loading",lastSuccessAt:null,lastErrorAt:null,lastErrorMessage:null,fetchCount:0,errorCount:0};function UW(e,n,s){return{status:n.ok?"connected":"disconnected",lastSuccessAt:n.ok?s:e.lastSuccessAt,lastErrorAt:n.ok?e.lastErrorAt:s,lastErrorMessage:n.ok?e.lastErrorMessage:n.error,fetchCount:e.fetchCount+1,errorCount:e.errorCount+(n.ok?0:1)}}function YW(e,n){return{timestamp:n,success:e.ok,statusCode:e.statusCode,durationMs:e.durationMs,error:e.error}}function GW(e,n){return[n,...e].slice(0,HW)}function VW(){const[e,n]=l.useState(qW),[s,r]=l.useState([]),a=l.useCallback(i=>{const c=Date.now();r(d=>GW(d,YW(i,c))),n(d=>UW(d,i,c))},[]),o=l.useCallback(()=>{n(i=>({...i,status:"polling"}))},[]);return{connectionState:e,fetchLog:s,recordFetch:a,markPolling:o}}async function KW(e){try{const r=await fetch("/api/test-results");if(r.ok&&(await r.json()).running)return{kind:"busy"}}catch{}const n={tests:[e.name]};e.file&&(n.changedFiles=[e.file]);let s;try{s=await fetch("/api/test-results/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}catch(r){return{kind:"error",message:r instanceof Error?r.message:String(r)}}if(s.ok)return{kind:"accepted"};if(s.status===409)return{kind:"busy"};try{const r=await s.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 ${s.status}).`}}function JW(e,n){if(!e.narrative)return null;for(const s of e.narrative.changes)for(const r of s.tests)if(r.name===n)return{lastRunAt:r.lastRunAt,status:r.status??"unknown"};return null}async function XW(e,n,s){const r=s.intervalMs??2e3,a=s.nowMs??(()=>Date.now()),o=s.sleep??(c=>new Promise(d=>setTimeout(d,c))),i=a()+s.timeoutMs;for(;;){const c=await gc();if(c.ok&&c.data){const d=JW(c.data,e.name);if(d!=null&&d.lastRunAt&&Date.parse(d.lastRunAt)>n)return{kind:"completed",status:d.status,summary:c.data}}if(a()>=i)return{kind:"timeout"};await o(r)}}function QW(e){return!e||e<=0?3e4:Math.max(3e4,e*2)}function ZW({onSummaryUpdate:e,getLastDurationMs:n}){const[s,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 KW(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=QW(n()),p=await XW(o,c,{timeoutMs:u});p.kind==="completed"?(e(p.summary),r(null)):r({name:i,state:{phase:"timeout"}})})()},[e,n]);return{active:s,onRerun:a}}function eH(e){switch(e.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 O2({state:e}){const n=us(),{dotClass:s,label:r,labelClass:a}=eH(e);return t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[11px] font-medium","data-testid":"connection-status-badge",children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${s}`,"data-testid":"connection-status-dot"}),t.jsx("span",{className:a,"data-testid":"connection-status-label",children:r}),e.lastSuccessAt!=null&&t.jsxs("span",{className:"text-[var(--text-muted)]","data-testid":"connection-status-updated",children:["Updated ",tl(e.lastSuccessAt,n)]})]})}const cre=Object.freeze(Object.defineProperty({__proto__:null,BackendConnectionStatusBadge:O2},Symbol.toStringTag,{value:"Module"}));function R2({feature:e,connectionState:n,statusChip:s,userPrompt:r}){return t.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border-default)] rounded-lg p-5",children:[t.jsx("h1",{className:"text-lg font-semibold text-[var(--text-primary)] m-0",children:e||"Working Session Results"}),t.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[t.jsx(O2,{state:n}),s&&t.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:s})]}),r&&t.jsxs("div",{className:"mt-3 pt-3 border-t border-[var(--border-subtle)]","data-testid":"user-prompt-section",children:[t.jsx("div",{className:"text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wide",children:"Your request"}),t.jsx("div",{className:"mt-2 bg-[var(--bg-input)] border border-[var(--border-subtle)] rounded-md p-3",children:t.jsx(bo,{maxHeight:90,moreLabel:"View More",lessLabel:"View Less",fadeColor:"var(--bg-input)",children:r})})]})]})}const dre=Object.freeze(Object.defineProperty({__proto__:null,BackendResultsHeader:R2},Symbol.toStringTag,{value:"Module"}));function tH(e,n,s=[]){var r;return{headline:(r=e.description)!=null&&r.trim()?e.description:e.name,name:e.name,file:e.file,status:e.status??"unknown",failureMessage:e.failureMessage,change:n.title,lastRunAt:e.lastRunAt,lastRunKind:e.lastRunKind,recentStatuses:e.recentStatuses,exercises:s.filter(a=>a.tests.some(o=>fp(o)===e.name)),example:e.example}}function E2(e,n=[]){const s=[],r=[];let a=0;for(const o of e.tests){if(o.verified===!1){a+=1;continue}const i=tH(o,e,n);i.status==="passing"?s.push(i):r.push(i)}return{worksNow:s,inProgress:r,unverifiedCount:a}}function nH(e,n=[]){const s=[],r=[];let a=0;for(const o of e.changes){const i=E2(o,n);s.push(...i.worksNow),r.push(...i.inProgress),a+=i.unverifiedCount}return{worksNow:s,inProgress:r,unverifiedCount:a}}function sH(e){if(!e||e.length<2)return!1;const n=e.some(r=>r.status==="pass"),s=e.some(r=>r.status==="fail");return n&&s}function rH(e){if(e==null||e===0)return"";const n=Math.abs(e),s=e>0?"slower":"faster";return`${n}s ${s} than the previous run`}function A2({status:e}){switch(e){case"passing":return t.jsx("span",{className:"text-green-500 text-xs mt-0.5 shrink-0",children:"✓"});case"failing":return t.jsx("span",{className:"text-red-500 text-xs mt-0.5 shrink-0",children:"✗"});case"running":return t.jsx("span",{className:"text-[#D7FF63] text-xs mt-0.5 shrink-0 animate-spin",children:"◠"});default:return t.jsx("span",{className:"text-gray-400 text-xs mt-0.5 shrink-0",children:"●"})}}const ure=Object.freeze(Object.defineProperty({__proto__:null,NarrativeTestStatusIcon:A2},Symbol.toStringTag,{value:"Module"})),km="font-mono text-[11px] text-[var(--text-primary)] whitespace-pre-wrap break-words min-w-0",Nm="w-0 text-[10px] font-semibold uppercase tracking-wide text-[var(--text-muted)] align-top pr-3 py-1 whitespace-nowrap";function M2({example:e}){return t.jsxs("div",{"data-testid":"behavior-example",children:[t.jsx("table",{className:"w-full border-collapse",children:t.jsxs("tbody",{children:[t.jsxs("tr",{children:[t.jsx("td",{className:Nm,children:"Input"}),t.jsx("td",{className:`${km} py-1`,"data-testid":"example-input",children:e.input})]}),t.jsxs("tr",{children:[t.jsx("td",{className:Nm,children:"Output"}),t.jsx("td",{className:`${km} py-1`,"data-testid":"example-output",children:e.output})]})]})}),e.note&&t.jsx("p",{className:"text-[10px] text-[var(--text-muted)] mt-1 mb-0 italic","data-testid":"example-note",children:e.note})]})}const pre=Object.freeze(Object.defineProperty({__proto__:null,BehaviorExampleTable:M2},Symbol.toStringTag,{value:"Module"})),aH="text-[10px] font-semibold uppercase tracking-wide text-[var(--text-muted)] mb-1";function oH(e){switch(e.phase){case"busy":return"Tests are already running — try again once they finish.";case"error":return e.message;case"timeout":return"Couldn't confirm — check test results.";default:return null}}function I2({rerun:e={phase:"idle"},onRerun:n,disabled:s=!1,disabledReason:r}){const a=e.phase==="verifying",o=e.phase==="error",i=s||a,c=s&&r||oH(e);return t.jsxs("div",{"data-testid":"evidence-rerun",children:[t.jsx("div",{className:aH,children:"Re-run"}),t.jsxs("button",{type:"button",onClick:n,disabled:i,title:s?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&&t.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"]}),c&&t.jsx("p",{className:`text-[11px] mt-1 m-0 ${o?"text-red-600":"text-[var(--text-muted)]"}`,"data-testid":"rerun-note",children:c})]})}const hre=Object.freeze(Object.defineProperty({__proto__:null,RerunSection:I2},Symbol.toStringTag,{value:"Module"}));function iH(e){return e==="passing"?"passed":e==="failing"?"failed":"ran"}function lH(e){switch(e){case"full":return"full run";case"changed":return"changed-files run";case"targeted":return"targeted run"}}function D2(e){var r;const n=e.status==="failing"&&!!e.failureMessage,s=(((r=e.recentStatuses)==null?void 0:r.length)??0)>0;return!!e.lastRunAt||e.exercises.length>0||n||!!e.example||s}const er="text-[10px] font-semibold uppercase tracking-wide text-[var(--text-muted)] mb-1";function L2({behavior:e,rerun:n={phase:"idle"},onRerun:s,disabled:r=!1,disabledReason:a}){const o=us(),i=e.status==="failing"&&!!e.failureMessage;return t.jsxs("div",{className:"mt-2 ml-5 space-y-3","data-testid":"behavior-evidence-drawer",children:[e.lastRunAt&&t.jsxs("div",{"data-testid":"evidence-verified",children:[t.jsx("div",{className:er,children:"Verified"}),t.jsxs("p",{className:"text-[11px] text-[var(--text-secondary)] m-0",children:[iH(e.status)," ",tl(Date.parse(e.lastRunAt),o),e.lastRunKind&&t.jsxs("span",{className:"text-[var(--text-muted)]",children:[" (",lH(e.lastRunKind),")"]})]})]}),e.example&&t.jsxs("div",{"data-testid":"evidence-example",children:[t.jsx("div",{className:er,children:"Example"}),t.jsx(M2,{example:e.example})]}),e.recentStatuses&&e.recentStatuses.length>0&&t.jsxs("div",{"data-testid":"evidence-recent-runs",children:[t.jsx("div",{className:er,children:"Recent runs"}),t.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:[...e.recentStatuses].reverse().map((c,d)=>t.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} · ${tl(Date.parse(c.at),o)}`,"data-testid":`recent-run-dot-${c.status}`},`${c.at}-${d}`))})]}),e.exercises.length>0&&t.jsxs("div",{"data-testid":"evidence-exercises",children:[t.jsx("div",{className:er,children:"Exercises"}),t.jsx("ul",{className:"list-none p-0 m-0 space-y-1",children:e.exercises.map(c=>t.jsxs("li",{className:"text-[11px] text-[var(--text-secondary)] flex items-center gap-x-1.5",children:[t.jsx("span",{className:"font-mono text-[var(--text-primary)]",children:c.name}),t.jsx("span",{className:"text-[var(--text-dim)]",children:"·"}),t.jsx("span",{className:"font-mono text-[var(--text-dim)] min-w-0 truncate",children:c.filePath}),c.coverage&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-[var(--text-dim)]",children:"·"}),t.jsxs("span",{className:"text-[var(--text-muted)]",children:[Math.round(c.coverage.percent),"% covered"]})]})]},c.name))})]}),i&&t.jsxs("div",{"data-testid":"evidence-failure",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("div",{className:er,children:"Failure"}),t.jsx(ct,{variant:"subtle",text:e.failureMessage??"",label:"Copy",className:"shrink-0 px-2 py-0.5 text-[11px] font-medium rounded border border-red-200 text-red-700 hover:bg-red-50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"})]}),t.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:e.failureMessage})]}),t.jsx(I2,{rerun:n,onRerun:s,disabled:r,disabledReason:a})]})}const fre=Object.freeze(Object.defineProperty({__proto__:null,BehaviorEvidenceDrawer:L2,hasDrawerContent:D2},Symbol.toStringTag,{value:"Module"}));function F2({behavior:e,rerun:n}){var p,h;const[s,r]=l.useState(!1),a=D2(e),o=sH(e.recentStatuses),i=((p=n==null?void 0:n.active)==null?void 0:p.name)===e.name,c=i?n.active.state:{phase:"idle"},d=c.phase==="verifying",u=((h=n==null?void 0:n.active)==null?void 0:h.state.phase)==="verifying"&&!i;return t.jsx("div",{"data-testid":"behavior-item",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(A2,{status:d?"running":e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-start gap-1.5",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"text-sm text-[var(--text-primary)] leading-relaxed",children:[e.headline,o&&t.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?"})]}),t.jsxs("div",{className:"flex items-center gap-x-1.5 mt-1 text-[11px]",children:[t.jsx("span",{className:"text-[var(--text-muted)] font-mono min-w-0 truncate",children:e.name}),e.file&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-[var(--text-dim)] shrink-0",children:"·"}),t.jsx("span",{className:"text-[var(--text-dim)] font-mono min-w-0 truncate",children:e.file})]}),e.change&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-[var(--text-dim)] shrink-0",children:"·"}),t.jsx("span",{className:"text-[var(--text-muted)] opacity-70 shrink-0",children:e.change})]})]})]}),a&&t.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(!s),"aria-expanded":s,"aria-label":s?"Hide evidence":"Show evidence","data-testid":"toggle-evidence-drawer",children:s?"▾":"▸"})]}),a&&s&&t.jsx(L2,{behavior:e,rerun:c,onRerun:n?()=>n.onRerun(e):void 0,disabled:u,disabledReason:"Verifying another behavior…"})]})]})})}const mre=Object.freeze(Object.defineProperty({__proto__:null,BehaviorItem:F2},Symbol.toStringTag,{value:"Module"}));function xc({label:e,behaviors:n,tone:s,rerun:r}){if(n.length===0)return null;const a=s==="positive"?"text-green-500":"text-[var(--text-secondary)]";return t.jsxs("section",{className:"space-y-3","data-testid":"behavior-group",children:[t.jsxs("h2",{className:`text-xs font-semibold uppercase tracking-wide m-0 ${a}`,"data-testid":"behavior-group-heading",children:[e," (",n.length,")"]}),t.jsx("div",{className:"space-y-4",children:n.map(o=>t.jsx(F2,{behavior:o,rerun:r},`${o.change}:${o.name}`))})]})}const gre=Object.freeze(Object.defineProperty({__proto__:null,BehaviorGroup:xc},Symbol.toStringTag,{value:"Module"}));function Cp({ways:e}){return e.length===0?null:t.jsxs("div",{className:"space-y-1.5","data-testid":"ways-to-test",children:[t.jsx("h4",{className:"text-[11px] font-semibold uppercase tracking-wide text-[var(--text-secondary)] m-0",children:"Ways to test"}),t.jsx("ul",{className:"list-disc pl-4 space-y-1 m-0",children:e.map((n,s)=>t.jsx("li",{className:"text-sm leading-relaxed","data-testid":"way-to-test",children:cH(n)},s))})]})}function cH(e){return e.kind==="run-scenario"&&e.scenarioUrl?t.jsxs("a",{href:e.scenarioUrl,target:"_blank",rel:"noopener",className:"text-[var(--accent-blue)] hover:underline inline-flex items-center gap-1","data-testid":"way-to-test-scenario-link",children:[e.text,t.jsx("span",{"aria-hidden":"true",className:"text-[10px] opacity-70",children:"↗ open in dev app"})]}):e.kind==="staging-only"?t.jsx("span",{className:"text-[var(--text-muted)] italic","data-testid":"way-to-test-staging-only",children:e.text}):t.jsx("span",{className:"text-[var(--text-primary)]",children:e.text})}const xre=Object.freeze(Object.defineProperty({__proto__:null,WaysToTestList:Cp},Symbol.toStringTag,{value:"Module"}));function $2({change:e,functions:n=[],rerun:s}){const{worksNow:r,inProgress:a}=E2(e,n);return t.jsxs("section",{className:"space-y-3 pt-4 border-t border-[var(--border-subtle)]","data-testid":"change-card",children:[t.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] m-0",children:e.title}),e.description&&t.jsx("p",{className:"text-sm text-[var(--text-secondary)] leading-relaxed m-0",children:e.description}),t.jsx(Cp,{ways:e.waysToTest??[]}),t.jsx(xc,{label:"Works now",behaviors:r,tone:"positive",rerun:s}),t.jsx(xc,{label:"In progress",behaviors:a,tone:"pending",rerun:s})]})}const bre=Object.freeze(Object.defineProperty({__proto__:null,ChangeCard:$2},Symbol.toStringTag,{value:"Module"}));function z2({narrative:e,functions:n=[],rerun:s}){const{unverifiedCount:r}=nH(e,n);return t.jsxs("div",{className:"space-y-6","data-testid":"behavior-gallery",children:[e.summary&&t.jsx("p",{className:"text-sm text-[var(--text-primary)] leading-relaxed m-0",children:e.summary}),e.changes.map((a,o)=>t.jsx($2,{change:a,functions:n,rerun:s},`${a.title}:${o}`)),r>0&&t.jsxs("p",{className:"text-[11px] text-[var(--text-muted)] m-0","data-testid":"unverified-footnote",children:[r," test",r===1?"":"s"," not yet found in source."]})]})}const yre=Object.freeze(Object.defineProperty({__proto__:null,BehaviorGallery:z2},Symbol.toStringTag,{value:"Module"}));function B2({step:e}){return t.jsx("div",{className:"text-sm text-[var(--text-muted)]","data-testid":"behavior-gallery-empty",children:t.jsx("span",{"data-testid":"behavior-gallery-prebuild",children:"The build will describe what it’s creating here as it works."})})}const vre=Object.freeze(Object.defineProperty({__proto__:null,BehaviorGalleryEmptyState:B2},Symbol.toStringTag,{value:"Module"}));function dH(e){const n=e.trim();if(n==="??")return"New";switch(n.replace(/\s/g,"").charAt(0)){case"M":return"Modified";case"A":return"Added";case"D":return"Deleted";case"R":return"Renamed";case"C":return"Copied";case"U":return"Unmerged";case"T":return"Type changed";default:return n||e}}function W2({path:e,status:n,testid:s}){return t.jsxs("li",{className:"flex items-center gap-2","data-testid":s,children:[t.jsx("span",{className:"font-mono text-[var(--text-primary)] truncate",children:e}),t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-[var(--bg-input)] border border-[var(--border-subtle)] text-[var(--text-secondary)] shrink-0",children:dH(n)})]})}const jre=Object.freeze(Object.defineProperty({__proto__:null,BuildFileRow:W2},Symbol.toStringTag,{value:"Module"}));function H2({feature:e,modifiedFiles:n,functions:s,waysToTestBaseline:r,step:a}){const o=new Set(s.map(u=>u.filePath)),i=n.filter(u=>!o.has(u.path)),c=(()=>{const u=new Map;for(const p of s.flatMap(h=>h.tests)){const h=fp(p);if(!h)continue;const f=eB(p),m=u.get(h);m?m.description===void 0&&f!==void 0&&(m.description=f):u.set(h,{name:h,description:f})}return Array.from(u.values())})(),d=a>=4;return t.jsxs("div",{className:"text-sm space-y-5","data-testid":"build-progress-detail",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-[var(--accent-blue)] animate-pulse","aria-hidden":"true"}),t.jsx("span",{className:"text-[var(--text-primary)] font-medium",children:e?`Building ${e}…`:"Building…"})]}),t.jsxs("section",{"data-testid":"build-areas-changed",children:[t.jsx("h4",{className:"text-[11px] font-semibold uppercase tracking-wide text-[var(--text-secondary)] m-0 mb-1.5",children:"Areas being changed"}),s.length===0&&n.length===0?t.jsx("div",{className:"text-[var(--text-muted)]",children:"Gathering changes…"}):t.jsxs("div",{className:"space-y-3",children:[s.length>0&&t.jsx("ul",{className:"list-none pl-0 m-0 space-y-2",children:s.map(u=>t.jsx("li",{children:t.jsx(hp,{fn:u,testid:"build-area-function"})},`${u.filePath}::${u.name}`))}),i.length>0&&t.jsxs("div",{children:[s.length>0&&t.jsx("div",{className:"text-[11px] font-medium text-[var(--text-muted)] mb-1",children:"Other files"}),t.jsx("ul",{className:"list-none pl-0 m-0 space-y-0.5",children:i.map(u=>t.jsx(W2,{path:u.path,status:u.status,testid:"build-area-file"},u.path))})]})]})]}),t.jsxs("section",{"data-testid":"build-tests",children:[t.jsxs("h4",{className:"text-[11px] font-semibold uppercase tracking-wide text-[var(--text-secondary)] m-0 mb-1.5",children:["Tests validating the change",c.length>0&&t.jsxs("span",{className:"ml-1 text-[var(--text-muted)] font-normal normal-case tracking-normal",children:["(",c.length,")"]})]}),c.length===0?t.jsx("div",{className:"text-[var(--text-muted)]",children:"Tests will appear here as they’re written."}):t.jsx("ul",{className:"list-none pl-0 m-0 space-y-1",children:c.map(u=>t.jsxs("li",{"data-testid":"build-test-name",children:[t.jsx("div",{className:"font-mono text-xs text-[var(--text-primary)]",children:u.name}),u.description&&t.jsx("div",{className:"text-[10px] text-[var(--text-muted)] mt-0.5",children:u.description})]},u.name))})]}),t.jsxs("section",{"data-testid":"build-ways-to-test",children:[t.jsx(Cp,{ways:r??[]}),t.jsx("div",{className:"mt-1.5 text-xs text-[var(--text-muted)] italic",children:d?"Detailed ways to test appear once the build finishes verifying.":"Detailed ways to test appear once the build finishes."})]})]})}const wre=Object.freeze(Object.defineProperty({__proto__:null,BuildProgressDetail:H2},Symbol.toStringTag,{value:"Module"}));function uH(e){return e.filter(Boolean).join(" · ")}function pH(e){if(!e)return"";const n=Math.round(e.global.percent);if(e.previousGlobal==null)return`coverage ${n}%`;const s=Math.round(e.global.percent-e.previousGlobal);if(s===0)return`coverage ${n}% (±0)`;const r=s>0?"+":"−";return`coverage ${n}% (${r}${Math.abs(s)})`}function q2({stats:e,thresholds:n,trendDeltaSecs:s}){if(!e)return null;const r=e.runners.length||e.per_runner.length,a=e.per_runner.filter(i=>i.duration_ms!=null).map(i=>`${i.name} ${Math.round(i.duration_ms/1e3)}s`),o=uH([`${r} runner${r===1?"":"s"}`,`${e.passed} passed`,e.failed>0?`${e.failed} failed`:"",...a,pH(n),rH(s)]);return t.jsx("p",{className:"text-[11px] text-[var(--text-muted)] font-mono m-0","data-testid":"run-evidence-line",children:o})}const _re=Object.freeze(Object.defineProperty({__proto__:null,RunEvidenceLine:q2},Symbol.toStringTag,{value:"Module"})),hH=5e3;function U2(){const[e,n]=l.useState(null),[s,r]=l.useState(!0),{connectionState:a,recordFetch:o,markPolling:i}=VW(),c=l.useRef(null),d=l.useRef(null);d.current=e;const u=ZW({onSummaryUpdate:n,getLastDurationMs:l.useCallback(()=>{var m,g;return(g=(m=d.current)==null?void 0:m.testRunnerStats)==null?void 0:g.duration_ms},[])});if(l.useEffect(()=>{async function m(){const g=await gc();o(g),g.ok&&g.data&&n(g.data),r(!1)}return m(),()=>{c.current&&clearInterval(c.current)}},[o]),l.useEffect(()=>(c.current&&(clearInterval(c.current),c.current=null),(e==null?void 0:e.live)===!0&&(c.current=setInterval(async()=>{i();const m=await gc();o(m),m.ok&&m.data&&n(m.data)},hH)),()=>{c.current&&clearInterval(c.current)}),[e==null?void 0:e.live,o,i]),s)return t.jsx("div",{className:"min-h-screen bg-[var(--bg-deep)] flex items-center justify-center",children:t.jsx("div",{className:"animate-spin w-6 h-6 border-2 border-[var(--border-default)] border-t-[#005c75] rounded-full"})});if(!e)return t.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 p=e.step??0,h=e.functions.reduce((m,g)=>m+g.tests.length,0),f=WW(p,e.modifiedFiles.length,h);return t.jsx("div",{className:"min-h-screen bg-[var(--bg-deep)] p-6",children:t.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[t.jsx(R2,{feature:e.feature,connectionState:a,statusChip:f,userPrompt:e.userPrompt}),t.jsx(q2,{stats:e.testRunnerStats,thresholds:e.coverageThresholds,trendDeltaSecs:e.suiteTrendDeltaSecs}),t.jsx("div",{className:"bg-[var(--bg-card)] border border-[var(--border-default)] rounded-lg p-5",children:e.narrative?t.jsx(z2,{narrative:e.narrative,functions:e.functions,rerun:u}):p>=3?t.jsx(H2,{feature:e.feature,modifiedFiles:e.modifiedFiles,functions:e.functions,waysToTestBaseline:e.waysToTestBaseline,step:p}):t.jsx(B2,{step:p})})]})})}const Sre=Object.freeze(Object.defineProperty({__proto__:null,BackendResultsPage:U2},Symbol.toStringTag,{value:"Module"}));function Y2(){return t.jsx("div",{className:"flex-1 flex flex-col min-w-0 overflow-auto",style:{background:"var(--bg-deep)"},children:t.jsx(U2,{})})}const kre=Object.freeze(Object.defineProperty({__proto__:null,BackendResultsPanelView:Y2},Symbol.toStringTag,{value:"Module"}));function G2({onClose:e,providerLabel:n}){const[s,r]=l.useState(""),a=l.useRef(null);return l.useEffect(()=>{var o;(o=a.current)==null||o.focus()},[]),l.useEffect(()=>{const o=i=>{i.key==="Escape"&&e()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[e]),t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onMouseDown:o=>{o.target===o.currentTarget&&e()},children:t.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:[t.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-1",children:"Create New State"}),t.jsxs("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:["Describe the state you want ",n," to build."]}),t.jsx("textarea",{ref:a,value:s,onChange:o=>r(o.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)"}}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:e,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"}),t.jsxs("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 ",n]})]})]})})}const Nre=Object.freeze(Object.defineProperty({__proto__:null,CreateStatePlaceholderModal:G2},Symbol.toStringTag,{value:"Module"}));function V2({dragActive:e,inputRef:n,folderInputRef:s,onDragOver:r,onDragLeave:a,onDrop:o,onFilePick:i,onFolderPick:c}){return t.jsxs(t.Fragment,{children:[t.jsxs("label",{onDragOver:r,onDragLeave:a,onDrop:o,style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"var(--spacing-xl, 32px)",border:`2px dashed ${e?"var(--accent-active)":"var(--border-default)"}`,borderRadius:12,background:e?"var(--bg-elevated, rgba(255,255,255,0.03))":"var(--bg-input)",cursor:"pointer",textAlign:"center",gap:"var(--spacing-xs, 4px)"},children:[t.jsx("input",{ref:n,type:"file",multiple:!0,onChange:i,style:{display:"none"}}),t.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-primary)",fontWeight:500},children:"Drop files or a folder here, or click to choose files"}),t.jsx("div",{style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:"PNG, JPG, PDF, Markdown — anything that describes your design"})]}),t.jsx(Fy,{fileInputRef:n,folderInputRef:s,onFolderPick:c})]})}const Cre=Object.freeze(Object.defineProperty({__proto__:null,DesignAssetDropLabel:V2},Symbol.toStringTag,{value:"Module"}));function K2({pending:e,onDescriptionChange:n,onRemove:s}){return t.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:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("span",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-primary)",fontWeight:500,overflowWrap:"anywhere"},children:e.relativePath}),t.jsx("button",{type:"button",onClick:()=>s(e.id),style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)",background:"transparent",border:"none",cursor:"pointer"},children:"Remove"})]}),t.jsx("textarea",{value:e.description,onChange:r=>n(e.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 Tre=Object.freeze(Object.defineProperty({__proto__:null,PendingFileCard:K2},Symbol.toStringTag,{value:"Module"}));function J2({pending:e,onDescriptionChange:n,onRemove:s}){return e.length===0?null:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-sm, 8px)",marginTop:"var(--spacing-md, 12px)"},children:[t.jsx(Ly,{count:e.length}),e.map(r=>t.jsx(K2,{pending:r,onDescriptionChange:n,onRemove:s},r.id))]})}const Pre=Object.freeze(Object.defineProperty({__proto__:null,PendingFileList:J2},Symbol.toStringTag,{value:"Module"}));function X2({message:e}){return e?t.jsx("div",{style:{marginTop:"var(--spacing-sm, 8px)",color:"var(--accent-danger, #f87171)",fontSize:"var(--text-xs, 12px)"},children:e}):null}const Ore=Object.freeze(Object.defineProperty({__proto__:null,AssetSaveErrorMessage:X2},Symbol.toStringTag,{value:"Module"}));function Q2({filenames:e}){return!e||e.length===0?null:t.jsxs("div",{style:{marginTop:"var(--spacing-sm, 8px)",color:"var(--text-secondary)",fontSize:"var(--text-xs, 12px)"},children:["Added ",e.length," file",e.length===1?"":"s","."]})}const Rre=Object.freeze(Object.defineProperty({__proto__:null,AssetSaveSuccessMessage:Q2},Symbol.toStringTag,{value:"Module"}));function Z2({disabled:e,submitting:n,onClick:s}){return t.jsx("button",{type:"button",onClick:s,disabled:e,style:{marginTop:"var(--spacing-md, 12px)",padding:"var(--spacing-sm, 8px) var(--spacing-md, 12px)",background:e?"var(--bg-input)":"var(--accent-active)",color:e?"var(--text-muted)":"var(--text-on-accent, white)",border:e?"1px solid var(--border-default)":"1px solid var(--accent-active)",borderRadius:6,fontSize:"var(--text-sm, 14px)",fontWeight:500,cursor:e?"not-allowed":"pointer"},children:n?"Saving…":"Save assets"})}const Ere=Object.freeze(Object.defineProperty({__proto__:null,SaveAssetsButton:Z2},Symbol.toStringTag,{value:"Module"})),fH=1024*1024*1024;function eC({onAssetsSaved:e,onRegisterDropReceiver:n}){const[s,r]=l.useState([]),[a,o]=l.useState(!1),[i,c]=l.useState(null),[d,u]=l.useState(null),[p,h]=l.useState(!1),f=l.useRef(null),m=l.useRef(null),g=l.useCallback((w,k)=>{const{valid:S,rejection:N}=YR(w,k,fH);return u(N),r(C=>[...C,...S.map(({file:T,relativePath:P})=>({id:`${P}-${T.size}-${Math.random().toString(36).slice(2)}`,file:T,relativePath:P,description:""}))]),N!==null},[]),x=l.useCallback(async w=>{const k=await GR(w);if(g(k.files,k.expandedViaEntryApi))return;const S=VR(k);S&&u(S)},[g]);l.useEffect(()=>{if(n)return n(w=>(x(w),!0)),()=>n(null)},[n,x]);const b=l.useCallback(w=>{w.target.files&&g(Array.from(w.target.files).map(k=>({file:k,relativePath:k.name})),!1),w.target.value=""},[g]),y=l.useCallback(w=>{if(w.target.files){const k=KR(w.target.files);g(k,!0),k.length===0&&u("No files found in that folder.")}w.target.value=""},[g]),v=l.useCallback((w,k)=>{r(S=>S.map(N=>N.id===w?{...N,description:k}:N))},[]),j=l.useCallback(w=>{r(k=>k.filter(S=>S.id!==w))},[]),_=l.useCallback(async()=>{if(s.length!==0){o(!0),u(null);try{const w=await Bd(s);c(w),r([]),e==null||e(w)}catch(w){u(w instanceof Error?w.message:String(w))}finally{o(!1)}}},[s,e]);return t.jsxs(t.Fragment,{children:[t.jsx(V2,{dragActive:p,inputRef:f,onDragOver:w=>{w.preventDefault(),h(!0)},onDragLeave:()=>h(!1),onDrop:w=>{w.preventDefault(),h(!1),x(w.dataTransfer)},onFilePick:b,onFolderPick:y,folderInputRef:m}),t.jsx(J2,{pending:s,onDescriptionChange:v,onRemove:j}),t.jsx(X2,{message:d}),t.jsx(Q2,{filenames:i}),t.jsx(Z2,{disabled:s.length===0||a,submitting:a,onClick:_})]})}const Are=Object.freeze(Object.defineProperty({__proto__:null,DesignAssetDropZone:eC},Symbol.toStringTag,{value:"Module"}));function tC({onRegisterDropReceiver:e}={}){const[n,s]=l.useState(null),r=l.useRef(!0),a=l.useCallback(async()=>{try{const o=await fetch("/api/editor-design-assets");if(!o.ok)return;const i=await o.json();r.current&&s(Array.isArray(i.assets)?i.assets:[])}catch{}},[]);return l.useEffect(()=>(r.current=!0,a(),()=>{r.current=!1}),[a]),t.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:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"var(--text-md, 15px)",fontWeight:600,color:"var(--text-primary)",marginBottom:"var(--spacing-xs, 4px)"},children:"Add design assets"}),t.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."})]}),t.jsx(eC,{onAssetsSaved:a,onRegisterDropReceiver:e}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-sm, 8px)"},children:[t.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",fontWeight:600,color:"var(--text-primary)"},children:"Added assets"}),n===null?t.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-secondary)"},children:"Loading…"}):n.length===0?t.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",color:"var(--text-secondary)"},children:"No assets added yet."}):n.map(o=>t.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:[t.jsx("span",{style:{fontSize:"var(--text-sm, 14px)",fontWeight:500,color:"var(--text-primary)"},children:o.filename}),o.description.trim().length>0&&t.jsx("span",{style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:o.description})]},o.filename))]})]})}const Mre=Object.freeze(Object.defineProperty({__proto__:null,DesignAssetsView:tC},Symbol.toStringTag,{value:"Module"}));function mH(e,n){var c;const s=[],r=Object.entries(n.vars).filter(([,d])=>d&&d.trim());if(r.length>0){const d=r.map(([u,p])=>` ${u}: ${p} !important;`).join(`
|
|
192
|
+
`);s.push(`:root, body {
|
|
193
|
+
${d}
|
|
194
|
+
}`)}if(n.primaryFont){const d=Cm(n.primaryFont,n.primaryFontStack);s.push(`body, p, li, span, button, input, textarea, select, label { font-family: ${d} !important; }`)}if(n.secondaryFont){const d=Cm(n.secondaryFont,n.secondaryFontStack);s.push(`h1, h2, h3, h4, h5, h6, .heading, [class*="title"], [class*="headline"] { font-family: ${d} !important; }`)}const a=s.length>0?`<style data-codeyam-overrides="1">
|
|
195
|
+
${s.join(`
|
|
196
|
+
|
|
197
|
+
`)}
|
|
198
|
+
</style>`:"",o=n.fontsHref?`<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
199
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
200
|
+
<link rel="stylesheet" href="${n.fontsHref}" data-codeyam-fonts="1">`:"";if(!a&&!o)return e;const i=e.search(/<\/head\s*>/i);if(i===-1){const d=e.search(/<body[^>]*>/i);if(d===-1)return`${o}
|
|
201
|
+
${a}
|
|
202
|
+
${e}`;const u=d+(((c=e.match(/<body[^>]*>/i))==null?void 0:c[0].length)??0);return`${e.slice(0,u)}
|
|
203
|
+
${o}
|
|
204
|
+
${a}
|
|
205
|
+
${e.slice(u)}`}return`${e.slice(0,i)}
|
|
206
|
+
${o}
|
|
207
|
+
${a}
|
|
208
|
+
${e.slice(i)}`}function Cm(e,n){const s=/\s/.test(e)?`"${e}"`:e,r=(n==null?void 0:n.trim())||"system-ui, sans-serif";return`${s}, ${r}`}const gH={vars:{},primaryFont:null,secondaryFont:null,primaryFontStack:null,secondaryFontStack:null};function ta(e){return e.replace(/^\d{1,2}-/,"").replace(/-mockup\.html$/i,"").replace(/\.html$/i,"")}function nC(e){return ta(e).replace(/-/g," ")}function xH(e,n){if(e===null||e.length!==n.length)return!1;for(let s=0;s<e.length;s++)if(e[s].filename!==n[s].filename||e[s].url!==n[s].url||e[s].name!==n[s].name)return!1;return!0}const bH="\x1B[200~",yH="\x1B[201~";function bc(e,n=vH,s=Kc){const r=e.replace(/\r\n/g,"\r").replace(/\n/g,"\r"),a=`${bH}${r}${yH}`;return n(a),new Promise(o=>{setTimeout(()=>{n("\r"),o()},s)})}function vH(e){Sn(e,Rb()??JR)}const Ar=5;function Tp(e){return e==null?0:Math.max(1,Math.min(Ar,Math.round(e/(100/Ar))))}function jH(e){return e<=0?null:Math.min(Ar,e)*(100/Ar)}const Tm='which of four things should happen to each design in the next round: Keep it unchanged, Iterate on it (refine in place), make Multiple versions of it (2-4 variations), or Replace it with a fresh redesign. Wait for their reply before writing any mockup. This is NOT a selection: the user has not picked or locked in any design, and a high rating is not a pick. Do not select a design, and do not tell them they chose one. In your question, name each design by its number and plain name and suggest a choice for each, then end the message with your suggestion as a fenced block the chat reads and hides, e.g. ```design-plan {"01-foo-mockup.html":"keep","02-bar-mockup.html":"iterate","03-baz-mockup.html":"replace"} ``` (verbs: keep, iterate, versions, replace).';function wH({feedbackByFilename:e,mockupFilenames:n,titles:s={},feedbackFile:r}){const a={};for(const d of n){const u=e[d];if(!u)continue;const p=typeof u.rating=="number",h=u.comment.trim().length>0;!p&&!h||(a[d]={rating:p?u.rating:null,comment:u.comment.trim()})}const o=Object.keys(a);if(o.length===0)return"Iterate: before regenerating anything, first ask the user in the chat "+Tm+" No per-card feedback was provided, so let their answer guide what happens to each design.";const i=JSON.stringify(a,null,2),c=o.map(d=>{const{rating:u,comment:p}=a[d],h=s[d]?` (${s[d]})`:"",f=u===null?"no stars":`${Tp(u)}/5 stars`,m=p?` Note: "${p}"`:" No note.";return`- ${d}${h}: ${f}.${m}`}).join(`
|
|
209
|
+
`);return"Iterate: before regenerating anything, first ask the user in the chat "+Tm+` Base your suggestion on the ratings below.
|
|
210
|
+
|
|
211
|
+
Once they answer, follow their choice for each design exactly: Keep = leave the file untouched. Iterate = refine it in place using its specific feedback, keeping the same numeric prefix and design system. Multiple versions = make the requested number of distinct variations of its direction; the first reuses its numeric prefix, the rest take the next free numbers, never overwriting a kept slot. Replace = 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.
|
|
212
|
+
|
|
213
|
+
Every note is a must-fix for every design you change: iterating on a design never means keeping what its note complained about. Notes may be in any language. Follow Step 5 of the codeyam-design skill: write the feedback checklist before editing, and check each new file against it before you say the round is done.
|
|
214
|
+
|
|
215
|
+
Feedback, design by design:
|
|
216
|
+
`+c+`
|
|
217
|
+
|
|
218
|
+
`+(r?`The same feedback is saved in ${r}; re-read it right before you write the new designs.
|
|
219
|
+
|
|
220
|
+
`:"")+"Per-card feedback (rating is 1-100 or null; comment may be empty):\n\n```json\n"+i+"\n```"}const _H=9e4;function SH(e){return!!(e.agentRespondedAfterDispatch||kH(e.snapshotFilenames,e.latestFilenames))}function kH(e,n){if(e.length!==n.length)return!0;const s=[...e].sort(),r=[...n].sort();for(let a=0;a<s.length;a++)if(s[a]!==r[a])return!0;return!1}function NH(e){const n={},s={},r=e.split(`
|
|
221
|
+
`);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 g=d[1].length;o=o.slice(0,g-1),o[g-1]=d[2].trim();continue}if(!c.startsWith("|"))continue;const u=c.split("|").map(g=>g.trim());if(u.length<3)continue;const p=u[1].replace(/`/g,"").trim(),h=u[2].replace(/`/g,"").trim();if(!/^--[A-Za-z0-9_-]+$/.test(p)||!CH(h))continue;const f=o.filter(Boolean).join(" / "),m=sC(f)?s:n;p in m||(m[p]=h)}return{light:n,dark:s}}function sC(e){return/\bdark[\s-]?mode\b|\bdark\b\s*(palette|variant|theme)?/i.test(e)}function CH(e){return!!(/^#[0-9a-fA-F]{3,8}$/.test(e)||/^rgba?\(/i.test(e)||/^hsla?\(/i.test(e)||/^oklch\(/i.test(e))}const TH=["Background","Surface","Text","Primary","Secondary","Accent"],PH={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 OH(e){const n=[],s=e.split(`
|
|
222
|
+
`);let r=!1,a="",o=0,i=null,c=[];for(let d=0;d<s.length;d++){const p=s[d].trim();if(!r){const h=/^(#{1,6})\s+(.+)$/.exec(p);if(h){const m=h[1].length;c=c.slice(0,m-1),c[m-1]=h[2].trim(),i=h[2].trim();continue}const f=/^```(\w*)/.exec(p);f&&(r=!0,a=f[1].toLowerCase(),o=d+1);continue}if(p==="```"){if(a==="css"||a===""){const h=s.slice(o,d).join(`
|
|
223
|
+
`);for(const f of EH(h)){const m=c.filter(Boolean).join(" / "),g=RH(f.selector)||sC(m);n.push({selector:f.selector,heading:i,isDark:g,vars:f.vars})}}r=!1,a=""}}return n}function RH(e){return/\[data-theme[~|*$^]?="?dark"?\]/.test(e)}function EH(e){const n=[],s=/(:root[^\{]*?)\{([\s\S]*?)\}/g;let r;for(;(r=s.exec(e))!==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],p=d[2].replace(/\/\*.*?\*\//g,"").trim();p&&(i[u]=p)}Object.keys(i).length>0&&n.push({selector:a,vars:i})}return n}function AH(e,n){const s=PH[n];for(const r of Object.keys(e))for(const a of s)if(a.test(r))return{cssVar:r,value:e[r]};return{cssVar:null,value:null}}function MH(e){const n=/\[data-palette[~|*$^]?="?([^"\]]+)"?\]/.exec(e);return n?n[1].split("-").map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" "):null}function IH(e){if(!e)return"Default";let n=e.replace(/\(.+?\)/g,"");return n=n.replace(/\bpalette\b/i,"").replace(/\bmode\b/i,""),/\bdark\b/i.test(n)?"Default":(n=n.replace(/\bdark\b/i,""),n=n.replace(/\blight\b/i,""),n=n.trim().replace(/\s+/g," "),n||"Default")}function Pm(e){const n=TH.map(s=>{const{cssVar:r,value:a}=AH(e,s);return{label:s,cssVar:r,value:a}});return{vars:e,slots:n}}function Pp(e){const n=OH(e),s=new Map,r=new Map,a=[];for(const o of n){const c=MH(o.selector)??IH(o.heading);a.includes(c)||a.push(c),o.isDark?r.has(c)||r.set(c,o.vars):s.has(c)||s.set(c,o.vars)}if(s.size===0){const o=NH(e);o.light&&Object.keys(o.light).length>0&&(a.unshift("Default"),s.set("Default",o.light),o.dark&&Object.keys(o.dark).length>0&&r.set("Default",o.dark))}return a.map(o=>{const i=s.get(o);if(!i)return null;const c=r.get(o)??null;return{name:o,light:Pm(i),dark:c?Pm(c):null}}).filter(o=>o!==null)}function DH(e){const n=Object.keys(e);if(n.length===0)return{};const s=iC(e),r={};for(const a of n){const o=e[a];if(!o||!o.trim())continue;const i=s.get(a)??null;r[a]=FH(o,i)}return r}const rC="#0f1115",LH="#181b21",aC="#e8eaed";function oC(e){const n=iC(e);let s=null,r=null;for(const[a,o]of n){const i=e[a];!i||!i.trim()||(o==="Background"&&s===null&&(s=i),o==="Text"&&r===null&&(r=i))}return{bg:s??rC,text:r??aC}}function iC(e){var i;const s=["```css",":root {",Object.entries(e).map(([c,d])=>` ${c}: ${d};`).join(`
|
|
224
|
+
`),"}","```"].join(`
|
|
225
|
+
`),r=Pp(s),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 FH(e,n){switch(n){case"Background":return rC;case"Surface":return LH;case"Text":return aC;case"Primary":case"Secondary":case"Accent":return Om(e);default:return Om(e)}}function Om(e){const n=$H(e.trim());if(!n)return e;const{h:s,s:r,l:a}=zH(n.r,n.g,n.b),{r:o,g:i,b:c}=BH(s,r,1-a),d=u=>u.toString(16).padStart(2,"0");return n.a!=null&&n.a<1?`rgba(${o}, ${i}, ${c}, ${n.a})`:`#${d(o)}${d(i)}${d(c)}`}function $H(e){const n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e);if(n){let r=n[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 s=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/i.exec(e);return s?{r:qi(parseInt(s[1],10)),g:qi(parseInt(s[2],10)),b:qi(parseInt(s[3],10)),a:s[4]!=null?parseFloat(s[4]):void 0}:null}function qi(e){return Math.max(0,Math.min(255,e))}function zH(e,n,s){const r=e/255,a=n/255,o=s/255,i=Math.max(r,a,o),c=Math.min(r,a,o),d=(i+c)/2;let u=0,p=0;if(i!==c){const h=i-c;switch(p=d>.5?h/(2-i-c):h/(i+c),i){case r:u=(a-o)/h+(a<o?6:0);break;case a:u=(o-r)/h+2;break;default:u=(r-a)/h+4;break}u/=6}return{h:u,s:p,l:d}}function BH(e,n,s){if(n===0){const i=Math.round(s*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=s<.5?s*(1+n):s+n-s*n,o=2*s-a;return{r:Math.round(r(o,a,e+1/3)*255),g:Math.round(r(o,a,e)*255),b:Math.round(r(o,a,e-1/3)*255)}}function WH(e){const[n,s]=l.useState({}),r=l.useRef(!0);return l.useEffect(()=>(r.current=!0,()=>{r.current=!1}),[]),l.useEffect(()=>{if(!e)return;const a=new Set,o=e.map(i=>ta(i.filename)).filter(i=>a.has(i)?!1:(a.add(i),!(i in n)));o.length!==0&&(async()=>{var i,c,d;for(const u of o)try{const p=await fetch(`/api/editor-design-systems/${u}`);if(!p.ok)continue;const h=await p.json().catch(()=>null);if(!(h!=null&&h.content)){r.current&&s(b=>({...b,[u]:null}));continue}const f=Pp(h.content),m=((c=(i=f[0])==null?void 0:i.dark)==null?void 0:c.vars)??null,g=((d=f[0])==null?void 0:d.light.vars)??null,x=m&&Object.keys(m).length>0?m:g&&Object.keys(g).length>0?DH(g):null;r.current&&s(b=>({...b,[u]:x}))}catch{r.current&&s(p=>({...p,[u]:null}))}})()},[e,n]),n}function HH(){const[e,n]=l.useState([]);return l.useEffect(()=>{let s=!1;async function r(){try{const o=await fetch("/api/editor-mockups-history");if(!o.ok)return;const i=await o.json();s||n(Array.isArray(i)?i:[])}catch{}}r();const a=window.setInterval(r,4e3);return()=>{s=!0,window.clearInterval(a)}},[]),e}function lC({round:e,onRestore:n,restoring:s=!1}){if(!e||!e.mockups||e.mockups.length===0)return t.jsx(nu,{});const r=e.feedback??{};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--spacing-md, 14px)"},children:[n&&t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{type:"button",onClick:n,disabled:s,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:s?"default":"pointer",opacity:s?.6:1},children:s?"Bringing back…":"Bring back this round"})}),t.jsx("div",{"data-mockup-archived-round":!0,style:{display:"grid",gridTemplateColumns:"1fr 1fr",columnGap:"var(--spacing-lg, 16px)",rowGap:"var(--spacing-xl, 28px)"},children:e.mockups.map((a,o)=>{const i=r[a.filename],c=o+1,d=a.name.replace(/^\d{1,2}-/,"").replace(/-/g," ");return t.jsxs("div",{style:{display:"flex",flexDirection:"column",border:"1px solid var(--border-default)",borderRadius:12,overflow:"hidden",background:"var(--bg-surface)"},children:[t.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:[t.jsx("span",{style:{fontWeight:700,color:"var(--text-muted)"},children:String(c).padStart(2,"0")}),t.jsx("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",style:{textTransform:"capitalize",fontWeight:500,color:"var(--text-primary)",textDecoration:"none"},children:d})]}),t.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)&&t.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"&&t.jsxs("div",{children:[t.jsxs("span",{style:{color:"var(--text-muted)"},children:["Rating ·"," "]}),t.jsxs("span",{style:{color:"var(--text-primary)"},children:[i.rating,"/100"]})]}),i.comment.trim().length>0&&t.jsxs("div",{style:{lineHeight:1.4},children:[t.jsxs("span",{style:{color:"var(--text-muted)"},children:["Note ·"," "]}),t.jsx("span",{style:{color:"var(--text-primary)"},children:i.comment})]})]})]},a.filename)})})]})}const Ire=Object.freeze(Object.defineProperty({__proto__:null,MockupArchivedRoundView:lC},Symbol.toStringTag,{value:"Module"})),qH=`
|
|
226
|
+
.mockup-feedback-comment {
|
|
227
|
+
width: 100%;
|
|
228
|
+
padding: var(--spacing-sm, 8px) var(--spacing-sm, 10px);
|
|
229
|
+
background: var(--bg-card, #1a1a1a);
|
|
230
|
+
color: var(--text-primary);
|
|
231
|
+
border: 1px solid var(--border-default);
|
|
232
|
+
border-radius: 6px;
|
|
233
|
+
font-size: var(--text-xs, 12px);
|
|
234
|
+
line-height: 1.4;
|
|
235
|
+
resize: vertical;
|
|
236
|
+
box-sizing: border-box;
|
|
237
|
+
min-height: 56px;
|
|
238
|
+
outline: none;
|
|
239
|
+
}
|
|
240
|
+
.mockup-feedback-comment:focus,
|
|
241
|
+
.mockup-feedback-comment:focus-visible {
|
|
242
|
+
border-color: var(--text-primary, #ffffff);
|
|
243
|
+
outline: none;
|
|
244
|
+
box-shadow: 0 0 0 1px var(--text-primary, #ffffff);
|
|
245
|
+
}
|
|
246
|
+
`;function cC({comment:e,onCommentChange:n,autoFocus:s=!1}){return t.jsxs(t.Fragment,{children:[t.jsx("style",{children:qH}),t.jsx("textarea",{autoFocus:s,"aria-label":"Feedback on this design",value:e,onChange:r=>n(r.target.value),placeholder:"What do you like or would like to change? (optional)",rows:3,className:"mockup-feedback-comment"})]})}const Dre=Object.freeze(Object.defineProperty({__proto__:null,MockupFeedbackCommentBox:cC},Symbol.toStringTag,{value:"Module"}));function Op({rating:e,onRatingChange:n,size:s=18}){const[r,a]=l.useState(0),o=Tp(e),i=r||o;return t.jsx("div",{role:"group","aria-label":"Rate this design","data-testid":"mockup-stars",onMouseLeave:()=>a(0),style:{display:"inline-flex",gap:2},children:Array.from({length:Ar},(c,d)=>{const u=d+1,p=u<=i;return t.jsx("button",{type:"button","aria-label":`${u} star${u>1?"s":""}`,"aria-pressed":u<=o,onMouseEnter:()=>a(u),onClick:h=>{h.stopPropagation(),n(jH(u===o?0:u))},style:{background:"transparent",border:"none",padding:1,cursor:"pointer",lineHeight:0,color:p?"var(--accent-active, #D7FF63)":"rgba(255,255,255,.25)"},children:t.jsx("svg",{width:s,height:s,viewBox:"0 0 20 20","aria-hidden":"true",children:t.jsx("path",{d:"M10 1.8l2.5 5.1 5.6.8-4 4 .9 5.6L10 14.7l-5 2.6.9-5.6-4-4 5.6-.8z",fill:p?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round"})})},u)})})}const Lre=Object.freeze(Object.defineProperty({__proto__:null,MockupFeedbackStars:Op},Symbol.toStringTag,{value:"Module"})),Rp={rating:null,comment:""};function dC({value:e,onChange:n}){const[s,r]=l.useState(!1),[a,o]=l.useState(!1),i=s||e.rating!=null||e.comment.length>0;return t.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:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[t.jsx(Op,{rating:e.rating,onRatingChange:c=>{i||o(!0),r(!0),n({...e,rating:c})}}),!i&&t.jsx("button",{type:"button",onClick:()=>{r(!0),o(!0)},style:{marginLeft:"auto",background:"transparent",border:"none",padding:0,cursor:"pointer",fontSize:12.5,color:"var(--text-muted)"},children:"Add a note"})]}),i&&t.jsx(cC,{comment:e.comment,autoFocus:a,onCommentChange:c=>n({...e,comment:c})})]})}const Fre=Object.freeze(Object.defineProperty({__proto__:null,EMPTY_FEEDBACK:Rp,MockupCardFeedback:dC},Symbol.toStringTag,{value:"Module"})),Ep=["Background","Surface","Text","Primary","Secondary","Accent"],UH={Background:["bg","background","canvas","page","paper","base"],Surface:["surface","card","panel","elevated","raised","sheet","cream"],Text:["text","fg","foreground","ink","copy"],Primary:["primary","accent","brand"],Secondary:["secondary"],Accent:["highlight","tertiary"]},YH=new Set(["black","white","transparent","currentcolor"]);function Ap(e){const n=e.trim().toLowerCase();return n?/^#[0-9a-f]{3,8}$/.test(n)||/^(rgb|rgba|hsl|hsla|oklch|oklab|lab|lch|color)\(/.test(n)?!0:YH.has(n):!1}function Mp(e){const n={};for(const[s,r]of GH(e)){if(/dark/i.test(s))continue;const a=/(--[A-Za-z0-9_-]+)\s*:\s*([^;\n}]+?)\s*(?:;|$)/g;let o;for(;(o=a.exec(r))!==null;){const i=o[2].replace(/\/\*.*?\*\//g,"").replace(/\s*!important\s*$/i,"").trim();i&&(o[1]in n||(n[o[1]]=i))}}return n}function GH(e){const n=[];let s=0;for(let r=e.indexOf(":root",s);r>=0;r=e.indexOf(":root",s)){const a=e.indexOf("{",r+5),o=a<0?-1:e.indexOf("}",a+1);if(o<0)break;const i=Math.max(s,e.lastIndexOf("{",r)+1,e.lastIndexOf("}",r)+1);n.push([e.slice(i,a),e.slice(a+1,o)]),s=o+1}return n}function VH(e,n){const s=e.replace(/^--/,"").split("-").filter(Boolean),r=UH[n];let a=null;for(let o=0;o<r.length;o++){const i=s.lastIndexOf(r[o]);if(i===-1)continue;const c=o*10+(s.length-1-i);(a===null||c<a)&&(a=c)}return a}function KH(e){let n=null;for(const s of Ep){const r=VH(e,s);r!==null&&(!n||r<n.score)&&(n={role:s,score:r})}return n}function JH(e){const n=e.trim().toLowerCase();if(n==="transparent")return!0;const s=/^#([0-9a-f]{4}|[0-9a-f]{8})$/.exec(n);if(s)return s[1].length===4?!s[1].endsWith("f"):!s[1].endsWith("ff");const r=/^(?:rgba?|hsla?)\([^)]*[,/]\s*([\d.]+)(%?)\s*\)$/.exec(n);return r&&(n.match(/[\d.]+%?/g)??[]).length===4?(r[2]?parseFloat(r[1])/100:Number(r[1]))<1:!1}function XH(e){const n=QH(e);if(!n)return 0;const s=Math.max(n[0],n[1],n[2]),r=Math.min(n[0],n[1],n[2]);return s===0?0:(s-r)/s}function QH(e){const n=e.trim(),s=/^#([0-9a-fA-F]{3,8})$/.exec(n);if(s){const a=s[1];return a.length===3||a.length===4?[parseInt(a[0]+a[0],16),parseInt(a[1]+a[1],16),parseInt(a[2]+a[2],16)]:a.length===6||a.length===8?[parseInt(a.slice(0,2),16),parseInt(a.slice(2,4),16),parseInt(a.slice(4,6),16)]:null}const r=/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/.exec(n);return r?[Number(r[1]),Number(r[2]),Number(r[3])]:null}function Ip(e,n=[]){const s=Mp(e),r=Object.keys(s).filter(d=>Ap(s[d])&&!JH(s[d])),a=new Map,o=new Set,i=new Map;for(const d of r){const u=KH(d);if(!u)continue;const p=i.get(u.role);(!p||u.score<p.score)&&i.set(u.role,{name:d,score:u.score})}for(const[d,{name:u}]of i)a.set(d,u),o.add(u);for(const d of n)a.has(d.label)||!d.cssVar||o.has(d.cssVar)||d.cssVar in s&&(a.set(d.label,d.cssVar),o.add(d.cssVar));const c=r.filter(d=>!o.has(d)).map(d=>({name:d,sat:XH(s[d])})).filter(d=>d.sat>.3).sort((d,u)=>u.sat-d.sat);for(const d of["Primary","Secondary","Accent"]){if(a.has(d))continue;const u=c.find(p=>!o.has(p.name));if(!u)break;a.set(d,u.name),o.add(u.name)}return Ep.map(d=>{const u=a.get(d)??null;return{label:d,cssVar:u,value:u?s[u]:null}})}function ZH(e){const n=Mp(e);return Object.entries(n).flatMap(([s,r])=>{const a=/^(\d+(?:\.\d+)?)px$/.exec(r.trim());return/radius/i.test(s)&&a?[{name:s,px:parseFloat(a[1])}]:[]})}function e7(e,n){const s=Math.max(...e.map(r=>r.px));return Object.fromEntries(e.map(r=>[r.name,`${s>0?Math.round(r.px/s*n):n}px`]))}const Dp=[{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]}],$re={sans:"Sans-serif",serif:"Serif",display:"Display",mono:"Monospace"};function uC(e){const n=new Set,s=[];for(const r of e){if(!r||n.has(r))continue;n.add(r);const a=Dp.find(c=>c.family===r),o=(a==null?void 0:a.weights)??[400,700],i=r.replace(/ /g,"+");s.push(`family=${i}:wght@${o.join(";")}`)}return s.length===0?"":`https://fonts.googleapis.com/css2?${s.join("&")}&display=swap`}const t7=new Set(["Background","Surface","Text"]),n7=.3;function yc(e,n,s){const r=Mp(e),a=n.filter(c=>!!c.cssVar&&!!c.value).map(c=>({cssVar:c.cssVar,neutral:c.label?t7.has(c.label):!1,rgba:Os(c.value)})).filter(c=>c.rgba!==null),o=new Set(a.map(c=>c.cssVar)),i={};for(const[c,d]of Object.entries(r)){if(o.has(c)||!Ap(d))continue;const u=Os(d);if(!u)continue;const p=Nn(u).s<n7,h=p&&a.some(x=>x.neutral)?a.filter(x=>x.neutral):a;let f=null,m=1/0;for(const x of h){const b=p?Math.abs(Nn(u).l-Nn(x.rgba).l):r7(u,x.rgba);b<m&&(m=b,f=x)}if(!f||!(f.cssVar in s))continue;const g=Os(s[f.cssVar]);g&&(i[c]=vc(s7(u,f.rgba,g)))}return i}function s7(e,n,s){const r=Nn(e),a=Nn(n),o=Nn(s),c=a.s>.12&&r.s>.12?(o.h+(r.h-a.h)+360)%360:o.h,d=Rm(o.s+(r.s-a.s)),u=a.l>.5!=o.l>.5?-1:1,p=Rm(o.l+u*(r.l-a.l));return{...jc(c,d,p),a:e.a}}function r7(e,n){return Math.hypot(e.r-n.r,e.g-n.g,e.b-n.b)}function Rm(e){return Math.min(1,Math.max(0,e))}function Os(e){const n=e.trim().toLowerCase();if(n==="white")return{r:255,g:255,b:255,a:1};if(n==="black")return{r:0,g:0,b:0,a:1};const s=/^#([0-9a-f]{3,8})$/.exec(n);if(s){const a=s[1];if(a.length===3||a.length===4){const o=i=>parseInt(a[i]+a[i],16);return{r:o(0),g:o(1),b:o(2),a:a.length===4?o(3)/255:1}}if(a.length===6||a.length===8){const o=i=>parseInt(a.slice(i,i+2),16);return{r:o(0),g:o(2),b:o(4),a:a.length===8?o(6)/255:1}}return null}const r=/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/.exec(n);if(r){const a=r[4]===void 0?1:r[4].endsWith("%")?parseFloat(r[4])/100:Number(r[4]);return{r:Number(r[1]),g:Number(r[2]),b:Number(r[3]),a}}return null}function vc(e){const n=Math.round(e.r),s=Math.round(e.g),r=Math.round(e.b);return e.a>=1?`#${[n,s,r].map(a=>a.toString(16).padStart(2,"0")).join("")}`:`rgba(${n}, ${s}, ${r}, ${Math.round(e.a*1e3)/1e3})`}function Nn({r:e,g:n,b:s}){const r=e/255,a=n/255,o=s/255,i=Math.max(r,a,o),c=Math.min(r,a,o),d=(i+c)/2;if(i===c)return{h:0,s:0,l:d};const u=i-c,p=d>.5?u/(2-i-c):u/(i+c);let h;return i===r?h=(a-o)/u+(a<o?6:0):i===a?h=(o-r)/u+2:h=(r-a)/u+4,{h:h*60,s:p,l:d}}function jc(e,n,s){if(n===0)return{r:s*255,g:s*255,b:s*255};const r=s<.5?s*(1+n):s+n-s*n,a=2*s-r,o=e/360,i=c=>{let d=c;return d<0&&(d+=1),d>1&&(d-=1),d<1/6?a+(r-a)*6*d:d<1/2?r:d<2/3?a+(r-a)*(2/3-d)*6:a};return{r:i(o+1/3)*255,g:i(o)*255,b:i(o-1/3)*255}}function pC(e,n,s){const r={},a=Em(e,s),o=Em(n,s),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 Em(e,n){return e?n==="dark"&&e.dark?e.dark.slots:e.light.slots:[]}function a7(e){if(!e.some(r=>r.cssVar))return;const n={};for(const r of e)r.cssVar&&r.value&&(n[r.cssVar]=r.value);const s={vars:n,slots:e};return{name:"Mockup",light:s,dark:s}}function o7(e,n,s){const r=a7(e);if(!r)return{};const a=pC(r,n,s),o=new Set(e.map(i=>i.cssVar).filter(i=>!!i));return Object.fromEntries(Object.entries(a).filter(([i])=>o.has(i)))}function hC(e){var g,x,b,y,v,j;const n=i7(e);if(Object.keys(n).filter(_=>Ap(n[_])).length>=2)return{vars:n,...oC(n),source:"own"};const s=Ip(e),r=_=>s.find(w=>w.label===_),a=r("Background"),o=a!=null&&a.value?Os(a.value):null;if(!(a!=null&&a.cssVar)||!o||Nn(o).l<.45)return null;const c=(_,w,k)=>{const S=_?Os(_):null;if(!S)return null;const N=Nn(S);return vc({...jc(N.h,Math.min(N.s,k),w),a:S.a})},d=_=>{const w=_?Os(_):null;if(!w)return null;const k=Nn(w);return vc({...jc(k.h,k.s,Math.max(k.l,.62)),a:w.a})},u={},p=(_,w)=>{const k=r(_);k!=null&&k.cssVar&&w&&(u[k.cssVar]=w)};p("Background",c(a.value,.08,.22)),p("Surface",c(((g=r("Surface"))==null?void 0:g.value)??a.value,.125,.2)),p("Text",c(((x=r("Text"))==null?void 0:x.value)??"#111111",.92,.1)),p("Primary",d(((b=r("Primary"))==null?void 0:b.value)??null)),p("Secondary",d(((y=r("Secondary"))==null?void 0:y.value)??null)),p("Accent",d(((v=r("Accent"))==null?void 0:v.value)??null));const h={...yc(e,s,u),...u},f=a.cssVar,m=(j=r("Text"))==null?void 0:j.cssVar;return{vars:h,bg:h[f]??"#141414",text:m&&h[m]||"#ececec",source:"derived"}}function i7(e){const n={},s=a=>{const o=/(--[A-Za-z0-9_-]+)\s*:\s*([^;}]+?)\s*(?:;|$)/g;let i;for(;(i=o.exec(a))!==null;){const c=i[2].replace(/\/\*.*?\*\//g,"").replace(/\s*!important\s*$/i,"").trim();c&&!(i[1]in n)&&(n[i[1]]=c)}};for(const[a,o]of Am(e))/data-theme\s*=\s*["']?dark|\.dark\b/i.test(a)&&s(o);const r=/@media[^{]*prefers-color-scheme\s*:\s*dark[^{]*\{/gi;for(;r.exec(e)!==null;){let a=1,o=r.lastIndex;const i=o;for(;o<e.length&&a>0;)e[o]==="{"?a++:e[o]==="}"&&a--,o++;const c=e.slice(i,o-1);for(const[d,u]of Am(c))/:root|html|body/i.test(d)&&s(u)}return n}function Am(e){const n=[];let s=0,r=-1;for(let a=0;a<e.length;a++){const o=e[a];o==="{"?(r>=0&&(s=r+1),r=a):o==="}"&&(r>=0&&n.push([e.slice(s,r),e.slice(r+1,a)]),s=a+1,r=-1)}return n}function Lp(e){const n=/<meta\b[^>]*>/gi;let s;for(;(s=n.exec(e))!==null;){const r=s[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 fC(e,n){const{vars:s,bg:r,text:a}=l7(n),o=Object.entries(s).filter(([,h])=>h&&h.trim());if(o.length===0)return e;const i=[`:root {
|
|
247
|
+
`+o.map(([h,f])=>` ${h}: ${f};`).join(`
|
|
248
|
+
`)+`
|
|
249
|
+
}`,":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(`
|
|
250
|
+
`)}</style>`;if(e.search(/<\/head\s*>/i)===-1)return`${c}
|
|
251
|
+
${e}`;const u=c7(e),p=u.search(/<\/head\s*>/i);return`${u.slice(0,p)}
|
|
252
|
+
${c}
|
|
253
|
+
${u.slice(p)}`}function l7(e){return e&&typeof e=="object"&&"vars"in e&&typeof e.vars=="object"?e:{vars:e}}function c7(e){const n=/<html\b([^>]*)>/i,s=n.exec(e);if(!s)return e;let r=s[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 e.replace(n,`<html${r}>`)}function d7(e,n){const[s,r]=l.useState({kind:"loading"});return l.useEffect(()=>{let a=!1;return r({kind:"loading"}),(async()=>{try{const[o,i]=await Promise.all([fetch(e),fetch(`/api/editor-design-systems/${n}`)]),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:Pp(d)})}catch(o){a||r({kind:"error",message:o instanceof Error?o.message:String(o)})}})(),()=>{a=!0}},[e,n]),s}const u7={vars:{},primaryFont:null,secondaryFont:null,primaryFontStack:null,secondaryFontStack:null};function p7(e,n,s){const r=d7(e,n),[a,o]=l.useState(s),[i,c]=l.useState(null),[d,u]=l.useState("light"),p=l.useMemo(()=>{const k=[];return a.primaryFont&&k.push(a.primaryFont),a.secondaryFont&&k.push(a.secondaryFont),k.length===0?null:uC(k)},[a.primaryFont,a.secondaryFont]),h=l.useMemo(()=>r.kind==="ready"?hC(r.html):null,[r]),f=l.useMemo(()=>d==="dark"&&h?{...h.vars,...a.vars}:a.vars,[d,h,a.vars]),m=l.useMemo(()=>{if(r.kind!=="ready")return"";const k=d==="dark"&&h?fC(r.html,h):r.html;return mH(k,{...a,fontsHref:p})},[r,a,d,h,p]),g=l.useMemo(()=>{var S,N;if(r.kind!=="ready")return[];const k=d==="dark"&&((S=r.palettes[0])!=null&&S.dark)?r.palettes[0].dark.slots:((N=r.palettes[0])==null?void 0:N.light.slots)??[];return Ip(r.html,k)},[r,d]),x=g.some(k=>k.cssVar),b=l.useCallback(k=>{c(k.name);const S=x?o7(g,k,d):pC(r.kind==="ready"?r.palettes[0]:void 0,k,d),N=x&&r.kind==="ready"?yc(r.html,g,S):{};o(C=>({...C,vars:{...C.vars,...N,...S}}))},[x,r,g,d]),y=l.useCallback((k,S)=>{c(null);const N=r.kind==="ready"?yc(r.html,g,{[k]:S}):{};o(C=>({...C,vars:{...C.vars,...N,[k]:S}}))},[r,g]),v=l.useCallback(()=>{o(u7),c(null)},[]),j=l.useMemo(()=>x?d!=="dark"||!h?g:g.map(k=>k.cssVar&&h.vars[k.cssVar]?{...k,value:h.vars[k.cssVar]}:k):Ep.map(k=>({label:k,cssVar:null,value:null})),[x,g,d,h]),_=!!h,w=Object.keys(a.vars).length>0||!!a.primaryFont||!!a.secondaryFont;return{state:r,overrides:a,setOverrides:o,theme:d,setTheme:u,hasDark:_,srcDoc:m,stackedVars:f,slots:j,activePaletteName:i,applyPalette:b,changeColor:y,reset:v,isEdited:w}}const h7=3;function f7(e){const[n,s]=l.useState([]),r=e.map(a=>a.url).join("|");return l.useEffect(()=>{let a=!1;return Promise.all(e.map(async o=>{try{const i=await fetch(o.url);if(!i.ok)return null;const c=Ip(await i.text());return c.filter(d=>d.value).length<h7?null:{name:o.name,light:{vars:{},slots:c},dark:null}}catch{return null}})).then(o=>{a||s(o.filter(i=>i!==null))}),()=>{a=!0}},[r]),n}function mC({message:e}){return t.jsx("div",{style:{padding:"var(--spacing-md, 12px)",color:"var(--accent-danger, #f87171)",fontSize:"var(--text-sm, 14px)"},children:e})}const zre=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizeErrorBanner:mC},Symbol.toStringTag,{value:"Module"})),bt={bezel:14,outerRadius:56,screenRadius:44,bodyColor:"#0d0d0f",ringColor:"rgba(255, 255, 255, 0.14)",notchWidth:120,notchHeight:30,notchTopInset:10,notchColor:"#0d0d0f",homeIndicatorWidth:134,homeIndicatorHeight:5,homeIndicatorBottomInset:8,homeIndicatorColor:"rgba(0, 0, 0, 0.35)"};function gC(e){return e==="mobile"}function m7(e){return gC(e)?bt.bezel:0}const ii={desktop:{w:1440,h:900},tablet:{w:834,h:1112},mobile:{w:390,h:844}},Mm="desktop",wc=1280,_c=1280;function xC(e){const n=ii[e],s=m7(e);return{w:n.w+s*2,h:n.h+s*2}}function g7(e){const[n,...s]=e;return n?s.some(r=>r!==n)?{w:wc,h:_c}:xC(n):{w:wc,h:_c}}const bC=Bs.backgroundColor,yC=Bs.backgroundImage,vC=Bs.backgroundSize;function x7(e,n,s,r){if(e<=0||n<=0||s<=0||r<=0)return{scale:0,offsetX:0,offsetY:0};const a=Math.min(e/s,n/r),o=s*a,i=r*a;return{scale:a,offsetX:Math.max(0,(e-o)/2),offsetY:Math.max(0,(n-i)/2)}}function b7(e,n,s){if(e<=0||n<=0)return{scale:0,frameW:s,frameH:0,boxW:0};const r=Math.min(1,e/s);return{scale:r,frameW:s,frameH:Math.round(n/r),boxW:Math.round(s*r)}}function jC({html:e,srcDoc:n,theme:s,mockupUrl:r,mockupName:a}){const o=Lp(e)??"desktop",i=o==="mobile"||o==="tablet",c=ii[o].w,d=l.useRef(null),[u,p]=l.useState({w:0,h:0});l.useEffect(()=>{const m=d.current;if(!m)return;const g=()=>p({w:m.clientWidth,h:m.clientHeight});if(g(),typeof ResizeObserver>"u")return;const x=new ResizeObserver(g);return x.observe(m),()=>x.disconnect()},[]);const f=u.w>0&&u.h>0?b7(u.w,u.h,c):{scale:1,frameW:c,frameH:800,boxW:c};return t.jsx("div",{ref:d,"data-testid":"customize-preview-pane",style:{flex:1,minHeight:0,overflow:"hidden",position:"relative",background:i?bC:"white",backgroundImage:i?yC:void 0,backgroundSize:i?vC:void 0,display:"flex",justifyContent:"center"},children:t.jsx("div",{style:{position:"relative",width:f.boxW,height:"100%",flexShrink:0},children:t.jsx("iframe",{title:`Customize preview: ${a}`,srcDoc:n,sandbox:"","data-viewport":o,style:{position:"absolute",top:0,left:0,width:f.frameW,height:f.frameH,transform:f.scale===1?void 0:`scale(${f.scale})`,transformOrigin:"top left",border:"none",background:"white"}},`${r}-${s}`)})})}const Bre=Object.freeze(Object.defineProperty({__proto__:null,MockupCustomizePreviewArea:jC},Symbol.toStringTag,{value:"Module"}));function y7(e){const n=e.trim();return/^#[0-9a-fA-F]{6}$/.test(n)?n.toLowerCase():/^#[0-9a-fA-F]{3}$/.test(n)?`#${n[1]}${n[1]}${n[2]}${n[2]}${n[3]}${n[3]}`.toLowerCase():"#000000"}const Fp=["Fraunces","Source Serif 4","Playfair Display","Inter","DM Sans","Nunito","Space Grotesk","Bricolage Grotesque","IBM Plex Mono"],Im=/^#[0-9a-f]{6}$/i,Sc={display:"flex",alignItems:"center",gap:8,fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:11,fontWeight:500,letterSpacing:".08em",textTransform:"uppercase",color:"rgba(255,255,255,.4)",marginBottom:10};function Ea({title:e,aside:n,children:s}){return t.jsxs("section",{children:[t.jsxs("div",{style:Sc,children:[e,t.jsx("span",{style:{flex:1}}),n]}),s]})}function wC({slot:e,value:n,onChange:s}){const[r,a]=l.useState(null),o=r??n,i=r!==null&&r.length>=7&&!Im.test(r);return t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"28px 1fr 92px",alignItems:"center",gap:10,padding:"3px 0"},children:[t.jsx("label",{style:{position:"relative",width:28,height:28,borderRadius:8,border:"1px solid rgba(255,255,255,.2)",overflow:"hidden",cursor:"pointer",background:n},children:t.jsx("input",{type:"color","aria-label":`${e.label} color`,value:y7(n),onChange:c=>s(c.target.value),style:{position:"absolute",inset:-8,width:44,height:44,opacity:0,cursor:"pointer"}})}),t.jsx("span",{style:{fontSize:13,color:"var(--text-secondary)"},children:e.label}),t.jsx("input",{"aria-label":`${e.label} hex`,value:o,spellCheck:!1,maxLength:7,onChange:c=>{let d=c.target.value.trim();d&&d[0]!=="#"&&(d=`#${d}`),a(d),Im.test(d)&&s(d)},onBlur:()=>a(null),style:{width:"100%",height:28,background:"rgba(255,255,255,.04)",border:`1px solid ${i?"#E5484D":"rgba(255,255,255,.1)"}`,borderRadius:7,color:"var(--text-primary)",fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12,padding:"0 8px",textTransform:"uppercase",outline:"none"}})]})}function kc({label:e,value:n,onChange:s,showAll:r}){const a=r?Dp.map(i=>i.family):Fp,o=(i,c)=>{const d=n===i;return t.jsx("button",{type:"button","aria-pressed":d,"aria-label":`${e}: ${c}`,onClick:()=>s(i),style:{padding:"6px 11px",borderRadius:8,border:`1px solid ${d?"rgba(215,255,99,.6)":"rgba(255,255,255,.12)"}`,background:d?"rgba(215,255,99,.12)":"transparent",color:d?"var(--text-primary)":"var(--text-secondary)",fontFamily:i?`'${i}', inherit`:"inherit",fontSize:14,cursor:"pointer"},children:c},c)};return t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginBottom:16},children:[o(null,"Design's own"),a.map(i=>o(i,i))]})}function _C({slots:e,vars:n,onColorChange:s,palettes:r,activePaletteName:a,theme:o,onApplyPalette:i,headingFont:c,bodyFont:d,onHeadingFont:u,onBodyFont:p,radius:h,onRadius:f,isEdited:m,onReset:g}){const[x,b]=l.useState(!1),y=e.filter(j=>j.cssVar),v=x?Dp.map(j=>j.family):Fp;return t.jsxs("aside",{"aria-label":"Customize","data-testid":"mockup-detail-sidebar",style:{borderLeft:"1px solid rgba(255,255,255,.08)",overflow:"auto",padding:18,display:"flex",flexDirection:"column",gap:24,background:"#111",minHeight:0},children:[t.jsx("link",{rel:"stylesheet",href:uC(v)}),t.jsxs(Ea,{title:"Colors",aside:m?t.jsx("button",{type:"button",onClick:g,style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--text-secondary)",fontSize:11,letterSpacing:0,textTransform:"none"},children:"Reset all"}):null,children:[y.length>0?y.map(j=>t.jsx(wC,{slot:j,value:n[j.cssVar]??j.value??"",onChange:_=>s(j.cssVar,_)},j.label)):t.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)"},children:"This design doesn't expose its colors as tokens, so they can't be changed here. Ask for color changes in the chat."}),y.length>0&&r.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{...Sc,marginTop:14},children:"Borrow a palette"}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(58px, 1fr))",gap:6},children:r.map(j=>{const w=(o==="dark"&&j.dark?j.dark:j.light).slots.map(S=>S.value).filter(S=>!!S),k=j.name===a;return t.jsx("button",{type:"button",title:`Use the colors from ${j.name}`,"aria-label":`Use the colors from ${j.name}`,"aria-pressed":k,onClick:()=>i(j),style:{display:"flex",height:26,borderRadius:7,overflow:"hidden",padding:0,cursor:"pointer",border:`1px solid ${k?"var(--accent-active, #D7FF63)":"rgba(255,255,255,.14)"}`},children:w.map((S,N)=>t.jsx("i",{style:{flex:1,background:S}},N))},j.name)})})]})]}),t.jsxs(Ea,{title:"Headings",aside:t.jsx("button",{type:"button",onClick:()=>b(j=>!j),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--text-secondary)",fontSize:11,letterSpacing:0,textTransform:"none"},children:x?"Fewer fonts":"More fonts"}),children:[t.jsx(kc,{label:"Headings",value:c,onChange:u,showAll:x}),t.jsx("div",{style:Sc,children:"Body text"}),t.jsx(kc,{label:"Body text",value:d,onChange:p,showAll:x})]}),h!==null&&t.jsx(Ea,{title:"Corners",aside:t.jsxs("span",{style:{color:"var(--text-secondary)",letterSpacing:0},children:[h,"px"]}),children:t.jsx("input",{type:"range",min:0,max:32,value:h,"aria-label":"Corner radius",onChange:j=>f(Number(j.target.value)),style:{width:"100%",accentColor:"var(--accent-active, #D7FF63)"}})})]})}const Wre=Object.freeze(Object.defineProperty({__proto__:null,ColorRow:wC,FEATURED_FONTS:Fp,FontChips:kc,MockupDetailSidebar:_C,Section:Ea},Symbol.toStringTag,{value:"Module"})),SC=600;function kC({value:e,placeholder:n,onChange:s}){const[r,a]=l.useState("idle"),o=l.useRef(null),i=l.useRef(void 0);l.useEffect(()=>()=>window.clearTimeout(i.current),[]);const c=()=>{var d;window.clearTimeout(i.current),a("saved"),(d=o.current)==null||d.blur()};return t.jsxs("div",{style:{position:"relative",flex:1,minWidth:200,maxWidth:560,display:"flex"},children:[t.jsx("input",{ref:o,value:e,placeholder:n,"aria-label":"Feedback on this design",onChange:d=>{s(d.target.value),a("typing"),window.clearTimeout(i.current),i.current=window.setTimeout(()=>a("saved"),SC)},onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),c())},style:{flex:1,minWidth:0,height:34,background:"rgba(255,255,255,.04)",border:`1px solid ${r==="saved"?"rgba(215,255,99,.45)":"rgba(255,255,255,.12)"}`,borderRadius:9,padding:"0 86px 0 12px",color:"var(--text-primary)",fontSize:13,outline:"none",transition:"border-color .2s"}}),t.jsxs("span",{style:{position:"absolute",right:5,top:0,bottom:0,display:"flex",alignItems:"center"},children:[r==="typing"&&t.jsx("button",{type:"button","aria-label":"Save note",title:"Save note (Enter)",onMouseDown:d=>d.preventDefault(),onClick:c,style:{width:24,height:24,borderRadius:7,border:"none",display:"grid",placeItems:"center",cursor:"pointer",background:"var(--accent-active, #D7FF63)",color:"var(--text-on-accent, #111)"},children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M8 13V3M3.5 7.5L8 3l4.5 4.5"})})}),r==="saved"&&e.trim()!==""&&t.jsxs("span",{role:"status","data-testid":"note-saved",style:{display:"inline-flex",alignItems:"center",gap:4,padding:"0 6px",fontSize:12,fontWeight:500,color:"var(--accent-active, #D7FF63)"},children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M3 8.5l3.2 3L13 4.5"})}),"Saved"]})]})]})}const Hre=Object.freeze(Object.defineProperty({__proto__:null,MockupNoteField:kC,NOTE_SAVED_AFTER_MS:SC},Symbol.toStringTag,{value:"Module"})),NC=["Rate it","Not for me","Meh","Okay","Good","Love it"];function v7(e){return e>0&&e<=2?"What isn't working for you?":e>=4?"What do you like most? Anything to change?":"Feedback on this design"}const Ui={height:34,padding:"0 14px",borderRadius:9,fontSize:13,fontWeight:600,cursor:"pointer"};function CC({mockup:e,systemName:n,initial:s,siblings:r,feedback:a,onFeedbackChange:o,onEditsChange:i,onSave:c,onSelect:d,saving:u=!1}){const p=p7(e.url,n,s),h=f7(r),f=l.useMemo(()=>[...p.state.kind==="ready"?p.state.palettes:[],...h],[p.state,h]),m=l.useMemo(()=>p.state.kind==="ready"?ZH(p.state.html):[],[p.state]),g=m.reduce((y,v)=>v.px>y.px?v:y,m[0]??{name:"",px:0}),x=m.length===0?null:parseFloat(p.overrides.vars[g.name]??`${g.px}`)||0;l.useEffect(()=>{i(p.overrides)},[p.overrides]);const b=Tp(a.rating);return t.jsxs("div",{style:{flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:[t.jsxs("div",{style:{flex:1,minHeight:0,display:"grid",gridTemplateColumns:"minmax(0, 1fr) 320px"},children:[t.jsxs("div",{style:{minWidth:0,minHeight:0,display:"flex",flexDirection:"column",background:"#0b0b0c"},children:[p.state.kind==="error"&&t.jsx(mC,{message:p.state.message}),p.state.kind==="loading"&&t.jsx("div",{style:{padding:16,color:"var(--text-secondary)"},children:"Loading the design…"}),p.state.kind==="ready"&&t.jsx(jC,{html:p.state.html,srcDoc:p.srcDoc,theme:p.theme,mockupUrl:e.url,mockupName:e.name})]}),t.jsx(_C,{slots:p.slots,vars:p.stackedVars,onColorChange:p.changeColor,palettes:f,activePaletteName:p.activePaletteName,theme:p.theme,onApplyPalette:p.applyPalette,headingFont:p.overrides.secondaryFont,bodyFont:p.overrides.primaryFont,onHeadingFont:y=>p.setOverrides(v=>({...v,secondaryFont:y})),onBodyFont:y=>p.setOverrides(v=>({...v,primaryFont:y})),radius:x,onRadius:y=>p.setOverrides(v=>({...v,vars:{...v.vars,...e7(m,y)}})),isEdited:p.isEdited,onReset:p.reset})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 14px 12px 18px",borderTop:"1px solid rgba(255,255,255,.08)",flexWrap:"wrap"},children:[t.jsx(Op,{rating:a.rating,onRatingChange:y=>o({...a,rating:y})}),t.jsx("span",{"data-testid":"mockup-rating-label",style:{fontSize:12,color:"var(--text-muted)",minWidth:64},children:NC[b]}),t.jsx(kC,{value:a.comment,placeholder:v7(b),onChange:y=>o({...a,comment:y})}),t.jsx("span",{style:{flex:1}}),p.hasDark&&t.jsx("button",{type:"button","aria-pressed":p.theme==="dark",onClick:()=>p.setTheme(y=>y==="light"?"dark":"light"),style:{...Ui,fontWeight:500,border:"1px solid rgba(255,255,255,.14)",background:"transparent",color:"var(--text-secondary)"},children:p.theme==="dark"?"Light mode":"Dark mode"}),p.isEdited&&t.jsx("button",{type:"button",disabled:u,onClick:()=>c(p.overrides),style:{...Ui,border:"1px solid rgba(255,255,255,.2)",background:"transparent",color:"var(--text-primary)"},children:u?"Saving…":"Save changes"}),t.jsx("button",{type:"button",onClick:d,style:{...Ui,border:"none",background:"var(--accent-active, #D7FF63)",color:"var(--text-on-accent, #111)"},children:"Select this design"})]})]})}const qre=Object.freeze(Object.defineProperty({__proto__:null,MockupDetailBody:CC,RATING_LABELS:NC},Symbol.toStringTag,{value:"Module"})),Dm={width:24,height:24,borderRadius:6,border:"1px solid rgba(255,255,255,.12)",background:"transparent",color:"var(--text-secondary)",cursor:"pointer"};function TC({number:e,name:n,index:s,total:r,onPrev:a,onNext:o,onClose:i,children:c}){return l.useEffect(()=>{const d=u=>{if(u.key==="Escape")return i();const p=u.target;p&&(p.tagName==="INPUT"||p.tagName==="TEXTAREA"||p.isContentEditable)||r<2||(u.key==="ArrowLeft"&&a(),u.key==="ArrowRight"&&o())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[i,a,o,r]),t.jsx("div",{"data-testid":"mockup-detail-backdrop",onClick:d=>{d.target===d.currentTarget&&i()},style:{position:"fixed",inset:0,zIndex:50,background:"rgba(0,0,0,.72)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"grid",placeItems:"center",padding:24},children:t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":n,style:{width:"min(1320px, 100%)",height:"min(860px, 100%)",display:"flex",flexDirection:"column",borderRadius:16,overflow:"hidden",border:"1px solid rgba(255,255,255,.12)",background:"#141415",boxShadow:"0 30px 80px rgba(0,0,0,.6)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 14px 12px 18px",borderBottom:"1px solid rgba(255,255,255,.08)"},children:[e!==null&&t.jsx("span",{style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:11,padding:"3px 8px",borderRadius:99,background:"rgba(255,255,255,.08)",color:"var(--text-secondary)"},children:String(e).padStart(2,"0")}),t.jsx("span",{style:{fontWeight:600,fontSize:15,color:"var(--text-primary)",textTransform:"capitalize"},children:n}),t.jsx("span",{style:{flex:1}}),r>1&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12,color:"var(--text-muted)"},children:[t.jsx("button",{type:"button","aria-label":"Previous design",onClick:a,style:Dm,children:"‹"}),s+1," of ",r,t.jsx("button",{type:"button","aria-label":"Next design",onClick:o,style:Dm,children:"›"})]}),t.jsx("button",{type:"button","aria-label":"Close",onClick:i,style:{width:32,height:32,borderRadius:8,border:"none",background:"transparent",color:"var(--text-muted)",fontSize:20,lineHeight:1,cursor:"pointer"},children:"×"})]}),c]})})}const Ure=Object.freeze(Object.defineProperty({__proto__:null,MockupDetailModal:TC},Symbol.toStringTag,{value:"Module"})),j7=["Feedback sent","Choose what to keep","New designs"];function PC({round:e,stage:n,agentWorking:s}){const r=n==="planning"&&!s,a=n==="designing"?2:1,o=n==="designing"?`Designing round ${e}. Each design comes back here as soon as it's redone.`:r?"Your turn: answer in the chat which designs to keep. The rest get redesigned.":"Reading your feedback. Next you'll be asked which designs to keep.";return t.jsxs("div",{role:"status","data-testid":"design-iterate-banner","data-stage":n,style:{display:"flex",flexDirection:"column",gap:10,padding:"12px 14px",borderRadius:12,border:`1px solid ${r?"rgba(215,255,99,.45)":"rgba(255,255,255,.12)"}`,background:r?"rgba(215,255,99,.06)":"rgba(255,255,255,.03)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[t.jsxs("span",{style:{fontFamily:"var(--font-mono, monospace)",fontSize:10.5,letterSpacing:".08em",textTransform:"uppercase",color:"var(--accent-active, #D7FF63)"},children:["Round ",e]}),t.jsx("ol",{style:{display:"flex",gap:6,listStyle:"none",margin:0,padding:0,flexWrap:"wrap"},children:j7.map((i,c)=>{const d=c<a,u=c===a;return t.jsxs("li",{"aria-current":u?"step":void 0,style:{display:"flex",alignItems:"center",gap:5,fontSize:11.5,padding:"2px 9px",borderRadius:999,border:`1px solid ${u?"rgba(215,255,99,.45)":"rgba(255,255,255,.1)"}`,color:d||u?"var(--text-primary)":"var(--text-muted)"},children:[d?t.jsx("span",{"aria-hidden":"true",style:{color:"var(--accent-active, #D7FF63)"},children:"✓"}):t.jsx("span",{"aria-hidden":"true",style:{opacity:.6},children:c+1}),i]},i)})})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,fontSize:13,color:"var(--text-secondary)"},children:[!r&&t.jsx(Ht,{size:13}),r&&t.jsx("span",{"aria-hidden":"true",style:{color:"var(--accent-active, #D7FF63)",fontSize:14},children:"←"}),t.jsx("span",{children:o})]})]})}const Yre=Object.freeze(Object.defineProperty({__proto__:null,DesignIterateBanner:PC},Symbol.toStringTag,{value:"Module"}));function OC({columns:e,onChange:n}){return t.jsxs("div",{role:"group","aria-label":"Mockup columns",style:{display:"flex",gap:2,padding:2,borderRadius:8,background:"rgba(255,255,255,.04)",flexShrink:0},children:[t.jsx(Nc,{count:1,active:e===1,onClick:()=>n(1)}),t.jsx(Nc,{count:2,active:e===2,onClick:()=>n(2)})]})}function Nc({count:e,active:n,onClick:s}){return t.jsx("button",{type:"button",onClick:s,"aria-pressed":n,"aria-label":e===1?"One column":"Two columns",title:e===1?"One column":"Two columns",style:{display:"flex",alignItems:"center",justifyContent:"center",width:26,height:22,border:"none",borderRadius:6,background:n?"var(--accent-active)":"transparent",color:n?"var(--text-on-accent, #14170a)":"var(--text-dim)",cursor:"pointer",transition:".16s"},children:t.jsx("svg",{width:"13",height:"11",viewBox:"0 0 13 11","aria-hidden":"true",children:e===1?t.jsx("rect",{x:"1",y:"1",width:"11",height:"9",rx:"1.5",fill:"currentColor"}):t.jsxs(t.Fragment,{children:[t.jsx("rect",{x:"1",y:"1",width:"4.5",height:"9",rx:"1.5",fill:"currentColor"}),t.jsx("rect",{x:"7.5",y:"1",width:"4.5",height:"9",rx:"1.5",fill:"currentColor"})]})})})}const Gre=Object.freeze(Object.defineProperty({__proto__:null,ColumnsButton:Nc,MockupColumnsToggle:OC},Symbol.toStringTag,{value:"Module"}));function RC({theme:e,onToggle:n,size:s=28}){return t.jsx("button",{type:"button",onClick:n,"aria-label":e==="light"?"Switch to dark mode":"Switch to light mode","aria-pressed":e==="dark",title:e==="light"?"Dark mode":"Light mode",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:s,height:s,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:e==="light"?"☾":"☀"})}const Vre=Object.freeze(Object.defineProperty({__proto__:null,MockupCardThemeToggleButton:RC},Symbol.toStringTag,{value:"Module"}));function EC(){return t.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:[t.jsx("path",{d:"M4.5 2.5h-2v7h7v-2"}),t.jsx("path",{d:"M7 2.5h2.5V5"}),t.jsx("path",{d:"M9.5 2.5L5.5 6.5"})]})}function AC({displayNumber:e,formattedName:n,theme:s,showThemeToggle:r,busy:a,openInNewTabUrl:o,onToggleTheme:i,onChoose:c,onCustomize:d}){return t.jsxs("div",{style:{padding:"var(--spacing-sm, 10px) var(--spacing-md, 14px)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",minWidth:0},children:[t.jsx("span",{style:{fontWeight:700,color:"var(--text-muted)"},children:String(e).padStart(2,"0")}),o?t.jsxs("a",{href:o,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ${n} 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:[t.jsx("span",{style:{textTransform:"capitalize",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n}),t.jsx("span",{style:{display:"inline-flex",alignItems:"center",color:"var(--text-muted)",lineHeight:1,flexShrink:0},children:t.jsx(EC,{})})]}):t.jsx("span",{style:{textTransform:"capitalize",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-xs, 8px)",flexShrink:0},children:[r&&t.jsx(RC,{theme:s,onToggle:i}),t.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"}),t.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 Kre=Object.freeze(Object.defineProperty({__proto__:null,MockupCardFooter:AC,OpenInNewTabIcon:EC},Symbol.toStringTag,{value:"Module"})),w7=700;function _7({srcDoc:e,url:n,theme:s,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 m=window.setTimeout(()=>d(!0),w7);return()=>window.clearTimeout(m)},[e,n,s]);const p=()=>{const m=window.requestAnimationFrame(()=>{const g=window.requestAnimationFrame(()=>i(!0));u.current.push(g)});u.current.push(m)};l.useEffect(()=>()=>{u.current.forEach(m=>window.cancelAnimationFrame(m)),u.current=[]},[]);const h=o&&r>0;return{handleIframeLoad:p,visible:h,showSkeleton:!a||!h||!c}}function MC(){return t.jsx("div",{"data-testid":"mockup-device-notch",style:{position:"absolute",top:bt.notchTopInset,left:"50%",transform:"translateX(-50%)",width:bt.notchWidth,height:bt.notchHeight,borderRadius:bt.notchHeight/2,background:bt.notchColor,pointerEvents:"none"}})}const Jre=Object.freeze(Object.defineProperty({__proto__:null,MockupDeviceNotch:MC},Symbol.toStringTag,{value:"Module"}));function IC(){return t.jsx("div",{"data-testid":"mockup-device-home-indicator",style:{position:"absolute",bottom:bt.homeIndicatorBottomInset,left:"50%",transform:"translateX(-50%)",width:bt.homeIndicatorWidth,height:bt.homeIndicatorHeight,borderRadius:bt.homeIndicatorHeight/2,background:bt.homeIndicatorColor,pointerEvents:"none"}})}const Xre=Object.freeze(Object.defineProperty({__proto__:null,MockupDeviceHomeIndicator:IC},Symbol.toStringTag,{value:"Module"}));function DC({width:e,height:n,children:s}){const{bezel:r}=bt;return t.jsx("div",{"data-testid":"mockup-device-frame",style:{position:"relative",width:e+r*2,height:n+r*2,borderRadius:bt.outerRadius,background:bt.bodyColor,boxShadow:`0 18px 48px rgba(0, 0, 0, 0.55), inset 0 0 0 1px ${bt.ringColor}`,boxSizing:"border-box"},children:t.jsxs("div",{"data-testid":"mockup-device-screen",style:{position:"absolute",top:r,left:r,width:e,height:n,borderRadius:bt.screenRadius,overflow:"hidden",background:"white"},children:[s,t.jsx(MC,{}),t.jsx(IC,{})]})})}const Qre=Object.freeze(Object.defineProperty({__proto__:null,MockupDeviceFrame:DC},Symbol.toStringTag,{value:"Module"}));function LC(){return t.jsxs("div",{"aria-label":"Loading mockup",style:{position:"absolute",inset:0,padding:"10%",display:"flex",flexDirection:"column",gap:"5%"},children:[t.jsx(Co,{}),t.jsx(ft,{widthPct:45,heightPx:14,variant:"overlay"}),t.jsx(ft,{widthPct:70,heightPx:10,variant:"overlay"}),t.jsx("div",{style:{height:"6%"}}),t.jsx(ft,{widthPct:100,heightPx:32,variant:"overlay"}),t.jsxs("div",{style:{display:"flex",gap:"4%"},children:[t.jsx(ft,{widthPct:48,heightPx:48,variant:"overlay"}),t.jsx(ft,{widthPct:48,heightPx:48,variant:"overlay"})]}),t.jsx(ft,{widthPct:88,heightPx:10,variant:"overlay"}),t.jsx(ft,{widthPct:60,heightPx:10,variant:"overlay"})]})}const Zre=Object.freeze(Object.defineProperty({__proto__:null,MockupSkeletonOverlay:LC},Symbol.toStringTag,{value:"Module"}));function $p({html:e,url:n,title:s,viewport:r,theme:a,darkVars:o,darkBgText:i,slotAspect:c={w:wc,h:_c},onOpen:d}){const u=l.useRef(null),[p,h]=l.useState(0),[f,m]=l.useState(0),g=ii[r],x=xC(r),b=gC(r);l.useEffect(()=>{const T=u.current;if(!T)return;const P=()=>{const I=T.clientWidth,A=T.clientHeight;I>0&&h(I),A>0&&m(A)};if(P(),typeof ResizeObserver>"u")return;const R=new ResizeObserver(P);return R.observe(T),()=>R.disconnect()},[]);const{scale:y,offsetX:v,offsetY:j}=x7(p,f,x.w,x.h),_=e&&a==="dark"&&o?fC(e,{vars:o,...i??oC(o)}):e,{handleIframeLoad:w,visible:k,showSkeleton:S}=_7({srcDoc:_,url:n,theme:a,scale:y,hasContent:e!==null}),N=()=>window.open(n,"_blank","noopener,noreferrer"),C=t.jsx("iframe",{src:_?void 0:n,srcDoc:_??void 0,title:s,sandbox:"",onLoad:w,style:{width:g.w,height:g.h,border:"none",background:"white",display:"block"}},a);return t.jsxs("div",{ref:u,onClick:d??N,"data-testid":"mockup-preview-slot",style:{position:"relative",width:"100%",aspectRatio:`${c.w} / ${c.h}`,overflow:"hidden",cursor:"pointer",backgroundColor:bC,backgroundImage:yC,backgroundSize:vC},children:[e!==null&&t.jsx("div",{style:{position:"absolute",top:j,left:v,transform:y>0?`scale(${y})`:"scale(0)",transformOrigin:"top left",pointerEvents:"none",visibility:k?"visible":"hidden"},children:b?t.jsx(DC,{width:g.w,height:g.h,children:C}):C}),S&&t.jsx(LC,{})]})}const eae=Object.freeze(Object.defineProperty({__proto__:null,MockupCardPreviewSlot:$p},Symbol.toStringTag,{value:"Module"}));function FC({mockup:e,displayNumber:n,onChoose:s,onCustomize:r,busy:a=!1,darkVars:o=null,feedback:i,onFeedbackChange:c,slotAspect:d,onViewportResolved:u}){const[p,h]=l.useState(null),[f,m]=l.useState(Mm),[g,x]=l.useState("light"),b=l.useMemo(()=>p?hC(p):null,[p]);if(l.useEffect(()=>{if(!e)return;let v=!1;return(async()=>{try{const j=await fetch(e.url);if(!j.ok)return;const _=await j.text();if(v)return;const w=Lp(_)??Mm;h(_),m(w),u==null||u(w)}catch{}})(),()=>{v=!0}},[e==null?void 0:e.url]),!e)return t.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 y=lr(e);return t.jsxs("div",{style:{position:"relative",display:"flex",flexDirection:"column",border:"1px solid var(--border-default)",borderRadius:12,overflow:"hidden",background:"var(--bg-surface)"},children:[t.jsx(AC,{displayNumber:n,formattedName:y,theme:g,showThemeToggle:!!b,busy:a,openInNewTabUrl:e.url,onToggleTheme:()=>x(v=>v==="light"?"dark":"light"),onChoose:()=>s==null?void 0:s(e),onCustomize:()=>r==null?void 0:r(e)}),t.jsx($p,{html:p,url:e.url,title:e.name,viewport:f,theme:g,darkVars:(b==null?void 0:b.vars)??null,darkBgText:b?{bg:b.bg,text:b.text}:void 0,slotAspect:d,onOpen:r?()=>r(e):void 0}),c&&t.jsx(dC,{value:i??Rp,onChange:c})]})}const tae=Object.freeze(Object.defineProperty({__proto__:null,MockupCard:FC},Symbol.toStringTag,{value:"Module"}));function $C({displayNumber:e,slotAspect:n}){return t.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:[t.jsx(Co,{}),t.jsxs("div",{style:{position:"relative",width:"100%",aspectRatio:n?`${n.w} / ${n.h}`:"1 / 1",overflow:"hidden",background:"var(--bg-elevated, #141414)",padding:"10%",display:"flex",flexDirection:"column",gap:"5%"},children:[t.jsx(ft,{widthPct:45,heightPx:14}),t.jsx(ft,{widthPct:70,heightPx:10}),t.jsx("div",{style:{height:"6%"}}),t.jsx(ft,{widthPct:100,heightPx:32}),t.jsxs("div",{style:{display:"flex",gap:"4%"},children:[t.jsx(ft,{widthPct:48,heightPx:48}),t.jsx(ft,{widthPct:48,heightPx:48})]}),t.jsx(ft,{widthPct:88,heightPx:10}),t.jsx(ft,{widthPct:60,heightPx:10})]}),t.jsx("div",{style:{padding:"var(--spacing-sm, 8px) var(--spacing-md, 12px)",display:"flex",alignItems:"center",gap:"var(--spacing-sm, 8px)"},children:t.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:6,color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",minWidth:0},children:[t.jsx("span",{style:{fontWeight:700,color:"var(--text-muted)"},children:String(e).padStart(2,"0")}),t.jsx("span",{style:{color:"var(--text-secondary)",fontStyle:"italic"},"data-testid":"mockup-placeholder-label",children:"The AI is designing this mockup…"})]})})]})}const nae=Object.freeze(Object.defineProperty({__proto__:null,MockupPlaceholderCard:$C},Symbol.toStringTag,{value:"Module"}));function zC({slots:e,darkVarsBySystem:n,busyFilename:s,feedbackByFilename:r,onFeedbackChange:a,onChoose:o,onCustomize:i,columns:c=2}){const[d,u]=l.useState({}),p=l.useCallback((f,m)=>{u(g=>g[f]===m?g:{...g,[f]:m})},[]),h=l.useMemo(()=>g7(Object.values(d)),[d]);return t.jsx("div",{style:{display:"grid",gridTemplateColumns:c===1?"1fr":"1fr 1fr",columnGap:"var(--spacing-lg, 16px)",rowGap:"var(--spacing-xl, 28px)"},children:e.map(f=>f.mockup?t.jsx(FC,{mockup:f.mockup,displayNumber:f.number,onChoose:o,onCustomize:i,busy:s===f.mockup.filename,darkVars:n[ta(f.mockup.filename)]??null,feedback:r==null?void 0:r[f.mockup.filename],onFeedbackChange:a?m=>a(f.mockup.filename,m):void 0,slotAspect:h,onViewportResolved:m=>p(f.mockup.filename,m)},`mockup-${f.mockup.filename}`):t.jsx($C,{displayNumber:f.number,slotAspect:h},`placeholder-${f.number}`))})}const sae=Object.freeze(Object.defineProperty({__proto__:null,MockupGrid:zC},Symbol.toStringTag,{value:"Module"}));function BC(){return t.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:[t.jsx("div",{className:"relative",children:t.jsx("div",{className:"w-12 h-12 border-4 border-primary/20 border-t-primary rounded-full animate-spin"})}),t.jsx("div",{style:{color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",fontWeight:500},children:"Generating new designs…"})]})}const rae=Object.freeze(Object.defineProperty({__proto__:null,MockupGridGeneratingOverlay:BC},Symbol.toStringTag,{value:"Module"}));function WC(){return t.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:[t.jsx("path",{d:"M9 18h6"}),t.jsx("path",{d:"M10 22h4"}),t.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 HC(){return t.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:[t.jsx("path",{d:"M18 6L6 18"}),t.jsx("path",{d:"M6 6l12 12"})]})}function qC({onDismiss:e}){return t.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:[t.jsx("span",{"aria-hidden":"true",style:{color:"var(--accent-active, #D7FF63)",display:"inline-flex",alignItems:"center",flexShrink:0,paddingTop:1},children:t.jsx(WC,{})}),t.jsxs("p",{style:{flex:1,margin:0,color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",lineHeight:1.5},children:[t.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."]}),t.jsx("button",{type:"button",onClick:e,"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:t.jsx(HC,{})})]})}const aae=Object.freeze(Object.defineProperty({__proto__:null,CloseIcon:HC,LightbulbIcon:WC,MockupGridInfoBanner:qC},Symbol.toStringTag,{value:"Module"}));function UC({filename:e,onDismiss:n}){const s=nC(e);return t.jsxs("div",{role:"status",style:{display:"flex",alignItems:"center",gap:"var(--spacing-sm, 8px)",padding:"var(--spacing-sm, 8px) var(--spacing-md, 12px)",borderRadius:8,border:"1px solid var(--accent-active, #D7FF63)",background:"var(--bg-elevated, rgba(215,255,99,0.08))",color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)"},children:[t.jsxs("span",{style:{flex:1},children:["Saved your changes to ",t.jsx("strong",{children:s}),". It stays in the lineup, so you can keep comparing. Press Select on a design when you're ready to build with it."]}),t.jsx("button",{type:"button",onClick:n,"aria-label":"Dismiss saved notice",style:{border:"none",background:"transparent",color:"var(--text-secondary)",cursor:"pointer",fontSize:16,lineHeight:1,padding:2},children:"×"})]})}const oae=Object.freeze(Object.defineProperty({__proto__:null,MockupSavedNotice:UC},Symbol.toStringTag,{value:"Module"}));function YC({filename:e}){const n=nC(e);return t.jsxs("div",{role:"status","data-testid":"design-switch-queued-notice",style:{padding:"10px 14px",borderRadius:10,border:"1px solid var(--accent-active, #D7FF63)",background:"var(--bg-card, #1a1a1a)",color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)"},children:["Queued a plan to switch the app to the"," ",t.jsx("strong",{style:{textTransform:"capitalize"},children:n})," design. Nothing in the app has changed yet. Find it in the Plan tab and run it when you are ready."]})}const iae=Object.freeze(Object.defineProperty({__proto__:null,DesignSwitchQueuedNotice:YC},Symbol.toStringTag,{value:"Module"}));function S7(e){const[n,s]=l.useState(!1);return l.useEffect(()=>{if(!e)return;let r=!1;return fetch("/api/editor-design-state").then(a=>a.ok?a.json():null).then(a=>{!r&&a&&s(a.projectBuilt===!0)}).catch(()=>{}),()=>{r=!0}},[e]),n}function k7(e){if(!e||typeof e!="object")return null;const n=e.queuedPlan;return typeof n=="string"&&n.length>0?n:null}function GC(){return t.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:[t.jsx("path",{d:"M21 12a9 9 0 1 1-3.36-7"}),t.jsx("polyline",{points:"21 4 21 10 15 10"})]})}const VC="Rate each design or leave it a note first, so the next round knows what to keep and what to change.";function KC({feedbackCount:e,busy:n,onIterate:s}){const[r,a]=l.useState(!1),o=e===0,i=e===0?"Add a rating or note above, then iterate.":e===1?"1 card has feedback — iterate to refresh the round.":`${e} cards have feedback — iterate to refresh the round.`;return t.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:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-md, 14px)",minWidth:0},children:[t.jsx("span",{"aria-hidden":"true",style:{color:"var(--accent-active, #D7FF63)",display:"inline-flex",alignItems:"center",flexShrink:0},children:t.jsx(GC,{})}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0},children:[t.jsx("span",{style:{color:"var(--text-primary)",fontSize:"var(--text-sm, 14px)",fontWeight:600,lineHeight:1.3},children:"Ready for the next round?"}),t.jsx("span",{style:{color:"var(--text-muted)",fontSize:"var(--text-xs, 12px)",lineHeight:1.4,marginTop:2},children:i})]})]}),t.jsxs("span",{style:{position:"relative",flexShrink:0,display:"inline-flex"},onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[t.jsx("button",{type:"button",onClick:()=>{o||s()},onFocus:()=>a(!0),onBlur:()=>a(!1),disabled:n,"aria-disabled":o?"true":void 0,"aria-describedby":o?"iterate-needs-feedback":void 0,"data-mockup-iterate":!0,style:{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:n?"wait":o?"not-allowed":"pointer",opacity:n?.6:o?.35:1},children:n?"Sending…":"Iterate"}),o&&t.jsx("span",{id:"iterate-needs-feedback",role:"tooltip",style:{position:"absolute",bottom:"calc(100% + 10px)",right:0,width:240,padding:"8px 10px",borderRadius:8,background:"#2a2a2c",border:"1px solid rgba(255,255,255,.12)",boxShadow:"0 8px 24px rgba(0,0,0,.45)",color:"var(--text-primary)",fontSize:12.5,lineHeight:1.4,textAlign:"left",pointerEvents:"none",opacity:r?1:0,transform:r?"none":"translateY(4px)",transition:"opacity .15s, transform .15s",zIndex:5},children:VC})]})]})}const lae=Object.freeze(Object.defineProperty({__proto__:null,ITERATE_NEEDS_FEEDBACK:VC,MockupGridIterateButton:KC,RefreshCycleIcon:GC},Symbol.toStringTag,{value:"Module"}));function JC(){return t.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:t.jsx("polyline",{points:"15 18 9 12 15 6"})})}function XC(){return t.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:t.jsx("polyline",{points:"9 18 15 12 9 6"})})}function QC({archivedRoundsNewestFirst:e,selected:n,onSelect:s}){if(!e||e.length===0)return null;const a=[...[...e].reverse(),"current"],o=a.length,i=a.indexOf(n),c=i===-1?o-1:i,d=n==="current",u=c>0,p=c<o-1,h=d?`Round ${o} of ${o} · Current`:`Round ${c+1} of ${o} · Archived`;return t.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:[t.jsx(Cc,{ariaLabel:"Previous round",disabled:!u,onClick:()=>u&&s(a[c-1]),icon:t.jsx(JC,{})}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-md, 12px)",fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:[t.jsx("span",{style:{fontWeight:500,color:"var(--text-primary)"},children:h}),!d&&t.jsx("button",{type:"button",onClick:()=>s("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"})]}),t.jsx(Cc,{ariaLabel:"Next round",disabled:!p,onClick:()=>p&&s(a[c+1]),icon:t.jsx(XC,{})})]})}function Cc({ariaLabel:e,disabled:n,onClick:s,icon:r}){return t.jsx("button",{type:"button",onClick:s,disabled:n,"aria-label":e,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:28,height:28,background:"transparent",color:n?"var(--text-dim, #666)":"var(--text-primary)",border:"1px solid var(--border-default)",borderRadius:6,cursor:n?"default":"pointer",opacity:n?.5:1,padding:0},children:r})}const cae=Object.freeze(Object.defineProperty({__proto__:null,ChevronLeftIcon:JC,ChevronRightIcon:XC,MockupRoundPager:QC,PagerArrowButton:Cc},Symbol.toStringTag,{value:"Module"}));function N7(e){return e?{title:"Plan the switch to this design?",action:"Queue the plan",busyAction:"Queuing…"}:{title:"Ready to start building?",action:"Start building",busyAction:"Starting…"}}function ZC({mockup:e,busy:n,onCancel:s,onConfirm:r,planSwitch:a=!1}){const o=N7(a);l.useEffect(()=>{const c=d=>{d.key==="Escape"&&!n&&s()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[n,s]);const i=e.name.replace(/^\d{1,2}-/,"").replace(/-/g," ");return t.jsx("div",{role:"presentation",onClick: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:t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":o.title,onClick:c=>c.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:[t.jsx("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:8,overflow:"hidden",aspectRatio:"16 / 9",background:"#1a1a1a",position:"relative"},children:t.jsx("iframe",{src:e.url,title:`${i} 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}})}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[t.jsx("h2",{style:{margin:0,color:"var(--text-primary)",fontSize:16,fontWeight:600},children:o.title}),t.jsxs("p",{style:{margin:0,color:"var(--text-secondary)",fontSize:13,textTransform:"capitalize"},children:["Using ",t.jsx("strong",{style:{color:"var(--text-primary)"},children:i})]}),a&&t.jsx(Ab,{})]}),t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[t.jsx("button",{type:"button",onClick:s,disabled:n,style:{padding:"8px 16px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)",borderRadius:6,fontSize:13,fontWeight:500,cursor:n?"wait":"pointer",opacity:n?.5:1,fontFamily:"inherit"},children:"Cancel"}),t.jsx("button",{type:"button",onClick:r,disabled:n,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:n?"wait":"pointer",opacity:n?.7:1,fontFamily:"inherit"},children:n?o.busyAction:o.action})]})]})})}const dae=Object.freeze(Object.defineProperty({__proto__:null,StartBuildingConfirmModal:ZC},Symbol.toStringTag,{value:"Module"}));function C7(e){return e===void 0?"/api/editor-mockup-customize":`/api/editor-mockup-customize?round=${encodeURIComponent(e)}`}function ao({onDesignConfirmed:e,round:n,hideInfoBanner:s=!1,pickInChat:r=!1}={}){const[a,o]=l.useState(null),[i,c]=l.useState(null),[d,u]=l.useState(null),[p,h]=l.useState(null),[f,m]=l.useState(null),[g,x]=l.useState(null),[b,y]=l.useState(null),[v,j]=l.useState(null),_=S7(n===void 0),[w,k]=l.useState({}),[S,N]=l.useState({}),[C,T]=l.useState(!1),[P,R]=l.useState(!1),I=l.useRef([]),A=l.useRef(!1),O=l.useRef(!1),[W,D]=l.useState(null),[Y,H]=l.useState(()=>typeof window>"u"?!1:window.sessionStorage.getItem("mockup-grid-tip-dismissed")==="1"),[E,U]=l.useState(()=>typeof window>"u"?2:window.localStorage.getItem("mockup-grid-columns")==="1"?1:2),M=B=>{U(B),typeof window<"u"&&window.localStorage.setItem("mockup-grid-columns",String(B))},[J,ne]=l.useState("current"),oe=HH(),ae=l.useRef(null),G=WH(a),ie=l.useRef(!0),le=l.useCallback(async()=>{try{const[B,F]=await Promise.all([fetch(bn("/api/editor-mockups",n)),fetch(bn("/api/editor-mockups-target",n))]),X=await B.json(),ue=await F.json();ie.current&&(o(be=>xH(be,X)||A.current&&X.length<I.current.length?be:X),c(be=>be===ue.count?be:ue.count))}catch(B){ie.current&&u(B instanceof Error?B.message:String(B))}},[n]);l.useEffect(()=>{ie.current=!0,le();const B=window.setInterval(le,4e3);return()=>{ie.current=!1,window.clearInterval(B)}},[le]),l.useEffect(()=>{let B=!1;return(async()=>{try{const F=await fetch(bn("/api/editor-mockups-feedback",n));if(!F.ok)return;const X=await F.json();if(B||!X||typeof X!="object"||Array.isArray(X))return;const ue={};for(const[be,xe]of Object.entries(X)){if(!xe||typeof xe!="object")continue;const ke=xe;ke.rating!=null&&typeof ke.rating!="number"||ke.comment!=null&&typeof ke.comment!="string"||(ue[be]={rating:typeof ke.rating=="number"?ke.rating:null,comment:typeof ke.comment=="string"?ke.comment:""})}N(ue)}catch{}})(),()=>{B=!0}},[]);const Z=l.useCallback((B,F)=>{N(X=>{const ue={...X,[B]:F};return ae.current!=null&&window.clearTimeout(ae.current),ae.current=window.setTimeout(()=>{fetch(bn("/api/editor-mockups-feedback",n),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ue)}).catch(()=>{})},400),ue})},[n]);l.useEffect(()=>()=>{ae.current!=null&&window.clearTimeout(ae.current)},[]);const z=l.useCallback(()=>{if(!a)return;const B=a.map(X=>X.filename);I.current=B,O.current=!1,R(!1),T(!0),x(null),ne("current"),ae.current!=null&&(window.clearTimeout(ae.current),ae.current=null);const F={};for(const X of a)F[X.filename]=lr(X);(async()=>{try{await fetch(bn("/api/editor-mockups-feedback",n),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(S)})}catch{}let X=null;try{const xe=await(await fetch("/api/editor-mockups-archive",{method:"POST"})).json().catch(()=>null);X=(xe==null?void 0:xe.round)??null}catch{}const ue=wH({feedbackByFilename:S,mockupFilenames:B,titles:F,feedbackFile:X&&n===void 0?`.codeyam/design/project_mockups/history/${X}/feedback.json`:void 0});ie.current&&(r&&mF({round:oe.length+2,prompt:ue,feedbackCount:Lm(S),snapshot:mf(a),designs:a.map(({filename:be,name:xe,title:ke})=>({filename:be,name:xe,title:ke}))}),await bc(ue,void 0,eT),ie.current&&(O.current=!0,N({}),fetch(bn("/api/editor-mockups-feedback",n),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}).catch(()=>{})))})()},[S,a,n,r,oe.length]),L=Ou(),q=Y0();l.useEffect(()=>{(L==null?void 0:L.stage)!=="planning"||!a||mf(a)!==L.snapshot&&Pu()},[L,a]);const se=r&&L!==null,fe=l.useRef(null),we=L==null?void 0:L.id;l.useEffect(()=>{if(!we)return;const B=window.requestAnimationFrame(()=>{var F,X;(X=(F=fe.current)==null?void 0:F.scrollIntoView)==null||X.call(F,{behavior:"smooth",block:"start"})});return()=>window.cancelAnimationFrame(B)},[we]),l.useEffect(()=>{A.current=C},[C]),l.useEffect(()=>{if(!C)return;const B=()=>{O.current&&R(!0)};return window.addEventListener("miniagent-output",B),()=>window.removeEventListener("miniagent-output",B)},[C]),l.useEffect(()=>{if(!C)return;const B=window.setTimeout(()=>{ie.current&&T(!1)},_H);return()=>window.clearTimeout(B)},[C]),l.useEffect(()=>{C&&SH({snapshotFilenames:I.current,latestFilenames:(a??[]).map(B=>B.filename),agentRespondedAfterDispatch:P})&&T(!1)},[C,a,P]);const De=l.useCallback(async B=>{D(B);try{const F=await fetch("/api/editor-mockups-restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({round:B})});if(!F.ok){const X=await F.text().catch(()=>`${F.status}`);throw new Error(X||`restore failed: ${F.status}`)}ie.current&&(ne("current"),le())}catch(F){ie.current&&u(F instanceof Error?F.message:String(F))}finally{ie.current&&D(null)}},[le]),Fe=l.useCallback(B=>{x(B)},[]),Me=l.useCallback(async()=>{if(!g)return;const B=g;h(B.filename);try{if(n===void 0){const F=await fetch("/api/editor-design-select",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:B.filename})});if(!F.ok){const ue=await F.text().catch(()=>"");let be=ue;try{be=JSON.parse(ue).error??ue}catch{}throw new Error(`Couldn't use this design: ${be||`status ${F.status}`}`)}if(k7(await F.json().catch(()=>null))){ie.current&&(x(null),j(B.filename));return}}ie.current&&(x(null),e==null||e({kind:"use",filename:B.filename}))}catch(F){u(F instanceof Error?F.message:String(F))}finally{ie.current&&h(null)}},[g,e,n]),ee=l.useCallback(B=>{const F=ta(B.filename);y(null),m({mockup:B,systemName:F})},[]);l.useEffect(()=>{const B=new Map;for(const F of a??[]){const X=/^(\d{1,2})-/.exec(F.filename);X&&B.set(parseInt(X[1],10),F)}return Ah([...B.keys()],F=>{const X=B.get(F);X&&ee(X)}),()=>Ah([],null)},[a,ee]);const Q=l.useCallback(async B=>{if(f){h(f.mockup.filename);try{const F=JSON.stringify({filename:f.mockup.filename,overrides:{vars:B.vars,primaryFont:B.primaryFont,secondaryFont:B.secondaryFont}}),X=await fetch(C7(n),{method:"POST",headers:{"Content-Type":"application/json"},body:F});if(!X.ok){const ue=await X.text().catch(()=>`${X.status}`);throw new Error(ue||`save failed: ${X.status}`)}k(ue=>({...ue,[f.mockup.filename]:B})),m(null),y(f.mockup.filename),le()}catch(F){u(F instanceof Error?F.message:String(F))}finally{ie.current&&h(null)}}},[f,le,n]);l.useEffect(()=>{if(!r||!g)return;const B=/^(\d{1,2})-/.exec(g.filename);return wf({filename:g.filename,name:lr(g),number:B?parseInt(B[1],10):null,busy:p===g.filename,confirm:()=>void Me(),cancel:()=>x(null)}),()=>wf(null)},[r,g,p,Me]);const te=f&&a?a.findIndex(B=>B.filename===f.mockup.filename):-1,he=B=>{!a||te<0||ee(a[(te+B+a.length)%a.length])},ye=f?t.jsx(TC,{number:(()=>{const B=/^(\d{1,2})-/.exec(f.mockup.filename);return B?parseInt(B[1],10):null})(),name:lr(f.mockup),index:Math.max(0,te),total:(a==null?void 0:a.length)??1,onPrev:()=>he(-1),onNext:()=>he(1),onClose:()=>m(null),children:t.jsx(CC,{mockup:f.mockup,systemName:f.systemName,initial:w[f.mockup.filename]??gH,siblings:(a??[]).filter(B=>B.filename!==f.mockup.filename),feedback:S[f.mockup.filename]??Rp,onFeedbackChange:B=>Z(f.mockup.filename,B),onEditsChange:B=>k(F=>({...F,[f.mockup.filename]:B})),onSave:B=>void Q(B),onSelect:()=>{const B=f.mockup;m(null),Fe(B)},saving:p===f.mockup.filename},f.mockup.filename)}):null;if(!a)return t.jsx("div",{style:{padding:"var(--spacing-lg, 16px)"},children:t.jsx("div",{style:{color:"var(--text-secondary)"},children:"Loading design mockups…"})});const ve=a.reduce((B,F)=>{const X=/^(\d{1,2})-/.exec(F.filename);return X?Math.max(B,parseInt(X[1],10)):B},0),Ne=Math.max(i??0,ve);if(Ne===0)return t.jsx(nu,{});const de=Array.from({length:Ne},(B,F)=>{const X=F+1,ue=String(X).padStart(2,"0"),be=a.find(xe=>xe.filename.startsWith(`${ue}-`))??null;return{number:X,mockup:be}}),me=se&&(L==null?void 0:L.stage)==="designing"?new Set(L.snapshot.split(`
|
|
254
|
+
`)):null,We=me?de.map(B=>B.mockup&&me.has(`${B.mockup.filename}|${B.mockup.url}`)?{...B,mockup:null}:B):de;return t.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:[!Y&&!s&&t.jsx(qC,{onDismiss:()=>{H(!0),typeof window<"u"&&window.sessionStorage.setItem("mockup-grid-tip-dismissed","1")}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-md, 12px)"},children:[t.jsx(QC,{archivedRoundsNewestFirst:oe.map(B=>B.round),selected:J,onSelect:ne}),t.jsx("div",{style:{marginLeft:"auto"},children:t.jsx(OC,{columns:E,onChange:M})})]}),d&&t.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:d}),se&&L&&t.jsx("div",{ref:fe,children:t.jsx(PC,{round:L.round,stage:L.stage,agentWorking:q})}),v&&t.jsx(YC,{filename:v}),b&&t.jsx(UC,{filename:b,onDismiss:()=>y(null)}),J==="current"?t.jsxs("div",{style:{position:"relative",display:"flex",flexDirection:"column",gap:"var(--spacing-md, 12px)"},children:[t.jsxs("div",{style:C&&!r?{opacity:.4,pointerEvents:"none"}:se&&(L==null?void 0:L.stage)==="planning"?{opacity:.55,transition:"opacity .2s"}:void 0,children:[t.jsx(zC,{slots:We,darkVarsBySystem:G,busyFilename:p,feedbackByFilename:S,onFeedbackChange:Z,onChoose:Fe,onCustomize:ee,columns:E}),a.length>0&&!se&&t.jsx("div",{style:{marginTop:"var(--spacing-md, 12px)"},children:t.jsx(KC,{feedbackCount:Lm(S),busy:C,onIterate:z})})]}),C&&!r&&t.jsx(BC,{})]}):(()=>{const B=oe.find(F=>F.round===J);return B?t.jsx(lC,{round:B,onRestore:()=>De(B.round),restoring:W===B.round}):t.jsx("div",{style:{padding:"var(--spacing-md, 14px)",color:"var(--text-secondary)",fontSize:"var(--text-sm, 14px)"},children:"Loading archived round…"})})(),ye,g&&!r&&t.jsx(ZC,{mockup:g,busy:p===g.filename,onCancel:()=>x(null),onConfirm:Me,planSwitch:n===void 0&&_})]})}const eT=600;function Lm(e){return Object.values(e).filter(n=>typeof n.rating=="number"||n.comment.trim().length>0).length}const uae=Object.freeze(Object.defineProperty({__proto__:null,DesignExplorationView:ao,ITERATE_SUBMIT_DELAY_MS:eT,systemNameFromFilename:ta,withRoundParam:bn},Symbol.toStringTag,{value:"Module"})),T7=3e3;function P7(e){const[n,s]=l.useState(null),[r,a]=l.useState(!1),o=l.useRef(!1);l.useEffect(()=>{let c=!1;const d=async()=>{if(!o.current)try{const p=await fetch("/api/editor-design-questions");if(!p.ok)return;const h=await p.json();if(c)return;s(OA(h.questions)),h.answered===!0&&(o.current=!0,a(!0))}catch{}};d();const u=window.setInterval(()=>void d(),T7);return()=>{c=!0,window.clearInterval(u)}},[e]);const i=l.useCallback(async c=>{try{return(await fetch("/api/editor-design-answers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)})).ok?(o.current=!0,a(!0),!0):!1}catch{return!1}},[]);return{doc:n,answered:r,submit:i}}const O7=2e4;function R7(e){const[n,s]=l.useState(null),[r,a]=l.useState(!1),o=Tu(n!==null),i=e||o.working||GA(o.messages);l.useEffect(()=>{if(n===null)return;if(i){s(null),a(!1);return}const d=window.setTimeout(()=>a(!0),O7);return()=>window.clearTimeout(d)},[n,i]);const c=l.useCallback(()=>{a(!1),s(Date.now())},[]);return{undelivered:n!==null&&r&&!i,markSent:c}}function E7({hasQuestions:e,answered:n,ready:s,target:r}){return e&&!n?"questions":r===null?s>0?"gallery":n?"generating":"preparing":s>=r&&s>0?"gallery":"generating"}function li({options:e,selected:n,onToggle:s,emphasized:r=!1}){return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:7},children:e.map(a=>{const o=n.includes(a.label);return t.jsx("button",{type:"button","aria-pressed":o,onClick:()=>s(a.label),title:a.detail,style:{padding:"6px 12px",borderRadius:999,border:`1px solid ${o?"var(--text-primary)":r?"rgba(255,255,255,.22)":"rgba(255,255,255,.12)"}`,background:o?"var(--text-primary)":r?"rgba(0,0,0,.18)":"transparent",color:o?"#0a0a0a":"var(--text-secondary)",fontSize:13,cursor:"pointer"},children:a.label},a.label)})})}const pae=Object.freeze(Object.defineProperty({__proto__:null,DesignQuestionChips:li},Symbol.toStringTag,{value:"Module"}));function Tc({selected:e,onToggle:n}){return t.jsxs("button",{type:"button","aria-pressed":e,onClick:n,style:{display:"inline-flex",alignItems:"center",gap:8,marginTop:10,padding:"6px 12px 6px 7px",borderRadius:999,border:`1px solid ${e?"rgba(215,255,99,.6)":"rgba(255,255,255,.1)"}`,background:e?"rgba(199,240,74,.15)":"transparent",color:e?"var(--text-primary)":"var(--text-secondary)",fontSize:12.5,cursor:"pointer"},children:[t.jsx("span",{"aria-hidden":"true",style:{width:18,height:18,borderRadius:"50%",display:"grid",placeItems:"center",background:e?"var(--accent-active)":"rgba(255,255,255,.08)",color:e?"var(--text-on-accent)":"var(--text-primary)",fontSize:11,fontWeight:600,fontFamily:"var(--font-mono, ui-monospace, monospace)"},children:"?"}),"I don't know",t.jsx("span",{style:{color:"#858585",fontSize:11.5},children:"CodeYam will pick for you"})]})}const hae=Object.freeze(Object.defineProperty({__proto__:null,DesignQuestionIdkPill:Tc},Symbol.toStringTag,{value:"Module"}));function A7(e){const n=e.replace("#",""),s=n.length===3?n.split("").map(i=>i+i).join(""):n,[r,a,o]=[0,2,4].map(i=>parseInt(s.slice(i,i+2),16));return r*.3+a*.59+o*.11>150}function tT({options:e,selected:n,onPick:s,emphasized:r=!1}){return t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(160px, 1fr))",gap:8},children:e.map(a=>{const o=n.includes(a.label);return t.jsxs("button",{type:"button","aria-pressed":o,onClick:()=>s(a.label),style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:10,textAlign:"left",padding:"13px 14px",borderRadius:12,border:`1px solid ${o?"rgba(215,255,99,.6)":r?"rgba(255,255,255,.22)":"rgba(255,255,255,.09)"}`,background:o?"rgba(199,240,74,.15)":r?"rgba(0,0,0,.18)":"transparent",color:"var(--text-primary)",fontSize:13.5,fontWeight:500,cursor:"pointer"},children:[a.hex?t.jsxs("span",{"aria-hidden":"true","data-swatch":a.hex,style:{alignSelf:"stretch",height:64,borderRadius:8,background:a.hex,boxShadow:"inset 0 0 0 1px rgba(255,255,255,.08)",display:"flex",alignItems:"flex-end",justifyContent:"space-between",padding:"8px 10px",color:A7(a.hex)?"rgba(0,0,0,.75)":"rgba(255,255,255,.9)"},children:[t.jsx("span",{style:{fontSize:20,fontWeight:600,lineHeight:1},children:"Aa"}),t.jsx("span",{style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:11},children:a.hex.toUpperCase()})]}):null,t.jsx("span",{"aria-hidden":"true",style:{width:15,height:15,borderRadius:4,border:`1.5px solid ${o?"var(--accent-active)":"#858585"}`,background:o?"var(--accent-active)":"transparent",boxShadow:o?"inset 0 0 0 3px #1f1f21":"none"}}),t.jsxs("span",{children:[a.label,a.detail?t.jsx("small",{style:{display:"block",color:"#858585",fontSize:12,fontWeight:400,marginTop:2,lineHeight:1.35},children:a.detail}):null]})]},a.label)})})}const fae=Object.freeze(Object.defineProperty({__proto__:null,DesignQuestionOptions:tT},Symbol.toStringTag,{value:"Module"}));function nT({value:e,selected:n,placeholder:s,label:r,onChange:a}){const[o,i]=l.useState(!1),c=n||o;return t.jsx("label",{"data-testid":"design-question-own-row","data-selected":n?"true":"false",style:{display:"flex",alignItems:"center",gap:10,padding:"2px 6px 2px 12px",marginTop:8,borderRadius:10,border:`1px solid ${c?"rgba(215,255,99,.6)":"rgba(255,255,255,.2)"}`,background:n?"rgba(199,240,74,.12)":"rgba(0,0,0,.28)",boxShadow:"inset 0 1px 2px rgba(0,0,0,.35)",transition:"border-color .15s",cursor:"text"},children:t.jsx("input",{type:"text",value:e,placeholder:s,"aria-label":r,onChange:d=>a(d.target.value),onFocus:()=>i(!0),onBlur:()=>i(!1),onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),d.target.blur())},style:{flex:1,minWidth:0,height:36,background:"none",border:0,outline:"none",color:"var(--text-primary)",fontSize:13.5,fontFamily:"inherit"}})})}const mae=Object.freeze(Object.defineProperty({__proto__:null,DesignQuestionOwnRow:nT},Symbol.toStringTag,{value:"Module"})),Fm=3,$m={fontSize:12,fontWeight:500,color:"var(--text-primary)"},M7=`
|
|
255
|
+
.cy-personality-range {
|
|
256
|
+
-webkit-appearance: none;
|
|
257
|
+
appearance: none;
|
|
258
|
+
width: 100%;
|
|
259
|
+
height: 16px;
|
|
260
|
+
margin: 0;
|
|
261
|
+
background: transparent;
|
|
262
|
+
cursor: pointer;
|
|
263
|
+
--thumb: #8a8a8a;
|
|
264
|
+
}
|
|
265
|
+
.cy-personality-range[data-moved="true"] { --thumb: var(--accent-active, #D7FF63); }
|
|
266
|
+
.cy-personality-range::-webkit-slider-runnable-track {
|
|
267
|
+
height: 4px;
|
|
268
|
+
border-radius: 999px;
|
|
269
|
+
background:
|
|
270
|
+
linear-gradient(rgba(255,255,255,.35), rgba(255,255,255,.35)) center / 1px 100% no-repeat,
|
|
271
|
+
rgba(255,255,255,.12);
|
|
272
|
+
}
|
|
273
|
+
.cy-personality-range::-moz-range-track {
|
|
274
|
+
height: 4px;
|
|
275
|
+
border-radius: 999px;
|
|
276
|
+
background:
|
|
277
|
+
linear-gradient(rgba(255,255,255,.35), rgba(255,255,255,.35)) center / 1px 100% no-repeat,
|
|
278
|
+
rgba(255,255,255,.12);
|
|
279
|
+
}
|
|
280
|
+
.cy-personality-range::-webkit-slider-thumb {
|
|
281
|
+
-webkit-appearance: none;
|
|
282
|
+
appearance: none;
|
|
283
|
+
width: 14px;
|
|
284
|
+
height: 14px;
|
|
285
|
+
margin-top: -5px;
|
|
286
|
+
border-radius: 50%;
|
|
287
|
+
border: 2px solid #1f1f21;
|
|
288
|
+
background: var(--thumb);
|
|
289
|
+
box-shadow: 0 0 0 1px var(--thumb);
|
|
290
|
+
}
|
|
291
|
+
.cy-personality-range::-moz-range-thumb {
|
|
292
|
+
width: 10px;
|
|
293
|
+
height: 10px;
|
|
294
|
+
border-radius: 50%;
|
|
295
|
+
border: 2px solid #1f1f21;
|
|
296
|
+
background: var(--thumb);
|
|
297
|
+
box-shadow: 0 0 0 1px var(--thumb);
|
|
298
|
+
}
|
|
299
|
+
.cy-personality-range:focus-visible { outline: none; }
|
|
300
|
+
.cy-personality-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px rgba(215,255,99,.35); }
|
|
301
|
+
.cy-personality-range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px rgba(215,255,99,.35); }
|
|
302
|
+
`,zm={alignSelf:"flex-start",background:"transparent",border:"none",padding:0,cursor:"pointer",fontSize:12.5,color:"var(--text-secondary)"};function sT({sliders:e,moreSliders:n,words:s,moreWords:r,maxWords:a,textPlaceholder:o,value:i,onChange:c,emphasized:d=!1}){const[u,p]=l.useState(0),[h,f]=l.useState(!1),[m,g]=l.useState(""),x=[...e,...n.slice(0,u)],b=n.length-u,y=[...s,...h?r:[]],v=i.words.filter(w=>!y.includes(w)&&!r.includes(w)),j=[...y,...v],_=()=>{m.trim()&&(i.words.includes(m.trim())||c(Oh(i,m,a)),g(""))};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[t.jsx("style",{children:M7}),t.jsx("div",{style:{fontSize:12,color:"#858585"},children:"Drag toward the side that fits. Skip any that don't matter."}),t.jsx("div",{"data-testid":"personality-sliders",style:{display:"grid",gridTemplateColumns:"max-content 1fr max-content",alignItems:"center",columnGap:14,rowGap:14},children:x.map(w=>{const k=i.sliders[_r(w)],S=k??w.value,N=k!==void 0&&k<Ia,C=k!==void 0&&k>100-Ia,T=P=>({fontSize:12.5,whiteSpace:"nowrap",fontWeight:P?500:400,color:P?"var(--accent-active)":"#9a9a9a"});return t.jsxs("div",{"data-moved":k!==void 0?"true":"false",style:{display:"contents"},children:[t.jsx("span",{style:{...T(N),textAlign:"right"},children:w.left}),t.jsx("input",{type:"range",min:0,max:100,value:S,"aria-label":`${w.left} to ${w.right}`,className:"cy-personality-range","data-moved":k!==void 0?"true":"false",onChange:P=>c(pA(i,w,Number(P.target.value)))}),t.jsx("span",{style:T(C),children:w.right})]},_r(w))})}),b>0&&t.jsxs("button",{type:"button",style:zm,onClick:()=>p(w=>w+Fm),children:["+ More sliders ",t.jsxs("span",{style:{color:"#6b6b6b"},children:[Math.min(Fm,b)," more"]})]}),j.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",marginTop:4},children:[t.jsx("span",{style:$m,children:"Vibe words"}),t.jsxs("span",{style:{marginLeft:"auto",fontSize:11.5,color:"#858585",fontFamily:"var(--font-mono, ui-monospace, monospace)"},children:[i.words.length," of ",a]})]}),t.jsx(li,{options:j.map(w=>({label:w})),selected:i.words,onToggle:w=>c(Oh(i,w,a)),emphasized:d})]}),t.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",border:"1px solid rgba(255,255,255,.2)",background:"rgba(0,0,0,.28)",borderRadius:999,padding:"2px 4px 2px 12px"},children:[t.jsx("input",{value:m,placeholder:"Add your own word","aria-label":"Add your own word",onChange:w=>g(w.target.value),onKeyDown:w=>{w.key==="Enter"&&(w.preventDefault(),_())},style:{background:"none",border:0,outline:"none",color:"var(--text-primary)",fontSize:12.5,width:130}}),t.jsx("button",{type:"button","aria-label":"Add word",onClick:_,style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:15,padding:"0 6px"},children:"+"})]}),!h&&r.length>0&&t.jsx("button",{type:"button",style:zm,onClick:()=>f(!0),children:"+ More words"})]}),t.jsxs("div",{style:{marginTop:4},children:[t.jsx("span",{style:$m,children:"In your own words"})," ",t.jsx("span",{style:{fontSize:11.5,color:"#858585"},children:"optional"})]}),t.jsx("textarea",{value:i.text,placeholder:o??"e.g. Like a journal I actually want to open.","aria-label":"How it should feel, in your own words",onChange:w=>c(hA(i,w.target.value)),style:{width:"100%",height:56,resize:"vertical",background:"rgba(255,255,255,.03)",border:"1px solid rgba(255,255,255,.08)",borderRadius:10,padding:"9px 12px",color:"var(--text-primary)",fontSize:13,fontFamily:"inherit",outline:"none"}}),sx(i)&&t.jsxs("div",{"data-testid":"personality-reads",style:{fontSize:12.5,color:"#9a9a9a"},children:["Reads as ",t.jsx("b",{style:{color:"var(--text-primary)",fontWeight:500},children:rx([...e,...n],i)||"your own words"}),"."]})]})}const gae=Object.freeze(Object.defineProperty({__proto__:null,DesignQuestionPersonality:sT},Symbol.toStringTag,{value:"Module"}));function rT({images:e,parts:n,value:s,onChange:r,emphasized:a=!1}){return t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:e.map(o=>t.jsxs("div",{"data-ref-file":o.file,style:{display:"grid",gridTemplateColumns:"minmax(96px, 140px) 1fr",gap:14,padding:12,borderRadius:12,border:"1px solid rgba(255,255,255,.09)",background:a?"rgba(0,0,0,.18)":"transparent"},children:[t.jsx("img",{src:vA(o.file),alt:`${o.label} reference`,width:140,height:96,style:{width:"100%",height:96,objectFit:"cover",borderRadius:8,background:"rgba(255,255,255,.04)",boxShadow:"0 0 0 1px rgba(255,255,255,.1)"}}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,minWidth:0},children:[t.jsx("div",{style:{fontSize:13.5,fontWeight:500,color:"var(--text-primary)"},children:o.label}),o.sees?t.jsxs("div",{style:{fontSize:12,color:"#9a9a9a"},children:[t.jsx("em",{style:{fontStyle:"normal",fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:10.5,letterSpacing:".06em",color:"var(--accent-active)",marginRight:6},children:"I SEE"}),o.sees]}):null,t.jsx(li,{options:[...new Set([...n,ba])].map(i=>({label:i})),selected:s.picks[o.file]??[],onToggle:i=>r(gA(s,o.file,i)),emphasized:a}),t.jsx("input",{value:s.notes[o.file]??"",placeholder:o.placeholder??"Or write it, e.g. only the big numbers","aria-label":`What to take from ${o.label}, in your words`,onChange:i=>r(xA(s,o.file,i.target.value)),style:{background:"rgba(255,255,255,.03)",border:"1px solid rgba(255,255,255,.08)",borderRadius:8,padding:"7px 10px",color:"var(--text-primary)",fontSize:12.5,outline:"none"}})]})]},o.file))})}const xae=Object.freeze(Object.defineProperty({__proto__:null,DesignQuestionRefs:rT},Symbol.toStringTag,{value:"Module"}));function aT({question:e,index:n,total:s,status:r,isFirst:a,state:o,onToggleOption:i,onOwnText:c,onToggleIdk:d,onFreeText:u,onSetAnswer:p,onLeave:h}){const f=e,[m,g]=l.useState(!1),[x,b]=l.useState(!1),y=r==="later"&&!x,[v,j]=l.useState(!1),_=r==="current",w=o.answers[f.id],k=o.own[f.id]??"",S=_?a?"Start here":"Up next":r==="answered"?"Answered":"";return t.jsxs("div",{"data-question-id":f.id,"data-status":r,onMouseEnter:()=>g(!0),onMouseLeave:N=>{g(!1),N.buttons===0&&(h==null||h())},onFocus:()=>g(!0),onBlur:N=>{N.currentTarget.contains(N.relatedTarget)||(g(!1),N.relatedTarget&&(h==null||h()))},style:{padding:_?"22px 20px 20px":y?"16px 0 0":"30px 0 4px",margin:_?`${a?12:26}px -20px 4px`:0,borderRadius:16,border:`1px solid ${_?"rgba(215,255,99,.5)":"transparent"}`,background:_?"linear-gradient(180deg, rgba(215,255,99,.07), rgba(215,255,99,.025))":"transparent",boxShadow:_?"0 0 0 4px rgba(215,255,99,.06), 0 12px 32px rgba(0,0,0,.35)":"none",opacity:r==="later"&&!m?.42:1,transition:"opacity .2s, background .25s, border-color .25s, box-shadow .25s, padding .25s, margin .25s"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6,fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:11,letterSpacing:".06em",color:_?"var(--accent-active)":"#858585"},children:[t.jsx("span",{children:f.type==="free"?"OPTIONAL":`${n} / ${s}`}),S?t.jsx("span",{style:{fontSize:10.5,letterSpacing:".08em",textTransform:"uppercase",padding:"2px 7px",borderRadius:5,background:_?"var(--accent-active)":"transparent",color:_?"var(--text-on-accent)":"var(--text-muted)",border:_?"none":"1px solid rgba(255,255,255,.08)",fontWeight:_?600:400},children:S}):null]}),t.jsxs("h3",{style:{margin:0,fontSize:_?17:16,fontWeight:600,color:"var(--text-primary)"},children:[y?t.jsx("button",{type:"button","aria-expanded":!1,onClick:()=>b(!0),style:{background:"none",border:"none",padding:0,font:"inherit",color:"inherit",cursor:"pointer",textAlign:"left"},children:f.title}):f.title,f.why&&!y?t.jsx("button",{type:"button","aria-expanded":v,onClick:()=>j(!v),style:{marginLeft:10,background:"none",border:"none",padding:0,cursor:"pointer",fontSize:12,fontWeight:400,color:"var(--text-muted)",textDecoration:"underline",textUnderlineOffset:2,whiteSpace:"nowrap"},children:"Why?"}):null]}),y?null:t.jsxs(t.Fragment,{children:[f.why&&v?t.jsxs("p",{style:{fontSize:12.5,color:"#858585",margin:"4px 0 14px",maxWidth:"60ch"},children:[t.jsx("em",{style:{fontStyle:"normal",color:"var(--accent-active)",fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:11,letterSpacing:".04em",marginRight:6},children:"WHY"}),f.why]}):f.type==="single"||f.type==="multi"||f.type==="palette"?t.jsx("p",{style:{fontSize:12.5,color:"#858585",margin:"4px 0 12px"},children:"Pick as many as you'd like."}):t.jsx("div",{style:{height:14}}),(f.type==="single"||f.type==="palette")&&t.jsx(tT,{options:f.options,selected:Array.isArray(w)?w:[],onPick:i,emphasized:_}),f.type==="multi"&&t.jsx(li,{options:f.options,selected:Array.isArray(w)?w:[],onToggle:i,emphasized:_}),f.type==="personality"&&t.jsx(sT,{sliders:f.sliders,moreSliders:f.moreSliders,words:f.words,moreWords:f.moreWords,maxWords:f.maxWords,textPlaceholder:f.textPlaceholder,value:nx(w),onChange:p,emphasized:_}),f.type==="refs"&&t.jsx(rT,{images:f.images,parts:f.parts,value:ox(w),onChange:p,emphasized:_}),(f.type==="personality"||f.type==="refs")&&t.jsx(Tc,{selected:w===Cn,onToggle:d}),(f.type==="single"||f.type==="multi"||f.type==="palette")&&t.jsxs(t.Fragment,{children:[t.jsx(nT,{value:k,selected:k.trim().length>0,placeholder:f.ownPlaceholder??"Something else? Write your own",label:`Your own answer: ${f.title}`,onChange:c}),t.jsx(Tc,{selected:w===Cn,onToggle:d})]}),f.type==="free"&&t.jsx("textarea",{value:typeof w=="string"?w:"",placeholder:f.placeholder??"","aria-label":f.title,onChange:N=>u(N.target.value),style:{width:"100%",height:70,resize:"vertical",background:"rgba(255,255,255,.03)",border:"1px solid rgba(255,255,255,.08)",borderRadius:10,padding:"10px 12px",color:"var(--text-primary)",fontSize:13.5,lineHeight:1.45,fontFamily:"inherit",outline:"none"}})]})]})}const bae=Object.freeze(Object.defineProperty({__proto__:null,DesignQuestionCard:aT},Symbol.toStringTag,{value:"Module"})),I7=6e3;function oT({doc:e,onSend:n,onAskFollowUp:s,onProgress:r,sending:a=!1,error:o=null}){var S;const[i,c]=l.useState(jA),d=l.useMemo(()=>wo(e),[e]),[u,p]=l.useState(null),h=RA(e,i),f=u??h,m=(S=d[0])==null?void 0:S.id,g=ix(e,i),x=l.useRef(null),b=l.useRef(!1);l.useEffect(()=>{r==null||r(g,d.length)},[g,d.length,r]),l.useEffect(()=>{var T,P;if(!b.current||!f)return;b.current=!1;const N=(T=x.current)==null?void 0:T.querySelector(`[data-question-id="${f}"]`),C=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;(P=N==null?void 0:N.scrollIntoView)==null||P.call(N,{behavior:C?"auto":"smooth",block:"center"})},[f]);const y=EA(e,i),v=Math.max(1,Math.min(2,d.length)-g),[j,_]=l.useState(!1);l.useEffect(()=>{if(!j)return;const N=window.setTimeout(()=>_(!1),I7);return()=>window.clearTimeout(N)},[j]);const w=N=>{N.type!=="free"&&p(N.id)},k=(N,C)=>{if(C==="free")return"idle";if(N===f)return"current";const T=e.questions.find(P=>P.id===N);return Fr(T,i)?"answered":f?"later":"idle"};return t.jsxs("div",{ref:x,"data-testid":"design-questions-form",style:{width:"100%",maxWidth:640,background:"#1f1f21",border:"1px solid rgba(255,255,255,.1)",borderRadius:18,padding:"0 32px 0",boxShadow:"0 24px 60px rgba(0,0,0,.45)"},children:[e.questions.map(N=>t.jsx(aT,{question:N,index:d.findIndex(C=>C.id===N.id)+1,total:d.length,status:k(N.id,N.type),isFirst:N.id===m,state:i,onToggleOption:C=>{w(N),c(T=>IA(T,N.id,C,MA(N)))},onOwnText:C=>{w(N),c(T=>DA(T,N,C))},onToggleIdk:()=>{p(null),b.current=!0,c(C=>LA(C,N.id))},onFreeText:C=>c(T=>$A(T,N.id,C)),onSetAnswer:C=>{w(N),c(T=>FA(T,N.id,C))},onLeave:()=>p(C=>C===N.id?null:C)},N.id)),t.jsxs("div",{style:{position:"sticky",bottom:0,zIndex:4,display:"flex",alignItems:"center",flexWrap:"wrap",gap:8,padding:"16px 32px 20px",margin:"28px -32px 0",borderRadius:"0 0 18px 18px",background:"#1f1f21",borderTop:"1px solid rgba(255,255,255,.08)",boxShadow:"0 -14px 20px -6px #1f1f21"},children:[t.jsx("button",{type:"button",onClick:()=>c(N=>zA(e,N)),style:Yi("ghost"),children:"Decide for me"}),t.jsx("span",{style:{flex:1}}),o?t.jsx("span",{role:"alert",style:{fontSize:12.5,color:"var(--accent-danger, #f87171)"},children:o}):null,t.jsx("button",{type:"button",onClick:()=>{s==null||s(),_(!0)},disabled:!s||j,style:Yi("secondary",!s||j),children:j?"Asked. Look in the chat":"Ask me follow-up questions"}),!y&&!a?t.jsxs("span",{"data-testid":"design-questions-send-hint",style:{fontSize:12,color:"var(--text-muted)"},children:["Answer ",v," more to send"]}):null,t.jsxs("button",{type:"button",onClick:()=>n(i),disabled:!y||a,style:Yi("primary",!y||a),children:[a?"Sending…":"Send answers",!a&&t.jsx("span",{"aria-hidden":"true",style:{marginLeft:8},children:"→"})]})]})]})}function Yi(e,n=!1){const s=e==="primary";return{height:s?40:32,padding:s?"0 22px":"0 14px",borderRadius:s?10:8,fontSize:s?14.5:13,whiteSpace:"nowrap",cursor:n?"not-allowed":"pointer",opacity:n?.4:1,boxShadow:s&&!n?"0 0 0 4px rgba(215,255,99,.16), 0 6px 18px rgba(215,255,99,.18)":"none",border:e==="primary"?"1px solid var(--accent-active)":e==="secondary"?"1px solid rgba(255,255,255,.12)":"1px solid transparent",background:e==="primary"?"var(--accent-active)":"transparent",color:e==="primary"?"var(--text-on-accent)":e==="ghost"?"var(--text-muted)":"var(--text-primary)",fontWeight:e==="primary"?600:400}}const yae=Object.freeze(Object.defineProperty({__proto__:null,DesignQuestionsForm:oT},Symbol.toStringTag,{value:"Module"}));function rs({title:e,subtitle:n,status:s,onSkip:r}){return t.jsxs("div",{"data-testid":"design-session-canvas-header",style:{position:"sticky",top:0,zIndex:3,display:"flex",alignItems:"center",gap:10,padding:"14px 18px",background:"#242424",borderBottom:"1px solid rgba(255,255,255,.08)",flex:"none"},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2,minWidth:0},children:[t.jsx("span",{style:{fontSize:14,fontWeight:600,color:"var(--text-primary)"},children:e}),n?t.jsx("span",{style:{fontSize:12.5,color:"var(--text-muted)"},children:n}):null]}),t.jsx("span",{style:{flex:1}}),s?t.jsx("span",{"data-testid":"design-session-canvas-status",style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12,color:"var(--text-muted)",whiteSpace:"nowrap"},children:s}):null,r?t.jsxs("button",{type:"button",onClick:r,style:{display:"inline-flex",alignItems:"center",gap:6,height:30,padding:"0 10px 0 12px",borderRadius:8,border:"1px solid var(--line-strong)",background:"rgba(255,255,255,.05)",color:"var(--text-primary)",fontSize:12.5,fontWeight:500,whiteSpace:"nowrap",cursor:"pointer"},children:["Skip to build",t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M2.5 6h7M6.5 3l3 3-3 3"})})]}):null]})}const vae=Object.freeze(Object.defineProperty({__proto__:null,DesignSessionCanvasHeader:rs},Symbol.toStringTag,{value:"Module"})),zp=7e3,Bm=350;function iT({tips:e,size:n=20}){const[s,r]=l.useState(0),[a,o]=l.useState(!0);return l.useEffect(()=>{if(e.length<2)return;let i;const c=window.setInterval(()=>{o(!1),i=window.setTimeout(()=>{r(d=>(d+1)%e.length),o(!0)},Bm)},zp);return()=>{window.clearInterval(c),i!==void 0&&window.clearTimeout(i)}},[e.length]),t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:10,textAlign:"center"},children:[t.jsx("span",{style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:11,letterSpacing:".12em",textTransform:"uppercase",color:"var(--accent-active, #D7FF63)"},children:"Tip"}),t.jsx("p",{"data-testid":"session-tip",style:{margin:0,fontSize:n,lineHeight:1.35,maxWidth:"32ch",minHeight:"2.7em",textWrap:"balance",color:"var(--text-primary)",opacity:a?1:0,transition:`opacity ${Bm}ms`},children:e[s%e.length]})]})}const jae=Object.freeze(Object.defineProperty({__proto__:null,SessionTip:iT,TIP_ROTATE_MS:zp},Symbol.toStringTag,{value:"Module"})),lT=["Rate each design and leave a note. The next round follows your feedback.","Customize colors and fonts on any design before you choose it.","Say “mix 2 and 5” in the chat to combine two directions.","Every round is saved. Page back to earlier ones anytime.","Switch to Terminal to see exactly what the agent is doing."];function cT({ready:e,target:n,onShowReady:s}){const r=n===null||n===0?"Getting started":`${Math.min(e,n)} of ${n} designs ready`;return t.jsxs("div",{"data-testid":"design-session-generating",style:{flex:1,minHeight:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:22,padding:"40px 16px",textAlign:"center"},children:[t.jsx(Ht,{size:28}),t.jsx(iT,{tips:lT}),n!==null&&n>0&&t.jsx("div",{"data-testid":"design-session-progress",style:{display:"flex",gap:6},children:Array.from({length:n},(a,o)=>t.jsx("i",{"data-on":o<e?"true":"false",style:{width:28,height:4,borderRadius:99,background:o<e?"var(--accent-active, #D7FF63)":"rgba(255,255,255,.1)",transition:"background .3s"}},o))}),t.jsx("span",{"aria-live":"polite","data-testid":"design-session-progress-label",style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12,color:"var(--text-tertiary, rgba(255,255,255,.45))"},children:r}),e>0&&s&&t.jsx("button",{type:"button",onClick:s,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",fontSize:13,color:"var(--text-secondary)",textDecoration:"underline",textUnderlineOffset:3},children:"Show the ready ones"})]})}const wae=Object.freeze(Object.defineProperty({__proto__:null,DesignSessionGenerating:cT,GENERATING_TIPS:lT},Symbol.toStringTag,{value:"Module"}));function dT(){return t.jsx("div",{"data-testid":"design-session-preparing",style:{flex:1,minHeight:0,overflow:"auto",display:"flex",justifyContent:"center",padding:"32px 16px 48px"},children:t.jsxs("div",{style:{width:"100%",maxWidth:640,display:"flex",flexDirection:"column",gap:12},children:[t.jsxs("div",{role:"status",style:{display:"flex",alignItems:"center",gap:10,fontSize:13,color:"var(--text-secondary)",marginBottom:6},children:[t.jsx(Ht,{}),"Reading your project and writing a few questions…"]}),[0,1,2].map(e=>t.jsxs("div",{"aria-hidden":"true",className:"animate-pulse",style:{borderRadius:12,border:"1px solid rgba(255,255,255,.08)",background:"rgba(255,255,255,.03)",padding:18,display:"flex",flexDirection:"column",gap:12,opacity:1-e*.25},children:[t.jsx("span",{style:{width:"45%",height:12,borderRadius:6,background:"rgba(255,255,255,.1)"}}),t.jsx("span",{style:{width:"70%",height:9,borderRadius:6,background:"rgba(255,255,255,.06)"}}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:8},children:[0,1,2].map(n=>t.jsx("span",{style:{height:44,borderRadius:8,background:"rgba(255,255,255,.05)"}},n))})]},e))]})})}const _ae=Object.freeze(Object.defineProperty({__proto__:null,DesignSessionPreparing:dT},Symbol.toStringTag,{value:"Module"})),uT=5e3,pT=1200*1e3;function hT({grid:e,round:n,onSkip:s}){const{doc:r,answered:a,submit:o}=P7(!0),{ready:i,target:c}=Q0(n,!0),[d,u]=l.useState(!1);l.useEffect(()=>{i===0&&u(!1)},[i]);const{sendToAgent:p,agentReady:h}=q0(),[f,m]=l.useState(null),[g,x]=l.useState(!1),[b,y]=l.useState(null),v=E7({hasQuestions:r!==null,answered:a,ready:i??0,target:c}),j=v==="questions"?"questions":i===null?"pending":v==="generating"&&d?"gallery":v,_=Ou(),w=Y0(),k=_==null?void 0:_.stage;l.useEffect(()=>{k==="planning"&&j==="generating"&&Pu()},[k,j]),l.useEffect(()=>{if(k!=="designing"||w||j!=="gallery")return;const O=window.setTimeout(xf,uT);return()=>window.clearTimeout(O)},[k,w,j]);const S=_==null?void 0:_.id;l.useEffect(()=>{if(!S)return;const O=window.setTimeout(xf,pT);return()=>window.clearTimeout(O)},[S]);const N=l.useCallback((O,W)=>{m({n:O,total:W})},[]),C=l.useRef([]);l.useEffect(()=>()=>{C.current.forEach(O=>O()),C.current=[]},[]);const T=O=>{const W=br(p,O);W&&C.current.push(W)},P=R7((c??0)>0||(i??0)>0),{markSent:R}=P,I=()=>{T(ld),R()},A=async O=>{if(!r)return;x(!0),y(null);const W=await o(WA(r,O));if(x(!1),!W){y("Couldn't save your answers. Try again.");return}I()};return t.jsxs("div",{"data-testid":"design-session-canvas",className:"flex-1 flex flex-col min-w-0",children:[j==="questions"&&r&&t.jsxs(t.Fragment,{children:[t.jsx(rs,{title:"Before I design",subtitle:"Answer a few quick questions so the designs fit your project, not a template.",status:f?`${f.n} of ${f.total} answered`:void 0,onSkip:s}),t.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto",display:"flex",justifyContent:"center",alignItems:"flex-start",padding:"32px 16px 0"},children:t.jsx(oT,{doc:r,onSend:O=>void A(O),onAskFollowUp:h?()=>T(HA):void 0,onProgress:N,sending:g,error:b})})]}),j==="preparing"&&t.jsxs(t.Fragment,{children:[t.jsx(rs,{title:"Before I design",subtitle:"Reading what you shared so the questions are about your project.",status:"preparing questions",onSkip:s}),t.jsx(dT,{})]}),j==="generating"&&t.jsxs(t.Fragment,{children:[t.jsx(rs,{title:_?`Designing round ${_.round}`:"Designing your directions",subtitle:_?"Redoing the designs from your feedback. They'll appear here as soon as they're ready.":"They'll appear here as soon as they're ready.",onSkip:s}),P.undelivered&&t.jsxs("div",{role:"alert","data-testid":"design-answers-undelivered",style:{margin:"14px 16px 0",padding:"10px 12px",borderRadius:10,border:`1px solid ${it}`,background:"rgba(255,139,67,.08)",display:"flex",alignItems:"center",gap:12,fontSize:13,color:"var(--text-primary)"},children:[t.jsx("span",{style:{flex:1},children:"Your answers are saved, but the agent doesn't seem to have received them."}),t.jsx("button",{type:"button",onClick:I,disabled:!h,style:{flex:"none",height:30,padding:"0 12px",borderRadius:8,border:"1px solid var(--accent-active)",background:"var(--accent-active)",color:"var(--text-on-accent)",fontSize:12.5,fontWeight:600,cursor:h?"pointer":"not-allowed",opacity:h?1:.4},children:"Send again"})]}),t.jsx(cT,{ready:i??0,target:c,onShowReady:()=>u(!0)})]}),j==="gallery"&&t.jsxs(t.Fragment,{children:[t.jsx(rs,{title:_?_.stage==="planning"?`Planning round ${_.round}`:`Designing round ${_.round}`:"Rate these designs",subtitle:_?_.stage==="planning"?"Your feedback is in. Choose in the chat which designs to keep; the rest get redesigned.":"Updated designs replace the old ones here as they're ready.":"Add feedback and keep iterating until you're happy with the results.",status:_?_.stage==="planning"&&!w?za:"working":void 0,onSkip:s}),e]}),j==="pending"&&t.jsx(rs,{title:"Design session",onSkip:s})]})}const Sae=Object.freeze(Object.defineProperty({__proto__:null,DesignSessionCanvas:hT,ITERATE_DONE_AFTER_IDLE_MS:uT,ITERATE_GIVE_UP_MS:pT},Symbol.toStringTag,{value:"Module"}));function fT({onDesignConfirmed:e,onExit:n,round:s,sessionMode:r=!1,onSkip:a}){const[o,i]=l.useState("assets"),c=qr(s===void 0),d=s!==void 0?s:c,u=d!==void 0,p=l.useRef(!0),h=l.useRef(0),f=l.useRef(null),m=l.useCallback(x=>{f.current=x},[]),g=l.useCallback(x=>{const b=f.current;return b?(i("assets"),b(x)):!1},[]);return bE(g,"design assets"),l.useEffect(()=>{p.current=!0;const x=async()=>{try{const v=await(await fetch("/api/editor-design-active-tab")).json();if(!p.current)return;v.tab!==null&&v.nonce!==null&&v.nonce>h.current&&(h.current=v.nonce,i(v.tab))}catch{}};x();const b=window.setInterval(x,4e3);return()=>{p.current=!1,window.clearInterval(b)}},[]),r?t.jsx(hT,{onSkip:a,round:d??void 0,grid:u?t.jsx(ao,{onDesignConfirmed:e,round:d??void 0,hideInfoBanner:!0,pickInChat:!0}):null}):t.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[t.jsxs("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:x,label:b})=>{const y=o===x;return t.jsx("button",{type:"button",role:"tab","aria-selected":y,onClick:()=>i(x),style:{padding:"var(--spacing-xs, 4px) var(--spacing-md, 12px)",borderRadius:6,border:"none",cursor:"pointer",fontSize:"var(--text-sm, 14px)",fontWeight:500,background:y?"var(--accent-active)":"transparent",color:y?"var(--text-on-accent, white)":"var(--text-secondary)"},children:b},x)}),n?t.jsx("button",{type:"button",onClick:n,style:{marginLeft:"auto",padding:"var(--spacing-xs, 4px) var(--spacing-md, 12px)",borderRadius:6,border:"1px solid var(--border-default)",cursor:"pointer",fontSize:"var(--text-sm, 14px)",background:"transparent",color:"var(--text-secondary)"},children:"Close"}):null]}),t.jsx("div",{className:"flex-1 flex-col min-w-0",style:{display:o==="assets"?"flex":"none"},children:t.jsx(tC,{onRegisterDropReceiver:m})}),o==="assets"?null:u?t.jsx(ao,{onDesignConfirmed:e,round:d??void 0}):null]})}const kae=Object.freeze(Object.defineProperty({__proto__:null,DesignChatPreviewPane:fT},Symbol.toStringTag,{value:"Module"}));function mT({roundId:e,onUse:n,onDiscard:s}={}){const[r,a]=l.useState(null),o=qr(e===void 0),i=e??o,c=l.useCallback(u=>{u.kind==="use"&&(a("use"),n?n(u.filename):bc(`I've picked the design "${u.filename}" for this round. Please record the selection (branch-outcome design-iterate use), apply it, and return to the build.`))},[n]),d=l.useCallback(()=>{a("discard"),s?s():bc("Let's discard this design round — none of these directions. Please record the discard (branch-outcome design-iterate discard), archive the round, and return to the build with the design unchanged.")},[s]);return t.jsxs("div",{className:"flex-1 flex flex-col min-w-0",style:{overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"var(--spacing-md, 12px)",padding:"var(--spacing-md, 12px) var(--spacing-lg, 16px)",borderBottom:"1px solid var(--border-default)"},children:[t.jsxs("div",{style:{minWidth:0},children:[t.jsx("div",{style:{fontSize:"var(--text-sm, 14px)",fontWeight:600,color:"var(--text-primary)"},children:"Design round"}),t.jsx("div",{style:{fontSize:"var(--text-xs, 12px)",color:"var(--text-secondary)"},children:"The first card reads as the app today, changed. Pick a direction to carry into the build, or discard the round."})]}),t.jsx("button",{type:"button",onClick:d,disabled:r!=null,style:{flexShrink:0,padding:"var(--spacing-xs, 6px) var(--spacing-md, 12px)",borderRadius:8,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:"var(--text-sm, 14px)",cursor:r!=null?"default":"pointer",opacity:r!=null?.6:1},children:r==="discard"?"Discarding…":"Discard round"})]}),typeof i=="string"?t.jsx(ao,{round:i,onDesignConfirmed:c}):t.jsx(Bb,{state:i===void 0?"resolving":"none"})]})}const Nae=Object.freeze(Object.defineProperty({__proto__:null,DesignRoundPreviewPane:mT},Symbol.toStringTag,{value:"Module"}));function gT({target:e,onStored:n,onClose:s}){const[r,a]=l.useState(null);if(!e)return t.jsxs("div",{"data-testid":"credential-request-pane",className:"flex-1 flex flex-col items-center justify-center gap-3 bg-[#0F0F0F] text-sm text-[#8E8E8E]",children:[t.jsx("p",{children:"No key has been requested."}),t.jsx("button",{onClick:s,className:"px-3 py-1.5 rounded-md border border-[#3A3A3A] text-white cursor-pointer",children:"Back to preview"})]});const o=r===e.envVar;return t.jsxs("div",{"data-testid":"credential-request-pane",className:"flex-1 flex flex-col min-w-0 min-h-0 bg-[#0F0F0F]",children:[t.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-[#2A2A2A]",children:[t.jsxs("h2",{className:"text-base font-semibold text-white",children:["Add your ",e.serviceName," key"]}),t.jsx("button",{"data-testid":"credential-request-close",onClick:s,className:"text-[#8E8E8E] hover:text-white cursor-pointer","aria-label":"Close",children:"✕"})]}),t.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:t.jsx("div",{className:"max-w-xl space-y-4",children:o?t.jsx(mb,{serviceName:e.serviceName,envVar:e.envVar,onBack:s}):t.jsxs(t.Fragment,{children:[e.instructions?t.jsx("div",{"data-testid":"credential-request-instructions",className:"text-sm text-[#CFCFCF] whitespace-pre-wrap leading-relaxed",children:e.instructions}):null,e.docsUrl?t.jsx(Sd,{href:e.docsUrl}):null,t.jsx(_d,{envVar:e.envVar}),t.jsx(kd,{target:e,onStored:()=>{a(e.envVar),n(e)}})]})})})]})}const Cae=Object.freeze(Object.defineProperty({__proto__:null,CredentialRequestPreviewPane:gT},Symbol.toStringTag,{value:"Module"}));function xT({deviceLabel:e,actions:n}){return t.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:[t.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:[t.jsx("rect",{x:"3",y:"4",width:"7",height:"16",rx:"1"}),t.jsx("rect",{x:"14",y:"4",width:"7",height:"16",rx:"1"}),t.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"22",strokeDasharray:"2 2"})]}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"font-semibold",children:"Live mirror — not interactive."})," ",t.jsxs("span",{style:{color:"var(--text-dim)"},children:["Tap and type directly in the ",e," window."]})]}),n?t.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-3",children:n}):null]})}const Tae=Object.freeze(Object.defineProperty({__proto__:null,NativeMirrorNotice:xT},Symbol.toStringTag,{value:"Module"}));function bT(){return t.jsx("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:t.jsxs("span",{children:[t.jsx("strong",{children:"Web preview"})," — this machine can't run the device simulator, so you're seeing the app's web build. Layout and logic match; fonts, native controls and status bars may differ from the phone. Saved scenario screenshots still come from the simulator."]})})}const Pae=Object.freeze(Object.defineProperty({__proto__:null,NativeWebPreviewNotice:bT},Symbol.toStringTag,{value:"Module"}));function yT({isCollapsed:e,onToggle:n}){return t.jsx("button",{onClick:n,className:`p-1.5 rounded transition-colors cursor-pointer ${e?"text-white bg-[#666] hover:bg-[#777]":"text-gray-500 hover:text-gray-300"}`,title:e?"Show editor":"Hide editor",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e?t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M13 17l5-5-5-5"}),t.jsx("path",{d:"M6 17l5-5-5-5"})]}):t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M11 17l-5-5 5-5"}),t.jsx("path",{d:"M18 17l-5-5 5-5"})]})})})}const Oae=Object.freeze(Object.defineProperty({__proto__:null,CollapseToggleButton:yT},Symbol.toStringTag,{value:"Module"}));function Pc({label:e,value:n,disabled:s,onCommit:r,bare:a=!1}){const[o,i]=l.useState(String(n));l.useEffect(()=>{i(String(n))},[n]);const c=()=>{const d=Number.parseInt(o,10);if(!Number.isFinite(d)||d<=0){i(String(n));return}d!==n&&r(d)};return t.jsxs("label",{className:`flex items-center gap-0.5 text-xs ${a?"":"px-1 py-0.5 rounded bg-[#2A2929]"} ${s?"opacity-50 cursor-not-allowed":""}`,children:[t.jsx("span",{className:a?"sr-only":"text-[10px] font-semibold text-gray-500 select-none",children:e}),t.jsx("input",{type:"text",inputMode:"numeric",value:o,disabled:s,"aria-label":e==="H"?"Height":"Width",onChange:d=>i(d.target.value.replace(/[^0-9]/g,"")),onBlur:c,onKeyDown:d=>{d.key==="Enter"?(c(),d.target.blur()):d.key==="Escape"&&(i(String(n)),d.target.blur())},className:"w-[4.5ch] 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 Rae=Object.freeze(Object.defineProperty({__proto__:null,DimensionInput:Pc},Symbol.toStringTag,{value:"Module"}));function vT({isFilled:e,onToggle:n}){return t.jsx("button",{onClick:n,className:`p-1.5 rounded transition-colors cursor-pointer ${e?"text-white bg-[#555]":"text-gray-500 hover:text-gray-300"}`,title:e?"Exit fullscreen":"Fill page with preview",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e?t.jsxs(t.Fragment,{children:[t.jsx("polyline",{points:"4 14 10 14 10 20"}),t.jsx("polyline",{points:"20 10 14 10 14 4"}),t.jsx("line",{x1:"14",y1:"10",x2:"21",y2:"3"}),t.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]}):t.jsxs(t.Fragment,{children:[t.jsx("polyline",{points:"15 3 21 3 21 9"}),t.jsx("polyline",{points:"9 21 3 21 3 15"}),t.jsx("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),t.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})})})}const Eae=Object.freeze(Object.defineProperty({__proto__:null,FillPreviewButton:vT},Symbol.toStringTag,{value:"Module"}));function jT({previewUrl:e}){return t.jsx("button",{onClick:()=>{e&&window.open(e,"_blank")},className:"p-1.5 rounded text-gray-500 hover:text-gray-300 transition-colors cursor-pointer",title:"Open preview in new window",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),t.jsx("polyline",{points:"15 3 21 3 21 9"}),t.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})})}const Aae=Object.freeze(Object.defineProperty({__proto__:null,OpenInNewTabButton:jT},Symbol.toStringTag,{value:"Module"})),Oc=new Set;function D7(e){return Oc.add(e),()=>{Oc.delete(e)}}function L7(){for(const e of Oc)e()}function wT(){return t.jsx("button",{onClick:()=>L7(),className:"p-1.5 rounded text-gray-500 hover:text-gray-300 transition-colors cursor-pointer",title:"Refresh preview","aria-label":"Refresh preview",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("polyline",{points:"1 20 1 14 7 14"}),t.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 Mae=Object.freeze(Object.defineProperty({__proto__:null,RefreshPreviewButton:wT},Symbol.toStringTag,{value:"Module"}));function Wm(e){var s;return e.route==="Uncategorized"?2:e.route.startsWith("/isolated-components/")||((s=e.scenarios[0])==null?void 0:s.scenarioType)==="component"?1:0}function _T(e){const n=new Map;for(const s of e){const r=s.url??"Uncategorized",a=n.get(r)??[];a.push(s),n.set(r,a)}return Array.from(n.entries()).map(([s,r])=>({route:s,scenarios:r})).sort((s,r)=>{const a=Wm(s)-Wm(r);return a!==0?a:s.route.localeCompare(r.route)})}function F7(e,n){const s=n.trim().toLowerCase();return s?e.filter(r=>{const a=(r.url??"").toLowerCase(),o=r.name.toLowerCase(),i=(r.componentName??"").toLowerCase();return a.includes(s)||o.includes(s)||i.includes(s)}):e}function ST({tab:e,hasQuery:n}){return n?t.jsx("p",{className:"text-xs text-gray-500 px-2 py-6 text-center",children:"No matches for your search."}):t.jsxs("p",{className:"text-xs text-gray-500 px-2 py-6 text-center",children:["No ",e==="pages"?"pages":"components"," yet."]})}const Iae=Object.freeze(Object.defineProperty({__proto__:null,PagePickerEmptyMessage:ST},Symbol.toStringTag,{value:"Module"}));function kT({scenario:e,active:n,onClick:s}){const r=e.screenshotPaths[0],a=Ao(e);return t.jsxs("button",{onClick:s,"aria-current":n?"true":void 0,className:"group w-28 text-left cursor-pointer",title:e.name,children:[t.jsx("div",{className:`aspect-[4/5] w-full overflow-hidden rounded-md bg-[#141414] flex items-center justify-center transition-shadow ${n?"ring-2 ring-[var(--accent-active)]":"ring-1 ring-white/10 group-hover:ring-white/25"}`,children:r?t.jsx("img",{src:ds(r),alt:e.name,loading:"lazy",className:"w-full h-full object-contain"}):t.jsx("span",{className:"text-[10px] text-gray-600",children:"No screenshot"})}),t.jsx("div",{className:`pt-1.5 px-0.5 text-[11.5px] truncate ${n?"text-white":"text-gray-400 group-hover:text-gray-200"}`,children:a})]})}const Dae=Object.freeze(Object.defineProperty({__proto__:null,PagePickerScenarioThumbnail:kT},Symbol.toStringTag,{value:"Module"}));function NT({group:e,currentSlug:n,onSelect:s}){const r=e.scenarios[0]?Cv(e.scenarios[0]):null;return t.jsxs("div",{className:"min-w-0 max-w-full",children:[t.jsx("div",{className:"mb-2 px-0.5 max-w-[16rem]",title:e.route,children:t.jsx("span",{className:"block text-xs font-medium text-gray-200 truncate",children:r??e.route})}),t.jsx("div",{className:"flex flex-wrap gap-3",children:e.scenarios.map(a=>t.jsx(kT,{scenario:a,active:a.slug===n,onClick:()=>s(a.slug)},a.slug))})]})}const Lae=Object.freeze(Object.defineProperty({__proto__:null,PagePickerRouteSection:NT},Symbol.toStringTag,{value:"Module"}));function Rc({label:e,active:n,count:s,onClick:r}){return t.jsxs("button",{onClick:r,"aria-pressed":n,className:`flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs cursor-pointer transition-colors ${n?"text-white bg-white/10":"text-gray-500 hover:text-gray-300"}`,children:[e,t.jsx("span",{className:`text-[11px] tabular-nums ${n?"text-gray-400":"text-gray-600"}`,children:s})]})}const Fae=Object.freeze(Object.defineProperty({__proto__:null,PagePickerTabButton:Rc},Symbol.toStringTag,{value:"Module"}));function CT({scenarioGroups:e,currentSlug:n,onSelect:s,onClose:r,triggerRef:a}){const[o,i]=l.useState("pages"),[c,d]=l.useState(""),u=l.useRef(null),p=l.useRef(null);l.useEffect(()=>{var y;(y=p.current)==null||y.focus()},[]),Hc(u,r,a);const h=l.useMemo(()=>e.flatMap(y=>y.scenarios),[e]),f=l.useMemo(()=>F7(h,c),[h,c]),m=l.useMemo(()=>f.filter(co),[f]),g=l.useMemo(()=>f.filter($c),[f]),x=o==="pages"?m:g,b=l.useMemo(()=>_T(x),[x]);return t.jsxs("div",{ref:u,className:"absolute top-full left-0 mt-1.5 bg-[#1f1f1f] border border-white/10 rounded-xl shadow-2xl z-50 w-[560px] max-w-[calc(100vw-2rem)] max-h-[480px] flex flex-col",role:"dialog",children:[t.jsxs("div",{className:"flex items-center border-b border-white/[.06] px-2.5 py-2 gap-1",children:[t.jsx(Rc,{label:"Pages",active:o==="pages",count:m.length,onClick:()=>i("pages")}),t.jsx(Rc,{label:"Components",active:o==="components",count:g.length,onClick:()=>i("components")}),t.jsx("div",{className:"flex-1"}),t.jsx("input",{ref:p,value:c,onChange:y=>d(y.target.value),placeholder:"Search…",className:"w-44 h-7 px-2.5 text-xs bg-white/[.04] border border-white/10 rounded-md text-gray-200 placeholder:text-gray-600 focus:outline-none focus:border-white/25"}),t.jsx("button",{onClick:r,"aria-label":"Close",className:"p-1 text-gray-500 hover:text-gray-200 cursor-pointer",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),t.jsx("div",{className:"overflow-y-auto p-4 flex-1 min-h-0 flex flex-wrap content-start items-start gap-x-6 gap-y-5",children:b.length===0?t.jsx(ST,{tab:o,hasQuery:c.trim().length>0}):b.map(y=>t.jsx(NT,{group:y,currentSlug:n,onSelect:v=>{s(v),r()}},y.route))})]})}const $ae=Object.freeze(Object.defineProperty({__proto__:null,PagePickerDropdown:CT},Symbol.toStringTag,{value:"Module"}));function TT(){return t.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:[t.jsx("path",{d:"M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),t.jsx("path",{d:"M14 3v6h6"})]})}function PT(){return t.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:[t.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1"}),t.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1"}),t.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1"}),t.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1"})]})}function OT({className:e}){return t.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:e??"opacity-70 shrink-0 text-gray-400",children:t.jsx("polyline",{points:"6 9 12 15 18 9"})})}const zae=Object.freeze(Object.defineProperty({__proto__:null,ComponentGlyph:PT,DropdownChevron:OT,PageGlyph:TT},Symbol.toStringTag,{value:"Module"}));function RT({currentScenario:e,isOpen:n,onClick:s,buttonRef:r}){const a=e?$c(e):!1,o=(e==null?void 0:e.screenshotPaths[0])??null,i=e?a?e.componentName??e.name:Cv(e)??e.url??e.name:"Select a page";return t.jsxs("button",{ref:r,onClick:s,className:`flex items-center gap-2 h-7 max-w-[260px] px-1.5 rounded-md transition-colors cursor-pointer text-xs ${e?"text-white":"text-gray-500"} ${n?"bg-white/10":"hover:bg-white/5"}`,title:i,"aria-haspopup":"menu","aria-expanded":n,children:[t.jsx("span",{className:"flex items-center",children:t.jsx("span",{className:"w-6 h-4 overflow-hidden rounded-sm bg-[#0f0f0f] ring-1 ring-white/10 flex items-center justify-center text-gray-500",children:o?t.jsx("img",{src:ds(o),alt:"",className:"w-full h-full object-cover"}):a?t.jsx(PT,{}):t.jsx(TT,{})})}),t.jsx("span",{className:"truncate",children:i})]})}const Bae=Object.freeze(Object.defineProperty({__proto__:null,PagePill:RT},Symbol.toStringTag,{value:"Module"}));function ET({scenario:e,active:n,onClick:s}){const r=e.screenshotPaths[0];return t.jsxs("button",{onClick:s,"aria-current":n?"true":void 0,className:`flex items-center gap-2.5 w-full px-2 py-1.5 rounded-md text-left transition-colors cursor-pointer ${n?"bg-white/[.08]":"hover:bg-white/5"}`,children:[t.jsx("div",{className:`w-10 h-7 shrink-0 rounded overflow-hidden bg-[#0f0f0f] flex items-center justify-center ${n?"ring-2 ring-[var(--accent-active)]":"ring-1 ring-white/10"}`,children:r?t.jsx("img",{src:ds(r),alt:"",className:"w-full h-full object-cover"}):null}),t.jsx("div",{className:`text-xs truncate flex-1 min-w-0 ${n?"text-white":"text-gray-200"}`,children:Ao(e)})]})}const Wae=Object.freeze(Object.defineProperty({__proto__:null,StatesDropdownRow:ET},Symbol.toStringTag,{value:"Module"}));function AT({currentScenario:e,scenarioGroups:n,onSelect:s,onCreateNew:r,onClose:a,triggerRef:o}){const i=l.useRef(null);Hc(i,a,o);const c=l.useMemo(()=>Kd(e,n),[e,n]);return t.jsxs("div",{ref:i,className:"absolute top-full left-0 mt-1.5 bg-[#1f1f1f] border border-white/10 rounded-xl shadow-2xl z-50 w-72 max-w-[calc(100vw-2rem)] max-h-[400px] flex flex-col overflow-hidden",role:"menu",children:[t.jsx("div",{className:"overflow-y-auto p-1 flex-1 min-h-0",children:c.map(d=>t.jsx(ET,{scenario:d,active:d.slug===e.slug,onClick:()=>{s(d.slug),a()}},d.slug))}),t.jsx("button",{onClick:()=>{r(),a()},className:"border-t border-white/[.06] px-3 py-2.5 text-left text-xs text-[var(--accent-active)] hover:bg-[var(--accent-active)]/10 cursor-pointer",children:"+ New state"})]})}const Hae=Object.freeze(Object.defineProperty({__proto__:null,StatesDropdown:AT},Symbol.toStringTag,{value:"Module"}));function MT({label:e,disabled:n,isOpen:s,onClick:r,buttonRef:a}){return t.jsxs("button",{ref:a,onClick:()=>{n||r()},disabled:n,className:`flex items-center gap-1.5 max-w-[200px] h-7 px-2 rounded-md transition-colors text-xs ${n?"text-gray-600 cursor-not-allowed":s?"bg-white/10 text-gray-200 cursor-pointer":"text-gray-400 hover:bg-white/5 hover:text-gray-200 cursor-pointer"}`,title:n?"No active state":e,"aria-haspopup":"menu","aria-expanded":s,children:[t.jsx("span",{className:"truncate",children:e}),t.jsx(OT,{className:"opacity-70 shrink-0"})]})}const qae=Object.freeze(Object.defineProperty({__proto__:null,StatesPillButton:MT},Symbol.toStringTag,{value:"Module"}));function IT({viewport:e,isActive:n,onSelect:s}){return t.jsx("button",{onClick:s,"aria-pressed":n,className:`p-1 rounded-md transition-colors cursor-pointer ${n?"text-white bg-white/10":"text-gray-500 hover:text-gray-300"}`,title:`${e.name} (${e.width}×${e.height})`,children:t.jsx(v1,{name:e.name})})}const Uae=Object.freeze(Object.defineProperty({__proto__:null,ViewportPresetButton:IT},Symbol.toStringTag,{value:"Module"}));function DT({viewports:e,active:n,onChange:s,currentWidth:r,currentHeight:a,previewUrl:o,isCollapsed:i,onToggleCollapsed:c,isFilled:d,onToggleFilled:u,containerWidth:p,containerHeight:h,onCustomSizeChange:f,currentScenario:m,scenarioGroups:g,onShowScenarioPreview:x,onCreateStateRequest:b,isNarrow:y=!1,onBack:v,onPlanChange:j,onToggleStatesModal:_,statesModalOpen:w=!1}){const[k,S]=l.useState(!1),[N,C]=l.useState(!1),T=l.useRef(null),P=l.useRef(null),R=d&&p?Math.round(p):r,I=d&&h?Math.round(h):a,A=m?Ao(m):"No state",O=!m;return t.jsxs("div",{className:"bg-[#2d2d2d] border-b border-[#3d3d3d] shrink-0 h-10 flex items-center gap-2 px-2",children:[t.jsx("div",{className:"shrink-0",children:v?t.jsxs("button",{type:"button",onClick:v,className:"flex items-center gap-1 h-7 px-2 rounded text-sm text-[#ddd] hover:bg-[#3a3a3a]",children:[t.jsx("span",{"aria-hidden":"true",children:"←"})," Home"]}):y?null:t.jsx(yT,{isCollapsed:i,onToggle:c})}),t.jsxs("div",{"data-testid":"preview-bar-groups",className:`flex flex-1 items-center justify-between gap-2 min-w-0 ${y?"overflow-x-auto":""}`,children:[t.jsxs("div",{"data-testid":"preview-subject-group",className:"relative flex items-center h-7 gap-0.5 shrink-0",children:[t.jsx(RT,{currentScenario:m,isOpen:k,onClick:()=>{S(W=>!W),C(!1)},buttonRef:T}),k&&t.jsx(CT,{scenarioGroups:g,currentSlug:(m==null?void 0:m.slug)??null,onSelect:x,onClose:()=>S(!1),triggerRef:T}),t.jsx("div",{className:"relative flex items-center",children:_?w?null:t.jsx("button",{type:"button",onClick:_,className:"px-2 font-mono text-[10px] leading-none uppercase tracking-widest underline underline-offset-2 whitespace-nowrap hover:opacity-80",style:{color:"var(--lime-300)"},children:"Scenarios"}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-xs text-[#666] shrink-0 select-none","aria-hidden":"true",children:"/"}),t.jsx(MT,{label:A,disabled:O,isOpen:N,onClick:()=>{C(W=>!W),S(!1)},buttonRef:P}),N&&m&&t.jsx(AT,{currentScenario:m,scenarioGroups:g,onSelect:x,onCreateNew:b,onClose:()=>C(!1),triggerRef:P})]})})]}),t.jsxs("div",{"data-testid":"preview-device-group",className:"relative flex items-center h-7 gap-2 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-0.5 p-0.5 rounded-lg border border-white/10",children:[e.map(W=>t.jsx(IT,{viewport:W,isActive:!d&&n===W.name,onSelect:()=>{d&&u(),s(W.name)}},W.name)),t.jsx(vT,{isFilled:d,onToggle:u})]}),t.jsxs("div",{"data-testid":"preview-size-field",className:"flex items-center text-[11px] font-mono text-gray-500",children:[t.jsx(Pc,{bare:!0,label:"W",value:R,disabled:d,onCommit:W=>f(W,a)}),t.jsx("span",{"aria-hidden":"true",children:"×"}),t.jsx(Pc,{bare:!0,label:"H",value:I,disabled:d,onCommit:W=>f(r,W)})]}),t.jsx("span",{className:"w-px h-4 bg-white/10 shrink-0","aria-hidden":"true"}),t.jsxs("div",{className:"flex items-center",children:[t.jsx(wT,{}),t.jsx(jT,{previewUrl:o})]})]})]}),t.jsx("div",{className:"shrink-0 flex items-center gap-2",children:j?t.jsx("button",{type:"button",onClick:j,className:"h-7 px-3 rounded text-xs font-medium uppercase tracking-wide whitespace-nowrap text-black hover:opacity-90",style:{background:"var(--lime-300)"},children:"Plan a change to this screen"}):null})]})}const Yae=Object.freeze(Object.defineProperty({__proto__:null,NavigationBar:DT},Symbol.toStringTag,{value:"Module"}));function LT(){return t.jsxs("div",{style:{padding:"3rem 1rem",textAlign:"center",color:"var(--text-muted)"},children:[t.jsx("h2",{style:{fontSize:"1.125rem",fontWeight:600,color:"var(--text-secondary)",margin:"0 0 0.5rem 0"},children:"No plan loaded"}),t.jsx("p",{style:{margin:0,fontSize:"0.875rem"},children:"Ask the AI to draft a plan, or pick one from the Plan tab."})]})}const Gae=Object.freeze(Object.defineProperty({__proto__:null,PlanPreviewEmptyState:LT},Symbol.toStringTag,{value:"Module"}));function FT({title:e}){return t.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:e})}const Vae=Object.freeze(Object.defineProperty({__proto__:null,PlanPreviewHeader:FT},Symbol.toStringTag,{value:"Module"})),Hm={prompt:null,title:null};function $T(){const[e,n]=l.useState(Hm),[s,r]=l.useState(!0);return l.useEffect(()=>{let a=!1;return(async()=>{try{const i=await(await fetch("/api/prompt")).json();a||n({prompt:i.prompt??null,title:i.title??null})}catch{a||n(Hm)}finally{a||r(!1)}})(),()=>{a=!0}},[]),{...e,loading:s}}function zT(){const{prompt:e,title:n,loading:s}=$T();return t.jsx("div",{className:"flex-1 flex flex-col min-w-0 overflow-auto",style:{background:"var(--bg-deep)"},children:t.jsx("div",{style:{padding:"1.5rem 2rem",maxWidth:"880px",width:"100%",margin:"0 auto"},children:s?null:e?t.jsxs(t.Fragment,{children:[n?t.jsx(FT,{title:n}):null,t.jsx(Ft,{children:e})]}):t.jsx(LT,{})})})}const Kae=Object.freeze(Object.defineProperty({__proto__:null,PlanPreviewPanelView:zT},Symbol.toStringTag,{value:"Module"}));function BT({message:e}){return t.jsx("span",{style:{color:"var(--text-dim)"},children:e})}const Jae=Object.freeze(Object.defineProperty({__proto__:null,PreviewEmptyState:BT},Symbol.toStringTag,{value:"Module"}));function WT({hasDevServerConfigured:e}){const n=e?"Starting your app…":"Your app will display here once set up";return t.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:t.jsx("span",{children:n})})}const Xae=Object.freeze(Object.defineProperty({__proto__:null,PreviewWaitingPlaceholder:WT},Symbol.toStringTag,{value:"Module"}));function HT(e,n,s){const r=[e];return n&&r.push(`reload:${n}`),s&&r.push(`command:${s}`),r.join("::")}function qT({currentWidth:e,currentHeight:n,isFilled:s,scale:r}){const a=t.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:t.jsxs("div",{className:"text-sm leading-relaxed",children:[t.jsx("div",{className:"font-medium",children:"Live Preview unavailable"}),t.jsxs("div",{className:"opacity-70 mt-1",children:[e,"×",n]})]})});return s?a:t.jsx($r,{width:e,height:n,scale:r,children:a})}const UT=l.forwardRef(function({currentHeight:n,currentWidth:s,isFilled:r,previewUrl:a,scale:o,reloadNonce:i,commandNonce:c,iframeKey:d,onLoad:u,onError:p},h){if(en())return t.jsx(qT,{currentWidth:s,currentHeight:n,isFilled:r,scale:o});const f=d??HT(a,i,c),m=()=>{p&&p("iframe error event")};return t.jsx($r,{width:s,height:n,scale:o,filled:r,children:t.jsx("iframe",{ref:h,src:a,name:rR,title:"Live Preview",style:{width:"100%",height:"100%",border:"none",background:"var(--bg-deep)"},onLoad:u,onError:m},f)})}),Qae=Object.freeze(Object.defineProperty({__proto__:null,EmbeddedPreviewPlaceholder:qT,PreviewFrame:UT},Symbol.toStringTag,{value:"Module"}));function YT({label:e="Loading preview..."}={}){return t.jsxs("div",{role:"status","aria-live":"polite",className:"pointer-events-none absolute inset-0 flex flex-col items-center justify-center gap-3 bg-[var(--bg-deep)]/80 backdrop-blur-sm text-[var(--text-muted)]",children:[t.jsx("div",{className:"w-10 h-10 border-4 border-primary/20 border-t-primary rounded-full animate-spin"}),t.jsx("span",{className:"text-sm",children:e})]})}const Zae=Object.freeze(Object.defineProperty({__proto__:null,PreviewLoadingSpinner:YT},Symbol.toStringTag,{value:"Module"}));function $7(e){var n,s;try{const r=(s=(n=e==null?void 0:e.contentWindow)==null?void 0:n.location)==null?void 0:s.href;return typeof r=="string"?r:null}catch{return null}}function z7(e,n){if(!n||!e||e==="about:blank")return null;let s;try{s=new URL(e,window.location.origin).pathname}catch{return null}return s===os||s.startsWith(`${os}/`)?null:s}function B7(e){return{type:"error",message:`The app navigated to "${e}", which is outside the Live Preview (everything the preview serves lives under ${os}). That path is served by the editor, so the frame would have rendered codeyam-editor instead of your app. The preview was stopped rather than showing you the wrong application.`,filename:e,lineno:null,colno:null,stack:[`Frame navigated to: ${e}`,`Expected to stay under: ${os}`,"",`Why this happens: the Live Preview is served from the same-origin ${os} subpath. A root-absolute navigation (an <a href="/…">, a form action, a location.href assignment, or an upstream redirect) leaves that subpath, so the request is answered by the editor rather than your app.`,"","Fix: if this app routes on the client, set `sameOriginSafe: false` in .codeyam/stack.json so the preview runs on its own dedicated origin."].join(`
|
|
303
|
+
`),timestampMs:Date.now(),dedupeKey:`preview-escape:${e}`,count:1}}function W7({previewUrl:e,resetKey:n,capturedErrors:s}){const[r,a]=l.useState(null),o=e.startsWith(os);l.useEffect(()=>{a(null)},[n,e]);const i=l.useCallback(u=>{const p=$7(u),h=z7(p,o);return a(h),h!==null&&PW(h),p},[o]),c=l.useCallback(()=>a(null),[]),d=l.useMemo(()=>r?[...s,B7(r)]:s,[s,r]);return{escaped:r!==null,overlayErrors:d,noteFrameLoad:i,clearEscape:c}}function H7(e){return!(e instanceof HTMLElement)||e===document.body||e===document.documentElement||!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e.isContentEditable)?!1:e.disabled!==!0}function q7(e,n){if(n!==null&&document.activeElement===n)return;const s=e!==null&&document.activeElement===e;if(!(!s&&!sc())){if(n===null){if(s)return;vr(),_t();return}if(vr(),s&&ac(e),!document.contains(n)){_t();return}requestAnimationFrame(()=>{n.focus({preventScroll:!0})})}}function U7(e){const n=l.useRef(null),s=l.useRef(null),r=l.useRef(null);return l.useEffect(()=>{function o(){const c=document.activeElement;if(!H7(c))return;const d=e.current;d!==null&&(c===d||d.contains(c))||(n.current=c)}function i(c){const d=e.current;if(d===null)return;if(c.target===d){n.current=null;return}const u=d.getBoundingClientRect();rc(c.clientX,c.clientY,u,1)&&(n.current=null)}return document.addEventListener("focusin",o),document.addEventListener("pointerdown",i,!0),()=>{document.removeEventListener("focusin",o),document.removeEventListener("pointerdown",i,!0)}},[e]),l.useEffect(()=>()=>{s.current!==null&&cancelAnimationFrame(s.current),r.current!==null&&clearTimeout(r.current)},[]),{notePreviewLoaded:l.useCallback(()=>{s.current!==null&&cancelAnimationFrame(s.current),r.current!==null&&clearTimeout(r.current);const o=()=>{q7(e.current,n.current)};s.current=requestAnimationFrame(()=>{s.current=null,o()}),r.current=setTimeout(()=>{r.current=null,o()},50)},[e])}}function Y7(e,n){const s=l.useRef(!1);l.useEffect(()=>{s.current||e&&e.startCommand&&(e.intendedRunning||e.status==="stopped"&&(s.current=!0,n()))},[e,n])}function G7(e,n){const[s,r]=l.useState(!1),a=l.useCallback(()=>{s?(r(!1),e.deactivate(),e.clearSelection()):(r(!0),e.activate())},[s,e]);return l.useEffect(()=>{s&&(r(!1),e.clearSelection())},[n]),{isActive:s,toggle:a}}function V7(e,n=!0,s="running"){const r=l.useRef(null),a=l.useRef(!1),[o,i]=l.useState(0),c=l.useRef(null);l.useEffect(()=>{e!=null&&(r.current!=null&&e!==r.current?(a.current=!1,i(p=>p+1)):r.current==null&&(a.current?n&&_m(e,c.current):i(p=>p+1)),r.current=e)},[e,n]);const d=l.useCallback(p=>{a.current=!0,p&&(c.current=p),n&&e!=null&&_m(e,p??c.current)},[e,n]),u=l.useCallback(p=>{n&&kW(p)},[n]);return{reloadNonce:o,handleIframeLoad:d,handleIframeError:u}}const K7=1500,J7=2e3,X7=3e3,Q7=2;function Z7(){return typeof window>"u"?!1:window.location.pathname.startsWith("/scenario/")?!0:en()}function e9(e,n=!1){const s=Z7(),[r,a]=l.useState(s?!0:null),[o,i]=l.useState(null),[c,d]=l.useState(0),[u,p]=l.useState(0),h=l.useRef(null),f=l.useRef(null),m=l.useRef(null),g=l.useRef(!1),x=l.useRef(e),b=l.useRef(n);l.useEffect(()=>{x.current=e},[e]),l.useEffect(()=>{b.current=n},[n]);const y=l.useCallback(()=>{f.current!=null&&(clearTimeout(f.current),f.current=null)},[]),v=l.useCallback(async()=>{if(g.current||b.current)return;const k=x.current;if(!k)return;m.current&&m.current.abort();const S=new AbortController;m.current=S;const N=setTimeout(()=>S.abort(),X7);let C=!1;try{await fetch(k,{mode:"no-cors",cache:"no-store",signal:S.signal}),C=!0}catch{C=!1}finally{clearTimeout(N)}if(!g.current){if(i(Date.now()),C){if(d(0),h.current!==!0){const T=h.current===!1;h.current=!0,a(!0),T&&p(P=>P+1)}}else d(T=>{const P=T+1;return P>=Q7&&h.current!==!1&&(h.current=!1,a(!1)),P});j()}},[]),j=l.useCallback(()=>{if(g.current)return;y();const k=h.current===!0?J7:K7;f.current=setTimeout(()=>{f.current=null,v()},k)},[y,v]),_=l.useCallback(()=>{y(),v()},[y,v]);l.useEffect(()=>{if(!s)return g.current=!1,v(),()=>{g.current=!0,y(),m.current&&(m.current.abort(),m.current=null)}},[v,y,s]),l.useEffect(()=>{s||v()},[e,v,s]);const w=l.useRef(n);return l.useEffect(()=>{if(s)return;const k=w.current;w.current=n,k&&!n&&v()},[n,v,s]),{healthy:r,lastProbeAt:o,failedProbeCount:c,reloadNonce:u,invalidate:_}}const qm={loaded:!1,stalledRequests:0,fastRequests:0,longestStallMs:0,tailReadFailedReason:null};function t9(e){const{active:n,trigger:s}=e,[r,a]=l.useState(qm),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 h=(u.stalls??[]).reduce((f,m)=>Math.max(f,m.durationMs??0),0);a({loaded:!0,stalledRequests:u.stalledRequests??0,fastRequests:u.fastRequests??0,longestStallMs:h,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(!n){a(qm),(c=o.current)==null||c.abort();return}return i(),()=>{var d;(d=o.current)==null||d.abort()}},[n,s,i]),r}function n9(e){return!e||!e.loaded||e.tailReadFailedReason?null:e.stalledRequests>0?`Recent requests took up to ${Math.max(1,Math.round(e.longestStallMs/1e3))}s — the dev server is responding, just slowly. Check the dev-server log for what's blocking the render.`:e.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 s9({liveIframeHealthy:e,previewReachable:n}){return e===!0||n===!0}function r9({hasDevServerConfigured:e,hasServed:n}){return!e||n}const a9=2e3;function o9(e,n){const[s,r]=l.useState(0),a=l.useRef(e),o=l.useRef(n),i=l.useRef(0);return l.useEffect(()=>{const c=a.current,d=o.current;if(a.current=e,o.current=n,!(n===!1)||!(e===!0)||!(c===!1&&e===!0)&&!(d===!0&&n===!1))return;const m=Date.now();m-i.current<a9||(i.current=m,r(g=>g+1))},[e,n]),s}const ma={windowMs:1e4,threshold:4,ringBufferSize:16};function i9({pidNonce:e,probeNonce:n,draftNonce:s,windowMs:r=ma.windowMs,threshold:a=ma.threshold}){const[o,i]=l.useState(!1),[c,d]=l.useState([]),[u,p]=l.useState(0),h=l.useRef(!1),f=l.useRef(e),m=l.useRef(n),g=l.useRef(s),x=l.useCallback(y=>{const v=Date.now(),j=v-r;let _=[];d(k=>{const S=k.filter(N=>N.timestampMs>=j);return S.push({reason:y,timestampMs:v}),S.length>ma.ringBufferSize&&S.splice(0,S.length-ma.ringBufferSize),_=S,S});const w=_.filter(k=>k.timestampMs>=j).length;if(!h.current&&w>=a){h.current=!0,i(!0);return}h.current||p(k=>k+1)},[r,a]);l.useEffect(()=>{e!==f.current&&(f.current=e,x("pid"))},[e,x]),l.useEffect(()=>{n!==m.current&&(m.current=n,x("probe"))},[n,x]),l.useEffect(()=>{s!==g.current&&(g.current=s,x("draft"))},[s,x]);const b=l.useCallback(()=>{h.current=!1,i(!1),d([]),p(y=>y+1)},[]);return{tripped:o,recentReloads:c,gatedNonce:u,reset:b}}function l9(e,n,s=Jc){const r=l.useRef(void 0);l.useEffect(()=>{if(!n){r.current=e;return}if(typeof e=="number"){if(r.current===void 0){r.current=e;return}e>r.current&&(r.current=e,s())}},[e,n,s])}const Um=20,c9="codeyam-error-capture";function d9(e,n=0){const[s,r]=l.useState([]),a=l.useCallback(()=>r([]),[]);return l.useEffect(()=>{r([])},[n]),l.useEffect(()=>{function o(i){const c=i.data;if(!c||c.source!==c9)return;const d=e.current;if(d&&i.source!==d.contentWindow)return;const u=c.payload;!u||typeof u!="object"||!u.dedupeKey||r(p=>{const h=p.findIndex(m=>m.dedupeKey===u.dedupeKey);if(h>=0){const m=p.slice();return m[h]={...m[h],count:m[h].count+1,timestampMs:u.timestampMs},m}const f=[...p,{...u,count:1}];return f.length>Um?f.slice(f.length-Um):f})}return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},[e]),{errors:s,clear:a}}const Gi=[500,1e3,2e3];async function u9(e){try{const s=await(await fetch(`/api/probe-url?url=${encodeURIComponent(e)}`)).json();return{status:typeof(s==null?void 0:s.status)=="number"?s.status:null}}catch{return{status:null}}}async function p9(){try{const n=await(await fetch("/api/dev-server-log/slice?lines=40")).json();return Array.isArray(n==null?void 0:n.lines)?n.lines:[]}catch{return[]}}function h9(e,n){const[s,r]=l.useState({status:null,clickThroughBroken:!1,logLines:[],loading:!1});return l.useEffect(()=>{if(!e){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+Gi.length;let i=null;for(let d=0;d<o;d++){if(a)return;const{status:u}=await u9(e);if(a)return;if(i=u,u===null||u<500){r({status:u,clickThroughBroken:!1,logLines:[],loading:!1});return}d<Gi.length&&await new Promise(p=>setTimeout(p,Gi[d]))}const c=await p9();a||r({status:i,clickThroughBroken:!0,logLines:c,loading:!1})})(),()=>{a=!0}},[e,n]),s}function GT({url:e,status:n,logLines:s,onRetry:r}){return t.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:t.jsxs("div",{className:"max-w-2xl w-full rounded-md border border-red-700 bg-zinc-900 text-zinc-100 shadow-xl",children:[t.jsxs("div",{className:"px-5 py-4 border-b border-red-800 flex justify-between items-start",children:[t.jsxs("div",{className:"flex-1 min-w-0 pr-4",children:[t.jsxs("div",{className:"text-sm font-semibold text-red-300",children:["Scenario render failed (HTTP ",n,")"]}),t.jsx("div",{className:"mt-1 text-xs text-zinc-400 break-all",children:e}),t.jsx("div",{className:"mt-2 text-xs text-zinc-300",children:"The preview URL returned a server error. This is a bug — capture and click should always agree. Check the log below, and refresh once the underlying error is fixed."})]}),t.jsxs("div",{className:"flex-shrink-0 flex items-start gap-2",children:[t.jsx(ct,{variant:"subtle",text:`Scenario render failed (HTTP ${n})
|
|
304
|
+
${e}
|
|
305
|
+
|
|
306
|
+
${s.join(`
|
|
307
|
+
`)}`,label:"Copy",className:"px-2.5 py-1 text-xs rounded border border-gray-600 bg-gray-800 text-gray-200 hover:bg-gray-700 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed"}),t.jsx("button",{type:"button",onClick:r,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"})]})]}),t.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:s.length>0?s.join(`
|
|
308
|
+
`):t.jsxs("span",{className:"text-zinc-500 italic",children:["No dev-server log lines available — see"," ",t.jsx("code",{children:".codeyam/logs/dev-server.log"}),"."]})})]})})}const eoe=Object.freeze(Object.defineProperty({__proto__:null,IframeClickThroughErrorCard:GT},Symbol.toStringTag,{value:"Module"}));function f9(e){if(e===null||!e.startCommand)return{isRestarting:!1,isFailed:!1,isStarting:!1,isStopped:!1};const n=e.status==="failed",s=!n&&e.status!=="running"&&e.intendedRunning&&(e.restartCount??0)>0,r=!n&&e.intendedRunning&&e.status!=="running"&&(e.restartCount??0)===0,a=e.status==="stopped"&&!e.intendedRunning;return{isRestarting:s,isFailed:n,isStarting:r,isStopped:a}}const m9=20;function g9(e){const{hasDevServerConfigured:n,probeHealthy:s,backendIframeHealthy:r,isStarting:a,isRestarting:o,isFailed:i,isStopped:c,isPrePrototype:d,withinStartupGrace:u,previewReachable:p,hasEverServed:h}=e;return n?i?"crashed":r===!0||p===!0||s===!0&&r!==!1?null:d?"scaffolding":c?h?"stopped":null:o?"restarting":a||u||!h?null:s===!1?"reconnecting":r===!1&&s===!0?"disconnected":s===null?"probing":"reconnecting":null}function x9(e){return e===null||e.status!=="running"?!1:e.liveIframeHealthy!==!1}const b9=5,y9=3;function v9(e,n){return e===null||e<=0?!1:e<=(n==="backend"?y9:b9)}const Ym="Setting up your project",Gm="Preparing your project — the preview will appear once it's ready.",j9={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."},w9={1:"Aligning on the plan with you.",2:"Aligning on the plan with you.",3:"Preparing the project environment."};function _9(e,n){return e===null?{title:Ym,body:Gm}:{title:Ym,body:(n==="backend"?w9:j9)[e]??Gm}}const S9={probing:{title:"Checking the Live Preview",body:"Making sure your app is responding before showing it.",spinner:!0,stuckTitle:"Your app isn't responding",stuckBody:"The preview couldn't reach it. Trying again usually brings it back.",nextAction:"Use Retry now. If the check keeps failing, copy this report — your app's own startup output will say why it isn't answering."},starting:{title:"Starting your app",body:"Waiting for your app's server to come up…",spinner:!0,stuckTitle:"Your app hasn't started",stuckBody:"Its server never came up. Trying again usually gets it going.",nextAction:"Use Retry now. If it never starts, copy this report and check your app's startup output for the reason."},restarting:{title:"Restarting your app",body:"Your app's server stopped unexpectedly. CodeYam is bringing it back automatically…",spinner:!0,stuckTitle:"Your app didn't come back",stuckBody:"It stopped and hasn't restarted yet. Trying again usually brings it back.",nextAction:"Use Retry now. If it keeps stopping, copy this report — the cause is in your app's own startup output."},reconnecting:{title:"Reconnecting to your app",body:"Waiting for your app's server to respond…",spinner:!0,stuckTitle:"Your app isn't responding",stuckBody:"Its server stopped answering. Trying again usually brings it back.",nextAction:"Use Retry now. If it stays unreachable, copy this report and check whether your app's server is still running."},disconnected:{title:"The preview lost its connection",body:"Your app's server is running fine. This preview just came unstuck from it after a restart, so it's showing nothing rather than something stale.",spinner:!1,nextAction:"Use Reload preview. There's no need to restart your app — it never stopped."},stopped:{title:"Your app isn't running",body:"Starting it automatically…",spinner:!1,stuckBody:"It didn't start on its own. Trying again usually gets it going.",nextAction:"Use Retry now. If it doesn't come up, copy this report and check your app's startup output."},crashed:{title:"Your app keeps stopping",body:"CodeYam has restarted it several times and it isn't staying up. This is something in the app itself rather than in the editor.",spinner:!1,nextAction:"Use Retry now to try once more. If it stops again, copy this report — the reason will be in your app's own startup output."},scaffolding:{title:"Setting up your project",body:"Preparing your project — the preview appears once it's ready.",spinner:!0,nextAction:"Nothing yet — setup finishes on its own. If it hasn't after a few minutes, copy this report."}};function VT({variant:e,restartCount:n=0,showRetry:s=!1,onRetry:r,bodyOverride:a}){const{title:o,body:i,spinner:c,nextAction:d,stuckTitle:u,stuckBody:p}=S9[e],h=a??i,f=e==="disconnected",m=f||e==="crashed"||s,g=f?"Reload preview":"Try again",{phase:x,attempts:b,retry:y}=Bc(r??(()=>{}));return m?t.jsx(wx,{variant:e,title:u??o,body:a??p??h,nextAction:d,actionLabel:g,onAction:r?y:void 0,pending:x==="pending",feedback:x==="unchanged"?t.jsxs("span",{"data-testid":"preview-unhealthy-overlay-unchanged",children:["Checked just now, the preview still isn’t back",b>1?` (${b} tries)`:"","."]}):null}):t.jsx(Iy,{title:o,body:h,spinner:c,restartCount:n,variant:e})}const toe=Object.freeze(Object.defineProperty({__proto__:null,PreviewUnhealthyOverlay:VT},Symbol.toStringTag,{value:"Module"}));function k9(e){return e.slice().reverse().map(n=>{const s=n.filename!=null?`
|
|
309
|
+
at ${n.filename}${n.lineno!=null?`:${n.lineno}`:""}${n.colno!=null?`:${n.colno}`:""}`:"",r=n.stack?`
|
|
310
|
+
${n.stack}`:"",a=n.count>1?` (×${n.count})`:"";return`[${n.type}]${a} ${n.message}${s}${r}`}).join(`
|
|
311
|
+
|
|
312
|
+
`)}function N9(e){if(e.length===0)return"no reloads recorded";const n={};for(const s of e)n[s.reason]=(n[s.reason]??0)+1;return Object.entries(n).map(([s,r])=>`${s}×${r}`).join(", ")}function KT({count:e,onExpand:n,onClear:s}){const r=`${e} ${e===1?"Error":"Errors"}`;return t.jsx("div",{"data-testid":"preview-error-badge",className:"absolute bottom-3 right-3 z-50 pointer-events-auto",children:t.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:[t.jsxs("button",{type:"button",onClick:n,"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:[t.jsx("span",{"aria-hidden":"true",className:"inline-block h-1.5 w-1.5 rounded-full bg-red-600"}),t.jsx("span",{children:r}),t.jsx("span",{"aria-hidden":"true",className:"text-gray-400",children:"›"})]}),t.jsx("button",{type:"button",onClick:s,"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 noe=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorBadge:KT},Symbol.toStringTag,{value:"Module"}));function JT({headline:e,tripped:n,onClear:s,closeAriaLabel:r="Dismiss errors",providerLabel:a}){return t.jsxs("div",{className:"flex items-start justify-between gap-3 px-4 py-3 border-b border-red-200 dark:border-red-900",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-sm font-semibold text-red-700 dark:text-red-300",children:e}),t.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:n?"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 ${a}.`})]}),t.jsx("button",{type:"button",onClick:s,className:"cursor-pointer text-xs text-gray-400 hover:text-gray-600 dark:hover:text-gray-200","aria-label":r,children:"✕"})]})}const soe=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorOverlayHeader:JT},Symbol.toStringTag,{value:"Module"}));function C9(e){const n=e.filename?`${e.filename}${e.lineno!=null?`:${e.lineno}`:""}${e.colno!=null?`:${e.colno}`:""}`:"";return[`${e.type}: ${e.message}`,n,e.stack??""].filter(Boolean).join(`
|
|
313
|
+
`)}function XT({error:e,expanded:n,onToggle:s}){return t.jsxs("li",{className:"rounded border border-red-200 dark:border-red-900 bg-red-50/60 dark:bg-red-950/30",children:[t.jsxs("div",{className:"flex items-start",children:[t.jsxs("button",{type:"button",onClick:s,className:"flex-1 min-w-0 flex items-start gap-2 text-left px-2 py-1.5 hover:bg-red-100/60 dark:hover:bg-red-900/30",children:[t.jsx("span",{className:"mt-0.5 text-red-500","aria-hidden":"true",children:n?"▾":"▸"}),t.jsxs("span",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"font-mono text-[10px] uppercase tracking-wide text-red-500 dark:text-red-400 mr-2",children:e.type}),t.jsx("span",{className:"text-gray-900 dark:text-gray-100 break-words",children:e.message}),e.count>1&&t.jsxs("span",{className:"ml-2 text-gray-500",children:["×",e.count]}),e.filename&&t.jsxs("span",{className:"block text-[11px] text-gray-500 mt-0.5 truncate",children:[e.filename,e.lineno!=null?`:${e.lineno}`:"",e.colno!=null?`:${e.colno}`:""]})]})]}),t.jsx("div",{className:"shrink-0 px-1.5 py-1.5",children:t.jsx(ct,{variant:"icon",text:C9(e)})})]}),n&&e.stack&&t.jsx("pre",{className:"px-3 pb-2 text-[11px] font-mono text-gray-700 dark:text-gray-300 whitespace-pre-wrap break-words",children:e.stack})]})}const roe=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorRow:XT},Symbol.toStringTag,{value:"Module"}));function QT({errors:e,emptyHint:n}){const[s,r]=l.useState(null);return e.length===0?t.jsx("ul",{className:"flex-1 overflow-auto px-2 py-2 space-y-1 text-xs",children:t.jsx("li",{className:"text-gray-500 px-2 py-3",children:n??"No runtime errors captured yet."})}):t.jsx("ul",{className:"flex-1 overflow-auto px-2 py-2 space-y-1 text-xs",children:e.slice().reverse().map(a=>t.jsx(XT,{error:a,expanded:s===a.dedupeKey,onToggle:()=>r(s===a.dedupeKey?null:a.dedupeKey)},a.dedupeKey))})}const aoe=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorList:QT},Symbol.toStringTag,{value:"Module"}));function ZT({canCopy:e,reasonsSummary:n,copyState:s,onCopy:r,onCopyForAgent:a,onRetry:o,providerLabel:i}){return t.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:[t.jsx("button",{type:"button",onClick:r,disabled:!e,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"}),t.jsxs("button",{type:"button",onClick:a,disabled:!e,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 ",i]}),t.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"}),t.jsxs("span",{className:"ml-auto text-[11px] text-gray-500",children:["Reloads in last 10s: ",n,s==="copied"&&t.jsx("span",{className:"ml-2 text-emerald-600",children:"copied ✓"}),s==="failed"&&t.jsx("span",{className:"ml-2 text-red-500",children:"copy blocked"})]})]})}const ooe=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorOverlayFooter:ZT},Symbol.toStringTag,{value:"Module"})),T9=`Fix this error in the live preview. Here is what the captured runtime error reported:
|
|
314
|
+
|
|
315
|
+
`;function e5({tripped:e,errors:n,recentReloads:s,serverHealthy:r,onRetry:a,onClear:o,providerLabel:i}){const[c,d]=l.useState("idle"),[u,p]=l.useState(!0),h=l.useMemo(()=>k9(n),[n]),f=l.useMemo(()=>N9(s),[s]);if(l.useEffect(()=>{n.length===0&&p(!0)},[n.length]),!e&&n.length===0)return null;const m=r&&!e,g=m&&u&&n.length>0,x=e?`Live Preview paused — ${n.length} error${n.length===1?"":"s"} captured`:`${n.length} runtime error${n.length===1?"":"s"} captured`;async function b(y){const v=await _E(y+h);d(v?"copied":"failed"),setTimeout(()=>d("idle"),1500)}return g?t.jsx("div",{"data-testid":"preview-error-overlay","data-tripped":"false","data-collapsed":"true",className:"absolute inset-0 z-50 pointer-events-none",children:t.jsx(KT,{count:n.length,onExpand:()=>p(!1),onClear:o})}):t.jsx("div",{"data-testid":"preview-error-overlay","data-tripped":e?"true":"false","data-collapsed":"false",className:"absolute inset-0 z-50 flex flex-col items-stretch p-4 pointer-events-none",children:t.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:[t.jsx(JT,{headline:x,tripped:e,onClear:m?()=>p(!0):o,closeAriaLabel:m?"Minimize errors":"Dismiss errors",providerLabel:i}),t.jsx(QT,{errors:n,emptyHint:e?`Breaker tripped before any runtime error was reported. Reasons in window: ${f}.`:null}),t.jsx(ZT,{canCopy:n.length>0,reasonsSummary:f,copyState:c,onCopy:()=>b(""),onCopyForAgent:()=>b(T9),onRetry:a,providerLabel:i})]})})}const ioe=Object.freeze(Object.defineProperty({__proto__:null,PreviewErrorOverlay:e5},Symbol.toStringTag,{value:"Module"}));function P9(e){if(!e)return null;const n=Object.entries(e).map(([s,r])=>`${s}=${typeof r=="string"?r:JSON.stringify(r)}`);return n.length>0?n.join(", "):null}function t5({previewUrl:e,description:n,demonstratesState:s}){const r=l.useMemo(()=>{try{return new URL(e,window.location.origin).searchParams.get("_codeyam_scenario")}catch{return null}},[e]),a=l.useMemo(()=>P9(s),[s]);if(!r)return null;const o=n!=null&&n.trim()?n.trim():null;return!o&&!a?null:t.jsxs("div",{className:"absolute top-2 left-2 z-30 flex flex-col gap-0.5 max-w-[16rem] px-2 py-1 rounded bg-black/60 backdrop-blur-sm border border-white/10 shadow-lg pointer-events-none select-none",children:[o?t.jsx("span",{className:"text-[10px] text-white/70 leading-snug whitespace-pre-line",children:o}):null,a?t.jsx("span",{className:"text-[9px] font-mono text-white/50 tracking-wide",children:a}):null]})}const loe=Object.freeze(Object.defineProperty({__proto__:null,ActiveScenarioOverlay:t5},Symbol.toStringTag,{value:"Module"}));function n5(){return t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-800",children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("div",{className:"w-2 h-2 rounded-full bg-red-500 animate-pulse"}),t.jsx("h3",{className:"text-sm font-bold text-gray-900 dark:text-gray-100 uppercase tracking-tight",children:"Dev Server Crash Recovery Failed"})]}),t.jsx("div",{className:"text-[10px] text-gray-500 dark:text-gray-400 font-medium",children:"LAST 50 LOG LINES"})]})}const coe=Object.freeze(Object.defineProperty({__proto__:null,CrashLogHeader:n5},Symbol.toStringTag,{value:"Module"}));function s5({logs:e}){return t.jsx("div",{className:"flex-1 bg-black p-4 font-mono text-[11px] leading-relaxed overflow-y-auto text-gray-300",children:e.length>0?e.map((n,s)=>t.jsx("div",{className:"whitespace-pre-wrap break-all border-l-2 border-gray-800 pl-3 mb-1",children:n},s)):t.jsx("div",{className:"italic text-gray-600",children:"No logs captured..."})})}const doe=Object.freeze(Object.defineProperty({__proto__:null,CrashLogViewer:s5},Symbol.toStringTag,{value:"Module"}));function r5({providerLabel:e}){return t.jsxs("div",{className:"flex-1",children:[t.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."}),t.jsxs("p",{className:"text-xs text-red-700/80 dark:text-red-400/80",children:["Copy the logs and share them with ",e," to investigate the underlying bug."]})]})}const uoe=Object.freeze(Object.defineProperty({__proto__:null,CrashLogFooterMessage:r5},Symbol.toStringTag,{value:"Module"}));function a5({logs:e,copyWriter:n,providerLabel:s}){return t.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-950/30 border-t border-red-100 dark:border-red-900/50",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsx(r5,{providerLabel:s}),t.jsx(ct,{text:e.join(`
|
|
316
|
+
`),label:"Copy logs",writer:n})]})})}const poe=Object.freeze(Object.defineProperty({__proto__:null,CrashLogFooter:a5},Symbol.toStringTag,{value:"Module"}));function o5({logs:e,providerLabel:n}){return t.jsxs("div",{className:"absolute inset-0 bg-white dark:bg-gray-900 flex flex-col z-[60] overflow-hidden",children:[t.jsx(n5,{}),t.jsx(s5,{logs:e}),t.jsx(a5,{logs:e,providerLabel:n})]})}const hoe=Object.freeze(Object.defineProperty({__proto__:null,DevServerCrashLog:o5},Symbol.toStringTag,{value:"Module"})),Vm=20;function O9(e){if(!e)return null;try{return new Date(e).toLocaleTimeString()}catch{return null}}function i5({lastError:e,failureCount:n,failedAtMs:s,holder:r,onRetry:a,onReap:o}){const[i,c]=l.useState(!1),d=e.split(`
|
|
317
|
+
`),u=d.length>Vm,p=i||!u?d:d.slice(d.length-Vm),h=O9(s);return t.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:[t.jsxs("header",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:["Dev server failed to start after ",n," ",n===1?"attempt":"attempts"]}),h&&t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:["Last attempt: ",h]}),r&&t.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:[t.jsxs("div",{children:["Port ",t.jsx("span",{className:"font-semibold",children:r.port})," is held by:"]}),t.jsxs("div",{className:"mt-1 font-mono",children:["PID ",r.pid," — ",r.command]})]})]}),t.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",children:p.join(`
|
|
318
|
+
`)}),t.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?t.jsx("button",{type:"button",onClick:()=>c(f=>!f),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`}):t.jsx("span",{}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ct,{variant:"subtle",text:e,label:"Copy error",className:"shrink-0 px-3 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 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"}),r&&o&&t.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"}),t.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 foe=Object.freeze(Object.defineProperty({__proto__:null,DevServerFailedPanel:i5},Symbol.toStringTag,{value:"Module"}));function l5({diagnostic:e,onRetry:n}){const{expectedPort:s,actualPort:r,appName:a,currentStartCommand:o,remediation:i}=e;return t.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:[t.jsxs("header",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:"Dev server port conflict"}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:[a," bound port"," ",t.jsx("span",{className:"font-semibold",children:r}),", but the editor needs the app on port"," ",t.jsx("span",{className:"font-semibold",children:s})," so its reverse proxy (mocking, capture) can sit in front."]})]}),t.jsxs("div",{className:"flex-1 px-6 py-4 text-sm text-gray-800 dark:text-gray-200 space-y-3",children:[t.jsx("p",{children:i}),t.jsxs("div",{children:[t.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400 mb-1",children:"Current start command"}),t.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)"})]})]}),t.jsx("footer",{className:"px-6 py-3 border-t border-gray-200 dark:border-gray-700 flex items-center justify-end",children:t.jsx("button",{type:"button","data-testid":"preview-port-mismatch-retry",onClick:n,className:"px-4 py-1.5 text-sm font-medium rounded bg-blue-600 text-white hover:bg-blue-700",children:"Retry"})})]})}const moe=Object.freeze(Object.defineProperty({__proto__:null,PreviewPortMismatchCard:l5},Symbol.toStringTag,{value:"Module"})),Km=48,R9=100,E9=320,A9=192;function M9({containerHeight:e,containerWidth:n,viewportHeight:s,viewportWidth:r}){if(!(r!=null&&s!=null&&n!=null&&e!=null&&r>0&&s>0&&n>0&&e>0))return{width:E9,height:A9,hasViewport:!1};const o=n-Km*2,i=e-Km*2-R9,c=Math.min(1,o/r,i/s);return{width:Math.round(r*c),height:Math.round(s*c),hasViewport:!0}}function Ec({containerHeight:e,containerWidth:n,heading:s="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:p,hasViewport:h}=M9({containerWidth:n,containerHeight:e,viewportWidth:d,viewportHeight:c}),f={width:u,height:p,...h?{overflowY:"auto"}:{}};return t.jsxs("div",{"data-testid":"building-preview-overlay",className:"absolute inset-0 z-50 flex flex-col overflow-y-auto animate-in fade-in duration-300",style:{background:"rgba(20,20,20,.94)"},children:[t.jsx("button",{type:"button",onClick:r,"aria-label":"Close preview",title:"Close preview",className:"sticky top-3 z-10 ml-auto mr-3 mt-3 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-white/[0.14] bg-[#1e1e1e] text-[var(--text-secondary)] transition-colors hover:border-white/[0.3] hover:text-[var(--text-primary)]",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":"true",children:t.jsx("path",{d:"M4 4l8 8M12 4l-8 8"})})}),t.jsxs("div",{className:"my-auto flex flex-col items-center space-y-4 text-center p-6",children:[t.jsx("div",{className:"rounded-lg overflow-hidden border border-white/[0.1] shadow-md",style:f,children:t.jsx(kt,{screenshotPath:o??void 0,alt:a??"Scenario preview",className:h?"w-full h-auto":"max-w-full max-h-full object-contain"})}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("h3",{className:"text-[15px] font-semibold text-[var(--text-primary)]",children:s}),t.jsx("p",{className:"text-[13px] text-[var(--text-muted)]",children:i})]}),t.jsx("button",{type:"button",onClick:r,className:"rounded-lg border border-white/[0.14] px-4 py-1.5 text-[12.5px] text-[var(--text-secondary)] transition-colors hover:border-white/[0.3] hover:text-[var(--text-primary)]",children:"Dismiss"})]})]})}const goe=Object.freeze(Object.defineProperty({__proto__:null,BuildingPreviewOverlay:Ec},Symbol.toStringTag,{value:"Module"}));function c5({isActive:e,onToggle:n,interactionAvailable:s=!0}){return t.jsx("button",{onClick:s?n:void 0,disabled:!s,title:s?e?"Exit Debug Mode (resumes paused animations)":"Debug Mode — pauses animations while you inspect":"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:e?"2px solid var(--accent-blue)":"1px solid var(--border-default)",background:e?"var(--accent-blue)":"var(--bg-surface)",color:e?"#000":"var(--text-secondary)",cursor:s?"pointer":"not-allowed",display:"none",alignItems:"center",justifyContent:"center",opacity:s?e?1:.6:.35,transition:"all 0.15s ease",fontSize:18},onMouseEnter:r=>{s&&(r.currentTarget.style.opacity="1")},onMouseLeave:r=>{s&&(e||(r.currentTarget.style.opacity="0.6"))},children:e?"✕":"🔍"})}const xoe=Object.freeze(Object.defineProperty({__proto__:null,DebugModeButton:c5},Symbol.toStringTag,{value:"Module"}));function I9(){const[e,n]=l.useState(null),s=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){n({message:(c==null?void 0:c.error)??`HTTP ${i.status}`,command:(c==null?void 0:c.command)??null});return}n(null)}catch(i){n({message:i instanceof Error?i.message:String(i),command:null})}},[]),r=l.useCallback(()=>n(null),[]);return{openInEditor:s,lastError:e,clearError:r}}function d5({tag:e,id:n,className:s,text:r,detectionMethod:a,previewUrl:o}){return t.jsxs("div",{className:"flex-1 flex flex-col gap-3 min-w-0",children:[t.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:t.jsxs("div",{style:{color:"var(--text-secondary)",fontSize:12},children:[t.jsxs("div",{className:"text-center",style:{color:"var(--text-secondary)"},children:["Preview: ",o.split("/").pop()]}),t.jsxs("div",{className:"mt-2 p-3 rounded",style:{background:"var(--bg-surface)",border:"1px dashed var(--border-default)",fontSize:11,fontFamily:"monospace"},children:["<",e,n?` id="${n}"`:"",s?` class="${s.slice(0,40)}"`:"",">",t.jsx("br",{}),r.slice(0,60),r.length>60?"...":""]})]})}),t.jsxs("div",{style:{fontSize:11,color:"var(--text-secondary)"},children:["Detected via: ",a]})]})}const boe=Object.freeze(Object.defineProperty({__proto__:null,DebugModalElementPreview:d5},Symbol.toStringTag,{value:"Module"}));function u5({ancestors:e,onOpenInEditor:n}){return e.length===0?t.jsx("div",{style:{color:"var(--text-secondary)",fontSize:12,fontStyle:"italic"},children:"No component ancestry available."}):t.jsx("ul",{className:"flex flex-col gap-1",style:{listStyle:"none",padding:0,margin:0},children:e.map((s,r)=>{const a=s.sourceFile&&s.lineNumber?`${s.sourceFile}:${s.lineNumber}`:s.sourceFile??"(unknown source)",o=!!s.sourceFile;return t.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 rounded",style:{background:"var(--bg-deep)"},children:[t.jsx("span",{style:{color:"var(--text-primary)",fontWeight:600,fontSize:12},children:s.componentName??"<anonymous>"}),t.jsx("span",{style:{color:"var(--text-secondary)",fontFamily:"monospace",fontSize:11,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a}),o&&t.jsx("button",{onClick:()=>n(s.sourceFile,s.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"})]},`${s.componentName??"anon"}-${r}`)})})}const yoe=Object.freeze(Object.defineProperty({__proto__:null,DebugAncestryList:u5},Symbol.toStringTag,{value:"Module"}));function p5({ancestors:e,onOpenInEditor:n}){const[s,r]=l.useState(e.length>1);return e.length===0?null:t.jsxs("div",{className:"flex flex-col gap-1",children:[t.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:[s?"▾":"▸"," Component ancestry (",e.length,")"]}),s&&t.jsx(u5,{ancestors:e,onOpenInEditor:n})]})}const voe=Object.freeze(Object.defineProperty({__proto__:null,DebugAncestrySection:p5},Symbol.toStringTag,{value:"Module"}));function h5({propsNames:e}){if(e.length===0)return null;const n=()=>{var s;(s=navigator.clipboard)==null||s.writeText(e.join(", "))};return t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[t.jsx("span",{style:{color:"var(--text-secondary)",fontSize:12},children:"props:"}),e.map(s=>t.jsx("span",{onClick:n,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:s},s))]})}const joe=Object.freeze(Object.defineProperty({__proto__:null,DebugPropsChips:h5},Symbol.toStringTag,{value:"Module"}));function f5({componentDisplay:e,sourceDisplay:n,tag:s,id:r,boundingBox:a,feedback:o,onFeedbackChange:i,creating:c,hasComponentName:d,ancestors:u,propsNames:p,onOpenInEditor:h,onGoToIsolated:f,onCreatePlan:m,onClose:g}){const x=c||!o.trim();return t.jsxs("div",{className:"flex-1 flex flex-col gap-3 min-w-0",children:[t.jsx("h3",{style:{color:"var(--text-primary)",fontSize:16,fontWeight:600,margin:0},children:e}),n&&t.jsx("div",{className:"px-2 py-1 rounded",style:{background:"var(--bg-deep)",fontSize:12,fontFamily:"monospace",color:"var(--accent-blue)"},children:n}),t.jsxs("div",{className:"flex flex-col gap-1",style:{color:"var(--text-secondary)",fontSize:12},children:[t.jsxs("div",{children:["Element: <",s,">",r?` #${r}`:""]}),t.jsxs("div",{children:["Position: ",Math.round(a.x),", ",Math.round(a.y)," (",Math.round(a.width),"x",Math.round(a.height),")"]})]}),t.jsx(h5,{propsNames:p}),t.jsx(p5,{ancestors:u,onOpenInEditor:h}),t.jsx("textarea",{value:o,onChange:b=>i(b.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"}}),t.jsxs("div",{className:"flex gap-2",children:[d&&t.jsx("button",{onClick:f,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"}),t.jsx("button",{onClick:m,disabled:x,className:"px-3 py-1.5 rounded text-sm flex-1",style:{background:x?"var(--bg-deep)":"var(--accent-blue)",border:"none",color:x?"var(--text-secondary)":"#000",cursor:x?"not-allowed":"pointer",fontWeight:600},children:c?"Creating...":"Create Fix Plan"}),t.jsx("button",{onClick:g,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 woe=Object.freeze(Object.defineProperty({__proto__:null,DebugModalInfoPanel:f5},Symbol.toStringTag,{value:"Module"}));function m5({error:e,onDismiss:n}){return t.jsxs("div",{onClick:s=>s.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:[t.jsxs("div",{children:["Open in editor failed: ",e.message]}),e.command&&t.jsx("div",{style:{fontFamily:"monospace",fontSize:11,marginTop:4},children:e.command}),t.jsx("button",{onClick:n,className:"mt-1",style:{background:"transparent",border:"none",color:"var(--accent-blue)",cursor:"pointer",fontSize:11,padding:0},children:"Dismiss"})]})}const _oe=Object.freeze(Object.defineProperty({__proto__:null,OpenInEditorErrorToast:m5},Symbol.toStringTag,{value:"Module"}));function g5({element:e,previewUrl:n,onClose:s,onGoToIsolated:r,onCreatePlan:a}){const[o,i]=l.useState(""),[c,d]=l.useState(!1),{openInEditor:u,lastError:p,clearError:h}=I9(),f=async()=>{d(!0);try{await a(o,e)}finally{d(!1)}},m=e.componentName??`<${e.element.tag}>`,g=e.sourceFile?`${e.sourceFile}${e.lineNumber?`:${e.lineNumber}`:""}`:null;return t.jsxs("div",{className:"absolute inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0, 0, 0, 0.7)"},onClick:s,children:[t.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:x=>x.stopPropagation(),children:[t.jsx(d5,{tag:e.element.tag,id:e.element.id,className:e.element.className,text:e.element.text,detectionMethod:e.detectionMethod,previewUrl:n}),t.jsx(f5,{componentDisplay:m,sourceDisplay:g,tag:e.element.tag,id:e.element.id,boundingBox:e.element.boundingBox,feedback:o,onFeedbackChange:i,creating:c,hasComponentName:!!e.componentName,ancestors:e.ancestors,propsNames:e.propsNames,onOpenInEditor:u,onGoToIsolated:()=>r(e.componentName),onCreatePlan:f,onClose:s})]}),p&&t.jsx(m5,{error:p,onDismiss:h})]})}const Soe=Object.freeze(Object.defineProperty({__proto__:null,DebugModal:g5},Symbol.toStringTag,{value:"Module"}));function x5(){return t.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:"Animations paused while inspecting"})}const koe=Object.freeze(Object.defineProperty({__proto__:null,DebugFreezePill:x5},Symbol.toStringTag,{value:"Module"}));function b5({hoveredElement:e,frozen:n}){return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"absolute inset-0 z-40",style:{border:"3px solid var(--accent-blue)",cursor:"crosshair",pointerEvents:"none"}}),e&&t.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:e.componentName??`<${e.element.tag}>`}),n&&t.jsx(x5,{})]})}const Noe=Object.freeze(Object.defineProperty({__proto__:null,DebugOverlay:b5},Symbol.toStringTag,{value:"Module"}));function y5(){return t.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:t.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 Coe=Object.freeze(Object.defineProperty({__proto__:null,InspectModeRibbon:y5},Symbol.toStringTag,{value:"Module"}));function D9(e,n,s){const{width:r,maxHeight:a,gap:o}=s,i=e.y+e.height+o,c=i+a>n.height,d=c?Math.max(o,e.y-a-o):i,u=Math.max(o,Math.min(e.x,n.width-r-o));return{top:d,left:u,placedAbove:c}}function v5({onDismiss:e}){return t.jsx("div",{onClick:e,style:{position:"fixed",inset:0,zIndex:999998,background:"transparent"}})}const Toe=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardBackdrop:v5},Symbol.toStringTag,{value:"Module"}));function j5({match:e,onOpen:n}){return t.jsxs("button",{onClick:()=>n(e),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:[t.jsx("div",{style:{fontWeight:600},children:e.endpoint}),t.jsx("div",{style:{opacity:.85},children:e.jsonPath})]})}const Poe=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardMatchButton:j5},Symbol.toStringTag,{value:"Module"}));function w5({matches:e,onOpen:n}){return t.jsx("ul",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:6},children:e.map((s,r)=>t.jsx("li",{children:t.jsx(j5,{match:s,onOpen:n})},`${s.endpoint}${s.jsonPath}${r}`))})}const Ooe=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardMatchList:w5},Symbol.toStringTag,{value:"Module"}));function _5({clickedText:e,matches:n,corpusEmpty:s,onOpenInPanel:r}){return t.jsxs("div",{style:{padding:"8px 12px"},children:[t.jsxs("div",{style:{opacity:.7,marginBottom:6,wordBreak:"break-all"},children:["Clicked: ",t.jsx("code",{children:S5(e,120)||"(empty)"})]}),s?t.jsx("div",{style:{opacity:.85},children:"No mocks were consumed on this page load yet."}):n.length===0?t.jsx("div",{style:{opacity:.85},children:"No direct mock value matches — this value may be computed or concatenated."}):t.jsx(w5,{matches:n,onOpen:r})]})}function S5(e,n){return e.length<=n?e:e.slice(0,n-1)+"…"}const Roe=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardBody:_5,truncate:S5},Symbol.toStringTag,{value:"Module"}));function k5({onDismiss:e}){return t.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid var(--border-muted, #374151)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("span",{style:{fontWeight:600},children:"Data source"}),t.jsx("button",{onClick:e,"aria-label":"Dismiss",style:{background:"transparent",color:"inherit",border:"none",cursor:"pointer",fontSize:14,lineHeight:1},children:"×"})]})}const Eoe=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCardHeader:k5},Symbol.toStringTag,{value:"Module"})),Jm=320,Xm=320,L9=8;function N5({clickedText:e,matches:n,anchor:s,onOpenInPanel:r,onDismiss:a,corpusEmpty:o}){l.useEffect(()=>{function p(h){h.key==="Escape"&&a()}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[a]);const i=typeof window<"u"?window.innerHeight:800,c=typeof window<"u"?window.innerWidth:1200,{top:d,left:u}=D9(s,{width:c,height:i},{width:Jm,maxHeight:Xm,gap:L9});return t.jsxs(t.Fragment,{children:[t.jsx(v5,{onDismiss:a}),t.jsxs("div",{style:{position:"fixed",top:d,left:u,width:Jm,maxHeight:Xm,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:[t.jsx(k5,{onDismiss:a}),t.jsx(_5,{clickedText:e,matches:n,corpusEmpty:o,onOpenInPanel:r})]})]})}const Aoe=Object.freeze(Object.defineProperty({__proto__:null,InspectResultCard:N5},Symbol.toStringTag,{value:"Module"}));function C5({healthy:e,reason:n,authNeeded:s}){const r=s?"auth-needed":e===!0?"healthy":e===!1?"unhealthy":"unknown",o={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:"—"},"auth-needed":{bg:"#3a2f1f",border:"#6b552f",dot:"#fbbf24",label:"Sign in"}}[r];return t.jsxs("div",{role:"status","aria-label":`Live preview iframe: ${r}`,title:r==="auth-needed"?"Live Preview runs on a separate secured host that needs sign-in. Open it top-level to sign in, then reload.":r==="healthy"?"Live Preview iframe is healthy and matches the running dev server.":r==="unhealthy"?n?`Live Preview iframe is stale: ${n}`:"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:o.bg,border:`1px solid ${o.border}`,color:"#fff",fontSize:11,fontFamily:"monospace",zIndex:30,pointerEvents:"auto"},children:[t.jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:o.dot,boxShadow:r==="healthy"?`0 0 6px ${o.dot}`:void 0}}),t.jsx("span",{children:o.label})]})}const Moe=Object.freeze(Object.defineProperty({__proto__:null,LiveIframeHealthPill:C5},Symbol.toStringTag,{value:"Module"})),F9=new Set(["localhost","127.0.0.1","[::1]","::1"]);function Qm(e){if(!e)return!1;try{return!F9.has(new URL(e).hostname)}catch{return!1}}function T5(e,n,s){if(e===!1)return"local";const r=typeof window<"u"?window.location.origin:null;return Qm(n)||Qm(r)?"hosted":"tunnel"}function $9(e,n,s,r){return/^https?:\/\//i.test(s??"")?!0:T5(e,n)==="local"}function P5(e,n){switch(e){case"local":return{heading:`Nothing is answering on port ${n}`,ariaLabel:"Preview port not answering",showForwardFlag:!1};case"hosted":return{heading:"This preview needs a dedicated preview host",ariaLabel:"Preview host not provisioned",showForwardFlag:!1};case"tunnel":return{heading:`Forward port ${n} to see the Live Preview`,ariaLabel:"Preview port forward required",showForwardFlag:!0}}}function O5({hint:e,onRecheck:n}){const{inContainer:s,reachableUrl:r}=ho(),a=T5(s,r),{heading:o,showForwardFlag:i}=P5(a,e.port),{phase:c,attempts:d,retry:u}=Bc(n),p=a==="local"?`This app does its own page routing, so its preview is served on its own address — port ${e.port} on this machine. The editor is running here too, so that address is already the right one. Nothing is answering on it.`:a==="hosted"?`This app does its own page routing, so its preview is served on its own address — port ${e.port}. But that address points at YOUR machine, not the one running the app. You reach this editor over a hosted address rather than a port forward, so there is no forward that could resolve it.`:`This app does its own page routing, so its preview is served on its own address — port ${e.port}. Your connection to this machine only carries the editor's port, so your browser can't reach that one.`,h=Dd(r,a==="hosted"),f=h?`A preview address for this machine already exists and is answering: ${h}. Point the preview at it with: ${Ua(h)} — it takes effect immediately, no restart needed.`:"This one isn't yours to fix from here — a dedicated preview host has to be provisioned for this machine, alongside the editor's own address. Copy this report and send it to whoever set the machine up.",m=a==="local"?"Start your app's server, then reload the preview.":a==="hosted"?f:`Add ${e.flag} to the connection you use to reach this machine, then reload the preview. Copy this report to get the flag with its context.`;return t.jsx("div",{className:"absolute inset-0 z-40 flex items-center justify-center p-8",style:{background:"var(--bg-surface)"},children:t.jsx(Lt,{severity:"blocked",testId:"preview-forward-port-notice",headline:o,explanation:p,nextAction:m,diagnostics:i?e.flag:void 0,actions:[{label:i?"I've added it — reload preview":"Reload preview",onClick:u,pending:c==="pending",pendingLabel:"Rechecking…",testId:"preview-forward-port-notice-recheck"}],actionFeedback:c==="unchanged"?t.jsxs("span",{"data-testid":"preview-forward-port-notice-unchanged",children:["Checked just now — port ",e.port," still isn’t reachable",d>1?` (${d} tries)`:"","."]}):null})})}const Ioe=Object.freeze(Object.defineProperty({__proto__:null,PreviewForwardPortNotice:O5,forwardPortNoticeCopy:P5},Symbol.toStringTag,{value:"Module"}));function R5(e){if(!e)return null;let n;try{n=new URL(e)}catch{return null}if(!(n.hostname==="localhost"||n.hostname==="127.0.0.1"||n.hostname==="[::1]"||n.hostname==="::1"))return null;const r=Number(n.port);return!Number.isInteger(r)||r<=0||r>65535?null:{port:r,flag:`-L ${r}:localhost:${r}`}}async function z9(e,n,s){if(Zd(e))return"unknown";const r=e,a=W9(r,s);try{await fetch(a,{credentials:"include",mode:"no-cors",redirect:"follow"})}catch{return R5(r)?"unreachable":"unknown"}try{return(await fetch(a,{credentials:"include",mode:"cors",redirect:"manual"})).type==="opaqueredirect"?"needs-signin":"authed"}catch{return"unknown"}}const B9="_cb";function W9(e,n){if(!n)return e;try{const s=new URL(n,e);return s.origin!==new URL(e).origin?e:(s.searchParams.delete(B9),s.href)}catch{return e}}const H9=Symbol("unsent");function q9(e,n){const[s,r]=l.useState("unknown"),[a,o]=l.useState(0),[i,c]=l.useState("idle"),[d,u]=l.useState(0),p=l.useRef(H9),h=l.useCallback(async()=>{const m=await z9(e,void 0,n);if(r(x=>(x==="needs-signin"&&m==="authed"&&o(b=>b+1),m)),Zd(e))return;const g=m==="needs-signin"?e??null:null;g!==p.current&&!en()&&(p.current=g,TW(g))},[e,n]);l.useEffect(()=>{h()},[h]);const f=l.useCallback(()=>{c("pending"),u(m=>m+1),h().finally(()=>c("unchanged"))},[h]);return{authState:s,recheck:f,remountNonce:a,recheckPhase:i,recheckAttempts:d}}function Zm(e,n){if(!n||!/^https?:\/\//i.test(e))return null;try{const s=new URL(e).origin;return s===new URL(n).origin?s:null}catch{return null}}function U9(e,n,s){return new Promise(r=>{const a=new Image,o=setTimeout(()=>i(!1),s);function i(c){clearTimeout(o),a.onload=null,a.onerror=null,r(c)}a.onload=()=>i(!0),a.onerror=()=>i(!1),a.src=`${e}${n}?_=${Date.now()}`})}function Y9(e,n,s){const r=new URL(e),a=`${r.pathname}${r.search}${r.hash}`;return`${r.origin}${n}?t=${encodeURIComponent(s)}&next=${encodeURIComponent(a)}`}const oo=new Map,E5="codeyam.previewHandoffRouted:",G9=3e3;function Ac(e){const n=oo.get(e);if(n!==void 0)return n;try{if(sessionStorage.getItem(E5+e)==="1")return!0}catch{}}function V9(e,n){if(oo.set(e,n),!!n)try{sessionStorage.setItem(E5+e,"1")}catch{}}function K9(e){oo.get(e)===!1&&oo.delete(e)}function J9(e,n,s){const r=Ac(e);return r!==void 0?Promise.resolve(r):(s??((o,i)=>U9(o,i,G9)))(e,n).catch(()=>!1).then(o=>(V9(e,o),o))}const A5="codeyam:preview-session-request",M5="codeyam:preview-session-result",X9=1e4;function Q9(e){if(typeof e!="object"||e===null)return null;const n=e;return n.type!==M5?null:n.outcome==="handed-off"||n.outcome==="route-unwired"||n.outcome==="failed"?n.outcome:null}function Z9(e){return typeof e=="object"&&e!==null&&e.type===A5}function I5(e=window){try{return e.self!==e.top}catch{return!0}}let io="idle";const Mc=new Set;function Vi(e){if(io!==e){io=e;for(const n of Mc)n()}}const eg={get:()=>io,subscribe:e=>(Mc.add(e),()=>{Mc.delete(e)})};let tg=!1,es=null;function eq(e=window){I5(e)&&(tg||(tg=!0,e.addEventListener("message",n=>{if(n.source!==e.parent)return;const s=Q9(n.data);s!==null&&(es&&clearTimeout(es),es=null,Vi(s))})),Vi("pending"),es&&clearTimeout(es),es=setTimeout(()=>{es=null,io==="pending"&&Vi("failed")},X9),e.parent.postMessage({type:A5},"*"))}function tq(e){const n=/^vm-(\d+)\./.exec(e);return n?Number(n[1]):null}const Ki=new Set,nq="/api/preview-session-handoff";function sq(e,n,s,r={}){const{probePath:a,probe:o}=r,i=!!(o||a),c=s?Zm(e,n):null,d=c!==null&&!Ki.has(c)&&!(i&&Ac(c)===!1),[u,p]=l.useState(null),[h,f]=l.useState(!1),[m,g]=l.useState(0),x=l.useRef(e);x.current=e;const b=l.useRef(o);b.current=o;const y=l.useRef(null),v=_=>{const w=y.current;if(y.current=null,!!w)try{w.source.postMessage({type:M5,outcome:_},w.origin)}catch{}},j=l.useRef(v);return j.current=v,l.useEffect(()=>{if(!c||!s)return;const _=w=>{w.origin!==c||!w.source||Z9(w.data)&&(y.current={source:w.source,origin:c},Ki.delete(c),K9(c),p(null),f(!1),g(k=>k+1))};return window.addEventListener("message",_),()=>window.removeEventListener("message",_)},[c,s]),l.useEffect(()=>{if(!c||!s)return;if(!d){y.current&&Ac(c)===!1&&j.current("route-unwired");return}let _=!1;return(i?J9(c,a??"",b.current):Promise.resolve(!0)).then(k=>{if(!_){if(!k){f(!0),j.current("route-unwired");return}return fetch(nq,{method:"POST"}).then(S=>S.ok?S.json():Promise.reject(S.status)).then(S=>{if(_)return;const N=x.current;if(!S.token||Zm(N,n)!==c){f(!0),j.current("failed");return}Ki.add(c),p({url:N,src:Y9(N,s,S.token)}),j.current("handed-off")})}}).catch(()=>{_||(f(!0),j.current("failed"))}),()=>{_=!0}},[d,c,s,n,i,a,m]),u&&u.url===e?u.src:!d||h?e:"about:blank"}function ng(e){if(!e||typeof e!="object")return null;const n=e;return{componentName:n.componentName??null,sourceFile:n.sourceFile??null,lineNumber:n.lineNumber??null,detectionMethod:n.detectionMethod??"dom-heuristics",ancestors:Array.isArray(n.ancestors)?n.ancestors:[],propsNames:Array.isArray(n.propsNames)?n.propsNames:[],element:n.element}}function rq(e){const[n,s]=l.useState(!1),[r,a]=l.useState(!1),[o,i]=l.useState(null),[c,d]=l.useState(null),u=l.useCallback(g=>{const x=e.current;x!=null&&x.contentWindow&&x.contentWindow.postMessage({type:g},"*")},[e]),p=l.useCallback(()=>{s(!0),i(null),d(null),u("codeyam:debug:activate")},[u]),h=l.useCallback(()=>{s(!1),i(null),d(null),u("codeyam:debug:deactivate")},[u]),f=l.useCallback(()=>{d(null)},[]);l.useEffect(()=>{function g(x){var b;!x.data||typeof x.data.type!="string"||(x.data.type==="codeyam:debug:hover"?i(ng(x.data.payload)):x.data.type==="codeyam:debug:selected"?d(ng(x.data.payload)):x.data.type==="codeyam:debug:state"&&a(((b=x.data.payload)==null?void 0:b.frozen)===!0))}return window.addEventListener("message",g),()=>window.removeEventListener("message",g)},[]);const m=l.useCallback(()=>{s(!1),a(!1),i(null),d(null)},[]);return l.useEffect(()=>{CW(r)},[r]),{isActive:n,frozen:r,hoveredElement:o,selectedElement:c,activate:p,deactivate:h,clearSelection:f,notifyIframeLoaded:m}}const aq=/^\/api\/mock-panel(\/.*)?$/;function oq(e,n){return e.toUpperCase()!=="GET"?!1:aq.test(n)}function iq(e){return Array.isArray(e)?e.filter(n=>n.consumedThisPageLoad&&!oq(n.method,n.pathPattern)).map(n=>({endpoint:`${n.method} ${n.pathPattern}`,body:n.body})):[]}async function lq(e,n,s){return(await fetch("/api/debug/create-plan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:e,componentName:n.componentName,sourceFile:n.sourceFile,lineNumber:n.lineNumber,detectionMethod:n.detectionMethod,element:n.element,previewUrl:s})})).json()}const cq=12;function dq(e,n,s){if(n.length===0)return[];const r=[];return Ic(e,n,s,"$",0,new Set,r),r}function uq(e,n){const s=[];for(const o of e)for(const i of dq(o.body,n,o.endpoint))s.push(i);const r=new Set,a=[];for(const o of s){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 Ic(e,n,s,r,a,o,i){if(e==null)return;const c=typeof e;if(c==="string"||c==="number"||c==="boolean"){String(e)===n&&i.push({endpoint:s,jsonPath:r,matchedValue:String(e),pathDepth:a});return}if(!(a>=cq)&&!o.has(e)){if(o.add(e),Array.isArray(e))for(let d=0;d<e.length;d++)Ic(e[d],n,s,`${r}[${d}]`,a+1,o,i);else if(c==="object")for(const[d,u]of Object.entries(e))Ic(u,n,s,`${r}.${d}`,a+1,o,i);o.delete(e)}}function D5({providerLabel:e,buildingScenarioName:n,buildingScenarioSlug:s,buildingScenarioDescription:r,buildingScreenshotPath:a,containerHeight:o,containerRef:i,containerWidth:c,currentHeight:d,currentWidth:u,emptyStateMessage:p,isFilled:h,onDismissBuildingOverlay:f,historicalScreenshotPath:m,historicalScenarioName:g,historicalHeading:x,historicalSubtext:b,onDismissHistoricalPreview:y,previewSlug:v,previewUrl:j,previewOrigin:_,previewSessionHandoff:w,previewSessionHandoffProbe:k,scale:S,commandNonce:N}){var fn,nn;const C=!!g&&!s,T=!!s||C,P=l.useRef(null),R=i??P,I=l.useRef(null),{notePreviewLoaded:A}=U7(I),{status:O,restart:W}=XR();Y7(O,W);const{isRestarting:D,isFailed:Y,isStarting:H,isStopped:E}=f9(O),{stepState:U}=Qr(),M=v9((U==null?void 0:U.step)??null,(U==null?void 0:U.mode)??"ui"),J=(O==null?void 0:O.liveIframeHealthy)!==void 0,{reloadNonce:ne,handleIframeLoad:oe,handleIframeError:ae}=V7((O==null?void 0:O.pid)??null,J,O==null?void 0:O.status),G=(O==null?void 0:O.status)==="failed",{healthy:ie,failedProbeCount:le,reloadNonce:Z,invalidate:z}=e9(j,G),L=Yl(O==null?void 0:O.liveIframeHealthy,750),q=o9(ie,L),[se,fe]=l.useState(0);l.useEffect(()=>QR(()=>{fe(Ge=>Ge+1)}),[]),l9(O==null?void 0:O.sourceVersion,O==null?void 0:O.liveReloadEnabled);const{authState:we,recheck:De,remountNonce:Fe}=q9(_,j),Me=l.useMemo(()=>R5(_),[_]),ee=i9({pidNonce:ne,probeNonce:Z+q,draftNonce:se+Fe}),Q=ee.gatedNonce,{errors:te,clear:he}=d9(I,Q),{escaped:ye,overlayErrors:ve,noteFrameLoad:Ne,clearEscape:de}=W7({previewUrl:j,resetKey:Q,capturedErrors:te}),me=h9(j,Q),We=l.useCallback(()=>{ee.reset(),he(),de(),z()},[ee,he,de,z]),B=l.useCallback(()=>{he(),de()},[he,de]),F=l.useCallback(()=>Jc(),[]),X=(O==null?void 0:O.devServerStartedSecsAgo)??null,ue=X!==null&&X<m9,be=!!(O!=null&&O.startCommand),xe=s9({liveIframeHealthy:L,previewReachable:(fn=O==null?void 0:O.previewProbe)==null?void 0:fn.reachable}),[ke,qe]=l.useState(!1);l.useEffect(()=>{xe&&!ke&&qe(!0)},[xe,ke]);const Le=xe||ke,Oe=r9({hasDevServerConfigured:be,hasServed:Le}),Ue=Oe?j:"about:blank",dt=sq(Ue,_,w,{probePath:k}),je=HT(Ue,Q,N),[$e,K]=l.useState(null),_e=Oe&&$e!==je;l.useEffect(()=>{Oe&&A()},[je,Oe,A]);const V=g9({hasDevServerConfigured:be,probeHealthy:ie,backendRunning:(O==null?void 0:O.status)==="running",backendIframeHealthy:L,isStarting:H,isRestarting:D,isFailed:Y,isStopped:E,isPrePrototype:M,withinStartupGrace:ue,previewReachable:((nn=O==null?void 0:O.previewProbe)==null?void 0:nn.reachable)===!0,hasEverServed:Le}),ce=l.useRef(void 0);l.useEffect(()=>{var Rt;if(ce.current===V)return;const Ge=ce.current;ce.current=V,console.debug(`[preview-overlay] ${Ge===void 0?"(init)":Ge??"none"} → ${V??"none"}`,{status:O==null?void 0:O.status,intendedRunning:O==null?void 0:O.intendedRunning,restartCount:O==null?void 0:O.restartCount,pid:O==null?void 0:O.pid,liveIframeHealthy:O==null?void 0:O.liveIframeHealthy,previewProbeReachable:(Rt=O==null?void 0:O.previewProbe)==null?void 0:Rt.reachable,devServerStartedSecsAgo:X,withinStartupGrace:ue,probeHealthy:ie,isStarting:H,isRestarting:D,isFailed:Y,isStopped:E})},[V,O,X,ue,ie,H,D,Y,E]);const Be=O==null?void 0:O.portDiagnostic,Ke=(Be==null?void 0:Be.conflict)===!0,Ie=V==="scaffolding"?_9((U==null?void 0:U.step)??null,(U==null?void 0:U.mode)??"ui").body:void 0,ut=t9({active:V==="reconnecting",trigger:le}),Ze=V==="reconnecting"?n9(ut):null,st=Ie??Ze??void 0,Ye=le>=10,{isActive:rt,frozen:Je,hoveredElement:vt,selectedElement:jt,activate:Yt,deactivate:Ct,clearSelection:Tt,notifyIframeLoaded:Kn}=rq(I),Gt=l.useCallback(()=>{rt?Ct():Yt()},[rt,Yt,Ct]),{entries:Pn}=ZR(v??null),{isActive:wt,toggle:Jn}=G7({activate:Yt,deactivate:Ct,clearSelection:Tt},ne);l.useEffect(()=>(vh({isActive:wt,previewSlug:v??null}),()=>{vh({isActive:!1,previewSlug:null})}),[wt,v]),l.useEffect(()=>eE(()=>{Jn()}),[Jn]);const Pt=wt&&jt?jt.element.text.trim():"",zt=l.useMemo(()=>iq(Pn),[Pn]),tn=l.useMemo(()=>!wt||!Pt?[]:uq(zt,Pt),[wt,Pt,zt]),Xn=l.useCallback(async Ge=>{Tt(),Ct();try{const mt=await(await fetch("/api/scenarios")).json(),sn=Array.isArray(mt)?mt.find(gt=>gt.componentName===Ge):null;if(sn!=null&&sn.slug){const gt=ko(window.location),rn=jy(sn.slug,gt,null,0,_);window.history.pushState(null,"",rn);return}}catch{}window.history.pushState(null,"",`${Xc()}/entities`)},[Tt,Ct,_]),Ot=l.useCallback(async(Ge,Rt)=>{try{await lq(Ge,Rt,j),Tt(),Ct()}catch(mt){console.error("Failed to create debug plan:",mt)}},[j,Tt,Ct]);return t.jsx("div",{ref:R,className:`relative flex-1 flex overflow-clip ${h?"":"items-center justify-center p-8"}`,style:h?{backgroundColor:"#fff"}:Bs,children:j?t.jsxs(t.Fragment,{children:[t.jsx(UT,{ref:I,currentHeight:d,currentWidth:u,isFilled:h,previewUrl:dt,scale:S,iframeKey:je,onLoad:()=>{if(Oe){const Ge=Ne(I.current);oe(Ge??j),Kn(),K(je),A()}},onError:ae}),!Oe&&t.jsx(WT,{hasDevServerConfigured:be}),_e&&t.jsx(YT,{}),!h&&t.jsx(t5,{previewUrl:j,description:r}),!h&&t.jsx(C5,{healthy:L,reason:(O==null?void 0:O.iframeLastError)??null,authNeeded:we==="needs-signin"}),we==="needs-signin"&&_&&t.jsx(Bj,{previewOrigin:_,onRecheck:De}),we==="unreachable"&&Me&&t.jsx(O5,{hint:Me,onRecheck:De}),rt&&t.jsx(b5,{hoveredElement:vt,frozen:Je}),wt&&t.jsx(y5,{}),jt&&!wt&&t.jsx(g5,{element:jt,previewUrl:j,onClose:Tt,onGoToIsolated:Xn,onCreatePlan:Ot}),jt&&wt&&t.jsx(N5,{clickedText:Pt,matches:tn,anchor:jt.element.boundingBox,corpusEmpty:zt.length===0,onOpenInPanel:Ge=>{tE({routeKey:Ge.endpoint,jsonPath:Ge.jsonPath}),Tt()},onDismiss:Tt}),!T&&t.jsx(c5,{isActive:rt,onToggle:Gt,interactionAvailable:Zd(_)}),G?t.jsx(i5,{lastError:(O==null?void 0:O.lastError)??(O==null?void 0:O.lastExit)??"(no error message captured)",failureCount:(O==null?void 0:O.failureCount)??0,failedAtMs:O==null?void 0:O.failedAtMs,holder:O==null?void 0:O.holder,onRetry:W,onReap:async()=>{await fetch("/api/editor-dev-server/reap",{method:"POST",headers:{"Content-Type":"application/json"}})}}):Ke&&Be?t.jsx(l5,{diagnostic:Be,onRetry:W}):V&&(V==="crashed"?t.jsx(o5,{logs:(O==null?void 0:O.logs)??[],providerLabel:e}):t.jsx(VT,{variant:V,restartCount:(O==null?void 0:O.restartCount)??0,showRetry:Ye,onRetry:V==="disconnected"?F:z,bodyOverride:st})),t.jsx(e5,{tripped:ee.tripped||ye,errors:ve,recentReloads:ee.recentReloads,serverHealthy:x9(O),onRetry:We,onClear:B,providerLabel:e}),me.clickThroughBroken&&me.status!==null&&t.jsx(GT,{url:j,status:me.status,logLines:me.logLines,onRetry:We}),s&&f&&t.jsx(Ec,{containerHeight:o,containerWidth:c,onDismiss:f,scenarioName:n??null,screenshotPath:a??null,viewportHeight:d,viewportWidth:u}),C&&y&&t.jsx(Ec,{containerHeight:o,containerWidth:c,heading:x??void 0,subtext:b??void 0,onDismiss:y,scenarioName:g??null,screenshotPath:m??null,viewportHeight:d,viewportWidth:u})]}):t.jsx(BT,{message:p})})}const Doe=Object.freeze(Object.defineProperty({__proto__:null,PreviewCanvas:D5},Symbol.toStringTag,{value:"Module"}));function L5({status:e}){return t.jsx(rs,{title:"Setting up your project…",subtitle:"This usually takes a few minutes. The agent explains each step in the terminal on the left.",status:e})}const Loe=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupHeader:L5},Symbol.toStringTag,{value:"Module"}));function F5({prompt:e,defaultExpanded:n=!1}){const[s,r]=l.useState(n);return t.jsxs("section",{"aria-label":"What you asked for",style:{borderTop:"1px solid rgba(255,255,255,.08)",paddingTop:14},children:[t.jsxs("button",{type:"button",onClick:()=>r(a=>!a),"aria-expanded":s,style:{width:"100%",background:"transparent",border:"none",padding:0,margin:0,color:"rgba(255,255,255,.45)",fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:11,letterSpacing:".08em",textTransform:"uppercase",textAlign:"left",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("span",{children:"What you asked for"}),t.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",transition:"transform 150ms ease",transform:s?"rotate(0deg)":"rotate(-90deg)"},children:"▾"})]}),s?t.jsx("div",{style:{marginTop:10,color:"var(--text-secondary)",fontSize:13,lineHeight:1.55},children:t.jsx(Ft,{children:e})}):null]})}const Foe=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupDescriptionCard:F5},Symbol.toStringTag,{value:"Module"}));function $5({html:e,viewport:n}){return t.jsxs("div",{children:[t.jsx("div",{style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:11,letterSpacing:".08em",textTransform:"uppercase",color:"rgba(255,255,255,.45)",marginBottom:10},children:"Your chosen design"}),t.jsx("div",{style:{borderRadius:10,overflow:"hidden",boxShadow:"0 0 0 1px rgba(255,255,255,.08)"},children:t.jsx($p,{html:e,url:"",title:"Chosen design",viewport:n,theme:"light",darkVars:null,slotAspect:ii[n]})})]})}const $oe=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupChosenMockup:$5},Symbol.toStringTag,{value:"Module"}));function z5({assets:e}){return t.jsxs("div",{children:[t.jsx("div",{style:{color:"var(--text-muted)",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.625rem"},children:"Design assets you added"}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",fontFamily:"ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"},children:e.map(n=>t.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:[t.jsx("span",{style:{fontSize:"0.8125rem",fontWeight:500,color:"var(--text-primary)"},children:n.filename}),n.description.trim().length>0&&t.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:n.description})]},n.filename))})]})}const zoe=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupDesignAssetList:z5},Symbol.toStringTag,{value:"Module"}));function B5({mockupHtml:e,mockupViewport:n,assets:s}){const r=e!==null,a=s.length>0;return!r&&!a?null:t.jsxs("section",{"aria-label":"Your chosen design",style:{border:"1px solid rgba(255,255,255,.1)",borderRadius:14,padding:14,background:"rgba(255,255,255,.03)",display:"flex",flexDirection:"column",gap:16,minWidth:0},children:[r&&t.jsx($5,{html:e,viewport:n}),a&&t.jsx(z5,{assets:s})]})}const Boe=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupDesignCard:B5},Symbol.toStringTag,{value:"Module"}));function W5(e,n){if(e.phaseSteps.length===0)return"pending";const s=e.phaseSteps[0],r=e.phaseSteps[e.phaseSteps.length-1];return n>r?"complete":n>=s?"active":"pending"}const pq="var(--accent-active, #D7FF63)";function H5({status:e}){return e==="complete"?t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18","aria-hidden":"true",style:{flexShrink:0,display:"block"},children:[t.jsx("circle",{cx:"9",cy:"9",r:"8",fill:"#D7FF63"}),t.jsx("path",{d:"M5.5 9.2 L8 11.5 L12.5 6.5",fill:"none",stroke:"#111",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]}):e==="active"?t.jsx("span",{role:"img","aria-label":"In progress",style:{display:"inline-flex"},children:t.jsx(Ht,{size:18})}):t.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18","aria-hidden":"true",style:{flexShrink:0,display:"block"},children:t.jsx("circle",{cx:"9",cy:"9",r:"7.5",fill:"none",stroke:"rgba(255,255,255,.22)",strokeWidth:"1.5"})})}function q5({phase:e,status:n}){const s=n==="active";return t.jsxs("li",{"data-phase-id":e.phaseId,"data-phase-status":n,style:{display:"flex",alignItems:"center",gap:12,padding:s?"12px 14px":"8px 14px",borderRadius:12,border:`1px solid ${s?"rgba(215,255,99,.45)":"transparent"}`,background:s?"linear-gradient(180deg, rgba(215,255,99,.07), rgba(215,255,99,.02))":"transparent"},children:[t.jsx(H5,{status:n}),t.jsxs("span",{style:{display:"flex",flexDirection:"column",gap:2,minWidth:0},children:[t.jsx("span",{style:{color:s?pq:n==="complete"?"var(--text-primary)":"rgba(255,255,255,.4)",fontSize:14,fontWeight:s?600:400},children:e.phaseLabel}),s?t.jsx("span",{style:{fontSize:12,color:"var(--text-muted)"},children:"Working on it…"}):null]})]})}const Woe=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupProgressRow:q5,StatusIndicator:H5},Symbol.toStringTag,{value:"Module"}));function U5({currentStep:e,mode:n}){const s=Su(n),r=s.map(o=>W5(o,e)),a=r.filter(o=>o==="complete").length;return t.jsxs("section",{"aria-label":"Progress",children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:10,fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:11,letterSpacing:".08em",textTransform:"uppercase",color:"rgba(255,255,255,.4)"},children:["Progress",t.jsxs("span",{style:{marginLeft:"auto",letterSpacing:0,textTransform:"none"},children:[a," of ",s.length," done"]})]}),t.jsx("div",{"data-testid":"project-setup-pills",style:{display:"flex",gap:6,marginBottom:18},children:r.map((o,i)=>t.jsx("i",{"data-status":o,className:o==="active"?"animate-pulse":void 0,style:{flex:1,height:4,borderRadius:99,background:o==="pending"?"rgba(255,255,255,.1)":"var(--accent-active, #D7FF63)",transition:"background .3s"}},s[i].phaseId))}),t.jsx("ol",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:4},children:s.map((o,i)=>t.jsx(q5,{phase:o,status:r[i]},o.phaseId))})]})}const Hoe=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupProgressList:U5},Symbol.toStringTag,{value:"Module"})),sg=300;function Y5({tips:e}){const[n,s]=l.useState(0),[r,a]=l.useState(!0),o=i=>{a(!1),window.setTimeout(()=>{s((i%e.length+e.length)%e.length),a(!0)},sg)};return l.useEffect(()=>{if(e.length<2)return;const i=window.setInterval(()=>o(n+1),zp);return()=>window.clearInterval(i)},[n,e.length]),t.jsxs("aside",{"aria-label":"Tip","data-testid":"session-tip-card",style:{display:"flex",flexDirection:"column",gap:8,padding:"14px 16px",borderRadius:12,border:"1px solid rgba(255,255,255,.09)",background:"rgba(255,255,255,.03)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[t.jsx("span",{style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:11,letterSpacing:".12em",textTransform:"uppercase",color:"var(--accent-active, #D7FF63)"},children:"Tip"}),e.length>1&&t.jsx("span",{style:{marginLeft:"auto",display:"flex",gap:4},children:e.map((i,c)=>t.jsx("button",{type:"button","aria-label":`Tip ${c+1} of ${e.length}`,"aria-current":c===n?"true":void 0,onClick:()=>c!==n&&o(c),style:{width:c===n?14:5,height:5,padding:0,border:"none",borderRadius:99,cursor:"pointer",background:c===n?"var(--accent-active, #D7FF63)":"rgba(255,255,255,.18)",transition:"width .2s, background .2s"}},c))})]}),t.jsx("p",{"data-testid":"session-tip","aria-live":"polite",style:{margin:0,fontSize:14,lineHeight:1.5,minHeight:"3em",color:"var(--text-primary)",opacity:r?1:0,transition:`opacity ${sg}ms`},children:e[n%e.length]})]})}const qoe=Object.freeze(Object.defineProperty({__proto__:null,SessionTipCard:Y5},Symbol.toStringTag,{value:"Module"}));function hq(e){let n=e;const s=n.match(/^Feature: [^\n]*\n\nProject context: /);return s?n=n.slice(s[0].length):n.startsWith("Project context: ")&&(n=n.slice(17)),n.endsWith(`
|
|
319
|
+
`)&&(n=n.slice(0,-1)),n}const G5=["The agent writes real code for your app, step by step, and checks its work as it goes.","You can type in the terminal on the left to ask the agent something while it works.","Every step is saved in History, so nothing gets lost.","Your chosen design becomes the app's colors, fonts and first screen."];function V5({prompt:e,currentStep:n,mode:s,mockupHtml:r=null,mockupViewport:a="desktop",assets:o=[]}){const i=r!==null||o.length>0,c=hq(e).trim(),d=t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:20,minWidth:0},children:[t.jsx(U5,{currentStep:n,mode:s}),t.jsx(Y5,{tips:G5}),c?t.jsx(F5,{prompt:c,defaultExpanded:!i}):null]});return t.jsxs("div",{"data-testid":"project-setup-view",style:{margin:"0 auto",maxWidth:i?1040:560,display:"grid",gridTemplateColumns:i?"repeat(auto-fit, minmax(300px, 1fr))":"1fr",gap:32,alignItems:"start"},children:[i?t.jsx(B5,{mockupHtml:r,mockupViewport:a,assets:o}):null,d]})}const Uoe=Object.freeze(Object.defineProperty({__proto__:null,BUILD_TIPS:G5,ProjectSetupPreviewView:V5},Symbol.toStringTag,{value:"Module"}));function fq(){const[e,n]=l.useState(null),[s,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 p=await u.json();if(!p||typeof p.filename!="string"||!p.filename)return;const h=await fetch("/api/editor-design-selected-mockup");if(!h.ok)return;const f=await h.text();if(i||!f)return;n(f),r(Lp(f)??"desktop")}catch{}}async function d(){try{const u=await fetch("/api/editor-design-assets");if(!u.ok)return;const p=await u.json();!i&&Array.isArray(p.assets)&&o(p.assets)}catch{}}return c(),d(),()=>{i=!0}},[]),{mockupHtml:e,mockupViewport:s,assets:a}}function K5(){const{prompt:e}=$T(),{stepState:n}=Qr(),{mockupHtml:s,mockupViewport:r,assets:a}=fq(),o=(n==null?void 0:n.step)??1,i=(n==null?void 0:n.mode)??"ui",c=Su(i),d=c.findIndex(u=>W5(u,o)==="active");return t.jsxs("div",{"data-testid":"project-setup-canvas",className:"flex-1 flex flex-col min-w-0",children:[t.jsx(L5,{status:d>=0?`phase ${d+1} of ${c.length}`:void 0}),t.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:"32px 24px 48px"},children:t.jsx(V5,{prompt:e??"",currentStep:o,mode:i,mockupHtml:s,mockupViewport:r,assets:a})})]})}const Yoe=Object.freeze(Object.defineProperty({__proto__:null,ProjectSetupPreviewPane:K5},Symbol.toStringTag,{value:"Module"}));function mq(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/setup-terminal`}function gq(e,n,s=1500){if(e<=0)return!1;const r=n-e;return r>=0&&r<=s}function J5({assistantTyping:e}){return t.jsxs("div",{className:"flex items-center justify-between px-3 py-2 text-[11px]",style:{background:"var(--bg-card)",color:"var(--text-secondary)",borderBottom:"1px solid var(--border-subtle)"},children:[t.jsx("span",{children:"Shared terminal — you and the assistant both drive this shell."}),e&&t.jsx("span",{className:"rounded px-2 py-0.5",style:{background:"rgba(215, 255, 99, 0.15)",color:"#8fae00",border:"1px solid rgba(215, 255, 99, 0.4)"},children:"Assistant is typing…"})]})}const Goe=Object.freeze(Object.defineProperty({__proto__:null,SetupTerminalHeader:J5},Symbol.toStringTag,{value:"Module"})),xq=1200,bq=1e3,yq=["\x1B[90mproject/my-app\x1B[0m $ dig codeyam.com +short","\x1B[36m76.76.21.21\x1B[0m","\x1B[90mproject/my-app\x1B[0m $ \x1B[2m# assistant ran:\x1B[0m vercel --version","\x1B[36mVercel CLI 39.1.3\x1B[0m","\x1B[90mproject/my-app\x1B[0m $ "].join(`\r
|
|
320
|
+
`);function X5(){const e=en(),n=l.useRef(null),s=l.useRef(null),r=l.useRef(null),a=l.useRef(null),o=l.useRef(!1),i=l.useRef(!1),c=l.useRef(null),[d,u]=l.useState(!1),[p,h]=qu(1200);function f(m){const g=a.current;(g==null?void 0:g.readyState)===WebSocket.OPEN&&g.send(new TextEncoder().encode(m))}return qc(n,()=>{if(r.current&&s.current){if(!jr(s.current,n.current))return;r.current.fit();const m=a.current;(m==null?void 0:m.readyState)===WebSocket.OPEN&&m.send(JSON.stringify({type:"resize",cols:s.current.cols,rows:s.current.rows}))}}),l.useEffect(()=>{if(e)return;let m=!1;const g=async()=>{try{const b=await fetch("/api/setup-terminal/activity");if(!b.ok)return;const y=await b.json();if(m)return;u(gq(y.lastInjectMs??0,Date.now()))}catch{}};g();const x=window.setInterval(g,bq);return()=>{m=!0,window.clearInterval(x)}},[e]),l.useEffect(()=>{if(!n.current||o.current)return;o.current=!0,i.current=!1;const m=new Uc.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'IBM Plex Mono', monospace",rightClickSelectsWord:!1,theme:{background:"#1e1e1e",foreground:"#cccccc",cursor:"#D7FF63",selectionBackground:"#264f78"}}),g=new Yc.FitAddon;m.loadAddon(g),m.open(n.current),s.current=m,r.current=g;const x=Gc(m,n.current,{onCopy:()=>h()}),b=Vc(m,{sendInput:f});if(requestAnimationFrame(()=>{jr(m,n.current)&&g.fit(),m.focus()}),e)return m.write(yq),u(!0),()=>{b(),x(),m.dispose(),o.current=!1};const y=()=>{if(i.current)return;const v=new WebSocket(mq());a.current=v,v.binaryType="arraybuffer",v.onmessage=j=>{j.data instanceof ArrayBuffer&&m.write(new Uint8Array(j.data))},v.onopen=()=>{v.send(JSON.stringify({type:"resize",cols:m.cols,rows:m.rows}))},v.onclose=()=>{i.current||(c.current=window.setTimeout(y,xq))}};return y(),m.onData(f),()=>{var v;i.current=!0,c.current!==null&&window.clearTimeout(c.current),(v=a.current)==null||v.close(),b(),x(),m.dispose(),o.current=!1}},[e]),t.jsxs("div",{className:"relative flex-1 flex flex-col",style:{minHeight:0},children:[t.jsx(J5,{assistantTyping:d}),t.jsx("div",{ref:n,className:"flex-1",style:{background:"#1e1e1e",minHeight:0,paddingTop:3,paddingLeft:3},onClick:()=>{var m;return(m=s.current)==null?void 0:m.focus()}}),p&&t.jsx(Qo,{})]})}const Voe=Object.freeze(Object.defineProperty({__proto__:null,SetupTerminalPane:X5},Symbol.toStringTag,{value:"Module"}));function vq(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/setup-browser`}function jq(e){let n;try{n=JSON.parse(e)}catch{return null}if(typeof n!="object"||n===null)return null;const s=n;if(s.type!=="frame"||typeof s.data!="string")return null;const r=typeof s.w=="number"?s.w:0,a=typeof s.h=="number"?s.h:0;return{src:`data:image/jpeg;base64,${s.data}`,width:r,height:a}}function wq(e){const n=e.paneWidth>0&&e.frameWidth>0?e.frameWidth/e.paneWidth:1,s=e.paneHeight>0&&e.frameHeight>0?e.frameHeight/e.paneHeight:1;return JSON.stringify({kind:"mouse",event:e.event,x:Math.round(e.paneX*n),y:Math.round(e.paneY*s),button:"left",clickCount:1})}function _q(e,n,s=1500){if(e<=0)return!1;const r=n-e;return r>=0&&r<=s}function tr(e,n){const s=`<svg xmlns="http://www.w3.org/2000/svg" width="1280" height="800" viewBox="0 0 1280 800">
|
|
321
|
+
<rect width="1280" height="800" fill="#0b0d12"/>
|
|
322
|
+
<rect width="1280" height="56" fill="#11141b"/>
|
|
323
|
+
<text x="28" y="35" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="20" font-weight="700">${n}</text>
|
|
324
|
+
${e}
|
|
325
|
+
</svg>`;return`data:image/svg+xml;utf8,${encodeURIComponent(s)}`}function Vt(e,n,s,r,a){return`
|
|
326
|
+
<text x="${e}" y="${n}" fill="#98a0ad" font-family="system-ui, sans-serif" font-size="14">${r}</text>
|
|
327
|
+
<rect x="${e}" y="${n+10}" width="${s}" height="40" rx="6" fill="#171b24" stroke="#2a303c"/>
|
|
328
|
+
<text x="${e+14}" y="${n+36}" fill="#e7e9ee" font-family="ui-monospace, monospace" font-size="15">${a}</text>`}const Sq={hosting:tr(`
|
|
329
|
+
<text x="28" y="130" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="28" font-weight="700">Production Deployment</text>
|
|
330
|
+
<rect x="28" y="160" width="1224" height="120" rx="10" fill="#12161f" stroke="#232a36"/>
|
|
331
|
+
<circle cx="60" cy="220" r="8" fill="#3ecf8e"/>
|
|
332
|
+
<text x="82" y="212" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="17">my-app.vercel.app</text>
|
|
333
|
+
<text x="82" y="238" fill="#98a0ad" font-family="system-ui, sans-serif" font-size="14">Ready · deployed 2m ago · main@a1b2c3d</text>
|
|
334
|
+
<rect x="28" y="320" width="360" height="44" rx="8" fill="#D7FF63"/>
|
|
335
|
+
<text x="70" y="348" fill="#0b0d12" font-family="system-ui, sans-serif" font-size="16" font-weight="600">Add a custom domain →</text>`,"▲ Vercel — Project Settings"),dns:tr(`
|
|
336
|
+
<text x="28" y="130" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="26" font-weight="700">DNS Records — codeyam.com</text>
|
|
337
|
+
${Vt(28,180,300,"Type","CNAME")}
|
|
338
|
+
${Vt(360,180,420,"Name","www")}
|
|
339
|
+
${Vt(812,180,440,"Value","cname.vercel-dns.com")}
|
|
340
|
+
${Vt(28,280,300,"Type","A")}
|
|
341
|
+
${Vt(360,280,420,"Name","@")}
|
|
342
|
+
${Vt(812,280,440,"Value","76.76.21.21")}
|
|
343
|
+
<rect x="28" y="380" width="220" height="44" rx="8" fill="#D7FF63"/>
|
|
344
|
+
<text x="70" y="408" fill="#0b0d12" font-family="system-ui, sans-serif" font-size="16" font-weight="600">Save Records</text>`,"☁ Cloudflare — DNS"),signin:tr(`
|
|
345
|
+
<rect x="440" y="200" width="400" height="380" rx="14" fill="#12161f" stroke="#232a36"/>
|
|
346
|
+
<text x="640" y="260" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="22" font-weight="700" text-anchor="middle">Sign in to continue</text>
|
|
347
|
+
${Vt(472,300,336,"Email","you@example.com")}
|
|
348
|
+
${Vt(472,380,336,"Password","••••••••••")}
|
|
349
|
+
<rect x="472" y="470" width="336" height="44" rx="8" fill="#4c7fff"/>
|
|
350
|
+
<text x="640" y="498" fill="#ffffff" font-family="system-ui, sans-serif" font-size="16" font-weight="600" text-anchor="middle">Sign in</text>`,"App Store Connect — Sign In"),appstore:tr(`
|
|
351
|
+
<text x="28" y="130" fill="#e7e9ee" font-family="system-ui, sans-serif" font-size="26" font-weight="700">App Information</text>
|
|
352
|
+
${Vt(28,180,560,"Name","CodeYam")}
|
|
353
|
+
${Vt(620,180,632,"Subtitle","Build code and data scenarios together")}
|
|
354
|
+
${Vt(28,280,1224,"Promotional Text","See your app in every state, before you ship it.")}
|
|
355
|
+
<rect x="28" y="400" width="200" height="44" rx="8" fill="#4c7fff"/>
|
|
356
|
+
<text x="128" y="428" fill="#ffffff" font-family="system-ui, sans-serif" font-size="16" font-weight="600" text-anchor="middle">Submit for Review</text>`," App Store Connect — 1.0"),navigating:tr(`
|
|
357
|
+
<rect x="0" y="56" width="1280" height="3" fill="#D7FF63"/>
|
|
358
|
+
<text x="28" y="420" fill="#5b6472" font-family="system-ui, sans-serif" font-size="20" text-anchor="start">Loading DNS records…</text>`,"☁ Cloudflare — DNS")},kq={hosting:"https://vercel.com/acme/my-app",dns:"https://dash.cloudflare.com/dns/codeyam.com",signin:"https://appstoreconnect.apple.com/login",appstore:"https://appstoreconnect.apple.com/apps/1234/appstore",navigating:"https://dash.cloudflare.com/dns/codeyam.com"};function Nq(e){return Sq[e]}function Cq(e){return kq[e]}function Q5({address:e,assistantNavigating:n,onBack:s,onForward:r,onReload:a,onStop:o}){const i={background:"var(--bg-input, #2a2a2a)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",borderRadius:4,width:24,height:22,cursor:"pointer",fontSize:12};return t.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2 text-[11px]",style:{background:"var(--bg-card)",color:"var(--text-secondary)",borderBottom:"1px solid var(--border-subtle)"},children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{children:"Shared setup browser — you and the assistant both control this window."}),n&&t.jsx("span",{className:"rounded px-2 py-0.5",style:{background:"rgba(215, 255, 99, 0.15)",color:"#8fae00",border:"1px solid rgba(215, 255, 99, 0.4)"},children:"Assistant is navigating…"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{type:"button",style:i,onClick:s,title:"Back","aria-label":"Back",children:"‹"}),t.jsx("button",{type:"button",style:i,onClick:r,title:"Forward","aria-label":"Forward",children:"›"}),t.jsx("button",{type:"button",style:i,onClick:a,title:"Reload","aria-label":"Reload",children:"↻"}),t.jsx("div",{className:"flex-1 truncate rounded px-2 py-0.5",style:{background:"var(--bg-input, #1e1e1e)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)",fontFamily:"'IBM Plex Mono', monospace"},title:e,children:e||"about:blank"}),t.jsx("button",{type:"button",style:i,onClick:o,title:"Stop","aria-label":"Stop",children:"✕"})]})]})}const Koe=Object.freeze(Object.defineProperty({__proto__:null,SetupBrowserHeader:Q5},Symbol.toStringTag,{value:"Module"})),Tq=1200,Pq=1e3;function Z5({demo:e="hosting",address:n,assistantNavigating:s,disconnected:r=!1}={}){const o=en()||s!==void 0||r,i=l.useRef(null),c=l.useRef(null),d=l.useRef(!1),u=l.useRef(null),p=l.useRef({width:0,height:0}),[h,f]=l.useState(o?Nq(e):null),[m,g]=l.useState(n??(o?Cq(e):"")),[x,b]=l.useState(s??!1),[y,v]=l.useState(!1);l.useEffect(()=>{if(o)return;let _=!1;const w=async()=>{try{const S=await fetch("/api/setup-browser/activity");if(!S.ok)return;const N=await S.json();if(_)return;b(_q(N.lastActMs??0,Date.now()))}catch{}};w();const k=window.setInterval(w,Pq);return()=>{_=!0,window.clearInterval(k)}},[o]),l.useEffect(()=>{if(o)return;d.current=!1;const _=()=>{if(d.current)return;const w=new WebSocket(vq());c.current=w,w.onopen=()=>v(!0),w.onmessage=k=>{if(typeof k.data!="string")return;const S=jq(k.data);S&&(p.current={width:S.width,height:S.height},f(S.src))},w.onclose=()=>{v(!1),!d.current&&(u.current=window.setTimeout(_,Tq))}};return _(),()=>{var w;d.current=!0,u.current!==null&&window.clearTimeout(u.current),(w=c.current)==null||w.close()}},[o]);function j(_,w){const k=c.current;if(!k||k.readyState!==WebSocket.OPEN)return;const S=w.currentTarget.getBoundingClientRect();k.send(wq({event:_,paneX:w.clientX-S.left,paneY:w.clientY-S.top,paneWidth:S.width,paneHeight:S.height,frameWidth:p.current.width,frameHeight:p.current.height}))}return t.jsxs("div",{className:"relative flex-1 flex flex-col",style:{minHeight:0},children:[t.jsx(Q5,{address:m,assistantNavigating:x,onReload:()=>g(m)}),t.jsx("div",{ref:i,className:"flex-1 flex items-center justify-center overflow-hidden",style:{background:"#0b0d12",minHeight:0},children:r?t.jsxs("div",{className:"flex flex-col items-center gap-3 text-center px-6",children:[t.jsx("span",{style:{color:"var(--text-secondary)",fontSize:13},children:"The shared browser session was stopped."}),t.jsx("button",{type:"button",className:"rounded px-3 py-1.5",style:{background:"#D7FF63",color:"#0b0d12",fontSize:13,fontWeight:600,cursor:"pointer"},children:"Relaunch shared browser"})]}):h?t.jsx("img",{src:h,alt:"Shared setup browser viewport",className:"max-w-full max-h-full",style:{objectFit:"contain"},draggable:!1,onMouseDown:_=>j("mousePressed",_),onMouseUp:_=>j("mouseReleased",_)}):t.jsx("span",{style:{color:"var(--text-secondary)",fontSize:13},children:y?"Waiting for the first frame…":"Connecting to the shared browser…"})})]})}const Joe=Object.freeze(Object.defineProperty({__proto__:null,SetupBrowserPane:Z5},Symbol.toStringTag,{value:"Module"}));function eP({onDismiss:e,previewOrigin:n}){const{inContainer:s,reachableUrl:r}=ho(),a=$9(s,r,n),o=Dd(r,!a),i=o?`A preview address for this machine already exists and is answering: ${o}. Point the preview at it with: ${Ua(o)} — it takes effect immediately, no restart needed.`:null;return t.jsx(Lt,{severity:"warning",testId:"client-routing-advisory",className:"flex w-full flex-col gap-3 border-b border-l-4 px-4 py-3 text-sm",headline:"Reloading the preview may land on the wrong page",explanation:"This app uses client-side routing, so it handles its own page navigation. The Live Preview is served from the /__codeyam_preview sub-path, which a client-side router cannot serve correctly on a reload or a deep link. Clicking around inside the app works, but reloading may land on the wrong route.",nextAction:a?t.jsxs(t.Fragment,{children:["Set ",t.jsx("code",{children:"sameOriginSafe: false"})," in"," ",t.jsx("code",{children:".codeyam/stack.json"}),", then reload. The preview moves to its own address and the problem goes away. Copy this report if you want to hand the change to an agent."]}):i?t.jsx(t.Fragment,{children:i}):t.jsx(t.Fragment,{children:"Nothing you can change here. This editor is reached remotely and has no dedicated preview address provisioned, so there is nowhere to move the preview to yet — one has to be provisioned for this machine, alongside the editor’s own address, and the preview will use it automatically. Until then the sub-path is the only route that reaches you. Copy this report and send it to whoever set the machine up."}),nextActionText:a?'Set "sameOriginSafe": false in .codeyam/stack.json, then reload. The preview moves to its own address and the problem goes away.':i??"Nothing you can change here. This editor is reached remotely and has no dedicated preview address provisioned, so there is nowhere to move the preview to yet — one has to be provisioned for this machine, alongside the editor's own address. Until then the sub-path is the only route that reaches you. Copy this report and send it to whoever set the machine up.",actions:[{label:"Dismiss",onClick:e,variant:"secondary",ariaLabel:"Dismiss client-routing advisory",testId:"client-routing-advisory-dismiss"}]})}const Xoe=Object.freeze(Object.defineProperty({__proto__:null,ClientRoutingAdvisory:eP},Symbol.toStringTag,{value:"Module"})),Oq="Seed failed — DB state is unknown",Rq="Preview capture failed — the app's data was seeded";function tP({error:e,kind:n,onRetry:s}){const r=n==="device"?Rq:Oq;return t.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:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"font-semibold",children:r}),t.jsx("div",{className:"truncate text-xs opacity-90",children:e})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ct,{variant:"subtle",text:`${r}
|
|
359
|
+
${e}`,label:"Copy",className:"shrink-0 rounded border border-[var(--accent-red)] px-2 py-1 text-xs hover:bg-[var(--accent-red)] hover:text-white disabled:opacity-50 disabled:cursor-not-allowed"}),s?t.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 Qoe=Object.freeze(Object.defineProperty({__proto__:null,SeedErrorBanner:tP},Symbol.toStringTag,{value:"Module"}));function nP({label:e="Loading scenario..."}={}){return t.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:e})}const Zoe=Object.freeze(Object.defineProperty({__proto__:null,SeedLoadingOverlay:nP},Symbol.toStringTag,{value:"Module"}));function sP(e){return e.state==="preflight-running"||e.state==="booting-simulator"||e.state==="simulator-booted"||e.state==="building-app"}const Eq=1500;function rP({stackId:e,pollMs:n=Eq,onStateChange:s}={}){const[r,a]=l.useState({state:"idle"}),[o,i]=l.useState(!1),c=l.useRef(s);c.current=s,l.useEffect(()=>{let p=!1,h=!0;const f=async()=>{var g;try{const x=await fetch("/api/simulator-status");if(!x.ok)return;const b=await x.json();if(p||!h)return;const{history:y,...v}=b;a(v),(g=c.current)==null||g.call(c,v)}catch{}};f();const m=window.setInterval(f,n);return()=>{p=!0,h=!1,window.clearInterval(m)}},[n]);const d=l.useCallback(async()=>{if(!o){i(!0);try{const p=e?JSON.stringify({stack_id:e}):"{}";await fetch("/api/start-simulator",{method:"POST",headers:{"content-type":"application/json"},body:p})}finally{i(!1)}}},[e,o]),u=o||sP(r);return{status:r,posting:o,buttonDisabled:u,start:d}}function aP({stderrTail:e,onClose:n}){return t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.6)"},onClick:n,children:t.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:s=>s.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("strong",{children:"Build logs (stderr tail)"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ct,{variant:"subtle",text:e,label:"Copy"}),t.jsx("button",{type:"button",onClick:n,className:"opacity-70 hover:opacity-100",children:"✕"})]})]}),t.jsx("pre",{className:"whitespace-pre-wrap",children:e||"(no stderr captured)"})]})})}const eie=Object.freeze(Object.defineProperty({__proto__:null,BuildLogsModal:aP},Symbol.toStringTag,{value:"Module"}));function Dc({stackId:e,pollMs:n,onStateChange:s}){const[r,a]=l.useState(!1),{status:o,start:i,buttonDisabled:c}=rP({stackId:e,pollMs:n,onStateChange:s}),d=o.state==="app-launched";return t.jsxs("div",{className:"flex items-center gap-3 text-sm",style:{color:"var(--text-primary)"},children:[t.jsx("button",{type:"button",onClick:i,disabled:c,className:"px-3 py-1 rounded font-medium disabled:opacity-40 disabled:cursor-not-allowed",style:d?{background:"var(--surface-raised)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)",opacity:.7}:{background:"var(--accent-primary)",color:"var(--bg-deep)"},children:d?"Restart simulator":"Start simulator"}),t.jsx(oP,{status:o}),o.state==="build-failed"?t.jsx("button",{type:"button",onClick:()=>a(!0),className:"text-xs underline opacity-80 hover:opacity-100",children:"see logs"}):null,r&&o.state==="build-failed"?t.jsx(aP,{stderrTail:o.stderrTail,onClose:()=>a(!1)}):null]})}function oP({status:e}){const n=Bp(e);return t.jsx("span",{className:"text-xs opacity-80","data-testid":"simulator-status-pill",children:n})}function Bp(e){switch(e.state){case"idle":return"No simulator running";case"preflight-running":return"Pre-flight checks…";case"preflight-failed":return`Pre-flight failed: ${e.check} — ${e.message}`;case"booting-simulator":return`Booting ${e.device}…`;case"simulator-booted":return`Simulator booted (${e.name})`;case"building-app":return`Building (${iP(e.elapsedSec)})…`;case"build-failed":return"Build failed";case"app-launched":return`App running ▸${e.appBundleId!=="com.codeyam.android"?" (host proxy active)":""}`;case"stopped":return e.reason.kind==="user-requested"?"Stopped":e.reason.kind==="editor-server-shutdown"?"Editor server shut down":e.reason.code!=null?`Stopped (exit ${e.reason.code})`:"Stopped"}}function iP(e){if(e<60)return`${e}s`;const n=Math.floor(e/60),s=e%60;return`${n}m ${s.toString().padStart(2,"0")}s`}const tie=Object.freeze(Object.defineProperty({__proto__:null,SimulatorLauncherControls:Dc,StatusPill:oP,formatElapsed:iP,pillText:Bp},Symbol.toStringTag,{value:"Module"}));function lP({stackId:e,pollMs:n,onStateChange:s}){const{status:r,start:a,buttonDisabled:o}=rP({stackId:e,pollMs:n,onStateChange:s}),i=sP(r);return t.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-full px-6 text-center",style:{color:"var(--text-primary)"},children:[t.jsx("div",{className:"text-3xl","aria-hidden":"true",children:"📱"}),t.jsx("div",{className:"text-sm font-medium",children:"No simulator running yet"}),t.jsx("div",{className:"text-xs opacity-70",children:i?Bp(r):"Start it to preview this scenario on device."}),t.jsx("button",{type:"button",onClick:a,disabled:o,className:"px-3 py-1 rounded font-medium disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"var(--accent-primary)",color:"var(--bg-deep)"},children:"Start simulator"})]})}const nie=Object.freeze(Object.defineProperty({__proto__:null,SimulatorNotBootedPrompt:lP},Symbol.toStringTag,{value:"Module"}));function Aa({src:e,currentHeight:n,currentWidth:s,isFilled:r,scale:a}){return r?t.jsx("img",{src:e,alt:"Simulator / Emulator preview",className:"w-full h-full object-contain",style:{background:"var(--bg-deep)"}}):t.jsx($r,{width:s,height:n,scale:a,children:t.jsx("img",{src:e,alt:"Simulator / Emulator preview",style:{width:"100%",height:"100%",background:"var(--bg-deep)",objectFit:"contain"}})})}const sie=Object.freeze(Object.defineProperty({__proto__:null,DeviceFrameImage:Aa},Symbol.toStringTag,{value:"Module"}));function lo({currentWidth:e,currentHeight:n,isFilled:s,scale:r,title:a,hint:o}){const i=t.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:t.jsxs("div",{className:"text-sm leading-relaxed",children:[t.jsx("div",{className:"font-medium",children:a}),t.jsx("div",{className:"opacity-70 mt-1",children:o})]})});return s?i:t.jsx($r,{width:e,height:n,scale:r,children:i})}const rie=Object.freeze(Object.defineProperty({__proto__:null,SimulatorFrameNotice:lo},Symbol.toStringTag,{value:"Module"}));function cP({currentWidth:e,currentHeight:n,isFilled:s,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 t.jsx(lo,{currentWidth:e,currentHeight:n,isFilled:s,scale:r,title:o,hint:i})}const aie=Object.freeze(Object.defineProperty({__proto__:null,NoBootedSimulatorPlaceholder:cP},Symbol.toStringTag,{value:"Module"})),Aq=1500;function dP(e=Aq){const[n,s]=l.useState({available:!1,loading:!0,capturedAtMs:null});return l.useEffect(()=>{let r=!1;const a=()=>{fetch("/api/preview-capture-status").then(i=>i.ok?i.json():{available:!1}).then(i=>{r||s({available:(i==null?void 0:i.available)===!0,loading:!1,capturedAtMs:typeof(i==null?void 0:i.capturedAtMs)=="number"?i.capturedAtMs:null})}).catch(()=>{r||s(i=>({available:i.available,loading:!1,capturedAtMs:i.capturedAtMs}))})};a();const o=window.setInterval(a,e);return()=>{r=!0,window.clearInterval(o)}},[e]),n}const Mq=700;function uP({currentHeight:e,currentWidth:n,isFilled:s,scale:r,pollMs:a=Mq,onError:o,deviceLabel:i="iOS Simulator",scenarioScreenshotSrc:c=null,bootState:d}){const u=P2({pollMs:a,paused:!!c||!!d,onError:o}),{state:p,frameToken:h}=d??u,f=dP();if(c)return t.jsx(Aa,{src:c,currentWidth:n,currentHeight:e,isFilled:s,scale:r});if(p.kind==="no-device"||p.kind==="xcode-missing"){if(!f.loading&&f.available){const g=f.capturedAtMs!=null?`/api/preview-capture?cb=${f.capturedAtMs}`:"/api/preview-capture";return t.jsx(Aa,{src:g,currentWidth:n,currentHeight:e,isFilled:s,scale:r})}return t.jsx(cP,{currentWidth:n,currentHeight:e,isFilled:s,scale:r,variant:p.kind})}if(p.kind==="loading")return t.jsx(lo,{currentWidth:n,currentHeight:e,isFilled:s,scale:r,title:`Connecting to the ${i}…`,hint:"Waiting for the first live frame."});if(p.kind==="capture-failed")return t.jsx(lo,{currentWidth:n,currentHeight:e,isFilled:s,scale:r,title:"Live preview frame unavailable",hint:`Your app is still running — interact with it directly in the ${i} window.`});const m=`/api/simulator-frame?t=${h}`;return t.jsx(Aa,{src:m,currentWidth:n,currentHeight:e,isFilled:s,scale:r})}const oie=Object.freeze(Object.defineProperty({__proto__:null,SimulatorPreviewFrame:uP},Symbol.toStringTag,{value:"Module"}));function pP({emptyStateMessage:e,projectSetupInProgress:n,previewSlug:s,previewUrl:r,viewports:a,activeViewport:o,onViewportChange:i,isCollapsed:c,onToggleCollapsed:d,isFilled:u,onToggleFilled:p,currentWidth:h,currentHeight:f,onCustomSizeChange:m,buildingScenarioSlug:g,buildingScreenshotPath:x,buildingScenarioName:b,buildingScenarioDescription:y,onDismissBuildingOverlay:v,historicalScreenshotPath:j,historicalScenarioName:_,historicalHeading:w,historicalSubtext:k,onDismissHistoricalPreview:S,previewSeeding:N,previewSeedError:C,previewSeedErrorKind:T,onRetrySeed:P,currentScenario:R,scenarioGroups:I,onShowScenarioPreview:A,commandNonce:O,previewOrigin:W,isNarrow:D=!1,onBack:Y,onPlanChange:H,onDesignConfirmed:E,onExitDesigns:U,designSession:M=!1,onSkipDesign:J,credentialTarget:ne=null,onCredentialStored:oe,onCloseCredentialRequest:ae}){const{config:G}=St(),ie=Qe(G==null?void 0:G.provider),[le,Z]=l.useState(!1),z=!!Y,q=(R?Kd(R,I??[]):[]).length>1,[se,fe]=l.useState(!0),[we,De]=l.useState(!1),Fe=z?se:we,Me=z?fe:De,ee=z||q,Q=Fe&&!!R&&(z||q),[te,he]=l.useState({state:"idle"}),{containerRef:ye,containerSize:ve,scale:Ne}=EW({currentHeight:f,currentWidth:h,isFilled:u}),de=T2(),We=FW(W===os),[B,F]=l.useState(!1),X=!!(G!=null&&G.previewDedicatedOriginUnavailable),[ue,be]=l.useState(!1);l.useEffect(()=>{en()||NW(C??null)},[C]);const xe=BW(R,o),ke=xe?ds(xe,R==null?void 0:R.screenshotCapturedAtMs):null,qe=vi(de.kind),Le=!!ke,Oe=P2({paused:!qe||Le}),Ue=Oe.state.kind==="no-device"||Oe.state.kind==="xcode-missing",dt=de.fallbackKind==="iframe"&&de.fallbackPort!==null,je=qe&&!Le&&dt&&Ue,$e=de.fallbackPort??0,_e=(R?_y(R,$e,W):"")||No("/",{appPort:$e,currentPort:typeof window<"u"?ko(window.location):0,previewOrigin:W}),V=r?Ms(r):"",ce=V==="/results"||V.startsWith("/results/"),Be=V==="/plan-preview",Ke=V==="/design-exploration",Ie=V==="/design-round",ut=V===Sy,Ze=V===ky,st=Id(V);if(V===dr)return t.jsx(gT,{target:ne,onStored:Je=>oe==null?void 0:oe(Je),onClose:()=>ae==null?void 0:ae()});if(ut)return t.jsx(X5,{});if(Ze)return t.jsx(Z5,{});if(Be)return t.jsx(zT,{});if(ce)return t.jsx(Y2,{});if(Ke)return t.jsx(fT,{onDesignConfirmed:E,onExit:U,sessionMode:M,onSkip:J});if(Ie)return t.jsx(mT,{});if(st)return t.jsx(Ty,{previewPath:V,commandNonce:O});if(n&&!r&&!de.loading&&!vi(de.kind))return t.jsx(K5,{});const rt=te.state==="app-launched";return t.jsxs("div",{"data-preview-pane":"true",className:"flex-1 flex flex-col min-w-0",children:[t.jsx(DT,{viewports:a,active:o,onChange:i,currentWidth:h,currentHeight:f,previewUrl:r,isCollapsed:c,onToggleCollapsed:d,isFilled:u,onToggleFilled:p,containerWidth:(ve==null?void 0:ve.width)??null,containerHeight:(ve==null?void 0:ve.height)??null,onCustomSizeChange:m,currentScenario:R??null,scenarioGroups:I??[],onShowScenarioPreview:A??(()=>{}),onCreateStateRequest:()=>Z(!0),isNarrow:D,onBack:Y,onPlanChange:H,onToggleStatesModal:ee?()=>Me(Je=>!Je):void 0,statesModalOpen:Fe}),C?t.jsx(tP,{error:C,kind:T,onRetry:P}):null,de.nativeWebPreview?t.jsx(bT,{}):null,X&&!ue?t.jsx(My,{onDismiss:()=>be(!0),hint:(G==null?void 0:G.previewDedicatedOriginHint)??null,onManagedFleetVm:!!(G!=null&&G.onManagedFleetVm)}):We&&!B?t.jsx(eP,{previewOrigin:W,onDismiss:()=>F(!0)}):null,Q&&R?t.jsx(Tv,{currentScenario:R,scenarioGroups:I??[],onSelect:Je=>(A??(()=>{}))(Je),onCreateNew:()=>Z(!0),onClose:()=>Me(!1)}):null,t.jsxs("div",{className:"relative flex-1 flex flex-col min-h-0",children:[qe&&!je?t.jsxs(t.Fragment,{children:[t.jsx(xT,{deviceLabel:ji(de.kind),actions:t.jsx(Dc,{onStateChange:he})}),t.jsx("div",{ref:ye,className:"relative flex-1 flex overflow-hidden items-center justify-center p-8",style:{backgroundColor:"#1e1e1e"},children:rt?t.jsx(uP,{currentHeight:f,currentWidth:h,isFilled:u,scale:Ne,deviceLabel:ji(de.kind),scenarioScreenshotSrc:ke,bootState:Oe}):t.jsx(lP,{onStateChange:he})})]}):t.jsxs(t.Fragment,{children:[je?t.jsx(zj,{deviceLabel:ji(de.kind),actions:t.jsx(Dc,{})}):null,t.jsx(D5,{providerLabel:ie,containerRef:ye,containerHeight:ve==null?void 0:ve.height,containerWidth:ve==null?void 0:ve.width,currentHeight:f,currentWidth:h,emptyStateMessage:e??"Select a scenario to preview",isFilled:u,previewSlug:je?(R==null?void 0:R.slug)??s:s,previewUrl:je?_e:r,previewOrigin:W,previewSessionHandoff:(G==null?void 0:G.previewSessionHandoff)??null,previewSessionHandoffProbe:(G==null?void 0:G.previewSessionHandoffProbe)??null,scale:Ne,buildingScenarioSlug:g,buildingScreenshotPath:x,buildingScenarioName:b,buildingScenarioDescription:y,onDismissBuildingOverlay:v,historicalScreenshotPath:j,historicalScenarioName:_,historicalHeading:w,historicalSubtext:k,onDismissHistoricalPreview:S,commandNonce:O})]}),N?t.jsx(nP,{label:vi(de.kind)?"Loading scenario on device…":void 0}):null]}),le?t.jsx(G2,{onClose:()=>Z(!1),providerLabel:ie}):null]})}const iie=Object.freeze(Object.defineProperty({__proto__:null,PreviewPanel:pP},Symbol.toStringTag,{value:"Module"}));function hP({designReturnVisible:e=!1,onOpenDesigns:n,onDismissDesignReturn:s,...r}){return t.jsxs("div",{className:"flex-1 flex min-w-0 relative",children:[t.jsx("div",{"data-testid":"preview-canvas-card",className:"flex-1 flex min-w-0",style:MI,children:t.jsx(pP,{...r})}),e&&n&&s?t.jsx(C2,{onOpenDesigns:n,onDismiss:s}):null]})}const lie=Object.freeze(Object.defineProperty({__proto__:null,EditorShellPreviewPane:hP},Symbol.toStringTag,{value:"Module"})),Lc="reset";function fP({busy:e,onCancel:n,onConfirm:s,planSessionActive:r=!1}){const[a,o]=l.useState(""),i=a.trim().toLowerCase()===Lc;return l.useEffect(()=>{const c=d=>{d.key==="Escape"&&!e&&n()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[e,n]),t.jsx("div",{role:"presentation",onClick:()=>{e||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:t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Cancel build and reset everything?",onClick:c=>c.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:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsx("h2",{style:{margin:0,color:"var(--text-primary)",fontSize:16,fontWeight:600},children:"Cancel build & reset everything?"}),t.jsxs("p",{style:{margin:0,color:"var(--text-secondary)",fontSize:13},children:["This stops the current build, clears the editor session, and"," ",t.jsx("strong",{style:{color:"var(--accent-red)"},children:"permanently discards uncommitted code changes"})," ","(back to the current commit). This cannot be undone."]}),t.jsx("p",{style:{margin:0,color:"var(--text-secondary)",fontSize:13},children:"Plans in the Plan tab are kept."}),r?t.jsx("p",{"data-testid":"reset-plan-kept-notice",style:{margin:0,padding:"8px 10px",borderRadius:6,border:"1px solid var(--accent-green, #3ecf8e)",color:"var(--text-primary)",fontSize:12},children:"A plan is being written in the Plan tab — it will be kept."}):null]}),t.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:6,color:"var(--text-secondary)",fontSize:12},children:["Type ",t.jsx("strong",{style:{color:"var(--text-primary)"},children:Lc})," to confirm",t.jsx("input",{type:"text",value:a,disabled:e,autoFocus:!0,"data-testid":"reset-confirm-input",onChange:c=>o(c.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"}})]}),t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[t.jsx("button",{type:"button",onClick:n,disabled:e,style:{padding:"8px 16px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-default)",borderRadius:6,fontSize:13,fontWeight:500,cursor:e?"wait":"pointer",opacity:e?.5:1,fontFamily:"inherit"},children:"Cancel"}),t.jsx("button",{type:"button",onClick:s,disabled:e||!i,"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:e?"wait":i?"pointer":"not-allowed",opacity:e||!i?.5:1,fontFamily:"inherit"},children:e?"Resetting…":"Reset everything"})]})]})})}const cie=Object.freeze(Object.defineProperty({__proto__:null,RESET_CONFIRM_WORD:Lc,ResetBuildConfirmModal:fP},Symbol.toStringTag,{value:"Module"}));function Iq(){const[e,n]=l.useState([]),[s,r]=l.useState(!0),[a,o]=l.useState(!1),[i,c]=l.useState(null),d=l.useRef(!1),{scenariosVersion:u}=Tn(),p=l.useCallback(async()=>{o(!0),d.current||r(!0),c(null);try{const f=await fetch("/api/scenarios");if(!f.ok)throw new Error(`HTTP ${f.status}`);const m=(await f.json()).map(zc);n(_T(m))}catch(f){c(f instanceof Error?f.message:"Failed to load scenarios")}finally{d.current=!0,o(!1),r(!1)}},[]);l.useEffect(()=>{p()},[p,u]);const h=e.reduce((f,m)=>f+m.scenarios.length,0);return{groups:e,loading:s,refreshing:a,error:i,totalScenarios:h,reload:p}}function Dq(e){if(Array.isArray(e))return{entities:e,unsurfacedPages:[],componentSurfaceReason:null};if(e&&typeof e=="object"){const n=e;return{entities:Array.isArray(n.entities)?n.entities:[],unsurfacedPages:Array.isArray(n.unsurfacedPages)?n.unsurfacedPages:[],componentSurfaceReason:Lq(n.componentSurfaceReason)}}return{entities:[],unsurfacedPages:[],componentSurfaceReason:null}}function Lq(e){if(!e||typeof e!="object")return null;const n=e.kind;return n==="no-component-scenarios"||n==="missing-from-glossary"||n==="not-visual-components"?e:null}function Fq(){const[e,n]=l.useState([]),[s,r]=l.useState([]),[a,o]=l.useState(null),[i,c]=l.useState(!0),[d,u]=l.useState(!1),[p,h]=l.useState(null),f=l.useRef(!1),{scenariosVersion:m}=Tn(),g=l.useCallback(async()=>{u(!0),f.current||c(!0),h(null);try{const x=await fetch("/api/app-route-entities");if(!x.ok)throw new Error(`HTTP ${x.status}`);const b=Dq(await x.json());n(b.entities.map(y=>({...y,scenarios:Array.isArray(y==null?void 0:y.scenarios)?y.scenarios.map(zc):[]}))),r(b.unsurfacedPages),o(b.componentSurfaceReason)}catch(x){h(x instanceof Error?x.message:"Failed to load app routes"),n([]),r([]),o(null)}finally{f.current=!0,u(!1),c(!1)}},[]);return l.useEffect(()=>{g()},[g,m]),{routeEntities:e,unsurfacedPages:s,componentSurfaceReason:a,loading:i,refreshing:d,error:p,reload:g}}const $q={prototype:"Prototype session",chat:"Chat"};function zq({building:e,build:n,activity:s,chatNeedsYou:r}){if(e)return{active:!0,label:n.label,status:n.status};const a=$q[s];return a?{active:!0,label:a,status:r?"waiting":"building"}:{active:!1,label:n.label,status:n.status}}function rg(e){const n=new Map;for(const s of e){const r=Bq(s.path);let a=n.get(r);a||(a=[],n.set(r,a));for(const o of s.tests)a.push({...o,file:s.path})}return Array.from(n.entries()).map(([s,r])=>({feature:s,tests:r})).filter(s=>s.tests.length>0).sort((s,r)=>s.feature.localeCompare(r.feature))}function Bq(e){const s=e.replace(/\\/g,"/").replace(/^\.\//,"").split("/").filter(r=>r.length>0);return s.length===0?"Other":s[0]==="crates"&&s.length>=2?`crates/${s[1]}`:e==="(no-file)"?"(no-file)":s[0]}function mP(e,n){if(n===".")return e;const s=n.endsWith("/")?n:`${n}/`;return e.map(r=>({feature:r.feature,tests:r.tests.filter(a=>a.file.startsWith(s))})).filter(r=>r.tests.length>0)}function gP(e,n,s){return s==="backend"?[]:e.map(r=>({...r,scenarios:r.scenarios.filter(co)})).filter(r=>r.scenarios.length>0)}function xP(e){let n=0,s=0,r=0,a=0,o=0;for(const i of e)for(const c of i.tests)o+=1,n+=1,c.status==="passed"?s+=1:c.status==="skipped"?a+=1:c.status==="failed"&&(r+=1);return{total:n,passed:s,failed:r,ignored:a,discovered:o}}function Wq(e){return e.reduce((n,s)=>n+s.scenarios.length,0)}const Hq=3e3;function qq(){const[e,n]=l.useState([]),[s,r]=l.useState(!0),[a,o]=l.useState(!1),[i,c]=l.useState(null),[d,u]=l.useState(!1),[p,h]=l.useState(null),[f,m]=l.useState(null),[g,x]=l.useState(null),b=l.useRef(null),y=l.useRef(null),v=l.useRef(!1),j=l.useRef(null),{testsVersion:_}=Tn(),w=l.useCallback(async(R=!1)=>{var W;(W=b.current)==null||W.abort();const I=new AbortController;b.current=I;const{signal:A}=I;R&&(v.current=!0,o(!0));const O=!R&&j.current!==null;O||(r(!0),c(null));try{if(!R&&!O)try{const E=await fetch("/api/test-results/summary",{signal:A});if(E.ok){const U=await E.json();U.running?h(U.currentRunner??null):U.stats&&(m(U.stats),x(U.coverage??null))}}catch{}let D,Y;if(O){D=j.current;const E=await fetch("/api/test-results",{signal:A});if(!E.ok)throw new Error(`test-results: HTTP ${E.status}`);Y=await E.json()}else if(R){const E=await fetch("/api/test-results/refresh",{method:"POST",signal:A});if(E.status===409){const U=await fetch("/api/test-results",{signal:A});if(!U.ok)throw new Error(`test-results: HTTP ${U.status}`);Y=await U.json()}else{if(!E.ok)throw new Error(`test-results: HTTP ${E.status}`);Y=await E.json()}D=j.current??[]}else{const[E,U]=await Promise.all([fetch("/api/tests",{signal:A}),fetch("/api/test-results",{signal:A})]);if(!E.ok)throw new Error(`tests: HTTP ${E.status}`);if(!U.ok)throw new Error(`test-results: HTTP ${U.status}`);D=rg(await E.json()),Y=await U.json(),j.current=D}if(h(Y.currentRunner??null),Y.running&&v.current){y.current=setTimeout(()=>w(!1),Hq);return}const H=v.current;if(v.current=!1,H){const E=await fetch("/api/tests",{signal:A});E.ok&&(D=rg(await E.json()),j.current=D)}n(D),u(Y.cached??!1),x(Y.coverage??null),m(null),r(!1),o(!1)}catch(D){if(D instanceof DOMException&&D.name==="AbortError")return;v.current=!1,c(D instanceof Error?D.message:"Failed to load tests"),r(!1),o(!1)}},[]);l.useEffect(()=>(j.current=null,w(),()=>{var R;(R=b.current)==null||R.abort(),y.current&&clearTimeout(y.current)}),[w,_]);const{total:k,passed:S,failed:N,ignored:C,discovered:T}=l.useMemo(()=>xP(e),[e]),P=l.useCallback(()=>{v.current||w(!0)},[w]);return{groups:e,loading:s,refreshing:a,error:i,cached:d,currentRunner:p,summaryStats:f,coverage:g,totalTests:k,passedTests:S,failedTests:N,ignoredTests:C,discoveredTests:T,reload:w,refresh:P}}function Wp(e,n){return e.filter(s=>s.appDir===n)}function bP(e,n){return n?e.find(s=>s.route===n)??null:null}function yP(e,n,s,r=null){const a=gP(e,n,s);return Gq(a,r)}function Uq(e){const n=e.filter(o=>o.defaultScenarioSlug);if(n.length===0)return null;const s=n.find(o=>o.route==="/"&&o.defaultScenarioSlug);if(s!=null&&s.defaultScenarioSlug)return s.defaultScenarioSlug;const r=n.find(o=>o.defaultScenarioSlug&&o.scenarios.some(i=>Fc(i)));if(r!=null&&r.defaultScenarioSlug)return r.defaultScenarioSlug;const a=[...n].sort((o,i)=>o.route.length-i.route.length||o.route.localeCompare(i.route))[0];return(a==null?void 0:a.defaultScenarioSlug)??null}function Yq(e){return(e==null?void 0:e.defaultScenarioSlug)??null}function vP(e,n,s=null){const r=e.find(a=>a.type==="web");return r?yP(n,r.dir,r.type,s):null}function Gq(e,n){const s=e.flatMap(d=>d.scenarios.filter(u=>co(u)).map(u=>({route:d.route,scenario:u})));if(s.length===0)return null;const r=ga(s.filter(({route:d,scenario:u})=>d==="/"&&Fc(u)),n);if(r)return r.scenario.slug;const a=ga(s.filter(({route:d})=>d==="/"),n);if(a)return a.scenario.slug;const o=ga(s.filter(({scenario:d})=>Fc(d)),n);if(o)return o.scenario.slug;const i=Math.min(...s.map(({route:d})=>d.length)),c=ga(s.filter(({route:d})=>d.length===i),n);return(c==null?void 0:c.scenario.slug)??null}function ga(e,n){return e.find(({scenario:s})=>Vq(s,n))??e[0]??null}function Vq(e,n){return n?e.dimensions.length===0||e.dimensions.includes(n):!0}function Fc(e){return/\bhome\b/i.test(e.name)}function ag(e){return new Set(e.flatMap(n=>n.scenarios.map(s=>s.slug)))}function Ji({selectedApp:e,appRouteEntities:n,scenarioGroups:s,defaultScreenSize:r=null}){return e?Uq(n)??yP(s,e.dir,e.type,r):null}function Kq({apps:e,hasExplicitAppSelection:n,scenarioGroups:s,defaultScreenSize:r=null}){return n||e.length===0||s.length===0?null:vP(e,s,r)}function og(e){return Yq(e)}function Jq({apps:e,routeEntities:n,selectedApp:s,appRouteEntities:r}){if(s)return r;const a=e.find(o=>o.type==="web");return a?Wp(n,a.dir):[]}function Xq({previewRouteEntities:e,selectedRouteEntity:n}){var r;if(n!=null&&n.route)return n.route;if(e.length===0)return null;const s=e.find(a=>a.route==="/");return s?s.route:((r=[...e].sort((a,o)=>a.route.length-o.route.length||a.route.localeCompare(o.route))[0])==null?void 0:r.route)??null}function Qq({previewRouteEntities:e,path:n}){var r;const s=Ms(n);return((r=bP(e,s))==null?void 0:r.defaultScenarioSlug)??null}function Zq(e){return e.startsWith("/scenario/")||yg(e)}function eU(e){const n=yE(e);return Zq(n)?!1:n==="/"||n==="/apps"||n==="/apps/"}function tU(e,n,s=""){const r=ki(s),[a,o]=l.useState(r.selectedAppDir),[i,c]=l.useState(r.selectedEntityHash);l.useEffect(()=>{const v=ki(s);o(j=>j===v.selectedAppDir?j:v.selectedAppDir),c(j=>j===v.selectedEntityHash?j:v.selectedEntityHash)},[s]),l.useEffect(()=>{if(typeof window>"u"||e.length!==1)return;const v=ki(s);if(v.selectedAppDir||v.selectedEntityHash||!eU(s))return;const j=`${Ni(e[0].dir)}${window.location.search}`;`${window.location.pathname}${window.location.search}`!==j&&(window.history.replaceState({},"",j),o(e[0].dir))},[e,s]);const d=l.useMemo(()=>i?n.find(v=>wl(v)===i)??null:null,[n,i]),u=l.useMemo(()=>a?e.find(v=>v.dir===a)??null:d?e.find(v=>v.dir===d.appDir)??null:i?e.find(v=>v.type==="web")??e[0]??null:null,[e,a,d,i]),p=l.useMemo(()=>u?Wp(n,u.dir):[],[n,u]),h=l.useMemo(()=>i?d:null,[i,d]);function f(v){if(typeof window>"u")return;const j=`${window.location.pathname}${window.location.search}`;v!==j&&window.history.pushState({},"",v)}function m(v){o(v),c(null),f(Ni(v))}function g(){o(null),c(null),f(cn("home"))}function x(v){const j=p.find(k=>k.route===v);if(!j)return;const _=wl(j),w=gv(j);!_||!w||(c(_),f(w))}function b(v){c(v),f(mv(v))}function y(){c(null),f(a?Ni(a):cn("home"))}return{selectedApp:u,appRouteEntities:p,selectedEntityHash:i,selectedRouteEntity:h,selectApp:m,deselectApp:g,selectRoute:x,selectEntity:b,deselectRoute:y}}function nU(e,n,s,r,a="",o=null,i=!0,c){const[d,u]=l.useState(null),p=l.useRef(!1),h=l.useRef(!1),{selectedApp:f,appRouteEntities:m,selectedEntityHash:g,selectedRouteEntity:x,selectApp:b,deselectApp:y,selectRoute:v,selectEntity:j,deselectRoute:_}=tU(e,n,a),w=l.useMemo(()=>ag(m),[m]),k=l.useMemo(()=>ag(x?[x]:[]),[x]),S=l.useMemo(()=>Ji({selectedApp:f,appRouteEntities:m,scenarioGroups:s,defaultScreenSize:o}),[m,o,s,f]),N=l.useMemo(()=>og(x),[x]),C=l.useMemo(()=>f?mP(r,f.dir):[],[r,f]);l.useEffect(()=>{if(p.current)return;if(c!=null&&c.current){p.current=!0;return}if(!i)return;const W=Kq({apps:e,scenarioGroups:s,hasExplicitAppSelection:!!f,defaultScreenSize:o});W&&(u(W),p.current=!0)},[e,o,s,f,i,c]),l.useEffect(()=>{if(f){if(h.current){h.current=!1;return}if(x){if(!N||d&&k.has(d))return;u(N);return}S&&(d&&w.has(d)||u(S))}},[S,N,d,f,w,x,k]);function T(W){b(W);const D=e.find(H=>H.dir===W);if(!D)return;const Y=Ji({selectedApp:D,appRouteEntities:Wp(n,D.dir),scenarioGroups:s,defaultScreenSize:o});u(Y)}function P(){y(),u(vP(e,s,o))}function R(W){v(W);const D=og(bP(m,W));u(D)}const I=l.useCallback(W=>{h.current=!0,u(W)},[]);function A(){if(_(),!f)return;const W=Ji({selectedApp:f,appRouteEntities:m,scenarioGroups:s,defaultScreenSize:o});W&&u(W)}function O(W){j(W)}return{selectedApp:f,appRouteEntities:m,appTestGroups:C,selectedEntityHash:g,selectedRouteEntity:x,previewSlug:d,setPreviewSlug:u,setPreviewSlugExplicit:I,selectApp:T,deselectApp:P,selectRoute:R,selectEntity:O,deselectRoute:A}}function sU(){const[e,n]=l.useState({}),[s,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;n(u),r(!1)}).catch(d=>{c||(o(d.message),r(!1))}),()=>{c=!0}},[]);const i=l.useMemo(()=>$D(e),[e]);return{graph:e,entityLookup:i,loading:s,error:a}}function Hp(e,n){if(!e)return null;for(const s of n)for(const r of s.scenarios)if(r.slug===e)return r;return null}function rU({apps:e,appRouteEntities:n,directPreviewPath:s,fallbackPort:r,previewKind:a,previewOrigin:o,previewSlug:i,routeEntities:c,scenarioGroups:d,selectedApp:u,selectedRouteEntity:p}){const h=Cy(d,i),f=Jq({apps:e,routeEntities:c,selectedApp:u,appRouteEntities:n}),m=Xq({previewRouteEntities:f,selectedRouteEntity:p}),g=e.length>0;let x="blank";a==="plan-preview"&&s?x="plan-preview":a==="results"&&s?x="results":a==="application"&&s?x=g||Md(s)?"application":"blank":h?g&&(x=co(h)?"application":"component"):m&&g&&(x="application");const b=$I({directPreviewPath:s,fallbackPreviewPath:m,previewKind:x,selectedScenario:h,port:r,previewOrigin:o});return{selectedScenario:h,previewRouteEntities:f,fallbackPreviewPath:m,resolvedPreviewKind:x,basePreviewUrl:b}}function aU({allowEditorRoutePreview:e,command:n,configLoaded:s,previewRouteEntities:r,scenarioGroups:a,scenarioDeferAvailable:o=!1}){const i=n.dimension??null,c=!!n.dimension,d=n.commandNonce;if(n.scenarioSlug??n.scenarioId){const x=n.scenarioSlug??n.scenarioId,b=Cy(a,x);return b?{clearCustomSize:c,scenarioSlug:b.slug,type:"show-scenario",viewportName:i,commandNonce:d}:o?{clearCustomSize:c,type:"defer",viewportName:i,commandNonce:d}:n.path?{clearCustomSize:c,path:n.path,previewKind:"application",previewSlug:null,preserveDirectPreviewPathOnSlugChange:!0,type:"show-path",viewportName:i,commandNonce:d}:{clearCustomSize:c,scenarioSlug:x,type:"show-scenario",viewportName:i,commandNonce:d}}if(!n.path)return{clearCustomSize:c,type:"refresh",viewportName:i,commandNonce:d};const u=n.path,p=u.startsWith("http")?new URL(u).pathname:u.split("?")[0]??u,h=p==="/results"||p.startsWith("/results/"),f=p==="/plan-preview",m=wy(u);if(Id(p))return{clearCustomSize:c,path:u,previewKind:"agent-html",previewSlug:null,preserveDirectPreviewPathOnSlugChange:!1,type:"show-path",viewportName:i,commandNonce:d};if(f)return{clearCustomSize:c,path:u,previewKind:"plan-preview",previewSlug:null,preserveDirectPreviewPathOnSlugChange:!1,type:"show-path",viewportName:i,commandNonce:d};if(h)return{clearCustomSize:c,path:u,previewKind:"results",previewSlug:null,preserveDirectPreviewPathOnSlugChange:!1,type:"show-path",viewportName:i,commandNonce:d};if(m&&!e)return{clearCustomSize:c,type:s?"ignore":"defer",viewportName:i,commandNonce:d};if(m&&e)return{clearCustomSize:c,path:u,previewKind:"application",previewSlug:null,preserveDirectPreviewPathOnSlugChange:!0,type:"show-path",viewportName:i,commandNonce:d};const g=Qq({previewRouteEntities:r,path:u});return g?{clearCustomSize:c,scenarioSlug:g,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 oU(e,n,s,r,a){const o=r.dimensions;return o.length===0||o.includes(e)&&n===null&&s===null?null:o.find(i=>a.some(c=>c.name===i))??o[0]}const iU=[{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 lU(e,n){const s=Object.entries(e);if(s.length===0)return iU;const r=s.map(([a,o])=>({name:a,width:o.width,height:o.height}));if(n){const a=r.findIndex(o=>o.name===n);if(a>0){const[o]=r.splice(a,1);r.unshift(o)}}return r}const cU=1500;function dU({enabled:e,pollMs:n=cU}){const[s,r]=l.useState(0),a=l.useRef(void 0);return l.useEffect(()=>{if(!e)return;let o=!1;const i=async()=>{try{const d=await fetch("/api/simulator-status");if(!d.ok)return;const u=await d.json();if(o)return;const p=u.state,h=a.current;a.current=p,p==="app-launched"&&h!==void 0&&h!=="app-launched"&&r(f=>f+1)}catch{}};i();const c=window.setInterval(i,n);return()=>{o=!0,window.clearInterval(c)}},[e,n]),s}function uU({isInIframe:e,hydrated:n=!0,persistedPath:s,previewKind:r,resolvedViewport:a,selectedScenario:o}){l.useEffect(()=>{e||!n||fetch("/api/editor-preview-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:r==="blank"?null:r,path:s,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(()=>{})},[n,e,s,r,a.height,a.name,a.width,o==null?void 0:o.id,o==null?void 0:o.slug])}function pU({deviceLaunchGeneration:e=0,isInIframe:n,onActivated:s,previewKind:r,previewMedium:a,scenariosLoaded:o,selectedScenario:i,seedRetryToken:c=0}){const[d,u]=l.useState(!1),[p,h]=l.useState(null),[f,m]=l.useState(null);return l.useEffect(()=>{if(!o||n)return;if(aR({isInIframe:n,previewKind:r,previewMedium:a,selectedScenario:i})){fetch("/api/editor-deactivate-scenario",{method:"POST"}).catch(()=>{});return}if(!i||i.scenarioType!=="application")return;let g=!1;return u(!0),h(null),m(null),fetch("/api/editor-activate-scenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:i.slug})}).then(async x=>{const b=await x.json().catch(()=>null);if(!g){if(!b||b.success===!1||b.seedError||b.deviceSeedError){h(b&&(b.seedError||b.deviceSeedError||b.error)||"scenario activation failed"),b!=null&&b.seedError?m("seed"):b!=null&&b.deviceSeedError||b!=null&&b.error?m("device"):m(null);return}s()}}).catch(x=>{g||(h(x instanceof Error?x.message:String(x)),m(null))}).finally(()=>{g||u(!1)}),()=>{g=!0}},[e,c,n,s,r,a,o,i==null?void 0:i.componentName,i==null?void 0:i.scenarioType,i==null?void 0:i.slug]),{seeding:d,seedError:p,seedErrorKind:f}}const hU=3;function fU({apps:e,appRouteEntities:n,configLoaded:s,defaultScreenSize:r,hydrated:a=!0,port:o,previewMedium:i,previewOrigin:c,projectTitle:d,previewSlug:u,routeEntities:p,scenarioGroups:h,scenariosLoaded:f,screenSizes:m,selectedApp:g,selectedRouteEntity:x,setPreviewSlug:b}){const[y,v]=l.useState(r??"Desktop"),j=l.useRef(!1),[_,w]=l.useState(null),[k,S]=l.useState(null),[N,C]=l.useState(null),[T,P]=l.useState(null),[R,I]=l.useState(()=>Date.now()),[A,O]=l.useState(0),W=l.useRef(null),D=l.useRef(!1),Y=l.useMemo(()=>lU(m,r),[r,m]);l.useEffect(()=>{j.current||r&&(v(r),j.current=!0)},[r]);const H=l.useMemo(()=>_!==null&&k!==null?{name:"Custom",width:_,height:k}:Y.find(he=>he.name===y)??Y[0]??{name:"Desktop",width:1440,height:900},[y,k,_,Y]),E=en(),U=d==="CodeYam Editor",{basePreviewUrl:M,fallbackPreviewPath:J,previewRouteEntities:ne,resolvedPreviewKind:oe,selectedScenario:ae}=l.useMemo(()=>rU({apps:e,appRouteEntities:n,directPreviewPath:N,fallbackPort:o,previewKind:T,previewOrigin:c,previewSlug:u,routeEntities:p,scenarioGroups:h,selectedApp:g,selectedRouteEntity:x}),[e,n,N,o,T,c,u,p,h,g,x]),G=l.useMemo(()=>M?zI(M,R):"",[M,R]),ie=l.useCallback(he=>{v(he),w(null),S(null)},[]),le=l.useCallback((he,ye)=>{w(he),S(ye)},[]),Z=l.useCallback(he=>{b(he),C(null),P(null),I(Date.now());const ye=Hp(he,h);if(!ye)return;const ve=oU(y,_,k,ye,Y);ve!==null&&(v(ve),w(null),S(null))},[y,k,_,h,b,Y]),z=l.useCallback((he,ye)=>{const ve=(ye==null?void 0:ye.retriesLeft)??hU,Ne=aU({allowEditorRoutePreview:U,command:he,configLoaded:s,previewRouteEntities:ne,scenarioGroups:h,scenarioDeferAvailable:ve>0});if(Ne.viewportName&&v(Ne.viewportName),Ne.clearCustomSize&&(w(null),S(null)),Ne.type==="show-scenario"){Z(Ne.scenarioSlug),O(de=>de+1);return}if(Ne.type==="defer"){W.current={command:he,retriesLeft:ve};return}if(Ne.type==="refresh"){I(Date.now()),O(de=>de+1);return}Ne.type!=="ignore"&&(Ne.type==="show-path"&&(P(Ne.previewKind),C(Ne.path),D.current=Ne.preserveDirectPreviewPathOnSlugChange,typeof Ne.previewSlug=="string"?b(Ne.previewSlug):Ne.previewSlug===null&&b(null)),I(Date.now()),O(de=>de+1))},[s,U,ne,h,b,Z]);l.useEffect(()=>{if(!s)return;const he=W.current;he&&(W.current=null,z(he.command,{retriesLeft:he.retriesLeft-1}))},[s,h,z]),l.useEffect(()=>{if(!(!u||N===null)){if(D.current){D.current=!1;return}C(null),P(null),I(Date.now())}},[N,u]);const L=l.useMemo(()=>oe==="results"||oe==="plan-preview"?N:oe==="application"?N??(ae==null?void 0:ae.url)??J:null,[N,J,oe,ae==null?void 0:ae.url]),q=l.useCallback(()=>{I(Date.now())},[]),[se,fe]=l.useState(0),we=l.useCallback(()=>{fe(he=>he+1)},[]);uU({isInIframe:E,hydrated:a,persistedPath:L,previewKind:oe,resolvedViewport:H,selectedScenario:ae?{id:ae.id??null,slug:ae.slug}:null});const Fe=dU({enabled:i==="simulator-ios"||i==="simulator-android"}),{seeding:Me,seedError:ee,seedErrorKind:Q}=pU({deviceLaunchGeneration:Fe,seedRetryToken:se,isInIframe:E,onActivated:q,previewKind:oe,previewMedium:i,scenariosLoaded:f,selectedScenario:ae?{slug:ae.slug,scenarioType:ae.scenarioType,componentName:ae.componentName??null}:null}),te=l.useCallback(he=>{he!==null&&(D.current=!0,Md(he)&&b(null)),C(he),P(he?"application":null),I(Date.now())},[b]);return{viewports:Y,resolvedViewport:H,previewUrl:G,handleViewportChange:ie,handleCustomSizeChange:le,showScenarioPreview:Z,handlePreviewCommand:z,setPreviewPath:te,previewSeeding:Me,previewSeedError:ee,previewSeedErrorKind:Q,retrySeed:we,commandNonce:A}}const mU=15e3;function Xi(){fetch("/api/editor-tab-heartbeat",{method:"POST"}).catch(()=>{})}function gU(e){l.useEffect(()=>{if(e)return;Xi();const n=setInterval(Xi,mU),s=()=>{document.visibilityState==="visible"&&Xi()};return document.addEventListener("visibilitychange",s),()=>{clearInterval(n),document.removeEventListener("visibilitychange",s)}},[e])}function qp(e){return e===null||e.slug===null||e.slug==="feature-complete"}function xU({showPostPushModal:e,stepState:n,dismissModal:s}){const r=l.useRef(!1);l.useEffect(()=>{if(!e){r.current=!1;return}if(qp(n)){r.current=!0;return}r.current&&(n==null?void 0:n.slug)!=null&&(s(),r.current=!1)},[e,n,s])}function bU({sessionInfo:e,stepState:n,showPostPushModal:s,onFeatureCompleteCommand:r}){const a=l.useRef(null);l.useEffect(()=>{const o=(e==null?void 0:e.cycleClosed)??null;if(!o)return;const i=`${o.closedAt??"unknown"}|${o.reshownAt??""}`;if(a.current!==i){if(s){a.current=i;return}qp(n)&&(a.current=i,r(o.summary??void 0))}},[e,n,s,r])}function yU(e,n){return e&&qp(n)}function vU({plans:e,completedPlans:n,isAgentBuilding:s,onLaunch:r}){const{claims:a}=jp(),{status:o}=wp(),i=((o==null?void 0:o.consecutiveFailures)??0)>=3,c=l.useMemo(()=>Sp(a),[a]),{annotationsBySlug:d,dependenciesBySlug:u}=kp(e),p=l.useMemo(()=>pN([...e.map(m=>m.author),...n.map(m=>m.author)]),[e,n]),{requestRun:h,gateModals:f}=ai({dependenciesBySlug:u,claimsBySlug:c,isAgentBuilding:s,onLaunch:r});return{claimsBySlug:c,staleFetch:i,annotationsBySlug:d,dependenciesBySlug:u,showAuthors:p,requestRun:h,gateModals:f}}function jU(){const{showBuildTab:e}=Np(typeof window>"u"?"/":window.location.pathname),{config:n}=St(),[s,r]=l.useState(!1),[a,o]=l.useState(null),i=l.useCallback(async c=>{if(s)return!1;o(null),r(!0);try{const d=await gN();try{await fN(),Xk()}catch{}const u=await fetch("/api/build/start-from-prompt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:c})});if(!u.ok){let p=`HTTP ${u.status}`;try{const h=await u.json();h!=null&&h.error&&(p=h.error)}catch{}throw new Error(p)}return e(),await mN({provider:n==null?void 0:n.provider,serverOwnsLaunch:d===!1}),!0}catch(d){return o(d instanceof Error?d.message:"Failed to launch build"),!1}finally{r(!1)}},[s,e,n==null?void 0:n.provider]);return{launching:s,error:a,launchPrompt:i}}function wU(e,n,s){return e.map(r=>{const a=mP(n,r.dir),o=gP(s,r.dir,r.type),{total:i,passed:c,failed:d,ignored:u,discovered:p}=xP(a),h=Wq(o);return{app:r,tests:{total:i,passed:c,failed:d,ignored:u,discovered:p},scenarios:{total:h,thumbnails:_U(o)}}})}function _U(e){const n=[];for(const s of e)for(const r of s.scenarios)if(r.screenshotPaths.length>0&&n.push({path:r.screenshotPaths[0],cacheBuster:r.screenshotCapturedAtMs}),n.length>=6)return n;return n}const SU="Your app will display here once set up.",kU="Loading your app…",NU="Setting up your project…",CU="Select a scenario to preview",TU="No preview is available for this project.";function PU({configLoading:e,hasNoApps:n,hasStepState:s,hasPreviewableApp:r,setupInProgress:a,hasCaptureFrame:o}){return e?kU:a&&!o?NU:n&&!s?SU:r?CU:TU}const OU=["web","mobile"];function RU(e){return OU.includes(e)}function EU(e,n){return n?{scenarioSlug:e,path:n}:{scenarioSlug:e}}function AU(e,n){return e==="needs-login"&&!n}function jP(e){return!e.hasActiveSession&&!e.isAgentBuilding&&!e.showPostPushModal&&e.launchingPlanSlug===null&&!e.submittingBuildPrompt&&!e.stepStateFeature&&!e.buildLaunchModalDismissed}function wP(e){return e.activeTab==="build"&&!e.buildActivityInFlight&&!e.buildActivityMinimized&&!e.buildHandoffPending&&jP(e)}function MU(e){return e.buildActivityMinimized&&wP({...e,buildActivityMinimized:!1})}function IU(e){const[n,s]=l.useState("menu"),[r,a]=l.useState(!1),o=l.useCallback(f=>{s(f),a(!0)},[]),i=l.useCallback(()=>{s("session"),a(!1)},[]),c=l.useCallback(()=>{s("menu"),a(!1)},[]),d=l.useCallback(()=>a(!0),[]),u=l.useCallback(()=>a(!1),[]),p=l.useCallback(f=>{if(f==="plan"){e==null||e();return}s(m=>f==="prototype"&&m==="chat"?m:f),a(f!=="menu")},[e]),h=l.useCallback(f=>{s(f),a(!0)},[]);return{activity:n,minimized:r,hasLiveActivity:n==="prototype"||n==="chat",chooseActivity:o,startSession:i,finishActivity:c,minimize:d,reopen:u,applyCommand:p,restore:h}}function DU({currentActivity:e,alreadyHydrated:n,buildSessionOwnsTab:s,liveBuildActivity:r}){return n||s||e!=="menu"?null:r}function LU(e,n){fetch("/api/build-activity-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({activity:e,escalated:n})}).catch(()=>{})}function FU({buildActivity:e,sessionInfo:n,buildSessionOwnsTab:s,chatEscalatedToPrototype:r,setChatEscalatedToPrototype:a}){const[o,i]=l.useState(!1),c=l.useRef(null),{activity:d,restore:u}=e;l.useEffect(()=>{if(o||!n)return;const p=DU({currentActivity:d,alreadyHydrated:o,buildSessionOwnsTab:s,liveBuildActivity:n.liveBuildActivity??null});if(p){const h=p.activity==="chat"&&p.escalated;u(p.activity),a(h),c.current=Qi(p.activity,h)}else c.current=Qi("menu",!1);i(!0)},[o,n,d,s,u,a]),l.useEffect(()=>{if(!o)return;const p=Qi(d,r);p!==c.current&&(c.current=p,LU(d,r))},[o,d,r])}function Qi(e,n){return`${e}:${n}`}const $U=900*1e3;function zU(){const[e,n]=l.useState(null),s=l.useCallback(async()=>{try{const r=await fetch("/api/server/update-check");if(!r.ok)return;const a=await r.json();n(a)}catch{}},[]);return l.useEffect(()=>{s()},[s]),l.useEffect(()=>{const r=setInterval(()=>void s(),$U);return()=>clearInterval(r)},[s]),{update:e}}const BU=8e3;function WU(e,n=BU){const[s,r]=l.useState(null),[a,o]=l.useState(null);l.useEffect(()=>{if(e===null)return;const d=setTimeout(()=>o(e),n);return()=>clearTimeout(d)},[e,n]);const i=l.useCallback(()=>r(e),[e]);return{visible:e!==null&&s!==e&&a!==e,dismiss:i}}function HU(e,n,s){const[r,a]=l.useState(!1),o=l.useCallback(()=>{a(!0)},[]),i=l.useCallback(c=>{a(!1),n(c)},[n]);return l.useEffect(()=>{r&&(e||(a(!1),s==null||s(),n("build")))},[r,e,n,s]),{arm:o,navigateToTabUser:i,pendingBuildNav:r}}function qU(e,n){const[s,r]=l.useState(!1),[a,o]=l.useState(!1),i=l.useCallback(()=>{r(!0),o(!1)},[]),{arm:c,navigateToTabUser:d,pendingBuildNav:u}=HU(e,n,i),[p,h]=l.useState(null),{visible:f,dismiss:m}=WU(p),g=l.useCallback(()=>{o(!0),h(Date.now()),n("build")},[n]);l.useEffect(()=>{if(!a)return;const b=setTimeout(()=>o(!1),6e4);return()=>clearTimeout(b)},[a]);const x=l.useCallback(()=>d("build"),[d]);return{buildLaunchModalDismissed:s,setBuildLaunchModalDismissed:r,buildHandoffPending:a,armPendingBuildNav:c,navigateToTabUser:d,pendingBuildNav:u,designReturnVisible:f,dismissDesignReturn:m,handleDesignConfirmed:g,handleAuthorizeToBuild:x}}function UU(){const[e,n]=l.useState(0),[s,r]=l.useState(0),[a,o]=l.useState(0),[i,c]=l.useState(0),[d,u]=l.useState(0);return{showResultsCommandKey:e,setShowResultsCommandKey:n,hideResultsCommandKey:s,setHideResultsCommandKey:r,featureCompleteKey:a,setFeatureCompleteKey:o,prototypeLaunchKey:i,setPrototypeLaunchKey:c,planCompleteKey:d,setPlanCompleteKey:u}}function YU(){const[e,n]=l.useState(!1),[s,r]=l.useState(void 0),a=l.useCallback(d=>{r(d),n(!0)},[]),o=l.useCallback(()=>{},[]),i=l.useCallback(()=>{},[]),c=l.useCallback(()=>{n(!1),r(void 0)},[]);return{showPostPushModal:e,featureSummary:s,onFeatureCompleteCommand:a,onAgentIdle:o,onAgentActive:i,dismissModal:c}}function GU(){const[e,n]=l.useState(!1),s=l.useCallback(()=>{n(!0)},[]),r=l.useCallback(()=>{n(!1)},[]);return{showPlanCompleteModal:e,onPlanCompleteCommand:s,dismissPlanCompleteModal:r}}function VU(){const{showPostPushModal:e,featureSummary:n,onFeatureCompleteCommand:s,onAgentIdle:r,onAgentActive:a,dismissModal:o}=YU(),i=l.useCallback(()=>{o(),fetch("/api/cycle-closed-ack",{method:"POST"}).catch(()=>{})},[o]),{showPlanCompleteModal:c,onPlanCompleteCommand:d,dismissPlanCompleteModal:u}=GU(),[p,h]=l.useState(!1),[f,m]=l.useState(!1),[g,x]=l.useState(!1),[b,y]=l.useState(!1),[v,j]=l.useState(!1);l.useEffect(()=>{const N=()=>j(!0);return window.addEventListener(ec,N),()=>window.removeEventListener(ec,N)},[]);const[_,w]=l.useState(!1),k=l.useCallback(()=>{x(!0)},[]),S=l.useCallback(()=>{x(!1)},[]);return{showPostPushModal:e,featureSummary:n,onFeatureCompleteCommand:s,handleAgentIdle:r,handleAgentActive:a,dismissModal:i,showPlanCompleteModal:c,onPlanCompleteCommand:d,dismissPlanCompleteModal:u,planChatOpen:p,setPlanChatOpen:h,selectPlanOpen:f,setSelectPlanOpen:m,showTranscriptModal:g,rawTerminalOpen:b,setRawTerminalOpen:y,resetModalOpen:v,setResetModalOpen:j,resetBusy:_,setResetBusy:w,handleSendTranscript:k,handleCloseTranscript:S}}const ws=300,ig=150;function KU(e,n=.5){const[s,r]=l.useState(null),a=l.useRef(!1),[o,i]=l.useState(!1),c=l.useCallback(()=>{var m;return((m=e.current)==null?void 0:m.clientWidth)??1200},[e]),d=l.useCallback(m=>Math.max(ws,Math.floor(m*n)),[n]),u=s??d(c()),p=l.useCallback(m=>{m.preventDefault(),a.current=!0,i(!0)},[]);l.useEffect(()=>{const m=x=>{var j;if(!a.current)return;const b=((j=e.current)==null?void 0:j.getBoundingClientRect().left)??0,y=x.clientX-b,v=c();y<ig?r(0):y>v-ig?r(v):r(Math.max(ws,y))},g=()=>{a.current&&(a.current=!1,i(!1))};return document.addEventListener("mousemove",m),document.addEventListener("mouseup",g),()=>{document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",g)}},[e,c]);const h=l.useCallback(()=>r(null),[]),f=l.useCallback(m=>{const g=c();r(x=>{const b=x??d(g),y=Math.max(ws,g-ws);return Math.min(y,Math.max(ws,b+m))})},[c,d]);return{leftWidth:u,isDragging:o,handleMouseDown:p,resetWidth:h,nudgeWidth:f,minWidth:ws}}const JU=1/3;function XU(e){const[n,s]=l.useState(!1),[r,a]=l.useState(!1),o=l.useRef(null),[i,c]=l.useState(!1),{leftWidth:d,handleMouseDown:u,isDragging:p,resetWidth:h,nudgeWidth:f,minWidth:m}=KU(o,i?JU:.5),g=GS(768),[x,b]=l.useState("editor"),y=l.useCallback(k=>{b(k),k==="editor"&&(_t(),typeof window<"u"&&window.dispatchEvent(new Event("resize")))},[]),[v,j]=l.useState(!1);l.useEffect(()=>{!e&&v&&j(!1)},[e,v]);const _=l.useCallback(()=>{s(k=>!k)},[]),w=l.useCallback(()=>{a(k=>!k)},[]);return{isCollapsed:n,setIsCollapsed:s,isFilled:r,setIsFilled:a,splitRef:o,setSessionSplit:c,leftWidth:d,handleMouseDown:u,isResizing:p,resetWidth:h,nudgeWidth:f,leftWidthMin:m,isNarrow:g,mobilePane:x,setMobilePane:b,handleMobilePaneChange:y,homeLivePageOpen:v,setHomeLivePageOpen:j,handleToggleCollapsed:_,handleToggleFilled:w}}function QU({previewSlug:e,previewUrl:n,setPreviewPath:s,showScenarioPreview:r,showPreviewPane:a,releasePreviewPane:o}){const[i,c]=l.useState(null),d=l.useRef({slug:null,path:""});d.current={slug:e,path:n};const u=l.useRef(null),p=l.useCallback(m=>{Ms(d.current.path)!==dr&&(u.current=d.current),c(m),s(dr),a()},[s,a]),h=l.useCallback(m=>{Ma(`The ${m.envVar} value has been saved (available to the app as ${m.envVar}).`)},[]),f=l.useCallback(()=>{const m=u.current;if(u.current=null,c(null),o(),m!=null&&m.slug){r(m.slug);return}const g=m?Ms(m.path):"";s(g&&g!==dr?g:null)},[o,s,r]);return{credentialTarget:i,openCredentialRequest:p,handleCredentialStored:h,handleCloseCredentialRequest:f}}function ZU({isHomeTab:e,homeLivePageOpen:n,setHomeLivePageOpen:s,setMobilePane:r,setIsCollapsed:a,previewSlug:o,previewUrl:i,setPreviewPath:c,showScenarioPreview:d}){const u=l.useRef(!1),p=l.useCallback(()=>{r("preview"),a(!1),e&&!n&&(u.current=!0,s(!0))},[e,n]),h=l.useCallback(()=>{u.current&&(u.current=!1,s(!1))},[]);return QU({previewSlug:o,previewUrl:i,setPreviewPath:c,showScenarioPreview:d,showPreviewPane:p,releasePreviewPane:h})}function eY({onTransitionToLive:e}){const[n,s]=l.useState(!1),[r,a]=l.useState(null),o=l.useRef(!1),i=l.useRef(null),c=l.useRef(e);c.current=e;const d=l.useCallback(()=>{o.current=!0,s(!0)},[]),u=l.useCallback(()=>{o.current=!1,s(!1);const m=i.current;m&&(i.current=null,a(null),c.current(m))},[]),p=l.useCallback(m=>o.current?(i.current=m,a(m),!0):!1,[]),h=l.useCallback(()=>{i.current=null,a(null)},[]),f=l.useCallback(()=>{o.current=!1,s(!1),i.current=null,a(null)},[]);return{isAgentBuilding:n,isAgentBuildingRef:o,buildingScenarioSlug:r,onAgentIdle:u,onAgentActive:d,guardScenarioSelect:p,clearBuildingOverlay:h,forceIdle:f}}function tY({chatOpen:e}){const[n,s]=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)&&(s(!0),a(!1))}function c(d){o(d)&&(s(!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(()=>{e||(s(!1),a(!1))},[e]),{planActive:n,planIdle:r}}const nY=1e4;function sY(e){const{isAgentBuilding:n,submittingBuildPrompt:s,launchingPlanSlug:r,sessionInfo:a,stepFeature:o,refetchSessionInfo:i}=e,[c,d]=l.useState(!1),u=l.useRef(!1),p=l.useCallback((f,m)=>{u.current!==f&&(pe("build-session-live-change",{from:u.current,to:f,trigger:m}),u.current=f,d(f))},[]);return l.useEffect(()=>{n&&p(!0,"agent-active")},[n,p]),l.useEffect(()=>{s&&p(!0,"launch-prompt")},[s,p]),l.useEffect(()=>{r!==null&&p(!0,"launch-plan")},[r,p]),l.useEffect(()=>{((a==null?void 0:a.resumeMode)==="resume"||(a==null?void 0:a.resumeMode)==="handoff")&&p(!0,"resumable-session-detected")},[a,p]),l.useEffect(()=>{(a==null?void 0:a.agentBrokerLive)===!0&&p(!0,"broker-live-detected")},[a,p]),l.useEffect(()=>{a&&!a.hasSession&&!a.agentBrokerLive&&p(!1,"session-ended")},[a,p]),l.useEffect(()=>{if(!c)return;const f=setInterval(()=>{i()},nY);return()=>clearInterval(f)},[c,i]),{buildSessionLive:c,agentActivelyBuilding:c&&(!!o||n||s||r!==null),transitionBuildSessionLive:p}}function rY(e){const n=l.useRef(null),s=l.useRef(null);l.useEffect(()=>{if(typeof document>"u")return;s.current||(s.current=document.createElement("canvas"),s.current.width=64,s.current.height=64);const r=document.querySelector('link[rel="icon"]');if(!r){pe("favicon-redraw",{idle:e,hasIcon:!1});return}if(n.current||(n.current=r.href),!e){r.href=n.current,pe("favicon-restore",{});return}pe("favicon-redraw",{idle:!0,hasIcon:!0});const a=new Image;a.crossOrigin="anonymous",a.onload=()=>{const o=s.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,p=64-u-1,h=u+1;i.beginPath(),i.arc(p,h,u,0,2*Math.PI),i.fillStyle=it,i.fill(),r.href=o.toDataURL("image/png")},a.src=n.current},[e]),l.useEffect(()=>()=>{if(typeof document>"u")return;const r=document.querySelector('link[rel="icon"]');r&&n.current&&(r.href=n.current)},[])}function aY(e,n){return new y$({playSound:ju,showSystemNotification:()=>{if(typeof Notification>"u"||Notification.permission!=="granted")return;n.current&&n.current.close();const s=e.current,r=new Notification(`${s} is ready for you`,{body:`${s} has finished and is waiting for your input.`,tag:"build-agent-idle"});r.onclick=()=>{window.focus(),r.close(),n.current=null},n.current=r},closeSystemNotification:()=>{typeof Notification>"u"||n.current&&(n.current.close(),n.current=null)}},{hasBrowserFocus:()=>document.hasFocus(),hasNotificationPermission:()=>typeof Notification<"u"&&Notification.permission==="granted"})}function oY(e,n){return e==="hook-stop"?n.idleOnStop:n.idleOnNotification}const iY=600*1e3,lY=3e3;function cY({agentName:e,isBuildTabActive:n,isAgentBuilding:s,buildSessionLive:r,featureCompleteKey:a,navigateToTab:o,onAgentIdleImmediate:i,onAgentActiveImmediate:c}){const d=l.useRef(e);d.current=e;const u=l.useRef(n);u.current=n;const p=l.useRef(i);p.current=i;const h=l.useRef(c);h.current=c;const[f,m]=l.useState(o0),[g,x]=l.useState(!1),b=l.useRef(!1);b.current=g;const[y,v]=l.useState(!1),j=l.useRef(!1),_=l.useRef(null),w=l.useRef(null),k=l.useRef(null),S=l.useRef(typeof document<"u"&&document.hidden?Date.now():null),N=l.useRef(null),C=l.useRef(r??!1);C.current=r??!1,rY(g),k.current||(k.current=aY(d,w));const T=l.useCallback(M=>{m(M),i0(M)},[]),P=l.useCallback(M=>{_.current!==null&&(clearTimeout(_.current),_.current=null,pe("debounce-cancelled",{trigger:M}))},[]),R=l.useCallback(M=>{b.current&&pe("idle-cleared",{trigger:M}),x(!1),b.current=!1,v(!1),N.current=null,w.current&&(w.current.close(),w.current=null)},[]);l.useEffect(()=>DS(()=>{ql()&&b.current&&R("chat-working")}),[R]);const I=l.useCallback((M,J)=>{var ne;if(!oY(M,f)){pe("idle-suppressed-by-pref",{source:M,blocked:J});return}pe("ws-idle-received",{buildTabActive:u.current,source:M,blocked:J}),(ne=p.current)==null||ne.call(p),P("re-arm-on-idle"),_.current=setTimeout(()=>{var ie;if(_.current=null,ql()){pe("idle-suppressed-chat-working",{source:M,blocked:J});return}const oe=S.current,ae=oe===null?null:Date.now()-oe,G=oe!==null&&Date.now()-oe>iY;pe("debounce-resolved",{suppressedForOvernight:G,msHidden:ae,buildTabActive:u.current}),G||(ie=k.current)==null||ie.onIdle(f,u.current),x(!0),b.current=!0,v(J),N.current=Date.now(),j.current=!1,pe("agent-currently-idle-set",{suppressedForOvernight:G,blocked:J}),u.current&&_t()},hr)},[f,P]),A=l.useCallback(M=>I(M,!1),[I]),O=l.useCallback(M=>I(M,!0),[I]),W=l.useCallback(()=>{var M,J,ne;(M=h.current)==null||M.call(h),P("agent-active"),(J=k.current)==null||J.onActive(),(ne=k.current)==null||ne.resetActivityFlag(),b.current&&C.current&&N.current!==null&&Date.now()-N.current>lY&&R("remote-resume")},[P,R]),D=l.useCallback(()=>{var M,J;P("user-input"),b.current&&((M=k.current)==null||M.onUserEngagement(),(J=k.current)==null||J.reportUserActivity("terminal-input"),j.current=!0,R("user-input"))},[P,R]),Y=l.useCallback(M=>{var J;M==="build"&&(P("navigate-build"),b.current&&((J=k.current)==null||J.onUserEngagement(),j.current=!0,R("navigate-build"))),o(M)},[o,P,R]),H=l.useCallback(()=>{var M;P("dismiss-banner"),(M=k.current)==null||M.onUserEngagement(),j.current=!0,R("dismiss-banner")},[P,R]),E=l.useCallback(()=>{var M;P("stop-building"),(M=k.current)==null||M.onUserEngagement(),j.current=!0,R("stop-building")},[P,R]);l.useEffect(()=>{function M(){var Z;b.current&&(j.current||(P("ack-notification"),(Z=k.current)==null||Z.onUserEngagement(),j.current=!0,pe("notification-acknowledged",{trigger:"user-return"})))}function J(Z){var z;b.current&&u.current&&document.hasFocus()&&(document.hidden||((z=k.current)==null||z.onUserEngagement(),j.current=!0,R(Z)))}function ne(Z){var z;document.hasFocus()&&M(),(z=k.current)==null||z.reportUserActivity(Z)}const oe=()=>ne("mousemove"),ae=()=>ne("mousedown"),G=()=>ne("keydown");function ie(){document.hidden?S.current===null&&(S.current=Date.now()):(S.current=null,M(),J("tab-visible-on-build"))}function le(){var Z;M(),J("window-focus-on-build"),(Z=k.current)==null||Z.reportUserActivity("focus")}return window.addEventListener("focus",le),document.addEventListener("visibilitychange",ie),document.addEventListener("mousemove",oe),document.addEventListener("mousedown",ae),document.addEventListener("keydown",G),()=>{P("unmount"),window.removeEventListener("focus",le),document.removeEventListener("visibilitychange",ie),document.removeEventListener("mousemove",oe),document.removeEventListener("mousedown",ae),document.removeEventListener("keydown",G)}},[P,R]);const U=l.useRef(a??0);return l.useEffect(()=>{var ne;const M=a??0;if(M===U.current)return;U.current=M;const J=u.current&&document.hasFocus();pe("feature-complete-fast-path",{skipBecauseWatching:J}),!J&&((ne=k.current)==null||ne.onIdle(f,!1),x(!0),b.current=!0,N.current=Date.now(),j.current=!1)},[a,f]),l.useEffect(()=>{var M,J;if((M=k.current)==null||M.onBuildTabChange(n,f),n)return b.current&&typeof document<"u"&&document.hasFocus()&&!document.hidden&&((J=k.current)==null||J.onUserEngagement(),j.current=!0,R("build-tab-active-on-focus")),_t()},[n,f,R]),{buildIdle:g,agentBlocked:y,bannerVisible:g,notifSettings:f,handleSettingsChange:T,handleAgentIdle:A,handleAgentBlocked:O,handleAgentActive:W,handleUserInput:D,handleNavigateToTab:Y,dismissIdleBanner:H,clearIdleForStopBuilding:E}}function dY(e){return e.agentActivelyBuilding||e.buildSessionLive&&e.hasCurrentStep?"building":e.buildRequestState==="failed"?"failed":e.buildRequestState==="interrupted"?"interrupted":e.buildRequestState==="unverified"?"unconfirmed":e.buildRequestState==="waiting-for-auth"?"waiting-for-auth":e.buildRequestState==="launch-timeout"?"launch-timeout":e.buildRequestState==="delayed"?"launch-delayed":e.buildRequestState==="dispatching"||e.pendingBuildNavArmed?"preparing":e.brokerReachable===!1?"unconfirmed":e.hasSavedSession&&!e.buildSessionLive?"interrupted":"not-started"}function uY({activeTab:e,config:n,stepState:s,sessionInfo:r,refetchSessionInfo:a,showScenarioPreview:o,planChatOpen:i,submittingBuildPrompt:c,pendingBuildNav:d,buildHandoffPending:u,featureCompleteKey:p,navigateToTabUser:h,handleAgentIdle:f,handleAgentActive:m}){const{isAgentBuilding:g,isAgentBuildingRef:x,buildingScenarioSlug:b,onAgentIdle:y,onAgentActive:v,guardScenarioSelect:j,clearBuildingOverlay:_,forceIdle:w}=eY({onTransitionToLive:o}),{planActive:k,planIdle:S}=tY({chatOpen:i}),N=(r==null?void 0:r.resumeMode)==="resume"||(r==null?void 0:r.resumeMode)==="handoff",{launchPlan:C,launchingSlug:T,error:P}=xN({launchAnchored:N||!!(s!=null&&s.feature)}),{buildSessionLive:R,agentActivelyBuilding:I,transitionBuildSessionLive:A}=sY({isAgentBuilding:g,submittingBuildPrompt:c,launchingPlanSlug:T,sessionInfo:r,stepFeature:(s==null?void 0:s.feature)??null,refetchSessionInfo:a}),O=Uo(),W=dY({buildRequestState:(O==null?void 0:O.state)??null,buildSessionLive:R,agentActivelyBuilding:I,hasCurrentStep:(r==null?void 0:r.step)!=null,hasSavedSession:!!(r!=null&&r.hasSession)&&(r==null?void 0:r.resumeMode)!=="completed",brokerReachable:(r==null?void 0:r.brokerDaemonReachable)??null,pendingBuildNavArmed:d||u});l.useEffect(()=>{g&&r&&!r.hasSession&&!r.agentBrokerLive&&w()},[g,r,w]),l.useEffect(()=>{ri({hasActiveSession:N,isAgentBuilding:g,stepStateFeature:(s==null?void 0:s.feature)??null})},[N,g,s==null?void 0:s.feature]);const D=l.useCallback(()=>{f(),y()},[f,y]),Y=l.useCallback(()=>{m(),v()},[m,v]),H=(n==null?void 0:n.provider)??nE,E=Qe(H),{buildIdle:U,agentBlocked:M,bannerVisible:J,notifSettings:ne,handleSettingsChange:oe,handleAgentIdle:ae,handleAgentBlocked:G,handleAgentActive:ie,handleUserInput:le,handleNavigateToTab:Z,dismissIdleBanner:z,clearIdleForStopBuilding:L}=cY({agentName:E,isBuildTabActive:e==="build",isAgentBuilding:g,buildSessionLive:R,featureCompleteKey:p,navigateToTab:h,onAgentIdleImmediate:D,onAgentActiveImmediate:Y});return{isAgentBuilding:g,isAgentBuildingRef:x,buildingScenarioSlug:b,guardScenarioSelect:j,clearBuildingOverlay:_,planActive:k,planIdle:S,hasActiveSession:N,launchPlan:C,launchingPlanSlug:T,planLaunchError:P,agentActivelyBuilding:I,transitionBuildSessionLive:A,emptyStateBuildStatus:W,provider:H,agentName:E,buildIdle:U,agentBlocked:M,bannerVisible:J,notifSettings:ne,handleSettingsChange:oe,handleIdleSignalIdle:ae,handleIdleSignalBlocked:G,handleIdleSignalActive:ie,handleIdleSignalUserInput:le,handleNavigateToTab:Z,dismissIdleBanner:z,clearIdleForStopBuilding:L}}function pY(e,n){return e==null?null:Math.min(1,Math.max(.04,e/_u(n)))}function hY(e,n){return e==null||e===0?null:`${e}/${_u(n)}`}function fY(e,n){var r;if(n==null||!Number.isFinite(n))return null;let s=null;for(const a of e??[]){const o=(r=a.screenshotPaths)==null?void 0:r[0];if(!o)continue;const i=a.screenshotCapturedAtMs;i==null||i<n||(!s||i>s.at)&&(s={path:o,at:i})}return(s==null?void 0:s.path)??null}const mY=new Set(["ui-confirm-plan","backend-confirm-plan","present-live","backend-confirm","ui-present","backend-review"]);function gY(e,n,s=!1){return s&&!n?"building":e&&mY.has(e)?"needs-input":n?"waiting":"building"}function xY({stepState:e,buildIdle:n,isAgentBuilding:s,completedPlans:r,scenarioGroups:a}){var f;const o=l.useMemo(()=>gY(e==null?void 0:e.slug,n,s),[e==null?void 0:e.slug,n,s]),i=e?C0(e.step,e.mode):null,c=l.useMemo(()=>pY(e==null?void 0:e.step,e==null?void 0:e.mode),[e==null?void 0:e.step,e==null?void 0:e.mode]),d=e?hY(e.step,e.mode):null,u=((f=r[0])==null?void 0:f.title)??null,p=l.useMemo(()=>{const m=Date.parse((e==null?void 0:e.featureStartedAt)||(e==null?void 0:e.startedAt)||"");return Number.isNaN(m)?null:m},[e==null?void 0:e.featureStartedAt,e==null?void 0:e.startedAt]),h=l.useMemo(()=>fY(a.flatMap(m=>m.scenarios),p),[a,p]);return{buildingStatus:o,buildingStepLabel:i,buildingProgress:c,buildingStepPosition:d,lastBuiltLabel:u,buildingThumbnailPath:h}}function bY(e,n){if(!e)return null;for(const s of n)for(const r of s.scenarios)if(r.name===e)return r;return null}const yY="The app is being edited",vY="Live preview will load when the build agent is idle",jY="Showing a saved version",wY="This is a past version of this scenario";function _Y({shot:e,isLatest:n,liveScenario:s,isAgentBuilding:r}){if(n&&s&&!r)return{kind:"live",slug:s.slug};const[a,o]=r?[yY,vY]:[jY,wY];return{kind:"historical",screenshotPath:e.screenshotPath??null,scenarioName:e.name,heading:a,subtext:o}}function SY({scenarioGroups:e,isAgentBuilding:n,isHomeTab:s,buildingScenarioSlug:r,guardScenarioSelect:a,showScenarioPreview:o,setHomeLivePageOpen:i}){var b;const[c,d]=l.useState(null),u=l.useCallback(y=>{d(null),!a(y)&&(o(y),s&&i(!0))},[a,o,s]);l.useEffect(()=>{tM(e.flatMap(y=>y.scenarios.map(v=>v.slug)))},[e]),l.useEffect(()=>(Eh(u),()=>Eh(null)),[u]);const p=l.useCallback(y=>{const v=bY(y.name,e),j=_Y({shot:{name:y.name,screenshotPath:y.screenshotPath},isLatest:y.isLatest,liveScenario:v,isAgentBuilding:n});if(j.kind==="live"){d(null),o(j.slug);return}d({screenshotPath:j.screenshotPath,scenarioName:j.scenarioName,heading:j.heading,subtext:j.subtext})},[n,e,o]),h=l.useCallback(()=>{d(null)},[]),f=l.useMemo(()=>Hp(r,e),[r,e]),m=((b=f==null?void 0:f.screenshotPaths)==null?void 0:b[0])??null,g=(f==null?void 0:f.name)??null,x=(f==null?void 0:f.description)??null;return{historicalPreview:c,guardedShowScenarioPreview:u,handlePreviewJournalScreenshot:p,handleDismissHistoricalPreview:h,buildingScreenshotPath:m,buildingScenarioName:g,buildingScenarioDescription:x}}const kY=1e3;function NY(e,n){const s=l.useRef(e);s.current=e;const r=l.useRef(n);r.current=n;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,p=u===null?"/api/editor-commands":`/api/editor-commands?since=${u}`,h=await fetch(p);if(h.ok){const f=await h.json();typeof f.seq=="number"&&(a.current=f.seq),f.bootId&&(o.current===null?o.current=f.bootId:o.current!==f.bootId&&(o.current=f.bootId,(d=r.current)==null||d.call(r)));for(const m of f.commands??[])s.current(m)}}catch{}i&&setTimeout(c,kY)}}return c(),()=>{i=!1}},[])}function lg(e){const{isAgentBuilding:n,trigger:s,transitionBuildSessionLive:r}=e;if(n){pe("build-session-live-suppress-clear",{trigger:s,reason:"agent-still-active"});return}r(!1,s)}function CY({stepState:e,refetchStep:n,refetchConfig:s,reloadScenarios:r,handlePreviewCommand:a,clearBuildingOverlay:o,isAgentBuildingRef:i,transitionBuildSessionLive:c,onFeatureCompleteCommand:d,onPlanCompleteCommand:u,launchPlan:p,buildActivity:h,setChatEscalatedToPrototype:f,openCredentialRequest:m,setShowResultsCommandKey:g,setHideResultsCommandKey:x,setFeatureCompleteKey:b,setPrototypeLaunchKey:y,setPlanCompleteKey:v}){const j=l.useCallback(_=>{switch(_.type){case"preview":("scenarioSlug"in _||"scenarioId"in _)&&r(),a(_);break;case"showResults":o(),r(),g(w=>w+1),(e==null?void 0:e.mode)==="backend"&&a({path:"/results",dimension:"Desktop"});break;case"hideResults":x(w=>w+1);break;case"featureComplete":o(),d({title:_.title,summary:_.summary,severeWarnings:_.severeWarnings,proposedPlans:_.proposedPlans}),b(w=>w+1),s(),n(),lg({isAgentBuilding:i.current,trigger:"feature-complete",transitionBuildSessionLive:c});break;case"planComplete":u(),v(w=>w+1),s(),lg({isAgentBuilding:i.current,trigger:"plan-complete",transitionBuildSessionLive:c});break;case"launchPlan":p(_.slug,_.title,"launch-plan-command"),y(w=>w+1),f(!1);break;case"buildActivity":_.activity==="prototype"?f(!0):_.activity==="menu"&&f(!1),h.applyCommand(_.activity);break;case"requestCredential":m({serviceName:_.serviceName,envVar:_.envVar,topic:_.topic,docsUrl:_.docsUrl,instructions:_.instructions});break}},[o,a,i,p,d,u,s,n,m,r,e,c]);NY(j,l.useCallback(()=>{window.location.reload()},[]))}function TY({stepState:e,handlePreviewCommand:n,setPreviewPath:s}){const r=(e==null?void 0:e.slug)==="ui-confirm-plan"||(e==null?void 0:e.slug)==="backend-confirm-plan",a=l.useRef(null);l.useEffect(()=>{if(!e||!r){a.current=null;return}a.current!==e.step&&(a.current=e.step,n({path:"/plan-preview",dimension:"Desktop"}))},[e,r,n]);const o=l.useRef(null);l.useEffect(()=>{if(!e||e.mode!=="backend"||e.step<2||r){o.current=null;return}o.current!==e.step&&(o.current=e.step,n({path:"/results",dimension:"Desktop"}))},[e,r,n]);const i=l.useRef(!1);l.useEffect(()=>{(e==null?void 0:e.slug)==="ui-confirm-plan"?i.current=!0:i.current&&(i.current=!1,s(null))},[e,s])}function PY({isDesignViewShowing:e,onOpen:n}){const s=l.useRef(e);s.current=e;const r=l.useRef(n);r.current=n,l.useEffect(()=>{let a=!0,o=null;const i=async()=>{try{const d=await fetch("/api/editor-design-active-tab");if(!d.ok)return;const u=await d.json();if(!a)return;const p=u.nonce??0;if(o===null){o=p;return}if(p<=o)return;o=p,u.tab==="mockups"&&!s.current&&r.current()}catch{}};i();const c=window.setInterval(i,4e3);return()=>{a=!1,window.clearInterval(c)}},[])}function OY({previewUrl:e,isOnboarding:n,setSessionSplit:s,dismissDesignReturn:r,setPreviewPath:a}){const o=Ms(e),i=o==="/design-exploration",c=n&&i;l.useEffect(()=>{s(c)},[c]);const[d,u]=l.useState(0),p=l.useCallback(()=>u(g=>g+1),[]),h=l.useCallback(()=>{fetch("/api/editor-design-active-tab",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tab:"mockups"})}).catch(()=>{}),r(),a("/design-exploration")},[r,a]);PY({isDesignViewShowing:o==="/design-exploration"||o==="/design-round",onOpen:h});const f=l.useCallback(()=>a(null),[a]),m=l.useCallback(()=>i?f():h(),[i,f,h]);return{designsOpen:i,inDesignSession:c,skipDesignSignal:d,handleSkipDesign:p,handleOpenDesigns:h,handleExitDesigns:f,handleToggleDesigns:m}}const nr="plan";async function cg(){await sE(rE),await hN({send:e=>Sn(e,nr),waitForIdle:e=>jh(e,nr),ceilingMs:wr,payload:"/clear\r"}),await jh(wr,nr),Sn("/codeyam-plan",nr),await new Promise(e=>setTimeout(e,Kc)),Sn("\r",nr)}function RY(){fetch("/api/clear-build-agent-session",{method:"POST"}).catch(()=>{})}function EY({navigateToTab:e,deactivateBuild:n,buildActivity:s,setBuildLaunchModalDismissed:r,dismissModal:a,dismissPlanCompleteModal:o,setPlanChatOpen:i,setSelectPlanOpen:c,setResetModalOpen:d,setResetBusy:u,transitionBuildSessionLive:p,clearBuildingOverlay:h,clearIdleForStopBuilding:f,refetchSessionInfo:m,launchPlan:g,launchPrompt:x}){const b=l.useCallback(()=>{r(!0),s.startSession(),a(),_t()},[a,s]),y=l.useCallback(async()=>{window.dispatchEvent(new CustomEvent("build-session-stopped")),await _8(),a(),e("home"),n(),p(!1,"stop-building"),h(),f(),r(!1),m()},[a,e,n,p,h,f,m]);l.useEffect(()=>{const T=()=>{y().then(()=>{window.setTimeout(()=>e("build"),0)})};return window.addEventListener(tc,T),()=>window.removeEventListener(tc,T)},[y,e]);const v=l.useCallback(async()=>{u(!0),window.dispatchEvent(new CustomEvent("build-session-stopped")),await S8(),u(!1),d(!1),e("home"),n(),p(!1,"reset-everything"),h(),f(),r(!1),m()},[e,n,p,h,f,m]),j=l.useCallback(()=>{i(!0),cg(),o(),_t()},[o]),_=l.useCallback(()=>{i(!0),o(),_t()},[o]),w=l.useCallback(()=>{o(),cg().finally(()=>{i(!1),RY()})},[o]),k=l.useCallback(()=>{c(!0)},[]),S=l.useCallback(()=>{c(!1)},[]),N=l.useCallback(async(T,P,R)=>{await g(T,P,R)&&(c(!1),r(!0),s.startSession(),a(),m())},[g,a,m,s]),C=l.useCallback(async T=>{await x(T)&&(r(!0),a(),m())},[x,m,a]);return{handleContinueInSession:b,handleStopBuilding:y,handleResetEverything:v,handleCreateNewPlan:j,handleContinueSession:_,handleViewPlans:w,handleOpenSelectPlan:k,handleCloseSelectPlan:S,handlePickPlan:N,handleSubmitBuildPrompt:C}}function AY({isInIframe:e,scenariosLoaded:n,restoredRef:s,onAdopt:r,onHydrated:a,onSettledEmpty:o}){const i=l.useRef(!1),c=l.useRef(!1),d=l.useRef(null),u=l.useRef(n);u.current=n;const p=l.useRef(r),h=l.useRef(a),f=l.useRef(o);p.current=r,h.current=a,f.current=o;const m=l.useCallback(()=>{if(c.current||!u.current||s.current)return;const g=d.current;g&&(c.current=!0,s.current=!0,p.current(g))},[s]);l.useEffect(()=>{e||i.current||(i.current=!0,fetch("/api/editor-preview-state").then(g=>g.json()).then(g=>{g&&(g.scenarioSlug||g.path)&&(d.current=g,m())}).catch(()=>{}).finally(()=>{var g;h.current(),!c.current&&!d.current&&((g=f.current)==null||g.call(f))}))},[e,m]),l.useEffect(()=>{m()},[n,m])}function MY({isInIframe:e,onConverge:n}){const s=l.useRef(n);s.current=n,l.useEffect(()=>{if(!e)return D7(()=>{fetch("/api/editor-preview-state").then(r=>r.json()).then(r=>{r&&(r.scenarioSlug||r.path)&&s.current(r)}).catch(()=>{}).finally(()=>{Jc()})})},[e])}function IY({restoredRef:e,initiallySettled:n=!1,apply:s}){const r=l.useRef(n),a=l.useRef(null),o=l.useRef(s);o.current=s;const i=l.useCallback(u=>{e.current||(u.scenarioSlug||u.path)&&(e.current=!0,o.current(u))},[e]),c=l.useCallback(u=>{if(!e.current){if(!r.current){a.current=u;return}i(u)}},[i,e]),d=l.useCallback(()=>{r.current=!0;const u=a.current;a.current=null,u&&i(u)},[i]);return{requestRestore:c,onAdoptSettledEmpty:d}}function DY({scenariosLoaded:e,restoredRef:n,apply:s,onSettled:r}){const a=l.useRef(typeof window>"u"?null:vE(window.location.search)),o=l.useRef(!1),i=l.useRef(!1),c=l.useRef(s),d=l.useRef(r);c.current=s,d.current=r,l.useEffect(()=>{i.current||!a.current||(i.current=!0,n.current=!0,d.current())},[n]),l.useEffect(()=>{if(o.current||!e)return;const u=a.current;u&&(o.current=!0,c.current(u))},[e])}function LY(e,{handlePreviewCommand:n,handleCustomSizeChange:s}){!e.scenarioSlug&&!e.path||(n({...e.scenarioSlug?{scenarioSlug:e.scenarioSlug}:{},...e.path?{path:e.path}:{},...e.dimension?{dimension:e.dimension}:{}}),e.dimension==="Custom"&&typeof e.width=="number"&&typeof e.height=="number"&&s(e.width,e.height))}function FY({isInIframe:e,scenariosLoaded:n,restoredPreviewRef:s,markHydrated:r,setRestoreSettled:a,handlePreviewCommand:o,handleCustomSizeChange:i,setHomeLivePageOpen:c}){const d=l.useCallback(g=>{o({...g.scenarioSlug?{scenarioSlug:g.scenarioSlug}:{},...g.path?{path:g.path}:{},...g.dimension?{dimension:g.dimension}:{}})},[o]),{requestRestore:u,onAdoptSettledEmpty:p}=IY({restoredRef:s,initiallySettled:e,apply:d}),h=l.useCallback(g=>{LY(g,{handlePreviewCommand:o,handleCustomSizeChange:i})},[i,o]),f=l.useCallback(()=>{p(),a(!0)},[p]);AY({isInIframe:e,scenariosLoaded:n,restoredRef:s,onAdopt:h,onHydrated:r,onSettledEmpty:f});const m=l.useCallback(g=>{o({scenarioSlug:g}),c(!0)},[o]);return DY({scenariosLoaded:n,restoredRef:s,apply:m,onSettled:()=>a(!0)}),MY({isInIframe:e,onConverge:h}),{handleRestorePreview:u}}const $Y=4e3,zY=2;function _P({state:e,provider:n,credsPresent:s=!0,cliInstalled:r=!0,scannedDirs:a=[],reason:o=null,expiresAt:i=null,shellShare:c=null,probeInFlight:d=!1,probeAttempts:u=0,backendOutOfDate:p=!1,serverUnreachable:h=!1,sessionOngoing:f=!1,onAuthenticated:m,onAuthorized:g}){const[x,b]=l.useState(!1),[y,v]=l.useState(!1),j=Qe(n),[_,w]=l.useState(!1);l.useEffect(()=>{if(e!=="unknown"){w(!1);return}const C=window.setTimeout(()=>w(!0),$Y);return()=>window.clearTimeout(C)},[e]);const k=l.useCallback(()=>{b(!1),m(),g==null||g()},[m,g]),S=l.useCallback(async()=>{v(!0);try{await fetch("/api/auth/refresh-cache",{method:"POST"}),m()}catch{}finally{v(!1)}},[m]);if(e==="authenticated")return null;const N=x?t.jsx(fg,{provider:n,onAuthenticated:k,onClose:()=>b(!1)}):null;if(e==="unknown"){if(h)return t.jsx(Pg,{onCheck:m});const C=o==="probe-timeout"&&u>=zY,T=r===!1||o==="cli-not-found";return!C&&!T&&(d||!_)||p?null:T?t.jsxs("div",{"data-testid":"provider-auth-cli-not-found","data-auth-card":!0,className:"m-4 rounded-lg border border-[#3A3A3A] bg-[#1E1E1E] p-5 space-y-3",children:[t.jsxs("p",{className:"text-sm text-white font-medium",children:[j," CLI not found"]}),t.jsxs("p",{className:"text-sm text-[#8E8E8E]",children:["We couldn't find the ",j," CLI on this machine — we searched your PATH and the standard install locations",a.length>0?t.jsxs(t.Fragment,{children:[" (",a.join(", "),")"]}):t.jsx(t.Fragment,{children:" (~/.local/bin, ~/.cargo/bin, /opt/homebrew/bin, /usr/local/bin)"}),". Install the ",j," CLI, or add the directory it lives in to your PATH, then recheck. This is a PATH/install problem — re-authenticating won't fix it."]}),t.jsx("div",{className:"flex flex-wrap items-center gap-3",children:t.jsx("button",{onClick:()=>void S(),"data-testid":"provider-auth-cli-not-found-recheck",disabled:y,className:"px-3 py-2 text-sm rounded-md bg-[#D7FF63] text-black font-medium cursor-pointer disabled:opacity-50",children:y?"Rechecking…":"Recheck after installing"})})]}):t.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:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.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"}),t.jsxs("p",{className:"text-sm text-[#8E8E8E]",children:["Checking your ",j," account… If this takes more than a few seconds, your token may need refresh."]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("button",{onClick:()=>b(!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"}),t.jsx("button",{onClick:()=>void S(),"data-testid":"provider-auth-checking-recheck",disabled:y,className:"px-3 py-2 text-sm rounded-md border border-[#3A3A3A] text-white cursor-pointer disabled:opacity-50",children:y?"Rechecking…":"Already logged in? Recheck"})]}),N]})}return t.jsx(aE,{provider:n,credsPresent:s,reason:o,expiresAt:i,shellShare:c,sessionOngoing:f,onAuthenticated:m,onAuthorized:g})}const die=Object.freeze(Object.defineProperty({__proto__:null,ProviderAuthGate:_P},Symbol.toStringTag,{value:"Module"}));function SP(){const e=l.useSyncExternalStore(_h.subscribe,_h.get),n=l.useSyncExternalStore(eg.subscribe,eg.get);return t.jsx(Wj,{visible:e!==null,reason:(e==null?void 0:e.reason)??"lost",framed:I5(),reconnect:n,vmNumber:tq(window.location.hostname),onReload:()=>window.location.reload(),onReconnect:()=>eq()})}const uie=Object.freeze(Object.defineProperty({__proto__:null,ConnectedSessionLostBanner:SP},Symbol.toStringTag,{value:"Module"}));function kP({update:e}){const{copied:n,copy:s}=fo();if(!e||!e.available)return null;const r=e.channel==="desktop";return t.jsx("div",{className:"rounded-lg p-4","data-testid":"update-available-banner",role:"status",style:{background:"rgba(91, 155, 213, 0.16)",border:"1px solid rgba(91, 155, 213, 0.55)",borderLeft:"4px solid var(--blue-300)",boxShadow:"0 2px 10px rgba(91, 155, 213, 0.18)"},children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("span",{className:"text-xl leading-none mt-0.5","aria-hidden":"true",style:{color:"var(--blue-300)"},children:"↑"}),t.jsxs("div",{className:"flex-1 min-w-0 text-sm",style:{color:"var(--text-body)"},children:[t.jsx("div",{className:"font-semibold mb-1",style:{color:"var(--blue-300)"},children:r?"Update ready":"Update available"}),r?t.jsx(t.Fragment,{children:"It will install automatically after your current session ends. To install now, use the Check for Updates menu."}):t.jsxs(t.Fragment,{children:["A new version of CodeYam Editor is available (",t.jsxs("span",{style:{color:"var(--text-strong)",fontWeight:600},children:[e.currentVersion," → ",e.latestVersion]}),"). Run"," ",t.jsx("code",{className:"text-xs",style:{color:"var(--text-strong)"},children:e.upgradeCommand})," ","to upgrade."," ",e.preflightCommand&&t.jsxs(t.Fragment,{children:["Upgrading can restart the editor, so first run"," ",t.jsx("code",{className:"text-xs",style:{color:"var(--text-strong)"},children:e.preflightCommand})," ","to see which agent sessions are mid-task."," "]}),t.jsx("button",{type:"button",className:"mt-2 inline-block rounded px-2.5 py-1 text-xs font-medium",style:{background:"var(--blue-300)",color:"#0b1220"},onClick:()=>void s(e.upgradeCommand??""),children:n?"Copied":"Copy command"})]})]})]})})}const pie=Object.freeze(Object.defineProperty({__proto__:null,UpdateAvailableBanner:kP},Symbol.toStringTag,{value:"Module"})),BY=3e3;function WY({hot:e,isInIframe:n,reload:s=()=>window.location.reload(),sustainedDisconnectMs:r=BY}){return()=>{}}function HY(){l.useEffect(()=>WY({hot:void 0,isInIframe:en()}),[])}function qY(){const[e,n]=l.useState({loading:!1,error:null,downloaded:!1}),s=l.useCallback(async a=>{n({loading:!0,error:null,downloaded:!1});try{const i=await(await fetch("/api/editor-transcript-package")).json();if(!i.success){n({loading:!1,error:i.error||"Failed to package transcript",downloaded:!1});return}let c=i.content;a!=null&&a.trim()&&(c=`## User Notes
|
|
360
|
+
|
|
361
|
+
${a.trim()}
|
|
362
|
+
|
|
363
|
+
${c}`);const d=new Blob([c],{type:"text/markdown"}),u=URL.createObjectURL(d),p=document.createElement("a");p.href=u,p.download=i.filename,document.body.appendChild(p),p.click(),document.body.removeChild(p),URL.revokeObjectURL(u),n({loading:!1,error:null,downloaded:!0})}catch(o){n({loading:!1,error:o instanceof Error?o.message:"Network error",downloaded:!1})}},[]),r=l.useCallback(()=>{n({loading:!1,error:null,downloaded:!1})},[]);return{...e,sendTranscript:s,reset:r}}function UY(e,n){var o;const s="feedback@codeyam.com",r=encodeURIComponent(`CodeYam Session Feedback: ${e||"Session"}`+(n!=null&&n.category?` [${n.category}]`:"")),a=encodeURIComponent([((o=n==null?void 0:n.note)==null?void 0:o.trim())||"(no note)","","(Please attach the downloaded transcript file.)"].join(`
|
|
364
|
+
|
|
365
|
+
`));return`mailto:${s}?subject=${r}&body=${a}`}const YY=["bug","suggestion","question","praise"];function NP({featureName:e,onClose:n}){const[s,r]=l.useState(""),[a,o]=l.useState(null),[i,c]=l.useState(!1),{loading:d,error:u,downloaded:p,sendTranscript:h}=qY(),f=l.useCallback(()=>{h(s)},[h,s]),m=l.useCallback(()=>{navigator.clipboard.writeText("feedback@codeyam.com").then(()=>{c(!0),setTimeout(()=>c(!1),2e3)})},[]),g=l.useCallback(x=>{o(b=>b===x?null:x)},[]);return t.jsxs("div",{className:"max-w-md w-full mx-4 p-6 rounded-xl",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",boxShadow:"0 24px 64px rgba(0,0,0,.5)"},children:[t.jsx("h2",{className:"text-[17px] font-semibold text-[var(--text-primary)] mb-1.5",children:"Send feedback"}),t.jsx("p",{className:"text-[13px] leading-relaxed text-[var(--text-muted)] mb-5",children:"Tell the CodeYam team what happened. Your session transcript downloads so you can attach it, which helps us see exactly what went on."}),t.jsxs("div",{className:"mb-4",children:[t.jsx("span",{className:"block text-[12px] font-medium text-[var(--text-secondary)] mb-2",children:"What kind of feedback?"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:YY.map(x=>{const b=a===x;return t.jsx("button",{type:"button","aria-pressed":b,onClick:()=>g(x),className:`px-3 py-1.5 rounded-full text-[12.5px] font-medium capitalize transition cursor-pointer ${b?"":"hover:bg-white/[0.1] hover:text-[var(--text-primary)]"}`,style:{background:b?"var(--accent-active)":"rgba(255,255,255,.06)",color:b?"var(--bg-deep)":"var(--text-secondary)",border:`1px solid ${b?"var(--accent-active)":"rgba(255,255,255,.14)"}`},children:x},x)})})]}),t.jsxs("label",{className:"block mb-5",children:[t.jsx("span",{className:"block text-[12px] font-medium text-[var(--text-secondary)] mb-2",children:"Your feedback"}),t.jsx("textarea",{value:s,onChange:x=>r(x.target.value),placeholder:"What happened, what you expected, or what you'd like to see",className:"w-full h-28 px-3 py-2.5 text-[13px] leading-relaxed rounded-lg resize-none outline-none transition border border-white/[0.18] placeholder:text-[var(--text-dim)] focus:border-[var(--accent-active)] focus:shadow-[0_0_0_3px_rgba(215,255,99,.12)]",style:{background:"#161616",color:"var(--text-primary)"}})]}),u&&t.jsx(tt,{text:u,className:"text-sm text-red-400",rowClassName:"mb-3"}),t.jsxs("div",{className:"flex flex-col gap-3",children:[p?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-green-400 text-center",children:"Transcript downloaded"}),t.jsx("a",{href:UY(e,{note:s,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"}),t.jsx("button",{onClick:m,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"}),t.jsx("p",{className:"text-xs text-[var(--text-dim)] text-center",children:"Attach the downloaded file to your email"})]}):t.jsx("button",{onClick:f,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"}),t.jsx("button",{onClick:n,className:"w-full px-4 py-2.5 rounded-md text-sm font-medium transition",style:{background:"transparent",color:"var(--text-secondary)",border:p?"none":"1px solid var(--border-default)"},type:"button",children:p?"Done":"Cancel"})]})]})}const hie=Object.freeze(Object.defineProperty({__proto__:null,SendTranscriptModal:NP},Symbol.toStringTag,{value:"Module"}));function CP({sha:e,onClick:n}){if(!e)return null;const s=e.slice(0,6),r="font-mono text-[11px] leading-none py-0.5 text-[var(--text-dim)] hover:text-[var(--text-secondary)] transition-colors";return t.jsx("div",{className:`fixed z-30 ${n?"":"pointer-events-none"}`,style:{left:8+un,bottom:9,paddingBottom:"env(safe-area-inset-bottom)"},children:n?t.jsx("button",{type:"button",onClick:n,"data-testid":"build-sha-badge",title:e,"aria-label":`Build commit ${e}`,className:`cursor-pointer ${r}`,children:s}):t.jsx("span",{"data-testid":"build-sha-badge",title:e,"aria-label":`Build commit ${e}`,className:r,children:s})})}const fie=Object.freeze(Object.defineProperty({__proto__:null,BuildShaBadge:CP},Symbol.toStringTag,{value:"Module"}));function GY(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/raw-terminal`}function TP(){if(en())return t.jsx(gd,{});const e=l.useRef(null),n=l.useRef(null),s=l.useRef(null),r=l.useRef(null),a=l.useRef(!1),[o,i]=l.useState(!1),[c,d]=qu(1200);function u(p){const h=r.current;(h==null?void 0:h.readyState)===WebSocket.OPEN&&h.send(new TextEncoder().encode(p))}return qc(e,()=>{if(s.current&&n.current){if(!jr(n.current,e.current))return;s.current.fit();const p=r.current;(p==null?void 0:p.readyState)===WebSocket.OPEN&&p.send(JSON.stringify({type:"resize",cols:n.current.cols,rows:n.current.rows}))}}),l.useEffect(()=>{if(!e.current||a.current)return;a.current=!0;const p=new Uc.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'IBM Plex Mono', monospace",rightClickSelectsWord:!1,theme:{background:"#1e1e1e",foreground:"#cccccc",cursor:"#D7FF63",selectionBackground:"#264f78"}}),h=new Yc.FitAddon;p.loadAddon(h),p.open(e.current),n.current=p,s.current=h;const f=Gc(p,e.current,{onCopy:()=>d()}),m=Vc(p,{sendInput:u});requestAnimationFrame(()=>{jr(p,e.current)&&h.fit(),p.focus()});const g=new WebSocket(GY());return r.current=g,g.binaryType="arraybuffer",g.onmessage=x=>{x.data instanceof ArrayBuffer&&p.write(new Uint8Array(x.data))},g.onopen=()=>{g.send(JSON.stringify({type:"resize",cols:p.cols,rows:p.rows}))},g.onclose=()=>{i(!0),p.writeln(`\r
|
|
366
|
+
\x1B[90m[Shell session ended]\x1B[0m`)},p.onData(u),()=>{var x;(x=r.current)==null||x.close(),m(),f(),p.dispose(),a.current=!1}},[]),t.jsxs("div",{className:"relative flex-1 flex flex-col",style:{minHeight:0},children:[t.jsx("div",{ref:e,className:"flex-1",style:{background:"#1e1e1e",minHeight:0,paddingTop:3,paddingLeft:3},onClick:()=>{var p;return(p=n.current)==null?void 0:p.focus()}}),o&&t.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&&t.jsx(Qo,{})]})}const mie=Object.freeze(Object.defineProperty({__proto__:null,RawTerminalEmulator:TP},Symbol.toStringTag,{value:"Module"}));function PP({isOpen:e,onClose:n}){return l.useEffect(()=>{if(!e)return;const s=r=>{r.key==="Escape"&&n()};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[e,n]),e?t.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:s=>{s.target===s.currentTarget&&n()},children:t.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:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-[var(--border-default)]",children:[t.jsx("h2",{id:"raw-terminal-modal-title",className:"text-sm font-semibold text-[var(--text-primary)] m-0",children:"Terminal"}),t.jsx("button",{type:"button",onClick:n,"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:"✕"})]}),t.jsx("div",{className:"flex-1 flex flex-col",style:{minHeight:0},children:t.jsx(TP,{})})]})}):null}const gie=Object.freeze(Object.defineProperty({__proto__:null,RawTerminalModal:PP},Symbol.toStringTag,{value:"Module"}));function VY(){const[e,n]=l.useState(!1),[s,r]=l.useState(null),[a,o]=l.useState(null),i=l.useRef(0),{claimDesignDrop:c,designDropLabel:d}=jE(),u=l.useRef(c);u.current=c,l.useEffect(()=>{if(a===null)return;const f=window.setTimeout(()=>o(null),oE);return()=>window.clearTimeout(f)},[a]);const p=l.useCallback(()=>r(null),[]),h=l.useCallback(async f=>{if(f.length!==0){for(const{file:m,relativePath:g}of f)if(m.size>wh){o(`${g} is larger than the ${wh/(1024*1024)} MB cap`);return}try{const m=await Promise.all(f.map(async({file:y,relativePath:v})=>({filename:v||y.name||"unnamed",contentBase64:await iE(y)}))),g=await fetch("/api/editor-upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:m})});if(!g.ok){const y=await g.json().then(v=>v.error).catch(()=>null);throw new Error(y??`Upload failed: ${g.status}`)}const b=(await g.json()).written??[];if(b.length===0)throw new Error("Upload returned no saved files");r(b)}catch(m){o(m instanceof Error?m.message:String(m))}}},[]);return l.useEffect(()=>{const f=y=>{var v,j;return!!((j=(v=y.dataTransfer)==null?void 0:v.types)!=null&&j.includes("Files"))},m=y=>{f(y)&&(y.preventDefault(),i.current+=1,n(!0))},g=y=>{f(y)&&y.preventDefault()},x=y=>{f(y)&&(i.current=Math.max(0,i.current-1),i.current===0&&n(!1))},b=y=>{if(f(y)){if(y.defaultPrevented){i.current=0,n(!1);return}y.preventDefault(),i.current=0,n(!1),!(!y.dataTransfer||u.current(y.dataTransfer))&&pg(y.dataTransfer).then(({files:v,error:j})=>{j&&o(j),h(v)})}};return window.addEventListener("dragenter",m),window.addEventListener("dragover",g),window.addEventListener("dragleave",x),window.addEventListener("drop",b),()=>{window.removeEventListener("dragenter",m),window.removeEventListener("dragover",g),window.removeEventListener("dragleave",x),window.removeEventListener("drop",b)}},[h]),{dragActive:e,pendingPaths:s,error:a,clearPending:p,uploadFiles:h,showError:o,designDropLabel:d}}function OP({visible:e,destinationLabel:n=null}){if(!e)return null;const s=n!==null;return t.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:t.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:[t.jsx("span",{className:"text-2xl font-semibold text-[var(--text-primary)]",children:s?`Drop to add ${n}`:"Drop files to add them to this session"}),t.jsx("span",{className:"text-sm text-[var(--text-muted)]",children:s?"Saved to your project's design assets":"Saved to .codeyam/uploads/ — then hand them to the agent"})]})})}const xie=Object.freeze(Object.defineProperty({__proto__:null,GlobalFileDropOverlay:OP},Symbol.toStringTag,{value:"Module"}));function RP({message:e}){return t.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.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{children:e}),t.jsx(ct,{variant:"icon",text:e})]})})}const bie=Object.freeze(Object.defineProperty({__proto__:null,GlobalFileDropToast:RP},Symbol.toStringTag,{value:"Module"}));function EP({paths:e,onClose:n}){const{sendToAgent:s,agentReady:r}=po(),[a,o]=l.useState(!1),i=l.useCallback(p=>{p.key==="Escape"&&(p.preventDefault(),n())},[n]);l.useEffect(()=>(window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)),[i]);const c=e.map(lE).join(" "),d=l.useCallback(()=>{s(c+" ")&&n()},[s,c,n]),u=l.useCallback(()=>{var p;(p=navigator.clipboard)==null||p.writeText(c).then(()=>{o(!0),window.setTimeout(()=>o(!1),1500)},()=>{})},[c]);return t.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",onMouseDown:p=>{p.target===p.currentTarget&&n()},children:t.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:[t.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:e.length===1?"File added":`${e.length} files added`}),t.jsxs("p",{className:"text-sm text-[var(--text-muted)] mb-4",children:["Saved to your project, but the agent hasn't been told about"," ",e.length===1?"it":"them"," yet. Hand the path",e.length===1?"":"s"," over so it can read"," ",e.length===1?"it":"them","."]}),t.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:e.map(p=>t.jsx("li",{className:"truncate py-0.5",children:p},p))}),!r&&t.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."}),t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t.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"}),t.jsx("button",{type:"button",onClick:n,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:"Not now"}),t.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"})]}),t.jsx("p",{className:"mt-3 text-center text-xs text-[var(--text-dim)]",children:"Escape closes · files stay in .codeyam/uploads/"})]})})}const yie=Object.freeze(Object.defineProperty({__proto__:null,FileDropConfirmModal:EP},Symbol.toStringTag,{value:"Module"}));let Zi=null;function KY(e){if(typeof e!="object"||e===null)return null;const n=e.buildCommitSha;return typeof n!="string"||n===""||n==="unknown"?null:n}async function JY(){try{const e=await fetch("/api/health");return e.ok?KY(await e.json()):null}catch{return null}}function XY(){const[e,n]=l.useState(null);return l.useEffect(()=>{let s=!0;return Zi||(Zi=JY()),Zi.then(r=>{s&&n(r)}),()=>{s=!1}},[]),{sha:e}}function QY(){var fh;HY();const{sha:e}=XY(),n=wE(),{state:s,provider:r,credsPresent:a,cliInstalled:o,scannedDirs:i,reason:c,expiresAt:d,shellShare:u,probeInFlight:p,probeAttempts:h,backendFieldAbsent:f,serverUnreachable:m,refresh:g}=Wc(),{update:x}=zU(),{sessionInfo:b,refetch:y}=up({pollIntervalMs:15e3}),v=(b==null?void 0:b.agentBrokerLive)??!1,j=AU(s,v),{activeTab:_,buildActivated:w,planActivated:k,navigateToTab:S,deactivateBuild:N}=Np(n,j,s==="needs-login"&&!v),{buildLaunchModalDismissed:C,setBuildLaunchModalDismissed:T,buildHandoffPending:P,armPendingBuildNav:R,navigateToTabUser:I,pendingBuildNav:A,designReturnVisible:O,dismissDesignReturn:W,handleDesignConfirmed:D,handleAuthorizeToBuild:Y}=qU(j,S),H=en(),[E,U]=l.useState(H),M=l.useRef(!1),J=l.useCallback(()=>U(!0),[]),[ne,oe]=l.useState(H),{showResultsCommandKey:ae,setShowResultsCommandKey:G,hideResultsCommandKey:ie,setHideResultsCommandKey:le,featureCompleteKey:Z,setFeatureCompleteKey:z,prototypeLaunchKey:L,setPrototypeLaunchKey:q,planCompleteKey:se,setPlanCompleteKey:fe}=UU(),{showPostPushModal:we,featureSummary:De,onFeatureCompleteCommand:Fe,handleAgentIdle:Me,handleAgentActive:ee,dismissModal:Q,showPlanCompleteModal:te,onPlanCompleteCommand:he,dismissPlanCompleteModal:ye,planChatOpen:ve,setPlanChatOpen:Ne,selectPlanOpen:de,setSelectPlanOpen:me,showTranscriptModal:We,rawTerminalOpen:B,setRawTerminalOpen:F,resetModalOpen:X,setResetModalOpen:ue,resetBusy:be,setResetBusy:xe,handleSendTranscript:ke,handleCloseTranscript:qe}=VU(),{plans:Le,loading:Oe,error:Ue,refetch:dt}=Ir(),{plans:je}=ed(),{reorderPlans:$e}=wN(dt),{launchPrompt:K,launching:_e,error:V}=jU(),{stepState:ce,refetch:Be}=Qr();xU({showPostPushModal:we,stepState:ce,dismissModal:Q}),bU({sessionInfo:b,stepState:ce,showPostPushModal:we,onFeatureCompleteCommand:Fe});const Ke=l.useMemo(()=>yU(we,ce),[we,ce]),Ie=_==="home",{isCollapsed:ut,setIsCollapsed:Ze,isFilled:st,setIsFilled:Ye,splitRef:rt,setSessionSplit:Je,leftWidth:vt,handleMouseDown:jt,isResizing:Yt,resetWidth:Ct,nudgeWidth:Tt,leftWidthMin:Kn,isNarrow:Gt,mobilePane:Pn,setMobilePane:wt,handleMobilePaneChange:Jn,homeLivePageOpen:Pt,setHomeLivePageOpen:zt,handleToggleCollapsed:tn,handleToggleFilled:Xn}=XU(Ie),{entityLookup:Ot}=sU(),{groups:fn,loading:nn,refreshing:Ge,currentRunner:Rt,coverage:mt,refresh:sn}=qq(),{groups:gt,loading:rn,reload:an}=Iq(),{routeEntities:Ks,unsurfacedPages:na,componentSurfaceReason:re,loading:He,refreshing:xt,error:Dt}=Fq(),{config:ge,apps:mn,loading:sa,refetch:ra}=St(),AP=T2(),Qn=l.useMemo(()=>wU(mn,fn,gt),[mn,gt,fn]),{saved:MP}=h0(),Up=f0({appStatsLength:Qn.length,configLoading:sa,scenariosLoading:rn,setupAnswersSaved:MP,hasStepState:!!ce}),ci=Ie&&!Pt&&!Up||_==="chat",IP=Gt||ci?((fh=rt.current)==null?void 0:fh.clientWidth)??(typeof window<"u"?window.innerWidth:vt):vt,{selectedApp:Zn,appRouteEntities:Yp,appTestGroups:DP,selectedEntityHash:LP,selectedRouteEntity:Gp,previewSlug:gs,setPreviewSlugExplicit:FP,selectApp:di,deselectApp:ui,selectRoute:pi,selectEntity:$P,deselectRoute:zP}=nU(mn,Ks,gt,fn,n,(ge==null?void 0:ge.defaultScreenSize)??null,ne,M),{viewports:BP,resolvedViewport:Js,previewUrl:hi,handleViewportChange:WP,handleCustomSizeChange:Vp,showScenarioPreview:fi,handlePreviewCommand:xs,setPreviewPath:aa,previewSeeding:HP,previewSeedError:qP,previewSeedErrorKind:UP,retrySeed:YP,commandNonce:GP}=fU({apps:mn,appRouteEntities:Yp,configLoaded:!sa,hydrated:E,port:(ge==null?void 0:ge.port)??5173,previewMedium:AP.kind,previewOrigin:Cl(ge,Zn),projectTitle:(ge==null?void 0:ge.projectTitle)??null,routeEntities:Ks,screenSizes:(ge==null?void 0:ge.screenSizes)??{},defaultScreenSize:(ge==null?void 0:ge.defaultScreenSize)??null,scenarioGroups:gt,scenariosLoaded:!rn,selectedApp:Zn,selectedRouteEntity:Gp,previewSlug:gs,setPreviewSlug:FP}),{credentialTarget:VP,openCredentialRequest:KP,handleCredentialStored:JP,handleCloseCredentialRequest:XP}=ZU({isHomeTab:Ie,homeLivePageOpen:Pt,setHomeLivePageOpen:zt,setMobilePane:wt,setIsCollapsed:Ze,previewSlug:gs,previewUrl:hi,setPreviewPath:aa,showScenarioPreview:fi});l.useEffect(()=>{Ie&&Pt&&Js.name==="Desktop"&&Ye(!0)},[Ie,Pt,Js.name]),l.useEffect(()=>{const pt=ge==null?void 0:ge.projectTitle;document.title=typeof pt=="string"&&pt.length>0?`CodeYam: ${pt}`:"CodeYam"},[ge==null?void 0:ge.projectTitle]);const{isAgentBuilding:mi,isAgentBuildingRef:QP,buildingScenarioSlug:Kp,guardScenarioSelect:ZP,clearBuildingOverlay:Xs,planActive:Jp,planIdle:Xp,hasActiveSession:Qp,launchPlan:gi,launchingPlanSlug:xi,planLaunchError:eO,agentActivelyBuilding:oa,transitionBuildSessionLive:Zp,emptyStateBuildStatus:tO,provider:nO,agentName:sO,buildIdle:bi,agentBlocked:rO,bannerVisible:aO,notifSettings:eh,handleSettingsChange:th,handleIdleSignalIdle:oO,handleIdleSignalBlocked:iO,handleIdleSignalActive:lO,handleIdleSignalUserInput:cO,handleNavigateToTab:nh,dismissIdleBanner:dO,clearIdleForStopBuilding:uO}=uY({activeTab:_,config:ge,stepState:ce,sessionInfo:b,refetchSessionInfo:y,showScenarioPreview:fi,planChatOpen:ve,submittingBuildPrompt:_e,pendingBuildNav:A,buildHandoffPending:P,featureCompleteKey:Z,navigateToTabUser:I,handleAgentIdle:Me,handleAgentActive:ee}),{buildingStatus:pO,buildingStepLabel:sh,buildingProgress:rh,buildingStepPosition:ah,lastBuiltLabel:hO,buildingThumbnailPath:fO}=xY({stepState:ce,buildIdle:bi,isAgentBuilding:mi,completedPlans:je,scenarioGroups:gt}),{claimsBySlug:mO,staleFetch:gO,annotationsBySlug:xO,dependenciesBySlug:bO,showAuthors:yO,requestRun:oh,gateModals:vO}=vU({plans:Le,completedPlans:je,isAgentBuilding:oa,onLaunch:pt=>{var mh;const Qs=((mh=Le.find(eR=>eR.slug===pt))==null?void 0:mh.title)??pt;gi(pt,Qs,"home-queue")}}),{historicalPreview:Bt,guardedShowScenarioPreview:ih,handlePreviewJournalScreenshot:jO,handleDismissHistoricalPreview:wO,buildingScreenshotPath:_O,buildingScenarioName:SO,buildingScenarioDescription:kO}=SY({scenarioGroups:gt,isAgentBuilding:mi,isHomeTab:Ie,buildingScenarioSlug:Kp,guardScenarioSelect:ZP,showScenarioPreview:fi,setHomeLivePageOpen:zt}),lh=l.useCallback(()=>S("plan"),[S]),Et=IU(lh),NO=l.useSyncExternalStore(IS,MS),bs=zq({building:oa,build:{label:(ce==null?void 0:ce.feature)??null,status:pO},activity:Et.activity,chatNeedsYou:NO}),[ch,dh]=l.useState(!1);FU({buildActivity:Et,sessionInfo:b,buildSessionOwnsTab:Qp||!!(ce!=null&&ce.feature),chatEscalatedToPrototype:ch,setChatEscalatedToPrototype:dh}),CY({stepState:ce,refetchStep:Be,refetchConfig:ra,reloadScenarios:an,handlePreviewCommand:xs,clearBuildingOverlay:Xs,isAgentBuildingRef:QP,transitionBuildSessionLive:Zp,onFeatureCompleteCommand:Fe,onPlanCompleteCommand:he,launchPlan:gi,buildActivity:Et,setChatEscalatedToPrototype:dh,openCredentialRequest:KP,setShowResultsCommandKey:G,setHideResultsCommandKey:le,setFeatureCompleteKey:z,setPrototypeLaunchKey:q,setPlanCompleteKey:fe}),TY({stepState:ce,handlePreviewCommand:xs,setPreviewPath:aa});const{designsOpen:CO,inDesignSession:uh,skipDesignSignal:TO,handleSkipDesign:PO,handleOpenDesigns:OO,handleExitDesigns:RO,handleToggleDesigns:EO}=OY({previewUrl:hi,isOnboarding:Up,setSessionSplit:Je,dismissDesignReturn:W,setPreviewPath:aa}),{handleContinueInSession:AO,handleStopBuilding:MO,handleResetEverything:IO,handleCreateNewPlan:DO,handleContinueSession:LO,handleViewPlans:FO,handleOpenSelectPlan:$O,handleCloseSelectPlan:zO,handlePickPlan:BO,handleSubmitBuildPrompt:WO}=EY({navigateToTab:S,deactivateBuild:N,buildActivity:Et,setBuildLaunchModalDismissed:T,dismissModal:Q,dismissPlanCompleteModal:ye,setPlanChatOpen:Ne,setSelectPlanOpen:me,setResetModalOpen:ue,setResetBusy:xe,transitionBuildSessionLive:Zp,clearBuildingOverlay:Xs,clearIdleForStopBuilding:uO,refetchSessionInfo:y,launchPlan:gi,launchPrompt:K}),yi={hasActiveSession:Qp,isAgentBuilding:mi,showPostPushModal:we,launchingPlanSlug:xi,submittingBuildPrompt:_e,stepStateFeature:(ce==null?void 0:ce.feature)??null,buildLaunchModalDismissed:C,buildActivityInFlight:Et.activity!=="menu",buildActivityMinimized:Et.minimized,buildHandoffPending:P},HO=jP(yi),ph=wP({activeTab:_,...yi}),qO=MU({activeTab:_,...yi}),UO=ph||de;l.useEffect(()=>{_==="build"&&y()},[_,y]),l.useEffect(()=>{_==="home"&&(ra(),g())},[_,ra,g]);const YO=l.useCallback(async(pt,Qs)=>{Xs(),xs(EU(pt,Qs))},[Xs,xs]),{handleRestorePreview:GO}=FY({isInIframe:H,scenariosLoaded:!rn,restoredPreviewRef:M,markHydrated:J,setRestoreSettled:oe,handlePreviewCommand:xs,handleCustomSizeChange:Vp,setHomeLivePageOpen:zt});gU(H);const VO=l.useMemo(()=>({apps:mn,isSingleApp:mn.length===1,onSelectApps:ui,onSelectApp:di,onSelectRoute:pi}),[mn,ui,di,pi]),KO=l.useMemo(()=>Zn?Qn.find(pt=>pt.app.dir===Zn.dir)??null:null,[Qn,Zn]),JO=t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{padding:"12px 28px 0"},children:t.jsx(_p,{staleness:null,backendOutOfDate:f})}),t.jsx("div",{style:{padding:"12px 28px 0"},children:t.jsx(kP,{update:x})}),t.jsx(_P,{state:s,provider:r,credsPresent:a,cliInstalled:o,scannedDirs:i,reason:c,expiresAt:d,shellShare:u,probeInFlight:p,probeAttempts:h,backendOutOfDate:f,serverUnreachable:m,sessionOngoing:v,onAuthenticated:g,onAuthorized:Y}),t.jsx(aN,{notificationBanner:Qn.length>0?t.jsx(u0,{settings:eh,onChange:th,providerLabel:sO}):null,selectedApp:Zn,projectTitle:(ge==null?void 0:ge.projectTitle)??null,admin:(ge==null?void 0:ge.admin)??!1,isBuilding:bs.active,buildingLabel:bs.label,buildingStepLabel:sh,buildingStepPosition:ah,buildingStatus:bs.status,buildingProgress:rh,lastBuiltLabel:hO,buildingThumbnailPath:fO,plans:Le,plansLoading:Oe,plansError:Ue,onRunPlan:oh,launchingSlug:xi,planDepAnnotationsBySlug:xO,planDependenciesBySlug:bO,planClaimsBySlug:mO,planStaleFetch:gO,showPlanAuthors:yO,onNavigateToPlan:()=>S("plan"),onNavigateToBuild:()=>I("build"),onResetBuild:()=>ue(!0),onBackToProjects:mn.length>1?ui:void 0,launcherUrl:(ge==null?void 0:ge.launcherUrl)??null,projectCount:(ge==null?void 0:ge.projectCount)??0,onOpenSetupBrowser:ge!=null&&ge.setupBrowserEnabled?()=>xs({path:"/setup-browser",dimension:"Desktop"}):void 0,appDetailProps:{navContext:VO,routeEntities:Yp,unsurfacedPages:na,componentSurfaceReason:re,routesLoading:He,routesRefreshing:xt,routesError:Dt,selectedEntityHash:LP,selectedRouteEntity:Gp,testGroups:DP,selectedSlug:gs,entityLookup:Ot,allScenarios:gt.flatMap(pt=>pt.scenarios),onSelectScenario:ih,onSelectRoute:pi,onSelectEntity:$P,onBackToRoutes:zP,onScenariosChanged:an,coverage:mt,showProjectBand:mn.length===1,stats:KO,testsLoading:nn,testsRefreshing:Ge,onRunTests:sn,currentRunner:Rt},appOverviewProps:{projectTitle:(ge==null?void 0:ge.projectTitle)??"Project",projectDescription:(ge==null?void 0:ge.projectDescription)??null,stats:Qn,coverage:mt,onSelectApp:di,configLoading:sa,scenariosLoading:rn,testsLoading:nn,testsRefreshing:Ge,onRunTests:sn,currentRunner:Rt,stepState:ce,onPreviewUrl:aa,onComplete:async()=>{await ra(),console.info("[EditorShell] questionnaire complete; arming pending build-nav",{providerAuthState:s,buildBlocked:j}),R()},onOpenBuildTab:()=>I("build"),isBuilding:bs.active,buildingLabel:bs.label,buildingStepLabel:sh,buildingStepPosition:ah,buildingStatus:bs.status,buildingProgress:rh,onResetBuild:()=>ue(!0),emptyStateBuildStatus:tO,skipDesignSignal:TO}})]}),XO=Qn.some(pt=>RU(pt.app.type)),QO=gt.reduce((pt,Qs)=>pt+Qs.scenarios.length,0),hh=!!ce&&!rn&&QO===0,ZO=dP(),gn=VY();return t.jsx(cE,{children:t.jsxs(dE,{fallbackUpload:gn.uploadFiles,onError:gn.showError,children:[t.jsx(SP,{}),t.jsx(cN,{splitRef:rt,isCollapsed:ut,hidePreview:ci,onHomeLivePageBack:Ie&&Pt?()=>zt(!1):void 0,onResizeStart:jt,onResizeReset:Ct,onResizeNudge:Tt,isResizing:Yt,leftWidth:vt,leftWidthMin:Kn,isNarrow:Gt,mobilePane:Pn,onMobilePaneChange:Jn,isAgentBuilding:oa,buildIdle:bi,leftPane:t.jsx(N2,{activeTab:_,onSendTranscript:ke,appTabContent:JO,awaitingPlanLaunchChoice:UO,buildActivated:w,planActivated:k,buildIdle:bi,agentBlocked:rO,isAgentBuilding:oa,planActive:Jp,planIdle:Xp,bannerVisible:aO,onDismissIdleBanner:dO,hideResultsCommandKey:ie,leftWidth:IP,fullWidth:Gt||ci,navigateToTab:nh,onAgentActive:lO,onAgentIdle:oO,onAgentBlocked:iO,onUserInput:cO,notifSettings:eh,onSettingsChange:th,provider:nO,onRestorePreview:GO,onResultsScenarioSelect:YO,previewSlug:gs,featureCycleComplete:Ke,featureSummary:De,onContinueInSession:AO,onStopBuilding:MO,showResultsCommandKey:ae,planChatOpen:ve,onPlanChatOpenChange:Ne,showPlanCompleteModal:te,onCreateNewPlan:DO,onContinueSession:LO,onViewPlans:FO,pendingPlans:Le,onSelectPlan:$O,selectPlanOpen:de,onPickPlan:BO,onCancelSelectPlan:zO,launchingPlanSlug:xi,planLaunchError:eO,prototypeLaunchSignal:L,planCompleteSignal:se,showBuildLaunchModal:ph,buildLaunchGateArmed:HO,buildActivity:Et.activity,buildActivityMinimized:Et.minimized,chatEscalatedToPrototype:ch,onChooseActivity:Et.chooseActivity,onNavigateToPlanTab:lh,onToggleDesigns:EO,designsOpen:CO,onActivityDone:Et.finishActivity,onPrototypeLaunched:Et.startSession,onMinimizeActivityModal:Et.hasLiveActivity?Et.minimize:void 0,onReopenActivityModal:qO?Et.reopen:void 0,onSubmitBuildPrompt:WO,submittingBuildPrompt:_e,buildPromptError:V,pendingPlansLoading:Oe,pendingPlansError:Ue,onReorderPlans:$e,buildDisabled:j,onPreviewScreenshot:jO,onRunHistoryPlan:oh,projectTitle:(ge==null?void 0:ge.projectTitle)??null,designSession:uh}),previewPane:t.jsx(hP,{emptyStateMessage:PU({configLoading:sa,hasNoApps:Qn.length===0,hasStepState:!!ce,hasPreviewableApp:XO,setupInProgress:hh,hasCaptureFrame:ZO.available}),projectSetupInProgress:hh,previewSlug:gs,previewUrl:hi,viewports:BP,activeViewport:Js.name,onViewportChange:WP,isCollapsed:ut,onToggleCollapsed:tn,isNarrow:Gt,onBack:Ie&&Pt?()=>zt(!1):void 0,onPlanChange:Ie&&Pt?()=>nh("plan"):void 0,isFilled:st,onToggleFilled:Xn,currentWidth:Js.width,currentHeight:Js.height,onCustomSizeChange:Vp,buildingScenarioSlug:Kp,buildingScreenshotPath:_O,buildingScenarioName:SO,buildingScenarioDescription:kO,onDismissBuildingOverlay:Xs,historicalScreenshotPath:(Bt==null?void 0:Bt.screenshotPath)??null,historicalScenarioName:(Bt==null?void 0:Bt.scenarioName)??null,historicalHeading:(Bt==null?void 0:Bt.heading)??null,historicalSubtext:(Bt==null?void 0:Bt.subtext)??null,onDismissHistoricalPreview:wO,previewSeeding:HP,previewSeedError:qP,previewSeedErrorKind:UP,onRetrySeed:YP,currentScenario:Hp(gs,gt),scenarioGroups:gt,onShowScenarioPreview:ih,commandNonce:GP,previewOrigin:Cl(ge,Zn),onDesignConfirmed:D,onExitDesigns:RO,designSession:uh,onSkipDesign:PO,designReturnVisible:O,onOpenDesigns:OO,onDismissDesignReturn:W,credentialTarget:VP,onCredentialStored:JP,onCloseCredentialRequest:XP})}),We?t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},children:t.jsx(NP,{featureName:(ce==null?void 0:ce.feature)??null,onClose:qe})}):null,t.jsx(PP,{isOpen:B,onClose:()=>F(!1)}),t.jsx(CP,{sha:e,onClick:()=>F(!0)}),t.jsx(OP,{visible:gn.dragActive,destinationLabel:gn.designDropLabel}),gn.error?t.jsx(RP,{message:gn.error}):null,gn.pendingPaths?t.jsx(EP,{paths:gn.pendingPaths,onClose:gn.clearPending}):null,X?t.jsx(fP,{busy:be,onCancel:()=>ue(!1),onConfirm:()=>void IO(),planSessionActive:Jp||Xp}):null,vO]})})}const vie=Object.freeze(Object.defineProperty({__proto__:null,EditorShell:QY},Symbol.toStringTag,{value:"Module"}));export{pu as $,xo as A,Dp as B,bo as C,eC as D,vL as E,EP as F,$re as G,RC as H,p7 as I,mC as J,jC as K,In as L,Mj as M,Ns as N,B0 as O,Bj as P,Wr as Q,hb as R,ow as S,yo as T,ls as U,FL as V,$L as W,WL as X,zL as Y,BL as Z,et as _,Do as a,sb as a$,Ds as a0,Te as a1,vw as a2,du as a3,uu as a4,Rj as a5,Pe as a6,jg as a7,Rs as a8,_g as a9,Ox as aA,Rx as aB,Ix as aC,Ex as aD,Ax as aE,Mx as aF,Dx as aG,$x as aH,Wx as aI,ul as aJ,md as aK,$r as aL,fd as aM,qx as aN,gd as aO,Yx as aP,Vx as aQ,Jx as aR,Xx as aS,xd as aT,Qx as aU,Kx as aV,Gx as aW,Ux as aX,eb as aY,tb as aZ,nb as a_,Sg as aa,kg as ab,Ng as ac,Cg as ad,Tg as ae,Pg as af,rl as ag,Og as ah,Gg as ai,cl as aj,xx as ak,bx as al,zg as am,yx as an,jx as ao,wx as ap,_x as aq,Ug as ar,Fg as as,Lg as at,Wa as au,kx as av,_o as aw,Nx as ax,$g as ay,Px as az,Na as b,va as b$,yd as b0,bd as b1,rb as b2,ab as b3,ob as b4,ib as b5,Zx as b6,cb as b7,db as b8,lb as b9,Fb as bA,$b as bB,zb as bC,Bb as bD,Wb as bE,xl as bF,Ub as bG,ay as bH,zx as bI,Hx as bJ,iy as bK,Ed as bL,hy as bM,py as bN,dy as bO,ly as bP,Yb as bQ,Kb as bR,Jb as bS,Gb as bT,ry as bU,ny as bV,ty as bW,ey as bX,Zb as bY,Qb as bZ,Xb as b_,pl as ba,ub as bb,_d as bc,Sd as bd,mb as be,kd as bf,fb as bg,xb as bh,Nd as bi,gb as bj,Eb as bk,Ab as bl,Mb as bm,Ib as bn,yb as bo,jb as bp,vb as bq,wb as br,Cd as bs,_b as bt,bb as bu,Nb as bv,Tb as bw,Cb as bx,Db as by,Lb as bz,_G as c,Wj as c$,sy as c0,bl as c1,fy as c2,gy as c3,xy as c4,by as c5,vl as c6,yy as c7,vy as c8,Ty as c9,av as cA,Ld as cB,Dy as cC,Ly as cD,Fy as cE,pb as cF,ov as cG,iv as cH,Nv as cI,Tv as cJ,Pj as cK,kv as cL,Sv as cM,tu as cN,Tl as cO,On as cP,Sa as cQ,ss as cR,ns as cS,ts as cT,En as cU,Xt as cV,$j as cW,Lj as cX,kl as cY,Yv as cZ,zj as c_,sr as ca,Py as cb,Oy as cc,Ry as cd,Ey as ce,Ay as cf,wd as cg,Iy as ch,My as ci,$y as cj,zy as ck,$d as cl,Dr as cm,zd as cn,By as co,So as cp,zs as cq,Wy as cr,Hy as cs,Yy as ct,Ya as cu,Fd as cv,Ws as cw,Zy as cx,sv as cy,Ud as cz,j_ as d,jL as d$,nu as d0,i1 as d1,$t as d2,oP as d3,H5 as d4,zw as d5,$w as d6,Fw as d7,y_ as d8,$n as d9,c1 as dA,i5 as dB,fT as dC,tC as dD,Gn as dE,f1 as dF,Vn as dG,Yd as dH,yt as dI,eu as dJ,Yn as dK,Oj as dL,t5 as dM,Ro as dN,Is as dO,Qo as dP,Nt as dQ,Eo as dR,Hr as dS,Lw as dT,ou as dU,ot as dV,Se as dW,wT as dX,GC as dY,dv as dZ,Io as d_,wn as da,Ce as db,Re as dc,Hn as dd,kP as de,_p as df,h1 as dg,m1 as dh,ur as di,$ as dj,LN as dk,dp as dl,l5 as dm,uN as dn,Cc as dp,zC as dq,Nc as dr,OC as ds,_N as dt,C2 as du,UC as dv,AC as dw,Z1 as dx,l1 as dy,Ls as dz,Ag as e,Vd as e$,EC as e0,Hs as e1,WC as e2,cv as e3,k_ as e4,R_ as e5,O_ as e6,T_ as e7,C_ as e8,N_ as e9,GT as eA,y5 as eB,YT as eC,nP as eD,tP as eE,j1 as eF,Mv as eG,Iv as eH,Av as eI,Ov as eJ,Ev as eK,kt as eL,Nj as eM,kj as eN,Sj as eO,Tj as eP,Cj as eQ,jj as eR,nN as eS,Rd as eT,V1 as eU,K1 as eV,Y1 as eW,q1 as eX,H1 as eY,B1 as eZ,W1 as e_,vu as ea,Wn as eb,hv as ec,rr as ed,qT as ee,Xe as ef,is as eg,HC as eh,uv as ei,XC as ej,JC as ek,lt as el,Qt as em,kn as en,Mt as eo,iu as ep,fv as eq,pv as er,WT as es,ft as et,w5 as eu,j5 as ev,k5 as ew,_5 as ex,v5 as ey,N5 as ez,sd as f,B2 as f$,rv as f0,w_ as f1,__ as f2,yv as f3,bv as f4,jv as f5,vv as f6,vj as f7,R0 as f8,T0 as f9,A0 as fA,j0 as fB,v0 as fC,x0 as fD,g0 as fE,m0 as fF,b0 as fG,Gj as fH,Uj as fI,Hj as fJ,Ol as fK,qj as fL,D1 as fM,P1 as fN,O1 as fO,R1 as fP,I1 as fQ,E1 as fR,A1 as fS,L1 as fT,z1 as fU,M1 as fV,F1 as fW,$1 as fX,Zr as fY,A2 as fZ,q2 as f_,_0 as fa,O0 as fb,P0 as fc,w0 as fd,Hg as fe,Nu as ff,Lv as fg,uj as fh,Nl as fi,dj as fj,Gd as fk,CP as fl,xr as fm,KT as fn,XT as fo,QT as fp,ZT as fq,JT as fr,e5 as fs,eP as ft,VT as fu,o5 as fv,s5 as fw,n5 as fx,r5 as fy,a5 as fz,ka as g,IN as g$,M2 as g0,I2 as g1,L2 as g2,F2 as g3,xc as g4,Cp as g5,$2 as g6,z2 as g7,O2 as g8,hp as g9,Q5 as gA,Z5 as gB,J5 as gC,X5 as gD,TP as gE,PP as gF,ZS as gG,S2 as gH,_2 as gI,k2 as gJ,RP as gK,OP as gL,Ku as gM,lk as gN,w2 as gO,nk as gP,rk as gQ,sk as gR,v2 as gS,y2 as gT,b2 as gU,g2 as gV,m2 as gW,x2 as gX,j2 as gY,Jt as gZ,MN as g_,W2 as ga,H2 as gb,R2 as gc,U2 as gd,x1 as ge,s1 as gf,o1 as gg,r1 as gh,p1 as gi,TT as gj,OT as gk,PT as gl,ET as gm,NT as gn,kT as go,ST as gp,Rc as gq,IT as gr,MT as gs,G2 as gt,AT as gu,CT as gv,RT as gw,DT as gx,JS as gy,KS as gz,Ni as h,Wd as h$,DN as h0,Kk as h1,ON as h2,EN as h3,Od as h4,PN as h5,RN as h6,AN as h7,CN as h8,TN as h9,SN as hA,FN as hB,go as hC,l2 as hD,d2 as hE,i2 as hF,u2 as hG,jT as hH,vT as hI,wa as hJ,Pv as hK,zv as hL,Fv as hM,Bv as hN,QY as hO,Pc as hP,yT as hQ,Yj as hR,nj as hS,lc as hT,a1 as hU,ic as hV,pc as hW,Hk as hX,qN as hY,Au as hZ,k1 as h_,si as ha,yN as hb,vN as hc,bN as hd,ad as he,Gk as hf,Bk as hg,lp as hh,zk as hi,Vk as hj,Uk as hk,qk as hl,Yk as hm,Uy as hn,cp as ho,ip as hp,op as hq,hk as hr,uk as hs,Ju as ht,Vl as hu,ck as hv,fk as hw,YC as hx,NN as hy,kN as hz,XS as i,xT as i$,r2 as i0,wv as i1,_v as i2,gx as i3,J1 as i4,X1 as i5,Yo as i6,s2 as i7,n2 as i8,t2 as i9,bj as iA,yj as iB,Xd as iC,lj as iD,oj as iE,aj as iF,rj as iG,ij as iH,cj as iI,Qv as iJ,tj as iK,ej as iL,Xv as iM,Zv as iN,Vv as iO,Gv as iP,su as iQ,El as iR,ew as iS,tw as iT,Jj as iU,rw as iV,Zj as iW,Kj as iX,Sl as iY,ja as iZ,Qd as i_,mx as ia,XN as ib,JN as ic,KN as id,VN as ie,YN as ig,E0 as ih,Vu as ii,Gu as ij,qv as ik,Uv as il,Hv as im,a2 as io,t1 as ip,oc as iq,e1 as ir,Dv as is,Jd as it,xv as iu,pj as iv,hj as iw,mj as ix,gj as iy,xj as iz,ek as j,kC as j$,lo as j0,cP as j1,Dc as j2,aP as j3,pP as j4,C5 as j5,q5 as j6,U5 as j7,z5 as j8,$5 as j9,IC as jA,MC as jB,DC as jC,$p as jD,FC as jE,lC as jF,Hl as jG,wS as jH,jS as jI,gS as jJ,mS as jK,xS as jL,nS as jM,kc as jN,wC as jO,Tc as jP,nT as jQ,li as jR,tT as jS,aT as jT,oT as jU,Du as jV,Vr as jW,Xo as jX,Y5 as jY,qn as jZ,PC as j_,B5 as ja,F5 as jb,L5 as jc,fP as jd,ZC as je,K5 as jf,V5 as jg,FT as jh,LT as ji,zT as jj,Y2 as jk,UT as jl,BT as jm,D5 as jn,Zk as jo,iN as jp,Fu as jq,mT as jr,ao as js,QC as jt,$C as ju,KC as jv,qC as jw,BC as jx,cC as jy,dC as jz,l0 as k,Iw as k$,iT as k0,Ea as k1,_C as k2,CC as k3,TC as k4,Op as k5,rT as k6,sT as k7,iS as k8,sS as k9,V_ as kA,G_ as kB,Y_ as kC,U_ as kD,q_ as kE,l_ as kF,i_ as kG,o_ as kH,a_ as kI,r_ as kJ,s_ as kK,n_ as kL,t_ as kM,e_ as kN,Zw as kO,Qw as kP,Xw as kQ,Jw as kR,Vw as kS,Gw as kT,Yw as kU,Uw as kV,qw as kW,Ww as kX,Bw as kY,Hw as kZ,Dw as k_,eS as ka,Jo as kb,ll as kc,tS as kd,Yr as ke,uS as kf,Ht as kg,dT as kh,cT as ki,hT as kj,rs as kk,zN as kl,zr as km,fS as kn,yS as ko,vS as kp,pS as kq,W0 as kr,H0 as ks,SS as kt,_S as ku,o2 as kv,Q_ as kw,X_ as kx,J_ as ky,K_ as kz,sj as l,ES as l$,Mw as l0,Rw as l1,Pw as l2,x_ as l3,g_ as l4,m_ as l5,f_ as l6,h_ as l7,d_ as l8,c_ as l9,Pl as lA,Dj as lB,Fj as lC,iw as lD,$l as lE,p0 as lF,u0 as lG,Mg as lH,Ll as lI,Z_ as lJ,e0 as lK,t0 as lL,jo as lM,s0 as lN,vo as lO,Qk as lP,w1 as lQ,lN as lR,p2 as lS,hP as lT,$N as lU,N2 as lV,cN as lW,oN as lX,aN as lY,RS as lZ,Ss as l_,bw as la,Il as lb,b_ as lc,Ml as ld,H_ as le,W_ as lf,B_ as lg,z_ as lh,$_ as li,F_ as lj,Dl as lk,L_ as ll,I_ as lm,M_ as ln,qo as lo,A_ as lp,E_ as lq,qb as lr,S_ as ls,v_ as lt,cw as lu,lw as lv,mw as lw,gw as lx,xw as ly,Ij as lz,Wv as m,$o as m$,OS as m0,PS as m1,TS as m2,US as m3,_1 as m4,C1 as m5,N1 as m6,v1 as m7,m5 as m8,x5 as m9,tv as mA,Hd as mB,qd as mC,fw as mD,gT as mE,yp as mF,_P as mG,Q2 as mH,X2 as mI,Z2 as mJ,J2 as mK,K2 as mL,V2 as mM,Fo as mN,bu as mO,Ew as mP,Aw as mQ,Ow as mR,xu as mS,Ho as mT,Wo as mU,Bo as mV,_w as mW,zo as mX,ww as mY,hu as mZ,dn as m_,h5 as ma,p5 as mb,u5 as mc,b5 as md,f5 as me,d5 as mf,g5 as mg,c5 as mh,Ec as mi,Mo as mj,$v as mk,ru as ml,tk as mm,YS as mn,Jk as mo,AS as mp,CS as mq,y1 as mr,NS as ms,n1 as mt,kS as mu,aw as mv,Vj as mw,O5 as mx,sN as my,ze as mz,Zc as n,Dte as n$,kw as n0,Ga as n1,fu as n2,Al as n3,Tw as n4,Nw as n5,Sw as n6,Cw as n7,Aa as n8,lP as n9,_Q as nA,bee as nB,TX as nC,NG as nD,PX as nE,bX as nF,yX as nG,xX as nH,bQ as nI,Fte as nJ,Lte as nK,lZ as nL,IQ as nM,Hse as nN,xG as nO,cG as nP,gG as nQ,uG as nR,hG as nS,fG as nT,mG as nU,TZ as nV,jG as nW,WK as nX,wG as nY,zK as nZ,pee as n_,uP as na,VQ as nb,nZ as nc,nQ as nd,XQ as ne,SJ as nf,Gse as ng,sZ as nh,pse as ni,hQ as nj,xre as nk,Uae as nl,_Z as nm,pie as nn,HX as no,qX as np,zX as nq,BX as nr,$X as ns,WX as nt,lK as nu,WV as nv,$te as nw,FK as nx,lV as ny,zV as nz,uF as o,Koe as o$,xee as o0,gee as o1,aee as o2,bne as o3,yne as o4,qae as o5,Wae as o6,Hae as o7,Jte as o8,Bte as o9,EV as oA,AV as oB,_V as oC,wV as oD,yV as oE,dee as oF,oie as oG,nie as oH,tie as oI,rie as oJ,hZ as oK,uZ as oL,pZ as oM,NZ as oN,UZ as oO,sQ as oP,Voe as oQ,Goe as oR,tZ as oS,eZ as oT,aQ as oU,rQ as oV,ZQ as oW,QQ as oX,FJ as oY,tQ as oZ,Joe as o_,dae as oa,WZ as ob,HZ as oc,fte as od,hte as oe,pne as of,iJ as og,oJ as oh,CV as oi,PV as oj,xV as ok,TV as ol,XX as om,bV as on,ZX as oo,QX as op,mV as oq,JX as or,NV as os,SV as ot,jV as ou,vV as ov,RV as ow,KX as ox,OV as oy,gV as oz,o0 as p,IX as p$,$Q as p0,Vse as p1,dG as p2,qoe as p3,jae as p4,jne as p5,kne as p6,wne as p7,Sne as p8,nV as p9,dV as pA,Ere as pB,TG as pC,xQ as pD,ree as pE,qQ as pF,_re as pG,BV as pH,UJ as pI,lX as pJ,iX as pK,KJ as pL,LX as pM,FX as pN,DX as pO,$J as pP,zJ as pQ,WJ as pR,UX as pS,HJ as pT,BJ as pU,EX as pV,RX as pW,OX as pX,hX as pY,MX as pZ,AX as p_,mQ as pa,Rte as pb,PJ as pc,zG as pd,mse as pe,hie as pf,EZ as pg,ore as ph,pG as pi,Zoe as pj,Qoe as pk,LZ as pl,qJ as pm,sK as pn,gX as po,MQ as pp,sX as pq,tX as pr,nX as ps,rX as pt,oX as pu,aX as pv,dQ as pw,MJ as px,cQ as py,mX as pz,d0 as q,Ioe as q$,YJ as q0,SX as q1,CX as q2,NX as q3,_X as q4,kX as q5,DQ as q6,lQ as q7,uQ as q8,pQ as q9,die as qA,Qte as qB,Kte as qC,Vte as qD,oV as qE,DK as qF,sV as qG,gne as qH,Woe as qI,Hoe as qJ,Uoe as qK,Yoe as qL,Loe as qM,Boe as qN,zoe as qO,Foe as qP,$oe as qQ,Jne as qR,Xae as qS,aJ as qT,toe as qU,WG as qV,fQ as qW,moe as qX,iie as qY,Zae as qZ,Qae as q_,BG as qa,cie as qb,hre as qc,xne as qd,kZ as qe,Mae as qf,yZ as qg,Ese as qh,oZ as qi,KQ as qj,AZ as qk,gie as ql,mie as qm,hne as qn,LV as qo,Kee as qp,Vee as qq,dte as qr,GV as qs,cte as qt,yee as qu,fZ as qv,wZ as qw,bK as qx,CJ as qy,vG as qz,U7 as r,Tre as r$,roe as r0,soe as r1,ooe as r2,ioe as r3,aoe as r4,noe as r5,Jae as r6,rJ as r7,Doe as r8,qZ as r9,une as rA,Kae as rB,Vae as rC,Gae as rD,HG as rE,fJ as rF,IG as rG,tne as rH,ene as rI,rne as rJ,EG as rK,yse as rL,eJ as rM,nJ as rN,tJ as rO,ZK as rP,are as rQ,rre as rR,fse as rS,Xte as rT,jse as rU,_K as rV,Dse as rW,iee as rX,vZ as rY,Pre as rZ,cJ as r_,vse as ra,Ase as rb,jJ as rc,BK as rd,bse as re,xse as rf,MG as rg,AG as rh,gse as ri,mJ as rj,hJ as rk,lJ as rl,bJ as rm,cne as rn,sne as ro,lne as rp,nne as rq,dne as rr,one as rs,ane as rt,gJ as ru,ine as rv,sJ as rw,vJ as rx,yJ as ry,pJ as rz,i0 as s,Fre as s$,iZ as s0,dse as s1,zae as s2,Bae as s3,Fae as s4,Dae as s5,Lae as s6,Iae as s7,$ae as s8,ste as s9,Tae as sA,ure as sB,iQ as sC,Zre as sD,oae as sE,cae as sF,nae as sG,Hre as sH,lae as sI,aae as sJ,rae as sK,gQ as sL,sae as sM,Lre as sN,Dre as sO,Jre as sP,Xre as sQ,Qre as sR,Wre as sS,Ure as sT,qre as sU,Bre as sV,zre as sW,Gre as sX,Vre as sY,eae as sZ,Kre as s_,Hne as sa,Aae as sb,_oe as sc,Mee as sd,KV as se,gte as sf,mte as sg,ute as sh,xte as si,pte as sj,yte as sk,Gee as sl,wJ as sm,cee as sn,bte as so,Oee as sp,Pee as sq,Ane as sr,UK as ss,vX as st,aie as su,vte as sv,Yae as sw,QK as sx,lG as sy,Pae as sz,au as t,Tee as t$,tae as t0,Ire as t1,Ite as t2,fee as t3,use as t4,Nne as t5,vK as t6,wK as t7,jK as t8,SK as t9,YQ as tA,GQ as tB,dZ as tC,qse as tD,HQ as tE,wX as tF,jX as tG,oQ as tH,eK as tI,nK as tJ,tK,ZV as tL,QV as tM,XV as tN,SZ as tO,Ooe as tP,Poe as tQ,Eoe as tR,Roe as tS,Toe as tT,Aoe as tU,Coe as tV,Sse as tW,xJ as tX,_se as tY,jee as tZ,eoe as t_,TK as ta,CK as tb,EK as tc,RK as td,MK as te,PK as tf,OK as tg,AK as th,ase as ti,aK as tj,pK as tk,ose as tl,hK as tm,uK as tn,dK as to,NK as tp,kK as tq,rK as tr,xK as ts,IK as tt,uee as tu,BZ as tv,UG as tw,JJ as tx,Moe as ty,UQ as tz,To as u,VZ as u$,Ene as u0,LJ as u1,JZ as u2,see as u3,eee as u4,XZ as u5,nee as u6,tee as u7,ZZ as u8,QZ as u9,tV as uA,Rne as uB,_ne as uC,$V as uD,xZ as uE,Zte as uF,YG as uG,Yte as uH,Eae as uI,CG as uJ,yie as uK,One as uL,mne as uM,QG as uN,GK as uO,$K as uP,LK as uQ,HK as uR,qK as uS,YK as uT,tre as uU,DJ as uV,GZ as uW,EJ as uX,RJ as uY,ise as uZ,KZ as u_,tse as ua,nse as ub,sse as uc,Qne as ud,LQ as ue,ese as uf,rse as ug,Xne as uh,VX as ui,eQ as uj,Zne as uk,Yee as ul,Cee as um,See as un,DG as uo,PG as up,OG as uq,kee as ur,Nee as us,RG as ut,uV as uu,Yse as uv,VJ as uw,GJ as ux,bie as uy,xie as uz,ds as v,bae as v$,NJ as v0,kJ as v1,yK as v2,AJ as v3,OJ as v4,lee as v5,hee as v6,oee as v7,GX as v8,PZ as v9,Tne as vA,sie as vB,foe as vC,hoe as vD,mee as vE,WQ as vF,Ine as vG,oK as vH,iae as vI,iK as vJ,qG as vK,_ae as vL,wae as vM,lte as vN,vae as vO,Sae as vP,Ise as vQ,Nae as vR,gK as vS,lre as vT,yae as vU,xae as vV,gae as vW,mae as vX,fae as vY,hae as vZ,pae as v_,eX as va,ZJ as vb,pX as vc,cX as vd,fX as ve,uX as vf,hV as vg,aZ as vh,Kse as vi,lie as vj,Mse as vk,ire as vl,hse as vm,lse as vn,Wse as vo,cse as vp,vie as vq,Cte as vr,Tte as vs,Nte as vt,kte as vu,Ste as vv,Pte as vw,Mne as vx,GG as vy,Rae as vz,Jv as w,zQ as w$,Yre as w0,uae as w1,pV as w2,cK as w3,ote as w4,VG as w5,ite as w6,ate as w7,kae as w8,nte as w9,HV as wA,UV as wB,Cae as wC,qV as wD,Nre as wE,vee as wF,doe as wG,coe as wH,uoe as wI,poe as wJ,Vne as wK,Gne as wL,Une as wM,Yne as wN,qne as wO,Kne as wP,Bne as wQ,Wne as wR,$ne as wS,Fne as wT,zne as wU,Lne as wV,NQ as wW,$Z as wX,uJ as wY,uie as wZ,YZ as w_,tte as wa,Zee as wb,Qee as wc,FG as wd,$G as we,ete as wf,Mre as wg,Are as wh,Cre as wi,MV as wj,wse as wk,IZ as wl,eV as wm,joe as wn,Noe as wo,Ree as wp,xoe as wq,woe as wr,boe as ws,Soe as wt,koe as wu,voe as wv,yoe as ww,DZ as wx,gZ as wy,mZ as wz,NP as x,Hte as x$,BQ as x0,Xee as x1,IJ as x2,Rse as x3,Ose as x4,Pse as x5,Tse as x6,Nse as x7,mK as x8,Cse as x9,zee as xA,goe as xB,Uee as xC,$ee as xD,Wee as xE,Bee as xF,zte as xG,Mte as xH,fne as xI,Ote as xJ,_te as xK,Cne as xL,wte as xM,JV as xN,kV as xO,vne as xP,Pne as xQ,fie as xR,Hee as xS,IV as xT,wre as xU,eie as xV,DV as xW,fV as xX,jre as xY,Gte as xZ,Wte as x_,fK as xa,kse as xb,SG as xc,jZ as xd,kG as xe,Oae as xf,FV as xg,aV as xh,rV as xi,iV as xj,ZG as xk,KG as xl,Xoe as xm,CZ as xn,dJ as xo,Use as xp,Jee as xq,Bse as xr,zse as xs,$se as xt,LG as xu,Fse as xv,Lse as xw,MZ as xx,_J as xy,bre as xz,y7 as y,KK as y$,qee as y0,sre as y1,ere as y2,Zse as y3,nre as y4,Qse as y5,Xse as y6,Jse as y7,dX as y8,Ate as y9,_ee as yA,wee as yB,Lee as yC,Dee as yD,Aee as yE,Eee as yF,Iee as yG,jte as yH,CQ as yI,QJ as yJ,XJ as yK,YX as yL,AQ as yM,SQ as yN,wQ as yO,vQ as yP,kQ as yQ,PQ as yR,TJ as yS,OZ as yT,FZ as yU,rte as yV,Fee as yW,bZ as yX,cZ as yY,XK as yZ,JK as y_,mre as ya,gre as yb,vre as yc,yre as yd,pre as ye,fre as yf,JG as yg,zZ as yh,kre as yi,Sre as yj,dre as yk,cre as yl,RZ as ym,VV as yn,yG as yo,bG as yp,Rre as yq,Ore as yr,jQ as ys,yQ as yt,TQ as yu,RQ as yv,EQ as yw,OQ as yx,Dne as yy,YV as yz,uC as z,VK as z0,XG as z1,Ete as z2,cV as z3,FQ as z4,qte as z5,Ute as z6,loe as z7,rZ as z8,JQ as z9,Lo as za};
|