pi-outpost 0.59.1 → 0.60.0
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/CHANGELOG.md +33 -0
- package/dist/contract/validate-structured-exchange.mjs +1 -1
- package/dist/pi-outpost.mjs +101 -100
- package/dist/pi-outpost.sea.mjs +2 -2
- package/dist/sea-prep.blob +2 -2
- package/dist/web/assets/{CodeEditor-CVdicAoQ.js → CodeEditor-D_pn0sQZ.js} +2 -2
- package/dist/web/assets/{PdfViewer-DpNH6Pd3.js → PdfViewer-DvbXSY9-.js} +2 -2
- package/dist/web/assets/{abnfDiagram-S7VZAUFO-DcPQpeRX.js → abnfDiagram-S7VZAUFO-lKJq8Skr.js} +1 -1
- package/dist/web/assets/{architecture-WOLXFQ4H-DrQv9dlr.js → architecture-WOLXFQ4H-Bbmzade-.js} +1 -1
- package/dist/web/assets/{architectureDiagram-YGSQEFNW-Dpuz0uy4.js → architectureDiagram-YGSQEFNW-C1wt-l8K.js} +1 -1
- package/dist/web/assets/{blockDiagram-APKKGZFW-BZMWnMU1.js → blockDiagram-APKKGZFW-B8Ur8I1_.js} +1 -1
- package/dist/web/assets/{c4Diagram-KJ2TOQU5-DC-KW8wf.js → c4Diagram-KJ2TOQU5-DycTkSLU.js} +1 -1
- package/dist/web/assets/{chunk-6MUBBAK2-CPDt0BoO.js → chunk-6MUBBAK2-B3aJt7CT.js} +1 -1
- package/dist/web/assets/{chunk-AXFCVDMN-C9CB2btY.js → chunk-AXFCVDMN-DD1zedxe.js} +1 -1
- package/dist/web/assets/{chunk-BG4553SI-CzX7_OwM.js → chunk-BG4553SI-DcC06r4y.js} +3 -3
- package/dist/web/assets/{chunk-DQASFODM-C1tcohun.js → chunk-DQASFODM-Chixat2J.js} +1 -1
- package/dist/web/assets/{chunk-HFQBQIA3-kN4KIMGn.js → chunk-HFQBQIA3-CY1-hzOn.js} +1 -1
- package/dist/web/assets/{chunk-KQLB2F66-DJ7gkXQn.js → chunk-KQLB2F66-BLgFg6mB.js} +1 -1
- package/dist/web/assets/{chunk-KS47KZWR-CuCrwrBF.js → chunk-KS47KZWR-DkGuNS_t.js} +1 -1
- package/dist/web/assets/{chunk-LEVMRMFU-DRkJFt8f.js → chunk-LEVMRMFU-C9YzX_KN.js} +1 -1
- package/dist/web/assets/{chunk-M57EVK23-Hyjy8C0M.js → chunk-M57EVK23-jtiQOgis.js} +1 -1
- package/dist/web/assets/{chunk-OY52VR5R-_T5hE3Vn.js → chunk-OY52VR5R-BovmS137.js} +1 -1
- package/dist/web/assets/{chunk-QB3YPZ4I-kXgKOFjf.js → chunk-QB3YPZ4I-DSzgjAeG.js} +1 -1
- package/dist/web/assets/{chunk-R3KSYZAL-B6qf_iEW.js → chunk-R3KSYZAL-Ddt2dlij.js} +1 -1
- package/dist/web/assets/{chunk-STOXU5M4-BIg6eLwt.js → chunk-STOXU5M4-mJqMpVLN.js} +1 -1
- package/dist/web/assets/{chunk-TU62E6Q5-CDhnpwo2.js → chunk-TU62E6Q5-BsClfx3U.js} +1 -1
- package/dist/web/assets/{chunk-X4PVCEUW-CIODkGYm.js → chunk-X4PVCEUW-CMHSzz8J.js} +1 -1
- package/dist/web/assets/{classDiagram-v2-L25IHNXF-CDVSmY9N.js → classDiagram-v2-L25IHNXF-HMY21Knl.js} +1 -1
- package/dist/web/assets/{conversationExport-Bm7AfdXa.js → conversationExport-Bz0O3u-1.js} +1 -1
- package/dist/web/assets/{cynefin-EF2NZ3EQ-6IU7tdmt.js → cynefin-EF2NZ3EQ-BdI27Ul-.js} +1 -1
- package/dist/web/assets/{cynefinDiagram-L36ESFBY-BK6Z9HuA.js → cynefinDiagram-L36ESFBY-BR9z3IbN.js} +1 -1
- package/dist/web/assets/{dagre-SPEB5RXH-BBeroizT.js → dagre-SPEB5RXH-9bEl0FEC.js} +1 -1
- package/dist/web/assets/{diagram-3B7GL73J-SHYKCjSI.js → diagram-3B7GL73J-CL6i1E77.js} +1 -1
- package/dist/web/assets/{diagram-DNEMPZML-DzPaQzfm.js → diagram-DNEMPZML-DpAKpppY.js} +1 -1
- package/dist/web/assets/{diagram-L3MUGCDN-1mQrFcYV.js → diagram-L3MUGCDN-C2NmDf70.js} +1 -1
- package/dist/web/assets/{diagram-LA4NIPWU-CInJtMu5.js → diagram-LA4NIPWU-NaVQcJsx.js} +1 -1
- package/dist/web/assets/{diagram-MHCOC4E2-CuZBVAjo.js → diagram-MHCOC4E2-C6qmFqu5.js} +1 -1
- package/dist/web/assets/{diagram-XPFHEONP-4rOwPF1t.js → diagram-XPFHEONP-DjOWugyN.js} +1 -1
- package/dist/web/assets/{dist-JX8lov9e.js → dist-0jiGEnP9.js} +1 -1
- package/dist/web/assets/{dist-CIBXytZw.js → dist-BWKfHbdB.js} +1 -1
- package/dist/web/assets/{dist-CT6YbwFR.js → dist-CRGKzKYZ.js} +1 -1
- package/dist/web/assets/{dist-Cs7RqIMZ.js → dist-DB_LwsDM.js} +1 -1
- package/dist/web/assets/{dist-DonMjL5Z.js → dist-DQ73tUZO.js} +1 -1
- package/dist/web/assets/{dist-BOWayl-A.js → dist-KnElFLn5.js} +1 -1
- package/dist/web/assets/{dist-DWfXhfYo.js → dist-hoZQdLqd.js} +1 -1
- package/dist/web/assets/{docxExport-5ja7lYgY.js → docxExport-So9p3lay.js} +1 -1
- package/dist/web/assets/{ebnfDiagram-UZSYDL2S-Pqz0PZXq.js → ebnfDiagram-UZSYDL2S-AUSXoQdT.js} +1 -1
- package/dist/web/assets/{elk-XV6XMXQE-BqfPNvMq.js → elk-XV6XMXQE-Da-xfGIv.js} +1 -1
- package/dist/web/assets/{erDiagram-EYBAPDEH-ykBIm_G6.js → erDiagram-EYBAPDEH-Cr-qiZJ1.js} +1 -1
- package/dist/web/assets/{eventmodeling-K75KTNOO-CMPff94p.js → eventmodeling-K75KTNOO-BVMDb9aS.js} +1 -1
- package/dist/web/assets/flowDiagram-MALGAFMO-DbmA-Jp0.js +1 -0
- package/dist/web/assets/{ganttDiagram-23REXITY-djUhDELZ.js → ganttDiagram-23REXITY-CwqkLeY_.js} +1 -1
- package/dist/web/assets/{gitGraph-VSP46ZUC-CbDZO3Gx.js → gitGraph-VSP46ZUC-B8wHPNc8.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-STJD7YCW-BqEqXfPF.js → gitGraphDiagram-STJD7YCW-D9sITkH8.js} +1 -1
- package/dist/web/assets/{info-OHQRW6UA-D3g7-vAU.js → info-OHQRW6UA-BxE_dAeA.js} +1 -1
- package/dist/web/assets/{infoDiagram-KBXO4MBG-C00qxUAm.js → infoDiagram-KBXO4MBG-D9Z7YGgT.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-M35NCXHK-D4M88qqf.js → ishikawaDiagram-M35NCXHK-BZvJLf4r.js} +1 -1
- package/dist/web/assets/{journeyDiagram-OPLOXDXO-CmfAEbL7.js → journeyDiagram-OPLOXDXO-CYhJB2UJ.js} +1 -1
- package/dist/web/assets/{kanban-definition-BZKZHSQY-64-0RT-5.js → kanban-definition-BZKZHSQY-Ba7eEvkt.js} +1 -1
- package/dist/web/assets/{line-Y-yvD4k8.js → line-CbfhrdIu.js} +1 -1
- package/dist/web/assets/{loadReferencedImage-CeinDAMm.js → loadReferencedImage-D0UnYJ_d.js} +1 -1
- package/dist/web/assets/{main-DAR6hIVB.js → main-C8QIyBAf.js} +6 -6
- package/dist/web/assets/{mermaid-parser.core-tpdaZqhb.js → mermaid-parser.core-Arsm8RwY.js} +3 -3
- package/dist/web/assets/{mermaid.core-ayA2pTNN.js → mermaid.core-CpAENllk.js} +4 -4
- package/dist/web/assets/{mermaidToImage-CNBBVbXG.js → mermaidToImage-Br-3GSD4.js} +3 -3
- package/dist/web/assets/{mindmap-definition-I2QAS2VK-Kqve1I-O.js → mindmap-definition-I2QAS2VK-B23-37oG.js} +1 -1
- package/dist/web/assets/{packet-JDAUHWVQ-qyS3G7IF.js → packet-JDAUHWVQ-X2dQ_Eu2.js} +1 -1
- package/dist/web/assets/{pdf-BF_OATTw.js → pdf-CtEIfYpr.js} +1 -1
- package/dist/web/assets/{pegDiagram-FD4XPPHP-CJjoxHP5.js → pegDiagram-FD4XPPHP-CBLpqVDg.js} +1 -1
- package/dist/web/assets/{pie-XZMESJXO-y6Ve6vA_.js → pie-XZMESJXO-B4pH97wX.js} +1 -1
- package/dist/web/assets/{pieDiagram-J4AKIIQI-C7sQNP9M.js → pieDiagram-J4AKIIQI-BYbYT8mA.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-XTYBLID2-CjJQ3Nsg.js → quadrantDiagram-XTYBLID2-BLmDIoG6.js} +1 -1
- package/dist/web/assets/{radar-ABXABTNO-B_S0YvT5.js → radar-ABXABTNO-CPYai8Hs.js} +1 -1
- package/dist/web/assets/{railroad-I3PHUGI6-CluEXdJX.js → railroad-I3PHUGI6-habfsre7.js} +1 -1
- package/dist/web/assets/{railroad-abnf-LNEFI6M7-CYz8PFAK.js → railroad-abnf-LNEFI6M7-BTbs0sYe.js} +1 -1
- package/dist/web/assets/{railroad-ebnf-DWYD2UWJ-k7u0H5uj.js → railroad-ebnf-DWYD2UWJ--6NtsCEl.js} +1 -1
- package/dist/web/assets/{railroad-peg-JR7BVNR7-C8R9pv1q.js → railroad-peg-JR7BVNR7-DbYSh0QY.js} +1 -1
- package/dist/web/assets/{railroadDiagram-MRQ6NCDL-Cqpn4-vP.js → railroadDiagram-MRQ6NCDL-DxFe5bXc.js} +1 -1
- package/dist/web/assets/{requirementDiagram-Y7LWUY3S-BelPC8qd.js → requirementDiagram-Y7LWUY3S-C4qUBGgN.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-WGJFYUXA-DaIN92Na.js → sankeyDiagram-WGJFYUXA-HrlriaRe.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-5NDRBG5M-Bu4bVJ0y.js → sequenceDiagram-5NDRBG5M-D3Q3gRP1.js} +1 -1
- package/dist/web/assets/{stateDiagram-v2-FJ4FJNEA-DfP7XqeH.js → stateDiagram-v2-FJ4FJNEA-TTiYX_ZR.js} +1 -1
- package/dist/web/assets/{swimlanes-UMQ2AFYF-eLMl9Ph9.js → swimlanes-UMQ2AFYF-DkskPoV5.js} +1 -1
- package/dist/web/assets/swimlanesDiagram-OMPLPG4O-9qbDHd1-.js +8 -0
- package/dist/web/assets/{timeline-definition-SEUHKTQE-Bq75bUFF.js → timeline-definition-SEUHKTQE-Vlv1oZRq.js} +1 -1
- package/dist/web/assets/{treeView-D4JQ5SDB-u9nQSLjY.js → treeView-D4JQ5SDB-ZZ1To3Lr.js} +1 -1
- package/dist/web/assets/{treemap-SAJKECNS-Cm7_rffJ.js → treemap-SAJKECNS-Dk_GWk1Y.js} +1 -1
- package/dist/web/assets/{usecaseDiagram-AFA6YXN4-BuDcLoKe.js → usecaseDiagram-AFA6YXN4-DA8bdS-1.js} +1 -1
- package/dist/web/assets/{vennDiagram-NNMJR3RB-BzbA4_BC.js → vennDiagram-NNMJR3RB-Vjin5r6v.js} +1 -1
- package/dist/web/assets/{wardley-7MLQ67FV-BDUXhKSc.js → wardley-7MLQ67FV-CN4QB_Wa.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-S7YFUSEH-DkfI-H0b.js → wardleyDiagram-S7YFUSEH-BEjuDndk.js} +1 -1
- package/dist/web/assets/{xychartDiagram-GGNKY7IX-Cmyg4oBd.js → xychartDiagram-GGNKY7IX-2mbCs8_j.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +2 -2
- package/dist/web/assets/flowDiagram-MALGAFMO-B6swKq_k.js +0 -1
- package/dist/web/assets/swimlanesDiagram-OMPLPG4O-DOMtbPJO.js +0 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-DFGL04am.js","assets/frame-BuvfWkjw.js","assets/mermaid.core-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-DFGL04am.js","assets/frame-BuvfWkjw.js","assets/mermaid.core-CpAENllk.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-B0SIfd8P.js","assets/chunk-BG4553SI-DcC06r4y.js","assets/chunk-DQASFODM-Chixat2J.js","assets/chunk-6MUBBAK2-B3aJt7CT.js","assets/dist-CRDUZiS0.js","assets/line-CbfhrdIu.js","assets/path-fybaL0A-.js","assets/array-BifhSqXX.js","assets/chunk-STOXU5M4-mJqMpVLN.js","assets/chunk-R3KSYZAL-Ddt2dlij.js","assets/chunk-X4PVCEUW-CMHSzz8J.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-AXFCVDMN-DD1zedxe.js","assets/chunk-J5ZVWO5B-oDCd-gWO.js","assets/chunk-LEVMRMFU-C9YzX_KN.js","assets/chunk-DUW6YSOI-Dgx8z5s3.js","assets/chunk-M57EVK23-jtiQOgis.js","assets/mermaidToImage-Br-3GSD4.js","assets/CodeEditor-D_pn0sQZ.js","assets/dist-7keixpik.js","assets/docxExport-So9p3lay.js","assets/loadReferencedImage-D0UnYJ_d.js","assets/conversationExport-Bz0O3u-1.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{a as e,c as t,d as n,f as r,g as i,m as a,n as o,p as s,s as c,t as l}from"./frame-BuvfWkjw.js";var u=s((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function ee(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function te(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var k=/\/+/g;function ne(e,t){return typeof e==`object`&&e&&e.key!=null?te(``+e.key):t.toString(36)}function A(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function re(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,re(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+ne(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(k,`$&/`)+`/`),re(o,r,i,``,function(e){return e})):o!=null&&(ee(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(k,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+ne(a,u),c+=re(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+ne(a,u++),c+=re(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return re(A(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function j(e,t,n){if(e==null)return e;var r=[],i=0;return re(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ie(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var ae=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function oe(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,ae)}catch(e){ae(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function se(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else oe(se.bind(null,e))}var ce={map:j,forEach:function(e,t,n){j(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return j(e,function(){t++}),t},toArray:function(e){return j(e,function(e){return e})||[]},only:function(e){if(!ee(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=ce,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=se,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return D(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)E.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=ee,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:ie}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=oe,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.1`})),d=s(((e,t)=>{t.exports=u()})),f=s((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&k(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&k(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var ee=new MessageChannel,te=ee.port2;ee.port1.onmessage=D,O=function(){te.postMessage(null)}}else O=function(){_(D,0)};function k(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,k(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),p=s(((e,t)=>{t.exports=f()})),m=s((e=>{var t=d();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.browser=function(e){return{$$typeof:o,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=u(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=u(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.1`})),h=s(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=m()})),g=s((e=>{var t=p(),n=d(),r=h();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}function m(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&m(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function g(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function _(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function v(e){var t=[null,null],n=g(e);return n===null||y(t,e,n.child,{foundSelf:!1}),t}function y(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&y(e,t,n.child,r))return!0;n=n.sibling}return!1}function b(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var x=null,S=null;function C(e,t,n){return e===n||e===t&&(x=e,!0)}function w(e,t,n){return e===n?(S=e,!1):e===t&&(S!==null&&(x=e),!0)}function T(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function E(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var D=Object.assign,O=Symbol.for(`react.element`),ee=Symbol.for(`react.transitional.element`),te=Symbol.for(`react.portal`),k=Symbol.for(`react.fragment`),ne=Symbol.for(`react.strict_mode`),A=Symbol.for(`react.profiler`),re=Symbol.for(`react.consumer`),j=Symbol.for(`react.context`),ie=Symbol.for(`react.forward_ref`),ae=Symbol.for(`react.suspense`),oe=Symbol.for(`react.suspense_list`),se=Symbol.for(`react.memo`),ce=Symbol.for(`react.lazy`),le=Symbol.for(`react.activity`),ue=Symbol.for(`react.legacy_hidden`),de=Symbol.for(`react.memo_cache_sentinel`),fe=Symbol.for(`react.view_transition`),M=Symbol.for(`react.recoverable`),pe=Symbol.iterator;function N(e){return typeof e!=`object`||!e?null:(e=pe&&e[pe]||e[`@@iterator`],typeof e==`function`?e:null)}var me=Symbol.for(`react.client.reference`);function he(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===me?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case k:return`Fragment`;case A:return`Profiler`;case ne:return`StrictMode`;case ae:return`Suspense`;case oe:return`SuspenseList`;case le:return`Activity`;case fe:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case te:return`Portal`;case j:return e.displayName||`Context`;case re:return(e._context.displayName||`Context`)+`.Consumer`;case ie:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case se:return t=e.displayName||null,t===null?he(e.type)||`Memo`:t;case ce:t=e._payload,e=e._init;try{return he(e(t))}catch{}}return null}var ge=Array.isArray,P=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_e=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ve={pending:!1,data:null,method:null,action:null},ye=[],be=-1;function xe(e){return{current:e}}function Se(e){0>be||(e.current=ye[be],ye[be]=null,be--)}function Ce(e,t){be++,ye[be]=e.current,e.current=t}var we=xe(null),Te=xe(null),Ee=xe(null),De=xe(null);function Oe(e,t){switch(Ce(Ee,t),Ce(Te,e),Ce(we,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?kp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=kp(t),e=Ap(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}Se(we),Ce(we,e)}function ke(){Se(we),Se(Te),Se(Ee)}function Ae(e){var t=e.memoizedState;t!==null&&(Eh._currentValue=t.memoizedState,Ce(De,e)),t=we.current;var n=Ap(t,e.type);t!==n&&(Ce(Te,e),Ce(we,n))}function je(e){Te.current===e&&(Se(we),Se(Te)),De.current===e&&(Se(De),Eh._currentValue=ve)}var Me,Ne;function Pe(e){if(Me===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Me=t&&t[1]||``,Ne=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+Me+e+Ne}var Fe=!1;function Ie(e,t){if(!e||Fe)return``;Fe=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
@@ -17,7 +17,7 @@ Error generating stack: `+e.message+`
|
|
|
17
17
|
`),n=Ie(t);if(n===-1)return;let r=t[n],i=/^(\s*)(flowchart|graph)([ \t]+(TD|TB|BT|LR|RL)\b)?(.*)$/i.exec(r);if(i!==null){let[,e,r,,a,o]=i,s=a===void 0?`TB`:Fe(a),c=Pe(s),l=[...t];return l[n]=`${e}${r} ${c}${o}`,{direction:s,turned:l.join(`
|
|
18
18
|
`)}}let a=/^(\s*)stateDiagram(-v2)?\s*$/i.exec(r);if(a!==null)return Re(t,n,a[1])}function Re(e,t,n){let r=0;for(let n=t+1;n<e.length;n+=1){let t=e[n],i=r===0?/^\s*direction\s+(TD|TB|BT|LR|RL)\s*$/i.exec(t):null;if(i!==null){let r=Fe(i[1]),a=[...e];return a[n]=t.replace(/(direction\s+)(TD|TB|BT|LR|RL)/i,`$1${Pe(r)}`),{direction:r,turned:a.join(`
|
|
19
19
|
`)}}r+=(t.match(/\{/g)?.length??0)-(t.match(/\}/g)?.length??0),r<0&&(r=0)}let i=[...e];return i.splice(t+1,0,`${n} direction LR`),{direction:`TB`,turned:i.join(`
|
|
20
|
-
`)}}var ze=Promise.resolve();function Be(e){let t=ze.then(e,e);return ze=t.then(()=>void 0,()=>void 0),t}var Ve=`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200 disabled:opacity-50`,He=`flex flex-wrap items-center gap-3 text-xs`,Ue=null;async function We(e){let t=await(Ue??=ye(()=>import(`./mermaid.core-ayA2pTNN.js`).then(e=>e.t),__vite__mapDeps([2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])));return t.default.initialize({startOnLoad:!1,theme:e,look:`classic`,securityLevel:`strict`,suppressErrorRendering:!0}),t}function Ge(e){let t=/viewBox="\s*[\d.-]+[\s,]+[\d.-]+[\s,]+([\d.]+)[\s,]+([\d.]+)/.exec(e),n=t?Number(t[1]):NaN;return Number.isFinite(n)&&n>0?n:void 0}function Ke(e,t){if(typeof e!=`object`||!e||!(`props`in e))return null;let n=e.props;if(t!==void 0&&!RegExp(`\\blanguage-${t}\\b`).test(n.className??``))return null;let r=n.children;return typeof r==`string`?r:Array.isArray(r)&&r.every(e=>typeof e==`string`)?r.join(``):null}function qe(e){let t=Ke(e,`mermaid`);return t===null?null:t.trim()}function Je(e){let{children:t,...n}=e,r=qe(t);if(r!==null)return(0,N.jsx)(Ye,{code:r});let i=Ke(t);return i===null?(0,N.jsx)(`pre`,{...n,children:t}):(0,N.jsxs)(`div`,{className:`code-block relative`,"data-testid":`code-block`,children:[(0,N.jsx)(`pre`,{...n,children:t}),(0,N.jsx)(me,{iconOnly:!0,text:i.replace(/\n$/,``),className:`absolute right-1.5 top-1.5 rounded border border-zinc-300 bg-white/80 px-1.5 py-0.5 text-xs text-zinc-500 hover:text-zinc-800 dark:border-zinc-700 dark:bg-zinc-900/80 dark:text-zinc-400 dark:hover:text-zinc-100`})]})}function Ye({code:e}){let t=(0,v.useId)().replace(/[^a-zA-Z0-9]/g,``),n=x()===`light`?`default`:`dark`,[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)(null),h=(0,v.useRef)(!1),g=(0,v.useRef)(0),_=(0,v.useRef)(0),y=()=>`mermaid-${t}-${++_.current}`,b=(0,v.useMemo)(()=>Le(e),[e]),S=b===void 0?`landscape`:Ne(b.direction),[C,w]=(0,v.useState)(void 0),T=r?.svg??null,E=r!==null&&r.orientation!==S,D=(0,v.useRef)(null),O=(0,v.useRef)(e);O.current=e,(0,v.useEffect)(()=>(g.current+=1,i(null),w(void 0),u(!1),o(null),m(null),()=>{g.current+=1}),[e]);async function ee(){if(!r||h.current)return;h.current=!0,f(!0),m(null);let e=g.current;try{let{renderDiagram:n}=await ye(async()=>{let{renderDiagram:e}=await import(`./mermaidToImage-CNBBVbXG.js`).then(e=>e.r);return{renderDiagram:e}},__vite__mapDeps([21,1])),i=await n(r.source,`mermaid-download-${t}`);if(e!==g.current)return;let a=URL.createObjectURL(new Blob([i.svg],{type:`image/svg+xml;charset=utf-8`}));try{let e=document.createElement(`a`);e.href=a,e.download=`diagram.svg`,e.click()}finally{URL.revokeObjectURL(a)}}catch(t){e===g.current&&m(t instanceof Error?t.message:String(t))}finally{h.current=!1,f(!1)}}return(0,v.useEffect)(()=>{let e=!1,t=setTimeout(()=>void Be(async()=>{try{let t=(await We(n)).default,r=O.current,a=Le(r),s=a===void 0?`landscape`:Ne(a.direction);if(C!==void 0&&a!==void 0){let n=C===s?r:a.turned,{svg:c}=await t.render(y(),n);e||(i({svg:c,orientation:C,source:n}),o(null));return}let c=await t.render(y(),r),l={svg:c.svg,orientation:s,source:r},u=Ge(c.svg);if(a!==void 0&&u!==void 0&&u>710){let e=await t.render(y(),a.turned),n=Ge(e.svg);if(n!==void 0){let t=s===`landscape`?je(u,n):je(n,u);t!==s&&(l={svg:e.svg,orientation:t,source:a.turned})}}e||(i(l),o(null))}catch(t){e||(i(null),o(t instanceof Error?t.message:String(t)))}}),300);return()=>{e=!0,clearTimeout(t)}},[e,t,n,C]),T?(0,N.jsxs)(`div`,{ref:D,className:`my-2 flex flex-col gap-2 rounded-lg border border-zinc-200 bg-zinc-50 p-3 dark:border-zinc-800 dark:bg-zinc-900`,children:[(0,N.jsxs)(`div`,{className:`${He} order-3`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>c(!s),title:s?`Show diagram`:`Show code`,className:Ve,children:s?`⚏ diagram`:`⌗ code`}),!s&&b!==void 0&&r!==null&&(0,N.jsx)(`button`,{type:`button`,"data-testid":`mermaid-orientation`,onClick:()=>w(e=>Ae(e??r.orientation)),title:r.orientation===`portrait`?`Turn it across the page — it is drawn down`:`Turn it down the page — it is drawn across`,"aria-label":`Turn the diagram ${Ae(r.orientation)}`,className:`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200 disabled:opacity-50`,children:r.orientation===`portrait`?`↔ landscape`:`↕ portrait`}),!s&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>u(!0),"aria-label":`Show diagram at full size`,className:`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200 disabled:opacity-50`,children:`⤢ enlarge`}),(0,N.jsx)(`button`,{type:`button`,className:Ve,disabled:d,onClick:()=>void ee(),title:`Save as .svg — insert it as a picture in a document`,children:d?`preparing SVG…`:`⤓ download SVG`}),(0,N.jsx)(me,{text:e,className:Ve}),p&&(0,N.jsxs)(`span`,{role:`alert`,className:`text-red-600 dark:text-red-400`,children:[`Could not download SVG: `,p]})]}),s?(0,N.jsx)(`pre`,{className:`overflow-x-auto font-mono text-xs text-zinc-500 dark:text-zinc-400`,children:e}):(0,N.jsx)(`div`,{className:`flex justify-center overflow-x-auto [&_svg]:max-w-full`,dangerouslySetInnerHTML:{__html:T}}),E&&!s&&(0,N.jsxs)(`div`,{className:`mt-1 text-center text-xs text-zinc-400 dark:text-zinc-600`,"data-testid":`mermaid-turned`,children:[`drawn `,r?.orientation,` to fit — the source asks for `,S]}),(0,N.jsx)(Oe,{label:`diagram`,testId:`mermaid-enlarged`,open:l,onClose:()=>u(!1),anchorRef:D,actions:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`button`,{type:`button`,className:Ve,disabled:d,onClick:()=>void ee(),children:d?`preparing SVG…`:`⤓ download SVG`}),p&&(0,N.jsxs)(`span`,{role:`alert`,className:`text-red-600 dark:text-red-400`,children:[`Could not download SVG: `,p]})]}),children:(0,N.jsx)(`div`,{style:{width:Ge(T)},className:`[&_svg]:!h-auto [&_svg]:!max-w-none [&_svg]:!w-full`,dangerouslySetInnerHTML:{__html:T}})})]}):(0,N.jsxs)(`pre`,{className:`my-2 overflow-x-auto rounded-lg border border-zinc-200 bg-zinc-50 p-3 font-mono text-xs text-zinc-500 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-400`,children:[e,a&&(0,N.jsx)(`div`,{className:`mt-2 text-red-600 dark:text-red-400`,children:a})]})}function Xe({html:e,className:t=``,as:n=`div`}){return(0,N.jsx)(n,{className:`rendered-ansi overflow-x-auto font-mono text-xs leading-relaxed [&_span]:whitespace-pre-wrap ${t}`,dangerouslySetInnerHTML:{__html:e}})}function Ze({lines:e,fill:t=!1}){return(0,N.jsx)(`div`,{className:`overflow-auto rounded border border-zinc-200 font-mono text-xs leading-relaxed dark:border-zinc-800 ${t?`max-h-full`:`max-h-72`}`,children:k(te(e)).map((e,t)=>e===null?(0,N.jsx)(`div`,{className:`bg-zinc-100 px-2 text-center text-zinc-400 dark:bg-zinc-800/60 dark:text-zinc-600`,children:`⋯`},t):(0,N.jsxs)(`div`,{className:`grid grid-cols-2`,children:[(0,N.jsx)(`div`,{className:`whitespace-pre-wrap break-words border-r border-zinc-200 px-2 dark:border-zinc-800 ${e.changed?e.left===null?`bg-zinc-50 dark:bg-zinc-900/40`:`bg-red-50 text-red-700 dark:bg-red-950/40 dark:text-red-300`:`text-zinc-500 dark:text-zinc-500`}`,children:e.left??` `}),(0,N.jsx)(`div`,{className:`whitespace-pre-wrap break-words px-2 ${e.changed?e.right===null?`bg-zinc-50 dark:bg-zinc-900/40`:`bg-emerald-50 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-300`:`text-zinc-500 dark:text-zinc-500`}`,children:e.right??` `})]},t))})}function Qe({lines:e}){return(0,N.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded border border-zinc-200 font-mono text-xs leading-relaxed dark:border-zinc-800`,children:ne(e).map((e,t)=>e===null?(0,N.jsx)(`div`,{className:`bg-zinc-100 px-2 text-center text-zinc-400 dark:bg-zinc-800/60 dark:text-zinc-600`,children:`⋯`},t):(0,N.jsxs)(`div`,{className:e.type===`add`?`bg-emerald-50 px-2 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-300`:e.type===`del`?`bg-red-50 px-2 text-red-700 dark:bg-red-950/40 dark:text-red-300`:`px-2 text-zinc-500 dark:text-zinc-500`,children:[e.type===`add`?`+ `:e.type===`del`?`− `:` `,e.text]},t))})}function $e({item:e,canEdit:t,onEdit:n,queued:r}){let[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(!1),c=(0,v.useRef)(null),l=t&&e.entryId!==void 0&&!o,u=i!==null;(0,v.useEffect)(()=>{u&&c.current?.focus()},[u]),(0,v.useEffect)(()=>{if(!o)return;let e=setTimeout(()=>s(!1),3e3);return()=>clearTimeout(e)},[o]);let d=r?.onDraftChange;(0,v.useEffect)(()=>{d?.(i)},[i,d]),(0,v.useEffect)(()=>{a(null)},[e.entryId,e.text]);function f(){let r=i?.trim();t&&e.entryId&&r&&(r===e.text||n(e.entryId,r,e.images),a(null))}let p=`mt-1.5 shrink-0 rounded px-1 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-500 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`;return(0,N.jsxs)(`div`,{className:`group ml-auto flex max-w-[85%] items-start gap-1.5`,...r?{"data-queued-prompt":e.entryId}:{},children:[l&&!u&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>a(e.text),title:r?`edit this queued message — the agent has not read it yet`:`edit this prompt and ask again (branches the conversation)`,"aria-label":r?`Edit this queued message`:`Edit this prompt`,className:p,children:`✎`}),r&&l&&!u&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>{s(!0),r.onRemove()},title:`remove this queued message — the agent will not read it`,"aria-label":`Remove this queued message`,className:p,children:`✕`}),(0,N.jsxs)(`div`,{className:r&&!u?`min-w-0 flex-1 rounded-xl bg-blue-50 px-4 py-2 text-[15px] text-blue-950/70 dark:bg-blue-950/25 dark:text-zinc-400`:`min-w-0 flex-1 rounded-xl bg-blue-100 px-4 py-2 text-[15px] text-blue-950 dark:bg-blue-950/60 dark:text-zinc-100`,...r&&!u?{title:`queued — the agent has not read it yet`}:{},children:[r&&!u&&(0,N.jsx)(`span`,{className:`sr-only`,children:`queued — not read yet`}),e.images&&e.images.length>0&&(0,N.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:e.images.map((e,t)=>(0,N.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:``,className:`max-h-48 max-w-full rounded-lg object-contain`},t))}),u?(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`textarea`,{ref:c,value:i,"aria-label":`Edit prompt`,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),f()),e.key===`Escape`&&a(null)},rows:Math.min(10,Math.max(2,i.split(`
|
|
20
|
+
`)}}var ze=Promise.resolve();function Be(e){let t=ze.then(e,e);return ze=t.then(()=>void 0,()=>void 0),t}var Ve=`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200 disabled:opacity-50`,He=`flex flex-wrap items-center gap-3 text-xs`,Ue=null;async function We(e){let t=await(Ue??=ye(()=>import(`./mermaid.core-CpAENllk.js`).then(e=>e.t),__vite__mapDeps([2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])));return t.default.initialize({startOnLoad:!1,theme:e,look:`classic`,securityLevel:`strict`,suppressErrorRendering:!0}),t}function Ge(e){let t=/viewBox="\s*[\d.-]+[\s,]+[\d.-]+[\s,]+([\d.]+)[\s,]+([\d.]+)/.exec(e),n=t?Number(t[1]):NaN;return Number.isFinite(n)&&n>0?n:void 0}function Ke(e,t){if(typeof e!=`object`||!e||!(`props`in e))return null;let n=e.props;if(t!==void 0&&!RegExp(`\\blanguage-${t}\\b`).test(n.className??``))return null;let r=n.children;return typeof r==`string`?r:Array.isArray(r)&&r.every(e=>typeof e==`string`)?r.join(``):null}function qe(e){let t=Ke(e,`mermaid`);return t===null?null:t.trim()}function Je(e){let{children:t,...n}=e,r=qe(t);if(r!==null)return(0,N.jsx)(Ye,{code:r});let i=Ke(t);return i===null?(0,N.jsx)(`pre`,{...n,children:t}):(0,N.jsxs)(`div`,{className:`code-block relative`,"data-testid":`code-block`,children:[(0,N.jsx)(`pre`,{...n,children:t}),(0,N.jsx)(me,{iconOnly:!0,text:i.replace(/\n$/,``),className:`absolute right-1.5 top-1.5 rounded border border-zinc-300 bg-white/80 px-1.5 py-0.5 text-xs text-zinc-500 hover:text-zinc-800 dark:border-zinc-700 dark:bg-zinc-900/80 dark:text-zinc-400 dark:hover:text-zinc-100`})]})}function Ye({code:e}){let t=(0,v.useId)().replace(/[^a-zA-Z0-9]/g,``),n=x()===`light`?`default`:`dark`,[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)(null),h=(0,v.useRef)(!1),g=(0,v.useRef)(0),_=(0,v.useRef)(0),y=()=>`mermaid-${t}-${++_.current}`,b=(0,v.useMemo)(()=>Le(e),[e]),S=b===void 0?`landscape`:Ne(b.direction),[C,w]=(0,v.useState)(void 0),T=r?.svg??null,E=r!==null&&r.orientation!==S,D=(0,v.useRef)(null),O=(0,v.useRef)(e);O.current=e,(0,v.useEffect)(()=>(g.current+=1,i(null),w(void 0),u(!1),o(null),m(null),()=>{g.current+=1}),[e]);async function ee(){if(!r||h.current)return;h.current=!0,f(!0),m(null);let e=g.current;try{let{renderDiagram:n}=await ye(async()=>{let{renderDiagram:e}=await import(`./mermaidToImage-Br-3GSD4.js`).then(e=>e.r);return{renderDiagram:e}},__vite__mapDeps([21,1])),i=await n(r.source,`mermaid-download-${t}`);if(e!==g.current)return;let a=URL.createObjectURL(new Blob([i.svg],{type:`image/svg+xml;charset=utf-8`}));try{let e=document.createElement(`a`);e.href=a,e.download=`diagram.svg`,e.click()}finally{URL.revokeObjectURL(a)}}catch(t){e===g.current&&m(t instanceof Error?t.message:String(t))}finally{h.current=!1,f(!1)}}return(0,v.useEffect)(()=>{let e=!1,t=setTimeout(()=>void Be(async()=>{try{let t=(await We(n)).default,r=O.current,a=Le(r),s=a===void 0?`landscape`:Ne(a.direction);if(C!==void 0&&a!==void 0){let n=C===s?r:a.turned,{svg:c}=await t.render(y(),n);e||(i({svg:c,orientation:C,source:n}),o(null));return}let c=await t.render(y(),r),l={svg:c.svg,orientation:s,source:r},u=Ge(c.svg);if(a!==void 0&&u!==void 0&&u>710){let e=await t.render(y(),a.turned),n=Ge(e.svg);if(n!==void 0){let t=s===`landscape`?je(u,n):je(n,u);t!==s&&(l={svg:e.svg,orientation:t,source:a.turned})}}e||(i(l),o(null))}catch(t){e||(i(null),o(t instanceof Error?t.message:String(t)))}}),300);return()=>{e=!0,clearTimeout(t)}},[e,t,n,C]),T?(0,N.jsxs)(`div`,{ref:D,className:`my-2 flex flex-col gap-2 rounded-lg border border-zinc-200 bg-zinc-50 p-3 dark:border-zinc-800 dark:bg-zinc-900`,children:[(0,N.jsxs)(`div`,{className:`${He} order-3`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>c(!s),title:s?`Show diagram`:`Show code`,className:Ve,children:s?`⚏ diagram`:`⌗ code`}),!s&&b!==void 0&&r!==null&&(0,N.jsx)(`button`,{type:`button`,"data-testid":`mermaid-orientation`,onClick:()=>w(e=>Ae(e??r.orientation)),title:r.orientation===`portrait`?`Turn it across the page — it is drawn down`:`Turn it down the page — it is drawn across`,"aria-label":`Turn the diagram ${Ae(r.orientation)}`,className:`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200 disabled:opacity-50`,children:r.orientation===`portrait`?`↔ landscape`:`↕ portrait`}),!s&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>u(!0),"aria-label":`Show diagram at full size`,className:`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200 disabled:opacity-50`,children:`⤢ enlarge`}),(0,N.jsx)(`button`,{type:`button`,className:Ve,disabled:d,onClick:()=>void ee(),title:`Save as .svg — insert it as a picture in a document`,children:d?`preparing SVG…`:`⤓ download SVG`}),(0,N.jsx)(me,{text:e,className:Ve}),p&&(0,N.jsxs)(`span`,{role:`alert`,className:`text-red-600 dark:text-red-400`,children:[`Could not download SVG: `,p]})]}),s?(0,N.jsx)(`pre`,{className:`overflow-x-auto font-mono text-xs text-zinc-500 dark:text-zinc-400`,children:e}):(0,N.jsx)(`div`,{className:`flex justify-center overflow-x-auto [&_svg]:max-w-full`,dangerouslySetInnerHTML:{__html:T}}),E&&!s&&(0,N.jsxs)(`div`,{className:`mt-1 text-center text-xs text-zinc-400 dark:text-zinc-600`,"data-testid":`mermaid-turned`,children:[`drawn `,r?.orientation,` to fit — the source asks for `,S]}),(0,N.jsx)(Oe,{label:`diagram`,testId:`mermaid-enlarged`,open:l,onClose:()=>u(!1),anchorRef:D,actions:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`button`,{type:`button`,className:Ve,disabled:d,onClick:()=>void ee(),children:d?`preparing SVG…`:`⤓ download SVG`}),p&&(0,N.jsxs)(`span`,{role:`alert`,className:`text-red-600 dark:text-red-400`,children:[`Could not download SVG: `,p]})]}),children:(0,N.jsx)(`div`,{style:{width:Ge(T)},className:`[&_svg]:!h-auto [&_svg]:!max-w-none [&_svg]:!w-full`,dangerouslySetInnerHTML:{__html:T}})})]}):(0,N.jsxs)(`pre`,{className:`my-2 overflow-x-auto rounded-lg border border-zinc-200 bg-zinc-50 p-3 font-mono text-xs text-zinc-500 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-400`,children:[e,a&&(0,N.jsx)(`div`,{className:`mt-2 text-red-600 dark:text-red-400`,children:a})]})}function Xe({html:e,className:t=``,as:n=`div`}){return(0,N.jsx)(n,{className:`rendered-ansi overflow-x-auto font-mono text-xs leading-relaxed [&_span]:whitespace-pre-wrap ${t}`,dangerouslySetInnerHTML:{__html:e}})}function Ze({lines:e,fill:t=!1}){return(0,N.jsx)(`div`,{className:`overflow-auto rounded border border-zinc-200 font-mono text-xs leading-relaxed dark:border-zinc-800 ${t?`max-h-full`:`max-h-72`}`,children:k(te(e)).map((e,t)=>e===null?(0,N.jsx)(`div`,{className:`bg-zinc-100 px-2 text-center text-zinc-400 dark:bg-zinc-800/60 dark:text-zinc-600`,children:`⋯`},t):(0,N.jsxs)(`div`,{className:`grid grid-cols-2`,children:[(0,N.jsx)(`div`,{className:`whitespace-pre-wrap break-words border-r border-zinc-200 px-2 dark:border-zinc-800 ${e.changed?e.left===null?`bg-zinc-50 dark:bg-zinc-900/40`:`bg-red-50 text-red-700 dark:bg-red-950/40 dark:text-red-300`:`text-zinc-500 dark:text-zinc-500`}`,children:e.left??` `}),(0,N.jsx)(`div`,{className:`whitespace-pre-wrap break-words px-2 ${e.changed?e.right===null?`bg-zinc-50 dark:bg-zinc-900/40`:`bg-emerald-50 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-300`:`text-zinc-500 dark:text-zinc-500`}`,children:e.right??` `})]},t))})}function Qe({lines:e}){return(0,N.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded border border-zinc-200 font-mono text-xs leading-relaxed dark:border-zinc-800`,children:ne(e).map((e,t)=>e===null?(0,N.jsx)(`div`,{className:`bg-zinc-100 px-2 text-center text-zinc-400 dark:bg-zinc-800/60 dark:text-zinc-600`,children:`⋯`},t):(0,N.jsxs)(`div`,{className:e.type===`add`?`bg-emerald-50 px-2 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-300`:e.type===`del`?`bg-red-50 px-2 text-red-700 dark:bg-red-950/40 dark:text-red-300`:`px-2 text-zinc-500 dark:text-zinc-500`,children:[e.type===`add`?`+ `:e.type===`del`?`− `:` `,e.text]},t))})}function $e({item:e,canEdit:t,onEdit:n,queued:r}){let[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(!1),c=(0,v.useRef)(null),l=t&&e.entryId!==void 0&&!o,u=i!==null;(0,v.useEffect)(()=>{u&&c.current?.focus()},[u]),(0,v.useEffect)(()=>{if(!o)return;let e=setTimeout(()=>s(!1),3e3);return()=>clearTimeout(e)},[o]);let d=r?.onDraftChange;(0,v.useEffect)(()=>{d?.(i)},[i,d]),(0,v.useEffect)(()=>{a(null)},[e.entryId,e.text]);function f(){let r=i?.trim();t&&e.entryId&&r&&(r===e.text||n(e.entryId,r,e.images),a(null))}let p=`mt-1.5 shrink-0 rounded px-1 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-500 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`;return(0,N.jsxs)(`div`,{className:`group ml-auto flex max-w-[85%] items-start gap-1.5`,...r?{"data-queued-prompt":e.entryId}:{},children:[l&&!u&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>a(e.text),title:r?`edit this queued message — the agent has not read it yet`:`edit this prompt and ask again (branches the conversation)`,"aria-label":r?`Edit this queued message`:`Edit this prompt`,className:p,children:`✎`}),r&&l&&!u&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>{s(!0),r.onRemove()},title:`remove this queued message — the agent will not read it`,"aria-label":`Remove this queued message`,className:p,children:`✕`}),(0,N.jsxs)(`div`,{className:r&&!u?`min-w-0 flex-1 rounded-xl bg-blue-50 px-4 py-2 text-[15px] text-blue-950/70 dark:bg-blue-950/25 dark:text-zinc-400`:`min-w-0 flex-1 rounded-xl bg-blue-100 px-4 py-2 text-[15px] text-blue-950 dark:bg-blue-950/60 dark:text-zinc-100`,...r&&!u?{title:`queued — the agent has not read it yet`}:{},children:[r&&!u&&(0,N.jsx)(`span`,{className:`sr-only`,children:`queued — not read yet`}),e.images&&e.images.length>0&&(0,N.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:e.images.map((e,t)=>(0,N.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:``,className:`max-h-48 max-w-full rounded-lg object-contain`},t))}),u?(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`textarea`,{ref:c,value:i,"aria-label":`Edit prompt`,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),f()),e.key===`Escape`&&a(null)},rows:Math.min(10,Math.max(2,i.split(`
|
|
21
21
|
`).length)),className:`w-full resize-none rounded-md bg-white/70 px-2 py-1 text-[15px] outline-none ring-1 ring-blue-300 dark:bg-zinc-900/60 dark:ring-blue-900`}),(0,N.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-end gap-2 text-xs`,children:[(0,N.jsx)(`span`,{className:`mr-auto text-blue-900/70 dark:text-zinc-400`,children:r?t?`replaces the queued message — the agent has not read it yet`:`waiting: the connection dropped`:t?`asks again from here — the current answer moves to its own branch`:`waiting: the agent is running (or the connection dropped)`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>a(null),className:`rounded border border-blue-300 px-2 py-0.5 hover:bg-white/60 dark:border-zinc-700 dark:hover:bg-zinc-800`,children:`cancel`}),(0,N.jsx)(`button`,{type:`button`,onClick:f,disabled:!t||!i.trim()||i.trim()===e.text,className:`rounded border border-blue-400 bg-white/70 px-2 py-0.5 font-medium disabled:opacity-50 dark:border-blue-800 dark:bg-zinc-900/60`,children:r?`save`:`send`})]})]}):(0,N.jsx)(`div`,{className:`whitespace-pre-wrap`,children:e.text})]})]})}var et=`urn:structured-exchange:1`,tt=[`graph`,`sequence`];function nt(e){return rt(e)?[`graph`,`sequence`,`table`]:tt}function rt(e){return e===`urn:structured-exchange:2`||e===`urn:structured-exchange:3`}function it(e){if(Array.isArray(e))return{cells:e};let t=e.heading;return typeof t==`string`?{cells:[],role:e.role,heading:t}:{cells:e.cells,role:e.role}}var at={nodes:500,edges:2e3,participants:100,messages:1e3,columns:50,rows:5e3,removals:500,ref:200,localId:200,label:500,kind:100,kindsPerVocabulary:64,columnName:200,cell:1e3},ot=`urn:structured-exchange:2`,st={profile:200,attributesPerItem:50,removeAttributesPerItem:50,attributeName:200,attributeString:1e3,attributeListItems:50,revision:200,locationsPerItem:10,uri:2e3,position:1e6,artifactsPerItem:20,artifactsPerDocument:50,artifactRel:100,artifactMediaType:100,artifactLabel:500,artifactDigest:71,relations:2e3,heading:500,headingDepth:6,viewpoints:20,viewpointConcern:500},ct=8e6,lt=`urn:structured-exchange:3`,ut=[et,ot,lt];function dt(e){return ut.find(t=>t===e)}var ft=4e6,pt=Math.max(ft,ct);function mt(e){return rt(e)?ct:ft}var ht=e=>new TextEncoder().encode(e).length;function gt(e){return e===`bytes`?pt:e===`relations`?st.relations:at[e]}function _t(e,t){let n=gt(e),r=t?.[e];return r===void 0||r>=n?{limit:n,level:`ceiling`}:{limit:r,level:`deployment`}}function vt(e,t,n){let r=ht(e),i=_t(`bytes`,t),a=n===void 0?1/0:mt(n),o=Math.min(i.limit,a),s=o===a&&a<i.limit?`ceiling`:i.level;if(!(r<=o))return{rule:`document-too-large`,path:``,message:`document is ${r} bytes, past the ${o}-byte ${s===`ceiling`?`contract ceiling`:`limit this deployment applies`}`,limit:o,observed:r,level:s}}var yt={graph:[`nodes`,`edges`],sequence:[`participants`,`messages`],table:[`columns`,`rows`,`relations`]};function bt(e,t){if(t===void 0)return[];let n=[];for(let r of yt[e.kind]??[]){let i=e.data[r];if(!Array.isArray(i))continue;let{limit:a,level:o}=_t(r,t);o===`deployment`&&i.length>a&&n.push({rule:`collection-past-deployment-limit`,path:`/data/${r}`,message:`${r} has ${i.length} entries, past the ${a} this deployment allows`,limit:a,observed:i.length,level:o})}return n}function xt(e,t){let n={};for(let t of yt[e.kind]??[]){let r=e.data[t];Array.isArray(r)&&(n[t]=r.length)}return{kind:e.kind,bytes:ht(t),counts:n}}var St=6.6,Ct=5.4;function wt(e,t,n){let r=e.flatMap(e=>e.split(/\r?\n/)).reduce((e,t)=>Math.max(e,t.length),0);return Math.min(Math.max(r*St+22,t),n)}function Tt(e,t,n,r){let i=t.map(e=>kt(e).length).reduce((e,t)=>Math.max(e,t),0);return Math.max(wt(e,n,r),Math.min(i*Ct+22,r))}function Et(e,t,n=St){let r=Math.max(Math.floor((t-22)/n+1e-6),4),i=[],a=e.split(/\r?\n/);if(a.length>1)return a.flatMap(e=>Et(e,t,n)).slice(0,3);let o=``;for(let t of e.split(/\s+/)){let e=o===``?t:`${o} ${t}`;if(e.length<=r)o=e;else for(o!==``&&i.push(o),o=t;o.length>r&&i.length<3;)i.push(o.slice(0,r)),o=o.slice(r)}if(o!==``&&i.push(o),i.length===0)return[``];if(i.length<=3)return i;let s=i.slice(0,3);return s[2]=`${s[2].slice(0,Math.max(r-1,1))}…`,s}function Dt(e,t){return e*15+t*15+14}function Ot(e,t){return e.flatMap(e=>Et(kt(e),t,Ct))}function kt(e){return`${e.field}: ${e.from===void 0?``:`${e.from} → `}${e.to}`}function At(e,t){return`${e}: ${jt(t)}`}function jt(e){return Array.isArray(e)?e.map(e=>jt(e)).join(`, `):e===null?`null`:typeof e==`object`&&e&&typeof e.ref==`string`?`<${e.ref}>`:String(e)}function Mt(e){let t=e.range===void 0?``:` lines ${e.range.startLine}–${e.range.endLine}`,n=e.revision===void 0?``:` at ${e.revision}`;return`${e.uri}${t}${n}`}function Nt(e){let t=e.label===void 0?e.uri:`${e.label} (${e.uri})`,n=e.mediaType===void 0?``:`, ${e.mediaType}`;return`${e.rel}: ${t}${n} — ${e.sha256.slice(0,14)}…`}var Pt=864e5,Ft=/^(\d{4})-(\d{2})-(\d{2})$/;function It(e){let t=Ft.exec(e);if(t===null)return;let[n,r,i]=[Number(t[1]),Number(t[2]),Number(t[3])],a=new Date(Date.UTC(n,r-1,i));if(a.setUTCFullYear(n,r-1,i),a.getUTCFullYear()===n&&a.getUTCMonth()===r-1&&a.getUTCDate()===i)return Math.round(a.getTime()/Pt)}function Lt(e){let t=new Date(e*Pt);return`${String(t.getUTCFullYear()).padStart(4,`0`)}-${String(t.getUTCMonth()+1).padStart(2,`0`)}-${String(t.getUTCDate()).padStart(2,`0`)}`}function Rt(e=new Date){return Math.round(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())/Pt)}function zt(e){let t=It(e.type===`activity`?e.start:e.date),n=It(e.type===`activity`?e.end:e.date);return t===void 0||n===void 0?void 0:{start:t,end:n}}function Bt(e){let t=new Map;return e.rows.forEach((e,n)=>{e.type===`task`&&(t.has(e.id)||t.set(e.id,{id:e.id,type:`task`,row:n,days:Vt(e)}),e.items.forEach((e,r)=>{e.id===void 0||t.has(e.id)||t.set(e.id,{id:e.id,type:e.type,row:n,item:r,days:zt(e)})}))}),t}function Vt(e){let t;for(let n of e.items){let e=zt(n);e!==void 0&&(t=t===void 0?{...e}:{start:Math.min(t.start,e.start),end:Math.max(t.end,e.end)})}return t}function Ht(e){return e.type??`finish-to-start`}function Ut(e){return{from:e.startsWith(`finish`)?`end`:`start`,to:e.endsWith(`finish`)?`end`:`start`}}function Wt(e,t){let n=t.get(e.from)?.days,r=t.get(e.to)?.days;if(n===void 0||r===void 0)return;let i=Ut(Ht(e));return r[i.to]>=n[i.from]}function Gt(e){if(`date`in e){let t=It(e.date)??0;return{start:t,end:t}}return{start:It(e.start)??0,end:It(e.end)??0}}function Kt(e){if(e.previous===void 0)return;let t=Gt(e.type===`activity`?{start:e.start,end:e.end}:{date:e.date}),n=Gt(e.previous);return{start:t.start-n.start,end:t.end-n.end}}function qt(e){if(e===0)return``;let t=e>0?`+`:`−`,n=Math.abs(e);return n<14?`${t}${n}d`:n<70?`${t}${Math.round(n/7)}w`:`${t}${Math.round(n/30.44)}mo`}function Jt(e){let t=Kt(e);return t===void 0?``:t.start===t.end?qt(t.start):t.start===0?`end${qt(t.end)}`:t.end===0?`start${qt(t.start)}`:`${qt(t.start)}, end${qt(t.end)}`}function Yt(e,t){if(e.role!==void 0||t?.role!==void 0)return!0;let n=Kt(e);return n!==void 0&&(n.start!==0||n.end!==0)}function Xt(e){return e.role!==void 0||e.items.some(t=>Yt(t,e))}var Zt={week:12,month:4,quarter:.75};function Qt(e,t){let n=e>=8?`week`:e>=1?`month`:`quarter`;if(t===void 0)return n;let r=[`week`,`month`,`quarter`];return r[Math.max(r.indexOf(n),r.indexOf(t))]}var $t=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function en(e){return e.width>=24?e.label:e.width>=9?e.label.charAt(0):``}function tn(e,t){return t===`month`?en(e):e.width>=e.label.length*6+4?e.label:``}function nn(e){return((e+3)%7+7)%7}function rn(e){let t=e-nn(e)+3,n=new Date(t*Pt).getUTCFullYear();return Math.floor((t-cn(n,0))/7)+1}function an(e){if(e.label!==void 0&&e.label!==``)return e.label;if(e.type===`milestone`&&e.kind!==void 0&&e.kind!==``)return e.kind}function on(e){return e.length*St}function sn(e,t){let n=new Date(e*Pt),r=n.getUTCFullYear(),i=n.getUTCMonth(),a=[];for(;;){i+=1,i===12&&(i=0,r+=1);let e=cn(r,i);if(e>t)return a;a.push({day:e,year:r,month:i})}}function cn(e,t){let n=new Date(0);return n.setUTCFullYear(e,t,1),Math.round(n.getTime()/Pt)}function ln(e,t){let n=e=>e===`bar`||e===`ghost`;return n(e)&&t===`star`||e===`star`&&n(t)}function un(e,t){return e.x0<t.x1&&t.x0<e.x1}function dn(e,t){if(t<=0||e.width<=t)return;let n=e.items.filter(e=>e.change!==void 0);if(n.length>0){let e=Math.min(...n.flatMap(e=>e.ghost===void 0?[e.glyph.x]:[e.glyph.x,e.ghost.x]));return e<t*.9?void 0:Math.max(0,e-t/6)}if(`x`in e.today&&e.today.x>t*.8)return Math.max(0,e.today.x-t/3)}function fn(e,t,n={}){let r=It(e.time.start)??0,i=It(e.time.end)??r,a=n.pxPerDay??Zt[e.time.scale]??4,o=(i-r+1)*a,s=e=>(e-r)*a,c=sn(r,i),l=new Date(r*Pt),u=[{day:r,year:l.getUTCFullYear(),month:l.getUTCMonth()},...c],d=u.map((e,t)=>{let n=t+1<u.length?u[t+1].day:i+1;return{label:$t[e.month],x:s(e.day),width:(n-e.day)*a,year:e.year,month:e.month}}),f=[];u.forEach((e,t)=>{let n=d[t],r=f[f.length-1];r!==void 0&&r.label===String(e.year)?r.width+=n.width:f.push({label:String(e.year),x:n.x,width:n.width})});let p=Qt(a,n.unit),m=(e,t)=>e.map((n,r)=>{let o=r+1<e.length?e[r+1]:i+1;return{label:t(n),x:s(n),width:(o-n)*a}}),h=f,g;if(p===`week`){let e=[];for(let t=r-nn(r)+7;t<=i;t+=7)e.push(t);g=m([r,...e],e=>`W${rn(e)}`),h=d.map(e=>({label:`${e.label} ${e.year}`,x:e.x,width:e.width}))}else if(p===`quarter`){let e=u.filter((e,t)=>t===0||e.month%3==0);g=e.map((t,n)=>{let r=n+1<e.length?e[n+1].day:i+1;return{label:`Q${Math.floor(t.month/3)+1}`,x:s(t.day),width:(r-t.day)*a}})}else g=d;let _=g.slice(1).map(e=>e.x),v=[],y=[],b=0,x=e.comparedTo!==void 0,S=(e,t)=>{if(!x)return;if(e.role===`added`||t.role===`added`)return`(new)`;let n=Jt(e);return n===``?void 0:`(${n})`},C=(e,t,n)=>{let r=S(e,t);return r===void 0?n:n===void 0?r:`${n} ${r}`},w=(e,t)=>{if(x)return e.role===`removed`||t.role===`removed`?`removed`:e.role===`added`||t.role===`added`?`added`:Jt(e)===``?void 0:`moved`},T=(e,t)=>{let n=[],r=[],i=[],c=e.map(e=>({...e,days:zt(e.item)})).filter(e=>e.days!==void 0).sort((e,t)=>Number(e.item.type===`milestone`)-Number(t.item.type===`milestone`)||e.days.start-t.days.start||e.row-t.row||e.index-t.index);for(let{item:e,index:t,row:l,days:u,text:d,note:f,change:p}of c){let c=[],m;if(p===`moved`&&e.previous!==void 0){let t=Gt(e.previous);if(e.type===`activity`)m={x0:s(t.start),x1:s(t.end+1)};else{let e=s(t.start)+a/2;m={x0:e-7,x1:e+7,cx:e}}c.push({kind:`ghost`,x0:m.x0,x1:m.x1})}let h,g,_,v;if(e.type===`activity`){if(g=s(u.start),_=s(u.end+1),c.push({kind:`bar`,x0:g,x1:_}),d!==void 0){let e=on(d);h=e+12<=_-g?{text:d,inside:!0,x:g+6,width:e}:pn(d,g,_,o),f!==void 0&&(h.note=f),c.push({kind:`label`,x0:h.x,x1:h.x+h.width})}}else v=s(u.start)+a/2,g=v-7,_=v+7,c.push({kind:`star`,x0:g,x1:_}),d!==void 0&&(h=pn(d,g,_,o),f!==void 0&&(h.note=f),c.push({kind:`label`,x0:h.x,x1:h.x+h.width}));let y=n.findIndex(e=>c.every(t=>e.every(e=>ln(t.kind,e.kind)||!un(t,e))));y===-1&&(y=n.length,n.push([])),n[y].push(...c),r.push({row:l,item:t,type:e.type,lane:y,days:u,...e.kind?{kind:e.kind}:{},...p===void 0?{}:{change:p}}),i.push({label:h===void 0?void 0:{...h,...p===`removed`?{struck:!0}:{}},x0:g,x1:_,cx:v,ghost:m})}return r.forEach((e,n)=>{let r=i[n],a=t+4+e.lane*24+12,o=e.type===`activity`?{x:r.x0,y:a-6,width:r.x1-r.x0,height:12}:{x:r.x0,y:a-7,width:14,height:14},s=r.ghost;y.push({...e,glyph:o,...r.cx===void 0?{}:{center:{x:r.cx,y:a}},...r.label===void 0?{}:{label:{...r.label,y:a-8,height:16}},...s===void 0?{}:e.type===`activity`?{ghost:{x:s.x0,y:a-6,width:s.x1-s.x0,height:12}}:{ghost:{x:s.x0,y:a-7,width:14,height:14},ghostCenter:{x:s.cx,y:a}}})}),Math.max(1,n.length)},E=e=>e*24+8,D=(e,t)=>{let n=T(e.items.map((n,r)=>({row:t,index:r,item:n,text:C(n,e,an(n)),note:S(n,e),change:w(n,e)})),b),r=E(n);v.push({type:`task`,row:t,y:b,height:r,lanes:n,label:e.label,id:e.id}),b+=r},O,ee=()=>{if(O!==void 0){if(O.tasks.length===0){let e=O.label?26:10;v.push({type:`separator`,row:O.row,y:b,height:e,...O.label?{label:O.label}:{}}),b+=e}else{let e=T(O.tasks.flatMap(({task:e,row:t})=>e.items.map((n,r)=>({row:t,index:r,item:n,text:C(n,e,an(n)??(n.type===`activity`?e.label:void 0)),note:S(n,e),change:w(n,e)}))),b),t=E(e);v.push({type:`section`,row:O.row,y:b,height:t,lanes:e,...O.label?{label:O.label}:{},tasks:O.tasks.map(({task:e})=>e.id)}),b+=t}O=void 0}},te=(()=>{let t=new Set;if(!(n.onlyChanged&&x))return;let r;return e.rows.forEach((e,n)=>{e.type===`separator`?r=n:Xt(e)&&(t.add(n),r!==void 0&&t.add(r))}),t})(),k=te===void 0?0:e.rows.filter((e,t)=>e.type===`task`&&!te.has(t)).length;e.rows.forEach((e,t)=>{if(te===void 0||te.has(t)){if(e.type===`separator`){if(n.compact){ee(),O={row:t,...e.label?{label:e.label}:{},tasks:[]};return}let r=e.label?26:10;v.push({type:`separator`,row:t,y:b,height:r,...e.label?{label:e.label}:{}}),b+=r}else O===void 0?D(e,t):O.tasks.push({task:e,row:t})}}),ee();let ne=[];for(let t of e.rows)if(t.type===`task`)for(let e of t.items)e.kind&&!ne.includes(e.kind)&&ne.push(e.kind);for(let t of[...e.periods??[],...e.references??[]])t.kind&&!ne.includes(t.kind)&&ne.push(t.kind);let A=[];(e.periods??[]).forEach((e,t)=>{let n=Math.max(It(e.start)??r,r),o=Math.min(It(e.end)??i,i);n>o||A.push({index:t,x:s(n),width:(o-n+1)*a,start:e.start,end:e.end,...e.label?{label:e.label}:{},...e.kind?{kind:e.kind}:{}})});let re=(e.references??[]).flatMap((e,t)=>{let n=It(e.date);return n===void 0||n<r||n>i?[]:[{index:t,x:s(n)+a/2,label:e.label,date:e.date,...e.kind?{kind:e.kind}:{}}]}),j=[];if(t>=r&&t<=i){let e=s(t)+a/2;j.push({x0:e-26,x1:e+26})}let ie=[],ae=[...A.filter(e=>e.label).map(e=>({of:`period`,index:e.index,text:e.label,x:e.x+3,room:e.width-6})),...re.map(e=>{let t=on(e.label)*(10/11);return{of:`reference`,index:e.index,text:e.label,x:Math.min(Math.max(2,e.x-t/2),o-t-2),room:o-4}})].sort((e,t)=>e.x-t.x);for(let e of ae){let t=on(e.text)*(10/11);if(t>e.room)continue;let n={x0:e.x-2,x1:e.x+t+2};j.some(e=>n.x0<e.x1&&e.x0<n.x1)||(j.push(n),ie.push({of:e.of,index:e.index,text:e.text,x:e.x,width:t}))}return{width:o,height:b,start:r,end:i,years:f,months:d,monthLines:c.map(e=>s(e.day)),unit:p,upper:h,lower:g,unitLines:_,rows:v,items:y,dependencies:mn(e,v,y,s),today:t<r?{outside:`before`,day:t}:t>i?{outside:`after`,day:t}:{x:s(t)+a/2,day:t},kinds:ne,hiddenTasks:k,periods:A,references:re,headerLabels:ie}}function pn(e,t,n,r){let i=on(e),a=n+4;if(a+i<=r)return{text:e,inside:!1,x:a,width:i};let o=t-4-i;return o>=0?{text:e,inside:!1,x:o,width:i}:{text:e,inside:!1,x:Math.max(0,r-i),width:i}}function mn(e,t,n,r){let i=Bt(e),a=new Map(n.map(e=>[`${e.row}:${e.item}`,e])),o=new Map(t.map(e=>[e.row,e])),s=(e,t)=>{let s=i.get(e);if(s?.days===void 0)return;if(s.item!==void 0){let e=a.get(`${s.row}:${s.item}`);if(e===void 0)return;let n=e.glyph.y+e.glyph.height/2;return e.center===void 0?{x:t===`start`?e.glyph.x:e.glyph.x+e.glyph.width,y:n}:{x:e.center.x+(t===`start`?-7:7),y:n}}let c=r(t===`start`?s.days.start:s.days.end+1),l=o.get(s.row);if(l!==void 0&&l.type===`task`)return{x:c,y:l.y+4+12};let u=n.filter(e=>e.row===s.row).sort((e,n)=>t===`start`?e.glyph.x-n.glyph.x:n.glyph.x+n.glyph.width-(e.glyph.x+e.glyph.width));if(u.length!==0)return{x:c,y:u[0].glyph.y+u[0].glyph.height/2}},c=[];return(e.dependencies??[]).forEach((e,t)=>{let n=Ht(e),r=Ut(n),a=s(e.from,r.from),o=s(e.to,r.to),l=Wt(e,i);if(a===void 0||o===void 0||l===void 0)return;let u={x:a.x+(r.from===`end`?8:-8),y:a.y},d={x:o.x+(r.to===`start`?-8:8),y:o.y};if(a.y===o.y&&r.from===`end`&&r.to===`start`&&o.x>=a.x-14){c.push({index:t,from:e.from,to:e.to,type:n,satisfied:l,points:[a,o]});return}let f=o.y>a.y?o.y-12:(o.y,a.y,o.y+12);c.push({index:t,from:e.from,to:e.to,type:n,satisfied:l,points:[a,u,{x:u.x,y:f},{x:d.x,y:f},d,o]})}),c}function hn(e){let t=e.rows.reduce((e,t)=>Math.max(e,(t.label??``).length),0);return Math.min(Math.max(t*St+24,120),280)}function gn(e,t){for(let n of e.rows){if(n.type!==`task`)continue;if(n.id===t)return`"${n.label}" (${t})`;let e=n.items.find(e=>e.id===t);if(e!==void 0){let n=an(e);return n===void 0?t:`"${n}" (${t})`}}return t}function _n(e,t,n){let r=n===!1?` — not satisfied by the dates`:``;return`${gn(e,t.to)} waits on ${gn(e,t.from)} (${Ht(t)})${r}`}function vn(e){let t=[];e.title!==void 0&&e.title!==``&&t.push(e.title),e.comparedTo!==void 0&&t.push(`Compared with ${e.comparedTo.label}${e.comparedTo.date===void 0?``:` (${e.comparedTo.date})`}`),t.push(`From ${e.time.start} to ${e.time.end}, by ${e.time.scale}`);for(let n of e.rows){if(t.push(``),n.type===`separator`){t.push(n.label?`— ${n.label} —`:`———`);continue}let e=n.role===void 0?``:n.role===`added`?` — new`:` — removed`;t.push(`${n.label} [${n.id}]${n.items.length===0?` — no items`:``}${e}`);for(let e of n.items){let n=e.type===`activity`?`${e.start} to ${e.end}`:e.date,r=e.label===void 0?``:`: ${e.label}`,i=e.kind===void 0?``:` [${e.kind}]`,a=e.id===void 0?``:` (${e.id})`,o=(()=>{if(e.role===`added`)return` — new`;if(e.role===`removed`)return` — removed`;let t=Jt(e);return t===``||e.previous===void 0?``:` — moved ${t}, was ${`date`in e.previous?e.previous.date:`${e.previous.start} to ${e.previous.end}`}`})();t.push(` ${e.type} ${n}${r}${i}${a}${o}`)}}let n=[...(e.periods??[]).map(e=>` period ${e.start} to ${e.end}${e.label?`: ${e.label}`:``}${e.kind?` [${e.kind}]`:``}`),...(e.references??[]).map(e=>` reference ${e.date}: ${e.label}${e.kind?` [${e.kind}]`:``}`)];n.length>0&&t.push(``,`Calendar`,...n);let r=e.dependencies??[];if(r.length>0){let n=Bt(e);t.push(``,`Dependencies`);for(let i of r)t.push(` ${_n(e,i,Wt(i,n))}`)}return t}function yn(e){let t=[],n=(e,n)=>{let r=It(e);return r===void 0&&t.push({rule:`invalid-date`,path:n,message:`"${e}" is not a day of the calendar`}),r},r=n(e.time.start,`/data/time/start`),i=n(e.time.end,`/data/time/end`),a=r!==void 0&&i!==void 0&&r<=i?{start:r,end:i}:void 0;r!==void 0&&i!==void 0&&r>i&&t.push({rule:`inverted-range`,path:`/data/time`,message:`the timeline starts on ${e.time.start}, after it ends on ${e.time.end}`});let o=`${e.time.start} to ${e.time.end}`,s=new Map,c=(e,n)=>{if(e===void 0)return;let r=s.get(e);r===void 0?s.set(e,n):t.push({rule:`duplicate-identifier`,path:`${n}/id`,message:`identifier "${e}" is already declared at ${r}`})},l=e.comparedTo!==void 0;e.comparedTo?.date!==void 0&&n(e.comparedTo.date,`/data/comparedTo/date`);let u=e=>t.push({rule:`comparison-without-reference`,path:e,message:"previous dates and change roles describe a comparison; declare `comparedTo` naming the plan they compare with"}),d=new Set;return e.rows.forEach((e,r)=>{if(e.type!==`task`)return;let i=`/data/rows/${r}`;c(e.id,i),e.role!==void 0&&!l&&u(`${i}/role`),e.items.forEach((r,s)=>{let f=`${i}/items/${s}`;if(c(r.id,f),r.kind!==void 0&&d.add(r.kind),r.role!==void 0&&!l&&u(`${f}/role`),r.previous!==void 0){l||u(`${f}/previous`),(r.role!==void 0||e.role!==void 0)&&t.push({rule:`contradictory-change`,path:`${f}/previous`,message:`an item that is ${r.role??`in a task that is ${e.role}`} has no previous dates; it is new or dropped, not moved`});let i=r.previous,s=r.type===`activity`?{first:n(i.start,`${f}/previous/start`),last:n(i.end,`${f}/previous/end`)}:(()=>{let e=n(i.date,`${f}/previous/date`);return{first:e,last:e}})();s.first!==void 0&&s.last!==void 0&&(s.first>s.last?t.push({rule:`inverted-range`,path:`${f}/previous`,message:`the previous dates start on ${i.start}, after they end on ${i.end}`}):a!==void 0&&(s.first<a.start||s.last>a.end)&&t.push({rule:`item-outside-range`,path:`${f}/previous`,message:`the previous dates fall outside the timeline's range ${o}; the range covers both plans, so widen \`time\``}))}r.role!==void 0&&e.role!==void 0&&r.role!==e.role&&t.push({rule:`contradictory-change`,path:`${f}/role`,message:`an item ${r.role} in a task that is ${e.role}`});let p,m;if(r.type===`activity`){if(p=n(r.start,`${f}/start`),m=n(r.end,`${f}/end`),p!==void 0&&m!==void 0&&p>m){t.push({rule:`inverted-range`,path:f,message:`the activity starts on ${r.start}, after it ends on ${r.end}`});return}}else p=m=n(r.date,`${f}/date`);a!==void 0&&p!==void 0&&m!==void 0&&(p<a.start||m>a.end)&&t.push({rule:`item-outside-range`,path:f,message:r.type===`activity`?`the activity runs ${r.start} to ${r.end}, outside the timeline's range ${o}; widen \`time\` or move the activity`:`the milestone falls on ${r.date}, outside the timeline's range ${o}; widen \`time\` or move the milestone`})})}),(e.periods??[]).forEach((e,r)=>{let i=`/data/periods/${r}`;e.kind!==void 0&&d.add(e.kind);let s=n(e.start,`${i}/start`),c=n(e.end,`${i}/end`);s!==void 0&&c!==void 0&&(s>c?t.push({rule:`inverted-range`,path:i,message:`the period starts on ${e.start}, after it ends on ${e.end}`}):a!==void 0&&(c<a.start||s>a.end)&&t.push({rule:`period-outside-range`,path:i,message:`the period ${e.start} to ${e.end} lies wholly outside the timeline's range ${o}, so nothing of it could be drawn`}))}),(e.references??[]).forEach((e,r)=>{let i=`/data/references/${r}`;e.kind!==void 0&&d.add(e.kind);let s=n(e.date,`${i}/date`);s!==void 0&&a!==void 0&&(s<a.start||s>a.end)&&t.push({rule:`item-outside-range`,path:i,message:`the reference date ${e.date} is outside the timeline's range ${o}; widen \`time\` or move it`})}),d.size>at.kindsPerVocabulary&&t.push({rule:`too-many-kinds`,path:`/data/rows`,message:`${d.size} distinct item types, and no more than ${at.kindsPerVocabulary} can be told apart in a rendering`,observed:d.size,limit:at.kindsPerVocabulary}),t.push(...xn(e,Bt(e))),t.push(...bn(e)),t}function bn(e){let t=new Set;for(let n of e.rows)if(n.type===`task`){n.role===`removed`&&t.add(n.id);for(let e of n.items)e.id!==void 0&&(e.role===`removed`||n.role===`removed`)&&t.add(e.id)}let n=[];return(e.dependencies??[]).forEach((e,r)=>{for(let i of[`from`,`to`])t.has(e[i])&&n.push({rule:`dependency-on-removed`,path:`/data/dependencies/${r}/${i}`,message:`"${e[i]}" was dropped from the plan, so nothing can depend on it any more; remove the dependency`})}),n}function xn(e,t){let n=[],r=e.dependencies??[],i=[],a=new Map;r.forEach((r,o)=>{let s=`/data/dependencies/${o}`,c=!0;for(let i of[`from`,`to`]){let a=r[i],o=t.get(a);if(o===void 0)c=!1,n.push({rule:`unresolved-endpoint`,path:`${s}/${i}`,message:`"${a}" is not the identifier of any task or item this timeline declares`});else if(o.type===`task`&&o.days===void 0){c=!1;let t=e.rows[o.row];if(t.type===`task`&&t.items.length>0)continue;n.push({rule:`empty-task-endpoint`,path:`${s}/${i}`,message:`task "${a}" holds no item, so it has no start or finish for a dependency to link`})}}if(!c)return;let l=t.get(r.from),u=t.get(r.to),d=(e,t)=>e.type===`task`&&t.type!==`task`&&t.row===e.row;if(l.id===u.id||d(l,u)||d(u,l)){n.push({rule:`self-dependency`,path:s,message:l.id===u.id?`"${l.id}" cannot depend on itself`:`a task and one of its own items cannot depend on each other: the task's span is made of its items`});return}let f=JSON.stringify([r.from,r.to,Ht(r)]),p=a.get(f);p===void 0?(a.set(f,o),i.push({from:r.from,to:r.to,index:o})):n.push({rule:`duplicate-dependency`,path:s,message:`the same dependency is already declared at /data/dependencies/${p}`})});let o=Sn(i);return o!==void 0&&n.push({rule:`dependency-cycle`,path:`/data/dependencies/${o.index}`,message:`dependencies form a cycle, which no dates can honour: ${o.ids.join(` → `)}`}),n}function Sn(e){let t=new Map;for(let n of e){let e=t.get(n.from)??[];e.push({to:n.to,index:n.index}),t.set(n.from,e)}let n=new Map,r=[];for(let e of t.keys()){if(n.has(e))continue;let i=[{id:e,next:0}];for(n.set(e,`open`),r.push({id:e,index:-1});i.length>0;){let e=i[i.length-1],a=t.get(e.id)??[];if(e.next>=a.length){n.set(e.id,`done`),i.pop(),r.pop();continue}let o=a[e.next++],s=n.get(o.to);if(s===`open`){let e=r.findIndex(e=>e.id===o.to);return{ids:[...r.slice(e).map(e=>e.id),o.to],index:o.index}}s===void 0&&(n.set(o.to,`open`),i.push({id:o.to,next:0}),r.push({id:o.to,index:o.index}))}}}function Cn(e){let t=e.data;return e.kind===`graph`?Array.isArray(t.nodes)&&Array.isArray(t.edges):e.kind===`sequence`?Array.isArray(t.participants)&&Array.isArray(t.messages):e.kind===`timeline`?typeof t.time==`object`&&t.time!==null&&Array.isArray(t.rows):Array.isArray(t.columns)&&Array.isArray(t.rows)}function wn(e){return e.kind===`graph`?e.data.nodes:e.kind===`sequence`?e.data.participants:[]}function Tn(e){return e.kind===`graph`?e.data.edges:e.kind===`sequence`?e.data.messages:[]}function En(e){return e.kind===`graph`||e.kind===`sequence`?e.data.containers??[]:[]}function Dn(e){return e.kind===`graph`?`/data/nodes`:`/data/participants`}function On(e){return e.kind===`graph`?`/data/edges`:`/data/messages`}function kn(e){if(e.kind===`timeline`)return[];let t=e.data,n=[];for(let e of[`nodes`,`edges`,`participants`,`messages`,`rows`,`relations`]){let r=t[e];Array.isArray(r)&&r.forEach((t,r)=>{if(typeof t!=`object`||!t||Array.isArray(t))return;let i=t;n.push({at:`/data/${e}/${r}`,ref:typeof i.ref==`string`?i.ref:void 0,set:i.set,expect:i.expect,locations:i.locations})})}return n}function An(e){if(e.kind!==`table`)return[];let t=e.data.rows,n=[];return t.forEach((e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))return;let r=e;(r.ref!==void 0||r.set!==void 0)&&n.push({at:`/data/rows/${t}`,...typeof r.ref==`string`?{ref:r.ref}:{},...r.set===void 0?{}:{set:r.set}})}),n}function jn(e){if(e.kind!==`table`)return[];let t=e.data.rows,n=[];return t.forEach((e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))return;let r=e.id;typeof r==`string`&&n.push({id:r,at:`/data/rows/${t}`})}),n}function Mn(e){if(e.kind!==`table`)return[];let t=e.data.relations;return Array.isArray(t)?t:[]}function Nn(e,t){return e===`timeline`?`a timeline is maintained by presenting the revised timeline again, not proposed as a change, ${t}`:`a ${e} is a projection and cannot be proposed, ${t}`}function Pn(e){let t=[];if(!Cn(e))return t.push({rule:`kind-data-mismatch`,path:`/data`,message:`data does not carry what kind "${e.kind}" declares`}),t;let n=nt(e.schema).includes(e.kind);e.target!==void 0&&!n&&t.push({rule:`kind-not-proposable`,path:`/target`,message:Nn(e.kind,`so it carries no target`)}),e.removals!==void 0&&(n?e.target===void 0&&t.push({rule:`removal-without-target`,path:`/removals`,message:`removals need a target: an artifact that does not exist yet has nothing to remove`}):t.push({rule:`kind-not-proposable`,path:`/removals`,message:Nn(e.kind,`so it declares no removals`)}));let r=wn(e),i=Dn(e),a=new Map;r.forEach((e,n)=>{let r=a.get(e.id);r===void 0?a.set(e.id,n):t.push({rule:`duplicate-identifier`,path:`${i}/${n}/id`,message:`identifier "${e.id}" is already declared at ${i}/${r}`})});let o=new Map;En(e).forEach((e,n)=>{let r=o.get(e.id);r===void 0?o.set(e.id,n):t.push({rule:`duplicate-container-identifier`,path:`/data/containers/${n}/id`,message:`container "${e.id}" is already declared at /data/containers/${r}`})}),r.forEach((e,n)=>{for(let[r,a]of[[`container`,e.container],[`set/container`,e.set?.container]])a!==void 0&&!o.has(a)&&t.push({rule:`unresolved-container`,path:`${i}/${n}/${r}`,message:`"${a}" is not a container declared in /data/containers`})});let s=On(e);Tn(e).forEach((e,n)=>{for(let r of[`from`,`to`]){let o=e[r];a.has(o)||t.push({rule:`unresolved-endpoint`,path:`${s}/${n}/${r}`,message:`"${o}" is not an identifier declared in ${i}`})}});let c=new Map,l=(e,n,r)=>{if(n===void 0)return;let i=`${e}:${n}`,a=c.get(i);a===void 0?c.set(i,r):t.push({rule:`duplicate-reference`,path:r,message:`${e} "${n}" is already addressed at ${a}; a proposal states one intention per thing`})};r.forEach((e,t)=>l(`element`,e.ref,`${i}/${t}`)),Tn(e).forEach((e,t)=>l(`relationship`,e.ref,`${s}/${t}`)),An(e).forEach(e=>l(`row`,e.ref,e.at)),(e.removals??[]).forEach((e,t)=>l(e.type,e.ref,`/removals/${t}`));let u=[...r.map((e,t)=>({at:`${i}/${t}`,ref:e.ref,set:e.set})),...Tn(e).map((t,n)=>({at:`${On(e)}/${n}`,ref:t.ref,set:t.set})),...An(e)];for(let r of u)r.set!==void 0&&(r.ref===void 0?t.push({rule:`change-without-reference`,path:`${r.at}/set`,message:`a change names a reference to change; without one this is a new thing, and its fields are its values`}):n?e.target===void 0&&t.push({rule:`change-without-target`,path:`${r.at}/set`,message:`a change needs a target: naming what is being changed is what makes this a proposal rather than a new artifact`}):t.push({rule:`kind-not-proposable`,path:`${r.at}/set`,message:Nn(e.kind,`so nothing in it declares a change`)}));let d=e=>{let t=new Set;for(let n of e)n.kind!==void 0&&n.kind!==``&&t.add(n.kind);return t},f=[[e.kind===`sequence`?`participant`:`element`,i,d(r)],[e.kind===`sequence`?`message`:`relationship`,On(e),d(Tn(e))]];for(let[e,n,r]of f)r.size>at.kindsPerVocabulary&&t.push({rule:`too-many-kinds`,path:n,message:`${r.size} distinct ${e} types, and no more than ${at.kindsPerVocabulary} can be told apart in a rendering`,observed:r.size,limit:at.kindsPerVocabulary});let p=e.viewpoints;if(Array.isArray(p)){if(e.kind!==`graph`)t.push({rule:`viewpoints-without-graph`,path:`/viewpoints`,message:`only a graph declares viewpoints; a ${e.kind} has no element and relationship kinds for one to retain`});else{let n=new Set(r.map(e=>e.kind).filter(e=>!!e)),i=new Set(Tn(e).map(e=>e.kind).filter(e=>!!e)),a=new Map;p.forEach((e,r)=>{let o=`/viewpoints/${r}`,{id:s,elementKinds:c,relationshipKinds:l}=e,u=a.get(s);u===void 0?a.set(s,r):t.push({rule:`duplicate-viewpoint-identifier`,path:`${o}/id`,message:`viewpoint "${s}" is already declared at /viewpoints/${u}`}),c===void 0&&l===void 0&&t.push({rule:`empty-viewpoint`,path:o,message:`viewpoint "${s}" retains no kind, so it would show nothing it was not already showing; name elementKinds, relationshipKinds, or both`});let d=[[c,n,i,`elementKinds`,`element`,`relationship`],[l,i,n,`relationshipKinds`,`relationship`,`element`]];for(let[e,n,r,i,a,c]of d)e?.forEach((e,l)=>{n.has(e)||t.push({rule:`unresolved-viewpoint-kind`,path:`${o}/${i}/${l}`,message:`viewpoint "${s}" retains ${a} kind "${e}", and no ${a} of this document has it`+(r.has(e)?` (it is a ${c} kind here, which is a different vocabulary)`:``)})})})}}if(e.kind===`table`){let{columns:n,rows:r}=e.data;r.forEach((e,r)=>{let{cells:i,heading:a}=it(e);a===void 0&&i.length!==n.length&&t.push({rule:`row-column-mismatch`,path:`/data/rows/${r}`,message:`row has ${i.length} values but ${n.length} columns are declared`,observed:i.length,limit:n.length})})}e.kind===`timeline`&&t.push(...yn(e.data));for(let n of kn(e)){n.expect!==void 0&&(e.target===void 0?t.push({rule:`expectation-without-target`,path:`${n.at}/expect`,message:`an expectation is checked by the authority a proposal targets; a document that targets nothing has nobody to check it`}):n.ref===void 0&&t.push({rule:`expectation-without-reference`,path:`${n.at}/expect`,message:`an expectation describes something that already exists, and this item carries no reference to one`}));let r=n.set?.removeAttributes;if(Array.isArray(r)){let e=n.set?.attributes??{},i=new Map;r.forEach((r,a)=>{if(typeof r!=`string`)return;let o=i.get(r);o===void 0?i.set(r,a):t.push({rule:`duplicate-attribute-removal`,path:`${n.at}/set/removeAttributes/${a}`,message:`"${r}" is already removed at ${n.at}/set/removeAttributes/${o}`}),Object.prototype.hasOwnProperty.call(e,r)&&t.push({rule:`attribute-set-and-removed`,path:`${n.at}/set/removeAttributes/${a}`,message:`"${r}" is both assigned and removed; a proposal states one intention per property`})})}Array.isArray(n.locations)&&n.locations.forEach((e,r)=>{if(typeof e!=`object`||!e)return;let i=e.range;i!==void 0&&(i.endLine<i.startLine||i.endLine===i.startLine&&i.endCharacter!==void 0&&i.startCharacter!==void 0&&i.endCharacter<i.startCharacter)&&t.push({rule:`location-range-reversed`,path:`${n.at}/locations/${r}/range`,message:`a range ends before it begins, so it selects nothing a reader could be taken to`})})}e.kind===`table`&&e.data.rows.forEach((e,n)=>{if(typeof e!=`object`||!e||Array.isArray(e))return;let r=e;r.role!==void 0&&r.set!==void 0&&t.push({rule:`role-with-change`,path:`/data/rows/${n}/role`,message:`a row states what it observed or what it asks for, not both: a declared role beside a change is a report and an instruction at once`})});let m=new Map;for(let n of jn(e)){let e=m.get(n.id);e===void 0?m.set(n.id,n.at):t.push({rule:`duplicate-identifier`,path:`${n.at}/id`,message:`identifier "${n.id}" is already declared at ${e}`})}return Mn(e).forEach((e,n)=>{for(let r of[`from`,`to`]){let i=e[r];if(typeof i!=`object`||!i)continue;let a=i.id;typeof a==`string`&&(m.has(a)||t.push({rule:`unresolved-endpoint`,path:`/data/relations/${n}/${r}`,message:`"${a}" is not the identifier of any row this document declares`}))}}),t}function Fn(e,t){let n=t(e);if(n.length>0)return{valid:!1,issues:n};let r=e,i=Pn(r);return i.length>0?{valid:!1,issues:i}:{valid:!0,envelope:r,issues:[]}}function In(e,t,n){let r=vt(e,n);if(r!==void 0)return{valid:!1,issues:[r]};let i;try{i=JSON.parse(e)}catch{return{valid:!1,issues:[{rule:`not-json`,path:``,message:`document is not parseable JSON`}]}}let a=Fn(i,t);if(!a.valid)return a;let o=vt(e,n,a.envelope.schema);if(o!==void 0)return{valid:!1,issues:[o]};let s=bt(a.envelope,n);return s.length>0?{valid:!1,issues:s}:{valid:!0,envelope:a.envelope,measurement:xt(a.envelope,e),issues:[]}}function Ln(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e.schema;if(typeof t==`string`&&t.startsWith(`urn:structured-exchange:`))return t}function Rn(e,t,n){let r=vt(e,n);if(r!==void 0)return{status:`too-large`,issue:r};let i;try{i=JSON.parse(e)}catch{return{status:`not-a-document`,why:`unparseable`}}let a=Ln(i);if(a===void 0)return{status:`not-a-document`,why:`undeclared`};if(dt(a)===void 0)return{status:`unsupported-version`,schema:a};let o=Fn(i,t);if(!o.valid)return{status:`invalid`,issues:o.issues};let s=vt(e,n,o.envelope.schema);return s===void 0?{status:`valid`,envelope:o.envelope}:{status:`too-large`,issue:s}}function zn(e){let t=e.replace(/\r\n/g,`
|
|
22
22
|
`).replace(/\s+$/,``),n=2166136261;for(let e=0;e<t.length;e++)n^=t.charCodeAt(e),n=Math.imul(n,16777619);return`sx-${(n>>>0).toString(16).padStart(8,`0`)}-${t.length.toString(36)}`}async function Bn(e){try{return await navigator.clipboard.writeText(e),!0}catch{let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.cssText=`position:fixed;top:0;left:0;opacity:0;pointer-events:none`,document.body.append(t);try{return t.select(),document.execCommand(`copy`)}catch{return!1}finally{t.remove()}}}function Vn(e,t,n){return e>=t&&e<=n}function Hn(e){return e===8205}function Un(e){return Vn(e,55296,56319)}function Wn(e){return Vn(e,127462,127487)}function Gn(e){return Vn(e,65024,65039)}function Kn(e){return Vn(e,768,879)||Vn(e,6832,6911)||Vn(e,7616,7679)||Vn(e,65056,65071)}function qn(e){return e>65535?2:1}function Jn(e,t){for(;t<e.length;){let n=e.codePointAt(t);if(Kn(n)||Gn(n))t+=qn(n);else break}return t}function Yn(e,t){let n=e.codePointAt(t),r=t+qn(n);for(r=Jn(e,r);r<e.length-1&&Hn(e.codePointAt(r));){let t=e.codePointAt(r+1);r+=1+qn(t),r=Jn(e,r)}return Wn(n)&&r<e.length&&Wn(e.codePointAt(r))&&(r+=qn(e.codePointAt(r))),r}function Xn(e){return Un(e)||Kn(e)||Gn(e)||Hn(e)}function Zn(e,t){if(t===0)return!0;let n=0,r=0;for(;r<e.length;)if(r=Yn(e,r),n++,n>=t)return!0;return!1}function Qn(e,t){let n=0,r=0;for(;r<e.length;)if(r=Yn(e,r),n++,n>t)return!1;return!0}function $n(e,t){if(t===0)return!0;let n=0;for(;n<e.length;){if(Xn(e.charCodeAt(n)))return Zn(e,t);if(n++,n>=t)return!0}return!1}function er(e,t){let n=0;for(;n<e.length;){if(Xn(e.charCodeAt(n)))return Qn(e,t);if(n++,n>t)return!1}return!0}function tr(e){return Array.isArray(e)}function nr(e){return dr(typeof e,`bigint`)}function rr(e){return dr(typeof e,`boolean`)}function ir(e){if(ur(e)||!ar(e))return!1;let t=Function.prototype.toString.call(e);return!!(/^class\s/.test(t)||/\[native code\]/.test(t))}function ar(e){return dr(typeof e,`function`)}function or(e){return dr(e,null)}function sr(e){return dr(typeof e,`object`)&&!or(e)}function cr(e){return dr(typeof e,`string`)}function lr(e){return dr(typeof e,`symbol`)}function ur(e){return dr(e,void 0)}function dr(e,t){return e===t}function fr(e,t){return er(e,t)}function pr(e,t){return $n(e,t)}function mr(e){return e instanceof Boolean}function hr(e){return e instanceof Number}function gr(e){return e instanceof String}function _r(e){return globalThis.ArrayBuffer.isView(e)}function vr(e){return e instanceof globalThis.RegExp}function yr(e){return e instanceof globalThis.Date}var br=[];function xr(e){br=e.variables}var Sr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`schema`in e&&`kind`in e&&`data`in e&&Object.getOwnPropertyNames(e).every((e,t)=>br[0].test(e)||!1)&&e.schema===`urn:structured-exchange:1`&&(e.kind===`graph`||e.kind===`sequence`||e.kind===`table`)&&(e.target===void 0||!(`target`in e)||Cr(e.target))&&(e.removals===void 0||!(`removals`in e)||Array.isArray(e.removals)&&e.removals.every((e,t)=>wr(e))&&e.removals.length<=500)&&[typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`nodes`in e.data&&`edges`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>br[2].test(e)||!1)&&Array.isArray(e.data.nodes)&&e.data.nodes.every((e,t)=>Or(e))&&e.data.nodes.length<=500&&e.data.nodes.length>=1&&Array.isArray(e.data.edges)&&e.data.edges.every((e,t)=>Ar(e))&&e.data.edges.length<=2e3&&(e.data.containers===void 0||!(`containers`in e.data)||Array.isArray(e.data.containers)&&e.data.containers.every((e,t)=>Mr(e))&&e.data.containers.length<=50),typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`participants`in e.data&&`messages`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>br[8].test(e)||!1)&&Array.isArray(e.data.participants)&&e.data.participants.every((e,t)=>Or(e))&&e.data.participants.length<=100&&e.data.participants.length>=1&&Array.isArray(e.data.messages)&&e.data.messages.every((e,t)=>Nr(e))&&e.data.messages.length<=1e3&&(e.data.containers===void 0||!(`containers`in e.data)||Array.isArray(e.data.containers)&&e.data.containers.every((e,t)=>Mr(e))&&e.data.containers.length<=50),typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`columns`in e.data&&`rows`in e.data&&Object.getOwnPropertyNames(e.data).length===2&&Array.isArray(e.data.columns)&&e.data.columns.every((e,t)=>typeof e==`string`&&fr(e,200)&&pr(e,1))&&e.data.columns.length<=50&&e.data.columns.length>=1&&Array.isArray(e.data.rows)&&e.data.rows.every((e,t)=>[Fr(e),typeof e==`object`&&!!e&&!Array.isArray(e)&&`cells`in e&&Object.getOwnPropertyNames(e).every((e,t)=>br[11].test(e)||!1)&&Fr(e.cells)&&(e.role===void 0||!(`role`in e)||e.role===`added`||e.role===`changed`||e.role===`context`||e.role===`removed`)].reduce((e,t,n)=>t===!0?++e:e,0)===1)&&e.data.rows.length<=5e3].reduce((e,t,n)=>t===!0?++e:e,0)===1),Cr=(e=>typeof e==`string`&&fr(e,200)&&pr(e,1)),wr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&`ref`in e&&Object.getOwnPropertyNames(e).every((e,t)=>br[1].test(e)||!1)&&(e.type===`element`||e.type===`relationship`)&&Cr(e.ref)&&(e.label===void 0||!(`label`in e)||Tr(e.label))&&(e.kind===void 0||!(`kind`in e)||Er(e.kind))&&(e.from===void 0||!(`from`in e)||Dr(e.from))&&(e.to===void 0||!(`to`in e)||Dr(e.to))),Tr=(e=>typeof e==`string`&&fr(e,500)),Er=(e=>typeof e==`string`&&fr(e,100)&&pr(e,1)),Dr=(e=>typeof e==`string`&&fr(e,200)&&pr(e,1)),Or=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&Object.getOwnPropertyNames(e).every((e,t)=>br[3].test(e)||!1)&&Dr(e.id)&&(e.ref===void 0||!(`ref`in e)||Cr(e.ref))&&(e.label===void 0||!(`label`in e)||Tr(e.label))&&(e.kind===void 0||!(`kind`in e)||Er(e.kind))&&(e.set===void 0||!(`set`in e)||kr(e.set))&&(e.container===void 0||!(`container`in e)||Dr(e.container))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`label`in e)),kr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>br[4].test(e)||!1)&&(e.label===void 0||!(`label`in e)||Tr(e.label))&&(e.kind===void 0||!(`kind`in e)||Er(e.kind))&&(e.container===void 0||!(`container`in e)||Dr(e.container))&&Object.getOwnPropertyNames(e).length>=1),Ar=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&Object.getOwnPropertyNames(e).every((e,t)=>br[5].test(e)||!1)&&Dr(e.from)&&Dr(e.to)&&(e.kind===void 0||!(`kind`in e)||Er(e.kind))&&(e.ref===void 0||!(`ref`in e)||Cr(e.ref))&&(e.label===void 0||!(`label`in e)||Tr(e.label))&&(e.set===void 0||!(`set`in e)||jr(e.set))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`kind`in e)),jr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>br[6].test(e)||!1)&&(e.kind===void 0||!(`kind`in e)||Er(e.kind))&&(e.label===void 0||!(`label`in e)||Tr(e.label))&&Object.getOwnPropertyNames(e).length>=1),Mr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&`label`in e&&Object.getOwnPropertyNames(e).every((e,t)=>br[7].test(e)||!1)&&Dr(e.id)&&Tr(e.label)&&(e.kind===void 0||!(`kind`in e)||Er(e.kind))),Nr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&Object.getOwnPropertyNames(e).every((e,t)=>br[9].test(e)||!1)&&Dr(e.from)&&Dr(e.to)&&(e.ref===void 0||!(`ref`in e)||Cr(e.ref))&&(e.label===void 0||!(`label`in e)||Tr(e.label))&&(e.set===void 0||!(`set`in e)||Pr(e.set))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`label`in e)),Pr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>br[10].test(e)||!1)&&(e.label===void 0||!(`label`in e)||Tr(e.label))&&Object.getOwnPropertyNames(e).length>=1),Fr=(e=>Array.isArray(e)&&e.every((e,t)=>(typeof e==`string`||Number.isFinite(e)||typeof e==`boolean`||e===null)&&(typeof e!=`string`||fr(e,1e3)))&&e.length<=50);function Ir(e){return Sr(e)}xr({variables:[RegExp(`(^schema$|^kind$|^target$|^removals$|^data$)`,`u`),RegExp(`(^type$|^ref$|^label$|^kind$|^from$|^to$)`,`u`),RegExp(`(^nodes$|^edges$|^containers$)`,`u`),RegExp(`(^id$|^ref$|^label$|^kind$|^set$|^container$)`,`u`),RegExp(`(^label$|^kind$|^container$)`,`u`),RegExp(`(^from$|^to$|^kind$|^ref$|^label$|^set$)`,`u`),RegExp(`(^kind$|^label$)`,`u`),RegExp(`(^id$|^label$|^kind$)`,`u`),RegExp(`(^participants$|^messages$|^containers$)`,`u`),RegExp(`(^from$|^to$|^ref$|^label$|^set$)`,`u`),RegExp(`(^label$)`,`u`),RegExp(`(^cells$|^role$)`,`u`)]});function Lr(){throw Error(`Unreachable`)}function Rr(e){let t=new Set,n=e;for(;n&&n!==Object.prototype;){for(let e of Reflect.ownKeys(n))e!==`constructor`&&typeof e!=`symbol`&&t.add(e);n=Object.getPrototypeOf(n)}return[...t]}function zr(e){return typeof e==`number`}var Br;(function(e){e[e.Array=0]=`Array`,e[e.BigInt=1]=`BigInt`,e[e.Boolean=2]=`Boolean`,e[e.Date=3]=`Date`,e[e.Constructor=4]=`Constructor`,e[e.Function=5]=`Function`,e[e.Null=6]=`Null`,e[e.Number=7]=`Number`,e[e.Object=8]=`Object`,e[e.RegExp=9]=`RegExp`,e[e.String=10]=`String`,e[e.Symbol=11]=`Symbol`,e[e.TypeArray=12]=`TypeArray`,e[e.Undefined=13]=`Undefined`})(Br||={});var Vr=BigInt(`14695981039346656037`),[Hr,Ur]=[BigInt(`1099511628211`),BigInt(`18446744073709551616`)],Wr=Array.from({length:256}).map((e,t)=>BigInt(t)),Gr=new Float64Array(1),Kr=new DataView(Gr.buffer),qr=new Uint8Array(Gr.buffer);function Jr(e){Vr^=Wr[e],Vr=Vr*Hr%Ur}function Yr(e){Jr(Br.Array);for(let t of e)ui(t)}function Xr(e){Jr(Br.BigInt),Kr.setBigInt64(0,e);for(let e of qr)Jr(e)}function Zr(e){Jr(Br.Boolean),Jr(+!!e)}function Qr(e){Jr(Br.Constructor),ui(e.toString())}function $r(e){Jr(Br.Date),ui(e.getTime())}function ei(e){Jr(Br.Function),ui(e.toString())}function ti(e){Jr(Br.Null)}function ni(e){Jr(Br.Number),Kr.setFloat64(0,e,!0);for(let e of qr)Jr(e)}function ri(e){Jr(Br.Object);for(let t of Rr(e).sort())ui(t),ui(e[t])}function ii(e){Jr(Br.RegExp),oi(e.toString())}var ai=new TextEncoder;function oi(e){Jr(Br.String);for(let t of ai.encode(e))Jr(t)}function si(e){Jr(Br.Symbol),ui(e.toString())}function ci(e){Jr(Br.TypeArray);let t=new Uint8Array(e.buffer);for(let e=0;e<t.length;e++)Jr(t[e])}function li(e){return Jr(Br.Undefined)}function ui(e){return _r(e)?ci(e):yr(e)?$r(e):vr(e)?ii(e):mr(e)?Zr(e.valueOf()):gr(e)?oi(e.valueOf()):hr(e)?ni(e.valueOf()):zr(e)?ni(e):tr(e)?Yr(e):rr(e)?Zr(e):nr(e)?Xr(e):ir(e)?Qr(e):or(e)?ti(e):sr(e)?ri(e):cr(e)?oi(e):lr(e)?si(e):ur(e)?li(e):ar(e)?ei(e):Lr()}function di(e){return Vr=BigInt(`14695981039346656037`),ui(e),Vr}function fi(e){return di(e).toString(16).padStart(16,`0`)}var pi=[];function mi(e){pi=e.variables}var hi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`schema`in e&&`kind`in e&&`data`in e&&Object.getOwnPropertyNames(e).every((e,t)=>pi[0].test(e)||!1)&&e.schema===`urn:structured-exchange:2`&&(e.kind===`graph`||e.kind===`sequence`||e.kind===`table`)&&(e.profile===void 0||!(`profile`in e)||typeof e.profile==`string`&&fr(e.profile,200)&&pr(e.profile,1))&&(e.target===void 0||!(`target`in e)||typeof e.target==`object`&&e.target!==null&&!Array.isArray(e.target)&&`ref`in e.target&&Object.getOwnPropertyNames(e.target).every((e,t)=>pi[1].test(e)||!1)&&gi(e.target.ref)&&(e.target.revision===void 0||!(`revision`in e.target)||_i(e.target.revision)))&&(e.removals===void 0||!(`removals`in e)||Array.isArray(e.removals)&&e.removals.every((e,t)=>vi(e))&&e.removals.length<=500)&&(e.artifacts===void 0||!(`artifacts`in e)||Array.isArray(e.artifacts)&&e.artifacts.every((e,t)=>Si(e))&&e.artifacts.length<=50)&&(e.viewpoints===void 0||!(`viewpoints`in e)||Array.isArray(e.viewpoints)&&e.viewpoints.every((e,t)=>Ci(e))&&e.viewpoints.length<=20)&&[typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`nodes`in e.data&&`edges`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>pi[6].test(e)||!1)&&Array.isArray(e.data.nodes)&&e.data.nodes.every((e,t)=>wi(e))&&e.data.nodes.length<=500&&e.data.nodes.length>=1&&Array.isArray(e.data.edges)&&e.data.edges.every((e,t)=>Ii(e))&&e.data.edges.length<=2e3&&(e.data.containers===void 0||!(`containers`in e.data)||Array.isArray(e.data.containers)&&e.data.containers.every((e,t)=>Ri(e))&&e.data.containers.length<=50),typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`participants`in e.data&&`messages`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>pi[16].test(e)||!1)&&Array.isArray(e.data.participants)&&e.data.participants.every((e,t)=>wi(e))&&e.data.participants.length<=100&&e.data.participants.length>=1&&Array.isArray(e.data.messages)&&e.data.messages.every((e,t)=>zi(e))&&e.data.messages.length<=1e3&&(e.data.containers===void 0||!(`containers`in e.data)||Array.isArray(e.data.containers)&&e.data.containers.every((e,t)=>Ri(e))&&e.data.containers.length<=50),typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`columns`in e.data&&`rows`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>pi[19].test(e)||!1)&&Array.isArray(e.data.columns)&&e.data.columns.every((e,t)=>typeof e==`string`&&fr(e,200)&&pr(e,1))&&e.data.columns.length<=50&&e.data.columns.length>=1&&Array.isArray(e.data.rows)&&e.data.rows.every((e,t)=>[Vi(e),Hi(e),Gi(e)].reduce((e,t,n)=>t===!0?++e:e,0)===1)&&e.data.rows.length<=5e3&&(e.data.relations===void 0||!(`relations`in e.data)||Array.isArray(e.data.relations)&&e.data.relations.every((e,t)=>Ki(e))&&e.data.relations.length<=2e3)].reduce((e,t,n)=>t===!0?++e:e,0)===1),gi=(e=>typeof e==`string`&&fr(e,200)&&pr(e,1)),_i=(e=>typeof e==`string`&&fr(e,200)&&pr(e,1)),vi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&`ref`in e&&Object.getOwnPropertyNames(e).every((e,t)=>pi[2].test(e)||!1)&&(e.type===`element`||e.type===`relationship`||e.type===`row`)&&gi(e.ref)&&(e.label===void 0||!(`label`in e)||yi(e.label))&&(e.kind===void 0||!(`kind`in e)||bi(e.kind))&&(e.from===void 0||!(`from`in e)||xi(e.from))&&(e.to===void 0||!(`to`in e)||xi(e.to))),yi=(e=>typeof e==`string`&&fr(e,500)),bi=(e=>typeof e==`string`&&fr(e,100)&&pr(e,1)),xi=(e=>typeof e==`string`&&fr(e,200)&&pr(e,1)),Si=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`rel`in e&&`uri`in e&&`sha256`in e&&Object.getOwnPropertyNames(e).every((e,t)=>pi[3].test(e)||!1)&&typeof e.rel==`string`&&fr(e.rel,100)&&pr(e.rel,1)&&typeof e.uri==`string`&&fr(e.uri,2e3)&&pr(e.uri,1)&&typeof e.sha256==`string`&&pi[4].test(e.sha256)&&(e.mediaType===void 0||!(`mediaType`in e)||typeof e.mediaType==`string`&&fr(e.mediaType,100)&&pr(e.mediaType,1))&&(e.label===void 0||!(`label`in e)||yi(e.label))),Ci=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&`label`in e&&`concern`in e&&Object.getOwnPropertyNames(e).every((e,t)=>pi[5].test(e)||!1)&&xi(e.id)&&typeof e.label==`string`&&fr(e.label,500)&&pr(e.label,1)&&typeof e.concern==`string`&&fr(e.concern,500)&&pr(e.concern,1)&&(e.elementKinds===void 0||!(`elementKinds`in e)||Array.isArray(e.elementKinds)&&e.elementKinds.every((e,t)=>bi(e))&&e.elementKinds.length<=64&&e.elementKinds.length>=1&&new Set(e.elementKinds.map(fi)).size===e.elementKinds.length)&&(e.relationshipKinds===void 0||!(`relationshipKinds`in e)||Array.isArray(e.relationshipKinds)&&e.relationshipKinds.every((e,t)=>bi(e))&&e.relationshipKinds.length<=64&&e.relationshipKinds.length>=1&&new Set(e.relationshipKinds.map(fi)).size===e.relationshipKinds.length)),wi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&Object.getOwnPropertyNames(e).every((e,t)=>pi[7].test(e)||!1)&&xi(e.id)&&(e.ref===void 0||!(`ref`in e)||gi(e.ref))&&(e.label===void 0||!(`label`in e)||yi(e.label))&&(e.kind===void 0||!(`kind`in e)||bi(e.kind))&&(e.set===void 0||!(`set`in e)||Ti(e.set))&&(e.container===void 0||!(`container`in e)||xi(e.container))&&(e.attributes===void 0||!(`attributes`in e)||Ei(e.attributes))&&(e.expect===void 0||!(`expect`in e)||ji(e.expect))&&(e.locations===void 0||!(`locations`in e)||Mi(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||Fi(e.artifacts))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`label`in e)),Ti=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>pi[8].test(e)||!1)&&(e.label===void 0||!(`label`in e)||yi(e.label))&&(e.kind===void 0||!(`kind`in e)||bi(e.kind))&&(e.container===void 0||!(`container`in e)||xi(e.container))&&(e.attributes===void 0||!(`attributes`in e)||Ei(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||Ai(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),Ei=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((t,n)=>pi[9].test(t)||Di(e[t]))&&Object.getOwnPropertyNames(e).every((e,t)=>typeof e!=`string`||fr(e,200)&&pr(e,1))&&Object.getOwnPropertyNames(e).length<=50),Di=(e=>[Oi(e),ki(e),Array.isArray(e)&&e.every((e,t)=>[Oi(e),ki(e)].reduce((e,t,n)=>t===!0?++e:e,0)===1)&&e.length<=50].reduce((e,t,n)=>t===!0?++e:e,0)===1),Oi=(e=>(typeof e==`string`||Number.isFinite(e)||typeof e==`boolean`||e===null)&&(typeof e!=`string`||fr(e,1e3))),ki=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`ref`in e&&Object.getOwnPropertyNames(e).length===1&&gi(e.ref)),Ai=(e=>Array.isArray(e)&&e.every((e,t)=>xi(e))&&e.length<=50),ji=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>pi[10].test(e)||!1)&&(e.label===void 0||!(`label`in e)||yi(e.label))&&(e.kind===void 0||!(`kind`in e)||bi(e.kind))&&(e.container===void 0||!(`container`in e)||xi(e.container))&&(e.revision===void 0||!(`revision`in e)||_i(e.revision))&&(e.attributes===void 0||!(`attributes`in e)||Ei(e.attributes))&&Object.getOwnPropertyNames(e).length>=1),Mi=(e=>Array.isArray(e)&&e.every((e,t)=>Ni(e))&&e.length<=10),Ni=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`uri`in e&&Object.getOwnPropertyNames(e).every((e,t)=>pi[11].test(e)||!1)&&typeof e.uri==`string`&&fr(e.uri,2e3)&&pr(e.uri,1)&&(e.revision===void 0||!(`revision`in e)||_i(e.revision))&&(e.range===void 0||!(`range`in e)||typeof e.range==`object`&&e.range!==null&&!Array.isArray(e.range)&&`startLine`in e.range&&`endLine`in e.range&&Object.getOwnPropertyNames(e.range).every((e,t)=>pi[12].test(e)||!1)&&Pi(e.range.startLine)&&(e.range.startCharacter===void 0||!(`startCharacter`in e.range)||Pi(e.range.startCharacter))&&Pi(e.range.endLine)&&(e.range.endCharacter===void 0||!(`endCharacter`in e.range)||Pi(e.range.endCharacter)))),Pi=(e=>Number.isInteger(e)&&(!(Number.isFinite(e)||typeof e==`bigint`)||e<=1e6&&e>=0)),Fi=(e=>Array.isArray(e)&&e.every((e,t)=>Si(e))&&e.length<=20),Ii=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&Object.getOwnPropertyNames(e).every((e,t)=>pi[13].test(e)||!1)&&xi(e.from)&&xi(e.to)&&(e.kind===void 0||!(`kind`in e)||bi(e.kind))&&(e.ref===void 0||!(`ref`in e)||gi(e.ref))&&(e.label===void 0||!(`label`in e)||yi(e.label))&&(e.set===void 0||!(`set`in e)||Li(e.set))&&(e.attributes===void 0||!(`attributes`in e)||Ei(e.attributes))&&(e.expect===void 0||!(`expect`in e)||ji(e.expect))&&(e.locations===void 0||!(`locations`in e)||Mi(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||Fi(e.artifacts))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`kind`in e)),Li=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>pi[14].test(e)||!1)&&(e.kind===void 0||!(`kind`in e)||bi(e.kind))&&(e.label===void 0||!(`label`in e)||yi(e.label))&&(e.attributes===void 0||!(`attributes`in e)||Ei(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||Ai(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),Ri=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&`label`in e&&Object.getOwnPropertyNames(e).every((e,t)=>pi[15].test(e)||!1)&&xi(e.id)&&yi(e.label)&&(e.kind===void 0||!(`kind`in e)||bi(e.kind))),zi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&Object.getOwnPropertyNames(e).every((e,t)=>pi[17].test(e)||!1)&&xi(e.from)&&xi(e.to)&&(e.ref===void 0||!(`ref`in e)||gi(e.ref))&&(e.label===void 0||!(`label`in e)||yi(e.label))&&(e.set===void 0||!(`set`in e)||Bi(e.set))&&(e.attributes===void 0||!(`attributes`in e)||Ei(e.attributes))&&(e.expect===void 0||!(`expect`in e)||ji(e.expect))&&(e.locations===void 0||!(`locations`in e)||Mi(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||Fi(e.artifacts))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`label`in e)),Bi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>pi[18].test(e)||!1)&&(e.label===void 0||!(`label`in e)||yi(e.label))&&(e.attributes===void 0||!(`attributes`in e)||Ei(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||Ai(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),Vi=(e=>Array.isArray(e)&&e.every((e,t)=>(typeof e==`string`||Number.isFinite(e)||typeof e==`boolean`||e===null)&&(typeof e!=`string`||fr(e,1e3)))&&e.length<=50),Hi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`cells`in e&&Object.getOwnPropertyNames(e).every((e,t)=>pi[20].test(e)||!1)&&Vi(e.cells)&&(e.role===void 0||!(`role`in e)||Ui(e.role))&&(e.id===void 0||!(`id`in e)||xi(e.id))&&(e.ref===void 0||!(`ref`in e)||gi(e.ref))&&(e.kind===void 0||!(`kind`in e)||bi(e.kind))&&(e.label===void 0||!(`label`in e)||yi(e.label))&&(e.set===void 0||!(`set`in e)||Wi(e.set))&&(e.attributes===void 0||!(`attributes`in e)||Ei(e.attributes))&&(e.expect===void 0||!(`expect`in e)||ji(e.expect))&&(e.locations===void 0||!(`locations`in e)||Mi(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||Fi(e.artifacts))),Ui=(e=>e===`added`||e===`changed`||e===`context`||e===`removed`),Wi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>pi[21].test(e)||!1)&&(e.label===void 0||!(`label`in e)||yi(e.label))&&(e.kind===void 0||!(`kind`in e)||bi(e.kind))&&(e.cells===void 0||!(`cells`in e)||Vi(e.cells))&&(e.attributes===void 0||!(`attributes`in e)||Ei(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||Ai(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),Gi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`heading`in e&&Object.getOwnPropertyNames(e).every((e,t)=>pi[22].test(e)||!1)&&typeof e.heading==`string`&&fr(e.heading,500)&&pr(e.heading,1)&&(e.depth===void 0||!(`depth`in e)||Number.isInteger(e.depth)&&(!(Number.isFinite(e.depth)||typeof e.depth==`bigint`)||e.depth<=6&&e.depth>=1))&&(e.role===void 0||!(`role`in e)||Ui(e.role))&&(e.id===void 0||!(`id`in e)||xi(e.id))&&(e.ref===void 0||!(`ref`in e)||gi(e.ref))),Ki=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&`kind`in e&&Object.getOwnPropertyNames(e).every((e,t)=>pi[23].test(e)||!1)&&qi(e.from)&&qi(e.to)&&bi(e.kind)&&(e.ref===void 0||!(`ref`in e)||gi(e.ref))&&(e.label===void 0||!(`label`in e)||yi(e.label))&&(e.attributes===void 0||!(`attributes`in e)||Ei(e.attributes))),qi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>pi[24].test(e)||!1)&&(e.id===void 0||!(`id`in e)||xi(e.id))&&(e.ref===void 0||!(`ref`in e)||gi(e.ref))&&Object.getOwnPropertyNames(e).length>=1&&Object.getOwnPropertyNames(e).length<=1&&[!(typeof e==`object`&&e&&!Array.isArray(e))||`id`in e,!(typeof e==`object`&&e&&!Array.isArray(e))||`ref`in e].reduce((e,t,n)=>t===!0?++e:e,0)===1);function Ji(e){return hi(e)}mi({variables:[RegExp(`(^schema$|^kind$|^profile$|^target$|^removals$|^artifacts$|^viewpoints$|^data$)`,`u`),RegExp(`(^ref$|^revision$)`,`u`),RegExp(`(^type$|^ref$|^label$|^kind$|^from$|^to$)`,`u`),RegExp(`(^rel$|^uri$|^sha256$|^mediaType$|^label$)`,`u`),RegExp(`^sha256:[0-9a-f]{64}$`,`u`),RegExp(`(^id$|^label$|^concern$|^elementKinds$|^relationshipKinds$)`,`u`),RegExp(`(^nodes$|^edges$|^containers$)`,`u`),RegExp(`(^id$|^ref$|^label$|^kind$|^set$|^container$|^attributes$|^expect$|^locations$|^artifacts$)`,`u`),RegExp(`(^label$|^kind$|^container$|^attributes$|^removeAttributes$)`,`u`),RegExp(`(?!)`,`u`),RegExp(`(^label$|^kind$|^container$|^revision$|^attributes$)`,`u`),RegExp(`(^uri$|^revision$|^range$)`,`u`),RegExp(`(^startLine$|^startCharacter$|^endLine$|^endCharacter$)`,`u`),RegExp(`(^from$|^to$|^kind$|^ref$|^label$|^set$|^attributes$|^expect$|^locations$|^artifacts$)`,`u`),RegExp(`(^kind$|^label$|^attributes$|^removeAttributes$)`,`u`),RegExp(`(^id$|^label$|^kind$)`,`u`),RegExp(`(^participants$|^messages$|^containers$)`,`u`),RegExp(`(^from$|^to$|^ref$|^label$|^set$|^attributes$|^expect$|^locations$|^artifacts$)`,`u`),RegExp(`(^label$|^attributes$|^removeAttributes$)`,`u`),RegExp(`(^columns$|^rows$|^relations$)`,`u`),RegExp(`(^cells$|^role$|^id$|^ref$|^kind$|^label$|^set$|^attributes$|^expect$|^locations$|^artifacts$)`,`u`),RegExp(`(^label$|^kind$|^cells$|^attributes$|^removeAttributes$)`,`u`),RegExp(`(^heading$|^depth$|^role$|^id$|^ref$)`,`u`),RegExp(`(^from$|^to$|^kind$|^ref$|^label$|^attributes$)`,`u`),RegExp(`(^id$|^ref$)`,`u`)]});var Yi=[];function Xi(e){Yi=e.variables}var Zi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`schema`in e&&`kind`in e&&`data`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Yi[0].test(e)||!1)&&e.schema===`urn:structured-exchange:3`&&(e.kind===`graph`||e.kind===`sequence`||e.kind===`table`||e.kind===`timeline`)&&(e.profile===void 0||!(`profile`in e)||typeof e.profile==`string`&&fr(e.profile,200)&&pr(e.profile,1))&&(e.target===void 0||!(`target`in e)||typeof e.target==`object`&&e.target!==null&&!Array.isArray(e.target)&&`ref`in e.target&&Object.getOwnPropertyNames(e.target).every((e,t)=>Yi[1].test(e)||!1)&&Qi(e.target.ref)&&(e.target.revision===void 0||!(`revision`in e.target)||$i(e.target.revision)))&&(e.removals===void 0||!(`removals`in e)||Array.isArray(e.removals)&&e.removals.every((e,t)=>ea(e))&&e.removals.length<=500)&&(e.artifacts===void 0||!(`artifacts`in e)||Array.isArray(e.artifacts)&&e.artifacts.every((e,t)=>ia(e))&&e.artifacts.length<=50)&&(e.viewpoints===void 0||!(`viewpoints`in e)||Array.isArray(e.viewpoints)&&e.viewpoints.every((e,t)=>aa(e))&&e.viewpoints.length<=20)&&[typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`nodes`in e.data&&`edges`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>Yi[6].test(e)||!1)&&Array.isArray(e.data.nodes)&&e.data.nodes.every((e,t)=>oa(e))&&e.data.nodes.length<=500&&e.data.nodes.length>=1&&Array.isArray(e.data.edges)&&e.data.edges.every((e,t)=>va(e))&&e.data.edges.length<=2e3&&(e.data.containers===void 0||!(`containers`in e.data)||Array.isArray(e.data.containers)&&e.data.containers.every((e,t)=>ba(e))&&e.data.containers.length<=50),typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`participants`in e.data&&`messages`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>Yi[16].test(e)||!1)&&Array.isArray(e.data.participants)&&e.data.participants.every((e,t)=>oa(e))&&e.data.participants.length<=100&&e.data.participants.length>=1&&Array.isArray(e.data.messages)&&e.data.messages.every((e,t)=>xa(e))&&e.data.messages.length<=1e3&&(e.data.containers===void 0||!(`containers`in e.data)||Array.isArray(e.data.containers)&&e.data.containers.every((e,t)=>ba(e))&&e.data.containers.length<=50),typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`columns`in e.data&&`rows`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>Yi[19].test(e)||!1)&&Array.isArray(e.data.columns)&&e.data.columns.every((e,t)=>typeof e==`string`&&fr(e,200)&&pr(e,1))&&e.data.columns.length<=50&&e.data.columns.length>=1&&Array.isArray(e.data.rows)&&e.data.rows.every((e,t)=>[Ca(e),wa(e),Da(e)].reduce((e,t,n)=>t===!0?++e:e,0)===1)&&e.data.rows.length<=5e3&&(e.data.relations===void 0||!(`relations`in e.data)||Array.isArray(e.data.relations)&&e.data.relations.every((e,t)=>Oa(e))&&e.data.relations.length<=2e3),typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`time`in e.data&&`rows`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>Yi[25].test(e)||!1)&&(e.data.title===void 0||!(`title`in e.data)||ta(e.data.title))&&typeof e.data.time==`object`&&e.data.time!==null&&!Array.isArray(e.data.time)&&`start`in e.data.time&&`end`in e.data.time&&`scale`in e.data.time&&Object.getOwnPropertyNames(e.data.time).length===3&&Aa(e.data.time.start)&&Aa(e.data.time.end)&&(e.data.time.scale===`week`||e.data.time.scale===`month`||e.data.time.scale===`quarter`)&&Array.isArray(e.data.rows)&&e.data.rows.every((e,t)=>ja(e))&&e.data.rows.length<=500&&(e.data.dependencies===void 0||!(`dependencies`in e.data)||Array.isArray(e.data.dependencies)&&e.data.dependencies.every((e,t)=>Ra(e))&&e.data.dependencies.length<=2e3)&&(e.data.comparedTo===void 0||!(`comparedTo`in e.data)||typeof e.data.comparedTo==`object`&&e.data.comparedTo!==null&&!Array.isArray(e.data.comparedTo)&&`label`in e.data.comparedTo&&Object.getOwnPropertyNames(e.data.comparedTo).every((e,t)=>Yi[32].test(e)||!1)&&typeof e.data.comparedTo.label==`string`&&fr(e.data.comparedTo.label,500)&&pr(e.data.comparedTo.label,1)&&(e.data.comparedTo.date===void 0||!(`date`in e.data.comparedTo)||Aa(e.data.comparedTo.date)))&&(e.data.periods===void 0||!(`periods`in e.data)||Array.isArray(e.data.periods)&&e.data.periods.every((e,t)=>za(e))&&e.data.periods.length<=100)&&(e.data.references===void 0||!(`references`in e.data)||Array.isArray(e.data.references)&&e.data.references.every((e,t)=>Ba(e))&&e.data.references.length<=50)].reduce((e,t,n)=>t===!0?++e:e,0)===1),Qi=(e=>typeof e==`string`&&fr(e,200)&&pr(e,1)),$i=(e=>typeof e==`string`&&fr(e,200)&&pr(e,1)),ea=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&`ref`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Yi[2].test(e)||!1)&&(e.type===`element`||e.type===`relationship`||e.type===`row`)&&Qi(e.ref)&&(e.label===void 0||!(`label`in e)||ta(e.label))&&(e.kind===void 0||!(`kind`in e)||na(e.kind))&&(e.from===void 0||!(`from`in e)||ra(e.from))&&(e.to===void 0||!(`to`in e)||ra(e.to))),ta=(e=>typeof e==`string`&&fr(e,500)),na=(e=>typeof e==`string`&&fr(e,100)&&pr(e,1)),ra=(e=>typeof e==`string`&&fr(e,200)&&pr(e,1)),ia=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`rel`in e&&`uri`in e&&`sha256`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Yi[3].test(e)||!1)&&typeof e.rel==`string`&&fr(e.rel,100)&&pr(e.rel,1)&&typeof e.uri==`string`&&fr(e.uri,2e3)&&pr(e.uri,1)&&typeof e.sha256==`string`&&Yi[4].test(e.sha256)&&(e.mediaType===void 0||!(`mediaType`in e)||typeof e.mediaType==`string`&&fr(e.mediaType,100)&&pr(e.mediaType,1))&&(e.label===void 0||!(`label`in e)||ta(e.label))),aa=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&`label`in e&&`concern`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Yi[5].test(e)||!1)&&ra(e.id)&&typeof e.label==`string`&&fr(e.label,500)&&pr(e.label,1)&&typeof e.concern==`string`&&fr(e.concern,500)&&pr(e.concern,1)&&(e.elementKinds===void 0||!(`elementKinds`in e)||Array.isArray(e.elementKinds)&&e.elementKinds.every((e,t)=>na(e))&&e.elementKinds.length<=64&&e.elementKinds.length>=1&&new Set(e.elementKinds.map(fi)).size===e.elementKinds.length)&&(e.relationshipKinds===void 0||!(`relationshipKinds`in e)||Array.isArray(e.relationshipKinds)&&e.relationshipKinds.every((e,t)=>na(e))&&e.relationshipKinds.length<=64&&e.relationshipKinds.length>=1&&new Set(e.relationshipKinds.map(fi)).size===e.relationshipKinds.length)),oa=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Yi[7].test(e)||!1)&&ra(e.id)&&(e.ref===void 0||!(`ref`in e)||Qi(e.ref))&&(e.label===void 0||!(`label`in e)||ta(e.label))&&(e.kind===void 0||!(`kind`in e)||na(e.kind))&&(e.set===void 0||!(`set`in e)||sa(e.set))&&(e.container===void 0||!(`container`in e)||ra(e.container))&&(e.attributes===void 0||!(`attributes`in e)||ca(e.attributes))&&(e.expect===void 0||!(`expect`in e)||pa(e.expect))&&(e.locations===void 0||!(`locations`in e)||ma(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||_a(e.artifacts))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`label`in e)),sa=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>Yi[8].test(e)||!1)&&(e.label===void 0||!(`label`in e)||ta(e.label))&&(e.kind===void 0||!(`kind`in e)||na(e.kind))&&(e.container===void 0||!(`container`in e)||ra(e.container))&&(e.attributes===void 0||!(`attributes`in e)||ca(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||fa(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),ca=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((t,n)=>Yi[9].test(t)||la(e[t]))&&Object.getOwnPropertyNames(e).every((e,t)=>typeof e!=`string`||fr(e,200)&&pr(e,1))&&Object.getOwnPropertyNames(e).length<=50),la=(e=>[ua(e),da(e),Array.isArray(e)&&e.every((e,t)=>[ua(e),da(e)].reduce((e,t,n)=>t===!0?++e:e,0)===1)&&e.length<=50].reduce((e,t,n)=>t===!0?++e:e,0)===1),ua=(e=>(typeof e==`string`||Number.isFinite(e)||typeof e==`boolean`||e===null)&&(typeof e!=`string`||fr(e,1e3))),da=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`ref`in e&&Object.getOwnPropertyNames(e).length===1&&Qi(e.ref)),fa=(e=>Array.isArray(e)&&e.every((e,t)=>ra(e))&&e.length<=50),pa=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>Yi[10].test(e)||!1)&&(e.label===void 0||!(`label`in e)||ta(e.label))&&(e.kind===void 0||!(`kind`in e)||na(e.kind))&&(e.container===void 0||!(`container`in e)||ra(e.container))&&(e.revision===void 0||!(`revision`in e)||$i(e.revision))&&(e.attributes===void 0||!(`attributes`in e)||ca(e.attributes))&&Object.getOwnPropertyNames(e).length>=1),ma=(e=>Array.isArray(e)&&e.every((e,t)=>ha(e))&&e.length<=10),ha=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`uri`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Yi[11].test(e)||!1)&&typeof e.uri==`string`&&fr(e.uri,2e3)&&pr(e.uri,1)&&(e.revision===void 0||!(`revision`in e)||$i(e.revision))&&(e.range===void 0||!(`range`in e)||typeof e.range==`object`&&e.range!==null&&!Array.isArray(e.range)&&`startLine`in e.range&&`endLine`in e.range&&Object.getOwnPropertyNames(e.range).every((e,t)=>Yi[12].test(e)||!1)&&ga(e.range.startLine)&&(e.range.startCharacter===void 0||!(`startCharacter`in e.range)||ga(e.range.startCharacter))&&ga(e.range.endLine)&&(e.range.endCharacter===void 0||!(`endCharacter`in e.range)||ga(e.range.endCharacter)))),ga=(e=>Number.isInteger(e)&&(!(Number.isFinite(e)||typeof e==`bigint`)||e<=1e6&&e>=0)),_a=(e=>Array.isArray(e)&&e.every((e,t)=>ia(e))&&e.length<=20),va=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Yi[13].test(e)||!1)&&ra(e.from)&&ra(e.to)&&(e.kind===void 0||!(`kind`in e)||na(e.kind))&&(e.ref===void 0||!(`ref`in e)||Qi(e.ref))&&(e.label===void 0||!(`label`in e)||ta(e.label))&&(e.set===void 0||!(`set`in e)||ya(e.set))&&(e.attributes===void 0||!(`attributes`in e)||ca(e.attributes))&&(e.expect===void 0||!(`expect`in e)||pa(e.expect))&&(e.locations===void 0||!(`locations`in e)||ma(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||_a(e.artifacts))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`kind`in e)),ya=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>Yi[14].test(e)||!1)&&(e.kind===void 0||!(`kind`in e)||na(e.kind))&&(e.label===void 0||!(`label`in e)||ta(e.label))&&(e.attributes===void 0||!(`attributes`in e)||ca(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||fa(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),ba=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&`label`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Yi[15].test(e)||!1)&&ra(e.id)&&ta(e.label)&&(e.kind===void 0||!(`kind`in e)||na(e.kind))),xa=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Yi[17].test(e)||!1)&&ra(e.from)&&ra(e.to)&&(e.ref===void 0||!(`ref`in e)||Qi(e.ref))&&(e.label===void 0||!(`label`in e)||ta(e.label))&&(e.set===void 0||!(`set`in e)||Sa(e.set))&&(e.attributes===void 0||!(`attributes`in e)||ca(e.attributes))&&(e.expect===void 0||!(`expect`in e)||pa(e.expect))&&(e.locations===void 0||!(`locations`in e)||ma(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||_a(e.artifacts))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`label`in e)),Sa=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>Yi[18].test(e)||!1)&&(e.label===void 0||!(`label`in e)||ta(e.label))&&(e.attributes===void 0||!(`attributes`in e)||ca(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||fa(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),Ca=(e=>Array.isArray(e)&&e.every((e,t)=>(typeof e==`string`||Number.isFinite(e)||typeof e==`boolean`||e===null)&&(typeof e!=`string`||fr(e,1e3)))&&e.length<=50),wa=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`cells`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Yi[20].test(e)||!1)&&Ca(e.cells)&&(e.role===void 0||!(`role`in e)||Ta(e.role))&&(e.id===void 0||!(`id`in e)||ra(e.id))&&(e.ref===void 0||!(`ref`in e)||Qi(e.ref))&&(e.kind===void 0||!(`kind`in e)||na(e.kind))&&(e.label===void 0||!(`label`in e)||ta(e.label))&&(e.set===void 0||!(`set`in e)||Ea(e.set))&&(e.attributes===void 0||!(`attributes`in e)||ca(e.attributes))&&(e.expect===void 0||!(`expect`in e)||pa(e.expect))&&(e.locations===void 0||!(`locations`in e)||ma(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||_a(e.artifacts))),Ta=(e=>e===`added`||e===`changed`||e===`context`||e===`removed`),Ea=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>Yi[21].test(e)||!1)&&(e.label===void 0||!(`label`in e)||ta(e.label))&&(e.kind===void 0||!(`kind`in e)||na(e.kind))&&(e.cells===void 0||!(`cells`in e)||Ca(e.cells))&&(e.attributes===void 0||!(`attributes`in e)||ca(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||fa(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),Da=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`heading`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Yi[22].test(e)||!1)&&typeof e.heading==`string`&&fr(e.heading,500)&&pr(e.heading,1)&&(e.depth===void 0||!(`depth`in e)||Number.isInteger(e.depth)&&(!(Number.isFinite(e.depth)||typeof e.depth==`bigint`)||e.depth<=6&&e.depth>=1))&&(e.role===void 0||!(`role`in e)||Ta(e.role))&&(e.id===void 0||!(`id`in e)||ra(e.id))&&(e.ref===void 0||!(`ref`in e)||Qi(e.ref))),Oa=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&`kind`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Yi[23].test(e)||!1)&&ka(e.from)&&ka(e.to)&&na(e.kind)&&(e.ref===void 0||!(`ref`in e)||Qi(e.ref))&&(e.label===void 0||!(`label`in e)||ta(e.label))&&(e.attributes===void 0||!(`attributes`in e)||ca(e.attributes))),ka=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>Yi[24].test(e)||!1)&&(e.id===void 0||!(`id`in e)||ra(e.id))&&(e.ref===void 0||!(`ref`in e)||Qi(e.ref))&&Object.getOwnPropertyNames(e).length>=1&&Object.getOwnPropertyNames(e).length<=1&&[!(typeof e==`object`&&e&&!Array.isArray(e))||`id`in e,!(typeof e==`object`&&e&&!Array.isArray(e))||`ref`in e].reduce((e,t,n)=>t===!0?++e:e,0)===1),Aa=(e=>typeof e==`string`&&Yi[26].test(e)),ja=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&(e.type===`task`||e.type===`separator`)&&(typeof e!=`object`||!e||Array.isArray(e)||e.type===void 0||!(`type`in e)||e.type===`task`?Ma(e):!0)&&(typeof e!=`object`||!e||Array.isArray(e)||e.type===void 0||!(`type`in e)||e.type===`separator`?La(e):!0)),Ma=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&`id`in e&&`label`in e&&`items`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Yi[27].test(e)||!1)&&e.type===`task`&&ra(e.id)&&ta(e.label)&&Array.isArray(e.items)&&e.items.every((e,t)=>Na(e))&&e.items.length<=100&&(e.role===void 0||!(`role`in e)||Fa(e.role))),Na=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&(e.type===`activity`||e.type===`milestone`)&&(typeof e!=`object`||!e||Array.isArray(e)||e.type===void 0||!(`type`in e)||e.type===`activity`?Pa(e):!0)&&(typeof e!=`object`||!e||Array.isArray(e)||e.type===void 0||!(`type`in e)||e.type===`milestone`?Ia(e):!0)),Pa=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&`start`in e&&`end`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Yi[28].test(e)||!1)&&e.type===`activity`&&Aa(e.start)&&Aa(e.end)&&(e.id===void 0||!(`id`in e)||ra(e.id))&&(e.label===void 0||!(`label`in e)||ta(e.label))&&(e.kind===void 0||!(`kind`in e)||na(e.kind))&&(e.previous===void 0||!(`previous`in e)||typeof e.previous==`object`&&e.previous!==null&&!Array.isArray(e.previous)&&`start`in e.previous&&`end`in e.previous&&Object.getOwnPropertyNames(e.previous).length===2&&Aa(e.previous.start)&&Aa(e.previous.end))&&(e.role===void 0||!(`role`in e)||Fa(e.role))),Fa=(e=>e===`added`||e===`removed`),Ia=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&`date`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Yi[29].test(e)||!1)&&e.type===`milestone`&&Aa(e.date)&&(e.id===void 0||!(`id`in e)||ra(e.id))&&(e.label===void 0||!(`label`in e)||ta(e.label))&&(e.kind===void 0||!(`kind`in e)||na(e.kind))&&(e.previous===void 0||!(`previous`in e)||typeof e.previous==`object`&&e.previous!==null&&!Array.isArray(e.previous)&&`date`in e.previous&&Object.getOwnPropertyNames(e.previous).length===1&&Aa(e.previous.date))&&(e.role===void 0||!(`role`in e)||Fa(e.role))),La=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Yi[30].test(e)||!1)&&e.type===`separator`&&(e.label===void 0||!(`label`in e)||ta(e.label))),Ra=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Yi[31].test(e)||!1)&&ra(e.from)&&ra(e.to)&&(e.type===void 0||!(`type`in e)||e.type===`finish-to-start`||e.type===`start-to-start`||e.type===`finish-to-finish`||e.type===`start-to-finish`)),za=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`start`in e&&`end`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Yi[33].test(e)||!1)&&Aa(e.start)&&Aa(e.end)&&(e.label===void 0||!(`label`in e)||ta(e.label))&&(e.kind===void 0||!(`kind`in e)||na(e.kind))),Ba=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`date`in e&&`label`in e&&Object.getOwnPropertyNames(e).every((e,t)=>Yi[34].test(e)||!1)&&Aa(e.date)&&typeof e.label==`string`&&fr(e.label,500)&&pr(e.label,1)&&(e.kind===void 0||!(`kind`in e)||na(e.kind)));function Va(e){return Zi(e)}Xi({variables:[RegExp(`(^schema$|^kind$|^profile$|^target$|^removals$|^artifacts$|^viewpoints$|^data$)`,`u`),RegExp(`(^ref$|^revision$)`,`u`),RegExp(`(^type$|^ref$|^label$|^kind$|^from$|^to$)`,`u`),RegExp(`(^rel$|^uri$|^sha256$|^mediaType$|^label$)`,`u`),RegExp(`^sha256:[0-9a-f]{64}$`,`u`),RegExp(`(^id$|^label$|^concern$|^elementKinds$|^relationshipKinds$)`,`u`),RegExp(`(^nodes$|^edges$|^containers$)`,`u`),RegExp(`(^id$|^ref$|^label$|^kind$|^set$|^container$|^attributes$|^expect$|^locations$|^artifacts$)`,`u`),RegExp(`(^label$|^kind$|^container$|^attributes$|^removeAttributes$)`,`u`),RegExp(`(?!)`,`u`),RegExp(`(^label$|^kind$|^container$|^revision$|^attributes$)`,`u`),RegExp(`(^uri$|^revision$|^range$)`,`u`),RegExp(`(^startLine$|^startCharacter$|^endLine$|^endCharacter$)`,`u`),RegExp(`(^from$|^to$|^kind$|^ref$|^label$|^set$|^attributes$|^expect$|^locations$|^artifacts$)`,`u`),RegExp(`(^kind$|^label$|^attributes$|^removeAttributes$)`,`u`),RegExp(`(^id$|^label$|^kind$)`,`u`),RegExp(`(^participants$|^messages$|^containers$)`,`u`),RegExp(`(^from$|^to$|^ref$|^label$|^set$|^attributes$|^expect$|^locations$|^artifacts$)`,`u`),RegExp(`(^label$|^attributes$|^removeAttributes$)`,`u`),RegExp(`(^columns$|^rows$|^relations$)`,`u`),RegExp(`(^cells$|^role$|^id$|^ref$|^kind$|^label$|^set$|^attributes$|^expect$|^locations$|^artifacts$)`,`u`),RegExp(`(^label$|^kind$|^cells$|^attributes$|^removeAttributes$)`,`u`),RegExp(`(^heading$|^depth$|^role$|^id$|^ref$)`,`u`),RegExp(`(^from$|^to$|^kind$|^ref$|^label$|^attributes$)`,`u`),RegExp(`(^id$|^ref$)`,`u`),RegExp(`(^title$|^time$|^rows$|^dependencies$|^comparedTo$|^periods$|^references$)`,`u`),RegExp(`^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$`,`u`),RegExp(`(^type$|^id$|^label$|^items$|^role$)`,`u`),RegExp(`(^type$|^start$|^end$|^id$|^label$|^kind$|^previous$|^role$)`,`u`),RegExp(`(^type$|^date$|^id$|^label$|^kind$|^previous$|^role$)`,`u`),RegExp(`(^type$|^label$)`,`u`),RegExp(`(^from$|^to$|^type$)`,`u`),RegExp(`(^label$|^date$)`,`u`),RegExp(`(^start$|^end$|^label$|^kind$)`,`u`),RegExp(`(^date$|^label$|^kind$)`,`u`)]});var Ha={[et]:Ir,[ot]:Ji,[lt]:Va},Ua=e=>{let t=Ln(e),n=dt(t);return n===void 0&&t!==void 0?[{rule:`unsupported-version`,path:`/schema`,message:`this build validates ${ut.join(` and `)}`}]:Ha[n??`urn:structured-exchange:1`](e)?[]:[{rule:`schema/invalid`,path:``,message:`does not conform to the published structured-exchange schema`}]},Wa=Object.defineProperty,Ga=(e,t,n)=>t in e?Wa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ka=(e,t)=>{for(var n in t)Wa(e,n,{get:t[n],enumerable:!0})},qa=(e,t,n)=>Ga(e,typeof t==`symbol`?t:t+``,n),Ja={};Ka(Ja,{Graph:()=>Po,alg:()=>so});var Ya=Object.defineProperty,Xa=(e,t)=>{for(var n in t)Ya(e,n,{get:t[n],enumerable:!0})},Za=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected=`directed`in e?e.directed:!0,this._isMultigraph=`multigraph`in e&&e.multigraph,this._isCompound=`compound`in e&&e.compound),this._isCompound&&(this._parent={},this._children={},this._children[`\0`]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=typeof e==`function`?e:()=>e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(e=>{t===void 0?this.setNode(e):this.setNode(e,t)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=`\0`,this._children[e]={},this._children[`\0`][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=e=>this.removeEdge(this._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(e=>{this.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error(`Cannot set parent in a non-compound graph`);if(t===void 0)t=`\0`;else{t+=``;for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw Error(`Setting `+t+` as parent of `+e+` would create a cycle`);this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!==`\0`)return t}}children(e=`\0`){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e===`\0`)return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t),r=this.successors(e);if(r)for(let e of r)n.add(e);return Array.from(n.values())}}isLeaf(e){let t;return t=this.isDirected()?this.successors(e):this.neighbors(e),(t?.length??0)===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([n,r])=>{e(n)&&t.setNode(n,r)}),Object.values(this._edgeObjs).forEach(e=>{t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,this.edge(e))});let n={},r=e=>{let i=this.parent(e);return!i||t.hasNode(i)?(n[e]=i,i):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,r(e))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=typeof e==`function`?e:()=>e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((e,n)=>(t===void 0?this.setEdge(e,n):this.setEdge(e,n,t),n)),this}setEdge(e,t,n,r){let i,a,o,s,c=!1;typeof e==`object`&&e&&`v`in e?(i=e.v,a=e.w,o=e.name,arguments.length===2&&(s=t,c=!0)):(i=e,a=t,o=r,arguments.length>2&&(s=n,c=!0)),i=``+i,a=``+a,o!==void 0&&(o=``+o);let l=eo(this._isDirected,i,a,o);if(l in this._edgeLabels)return c&&(this._edgeLabels[l]=s),this;if(o!==void 0&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(i),this.setNode(a),this._edgeLabels[l]=c?s:this._defaultEdgeLabelFn(i,a,o);let u=to(this._isDirected,i,a,o);return i=u.v,a=u.w,Object.freeze(u),this._edgeObjs[l]=u,Qa(this._preds[a],i),Qa(this._sucs[i],a),this._in[a][l]=u,this._out[i][l]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?no(this._isDirected,e):eo(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r!=`object`||!r?{label:r}:r}hasEdge(e,t,n){return(arguments.length===1?no(this._isDirected,e):eo(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?no(this._isDirected,e):eo(this._isDirected,e,t,n),i=this._edgeObjs[r];if(i){let e=i.v,t=i.w;delete this._edgeLabels[r],delete this._edgeObjs[r],$a(this._preds[t],e),$a(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(e=>e.v===t&&e.w===n||e.v===n&&e.w===t):r}};function Qa(e,t){e[t]?e[t]++:e[t]=1}function $a(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function eo(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}return i+``+a+``+(r===void 0?`\0`:r)}function to(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}let o={v:i,w:a};return r&&(o.name=r),o}function no(e,t){return eo(e,t.v,t.w,t.name)}Xa({},{read:()=>oo,write:()=>ro});function ro(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:io(e),edges:ao(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function io(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),i={v:t};return n!==void 0&&(i.value=n),r!==void 0&&(i.parent=r),i})}function ao(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function oo(e){let t=new Za(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(e=>{t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(e=>{t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}var so={};Xa(so,{CycleException:()=>Co,bellmanFord:()=>lo,components:()=>fo,dijkstra:()=>ho,dijkstraAll:()=>_o,findCycles:()=>yo,floydWarshall:()=>xo,isAcyclic:()=>To,postorder:()=>ko,preorder:()=>Ao,prim:()=>jo,shortestPaths:()=>Mo,tarjan:()=>vo,topsort:()=>wo});var co=()=>1;function lo(e,t,n,r){return uo(e,String(t),n||co,r||function(t){return e.outEdges(t)??[]})}function uo(e,t,n,r){let i={},a,o=0,s=e.nodes(),c=function(e){let t=i[e.v],r=i[e.w];if(!t||!r)return;let o=n(e);t.distance+o<r.distance&&(i[e.w]={distance:t.distance+o,predecessor:e.v},a=!0)},l=function(){s.forEach(function(e){r(e).forEach(function(t){let n=t.v===e?t.v:t.w,r=n===t.v?t.w:t.v;c({v:n,w:r})})})};s.forEach(function(e){i[e]={distance:e===t?0:1/0,predecessor:``}});let u=s.length;for(let e=1;e<u&&(a=!1,o++,l(),a);e++);if(o===u-1&&(a=!1,l(),a))throw Error(`The graph contains a negative weight cycle`);return i}function fo(e){let t={},n=[],r;function i(n){var a,o;n in t||(t[n]=!0,r.push(n),(a=e.successors(n))==null||a.forEach(i),(o=e.predecessors(n))==null||o.forEach(i))}return e.nodes().forEach(function(e){r=[],i(e),r.length&&n.push(r)}),n}var po=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw Error(`Queue underflow`);return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let e=this._arr,i=e.length;return n[r]=i,e.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){if(this.size()===0)throw Error(`Queue underflow`);this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,i=n[e],a=n[t];n[e]=a,n[t]=i,r[a.key]=e,r[i.key]=t}},mo=()=>1;function ho(e,t,n,r){return go(e,String(t),n||mo,r||function(t){return e.outEdges(t)??[]})}function go(e,t,n,r){let i={},a=new po,o,s,c=function(e){let t=e.v===o?e.w:e.v,r=i[t];if(!r)return;let c=n(e),l=s.distance+c;if(c<0)throw Error(`dijkstra does not allow negative edge weights. Bad edge: `+e+` Weight: `+c);l<r.distance&&(r.distance=l,r.predecessor=o,a.decrease(t,l))};for(e.nodes().forEach(function(e){let n=e===t?0:1/0;i[e]={distance:n,predecessor:``},a.add(e,n)});a.size()>0;){o=a.removeMin();let e=i[o];if(!e||e.distance===1/0)break;s=e,r(o).forEach(c)}return i}function _o(e,t,n){return e.nodes().reduce(function(r,i){return r[i]=ho(e,i,t,n),r},{})}function vo(e){let t=0,n=[],r={},i=[];function a(o){var s;let c=r[o]={onStack:!0,lowlink:t,index:t++};if(n.push(o),(s=e.successors(o))==null||s.forEach(function(e){if(e in r){let t=r[e];t!=null&&t.onStack&&(c.lowlink=Math.min(c.lowlink,t.index))}else{a(e);let t=r[e];t&&(c.lowlink=Math.min(c.lowlink,t.lowlink))}}),c.lowlink===c.index){let e=[],t;do{t=n.pop();let i=r[t];i&&(i.onStack=!1),e.push(t)}while(o!==t);i.push(e)}}return e.nodes().forEach(function(e){e in r||a(e)}),i}function yo(e){return vo(e).filter(function(t){let n=t[0];return n?t.length>1||t.length===1&&(e.outEdges(n,n)??[]).length>0:!1})}var bo=()=>1;function xo(e,t,n){return So(e,t||bo,n||function(t){return e.outEdges(t)??[]})}function So(e,t,n){let r={},i=e.nodes();return i.forEach(function(e){let a={};r[e]=a,a[e]={distance:0,predecessor:``},i.forEach(function(t){e!==t&&(a[t]={distance:1/0,predecessor:``})}),n(e).forEach(function(n){let r=n.v===e?n.w:n.v,i=t(n);a[r]={distance:i,predecessor:e}})}),i.forEach(function(e){let t=r[e];t&&i.forEach(function(n){let a=r[n];a&&i.forEach(function(n){let r=a[e],i=t[n],o=a[n];if(r&&i&&o){let e=r.distance+i.distance;e<o.distance&&(o.distance=e,o.predecessor=i.predecessor)}})})}),r}var Co=class extends Error{constructor(e){super(e),this.name=`CycleException`}};function wo(e){let t={},n={},r=[];function i(a){var o;if(a in n)throw new Co;a in t||(n[a]=!0,t[a]=!0,(o=e.predecessors(a))==null||o.forEach(i),delete n[a],r.push(a))}if(e.sinks().forEach(i),Object.keys(t).length!==e.nodeCount())throw new Co;return r}function To(e){try{wo(e)}catch(e){if(e instanceof Co)return!1;throw e}return!0}function Eo(e,t,n,r,i){Array.isArray(t)||(t=[t]);let a=(t=>(e.isDirected()?e.successors(t):e.neighbors(t))??[]),o={};return t.forEach(function(t){if(!e.hasNode(t))throw Error(`Graph does not have node: `+t);i=Do(e,t,n===`post`,o,a,r,i)}),i}function Do(e,t,n,r,i,a,o){return t in r||(r[t]=!0,n||(o=a(o,t)),i(t).forEach(function(t){o=Do(e,t,n,r,i,a,o)}),n&&(o=a(o,t))),o}function Oo(e,t,n){return Eo(e,t,n,function(e,t){return e.push(t),e},[])}function ko(e,t){return Oo(e,t,`post`)}function Ao(e,t){return Oo(e,t,`pre`)}function jo(e,t){var n;let r=new Za,i={},a=new po,o;function s(e){let n=e.v===o?e.w:e.v,r=a.priority(n);if(r!==void 0){let s=t(e);s<r&&(i[n]=o,a.decrease(n,s))}}if(e.nodeCount()===0)return r;e.nodes().forEach(function(e){a.add(e,1/0),r.setNode(e)});let c=e.nodes()[0];c!==void 0&&a.decrease(c,0);let l=!1;for(;a.size()>0;){if(o=a.removeMin(),o in i)r.setEdge(o,i[o]);else{if(l)throw Error(`Input graph is not connected: `+e);l=!0}(n=e.nodeEdges(o))==null||n.forEach(s)}return r}function Mo(e,t,n,r){return No(e,t,n,r??(t=>e.outEdges(t)??[]))}function No(e,t,n,r){if(n===void 0)return ho(e,t,n,r);let i=!1,a=e.nodes();for(let o=0;o<a.length;o++){let s=a[o];if(s===void 0)continue;let c=r(s);for(let e=0;e<c.length;e++){let t=c[e];if(!t)continue;let r=t.v===s?t.v:t.w;n({v:r,w:r===t.v?t.w:t.v})<0&&(i=!0)}if(i)return lo(e,t,n,r)}return ho(e,t,n,r)}var Po=Za;function Fo(e,t,n,r){let i=r;for(;e.hasNode(i);)i=Zo(r);return n.dummy=t,e.setNode(i,n),i}function Io(e){let t=new Po().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function Lo(e){let t=new Po({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function Ro(e,t){let n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw Error(`Not possible to find intersection inside of the rectangle`);let c,l;return Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function zo(e){let t=Qo(Ko(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),i=r.rank;i!==void 0&&(t[i]||(t[i]=[]),t[i][r.order]=n)}),t}function Bo(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=Go(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function Vo(e){let t=e.nodes().map(t=>e.node(t).rank).filter(e=>e!==void 0),n=Go(Math.min,t),r=[];e.nodes().forEach(t=>{let i=e.node(t).rank-n;r[i]||(r[i]=[]),r[i].push(t)});let i=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,n)=>{t===void 0&&n%a!==0?--i:t!==void 0&&i&&t.forEach(t=>e.node(t).rank+=i)})}function Ho(e,t,n,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),Fo(e,`border`,i,t)}function Uo(e,t=Wo){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var Wo=65535;function Go(e,t){return t.length>Wo?e(...Uo(t).map(t=>e(...t))):e(...t)}function Ko(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return Go(Math.max,t)}function qo(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function Jo(e,t){let n=Date.now();try{return t()}finally{console.log(e+` time: `+(Date.now()-n)+`ms`)}}function Yo(e,t){return t()}var Xo=0;function Zo(e){return e+(``+ ++Xo)}function Qo(e,t,n=1){t??(t=e,e=0);let r=e=>e<t;n<0&&(r=e=>t<e);let i=[];for(let t=e;r(t);t+=n)i.push(t);return i}function $o(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function es(e,t){let n;return n=typeof t==`string`?e=>e[t]:t,Object.entries(e).reduce((e,[t,r])=>(e[t]=n(r,t),e),{})}function ts(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}var ns=`\0`;function rs(e,t,n){if(!(e&&t&&n&&t.dummy===`edge`&&n.dummy===`edge`&&t.edgeObj&&n.edgeObj&&e[t.edgeObj.v]&&e[n.edgeObj.v]&&e[t.edgeObj.w]&&e[n.edgeObj.w]))return 0;let r=!0;t.edgeObj.w===n.edgeObj.w&&(r=!1);let i=r?e[t.edgeObj.v]?.rank??NaN:e[t.edgeObj.w]?.rank??NaN,a=Object.entries(e).find(e=>e[1].edgeObj?.v===t.edgeObj.v&&e[1].edgeObj?.w===t.edgeObj.w&&e[1].rank===i),o=Object.entries(e).find(e=>e[1].edgeObj?.v===n.edgeObj.v&&e[1].edgeObj?.w===n.edgeObj.w&&e[1].rank===i);if(!a||!o)return 0;let s=a[1].order??NaN,c=o[1].order??NaN;return isNaN(s-c)?0:s-c}var is=`3.1.1`,as=class{constructor(){qa(this,`_sentinel`);let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return os(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&os(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,ss)),n=n._prev;return`[`+e.join(`, `)+`]`}};function os(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function ss(e,t){if(e!==`_next`&&e!==`_prev`)return t}var cs=as,ls=()=>1;function us(e,t){if(e.nodeCount()<=1)return[];let n=ps(e,t||ls);return ds(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w)||[])}function ds(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)fs(e,t,n,o);for(;o=i.dequeue();)fs(e,t,n,o);if(e.nodeCount()){for(let i=t.length-2;i>0;--i)if(o=t[i]?.dequeue(),o){r=r.concat(fs(e,t,n,o,!0)||[]);break}}}return r}function fs(e,t,n,r,i){let a=[],o=i?a:void 0;return(e.inEdges(r.v)||[]).forEach(r=>{let o=e.edge(r),s=e.node(r.v);i&&a.push({v:r.v,w:r.w}),s.out-=o,ms(t,n,s)}),(e.outEdges(r.v)||[]).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,ms(t,n,o)}),e.removeNode(r.v),o}function ps(e,t){let n=new Po,r=0,i=0;e.nodes().forEach(e=>{n.setNode(e,{v:e,in:0,out:0})}),e.edges().forEach(e=>{let a=n.edge(e.v,e.w)||0,o=t(e),s=a+o;n.setEdge(e.v,e.w,s);let c=n.node(e.v),l=n.node(e.w);i=Math.max(i,c.out+=o),r=Math.max(r,l.in+=o)});let a=hs(i+r+3).map(()=>new cs),o=r+1;return n.nodes().forEach(e=>{ms(a,o,n.node(e))}),{graph:n,buckets:a,zeroIdx:o}}function ms(e,t,n){var r,i,a;n.out?n.in?(a=e[n.out-n.in+t])==null||a.enqueue(n):(i=e[e.length-1])==null||i.enqueue(n):(r=e[0])==null||r.enqueue(n)}function hs(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function gs(e,t){(e.graph().acyclicer===`greedy`?us(e,n(e)):_s(e,t??null)).forEach(t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,Zo(`rev`))});function n(e){return t=>e.edge(t).weight}}function _s(e,t){let n=[],r={},i={};function a(t){Object.hasOwn(i,t)||(i[t]=!0,r[t]=!0,e.outEdges(t).forEach(e=>{Object.hasOwn(r,e.w)?n.push(e):a(e.w)}),delete r[t])}function o(a){var s;Object.hasOwn(i,a)||(i[a]=!0,r[a]=!0,(s=e.outEdges(a))==null||s.forEach(i=>{Object.hasOwn(r,i.w)||t.node(a)?.rank>t.node(i.w)?.rank&&ys(e,i.w,i)?n.push(i):o(i.w)}),delete r[a])}let s=a;return t&&typeof t.node==`function`&&(s=o),e.sources().forEach(s),e.nodes().forEach(s),n}function vs(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function ys(e,t,n){let r=new Set;function i(t){if(e.sources().includes(t))return!0;r.add(t);for(let a of e.inEdges(t)??[])if((a.v!==n.v||a.w!==n.w)&&!r.has(a.v)&&i(a.v))return!0;return!1}return i(t)}function bs(e){e.graph().dummyChains=[],e.edges().forEach(t=>xs(e,t))}function xs(e,t){let n=t.v,r=e.node(n).rank,i=t.w,a=e.node(i).rank,o=t.name,s=e.edge(t),c=s.labelRank;if(a===r+1)return;e.removeEdge(t);let l,u,d=0;for(++r;r<a;++d,++r)s.points=[],u={width:0,height:0,edgeLabel:s,edgeObj:t,rank:r},l=Fo(e,`edge`,u,`_d`),r===c&&(u.width=s.width,u.height=s.height,u.dummy=`edge-label`,u.labelpos=s.labelpos),e.setEdge(n,l,{weight:s.weight},o),d===0&&e.graph().dummyChains.push(l),n=l;e.setEdge(n,i,{weight:s.weight},o)}function Ss(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy===`edge-label`&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}function Cs(e){let t={};function n(r){let i=e.node(r);if(Object.hasOwn(t,r))return i.rank;t[r]=!0;let a=e.outEdges(r),o=a?a.map(t=>t==null?1/0:n(t.w)-e.edge(t).minlen):[],s=Go(Math.min,o);return s===1/0&&(s=0),i.rank=s}e.sources().forEach(n)}function ws(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var Ts=Es;function Es(e){let t=new Po({directed:!1}),n=e.nodes();if(n.length===0)throw Error(`Graph must have at least one node`);let r=n[0],i=e.nodeCount();t.setNode(r,{});let a,o;for(;Ds(t,e)<i&&(a=Os(t,e),a);)o=t.hasNode(a.v)?ws(e,a):-ws(e,a),ks(t,e,o);return t}function Ds(e,t){function n(r){let i=t.nodeEdges(r);i&&i.forEach(i=>{let a=i.v,o=r===a?i.w:a;!e.hasNode(o)&&!ws(t,i)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function Os(e,t){return t.edges().reduce((n,r)=>{let i=1/0;return e.hasNode(r.v)!==e.hasNode(r.w)&&(i=ws(t,r)),i<n[0]?[i,r]:n},[1/0,null])[1]}function ks(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}var{preorder:As,postorder:js}=so,Ms=Ns;Ns.initLowLimValues=Ls,Ns.initCutValues=Ps,Ns.calcCutValue=Is,Ns.leaveEdge=zs,Ns.enterEdge=Bs,Ns.exchangeEdges=Vs;function Ns(e){e=Io(e),Cs(e);let t=Ts(e);Ls(t),Ps(t,e);let n,r;for(;n=zs(t);)r=Bs(t,e,n),Vs(t,e,n,r)}function Ps(e,t){let n=js(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>Fs(e,t,n))}function Fs(e,t,n){let r=e.node(n).parent,i=e.edge(n,r);i.cutvalue=Is(e,t,n)}function Is(e,t,n){let r=e.node(n).parent,i=!0,a=t.edge(n,r),o=0;a||=(i=!1,t.edge(r,n)),o=a.weight;let s=t.nodeEdges(n);return s&&s.forEach(a=>{let s=a.v===n,c=s?a.w:a.v;if(c!==r){let r=s===i,l=t.edge(a).weight;if(o+=r?l:-l,Us(e,n,c)){let t=e.edge(n,c).cutvalue;o+=r?-t:t}}}),o}function Ls(e,t){arguments.length<2&&(t=e.nodes()[0]),Rs(e,{},1,t)}function Rs(e,t,n,r,i){let a=n,o=e.node(r);t[r]=!0;let s=e.neighbors(r);return s&&s.forEach(i=>{Object.hasOwn(t,i)||(n=Rs(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function zs(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function Bs(e,t,n){let r=n.v,i=n.w;t.hasEdge(r,i)||(r=n.w,i=n.v);let a=e.node(r),o=e.node(i),s=a,c=!1;return a.lim>o.lim&&(s=o,c=!0),t.edges().filter(t=>c===Ws(e,e.node(t.v),s)&&c!==Ws(e,e.node(t.w),s)).reduce((e,n)=>ws(t,n)<ws(t,e)?n:e)}function Vs(e,t,n,r){let i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),Ls(e),Ps(e,t),Hs(e,t)}function Hs(e,t){let n=e.nodes().find(t=>!e.node(t).parent);if(!n)return;let r=As(e,[n]);r=r.slice(1),r.forEach(n=>{let r=e.node(n).parent,i=t.edge(n,r),a=!1;i||(i=t.edge(r,n),a=!0),t.node(n).rank=t.node(r).rank+(a?i.minlen:-i.minlen)})}function Us(e,t,n){return e.hasEdge(t,n)}function Ws(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var Gs=Ks;function Ks(e){let t=e.graph().ranker;if(typeof t==`function`)return t(e);switch(t){case`network-simplex`:Ys(e);break;case`tight-tree`:Js(e);break;case`longest-path`:qs(e);break;case`none`:break;default:Ys(e)}}var qs=Cs;function Js(e){Cs(e),Ts(e)}function Ys(e){Ms(e)}var Xs=Zs;function Zs(e){let t=$s(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(n=>{let r=e.node(n),i=r.edgeObj,a=Qs(e,t,i.v,i.w),o=a.path,s=a.lca,c=0,l=o[c],u=!0;for(;n!==i.w;){if(r=e.node(n),u){for(;(l=o[c])!==s&&e.node(l).maxRank<r.rank;)c++;l===s&&(u=!1)}if(!u){for(;c<o.length-1&&e.node(o[c+1]).minRank<=r.rank;)c++;l=o[c]}l!==void 0&&e.setParent(n,l),n=e.successors(n)[0]}})}function Qs(e,t,n,r){let i=[],a=[],o=Math.min(t[n].low,t[r].low),s=Math.max(t[n].lim,t[r].lim),c;c=n;do c=e.parent(c),i.push(c);while(c&&(t[c].low>o||s>t[c].lim));let l=c,u=r;for(;(u=e.parent(u))!==l;)a.push(u);return{path:i.concat(a.reverse()),lca:l}}function $s(e){let t={},n=0;function r(i){let a=n;e.children(i).forEach(r),t[i]={low:a,lim:n++}}return e.children(ns).forEach(r),t}function ec(e){let t=Fo(e,`root`,{},`_root`),n=nc(e),r=Object.values(n),i=Go(Math.max,r)-1,a=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=a);let o=rc(e)+1;e.children(ns).forEach(r=>{tc(e,t,a,o,i,n,r)}),e.graph().nodeRankFactor=a}function tc(e,t,n,r,i,a,o){let s=e.children(o);if(!s.length){o!==t&&e.setEdge(t,o,{weight:0,minlen:n});return}let c=Ho(e,`_bt`),l=Ho(e,`_bb`),u=e.node(o);e.setParent(c,o),u.borderTop=c,e.setParent(l,o),u.borderBottom=l,s.forEach(s=>{tc(e,t,n,r,i,a,s);let u=e.node(s),d=u.borderTop?u.borderTop:s,f=u.borderBottom?u.borderBottom:s,p=u.borderTop?r:2*r,m=d===f?i-(a[o]??0)+1:1;e.setEdge(c,d,{weight:p,minlen:m,nestingEdge:!0}),e.setEdge(f,l,{weight:p,minlen:m,nestingEdge:!0})}),e.parent(o)||e.setEdge(t,c,{weight:0,minlen:i+(a[o]??0)})}function nc(e){let t={};function n(r,i){let a=e.children(r);a&&a.length&&a.forEach(e=>n(e,i+1)),t[r]=i}return e.children(ns).forEach(e=>n(e,1)),t}function rc(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function ic(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}var ac=oc;function oc(e){function t(n){let r=e.children(n),i=e.node(n);if(r.length&&r.forEach(t),i&&Object.hasOwn(i,`minRank`)){i.borderLeft=[],i.borderRight=[];for(let t=i.minRank,r=i.maxRank+1;t<r;++t)sc(e,`borderLeft`,`_bl`,n,i,t),sc(e,`borderRight`,`_br`,n,i,t)}}e.children(ns).forEach(t)}function sc(e,t,n,r,i,a){let o={width:0,height:0,rank:a,borderType:t},s=i[t][a-1],c=Fo(e,`border`,o,n);i[t][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}function cc(e){let t=e.graph().rankdir?.toLowerCase();(t===`lr`||t===`rl`)&&uc(e)}function lc(e){let t=e.graph().rankdir?.toLowerCase();(t===`bt`||t===`rl`)&&fc(e),(t===`lr`||t===`rl`)&&(mc(e),uc(e))}function uc(e){e.nodes().forEach(t=>dc(e.node(t))),e.edges().forEach(t=>dc(e.edge(t)))}function dc(e){let t=e.width;e.width=e.height,e.height=t}function fc(e){e.nodes().forEach(t=>pc(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(pc),Object.hasOwn(r,`y`)&&pc(r)})}function pc(e){e.y=-e.y}function mc(e){e.nodes().forEach(t=>hc(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(hc),Object.hasOwn(r,`x`)&&hc(r)})}function hc(e){let t=e.x;e.x=e.y,e.y=t}function gc(e,t=null){let n={},r=e.nodes().filter(t=>!e.children(t).length),i=r.map(t=>e.node(t).rank),a=Qo(Go(Math.max,i)+1).map(()=>[]);function o(t){if(n[t])return;n[t]=!0;let r=e.node(t);a[r.rank].push(t);let i=e.successors(t);i&&[...i].sort((e,t)=>s(e,t)).forEach(o)}r.sort((t,n)=>e.node(t).rank-e.node(n).rank).forEach(o);function s(n,r){return rs(t,e.node(n),e.node(r))}return a}function _c(e,t){let n=0;for(let r=1;r<t.length;++r)n+=vc(e,t[r-1],t[r]);return n}function vc(e,t,n){let r=ts(n,n.map((e,t)=>t)),i=t.flatMap(t=>{let n=e.outEdges(t);return n?n.map(t=>({pos:r[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos):[]}),a=1;for(;a<n.length;)a<<=1;let o=2*a-1;--a;let s=Array(o).fill(0),c=0;return i.forEach(e=>{let t=e.pos+a;s[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=s[t+1]),t=t-1>>1,s[t]+=e.weight;c+=e.weight*n}),c}function yc(e,t=[]){return t.map(t=>{let n=e.inEdges(t);if(!n||!n.length)return{v:t};{let r=n.reduce((t,n)=>{let r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:t,barycenter:r.sum/r.weight,weight:r.weight}}})}function bc(e,t){let n={};return e.forEach((e,t)=>{let r={indegree:0,in:[],out:[],vs:[e.v],i:t};e.barycenter!==void 0&&(r.barycenter=e.barycenter,r.weight=e.weight),n[e.v]=r}),t.edges().forEach(e=>{let t=n[e.v],r=n[e.w];t!==void 0&&r!==void 0&&(r.indegree++,t.out.push(r))}),xc(Object.values(n).filter(e=>!e.indegree))}function xc(e){let t=[];function n(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&Sc(e,t)}}function r(t){return n=>{n.in.push(t),--n.indegree===0&&e.push(n)}}for(;e.length;){let i=e.pop();t.push(i),i.in.reverse().forEach(n(i)),i.out.forEach(r(i))}return t.filter(e=>!e.merged).map(e=>$o(e,[`vs`,`i`,`barycenter`,`weight`]))}function Sc(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function Cc(e,t,n,r,i){let a={},o=null,s=null,c=i;typeof t==`boolean`?(c=t,a={}):t&&(a=t,o=n??null,s=r??null);let l=qo(e,e=>Object.hasOwn(e,`barycenter`)),u=l.lhs,d=l.rhs.sort((e,t)=>t.i-e.i),f=[],p=0,m=0,h=0;u.sort(Tc(s,o,!!c));for(let[e,t]of Object.entries(a)){let n=u.findIndex(t=>t.vs[0]===e);u.splice(n+1,0,t)}h=wc(f,d,h),u.forEach(e=>{h+=e.vs.length,f.push(e.vs),p+=e.barycenter*e.weight,m+=e.weight,h=wc(f,d,h)});let g={vs:f.flat(1)};return m&&(g.barycenter=p/m,g.weight=m),g}function wc(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function Tc(e,t,n){return(r,i)=>{if(r.barycenter<i.barycenter)return-1;if(r.barycenter>i.barycenter)return 1;if(e&&(typeof r.vs[0]==`string`||typeof i.vs[0]==`string`)){let n=rs(t,e.node(r.vs[0]),e.node(i.vs[0]));if(n!==0)return n}return n?i.i-r.i:r.i-i.i}}function Ec(e,t,n,r,i){var a,o;let s=null,c=i;typeof r==`boolean`?(c=r,s=null):r!==void 0&&(s=r);let l=e.children(t),u=e.node(t),d=u?u.borderLeft:void 0,f=u?u.borderRight:void 0,p={};d&&(l=l.filter(e=>e!==d&&e!==f));let m=yc(e,l);m.forEach(t=>{if(e.children(t.v).length){let{result:r}=Ec(e,t.v,n,s,c);p[t.v]=r,Object.hasOwn(r,`barycenter`)&&Oc(t,r)}});let h=bc(m,n);Dc(h,p);let g={},_=!1;for(let t=0;t<h.length;t++)for(let n=t+1;n<h.length;n++)if(h[t]&&h[n]&&(a=h[t])!=null&&a.barycenter&&(o=h[n])!=null&&o.barycenter&&h[t]?.barycenter===h[n].barycenter){let r=h[t]?.vs[0]??``,i=h[n]?.vs[0]??``,a=e.node(r),o=e.node(i);if(a.dummy===`edge`&&o.dummy===`edge`&&a.edgeObj?.v===o.edgeObj?.v&&a.edgeObj?.w===o.edgeObj?.w){if(a.edgeLabel.reversed){g[i]=h[t],h.splice(t,1),t--;break}g[r]=h[n],h.splice(n,1),n--}else _=!0}let v=Cc(h,g,s,e,c);if(d&&f){v.vs=[d,v.vs,f].flat(1);let t=e.predecessors(d);if(t&&t.length){let n=e.node(t[0]),r=e.predecessors(f),i=e.node(r[0]);Object.hasOwn(v,`barycenter`)||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+n.order+i.order)/(v.weight+2),v.weight+=2}}return Object.defineProperty(v,"result",{value:v,enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(v,"usedBias",{value:_,enumerable:!1,configurable:!0,writable:!0}),v}function Dc(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function Oc(e,t){e.barycenter===void 0?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}function kc(e,t,n,r){r||=e.nodes();let i=Ac(e),a=new Po({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(t=>e.node(t));return r.forEach(r=>{let o=e.node(r),s=e.parent(r);if(o.rank===t||o.minRank<=t&&t<=o.maxRank){a.setNode(r),a.setParent(r,s||i);let c=e[n](r);c&&c.forEach(t=>{let n=t.v===r?t.w:t.v,i=a.edge(n,r),o=i===void 0?0:i.weight;a.setEdge(n,r,{weight:e.edge(t).weight+o})}),Object.hasOwn(o,`minRank`)&&a.setNode(r,{borderLeft:o.borderLeft[t],borderRight:o.borderRight[t]})}}),a}function Ac(e){let t;for(;e.hasNode(t=Zo(`_root`)););return t}function jc(e,t,n){let r={},i;n.forEach(n=>{let a=e.parent(n),o,s;for(;a;){if(o=e.parent(a),o?(s=r[o],r[o]=a):(s=i,i=a),s&&s!==a){t.setEdge(s,a);return}a=o}})}function Mc(e,t={},n=null){if(typeof t.customOrder==`function`){t.customOrder(e,Mc);return}let r=Ko(e),i=Nc(e,Qo(1,r+1),`inEdges`),a=Nc(e,Qo(r-1,-1,-1),`outEdges`),o=gc(e,n);if(Fc(e,o),t.disableOptimalOrderHeuristic)return;let s=1/0,c,l=t.constraints||[];for(let t=0,r=0;r<4;++t,++r){Pc(t%2?i:a,t%4>=2,l,n),o=zo(e);let u=_c(e,o);u<s?(r=0,c=Object.assign({},o),s=u):u===s&&(c=structuredClone(o))}Fc(e,c)}function Nc(e,t,n){let r=new Map,i=(e,t)=>{r.has(e)||r.set(e,[]),r.get(e).push(t)};for(let t of e.nodes()){let n=e.node(t);if(typeof n.rank==`number`&&i(n.rank,t),typeof n.minRank==`number`&&typeof n.maxRank==`number`)for(let e=n.minRank;e<=n.maxRank;e++)e!==n.rank&&i(e,t)}return t.map(function(t){return kc(e,t,n,r.get(t)||[])})}function Pc(e,t,n,r){let i=!0,a=new Po;e.forEach(function(e){n.forEach(e=>a.setEdge(e.left,e.right));let o=e.graph().root,{result:s,usedBias:c}=Ec(e,o,a,r,i);t&&c&&(i=!i),s.vs.forEach((t,n)=>e.node(t).order=n),jc(e,a,s.vs)})}function Fc(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}function Ic(e,t){let n={};function r(t,r){let i=0,a=0,o=t.length,s=r[r.length-1];return r.forEach((t,c)=>{let l=Rc(e,t),u=l?e.node(l).order:o;(l||t===s)&&(r.slice(a,c+1).forEach(t=>{let r=e.predecessors(t);r&&r.forEach(r=>{let a=e.node(r),o=a.order;(o<i||u<o)&&!(a.dummy&&e.node(t).dummy)&&zc(n,r,t)})}),a=c+1,i=u)}),r}return t.length&&t.reduce(r),n}function Lc(e,t){let n={};function r(t,r,i,a,o){Qo(r,i).forEach(r=>{let i=t[r];if(i!==void 0&&e.node(i).dummy){let t=e.predecessors(i);t&&t.forEach(t=>{if(t===void 0)return;let r=e.node(t);r.dummy&&(r.order<a||r.order>o)&&zc(n,t,i)})}})}function i(t,n){let i=-1,a=-1,o=0;return n.forEach((s,c)=>{if(e.node(s).dummy===`border`){let t=e.predecessors(s);if(t&&t.length){let s=t[0];if(s===void 0)return;a=e.node(s).order,r(n,o,c,i,a),o=c,i=a}}r(n,o,n.length,a,t.length)}),n}return t.length&&t.reduce(i),n}function Rc(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(t=>e.node(t).dummy)}}function zc(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];r||(e[t]=r={}),r[n]=!0}function Bc(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function Vc(e,t,n,r,i){let a={},o={},s={};return t.forEach(e=>{e.forEach((e,t)=>{a[e]=e,o[e]=e,s[e]=t})}),t.forEach(t=>{let c=-1,l=-1,u=!1,d=t,f=t.findIndex(t=>i?.includes(t)||Xc(t,e,i));f>0&&(d=[t[f],...t.slice(0,f),...t.slice(f+1)],u=!0),d.forEach(t=>{let d=r(t);if(d&&d.length){i!=null&&i.includes(t)&&(d=d.filter(t=>Xc(t,e,i)));let r=d.sort((e,t)=>{let n=s[e],r=s[t];return(n===void 0?0:n)-(r===void 0?0:r)}),f=(r.length-1)/2;for(let e=Math.floor(f),i=Math.ceil(f);e<=i;++e){let i=r[e];if(i===void 0)continue;let d=s[i];if(d!==void 0&&o[t]===t&&c<d&&s[i]!==l&&!Bc(n,t,i)){let e=a[i];e!==void 0&&(o[i]=t,o[t]=a[t]=e,c=d,u&&=(c=-1,l=s[i]??-1,!1))}}}})}),{root:a,align:o}}function Hc(e,t,n,r,i=!1){let a={},o=Uc(e,t,n,i),s=i?`borderLeft`:`borderRight`;function c(e,t){let n=o.nodes().slice(),r={},i=n.pop();for(;i;){if(r[i])e(i);else{r[i]=!0,n.push(i);for(let e of t(i))n.push(e)}i=n.pop()}}function l(e){let t=o.inEdges(e);t?a[e]=t.reduce((e,t)=>{let n=a[t.v]??0,r=o.edge(t);return Math.max(e,n+(r===void 0?0:r))},0):a[e]=0}function u(t){let n=o.outEdges(t),r=1/0;n&&(r=n.reduce((e,t)=>{let n=a[t.w],r=o.edge(t);return Math.min(e,(n===void 0?0:n)-(r===void 0?0:r))},1/0));let i=e.node(t);r!==1/0&&i.borderType!==s&&(a[t]=Math.max(a[t]===void 0?0:a[t],r))}function d(e){return o.predecessors(e)||[]}function f(e){return o.successors(e)||[]}return c(l,d),c(u,f),Object.keys(r).forEach(e=>{let t=n[e];t!==void 0&&(a[e]=a[t]??0)}),a}function Uc(e,t,n,r){let i=new Po,a=e.graph(),o=Jc(a.nodesep,a.edgesep,r);return t.forEach(t=>{let r;t.forEach(t=>{let a=n[t];if(a!==void 0){if(i.setNode(a),r!==void 0){let s=n[r];if(s!==void 0){let n=i.edge(s,a);i.setEdge(s,a,Math.max(o(e,t,r),n||0))}}r=t}})}),i}function Wc(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=Yc(e,t)/2;r=Math.max(n+a,r),i=Math.min(n-a,i)});let a=r-i;return a<t[0]&&(t=[a,n]),t},[1/0,null])[1]}function Gc(e,t){let n=Object.values(t),r=Go(Math.min,n),i=Go(Math.max,n);[`u`,`d`].forEach(n=>{[`l`,`r`].forEach(a=>{let o=n+a,s=e[o];if(!s||s===t)return;let c=Object.values(s),l=r-Go(Math.min,c);a!==`l`&&(l=i-Go(Math.max,c)),l&&(e[o]=es(s,e=>e+l))})})}function Kc(e,t=void 0){let n=e.ul;return n?es(n,(n,r)=>{if(t){let n=e[t.toLowerCase()];if(n&&n[r]!==void 0)return n[r]}let i=Object.values(e).map(e=>{let t=e[r];return t===void 0?0:t}).sort((e,t)=>e-t);return((i[1]??0)+(i[2]??0))/2}):{}}function qc(e,t){let n=zo(e),r=Object.assign(Ic(e,n),Lc(e,n)),i={},a;return[`u`,`d`].forEach(o=>{a=o===`u`?n:Object.values(n).reverse(),[`l`,`r`].forEach(n=>{n===`r`&&(a=a.map(e=>Object.values(e).reverse()));let s=Vc(e,a,r,t=>(o===`u`?e.predecessors(t):e.successors(t))||[],t),c=Hc(e,a,s.root,s.align,n===`r`);n===`r`&&(c=es(c,e=>-e)),i[o+n]=c})}),Gc(i,Wc(e,i)),Kc(i,e.graph().align)}function Jc(e,t,n){return(r,i,a)=>{let o=r.node(i),s=r.node(a),c=0,l;if(c+=o.width/2,Object.hasOwn(o,`labelpos`))switch(o.labelpos.toLowerCase()){case`l`:l=-o.width/2;break;case`r`:l=o.width/2}if(l&&(c+=n?l:-l),l=void 0,c+=(o.dummy?t:e)/2,c+=(s.dummy?t:e)/2,c+=s.width/2,Object.hasOwn(s,`labelpos`))switch(s.labelpos.toLowerCase()){case`l`:l=s.width/2;break;case`r`:l=-s.width/2}return l&&(c+=n?l:-l),c}}function Yc(e,t){return e.node(t).width}function Xc(e,t,n){if(!n)return!1;let r=t.node(e)?.edgeObj;if(!r||t.node(e).edgeLabel.reversed)return!1;let i=n.indexOf(r?.v),a=n.indexOf(r?.w);return i!==-1&&a!==-1&&i===(a+1)%n.length||i===(a-1)%n.length}function Zc(e,t){e=Lo(e),Qc(e),Object.entries(qc(e,t)).forEach(([t,n])=>e.node(t).x=n)}function Qc(e){let t=zo(e),n=e.graph(),r=n.ranksep,i=n.rankalign,a=0;t.forEach(t=>{let n=t.reduce((t,n)=>{let r=e.node(n).height??0;return t>r?t:r},0);t.forEach(t=>{let r=e.node(t);r.y=i===`top`?a+r.height/2:i===`bottom`?a+n-r.height/2:a+n/2}),a+=n+r})}var $c=new WeakMap;function el(e,t={}){return nl(e,Yo,t),e}function tl(e,t,n){let r=t;for(;r!==void 0;){let t=e.parent(r);if(t===n)return r;r=t}}function nl(e,t,n){let r=e.nodes().filter(t=>e.children(t).length),i={};r.forEach(r=>{let a=e.node(r);if(a&&a.rankdir){let o=new Po({multigraph:!0,compound:!0});o.setGraph({rankdir:a.rankdir});let s=e.children(r);s.forEach(t=>{let n={...e.node(t)};o.setNode(t,n);let i=e.parent(t);i&&i!==r&&s.includes(i)&&o.setParent(t,i)});let c=new Set;e.edges().forEach(t=>{let n=tl(e,t.v,r),i=tl(e,t.w,r);if(n&&i&&n!==i){let r=`${n}\0${i}`;c.has(r)||(c.add(r),o.setEdge(n,i,{...e.edge(t)}))}}),nl(o,t,n);let l=pl(o);rl(l,t,n,null),il(o,l);let u=1/0,d=1/0,f=-1/0,p=-1/0;o.nodes().forEach(e=>{if(e===r)return;let t=o.node(e);t&&typeof t.x==`number`&&typeof t.y==`number`&&typeof t.width==`number`&&typeof t.height==`number`&&(u=Math.min(u,t.x-t.width/2),f=Math.max(f,t.x+t.width/2),d=Math.min(d,t.y-t.height/2),p=Math.max(p,t.y+t.height/2))}),(!isFinite(u)||!isFinite(d)||!isFinite(f)||!isFinite(p))&&(u=d=0,f=p=0);let m=f-u,h=p-d;i[r]={minX:u,minY:d,maxX:f,maxY:p,width:m,height:h,offsetX:u,offsetY:d},a._dagreClusterSubgraph=o}});let a=[],o=t=>{let n=[],r=(e.children(t)||[]).filter(e=>e!==t);for(;r.length>0;){let t=r.shift();n.push(t),(e.children(t)||[]).filter(e=>e!==t).forEach(e=>r.push(e))}return n},s=new Map;r.forEach(t=>{let n=e.node(t);n&&n.rankdir&&i[t]&&s.set(t,(e.children(t)||[]).filter(e=>e!==t))});let c=new Set([...s.values()].flat()),l=new Map;s.forEach((e,t)=>{c.has(t)||l.set(t,o(t))});let u=new Set([...l.values()].flat()),d=e=>{for(let[t,n]of l)if(n.includes(e))return t;return e},f=[];e.edges().forEach(t=>{(u.has(t.v)||u.has(t.w))&&f.push({edge:t,label:e.edge(t)})});let p=new Map;u.forEach(t=>{let n=e.parent(t);p.set(t,typeof n==`string`?n:void 0)}),l.forEach((t,n)=>{let r=e.node(n),o=[];t.forEach(t=>{let n=e.node(t);n&&(o.push({id:t,node:n,parent:p.get(t)}),e.removeNode(t))});let s=f.filter(({edge:e})=>t.includes(e.v)||t.includes(e.w)),c=i[n];r&&(a.push({clusterId:n,subgraph:r._dagreClusterSubgraph,bounds:c,children:t,removedNodes:o,removedEdges:s}),r.width=c.width,r.height=c.height)});let m=new Set;f.forEach(({edge:t,label:n})=>{let r=d(t.v),i=d(t.w);if(r!==i&&e.hasNode(r)&&e.hasNode(i)){let t=`${r}\0${i}`;m.has(t)||(m.add(t),e.setEdge(r,i,{...n,width:0,height:0}))}});let h=pl(e),g=rl(h,t,n,$c.get(e)??null);$c.set(e,g),il(e,h),m.forEach(t=>{let n=t.indexOf(`\0`),r=t.slice(0,n),i=t.slice(n+1);e.hasEdge(r,i)&&e.removeEdge(r,i)}),a.forEach(({clusterId:t,subgraph:n,bounds:r,removedNodes:i,removedEdges:a})=>{let o=e.node(t),s=o?.x??0,c=o?.y??0,l=(r.minX+r.maxX)/2,u=(r.minY+r.maxY)/2;i.forEach(({id:t,node:n,parent:r})=>{e.setNode(t,n),r!==void 0&&e.setParent(t,r)}),a.forEach(({edge:t,label:n})=>{e.setEdge(t,n)}),n.nodes().forEach(r=>{if(r===t)return;let i=n.node(r),a=e.node(r);a&&i&&typeof i.x==`number`&&typeof i.y==`number`&&(a.x=s+(i.x-l),a.y=c+(i.y-u))}),delete o._dagreClusterSubgraph}),r.forEach(t=>{let n=e.node(t),r=i[t];if(n&&n.rankdir&&n._dagreClusterSubgraph&&r){let i=n._dagreClusterSubgraph,a=n.x??0,o=n.y??0,s=(r.minX+r.maxX)/2,c=(r.minY+r.maxY)/2;i.nodes().forEach(n=>{if(n===t)return;let r=i.node(n),l=e.node(n);if(l&&r&&typeof r.x==`number`&&typeof r.y==`number`){let e=r.x-s,t=r.y-c;l.x=a+e,l.y=o+t}}),delete n._dagreClusterSubgraph}})}function rl(e,t,n,r=null){var i,a;let o=n?.useDynamic!==!1,s=o&&(i=r?.graph)!=null?i:null,c=o&&(a=r?.rawNodes)!=null?a:null;t(` makeSpaceForEdgeLabels`,()=>ml(e)),t(` removeSelfEdges`,()=>Cl(e)),t(` acyclic`,()=>gs(e,s)),t(` nestingGraph.run`,()=>ec(e)),t(` rank`,()=>Gs(Lo(e))),t(` injectEdgeLabelProxies`,()=>hl(e)),t(` removeEmptyRanks`,()=>Vo(e)),t(` nestingGraph.cleanup`,()=>ic(e)),t(` normalizeRanks`,()=>Bo(e)),t(` assignRankMinMax`,()=>gl(e)),t(` removeEdgeLabelProxies`,()=>_l(e)),t(` normalize.run`,()=>bs(e)),t(` parentDummyChains`,()=>Xs(e)),t(` addBorderSegments`,()=>ac(e)),t(` order`,()=>Mc(e,n,c)),t(` insertSelfEdges`,()=>wl(e)),t(` adjustCoordinateSystem`,()=>cc(e)),t(` position`,()=>Zc(e,n.corePath)),t(` positionSelfEdges`,()=>Tl(e));let l=JSON.parse(JSON.stringify(e._nodes));return t(` removeBorderNodes`,()=>Sl(e)),t(` normalize.undo`,()=>Ss(e)),t(` fixupEdgeLabelCoords`,()=>bl(e)),t(` undoCoordinateSystem`,()=>lc(e)),t(` translateGraph`,()=>vl(e)),t(` assignNodeIntersects`,()=>yl(e)),t(` reversePoints`,()=>xl(e)),t(` acyclic.undo`,()=>vs(e)),{graph:e,rawNodes:l}}function il(e,t){e.nodes().forEach(n=>{let r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,r.order=i.order,r.rank=i.rank,t.children(n).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(n=>{let r=e.edge(n),i=t.edge(n);r.points=i.points,Object.hasOwn(i,`x`)&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var al=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],ol={ranksep:50,edgesep:20,nodesep:50,rankdir:`TB`,rankalign:`center`},sl=[`acyclicer`,`ranker`,`rankdir`,`align`,`rankalign`],cl=[`width`,`height`,`rank`],ll={width:0,height:0},ul=[`minlen`,`weight`,`width`,`height`,`labeloffset`],dl={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},fl=[`labelpos`];function pl(e){let t=new Po({multigraph:!0,compound:!0}),n=Dl(e.graph());return t.setGraph(Object.assign({},ol,El(n,al),$o(n,sl))),e.nodes().forEach(n=>{let r=El(Dl(e.node(n)),cl);Object.keys(ll).forEach(e=>{r[e]===void 0&&(r[e]=ll[e])}),t.setNode(n,r);let i=e.parent(n);i!==void 0&&t.setParent(n,i)}),e.edges().forEach(n=>{let r=Dl(e.edge(n));t.setEdge(n,Object.assign({},dl,El(r,ul),$o(r,fl)))}),t}function ml(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,(r.labelpos??`r`).toLowerCase()!==`c`&&(t.rankdir===`TB`||t.rankdir===`BT`?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function hl(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v);Fo(e,`edge-proxy`,{rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t},`_ep`)}})}function gl(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function _l(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy===`edge-proxy`){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function vl(e){let t=1/0,n=0,r=1/0,i=0,a=e.graph(),o=a.marginx||0,s=a.marginy||0;function c(e){let a=e.x,o=e.y,s=e.width,c=e.height;t=Math.min(t,a-s/2),n=Math.max(n,a+s/2),r=Math.min(r,o-c/2),i=Math.max(i,o+c/2)}e.nodes().forEach(t=>c(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);Object.hasOwn(n,`x`)&&c(n)}),t-=o,r-=s,e.nodes().forEach(n=>{let i=e.node(n);i.x-=t,i.y-=r}),e.edges().forEach(n=>{let i=e.edge(n);i.points.forEach(e=>{e.x-=t,e.y-=r}),Object.hasOwn(i,`x`)&&(i.x-=t),Object.hasOwn(i,`y`)&&(i.y-=r)}),a.width=n-t+o,a.height=i-r+s}function yl(e){e.edges().forEach(t=>{if(t.v===t.w)return;let n=e.edge(t),r=e.node(t.v),i=e.node(t.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(Ro(r,a)),n.points.push(Ro(i,o))})}function bl(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,`x`))switch((n.labelpos===`l`||n.labelpos===`r`)&&(n.width-=n.labeloffset),n.labelpos){case`l`:n.x-=n.width/2+n.labeloffset;break;case`r`:n.x+=n.width/2+n.labeloffset}})}function xl(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function Sl(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),o=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-a.x),n.height=Math.abs(i.y-r.y),n.x=a.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy===`border`&&e.removeNode(t)})}function Cl(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||=[],n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function wl(e){zo(e).forEach(t=>{let n=0;t.forEach((t,r)=>{let i=e.node(t);typeof i.rank!=`number`&&(i.rank=0),i.order=r+n,(i.selfEdges||[]).forEach(t=>{Fo(e,`selfedge`,{width:t.label.width,height:t.label.height,rank:i.rank,order:r+ ++n,e:t.e,edgeLabel:t.label},`_se`),(!Array.isArray(t.label.points)||t.label.points.length!==7)&&(t.label.points=[{x:0,y:-10},{x:0,y:-10},{x:0,y:0},{x:0,y:10},{x:0,y:10},{x:0,y:0},{x:0,y:0}])}),delete i.selfEdges})})}function Tl(e){e.nodes().forEach(t=>{let n=e.node(t),r=e=>typeof e==`number`&&isFinite(e);if(n.dummy===`selfedge`){let i=n,a=e.node(i.e.v),o=r(a?.x)?a.x:0,s=r(a?.y)?a.y:0,c=r(a?.width)?a.width:0,l=r(a?.height)?a.height:0,u=r(n.x)?n.x:o,d=r(n.y)?n.y:s,f=c/2,p=l/2;i.edgeLabel.points=[{x:u+f,y:d-p},{x:u+f,y:d-p},{x:u,y:d},{x:u-f,y:d+p},{x:u-f,y:d+p},{x:u,y:d},{x:u,y:d}],i.edgeLabel.x=u,i.edgeLabel.y=d,e.setEdge(i.e,i.edgeLabel),e.removeNode(t)}else n&&Array.isArray(n.selfEdges)&&n.selfEdges.forEach(e=>{if(!Array.isArray(e.label.points)||e.label.points.length!==7){let t=r(n.x)?n.x:0,i=r(n.y)?n.y:0,a=r(n.width)?n.width:0,o=r(n.height)?n.height:0,s=a/2,c=o/2;e.label.points=[{x:t+s,y:i-c},{x:t+s,y:i-c},{x:t,y:i},{x:t-s,y:i+c},{x:t-s,y:i+c},{x:t,y:i},{x:t,y:i}]}})})}function El(e,t){return es($o(e,t),Number)}function Dl(e){let t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}function Ol(e){let t=zo(e),n=new Po({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(t=>{n.setNode(t,{label:t}),n.setParent(t,`layer`+e.node(t).rank)}),e.edges().forEach(e=>n.setEdge(e.v,e.w,{},e.name)),t.forEach((e,t)=>{let r=`layer`+t;n.setNode(r,{rank:`same`}),e.reduce((e,t)=>(n.setEdge(e,t,{style:`invis`}),t))}),n}var kl={graphlib:Ja,version:is,layout:el,debug:Ol,util:{time:Jo,notime:Yo}};function Al(e,t){return t?e.ref===void 0?`added`:e.set===void 0?`context`:`changed`:`unchanged`}function jl(e,t){if(t&&e.heading===void 0)return e.ref===void 0?`added`:e.set===void 0?`context`:`changed`}function Ml(e,t){return t?e.ref===void 0?`added`:e.set===void 0?`context`:`changed`:`unchanged`}function Nl(e){let t=e.set;if(t===void 0)return[];let n=e;return Object.entries(t).filter(([e])=>e!==`attributes`&&e!==`removeAttributes`).map(([e,t])=>{let r=n[e];return{field:e,...typeof r==`string`?{from:r}:{},to:String(t)}})}var Pl={added:`added`,changed:`changed`,context:`existing`,unchanged:``},Fl={added:`added`,changed:`changed`,context:`existing`,removed:`removed`},Il=[`added`,`changed`,`context`,`removed`];function Ll(e){return e.rows.some(e=>it(e).role!==void 0)}function Rl(e,t){if(t)return it(e).role??`context`}function zl(e){if(e.length===0)return;let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y)),r=Math.max(...e.map(e=>e.x+e.width)),i=Math.max(...e.map(e=>e.y+e.height));return{x:t-Ul,y:n-Ul-Wl,width:r-t+Ul*2,height:i-n+Ul*2+Wl}}var Bl=64,Vl=24,Hl=12,Ul=10,Wl=16,Gl=16,Kl=160,ql=52;function Jl(e,t,n=`landscape`){let r=new kl.graphlib.Graph({compound:!0,multigraph:!0});r.setGraph({rankdir:n===`portrait`?`TB`:`LR`,ranksep:Bl,nodesep:Vl,marginx:Hl,marginy:Hl}),r.setDefaultEdgeLabel(()=>({}));for(let n of e.nodes)r.setNode(n.id,t(n));let i=e.containers??[],a=new Map;for(let t of e.nodes)t.container!==void 0&&i.some(e=>e.id===t.container)&&(r.setNode(t.container,{label:t.container}),r.setParent(t.id,t.container),a.set(t.container,[...a.get(t.container)??[],t.id]));e.edges.forEach((e,t)=>{e.from!==e.to&&r.hasNode(e.from)&&r.hasNode(e.to)&&r.setEdge(e.from,e.to,{},String(t))}),kl.layout(r);let o=e.nodes.map(e=>{let n=r.node(e.id),{width:i,height:a}=t(e);return{id:e.id,x:(n?.x??Hl+i/2)-i/2,y:(n?.y??Hl+a/2)-a/2,width:i,height:a}}),s=[];e.edges.forEach((e,t)=>{if(e.from===e.to)return;let n=r.edge(e.from,e.to,String(t));n?.points!==void 0&&n.points.length>0&&s.push({index:t,points:n.points.map(e=>({x:e.x,y:e.y}))})});let c=[],l=o.reduce((e,t)=>Math.max(e,t.y+t.height),Hl)+Gl,u=new Map(o.map(e=>[e.id,e]));for(let e of i){let t=zl((a.get(e.id)??[]).flatMap(e=>{let t=u.get(e);return t===void 0?[]:[t]}));t===void 0?(c.push({id:e.id,label:e.label,x:Hl,y:l,width:Kl,height:ql}),l+=68):c.push({id:e.id,label:e.label,...t})}let d=[...o.map(e=>({x:e.x,y:e.y,width:e.width,height:e.height})),...c],f=Math.min(0,...d.map(e=>e.x))-Hl,p=Math.min(0,...d.map(e=>e.y))-Hl;if(f<0||p<0){for(let e of o)e.x-=f,e.y-=p;for(let e of c)e.x-=f,e.y-=p;for(let e of s)for(let t of e.points)t.x-=f,t.y-=p}let m=[...o.map(e=>({x:e.x,y:e.y,width:e.width,height:e.height})),...c].reduce((e,t)=>({width:Math.max(e.width,t.x+t.width),height:Math.max(e.height,t.y+t.height)}),{width:0,height:0});return{nodes:o,edges:s,containers:c,width:m.width+Hl,height:m.height+Hl}}var Yl={attributes:[],expectations:[],assignments:[],removedAttributes:[],locations:[],artifacts:[]};function Xl(e){if(typeof e!=`object`||!e)return Yl;let t=e,n=e=>typeof e==`object`&&e&&!Array.isArray(e)?Object.entries(e):[],r=t.set,i=r?.removeAttributes;return{attributes:n(t.attributes),expectations:n(t.expect?.attributes),assignments:n(r?.attributes),removedAttributes:Array.isArray(i)?i.filter(e=>typeof e==`string`):[],locations:Array.isArray(t.locations)?t.locations:[],artifacts:Array.isArray(t.artifacts)?t.artifacts:[]}}function Zl(e){let t=e.target;if(typeof t==`string`)return{ref:t};if(typeof t!=`object`||!t)return;let n=t;if(typeof n.ref==`string`)return{ref:n.ref,...typeof n.revision==`string`?{revision:n.revision}:{}}}function Ql(e,t){let n=(e.removals??[]).map(e=>({type:e.type,ref:e.ref})),r=e.profile,i=e.artifacts,a={...typeof r==`string`?{profile:r}:{},...(()=>{let t=Zl(e);return t===void 0?{}:{target:t}})(),artifacts:Array.isArray(i)?i:[]};if(e.kind===`table`){let r=e.data,i=Ll(r),o=r.rows.map(e=>{let n=Array.isArray(e)?{}:e,r=(Array.isArray(e)?void 0:e.role)??jl({ref:typeof n.ref==`string`?n.ref:void 0,set:n.set,heading:typeof n.heading==`string`?n.heading:void 0},t)??Rl(e,i),{cells:a,heading:o}=it(e),s=Array.isArray(e)?{}:e;return{cells:a,...r===void 0?{}:{role:r},...o===void 0?{}:{heading:o},...typeof s.depth==`number`?{depth:s.depth}:{},...typeof s.id==`string`?{id:s.id}:{},...typeof s.ref==`string`?{ref:s.ref}:{},...typeof s.kind==`string`?{kind:s.kind}:{},changes:Nl(s),...Xl(e)}}),s=new Map;for(let e of o){if(e.id===void 0)continue;let t=e.cells.find(e=>typeof e==`string`&&e!==``);s.set(e.id,(typeof t==`string`?t:void 0)??e.ref??e.id)}let c=r.relations,l=(Array.isArray(c)?c:[]).map(e=>{let t=e,n=e=>{let t=typeof e?.id==`string`?e.id:void 0,n=typeof e?.ref==`string`?e.ref:void 0;return{id:t,ref:n,label:(t===void 0?void 0:s.get(t))??n??t??``}},r=n(t.from),i=n(t.to);return{kind:t.kind??``,...typeof t.label==`string`?{label:t.label}:{},...r.id===void 0?{}:{fromRow:r.id},...i.id===void 0?{}:{toRow:i.id},...r.ref===void 0?{}:{fromRef:r.ref},...i.ref===void 0?{}:{toRef:i.ref},fromLabel:r.label,toLabel:i.label}});return{thingNoun:`column`,linkNoun:`row`,things:[],links:[],columns:r.columns,rows:o,containers:[],removals:n,traces:l,...a}}if(e.kind===`timeline`)return{thingNoun:`task`,linkNoun:`dependency`,things:[],links:[],containers:[],removals:n,traces:[],...a};let o=e.kind===`graph`,s=o?e.data.nodes:e.data.participants,c=o?e.data.edges:e.data.messages,l=new Map(s.map(e=>[e.id,$l(e)]));return{thingNoun:o?`element`:`participant`,linkNoun:o?`relationship`:`message`,things:s.map(e=>({id:e.id,label:$l(e),kind:e.kind,role:Al(e,t),changes:Nl(e),container:e.container,...Xl(e)})),links:c.map(e=>({from:e.from,to:e.to,fromLabel:l.get(e.from)??e.from,toLabel:l.get(e.to)??e.to,label:e.label,kind:`kind`in e?e.kind:void 0,role:Ml(e,t),changes:Nl(e),isLoop:e.from===e.to,...Xl(e)})),containers:e.data.containers??[],removals:n,traces:[],...a}}function $l(e){return e.label??e.ref??e.id}function eu(e){if(e.kind===`graph`){let t=e.data,n=[`flowchart TD`],r=t.containers??[],i=new Set(r.map(e=>e.id)),a=e=>t.nodes.filter(t=>t.container===e);for(let e of r){n.push(` subgraph ${tu(e.id)}["${ru(e.label)}"]`);for(let t of a(e.id))n.push(` ${tu(t.id)}["${ru($l(t))}"]`);n.push(` end`)}for(let e of t.nodes)e.container!==void 0&&i.has(e.container)||n.push(` ${tu(e.id)}["${ru($l(e))}"]`);for(let e of t.edges){let t=e.label??e.kind,r=t===void 0?`-->`:`-- "${ru(t)}" -->`;n.push(` ${tu(e.from)} ${r} ${tu(e.to)}`)}return n.join(`
|
|
23
23
|
`)}if(e.kind===`sequence`){let t=e.data,n=[`sequenceDiagram`],r=t.containers??[],i=new Set(r.map(e=>e.id)),a=(e,t)=>`${t}participant ${tu(e.id)} as "${ru($l(e))}"`;for(let e of r){n.push(` box ${ru(e.label)}`);for(let r of t.participants.filter(t=>t.container===e.id))n.push(a(r,` `));n.push(` end`)}for(let e of t.participants)e.container!==void 0&&i.has(e.container)||n.push(a(e,` `));for(let e of t.messages)n.push(` ${tu(e.from)}->>${tu(e.to)}: ${ru(e.label??``)}`);return n.join(`
|
|
@@ -836,7 +836,7 @@ l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
836
836
|
`:``}${e}`};for(let e of t)e.kind===`path`?$V(n,e.data)||r(`@${e.data}`):e.kind===`text`&&r(`\`\`\`${e.name}\n${e.data}\n\`\`\``);return n}function nH(e){return{name:e,kind:`path`,data:e,mimeType:`text/plain`,source:`manual`}}function rH(e,t){return e.some(e=>e.kind===`path`&&e.data===t)?e:[...e,nH(t)]}function iH(e,t){return e.filter((e,n)=>n!==t)}function aH(e,t){if(!t)return!1;let n=e.composedPath();if(n.length>0)return n.includes(t);let r=e.target;return r!==null&&t.contains(r)}function oH(e){let t=(0,v.useRef)(null);return(0,v.useEffect)(()=>{function n(n){t.current&&!aH(n,t.current)&&e()}return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),t}var sH=100,cH=new Intl.Collator(void 0,{sensitivity:`base`,numeric:!0}),lH={extension:`ext`,prompt:`prompt`,skill:`skill`};function uH(e){return e===`directory`||e===`symlink-directory`}function dH(e,t){let n=e.slice(0,t),r=/(?:^|\s)@([^\s@]*)$/.exec(n);return r?{start:t-r[1].length-1,query:r[1]}:null}function fH({isStreaming:e,connected:t,commands:n,fileSearch:r,prefill:i,attachments:a,pendingUploads:o=[],onAttach:s,onMentionPaths:c,onRemoveAttachment:l,onSend:u,onAbort:d,onSearchFiles:f,onClearFileSearch:p,initialDraft:m,onDraftChange:h}){let[g,_]=(0,v.useState)(m??``);(0,v.useEffect)(()=>{h?.(g)},[g,h]);let[y,b]=(0,v.useState)(0),[x,S]=(0,v.useState)(0),[C,w]=(0,v.useState)(!1),T=(0,v.useRef)(null),E=(0,v.useRef)(null),D=(0,v.useRef)(null),O=(0,v.useRef)(null),ee=(0,v.useRef)(null);(0,v.useEffect)(()=>{i&&_(i.text)},[i?.nonce]),(0,v.useEffect)(()=>{ee.current!==null&&(D.current?.focus(),D.current?.setSelectionRange(ee.current,ee.current),ee.current=null)},[g]),(0,v.useLayoutEffect)(()=>{let e=D.current;if(!e)return;let t=-1,n=()=>{t=e.offsetWidth,e.style.overflowY=`hidden`,e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`,e.scrollHeight>e.clientHeight&&(e.style.overflowY=`auto`)};n();let r=typeof ResizeObserver>`u`?void 0:new ResizeObserver(()=>{e.offsetWidth!==t&&n()});return r?.observe(e,{box:`border-box`}),()=>r?.disconnect()},[g]);let te=(0,v.useMemo)(()=>eH(g),[g]);(0,v.useEffect)(()=>{c(te)},[te.join(`
|
|
837
837
|
`)]);let k=(0,v.useMemo)(()=>{let e=/^\/(\S*)$/.exec(g);return e?e[1].toLowerCase():null},[g]),ne=(0,v.useMemo)(()=>k===null?[]:n.filter(e=>e.name.toLowerCase().includes(k)).sort((e,t)=>{let n=e.name.toLowerCase().startsWith(k);return n===t.name.toLowerCase().startsWith(k)?cH.compare(e.name,t.name):n?-1:1}).slice(0,sH),[k,n]),A=k===null?dH(g,y):null;(0,v.useEffect)(()=>{if(!A||A.query.length===0){p();return}let e=window.setTimeout(()=>f(A.query),150);return()=>clearTimeout(e)},[A?.query]);let re=(0,v.useMemo)(()=>{if(ne.length>0)return{kind:`command`,items:ne};let e=A&&r?.query===A.query?r.results:[];return e.length>0?{kind:`file`,items:e}:null},[ne,A,r]),j=re!==null&&!C,ie=k===null?A?`file:${A.query}`:null:`cmd:${k}`;(0,v.useEffect)(()=>{S(0)},[ie]),(0,v.useEffect)(()=>{w(!1)},[k===null?A?`file`:null:`command`]),(0,v.useEffect)(()=>{if(!j)return;let e=e=>{aH(e,T.current)||w(!0)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e)}},[j]),(0,v.useEffect)(()=>{E.current?.querySelector(`[data-selected="true"]`)?.scrollIntoView({block:`nearest`})},[x]);let ae=o.length>0,[oe,se]=(0,v.useState)(!1);(0,v.useEffect)(()=>{ae||se(!1)},[ae]);function ce(){if(ae){se(!0);return}let e=tH(g,a),t=a.filter(e=>e.kind===`image`).map(e=>({data:e.data,mimeType:e.mimeType})),n=a.every(e=>e.kind===`path`);(g.trim()||!n&&e||t.length!==0)&&(u(e,t.length>0?t:void 0),_(``),p())}function le(e){let t=`/${e.name} `;_(t),ee.current=t.length,b(t.length)}function ue(e){if(!A)return;let t=g.slice(0,A.start),n=g.slice(y),r=`@${e.path}${uH(e.type)?`/`:` `}`,i=`${t}${r}${n}`;_(i),p();let a=t.length+r.length;ee.current=a,b(a)}function de(){if(re){if(re.kind===`command`){let e=re.items[x];e&&le(e)}else{let e=re.items[x];e&&ue(e)}}}function fe(e){if(j&&re){if(e.key===`ArrowDown`){e.preventDefault(),S(e=>(e+1)%re.items.length);return}if(e.key===`ArrowUp`){e.preventDefault(),S(e=>(e-1+re.items.length)%re.items.length);return}if(e.key===`Tab`||e.key===`Enter`){e.preventDefault(),de();return}if(e.key===`Escape`){e.preventDefault(),w(!0);return}}e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),ce())}function M(e){b(e.currentTarget.selectionStart??0)}function pe(e){let t=Array.from(e.clipboardData.files);t.length>0&&(e.preventDefault(),s(t))}return(0,N.jsxs)(`div`,{ref:T,className:`relative`,children:[(a.length>0||ae)&&(0,N.jsxs)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:[o.map(e=>(0,N.jsxs)(`span`,{"data-pending-upload":e.name,title:`${e.name} — copying into the workspace`,className:`flex items-center gap-1.5 rounded-md border border-dashed border-zinc-300 bg-zinc-50 py-1 pl-1.5 pr-2 text-xs text-zinc-500 dark:border-zinc-600 dark:bg-zinc-800/40 dark:text-zinc-400`,children:[(0,N.jsx)(`span`,{"aria-hidden":!0,className:`animate-pulse`,children:`⏳`}),(0,N.jsx)(`span`,{className:`max-w-40 truncate`,children:e.name}),(0,N.jsx)(`span`,{className:`sr-only`,children:`uploading`})]},e.id)),oe&&(0,N.jsx)(`span`,{role:`status`,className:`flex items-center py-1 text-xs text-amber-600 dark:text-amber-400`,children:`waiting for the attachment to finish uploading…`}),a.map((e,t)=>(0,N.jsxs)(`span`,{title:e.kind===`path`?`${e.name} — sent as a reference; the agent reads the file itself`:e.name,className:`flex items-center gap-1.5 rounded-md border border-zinc-200 bg-zinc-50 py-1 pl-1.5 pr-1 text-xs text-zinc-600 dark:border-zinc-700 dark:bg-zinc-800/60 dark:text-zinc-300`,children:[e.kind===`image`?(0,N.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:e.name,className:`h-8 w-8 rounded object-cover`}):(0,N.jsx)(`span`,{"aria-hidden":!0,className:e.kind===`path`?`font-mono font-bold text-blue-600 dark:text-blue-400`:``,children:e.kind===`path`?`@`:`📄`}),(0,N.jsx)(`span`,{className:`max-w-40 truncate`,children:e.name}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>l(t),title:`remove attachment`,className:`rounded px-1 text-zinc-400 hover:bg-zinc-200 hover:text-zinc-700 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`,children:`✕`})]},`${e.name}:${t}`))]}),j&&re&&(0,N.jsx)(`div`,{ref:E,className:`absolute bottom-full left-0 z-20 mb-2 max-h-72 w-full max-w-xl overflow-y-auto rounded-lg border border-zinc-200 bg-white py-1 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:re.kind===`command`?re.items.map((e,t)=>(0,N.jsxs)(`button`,{type:`button`,"data-selected":t===x,onMouseEnter:()=>S(t),onClick:()=>le(e),className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm ${t===x?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:[(0,N.jsxs)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:[`/`,e.name]}),e.argumentHint&&(0,N.jsx)(`span`,{className:`font-mono text-xs text-zinc-500`,children:e.argumentHint}),e.description&&(0,N.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-zinc-500`,children:e.description}),(0,N.jsx)(`span`,{className:`ml-auto shrink-0 rounded bg-zinc-200 px-1 text-[10px] uppercase text-zinc-500 dark:bg-zinc-800`,children:lH[e.source]})]},e.name)):re.items.map((e,t)=>(0,N.jsx)(`button`,{type:`button`,"data-selected":t===x,onMouseEnter:()=>S(t),onClick:()=>ue(e),className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm ${t===x?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:(0,N.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-zinc-800 dark:text-zinc-200`,children:[e.path,uH(e.type)?`/`:``]})},e.path))}),(0,N.jsxs)(`div`,{className:`flex items-end gap-2 rounded-xl border border-zinc-200 bg-zinc-50 p-2 focus-within:border-zinc-400 dark:border-zinc-800 dark:bg-zinc-900 dark:focus-within:border-zinc-600`,children:[(0,N.jsx)(`textarea`,{ref:D,value:g,onChange:e=>{_(e.target.value),b(e.target.selectionStart??e.target.value.length)},onKeyDown:fe,onClick:M,onKeyUp:M,onPaste:pe,placeholder:t?e?`steer the agent… (Enter to send)`:`message pi… (/ for commands, @ for files, Enter to send, Shift+Enter for newline)`:`connecting…`,disabled:!t,rows:1,className:`max-h-[min(40vh,20rem)] flex-1 resize-none overflow-y-hidden bg-transparent px-2 py-1.5 text-[15px] outline-none placeholder:text-zinc-400 disabled:opacity-50 dark:placeholder:text-zinc-600`}),e&&(0,N.jsx)(`button`,{type:`button`,onClick:d,title:`stop`,"aria-label":`Stop the agent`,className:`rounded-lg bg-red-100 p-2 text-red-700 hover:bg-red-200 dark:bg-red-900/60 dark:text-red-200 dark:hover:bg-red-900`,children:(0,N.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,className:`h-4 w-4`,children:(0,N.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>O.current?.click(),disabled:!t,title:`attach files`,"aria-label":`Attach files`,className:`rounded-lg p-2 text-zinc-500 hover:bg-zinc-200 hover:text-zinc-700 disabled:opacity-30 dark:text-zinc-400 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:(0,N.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,N.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48`})})}),(0,N.jsx)(`input`,{ref:O,type:`file`,multiple:!0,hidden:!0,onChange:e=>{e.target.files?.length&&s(Array.from(e.target.files)),e.target.value=``}}),(0,N.jsx)(`button`,{type:`button`,onClick:ce,disabled:!t||ae||!g.trim()&&a.length===0,title:ae?`waiting for an attachment to finish uploading`:e?`steer`:`send`,"aria-label":e?`Steer the agent`:`Send message`,className:`rounded-lg bg-zinc-900 p-2 text-zinc-100 hover:bg-zinc-800 disabled:opacity-30 dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-white`,children:e?(0,N.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:[(0,N.jsx)(`circle`,{cx:`6`,cy:`19`,r:`3`}),(0,N.jsx)(`path`,{strokeLinecap:`round`,d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`}),(0,N.jsx)(`circle`,{cx:`18`,cy:`5`,r:`3`})]}):(0,N.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,N.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M6 12 3.27 3.13c6.6 1.9 12.83 4.9 18.43 8.87-5.6 3.97-11.83 6.97-18.43 8.87L6 12Zm0 0h7.5`})})})]})]})}var pH=`rounded-md border px-3 py-1.5 text-sm border-zinc-200 hover:bg-zinc-100 dark:border-zinc-800 dark:hover:bg-zinc-800`,mH=`rounded-md bg-zinc-900 px-3 py-1.5 text-sm text-zinc-100 hover:bg-zinc-800 dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-white`,hH=`w-full rounded-md border border-zinc-300 bg-white px-2 py-1.5 text-sm outline-none focus:border-zinc-500 dark:border-zinc-700 dark:bg-zinc-950 dark:focus:border-zinc-500`,gH=`mb-4 ${hH}`,_H=`1,3`,vH=` — `;function yH(e){let t=e.indexOf(`
|
|
838
838
|
`);return t===-1?{heading:e,body:``}:{heading:e.slice(0,t),body:e.slice(t+1).trim()}}function bH(e){let t=/^(\d+)\.\s+(\S[\s\S]*)$/.exec(e.trim());if(!t)return null;let n=t[2],r=n.indexOf(vH);return{index:Number(t[1]),label:r===-1?n:n.slice(0,r),description:r===-1?``:n.slice(r+3)}}function xH(e){if(e.method!==`input`||e.placeholder!==_H)return null;let{heading:t,body:n}=yH(e.title),r=[];for(let e of n.split(`
|
|
839
|
-
`)){let t=bH(e);t&&r.push(t)}return r.length<2||r.some((e,t)=>e.index!==t+1)?null:{heading:t,options:r}}function SH(e){return`grid grid-cols-1 gap-2${e.length>1&&e.every(e=>e.length<=120)?` @min-[41rem]:grid-cols-2`:``}`}function CH({request:e,onRespond:t}){let n=(0,v.useId)(),[r,i]=(0,v.useState)(e.method===`editor`?e.prefill??``:``),[a,o]=(0,v.useState)([]),s=(e.method===`select`||e.method===`confirm`||e.method===`input`)&&e.timeout,[c,l]=(0,v.useState)(s?Math.ceil(s/1e3):null),u=xH(e),{heading:d,body:f}=yH(e.title);function p(){t({id:e.id,cancelled:!0})}function m(e){o(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e].sort((e,t)=>e-t))}function h(){let n=r.trim();t({id:e.id,value:n.length>0?n:a.join(`,`)})}return(0,v.useEffect)(()=>{if(c===null)return;if(c<=0){t({id:e.id,cancelled:!0});return}let n=setTimeout(()=>l(e=>e===null?null:e-1),1e3);return()=>clearTimeout(n)},[c,e.id,t]),(0,N.jsxs)(`section`,{role:`region`,"aria-labelledby":n,className:`@container max-h-[40dvh] overflow-y-auto overscroll-contain rounded-xl border border-zinc-200 bg-white p-4 dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,N.jsxs)(`div`,{className:`mb-3 flex items-start gap-3`,children:[(0,N.jsx)(`h2`,{id:n,className:`min-w-0 flex-1 break-words text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:d}),(0,N.jsx)(`button`,{type:`button`,onClick:p,"aria-label":`Refuse to answer`,title:`Refuse to answer`,className:`-mr-1 -mt-1 shrink-0 rounded-md px-1.5 py-0.5 text-sm leading-none text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-500 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:`✕`})]}),f&&!u&&(0,N.jsx)(`pre`,{className:`mb-3 max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md bg-zinc-50 p-2 font-mono text-xs text-zinc-600 dark:bg-zinc-950 dark:text-zinc-400`,children:f}),e.method===`select`&&(0,N.jsx)(`div`,{role:`group`,"aria-label":`Answer choices`,className:`mb-1 ${SH(e.options)}`,children:e.options.map((n,r)=>{let i=bH(n);return(0,N.jsx)(`button`,{type:`button`,autoFocus:r===0,onClick:()=>t({id:e.id,value:n}),className:`min-w-0 break-words text-left ${pH}`,children:i?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:i.label}),i.description&&(0,N.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:i.description})]}):n},n)})}),e.method===`confirm`&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`p`,{className:`mb-4 text-sm text-zinc-600 dark:text-zinc-400`,children:e.message}),(0,N.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!1}),className:pH,children:`No`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!0}),className:mH,children:`Yes`})]})]}),u&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`div`,{role:`group`,"aria-label":`Answer choices`,className:`mb-3 ${SH(u.options.map(e=>`${e.label} ${e.description}`))}`,children:u.options.map(e=>(0,N.jsxs)(`label`,{className:`flex min-w-0 cursor-pointer items-start gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:a.includes(e.index),onChange:()=>m(e.index),className:`mt-0.5`}),(0,N.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,N.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:e.label}),e.description&&(0,N.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:e.description})]})]},e.index))}),(0,N.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>i(e.target.value),placeholder:`…or type your own answer`,onKeyDown:e=>{e.key===`Enter`&&h(),e.key===`Escape`&&p()},className:`mb-1 ${hH}`}),(0,N.jsx)(`p`,{className:`mb-4 text-xs text-zinc-400 dark:text-zinc-600`,children:`A typed answer replaces the selection above.`}),(0,N.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:p,className:pH,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,onClick:h,className:mH,children:`OK`})]})]}),e.method===`input`&&!u&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>i(e.target.value),placeholder:e.placeholder,onKeyDown:n=>{n.key===`Enter`&&t({id:e.id,value:r}),n.key===`Escape`&&p()},className:gH}),(0,N.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:p,className:pH,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:r}),className:mH,children:`OK`})]})]}),e.method===`editor`&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`textarea`,{autoFocus:!0,value:r,onChange:e=>i(e.target.value),rows:8,onKeyDown:e=>{e.key===`Escape`&&p()},className:`resize-none font-mono ${gH}`}),(0,N.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:p,className:pH,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:r}),className:mH,children:`OK`})]})]}),c!==null&&(0,N.jsxs)(`p`,{className:`mt-3 text-right text-xs text-zinc-400 dark:text-zinc-600`,children:[`auto-dismiss in `,c,`s`]})]})}var wH=`rounded-md border px-3 py-1.5 text-sm border-zinc-200 hover:bg-zinc-100 disabled:opacity-50 dark:border-zinc-800 dark:hover:bg-zinc-800`,TH=`rounded-md bg-zinc-900 px-3 py-1.5 text-sm text-zinc-100 hover:bg-zinc-800 disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-white`,EH=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});function DH({request:e,onRespond:t}){let n=(0,v.useId)(),[r,i]=(0,v.useState)(null);(0,v.useEffect)(()=>i(null),[e.id]);function a(n){r||(i(n),t(e.id,n))}let{hosts:o,directories:s}=e.grant,c=e.kind===`connection`;return(0,N.jsxs)(`section`,{role:`region`,"aria-labelledby":n,"data-testid":`sandbox-grant-dialog`,"data-request-id":e.id,className:`flex max-h-[40dvh] flex-col overflow-hidden rounded-xl border border-zinc-200 bg-white dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,N.jsxs)(`div`,{"data-testid":`sandbox-grant-details`,className:`min-h-0 overflow-y-auto overscroll-contain break-words p-4`,children:[(0,N.jsx)(`h2`,{id:n,className:`mb-3 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:c?`A running command is connecting to ${o.join(`, `)}`:`The agent asks to run a command beyond its sandbox`}),(0,N.jsx)(`div`,{className:`mb-1 text-xs font-medium text-zinc-500 dark:text-zinc-400`,children:c?`The running command`:`Command`}),(0,N.jsx)(`pre`,{"data-testid":`sandbox-grant-command`,className:`mb-3 max-h-48 overflow-auto whitespace-pre-wrap break-all rounded-md bg-zinc-50 p-2 font-mono text-xs text-zinc-800 dark:bg-zinc-950 dark:text-zinc-200`,children:e.command}),(0,N.jsx)(`div`,{className:`mb-1 text-xs font-medium text-zinc-500 dark:text-zinc-400`,children:c?`It is waiting to reach`:`It would also reach`}),(0,N.jsxs)(`ul`,{"data-testid":`sandbox-grant-targets`,className:`mb-3 list-disc pl-5 text-sm text-zinc-800 dark:text-zinc-200`,children:[o.map(e=>(0,N.jsxs)(`li`,{children:[`host `,(0,N.jsx)(`code`,{className:`break-all font-mono`,children:e})]},`host:${e}`)),s.map(e=>(0,N.jsxs)(`li`,{children:[e.access===`write`?`read and write`:`read`,` `,(0,N.jsx)(`code`,{className:`break-all font-mono`,children:e.path})]},`dir:${e.path}`))]}),e.overridesReadOnly&&(0,N.jsx)(`p`,{"data-testid":`sandbox-grant-overrides`,className:`mb-3 rounded-md bg-amber-50 p-2 text-xs text-amber-800 dark:bg-amber-900/40 dark:text-amber-200`,children:`Writing is off in this project's sandbox: allowing this lets the command write there anyway.`}),c?(0,N.jsx)(`p`,{"data-testid":`sandbox-grant-reason`,className:`mb-4 text-sm text-zinc-600 dark:text-zinc-400`,children:`Not in this sandbox's allowed hosts. The agent did not ask for it: the command connected, and waits for your answer.`}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`div`,{className:`mb-1 text-xs font-medium text-zinc-500 dark:text-zinc-400`,children:`The agent says`}),(0,N.jsx)(`blockquote`,{"data-testid":`sandbox-grant-reason`,className:`mb-4 border-l-2 border-zinc-300 pl-2 text-sm italic text-zinc-600 dark:border-zinc-700 dark:text-zinc-400`,children:e.reason})]})]}),(0,N.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-zinc-200 p-3 dark:border-zinc-700`,children:[(0,N.jsxs)(`span`,{className:`mr-auto text-xs text-zinc-500 dark:text-zinc-400`,children:[`Refused if unanswered by `,EH(e.expiresAt)]}),(0,N.jsx)(`button`,{type:`button`,className:wH,disabled:r!==null,onClick:()=>a(`refuse`),children:`Refuse`}),(0,N.jsx)(`button`,{type:`button`,className:wH,disabled:r!==null,onClick:()=>a(`session`),children:`Allow for this session`}),(0,N.jsx)(`button`,{type:`button`,className:TH,disabled:r!==null,onClick:()=>a(`once`),children:c?`Allow for this command`:`Allow once`})]})]})}var OH={info:`border-blue-300 bg-blue-50 text-blue-800 dark:border-blue-900 dark:bg-blue-950/60 dark:text-blue-200`,warning:`border-amber-300 bg-amber-50 text-amber-800 dark:border-amber-900 dark:bg-amber-950/60 dark:text-amber-200`,error:`border-red-300 bg-red-50 text-red-800 dark:border-red-900 dark:bg-red-950/60 dark:text-red-200`},kH=6e3;function AH({notification:e,onDismiss:t}){let n=(0,v.useRef)(t);return(0,v.useEffect)(()=>{n.current=t}),(0,v.useEffect)(()=>{let e=setTimeout(()=>n.current(),kH);return()=>clearTimeout(e)},[e.id]),(0,N.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-lg border px-3 py-2 text-sm shadow-lg ${OH[e.notifyType??`info`]}`,children:[(0,N.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:e.message}),(0,N.jsx)(`button`,{type:`button`,"aria-label":`Dismiss notification`,onClick:()=>n.current(),className:`-mr-1 shrink-0 rounded px-1 leading-5 opacity-60 transition-opacity hover:opacity-100 focus-visible:opacity-100`,children:`×`})]})}function jH({notifications:e,onDismiss:t}){return e.length===0?null:(0,N.jsx)(`div`,{className:`fixed right-4 top-16 z-40 flex w-80 flex-col gap-2`,children:e.map(e=>(0,N.jsx)(AH,{notification:e,onDismiss:()=>t(e.id)},e.id))})}var MH={30:`#3f3f46`,31:`#dc2626`,32:`#16a34a`,33:`#ca8a04`,34:`#2563eb`,35:`#9333ea`,36:`#0891b2`,37:`#71717a`,90:`#a1a1aa`,91:`#ef4444`,92:`#22c55e`,93:`#eab308`,94:`#3b82f6`,95:`#a855f7`,96:`#06b6d4`,97:`#d4d4d8`};function NH(e){if(!Number.isInteger(e)||e<0||e>255)return;if(e<16)return MH[e<8?30+e:90+e-8];if(e>=232){let t=8+(e-232)*10;return`rgb(${t} ${t} ${t})`}let t=e-16,n=e=>e===0?0:55+e*40;return`rgb(${n(Math.floor(t/36))} ${n(Math.floor(t/6)%6)} ${n(t%6)})`}var PH=/\u001B\[[0-9;:]*[A-Za-z]|\u001B[()][A-Za-z0-9]|\u001B[A-Za-z]/g;function FH(e,t){let n={...e};for(let e=0;e<t.length;e++){let r=t[e];if(r===0)for(let e of Object.keys(n))delete n[e];else if(r===1)n.bold=!0;else if(r===2)n.dim=!0;else if(r===3)n.italic=!0;else if(r===4)n.underline=!0;else if(r===22)delete n.bold,delete n.dim;else if(r===23)delete n.italic;else if(r===24)delete n.underline;else if(r===39)delete n.color;else if(MH[r]!==void 0)n.color=MH[r];else if(r===38){if(t[e+1]===2){let[r,i,a]=[t[e+2],t[e+3],t[e+4]];[r,i,a].every(e=>Number.isFinite(e))&&(n.color=`rgb(${r} ${i} ${a})`),e+=4}else if(t[e+1]===5){let r=NH(t[e+2]);r!==void 0&&(n.color=r),e+=2}}}return n}function IH(e){let t=[],n={},r=0;PH.lastIndex=0;for(let i=PH.exec(e);i!==null;i=PH.exec(e)){i.index>r&&t.push({text:e.slice(r,i.index),...n}),r=i.index+i[0].length;let a=i[0];if(a.endsWith(`m`)){let e=a.slice(2,-1),t=e===``?[0]:e.split(/[;:]/).map(e=>e===``?0:Number(e));n=FH(n,t)}}return r<e.length&&t.push({text:e.slice(r),...n}),t}function LH(e){return e.replace(PH,``)}function RH({text:e}){let t=IH(e);return(0,N.jsx)(N.Fragment,{children:t.map((e,t)=>(0,N.jsx)(`span`,{style:{...e.color?{color:e.color}:{},...e.bold?{fontWeight:600}:{},...e.dim?{opacity:.7}:{},...e.italic?{fontStyle:`italic`}:{},...e.underline?{textDecoration:`underline`}:{}},children:e.text},t))})}function zH({widgets:e,placement:t,controls:n={}}){let r=Object.entries(e).filter(([,e])=>e.placement===t);return r.length===0?null:(0,N.jsx)(`div`,{className:`mb-2 flex flex-col gap-1`,children:r.map(([e,t])=>(0,N.jsx)(VH,{name:e,lines:t.lines,control:n[e]??{}},e))})}function BH({text:e}){return(0,N.jsx)(`div`,{className:`min-h-4`,children:(0,N.jsx)(RH,{text:e})})}function VH({name:e,lines:t,control:n}){let r=(0,v.useRef)(null),i=t.slice(0,n.pinnedLines??0),a=t.slice(i.length),o=n.anchor?n.anchor(t)-i.length:-1;return(0,v.useLayoutEffect)(()=>{let e=r.current,t=o>=0?e?.children[o]:void 0;e&&t&&(e.scrollTop=t.offsetTop)},[t,o]),(0,N.jsxs)(`div`,{"data-widget":e,className:`flex items-start gap-2 rounded-md border border-zinc-200 bg-zinc-50 px-3 py-1.5 font-mono text-xs text-zinc-600 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-400`,children:[(0,N.jsxs)(`div`,{className:`min-w-0 flex-1 whitespace-pre-wrap`,children:[i.map((e,t)=>(0,N.jsx)(BH,{text:e},t)),(0,N.jsx)(`div`,{ref:r,tabIndex:0,"aria-label":n.region??`Extension widget ${e}`,className:`relative max-h-[20vh] overflow-y-auto rounded-sm focus:outline-none focus-visible:ring-1 focus-visible:ring-zinc-400`,children:a.map((e,t)=>(0,N.jsx)(BH,{text:e},t))})]}),n.close&&(0,N.jsx)(`button`,{type:`button`,"aria-label":n.close.label,title:n.close.label,onClick:n.close.run,className:`-mr-1 shrink-0 rounded px-1 font-sans text-sm leading-5 opacity-60 transition-opacity hover:opacity-100 focus-visible:opacity-100`,children:`×`})]})}var HH=null,UH=null;function WH(){return UH??=ye(()=>import(`./CodeEditor-CVdicAoQ.js`).then(e=>e.t).then(e=>HH=e,e=>{throw UH=null,e}),__vite__mapDeps([22,1,23])),UH}var GH=(0,v.lazy)(()=>{if(HH!==null){let e=HH;return{then:t=>t({default:e.CodeEditor})}}return WH().then(e=>({default:e.CodeEditor}))});function KH({text:e,path:t,serverUrl:n,token:r,workspace:i,template:a}){let[o,s]=(0,v.useState)(`idle`),[c,l]=(0,v.useState)(`plain`),[u,d]=(0,v.useState)(null),f=(0,v.useRef)(!1),p=(0,v.useRef)({plain:0,template:0});async function m(a){if(!(f.current||Date.now()-p.current[a]<750)){f.current=!0,p.current[a]=Date.now(),l(a),s(`working`),d(null);try{let{downloadDocx:o,downloadDocxInTemplate:c}=await ye(async()=>{let{downloadDocx:e,downloadDocxInTemplate:t}=await import(`./docxExport-5ja7lYgY.js`);return{downloadDocx:e,downloadDocxInTemplate:t}},__vite__mapDeps([24,21,1,25])),l=typeof e==`function`?e():e;await(a===`template`?c:o)(l,t,{serverUrl:n,token:r,workspace:i}),s(`idle`)}catch(e){s(`failed`),d(e instanceof Error?e.message:String(e))}finally{f.current=!1}}}let h=`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 disabled:opacity-50 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`,g=(e,t)=>o===`working`&&c===e?`… exporting`:o===`failed`&&c===e?`⚠ export failed`:t,_=(e,t)=>o===`failed`&&c===e?`Could not export: ${u??`unknown reason`}`:t;return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>void m(`plain`),disabled:o===`working`,title:_(`plain`,`Download as a Word document`),"aria-label":`Download as a Word document`,className:h,children:g(`plain`,`⤓ word`)}),a!==void 0&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>void m(`template`),disabled:o===`working`,title:_(`template`,`Download as a Word document in the template ${a}`),"aria-label":`Download as a Word document in the template ${a}`,className:h,children:g(`template`,`⤓ word · template`)})]})}var qH=3e4,JH=(0,v.forwardRef)(function({serverUrl:e},t){let[n,r]=(0,v.useState)(null),i=(0,v.useRef)(null),a=(0,v.useRef)(Promise.resolve()),o=(0,v.useRef)(null),s=(0,v.useRef)(0);function c(e,t){let n=i.current;n!==null&&n.id===e&&(clearTimeout(n.timer),i.current=null,r(null),t instanceof Error?n.reject(t):n.resolve(t))}if((0,v.useImperativeHandle)(t,()=>({draw(e){let t=()=>new Promise((t,n)=>{let a=++s.current,o=setTimeout(()=>c(a,Error(`the draw.io viewer did not answer`)),qH);i.current={id:a,resolve:t,reject:n,timer:o},r({id:a,xml:e})}),n=a.current.then(t,t);return a.current=n.catch(()=>void 0),n}}),[]),(0,v.useEffect)(()=>()=>{let e=i.current;e!==null&&(clearTimeout(e.timer),i.current=null,e.reject(Error(`the poster was closed`)))},[]),n===null)return null;let{id:l}=n;return(0,N.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`drawio-painter`,style:{position:`fixed`,left:-2e4,top:0,width:1200,height:900,pointerEvents:`none`},children:(0,N.jsx)(Km,{ref:o,xml:n.xml,serverUrl:e,title:`draw.io diagram for a poster`,className:`flex h-full flex-col`,onRendered:e=>{if(e!==null)return c(l,Error(e));o.current?.exportSvg().then(({svg:e})=>c(l,e),e=>c(l,e instanceof Error?e:Error(String(e))))}},l)})});function YH(e,t=window.location.href){return new URL(`${e}/${l}`,t).href}var XH=`allow-scripts allow-same-origin`,ZH=`Discard the unsaved touch-ups to this diagram?`;function QH(e,t,n){let r=URL.createObjectURL(new Blob([t],{type:n}));try{let t=document.createElement(`a`);t.href=r,t.download=e,t.click()}finally{URL.revokeObjectURL(r)}}function $H({path:i,content:a,mtimeMs:s,writable:l,loadFile:u,fallback:d,onTouchUpDirtyChange:f}){let{serverUrl:p,fileIo:m,onOpenNative:h}=Fm(),g=x()===`dark`,_=(0,v.useRef)(null),y=(0,v.useRef)(null),b=(0,v.useMemo)(()=>YH(p),[p]),S=(0,v.useMemo)(()=>{try{return{page:r(a)}}catch(e){return{problem:e instanceof Error?e.message:String(e)}}},[a]),C=(0,v.useRef)(null),w=(0,v.useRef)(null),T=(0,v.useRef)(!1),E=(0,v.useRef)(null),D=(0,v.useRef)(()=>{}),[O,ee]=(0,v.useState)(!l||m===void 0),te=(0,v.useRef)(!1),k=(0,v.useRef)(f);k.current=f;let ne=(0,v.useRef)({path:i,content:a,mtimeMs:s,dark:g,readOnly:O,poster:S,loadFile:u});ne.current={path:i,content:a,mtimeMs:s,dark:g,readOnly:O,poster:S,loadFile:u};let[A,re]=(0,v.useState)(null),j=(0,v.useRef)(A);j.current=A;let ie=(0,v.useRef)(!1),ae=(0,v.useRef)(()=>{});(0,v.useEffect)(()=>{let r=!0,i=new URL(b).origin,a=e=>_.current?.contentWindow?.postMessage(e,i),s=(e,t)=>{r&&a({type:o.ANSWER,id:e,value:t})};ae.current=s;let u=0;async function d(){let e=++u,{path:t,content:n,mtimeMs:i,poster:s,dark:c}=ne.current;if(!(`page`in s))return;let d=l&&m!==void 0;if(d)try{await m.read(t)}catch{d=!1}r&&e===u&&(C.current=d?{mtimeMs:i}:null,w.current=n,ee(!d),a({type:o.OPEN,poster:{...s.page,revision:0,readOnly:!d},theme:c?`dark`:`light`}))}D.current=()=>{te.current&&!T.current&&ne.current.content!==E.current&&(E.current=null,ne.current.content===w.current?C.current!==null&&(C.current={mtimeMs:ne.current.mtimeMs}):d())};async function f(e,t,r){let{path:i,poster:a}=ne.current;if(!(`page`in a)||m===void 0||C.current===null||ne.current.readOnly)s(e,{saved:!1,message:`this file cannot be saved here`});else try{let o=n(a.page.title,{html:t,css:r,format:a.page.format}),{mtimeMs:c}=await m.write(i,o,C.current.mtimeMs);C.current={mtimeMs:c},ne.current.content!==o&&(E.current=ne.current.content),w.current=o,s(e,{saved:!0,revision:0,message:`Saved. The agent reads this version.`})}catch(t){let n=t instanceof wz&&t.reason===`conflict`;s(e,{saved:!1,message:n?`the file changed on disk since it was opened, so it was not saved. Close and reopen it to see what is there now.`:t instanceof Error?t.message:String(t)})}}async function p(e,t){let n;try{n={ok:!0,value:await t()}}catch(e){n={ok:!1,message:e instanceof Error?e.message:String(e)}}s(e,n)}async function h(){if(m?.find===void 0)throw Error(`this view cannot look through the project's files`);let e=new Set;for(let t of[`.drawio`,`.dio`])for(let n of await m.find(t))n.type===`file`&&ce(n.path)&&e.add(n.path);let t=ne.current.path;return Promise.all([...e].map(async e=>{let n=[];try{n=Mz((await m.read(e)).content)}catch{}return{path:Fz(t,e),pages:n}}))}async function g(e,t){let n=oe(ne.current.path,e);if(!ce(n))throw Error(`"${e}" is not a .drawio file`);if(m===void 0)throw Error(`this view cannot read the project's files`);let r;try{r=(await m.read(n)).content}catch(t){throw Error(`"${e}" could not be read: ${t instanceof Error?t.message:String(t)}`)}let i=Pz(r,t);if(y.current===null)throw Error(`the poster was closed`);return y.current.draw(i)}async function v(e,t,n){let i=t=>s(e,{ok:!1,message:t});if(j.current!==null)return i(`another diagram is open for touch-up`);let a=oe(ne.current.path,t);if(!ce(a))return i(`"${t}" is not a .drawio file`);if(m===void 0)return i(`this view cannot read the project's files`);let o;try{o=(await m.read(a)).content,Mz(o)}catch(e){return i(`"${t}" could not be opened: ${e instanceof Error?e.message:String(e)}`)}r&&(ie.current=!1,re({file:a,page:n,id:e,before:o}))}async function x(){if(m?.find===void 0)throw Error(`this view cannot look through the project's files`);let e=new Set;for(let n of Object.keys(c))for(let r of await m.find(n))r.type===`file`&&t(r.path)!==void 0&&e.add(r.path);let n=ne.current.path;return[...e].map(e=>Fz(n,e))}async function S(n){let r=oe(ne.current.path,n),i=t(r);if(i===void 0)throw Error(`"${n}" is not a picture file (SVG, PNG, JPEG, GIF or WebP)`);let a=ne.current.loadFile;if(a===void 0)throw Error(`this view cannot read the project's files`);let o=await a(r);if(o===void 0)throw Error(`"${n}" could not be read: it is not there, or not in the project`);if(o.size>20971520)throw Error(`"${n}" is ${Math.round(o.size/1024/1024)} MB, more than a poster reads (${e/1024/1024} MB)`);return{type:i,bytes:new Uint8Array(await o.arrayBuffer())}}function O(e){if(_.current===null||e.source!==_.current.contentWindow||e.origin!==i)return;let t=e.data;if(typeof t==`object`&&t){if(t.type===o.READY)te.current=!0,d();else if(t.type===o.DIRTY)T.current=t.dirty===!0,k.current?.(T.current),D.current();else if(t.type===o.SAVE&&typeof t.html==`string`&&typeof t.css==`string`)f(t.id,t.html,t.css);else if(t.type===o.DELIVER&&typeof t.name==`string`&&typeof t.mediaType==`string`&&t.bytes instanceof Uint8Array)QH(t.name,t.bytes,t.mediaType),s(t.id,`Downloaded "${t.name}".`);else if(t.type===o.DRAWIO_LIST)p(t.id,h);else if(t.type===o.DRAWIO_DRAW){let{path:e,page:n}=t;typeof e==`string`&&p(t.id,()=>g(e,typeof n==`string`?n:void 0))}else if(t.type===o.DRAWIO_EDIT){let{path:e,page:n}=t;typeof e==`string`&&v(t.id,e,typeof n==`string`?n:void 0)}else if(t.type===o.PICTURE_LIST)p(t.id,x);else if(t.type===o.PICTURE_READ){let{path:e}=t;typeof e==`string`&&p(t.id,()=>S(e))}}}return window.addEventListener(`message`,O),()=>{r=!1,te.current=!1,re(null),D.current=()=>{},k.current?.(!1),window.removeEventListener(`message`,O)}},[b,m,l]),(0,v.useEffect)(()=>D.current(),[a,s]),(0,v.useEffect)(()=>{te.current&&_.current?.contentWindow?.postMessage({type:o.THEME,theme:g?`dark`:`light`},new URL(b).origin)},[g,b]);async function se(){let e=j.current;if(e===null||ie.current&&!window.confirm(ZH))return;re(null);let t;try{t={ok:!0,value:(await m.read(e.file)).content!==e.before}}catch(e){t={ok:!1,message:`the diagram could not be read again: ${e instanceof Error?e.message:String(e)}`}}ae.current(e.id,t)}let le=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(A===null)return;le.current?.focus();function e(e){e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),e.stopImmediatePropagation(),ue.current())}return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[A]);let ue=(0,v.useRef)(se);ue.current=se;let de=(0,v.useCallback)(()=>void ue.current(),[]),fe=(0,v.useCallback)(e=>{ie.current=e},[]);return`problem`in S?(0,N.jsxs)(`div`,{"data-testid":`poster-unreadable`,children:[(0,N.jsxs)(`p`,{className:`border-b border-amber-300 bg-amber-50 px-3 py-1.5 text-xs text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200`,children:[`This poster cannot be opened in the editor: `,S.problem,`.`]}),d]}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`iframe`,{ref:_,title:i,"data-testid":`poster-frame`,"data-read-only":O?`true`:`false`,sandbox:XH,src:b,className:`block h-full w-full border-0`}),(0,N.jsx)(JH,{ref:y,serverUrl:p}),A!==null&&De(_.current)!==void 0&&(0,Ee.createPortal)((0,N.jsx)(`div`,{ref:le,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":`Touch up ${A.file}`,"data-testid":`poster-diagram-touch-up`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4 outline-none`,children:(0,N.jsxs)(`div`,{className:`flex h-full max-h-[56rem] w-full max-w-[90rem] flex-col overflow-hidden rounded-lg border border-zinc-300 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,N.jsxs)(`header`,{className:`flex shrink-0 items-center gap-2 border-b border-zinc-200 px-3 py-2 text-sm dark:border-zinc-800`,children:[(0,N.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,title:A.file,children:[A.file,A.page===void 0?``:` — ${A.page}`]}),h&&(0,N.jsx)(`button`,{type:`button`,className:`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200 disabled:opacity-50`,onClick:()=>h(A.file),title:`Open the diagram in draw.io desktop, for anything more than a touch-up; its saves come back here`,children:`↗ draw.io desktop`}),(0,N.jsx)(`button`,{type:`button`,className:`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200 disabled:opacity-50`,onClick:()=>void se(),title:`Back to the poster, which takes the diagram as saved (Escape)`,children:`back to the poster`})]}),(0,N.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,N.jsx)(Uz,{path:A.file,variant:`viewer`,page:A.page,startTouchUp:!0,onTouchUpDirtyChange:fe,onEscape:de})})]})}),De(_.current))]})}var eU=`pi-outpost:open`,tU=4,nU={css:`text/css`,js:`text/javascript`,mjs:`text/javascript`,png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,avif:`image/avif`,svg:`image/svg+xml`,ico:`image/x-icon`,bmp:`image/bmp`,woff:`font/woff`,woff2:`font/woff2`,ttf:`font/ttf`,otf:`font/otf`,mp4:`video/mp4`,webm:`video/webm`,mp3:`audio/mpeg`,wav:`audio/wav`,ogg:`audio/ogg`},rU=`(function () {
|
|
839
|
+
`)){let t=bH(e);t&&r.push(t)}return r.length<2||r.some((e,t)=>e.index!==t+1)?null:{heading:t,options:r}}function SH(e){return`grid grid-cols-1 gap-2${e.length>1&&e.every(e=>e.length<=120)?` @min-[41rem]:grid-cols-2`:``}`}function CH({request:e,onRespond:t}){let n=(0,v.useId)(),[r,i]=(0,v.useState)(e.method===`editor`?e.prefill??``:``),[a,o]=(0,v.useState)([]),s=(e.method===`select`||e.method===`confirm`||e.method===`input`)&&e.timeout,[c,l]=(0,v.useState)(s?Math.ceil(s/1e3):null),u=xH(e),{heading:d,body:f}=yH(e.title);function p(){t({id:e.id,cancelled:!0})}function m(e){o(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e].sort((e,t)=>e-t))}function h(){let n=r.trim();t({id:e.id,value:n.length>0?n:a.join(`,`)})}return(0,v.useEffect)(()=>{if(c===null)return;if(c<=0){t({id:e.id,cancelled:!0});return}let n=setTimeout(()=>l(e=>e===null?null:e-1),1e3);return()=>clearTimeout(n)},[c,e.id,t]),(0,N.jsxs)(`section`,{role:`region`,"aria-labelledby":n,className:`@container max-h-[40dvh] overflow-y-auto overscroll-contain rounded-xl border border-zinc-200 bg-white p-4 dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,N.jsxs)(`div`,{className:`mb-3 flex items-start gap-3`,children:[(0,N.jsx)(`h2`,{id:n,className:`min-w-0 flex-1 break-words text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:d}),(0,N.jsx)(`button`,{type:`button`,onClick:p,"aria-label":`Refuse to answer`,title:`Refuse to answer`,className:`-mr-1 -mt-1 shrink-0 rounded-md px-1.5 py-0.5 text-sm leading-none text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-500 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:`✕`})]}),f&&!u&&(0,N.jsx)(`pre`,{className:`mb-3 max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md bg-zinc-50 p-2 font-mono text-xs text-zinc-600 dark:bg-zinc-950 dark:text-zinc-400`,children:f}),e.method===`select`&&(0,N.jsx)(`div`,{role:`group`,"aria-label":`Answer choices`,className:`mb-1 ${SH(e.options)}`,children:e.options.map((n,r)=>{let i=bH(n);return(0,N.jsx)(`button`,{type:`button`,autoFocus:r===0,onClick:()=>t({id:e.id,value:n}),className:`min-w-0 break-words text-left ${pH}`,children:i?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:i.label}),i.description&&(0,N.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:i.description})]}):n},n)})}),e.method===`confirm`&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`p`,{className:`mb-4 text-sm text-zinc-600 dark:text-zinc-400`,children:e.message}),(0,N.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!1}),className:pH,children:`No`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!0}),className:mH,children:`Yes`})]})]}),u&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`div`,{role:`group`,"aria-label":`Answer choices`,className:`mb-3 ${SH(u.options.map(e=>`${e.label} ${e.description}`))}`,children:u.options.map(e=>(0,N.jsxs)(`label`,{className:`flex min-w-0 cursor-pointer items-start gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:a.includes(e.index),onChange:()=>m(e.index),className:`mt-0.5`}),(0,N.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,N.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:e.label}),e.description&&(0,N.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:e.description})]})]},e.index))}),(0,N.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>i(e.target.value),placeholder:`…or type your own answer`,onKeyDown:e=>{e.key===`Enter`&&h(),e.key===`Escape`&&p()},className:`mb-1 ${hH}`}),(0,N.jsx)(`p`,{className:`mb-4 text-xs text-zinc-400 dark:text-zinc-600`,children:`A typed answer replaces the selection above.`}),(0,N.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:p,className:pH,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,onClick:h,className:mH,children:`OK`})]})]}),e.method===`input`&&!u&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>i(e.target.value),placeholder:e.placeholder,onKeyDown:n=>{n.key===`Enter`&&t({id:e.id,value:r}),n.key===`Escape`&&p()},className:gH}),(0,N.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:p,className:pH,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:r}),className:mH,children:`OK`})]})]}),e.method===`editor`&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`textarea`,{autoFocus:!0,value:r,onChange:e=>i(e.target.value),rows:8,onKeyDown:e=>{e.key===`Escape`&&p()},className:`resize-none font-mono ${gH}`}),(0,N.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:p,className:pH,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:r}),className:mH,children:`OK`})]})]}),c!==null&&(0,N.jsxs)(`p`,{className:`mt-3 text-right text-xs text-zinc-400 dark:text-zinc-600`,children:[`auto-dismiss in `,c,`s`]})]})}var wH=`rounded-md border px-3 py-1.5 text-sm border-zinc-200 hover:bg-zinc-100 disabled:opacity-50 dark:border-zinc-800 dark:hover:bg-zinc-800`,TH=`rounded-md bg-zinc-900 px-3 py-1.5 text-sm text-zinc-100 hover:bg-zinc-800 disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-white`,EH=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});function DH({request:e,onRespond:t}){let n=(0,v.useId)(),[r,i]=(0,v.useState)(null);(0,v.useEffect)(()=>i(null),[e.id]);function a(n){r||(i(n),t(e.id,n))}let{hosts:o,directories:s}=e.grant,c=e.kind===`connection`;return(0,N.jsxs)(`section`,{role:`region`,"aria-labelledby":n,"data-testid":`sandbox-grant-dialog`,"data-request-id":e.id,className:`flex max-h-[40dvh] flex-col overflow-hidden rounded-xl border border-zinc-200 bg-white dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,N.jsxs)(`div`,{"data-testid":`sandbox-grant-details`,className:`min-h-0 overflow-y-auto overscroll-contain break-words p-4`,children:[(0,N.jsx)(`h2`,{id:n,className:`mb-3 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:c?`A running command is connecting to ${o.join(`, `)}`:`The agent asks to run a command beyond its sandbox`}),(0,N.jsx)(`div`,{className:`mb-1 text-xs font-medium text-zinc-500 dark:text-zinc-400`,children:c?`The running command`:`Command`}),(0,N.jsx)(`pre`,{"data-testid":`sandbox-grant-command`,className:`mb-3 max-h-48 overflow-auto whitespace-pre-wrap break-all rounded-md bg-zinc-50 p-2 font-mono text-xs text-zinc-800 dark:bg-zinc-950 dark:text-zinc-200`,children:e.command}),(0,N.jsx)(`div`,{className:`mb-1 text-xs font-medium text-zinc-500 dark:text-zinc-400`,children:c?`It is waiting to reach`:`It would also reach`}),(0,N.jsxs)(`ul`,{"data-testid":`sandbox-grant-targets`,className:`mb-3 list-disc pl-5 text-sm text-zinc-800 dark:text-zinc-200`,children:[o.map(e=>(0,N.jsxs)(`li`,{children:[`host `,(0,N.jsx)(`code`,{className:`break-all font-mono`,children:e})]},`host:${e}`)),s.map(e=>(0,N.jsxs)(`li`,{children:[e.access===`write`?`read and write`:`read`,` `,(0,N.jsx)(`code`,{className:`break-all font-mono`,children:e.path})]},`dir:${e.path}`))]}),e.overridesReadOnly&&(0,N.jsx)(`p`,{"data-testid":`sandbox-grant-overrides`,className:`mb-3 rounded-md bg-amber-50 p-2 text-xs text-amber-800 dark:bg-amber-900/40 dark:text-amber-200`,children:`Writing is off in this project's sandbox: allowing this lets the command write there anyway.`}),c?(0,N.jsx)(`p`,{"data-testid":`sandbox-grant-reason`,className:`mb-4 text-sm text-zinc-600 dark:text-zinc-400`,children:`Not in this sandbox's allowed hosts. The agent did not ask for it: the command connected, and waits for your answer.`}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`div`,{className:`mb-1 text-xs font-medium text-zinc-500 dark:text-zinc-400`,children:`The agent says`}),(0,N.jsx)(`blockquote`,{"data-testid":`sandbox-grant-reason`,className:`mb-4 border-l-2 border-zinc-300 pl-2 text-sm italic text-zinc-600 dark:border-zinc-700 dark:text-zinc-400`,children:e.reason})]})]}),(0,N.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-zinc-200 p-3 dark:border-zinc-700`,children:[(0,N.jsxs)(`span`,{className:`mr-auto text-xs text-zinc-500 dark:text-zinc-400`,children:[`Refused if unanswered by `,EH(e.expiresAt)]}),(0,N.jsx)(`button`,{type:`button`,className:wH,disabled:r!==null,onClick:()=>a(`refuse`),children:`Refuse`}),(0,N.jsx)(`button`,{type:`button`,className:wH,disabled:r!==null,onClick:()=>a(`session`),children:`Allow for this session`}),(0,N.jsx)(`button`,{type:`button`,className:TH,disabled:r!==null,onClick:()=>a(`once`),children:c?`Allow for this command`:`Allow once`})]})]})}var OH={info:`border-blue-300 bg-blue-50 text-blue-800 dark:border-blue-900 dark:bg-blue-950/60 dark:text-blue-200`,warning:`border-amber-300 bg-amber-50 text-amber-800 dark:border-amber-900 dark:bg-amber-950/60 dark:text-amber-200`,error:`border-red-300 bg-red-50 text-red-800 dark:border-red-900 dark:bg-red-950/60 dark:text-red-200`},kH=6e3;function AH({notification:e,onDismiss:t}){let n=(0,v.useRef)(t);return(0,v.useEffect)(()=>{n.current=t}),(0,v.useEffect)(()=>{let e=setTimeout(()=>n.current(),kH);return()=>clearTimeout(e)},[e.id]),(0,N.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-lg border px-3 py-2 text-sm shadow-lg ${OH[e.notifyType??`info`]}`,children:[(0,N.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:e.message}),(0,N.jsx)(`button`,{type:`button`,"aria-label":`Dismiss notification`,onClick:()=>n.current(),className:`-mr-1 shrink-0 rounded px-1 leading-5 opacity-60 transition-opacity hover:opacity-100 focus-visible:opacity-100`,children:`×`})]})}function jH({notifications:e,onDismiss:t}){return e.length===0?null:(0,N.jsx)(`div`,{className:`fixed right-4 top-16 z-40 flex w-80 flex-col gap-2`,children:e.map(e=>(0,N.jsx)(AH,{notification:e,onDismiss:()=>t(e.id)},e.id))})}var MH={30:`#3f3f46`,31:`#dc2626`,32:`#16a34a`,33:`#ca8a04`,34:`#2563eb`,35:`#9333ea`,36:`#0891b2`,37:`#71717a`,90:`#a1a1aa`,91:`#ef4444`,92:`#22c55e`,93:`#eab308`,94:`#3b82f6`,95:`#a855f7`,96:`#06b6d4`,97:`#d4d4d8`};function NH(e){if(!Number.isInteger(e)||e<0||e>255)return;if(e<16)return MH[e<8?30+e:90+e-8];if(e>=232){let t=8+(e-232)*10;return`rgb(${t} ${t} ${t})`}let t=e-16,n=e=>e===0?0:55+e*40;return`rgb(${n(Math.floor(t/36))} ${n(Math.floor(t/6)%6)} ${n(t%6)})`}var PH=/\u001B\[[0-9;:]*[A-Za-z]|\u001B[()][A-Za-z0-9]|\u001B[A-Za-z]/g;function FH(e,t){let n={...e};for(let e=0;e<t.length;e++){let r=t[e];if(r===0)for(let e of Object.keys(n))delete n[e];else if(r===1)n.bold=!0;else if(r===2)n.dim=!0;else if(r===3)n.italic=!0;else if(r===4)n.underline=!0;else if(r===22)delete n.bold,delete n.dim;else if(r===23)delete n.italic;else if(r===24)delete n.underline;else if(r===39)delete n.color;else if(MH[r]!==void 0)n.color=MH[r];else if(r===38){if(t[e+1]===2){let[r,i,a]=[t[e+2],t[e+3],t[e+4]];[r,i,a].every(e=>Number.isFinite(e))&&(n.color=`rgb(${r} ${i} ${a})`),e+=4}else if(t[e+1]===5){let r=NH(t[e+2]);r!==void 0&&(n.color=r),e+=2}}}return n}function IH(e){let t=[],n={},r=0;PH.lastIndex=0;for(let i=PH.exec(e);i!==null;i=PH.exec(e)){i.index>r&&t.push({text:e.slice(r,i.index),...n}),r=i.index+i[0].length;let a=i[0];if(a.endsWith(`m`)){let e=a.slice(2,-1),t=e===``?[0]:e.split(/[;:]/).map(e=>e===``?0:Number(e));n=FH(n,t)}}return r<e.length&&t.push({text:e.slice(r),...n}),t}function LH(e){return e.replace(PH,``)}function RH({text:e}){let t=IH(e);return(0,N.jsx)(N.Fragment,{children:t.map((e,t)=>(0,N.jsx)(`span`,{style:{...e.color?{color:e.color}:{},...e.bold?{fontWeight:600}:{},...e.dim?{opacity:.7}:{},...e.italic?{fontStyle:`italic`}:{},...e.underline?{textDecoration:`underline`}:{}},children:e.text},t))})}function zH({widgets:e,placement:t,controls:n={}}){let r=Object.entries(e).filter(([,e])=>e.placement===t);return r.length===0?null:(0,N.jsx)(`div`,{className:`mb-2 flex flex-col gap-1`,children:r.map(([e,t])=>(0,N.jsx)(VH,{name:e,lines:t.lines,control:n[e]??{}},e))})}function BH({text:e}){return(0,N.jsx)(`div`,{className:`min-h-4`,children:(0,N.jsx)(RH,{text:e})})}function VH({name:e,lines:t,control:n}){let r=(0,v.useRef)(null),i=t.slice(0,n.pinnedLines??0),a=t.slice(i.length),o=n.anchor?n.anchor(t)-i.length:-1;return(0,v.useLayoutEffect)(()=>{let e=r.current,t=o>=0?e?.children[o]:void 0;e&&t&&(e.scrollTop=t.offsetTop)},[t,o]),(0,N.jsxs)(`div`,{"data-widget":e,className:`flex items-start gap-2 rounded-md border border-zinc-200 bg-zinc-50 px-3 py-1.5 font-mono text-xs text-zinc-600 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-400`,children:[(0,N.jsxs)(`div`,{className:`min-w-0 flex-1 whitespace-pre-wrap`,children:[i.map((e,t)=>(0,N.jsx)(BH,{text:e},t)),(0,N.jsx)(`div`,{ref:r,tabIndex:0,"aria-label":n.region??`Extension widget ${e}`,className:`relative max-h-[20vh] overflow-y-auto rounded-sm focus:outline-none focus-visible:ring-1 focus-visible:ring-zinc-400`,children:a.map((e,t)=>(0,N.jsx)(BH,{text:e},t))})]}),n.close&&(0,N.jsx)(`button`,{type:`button`,"aria-label":n.close.label,title:n.close.label,onClick:n.close.run,className:`-mr-1 shrink-0 rounded px-1 font-sans text-sm leading-5 opacity-60 transition-opacity hover:opacity-100 focus-visible:opacity-100`,children:`×`})]})}var HH=null,UH=null;function WH(){return UH??=ye(()=>import(`./CodeEditor-D_pn0sQZ.js`).then(e=>e.t).then(e=>HH=e,e=>{throw UH=null,e}),__vite__mapDeps([22,1,23])),UH}var GH=(0,v.lazy)(()=>{if(HH!==null){let e=HH;return{then:t=>t({default:e.CodeEditor})}}return WH().then(e=>({default:e.CodeEditor}))});function KH({text:e,path:t,serverUrl:n,token:r,workspace:i,template:a}){let[o,s]=(0,v.useState)(`idle`),[c,l]=(0,v.useState)(`plain`),[u,d]=(0,v.useState)(null),f=(0,v.useRef)(!1),p=(0,v.useRef)({plain:0,template:0});async function m(a){if(!(f.current||Date.now()-p.current[a]<750)){f.current=!0,p.current[a]=Date.now(),l(a),s(`working`),d(null);try{let{downloadDocx:o,downloadDocxInTemplate:c}=await ye(async()=>{let{downloadDocx:e,downloadDocxInTemplate:t}=await import(`./docxExport-So9p3lay.js`);return{downloadDocx:e,downloadDocxInTemplate:t}},__vite__mapDeps([24,21,1,25])),l=typeof e==`function`?e():e;await(a===`template`?c:o)(l,t,{serverUrl:n,token:r,workspace:i}),s(`idle`)}catch(e){s(`failed`),d(e instanceof Error?e.message:String(e))}finally{f.current=!1}}}let h=`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 disabled:opacity-50 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`,g=(e,t)=>o===`working`&&c===e?`… exporting`:o===`failed`&&c===e?`⚠ export failed`:t,_=(e,t)=>o===`failed`&&c===e?`Could not export: ${u??`unknown reason`}`:t;return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>void m(`plain`),disabled:o===`working`,title:_(`plain`,`Download as a Word document`),"aria-label":`Download as a Word document`,className:h,children:g(`plain`,`⤓ word`)}),a!==void 0&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>void m(`template`),disabled:o===`working`,title:_(`template`,`Download as a Word document in the template ${a}`),"aria-label":`Download as a Word document in the template ${a}`,className:h,children:g(`template`,`⤓ word · template`)})]})}var qH=3e4,JH=(0,v.forwardRef)(function({serverUrl:e},t){let[n,r]=(0,v.useState)(null),i=(0,v.useRef)(null),a=(0,v.useRef)(Promise.resolve()),o=(0,v.useRef)(null),s=(0,v.useRef)(0);function c(e,t){let n=i.current;n!==null&&n.id===e&&(clearTimeout(n.timer),i.current=null,r(null),t instanceof Error?n.reject(t):n.resolve(t))}if((0,v.useImperativeHandle)(t,()=>({draw(e){let t=()=>new Promise((t,n)=>{let a=++s.current,o=setTimeout(()=>c(a,Error(`the draw.io viewer did not answer`)),qH);i.current={id:a,resolve:t,reject:n,timer:o},r({id:a,xml:e})}),n=a.current.then(t,t);return a.current=n.catch(()=>void 0),n}}),[]),(0,v.useEffect)(()=>()=>{let e=i.current;e!==null&&(clearTimeout(e.timer),i.current=null,e.reject(Error(`the poster was closed`)))},[]),n===null)return null;let{id:l}=n;return(0,N.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`drawio-painter`,style:{position:`fixed`,left:-2e4,top:0,width:1200,height:900,pointerEvents:`none`},children:(0,N.jsx)(Km,{ref:o,xml:n.xml,serverUrl:e,title:`draw.io diagram for a poster`,className:`flex h-full flex-col`,onRendered:e=>{if(e!==null)return c(l,Error(e));o.current?.exportSvg().then(({svg:e})=>c(l,e),e=>c(l,e instanceof Error?e:Error(String(e))))}},l)})});function YH(e,t=window.location.href){return new URL(`${e}/${l}`,t).href}var XH=`allow-scripts allow-same-origin`,ZH=`Discard the unsaved touch-ups to this diagram?`;function QH(e,t,n){let r=URL.createObjectURL(new Blob([t],{type:n}));try{let t=document.createElement(`a`);t.href=r,t.download=e,t.click()}finally{URL.revokeObjectURL(r)}}function $H({path:i,content:a,mtimeMs:s,writable:l,loadFile:u,fallback:d,onTouchUpDirtyChange:f}){let{serverUrl:p,fileIo:m,onOpenNative:h}=Fm(),g=x()===`dark`,_=(0,v.useRef)(null),y=(0,v.useRef)(null),b=(0,v.useMemo)(()=>YH(p),[p]),S=(0,v.useMemo)(()=>{try{return{page:r(a)}}catch(e){return{problem:e instanceof Error?e.message:String(e)}}},[a]),C=(0,v.useRef)(null),w=(0,v.useRef)(null),T=(0,v.useRef)(!1),E=(0,v.useRef)(null),D=(0,v.useRef)(()=>{}),[O,ee]=(0,v.useState)(!l||m===void 0),te=(0,v.useRef)(!1),k=(0,v.useRef)(f);k.current=f;let ne=(0,v.useRef)({path:i,content:a,mtimeMs:s,dark:g,readOnly:O,poster:S,loadFile:u});ne.current={path:i,content:a,mtimeMs:s,dark:g,readOnly:O,poster:S,loadFile:u};let[A,re]=(0,v.useState)(null),j=(0,v.useRef)(A);j.current=A;let ie=(0,v.useRef)(!1),ae=(0,v.useRef)(()=>{});(0,v.useEffect)(()=>{let r=!0,i=new URL(b).origin,a=e=>_.current?.contentWindow?.postMessage(e,i),s=(e,t)=>{r&&a({type:o.ANSWER,id:e,value:t})};ae.current=s;let u=0;async function d(){let e=++u,{path:t,content:n,mtimeMs:i,poster:s,dark:c}=ne.current;if(!(`page`in s))return;let d=l&&m!==void 0;if(d)try{await m.read(t)}catch{d=!1}r&&e===u&&(C.current=d?{mtimeMs:i}:null,w.current=n,ee(!d),a({type:o.OPEN,poster:{...s.page,revision:0,readOnly:!d},theme:c?`dark`:`light`}))}D.current=()=>{te.current&&!T.current&&ne.current.content!==E.current&&(E.current=null,ne.current.content===w.current?C.current!==null&&(C.current={mtimeMs:ne.current.mtimeMs}):d())};async function f(e,t,r){let{path:i,poster:a}=ne.current;if(!(`page`in a)||m===void 0||C.current===null||ne.current.readOnly)s(e,{saved:!1,message:`this file cannot be saved here`});else try{let o=n(a.page.title,{html:t,css:r,format:a.page.format}),{mtimeMs:c}=await m.write(i,o,C.current.mtimeMs);C.current={mtimeMs:c},ne.current.content!==o&&(E.current=ne.current.content),w.current=o,s(e,{saved:!0,revision:0,message:`Saved. The agent reads this version.`})}catch(t){let n=t instanceof wz&&t.reason===`conflict`;s(e,{saved:!1,message:n?`the file changed on disk since it was opened, so it was not saved. Close and reopen it to see what is there now.`:t instanceof Error?t.message:String(t)})}}async function p(e,t){let n;try{n={ok:!0,value:await t()}}catch(e){n={ok:!1,message:e instanceof Error?e.message:String(e)}}s(e,n)}async function h(){if(m?.find===void 0)throw Error(`this view cannot look through the project's files`);let e=new Set;for(let t of[`.drawio`,`.dio`])for(let n of await m.find(t))n.type===`file`&&ce(n.path)&&e.add(n.path);let t=ne.current.path;return Promise.all([...e].map(async e=>{let n=[];try{n=Mz((await m.read(e)).content)}catch{}return{path:Fz(t,e),pages:n}}))}async function g(e,t){let n=oe(ne.current.path,e);if(!ce(n))throw Error(`"${e}" is not a .drawio file`);if(m===void 0)throw Error(`this view cannot read the project's files`);let r;try{r=(await m.read(n)).content}catch(t){throw Error(`"${e}" could not be read: ${t instanceof Error?t.message:String(t)}`)}let i=Pz(r,t);if(y.current===null)throw Error(`the poster was closed`);return y.current.draw(i)}async function v(e,t,n){let i=t=>s(e,{ok:!1,message:t});if(j.current!==null)return i(`another diagram is open for touch-up`);let a=oe(ne.current.path,t);if(!ce(a))return i(`"${t}" is not a .drawio file`);if(m===void 0)return i(`this view cannot read the project's files`);let o;try{o=(await m.read(a)).content,Mz(o)}catch(e){return i(`"${t}" could not be opened: ${e instanceof Error?e.message:String(e)}`)}r&&(ie.current=!1,re({file:a,page:n,id:e,before:o}))}async function x(){if(m?.find===void 0)throw Error(`this view cannot look through the project's files`);let e=new Set;for(let n of Object.keys(c))for(let r of await m.find(n))r.type===`file`&&t(r.path)!==void 0&&e.add(r.path);let n=ne.current.path;return[...e].map(e=>Fz(n,e))}async function S(n){let r=oe(ne.current.path,n),i=t(r);if(i===void 0)throw Error(`"${n}" is not a picture file (SVG, PNG, JPEG, GIF or WebP)`);let a=ne.current.loadFile;if(a===void 0)throw Error(`this view cannot read the project's files`);let o=await a(r);if(o===void 0)throw Error(`"${n}" could not be read: it is not there, or not in the project`);if(o.size>20971520)throw Error(`"${n}" is ${Math.round(o.size/1024/1024)} MB, more than a poster reads (${e/1024/1024} MB)`);return{type:i,bytes:new Uint8Array(await o.arrayBuffer())}}function O(e){if(_.current===null||e.source!==_.current.contentWindow||e.origin!==i)return;let t=e.data;if(typeof t==`object`&&t){if(t.type===o.READY)te.current=!0,d();else if(t.type===o.DIRTY)T.current=t.dirty===!0,k.current?.(T.current),D.current();else if(t.type===o.SAVE&&typeof t.html==`string`&&typeof t.css==`string`)f(t.id,t.html,t.css);else if(t.type===o.DELIVER&&typeof t.name==`string`&&typeof t.mediaType==`string`&&t.bytes instanceof Uint8Array)QH(t.name,t.bytes,t.mediaType),s(t.id,`Downloaded "${t.name}".`);else if(t.type===o.DRAWIO_LIST)p(t.id,h);else if(t.type===o.DRAWIO_DRAW){let{path:e,page:n}=t;typeof e==`string`&&p(t.id,()=>g(e,typeof n==`string`?n:void 0))}else if(t.type===o.DRAWIO_EDIT){let{path:e,page:n}=t;typeof e==`string`&&v(t.id,e,typeof n==`string`?n:void 0)}else if(t.type===o.PICTURE_LIST)p(t.id,x);else if(t.type===o.PICTURE_READ){let{path:e}=t;typeof e==`string`&&p(t.id,()=>S(e))}}}return window.addEventListener(`message`,O),()=>{r=!1,te.current=!1,re(null),D.current=()=>{},k.current?.(!1),window.removeEventListener(`message`,O)}},[b,m,l]),(0,v.useEffect)(()=>D.current(),[a,s]),(0,v.useEffect)(()=>{te.current&&_.current?.contentWindow?.postMessage({type:o.THEME,theme:g?`dark`:`light`},new URL(b).origin)},[g,b]);async function se(){let e=j.current;if(e===null||ie.current&&!window.confirm(ZH))return;re(null);let t;try{t={ok:!0,value:(await m.read(e.file)).content!==e.before}}catch(e){t={ok:!1,message:`the diagram could not be read again: ${e instanceof Error?e.message:String(e)}`}}ae.current(e.id,t)}let le=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(A===null)return;le.current?.focus();function e(e){e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),e.stopImmediatePropagation(),ue.current())}return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[A]);let ue=(0,v.useRef)(se);ue.current=se;let de=(0,v.useCallback)(()=>void ue.current(),[]),fe=(0,v.useCallback)(e=>{ie.current=e},[]);return`problem`in S?(0,N.jsxs)(`div`,{"data-testid":`poster-unreadable`,children:[(0,N.jsxs)(`p`,{className:`border-b border-amber-300 bg-amber-50 px-3 py-1.5 text-xs text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200`,children:[`This poster cannot be opened in the editor: `,S.problem,`.`]}),d]}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`iframe`,{ref:_,title:i,"data-testid":`poster-frame`,"data-read-only":O?`true`:`false`,sandbox:XH,src:b,className:`block h-full w-full border-0`}),(0,N.jsx)(JH,{ref:y,serverUrl:p}),A!==null&&De(_.current)!==void 0&&(0,Ee.createPortal)((0,N.jsx)(`div`,{ref:le,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":`Touch up ${A.file}`,"data-testid":`poster-diagram-touch-up`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4 outline-none`,children:(0,N.jsxs)(`div`,{className:`flex h-full max-h-[56rem] w-full max-w-[90rem] flex-col overflow-hidden rounded-lg border border-zinc-300 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,N.jsxs)(`header`,{className:`flex shrink-0 items-center gap-2 border-b border-zinc-200 px-3 py-2 text-sm dark:border-zinc-800`,children:[(0,N.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,title:A.file,children:[A.file,A.page===void 0?``:` — ${A.page}`]}),h&&(0,N.jsx)(`button`,{type:`button`,className:`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200 disabled:opacity-50`,onClick:()=>h(A.file),title:`Open the diagram in draw.io desktop, for anything more than a touch-up; its saves come back here`,children:`↗ draw.io desktop`}),(0,N.jsx)(`button`,{type:`button`,className:`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200 disabled:opacity-50`,onClick:()=>void se(),title:`Back to the poster, which takes the diagram as saved (Escape)`,children:`back to the poster`})]}),(0,N.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,N.jsx)(Uz,{path:A.file,variant:`viewer`,page:A.page,startTouchUp:!0,onTouchUpDirtyChange:fe,onEscape:de})})]})}),De(_.current))]})}var eU=`pi-outpost:open`,tU=4,nU={css:`text/css`,js:`text/javascript`,mjs:`text/javascript`,png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,avif:`image/avif`,svg:`image/svg+xml`,ico:`image/x-icon`,bmp:`image/bmp`,woff:`font/woff`,woff2:`font/woff2`,ttf:`font/ttf`,otf:`font/otf`,mp4:`video/mp4`,webm:`video/webm`,mp3:`audio/mpeg`,wav:`audio/wav`,ogg:`audio/ogg`},rU=`(function () {
|
|
840
840
|
document.addEventListener("click", function (event) {
|
|
841
841
|
var link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
|
|
842
842
|
if (!link || event.defaultPrevented) return;
|
|
@@ -863,7 +863,7 @@ l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
863
863
|
event.preventDefault();
|
|
864
864
|
parent.postMessage({ type: "${eU}", href: href }, "*");
|
|
865
865
|
}, true);
|
|
866
|
-
})();`;function iU(e){if(e==null)return!1;let t=e.trim();return t!==``&&!t.startsWith(`#`)&&!ae(t)}function aU(e,t){return nU[e.split(`.`).pop()?.toLowerCase()??``]??t}function oU(e,t){return new Promise((n,r)=>{let i=new FileReader;i.onload=()=>n(String(i.result).replace(/^data:[^;,]*/,`data:${t}`)),i.onerror=()=>r(i.error),i.readAsDataURL(e)})}async function sU(e,t,n){let r=new DOMParser().parseFromString(e,`text/html`),i=new Map,a=e=>{let t=i.get(e);return t===void 0&&(t=n(e).catch(()=>void 0),i.set(e,t)),t},o=async e=>(await a(e))?.text(),s=async e=>{let t=await a(e);return t===void 0?void 0:oU(t,aU(e,t.type||`application/octet-stream`))},c=async(e,t,n=0)=>{let r=[...e.matchAll(/@import\s+(?:url\(\s*(['"]?)([^'")]+)\1\s*\)|(['"])([^'"]+)\3)[^;]*;/gi)];for(let i of r){let r=i[2]??i[4];if(!iU(r)||n>=tU)continue;let a=oe(t,r),s=await o(a);s!==void 0&&(e=e.replace(i[0],await c(s,a,n+1)))}let i=/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi,a=new Map;for(let n of new Set([...e.matchAll(i)].map(e=>e[2]))){if(!iU(n))continue;let e=await s(oe(t,n));e!==void 0&&a.set(n,e)}return e.replace(i,(e,t,n)=>a.has(n)?`url("${a.get(n)}")`:e)},l=Array.from(r.querySelectorAll(`style`));for(let e of Array.from(r.querySelectorAll(`link[href]`))){let n=(e.getAttribute(`rel`)??``).toLowerCase().split(/\s+/),i=e.getAttribute(`href`);if(!iU(i))continue;let a=oe(t,i);if(n.includes(`stylesheet`)){let t=await o(a);if(t===void 0)continue;let n=r.createElement(`style`),i=e.getAttribute(`media`);i!==null&&n.setAttribute(`media`,i),n.textContent=await c(t,a),e.replaceWith(n)}else if(n.includes(`icon`)){let t=await s(a);t!==void 0&&e.setAttribute(`href`,t)}}for(let e of l)e.textContent=await c(e.textContent??``,t);for(let e of Array.from(r.querySelectorAll(`[style]`)))e.setAttribute(`style`,await c(e.getAttribute(`style`)??``,t));for(let e of Array.from(r.querySelectorAll(`script[src]`))){let n=e.getAttribute(`src`);if(!iU(n))continue;let r=await o(oe(t,n));r!==void 0&&(e.removeAttribute(`src`),e.textContent=r.replace(/<\/script/gi,`<\\/script`))}for(let[e,n]of[[`img`,`src`],[`source`,`src`],[`video`,`src`],[`video`,`poster`],[`audio`,`src`],[`track`,`src`],[`input`,`src`],[`image`,`href`],[`image`,`xlink:href`],[`use`,`href`]])for(let i of Array.from(r.getElementsByTagName(e))){let e=i.getAttribute(n);if(!iU(e))continue;let r=await s(oe(t,e));r!==void 0&&i.setAttribute(n,r)}for(let e of Array.from(r.querySelectorAll(`img[srcset], source[srcset]`))){let n=(e.getAttribute(`srcset`)??``).split(`,`).map(e=>e.trim()).filter(Boolean),r=[];for(let e of n){let[n,...i]=e.split(/\s+/),a=iU(n)?await s(oe(t,n)):void 0;r.push([a??n,...i].join(` `))}e.setAttribute(`srcset`,r.join(`, `))}let u=r.createElement(`script`);return u.textContent=rU,r.head.prepend(u),`<!doctype html>\n${r.documentElement.outerHTML}`}var cU=`allow-scripts allow-popups allow-popups-to-escape-sandbox`;function lU({source:e,path:t,load:n,onOpen:r}){let i=(0,v.useRef)(null),[a,o]=(0,v.useState)(null);return(0,v.useEffect)(()=>{let r=!0;return sU(e,t,n).then(e=>{r&&o(e)},()=>{r&&o(e)}),()=>{r=!1}},[e,t,n]),(0,v.useEffect)(()=>{function e(e){if(i.current===null||e.source!==i.current.contentWindow)return;let n=e.data;typeof n==`object`&&n&&n.type===`pi-outpost:open`&&typeof n.href==`string`&&r(oe(t,n.href))}return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[t,r]),a===null?(0,N.jsx)(`div`,{className:`p-4 text-sm text-zinc-500`,"data-testid":`html-page-loading`,children:`Loading…`}):(0,N.jsx)(`iframe`,{ref:i,title:t,"data-testid":`html-page`,sandbox:cU,srcDoc:a,className:`h-full min-h-[24rem] w-full border-0 bg-white`})}function uU({query:e,onQueryChange:t,matchCount:n,truncated:r=!1,currentIndex:i,searching:a=!1,onNext:o,onPrev:s,onClose:c,inputRef:l}){let u=(0,v.useRef)(null),d=l??u;(0,v.useEffect)(()=>{d.current?.focus(),d.current?.select()},[]);let f=n===0?a?`searching…`:`0/0`:`${i+1}/${n}${r?`+`:``}`;return(0,N.jsxs)(`div`,{role:`search`,"aria-label":`Find in file`,className:`flex items-center gap-2 border-b border-zinc-200 bg-zinc-50 px-3 py-1.5 text-xs dark:border-zinc-800 dark:bg-zinc-900`,children:[(0,N.jsx)(`input`,{ref:d,type:`text`,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.shiftKey?s():o()):e.key===`Escape`&&(e.stopPropagation(),c())},placeholder:`Find in file`,"aria-label":`Find`,className:`min-w-0 flex-1 rounded border border-zinc-300 bg-white px-2 py-1 text-xs text-zinc-700 outline-none focus-visible:ring-1 focus-visible:ring-zinc-400 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-200`}),(0,N.jsx)(`span`,{className:`shrink-0 tabular-nums text-zinc-500 dark:text-zinc-400`,children:f}),(0,N.jsx)(`button`,{type:`button`,onClick:s,disabled:n===0,"aria-label":`Previous match`,title:`Previous match (Shift+Enter)`,className:`shrink-0 rounded px-1.5 py-0.5 text-zinc-500 hover:bg-zinc-200 disabled:opacity-40 dark:text-zinc-400 dark:hover:bg-zinc-800`,children:`‹`}),(0,N.jsx)(`button`,{type:`button`,onClick:o,disabled:n===0,"aria-label":`Next match`,title:`Next match (Enter)`,className:`shrink-0 rounded px-1.5 py-0.5 text-zinc-500 hover:bg-zinc-200 disabled:opacity-40 dark:text-zinc-400 dark:hover:bg-zinc-800`,children:`›`}),(0,N.jsx)(`button`,{type:`button`,onClick:c,"aria-label":`Close find bar`,title:`Close (Esc)`,className:`shrink-0 rounded px-1.5 py-0.5 text-zinc-500 hover:bg-zinc-200 dark:text-zinc-400 dark:hover:bg-zinc-800`,children:`✕`})]})}var dU=3e3;function fU(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function pU(e,t,n=1/0){if(t===``)return[];let r=new RegExp(fU(t),`gi`),i=[],a;for(;(a=r.exec(e))!==null&&(i.push({start:a.index,end:a.index+a[0].length}),!(i.length>=n)););return i}function mU(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=[],r=``;for(let e=t.nextNode();e!==null;e=t.nextNode()){let t=e.data.length;t!==0&&(n.push({node:e,start:r.length,end:r.length+t}),r+=e.data)}return{nodes:n,text:r}}function hU(e,t,n=dU){let r={matches:[],truncated:!1,clear:()=>{}};if(t===``)return r;let{nodes:i,text:a}=mU(e);if(a===``)return r;let o=pU(a,t,n+1),s=o.length>n,c=s?o.slice(0,n):o;if(c.length===0)return{matches:[],truncated:s,clear:()=>{}};let l=Array(c.length);for(let e=c.length-1;e>=0;e--){let{start:t,end:n}=c[e],r=[];for(let e of i){if(e.end<=t||e.start>=n)continue;let i=Math.max(0,t-e.start),a=Math.min(e.node.data.length,n-e.start);if(i>=a)continue;let o=e.node;a<o.data.length&&o.splitText(a);let s=i>0?o.splitText(i):o,c=document.createElement(`mark`);c.className=`find-match`,s.replaceWith(c),c.appendChild(s),r.push(c)}l[e]={marks:r}}return{matches:l,truncated:s,clear:()=>{for(let{marks:e}of l)for(let t of e)t.replaceWith(document.createTextNode(t.textContent??``));e.normalize()}}}var gU=(0,v.lazy)(()=>ye(()=>import(`./PdfViewer-DpNH6Pd3.js`),[])),_U=250,vU=`(min-width: 768px)`;function yU(){let[e,t]=(0,v.useState)(()=>window.matchMedia?.(vU).matches??!0);return(0,v.useEffect)(()=>{let e=window.matchMedia?.(vU);if(e===void 0)return;let n=()=>t(e.matches);return n(),e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[]),e}function bU(e,t){let[n,r]=(0,v.useState)(e);return(0,v.useEffect)(()=>{let n=window.setTimeout(()=>r(e),t);return()=>window.clearTimeout(n)},[e,t]),n}function xU(e){let t=Su(e);return t.status===`valid`?t.envelope:void 0}var SU=`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`;function CU(e){return/\.(md|markdown)$/i.test(e)}var wU=ce;function TU(e){return/\.html?$/i.test(e)}function EU(e){return/\.poster\.html$/i.test(e)}function DU(e,t){return t===void 0?!0:t===null?!1:t===``||e===t||e.startsWith(`${t}/`)}function OU({file:e,writableRoot:t,isStreaming:n,onDirtyChange:r,gitState:i,initialShowGitDiff:a=!1,gitDiff:o,gitBaseline:s=null,onFetchGitDiff:c,onClearGitDiff:l,inRepository:u,onOpenGitHistory:d,onClose:f,onReload:p,onSave:m,serverUrl:h=``,token:g=null,workspace:_,docxTemplate:y,onImageLoad:b,onPdfLoad:x,rawRevision:S=0,onOpenNative:C}){let[w,T]=(0,v.useState)(`rendered`),[E,D]=(0,v.useState)(null),[O,te]=(0,v.useState)(a),[k,ne]=(0,v.useState)(e.status===`loaded`&&e.justCreated?{draft:e.content,baseContent:e.content,baseMtimeMs:e.mtimeMs}:null),[A,j]=(0,v.useState)(`idle`),ie=(0,v.useRef)(null),[ae,ce]=(0,v.useState)(0),ue=(0,v.useCallback)(()=>ce(e=>e+1),[]),fe=(0,v.useRef)(null),M=e.status===`loaded`?e:null,pe=M!==null&&CU(e.path),he=M!==null&&EU(e.path),ge=M!==null&&TU(e.path)&&!he,P=M!==null&&wU(e.path),_e=se(e.path),ve=le(e.path),ye=(0,v.useMemo)(()=>M===null?void 0:Su(M.content),[M?.content]),be=ye?.status===`valid`,xe=ye?.status===`valid`||ye?.status===`invalid`,Se=xe||pe||ge||P,Ce=w===`source`,we=yU(),Ee=DU(e.path,t)&&!ve,De=M!==null&&!_e&&!ve;(0,v.useEffect)(()=>{De&&WH().catch(()=>{})},[De]);let Oe=k!==null&&k.draft!==k.baseContent,[ke,Ae]=(0,v.useState)(!1),je=Oe||ke,Me=M?.pendingSave!==void 0,Ne=k!==null&&M!==null&&M.mtimeMs!==k.baseMtimeMs,Pe=M?.saveError?.conflict===!0||Ne,Fe=k?.draft??M?.content??``,Ie=bU(Fe,_U),Le=(0,v.useMemo)(()=>M===null?void 0:Su(Ie),[Ie,M===null]),[Re,ze]=(0,v.useState)(()=>e.status===`loaded`?xU(e.content):void 0);(0,v.useEffect)(()=>{Le?.status===`valid`&&ze(Le.envelope)},[Le]);let Be=Le!==void 0&&Le.status!==`valid`&&Re!==void 0,Ve=Le?.status===`invalid`?Ie===M?.content&&M.documentIssues!==void 0?M.documentIssues:Le.issues:void 0,He=Le?.status===`not-a-document`?Le.why===`unparseable`?`This is not parseable JSON yet.`:"This no longer declares a structured-exchange `schema`.":Le?.status===`unsupported-version`?`This declares ${Le.schema}, which this version does not render.`:void 0,Ue=w===`split`&&Se&&!O&&M!==null&&we,We=O?void 0:Ue?xe?Re:void 0:k===null&&!Ce&&ye?.status===`valid`?ye.envelope:void 0,Ge=(0,v.useRef)(null),Ke=k!==null,qe=M!==null&&k===null&&!Ue&&!O&&(!pe||Ce)&&(!be||Ce)&&(!ge||Ce)&&(!P||Ce)&&(!he||Ce),Ye=O||Ue?`none`:ve?`pdf`:k!==null||qe?`text`:M!==null&&!_e?`dom`:`none`,[Xe,Qe]=(0,v.useState)(!1),[$e,et]=(0,v.useState)(``),[tt,nt]=(0,v.useState)(0),rt=(0,v.useRef)(null),it=(0,v.useRef)(null),at=(0,v.useRef)(null),[ot,st]=(0,v.useState)({matchCount:0,currentIndex:-1,searching:!1}),[ct,lt]=(0,v.useState)([]),[ut,dt]=(0,v.useState)(!1),ft=(0,v.useRef)(null),pt=(0,v.useRef)([]),mt=(0,v.useRef)(0),ht=(0,v.useRef)(``);function gt(e){mt.current=e;for(let[t,n]of pt.current.entries())for(let r of n.marks)r.isConnected&&r.classList.toggle(`find-match-current`,t===e);let t=pt.current[e]?.marks;t?.[0]?.isConnected&&t[0].scrollIntoView({block:`center`})}let _t=Xe?$e:``,vt=(0,v.useMemo)(()=>Ye===`text`?pU(Fe,_t):[],[Ye,Fe,_t]);(0,v.useEffect)(()=>{Xe&&Ye===`none`&&Qe(!1)},[Xe,Ye]),(0,v.useEffect)(()=>{function e(){ft.current?.clear(),ft.current=null,pt.current=[],lt([]),dt(!1)}let t=it.current;if(Ye!==`dom`||_t===``||t===null){e();return}ft.current?.clear();let n=hU(t,_t);ft.current=n,pt.current=n.matches,lt(n.matches),dt(n.truncated);let r=_t!==ht.current;ht.current=_t;let i=r?0:Math.min(mt.current,Math.max(n.matches.length-1,0));return nt(i),gt(i),e},[Ye,_t,w,Ce]);function yt(e,t){let n=e[t];n!==void 0&&ie.current?.select(n.start,n.end)}(0,v.useEffect)(()=>{if(Ye!==`text`||!Xe)return;let e=pU(Fe,_t),t=_t!==ht.current;ht.current=_t;let n=t?0:Math.min(tt,Math.max(e.length-1,0));nt(n),e.length>0&&yt(e,n)},[_t,Ye,Xe,Ke,ae]),(0,v.useEffect)(()=>{ie.current?.markMatches(Ye===`text`?vt:[],tt)},[Ye,vt,tt,Ke,ae]);let bt=M?.reveal,[xt,St]=(0,v.useState)(void 0);(0,v.useEffect)(()=>{if(bt!==void 0&&M!==null){if(bt.page!==void 0)St({page:bt.page});else if(bt.line!==void 0){k===null&&T(`source`);let e=pU(Fe,bt.query),t=kU(Fe,bt.line),n=e.findIndex(e=>e.start>=t);ht.current=bt.query,nt(n===-1?0:n)}et(bt.query),Qe(!0)}},[bt]);function Ct(){Qe(!0)}function wt(){Qe(!1)}function Tt(){if(Ye===`pdf`)at.current?.findNext();else if(Ye===`text`){if(vt.length===0)return;let e=(tt+1)%vt.length;nt(e),yt(vt,e)}else{let e=pt.current.length;if(e===0)return;let t=(mt.current+1)%e;nt(t),gt(t)}}function Et(){if(Ye===`pdf`)at.current?.findPrevious();else if(Ye===`text`){if(vt.length===0)return;let e=(tt-1+vt.length)%vt.length;nt(e),yt(vt,e)}else{let e=pt.current.length;if(e===0)return;let t=(mt.current-1+e)%e;nt(t),gt(t)}}let Dt=Ye===`pdf`?{matchCount:ot.matchCount,currentIndex:ot.currentIndex,truncated:!1,searching:ot.searching}:Ye===`text`?{matchCount:vt.length,currentIndex:vt.length>0?Math.min(tt,vt.length-1):-1,truncated:!1,searching:!1}:{matchCount:ct.length,currentIndex:ct.length>0?Math.min(tt,ct.length-1):-1,truncated:ut,searching:!1},Ot=k===null?null:(0,N.jsx)(v.Suspense,{fallback:(0,N.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading editor…`}),children:(0,N.jsx)(GH,{handle:ie,onReady:ue,path:e.path,value:k.draft,baseline:s,onChange:e=>ne(t=>t===null?t:{...t,draft:e}),onSave:()=>{Oe&&!Me&&!Pe&&It()}})},`editor`);function kt(t){return M===null?null:(0,N.jsx)(v.Suspense,{fallback:(0,N.jsx)(`div`,{className:`p-4`,children:(0,N.jsx)(Te,{code:M.content,path:e.path})}),children:(0,N.jsx)(GH,{readOnly:!0,handle:t?ie:void 0,onReady:t?ue:void 0,path:e.path,value:M.content,baseline:s})},`source`)}let At=(0,v.useCallback)(e=>fetch(de(h,e,g,void 0,_)).then(e=>e.ok?e.blob():void 0,()=>void 0),[h,g,_]);function jt(t){return(0,N.jsx)(`div`,{className:`prose-chat mx-auto max-w-3xl p-4 text-zinc-700 dark:text-zinc-300`,children:(0,N.jsx)(SC,{remarkPlugins:[dz,Cz],rehypePlugins:[WA],components:{pre:Je,a:({href:t,children:n,...r})=>!t||/^[a-z][a-z0-9+.-]*:/i.test(t)?(0,N.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,...r,children:n}):t.startsWith(`#`)?(0,N.jsx)(`a`,{href:t,...r,children:n}):(0,N.jsx)(`a`,{href:t,onClick:n=>{n.preventDefault(),p(oe(e.path,t))},...r,children:n}),img:({src:t,alt:n,...r})=>{let i=typeof t==`string`&&t!==``&&!/^[a-z][a-z0-9+.-]*:/i.test(t)&&!t.startsWith(`//`)?de(h,oe(e.path,t),g,void 0,_):t;return(0,N.jsx)(`img`,{...r,src:i,alt:n??``,loading:`lazy`,className:`max-w-full rounded-lg`})}},children:re(t)})})}function Mt(e){(w!==`split`||e===`split`||!Oe||window.confirm(`Discard unsaved changes?`))&&(e===w||!ke||window.confirm(`Discard unsaved changes?`))&&(w===`split`&&e!==`split`&&ne(null),D(null),T(e))}function Nt(){(!je||window.confirm(`Discard unsaved changes?`))&&f()}function Pt(){M&&(!ke||window.confirm(`Discard unsaved changes?`))&&(Se&&w===`rendered`?(D(`rendered`),T(we?`split`:`source`)):he&&w===`rendered`&&(D(`rendered`),T(`source`)),ne({draft:M.content,baseContent:M.content,baseMtimeMs:M.mtimeMs}))}function Ft(){E===null?ne(Ue&&M!==null?{draft:M.content,baseContent:M.content,baseMtimeMs:M.mtimeMs}:null):(ne(null),T(E),D(null))}function It(t=!1){M&&k!==null&&!Me&&(fe.current=k.draft,m(e.path,k.draft,k.baseMtimeMs,t))}function Lt(){ne(null),p(e.path)}function Rt(){let t=!O;te(t),t?c(e.path):l()}return(0,v.useEffect)(()=>{k!==null&&M!==null&&fe.current!==null&&M.content===fe.current&&M.mtimeMs!==k.baseMtimeMs&&(fe.current=null,ne({...k,baseContent:M.content,baseMtimeMs:M.mtimeMs}))},[M?.mtimeMs]),(0,v.useEffect)(()=>{function e(e){if(e.key===`Escape`)Xe?wt():Nt();else if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`f`){if(Ye===`none`)return;e.preventDefault(),Ct()}}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),(0,v.useEffect)(()=>{Ue&&Ee&&k===null&&M!==null&&ne({draft:M.content,baseContent:M.content,baseMtimeMs:M.mtimeMs})},[Ue,Ee,M?.mtimeMs]),(0,v.useEffect)(()=>{j(n?`streaming`:e=>e===`streaming`?`done`:e)},[n]),(0,v.useEffect)(()=>(r(je),()=>r(!1)),[je]),(0,v.useEffect)(()=>(a&&c(e.path),()=>l()),[]),(0,N.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(Se||he)&&!O&&(0,N.jsx)(`div`,{className:`flex shrink-0 items-center gap-0.5`,role:`group`,"aria-label":`How to show this document`,children:[[`rendered`,`⚏ rendered`,`Show the rendering`],[`split`,`⇹ split`,`Edit the file beside its rendering`],[`source`,`⌗ source`,`Show the file as written`]].filter(([e])=>!(he&&e===`split`)).map(([e,t,n])=>(0,N.jsx)(`button`,{type:`button`,onClick:()=>Mt(e),"aria-pressed":w===e,title:n,className:`rounded px-1.5 py-0.5 text-xs ${w===e?`bg-zinc-100 text-zinc-700 dark:bg-zinc-800 dark:text-zinc-200`:`text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`}`,children:t},e))}),i!==void 0&&k===null&&(0,N.jsx)(`button`,{type:`button`,onClick:Rt,"aria-pressed":O,title:O?`Show file content`:`Show uncommitted changes (vs HEAD)`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs ${O?`bg-amber-100 text-amber-800 dark:bg-amber-950/60 dark:text-amber-300`:`text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`}`,children:`± diff`}),u&&k===null&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>d(e.path),title:`Show this file's history`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`,children:`⎇ history`}),(0,N.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-zinc-500 dark:text-zinc-400`,title:e.path,children:[e.path,je&&(0,N.jsx)(`span`,{className:`ml-1 text-amber-500`,children:`●`})]}),P&&C&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>C(e.path),title:`Open with the application associated with .drawio files — draw.io desktop, where it is installed`,className:`shrink-0 rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-600 hover:border-zinc-400 hover:text-zinc-900 dark:border-zinc-700 dark:text-zinc-300 dark:hover:border-zinc-500 dark:hover:text-zinc-100`,children:`↗ open in draw.io`}),M&&!_e&&!ve&&!P&&!he&&!O&&!xe&&(0,N.jsx)(KH,{text:Fe,path:e.path,serverUrl:h,token:g,workspace:_,template:y}),We?.kind===`table`&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(KH,{text:()=>Ge.current?.markdown?.()??``,path:`${e.path.replace(/\.[^./]*$/,``)}.md`,serverUrl:h,token:g,workspace:_,template:y}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>Ge.current?.xlsx?.(),title:`Download as an Excel workbook`,"aria-label":`Download as an Excel workbook`,className:SU,children:`⤓ excel`})]}),(We?.kind===`graph`||We?.kind===`sequence`||We?.kind===`timeline`)&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>Ge.current?.svg?.(),title:`Download the figure as SVG`,"aria-label":`Download the figure as SVG`,className:SU,children:`⤓ svg`}),M&&k===null&&(0,N.jsx)(me,{text:M.content}),M&&k===null&&!O&&Ee&&(0,N.jsx)(`button`,{type:`button`,onClick:Pt,className:`shrink-0 rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-700 dark:text-zinc-400 dark:hover:border-zinc-500 dark:hover:text-zinc-200`,children:`✎ edit`}),M&&k===null&&!Ee&&(0,N.jsx)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,title:`Outside the writable zone`,children:`🔒 read-only`}),k!==null&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>It(),disabled:!Oe||Me||Pe,className:`shrink-0 rounded border border-emerald-300 px-2 py-0.5 text-xs text-emerald-700 hover:border-emerald-500 disabled:opacity-50 dark:border-emerald-900 dark:text-emerald-400 dark:hover:border-emerald-600`,children:Me?`saving…`:`save`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>{(!Oe||window.confirm(`Discard unsaved changes?`))&&Ft()},className:`shrink-0 rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-500 hover:border-zinc-400 dark:border-zinc-700 dark:text-zinc-400 dark:hover:border-zinc-500`,children:Oe?`cancel`:`done`})]}),(0,N.jsx)(`button`,{type:`button`,onClick:Nt,title:`Close (Esc)`,"aria-label":`Close file viewer`,className:`shrink-0 px-1 text-sm text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-300`,children:`✕`})]}),Xe&&Ye!==`none`&&(0,N.jsx)(uU,{inputRef:rt,query:$e,onQueryChange:et,matchCount:Dt.matchCount,currentIndex:Dt.currentIndex,truncated:Dt.truncated,searching:Dt.searching,onNext:Tt,onPrev:Et,onClose:wt}),Pe&&k!==null&&(0,N.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:[(0,N.jsx)(`span`,{className:`min-w-0 flex-1`,children:`File changed on disk since you started editing.`}),(0,N.jsx)(`button`,{type:`button`,onClick:Lt,className:`shrink-0 rounded border border-amber-400 px-2 py-0.5 text-xs hover:bg-amber-100 dark:border-amber-800 dark:hover:bg-amber-950/60`,children:`reload (discard my edits)`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>It(!0),disabled:Me,className:`shrink-0 rounded border border-amber-400 px-2 py-0.5 text-xs hover:bg-amber-100 disabled:opacity-50 dark:border-amber-800 dark:hover:bg-amber-950/60`,children:`overwrite with my version`})]}),k!==null&&M?.saveError&&!M.saveError.conflict&&(0,N.jsx)(`div`,{className:`border-b border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:M.saveError.message}),(0,N.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[O&&k===null&&(0,N.jsxs)(`div`,{className:`p-4`,children:[o?.path===e.path&&`error`in o&&(0,N.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:o.error}),o?.path===e.path&&`before`in o&&(0,N.jsx)(Ze,{fill:!0,lines:ee(o.before,o.after)}),o?.path!==e.path&&(0,N.jsx)(`div`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`loading diff…`})]}),ve&&k===null&&!O&&(0,N.jsx)(Og,{label:`This PDF`,children:(0,N.jsx)(v.Suspense,{fallback:(0,N.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),children:(0,N.jsx)(gU,{ref:at,path:e.path,serverUrl:h,token:g,workspace:_,revision:S,findQuery:Ye===`pdf`?_t:``,onFindStateChange:st,...xt?{startAt:xt}:{},...x?{onLoaded:x}:{}})})}),_e&&k===null&&!O&&(0,N.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,N.jsx)(`img`,{src:de(h,e.path,g,S,_),alt:e.path,onLoad:()=>b?.(e.path),className:`max-h-full max-w-full rounded object-contain`})}),e.status===`loading`&&k===null&&!O&&!_e&&!ve&&(0,N.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),e.status===`error`&&!_e&&!ve&&(0,N.jsx)(`div`,{className:`p-4 text-sm text-red-600 dark:text-red-400`,children:e.message}),k!==null&&!Ue&&Ot,M&&k===null&&!Ue&&!O&&pe&&!Ce&&(0,N.jsx)(`div`,{ref:it,children:jt(M.content)}),M&&k===null&&!Ue&&!O&&P&&!Ce&&(0,N.jsx)(`div`,{className:`h-full`,"data-testid":`file-drawio`,children:(0,N.jsx)(Uz,{path:e.path,xml:M.content,variant:`viewer`,fallback:kt(!1),onTouchUpDirtyChange:Ae})}),M&&k===null&&!Ue&&!O&&he&&!Ce&&(0,N.jsx)(`div`,{className:`h-full`,"data-testid":`file-poster`,children:(0,N.jsx)($H,{path:e.path,content:M.content,mtimeMs:M.mtimeMs,writable:Ee,loadFile:At,fallback:kt(!1),onTouchUpDirtyChange:Ae})}),M&&k===null&&!Ue&&!O&&ge&&!Ce&&(0,N.jsx)(`div`,{className:`h-full`,"data-testid":`file-html`,children:(0,N.jsx)(lU,{source:M.content,path:e.path,load:At,onOpen:p})}),Ue&&(0,N.jsxs)(`div`,{className:`flex h-full min-h-0`,"data-testid":`file-split`,children:[(0,N.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto border-r border-zinc-200 dark:border-zinc-800`,children:Ot??kt(!1)}),(0,N.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto`,"data-testid":`file-split-rendering`,children:pe&&!xe?(0,N.jsx)(`div`,{className:`prose-chat p-4 text-zinc-700 dark:text-zinc-300`,children:jt(Ie)}):P&&!xe?(0,N.jsx)(Km,{xml:Ie,serverUrl:h,title:e.path}):ge&&!xe?(0,N.jsx)(lU,{source:Ie,path:e.path,load:At,onOpen:p}):(0,N.jsxs)(N.Fragment,{children:[Be&&(0,N.jsx)(`p`,{"data-testid":`file-split-stale`,className:`flex flex-wrap items-center gap-2 border-b border-amber-300 bg-amber-50 px-3 py-1.5 text-xs text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200`,children:(0,N.jsxs)(`span`,{children:[`Showing the document as it last stood.`,` `,He??`The text beside it does not satisfy the schema it declares.`]})}),Ve!==void 0&&(0,N.jsxs)(`ul`,{"data-testid":`file-split-issues`,className:`space-y-0.5 border-b border-zinc-200 px-3 py-1.5 text-xs text-zinc-500 dark:border-zinc-800 dark:text-zinc-400`,children:[Ve.slice(0,6).map((e,t)=>(0,N.jsxs)(`li`,{children:[(0,N.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),Ve.length>6&&(0,N.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,Ve.length-6,` more`]})]}),Re===void 0?(0,N.jsxs)(`p`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,"data-testid":`file-split-nothing`,children:[`Nothing to draw yet. `,He??`This document does not satisfy the schema it declares.`]}):(0,N.jsx)(Og,{label:`This diagram`,children:(0,N.jsx)(`div`,{className:`p-4`,"data-testid":`file-structured-exchange`,children:(0,N.jsx)(Tg,{envelope:Re,source:Fe,exportRef:Ge,file:{path:e.path,writable:Ee}})})})]})})]}),M&&k===null&&!Ue&&!O&&be&&!Ce&&ye?.status===`valid`&&(0,N.jsx)(Og,{label:`This diagram`,children:(0,N.jsx)(`div`,{className:`mx-auto max-w-5xl p-4`,"data-testid":`file-structured-exchange`,children:(0,N.jsx)(Tg,{envelope:ye.envelope,source:M.content,exportRef:Ge,file:{path:e.path,writable:Ee}})})}),M&&k===null&&!Ue&&!O&&ye?.status===`invalid`&&(0,N.jsxs)(`div`,{"data-testid":`file-structured-exchange-invalid`,className:`mx-4 mt-4 rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-200`,children:[(0,N.jsx)(`p`,{className:`font-medium`,children:`This declares a structured-exchange document and does not satisfy the schema.`}),(0,N.jsxs)(`ul`,{className:`mt-1 space-y-0.5 text-xs`,children:[(M.documentIssues??ye.issues).slice(0,8).map((e,t)=>(0,N.jsxs)(`li`,{children:[(0,N.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),(M.documentIssues??ye.issues).length>8&&(0,N.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,(M.documentIssues??ye.issues).length-8,` more`]})]})]}),M&&k===null&&!Ue&&!O&&ye?.status===`unsupported-version`&&(0,N.jsxs)(`div`,{"data-testid":`file-structured-exchange-unsupported`,className:`mx-4 mt-4 rounded-lg border border-zinc-300 bg-zinc-50 px-3 py-2 text-sm text-zinc-600 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-400`,children:[`This document declares `,(0,N.jsx)(`span`,{className:`font-mono`,children:ye.schema}),`, which this version does not render. Shown as text.`]}),qe&&kt(!0)]}),A!==`idle`&&(0,N.jsxs)(`button`,{type:`button`,onClick:Nt,"aria-live":`polite`,className:`flex items-center gap-2 border-t border-zinc-200 px-3 py-2 text-left text-sm hover:bg-zinc-50 dark:border-zinc-800 dark:hover:bg-zinc-900`,children:[A===`streaming`?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 animate-pulse motion-reduce:animate-none rounded-full bg-amber-500`}),(0,N.jsx)(`span`,{className:`text-amber-700 dark:text-amber-400`,children:`π is replying…`})]}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 rounded-full bg-emerald-500`}),(0,N.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:`π replied`})]}),(0,N.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-500`,children:`show conversation →`})]})]})}function kU(e,t){let n=0;for(let r=1;r<t;r++){let t=e.indexOf(`
|
|
866
|
+
})();`;function iU(e){if(e==null)return!1;let t=e.trim();return t!==``&&!t.startsWith(`#`)&&!ae(t)}function aU(e,t){return nU[e.split(`.`).pop()?.toLowerCase()??``]??t}function oU(e,t){return new Promise((n,r)=>{let i=new FileReader;i.onload=()=>n(String(i.result).replace(/^data:[^;,]*/,`data:${t}`)),i.onerror=()=>r(i.error),i.readAsDataURL(e)})}async function sU(e,t,n){let r=new DOMParser().parseFromString(e,`text/html`),i=new Map,a=e=>{let t=i.get(e);return t===void 0&&(t=n(e).catch(()=>void 0),i.set(e,t)),t},o=async e=>(await a(e))?.text(),s=async e=>{let t=await a(e);return t===void 0?void 0:oU(t,aU(e,t.type||`application/octet-stream`))},c=async(e,t,n=0)=>{let r=[...e.matchAll(/@import\s+(?:url\(\s*(['"]?)([^'")]+)\1\s*\)|(['"])([^'"]+)\3)[^;]*;/gi)];for(let i of r){let r=i[2]??i[4];if(!iU(r)||n>=tU)continue;let a=oe(t,r),s=await o(a);s!==void 0&&(e=e.replace(i[0],await c(s,a,n+1)))}let i=/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi,a=new Map;for(let n of new Set([...e.matchAll(i)].map(e=>e[2]))){if(!iU(n))continue;let e=await s(oe(t,n));e!==void 0&&a.set(n,e)}return e.replace(i,(e,t,n)=>a.has(n)?`url("${a.get(n)}")`:e)},l=Array.from(r.querySelectorAll(`style`));for(let e of Array.from(r.querySelectorAll(`link[href]`))){let n=(e.getAttribute(`rel`)??``).toLowerCase().split(/\s+/),i=e.getAttribute(`href`);if(!iU(i))continue;let a=oe(t,i);if(n.includes(`stylesheet`)){let t=await o(a);if(t===void 0)continue;let n=r.createElement(`style`),i=e.getAttribute(`media`);i!==null&&n.setAttribute(`media`,i),n.textContent=await c(t,a),e.replaceWith(n)}else if(n.includes(`icon`)){let t=await s(a);t!==void 0&&e.setAttribute(`href`,t)}}for(let e of l)e.textContent=await c(e.textContent??``,t);for(let e of Array.from(r.querySelectorAll(`[style]`)))e.setAttribute(`style`,await c(e.getAttribute(`style`)??``,t));for(let e of Array.from(r.querySelectorAll(`script[src]`))){let n=e.getAttribute(`src`);if(!iU(n))continue;let r=await o(oe(t,n));r!==void 0&&(e.removeAttribute(`src`),e.textContent=r.replace(/<\/script/gi,`<\\/script`))}for(let[e,n]of[[`img`,`src`],[`source`,`src`],[`video`,`src`],[`video`,`poster`],[`audio`,`src`],[`track`,`src`],[`input`,`src`],[`image`,`href`],[`image`,`xlink:href`],[`use`,`href`]])for(let i of Array.from(r.getElementsByTagName(e))){let e=i.getAttribute(n);if(!iU(e))continue;let r=await s(oe(t,e));r!==void 0&&i.setAttribute(n,r)}for(let e of Array.from(r.querySelectorAll(`img[srcset], source[srcset]`))){let n=(e.getAttribute(`srcset`)??``).split(`,`).map(e=>e.trim()).filter(Boolean),r=[];for(let e of n){let[n,...i]=e.split(/\s+/),a=iU(n)?await s(oe(t,n)):void 0;r.push([a??n,...i].join(` `))}e.setAttribute(`srcset`,r.join(`, `))}let u=r.createElement(`script`);return u.textContent=rU,r.head.prepend(u),`<!doctype html>\n${r.documentElement.outerHTML}`}var cU=`allow-scripts allow-popups allow-popups-to-escape-sandbox`;function lU({source:e,path:t,load:n,onOpen:r}){let i=(0,v.useRef)(null),[a,o]=(0,v.useState)(null);return(0,v.useEffect)(()=>{let r=!0;return sU(e,t,n).then(e=>{r&&o(e)},()=>{r&&o(e)}),()=>{r=!1}},[e,t,n]),(0,v.useEffect)(()=>{function e(e){if(i.current===null||e.source!==i.current.contentWindow)return;let n=e.data;typeof n==`object`&&n&&n.type===`pi-outpost:open`&&typeof n.href==`string`&&r(oe(t,n.href))}return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[t,r]),a===null?(0,N.jsx)(`div`,{className:`p-4 text-sm text-zinc-500`,"data-testid":`html-page-loading`,children:`Loading…`}):(0,N.jsx)(`iframe`,{ref:i,title:t,"data-testid":`html-page`,sandbox:cU,srcDoc:a,className:`h-full min-h-[24rem] w-full border-0 bg-white`})}function uU({query:e,onQueryChange:t,matchCount:n,truncated:r=!1,currentIndex:i,searching:a=!1,onNext:o,onPrev:s,onClose:c,inputRef:l}){let u=(0,v.useRef)(null),d=l??u;(0,v.useEffect)(()=>{d.current?.focus(),d.current?.select()},[]);let f=n===0?a?`searching…`:`0/0`:`${i+1}/${n}${r?`+`:``}`;return(0,N.jsxs)(`div`,{role:`search`,"aria-label":`Find in file`,className:`flex items-center gap-2 border-b border-zinc-200 bg-zinc-50 px-3 py-1.5 text-xs dark:border-zinc-800 dark:bg-zinc-900`,children:[(0,N.jsx)(`input`,{ref:d,type:`text`,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.shiftKey?s():o()):e.key===`Escape`&&(e.stopPropagation(),c())},placeholder:`Find in file`,"aria-label":`Find`,className:`min-w-0 flex-1 rounded border border-zinc-300 bg-white px-2 py-1 text-xs text-zinc-700 outline-none focus-visible:ring-1 focus-visible:ring-zinc-400 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-200`}),(0,N.jsx)(`span`,{className:`shrink-0 tabular-nums text-zinc-500 dark:text-zinc-400`,children:f}),(0,N.jsx)(`button`,{type:`button`,onClick:s,disabled:n===0,"aria-label":`Previous match`,title:`Previous match (Shift+Enter)`,className:`shrink-0 rounded px-1.5 py-0.5 text-zinc-500 hover:bg-zinc-200 disabled:opacity-40 dark:text-zinc-400 dark:hover:bg-zinc-800`,children:`‹`}),(0,N.jsx)(`button`,{type:`button`,onClick:o,disabled:n===0,"aria-label":`Next match`,title:`Next match (Enter)`,className:`shrink-0 rounded px-1.5 py-0.5 text-zinc-500 hover:bg-zinc-200 disabled:opacity-40 dark:text-zinc-400 dark:hover:bg-zinc-800`,children:`›`}),(0,N.jsx)(`button`,{type:`button`,onClick:c,"aria-label":`Close find bar`,title:`Close (Esc)`,className:`shrink-0 rounded px-1.5 py-0.5 text-zinc-500 hover:bg-zinc-200 dark:text-zinc-400 dark:hover:bg-zinc-800`,children:`✕`})]})}var dU=3e3;function fU(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function pU(e,t,n=1/0){if(t===``)return[];let r=new RegExp(fU(t),`gi`),i=[],a;for(;(a=r.exec(e))!==null&&(i.push({start:a.index,end:a.index+a[0].length}),!(i.length>=n)););return i}function mU(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=[],r=``;for(let e=t.nextNode();e!==null;e=t.nextNode()){let t=e.data.length;t!==0&&(n.push({node:e,start:r.length,end:r.length+t}),r+=e.data)}return{nodes:n,text:r}}function hU(e,t,n=dU){let r={matches:[],truncated:!1,clear:()=>{}};if(t===``)return r;let{nodes:i,text:a}=mU(e);if(a===``)return r;let o=pU(a,t,n+1),s=o.length>n,c=s?o.slice(0,n):o;if(c.length===0)return{matches:[],truncated:s,clear:()=>{}};let l=Array(c.length);for(let e=c.length-1;e>=0;e--){let{start:t,end:n}=c[e],r=[];for(let e of i){if(e.end<=t||e.start>=n)continue;let i=Math.max(0,t-e.start),a=Math.min(e.node.data.length,n-e.start);if(i>=a)continue;let o=e.node;a<o.data.length&&o.splitText(a);let s=i>0?o.splitText(i):o,c=document.createElement(`mark`);c.className=`find-match`,s.replaceWith(c),c.appendChild(s),r.push(c)}l[e]={marks:r}}return{matches:l,truncated:s,clear:()=>{for(let{marks:e}of l)for(let t of e)t.replaceWith(document.createTextNode(t.textContent??``));e.normalize()}}}var gU=(0,v.lazy)(()=>ye(()=>import(`./PdfViewer-DvbXSY9-.js`),[])),_U=250,vU=`(min-width: 768px)`;function yU(){let[e,t]=(0,v.useState)(()=>window.matchMedia?.(vU).matches??!0);return(0,v.useEffect)(()=>{let e=window.matchMedia?.(vU);if(e===void 0)return;let n=()=>t(e.matches);return n(),e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[]),e}function bU(e,t){let[n,r]=(0,v.useState)(e);return(0,v.useEffect)(()=>{let n=window.setTimeout(()=>r(e),t);return()=>window.clearTimeout(n)},[e,t]),n}function xU(e){let t=Su(e);return t.status===`valid`?t.envelope:void 0}var SU=`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`;function CU(e){return/\.(md|markdown)$/i.test(e)}var wU=ce;function TU(e){return/\.html?$/i.test(e)}function EU(e){return/\.poster\.html$/i.test(e)}function DU(e,t){return t===void 0?!0:t===null?!1:t===``||e===t||e.startsWith(`${t}/`)}function OU({file:e,writableRoot:t,isStreaming:n,onDirtyChange:r,gitState:i,initialShowGitDiff:a=!1,gitDiff:o,gitBaseline:s=null,onFetchGitDiff:c,onClearGitDiff:l,inRepository:u,onOpenGitHistory:d,onClose:f,onReload:p,onSave:m,serverUrl:h=``,token:g=null,workspace:_,docxTemplate:y,onImageLoad:b,onPdfLoad:x,rawRevision:S=0,onOpenNative:C}){let[w,T]=(0,v.useState)(`rendered`),[E,D]=(0,v.useState)(null),[O,te]=(0,v.useState)(a),[k,ne]=(0,v.useState)(e.status===`loaded`&&e.justCreated?{draft:e.content,baseContent:e.content,baseMtimeMs:e.mtimeMs}:null),[A,j]=(0,v.useState)(`idle`),ie=(0,v.useRef)(null),[ae,ce]=(0,v.useState)(0),ue=(0,v.useCallback)(()=>ce(e=>e+1),[]),fe=(0,v.useRef)(null),M=e.status===`loaded`?e:null,pe=M!==null&&CU(e.path),he=M!==null&&EU(e.path),ge=M!==null&&TU(e.path)&&!he,P=M!==null&&wU(e.path),_e=se(e.path),ve=le(e.path),ye=(0,v.useMemo)(()=>M===null?void 0:Su(M.content),[M?.content]),be=ye?.status===`valid`,xe=ye?.status===`valid`||ye?.status===`invalid`,Se=xe||pe||ge||P,Ce=w===`source`,we=yU(),Ee=DU(e.path,t)&&!ve,De=M!==null&&!_e&&!ve;(0,v.useEffect)(()=>{De&&WH().catch(()=>{})},[De]);let Oe=k!==null&&k.draft!==k.baseContent,[ke,Ae]=(0,v.useState)(!1),je=Oe||ke,Me=M?.pendingSave!==void 0,Ne=k!==null&&M!==null&&M.mtimeMs!==k.baseMtimeMs,Pe=M?.saveError?.conflict===!0||Ne,Fe=k?.draft??M?.content??``,Ie=bU(Fe,_U),Le=(0,v.useMemo)(()=>M===null?void 0:Su(Ie),[Ie,M===null]),[Re,ze]=(0,v.useState)(()=>e.status===`loaded`?xU(e.content):void 0);(0,v.useEffect)(()=>{Le?.status===`valid`&&ze(Le.envelope)},[Le]);let Be=Le!==void 0&&Le.status!==`valid`&&Re!==void 0,Ve=Le?.status===`invalid`?Ie===M?.content&&M.documentIssues!==void 0?M.documentIssues:Le.issues:void 0,He=Le?.status===`not-a-document`?Le.why===`unparseable`?`This is not parseable JSON yet.`:"This no longer declares a structured-exchange `schema`.":Le?.status===`unsupported-version`?`This declares ${Le.schema}, which this version does not render.`:void 0,Ue=w===`split`&&Se&&!O&&M!==null&&we,We=O?void 0:Ue?xe?Re:void 0:k===null&&!Ce&&ye?.status===`valid`?ye.envelope:void 0,Ge=(0,v.useRef)(null),Ke=k!==null,qe=M!==null&&k===null&&!Ue&&!O&&(!pe||Ce)&&(!be||Ce)&&(!ge||Ce)&&(!P||Ce)&&(!he||Ce),Ye=O||Ue?`none`:ve?`pdf`:k!==null||qe?`text`:M!==null&&!_e?`dom`:`none`,[Xe,Qe]=(0,v.useState)(!1),[$e,et]=(0,v.useState)(``),[tt,nt]=(0,v.useState)(0),rt=(0,v.useRef)(null),it=(0,v.useRef)(null),at=(0,v.useRef)(null),[ot,st]=(0,v.useState)({matchCount:0,currentIndex:-1,searching:!1}),[ct,lt]=(0,v.useState)([]),[ut,dt]=(0,v.useState)(!1),ft=(0,v.useRef)(null),pt=(0,v.useRef)([]),mt=(0,v.useRef)(0),ht=(0,v.useRef)(``);function gt(e){mt.current=e;for(let[t,n]of pt.current.entries())for(let r of n.marks)r.isConnected&&r.classList.toggle(`find-match-current`,t===e);let t=pt.current[e]?.marks;t?.[0]?.isConnected&&t[0].scrollIntoView({block:`center`})}let _t=Xe?$e:``,vt=(0,v.useMemo)(()=>Ye===`text`?pU(Fe,_t):[],[Ye,Fe,_t]);(0,v.useEffect)(()=>{Xe&&Ye===`none`&&Qe(!1)},[Xe,Ye]),(0,v.useEffect)(()=>{function e(){ft.current?.clear(),ft.current=null,pt.current=[],lt([]),dt(!1)}let t=it.current;if(Ye!==`dom`||_t===``||t===null){e();return}ft.current?.clear();let n=hU(t,_t);ft.current=n,pt.current=n.matches,lt(n.matches),dt(n.truncated);let r=_t!==ht.current;ht.current=_t;let i=r?0:Math.min(mt.current,Math.max(n.matches.length-1,0));return nt(i),gt(i),e},[Ye,_t,w,Ce]);function yt(e,t){let n=e[t];n!==void 0&&ie.current?.select(n.start,n.end)}(0,v.useEffect)(()=>{if(Ye!==`text`||!Xe)return;let e=pU(Fe,_t),t=_t!==ht.current;ht.current=_t;let n=t?0:Math.min(tt,Math.max(e.length-1,0));nt(n),e.length>0&&yt(e,n)},[_t,Ye,Xe,Ke,ae]),(0,v.useEffect)(()=>{ie.current?.markMatches(Ye===`text`?vt:[],tt)},[Ye,vt,tt,Ke,ae]);let bt=M?.reveal,[xt,St]=(0,v.useState)(void 0);(0,v.useEffect)(()=>{if(bt!==void 0&&M!==null){if(bt.page!==void 0)St({page:bt.page});else if(bt.line!==void 0){k===null&&T(`source`);let e=pU(Fe,bt.query),t=kU(Fe,bt.line),n=e.findIndex(e=>e.start>=t);ht.current=bt.query,nt(n===-1?0:n)}et(bt.query),Qe(!0)}},[bt]);function Ct(){Qe(!0)}function wt(){Qe(!1)}function Tt(){if(Ye===`pdf`)at.current?.findNext();else if(Ye===`text`){if(vt.length===0)return;let e=(tt+1)%vt.length;nt(e),yt(vt,e)}else{let e=pt.current.length;if(e===0)return;let t=(mt.current+1)%e;nt(t),gt(t)}}function Et(){if(Ye===`pdf`)at.current?.findPrevious();else if(Ye===`text`){if(vt.length===0)return;let e=(tt-1+vt.length)%vt.length;nt(e),yt(vt,e)}else{let e=pt.current.length;if(e===0)return;let t=(mt.current-1+e)%e;nt(t),gt(t)}}let Dt=Ye===`pdf`?{matchCount:ot.matchCount,currentIndex:ot.currentIndex,truncated:!1,searching:ot.searching}:Ye===`text`?{matchCount:vt.length,currentIndex:vt.length>0?Math.min(tt,vt.length-1):-1,truncated:!1,searching:!1}:{matchCount:ct.length,currentIndex:ct.length>0?Math.min(tt,ct.length-1):-1,truncated:ut,searching:!1},Ot=k===null?null:(0,N.jsx)(v.Suspense,{fallback:(0,N.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading editor…`}),children:(0,N.jsx)(GH,{handle:ie,onReady:ue,path:e.path,value:k.draft,baseline:s,onChange:e=>ne(t=>t===null?t:{...t,draft:e}),onSave:()=>{Oe&&!Me&&!Pe&&It()}})},`editor`);function kt(t){return M===null?null:(0,N.jsx)(v.Suspense,{fallback:(0,N.jsx)(`div`,{className:`p-4`,children:(0,N.jsx)(Te,{code:M.content,path:e.path})}),children:(0,N.jsx)(GH,{readOnly:!0,handle:t?ie:void 0,onReady:t?ue:void 0,path:e.path,value:M.content,baseline:s})},`source`)}let At=(0,v.useCallback)(e=>fetch(de(h,e,g,void 0,_)).then(e=>e.ok?e.blob():void 0,()=>void 0),[h,g,_]);function jt(t){return(0,N.jsx)(`div`,{className:`prose-chat mx-auto max-w-3xl p-4 text-zinc-700 dark:text-zinc-300`,children:(0,N.jsx)(SC,{remarkPlugins:[dz,Cz],rehypePlugins:[WA],components:{pre:Je,a:({href:t,children:n,...r})=>!t||/^[a-z][a-z0-9+.-]*:/i.test(t)?(0,N.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,...r,children:n}):t.startsWith(`#`)?(0,N.jsx)(`a`,{href:t,...r,children:n}):(0,N.jsx)(`a`,{href:t,onClick:n=>{n.preventDefault(),p(oe(e.path,t))},...r,children:n}),img:({src:t,alt:n,...r})=>{let i=typeof t==`string`&&t!==``&&!/^[a-z][a-z0-9+.-]*:/i.test(t)&&!t.startsWith(`//`)?de(h,oe(e.path,t),g,void 0,_):t;return(0,N.jsx)(`img`,{...r,src:i,alt:n??``,loading:`lazy`,className:`max-w-full rounded-lg`})}},children:re(t)})})}function Mt(e){(w!==`split`||e===`split`||!Oe||window.confirm(`Discard unsaved changes?`))&&(e===w||!ke||window.confirm(`Discard unsaved changes?`))&&(w===`split`&&e!==`split`&&ne(null),D(null),T(e))}function Nt(){(!je||window.confirm(`Discard unsaved changes?`))&&f()}function Pt(){M&&(!ke||window.confirm(`Discard unsaved changes?`))&&(Se&&w===`rendered`?(D(`rendered`),T(we?`split`:`source`)):he&&w===`rendered`&&(D(`rendered`),T(`source`)),ne({draft:M.content,baseContent:M.content,baseMtimeMs:M.mtimeMs}))}function Ft(){E===null?ne(Ue&&M!==null?{draft:M.content,baseContent:M.content,baseMtimeMs:M.mtimeMs}:null):(ne(null),T(E),D(null))}function It(t=!1){M&&k!==null&&!Me&&(fe.current=k.draft,m(e.path,k.draft,k.baseMtimeMs,t))}function Lt(){ne(null),p(e.path)}function Rt(){let t=!O;te(t),t?c(e.path):l()}return(0,v.useEffect)(()=>{k!==null&&M!==null&&fe.current!==null&&M.content===fe.current&&M.mtimeMs!==k.baseMtimeMs&&(fe.current=null,ne({...k,baseContent:M.content,baseMtimeMs:M.mtimeMs}))},[M?.mtimeMs]),(0,v.useEffect)(()=>{function e(e){if(e.key===`Escape`)Xe?wt():Nt();else if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`f`){if(Ye===`none`)return;e.preventDefault(),Ct()}}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),(0,v.useEffect)(()=>{Ue&&Ee&&k===null&&M!==null&&ne({draft:M.content,baseContent:M.content,baseMtimeMs:M.mtimeMs})},[Ue,Ee,M?.mtimeMs]),(0,v.useEffect)(()=>{j(n?`streaming`:e=>e===`streaming`?`done`:e)},[n]),(0,v.useEffect)(()=>(r(je),()=>r(!1)),[je]),(0,v.useEffect)(()=>(a&&c(e.path),()=>l()),[]),(0,N.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(Se||he)&&!O&&(0,N.jsx)(`div`,{className:`flex shrink-0 items-center gap-0.5`,role:`group`,"aria-label":`How to show this document`,children:[[`rendered`,`⚏ rendered`,`Show the rendering`],[`split`,`⇹ split`,`Edit the file beside its rendering`],[`source`,`⌗ source`,`Show the file as written`]].filter(([e])=>!(he&&e===`split`)).map(([e,t,n])=>(0,N.jsx)(`button`,{type:`button`,onClick:()=>Mt(e),"aria-pressed":w===e,title:n,className:`rounded px-1.5 py-0.5 text-xs ${w===e?`bg-zinc-100 text-zinc-700 dark:bg-zinc-800 dark:text-zinc-200`:`text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`}`,children:t},e))}),i!==void 0&&k===null&&(0,N.jsx)(`button`,{type:`button`,onClick:Rt,"aria-pressed":O,title:O?`Show file content`:`Show uncommitted changes (vs HEAD)`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs ${O?`bg-amber-100 text-amber-800 dark:bg-amber-950/60 dark:text-amber-300`:`text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`}`,children:`± diff`}),u&&k===null&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>d(e.path),title:`Show this file's history`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`,children:`⎇ history`}),(0,N.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-zinc-500 dark:text-zinc-400`,title:e.path,children:[e.path,je&&(0,N.jsx)(`span`,{className:`ml-1 text-amber-500`,children:`●`})]}),P&&C&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>C(e.path),title:`Open with the application associated with .drawio files — draw.io desktop, where it is installed`,className:`shrink-0 rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-600 hover:border-zinc-400 hover:text-zinc-900 dark:border-zinc-700 dark:text-zinc-300 dark:hover:border-zinc-500 dark:hover:text-zinc-100`,children:`↗ open in draw.io`}),M&&!_e&&!ve&&!P&&!he&&!O&&!xe&&(0,N.jsx)(KH,{text:Fe,path:e.path,serverUrl:h,token:g,workspace:_,template:y}),We?.kind===`table`&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(KH,{text:()=>Ge.current?.markdown?.()??``,path:`${e.path.replace(/\.[^./]*$/,``)}.md`,serverUrl:h,token:g,workspace:_,template:y}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>Ge.current?.xlsx?.(),title:`Download as an Excel workbook`,"aria-label":`Download as an Excel workbook`,className:SU,children:`⤓ excel`})]}),(We?.kind===`graph`||We?.kind===`sequence`||We?.kind===`timeline`)&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>Ge.current?.svg?.(),title:`Download the figure as SVG`,"aria-label":`Download the figure as SVG`,className:SU,children:`⤓ svg`}),M&&k===null&&(0,N.jsx)(me,{text:M.content}),M&&k===null&&!O&&Ee&&(0,N.jsx)(`button`,{type:`button`,onClick:Pt,className:`shrink-0 rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-700 dark:text-zinc-400 dark:hover:border-zinc-500 dark:hover:text-zinc-200`,children:`✎ edit`}),M&&k===null&&!Ee&&(0,N.jsx)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,title:`Outside the writable zone`,children:`🔒 read-only`}),k!==null&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>It(),disabled:!Oe||Me||Pe,className:`shrink-0 rounded border border-emerald-300 px-2 py-0.5 text-xs text-emerald-700 hover:border-emerald-500 disabled:opacity-50 dark:border-emerald-900 dark:text-emerald-400 dark:hover:border-emerald-600`,children:Me?`saving…`:`save`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>{(!Oe||window.confirm(`Discard unsaved changes?`))&&Ft()},className:`shrink-0 rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-500 hover:border-zinc-400 dark:border-zinc-700 dark:text-zinc-400 dark:hover:border-zinc-500`,children:Oe?`cancel`:`done`})]}),(0,N.jsx)(`button`,{type:`button`,onClick:Nt,title:`Close (Esc)`,"aria-label":`Close file viewer`,className:`shrink-0 px-1 text-sm text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-300`,children:`✕`})]}),Xe&&Ye!==`none`&&(0,N.jsx)(uU,{inputRef:rt,query:$e,onQueryChange:et,matchCount:Dt.matchCount,currentIndex:Dt.currentIndex,truncated:Dt.truncated,searching:Dt.searching,onNext:Tt,onPrev:Et,onClose:wt}),Pe&&k!==null&&(0,N.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:[(0,N.jsx)(`span`,{className:`min-w-0 flex-1`,children:`File changed on disk since you started editing.`}),(0,N.jsx)(`button`,{type:`button`,onClick:Lt,className:`shrink-0 rounded border border-amber-400 px-2 py-0.5 text-xs hover:bg-amber-100 dark:border-amber-800 dark:hover:bg-amber-950/60`,children:`reload (discard my edits)`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>It(!0),disabled:Me,className:`shrink-0 rounded border border-amber-400 px-2 py-0.5 text-xs hover:bg-amber-100 disabled:opacity-50 dark:border-amber-800 dark:hover:bg-amber-950/60`,children:`overwrite with my version`})]}),k!==null&&M?.saveError&&!M.saveError.conflict&&(0,N.jsx)(`div`,{className:`border-b border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:M.saveError.message}),(0,N.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[O&&k===null&&(0,N.jsxs)(`div`,{className:`p-4`,children:[o?.path===e.path&&`error`in o&&(0,N.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:o.error}),o?.path===e.path&&`before`in o&&(0,N.jsx)(Ze,{fill:!0,lines:ee(o.before,o.after)}),o?.path!==e.path&&(0,N.jsx)(`div`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`loading diff…`})]}),ve&&k===null&&!O&&(0,N.jsx)(Og,{label:`This PDF`,children:(0,N.jsx)(v.Suspense,{fallback:(0,N.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),children:(0,N.jsx)(gU,{ref:at,path:e.path,serverUrl:h,token:g,workspace:_,revision:S,findQuery:Ye===`pdf`?_t:``,onFindStateChange:st,...xt?{startAt:xt}:{},...x?{onLoaded:x}:{}})})}),_e&&k===null&&!O&&(0,N.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,N.jsx)(`img`,{src:de(h,e.path,g,S,_),alt:e.path,onLoad:()=>b?.(e.path),className:`max-h-full max-w-full rounded object-contain`})}),e.status===`loading`&&k===null&&!O&&!_e&&!ve&&(0,N.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),e.status===`error`&&!_e&&!ve&&(0,N.jsx)(`div`,{className:`p-4 text-sm text-red-600 dark:text-red-400`,children:e.message}),k!==null&&!Ue&&Ot,M&&k===null&&!Ue&&!O&&pe&&!Ce&&(0,N.jsx)(`div`,{ref:it,children:jt(M.content)}),M&&k===null&&!Ue&&!O&&P&&!Ce&&(0,N.jsx)(`div`,{className:`h-full`,"data-testid":`file-drawio`,children:(0,N.jsx)(Uz,{path:e.path,xml:M.content,variant:`viewer`,fallback:kt(!1),onTouchUpDirtyChange:Ae})}),M&&k===null&&!Ue&&!O&&he&&!Ce&&(0,N.jsx)(`div`,{className:`h-full`,"data-testid":`file-poster`,children:(0,N.jsx)($H,{path:e.path,content:M.content,mtimeMs:M.mtimeMs,writable:Ee,loadFile:At,fallback:kt(!1),onTouchUpDirtyChange:Ae})}),M&&k===null&&!Ue&&!O&&ge&&!Ce&&(0,N.jsx)(`div`,{className:`h-full`,"data-testid":`file-html`,children:(0,N.jsx)(lU,{source:M.content,path:e.path,load:At,onOpen:p})}),Ue&&(0,N.jsxs)(`div`,{className:`flex h-full min-h-0`,"data-testid":`file-split`,children:[(0,N.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto border-r border-zinc-200 dark:border-zinc-800`,children:Ot??kt(!1)}),(0,N.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto`,"data-testid":`file-split-rendering`,children:pe&&!xe?(0,N.jsx)(`div`,{className:`prose-chat p-4 text-zinc-700 dark:text-zinc-300`,children:jt(Ie)}):P&&!xe?(0,N.jsx)(Km,{xml:Ie,serverUrl:h,title:e.path}):ge&&!xe?(0,N.jsx)(lU,{source:Ie,path:e.path,load:At,onOpen:p}):(0,N.jsxs)(N.Fragment,{children:[Be&&(0,N.jsx)(`p`,{"data-testid":`file-split-stale`,className:`flex flex-wrap items-center gap-2 border-b border-amber-300 bg-amber-50 px-3 py-1.5 text-xs text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200`,children:(0,N.jsxs)(`span`,{children:[`Showing the document as it last stood.`,` `,He??`The text beside it does not satisfy the schema it declares.`]})}),Ve!==void 0&&(0,N.jsxs)(`ul`,{"data-testid":`file-split-issues`,className:`space-y-0.5 border-b border-zinc-200 px-3 py-1.5 text-xs text-zinc-500 dark:border-zinc-800 dark:text-zinc-400`,children:[Ve.slice(0,6).map((e,t)=>(0,N.jsxs)(`li`,{children:[(0,N.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),Ve.length>6&&(0,N.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,Ve.length-6,` more`]})]}),Re===void 0?(0,N.jsxs)(`p`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,"data-testid":`file-split-nothing`,children:[`Nothing to draw yet. `,He??`This document does not satisfy the schema it declares.`]}):(0,N.jsx)(Og,{label:`This diagram`,children:(0,N.jsx)(`div`,{className:`p-4`,"data-testid":`file-structured-exchange`,children:(0,N.jsx)(Tg,{envelope:Re,source:Fe,exportRef:Ge,file:{path:e.path,writable:Ee}})})})]})})]}),M&&k===null&&!Ue&&!O&&be&&!Ce&&ye?.status===`valid`&&(0,N.jsx)(Og,{label:`This diagram`,children:(0,N.jsx)(`div`,{className:`mx-auto max-w-5xl p-4`,"data-testid":`file-structured-exchange`,children:(0,N.jsx)(Tg,{envelope:ye.envelope,source:M.content,exportRef:Ge,file:{path:e.path,writable:Ee}})})}),M&&k===null&&!Ue&&!O&&ye?.status===`invalid`&&(0,N.jsxs)(`div`,{"data-testid":`file-structured-exchange-invalid`,className:`mx-4 mt-4 rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-200`,children:[(0,N.jsx)(`p`,{className:`font-medium`,children:`This declares a structured-exchange document and does not satisfy the schema.`}),(0,N.jsxs)(`ul`,{className:`mt-1 space-y-0.5 text-xs`,children:[(M.documentIssues??ye.issues).slice(0,8).map((e,t)=>(0,N.jsxs)(`li`,{children:[(0,N.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),(M.documentIssues??ye.issues).length>8&&(0,N.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,(M.documentIssues??ye.issues).length-8,` more`]})]})]}),M&&k===null&&!Ue&&!O&&ye?.status===`unsupported-version`&&(0,N.jsxs)(`div`,{"data-testid":`file-structured-exchange-unsupported`,className:`mx-4 mt-4 rounded-lg border border-zinc-300 bg-zinc-50 px-3 py-2 text-sm text-zinc-600 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-400`,children:[`This document declares `,(0,N.jsx)(`span`,{className:`font-mono`,children:ye.schema}),`, which this version does not render. Shown as text.`]}),qe&&kt(!0)]}),A!==`idle`&&(0,N.jsxs)(`button`,{type:`button`,onClick:Nt,"aria-live":`polite`,className:`flex items-center gap-2 border-t border-zinc-200 px-3 py-2 text-left text-sm hover:bg-zinc-50 dark:border-zinc-800 dark:hover:bg-zinc-900`,children:[A===`streaming`?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 animate-pulse motion-reduce:animate-none rounded-full bg-amber-500`}),(0,N.jsx)(`span`,{className:`text-amber-700 dark:text-amber-400`,children:`π is replying…`})]}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 rounded-full bg-emerald-500`}),(0,N.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:`π replied`})]}),(0,N.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-500`,children:`show conversation →`})]})]})}function kU(e,t){let n=0;for(let r=1;r<t;r++){let t=e.indexOf(`
|
|
867
867
|
`,n);if(t===-1)return e.length;n=t+1}return n}function AU(e){return e.split(`
|
|
868
868
|
`).map(e=>e.startsWith(`diff --git `)?{kind:`file`,text:e.slice(11)}:e.startsWith(`@@`)||e.startsWith(`+++`)||e.startsWith(`---`)||e.startsWith(`index `)?{kind:`hunk`,text:e}:e.startsWith(`+`)?{kind:`add`,text:e.slice(1)}:e.startsWith(`-`)?{kind:`del`,text:e.slice(1)}:{kind:`context`,text:e.startsWith(` `)?e.slice(1):e})}function jU({show:e,onClose:t}){return(0,v.useEffect)(()=>{function e(e){e.key===`Escape`&&(e.stopImmediatePropagation(),t())}return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t]),(0,N.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,N.jsx)(`span`,{className:`font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,12)}),(0,N.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`commit diff`}),(0,N.jsx)(`button`,{type:`button`,onClick:t,title:`Close (Esc)`,"aria-label":`Close commit diff`,className:`shrink-0 px-1 text-sm text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-300`,children:`✕`})]}),e.truncated&&(0,N.jsx)(`div`,{className:`border-b border-amber-300 bg-amber-50 px-3 py-1.5 text-xs text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:`Patch truncated — showing the first 256 KiB.`}),(0,N.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto p-3 font-mono text-xs leading-relaxed`,children:AU(e.patch).map((e,t)=>(0,N.jsxs)(`div`,{className:e.kind===`file`?`mt-3 border-t border-zinc-200 pt-2 font-bold text-zinc-700 first:mt-0 first:border-t-0 first:pt-0 dark:border-zinc-800 dark:text-zinc-200`:e.kind===`hunk`?`text-sky-600 dark:text-sky-400`:e.kind===`add`?`bg-emerald-50 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-300`:e.kind===`del`?`bg-red-50 text-red-700 dark:bg-red-950/40 dark:text-red-300`:`text-zinc-500 dark:text-zinc-500`,children:[e.kind===`add`?`+ `:e.kind===`del`?`− `:``,e.text||` `]},t))})]})}var MU=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`],NU=`worktree`,PU={defaultWidth:288,minWidth:224,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.files-sidebar-width.v1`},FU={defaultWidth:416,minWidth:224,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.history-list-width.v1`},IU={defaultWidth:288,minWidth:160,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.terminal-height.v1`};function LU(e,t){return Number.isFinite(e)?Math.min(t.maxWidth,Math.max(t.minWidth,Math.round(e))):t.defaultWidth}function RU(e,t){return e===null||e.trim()===``?t.defaultWidth:LU(Number(e),t)}function zU(e,t){try{return RU((t??window.localStorage).getItem(e.storageKey),e)}catch{return e.defaultWidth}}function BU(e,t,n){try{(n??window.localStorage).setItem(t.storageKey,String(LU(e,t)))}catch{}}function VU(e,t=`x`){let[n,r]=(0,v.useState)(()=>zU(e)),i=(0,v.useRef)(n),a=(0,v.useRef)(null),o=(0,v.useCallback)(t=>{let n=LU(t,e);return i.current=n,r(n),n},[e]),s=(0,v.useCallback)(()=>{a.current!==null&&(a.current=null,BU(i.current,e))},[e]);return{width:n,separatorProps:{onPointerDown:e=>{e.isPrimary!==!1&&(e.button??0)===0&&(e.preventDefault(),e.currentTarget.setPointerCapture?.(e.pointerId),a.current={pointerId:e.pointerId,startX:t===`y`?e.clientY:e.clientX,startWidth:i.current})},onPointerMove:e=>{let n=a.current;n!==null&&n.pointerId===e.pointerId&&o(n.startWidth+(t===`y`?n.startX-e.clientY:e.clientX-n.startX))},onPointerUp:e=>{a.current?.pointerId===e.pointerId&&s()},onPointerCancel:e=>{let t=a.current;t!==null&&t.pointerId===e.pointerId&&(a.current=null,o(t.startWidth))},onLostPointerCapture:s,onKeyDown:n=>{let r=null;n.key===(t===`y`?`ArrowDown`:`ArrowLeft`)?r=i.current-e.keyboardStep:n.key===(t===`y`?`ArrowUp`:`ArrowRight`)?r=i.current+e.keyboardStep:n.key===`Home`&&(r=e.defaultWidth),r!==null&&(n.preventDefault(),BU(o(r),e))}}}}function HU({axis:e=`x`,label:t,width:n,config:r,separatorProps:i,className:a=``}){return(0,N.jsx)(`div`,{...i,role:`separator`,"aria-label":t,"aria-orientation":e===`y`?`horizontal`:`vertical`,"aria-valuemin":r.minWidth,"aria-valuemax":r.maxWidth,"aria-valuenow":n,tabIndex:0,title:t,className:`group absolute z-20 touch-none outline-none ${e===`y`?`inset-x-0 -top-1 h-2 cursor-row-resize`:`inset-y-0 -right-1 w-2 cursor-col-resize`} ${a}`,children:(0,N.jsx)(`span`,{className:`pointer-events-none absolute ${e===`y`?`inset-x-0 top-1/2 h-px`:`inset-y-0 left-1/2 w-px`} bg-transparent transition-colors group-hover:bg-blue-400 group-focus-visible:bg-blue-500 group-active:bg-blue-500 dark:group-hover:bg-blue-500`})})}var UU=`#10b981`,WU=[`#8b5cf6`,`#f59e0b`,`#0ea5e9`,`#f43f5e`,`#14b8a6`,`#d946ef`];function GU(e){return e===0?UU:WU[(e-1)%WU.length]}function KU(e){return WU[e%WU.length]}function qU(e){return e*14+7+1}function JU(e){return e*14+2}function YU({row:e,laneCount:t,colorOf:n=GU}){let r=JU(t),i=qU(e.lane),a=e.highlight?UU:n(e.lane),o=e.dashed?`3 3`:void 0;return(0,N.jsxs)(`svg`,{width:r,height:36,viewBox:`0 0 ${r} 36`,"aria-hidden":!0,className:`shrink-0`,children:[e.through.map(e=>(0,N.jsx)(`line`,{x1:qU(e),y1:0,x2:qU(e),y2:36,stroke:n(e),strokeWidth:2,opacity:.55},e)),e.lineAbove&&(0,N.jsx)(`line`,{x1:i,y1:0,x2:i,y2:18,stroke:a,strokeWidth:2,strokeDasharray:o}),e.lineBelow&&(0,N.jsx)(`line`,{x1:i,y1:18,x2:i,y2:36,stroke:a,strokeWidth:2,strokeDasharray:o}),e.forkTo.map(e=>(0,N.jsx)(`path`,{d:`M ${i} 18 C ${i} 36, ${qU(e)} 18, ${qU(e)} 36`,fill:`none`,stroke:n(e),strokeWidth:2,opacity:.75},`fork-${e}`)),(e.mergeFrom??[]).map(e=>(0,N.jsx)(`path`,{d:`M ${i} 18 C ${i} 0, ${qU(e)} 18, ${qU(e)} 0`,fill:`none`,stroke:n(e),strokeWidth:2,opacity:.75},`merge-${e}`)),e.emphasis===`current`?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`circle`,{cx:i,cy:18,r:6,fill:`none`,stroke:a,strokeWidth:2}),(0,N.jsx)(`circle`,{cx:i,cy:18,r:2.5,fill:a})]}):(0,N.jsx)(`circle`,{cx:i,cy:18,r:4,fill:e.emphasis===`filled`?a:`var(--tree-off, #d4d4d8)`,stroke:a,strokeWidth:e.emphasis===`filled`?0:1.5})]})}function XU(e,t){let n=[],r=t===void 0?[]:[t],i=r.length,a=t!==void 0,o=()=>{let e=r.indexOf(null);return e===-1?(r.push(null),i=Math.max(i,r.length),r.length-1):e};for(let s of e){let e=r.reduce((e,t,n)=>t===s.sha?[...e,n]:e,[]),c=e[0]??o();s.sha===t&&(a=!1);let l=(s.sha===t?e.length-1:e.length)===0,u=e.slice(1);for(let e of u)r[e]=null;i=Math.max(i,c+1);let[d,...f]=s.parents;r[c]=d??null;let p=f.map(e=>{let t=o();return r[t]=e,t});n.push({lane:c,through:r.reduce((e,t,n)=>t!==null&&n!==c&&!p.includes(n)&&!(a&&n===0)?[...e,n]:e,[]),forkTo:p,mergeFrom:u,tip:l})}return{lanes:n,laneCount:Math.max(i,1)}}function ZU(e){let t=e.find(e=>e.head)?.sha,{lanes:n,laneCount:r}=XU(e,t);return{rows:e.map((e,t)=>{let{lane:r,through:i,forkTo:a,mergeFrom:o,tip:s}=n[t];return{lane:r,through:i,forkTo:a,mergeFrom:o,entry:e,lineAbove:!s,lineBelow:e.parents.length>0,emphasis:e.head?`current`:`filled`}}),laneCount:r}}function QU(e,t={}){let{lanes:n,laneCount:r}=XU(e),i=e.map((e,t)=>{let{lane:r,through:i,forkTo:a,mergeFrom:o}=n[t];return{lane:r,through:i,forkTo:a,mergeFrom:o,rev:e.sha,path:e.path,entry:e,lineAbove:!0,lineBelow:e.parents.length>0,emphasis:`filled`}}),a=i[0];return i.unshift({rev:NU,path:a?.path??``,lane:a?.lane??0,through:a?.through??[],forkTo:[],mergeFrom:[],lineAbove:!1,lineBelow:i.length>0,emphasis:`current`,dashed:!t.dirty}),i[1]&&(i[1].lineAbove=!0),{rows:i,laneCount:r}}var $U=20;function eW(e){let t=(Date.now()-new Date(e).getTime())/1e3;return t<90?`now`:t<3600?`${Math.round(t/60)}m ago`:t<86400?`${Math.round(t/3600)}h ago`:`${Math.round(t/86400)}d ago`}function tW(e){return e.rev===`worktree`?`working tree`:e.rev.slice(0,7)}function nW(e,t){return e!==null&&t!==null&&e.rev===t.rev&&e.path===t.path}function rW(e){return{rev:e.rev,path:e.path}}function iW({history:e,diff:t,dirty:n,onFetchDiff:r,onClearDiff:i,onClose:a}){let[o,s]=(0,v.useState)({base:null,target:null}),{base:c,target:l}=o,[u,d]=(0,v.useState)(0),f=(0,v.useRef)([]),p=VU(FU),{rows:m,laneCount:h}=(0,v.useMemo)(()=>QU(e.entries,{dirty:n}),[e.entries,n]),g=(0,v.useRef)({onFetchDiff:r,onClose:a});g.current={onFetchDiff:r,onClose:a},(0,v.useEffect)(()=>{function e(e){e.key===`Escape`&&(e.stopImmediatePropagation(),g.current.onClose())}return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[]),(0,v.useEffect)(()=>{c===null||l===null||nW(c,l)||g.current.onFetchDiff(c,l)},[c,l]);let _=(0,v.useCallback)((e,t)=>{let n=rW(e);s(r=>{if(t===`base`)return{base:n,target:nW(n,r.target)?r.base:r.target};if(t===`target`)return{base:nW(n,r.base)?r.target:r.base,target:n};if(r.base===null&&r.target===null){let t=e.entry?.parents[0],r=t===void 0?void 0:m.find(e=>e.rev===t);return{base:r?rW(r):null,target:n}}return{base:nW(n,r.base)?r.target:r.base,target:n}})},[m]),y=(0,v.useCallback)(()=>{s({base:null,target:null}),i()},[i]),b=(0,v.useCallback)(()=>s(e=>({base:e.target,target:e.base})),[]),x=(0,v.useCallback)(e=>{d(t=>{let n=Math.max(0,Math.min(m.length-1,t+e));return f.current[n]?.focus(),n})},[m.length]),S=e=>{let t=rW(e);return nW(t,c)?`base`:nW(t,l)?`target`:null},C=m.findIndex(e=>nW(rW(e),c)),w=m.findIndex(e=>nW(rW(e),l)),T=C>=0&&w>=0?{top:Math.min(C,w)*36+18,height:Math.abs(w-C)*36}:null;return(0,N.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,N.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-zinc-500 dark:text-zinc-400`,title:e.path,children:e.path}),c!==null&&l!==null&&(0,N.jsxs)(`span`,{className:`shrink-0 font-mono text-xs text-zinc-500 dark:text-zinc-400`,"aria-label":`Comparing ${tW(c)} to ${tW(l)}`,children:[(0,N.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:tW(c)}),` → `,(0,N.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:tW(l)})]}),c!==null&&l!==null&&(0,N.jsx)(`button`,{type:`button`,onClick:b,title:`Compare the other way round`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-500 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:`⇄ swap`}),(c!==null||l!==null)&&(0,N.jsx)(`button`,{type:`button`,onClick:y,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-500 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:`clear`}),(0,N.jsx)(`button`,{type:`button`,onClick:a,title:`Close (Esc)`,"aria-label":`Close file history`,className:`shrink-0 px-1 text-sm text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-300`,children:`✕`})]}),(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,N.jsxs)(`div`,{role:`region`,"aria-label":`Commit history`,style:{"--history-list-width":`${p.width}px`},className:`relative flex max-h-[40%] w-full shrink-0 flex-col border-b border-zinc-200 md:max-h-none md:w-[var(--history-list-width)] md:border-b-0 md:border-r dark:border-zinc-800`,children:[(0,N.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),x(1)):e.key===`ArrowUp`&&(e.preventDefault(),x(-1))},children:[e.status===`loading`&&(0,N.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`Reading history…`}),e.status===`error`&&(0,N.jsx)(`div`,{className:`m-3 rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:e.error}),e.status===`loaded`&&e.entries.length===0&&(0,N.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`No commits touch this file yet.`}),e.status===`loaded`&&e.entries.length>0&&(0,N.jsxs)(`div`,{className:`relative`,role:`group`,"aria-label":`Commits`,children:[T&&(0,N.jsx)(aW,{top:T.top,height:T.height,baseFirst:C<w}),m.map((e,t)=>(0,N.jsx)(cW,{ref:e=>{f.current[t]=e},row:e,laneCount:h,role:S(e),isFocused:t===u,onSelect:t=>_(e,t),onFocus:()=>d(t)},e.rev))]})]}),(0,N.jsx)(HU,{label:`Resize History commit list`,width:p.width,config:FU,separatorProps:p.separatorProps,className:`hidden md:block`})]}),(0,N.jsx)(`div`,{role:`region`,"aria-label":`History diff`,className:`min-h-0 min-w-0 flex-1 overflow-auto p-3`,children:(0,N.jsx)(lW,{diff:t,base:c,target:l})})]})]})}function aW({top:e,height:t,baseFirst:n}){return(0,N.jsxs)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute left-0 z-10 motion-safe:transition-all motion-safe:duration-150 motion-safe:ease-out`,style:{top:e,height:t,width:$U},children:[(0,N.jsx)(`div`,{className:`absolute inset-y-0 left-2 w-px bg-zinc-400 dark:bg-zinc-500`}),(0,N.jsx)(oW,{label:n?`base`:`target`,className:`top-0`}),(0,N.jsx)(oW,{label:n?`target`:`base`,className:`bottom-0`})]})}function oW({label:e,className:t}){return(0,N.jsx)(`div`,{className:`absolute left-2 flex h-px w-2.5 items-center bg-zinc-400 dark:bg-zinc-500 ${t}`,children:(0,N.jsx)(`span`,{className:`absolute -left-1 -top-1.5 rotate-180 text-[9px] leading-none text-zinc-500 [writing-mode:vertical-rl] dark:text-zinc-400`,children:e})})}var sW=`shrink-0 rounded px-1 py-0.5 text-[10px] text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 aria-disabled:cursor-default aria-disabled:opacity-30 dark:text-zinc-500 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`;function cW({row:e,laneCount:t,role:n,isFocused:r,onSelect:i,onFocus:a,ref:o}){let s=e.entry,c=s?`${s.sha.slice(0,7)} ${s.subject}`:`Working tree`;return(0,N.jsxs)(`div`,{ref:o,role:`button`,tabIndex:r?0:-1,"aria-label":c,"aria-current":n===null?void 0:`true`,onFocus:a,onClick:()=>i(),onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `?(e.preventDefault(),i()):e.key===`b`?i(`base`):e.key===`t`&&i(`target`))},style:{height:36,paddingLeft:$U},className:`group flex cursor-pointer items-center gap-2 pr-2 focus:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800/70 ${n===null?``:`bg-zinc-100 dark:bg-zinc-800/60`}`,children:[(0,N.jsx)(YU,{row:e,laneCount:t}),s?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:s.sha.slice(0,7)}),(0,N.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-700 dark:text-zinc-300`,title:s.subject,children:s.subject}),(0,N.jsxs)(`span`,{className:`shrink-0 text-[10px] text-zinc-400 dark:text-zinc-600`,children:[s.author,` · `,eW(s.date)]}),(0,N.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums`,"aria-label":`${s.added} lines added, ${s.deleted} removed`,children:[(0,N.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-500`,children:[`+`,s.added]}),` `,(0,N.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,s.deleted]})]})]}):(0,N.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`working tree`}),(0,N.jsxs)(`span`,{className:`flex shrink-0 gap-0.5`,children:[(0,N.jsx)(`button`,{type:`button`,title:n===`target`?`Make this the base (swaps the two)`:`Compare from this version`,onClick:e=>{e.stopPropagation(),i(`base`)},className:sW,children:`base`}),(0,N.jsx)(`button`,{type:`button`,title:n===`base`?`Make this the target (swaps the two)`:`Compare to this version`,onClick:e=>{e.stopPropagation(),i(`target`)},className:sW,children:`target`})]})]})}function lW({diff:e,base:t,target:n}){return t===null&&n===null?(0,N.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Pick a commit to see what changed.`}):t===null||n===null?(0,N.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Now pick the version to compare it against.`}):e?.status===`error`?(0,N.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:e.error}):e===null?(0,N.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Loading…`}):e.status===`loaded`&&e.beforeText===e.afterText?(0,N.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`These two versions are identical.`}):e.status===`loaded`&&O(e.beforeText,e.afterText)?(0,N.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`These two versions differ only in their line endings.`}):(0,N.jsx)(`div`,{className:e.status===`loading`?`opacity-40`:void 0,children:(0,N.jsx)(Ze,{fill:!0,lines:ee(e.beforeText,e.afterText)})})}var uW=`inline-flex h-7 shrink-0 items-center gap-1 whitespace-nowrap rounded-md border px-2 text-xs leading-none`,dW=`inline-flex h-7 min-w-0 items-center gap-1 whitespace-nowrap rounded-md border px-2 text-xs leading-none`;function fW(e){let t=e.filter(e=>!e.sideOf).flatMap(t=>[t,...e.filter(e=>e.sideOf===t.root)]);return[...t,...e.filter(e=>!t.includes(e))]}var pW={stopped:`stopped`,starting:`starting…`,idle:`idle`,working:`working`,waiting:`waiting for you`,"ready-for-review":`ready for review`};function mW({activity:e}){switch(e){case`stopped`:return(0,N.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full border border-dashed border-zinc-400 dark:border-zinc-600`});case`starting`:return(0,N.jsx)(`svg`,{className:`h-2.5 w-2.5 shrink-0 animate-spin text-zinc-500 dark:text-zinc-400`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3.5`,strokeLinecap:`round`,children:(0,N.jsx)(`path`,{d:`M12 3a9 9 0 0 1 9 9`})});case`working`:return(0,N.jsxs)(`span`,{className:`relative flex h-2 w-2 shrink-0 items-center justify-center`,children:[(0,N.jsx)(`span`,{className:`absolute h-2 w-2 animate-ping rounded-full bg-blue-700 opacity-60 dark:bg-blue-400`}),(0,N.jsx)(`span`,{className:`relative h-2 w-2 rounded-full bg-blue-700 dark:bg-blue-400`})]});case`waiting`:return(0,N.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-amber-500`});case`ready-for-review`:return(0,N.jsx)(`span`,{className:`h-2 w-2 shrink-0 rotate-45 rounded-[1px] border-2 border-violet-600 bg-violet-100 dark:border-violet-400 dark:bg-violet-950`});default:return(0,N.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-zinc-400 dark:bg-zinc-600`})}}function hW({className:e}){return(0,N.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,N.jsx)(`path`,{d:`M12 6v7`}),(0,N.jsx)(`path`,{d:`M12 18h.01`})]})}function gW({className:e}){return(0,N.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,N.jsx)(`path`,{d:`M7 3h10v18H7z`}),(0,N.jsx)(`path`,{d:`m9.5 12 1.7 1.7 3.5-3.7`})]})}function _W(e){let{workspace:t,workspaces:n,locked:r}=e,[i,a]=(0,v.useState)(!1),o=(0,v.useRef)(null);if((0,v.useEffect)(()=>{if(!i)return;let e=e=>{aH(e,o.current)||a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]),r||!t)return null;let s=n.filter(e=>GB(e)!==GB(t)),c=n.filter(e=>!e.sideOf).length,l=n.filter(e=>e.needsAttention);return(0,N.jsxs)(`div`,{ref:o,className:`relative min-w-[4rem] max-w-[16rem]`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),"aria-expanded":i,"aria-haspopup":`menu`,title:`Project: ${t.name} (${pW[t.activity]})`,className:`${dW} max-w-full gap-1.5 ${l.length>0?`border-amber-500 bg-amber-50 text-zinc-700 dark:bg-amber-950/40 dark:text-zinc-200`:`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`}`,children:[(0,N.jsx)(mW,{activity:t.activity}),(0,N.jsx)(`span`,{className:`truncate font-medium`,children:t.name}),l.length>0?(0,N.jsxs)(`span`,{className:`flex items-center gap-1 text-amber-600 dark:text-amber-500`,children:[(0,N.jsx)(hW,{className:`h-3 w-3`}),(0,N.jsx)(`span`,{className:`font-semibold`,children:l.length})]}):s.some(e=>e.activity===`working`)&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{className:`h-3 w-px bg-zinc-300 dark:bg-zinc-600`}),(0,N.jsx)(`span`,{className:`flex items-center gap-1`,children:s.map(e=>e.activity===`working`?(0,N.jsxs)(`span`,{className:`relative flex h-1.5 w-1.5 items-center justify-center`,children:[(0,N.jsx)(`span`,{className:`absolute h-1.5 w-1.5 animate-ping rounded-full bg-blue-700 opacity-60 dark:bg-blue-400`}),(0,N.jsx)(`span`,{className:`relative h-1.5 w-1.5 rounded-full bg-blue-700 dark:bg-blue-400`})]},GB(e)):(0,N.jsx)(`span`,{className:`h-1 w-1 rounded-full bg-zinc-300 dark:bg-zinc-600`},GB(e)))})]}),(0,N.jsx)(`svg`,{className:`h-3 w-3 text-zinc-500`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,N.jsx)(`path`,{d:`m6 9 6 6 6-6`})})]}),i&&(0,N.jsxs)(`div`,{role:`menu`,className:`absolute left-0 top-full z-40 mt-1 w-87 rounded-md border border-zinc-300 bg-white p-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:[fW(n).map(n=>{let r=GB(n),i=r===GB(t),o=n.sideOf!==void 0;return(0,N.jsxs)(`div`,{"data-testid":o?`side-session-row`:`project-row`,className:`group flex items-center gap-2.5 rounded-md py-2 pr-2.5 ${o?`pl-7`:`pl-2.5`} ${i?`bg-zinc-100 dark:bg-zinc-800`:`hover:bg-zinc-50 dark:hover:bg-zinc-800/50`}`,children:[(0,N.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{a(!1),o?e.onSwitch(n.root,n.id):e.onSwitch(n.root)},className:`flex min-w-0 flex-1 items-center gap-2.5 text-left`,children:[(0,N.jsx)(mW,{activity:n.activity}),(0,N.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,N.jsx)(`span`,{className:`truncate text-[13px] ${i?`font-semibold text-zinc-900 dark:text-zinc-100`:`font-medium text-zinc-900 dark:text-zinc-100`}`,children:o?n.label??n.name:n.name}),!o&&(0,N.jsx)(`span`,{className:`truncate font-mono text-[11px] text-zinc-400 dark:text-zinc-500`,children:n.root})]})]}),(0,N.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[n.needsAttention?(0,N.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] font-medium ${n.activity===`ready-for-review`?`text-violet-700 dark:text-violet-400`:`text-amber-600 dark:text-amber-500`}`,children:[n.activity===`ready-for-review`?(0,N.jsx)(gW,{className:`h-3 w-3`}):(0,N.jsx)(hW,{className:`h-3 w-3`}),pW[n.activity]]}):(0,N.jsx)(`span`,{className:`text-[11px] ${n.activity===`working`?`text-blue-700 dark:text-blue-400`:`text-zinc-400 dark:text-zinc-500`}`,children:pW[n.activity]}),!o&&e.onOpenSide&&(0,N.jsx)(`button`,{type:`button`,title:`New side session on ${n.name}`,"aria-label":`New side session on ${n.name}`,onClick:t=>{t.stopPropagation(),a(!1),e.onOpenSide?.(n.root)},className:`flex h-5 w-5 items-center justify-center rounded border border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-800 dark:border-zinc-600 dark:text-zinc-400 dark:hover:border-zinc-500 dark:hover:text-zinc-100`,children:(0,N.jsxs)(`svg`,{className:`h-2.5 w-2.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,children:[(0,N.jsx)(`path`,{d:`M12 5v14`}),(0,N.jsx)(`path`,{d:`M5 12h14`})]})}),(o||c>1)&&(0,N.jsx)(`button`,{type:`button`,title:`Close ${o?n.label??n.name:n.name}`,"aria-label":`Close ${o?n.label??n.name:n.name}`,onClick:t=>{t.stopPropagation(),o?e.onClose(n.root,n.id):e.onClose(n.root)},className:`flex h-5 w-5 items-center justify-center rounded border border-transparent text-zinc-400 opacity-0 group-hover:border-zinc-300 group-hover:opacity-100 hover:text-zinc-700 dark:group-hover:border-zinc-600 dark:hover:text-zinc-200`,children:(0,N.jsxs)(`svg`,{className:`h-2.5 w-2.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,N.jsx)(`path`,{d:`M18 6 6 18`}),(0,N.jsx)(`path`,{d:`m6 6 12 12`})]})})]})]},r)}),(0,N.jsx)(`div`,{className:`my-1 h-px bg-zinc-200 dark:bg-zinc-700`}),(0,N.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{a(!1),e.onOpen()},className:`flex w-full items-center gap-2.5 rounded-md px-2.5 py-2 text-left text-[13px] text-zinc-700 hover:bg-zinc-50 dark:text-zinc-300 dark:hover:bg-zinc-800/50`,children:[(0,N.jsxs)(`svg`,{className:`h-3.5 w-3.5 text-zinc-500`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`path`,{d:`M12 5v14`}),(0,N.jsx)(`path`,{d:`M5 12h14`})]}),`Open a project…`]})]})]})}function vW({label:e,browse:t,onBrowse:n,onSelect:r,onCancel:i}){let a=t?.path??`/`,o=t?.entries??[],s=t?.status===`loading`,[c,l]=(0,v.useState)(a);return(0,v.useEffect)(()=>{l(a)},[a]),(0,N.jsxs)(`div`,{className:`rounded-md border border-zinc-300 p-2 dark:border-zinc-700`,"data-testid":`server-path-picker`,children:[(0,N.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,N.jsx)(`span`,{className:`text-xs font-semibold text-zinc-600 dark:text-zinc-300`,children:e}),(0,N.jsx)(`button`,{type:`button`,onClick:i,className:`text-xs text-zinc-500 hover:text-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200`,children:`Cancel`})]}),(0,N.jsxs)(`form`,{className:`mb-2 flex gap-1`,onSubmit:e=>{e.preventDefault();let t=c.trim();t&&n(t)},children:[(0,N.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),l(a))},spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,"aria-label":`Current directory`,"data-testid":`picker-path`,className:`min-w-0 flex-1 rounded border border-zinc-300 px-2 py-1 font-mono text-xs text-zinc-700 focus:border-zinc-500 focus:outline-none dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200`}),(0,N.jsx)(`button`,{type:`submit`,disabled:c.trim()===``||c===a,className:`rounded border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-40 dark:border-zinc-700 dark:text-zinc-300`,children:`Go`})]}),t?.status===`error`&&(0,N.jsx)(`p`,{role:`alert`,className:`mb-2 text-xs text-red-600 dark:text-red-400`,children:t.error}),(0,N.jsxs)(`div`,{className:`mb-2 flex gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,disabled:!t?.parent,onClick:()=>t?.parent&&n(t.parent),className:`rounded border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-40 dark:border-zinc-700 dark:text-zinc-300`,children:`Up`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>r(a),className:`rounded bg-zinc-800 px-2 py-1 text-xs font-medium text-white hover:bg-zinc-700 dark:bg-zinc-200 dark:text-zinc-900`,children:`Use this directory`})]}),(0,N.jsxs)(`ul`,{className:`max-h-40 overflow-y-auto`,children:[s&&o.length===0&&(0,N.jsx)(`li`,{className:`px-2 py-1 text-xs text-zinc-400`,children:`Loading…`}),!s&&o.length===0&&t?.status!==`error`&&(0,N.jsx)(`li`,{className:`px-2 py-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`No subdirectories`}),o.map(e=>(0,N.jsx)(`li`,{children:(0,N.jsxs)(`button`,{type:`button`,onClick:()=>n(e.path),className:`w-full truncate rounded px-2 py-1 text-left font-mono text-xs text-zinc-600 hover:bg-zinc-100 dark:text-zinc-300 dark:hover:bg-zinc-800`,title:e.path,children:[e.name,e.name.endsWith(`:`)?`\\`:`/`]})},e.path))]})]})}function yW(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function bW(e){let{sandbox:t,applyState:n,blocked:r=!1,onCloseBrowser:i}=e,[a,o]=(0,v.useState)(!1),s=(0,v.useRef)(!1);if((0,v.useEffect)(()=>{r&&a&&(s.current=!1,o(!1))},[r,a]),(0,v.useEffect)(()=>{s.current&&n?.status!==`applying`&&(n?.status===`error`?s.current=!1:(s.current=!1,o(!1),i()))},[n,i]),!t)return(0,N.jsx)(`span`,{className:`${uW} border-dashed border-zinc-300 text-zinc-400 dark:border-zinc-700 dark:text-zinc-500`,title:`This server runs without a sandbox, so there is no root to move`,children:`No sandbox`});let c=t.locks?.root===!0,l=yW(t.root);return(0,N.jsxs)(`div`,{className:`relative min-w-[4rem] max-w-[14rem]`,children:[(0,N.jsxs)(`button`,{type:`button`,disabled:c,"aria-label":c?`Sandbox root: ${t.root} (locked)`:`Sandbox root: ${t.root}`,title:c?`${t.root} — locked by the server's configuration`:t.root,onClick:()=>{e.onOpened(),o(!0),e.onBrowse(t.root)},className:`${dW} max-w-full gap-1.5 ${c?`cursor-not-allowed border-zinc-200 text-zinc-400 dark:border-zinc-800 dark:text-zinc-500`:`border-zinc-300 text-zinc-600 hover:border-zinc-400 hover:text-zinc-800 dark:border-zinc-700 dark:text-zinc-300 dark:hover:border-zinc-500 dark:hover:text-zinc-100`}`,children:[(0,N.jsx)(`span`,{className:`truncate font-mono`,children:l}),c?(0,N.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):(0,N.jsx)(`span`,{"aria-hidden":`true`,children:`▾`})]}),a&&!r&&(0,N.jsxs)(`div`,{className:`absolute left-0 top-full z-20 mt-1 w-[380px] rounded-lg border border-zinc-200 bg-white p-2 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[n?.status===`error`&&(0,N.jsx)(`p`,{role:`alert`,className:`mb-2 text-xs text-red-600 dark:text-red-400`,children:n.message}),(0,N.jsx)(vW,{label:`Choose the sandbox root`,browse:e.browse,onBrowse:e.onBrowse,onSelect:t=>{s.current=!0,e.onSelect(t)},onCancel:()=>{s.current=!1,o(!1),i()}})]})]})}function xW(e){let t=(Date.now()-new Date(e).getTime())/1e3;return t<90?`now`:t<3600?`${Math.round(t/60)}m ago`:t<86400?`${Math.round(t/3600)}h ago`:`${Math.round(t/86400)}d ago`}function SW(e){return e.slice(e.lastIndexOf(`/`)+1)}function CW({status:e,selected:t,log:n,onFetchLog:r,onCloseLog:i,onShowCommit:a}){let[o,s]=(0,v.useState)(!1),c=()=>{s(!1),i()},l=oH(()=>{o&&c()}),u=e?.repos??[],d=(t===null?null:NV(u,t))??(t===null&&u.length===1?u[0]:null),f=d&&(d.ahead>0||d.behind>0)?` ${d.ahead>0?`↑${d.ahead}`:``}${d.behind>0?`↓${d.behind}`:``}`:``,p=u.length>1&&d!==null&&d.repo!==``?`${SW(d.repo)} `:``,m=e===null?`…`:d?.branch??`—`,h=d!==null&&n?.repo===d.repo?n:null,g=h?.entries??null,_=h?.error??null,y=(0,v.useMemo)(()=>g===null?null:ZU(g),[g]);return(0,v.useEffect)(()=>{o&&d!==null&&n?.repo!==d.repo&&r(d.repo)},[o,d?.repo,r]),(0,N.jsxs)(`div`,{className:`relative min-w-[4rem] max-w-[14rem] shrink-[2]`,ref:l,children:[(0,N.jsxs)(`button`,{type:`button`,disabled:d===null,onClick:()=>{if(d!==null){if(o)return c();s(!0),r(d.repo)}},title:d===null?`no repository selected`:`git history — ${d.repo===``?`this project`:d.repo}`,className:`${dW} max-w-full border-zinc-300 font-mono text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 disabled:cursor-default disabled:hover:border-zinc-300 disabled:hover:text-zinc-500 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200 dark:disabled:hover:border-zinc-800 dark:disabled:hover:text-zinc-400`,children:[(0,N.jsxs)(`span`,{className:`truncate`,children:[p,`⎇ `,m]}),f]}),o&&d!==null&&(0,N.jsxs)(`div`,{className:`absolute left-0 top-full z-20 mt-1 max-h-96 w-[26rem] max-w-[80vw] overflow-y-auto rounded-lg border border-zinc-200 bg-white py-1 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[_!==null&&(0,N.jsxs)(`div`,{role:`alert`,className:`px-3 py-2 text-xs text-red-600 dark:text-red-400`,children:[`history unavailable: `,_]}),g===null&&_===null&&(0,N.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),g?.length===0&&(0,N.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no commits`}),y?.rows.map(e=>{let{entry:t}=e;return(0,N.jsxs)(`button`,{type:`button`,onClick:()=>{a(d.repo,t.sha),c()},style:{height:36},className:`flex w-full items-center gap-2 pl-2 pr-3 text-left text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:[(0,N.jsx)(YU,{row:e,laneCount:y.laneCount}),(0,N.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:t.sha.slice(0,7)}),t.refs.map(t=>{let n=t===d.branch?`#10b981`:GU(e.lane);return(0,N.jsx)(`span`,{style:{borderColor:n,color:n},className:`max-w-[8rem] shrink-0 truncate rounded-full border px-1.5 font-mono text-[10px] leading-4 ${t===d.branch?`font-semibold`:``}`,children:t},t)}),t.tags.map(e=>(0,N.jsxs)(`span`,{title:`tag ${e}`,className:`max-w-[8rem] shrink-0 truncate rounded border border-zinc-300 px-1 font-mono text-[10px] leading-4 text-zinc-500 dark:border-zinc-600 dark:text-zinc-400`,children:[`◆ `,e]},`tag-${e}`)),(0,N.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-zinc-700 dark:text-zinc-300`,title:t.subject,children:t.subject}),(0,N.jsxs)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:[t.author,` · `,xW(t.date)]})]},t.sha)})]})]})}var wW=[{name:`draw.io / diagrams.net`,website:`https://www.drawio.com/`,license:`Apache-2.0`,text:` Apache License
|
|
869
869
|
Version 2.0, January 2004
|
|
@@ -1508,7 +1508,7 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
1508
1508
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1509
1509
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1510
1510
|
SOFTWARE.
|
|
1511
|
-
`,EW=[[`draw.io / diagrams.net`,`Diagram viewer and editor`],[`GrapesJS`,`Poster editor`],[`React`,`User interface`],[`CodeMirror · xterm.js · node-pty`,`Code editor and terminal`],[`PDF.js · docx`,`Document tools`],[`Mermaid · KaTeX`,`Diagrams and mathematical notation`]],DW=[{name:`pi-outpost`,license:`MIT`,text:TW},...wW];function OW(){let[e,t]=(0,v.useState)(!1),n=(0,v.useRef)(null);return(0,v.useLayoutEffect)(()=>{n.current?.focus({preventScroll:!0});let e=n.current?.closest(`.overflow-y-auto`);e&&(e.scrollTop=0)},[e]),e?(0,N.jsxs)(`div`,{className:`text-zinc-700 dark:text-zinc-300`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>t(!1),className:`mb-3 text-xs text-zinc-500 hover:underline dark:text-zinc-400`,children:`← Back to credits`}),(0,N.jsx)(`h3`,{ref:n,tabIndex:-1,className:`text-sm font-semibold outline-none`,children:`Third-party notices`}),(0,N.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500 dark:text-zinc-400`,children:`License texts and attributions for pi-outpost and the components acknowledged here.`}),DW.map(e=>(0,N.jsxs)(`section`,{className:`mt-5 border-t border-zinc-200 pt-3 dark:border-zinc-700`,children:[(0,N.jsxs)(`h4`,{className:`text-sm font-semibold`,children:[e.name,` `,(0,N.jsxs)(`span`,{className:`font-normal text-zinc-500 dark:text-zinc-400`,children:[`· `,e.license]})]}),(0,N.jsx)(`pre`,{className:`mt-2 whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed`,children:e.text})]},e.name))]}):(0,N.jsxs)(`div`,{className:`text-sm text-zinc-700 dark:text-zinc-300`,children:[(0,N.jsxs)(`section`,{className:`pb-5`,children:[(0,N.jsx)(`h3`,{ref:n,tabIndex:-1,className:`text-xl font-semibold tracking-tight outline-none`,children:`pi-outpost`}),(0,N.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500 dark:text-zinc-400`,children:`Created by Laurent Francoise · MIT license`}),(0,N.jsxs)(`a`,{className:`mt-3 inline-flex items-center gap-2 text-xs underline underline-offset-4`,href:`https://laurentftech.github.io/pi-outpost/`,target:`_blank`,rel:`noopener noreferrer`,children:[`Project website `,(0,N.jsx)(`span`,{"aria-hidden":`true`,children:`↗`})]})]}),(0,N.jsxs)(`section`,{className:`border-t border-zinc-200 pt-4 dark:border-zinc-700`,children:[(0,N.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Open-source acknowledgements`}),(0,N.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500 dark:text-zinc-400`,children:`Thanks to the authors and contributors of these projects.`}),(0,N.jsx)(`dl`,{className:`mt-3 space-y-3`,children:EW.map(([e,t])=>(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{className:`text-xs font-medium`,children:e}),(0,N.jsx)(`dd`,{className:`mt-0.5 text-xs text-zinc-500 dark:text-zinc-400`,children:t})]},e))}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>t(!0),className:`mt-4 flex w-full items-center justify-between rounded-md border border-zinc-300 px-3 py-2 text-xs hover:bg-zinc-100 dark:border-zinc-700 dark:hover:bg-zinc-800`,children:[`Third-party notices `,(0,N.jsx)(`span`,{"aria-hidden":`true`,children:`→`})]})]})]})}function kW(e){if(e.removed)return`removed — still running until pi-outpost restarts`;if(e.installed===void 0)return`not installed`;if(e.restartNeeded)return`${e.installed} installed — restart to use it`;if(e.pinned!==void 0)return`${e.installed}, pinned`;let t=e.check;if(!t)return e.installed;switch(t.state){case`checking`:return`${e.installed}, checking…`;case`newer`:return`${e.installed} — ${t.latest} available`;case`current`:return`${e.installed}, up to date`;case`failed`:return`${e.installed}, not checked: ${t.reason}`;case`off`:return`${e.installed}, not checked: ${t.reason}`}}function AW(e){let t=e.trim().replace(/^npm:/,``),n=t.lastIndexOf(`@`);return n>0?{name:t.slice(0,n),version:t.slice(n+1)}:{name:t}}var jW=e=>`${e.scope}:${e.name}`,MW=(e,t)=>e===`user`?`all projects`:`the ${t} project`,NW=`w-16 shrink-0 rounded border border-zinc-300 px-1.5 py-0.5 text-zinc-700 hover:bg-zinc-100 disabled:opacity-50 dark:border-zinc-600 dark:text-zinc-200 dark:hover:bg-zinc-700`,PW=`w-16 shrink-0 rounded border border-transparent px-1.5 py-0.5 text-zinc-600 hover:bg-zinc-100 hover:text-red-700 disabled:opacity-50 dark:text-zinc-300 dark:hover:bg-zinc-700 dark:hover:text-red-400`,FW=`mt-1 rounded border border-amber-300 bg-amber-50 p-2 text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200`,IW=`rounded bg-amber-600 px-2 py-0.5 text-white hover:bg-amber-700`,LW=`rounded px-2 py-0.5 hover:bg-amber-100 dark:hover:bg-amber-900/40`,RW=()=>(0,N.jsx)(`span`,{"aria-hidden":`true`,className:`${NW} invisible`,children:`Update`});function zW({packages:e,update:t,locked:n,onCheck:r,onUpdate:i,edits:a}){let[o,s]=(0,v.useState)(null);if(e===null||e.length===0&&!a)return null;let c=t?.status===`pending`?t.source:null,l=a?.change??null,u=l?.status===`pending`?l:null,d=c!==null||u!==null||a?.lookup?.status===`pending`,f=!n&&a!==void 0;function p(e){if(c===e.source&&e.check?.state===`newer`)return{text:`updating to ${e.check.latest}…`,warn:!1};if(u&&u.key===jW(e)){if(u.action===`remove`)return{text:`removing…`,warn:!1};if(u.action===`restore`)return{text:`reinstalling ${e.loaded??``}…`,warn:!1}}return t&&t.status!==`pending`&&t.status!==`installed`&&t.source===e.source?{text:t.message,warn:!0}:l&&(l.status===`failed`||l.status===`refused`)&&l.key===jW(e)&&l.action!==`install`?{text:l.message,warn:!0}:{text:kW(e),warn:!1}}return(0,N.jsxs)(`div`,{className:`mt-3 text-xs`,"data-testid":`pi-packages`,children:[(0,N.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,N.jsx)(`span`,{className:`font-medium text-zinc-600 dark:text-zinc-400`,children:`Packages`}),e.length>0&&(0,N.jsx)(`button`,{type:`button`,onClick:r,className:`text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200`,children:`check for updates`})]}),e.length===0&&(0,N.jsx)(`p`,{className:`text-zinc-500 dark:text-zinc-400`,"data-testid":`pi-packages-empty`,children:`No packages installed`}),(0,N.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>{let t=jW(e),r=e.check?.state===`newer`&&!e.restartNeeded&&!e.removed?e.check.latest:void 0,c=o?.key===t?o.kind:null,{text:l,warn:u}=p(e);return(0,N.jsxs)(`li`,{"data-testid":`pi-package`,className:`rounded bg-zinc-50 px-2 py-1 dark:bg-zinc-800`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,N.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium ${e.removed?`text-zinc-400 line-through dark:text-zinc-500`:`text-zinc-700 dark:text-zinc-200`}`,title:e.source,children:e.name}),!n&&(r?(0,N.jsx)(`button`,{type:`button`,disabled:d||c!==null,onClick:()=>s({kind:`update`,key:t}),className:NW,children:`Update`}):(0,N.jsx)(RW,{})),f&&(e.removed?(0,N.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>a.onRestore(e),className:NW,title:`Put ${e.name} back as it was`,children:`Undo`}):(0,N.jsx)(`button`,{type:`button`,disabled:d||c!==null,onClick:()=>s({kind:`remove`,key:t}),className:PW,"aria-label":`Remove ${e.name}`,children:`Remove`}))]}),(0,N.jsxs)(`div`,{className:`truncate ${u?`text-amber-700 dark:text-amber-400`:`text-zinc-500 dark:text-zinc-400`}`,title:l,children:[e.scope===`project`&&(0,N.jsx)(`span`,{children:`this project · `}),(0,N.jsx)(`span`,{"data-testid":`pi-package-status`,children:l})]}),r&&c===`update`&&(0,N.jsxs)(`div`,{className:FW,"data-testid":`pi-package-confirm`,children:[(0,N.jsxs)(`p`,{children:[`This replaces code that runs with the agent's privileges: `,e.name,` `,e.installed,` → `,r,`. It takes effect when pi-outpost restarts.`]}),(0,N.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>{s(null),i(e.source)},className:IW,children:[`Install `,r]}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>s(null),className:LW,children:`Cancel`})]})]}),a&&c===`remove`&&(0,N.jsxs)(`div`,{className:FW,"data-testid":`pi-package-confirm`,children:[(0,N.jsxs)(`p`,{children:[`Removes `,e.name,` from `,e.scope===`user`?`the agent's settings (all projects)`:`the ${a.projectName} project's settings`,` `,`and uninstalls it. The agent keeps running it until pi-outpost restarts.`]}),(0,N.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>{s(null),a.onRemove(e)},className:IW,children:`Remove`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>s(null),className:LW,children:`Cancel`})]})]})]},`${t}:${e.source}`)})}),f&&(0,N.jsx)(BW,{edits:a,busy:d},a.projectName)]})}function BW({edits:e,busy:t}){let[n,r]=(0,v.useState)(!1),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(`user`),c=(0,v.useRef)(null),{lookup:l,change:u}=e,d=u?.status===`pending`&&u.action===`install`?u:null,f=u&&u.action===`install`&&(u.status===`failed`||u.status===`refused`)?u.message:null,p=AW(i),m=l&&l.name===p.name&&l.version===p.version&&l.scope===o?l:null;(0,v.useEffect)(()=>{u?.action===`install`&&u.status===`installed`&&(r(!1),a(``),s(`user`))},[u]),(0,v.useEffect)(()=>{n&&m?.status!==`found`&&c.current?.focus()},[n,m?.status]);let h=()=>{r(!1),a(``),s(`user`),e.onCloseLookup()};if(d)return(0,N.jsxs)(`p`,{className:`mt-1 text-zinc-500 dark:text-zinc-400`,role:`status`,children:[`installing `,d.key.slice(d.key.indexOf(`:`)+1),`…`]});if(!n)return(0,N.jsxs)(N.Fragment,{children:[f&&(0,N.jsx)(`p`,{className:`mt-1 text-amber-700 dark:text-amber-400`,role:`alert`,children:f}),(0,N.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>r(!0),className:`mt-1 text-zinc-500 underline hover:text-zinc-800 disabled:opacity-50 dark:hover:text-zinc-200`,children:`Add a package`})]});if(m?.status===`found`)return(0,N.jsxs)(`div`,{className:FW,"data-testid":`pi-package-add-confirm`,children:[(0,N.jsxs)(`p`,{children:[`This installs code that runs with the agent's privileges: `,m.name,` `,m.resolved,m.version===void 0?``:` (pinned)`,`, for `,MW(m.scope,e.projectName),`. It takes effect when pi-outpost restarts.`]}),(0,N.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,N.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>e.onInstall(m.name,m.version,m.scope,m.resolved),className:IW,children:[`Install `,m.name]}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>e.onCloseLookup(),className:LW,children:`Cancel`})]})]});let g=m?m.status===`refused`?m.message:null:f;return(0,N.jsxs)(`form`,{className:`mt-1 rounded border border-zinc-200 p-2 dark:border-zinc-700`,onSubmit:n=>{n.preventDefault(),p.name&&!t&&e.onLookup(p.name,p.version,o)},onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),h())},children:[(0,N.jsx)(`label`,{className:`block text-zinc-600 dark:text-zinc-400`,htmlFor:`pi-package-name`,children:`npm package`}),(0,N.jsx)(`input`,{id:`pi-package-name`,ref:c,value:i,onChange:e=>a(e.target.value),disabled:m?.status===`pending`,autoComplete:`off`,spellCheck:!1,placeholder:`openlore, @scope/name or name@1.2.3`,className:`mt-0.5 w-full rounded border border-zinc-300 bg-white px-2 py-1 text-xs outline-none focus:ring-1 focus:ring-blue-400 dark:border-zinc-600 dark:bg-zinc-800`}),(0,N.jsxs)(`fieldset`,{className:`mt-2 flex flex-wrap gap-x-3 text-zinc-600 dark:text-zinc-400`,children:[(0,N.jsx)(`legend`,{className:`sr-only`,children:`Install for`}),(0,N.jsxs)(`label`,{children:[(0,N.jsx)(`input`,{type:`radio`,name:`pi-package-scope`,checked:o===`user`,onChange:()=>s(`user`)}),` all projects`]}),(0,N.jsxs)(`label`,{children:[(0,N.jsx)(`input`,{type:`radio`,name:`pi-package-scope`,checked:o===`project`,onChange:()=>s(`project`)}),` this project only (`,e.projectName,`)`]})]}),(0,N.jsxs)(`div`,{className:`mt-2 flex justify-end gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:h,className:`rounded px-2 py-0.5 hover:bg-zinc-100 dark:hover:bg-zinc-700`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`submit`,disabled:t||!p.name,className:NW.replace(`w-16 `,``),children:`Install…`})]}),(0,N.jsx)(`p`,{className:`mt-1 min-h-[1rem] ${g?`text-amber-700 dark:text-amber-400`:`text-zinc-500 dark:text-zinc-400`}`,role:g?`alert`:`status`,children:g??(m?.status===`pending`?`looking up ${m.name}…`:``)})]})}function VW({reasons:e,canRestart:t,restarting:n,onRestart:r}){let[i,a]=(0,v.useState)(!1);return e.length===0?null:(0,N.jsxs)(`div`,{className:`mt-3 rounded border border-sky-200 bg-sky-50 p-2 text-xs text-sky-900 dark:border-sky-900 dark:bg-sky-950/40 dark:text-sky-200`,"data-testid":`restart-needed`,children:[(0,N.jsxs)(`p`,{children:[`Waiting on a restart to take effect: `,e.join(`, `),`.`]}),t?n?(0,N.jsx)(`p`,{className:`mt-1`,children:`Restarting pi-outpost…`}):i?(0,N.jsxs)(`div`,{className:`mt-1`,children:[(0,N.jsx)(`p`,{children:`pi-outpost stops and starts again in the same terminal. Every open window reconnects by itself, and conversations are kept.`}),(0,N.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>{a(!1),r()},className:`rounded bg-sky-700 px-2 py-0.5 text-white hover:bg-sky-800`,children:`Restart now`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>a(!1),className:`rounded px-2 py-0.5 hover:bg-sky-100 dark:hover:bg-sky-900/50`,children:`Cancel`})]})]}):(0,N.jsx)(`button`,{type:`button`,onClick:()=>a(!0),className:`mt-1 rounded border border-sky-300 px-2 py-0.5 hover:bg-sky-100 dark:border-sky-700 dark:hover:bg-sky-900/50`,children:`Restart pi-outpost`}):null]})}var HW=30,UW={display:`-webkit-box`,WebkitLineClamp:2,WebkitBoxOrient:`vertical`,overflow:`hidden`};function WW({skills:e,groups:t,enabled:n,onChange:r,disabled:i=!1,bound:a}){let[o,s]=(0,v.useState)(()=>e.length>40?new Set(e.filter(e=>n.has(e.relativePath)).map(e=>e.group)):new Set(t.map(e=>e.path))),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),f=c.trim().toLocaleLowerCase(),p=f!==``||u,m=e=>(!u||n.has(e.relativePath))&&(!f||`${e.name} ${e.relativePath} ${e.description??``}`.toLocaleLowerCase().includes(f)),h=new Map;for(let t of e)h.set(t.group,[...h.get(t.group)??[],t]);let g=e.filter(e=>n.has(e.relativePath)).length,_=p?e.filter(m).length:e.length,y=(e,t)=>{let i=new Set(n);for(let n of e)t?i.add(n.relativePath):i.delete(n.relativePath);r(i)},b=e=>{let t=new Set(n);t.has(e)?t.delete(e):t.add(e),r(t)},x=e=>s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,N.jsxs)(`section`,{className:`rounded-xl border border-zinc-200 p-4 dark:border-zinc-800`,"aria-label":`Collection skills`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,N.jsxs)(`h3`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:[`Skills `,(0,N.jsxs)(`span`,{className:`font-normal text-zinc-500`,children:[`· `,g,` of `,e.length,` on`]})]}),(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,disabled:i||g===e.length,onClick:()=>y(e,!0),className:`rounded-md border px-2.5 py-1 text-xs disabled:opacity-50`,children:`All on`}),(0,N.jsx)(`button`,{type:`button`,disabled:i||g===0,onClick:()=>y(e,!1),className:`rounded-md border px-2.5 py-1 text-xs disabled:opacity-50`,children:`All off`})]})]}),a?(0,N.jsx)(`p`,{className:`mt-2 rounded border border-amber-200 bg-amber-50 p-2 text-xs text-amber-800`,children:a.kind===`count`?`This repository holds more skills than the ${a.limit} listed here.`:`Folders deeper than ${a.limit} levels were not searched for skills.`}):null,e.length>0?(0,N.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`input`,{type:`search`,"aria-label":`Search skills`,placeholder:`Search skills by name or folder`,value:c,onChange:e=>l(e.target.value),className:`min-w-0 flex-1 rounded-md border bg-transparent px-2.5 py-1 text-xs`}),(0,N.jsxs)(`button`,{type:`button`,"aria-pressed":u,onClick:()=>d(e=>!e),className:`rounded-md px-2.5 py-1 text-xs ${u?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:[`Only on (`,g,`)`]})]}):null,!p&&g>0&&g<=HW?(0,N.jsxs)(`div`,{role:`region`,"aria-label":`Skills that are on`,className:`mt-3 rounded-lg border border-emerald-200 bg-emerald-50/60 p-2 dark:border-emerald-900 dark:bg-emerald-950/30`,children:[(0,N.jsx)(`p`,{className:`px-1 text-[11px] font-medium text-emerald-800 dark:text-emerald-300`,children:`Turned on`}),(0,N.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.filter(e=>n.has(e.relativePath)).map(e=>(0,N.jsxs)(`li`,{className:`flex items-start justify-between gap-2 px-1`,children:[(0,N.jsxs)(`span`,{className:`min-w-0 text-xs`,children:[(0,N.jsx)(`span`,{className:`font-medium text-zinc-800 dark:text-zinc-100`,children:e.name}),` `,(0,N.jsx)(`span`,{className:`font-mono text-[11px] text-zinc-500`,children:e.group||`(repository root)`}),(0,N.jsx)(GW,{skill:e,checked:!0})]}),(0,N.jsx)(`button`,{type:`button`,"aria-label":`Turn off ${e.name} (${e.relativePath})`,disabled:i,onClick:()=>b(e.relativePath),className:`shrink-0 rounded border bg-white px-2 py-0.5 text-[11px] disabled:opacity-50 dark:bg-zinc-900`,children:`Turn off`})]},e.relativePath))})]}):null,e.length===0?(0,N.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:`This repository holds no skills.`}):null,p&&_===0?(0,N.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:u&&!f?`No skill is on.`:`No skill matches.`}):null,(0,N.jsx)(`ul`,{className:`mt-3 space-y-2`,children:t.map(e=>{let t=h.get(e.path)??[],r=p?t.filter(m):t;if(p&&r.length===0)return null;let a=r.filter(e=>n.has(e.relativePath)).length,s=p||o.has(e.path);return(0,N.jsxs)(`li`,{className:`rounded-lg border border-zinc-100 dark:border-zinc-800`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2`,children:[(0,N.jsxs)(`button`,{type:`button`,"aria-expanded":s,onClick:()=>x(e.path),className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,N.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs text-zinc-400`,children:s?`▾`:`▸`}),(0,N.jsx)(`span`,{className:`truncate font-mono text-xs font-medium text-zinc-700 dark:text-zinc-200`,children:e.label}),(0,N.jsxs)(`span`,{className:`shrink-0 text-[11px] text-zinc-500`,children:[a,`/`,r.length,` on`]})]}),(0,N.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,N.jsx)(`button`,{type:`button`,"aria-label":`All on in ${e.label}`,disabled:i||a===r.length,onClick:()=>y(r,!0),className:`rounded border px-2 py-0.5 text-[11px] disabled:opacity-50`,children:`All on`}),(0,N.jsx)(`button`,{type:`button`,"aria-label":`All off in ${e.label}`,disabled:i||a===0,onClick:()=>y(r,!1),className:`rounded border px-2 py-0.5 text-[11px] disabled:opacity-50`,children:`All off`})]})]}),s?(0,N.jsx)(`ul`,{className:`space-y-1 border-t border-zinc-100 px-3 py-2 dark:border-zinc-800`,children:r.map(e=>{let t=n.has(e.relativePath);return(0,N.jsx)(`li`,{children:(0,N.jsxs)(`label`,{className:`flex items-start gap-2 rounded px-1 py-1 ${i?`opacity-60`:`cursor-pointer hover:bg-zinc-50 dark:hover:bg-zinc-800/60`}`,children:[(0,N.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":t,"aria-label":`${e.name} (${e.relativePath})`,checked:t,disabled:i,onChange:()=>b(e.relativePath),className:`mt-0.5`}),(0,N.jsxs)(`span`,{className:`min-w-0`,children:[(0,N.jsx)(`span`,{className:`block truncate text-sm text-zinc-800 dark:text-zinc-100`,children:e.name}),e.description?(0,N.jsx)(`span`,{title:e.description,style:UW,className:`text-[11px] text-zinc-500`,children:e.description}):null,(0,N.jsx)(GW,{skill:e,checked:t})]})]})},e.relativePath)})}):null]},e.path)})})]})}function GW({skill:e,checked:t}){return t===(e.state!==`off`)?e.state===`on-loaded`?(0,N.jsx)(`span`,{className:`block text-[11px] text-emerald-700 dark:text-emerald-400`,children:`Loaded`}):e.state===`on-not-loaded`?(0,N.jsxs)(`span`,{className:`block text-[11px] text-amber-700 dark:text-amber-400`,children:[`Not loaded — `,e.reason]}):e.state===`on-missing`?(0,N.jsxs)(`span`,{className:`block text-[11px] text-rose-700 dark:text-rose-400`,children:[`Missing — `,e.reason]}):null:(0,N.jsx)(`span`,{className:`block text-[11px] font-medium text-sky-700 dark:text-sky-300`,children:t?`Pending: on`:`Pending: off`})}function KW(e,t){return[...new Set(e.map(e=>e.group))].sort().map(e=>({path:e,label:e||t}))}function qW(e){return e.skills.filter(e=>e.state!==`off`).map(e=>e.relativePath)}function JW(e,t){let n=new Set(e),r=new Set(t);return n.size===r.size&&[...n].every(e=>r.has(e))}function YW(e,t){if(t.status===`loading`)return`Removing ${e}…`;if(t.status===`error`)return t.message??`Could not remove ${e}`;let n=t.result;return n?n.status===`removed`?`Removed ${e} and deleted ${n.path}.`:n.status===`removed-files-kept`?`Removed ${e}. ${n.reason??`Its files were kept`} (${n.path}).`:`Removed ${e}, but not every file could be deleted${n.reason?` — ${n.reason}`:``}. What remains is at ${n.path}.`:`Removed ${e}.`}var XW={unchecked:`Not checked`,checking:`Checking…`,current:`Up to date`,updateable:`Update available`,dirty:`Local changes`,detached:`Detached HEAD`,ahead:`Local branch ahead`,diverged:`Histories diverged`,"no-upstream":`No upstream`,locked:`Locked`,busy:`Workspace busy`,unavailable:`Unavailable`,failed:`Check failed`};function ZW(e){if(!e)return[];let t=new Map(e.resources.map(e=>[e.id,e])),n=new Set(e.repositories.flatMap(e=>e.resourceIds)),r=e.repositories.map(e=>({id:e.id,name:e.name,path:e.path,repository:e,resources:e.resourceIds.flatMap(e=>t.get(e)?[t.get(e)]:[])})),i=e.resources.filter(e=>!n.has(e.id)),a=i.filter(e=>e.unavailableReason),o=i.filter(e=>!e.unavailableReason);return o.length&&r.push({id:`local`,name:`Local and built in`,reason:`Not backed by an updateable Git repository`,resources:o}),a.length&&r.push({id:`unavailable`,name:`Provenance unavailable`,reason:`The active runtime did not report enough filesystem provenance`,resources:a}),r}function QW(e){let t=e.length;for(;t>0&&(e[t-1]===`/`||e[t-1]===`\\`);)--t;return t===e.length?e:e.slice(0,t)}function $W(e){let t=QW(e),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n<=0?`/`:t.slice(0,n)}function eG(e,t){let n=QW(t),r=Math.max(n.lastIndexOf(`/`),n.lastIndexOf(`\\`)),i=r>=0?n.slice(r+1):n;return`${QW(e)}/${i||`agent-resources`}`}function tG({kind:e,resources:t,removalLocked:n=!1,onRemove:r}){return(0,N.jsxs)(`section`,{className:`rounded-xl border border-zinc-200 p-4 dark:border-zinc-800`,children:[(0,N.jsxs)(`h3`,{className:`flex items-center justify-between text-sm font-semibold capitalize text-zinc-800 dark:text-zinc-200`,children:[(0,N.jsxs)(`span`,{children:[e,`s`]}),(0,N.jsx)(`span`,{className:`text-xs font-normal text-zinc-400`,children:t.length})]}),t.length===0?(0,N.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:`None in this group`}):(0,N.jsx)(`ul`,{className:`mt-3 space-y-2`,children:t.map(e=>(0,N.jsxs)(`li`,{className:`rounded-lg bg-zinc-50 px-3 py-2 dark:bg-zinc-800/70`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,N.jsx)(`p`,{className:`truncate text-sm font-medium text-zinc-700 dark:text-zinc-200`,children:e.name}),e.userRoot&&!n?(0,N.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.userRoot}`,onClick:()=>r(e),className:`text-xs text-zinc-500 hover:text-red-600`,children:`Remove`}):null]}),(0,N.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[11px] text-zinc-400`,title:e.path,children:e.path??e.unavailableReason??`Path unavailable`})]},e.id))})]})}function nG({preview:e,busy:t,error:n,onApply:r,onCancel:i}){let[a,o]=(0,v.useState)(()=>new Set(e.roots.filter(e=>!e.locked).map(e=>`${e.kind}:${e.path}`))),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(()=>new Set),d=e.mode===`collection`,f=(0,v.useMemo)(()=>e.skills.map(e=>({...e,state:`off`})),[e.skills]),p=(0,v.useMemo)(()=>KW(e.skills,e.repositoryName),[e.skills,e.repositoryName]),m=e.roots.filter(e=>e.kind===`extension`&&a.has(`extension:${e.path}`)),h=m.length>0&&!s,g=t||!d&&a.size===0||h,_=()=>{let t=m.map(e=>e.path);d?r([],t,[...l]):r(e.roots.filter(e=>e.kind===`skill`&&a.has(`skill:${e.path}`)).map(e=>e.path),t)},y=e=>{c(!1),o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,N.jsxs)(`div`,{className:`space-y-3`,"data-testid":`resource-preview`,children:[(0,N.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsx)(`h3`,{className:`truncate text-xl font-semibold text-zinc-900 dark:text-zinc-100`,children:e.repositoryName}),(0,N.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[11px] text-zinc-500`,title:e.repositoryPath,children:e.repositoryPath})]}),(0,N.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:i,className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,disabled:g,onClick:_,className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs font-medium text-white disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-900`,children:t?`Saving…`:`Save`})]})]}),h?(0,N.jsx)(`p`,{className:`text-xs text-amber-700`,children:`Confirm the extension warning below to save.`}):null,n?(0,N.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:n}):null,d?(0,N.jsx)(WW,{skills:f,groups:p,enabled:l,onChange:u,disabled:t,...e.bound?{bound:e.bound}:{}}):null,e.roots.map(e=>{let t=`${e.kind}:${e.path}`;return(0,N.jsxs)(`label`,{className:`flex items-start gap-2 rounded border p-2 ${e.locked?`opacity-50`:`cursor-pointer`}`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:a.has(t),disabled:e.locked,onChange:()=>y(t)}),(0,N.jsxs)(`span`,{children:[(0,N.jsxs)(`span`,{className:`block text-sm`,children:[e.name,` · `,e.kind]}),(0,N.jsx)(`span`,{className:`font-mono text-[11px] text-zinc-500`,children:e.path}),e.locked?(0,N.jsx)(`span`,{className:`block text-xs text-amber-700`,children:`Extension paths are locked`}):null]})]},t)}),m.length>0?(0,N.jsxs)(`label`,{className:`flex gap-2 rounded-md border border-amber-300 bg-amber-50 p-3 text-xs text-amber-900`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked)}),(0,N.jsx)(`span`,{children:`Extensions execute code with the agent's privileges. I trust the selected extension roots in this repository.`})]}):null]})}function rG(e){let t=(0,v.useRef)(null),n=(0,v.useRef)(e.onClose),r=(0,v.useRef)(!1),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(`all`),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(`skill`),[y,b]=(0,v.useState)(``),[x,S]=(0,v.useState)(!1),[C,w]=(0,v.useState)(``),[T,E]=(0,v.useState)(``),[D,O]=(0,v.useState)(!1),[ee,te]=(0,v.useState)(``),[k,ne]=(0,v.useState)(null),[A,re]=(0,v.useState)({}),[j,ie]=(0,v.useState)(null),[ae,oe]=(0,v.useState)(null),se=(0,v.useMemo)(()=>ZW(e.inventory),[e.inventory]),ce=(0,v.useMemo)(()=>{let e=o.trim().toLocaleLowerCase();return se.flatMap(t=>{let n=`repository`in t?t.repository.collection:void 0,r=n?t.resources.filter(e=>e.kind!==`skill`):t.resources,i=c===`all`?r:r.filter(e=>e.kind===c),a=n&&c!==`extension`?n.skills:[],o=i.length+a.length;if(o===0&&!(n&&c===`all`)||u&&(!(`repository`in t)||![`updateable`,`dirty`,`failed`,`unavailable`,`busy`].includes(t.repository.assessment.status)))return[];let s=`${t.name} ${`path`in t?t.path??``:``} ${i.map(e=>`${e.name} ${e.path??``}`).join(` `)} ${a.map(e=>`${e.name} ${e.relativePath}`).join(` `)}`.toLocaleLowerCase(),l=n?n.skills.filter(e=>e.state!==`off`).length:void 0;return!e||s.includes(e)?[{...t,resources:i,count:o,...l===void 0?{}:{onCount:l}}]:[]})},[se,u,c,o]),le=ce.find(e=>e.id===i)??ce[0]??null;if((0,v.useEffect)(()=>{n.current=e.onClose},[e.onClose]),(0,v.useEffect)(()=>{re(t=>{let n={},r=!1;for(let[i,a]of Object.entries(t)){let t=e.inventory?.repositories.find(e=>e.id===i)?.collection;!t||JW(a,qW(t))?r=!0:n[i]=a}return r?n:t})},[e.inventory]),(0,v.useEffect)(()=>{e.open&&t.current?.focus()},[e.open]),(0,v.useEffect)(()=>{if(!e.open)return;let t=e=>{e.key===`Escape`&&n.current()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e.open]),(0,v.useEffect)(()=>{let t=e.operations.clonePath;t?.status===`ready`&&t.path&&!D&&E(t.path)},[D,e.operations.clonePath]),(0,v.useEffect)(()=>{e.operations.enrollment?.status===`ready`&&p(null)},[e.operations.enrollment]),(0,v.useEffect)(()=>{e.applyState?.status===`applying`?r.current=!0:r.current&&e.applyState===null&&(r.current=!1,p(null),h(null),S(!1))},[e.applyState]),!e.open)return null;let ue=le&&`repository`in le?le.repository:null,de=ue?e.operations.updates[ue.id]:void 0,fe=ue?.assessment,M=fe?.status===`updateable`&&fe.token&&fe.localRevision&&fe.upstreamRevision,pe=()=>{let t=y.trim();t&&(g===`skill`?e.onUpdateConfig({userSkillPaths:[...new Set([...e.userSkillPaths,t])]}):e.onUpdateConfig({userExtensionPaths:[...new Set([...e.userExtensionPaths,t])]}))},me=t=>{t.userRoot&&(t.kind===`skill`?e.onUpdateConfig({userSkillPaths:e.userSkillPaths.filter(e=>e!==t.userRoot)}):e.onUpdateConfig({userExtensionPaths:e.userExtensionPaths.filter(e=>e!==t.userRoot)}))},he=(t,n=!1)=>{let r=t.assessment;r.token&&r.localRevision&&r.upstreamRevision&&e.onUpdate(t.id,r.token,r.localRevision,r.upstreamRevision,n)},ge=ue?.collection,P=ge?qW(ge):[],_e=new Set(ue&&A[ue.id]?A[ue.id]:P),ve=ge?[...new Set([..._e,...P])].filter(e=>_e.has(e)!==P.includes(e)).length:0,ye=ue?e.operations.skills?.[ue.id]:void 0,be=e=>{if(!ue)return;let t=ue.id;re(n=>{let r={...n};return JW(e,P)?delete r[t]:r[t]=[...e],r})},xe=()=>{if(!ue)return;let e=ue.id;re(t=>{let n={...t};return delete n[e],n})},Se=()=>{if(!ue||!ge)return;let t=new Set(ge.skills.filter(e=>e.state!==`on-missing`).map(e=>e.relativePath));e.onSetSkills(ue.id,[..._e].filter(e=>t.has(e)))},Ce=ae?e.operations.removals?.[ae.id]:void 0,we=Ce?.status===`error`||Ce?.result?.status===`removed-delete-failed`;return(0,N.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/45 p-4`,role:`presentation`,onMouseDown:t=>{t.currentTarget===t.target&&e.onClose()},children:[(0,N.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`agent-resources-title`,className:`flex h-[min(760px,92vh)] w-[min(1120px,96vw)] flex-col overflow-hidden rounded-2xl border border-zinc-200 bg-white shadow-2xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,N.jsxs)(`header`,{className:`flex items-center justify-between border-b border-zinc-200 px-5 py-4 dark:border-zinc-800`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h2`,{id:`agent-resources-title`,className:`text-lg font-semibold text-zinc-900 dark:text-zinc-100`,children:`Agent resources`}),(0,N.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Skills and extensions, grouped by repository`})]}),(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,disabled:e.operations.refresh?.status===`loading`,onClick:()=>e.onRefresh(),className:`rounded-md border px-3 py-1.5 text-xs disabled:opacity-50`,children:`Refresh all`}),(0,N.jsx)(`button`,{ref:t,type:`button`,"aria-label":`Close agent resources`,onClick:e.onClose,className:`rounded-md border px-2 py-1 text-sm`,children:`✕`})]})]}),(0,N.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[300px_1fr]`,children:[(0,N.jsxs)(`aside`,{className:`flex min-h-0 flex-col border-r border-zinc-200 bg-zinc-50/80 p-3 dark:border-zinc-800 dark:bg-zinc-950/40`,children:[(0,N.jsx)(`input`,{"aria-label":`Search resources`,value:o,onChange:e=>s(e.target.value),placeholder:`Search repositories or resources`,className:`rounded-md border bg-white px-3 py-2 text-xs dark:bg-zinc-900`}),(0,N.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[[`all`,`skill`,`extension`].map(e=>(0,N.jsx)(`button`,{type:`button`,"aria-pressed":c===e,onClick:()=>l(e),className:`rounded px-2 py-1 text-[11px] ${c===e?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:e===`all`?`All`:`${e}s`},e)),(0,N.jsx)(`button`,{type:`button`,"aria-pressed":u,onClick:()=>d(e=>!e),className:`rounded px-2 py-1 text-[11px] ${u?`bg-amber-600 text-white`:`border`}`,children:`Needs attention`})]}),(0,N.jsxs)(`div`,{className:`mt-3 min-h-0 flex-1 space-y-1 overflow-y-auto`,children:[ce.map(e=>(0,N.jsxs)(`button`,{type:`button`,onClick:()=>a(e.id),className:`w-full rounded-lg px-3 py-2.5 text-left ${le?.id===e.id?`bg-white shadow-sm ring-1 ring-zinc-200 dark:bg-zinc-800 dark:ring-zinc-700`:`hover:bg-white/70 dark:hover:bg-zinc-900`}`,children:[(0,N.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-sm font-medium`,children:[(0,N.jsx)(`span`,{className:`truncate`,children:e.name}),(0,N.jsx)(`span`,{className:`shrink-0 text-xs text-zinc-400`,children:e.onCount===void 0?e.count??e.resources.length:`${e.onCount} on · ${e.count}`})]}),(0,N.jsx)(`span`,{className:`mt-1 block text-xs text-zinc-500`,children:`repository`in e?XW[e.repository.assessment.status]:e.reason})]},e.id)),ce.length===0?(0,N.jsx)(`p`,{className:`px-2 py-4 text-xs text-zinc-500`,children:`No matching resources`}):null]}),(0,N.jsxs)(`div`,{className:`mt-3 grid gap-2 border-t pt-3`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>{S(!1),p(`local`),h(`local`),e.onBrowseServerPath(y||`/`)},className:`rounded-md border bg-white px-3 py-2 text-xs font-medium dark:bg-zinc-900`,children:`Add local folder…`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>p(`git`),className:`rounded-md bg-zinc-900 px-3 py-2 text-xs font-medium text-white dark:bg-zinc-100 dark:text-zinc-900`,children:`Add Git repository…`})]})]}),(0,N.jsxs)(`main`,{className:`min-w-0 overflow-y-auto p-6`,children:[ae&&Ce?(0,N.jsxs)(`div`,{role:we?`alert`:`status`,className:`mb-4 flex items-start justify-between gap-3 rounded-lg border p-3 text-sm ${we?`border-rose-200 bg-rose-50 text-rose-800`:`border-zinc-200 bg-zinc-50 text-zinc-700`}`,children:[(0,N.jsx)(`p`,{className:`min-w-0 break-words`,children:YW(ae.name,Ce)}),Ce.status===`loading`?null:(0,N.jsx)(`button`,{type:`button`,onClick:()=>oe(null),className:`shrink-0 text-xs underline`,children:`Dismiss`})]}):null,f===`local`?(0,N.jsxs)(`div`,{className:`max-w-xl space-y-4`,"data-testid":`add-local-folder`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Add local folder`}),(0,N.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Choose an existing folder on the server and how the agent should load it.`})]}),(0,N.jsx)(`div`,{className:`flex gap-2`,children:[`skill`,`extension`].map(t=>(0,N.jsx)(`button`,{type:`button`,"aria-pressed":g===t,disabled:t===`extension`&&e.extensionLock,onClick:()=>{_(t),S(!1)},className:`rounded-md px-3 py-1.5 text-xs ${g===t?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:t===`skill`?`Skill folder`:`Extension folder`},t))}),(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsx)(`input`,{"aria-label":`Local resource folder`,value:y,onChange:e=>{S(!1),b(e.target.value)},className:`min-w-0 flex-1 rounded-md border bg-transparent px-3 py-2 text-sm`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>{h(`local`),e.onBrowseServerPath(y||`/`)},className:`rounded-md border px-3 text-xs`,children:`Browse…`})]}),m===`local`?(0,N.jsx)(vW,{label:`Choose a local resource folder`,browse:e.serverBrowse,onBrowse:e.onBrowseServerPath,onSelect:t=>{S(!1),b(t),h(null),e.onCloseServerBrowser()},onCancel:()=>{h(null),e.onCloseServerBrowser()}}):null,g===`extension`?(0,N.jsxs)(`label`,{className:`flex gap-2 rounded-md border border-amber-300 bg-amber-50 p-3 text-xs text-amber-900`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked)}),(0,N.jsx)(`span`,{children:`Extensions execute code with the agent's privileges. I trust every extension in this folder.`})]}):null,e.extensionLock?(0,N.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Extension paths are locked by this deployment.`}):null,e.applyState?.status===`error`?(0,N.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.applyState.message}):null,(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>{S(!1),p(null),h(null),e.onCloseServerBrowser()},className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,disabled:!y.trim()||e.applyState?.status===`applying`||g===`extension`&&(!x||e.extensionLock),onClick:pe,className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:e.applyState?.status===`applying`?`Applying…`:`Add folder`})]})]}):f===`git`?(0,N.jsx)(`div`,{className:`max-w-2xl space-y-4`,"data-testid":`add-git-repository`,children:e.operations.preview?.status===`ready`&&e.operations.preview.preview?(0,N.jsx)(nG,{onCancel:()=>{p(null),h(null),e.onCloseServerBrowser()},preview:e.operations.preview.preview,busy:e.operations.enrollment?.status===`loading`,error:e.operations.enrollment?.status===`error`?e.operations.enrollment.message:void 0,onApply:(t,n,r)=>r?e.onEnrollRepository(e.operations.preview.preview.token,t,n,r):e.onEnrollRepository(e.operations.preview.preview.token,t,n)}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Add Git repository`}),(0,N.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Clone it to a local folder, then choose what to turn on.`})]}),(0,N.jsxs)(`label`,{className:`block`,children:[(0,N.jsx)(`span`,{className:`text-xs font-medium`,children:`Repository address`}),(0,N.jsx)(`input`,{"aria-label":`Repository address`,value:C,onChange:e=>w(e.target.value),onBlur:()=>{let t=C.trim();t&&(O(!1),te(t),e.onSuggestClonePath(C))},placeholder:`https://github.com/team/resources.git`,className:`mt-1 w-full rounded-md border bg-transparent px-3 py-2 text-sm`})]}),(0,N.jsxs)(`label`,{className:`block`,children:[(0,N.jsx)(`span`,{className:`text-xs font-medium`,children:`Local folder`}),(0,N.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,N.jsx)(`input`,{"aria-label":`Local clone folder`,value:T,onChange:e=>{O(!0),E(e.target.value)},placeholder:`/path/to/resource-repositories/team-resources-ab12cd`,className:`min-w-0 flex-1 rounded-md border bg-transparent px-3 py-2 text-sm`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>{h(`clone-parent`),e.onBrowseServerPath($W(T))},className:`rounded-md border px-3 text-xs`,children:`Choose parent…`})]})]}),e.operations.clonePath?.status===`loading`?(0,N.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Suggesting a managed folder…`}):null,e.operations.clonePath?.status===`error`&&C.trim()===ee?(0,N.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.operations.clonePath.message}):null,m===`clone-parent`?(0,N.jsx)(vW,{label:`Choose the clone's parent folder`,browse:e.serverBrowse,onBrowse:e.onBrowseServerPath,onSelect:t=>{E(eG(t,T)),h(null),e.onCloseServerBrowser()},onCancel:()=>{h(null),e.onCloseServerBrowser()}}):null,e.operations.preview?.status===`error`?(0,N.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.operations.preview.message}):null,(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>{p(null),h(null),e.onCloseServerBrowser()},className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,disabled:!C.trim()||!T.trim()||e.operations.preview?.status===`loading`,onClick:()=>e.onCloneRepository(C,T),className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:e.operations.preview?.status===`loading`?`Cloning…`:`Clone and inspect`})]})]})}):le?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`h3`,{className:`text-xl font-semibold`,children:le.name}),ue?(0,N.jsx)(`span`,{className:`rounded-full border px-2 py-0.5 text-[11px]`,children:XW[ue.assessment.status]}):null]}),(0,N.jsx)(`p`,{className:`mt-1 truncate font-mono text-xs text-zinc-500`,children:`repository`in le?le.path:le.reason}),fe?.branch?(0,N.jsxs)(`p`,{className:`mt-1 text-xs text-zinc-400`,children:[fe.branch,fe.upstream?` → ${fe.upstream}`:``]}):null,ue?.removal&&!ue.removal.allowed?(0,N.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:ue.removal.reason}):null]}),ue?(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[ue.removal?.allowed?(0,N.jsx)(`button`,{type:`button`,disabled:e.operations.removals?.[ue.id]?.status===`loading`,onClick:()=>ie(ue),className:`rounded-md border border-red-200 px-3 py-1.5 text-xs text-red-700 disabled:opacity-50 dark:border-red-900 dark:text-red-400`,children:`Remove repository`}):null,(0,N.jsx)(`button`,{type:`button`,disabled:e.operations.refresh?.status===`loading`,onClick:()=>e.onRefresh(ue.id),className:`rounded-md border px-3 py-1.5 text-xs`,children:`Check`}),M||de?.status===`loading`?(0,N.jsx)(`button`,{type:`button`,disabled:de?.status===`loading`,onClick:()=>ue.containsExtensions?ne(ue):he(ue),className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:de?.status===`loading`?`Updating…`:`Update repository`}):null]}):null]}),fe?.reason?(0,N.jsxs)(`div`,{className:`mt-5 rounded-lg border p-3 text-sm ${fe.status===`dirty`?`border-rose-200 bg-rose-50 text-rose-800`:`border-zinc-200 bg-zinc-50 text-zinc-700`}`,children:[fe.reason,fe.status===`dirty`?(0,N.jsx)(`p`,{className:`mt-1 text-xs`,children:`Review and resolve these local changes in an external terminal, then check again. This updater never commits, stashes, discards, rebases, or merges them.`}):null]}):null,fe?.hasSubmodules?(0,N.jsx)(`p`,{className:`mt-3 rounded border border-amber-200 bg-amber-50 p-2 text-xs text-amber-800`,children:`This repository declares submodules. Their working trees will not be initialized or updated.`}):null,de?.status===`ready`?(0,N.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-zinc-600`,children:de.result?.status===`updated`&&de.result.reloads.some(e=>e.status===`restart-required`)?`Repository updated. Its skills are reloaded; its extension code runs after pi-outpost restarts — restart it from Settings.`:de.result?.status===`updated`?`Repository updated and runtimes reloaded.`:de.result?.status===`updated-reload-failed`?`Repository updated on disk, but at least one runtime failed to reload.`:de.result?.reason}):null,de?.status===`error`?(0,N.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-red-600`,children:de.message}):null,ge&&ue&&c!==`extension`?(0,N.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[ve>0||ye?.status===`loading`?(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-sky-200 bg-sky-50 px-3 py-2 text-xs text-sky-900 dark:border-sky-900 dark:bg-sky-950/40 dark:text-sky-200`,children:[(0,N.jsx)(`span`,{children:ye?.status===`loading`?`Applying…`:`${ve} pending change${ve===1?``:`s`} — applying replaces the session`}),(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,disabled:ye?.status===`loading`,onClick:xe,className:`rounded border bg-white px-2.5 py-1 disabled:opacity-50 dark:bg-zinc-900`,children:`Discard`}),(0,N.jsx)(`button`,{type:`button`,disabled:ye?.status===`loading`||ve===0,onClick:Se,className:`rounded bg-zinc-900 px-2.5 py-1 font-medium text-white disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-900`,children:`Apply`})]})]}):null,ye?.status===`error`?(0,N.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:ye.message}):null,(0,N.jsx)(WW,{skills:ge.skills,groups:ge.groups,enabled:_e,onChange:be,disabled:ye?.status===`loading`,...ge.bound?{bound:ge.bound}:{}},ue.id),le.resources.some(e=>e.kind===`extension`)?(0,N.jsx)(tG,{kind:`extension`,resources:le.resources.filter(e=>e.kind===`extension`),removalLocked:e.extensionLock,onRemove:me}):null]}):(0,N.jsxs)(`div`,{className:`mt-6 grid grid-cols-2 gap-4`,children:[(0,N.jsx)(tG,{kind:`skill`,resources:le.resources.filter(e=>e.kind===`skill`),onRemove:me}),(0,N.jsx)(tG,{kind:`extension`,resources:le.resources.filter(e=>e.kind===`extension`),removalLocked:e.extensionLock,onRemove:me})]})]}):(0,N.jsx)(`p`,{className:`text-sm text-zinc-500`,children:`No resources are reported by this runtime.`})]})]})]}),k?(0,N.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/55 p-4`,children:(0,N.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`extension-update-title`,className:`w-full max-w-md rounded-xl bg-white p-5 shadow-2xl dark:bg-zinc-900`,children:[(0,N.jsx)(`h3`,{id:`extension-update-title`,className:`font-semibold`,children:`Update executable extensions?`}),(0,N.jsxs)(`p`,{className:`mt-2 text-sm text-zinc-600 dark:text-zinc-300`,children:[k.name,` contains extensions that run with the agent's privileges. Confirm updating `,k.assessment.localRevision?.slice(0,8),` to `,k.assessment.upstreamRevision?.slice(0,8),`.`]}),(0,N.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>ne(null),className:`rounded border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>{he(k,!0),ne(null)},className:`rounded bg-amber-600 px-3 py-1.5 text-xs font-medium text-white`,children:`Confirm executable update`})]})]})}):null,j?(0,N.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/55 p-4`,children:(0,N.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`remove-repository-title`,"aria-describedby":`remove-repository-detail`,className:`w-full max-w-md rounded-xl bg-white p-5 shadow-2xl dark:bg-zinc-900`,children:[(0,N.jsxs)(`h3`,{id:`remove-repository-title`,className:`font-semibold`,children:[`Remove `,j.name,`?`]}),(0,N.jsx)(`p`,{id:`remove-repository-detail`,className:`mt-2 break-words text-sm text-zinc-600 dark:text-zinc-300`,children:j.removal?.deletesFiles?(0,N.jsxs)(N.Fragment,{children:[`This stops loading everything from `,j.name,` and deletes `,(0,N.jsx)(`span`,{className:`font-mono`,children:j.removal.path}),` from disk, with any local changes in it. This cannot be undone.`]}):(0,N.jsxs)(N.Fragment,{children:[`This stops loading everything from `,j.name,`. pi-outpost does not manage `,(0,N.jsx)(`span`,{className:`font-mono`,children:j.removal?.path??j.path}),`, so its files will be kept.`]})}),(0,N.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>ie(null),className:`rounded border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>{e.onRemoveRepository(j.id),oe({id:j.id,name:j.name}),ie(null)},className:`rounded bg-red-600 px-3 py-1.5 text-xs font-medium text-white`,children:j.removal?.deletesFiles?`Delete and remove`:`Remove repository`})]})]})}):null]})}var iG=`w-full rounded-md border border-zinc-300 bg-white px-3 py-2 text-sm text-zinc-800 placeholder:text-zinc-400 focus:border-zinc-400 focus:outline-none dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-100 dark:placeholder:text-zinc-600`,aG=`rounded-md border border-zinc-300 px-3 py-1.5 text-xs font-medium text-zinc-700 hover:bg-zinc-50 disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-800`;function oG({event:e}){switch(e.type){case`auth_url`:return(0,N.jsxs)(`div`,{"data-testid":`login-auth-url`,className:`space-y-1`,children:[(0,N.jsx)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:e.instructions??`Open this page to sign in:`}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`truncate text-sm text-sky-700 underline dark:text-sky-400`,children:e.url}),(0,N.jsx)(`button`,{type:`button`,className:aG,onClick:()=>void navigator.clipboard?.writeText(e.url),children:`Copy`})]})]});case`device_code`:return(0,N.jsxs)(`div`,{"data-testid":`login-device-code`,className:`space-y-1`,children:[(0,N.jsxs)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:[`Enter this code at`,` `,(0,N.jsx)(`a`,{href:e.verificationUri,target:`_blank`,rel:`noopener noreferrer`,className:`text-sky-700 underline dark:text-sky-400`,children:e.verificationUri}),`:`]}),(0,N.jsx)(`p`,{className:`select-all font-mono text-2xl tracking-widest text-zinc-900 dark:text-zinc-50`,children:e.userCode})]});case`info`:return(0,N.jsxs)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:[e.message,e.links?.map(e=>(0,N.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`ml-2 text-sky-700 underline dark:text-sky-400`,children:e.label??e.url},e.url))]});case`progress`:return(0,N.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:e.message})}}function sG({prompt:e,onAnswer:t}){let[n,r]=(0,v.useState)(``),i=e.type===`manual_code`&&/^http:\/\/(?:localhost|127\.0\.0\.1):1455\/auth\/callback\/?$/.test(e.placeholder??``);return e.type===`select`?(0,N.jsxs)(`div`,{"data-testid":`login-prompt`,className:`space-y-2`,children:[(0,N.jsx)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:e.message}),(0,N.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.options.map(e=>(0,N.jsx)(`button`,{type:`button`,className:aG,title:e.description,onClick:()=>t(e.id),children:e.label},e.id))})]}):(0,N.jsxs)(`div`,{"data-testid":`login-prompt`,className:`space-y-2`,children:[(0,N.jsxs)(`label`,{className:`block text-sm text-zinc-700 dark:text-zinc-200`,children:[e.type===`manual_code`?`${e.message} — or the whole address the browser was sent to`:e.message,(0,N.jsx)(`input`,{className:`${iG} mt-1`,type:e.type===`secret`?`password`:`text`,name:`provider-auth-response`,placeholder:e.placeholder,autoComplete:`off`,spellCheck:e.type!==`manual_code`,autoFocus:!0,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),n.trim()&&t(n.trim()))}})]}),i&&(0,N.jsx)(`p`,{className:`text-xs text-zinc-600 dark:text-zinc-300`,children:`If Pi Outpost runs on another computer, your browser may say it cannot connect to localhost. Copy the full address from that browser page and paste it above to finish signing in.`}),(0,N.jsx)(`button`,{type:`button`,className:aG,disabled:!n.trim(),onClick:()=>t(n.trim()),children:`Continue`})]})}function cG({login:e,providerName:t,onAnswer:n,onCancel:r,onDismiss:i}){return(0,N.jsxs)(`div`,{"data-testid":`login-flow`,className:`space-y-3 rounded-md border border-zinc-200 p-3 dark:border-zinc-700`,children:[(0,N.jsxs)(`p`,{className:`text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:[`Signing in to `,t]}),(0,N.jsxs)(`div`,{"aria-live":`polite`,"aria-atomic":`false`,children:[e.events.map((e,t)=>(0,N.jsx)(oG,{event:e},t)),e.prompt&&(0,N.jsx)(sG,{prompt:e.prompt.prompt,onAnswer:n},e.prompt.promptId),!e.done&&!e.prompt&&e.events.length===0&&(0,N.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:`Starting…`}),e.done?(0,N.jsxs)(`div`,{"data-testid":`login-done`,"data-ok":e.done.ok?`true`:`false`,className:`space-y-2`,children:[(0,N.jsx)(`p`,{className:`text-sm ${e.done.ok?`text-emerald-700 dark:text-emerald-400`:`text-red-700 dark:text-red-400`}`,children:e.done.ok?`Signed in to ${t}.`:e.done.cancelled?`Sign-in cancelled.`:`Sign-in failed: ${e.done.message??`unknown error`}`}),(0,N.jsx)(`button`,{type:`button`,className:aG,onClick:i,children:`Close`})]}):(0,N.jsx)(`button`,{type:`button`,className:aG,onClick:r,children:`Cancel`})]})]})}function lG(e){return[...e].sort((e,t)=>e.localeCompare(t))}function uG(e,t){return e===`models_json_key`?`This key is managed in models.json. Remove it from that provider configuration.`:e===`environment`?`This key comes from ${t??`the server environment`}. Remove it from there.`:`This key is managed by ${t??e??`the provider runtime`}. Remove it from that source.`}function dG(e,t){return e===`models_json_key`?`models.json`:t??e}function fG({credentials:e,login:t,onStartLogin:n,onAnswerLogin:r,onCancelLogin:i,onDismissLogin:a,onLogoutProvider:o,extensionPaths:s,configuredExtensionPaths:c,userExtensionPaths:l,extensionLock:u,piPackages:d=null,piPackageUpdate:f=null,piPackageEdits:p,canRestartServer:m=!1,serverRestarting:h=!1,onCheckPiPackages:g,onUpdatePiPackage:_,onRestartServer:y,onRestartSession:b,restartNeeded:x=[],tools:S,commands:C,sandbox:w,showRoots:T=!0,gitUnavailable:E,userSkillPaths:D,serverBrowse:O,pickerBlocked:ee=!1,onPickerOpened:te,applyState:k,agentResources:ne=null,agentResourceOperations:A={clonePath:null,preview:null,enrollment:null,refresh:null,updates:{},skills:{},removals:{}},versions:re,onBrowseServerPath:j,onCloseServerBrowser:ie,onUpdateConfig:ae,onSuggestAgentResourceClonePath:oe=()=>{},onCloneAgentResourceRepository:se=()=>{},onEnrollAgentResourceRepository:ce=()=>{},onSetAgentResourceSkills:le=()=>{},onRemoveAgentResourceRepository:ue=()=>{},onRefreshAgentResourceRepositories:de=()=>{},onUpdateAgentResourceRepository:fe=()=>{}}){let[M,pe]=(0,v.useState)(!1),[me,he]=(0,v.useState)(!1),ge=(0,v.useRef)(new Map),[P,_e]=(0,v.useState)(!1),ve=(0,v.useRef)(null),[ye,be]=(0,v.useState)(``),[xe,Se]=(0,v.useState)(``),[Ce,we]=(0,v.useState)(!1),[Te,Ee]=(0,v.useState)(!1),[De,Oe]=(0,v.useState)(null),ke=(e,r)=>{if(t&&!t.done){i?.(),a?.();let e=ge.current.get(t.provider);e&&(e.open=!1)}else n?.(e,r)};(0,v.useEffect)(()=>{ee&&De!==null&&Oe(null)},[ee,De]);let Ae=oH(()=>{(M||De!==null)&&Re()}),je=S.filter(e=>e.active),Me=S.filter(e=>!e.active),Ne=C.filter(e=>e.source===`skill`),Pe=[...S].sort((e,t)=>e.name.localeCompare(t.name)||Number(t.active)-Number(e.active)),Fe=k?.status===`applying`,Ie=k?.status===`error`?k.message:null;(0,v.useEffect)(()=>{w&&(be(w.root),Se(w.writableRoot??``),we(w.allowWrite),Ee(w.allowBash))},[w]);let Le=(0,v.useRef)(!1);(0,v.useEffect)(()=>{Le.current&&k===null&&Re(),Le.current=Fe},[k,Fe]);function Re(){he(!1),pe(!1),Oe(null),ie()}function ze(e,t){te?.(),Oe(e),j(t.trim()||`/`)}function Be(e){De===`root`?be(e):De===`writableRoot`&&Se(e),Oe(null),ie()}let Ve=w!==null&&(ye!==w.root||(xe.trim()||void 0)!==(w.writableRoot||void 0)||Ce!==w.allowWrite||Te!==w.allowBash);function He(){w&&Ve&&ae({sandbox:{root:ye,allowWrite:Ce,allowBash:Te,writableRoot:xe.trim()||void 0}})}let Ue=T&&w?.rootEditable!==!1,We=De!==null&&!ee&&(0,N.jsx)(vW,{label:De===`root`?`Choose the sandbox root`:`Choose the writable root`,browse:O,onBrowse:j,onSelect:Be,onCancel:()=>{Oe(null),ie()}});return(0,N.jsxs)(`div`,{className:`relative`,ref:Ae,children:[(0,N.jsx)(`button`,{ref:ve,type:`button`,onClick:()=>{he(!1),M?Re():pe(!0)},title:`Settings`,"aria-label":`Settings`,className:`${uW} border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`⚙`}),M&&(0,N.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-[80vh] w-[380px] flex-col rounded-lg border border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,N.jsxs)(`div`,{className:`border-b border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:[me&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>he(!1),className:`mb-2 text-xs text-zinc-600 hover:underline dark:text-zinc-400`,children:`← Back to settings`}),(0,N.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:me?`Credits`:`Settings`})]}),(0,N.jsx)(`div`,{className:`min-h-0 overflow-y-auto p-4`,children:me?(0,N.jsx)(OW,{}):(0,N.jsxs)(N.Fragment,{children:[E&&(0,N.jsxs)(`section`,{className:`mb-4`,"data-testid":`git-unavailable`,children:[(0,N.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Version control`}),E.reason===`no-repository`?(0,N.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:`This project is not in a git repository.`}):(0,N.jsxs)(`div`,{className:`rounded border border-amber-300 bg-amber-50 px-2 py-1.5 dark:border-amber-900 dark:bg-amber-950/40`,children:[(0,N.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-300`,children:E.reason===`no-executable`?`Git is unavailable: its executable could not be run.`:`Git is unavailable: it refused this repository.`}),(0,N.jsx)(`p`,{className:`mt-1 break-all font-mono text-[11px] text-amber-700 dark:text-amber-400`,children:E.message}),E.reason===`no-executable`&&(0,N.jsxs)(`p`,{className:`mt-1 text-xs text-amber-700 dark:text-amber-400`,children:[`Install git, add it to PATH, or name it with `,(0,N.jsx)(`span`,{className:`font-mono`,children:`gitPath`}),` in the configuration.`]})]})]}),e&&(0,N.jsxs)(`details`,{className:`mb-4`,"data-testid":`accounts-panel`,children:[(0,N.jsxs)(`summary`,{className:`cursor-pointer text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:[`Accounts · `,(0,N.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:[e.providers.filter(e=>e.configured).length,` providers configured`]})]}),(0,N.jsxs)(`div`,{className:`mt-2`,children:[(0,N.jsx)(`ul`,{className:`space-y-2`,children:e.providers.map(n=>(0,N.jsx)(`li`,{className:`rounded border border-zinc-200 p-2 dark:border-zinc-700`,children:(0,N.jsxs)(`details`,{ref:e=>{e?ge.current.set(n.id,e):ge.current.delete(n.id)},"data-testid":`account-${n.id}`,children:[(0,N.jsxs)(`summary`,{className:`cursor-pointer`,children:[(0,N.jsx)(`span`,{className:`text-xs font-medium text-zinc-800 dark:text-zinc-200`,children:n.name}),(0,N.jsx)(`span`,{className:`ml-2 text-[11px] ${n.configured?`text-emerald-700 dark:text-emerald-400`:`text-zinc-500 dark:text-zinc-400`}`,children:n.configured?`${n.auth??`Authenticated`}${n.source?` · ${dG(n.source,n.label)}`:``}`:`Not signed in`})]}),(0,N.jsxs)(`div`,{className:`mt-2`,children:[n.configured&&n.auth===`api_key`&&n.source!==`stored`&&(0,N.jsx)(`p`,{className:`mb-2 text-[11px] text-zinc-500 dark:text-zinc-400`,children:uG(n.source,n.label)}),!e.locked&&(0,N.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[n.methods?.includes(`oauth`)&&(0,N.jsx)(`button`,{type:`button`,className:`rounded border px-2 py-1 text-[11px]`,onClick:()=>ke(n.id,`oauth`),children:`Sign in`}),n.methods?.includes(`api_key`)&&(0,N.jsx)(`button`,{type:`button`,className:`rounded border px-2 py-1 text-[11px]`,onClick:()=>ke(n.id,`api_key`),children:`API key`}),n.configured&&n.source===`stored`&&(0,N.jsx)(`button`,{type:`button`,className:`rounded border px-2 py-1 text-[11px]`,onClick:()=>o?.(n.id),children:n.auth===`api_key`?`Remove API key`:`Sign out`})]}),t?.provider===n.id&&(0,N.jsx)(`div`,{className:`mt-2`,children:(0,N.jsx)(cG,{login:t,providerName:n.name,onAnswer:e=>r?.(e),onCancel:()=>i?.(),onDismiss:()=>a?.()})})]})]})},n.id))}),e.locked&&(0,N.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500 dark:text-zinc-400`,children:`Credentials are locked by this server.`})]})]}),(0,N.jsxs)(`section`,{className:`mb-4`,children:[(0,N.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Agent resources`}),S.length===0?(0,N.jsx)(`p`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:`Tool inventory unavailable for this runtime`}):(0,N.jsxs)(`details`,{"data-testid":`tools-loaded`,children:[(0,N.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[je.length,` tools active`,Me.length?` · ${Me.length} inactive`:``]}),(0,N.jsx)(`ul`,{className:`mt-2 space-y-1`,children:Pe.map(e=>(0,N.jsxs)(`li`,{className:`flex justify-between rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,children:[(0,N.jsx)(`span`,{children:e.name}),(0,N.jsx)(`span`,{children:e.active?`active`:`inactive`})]},e.name))})]}),Ne.length===0?(0,N.jsx)(`p`,{className:`mt-2 text-xs text-zinc-600 dark:text-zinc-400`,children:`No skills loaded`}):(0,N.jsxs)(`details`,{className:`mt-2`,"data-testid":`skills-loaded`,children:[(0,N.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[Ne.length,` skills loaded`]}),(0,N.jsx)(`ul`,{className:`mt-2 space-y-1`,children:lG(Ne.map(e=>e.name)).map(e=>(0,N.jsx)(`li`,{className:`rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,children:e},e))})]}),(0,N.jsx)(`button`,{type:`button`,"aria-label":`Manage agent resources`,onClick:()=>{pe(!1),_e(!0)},className:`mt-3 w-full rounded-md border border-zinc-300 px-3 py-2 text-xs font-medium text-zinc-700 hover:bg-zinc-50 dark:border-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-800`,children:`Manage agent resources`})]}),(0,N.jsxs)(`section`,{className:`mb-4`,children:[(0,N.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Extensions`}),s===null?(0,N.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,"data-testid":`extensions-unknown`,children:`Not reported by this runtime`}):s.length===0?(0,N.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No extensions loaded`}):(0,N.jsxs)(`details`,{"data-testid":`extensions-loaded`,children:[(0,N.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[s.length,` `,s.length===1?`extension`:`extensions`,` loaded`]}),(0,N.jsx)(`ul`,{className:`mt-2 space-y-1`,children:lG(s).map(e=>(0,N.jsx)(`li`,{className:`truncate rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,title:e,children:e},e))})]}),c.length>0&&(0,N.jsxs)(`details`,{className:`mt-2`,"data-testid":`extensions-configured`,children:[(0,N.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[c.length,` configured by this deployment`]}),(0,N.jsx)(`p`,{className:`mt-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`Declared in the configuration file. They load either way, and nothing here can remove them.`}),(0,N.jsx)(`ul`,{className:`mt-1 space-y-1`,children:lG(c).map(e=>(0,N.jsx)(`li`,{className:`truncate rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,title:e,children:e},e))})]}),u?(0,N.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400 dark:text-zinc-500`,"data-testid":`extensions-locked`,children:`Extension paths and repository updates that contain extensions are locked by this deployment.`}):null,(0,N.jsx)(zW,{packages:d,update:f,locked:u,onCheck:()=>g?.(),onUpdate:e=>_?.(e),...p?{edits:p}:{}}),(0,N.jsx)(VW,{reasons:x,canRestart:m,restarting:h,onRestart:()=>y?.()})]}),w&&(0,N.jsxs)(`section`,{children:[(0,N.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:Ue?`Sandbox`:`Agent permissions`}),(0,N.jsxs)(`div`,{className:`space-y-3`,children:[!Ue&&(0,N.jsxs)(`p`,{"data-testid":`sandbox-project-root`,className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`This project is confined to its own folder,`,` `,(0,N.jsx)(`span`,{className:`break-all font-mono text-zinc-800 dark:text-zinc-200`,children:w.projectRoot??w.root}),`. Each open project is confined to its own. A change here applies to this project now, and to projects opened after.`]}),Ue&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`label`,{className:`block`,children:[(0,N.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Root `,w.locks?.root?(0,N.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,N.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,N.jsx)(`input`,{type:`text`,value:ye,onChange:e=>be(e.target.value),disabled:w.locks?.root,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none focus:border-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:focus:border-zinc-500`}),(0,N.jsx)(`button`,{type:`button`,"aria-label":`Browse for sandbox root`,disabled:w.locks?.root,onClick:()=>ze(`root`,ye),className:`shrink-0 rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-300`,children:`Browse…`})]})]}),De===`root`&&We,(0,N.jsxs)(`label`,{className:`block`,children:[(0,N.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Writable root (optional) `,w.locks?.writableRoot?(0,N.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,N.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,N.jsx)(`input`,{type:`text`,value:xe,onChange:e=>Se(e.target.value),disabled:w.locks?.writableRoot,placeholder:`Same as root`,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,N.jsx)(`button`,{type:`button`,"aria-label":`Browse for writable root`,disabled:w.locks?.writableRoot,onClick:()=>ze(`writableRoot`,xe||ye),className:`shrink-0 rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-300`,children:`Browse…`})]})]}),De===`writableRoot`&&We]}),(0,N.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:Ce,onChange:e=>we(e.target.checked),disabled:w.locks?.allowWrite,className:`rounded border-zinc-300 text-zinc-700 focus:ring-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300`}),(0,N.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow write `,w.locks?.allowWrite?(0,N.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]}),(0,N.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:Te,onChange:e=>Ee(e.target.checked),disabled:w.locks?.allowBash,className:`rounded border-zinc-300 text-zinc-700 focus:ring-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300`}),(0,N.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow bash `,w.locks?.allowBash?(0,N.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]})]})]}),!w&&(0,N.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No sandbox configured`}),(0,N.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[Ie&&(0,N.jsx)(`p`,{role:`alert`,className:`rounded-md border border-red-300 bg-red-50 px-2 py-1 text-xs text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:Ie}),(0,N.jsx)(`button`,{type:`button`,disabled:Fe||Ve&&!ye.trim(),onClick:Ve?He:b,className:`w-full rounded-md bg-zinc-800 px-3 py-1.5 text-xs font-medium text-white hover:bg-zinc-700 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-zinc-200 dark:text-zinc-900 dark:hover:bg-zinc-300`,children:Fe?`Restarting…`:Ve?`Apply & restart session`:`Restart session`}),(0,N.jsx)(`p`,{className:`text-[11px] text-zinc-400 dark:text-zinc-500`,children:Ve?`Saved to the server's configuration file, then the session is rebuilt — the change survives a restart.`:`Start a fresh session to reload extensions and MCP connections. Settings are kept.`})]}),re&&(0,N.jsxs)(`section`,{className:`mt-4`,children:[(0,N.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Versions`}),(0,N.jsxs)(`div`,{className:`space-y-1 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,N.jsxs)(`p`,{children:[`pi-outpost: `,(0,N.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:re.piOutpost})]}),re.piSdk&&(0,N.jsxs)(`p`,{children:[`pi SDK: `,(0,N.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:re.piSdk})]}),re.agent&&(0,N.jsxs)(`p`,{children:[`agent: `,(0,N.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:re.agent})]})]})]}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>he(!0),className:`mt-4 w-full border-t border-zinc-200 pt-3 text-left text-sm text-zinc-600 hover:text-zinc-900 dark:border-zinc-700 dark:text-zinc-400 dark:hover:text-zinc-100`,children:`Credits →`})]})})]}),(0,N.jsx)(rG,{open:P,inventory:ne,operations:A,extensionLock:u,userSkillPaths:D,userExtensionPaths:l,serverBrowse:O,applyState:k,onClose:()=>{_e(!1),ie(),ve.current?.focus()},onBrowseServerPath:e=>{te?.(),j(e)},onCloseServerBrowser:ie,onUpdateConfig:ae,onSuggestClonePath:oe,onCloneRepository:se,onEnrollRepository:ce,onSetSkills:le,onRemoveRepository:ue,onRefresh:de,onUpdate:fe})]})}function pG(e){let t=[],n=new Set,r=0,i=0;function a(e,o,s,c){let l=e.children,u=l.slice(1).map(e=>[e,r++]);u.length>0&&i++;let d=e.onPath&&!l.some(e=>e.onPath);if(t.push({node:e,lane:o,through:[...n].filter(e=>e!==o),forkTo:u.map(([,e])=>e),lineAbove:s,lineBelow:l.length>0,branchIndex:c,isCurrent:d,emphasis:d?`current`:e.onPath?`filled`:`hollow`,highlight:e.onPath}),l.length===0)n.delete(o);else{for(let[,e]of u)n.add(e);a(l[0],o,!0,u.length>0?1:void 0),u.forEach(([e,t],n)=>a(e,t,!0,n+2))}}return e.length>1&&i++,e.forEach((t,i)=>{let o=r++;n.add(o),a(t,o,!1,e.length>1?i+1:void 0)}),{rows:t,laneCount:r,branchPoints:i}}function mG(e){return e.flatMap(e=>[e,...mG(e.children)])}function hG({children:e,tone:t}){let n={current:`border-emerald-300 bg-emerald-50 text-emerald-700 dark:border-emerald-800 dark:bg-emerald-950/50 dark:text-emerald-300`,branch:`border-zinc-300 text-zinc-500 dark:border-zinc-700 dark:text-zinc-400`,label:`border-violet-300 bg-violet-50 text-violet-700 dark:border-violet-900 dark:bg-violet-950/50 dark:text-violet-300`}[t];return(0,N.jsx)(`span`,{className:`shrink-0 rounded-full border px-1.5 py-px text-[10px] leading-4 ${n}`,children:e})}var gG=`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-500 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`;function _G({row:e,laneCount:t,isStreaming:n,onNavigate:r,onFork:i,onClose:a}){let{node:o}=e,s=o.tipId??o.entryId;return(0,N.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70 ${e.isCurrent?`bg-emerald-50/60 dark:bg-emerald-950/20`:``}`,style:{height:36},children:[(0,N.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>{r(s),a()},title:n?`unavailable while the agent is running`:o.tipId?`restore the conversation at this point (reply included)`:`go back to this point`,className:`flex h-full min-w-0 flex-1 items-center gap-2 pl-2 text-left text-sm disabled:opacity-50`,children:[(0,N.jsx)(YU,{row:e,laneCount:t,colorOf:KU}),(0,N.jsx)(`span`,{className:`min-w-0 truncate ${o.onPath?`text-zinc-800 dark:text-zinc-200`:`text-zinc-600 dark:text-zinc-400`}`,children:o.text||`(empty)`}),e.forkTo.length>0&&(0,N.jsxs)(hG,{tone:`branch`,children:[e.forkTo.length+1,` branches`]}),e.branchIndex!==void 0&&(0,N.jsxs)(hG,{tone:`branch`,children:[`branch `,e.branchIndex,o.onPath&&!e.isCurrent?` · current`:``]}),e.isCurrent&&(0,N.jsx)(hG,{tone:`current`,children:`current`}),o.label&&(0,N.jsx)(hG,{tone:`label`,children:o.label})]}),(0,N.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>{r(o.entryId),a()},title:`rewind to just before this message (its text comes back in the composer)`,"aria-label":`Rewind to before this message`,className:gG,children:`↺ redo`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>{i(o.entryId),a()},title:`fork a new session from this point`,className:gG,children:`⑂ fork`})]})}function vG({tree:e,isStreaming:t,onListTree:n,onNavigate:r,onFork:i}){let[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``),l=oH(()=>o(!1));(0,v.useEffect)(()=>{a&&e===null&&n()},[a,e]);let u=(0,v.useMemo)(()=>e&&e.length>0?pG(e):null,[e]),d=(0,v.useMemo)(()=>{if(!e||!s.trim())return null;let t=s.trim().toLowerCase();return mG(e).filter(e=>e.text.toLowerCase().includes(t)||e.label?.toLowerCase().includes(t))},[e,s]);return(0,N.jsxs)(`div`,{className:`relative`,ref:l,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>{o(!a),a||(c(``),n())},title:`conversation tree: go back to an earlier point or fork`,className:`${uW} border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`tree`}),a&&(0,N.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-[70vh] w-[32rem] max-w-[90vw] flex-col rounded-lg border border-zinc-200 bg-white shadow-xl [--tree-off:#e4e4e7] dark:border-zinc-700 dark:bg-zinc-900 dark:[--tree-off:#3f3f46]`,children:[e===null&&(0,N.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),e?.length===0&&(0,N.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no messages yet`}),e&&e.length>0&&u&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,N.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,N.jsx)(`span`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Conversation tree`}),(0,N.jsxs)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:[u.rows.length,` turn`,u.rows.length===1?``:`s`,` · `,u.branchPoints,` branch point`,u.branchPoints===1?``:`s`]})]}),(0,N.jsx)(`input`,{type:`search`,value:s,onChange:e=>c(e.target.value),placeholder:`Search tree`,"aria-label":`Search conversation tree`,className:`mt-2 w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,N.jsx)(`p`,{className:`mt-1.5 text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Follow the colored lines — the current branch is highlighted. Click a turn to restore the conversation there · ↺ to send it again · ⑂ to fork a session`})]}),(0,N.jsx)(`div`,{className:`min-h-0 overflow-y-auto py-1`,children:d===null?u.rows.map(e=>(0,N.jsx)(_G,{row:e,laneCount:u.laneCount,isStreaming:t,onNavigate:r,onFork:i,onClose:()=>o(!1)},e.node.entryId)):d.length===0?(0,N.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no matches`}):d.map(e=>(0,N.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70`,children:[(0,N.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>{r(e.tipId??e.entryId),o(!1)},title:e.tipId?`restore the conversation at this point (reply included)`:`go back to this point`,className:`flex min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-left text-sm disabled:opacity-50`,children:[(0,N.jsx)(`span`,{"aria-hidden":!0,className:e.onPath?`text-emerald-500`:`text-zinc-300 dark:text-zinc-600`,children:`●`}),(0,N.jsx)(`span`,{className:`min-w-0 truncate text-zinc-700 dark:text-zinc-300`,children:e.text||`(empty)`}),e.onPath&&(0,N.jsx)(hG,{tone:`current`,children:`on current branch`}),e.label&&(0,N.jsx)(hG,{tone:`label`,children:e.label})]}),(0,N.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>{r(e.entryId),o(!1)},title:`rewind to just before this message (its text comes back in the composer)`,"aria-label":`Rewind to before this message`,className:gG,children:`↺ redo`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>{i(e.entryId),o(!1)},title:`fork a new session from this point`,className:gG,children:`⑂ fork`})]},e.entryId))})]})]})]})}var yG=200;function bG({initial:e,onCommit:t,onCancel:n}){let[r,i]=(0,v.useState)(e);return(0,N.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>i(e.target.value),onBlur:n,onKeyDown:e=>{e.key===`Enter`?t(r):e.key===`Escape`&&n()},placeholder:`Session name (empty to clear)`,"aria-label":`Session name`,className:`w-full rounded-md border border-zinc-400 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 dark:border-zinc-600 dark:placeholder:text-zinc-600`})}function xG({session:e,isCurrent:t,renaming:n,onSwitch:r,onDelete:i,onStartRename:a,onRename:o,onCancelRename:s}){return n?(0,N.jsx)(`div`,{className:`px-3 py-2`,children:(0,N.jsx)(bG,{initial:e.name??``,onCommit:o,onCancel:s})}):(0,N.jsxs)(`div`,{className:`group flex items-start gap-1 hover:bg-zinc-100 dark:hover:bg-zinc-800 ${t?`bg-zinc-100 dark:bg-zinc-800/60`:``}`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 flex-1 px-3 py-2 text-left text-sm`,children:[(0,N.jsx)(`div`,{className:`truncate text-zinc-700 dark:text-zinc-300`,children:e.name||e.firstMessage||`(empty)`}),e.snippet&&(0,N.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-zinc-500 dark:text-zinc-500`,children:e.snippet}),(0,N.jsxs)(`div`,{className:`mt-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:[new Date(e.modified).toLocaleString(),` · `,e.messageCount,` messages`,t?` · current`:``,!t&&e.liveIn?(0,N.jsxs)(`span`,{"data-testid":`session-live-in`,children:[` · open in `,e.liveIn]}):null]})]}),(0,N.jsx)(`button`,{type:`button`,onClick:a,title:`rename session`,"aria-label":`Rename session`,className:`mt-2 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-600 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`,children:`✎`}),!t&&!e.liveIn&&(0,N.jsx)(`button`,{type:`button`,onClick:i,title:`delete session`,"aria-label":`Delete session`,className:`mr-2 mt-2 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-red-100 hover:text-red-600 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-600 dark:hover:bg-red-950/60 dark:hover:text-red-400`,children:`✕`})]})}function SG({sessions:e,sessionSearch:t,sessionId:n,onSwitchSession:r,onDeleteSession:i,onListSessions:a,onRenameSession:o,onSearchSessions:s,onClearSessionSearch:c}){let[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(null),h=oH(()=>u(!1)),g=d.trim(),_=g.length>=2;(0,v.useEffect)(()=>{if(!l)return;if(!_){c();return}let e=setTimeout(()=>s(g),yG);return()=>clearTimeout(e)},[l,g,_]);function y(){u(!1),m(null)}let b=_&&(t?.status!==`loaded`||t.query!==g),x=_?b?null:t?.results??null:e;return(0,N.jsxs)(`div`,{className:`relative`,ref:h,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>{l?y():(u(!0),f(``),m(null),c(),a())},className:`${uW} border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`sessions`}),l&&(0,N.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-96 w-96 flex-col rounded-lg border border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,N.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,N.jsx)(`input`,{type:`search`,value:d,onChange:e=>f(e.target.value),placeholder:`Search sessions`,"aria-label":`Search sessions`,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,N.jsx)(`p`,{className:`mt-1.5 text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Searches names and everything said in a session · ✎ to rename`})]}),(0,N.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[x===null&&(0,N.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),x?.length===0&&(0,N.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:_?`no matches`:`no saved sessions`}),x?.map(e=>(0,N.jsx)(xG,{session:e,isCurrent:e.id===n,renaming:p===e.path,onSwitch:()=>{r(e.path),y()},onDelete:()=>{window.confirm(`Delete this session?`)&&i(e.path)},onStartRename:()=>m(e.path),onRename:t=>{o(e.path,t),m(null),_&&s(d.trim())},onCancelRename:()=>m(null)},e.path))]})]})]})}function CG({filters:e,onFilterChange:t}){let[n,r]=(0,v.useState)(!1),i=oH(()=>r(!1)),a=MV(e),o=a>0?`Filter · ${a} hidden`:`Filter`;return(0,N.jsxs)(`div`,{className:`relative`,ref:i,onKeyDown:e=>{e.key===`Escape`&&n&&(e.stopPropagation(),r(!1))},children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>r(!n),"aria-haspopup":`menu`,"aria-expanded":n,title:`Choose what the conversation shows`,className:`${uW} ${a>0?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`}`,children:o}),n&&(0,N.jsx)(`div`,{role:`menu`,className:`absolute right-0 z-30 mt-1 w-48 rounded-md border border-zinc-200 bg-white py-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:DV.map(n=>(0,N.jsxs)(`button`,{type:`button`,role:`menuitemcheckbox`,"aria-checked":e[n],onClick:()=>t(n,!e[n]),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-zinc-600 hover:bg-zinc-100 dark:text-zinc-300 dark:hover:bg-zinc-800`,children:[(0,N.jsx)(`span`,{"aria-hidden":!0,className:`w-3`,children:e[n]?`✓`:``}),(0,N.jsx)(`span`,{children:OV[n]})]},n))})]})}function wG({statuses:e,bar:t}){let n=Object.entries(e).filter(([,e])=>LH(e).trim()!==``),r=n.map(([e,t])=>`${e}\u0000${t}`).join(``),[i,a]=(0,v.useState)(!1),o=(0,v.useRef)(null),s=(0,v.useRef)(null),[c,l]=(0,v.useState)(!1),u=oH(()=>l(!1));if((0,v.useLayoutEffect)(()=>{o.current=null,a(!1),l(!1)},[r]),(0,v.useLayoutEffect)(()=>{let e=t;if(e===null)return;let n=()=>{if(o.current!==null){e.clientWidth>o.current+64&&(o.current=null,a(!1),l(!1));return}let t=Array.from(s.current?.querySelectorAll(`[data-status-text]`)??[]).some(e=>e.scrollWidth>e.clientWidth+1),n=e.firstElementChild?.getBoundingClientRect(),r=n&&n.height>0&&Array.from(e.children).some(e=>e.getBoundingClientRect().top>=n.bottom);(t||r||e.scrollWidth>e.clientWidth+1)&&(o.current=e.clientWidth,a(!0))};if(n(),typeof ResizeObserver>`u`)return;let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[t,i,r]),n.length===0)return null;if(!i)return(0,N.jsx)(`div`,{ref:s,className:`flex shrink-0 items-center gap-1.5`,children:n.map(([e,t])=>(0,N.jsx)(`span`,{title:LH(t),className:`${uW} max-w-[16rem] border-zinc-200 text-zinc-500 dark:border-zinc-800 dark:text-zinc-400`,children:(0,N.jsx)(`span`,{"data-status-text":!0,className:`truncate`,children:(0,N.jsx)(RH,{text:t})})},e))});let d=`${n.length} ${n.length===1?`status`:`statuses`}`;return(0,N.jsxs)(`div`,{ref:u,className:`relative shrink-0`,onKeyDown:e=>{e.key===`Escape`&&c&&(e.stopPropagation(),l(!1))},children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>l(!c),"aria-expanded":c,title:n.map(([,e])=>LH(e)).join(`
|
|
1511
|
+
`,EW=[[`draw.io / diagrams.net`,`Diagram viewer and editor`],[`GrapesJS`,`Poster editor`],[`React`,`User interface`],[`CodeMirror · xterm.js · node-pty`,`Code editor and terminal`],[`PDF.js · docx`,`Document tools`],[`Mermaid · KaTeX`,`Diagrams and mathematical notation`]],DW=[{name:`pi-outpost`,license:`MIT`,text:TW},...wW];function OW(){let[e,t]=(0,v.useState)(!1),n=(0,v.useRef)(null);return(0,v.useLayoutEffect)(()=>{n.current?.focus({preventScroll:!0});let e=n.current?.closest(`.overflow-y-auto`);e&&(e.scrollTop=0)},[e]),e?(0,N.jsxs)(`div`,{className:`text-zinc-700 dark:text-zinc-300`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>t(!1),className:`mb-3 text-xs text-zinc-500 hover:underline dark:text-zinc-400`,children:`← Back to credits`}),(0,N.jsx)(`h3`,{ref:n,tabIndex:-1,className:`text-sm font-semibold outline-none`,children:`Third-party notices`}),(0,N.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500 dark:text-zinc-400`,children:`License texts and attributions for pi-outpost and the components acknowledged here.`}),DW.map(e=>(0,N.jsxs)(`section`,{className:`mt-5 border-t border-zinc-200 pt-3 dark:border-zinc-700`,children:[(0,N.jsxs)(`h4`,{className:`text-sm font-semibold`,children:[e.name,` `,(0,N.jsxs)(`span`,{className:`font-normal text-zinc-500 dark:text-zinc-400`,children:[`· `,e.license]})]}),(0,N.jsx)(`pre`,{className:`mt-2 whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed`,children:e.text})]},e.name))]}):(0,N.jsxs)(`div`,{className:`text-sm text-zinc-700 dark:text-zinc-300`,children:[(0,N.jsxs)(`section`,{className:`pb-5`,children:[(0,N.jsx)(`h3`,{ref:n,tabIndex:-1,className:`text-xl font-semibold tracking-tight outline-none`,children:`pi-outpost`}),(0,N.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500 dark:text-zinc-400`,children:`Created by Laurent Francoise · MIT license`}),(0,N.jsxs)(`a`,{className:`mt-3 inline-flex items-center gap-2 text-xs underline underline-offset-4`,href:`https://laurentftech.github.io/pi-outpost/`,target:`_blank`,rel:`noopener noreferrer`,children:[`Project website `,(0,N.jsx)(`span`,{"aria-hidden":`true`,children:`↗`})]})]}),(0,N.jsxs)(`section`,{className:`border-t border-zinc-200 pt-4 dark:border-zinc-700`,children:[(0,N.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Open-source acknowledgements`}),(0,N.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500 dark:text-zinc-400`,children:`Thanks to the authors and contributors of these projects.`}),(0,N.jsx)(`dl`,{className:`mt-3 space-y-3`,children:EW.map(([e,t])=>(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{className:`text-xs font-medium`,children:e}),(0,N.jsx)(`dd`,{className:`mt-0.5 text-xs text-zinc-500 dark:text-zinc-400`,children:t})]},e))}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>t(!0),className:`mt-4 flex w-full items-center justify-between rounded-md border border-zinc-300 px-3 py-2 text-xs hover:bg-zinc-100 dark:border-zinc-700 dark:hover:bg-zinc-800`,children:[`Third-party notices `,(0,N.jsx)(`span`,{"aria-hidden":`true`,children:`→`})]})]})]})}function kW(e){if(e.removed)return`removed — still running until pi-outpost restarts`;if(e.installed===void 0)return`not installed`;if(e.restartNeeded)return`${e.installed} installed — restart to use it`;if(e.pinned!==void 0)return`${e.installed}, pinned`;let t=e.check;if(!t)return e.installed;switch(t.state){case`checking`:return`${e.installed}, checking…`;case`newer`:return`${e.installed} — ${t.latest} available`;case`current`:return`${e.installed}, up to date`;case`failed`:return`${e.installed}, not checked: ${t.reason}`;case`off`:return`${e.installed}, not checked: ${t.reason}`}}function AW(e){let t=e.trim().replace(/^npm:/,``),n=t.lastIndexOf(`@`);return n>0?{name:t.slice(0,n),version:t.slice(n+1)}:{name:t}}var jW=e=>`${e.scope}:${e.name}`,MW=(e,t)=>e===`user`?`all projects`:`the ${t} project`,NW=`w-16 shrink-0 rounded border border-zinc-300 px-1.5 py-0.5 text-zinc-700 hover:bg-zinc-100 disabled:opacity-50 dark:border-zinc-600 dark:text-zinc-200 dark:hover:bg-zinc-700`,PW=`w-16 shrink-0 rounded border border-transparent px-1.5 py-0.5 text-zinc-600 hover:bg-zinc-100 hover:text-red-700 disabled:opacity-50 dark:text-zinc-300 dark:hover:bg-zinc-700 dark:hover:text-red-400`,FW=`mt-1 rounded border border-amber-300 bg-amber-50 p-2 text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200`,IW=`rounded bg-amber-600 px-2 py-0.5 text-white hover:bg-amber-700`,LW=`rounded px-2 py-0.5 hover:bg-amber-100 dark:hover:bg-amber-900/40`,RW=()=>(0,N.jsx)(`span`,{"aria-hidden":`true`,className:`${NW} invisible`,children:`Update`});function zW({packages:e,update:t,locked:n,onCheck:r,onUpdate:i,edits:a}){let[o,s]=(0,v.useState)(null);if(e===null||e.length===0&&!a)return null;let c=t?.status===`pending`?t.source:null,l=a?.change??null,u=l?.status===`pending`?l:null,d=c!==null||u!==null||a?.lookup?.status===`pending`,f=!n&&a!==void 0;function p(e){if(c===e.source&&e.check?.state===`newer`)return{text:`updating to ${e.check.latest}…`,warn:!1};if(u&&u.key===jW(e)){if(u.action===`remove`)return{text:`removing…`,warn:!1};if(u.action===`restore`)return{text:`reinstalling ${e.loaded??``}…`,warn:!1}}return t&&t.status!==`pending`&&t.status!==`installed`&&t.source===e.source?{text:t.message,warn:!0}:l&&(l.status===`failed`||l.status===`refused`)&&l.key===jW(e)&&l.action!==`install`?{text:l.message,warn:!0}:{text:kW(e),warn:!1}}return(0,N.jsxs)(`div`,{className:`mt-3 text-xs`,"data-testid":`pi-packages`,children:[(0,N.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,N.jsx)(`span`,{className:`font-medium text-zinc-600 dark:text-zinc-400`,children:`Packages`}),e.length>0&&(0,N.jsx)(`button`,{type:`button`,onClick:r,className:`text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200`,children:`check for updates`})]}),e.length===0&&(0,N.jsx)(`p`,{className:`text-zinc-500 dark:text-zinc-400`,"data-testid":`pi-packages-empty`,children:`No packages installed`}),(0,N.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>{let t=jW(e),r=e.check?.state===`newer`&&!e.restartNeeded&&!e.removed?e.check.latest:void 0,c=o?.key===t?o.kind:null,{text:l,warn:u}=p(e);return(0,N.jsxs)(`li`,{"data-testid":`pi-package`,className:`rounded bg-zinc-50 px-2 py-1 dark:bg-zinc-800`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,N.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium ${e.removed?`text-zinc-400 line-through dark:text-zinc-500`:`text-zinc-700 dark:text-zinc-200`}`,title:e.source,children:e.name}),!n&&(r?(0,N.jsx)(`button`,{type:`button`,disabled:d||c!==null,onClick:()=>s({kind:`update`,key:t}),className:NW,children:`Update`}):(0,N.jsx)(RW,{})),f&&(e.removed?(0,N.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>a.onRestore(e),className:NW,title:`Put ${e.name} back as it was`,children:`Undo`}):(0,N.jsx)(`button`,{type:`button`,disabled:d||c!==null,onClick:()=>s({kind:`remove`,key:t}),className:PW,"aria-label":`Remove ${e.name}`,children:`Remove`}))]}),(0,N.jsxs)(`div`,{className:`truncate ${u?`text-amber-700 dark:text-amber-400`:`text-zinc-500 dark:text-zinc-400`}`,title:l,children:[e.scope===`project`&&(0,N.jsx)(`span`,{children:`this project · `}),(0,N.jsx)(`span`,{"data-testid":`pi-package-status`,children:l})]}),r&&c===`update`&&(0,N.jsxs)(`div`,{className:FW,"data-testid":`pi-package-confirm`,children:[(0,N.jsxs)(`p`,{children:[`This replaces code that runs with the agent's privileges: `,e.name,` `,e.installed,` → `,r,`. It takes effect when pi-outpost restarts.`]}),(0,N.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>{s(null),i(e.source)},className:IW,children:[`Install `,r]}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>s(null),className:LW,children:`Cancel`})]})]}),a&&c===`remove`&&(0,N.jsxs)(`div`,{className:FW,"data-testid":`pi-package-confirm`,children:[(0,N.jsxs)(`p`,{children:[`Removes `,e.name,` from `,e.scope===`user`?`the agent's settings (all projects)`:`the ${a.projectName} project's settings`,` `,`and uninstalls it. The agent keeps running it until pi-outpost restarts.`]}),(0,N.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>{s(null),a.onRemove(e)},className:IW,children:`Remove`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>s(null),className:LW,children:`Cancel`})]})]})]},`${t}:${e.source}`)})}),f&&(0,N.jsx)(BW,{edits:a,busy:d},a.projectName)]})}function BW({edits:e,busy:t}){let[n,r]=(0,v.useState)(!1),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(`user`),c=(0,v.useRef)(null),{lookup:l,change:u}=e,d=u?.status===`pending`&&u.action===`install`?u:null,f=u&&u.action===`install`&&(u.status===`failed`||u.status===`refused`)?u.message:null,p=AW(i),m=l&&l.name===p.name&&l.version===p.version&&l.scope===o?l:null;(0,v.useEffect)(()=>{u?.action===`install`&&u.status===`installed`&&(r(!1),a(``),s(`user`))},[u]),(0,v.useEffect)(()=>{n&&m?.status!==`found`&&c.current?.focus()},[n,m?.status]);let h=()=>{r(!1),a(``),s(`user`),e.onCloseLookup()};if(d)return(0,N.jsxs)(`p`,{className:`mt-1 text-zinc-500 dark:text-zinc-400`,role:`status`,children:[`installing `,d.key.slice(d.key.indexOf(`:`)+1),`…`]});if(!n)return(0,N.jsxs)(N.Fragment,{children:[f&&(0,N.jsx)(`p`,{className:`mt-1 text-amber-700 dark:text-amber-400`,role:`alert`,children:f}),(0,N.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>r(!0),className:`mt-1 text-zinc-500 underline hover:text-zinc-800 disabled:opacity-50 dark:hover:text-zinc-200`,children:`Add a package`})]});if(m?.status===`found`)return(0,N.jsxs)(`div`,{className:FW,"data-testid":`pi-package-add-confirm`,children:[(0,N.jsxs)(`p`,{children:[`This installs code that runs with the agent's privileges: `,m.name,` `,m.resolved,m.version===void 0?``:` (pinned)`,`, for `,MW(m.scope,e.projectName),`. It takes effect when pi-outpost restarts.`]}),(0,N.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,N.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>e.onInstall(m.name,m.version,m.scope,m.resolved),className:IW,children:[`Install `,m.name]}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>e.onCloseLookup(),className:LW,children:`Cancel`})]})]});let g=m?m.status===`refused`?m.message:null:f;return(0,N.jsxs)(`form`,{className:`mt-1 rounded border border-zinc-200 p-2 dark:border-zinc-700`,onSubmit:n=>{n.preventDefault(),p.name&&!t&&e.onLookup(p.name,p.version,o)},onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),h())},children:[(0,N.jsx)(`label`,{className:`block text-zinc-600 dark:text-zinc-400`,htmlFor:`pi-package-name`,children:`npm package`}),(0,N.jsx)(`input`,{id:`pi-package-name`,ref:c,value:i,onChange:e=>a(e.target.value),disabled:m?.status===`pending`,autoComplete:`off`,spellCheck:!1,placeholder:`openlore, @scope/name or name@1.2.3`,className:`mt-0.5 w-full rounded border border-zinc-300 bg-white px-2 py-1 text-xs outline-none focus:ring-1 focus:ring-blue-400 dark:border-zinc-600 dark:bg-zinc-800`}),(0,N.jsxs)(`fieldset`,{className:`mt-2 flex flex-wrap gap-x-3 text-zinc-600 dark:text-zinc-400`,children:[(0,N.jsx)(`legend`,{className:`sr-only`,children:`Install for`}),(0,N.jsxs)(`label`,{children:[(0,N.jsx)(`input`,{type:`radio`,name:`pi-package-scope`,checked:o===`user`,onChange:()=>s(`user`)}),` all projects`]}),(0,N.jsxs)(`label`,{children:[(0,N.jsx)(`input`,{type:`radio`,name:`pi-package-scope`,checked:o===`project`,onChange:()=>s(`project`)}),` this project only (`,e.projectName,`)`]})]}),(0,N.jsxs)(`div`,{className:`mt-2 flex justify-end gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:h,className:`rounded px-2 py-0.5 hover:bg-zinc-100 dark:hover:bg-zinc-700`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`submit`,disabled:t||!p.name,className:NW.replace(`w-16 `,``),children:`Install…`})]}),(0,N.jsx)(`p`,{className:`mt-1 min-h-[1rem] ${g?`text-amber-700 dark:text-amber-400`:`text-zinc-500 dark:text-zinc-400`}`,role:g?`alert`:`status`,children:g??(m?.status===`pending`?`looking up ${m.name}…`:``)})]})}function VW({reasons:e,canRestart:t,restarting:n,onRestart:r}){let[i,a]=(0,v.useState)(!1);return e.length===0?null:(0,N.jsxs)(`div`,{className:`mt-3 rounded border border-sky-200 bg-sky-50 p-2 text-xs text-sky-900 dark:border-sky-900 dark:bg-sky-950/40 dark:text-sky-200`,"data-testid":`restart-needed`,children:[(0,N.jsxs)(`p`,{children:[`Waiting on a restart to take effect: `,e.join(`, `),`.`]}),t?n?(0,N.jsx)(`p`,{className:`mt-1`,children:`Restarting pi-outpost…`}):i?(0,N.jsxs)(`div`,{className:`mt-1`,children:[(0,N.jsx)(`p`,{children:`pi-outpost stops and starts again in the same terminal. Every open window reconnects by itself, and conversations are kept.`}),(0,N.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>{a(!1),r()},className:`rounded bg-sky-700 px-2 py-0.5 text-white hover:bg-sky-800`,children:`Restart now`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>a(!1),className:`rounded px-2 py-0.5 hover:bg-sky-100 dark:hover:bg-sky-900/50`,children:`Cancel`})]})]}):(0,N.jsx)(`button`,{type:`button`,onClick:()=>a(!0),className:`mt-1 rounded border border-sky-300 px-2 py-0.5 hover:bg-sky-100 dark:border-sky-700 dark:hover:bg-sky-900/50`,children:`Restart pi-outpost`}):null]})}var HW=30,UW={display:`-webkit-box`,WebkitLineClamp:2,WebkitBoxOrient:`vertical`,overflow:`hidden`};function WW({skills:e,groups:t,enabled:n,onChange:r,disabled:i=!1,bound:a}){let[o,s]=(0,v.useState)(()=>e.length>40?new Set(e.filter(e=>n.has(e.relativePath)).map(e=>e.group)):new Set(t.map(e=>e.path))),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),f=c.trim().toLocaleLowerCase(),p=f!==``||u,m=e=>(!u||n.has(e.relativePath))&&(!f||`${e.name} ${e.relativePath} ${e.description??``}`.toLocaleLowerCase().includes(f)),h=new Map;for(let t of e)h.set(t.group,[...h.get(t.group)??[],t]);let g=e.filter(e=>n.has(e.relativePath)).length,_=p?e.filter(m).length:e.length,y=(e,t)=>{let i=new Set(n);for(let n of e)t?i.add(n.relativePath):i.delete(n.relativePath);r(i)},b=e=>{let t=new Set(n);t.has(e)?t.delete(e):t.add(e),r(t)},x=e=>s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,N.jsxs)(`section`,{className:`rounded-xl border border-zinc-200 p-4 dark:border-zinc-800`,"aria-label":`Collection skills`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,N.jsxs)(`h3`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:[`Skills `,(0,N.jsxs)(`span`,{className:`font-normal text-zinc-500`,children:[`· `,g,` of `,e.length,` on`]})]}),(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,disabled:i||g===e.length,onClick:()=>y(e,!0),className:`rounded-md border px-2.5 py-1 text-xs disabled:opacity-50`,children:`All on`}),(0,N.jsx)(`button`,{type:`button`,disabled:i||g===0,onClick:()=>y(e,!1),className:`rounded-md border px-2.5 py-1 text-xs disabled:opacity-50`,children:`All off`})]})]}),a?(0,N.jsx)(`p`,{className:`mt-2 rounded border border-amber-200 bg-amber-50 p-2 text-xs text-amber-800`,children:a.kind===`count`?`This repository holds more skills than the ${a.limit} listed here.`:`Folders deeper than ${a.limit} levels were not searched for skills.`}):null,e.length>0?(0,N.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`input`,{type:`search`,"aria-label":`Search skills`,placeholder:`Search skills by name or folder`,value:c,onChange:e=>l(e.target.value),className:`min-w-0 flex-1 rounded-md border bg-transparent px-2.5 py-1 text-xs`}),(0,N.jsxs)(`button`,{type:`button`,"aria-pressed":u,onClick:()=>d(e=>!e),className:`rounded-md px-2.5 py-1 text-xs ${u?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:[`Only on (`,g,`)`]})]}):null,!p&&g>0&&g<=HW?(0,N.jsxs)(`div`,{role:`region`,"aria-label":`Skills that are on`,className:`mt-3 rounded-lg border border-emerald-200 bg-emerald-50/60 p-2 dark:border-emerald-900 dark:bg-emerald-950/30`,children:[(0,N.jsx)(`p`,{className:`px-1 text-[11px] font-medium text-emerald-800 dark:text-emerald-300`,children:`Turned on`}),(0,N.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.filter(e=>n.has(e.relativePath)).map(e=>(0,N.jsxs)(`li`,{className:`flex items-start justify-between gap-2 px-1`,children:[(0,N.jsxs)(`span`,{className:`min-w-0 text-xs`,children:[(0,N.jsx)(`span`,{className:`font-medium text-zinc-800 dark:text-zinc-100`,children:e.name}),` `,(0,N.jsx)(`span`,{className:`font-mono text-[11px] text-zinc-500`,children:e.group||`(repository root)`}),(0,N.jsx)(GW,{skill:e,checked:!0})]}),(0,N.jsx)(`button`,{type:`button`,"aria-label":`Turn off ${e.name} (${e.relativePath})`,disabled:i,onClick:()=>b(e.relativePath),className:`shrink-0 rounded border bg-white px-2 py-0.5 text-[11px] disabled:opacity-50 dark:bg-zinc-900`,children:`Turn off`})]},e.relativePath))})]}):null,e.length===0?(0,N.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:`This repository holds no skills.`}):null,p&&_===0?(0,N.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:u&&!f?`No skill is on.`:`No skill matches.`}):null,(0,N.jsx)(`ul`,{className:`mt-3 space-y-2`,children:t.map(e=>{let t=h.get(e.path)??[],r=p?t.filter(m):t;if(p&&r.length===0)return null;let a=r.filter(e=>n.has(e.relativePath)).length,s=p||o.has(e.path);return(0,N.jsxs)(`li`,{className:`rounded-lg border border-zinc-100 dark:border-zinc-800`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2`,children:[(0,N.jsxs)(`button`,{type:`button`,"aria-expanded":s,onClick:()=>x(e.path),className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,N.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs text-zinc-400`,children:s?`▾`:`▸`}),(0,N.jsx)(`span`,{className:`truncate font-mono text-xs font-medium text-zinc-700 dark:text-zinc-200`,children:e.label}),(0,N.jsxs)(`span`,{className:`shrink-0 text-[11px] text-zinc-500`,children:[a,`/`,r.length,` on`]})]}),(0,N.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,N.jsx)(`button`,{type:`button`,"aria-label":`All on in ${e.label}`,disabled:i||a===r.length,onClick:()=>y(r,!0),className:`rounded border px-2 py-0.5 text-[11px] disabled:opacity-50`,children:`All on`}),(0,N.jsx)(`button`,{type:`button`,"aria-label":`All off in ${e.label}`,disabled:i||a===0,onClick:()=>y(r,!1),className:`rounded border px-2 py-0.5 text-[11px] disabled:opacity-50`,children:`All off`})]})]}),s?(0,N.jsx)(`ul`,{className:`space-y-1 border-t border-zinc-100 px-3 py-2 dark:border-zinc-800`,children:r.map(e=>{let t=n.has(e.relativePath);return(0,N.jsx)(`li`,{children:(0,N.jsxs)(`label`,{className:`flex items-start gap-2 rounded px-1 py-1 ${i?`opacity-60`:`cursor-pointer hover:bg-zinc-50 dark:hover:bg-zinc-800/60`}`,children:[(0,N.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":t,"aria-label":`${e.name} (${e.relativePath})`,checked:t,disabled:i,onChange:()=>b(e.relativePath),className:`mt-0.5`}),(0,N.jsxs)(`span`,{className:`min-w-0`,children:[(0,N.jsx)(`span`,{className:`block truncate text-sm text-zinc-800 dark:text-zinc-100`,children:e.name}),e.description?(0,N.jsx)(`span`,{title:e.description,style:UW,className:`text-[11px] text-zinc-500`,children:e.description}):null,(0,N.jsx)(GW,{skill:e,checked:t})]})]})},e.relativePath)})}):null]},e.path)})})]})}function GW({skill:e,checked:t}){return t===(e.state!==`off`)?e.state===`on-loaded`?(0,N.jsx)(`span`,{className:`block text-[11px] text-emerald-700 dark:text-emerald-400`,children:`Loaded`}):e.state===`on-not-loaded`?(0,N.jsxs)(`span`,{className:`block text-[11px] text-amber-700 dark:text-amber-400`,children:[`Not loaded — `,e.reason]}):e.state===`on-missing`?(0,N.jsxs)(`span`,{className:`block text-[11px] text-rose-700 dark:text-rose-400`,children:[`Missing — `,e.reason]}):null:(0,N.jsx)(`span`,{className:`block text-[11px] font-medium text-sky-700 dark:text-sky-300`,children:t?`Pending: on`:`Pending: off`})}function KW(e,t){return[...new Set(e.map(e=>e.group))].sort().map(e=>({path:e,label:e||t}))}function qW(e){return e.skills.filter(e=>e.state!==`off`).map(e=>e.relativePath)}function JW(e,t){let n=new Set(e),r=new Set(t);return n.size===r.size&&[...n].every(e=>r.has(e))}function YW(e,t){if(t.status===`loading`)return`Removing ${e}…`;if(t.status===`error`)return t.message??`Could not remove ${e}`;let n=t.result;return n?n.status===`removed`?`Removed ${e} and deleted ${n.path}.`:n.status===`removed-files-kept`?`Removed ${e}. ${n.reason??`Its files were kept`} (${n.path}).`:`Removed ${e}, but not every file could be deleted${n.reason?` — ${n.reason}`:``}. What remains is at ${n.path}.`:`Removed ${e}.`}var XW={unchecked:`Not checked`,checking:`Checking…`,current:`Up to date`,updateable:`Update available`,dirty:`Local changes`,detached:`Detached HEAD`,ahead:`Local branch ahead`,diverged:`Histories diverged`,"no-upstream":`No upstream`,locked:`Locked`,busy:`Workspace busy`,unavailable:`Unavailable`,failed:`Check failed`};function ZW(e){if(!e)return[];let t=new Map(e.resources.map(e=>[e.id,e])),n=new Set(e.repositories.flatMap(e=>e.resourceIds)),r=e.repositories.map(e=>({id:e.id,name:e.name,path:e.path,repository:e,resources:e.resourceIds.flatMap(e=>t.get(e)?[t.get(e)]:[])})),i=e.resources.filter(e=>!n.has(e.id)),a=i.filter(e=>e.unavailableReason),o=i.filter(e=>!e.unavailableReason);return o.length&&r.push({id:`local`,name:`Local and built in`,reason:`Not backed by an updateable Git repository`,resources:o}),a.length&&r.push({id:`unavailable`,name:`Provenance unavailable`,reason:`The active runtime did not report enough filesystem provenance`,resources:a}),r}function QW(e){let t=e.length;for(;t>0&&(e[t-1]===`/`||e[t-1]===`\\`);)--t;return t===e.length?e:e.slice(0,t)}function $W(e){let t=QW(e),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n<=0?`/`:t.slice(0,n)}function eG(e,t){let n=QW(t),r=Math.max(n.lastIndexOf(`/`),n.lastIndexOf(`\\`)),i=r>=0?n.slice(r+1):n;return`${QW(e)}/${i||`agent-resources`}`}function tG({kind:e,resources:t,removalLocked:n=!1,onRemove:r}){return(0,N.jsxs)(`section`,{className:`rounded-xl border border-zinc-200 p-4 dark:border-zinc-800`,children:[(0,N.jsxs)(`h3`,{className:`flex items-center justify-between text-sm font-semibold capitalize text-zinc-800 dark:text-zinc-200`,children:[(0,N.jsxs)(`span`,{children:[e,`s`]}),(0,N.jsx)(`span`,{className:`text-xs font-normal text-zinc-400`,children:t.length})]}),t.length===0?(0,N.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:`None in this group`}):(0,N.jsx)(`ul`,{className:`mt-3 space-y-2`,children:t.map(e=>(0,N.jsxs)(`li`,{className:`rounded-lg bg-zinc-50 px-3 py-2 dark:bg-zinc-800/70`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,N.jsx)(`p`,{className:`truncate text-sm font-medium text-zinc-700 dark:text-zinc-200`,children:e.name}),e.userRoot&&!n?(0,N.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.userRoot}`,onClick:()=>r(e),className:`text-xs text-zinc-500 hover:text-red-600`,children:`Remove`}):null]}),(0,N.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[11px] text-zinc-400`,title:e.path,children:e.path??e.unavailableReason??`Path unavailable`}),e.kind===`extension`&&e.userRoot&&e.userRoot!==e.path?(0,N.jsxs)(`p`,{className:`mt-0.5 truncate font-mono text-[11px] text-zinc-500`,title:e.userRoot,children:[(0,N.jsx)(`span`,{children:`Folder: `}),(0,N.jsx)(`span`,{children:e.userRoot})]}):null]},e.id))})]})}function nG({preview:e,busy:t,error:n,onApply:r,onCancel:i}){let[a,o]=(0,v.useState)(()=>new Set(e.roots.filter(e=>!e.locked).map(e=>`${e.kind}:${e.path}`))),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(()=>new Set),d=e.mode===`collection`,f=(0,v.useMemo)(()=>e.skills.map(e=>({...e,state:`off`})),[e.skills]),p=(0,v.useMemo)(()=>KW(e.skills,e.repositoryName),[e.skills,e.repositoryName]),m=e.roots.filter(e=>e.kind===`extension`&&a.has(`extension:${e.path}`)),h=m.length>0&&!s,g=t||!d&&a.size===0||h,_=()=>{let t=m.map(e=>e.path);d?r([],t,[...l]):r(e.roots.filter(e=>e.kind===`skill`&&a.has(`skill:${e.path}`)).map(e=>e.path),t)},y=e=>{c(!1),o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,N.jsxs)(`div`,{className:`space-y-3`,"data-testid":`resource-preview`,children:[(0,N.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsx)(`h3`,{className:`truncate text-xl font-semibold text-zinc-900 dark:text-zinc-100`,children:e.repositoryName}),(0,N.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[11px] text-zinc-500`,title:e.repositoryPath,children:e.repositoryPath})]}),(0,N.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:i,className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,disabled:g,onClick:_,className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs font-medium text-white disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-900`,children:t?`Saving…`:`Save`})]})]}),h?(0,N.jsx)(`p`,{className:`text-xs text-amber-700`,children:`Confirm the extension warning below to save.`}):null,n?(0,N.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:n}):null,d?(0,N.jsx)(WW,{skills:f,groups:p,enabled:l,onChange:u,disabled:t,...e.bound?{bound:e.bound}:{}}):null,e.roots.map(e=>{let t=`${e.kind}:${e.path}`;return(0,N.jsxs)(`label`,{className:`flex items-start gap-2 rounded border p-2 ${e.locked?`opacity-50`:`cursor-pointer`}`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:a.has(t),disabled:e.locked,onChange:()=>y(t)}),(0,N.jsxs)(`span`,{children:[(0,N.jsxs)(`span`,{className:`block text-sm`,children:[e.name,` · `,e.kind]}),(0,N.jsx)(`span`,{className:`font-mono text-[11px] text-zinc-500`,children:e.path}),e.locked?(0,N.jsx)(`span`,{className:`block text-xs text-amber-700`,children:`Extension paths are locked`}):null]})]},t)}),m.length>0?(0,N.jsxs)(`label`,{className:`flex gap-2 rounded-md border border-amber-300 bg-amber-50 p-3 text-xs text-amber-900`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked)}),(0,N.jsx)(`span`,{children:`Extensions execute code with the agent's privileges. I trust the selected extension roots in this repository.`})]}):null]})}function rG(e){let t=(0,v.useRef)(null),n=(0,v.useRef)(e.onClose),r=(0,v.useRef)(!1),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(`all`),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(`skill`),[y,b]=(0,v.useState)(``),[x,S]=(0,v.useState)(!1),[C,w]=(0,v.useState)(``),[T,E]=(0,v.useState)(``),[D,O]=(0,v.useState)(!1),[ee,te]=(0,v.useState)(``),[k,ne]=(0,v.useState)(null),[A,re]=(0,v.useState)({}),[j,ie]=(0,v.useState)(null),[ae,oe]=(0,v.useState)(null),se=(0,v.useMemo)(()=>ZW(e.inventory),[e.inventory]),ce=(0,v.useMemo)(()=>{let e=o.trim().toLocaleLowerCase();return se.flatMap(t=>{let n=`repository`in t?t.repository.collection:void 0,r=n?t.resources.filter(e=>e.kind!==`skill`):t.resources,i=c===`all`?r:r.filter(e=>e.kind===c),a=n&&c!==`extension`?n.skills:[],o=i.length+a.length;if(o===0&&!(n&&c===`all`)||u&&(!(`repository`in t)||![`updateable`,`dirty`,`failed`,`unavailable`,`busy`].includes(t.repository.assessment.status)))return[];let s=`${t.name} ${`path`in t?t.path??``:``} ${i.map(e=>`${e.name} ${e.path??``}`).join(` `)} ${a.map(e=>`${e.name} ${e.relativePath}`).join(` `)}`.toLocaleLowerCase(),l=n?n.skills.filter(e=>e.state!==`off`).length:void 0;return!e||s.includes(e)?[{...t,resources:i,count:o,...l===void 0?{}:{onCount:l}}]:[]})},[se,u,c,o]),le=ce.find(e=>e.id===i)??ce[0]??null;if((0,v.useEffect)(()=>{n.current=e.onClose},[e.onClose]),(0,v.useEffect)(()=>{re(t=>{let n={},r=!1;for(let[i,a]of Object.entries(t)){let t=e.inventory?.repositories.find(e=>e.id===i)?.collection;!t||JW(a,qW(t))?r=!0:n[i]=a}return r?n:t})},[e.inventory]),(0,v.useEffect)(()=>{e.open&&t.current?.focus()},[e.open]),(0,v.useEffect)(()=>{if(!e.open)return;let t=e=>{e.key===`Escape`&&n.current()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e.open]),(0,v.useEffect)(()=>{let t=e.operations.clonePath;t?.status===`ready`&&t.path&&!D&&E(t.path)},[D,e.operations.clonePath]),(0,v.useEffect)(()=>{e.operations.enrollment?.status===`ready`&&p(null)},[e.operations.enrollment]),(0,v.useEffect)(()=>{e.applyState?.status===`applying`?r.current=!0:r.current&&e.applyState===null&&(r.current=!1,p(null),h(null),S(!1))},[e.applyState]),!e.open)return null;let ue=le&&`repository`in le?le.repository:null,de=ue?e.operations.updates[ue.id]:void 0,fe=ue?.assessment,M=fe?.status===`updateable`&&fe.token&&fe.localRevision&&fe.upstreamRevision,pe=()=>{let t=y.trim();t&&(g===`skill`?e.onUpdateConfig({userSkillPaths:[...new Set([...e.userSkillPaths,t])]}):e.onUpdateConfig({userExtensionPaths:[...new Set([...e.userExtensionPaths,t])]}))},me=t=>{t.userRoot&&(t.kind===`skill`?e.onUpdateConfig({userSkillPaths:e.userSkillPaths.filter(e=>e!==t.userRoot)}):e.onUpdateConfig({userExtensionPaths:e.userExtensionPaths.filter(e=>e!==t.userRoot)}))},he=(t,n=!1)=>{let r=t.assessment;r.token&&r.localRevision&&r.upstreamRevision&&e.onUpdate(t.id,r.token,r.localRevision,r.upstreamRevision,n)},ge=ue?.collection,P=ge?qW(ge):[],_e=new Set(ue&&A[ue.id]?A[ue.id]:P),ve=ge?[...new Set([..._e,...P])].filter(e=>_e.has(e)!==P.includes(e)).length:0,ye=ue?e.operations.skills?.[ue.id]:void 0,be=e=>{if(!ue)return;let t=ue.id;re(n=>{let r={...n};return JW(e,P)?delete r[t]:r[t]=[...e],r})},xe=()=>{if(!ue)return;let e=ue.id;re(t=>{let n={...t};return delete n[e],n})},Se=()=>{if(!ue||!ge)return;let t=new Set(ge.skills.filter(e=>e.state!==`on-missing`).map(e=>e.relativePath));e.onSetSkills(ue.id,[..._e].filter(e=>t.has(e)))},Ce=ae?e.operations.removals?.[ae.id]:void 0,we=Ce?.status===`error`||Ce?.result?.status===`removed-delete-failed`;return(0,N.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/45 p-4`,role:`presentation`,onMouseDown:t=>{t.currentTarget===t.target&&e.onClose()},children:[(0,N.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`agent-resources-title`,className:`flex h-[min(760px,92vh)] w-[min(1120px,96vw)] flex-col overflow-hidden rounded-2xl border border-zinc-200 bg-white shadow-2xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,N.jsxs)(`header`,{className:`flex items-center justify-between border-b border-zinc-200 px-5 py-4 dark:border-zinc-800`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h2`,{id:`agent-resources-title`,className:`text-lg font-semibold text-zinc-900 dark:text-zinc-100`,children:`Agent resources`}),(0,N.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Skills and extensions, grouped by repository`})]}),(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,disabled:e.operations.refresh?.status===`loading`,onClick:()=>e.onRefresh(),className:`rounded-md border px-3 py-1.5 text-xs disabled:opacity-50`,children:`Refresh all`}),(0,N.jsx)(`button`,{ref:t,type:`button`,"aria-label":`Close agent resources`,onClick:e.onClose,className:`rounded-md border px-2 py-1 text-sm`,children:`✕`})]})]}),(0,N.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[300px_1fr]`,children:[(0,N.jsxs)(`aside`,{className:`flex min-h-0 flex-col border-r border-zinc-200 bg-zinc-50/80 p-3 dark:border-zinc-800 dark:bg-zinc-950/40`,children:[(0,N.jsx)(`input`,{"aria-label":`Search resources`,value:o,onChange:e=>s(e.target.value),placeholder:`Search repositories or resources`,className:`rounded-md border bg-white px-3 py-2 text-xs dark:bg-zinc-900`}),(0,N.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[[`all`,`skill`,`extension`].map(e=>(0,N.jsx)(`button`,{type:`button`,"aria-pressed":c===e,onClick:()=>l(e),className:`rounded px-2 py-1 text-[11px] ${c===e?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:e===`all`?`All`:`${e}s`},e)),(0,N.jsx)(`button`,{type:`button`,"aria-pressed":u,onClick:()=>d(e=>!e),className:`rounded px-2 py-1 text-[11px] ${u?`bg-amber-600 text-white`:`border`}`,children:`Needs attention`})]}),(0,N.jsxs)(`div`,{className:`mt-3 min-h-0 flex-1 space-y-1 overflow-y-auto`,children:[ce.map(e=>(0,N.jsxs)(`button`,{type:`button`,onClick:()=>a(e.id),className:`w-full rounded-lg px-3 py-2.5 text-left ${le?.id===e.id?`bg-white shadow-sm ring-1 ring-zinc-200 dark:bg-zinc-800 dark:ring-zinc-700`:`hover:bg-white/70 dark:hover:bg-zinc-900`}`,children:[(0,N.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-sm font-medium`,children:[(0,N.jsx)(`span`,{className:`truncate`,children:e.name}),(0,N.jsx)(`span`,{className:`shrink-0 text-xs text-zinc-400`,children:e.onCount===void 0?e.count??e.resources.length:`${e.onCount} on · ${e.count}`})]}),(0,N.jsx)(`span`,{className:`mt-1 block text-xs text-zinc-500`,children:`repository`in e?XW[e.repository.assessment.status]:e.reason})]},e.id)),ce.length===0?(0,N.jsx)(`p`,{className:`px-2 py-4 text-xs text-zinc-500`,children:`No matching resources`}):null]}),(0,N.jsxs)(`div`,{className:`mt-3 grid gap-2 border-t pt-3`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>{S(!1),p(`local`),h(`local`),e.onBrowseServerPath(y||`/`)},className:`rounded-md border bg-white px-3 py-2 text-xs font-medium dark:bg-zinc-900`,children:`Add local folder…`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>p(`git`),className:`rounded-md bg-zinc-900 px-3 py-2 text-xs font-medium text-white dark:bg-zinc-100 dark:text-zinc-900`,children:`Add Git repository…`})]})]}),(0,N.jsxs)(`main`,{className:`min-w-0 overflow-y-auto p-6`,children:[ae&&Ce?(0,N.jsxs)(`div`,{role:we?`alert`:`status`,className:`mb-4 flex items-start justify-between gap-3 rounded-lg border p-3 text-sm ${we?`border-rose-200 bg-rose-50 text-rose-800`:`border-zinc-200 bg-zinc-50 text-zinc-700`}`,children:[(0,N.jsx)(`p`,{className:`min-w-0 break-words`,children:YW(ae.name,Ce)}),Ce.status===`loading`?null:(0,N.jsx)(`button`,{type:`button`,onClick:()=>oe(null),className:`shrink-0 text-xs underline`,children:`Dismiss`})]}):null,f===`local`?(0,N.jsxs)(`div`,{className:`max-w-xl space-y-4`,"data-testid":`add-local-folder`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Add local folder`}),(0,N.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Choose an existing folder on the server and how the agent should load it.`})]}),(0,N.jsx)(`div`,{className:`flex gap-2`,children:[`skill`,`extension`].map(t=>(0,N.jsx)(`button`,{type:`button`,"aria-pressed":g===t,disabled:t===`extension`&&e.extensionLock,onClick:()=>{_(t),S(!1)},className:`rounded-md px-3 py-1.5 text-xs ${g===t?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:t===`skill`?`Skill folder`:`Extension folder`},t))}),(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsx)(`input`,{"aria-label":`Local resource folder`,value:y,onChange:e=>{S(!1),b(e.target.value)},className:`min-w-0 flex-1 rounded-md border bg-transparent px-3 py-2 text-sm`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>{h(`local`),e.onBrowseServerPath(y||`/`)},className:`rounded-md border px-3 text-xs`,children:`Browse…`})]}),m===`local`?(0,N.jsx)(vW,{label:`Choose a local resource folder`,browse:e.serverBrowse,onBrowse:e.onBrowseServerPath,onSelect:t=>{S(!1),b(t),h(null),e.onCloseServerBrowser()},onCancel:()=>{h(null),e.onCloseServerBrowser()}}):null,g===`extension`?(0,N.jsxs)(`label`,{className:`flex gap-2 rounded-md border border-amber-300 bg-amber-50 p-3 text-xs text-amber-900`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked)}),(0,N.jsx)(`span`,{children:`Extensions execute code with the agent's privileges. I trust every extension in this folder.`})]}):null,e.extensionLock?(0,N.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Extension paths are locked by this deployment.`}):null,e.applyState?.status===`error`?(0,N.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.applyState.message}):null,(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>{S(!1),p(null),h(null),e.onCloseServerBrowser()},className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,disabled:!y.trim()||e.applyState?.status===`applying`||g===`extension`&&(!x||e.extensionLock),onClick:pe,className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:e.applyState?.status===`applying`?`Applying…`:`Add folder`})]})]}):f===`git`?(0,N.jsx)(`div`,{className:`max-w-2xl space-y-4`,"data-testid":`add-git-repository`,children:e.operations.preview?.status===`ready`&&e.operations.preview.preview?(0,N.jsx)(nG,{onCancel:()=>{p(null),h(null),e.onCloseServerBrowser()},preview:e.operations.preview.preview,busy:e.operations.enrollment?.status===`loading`,error:e.operations.enrollment?.status===`error`?e.operations.enrollment.message:void 0,onApply:(t,n,r)=>r?e.onEnrollRepository(e.operations.preview.preview.token,t,n,r):e.onEnrollRepository(e.operations.preview.preview.token,t,n)}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Add Git repository`}),(0,N.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Clone it to a local folder, then choose what to turn on.`})]}),(0,N.jsxs)(`label`,{className:`block`,children:[(0,N.jsx)(`span`,{className:`text-xs font-medium`,children:`Repository address`}),(0,N.jsx)(`input`,{"aria-label":`Repository address`,value:C,onChange:e=>w(e.target.value),onBlur:()=>{let t=C.trim();t&&(O(!1),te(t),e.onSuggestClonePath(C))},placeholder:`https://github.com/team/resources.git`,className:`mt-1 w-full rounded-md border bg-transparent px-3 py-2 text-sm`})]}),(0,N.jsxs)(`label`,{className:`block`,children:[(0,N.jsx)(`span`,{className:`text-xs font-medium`,children:`Local folder`}),(0,N.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,N.jsx)(`input`,{"aria-label":`Local clone folder`,value:T,onChange:e=>{O(!0),E(e.target.value)},placeholder:`/path/to/resource-repositories/team-resources-ab12cd`,className:`min-w-0 flex-1 rounded-md border bg-transparent px-3 py-2 text-sm`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>{h(`clone-parent`),e.onBrowseServerPath($W(T))},className:`rounded-md border px-3 text-xs`,children:`Choose parent…`})]})]}),e.operations.clonePath?.status===`loading`?(0,N.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Suggesting a managed folder…`}):null,e.operations.clonePath?.status===`error`&&C.trim()===ee?(0,N.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.operations.clonePath.message}):null,m===`clone-parent`?(0,N.jsx)(vW,{label:`Choose the clone's parent folder`,browse:e.serverBrowse,onBrowse:e.onBrowseServerPath,onSelect:t=>{E(eG(t,T)),h(null),e.onCloseServerBrowser()},onCancel:()=>{h(null),e.onCloseServerBrowser()}}):null,e.operations.preview?.status===`error`?(0,N.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.operations.preview.message}):null,(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>{p(null),h(null),e.onCloseServerBrowser()},className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,disabled:!C.trim()||!T.trim()||e.operations.preview?.status===`loading`,onClick:()=>e.onCloneRepository(C,T),className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:e.operations.preview?.status===`loading`?`Cloning…`:`Clone and inspect`})]})]})}):le?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`h3`,{className:`text-xl font-semibold`,children:le.name}),ue?(0,N.jsx)(`span`,{className:`rounded-full border px-2 py-0.5 text-[11px]`,children:XW[ue.assessment.status]}):null]}),(0,N.jsx)(`p`,{className:`mt-1 truncate font-mono text-xs text-zinc-500`,children:`repository`in le?le.path:le.reason}),fe?.branch?(0,N.jsxs)(`p`,{className:`mt-1 text-xs text-zinc-400`,children:[fe.branch,fe.upstream?` → ${fe.upstream}`:``]}):null,ue?.removal&&!ue.removal.allowed?(0,N.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:ue.removal.reason}):null]}),ue?(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[ue.removal?.allowed?(0,N.jsx)(`button`,{type:`button`,disabled:e.operations.removals?.[ue.id]?.status===`loading`,onClick:()=>ie(ue),className:`rounded-md border border-red-200 px-3 py-1.5 text-xs text-red-700 disabled:opacity-50 dark:border-red-900 dark:text-red-400`,children:`Remove repository`}):null,(0,N.jsx)(`button`,{type:`button`,disabled:e.operations.refresh?.status===`loading`,onClick:()=>e.onRefresh(ue.id),className:`rounded-md border px-3 py-1.5 text-xs`,children:`Check`}),M||de?.status===`loading`?(0,N.jsx)(`button`,{type:`button`,disabled:de?.status===`loading`,onClick:()=>ue.containsExtensions?ne(ue):he(ue),className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:de?.status===`loading`?`Updating…`:`Update repository`}):null]}):null]}),fe?.reason?(0,N.jsxs)(`div`,{className:`mt-5 rounded-lg border p-3 text-sm ${fe.status===`dirty`?`border-rose-200 bg-rose-50 text-rose-800`:`border-zinc-200 bg-zinc-50 text-zinc-700`}`,children:[fe.reason,fe.status===`dirty`?(0,N.jsx)(`p`,{className:`mt-1 text-xs`,children:`Review and resolve these local changes in an external terminal, then check again. This updater never commits, stashes, discards, rebases, or merges them.`}):null]}):null,fe?.hasSubmodules?(0,N.jsx)(`p`,{className:`mt-3 rounded border border-amber-200 bg-amber-50 p-2 text-xs text-amber-800`,children:`This repository declares submodules. Their working trees will not be initialized or updated.`}):null,de?.status===`ready`?(0,N.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-zinc-600`,children:de.result?.status===`updated`&&de.result.reloads.some(e=>e.status===`restart-required`)?`Repository updated. Its skills are reloaded; its extension code runs after pi-outpost restarts — restart it from Settings.`:de.result?.status===`updated`?`Repository updated and runtimes reloaded.`:de.result?.status===`updated-reload-failed`?`Repository updated on disk, but at least one runtime failed to reload.`:de.result?.reason}):null,de?.status===`error`?(0,N.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-red-600`,children:de.message}):null,ge&&ue&&c!==`extension`?(0,N.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[ve>0||ye?.status===`loading`?(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-sky-200 bg-sky-50 px-3 py-2 text-xs text-sky-900 dark:border-sky-900 dark:bg-sky-950/40 dark:text-sky-200`,children:[(0,N.jsx)(`span`,{children:ye?.status===`loading`?`Applying…`:`${ve} pending change${ve===1?``:`s`} — applying replaces the session`}),(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,disabled:ye?.status===`loading`,onClick:xe,className:`rounded border bg-white px-2.5 py-1 disabled:opacity-50 dark:bg-zinc-900`,children:`Discard`}),(0,N.jsx)(`button`,{type:`button`,disabled:ye?.status===`loading`||ve===0,onClick:Se,className:`rounded bg-zinc-900 px-2.5 py-1 font-medium text-white disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-900`,children:`Apply`})]})]}):null,ye?.status===`error`?(0,N.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:ye.message}):null,(0,N.jsx)(WW,{skills:ge.skills,groups:ge.groups,enabled:_e,onChange:be,disabled:ye?.status===`loading`,...ge.bound?{bound:ge.bound}:{}},ue.id),le.resources.some(e=>e.kind===`extension`)?(0,N.jsx)(tG,{kind:`extension`,resources:le.resources.filter(e=>e.kind===`extension`),removalLocked:e.extensionLock,onRemove:me}):null]}):(0,N.jsxs)(`div`,{className:`mt-6 grid grid-cols-2 gap-4`,children:[(0,N.jsx)(tG,{kind:`skill`,resources:le.resources.filter(e=>e.kind===`skill`),onRemove:me}),(0,N.jsx)(tG,{kind:`extension`,resources:le.resources.filter(e=>e.kind===`extension`),removalLocked:e.extensionLock,onRemove:me})]})]}):(0,N.jsx)(`p`,{className:`text-sm text-zinc-500`,children:`No resources are reported by this runtime.`})]})]})]}),k?(0,N.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/55 p-4`,children:(0,N.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`extension-update-title`,className:`w-full max-w-md rounded-xl bg-white p-5 shadow-2xl dark:bg-zinc-900`,children:[(0,N.jsx)(`h3`,{id:`extension-update-title`,className:`font-semibold`,children:`Update executable extensions?`}),(0,N.jsxs)(`p`,{className:`mt-2 text-sm text-zinc-600 dark:text-zinc-300`,children:[k.name,` contains extensions that run with the agent's privileges. Confirm updating `,k.assessment.localRevision?.slice(0,8),` to `,k.assessment.upstreamRevision?.slice(0,8),`.`]}),(0,N.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>ne(null),className:`rounded border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>{he(k,!0),ne(null)},className:`rounded bg-amber-600 px-3 py-1.5 text-xs font-medium text-white`,children:`Confirm executable update`})]})]})}):null,j?(0,N.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/55 p-4`,children:(0,N.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`remove-repository-title`,"aria-describedby":`remove-repository-detail`,className:`w-full max-w-md rounded-xl bg-white p-5 shadow-2xl dark:bg-zinc-900`,children:[(0,N.jsxs)(`h3`,{id:`remove-repository-title`,className:`font-semibold`,children:[`Remove `,j.name,`?`]}),(0,N.jsx)(`p`,{id:`remove-repository-detail`,className:`mt-2 break-words text-sm text-zinc-600 dark:text-zinc-300`,children:j.removal?.deletesFiles?(0,N.jsxs)(N.Fragment,{children:[`This stops loading everything from `,j.name,` and deletes `,(0,N.jsx)(`span`,{className:`font-mono`,children:j.removal.path}),` from disk, with any local changes in it. This cannot be undone.`]}):(0,N.jsxs)(N.Fragment,{children:[`This stops loading everything from `,j.name,`. pi-outpost does not manage `,(0,N.jsx)(`span`,{className:`font-mono`,children:j.removal?.path??j.path}),`, so its files will be kept.`]})}),(0,N.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>ie(null),className:`rounded border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>{e.onRemoveRepository(j.id),oe({id:j.id,name:j.name}),ie(null)},className:`rounded bg-red-600 px-3 py-1.5 text-xs font-medium text-white`,children:j.removal?.deletesFiles?`Delete and remove`:`Remove repository`})]})]})}):null]})}var iG=`w-full rounded-md border border-zinc-300 bg-white px-3 py-2 text-sm text-zinc-800 placeholder:text-zinc-400 focus:border-zinc-400 focus:outline-none dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-100 dark:placeholder:text-zinc-600`,aG=`rounded-md border border-zinc-300 px-3 py-1.5 text-xs font-medium text-zinc-700 hover:bg-zinc-50 disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-800`;function oG({event:e}){switch(e.type){case`auth_url`:return(0,N.jsxs)(`div`,{"data-testid":`login-auth-url`,className:`space-y-1`,children:[(0,N.jsx)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:e.instructions??`Open this page to sign in:`}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`truncate text-sm text-sky-700 underline dark:text-sky-400`,children:e.url}),(0,N.jsx)(`button`,{type:`button`,className:aG,onClick:()=>void navigator.clipboard?.writeText(e.url),children:`Copy`})]})]});case`device_code`:return(0,N.jsxs)(`div`,{"data-testid":`login-device-code`,className:`space-y-1`,children:[(0,N.jsxs)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:[`Enter this code at`,` `,(0,N.jsx)(`a`,{href:e.verificationUri,target:`_blank`,rel:`noopener noreferrer`,className:`text-sky-700 underline dark:text-sky-400`,children:e.verificationUri}),`:`]}),(0,N.jsx)(`p`,{className:`select-all font-mono text-2xl tracking-widest text-zinc-900 dark:text-zinc-50`,children:e.userCode})]});case`info`:return(0,N.jsxs)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:[e.message,e.links?.map(e=>(0,N.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`ml-2 text-sky-700 underline dark:text-sky-400`,children:e.label??e.url},e.url))]});case`progress`:return(0,N.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:e.message})}}function sG({prompt:e,onAnswer:t}){let[n,r]=(0,v.useState)(``),i=e.type===`manual_code`&&/^http:\/\/(?:localhost|127\.0\.0\.1):1455\/auth\/callback\/?$/.test(e.placeholder??``);return e.type===`select`?(0,N.jsxs)(`div`,{"data-testid":`login-prompt`,className:`space-y-2`,children:[(0,N.jsx)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:e.message}),(0,N.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.options.map(e=>(0,N.jsx)(`button`,{type:`button`,className:aG,title:e.description,onClick:()=>t(e.id),children:e.label},e.id))})]}):(0,N.jsxs)(`div`,{"data-testid":`login-prompt`,className:`space-y-2`,children:[(0,N.jsxs)(`label`,{className:`block text-sm text-zinc-700 dark:text-zinc-200`,children:[e.type===`manual_code`?`${e.message} — or the whole address the browser was sent to`:e.message,(0,N.jsx)(`input`,{className:`${iG} mt-1`,type:e.type===`secret`?`password`:`text`,name:`provider-auth-response`,placeholder:e.placeholder,autoComplete:`off`,spellCheck:e.type!==`manual_code`,autoFocus:!0,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),n.trim()&&t(n.trim()))}})]}),i&&(0,N.jsx)(`p`,{className:`text-xs text-zinc-600 dark:text-zinc-300`,children:`If Pi Outpost runs on another computer, your browser may say it cannot connect to localhost. Copy the full address from that browser page and paste it above to finish signing in.`}),(0,N.jsx)(`button`,{type:`button`,className:aG,disabled:!n.trim(),onClick:()=>t(n.trim()),children:`Continue`})]})}function cG({login:e,providerName:t,onAnswer:n,onCancel:r,onDismiss:i}){return(0,N.jsxs)(`div`,{"data-testid":`login-flow`,className:`space-y-3 rounded-md border border-zinc-200 p-3 dark:border-zinc-700`,children:[(0,N.jsxs)(`p`,{className:`text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:[`Signing in to `,t]}),(0,N.jsxs)(`div`,{"aria-live":`polite`,"aria-atomic":`false`,children:[e.events.map((e,t)=>(0,N.jsx)(oG,{event:e},t)),e.prompt&&(0,N.jsx)(sG,{prompt:e.prompt.prompt,onAnswer:n},e.prompt.promptId),!e.done&&!e.prompt&&e.events.length===0&&(0,N.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:`Starting…`}),e.done?(0,N.jsxs)(`div`,{"data-testid":`login-done`,"data-ok":e.done.ok?`true`:`false`,className:`space-y-2`,children:[(0,N.jsx)(`p`,{className:`text-sm ${e.done.ok?`text-emerald-700 dark:text-emerald-400`:`text-red-700 dark:text-red-400`}`,children:e.done.ok?`Signed in to ${t}.`:e.done.cancelled?`Sign-in cancelled.`:`Sign-in failed: ${e.done.message??`unknown error`}`}),(0,N.jsx)(`button`,{type:`button`,className:aG,onClick:i,children:`Close`})]}):(0,N.jsx)(`button`,{type:`button`,className:aG,onClick:r,children:`Cancel`})]})]})}function lG(e){return[...e].sort((e,t)=>e.localeCompare(t))}function uG(e,t){return e===`models_json_key`?`This key is managed in models.json. Remove it from that provider configuration.`:e===`environment`?`This key comes from ${t??`the server environment`}. Remove it from there.`:`This key is managed by ${t??e??`the provider runtime`}. Remove it from that source.`}function dG(e,t){return e===`models_json_key`?`models.json`:t??e}function fG({credentials:e,login:t,onStartLogin:n,onAnswerLogin:r,onCancelLogin:i,onDismissLogin:a,onLogoutProvider:o,extensionPaths:s,configuredExtensionPaths:c,userExtensionPaths:l,extensionLock:u,piPackages:d=null,piPackageUpdate:f=null,piPackageEdits:p,canRestartServer:m=!1,serverRestarting:h=!1,onCheckPiPackages:g,onUpdatePiPackage:_,onRestartServer:y,onRestartSession:b,restartNeeded:x=[],tools:S,commands:C,sandbox:w,showRoots:T=!0,gitUnavailable:E,userSkillPaths:D,serverBrowse:O,pickerBlocked:ee=!1,onPickerOpened:te,applyState:k,agentResources:ne=null,agentResourceOperations:A={clonePath:null,preview:null,enrollment:null,refresh:null,updates:{},skills:{},removals:{}},versions:re,onBrowseServerPath:j,onCloseServerBrowser:ie,onUpdateConfig:ae,onSuggestAgentResourceClonePath:oe=()=>{},onCloneAgentResourceRepository:se=()=>{},onEnrollAgentResourceRepository:ce=()=>{},onSetAgentResourceSkills:le=()=>{},onRemoveAgentResourceRepository:ue=()=>{},onRefreshAgentResourceRepositories:de=()=>{},onUpdateAgentResourceRepository:fe=()=>{}}){let[M,pe]=(0,v.useState)(!1),[me,he]=(0,v.useState)(!1),ge=(0,v.useRef)(new Map),[P,_e]=(0,v.useState)(!1),ve=(0,v.useRef)(null),[ye,be]=(0,v.useState)(``),[xe,Se]=(0,v.useState)(``),[Ce,we]=(0,v.useState)(!1),[Te,Ee]=(0,v.useState)(!1),[De,Oe]=(0,v.useState)(null),ke=(e,r)=>{if(t&&!t.done){i?.(),a?.();let e=ge.current.get(t.provider);e&&(e.open=!1)}else n?.(e,r)};(0,v.useEffect)(()=>{ee&&De!==null&&Oe(null)},[ee,De]);let Ae=oH(()=>{(M||De!==null)&&Re()}),je=S.filter(e=>e.active),Me=S.filter(e=>!e.active),Ne=C.filter(e=>e.source===`skill`),Pe=[...S].sort((e,t)=>e.name.localeCompare(t.name)||Number(t.active)-Number(e.active)),Fe=k?.status===`applying`,Ie=k?.status===`error`?k.message:null;(0,v.useEffect)(()=>{w&&(be(w.root),Se(w.writableRoot??``),we(w.allowWrite),Ee(w.allowBash))},[w]);let Le=(0,v.useRef)(!1);(0,v.useEffect)(()=>{Le.current&&k===null&&Re(),Le.current=Fe},[k,Fe]);function Re(){he(!1),pe(!1),Oe(null),ie()}function ze(e,t){te?.(),Oe(e),j(t.trim()||`/`)}function Be(e){De===`root`?be(e):De===`writableRoot`&&Se(e),Oe(null),ie()}let Ve=w!==null&&(ye!==w.root||(xe.trim()||void 0)!==(w.writableRoot||void 0)||Ce!==w.allowWrite||Te!==w.allowBash);function He(){w&&Ve&&ae({sandbox:{root:ye,allowWrite:Ce,allowBash:Te,writableRoot:xe.trim()||void 0}})}let Ue=T&&w?.rootEditable!==!1,We=De!==null&&!ee&&(0,N.jsx)(vW,{label:De===`root`?`Choose the sandbox root`:`Choose the writable root`,browse:O,onBrowse:j,onSelect:Be,onCancel:()=>{Oe(null),ie()}});return(0,N.jsxs)(`div`,{className:`relative`,ref:Ae,children:[(0,N.jsx)(`button`,{ref:ve,type:`button`,onClick:()=>{he(!1),M?Re():pe(!0)},title:`Settings`,"aria-label":`Settings`,className:`${uW} border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`⚙`}),M&&(0,N.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-[80vh] w-[380px] flex-col rounded-lg border border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,N.jsxs)(`div`,{className:`border-b border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:[me&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>he(!1),className:`mb-2 text-xs text-zinc-600 hover:underline dark:text-zinc-400`,children:`← Back to settings`}),(0,N.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:me?`Credits`:`Settings`})]}),(0,N.jsx)(`div`,{className:`min-h-0 overflow-y-auto p-4`,children:me?(0,N.jsx)(OW,{}):(0,N.jsxs)(N.Fragment,{children:[E&&(0,N.jsxs)(`section`,{className:`mb-4`,"data-testid":`git-unavailable`,children:[(0,N.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Version control`}),E.reason===`no-repository`?(0,N.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:`This project is not in a git repository.`}):(0,N.jsxs)(`div`,{className:`rounded border border-amber-300 bg-amber-50 px-2 py-1.5 dark:border-amber-900 dark:bg-amber-950/40`,children:[(0,N.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-300`,children:E.reason===`no-executable`?`Git is unavailable: its executable could not be run.`:`Git is unavailable: it refused this repository.`}),(0,N.jsx)(`p`,{className:`mt-1 break-all font-mono text-[11px] text-amber-700 dark:text-amber-400`,children:E.message}),E.reason===`no-executable`&&(0,N.jsxs)(`p`,{className:`mt-1 text-xs text-amber-700 dark:text-amber-400`,children:[`Install git, add it to PATH, or name it with `,(0,N.jsx)(`span`,{className:`font-mono`,children:`gitPath`}),` in the configuration.`]})]})]}),e&&(0,N.jsxs)(`details`,{className:`mb-4`,"data-testid":`accounts-panel`,children:[(0,N.jsxs)(`summary`,{className:`cursor-pointer text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:[`Accounts · `,(0,N.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:[e.providers.filter(e=>e.configured).length,` providers configured`]})]}),(0,N.jsxs)(`div`,{className:`mt-2`,children:[(0,N.jsx)(`ul`,{className:`space-y-2`,children:e.providers.map(n=>(0,N.jsx)(`li`,{className:`rounded border border-zinc-200 p-2 dark:border-zinc-700`,children:(0,N.jsxs)(`details`,{ref:e=>{e?ge.current.set(n.id,e):ge.current.delete(n.id)},"data-testid":`account-${n.id}`,children:[(0,N.jsxs)(`summary`,{className:`cursor-pointer`,children:[(0,N.jsx)(`span`,{className:`text-xs font-medium text-zinc-800 dark:text-zinc-200`,children:n.name}),(0,N.jsx)(`span`,{className:`ml-2 text-[11px] ${n.configured?`text-emerald-700 dark:text-emerald-400`:`text-zinc-500 dark:text-zinc-400`}`,children:n.configured?`${n.auth??`Authenticated`}${n.source?` · ${dG(n.source,n.label)}`:``}`:`Not signed in`})]}),(0,N.jsxs)(`div`,{className:`mt-2`,children:[n.configured&&n.auth===`api_key`&&n.source!==`stored`&&(0,N.jsx)(`p`,{className:`mb-2 text-[11px] text-zinc-500 dark:text-zinc-400`,children:uG(n.source,n.label)}),!e.locked&&(0,N.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[n.methods?.includes(`oauth`)&&(0,N.jsx)(`button`,{type:`button`,className:`rounded border px-2 py-1 text-[11px]`,onClick:()=>ke(n.id,`oauth`),children:`Sign in`}),n.methods?.includes(`api_key`)&&(0,N.jsx)(`button`,{type:`button`,className:`rounded border px-2 py-1 text-[11px]`,onClick:()=>ke(n.id,`api_key`),children:`API key`}),n.configured&&n.source===`stored`&&(0,N.jsx)(`button`,{type:`button`,className:`rounded border px-2 py-1 text-[11px]`,onClick:()=>o?.(n.id),children:n.auth===`api_key`?`Remove API key`:`Sign out`})]}),t?.provider===n.id&&(0,N.jsx)(`div`,{className:`mt-2`,children:(0,N.jsx)(cG,{login:t,providerName:n.name,onAnswer:e=>r?.(e),onCancel:()=>i?.(),onDismiss:()=>a?.()})})]})]})},n.id))}),e.locked&&(0,N.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500 dark:text-zinc-400`,children:`Credentials are locked by this server.`})]})]}),(0,N.jsxs)(`section`,{className:`mb-4`,children:[(0,N.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Agent resources`}),S.length===0?(0,N.jsx)(`p`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:`Tool inventory unavailable for this runtime`}):(0,N.jsxs)(`details`,{"data-testid":`tools-loaded`,children:[(0,N.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[je.length,` tools active`,Me.length?` · ${Me.length} inactive`:``]}),(0,N.jsx)(`ul`,{className:`mt-2 space-y-1`,children:Pe.map(e=>(0,N.jsxs)(`li`,{className:`flex justify-between rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,children:[(0,N.jsx)(`span`,{children:e.name}),(0,N.jsx)(`span`,{children:e.active?`active`:`inactive`})]},e.name))})]}),Ne.length===0?(0,N.jsx)(`p`,{className:`mt-2 text-xs text-zinc-600 dark:text-zinc-400`,children:`No skills loaded`}):(0,N.jsxs)(`details`,{className:`mt-2`,"data-testid":`skills-loaded`,children:[(0,N.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[Ne.length,` skills loaded`]}),(0,N.jsx)(`ul`,{className:`mt-2 space-y-1`,children:lG(Ne.map(e=>e.name)).map(e=>(0,N.jsx)(`li`,{className:`rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,children:e},e))})]}),(0,N.jsx)(`button`,{type:`button`,"aria-label":`Manage agent resources`,onClick:()=>{pe(!1),_e(!0)},className:`mt-3 w-full rounded-md border border-zinc-300 px-3 py-2 text-xs font-medium text-zinc-700 hover:bg-zinc-50 dark:border-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-800`,children:`Manage agent resources`})]}),(0,N.jsxs)(`section`,{className:`mb-4`,children:[(0,N.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Extensions`}),s===null?(0,N.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,"data-testid":`extensions-unknown`,children:`Not reported by this runtime`}):s.length===0?(0,N.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No extensions loaded`}):(0,N.jsxs)(`details`,{"data-testid":`extensions-loaded`,children:[(0,N.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[s.length,` `,s.length===1?`extension`:`extensions`,` loaded`]}),(0,N.jsx)(`ul`,{className:`mt-2 space-y-1`,children:lG(s).map(e=>(0,N.jsx)(`li`,{className:`truncate rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,title:e,children:e},e))})]}),c.length>0&&(0,N.jsxs)(`details`,{className:`mt-2`,"data-testid":`extensions-configured`,children:[(0,N.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[c.length,` configured by this deployment`]}),(0,N.jsx)(`p`,{className:`mt-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`Declared in the configuration file. They load either way, and nothing here can remove them.`}),(0,N.jsx)(`ul`,{className:`mt-1 space-y-1`,children:lG(c).map(e=>(0,N.jsx)(`li`,{className:`truncate rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,title:e,children:e},e))})]}),u?(0,N.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400 dark:text-zinc-500`,"data-testid":`extensions-locked`,children:`Extension paths and repository updates that contain extensions are locked by this deployment.`}):null,(0,N.jsx)(zW,{packages:d,update:f,locked:u,onCheck:()=>g?.(),onUpdate:e=>_?.(e),...p?{edits:p}:{}}),(0,N.jsx)(VW,{reasons:x,canRestart:m,restarting:h,onRestart:()=>y?.()})]}),w&&(0,N.jsxs)(`section`,{children:[(0,N.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:Ue?`Sandbox`:`Agent permissions`}),(0,N.jsxs)(`div`,{className:`space-y-3`,children:[!Ue&&(0,N.jsxs)(`p`,{"data-testid":`sandbox-project-root`,className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`This project is confined to its own folder,`,` `,(0,N.jsx)(`span`,{className:`break-all font-mono text-zinc-800 dark:text-zinc-200`,children:w.projectRoot??w.root}),`. Each open project is confined to its own. A change here applies to this project now, and to projects opened after.`]}),Ue&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`label`,{className:`block`,children:[(0,N.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Root `,w.locks?.root?(0,N.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,N.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,N.jsx)(`input`,{type:`text`,value:ye,onChange:e=>be(e.target.value),disabled:w.locks?.root,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none focus:border-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:focus:border-zinc-500`}),(0,N.jsx)(`button`,{type:`button`,"aria-label":`Browse for sandbox root`,disabled:w.locks?.root,onClick:()=>ze(`root`,ye),className:`shrink-0 rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-300`,children:`Browse…`})]})]}),De===`root`&&We,(0,N.jsxs)(`label`,{className:`block`,children:[(0,N.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Writable root (optional) `,w.locks?.writableRoot?(0,N.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,N.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,N.jsx)(`input`,{type:`text`,value:xe,onChange:e=>Se(e.target.value),disabled:w.locks?.writableRoot,placeholder:`Same as root`,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,N.jsx)(`button`,{type:`button`,"aria-label":`Browse for writable root`,disabled:w.locks?.writableRoot,onClick:()=>ze(`writableRoot`,xe||ye),className:`shrink-0 rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-300`,children:`Browse…`})]})]}),De===`writableRoot`&&We]}),(0,N.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:Ce,onChange:e=>we(e.target.checked),disabled:w.locks?.allowWrite,className:`rounded border-zinc-300 text-zinc-700 focus:ring-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300`}),(0,N.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow write `,w.locks?.allowWrite?(0,N.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]}),(0,N.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:Te,onChange:e=>Ee(e.target.checked),disabled:w.locks?.allowBash,className:`rounded border-zinc-300 text-zinc-700 focus:ring-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300`}),(0,N.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow bash `,w.locks?.allowBash?(0,N.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]})]})]}),!w&&(0,N.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No sandbox configured`}),(0,N.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[Ie&&(0,N.jsx)(`p`,{role:`alert`,className:`rounded-md border border-red-300 bg-red-50 px-2 py-1 text-xs text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:Ie}),(0,N.jsx)(`button`,{type:`button`,disabled:Fe||Ve&&!ye.trim(),onClick:Ve?He:b,className:`w-full rounded-md bg-zinc-800 px-3 py-1.5 text-xs font-medium text-white hover:bg-zinc-700 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-zinc-200 dark:text-zinc-900 dark:hover:bg-zinc-300`,children:Fe?`Restarting…`:Ve?`Apply & restart session`:`Restart session`}),(0,N.jsx)(`p`,{className:`text-[11px] text-zinc-400 dark:text-zinc-500`,children:Ve?`Saved to the server's configuration file, then the session is rebuilt — the change survives a restart.`:`Start a fresh session to reload extensions and MCP connections. Settings are kept.`})]}),re&&(0,N.jsxs)(`section`,{className:`mt-4`,children:[(0,N.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Versions`}),(0,N.jsxs)(`div`,{className:`space-y-1 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,N.jsxs)(`p`,{children:[`pi-outpost: `,(0,N.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:re.piOutpost})]}),re.piSdk&&(0,N.jsxs)(`p`,{children:[`pi SDK: `,(0,N.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:re.piSdk})]}),re.agent&&(0,N.jsxs)(`p`,{children:[`agent: `,(0,N.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:re.agent})]})]})]}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>he(!0),className:`mt-4 w-full border-t border-zinc-200 pt-3 text-left text-sm text-zinc-600 hover:text-zinc-900 dark:border-zinc-700 dark:text-zinc-400 dark:hover:text-zinc-100`,children:`Credits →`})]})})]}),(0,N.jsx)(rG,{open:P,inventory:ne,operations:A,extensionLock:u,userSkillPaths:D,userExtensionPaths:l,serverBrowse:O,applyState:k,onClose:()=>{_e(!1),ie(),ve.current?.focus()},onBrowseServerPath:e=>{te?.(),j(e)},onCloseServerBrowser:ie,onUpdateConfig:ae,onSuggestClonePath:oe,onCloneRepository:se,onEnrollRepository:ce,onSetSkills:le,onRemoveRepository:ue,onRefresh:de,onUpdate:fe})]})}function pG(e){let t=[],n=new Set,r=0,i=0;function a(e,o,s,c){let l=e.children,u=l.slice(1).map(e=>[e,r++]);u.length>0&&i++;let d=e.onPath&&!l.some(e=>e.onPath);if(t.push({node:e,lane:o,through:[...n].filter(e=>e!==o),forkTo:u.map(([,e])=>e),lineAbove:s,lineBelow:l.length>0,branchIndex:c,isCurrent:d,emphasis:d?`current`:e.onPath?`filled`:`hollow`,highlight:e.onPath}),l.length===0)n.delete(o);else{for(let[,e]of u)n.add(e);a(l[0],o,!0,u.length>0?1:void 0),u.forEach(([e,t],n)=>a(e,t,!0,n+2))}}return e.length>1&&i++,e.forEach((t,i)=>{let o=r++;n.add(o),a(t,o,!1,e.length>1?i+1:void 0)}),{rows:t,laneCount:r,branchPoints:i}}function mG(e){return e.flatMap(e=>[e,...mG(e.children)])}function hG({children:e,tone:t}){let n={current:`border-emerald-300 bg-emerald-50 text-emerald-700 dark:border-emerald-800 dark:bg-emerald-950/50 dark:text-emerald-300`,branch:`border-zinc-300 text-zinc-500 dark:border-zinc-700 dark:text-zinc-400`,label:`border-violet-300 bg-violet-50 text-violet-700 dark:border-violet-900 dark:bg-violet-950/50 dark:text-violet-300`}[t];return(0,N.jsx)(`span`,{className:`shrink-0 rounded-full border px-1.5 py-px text-[10px] leading-4 ${n}`,children:e})}var gG=`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-500 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`;function _G({row:e,laneCount:t,isStreaming:n,onNavigate:r,onFork:i,onClose:a}){let{node:o}=e,s=o.tipId??o.entryId;return(0,N.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70 ${e.isCurrent?`bg-emerald-50/60 dark:bg-emerald-950/20`:``}`,style:{height:36},children:[(0,N.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>{r(s),a()},title:n?`unavailable while the agent is running`:o.tipId?`restore the conversation at this point (reply included)`:`go back to this point`,className:`flex h-full min-w-0 flex-1 items-center gap-2 pl-2 text-left text-sm disabled:opacity-50`,children:[(0,N.jsx)(YU,{row:e,laneCount:t,colorOf:KU}),(0,N.jsx)(`span`,{className:`min-w-0 truncate ${o.onPath?`text-zinc-800 dark:text-zinc-200`:`text-zinc-600 dark:text-zinc-400`}`,children:o.text||`(empty)`}),e.forkTo.length>0&&(0,N.jsxs)(hG,{tone:`branch`,children:[e.forkTo.length+1,` branches`]}),e.branchIndex!==void 0&&(0,N.jsxs)(hG,{tone:`branch`,children:[`branch `,e.branchIndex,o.onPath&&!e.isCurrent?` · current`:``]}),e.isCurrent&&(0,N.jsx)(hG,{tone:`current`,children:`current`}),o.label&&(0,N.jsx)(hG,{tone:`label`,children:o.label})]}),(0,N.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>{r(o.entryId),a()},title:`rewind to just before this message (its text comes back in the composer)`,"aria-label":`Rewind to before this message`,className:gG,children:`↺ redo`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>{i(o.entryId),a()},title:`fork a new session from this point`,className:gG,children:`⑂ fork`})]})}function vG({tree:e,isStreaming:t,onListTree:n,onNavigate:r,onFork:i}){let[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``),l=oH(()=>o(!1));(0,v.useEffect)(()=>{a&&e===null&&n()},[a,e]);let u=(0,v.useMemo)(()=>e&&e.length>0?pG(e):null,[e]),d=(0,v.useMemo)(()=>{if(!e||!s.trim())return null;let t=s.trim().toLowerCase();return mG(e).filter(e=>e.text.toLowerCase().includes(t)||e.label?.toLowerCase().includes(t))},[e,s]);return(0,N.jsxs)(`div`,{className:`relative`,ref:l,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>{o(!a),a||(c(``),n())},title:`conversation tree: go back to an earlier point or fork`,className:`${uW} border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`tree`}),a&&(0,N.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-[70vh] w-[32rem] max-w-[90vw] flex-col rounded-lg border border-zinc-200 bg-white shadow-xl [--tree-off:#e4e4e7] dark:border-zinc-700 dark:bg-zinc-900 dark:[--tree-off:#3f3f46]`,children:[e===null&&(0,N.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),e?.length===0&&(0,N.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no messages yet`}),e&&e.length>0&&u&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,N.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,N.jsx)(`span`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Conversation tree`}),(0,N.jsxs)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:[u.rows.length,` turn`,u.rows.length===1?``:`s`,` · `,u.branchPoints,` branch point`,u.branchPoints===1?``:`s`]})]}),(0,N.jsx)(`input`,{type:`search`,value:s,onChange:e=>c(e.target.value),placeholder:`Search tree`,"aria-label":`Search conversation tree`,className:`mt-2 w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,N.jsx)(`p`,{className:`mt-1.5 text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Follow the colored lines — the current branch is highlighted. Click a turn to restore the conversation there · ↺ to send it again · ⑂ to fork a session`})]}),(0,N.jsx)(`div`,{className:`min-h-0 overflow-y-auto py-1`,children:d===null?u.rows.map(e=>(0,N.jsx)(_G,{row:e,laneCount:u.laneCount,isStreaming:t,onNavigate:r,onFork:i,onClose:()=>o(!1)},e.node.entryId)):d.length===0?(0,N.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no matches`}):d.map(e=>(0,N.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70`,children:[(0,N.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>{r(e.tipId??e.entryId),o(!1)},title:e.tipId?`restore the conversation at this point (reply included)`:`go back to this point`,className:`flex min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-left text-sm disabled:opacity-50`,children:[(0,N.jsx)(`span`,{"aria-hidden":!0,className:e.onPath?`text-emerald-500`:`text-zinc-300 dark:text-zinc-600`,children:`●`}),(0,N.jsx)(`span`,{className:`min-w-0 truncate text-zinc-700 dark:text-zinc-300`,children:e.text||`(empty)`}),e.onPath&&(0,N.jsx)(hG,{tone:`current`,children:`on current branch`}),e.label&&(0,N.jsx)(hG,{tone:`label`,children:e.label})]}),(0,N.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>{r(e.entryId),o(!1)},title:`rewind to just before this message (its text comes back in the composer)`,"aria-label":`Rewind to before this message`,className:gG,children:`↺ redo`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>{i(e.entryId),o(!1)},title:`fork a new session from this point`,className:gG,children:`⑂ fork`})]},e.entryId))})]})]})]})}var yG=200;function bG({initial:e,onCommit:t,onCancel:n}){let[r,i]=(0,v.useState)(e);return(0,N.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>i(e.target.value),onBlur:n,onKeyDown:e=>{e.key===`Enter`?t(r):e.key===`Escape`&&n()},placeholder:`Session name (empty to clear)`,"aria-label":`Session name`,className:`w-full rounded-md border border-zinc-400 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 dark:border-zinc-600 dark:placeholder:text-zinc-600`})}function xG({session:e,isCurrent:t,renaming:n,onSwitch:r,onDelete:i,onStartRename:a,onRename:o,onCancelRename:s}){return n?(0,N.jsx)(`div`,{className:`px-3 py-2`,children:(0,N.jsx)(bG,{initial:e.name??``,onCommit:o,onCancel:s})}):(0,N.jsxs)(`div`,{className:`group flex items-start gap-1 hover:bg-zinc-100 dark:hover:bg-zinc-800 ${t?`bg-zinc-100 dark:bg-zinc-800/60`:``}`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 flex-1 px-3 py-2 text-left text-sm`,children:[(0,N.jsx)(`div`,{className:`truncate text-zinc-700 dark:text-zinc-300`,children:e.name||e.firstMessage||`(empty)`}),e.snippet&&(0,N.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-zinc-500 dark:text-zinc-500`,children:e.snippet}),(0,N.jsxs)(`div`,{className:`mt-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:[new Date(e.modified).toLocaleString(),` · `,e.messageCount,` messages`,t?` · current`:``,!t&&e.liveIn?(0,N.jsxs)(`span`,{"data-testid":`session-live-in`,children:[` · open in `,e.liveIn]}):null]})]}),(0,N.jsx)(`button`,{type:`button`,onClick:a,title:`rename session`,"aria-label":`Rename session`,className:`mt-2 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-600 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`,children:`✎`}),!t&&!e.liveIn&&(0,N.jsx)(`button`,{type:`button`,onClick:i,title:`delete session`,"aria-label":`Delete session`,className:`mr-2 mt-2 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-red-100 hover:text-red-600 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-600 dark:hover:bg-red-950/60 dark:hover:text-red-400`,children:`✕`})]})}function SG({sessions:e,sessionSearch:t,sessionId:n,onSwitchSession:r,onDeleteSession:i,onListSessions:a,onRenameSession:o,onSearchSessions:s,onClearSessionSearch:c}){let[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(null),h=oH(()=>u(!1)),g=d.trim(),_=g.length>=2;(0,v.useEffect)(()=>{if(!l)return;if(!_){c();return}let e=setTimeout(()=>s(g),yG);return()=>clearTimeout(e)},[l,g,_]);function y(){u(!1),m(null)}let b=_&&(t?.status!==`loaded`||t.query!==g),x=_?b?null:t?.results??null:e;return(0,N.jsxs)(`div`,{className:`relative`,ref:h,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>{l?y():(u(!0),f(``),m(null),c(),a())},className:`${uW} border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`sessions`}),l&&(0,N.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-96 w-96 flex-col rounded-lg border border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,N.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,N.jsx)(`input`,{type:`search`,value:d,onChange:e=>f(e.target.value),placeholder:`Search sessions`,"aria-label":`Search sessions`,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,N.jsx)(`p`,{className:`mt-1.5 text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Searches names and everything said in a session · ✎ to rename`})]}),(0,N.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[x===null&&(0,N.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),x?.length===0&&(0,N.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:_?`no matches`:`no saved sessions`}),x?.map(e=>(0,N.jsx)(xG,{session:e,isCurrent:e.id===n,renaming:p===e.path,onSwitch:()=>{r(e.path),y()},onDelete:()=>{window.confirm(`Delete this session?`)&&i(e.path)},onStartRename:()=>m(e.path),onRename:t=>{o(e.path,t),m(null),_&&s(d.trim())},onCancelRename:()=>m(null)},e.path))]})]})]})}function CG({filters:e,onFilterChange:t}){let[n,r]=(0,v.useState)(!1),i=oH(()=>r(!1)),a=MV(e),o=a>0?`Filter · ${a} hidden`:`Filter`;return(0,N.jsxs)(`div`,{className:`relative`,ref:i,onKeyDown:e=>{e.key===`Escape`&&n&&(e.stopPropagation(),r(!1))},children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>r(!n),"aria-haspopup":`menu`,"aria-expanded":n,title:`Choose what the conversation shows`,className:`${uW} ${a>0?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`}`,children:o}),n&&(0,N.jsx)(`div`,{role:`menu`,className:`absolute right-0 z-30 mt-1 w-48 rounded-md border border-zinc-200 bg-white py-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:DV.map(n=>(0,N.jsxs)(`button`,{type:`button`,role:`menuitemcheckbox`,"aria-checked":e[n],onClick:()=>t(n,!e[n]),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-zinc-600 hover:bg-zinc-100 dark:text-zinc-300 dark:hover:bg-zinc-800`,children:[(0,N.jsx)(`span`,{"aria-hidden":!0,className:`w-3`,children:e[n]?`✓`:``}),(0,N.jsx)(`span`,{children:OV[n]})]},n))})]})}function wG({statuses:e,bar:t}){let n=Object.entries(e).filter(([,e])=>LH(e).trim()!==``),r=n.map(([e,t])=>`${e}\u0000${t}`).join(``),[i,a]=(0,v.useState)(!1),o=(0,v.useRef)(null),s=(0,v.useRef)(null),[c,l]=(0,v.useState)(!1),u=oH(()=>l(!1));if((0,v.useLayoutEffect)(()=>{o.current=null,a(!1),l(!1)},[r]),(0,v.useLayoutEffect)(()=>{let e=t;if(e===null)return;let n=()=>{if(o.current!==null){e.clientWidth>o.current+64&&(o.current=null,a(!1),l(!1));return}let t=Array.from(s.current?.querySelectorAll(`[data-status-text]`)??[]).some(e=>e.scrollWidth>e.clientWidth+1),n=e.firstElementChild?.getBoundingClientRect(),r=n&&n.height>0&&Array.from(e.children).some(e=>e.getBoundingClientRect().top>=n.bottom);(t||r||e.scrollWidth>e.clientWidth+1)&&(o.current=e.clientWidth,a(!0))};if(n(),typeof ResizeObserver>`u`)return;let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[t,i,r]),n.length===0)return null;if(!i)return(0,N.jsx)(`div`,{ref:s,className:`flex shrink-0 items-center gap-1.5`,children:n.map(([e,t])=>(0,N.jsx)(`span`,{title:LH(t),className:`${uW} max-w-[16rem] border-zinc-200 text-zinc-500 dark:border-zinc-800 dark:text-zinc-400`,children:(0,N.jsx)(`span`,{"data-status-text":!0,className:`truncate`,children:(0,N.jsx)(RH,{text:t})})},e))});let d=`${n.length} ${n.length===1?`status`:`statuses`}`;return(0,N.jsxs)(`div`,{ref:u,className:`relative shrink-0`,onKeyDown:e=>{e.key===`Escape`&&c&&(e.stopPropagation(),l(!1))},children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>l(!c),"aria-expanded":c,title:n.map(([,e])=>LH(e)).join(`
|
|
1512
1512
|
`),className:`${uW} border-zinc-200 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:[d,` ▾`]}),c&&(0,N.jsx)(`ul`,{"aria-label":`Extension statuses`,className:`absolute left-0 top-full z-20 mt-1 w-max max-w-[24rem] rounded-md border border-zinc-200 bg-white py-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:n.map(([e,t])=>(0,N.jsx)(`li`,{className:`break-words px-3 py-1.5 text-xs text-zinc-600 dark:text-zinc-300`,children:(0,N.jsx)(RH,{text:t})},e))})]})}function TG({theme:e,preference:t=e,onToggle:n,onSetTheme:r}){let[i,a]=(0,v.useState)(!1),o=(0,v.useRef)(null),s=oH(()=>a(!1));(0,v.useEffect)(()=>{i&&s.current?.querySelector(`[aria-checked="true"]`)?.focus()},[i]);let c={light:`Light`,dark:`Dark`,system:`System`}[t];return(0,N.jsxs)(`div`,{ref:s,className:`relative`,onKeyDown:e=>{if(e.key===`Escape`&&(e.stopPropagation(),a(!1),o.current?.focus()),i&&[`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key)){e.preventDefault();let t=Array.from(s.current?.querySelectorAll(`[role="menuitemradio"]`)??[]),n=t.findIndex(e=>e.matches(`:focus`));t[e.key===`Home`?0:e.key===`End`?t.length-1:(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length]?.focus()}},children:[(0,N.jsx)(`button`,{ref:o,type:`button`,onClick:()=>a(e=>!e),title:`Theme: ${c}`,"aria-label":`Theme: ${c}`,"aria-haspopup":`menu`,"aria-expanded":i,className:`${uW} border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:t===`system`?`◐`:e===`dark`?`☾`:`☀`}),i&&(0,N.jsx)(`div`,{role:`menu`,"aria-label":`Theme`,className:`absolute right-0 top-full z-40 mt-2 min-w-32 rounded-lg border border-zinc-300 bg-white p-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:[`light`,`dark`,`system`].map(i=>(0,N.jsx)(`button`,{role:`menuitemradio`,"aria-checked":t===i,type:`button`,className:`block w-full rounded px-3 py-1.5 text-left text-xs text-zinc-700 hover:bg-zinc-100 focus:bg-zinc-100 dark:text-zinc-200 dark:hover:bg-zinc-800 dark:focus:bg-zinc-800`,onClick:()=>{r?r(i):i!==e&&n(),a(!1),o.current?.focus()},children:i===`light`?`Light`:i===`dark`?`Dark`:`System`},i))})]})}function EG(e){let{isStreaming:t,connected:n}=e,[r,i]=(0,v.useState)(null);return(0,N.jsxs)(`header`,{ref:i,className:`relative z-30 flex min-w-0 flex-wrap items-center gap-1.5 border-b border-zinc-200 px-4 py-2 dark:border-zinc-800`,children:[e.workspaceControl===`projects`&&(0,N.jsx)(_W,{workspace:e.workspace,workspaces:e.workspaces,locked:e.workspaceLocked,onSwitch:e.onSwitchWorkspace,onOpen:e.onOpenProject,onClose:e.onCloseProject,onOpenSide:e.onOpenSideSession}),e.workspaceControl===`root`&&e.rootControl&&(0,N.jsx)(bW,{sandbox:e.rootControl.sandbox,browse:e.rootControl.browse,applyState:e.rootControl.applyState,blocked:e.rootControl.blocked,onBrowse:e.rootControl.onBrowse,onCloseBrowser:e.rootControl.onCloseBrowser,onOpened:e.rootControl.onOpened,onSelect:e.rootControl.onSelect}),(0,N.jsxs)(`button`,{type:`button`,onClick:e.onToggleSidebar,title:e.sidebarOpen?`Hide files (panel opens on the left)`:`Show files`,"aria-pressed":e.sidebarOpen,className:`${uW} ${e.sidebarOpen?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`}`,children:[e.sidebarOpen?`◧`:`◨`,` files`]}),(0,N.jsxs)(`button`,{type:`button`,onClick:e.onToggleOutcome,"aria-pressed":e.outcomeOpen,title:`Review structured workspace Outcome`,className:`${uW} ${e.outcomeOpen?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:e.workspace?.activity===`ready-for-review`?`border-amber-400 text-amber-700 dark:text-amber-300`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 dark:border-zinc-800 dark:text-zinc-400`}`,children:[`Outcome`,e.workspace?.activity===`ready-for-review`?` •`:``]}),e.gitAvailable&&(0,N.jsx)(CW,{status:e.gitStatus,selected:e.gitSelectedPath,log:e.gitLog,onFetchLog:e.onFetchGitLog,onCloseLog:e.onCloseGitLog,onShowCommit:e.onShowCommit}),(0,N.jsx)(`span`,{title:e.title??void 0,className:`hidden min-w-[2.25rem] shrink-[4] truncate whitespace-nowrap text-lg font-semibold leading-tight tracking-tight sm:block`,style:{color:`var(--accent, inherit)`},children:e.title??`π`}),(0,N.jsx)(wG,{statuses:e.statuses,bar:r}),(0,N.jsxs)(`div`,{className:`ml-auto flex w-full max-w-full shrink-0 flex-wrap items-center gap-1 sm:w-auto sm:gap-1.5`,children:[(0,N.jsx)(CG,{filters:e.filters,onFilterChange:e.onFilterChange}),e.onExportConversation&&(0,N.jsx)(`button`,{type:`button`,onClick:e.onExportConversation,disabled:!!e.exportProgress,"aria-busy":!!e.exportProgress,title:`Save the whole conversation as one HTML file`,"aria-label":`Export the conversation as HTML`,className:`inline-flex h-7 shrink-0 items-center gap-1 whitespace-nowrap rounded-md border px-2 text-xs leading-none border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 disabled:cursor-progress disabled:opacity-60 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:e.exportProgress??`↓ html`}),e.onToggleTerminal&&(0,N.jsx)(`button`,{type:`button`,onClick:e.onToggleTerminal,title:e.terminalOpen?"Close Terminal (Ctrl+`)":"Open Terminal (Ctrl+`)","aria-pressed":e.terminalOpen,className:`inline-flex h-7 shrink-0 items-center gap-1 whitespace-nowrap rounded-md border px-2 text-xs leading-none ${e.terminalOpen?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`}`,children:`>_ terminal`}),e.showThemeToggle&&(0,N.jsx)(TG,{theme:e.theme,preference:e.themePreference,onSetTheme:e.onSetTheme,onToggle:e.onToggleTheme}),(0,N.jsx)(`button`,{type:`button`,onClick:e.onNewSession,title:`new session`,className:`${uW} border-emerald-300 text-emerald-700 hover:border-emerald-500 hover:text-emerald-600 dark:border-emerald-900 dark:text-emerald-400 dark:hover:border-emerald-600 dark:hover:text-emerald-300`,children:`+ new`}),(0,N.jsx)(vG,{tree:e.tree,isStreaming:t,onListTree:e.onListTree,onNavigate:e.onNavigateTree,onFork:e.onForkSession}),(0,N.jsx)(SG,{sessions:e.sessions,sessionSearch:e.sessionSearch,sessionId:e.sessionId,onSwitchSession:e.onSwitchSession,onDeleteSession:e.onDeleteSession,onListSessions:e.onListSessions,onRenameSession:e.onRenameSession,onSearchSessions:e.onSearchSessions,onClearSessionSearch:e.onClearSessionSearch}),(0,N.jsx)(fG,{credentials:e.credentials,login:e.login,onStartLogin:e.onStartLogin,onAnswerLogin:e.onAnswerLogin,onCancelLogin:e.onCancelLogin,onDismissLogin:e.onDismissLogin,onLogoutProvider:e.onLogoutProvider,extensionPaths:e.extensionPaths,configuredExtensionPaths:e.configuredExtensionPaths,userExtensionPaths:e.userExtensionPaths,extensionLock:e.extensionLock,piPackages:e.piPackages??null,piPackageUpdate:e.piPackageUpdate??null,...e.piPackageEdits?{piPackageEdits:e.piPackageEdits}:{},canRestartServer:e.canRestartServer??!1,serverRestarting:e.serverRestarting??!1,...e.onCheckPiPackages?{onCheckPiPackages:e.onCheckPiPackages}:{},...e.onUpdatePiPackage?{onUpdatePiPackage:e.onUpdatePiPackage}:{},...e.onRestartServer?{onRestartServer:e.onRestartServer}:{},restartNeeded:e.restartNeeded??[],tools:e.tools??[],commands:e.commands??[],sandbox:e.sandbox,showRoots:!(e.workspaceControl===`projects`&&e.workspaces.filter(e=>!e.sideOf).length>1),gitUnavailable:e.gitUnavailable,userSkillPaths:e.userSkillPaths,serverBrowse:e.serverBrowse,applyState:e.settingsApply,agentResources:e.agentResources,agentResourceOperations:e.agentResourceOperations,versions:e.versions,onBrowseServerPath:e.onBrowseServerPath,onCloseServerBrowser:e.onCloseServerBrowser,pickerBlocked:e.settingsPickerBlocked,onPickerOpened:e.onSettingsPickerOpened,onRestartSession:e.onRestartSession,onUpdateConfig:e.onUpdateConfig,onSuggestAgentResourceClonePath:e.onSuggestAgentResourceClonePath,onCloneAgentResourceRepository:e.onCloneAgentResourceRepository,onEnrollAgentResourceRepository:e.onEnrollAgentResourceRepository,onSetAgentResourceSkills:e.onSetAgentResourceSkills,onRemoveAgentResourceRepository:e.onRemoveAgentResourceRepository,onRefreshAgentResourceRepositories:e.onRefreshAgentResourceRepositories,onUpdateAgentResourceRepository:e.onUpdateAgentResourceRepository}),(0,N.jsx)(`span`,{className:`h-2 w-2 rounded-full ${n?`bg-emerald-500`:`bg-red-500`}`,title:n?`connected`:`disconnected`})]})]})}function DG(e,t){let n=(0,v.useRef)(new Map);(0,v.useEffect)(()=>{if(typeof Notification>`u`)return;let r=e.filter(e=>e.needsAttention),i=r.filter(e=>GB(e)!==t);for(let e of[...n.current.keys()])r.some(t=>GB(t)===e)||n.current.delete(e);if(Notification.permission===`granted`&&(typeof document>`u`||document.visibilityState!==`visible`)){for(let e of i)if(n.current.get(GB(e))!==e.activity){n.current.set(GB(e),e.activity);try{let t=e.activity===`ready-for-review`;new Notification(t?`${e.name} is ready for review`:`${e.name} needs you`,{body:t?`Background work is ready for review.`:`The agent needs an answer to continue.`,tag:`pi-outpost:${GB(e)}`})}catch{}}}},[e,t])}var OG={"agent-directory":`read the agent directory (the provider keys)`,"beside-root":`read a file beside the root`,"write-beside-root":`write beside the root`,"signal-process":`signal another process of the server's user`,"server-environment":`inherit the server's environment`,"server-process-environment":`read the server's process environment (/proc)`,"unlisted-host":`reach a host not in sandbox.allowedHosts`,"direct-connection":`connect around the proxy`},kG=e=>e.map(e=>OG[e]??e),AG=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()};function jG(e,t){let n=t===`shell`?`The agent's shell`:`This terminal`;switch(e.state){case`checking`:return`${n} runs under ${e.runner||`a sandbox runner`}; its confinement is being checked.`;case`verified`:return[`${n} is confined by ${e.runner}, checked at ${AG(e.checkedAt)}. A command could not:`,...kG(e.refused).map(e=>`• ${e}`),...e.environmentReadable?[`The server's process environment is readable, and holds no secret.`]:[],...e.notChecked.length?[`Not checked:`,...e.notChecked.map(e=>`• ${OG[e.attempt]??e.attempt} — ${e.why}`)]:[]].join(`
|
|
1513
1513
|
`);case`partial`:return[`${n} is confined by ${e.runner}, checked at ${AG(e.checkedAt)}, except one thing: a command can read the server's process environment, which holds ${e.exposed.join(`, `)}.`,`Move these out of the server's environment — provider keys belong in the agent directory.`,`A command could not:`,...kG(e.refused).map(e=>`• ${e}`)].join(`
|
|
1514
1514
|
`);case`leaking`:return[`${n} is NOT confined as configured: under ${e.runner}, checked at ${AG(e.checkedAt)}, a command could:`,...kG(e.reached).map(e=>`• ${e}`),`The configuration is unchanged: fix the runner or its host, or stop using it.`].join(`
|
|
@@ -1534,4 +1534,4 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t
|
|
|
1534
1534
|
[Clipboard copy was refused by the browser.]`))),h.current=n,g.current=r,y.current.registerClear(e,()=>{n.clear()}),y.current.openTerminal?.(e,y.current.cwd,n.cols,n.rows,...t?[t]:[]);let i=null,a=0,o=()=>{let t=Date.now();t-a<1e3?i||=setTimeout(()=>{i=null,a=Date.now(),y.current.getTerminalCwd?.(e)},1e3-(t-a)):(a=t,y.current.getTerminalCwd?.(e))},s=n.onData(t=>{y.current.sendTerminalInput?.(e,t),(t.includes(`\r`)||t.includes(`
|
|
1535
1535
|
`))&&o()}),c=y.current.subscribeTerminal?.(e,{onData:t=>{n.write(t);let r=t.match(/\x1b\]7;file:\/\/[^/]*([^\x07\x1b]+)(?:\x07|\x1b\\)/);if(r&&r[1])try{let t=decodeURIComponent(r[1]);y.current.onCwdUpdate(e,t)}catch{}},onCwd:t=>{y.current.onCwdUpdate(e,t)},onExit:e=>{n.writeln(`\r\n\x1b[90m[Process completed (exit code ${e??0})]\x1b[0m`)},onError:e=>{n.writeln(`\r\n\x1b[31m[Terminal error: ${e}]\x1b[0m`)}})??(()=>{}),l=new ResizeObserver(()=>{if(m.current&&m.current.clientWidth>0&&m.current.clientHeight>0)try{r.fit(),n.cols>0&&n.rows>0&&y.current.resizeTerminal?.(e,n.cols,n.rows)}catch{}});return l.observe(m.current),()=>{s.dispose(),c(),l.disconnect(),n.dispose(),y.current.closeTerminal?.(e)}},[e]),(0,v.useEffect)(()=>{if(!a&&i&&r&&g.current&&h.current&&m.current){y.current.getTerminalCwd?.(e);let t=setTimeout(()=>{try{g.current?.fit(),h.current?.focus()}catch{}},50);return()=>clearTimeout(t)}},[i,r,e,a]),(0,N.jsx)(`div`,{ref:m,className:`h-full w-full p-2 bg-white dark:bg-zinc-950 overflow-hidden ${r?`block`:`hidden`}`})}function E1({shells:e,open:t,onClose:n,cwd:r,confinedRoot:i,confinement:a,unavailable:o,onSetWorkspaceRoot:s,openTerminal:c,sendTerminalInput:l,getTerminalCwd:u,resizeTerminal:d,closeTerminal:f,subscribeTerminal:p}){let[m,h]=(0,v.useState)(``),g=e?.some(e=>e.id===m)?m:``,[_,y]=(0,v.useState)(t);(0,v.useEffect)(()=>{t&&y(!0)},[t]);let[b,x]=(0,v.useState)([{id:`term-1`,title:`terminal 1`}]),[S,C]=(0,v.useState)(`term-1`),[w,T]=(0,v.useState)(null),[E,D]=(0,v.useState)(``),[O,ee]=(0,v.useState)({}),[te,k]=(0,v.useState)(!1),ne=VU(IU,`y`),[A,re]=(0,v.useState)(!1),j=(0,v.useRef)(new Map),ie=(0,v.useCallback)((e,t)=>{j.current.set(e,t)},[]),ae=(0,v.useCallback)((e,t)=>{ee(n=>({...n,[e]:t}))},[]),oe=(0,v.useCallback)(()=>{let e=b.length+1,t=`term-${crypto.randomUUID()}`,n={id:t,title:`terminal ${e}`,...g?{shellId:g}:{}};x(e=>[...e,n]),C(t)},[b.length,g]),se=(0,v.useCallback)((e,t)=>{t.stopPropagation(),b.length<=1?n():(x(t=>{let n=t.filter(t=>t.id!==e);if(S===e){let r=t.findIndex(t=>t.id===e),i=n[Math.max(0,r-1)]?.id??n[0]?.id;C(i)}return n}),j.current.delete(e),ee(t=>{let n={...t};return delete n[e],n}))},[b.length,S,n]),ce=(e,t)=>{t.stopPropagation(),T(e.id),D(e.title)},le=()=>{if(w){let e=E.trim();e&&x(t=>t.map(t=>t.id===w?{...t,title:e}:t)),T(null)}},ue=e=>{e.key===`Enter`?le():e.key===`Escape`&&T(null)},de=(0,v.useCallback)(()=>{let e=j.current.get(S);e&&e()},[S]),fe=O[S]||r||``;return _?(0,N.jsxs)(`div`,{style:{height:te?`85vh`:ne.width,maxHeight:te?`85vh`:`65vh`},className:`flex-col shrink-0 border-t border-zinc-200 dark:border-zinc-800 bg-zinc-100 dark:bg-zinc-900 ${t?`flex`:`hidden`} relative z-20`,children:[!te&&(0,N.jsx)(HU,{axis:`y`,label:`Resize Terminal panel`,width:ne.width,config:IU,separatorProps:ne.separatorProps}),(0,N.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-1 border-b border-zinc-200 dark:border-zinc-800 select-none bg-zinc-50 dark:bg-zinc-950 text-xs`,children:[(0,N.jsxs)(`div`,{className:`flex items-center space-x-1 overflow-x-auto min-w-0`,children:[(0,N.jsx)(`div`,{className:`flex items-center space-x-1`,children:b.map(e=>{let t=e.id===S,n=e.id===w;return(0,N.jsxs)(`div`,{onClick:()=>C(e.id),onDoubleClick:t=>ce(e,t),title:`Double-click to rename tab`,className:`flex items-center space-x-1 px-2.5 py-1 rounded text-xs cursor-pointer transition-colors ${t?`bg-zinc-200 dark:bg-zinc-800 text-zinc-900 dark:text-zinc-100 font-medium shadow-sm`:`text-zinc-500 hover:text-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200 hover:bg-zinc-200/50 dark:hover:bg-zinc-800/50`}`,children:[n?(0,N.jsx)(`input`,{type:`text`,"data-testid":`terminal-tab-rename-input`,value:E,autoFocus:!0,onChange:e=>D(e.target.value),onBlur:le,onKeyDown:ue,className:`bg-transparent border border-sky-500 rounded px-1 py-0 text-xs font-mono outline-none text-zinc-900 dark:text-zinc-100 w-24`}):(0,N.jsx)(`span`,{children:e.title}),b.length>1&&(0,N.jsx)(`span`,{onClick:t=>se(e.id,t),role:`button`,tabIndex:0,"aria-label":`Close terminal tab`,className:`ml-1 hover:text-red-500 rounded p-0.5 hover:bg-zinc-200 dark:hover:bg-zinc-700`,children:(0,N.jsx)(`svg`,{className:`w-3 h-3`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,N.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M6 18L18 6M6 6l12 12`})})})]},e.id)})}),e&&e.length>0&&(0,N.jsxs)(`select`,{"aria-label":`Shell for new terminal`,value:g,onChange:e=>h(e.target.value),disabled:!!o,className:`min-w-0 max-w-40 rounded border border-zinc-300 bg-zinc-50 text-xs text-zinc-800 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-200`,children:[(0,N.jsx)(`option`,{value:``,children:`Default shell`}),e.map(e=>(0,N.jsx)(`option`,{value:e.id,children:e.label},e.id))]}),(0,N.jsx)(`button`,{onClick:oe,type:`button`,title:`New Terminal Tab`,className:`p-1 rounded text-zinc-500 hover:text-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200 hover:bg-zinc-200/60 dark:hover:bg-zinc-800/60`,children:(0,N.jsx)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,N.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M12 4v16m8-8H4`})})})]}),i&&!o&&(0,N.jsx)(NG,{verdict:a??{state:`checking`,runner:``},surface:`terminal`,root:w1(i)}),fe&&(0,N.jsx)(`div`,{className:`hidden md:flex items-center space-x-1.5 px-2 text-xs font-mono text-zinc-500 dark:text-zinc-400`,children:s&&(0,N.jsx)(`button`,{onClick:()=>{if(fe&&s){if((fe===`/`||fe===`\\`||/^[A-Za-z]:[\\/]?$/.test(fe))&&!window.confirm(`Open root filesystem "${fe}" as the workspace project?`))return;s(fe),re(!0),setTimeout(()=>re(!1),2e3)}},type:`button`,title:`Open "${fe}" as the workspace project and reposition the LLM agent`,className:`flex items-center space-x-1 px-1.5 py-0.5 rounded text-[11px] font-sans transition-colors ${A?`bg-emerald-500 text-white font-medium`:`bg-zinc-200/80 hover:bg-sky-500 hover:text-white dark:bg-zinc-800 dark:hover:bg-sky-600 dark:hover:text-white text-zinc-700 dark:text-zinc-300`}`,children:(0,N.jsx)(`span`,{children:A?`✓ Project opened`:`📁 ${w1(fe)} → open as project`})})}),(0,N.jsxs)(`div`,{className:`flex items-center space-x-1 text-zinc-500 dark:text-zinc-400`,children:[(0,N.jsx)(`button`,{onClick:de,type:`button`,title:`Clear Terminal Output`,className:`p-1 rounded hover:text-zinc-800 dark:hover:text-zinc-200 hover:bg-zinc-200/60 dark:hover:bg-zinc-800/60`,children:(0,N.jsx)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,N.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16`})})}),(0,N.jsx)(`button`,{onClick:()=>k(e=>!e),type:`button`,title:te?`Restore Terminal Panel`:`Maximize Terminal Panel`,className:`p-1 rounded hover:text-zinc-800 dark:hover:text-zinc-200 hover:bg-zinc-200/60 dark:hover:bg-zinc-800/60`,children:te?(0,N.jsx)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,N.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M19 9l-7 7-7-7`})}):(0,N.jsx)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,N.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M5 15l7-7 7 7`})})}),(0,N.jsx)(`button`,{onClick:n,type:`button`,title:"Minimize Terminal Panel (Ctrl+`)",className:`p-1 rounded hover:text-zinc-800 dark:hover:text-zinc-200 hover:bg-zinc-200/60 dark:hover:bg-zinc-800/60`,children:(0,N.jsx)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,N.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M6 18L18 6M6 6l12 12`})})})]})]}),(0,N.jsx)(`div`,{className:`flex-1 min-h-0 relative`,children:o?(0,N.jsxs)(`div`,{role:`status`,"data-testid":`terminal-unavailable`,className:`p-3 text-xs text-amber-700 dark:text-amber-300`,children:[(0,N.jsx)(`p`,{className:`font-medium`,children:`The terminal is unavailable.`}),(0,N.jsx)(`p`,{className:`mt-1 break-words font-mono`,children:o})]}):b.map(e=>(0,N.jsx)(T1,{id:e.id,shellId:e.shellId,cwd:r,isActive:e.id===S,isPanelOpen:t,renaming:w!==null,openTerminal:c,sendTerminalInput:l,getTerminalCwd:u,resizeTerminal:d,closeTerminal:f,subscribeTerminal:p,onCwdUpdate:ae,registerClear:ie},e.id))})]}):null}var D1={todo:{label:`To do`,className:`text-zinc-500`},in_progress:{label:`In progress`,className:`text-blue-600 dark:text-blue-400`},done:{label:`Done`,className:`text-emerald-600 dark:text-emerald-400`},blocked:{label:`Blocked`,className:`text-red-600 dark:text-red-400`},needs_review:{label:`Needs review`,className:`text-amber-600 dark:text-amber-400`},passed:{label:`Passed`,className:`text-emerald-600 dark:text-emerald-400`},failed:{label:`Failed`,className:`text-red-600 dark:text-red-400`},inconclusive:{label:`Inconclusive`,className:`text-amber-600 dark:text-amber-400`},informational:{label:`Informational`,className:`text-zinc-500`},modified:{label:`Modified`,className:`text-blue-600 dark:text-blue-400`},added:{label:`Added`,className:`text-emerald-600 dark:text-emerald-400`},deleted:{label:`Deleted`,className:`text-red-600 dark:text-red-400`},untracked:{label:`Untracked`,className:`text-zinc-600 dark:text-zinc-300`},conflicted:{label:`Conflicted`,className:`text-red-600 dark:text-red-400`},unavailable:{label:`Unavailable`,className:`text-red-600 dark:text-red-400`},"not-recorded":{label:`Not recorded`,className:`text-zinc-500`}};function O1(e){return D1[e]??{label:e,className:`text-zinc-500`}}function k1({entry:e,onTarget:t}){let n=O1(e.status),r=(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,N.jsx)(`span`,{className:`min-w-0 break-words text-sm font-medium text-zinc-900 dark:text-zinc-100`,children:e.title}),(0,N.jsx)(`span`,{className:`shrink-0 text-[11px] font-semibold uppercase tracking-wide ${n.className}`,children:n.label})]}),e.group&&(0,N.jsx)(`div`,{className:`mt-0.5 text-[11px] text-zinc-500`,children:e.group}),e.detail&&(0,N.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-xs text-zinc-600 dark:text-zinc-300`,children:e.detail}),e.reference&&(0,N.jsx)(`div`,{className:`mt-1 truncate text-xs text-zinc-500`,children:e.reference}),(0,N.jsx)(`div`,{className:`mt-1 text-[10px] uppercase tracking-wide text-zinc-400`,children:e.source})]}),i=`block w-full rounded-md border border-zinc-200 p-2 text-left hover:bg-zinc-50 dark:border-zinc-800 dark:hover:bg-zinc-900`;return e.target?.kind===`external-url`?(0,N.jsx)(`a`,{href:e.target.url,target:`_blank`,rel:`noreferrer`,className:i,children:r}):e.target?(0,N.jsx)(`button`,{type:`button`,onClick:()=>t(e.target),className:i,children:r}):(0,N.jsx)(`div`,{className:`rounded-md border border-zinc-200 p-2 dark:border-zinc-800`,children:r})}function A1({state:e,onClose:t,onRefresh:n,onTarget:r}){return(0,N.jsxs)(`aside`,{"aria-label":`Workspace Outcome`,className:`absolute inset-y-0 right-0 z-10 flex w-full flex-col border-l border-zinc-200 bg-white/95 shadow-lg backdrop-blur md:w-[26rem] dark:border-zinc-800 dark:bg-zinc-950/95`,children:[(0,N.jsxs)(`header`,{className:`flex items-start justify-between gap-2 border-b border-zinc-200 px-3 py-3 dark:border-zinc-800`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-zinc-500`,children:`Workspace review`}),(0,N.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:`Outcome`})]}),(0,N.jsxs)(`div`,{className:`flex gap-1`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:n,className:`rounded px-2 py-1 text-xs text-zinc-500 hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:`Refresh`}),(0,N.jsx)(`button`,{type:`button`,onClick:t,className:`rounded px-2 py-1 text-xs text-zinc-500 hover:bg-zinc-100 dark:hover:bg-zinc-800`,"aria-label":`Close Outcome`,children:`×`})]})]}),(0,N.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:e===null||e.status===`loading`?(0,N.jsx)(`div`,{role:`status`,className:`text-sm text-zinc-500`,children:`Loading Outcome…`}):e.status===`error`?(0,N.jsx)(`div`,{role:`alert`,className:`rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:border-red-900 dark:bg-red-950/30 dark:text-red-300`,children:e.message}):(0,N.jsx)(`div`,{className:`space-y-4`,children:e.outcome.sections.map(e=>(0,N.jsxs)(`section`,{"aria-labelledby":`outcome-${e.id}`,className:`rounded-lg border border-zinc-200 p-3 dark:border-zinc-800`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,N.jsx)(`h3`,{id:`outcome-${e.id}`,className:`text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:e.title}),e.availability===`partial`||e.availability===`unavailable`?(0,N.jsx)(`span`,{className:`text-[11px] font-semibold uppercase text-red-600 dark:text-red-400`,children:e.availability}):null]}),e.summary&&(0,N.jsx)(`p`,{className:`mt-1 text-xs text-zinc-600 dark:text-zinc-300`,children:e.summary}),e.entries.length>0&&(0,N.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.entries.map(e=>(0,N.jsx)(k1,{entry:e,onTarget:r},e.id))})]},e.id))})})]})}function j1(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`));return`${t.slice(0,4).join(``)}-${t.slice(4,6).join(``)}-${t.slice(6,8).join(``)}-${t.slice(8,10).join(``)}-${t.slice(10).join(``)}`}var M1=`pi-outpost:token`;function N1(){let e=null;try{let t=new URL(window.location.href);return e=t.searchParams.get(`token`),e&&(localStorage.setItem(M1,e),t.searchParams.delete(`token`),window.history.replaceState(null,``,`${t.pathname}${t.search}${t.hash}`)),localStorage.getItem(M1)}catch{return e}}function P1(){try{return localStorage.getItem(M1)}catch{return null}}function F1(e){try{localStorage.setItem(M1,e)}catch{}}var I1=class extends Error{kind;constructor(e,t){super(e),this.name=`HistoryError`,this.kind=t}};async function L1(e,t){let n=[];for(;;){let r=await e(n.length,50);if(r.items.length===0||(n.unshift(...r.items),t?.(n.length),r.remaining===0))return n}}function R1(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}function z1(e,t){return e.base.rev===t.base.rev&&e.base.path===t.base.path&&e.target.rev===t.target.rev&&e.target.path===t.target.path}function B1(){return{clonePath:null,preview:null,enrollment:null,refresh:null,updates:{},skills:{},removals:{}}}var V1={login:null,connected:!1,workspace:null,workspaces:[],workspaceLocked:!1,embedWorkspaceControls:`settings`,switching:!1,agentStarting:!1,authRequired:!1,brandingReady:!1,branding:{},sessionId:``,sessionName:null,model:``,thinkingLevel:`off`,modelSupportsReasoning:!1,models:[],commands:[],extensionsBinding:!1,sessions:null,sessionSearch:null,tree:null,isStreaming:!1,items:[],olderHistory:null,pendingPrompt:null,workPlan:null,replyConformance:{},structuredAppearance:null,outpostUpdate:null,outpostChanges:null,piPackages:null,piPackageUpdate:null,piPackageLookup:null,piPackageChange:null,serverRestarting:!1,restartNeeded:[],outcome:null,queue:[],queuedEditRefused:null,errors:[],contextUsage:null,isCompacting:!1,dialogQueue:[],sandboxGrants:null,notifications:[],statuses:{},widgets:{},editorPrefill:null,fileTree:{},directoryRequests:{},openFile:null,previewRevision:0,fileSearch:null,contentSearch:null,createError:null,created:null,fileOperation:null,extensionPaths:null,configuredExtensionPaths:[],userExtensionPaths:[],extensionLock:!1,tools:[],sandbox:null,terminal:null,userSkillPaths:[],serverBrowse:null,settingsApply:null,agentResources:null,agentResourceOperations:B1(),versions:null,gitAvailable:!1,gitUnavailable:null,credentials:null,gitStatus:null,gitDiff:null,gitBaseline:null,gitLog:null,gitShow:null,gitFileHistory:null,gitFileDiff:null};function H1(e,t){if(!e.startsWith(`/`))return!1;let n=e.indexOf(` `),r=n===-1?e.slice(1):e.slice(1,n);return t.some(e=>e.source===`extension`&&e.name===r)}function U1(e,t){for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.kind===`assistant`&&r.streaming){let i=[...e];return i[n]=t(r),i}}return[...e,t({kind:`assistant`,blocks:[],streaming:!0})]}function W1(e,t,n,r){for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.kind===`tool`&&i.toolCallId===t){let t=[...e];return t[n]={...i,...r},t}}return[...e,{kind:`tool`,toolCallId:t,toolName:n,args:{},output:``,running:!0,...r}]}function G1(e,t,n){for(let r=e.length-1;r>=0;r--){let i=e[r];if(i.kind===`tool`&&i.toolCallId===t){let t=[...e];return t[r]={...i,...n},t}}return e}function K1(e,t){if(t.type!==`hello`&&t.type!==`session_replaced`&&t.type!==`update_config_ack`&&t.type!==`workspace_switched`&&t.type!==`workspace_starting`)return e;let n=t.models.find(e=>`${e.provider}/${e.id}`===t.model);return{...e,replyConformance:{},structuredAppearance:t.type===`workspace_switched`||t.type===`workspace_starting`?null:e.structuredAppearance,agentStarting:t.agentStarting===!0,outpostUpdate:t.outpostUpdate??e.outpostUpdate,outpostChanges:t.outpostChanges??e.outpostChanges,piPackages:t.piPackages??(t.type===`workspace_switched`||t.type===`workspace_starting`?null:e.piPackages),...t.type===`workspace_switched`||t.type===`workspace_starting`?{piPackageLookup:null,piPackageChange:null,piPackageUpdate:null}:{},serverRestarting:!1,restartNeeded:t.restartNeeded??[],connected:!0,brandingReady:!0,workspace:t.workspace??null,workspaces:t.workspaces??[],workspaceLocked:t.workspaceLocked===!0,embedWorkspaceControls:t.embedWorkspaceControls??`settings`,switching:!1,branding:t.branding,sessionId:t.sessionId,sessionName:t.sessionName??null,model:t.model,thinkingLevel:t.thinkingLevel,thinkingLevels:t.thinkingLevels,modelSupportsReasoning:n?.reasoning??!1,models:t.models,commands:t.commands,extensionsBinding:t.extensionsBinding===!0,isStreaming:t.isStreaming,items:t.items,olderHistory:t.olderItems?{remaining:t.olderItems,have:0,loading:!1,error:null}:null,pendingPrompt:null,workPlan:t.workPlan??null,outcome:null,queue:t.queuedPrompts??[],errors:[],contextUsage:t.contextUsage??null,isCompacting:!1,dialogQueue:[],notifications:[],statuses:{},widgets:{},extensionTitle:void 0,editorPrefill:null,tree:null,fileTree:{},directoryRequests:{},fileOperation:null,writableRoot:t.writableRoot,docxTemplate:t.docxTemplate,gitAvailable:t.gitAvailable===!0,gitUnavailable:t.gitUnavailable??null,credentials:t.credentials??null,extensionPaths:t.extensionPaths??null,configuredExtensionPaths:t.configuredExtensionPaths??[],userExtensionPaths:t.userExtensionPaths??[],extensionLock:t.extensionLock===!0,tools:t.tools??[],sandbox:t.sandbox??null,terminal:t.terminal??null,confinement:t.confinement??null,sandboxGrants:t.sandboxGrants??null,userSkillPaths:t.userSkillPaths??[],serverBrowse:null,settingsApply:null,versions:t.versions??null,agentResources:t.agentResources??null,agentResourceOperations:t.type===`hello`||t.type===`workspace_switched`||t.type===`workspace_starting`?B1():e.agentResourceOperations}}function q1(e,t){if(t.type===`connected`)return{...e,connected:!0,authRequired:!1};if(t.type===`workspace_switching`)return{...e,switching:!0};if(t.type===`pi_package_update_started`)return{...e,piPackageUpdate:{requestId:t.requestId,source:t.source,status:`pending`}};if(t.type===`pi_package_lookup_started`){let{type:n,...r}=t;return{...e,piPackageLookup:{...r,status:`pending`}}}if(t.type===`pi_package_lookup_closed`)return{...e,piPackageLookup:null};if(t.type===`pi_package_change_started`){let{type:n,...r}=t;return{...e,piPackageChange:{...r,status:`pending`}}}if(t.type===`auth_required`)return{...e,connected:!1,authRequired:!0};if(t.type===`auth_retrying`)return{...e,authRequired:!1};if(t.type===`login_started`)return{...e,login:{flowId:t.flowId,provider:t.provider,method:t.method,events:[],prompt:null,done:null}};if(t.type===`login_answered`)return e.login?{...e,login:{...e.login,prompt:null}}:e;if(t.type===`login_dismissed`)return{...e,login:null};if(t.type===`disconnected`&&e.login&&!e.login.done&&(e={...e,login:{...e.login,prompt:null,done:{ok:!1,message:`Connection lost — the sign-in was stopped. Start it again.`}}}),t.type===`disconnected`){let t=e.openFile,n=t?.status===`loaded`&&t.pendingSave!==void 0?{...t,pendingSave:void 0,saveError:{message:`Connection lost while saving — try again`,conflict:!1}}:e.openFile,r=e.outcome?.status===`loading`?{...e.outcome,status:`error`,message:`Connection lost while loading Outcome.`}:e.outcome;return{...e,connected:!1,openFile:n,outcome:r}}if(t.type===`branding_settled`)return{...e,brandingReady:!0};if(t.type===`branding_loaded`)return{...e,brandingReady:!0,branding:t.branding};if(t.type===`composer_prefilled`)return{...e,editorPrefill:{text:t.text,nonce:e.editorPrefill?e.editorPrefill.nonce+1:1},...t.notice?{errors:[...e.errors,t.notice]}:{}};if(t.type===`prompt_sent`)return H1(t.text,e.commands)?e:{...e,pendingPrompt:{text:t.text,...t.images?.length?{images:t.images}:{}}};if(t.type===`pending_prompt_cancelled`)return!t.restoreText||!e.pendingPrompt?e:{...e,editorPrefill:{text:e.pendingPrompt.text,nonce:e.editorPrefill?e.editorPrefill.nonce+1:1}};if(t.type===`dismiss_notification`)return{...e,notifications:e.notifications.filter(e=>e.id!==t.id)};if(t.type===`dialog_answered`)return{...e,dialogQueue:e.dialogQueue.slice(1)};if(t.type===`dir_list_started`){let n=e.fileTree[t.path];return{...e,fileTree:{...e.fileTree,[t.path]:t.preserveEntries&&Array.isArray(n)?n:`loading`},directoryRequests:{...e.directoryRequests,[t.path]:t.requestId}}}if(t.type===`raw_preview_changed`)return e.openFile?.path===t.path?{...e,previewRevision:e.previewRevision+1}:e;if(t.type===`file_read_started`){let n=e.openFile;return t.preserveContent&&n?.status===`loaded`&&n.path===t.path?{...e,openFile:{...n,refreshRequestId:t.requestId}}:{...e,openFile:{status:`loading`,path:t.path,requestId:t.requestId,...t.reveal?{reveal:t.reveal}:{}}}}if(t.type===`file_save_started`){let n=e.openFile;return!e.connected||n?.status!==`loaded`||n.path!==t.path?e:{...e,openFile:{...n,pendingSave:{requestId:t.requestId,content:t.content},saveError:void 0}}}if(t.type===`close_file_preview`)return{...e,openFile:null};if(t.type===`file_search_started`)return{...e,fileSearch:{status:`loading`,query:t.query,requestId:t.requestId,results:[]}};if(t.type===`file_search_cleared`)return{...e,fileSearch:null};if(t.type===`content_search_started`)return{...e,contentSearch:{status:`loading`,query:t.query,requestId:t.requestId,hits:[],truncated:!1,skipped:0}};if(t.type===`content_search_cleared`)return{...e,contentSearch:null};if(t.type===`file_create_started`)return{...e,createError:null,created:null};if(t.type===`file_operation_started`)return{...e,fileOperation:{status:`pending`,operation:t.operation,path:t.path,requestId:t.requestId}};if(t.type===`session_search_started`)return{...e,sessionSearch:{status:`loading`,query:t.query,requestId:t.requestId,results:[]}};if(t.type===`session_search_cleared`)return{...e,sessionSearch:null};if(t.type===`history_load_started`)return e.olderHistory?{...e,olderHistory:{...e.olderHistory,loading:!0,error:null}}:e;if(t.type===`history_loaded`)return e.olderHistory?{...e,items:[...t.items,...e.items],olderHistory:{remaining:t.remaining,have:e.olderHistory.have+t.items.length,loading:!1,error:null}}:e;if(t.type===`history_load_failed`)return e.olderHistory?{...e,olderHistory:{...e.olderHistory,loading:!1,error:t.message}}:e;if(t.type===`git_diff_started`||t.type===`git_diff_cleared`)return{...e,gitDiff:null};if(t.type===`git_baseline_started`){let n=e.gitBaseline?.path===t.path?e.gitBaseline.text:void 0;return{...e,gitBaseline:{path:t.path,requestId:t.requestId,...n===void 0?{}:{text:n}}}}if(t.type===`git_baseline_cleared`)return{...e,gitBaseline:null};if(t.type===`git_show_cleared`)return{...e,gitShow:null,gitLog:e.gitLog};if(t.type===`git_log_started`){let n=e.gitLog?.repo===t.repo?e.gitLog.entries:null;return{...e,gitLog:{repo:t.repo,entries:n,error:null,requestId:t.requestId}}}if(t.type===`git_log_closed`)return e.gitLog===null?e:{...e,gitLog:null};if(t.type===`git_file_history_started`)return{...e,gitFileHistory:{path:t.path,status:`loading`,entries:[],requestId:t.requestId},gitFileDiff:null};if(t.type===`git_file_history_closed`)return{...e,gitFileHistory:null,gitFileDiff:null};if(t.type===`git_file_diff_started`)return{...e,gitFileDiff:{base:t.base,target:t.target,status:`loading`,beforeText:e.gitFileDiff?.beforeText??``,afterText:e.gitFileDiff?.afterText??``,requestId:t.requestId}};if(t.type===`git_file_diff_cleared`)return{...e,gitFileDiff:null};if(t.type===`server_browse_started`)return{...e,serverBrowse:{status:`loading`,path:e.serverBrowse?.path??t.path,parent:e.serverBrowse?.parent??null,entries:e.serverBrowse?.entries??[],requestId:t.requestId}};if(t.type===`server_browse_closed`)return{...e,serverBrowse:null};if(t.type===`settings_apply_started`)return{...e,settingsApply:{status:`applying`}};if(t.type===`resource_clone_path_started`)return{...e,agentResourceOperations:{...e.agentResourceOperations,clonePath:{requestId:t.requestId,status:`loading`}}};if(t.type===`resource_preview_started`)return{...e,agentResourceOperations:{...e.agentResourceOperations,preview:{requestId:t.requestId,status:`loading`}}};if(t.type===`resource_enrollment_started`)return{...e,agentResourceOperations:{...e.agentResourceOperations,enrollment:{requestId:t.requestId,status:`loading`}}};if(t.type===`resource_refresh_started`)return{...e,agentResourceOperations:{...e.agentResourceOperations,refresh:{requestId:t.requestId,status:`loading`,...t.repositoryId?{repositoryId:t.repositoryId}:{}}}};if(t.type===`resource_update_started`)return{...e,agentResourceOperations:{...e.agentResourceOperations,updates:{...e.agentResourceOperations.updates,[t.repositoryId]:{requestId:t.requestId,status:`loading`}}}};if(t.type===`resource_skills_started`){let n=e.agentResourceOperations;return{...e,agentResourceOperations:{...n,skills:{...n.skills,[t.repositoryId]:{requestId:t.requestId,status:`loading`}}}}}if(t.type===`resource_removal_started`){let n=e.agentResourceOperations;return{...e,agentResourceOperations:{...n,removals:{...n.removals,[t.repositoryId]:{requestId:t.requestId,status:`loading`}}}}}if(t.type===`outcome_started`)return{...e,outcome:{status:`loading`,requestId:t.requestId,workspaceRoot:t.workspaceRoot,sessionId:t.sessionId}};if(t.type===`outcome_failed`){let n=e.outcome;return n===null||n.status!==`loading`||n.requestId!==t.requestId?e:{...e,outcome:{...n,status:`error`,message:t.message}}}let n=t.message;if(n.type===`workspace_switched`&&e.agentStarting&&e.workspace&&n.workspace&&GB(n.workspace)===GB(e.workspace))return{...K1(e,n),openFile:e.openFile,gitDiff:e.gitDiff,gitBaseline:e.gitBaseline,fileTree:e.fileTree,directoryRequests:e.directoryRequests,contentSearch:e.contentSearch};switch(n.type){case`workspace_switched`:case`hello`:case`session_replaced`:case`update_config_ack`:case`workspace_starting`:return{...K1(e,n),openFile:null,gitDiff:null,gitBaseline:null,fileTree:{},directoryRequests:{},contentSearch:n.type===`session_replaced`?e.contentSearch:null};case`workspace_activity`:return{...e,workspaces:n.workspaces,workspace:(e.workspace&&n.workspaces.find(t=>GB(t)===GB(e.workspace)))??e.workspace};case`agent_resource_clone_path`:{let t=e.agentResourceOperations.clonePath;return t?.requestId===n.requestId?{...e,agentResourceOperations:{...e.agentResourceOperations,clonePath:{...t,status:`ready`,path:n.path}}}:e}case`agent_resource_preview`:{let t=e.agentResourceOperations.preview;return t?.requestId===n.requestId?{...e,agentResourceOperations:{...e.agentResourceOperations,preview:{...t,status:`ready`,preview:n.preview}}}:e}case`agent_resource_enrolled`:{let t=e.agentResourceOperations.enrollment;return t?.requestId===n.requestId?{...e,agentResources:n.inventory,agentResourceOperations:{...e.agentResourceOperations,preview:null,enrollment:{...t,status:`ready`}}}:e}case`agent_resource_assessments`:{let t=e.agentResourceOperations.refresh;if(t?.requestId!==n.requestId||!e.agentResources)return e;let r=new Map(n.assessments.map(e=>[e.repositoryId,e]));return{...e,agentResources:{...e.agentResources,repositories:e.agentResources.repositories.map(e=>({...e,assessment:r.get(e.id)??e.assessment}))},agentResourceOperations:{...e.agentResourceOperations,refresh:{...t,status:`ready`}}}}case`agent_resource_inventory`:return{...e,agentResources:n.inventory};case`agent_resource_update_result`:{let t=n.result.repositoryId;if(!t)return e;let r=e.agentResourceOperations.updates[t];return r?.requestId===n.requestId?{...e,agentResources:n.inventory,agentResourceOperations:{...e.agentResourceOperations,updates:{...e.agentResourceOperations.updates,[t]:{...r,status:`ready`,result:n.result}}}}:e}case`agent_resource_skills_applied`:{let t=e.agentResourceOperations,r=t.skills[n.repositoryId];return r?.requestId===n.requestId?{...e,agentResources:n.inventory,agentResourceOperations:{...t,skills:{...t.skills,[n.repositoryId]:{...r,status:`ready`}}}}:e}case`agent_resource_removed`:{let t=e.agentResourceOperations,r=t.removals[n.repositoryId];return r?.requestId===n.requestId?{...e,agentResources:n.inventory,agentResourceOperations:{...t,removals:{...t.removals,[n.repositoryId]:{...r,status:`ready`,result:n.result}}}}:e}case`agent_resource_error`:{let t=e=>e?.requestId===n.requestId?{...e,status:`error`,message:n.message}:null,r=t(e.agentResourceOperations.clonePath),i=t(e.agentResourceOperations.preview),a=t(e.agentResourceOperations.enrollment),o=t(e.agentResourceOperations.refresh),s=e=>{let t=Object.entries(e).find(([,e])=>e.requestId===n.requestId);return t?{...e,[t[0]]:{...t[1],status:`error`,message:n.message}}:null},c=s(e.agentResourceOperations.updates),l=s(e.agentResourceOperations.skills),u=s(e.agentResourceOperations.removals);return!r&&!i&&!a&&!o&&!c&&!l&&!u?e:{...e,agentResourceOperations:{...e.agentResourceOperations,...r?{clonePath:r}:{},...i?{preview:i}:{},...a?{enrollment:a}:{},...o?{refresh:o}:{},...c?{updates:c}:{},...l?{skills:l}:{},...u?{removals:u}:{}}}}case`workspace_error`:return{...e,switching:!1,errors:[...e.errors,n.message]};case`sessions`:return{...e,sessions:n.sessions};case`session_search_results`:return e.sessionSearch?.requestId===n.requestId?{...e,sessionSearch:{...e.sessionSearch,status:`loaded`,results:n.sessions}}:e;case`tree`:return{...e,tree:n.roots};case`editor_prefill`:return{...e,editorPrefill:{text:n.text,nonce:e.editorPrefill?e.editorPrefill.nonce+1:1}};case`model_changed`:return{...e,model:n.model,modelSupportsReasoning:n.reasoning,thinkingLevels:n.thinkingLevels};case`login_event`:return e.login?.flowId===n.flowId?{...e,login:{...e.login,events:[...e.login.events,n.event]}}:e;case`login_prompt`:return e.login?.flowId===n.flowId?{...e,login:{...e.login,prompt:{promptId:n.promptId,prompt:n.prompt}}}:e;case`login_prompt_cancelled`:return e.login?.flowId!==n.flowId||e.login.prompt?.promptId!==n.promptId?e:{...e,login:{...e.login,prompt:null}};case`login_done`:return e.login?.flowId===n.flowId?{...e,login:{...e.login,prompt:null,done:{ok:n.ok,...n.cancelled?{cancelled:!0}:{},...n.message?{message:n.message}:{}}}}:e;case`credentials_changed`:{let t=n.models.find(e=>`${e.provider}/${e.id}`===n.model);return{...e,models:n.models,model:n.model,modelSupportsReasoning:t?.reasoning??!1,thinkingLevels:void 0,credentials:n.credentials}}case`extensions_bound`:return{...e,commands:n.commands,tools:n.tools??e.tools,extensionsBinding:!1};case`thinking_changed`:return{...e,thinkingLevel:n.level};case`work_plan_changed`:return{...e,workPlan:n.workPlan};case`workspace_outcome`:{let t=e.outcome;return t===null||t.requestId!==n.requestId||t.sessionId!==e.sessionId||n.outcome.sessionId!==e.sessionId||t.workspaceRoot!==null&&n.outcome.workspaceRoot!==t.workspaceRoot?e:{...e,outcome:{...t,status:`loaded`,outcome:n.outcome}}}case`workspace_outcome_error`:{let t=e.outcome;return t===null||t.status!==`loading`||t.requestId!==n.requestId?e:{...e,outcome:{...t,status:`error`,message:n.message}}}case`user`:return{...e,pendingPrompt:null,items:[...e.items,{kind:`user`,text:n.text,...n.images?{images:n.images}:{}}]};case`user_entries`:{let{entries:t}=n,r=e.items.flatMap((e,t)=>e.kind===`user`?[t]:[]),i=new Map;for(let n=r.length-1,a=t.length-1;n>=0&&a>=0;n--,a--){let o=e.items[r[n]];if(o.kind!==`user`||o.text!==t[a].text)break;i.set(r[n],t[a].entryId)}return{...e,items:e.items.map((e,t)=>{if(e.kind!==`user`)return e;let n=i.get(t);if(n===e.entryId)return e;if(n===void 0){let{entryId:t,...n}=e;return n}return{...e,entryId:n}})}}case`agent_start`:return{...e,isStreaming:!0,errors:[]};case`agent_end`:return{...e,isStreaming:!1,items:e.items.map(e=>e.kind===`tool`&&e.running?{...e,running:!1}:e.kind===`assistant`&&e.streaming?{...e,streaming:!1}:e)};case`assistant_start`:return{...e,items:[...e.items,{kind:`assistant`,blocks:[],streaming:!0}]};case`block_delta`:return{...e,items:U1(e.items,e=>{let t=[...e.blocks],r=t.findIndex(e=>e.contentIndex===n.contentIndex);return r>=0?t[r]={...t[r],text:t[r].text+n.delta}:t.push({type:n.block,text:n.delta,contentIndex:n.contentIndex}),{...e,blocks:t,streaming:!0}})};case`assistant_end`:return{...e,items:U1(e.items,()=>n.item)};case`custom_message`:return{...e,items:[...e.items,n.item]};case`tool_start`:return{...e,items:W1(e.items,n.toolCallId,n.toolName,{toolName:n.toolName,args:n.args,running:!0,callHtml:n.callHtml})};case`tool_update`:return{...e,items:W1(e.items,n.toolCallId,`tool`,{output:n.text,...n.outputHtml===void 0?{}:{outputHtml:n.outputHtml,outputHtmlCollapsed:n.outputHtmlCollapsed},...typeof n.progress==`number`?{progress:n.progress}:{}})};case`tool_end`:return{...e,items:W1(e.items,n.toolCallId,`tool`,{output:n.text,isError:n.isError,running:!1,outputHtml:n.outputHtml,outputHtmlCollapsed:n.outputHtmlCollapsed,structured:n.structured})};case`structured_conformance`:return{...e,items:G1(e.items,n.toolCallId,{structuredConformance:n.conformance})};case`structured_appearance`:return{...e,structuredAppearance:n.appearance};case`outpost_update`:return{...e,outpostUpdate:n.notice};case`outpost_changes`:return{...e,outpostChanges:n.changes};case`pi_packages`:return{...e,piPackages:n.packages,...e.piPackageChange&&e.piPackageChange.status!==`pending`?{piPackageChange:null}:{}};case`pi_package_update_result`:{let t=e.piPackageUpdate;return t?.requestId===n.requestId?{...e,piPackageUpdate:{requestId:n.requestId,source:t.source,status:n.outcome,message:n.message}}:e}case`pi_package_lookup_result`:{let t=e.piPackageLookup;if(t?.requestId!==n.requestId)return e;let{status:r,...i}=t;return n.outcome===`found`&&n.version!==void 0?{...e,piPackageLookup:{...i,status:`found`,resolved:n.version,message:n.message}}:{...e,piPackageLookup:{...i,status:`refused`,message:n.message}}}case`pi_package_change_result`:{let t=e.piPackageChange;if(t?.requestId!==n.requestId)return e;let r={...e,piPackageChange:{requestId:t.requestId,key:t.key,action:t.action,status:n.outcome,message:n.message}};return n.outcome===`installed`?{...r,piPackageLookup:null}:r}case`restart_needed`:return{...e,restartNeeded:n.reasons};case`server_restarting`:return{...e,serverRestarting:!0,piPackageUpdate:null};case`reply_structured_conformance`:return{...e,replyConformance:{...e.replyConformance,[n.key]:n.conformance}};case`queue`:return{...e,queue:n.prompts,pendingPrompt:n.prompts.length>e.queue.length?null:e.pendingPrompt};case`queued_prompt_refused`:return{...e,errors:[...e.errors,n.message],queuedEditRefused:n.text===void 0?e.queuedEditRefused:{text:n.text,nonce:(e.queuedEditRefused?.nonce??0)+1}};case`context_usage`:return{...e,contextUsage:n.usage};case`confinement`:return{...e,confinement:n.confinement};case`sandbox_grant_request`:{let t=e.sandboxGrants??{pending:[],active:{hosts:[],directories:[]}};return t.pending.some(e=>e.id===n.request.id)?e:{...e,sandboxGrants:{...t,pending:[...t.pending,n.request]}}}case`sandbox_grant_resolved`:return e.sandboxGrants?{...e,sandboxGrants:{...e.sandboxGrants,pending:e.sandboxGrants.pending.filter(e=>e.id!==n.id)}}:e;case`sandbox_grants`:return{...e,sandboxGrants:{pending:e.sandboxGrants?.pending??[],active:n.active}};case`compaction_start`:return{...e,isCompacting:!0};case`compaction_end`:return{...e,isCompacting:!1,errors:n.errorMessage?[...e.errors,n.errorMessage]:e.errors};case`error`:return{...e,errors:[...e.errors,n.message],pendingPrompt:null,settingsApply:e.settingsApply?.status===`applying`?{status:`error`,message:n.message}:e.settingsApply};case`server_directory`:return e.serverBrowse?.requestId===n.requestId?{...e,serverBrowse:{status:`loaded`,path:n.path,parent:n.parent,entries:n.entries,requestId:n.requestId}}:e;case`server_directory_error`:return e.serverBrowse?.requestId===n.requestId?{...e,serverBrowse:{...e.serverBrowse,status:`error`,error:n.message}}:e;case`directory_listing`:return n.requestId.startsWith(`dir:`)&&e.directoryRequests[n.path]!==n.requestId?e:{...e,fileTree:{...e.fileTree,[n.path]:n.entries},...n.requestId.startsWith(`create:`)?{created:n.path,createError:null}:{}};case`file_content`:{let t=e.openFile,r=t?.status===`loading`&&t.requestId===n.requestId,i=t?.status===`loaded`&&t.refreshRequestId===n.requestId;return!r&&!i?e:{...e,openFile:{status:`loaded`,path:n.path,content:n.content,size:n.size,mtimeMs:n.mtimeMs,...n.documentIssues===void 0?{}:{documentIssues:n.documentIssues},...r&&t.reveal?{reveal:t.reveal}:{}}}}case`file_written`:{if(n.requestId.startsWith(`create:`))return{...e,createError:null,created:n.path,openFile:{status:`loaded`,path:n.path,content:``,size:n.size,mtimeMs:n.mtimeMs,justCreated:!0}};let t=e.openFile;return t?.status!==`loaded`||t.pendingSave?.requestId!==n.requestId?e:{...e,openFile:{status:`loaded`,path:t.path,content:t.pendingSave.content,size:n.size,mtimeMs:n.mtimeMs}}}case`file_operation_result`:{if(e.fileOperation?.status!==`pending`||e.fileOperation.requestId!==n.requestId)return e;let t=n.previousPath??n.path,r=n.operation===`delete_file`&&e.openFile?.path===n.path?null:e.openFile?.path===t?{...e.openFile,path:n.path}:e.openFile,i=e.gitFileHistory?.path===t||e.gitFileHistory?.path===n.path,a=e.gitDiff?.path===t||e.gitDiff?.path===n.path,o=e.gitBaseline?.path===t||e.gitBaseline?.path===n.path;return{...e,openFile:r,gitFileHistory:i?null:e.gitFileHistory,gitFileDiff:i?null:e.gitFileDiff,gitDiff:a?null:e.gitDiff,gitBaseline:o?null:e.gitBaseline,fileOperation:{status:`succeeded`,operation:n.operation,path:e.fileOperation.path,resultPath:n.path,requestId:n.requestId}}}case`file_browser_error`:if(n.requestId.startsWith(`dir:`))return e.directoryRequests[n.path]===n.requestId?{...e,fileTree:{...e.fileTree,[n.path]:{error:n.message}}}:e;if(n.requestId.startsWith(`create:`))return{...e,createError:{path:n.path,message:n.message}};if(n.requestId.startsWith(`write:`)){let t=e.openFile;return t?.status!==`loaded`||t.pendingSave?.requestId!==n.requestId?e:{...e,openFile:{...t,pendingSave:void 0,saveError:{message:n.message,conflict:n.reason===`conflict`}}}}return n.requestId.startsWith(`fileop:`)?e.fileOperation?.status!==`pending`||e.fileOperation.requestId!==n.requestId?e:{...e,fileOperation:{status:`error`,operation:e.fileOperation.operation,path:e.fileOperation.path,message:n.message,requestId:n.requestId}}:e.openFile?.status===`loading`&&e.openFile.requestId===n.requestId?{...e,openFile:{status:`error`,path:n.path,message:n.message}}:e.openFile?.status===`loaded`&&e.openFile.refreshRequestId===n.requestId?{...e,openFile:{...e.openFile,refreshRequestId:void 0}}:e;case`file_search_results`:return e.fileSearch?.requestId===n.requestId?{...e,fileSearch:{...e.fileSearch,status:`loaded`,results:n.results}}:e;case`content_search_results`:return e.contentSearch?.requestId===n.requestId?{...e,contentSearch:{...e.contentSearch,status:`loaded`,hits:n.hits,truncated:n.truncated,skipped:n.skipped}}:e;case`git_status`:{let t={};for(let e of n.files)t[e.path]=e.status;let r=e.gitStatus;if(n.repo===void 0||r===null)return{...e,gitStatus:{repos:n.repos,files:t}};let i={};for(let[e,t]of Object.entries(r.files))NV(r.repos,e)?.repo!==n.repo&&(i[e]=t);let a=r.repos.map(e=>n.repos.find(t=>t.repo===e.repo)??e);return{...e,gitStatus:{repos:a,files:{...i,...t}}}}case`git_repositories_changed`:return{...e,gitAvailable:n.available,gitUnavailable:n.available?null:n.unavailable??null,gitStatus:n.available?e.gitStatus:null};case`git_diff`:return n.requestId.startsWith(`gitbase:`)?e.gitBaseline?.requestId===n.requestId?{...e,gitBaseline:{...e.gitBaseline,text:n.before}}:e:{...e,gitDiff:{path:n.path,before:n.before,after:n.after}};case`git_log`:return e.gitLog===null?e:{...e,gitLog:{...e.gitLog,repo:n.repo,entries:n.entries,error:null}};case`git_show`:return{...e,gitShow:{sha:n.sha,patch:n.patch,truncated:n.truncated}};case`git_file_log`:return e.gitFileHistory?.requestId===n.requestId?{...e,gitFileHistory:{...e.gitFileHistory,status:`loaded`,entries:n.entries}}:e;case`git_file_diff`:return e.gitFileDiff===null||!z1(e.gitFileDiff,n)?e:{...e,gitFileDiff:{...e.gitFileDiff,status:`loaded`,beforeText:n.beforeText,afterText:n.afterText}};case`git_error`:return n.requestId.startsWith(`gitbase:`)?e.gitBaseline?.requestId===n.requestId?{...e,gitBaseline:null}:e:n.requestId.startsWith(`gitdiff:`)?{...e,gitDiff:e.openFile?{path:e.openFile.path,error:n.message}:null}:n.requestId===e.gitFileHistory?.requestId?{...e,gitFileHistory:{...e.gitFileHistory,status:`error`,error:n.message}}:n.requestId===e.gitFileDiff?.requestId?{...e,gitFileDiff:{...e.gitFileDiff,status:`error`,error:n.message}}:n.requestId.startsWith(`gitlog:`)?n.requestId===e.gitLog?.requestId?{...e,gitLog:{...e.gitLog,entries:null,error:n.message}}:e:{...e,errors:[...e.errors,`git: ${n.message}`]};case`extension_ui_request`:switch(n.method){case`select`:case`confirm`:case`input`:case`editor`:return{...e,dialogQueue:[...e.dialogQueue,n]};case`notify`:return{...e,notifications:[...e.notifications,{id:n.id,message:n.message,notifyType:n.notifyType}]};case`setStatus`:{let t={...e.statuses};return n.statusText===void 0?delete t[n.statusKey]:t[n.statusKey]=n.statusText,{...e,statuses:t}}case`setWidget`:{let t={...e.widgets};return n.widgetLines===void 0?delete t[n.widgetKey]:t[n.widgetKey]={lines:n.widgetLines,placement:n.widgetPlacement??`aboveEditor`},{...e,widgets:t}}case`setTitle`:return{...e,extensionTitle:n.title};case`set_editor_text`:return{...e,editorPrefill:{text:n.text,nonce:e.editorPrefill?e.editorPrefill.nonce+1:1}};default:return e}default:return e}}function J1(e,t,n){let r=e?`${e.replace(/^http/,`ws`)}/ws`:`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/ws`,i=new URLSearchParams;t&&i.set(`token`,t),n&&i.set(`workspace`,n);let a=i.toString();return a?`${r}?${a}`:r}var Y1=12e4,X1=3e4,Z1=2e4,Q1=45e3,$1=4401,e0=1e3;function t0(e=``,t,n=!1,r){let[i,a]=(0,v.useReducer)(q1,V1),o=(0,v.useRef)(null),[s,c]=(0,v.useState)(0),l=(0,v.useRef)(null),u=(0,v.useRef)(null);s===0&&l.current===null&&(l.current=t??(n?P1():N1()));let d=(0,v.useRef)(i.fileTree),f=(0,v.useRef)(i.openFile);(0,v.useEffect)(()=>{d.current=i.fileTree},[i.fileTree]),(0,v.useEffect)(()=>{f.current=i.openFile},[i.openFile]);let p=(0,v.useRef)(null);(0,v.useEffect)(()=>{p.current=i.gitDiff?.path??null},[i.gitDiff]);let m=(0,v.useRef)(new Map),h=(0,v.useRef)(new Map),g=(0,v.useRef)(new Map),_=(0,v.useRef)(new Map),y=(0,v.useRef)(i.sessionId);(0,v.useEffect)(()=>{y.current=i.sessionId},[i.sessionId]);let b=(0,v.useRef)(!1),x=(0,v.useRef)(i.olderHistory);(0,v.useEffect)(()=>{x.current=i.olderHistory},[i.olderHistory]);let S=(0,v.useRef)(i.writableRoot);(0,v.useEffect)(()=>{S.current=i.writableRoot},[i.writableRoot]);let C=(0,v.useRef)(!1),w=(0,v.useRef)(new Map),T=(0,v.useRef)(new Map),E=i.workspace?GB(i.workspace):null,D=(0,v.useRef)({key:E,root:i.sandbox?.projectRoot??i.sandbox?.root,writableRoot:i.writableRoot}),O=(0,v.useRef)(0),ee=O.current,te=(0,v.useRef)({workspaceRoot:E,sessionId:i.sessionId});(0,v.useEffect)(()=>{te.current={workspaceRoot:E,sessionId:i.sessionId}},[E,i.sessionId]);let k=(0,v.useCallback)(e=>{[`switch_workspace`,`open_project`,`close_project`,`open_side_session`].includes(e.type)&&O.current++;let t=o.current;t&&t.readyState===WebSocket.OPEN&&t.send(JSON.stringify(e))},[]),ne=(0,v.useRef)(!1),A=(0,v.useRef)(null),re=(0,v.useRef)(!1),j=(0,v.useRef)(null),ie=(0,v.useRef)(()=>{}),ae=(0,v.useCallback)(()=>{A.current=null,j.current!==null&&(clearTimeout(j.current),j.current=null)},[]),oe=(0,v.useCallback)(()=>{let e=o.current;if(!e||e.readyState!==WebSocket.OPEN)return;if(A.current!==null){re.current=!0;return}let t=`outcome:${j1()}`;A.current=t;let n=te.current;a({type:`outcome_started`,requestId:t,...n}),k({type:`get_outcome`,requestId:t}),j.current=setTimeout(()=>{A.current===t&&(ae(),re.current=!1,a({type:`outcome_failed`,requestId:t,message:`The Outcome took too long to answer — try again.`}))},Q1)},[k,ae]);ie.current=oe;let ce=(0,v.useCallback)(()=>{ne.current&&ie.current()},[]),ue=(0,v.useCallback)(e=>{ne.current=e,e?oe():re.current=!1},[oe]),de=(0,v.useCallback)((e,t=!1)=>{e===``&&(C.current=!0);let n=`dir:${j1()}`;a({type:`dir_list_started`,path:e,requestId:n,preserveEntries:t}),k({type:`list_directory`,path:e,requestId:n})},[k]),fe=(0,v.useRef)(!1),M=(0,v.useRef)(null),pe=(0,v.useCallback)((e,t)=>{let n=`gitlog:${j1()}`;a({type:`git_log_started`,repo:e,requestId:n}),k({type:`git_log`,repo:e,...t?{limit:t}:{},requestId:n})},[k]),N=(0,v.useRef)([]);(0,v.useEffect)(()=>{N.current=i.gitStatus?.repos??[]},[i.gitStatus]);let me=(0,v.useRef)(new Set),he=(0,v.useRef)(new Set),ge=(0,v.useRef)(new Map),P=(0,v.useCallback)(e=>{if(!fe.current)return;let t=e??``;if(me.current.has(t)){he.current.add(t);return}me.current.add(t);let n=`git:${j1()}`;ge.current.set(n,t),k({type:`git_status`,...e===void 0?{}:{repo:e},requestId:n})},[k]),_e=(0,v.useCallback)(e=>{let t=ge.current.get(e)??``;ge.current.delete(e),me.current.delete(t),he.current.delete(t)&&P(t===``?void 0:t)},[P]),ve=(0,v.useCallback)(e=>{d.current[e]!==void 0&&de(e,!0)},[de]),ye=(0,v.useCallback)(()=>{de(``,!0);for(let e of Object.keys(d.current))e!==``&&ve(e)},[ve,de]);(0,v.useEffect)(()=>{i.connected&&C.current&&d.current[``]===void 0&&de(``)},[i.connected,i.fileTree,de]),(0,v.useEffect)(()=>{i.connected&&ne.current&&A.current===null&&ie.current()},[i.connected]);let be=i.openFile?.path??null,xe=be===null?void 0:i.gitStatus?.files[be],Se=i.gitBaseline!==null;(0,v.useEffect)(()=>{let e=xe===`modified`||xe===`added`||xe===`conflicted`;if(!i.connected||be===null||!e){Se&&a({type:`git_baseline_cleared`});return}let t=`gitbase:${j1()}`;a({type:`git_baseline_started`,path:be,requestId:t}),k({type:`git_diff`,path:be,requestId:t})},[i.connected,be,xe,i.gitStatus,k]),(0,v.useEffect)(()=>{let t=!1;return fetch(`${e}/branding`,{headers:l.current?{Authorization:`Bearer ${l.current}`}:{}}).then(e=>e.ok?e.json():null).then(e=>{t||a(e?{type:`branding_loaded`,branding:e}:{type:`branding_settled`})}).catch(()=>{t||a({type:`branding_settled`})}),()=>{t=!0}},[e,s]),(0,v.useEffect)(()=>{let t,n=!1;function i(){let s=new WebSocket(J1(e,l.current,r));o.current=s,s.onopen=()=>{o.current===s&&a({type:`connected`})},s.onmessage=e=>{if(o.current!==s)return;let t;try{t=JSON.parse(e.data)}catch{return}if(t.type===`hello`){for(let e of T.current.values())if(e.socket!==s){for(let t of w.current.get(e.message.terminalId)?.onData??[])t(`\r
|
|
1536
1536
|
[Connection restored; starting a new terminal session.]\r
|
|
1537
|
-
`);e.socket=s,s.send(JSON.stringify(e.message))}}if(t.type===`terminal_data`){let e=w.current.get(t.terminalId);if(e)for(let n of e.onData)n(t.data)}else if(t.type===`terminal_cwd`){let e=T.current.get(t.terminalId);e&&(e.message.cwd=t.cwd);let n=w.current.get(t.terminalId);if(n)for(let e of n.onCwd)e(t.cwd)}else if(t.type===`terminal_exit`){T.current.delete(t.terminalId);let e=w.current.get(t.terminalId);if(e)for(let n of e.onExit)n(t.exitCode)}else if(t.type===`terminal_error`){T.current.delete(t.terminalId);let e=w.current.get(t.terminalId);if(e)for(let n of e.onError)n(t.message)}else if(t.type===`history_items`){let e=_.current.get(t.requestId);e&&(_.current.delete(t.requestId),e.resolve({items:t.items,remaining:t.remaining}))}else if(t.type===`history_unavailable`){let e=_.current.get(t.requestId);e&&(_.current.delete(t.requestId),e.reject(new I1(t.reason,t.kind)))}else if((t.type===`file_content`||t.type===`file_written`||t.type===`arrangement_saved`||t.type===`file_browser_error`)&&h.current.has(t.requestId)){let e=h.current.get(t.requestId);h.current.delete(t.requestId),t.type===`file_browser_error`?e.reject(new wz(t.message,t.reason)):t.type===`file_content`?e.resolve({content:t.content,mtimeMs:t.mtimeMs}):t.type===`arrangement_saved`?e.resolve({path:t.path}):e.resolve({mtimeMs:t.mtimeMs})}else if(t.type===`file_search_results`&&h.current.has(t.requestId)){let e=h.current.get(t.requestId);h.current.delete(t.requestId),e.resolve({results:t.results})}else{if(t.type===`hello`||t.type===`workspace_switched`||t.type===`workspace_starting`||t.type===`session_replaced`||t.type===`update_config_ack`){let e={key:t.workspace?GB(t.workspace):null,root:t.sandbox?.projectRoot??t.sandbox?.root,writableRoot:t.writableRoot},n=D.current;(t.type===`hello`||n.key!==e.key||n.root!==e.root||n.writableRoot!==e.writableRoot)&&O.current++,D.current=e,S.current=t.writableRoot}if(t.type===`file_uploaded`){let e=m.current.get(t.requestId);e&&(m.current.delete(t.requestId),e.resolve(t.path))}else if(t.type===`file_browser_error`&&m.current.has(t.requestId)){let e=m.current.get(t.requestId);m.current.delete(t.requestId),e.reject(new zV(t.message,t.reason))}else if(t.type===`file_changed`){ce();for(let e of g.current.get(t.path)??[])e();ve(R1(t.path));let e=f.current;if(e?.status===`loaded`&&e.path===t.path){let e=`file:${j1()}`;a({type:`file_read_started`,path:t.path,requestId:e,preserveContent:!0}),k({type:`read_file`,path:t.path,requestId:e})}p.current===t.path&&k({type:`git_diff`,path:t.path,requestId:`gitdiff:${j1()}`}),P(NV(N.current,t.path)?.repo)}else if(t.type===`directory_changed`){ce();for(let[e,n]of g.current)if(R1(e)===t.path)for(let e of n)e();ve(t.path);let e=f.current;if(e!==null&&R1(e.path)===t.path){if(se(e.path)||le(e.path))a({type:`raw_preview_changed`,path:e.path});else if(e.status===`loaded`){let t=`file:${j1()}`;a({type:`file_read_started`,path:e.path,requestId:t,preserveContent:!0}),k({type:`read_file`,path:e.path,requestId:t})}}let n=p.current;n!==null&&R1(n)===t.path&&k({type:`git_diff`,path:n,requestId:`gitdiff:${j1()}`}),P()}else{if((t.type===`hello`||t.type===`session_replaced`||t.type===`workspace_switched`||t.type===`workspace_starting`)&&(fe.current=t.gitAvailable===!0,t.type!==`session_replaced`&&P()),t.type===`agent_end`&&(P(),ce()),t.type===`git_repositories_changed`&&(ce(),fe.current=t.available,t.available&&P()),t.type===`git_changed`){ce(),P(t.repo===``?void 0:t.repo);let e=M.current;e!==null&&e.repo===t.repo&&pe(e.repo,e.limit)}if((t.type===`git_status`||t.type===`git_error`&&t.requestId.startsWith(`git:`))&&_e(t.requestId),t.type===`work_plan_changed`&&ce(),(t.type===`workspace_outcome`||t.type===`workspace_outcome_error`)&&A.current===t.requestId&&(ae(),re.current&&(re.current=!1,queueMicrotask(()=>ie.current()))),t.type===`hello`||t.type===`session_replaced`||t.type===`workspace_switched`||t.type===`workspace_starting`||t.type===`update_config_ack`){ae(),re.current=!1;let e=te.current,n=t.sessionId===e.sessionId,r=(t.workspace?GB(t.workspace):null)===e.workspaceRoot;ne.current&&n&&r&&queueMicrotask(()=>ie.current())}if(t.type===`file_operation_result`){let e=t.previousPath??t.path,n=f.current;t.operation===`delete_file`&&n?.path===t.path?f.current=null:n?.path===e&&(f.current={...n,path:t.path})}a({type:`server`,message:t}),t.type===`session_replaced`&&de(``)}}},s.onclose=e=>{if(o.current===s){O.current++,me.current.clear(),he.current.clear(),ge.current.clear(),ae(),re.current=!1;for(let e of m.current.values())e.reject(new zV(`The connection dropped before the upload finished`));m.current.clear();for(let e of h.current.values())e.reject(new wz(`The connection dropped before the server answered`));h.current.clear();for(let e of _.current.values())e.reject(new I1(`the connection dropped before the older messages arrived`,`failed`));_.current.clear(),e.code===$1?a({type:`auth_required`}):(a({type:`disconnected`}),n||(t=window.setTimeout(i,1500)))}}}return i(),()=>{n=!0,t!==void 0&&clearTimeout(t);let e=o.current;o.current=null,e?.close()}},[k,e,P,_e,ve,de,ce,ae,s,r,pe]);let Ce=(0,v.useCallback)((e,t)=>{let n=o.current;if(!n||n.readyState!==WebSocket.OPEN)return Promise.reject(new I1(`not connected to the server`,`failed`));let r=`history:${j1()}`;return new Promise((n,i)=>{let a=window.setTimeout(()=>{_.current.delete(r)&&i(new I1(`the older messages did not arrive`,`failed`))},Z1),o=e=>t=>{clearTimeout(a),e(t)};_.current.set(r,{resolve:o(n),reject:o(i)}),k({type:`history_before`,sessionId:y.current,have:e,count:t,requestId:r})})},[k]),we=(0,v.useCallback)(async()=>{let e=x.current;if(!(!e||e.loading||b.current||e.remaining<=0)){b.current=!0,a({type:`history_load_started`});try{let t=await Ce(e.have,50);a({type:`history_loaded`,items:t.items,remaining:t.remaining})}catch(e){if(e instanceof I1&&e.kind===`stale`){a({type:`history_load_failed`,message:``});return}a({type:`history_load_failed`,message:e instanceof Error?e.message:`the older messages could not be loaded`})}finally{b.current=!1}}},[Ce]);return{state:i,fileIo:(0,v.useMemo)(()=>{function e(e,t){let n=o.current;if(!n||n.readyState!==WebSocket.OPEN)return Promise.reject(new wz(`not connected to the server`));let r=`${e}:${j1()}`;return new Promise((e,n)=>{let i=window.setTimeout(()=>{h.current.delete(r)&&n(new wz(`the server did not answer`))},X1);h.current.set(r,{resolve:t=>{clearTimeout(i),e(t)},reject:e=>{clearTimeout(i),n(e)}}),k(t(r))})}return{read:t=>e(`fileio-read`,e=>({type:`read_file`,path:t,requestId:e})),write:(t,n,r)=>e(`fileio-write`,e=>({type:`write_file`,path:t,content:n,expectedMtimeMs:r,requestId:e})),find:async t=>(await e(`fileio-find`,e=>({type:`search_files`,query:t,requestId:e}))).results,keepArrangement:async(t,n)=>(await e(`fileio-arrangement`,e=>({type:`save_arrangement`,documentPath:t,content:n,requestId:e}))).path,onChanged:(e,t)=>{let n=g.current.get(e)??new Set;return n.add(t),g.current.set(e,n),()=>{n.delete(t),n.size===0&&g.current.delete(e)}}}},[k]),setOutcomeActive:ue,refreshOutcome:oe,authToken:l.current,switchWorkspace:(e,t)=>{((t??e)!==E||i.switching)&&(a({type:`workspace_switching`}),k({type:`switch_workspace`,root:e,...t!==void 0&&t!==e?{id:t}:{}}))},openProject:e=>{a({type:`workspace_switching`}),k({type:`open_project`,root:e})},closeProject:(e,t)=>k({type:`close_project`,root:e,...t!==void 0&&t!==e?{id:t}:{}}),checkPiPackages:()=>k({type:`check_pi_packages`}),updatePiPackage:e=>{let t=`pkg:${j1()}`;a({type:`pi_package_update_started`,requestId:t,source:e}),k({type:`update_pi_package`,source:e,requestId:t})},lookupPiPackage:(e,t,n)=>{let r=`pkg:${j1()}`;a({type:`pi_package_lookup_started`,requestId:r,name:e,scope:n,...t===void 0?{}:{version:t}}),k({type:`lookup_pi_package`,name:e,scope:n,requestId:r,...t===void 0?{}:{version:t}})},closePiPackageLookup:()=>a({type:`pi_package_lookup_closed`}),installPiPackage:(e,t,n,r)=>{let i=`pkg:${j1()}`;a({type:`pi_package_change_started`,requestId:i,key:`${n}:${e}`,action:`install`}),k({type:`install_pi_package`,name:e,scope:n,confirmed:r,requestId:i,...t===void 0?{}:{version:t}})},removePiPackage:e=>{let t=`pkg:${j1()}`;a({type:`pi_package_change_started`,requestId:t,key:`${e.scope}:${e.name}`,action:`remove`}),k({type:`remove_pi_package`,source:e.source,scope:e.scope,requestId:t})},restorePiPackage:e=>{let t=`pkg:${j1()}`;a({type:`pi_package_change_started`,requestId:t,key:`${e.scope}:${e.name}`,action:`restore`}),k({type:`restore_pi_package`,name:e.name,scope:e.scope,requestId:t})},restartServer:()=>k({type:`restart_server`}),restartSession:()=>{a({type:`settings_apply_started`}),k({type:`restart_session`})},openSideSession:e=>{a({type:`workspace_switching`}),k({type:`open_side_session`,root:e})},submitToken:e=>{F1(e),l.current=e,a({type:`auth_retrying`}),c(e=>e+1)},prompt:(e,t)=>{a({type:`prompt_sent`,text:e,...t?.length?{images:t}:{}}),k({type:`prompt`,text:e,...t?.length?{images:t}:{}})},abort:()=>k({type:`abort`}),cancelPendingPrompt:e=>{a({type:`pending_prompt_cancelled`,restoreText:e}),k({type:`abort`})},setModel:(e,t)=>k({type:`set_model`,provider:e,id:t}),setThinking:e=>k({type:`set_thinking`,level:e}),newSession:()=>k({type:`new_session`}),switchSession:e=>k({type:`switch_session`,path:e}),deleteSession:e=>k({type:`delete_session`,path:e}),listSessions:()=>k({type:`list_sessions`}),renameSession:(e,t)=>k({type:`rename_session`,path:e,name:t}),searchSessions:e=>{let t=`sessions:${j1()}`;a({type:`session_search_started`,query:e,requestId:t}),k({type:`search_sessions`,query:e,requestId:t})},clearSessionSearch:()=>a({type:`session_search_cleared`}),listTree:()=>k({type:`list_tree`}),navigateTree:e=>k({type:`navigate_tree`,entryId:e}),forkSession:e=>k({type:`fork_session`,entryId:e}),prefillComposer:(e,t)=>a({type:`composer_prefilled`,text:e,...t?{notice:t}:{}}),editQueuedPrompt:(e,t)=>k({type:`edit_queued_prompt`,id:e,text:t}),removeQueuedPrompt:e=>k({type:`remove_queued_prompt`,id:e}),sendQueueNow:()=>k({type:`send_queue_now`}),editPrompt:(e,t,n)=>k({type:`edit_prompt`,entryId:e,text:t,...n?.length?{images:n}:{}}),compact:()=>k({type:`compact`}),fetchOlderItems:Ce,loadOlderItems:we,respondToDialog:e=>{k({type:`extension_ui_response`,...e}),a({type:`dialog_answered`})},respondToGrant:(e,t)=>k({type:`sandbox_grant_response`,id:e,decision:t}),dismissNotification:e=>a({type:`dismiss_notification`,id:e}),listDirectory:e=>de(e),refreshFileTree:ye,readFile:(e,t,n)=>{let r=`file:${j1()}`;a({type:`file_read_started`,path:e,requestId:r,...n?{reveal:n}:{}}),k({type:`read_file`,path:e,requestId:r,...t===void 0?{}:{sha256:t}})},closeFilePreview:()=>a({type:`close_file_preview`}),writeFile:(e,t,n,r=!1)=>{let i=`write:${j1()}`;a({type:`file_save_started`,path:e,requestId:i,content:t}),k({type:`write_file`,path:e,content:t,expectedMtimeMs:n,...r?{force:r}:{},requestId:i})},createFile:e=>{a({type:`file_create_started`}),k({type:`create_file`,path:e,requestId:`create:${j1()}`})},uploadFile:(e,t,n)=>{if(n!==void 0&&(i.switching||ee!==O.current))return Promise.reject(new BV);let r=S.current;if(r===null)return Promise.reject(new zV(`the workspace is read-only`,`denied`));let a=o.current;if(!a||a.readyState!==WebSocket.OPEN)return Promise.reject(new zV(`not connected to the server`));let s=n??(r?`${r}/uploads`:`uploads`),c=`upload:${j1()}`;return new Promise((r,i)=>{let a=window.setTimeout(()=>{m.current.delete(c)&&i(new zV(`the upload timed out`))},Y1),o=e=>t=>{clearTimeout(a),e(t)};m.current.set(c,{resolve:o(e=>{if(n!==void 0){if(ee!==O.current){i(new BV);return}de(n,!0)}r(e)}),reject:o(i)}),k({type:`upload_file`,destinationDirectory:s,name:e,contentBase64:t,requestId:c,...n===void 0?{}:{existingDirectory:!0,workspaceId:E??void 0}})})},createDirectory:e=>{a({type:`file_create_started`}),k({type:`create_directory`,path:e,requestId:`create:${j1()}`})},openNative:e=>{let t=`fileop:${j1()}`;a({type:`file_operation_started`,operation:`open_native`,path:e,requestId:t}),k({type:`open_native`,path:e,requestId:t})},revealNative:e=>{let t=Date.now();if(u.current?.path===e&&t-u.current.at<e0)return;u.current={path:e,at:t};let n=`fileop:${j1()}`;a({type:`file_operation_started`,operation:`reveal_native`,path:e,requestId:n}),k({type:`reveal_native`,path:e,requestId:n})},renameFile:(e,t)=>{let n=`fileop:${j1()}`;a({type:`file_operation_started`,operation:`rename_file`,path:e,requestId:n}),k({type:`rename_file`,path:e,name:t,requestId:n})},deleteFile:e=>{let t=`fileop:${j1()}`;a({type:`file_operation_started`,operation:`delete_file`,path:e,requestId:t}),k({type:`delete_file`,path:e,requestId:t})},moveFile:(e,t)=>{let n=`fileop:${j1()}`;a({type:`file_operation_started`,operation:`move_file`,path:e,requestId:n}),k({type:`move_file`,path:e,destinationDirectory:t,requestId:n})},copyFile:(e,t)=>{let n=`fileop:${j1()}`;a({type:`file_operation_started`,operation:`copy_file`,path:e,requestId:n}),k({type:`copy_file`,path:e,destinationDirectory:t,requestId:n})},searchFiles:e=>{let t=`search:${j1()}`;a({type:`file_search_started`,query:e,requestId:t}),k({type:`search_files`,query:e,requestId:t})},clearFileSearch:()=>a({type:`file_search_cleared`}),searchContent:e=>{if(e.trim()===``){a({type:`content_search_cleared`});return}let t=`content:${j1()}`;a({type:`content_search_started`,query:e,requestId:t}),k({type:`search_content`,query:e,requestId:t})},clearContentSearch:()=>a({type:`content_search_cleared`}),fetchGitStatus:()=>P(),fetchGitDiff:e=>{let t=`gitdiff:${j1()}`;a({type:`git_diff_started`,path:e,requestId:t}),k({type:`git_diff`,path:e,requestId:t})},clearGitDiff:()=>a({type:`git_diff_cleared`}),fetchGitLog:(e,t)=>{M.current={repo:e,limit:t},pe(e,t)},closeGitLog:()=>{M.current=null,a({type:`git_log_closed`})},fetchGitShow:(e,t)=>k({type:`git_show`,repo:e,sha:t,requestId:`gitshow:${j1()}`}),clearGitShow:()=>a({type:`git_show_cleared`}),fetchGitFileHistory:(e,t)=>{let n=`gitfilelog:${j1()}`;a({type:`git_file_history_started`,path:e,requestId:n}),k({type:`git_file_log`,path:e,...t?{limit:t}:{},requestId:n})},closeGitFileHistory:()=>a({type:`git_file_history_closed`}),fetchGitFileDiff:(e,t)=>{let n=`gitfilediff:${j1()}`;a({type:`git_file_diff_started`,base:e,target:t,requestId:n}),k({type:`git_file_diff`,base:e,target:t,requestId:n})},clearGitFileDiff:()=>a({type:`git_file_diff_cleared`}),setCredential:(e,t)=>k({type:`set_credential`,provider:e,apiKey:t}),startLogin:(e,t)=>{let n=j1();a({type:`login_started`,flowId:n,provider:e,method:t}),k({type:`start_login`,flowId:n,provider:e,method:t})},answerLogin:e=>{let t=i.login;t?.prompt&&(k({type:`login_answer`,flowId:t.flowId,promptId:t.prompt.promptId,value:e}),a({type:`login_answered`}))},cancelLogin:()=>{let e=i.login;e&&!e.done&&k({type:`cancel_login`,flowId:e.flowId})},dismissLogin:()=>a({type:`login_dismissed`}),logoutProvider:e=>k({type:`logout_provider`,provider:e}),declareProvider:e=>k({type:`declare_provider`,...e}),browseServerDirectory:e=>{let t=`serverdir:${j1()}`;a({type:`server_browse_started`,path:e,requestId:t}),k({type:`browse_server_directory`,path:e,requestId:t})},closeServerBrowser:()=>a({type:`server_browse_closed`}),suggestAgentResourceClonePath:e=>{let t=`resource-clone-path:${j1()}`;a({type:`resource_clone_path_started`,requestId:t}),k({type:`suggest_agent_resource_clone_path`,repositoryUrl:e,requestId:t})},cloneAgentResourceRepository:(e,t)=>{let n=`resource-preview:${j1()}`;a({type:`resource_preview_started`,requestId:n}),k({type:`clone_agent_resource_repository`,repositoryUrl:e,destinationPath:t,requestId:n})},enrollAgentResourceRepository:(e,t,n,r)=>{let i=`resource-enroll:${j1()}`;a({type:`resource_enrollment_started`,requestId:i}),k({type:`enroll_agent_resource_repository`,previewToken:e,skillRoots:t,extensionRoots:n,...r?{enabledSkills:r}:{},requestId:i})},setAgentResourceSkills:(e,t)=>{let n=`resource-skills:${j1()}`;a({type:`resource_skills_started`,requestId:n,repositoryId:e}),k({type:`set_agent_resource_skills`,repositoryId:e,enabledSkills:t,requestId:n})},removeAgentResourceRepository:e=>{let t=`resource-remove:${j1()}`;a({type:`resource_removal_started`,requestId:t,repositoryId:e}),k({type:`remove_agent_resource_repository`,repositoryId:e,requestId:t})},refreshAgentResourceRepositories:e=>{let t=`resource-refresh:${j1()}`;a({type:`resource_refresh_started`,requestId:t,...e?{repositoryId:e}:{}}),k({type:`refresh_agent_resource_repositories`,...e?{repositoryId:e}:{},requestId:t})},updateAgentResourceRepository:(e,t,n,r,i=!1)=>{let o=`resource-update:${j1()}`;a({type:`resource_update_started`,requestId:o,repositoryId:e}),k({type:`update_agent_resource_repository`,repositoryId:e,assessmentToken:t,localRevision:n,upstreamRevision:r,...i?{allowExecutableChanges:!0}:{},requestId:o})},updateConfig:e=>{a({type:`settings_apply_started`}),k({type:`update_config`,...e})},openTerminal:(e,t,n,r,i)=>{let a={type:`terminal_open`,terminalId:e,cwd:t,cols:n,rows:r,...i?{shellId:i}:{}};T.current.set(e,{message:a,socket:o.current?.readyState===WebSocket.OPEN?o.current:null}),k(a)},sendTerminalInput:(e,t)=>k({type:`terminal_input`,terminalId:e,data:t}),getTerminalCwd:e=>k({type:`terminal_get_cwd`,terminalId:e}),resizeTerminal:(e,t,n)=>{let r=T.current.get(e);r&&Object.assign(r.message,{cols:t,rows:n}),k({type:`terminal_resize`,terminalId:e,cols:t,rows:n})},closeTerminal:e=>{T.current.delete(e),k({type:`terminal_close`,terminalId:e}),w.current.delete(e)},subscribeTerminal:(e,t)=>{let n=w.current.get(e);return n||(n={onData:new Set,onCwd:new Set,onExit:new Set,onError:new Set},w.current.set(e,n)),t.onData&&n.onData.add(t.onData),t.onCwd&&n.onCwd.add(t.onCwd),t.onExit&&n.onExit.add(t.onExit),t.onError&&n.onError.add(t.onError),()=>{t.onData&&n?.onData.delete(t.onData),t.onCwd&&n?.onCwd.delete(t.onCwd),t.onExit&&n?.onExit.delete(t.onExit),t.onError&&n?.onError.delete(t.onError)}}}}var n0=120;function r0({label:e}){return(0,N.jsx)(`div`,{className:`flex justify-end px-4`,role:`status`,"aria-live":`polite`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,N.jsx)(`span`,{className:`inline-block h-4 w-4 animate-spin rounded-full border-[3px] border-zinc-300 border-t-blue-500 dark:border-zinc-600 dark:border-t-blue-400 motion-reduce:animate-pulse`}),(0,N.jsx)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:e})]})})}var i0=(0,v.forwardRef)(function({serverUrl:e=``,rootElement:t,initialTheme:n,token:r,workspace:i},a){let o=t!==void 0,s=t??document.documentElement,{state:c,authToken:l,submitToken:u,prompt:d,abort:f,cancelPendingPrompt:p,setModel:m,setThinking:h,newSession:g,switchSession:_,deleteSession:y,listSessions:x,renameSession:S,searchSessions:C,clearSessionSearch:w,listTree:T,navigateTree:D,forkSession:O,editPrompt:ee,editQueuedPrompt:te,removeQueuedPrompt:k,sendQueueNow:ne,prefillComposer:A,compact:re,loadOlderItems:j,fetchOlderItems:ie,respondToDialog:ae,respondToGrant:oe,dismissNotification:se,listDirectory:ce,refreshFileTree:le,readFile:ue,searchContent:de,writeFile:M,createFile:pe,createDirectory:me,uploadFile:he,openNative:ge,revealNative:P,renameFile:_e,deleteFile:ve,moveFile:be,copyFile:xe,closeFilePreview:Se,searchFiles:Ce,clearFileSearch:we,fetchGitDiff:Te,clearGitDiff:Ee,fetchGitLog:De,closeGitLog:Oe,fetchGitShow:ke,clearGitShow:Ae,fetchGitFileHistory:je,closeGitFileHistory:Me,fetchGitFileDiff:Ne,clearGitFileDiff:Pe,setCredential:Fe,startLogin:Ie,answerLogin:Le,cancelLogin:Re,dismissLogin:ze,logoutProvider:Be,declareProvider:Ve,updateConfig:He,suggestAgentResourceClonePath:Ue,cloneAgentResourceRepository:We,enrollAgentResourceRepository:Ge,setAgentResourceSkills:Ke,removeAgentResourceRepository:qe,refreshAgentResourceRepositories:Je,updateAgentResourceRepository:Ye,browseServerDirectory:Xe,closeServerBrowser:Ze,switchWorkspace:Qe,openProject:et,closeProject:tt,openSideSession:nt,checkPiPackages:rt,updatePiPackage:it,lookupPiPackage:at,closePiPackageLookup:ot,installPiPackage:st,removePiPackage:ct,restorePiPackage:lt,restartServer:ut,restartSession:dt,openTerminal:ft,sendTerminalInput:pt,getTerminalCwd:mt,resizeTerminal:ht,closeTerminal:gt,subscribeTerminal:_t,setOutcomeActive:vt,refreshOutcome:yt,fileIo:bt}=t0(e,r,o,i),xt=fe(c.workspace);DG(c.workspaces,c.workspace?GB(c.workspace):null);let St=c.workspace?GB(c.workspace):null;(0,v.useEffect)(()=>{Ot([]),Cn([]),Bn.current&&(Bn.current.scrollTop=0)},[St]);let[Ct,wt]=(0,v.useState)(!1),[Tt,Et]=(0,v.useState)(!1),[Dt,Ot]=(0,v.useState)([]),[kt,At]=(0,v.useState)([]),[jt,Mt]=(0,v.useState)(!1),[Nt,Pt]=(0,v.useState)(null),[Ft,It]=(0,v.useState)(null),Lt=Nt===`project`,Rt=e=>Pt(e?`project`:null),zt=c.embedWorkspaceControls===`projects`?`projects`:c.embedWorkspaceControls===`root`?`root`:`none`,Bt=(0,v.useRef)({}),Vt=(e,t)=>{let n=Bt.current[St??``]?.trim(),r=n?`${n}\n\n${e}`:e;t?A(r,t):A(r)},Ht=c.queuedEditRefused;(0,v.useEffect)(()=>{Ht&&Vt(Ht.text)},[Ht?.nonce]);let Ut=(0,v.useRef)({key:null,drafts:new Map});(0,v.useEffect)(()=>{let e=Ut.current;if(e.key!==St){Ut.current={key:St,drafts:new Map};return}let t=new Set(c.queue.map(e=>e.id));for(let[n,{original:r,draft:i}]of e.drafts)t.has(n)||(e.drafts.delete(n),i.trim()&&i.trim()!==r&&Vt(i.trim(),`The agent read that message before your edit was saved — your edit is in the composer`))},[c.queue,St]);let Wt=(e,t)=>n=>{Ut.current.key!==St&&(Ut.current={key:St,drafts:new Map}),n===null?Ut.current.drafts.delete(e):Ut.current.drafts.set(e,{original:t,draft:n})},Gt=(0,v.useRef)([]),[Kt,qt]=(0,v.useState)(!1),Jt=(0,v.useRef)({readFile:ue,openNative:ge});Jt.current={readFile:ue,openNative:ge};let Yt=(0,v.useMemo)(()=>({serverUrl:e,fileIo:bt,onOpenFile:e=>{qt(!1),Jt.current.readFile(e)},onOpenNative:e=>Jt.current.openNative(e)}),[e,bt]),[Xt,Zt]=(0,v.useState)(AV),Qt=(0,v.useCallback)((e,t)=>{jV(e,t),Zt(n=>({...n,[e]:t}))},[]),[$t,en]=(0,v.useState)(!1),[tn,nn]=(0,v.useState)(!0),[rn,an]=(0,v.useState)(()=>typeof window<`u`&&window.innerWidth<768),[on,sn]=(0,v.useState)(!1),cn=rn?on:tn,[ln,un]=(0,v.useState)(!1),dn=c.terminal?.enabled??!1;(0,v.useEffect)(()=>{let e=window.matchMedia(`(max-width: 767px)`),t=()=>{let t=e.matches;t&&sn(!1),an(t)};return t(),e.addEventListener(`change`,t),window.addEventListener(`resize`,t),()=>{e.removeEventListener(`change`,t),window.removeEventListener(`resize`,t)}},[]),(0,v.useEffect)(()=>{let e=e=>{dn&&(e.ctrlKey||e.metaKey)&&e.key==="`"&&(e.preventDefault(),un(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[dn]);let[fn,pn]=(0,v.useState)(!1),[mn,hn]=(0,v.useState)(null),gn=(0,v.useCallback)(()=>hn(null),[]);function _n(){let e=!$t;en(e),e&&(nn(!1),sn(!1),pn(!1))}function vn(){if(rn){let e=!on;sn(e),e&&(en(!1),pn(!1));return}let e=!tn;nn(e),e&&(en(!1),pn(!1))}function yn(){let e=!fn;pn(e),e&&(en(!1),nn(!1),sn(!1))}(0,v.useEffect)(()=>(vt(fn),()=>vt(!1)),[fn,vt,c.sessionId,St]),(0,v.useEffect)(()=>{pn(!1),hn(null)},[St]);let[bn,xn]=(0,v.useState)([]),[Sn,Cn]=(0,v.useState)([]),wn=(0,v.useRef)(0),Tn=(0,v.useRef)(0),[En,Dn]=(0,v.useState)(0);async function On(e){let t=[...e],n=t.filter(WV).map(e=>({id:`${wn.current++}`,name:e.name}));n.length>0&&Cn(e=>[...e,...n]),Tn.current===0&&xn([]),Tn.current++;try{let{attachments:e,errors:n}=await QV(t,he);e.length>0&&Ot(t=>[...t,...e]),n.length>0&&xn(e=>[...e,...n])}finally{if(Tn.current--,n.length>0){let e=new Set(n.map(e=>e.id));Cn(t=>t.filter(t=>!e.has(t.id)))}}}(0,v.useEffect)(()=>{Gt.current=Dt},[Dt]);function kn(){Se()}let An=(0,v.useMemo)(()=>[...Dt.filter(e=>e.kind===`path`).map(e=>e.data),...kt],[Dt,kt]);function jn(e){let t=Gt.current.findIndex(t=>t.kind===`path`&&t.data===e);t>=0?Mn(t):kt.includes(e)||Ot(t=>rH(t,e))}function Mn(e){Ot(t=>iH(t,e))}let Nn=(0,v.useMemo)(()=>({btw:{region:`Side answer`,pinnedLines:1,anchor:e=>e.findLastIndex(e=>e.startsWith(`› `)),close:{label:`Close side answer`,run:()=>d(`/btw`)}}}),[d]);function Pn(e,t){d(e,t),Ot([]),xn([]),jt||kn()}function Fn(e){e.preventDefault(),Dn(0),e.dataTransfer.files.length>0&&On(Array.from(e.dataTransfer.files))}let{theme:In,preference:Ln,toggle:Rn,setTheme:zn}=E(c.branding.defaultTheme??`system`,c.branding.allowThemeToggle!==!1,s,n);(0,v.useImperativeHandle)(a,()=>({setTheme:zn}),[zn]);let Bn=(0,v.useRef)(null),[Vn,Hn]=(0,v.useState)(null),Un=(0,v.useCallback)(e=>{Bn.current=e,Hn(e)},[]),Wn=(0,v.useRef)(null),Gn=(0,v.useRef)(!0),[Kn,qn]=(0,v.useState)(!0),Jn=(0,v.useCallback)(e=>{e!==Gn.current&&qn(e),Gn.current=e},[]),Yn=(0,v.useCallback)(()=>{let e=Bn.current;e&&Jn(e.scrollHeight-e.scrollTop-e.clientHeight<n0)},[Jn]),Xn=(0,v.useRef)(null),Zn=(0,v.useCallback)(()=>{let e=Bn.current;e&&(e.scrollHeight-e.scrollTop-e.clientHeight<n0||(Xn.current=e.scrollTop))},[]),Qn=(0,v.useCallback)(()=>{let e=Bn.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<n0,n=Xn.current;if(n!==null){if(e.scrollTop<n)Xn.current=null;else if(Xn.current=t?null:e.scrollTop,!t)return}Jn(t)},[Jn]);function $n(){Xn.current=null}(0,v.useEffect)(()=>{let e=Vn;if(!e)return;let t=()=>{Xn.current=null,Qn()};e.addEventListener(`scrollend`,t);let n;return typeof ResizeObserver<`u`&&(n=new ResizeObserver(()=>{Gn.current?(Zn(),Wn.current?.scrollIntoView({behavior:`auto`})):Qn()}),n.observe(e),e.firstElementChild&&n.observe(e.firstElementChild)),()=>{e.removeEventListener(`scrollend`,t),n?.disconnect()}},[Vn,Qn,Zn]);let er=(0,v.useCallback)(()=>{Jn(!0),Zn();let e=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1;Wn.current?.scrollIntoView({behavior:e?`auto`:`smooth`})},[Jn,Zn]);(0,v.useEffect)(()=>{Gn.current?(Zn(),Wn.current?.scrollIntoView({behavior:`smooth`})):Yn()},[c.items,Yn,Zn]);let tr=(0,v.useMemo)(()=>XB(c.items),[c.items]),nr=(0,v.useMemo)(()=>$t?oV(c.items):null,[$t,c.items]),rr=(0,v.useMemo)(()=>tB({readFile:(e,t)=>{qt(!1),ue(e,t)},fetchGitFileHistory:e=>je(e),fetchGitDiff:e=>{qt(!0),ue(e)},searchFiles:e=>Ce(e)}),[ue,je,Ce]),ir=(0,v.useCallback)(()=>Qt(`tools`,!0),[Qt]),ar=(0,v.useCallback)(e=>{let t=Bn.current;if(t){let n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),i=r.top>=n.top&&r.bottom<=n.bottom,a=t.scrollHeight-t.scrollTop-t.clientHeight<n0;if(i&&a)return}Jn(!1)},[Jn]),[or,sr]=(0,v.useState)(null),[cr,lr]=(0,v.useState)(null),ur=(0,v.useMemo)(()=>{let e=c.sessions?.find(e=>e.id===c.sessionId);return c.sessionName?.trim()||e?.name?.trim()||e?.firstMessage?.trim()||c.sessionId},[c.sessionName,c.sessions,c.sessionId]),dr=(0,v.useCallback)(async()=>{lr(null),sr(`preparing…`);try{let{exportConversation:t}=await ye(async()=>{let{exportConversation:e}=await import(`./conversationExport-Bm7AfdXa.js`);return{exportConversation:e}},__vite__mapDeps([26,21,1,25]));await t({items:c.items,olderItems:c.olderHistory?.remaining??0,...c.olderHistory?{fetchOlderItems:ie}:{},connection:{serverUrl:e,token:l,workspace:xt},meta:{...c.workspace?{project:c.workspace.name}:{},session:ur,model:c.model,exportedAt:new Date},onProgress:(e,t,n)=>sr(e===`collecting`?`reading ${t}/${n}…`:`writing ${t}/${n}…`)})}catch(e){lr(e instanceof Error?e.message:`the conversation could not be exported`)}finally{sr(null)}},[c.items,c.olderHistory,c.workspace,c.model,ur,ie,e,l,xt]),{jumpToItem:fr,highlightIndex:pr}=TV({items:c.items,scrollerRef:Bn,hideTools:!Xt.tools,onShowTools:ir,onJump:ar}),mr=(0,v.useRef)(null),hr=(0,v.useRef)(c.olderHistory?.have??0),gr=(0,v.useCallback)(()=>{let e=Bn.current;e&&(mr.current={height:e.scrollHeight,top:e.scrollTop}),j()},[j]);if((0,v.useLayoutEffect)(()=>{let e=c.olderHistory?.have??0,t=hr.current;hr.current=e;let n=mr.current;if(mr.current=null,!n||e<=t)return;let r=Bn.current;r&&(r.scrollTop=n.top+(r.scrollHeight-n.height))},[c.olderHistory?.have]),(0,v.useEffect)(()=>{if(!o){let e=c.extensionTitle??c.branding.title??`pi`;document.title=c.workspace?`${c.workspace.name} — ${e}`:e}c.branding.accentColor&&s.style.setProperty(`--accent`,c.branding.accentColor)},[c.branding,c.extensionTitle,c.workspace?.name,o,s]),o&&!c.brandingReady)return null;if(c.authRequired)return(0,N.jsx)(b.Provider,{value:In,children:(0,N.jsx)(cK,{title:c.branding.title,onSubmit:u})});if(c.credentials&&!c.credentials.usableModel)return(0,N.jsx)(b.Provider,{value:In,children:(0,N.jsx)(VG,{title:c.branding.title,credentials:c.credentials,onSetCredential:Fe,onStartLogin:Ie,login:c.login,onAnswerLogin:Le,onCancelLogin:Re,onDismissLogin:ze,onDeclareProvider:Ve,errors:c.errors})});let _r=c.dialogQueue[0],vr=_r?void 0:c.sandboxGrants?.pending[0];return(0,N.jsx)(b.Provider,{value:In,children:(0,N.jsx)(kg.Provider,{value:c.replyConformance,children:(0,N.jsx)(ng.Provider,{value:c.structuredAppearance,children:(0,N.jsxs)(Pm.Provider,{value:Yt,children:[(0,N.jsxs)(`div`,{className:`relative flex h-full`,onDragEnter:e=>{e.dataTransfer.types.includes(`Files`)&&Dn(e=>e+1)},onDragLeave:()=>Dn(e=>Math.max(0,e-1)),onDragOver:e=>e.preventDefault(),onDrop:Fn,children:[En>0&&(0,N.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-40 flex items-center justify-center border-2 border-dashed bg-white/70 backdrop-blur-sm dark:bg-zinc-950/70`,style:{borderColor:`var(--accent, #3b82f6)`},children:(0,N.jsx)(`p`,{className:`text-lg font-medium text-zinc-700 dark:text-zinc-200`,children:`Drop files to attach (images, documents & text)`})}),(Ct||Tt)&&(0,N.jsx)(sK,{hidden:!Ct,onUploadFile:he,onExternalDragEnter:()=>Dn(0),tree:c.fileTree,openFile:c.openFile,writableRoot:c.writableRoot,gitFiles:c.gitStatus?.files,attachedPaths:An,onExpand:ce,onSelectDirectory:It,onRefresh:le,onSelectFile:e=>{qt(!1),It(e),ue(e)},onSelectDiff:e=>{qt(!0),It(e),ue(e)},onToggleAttachPath:jn,onCreateFile:e=>{qt(!1),pe(e)},onCreateDirectory:me,onOpenNative:ge,onRevealNative:P,onRenameFile:_e,onDeleteFile:ve,onMoveFile:be,onCopyFile:xe,fileOperation:c.fileOperation,createError:c.createError,created:c.created,contentSearch:c.contentSearch,onSearchContent:de,onOpenSearchHit:(e,t)=>{qt(!1),It(e.path),ue(e.path,void 0,e.kind===`line`?{query:t,line:e.line}:{query:t,page:e.page})}},JSON.stringify([St,c.sandbox?.projectRoot??c.sandbox?.root])),(0,N.jsxs)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,children:[Lt&&(0,N.jsx)(vW,{label:`Choose a project directory`,browse:c.serverBrowse,onBrowse:Xe,onSelect:e=>{Rt(!1),Ze(),et(e)},onCancel:()=>{Rt(!1),Ze()}}),!o&&c.outpostUpdate&&(0,N.jsx)(BB,{notice:c.outpostUpdate}),!o&&c.outpostChanges&&(0,N.jsx)(WB,{changes:c.outpostChanges}),(0,N.jsx)(EG,{workspace:c.workspace,workspaces:c.workspaces,workspaceLocked:c.workspaceLocked,workspaceControl:o?zt:`projects`,rootControl:{sandbox:c.sandbox,browse:c.serverBrowse,applyState:c.settingsApply,blocked:Nt!==null&&Nt!==`root`,onBrowse:Xe,onCloseBrowser:()=>{Pt(null),Ze()},onOpened:()=>Pt(`root`),onSelect:e=>He({sandbox:{root:e,allowWrite:c.sandbox?.allowWrite??!1,allowBash:c.sandbox?.allowBash??!1,...c.sandbox?.writableRoot?{writableRoot:c.sandbox.writableRoot}:{}}})},onSwitchWorkspace:Qe,onOpenProject:()=>{Rt(!0),Xe(``)},onCloseProject:tt,onOpenSideSession:nt,piPackages:c.piPackages,piPackageUpdate:c.piPackageUpdate,piPackageEdits:{lookup:c.piPackageLookup,change:c.piPackageChange,projectName:c.workspace?.name??`this`,onLookup:at,onCloseLookup:ot,onInstall:st,onRemove:ct,onRestore:lt},canRestartServer:!o,serverRestarting:c.serverRestarting,onCheckPiPackages:rt,onUpdatePiPackage:it,onRestartServer:ut,restartNeeded:c.restartNeeded,title:c.branding.title,credentials:c.credentials,login:c.login,onStartLogin:Ie,onAnswerLogin:Le,onCancelLogin:Re,onDismissLogin:ze,onLogoutProvider:Be,sessions:c.sessions,sessionSearch:c.sessionSearch,sessionId:c.sessionId,tree:c.tree,isStreaming:c.isStreaming,connected:c.connected,theme:In,showThemeToggle:c.branding.allowThemeToggle!==!1,statuses:c.statuses,sidebarOpen:Ct,outcomeOpen:fn,filters:Xt,onToggleSidebar:()=>{Et(!0),wt(e=>!e)},onToggleOutcome:yn,onFilterChange:Qt,...c.items.length>0?{onExportConversation:()=>void dr()}:{},exportProgress:or,onToggleTheme:Rn,themePreference:Ln,onSetTheme:zn,onNewSession:g,onSwitchSession:_,onDeleteSession:y,onListSessions:x,onRenameSession:S,onSearchSessions:C,onClearSessionSearch:w,onListTree:T,onNavigateTree:D,onForkSession:O,gitAvailable:c.gitAvailable,gitStatus:c.gitStatus,gitSelectedPath:Ft,gitLog:c.gitLog,extensionPaths:c.extensionPaths,configuredExtensionPaths:c.configuredExtensionPaths,userExtensionPaths:c.userExtensionPaths,extensionLock:c.extensionLock,tools:c.tools,commands:c.commands,sandbox:c.sandbox,gitUnavailable:c.gitUnavailable,userSkillPaths:c.userSkillPaths,serverBrowse:c.serverBrowse,settingsApply:c.settingsApply,agentResources:c.agentResources,agentResourceOperations:c.agentResourceOperations,versions:c.versions,onBrowseServerPath:Xe,onCloseServerBrowser:Ze,settingsPickerBlocked:Nt!==null&&Nt!==`settings`,onSettingsPickerOpened:()=>Pt(`settings`),onRestartSession:dt,onUpdateConfig:He,onSuggestAgentResourceClonePath:Ue,onCloneAgentResourceRepository:We,onEnrollAgentResourceRepository:Ge,onSetAgentResourceSkills:Ke,onRemoveAgentResourceRepository:qe,onRefreshAgentResourceRepositories:Je,onUpdateAgentResourceRepository:Ye,onFetchGitLog:De,onCloseGitLog:Oe,onShowCommit:ke,terminalOpen:ln,onToggleTerminal:dn?()=>un(e=>!e):void 0}),(0,N.jsxs)(`div`,{className:`relative z-0 flex min-h-0 flex-1 flex-col`,children:[c.workPlan&&(0,N.jsx)(fK,{plan:c.workPlan,open:cn,onToggle:vn,onOpenWorkspace:e=>{qt(!1),ue(e)},requestedTaskId:mn,onTaskRequestHandled:gn}),fn&&(0,N.jsx)(A1,{state:c.outcome,onClose:()=>pn(!1),onRefresh:yt,onTarget:e=>{e.kind===`work-plan-task`?(hn(e.taskId),pn(!1),en(!1),nn(!0)):e.kind===`workspace-file`?(qt(!1),ue(e.path)):e.kind===`workspace-diff`&&(qt(!0),ue(e.path))}}),c.openFile&&(0,N.jsx)(OU,{file:c.openFile,writableRoot:c.writableRoot,docxTemplate:c.docxTemplate,isStreaming:c.isStreaming,onDirtyChange:Mt,gitState:c.gitStatus?.files[c.openFile.path],initialShowGitDiff:Kt,gitDiff:c.gitDiff,gitBaseline:c.gitBaseline?.path===c.openFile.path?c.gitBaseline.text??null:null,onFetchGitDiff:Te,onClearGitDiff:Ee,inRepository:NV(c.gitStatus?.repos??[],c.openFile.path)!==null,onOpenGitHistory:je,onClose:kn,onReload:ue,onSave:M,serverUrl:e,token:l,workspace:xt,onOpenNative:ge,rawRevision:c.previewRevision},c.openFile.path),c.gitFileHistory&&(0,N.jsx)(iW,{history:c.gitFileHistory,diff:c.gitFileDiff,dirty:c.gitStatus?.files[c.gitFileHistory.path]!==void 0,onFetchDiff:Ne,onClearDiff:Pe,onClose:Me}),c.gitShow&&(0,N.jsx)(jU,{show:c.gitShow,onClose:Ae}),nr&&(0,N.jsx)(CV,{analysis:nr,onJump:fr,onClose:()=>en(!1)}),(0,N.jsx)(`main`,{ref:Un,onScroll:Qn,onWheel:$n,onTouchStart:$n,onKeyDown:$n,className:`relative flex-1 overflow-y-auto transition-opacity duration-150 ${c.switching?`opacity-40`:`opacity-100`} ${$t?`md:pr-[26rem]`:c.workPlan&&cn?`md:pr-[23rem]`:``}`,children:(0,N.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-3 px-4 py-6`,children:[c.items.length===0&&(0,N.jsxs)(`div`,{className:`mt-24 text-center text-zinc-500 dark:text-zinc-600`,children:[(0,N.jsx)(`div`,{className:`mb-2 text-4xl`,children:c.branding.title??`π`}),c.agentStarting?(0,N.jsx)(`p`,{className:`text-sm`,role:`status`,"data-testid":`agent-starting`,children:`Starting the agent… The project's files are ready.`}):(0,N.jsx)(`p`,{className:`text-sm`,children:c.branding.welcome??`Send a message to start the agent.`})]}),c.olderHistory&&(0,N.jsx)(JB,{older:c.olderHistory,onLoad:gr}),c.items.map((t,n)=>{let r=`${c.sessionId}:${n}`,i=(e,t=r)=>(0,N.jsx)(`div`,{"data-item-index":n,className:`flex flex-col gap-3 rounded-lg transition-shadow ${pr===n?`ring-2 ring-blue-400 dark:ring-blue-500`:``}`,children:e},t);return t.kind===`user`?i((0,N.jsx)($e,{item:t,canEdit:!t.readOnly&&!c.isStreaming&&c.connected,onEdit:ee})):t.kind===`compaction`?i((0,N.jsx)(qB,{item:t})):t.kind===`tool`?Xt.tools?i((0,N.jsx)(IB,{item:t,dispatch:rr}),t.toolCallId?`${c.sessionId}:${t.toolCallId}`:r):null:t.kind===`custom`?i((0,N.jsx)(LB,{item:t})):(Xt.reasoning?t.blocks:t.blocks.filter(e=>e.type!==`thinking`)).length===0&&!t.errorMessage?(0,N.jsx)(`div`,{"data-item-index":n,className:`sr-only`,"aria-hidden":!0},r):i((0,N.jsx)(Qz,{item:t,hideReasoning:!Xt.reasoning,serverUrl:e,token:l,workspace:xt,onOpenFile:e=>{qt(!1),ue(e)}}))}),c.pendingPrompt&&(0,N.jsxs)(`div`,{className:`flex flex-col gap-3 opacity-60`,"data-pending-prompt":!0,children:[(0,N.jsx)($e,{item:{kind:`user`,...c.pendingPrompt},canEdit:!1,onEdit:()=>{}}),c.extensionsBinding?(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,"data-testid":`prompt-waiting-for-extensions`,children:[(0,N.jsx)(r0,{label:`waiting for extensions to start…`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>p(!Bt.current[St??``]),className:`text-xs text-zinc-500 underline hover:text-zinc-700 dark:hover:text-zinc-300`,children:`cancel`})]}):(0,N.jsx)(r0,{label:`sending…`})]}),c.isStreaming&&!c.pendingPrompt&&(0,N.jsx)(r0,{label:`working…`}),c.queue.map(e=>(0,N.jsx)($e,{item:{kind:`user`,text:e.text,entryId:e.id,...e.images?{images:e.images}:{}},canEdit:e.editable&&c.connected,onEdit:(e,t)=>te(e,t),queued:{onRemove:()=>k(e.id),onDraftChange:Wt(e.id,e.text)}},e.id)),c.queue.length>0&&(0,N.jsx)(PV,{isStreaming:c.isStreaming,count:c.queue.length,canSend:c.queue.every(e=>e.editable)&&c.connected,onSend:ne}),bn.map((e,t)=>(0,N.jsx)(`div`,{className:`rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-700 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:e},`att${t}`)),cr&&(0,N.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:cr}),c.errors.map((e,t)=>(0,N.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:e},t)),(0,N.jsx)(`div`,{ref:Wn})]})}),(0,N.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-4 z-0 flex justify-center ${$t||fn?`md:pr-[26rem]`:c.workPlan&&cn?`md:pr-[23rem]`:``}`,children:!Kn&&(0,N.jsxs)(`button`,{type:`button`,onClick:er,"aria-label":`Scroll to the latest message`,className:`pointer-events-auto flex items-center gap-1.5 rounded-full border border-zinc-300 bg-white/95 px-3 py-1.5 text-xs text-zinc-600 shadow-lg backdrop-blur transition-colors hover:bg-zinc-50 motion-reduce:transition-none dark:border-zinc-700 dark:bg-zinc-900/95 dark:text-zinc-300 dark:hover:bg-zinc-800`,children:[(0,N.jsx)(`span`,{"aria-hidden":!0,children:`↓`}),`Latest`]})})]}),dn&&(0,N.jsx)(E1,{open:ln,onClose:()=>un(!1),cwd:c.workspace?.root,confinedRoot:c.terminal?.confined?c.sandbox?.root??c.workspace?.root:void 0,confinement:c.confinement?.terminal,unavailable:c.terminal?.unavailable,onSetWorkspaceRoot:e=>{et&&!o?et(e):c.sandbox?He({sandbox:{root:e,allowWrite:c.sandbox.allowWrite,allowBash:c.sandbox.allowBash,...c.sandbox.writableRoot?{writableRoot:c.sandbox.writableRoot}:{}}}):He({sandbox:{root:e,allowWrite:!0,allowBash:!0}})},shells:c.terminal?.shells,openTerminal:ft,sendTerminalInput:pt,getTerminalCwd:mt,resizeTerminal:ht,closeTerminal:gt,subscribeTerminal:_t}),(0,N.jsxs)(`footer`,{className:`shrink-0 border-t border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:[(_r||vr)&&(0,N.jsxs)(`div`,{className:`mx-auto max-w-3xl`,children:[_r&&(0,N.jsx)(CH,{request:_r,onRespond:ae},_r.id),vr&&(0,N.jsx)(DH,{request:vr,onRespond:oe},vr.id)]}),(0,N.jsxs)(`div`,{className:`mx-auto max-w-3xl`,hidden:!!(_r||vr),children:[(0,N.jsx)(zH,{widgets:c.widgets,placement:`aboveEditor`,controls:Nn}),(0,N.jsx)(fH,{initialDraft:Bt.current[St??``]??``,onDraftChange:e=>{Bt.current[St??``]=e},isStreaming:c.isStreaming,connected:c.connected,commands:c.commands,fileSearch:c.fileSearch,prefill:c.editorPrefill,attachments:Dt,pendingUploads:Sn,onAttach:e=>void On(e),onMentionPaths:At,onRemoveAttachment:Mn,onSend:Pn,onAbort:f,onSearchFiles:Ce,onClearFileSearch:we},St??``),(0,N.jsx)(zH,{widgets:c.widgets,placement:`belowEditor`}),(0,N.jsx)(RG,{model:c.model,models:c.models,thinkingLevel:c.thinkingLevel,thinkingLevels:c.thinkingLevels,modelSupportsReasoning:c.modelSupportsReasoning,isStreaming:c.isStreaming,contextUsage:c.contextUsage,shellConfinement:c.confinement?.bash,shellGrants:c.sandboxGrants?.active,sessionUsage:tr,analysisOpen:$t,onToggleAnalysis:_n,isCompacting:c.isCompacting,onSetModel:m,onSetThinking:h,onCompact:re})]})]})]})]}),(0,N.jsx)(jH,{notifications:c.notifications,onDismiss:se})]})})})})});(0,y.createRoot)(document.getElementById(`root`)).render((0,N.jsx)(v.StrictMode,{children:(0,N.jsx)(i0,{})}));export{oe as A,Pg as C,pe as D,ye as E,d as M,ae as O,Bg as S,Be as T,gx as _,Cz as a,S_ as b,lI as c,ij as d,WA as f,PS as g,cC as h,Kz as i,re as j,de as k,WF as l,Cw as m,pU as n,dz as o,VA as p,hU as r,uI as s,L1 as t,vj as u,w_ as v,oh as w,v_ as x,x_ as y};
|
|
1537
|
+
`);e.socket=s,s.send(JSON.stringify(e.message))}}if(t.type===`terminal_data`){let e=w.current.get(t.terminalId);if(e)for(let n of e.onData)n(t.data)}else if(t.type===`terminal_cwd`){let e=T.current.get(t.terminalId);e&&(e.message.cwd=t.cwd);let n=w.current.get(t.terminalId);if(n)for(let e of n.onCwd)e(t.cwd)}else if(t.type===`terminal_exit`){T.current.delete(t.terminalId);let e=w.current.get(t.terminalId);if(e)for(let n of e.onExit)n(t.exitCode)}else if(t.type===`terminal_error`){T.current.delete(t.terminalId);let e=w.current.get(t.terminalId);if(e)for(let n of e.onError)n(t.message)}else if(t.type===`history_items`){let e=_.current.get(t.requestId);e&&(_.current.delete(t.requestId),e.resolve({items:t.items,remaining:t.remaining}))}else if(t.type===`history_unavailable`){let e=_.current.get(t.requestId);e&&(_.current.delete(t.requestId),e.reject(new I1(t.reason,t.kind)))}else if((t.type===`file_content`||t.type===`file_written`||t.type===`arrangement_saved`||t.type===`file_browser_error`)&&h.current.has(t.requestId)){let e=h.current.get(t.requestId);h.current.delete(t.requestId),t.type===`file_browser_error`?e.reject(new wz(t.message,t.reason)):t.type===`file_content`?e.resolve({content:t.content,mtimeMs:t.mtimeMs}):t.type===`arrangement_saved`?e.resolve({path:t.path}):e.resolve({mtimeMs:t.mtimeMs})}else if(t.type===`file_search_results`&&h.current.has(t.requestId)){let e=h.current.get(t.requestId);h.current.delete(t.requestId),e.resolve({results:t.results})}else{if(t.type===`hello`||t.type===`workspace_switched`||t.type===`workspace_starting`||t.type===`session_replaced`||t.type===`update_config_ack`){let e={key:t.workspace?GB(t.workspace):null,root:t.sandbox?.projectRoot??t.sandbox?.root,writableRoot:t.writableRoot},n=D.current;(t.type===`hello`||n.key!==e.key||n.root!==e.root||n.writableRoot!==e.writableRoot)&&O.current++,D.current=e,S.current=t.writableRoot}if(t.type===`file_uploaded`){let e=m.current.get(t.requestId);e&&(m.current.delete(t.requestId),e.resolve(t.path))}else if(t.type===`file_browser_error`&&m.current.has(t.requestId)){let e=m.current.get(t.requestId);m.current.delete(t.requestId),e.reject(new zV(t.message,t.reason))}else if(t.type===`file_changed`){ce();for(let e of g.current.get(t.path)??[])e();ve(R1(t.path));let e=f.current;if(e?.status===`loaded`&&e.path===t.path){let e=`file:${j1()}`;a({type:`file_read_started`,path:t.path,requestId:e,preserveContent:!0}),k({type:`read_file`,path:t.path,requestId:e})}p.current===t.path&&k({type:`git_diff`,path:t.path,requestId:`gitdiff:${j1()}`}),P(NV(N.current,t.path)?.repo)}else if(t.type===`directory_changed`){ce();for(let[e,n]of g.current)if(R1(e)===t.path)for(let e of n)e();ve(t.path);let e=f.current;if(e!==null&&R1(e.path)===t.path){if(se(e.path)||le(e.path))a({type:`raw_preview_changed`,path:e.path});else if(e.status===`loaded`){let t=`file:${j1()}`;a({type:`file_read_started`,path:e.path,requestId:t,preserveContent:!0}),k({type:`read_file`,path:e.path,requestId:t})}}let n=p.current;n!==null&&R1(n)===t.path&&k({type:`git_diff`,path:n,requestId:`gitdiff:${j1()}`}),P()}else{if((t.type===`hello`||t.type===`session_replaced`||t.type===`workspace_switched`||t.type===`workspace_starting`)&&(fe.current=t.gitAvailable===!0,t.type!==`session_replaced`&&P()),t.type===`agent_end`&&(P(),ce()),t.type===`git_repositories_changed`&&(ce(),fe.current=t.available,t.available&&P()),t.type===`git_changed`){ce(),P(t.repo===``?void 0:t.repo);let e=M.current;e!==null&&e.repo===t.repo&&pe(e.repo,e.limit)}if((t.type===`git_status`||t.type===`git_error`&&t.requestId.startsWith(`git:`))&&_e(t.requestId),t.type===`work_plan_changed`&&ce(),(t.type===`workspace_outcome`||t.type===`workspace_outcome_error`)&&A.current===t.requestId&&(ae(),re.current&&(re.current=!1,queueMicrotask(()=>ie.current()))),t.type===`hello`||t.type===`session_replaced`||t.type===`workspace_switched`||t.type===`workspace_starting`||t.type===`update_config_ack`){ae(),re.current=!1;let e=te.current,n=t.sessionId===e.sessionId,r=(t.workspace?GB(t.workspace):null)===e.workspaceRoot;ne.current&&n&&r&&queueMicrotask(()=>ie.current())}if(t.type===`file_operation_result`){let e=t.previousPath??t.path,n=f.current;t.operation===`delete_file`&&n?.path===t.path?f.current=null:n?.path===e&&(f.current={...n,path:t.path})}a({type:`server`,message:t}),t.type===`session_replaced`&&de(``)}}},s.onclose=e=>{if(o.current===s){O.current++,me.current.clear(),he.current.clear(),ge.current.clear(),ae(),re.current=!1;for(let e of m.current.values())e.reject(new zV(`The connection dropped before the upload finished`));m.current.clear();for(let e of h.current.values())e.reject(new wz(`The connection dropped before the server answered`));h.current.clear();for(let e of _.current.values())e.reject(new I1(`the connection dropped before the older messages arrived`,`failed`));_.current.clear(),e.code===$1?a({type:`auth_required`}):(a({type:`disconnected`}),n||(t=window.setTimeout(i,1500)))}}}return i(),()=>{n=!0,t!==void 0&&clearTimeout(t);let e=o.current;o.current=null,e?.close()}},[k,e,P,_e,ve,de,ce,ae,s,r,pe]);let Ce=(0,v.useCallback)((e,t)=>{let n=o.current;if(!n||n.readyState!==WebSocket.OPEN)return Promise.reject(new I1(`not connected to the server`,`failed`));let r=`history:${j1()}`;return new Promise((n,i)=>{let a=window.setTimeout(()=>{_.current.delete(r)&&i(new I1(`the older messages did not arrive`,`failed`))},Z1),o=e=>t=>{clearTimeout(a),e(t)};_.current.set(r,{resolve:o(n),reject:o(i)}),k({type:`history_before`,sessionId:y.current,have:e,count:t,requestId:r})})},[k]),we=(0,v.useCallback)(async()=>{let e=x.current;if(!(!e||e.loading||b.current||e.remaining<=0)){b.current=!0,a({type:`history_load_started`});try{let t=await Ce(e.have,50);a({type:`history_loaded`,items:t.items,remaining:t.remaining})}catch(e){if(e instanceof I1&&e.kind===`stale`){a({type:`history_load_failed`,message:``});return}a({type:`history_load_failed`,message:e instanceof Error?e.message:`the older messages could not be loaded`})}finally{b.current=!1}}},[Ce]);return{state:i,fileIo:(0,v.useMemo)(()=>{function e(e,t){let n=o.current;if(!n||n.readyState!==WebSocket.OPEN)return Promise.reject(new wz(`not connected to the server`));let r=`${e}:${j1()}`;return new Promise((e,n)=>{let i=window.setTimeout(()=>{h.current.delete(r)&&n(new wz(`the server did not answer`))},X1);h.current.set(r,{resolve:t=>{clearTimeout(i),e(t)},reject:e=>{clearTimeout(i),n(e)}}),k(t(r))})}return{read:t=>e(`fileio-read`,e=>({type:`read_file`,path:t,requestId:e})),write:(t,n,r)=>e(`fileio-write`,e=>({type:`write_file`,path:t,content:n,expectedMtimeMs:r,requestId:e})),find:async t=>(await e(`fileio-find`,e=>({type:`search_files`,query:t,requestId:e}))).results,keepArrangement:async(t,n)=>(await e(`fileio-arrangement`,e=>({type:`save_arrangement`,documentPath:t,content:n,requestId:e}))).path,onChanged:(e,t)=>{let n=g.current.get(e)??new Set;return n.add(t),g.current.set(e,n),()=>{n.delete(t),n.size===0&&g.current.delete(e)}}}},[k]),setOutcomeActive:ue,refreshOutcome:oe,authToken:l.current,switchWorkspace:(e,t)=>{((t??e)!==E||i.switching)&&(a({type:`workspace_switching`}),k({type:`switch_workspace`,root:e,...t!==void 0&&t!==e?{id:t}:{}}))},openProject:e=>{a({type:`workspace_switching`}),k({type:`open_project`,root:e})},closeProject:(e,t)=>k({type:`close_project`,root:e,...t!==void 0&&t!==e?{id:t}:{}}),checkPiPackages:()=>k({type:`check_pi_packages`}),updatePiPackage:e=>{let t=`pkg:${j1()}`;a({type:`pi_package_update_started`,requestId:t,source:e}),k({type:`update_pi_package`,source:e,requestId:t})},lookupPiPackage:(e,t,n)=>{let r=`pkg:${j1()}`;a({type:`pi_package_lookup_started`,requestId:r,name:e,scope:n,...t===void 0?{}:{version:t}}),k({type:`lookup_pi_package`,name:e,scope:n,requestId:r,...t===void 0?{}:{version:t}})},closePiPackageLookup:()=>a({type:`pi_package_lookup_closed`}),installPiPackage:(e,t,n,r)=>{let i=`pkg:${j1()}`;a({type:`pi_package_change_started`,requestId:i,key:`${n}:${e}`,action:`install`}),k({type:`install_pi_package`,name:e,scope:n,confirmed:r,requestId:i,...t===void 0?{}:{version:t}})},removePiPackage:e=>{let t=`pkg:${j1()}`;a({type:`pi_package_change_started`,requestId:t,key:`${e.scope}:${e.name}`,action:`remove`}),k({type:`remove_pi_package`,source:e.source,scope:e.scope,requestId:t})},restorePiPackage:e=>{let t=`pkg:${j1()}`;a({type:`pi_package_change_started`,requestId:t,key:`${e.scope}:${e.name}`,action:`restore`}),k({type:`restore_pi_package`,name:e.name,scope:e.scope,requestId:t})},restartServer:()=>k({type:`restart_server`}),restartSession:()=>{a({type:`settings_apply_started`}),k({type:`restart_session`})},openSideSession:e=>{a({type:`workspace_switching`}),k({type:`open_side_session`,root:e})},submitToken:e=>{F1(e),l.current=e,a({type:`auth_retrying`}),c(e=>e+1)},prompt:(e,t)=>{a({type:`prompt_sent`,text:e,...t?.length?{images:t}:{}}),k({type:`prompt`,text:e,...t?.length?{images:t}:{}})},abort:()=>k({type:`abort`}),cancelPendingPrompt:e=>{a({type:`pending_prompt_cancelled`,restoreText:e}),k({type:`abort`})},setModel:(e,t)=>k({type:`set_model`,provider:e,id:t}),setThinking:e=>k({type:`set_thinking`,level:e}),newSession:()=>k({type:`new_session`}),switchSession:e=>k({type:`switch_session`,path:e}),deleteSession:e=>k({type:`delete_session`,path:e}),listSessions:()=>k({type:`list_sessions`}),renameSession:(e,t)=>k({type:`rename_session`,path:e,name:t}),searchSessions:e=>{let t=`sessions:${j1()}`;a({type:`session_search_started`,query:e,requestId:t}),k({type:`search_sessions`,query:e,requestId:t})},clearSessionSearch:()=>a({type:`session_search_cleared`}),listTree:()=>k({type:`list_tree`}),navigateTree:e=>k({type:`navigate_tree`,entryId:e}),forkSession:e=>k({type:`fork_session`,entryId:e}),prefillComposer:(e,t)=>a({type:`composer_prefilled`,text:e,...t?{notice:t}:{}}),editQueuedPrompt:(e,t)=>k({type:`edit_queued_prompt`,id:e,text:t}),removeQueuedPrompt:e=>k({type:`remove_queued_prompt`,id:e}),sendQueueNow:()=>k({type:`send_queue_now`}),editPrompt:(e,t,n)=>k({type:`edit_prompt`,entryId:e,text:t,...n?.length?{images:n}:{}}),compact:()=>k({type:`compact`}),fetchOlderItems:Ce,loadOlderItems:we,respondToDialog:e=>{k({type:`extension_ui_response`,...e}),a({type:`dialog_answered`})},respondToGrant:(e,t)=>k({type:`sandbox_grant_response`,id:e,decision:t}),dismissNotification:e=>a({type:`dismiss_notification`,id:e}),listDirectory:e=>de(e),refreshFileTree:ye,readFile:(e,t,n)=>{let r=`file:${j1()}`;a({type:`file_read_started`,path:e,requestId:r,...n?{reveal:n}:{}}),k({type:`read_file`,path:e,requestId:r,...t===void 0?{}:{sha256:t}})},closeFilePreview:()=>a({type:`close_file_preview`}),writeFile:(e,t,n,r=!1)=>{let i=`write:${j1()}`;a({type:`file_save_started`,path:e,requestId:i,content:t}),k({type:`write_file`,path:e,content:t,expectedMtimeMs:n,...r?{force:r}:{},requestId:i})},createFile:e=>{a({type:`file_create_started`}),k({type:`create_file`,path:e,requestId:`create:${j1()}`})},uploadFile:(e,t,n)=>{if(n!==void 0&&(i.switching||ee!==O.current))return Promise.reject(new BV);let r=S.current;if(r===null)return Promise.reject(new zV(`the workspace is read-only`,`denied`));let a=o.current;if(!a||a.readyState!==WebSocket.OPEN)return Promise.reject(new zV(`not connected to the server`));let s=n??(r?`${r}/uploads`:`uploads`),c=`upload:${j1()}`;return new Promise((r,i)=>{let a=window.setTimeout(()=>{m.current.delete(c)&&i(new zV(`the upload timed out`))},Y1),o=e=>t=>{clearTimeout(a),e(t)};m.current.set(c,{resolve:o(e=>{if(n!==void 0){if(ee!==O.current){i(new BV);return}de(n,!0)}r(e)}),reject:o(i)}),k({type:`upload_file`,destinationDirectory:s,name:e,contentBase64:t,requestId:c,...n===void 0?{}:{existingDirectory:!0,workspaceId:E??void 0}})})},createDirectory:e=>{a({type:`file_create_started`}),k({type:`create_directory`,path:e,requestId:`create:${j1()}`})},openNative:e=>{let t=`fileop:${j1()}`;a({type:`file_operation_started`,operation:`open_native`,path:e,requestId:t}),k({type:`open_native`,path:e,requestId:t})},revealNative:e=>{let t=Date.now();if(u.current?.path===e&&t-u.current.at<e0)return;u.current={path:e,at:t};let n=`fileop:${j1()}`;a({type:`file_operation_started`,operation:`reveal_native`,path:e,requestId:n}),k({type:`reveal_native`,path:e,requestId:n})},renameFile:(e,t)=>{let n=`fileop:${j1()}`;a({type:`file_operation_started`,operation:`rename_file`,path:e,requestId:n}),k({type:`rename_file`,path:e,name:t,requestId:n})},deleteFile:e=>{let t=`fileop:${j1()}`;a({type:`file_operation_started`,operation:`delete_file`,path:e,requestId:t}),k({type:`delete_file`,path:e,requestId:t})},moveFile:(e,t)=>{let n=`fileop:${j1()}`;a({type:`file_operation_started`,operation:`move_file`,path:e,requestId:n}),k({type:`move_file`,path:e,destinationDirectory:t,requestId:n})},copyFile:(e,t)=>{let n=`fileop:${j1()}`;a({type:`file_operation_started`,operation:`copy_file`,path:e,requestId:n}),k({type:`copy_file`,path:e,destinationDirectory:t,requestId:n})},searchFiles:e=>{let t=`search:${j1()}`;a({type:`file_search_started`,query:e,requestId:t}),k({type:`search_files`,query:e,requestId:t})},clearFileSearch:()=>a({type:`file_search_cleared`}),searchContent:e=>{if(e.trim()===``){a({type:`content_search_cleared`});return}let t=`content:${j1()}`;a({type:`content_search_started`,query:e,requestId:t}),k({type:`search_content`,query:e,requestId:t})},clearContentSearch:()=>a({type:`content_search_cleared`}),fetchGitStatus:()=>P(),fetchGitDiff:e=>{let t=`gitdiff:${j1()}`;a({type:`git_diff_started`,path:e,requestId:t}),k({type:`git_diff`,path:e,requestId:t})},clearGitDiff:()=>a({type:`git_diff_cleared`}),fetchGitLog:(e,t)=>{M.current={repo:e,limit:t},pe(e,t)},closeGitLog:()=>{M.current=null,a({type:`git_log_closed`})},fetchGitShow:(e,t)=>k({type:`git_show`,repo:e,sha:t,requestId:`gitshow:${j1()}`}),clearGitShow:()=>a({type:`git_show_cleared`}),fetchGitFileHistory:(e,t)=>{let n=`gitfilelog:${j1()}`;a({type:`git_file_history_started`,path:e,requestId:n}),k({type:`git_file_log`,path:e,...t?{limit:t}:{},requestId:n})},closeGitFileHistory:()=>a({type:`git_file_history_closed`}),fetchGitFileDiff:(e,t)=>{let n=`gitfilediff:${j1()}`;a({type:`git_file_diff_started`,base:e,target:t,requestId:n}),k({type:`git_file_diff`,base:e,target:t,requestId:n})},clearGitFileDiff:()=>a({type:`git_file_diff_cleared`}),setCredential:(e,t)=>k({type:`set_credential`,provider:e,apiKey:t}),startLogin:(e,t)=>{let n=j1();a({type:`login_started`,flowId:n,provider:e,method:t}),k({type:`start_login`,flowId:n,provider:e,method:t})},answerLogin:e=>{let t=i.login;t?.prompt&&(k({type:`login_answer`,flowId:t.flowId,promptId:t.prompt.promptId,value:e}),a({type:`login_answered`}))},cancelLogin:()=>{let e=i.login;e&&!e.done&&k({type:`cancel_login`,flowId:e.flowId})},dismissLogin:()=>a({type:`login_dismissed`}),logoutProvider:e=>k({type:`logout_provider`,provider:e}),declareProvider:e=>k({type:`declare_provider`,...e}),browseServerDirectory:e=>{let t=`serverdir:${j1()}`;a({type:`server_browse_started`,path:e,requestId:t}),k({type:`browse_server_directory`,path:e,requestId:t})},closeServerBrowser:()=>a({type:`server_browse_closed`}),suggestAgentResourceClonePath:e=>{let t=`resource-clone-path:${j1()}`;a({type:`resource_clone_path_started`,requestId:t}),k({type:`suggest_agent_resource_clone_path`,repositoryUrl:e,requestId:t})},cloneAgentResourceRepository:(e,t)=>{let n=`resource-preview:${j1()}`;a({type:`resource_preview_started`,requestId:n}),k({type:`clone_agent_resource_repository`,repositoryUrl:e,destinationPath:t,requestId:n})},enrollAgentResourceRepository:(e,t,n,r)=>{let i=`resource-enroll:${j1()}`;a({type:`resource_enrollment_started`,requestId:i}),k({type:`enroll_agent_resource_repository`,previewToken:e,skillRoots:t,extensionRoots:n,...r?{enabledSkills:r}:{},requestId:i})},setAgentResourceSkills:(e,t)=>{let n=`resource-skills:${j1()}`;a({type:`resource_skills_started`,requestId:n,repositoryId:e}),k({type:`set_agent_resource_skills`,repositoryId:e,enabledSkills:t,requestId:n})},removeAgentResourceRepository:e=>{let t=`resource-remove:${j1()}`;a({type:`resource_removal_started`,requestId:t,repositoryId:e}),k({type:`remove_agent_resource_repository`,repositoryId:e,requestId:t})},refreshAgentResourceRepositories:e=>{let t=`resource-refresh:${j1()}`;a({type:`resource_refresh_started`,requestId:t,...e?{repositoryId:e}:{}}),k({type:`refresh_agent_resource_repositories`,...e?{repositoryId:e}:{},requestId:t})},updateAgentResourceRepository:(e,t,n,r,i=!1)=>{let o=`resource-update:${j1()}`;a({type:`resource_update_started`,requestId:o,repositoryId:e}),k({type:`update_agent_resource_repository`,repositoryId:e,assessmentToken:t,localRevision:n,upstreamRevision:r,...i?{allowExecutableChanges:!0}:{},requestId:o})},updateConfig:e=>{a({type:`settings_apply_started`}),k({type:`update_config`,...e})},openTerminal:(e,t,n,r,i)=>{let a={type:`terminal_open`,terminalId:e,cwd:t,cols:n,rows:r,...i?{shellId:i}:{}};T.current.set(e,{message:a,socket:o.current?.readyState===WebSocket.OPEN?o.current:null}),k(a)},sendTerminalInput:(e,t)=>k({type:`terminal_input`,terminalId:e,data:t}),getTerminalCwd:e=>k({type:`terminal_get_cwd`,terminalId:e}),resizeTerminal:(e,t,n)=>{let r=T.current.get(e);r&&Object.assign(r.message,{cols:t,rows:n}),k({type:`terminal_resize`,terminalId:e,cols:t,rows:n})},closeTerminal:e=>{T.current.delete(e),k({type:`terminal_close`,terminalId:e}),w.current.delete(e)},subscribeTerminal:(e,t)=>{let n=w.current.get(e);return n||(n={onData:new Set,onCwd:new Set,onExit:new Set,onError:new Set},w.current.set(e,n)),t.onData&&n.onData.add(t.onData),t.onCwd&&n.onCwd.add(t.onCwd),t.onExit&&n.onExit.add(t.onExit),t.onError&&n.onError.add(t.onError),()=>{t.onData&&n?.onData.delete(t.onData),t.onCwd&&n?.onCwd.delete(t.onCwd),t.onExit&&n?.onExit.delete(t.onExit),t.onError&&n?.onError.delete(t.onError)}}}}var n0=120;function r0({label:e}){return(0,N.jsx)(`div`,{className:`flex justify-end px-4`,role:`status`,"aria-live":`polite`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,N.jsx)(`span`,{className:`inline-block h-4 w-4 animate-spin rounded-full border-[3px] border-zinc-300 border-t-blue-500 dark:border-zinc-600 dark:border-t-blue-400 motion-reduce:animate-pulse`}),(0,N.jsx)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:e})]})})}var i0=(0,v.forwardRef)(function({serverUrl:e=``,rootElement:t,initialTheme:n,token:r,workspace:i},a){let o=t!==void 0,s=t??document.documentElement,{state:c,authToken:l,submitToken:u,prompt:d,abort:f,cancelPendingPrompt:p,setModel:m,setThinking:h,newSession:g,switchSession:_,deleteSession:y,listSessions:x,renameSession:S,searchSessions:C,clearSessionSearch:w,listTree:T,navigateTree:D,forkSession:O,editPrompt:ee,editQueuedPrompt:te,removeQueuedPrompt:k,sendQueueNow:ne,prefillComposer:A,compact:re,loadOlderItems:j,fetchOlderItems:ie,respondToDialog:ae,respondToGrant:oe,dismissNotification:se,listDirectory:ce,refreshFileTree:le,readFile:ue,searchContent:de,writeFile:M,createFile:pe,createDirectory:me,uploadFile:he,openNative:ge,revealNative:P,renameFile:_e,deleteFile:ve,moveFile:be,copyFile:xe,closeFilePreview:Se,searchFiles:Ce,clearFileSearch:we,fetchGitDiff:Te,clearGitDiff:Ee,fetchGitLog:De,closeGitLog:Oe,fetchGitShow:ke,clearGitShow:Ae,fetchGitFileHistory:je,closeGitFileHistory:Me,fetchGitFileDiff:Ne,clearGitFileDiff:Pe,setCredential:Fe,startLogin:Ie,answerLogin:Le,cancelLogin:Re,dismissLogin:ze,logoutProvider:Be,declareProvider:Ve,updateConfig:He,suggestAgentResourceClonePath:Ue,cloneAgentResourceRepository:We,enrollAgentResourceRepository:Ge,setAgentResourceSkills:Ke,removeAgentResourceRepository:qe,refreshAgentResourceRepositories:Je,updateAgentResourceRepository:Ye,browseServerDirectory:Xe,closeServerBrowser:Ze,switchWorkspace:Qe,openProject:et,closeProject:tt,openSideSession:nt,checkPiPackages:rt,updatePiPackage:it,lookupPiPackage:at,closePiPackageLookup:ot,installPiPackage:st,removePiPackage:ct,restorePiPackage:lt,restartServer:ut,restartSession:dt,openTerminal:ft,sendTerminalInput:pt,getTerminalCwd:mt,resizeTerminal:ht,closeTerminal:gt,subscribeTerminal:_t,setOutcomeActive:vt,refreshOutcome:yt,fileIo:bt}=t0(e,r,o,i),xt=fe(c.workspace);DG(c.workspaces,c.workspace?GB(c.workspace):null);let St=c.workspace?GB(c.workspace):null;(0,v.useEffect)(()=>{Ot([]),Cn([]),Bn.current&&(Bn.current.scrollTop=0)},[St]);let[Ct,wt]=(0,v.useState)(!1),[Tt,Et]=(0,v.useState)(!1),[Dt,Ot]=(0,v.useState)([]),[kt,At]=(0,v.useState)([]),[jt,Mt]=(0,v.useState)(!1),[Nt,Pt]=(0,v.useState)(null),[Ft,It]=(0,v.useState)(null),Lt=Nt===`project`,Rt=e=>Pt(e?`project`:null),zt=c.embedWorkspaceControls===`projects`?`projects`:c.embedWorkspaceControls===`root`?`root`:`none`,Bt=(0,v.useRef)({}),Vt=(e,t)=>{let n=Bt.current[St??``]?.trim(),r=n?`${n}\n\n${e}`:e;t?A(r,t):A(r)},Ht=c.queuedEditRefused;(0,v.useEffect)(()=>{Ht&&Vt(Ht.text)},[Ht?.nonce]);let Ut=(0,v.useRef)({key:null,drafts:new Map});(0,v.useEffect)(()=>{let e=Ut.current;if(e.key!==St){Ut.current={key:St,drafts:new Map};return}let t=new Set(c.queue.map(e=>e.id));for(let[n,{original:r,draft:i}]of e.drafts)t.has(n)||(e.drafts.delete(n),i.trim()&&i.trim()!==r&&Vt(i.trim(),`The agent read that message before your edit was saved — your edit is in the composer`))},[c.queue,St]);let Wt=(e,t)=>n=>{Ut.current.key!==St&&(Ut.current={key:St,drafts:new Map}),n===null?Ut.current.drafts.delete(e):Ut.current.drafts.set(e,{original:t,draft:n})},Gt=(0,v.useRef)([]),[Kt,qt]=(0,v.useState)(!1),Jt=(0,v.useRef)({readFile:ue,openNative:ge});Jt.current={readFile:ue,openNative:ge};let Yt=(0,v.useMemo)(()=>({serverUrl:e,fileIo:bt,onOpenFile:e=>{qt(!1),Jt.current.readFile(e)},onOpenNative:e=>Jt.current.openNative(e)}),[e,bt]),[Xt,Zt]=(0,v.useState)(AV),Qt=(0,v.useCallback)((e,t)=>{jV(e,t),Zt(n=>({...n,[e]:t}))},[]),[$t,en]=(0,v.useState)(!1),[tn,nn]=(0,v.useState)(!0),[rn,an]=(0,v.useState)(()=>typeof window<`u`&&window.innerWidth<768),[on,sn]=(0,v.useState)(!1),cn=rn?on:tn,[ln,un]=(0,v.useState)(!1),dn=c.terminal?.enabled??!1;(0,v.useEffect)(()=>{let e=window.matchMedia(`(max-width: 767px)`),t=()=>{let t=e.matches;t&&sn(!1),an(t)};return t(),e.addEventListener(`change`,t),window.addEventListener(`resize`,t),()=>{e.removeEventListener(`change`,t),window.removeEventListener(`resize`,t)}},[]),(0,v.useEffect)(()=>{let e=e=>{dn&&(e.ctrlKey||e.metaKey)&&e.key==="`"&&(e.preventDefault(),un(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[dn]);let[fn,pn]=(0,v.useState)(!1),[mn,hn]=(0,v.useState)(null),gn=(0,v.useCallback)(()=>hn(null),[]);function _n(){let e=!$t;en(e),e&&(nn(!1),sn(!1),pn(!1))}function vn(){if(rn){let e=!on;sn(e),e&&(en(!1),pn(!1));return}let e=!tn;nn(e),e&&(en(!1),pn(!1))}function yn(){let e=!fn;pn(e),e&&(en(!1),nn(!1),sn(!1))}(0,v.useEffect)(()=>(vt(fn),()=>vt(!1)),[fn,vt,c.sessionId,St]),(0,v.useEffect)(()=>{pn(!1),hn(null)},[St]);let[bn,xn]=(0,v.useState)([]),[Sn,Cn]=(0,v.useState)([]),wn=(0,v.useRef)(0),Tn=(0,v.useRef)(0),[En,Dn]=(0,v.useState)(0);async function On(e){let t=[...e],n=t.filter(WV).map(e=>({id:`${wn.current++}`,name:e.name}));n.length>0&&Cn(e=>[...e,...n]),Tn.current===0&&xn([]),Tn.current++;try{let{attachments:e,errors:n}=await QV(t,he);e.length>0&&Ot(t=>[...t,...e]),n.length>0&&xn(e=>[...e,...n])}finally{if(Tn.current--,n.length>0){let e=new Set(n.map(e=>e.id));Cn(t=>t.filter(t=>!e.has(t.id)))}}}(0,v.useEffect)(()=>{Gt.current=Dt},[Dt]);function kn(){Se()}let An=(0,v.useMemo)(()=>[...Dt.filter(e=>e.kind===`path`).map(e=>e.data),...kt],[Dt,kt]);function jn(e){let t=Gt.current.findIndex(t=>t.kind===`path`&&t.data===e);t>=0?Mn(t):kt.includes(e)||Ot(t=>rH(t,e))}function Mn(e){Ot(t=>iH(t,e))}let Nn=(0,v.useMemo)(()=>({btw:{region:`Side answer`,pinnedLines:1,anchor:e=>e.findLastIndex(e=>e.startsWith(`› `)),close:{label:`Close side answer`,run:()=>d(`/btw`)}}}),[d]);function Pn(e,t){d(e,t),Ot([]),xn([]),jt||kn()}function Fn(e){e.preventDefault(),Dn(0),e.dataTransfer.files.length>0&&On(Array.from(e.dataTransfer.files))}let{theme:In,preference:Ln,toggle:Rn,setTheme:zn}=E(c.branding.defaultTheme??`system`,c.branding.allowThemeToggle!==!1,s,n);(0,v.useImperativeHandle)(a,()=>({setTheme:zn}),[zn]);let Bn=(0,v.useRef)(null),[Vn,Hn]=(0,v.useState)(null),Un=(0,v.useCallback)(e=>{Bn.current=e,Hn(e)},[]),Wn=(0,v.useRef)(null),Gn=(0,v.useRef)(!0),[Kn,qn]=(0,v.useState)(!0),Jn=(0,v.useCallback)(e=>{e!==Gn.current&&qn(e),Gn.current=e},[]),Yn=(0,v.useCallback)(()=>{let e=Bn.current;e&&Jn(e.scrollHeight-e.scrollTop-e.clientHeight<n0)},[Jn]),Xn=(0,v.useRef)(null),Zn=(0,v.useCallback)(()=>{let e=Bn.current;e&&(e.scrollHeight-e.scrollTop-e.clientHeight<n0||(Xn.current=e.scrollTop))},[]),Qn=(0,v.useCallback)(()=>{let e=Bn.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<n0,n=Xn.current;if(n!==null){if(e.scrollTop<n)Xn.current=null;else if(Xn.current=t?null:e.scrollTop,!t)return}Jn(t)},[Jn]);function $n(){Xn.current=null}(0,v.useEffect)(()=>{let e=Vn;if(!e)return;let t=()=>{Xn.current=null,Qn()};e.addEventListener(`scrollend`,t);let n;return typeof ResizeObserver<`u`&&(n=new ResizeObserver(()=>{Gn.current?(Zn(),Wn.current?.scrollIntoView({behavior:`auto`})):Qn()}),n.observe(e),e.firstElementChild&&n.observe(e.firstElementChild)),()=>{e.removeEventListener(`scrollend`,t),n?.disconnect()}},[Vn,Qn,Zn]);let er=(0,v.useCallback)(()=>{Jn(!0),Zn();let e=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1;Wn.current?.scrollIntoView({behavior:e?`auto`:`smooth`})},[Jn,Zn]);(0,v.useEffect)(()=>{Gn.current?(Zn(),Wn.current?.scrollIntoView({behavior:`smooth`})):Yn()},[c.items,Yn,Zn]);let tr=(0,v.useMemo)(()=>XB(c.items),[c.items]),nr=(0,v.useMemo)(()=>$t?oV(c.items):null,[$t,c.items]),rr=(0,v.useMemo)(()=>tB({readFile:(e,t)=>{qt(!1),ue(e,t)},fetchGitFileHistory:e=>je(e),fetchGitDiff:e=>{qt(!0),ue(e)},searchFiles:e=>Ce(e)}),[ue,je,Ce]),ir=(0,v.useCallback)(()=>Qt(`tools`,!0),[Qt]),ar=(0,v.useCallback)(e=>{let t=Bn.current;if(t){let n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),i=r.top>=n.top&&r.bottom<=n.bottom,a=t.scrollHeight-t.scrollTop-t.clientHeight<n0;if(i&&a)return}Jn(!1)},[Jn]),[or,sr]=(0,v.useState)(null),[cr,lr]=(0,v.useState)(null),ur=(0,v.useMemo)(()=>{let e=c.sessions?.find(e=>e.id===c.sessionId);return c.sessionName?.trim()||e?.name?.trim()||e?.firstMessage?.trim()||c.sessionId},[c.sessionName,c.sessions,c.sessionId]),dr=(0,v.useCallback)(async()=>{lr(null),sr(`preparing…`);try{let{exportConversation:t}=await ye(async()=>{let{exportConversation:e}=await import(`./conversationExport-Bz0O3u-1.js`);return{exportConversation:e}},__vite__mapDeps([26,21,1,25]));await t({items:c.items,olderItems:c.olderHistory?.remaining??0,...c.olderHistory?{fetchOlderItems:ie}:{},connection:{serverUrl:e,token:l,workspace:xt},meta:{...c.workspace?{project:c.workspace.name}:{},session:ur,model:c.model,exportedAt:new Date},onProgress:(e,t,n)=>sr(e===`collecting`?`reading ${t}/${n}…`:`writing ${t}/${n}…`)})}catch(e){lr(e instanceof Error?e.message:`the conversation could not be exported`)}finally{sr(null)}},[c.items,c.olderHistory,c.workspace,c.model,ur,ie,e,l,xt]),{jumpToItem:fr,highlightIndex:pr}=TV({items:c.items,scrollerRef:Bn,hideTools:!Xt.tools,onShowTools:ir,onJump:ar}),mr=(0,v.useRef)(null),hr=(0,v.useRef)(c.olderHistory?.have??0),gr=(0,v.useCallback)(()=>{let e=Bn.current;e&&(mr.current={height:e.scrollHeight,top:e.scrollTop}),j()},[j]);if((0,v.useLayoutEffect)(()=>{let e=c.olderHistory?.have??0,t=hr.current;hr.current=e;let n=mr.current;if(mr.current=null,!n||e<=t)return;let r=Bn.current;r&&(r.scrollTop=n.top+(r.scrollHeight-n.height))},[c.olderHistory?.have]),(0,v.useEffect)(()=>{if(!o){let e=c.extensionTitle??c.branding.title??`pi`;document.title=c.workspace?`${c.workspace.name} — ${e}`:e}c.branding.accentColor&&s.style.setProperty(`--accent`,c.branding.accentColor)},[c.branding,c.extensionTitle,c.workspace?.name,o,s]),o&&!c.brandingReady)return null;if(c.authRequired)return(0,N.jsx)(b.Provider,{value:In,children:(0,N.jsx)(cK,{title:c.branding.title,onSubmit:u})});if(c.credentials&&!c.credentials.usableModel)return(0,N.jsx)(b.Provider,{value:In,children:(0,N.jsx)(VG,{title:c.branding.title,credentials:c.credentials,onSetCredential:Fe,onStartLogin:Ie,login:c.login,onAnswerLogin:Le,onCancelLogin:Re,onDismissLogin:ze,onDeclareProvider:Ve,errors:c.errors})});let _r=c.dialogQueue[0],vr=_r?void 0:c.sandboxGrants?.pending[0];return(0,N.jsx)(b.Provider,{value:In,children:(0,N.jsx)(kg.Provider,{value:c.replyConformance,children:(0,N.jsx)(ng.Provider,{value:c.structuredAppearance,children:(0,N.jsxs)(Pm.Provider,{value:Yt,children:[(0,N.jsxs)(`div`,{className:`relative flex h-full`,onDragEnter:e=>{e.dataTransfer.types.includes(`Files`)&&Dn(e=>e+1)},onDragLeave:()=>Dn(e=>Math.max(0,e-1)),onDragOver:e=>e.preventDefault(),onDrop:Fn,children:[En>0&&(0,N.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-40 flex items-center justify-center border-2 border-dashed bg-white/70 backdrop-blur-sm dark:bg-zinc-950/70`,style:{borderColor:`var(--accent, #3b82f6)`},children:(0,N.jsx)(`p`,{className:`text-lg font-medium text-zinc-700 dark:text-zinc-200`,children:`Drop files to attach (images, documents & text)`})}),(Ct||Tt)&&(0,N.jsx)(sK,{hidden:!Ct,onUploadFile:he,onExternalDragEnter:()=>Dn(0),tree:c.fileTree,openFile:c.openFile,writableRoot:c.writableRoot,gitFiles:c.gitStatus?.files,attachedPaths:An,onExpand:ce,onSelectDirectory:It,onRefresh:le,onSelectFile:e=>{qt(!1),It(e),ue(e)},onSelectDiff:e=>{qt(!0),It(e),ue(e)},onToggleAttachPath:jn,onCreateFile:e=>{qt(!1),pe(e)},onCreateDirectory:me,onOpenNative:ge,onRevealNative:P,onRenameFile:_e,onDeleteFile:ve,onMoveFile:be,onCopyFile:xe,fileOperation:c.fileOperation,createError:c.createError,created:c.created,contentSearch:c.contentSearch,onSearchContent:de,onOpenSearchHit:(e,t)=>{qt(!1),It(e.path),ue(e.path,void 0,e.kind===`line`?{query:t,line:e.line}:{query:t,page:e.page})}},JSON.stringify([St,c.sandbox?.projectRoot??c.sandbox?.root])),(0,N.jsxs)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,children:[Lt&&(0,N.jsx)(vW,{label:`Choose a project directory`,browse:c.serverBrowse,onBrowse:Xe,onSelect:e=>{Rt(!1),Ze(),et(e)},onCancel:()=>{Rt(!1),Ze()}}),!o&&c.outpostUpdate&&(0,N.jsx)(BB,{notice:c.outpostUpdate}),!o&&c.outpostChanges&&(0,N.jsx)(WB,{changes:c.outpostChanges}),(0,N.jsx)(EG,{workspace:c.workspace,workspaces:c.workspaces,workspaceLocked:c.workspaceLocked,workspaceControl:o?zt:`projects`,rootControl:{sandbox:c.sandbox,browse:c.serverBrowse,applyState:c.settingsApply,blocked:Nt!==null&&Nt!==`root`,onBrowse:Xe,onCloseBrowser:()=>{Pt(null),Ze()},onOpened:()=>Pt(`root`),onSelect:e=>He({sandbox:{root:e,allowWrite:c.sandbox?.allowWrite??!1,allowBash:c.sandbox?.allowBash??!1,...c.sandbox?.writableRoot?{writableRoot:c.sandbox.writableRoot}:{}}})},onSwitchWorkspace:Qe,onOpenProject:()=>{Rt(!0),Xe(``)},onCloseProject:tt,onOpenSideSession:nt,piPackages:c.piPackages,piPackageUpdate:c.piPackageUpdate,piPackageEdits:{lookup:c.piPackageLookup,change:c.piPackageChange,projectName:c.workspace?.name??`this`,onLookup:at,onCloseLookup:ot,onInstall:st,onRemove:ct,onRestore:lt},canRestartServer:!o,serverRestarting:c.serverRestarting,onCheckPiPackages:rt,onUpdatePiPackage:it,onRestartServer:ut,restartNeeded:c.restartNeeded,title:c.branding.title,credentials:c.credentials,login:c.login,onStartLogin:Ie,onAnswerLogin:Le,onCancelLogin:Re,onDismissLogin:ze,onLogoutProvider:Be,sessions:c.sessions,sessionSearch:c.sessionSearch,sessionId:c.sessionId,tree:c.tree,isStreaming:c.isStreaming,connected:c.connected,theme:In,showThemeToggle:c.branding.allowThemeToggle!==!1,statuses:c.statuses,sidebarOpen:Ct,outcomeOpen:fn,filters:Xt,onToggleSidebar:()=>{Et(!0),wt(e=>!e)},onToggleOutcome:yn,onFilterChange:Qt,...c.items.length>0?{onExportConversation:()=>void dr()}:{},exportProgress:or,onToggleTheme:Rn,themePreference:Ln,onSetTheme:zn,onNewSession:g,onSwitchSession:_,onDeleteSession:y,onListSessions:x,onRenameSession:S,onSearchSessions:C,onClearSessionSearch:w,onListTree:T,onNavigateTree:D,onForkSession:O,gitAvailable:c.gitAvailable,gitStatus:c.gitStatus,gitSelectedPath:Ft,gitLog:c.gitLog,extensionPaths:c.extensionPaths,configuredExtensionPaths:c.configuredExtensionPaths,userExtensionPaths:c.userExtensionPaths,extensionLock:c.extensionLock,tools:c.tools,commands:c.commands,sandbox:c.sandbox,gitUnavailable:c.gitUnavailable,userSkillPaths:c.userSkillPaths,serverBrowse:c.serverBrowse,settingsApply:c.settingsApply,agentResources:c.agentResources,agentResourceOperations:c.agentResourceOperations,versions:c.versions,onBrowseServerPath:Xe,onCloseServerBrowser:Ze,settingsPickerBlocked:Nt!==null&&Nt!==`settings`,onSettingsPickerOpened:()=>Pt(`settings`),onRestartSession:dt,onUpdateConfig:He,onSuggestAgentResourceClonePath:Ue,onCloneAgentResourceRepository:We,onEnrollAgentResourceRepository:Ge,onSetAgentResourceSkills:Ke,onRemoveAgentResourceRepository:qe,onRefreshAgentResourceRepositories:Je,onUpdateAgentResourceRepository:Ye,onFetchGitLog:De,onCloseGitLog:Oe,onShowCommit:ke,terminalOpen:ln,onToggleTerminal:dn?()=>un(e=>!e):void 0}),(0,N.jsxs)(`div`,{className:`relative z-0 flex min-h-0 flex-1 flex-col`,children:[c.workPlan&&(0,N.jsx)(fK,{plan:c.workPlan,open:cn,onToggle:vn,onOpenWorkspace:e=>{qt(!1),ue(e)},requestedTaskId:mn,onTaskRequestHandled:gn}),fn&&(0,N.jsx)(A1,{state:c.outcome,onClose:()=>pn(!1),onRefresh:yt,onTarget:e=>{e.kind===`work-plan-task`?(hn(e.taskId),pn(!1),en(!1),nn(!0)):e.kind===`workspace-file`?(qt(!1),ue(e.path)):e.kind===`workspace-diff`&&(qt(!0),ue(e.path))}}),c.openFile&&(0,N.jsx)(OU,{file:c.openFile,writableRoot:c.writableRoot,docxTemplate:c.docxTemplate,isStreaming:c.isStreaming,onDirtyChange:Mt,gitState:c.gitStatus?.files[c.openFile.path],initialShowGitDiff:Kt,gitDiff:c.gitDiff,gitBaseline:c.gitBaseline?.path===c.openFile.path?c.gitBaseline.text??null:null,onFetchGitDiff:Te,onClearGitDiff:Ee,inRepository:NV(c.gitStatus?.repos??[],c.openFile.path)!==null,onOpenGitHistory:je,onClose:kn,onReload:ue,onSave:M,serverUrl:e,token:l,workspace:xt,onOpenNative:ge,rawRevision:c.previewRevision},c.openFile.path),c.gitFileHistory&&(0,N.jsx)(iW,{history:c.gitFileHistory,diff:c.gitFileDiff,dirty:c.gitStatus?.files[c.gitFileHistory.path]!==void 0,onFetchDiff:Ne,onClearDiff:Pe,onClose:Me}),c.gitShow&&(0,N.jsx)(jU,{show:c.gitShow,onClose:Ae}),nr&&(0,N.jsx)(CV,{analysis:nr,onJump:fr,onClose:()=>en(!1)}),(0,N.jsx)(`main`,{ref:Un,onScroll:Qn,onWheel:$n,onTouchStart:$n,onKeyDown:$n,className:`relative flex-1 overflow-y-auto transition-opacity duration-150 ${c.switching?`opacity-40`:`opacity-100`} ${$t?`md:pr-[26rem]`:c.workPlan&&cn?`md:pr-[23rem]`:``}`,children:(0,N.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-3 px-4 py-6`,children:[c.items.length===0&&(0,N.jsxs)(`div`,{className:`mt-24 text-center text-zinc-500 dark:text-zinc-600`,children:[(0,N.jsx)(`div`,{className:`mb-2 text-4xl`,children:c.branding.title??`π`}),c.agentStarting?(0,N.jsx)(`p`,{className:`text-sm`,role:`status`,"data-testid":`agent-starting`,children:`Starting the agent… The project's files are ready.`}):(0,N.jsx)(`p`,{className:`text-sm`,children:c.branding.welcome??`Send a message to start the agent.`})]}),c.olderHistory&&(0,N.jsx)(JB,{older:c.olderHistory,onLoad:gr}),c.items.map((t,n)=>{let r=`${c.sessionId}:${n}`,i=(e,t=r)=>(0,N.jsx)(`div`,{"data-item-index":n,className:`flex flex-col gap-3 rounded-lg transition-shadow ${pr===n?`ring-2 ring-blue-400 dark:ring-blue-500`:``}`,children:e},t);return t.kind===`user`?i((0,N.jsx)($e,{item:t,canEdit:!t.readOnly&&!c.isStreaming&&c.connected,onEdit:ee})):t.kind===`compaction`?i((0,N.jsx)(qB,{item:t})):t.kind===`tool`?Xt.tools?i((0,N.jsx)(IB,{item:t,dispatch:rr}),t.toolCallId?`${c.sessionId}:${t.toolCallId}`:r):null:t.kind===`custom`?i((0,N.jsx)(LB,{item:t})):(Xt.reasoning?t.blocks:t.blocks.filter(e=>e.type!==`thinking`)).length===0&&!t.errorMessage?(0,N.jsx)(`div`,{"data-item-index":n,className:`sr-only`,"aria-hidden":!0},r):i((0,N.jsx)(Qz,{item:t,hideReasoning:!Xt.reasoning,serverUrl:e,token:l,workspace:xt,onOpenFile:e=>{qt(!1),ue(e)}}))}),c.pendingPrompt&&(0,N.jsxs)(`div`,{className:`flex flex-col gap-3 opacity-60`,"data-pending-prompt":!0,children:[(0,N.jsx)($e,{item:{kind:`user`,...c.pendingPrompt},canEdit:!1,onEdit:()=>{}}),c.extensionsBinding?(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,"data-testid":`prompt-waiting-for-extensions`,children:[(0,N.jsx)(r0,{label:`waiting for extensions to start…`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>p(!Bt.current[St??``]),className:`text-xs text-zinc-500 underline hover:text-zinc-700 dark:hover:text-zinc-300`,children:`cancel`})]}):(0,N.jsx)(r0,{label:`sending…`})]}),c.isStreaming&&!c.pendingPrompt&&(0,N.jsx)(r0,{label:`working…`}),c.queue.map(e=>(0,N.jsx)($e,{item:{kind:`user`,text:e.text,entryId:e.id,...e.images?{images:e.images}:{}},canEdit:e.editable&&c.connected,onEdit:(e,t)=>te(e,t),queued:{onRemove:()=>k(e.id),onDraftChange:Wt(e.id,e.text)}},e.id)),c.queue.length>0&&(0,N.jsx)(PV,{isStreaming:c.isStreaming,count:c.queue.length,canSend:c.queue.every(e=>e.editable)&&c.connected,onSend:ne}),bn.map((e,t)=>(0,N.jsx)(`div`,{className:`rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-700 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:e},`att${t}`)),cr&&(0,N.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:cr}),c.errors.map((e,t)=>(0,N.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:e},t)),(0,N.jsx)(`div`,{ref:Wn})]})}),(0,N.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-4 z-0 flex justify-center ${$t||fn?`md:pr-[26rem]`:c.workPlan&&cn?`md:pr-[23rem]`:``}`,children:!Kn&&(0,N.jsxs)(`button`,{type:`button`,onClick:er,"aria-label":`Scroll to the latest message`,className:`pointer-events-auto flex items-center gap-1.5 rounded-full border border-zinc-300 bg-white/95 px-3 py-1.5 text-xs text-zinc-600 shadow-lg backdrop-blur transition-colors hover:bg-zinc-50 motion-reduce:transition-none dark:border-zinc-700 dark:bg-zinc-900/95 dark:text-zinc-300 dark:hover:bg-zinc-800`,children:[(0,N.jsx)(`span`,{"aria-hidden":!0,children:`↓`}),`Latest`]})})]}),dn&&(0,N.jsx)(E1,{open:ln,onClose:()=>un(!1),cwd:c.workspace?.root,confinedRoot:c.terminal?.confined?c.sandbox?.root??c.workspace?.root:void 0,confinement:c.confinement?.terminal,unavailable:c.terminal?.unavailable,onSetWorkspaceRoot:e=>{et&&!o?et(e):c.sandbox?He({sandbox:{root:e,allowWrite:c.sandbox.allowWrite,allowBash:c.sandbox.allowBash,...c.sandbox.writableRoot?{writableRoot:c.sandbox.writableRoot}:{}}}):He({sandbox:{root:e,allowWrite:!0,allowBash:!0}})},shells:c.terminal?.shells,openTerminal:ft,sendTerminalInput:pt,getTerminalCwd:mt,resizeTerminal:ht,closeTerminal:gt,subscribeTerminal:_t}),(0,N.jsxs)(`footer`,{className:`shrink-0 border-t border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:[(_r||vr)&&(0,N.jsxs)(`div`,{className:`mx-auto max-w-3xl`,children:[_r&&(0,N.jsx)(CH,{request:_r,onRespond:ae},_r.id),vr&&(0,N.jsx)(DH,{request:vr,onRespond:oe},vr.id)]}),(0,N.jsxs)(`div`,{className:`mx-auto max-w-3xl`,hidden:!!(_r||vr),children:[(0,N.jsx)(zH,{widgets:c.widgets,placement:`aboveEditor`,controls:Nn}),(0,N.jsx)(fH,{initialDraft:Bt.current[St??``]??``,onDraftChange:e=>{Bt.current[St??``]=e},isStreaming:c.isStreaming,connected:c.connected,commands:c.commands,fileSearch:c.fileSearch,prefill:c.editorPrefill,attachments:Dt,pendingUploads:Sn,onAttach:e=>void On(e),onMentionPaths:At,onRemoveAttachment:Mn,onSend:Pn,onAbort:f,onSearchFiles:Ce,onClearFileSearch:we},St??``),(0,N.jsx)(zH,{widgets:c.widgets,placement:`belowEditor`}),(0,N.jsx)(RG,{model:c.model,models:c.models,thinkingLevel:c.thinkingLevel,thinkingLevels:c.thinkingLevels,modelSupportsReasoning:c.modelSupportsReasoning,isStreaming:c.isStreaming,contextUsage:c.contextUsage,shellConfinement:c.confinement?.bash,shellGrants:c.sandboxGrants?.active,sessionUsage:tr,analysisOpen:$t,onToggleAnalysis:_n,isCompacting:c.isCompacting,onSetModel:m,onSetThinking:h,onCompact:re})]})]})]})]}),(0,N.jsx)(jH,{notifications:c.notifications,onDismiss:se})]})})})})});(0,y.createRoot)(document.getElementById(`root`)).render((0,N.jsx)(v.StrictMode,{children:(0,N.jsx)(i0,{})}));export{oe as A,Pg as C,pe as D,ye as E,d as M,ae as O,Bg as S,Be as T,gx as _,Cz as a,S_ as b,lI as c,ij as d,WA as f,PS as g,cC as h,Kz as i,re as j,de as k,WF as l,Cw as m,pU as n,dz as o,VA as p,hU as r,uI as s,L1 as t,vj as u,w_ as v,oh as w,v_ as x,x_ as y};
|