@smartmemory/compose 0.3.2-beta → 0.3.4-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{App-DR9pCiNE.js → App-BG92y_CY.js} +5 -5
- package/dist/assets/{abnfDiagram-VRR7QNED-CZ6p2bRe.js → abnfDiagram-VRR7QNED-Bip6cMjP.js} +1 -1
- package/dist/assets/{arc-6j04LBqn.js → arc-CyMTM07c.js} +1 -1
- package/dist/assets/{architectureDiagram-ZJ3FMSHR-00QM3pmc.js → architectureDiagram-ZJ3FMSHR-BukV0CJw.js} +1 -1
- package/dist/assets/{blockDiagram-677ZJIJ3-BUb9Kjfd.js → blockDiagram-677ZJIJ3-Bjb_MNB4.js} +1 -1
- package/dist/assets/{browser-CvETNQNv.js → browser-BSM23If2.js} +1 -1
- package/dist/assets/{c4Diagram-LMCZKHZV-D1PkhmSm.js → c4Diagram-LMCZKHZV-CUmTCrMW.js} +1 -1
- package/dist/assets/channel-BzkmtaLy.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-CduDdMf4.js → chunk-2Q5K7J3B-Cyvi1AFH.js} +1 -1
- package/dist/assets/{chunk-32BRIVSS-CH8Kj5rh.js → chunk-32BRIVSS-B1y5FpOd.js} +1 -1
- package/dist/assets/{chunk-5VM5RSS4-Cfts6Lix.js → chunk-5VM5RSS4-Qw-L7OoJ.js} +1 -1
- package/dist/assets/{chunk-EX3LRPZG-Dguk4yKZ.js → chunk-EX3LRPZG-G_MZEji_.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-DbCJp6t9.js → chunk-JWPE2WC7-DQFs7gjy.js} +1 -1
- package/dist/assets/{chunk-MOJQB5TN-CNjM_9_U.js → chunk-MOJQB5TN-CQZQYMcz.js} +1 -1
- package/dist/assets/{chunk-RYQCIY6F-D4k-BUbh.js → chunk-RYQCIY6F-CmAda4sZ.js} +1 -1
- package/dist/assets/{chunk-V7JOEXUC-O1sFoHf1.js → chunk-V7JOEXUC-CbjBz-Ek.js} +1 -1
- package/dist/assets/{chunk-VR4S4FIN-CGbSXVPL.js → chunk-VR4S4FIN-Dvhgnm7E.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-iIelV7SO.js → chunk-XXDRQBXY-CSdt06Hp.js} +1 -1
- package/dist/assets/classDiagram-OUVF2IWQ-BIvLcbex.js +1 -0
- package/dist/assets/classDiagram-v2-EOCWNBFH-BIvLcbex.js +1 -0
- package/dist/assets/{cose-bilkent-JH36ORCC-BKmPLgw2.js → cose-bilkent-JH36ORCC-G8l05tXy.js} +1 -1
- package/dist/assets/{cynefin-VYW2F7L2-CmT6ieC5.js → cynefin-VYW2F7L2-C3n1PNJC.js} +1 -1
- package/dist/assets/{cynefinDiagram-TSTJHNR4-Hn2vSVOw.js → cynefinDiagram-TSTJHNR4-C8N_CvKJ.js} +1 -1
- package/dist/assets/{dagre-VKFMJZFB-B0ifIwlU.js → dagre-VKFMJZFB-B2pkwDhN.js} +1 -1
- package/dist/assets/{diagram-FQU43EPY-BuCDB-JG.js → diagram-FQU43EPY-DPHD_t-1.js} +1 -1
- package/dist/assets/{diagram-G47NLZAW-D5avTZAQ.js → diagram-G47NLZAW-DGmHIZRr.js} +1 -1
- package/dist/assets/{diagram-NH7WQ7WH-24QCIgpj.js → diagram-NH7WQ7WH-BlLWwKVt.js} +1 -1
- package/dist/assets/{diagram-OA4YK3LP-A-bbUTK3.js → diagram-OA4YK3LP-DEv704Re.js} +1 -1
- package/dist/assets/{diagram-WEI45ONY-BIMDm-Kj.js → diagram-WEI45ONY-Bj6PGUCe.js} +1 -1
- package/dist/assets/{ebnfDiagram-CCIWWBDH-DCXMfG-M.js → ebnfDiagram-CCIWWBDH-Ch-icksT.js} +1 -1
- package/dist/assets/{erDiagram-Q63AITRT-BlDrG0Ev.js → erDiagram-Q63AITRT-CI3lwEFA.js} +1 -1
- package/dist/assets/{flowDiagram-23GEKE2U-aTyazY6P.js → flowDiagram-23GEKE2U-DcUANpAz.js} +1 -1
- package/dist/assets/{ganttDiagram-NO4QXBWP-Bxo-a80f.js → ganttDiagram-NO4QXBWP-Cy0Ie8KS.js} +1 -1
- package/dist/assets/{gitGraphDiagram-IHSO6WYX-COhKb9wR.js → gitGraphDiagram-IHSO6WYX-BswI52az.js} +1 -1
- package/dist/assets/{graph--wGAvskB.js → graph-BXPQrYYB.js} +1 -1
- package/dist/assets/{index-BcmsQZX-.js → index-B1H7-G2y.js} +5 -5
- package/dist/assets/{infoDiagram-FWYZ7A6U-DLCbpinV.js → infoDiagram-FWYZ7A6U-BBunqvr-.js} +1 -1
- package/dist/assets/{ishikawaDiagram-FXEZZL3T-eyHF7GIj.js → ishikawaDiagram-FXEZZL3T-Hm4zSDlM.js} +1 -1
- package/dist/assets/{journeyDiagram-5HDEW3XC-BsVocmlw.js → journeyDiagram-5HDEW3XC-CIqcTFuO.js} +1 -1
- package/dist/assets/{kanban-definition-HUTT4EX6-CaFPSZxY.js → kanban-definition-HUTT4EX6-CB9jCXj_.js} +1 -1
- package/dist/assets/{linear-cqnI_wgW.js → linear-CsXqv70E.js} +1 -1
- package/dist/assets/{mindmap-definition-LN4V7U3C-B66BGqKn.js → mindmap-definition-LN4V7U3C-CpqH5F_P.js} +1 -1
- package/dist/assets/{mobile-PV1zQVwv.js → mobile-CaoXUwAr.js} +1 -1
- package/dist/assets/{pegDiagram-2B236MQR-F6IN0_L5.js → pegDiagram-2B236MQR-HpQyrDcm.js} +1 -1
- package/dist/assets/{pieDiagram-ENE6RG2P-D5nOQxpo.js → pieDiagram-ENE6RG2P-xkcpHwnY.js} +1 -1
- package/dist/assets/{quadrantDiagram-ABIIQ3AL-DwUAYbMO.js → quadrantDiagram-ABIIQ3AL-kebZIOmu.js} +1 -1
- package/dist/assets/{railroadDiagram-RFXS5EU6-Cvmlah5P.js → railroadDiagram-RFXS5EU6-DNvGwWm9.js} +1 -1
- package/dist/assets/{requirementDiagram-TGXJPOKE-DoUtsFnL.js → requirementDiagram-TGXJPOKE-D1lG1P7h.js} +1 -1
- package/dist/assets/{sankeyDiagram-HTMAVEWB-D4XTwiKp.js → sankeyDiagram-HTMAVEWB-DOEEcn52.js} +1 -1
- package/dist/assets/{sequenceDiagram-DBY2YBRQ-CiG9yRIR.js → sequenceDiagram-DBY2YBRQ-DynIVCk_.js} +1 -1
- package/dist/assets/{sizeCapture-X5ZJPWSS-zd7ydQ_Y.js → sizeCapture-X5ZJPWSS-DJXFjUUL.js} +1 -1
- package/dist/assets/{stateDiagram-2N3HPSRC-BZesBHQ4.js → stateDiagram-2N3HPSRC-OZ7trFh5.js} +1 -1
- package/dist/assets/stateDiagram-v2-6OUMAXLB-GcPRHAJT.js +1 -0
- package/dist/assets/{swimlanes-5IMT3BWC-Bg8exSE7.js → swimlanes-5IMT3BWC-DULYAFmB.js} +2 -2
- package/dist/assets/swimlanesDiagram-G3AALYLV-BB0gCy01.js +8 -0
- package/dist/assets/{timeline-definition-FHXFAJF6-TKj_HY9k.js → timeline-definition-FHXFAJF6-CzqqUDvt.js} +1 -1
- package/dist/assets/{vennDiagram-L72KCM5P-CJf-bqn0.js → vennDiagram-L72KCM5P-CdKmtcFL.js} +1 -1
- package/dist/assets/{wardleyDiagram-EHGQE667-CqizSfCL.js → wardleyDiagram-EHGQE667-DknGwjCA.js} +1 -1
- package/dist/assets/{xychartDiagram-FW5EYKEG-CK-OErMM.js → xychartDiagram-FW5EYKEG-DdYyKfQ3.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/dist/assets/channel-BcWZM2KA.js +0 -1
- package/dist/assets/classDiagram-OUVF2IWQ-Ce7YjlIK.js +0 -1
- package/dist/assets/classDiagram-v2-EOCWNBFH-Ce7YjlIK.js +0 -1
- package/dist/assets/stateDiagram-v2-6OUMAXLB-BnlLOJzB.js +0 -1
- package/dist/assets/swimlanesDiagram-G3AALYLV-DZMVxqbs.js +0 -8
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dagre-VKFMJZFB-
|
|
2
|
-
var ON=Object.defineProperty;var $N=(e,t,r)=>t in e?ON(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var st=(e,t,r)=>$N(e,typeof t!="symbol"?t+"":t,r);import{a as C,j as c,d as Ge,i as w1,e as v1,f as DN,g as lm,w as _e,h as PN,v as S1,k as rn,n as lt,l as RN,m as zN,P as px,o as qN,N as WN}from"./mobile-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dagre-VKFMJZFB-B2pkwDhN.js","assets/chunk-RYQCIY6F-CmAda4sZ.js","assets/graph-C9eacEi8.js","assets/map-Czzmt4hB.js","assets/layout-DEXfKzaS.js","assets/mobile-CaoXUwAr.js","assets/mobile-1gVCT0OK.css","assets/index-B1H7-G2y.js","assets/index-LIwREYgH.css","assets/graph-BXPQrYYB.js","assets/swimlanes-5IMT3BWC-DULYAFmB.js","assets/cose-bilkent-JH36ORCC-G8l05tXy.js","assets/c4Diagram-LMCZKHZV-CUmTCrMW.js","assets/chunk-32BRIVSS-B1y5FpOd.js","assets/flowDiagram-23GEKE2U-DcUANpAz.js","assets/chunk-5VM5RSS4-Qw-L7OoJ.js","assets/chunk-XXDRQBXY-CSdt06Hp.js","assets/chunk-VR4S4FIN-Dvhgnm7E.js","assets/channel-BzkmtaLy.js","assets/swimlanesDiagram-G3AALYLV-BB0gCy01.js","assets/erDiagram-Q63AITRT-CI3lwEFA.js","assets/gitGraphDiagram-IHSO6WYX-BswI52az.js","assets/chunk-2Q5K7J3B-Cyvi1AFH.js","assets/chunk-JWPE2WC7-DQFs7gjy.js","assets/cynefin-VYW2F7L2-C3n1PNJC.js","assets/ganttDiagram-NO4QXBWP-Cy0Ie8KS.js","assets/linear-CsXqv70E.js","assets/init-Gi6I4Gst.js","assets/defaultLocale-DX6XiGOO.js","assets/infoDiagram-FWYZ7A6U-BBunqvr-.js","assets/pieDiagram-ENE6RG2P-xkcpHwnY.js","assets/arc-CyMTM07c.js","assets/ordinal-Cboi1Yqb.js","assets/quadrantDiagram-ABIIQ3AL-kebZIOmu.js","assets/xychartDiagram-FW5EYKEG-DdYyKfQ3.js","assets/requirementDiagram-TGXJPOKE-D1lG1P7h.js","assets/sequenceDiagram-DBY2YBRQ-DynIVCk_.js","assets/classDiagram-OUVF2IWQ-BIvLcbex.js","assets/chunk-V7JOEXUC-CbjBz-Ek.js","assets/classDiagram-v2-EOCWNBFH-BIvLcbex.js","assets/stateDiagram-2N3HPSRC-OZ7trFh5.js","assets/chunk-EX3LRPZG-G_MZEji_.js","assets/stateDiagram-v2-6OUMAXLB-GcPRHAJT.js","assets/journeyDiagram-5HDEW3XC-CIqcTFuO.js","assets/timeline-definition-FHXFAJF6-CzqqUDvt.js","assets/mindmap-definition-LN4V7U3C-CpqH5F_P.js","assets/kanban-definition-HUTT4EX6-CB9jCXj_.js","assets/sankeyDiagram-HTMAVEWB-DOEEcn52.js","assets/diagram-NH7WQ7WH-BlLWwKVt.js","assets/diagram-WEI45ONY-Bj6PGUCe.js","assets/blockDiagram-677ZJIJ3-Bjb_MNB4.js","assets/diagram-OA4YK3LP-DEv704Re.js","assets/architectureDiagram-ZJ3FMSHR-BukV0CJw.js","assets/diagram-FQU43EPY-DPHD_t-1.js","assets/ishikawaDiagram-FXEZZL3T-Hm4zSDlM.js","assets/vennDiagram-L72KCM5P-CdKmtcFL.js","assets/diagram-G47NLZAW-DGmHIZRr.js","assets/wardleyDiagram-EHGQE667-DknGwjCA.js","assets/cynefinDiagram-TSTJHNR4-C8N_CvKJ.js","assets/railroadDiagram-RFXS5EU6-DNvGwWm9.js","assets/chunk-MOJQB5TN-CQZQYMcz.js","assets/ebnfDiagram-CCIWWBDH-Ch-icksT.js","assets/abnfDiagram-VRR7QNED-Bip6cMjP.js","assets/pegDiagram-2B236MQR-HpQyrDcm.js","assets/browser-BSM23If2.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var ON=Object.defineProperty;var $N=(e,t,r)=>t in e?ON(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var st=(e,t,r)=>$N(e,typeof t!="symbol"?t+"":t,r);import{a as C,j as c,d as Ge,i as w1,e as v1,f as DN,g as lm,w as _e,h as PN,v as S1,k as rn,n as lt,l as RN,m as zN,P as px,o as qN,N as WN}from"./mobile-CaoXUwAr.js";import{c as ve,a as ne,b as HN,P as ou,d as Vi,u as Fo,e as Oo,f as UN,g as Pi,h as YN,I as cm,B as Fe,X as jr,i as T1,_ as Ue,j as hm,D as yo,k as bo,l as ko,m as Co,n as sl,o as um,r as VN,p as _1}from"./index-B1H7-G2y.js";import{c as cs,b as dm,f as GN}from"./graph-BXPQrYYB.js";/**
|
|
3
3
|
* @license lucide-react v0.563.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
@@ -807,8 +807,8 @@ Please report this to https://github.com/markedjs/marked.`,t){let i="<p>An error
|
|
|
807
807
|
L0,20`)},"requirement_arrow"),WW=v((e,t,r)=>{const n=vt(),{themeVariables:i}=n,{strokeWidth:s}=i;e.append("defs").append("marker").attr("id",r+"_"+t+"-requirement_arrowEnd").attr("refX",20).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").attr("markerUnits","userSpaceOnUse").attr("stroke-width",`${s}`).attr("viewBox","0 0 25 20").append("path").attr("d",`M0,0
|
|
808
808
|
L20,10
|
|
809
809
|
M20,10
|
|
810
|
-
L0,20`).attr("stroke-linejoin","miter")},"requirement_arrow_neo"),HW=v((e,t,r)=>{const n=e.append("defs").append("marker").attr("id",r+"_"+t+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").append("g");n.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),n.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),n.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10)},"requirement_contains"),UW=v((e,t,r)=>{const n=vt(),{themeVariables:i}=n,{strokeWidth:s}=i,o=e.append("defs").append("marker").attr("id",r+"_"+t+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").attr("markerUnits","userSpaceOnUse").append("g");o.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),o.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),o.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10),o.selectAll("*").attr("stroke-width",`${s}`)},"requirement_contains_neo"),YW={extension:SW,composition:TW,aggregation:_W,dependency:jW,lollipop:NW,point:EW,circle:AW,cross:LW,barb:BW,barbNeo:MW,only_one:IW,zero_or_one:FW,one_or_more:OW,zero_or_more:$W,only_one_neo:DW,zero_or_one_neo:PW,one_or_more_neo:RW,zero_or_more_neo:zW,requirement_arrow:qW,requirement_contains:HW,requirement_arrow_neo:WW,requirement_contains_neo:UW},VW=vW,GW={common:$l,getConfig:vt,insertCluster:Wq,insertEdge:wW,insertEdgeLabel:mW,insertMarkers:VW,insertNode:$_,interpolateToCurve:Pg,labelHelper:$e,log:oe,positionEdgeLabel:gW},wl={},z_=v(e=>{for(const t of e)wl[t.name]=t},"registerLayoutLoaders"),XW=v(()=>{z_([{name:"dagre",loader:v(async()=>await Ue(()=>import("./dagre-VKFMJZFB-B0ifIwlU.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])),"loader")},{name:"swimlane",loader:v(async()=>await Ue(()=>import("./swimlanes-5IMT3BWC-Bg8exSE7.js"),__vite__mapDeps([10,7,5,6,8,1,2,3,9])),"loader")},{name:"cose-bilkent",loader:v(async()=>await Ue(()=>import("./cose-bilkent-JH36ORCC-BKmPLgw2.js"),__vite__mapDeps([11,9,5,6,7,8])),"loader")}])},"registerDefaultLayoutLoaders");XW();var Yee=v(async(e,t,r)=>{if(!(e.layoutAlgorithm in wl))throw new Error(`Unknown layout algorithm: ${e.layoutAlgorithm}`);if(e.diagramId)for(const d of e.nodes){const p=d.domId||d.id;d.domId=`${e.diagramId}-${p}`}const n=wl[e.layoutAlgorithm],i=await n.loader(),{theme:s,themeVariables:o}=e.config,{useGradient:a,gradientStart:l,gradientStop:h}=o,u=t.attr("id");if(t.append("defs").append("filter").attr("id",`${u}-drop-shadow`).attr("height","130%").attr("width","130%").append("feDropShadow").attr("dx","4").attr("dy","4").attr("stdDeviation",0).attr("flood-opacity","0.06").attr("flood-color",`${s!=null&&s.includes("dark")?"#FFFFFF":"#000000"}`),t.append("defs").append("filter").attr("id",`${u}-drop-shadow-small`).attr("height","150%").attr("width","150%").append("feDropShadow").attr("dx","2").attr("dy","2").attr("stdDeviation",0).attr("flood-opacity","0.06").attr("flood-color",`${s!=null&&s.includes("dark")?"#FFFFFF":"#000000"}`),a){const d=t.append("linearGradient").attr("id",t.attr("id")+"-gradient").attr("gradientUnits","objectBoundingBox").attr("x1","0%").attr("y1","0%").attr("x2","100%").attr("y2","0%");d.append("svg:stop").attr("offset","0%").attr("stop-color",l).attr("stop-opacity",1),d.append("svg:stop").attr("offset","100%").attr("stop-color",h).attr("stop-opacity",1)}return i.render(e,t,GW,{algorithm:n.algorithm},r)},"render"),Vee=v((e="",{fallback:t="dagre"}={})=>{if(e in wl)return e;if(t in wl)return oe.warn(`Layout algorithm ${e} is not registered. Using ${t} as fallback.`),t;throw new Error(`Both layout algorithms ${e} and ${t} are not registered.`)},"getRegisteredLayoutAlgorithm"),ox="comm",q_="rule",W_="decl",KW="@media",QW="@import",JW="@supports",ZW="@namespace",Yp="@keyframes",H_="@layer",eH="@scope",tH=Math.abs,tl=String.fromCharCode;function U_(e){return e.trim()}function Vp(e,t,r){return e.replace(t,r)}function to(e,t){return e.charCodeAt(t)|0}function Mo(e,t,r){return e.slice(t,r)}function mn(e){return e.length}function Y_(e){return e.length}function _c(e,t){return t.push(e),e}var Uu=1,Io=1,V_=0,Yr=0,Bt=0,Xo="";function ax(e,t,r,n,i,s,o,a){return{value:e,root:t,parent:r,type:n,props:i,children:s,line:Uu,column:Io,length:o,return:"",siblings:a}}function rH(){return Bt}function nH(){return Bt=Yr>0?to(Xo,--Yr):0,Io--,Bt===10&&(Io=1,Uu--),Bt}function on(){return Bt=Yr<V_?to(Xo,Yr++):0,Io++,Bt===10&&(Io=1,Uu++),Bt}function hi(){return to(Xo,Yr)}function rh(){return Yr}function Yu(e,t){return Mo(Xo,e,t)}function vl(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function iH(e){return Uu=Io=1,V_=mn(Xo=e),Yr=0,[]}function sH(e){return Xo="",e}function nf(e){return U_(Yu(Yr-1,Gp(e===91?e+2:e===40?e+1:e)))}function oH(e){for(;(Bt=hi())&&Bt<33;)on();return vl(e)>2||vl(Bt)>3?"":" "}function aH(e,t){for(;--t&&on()&&!(Bt<48||Bt>102||Bt>57&&Bt<65||Bt>70&&Bt<97););return Yu(e,rh()+(t<6&&hi()==32&&on()==32))}function Gp(e){for(;on();)switch(Bt){case e:return Yr;case 34:case 39:e!==34&&e!==39&&Gp(Bt);break;case 40:e===41&&Gp(e);break;case 92:on();break}return Yr}function lH(e,t){for(;on()&&e+Bt!==57;)if(e+Bt===84&&hi()===47)break;return"/*"+Yu(t,Yr-1)+"*"+tl(e===47?e:on())}function cH(e){for(;!vl(hi());)on();return Yu(e,Yr)}function hH(e){return sH(nh("",null,null,null,[""],e=iH(e),0,[0],e))}function nh(e,t,r,n,i,s,o,a,l){for(var h=0,u=0,d=o,p=0,f=0,m=0,g=1,x=1,y=1,k=0,b=0,w="",T=i,S=s,j=n,E=w;x;)switch(m=b,b=on()){case 40:m!=108&&to(E,d-1)==58?(k++,E+="("):E+=nf(b);break;case 41:k--,E+=")";break;case 34:case 39:case 91:E+=nf(b);break;case 9:case 10:case 13:case 32:if(k>0){E+=tl(b);break}E+=oH(m);break;case 92:E+=aH(rh()-1,7);continue;case 47:switch(hi()){case 42:case 47:_c(uH(lH(on(),rh()),t,r,l),l),(vl(m||1)==5||vl(hi()||1)==5)&&mn(E)&&Mo(E,-1,void 0)!==" "&&(E+=" ");break;default:E+="/"}break;case 123*g:a[h++]=mn(E)*y;case 125*g:case 59:case 0:if(k>0&&b){E+=tl(b);break}switch(b){case 0:case 125:x=0;case 59+u:y==-1&&(E=Vp(E,/\f/g,"")),f>0&&(mn(E)-d||g===0)&&_c(f>32?kb(E+";",n,r,d-1,l):kb(Vp(E," ","")+";",n,r,d-2,l),l);break;case 59:E+=";";default:if(_c(j=bb(E,t,r,h,u,i,a,w,T=[],S=[],d,s),s),b===123)if(u===0)nh(E,t,j,j,T,s,d,a,S);else{switch(p){case 99:if(to(E,3)===110)break;case 108:if(to(E,2)===97)break;default:u=0;case 100:case 109:case 115:}u?nh(e,j,j,n&&_c(bb(e,j,j,0,0,i,a,w,i,T=[],d,S),S),i,S,d,a,n?T:S):nh(E,j,j,j,[""],S,0,a,S)}}h=u=f=0,g=y=1,w=E="",d=o;break;case 58:d=1+mn(E),f=m;default:if(g<1){if(b==123)--g;else if(b==125&&g++==0&&nH()==125)continue}switch(E+=tl(b),b*g){case 38:y=u>0?1:(E+="\f",-1);break;case 44:if(k>0)break;a[h++]=(mn(E)-1)*y,y=1;break;case 64:hi()===45&&(E+=nf(on())),p=hi(),u=d=mn(w=E+=cH(rh())),b++;break;case 45:m===45&&mn(E)==2&&(g=0)}}return s}function bb(e,t,r,n,i,s,o,a,l,h,u,d){for(var p=i-1,f=i===0?s:[""],m=Y_(f),g=0,x=0,y=0;g<n;++g)for(var k=0,b=Mo(e,p+1,p=tH(x=o[g])),w=e;k<m;++k)(w=U_(x>0?f[k]+" "+b:Vp(b,/&\f/g,f[k])))&&(l[y++]=w);return ax(e,t,r,i===0?q_:a,l,h,u,d)}function uH(e,t,r,n){return ax(e,t,r,ox,tl(rH()),Mo(e,2,-2),0,n)}function kb(e,t,r,n,i){return ax(e,t,r,W_,Mo(e,0,n),Mo(e,n+1,-1),n,i)}function Xp(e,t){for(var r="",n=0;n<e.length;n++)r+=t(e[n],n,e,t)||"";return r}function dH(e,t,r,n){switch(e.type){case H_:if(e.children.length)break;case QW:case ZW:case W_:return e.return=e.return||e.value;case ox:return"";case Yp:return e.return=e.value+"{"+Xp(e.children,n)+"}";case q_:if(!mn(e.value=e.props.join(",")))return""}return mn(r=Xp(e.children,n))?e.return=e.value+"{"+r+"}":""}function fH(e){var t=Y_(e);return function(r,n,i,s){for(var o="",a=0;a<t;a++)o+=e[a](r,n,i,s)||"";return o}}var G_="c4",pH=v(e=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(e),"detector"),mH=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./c4Diagram-LMCZKHZV-D1PkhmSm.js");return{diagram:t}},__vite__mapDeps([12,13,5,6,7,8,9]));return{id:G_,diagram:e}},"loader"),gH={id:G_,detector:pH,loader:mH},xH=gH,X_="flowchart",yH=v((e,t)=>{var r,n;return((r=t==null?void 0:t.flowchart)==null?void 0:r.defaultRenderer)==="dagre-wrapper"||((n=t==null?void 0:t.flowchart)==null?void 0:n.defaultRenderer)==="elk"?!1:/^\s*graph/.test(e)},"detector"),bH=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./flowDiagram-23GEKE2U-aTyazY6P.js").then(r=>r.f);return{diagram:t}},__vite__mapDeps([14,15,16,17,13,18]));return{id:X_,diagram:e}},"loader"),kH={id:X_,detector:yH,loader:bH},CH=kH,K_="flowchart-v2",wH=v((e,t)=>{var r,n,i;return((r=t==null?void 0:t.flowchart)==null?void 0:r.defaultRenderer)==="dagre-d3"?!1:(((n=t==null?void 0:t.flowchart)==null?void 0:n.defaultRenderer)==="elk"&&(t.layout="elk"),/^\s*graph/.test(e)&&((i=t==null?void 0:t.flowchart)==null?void 0:i.defaultRenderer)==="dagre-wrapper"?!0:/^\s*flowchart/.test(e))},"detector"),vH=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./flowDiagram-23GEKE2U-aTyazY6P.js").then(r=>r.f);return{diagram:t}},__vite__mapDeps([14,15,16,17,13,18]));return{id:K_,diagram:e}},"loader"),SH={id:K_,detector:wH,loader:vH},TH=SH,Q_="swimlane",_H=v(e=>/^\s*swimlane-beta\b/.test(e),"detector"),jH=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./swimlanesDiagram-G3AALYLV-DZMVxqbs.js");return{diagram:t}},__vite__mapDeps([19,14,15,16,17,13,18,5,6,7,8,9]));return{id:Q_,diagram:e}},"loader"),NH={id:Q_,detector:_H,loader:jH},EH=NH,J_="er",AH=v(e=>/^\s*erDiagram/.test(e),"detector"),LH=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./erDiagram-Q63AITRT-BlDrG0Ev.js");return{diagram:t}},__vite__mapDeps([20,16,17,18,5,6,7,8,9]));return{id:J_,diagram:e}},"loader"),BH={id:J_,detector:AH,loader:LH},MH=BH,Z_="gitGraph",IH=v(e=>/^\s*gitGraph/.test(e),"detector"),FH=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./gitGraphDiagram-IHSO6WYX-COhKb9wR.js");return{diagram:t}},__vite__mapDeps([21,22,23,24,7,5,6,8,9]));return{id:Z_,diagram:e}},"loader"),OH={id:Z_,detector:IH,loader:FH},$H=OH,ej="gantt",DH=v(e=>/^\s*gantt/.test(e),"detector"),PH=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./ganttDiagram-NO4QXBWP-Bxo-a80f.js");return{diagram:t}},__vite__mapDeps([25,5,6,26,27,28,7,8,9]));return{id:ej,diagram:e}},"loader"),RH={id:ej,detector:DH,loader:PH},zH=RH,tj="info",qH=v(e=>/^\s*info/.test(e),"detector"),WH=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./infoDiagram-FWYZ7A6U-DLCbpinV.js");return{diagram:t}},__vite__mapDeps([29,24,7,5,6,8,9]));return{id:tj,diagram:e}},"loader"),HH={id:tj,detector:qH,loader:WH},rj="pie",UH=v(e=>/^\s*pie/.test(e),"detector"),YH=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./pieDiagram-ENE6RG2P-D5nOQxpo.js");return{diagram:t}},__vite__mapDeps([30,23,24,7,5,6,8,31,32,27,9]));return{id:rj,diagram:e}},"loader"),VH={id:rj,detector:UH,loader:YH},nj="quadrantChart",GH=v(e=>/^\s*quadrantChart/.test(e),"detector"),XH=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./quadrantDiagram-ABIIQ3AL-DwUAYbMO.js");return{diagram:t}},__vite__mapDeps([33,26,27,28,5,6,7,8,9]));return{id:nj,diagram:e}},"loader"),KH={id:nj,detector:GH,loader:XH},QH=KH,ij="xychart",JH=v(e=>/^\s*xychart(-beta)?/.test(e),"detector"),ZH=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./xychartDiagram-FW5EYKEG-CK-OErMM.js");return{diagram:t}},__vite__mapDeps([34,27,32,26,28,5,6,7,8,9]));return{id:ij,diagram:e}},"loader"),eU={id:ij,detector:JH,loader:ZH},tU=eU,sj="requirement",rU=v(e=>/^\s*requirement(Diagram)?/.test(e),"detector"),nU=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./requirementDiagram-TGXJPOKE-DoUtsFnL.js");return{diagram:t}},__vite__mapDeps([35,16,17,5,6,7,8,9]));return{id:sj,diagram:e}},"loader"),iU={id:sj,detector:rU,loader:nU},sU=iU,oj="sequence",oU=v(e=>/^\s*sequenceDiagram/.test(e),"detector"),aU=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./sequenceDiagram-DBY2YBRQ-CiG9yRIR.js");return{diagram:t}},__vite__mapDeps([36,22,13,5,6,7,8,9]));return{id:oj,diagram:e}},"loader"),lU={id:oj,detector:oU,loader:aU},cU=lU,aj="class",hU=v((e,t)=>{var r;return((r=t==null?void 0:t.class)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!1:/^\s*classDiagram/.test(e)},"detector"),uU=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./classDiagram-OUVF2IWQ-Ce7YjlIK.js");return{diagram:t}},__vite__mapDeps([37,38,15,16,17,13,5,6,7,8,9]));return{id:aj,diagram:e}},"loader"),dU={id:aj,detector:hU,loader:uU},fU=dU,lj="classDiagram",pU=v((e,t)=>{var r;return/^\s*classDiagram/.test(e)&&((r=t==null?void 0:t.class)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!0:/^\s*classDiagram-v2/.test(e)},"detector"),mU=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./classDiagram-v2-EOCWNBFH-Ce7YjlIK.js");return{diagram:t}},__vite__mapDeps([39,38,15,16,17,13,5,6,7,8,9]));return{id:lj,diagram:e}},"loader"),gU={id:lj,detector:pU,loader:mU},xU=gU,cj="state",yU=v((e,t)=>{var r;return((r=t==null?void 0:t.state)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!1:/^\s*stateDiagram/.test(e)},"detector"),bU=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./stateDiagram-2N3HPSRC-BZesBHQ4.js");return{diagram:t}},__vite__mapDeps([40,41,16,17,13,2,4,3,5,6,7,8,9]));return{id:cj,diagram:e}},"loader"),kU={id:cj,detector:yU,loader:bU},CU=kU,hj="stateDiagram",wU=v((e,t)=>{var r;return!!(/^\s*stateDiagram-v2/.test(e)||/^\s*stateDiagram/.test(e)&&((r=t==null?void 0:t.state)==null?void 0:r.defaultRenderer)==="dagre-wrapper")},"detector"),vU=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./stateDiagram-v2-6OUMAXLB-BnlLOJzB.js");return{diagram:t}},__vite__mapDeps([42,41,16,17,13,5,6,7,8,9]));return{id:hj,diagram:e}},"loader"),SU={id:hj,detector:wU,loader:vU},TU=SU,uj="journey",_U=v(e=>/^\s*journey/.test(e),"detector"),jU=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./journeyDiagram-5HDEW3XC-BsVocmlw.js");return{diagram:t}},__vite__mapDeps([43,15,13,31,5,6,7,8,9]));return{id:uj,diagram:e}},"loader"),NU={id:uj,detector:_U,loader:jU},EU=NU,AU=v((e,t,r)=>{oe.debug(`rendering svg for syntax error
|
|
811
|
-
`);const n=sz(t),i=n.append("g");n.attr("viewBox","0 0 2412 512"),qw(n,100,512,!0),i.append("path").attr("class","error-icon").attr("d","m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z"),i.append("path").attr("class","error-icon").attr("d","m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z"),i.append("path").attr("class","error-icon").attr("d","m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z"),i.append("path").attr("class","error-icon").attr("d","m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z"),i.append("path").attr("class","error-icon").attr("d","m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z"),i.append("path").attr("class","error-icon").attr("d","m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z"),i.append("text").attr("class","error-text").attr("x",1440).attr("y",250).attr("font-size","150px").style("text-anchor","middle").text("Syntax error in text"),i.append("text").attr("class","error-text").attr("x",1250).attr("y",400).attr("font-size","100px").style("text-anchor","middle").text(`mermaid version ${r}`)},"draw"),dj={draw:AU},LU=dj,BU={db:{},renderer:dj,parser:{parse:v(()=>{},"parse")}},MU=BU,fj="flowchart-elk",IU=v((e,t={})=>{var r;return/^\s*flowchart-elk/.test(e)||/^\s*(flowchart|graph)/.test(e)&&((r=t==null?void 0:t.flowchart)==null?void 0:r.defaultRenderer)==="elk"?(t.layout="elk",!0):!1},"detector"),FU=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./flowDiagram-23GEKE2U-aTyazY6P.js").then(r=>r.f);return{diagram:t}},__vite__mapDeps([14,15,16,17,13,18]));return{id:fj,diagram:e}},"loader"),OU={id:fj,detector:IU,loader:FU},$U=OU,pj="timeline",DU=v(e=>/^\s*timeline/.test(e),"detector"),PU=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./timeline-definition-FHXFAJF6-TKj_HY9k.js");return{diagram:t}},__vite__mapDeps([44,31,5,6,7,8,9]));return{id:pj,diagram:e}},"loader"),RU={id:pj,detector:DU,loader:PU},zU=RU,mj="mindmap",qU=v(e=>/^\s*mindmap/.test(e),"detector"),WU=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./mindmap-definition-LN4V7U3C-B66BGqKn.js");return{diagram:t}},__vite__mapDeps([45,16,17,5,6,7,8,9]));return{id:mj,diagram:e}},"loader"),HU={id:mj,detector:qU,loader:WU},UU=HU,gj="kanban",YU=v(e=>/^\s*kanban/.test(e),"detector"),VU=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./kanban-definition-HUTT4EX6-CaFPSZxY.js");return{diagram:t}},__vite__mapDeps([46,15,5,6,7,8,9]));return{id:gj,diagram:e}},"loader"),GU={id:gj,detector:YU,loader:VU},XU=GU,xj="sankey",KU=v(e=>/^\s*sankey(-beta)?/.test(e),"detector"),QU=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./sankeyDiagram-HTMAVEWB-D4XTwiKp.js");return{diagram:t}},__vite__mapDeps([47,32,27,5,6,7,8,9]));return{id:xj,diagram:e}},"loader"),JU={id:xj,detector:KU,loader:QU},ZU=JU,yj="packet",eY=v(e=>/^\s*packet(-beta)?/.test(e),"detector"),tY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./diagram-NH7WQ7WH-24QCIgpj.js");return{diagram:t}},__vite__mapDeps([48,23,24,7,5,6,8,9]));return{id:yj,diagram:e}},"loader"),rY={id:yj,detector:eY,loader:tY},bj="radar",nY=v(e=>/^\s*radar-beta/.test(e),"detector"),iY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./diagram-WEI45ONY-BIMDm-Kj.js");return{diagram:t}},__vite__mapDeps([49,23,24,7,5,6,8,9]));return{id:bj,diagram:e}},"loader"),sY={id:bj,detector:nY,loader:iY},kj="block",oY=v(e=>/^\s*block(-beta)?/.test(e),"detector"),aY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./blockDiagram-677ZJIJ3-BUb9Kjfd.js");return{diagram:t}},__vite__mapDeps([50,15,2,18,5,6,7,8,9]));return{id:kj,diagram:e}},"loader"),lY={id:kj,detector:oY,loader:aY},cY=lY,Cj="treeView",hY=v(e=>/^\s*treeView-beta/.test(e),"detector"),uY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./diagram-OA4YK3LP-A-bbUTK3.js");return{diagram:t}},__vite__mapDeps([51,22,23,24,7,5,6,8,9]));return{id:Cj,diagram:e}},"loader"),dY={id:Cj,detector:hY,loader:uY},fY=dY,wj="architecture",pY=v(e=>/^\s*architecture/.test(e),"detector"),mY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./architectureDiagram-ZJ3FMSHR-00QM3pmc.js");return{diagram:t}},__vite__mapDeps([52,23,24,7,5,6,8,9]));return{id:wj,diagram:e}},"loader"),gY={id:wj,detector:pY,loader:mY},xY=gY,vj="eventmodeling",yY=v(e=>/^\s*eventmodeling/.test(e),"detector"),bY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./diagram-FQU43EPY-BuCDB-JG.js");return{diagram:t}},__vite__mapDeps([53,23,24,7,5,6,8,9]));return{id:vj,diagram:e}},"loader"),kY={id:vj,detector:yY,loader:bY},wY=kY,Sj="ishikawa",vY=v(e=>/^\s*ishikawa(-beta)?\b/i.test(e),"detector"),SY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./ishikawaDiagram-FXEZZL3T-eyHF7GIj.js");return{diagram:t}},__vite__mapDeps([54,5,6,7,8,9]));return{id:Sj,diagram:e}},"loader"),TY={id:Sj,detector:vY,loader:SY},Tj="venn",_Y=v(e=>/^\s*venn-beta/.test(e),"detector"),jY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./vennDiagram-L72KCM5P-CJf-bqn0.js");return{diagram:t}},__vite__mapDeps([55,5,6,7,8,9]));return{id:Tj,diagram:e}},"loader"),NY={id:Tj,detector:_Y,loader:jY},EY=NY,_j="treemap",AY=v(e=>/^\s*treemap/.test(e),"detector"),LY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./diagram-G47NLZAW-D5avTZAQ.js");return{diagram:t}},__vite__mapDeps([56,23,17,24,7,5,6,8,28,32,27,9]));return{id:_j,diagram:e}},"loader"),BY={id:_j,detector:AY,loader:LY},jj="wardley",MY=v(e=>/^\s*wardley-beta/i.test(e),"detector"),IY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./wardleyDiagram-EHGQE667-CqizSfCL.js");return{diagram:t}},__vite__mapDeps([57,23,24,7,5,6,8,9]));return{id:jj,diagram:e}},"loader"),FY={id:jj,detector:MY,loader:IY},OY=FY,Nj="cynefin",$Y=v(e=>/^\s*cynefin-beta(?:[\s:]|$)/.test(e),"detector"),DY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./cynefinDiagram-TSTJHNR4-Hn2vSVOw.js");return{diagram:t}},__vite__mapDeps([58,23,24,7,5,6,8,9]));return{id:Nj,diagram:e}},"loader"),PY={id:Nj,detector:$Y,loader:DY},Ej="railroad",RY=v(e=>/^\s*railroad-beta/i.test(e),"detector"),zY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./railroadDiagram-RFXS5EU6-Cvmlah5P.js");return{diagram:t}},__vite__mapDeps([59,60,23,24,7,5,6,8,9]));return{id:Ej,diagram:e}},"loader"),qY={id:Ej,detector:RY,loader:zY},Aj="railroadEbnf",WY=v(e=>/^\s*railroad-ebnf-beta/i.test(e),"detector"),HY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./ebnfDiagram-CCIWWBDH-DCXMfG-M.js");return{diagram:t}},__vite__mapDeps([61,60,23,24,7,5,6,8,9]));return{id:Aj,diagram:e}},"loader"),UY={id:Aj,detector:WY,loader:HY},Lj="railroadAbnf",YY=v(e=>/^\s*railroad-abnf-beta/i.test(e),"detector"),VY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./abnfDiagram-VRR7QNED-CZ6p2bRe.js");return{diagram:t}},__vite__mapDeps([62,60,23,24,7,5,6,8,9]));return{id:Lj,diagram:e}},"loader"),GY={id:Lj,detector:YY,loader:VY},Bj="railroadPeg",XY=v(e=>/^\s*railroad-peg-beta/i.test(e),"detector"),KY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./pegDiagram-2B236MQR-F6IN0_L5.js");return{diagram:t}},__vite__mapDeps([63,60,23,24,7,5,6,8,9]));return{id:Bj,diagram:e}},"loader"),QY={id:Bj,detector:XY,loader:KY},Cb=!1,Vu=v(()=>{Cb||(Cb=!0,jh("error",MU,e=>e.toLowerCase().trim()==="error"),jh("---",{db:{clear:v(()=>{},"clear")},styles:{},renderer:{draw:v(()=>{},"draw")},parser:{parse:v(()=>{throw new Error("Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks")},"parse")},init:v(()=>null,"init")},e=>e.toLowerCase().trimStart().startsWith("---")),tp($U,UU,xY),tp(xH,XU,xU,fU,MH,zH,HH,VH,sU,cU,EH,TH,CH,zU,$H,TU,CU,EU,QH,ZU,rY,tU,cY,wY,fY,sY,TY,BY,qY,UY,GY,QY,EY,OY,PY))},"addDiagrams"),JY=v(async()=>{oe.debug("Loading registered diagrams");const t=(await Promise.allSettled(Object.entries(ns).map(async([r,{detector:n,loader:i}])=>{if(i)try{sp(r)}catch{try{const{diagram:s,id:o}=await i();jh(o,s,n)}catch(s){throw oe.error(`Failed to load external diagram with key ${r}. Removing from detectors.`),delete ns[r],s}}}))).filter(r=>r.status==="rejected");if(t.length>0){oe.error(`Failed to load ${t.length} external diagrams`);for(const r of t)oe.error(r);throw new Error(`Failed to load ${t.length} external diagrams`)}},"loadRegisteredDiagrams"),ZY="graphics-document document";function Mj(e,t){e.attr("role",ZY),t!==""&&e.attr("aria-roledescription",t)}v(Mj,"setA11yDiagramInfo");function Ij(e,t,r,n){if(e.insert!==void 0){if(r){const i=`chart-desc-${n}`;e.attr("aria-describedby",i),e.insert("desc",":first-child").attr("id",i).text(r)}if(t){const i=`chart-title-${n}`;e.attr("aria-labelledby",i),e.insert("title",":first-child").attr("id",i).text(t)}}}v(Ij,"addSVGa11yTitleDescription");var Ki,Kp=(Ki=class{constructor(t,r,n,i,s){this.type=t,this.text=r,this.db=n,this.parser=i,this.renderer=s}static async fromText(t,r={}){var h,u;const n=vt(),i=cg(t,n);t=u7(t)+`
|
|
810
|
+
L0,20`).attr("stroke-linejoin","miter")},"requirement_arrow_neo"),HW=v((e,t,r)=>{const n=e.append("defs").append("marker").attr("id",r+"_"+t+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").append("g");n.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),n.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),n.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10)},"requirement_contains"),UW=v((e,t,r)=>{const n=vt(),{themeVariables:i}=n,{strokeWidth:s}=i,o=e.append("defs").append("marker").attr("id",r+"_"+t+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").attr("markerUnits","userSpaceOnUse").append("g");o.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),o.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),o.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10),o.selectAll("*").attr("stroke-width",`${s}`)},"requirement_contains_neo"),YW={extension:SW,composition:TW,aggregation:_W,dependency:jW,lollipop:NW,point:EW,circle:AW,cross:LW,barb:BW,barbNeo:MW,only_one:IW,zero_or_one:FW,one_or_more:OW,zero_or_more:$W,only_one_neo:DW,zero_or_one_neo:PW,one_or_more_neo:RW,zero_or_more_neo:zW,requirement_arrow:qW,requirement_contains:HW,requirement_arrow_neo:WW,requirement_contains_neo:UW},VW=vW,GW={common:$l,getConfig:vt,insertCluster:Wq,insertEdge:wW,insertEdgeLabel:mW,insertMarkers:VW,insertNode:$_,interpolateToCurve:Pg,labelHelper:$e,log:oe,positionEdgeLabel:gW},wl={},z_=v(e=>{for(const t of e)wl[t.name]=t},"registerLayoutLoaders"),XW=v(()=>{z_([{name:"dagre",loader:v(async()=>await Ue(()=>import("./dagre-VKFMJZFB-B2pkwDhN.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])),"loader")},{name:"swimlane",loader:v(async()=>await Ue(()=>import("./swimlanes-5IMT3BWC-DULYAFmB.js"),__vite__mapDeps([10,7,5,6,8,1,2,3,9])),"loader")},{name:"cose-bilkent",loader:v(async()=>await Ue(()=>import("./cose-bilkent-JH36ORCC-G8l05tXy.js"),__vite__mapDeps([11,9,5,6,7,8])),"loader")}])},"registerDefaultLayoutLoaders");XW();var Yee=v(async(e,t,r)=>{if(!(e.layoutAlgorithm in wl))throw new Error(`Unknown layout algorithm: ${e.layoutAlgorithm}`);if(e.diagramId)for(const d of e.nodes){const p=d.domId||d.id;d.domId=`${e.diagramId}-${p}`}const n=wl[e.layoutAlgorithm],i=await n.loader(),{theme:s,themeVariables:o}=e.config,{useGradient:a,gradientStart:l,gradientStop:h}=o,u=t.attr("id");if(t.append("defs").append("filter").attr("id",`${u}-drop-shadow`).attr("height","130%").attr("width","130%").append("feDropShadow").attr("dx","4").attr("dy","4").attr("stdDeviation",0).attr("flood-opacity","0.06").attr("flood-color",`${s!=null&&s.includes("dark")?"#FFFFFF":"#000000"}`),t.append("defs").append("filter").attr("id",`${u}-drop-shadow-small`).attr("height","150%").attr("width","150%").append("feDropShadow").attr("dx","2").attr("dy","2").attr("stdDeviation",0).attr("flood-opacity","0.06").attr("flood-color",`${s!=null&&s.includes("dark")?"#FFFFFF":"#000000"}`),a){const d=t.append("linearGradient").attr("id",t.attr("id")+"-gradient").attr("gradientUnits","objectBoundingBox").attr("x1","0%").attr("y1","0%").attr("x2","100%").attr("y2","0%");d.append("svg:stop").attr("offset","0%").attr("stop-color",l).attr("stop-opacity",1),d.append("svg:stop").attr("offset","100%").attr("stop-color",h).attr("stop-opacity",1)}return i.render(e,t,GW,{algorithm:n.algorithm},r)},"render"),Vee=v((e="",{fallback:t="dagre"}={})=>{if(e in wl)return e;if(t in wl)return oe.warn(`Layout algorithm ${e} is not registered. Using ${t} as fallback.`),t;throw new Error(`Both layout algorithms ${e} and ${t} are not registered.`)},"getRegisteredLayoutAlgorithm"),ox="comm",q_="rule",W_="decl",KW="@media",QW="@import",JW="@supports",ZW="@namespace",Yp="@keyframes",H_="@layer",eH="@scope",tH=Math.abs,tl=String.fromCharCode;function U_(e){return e.trim()}function Vp(e,t,r){return e.replace(t,r)}function to(e,t){return e.charCodeAt(t)|0}function Mo(e,t,r){return e.slice(t,r)}function mn(e){return e.length}function Y_(e){return e.length}function _c(e,t){return t.push(e),e}var Uu=1,Io=1,V_=0,Yr=0,Bt=0,Xo="";function ax(e,t,r,n,i,s,o,a){return{value:e,root:t,parent:r,type:n,props:i,children:s,line:Uu,column:Io,length:o,return:"",siblings:a}}function rH(){return Bt}function nH(){return Bt=Yr>0?to(Xo,--Yr):0,Io--,Bt===10&&(Io=1,Uu--),Bt}function on(){return Bt=Yr<V_?to(Xo,Yr++):0,Io++,Bt===10&&(Io=1,Uu++),Bt}function hi(){return to(Xo,Yr)}function rh(){return Yr}function Yu(e,t){return Mo(Xo,e,t)}function vl(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function iH(e){return Uu=Io=1,V_=mn(Xo=e),Yr=0,[]}function sH(e){return Xo="",e}function nf(e){return U_(Yu(Yr-1,Gp(e===91?e+2:e===40?e+1:e)))}function oH(e){for(;(Bt=hi())&&Bt<33;)on();return vl(e)>2||vl(Bt)>3?"":" "}function aH(e,t){for(;--t&&on()&&!(Bt<48||Bt>102||Bt>57&&Bt<65||Bt>70&&Bt<97););return Yu(e,rh()+(t<6&&hi()==32&&on()==32))}function Gp(e){for(;on();)switch(Bt){case e:return Yr;case 34:case 39:e!==34&&e!==39&&Gp(Bt);break;case 40:e===41&&Gp(e);break;case 92:on();break}return Yr}function lH(e,t){for(;on()&&e+Bt!==57;)if(e+Bt===84&&hi()===47)break;return"/*"+Yu(t,Yr-1)+"*"+tl(e===47?e:on())}function cH(e){for(;!vl(hi());)on();return Yu(e,Yr)}function hH(e){return sH(nh("",null,null,null,[""],e=iH(e),0,[0],e))}function nh(e,t,r,n,i,s,o,a,l){for(var h=0,u=0,d=o,p=0,f=0,m=0,g=1,x=1,y=1,k=0,b=0,w="",T=i,S=s,j=n,E=w;x;)switch(m=b,b=on()){case 40:m!=108&&to(E,d-1)==58?(k++,E+="("):E+=nf(b);break;case 41:k--,E+=")";break;case 34:case 39:case 91:E+=nf(b);break;case 9:case 10:case 13:case 32:if(k>0){E+=tl(b);break}E+=oH(m);break;case 92:E+=aH(rh()-1,7);continue;case 47:switch(hi()){case 42:case 47:_c(uH(lH(on(),rh()),t,r,l),l),(vl(m||1)==5||vl(hi()||1)==5)&&mn(E)&&Mo(E,-1,void 0)!==" "&&(E+=" ");break;default:E+="/"}break;case 123*g:a[h++]=mn(E)*y;case 125*g:case 59:case 0:if(k>0&&b){E+=tl(b);break}switch(b){case 0:case 125:x=0;case 59+u:y==-1&&(E=Vp(E,/\f/g,"")),f>0&&(mn(E)-d||g===0)&&_c(f>32?kb(E+";",n,r,d-1,l):kb(Vp(E," ","")+";",n,r,d-2,l),l);break;case 59:E+=";";default:if(_c(j=bb(E,t,r,h,u,i,a,w,T=[],S=[],d,s),s),b===123)if(u===0)nh(E,t,j,j,T,s,d,a,S);else{switch(p){case 99:if(to(E,3)===110)break;case 108:if(to(E,2)===97)break;default:u=0;case 100:case 109:case 115:}u?nh(e,j,j,n&&_c(bb(e,j,j,0,0,i,a,w,i,T=[],d,S),S),i,S,d,a,n?T:S):nh(E,j,j,j,[""],S,0,a,S)}}h=u=f=0,g=y=1,w=E="",d=o;break;case 58:d=1+mn(E),f=m;default:if(g<1){if(b==123)--g;else if(b==125&&g++==0&&nH()==125)continue}switch(E+=tl(b),b*g){case 38:y=u>0?1:(E+="\f",-1);break;case 44:if(k>0)break;a[h++]=(mn(E)-1)*y,y=1;break;case 64:hi()===45&&(E+=nf(on())),p=hi(),u=d=mn(w=E+=cH(rh())),b++;break;case 45:m===45&&mn(E)==2&&(g=0)}}return s}function bb(e,t,r,n,i,s,o,a,l,h,u,d){for(var p=i-1,f=i===0?s:[""],m=Y_(f),g=0,x=0,y=0;g<n;++g)for(var k=0,b=Mo(e,p+1,p=tH(x=o[g])),w=e;k<m;++k)(w=U_(x>0?f[k]+" "+b:Vp(b,/&\f/g,f[k])))&&(l[y++]=w);return ax(e,t,r,i===0?q_:a,l,h,u,d)}function uH(e,t,r,n){return ax(e,t,r,ox,tl(rH()),Mo(e,2,-2),0,n)}function kb(e,t,r,n,i){return ax(e,t,r,W_,Mo(e,0,n),Mo(e,n+1,-1),n,i)}function Xp(e,t){for(var r="",n=0;n<e.length;n++)r+=t(e[n],n,e,t)||"";return r}function dH(e,t,r,n){switch(e.type){case H_:if(e.children.length)break;case QW:case ZW:case W_:return e.return=e.return||e.value;case ox:return"";case Yp:return e.return=e.value+"{"+Xp(e.children,n)+"}";case q_:if(!mn(e.value=e.props.join(",")))return""}return mn(r=Xp(e.children,n))?e.return=e.value+"{"+r+"}":""}function fH(e){var t=Y_(e);return function(r,n,i,s){for(var o="",a=0;a<t;a++)o+=e[a](r,n,i,s)||"";return o}}var G_="c4",pH=v(e=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(e),"detector"),mH=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./c4Diagram-LMCZKHZV-CUmTCrMW.js");return{diagram:t}},__vite__mapDeps([12,13,5,6,7,8,9]));return{id:G_,diagram:e}},"loader"),gH={id:G_,detector:pH,loader:mH},xH=gH,X_="flowchart",yH=v((e,t)=>{var r,n;return((r=t==null?void 0:t.flowchart)==null?void 0:r.defaultRenderer)==="dagre-wrapper"||((n=t==null?void 0:t.flowchart)==null?void 0:n.defaultRenderer)==="elk"?!1:/^\s*graph/.test(e)},"detector"),bH=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./flowDiagram-23GEKE2U-DcUANpAz.js").then(r=>r.f);return{diagram:t}},__vite__mapDeps([14,15,16,17,13,18]));return{id:X_,diagram:e}},"loader"),kH={id:X_,detector:yH,loader:bH},CH=kH,K_="flowchart-v2",wH=v((e,t)=>{var r,n,i;return((r=t==null?void 0:t.flowchart)==null?void 0:r.defaultRenderer)==="dagre-d3"?!1:(((n=t==null?void 0:t.flowchart)==null?void 0:n.defaultRenderer)==="elk"&&(t.layout="elk"),/^\s*graph/.test(e)&&((i=t==null?void 0:t.flowchart)==null?void 0:i.defaultRenderer)==="dagre-wrapper"?!0:/^\s*flowchart/.test(e))},"detector"),vH=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./flowDiagram-23GEKE2U-DcUANpAz.js").then(r=>r.f);return{diagram:t}},__vite__mapDeps([14,15,16,17,13,18]));return{id:K_,diagram:e}},"loader"),SH={id:K_,detector:wH,loader:vH},TH=SH,Q_="swimlane",_H=v(e=>/^\s*swimlane-beta\b/.test(e),"detector"),jH=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./swimlanesDiagram-G3AALYLV-BB0gCy01.js");return{diagram:t}},__vite__mapDeps([19,14,15,16,17,13,18,5,6,7,8,9]));return{id:Q_,diagram:e}},"loader"),NH={id:Q_,detector:_H,loader:jH},EH=NH,J_="er",AH=v(e=>/^\s*erDiagram/.test(e),"detector"),LH=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./erDiagram-Q63AITRT-CI3lwEFA.js");return{diagram:t}},__vite__mapDeps([20,16,17,18,5,6,7,8,9]));return{id:J_,diagram:e}},"loader"),BH={id:J_,detector:AH,loader:LH},MH=BH,Z_="gitGraph",IH=v(e=>/^\s*gitGraph/.test(e),"detector"),FH=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./gitGraphDiagram-IHSO6WYX-BswI52az.js");return{diagram:t}},__vite__mapDeps([21,22,23,24,7,5,6,8,9]));return{id:Z_,diagram:e}},"loader"),OH={id:Z_,detector:IH,loader:FH},$H=OH,ej="gantt",DH=v(e=>/^\s*gantt/.test(e),"detector"),PH=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./ganttDiagram-NO4QXBWP-Cy0Ie8KS.js");return{diagram:t}},__vite__mapDeps([25,5,6,26,27,28,7,8,9]));return{id:ej,diagram:e}},"loader"),RH={id:ej,detector:DH,loader:PH},zH=RH,tj="info",qH=v(e=>/^\s*info/.test(e),"detector"),WH=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./infoDiagram-FWYZ7A6U-BBunqvr-.js");return{diagram:t}},__vite__mapDeps([29,24,7,5,6,8,9]));return{id:tj,diagram:e}},"loader"),HH={id:tj,detector:qH,loader:WH},rj="pie",UH=v(e=>/^\s*pie/.test(e),"detector"),YH=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./pieDiagram-ENE6RG2P-xkcpHwnY.js");return{diagram:t}},__vite__mapDeps([30,23,24,7,5,6,8,31,32,27,9]));return{id:rj,diagram:e}},"loader"),VH={id:rj,detector:UH,loader:YH},nj="quadrantChart",GH=v(e=>/^\s*quadrantChart/.test(e),"detector"),XH=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./quadrantDiagram-ABIIQ3AL-kebZIOmu.js");return{diagram:t}},__vite__mapDeps([33,26,27,28,5,6,7,8,9]));return{id:nj,diagram:e}},"loader"),KH={id:nj,detector:GH,loader:XH},QH=KH,ij="xychart",JH=v(e=>/^\s*xychart(-beta)?/.test(e),"detector"),ZH=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./xychartDiagram-FW5EYKEG-DdYyKfQ3.js");return{diagram:t}},__vite__mapDeps([34,27,32,26,28,5,6,7,8,9]));return{id:ij,diagram:e}},"loader"),eU={id:ij,detector:JH,loader:ZH},tU=eU,sj="requirement",rU=v(e=>/^\s*requirement(Diagram)?/.test(e),"detector"),nU=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./requirementDiagram-TGXJPOKE-D1lG1P7h.js");return{diagram:t}},__vite__mapDeps([35,16,17,5,6,7,8,9]));return{id:sj,diagram:e}},"loader"),iU={id:sj,detector:rU,loader:nU},sU=iU,oj="sequence",oU=v(e=>/^\s*sequenceDiagram/.test(e),"detector"),aU=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./sequenceDiagram-DBY2YBRQ-DynIVCk_.js");return{diagram:t}},__vite__mapDeps([36,22,13,5,6,7,8,9]));return{id:oj,diagram:e}},"loader"),lU={id:oj,detector:oU,loader:aU},cU=lU,aj="class",hU=v((e,t)=>{var r;return((r=t==null?void 0:t.class)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!1:/^\s*classDiagram/.test(e)},"detector"),uU=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./classDiagram-OUVF2IWQ-BIvLcbex.js");return{diagram:t}},__vite__mapDeps([37,38,15,16,17,13,5,6,7,8,9]));return{id:aj,diagram:e}},"loader"),dU={id:aj,detector:hU,loader:uU},fU=dU,lj="classDiagram",pU=v((e,t)=>{var r;return/^\s*classDiagram/.test(e)&&((r=t==null?void 0:t.class)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!0:/^\s*classDiagram-v2/.test(e)},"detector"),mU=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./classDiagram-v2-EOCWNBFH-BIvLcbex.js");return{diagram:t}},__vite__mapDeps([39,38,15,16,17,13,5,6,7,8,9]));return{id:lj,diagram:e}},"loader"),gU={id:lj,detector:pU,loader:mU},xU=gU,cj="state",yU=v((e,t)=>{var r;return((r=t==null?void 0:t.state)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!1:/^\s*stateDiagram/.test(e)},"detector"),bU=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./stateDiagram-2N3HPSRC-OZ7trFh5.js");return{diagram:t}},__vite__mapDeps([40,41,16,17,13,2,4,3,5,6,7,8,9]));return{id:cj,diagram:e}},"loader"),kU={id:cj,detector:yU,loader:bU},CU=kU,hj="stateDiagram",wU=v((e,t)=>{var r;return!!(/^\s*stateDiagram-v2/.test(e)||/^\s*stateDiagram/.test(e)&&((r=t==null?void 0:t.state)==null?void 0:r.defaultRenderer)==="dagre-wrapper")},"detector"),vU=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./stateDiagram-v2-6OUMAXLB-GcPRHAJT.js");return{diagram:t}},__vite__mapDeps([42,41,16,17,13,5,6,7,8,9]));return{id:hj,diagram:e}},"loader"),SU={id:hj,detector:wU,loader:vU},TU=SU,uj="journey",_U=v(e=>/^\s*journey/.test(e),"detector"),jU=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./journeyDiagram-5HDEW3XC-CIqcTFuO.js");return{diagram:t}},__vite__mapDeps([43,15,13,31,5,6,7,8,9]));return{id:uj,diagram:e}},"loader"),NU={id:uj,detector:_U,loader:jU},EU=NU,AU=v((e,t,r)=>{oe.debug(`rendering svg for syntax error
|
|
811
|
+
`);const n=sz(t),i=n.append("g");n.attr("viewBox","0 0 2412 512"),qw(n,100,512,!0),i.append("path").attr("class","error-icon").attr("d","m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z"),i.append("path").attr("class","error-icon").attr("d","m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z"),i.append("path").attr("class","error-icon").attr("d","m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z"),i.append("path").attr("class","error-icon").attr("d","m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z"),i.append("path").attr("class","error-icon").attr("d","m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z"),i.append("path").attr("class","error-icon").attr("d","m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z"),i.append("text").attr("class","error-text").attr("x",1440).attr("y",250).attr("font-size","150px").style("text-anchor","middle").text("Syntax error in text"),i.append("text").attr("class","error-text").attr("x",1250).attr("y",400).attr("font-size","100px").style("text-anchor","middle").text(`mermaid version ${r}`)},"draw"),dj={draw:AU},LU=dj,BU={db:{},renderer:dj,parser:{parse:v(()=>{},"parse")}},MU=BU,fj="flowchart-elk",IU=v((e,t={})=>{var r;return/^\s*flowchart-elk/.test(e)||/^\s*(flowchart|graph)/.test(e)&&((r=t==null?void 0:t.flowchart)==null?void 0:r.defaultRenderer)==="elk"?(t.layout="elk",!0):!1},"detector"),FU=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./flowDiagram-23GEKE2U-DcUANpAz.js").then(r=>r.f);return{diagram:t}},__vite__mapDeps([14,15,16,17,13,18]));return{id:fj,diagram:e}},"loader"),OU={id:fj,detector:IU,loader:FU},$U=OU,pj="timeline",DU=v(e=>/^\s*timeline/.test(e),"detector"),PU=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./timeline-definition-FHXFAJF6-CzqqUDvt.js");return{diagram:t}},__vite__mapDeps([44,31,5,6,7,8,9]));return{id:pj,diagram:e}},"loader"),RU={id:pj,detector:DU,loader:PU},zU=RU,mj="mindmap",qU=v(e=>/^\s*mindmap/.test(e),"detector"),WU=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./mindmap-definition-LN4V7U3C-CpqH5F_P.js");return{diagram:t}},__vite__mapDeps([45,16,17,5,6,7,8,9]));return{id:mj,diagram:e}},"loader"),HU={id:mj,detector:qU,loader:WU},UU=HU,gj="kanban",YU=v(e=>/^\s*kanban/.test(e),"detector"),VU=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./kanban-definition-HUTT4EX6-CB9jCXj_.js");return{diagram:t}},__vite__mapDeps([46,15,5,6,7,8,9]));return{id:gj,diagram:e}},"loader"),GU={id:gj,detector:YU,loader:VU},XU=GU,xj="sankey",KU=v(e=>/^\s*sankey(-beta)?/.test(e),"detector"),QU=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./sankeyDiagram-HTMAVEWB-DOEEcn52.js");return{diagram:t}},__vite__mapDeps([47,32,27,5,6,7,8,9]));return{id:xj,diagram:e}},"loader"),JU={id:xj,detector:KU,loader:QU},ZU=JU,yj="packet",eY=v(e=>/^\s*packet(-beta)?/.test(e),"detector"),tY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./diagram-NH7WQ7WH-BlLWwKVt.js");return{diagram:t}},__vite__mapDeps([48,23,24,7,5,6,8,9]));return{id:yj,diagram:e}},"loader"),rY={id:yj,detector:eY,loader:tY},bj="radar",nY=v(e=>/^\s*radar-beta/.test(e),"detector"),iY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./diagram-WEI45ONY-Bj6PGUCe.js");return{diagram:t}},__vite__mapDeps([49,23,24,7,5,6,8,9]));return{id:bj,diagram:e}},"loader"),sY={id:bj,detector:nY,loader:iY},kj="block",oY=v(e=>/^\s*block(-beta)?/.test(e),"detector"),aY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./blockDiagram-677ZJIJ3-Bjb_MNB4.js");return{diagram:t}},__vite__mapDeps([50,15,2,18,5,6,7,8,9]));return{id:kj,diagram:e}},"loader"),lY={id:kj,detector:oY,loader:aY},cY=lY,Cj="treeView",hY=v(e=>/^\s*treeView-beta/.test(e),"detector"),uY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./diagram-OA4YK3LP-DEv704Re.js");return{diagram:t}},__vite__mapDeps([51,22,23,24,7,5,6,8,9]));return{id:Cj,diagram:e}},"loader"),dY={id:Cj,detector:hY,loader:uY},fY=dY,wj="architecture",pY=v(e=>/^\s*architecture/.test(e),"detector"),mY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./architectureDiagram-ZJ3FMSHR-BukV0CJw.js");return{diagram:t}},__vite__mapDeps([52,23,24,7,5,6,8,9]));return{id:wj,diagram:e}},"loader"),gY={id:wj,detector:pY,loader:mY},xY=gY,vj="eventmodeling",yY=v(e=>/^\s*eventmodeling/.test(e),"detector"),bY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./diagram-FQU43EPY-DPHD_t-1.js");return{diagram:t}},__vite__mapDeps([53,23,24,7,5,6,8,9]));return{id:vj,diagram:e}},"loader"),kY={id:vj,detector:yY,loader:bY},wY=kY,Sj="ishikawa",vY=v(e=>/^\s*ishikawa(-beta)?\b/i.test(e),"detector"),SY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./ishikawaDiagram-FXEZZL3T-Hm4zSDlM.js");return{diagram:t}},__vite__mapDeps([54,5,6,7,8,9]));return{id:Sj,diagram:e}},"loader"),TY={id:Sj,detector:vY,loader:SY},Tj="venn",_Y=v(e=>/^\s*venn-beta/.test(e),"detector"),jY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./vennDiagram-L72KCM5P-CdKmtcFL.js");return{diagram:t}},__vite__mapDeps([55,5,6,7,8,9]));return{id:Tj,diagram:e}},"loader"),NY={id:Tj,detector:_Y,loader:jY},EY=NY,_j="treemap",AY=v(e=>/^\s*treemap/.test(e),"detector"),LY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./diagram-G47NLZAW-DGmHIZRr.js");return{diagram:t}},__vite__mapDeps([56,23,17,24,7,5,6,8,28,32,27,9]));return{id:_j,diagram:e}},"loader"),BY={id:_j,detector:AY,loader:LY},jj="wardley",MY=v(e=>/^\s*wardley-beta/i.test(e),"detector"),IY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./wardleyDiagram-EHGQE667-DknGwjCA.js");return{diagram:t}},__vite__mapDeps([57,23,24,7,5,6,8,9]));return{id:jj,diagram:e}},"loader"),FY={id:jj,detector:MY,loader:IY},OY=FY,Nj="cynefin",$Y=v(e=>/^\s*cynefin-beta(?:[\s:]|$)/.test(e),"detector"),DY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./cynefinDiagram-TSTJHNR4-C8N_CvKJ.js");return{diagram:t}},__vite__mapDeps([58,23,24,7,5,6,8,9]));return{id:Nj,diagram:e}},"loader"),PY={id:Nj,detector:$Y,loader:DY},Ej="railroad",RY=v(e=>/^\s*railroad-beta/i.test(e),"detector"),zY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./railroadDiagram-RFXS5EU6-DNvGwWm9.js");return{diagram:t}},__vite__mapDeps([59,60,23,24,7,5,6,8,9]));return{id:Ej,diagram:e}},"loader"),qY={id:Ej,detector:RY,loader:zY},Aj="railroadEbnf",WY=v(e=>/^\s*railroad-ebnf-beta/i.test(e),"detector"),HY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./ebnfDiagram-CCIWWBDH-Ch-icksT.js");return{diagram:t}},__vite__mapDeps([61,60,23,24,7,5,6,8,9]));return{id:Aj,diagram:e}},"loader"),UY={id:Aj,detector:WY,loader:HY},Lj="railroadAbnf",YY=v(e=>/^\s*railroad-abnf-beta/i.test(e),"detector"),VY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./abnfDiagram-VRR7QNED-Bip6cMjP.js");return{diagram:t}},__vite__mapDeps([62,60,23,24,7,5,6,8,9]));return{id:Lj,diagram:e}},"loader"),GY={id:Lj,detector:YY,loader:VY},Bj="railroadPeg",XY=v(e=>/^\s*railroad-peg-beta/i.test(e),"detector"),KY=v(async()=>{const{diagram:e}=await Ue(async()=>{const{diagram:t}=await import("./pegDiagram-2B236MQR-HpQyrDcm.js");return{diagram:t}},__vite__mapDeps([63,60,23,24,7,5,6,8,9]));return{id:Bj,diagram:e}},"loader"),QY={id:Bj,detector:XY,loader:KY},Cb=!1,Vu=v(()=>{Cb||(Cb=!0,jh("error",MU,e=>e.toLowerCase().trim()==="error"),jh("---",{db:{clear:v(()=>{},"clear")},styles:{},renderer:{draw:v(()=>{},"draw")},parser:{parse:v(()=>{throw new Error("Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks")},"parse")},init:v(()=>null,"init")},e=>e.toLowerCase().trimStart().startsWith("---")),tp($U,UU,xY),tp(xH,XU,xU,fU,MH,zH,HH,VH,sU,cU,EH,TH,CH,zU,$H,TU,CU,EU,QH,ZU,rY,tU,cY,wY,fY,sY,TY,BY,qY,UY,GY,QY,EY,OY,PY))},"addDiagrams"),JY=v(async()=>{oe.debug("Loading registered diagrams");const t=(await Promise.allSettled(Object.entries(ns).map(async([r,{detector:n,loader:i}])=>{if(i)try{sp(r)}catch{try{const{diagram:s,id:o}=await i();jh(o,s,n)}catch(s){throw oe.error(`Failed to load external diagram with key ${r}. Removing from detectors.`),delete ns[r],s}}}))).filter(r=>r.status==="rejected");if(t.length>0){oe.error(`Failed to load ${t.length} external diagrams`);for(const r of t)oe.error(r);throw new Error(`Failed to load ${t.length} external diagrams`)}},"loadRegisteredDiagrams"),ZY="graphics-document document";function Mj(e,t){e.attr("role",ZY),t!==""&&e.attr("aria-roledescription",t)}v(Mj,"setA11yDiagramInfo");function Ij(e,t,r,n){if(e.insert!==void 0){if(r){const i=`chart-desc-${n}`;e.attr("aria-describedby",i),e.insert("desc",":first-child").attr("id",i).text(r)}if(t){const i=`chart-title-${n}`;e.attr("aria-labelledby",i),e.insert("title",":first-child").attr("id",i).text(t)}}}v(Ij,"addSVGa11yTitleDescription");var Ki,Kp=(Ki=class{constructor(t,r,n,i,s){this.type=t,this.text=r,this.db=n,this.parser=i,this.renderer=s}static async fromText(t,r={}){var h,u;const n=vt(),i=cg(t,n);t=u7(t)+`
|
|
812
812
|
`;try{sp(i)}catch{const d=ZD(i);if(!d)throw new Ow(`Diagram ${i} not found.`);const{id:p,diagram:f}=await d();jh(p,f)}const{db:s,parser:o,renderer:a,init:l}=sp(i);return o.parser&&(o.parser.yy=s),(h=s.clear)==null||h.call(s),l==null||l(n),r.title&&((u=s.setDiagramTitle)==null||u.call(s,r.title)),await o.parse(t),new Ki(i,t,s,o,a)}async render(t,r){await this.renderer.draw(this.text,t,r,this)}getParser(){return this.parser}getType(){return this.type}},v(Ki,"Diagram"),Ki),wb=[],eV=v(()=>{wb.forEach(e=>{e()}),wb=[]},"attachFunctions"),tV=v(e=>e.replace(/^\s*%%(?!{)[^\n]+\n?/gm,"").trimStart(),"cleanupComments");function Fj(e){const t=e.match(Fw);if(!t)return{text:e,metadata:{}};const r=t[1],n=r?t[2].split(`
|
|
813
813
|
`).map(o=>o.startsWith(r)?o.slice(r.length):o).join(`
|
|
814
814
|
`):t[2];let i=d9(n,{schema:u9})??{};i=typeof i=="object"&&!Array.isArray(i)?i:{};const s={};return i.displayMode&&(s.displayMode=i.displayMode.toString()),i.title&&(s.title=i.title.toString()),i.config&&(s.config=i.config),{text:e.slice(t[0].length),metadata:s}}v(Fj,"extractFrontMatter");var rV=v(e=>e.replace(/\r\n?/g,`
|
|
@@ -866,7 +866,7 @@ Description: ${e.description}`:"",x=["Challenge the assumptions of this item and
|
|
|
866
866
|
`,a.length>0?(n+=a.map(h=>`- ${h}`).join(`
|
|
867
867
|
`),n+=`
|
|
868
868
|
`):n+=`_No open threads._
|
|
869
|
-
`,n}function DQ(e,t){return(t||[]).filter(n=>!n.superseded).map(n=>({title:n.question,type:"decision",decided:!0}))}const Aa={es:null},pi=Rm((e,t)=>({session:null,messages:[],decisions:[],status:"idle",error:null,streamingMessage:null,scope:null,featureCode:null,designDocPath:null,draftDoc:"",docManuallyEdited:!1,researchItems:[],topicOutline:[],hydrate:async(r,n)=>{if(!r){const l=t().scope;if(l)r=l,n=t().featureCode||null;else try{const h=JSON.parse(localStorage.getItem("compose:designSession")||"{}");r=h.scope||"product",n=h.featureCode||null}catch{r="product"}}const i=t().docManuallyEdited,s=t().draftDoc,o=t().researchItems||[];e({session:null,messages:[],decisions:[],status:"idle",error:null,streamingMessage:null,designDocPath:null,scope:r,featureCode:n,draftDoc:"",docManuallyEdited:!1,researchItems:[],topicOutline:[]});const a=r==="feature"&&n?`?scope=feature&featureCode=${n}`:`?scope=${r}`;try{const l=await _e(`/api/design/session${a}`),{session:h}=await l.json();if(h){const u=h.messages||[],d=h.decisions||[],p=Kb(u,d),f=DQ(u,d);e({session:h,messages:u,decisions:d,status:h.status==="complete"?"complete":"active",scope:r,featureCode:n,draftDoc:i?s:p,docManuallyEdited:i,topicOutline:f,researchItems:o}),t().disconnectSSE(),t().connectSSE()}else e({session:null,messages:[],decisions:[],status:"idle",error:null,streamingMessage:null,scope:r,featureCode:n,draftDoc:"",docManuallyEdited:!1,researchItems:[],topicOutline:[]}),t().disconnectSSE()}catch(l){e({error:l.message})}},startSession:async(r="product",n=null)=>{try{const i=await _e("/api/design/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:r,featureCode:n})});if(!i.ok){const{error:o}=await i.json();e({error:o});return}const{session:s}=await i.json();try{localStorage.setItem("compose:designSession",JSON.stringify({scope:r,featureCode:n}))}catch{}e({session:s,messages:s.messages||[],decisions:s.decisions||[],status:"active",error:null,scope:r,featureCode:n}),t().connectSSE()}catch(i){e({error:i.message})}},sendMessage:async r=>{const{session:n,messages:i}=t();if(!n)return;const s=n.scope,o=n.featureCode,a={role:"human",type:"text",content:r,timestamp:new Date().toISOString()};e(l=>({messages:[...l.messages,a],status:"streaming"}));try{const l=await _e("/api/design/message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:s,featureCode:o,type:"text",content:r})});l.ok||e({messages:i,status:"active",error:`Failed to send message: ${l.status}`})}catch(l){e({messages:i,status:"active",error:l.message})}},selectCard:async(r,n=null,i=null)=>{const{session:s,messages:o}=t();if(!s)return;const a={role:"human",type:"card_select",content:{cardId:r,comment:n},timestamp:new Date().toISOString()};e(l=>({messages:[...l.messages,a],status:"streaming"}));try{const l=await _e("/api/design/message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:s.scope,featureCode:s.featureCode,type:"card_select",cardId:r,comment:n,messageIndex:i})});l.ok||e({messages:o,status:"active",error:`Failed to select card: ${l.status}`})}catch(l){e({messages:o,status:"active",error:l.message})}},reviseDecision:async r=>{const{session:n}=t();if(!n)return;const i=t().decisions[r];if(!(!i||i.superseded))try{const s=await _e("/api/design/revise",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:n.scope,featureCode:n.featureCode,decisionIndex:r})});if(!s.ok){const{error:o}=await s.json().catch(()=>({error:"Revision failed"}));e({error:o});return}t().hydrate(n.scope,n.featureCode)}catch(s){e({error:s.message})}},completeDesign:async()=>{const{session:r,draftDoc:n}=t();if(r){e({status:"summarizing"});try{const i={scope:r.scope,featureCode:r.featureCode};n&&(i.draftDoc=n);const s=await _e("/api/design/complete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!s.ok){const{error:l}=await s.json().catch(()=>({error:"Unknown error"}));e({error:l,status:"active"});return}const o=await s.json(),a={session:o.session,status:"complete",designDocPath:o.designDocPath||null};o.error&&(a.error=o.error),e(a)}catch(i){e({error:i.message,status:"active"})}}},connectSSE:()=>{if(Aa.es)return;const{scope:r,featureCode:n}=t(),i=new URLSearchParams({scope:r||"product"});n&&i.set("featureCode",n);const s=v1("/api/design/stream"),o=s.includes("?")?"&":"?",a=new EventSource(`${s}${o}${i}`);Aa.es=a,a.addEventListener("ack",()=>{e(l=>l.status!=="streaming"?{status:"streaming"}:{})}),a.addEventListener("text",l=>{const h=JSON.parse(l.data);e(u=>u.streamingMessage?{streamingMessage:{...u.streamingMessage,content:u.streamingMessage.content+h.content}}:{status:"streaming",streamingMessage:{role:"assistant",type:"text",content:h.content,timestamp:new Date().toISOString()}})}),a.addEventListener("decision",l=>{const h=JSON.parse(l.data);e(u=>({status:"streaming",streamingMessage:u.streamingMessage?{...u.streamingMessage,type:"decision",decisionData:h}:{role:"assistant",type:"decision",content:"",decisionData:h,timestamp:new Date().toISOString()}}))}),a.addEventListener("done",()=>{e(l=>({messages:l.streamingMessage?[...l.messages,l.streamingMessage]:l.messages,streamingMessage:null,status:"active"})),t().hydrate()}),a.addEventListener("research",l=>{const h=JSON.parse(l.data);e(u=>({researchItems:[...u.researchItems,{id:h.id,tool:h.tool,input:h.input,timestamp:h.timestamp,summary:null}]}))}),a.addEventListener("research_result",l=>{const h=JSON.parse(l.data);e(u=>{const d=[...u.researchItems],p=h.id?d.findIndex(f=>f.id===h.id):-1;return p!==-1&&(d[p]={...d[p],summary:h.summary}),{researchItems:d}})}),a.addEventListener("error",l=>{try{const h=JSON.parse(l.data);e(u=>({status:"active",streamingMessage:null,error:h.message||"Agent error",messages:u.messages}))}catch{e({status:"active",streamingMessage:null})}}),a.onerror=()=>{e({status:"active"})}},disconnectSSE:()=>{Aa.es&&(Aa.es.close(),Aa.es=null)},reset:()=>{try{localStorage.removeItem("compose:designSession")}catch{}e({session:null,messages:[],decisions:[],status:"idle",error:null,streamingMessage:null,scope:null,featureCode:null,designDocPath:null,draftDoc:"",docManuallyEdited:!1,researchItems:[],topicOutline:[]})},updateDraftDoc:r=>{e({draftDoc:r,docManuallyEdited:!0})},resetDocEdited:()=>{const{messages:r,decisions:n}=t(),i=Kb(r,n);e({draftDoc:i,docManuallyEdited:!1})}}));function PQ(){const{draftDoc:e,docManuallyEdited:t,updateDraftDoc:r,resetDocEdited:n}=pi(Ti(h=>({draftDoc:h.draftDoc,docManuallyEdited:h.docManuallyEdited,updateDraftDoc:h.updateDraftDoc,resetDocEdited:h.resetDocEdited}))),[i,s]=C.useState(!1),o=!e;let a="empty",l={color:"hsl(var(--muted-foreground))"};return t?(a="edited",l={color:"hsl(var(--primary))"}):o||(a="draft",l={color:"hsl(var(--muted-foreground))"}),c.jsxs("div",{className:"h-full flex flex-col",style:{fontFamily:"inherit"},children:[c.jsxs("div",{className:"flex items-center justify-between px-3 py-2 shrink-0",style:{borderBottom:"1px solid hsl(var(--border))"},children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-[12px] font-semibold",style:{color:"hsl(var(--foreground))"},children:"Design Document"}),c.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{...l,background:"hsl(var(--muted))"},children:a})]}),!o&&c.jsx("button",{onClick:()=>s(h=>!h),className:"text-[11px] px-2 py-1 rounded transition-colors",style:{color:"hsl(var(--muted-foreground))",background:i?"hsl(var(--accent))":"transparent"},onMouseEnter:h=>{h.currentTarget.style.color="hsl(var(--foreground))"},onMouseLeave:h=>{h.currentTarget.style.color="hsl(var(--muted-foreground))"},children:i?"Preview":"Edit"})]}),c.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:o?c.jsx("div",{className:"p-4 text-[12px] italic",style:{color:"hsl(var(--muted-foreground))"},children:"Start the design conversation to see the document build here."}):i?c.jsxs("div",{className:"h-full flex flex-col p-2 gap-2",children:[c.jsx("textarea",{className:"flex-1 min-h-0 w-full resize-none rounded p-2 text-[12px]",style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",background:"hsl(var(--background))",color:"hsl(var(--foreground))",border:"1px solid hsl(var(--border))",outline:"none"},value:e,onChange:h=>r(h.target.value),spellCheck:!1}),c.jsx("button",{onClick:()=>{n(),s(!1)},className:"shrink-0 text-[11px] px-3 py-1.5 rounded transition-colors self-start",style:{color:"hsl(var(--muted-foreground))",border:"1px solid hsl(var(--border))",background:"transparent"},onMouseEnter:h=>{h.currentTarget.style.color="hsl(var(--foreground))",h.currentTarget.style.borderColor="hsl(var(--foreground))"},onMouseLeave:h=>{h.currentTarget.style.color="hsl(var(--muted-foreground))",h.currentTarget.style.borderColor="hsl(var(--border))"},children:"Reset to auto-generated"})]}):c.jsx("div",{className:"p-4 prose prose-sm max-w-none",style:{color:"hsl(var(--foreground))","--tw-prose-body":"hsl(var(--foreground))","--tw-prose-headings":"hsl(var(--foreground))","--tw-prose-code":"hsl(var(--foreground))","--tw-prose-bold":"hsl(var(--foreground))","--tw-prose-links":"hsl(var(--primary))",fontSize:"12px"},children:c.jsx(Fm,{remarkPlugins:[Pm],children:e})})})]})}function Qb(e){if(!e)return"—";const t=Date.now()-new Date(e).getTime(),r=Math.floor(t/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const n=Math.floor(r/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}function RQ(e){if(!e)return"";const t=Math.max(0,Math.floor((new Date(e).getTime()-Date.now())/1e3));if(t<=0)return"expired";const r=Math.floor(t/60),n=t%60;return`${r}:${String(n).padStart(2,"0")}`}function zQ({device:e,idx:t,onRevoke:r}){const[n,i]=C.useState(!1),s=C.useRef(null),o=C.useCallback(()=>{if(!n){i(!0),s.current=setTimeout(()=>i(!1),3e3);return}clearTimeout(s.current),i(!1),r(e.id)},[n,e.id,r]);return C.useEffect(()=>()=>clearTimeout(s.current),[]),c.jsxs("div",{className:"flex items-center gap-3 py-2 px-3 rounded-lg bg-muted/30 border border-border",style:{opacity:e.revoked?.5:1},children:[c.jsx(D1,{className:"h-4 w-4 text-muted-foreground shrink-0"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:e.name||"Unknown device"}),e.revoked&&c.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-destructive/10 text-destructive shrink-0",children:"revoked"})]}),c.jsxs("div",{className:"text-[10px] text-muted-foreground mt-0.5",children:["Paired ",Qb(e.paired_at),e.last_seen&&!e.revoked&&` · seen ${Qb(e.last_seen)}`]})]}),!e.revoked&&c.jsx("button",{"data-testid":`pair-device-revoke-${t}`,onClick:o,className:`shrink-0 text-[10px] px-2 py-1 rounded transition-colors ${n?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"text-muted-foreground hover:text-destructive hover:bg-destructive/10"}`,title:n?"Click again to confirm revoke":"Revoke device",children:n?c.jsxs("span",{className:"flex items-center gap-1",children:[c.jsx(oh,{className:"h-3 w-3"})," Confirm"]}):c.jsx(oh,{className:"h-3 w-3"})})]})}function qQ({open:e,onClose:t,publicHost:r}){const[n,i]=C.useState("idle"),[s,o]=C.useState(null),[a,l]=C.useState(""),[h,u]=C.useState(null),[d,p]=C.useState(""),[f,m]=C.useState(null),[g,x]=C.useState(""),[y,k]=C.useState(null),[b,w]=C.useState([]),[T,S]=C.useState(!1),j=C.useRef(null),E=C.useRef(null),L=C.useCallback(async()=>{S(!0);try{const B=await _e("/api/auth/devices",{headers:rn()});if(B.ok){const O=await B.json();w(O.devices||[])}}catch{}finally{S(!1)}},[]),N=C.useCallback(async B=>{try{(await _e(`/api/auth/devices/${B}`,{method:"DELETE",headers:rn()})).ok&&await L()}catch{}},[L]),F=C.useCallback(async()=>{i("loading"),x(""),k(null),o(null),l(""),u(null),p("");try{const B=await _e("/api/auth/pair/init",{method:"POST",headers:rn({"Content-Type":"application/json"})});if(B.status===503){i("error"),x("COMPOSE_API_TOKEN is not set — the server cannot authenticate this request. Start compose via `compose start` so the supervisor generates the token, or set COMPOSE_API_TOKEN manually.");return}if(!B.ok){const $=await B.json().catch(()=>({}));i("error"),x($.error||`Server returned ${B.status}`);return}const O=await B.json(),M=O.public_host||r||(typeof window<"u"?window.location.origin:""),A=O.pair_url||`${M}/m/pair?code=${O.code}`;m(O.public_host||r||null),o(O.code),l(A),u(O.expires_at),i("ready")}catch(B){i("error"),x(B.message||"Network error")}},[r]);if(C.useEffect(()=>{if(!e){i("idle"),o(null),l(""),u(null),p(""),x(""),k(null),clearInterval(E.current);return}F(),L()},[e]),C.useEffect(()=>{if(n!=="ready"||!a||!j.current)return;let B=!1;return(async()=>{try{const O=(await Ue(async()=>{const{default:M}=await import("./browser-CvETNQNv.js").then(A=>A.b);return{default:M}},__vite__mapDeps([64,5,6]))).default;!B&&j.current&&await O.toCanvas(j.current,a,{width:200,margin:2,color:{dark:"#000000",light:"#ffffff"}})}catch{}})(),()=>{B=!0}},[n,a]),C.useEffect(()=>{if(!h){clearInterval(E.current);return}clearInterval(E.current);const B=()=>p(RQ(h));return B(),E.current=setInterval(B,1e3),()=>clearInterval(E.current)},[h]),C.useEffect(()=>{if(!e)return;function B(O){const{name:M,device_id:A}=O.detail??{};k({name:M||"New device",id:A}),clearInterval(E.current),p(""),L()}return window.addEventListener("compose:devicePaired",B),()=>window.removeEventListener("compose:devicePaired",B)},[e,L]),!e)return null;const R=!f;return c.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",role:"dialog","aria-modal":"true","aria-label":"Pair mobile device","data-testid":"pair-device-modal",children:[c.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:t}),c.jsxs("div",{className:"relative w-full max-w-md max-h-[85vh] flex flex-col rounded-xl border border-border bg-card shadow-2xl mx-4",children:[c.jsxs("div",{className:"flex items-center gap-3 p-4 pb-3 border-b border-border shrink-0",children:[c.jsx(D1,{className:"h-5 w-5 text-accent shrink-0"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("h2",{className:"text-sm font-semibold text-foreground",children:"Pair mobile device"}),c.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Scan the QR code on your phone to connect remotely"})]}),c.jsx("button",{className:"shrink-0 opacity-60 hover:opacity-100 transition-opacity",onClick:t,"aria-label":"Close",children:c.jsx(jr,{className:"h-4 w-4"})})]}),c.jsxs("div",{className:"flex-1 overflow-auto p-4 space-y-4",children:[y&&c.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-success/10 border border-success/20",children:[c.jsx(pm,{className:"h-4 w-4 text-success shrink-0"}),c.jsxs("span",{className:"text-xs text-success font-medium",children:["Paired: ",y.name]})]}),n==="loading"&&c.jsxs("div",{className:"flex items-center justify-center py-10 gap-2 text-muted-foreground",children:[c.jsx(sh,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-xs",children:"Generating pairing code…"})]}),n==="error"&&c.jsxs("div",{"data-testid":"pair-device-error",className:"px-3 py-3 rounded-lg bg-destructive/10 border border-destructive/20 space-y-2",children:[c.jsxs("div",{className:"flex items-start gap-2",children:[c.jsx(M5,{className:"h-4 w-4 text-destructive shrink-0 mt-0.5"}),c.jsx("p",{className:"text-xs text-destructive leading-relaxed",children:g})]}),c.jsx("button",{className:"text-[10px] text-accent hover:underline",onClick:F,children:"Retry"})]}),n==="ready"&&c.jsxs("div",{className:"space-y-3",children:[R&&c.jsxs("div",{className:"text-[10px] text-amber-500 bg-amber-500/10 border border-amber-500/20 rounded px-2 py-1.5",children:["No public host configured — the URL below uses your local origin. For remote pairing, configure a public host (e.g. via"," ",c.jsx("code",{className:"font-mono",children:"compose remote pair --public-host=<URL>"}),")."]}),c.jsx("div",{className:"flex justify-center",children:c.jsx("canvas",{ref:j,"data-testid":"pair-device-qr",className:"rounded border border-border bg-white",width:200,height:200,"aria-label":"QR code for pairing"})}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("label",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Pairing URL"}),c.jsx("input",{"data-testid":"pair-device-url",readOnly:!0,value:a,className:"w-full text-[10px] font-mono bg-muted text-foreground px-2 py-1.5 rounded border border-border outline-none select-all cursor-text",onFocus:B=>B.target.select(),"aria-label":"Pairing URL"})]}),d&&c.jsxs("p",{className:"text-[10px] text-center text-muted-foreground",children:["Expires in"," ",c.jsx("span",{className:d==="expired"?"text-destructive font-semibold":"text-foreground font-mono",children:d}),d!=="expired"&&c.jsx("button",{className:"ml-2 text-accent hover:underline",onClick:F,children:"Refresh"}),d==="expired"&&c.jsx("button",{className:"ml-2 text-accent hover:underline",onClick:F,children:"Generate new code"})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h3",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:"Paired devices"}),T&&c.jsx(sh,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),c.jsxs("div",{"data-testid":"pair-device-list",className:"space-y-1.5",children:[!T&&b.length===0&&c.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:"No paired devices yet"}),b.map((B,O)=>c.jsx(zQ,{device:B,idx:O,onRevoke:N},B.id))]})]})]})]})]})}const pf={build:{background:"hsl(217 91% 60% / 0.12)",borderColor:"hsl(217 91% 60% / 0.3)",color:"hsl(217 91% 60%)"},gate:{background:"hsl(38 92% 50% / 0.12)",borderColor:"hsl(38 92% 50% / 0.3)",color:"hsl(38 92% 50%)"},error:{background:"hsl(0 72% 51% / 0.12)",borderColor:"hsl(0 72% 51% / 0.3)",color:"hsl(0 72% 51%)"},done:{background:"hsl(160 60% 45% / 0.12)",borderColor:"hsl(160 60% 45% / 0.3)",color:"hsl(160 60% 45%)"},iteration:{background:"hsl(217 91% 60% / 0.12)",borderColor:"hsl(217 91% 60% / 0.3)",color:"hsl(210 100% 66%)"}},Jb={enter:{transform:"translateX(20px)",opacity:0},steady:{transform:"translateX(0)",opacity:1},flash:{transform:"translateX(0)",opacity:1},exit:{transform:"translateX(0)",opacity:0}};function WQ({type:e="build",label:t,retries:r=0,onClick:n,onApprove:i,onDismiss:s,animationState:o="steady"}){const a=(o==="flash"?pf.done:pf[e])||pf.build,l=Jb[o]||Jb.steady,h=o==="exit"?"200ms":o==="flash"?"300ms":"200ms";return c.jsxs("div",{className:"ops-strip-entry",style:{display:"inline-flex",alignItems:"center",gap:"4px",height:"24px",padding:"0 10px",borderRadius:"12px",border:`1px solid ${a.borderColor}`,background:a.background,color:a.color,fontSize:"11px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.04em",cursor:n?"pointer":"default",whiteSpace:"nowrap",transition:`transform ${h} ease, opacity ${h} ease, background 300ms ease, border-color 300ms ease, color 300ms ease`,...l},onClick:n,role:"button",tabIndex:0,onKeyDown:u=>{u.key==="Enter"&&n&&n()},children:[c.jsxs("span",{style:{fontSize:"12px",lineHeight:1},children:[e==="build"&&"▶",e==="gate"&&"⚠",e==="error"&&"✕",e==="done"&&"✓",e==="iteration"&&"↻"]}),c.jsx("span",{children:t}),r>0&&c.jsx("span",{style:{background:"hsl(38 90% 50% / 0.2)",color:"hsl(38 90% 60%)",padding:"0 5px",borderRadius:"9999px",fontSize:"9px"},children:r}),e==="gate"&&i&&c.jsx("button",{className:"ops-strip-approve",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"18px",height:"18px",borderRadius:"9px",border:`1px solid ${a.borderColor}`,background:"transparent",color:a.color,fontSize:"11px",cursor:"pointer",padding:0,marginLeft:"2px",lineHeight:1},onClick:u=>{u.stopPropagation(),i()},title:"Approve gate",children:"✓"}),e==="error"&&s&&c.jsx("button",{className:"ops-strip-dismiss",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"18px",height:"18px",borderRadius:"9px",border:"none",background:"transparent",color:a.color,fontSize:"10px",cursor:"pointer",padding:0,marginLeft:"2px",opacity:.6,lineHeight:1},onClick:u=>{u.stopPropagation(),s()},title:"Dismiss error",children:"✕"})]})}function HQ(e){return!e||e<=0?"":`$${e.toFixed(2)}`}function UQ(e){const t=Math.floor(e/1e3),r=Math.floor(t/60),n=t%60;return`${r}:${String(n).padStart(2,"0")}`}function YQ(e){const t=Math.round(e*60),r=Math.floor(t/60),n=t%60;return`${r}:${String(n).padStart(2,"0")}`}function VQ({activeBuild:e,gates:t,items:r,recentErrors:n,iterationStates:i,now:s=Date.now()}){const o=[];if(e&&e.featureCode){const a=e.currentStep?`${e.currentStep}`:"building",l=e.totalSteps?` · step ${e.currentStepIndex??"?"}/${e.totalSteps}`:"",h=HQ(e.cumulative_cost_usd),u=h?` · ${h}`:"",d=e.flowId||e.startedAt||e.featureCode;o.push({key:`build-${e.featureCode}-${d}`,type:e.status==="complete"?"done":"build",label:`${e.featureCode} · ${a}${l}${u}`,featureCode:e.featureCode,retries:e.retries??0})}if(Array.isArray(t)){for(const a of t)if(a.status==="pending"){const l=Tl[a.stepId]??(a.fromPhase||a.toPhase||"Gate"),h=Array.isArray(r)?r.find(d=>d.id===a.itemId):null,u=(h==null?void 0:h.title)||a.featureCode||"";o.push({key:`gate-${a.id}`,type:"gate",label:u?`${l} — ${u}`:l,featureCode:a.featureCode||"",gateId:a.id})}}if(i){for(const[a,l]of i)if(l.status==="running"){const h=l.loopType==="review"?"review":"coverage",u=`${l.count}/${l.maxIterations}`;let d="";if(l.wallClockTimeout!=null&&l.startedAt){const p=s-new Date(l.startedAt).getTime();d=`, ${UQ(p)}/${YQ(l.wallClockTimeout)}`}o.push({key:`iter-${a}`,type:"iteration",label:`${h} ${u}${d}`})}}if(Array.isArray(n))for(const a of n){const l=a.featureCode||"system",h=(a.message||a.errorType||"error").substring(0,60);o.push({key:`error-${a.timestamp}-${h.substring(0,10)}`,type:"error",label:`${l} · ${h}`,featureCode:l,timestamp:a.timestamp})}return o}function GQ({activeView:e,onSelectFeature:t}){const{activeBuild:r,gates:n,items:i,recentErrors:s,resolveGate:o,iterationStates:a}=Ee(Ti(O=>({activeBuild:O.activeBuild,gates:O.gates,items:O.items,recentErrors:O.recentErrors,resolveGate:O.resolveGate,iterationStates:O.iterationStates}))),[l,h]=C.useState(new Map),u=C.useRef([]),d=C.useRef(new Set),p=C.useRef(new Set),[f,m]=C.useState(null),g=C.useRef(null),x=(r==null?void 0:r.featureCode)??null;C.useEffect(()=>{if(!x){m(null),g.current=null;return}x!==g.current&&(g.current=x,_e(`/api/lifecycle/budget?featureCode=${encodeURIComponent(x)}`).then(O=>O.json()).then(O=>m(O)).catch(()=>{}))},[x]);const y=C.useRef(0);C.useEffect(()=>{if(!x)return;const O=a?[...a.values()].reduce((M,A)=>M+(A.count??0),0):0;O!==y.current&&(y.current=O,_e(`/api/lifecycle/budget?featureCode=${encodeURIComponent(x)}`).then(M=>M.json()).then(M=>m(M)).catch(()=>{}))},[a,x]);const k=C.useRef(r),[b,w]=C.useState(null);C.useEffect(()=>{const O=k.current;if(O&&O.featureCode&&!r){w({...O,status:"complete"});const M=setTimeout(()=>w(null),3e3);return k.current=r,()=>clearTimeout(M)}k.current=r},[r]);const T=r||b,[S,j]=C.useState(()=>Date.now()),E=a&&[...a.values()].some(O=>O.status==="running");C.useEffect(()=>{if(!E)return;const O=setInterval(()=>j(Date.now()),1e3);return()=>clearInterval(O)},[E]);const L=C.useMemo(()=>VQ({activeBuild:T,gates:n,items:i,recentErrors:s,iterationStates:a,now:S}),[T,n,i,s,a,S]),N=C.useMemo(()=>L.filter(O=>!d.current.has(O.key)),[L]);C.useEffect(()=>{const O=new Set(u.current.map(A=>A.key)),M=N.filter(A=>!O.has(A.key)).map(A=>A.key);M.length>0&&(h(A=>{const $=new Map(A);for(const z of M)$.set(z,"enter");return $}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{h(A=>{const $=new Map(A);for(const z of M)$.get(z)==="enter"&&$.set(z,"steady");return $})})}));for(const A of N)A.type==="done"&&!p.current.has(A.key)&&(p.current.add(A.key),h($=>{const z=new Map($);return z.set(A.key,"flash"),z}),setTimeout(()=>{h($=>{const z=new Map($);return z.set(A.key,"exit"),z}),setTimeout(()=>{d.current.add(A.key),h($=>{const z=new Map($);return z.delete(A.key),z})},500)},2e3));u.current=N},[N]);const F=C.useCallback(O=>{h(M=>{const A=new Map(M);return A.set(O,"exit"),A}),setTimeout(()=>{d.current.add(O),h(M=>{const A=new Map(M);return A.delete(O),A})},200)},[]),R=C.useCallback(O=>{o&&o(O,"approve","Approved from ops strip")},[o]);if(e==="docs"||N.length===0)return null;const B=MQ(f);return c.jsxs("div",{className:"ops-strip",style:{height:"36px",display:"flex",alignItems:"center",gap:"6px",padding:"0 12px",overflowX:"auto",overflowY:"hidden",borderTop:"1px solid hsl(var(--border))",background:"hsl(var(--background))",flexShrink:0},children:[N.map(O=>c.jsx(WQ,{type:O.type,label:O.label,retries:O.retries,animationState:l.get(O.key)||"steady",onClick:t?()=>t(O.featureCode):void 0,onApprove:O.type==="gate"&&O.gateId?()=>R(O.gateId):void 0,onDismiss:O.type==="error"?()=>F(O.key):void 0},O.key)),B&&c.jsx("span",{className:"ml-auto text-[9px] text-muted-foreground font-mono shrink-0 opacity-70",title:"Cumulative budget usage: review / coverage",children:B})]})}const XQ={ok:"hsl(var(--success))",warn:"hsl(var(--warning))",error:"hsl(var(--destructive))"},Fc="hsl(var(--muted-foreground))",KQ={"installed-current":"hsl(var(--success))",absent:"hsl(var(--muted-foreground))",foreign:"hsl(var(--destructive))","installed-stale":"hsl(var(--warning))","workspace-unverified":"hsl(var(--warning))",unavailable:"hsl(var(--muted-foreground))"};function On({color:e}){return c.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:e,display:"inline-block",flexShrink:0}})}function mf({title:e,children:t}){return c.jsxs("div",{className:"mt-2 first:mt-0",children:[c.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground mb-1",children:e}),t]})}function QQ(e){return e.optional?"hsl(var(--warning))":"hsl(var(--destructive))"}async function JQ(e){var t;try{return await((t=navigator.clipboard)==null?void 0:t.writeText(e)),!0}catch{return!1}}function kN({command:e,testid:t,label:r="copy"}){const[n,i]=C.useState(!1);return e?c.jsx("button",{"data-testid":t,className:"text-[10px] text-muted-foreground hover:text-foreground transition-colors shrink-0",title:`Copy: ${e}`,"aria-label":`Copy command: ${e}`,onClick:async s=>{s.stopPropagation(),await JQ(e)&&(i(!0),setTimeout(()=>i(!1),1200))},children:n?"✓ copied":r}):null}function ZQ(){var w;const{loading:e,workspace:t}=um()||{},[r,n]=C.useState(null),[i,s]=C.useState(!1),[o,a]=C.useState(null),[l,h]=C.useState(!1),[u,d]=C.useState(!1),[p,f]=C.useState(null),m=C.useRef(null),g=C.useRef(0),x=C.useCallback(async(T=!1)=>{const S=++g.current;s(!0);try{const E=await(await _e(`/api/environment-health${T?"?refresh=1":""}`)).json();if(S!==g.current)return;n(E),a(null)}catch(j){if(S!==g.current)return;n(null),a((j==null?void 0:j.message)||"unavailable")}finally{S===g.current&&s(!1)}},[]),y=C.useCallback(async T=>{d(!0),f(null);try{const S=await _e("/api/environment-health/repair-hooks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:!!T})}),j=await S.json().catch(()=>null);(!S.ok||(j==null?void 0:j.ok)!==!0)&&f((j==null?void 0:j.error)||`repair failed (${S.status})`)}catch(S){f((S==null?void 0:S.message)||"repair failed")}finally{d(!1),x(!1)}},[x]);C.useEffect(()=>{e||!t||x(!1)},[e,t==null?void 0:t.id,t==null?void 0:t.root,x]),C.useEffect(()=>{if(!l)return;const T=j=>{var E;(E=m.current)!=null&&E.contains(j.target)||h(!1)},S=j=>{j.key==="Escape"&&h(!1)};return window.addEventListener("mousedown",T),window.addEventListener("keydown",S),()=>{window.removeEventListener("mousedown",T),window.removeEventListener("keydown",S)}},[l]);const k=r==null?void 0:r.summary,b=k?XQ[k]:Fc;return c.jsxs("div",{ref:m,className:"relative flex items-center shrink-0",children:[c.jsx("button",{"data-testid":"env-health-dot",className:"compose-btn-icon",onClick:()=>h(T=>!T),title:`Environment health: ${k||(i?"checking…":"unknown")}`,"aria-label":"Environment health","aria-haspopup":"dialog","aria-expanded":l,children:c.jsx(On,{color:b})}),l&&c.jsxs("div",{"data-testid":"env-health-panel",role:"dialog","aria-label":"Environment health",className:"absolute top-full right-0 mt-1 z-50 p-2 rounded-md shadow-lg text-xs",style:{background:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",minWidth:280,maxWidth:360},children:[c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Environment Health"}),c.jsx("button",{"data-testid":"env-health-refresh",className:"text-[11px] text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",onClick:()=>x(!0),disabled:i,title:"Refresh","aria-label":"Refresh environment health",children:"↻"})]}),o&&c.jsxs("div",{className:"mt-1 text-destructive",children:["Unavailable: ",o]}),!r&&!o&&c.jsx("div",{className:"mt-1 text-muted-foreground",children:i?"Checking…":"No data"}),r&&c.jsxs(c.Fragment,{children:[c.jsxs(mf,{title:"Dependencies",children:[Zb(r.dependencies,"dependency"),Zb(r.binaries,"binary")]}),c.jsx(mf,{title:"Version",children:c.jsx("div",{"data-testid":"env-health-version",className:"flex items-center gap-1.5",children:r.version?r.version.behind?c.jsxs(c.Fragment,{children:[c.jsx(On,{color:"hsl(var(--warning))"}),c.jsxs("span",{className:"flex-1",children:[r.version.current," → ",r.version.latest," (behind — run ",c.jsx("code",{children:"compose update"}),")"]}),c.jsx(kN,{command:"compose update",testid:"env-health-copy-version"})]}):c.jsxs(c.Fragment,{children:[c.jsx(On,{color:"hsl(var(--success))"}),c.jsxs("span",{children:[r.version.current," (up to date)"]})]}):c.jsxs(c.Fragment,{children:[c.jsx(On,{color:Fc}),c.jsx("span",{className:"text-muted-foreground",children:"version check unavailable"})]})})}),c.jsxs(mf,{title:"Git Hooks",children:[Object.entries(r.hooks||{}).filter(([T])=>T!=="unavailable").map(([T,S])=>c.jsxs("div",{"data-testid":`env-health-hook-${T}`,className:"flex items-center gap-1.5",children:[c.jsx(On,{color:KQ[S.state]||Fc}),c.jsx("span",{className:"font-mono",children:T}),c.jsxs("span",{className:"text-muted-foreground",children:[S.state,S.reason?` (${S.reason})`:""]})]},T)),((w=r.hooks)==null?void 0:w.unavailable)&&c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(On,{color:Fc}),c.jsx("span",{className:"text-muted-foreground",children:"hook status unavailable"})]}),(()=>{const T=Object.entries(r.hooks||{}).filter(([L])=>L!=="unavailable"),S=["installed-stale","absent","foreign"],j=T.some(([,L])=>S.includes(L==null?void 0:L.state)),E=T.some(([,L])=>(L==null?void 0:L.state)==="foreign");return j?c.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[c.jsx("button",{"data-testid":"env-health-repair-hooks",className:"text-[11px] px-2 py-0.5 rounded border border-border hover:bg-accent/30 transition-colors disabled:opacity-50",disabled:u,onClick:()=>{if(E){if(!window.confirm("A foreign git hook exists. Overwrite it with the Compose hook?"))return;y(!0)}else y(!1)},title:"Install / refresh Compose git hooks for this workspace",children:u?"Repairing…":"Repair hooks"}),p&&c.jsx("span",{className:"text-destructive text-[10px]",children:p})]}):null})()]})]})]})]})}function Zb(e,t){if(!e||e.unavailable)return c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(On,{color:"hsl(var(--warning))"}),c.jsxs("span",{className:"text-muted-foreground",children:[t==="binary"?"binaries":"skills"," unavailable"]})]});const r=e.missing||[],n=(e.present||[]).length;return c.jsxs(c.Fragment,{children:[r.map(i=>c.jsxs("div",{"data-testid":`env-health-${t}-${i.id}`,className:"flex items-center gap-1.5",children:[c.jsx(On,{color:QQ(i)}),c.jsx("span",{className:"font-mono truncate",children:i.id}),c.jsxs("span",{className:"text-muted-foreground flex-1",children:["missing",i.optional?" (optional)":""]}),c.jsx(kN,{command:i.install,testid:`env-health-copy-${i.id}`,label:"copy install"})]},i.id)),r.length===0&&c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(On,{color:"hsl(var(--success))"}),c.jsxs("span",{className:"text-muted-foreground",children:[n," ",t==="binary"?"binaries":"skills"," present"]})]})]})}function eJ(e,t={}){const{bugCode:r="",intent:n="",description:i="",resumableCode:s=""}=t;if(e==="new"){const a=(n||"").trim();return a?{args:{mode:"new",description:a}}:{error:"Product intent is required"}}if(e==="resume"){const a=(s||"").trim();return a?{args:{featureCode:a,mode:"bug",resume:!0}}:{error:"No active fix to resume"}}const o=(r||"").trim();return o?{args:{featureCode:o,mode:"bug",description:(i||"").trim()}}:{error:"Bug code is required"}}function tJ({activeBuild:e,onClose:t}){const r=e&&e.mode==="bug"&&e.featureCode?e.featureCode:"",[n,i]=C.useState("fix"),[s,o]=C.useState(""),[a,l]=C.useState(""),[h,u]=C.useState(""),[d,p]=C.useState(!1),[f,m]=C.useState(null);async function g(y){y==null||y.preventDefault(),m(null);const k=eJ(n,{bugCode:s,intent:a,description:h,resumableCode:r});if(k.error){m(k.error);return}p(!0);try{await Ku(k.args),t==null||t()}catch(b){m(b.message||"Failed to launch"),p(!1)}}const x=d||n==="fix"&&!s.trim()||n==="new"&&!a.trim()||n==="resume"&&!r;return c.jsx("div",{className:"absolute top-full right-0 mt-1 w-64 rounded-md border border-border bg-popover shadow-lg z-50","data-testid":"launch-popover",children:c.jsxs("form",{className:"p-2 space-y-2",onSubmit:g,children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"Lifecycle"}),c.jsxs("div",{className:"flex items-center gap-1.5",role:"radiogroup","aria-label":"Launch lifecycle",children:[c.jsx("button",{type:"button",role:"radio","aria-checked":n==="fix",className:`text-[10px] px-2 py-1 rounded border cursor-pointer ${n==="fix"?"bg-accent/10 border-accent text-foreground":"bg-muted border-border text-muted-foreground"}`,"data-testid":"launch-mode-fix",onClick:()=>i("fix"),children:"Fix"}),c.jsx("button",{type:"button",role:"radio","aria-checked":n==="new",className:`text-[10px] px-2 py-1 rounded border cursor-pointer ${n==="new"?"bg-accent/10 border-accent text-foreground":"bg-muted border-border text-muted-foreground"}`,"data-testid":"launch-mode-new",onClick:()=>i("new"),children:"New"}),c.jsx("button",{type:"button",role:"radio","aria-checked":n==="resume","aria-disabled":!r,disabled:!r,className:`text-[10px] px-2 py-1 rounded border ${r?n==="resume"?"bg-accent/10 border-accent text-foreground cursor-pointer":"bg-muted border-border text-muted-foreground cursor-pointer":"bg-muted border-border text-muted-foreground opacity-50 cursor-not-allowed"}`,"data-testid":"launch-mode-resume",onClick:()=>{r&&i("resume")},children:"Resume"})]})]}),n==="new"?c.jsxs("div",{className:"space-y-1",children:[c.jsx("label",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground",htmlFor:"launch-intent",children:"Product intent"}),c.jsx("textarea",{id:"launch-intent",className:"w-full text-xs bg-muted text-foreground px-2 py-1.5 rounded border border-border outline-none resize-none",rows:3,value:a,onChange:y=>l(y.target.value),"data-testid":"launch-intent-input",autoFocus:!0})]}):n==="resume"?c.jsx("div",{className:"text-[10px] text-muted-foreground","data-testid":"launch-resume-target",children:r?c.jsxs(c.Fragment,{children:["Resume active fix: ",c.jsx("span",{className:"text-foreground",children:r})]}):"No active fix to resume."}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("label",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground",htmlFor:"launch-bugcode",children:"Bug code"}),c.jsx("input",{id:"launch-bugcode",type:"text",className:"w-full text-xs bg-muted text-foreground px-2 py-1.5 rounded border border-border outline-none",value:s,onChange:y=>o(y.target.value),"data-testid":"launch-bugcode-input",autoFocus:!0})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("label",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground",htmlFor:"launch-desc",children:"Description (optional)"}),c.jsx("textarea",{id:"launch-desc",className:"w-full text-xs bg-muted text-foreground px-2 py-1.5 rounded border border-border outline-none resize-none",rows:3,value:h,onChange:y=>u(y.target.value),"data-testid":"launch-description"})]})]}),f?c.jsx("div",{className:"text-[10px] text-destructive",role:"alert",children:f}):null,c.jsxs("div",{className:"flex items-center justify-end gap-1.5",children:[c.jsx("button",{type:"button",className:"text-[10px] px-2 py-1 rounded border border-border text-muted-foreground hover:bg-muted/50",onClick:()=>t==null?void 0:t(),disabled:d,"data-testid":"launch-cancel",children:"Cancel"}),c.jsx("button",{type:"submit",className:"text-[10px] px-2 py-1 rounded border border-accent bg-accent/10 text-foreground disabled:opacity-50",disabled:x,"data-testid":"launch-submit",children:d?"Launching…":"Launch"})]})]})})}const rJ={title:"Build all PLANNED features?",body:"This builds every still-buildable (PLANNED/PARTIAL) feature on the roadmap in dependency order. It is roadmap-wide and expensive."};function nJ(){return{mode:"all"}}function CN(e){return(e??"").trim()}function iJ(e){return CN(e).length>0}function sJ(e){const t=CN(e);return t?{featureCode:t,mode:"gsd"}:null}function oJ(){const e=hm(),[t,r]=C.useState(!1),[n,i]=C.useState(""),[s,o]=C.useState(!1),[a,l]=C.useState(null),h=C.useRef(null);C.useEffect(()=>{if(!t)return;const m=x=>{var y;(y=h.current)!=null&&y.contains(x.target)||r(!1)},g=x=>{x.key==="Escape"&&r(!1)};return window.addEventListener("mousedown",m),window.addEventListener("keydown",g),()=>{window.removeEventListener("mousedown",m),window.removeEventListener("keydown",g)}},[t]);function u(){l(null),o(!1)}async function d(m){o(!0),l(null);try{await Ku(m),r(!1),i(""),o(!1)}catch(g){l(g.message||"Failed to start build"),o(!1)}}async function p(){await e(rJ)&&await d(nJ())}async function f(m){m==null||m.preventDefault();const g=sJ(n);if(!g){l("Feature code is required");return}await d(g)}return c.jsxs("div",{ref:h,className:"relative flex items-center shrink-0",children:[c.jsx("button",{type:"button","data-testid":"build-all-gsd-trigger",className:"compose-btn-icon",onClick:()=>{r(m=>!m),u()},title:"Batch builds: build all PLANNED features or run GSD on one feature","aria-label":"Batch builds","aria-haspopup":"dialog","aria-expanded":t,children:c.jsx("span",{"aria-hidden":"true",className:"text-[13px] leading-none",children:"≣"})}),t&&c.jsx("div",{"data-testid":"build-all-gsd-popover",role:"dialog","aria-label":"Batch builds",className:"absolute top-full right-0 mt-1 w-64 rounded-md border border-border bg-popover shadow-lg z-50",children:c.jsxs("div",{className:"p-2 space-y-3",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Build all"}),c.jsx("button",{type:"button","data-testid":"build-all-submit",className:"w-full text-[10px] px-2 py-1.5 rounded border border-accent bg-accent/10 text-foreground disabled:opacity-50",disabled:s,onClick:p,children:s?"Starting…":"Build all PLANNED features"})]}),c.jsxs("form",{className:"space-y-1",onSubmit:f,children:[c.jsx("label",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",htmlFor:"build-gsd-feature",children:"GSD"}),c.jsx("input",{id:"build-gsd-feature",type:"text",className:"w-full text-xs bg-muted text-foreground px-2 py-1.5 rounded border border-border outline-none",placeholder:"FEATURE-CODE",value:n,onChange:m=>i(m.target.value),"data-testid":"build-gsd-feature-input"}),c.jsx("button",{type:"submit","data-testid":"build-gsd-submit",className:"w-full text-[10px] px-2 py-1.5 rounded border border-accent bg-accent/10 text-foreground disabled:opacity-50",disabled:s||!iJ(n),children:s?"Starting…":"Run GSD"})]}),a?c.jsx("div",{className:"text-[10px] text-destructive",role:"alert","data-testid":"build-all-gsd-error",children:a}):null]})})]})}const gf=["dashboard","graph","tree","docs","journal","design","gates","validate","qa-scope","pipeline","pipeline-editor","sessions","build-history","ideabox"];function aJ(e,t){return!t||!Array.isArray(e)?!1:e.includes(t)}function lJ(e){return(e==null?void 0:e[0])??null}const cJ="compose:mainTabs",wN="compose:activeTab";function hJ(){var e;try{const t=(e=globalThis.localStorage)==null?void 0:e.getItem(cJ);if(!t)return[...gf];const r=JSON.parse(t);if(Array.isArray(r)&&r.length>=1){let n=r;for(const i of gf)if(!n.includes(i)){const s=n.indexOf("docs");s>=0?n=[...n.slice(0,s+1),i,...n.slice(s+1)]:n=[...n,i]}return n}}catch{}return[...gf]}function uJ(e){var t;try{const r=(t=globalThis.localStorage)==null?void 0:t.getItem(wN);if(r&&aJ(e,r))return r}catch{}return lJ(e)}function e1(e){var t;try{(t=globalThis.localStorage)==null||t.setItem(wN,e)}catch{}}function vN(e,t){var r;try{const n=(r=globalThis.localStorage)==null?void 0:r.getItem(e);return n==null?t:n!=="false"}catch{return t}}function SN(e,t){var r;try{(r=globalThis.localStorage)==null||r.setItem(e,String(!!t))}catch{}}const TN="compose:sidebarOpen",_N="compose:contextPanelOpen";function dJ(){return vN(TN,!0)}function fJ(e){return SN(TN,e)}function pJ(){return vN(_N,!1)}function t1(e){return SN(_N,e)}cs.use(dm);const mJ={overlay:"#161625",text:"#f1f5f9",textMuted:"#475569",border:"#334155",accent:"#FBBF24",danger:"#ef4444"},gJ={overlay:"#F5F5F5",text:"#0a0a0a",textMuted:"#a3a3a3",border:"#d4d4d4",accent:"#FBBF24",danger:"#dc2626"};function xJ(){const[e,t]=C.useState(()=>typeof document<"u"&&document.documentElement.classList.contains("dark"));return C.useEffect(()=>{if(typeof document>"u")return;const r=new MutationObserver(()=>t(document.documentElement.classList.contains("dark")));return r.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>r.disconnect()},[]),e}function yJ(e){return[{selector:"node",style:{label:"data(label)","text-valign":"center","text-halign":"center","text-wrap":"wrap","text-max-width":"150px","font-size":"10px","font-family":'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:e.text,"background-color":e.overlay,"border-width":1,"border-color":e.border,"border-opacity":.8,width:170,height:64,shape:"round-rectangle","text-outline-width":0,padding:"6px"}},{selector:"node:selected",style:{"border-width":2,"border-opacity":1,"border-color":e.accent}},{selector:"node[hasWarning = 1]",style:{"border-color":e.danger,"border-width":2,"border-opacity":1}},{selector:"node.connect-source",style:{"border-color":e.accent,"border-width":3,"border-opacity":1,"background-color":e.overlay}},{selector:"node.multi-select",style:{"border-color":e.accent,"border-width":3,"border-style":"dashed","border-opacity":1}},{selector:".connect-flash",style:{"border-color":e.danger,"border-width":3,"border-opacity":1,"line-color":e.danger,"target-arrow-color":e.danger}},{selector:"edge",style:{width:1.2,"line-color":e.textMuted,"target-arrow-color":e.textMuted,"target-arrow-shape":"triangle","curve-style":"bezier","arrow-scale":.8,opacity:.6}}]}const r1={name:"dagre",rankDir:"LR",rankSep:90,nodeSep:45,padding:40};function La(e,t){if(!e)return"";const r=String(e).replace(/\s+/g," ").trim();return r.length>t?`${r.slice(0,t-1)}…`:r}function bJ(e,t){var o,a,l;if(e.kind!=="flow")return null;const r=(o=e._extra)==null?void 0:o.flow;if(!r)return null;const n=(l=(a=t==null?void 0:t._doc)==null?void 0:a.flows)==null?void 0:l[r];if(!n||typeof n!="object")return{inputs:[],output:null,name:r};const i=n.input&&typeof n.input=="object"?Object.keys(n.input):[],s=n.output!=null&&n.output!==""?String(n.output):null;return{inputs:i,output:s,name:r}}function jN(e,t){const r=[e.id||"(unnamed)"],n=bJ(e,t);if(n)return r.push(La(`⊟ flow: ${n.name}`,28)),n.inputs.length&&r.push(La(`in: ${n.inputs.join(", ")}`,36)),n.output&&r.push(La(`out: ${n.output}`,36)),r.join(`
|
|
869
|
+
`,n}function DQ(e,t){return(t||[]).filter(n=>!n.superseded).map(n=>({title:n.question,type:"decision",decided:!0}))}const Aa={es:null},pi=Rm((e,t)=>({session:null,messages:[],decisions:[],status:"idle",error:null,streamingMessage:null,scope:null,featureCode:null,designDocPath:null,draftDoc:"",docManuallyEdited:!1,researchItems:[],topicOutline:[],hydrate:async(r,n)=>{if(!r){const l=t().scope;if(l)r=l,n=t().featureCode||null;else try{const h=JSON.parse(localStorage.getItem("compose:designSession")||"{}");r=h.scope||"product",n=h.featureCode||null}catch{r="product"}}const i=t().docManuallyEdited,s=t().draftDoc,o=t().researchItems||[];e({session:null,messages:[],decisions:[],status:"idle",error:null,streamingMessage:null,designDocPath:null,scope:r,featureCode:n,draftDoc:"",docManuallyEdited:!1,researchItems:[],topicOutline:[]});const a=r==="feature"&&n?`?scope=feature&featureCode=${n}`:`?scope=${r}`;try{const l=await _e(`/api/design/session${a}`),{session:h}=await l.json();if(h){const u=h.messages||[],d=h.decisions||[],p=Kb(u,d),f=DQ(u,d);e({session:h,messages:u,decisions:d,status:h.status==="complete"?"complete":"active",scope:r,featureCode:n,draftDoc:i?s:p,docManuallyEdited:i,topicOutline:f,researchItems:o}),t().disconnectSSE(),t().connectSSE()}else e({session:null,messages:[],decisions:[],status:"idle",error:null,streamingMessage:null,scope:r,featureCode:n,draftDoc:"",docManuallyEdited:!1,researchItems:[],topicOutline:[]}),t().disconnectSSE()}catch(l){e({error:l.message})}},startSession:async(r="product",n=null)=>{try{const i=await _e("/api/design/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:r,featureCode:n})});if(!i.ok){const{error:o}=await i.json();e({error:o});return}const{session:s}=await i.json();try{localStorage.setItem("compose:designSession",JSON.stringify({scope:r,featureCode:n}))}catch{}e({session:s,messages:s.messages||[],decisions:s.decisions||[],status:"active",error:null,scope:r,featureCode:n}),t().connectSSE()}catch(i){e({error:i.message})}},sendMessage:async r=>{const{session:n,messages:i}=t();if(!n)return;const s=n.scope,o=n.featureCode,a={role:"human",type:"text",content:r,timestamp:new Date().toISOString()};e(l=>({messages:[...l.messages,a],status:"streaming"}));try{const l=await _e("/api/design/message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:s,featureCode:o,type:"text",content:r})});l.ok||e({messages:i,status:"active",error:`Failed to send message: ${l.status}`})}catch(l){e({messages:i,status:"active",error:l.message})}},selectCard:async(r,n=null,i=null)=>{const{session:s,messages:o}=t();if(!s)return;const a={role:"human",type:"card_select",content:{cardId:r,comment:n},timestamp:new Date().toISOString()};e(l=>({messages:[...l.messages,a],status:"streaming"}));try{const l=await _e("/api/design/message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:s.scope,featureCode:s.featureCode,type:"card_select",cardId:r,comment:n,messageIndex:i})});l.ok||e({messages:o,status:"active",error:`Failed to select card: ${l.status}`})}catch(l){e({messages:o,status:"active",error:l.message})}},reviseDecision:async r=>{const{session:n}=t();if(!n)return;const i=t().decisions[r];if(!(!i||i.superseded))try{const s=await _e("/api/design/revise",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:n.scope,featureCode:n.featureCode,decisionIndex:r})});if(!s.ok){const{error:o}=await s.json().catch(()=>({error:"Revision failed"}));e({error:o});return}t().hydrate(n.scope,n.featureCode)}catch(s){e({error:s.message})}},completeDesign:async()=>{const{session:r,draftDoc:n}=t();if(r){e({status:"summarizing"});try{const i={scope:r.scope,featureCode:r.featureCode};n&&(i.draftDoc=n);const s=await _e("/api/design/complete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!s.ok){const{error:l}=await s.json().catch(()=>({error:"Unknown error"}));e({error:l,status:"active"});return}const o=await s.json(),a={session:o.session,status:"complete",designDocPath:o.designDocPath||null};o.error&&(a.error=o.error),e(a)}catch(i){e({error:i.message,status:"active"})}}},connectSSE:()=>{if(Aa.es)return;const{scope:r,featureCode:n}=t(),i=new URLSearchParams({scope:r||"product"});n&&i.set("featureCode",n);const s=v1("/api/design/stream"),o=s.includes("?")?"&":"?",a=new EventSource(`${s}${o}${i}`);Aa.es=a,a.addEventListener("ack",()=>{e(l=>l.status!=="streaming"?{status:"streaming"}:{})}),a.addEventListener("text",l=>{const h=JSON.parse(l.data);e(u=>u.streamingMessage?{streamingMessage:{...u.streamingMessage,content:u.streamingMessage.content+h.content}}:{status:"streaming",streamingMessage:{role:"assistant",type:"text",content:h.content,timestamp:new Date().toISOString()}})}),a.addEventListener("decision",l=>{const h=JSON.parse(l.data);e(u=>({status:"streaming",streamingMessage:u.streamingMessage?{...u.streamingMessage,type:"decision",decisionData:h}:{role:"assistant",type:"decision",content:"",decisionData:h,timestamp:new Date().toISOString()}}))}),a.addEventListener("done",()=>{e(l=>({messages:l.streamingMessage?[...l.messages,l.streamingMessage]:l.messages,streamingMessage:null,status:"active"})),t().hydrate()}),a.addEventListener("research",l=>{const h=JSON.parse(l.data);e(u=>({researchItems:[...u.researchItems,{id:h.id,tool:h.tool,input:h.input,timestamp:h.timestamp,summary:null}]}))}),a.addEventListener("research_result",l=>{const h=JSON.parse(l.data);e(u=>{const d=[...u.researchItems],p=h.id?d.findIndex(f=>f.id===h.id):-1;return p!==-1&&(d[p]={...d[p],summary:h.summary}),{researchItems:d}})}),a.addEventListener("error",l=>{try{const h=JSON.parse(l.data);e(u=>({status:"active",streamingMessage:null,error:h.message||"Agent error",messages:u.messages}))}catch{e({status:"active",streamingMessage:null})}}),a.onerror=()=>{e({status:"active"})}},disconnectSSE:()=>{Aa.es&&(Aa.es.close(),Aa.es=null)},reset:()=>{try{localStorage.removeItem("compose:designSession")}catch{}e({session:null,messages:[],decisions:[],status:"idle",error:null,streamingMessage:null,scope:null,featureCode:null,designDocPath:null,draftDoc:"",docManuallyEdited:!1,researchItems:[],topicOutline:[]})},updateDraftDoc:r=>{e({draftDoc:r,docManuallyEdited:!0})},resetDocEdited:()=>{const{messages:r,decisions:n}=t(),i=Kb(r,n);e({draftDoc:i,docManuallyEdited:!1})}}));function PQ(){const{draftDoc:e,docManuallyEdited:t,updateDraftDoc:r,resetDocEdited:n}=pi(Ti(h=>({draftDoc:h.draftDoc,docManuallyEdited:h.docManuallyEdited,updateDraftDoc:h.updateDraftDoc,resetDocEdited:h.resetDocEdited}))),[i,s]=C.useState(!1),o=!e;let a="empty",l={color:"hsl(var(--muted-foreground))"};return t?(a="edited",l={color:"hsl(var(--primary))"}):o||(a="draft",l={color:"hsl(var(--muted-foreground))"}),c.jsxs("div",{className:"h-full flex flex-col",style:{fontFamily:"inherit"},children:[c.jsxs("div",{className:"flex items-center justify-between px-3 py-2 shrink-0",style:{borderBottom:"1px solid hsl(var(--border))"},children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-[12px] font-semibold",style:{color:"hsl(var(--foreground))"},children:"Design Document"}),c.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{...l,background:"hsl(var(--muted))"},children:a})]}),!o&&c.jsx("button",{onClick:()=>s(h=>!h),className:"text-[11px] px-2 py-1 rounded transition-colors",style:{color:"hsl(var(--muted-foreground))",background:i?"hsl(var(--accent))":"transparent"},onMouseEnter:h=>{h.currentTarget.style.color="hsl(var(--foreground))"},onMouseLeave:h=>{h.currentTarget.style.color="hsl(var(--muted-foreground))"},children:i?"Preview":"Edit"})]}),c.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:o?c.jsx("div",{className:"p-4 text-[12px] italic",style:{color:"hsl(var(--muted-foreground))"},children:"Start the design conversation to see the document build here."}):i?c.jsxs("div",{className:"h-full flex flex-col p-2 gap-2",children:[c.jsx("textarea",{className:"flex-1 min-h-0 w-full resize-none rounded p-2 text-[12px]",style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",background:"hsl(var(--background))",color:"hsl(var(--foreground))",border:"1px solid hsl(var(--border))",outline:"none"},value:e,onChange:h=>r(h.target.value),spellCheck:!1}),c.jsx("button",{onClick:()=>{n(),s(!1)},className:"shrink-0 text-[11px] px-3 py-1.5 rounded transition-colors self-start",style:{color:"hsl(var(--muted-foreground))",border:"1px solid hsl(var(--border))",background:"transparent"},onMouseEnter:h=>{h.currentTarget.style.color="hsl(var(--foreground))",h.currentTarget.style.borderColor="hsl(var(--foreground))"},onMouseLeave:h=>{h.currentTarget.style.color="hsl(var(--muted-foreground))",h.currentTarget.style.borderColor="hsl(var(--border))"},children:"Reset to auto-generated"})]}):c.jsx("div",{className:"p-4 prose prose-sm max-w-none",style:{color:"hsl(var(--foreground))","--tw-prose-body":"hsl(var(--foreground))","--tw-prose-headings":"hsl(var(--foreground))","--tw-prose-code":"hsl(var(--foreground))","--tw-prose-bold":"hsl(var(--foreground))","--tw-prose-links":"hsl(var(--primary))",fontSize:"12px"},children:c.jsx(Fm,{remarkPlugins:[Pm],children:e})})})]})}function Qb(e){if(!e)return"—";const t=Date.now()-new Date(e).getTime(),r=Math.floor(t/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const n=Math.floor(r/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}function RQ(e){if(!e)return"";const t=Math.max(0,Math.floor((new Date(e).getTime()-Date.now())/1e3));if(t<=0)return"expired";const r=Math.floor(t/60),n=t%60;return`${r}:${String(n).padStart(2,"0")}`}function zQ({device:e,idx:t,onRevoke:r}){const[n,i]=C.useState(!1),s=C.useRef(null),o=C.useCallback(()=>{if(!n){i(!0),s.current=setTimeout(()=>i(!1),3e3);return}clearTimeout(s.current),i(!1),r(e.id)},[n,e.id,r]);return C.useEffect(()=>()=>clearTimeout(s.current),[]),c.jsxs("div",{className:"flex items-center gap-3 py-2 px-3 rounded-lg bg-muted/30 border border-border",style:{opacity:e.revoked?.5:1},children:[c.jsx(D1,{className:"h-4 w-4 text-muted-foreground shrink-0"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:e.name||"Unknown device"}),e.revoked&&c.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-destructive/10 text-destructive shrink-0",children:"revoked"})]}),c.jsxs("div",{className:"text-[10px] text-muted-foreground mt-0.5",children:["Paired ",Qb(e.paired_at),e.last_seen&&!e.revoked&&` · seen ${Qb(e.last_seen)}`]})]}),!e.revoked&&c.jsx("button",{"data-testid":`pair-device-revoke-${t}`,onClick:o,className:`shrink-0 text-[10px] px-2 py-1 rounded transition-colors ${n?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"text-muted-foreground hover:text-destructive hover:bg-destructive/10"}`,title:n?"Click again to confirm revoke":"Revoke device",children:n?c.jsxs("span",{className:"flex items-center gap-1",children:[c.jsx(oh,{className:"h-3 w-3"})," Confirm"]}):c.jsx(oh,{className:"h-3 w-3"})})]})}function qQ({open:e,onClose:t,publicHost:r}){const[n,i]=C.useState("idle"),[s,o]=C.useState(null),[a,l]=C.useState(""),[h,u]=C.useState(null),[d,p]=C.useState(""),[f,m]=C.useState(null),[g,x]=C.useState(""),[y,k]=C.useState(null),[b,w]=C.useState([]),[T,S]=C.useState(!1),j=C.useRef(null),E=C.useRef(null),L=C.useCallback(async()=>{S(!0);try{const B=await _e("/api/auth/devices",{headers:rn()});if(B.ok){const O=await B.json();w(O.devices||[])}}catch{}finally{S(!1)}},[]),N=C.useCallback(async B=>{try{(await _e(`/api/auth/devices/${B}`,{method:"DELETE",headers:rn()})).ok&&await L()}catch{}},[L]),F=C.useCallback(async()=>{i("loading"),x(""),k(null),o(null),l(""),u(null),p("");try{const B=await _e("/api/auth/pair/init",{method:"POST",headers:rn({"Content-Type":"application/json"})});if(B.status===503){i("error"),x("COMPOSE_API_TOKEN is not set — the server cannot authenticate this request. Start compose via `compose start` so the supervisor generates the token, or set COMPOSE_API_TOKEN manually.");return}if(!B.ok){const $=await B.json().catch(()=>({}));i("error"),x($.error||`Server returned ${B.status}`);return}const O=await B.json(),M=O.public_host||r||(typeof window<"u"?window.location.origin:""),A=O.pair_url||`${M}/m/pair?code=${O.code}`;m(O.public_host||r||null),o(O.code),l(A),u(O.expires_at),i("ready")}catch(B){i("error"),x(B.message||"Network error")}},[r]);if(C.useEffect(()=>{if(!e){i("idle"),o(null),l(""),u(null),p(""),x(""),k(null),clearInterval(E.current);return}F(),L()},[e]),C.useEffect(()=>{if(n!=="ready"||!a||!j.current)return;let B=!1;return(async()=>{try{const O=(await Ue(async()=>{const{default:M}=await import("./browser-BSM23If2.js").then(A=>A.b);return{default:M}},__vite__mapDeps([64,5,6]))).default;!B&&j.current&&await O.toCanvas(j.current,a,{width:200,margin:2,color:{dark:"#000000",light:"#ffffff"}})}catch{}})(),()=>{B=!0}},[n,a]),C.useEffect(()=>{if(!h){clearInterval(E.current);return}clearInterval(E.current);const B=()=>p(RQ(h));return B(),E.current=setInterval(B,1e3),()=>clearInterval(E.current)},[h]),C.useEffect(()=>{if(!e)return;function B(O){const{name:M,device_id:A}=O.detail??{};k({name:M||"New device",id:A}),clearInterval(E.current),p(""),L()}return window.addEventListener("compose:devicePaired",B),()=>window.removeEventListener("compose:devicePaired",B)},[e,L]),!e)return null;const R=!f;return c.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",role:"dialog","aria-modal":"true","aria-label":"Pair mobile device","data-testid":"pair-device-modal",children:[c.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:t}),c.jsxs("div",{className:"relative w-full max-w-md max-h-[85vh] flex flex-col rounded-xl border border-border bg-card shadow-2xl mx-4",children:[c.jsxs("div",{className:"flex items-center gap-3 p-4 pb-3 border-b border-border shrink-0",children:[c.jsx(D1,{className:"h-5 w-5 text-accent shrink-0"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("h2",{className:"text-sm font-semibold text-foreground",children:"Pair mobile device"}),c.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Scan the QR code on your phone to connect remotely"})]}),c.jsx("button",{className:"shrink-0 opacity-60 hover:opacity-100 transition-opacity",onClick:t,"aria-label":"Close",children:c.jsx(jr,{className:"h-4 w-4"})})]}),c.jsxs("div",{className:"flex-1 overflow-auto p-4 space-y-4",children:[y&&c.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-success/10 border border-success/20",children:[c.jsx(pm,{className:"h-4 w-4 text-success shrink-0"}),c.jsxs("span",{className:"text-xs text-success font-medium",children:["Paired: ",y.name]})]}),n==="loading"&&c.jsxs("div",{className:"flex items-center justify-center py-10 gap-2 text-muted-foreground",children:[c.jsx(sh,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-xs",children:"Generating pairing code…"})]}),n==="error"&&c.jsxs("div",{"data-testid":"pair-device-error",className:"px-3 py-3 rounded-lg bg-destructive/10 border border-destructive/20 space-y-2",children:[c.jsxs("div",{className:"flex items-start gap-2",children:[c.jsx(M5,{className:"h-4 w-4 text-destructive shrink-0 mt-0.5"}),c.jsx("p",{className:"text-xs text-destructive leading-relaxed",children:g})]}),c.jsx("button",{className:"text-[10px] text-accent hover:underline",onClick:F,children:"Retry"})]}),n==="ready"&&c.jsxs("div",{className:"space-y-3",children:[R&&c.jsxs("div",{className:"text-[10px] text-amber-500 bg-amber-500/10 border border-amber-500/20 rounded px-2 py-1.5",children:["No public host configured — the URL below uses your local origin. For remote pairing, configure a public host (e.g. via"," ",c.jsx("code",{className:"font-mono",children:"compose remote pair --public-host=<URL>"}),")."]}),c.jsx("div",{className:"flex justify-center",children:c.jsx("canvas",{ref:j,"data-testid":"pair-device-qr",className:"rounded border border-border bg-white",width:200,height:200,"aria-label":"QR code for pairing"})}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("label",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Pairing URL"}),c.jsx("input",{"data-testid":"pair-device-url",readOnly:!0,value:a,className:"w-full text-[10px] font-mono bg-muted text-foreground px-2 py-1.5 rounded border border-border outline-none select-all cursor-text",onFocus:B=>B.target.select(),"aria-label":"Pairing URL"})]}),d&&c.jsxs("p",{className:"text-[10px] text-center text-muted-foreground",children:["Expires in"," ",c.jsx("span",{className:d==="expired"?"text-destructive font-semibold":"text-foreground font-mono",children:d}),d!=="expired"&&c.jsx("button",{className:"ml-2 text-accent hover:underline",onClick:F,children:"Refresh"}),d==="expired"&&c.jsx("button",{className:"ml-2 text-accent hover:underline",onClick:F,children:"Generate new code"})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h3",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:"Paired devices"}),T&&c.jsx(sh,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),c.jsxs("div",{"data-testid":"pair-device-list",className:"space-y-1.5",children:[!T&&b.length===0&&c.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:"No paired devices yet"}),b.map((B,O)=>c.jsx(zQ,{device:B,idx:O,onRevoke:N},B.id))]})]})]})]})]})}const pf={build:{background:"hsl(217 91% 60% / 0.12)",borderColor:"hsl(217 91% 60% / 0.3)",color:"hsl(217 91% 60%)"},gate:{background:"hsl(38 92% 50% / 0.12)",borderColor:"hsl(38 92% 50% / 0.3)",color:"hsl(38 92% 50%)"},error:{background:"hsl(0 72% 51% / 0.12)",borderColor:"hsl(0 72% 51% / 0.3)",color:"hsl(0 72% 51%)"},done:{background:"hsl(160 60% 45% / 0.12)",borderColor:"hsl(160 60% 45% / 0.3)",color:"hsl(160 60% 45%)"},iteration:{background:"hsl(217 91% 60% / 0.12)",borderColor:"hsl(217 91% 60% / 0.3)",color:"hsl(210 100% 66%)"}},Jb={enter:{transform:"translateX(20px)",opacity:0},steady:{transform:"translateX(0)",opacity:1},flash:{transform:"translateX(0)",opacity:1},exit:{transform:"translateX(0)",opacity:0}};function WQ({type:e="build",label:t,retries:r=0,onClick:n,onApprove:i,onDismiss:s,animationState:o="steady"}){const a=(o==="flash"?pf.done:pf[e])||pf.build,l=Jb[o]||Jb.steady,h=o==="exit"?"200ms":o==="flash"?"300ms":"200ms";return c.jsxs("div",{className:"ops-strip-entry",style:{display:"inline-flex",alignItems:"center",gap:"4px",height:"24px",padding:"0 10px",borderRadius:"12px",border:`1px solid ${a.borderColor}`,background:a.background,color:a.color,fontSize:"11px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.04em",cursor:n?"pointer":"default",whiteSpace:"nowrap",transition:`transform ${h} ease, opacity ${h} ease, background 300ms ease, border-color 300ms ease, color 300ms ease`,...l},onClick:n,role:"button",tabIndex:0,onKeyDown:u=>{u.key==="Enter"&&n&&n()},children:[c.jsxs("span",{style:{fontSize:"12px",lineHeight:1},children:[e==="build"&&"▶",e==="gate"&&"⚠",e==="error"&&"✕",e==="done"&&"✓",e==="iteration"&&"↻"]}),c.jsx("span",{children:t}),r>0&&c.jsx("span",{style:{background:"hsl(38 90% 50% / 0.2)",color:"hsl(38 90% 60%)",padding:"0 5px",borderRadius:"9999px",fontSize:"9px"},children:r}),e==="gate"&&i&&c.jsx("button",{className:"ops-strip-approve",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"18px",height:"18px",borderRadius:"9px",border:`1px solid ${a.borderColor}`,background:"transparent",color:a.color,fontSize:"11px",cursor:"pointer",padding:0,marginLeft:"2px",lineHeight:1},onClick:u=>{u.stopPropagation(),i()},title:"Approve gate",children:"✓"}),e==="error"&&s&&c.jsx("button",{className:"ops-strip-dismiss",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"18px",height:"18px",borderRadius:"9px",border:"none",background:"transparent",color:a.color,fontSize:"10px",cursor:"pointer",padding:0,marginLeft:"2px",opacity:.6,lineHeight:1},onClick:u=>{u.stopPropagation(),s()},title:"Dismiss error",children:"✕"})]})}function HQ(e){return!e||e<=0?"":`$${e.toFixed(2)}`}function UQ(e){const t=Math.floor(e/1e3),r=Math.floor(t/60),n=t%60;return`${r}:${String(n).padStart(2,"0")}`}function YQ(e){const t=Math.round(e*60),r=Math.floor(t/60),n=t%60;return`${r}:${String(n).padStart(2,"0")}`}function VQ({activeBuild:e,gates:t,items:r,recentErrors:n,iterationStates:i,now:s=Date.now()}){const o=[];if(e&&e.featureCode){const a=e.currentStep?`${e.currentStep}`:"building",l=e.totalSteps?` · step ${e.currentStepIndex??"?"}/${e.totalSteps}`:"",h=HQ(e.cumulative_cost_usd),u=h?` · ${h}`:"",d=e.flowId||e.startedAt||e.featureCode;o.push({key:`build-${e.featureCode}-${d}`,type:e.status==="complete"?"done":"build",label:`${e.featureCode} · ${a}${l}${u}`,featureCode:e.featureCode,retries:e.retries??0})}if(Array.isArray(t)){for(const a of t)if(a.status==="pending"){const l=Tl[a.stepId]??(a.fromPhase||a.toPhase||"Gate"),h=Array.isArray(r)?r.find(d=>d.id===a.itemId):null,u=(h==null?void 0:h.title)||a.featureCode||"";o.push({key:`gate-${a.id}`,type:"gate",label:u?`${l} — ${u}`:l,featureCode:a.featureCode||"",gateId:a.id})}}if(i){for(const[a,l]of i)if(l.status==="running"){const h=l.loopType==="review"?"review":"coverage",u=`${l.count}/${l.maxIterations}`;let d="";if(l.wallClockTimeout!=null&&l.startedAt){const p=s-new Date(l.startedAt).getTime();d=`, ${UQ(p)}/${YQ(l.wallClockTimeout)}`}o.push({key:`iter-${a}`,type:"iteration",label:`${h} ${u}${d}`})}}if(Array.isArray(n))for(const a of n){const l=a.featureCode||"system",h=(a.message||a.errorType||"error").substring(0,60);o.push({key:`error-${a.timestamp}-${h.substring(0,10)}`,type:"error",label:`${l} · ${h}`,featureCode:l,timestamp:a.timestamp})}return o}function GQ({activeView:e,onSelectFeature:t}){const{activeBuild:r,gates:n,items:i,recentErrors:s,resolveGate:o,iterationStates:a}=Ee(Ti(O=>({activeBuild:O.activeBuild,gates:O.gates,items:O.items,recentErrors:O.recentErrors,resolveGate:O.resolveGate,iterationStates:O.iterationStates}))),[l,h]=C.useState(new Map),u=C.useRef([]),d=C.useRef(new Set),p=C.useRef(new Set),[f,m]=C.useState(null),g=C.useRef(null),x=(r==null?void 0:r.featureCode)??null;C.useEffect(()=>{if(!x){m(null),g.current=null;return}x!==g.current&&(g.current=x,_e(`/api/lifecycle/budget?featureCode=${encodeURIComponent(x)}`).then(O=>O.json()).then(O=>m(O)).catch(()=>{}))},[x]);const y=C.useRef(0);C.useEffect(()=>{if(!x)return;const O=a?[...a.values()].reduce((M,A)=>M+(A.count??0),0):0;O!==y.current&&(y.current=O,_e(`/api/lifecycle/budget?featureCode=${encodeURIComponent(x)}`).then(M=>M.json()).then(M=>m(M)).catch(()=>{}))},[a,x]);const k=C.useRef(r),[b,w]=C.useState(null);C.useEffect(()=>{const O=k.current;if(O&&O.featureCode&&!r){w({...O,status:"complete"});const M=setTimeout(()=>w(null),3e3);return k.current=r,()=>clearTimeout(M)}k.current=r},[r]);const T=r||b,[S,j]=C.useState(()=>Date.now()),E=a&&[...a.values()].some(O=>O.status==="running");C.useEffect(()=>{if(!E)return;const O=setInterval(()=>j(Date.now()),1e3);return()=>clearInterval(O)},[E]);const L=C.useMemo(()=>VQ({activeBuild:T,gates:n,items:i,recentErrors:s,iterationStates:a,now:S}),[T,n,i,s,a,S]),N=C.useMemo(()=>L.filter(O=>!d.current.has(O.key)),[L]);C.useEffect(()=>{const O=new Set(u.current.map(A=>A.key)),M=N.filter(A=>!O.has(A.key)).map(A=>A.key);M.length>0&&(h(A=>{const $=new Map(A);for(const z of M)$.set(z,"enter");return $}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{h(A=>{const $=new Map(A);for(const z of M)$.get(z)==="enter"&&$.set(z,"steady");return $})})}));for(const A of N)A.type==="done"&&!p.current.has(A.key)&&(p.current.add(A.key),h($=>{const z=new Map($);return z.set(A.key,"flash"),z}),setTimeout(()=>{h($=>{const z=new Map($);return z.set(A.key,"exit"),z}),setTimeout(()=>{d.current.add(A.key),h($=>{const z=new Map($);return z.delete(A.key),z})},500)},2e3));u.current=N},[N]);const F=C.useCallback(O=>{h(M=>{const A=new Map(M);return A.set(O,"exit"),A}),setTimeout(()=>{d.current.add(O),h(M=>{const A=new Map(M);return A.delete(O),A})},200)},[]),R=C.useCallback(O=>{o&&o(O,"approve","Approved from ops strip")},[o]);if(e==="docs"||N.length===0)return null;const B=MQ(f);return c.jsxs("div",{className:"ops-strip",style:{height:"36px",display:"flex",alignItems:"center",gap:"6px",padding:"0 12px",overflowX:"auto",overflowY:"hidden",borderTop:"1px solid hsl(var(--border))",background:"hsl(var(--background))",flexShrink:0},children:[N.map(O=>c.jsx(WQ,{type:O.type,label:O.label,retries:O.retries,animationState:l.get(O.key)||"steady",onClick:t?()=>t(O.featureCode):void 0,onApprove:O.type==="gate"&&O.gateId?()=>R(O.gateId):void 0,onDismiss:O.type==="error"?()=>F(O.key):void 0},O.key)),B&&c.jsx("span",{className:"ml-auto text-[9px] text-muted-foreground font-mono shrink-0 opacity-70",title:"Cumulative budget usage: review / coverage",children:B})]})}const XQ={ok:"hsl(var(--success))",warn:"hsl(var(--warning))",error:"hsl(var(--destructive))"},Fc="hsl(var(--muted-foreground))",KQ={"installed-current":"hsl(var(--success))",absent:"hsl(var(--muted-foreground))",foreign:"hsl(var(--destructive))","installed-stale":"hsl(var(--warning))","workspace-unverified":"hsl(var(--warning))",unavailable:"hsl(var(--muted-foreground))"};function On({color:e}){return c.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:e,display:"inline-block",flexShrink:0}})}function mf({title:e,children:t}){return c.jsxs("div",{className:"mt-2 first:mt-0",children:[c.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground mb-1",children:e}),t]})}function QQ(e){return e.optional?"hsl(var(--warning))":"hsl(var(--destructive))"}async function JQ(e){var t;try{return await((t=navigator.clipboard)==null?void 0:t.writeText(e)),!0}catch{return!1}}function kN({command:e,testid:t,label:r="copy"}){const[n,i]=C.useState(!1);return e?c.jsx("button",{"data-testid":t,className:"text-[10px] text-muted-foreground hover:text-foreground transition-colors shrink-0",title:`Copy: ${e}`,"aria-label":`Copy command: ${e}`,onClick:async s=>{s.stopPropagation(),await JQ(e)&&(i(!0),setTimeout(()=>i(!1),1200))},children:n?"✓ copied":r}):null}function ZQ(){var w;const{loading:e,workspace:t}=um()||{},[r,n]=C.useState(null),[i,s]=C.useState(!1),[o,a]=C.useState(null),[l,h]=C.useState(!1),[u,d]=C.useState(!1),[p,f]=C.useState(null),m=C.useRef(null),g=C.useRef(0),x=C.useCallback(async(T=!1)=>{const S=++g.current;s(!0);try{const E=await(await _e(`/api/environment-health${T?"?refresh=1":""}`)).json();if(S!==g.current)return;n(E),a(null)}catch(j){if(S!==g.current)return;n(null),a((j==null?void 0:j.message)||"unavailable")}finally{S===g.current&&s(!1)}},[]),y=C.useCallback(async T=>{d(!0),f(null);try{const S=await _e("/api/environment-health/repair-hooks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:!!T})}),j=await S.json().catch(()=>null);(!S.ok||(j==null?void 0:j.ok)!==!0)&&f((j==null?void 0:j.error)||`repair failed (${S.status})`)}catch(S){f((S==null?void 0:S.message)||"repair failed")}finally{d(!1),x(!1)}},[x]);C.useEffect(()=>{e||!t||x(!1)},[e,t==null?void 0:t.id,t==null?void 0:t.root,x]),C.useEffect(()=>{if(!l)return;const T=j=>{var E;(E=m.current)!=null&&E.contains(j.target)||h(!1)},S=j=>{j.key==="Escape"&&h(!1)};return window.addEventListener("mousedown",T),window.addEventListener("keydown",S),()=>{window.removeEventListener("mousedown",T),window.removeEventListener("keydown",S)}},[l]);const k=r==null?void 0:r.summary,b=k?XQ[k]:Fc;return c.jsxs("div",{ref:m,className:"relative flex items-center shrink-0",children:[c.jsx("button",{"data-testid":"env-health-dot",className:"compose-btn-icon",onClick:()=>h(T=>!T),title:`Environment health: ${k||(i?"checking…":"unknown")}`,"aria-label":"Environment health","aria-haspopup":"dialog","aria-expanded":l,children:c.jsx(On,{color:b})}),l&&c.jsxs("div",{"data-testid":"env-health-panel",role:"dialog","aria-label":"Environment health",className:"absolute top-full right-0 mt-1 z-50 p-2 rounded-md shadow-lg text-xs",style:{background:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",minWidth:280,maxWidth:360},children:[c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Environment Health"}),c.jsx("button",{"data-testid":"env-health-refresh",className:"text-[11px] text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",onClick:()=>x(!0),disabled:i,title:"Refresh","aria-label":"Refresh environment health",children:"↻"})]}),o&&c.jsxs("div",{className:"mt-1 text-destructive",children:["Unavailable: ",o]}),!r&&!o&&c.jsx("div",{className:"mt-1 text-muted-foreground",children:i?"Checking…":"No data"}),r&&c.jsxs(c.Fragment,{children:[c.jsxs(mf,{title:"Dependencies",children:[Zb(r.dependencies,"dependency"),Zb(r.binaries,"binary")]}),c.jsx(mf,{title:"Version",children:c.jsx("div",{"data-testid":"env-health-version",className:"flex items-center gap-1.5",children:r.version?r.version.behind?c.jsxs(c.Fragment,{children:[c.jsx(On,{color:"hsl(var(--warning))"}),c.jsxs("span",{className:"flex-1",children:[r.version.current," → ",r.version.latest," (behind — run ",c.jsx("code",{children:"compose update"}),")"]}),c.jsx(kN,{command:"compose update",testid:"env-health-copy-version"})]}):c.jsxs(c.Fragment,{children:[c.jsx(On,{color:"hsl(var(--success))"}),c.jsxs("span",{children:[r.version.current," (up to date)"]})]}):c.jsxs(c.Fragment,{children:[c.jsx(On,{color:Fc}),c.jsx("span",{className:"text-muted-foreground",children:"version check unavailable"})]})})}),c.jsxs(mf,{title:"Git Hooks",children:[Object.entries(r.hooks||{}).filter(([T])=>T!=="unavailable").map(([T,S])=>c.jsxs("div",{"data-testid":`env-health-hook-${T}`,className:"flex items-center gap-1.5",children:[c.jsx(On,{color:KQ[S.state]||Fc}),c.jsx("span",{className:"font-mono",children:T}),c.jsxs("span",{className:"text-muted-foreground",children:[S.state,S.reason?` (${S.reason})`:""]})]},T)),((w=r.hooks)==null?void 0:w.unavailable)&&c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(On,{color:Fc}),c.jsx("span",{className:"text-muted-foreground",children:"hook status unavailable"})]}),(()=>{const T=Object.entries(r.hooks||{}).filter(([L])=>L!=="unavailable"),S=["installed-stale","absent","foreign"],j=T.some(([,L])=>S.includes(L==null?void 0:L.state)),E=T.some(([,L])=>(L==null?void 0:L.state)==="foreign");return j?c.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[c.jsx("button",{"data-testid":"env-health-repair-hooks",className:"text-[11px] px-2 py-0.5 rounded border border-border hover:bg-accent/30 transition-colors disabled:opacity-50",disabled:u,onClick:()=>{if(E){if(!window.confirm("A foreign git hook exists. Overwrite it with the Compose hook?"))return;y(!0)}else y(!1)},title:"Install / refresh Compose git hooks for this workspace",children:u?"Repairing…":"Repair hooks"}),p&&c.jsx("span",{className:"text-destructive text-[10px]",children:p})]}):null})()]})]})]})]})}function Zb(e,t){if(!e||e.unavailable)return c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(On,{color:"hsl(var(--warning))"}),c.jsxs("span",{className:"text-muted-foreground",children:[t==="binary"?"binaries":"skills"," unavailable"]})]});const r=e.missing||[],n=(e.present||[]).length;return c.jsxs(c.Fragment,{children:[r.map(i=>c.jsxs("div",{"data-testid":`env-health-${t}-${i.id}`,className:"flex items-center gap-1.5",children:[c.jsx(On,{color:QQ(i)}),c.jsx("span",{className:"font-mono truncate",children:i.id}),c.jsxs("span",{className:"text-muted-foreground flex-1",children:["missing",i.optional?" (optional)":""]}),c.jsx(kN,{command:i.install,testid:`env-health-copy-${i.id}`,label:"copy install"})]},i.id)),r.length===0&&c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(On,{color:"hsl(var(--success))"}),c.jsxs("span",{className:"text-muted-foreground",children:[n," ",t==="binary"?"binaries":"skills"," present"]})]})]})}function eJ(e,t={}){const{bugCode:r="",intent:n="",description:i="",resumableCode:s=""}=t;if(e==="new"){const a=(n||"").trim();return a?{args:{mode:"new",description:a}}:{error:"Product intent is required"}}if(e==="resume"){const a=(s||"").trim();return a?{args:{featureCode:a,mode:"bug",resume:!0}}:{error:"No active fix to resume"}}const o=(r||"").trim();return o?{args:{featureCode:o,mode:"bug",description:(i||"").trim()}}:{error:"Bug code is required"}}function tJ({activeBuild:e,onClose:t}){const r=e&&e.mode==="bug"&&e.featureCode?e.featureCode:"",[n,i]=C.useState("fix"),[s,o]=C.useState(""),[a,l]=C.useState(""),[h,u]=C.useState(""),[d,p]=C.useState(!1),[f,m]=C.useState(null);async function g(y){y==null||y.preventDefault(),m(null);const k=eJ(n,{bugCode:s,intent:a,description:h,resumableCode:r});if(k.error){m(k.error);return}p(!0);try{await Ku(k.args),t==null||t()}catch(b){m(b.message||"Failed to launch"),p(!1)}}const x=d||n==="fix"&&!s.trim()||n==="new"&&!a.trim()||n==="resume"&&!r;return c.jsx("div",{className:"absolute top-full right-0 mt-1 w-64 rounded-md border border-border bg-popover shadow-lg z-50","data-testid":"launch-popover",children:c.jsxs("form",{className:"p-2 space-y-2",onSubmit:g,children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"Lifecycle"}),c.jsxs("div",{className:"flex items-center gap-1.5",role:"radiogroup","aria-label":"Launch lifecycle",children:[c.jsx("button",{type:"button",role:"radio","aria-checked":n==="fix",className:`text-[10px] px-2 py-1 rounded border cursor-pointer ${n==="fix"?"bg-accent/10 border-accent text-foreground":"bg-muted border-border text-muted-foreground"}`,"data-testid":"launch-mode-fix",onClick:()=>i("fix"),children:"Fix"}),c.jsx("button",{type:"button",role:"radio","aria-checked":n==="new",className:`text-[10px] px-2 py-1 rounded border cursor-pointer ${n==="new"?"bg-accent/10 border-accent text-foreground":"bg-muted border-border text-muted-foreground"}`,"data-testid":"launch-mode-new",onClick:()=>i("new"),children:"New"}),c.jsx("button",{type:"button",role:"radio","aria-checked":n==="resume","aria-disabled":!r,disabled:!r,className:`text-[10px] px-2 py-1 rounded border ${r?n==="resume"?"bg-accent/10 border-accent text-foreground cursor-pointer":"bg-muted border-border text-muted-foreground cursor-pointer":"bg-muted border-border text-muted-foreground opacity-50 cursor-not-allowed"}`,"data-testid":"launch-mode-resume",onClick:()=>{r&&i("resume")},children:"Resume"})]})]}),n==="new"?c.jsxs("div",{className:"space-y-1",children:[c.jsx("label",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground",htmlFor:"launch-intent",children:"Product intent"}),c.jsx("textarea",{id:"launch-intent",className:"w-full text-xs bg-muted text-foreground px-2 py-1.5 rounded border border-border outline-none resize-none",rows:3,value:a,onChange:y=>l(y.target.value),"data-testid":"launch-intent-input",autoFocus:!0})]}):n==="resume"?c.jsx("div",{className:"text-[10px] text-muted-foreground","data-testid":"launch-resume-target",children:r?c.jsxs(c.Fragment,{children:["Resume active fix: ",c.jsx("span",{className:"text-foreground",children:r})]}):"No active fix to resume."}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("label",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground",htmlFor:"launch-bugcode",children:"Bug code"}),c.jsx("input",{id:"launch-bugcode",type:"text",className:"w-full text-xs bg-muted text-foreground px-2 py-1.5 rounded border border-border outline-none",value:s,onChange:y=>o(y.target.value),"data-testid":"launch-bugcode-input",autoFocus:!0})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("label",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground",htmlFor:"launch-desc",children:"Description (optional)"}),c.jsx("textarea",{id:"launch-desc",className:"w-full text-xs bg-muted text-foreground px-2 py-1.5 rounded border border-border outline-none resize-none",rows:3,value:h,onChange:y=>u(y.target.value),"data-testid":"launch-description"})]})]}),f?c.jsx("div",{className:"text-[10px] text-destructive",role:"alert",children:f}):null,c.jsxs("div",{className:"flex items-center justify-end gap-1.5",children:[c.jsx("button",{type:"button",className:"text-[10px] px-2 py-1 rounded border border-border text-muted-foreground hover:bg-muted/50",onClick:()=>t==null?void 0:t(),disabled:d,"data-testid":"launch-cancel",children:"Cancel"}),c.jsx("button",{type:"submit",className:"text-[10px] px-2 py-1 rounded border border-accent bg-accent/10 text-foreground disabled:opacity-50",disabled:x,"data-testid":"launch-submit",children:d?"Launching…":"Launch"})]})]})})}const rJ={title:"Build all PLANNED features?",body:"This builds every still-buildable (PLANNED/PARTIAL) feature on the roadmap in dependency order. It is roadmap-wide and expensive."};function nJ(){return{mode:"all"}}function CN(e){return(e??"").trim()}function iJ(e){return CN(e).length>0}function sJ(e){const t=CN(e);return t?{featureCode:t,mode:"gsd"}:null}function oJ(){const e=hm(),[t,r]=C.useState(!1),[n,i]=C.useState(""),[s,o]=C.useState(!1),[a,l]=C.useState(null),h=C.useRef(null);C.useEffect(()=>{if(!t)return;const m=x=>{var y;(y=h.current)!=null&&y.contains(x.target)||r(!1)},g=x=>{x.key==="Escape"&&r(!1)};return window.addEventListener("mousedown",m),window.addEventListener("keydown",g),()=>{window.removeEventListener("mousedown",m),window.removeEventListener("keydown",g)}},[t]);function u(){l(null),o(!1)}async function d(m){o(!0),l(null);try{await Ku(m),r(!1),i(""),o(!1)}catch(g){l(g.message||"Failed to start build"),o(!1)}}async function p(){await e(rJ)&&await d(nJ())}async function f(m){m==null||m.preventDefault();const g=sJ(n);if(!g){l("Feature code is required");return}await d(g)}return c.jsxs("div",{ref:h,className:"relative flex items-center shrink-0",children:[c.jsx("button",{type:"button","data-testid":"build-all-gsd-trigger",className:"compose-btn-icon",onClick:()=>{r(m=>!m),u()},title:"Batch builds: build all PLANNED features or run GSD on one feature","aria-label":"Batch builds","aria-haspopup":"dialog","aria-expanded":t,children:c.jsx("span",{"aria-hidden":"true",className:"text-[13px] leading-none",children:"≣"})}),t&&c.jsx("div",{"data-testid":"build-all-gsd-popover",role:"dialog","aria-label":"Batch builds",className:"absolute top-full right-0 mt-1 w-64 rounded-md border border-border bg-popover shadow-lg z-50",children:c.jsxs("div",{className:"p-2 space-y-3",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Build all"}),c.jsx("button",{type:"button","data-testid":"build-all-submit",className:"w-full text-[10px] px-2 py-1.5 rounded border border-accent bg-accent/10 text-foreground disabled:opacity-50",disabled:s,onClick:p,children:s?"Starting…":"Build all PLANNED features"})]}),c.jsxs("form",{className:"space-y-1",onSubmit:f,children:[c.jsx("label",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",htmlFor:"build-gsd-feature",children:"GSD"}),c.jsx("input",{id:"build-gsd-feature",type:"text",className:"w-full text-xs bg-muted text-foreground px-2 py-1.5 rounded border border-border outline-none",placeholder:"FEATURE-CODE",value:n,onChange:m=>i(m.target.value),"data-testid":"build-gsd-feature-input"}),c.jsx("button",{type:"submit","data-testid":"build-gsd-submit",className:"w-full text-[10px] px-2 py-1.5 rounded border border-accent bg-accent/10 text-foreground disabled:opacity-50",disabled:s||!iJ(n),children:s?"Starting…":"Run GSD"})]}),a?c.jsx("div",{className:"text-[10px] text-destructive",role:"alert","data-testid":"build-all-gsd-error",children:a}):null]})})]})}const gf=["dashboard","graph","tree","docs","journal","design","gates","validate","qa-scope","pipeline","pipeline-editor","sessions","build-history","ideabox"];function aJ(e,t){return!t||!Array.isArray(e)?!1:e.includes(t)}function lJ(e){return(e==null?void 0:e[0])??null}const cJ="compose:mainTabs",wN="compose:activeTab";function hJ(){var e;try{const t=(e=globalThis.localStorage)==null?void 0:e.getItem(cJ);if(!t)return[...gf];const r=JSON.parse(t);if(Array.isArray(r)&&r.length>=1){let n=r;for(const i of gf)if(!n.includes(i)){const s=n.indexOf("docs");s>=0?n=[...n.slice(0,s+1),i,...n.slice(s+1)]:n=[...n,i]}return n}}catch{}return[...gf]}function uJ(e){var t;try{const r=(t=globalThis.localStorage)==null?void 0:t.getItem(wN);if(r&&aJ(e,r))return r}catch{}return lJ(e)}function e1(e){var t;try{(t=globalThis.localStorage)==null||t.setItem(wN,e)}catch{}}function vN(e,t){var r;try{const n=(r=globalThis.localStorage)==null?void 0:r.getItem(e);return n==null?t:n!=="false"}catch{return t}}function SN(e,t){var r;try{(r=globalThis.localStorage)==null||r.setItem(e,String(!!t))}catch{}}const TN="compose:sidebarOpen",_N="compose:contextPanelOpen";function dJ(){return vN(TN,!0)}function fJ(e){return SN(TN,e)}function pJ(){return vN(_N,!1)}function t1(e){return SN(_N,e)}cs.use(dm);const mJ={overlay:"#161625",text:"#f1f5f9",textMuted:"#475569",border:"#334155",accent:"#FBBF24",danger:"#ef4444"},gJ={overlay:"#F5F5F5",text:"#0a0a0a",textMuted:"#a3a3a3",border:"#d4d4d4",accent:"#FBBF24",danger:"#dc2626"};function xJ(){const[e,t]=C.useState(()=>typeof document<"u"&&document.documentElement.classList.contains("dark"));return C.useEffect(()=>{if(typeof document>"u")return;const r=new MutationObserver(()=>t(document.documentElement.classList.contains("dark")));return r.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>r.disconnect()},[]),e}function yJ(e){return[{selector:"node",style:{label:"data(label)","text-valign":"center","text-halign":"center","text-wrap":"wrap","text-max-width":"150px","font-size":"10px","font-family":'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:e.text,"background-color":e.overlay,"border-width":1,"border-color":e.border,"border-opacity":.8,width:170,height:64,shape:"round-rectangle","text-outline-width":0,padding:"6px"}},{selector:"node:selected",style:{"border-width":2,"border-opacity":1,"border-color":e.accent}},{selector:"node[hasWarning = 1]",style:{"border-color":e.danger,"border-width":2,"border-opacity":1}},{selector:"node.connect-source",style:{"border-color":e.accent,"border-width":3,"border-opacity":1,"background-color":e.overlay}},{selector:"node.multi-select",style:{"border-color":e.accent,"border-width":3,"border-style":"dashed","border-opacity":1}},{selector:".connect-flash",style:{"border-color":e.danger,"border-width":3,"border-opacity":1,"line-color":e.danger,"target-arrow-color":e.danger}},{selector:"edge",style:{width:1.2,"line-color":e.textMuted,"target-arrow-color":e.textMuted,"target-arrow-shape":"triangle","curve-style":"bezier","arrow-scale":.8,opacity:.6}}]}const r1={name:"dagre",rankDir:"LR",rankSep:90,nodeSep:45,padding:40};function La(e,t){if(!e)return"";const r=String(e).replace(/\s+/g," ").trim();return r.length>t?`${r.slice(0,t-1)}…`:r}function bJ(e,t){var o,a,l;if(e.kind!=="flow")return null;const r=(o=e._extra)==null?void 0:o.flow;if(!r)return null;const n=(l=(a=t==null?void 0:t._doc)==null?void 0:a.flows)==null?void 0:l[r];if(!n||typeof n!="object")return{inputs:[],output:null,name:r};const i=n.input&&typeof n.input=="object"?Object.keys(n.input):[],s=n.output!=null&&n.output!==""?String(n.output):null;return{inputs:i,output:s,name:r}}function jN(e,t){const r=[e.id||"(unnamed)"],n=bJ(e,t);if(n)return r.push(La(`⊟ flow: ${n.name}`,28)),n.inputs.length&&r.push(La(`in: ${n.inputs.join(", ")}`,36)),n.output&&r.push(La(`out: ${n.output}`,36)),r.join(`
|
|
870
870
|
`);const i=e.agent||(e.function?`fn:${e.function}`:e.kind);return i&&r.push(La(i,28)),e.intent&&r.push(La(e.intent,40)),r.join(`
|
|
871
871
|
`)}function kJ(e,t,r){const n=[],i=new Map;return e.forEach((s,o)=>{var l,h;const a=`n${o}`;i.has(s.id)||i.set(s.id,a),n.push({data:{id:a,stepId:s.id,label:jN(s,r),hasWarning:((l=t==null?void 0:t[s.id])==null?void 0:l.length)>0?1:0,isFlow:s.kind==="flow"?1:0,flowName:s.kind==="flow"&&((h=s._extra)==null?void 0:h.flow)||""}})}),e.forEach((s,o)=>{for(const a of s.depends_on||[]){const l=i.get(a);l&&n.push({data:{id:`e-${l}-n${o}`,source:l,target:`n${o}`}})}}),n}const CJ=C.forwardRef(function({connectMode:t=!1,multiSelect:r=[],onMultiSelectChange:n,onExpand:i}={},s){const o=C.useRef(null),a=C.useRef(null),l=xJ(),h=l?mJ:gJ,u=Ee(B=>B.editorModel),d=Ee(B=>B.editorSelectedFlow),p=Ee(B=>B.editorSelectedStep),f=Ee(B=>B.editorErrors),m=Ee(B=>B.editorReadOnly),g=Ee(B=>B.selectStep),x=Ee(B=>B.deleteStep),y=Ee(B=>B.addDependency),k=Ee(B=>B.removeDependency),b=C.useRef(r),w=C.useRef(n),T=C.useRef(i),S=C.useRef(m);C.useEffect(()=>{b.current=r},[r]),C.useEffect(()=>{w.current=n},[n]),C.useEffect(()=>{T.current=i},[i]),C.useEffect(()=>{S.current=m},[m]);const j=C.useRef(t);C.useEffect(()=>{if(j.current=t,!t){E.current=null;const B=a.current;B&&B.nodes().removeClass("connect-source")}},[t]);const E=C.useRef(null),L=u&&d?Vn(u,d):[],N=JSON.stringify({flow:d,steps:L.map(B=>{var O,M;return{id:B.id,l:jN(B,u),d:B.depends_on,w:((M=(O=f==null?void 0:f.warningsByStepId)==null?void 0:O[B.id])==null?void 0:M.length)||0}})}),F=()=>{const B=a.current;B&&(B.layout(r1).run(),B.fit(void 0,40))};C.useImperativeHandle(s,()=>({relayout:F}),[]);const R=B=>{!B||!B.length||(B.addClass("connect-flash"),setTimeout(()=>{try{B.removeClass("connect-flash")}catch{}},600))};return C.useEffect(()=>{if(!o.current)return;E.current=null;const B=cs({container:o.current,elements:kJ(L,f==null?void 0:f.warningsByStepId,u),style:yJ(h),layout:r1,minZoom:.2,maxZoom:3,wheelSensitivity:.3,boxSelectionEnabled:!1});return a.current=B,B.on("tap","node",O=>{const M=O.target,A=M.data("stepId");if(!j.current){if(!!(O.originalEvent&&O.originalEvent.shiftKey)&&!S.current&&w.current){const _=b.current||[],U=_.includes(A)?_.filter(Q=>Q!==A):[..._,A];w.current(U);return}g(A);return}const $=E.current;if(!$){E.current=A,B.nodes().removeClass("connect-source"),M.addClass("connect-source");return}if($===A){E.current=null,B.nodes().removeClass("connect-source");return}const z=y(A,$);E.current=null,B.nodes().removeClass("connect-source"),z?F():R(M)}),B.on("cxttap","node",O=>{if(j.current)return;const M=O.target.data("stepId");typeof window<"u"&&window.confirm(`Delete step "${M}"?`)&&x(M)}),B.on("cxttap","edge",O=>{const M=O.target,A=B.getElementById(M.data("source")).data("stepId"),$=B.getElementById(M.data("target")).data("stepId");typeof window<"u"&&window.confirm(`Remove dependency "${$}" → "${A}"?`)&&k($,A)}),B.on("dbltap","node",O=>{if(j.current)return;const M=O.target;if(M.data("isFlow")!==1)return;const A=M.data("flowName");A&&T.current&&T.current(A)}),B.on("layoutstop",()=>B.fit(void 0,40)),()=>{B.destroy(),a.current=null}},[N,l]),C.useEffect(()=>{const B=a.current;if(B&&(B.nodes().unselect(),p)){const O=B.nodes(`[stepId = "${p}"]`);O&&O.length&&O.select()}},[p,N]),C.useEffect(()=>{const B=a.current;if(B){B.nodes().removeClass("multi-select");for(const O of r||[]){const M=B.nodes(`[stepId = "${O}"]`);M&&M.length&&M.addClass("multi-select")}}},[r,N]),!u||!d?c.jsx("div",{className:"w-full h-full flex items-center justify-center text-sm text-muted-foreground",children:"Select a spec and a flow to edit."}):L.length===0?c.jsxs("div",{className:"w-full h-full flex items-center justify-center text-sm text-muted-foreground",children:['Flow "',d,'" has no steps. Use “Add step” to create one.']}):c.jsxs("div",{className:"w-full h-full relative bg-background",children:[t&&c.jsx("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-10 px-2.5 py-1 rounded-full text-[10px] bg-accent/15 text-accent border border-accent/40 pointer-events-none","data-testid":"connect-mode-hint",children:"Connect mode: tap a source step, then a target. Tap the same node to cancel."}),c.jsx("div",{ref:o,className:t?"w-full h-full cursor-crosshair":"w-full h-full","data-testid":"pipeline-editor-canvas"})]})}),Mn="w-full text-xs bg-muted text-foreground px-2 py-1 rounded border border-border outline-none focus:border-ring",Zp="text-[10px] text-muted-foreground uppercase tracking-wider";function Fs({label:e,children:t,hint:r}){return c.jsxs("label",{className:"flex flex-col gap-1",children:[c.jsx("span",{className:Zp,children:e}),t,r&&c.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:r})]})}function wJ(){var R;const e=Ee(B=>B.editorModel),t=Ee(B=>B.editorSelectedFlow),r=Ee(B=>B.editorSelectedStep),n=Ee(B=>B.editorErrors),i=Ee(B=>B.editorReadOnly),s=Ee(B=>B.updateStep),o=Ee(B=>B.renameStep),a=e&&t?Vn(e,t):[],l=a.find(B=>B.id===r)||null,[h,u]=C.useState("");if(C.useEffect(()=>{u((l==null?void 0:l.id)??"")},[l==null?void 0:l.id]),!l)return c.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Select a step on the canvas to edit it."});const d=((R=n==null?void 0:n.warningsByStepId)==null?void 0:R[l.id])||[],p=Object.keys(e.contracts||{}),f=[...p,...p.includes("TaskGraph")?[]:["TaskGraph"],"(none)"],m=a.filter(B=>B.id!==l.id).map(B=>B.id),g=()=>{const B=h.trim();B&&B!==l.id?o(l.id,B):u(l.id)},x=l.inputs||{},y=B=>s(l.id,{inputs:B}),k=()=>{let B="key",O=1;for(;Object.prototype.hasOwnProperty.call(x,B);)B=`key_${++O}`;y({...x,[B]:""})},b=(B,O)=>{if(!O||O===B)return;const M={};for(const[A,$]of Object.entries(x))M[A===B?O:A]=$;y(M)},w=(B,O)=>y({...x,[B]:O}),T=B=>{const O={...x};delete O[B],y(O)},S=Array.isArray(l.ensure)?l.ensure:[],j=B=>s(l.id,{ensure:B}),E=(B,O)=>j(S.map((M,A)=>A===B?O:M)),L=()=>j([...S,""]),N=B=>j(S.filter((O,M)=>M!==B)),F=i;return c.jsxs("div",{className:"h-full overflow-y-auto p-4 space-y-4","data-testid":"step-inspector",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Step"}),i&&c.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:"read-only"})]}),d.length>0&&c.jsx("div",{className:"rounded border border-destructive/40 bg-destructive/10 px-2 py-1.5 space-y-0.5",children:d.map((B,O)=>c.jsx("p",{className:"text-[10px] text-destructive",children:B},O))}),c.jsx(Fs,{label:"ID",children:c.jsx("input",{type:"text",value:h,disabled:F,onChange:B=>u(B.target.value),onBlur:g,onKeyDown:B=>{B.key==="Enter"&&(B.preventDefault(),g())},className:ne(Mn,F&&"opacity-60 cursor-not-allowed")})}),c.jsx(Fs,{label:"Agent",hint:"provider:template:tier",children:c.jsx("input",{type:"text",value:l.agent??"",disabled:F,placeholder:"claude:design:opus",onChange:B=>s(l.id,{agent:B.target.value}),className:ne(Mn,F&&"opacity-60 cursor-not-allowed")})}),c.jsx(Fs,{label:"Intent",children:c.jsx("textarea",{value:l.intent??"",disabled:F,rows:3,onChange:B=>s(l.id,{intent:B.target.value}),className:ne(Mn,"resize-none",F&&"opacity-60 cursor-not-allowed")})}),c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:Zp,children:"Inputs"}),!F&&c.jsx("button",{type:"button",onClick:k,className:"text-muted-foreground hover:text-foreground",title:"Add input",children:c.jsx(zn,{className:"h-3 w-3"})})]}),Object.entries(x).length===0&&c.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:"No inputs"}),Object.entries(x).map(([B,O])=>c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx("input",{type:"text",value:B,disabled:F,placeholder:"key",onChange:M=>b(B,M.target.value),className:ne(Mn,"w-1/3",F&&"opacity-60")}),c.jsx("input",{type:"text",value:O??"",disabled:F,placeholder:"$.input.x",onChange:M=>w(B,M.target.value),className:ne(Mn,"flex-1",F&&"opacity-60")}),!F&&c.jsx("button",{type:"button",onClick:()=>T(B),className:"text-muted-foreground hover:text-destructive",title:"Remove",children:c.jsx(jr,{className:"h-3 w-3"})})]},B))]}),c.jsx(Fs,{label:"Output Contract",children:c.jsx("select",{value:l.output_contract??"(none)",disabled:F,onChange:B=>s(l.id,{output_contract:B.target.value==="(none)"?void 0:B.target.value}),className:ne(Mn,"cursor-pointer",F&&"opacity-60 cursor-not-allowed"),children:f.map(B=>c.jsx("option",{value:B,children:B},B))})}),c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:Zp,children:"Ensure"}),!F&&c.jsx("button",{type:"button",onClick:L,className:"text-muted-foreground hover:text-foreground",title:"Add ensure",children:c.jsx(zn,{className:"h-3 w-3"})})]}),S.length===0&&c.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:"No postconditions"}),S.map((B,O)=>c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx("input",{type:"text",value:B??"",disabled:F,placeholder:"expression",onChange:M=>E(O,M.target.value),className:ne(Mn,"flex-1",F&&"opacity-60")}),!F&&c.jsx("button",{type:"button",onClick:()=>N(O),className:"text-muted-foreground hover:text-destructive",title:"Remove",children:c.jsx(jr,{className:"h-3 w-3"})})]},O))]}),c.jsx(Fs,{label:"Retries",children:c.jsx("input",{type:"number",min:0,value:l.retries??"",disabled:F,onChange:B=>s(l.id,{retries:B.target.value===""?void 0:Number(B.target.value)}),className:ne(Mn,F&&"opacity-60 cursor-not-allowed")})}),c.jsx(Fs,{label:"On Fail",children:c.jsxs("select",{value:l.on_fail??"(none)",disabled:F,onChange:B=>s(l.id,{on_fail:B.target.value==="(none)"?void 0:B.target.value}),className:ne(Mn,"cursor-pointer",F&&"opacity-60 cursor-not-allowed"),children:[c.jsx("option",{value:"(none)",children:"(none)"}),m.map(B=>c.jsx("option",{value:B,children:B},B))]})})]})}const xf="TaskGraph",vJ=["string","number","boolean","array","object"],rl="w-full text-xs bg-muted text-foreground px-2 py-1 rounded border border-border outline-none focus:border-ring";function NN({value:e,disabled:t,placeholder:r,className:n,onCommit:i}){const[s,o]=C.useState(e??"");C.useEffect(()=>{o(e??"")},[e]);const a=()=>{const l=s.trim();l&&l!==e?i(l):o(e??"")};return c.jsx("input",{type:"text",value:s,disabled:t,placeholder:r,onChange:l=>o(l.target.value),onBlur:a,onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),a())},className:ne(n,t&&"opacity-60 cursor-not-allowed")})}function SJ({contractName:e,fieldName:t,spec:r,disabled:n,store:i}){const s=(r==null?void 0:r.type)??"string",o=Array.isArray(r==null?void 0:r.values)?r.values.join(", "):"",a=!!(r!=null&&r.optional),l=h=>i.setContractField(e,t,{...r,...h});return c.jsxs("div",{className:"flex items-center gap-1","data-testid":`contract-field-${e}-${t}`,children:[c.jsx(NN,{value:t,disabled:n,placeholder:"field",className:ne(rl,"w-1/4"),onCommit:h=>i.renameContractField(e,t,h)}),c.jsx("select",{value:s,disabled:n,onChange:h=>l({type:h.target.value}),className:ne(rl,"w-1/4 cursor-pointer",n&&"opacity-60 cursor-not-allowed"),children:vJ.map(h=>c.jsx("option",{value:h,children:h},h))}),c.jsx("input",{type:"text",value:o,disabled:n,placeholder:"values (csv)",onChange:h=>{const u=h.target.value.split(",").map(d=>d.trim()).filter(Boolean);l({values:u.length?u:void 0})},className:ne(rl,"flex-1",n&&"opacity-60")}),c.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-muted-foreground shrink-0",title:"Optional",children:[c.jsx("input",{type:"checkbox",checked:a,disabled:n,onChange:h=>l({optional:h.target.checked||void 0})}),"opt"]}),!n&&c.jsx("button",{type:"button",onClick:()=>i.removeContractField(e,t),className:"text-muted-foreground hover:text-destructive shrink-0",title:"Remove field",children:c.jsx(jr,{className:"h-3 w-3"})})]})}function TJ({name:e,fields:t,disabled:r,store:n}){const i=Object.entries(t||{}),s=()=>{let o="field",a=1;for(;Object.prototype.hasOwnProperty.call(t||{},o);)o=`field_${++a}`;n.setContractField(e,o,{type:"string"})};return c.jsxs("div",{className:"rounded border border-border/60 p-2 space-y-2","data-testid":`contract-${e}`,children:[c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(NN,{value:e,disabled:r,placeholder:"ContractName",className:ne(rl,"flex-1 font-medium"),onCommit:o=>n.renameContract(e,o)}),!r&&c.jsx("button",{type:"button",onClick:()=>n.deleteContract(e),className:"text-muted-foreground hover:text-destructive shrink-0",title:"Delete contract",children:c.jsx(jr,{className:"h-3.5 w-3.5"})})]}),i.length===0&&c.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:"No fields"}),i.map(([o,a])=>c.jsx(SJ,{contractName:e,fieldName:o,spec:a,disabled:r,store:n},o)),!r&&c.jsxs("button",{type:"button",onClick:s,className:"flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground",title:"Add field",children:[c.jsx(zn,{className:"h-3 w-3"})," Add field"]})]})}function _J(){var d;const e=Ee(p=>p.editorModel),t=Ee(p=>p.editorReadOnly),r=Ee(p=>p.editorErrors),n=Ee(Ti(p=>({addContract:p.addContract,renameContract:p.renameContract,deleteContract:p.deleteContract,setContractField:p.setContractField,removeContractField:p.removeContractField,renameContractField:p.renameContractField}))),[i,s]=C.useState("");if(!e)return c.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Select a spec to edit its contracts."});const o=e.contracts||{},a=Object.keys(o).filter(p=>p!==xf),l=xf in o,h=t,u=()=>{const p=i.trim();if(!p)return;n.addContract(p)&&s("")};return c.jsxs("div",{className:"h-full overflow-y-auto p-4 space-y-4","data-testid":"contract-editor",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Contracts"}),t&&c.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:"read-only"})]}),((d=r==null?void 0:r.errors)==null?void 0:d.length)>0&&c.jsx("div",{className:"rounded border border-destructive/40 bg-destructive/10 px-2 py-1.5 space-y-0.5","data-testid":"contract-errors",children:r.errors.map((p,f)=>c.jsx("p",{className:"text-[11px] text-destructive",children:p},f))}),!h&&c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx("input",{type:"text",value:i,placeholder:"New contract name…",onChange:p=>s(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),u())},className:rl,"data-testid":"new-contract-name"}),c.jsxs("button",{type:"button",onClick:u,disabled:!i.trim(),className:ne("flex items-center gap-1 text-xs px-2 py-1 rounded border border-border shrink-0 transition-colors",i.trim()?"text-foreground hover:bg-accent":"opacity-50 cursor-not-allowed text-muted-foreground"),title:"Add contract",children:[c.jsx(zn,{className:"h-3 w-3"})," Add"]})]}),a.length===0&&c.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:"No contracts defined."}),c.jsx("div",{className:"space-y-3",children:a.map(p=>c.jsx(TJ,{name:p,fields:o[p],disabled:h,store:n},p))}),l&&c.jsxs("div",{className:"rounded border border-border/40 bg-muted/20 p-2 flex items-center gap-2","data-testid":"contract-taskgraph-locked",children:[c.jsx(e5,{className:"h-3 w-3 text-muted-foreground shrink-0"}),c.jsxs("span",{className:"text-[11px] text-muted-foreground",children:[c.jsx("span",{className:"font-medium text-foreground",children:xf})," — reserved built-in (locked)"]})]})]})}const jJ=300;function n1(e){if(!e)return"";try{return Hf.stringify(rO(e))}catch{return""}}function NJ(){const e=Ee(p=>p.editorModel),t=Ee(p=>p.editorReadOnly),r=Ee(p=>p.editorYamlError),n=Ee(p=>p.editorYamlBuffer),i=Ee(p=>p.setYamlBuffer),s=Ee(p=>p.flushYaml),[o,a]=C.useState(()=>n??n1(e)),l=C.useRef(n!=null),h=C.useRef(null),u=C.useRef(s);C.useEffect(()=>{u.current=s},[s]),C.useEffect(()=>{l.current||a(n1(e))},[e]),C.useEffect(()=>()=>{var p;h.current&&clearTimeout(h.current),(p=u.current)==null||p.call(u)},[]);const d=p=>{if(t)return;const f=p.target.value;a(f),l.current=!0,i(f),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{l.current=!1,s()},jJ)};return e?c.jsxs("div",{className:"w-full h-full flex flex-col","data-testid":"yaml-pane",children:[c.jsxs("div",{className:"shrink-0 flex items-center justify-between px-3 py-1.5 border-b border-border",children:[c.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"YAML (spec-wide)"}),t&&c.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:"read-only"})]}),c.jsx("textarea",{value:o,onChange:d,readOnly:t,spellCheck:!1,className:"flex-1 w-full resize-none border-0 outline-none px-3 py-2 text-xs",style:{fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',background:"hsl(var(--background))",color:"hsl(var(--foreground))",tabSize:2},"data-testid":"yaml-pane-textarea"}),r&&c.jsx("div",{className:"shrink-0 px-3 py-1.5 text-[11px] bg-destructive/10 text-destructive border-t border-destructive/30","data-testid":"yaml-pane-error",children:r}),c.jsx("div",{className:"shrink-0 px-3 py-1 text-[10px] text-muted-foreground/70 border-t border-border",children:"Comment-stripped editing projection. A pane-only step rename loses that step's disk comments on save."})]}):c.jsx("div",{className:"w-full h-full flex items-center justify-center text-sm text-muted-foreground p-4 text-center",children:"Select a spec to view its YAML."})}function EJ(e){let t=String(e||"").trim().replace(/[/\\]/g,"");return t?(t.endsWith(".stratum.yaml")||(t=t.replace(/\.(ya?ml)$/i,""),t=`${t}.stratum.yaml`),t):""}const i1="text-xs bg-muted text-foreground px-2 py-1 rounded border border-border cursor-pointer outline-none focus:border-ring";function AJ(){var de;const e=C.useRef(null),t=Ee(W=>W.editorSpecs),r=Ee(W=>W.editorSpecFile),n=Ee(W=>W.editorModel),i=Ee(W=>W.editorSelectedFlow),s=Ee(W=>W.editorDirty),o=Ee(W=>W.editorErrors),a=Ee(W=>W.editorReadOnly),l=Ee(W=>W.editorConflict),h=Ee(W=>W.editorYamlBuffer),u=Ee(W=>W.editorYamlError),d=Ee(W=>W.loadSpecList),p=Ee(W=>W.loadSpecForEdit),f=Ee(W=>W.selectFlow),m=Ee(W=>W.addStep),g=Ee(W=>W.saveSpec),x=Ee(W=>W.saveAsTemplate),y=Ee(W=>W.resolveConflict),k=Ee(W=>W.collapseSelectedToSubflow),[b,w]=C.useState(!1),[T,S]=C.useState("inspector"),[j,E]=C.useState(!1),[L,N]=C.useState({filename:"",id:"",label:""}),[F,R]=C.useState(""),[B,O]=C.useState(!1),[M,A]=C.useState([]),[$,z]=C.useState(!1),[P,_]=C.useState(""),[U,Q]=C.useState("");C.useEffect(()=>{d()},[d]),C.useEffect(()=>{a&&(w(!1),S("inspector"))},[a]),C.useEffect(()=>{A([])},[i,r]);const D=n!=null&&n._doc?Wc(n._doc):[],ae=((de=o==null?void 0:o.errors)==null?void 0:de.length)||0,J=h!=null||!!u,he=s&&ae===0&&!a&&!J,Ce=async()=>{const W=await g();W!=null&&W.error&&typeof window<"u"?window.dispatchEvent(new CustomEvent("compose:notify",{detail:{level:"warn",message:`Save failed: ${W.error}`}})):W!=null&&W.ok&&typeof window<"u"&&window.dispatchEvent(new CustomEvent("compose:notify",{detail:{level:"info",message:`Saved ${W.file}`}}))},Be=async W=>{const ce=await y(W);ce!=null&&ce.error&&typeof window<"u"&&window.dispatchEvent(new CustomEvent("compose:notify",{detail:{level:"warn",message:`Conflict resolution failed: ${ce.error}`}}))},me=()=>{_(""),Q(""),z(!0)},X=()=>{var Ye,_t,Qe;const W=P.trim();if(!W){Q("A sub-flow name is required");return}if(M.length===0){Q("Select at least one step to collapse");return}if(!k(M,W)){const lr=((_t=(Ye=Ee.getState().editorErrors)==null?void 0:Ye.errors)==null?void 0:_t[0])||"Cannot collapse the selected steps";Q(lr);return}z(!1),A([]),(Qe=e.current)==null||Qe.relayout()},te=()=>{N({filename:"",id:"",label:""}),R(""),E(!0)},ge=async()=>{const W=EJ(L.filename),ce=L.id.trim();if(!W){R("Filename is required");return}if(!ce){R("Template id is required");return}if(J){R("Resolve the YAML pane before saving as a template");return}if(ae>0){R("Resolve validation errors before saving as a template");return}O(!0),R("");const Ye=await x({filename:W,metadata:{id:ce,...L.label.trim()?{label:L.label.trim()}:{}}});if(O(!1),Ye!=null&&Ye.error){R(Ye.error);return}E(!1),d(),typeof window<"u"&&window.dispatchEvent(new CustomEvent("compose:notify",{detail:{level:"info",message:`Saved template ${Ye.file||W}`}}))};return c.jsxs("div",{className:"w-full h-full flex flex-col bg-background",children:[c.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-3 py-2 border-b border-border",children:[c.jsxs("select",{value:r??"",onChange:W=>W.target.value&&p(W.target.value),className:i1,title:"Spec file","data-testid":"spec-picker",children:[c.jsx("option",{value:"",disabled:!0,children:"Select a spec…"}),t.map(W=>c.jsxs("option",{value:W.file,children:[W.file,W.version?` (v${W.version})`:""]},W.file))]}),c.jsxs("select",{value:i??"",onChange:W=>W.target.value&&f(W.target.value),className:i1,title:"Flow",disabled:!n||D.length===0,"data-testid":"flow-picker",children:[D.length===0&&c.jsx("option",{value:"",children:"(no flows)"}),D.map(W=>c.jsx("option",{value:W,children:W},W))]}),c.jsx("div",{className:"w-px h-5 bg-border mx-1"}),c.jsxs("button",{type:"button",onClick:()=>m(),disabled:!n||!i||a,className:ne("flex items-center gap-1 text-xs px-2 py-1 rounded border border-border transition-colors",!n||!i||a?"opacity-50 cursor-not-allowed text-muted-foreground":"text-foreground hover:bg-accent"),title:"Add step",children:[c.jsx(zn,{className:"h-3 w-3"})," Add step"]}),c.jsxs("button",{type:"button",onClick:Ce,disabled:!he,className:ne("flex items-center gap-1 text-xs px-2 py-1 rounded border transition-colors",he?"border-accent/60 text-accent hover:bg-accent/10":"opacity-50 cursor-not-allowed text-muted-foreground border-border"),title:ae>0?"Fix validation errors before saving":"Save spec",children:[c.jsx(O1,{className:"h-3 w-3"})," Save",s?" *":""]}),c.jsxs("button",{type:"button",onClick:()=>{var W;return(W=e.current)==null?void 0:W.relayout()},disabled:!n||!i,className:ne("flex items-center gap-1 text-xs px-2 py-1 rounded border border-border transition-colors",!n||!i?"opacity-50 cursor-not-allowed text-muted-foreground":"text-foreground hover:bg-accent"),title:"Re-layout",children:[c.jsx(wo,{className:"h-3 w-3"})," Layout"]}),c.jsx("div",{className:"w-px h-5 bg-border mx-1"}),c.jsxs("button",{type:"button",onClick:()=>w(W=>!W),disabled:!n||!i||a,"aria-pressed":b,className:ne("flex items-center gap-1 text-xs px-2 py-1 rounded border transition-colors",!n||!i||a?"opacity-50 cursor-not-allowed text-muted-foreground border-border":b?"border-accent/60 text-accent bg-accent/10":"text-foreground border-border hover:bg-accent"),title:"Connect dependencies (tap source, then target)","data-testid":"connect-toggle",children:[c.jsx(I1,{className:"h-3 w-3"})," Connect"]}),c.jsxs("button",{type:"button",onClick:()=>S(W=>W==="contracts"?"inspector":"contracts"),disabled:!n,"aria-pressed":T==="contracts",className:ne("flex items-center gap-1 text-xs px-2 py-1 rounded border transition-colors",n?T==="contracts"?"border-accent/60 text-accent bg-accent/10":"text-foreground border-border hover:bg-accent":"opacity-50 cursor-not-allowed text-muted-foreground border-border"),title:"Edit contracts","data-testid":"contracts-toggle",children:[T==="contracts"?c.jsx(k5,{className:"h-3 w-3"}):c.jsx(mx,{className:"h-3 w-3"}),"Contracts"]}),c.jsxs("button",{type:"button",onClick:()=>S(W=>W==="yaml"?"inspector":"yaml"),disabled:!n,"aria-pressed":T==="yaml",className:ne("flex items-center gap-1 text-xs px-2 py-1 rounded border transition-colors",n?T==="yaml"?"border-accent/60 text-accent bg-accent/10":"text-foreground border-border hover:bg-accent":"opacity-50 cursor-not-allowed text-muted-foreground border-border"),title:"View / edit YAML","data-testid":"yaml-toggle",children:[c.jsx(TE,{className:"h-3 w-3"})," YAML"]}),c.jsxs("button",{type:"button",onClick:me,disabled:!n||!i||a||M.length===0,className:ne("flex items-center gap-1 text-xs px-2 py-1 rounded border border-border transition-colors",!n||!i||a||M.length===0?"opacity-50 cursor-not-allowed text-muted-foreground":"text-foreground hover:bg-accent"),title:M.length===0?"Shift-tap steps on the canvas to select a group, then collapse":`Collapse ${M.length} step${M.length===1?"":"s"} to a sub-flow`,"data-testid":"collapse-toggle",children:[c.jsx(DE,{className:"h-3 w-3"})," Collapse",M.length>0?` (${M.length})`:""]}),c.jsxs("button",{type:"button",onClick:te,disabled:!n||!i||a||ae>0||J,className:ne("flex items-center gap-1 text-xs px-2 py-1 rounded border border-border transition-colors",!n||!i||a||ae>0||J?"opacity-50 cursor-not-allowed text-muted-foreground":"text-foreground hover:bg-accent"),title:J?"Resolve the YAML pane before saving as a template":ae>0?"Resolve validation errors before saving as a template":"Save as new template","data-testid":"save-as-template",children:[c.jsx(mx,{className:"h-3 w-3"})," Save as template"]}),c.jsx("div",{className:"flex-1"}),ae>0&&c.jsxs("span",{className:"text-[10px] text-destructive","data-testid":"error-count",children:[ae," validation ",ae===1?"error":"errors"]})]}),a&&c.jsx("div",{className:"shrink-0 px-3 py-1.5 text-[11px] bg-amber-500/10 text-amber-600 dark:text-amber-400 border-b border-amber-500/30",children:"This spec is version 0.1 and cannot be validated by Stratum. It is loaded read-only."}),l&&c.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-3 py-1.5 text-[11px] bg-destructive/10 text-destructive border-b border-destructive/30","data-testid":"conflict-banner",children:[c.jsx("span",{className:"flex-1",children:"This spec changed on disk since you loaded it."}),c.jsx("button",{type:"button",onClick:()=>Be("reload"),className:"px-2 py-0.5 rounded border border-destructive/50 hover:bg-destructive/15","data-testid":"conflict-reload",children:"Reload (discard my edits)"}),c.jsx("button",{type:"button",onClick:()=>Be("overwrite"),className:"px-2 py-0.5 rounded border border-destructive/50 hover:bg-destructive/15","data-testid":"conflict-overwrite",children:"Overwrite"})]}),J&&c.jsx("div",{className:"shrink-0 px-3 py-1 text-[10px] bg-amber-500/10 text-amber-600 dark:text-amber-400 border-b border-amber-500/30","data-testid":"buffer-pending",children:u?"The YAML pane has a parse error. Fix it before saving.":"The YAML pane has unsaved text. It will apply shortly; saving is paused until then."}),c.jsxs("div",{className:"flex-1 min-h-0 flex",children:[c.jsx("div",{className:"flex-1 min-w-0",children:c.jsx(CJ,{ref:e,connectMode:b&&!a,multiSelect:M,onMultiSelectChange:A,onExpand:W=>Ee.getState().expandSubflow(W)})}),c.jsx("div",{className:"w-80 shrink-0 border-l border-border overflow-hidden",children:T==="yaml"?c.jsx(NJ,{}):T==="contracts"?c.jsx(_J,{}):c.jsx(wJ,{})})]}),c.jsx(yo,{open:j,onOpenChange:W=>!W&&E(!1),children:c.jsxs(bo,{className:"max-w-md",children:[c.jsx(ko,{children:c.jsx(Co,{children:"Save as template"})}),c.jsxs("div",{className:"px-6 pb-2 space-y-3",children:[c.jsxs("label",{className:"flex flex-col gap-1",children:[c.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Filename"}),c.jsx("input",{type:"text",placeholder:"my-pipeline",value:L.filename,onChange:W=>N(ce=>({...ce,filename:W.target.value})),className:"text-xs bg-muted text-foreground px-2 py-1 rounded border border-border outline-none focus:border-ring","data-testid":"tpl-filename"}),c.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:'Saved to pipelines/. ".stratum.yaml" is appended automatically.'})]}),c.jsxs("label",{className:"flex flex-col gap-1",children:[c.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Template id"}),c.jsx("input",{type:"text",placeholder:"my-pipeline",value:L.id,onChange:W=>N(ce=>({...ce,id:W.target.value})),className:"text-xs bg-muted text-foreground px-2 py-1 rounded border border-border outline-none focus:border-ring","data-testid":"tpl-id"})]}),c.jsxs("label",{className:"flex flex-col gap-1",children:[c.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Label (optional)"}),c.jsx("input",{type:"text",placeholder:"My Pipeline",value:L.label,onChange:W=>N(ce=>({...ce,label:W.target.value})),className:"text-xs bg-muted text-foreground px-2 py-1 rounded border border-border outline-none focus:border-ring","data-testid":"tpl-label"})]}),F&&c.jsx("p",{className:"text-xs text-destructive","data-testid":"tpl-error",children:F})]}),c.jsxs(sl,{children:[c.jsx(Fe,{variant:"ghost",size:"sm",onClick:()=>E(!1),disabled:B,children:"Cancel"}),c.jsx(Fe,{size:"sm",onClick:ge,disabled:B||!L.filename.trim()||!L.id.trim(),children:B?"Saving…":"Save template"})]})]})}),c.jsx(yo,{open:$,onOpenChange:W=>!W&&z(!1),children:c.jsxs(bo,{className:"max-w-md",children:[c.jsx(ko,{children:c.jsx(Co,{children:"Collapse to sub-flow"})}),c.jsxs("div",{className:"px-6 pb-2 space-y-3",children:[c.jsxs("p",{className:"text-xs text-muted-foreground",children:["Extract ",M.length," selected step",M.length===1?"":"s"," ","(",M.join(", ")||"none",") into a new sub-flow, replacing",M.length===1?" it":" them"," with one flow step."]}),c.jsxs("label",{className:"flex flex-col gap-1",children:[c.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Sub-flow name"}),c.jsx("input",{type:"text",placeholder:"prep",value:P,onChange:W=>_(W.target.value),className:"text-xs bg-muted text-foreground px-2 py-1 rounded border border-border outline-none focus:border-ring","data-testid":"collapse-name"})]}),U&&c.jsx("p",{className:"text-xs text-destructive","data-testid":"collapse-error",children:U})]}),c.jsxs(sl,{children:[c.jsx(Fe,{variant:"ghost",size:"sm",onClick:()=>z(!1),children:"Cancel"}),c.jsx(Fe,{size:"sm",onClick:X,disabled:!P.trim(),children:"Collapse"})]})]})})]})}const s1={complete:"bg-emerald-500/15 text-emerald-400 border border-emerald-500/30",failed:"bg-red-500/15 text-red-400 border border-red-500/30",aborted:"bg-amber-500/15 text-amber-400 border border-amber-500/30",killed:"bg-slate-500/15 text-slate-400 border border-slate-500/30"};function LJ(e){if(typeof e!="number"||e<0)return"—";const t=Math.round(e/1e3);if(t<60)return`${t}s`;const r=Math.floor(t/60),n=t%60;return r<60?`${r}m ${n}s`:`${Math.floor(r/60)}h ${r%60}m`}function BJ(e){return typeof e!="number"||e<=0?null:`$${e.toFixed(e<1?4:2)}`}function MJ({builds:e=[],items:t=[],onSelectItem:r}){const[n,i]=C.useState(""),[s,o]=C.useState("all"),a=C.useMemo(()=>{let l=e;if(s!=="all"&&(l=l.filter(h=>h.status===s)),n.trim()){const h=n.toLowerCase();l=l.filter(u=>(u.featureCode||"").toLowerCase().includes(h))}return l},[e,n,s]);return c.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 px-3 py-2 border-b border-border shrink-0",children:[c.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",children:[c.jsx(Sf,{className:"h-3 w-3"}),c.jsx("span",{children:"Past builds"})]}),c.jsx("div",{className:"h-4 w-px bg-border"}),c.jsxs("div",{className:"relative",children:[c.jsx(Un,{className:"absolute left-1.5 top-1/2 -translate-y-1/2 h-3 w-3 text-muted-foreground"}),c.jsx("input",{type:"text",placeholder:"Search feature…",value:n,onChange:l=>i(l.target.value),className:"text-xs pl-5 pr-2 py-0.5 h-6 rounded bg-muted text-foreground border border-border w-36"})]}),c.jsxs("select",{value:s,onChange:l=>o(l.target.value),className:"text-xs px-1.5 py-0.5 h-6 rounded bg-muted text-foreground border border-border cursor-pointer",children:[c.jsx("option",{value:"all",children:"All status"}),["complete","failed","aborted","killed"].map(l=>c.jsx("option",{value:l,children:l},l))]}),c.jsxs("span",{className:"ml-auto text-[10px] text-muted-foreground",children:[a.length,"/",e.length]})]}),c.jsxs("div",{className:"flex-1 overflow-auto",children:[a.length===0&&c.jsx(Fl,{icon:Sf,title:"No past builds yet",description:"Builds are recorded here after each run completes",className:"py-8"}),a.map((l,h)=>c.jsx(IJ,{build:l,items:t,onSelectItem:r},`${l.featureCode}-${l.completedAt}-${h}`))]})]})}function IJ({build:e,items:t,onSelectItem:r}){const n=e.featureCode?t.find(u=>{var d;return u.featureCode===e.featureCode||u.feature_code===e.featureCode||((d=u.lifecycle)==null?void 0:d.featureCode)===e.featureCode}):null,i=s1[e.status]||s1.killed,s=BJ(e.cost_usd),o=e.status==="failed"||e.status==="aborted",[a,l]=C.useState(!1);async function h(){const u=e.featureCode;l(!0);try{await Ku({featureCode:u,mode:e.mode}),lt(`Build restarted for ${u}`,"info")}catch(d){d.status===409?lt(`A build for ${u} is already active`,"warn"):lt(d.message||"Failed to restart build","error")}finally{l(!1)}}return c.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2.5 border-b border-border/50 hover:bg-muted/30 transition-colors",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:ne("text-[10px] px-1.5 py-0.5 rounded capitalize",i),children:e.status}),e.featureCode&&c.jsx("button",{onClick:()=>n&&(r==null?void 0:r(n.id)),className:ne("text-[11px] font-mono",n?"text-blue-400 hover:underline cursor-pointer":"text-muted-foreground cursor-default"),children:e.featureCode}),e.mode==="bug"&&c.jsx("span",{className:"text-[10px] px-1 py-0.5 rounded bg-rose-500/15 text-rose-400",children:"bug"}),c.jsx(dx,{date:e.completedAt,className:"ml-auto text-[10px] shrink-0"})]}),c.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-muted-foreground",children:[c.jsxs("span",{children:["⏱ ",LJ(e.durationMs)]}),s&&c.jsxs("span",{children:["💵 ",s]}),typeof e.stepCount=="number"&&c.jsxs("span",{children:["◆ ",e.stepCount," steps"]})]}),(e.failureReason||o)&&c.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.failureReason&&c.jsx("p",{className:"text-[11px] text-red-400/90 truncate flex-1 min-w-0",children:e.failureReason}),o&&c.jsxs("button",{onClick:h,disabled:a,className:"flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-muted/50 disabled:opacity-50 shrink-0 ml-auto cursor-pointer",title:`Restart build for ${e.featureCode}`,"data-testid":"past-build-retry",children:[c.jsx(u5,{className:"h-2.5 w-2.5"}),a?"Retrying…":"Retry"]})]})]})}const em=C.forwardRef(({className:e,...t},r)=>c.jsx("div",{ref:r,className:ne("rounded-xl border bg-card text-card-foreground shadow",e),...t}));em.displayName="Card";const tm=C.forwardRef(({className:e,...t},r)=>c.jsx("div",{ref:r,className:ne("flex flex-col space-y-1.5 p-6",e),...t}));tm.displayName="CardHeader";const rm=C.forwardRef(({className:e,...t},r)=>c.jsx("div",{ref:r,className:ne("font-semibold leading-none tracking-tight",e),...t}));rm.displayName="CardTitle";const FJ=C.forwardRef(({className:e,...t},r)=>c.jsx("div",{ref:r,className:ne("text-sm text-muted-foreground",e),...t}));FJ.displayName="CardDescription";const nm=C.forwardRef(({className:e,...t},r)=>c.jsx("div",{ref:r,className:ne("p-6 pt-0",e),...t}));nm.displayName="CardContent";const OJ=C.forwardRef(({className:e,...t},r)=>c.jsx("div",{ref:r,className:ne("flex items-center p-6 pt-0",e),...t}));OJ.displayName="CardFooter";function $J(e){const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const r=Math.floor(t/60);return r<60?`${r}m ${t%60}s`:`${Math.floor(r/60)}h ${r%60}m`}function o1({agent:e,toolCount:t,errorCount:r,currentTool:n,currentCategory:i,onStop:s}){const o=e.status==="running",a=e.status==="killed",l=e.status==="failed"||e.status==="error"||a,h=!o&&!l,u=e.silent,[d,p]=C.useState(()=>{const m=e.startedAt?new Date(e.startedAt).getTime():Date.now();return(e.completedAt?new Date(e.completedAt).getTime():Date.now())-m});C.useEffect(()=>{if(!o)return;const m=e.startedAt?new Date(e.startedAt).getTime():Date.now(),g=()=>p(Date.now()-m);g();const x=setInterval(g,1e3);return()=>clearInterval(x)},[o,e.startedAt]);const f=e.agentType||e.type||e.agent||"agent";return c.jsxs("div",{className:"px-3 py-2 rounded border border-border bg-muted/20",children:[c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsx("span",{className:"text-[11px] text-foreground font-medium truncate",children:f}),c.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",children:[c.jsx("span",{className:ne("w-1.5 h-1.5 rounded-full inline-block",o&&!u&&"bg-green-400",o&&u&&"bg-yellow-400",h&&"bg-emerald-400",l&&"bg-red-400"),style:o&&!u?{animation:"phase-active-pulse 2s ease-in-out infinite"}:void 0}),c.jsx("span",{className:ne("text-[10px]",o&&!u&&"text-green-400",o&&u&&"text-yellow-400",h&&"text-emerald-400",l&&"text-red-400"),children:u?"silent":e.status}),c.jsx("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:$J(d)}),o&&s&&c.jsx("button",{onClick:m=>{m.stopPropagation(),s(e.agentId||e.id)},className:"text-[10px] text-muted-foreground hover:text-destructive cursor-pointer ml-0.5",title:"Stop agent",children:"x"})]})]}),c.jsx("div",{className:"text-[10px] text-muted-foreground mt-0.5",children:t!=null&&c.jsxs(c.Fragment,{children:[c.jsxs("span",{children:[t," tools"]}),c.jsx("span",{className:"mx-1",children:"·"}),c.jsxs("span",{className:ne(r>0&&"text-red-400"),children:[r??0," err"]}),o&&n&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"mx-1",children:"·"}),c.jsxs("span",{children:[i||"working"," (",n,")"]})]})]})})]})}function DJ(e,t,r){const n=new Array(e);return new Proxy(n,{get(i,s,o){if(typeof s=="string"){const a=s.charCodeAt(0);if(a>=48&&a<=57){const l=+s;if(Number.isInteger(l)&&l>=0&&l<e){let h=i[l];if(!h){const u=t[l*2];h=i[l]={index:l,key:r(l),start:u,size:t[l*2+1],end:u+t[l*2+1],lane:0}}return h}}if(s==="length")return e}return Reflect.get(i,s,o)}})}function Os(e,t,r){let n=r.initialDeps??[],i,s=!0;function o(){const a=e();return(a.length!==n.length||a.some((h,u)=>n[u]!==h))&&(n=a,i=t(...a),r!=null&&r.onChange&&!(s&&r.skipInitialOnChange)&&r.onChange(i),s=!1),i}return o.updateDeps=a=>{n=a},o}function a1(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const PJ=(e,t)=>Math.abs(e-t)<1.01,RJ=(e,t,r)=>{let n;return function(...i){e.clearTimeout(n),n=e.setTimeout(()=>t.apply(this,i),r)}};let Ba;const yf=()=>{if(Ba!==void 0)return Ba;if(typeof navigator>"u")return Ba=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Ba=!0;const e=navigator.maxTouchPoints;return Ba=navigator.platform==="MacIntel"&&e!==void 0&&e>0},l1=e=>{const{offsetWidth:t,offsetHeight:r}=e;return{width:t,height:r}},zJ=e=>e,qJ=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,i=new Array(n);for(let s=0;s<n;s++)i[s]=t+s;return i},WJ=(e,t)=>{const r=e.scrollElement;if(!r)return;const n=e.targetWindow;if(!n)return;const i=o=>{const{width:a,height:l}=o;t({width:Math.round(a),height:Math.round(l)})};if(i(l1(r)),!n.ResizeObserver)return()=>{};const s=new n.ResizeObserver(o=>{const a=()=>{const l=o[0];if(l!=null&&l.borderBoxSize){const h=l.borderBoxSize[0];if(h){i({width:h.inlineSize,height:h.blockSize});return}}i(l1(r))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return s.observe(r,{box:"border-box"}),()=>{s.unobserve(r)}},su={passive:!0},HJ=typeof window>"u"?!0:"onscrollend"in window,UJ=(e,t,r)=>{const n=e.scrollElement;if(!n)return;const i=e.targetWindow;if(!i)return;const s=e.options.useScrollendEvent&&HJ;let o=0;const a=s?null:RJ(i,()=>t(o,!1),e.options.isScrollingResetDelay),l=d=>()=>{o=r(n),a==null||a(),t(o,d)},h=l(!0),u=l(!1);return n.addEventListener("scroll",h,su),s&&n.addEventListener("scrollend",u,su),()=>{n.removeEventListener("scroll",h),s&&n.removeEventListener("scrollend",u)}},YJ=(e,t)=>UJ(e,t,r=>{const{horizontal:n,isRtl:i}=e.options;return n?r.scrollLeft*(i&&-1||1):r.scrollTop}),VJ=(e,t,r)=>{if(r.options.useCachedMeasurements){const n=r.indexFromElement(e),i=r.options.getItemKey(n);return r.itemSizeCache.get(i)??r.options.estimateSize(n)}if(t!=null&&t.borderBoxSize){const n=t.borderBoxSize[0];if(n)return Math.round(n[r.options.horizontal?"inlineSize":"blockSize"])}if(!t){const n=r.indexFromElement(e),i=r.options.getItemKey(n),s=r.itemSizeCache.get(i);if(s!==void 0)return s}return e[r.options.horizontal?"offsetWidth":"offsetHeight"]},GJ=(e,{adjustments:t=0,behavior:r},n)=>{var i,s;(s=(i=n.scrollElement)==null?void 0:i.scrollTo)==null||s.call(i,{[n.options.horizontal?"left":"top"]:e+t,behavior:r})},XJ=GJ;class KJ{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var r,n,i;return((i=(n=(r=this.targetWindow)==null?void 0:r.performance)==null?void 0:n.now)==null?void 0:i.call(n))??Date.now()},this.observer=(()=>{let r=null;const n=()=>r||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:r=new this.targetWindow.ResizeObserver(i=>{i.forEach(s=>{const o=()=>{const a=s.target,l=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);for(const[h,u]of this.elementsCache)if(u===a){this.elementsCache.delete(h);break}return}this.shouldMeasureDuringScroll(l)&&this.resizeItem(l,this.options.measureElement(a,s,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var i;(i=n())==null||i.disconnect(),r=null},observe:i=>{var s;return(s=n())==null?void 0:s.observe(i,{box:"border-box"})},unobserve:i=>{var s;return(s=n())==null?void 0:s.unobserve(i)}}})(),this.range=null,this.setOptions=r=>{var n,i;const s={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:zJ,rangeExtractor:qJ,onChange:()=>{},measureElement:VJ,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const p in r){const f=r[p];f!==void 0&&(s[p]=f)}const o=this.options;let a=null,l=null,h=!1;if(o!==void 0&&o.enabled&&s.enabled&&s.anchorTo==="end"&&this.scrollElement!==null){const p=o.count,f=s.count,m=this.getMeasurements(),g=p>0?((n=m[0])==null?void 0:n.key)??o.getItemKey(0):null,x=p>0?((i=m[p-1])==null?void 0:i.key)??o.getItemKey(p-1):null;if(f!==p||p>0&&f>0&&(s.getItemKey(0)!==g||s.getItemKey(f-1)!==x)){h=!0;const b=p>0?this.getVirtualItemForOffset(this.getScrollOffset())??m[0]:null;b&&(a=[b.key,this.getScrollOffset()-b.start]);const w=s.followOnAppend===!0?"auto":s.followOnAppend||null;w&&f>p&&this.isAtEnd(o.scrollEndThreshold)&&(p===0||s.getItemKey(f-1)!==x)&&(l=w)}}this.options=s,h&&(this.pendingMin=0,this.itemSizeCacheVersion++);let u=!1,d=0;if(a&&this.scrollOffset!==null){const[p,f]=a,m=this.getMeasurements(),{count:g,getItemKey:x}=this.options;let y=0;for(;y<g&&x(y)!==p;)y++;if(y<g){const k=m[y];if(k){const b=Math.max(0,k.start+f);b!==this.scrollOffset&&(d=b-this.scrollOffset,this.scrollOffset=b,u=!0)}}}(u||l)&&(this.pendingScrollAnchor=[u?a[0]:null,u?a[1]:0,l,d])},this.notify=r=>{var n,i;(i=(n=this.options).onChange)==null||i.call(n,this,r)},this.maybeNotify=Os(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),r=>{this.notify(r)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(r=>r()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var r;const n=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==n){if(this.cleanup(),!n){this.maybeNotify();return}if(this.scrollElement=n,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((r=this.scrollElement)==null?void 0:r.window)??null,this.elementsCache.forEach(s=>{this.observer.observe(s)}),this.unsubs.push(this.options.observeElementRect(this,s=>{this.scrollRect=s,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(s,o)=>{if(o&&this._intendedScrollOffset===null&&s===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(s-this._intendedScrollOffset)<1.5&&(s=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const a=this.getScrollOffset();this.scrollDirection=o?a===s?this.scrollDirection:a<s?"forward":"backward":null,this.scrollOffset=s,this.isScrolling=o,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const s=this.scrollElement,o=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},a=()=>{this._iosTouching=!1,!(!yf()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};s.addEventListener("touchstart",o,su),s.addEventListener("touchend",a,su),this.unsubs.push(()=>{s.removeEventListener("touchstart",o),s.removeEventListener("touchend",a),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const i=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,i&&this.scrollElement&&this.options.enabled){const[s,o,a,l]=i;s!==null&&!a&&(yf()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?l!==0&&(this._iosDeferredAdjustment+=l):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),a&&this.scrollToEnd({behavior:a})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const r=this.getScrollOffset(),n=this.getMaxScrollOffset();if(r<0||r>n)return;if(this._iosDeferredAdjustment<0&&r>=n-1){this._iosDeferredAdjustment=0;return}const i=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(r,{adjustments:this.scrollAdjustments+=i,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=Os(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(r,n,i,s,o,a,l,h)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:r,paddingStart:n,scrollMargin:i,getItemKey:s,enabled:o,lanes:a,laneAssignmentMode:l,gap:h}),{key:!1}),this.getMeasurements=Os(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:r,paddingStart:n,scrollMargin:i,getItemKey:s,enabled:o,lanes:a,laneAssignmentMode:l,gap:h},u)=>{const d=this.itemSizeCache;if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>r)for(const y of this.laneAssignments.keys())y>=r&&this.laneAssignments.delete(y);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(y=>{this.itemSizeCache.set(y.key,y.size)}));const p=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===r&&(this.lanesSettling=!1),a===1){const y=r*2;let k=this._flatMeasurements;if(!k||k.length<y){const T=new Float64Array(y);k&&p>0&&T.set(k.subarray(0,p*2)),k=T,this._flatMeasurements=k}let b;if(p===0)b=n+i;else{const T=p-1;b=k[T*2]+k[T*2+1]+h}for(let T=p;T<r;T++){const S=s(T),j=d.get(S),E=typeof j=="number"?j:this.options.estimateSize(T);k[T*2]=b,k[T*2+1]=E,b+=E+h}const w=DJ(r,k,s);return this.measurementsCache=w,w}const f=this.measurementsCache.slice(0,p),m=new Array(a).fill(void 0),g=new Float64Array(a);let x=0;for(let y=0;y<p;y++){const k=f[y];k&&(m[k.lane]===void 0&&x++,m[k.lane]=y,g[k.lane]=k.end)}for(let y=p;y<r;y++){const k=s(y),b=this.laneAssignments.get(y);let w,T;const S=l==="estimate"||d.has(k);if(b!==void 0&&this.options.lanes>1){w=b;const N=m[w],F=N!==void 0?f[N]:void 0;T=F?F.end+h:n+i}else if(x===a){let N=0,F=g[0],R=m[0];for(let B=1;B<a;B++){const O=g[B];(O<F||O===F&&m[B]<R)&&(N=B,F=O,R=m[B])}w=N,T=F+h,S&&this.laneAssignments.set(y,w)}else w=y%this.options.lanes,T=n+i,S&&this.laneAssignments.set(y,w);const j=d.get(k),E=typeof j=="number"?j:this.options.estimateSize(y),L=T+E;f[y]={index:y,start:T,size:E,end:L,key:k,lane:w},m[w]===void 0&&x++,m[w]=y,g[w]=L}return this.measurementsCache=f,f},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Os(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(r,n,i,s)=>r.length===0||n===0?(this.range=null,null):(this.range=JJ(r,n,i,s,s===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Os(()=>{let r=null,n=null;const i=this.calculateRange();return i&&(r=i.startIndex,n=i.endIndex),this.maybeNotify.updateDeps([this.isScrolling,r,n]),[this.options.rangeExtractor,this.options.overscan,this.options.count,r,n]},(r,n,i,s,o)=>s===null||o===null?[]:r({startIndex:s,endIndex:o,overscan:n,count:i}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=r=>{const n=this.options.indexAttribute,i=r.getAttribute(n);return i?parseInt(i,10):(console.warn(`Missing attribute name '${n}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=r=>{var n;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const i=this.scrollState.index??((n=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:n.index);if(i!==void 0&&this.range){const s=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),o=Math.max(0,i-s),a=Math.min(this.options.count-1,i+s);return r>=o&&r<=a}return!0},this.measureElement=r=>{if(!r){this.elementsCache.forEach((o,a)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(a))});return}const n=this.indexFromElement(r),i=this.options.getItemKey(n),s=this.elementsCache.get(i);s!==r&&(s&&this.observer.unobserve(s),this.observer.observe(r),this.elementsCache.set(i,r)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(r,void 0,this))},this.resizeItem=(r,n)=>{var i,s;if(r<0||r>=this.options.count)return;let o,a,l;const h=this._flatMeasurements;if(this.options.lanes===1&&h!==null)l=this.options.getItemKey(r),a=h[r*2],o=h[r*2+1];else{const p=this.measurementsCache[r];if(!p)return;l=p.key,a=p.start,o=p.size}const u=this.itemSizeCache.get(l)??o,d=n-u;if(d!==0){const p=this.options.anchorTo==="end"&&((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,f=p?this.getTotalSize():0,m=((s=this.scrollState)==null?void 0:s.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[r]??{index:r,key:l,start:a,size:o,end:a+o,lane:0},d,this):a<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(l)||this.scrollDirection!=="backward"));(this.pendingMin===null||r<this.pendingMin)&&(this.pendingMin=r),this.itemSizeCache.set(l,n),this.itemSizeCacheVersion++,p?this.applyScrollAdjustment(this.getTotalSize()-f):m&&this.applyScrollAdjustment(d),this.notify(!1)}},this.getVirtualItems=Os(()=>[this.getVirtualIndexes(),this.getMeasurements()],(r,n)=>{const i=[];for(let s=0,o=r.length;s<o;s++){const a=r[s],l=n[a];i.push(l)}return i},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=r=>{const n=this.getMeasurements();if(n.length===0)return;const i=this._flatMeasurements,s=this.options.lanes===1&&i!=null,o=EN(0,n.length-1,s?a=>i[a*2]:a=>a1(n[a]).start,r);return a1(n[o])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const r=this.scrollElement.document.documentElement;return this.options.horizontal?r.scrollWidth-this.scrollElement.innerWidth:r.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(r=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=r,this.getOffsetForAlignment=(r,n,i=0)=>{if(!this.scrollElement)return 0;const s=this.getSize(),o=this.getScrollOffset();n==="auto"&&(n=r>=o+s?"end":"start"),n==="center"?r+=(i-s)/2:n==="end"&&(r-=s);const a=this.getMaxScrollOffset();return Math.max(Math.min(a,r),0)},this.getOffsetForIndex=(r,n="auto")=>{r=Math.max(0,Math.min(r,this.options.count-1));const i=this.getSize(),s=this.getScrollOffset(),o=this.measurementsCache[r];if(!o)return;if(n==="auto")if(o.end>=s+i-this.options.scrollPaddingEnd)n="end";else if(o.start<=s+this.options.scrollPaddingStart)n="start";else return[s,n];if(n==="end"&&r===this.options.count-1)return[this.getMaxScrollOffset(),n];const a=n==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,n,o.size),n]},this.scrollToOffset=(r,{align:n="start",behavior:i="auto"}={})=>{this._iosDeferredAdjustment=0;const s=this.getOffsetForAlignment(r,n),o=this.now();this.scrollState={index:null,align:n,behavior:i,startedAt:o,lastTargetOffset:s,stableFrames:0},this._scrollToOffset(s,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollToIndex=(r,{align:n="auto",behavior:i="auto"}={})=>{this._iosDeferredAdjustment=0,r=Math.max(0,Math.min(r,this.options.count-1));const s=this.getOffsetForIndex(r,n);if(!s)return;const[o,a]=s,l=this.now();this.scrollState={index:r,align:a,behavior:i,startedAt:l,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollBy=(r,{behavior:n="auto"}={})=>{const i=this.getScrollOffset()+r,s=this.now();this.scrollState={index:null,align:"start",behavior:n,startedAt:s,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:r="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:r});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:r})},this.getTotalSize=()=>{var r;const n=this.getMeasurements();let i;if(n.length===0)i=this.options.paddingStart;else if(this.options.lanes===1){const s=n.length-1,o=this._flatMeasurements;o!=null?i=o[s*2]+o[s*2+1]:i=((r=n[s])==null?void 0:r.end)??0}else{const s=Array(this.options.lanes).fill(null);let o=n.length-1;for(;o>=0&&s.some(a=>a===null);){const a=n[o];s[a.lane]===null&&(s[a.lane]=a.end),o--}i=Math.max(...s.filter(a=>a!==null))}return Math.max(i-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const r=[];if(this.itemSizeCache.size===0)return r;const n=this.getMeasurements();for(const i of n)i&&this.itemSizeCache.has(i.key)&&r.push({index:i.index,key:i.key,start:i.start,size:i.size,end:i.end,lane:i.lane});return r},this._scrollToOffset=(r,{adjustments:n,behavior:i})=>{this._intendedScrollOffset=r+(n??0),this.options.scrollToFn(r,{behavior:i,adjustments:n},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(t)}applyScrollAdjustment(t,r){t!==0&&(yf()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=t:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,behavior:r}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const n=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,i=n?n[0]:this.scrollState.lastTargetOffset,s=1,o=i!==this.scrollState.lastTargetOffset;if(!o&&PJ(i,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=s){this.getScrollOffset()!==i&&this._scrollToOffset(i,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,o){const a=this.getSize()||600,l=Math.abs(i-this.getScrollOffset()),h=this.scrollState.behavior==="smooth"&&l>a;this.scrollState.lastTargetOffset=i,h||(this.scrollState.behavior="auto"),this._scrollToOffset(i,{adjustments:void 0,behavior:h?"smooth":"auto"})}this.scheduleScrollReconcile()}}const EN=(e,t,r,n)=>{for(;e<=t;){const i=(e+t)/2|0,s=r(i);if(s<n)e=i+1;else if(s>n)t=i-1;else return i}return e>0?e-1:0};function QJ(e,t,r){let n=0;for(;n<=t;){const i=(n+t)/2|0,s=e[i*2];if(s<r)n=i+1;else if(s>r)t=i-1;else return i}return n>0?n-1:0}function JJ(e,t,r,n,i){const s=e.length-1;if(e.length<=n)return{startIndex:0,endIndex:s};if(n===1&&i!==null){const h=QJ(i,s,r);let u=h;const d=r+t;for(;u<s&&i[u*2]+i[u*2+1]<d;)u++;return{startIndex:h,endIndex:u}}let a=EN(0,s,h=>e[h].start,r),l=a;if(n===1)for(;l<s&&e[l].end<r+t;)l++;else if(n>1){const h=Array(n).fill(0);for(;l<s&&h.some(d=>d<r+t);){const d=e[l];h[d.lane]=d.end,l++}const u=Array(n).fill(r+t);for(;a>=0&&u.some(d=>d>=r);){const d=e[a];u[d.lane]=d.start,a--}a=Math.max(0,a-a%n),l=Math.min(s,l+(n-1-l%n))}return{startIndex:a,endIndex:l}}const bf=typeof document<"u"?C.useLayoutEffect:C.useEffect;function ZJ({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:r="transform",...n}){const i=C.useReducer(h=>h+1,0)[1],s=C.useRef({enabled:t,mode:r,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});s.current.enabled=t,s.current.mode=r;const o=h=>{const u=s.current;if(!u.enabled||!u.container)return;const d=h.getTotalSize();if(d!==u.lastSize){u.lastSize=d;const y=h.options.horizontal?"width":"height";u.container.style[y]=`${d}px`}const p=!!h.options.horizontal,f=u.mode==="transform",m=p?"left":"top",g=h.options.scrollMargin,x=h.getVirtualItems();for(const y of x){const k=y.start-g,b=h.elementsCache.get(y.key);b&&u.lastPositions.get(b)!==k&&(u.lastPositions.set(b,k),f?b.style.transform=p?`translate3d(${k}px, 0, 0)`:`translate3d(0, ${k}px, 0)`:b.style[m]=`${k}px`)}},a={...n,onChange:(h,u)=>{var d;const p=s.current;let f=!0;if(p.enabled){o(h);const m=h.range,g=p.prevRange;f=!g||g.isScrolling!==h.isScrolling||g.startIndex!==(m==null?void 0:m.startIndex)||g.endIndex!==(m==null?void 0:m.endIndex),f&&(p.prevRange=m?{startIndex:m.startIndex,endIndex:m.endIndex,isScrolling:h.isScrolling}:null)}f&&(e&&u?VN.flushSync(i):i()),(d=n.onChange)==null||d.call(n,h,u)}},[l]=C.useState(()=>{const h=new KJ(a);return Object.assign(h,{containerRef:u=>{const d=s.current;if(d.container=u,d.lastSize=null,u&&d.enabled){const p=h.getTotalSize();d.lastSize=p;const f=h.options.horizontal?"width":"height";u.style[f]=`${p}px`}}})});return l.setOptions(a),bf(()=>l._didMount(),[]),bf(()=>l._willUpdate()),bf(()=>{o(l)}),l}function eZ(e){return ZJ({observeElementRect:WJ,observeElementOffset:YJ,scrollToFn:XJ,...e})}function tZ(e,t,r){var a,l;const n=[],i=(r==null?void 0:r.id)??null;if(Array.isArray(e))for(const h of e){if(n.push({id:`session-start-${h.id}`,timestamp:h.startedAt,category:"session",title:"Session started",detail:h.source?`Source: ${h.source}`:null,severity:"info",sessionId:h.id,meta:{toolCount:h.toolCount,source:h.source}}),h.endedAt&&n.push({id:`session-end-${h.id}`,timestamp:h.endedAt,category:"session",title:`Session ended (${h.toolCount??0} tools${(a=h.errors)!=null&&a.length?`, ${h.errors.length} error${h.errors.length>1?"s":""}`:""})`,detail:null,severity:"info",sessionId:h.id,meta:{toolCount:h.toolCount,errorCount:((l=h.errors)==null?void 0:l.length)??0}}),Array.isArray(h.errors))for(let u=0;u<h.errors.length;u++){const d=h.errors[u];n.push({id:`error-${h.id}-${u}`,timestamp:d.timestamp||h.startedAt,category:"error",title:d.message||`${d.type} error`,detail:d.tool?`Tool: ${d.tool}`:null,severity:d.severity==="error"?"error":"warning",sessionId:h.id,meta:{type:d.type,tool:d.tool}})}if(h.phaseAtBind&&h.phaseAtEnd&&h.phaseAtBind!==h.phaseAtEnd){const u=new Date(h.startedAt).getTime(),d=h.endedAt?new Date(h.endedAt).getTime():u,p=new Date(u+(d-u)*.8).toISOString();n.push({id:`phase-${h.id}`,timestamp:p,category:"phase",title:`Phase: ${h.phaseAtBind} → ${h.phaseAtEnd}`,detail:null,severity:"success",sessionId:h.id,meta:{from:h.phaseAtBind,to:h.phaseAtEnd}})}}if(Array.isArray(t)){const h=i?t.filter(u=>u.itemId===i):t;for(const u of h){if(u.createdAt){const d=Tl[u.stepId]??(u.fromPhase&&u.toPhase?`${Pr[u.fromPhase]??u.fromPhase} → ${Pr[u.toPhase]??u.toPhase}`:"Gate created");n.push({id:`gate-created-${u.id}`,timestamp:u.createdAt,category:"gate",title:d,detail:null,severity:"info",sessionId:null,meta:{gateId:u.id,fromPhase:u.fromPhase,toPhase:u.toPhase}})}if(u.resolvedAt&&u.outcome){const p={approve:"approve",approved:"approve",revise:"revise",revised:"revise",kill:"kill",killed:"kill"}[u.outcome]||u.outcome,f={approve:"success",revise:"warning",kill:"error"},m={approve:"approved",revise:"revised",kill:"killed"};n.push({id:`gate-resolved-${u.id}`,timestamp:u.resolvedAt,category:"gate",title:`Gate ${m[p]||u.outcome}`,detail:u.comment||null,severity:f[p]||"info",sessionId:null,meta:{gateId:u.id,outcome:u.outcome,comment:u.comment}})}}}const s=new Set,o=[];for(const h of n)s.has(h.id)||(s.add(h.id),o.push(h));return o.sort((h,u)=>h.timestamp.localeCompare(u.timestamp)),o}const rZ={phase:"→",gate:"◈",session:"●",iteration:"↻",error:"⚠"};function nZ(e){if(!e)return"";const t=Date.now()-new Date(e).getTime(),r=Math.floor(t/6e4);if(r<1)return"now";if(r<60)return`${r}m`;const n=Math.floor(r/60);return n<24?`${n}h`:`${Math.floor(n/24)}d`}function iZ({event:e,onSelectItem:t,style:r}){const n=rZ[e.category]||"●",i=W5[e.category]||"text-zinc-400",s=q5[e.severity]||"text-zinc-400";return c.jsxs("div",{className:"flex items-start gap-2 px-2 py-1.5 rounded",style:r,children:[c.jsx("span",{className:ne("text-[11px] shrink-0 w-4 text-center leading-4",i),children:n}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("p",{className:ne("text-[11px] truncate",s),children:e.title}),e.detail&&c.jsx("p",{className:"text-[10px] text-muted-foreground/60 truncate",children:e.detail})]}),c.jsx("span",{className:"text-[10px] text-muted-foreground/50 tabular-nums shrink-0 leading-4",children:nZ(e.timestamp)})]})}const sZ=["all","phase","gate","session","iteration","error"],c1={all:"All",phase:"Phase",gate:"Gate",session:"Session",iteration:"Iteration",error:"Error"};function oZ({featureCode:e,itemId:t,onSelectItem:r}){const[n,i]=C.useState("all"),[s,o]=C.useState([]),a=C.useRef(null),l=Ee(m=>m.gates),h=Ee(m=>m.featureTimeline),u=Ee(m=>m.setFeatureTimeline);C.useEffect(()=>{if(!e)return;let m=!1;return _e(`/api/session/history?featureCode=${encodeURIComponent(e)}&limit=50`).then(g=>g.json()).then(g=>{if(m)return;const x=t?(l||[]).filter(k=>k.itemId===t):l||[],y=tZ(g.sessions||[],x,{id:t});o(y)}).catch(()=>{m||o([])}),()=>{m=!0}},[e,t]);const d=C.useMemo(()=>{var x,y;const m=new Map;for(const k of s)m.set(k.id,k);for(const k of h){const b=(x=k.meta)==null?void 0:x.itemId,w=(y=k.meta)==null?void 0:y.featureCode;(!b&&!w||b===t||w===e)&&m.set(k.id,k)}const g=[...m.values()];return g.sort((k,b)=>k.timestamp.localeCompare(b.timestamp)),g},[s,h,t,e]),p=C.useMemo(()=>n==="all"?d:d.filter(m=>m.category===n),[d,n]),f=eZ({count:p.length,getScrollElement:()=>a.current,estimateSize:()=>48,overscan:5});return C.useEffect(()=>{u&&u([])},[e]),e?c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsx("div",{className:"flex flex-wrap gap-1 px-2 py-2 border-b border-border",children:sZ.map(m=>c.jsxs("button",{className:ne("px-2 py-0.5 rounded text-[10px] font-medium transition-colors",n===m?"bg-foreground/10 text-foreground":"text-muted-foreground/60 hover:text-muted-foreground hover:bg-muted/30"),onClick:()=>i(m),children:[c1[m],m!=="all"&&c.jsx("span",{className:"ml-1 text-[9px] opacity-60",children:d.filter(g=>g.category===m).length})]},m))}),c.jsx("div",{className:"px-2 py-1",children:c.jsxs("span",{className:"text-[10px] text-muted-foreground/50",children:[p.length," event",p.length!==1?"s":""]})}),c.jsx("div",{ref:a,className:"flex-1 overflow-auto",children:p.length===0?c.jsxs("p",{className:"text-[11px] text-muted-foreground/50 px-2 py-4 text-center",children:["No events",n!=="all"?` in "${c1[n]}"`:"","."]}):c.jsx("div",{style:{height:`${f.getTotalSize()}px`,width:"100%",position:"relative"},children:f.getVirtualItems().map(m=>c.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:`${m.size}px`,transform:`translateY(${m.start}px)`},children:c.jsx(iZ,{event:p[m.index],onSelectItem:r})},m.key))})})]}):c.jsx("div",{className:"flex items-center justify-center h-full",children:c.jsx("p",{className:"text-[11px] text-muted-foreground/50",children:"Select a feature to see its timeline."})})}const nl=["explore_design","prd","architecture","blueprint","plan","execute","report"];function aZ(e){if(!e)return"";const t=Date.now()-new Date(e).getTime(),r=Math.floor(t/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const n=Math.floor(r/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}function lZ({currentPhase:e}){const t=nl.indexOf(e);return c.jsx("div",{className:"space-y-1.5",children:nl.map((r,n)=>{const i=t>n,s=t===n,o=Pr[r]??r;return c.jsxs("div",{className:"flex items-center gap-2",style:{animation:`phase-slide-in 300ms ease-out ${n*50}ms both`},children:[i?c.jsx(pm,{className:"w-3.5 h-3.5 text-emerald-400 shrink-0",style:{animation:"phase-check-pop 400ms ease-out"}}):s?c.jsx(j1,{className:"w-3.5 h-3.5 text-blue-400 shrink-0",style:{animation:"phase-active-pulse 2s ease-in-out infinite"}}):c.jsx(bE,{className:"w-3.5 h-3.5 text-muted-foreground/40 shrink-0"}),c.jsx("span",{className:ne("text-[11px] transition-colors duration-500",i&&"text-emerald-400",s&&"text-blue-400 font-medium",!i&&!s&&"text-muted-foreground/50"),children:o})]},r)})})}function cZ({spawnedAgents:e,activeBuild:t,sessionState:r,agentActivity:n}){const i=(e||[]).filter(a=>a.status==="running"),s=(e||[]).filter(a=>a.status!=="running").slice(-3).reverse(),o=C.useMemo(()=>{const a=["design.md","blueprint.md","plan.md","prd.md","architecture.md"],l=new Set(((t==null?void 0:t.steps)||[]).filter(h=>h.status==="done"||h.status==="completed").map(h=>h.id||h.name));return a.map(h=>({name:h,done:l.has(h)||((t==null?void 0:t.steps)||[]).some(u=>{var d,p;return(u.status==="done"||u.status==="completed")&&(((d=u.id)==null?void 0:d.includes(h.replace(".md","")))||((p=u.name)==null?void 0:p.includes(h.replace(".md",""))))})}))},[t]);return c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{children:[c.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Agents"}),i.length===0&&s.length===0&&c.jsx("p",{className:"text-[11px] text-muted-foreground/50 mt-1",children:"No agents active"}),c.jsxs("div",{className:"mt-1 space-y-1.5",children:[i.map((a,l)=>c.jsx(o1,{agent:a,toolCount:(r==null?void 0:r.toolCount)||0,errorCount:(r==null?void 0:r.errorCount)||0,currentTool:n==null?void 0:n.tool,currentCategory:n==null?void 0:n.category},a.agentId||l)),s.map((a,l)=>c.jsx(o1,{agent:a},a.agentId||`r-${l}`))]})]}),c.jsxs("div",{children:[c.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Artifacts"}),c.jsx("div",{className:"mt-1 space-y-1",children:o.map(a=>c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(hs,{className:ne("w-3 h-3",a.done?"text-emerald-400":"text-muted-foreground/40")}),c.jsx("span",{className:ne("text-[11px] font-mono",a.done?"text-foreground":"text-muted-foreground/50"),children:a.name})]},a.name))})]})]})}function hZ({gates:e,allGates:t,items:r,onResolveGate:n}){const i=T1(),s=C.useMemo(()=>{const o=new Map,a=(t||[]).filter(l=>l.resolvedAt&&(l.outcome==="revised"||l.outcome==="revise")).sort((l,h)=>new Date(h.resolvedAt)-new Date(l.resolvedAt));for(const l of e||[]){const h=a.find(u=>u.stepId===l.stepId&&u.itemId===l.itemId);h!=null&&h.artifactSnapshot&&l.artifactSnapshot&&o.set(l.id,{priorSnapshot:h.artifactSnapshot,currentSnapshot:l.artifactSnapshot})}return o},[e,t]);return!e||e.length===0?c.jsx("p",{className:"text-[11px] text-muted-foreground/50 px-1",children:"No gates pending."}):c.jsx("div",{className:"space-y-2",children:e.map(o=>{var h;const a=r.find(u=>u.id===o.itemId),l=(h=o.artifactAssessment)==null?void 0:h.completeness;return c.jsx("div",{className:"px-3 py-2 rounded border border-border bg-muted/30",children:c.jsxs("div",{className:"flex items-start gap-2",children:[c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("p",{className:"text-[11px] text-foreground truncate",children:(a==null?void 0:a.title)??"Unknown"}),c.jsxs("p",{className:"text-[10px] text-muted-foreground",children:[Tl[o.stepId]??Pr[o.fromPhase]??o.fromPhase??"Gate",l!=null&&` · ${Math.round(l*100)}% complete`]}),s.has(o.id)&&c.jsx("div",{className:"mt-1",children:c.jsx(hx,{oldText:s.get(o.id).priorSnapshot,newText:s.get(o.id).currentSnapshot})})]}),c.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[c.jsx(Fe,{variant:"outline",size:"sm",className:"h-6 text-[10px] gap-1 text-success border-success/30 hover:bg-success/10",onClick:()=>n(o.id,"approved"),children:"Approve"}),c.jsx(Fe,{variant:"outline",size:"sm",className:"h-6 text-[10px] gap-1 text-amber-400 border-amber-400/30 hover:bg-amber-400/10",onClick:()=>n(o.id,"revised"),children:"Revise"}),c.jsx(Fe,{variant:"outline",size:"sm",className:"h-6 text-[10px] gap-1 text-destructive border-destructive/30 hover:bg-destructive/10",onClick:async()=>{const u=await i({title:"Kill this gate?",label:"Reason (required)",destructive:!0});u&&n(o.id,"killed",u)},children:"Kill"})]})]})},o.id)})})}function uZ({sessions:e,items:t,onSelect:r}){const n=(e||[]).slice(-5).reverse();return n.length===0?c.jsx("p",{className:"text-[11px] text-muted-foreground/50 px-1",children:"No sessions yet."}):c.jsx("div",{className:"space-y-1",children:n.map(i=>{const s=i.featureCode||i.feature_code,o=s?t.find(l=>{var h;return l.featureCode===s||l.feature_code===s||((h=l.lifecycle)==null?void 0:h.featureCode)===s}):null,a=i.startedAt||i.created_date;return c.jsxs("div",{className:ne("flex items-center gap-2 px-2 py-1.5 rounded hover:bg-muted/50 transition-colors",o&&"cursor-pointer"),onClick:()=>o&&r(o.id),children:[c.jsx(N5,{className:"w-3 h-3 text-muted-foreground shrink-0"}),c.jsx("span",{className:"text-[11px] text-foreground",children:i.agent||"agent"}),s&&c.jsx(Ko,{kind:"feature",id:s,label:s,className:"text-[9px]"}),c.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground tabular-nums shrink-0",children:aZ(a)}),c.jsx("span",{className:ne("w-1.5 h-1.5 rounded-full shrink-0",i.status==="active"?"bg-emerald-400":"bg-slate-600")})]},i.id)})})}function dZ({items:e=[],gates:t=[],sessions:r=[],activeBuild:n,spawnedAgents:i=[],featureCode:s,sessionState:o,agentActivity:a,iterationStates:l,onSelect:h,onResolveGate:u,onOpenGate:d,onCreateFeature:p,isEmptyProject:f}){var S;const m=C.useMemo(()=>e.find(j=>{var E;return j.featureCode===s||((E=j.lifecycle)==null?void 0:E.featureCode)===s}),[e,s]),[g,x]=C.useState(()=>{try{return localStorage.getItem("compose:timeline-open")==="true"}catch{return!1}}),y=C.useCallback(()=>{x(j=>{const E=!j;try{localStorage.setItem("compose:timeline-open",String(E))}catch{}return E})},[]),k=((S=m==null?void 0:m.lifecycle)==null?void 0:S.currentPhase)||(m==null?void 0:m.phase)||(n==null?void 0:n.currentStepId)||(n==null?void 0:n.currentStep)||null,b=nl.indexOf(k),w=k?Math.max(0,(b+1)/nl.length):0,T=C.useMemo(()=>{let j=t.filter(E=>E.status==="pending"||!E.resolvedAt);if(s){const E=new Set(e.filter(L=>{var N;return L.featureCode===s||((N=L.lifecycle)==null?void 0:N.featureCode)===s}).map(L=>L.id));j=j.filter(L=>E.has(L.itemId))}return j},[t,e,s]);if(!s){const j=e.filter(E=>E.type==="feature"&&(E.status==="complete"||E.status==="done")).slice(-5);return c.jsx("div",{className:"flex-1 overflow-auto p-4",children:c.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 py-16 text-center",children:[c.jsx("p",{className:"text-sm text-muted-foreground",children:f?"No items yet.":"No feature in progress."}),f&&p&&c.jsx(Fe,{variant:"outline",size:"sm",onClick:p,children:"Create your first feature"}),c.jsx("p",{className:"text-[11px] text-muted-foreground/70 font-mono",children:"Run /compose <feature-code> in the terminal to start."}),j.length>0&&c.jsxs("div",{className:"mt-6 w-full max-w-sm",children:[c.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Recently completed"}),c.jsx("div",{className:"mt-2 space-y-1",children:j.map(E=>c.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded hover:bg-muted/50 cursor-pointer transition-colors",onClick:()=>h(E.id),children:[c.jsx(pm,{className:"w-3 h-3 text-emerald-400 shrink-0"}),c.jsx("span",{className:"text-[11px] text-foreground truncate",children:E.title}),E.featureCode&&c.jsx(_r,{variant:"outline",className:"text-[9px] px-1 py-0 h-4 font-mono ml-auto shrink-0",children:E.featureCode})]},E.id))})]})]})})}return c.jsxs("div",{className:"flex-1 flex flex-row overflow-hidden",children:[c.jsxs("div",{className:"flex-1 overflow-auto p-4 space-y-4 min-w-0",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("h2",{className:"text-sm font-semibold text-foreground truncate",children:(m==null?void 0:m.title)??s}),c.jsx(_r,{variant:"outline",className:"text-[9px] px-1.5 py-0 h-4 font-mono shrink-0",children:s}),k&&c.jsx(_r,{variant:"secondary",className:"text-[9px] px-1.5 py-0 h-4 shrink-0",children:Pr[k]??k}),c.jsxs("button",{className:ne("ml-auto flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-medium transition-colors shrink-0",g?"bg-foreground/10 text-foreground":"text-muted-foreground/60 hover:text-muted-foreground hover:bg-muted/30"),onClick:y,children:[c.jsx(QE,{className:"w-3 h-3"}),"Timeline"]})]}),c.jsx("div",{className:"mt-2 h-1.5 rounded-full bg-muted overflow-hidden",children:c.jsx("div",{className:"h-full rounded-full bg-blue-500",style:{width:`${Math.round(w*100)}%`,transition:"width 800ms cubic-bezier(0.4, 0, 0.2, 1)"}})}),c.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:b>=0?`${b+1} of ${nl.length} phases`:"Phase unknown"})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[c.jsxs(em,{className:"bg-card border-border",style:{animation:"phase-card-enter 400ms ease-out"},children:[c.jsx(tm,{className:"p-3 pb-2",children:c.jsx(rm,{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Phase Timeline"})}),c.jsx(nm,{className:"p-3 pt-0",children:c.jsx(lZ,{currentPhase:k})})]}),c.jsxs(em,{className:"bg-card border-border",style:{animation:"phase-card-enter 400ms ease-out 100ms both"},children:[c.jsx(tm,{className:"p-3 pb-2",children:c.jsx(rm,{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Agents & Artifacts"})}),c.jsx(nm,{className:"p-3 pt-0",children:c.jsx(cZ,{spawnedAgents:i,activeBuild:n,sessionState:o,agentActivity:a})})]})]}),l&&l.size>0&&c.jsx("div",{className:"space-y-2",children:[...l.values()].map(j=>c.jsxs("div",{className:"px-3 py-2.5 rounded border border-blue-500/30 bg-blue-500/10",children:[c.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[c.jsxs("span",{className:"text-[11px] text-blue-400 font-medium",children:[j.status==="running"?"↻":j.outcome==="clean"?"✓":"✗"," ",j.loopType==="review"?"Review Loop":"Coverage Sweep"]}),c.jsxs("span",{className:"text-[11px] text-blue-300 font-mono",children:[j.count," of ",j.maxIterations]})]}),c.jsx("div",{className:"h-1.5 rounded-full bg-blue-500/20 overflow-hidden",children:c.jsx("div",{className:"h-full rounded-full",style:{width:`${Math.round(j.count/j.maxIterations*100)}%`,transition:"width 600ms cubic-bezier(0.4, 0, 0.2, 1)",backgroundColor:j.outcome==="clean"?"#22c55e":j.outcome==="max_reached"?"#ef4444":"#3b82f6"}})}),c.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:j.status==="running"?j.loopType==="review"?"Waiting for clean review...":"Waiting for tests passing...":j.outcome==="clean"?"Clean!":j.outcome==="max_reached"?"Max iterations reached":"Aborted"})]},j.loopId))}),c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[c.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Pending Gates"}),T.length>0&&c.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-amber-400/15 text-amber-400 font-medium",children:T.length})]}),c.jsx(hZ,{gates:T,allGates:t,items:e,onResolveGate:u})]}),c.jsxs("div",{children:[c.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Recent Sessions"}),c.jsx("div",{className:"mt-2",children:c.jsx(uZ,{sessions:r,items:e,onSelect:h})})]})]}),g&&c.jsxs("div",{className:"w-80 border-l border-border flex flex-col shrink-0",children:[c.jsx("div",{className:"px-3 py-2 border-b border-border",children:c.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Event Timeline"})}),c.jsx(oZ,{featureCode:s,itemId:m==null?void 0:m.id,onSelectItem:h})]})]})}function fZ(e,t){var i,s;if(!((i=e.tags)!=null&&i.length)||!((s=t.tags)!=null&&s.length))return 0;const r=new Set(e.tags);return t.tags.filter(o=>r.has(o)).length/Math.max(e.tags.length,t.tags.length)}function pZ(e,t){return t.filter(r=>r.id!==e.id).map(r=>({idea:r,score:fZ(e,r)})).filter(({score:r})=>r>.25).sort((r,n)=>n.score-r.score).slice(0,3).map(({idea:r})=>r)}function mZ({results:e,onClose:t}){const r=C.useMemo(()=>{const i={P0:0,P1:0,P2:0,killed:0,promoted:0,skipped:0};for(const s of e)s.action==="skip"?i.skipped++:s.action==="kill"?i.killed++:s.action==="promote"?i.promoted++:s.priority==="P0"?i.P0++:s.priority==="P1"?i.P1++:s.priority==="P2"&&i.P2++;return i},[e]),n=e.filter(i=>i.action!=="skip").length;return c.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-8 text-center",children:[c.jsx("div",{className:"w-10 h-10 rounded-full bg-emerald-400/20 flex items-center justify-center",children:c.jsx(Ji,{className:"w-5 h-5 text-emerald-400"})}),c.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Triage complete"}),c.jsxs("p",{className:"text-[12px] text-muted-foreground",children:["Triaged ",n," of ",e.length," ideas"]}),c.jsxs("div",{className:"flex gap-3 text-[11px]",children:[r.P0>0&&c.jsxs("span",{className:"text-red-400",children:[r.P0," P0"]}),r.P1>0&&c.jsxs("span",{className:"text-amber-400",children:[r.P1," P1"]}),r.P2>0&&c.jsxs("span",{className:"text-blue-400",children:[r.P2," P2"]}),r.promoted>0&&c.jsxs("span",{className:"text-emerald-400",children:[r.promoted," promoted"]}),r.killed>0&&c.jsxs("span",{className:"text-muted-foreground",children:[r.killed," killed"]}),r.skipped>0&&c.jsxs("span",{className:"text-muted-foreground/60",children:[r.skipped," skipped"]})]}),c.jsx(Fe,{size:"sm",onClick:t,className:"mt-2",children:"Done"})]})}function gZ({ideas:e,onClose:t}){const{setPriority:r,killIdea:n,promoteIdea:i,ideas:s}=_o(),[o,a]=C.useState(()=>[...e]),[l,h]=C.useState(0),[u,d]=C.useState([]),[p,f]=C.useState(!1),[m,g]=C.useState(""),[x,y]=C.useState(!1),[k,b]=C.useState(!1),w=o[l]??null;o.length-l;const T=C.useMemo(()=>w?pZ(w,s.filter(F=>F.id!==w.id)):[],[w,s]),S=C.useCallback(()=>{const F=l+1;F>=o.length?f(!0):(h(F),y(!1),g(""))},[l,o.length]),j=C.useCallback(async F=>{if(!(!w||k)){b(!0);try{await r(w.id,F),d(R=>[...R,{id:w.id,action:"priority",priority:F}]),S()}finally{b(!1)}}},[w,k,r,S]),E=C.useCallback(async()=>{if(!(!w||k)){b(!0);try{await n(w.id,m),d(F=>[...F,{id:w.id,action:"kill"}]),y(!1),g(""),S()}finally{b(!1)}}},[w,k,n,m,S]),L=C.useCallback(()=>{w&&(d(F=>[...F,{id:w.id,action:"skip"}]),S())},[w,S]),N=C.useCallback(async()=>{if(!(!w||k)){b(!0);try{await i(w.id),d(F=>[...F,{id:w.id,action:"promote"}]),S()}finally{b(!1)}}},[w,k,i,S]);return C.useEffect(()=>{const F=R=>{if(R.key==="Escape"){t();return}x||(R.key==="0"&&j("P0"),R.key==="1"&&j("P1"),R.key==="2"&&j("P2"),(R.key==="s"||R.key==="ArrowRight")&&L(),R.key==="k"&&y(!0))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[x,j,L,t]),c.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"hsl(var(--background) / 0.8)",backdropFilter:"blur(4px)"},children:c.jsxs("div",{className:"w-full max-w-lg mx-4 rounded-xl border border-border bg-card shadow-2xl flex flex-col overflow-hidden",children:[c.jsxs("div",{className:"px-4 py-3 border-b border-border flex items-center gap-2",children:[c.jsx(Ji,{className:"w-4 h-4 text-amber-400 shrink-0"}),c.jsx("span",{className:"text-sm font-semibold text-foreground",children:"Triage"}),!p&&c.jsxs("span",{className:"text-[11px] text-muted-foreground ml-1",children:[l+1," of ",o.length," untriaged"]}),c.jsx("div",{className:"flex-1"}),c.jsx("button",{onClick:t,className:"text-muted-foreground/60 hover:text-foreground transition-colors",children:c.jsx(jr,{className:"w-4 h-4"})})]}),!p&&c.jsx("div",{className:"h-1 bg-muted",children:c.jsx("div",{className:"h-full bg-accent transition-all duration-300",style:{width:`${Math.round(l/o.length*100)}%`}})}),c.jsx("div",{className:"flex-1 p-4",children:p?c.jsx(mZ,{results:u,onClose:t}):w?c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 p-4",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[c.jsx(_r,{variant:"outline",className:"text-[9px] px-1 py-0 h-4 font-mono",children:w.id}),w.cluster&&c.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:w.cluster})]}),c.jsx("h3",{className:"text-[14px] text-foreground font-semibold leading-snug mb-2",children:w.title}),w.description&&c.jsx("p",{className:"text-[12px] text-muted-foreground leading-relaxed mb-2",children:w.description}),c.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:(w.tags||[]).map(F=>c.jsx("span",{className:"text-[10px] bg-muted px-1.5 py-0.5 rounded font-mono text-muted-foreground",children:F},F))}),w.source&&c.jsxs("p",{className:"text-[10px] text-muted-foreground/50 mt-2",children:["Source: ",w.source]})]}),T.length>0&&c.jsxs("div",{children:[c.jsx("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold mb-1.5",children:"Similar to:"}),c.jsx("div",{className:"space-y-1",children:T.map(F=>c.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded bg-muted/30 border border-border/40",children:[c.jsx(_r,{variant:"outline",className:"text-[9px] px-1 py-0 h-4 font-mono opacity-70",children:F.id}),c.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:F.title})]},F.id))})]}),x&&c.jsxs("div",{className:"space-y-2",children:[c.jsx("input",{autoFocus:!0,type:"text",placeholder:"Reason for killing (optional)…",value:m,onChange:F=>g(F.target.value),onKeyDown:F=>{F.key==="Enter"&&E(),F.key==="Escape"&&y(!1)},className:"w-full text-[12px] bg-muted text-foreground px-3 py-2 rounded border border-border outline-none focus:border-ring"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Fe,{size:"sm",variant:"outline",className:"flex-1 h-7 text-[11px]",onClick:()=>{y(!1),g("")},children:"Cancel"}),c.jsx(Fe,{size:"sm",className:"flex-1 h-7 text-[11px] bg-destructive/80 hover:bg-destructive text-destructive-foreground",onClick:E,disabled:k,children:"Confirm Kill"})]})]})]}):c.jsx("p",{className:"text-[12px] text-muted-foreground text-center py-8",children:"No more untriaged ideas."})}),!p&&w&&!x&&c.jsxs("div",{className:"px-4 pb-4 space-y-2",children:[c.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[c.jsxs(Fe,{size:"sm",className:"h-9 text-[12px] bg-red-500/80 hover:bg-red-500 text-white border-0",onClick:()=>j("P0"),disabled:k,title:"Press 0",children:["P0 ",c.jsx("kbd",{className:"ml-1 text-[9px] opacity-60 font-mono",children:"0"})]}),c.jsxs(Fe,{size:"sm",className:"h-9 text-[12px] bg-amber-500/80 hover:bg-amber-500 text-white border-0",onClick:()=>j("P1"),disabled:k,title:"Press 1",children:["P1 ",c.jsx("kbd",{className:"ml-1 text-[9px] opacity-60 font-mono",children:"1"})]}),c.jsxs(Fe,{size:"sm",className:"h-9 text-[12px] bg-blue-500/80 hover:bg-blue-500 text-white border-0",onClick:()=>j("P2"),disabled:k,title:"Press 2",children:["P2 ",c.jsx("kbd",{className:"ml-1 text-[9px] opacity-60 font-mono",children:"2"})]})]}),c.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[c.jsx(Fe,{size:"sm",variant:"outline",className:"h-7 text-[11px] text-emerald-400 border-emerald-400/30 hover:bg-emerald-400/10",onClick:N,disabled:k,children:"Promote"}),c.jsxs(Fe,{size:"sm",variant:"outline",className:"h-7 text-[11px] text-destructive border-destructive/30 hover:bg-destructive/10",onClick:()=>y(!0),title:"Press k",children:["Kill ",c.jsx("kbd",{className:"ml-1 text-[9px] opacity-60 font-mono",children:"k"})]}),c.jsxs(Fe,{size:"sm",variant:"outline",className:"h-7 text-[11px] text-muted-foreground gap-1",onClick:L,title:"Press s or →",children:[c.jsx($1,{className:"w-3 h-3"}),"Skip ",c.jsx("kbd",{className:"ml-1 text-[9px] opacity-60 font-mono",children:"s"})]})]})]})]})})}function h1(e){var n;if(!e)return"";const r=(e.cluster||"").toUpperCase().replace(/[^A-Z0-9]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").slice(0,8);if(!r){const i=(((n=e.tags)==null?void 0:n[0])||"").replace("#","").toUpperCase().slice(0,6);return i?`${i}-1`:"FEAT-1"}return`${r}-1`}function xZ(e,t){const r=new Date().toISOString().slice(0,10),n=(e.tags||[]).join(", ")||"N/A";return`# ${t}: ${e.title}
|
|
872
872
|
|