@capagents/forgeqe 2.7.0 → 2.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/HOW_TO_USE.md +92 -19
  2. package/THIRD_PARTY_NOTICES.md +39 -0
  3. package/dist/docs-site/docs/index.html +79 -2
  4. package/dist/docs-site/docs/search.js +1 -1
  5. package/dist/forgeqe.js +1564 -1506
  6. package/dist/web/THIRD_PARTY_NOTICES.md +18 -51
  7. package/dist/web/assets/Agent-CxCmYQU5.js +4 -0
  8. package/dist/web/assets/ApiTests-BYx-CDHt.js +10 -0
  9. package/dist/web/assets/Chat-C6tALAzM.js +3 -0
  10. package/dist/web/assets/Data-IpXp3YB-.js +3 -0
  11. package/dist/web/assets/Evidence-B9rcXYHM.js +1 -0
  12. package/dist/web/assets/Features-EGps6J7t.js +1 -0
  13. package/dist/web/assets/Jobs-DutW6w6P.js +5 -0
  14. package/dist/web/assets/KindPage-DOYNwJDp.js +6 -0
  15. package/dist/web/assets/Migration-5kPbd43c.js +2 -0
  16. package/dist/web/assets/Product-DSxgpqDA.js +1 -0
  17. package/dist/web/assets/Quality-Bo0GxWoZ.js +1 -0
  18. package/dist/web/assets/Record-gGESInMV.js +2 -0
  19. package/dist/web/assets/Regression-b5ykN8hf.js +5 -0
  20. package/dist/web/assets/Reports-BcIDq-yP.js +2 -0
  21. package/dist/web/assets/Response-DLbH7Zyc.js +4 -0
  22. package/dist/web/assets/Runs-C9YExlBk.js +2 -0
  23. package/dist/web/assets/Shell-DGv_Zqjs.js +3 -0
  24. package/dist/web/assets/TestCases-CynVHtUB.js +1 -0
  25. package/dist/web/assets/TestData-5ynuvxFS.js +2 -0
  26. package/dist/web/assets/Tosca-BMePLsZA.js +2 -0
  27. package/dist/web/assets/WhatsNew-gMY090GS.js +1 -0
  28. package/dist/web/assets/dataParts-PzO8u_dt.js +3 -0
  29. package/dist/web/assets/index-CrZYPHPP.css +2 -0
  30. package/dist/web/assets/index-DI1ST-gI.js +43 -0
  31. package/dist/web/assets/parts-BD8kP4IN.js +1 -0
  32. package/dist/web/assets/productParts-Q9GA6BML.js +1 -0
  33. package/dist/web/assets/qualityParts-Df8rJX4J.js +1 -0
  34. package/dist/web/assets/segmented-1nc3D7ML.js +1 -0
  35. package/dist/web/assets/{thread-Jysn_9Ki.js → thread-CE28Yblm.js} +2 -2
  36. package/dist/web/assets/{usePageChat-DOel8PVW.js → usePageChat-3HvaQpPP.js} +1 -1
  37. package/dist/web/index.html +3 -3
  38. package/docs/prompts/graphify-evidence.md +164 -0
  39. package/docs/user-guide.html +79 -2
  40. package/forgeqe.example.yaml +17 -1
  41. package/package.json +3 -1
  42. package/prompts/README.md +1 -0
  43. package/prompts/tosca.md +64 -0
  44. package/py/forgeqe_tosca/__init__.py +85 -0
  45. package/py/forgeqe_tosca/__main__.py +50 -0
  46. package/py/forgeqe_tosca/ntir.py +484 -0
  47. package/py/forgeqe_tosca/render.py +128 -0
  48. package/py/forgeqe_tosca/tsu.py +187 -0
  49. package/py/forgeqe_tosca/vendor/toscatsu/LICENSE +26 -0
  50. package/py/forgeqe_tosca/vendor/toscatsu/UPSTREAM +7 -0
  51. package/py/forgeqe_tosca/vendor/toscatsu/gen_tsu.py +735 -0
  52. package/py/forgeqe_tosca/vendor/toscatsu/parse_tsu.py +1979 -0
  53. package/py/forgeqe_tosca/vendor/toscatsu/spec_to_manifest.py +878 -0
  54. package/py/forgeqe_tosca/vendored.py +50 -0
  55. package/skills/tosca-knowledge/SKILL.md +56 -0
  56. package/skills/tosca-knowledge/references/actions-and-values.md +63 -0
  57. package/skills/tosca-knowledge/references/locators.md +29 -0
  58. package/skills/tosca-knowledge/references/mapping-cypress.md +21 -0
  59. package/skills/tosca-knowledge/references/mapping-playwright.md +31 -0
  60. package/skills/tosca-knowledge/references/mapping-selenium-webdriverio.md +26 -0
  61. package/skills/tosca-knowledge/references/ntir.md +46 -0
  62. package/dist/web/assets/Agent-CTf8KPLI.js +0 -4
  63. package/dist/web/assets/ApiTests-8frnNIDb.js +0 -10
  64. package/dist/web/assets/Chat-Dj_ewn_H.js +0 -3
  65. package/dist/web/assets/Data-rQIV2OfV.js +0 -3
  66. package/dist/web/assets/Evidence-Dn4Uyakw.js +0 -1
  67. package/dist/web/assets/Features-BHbDkY6d.js +0 -1
  68. package/dist/web/assets/Jobs-1kD96CNp.js +0 -5
  69. package/dist/web/assets/KindPage-zoTK8F69.js +0 -6
  70. package/dist/web/assets/Migration-BZcHKmJc.js +0 -2
  71. package/dist/web/assets/Product-DDFGmWxZ.js +0 -1
  72. package/dist/web/assets/Quality-CopMddhf.js +0 -1
  73. package/dist/web/assets/Record-DrgYte-f.js +0 -2
  74. package/dist/web/assets/Regression-Cvj1amuO.js +0 -5
  75. package/dist/web/assets/Reports-BCZeHlgo.js +0 -2
  76. package/dist/web/assets/Response-wbe7YDRm.js +0 -4
  77. package/dist/web/assets/Runs-C-U8Zto_.js +0 -2
  78. package/dist/web/assets/Shell-CUmMbYAE.js +0 -3
  79. package/dist/web/assets/TestCases-D_WpgWxA.js +0 -1
  80. package/dist/web/assets/TestData-B5gzaqO3.js +0 -2
  81. package/dist/web/assets/WhatsNew-BD1_wOmf.js +0 -1
  82. package/dist/web/assets/arrow-down-I4TbiZy1.js +0 -1
  83. package/dist/web/assets/arrow-right-vf1aUPQ0.js +0 -1
  84. package/dist/web/assets/circle-DdyoI0MW.js +0 -1
  85. package/dist/web/assets/circle-dashed-D-xCti8W.js +0 -1
  86. package/dist/web/assets/circle-dot-__mRW42w.js +0 -1
  87. package/dist/web/assets/dataParts-Pr6w8WFl.js +0 -3
  88. package/dist/web/assets/index-BiJ_Nvm1.css +0 -2
  89. package/dist/web/assets/index-mdr9iNZb.js +0 -43
  90. package/dist/web/assets/keyboard-yInSyaVv.js +0 -1
  91. package/dist/web/assets/pencil-wafYzIpD.js +0 -1
  92. package/dist/web/assets/productParts-96V-QyCQ.js +0 -1
  93. package/dist/web/assets/qualityParts-CQ_0RsYl.js +0 -1
  94. package/dist/web/assets/segmented-OwL-zu4L.js +0 -1
  95. package/dist/web/assets/upload-CXgoFfF6.js +0 -1
@@ -0,0 +1,2 @@
1
+ import{$ as e,$a as t,Bn as n,Dt as r,Ia as i,Ii as a,J as o,Jt as s,Kt as c,Oi as l,Sn as u,Tt as d,Xi as f,Xt as p,Y as m,Za as h,_i as g,at as _,bn as v,ca as y,dt as b,et as x,fi as S,ft as C,ga as w,hi as T,hr as E,ir as D,it as O,kt as k,mt as A,n as j,nn as M,no as N,ot as P,qi as F,st as ee,tn as I,ur as L,ut as R,vi as z,vn as B,wt as te,yr as V}from"./Shell-DGv_Zqjs.js";import{i as H,n as U,o as ne,t as W}from"./index-DI1ST-gI.js";import{t as G}from"./when-CHnpLdYw.js";import{_ as re,a as K,b as q,c as ie,d as ae,f as J,g as oe,h as se,i as ce,l as le,m as ue,n as de,o as fe,p as pe,r as Y,s as me,t as he,u as ge,v as _e,x as ve,y as ye}from"./parts-BD8kP4IN.js";var X=N(t(),1),Z=h(),be={py:`python`,ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,java:`java`,cs:`csharp`,rb:`ruby`};function xe({path:e}){let t=oe[be[e.split(`.`).pop()?.toLowerCase()||``]||``];return t?(0,Z.jsx)(t,{"aria-hidden":`true`,width:15,height:15,className:`flex-none`}):(0,Z.jsx)(L,{size:15,"aria-hidden":`true`,className:`flex-none text-muted`})}function Se(e){let t={name:``,path:``,dirs:new Map,files:[]};for(let n of e){let e=n.path.split(`/`),r=t;for(let t of e.slice(0,-1))r.dirs.has(t)||r.dirs.set(t,{name:t,path:r.path?`${r.path}/${t}`:t,dirs:new Map,files:[]}),r=r.dirs.get(t);r.files.push(n)}let n=e=>{for(let[t,r]of[...e.dirs]){let i=n(r);for(;i.files.length===0&&i.dirs.size===1;){let e=[...i.dirs.values()][0];i={...e,name:`${i.name}/${e.name}`}}e.dirs.set(t,i)}return e};return n(t)}function Ce({files:e,selected:t,onSelect:n,label:r}){let i=(0,X.useMemo)(()=>Se(e),[e]),[a,o]=(0,X.useState)(new Set),s=e=>o(t=>t.has(e)?new Set([...t].filter(t=>t!==e)):new Set([...t,e])),c=(e,r)=>(0,Z.jsxs)(Z.Fragment,{children:[[...e.dirs.values()].sort((e,t)=>e.name.localeCompare(t.name)).map(e=>{let t=!a.has(e.path);return(0,Z.jsxs)(`li`,{role:`treeitem`,"aria-expanded":t,"aria-selected":!1,className:`list-none`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>s(e.path),className:`flex h-8 w-full cursor-pointer items-center gap-1.5 rounded-[6px] border-0 bg-transparent px-1.5 text-left text-[13px] text-ink hover:bg-surface-strong`,children:[(0,Z.jsx)(u,{size:14,"aria-hidden":`true`,className:p(`flex-none text-muted transition-transform duration-150`,t&&`rotate-90`)}),t?(0,Z.jsx)(V,{size:15,"aria-hidden":`true`,className:`flex-none text-accent-fg`}):(0,Z.jsx)(E,{size:15,"aria-hidden":`true`,className:`flex-none text-accent-fg`}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.name})]}),t&&(0,Z.jsx)(`ul`,{role:`group`,className:`m-0 ml-[13px] border-l border-line-soft p-0 pl-2`,children:c(e,r+1)})]},e.path)}),[...e.files].sort((e,t)=>e.path.localeCompare(t.path)).map(e=>{let r=t===e.id;return(0,Z.jsx)(`li`,{role:`treeitem`,"aria-selected":r,className:`list-none`,children:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>n?.(e.id),"data-tip":e.title,className:p(`flex h-8 w-full items-center gap-2 rounded-[6px] border-0 px-1.5 text-left text-[13px]`,n?`cursor-pointer`:`cursor-default`,r?`bg-accent-soft font-medium text-ink`:`bg-transparent text-ink-2 hover:bg-surface-strong hover:text-ink`),children:[(0,Z.jsx)(`span`,{className:`w-[14px] flex-none`,"aria-hidden":`true`}),(0,Z.jsx)(xe,{path:e.path}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.path.slice(e.path.lastIndexOf(`/`)+1)}),e.tail]})},e.id)})]});return(0,Z.jsx)(`ul`,{role:`tree`,"aria-label":r,className:`m-0 flex flex-col p-0`,children:c(i,0)})}function we({title:e,side:t,file:n,lang:r,text:i,missing:a}){let o=(i??``).split(`
2
+ `),s=(0,X.useMemo)(()=>i?ne(i,r):null,[i,r]);return(0,Z.jsxs)(`figure`,{className:`m-0 flex min-h-0 min-w-0 flex-col overflow-hidden rounded-[12px] card border`,children:[(0,Z.jsxs)(`figcaption`,{className:`flex min-h-10 items-center gap-2 border-b border-line-soft pr-1 pl-3`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] font-semibold tracking-[0.04em] text-muted uppercase`,children:t}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[12px] text-ink-2`,"data-tip":n,children:n||e}),i&&(0,Z.jsx)(U,{text:i,label:`Copy ${n||t}`})]}),i?(0,Z.jsxs)(`div`,{className:`flex min-h-[260px] flex-1 overflow-auto font-mono text-[12.5px] leading-[1.6]`,children:[(0,Z.jsx)(`pre`,{"aria-hidden":`true`,className:`m-0 min-h-full flex-none self-stretch border-r border-line-soft px-3 py-3 text-right text-muted select-none`,children:o.map((e,t)=>`${t+1}\n`).join(``)}),(0,Z.jsx)(`pre`,{className:`m-0 min-w-0 flex-1 px-3 py-3`,children:(0,Z.jsx)(`code`,{className:`hljs`,children:s})})]}):(0,Z.jsx)(`p`,{className:`m-0 flex min-h-[260px] flex-1 items-center justify-center px-4 text-center text-sm text-muted`,children:a||`Nothing to show.`})]})}function Te({id:e,plan:t,result:n,initial:r}){let a=new Map((n?.units||[]).map(e=>[e.id,e.status])),o=[...t.units.filter(e=>e.kind!==`setup`).map(e=>({unit:e.id,kind:de[e.kind],source:e.source,target:e.target,status:a.get(e.id)})),...t.copies.map((e,t)=>({unit:`c${t}`,kind:`Data`,source:e.source,target:e.target,data:!0}))],[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(r||o.find(e=>e.kind===`Test`)?.unit||o[0]?.unit||``),[d,f]=(0,X.useState)(null),[m,h]=(0,X.useState)(``);(0,X.useEffect)(()=>{l&&(h(``),i.pair(e,l).then(f,e=>h(e.message)))},[e,l,n?.units.length,n?.endedAt]);let g=o.filter(e=>!s||`${e.source} ${e.target}`.toLowerCase().includes(s.toLowerCase())),_=o.filter(e=>e.status===`migrated`).length,v=o.filter(e=>e.status===`failed`||e.status===`blocked`).length;return(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] gap-4 @4xl:h-[calc(100vh-320px)] @4xl:min-h-[540px] @4xl:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,Z.jsxs)(`nav`,{"aria-label":`Files`,className:`flex max-h-[360px] min-h-0 min-w-0 flex-col gap-2 overflow-hidden rounded-[14px] card border p-3 @4xl:max-h-none`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5 px-1`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-semibold`,children:`Files`}),(0,Z.jsxs)(`span`,{className:`text-[12px] text-muted`,children:[_,` migrated · `,v,` failed · `,o.length,` files`]})]}),(0,Z.jsx)(O,{id:`find-a-file`,label:`Find a file`,value:s,onChange:c,className:`max-w-none flex-none`}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:g.length?(0,Z.jsx)(Ce,{label:`Files`,selected:l,onSelect:u,files:g.map(e=>({id:e.unit,path:e.target,title:e.source?`from ${e.source}`:void 0,tail:(0,Z.jsx)(`span`,{role:`img`,"aria-label":e.status?ie[e.status].label:e.data?`Copied`:`Waiting`,className:p(`size-2 flex-none rounded-full`,e.status===`migrated`?`bg-pass`:e.status===`failed`?`bg-fail`:e.status===`blocked`?`bg-warn`:e.status===`written`?`bg-line-strong`:`bg-line`)})}))}):(0,Z.jsx)(`p`,{className:`m-0 px-2 py-3 text-[13px] text-muted`,children:`No file matches.`})})]}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-col gap-3`,children:[m&&(0,Z.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:m}),(0,Z.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[minmax(0,1fr)] gap-3 @3xl:grid-cols-2`,children:[(0,Z.jsx)(we,{title:`Source`,side:`Source`,file:d?.source?.path,lang:d?.source?.lang||`plaintext`,text:d?.source?.text,missing:d&&!d.source?`This file is made new for the target.`:void 0}),(0,Z.jsx)(we,{title:`Target`,side:`Migrated`,file:d?.target.path,lang:d?.target.lang||`plaintext`,text:d?.target.text,missing:d&&!d.target.exists?`Not written yet.`:void 0})]})]})]})}var Ee=[`prepare`,`setup`,`migrate`,`validate`,`fix`,`review`];function De(e){if(e.job?.running)return{label:e.job.kind===`verify`?`Validating`:e.job.kind===`fix`?`Fixing`:`Running`,tone:`running`};let t=e.result;return t?.status===`running`?{label:t.stage===`validate`?`Validating`:t.stage===`fix`?`Fixing`:`Running`,tone:`running`}:t?ce[t.status]:e.job?.last?{label:`Did not start`,tone:`fail`}:e.confirmed?{label:`Confirmed`,tone:`neutral`}:le[e.plan.feasibility.verdict]}var Q=e=>e.slice(e.lastIndexOf(`/`)+1);function Oe({d:t,planView:n}){let r=t.result;if(!r)return(0,Z.jsx)(Z.Fragment,{children:n});let i=new Map(r.units.map(e=>[e.id,e])),a=t.plan.units.filter(e=>e.kind===`test`),s=r.units.filter(e=>e.kind===`test`&&e.status===`migrated`).length,c=t.plan.units.filter(e=>e.kind!==`setup`),l=r.units.filter(e=>e.kind!==`setup`&&(e.status===`migrated`||e.status===`written`)).length,u=r.units.filter(e=>e.status===`failed`||e.status===`blocked`).length,d=t.plan.source.stack,[f,...h]=t.plan.target.id.split(`-`);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Z.jsxs)(fe,{children:[(0,Z.jsx)(Y,{label:`Tests passing`,value:`${s} / ${a.length}`,tone:s===a.length&&a.length?`text-pass`:void 0}),(0,Z.jsx)(Y,{label:`Files migrated`,value:`${l} / ${c.length}`}),(0,Z.jsx)(Y,{label:`Need attention`,value:u,tone:u?`text-fail`:void 0}),(0,Z.jsx)(Y,{label:r.status===`running`?`Running for`:`Took`,value:ae(r.status===`running`?Date.now()-Date.parse(r.startedAt):r.ms)})]}),r.notes&&(0,Z.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:r.notes}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] items-start gap-5 @5xl:grid-cols-[minmax(0,1fr)_320px]`,children:[(0,Z.jsx)(o,{label:`Files`,placeholder:`Find a file`,empty:`No files.`,head:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`th`,{className:`py-2 pr-3 pl-3 font-medium`,children:`File`}),(0,Z.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:`Status`}),(0,Z.jsx)(`th`,{className:`hidden py-2 pr-3 font-medium @3xl:table-cell`,children:`Note`})]}),children:t.plan.units.map(t=>{let n=i.get(t.id),r=n?ie[n.status]:null;return(0,Z.jsxs)(`tr`,{className:e,children:[(0,Z.jsxs)(`td`,{className:m,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:t.kind===`setup`?`Project set-up`:Q(t.target)}),(0,Z.jsx)(`span`,{className:`block text-[12px] text-muted`,children:t.source?`from ${Q(t.source)}`:t.target})]}),(0,Z.jsx)(`td`,{className:p(m,`whitespace-nowrap`),children:r?(0,Z.jsx)(R,{tone:r.tone,children:r.label}):(0,Z.jsx)(`span`,{className:`text-[13px] text-muted`,children:`Waiting`})}),(0,Z.jsx)(`td`,{className:p(m,`hidden text-[13px] text-ink-2 @3xl:table-cell`),children:(0,Z.jsx)(`span`,{className:`line-clamp-2`,children:n?.problems?.[0]||n?.reason||``})})]},t.id)})}),(0,Z.jsxs)(`aside`,{"aria-label":`Details`,className:`flex flex-col gap-4 rounded-[14px] card border p-5 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[12px] font-medium text-muted`,children:`From`}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[d&&(0,Z.jsx)(q,{framework:d.framework,language:d.language}),t.plan.source.title]}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-ink-2`,children:[(0,Z.jsx)(ye,{kind:t.origin.kind,label:t.origin.label,size:15}),(0,Z.jsxs)(`span`,{className:`truncate`,"data-tip":t.origin.label,children:[J(t.origin.label),t.origin.branch?` · ${t.origin.branch}`:``]})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-line-soft pt-4`,children:[(0,Z.jsx)(`span`,{className:`text-[12px] font-medium text-muted`,children:`To`}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[(0,Z.jsx)(q,{framework:f,language:h.join(`-`)}),t.plan.target.title]}),(0,Z.jsx)(`span`,{className:`font-mono text-[12px] text-ink-2 [overflow-wrap:anywhere]`,children:t.targetPath})]}),(0,Z.jsxs)(`dl`,{className:`m-0 grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 border-t border-line-soft pt-4`,children:[(0,Z.jsx)(`dt`,{className:`text-muted`,children:`Started`}),(0,Z.jsx)(`dd`,{className:`m-0 text-right`,children:pe(r.startedAt)}),r.model&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`dt`,{className:`text-muted`,children:`Agent`}),(0,Z.jsx)(`dd`,{className:`m-0 truncate text-right`,"data-tip":r.model,children:r.model})]}),r.reverted.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`dt`,{className:`text-muted`,children:`Put back`}),(0,Z.jsxs)(`dd`,{className:`m-0 text-right`,children:[r.reverted.length,` edits outside the target`]})]})]})]})]})]})}function ke({d:e,events:t,picked:n,setPicked:r,busy:i,working:a,onFix:o,onCheck:s}){let[u,d]=(0,X.useState)(``),f=(0,X.useRef)(null),m=e.result?.validation?.tests||[],h=m.filter(e=>!e.ok),_=[];for(let t of e.result?.fixes||[])t.auto||_.push({who:`you`,text:t.note?`${t.note}`:`Fix ${Q(t.target)}`,at:t.at,detail:t.note?`for ${Q(t.target)}`:void 0}),_.push({who:`agent`,tone:t.ok?`ok`:`fail`,at:t.at,text:t.ok?`${Q(t.target)} passes now${t.attempts>1?` (${t.attempts} tries)`:``}. ${t.reason||``}`.trim():`I could not make ${Q(t.target)} pass. ${t.problems?.[0]||t.reason||``}`.trim(),detail:t.auto?`after the first check`:void 0});let v=a?t.filter(e=>e.stage===`fix`&&(e.kind===`agent`||e.kind===`ok`||e.kind===`fail`||e.kind===`info`)).slice(-6):[];(0,X.useEffect)(()=>{f.current&&(f.current.scrollTop=f.current.scrollHeight)},[_.length,v.length]);let y=()=>{let e=[...n];e.length&&(o(e,u.trim()),d(``))},b=e=>{let t=new Set(n);t.has(e)?t.delete(e):t.add(e),r(t)};return(0,Z.jsxs)(`section`,{"aria-label":`Migration agent`,className:`flex h-[560px] min-h-0 min-w-0 flex-col overflow-hidden rounded-[14px] card border @5xl:h-full`,children:[(0,Z.jsxs)(`header`,{className:`flex items-center gap-3 border-b border-line-soft px-4 py-3`,children:[(0,Z.jsx)(k,{agent:`forgeqe-migrate`,px:28,working:a,decorative:!0}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-semibold`,children:`Migration agent`}),(0,Z.jsx)(`span`,{className:`text-[12px] text-muted`,children:a?`Working on it…`:h.length?`${h.length} test${h.length===1?``:`s`} to fix`:`Every test passes`})]}),(0,Z.jsxs)(c,{size:`sm`,variant:`ghost`,disabled:i,onClick:s,"data-tip":`Run every migrated test again`,children:[(0,Z.jsx)(g,{"aria-hidden":`true`}),`Run tests`]})]}),(0,Z.jsxs)(`ol`,{ref:f,"aria-live":`polite`,className:`m-0 flex min-h-0 flex-1 list-none flex-col gap-3 overflow-y-auto bg-surface-muted p-4`,children:[!_.length&&!v.length&&(0,Z.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-[12px] bg-bg p-3 text-[13px] text-ink-2`,children:[(0,Z.jsx)(`span`,{children:`I fix migrated tests that fail. Pick the tests below and tell me what you know, or just send.`}),h.length>0&&(0,Z.jsx)(`button`,{type:`button`,disabled:i,onClick:()=>o(h.map(e=>e.id),``),className:`self-start rounded-[8px] border-0 bg-surface-strong px-2.5 py-1.5 text-[13px] font-medium text-ink hover:bg-line disabled:opacity-50`,children:`Fix all failing tests`})]}),_.map((e,t)=>(0,Z.jsxs)(`li`,{className:p(`flex max-w-[92%] flex-col gap-1`,e.who===`you`?`self-end items-end`:`self-start`),children:[(0,Z.jsxs)(`span`,{className:p(`rounded-[12px] px-3 py-2 text-[13px] leading-relaxed [overflow-wrap:anywhere]`,e.who===`you`?`bg-accent text-accent-ink`:e.tone===`fail`?`border border-fail-soft bg-bg text-ink`:`bg-bg text-ink`),children:[e.who===`agent`&&(0,Z.jsx)(`span`,{className:p(`mr-1 font-semibold`,e.tone===`ok`?`text-pass`:`text-fail`),children:e.tone===`ok`?`✓`:`✗`}),e.text]}),(0,Z.jsxs)(`span`,{className:`text-[11px] text-muted`,children:[e.detail?`${e.detail} · `:``,G(e.at)]})]},t)),v.map((e,t)=>(0,Z.jsxs)(`li`,{className:`flex max-w-[92%] items-start gap-2 self-start rounded-[12px] bg-bg px-3 py-2 text-[13px] text-ink-2`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:p(`flex-none`,e.kind===`ok`?`text-pass`:e.kind===`fail`?`text-fail`:`text-muted`),children:e.kind===`ok`?`✓`:e.kind===`fail`?`✗`:`•`}),(0,Z.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:e.text})]},`live-${t}`))]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2.5 border-t border-line-soft p-3`,children:[m.length>0&&(0,Z.jsx)(`div`,{role:`group`,"aria-label":`Tests to fix`,className:`flex flex-wrap gap-1.5`,children:m.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":n.has(e.id),onClick:()=>b(e.id),className:p(`inline-flex min-h-7 items-center gap-1.5 rounded-full border px-2.5 text-[12px]`,n.has(e.id)?`border-accent bg-accent-soft text-ink`:`border-line-soft bg-bg text-ink-2 hover:bg-surface-muted`),children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:p(`size-1.5 rounded-full`,e.ok?`bg-pass`:`bg-fail`)}),Q(e.target)]},e.id))}),(0,Z.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,Z.jsx)(ee,{"aria-label":`Message to the agent`,value:u,rows:2,maxLength:2e3,placeholder:n.size?`What should change? (optional)`:`Pick a test above first`,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!i&&n.size&&(e.preventDefault(),y())},className:`min-h-[44px] flex-1 resize-none`}),(0,Z.jsx)(c,{variant:`primary`,size:`icon`,"aria-label":`Send to the agent`,disabled:i||!n.size,onClick:y,children:(0,Z.jsx)(l,{"aria-hidden":`true`})})]})]})]})}var Ae=`@5xl:h-[calc(100vh-320px)] @5xl:min-h-[540px]`;function je({d:e,events:t,busy:r,working:i,onFix:a,onCheck:o,onCompare:s}){let l=e.result?.validation?.tests||[],u=e.result?.fixes||[],d=l.filter(e=>!e.ok).map(e=>e.id).join(`,`),[f,m]=(0,X.useState)(()=>l.find(e=>!e.ok)?.id||l[0]?.id||``),[h,g]=(0,X.useState)(()=>new Set(l.filter(e=>!e.ok).map(e=>e.id)));(0,X.useEffect)(()=>g(new Set(d?d.split(`,`):[])),[d]);let _=l.find(e=>e.id===f),v=_&&[...u].reverse().find(e=>e.id===_.id);return l.length?(0,Z.jsxs)(`div`,{className:p(`grid grid-cols-[minmax(0,1fr)] gap-5 @5xl:grid-cols-[minmax(0,1fr)_380px]`,Ae),children:[(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-col gap-4`,children:[(0,Z.jsx)(`div`,{className:`relative flex-none overflow-x-auto rounded-[12px] card border`,children:(0,Z.jsxs)(`table`,{className:`w-full border-collapse text-sm`,children:[(0,Z.jsx)(`thead`,{className:`bg-surface-strong text-left text-[12px] text-muted`,children:(0,Z.jsxs)(`tr`,{children:[(0,Z.jsxs)(`th`,{className:`px-4 py-2.5 font-medium`,children:[`Test `,(0,Z.jsxs)(`span`,{className:`font-normal`,children:[`· `,l.filter(e=>e.ok).length,` of `,l.length,` pass`]})]}),(0,Z.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:`Result`}),(0,Z.jsx)(`th`,{className:`hidden px-3 py-2.5 font-medium @2xl:table-cell`,children:`Kept from the source`}),(0,Z.jsx)(`th`,{className:`hidden px-3 py-2.5 text-right font-medium @3xl:table-cell`,children:`Time`})]})}),(0,Z.jsx)(`tbody`,{children:l.map(e=>{let t=[...u].reverse().find(t=>t.id===e.id);return(0,Z.jsxs)(`tr`,{onClick:()=>m(e.id),"aria-selected":f===e.id,className:p(`cursor-pointer border-t border-line-soft`,f===e.id?`bg-accent-soft`:`hover:bg-surface-muted`),children:[(0,Z.jsxs)(`td`,{className:`px-4 py-2.5`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>m(e.id),className:`cursor-pointer border-0 bg-transparent p-0 text-left font-medium text-ink`,children:Q(e.target)}),t&&(0,Z.jsx)(`span`,{className:p(`block text-[12px]`,t.ok?`text-pass`:`text-muted`),children:t.ok?`Fixed by the agent`:`The agent could not fix it`})]}),(0,Z.jsx)(`td`,{className:`px-3 py-2.5 whitespace-nowrap`,children:(0,Z.jsx)(R,{tone:e.ok?`pass`:`fail`,children:e.ok?`Passes`:`Fails`})}),(0,Z.jsxs)(`td`,{className:`hidden px-3 py-2.5 text-[13px] whitespace-nowrap text-ink-2 @2xl:table-cell`,children:[(0,Z.jsxs)(`span`,{className:e.after.tests<e.before.tests?`text-fail`:void 0,children:[e.after.tests,`/`,e.before.tests,` tests`]}),` · `,(0,Z.jsxs)(`span`,{className:e.after.assertions<e.before.assertions?`text-warn`:void 0,children:[e.after.assertions,`/`,e.before.assertions,` checks`]})]}),(0,Z.jsx)(`td`,{className:`hidden px-3 py-2.5 text-right text-[13px] text-muted tabular-nums @3xl:table-cell`,children:e.ms?ae(e.ms):`–`})]},e.id)})})]})}),_&&(0,Z.jsxs)(`section`,{"aria-label":`${Q(_.target)} details`,className:`flex min-h-[260px] flex-1 flex-col overflow-hidden rounded-[12px] card border`,children:[(0,Z.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2 border-b border-line-soft px-4 py-2.5`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:Q(_.target)}),(0,Z.jsx)(R,{tone:_.ok?`pass`:`fail`,children:_.ok?`Passes`:_.exitCode===null&&_.ms?`Timed out`:`Fails`}),_.source&&(0,Z.jsxs)(`span`,{className:`text-[12.5px] text-muted`,children:[`from `,Q(_.source)]}),(0,Z.jsx)(`span`,{className:`flex-1`}),(0,Z.jsxs)(c,{size:`sm`,variant:`ghost`,onClick:()=>s(_.id),children:[(0,Z.jsx)(n,{"aria-hidden":`true`}),`Compare`]}),!_.ok&&(0,Z.jsxs)(c,{size:`sm`,disabled:r,onClick:()=>g(new Set([_.id])),children:[(0,Z.jsx)(y,{"aria-hidden":`true`}),`Fix`]})]}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto bg-surface-muted px-4 py-3`,children:[_.problems.length>0&&(0,Z.jsx)(`p`,{className:`m-0 text-[13px] text-fail`,children:_.problems.join(` `)}),v&&(0,Z.jsxs)(`p`,{className:p(`m-0 text-[13px]`,v.ok?`text-pass`:`text-ink-2`),children:[v.ok?`Fixed by the agent`:`The agent could not fix it`,v.reason?`: ${v.reason}`:`.`]}),_.command&&(0,Z.jsxs)(`code`,{className:`block font-mono text-[12px] text-muted`,children:[`$ `,_.command]}),(0,Z.jsx)(`pre`,{className:`m-0 flex-1 font-mono text-[12.5px] leading-relaxed whitespace-pre-wrap text-ink-2`,children:_.output||(_.ok?`${_.after.tests} test${_.after.tests===1?``:`s`} passed in ${ae(_.ms)}.`:`No output.`)})]})]})]}),(0,Z.jsx)(ke,{d:e,events:t,picked:h,setPicked:g,busy:r,working:i,onFix:a,onCheck:o})]}):(0,Z.jsx)(b,{center:!0,className:`py-6`,children:e.result?`The tests are checked once every file is migrated.`:`Start the migration first.`})}var Me={ok:{mark:`✓`,cls:`text-pass`},fail:{mark:`✗`,cls:`text-fail`},info:{mark:`•`,cls:`text-muted`},agent:{mark:`•`,cls:`text-accent-fg`},tool:{mark:`·`,cls:`text-muted`}};function Ne({events:e,running:t}){let n=(0,X.useRef)(null);(0,X.useEffect)(()=>{t&&n.current&&(n.current.scrollTop=n.current.scrollHeight)},[e.length,t]);let r=e.filter(e=>e.kind!==`tool`);return(0,Z.jsxs)(`ol`,{ref:n,"aria-live":t?`polite`:void 0,"aria-label":`Activity`,className:`m-0 flex max-h-[60vh] list-none flex-col overflow-y-auto rounded-[12px] card border p-0`,children:[r.map((e,t)=>(0,Z.jsxs)(`li`,{className:`flex gap-3 border-b border-line-soft px-4 py-2 text-[13px] last:border-b-0`,children:[(0,Z.jsx)(`span`,{className:`w-[64px] flex-none text-[12px] text-muted tabular-nums`,children:new Date(e.ts).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:p(`w-3 flex-none text-center`,Me[e.kind].cls),children:Me[e.kind].mark}),(0,Z.jsx)(`span`,{className:p(`min-w-0 flex-1 [overflow-wrap:anywhere]`,e.kind===`fail`?`text-fail`:e.kind===`ok`?`text-ink`:`text-ink-2`),children:e.text})]},t)),!r.length&&(0,Z.jsx)(`li`,{className:`px-4 py-8 text-center text-sm text-muted`,children:`Nothing yet.`})]})}function Pe({id:e,plan:t}){let[n,o]=(0,X.useState)(null),[s,l]=(0,X.useState)(``),[u,d]=(0,X.useState)(`overview`),[f,p]=(0,X.useState)(),[m,h]=(0,X.useState)([]),[_,v]=(0,X.useState)(null),[y,b]=(0,X.useState)(!1),x=(0,X.useRef)(0),S=(0,X.useCallback)(()=>{i.detail(e).then(e=>{o(e),l(``)},e=>l(e.message)),i.events(e,x.current).then(e=>{e.next<x.current?(x.current=0,h([])):(x.current=e.next,e.events.length&&h(t=>[...t,...e.events].slice(-2e3)))},()=>{})},[e]);(0,X.useEffect)(S,[S]);let C=!!(n?.job?.running||n?.result?.status===`running`);(0,X.useEffect)(()=>{if(!C)return;let e=setInterval(S,1500);return()=>clearInterval(e)},[C,S]);let w=async e=>{b(!0),l(``);try{o(await e()),setTimeout(S,800)}catch(e){l(e.message)}finally{b(!1)}};if(!n)return s?(0,Z.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:s}):(0,Z.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`});let T=De(n),E=ge(n.plan,n.result),D=n.result,O=(D?.validation?.tests||[]).filter(e=>!e.ok).length,k=[{id:`overview`,label:`Overview`},{id:`tests`,label:`Tests`,n:D?.validation?`${D.validation.tests.length-O}/${D.validation.tests.length}`:void 0,tone:O?`text-fail`:void 0},{id:`compare`,label:`Compare`},{id:`activity`,label:`Activity`}];return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`a`,{href:A(`migration`),className:`inline-flex items-center gap-1.5 self-start text-sm`,children:[(0,Z.jsx)(I,{size:16,"aria-hidden":`true`}),`Migration`]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 @3xl:flex-row @3xl:items-start`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Z.jsxs)(`h2`,{className:`m-0 flex flex-wrap items-center gap-x-2.5 gap-y-1 text-[20px] leading-snug font-semibold tracking-[-0.01em]`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[n.plan.source.stack&&(0,Z.jsx)(q,{framework:n.plan.source.stack.framework,language:n.plan.source.stack.language,size:22}),n.plan.source.title]}),(0,Z.jsx)(M,{size:18,"aria-hidden":`true`,className:`text-muted`}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`to`}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,Z.jsx)(q,{framework:n.plan.target.id.split(`-`)[0],language:n.plan.target.id.split(`-`).slice(1).join(`-`),size:20}),n.plan.target.title]})]}),(0,Z.jsxs)(`p`,{className:`m-0 flex flex-wrap items-center gap-1.5 text-sm text-muted`,children:[(0,Z.jsx)(ye,{kind:n.origin.kind,label:n.origin.label,size:15}),(0,Z.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:J(n.origin.label)}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,Z.jsxs)(`span`,{children:[`into `,(0,Z.jsx)(`span`,{className:`font-mono text-[12.5px]`,children:n.plan.target.dir})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(R,{tone:T.tone,children:T.label}),C?(0,Z.jsxs)(c,{variant:`danger`,disabled:y,onClick:()=>void w(()=>i.stop(e)),children:[(0,Z.jsx)(a,{fill:`currentColor`,"aria-hidden":`true`}),`Stop`]}):D?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(c,{variant:`ghost`,onClick:()=>i.report(e).then(e=>v(e.text),()=>v(``)),children:`Report`}),(0,Z.jsxs)(c,{disabled:y,onClick:()=>void w(()=>i.verify(e)),children:[(0,Z.jsx)(g,{"aria-hidden":`true`}),`Check again`]})]}):null]})]}),D&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 rounded-[12px] card border px-3 py-2.5 @xl:gap-4 @xl:px-4`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(K,{ids:Ee,states:D.stages})}),C&&(0,Z.jsxs)(`span`,{className:`flex-none text-[13px] font-semibold tabular-nums text-accent-fg`,"aria-label":`${Math.round(E)}% done`,children:[Math.round(E),`%`]})]}),s&&(0,Z.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:s}),(0,Z.jsx)(me,{tabs:k,tab:u,onTab:d,label:`Migration`}),(0,Z.jsxs)(`div`,{role:`tabpanel`,id:`mpanel-${u}`,"aria-labelledby":`mtab-${u}`,className:`flex min-w-0 flex-col gap-4`,children:[u===`overview`&&(0,Z.jsx)(Oe,{d:n,planView:t(n)}),u===`tests`&&(0,Z.jsx)(je,{d:n,events:m,busy:y||C,working:C,onFix:(t,n)=>void w(()=>i.fix(e,t,n)),onCheck:()=>void w(()=>i.verify(e)),onCompare:e=>(p(e),d(`compare`))}),u===`compare`&&(0,Z.jsx)(Te,{id:e,plan:n.plan,result:D,initial:f}),u===`activity`&&(0,Z.jsx)(Ne,{events:m,running:C})]}),(0,Z.jsx)(r,{open:_!==null,onClose:()=>v(null),wide:!0,title:`Report`,description:`migrate.md for ${n.plan.id}`,footer:(0,Z.jsx)(c,{onClick:()=>v(null),children:`Close`}),children:_?(0,Z.jsx)(H,{text:_}):(0,Z.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`No report yet.`})})]})}var Fe=[{id:`git`,label:`Git`},{id:`folder`,label:`Folder`},{id:`upload`,label:`Upload`},{id:`paste`,label:`Paste`},{id:`project`,label:`This project`}],Ie=[`Source`,`Target`,`Instructions`,`Review`],Le=[`Keep one page object per page, in pages/.`,`Read the base URL from BASE_URL.`,`Keep test names as they are.`],Re=[`Where the tests are`,`Framework and language`,`Your rules, optional`,`Check and start`];function ze({at:e,reached:t,onGo:n}){return(0,Z.jsx)(`nav`,{"aria-label":`Steps`,children:(0,Z.jsx)(`ol`,{className:`m-0 flex list-none items-center gap-2 p-0`,children:Ie.map((r,i)=>{let a=i<=t,o=i===e,s=i<t&&!o;return(0,Z.jsxs)(`li`,{className:p(`flex items-center gap-2`,i<Ie.length-1&&`flex-1`),children:[(0,Z.jsxs)(`button`,{type:`button`,disabled:!a,"aria-current":o?`step`:void 0,onClick:()=>n(i),"aria-label":r,"data-tip":Re[i],className:p(`inline-flex min-h-8 flex-none items-center gap-2 rounded-[8px] border-0 bg-transparent px-1 text-[13px] whitespace-nowrap`,a&&!o?`cursor-pointer hover:bg-surface-strong`:``),children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:p(`inline-flex size-6 flex-none items-center justify-center rounded-full text-[11px] font-semibold tabular-nums`,s?`bg-pass text-white`:o?`bg-accent text-accent-ink`:`border border-line bg-bg text-muted`),children:s?(0,Z.jsx)(B,{size:13,strokeWidth:3}):i+1}),(0,Z.jsx)(`span`,{className:p(o?`font-medium text-ink`:a?`text-ink-2`:`text-muted`,!o&&`hidden @xl:inline`),children:r})]}),i<Ie.length-1&&(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`h-0.5 min-w-4 flex-1 overflow-hidden rounded-full bg-line @xl:min-w-8`,children:(0,Z.jsx)(`span`,{className:p(`block h-full rounded-full bg-pass transition-[width] duration-500`,i<t?`w-full`:`w-0`)})})]},r)})})})}function $({id:e,label:t,help:n,children:r}){return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:e,className:`text-sm font-medium`,children:t}),r,n&&(0,Z.jsx)(`span`,{className:`text-[13px] text-muted`,children:n})]})}function Be({busy:e,onBack:t,next:n,onNext:r,disabled:i,aside:a}){return(0,Z.jsxs)(`div`,{className:`sticky bottom-0 flex flex-wrap items-center gap-3 border-t border-line-soft bg-bg py-3`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:a}),t&&(0,Z.jsx)(c,{variant:`ghost`,disabled:e,onClick:t,children:`Back`}),(0,Z.jsx)(c,{variant:`primary`,disabled:e||i,onClick:r,children:n})]})}function Ve({d:e}){let t=e.counts,n=[`${t.tests} test file${t.tests===1?``:`s`}`,`${t.support} support file${t.support===1?``:`s`}`,...t.features?[`${t.features} feature file${t.features===1?``:`s`}`]:[],...t.data?[`${t.data} data file${t.data===1?``:`s`}`]:[]];return(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-[12px] bg-surface-muted px-4 py-3 text-sm`,children:[e.stack?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-2 font-medium`,children:[(0,Z.jsx)(q,{framework:e.stack.framework,language:e.stack.language}),e.title]}):(0,Z.jsx)(R,{tone:`warn`,children:`Framework not detected`}),(0,Z.jsx)(`span`,{className:`text-ink-2`,children:n.join(` · `)}),t.skipped>0&&(0,Z.jsxs)(`span`,{className:`text-muted`,children:[`· `,t.skipped,` left out (links, large files)`]})]})}async function He(e,t,n){let r=[],a=0,o=null,s=0,c=async()=>{r.length&&(o=await i.files(e,r),s+=r.length,n(s),r=[],a=0)};for(let e of t){let t=e.webkitRelativePath||``,n=t&&t.split(`/`).slice(1).join(`/`)||e.name,i=new Uint8Array(await e.arrayBuffer()),o=``;for(let e=0;e<i.length;e+=32768)o+=String.fromCharCode(...i.subarray(e,e+32768));let s=btoa(o);a+s.length>8388608&&await c(),r.push({path:n,data:s}),a+=s.length}return await c(),o}var Ue=e=>(e.webkitRelativePath||e.name).split(`/`).some(e=>e.startsWith(`.`)||e===`node_modules`);function We({view:e,kind:t,setKind:n,src:r,setSrc:a,from:o,setFrom:s,stack:l,setStack:u,found:d,setFound:f}){let[m,h]=(0,X.useState)(``),[g,v]=(0,X.useState)(``),[y,b]=(0,X.useState)(null),[x,S]=(0,X.useState)(``),[C,E]=(0,X.useState)(e.credentials),[O,k]=(0,X.useState)(null),[A,j]=(0,X.useState)(``),[M,N]=(0,X.useState)([{path:``,text:``}]),[I,L]=(0,X.useState)(``),[z,B]=(0,X.useState)(``),[te,H]=(0,X.useState)(``),U=(0,X.useRef)(null),ne=(0,X.useRef)(null);(0,X.useEffect)(()=>{U.current?.setAttribute(`webkitdirectory`,``)},[t,r]);let W=r?.workspace,G=async(e,t)=>{L(e),B(``),H(``);try{await t()}catch(e){B(e.message)}finally{L(``)}},K=e=>{a(e),s(`.`),f(e.discovery)};(0,X.useEffect)(()=>{if(t!==`project`)return;let e=setTimeout(()=>i.discover(void 0,o||`.`).then(f,()=>f(null)),300);return()=>clearTimeout(e)},[t,o,f]);let q=e=>{let t=e.filter(e=>!Ue(e));if(!t.length)return B(`Nothing to send: every file is hidden or a dependency.`);G(`upload`,async()=>{let n=e[0],r=await i.source({kind:`upload`,label:n?.webkitRelativePath?n.webkitRelativePath.split(`/`)[0]:`${t.length} files`});await He(r.workspace.id,t,e=>H(`Sending ${e} of ${t.length} files…`)),K(await i.finish(r.workspace.id))})},ie=t===`project`||!!W?.ready;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Z.jsx)(`div`,{role:`radiogroup`,"aria-label":`Where the tests come from`,className:`flex w-fit max-w-full gap-1 overflow-x-auto rounded-[10px] bg-surface-strong p-1`,children:Fe.map(e=>(0,Z.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t===e.id,onClick:()=>{e.id!==t&&(n(e.id),a(null),f(null),B(``),s(e.id===`project`?``:`.`))},className:p(`inline-flex min-h-9 flex-none cursor-pointer items-center gap-2 rounded-[7px] border-0 px-3 text-sm font-medium`,t===e.id?`bg-bg text-ink shadow-sm`:`bg-transparent text-muted hover:text-ink`),children:[(0,Z.jsx)(re,{logo:_e[e.id].Logo,icon:_e[e.id].Icon,size:16}),e.label]},e.id))}),z&&(0,Z.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:z}),W?.ready?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-[12px] card border px-4 py-3`,children:[(0,Z.jsx)(ye,{kind:W.kind,label:W.label,size:22}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 text-sm`,children:[(0,Z.jsx)(`span`,{className:`font-medium [overflow-wrap:anywhere]`,children:J(W.label)}),W.branch&&(0,Z.jsxs)(`span`,{className:`text-muted`,children:[` · `,W.branch]}),(0,Z.jsxs)(`span`,{className:`text-muted`,children:[` · `,W.files,` files`]})]}),(0,Z.jsx)(R,{tone:`pass`,children:`Ready`}),(0,Z.jsx)(c,{variant:`ghost`,size:`sm`,onClick:()=>(a(null),f(null)),children:`Change`})]}):t===`git`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsx)($,{id:`mig-url`,label:`Repository URL`,help:(0,Z.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-3 gap-y-1`,children:[`Works with `,se.map(e=>(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Z.jsx)(re,{logo:e.Logo,size:14}),e.name]},e.name)),` and any git server over https or ssh.`]}),children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsxs)(`span`,{className:`relative min-w-0 flex-[1_1_300px]`,children:[(0,Z.jsx)(`span`,{className:`pointer-events-none absolute top-1/2 left-3 -translate-y-1/2`,children:(0,Z.jsx)(re,{logo:ve(m).Logo,size:18})}),(0,Z.jsx)(_,{id:`mig-url`,value:m,spellCheck:!1,maxLength:500,placeholder:`https://github.com/org/ui-tests.git`,onChange:e=>(h(e.target.value),b(null)),className:`w-full pl-10`})]}),(0,Z.jsx)(c,{disabled:!!I||!m.trim(),onClick:()=>void G(`test`,async()=>{let e=await i.testRepository(m.trim(),x||void 0);b(e.branches),!g&&e.head&&v(e.head),H(`Connected · ${e.branches.length} branch${e.branches.length===1?``:`es`}`)}),children:I===`test`?`Testing…`:`Test connection`})]})}),(0,Z.jsxs)(`div`,{className:`grid gap-4 @xl:grid-cols-2`,children:[(0,Z.jsx)($,{id:`mig-branch`,label:`Branch`,children:y?.length?(0,Z.jsx)(P,{id:`mig-branch`,value:g,onChange:e=>v(e.target.value),children:y.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))}):(0,Z.jsx)(_,{id:`mig-branch`,value:g,spellCheck:!1,maxLength:200,placeholder:`Default branch`,onChange:e=>v(e.target.value)})}),(0,Z.jsx)($,{id:`mig-token`,label:`Access token`,help:O?void 0:(0,Z.jsx)(`button`,{type:`button`,onClick:()=>k({name:`GIT_TOKEN`,value:``}),className:`cursor-pointer border-0 bg-transparent p-0 text-[13px] text-accent-fg underline`,children:`Add a token`}),children:(0,Z.jsxs)(P,{id:`mig-token`,value:x,onChange:e=>S(e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`None (public, or ssh)`}),C.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))]})})]}),O&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2 rounded-[12px] bg-surface-muted p-3`,children:[(0,Z.jsx)($,{id:`mig-token-name`,label:`Name`,children:(0,Z.jsx)(_,{id:`mig-token-name`,value:O.name,spellCheck:!1,maxLength:64,onChange:e=>k({...O,name:e.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,`_`)}),className:`w-[180px]`})}),(0,Z.jsx)($,{id:`mig-token-value`,label:`Token`,children:(0,Z.jsx)(_,{id:`mig-token-value`,type:`password`,autoComplete:`off`,value:O.value,onChange:e=>k({...O,value:e.target.value}),className:`w-[260px] max-w-full`})}),(0,Z.jsx)(c,{disabled:!!I||!O.name||!O.value,onClick:()=>void G(`token`,async()=>{await w.saveSecrets({[O.name]:O.value}),E([...new Set([...C,O.name])].sort()),S(O.name),k(null)}),children:`Save`}),(0,Z.jsx)(c,{variant:`ghost`,onClick:()=>k(null),children:`Cancel`}),(0,Z.jsx)(`span`,{className:`w-full text-[12.5px] text-muted`,children:`Kept in ForgeQE's credential store, never in the URL or on this page.`})]}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(c,{variant:`primary`,disabled:!!I||!m.trim(),onClick:()=>void G(`clone`,async()=>K(await i.source({kind:`git`,url:m.trim(),...g?{branch:g}:{},...x?{tokenVar:x}:{}}))),children:I===`clone`?`Cloning…`:`Clone`})})]}):t===`folder`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsx)($,{id:`mig-folder`,label:`Folder path`,help:`Copied first; the folder itself is never changed.`,children:(0,Z.jsx)(_,{id:`mig-folder`,value:A,spellCheck:!1,maxLength:1e3,placeholder:`/home/me/projects/shop-ui-tests`,onChange:e=>j(e.target.value)})}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(c,{variant:`primary`,disabled:!!I||!A.trim(),onClick:()=>void G(`copy`,async()=>K(await i.source({kind:`folder`,folder:A.trim()}))),children:I===`copy`?`Copying…`:`Use this folder`})})]}):t===`upload`?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-3 rounded-[14px] border border-dashed border-line px-6 py-10 text-center`,children:[(0,Z.jsx)(`p`,{className:`m-0 text-sm text-ink-2`,children:`Choose a folder of tests, or some files.`}),(0,Z.jsx)(`input`,{ref:U,type:`file`,multiple:!0,hidden:!0,onChange:e=>e.target.files&&q([...e.target.files])}),(0,Z.jsx)(`input`,{ref:ne,type:`file`,multiple:!0,hidden:!0,onChange:e=>e.target.files&&q([...e.target.files])}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:[(0,Z.jsxs)(c,{variant:`primary`,disabled:!!I,onClick:()=>U.current?.click(),children:[(0,Z.jsx)(V,{"aria-hidden":`true`}),`Choose a folder`]}),(0,Z.jsxs)(c,{disabled:!!I,onClick:()=>ne.current?.click(),children:[(0,Z.jsx)(D,{"aria-hidden":`true`}),`Choose files`]})]})]}):t===`paste`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[M.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(_,{"aria-label":`File ${t+1} name`,value:e.path,spellCheck:!1,maxLength:300,placeholder:t?`pages/LoginPage.java`:`tests/LoginTest.java`,onChange:e=>N(M.map((n,r)=>r===t?{...n,path:e.target.value}:n)),className:`max-w-[360px]`}),M.length>1&&(0,Z.jsx)(c,{variant:`icon`,size:`icon`,"aria-label":`Remove file ${t+1}`,onClick:()=>N(M.filter((e,n)=>n!==t)),children:(0,Z.jsx)(F,{"aria-hidden":`true`})})]}),(0,Z.jsx)(ee,{"aria-label":`File ${t+1} code`,value:e.text,rows:7,spellCheck:!1,placeholder:`Paste the code`,onChange:e=>N(M.map((n,r)=>r===t?{...n,text:e.target.value}:n)),className:`font-mono`})]},t)),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsxs)(c,{variant:`ghost`,onClick:()=>N([...M,{path:``,text:``}]),children:[(0,Z.jsx)(T,{"aria-hidden":`true`}),`Add a file`]}),(0,Z.jsx)(`span`,{className:`flex-1`}),(0,Z.jsx)(c,{variant:`primary`,disabled:!!I||M.some(e=>!e.path.trim()||!e.text.trim()),onClick:()=>void G(`paste`,async()=>{let e=await i.source({kind:`paste`});await i.files(e.workspace.id,M.map(e=>({path:e.path.trim(),text:e.text}))),K(await i.finish(e.workspace.id))}),children:I===`paste`?`Adding…`:`Use this code`})]})]}):null,te&&!z&&(0,Z.jsx)(`p`,{role:`status`,className:`m-0 text-[13px] text-muted`,children:te}),ie&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`grid gap-4 @xl:grid-cols-2`,children:[(0,Z.jsx)($,{id:`mig-from`,label:`Tests folder`,children:t===`project`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(_,{id:`mig-from`,list:`mig-folders`,value:o,spellCheck:!1,maxLength:300,placeholder:`Whole project`,onChange:e=>s(e.target.value)}),(0,Z.jsx)(`datalist`,{id:`mig-folders`,children:e.folders.map(e=>(0,Z.jsx)(`option`,{value:e},e))})]}):(0,Z.jsxs)(P,{id:`mig-from`,value:o||`.`,onChange:e=>(s(e.target.value),W&&i.discover(W.id,e.target.value).then(f,()=>{})),children:[(0,Z.jsx)(`option`,{value:`.`,children:`All of it`}),(r?.folders||[]).map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))]})}),(0,Z.jsx)($,{id:`mig-stack`,label:`Framework`,children:(0,Z.jsxs)(P,{id:`mig-stack`,value:l,onChange:e=>u(e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:d?.stack?`${d.title} (detected)`:`Detect`}),e.sources.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.title},e.id))]})})]}),d&&(0,Z.jsx)(Ve,{d})]})]})}function Ge({on:e,onPick:t,logo:n,title:r,sub:i,label:a}){return(0,Z.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":e,"aria-label":a,onClick:t,className:p(`flex min-h-[72px] min-w-0 cursor-pointer items-center gap-3 rounded-[12px] border px-3.5 py-3 text-left transition-colors`,e?`border-accent bg-accent-soft ring-1 ring-accent`:`border-line-soft bg-bg hover:border-line hover:bg-surface-muted`),children:[(0,Z.jsx)(`span`,{className:`inline-flex size-9 flex-none items-center justify-center rounded-[10px] bg-surface-muted`,children:n}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium text-ink`,children:r}),i&&(0,Z.jsx)(`span`,{className:`truncate text-[12px] text-muted`,children:i})]})]})}var Ke={playwright:`Microsoft`,cypress:`JavaScript only`,webdriverio:`WebDriver and BiDi`,selenium:`WebDriver`};function qe({view:e,to:t,setTo:n,other:r,setOther:i,into:a,setInto:o,only:s,setOnly:c}){let l=e=>e.split(`-`)[0],u=e=>e.split(`-`).slice(1).join(`-`),d=[...new Map(e.targets.map(e=>[l(e.id),e.framework])).entries()],f=r===null?l(t):``,p=e.targets.filter(e=>l(e.id)===f);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Z.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2.5 border-0 p-0`,children:[(0,Z.jsx)(`legend`,{className:`mb-2.5 text-sm font-medium`,children:`Framework`}),(0,Z.jsxs)(`div`,{role:`radiogroup`,"aria-label":`Framework`,className:`grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-2.5`,children:[d.map(([r,a])=>{let o=ue[r];return(0,Z.jsx)(Ge,{on:f===r,onPick:()=>(i(null),n((e.targets.find(e=>l(e.id)===r&&u(e.id)===u(t))||e.targets.find(e=>l(e.id)===r)).id)),logo:o?(0,Z.jsx)(o,{width:22,height:22,"aria-hidden":`true`}):null,title:a,sub:Ke[r],label:a},r)}),(0,Z.jsx)(Ge,{on:r!==null,onPick:()=>i(r??``),logo:(0,Z.jsx)(T,{size:18,"aria-hidden":`true`,className:`text-ink-2`}),title:`Other`,sub:`Type the framework`,label:`Other framework`})]})]}),r===null?(0,Z.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2.5 border-0 p-0`,children:[(0,Z.jsx)(`legend`,{className:`mb-2.5 text-sm font-medium`,children:`Language`}),(0,Z.jsx)(`div`,{role:`radiogroup`,"aria-label":`Language`,className:`grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-2.5`,children:p.map(e=>{let r=oe[u(e.id)];return(0,Z.jsx)(Ge,{on:t===e.id,onPick:()=>n(e.id),logo:r?(0,Z.jsx)(r,{width:22,height:22,"aria-hidden":`true`}):null,title:e.language,sub:e.title.includes(`(`)&&e.title.slice(e.title.indexOf(`(`)+1,-1).replace(e.language,``).replace(/^,\s*/,``)||void 0,label:e.language},e.id)})})]}):(0,Z.jsx)($,{id:`mig-other`,label:`Which framework and language?`,help:`ForgeQE checks it against what it can run, and says so before anything starts.`,children:(0,Z.jsx)(_,{id:`mig-other`,value:r,maxLength:120,autoFocus:!0,placeholder:`Playwright with Java, WebdriverIO TypeScript…`,onChange:e=>i(e.target.value)})}),(0,Z.jsxs)(`div`,{className:`grid gap-4 @2xl:grid-cols-2`,children:[(0,Z.jsx)($,{id:`mig-into`,label:`Output folder`,help:`A new folder. Empty: named after the source and the target.`,children:(0,Z.jsx)(_,{id:`mig-into`,value:a,spellCheck:!1,maxLength:300,placeholder:`tests-playwright`,onChange:e=>o(e.target.value)})}),(0,Z.jsx)($,{id:`mig-only`,label:`Only some tests (optional)`,help:`A pattern, such as checkout/** or **/*Login*.`,children:(0,Z.jsx)(_,{id:`mig-only`,value:s,spellCheck:!1,maxLength:200,placeholder:`All tests`,onChange:e=>c(e.target.value)})})]})]})}function Je({view:e,kind:t,src:n,found:r,to:i,other:a,instructions:o}){let s=e.targets.find(e=>e.id===i),c=(e,t)=>(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 border-b border-line-soft py-3.5 first:pt-0 last:border-b-0 last:pb-0`,children:[(0,Z.jsx)(`span`,{className:`text-[12px] font-medium text-muted`,children:e}),(0,Z.jsx)(`div`,{className:`text-sm`,children:t})]});return(0,Z.jsxs)(`aside`,{"aria-label":`Summary`,className:`flex flex-col rounded-[14px] card border p-5`,children:[c(`Source`,n?.workspace?.ready||t===`project`&&r?(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(ye,{kind:n?.workspace?.kind||`project`,label:n?.workspace?.label,size:18}),(0,Z.jsx)(`span`,{className:`truncate font-medium`,children:n?.workspace?J(n.workspace.label):`This project`})]}):(0,Z.jsx)(`span`,{className:`text-muted`,children:`Not picked yet`})),c(`Tests found`,r?.stack?(0,Z.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,Z.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[(0,Z.jsx)(q,{framework:r.stack.framework,language:r.stack.language}),r.title]}),(0,Z.jsxs)(`span`,{className:`text-[13px] text-ink-2`,children:[r.counts.tests,` test files · `,r.counts.support,` support files`]})]}):(0,Z.jsx)(`span`,{className:`text-muted`,children:`–`})),c(`Target`,a===null?s?(0,Z.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[(0,Z.jsx)(q,{framework:s.id.split(`-`)[0],language:s.id.split(`-`).slice(1).join(`-`)}),s.title]}):(0,Z.jsx)(`span`,{className:`text-muted`,children:`–`}):(0,Z.jsx)(`span`,{className:a.trim()?`font-medium`:`text-muted`,children:a.trim()||`Type it in`})),c(`Instructions`,o.trim()?(0,Z.jsx)(`span`,{className:`line-clamp-3 text-ink-2`,children:o.trim()}):(0,Z.jsx)(`span`,{className:`text-muted`,children:`None`}))]})}function Ye({view:e,review:t,onStart:n}){let[r,a]=(0,X.useState)(0),[o,c]=(0,X.useState)(0),[l,u]=(0,X.useState)(`git`),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(`.`),[h,g]=(0,X.useState)(``),[_,v]=(0,X.useState)(null),[y,b]=(0,X.useState)(e.targets[0]?.id||``),[x,C]=(0,X.useState)(null),[w,E]=(0,X.useState)(``),[D,O]=(0,X.useState)(``),[k,A]=(0,X.useState)(``),[j,M]=(0,X.useState)(null),[N,P]=(0,X.useState)(!1),[F,I]=(0,X.useState)(!1),[L,R]=(0,X.useState)(``);(0,X.useEffect)(()=>{M(null),P(!1),c(e=>Math.min(e,2))},[l,d,p,h,D,y,x,w,k]);let z=e=>{a(e),c(t=>Math.max(t,e)),R(``)},B=l===`project`||!!d?.workspace?.ready,te=async()=>{I(!0),R(``);try{let e=await i.plan({...l!==`project`&&d?.workspace?{workspace:d.workspace.id}:{},...p.trim()&&p!==`.`?{from:p.trim()}:{},...h?{stack:h}:{},...x===null?{to:y}:{to:``,toText:x.trim()},...w.trim()?{into:w.trim()}:{},...D.trim()?{only:D.trim()}:{},...k.trim()?{instructions:k.trim()}:{}});M(e),z(3)}catch(e){R(e.message)}finally{I(!1)}},V=j?.plan,H=V?.feasibility.findings.some(e=>e.level===`limit`),U=V?.feasibility.verdict===`blocked`;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Z.jsx)(ze,{at:r,reached:o,onGo:e=>!F&&(e<3||j)&&a(e)}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] items-start gap-6 @5xl:grid-cols-[minmax(0,1fr)_280px]`,children:[(0,Z.jsxs)(`section`,{"aria-labelledby":`mig-step`,className:`flex min-w-0 flex-col gap-5`,children:[(0,Z.jsx)(`h2`,{id:`mig-step`,className:`m-0 text-[22px] font-semibold tracking-[-0.01em]`,children:[`Where are the tests?`,`What should they become?`,`Anything the agent should know?`,`Review and start`][r]}),L&&(0,Z.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:L}),r===0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(We,{view:e,kind:l,setKind:u,src:d,setSrc:f,from:p,setFrom:m,stack:h,setStack:g,found:_,setFound:v}),(0,Z.jsx)(Be,{busy:F,next:`Continue`,onNext:()=>z(1),disabled:!B})]}),r===1&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(qe,{view:e,to:y,setTo:b,other:x,setOther:C,into:w,setInto:E,only:D,setOnly:O}),(0,Z.jsx)(Be,{busy:F,onBack:()=>a(0),next:`Continue`,onNext:()=>z(2),disabled:x===null?!y:!x.trim()})]}),r===2&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{id:`mig-instructions`,label:`Instructions (optional)`,help:`Style and structure for the new code. Every test and check is kept either way.`,children:(0,Z.jsx)(ee,{id:`mig-instructions`,value:k,rows:6,maxLength:4e3,placeholder:`Page objects go in pages/, one class per page.`,onChange:e=>A(e.target.value)})}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Le.map(e=>(0,Z.jsxs)(`button`,{type:`button`,disabled:k.includes(e),onClick:()=>A(k.trim()?`${k.trim()}\n${e}`:e),className:`inline-flex min-h-8 cursor-pointer items-center gap-1.5 rounded-[8px] border-0 bg-surface-strong px-2.5 text-[13px] text-ink hover:bg-line disabled:cursor-default disabled:opacity-50`,children:[(0,Z.jsx)(T,{size:13,"aria-hidden":`true`}),e]},e))}),(0,Z.jsx)(Be,{busy:F,onBack:()=>a(1),next:F?`Checking…`:`Check the plan`,onNext:()=>void te(),aside:(0,Z.jsx)(`span`,{className:`text-muted`,children:`Nothing is changed yet.`})})]}),r===3&&V&&(0,Z.jsxs)(Z.Fragment,{children:[t(V,N,P),(0,Z.jsx)(Be,{busy:F,onBack:()=>a(2),next:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(s,{icon:S,size:15}),`Start migration`]}),disabled:U||H&&!N,onNext:()=>n(j,!!H&&N),aside:(0,Z.jsx)(`span`,{className:`text-muted`,children:U?`Change what is not possible first.`:H&&!N?`Accept the limits to start.`:`Runs in the background.`})})]})]}),(0,Z.jsx)(`div`,{className:`@5xl:sticky @5xl:top-6`,children:(0,Z.jsx)(Je,{view:e,kind:l,src:d,found:_,to:y,other:x,instructions:k})})]})]})}function Xe({children:e,wide:t}){return(0,Z.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,Z.jsx)(j,{}),(0,Z.jsx)(`main`,{className:p(W,`@container flex-auto gap-5`,t?`max-w-[1480px]`:`max-w-[1180px]`),children:e})]})}function Ze({action:e}){return(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Z.jsx)(te,{pixel:C.migration,size:`lg`}),(0,Z.jsx)(`h1`,{className:`m-0 text-[26px] font-semibold tracking-[-0.01em]`,children:`Migration`}),(0,Z.jsx)(`span`,{className:`flex-1`}),e]})}function Qe({error:e}){return e?(0,Z.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:e}):null}function $e({title:e,children:t}){let[n,r]=(0,X.useState)(!1),i=(0,X.useId)();return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":n,"aria-controls":i,onClick:()=>r(!n),className:`inline-flex min-h-8 cursor-pointer items-center gap-1.5 self-start rounded-[8px] border-0 bg-transparent px-1 text-sm font-medium text-ink hover:bg-surface-strong`,children:[(0,Z.jsx)(v,{size:15,"aria-hidden":`true`,className:p(`transition-transform`,n&&`rotate-180`)}),e]}),(0,Z.jsx)(d,{open:n,id:i,children:t})]})}function et({finding:e}){let t=e.hits||[],n=e.files?.length||0;if(!t.length)return n?(0,Z.jsxs)(`span`,{className:`text-muted`,children:[` (`,n,` file`,n===1?``:`s`,`)`]}):null;let r=n-new Set(t.map(e=>e.file)).size;return(0,Z.jsxs)(`details`,{className:`mt-1 text-[13px]`,children:[(0,Z.jsxs)(`summary`,{className:`cursor-pointer text-muted hover:text-ink`,children:[`Found in `,n||t.length,` file`,(n||t.length)===1?``:`s`]}),(0,Z.jsxs)(`ul`,{className:`m-0 mt-1.5 flex list-none flex-col gap-1.5 p-0`,children:[t.map(e=>(0,Z.jsxs)(`li`,{className:`min-w-0`,children:[(0,Z.jsxs)(`span`,{className:`font-mono text-[12px] text-ink-2 [overflow-wrap:anywhere]`,children:[e.file,`:`,e.line]}),(0,Z.jsx)(`code`,{className:`mt-0.5 block overflow-x-auto rounded-[8px] bg-bg px-2 py-1 font-mono text-[12px] whitespace-pre text-ink`,children:e.code})]},`${e.file}:${e.line}`)),r>0&&(0,Z.jsxs)(`li`,{className:`text-muted`,children:[`and `,r,` more file`,r===1?``:`s`]})]})]})}function tt({plan:e,accepted:t,onAccept:n}){let r=e.feasibility.findings.filter(e=>e.level===`blocker`),i=e.feasibility.findings.filter(e=>e.level===`limit`),a=e.units.filter(e=>e.kind===`test`).length,o=e.units.filter(e=>e.kind===`support`).length;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Z.jsxs)(`dl`,{className:`m-0 grid gap-x-6 gap-y-2.5 rounded-[14px] card border px-5 py-4 text-sm @xl:grid-cols-[auto_1fr]`,children:[(0,Z.jsx)(`dt`,{className:`text-muted`,children:`From`}),(0,Z.jsxs)(`dd`,{className:`m-0 [overflow-wrap:anywhere]`,children:[e.source.title,(0,Z.jsxs)(`span`,{className:`text-muted`,children:[` `,`· `,e.workspace?J(e.workspace.label):`this project`,e.source.dir===`.`?``:`/${e.source.dir}`]})]}),(0,Z.jsx)(`dt`,{className:`text-muted`,children:`To`}),(0,Z.jsxs)(`dd`,{className:`m-0`,children:[e.target.title,(0,Z.jsxs)(`span`,{className:`text-muted`,children:[` · `,e.target.dir]})]}),(0,Z.jsx)(`dt`,{className:`text-muted`,children:`Files`}),(0,Z.jsxs)(`dd`,{className:`m-0`,children:[a,` test`,a===1?``:`s`,`, `,o,` support file`,o===1?``:`s`,e.copies.length?`, ${e.copies.length} data file${e.copies.length===1?``:`s`}`:``]}),e.instructions&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`dt`,{className:`text-muted`,children:`Instructions`}),(0,Z.jsx)(`dd`,{className:`m-0 whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.instructions})]})]}),r.length>0&&(0,Z.jsxs)(`section`,{"aria-labelledby":`mig-blockers`,className:`flex flex-col gap-2 rounded-[14px] bg-fail-soft px-5 py-4`,children:[(0,Z.jsxs)(`h3`,{id:`mig-blockers`,className:`m-0 flex items-center gap-2 text-sm font-semibold text-fail`,children:[(0,Z.jsx)(f,{size:16,"aria-hidden":`true`}),`Not possible`]}),(0,Z.jsx)(`ul`,{className:`m-0 flex list-disc flex-col gap-1 pl-5 text-sm text-ink`,children:r.map(e=>(0,Z.jsx)(`li`,{children:e.text},e.code))})]}),i.length>0&&(0,Z.jsxs)(`section`,{"aria-labelledby":`mig-limits`,className:`flex flex-col gap-3 rounded-[14px] bg-warn-soft px-5 py-4`,children:[(0,Z.jsxs)(`h3`,{id:`mig-limits`,className:`m-0 flex items-center gap-2 text-sm font-semibold text-warn`,children:[(0,Z.jsx)(f,{size:16,"aria-hidden":`true`}),`Before you start`]}),(0,Z.jsx)(`ul`,{className:`m-0 flex list-disc flex-col gap-1.5 pl-5 text-sm text-ink`,children:i.map(e=>(0,Z.jsxs)(`li`,{children:[e.text,(0,Z.jsx)(et,{finding:e})]},e.code))}),n&&!r.length&&(0,Z.jsxs)(`label`,{className:`flex min-h-9 cursor-pointer items-center gap-2 text-sm font-medium`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:!!t,onChange:e=>n(e.target.checked)}),`I understand`]})]}),(0,Z.jsxs)($e,{title:`Files, in order (${e.units.length})`,children:[(0,Z.jsx)(`ol`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-0 text-[13px]`,children:e.units.map(e=>(0,Z.jsxs)(`li`,{className:`flex flex-wrap gap-x-3 border-b border-line-soft px-4 py-2 last:border-b-0`,children:[(0,Z.jsx)(`span`,{className:`w-16 flex-none text-muted`,children:de[e.kind]}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 [overflow-wrap:anywhere]`,children:[e.source?(0,Z.jsxs)(`span`,{className:`text-muted`,children:[e.source.slice(e.source.lastIndexOf(`/`)+1),` → `]}):null,e.target]})]},e.id))}),e.notMigrated.length>0&&(0,Z.jsxs)(`p`,{className:`m-0 mt-2 text-[12.5px] text-muted`,children:[`Not migrated: `,e.notMigrated.map(e=>e.rel.slice(e.rel.lastIndexOf(`/`)+1)).join(`, `)]})]})]})}function nt({plan:e,acceptLimits:t,onClose:n,onStarted:a}){let[o,s]=(0,X.useState)(``),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(``),p=async()=>{u(!0),f(``);try{a((await i.start(e.id,o,t)).detail)}catch(e){f(e.message),u(!1)}};return(0,Z.jsx)(r,{open:!0,onClose:n,title:`Start the migration`,description:`The tests are rewritten in ${e.target.title} into ${e.target.dir}, and ForgeQE runs each one. It runs in the background; your source tests are not changed.`,footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(c,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,Z.jsx)(c,{variant:`primary`,disabled:l||o!==e.id,onClick:()=>void p(),children:`Start migration`})]}),children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,Z.jsxs)(`span`,{children:[`Type `,(0,Z.jsx)(`span`,{className:`font-mono`,children:e.id}),` to confirm`]}),(0,Z.jsx)(_,{value:o,onChange:e=>s(e.target.value),autoComplete:`off`,spellCheck:!1})]}),(0,Z.jsx)(Qe,{error:d})]})})}function rt({d:e,onStarted:t}){let[n,r]=(0,X.useState)(!1),[i,a]=(0,X.useState)(!1),o=e.plan.feasibility.findings.some(e=>e.level===`limit`),s=e.plan.feasibility.verdict===`blocked`,l=!!e.job?.running;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[e.job?.last&&!l&&(0,Z.jsx)(`p`,{className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail`,children:`The last start did not run. Its job's log on the Jobs page says why.`}),(0,Z.jsx)(tt,{plan:e.plan,accepted:e.confirmed||n,onAccept:e.confirmed?void 0:r}),!s&&!l&&(0,Z.jsx)(`div`,{children:(0,Z.jsxs)(c,{variant:`primary`,disabled:!e.confirmed&&o&&!n,onClick:()=>a(!0),children:[(0,Z.jsx)(S,{"aria-hidden":`true`}),`Start migration`]})}),i&&(0,Z.jsx)(nt,{plan:e.plan,acceptLimits:o&&(e.confirmed||n),onClose:()=>a(!1),onStarted:e=>{a(!1),t(e)}})]})}function it(e){return e.result?.status===`running`?`running`:e.result?.status===`migrated`?`done`:e.result?`review`:`planned`}function at(e){return e.result?ce[e.result.status]:e.confirmed?{label:`Confirmed`,tone:`neutral`}:le[e.verdict]}function ot({view:e}){let[t,n]=(0,X.useState)(`all`),r=t=>t===`all`?e.plans.length:e.plans.filter(e=>it(e)===t).length,i=e.plans.filter(e=>t===`all`||it(e)===t),a=e=>location.hash=A(`migration`,e);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(fe,{children:[(0,Z.jsx)(Y,{label:`All`,value:r(`all`),onClick:()=>n(`all`),on:t===`all`}),(0,Z.jsx)(Y,{label:`Running`,value:r(`running`),onClick:()=>n(`running`),on:t===`running`}),(0,Z.jsx)(Y,{label:`Migrated`,value:r(`done`),tone:r(`done`)?`text-pass`:void 0,onClick:()=>n(`done`),on:t===`done`}),(0,Z.jsx)(Y,{label:`Needs review`,value:r(`review`),tone:r(`review`)?`text-warn`:void 0,onClick:()=>n(`review`),on:t===`review`})]}),(0,Z.jsx)(o,{label:`Migrations`,placeholder:`Find a migration`,empty:t===`all`?`No migrations.`:`None here.`,resetKey:t,head:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`th`,{className:`py-1.5 pr-3 pl-3 font-medium`,children:`Migration`}),(0,Z.jsx)(`th`,{className:`hidden py-1.5 pr-3 font-medium @3xl:table-cell`,children:`Source`}),(0,Z.jsx)(`th`,{className:`py-1.5 pr-3 font-medium`,children:`Tests`}),(0,Z.jsx)(`th`,{className:`py-1.5 pr-3 font-medium`,children:`Status`}),(0,Z.jsx)(`th`,{className:`hidden py-1.5 pr-3 font-medium @xl:table-cell`,children:`Updated`})]}),children:i.map(e=>{let t=at(e),n=e.result?e.result.status===`migrated`||e.result.endedAt?100:Math.round(e.result.done/Math.max(1,e.files)*95):0;return(0,Z.jsxs)(`tr`,{onClick:()=>a(e.id),className:x,children:[(0,Z.jsx)(`td`,{className:m,children:(0,Z.jsxs)(`span`,{className:`flex items-center gap-3`,children:[(0,Z.jsxs)(`span`,{className:`hidden flex-none items-center gap-1 @xl:inline-flex`,"aria-hidden":`true`,children:[(0,Z.jsx)(q,{framework:e.stack?.framework,language:e.stack?.language,size:18}),(0,Z.jsx)(M,{size:13,className:`text-muted`}),(0,Z.jsx)(q,{framework:e.targetId.split(`-`)[0],language:e.targetId.split(`-`).slice(1).join(`-`),size:18})]}),(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsxs)(`a`,{href:A(`migration`,e.id),onClick:e=>e.stopPropagation(),className:`font-medium text-ink no-underline hover:underline`,children:[e.source,` to `,e.target]}),(0,Z.jsx)(`span`,{className:`block text-[12px] text-muted`,children:e.to})]})]})}),(0,Z.jsx)(`td`,{className:p(m,`hidden max-w-[260px] @3xl:table-cell`),children:(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[13px] text-ink-2`,children:[(0,Z.jsx)(ye,{kind:e.origin.kind,label:e.origin.label,size:15}),(0,Z.jsx)(`span`,{className:`truncate`,"data-tip":e.origin.label,children:e.origin.kind===`project`?e.from:J(e.origin.label)})]})}),(0,Z.jsx)(`td`,{className:p(m,`w-[180px] text-[13px]`),children:e.result?.status===`running`?(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(he,{value:n,label:`${e.source} to ${e.target}: progress`}),(0,Z.jsxs)(`span`,{className:`w-9 flex-none text-right text-[12px] text-muted tabular-nums`,children:[n,`%`]})]}):e.result?(0,Z.jsxs)(`span`,{className:e.result.migrated===e.tests?`text-pass`:`text-ink-2`,children:[e.result.migrated,` of `,e.tests,` pass`]}):(0,Z.jsx)(`span`,{className:`text-muted`,children:`Not started`})}),(0,Z.jsx)(`td`,{className:p(m,`whitespace-nowrap`),children:(0,Z.jsx)(R,{tone:t.tone,children:t.label})}),(0,Z.jsx)(`td`,{className:p(m,`hidden text-[12.5px] whitespace-nowrap text-muted @xl:table-cell`),children:G(e.result?.endedAt||e.result?.at||e.createdAt)})]},e.id)})})]})}function st({sub:e}){let[t,n]=(0,X.useState)(null),[r,a]=(0,X.useState)(``),[o,s]=(0,X.useState)(null),l=(0,X.useCallback)(()=>{i.list().then(e=>{n(e),a(``)},e=>a(e.message))},[]);(0,X.useEffect)(l,[l,e]);let u=t?.plans.some(e=>e.result?.status===`running`);(0,X.useEffect)(()=>{if(!u||e)return;let t=setInterval(l,3e3);return()=>clearInterval(t)},[u,e,l]);let d=e&&/^mig-\d{8}-\d{6}-[0-9a-f]{4}$/.test(e)?e:``,f=()=>location.hash=A(`migration`,`new`),p=!t&&!r&&(0,Z.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`});return e===`new`?(0,Z.jsxs)(Xe,{children:[(0,Z.jsx)(Ze,{}),(0,Z.jsx)(Qe,{error:r}),p,t&&(0,Z.jsx)(Ye,{view:t,review:(e,t,n)=>(0,Z.jsx)(tt,{plan:e,accepted:t,onAccept:n}),onStart:(e,t)=>s({d:e,accept:t})}),o&&(0,Z.jsx)(nt,{plan:o.d.plan,acceptLimits:o.accept,onClose:()=>s(null),onStarted:e=>location.hash=A(`migration`,e.plan.id)})]}):d?(0,Z.jsxs)(Xe,{wide:!0,children:[(0,Z.jsx)(Ze,{}),(0,Z.jsx)(Qe,{error:r}),p,t&&(0,Z.jsx)(Pe,{id:d,view:t,plan:e=>(0,Z.jsx)(rt,{d:e,onStarted:()=>location.reload()})},d)]}):(0,Z.jsxs)(Xe,{children:[(0,Z.jsx)(Ze,{action:t&&!t.plans.length?void 0:(0,Z.jsx)(c,{variant:`primary`,disabled:!t,onClick:f,children:`New migration`})}),(0,Z.jsx)(Qe,{error:r}),p,t&&(t.plans.length?(0,Z.jsx)(ot,{view:t}):(0,Z.jsx)(b,{icon:z,title:`No migrations yet`,action:(0,Z.jsx)(c,{size:`sm`,onClick:f,children:`New migration`}),children:`Bring in tests from git, a folder, uploaded files or pasted code, and pick the framework they move to. Nothing starts until you confirm.`}))]})}export{st as Migration};
@@ -0,0 +1 @@
1
+ import{$a as e,$r as t,Ar as n,Dn as r,Dr as i,Dt as a,En as o,Gn as s,Jt as c,Kt as l,Mn as u,On as d,Pa as f,Pi as p,Qn as m,Ra as h,Rr as g,Si as _,Tt as v,Ui as y,Vr as b,Wr as x,Xi as S,Xt as C,Yr as w,Za as T,an as E,at as D,dn as O,dt as k,ft as ee,ja as te,ji as A,ki as j,ln as M,mt as N,n as P,nn as F,no as I,oa as L,oi as ne,pi as re,pt as R,qn as z,tn as ie,ut as ae,wa as B,wi as V,wt as H}from"./Shell-DGv_Zqjs.js";import{t as U}from"./index-DI1ST-gI.js";import{t as oe}from"./when-CHnpLdYw.js";import{t as se}from"./segmented-1nc3D7ML.js";import{a as W,i as G,n as ce,o as le,r as K,t as ue}from"./productParts-Q9GA6BML.js";var q=I(e(),1),J={w:196,h:60},Y=56,de=24,fe=36,pe=18,me=30,X=8,Z=12,he=14,ge=6;function _e(e,t=8){let n=e=>Math.round(e*10)/10,r=`M${n(e[0][0])} ${n(e[0][1])}`;for(let i=1;i<e.length-1;i++){let[a,o]=e[i-1],[s,c]=e[i],[l,u]=e[i+1],d=Math.min(t,Math.hypot(s-a,c-o)/2),f=Math.min(t,Math.hypot(l-s,u-c)/2),p=s-Math.sign(s-a)*d,m=c-Math.sign(c-o)*d,h=s+Math.sign(l-s)*f,g=c+Math.sign(u-c)*f;r+=` L${n(p)} ${n(m)} Q${n(s)} ${n(c)} ${n(h)} ${n(g)}`}let[i,a]=e[e.length-1];return`${r} L${n(i)} ${n(a)}`}function ve(e){let t=[];for(let n of e){let e=t[t.length-1];e&&Math.abs(e[0]-n[0])<.01&&Math.abs(e[1]-n[1])<.01||t.push(n)}return t.filter((e,n)=>{if(n===0||n===t.length-1)return!0;let[r,i]=[t[n-1],t[n+1]];return!(Math.abs(r[0]-e[0])<.01&&Math.abs(i[0]-e[0])<.01||Math.abs(r[1]-e[1])<.01&&Math.abs(i[1]-e[1])<.01)})}function ye(e,t,n,r){let i=r?e.filter(e=>e.band===r):[],a=n.filter(t=>e.some(e=>e.band===t)),o=new Set([...e.filter(e=>a.includes(e.band)).map(e=>e.id),...i.map(e=>e.id)]),s=t.filter(e=>o.has(e.from)&&o.has(e.to)&&e.from!==e.to),c=new Set(i.map(e=>e.id)),l=new Map;for(let e of s)l.set(e.from,[...l.get(e.from)||[],e.to]),l.set(e.to,[...l.get(e.to)||[],e.from]);let u=new Map(a.map(t=>[t,e.filter(e=>e.band===t).map(e=>e.id)])),d=new Map,f=e=>u.get(e).forEach((e,t,n)=>d.set(e,n.length>1?t/(n.length-1):.5)),p=(e,t)=>{let n=u.get(e),r=(e,r)=>{let i=(l.get(e)||[]).filter(e=>t(e)&&d.has(e)).map(e=>d.get(e));return i.length?i.reduce((e,t)=>e+t,0)/i.length:n.length>1?r/(n.length-1):.5},i=n.map((e,t)=>({id:e,k:r(e,t),i:t}));i.sort((e,t)=>e.k-t.k||e.i-t.i),u.set(e,i.map(e=>e.id)),f(e)};a.forEach(f);let m=new Map(e.map(e=>[e.id,e.band])),h=e=>t=>a.indexOf(m.get(t))<a.indexOf(e),g=e=>t=>a.indexOf(m.get(t))>a.indexOf(e);a.slice(1).forEach(e=>p(e,h(e))),a.slice(0,-1).reverse().forEach(e=>p(e,g(e)));let _=Math.max(1,...a.map(e=>u.get(e).length)),v=Math.min(_,ge),y=[];for(let e of a){let t=u.get(e);for(let n=0;n<t.length;n+=v)y.push({band:e,ids:t.slice(n,n+v)})}let b=new Map;y.forEach((e,t)=>e.ids.forEach(e=>b.set(e,t)));let x=v*J.w+(v-1)*Y,S=new Map,C=y.map(e=>{let t=e.ids.length*J.w+(e.ids.length-1)*Y,n=(x-t)/2;return e.ids.forEach((e,t)=>S.set(e,n+t*(J.w+Y))),{left:n,right:n+t}}),w=e=>S.get(e)+J.w/2,T=[],E=(e,t,n)=>{for(let r=t;r<=n;r++)for(let t of y[r].ids)if(e>S.get(t)-6&&e<S.get(t)+J.w+6)return!1;return!0};s.forEach((e,t)=>{let n=c.has(e.to)&&!c.has(e.from),r=c.has(e.from)&&!c.has(e.to);if(c.has(e.from)&&c.has(e.to))return;let i=r?{from:e.to,to:e.from}:e,a=b.get(i.from);if(n||r){T.push({e,i:t,reverse:r,out:{side:`bottom`,node:i.from,edge:t},inn:{side:`left`,node:i.to,edge:t},c1:a+1,c2:a+1,toSide:!0});return}let o=b.get(i.to),s=a<=o,l={side:a<o||a===o?`bottom`:`top`,node:i.from,edge:t},u={side:a<o?`top`:`bottom`,node:i.to,edge:t},d=s?a+1:a,f=a<o?o:o+1,p;if(d!==f){let[e,t]=d<f?[d,f-1]:[f,d-1],n=(w(i.from)+w(i.to))/2,r=new Set;for(let n=e;n<=t;n++)y[n].ids.forEach((e,t)=>t>0&&r.add(S.get(e)-Y/2)),r.add(C[n].left-Y/2),r.add(C[n].right+Y/2);let a=[...r].filter(n=>n>-29&&n<x+Y/2+1&&E(n,e,t)).sort((e,t)=>Math.abs(e-n)-Math.abs(t-n));p=a.length?a[0]:`gutter`}T.push({e,i:t,reverse:!1,out:l,inn:u,c1:d,c2:f,corridor:p,toSide:!1})});let D=e=>{let t=new Map;for(let n of T)for(let r of e(n))t.set(r,[...t.get(r)||[],n]);return t},O=e=>w(e.toSide&&e.reverse?e.e.to:e.e.from),k=D(e=>e.c1===e.c2?[e.c1]:[e.c1,e.c2]);for(let[,e]of k)e.sort((e,t)=>O(e)-O(t));let ee=D(e=>typeof e.corridor==`number`?[e.corridor]:[]),te=T.filter(e=>e.corridor===`gutter`),A=T.filter(e=>e.toSide),j=(e,t)=>{if(!e)return 0;let n=e.length;return(e.indexOf(t)-(n-1)/2)*X},M=y.length,N=e=>{let t=16+(k.get(e)?.length||0)*X;return e===M?Math.max(28,t):y[e-1].band===y[e].band?Math.max(me,t):Math.max(72,t+24)},P=[],F=[],I=48;for(let e=0;e<M;e++){P.push(I),I+=J.h;let t=N(e+1);e+1<M&&y[e].band!==y[e+1].band?F[e+1]=I+pe+(t-pe-fe)/2:F[e+1]=I+t/2,I+=t}let L=P[M-1]+J.h+N(M),ne=te.length?16+te.length*X:0,re=Z+ne+de,R=Z+ne,z=x+48,ie=A.length?20+A.length*X:0,ae=R+z+Math.max(ie,24),B=new Map;y.forEach((e,t)=>e.ids.forEach(n=>B.set(n,{id:n,band:e.band,x:re+S.get(n),y:P[t],w:J.w,h:J.h})));let V=[];for(let e of a){let t=y.map((e,t)=>({r:e,i:t})).filter(t=>t.r.band===e),n=P[t[0].i]-fe,r=P[t[t.length-1].i]+J.h+pe;V.push({id:e,x:R,y:n,w:z,h:r-n})}let H=0;if(r&&i.length){let e=e=>{let t=(l.get(e)||[]).filter(e=>B.has(e)).map(e=>B.get(e).y);return t.length?t.reduce((e,t)=>e+t,0)/t.length:1/0},t=i.map((t,n)=>({id:t.id,k:e(t.id),i:n})).sort((e,t)=>e.k-t.k||e.i-t.i),n=Z,a=48;for(let e of t){let t=Math.max(a,Number.isFinite(e.k)?e.k:a);B.set(e.id,{id:e.id,band:r,x:ae+de,y:t,w:J.w,h:J.h}),a=t+J.h+he}H=a-he+pe;let o=Math.max(H,L-10)-n;V.push({id:r,x:ae,y:n,w:J.w+48,h:o}),H=n+o}let U=new Map;for(let e of T)for(let t of[e.out,e.inn])U.set(`${t.node}|${t.side}`,[...U.get(`${t.node}|${t.side}`)||[],t]);let oe=e=>{let t=T.find(t=>t.i===e.edge),n=t.reverse?{from:t.e.to,to:t.e.from}:t.e,r=e.node===n.from?n.to:n.from,i=B.get(r);return e.side===`left`?i.y:i.x};for(let[,e]of U)e.sort((e,t)=>oe(e)-oe(t));let se=e=>{let t=B.get(e.node),n=U.get(`${e.node}|${e.side}`),r=n.indexOf(e),i=n.length;if(e.side===`left`)return[t.x,t.y+t.h*(r+1)/(i+1)];let a=Math.min(t.w*.7,i*22);return[t.x+t.w/2-a/2+(i===1?a/2:a*r/(i-1)),e.side===`top`?t.y:t.y+t.h]},W=[];for(let e of T){let t=se(e.out),n=se(e.inn),r=F[e.c1]+j(k.get(e.c1),e),i;if(e.toSide){let a=R+z+12+A.indexOf(e)*X;i=[t,[t[0],r],[a,r],[a,n[1]],n]}else if(e.c1===e.c2)i=[t,[t[0],r],[n[0],r],n];else{let a=F[e.c2]+j(k.get(e.c2),e),o=e.corridor===`gutter`?20+te.indexOf(e)*X:re+e.corridor+j(ee.get(e.corridor),e);i=[t,[t[0],r],[o,r],[o,a],[n[0],a],n]}i=ve(i),e.reverse&&i.reverse(),W.push({index:e.i,from:e.e.from,to:e.e.to,points:i,d:_e(i)})}return{w:r&&i.length?ae+J.w+48+Z:R+z+Math.max(ie,0)+Z,h:Math.max(L,H)+Z,boxes:B,bands:V,wires:W}}var Q=T(),be=[{id:`front`,label:`Front ends`,icon:i,hue:`#0B6E4F`},{id:`gateway`,label:`Gateways`,icon:_,hue:`#C86A0A`},{id:`service`,label:`Services`,icon:j,hue:`#2563EB`},{id:`data`,label:`Data and messages`,icon:z,hue:`#0B8A8A`},{id:`outside`,label:`Outside`,icon:O,hue:`#5B4BC9`}],xe=e=>e.repo&&e.column!==`data`?`select it to see it from the inside`:e.part?`select it for how it is known`:``,Se=.72;function Ce(e){return e.known===`seen`?`stroke-pass`:e.known===`differs`?`stroke-warn`:`stroke-muted`}var we=[`seen`,`differs`,`read`,`inferred`];function Te(e){let t=new Map;for(let n of e){let e=`${n.from}\u0000${n.to}`,r=t.get(e);(!r||we.indexOf(n.known)<we.indexOf(r.known))&&t.set(e,{from:n.from,to:n.to,known:n.known})}return t}function Ee({view:e,onOpen:t,words:n={}}){let r=e=>({...be.find(t=>t.id===e),...n.bands?.[e]}),i=(0,q.useMemo)(()=>Te(e.links),[e]),a=(0,q.useMemo)(()=>ye(e.nodes.map(e=>({id:e.id,band:e.column})),[...i.values()].map(e=>({from:e.from,to:e.to})),[`front`,`gateway`,`service`,`data`],`outside`),[e,i]),s=(0,q.useRef)(null),[l,u]=(0,q.useState)(1),[d,f]=(0,q.useState)(null),[p,m]=(0,q.useState)(null),h=d||p;(0,q.useLayoutEffect)(()=>{let e=()=>{let e=s.current;if(!e)return;let t=window.innerHeight-e.getBoundingClientRect().top-24,n=Math.min(e.clientWidth/a.w,Math.max(t,360)/a.h,1);u(Math.max(Se,n))};e();let t=typeof ResizeObserver>`u`?null:new ResizeObserver(e);return s.current&&t?.observe(s.current),window.addEventListener(`resize`,e),()=>{t?.disconnect(),window.removeEventListener(`resize`,e)}},[a]);let g=new Map(e.nodes.map(e=>[e.id,e])),_=e=>!h||e.from===h||e.to===h,v=new Set(h?e.links.filter(e=>e.from===h||e.to===h).flatMap(e=>[e.from,e.to]):[]),y=l<=Se&&(s.current?.clientWidth||1/0)<a.w*l,b=(e,t)=>i.get(`${e}\u0000${t}`);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(`div`,{ref:s,className:`w-full overflow-x-auto`,onMouseLeave:()=>f(null),children:(0,Q.jsx)(`div`,{className:`relative mx-auto`,style:{width:a.w*l,height:a.h*l},children:(0,Q.jsxs)(`div`,{className:`absolute top-0 left-0`,style:{width:a.w,height:a.h,transform:`scale(${l})`,transformOrigin:`0 0`},children:[(0,Q.jsxs)(`svg`,{"aria-hidden":`true`,width:a.w,height:a.h,viewBox:`0 0 ${a.w} ${a.h}`,className:`absolute inset-0 overflow-visible`,children:[(0,Q.jsx)(`defs`,{children:[`pass`,`warn`,`muted`].map(e=>(0,Q.jsx)(`marker`,{id:`map-${e}`,viewBox:`0 0 8 8`,refX:7,refY:4,markerWidth:8,markerHeight:8,markerUnits:`userSpaceOnUse`,orient:`auto`,children:(0,Q.jsx)(`path`,{d:`M0 0 L8 4 L0 8 Z`,className:e===`pass`?`fill-pass`:e===`warn`?`fill-warn`:`fill-muted`})},e))}),a.bands.map(e=>(0,Q.jsx)(`rect`,{x:e.x,y:e.y,width:e.w,height:e.h,rx:16,fill:r(e.id).hue,fillOpacity:.055,stroke:r(e.id).hue,strokeOpacity:.24},e.id)),a.wires.map(e=>(0,Q.jsx)(`path`,{d:e.d,fill:`none`,strokeWidth:5,className:`stroke-bg`,opacity:_(e)?1:.15},`h${e.index}`)),a.wires.map(e=>{let t=b(e.from,e.to),n=g.get(e.from)?.column===`outside`||g.get(e.to)?.column===`outside`,r=t.known===`seen`?`pass`:t.known===`differs`?`warn`:`muted`;return(0,Q.jsx)(`path`,{d:e.d,fill:`none`,strokeWidth:h&&_(e)?2.25:t.known===`seen`?1.75:1.4,strokeDasharray:n?`5 4`:t.known===`differs`?`2 3`:void 0,markerEnd:`url(#map-${r})`,className:C(Ce(t),`transition-opacity duration-150`),opacity:_(e)?1:.15},e.index)})]}),a.bands.map(e=>(0,Q.jsxs)(`span`,{className:`absolute z-[1] flex items-center gap-1.5 rounded-[6px] bg-bg/90 px-1.5 py-0.5 text-[12px] font-semibold text-ink-2`,style:{left:e.x+10,top:e.y+7},children:[(0,Q.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:r(e.id).hue},"aria-hidden":`true`}),r(e.id).label]},e.id)),[...a.boxes.values()].map(n=>{let i=g.get(n.id),a=h&&h!==i.id&&!v.has(i.id),s=e.links.filter(e=>e.from===i.id).length,l=e.links.filter(e=>e.to===i.id).length;return(0,Q.jsxs)(`button`,{type:`button`,onMouseEnter:()=>f(i.id),onFocus:()=>m(i.id),onBlur:()=>m(e=>e===i.id?null:e),onClick:()=>t(i),"aria-label":`${i.name}, ${r(i.column).label.toLowerCase()}: ${i.detail}. ${ce[i.known].label}. Sends to ${s}, receives from ${l}.`,className:C(`absolute flex cursor-pointer flex-col justify-center gap-0.5 rounded-[10px] border bg-bg px-3 text-left transition-opacity duration-150 hover:bg-surface-muted`,i.column===`outside`&&`border-dashed`,a&&`opacity-40`,h===i.id&&`shadow-md`),style:{left:n.x,top:n.y,width:n.w,height:n.h,borderColor:`color-mix(in srgb, ${r(i.column).hue} 55%, transparent)`},children:[(0,Q.jsxs)(`span`,{className:`flex w-full min-w-0 items-center gap-1.5 text-[13.5px] font-semibold text-ink`,children:[(0,Q.jsx)(c,{icon:r(i.column).icon,size:14,className:`flex-none`}),(0,Q.jsx)(`span`,{className:`truncate`,children:i.name}),i.known===`seen`&&(0,Q.jsx)(o,{size:13,"aria-hidden":`true`,className:`ml-auto flex-none text-pass`})]}),(0,Q.jsx)(`span`,{className:`truncate font-mono text-[11px] text-muted`,children:i.detail})]},i.id)})]})})}),y&&(0,Q.jsx)(`p`,{className:`m-0 text-[12px] text-muted`,children:`Scroll sideways to see the whole map.`}),(0,Q.jsx)(De,{}),(0,Q.jsx)(Oe,{view:e,id:h,words:n,band:r})]})}function De(){let e=(e,t,n)=>(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,Q.jsx)(`svg`,{width:`28`,height:`8`,"aria-hidden":`true`,children:(0,Q.jsx)(`path`,{d:`M1 4 H27`,fill:`none`,strokeWidth:1.75,strokeDasharray:e,className:t})}),n]});return(0,Q.jsxs)(`p`,{className:`m-0 flex flex-wrap items-center gap-x-5 gap-y-1 text-[12px] text-muted`,children:[e(void 0,`stroke-muted`,`Inside the product, read in the code`),e(`5 4`,`stroke-muted`,`To or from an outside system`),e(void 0,`stroke-pass`,`Seen in a run`),e(`2 3`,`stroke-warn`,`A run called it differently`)]})}function Oe({view:e,id:t,words:n,band:r}){let i=t?e.nodes.find(e=>e.id===t):void 0,a=i?(n.hint||xe)(i):``,o=t=>e.nodes.find(e=>e.id===t)?.name||t,s=(e,t)=>{let n=new Map;for(let r of e){let e=r[t],i=n.get(e);i?n.set(e,{other:e,label:i.label.split(`, `).includes(r.label)?i.label:`${i.label}, ${r.label}`,known:i.known===`seen`||r.known===`seen`?`seen`:i.known}):n.set(e,{other:e,label:r.label,known:r.known})}return[...n.values()]},c=(e,t)=>e.length?(0,Q.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0 text-[13px]`,children:e.map((e,t)=>(0,Q.jsxs)(`li`,{className:`flex justify-between gap-3 border-t border-line-soft py-1.5 first:border-t-0 first:pt-0`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-medium text-ink`,children:o(e.other)}),(0,Q.jsxs)(`span`,{className:`flex-none text-muted`,children:[e.label,e.known===`seen`?` · seen in a run`:``]})]},t))}):(0,Q.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:t});return(0,Q.jsx)(`div`,{"aria-live":`polite`,className:`grid min-h-[120px] gap-x-10 gap-y-4 rounded-[14px] card border px-5 py-4 @3xl:[grid-template-columns:minmax(220px,1.1fr)_1fr_1fr]`,children:i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Q.jsxs)(`h3`,{className:`m-0 flex items-center gap-2 text-base font-semibold`,children:[(0,Q.jsx)(`span`,{className:`size-2.5 flex-none rounded-full`,style:{background:r(i.column).hue},"aria-hidden":`true`}),i.name]}),(0,Q.jsx)(`p`,{className:`m-0 text-[13px] text-muted [overflow-wrap:anywhere]`,children:i.detail}),(0,Q.jsxs)(`p`,{className:`m-0 text-[12px] text-muted`,children:[r(i.column).label,` · `,ce[i.known].label,a?` · ${a}`:``]})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Q.jsx)(`h4`,{className:`m-0 text-[13px] font-semibold`,children:n.sends||`Sends to`}),c(s(e.links.filter(e=>e.from===i.id),`to`),`Nothing.`)]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Q.jsx)(`h4`,{className:`m-0 text-[13px] font-semibold`,children:n.receives||`Receives from`}),c(s(e.links.filter(e=>e.to===i.id),`from`),`Nothing.`)]})]}):(0,Q.jsx)(`p`,{className:`m-0 self-center text-[13px] text-muted @3xl:col-span-3`,children:n.idle||`Hover over or tab to a part to trace what it sends and receives. Select a service to see it from the inside; the How they talk tab lists every link in words.`})})}var ke={bands:{front:{label:`Channels`,icon:i},gateway:{label:`Edge`,icon:_},service:{label:`Business systems`,icon:j},data:{label:`Data`,icon:z},outside:{label:`Outside and SaaS`,icon:O}},hint:e=>e.column===`outside`?`select it for how it is known`:`select it to see its services`,idle:`Hover over or tab to a system to trace what it sends and receives, and how. Select one to see its services.`},Ae=e=>e.modes.map(e=>`${e.mode} (${e.count})`).join(`, `);function je(e){return{nodes:e.nodes.map(e=>({id:e.id,name:e.name,column:e.column,detail:e.detail,known:e.known,...e.column===`outside`?{part:e.id}:{}})),links:e.links.map(e=>({from:e.from,to:e.to,label:Ae(e),count:e.count,known:e.known,example:e.examples[0]||``}))}}function Me({onPart:e}){let[t,n]=(0,q.useState)(null),[r,i]=(0,q.useState)(``);(0,q.useEffect)(()=>{f.view().then(n,e=>i(e.message))},[]);let a=(0,q.useMemo)(()=>t?je(t):null,[t]);if(r)return(0,Q.jsx)(G,{text:r});if(!t||!a)return(0,Q.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`});let o=e=>t.nodes.find(t=>t.id===e)?.name||e;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[t.grouping===`names`&&(0,Q.jsxs)(`p`,{className:`m-0 flex max-w-[74ch] items-start gap-2 text-sm text-ink-2`,children:[(0,Q.jsx)(g,{size:16,"aria-hidden":`true`,className:`mt-0.5 flex-none text-muted`}),(0,Q.jsxs)(`span`,{children:[`Repositories without a system are grouped by the first word of their names, or stand alone (`,t.guessed.slice(0,6).join(`, `),t.guessed.length>6?`, and ${t.guessed.length-6} more`:``,`). Give each repository its system, as your teams name them, in `,(0,Q.jsx)(`a`,{href:N(`settings`,`evidence`),children:`Settings, Evidence, Repositories`}),t.proposal?`.`:(0,Q.jsxs)(Q.Fragment,{children:[`, or let the model propose them: `,(0,Q.jsx)(`code`,{children:`forgeqe knowledge systems --propose`}),`.`]})]})]}),(0,Q.jsxs)(`section`,{"aria-labelledby":`landscape-h`,className:`flex flex-col gap-3`,children:[(0,Q.jsx)(`h2`,{id:`landscape-h`,className:`sr-only`,children:`Systems map`}),(0,Q.jsx)(Ee,{view:a,onOpen:t=>{t.column===`outside`?e(t.id):location.hash=N(`product`,`systems`,encodeURIComponent(t.name))},words:ke})]}),t.proposal&&(0,Q.jsx)(Ne,{view:t,onView:n}),(0,Q.jsx)(W,{id:`systems-talk`,title:`How the systems talk`,icon:re,n:t.links.length,children:t.links.length?(0,Q.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:[...t.links].sort((e,t)=>t.count-e.count).map(e=>(0,Q.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-b border-line-soft py-2.5 last:border-b-0`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 flex-[1_1_320px] text-[14px] [overflow-wrap:anywhere]`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:o(e.from)}),` `,(0,Q.jsx)(`span`,{className:`text-muted`,children:`to`}),` `,(0,Q.jsx)(`span`,{className:`font-medium`,children:o(e.to)}),(0,Q.jsxs)(`span`,{className:`text-muted`,children:[` · `,Ae(e)]}),e.via.length>0&&(0,Q.jsxs)(`span`,{className:`text-muted`,children:[` · on `,e.via.slice(0,4).join(`, `)]}),e.examples.slice(0,3).map((e,t)=>(0,Q.jsx)(`span`,{className:`block text-[12px] text-muted`,children:e},t))]}),(0,Q.jsx)(K,{known:e.known})]},`${e.from}>${e.to}`))}):(0,Q.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`No link between systems was found: each system's code talks only to itself, or calls no route read.`})}),t.loose.length>0&&(0,Q.jsxs)(W,{id:`loose`,title:`Messages with one end here`,icon:E,n:t.loose.length,children:[(0,Q.jsx)(`p`,{className:`m-0 max-w-[74ch] text-sm text-muted`,children:`A topic or queue a system here publishes that nothing here consumes, or the other way round: the other end is in a repository not read yet, or nobody.`}),(0,Q.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:t.loose.map(e=>(0,Q.jsxs)(`li`,{className:`border-b border-line-soft py-2 text-[14px] last:border-b-0 [overflow-wrap:anywhere]`,children:[(0,Q.jsx)(`span`,{className:`font-mono text-[13px]`,children:e.topic}),(0,Q.jsxs)(`span`,{className:`text-muted`,children:[e.publishers.length?` · published by ${e.publishers.join(`, `)}`:``,e.consumers.length?` · consumed by ${e.consumers.join(`, `)}`:``]})]},e.topic))})]})]})}function Ne({view:e,onView:t}){let[n,r]=(0,q.useState)(null),[i,a]=(0,q.useState)(``),[s,c]=(0,q.useState)(``),[d,m]=(0,q.useState)(!1),h=e.assigned.filter(e=>e.by!==`settings`&&(e.why||e.by===`person`||e.rejected)),g=h.filter(e=>e.by===`model`),_=async n=>{m(!0),c(``);try{let i=e;for(let[e,t,r]of n)i=await f.decide(e,t,r);t(i),r(null)}catch(e){c(e.message)}finally{m(!1)}};if(!h.length)return null;let v=e.proposal;return(0,Q.jsxs)(W,{id:`proposal`,title:`Systems proposed by the model`,icon:p,n:g.length||void 0,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`p`,{className:`m-0 max-w-[74ch] text-sm text-muted`,children:[`Proposed by `,v?.model||`the model`,v?.at?` on ${v.at.slice(0,10)}`:``,`, from what the graph knows of each repository. Accept each, rename it, or reject it; a system set in Settings always wins. `,g.length?`${g.length} wait for a person.`:`All are decided.`]}),g.length>1&&(0,Q.jsxs)(l,{size:`sm`,variant:`ghost`,disabled:d,onClick:()=>void _(g.map(e=>[e.repo,`accepted`])),children:[(0,Q.jsx)(o,{"aria-hidden":`true`}),`Accept all `,g.length]})]}),s&&(0,Q.jsx)(G,{text:s}),(0,Q.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:h.map(e=>(0,Q.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-line-soft py-2.5 last:border-b-0`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 flex-[1_1_320px] text-[14px] [overflow-wrap:anywhere]`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.repo}),` `,(0,Q.jsx)(`span`,{className:`text-muted`,children:`in`}),` `,(0,Q.jsx)(`span`,{className:`font-medium`,children:e.rejected?`its own name`:e.system}),(0,Q.jsxs)(`span`,{className:`text-muted`,children:[` · `,e.rejected?`rejected`:e.by===`person`?`accepted`:`proposed`]}),e.why&&(0,Q.jsx)(`span`,{className:`block text-[12px] text-muted`,children:e.why})]}),n===e.repo?(0,Q.jsxs)(`form`,{className:`flex w-full max-w-[420px] gap-1.5`,onSubmit:t=>{t.preventDefault(),i.trim()&&_([[e.repo,`accepted`,i.trim()]])},children:[(0,Q.jsx)(D,{"aria-label":`System for ${e.repo}`,placeholder:`CRM`,value:i,maxLength:60,onChange:e=>a(e.target.value),className:`flex-1`}),(0,Q.jsx)(l,{type:`submit`,size:`sm`,disabled:d||!i.trim(),children:`Save`}),(0,Q.jsx)(l,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>r(null),children:`Cancel`})]}):(0,Q.jsx)(`div`,{role:`group`,"aria-label":`The system for ${e.repo}`,className:`flex gap-1.5`,children:e.by===`model`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,disabled:d,onClick:()=>void _([[e.repo,`accepted`]]),className:Pe,children:[(0,Q.jsx)(o,{size:14,"aria-hidden":`true`}),`Accept`]}),(0,Q.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>{a(e.system),r(e.repo)},className:Pe,children:`Rename`}),(0,Q.jsxs)(`button`,{type:`button`,disabled:d,onClick:()=>void _([[e.repo,`rejected`]]),className:Pe,children:[(0,Q.jsx)(u,{size:14,"aria-hidden":`true`}),`Reject`]})]}):(0,Q.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>void _([[e.repo,null]]),className:Pe,children:`Undo`})})]},e.repo))})]})}var Pe=C(`inline-flex min-h-8 cursor-pointer items-center gap-1 rounded-[8px] border border-transparent bg-surface-strong px-3 text-[13px] font-medium text-ink-2 hover:bg-line hover:text-ink disabled:cursor-not-allowed`);function Fe({eng:e,name:t,onOpen:n}){let[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(``);(0,q.useEffect)(()=>{f.view().then(i,e=>o(e.message))},[]);let s=(0,q.useMemo)(()=>{let n=r?.nodes.find(e=>e.name===t&&e.column!==`outside`);if(!r||!n)return null;let i=new Set(n.parts),a=e.links.filter(e=>i.has(e.from)||i.has(e.to)),o=new Set(a.flatMap(e=>[e.from,e.to])),s=e=>r.nodes.find(t=>t.parts.includes(e))?.name,c=e.nodes.filter(e=>i.has(e.id)||o.has(e.id)).map(e=>i.has(e.id)||e.column===`outside`||!s(e.id)?e:{...e,detail:`in ${s(e.id)} · ${e.detail}`});return{nodes:c,links:a,other:c.filter(e=>!i.has(e.id)).length}},[r,e,t]),c=r?.nodes.find(e=>e.name===t&&e.column!==`outside`);return(0,Q.jsxs)(`section`,{"aria-labelledby":`system-h`,className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`a`,{href:N(`product`),className:`inline-flex items-center gap-1.5 self-start text-sm`,children:[(0,Q.jsx)(ie,{size:16,"aria-hidden":`true`}),`All systems`]}),(0,Q.jsx)(`h2`,{id:`system-h`,className:`m-0 text-[22px] font-semibold tracking-[-0.01em] [overflow-wrap:anywhere]`,children:t}),c&&(0,Q.jsxs)(`p`,{className:`m-0 text-sm text-ink-2`,children:[c.detail,c.repos.length?` · repositories: ${c.repos.join(`, `)}`:``,c.inside?` · ${c.inside} links among its own parts`:``,s?.other?` · ${s.other} parts of other systems it talks to, named with their system`:``]})]}),a&&(0,Q.jsx)(G,{text:a}),!r&&!a&&(0,Q.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),r&&!c&&(0,Q.jsxs)(`p`,{className:`m-0 text-sm text-muted`,children:[`No system is named `,t,`; it may have been renamed in Settings. See `,(0,Q.jsx)(`a`,{href:N(`product`),children:`all systems`}),`.`]}),s&&(0,Q.jsx)(Ee,{view:s,onOpen:n,words:{idle:`Hover over or tab to a part to trace what it sends and receives. Select a service to see it from the inside.`}}),c&&(0,Q.jsx)(`p`,{className:`m-0 text-[12px] text-muted`,children:`The system's services and the parts of other systems they reach, from the same graph as the services map.`})]})}function Ie({id:e,verdict:t,note:n,onChanged:r}){let[i,a]=(0,q.useState)(n||``),[s,c]=(0,q.useState)(``),[d,f]=(0,q.useState)(!1),p=async(t,n)=>{f(!0),c(``);try{await h.feedback(e,t,n),r()}catch(e){c(e.message)}finally{f(!1)}};return(0,Q.jsxs)(`div`,{className:`flex flex-col items-start gap-1.5`,children:[(0,Q.jsx)(`div`,{role:`group`,"aria-label":`Is this right?`,className:`flex gap-1.5`,children:[`right`,`wrong`].map(e=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":t===e,disabled:d,onClick:()=>void p(t===e?null:e,e===`wrong`&&i.trim()||void 0),className:C(`inline-flex min-h-8 cursor-pointer items-center gap-1 rounded-[8px] border px-3 text-[13px] font-medium disabled:cursor-not-allowed`,t===e?`border-accent bg-accent-soft text-ink`:`border-transparent bg-surface-strong text-ink-2 hover:bg-line hover:text-ink`),children:[e===`right`?(0,Q.jsx)(o,{size:14,"aria-hidden":`true`}):(0,Q.jsx)(u,{size:14,"aria-hidden":`true`}),e===`right`?`Right`:`Wrong`]},e))}),t===`wrong`&&(0,Q.jsxs)(`form`,{className:`flex w-full max-w-[420px] gap-1.5`,onSubmit:e=>{e.preventDefault(),p(`wrong`,i.trim()||void 0)},children:[(0,Q.jsx)(D,{"aria-label":`What is right instead`,placeholder:`What is right instead`,value:i,maxLength:500,onChange:e=>a(e.target.value),className:`flex-1`}),(0,Q.jsx)(l,{type:`submit`,size:`sm`,disabled:d,children:`Save`})]}),s&&(0,Q.jsx)(G,{text:s})]})}function $({icon:e,children:t}){return(0,Q.jsx)(k,{icon:e,children:t})}var Le=190,Re=46,ze=64,Be=(e,t)=>{let n=Math.max(6,Math.floor(t/6.6));return e.length<=n?e:`${e.slice(0,n-1)}…`};function Ve({j:e}){let t=[{id:`browser`,label:`Browser`,kind:`browser`}],n=(e,n,r)=>(t.some(t=>t.id===e)||t.push({id:e,label:n,kind:r}),t.findIndex(t=>t.id===e)),r=[];e.steps.forEach((e,t)=>{let i=n(`s:${e.service||`?`}`,e.service||`service`,`service`);r.push({from:0,to:i,label:e.endpoint||e.name,solid:e.known===`seen`,n:t+1});for(let t of e.effects)r.push({from:i,to:n(`${t.lane}:${t.target}`,t.target,t.lane===`service`?`service`:t.lane),label:t.kind,solid:t.known===`seen`})});let i=t.length*Le,a=ze+r.length*Re+24,o=e=>e*Le+Le/2,s=`${e.name}: ${e.steps.length} ${e.steps.length===1?`step`:`steps`} across ${t.slice(1).map(e=>e.label).join(`, `)}.`;return(0,Q.jsxs)(`div`,{className:`overflow-x-auto`,children:[(0,Q.jsxs)(`svg`,{role:`img`,"aria-label":s,width:i,height:a,viewBox:`0 0 ${i} ${a}`,className:`block`,children:[t.map((t,n)=>(0,Q.jsxs)(`g`,{children:[(0,Q.jsx)(`line`,{x1:o(n),y1:56,x2:o(n),y2:a-8,strokeDasharray:`3 4`,className:`stroke-line-strong`}),(0,Q.jsx)(`rect`,{x:o(n)-Le/2+8,y:6,width:174,height:40,rx:10,className:C(`stroke-line`,t.kind===`outside`?`fill-surface-muted`:`fill-bg`)}),(0,Q.jsx)(`text`,{x:o(n),y:24,textAnchor:`middle`,className:`fill-ink text-[13px] font-medium`,children:Be(t.label,162)}),(0,Q.jsx)(`text`,{x:o(n),y:39,textAnchor:`middle`,className:`fill-muted text-[11px]`,children:t.kind===`browser`?Be(e.steps[0]?.page||``,162):t.kind===`data`?`table`:t.kind===`message`?`message`:t.kind===`outside`?`outside`:`service`})]},t.id)),r.map((e,t)=>{let n=ze+t*Re+Re/2,r=Math.min(o(e.from),o(e.to)),i=Math.max(o(e.from),o(e.to)),a=o(e.to)>o(e.from)?1:-1,s=o(e.to)-a*4;return(0,Q.jsxs)(`g`,{children:[(0,Q.jsx)(`line`,{x1:o(e.from),y1:n,x2:s,y2:n,strokeWidth:e.solid?2:1.5,strokeDasharray:e.solid?void 0:`5 4`,className:e.solid?`stroke-pass`:`stroke-ink-2`}),(0,Q.jsx)(`path`,{d:`M ${s} ${n} l ${-a*7} -4 l 0 8 z`,className:e.solid?`fill-pass`:`fill-ink-2`}),(0,Q.jsxs)(`text`,{x:r+8,y:n-7,className:C(`text-[12px]`,e.n?`fill-ink`:`fill-muted`),children:[e.n?`${e.n} `:``,Be(e.label,i-r-16)]})]},t)})]}),(0,Q.jsx)(`ol`,{className:`sr-only`,children:e.steps.map((e,t)=>(0,Q.jsxs)(`li`,{children:[e.endpoint||e.name,` on `,e.service||`a service`,e.effects.length?`, which ${e.effects.map(e=>`${e.kind} ${e.target}`).join(`, `)}`:``,`. `,He(e.known),`.`]},t))})]})}var He=e=>({seen:`Seen in a run`,read:`From the code`,inferred:`Worked out`,differs:`A run differs`,confirmed:`Confirmed by a person`,rejected:`Marked wrong`})[e];function Ue({d:e}){let t=[...e.writtenBy.map(e=>({id:`w:${e}`,column:`writes`,title:e,known:`read`})),{id:e.id,column:`table`,title:e.name,detail:e.columns.length?e.columns.join(`, `):e.where,known:`read`,personal:e.personal.length>0},...e.readBy.map(e=>({id:`r:${e}`,column:`reads`,title:e,known:`read`})),...e.sentOn.map(e=>({id:`s:${e}`,column:`onward`,title:e,detail:`message`,known:`inferred`})),...e.leavesTo.map(e=>({id:`o:${e}`,column:`onward`,title:e,detail:`outside service`,known:`inferred`}))],n=[...e.writtenBy.map(t=>({from:`w:${t}`,to:e.id,known:`read`})),...e.readBy.map(t=>({from:e.id,to:`r:${t}`,known:`read`})),...e.sentOn.map(t=>({from:e.id,to:`s:${t}`,known:`inferred`})),...e.leavesTo.map(t=>({from:e.id,to:`o:${t}`,known:`inferred`}))];return(0,Q.jsx)(ue,{label:`What happens to the data of ${e.name}`,columns:[{id:`writes`,label:`Written by`,icon:L},{id:`table`,label:`Kept in`,icon:z},{id:`reads`,label:`Read by`,icon:L},{id:`onward`,label:`Sent on, and leaves to`,icon:E}],nodes:t,links:n})}var We=({known:e})=>e===`seen`?(0,Q.jsx)(o,{size:15,role:`img`,"aria-label":`Seen in a run`,className:`mt-0.5 flex-none text-pass`}):(0,Q.jsx)(d,{size:15,"aria-hidden":`true`,className:`mt-0.5 flex-none text-muted`});function Ge({items:e}){let t=e.filter(e=>e.value);return t.length?(0,Q.jsx)(`span`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-[13px] text-muted`,children:t.map(e=>(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(c,{icon:e.icon,size:14}),(0,Q.jsxs)(`span`,{children:[e.label,`: `,(0,Q.jsx)(`span`,{className:`text-ink-2`,children:e.value})]})]},e.label))}):null}function Ke({d:e}){let t=e.states.filter(e=>e.first),n=e.states.filter(e=>!e.first&&e.setBy.length),r=e.states.filter(e=>!e.first&&!e.setBy.length);if(!e.states.length)return(0,Q.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`The code names no state for it (a status the record moves through).`});let i=({s:e,dashed:t})=>(0,Q.jsx)(`span`,{className:C(`inline-flex min-h-9 items-center rounded-[10px] border px-3 text-[14px] font-medium`,t?`border-dashed border-muted text-ink-2`:`border-line bg-bg text-ink`),children:e});return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`ol`,{"aria-label":`The life of ${e.record.toLowerCase()}`,className:`m-0 flex list-none flex-wrap items-center gap-2 p-0`,children:[t.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[12px] text-muted`,children:`Starts`}),(0,Q.jsx)(i,{s:e.state})]},e.state)),n.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[12px] text-ink-2`,children:[(0,Q.jsx)(F,{size:14,"aria-hidden":`true`,className:`text-muted`}),e.setBy.join(`, `),(0,Q.jsx)(F,{size:14,"aria-hidden":`true`,className:`text-muted`})]}),(0,Q.jsx)(i,{s:e.state})]},e.state))]}),r.length>0&&(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-[13px] text-muted`,children:[`Also checked:`,r.map(e=>(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,Q.jsx)(i,{s:e.state,dashed:!0}),e.checkedBy.length>0&&(0,Q.jsxs)(`span`,{className:`text-ink-2`,children:[`(`,e.checkedBy.join(`; `),`)`]})]},e.state))]})]})}function qe({label:e,rows:t,current:n,name:r,icon:i,to:a}){return(0,Q.jsx)(`nav`,{"aria-label":e,className:`flex min-w-0 flex-col gap-1 @2xl:sticky @2xl:top-6 @2xl:w-[260px] @2xl:flex-none`,children:(0,Q.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:t.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`a`,{href:N(`product`,`business`,a,encodeURIComponent(e.id)),"aria-current":n===e.id?`page`:void 0,className:C(`flex min-h-11 items-center gap-2.5 rounded-[10px] px-3 py-1.5 text-ink no-underline`,n===e.id?`bg-surface-strong hover:text-ink`:`hover:bg-surface-muted hover:text-ink`),children:[i(e),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[14px] font-medium`,"data-tip":r(e),children:r(e)})]})},e.id))})})}function Je({view:e,tab:t,item:n,onChanged:r}){let[a,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(null),f=[{id:`capabilities`,label:`What it does`},{id:`journeys`,label:`Journeys (${e.journeys.length})`},{id:`rules`,label:`Rules (${e.rules.length})`},{id:`data`,label:`Records (${e.data.length})`},...e.terms.length?[{id:`glossary`,label:`Glossary (${e.terms.length})`}]:[],{id:`team`,label:e.team?`Team questions (${e.team.passed} of ${e.team.questions})`:`Team questions`}],p=e.journeys.find(e=>e.id===n)||e.journeys[0],m=e.data.find(e=>e.id===n)||e.data[0],h=(...e)=>location.hash=N(`product`,`business`,...e),g=new Map;for(let t of e.rules)g.set(t.capability||`Other`,[...g.get(t.capability||`Other`)||[],t]);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[!e.modelRead&&(0,Q.jsx)(`p`,{className:`m-0 max-w-[74ch] text-sm leading-relaxed text-ink-2`,children:`These words come from the code itself: the action from each request, the rule from the message the product answers with, the record from each table. Build the graph with the model to have capabilities, journeys and rules named and phrased by it, each citing what shows it.`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-x-6 @3xl:flex-row @3xl:items-end`,children:[(0,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(se,{label:`Product view`,current:t,onPick:e=>h(e),tabs:f})}),(0,Q.jsxs)(`span`,{className:`mb-5 flex items-center gap-2 text-sm text-ink-2`,children:[(0,Q.jsx)(R,{checked:a,onChange:l,label:`Show how it is built`}),`Show how it is built`]})]}),t===`capabilities`&&(0,Q.jsxs)(`div`,{role:`tabpanel`,id:`panel-capabilities`,"aria-labelledby":`tab-capabilities`,className:`flex flex-col gap-6`,children:[!e.capabilities.length&&(0,Q.jsx)($,{icon:b,children:`Nothing the product does was found yet: the product serves no request the patterns read. Build the graph with the model to find what it does from the code and documents.`}),(0,Q.jsx)(`ul`,{className:`m-0 grid list-none gap-4 p-0 @2xl:grid-cols-2`,children:e.capabilities.map(e=>(0,Q.jsxs)(`li`,{className:`flex flex-col gap-3 rounded-[14px] card border p-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,Q.jsxs)(`h3`,{className:`m-0 flex items-center gap-2 text-lg font-semibold`,children:[(0,Q.jsx)(c,{icon:b,size:18}),e.name]}),e.by===`model`&&(0,Q.jsx)(K,{known:e.known})]}),e.by===`model`&&(0,Q.jsx)(`p`,{className:`m-0 text-sm leading-relaxed text-ink-2 [overflow-wrap:anywhere]`,children:e.summary}),(0,Q.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1.5 p-0`,children:e.actions.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-start gap-2 text-[15px] text-ink`,children:[(0,Q.jsx)(We,{known:e.known}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[e.action,a&&(0,Q.jsx)(`span`,{className:`font-mono text-[12px] text-muted [overflow-wrap:anywhere]`,children:e.endpoint})]})]},e.endpoint))}),(0,Q.jsx)(Ge,{items:[{icon:z,label:`Keeps`,value:e.records.join(`, `)},{icon:i,label:`Shares with`,value:e.outside.join(`, `)},{icon:A,label:`Rules`,value:e.rules?String(e.rules):``},{icon:w,label:`Personal data`,value:e.personal?`yes`:``}]}),e.by===`model`&&(0,Q.jsx)(Ie,{id:e.id,verdict:e.verdict,note:e.note,onChanged:r})]},e.id))}),(0,Q.jsxs)(`p`,{className:`m-0 text-[12px] text-muted`,children:[(0,Q.jsx)(o,{size:12,"aria-hidden":`true`,className:`mr-1 inline align-[-1px] text-pass`}),`Seen in a run: ForgeQE's runs did it. The rest is read in the code.`]}),a&&e.map.nodes.length>0&&(0,Q.jsx)(W,{id:`capability-map`,title:`How it is built`,icon:L,children:(0,Q.jsx)(ue,{label:`Capability map`,columns:[{id:`capability`,label:`Capabilities`,icon:b},{id:`endpoint`,label:`Requests`,icon:L},{id:`rule`,label:`Rules it checks`,icon:A},{id:`data`,label:`Tables`,icon:z}],nodes:e.map.nodes,links:e.map.links,opens:e=>e.column===`data`||e.column===`rule`,onOpen:e=>e.column===`data`?h(`data`,encodeURIComponent(e.id)):h(`rules`)})})]}),t===`journeys`&&(0,Q.jsx)(`div`,{role:`tabpanel`,id:`panel-journeys`,"aria-labelledby":`tab-journeys`,children:p?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6 @2xl:flex-row @2xl:items-start @2xl:gap-8`,children:[(0,Q.jsx)(qe,{label:`Journeys`,rows:e.journeys,current:p.id,name:e=>e.name,to:`journeys`,icon:e=>e.known===`seen`?(0,Q.jsx)(o,{size:16,role:`img`,"aria-label":`Seen in a run`,className:`flex-none text-pass`}):(0,Q.jsx)(c,{icon:_,size:16,className:`flex-none`})}),(0,Q.jsxs)(`section`,{"aria-labelledby":`journey-h`,className:`flex min-w-0 flex-1 flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h2`,{id:`journey-h`,className:`m-0 text-[22px] font-semibold tracking-[-0.01em] [overflow-wrap:anywhere]`,children:p.name}),(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(ae,{tone:`neutral`,icon:!1,children:p.by===`run`?`Walked by a run`:`Named by the model`}),(0,Q.jsx)(K,{known:p.known})]})]}),(0,Q.jsxs)(`ol`,{"aria-label":`Steps`,className:`m-0 flex list-none flex-col gap-2 p-0 @3xl:flex-row @3xl:flex-wrap @3xl:items-stretch`,children:[p.steps[0]?.page&&(0,Q.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`span`,{className:`flex flex-col justify-center rounded-[14px] bg-surface-muted px-4 py-3 text-[13px] text-ink-2`,children:[`Starts on`,(0,Q.jsx)(`span`,{className:`font-mono text-[12px] text-muted`,children:p.steps[0].page})]}),(0,Q.jsx)(F,{size:18,"aria-hidden":`true`,className:`hidden flex-none text-muted @3xl:block`})]}),p.steps.map((e,t)=>(0,Q.jsxs)(`li`,{className:`flex items-stretch gap-2 @3xl:items-center`,children:[(0,Q.jsxs)(`div`,{className:`flex w-full flex-col gap-2 self-stretch rounded-[14px] card border p-4 @3xl:w-[220px]`,children:[(0,Q.jsxs)(`span`,{className:`flex items-start gap-2 text-[15px] font-semibold text-ink`,children:[(0,Q.jsx)(`span`,{className:`flex size-6 flex-none items-center justify-center rounded-full bg-surface-strong text-[12px] tabular-nums`,children:t+1}),e.action]}),e.outcomes.map(e=>(0,Q.jsxs)(`span`,{className:`flex items-start gap-1.5 text-[13px] text-ink-2`,children:[(0,Q.jsx)(s,{size:13,"aria-hidden":`true`,className:`mt-0.5 flex-none text-muted`}),e]},e)),e.guards.length>0&&(0,Q.jsxs)(`span`,{className:`flex items-start gap-1.5 rounded-[10px] bg-surface-muted px-2.5 py-1.5 text-[12px] text-ink-2`,children:[(0,Q.jsx)(c,{icon:A,size:13,className:`mt-0.5 flex-none`}),`Not allowed when: `,e.guards.join(`; `)]}),(0,Q.jsxs)(`span`,{className:`mt-auto flex items-center gap-1.5 text-[12px] text-muted`,children:[(0,Q.jsx)(We,{known:e.known}),e.known===`seen`?`Seen in a run`:He(e.known)]}),a&&e.endpoint&&(0,Q.jsxs)(`span`,{className:`font-mono text-[12px] text-muted [overflow-wrap:anywhere]`,children:[e.endpoint,` · `,e.service]})]}),t<p.steps.length-1&&(0,Q.jsx)(F,{size:18,"aria-hidden":`true`,className:`hidden flex-none text-muted @3xl:block`})]},t))]}),(0,Q.jsx)(Ie,{id:p.id,verdict:p.verdict,note:p.note,onChanged:r}),a&&(0,Q.jsxs)(W,{id:`journey-built`,title:`How it is built`,icon:L,children:[(0,Q.jsx)(Ve,{j:p}),(0,Q.jsx)(`p`,{className:`m-0 text-[12px] text-muted`,children:`Numbered arrows: the requests the browser made, in order; under each, what that request's code does. Solid green: seen in a run; dashed: from the code. A call made through a helper in another file is not drawn.`})]})]})]}):(0,Q.jsx)($,{icon:_,children:`No journey yet. Each browser run of ForgeQE becomes one here once the graph is built again; the model names more from the code.`})}),t===`rules`&&(0,Q.jsxs)(`div`,{role:`tabpanel`,id:`panel-rules`,"aria-labelledby":`tab-rules`,className:`flex flex-col gap-6`,children:[!e.rules.length&&(0,Q.jsx)($,{icon:A,children:`No rule was found yet: nothing in the code refuses a request with a reason. Rules show here once one is read.`}),[...g].map(([e,t],n)=>(0,Q.jsx)(W,{id:`rules-${n}`,title:e,icon:b,n:t.length,children:(0,Q.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:t.map(e=>(0,Q.jsxs)(`li`,{className:`flex flex-col gap-2 border-b border-line-soft py-3 last:border-b-0`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-4 gap-y-2`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_380px] items-start gap-2 text-[15px] font-medium text-ink [overflow-wrap:anywhere]`,children:[(0,Q.jsx)(c,{icon:A,size:16,className:`mt-0.5 flex-none`}),e.plain]}),(0,Q.jsx)(K,{known:e.known})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col items-start gap-1 pl-6`,children:[!a&&(0,Q.jsx)(`button`,{type:`button`,"aria-expanded":u===e.id,onClick:()=>d(u===e.id?null:e.id),className:`inline-flex min-h-11 cursor-pointer items-center border-0 bg-transparent p-0 text-[12px] text-accent-fg hover:text-accent-fg-hover`,children:u===e.id?`Hide how it is checked`:`Show how it is checked`}),(0,Q.jsx)(Ie,{id:e.id,verdict:e.verdict,note:e.note,onChanged:r})]}),(0,Q.jsx)(v,{open:a||u===e.id,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 pb-1 pl-6`,children:[e.quote&&(0,Q.jsx)(`code`,{className:`font-mono text-[12px] text-ink-2 [overflow-wrap:anywhere]`,children:e.quote}),(0,Q.jsxs)(`span`,{className:`font-mono text-[12px] text-muted [overflow-wrap:anywhere]`,children:[e.endpoint?`${e.endpoint} · `:``,e.where]})]})})]},e.id))})},e))]}),t===`data`&&(0,Q.jsx)(`div`,{role:`tabpanel`,id:`panel-data`,"aria-labelledby":`tab-data`,children:m?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6 @2xl:flex-row @2xl:items-start @2xl:gap-8`,children:[(0,Q.jsx)(qe,{label:`Records`,rows:e.data,current:m.id,name:e=>e.record,to:`data`,icon:e=>e.personal.length?(0,Q.jsx)(c,{icon:w,size:16,label:`Holds personal data`,className:`flex-none`}):(0,Q.jsx)(y,{size:16,"aria-hidden":`true`,className:`flex-none text-muted`})}),(0,Q.jsxs)(`section`,{"aria-labelledby":`table-h`,className:`flex min-w-0 flex-1 flex-col gap-4`,children:[(0,Q.jsx)(`h2`,{id:`table-h`,className:`m-0 text-[22px] font-semibold tracking-[-0.01em] [overflow-wrap:anywhere]`,children:m.record}),(0,Q.jsx)(W,{id:`life`,title:`Its life`,icon:_,children:(0,Q.jsx)(Ke,{d:m})}),(0,Q.jsx)(Ge,{items:[{icon:L,label:`Changed by`,value:m.keptBy.join(`, `)},{icon:E,label:`Announced as`,value:m.sentOn.map(e=>e.replace(/^Announces /,``)).join(`, `)},{icon:i,label:`Shared with`,value:m.leavesTo.join(`, `)},{icon:w,label:`Personal data`,value:m.personal.join(`, `)}]}),a&&(0,Q.jsxs)(W,{id:`record-built`,title:`How it is built`,icon:L,children:[(0,Q.jsxs)(`span`,{className:`font-mono text-[12px] text-muted`,children:[`table `,m.name,` · `,m.where,m.columns.length?` · ${m.columns.join(`, `)}`:``]}),(0,Q.jsx)(Ue,{d:m})]})]})]}):(0,Q.jsx)($,{icon:z,children:`No record yet: no migration or model of the repositories defines a table. Records show here once a schema is read.`})}),t===`glossary`&&(0,Q.jsx)(`div`,{role:`tabpanel`,id:`panel-glossary`,"aria-labelledby":`tab-glossary`,children:(0,Q.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:e.terms.map(e=>(0,Q.jsxs)(`li`,{className:`flex flex-wrap items-start gap-x-4 gap-y-2 border-b border-line-soft py-3 last:border-b-0`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_380px] flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-2 text-[14px] font-medium`,children:[(0,Q.jsx)(c,{icon:M,size:15}),e.term]}),(0,Q.jsx)(`span`,{className:`text-[13px] text-ink-2 [overflow-wrap:anywhere]`,children:e.meaning})]}),(0,Q.jsx)(Ie,{id:e.id,verdict:e.verdict,note:e.note,onChanged:r})]},e.id))})}),t===`team`&&(0,Q.jsx)(`div`,{role:`tabpanel`,id:`panel-team`,"aria-labelledby":`tab-team`,className:`flex flex-col gap-3`,children:e.team?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`m-0 text-sm text-ink-2`,children:[e.team.passed,` of `,e.team.questions,` answered right, `,e.team.grounded,` with every quote found in its file`,e.team.model?`, by ${e.team.model}`:``,`, `,oe(e.team.at),`.`]}),(0,Q.jsx)(W,{id:`team-scores`,title:`Questions`,icon:x,n:e.team.scores.length,children:(0,Q.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:e.team.scores.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-start gap-2 border-b border-line-soft py-3 last:border-b-0`,children:[e.pass?(0,Q.jsx)(o,{size:16,role:`img`,"aria-label":`Answered right`,className:`mt-0.5 flex-none text-pass`}):(0,Q.jsx)(S,{size:16,role:`img`,"aria-label":`Not answered right`,className:`mt-0.5 flex-none text-warn`}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsx)(`span`,{className:`text-[14px] font-medium [overflow-wrap:anywhere]`,children:e.question}),!e.pass&&(0,Q.jsx)(`span`,{className:`text-[13px] text-muted [overflow-wrap:anywhere]`,children:e.why.join(`; `)})]})]},e.id))})})]}):(0,Q.jsx)($,{icon:x,children:`No team questions yet. Write questions whose answers your team knows (evals/knowledge/shop/questions.yaml shows how), then run forgeqe knowledge eval with the file: each answer is scored, and the last result shows here.`})})]})}var Ye=e=>/^https:\/\/[^/\s]/i.test(e)&&!/[\u0000-\u0020\u007f-\u009f]/.test(e);function Xe({id:e,onClose:t}){let[n,r]=(0,q.useState)(null),[i,o]=(0,q.useState)(``);return(0,q.useEffect)(()=>{if(!e)return;let t=!1;return r(null),o(``),te.part(e).then(e=>!t&&r(e),e=>!t&&o(e.message)),()=>{t=!0}},[e]),(0,Q.jsxs)(a,{open:!!e,onClose:t,title:n?.part.name||`Part`,description:n?.part.where,footer:(0,Q.jsx)(l,{onClick:t,children:`Close`}),wide:!0,children:[i&&(0,Q.jsx)(G,{text:i}),!n&&!i&&(0,Q.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),n&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[n.part.summary&&(0,Q.jsx)(`p`,{className:`m-0 text-sm leading-relaxed text-ink-2 [overflow-wrap:anywhere]`,children:n.part.summary}),(0,Q.jsxs)(`section`,{"aria-labelledby":`evidence-h`,className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h3`,{id:`evidence-h`,className:`m-0 text-base font-semibold`,children:`How it is known`}),n.part.evidence?.length?(0,Q.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:n.part.evidence.map((e,t)=>(0,Q.jsx)(`li`,{className:`border-b border-line-soft py-2 font-mono text-[12.5px] leading-relaxed text-ink-2 [overflow-wrap:anywhere] last:border-b-0`,children:e},t))}):(0,Q.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`No evidence kept for it: build the graph again.`}),n.links?.some(e=>Ye(e.url))&&(0,Q.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:n.links.filter(e=>Ye(e.url)).map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 text-[13px] [overflow-wrap:anywhere]`,children:[(0,Q.jsx)(m,{size:13,"aria-hidden":`true`,className:`flex-none`}),e.label]})},e.url))})]}),n.groups.map(e=>(0,Q.jsxs)(`section`,{"aria-label":e.label,className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`h3`,{className:`m-0 text-sm font-semibold`,children:[e.label,` (`,e.rows.length+e.more,`)`]}),(0,Q.jsxs)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:[e.rows.map(e=>(0,Q.jsxs)(`li`,{className:`flex flex-col py-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[14px] font-medium [overflow-wrap:anywhere]`,children:e.name}),(0,Q.jsx)(`span`,{className:`font-mono text-[12px] text-muted [overflow-wrap:anywhere]`,children:e.where})]},e.id)),e.more>0&&(0,Q.jsxs)(`li`,{className:`py-1 text-[12px] text-muted`,children:[`… and `,e.more,` more`]})]})]},e.label))]})]})}function Ze({view:e}){let t=t=>e.nodes.find(e=>e.id===t)?.name||t;if(!e.links.length)return(0,Q.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`No link between the parts was found.`});let n=[`differs`,`seen`,`read`,`inferred`];return(0,Q.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:[...e.links].sort((e,t)=>n.indexOf(e.known)-n.indexOf(t.known)).map((e,n)=>(0,Q.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-b border-line-soft py-2.5 last:border-b-0`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 flex-[1_1_320px] text-[14px] [overflow-wrap:anywhere]`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:t(e.from)}),` `,(0,Q.jsx)(`span`,{className:`text-muted`,children:e.label}),` `,(0,Q.jsx)(`span`,{className:`font-medium`,children:t(e.to)}),e.count>1&&(0,Q.jsxs)(`span`,{className:`text-muted`,children:[` · `,e.count,` places in the code`]}),e.example&&(0,Q.jsx)(`span`,{className:`block text-[12px] text-muted`,children:e.example})]}),(0,Q.jsx)(K,{known:e.known})]},n))})}function Qe({id:e}){let[t,n]=(0,q.useState)(null),[r,i]=(0,q.useState)(``);return(0,q.useEffect)(()=>{let t=!1;return B.impact(e).then(e=>!t&&n(e),e=>!t&&i(e.message)),()=>{t=!0}},[e]),r?(0,Q.jsx)(G,{text:r}):t?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 py-2 pl-3 text-[13px]`,children:[(0,Q.jsxs)(`span`,{className:`text-muted`,children:[t.reached.length?`A change here reaches ${t.reached.length} ${t.reached.length===1?`part`:`parts`}`:`Nothing else depends on it in the graph`,t.tests.length?`; ${t.tests.length} ${t.tests.length===1?`test covers`:`tests cover`} them.`:`; no test covers it.`]}),t.reached.length>0&&(0,Q.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:t.reached.slice(0,15).map(e=>(0,Q.jsxs)(`li`,{className:`py-0.5 [overflow-wrap:anywhere]`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.name}),` `,(0,Q.jsxs)(`span`,{className:`text-muted`,children:[`(`,e.type,`, `,(0,Q.jsx)(`span`,{className:`font-mono`,children:e.where}),`)`]})]},e.id))}),t.tests.length>0&&(0,Q.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:t.tests.slice(0,10).map(e=>(0,Q.jsxs)(`li`,{className:`py-0.5 text-muted [overflow-wrap:anywhere]`,children:[`Test: `,e.name,` (`,(0,Q.jsx)(`span`,{className:`font-mono`,children:e.where}),`)`]},e.id))})]}):(0,Q.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})}function $e({p:e,extra:t,onEvidence:n,children:r}){return(0,Q.jsxs)(`li`,{className:`border-b border-line-soft py-2.5 last:border-b-0`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_320px] flex-col`,children:[(0,Q.jsxs)(`span`,{className:`text-[14px] font-medium [overflow-wrap:anywhere]`,children:[e.name,t]}),(0,Q.jsxs)(`span`,{className:`text-[12px] text-muted [overflow-wrap:anywhere]`,children:[e.note,e.note&&e.where?` · `:``,e.where&&(0,Q.jsx)(`span`,{className:`font-mono`,children:e.where})]})]}),(0,Q.jsx)(K,{known:e.known}),(0,Q.jsxs)(l,{size:`sm`,variant:`ghost`,onClick:()=>n(e.id),children:[(0,Q.jsx)(V,{"aria-hidden":`true`}),`Evidence`]})]}),r]})}function et({gaps:e,onError:t}){return(0,Q.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:e.map((e,n)=>(0,Q.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-b border-line-soft py-2.5 last:border-b-0`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_360px] flex-col`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[14px] font-medium [overflow-wrap:anywhere]`,children:[(0,Q.jsx)(S,{size:14,"aria-hidden":`true`,className:`flex-none text-warn`}),e.what]}),(0,Q.jsxs)(`span`,{className:`text-[12px] text-muted [overflow-wrap:anywhere]`,children:[(0,Q.jsx)(`span`,{className:`font-mono`,children:e.where}),e.quote?` · ${e.quote}`:``]}),(0,Q.jsx)(`span`,{className:`text-[13px] text-ink-2 [overflow-wrap:anywhere]`,children:e.next})]}),(0,Q.jsxs)(l,{size:`sm`,variant:`ghost`,onClick:()=>void le(e.what,`${e.where}. ${e.next}`,t),children:[(0,Q.jsx)(p,{"aria-hidden":`true`}),`Investigate`]})]},n))})}function tt({repo:e,onEvidence:n}){let[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(``),[s,c]=(0,q.useState)(null),[u,d]=(0,q.useState)(``);return(0,q.useEffect)(()=>{let t=!1;return i(null),o(``),B.service(e).then(e=>!t&&i(e),e=>!t&&o(e.message)),()=>{t=!0}},[e]),a?(0,Q.jsx)(G,{text:a}):r?(0,Q.jsxs)(`section`,{"aria-labelledby":`service-h`,className:`flex min-w-0 flex-col gap-6`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`a`,{href:N(`product`,`services`),className:`inline-flex items-center gap-1.5 self-start text-sm`,children:[(0,Q.jsx)(ie,{size:16,"aria-hidden":`true`}),`All services`]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,Q.jsx)(`h2`,{id:`service-h`,className:`m-0 flex-[1_1_260px] text-[22px] font-semibold tracking-[-0.01em] [overflow-wrap:anywhere]`,children:r.repo}),(0,Q.jsxs)(l,{size:`sm`,variant:`ghost`,onClick:()=>void le(`How does ${r.repo} work, and what does it depend on?`,r.summary,d),children:[(0,Q.jsx)(t,{"aria-hidden":`true`}),`Ask in a chat`]})]}),(0,Q.jsx)(`p`,{className:`m-0 max-w-[74ch] text-sm leading-relaxed text-ink-2 [overflow-wrap:anywhere]`,children:r.summary}),(0,Q.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[r.counts.files,` files, `,r.counts.classes,` classes, `,r.counts.tests,` test files`,r.deployedAs.length?` · deployed as ${r.deployedAs.join(`; `)}`:``]}),u&&(0,Q.jsx)(G,{text:u})]}),(0,Q.jsx)(W,{id:`endpoints`,title:`Endpoints`,icon:ne,n:r.endpoints.length,children:r.endpoints.length?(0,Q.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:r.endpoints.map(e=>(0,Q.jsxs)($e,{p:e,onEvidence:n,extra:e.auth?(0,Q.jsxs)(`span`,{className:`font-normal text-muted`,children:[` · requires `,e.auth]}):null,children:[e.differs&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-[12px] text-warn`,children:[(0,Q.jsx)(S,{size:12,"aria-hidden":`true`}),`A run called a route near it: Runs against the code.`]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 text-[12px] text-muted`,children:[(0,Q.jsx)(`span`,{children:e.callers.length?`Called by ${e.callers.join(`, `)}`:`No caller found in the other repositories`}),(0,Q.jsx)(`button`,{type:`button`,"aria-expanded":s===e.id,onClick:()=>c(s===e.id?null:e.id),className:`inline-flex min-h-11 cursor-pointer items-center border-0 bg-transparent p-0 text-[12px] text-accent-fg hover:text-accent-fg-hover`,children:s===e.id?`Hide what a change reaches`:`What a change reaches`})]}),(0,Q.jsx)(v,{open:s===e.id,children:s===e.id&&(0,Q.jsx)(Qe,{id:e.id})})]},e.id))}):(0,Q.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`It serves no endpoint the patterns read.`})}),[{id:`calls`,title:`Calls out`,icon:re,rows:r.calls.map(e=>({p:e,extra:(0,Q.jsxs)(`span`,{className:`font-normal text-muted`,children:[` · `,e.to]})}))},{id:`data`,title:`Data`,icon:z,rows:r.data.map(e=>({p:e,extra:(0,Q.jsxs)(`span`,{className:`font-normal text-muted`,children:[` · `,e.use]})}))},{id:`messages`,title:`Messages`,icon:E,rows:r.messages.map(e=>({p:e,extra:(0,Q.jsxs)(`span`,{className:`font-normal text-muted`,children:[` · `,e.use]})}))},{id:`outside`,title:`Outside services`,icon:O,rows:r.outside.map(e=>({p:e,extra:null}))},{id:`cloud`,title:`Cloud resources`,icon:j,rows:r.cloud.map(e=>({p:e,extra:null}))}].filter(e=>e.rows.length).map(e=>(0,Q.jsx)(W,{id:e.id,title:e.title,icon:e.icon,n:e.rows.length,children:(0,Q.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:e.rows.map((e,t)=>(0,Q.jsx)($e,{p:e.p,extra:e.extra,onEvidence:n},`${e.p.id}-${t}`))})},e.id)),r.gaps.length>0&&(0,Q.jsx)(W,{id:`service-gaps`,title:`Open questions`,icon:S,n:r.gaps.length,children:(0,Q.jsx)(et,{gaps:r.gaps,onError:d})})]}):(0,Q.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})}function nt({view:e,onEvidence:t,onError:i}){let a=e.runtime;return a?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsxs)(`p`,{className:`m-0 text-sm text-ink-2`,children:[a.runs,` runs made `,a.calls,` API calls; `,a.matched,` reached a route the code declares. `,a.seen,` of `,a.endpoints,` endpoints were seen in a run.`]}),(0,Q.jsx)(W,{id:`differs`,title:`Differ from the code`,icon:S,n:a.differs.length,children:a.differs.length?(0,Q.jsx)(et,{gaps:a.differs,onError:i}):(0,Q.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`No call differs from the code.`})}),(0,Q.jsx)(W,{id:`only`,title:`Only the runs show`,icon:V,n:a.only.length,children:a.only.length?(0,Q.jsx)(et,{gaps:a.only,onError:i}):(0,Q.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Every call reached a route the code declares.`})}),(0,Q.jsx)(W,{id:`unseen`,title:`Never seen in a run`,icon:r,n:a.endpoints-a.seen,children:(0,Q.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:a.notSeen.map(e=>(0,Q.jsx)($e,{p:{...e,known:`read`,note:``},onEvidence:t},e.id))})})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col items-start gap-3 border-t border-line pt-6`,children:[(0,Q.jsx)(c,{icon:n,size:22,className:`text-muted`}),(0,Q.jsx)(`p`,{className:`m-0 max-w-[62ch] leading-relaxed text-ink-2`,children:`No run of ForgeQE has recorded API calls yet. Every browser run records them; after a run, build the product graph again and what the runs did shows here against the code.`})]})}function rt({sub:e}){let[t,n]=(0,q.useState)(null),[r,i]=(0,q.useState)(``),[a,o]=(0,q.useState)(``),[s,c]=(0,q.useState)(null),l=(e||``).split(`/`),u=l[0]===`business`,[d,f]=(0,q.useState)(null),p=(0,q.useCallback)(()=>{h.view().then(f,e=>i(e.message))},[]);(0,q.useEffect)(()=>{u&&!d&&p()},[u,d,p]);let m=[`capabilities`,`journeys`,`rules`,`data`,`glossary`,`team`].find(e=>e===l[1]&&(e!==`glossary`||!!d?.terms.length))||`capabilities`,g=[`links`,`runtime`,`questions`].find(e=>e===l[0])||(l[0]===`services`?`services`:`landscape`),_=l[0]===`services`&&l[1]?decodeURIComponent(l[1]):``,v=l[0]===`systems`&&l[1]?decodeURIComponent(l[1]):``,y=!u&&(g===`landscape`||g===`services`&&!_);(0,q.useEffect)(()=>{B.view().then(e=>{n(e),i(``)},e=>i(e.message))},[]);let b=e=>{e.repo&&e.column!==`data`?location.hash=N(`product`,`services`,encodeURIComponent(e.repo)):e.part&&c(e.part)};return(0,Q.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,Q.jsx)(P,{}),(0,Q.jsxs)(`main`,{className:C(U,`@container flex-auto gap-4`,y&&t?.built&&`max-w-none`),children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Q.jsx)(H,{pixel:ee.product,size:`lg`}),(0,Q.jsx)(`h1`,{className:`m-0 flex-1 text-[26px] font-semibold tracking-[-0.01em]`,children:`Product`})]}),(0,Q.jsxs)(`p`,{className:`m-0 max-w-[74ch] text-sm leading-relaxed text-ink-2`,children:[`How `,t?.product||`the product`,` is built and how it works for the business, read from its repositories, documents and ForgeQE's runs. Each part says how it is known, and you can mark what the business view says right or wrong.`]}),r&&(0,Q.jsx)(G,{text:r}),a&&(0,Q.jsx)(G,{text:a}),!t&&!r&&(0,Q.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),t&&!t.built&&(0,Q.jsx)(k,{icon:ne,title:`The product graph is not built yet`,children:`Add the product's repositories under Settings, Evidence, then run forgeqe knowledge build, or ask in a chat to build it.`}),t?.built&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{role:`radiogroup`,"aria-label":`View`,className:`flex gap-1 self-start rounded-[10px] bg-surface-strong p-1`,children:[[`engineering`,`Engineering`,N(`product`)],[`business`,`Product`,N(`product`,`business`)]].map(([e,t,n])=>(0,Q.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e===`business`===u,onClick:()=>location.hash=n,className:C(`inline-flex min-h-8 cursor-pointer items-center gap-1.5 rounded-[7px] border-0 px-3 text-sm font-medium`,e===`business`===u?`bg-bg text-ink shadow-sm`:`bg-transparent text-muted hover:text-ink`),children:t},e))}),u&&!d&&!r&&(0,Q.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),u&&d&&(0,Q.jsx)(Je,{view:d,tab:m,item:l[2]?decodeURIComponent(l[2]):void 0,onChanged:p}),!u&&t.summary.length>0&&(0,Q.jsx)(`p`,{className:`m-0 text-sm text-ink-2`,children:t.summary.join(` `)}),!u&&(0,Q.jsx)(se,{label:`Product`,current:g,onPick:e=>location.hash=e===`landscape`?N(`product`):N(`product`,e),tabs:[{id:`landscape`,label:`Landscape`},{id:`services`,label:`Services`},{id:`links`,label:`How they talk (${t.links.length})`},{id:`runtime`,label:`Runs against the code`},{id:`questions`,label:`Open questions (${t.gapsTotal})`}]}),!u&&g===`services`&&(0,Q.jsx)(`div`,{role:`tabpanel`,id:`panel-services`,"aria-labelledby":`tab-services`,className:`flex flex-col gap-8`,children:_?(0,Q.jsx)(tt,{repo:_,onEvidence:c}):(0,Q.jsxs)(`section`,{"aria-labelledby":`map-h`,className:`flex flex-col gap-3`,children:[(0,Q.jsx)(`h2`,{id:`map-h`,className:`sr-only`,children:`Services map`}),(0,Q.jsx)(Ee,{view:t,onOpen:b})]})}),!u&&g===`landscape`&&(0,Q.jsx)(`div`,{role:`tabpanel`,id:`panel-landscape`,"aria-labelledby":`tab-landscape`,children:v?(0,Q.jsx)(Fe,{eng:t,name:v,onOpen:b}):(0,Q.jsx)(Me,{onPart:c})}),!u&&g===`links`&&(0,Q.jsxs)(`div`,{role:`tabpanel`,id:`panel-links`,"aria-labelledby":`tab-links`,className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`p`,{className:`m-0 max-w-[74ch] text-sm text-muted`,children:`Every link between the parts, how often it is in the code, and how it is known: the map's wires in words.`}),(0,Q.jsx)(Ze,{view:t})]}),!u&&g===`runtime`&&(0,Q.jsx)(`div`,{role:`tabpanel`,id:`panel-runtime`,"aria-labelledby":`tab-runtime`,children:(0,Q.jsx)(nt,{view:t,onEvidence:c,onError:o})}),!u&&g===`questions`&&(0,Q.jsxs)(`div`,{role:`tabpanel`,id:`panel-questions`,"aria-labelledby":`tab-questions`,className:`flex flex-col gap-3`,children:[(0,Q.jsx)(`p`,{className:`m-0 max-w-[74ch] text-sm text-muted`,children:`What the build could not settle. Investigate one: ForgeQE's agent asks the investigator in a chat, which reads the code, documents and runs and answers with the lines it rests on.`}),t.gaps.length?(0,Q.jsx)(et,{gaps:t.gaps,onError:o}):(0,Q.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`No open question.`}),t.gapsTotal>t.gaps.length&&(0,Q.jsxs)(`p`,{className:`m-0 text-[12px] text-muted`,children:[`… and `,t.gapsTotal-t.gaps.length,` more: forgeqe knowledge gaps.`]})]})]})]}),(0,Q.jsx)(Xe,{id:s,onClose:()=>c(null)})]})}export{rt as Product};
@@ -0,0 +1 @@
1
+ import{$a as e,$r as t,En as n,J as r,Jt as i,Kt as a,Lr as o,Mn as s,Qt as c,Sr as l,Xi as u,Xt as d,Za as f,ba as p,bn as m,dt as h,ft as g,mt as _,n as v,no as y,tt as b,wt as x,za as S}from"./Shell-DGv_Zqjs.js";import{r as C,t as w}from"./index-DI1ST-gI.js";import{t as T}from"./when-CHnpLdYw.js";import{n as E,r as D}from"./segmented-1nc3D7ML.js";import{d as O,f as k,g as A,l as j,o as M,p as N,s as P,t as F}from"./qualityParts-Df8rJX4J.js";var I=y(e(),1),L=f();function R({id:e,view:n,onChanged:r}){let[s,u]=(0,I.useState)(null),[f,h]=(0,I.useState)(``),[g,v]=(0,I.useState)(`accessibility`),[y,b]=(0,I.useState)(``);(0,I.useEffect)(()=>{let t=!1;return u(null),S.run(e).then(e=>{if(t)return;u(e),h(``);let n=e.visual?.pages.some(e=>e.status===`changed`)||!e.visual&&e.captured;v(e.report?.accessibility.failed.length?`accessibility`:e.report?.breaches.some(e=>e.kind===`performance`)?`performance`:n?`visual`:e.report?.accessibility.pages?`accessibility`:e.report?.performance.pages.length?`performance`:`visual`)},e=>!t&&h(e.message)),()=>{t=!0}},[e]);let x=(0,L.jsxs)(`a`,{href:_(`quality`),className:`inline-flex items-center gap-1 self-start text-[13px] no-underline`,children:[(0,L.jsx)(m,{size:14,"aria-hidden":`true`,className:`rotate-90`}),`All runs`]});if(f)return(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[x,(0,L.jsx)(`p`,{className:`m-0 rounded-[10px] bg-fail-soft px-3 py-2 text-[13px] text-fail`,children:f})]});if(!s)return(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[x,(0,L.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`Loading…`})]});let w=async()=>{try{let{id:e}=await p.start(`Explain the accessibility, performance and visual results of the run in ${s.dir}: call quality_report and visual_compare with run_dir ${s.dir}. Say what matters most to fix first, and why.`,{});location.hash=_(`chats`,e)}catch(e){b(e.message)}},T=s.report,j=T?.accessibility,N=T?.performance.pages??[],R=N.filter(e=>e.over.length).length,z=N.map(e=>e.lcp).filter(e=>typeof e==`number`),B=z.length?Math.max(...z):void 0,V=s.visual?.pages.filter(e=>e.status===`changed`).length??0,H=T?.breaches.length??0,U=[{id:`accessibility`,label:`Accessibility`,icon:c,n:j?.pages?`${j.failed.length} failed`:`not measured`,tone:j?.failed.length?`text-fail`:void 0},{id:`performance`,label:`Performance`,icon:l,n:N.length?R?`${R} over budget`:`${N.length} pages`:`not measured`,tone:R?`text-fail`:void 0},{id:`visual`,label:`Visual`,icon:o,n:s.visual?`${V} changed`:s.captured?`not compared`:`not captured`,tone:V?`text-warn`:void 0}];return(0,L.jsxs)(`section`,{"aria-labelledby":`run-h`,className:`flex min-w-0 flex-col gap-3`,children:[x,(0,L.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-[1_1_300px] flex-col gap-0.5`,children:[(0,L.jsx)(`h2`,{id:`run-h`,"data-tip":s.goal,className:`m-0 truncate text-[16px] leading-snug font-semibold`,children:s.goal}),(0,L.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 text-[12.5px] text-muted`,children:[A(s.at),` · `,n.standard,` · `,(0,L.jsx)(C,{path:s.dir})]})]}),(0,L.jsxs)(a,{size:`sm`,variant:`ghost`,onClick:()=>void w(),children:[(0,L.jsx)(t,{"aria-hidden":`true`}),`Ask in a chat`]})]}),y&&(0,L.jsx)(`p`,{className:`m-0 text-[13px] text-fail`,children:y}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 overflow-hidden border-y border-line-soft @xl:grid-cols-4 @4xl:grid-cols-8 @4xl:divide-x @4xl:divide-line-soft`,children:[(0,L.jsx)(M,{label:`Budgets exceeded`,value:H,tone:H?`text-fail`:`text-pass`,sub:H?`fails the run`:`within budgets`}),(0,L.jsx)(M,{label:`Rules failed`,value:j?.pages?j.failed.length:`–`,tone:j?.failed.length?`text-fail`:void 0,sub:j?.pages?`${j.passed.length} passed`:`not measured`}),(0,L.jsx)(M,{label:`Critical · serious`,value:j?.pages?`${j.byImpact.critical} · ${j.byImpact.serious}`:`–`,tone:j&&j.byImpact.critical+j.byImpact.serious?`text-fail`:void 0,sub:`violations`}),(0,L.jsx)(M,{label:`Moderate · minor`,value:j?.pages?`${j.byImpact.moderate} · ${j.byImpact.minor}`:`–`,sub:`violations`}),(0,L.jsx)(M,{label:`Pages timed`,value:N.length||`–`,sub:R?`${R} over budget`:`none over budget`,tone:R?`text-fail`:void 0}),(0,L.jsx)(M,{label:`Slowest LCP`,value:B===void 0?`–`:k(B,`ms`),tone:B===void 0?void 0:B>4e3?`text-fail`:B>2500?`text-warn`:`text-pass`,sub:`good up to 2.5s`}),(0,L.jsx)(M,{label:`Pages compared`,value:s.visual?s.visual.pages.length:s.captured?`${s.captured} captured`:`–`,sub:s.visual?`against baselines`:`not compared`}),(0,L.jsx)(M,{label:`Visual changes`,value:s.visual?V:`–`,tone:V?`text-warn`:void 0,sub:s.visual?.pages.some(e=>e.over)?`over budget`:`pages changed`})]}),(0,L.jsx)(`div`,{role:`tablist`,"aria-label":`Results`,className:E,children:U.map(e=>(0,L.jsxs)(`button`,{type:`button`,role:`tab`,id:`tab-${e.id}`,"aria-selected":g===e.id,"aria-controls":`panel-${e.id}`,onClick:()=>v(e.id),className:D(g===e.id),children:[(0,L.jsx)(i,{icon:e.icon,size:14}),e.label,(0,L.jsx)(`span`,{className:d(`font-normal`,e.tone||`text-muted`),children:e.n})]},e.id))}),(0,L.jsxs)(`div`,{role:`tabpanel`,id:`panel-${g}`,"aria-labelledby":`tab-${g}`,className:`flex min-w-0 flex-col`,children:[g===`accessibility`&&(0,L.jsx)(F,{run:s,standard:n.standard,disclaimer:n.disclaimer}),g===`performance`&&(0,L.jsx)(P,{run:s}),g===`visual`&&(0,L.jsx)(O,{run:s,budget:n.budgets.visual,onChange:e=>{u(e),r()}})]})]})}function z({runs:e}){let[t,i]=(0,I.useState)(`all`),a=e,o=t===`attention`?a.filter(N):a,c=e=>location.hash=_(`quality`,encodeURIComponent(e)),l=`py-2 pr-3 text-right tabular-nums`;return(0,L.jsx)(`div`,{className:`flex flex-col gap-2`,children:(0,L.jsx)(r,{label:`Runs`,placeholder:`Find a run by what it did`,resetKey:t,empty:`Nothing matches.`,tools:(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:(0,L.jsx)(b,{items:[{id:`all`,label:`All`,n:a.length},{id:`attention`,label:`Needs a look`,n:a.filter(N).length,alert:!0}],value:t,onChange:i})}),head:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`th`,{className:`w-[46%] py-1.5 pr-3 pl-3 font-medium`,children:`Run`}),(0,L.jsx)(`th`,{className:`py-1.5 pr-3 text-right font-medium`,children:`Rules failed`}),(0,L.jsx)(`th`,{className:`hidden py-1.5 pr-3 text-right font-medium @2xl:table-cell`,children:`Critical · serious`}),(0,L.jsx)(`th`,{className:`hidden py-1.5 pr-3 text-right font-medium @xl:table-cell`,children:`Slow pages`}),(0,L.jsx)(`th`,{className:`py-1.5 pr-3 text-right font-medium`,children:`Visual`}),(0,L.jsx)(`th`,{className:`hidden py-1.5 pr-3 text-right font-medium @3xl:table-cell`,children:`Budgets`}),(0,L.jsx)(`th`,{className:`hidden py-1.5 pr-3 font-medium @xl:table-cell`,children:`When`})]}),children:o.map(e=>{let t=e.breaches?s:N(e)?u:n,r=e.a11y?e.a11y.critical+e.a11y.serious:void 0;return(0,L.jsxs)(`tr`,{onClick:()=>c(e.id),className:`cursor-pointer border-t border-line-soft hover:bg-surface-muted`,children:[(0,L.jsx)(`td`,{className:`max-w-0 py-2 pr-3 pl-3`,children:(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(t,{size:15,"aria-label":e.breaches?`Over a budget`:N(e)?`Needs a look`:`Within budgets`,className:d(`flex-none`,e.breaches?`text-fail`:N(e)?`text-warn`:`text-pass`)}),(0,L.jsx)(`a`,{href:_(`quality`,encodeURIComponent(e.id)),onClick:e=>e.stopPropagation(),"data-tip":e.goal,className:`truncate text-ink no-underline hover:underline`,children:e.goal})]})}),(0,L.jsx)(`td`,{className:d(l,e.a11y?.failed?`text-fail`:`text-muted`),children:e.a11y?e.a11y.failed:`–`}),(0,L.jsx)(`td`,{className:d(l,`hidden @2xl:table-cell`,r?`text-fail`:`text-muted`),children:e.a11y?`${e.a11y.critical} · ${e.a11y.serious}`:`–`}),(0,L.jsx)(`td`,{className:d(l,`hidden @xl:table-cell`,e.perf.over?`text-fail`:`text-muted`),children:e.perf.pages?`${e.perf.over} / ${e.perf.pages}`:`–`}),(0,L.jsx)(`td`,{className:d(l,e.visual?.changed?`text-warn`:`text-muted`),children:e.visual?`${e.visual.changed} changed`:e.captured?`not compared`:`–`}),(0,L.jsx)(`td`,{className:d(l,`hidden @3xl:table-cell`,e.breaches?`text-fail`:`text-muted`),children:e.breaches?`${e.breaches} over`:`ok`}),(0,L.jsx)(`td`,{className:`hidden py-2 pr-3 whitespace-nowrap text-[12.5px] text-muted @xl:table-cell`,"data-tip":A(e.at),children:T(e.at)})]},e.id)})})})}function B({sub:e}){let[t,n]=(0,I.useState)(null),[r,i]=(0,I.useState)(``),a=(0,I.useCallback)(()=>{S.view().then(e=>{n(e),i(``)},e=>i(e.message))},[]);(0,I.useEffect)(a,[a]);let o=e===`trends`,s=e&&!o?decodeURIComponent(e):``,l=t?.trends.filter(e=>e.perf.worse.length||e.a11y.newRules.length).length??0;return(0,L.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,L.jsx)(v,{}),(0,L.jsxs)(`main`,{className:d(w,`@container max-w-[1320px] flex-auto gap-4`),children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,L.jsx)(x,{pixel:g.quality,size:`lg`}),(0,L.jsx)(`h1`,{className:`m-0 text-[26px] font-semibold tracking-[-0.01em]`,children:`Quality`}),!s&&(0,L.jsx)(`div`,{role:`tablist`,"aria-label":`Show`,className:`flex gap-1 rounded-[10px] bg-surface-strong p-1`,children:[[`runs`,t?`Runs (${t.runs.length})`:`Runs`],[`trends`,`Trends${l?` (${l} worse)`:``}`]].map(([e,t])=>{let n=e===`trends`?o:!o;return(0,L.jsx)(`a`,{role:`tab`,"aria-selected":n,href:e===`runs`?_(`quality`):_(`quality`,e),className:d(`inline-flex min-h-8 items-center gap-1.5 rounded-[7px] px-3 text-sm font-medium no-underline`,n?`bg-bg text-ink shadow-sm hover:text-ink`:`text-muted hover:text-ink`),children:t},e)})})]}),!s&&(0,L.jsxs)(`p`,{className:`m-0 max-w-[80ch] text-[13px] leading-relaxed text-ink-2`,children:[`What each browser run measured on the pages it visited: accessibility (`,t?.standard||`WCAG`,`), Core Web Vitals, and visual changes against approved baselines. Budgets (quality.budgets) decide what fails a run. Open a run for all its details, or one kind with its agent: `,(0,L.jsx)(`a`,{href:_(`accessibility`),children:`Accessibility`}),`, `,(0,L.jsx)(`a`,{href:_(`performance`),children:`Performance`}),` or `,(0,L.jsx)(`a`,{href:_(`visual`),children:`Visual`}),`.`]}),r&&(0,L.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[10px] bg-fail-soft px-3 py-2 text-[13px] text-fail [overflow-wrap:anywhere]`,children:r}),!t&&!r&&(0,L.jsx)(`p`,{role:`status`,className:`m-0 text-[13px] text-muted`,children:`Loading…`}),t&&s&&(0,L.jsx)(R,{id:s,view:t,onChanged:a}),t&&!s&&o&&(0,L.jsx)(`div`,{role:`tabpanel`,"aria-label":`Trends`,children:(0,L.jsx)(j,{trends:t.trends})}),t&&!s&&!o&&(t.runs.length?(0,L.jsx)(z,{runs:t.runs}):(0,L.jsx)(h,{icon:c,title:`No measurements yet`,children:`Every browser run checks accessibility, timings and visual changes of the pages it visits; run a flow from a chat or the Record page, and its results show here.`}))]})]})}export{B as Quality};
@@ -0,0 +1,2 @@
1
+ import{$a as e,An as t,Ba as n,Br as r,Dr as i,En as a,Et as o,Hi as s,Ii as c,Jn as l,Jt as u,Kt as d,Mn as f,Mr as p,On as m,Ot as h,Pi as g,Pr as _,Qi as v,Tt as y,Wr as b,Xt as x,Za as S,Zi as ee,Zt as C,ai as w,at as T,ba as E,bi as D,bn as O,di as te,dt as ne,er as k,fi as re,ft as ie,it as ae,jr as oe,la as se,mt as A,n as j,na as ce,ni as le,no as ue,nt as de,ot as M,pt as fe,qi as pe,ra as me,sn as he,st as ge,ti as _e,tn as ve,tt as ye,ui as N,ur as be,ut as P,vn as xe,wt as Se}from"./Shell-DGv_Zqjs.js";import{C as Ce,i as we,r as Te,t as Ee}from"./index-DI1ST-gI.js";import{n as F,t as De}from"./when-CHnpLdYw.js";import{n as Oe,r as ke}from"./segmented-1nc3D7ML.js";import{n as Ae,t as I}from"./thread-CE28Yblm.js";var L=ue(e(),1),R=S(),z=e=>new Promise(t=>setTimeout(t,e));function je({id:e,onEnd:t,label:n=`The agent at work`,done:r=`Done.`,failed:i=`It could not finish.`}){let[a,o]=(0,L.useState)([]),[s,c]=(0,L.useState)(`starting`);(0,L.useEffect)(()=>{let t=!1,n=0,r=[];return(async()=>{for(;!t;)try{let i=await E.events(e,n,!0);if(t||(i.events.length&&(r.push(...i.events),n=i.events.at(-1).n,o([...r])),c(i.state),i.state===`closed`||i.state===`failed`))return}catch{await z(2e3)}})(),()=>{t=!0}},[e]);let l=Ae(a),u=l.turns.at(-1),d=!!u?.outcome||s===`failed`||s===`closed`,f=u&&!d?I(u):null,p=u?.outcome===`done`,m=d&&!p&&(u?.error||l.fatal||l.ended?.message)||``;return(0,L.useEffect)(()=>{d&&t?.()},[d]),(0,R.jsxs)(`section`,{"aria-label":n,className:`flex flex-col gap-2 border-t border-line-soft pt-3 text-sm`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[f||!d?(0,R.jsx)(h,{state:f?.orb??`thinking`,px:16}):p?(0,R.jsx)(xe,{size:16,"aria-hidden":`true`,className:`text-pass`}):(0,R.jsx)(se,{size:16,"aria-hidden":`true`,className:`text-fail`}),(0,R.jsx)(`span`,{className:x(`min-w-0 flex-1 font-medium [overflow-wrap:anywhere]`,d&&!p&&`text-fail`),children:f?f.text:d?p?r:u?.outcome===`stopped`?`It was stopped.`:i:`Starting…`}),(0,R.jsx)(`a`,{href:A(`chats`,e),className:`text-[13px]`,children:`Open the chat`})]}),m&&(0,R.jsx)(`p`,{className:`m-0 text-[13px] text-fail [overflow-wrap:anywhere]`,children:m.split(`
2
+ `).slice(0,3).join(` `)}),u&&u.steps.length>0&&(0,R.jsx)(`ol`,{className:`m-0 flex list-none flex-col gap-0.5 p-0 text-[13px] text-muted`,children:u.steps.slice(-6).map(e=>(0,R.jsxs)(`li`,{className:x(`[overflow-wrap:anywhere]`,e.status===`fail`&&`text-fail`),children:[e.status===`running`?`… `:e.status===`fail`?`✗ `:`✓ `,e.label,e.arg?`: ${e.arg}`:``]},e.key))}),u&&u.changes.length>0&&(0,R.jsxs)(`p`,{className:`m-0 text-[13px] [overflow-wrap:anywhere]`,children:[`Changed: `,u.changes.map(e=>`${e.path} (+${e.added} −${e.removed})`).join(`, `)]}),u&&u.asks.some(e=>e.answer===void 0)&&(0,R.jsxs)(`p`,{className:`m-0 text-[13px] text-warn`,children:[`It is asking something: `,(0,R.jsx)(`a`,{href:A(`chats`,e),children:`answer it in the chat`}),`.`]}),u?.reply&&d&&(0,R.jsx)(we,{text:u.reply,className:`text-[14px]`})]})}var Me=[{id:`typed`,label:`As typed`,note:`The test types exactly this.`},{id:`data`,label:`Test data`,note:`A named value the test reads from its data, one per environment.`},{id:`unique`,label:`New on each run`,note:`A fresh value each time, like this one: for an email or a name that must not repeat.`},{id:`secret`,label:`Secret`,note:`Read from the environment when the test runs; what was typed is removed from the recording.`}];function Ne({runDir:e,onClose:r,onRecordMore:i,notices:o}){let[s,c]=(0,L.useState)(null),[l,f]=(0,L.useState)(``),[p,h]=(0,L.useState)(!1),[v,y]=(0,L.useState)(`steps`),[b,S]=(0,L.useState)(``),[ee,w]=(0,L.useState)(!1),[O,k]=(0,L.useState)(null),[ie,A]=(0,L.useState)(null),[j,ce]=(0,L.useState)(null),[le,ue]=(0,L.useState)(``),[de,fe]=(0,L.useState)(`all`),[N,be]=(0,L.useState)(null),[Se,we]=(0,L.useState)(!1),[Te,Ee]=(0,L.useState)(``),[F,Ae]=(0,L.useState)(``),[I,z]=(0,L.useState)([]),[Ne,Ie]=(0,L.useState)(void 0),[B,V]=(0,L.useState)({from:0,to:0,name:``}),[H,Le]=(0,L.useState)({block:``,after:0}),[Re,ze]=(0,L.useState)(``),[U,Be]=(0,L.useState)(null),[Ve,W]=(0,L.useState)(``),[He,Ue]=(0,L.useState)({}),[G,We]=(0,L.useState)(null),[K,Ge]=(0,L.useState)(null),[Ke,qe]=(0,L.useState)(null),[Je,Ye]=(0,L.useState)(!1);(0,L.useEffect)(()=>{let t=!1;return n.review(e).then(e=>{t||(c(e),S(e.name),Ae(e.instructions))},e=>!t&&f(e.message)),()=>{t=!0}},[e]),(0,L.useEffect)(()=>{n.blocks().then(e=>{z(e.blocks),Ie(e.shared)},()=>z([]))},[]),(0,L.useEffect)(()=>{let t=!1;return n.tryView(e).then(e=>{t||(Be(e),Ue(t=>Object.fromEntries(e.data.map(e=>[e.name,t[e.name]??e.value]))))},()=>{}),()=>{t=!0}},[e,s]);let q=U?.running===e;(0,L.useEffect)(()=>{if(!q)return;let t=setInterval(()=>{n.tryView(e).then(Be,()=>{})},1500);return()=>clearInterval(t)},[q,e]);let Xe=async()=>{f(``),Ye(!0);try{let{id:t}=await E.start(`Turn the reviewed recording in ${e} into a test: call write_test with run_dir ${e} and unattended true.`,{});qe(t)}catch(e){f(e.message),Ye(!1)}};(0,L.useEffect)(()=>{K&&!q&&U&&(Ge(null),G===s&&U.result?.ok&&Xe())},[K,q,U,G,s]);let Ze=async t=>{f(``),qe(null);try{let r=await n.tryRun(e,Ve,He);We(s),Ge(t),Be(r)}catch(e){f(e.message)}},Qe=async()=>{h(!0),f(``),ze(``);try{let t=await n.saveBlock(e,B.name.trim(),B.from,B.to);z(t.blocks),ze(`Kept as the block "${t.block.name}": put it into other recordings, or start one from it on the Record page.`),V({...B,name:``})}catch(e){f(e.message)}finally{h(!1)}},J=async t=>{h(!0),f(``);try{let r=`restore`in t?await n.restoreReview(e,t.restore):`insert`in t?await n.insertBlock(e,t.insert.after,t.insert.block):`useBlock`in t?await n.useBlock(e,t.useBlock.block,t.useBlock.from):await n.saveReview(e,t);c(r),S(r.name),Ae(r.instructions)}catch(e){f(e.message)}finally{h(!1)}},$e=async()=>{we(!0),Ee(``);try{let t=await n.suggest(e);be(t.picks),Ee(t.error||(t.picks.length?``:`The model found nothing more to check.`))}catch(e){Ee(e.message)}finally{we(!1)}},et=e=>e.kind===`data`||e.kind===`unique`?{data:[{index:e.after,as:e.kind}]}:{checks:[{after:e.after,kind:e.kind,text:e.text}]},tt=async e=>{for(let t of e)await J(et(t));be(t=>(t||[]).filter(t=>!e.includes(t)))};if(!s)return l?(0,R.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail`,children:l}):(0,R.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Reading the recording…`});let nt=s.steps.filter(e=>e.value),rt=s.steps.filter(e=>e.op===`expect`).length,Y=q?void 0:U?.result,it=new Map((Y?.steps??[]).map(e=>[e.n-1,e])),X=Y?.steps.find(e=>!e.ok),Z=X?X.n-1:-1,Q=Z>=0?s.steps[Z]:void 0,at=!!Y&&!!G&&G!==s,ot=(Y?.steps??[]).filter(e=>!e.ok).length,st=le.toLowerCase().split(/\s+/).filter(Boolean),ct=s.steps.filter(e=>st.every(t=>`${e.index+1} ${e.line} ${e.note||``}`.toLowerCase().includes(t))&&(de===`all`||(de===`checks`?e.op===`expect`:it.get(e.index)?.ok===!1))),lt=e=>{y(`steps`),fe(`all`),ue(``),requestAnimationFrame(()=>document.getElementById(`step-${e}`)?.scrollIntoView({block:`center`,behavior:`smooth`}))},$=!!U?.running&&!q,ut=Je||K===`write`&&q,dt=[{id:`steps`,label:`Steps`,n:s.steps.length},{id:`data`,label:`Test data`,n:nt.length},{id:`run`,label:`Last run`},{id:`instructions`,label:`Instructions`},{id:`blocks`,label:`Blocks`},{id:`history`,label:`History`,n:s.history.length}];return(0,R.jsxs)(`section`,{"aria-labelledby":`review-title`,className:`flex min-w-0 flex-col gap-4`,children:[(0,R.jsxs)(`div`,{className:`sticky top-0 z-20 -mx-1 flex flex-col gap-3 border-b border-line bg-bg px-1 py-3`,children:[(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:r&&(0,R.jsxs)(d,{size:`sm`,variant:`ghost`,onClick:r,className:`-ml-2 text-ink-2`,children:[(0,R.jsx)(ve,{"aria-hidden":`true`}),`Recordings`]})}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-3`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-[1_1_320px] flex-col gap-1`,children:[ee?(0,R.jsxs)(`form`,{className:`flex items-center gap-2`,onSubmit:e=>{e.preventDefault(),w(!1),b.trim()&&b.trim()!==s.name&&J({name:b.trim()})},children:[(0,R.jsx)(T,{"aria-label":`Name of the recording`,value:b,maxLength:200,autoFocus:!0,onChange:e=>S(e.target.value),className:`min-w-0 flex-1`}),(0,R.jsx)(d,{type:`submit`,size:`sm`,variant:`primary`,children:`Save`}),(0,R.jsx)(d,{size:`sm`,variant:`ghost`,onClick:()=>{S(s.name),w(!1)},children:`Cancel`})]}):(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,R.jsx)(`h2`,{id:`review-title`,className:`m-0 min-w-0 truncate text-lg font-semibold`,"data-tip":s.name,children:s.name}),(0,R.jsx)(d,{size:`icon`,variant:`icon`,"aria-label":`Rename the recording`,"data-tip":`Rename`,onClick:()=>w(!0),className:`size-8 flex-none`,children:(0,R.jsx)(te,{"aria-hidden":`true`})})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[13px] text-muted`,children:[(0,R.jsxs)(`span`,{children:[C(s.steps.length,`step`),` · `,C(rt,`check`)]}),q?(0,R.jsx)(P,{tone:`running`,children:`Running the steps…`}):Y?(0,R.jsx)(P,{tone:Y.ok?`pass`:`fail`,children:Y.ok?`Last run passed${Y.env?` on ${Y.env}`:``}`:X?`Last run failed at step ${X.n}`:`Last run did not get through`}):(0,R.jsx)(P,{tone:`neutral`,icon:!1,children:`Not run yet`}),at&&(0,R.jsx)(`span`,{children:`· you changed it since`})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsxs)(d,{disabled:q||$||ut,onClick:()=>void Ze(null),"data-tip":`Play the steps in a new browser, as the test will`,children:[(0,R.jsx)(re,{"aria-hidden":`true`}),q&&!K?`Running…`:$?`Another run is going`:`Re-run`]}),(0,R.jsxs)(d,{variant:`primary`,disabled:p||q||$||ut,onClick:()=>void(Y?.ok&&G===s?Xe():Ze(`write`)),"data-tip":`The steps are run first; when they work, the Coding agent writes the test in your repository's style`,children:[(0,R.jsx)(me,{"aria-hidden":`true`}),K===`write`&&q?`Checking the steps…`:Je?`Writing…`:Ke?`Write the test again`:`Write the test`]})]})]})]}),o,l&&(0,R.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:l}),Y&&!Y.ok&&(0,R.jsxs)(`div`,{role:`alert`,className:`flex flex-col gap-2 rounded-[12px] border border-fail/30 bg-fail-soft px-4 py-3 text-sm`,children:[(0,R.jsxs)(`p`,{className:`m-0 font-semibold text-fail [overflow-wrap:anywhere]`,children:[X?`Step ${X.n} failed${Y.env?` on ${Y.env}`:``}`:`The run did not get through${Y.env?` on ${Y.env}`:``}`,at&&(0,R.jsx)(`span`,{className:`font-normal text-ink-2`,children:` · before your last change`})]}),Q&&(0,R.jsx)(`p`,{className:`m-0 font-medium text-ink [overflow-wrap:anywhere]`,children:Q.line}),(0,R.jsx)(`p`,{className:`m-0 line-clamp-3 text-[13px] text-ink-2 [overflow-wrap:anywhere]`,"data-tip":(X?X.error:Y.error)||void 0,children:(X?X.error:Y.error)||(X?`It failed.`:`The last page was not the recorded one.`)}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Q&&(0,R.jsx)(d,{size:`sm`,onClick:()=>lt(Z),children:`Show the step`}),Q&&i&&Z>0&&(0,R.jsxs)(d,{size:`sm`,onClick:()=>i(Z),"data-tip":`The browser does the steps before it; you do this step again, and what you record takes its place`,children:[(0,R.jsx)(m,{"aria-hidden":`true`}),`Record it again`]}),Q&&!Q.fixed&&(0,R.jsxs)(d,{size:`sm`,disabled:p,onClick:()=>void J({remove:[Z]}),children:[(0,R.jsx)(pe,{"aria-hidden":`true`}),`Drop it`]}),(0,R.jsx)(d,{size:`sm`,variant:`ghost`,disabled:ut,onClick:()=>void Xe(),children:`Write the test anyway`})]})]}),Ke&&(0,R.jsx)(je,{id:Ke,onEnd:()=>Ye(!1),label:`The Coding agent writing the test`,done:`The test is written.`,failed:`The test could not be written.`},Ke),s.blocksFound?.map(e=>(0,R.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center gap-x-3 gap-y-2 rounded-[12px] bg-accent-soft px-3 py-2.5 text-sm text-ink`,children:[(0,R.jsx)(u,{icon:he,size:16,className:`flex-none`}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-[1_1_240px]`,children:[`Steps `,e.from+1,` to `,e.to+1,` are the block `,(0,R.jsx)(`strong`,{className:`font-semibold`,children:e.name}),`: the test can call its helper instead.`]}),(0,R.jsx)(d,{size:`sm`,disabled:p,onClick:()=>void J({useBlock:{block:e.block,from:e.from}}),children:`Use the block`})]},`${e.block}-${e.from}`)),(0,R.jsx)(`div`,{role:`tablist`,"aria-label":`This recording`,className:Oe,children:dt.map(e=>(0,R.jsxs)(`button`,{type:`button`,role:`tab`,id:`rev-tab-${e.id}`,"aria-selected":v===e.id,"aria-controls":`rev-panel-${e.id}`,onClick:()=>y(e.id),className:ke(v===e.id),children:[e.label,e.n!==void 0&&(0,R.jsx)(`span`,{className:`text-[12px] text-muted tabular-nums`,children:e.n}),e.id===`run`&&Y&&(0,R.jsx)(`span`,{"aria-label":Y.ok?`passed`:`failed`,className:x(`size-2 rounded-full`,Y.ok?`bg-pass`:`bg-fail`)})]},e.id))}),(0,R.jsxs)(`div`,{role:`tabpanel`,id:`rev-panel-${v}`,"aria-labelledby":`rev-tab-${v}`,className:`flex min-w-0 flex-col gap-4`,children:[v===`steps`&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(ae,{id:`rev-step-search`,label:`Find a step`,value:le,onChange:ue}),(0,R.jsx)(ye,{items:[{id:`all`,label:`All`,n:s.steps.length},{id:`checks`,label:`Checks`,n:rt},...ot?[{id:`failed`,label:`Failed`,n:ot,alert:!0}]:[]],value:de,onChange:fe}),(0,R.jsx)(`span`,{className:`flex-1`}),(0,R.jsxs)(d,{size:`sm`,variant:`ghost`,disabled:Se||p,onClick:()=>void $e(),"data-tip":`One model call reads the pages after each step and suggests checks and test data`,children:[(0,R.jsx)(g,{"aria-hidden":`true`}),Se?`Asking the model…`:`Suggest checks`]})]}),Te&&(0,R.jsx)(`p`,{className:`m-0 text-[13px] text-muted [overflow-wrap:anywhere]`,children:Te}),N&&N.length>0&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-[12px] border border-accent-line bg-accent-soft px-3 py-2.5 text-ink`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,R.jsx)(u,{icon:g,size:14}),(0,R.jsx)(`span`,{className:`flex-1 font-medium`,children:`The model suggests`}),(0,R.jsx)(d,{size:`sm`,disabled:p,onClick:()=>void tt(N),children:`Add all`}),(0,R.jsx)(d,{size:`icon`,variant:`icon`,"aria-label":`Dismiss the suggestions`,onClick:()=>be(null),className:`size-8`,children:(0,R.jsx)(se,{size:14,"aria-hidden":`true`})})]}),(0,R.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:N.map(e=>(0,R.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[13.5px]`,children:[(0,R.jsxs)(`span`,{className:`min-w-0 flex-[1_1_240px] [overflow-wrap:anywhere]`,children:[e.kind===`data`||e.kind===`unique`?e.label:`After step ${e.after+1}: ${e.label}`,e.why&&(0,R.jsxs)(`span`,{className:`text-ink-2`,children:[` · `,e.why]})]}),(0,R.jsx)(d,{size:`sm`,variant:`ghost`,disabled:p,onClick:()=>void tt([e]),children:`Add`})]},`${e.after}-${e.kind}-${e.text}`))})]}),ct.length===0?(0,R.jsx)(`p`,{className:`m-0 rounded-[12px] card border px-4 py-4 text-sm text-muted`,children:`No step matches.`}):(0,R.jsx)(`ol`,{className:`m-0 flex list-none flex-col overflow-hidden rounded-[12px] card border p-0`,children:ct.map((n,r)=>{let o=it.get(n.index),s=n.op===`expect`;return(0,R.jsxs)(`li`,{id:`step-${n.index}`,className:x(`flex scroll-mt-48 flex-col`,r>0&&`border-t border-line-soft`,o&&!o.ok&&`bg-fail-soft`),children:[(0,R.jsxs)(`div`,{className:`group flex min-h-11 items-start gap-3 px-3 py-2`,children:[(0,R.jsx)(`span`,{className:`w-6 flex-none pt-0.5 text-right font-mono text-[12px] text-muted tabular-nums`,children:n.index+1}),(0,R.jsx)(`span`,{className:`flex w-4 flex-none justify-center pt-1`,children:o?o.skipped?(0,R.jsx)(_e,{size:14,"aria-label":`Not replayed`,className:`text-muted`}):o.ok?(0,R.jsx)(xe,{size:14,strokeWidth:2.5,"aria-label":`Passed on the last run`,className:`text-pass`}):(0,R.jsx)(se,{size:14,strokeWidth:2.5,"aria-label":`Failed on the last run`,className:`text-fail`}):s?(0,R.jsx)(a,{size:14,"aria-hidden":`true`,className:`text-pass`}):(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1 size-1.5 rounded-full bg-line-strong`})}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[s&&(0,R.jsx)(P,{tone:`pass`,icon:!1,className:`min-h-5 px-2 text-[11px]`,children:`Check`}),(0,R.jsx)(`span`,{className:`min-w-0 text-[14px] text-ink [overflow-wrap:anywhere]`,children:n.line}),n.block&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-line px-2 py-px text-[11.5px] text-ink-2`,children:[(0,R.jsx)(u,{icon:he,size:11}),I.find(e=>e.id===n.block)?.name||n.block]})]}),n.note&&(0,R.jsxs)(`span`,{className:`text-[12.5px] text-ink-2`,children:[`Note: `,n.note]}),o&&!o.ok&&o.error&&(0,R.jsx)(`span`,{className:`line-clamp-2 text-[12.5px] text-fail [overflow-wrap:anywhere]`,"data-tip":o.error,children:o.error}),n.suggest&&n.suggest.length>0&&(0,R.jsxs)(`button`,{type:`button`,"aria-expanded":j===n.index,onClick:()=>ce(j===n.index?null:n.index),className:`inline-flex cursor-pointer items-center gap-1 self-start border-0 bg-transparent p-0 text-[12.5px] font-medium text-accent-fg hover:text-accent-fg-hover`,children:[(0,R.jsx)(u,{icon:g,size:12}),j===n.index?`Hide the suggested checks`:`${C(n.suggest.length,`suggested check`)}`]})]}),(0,R.jsxs)(`span`,{className:`relative flex flex-none items-center gap-0.5`,children:[(0,R.jsx)(d,{size:`icon`,variant:`icon`,disabled:p,"aria-haspopup":`menu`,"aria-expanded":O===n.index,"aria-label":`Add after step ${n.index+1}`,"data-tip":`Add a check, a step or a note after this step`,onClick:()=>k(O===n.index?null:n.index),className:`size-8`,children:(0,R.jsx)(t,{"aria-hidden":`true`})}),(0,R.jsx)(Ce,{open:O===n.index,onClose:()=>k(null),label:`Add after step ${n.index+1}`,role:`dialog`,side:`auto`,className:`right-0 w-[min(360px,calc(100vw-48px))]`,children:(0,R.jsx)(Fe,{step:n,...i?{onRecordMore:()=>{k(null),i(n.index)}}:{},onAdd:e=>{k(null),J(e)}})}),n.shot&&(0,R.jsx)(d,{size:`icon`,variant:`icon`,"aria-label":`The page after step ${n.index+1}`,"aria-expanded":ie===n.index,"data-tip":`See the page after this step, and pick what to check`,onClick:()=>A(ie===n.index?null:n.index),className:`size-8`,children:(0,R.jsx)(_,{"aria-hidden":`true`})}),!n.fixed&&(0,R.jsx)(d,{size:`icon`,variant:`icon`,disabled:p,"aria-label":`Drop step ${n.index+1}`,"data-tip":`Drop this step`,onClick:()=>void J({remove:[n.index]}),className:`size-8`,children:(0,R.jsx)(pe,{"aria-hidden":`true`})})]})]}),j===n.index&&n.suggest&&n.suggest.length>0&&(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 pr-3 pb-2.5 pl-3 sm:pl-[76px]`,children:[(0,R.jsx)(`span`,{className:`text-[12.5px] text-ink-2`,children:`Add a check that`}),n.suggest.map(e=>(0,R.jsxs)(d,{size:`sm`,disabled:p,"data-tip":`Add this check after the step`,onClick:()=>void J({checks:[{after:n.index,kind:e.kind,text:e.text}]}),className:`h-7 min-h-7 max-w-full rounded-full px-2.5 text-[12.5px]`,children:[(0,R.jsx)(t,{"aria-hidden":`true`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.label})]},`${e.kind}-${e.text}`))]}),ie===n.index&&n.shot&&n.snap&&(0,R.jsx)(Pe,{runDir:e,step:n,busy:p,onPick:(e,t)=>void J({checks:[{after:n.index,kind:e,text:t}]})})]},`${n.index}-${n.line}`)})})]}),v===`data`&&(nt.length===0?(0,R.jsx)(ne,{className:`py-4`,children:`Nothing was typed or chosen in this recording, so it has no test data.`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:`m-0 text-sm text-ink-2`,children:`Where each value you typed or chose comes from when the test runs.`}),(0,R.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-0`,children:nt.map((e,t)=>{let n=e.value,r=Me.filter(t=>e.op!==`select`||t.id===`typed`||t.id===`data`);return(0,R.jsxs)(`li`,{className:x(`flex flex-wrap items-center gap-x-4 gap-y-2 px-3 py-2.5`,t>0&&`border-t border-line-soft`),children:[(0,R.jsx)(`span`,{className:`w-6 flex-none text-right font-mono text-[12px] text-muted tabular-nums`,children:e.index+1}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_240px] flex-col`,children:[(0,R.jsx)(`span`,{className:`text-[14px] text-ink [overflow-wrap:anywhere]`,children:e.line}),(0,R.jsx)(`span`,{className:`text-[12.5px] text-ink-2`,children:Me.find(e=>e.id===n.as)?.note})]}),(0,R.jsx)(M,{"aria-label":`Where the value of step ${e.index+1} comes from`,value:n.as,disabled:p,onChange:t=>void J({data:[{index:e.index,as:t.target.value}]}),className:`w-[200px] flex-none`,children:r.map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.label},e.id))})]},e.index)})})]})),v===`run`&&U&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:`m-0 text-sm text-ink-2`,children:`Re-run plays the steps in a new browser, as the test will, so you know they work before the test is written. Choose where it runs and the values it types.`}),(0,R.jsxs)(`form`,{className:`flex flex-wrap items-end gap-3 rounded-[12px] card border p-3`,onSubmit:e=>{e.preventDefault(),Ze(null)},children:[U.environments.length>0&&(0,R.jsxs)(`label`,{className:`flex min-w-[180px] flex-col gap-1 text-[13px] font-medium text-ink-2`,children:[`Environment`,(0,R.jsxs)(M,{value:Ve,onChange:e=>W(e.target.value),children:[(0,R.jsx)(`option`,{value:``,children:`Where it was recorded`}),U.environments.map(e=>(0,R.jsxs)(`option`,{value:e,children:[e,e===U.environment?` (active)`:``]},e))]})]}),U.data.map(e=>(0,R.jsxs)(`label`,{className:`flex min-w-[160px] flex-1 flex-col gap-1 text-[13px] font-medium text-ink-2`,children:[e.name,(0,R.jsx)(T,{value:He[e.name]??``,maxLength:300,onChange:t=>Ue({...He,[e.name]:t.target.value})})]},e.name)),(0,R.jsxs)(d,{type:`submit`,disabled:q||$||ut,children:[(0,R.jsx)(re,{"aria-hidden":`true`}),q?`Running…`:$?`Another run is going`:`Re-run`]})]}),q&&(0,R.jsx)(P,{tone:`running`,children:`Playing the steps in a new browser…`}),!q&&!Y&&(0,R.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Not run yet.`}),Y&&(0,R.jsxs)(`div`,{role:`status`,className:`flex flex-col gap-2`,children:[(0,R.jsx)(`p`,{className:x(`m-0 text-sm font-semibold [overflow-wrap:anywhere]`,Y.ok?`text-pass`:`text-fail`),children:Y.ok?`All ${Y.steps.length} steps passed${Y.env?` on ${Y.env}`:``}${Y.ms?` in ${Math.round(Y.ms/1e3)}s`:``}.`:X?`Step ${X.n} failed${Y.env?` on ${Y.env}`:``}.`:`It did not get through${Y.env?` on ${Y.env}`:``}: ${Y.error||`the last page was not the recorded one`}`}),Y.steps.length>0&&(0,R.jsx)(`ol`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-0 text-[13.5px]`,children:Y.steps.map((e,t)=>(0,R.jsxs)(`li`,{className:x(`flex items-start gap-2 px-3 py-1.5`,t>0&&`border-t border-line-soft`,!e.ok&&`bg-fail-soft`),children:[e.skipped?(0,R.jsx)(_e,{size:14,"aria-label":`Not replayed`,className:`mt-0.5 flex-none text-muted`}):e.ok?(0,R.jsx)(xe,{size:14,strokeWidth:2.5,"aria-label":`Passed`,className:`mt-0.5 flex-none text-pass`}):(0,R.jsx)(se,{size:14,strokeWidth:2.5,"aria-label":`Failed`,className:`mt-0.5 flex-none text-fail`}),(0,R.jsx)(`span`,{className:`w-6 flex-none text-right font-mono text-[12px] text-muted tabular-nums`,children:e.n}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,R.jsxs)(`span`,{className:`text-ink [overflow-wrap:anywhere]`,children:[e.action,e.skipped?(0,R.jsx)(`span`,{className:`text-muted`,children:` (not replayed)`}):null]}),!e.ok&&e.error&&(0,R.jsx)(`span`,{className:`text-[12.5px] text-fail [overflow-wrap:anywhere]`,children:e.error})]})]},e.n))})]})]}),v===`instructions`&&(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-semibold text-ink`,children:[`Instructions for the Coding agent`,(0,R.jsx)(`span`,{className:`text-[13px] font-normal text-ink-2`,children:`Anything else about the test, in your words: where it goes, the page objects to use, its tags, what to leave out. Saved when you leave the box.`}),(0,R.jsx)(ge,{value:F,maxLength:4e3,rows:5,placeholder:`e.g. Put it in tests/checkout, use the CheckoutPage page object, and tag it @smoke.`,onChange:e=>Ae(e.target.value),onBlur:()=>F.trim()!==s.instructions&&void J({instructions:F.trim()}),className:`font-normal`})]}),v===`blocks`&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:`m-0 text-sm text-ink-2`,children:`Steps you do in many tests, like signing in, kept under a name: put them into other recordings, or start a new one from them. The Coding agent writes each block once, as a helper every test calls.`}),Ne===!0&&(0,R.jsx)(`p`,{className:`m-0 text-[13px] text-ink-2`,children:`They are kept in .forgeqe/blocks/ and go into the repository with your next commit, so the team shares them.`}),Ne===!1&&(0,R.jsxs)(`p`,{className:`m-0 rounded-[12px] bg-warn-soft px-3 py-2 text-[13px] text-ink`,children:[`Your .gitignore leaves .forgeqe/blocks/ out of the repository, so only you have these blocks. To share them with the team, ignore only `,(0,R.jsx)(`code`,{children:`.forgeqe/reports/`}),` (the run reports) there, not all of `,(0,R.jsx)(`code`,{children:`.forgeqe/`}),`.`]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-[12px] card border p-3`,children:[(0,R.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2`,onSubmit:e=>{e.preventDefault(),B.name.trim()&&Qe()},children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-[13px] font-medium text-ink-2`,children:[`Keep steps`,(0,R.jsx)(M,{"aria-label":`The first step of the block`,value:B.from,onChange:e=>V({...B,from:Number(e.target.value),to:Math.max(B.to,Number(e.target.value))}),className:`w-[84px]`,children:s.steps.map(e=>(0,R.jsx)(`option`,{value:e.index,children:e.index+1},e.index))})]}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-[13px] font-medium text-ink-2`,children:[`to`,(0,R.jsx)(M,{"aria-label":`The last step of the block`,value:B.to,onChange:e=>V({...B,to:Number(e.target.value)}),className:`w-[84px]`,children:s.steps.filter(e=>e.index>=B.from).map(e=>(0,R.jsx)(`option`,{value:e.index,children:e.index+1},e.index))})]}),(0,R.jsxs)(`label`,{className:`flex min-w-[180px] flex-1 flex-col gap-1 text-[13px] font-medium text-ink-2`,children:[`as the block`,(0,R.jsx)(T,{value:B.name,maxLength:80,placeholder:`Sign in`,onChange:e=>V({...B,name:e.target.value})})]}),(0,R.jsxs)(d,{type:`submit`,disabled:p||!B.name.trim(),children:[(0,R.jsx)(he,{"aria-hidden":`true`}),`Keep as a block`]})]}),Re&&(0,R.jsx)(`p`,{className:`m-0 text-[13px] text-pass`,children:Re}),I.length>0&&(0,R.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2 border-t border-line-soft pt-3`,onSubmit:e=>{e.preventDefault();let t=H.block||I[0].id;J({insert:{after:H.after,block:t}})},children:[(0,R.jsxs)(`label`,{className:`flex min-w-[180px] flex-1 flex-col gap-1 text-[13px] font-medium text-ink-2`,children:[`Put in the block`,(0,R.jsx)(M,{"aria-label":`The block to put in`,value:H.block||I[0].id,onChange:e=>Le({...H,block:e.target.value}),children:I.map(e=>(0,R.jsxs)(`option`,{value:e.id,children:[e.name,` · `,e.steps,` `,e.steps===1?`step`:`steps`]},e.id))})]}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-[13px] font-medium text-ink-2`,children:[`after step`,(0,R.jsx)(M,{"aria-label":`The step the block goes after`,value:H.after,onChange:e=>Le({...H,after:Number(e.target.value)}),className:`w-[84px]`,children:s.steps.map(e=>(0,R.jsx)(`option`,{value:e.index,children:e.index+1},e.index))})]}),(0,R.jsx)(d,{type:`submit`,disabled:p,children:`Put it in`})]})]})]}),v===`history`&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:`m-0 flex items-center gap-1.5 text-sm text-ink-2`,children:[(0,R.jsx)(u,{icon:oe,size:15}),`Every change is kept: go back to any version, and you can come back from it too.`]}),(0,R.jsx)(`ol`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-0`,children:[...s.history,{n:0,at:``,change:`The recording as recorded`,steps:0}].map((e,t)=>(0,R.jsxs)(`li`,{className:x(`flex flex-wrap items-center gap-x-3 gap-y-1 px-3 py-2`,t>0&&`border-t border-line-soft`),children:[(0,R.jsxs)(`span`,{className:`w-8 flex-none font-mono text-[12px] text-muted tabular-nums`,children:[`v`,e.n]}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_220px] flex-col`,children:[(0,R.jsx)(`span`,{className:`text-[14px] text-ink [overflow-wrap:anywhere]`,children:e.change}),e.at&&(0,R.jsxs)(`span`,{className:`text-[12.5px] text-muted`,children:[De(e.at),` · `,C(e.steps,`step`)]})]}),t===0?(0,R.jsx)(P,{tone:`neutral`,icon:!1,children:`Now`}):(0,R.jsxs)(d,{size:`sm`,variant:`ghost`,disabled:p,onClick:()=>void J({restore:e.n}),"data-tip":`Make this version the recording again; you can come back from it too`,children:[(0,R.jsx)(D,{"aria-hidden":`true`}),`Go back to this`]})]},e.n))})]})]})]})}function Pe({runDir:e,step:t,busy:r,onPick:i}){let[a,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(``);(0,L.useEffect)(()=>{let r=!1;return n.shot(e,t.shot).then(e=>!r&&o(e),e=>!r&&c(e.message)),()=>{r=!0}},[e,t.shot]);let l=t.snap,u=[...l.texts.map(e=>({...e,kind:`text`})),...l.fields.filter(e=>e.value).map(e=>({...e,kind:`value`}))].filter(e=>e.w>0&&e.h>0&&l.w>0&&l.h>0).sort((e,t)=>t.w*t.h-e.w*e.h),d=(e,t)=>`${Math.max(0,Math.min(100,e/t*100))}%`;return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 pr-3 pb-3 pl-3 sm:pl-[76px]`,children:[(0,R.jsx)(`p`,{className:`m-0 text-[12.5px] text-muted`,children:`Click a text on the page to check that it shows; a field, to check its value.`}),s&&(0,R.jsx)(`p`,{className:`m-0 text-sm text-fail`,children:s}),!a&&!s&&(0,R.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Loading the picture…`}),a&&(0,R.jsxs)(`div`,{className:`relative w-full max-w-[720px] overflow-hidden rounded-[10px] border border-line-soft`,style:{aspectRatio:`${l.w} / ${l.h}`},children:[(0,R.jsx)(`img`,{src:a,alt:`The page after step ${t.index+1}`,className:`absolute inset-0 size-full object-cover object-top`}),u.map((e,t)=>{let n=e.kind===`value`?`Check ${e.t} has the value "${e.value}"`:`Check the page shows "${e.t}"`;return(0,R.jsx)(`button`,{type:`button`,disabled:r,"aria-label":n,"data-tip":n,onClick:()=>i(e.kind,e.t),className:`absolute rounded-[3px] outline-none hover:bg-accent/15 hover:ring-2 hover:ring-accent focus-visible:bg-accent/15 focus-visible:ring-2 focus-visible:ring-accent`,style:{left:d(e.x,l.w),top:d(e.y,l.h),width:d(e.w,l.w),height:d(e.h,l.h)}},`${t}-${e.t}`)})]})]})}function Fe({step:e,onAdd:t,onRecordMore:n}){let[r,i]=(0,L.useState)(`check`),[a,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(``),[l,u]=(0,L.useState)(e.note||``),f=e.index;return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 p-2`,children:[(0,R.jsx)(`div`,{role:`tablist`,"aria-label":`What to add`,className:`flex gap-1 rounded-[9px] bg-surface-strong p-1`,children:[[`check`,`Check`],[`step`,`Step`],[`note`,`Note`]].map(([e,t])=>(0,R.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":r===e,onClick:()=>i(e),className:x(`flex-1 cursor-pointer rounded-[6px] border-0 px-2 py-1 text-[13px] font-medium`,r===e?`bg-bg text-ink shadow-sm`:`bg-transparent text-muted hover:text-ink`),children:t},e))}),r===`check`&&(0,R.jsxs)(R.Fragment,{children:[e.page&&(0,R.jsxs)(d,{size:`sm`,className:`justify-start`,onClick:()=>t({checks:[{after:f,kind:`url`}]}),children:[`The page is `,e.page]}),(0,R.jsxs)(`form`,{className:`flex flex-col gap-2`,onSubmit:e=>{e.preventDefault(),a.trim()&&t({checks:[{after:f,kind:`intent`,text:a.trim()}]})},children:[(0,R.jsx)(T,{value:a,maxLength:300,placeholder:`Or say what shows here, e.g. the order number`,onChange:e=>o(e.target.value)}),(0,R.jsx)(d,{type:`submit`,size:`sm`,variant:`primary`,disabled:!a.trim(),children:`Add the check`})]})]}),r===`step`&&(0,R.jsxs)(R.Fragment,{children:[n&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-line-soft pb-2`,children:[(0,R.jsxs)(d,{size:`sm`,onClick:n,children:[(0,R.jsx)(m,{"aria-hidden":`true`}),`Record more from here`]}),(0,R.jsx)(`span`,{className:`text-[12px] text-muted`,children:`The browser opens, does the steps up to here, and you record what comes next. A step that cannot be done, you redo by hand.`})]}),(0,R.jsxs)(`form`,{className:`flex flex-col gap-2`,onSubmit:e=>{e.preventDefault(),a.trim()&&t({steps:[{after:f,kind:`do`,text:a.trim()}]})},children:[(0,R.jsx)(T,{value:a,maxLength:300,placeholder:`In your words, e.g. choose the cheapest delivery`,onChange:e=>o(e.target.value)}),(0,R.jsx)(`span`,{className:`text-[12px] text-muted`,children:`The Coding agent finds the control on the page and does it here.`}),(0,R.jsx)(d,{type:`submit`,size:`sm`,variant:`primary`,disabled:!a.trim(),children:`Add the step`})]}),(0,R.jsxs)(`form`,{className:`flex gap-2 border-t border-line-soft pt-2`,onSubmit:e=>{e.preventDefault(),/^https?:\/\/\S+$/i.test(s.trim())&&t({steps:[{after:f,kind:`open`,url:s.trim()}]})},children:[(0,R.jsx)(T,{value:s,type:`url`,maxLength:2e3,placeholder:`Open a page: https://…`,onChange:e=>c(e.target.value),className:`min-w-0 flex-1`}),(0,R.jsx)(d,{type:`submit`,size:`sm`,disabled:!/^https?:\/\/\S+$/i.test(s.trim()),children:`Open`})]}),(0,R.jsx)(d,{size:`sm`,className:`justify-start`,onClick:()=>t({steps:[{after:f,kind:`back`}]}),children:`Go back a page`})]}),r===`note`&&(0,R.jsxs)(`form`,{className:`flex flex-col gap-2`,onSubmit:e=>{e.preventDefault(),t({notes:[{index:f,text:l.trim()}]})},children:[(0,R.jsx)(T,{value:l,maxLength:300,placeholder:`e.g. this is the cart page object`,onChange:e=>u(e.target.value)}),(0,R.jsx)(`span`,{className:`text-[12px] text-muted`,children:`For whoever writes the test; it is not a step.`}),(0,R.jsx)(d,{type:`submit`,size:`sm`,variant:`primary`,disabled:l.trim()===(e.note||``),children:l.trim()||!e.note?`Save the note`:`Remove the note`})]})]})}var Ie={navigate:i,back:ve,click:w,dblclick:w,input:r,press:r,select:b,upload:v,expect:a,wait_for:p,capture:ce,note:s,launch:re,double_click:w,type:r,keys:r},B=e=>Ie[e]||(e.startsWith(`expect`)?a:l),V=new Set([`starting`,`recording`,`paused`,`stopping`]);function H(e,t){let n=Math.max(0,Math.round(((t?Date.parse(t):Date.now())-Date.parse(e))/1e3));return n<3600?`${Math.floor(n/60)}:${String(n%60).padStart(2,`0`)}`:`${Math.floor(n/3600)}h ${Math.floor(n%3600/60)}m`}async function Le(e){let{id:t}=await E.start(`Turn the recording in ${e} into a test: call write_test with run_dir ${e} and unattended true.`,{});location.hash=A(`chats`,t)}async function Re(e){let{id:t}=await E.start(`Replay the desktop workflow ${e}: call desktop_replay with workflow ${e}, and tell me how each step went.`,{});location.hash=A(`chats`,t)}function ze({s:e,live:t,onDelete:n}){let r=B(e.op);return(0,R.jsxs)(`li`,{className:`group flex min-h-[44px] items-start gap-3 border-t border-line-soft py-2 first:border-t-0`,children:[(0,R.jsx)(`span`,{className:`w-6 flex-none pt-0.5 text-right text-[13px] text-muted tabular-nums`,children:e.n}),(0,R.jsx)(r,{size:16,"aria-hidden":`true`,className:x(`mt-0.5 flex-none`,e.op.startsWith(`expect`)?`text-pass`:`text-muted`)}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{className:`text-sm [overflow-wrap:anywhere]`,children:e.text}),(e.note||e.dynamic||e.inferred||e.case_step)&&(0,R.jsxs)(`span`,{className:`flex flex-wrap gap-x-2 text-[12px] text-muted`,children:[e.case_step?(0,R.jsxs)(`span`,{children:[`case step `,e.case_step]}):null,e.dynamic&&(0,R.jsx)(`span`,{children:`value changes between runs`}),e.inferred&&(0,R.jsx)(`span`,{children:`added by ForgeQE`}),e.note&&(0,R.jsxs)(`span`,{className:`[overflow-wrap:anywhere]`,children:[`note: `,e.note]})]})]}),t&&e.n>1&&(0,R.jsx)(d,{variant:`icon`,size:`icon`,"aria-label":`Delete step ${e.n}`,onClick:n,className:`size-8 flex-none opacity-60 group-hover:opacity-100`,children:(0,R.jsx)(pe,{"aria-hidden":`true`})})]})}function U({s:e,send:t,busy:n}){let[,r]=(0,L.useState)(0);(0,L.useEffect)(()=>{let e=setInterval(()=>r(e=>e+1),1e3);return()=>clearInterval(e)},[]);let i=(0,L.useRef)(null),o=(0,L.useRef)(null);(0,L.useEffect)(()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)},[e.log.length]),(0,L.useEffect)(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},[e.steps.length]);let s=e.kind===`desktop`,l=e.state===`paused`,f=e.log.at(-1)?.level===`warn`&&/press Stop again/i.test(e.log.at(-1).text),p=Math.max(0,...e.steps.map(e=>e.case_step||0));return(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-3 rounded-[14px] card border px-4 py-3`,children:[l?(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 flex-none rounded-full bg-warn`}):(0,R.jsx)(h,{state:e.state===`starting`?`waiting`:e.state===`stopping`?`working`:`recording`,px:20}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_260px] flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{className:`font-medium [overflow-wrap:anywhere]`,children:e.name}),(0,R.jsxs)(`span`,{className:`truncate text-[13px] text-muted`,children:[e.state===`starting`?s?`Starting ${e.app}…`:`Opening the browser…`:e.state===`stopping`?`Saving the workflow…`:l?`Paused: what you do now is not recorded`:`Recording`,` · `,H(e.startedAt),` ·`,` `,s?`${e.app}, a desktop app`:e.url]}),e.block&&(0,R.jsx)(`span`,{className:x(`text-[13px] [overflow-wrap:anywhere]`,e.block.state===`stopped`?`text-warn`:`text-muted`),children:e.block.kind===`recording`?e.block.state===`waiting`?`The recording's steps up to step ${e.block.total+1} play when the page is open.`:e.block.state===`playing`?`Doing the recording's steps up to step ${e.block.total+1}: wait for it.`:e.block.state===`done`?`At step ${e.block.total+1}: record what comes next, then Stop and save.`:`Step ${e.block.done+2} could not be done${e.block.note?` (${e.block.note})`:``}: do it and what follows by hand; it takes the place of steps ${e.block.done+2} to ${e.block.total+1}.`:e.block.state===`waiting`?`The block "${e.block.name}" plays when the page is open.`:e.block.state===`playing`?`Doing the block "${e.block.name}" (${e.block.total} steps): wait for it.`:e.block.state===`done`?`The block "${e.block.name}" is done: carry on.`:`The block "${e.block.name}" stopped after ${e.block.done} of ${e.block.total} steps${e.block.note?` (${e.block.note})`:``}: do the rest by hand.`})]}),!s&&(0,R.jsxs)(d,{disabled:n||e.state===`starting`,onClick:()=>t({cmd:`pause`}),children:[l?(0,R.jsx)(re,{"aria-hidden":`true`}):(0,R.jsx)(N,{"aria-hidden":`true`}),l?`Resume`:`Pause`]}),!s&&(0,R.jsxs)(d,{disabled:n||e.state===`starting`||!e.steps.length,onClick:()=>t({cmd:`undo`}),"data-tip":`Remove the last step`,children:[(0,R.jsx)(ee,{"aria-hidden":`true`}),`Undo`]}),(0,R.jsxs)(d,{variant:`destructive`,disabled:n||e.state===`stopping`,onClick:()=>t({cmd:`stop`,...f?{force:!0}:{}}),children:[(0,R.jsx)(c,{fill:`currentColor`,"aria-hidden":`true`}),f?`Stop anyway`:`Stop and save`]})]}),s?(0,R.jsxs)(`p`,{className:`m-0 rounded-[12px] bg-accent-soft px-4 py-3 text-sm leading-relaxed text-ink-2`,children:[e.app,` is open on this computer: do the steps in it. Only clicks and keys in its own windows are recorded; password fields are saved as secret names, never as what you type. In the app, `,(0,R.jsx)(`strong`,{children:`Ctrl+Shift+F11`}),` over a control adds a check of what it shows, and `,(0,R.jsx)(`strong`,{children:`Ctrl+Shift+F12`}),` or closing the app stops.`]}):(0,R.jsxs)(`p`,{className:`m-0 rounded-[12px] bg-accent-soft px-4 py-3 text-sm leading-relaxed text-ink-2`,children:[`Do the steps in the browser on this computer: each click, entry and choice is recorded. When you stop, you choose the checks and the test data here. In the page, `,e.leader,` then `,(0,R.jsx)(`strong`,{children:`P`}),` pauses, `,(0,R.jsx)(`strong`,{children:`Z`}),` undoes the last step and `,(0,R.jsx)(`strong`,{children:`S`}),` stops.`]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-6 gap-y-5`,children:[(0,R.jsxs)(`section`,{"aria-labelledby":`rec-steps`,className:`flex min-w-0 flex-[999_1_420px] flex-col gap-2 rounded-[14px] card border px-4 py-3`,children:[(0,R.jsxs)(`h2`,{id:`rec-steps`,className:`m-0 flex items-center gap-2 text-base font-semibold`,children:[(0,R.jsx)(u,{icon:b,size:18,className:`text-accent-fg`}),`Steps`,(0,R.jsx)(`span`,{className:`text-sm font-normal text-muted`,children:e.summary})]}),e.steps.length?(0,R.jsx)(`div`,{ref:o,className:`max-h-[60vh] overflow-y-auto`,children:(0,R.jsx)(`ol`,{className:`m-0 flex list-none flex-col p-0`,"aria-live":`polite`,children:e.steps.map(e=>(0,R.jsx)(ze,{s:e,live:!s,onDelete:()=>t({cmd:`delete`,n:e.n})},`${e.n}-${e.text}`))})}):(0,R.jsx)(`p`,{className:`m-0 py-2 text-sm text-muted`,children:e.state===`starting`?s?`Starting ${e.app}…`:`Opening the browser…`:`Nothing yet: do the first step in ${s?e.app:`the browser`}.`})]}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-[1_1_300px] flex-col gap-5`,children:[e.case&&(0,R.jsxs)(`section`,{"aria-labelledby":`rec-case`,className:`flex flex-col gap-2 rounded-[14px] card border px-4 py-3`,children:[(0,R.jsxs)(`h2`,{id:`rec-case`,className:`m-0 flex items-center gap-2 text-base font-semibold`,children:[(0,R.jsx)(u,{icon:b,size:18,className:`text-accent-fg`}),e.case.id]}),(0,R.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,children:[e.case.title,`. Each step you record belongs to the case step you are on: pick one to record it.`]}),(0,R.jsx)(`ol`,{className:`m-0 flex list-none flex-col p-0`,children:e.case.steps.map(r=>{let i=e.steps.some(e=>e.case_step===r.n);return(0,R.jsx)(`li`,{className:`border-t border-line-soft first:border-t-0`,children:(0,R.jsxs)(`button`,{type:`button`,disabled:n,"aria-current":r.n===p?`step`:void 0,onClick:()=>t({cmd:`case_step`,n:r.n}),className:x(`flex w-full cursor-pointer items-start gap-2 rounded-[10px] border-0 bg-transparent px-2 py-2 text-left text-sm text-ink hover:bg-surface-muted`,r.n===p&&`bg-accent-soft`),children:[i?(0,R.jsx)(a,{size:16,"aria-hidden":`true`,className:`mt-0.5 flex-none text-pass`}):(0,R.jsx)(`span`,{className:`mt-0.5 w-4 flex-none text-center text-[12px] text-muted`,children:r.n}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,R.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:r.action}),r.expected&&(0,R.jsxs)(`span`,{className:`text-[12px] text-muted [overflow-wrap:anywhere]`,children:[`Expect: `,r.expected]})]})]})},r.n)})}),(0,R.jsx)(d,{disabled:n,onClick:()=>t({cmd:`case_next`}),className:`self-start`,children:`Next case step`})]}),(0,R.jsxs)(`section`,{"aria-labelledby":`rec-log`,className:`flex flex-col gap-2 rounded-[14px] card border px-4 py-3`,children:[(0,R.jsx)(`h2`,{id:`rec-log`,className:`m-0 text-base font-semibold`,children:`What the recorder says`}),(0,R.jsx)(`div`,{ref:i,className:`flex max-h-[280px] flex-col gap-1 overflow-auto text-[13px]`,"aria-live":`polite`,children:e.log.length?e.log.map((e,t)=>(0,R.jsx)(`p`,{className:x(`m-0 [overflow-wrap:anywhere]`,e.level===`warn`?`text-warn`:e.level===`error`?`text-fail`:`text-ink-2`),children:e.text},t)):(0,R.jsxs)(`p`,{className:`m-0 text-muted`,children:[`Waiting for `,s?`the app`:`the browser`,`…`]})})]})]})]})]})}function Be({s:e}){let t=e.result,[n,r]=(0,L.useState)(``),[i,a]=(0,L.useState)(!1);if(!t)return null;let s=e.kind===`desktop`;return(0,R.jsxs)(`section`,{"aria-labelledby":`rec-result`,className:`flex flex-col gap-3 rounded-[14px] card border p-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`h2`,{id:`rec-result`,className:`m-0 flex-1 text-base font-semibold [overflow-wrap:anywhere]`,children:e.name}),(0,R.jsx)(P,{tone:t.ok?`pass`:`fail`,children:t.ok?`Recorded`:`Not recorded`})]}),(0,R.jsxs)(`p`,{className:`m-0 text-sm text-ink-2`,children:[t.ok?t.summary||e.summary:t.error||`Nothing was recorded.`,` `,e.endedAt&&(0,R.jsxs)(`span`,{className:`text-muted`,children:[`· `,H(e.startedAt,e.endedAt)]})]}),t.ok&&(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-sm`,children:[(0,R.jsx)(P,{tone:`neutral`,icon:!1,children:C(e.steps.length,`step`)}),(0,R.jsxs)(P,{tone:t.checks?`pass`:`warn`,children:[t.checks,` check`,t.checks===1?``:`s`]}),t.variables.length>0&&(0,R.jsxs)(P,{tone:`neutral`,icon:!1,children:[`kept: `,t.variables.join(`, `)]}),t.testData.length>0&&(0,R.jsxs)(P,{tone:`neutral`,icon:!1,children:[`test data: `,t.testData.join(`, `)]})]}),!s&&t.secrets.length>0&&(0,R.jsxs)(`p`,{className:`m-0 text-sm text-ink-2`,children:[`The test reads`,` `,t.secrets.map((e,t)=>(0,R.jsxs)(`span`,{children:[t?`, `:``,(0,R.jsx)(`code`,{className:`font-mono text-[13px]`,children:e})]},e)),` `,`from the environment: what you typed there was not saved. Set `,t.secrets.length===1?`it`:`them`,` before the test runs.`]}),t.caseGaps.length>0&&(0,R.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-5 text-sm text-warn`,children:t.caseGaps.map(e=>(0,R.jsxs)(`li`,{children:[`No check for case step `,e.n,`: expects “`,e.expected,`”`]},e.n))}),(t.notes??[]).length>0&&(0,R.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-5 text-sm text-ink-2`,children:t.notes.map((e,t)=>(0,R.jsx)(`li`,{children:e},t))}),t.skipped.length>0&&(0,R.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-5 text-sm text-muted`,children:t.skipped.map((e,t)=>(0,R.jsxs)(`li`,{children:[`Not recorded: `,e.action,`: `,e.reason]},t))}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[s&&t.workflow&&(0,R.jsxs)(d,{variant:`primary`,disabled:i,onClick:async()=>{a(!0);try{await Re(t.workflow)}catch(e){r(e.message),a(!1)}},children:[(0,R.jsx)(D,{"aria-hidden":`true`}),`Replay it`]}),s&&t.report&&(0,R.jsxs)(d,{onClick:async()=>r(await o(t.report)),children:[(0,R.jsx)(k,{"aria-hidden":`true`}),`Open the report`]}),!s&&t.ok&&(0,R.jsxs)(d,{onClick:async()=>r(await o(`${e.runDir}/trace.md`)),children:[(0,R.jsx)(be,{"aria-hidden":`true`}),`Read the steps`]}),(0,R.jsx)(`span`,{className:`text-sm`,children:(0,R.jsx)(Te,{path:s&&t.workflow?t.workflow:e.runDir})}),n&&(0,R.jsx)(`span`,{className:`text-[13px] text-fail`,children:n})]})]})}function Ve({view:e,busy:t,onStart:n}){let[r,a]=(0,L.useState)(e.session?.kind===`desktop`&&e.desktop.available?`desktop`:`web`),[o,s]=(0,L.useState)(e.desktop.apps[0]??``),[c,l]=(0,L.useState)(e.apps[0]?.name??``),[u,f]=(0,L.useState)(``),[p,h]=(0,L.useState)(``),[g,_]=(0,L.useState)(e.environment??``),[v,b]=(0,L.useState)(!1),[S,ee]=(0,L.useState)(!1),[C,w]=(0,L.useState)(``),E=r===`web`?e.blocks.find(e=>e.id===C):void 0,D=r===`desktop`?e.desktop.available&&!!o:E||c?!0:/^https?:\/\/\S+$/i.test(u.trim()),te=r===`web`||e.environments.length>1;return(0,R.jsxs)(`form`,{"aria-labelledby":`rec-new`,className:`flex flex-col gap-3 rounded-[14px] card border p-4`,onSubmit:t=>{if(t.preventDefault(),D){if(r===`desktop`)return n({kind:`desktop`,app:o,...g&&g!==e.environment?{env:g}:{}});if(E)return n({block:E.id,...g&&g!==e.environment?{env:g}:{},signedIn:v});n({...c?{app:c}:{url:u.trim()},...p.trim()?{case:p.trim()}:{},...g&&g!==e.environment?{env:g}:{},signedIn:v})}},children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,R.jsx)(`h2`,{id:`rec-new`,className:`m-0 flex-1 text-base font-semibold`,children:`New recording`}),(0,R.jsx)(`div`,{role:`radiogroup`,"aria-label":`What to record`,className:`flex gap-1 rounded-[10px] bg-surface-strong p-1`,children:[[`web`,`Web page`,i,!0],[`desktop`,`Desktop app`,le,e.desktop.available]].map(([t,n,i,o])=>(0,R.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":r===t,disabled:!o,"data-tip":o?void 0:e.desktop.reason||`Windows only.`,onClick:()=>a(t),className:x(`inline-flex min-h-8 cursor-pointer items-center gap-1.5 rounded-[7px] border-0 px-3 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50`,r===t?`bg-bg text-ink shadow-sm`:`bg-transparent text-muted hover:text-ink`),children:[(0,R.jsx)(i,{size:14,"aria-hidden":`true`}),n]},t))})]}),(0,R.jsxs)(`div`,{className:`grid gap-2 @2xl:grid-cols-[minmax(0,1fr)_auto]`,children:[r===`desktop`?e.desktop.apps.length?(0,R.jsx)(M,{"aria-label":`App`,value:o,onChange:e=>s(e.target.value),children:e.desktop.apps.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))}):(0,R.jsxs)(`p`,{className:`m-0 self-center text-sm text-muted`,children:[`No desktop apps yet: add one in `,(0,R.jsx)(`a`,{href:A(`settings`,`environments`),children:`Settings, Environments`}),`.`]}):E?(0,R.jsxs)(`p`,{className:`m-0 self-center text-sm [overflow-wrap:anywhere]`,children:[`Opens `,E.startUrl,`, does the block `,(0,R.jsx)(`strong`,{className:`font-semibold`,children:E.name}),` (`,E.steps,` `,E.steps===1?`step`:`steps`,`), then you carry on.`]}):(0,R.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[e.apps.length>0&&(0,R.jsxs)(M,{"aria-label":`Start on`,value:c,onChange:e=>l(e.target.value),className:x(c?`min-w-0 flex-1`:`w-[150px] flex-none`),children:[e.apps.map(e=>(0,R.jsxs)(`option`,{value:e.name,children:[e.name,` · `,e.url]},e.name)),(0,R.jsx)(`option`,{value:``,children:`Another page…`})]}),!c&&(0,R.jsx)(T,{"aria-label":`Page address`,type:`url`,value:u,spellCheck:!1,placeholder:`https://shop.example.com/`,onChange:e=>f(e.target.value),className:`min-w-0 flex-1`})]}),(0,R.jsxs)(d,{type:`submit`,variant:`primary`,disabled:t||!D,children:[(0,R.jsx)(m,{"aria-hidden":`true`}),t?r===`desktop`?`Starting…`:`Opening…`:`Start recording`]})]}),te&&(0,R.jsxs)(`button`,{type:`button`,"aria-expanded":S,onClick:()=>ee(!S),className:`inline-flex cursor-pointer items-center gap-1 self-start border-0 bg-transparent p-0 text-[13px] text-muted hover:text-ink`,children:[(0,R.jsx)(O,{size:14,"aria-hidden":`true`,className:x(`transition-transform`,S&&`rotate-180`)}),`More options`,!S&&(p||v||E||g&&g!==e.environment)?(0,R.jsx)(`span`,{className:`text-accent-fg`,children:`· set`}):null]}),(0,R.jsx)(y,{open:S,children:(0,R.jsxs)(`div`,{className:`grid gap-3 rounded-[12px] bg-surface-muted p-3 @2xl:grid-cols-2`,children:[r===`web`&&e.blocks.length>0&&(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium`,children:[`Start from a block `,(0,R.jsx)(`span`,{className:`-mt-1 text-[12.5px] font-normal text-muted`,children:`Its steps are done for you first, then you record the rest.`}),(0,R.jsxs)(M,{value:C,onChange:e=>w(e.target.value),children:[(0,R.jsx)(`option`,{value:``,children:`No block: start on the page`}),e.blocks.map(e=>(0,R.jsxs)(`option`,{value:e.id,children:[e.name,` · `,e.steps,` `,e.steps===1?`step`:`steps`]},e.id))]})]}),r===`web`&&(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium`,children:[`Test case `,(0,R.jsx)(`span`,{className:`-mt-1 text-[12.5px] font-normal text-muted`,children:`Its steps are listed while you record; each one you do is tied to it.`}),(0,R.jsx)(T,{value:p,spellCheck:!1,placeholder:`SHOP-12, ado:1234 or a file`,onChange:e=>h(e.target.value),className:`bg-bg`})]}),e.environments.length>1&&(r===`desktop`||!!c)&&(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium`,children:[`Environment`,(0,R.jsx)(M,{value:g,onChange:e=>_(e.target.value),children:e.environments.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))})]}),r===`web`&&e.logins.length>0&&(0,R.jsxs)(`div`,{className:`flex items-center gap-3 @2xl:col-span-2`,children:[(0,R.jsx)(fe,{checked:v,onChange:b,label:`Start signed in`}),(0,R.jsxs)(`span`,{className:`flex flex-col`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium`,children:`Start signed in`}),(0,R.jsxs)(`span`,{className:`text-[12.5px] text-muted`,children:[`With the saved sign-ins (`,e.logins.join(`, `),`). Off: the sign-in is recorded too, its password saved as a variable name, never as typed.`]})]})]})]})}),(0,R.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:r===`desktop`?`The app starts on this computer; do the steps in it. It is saved as a workflow that replays with no model.`:`A browser opens on this computer: do the steps, then choose the checks and the test data here, and the Coding agent writes the test.`})]})}var W=20;function He({rows:e,onReview:t}){let[n,r]=(0,L.useState)(``),[s,c]=(0,L.useState)(``),[l,p]=(0,L.useState)(`all`),[m,h]=(0,L.useState)(0);if((0,L.useEffect)(()=>h(0),[s,l]),!e.length)return null;let g=s.toLowerCase().split(/\s+/).filter(Boolean),_=e.filter(e=>g.every(t=>`${e.name} ${e.caseId||``} ${e.app||``} ${e.startUrl}`.toLowerCase().includes(t))),v=l===`all`?_:_.filter(e=>e.kind===l),y=v.slice(m*W,m*W+W),x=e.some(e=>e.kind===`desktop`)&&e.some(e=>e.kind===`web`);return(0,R.jsxs)(`section`,{"aria-labelledby":`rec-list`,className:`flex min-w-0 flex-col gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`h2`,{id:`rec-list`,className:`sr-only`,children:`Recordings`}),(0,R.jsx)(ae,{id:`rec-search`,label:`Find a recording`,value:s,onChange:c}),x&&(0,R.jsx)(ye,{items:[{id:`all`,label:`All`,n:_.length},{id:`web`,label:`Web`,n:_.filter(e=>e.kind===`web`).length},{id:`desktop`,label:`Desktop`,n:_.filter(e=>e.kind===`desktop`).length}],value:l,onChange:p})]}),n&&(0,R.jsx)(`p`,{className:`m-0 text-[13px] text-fail`,children:n}),(0,R.jsxs)(`div`,{className:`rounded-[14px] card border`,children:[(0,R.jsxs)(`ul`,{className:`m-0 list-none p-1.5`,children:[y.length===0&&(0,R.jsx)(`li`,{className:`px-3 py-4 text-sm text-muted`,children:`Nothing matches.`}),y.map((e,n)=>{let s=F(e.startedAt);return(0,R.jsxs)(`li`,{className:`contents`,children:[(n===0||F(y[n-1].startedAt)!==s)&&(0,R.jsx)(`span`,{className:`block px-3 pt-3 pb-1 text-[12px] font-semibold text-muted`,children:s}),(0,R.jsxs)(`div`,{className:`grid min-h-12 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-3 rounded-[10px] px-3 py-1.5 hover:bg-surface-muted`,children:[e.ok?(0,R.jsx)(a,{size:16,"aria-label":`Recorded`,className:`text-pass`}):(0,R.jsx)(f,{size:16,"aria-label":`Not recorded`,className:`text-fail`}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.kind===`desktop`?(0,R.jsx)(u,{icon:le,size:13,className:`flex-none text-muted`,label:`Desktop app`}):(0,R.jsx)(u,{icon:i,size:13,className:`flex-none text-muted`,label:`Web page`}),(0,R.jsx)(`span`,{className:`truncate text-[14px] font-medium`,"data-tip":e.name,children:e.name})]}),(0,R.jsx)(`span`,{className:`truncate text-[12px] text-muted`,children:[C(e.steps,`step`),C(e.checks,`check`),e.caseId,e.app,De(e.startedAt)].filter(Boolean).join(` · `)})]}),(0,R.jsxs)(`span`,{className:`flex flex-none items-center gap-1`,children:[e.trace&&e.kind===`desktop`&&(0,R.jsx)(d,{size:`sm`,variant:`ghost`,"aria-label":`Read the steps of ${e.name}`,"data-tip":`Read the steps`,onClick:async()=>r(await o(e.trace)),children:`Steps`}),e.report&&(0,R.jsx)(d,{size:`sm`,variant:`ghost`,"aria-label":`Open the report of ${e.name}`,"data-tip":`Open the report`,onClick:async()=>r(await o(e.report)),children:`Report`}),e.kind===`desktop`&&e.workflow&&(0,R.jsxs)(d,{size:`sm`,onClick:()=>Re(e.workflow).catch(e=>r(e.message)),children:[(0,R.jsx)(D,{"aria-hidden":`true`}),(0,R.jsx)(`span`,{className:`hidden @md:inline`,children:`Replay`})]}),e.kind===`web`&&e.ok&&(0,R.jsxs)(d,{size:`sm`,"aria-label":`Open ${e.name}`,onClick:()=>t(e.runDir),children:[(0,R.jsx)(b,{"aria-hidden":`true`}),(0,R.jsx)(`span`,{className:`hidden @md:inline`,children:`Open`})]}),e.kind===`web`&&e.ok&&(0,R.jsxs)(d,{size:`sm`,onClick:()=>Le(e.runDir).catch(e=>r(e.message)),children:[(0,R.jsx)(me,{"aria-hidden":`true`}),(0,R.jsx)(`span`,{className:`hidden @md:inline`,children:`Write a test`})]})]})]})]},e.runDir)})]}),(0,R.jsx)(de,{page:m,size:W,total:v.length,onPage:h,label:`Pages of recordings`})]})]})}function Ue({s:e}){let t=e.result;return!t||!(t.secrets.length+t.caseGaps.length+(t.notes??[]).length+t.skipped.length)?null:(0,R.jsxs)(`div`,{role:`status`,className:`flex flex-col gap-2 rounded-[12px] card border px-4 py-3 text-sm text-ink`,children:[(0,R.jsx)(`p`,{className:`m-0 font-semibold`,children:`Just recorded: worth knowing`}),t.secrets.length>0&&(0,R.jsxs)(`p`,{className:`m-0 text-ink-2`,children:[`The test reads`,` `,t.secrets.map((e,t)=>(0,R.jsxs)(`span`,{children:[t?`, `:``,(0,R.jsx)(`code`,{className:`font-mono text-[13px]`,children:e})]},e)),` `,`from the environment: what you typed there was not saved. Set `,t.secrets.length===1?`it`:`them`,` before the test runs.`]}),t.caseGaps.length>0&&(0,R.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-5 text-ink-2`,children:t.caseGaps.map(e=>(0,R.jsxs)(`li`,{children:[(0,R.jsxs)(`span`,{className:`font-medium text-warn`,children:[`No check for case step `,e.n]}),`: expects “`,e.expected,`”`]},e.n))}),(t.notes??[]).length>0&&(0,R.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-5 text-ink-2`,children:t.notes.map((e,t)=>(0,R.jsx)(`li`,{children:e},t))}),t.skipped.length>0&&(0,R.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-5 text-ink-2`,children:t.skipped.map((e,t)=>(0,R.jsxs)(`li`,{children:[`Not recorded: `,e.action,`: `,e.reason]},t))})]})}function G(){let[e,t]=(0,L.useState)(null),[r,i]=(0,L.useState)(null),[o,s]=(0,L.useState)(`new`),[c,l]=(0,L.useState)(``),[u,f]=(0,L.useState)(!1),p=(0,L.useCallback)(()=>{n.get().then(e=>{t(e),l(``)},e=>l(e.message))},[]);(0,L.useEffect)(p,[p]);let h=!!e?.session&&V.has(e.session.state);(0,L.useEffect)(()=>{if(!h)return;let e=setInterval(p,800);return()=>clearInterval(e)},[h,p]);let g=(0,L.useRef)(!1),_=e?.session;(0,L.useEffect)(()=>{h?g.current=!0:g.current&&_&&(g.current=!1,_.result?.ok&&_.kind===`web`&&i(_.runDir))},[h,_]);let v=async e=>{f(!0),l(``);try{t(await e())}catch(e){l(e.message)}finally{f(!1)}},y=(e,t)=>{i(null),window.scrollTo({top:0,behavior:`smooth`}),v(()=>n.start({more:{run:e,after:t}}))},S=e=>{i(e),window.scrollTo({top:0})},ee=!!_?.result&&(_.kind===`desktop`||!_.result.ok);return(0,R.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,R.jsx)(j,{}),(0,R.jsxs)(`main`,{className:x(Ee,`@container flex-auto gap-4`),children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,R.jsx)(Se,{pixel:ie.record,size:`lg`}),(0,R.jsx)(`h1`,{className:`m-0 flex-1 text-[26px] font-semibold tracking-[-0.01em]`,children:`Record`}),e&&!h&&!r&&(0,R.jsx)(`div`,{role:`tablist`,"aria-label":`Record`,className:`flex gap-1 rounded-[10px] bg-surface-strong p-1`,children:[[`new`,`New recording`,m],[`recordings`,`Recordings${e.recordings.length?` (${e.recordings.length})`:``}`,b]].map(([e,t,n])=>(0,R.jsxs)(`button`,{type:`button`,role:`tab`,id:`rec-tab-${e}`,"aria-selected":o===e,"aria-controls":`rec-panel`,onClick:()=>s(e),className:x(`inline-flex min-h-8 cursor-pointer items-center gap-1.5 rounded-[7px] border-0 px-3 text-sm font-medium`,o===e?`bg-bg text-ink shadow-sm`:`bg-transparent text-muted hover:text-ink`),children:[(0,R.jsx)(n,{size:14,"aria-hidden":`true`}),t]},e))})]}),!r&&(0,R.jsx)(`p`,{className:`m-0 max-w-[74ch] text-sm leading-relaxed text-ink-2`,children:`Do a test's steps yourself in a browser or a Windows app ForgeQE opens; each click, entry and choice is recorded in order, and you choose the checks after.`}),c&&(0,R.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:c}),!e&&!c&&(0,R.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),e&&_&&h&&(0,R.jsx)(U,{s:_,busy:u,send:e=>void v(()=>n.command(e))}),e&&!h&&r&&(0,R.jsx)(Ne,{runDir:r,notices:_&&_.runDir===r?(0,R.jsx)(Ue,{s:_}):void 0,onRecordMore:e=>y(r,e),onClose:()=>{i(null),s(`recordings`),p()}},r),e&&!h&&!r&&(0,R.jsxs)(`div`,{role:`tabpanel`,id:`rec-panel`,"aria-labelledby":`rec-tab-${o}`,className:`flex min-w-0 flex-col gap-4`,children:[o===`new`&&(0,R.jsxs)(R.Fragment,{children:[ee&&(0,R.jsx)(Be,{s:_}),_?.result?.ok&&_.kind===`web`&&(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-[12px] card border px-4 py-3 text-sm`,children:[(0,R.jsx)(a,{size:16,"aria-hidden":`true`,className:`flex-none text-pass`}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-[1_1_240px] [overflow-wrap:anywhere]`,children:[`Last recorded: `,(0,R.jsx)(`strong`,{className:`font-semibold`,children:_.name}),(0,R.jsxs)(`span`,{className:`text-muted`,children:[` · `,C(_.steps.length,`step`)]})]}),(0,R.jsx)(d,{size:`sm`,onClick:()=>S(_.runDir),children:`Open`})]}),(0,R.jsx)(Ve,{view:e,busy:u,onStart:e=>void v(()=>n.start(e))})]}),o===`recordings`&&(e.recordings.length?(0,R.jsx)(He,{rows:e.recordings,onReview:S}):(0,R.jsx)(ne,{className:`py-4`,children:`No recordings yet: start one on the New recording tab.`}))]})]})]})}export{G as Record};