pi-outpost 0.15.2 → 0.16.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/dist/pi-outpost.mjs +587 -402
- package/dist/pi-outpost.sea.mjs +1841 -1656
- package/dist/sea-prep.blob +0 -0
- package/dist/web/assets/{PdfViewer-Bg5VXsan.js → PdfViewer-BYmPlLvT.js} +2 -2
- package/dist/web/assets/{abnfDiagram-VCTEODGH-Bcy0b4DW.js → abnfDiagram-VCTEODGH-DH74fGad.js} +1 -1
- package/dist/web/assets/architecture-7GRP2DOG-D84BA-zd.js +1 -0
- package/dist/web/assets/{architectureDiagram-5GKGNRK7-BVwCpWp7.js → architectureDiagram-5GKGNRK7-CozQRVI3.js} +1 -1
- package/dist/web/assets/{blockDiagram-OSKFZWR5-BKiHuPGm.js → blockDiagram-OSKFZWR5-yYfb8KVV.js} +1 -1
- package/dist/web/assets/{c4Diagram-7LVT6UL2-D8U8F9Aq.js → c4Diagram-7LVT6UL2-W8q_SHt7.js} +1 -1
- package/dist/web/assets/channel-BC7b47So.js +1 -0
- package/dist/web/assets/{chunk-3NF5O7KM-CGDh9sFs.js → chunk-3NF5O7KM-Dhu8uSob.js} +1 -1
- package/dist/web/assets/{chunk-4HAMMTFA-C3_IDYGn.js → chunk-4HAMMTFA-blOO9mdS.js} +1 -1
- package/dist/web/assets/{chunk-75Z2AOVW-EnMTu93R.js → chunk-75Z2AOVW-CMnlxI9q.js} +1 -1
- package/dist/web/assets/{chunk-DU6HZSFF-CwEIrcOW.js → chunk-DU6HZSFF-BPG7Nk40.js} +1 -1
- package/dist/web/assets/{chunk-F27PBJKO-D4Z-bAG6.js → chunk-F27PBJKO-BaMy-SJv.js} +1 -1
- package/dist/web/assets/{chunk-GMAD6QVW-iBmv9R70.js → chunk-GMAD6QVW-iY2LbHpm.js} +1 -1
- package/dist/web/assets/{chunk-GVQU2GXP-DbWqlI1r.js → chunk-GVQU2GXP-BkihtNtX.js} +1 -1
- package/dist/web/assets/{chunk-HLEWEB6X-C9_BXABU.js → chunk-HLEWEB6X-CLvM-boe.js} +1 -1
- package/dist/web/assets/{chunk-L3NEJ4N5-C9JJ0HIS.js → chunk-L3NEJ4N5-BqaHKX_a.js} +1 -1
- package/dist/web/assets/{chunk-OSK3NFVY-oL0qDGlF.js → chunk-OSK3NFVY-kPyXLabE.js} +1 -1
- package/dist/web/assets/{chunk-P2QGCYS3-Dsafwwis.js → chunk-P2QGCYS3-iOebDYZQ.js} +1 -1
- package/dist/web/assets/{chunk-POPQ4Y6H-BF7QK4nD.js → chunk-POPQ4Y6H-WMRys2Fj.js} +1 -1
- package/dist/web/assets/{chunk-PWAF6VOD-qgicUl6y.js → chunk-PWAF6VOD-Bse_eAiz.js} +1 -1
- package/dist/web/assets/{chunk-SVP7TREG-B_ptCsl-.js → chunk-SVP7TREG-BoNa7IEE.js} +1 -1
- package/dist/web/assets/{chunk-ZLD2IHE6-hP47_J_5.js → chunk-ZLD2IHE6-C9Z_LRIl.js} +1 -1
- package/dist/web/assets/classDiagram-CYGNFDIV-DZ6K4mk1.js +1 -0
- package/dist/web/assets/classDiagram-v2-TLXNO2FR-DZ6K4mk1.js +1 -0
- package/dist/web/assets/{cynefin-OW5HDTMX-B10LEmyE.js → cynefin-OW5HDTMX-EvExf4Px.js} +1 -1
- package/dist/web/assets/{cynefinDiagram-5FMLGOSQ-DHVpKaCQ.js → cynefinDiagram-5FMLGOSQ-B2_EmG39.js} +1 -1
- package/dist/web/assets/{dagre-OS7QT2EB-D4ygs5QH.js → dagre-OS7QT2EB-CVyp8c8o.js} +1 -1
- package/dist/web/assets/{diagram-S7CK7UJ4-BzNSGJCg.js → diagram-S7CK7UJ4-TBDljpj1.js} +1 -1
- package/dist/web/assets/{diagram-UQ7AKVKN-DnFoCtkQ.js → diagram-UQ7AKVKN-_OKc9ZHh.js} +1 -1
- package/dist/web/assets/{diagram-VSXAHHWV-BtS9ZbIY.js → diagram-VSXAHHWV-BKXUL2Zc.js} +1 -1
- package/dist/web/assets/{diagram-VX7I27RA-C88R5oiS.js → diagram-VX7I27RA-BxB4pZO7.js} +1 -1
- package/dist/web/assets/{diagram-Z3DM3KII-L5JxKJ_2.js → diagram-Z3DM3KII-o_SatsX9.js} +1 -1
- package/dist/web/assets/{ebnfDiagram-PWID7BFC-D4VzAVLZ.js → ebnfDiagram-PWID7BFC-DJUtXvCY.js} +1 -1
- package/dist/web/assets/{erDiagram-2YWLMYGG-Df7eIG0W.js → erDiagram-2YWLMYGG-Bxue1AvS.js} +1 -1
- package/dist/web/assets/eventmodeling-NTZA5JFV-CxTxqfl7.js +1 -0
- package/dist/web/assets/flowDiagram-T62WH6J4-C9qs0OiC.js +1 -0
- package/dist/web/assets/{ganttDiagram-EL5Y4UJY-C0vOW2zY.js → ganttDiagram-EL5Y4UJY-C5aPpTPW.js} +1 -1
- package/dist/web/assets/{gitGraph-4MIJSDKK-C7GEZyb4.js → gitGraph-4MIJSDKK-TLKE7FjK.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-WWUBYQGX-DOjcZUsc.js → gitGraphDiagram-WWUBYQGX-L_EDmi5u.js} +1 -1
- package/dist/web/assets/{index-sc9CV9lk.js → index-CHIfzJPk.js} +9 -9
- package/dist/web/assets/{info-A6RAGUB7-Cxrj4nO-.js → info-A6RAGUB7-BLDJtBkV.js} +1 -1
- package/dist/web/assets/{infoDiagram-FKFFQAWI-BTCM-V-2.js → infoDiagram-FKFFQAWI-CFzjjIf8.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-5VMMS53U-Dh5RFP9z.js → ishikawaDiagram-5VMMS53U-DtDABrq7.js} +1 -1
- package/dist/web/assets/{journeyDiagram-EYS64GPL-DPdqxcX1.js → journeyDiagram-EYS64GPL-CL38D-8l.js} +1 -1
- package/dist/web/assets/{kanban-definition-UXKFOSKX-CRB_Qqyg.js → kanban-definition-UXKFOSKX-BYkIuVoB.js} +1 -1
- package/dist/web/assets/{line-BSfpCavY.js → line-CgF2C2df.js} +1 -1
- package/dist/web/assets/{mermaid-parser.core-uINaD4jq.js → mermaid-parser.core-SARiv9lL.js} +3 -3
- package/dist/web/assets/{mermaid.core-D3_n2cs6.js → mermaid.core-Dybj2ZTu.js} +4 -4
- package/dist/web/assets/{mindmap-definition-THT77NOG-Cft8EceW.js → mindmap-definition-THT77NOG-ZJ5bRkWw.js} +1 -1
- package/dist/web/assets/{packet-AYTQ26CC-BUPR5T8D.js → packet-AYTQ26CC-hXLYxz-k.js} +1 -1
- package/dist/web/assets/{pdf-BqaSAxIb.js → pdf-CdhwKmnX.js} +1 -1
- package/dist/web/assets/{pegDiagram-XKGWAZYB-DI7A3muX.js → pegDiagram-XKGWAZYB-e2h1fDPV.js} +1 -1
- package/dist/web/assets/{pie-WAS4IAKB-Bgsy0wBD.js → pie-WAS4IAKB-BnYndQ_T.js} +1 -1
- package/dist/web/assets/{pieDiagram-E7YTZNPT-BidxWikp.js → pieDiagram-E7YTZNPT-DbwJnVX6.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-AXDQQJYC-Cc0shg9C.js → quadrantDiagram-AXDQQJYC-OL1FldtK.js} +1 -1
- package/dist/web/assets/{radar-RG4KPBEZ-rdwFr3s9.js → radar-RG4KPBEZ-BFgKl4vD.js} +1 -1
- package/dist/web/assets/{railroad-74A4TZTK-BcKbDVEE.js → railroad-74A4TZTK-DfbOQnT_.js} +1 -1
- package/dist/web/assets/railroad-abnf-HS5TGJTU-DzL6FfBV.js +1 -0
- package/dist/web/assets/railroad-ebnf-LZEXJU2U-kp6c_rJD.js +1 -0
- package/dist/web/assets/railroad-peg-WCYAUIDC-CjsczXbU.js +1 -0
- package/dist/web/assets/{railroadDiagram-O6MQD6OU-COGc07kE.js → railroadDiagram-O6MQD6OU-8h8x1liQ.js} +1 -1
- package/dist/web/assets/{requirementDiagram-IS5BZ75X-Cbr3lz0v.js → requirementDiagram-IS5BZ75X-Dwjg6q3r.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-P5KCCOFB-DgG5AY9B.js → sankeyDiagram-P5KCCOFB-yYFw2Klv.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-WJ2MYXX4-NBvkEPtP.js → sequenceDiagram-WJ2MYXX4-D4cAJMIV.js} +1 -1
- package/dist/web/assets/{stateDiagram-XQSTLZYL-CJCqxCZU.js → stateDiagram-XQSTLZYL-AtVBFTbf.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-IH3M54BS--q8u_hE7.js +1 -0
- package/dist/web/assets/{swimlanes-V6O3JKXN-CO7ttssW.js → swimlanes-V6O3JKXN-DQpsBp9K.js} +1 -1
- package/dist/web/assets/swimlanesDiagram-JKAHXJPX-BgEGzsbn.js +8 -0
- package/dist/web/assets/{timeline-definition-24CTP7MA-yM427sub.js → timeline-definition-24CTP7MA-BEyUcp_P.js} +1 -1
- package/dist/web/assets/{treeView-Q6P3EWNA-kofYi7Gc.js → treeView-Q6P3EWNA-BFLygJye.js} +1 -1
- package/dist/web/assets/{treemap-WGGIJYW6-2PnSzQSS.js → treemap-WGGIJYW6-WKT7_l3q.js} +1 -1
- package/dist/web/assets/{vennDiagram-4TSXK5OY-W9LC00jC.js → vennDiagram-4TSXK5OY-CQomEWpo.js} +1 -1
- package/dist/web/assets/{wardley-WFR3VGLG-DKrVRlCG.js → wardley-WFR3VGLG-eBBa9ULw.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-VM6X3IG4-aJUB_b5A.js → wardleyDiagram-VM6X3IG4-CZ1YzK6K.js} +1 -1
- package/dist/web/assets/{xychartDiagram-S5SC5T6Z-5zhqgnco.js → xychartDiagram-S5SC5T6Z-BALbqvxW.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/web/assets/architecture-7GRP2DOG-DjY6XlyC.js +0 -1
- package/dist/web/assets/channel-Cjqnab5E.js +0 -1
- package/dist/web/assets/classDiagram-CYGNFDIV-BNK0OIN8.js +0 -1
- package/dist/web/assets/classDiagram-v2-TLXNO2FR-BNK0OIN8.js +0 -1
- package/dist/web/assets/eventmodeling-NTZA5JFV-J2Ra1tU_.js +0 -1
- package/dist/web/assets/flowDiagram-T62WH6J4-CnwDFsGR.js +0 -1
- package/dist/web/assets/railroad-abnf-HS5TGJTU-Dt59nPpP.js +0 -1
- package/dist/web/assets/railroad-ebnf-LZEXJU2U-CdcDy4ML.js +0 -1
- package/dist/web/assets/railroad-peg-WCYAUIDC-BELZuybk.js +0 -1
- package/dist/web/assets/stateDiagram-v2-IH3M54BS-BYQ7nByH.js +0 -1
- package/dist/web/assets/swimlanesDiagram-JKAHXJPX-BxgLY3nA.js +0 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-VbNX68N4.js","assets/rolldown-runtime-hePW80VL.js","assets/mermaid.core-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-VbNX68N4.js","assets/rolldown-runtime-hePW80VL.js","assets/mermaid.core-Dybj2ZTu.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-B6xuSHsQ.js","assets/chunk-DU6HZSFF-BPG7Nk40.js","assets/chunk-75Z2AOVW-CMnlxI9q.js","assets/dist-v5Q1xZ2K.js","assets/chunk-PWAF6VOD-Bse_eAiz.js","assets/chunk-GMAD6QVW-iY2LbHpm.js","assets/chunk-P2QGCYS3-iOebDYZQ.js","assets/chunk-4HAMMTFA-blOO9mdS.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-GVQU2GXP-BkihtNtX.js","assets/chunk-OSK3NFVY-kPyXLabE.js","assets/line-CgF2C2df.js","assets/path-fybaL0A-.js","assets/array-BifhSqXX.js","assets/graphlib-DS17s2tU.js","assets/chunk-L3NEJ4N5-BqaHKX_a.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{n as e,r as t,t as n}from"./rolldown-runtime-hePW80VL.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var r=n((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.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.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`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function ee(e,t){return E(e.type,t,e.props)}function D(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function O(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var te=/\/+/g;function ne(e,t){return typeof e==`object`&&e&&e.key!=null?O(``+e.key):t.toString(36)}function re(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(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 ie(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,ie(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+ne(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(te,`$&/`)+`/`),ie(o,r,i,``,function(e){return e})):o!=null&&(D(o)&&(o=ee(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(te,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+ne(a,u),c+=ie(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+ne(a,u++),c+=ie(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return ie(re(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 ae(e,t,n){if(e==null)return e;var r=[],i=0;return ie(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function oe(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var k=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)},se={map:ae,forEach:function(e,t,n){ae(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ae(e,function(){t++}),t},toArray:function(e){return ae(e,function(e){return e})||[]},only:function(e){if(!D(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=se,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},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=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.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 E(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)T.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 E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=D,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:oe}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,k)}catch(e){k(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.8`})),i=n(((e,t)=>{t.exports=r()})),a=n((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,D());else{var t=n(l);t!==null&&ne(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function ee(){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&&ne(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?D():S=!1}}}var D;if(typeof y==`function`)D=function(){y(ee)};else if(typeof MessageChannel<`u`){var O=new MessageChannel,te=O.port2;O.port1.onmessage=ee,D=function(){te.postMessage(null)}}else D=function(){_(ee,0)};function ne(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,ne(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,D()))),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}}}})),o=n(((e,t)=>{t.exports=a()})),s=n((e=>{var t=i();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 a={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},o=Symbol.for(`react.portal`);function s(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var c=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(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=a,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 s(e,t,null,r)},e.flushSync=function(e){var t=c.T,n=a.p;try{if(c.T=null,a.p=2,e)return e()}finally{c.T=t,a.p=n,a.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,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,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=l(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??a.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=l(n,t.crossOrigin);a.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=l(t.as,t.crossOrigin);a.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})}else a.d.m(e)}},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return c.H.useFormState(e,t,n)},e.useFormStatus=function(){return c.H.useHostTransitionStatus()},e.version=`19.2.8`})),c=n(((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=s()})),l=n((e=>{var t=o(),n=i(),r=c();function a(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 s(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function l(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function u(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 d(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 f(e){if(l(e)!==e)throw Error(a(188))}function p(e){var t=e.alternate;if(!t){if(t=l(e),t===null)throw Error(a(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return f(i),e;if(o===r)return f(i),t;o=o.sibling}throw Error(a(188))}if(n.return!==r.return)n=i,r=o;else{for(var s=!1,c=i.child;c;){if(c===n){s=!0,n=i,r=o;break}if(c===r){s=!0,r=i,n=o;break}c=c.sibling}if(!s){for(c=o.child;c;){if(c===n){s=!0,n=o,r=i;break}if(c===r){s=!0,r=o,n=i;break}c=c.sibling}if(!s)throw Error(a(189))}}if(n.alternate!==r)throw Error(a(190))}if(n.tag!==3)throw Error(a(188));return n.stateNode.current===n?e:t}function m(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=m(e),t!==null)return t;e=e.sibling}return null}var h=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),ee=Symbol.for(`react.memo`),D=Symbol.for(`react.lazy`),O=Symbol.for(`react.activity`),te=Symbol.for(`react.memo_cache_sentinel`),ne=Symbol.iterator;function re(e){return typeof e!=`object`||!e?null:(e=ne&&e[ne]||e[`@@iterator`],typeof e==`function`?e:null)}var ie=Symbol.for(`react.client.reference`);function ae(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ie?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case T:return`Suspense`;case E:return`SuspenseList`;case O:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ee:return t=e.displayName||null,t===null?ae(e.type)||`Memo`:t;case D:t=e._payload,e=e._init;try{return ae(e(t))}catch{}}return null}var oe=Array.isArray,k=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,se=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A={pending:!1,data:null,method:null,action:null},ce=[],le=-1;function j(e){return{current:e}}function ue(e){0>le||(e.current=ce[le],ce[le]=null,le--)}function de(e,t){le++,ce[le]=e.current,e.current=t}var fe=j(null),pe=j(null),me=j(null),he=j(null);function ge(e,t){switch(de(me,t),de(pe,e),de(fe,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Hd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Hd(t),e=Ud(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ue(fe),de(fe,e)}function _e(){ue(fe),ue(pe),ue(me)}function ve(e){e.memoizedState!==null&&de(he,e);var t=fe.current,n=Ud(t,e.type);t!==n&&(de(pe,e),de(fe,n))}function ye(e){pe.current===e&&(ue(fe),ue(pe)),he.current===e&&(ue(he),$._currentValue=A)}var be,xe;function Se(e){if(be===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);be=t&&t[1]||``,xe=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+be+e+xe}var Ce=!1;function we(e,t){if(!e||Ce)return``;Ce=!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}e.call(n.prototype)}}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(`
|
|
@@ -13,7 +13,7 @@ Error generating stack: `+e.message+`
|
|
|
13
13
|
|
|
14
14
|
`)?-1:i}function T(e){if(!e.includes(`\\(`)&&!e.includes(`\\[`)&&!e.includes(`\\)`)&&!e.includes(`\\]`))return e;let t=[],n=0;for(;n<e.length;){if(e.startsWith("```",n)){let r=e.indexOf("```",n+3);if(r===-1){t.push(e.slice(n));break}t.push(e.slice(n,r+3)),n=r+3;continue}if(e[n]==="`"){let r=e.indexOf("`",n+1);if(r!==-1&&!e.slice(n+1,r).includes(`
|
|
15
15
|
`)){t.push(e.slice(n,r+1)),n=r+1;continue}}if(e.startsWith(`\\[`,n)){let r=e.indexOf(`\\]`,n+2);if(r!==-1){t.push(`$$`,e.slice(n+2,r),`$$`),n=r+2;continue}let i=w(e,n+2,`$$`,`\\[`);if(i!==-1){t.push(`$$`,e.slice(n+2,i),`$$`),n=i+2;continue}}if(e.startsWith(`\\(`,n)){let r=e.indexOf(`\\)`,n+2);if(r!==-1){t.push(`$`,e.slice(n+2,r),`$`),n=r+2;continue}let i=w(e,n+2,`$`,`\\(`);if(i!==-1){t.push(`$`,e.slice(n+2,i),`$`),n=i+1;continue}}if(e.startsWith(`$$`,n)){let r=w(e,n+2,`\\]`,`\\[`),i=e.indexOf(`$$`,n+2);if(r!==-1&&(i===-1||r<i)){t.push(`$$`,e.slice(n+2,r),`$$`),n=r+2;continue}}if(e[n]===`$`){let r=w(e,n+1,`\\)`,`\\(`),i=e.indexOf(`$`,n+1);if(r!==-1&&(i===-1||r<i)){t.push(`$`,e.slice(n+1,r),`$`),n=r+2;continue}}t.push(e[n]),n++}return t.join(``)}function E(e){let t=`
|
|
16
|
-
… [truncated,`,n=e.includes(t)?e.split(t)[0]:e;try{return JSON.parse(n)}catch{}let r=0,i=-1,a=-1;for(let e=0;e<n.length;e++)if(n[e]===`{`&&r++,n[e]===`}`&&(r--,a=e,r===0)){i=e;break}if(i>0)try{return JSON.parse(n.slice(0,i+1))}catch{return}if(a>0)try{return JSON.parse(n.slice(0,a+1))}catch{return}}function ee(e){let t=E(e);if(typeof t==`string`)return t;if(typeof t!=`object`||!t)return;let n=t.__pi_render;if(n?.text!==void 0&&n.text!==null)return String(n.text)}function D(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith(`//`)}function O(e,t){let n=t.split(/[?#]/)[0],r=n.startsWith(`/`)?n.split(`/`):[...e.split(`/`).slice(0,-1),...n.split(`/`)],i=[];for(let e of r)e!==``&&e!==`.`&&(e===`..`?i.pop():i.push(e));return i.join(`/`)}function te(e){return/\.(png|jpe?g|gif|webp|svg|avif)$/i.test(e)}function ne(e){return/\.pdf$/i.test(e)}function re(e){return/\.(docx|xlsx|pptx)$/i.test(e)}function ie(e,t,n,r){let i=n?`&token=${encodeURIComponent(n)}`:``,a=r===void 0?``:`&v=${encodeURIComponent(String(r))}`;return`${e}/files/raw?path=${encodeURIComponent(t)}${i}${a}`}var ae=n((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),oe=n(((e,t)=>{t.exports=ae()})),k=oe();function se({text:e,className:t}){let[n,r]=(0,d.useState)(!1);async function i(){try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1500)}catch{}}return(0,k.jsx)(`button`,{type:`button`,onClick:i,title:n?`Copied!`:`Copy`,className:t??`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:n?`✓ copied`:`⧉ copy`})}var A=`modulepreload`,ce=function(e){return`/`+e},le={},j=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=ce(t,n),t=s(t),t in le)return;le[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:A,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},ue=null,de={javascript:()=>j(()=>import(`./javascript-8AmHuH5O.js`),[]),typescript:()=>j(()=>import(`./typescript-CxkPLmSc.js`),[]),json:()=>j(()=>import(`./json-PmyKWHmm.js`),[]),xml:()=>j(()=>import(`./xml-COl5yFSC.js`),[]),css:()=>j(()=>import(`./css-D8M8GYaw.js`),[]),scss:()=>j(()=>import(`./scss-gOyOKiXd.js`),[]),bash:()=>j(()=>import(`./bash-LmRjUKlR.js`),[]),python:()=>j(()=>import(`./python-gHmu6VPG.js`),[]),go:()=>j(()=>import(`./go-CYstVVJV.js`),[]),rust:()=>j(()=>import(`./rust-BIKPVoi6.js`),[]),java:()=>j(()=>import(`./java-Dde-Wnb4.js`),[]),c:()=>j(()=>import(`./c-DBVbJFpC.js`),[]),cpp:()=>j(()=>import(`./cpp-N2d8M7Nc.js`),[]),csharp:()=>j(()=>import(`./csharp-yYt0Ikks.js`),[]),ruby:()=>j(()=>import(`./ruby-BGpZ3p4_.js`),[]),php:()=>j(()=>import(`./php-DuZl5e-L.js`),[]),sql:()=>j(()=>import(`./sql-DWRKyvJ-.js`),[]),yaml:()=>j(()=>import(`./yaml-DjOhhVLG.js`),[]),ini:()=>j(()=>import(`./ini-B1CroMsf.js`),[]),dockerfile:()=>j(()=>import(`./dockerfile-C0zufGsU.js`),[]),markdown:()=>j(()=>import(`./markdown-D6FrnlqJ.js`),[]),plaintext:()=>j(()=>import(`./plaintext-YB8mb-y7.js`),[])};async function fe(){return ue||=(async()=>{let{default:e}=await j(async()=>{let{default:e}=await import(`./core-VbNX68N4.js`);return{default:e}},__vite__mapDeps([0,1]));return await Promise.all(Object.entries(de).map(async([t,n])=>{let r=await n();e.registerLanguage(t,r.default)})),e})(),ue}var pe={ts:`typescript`,tsx:`typescript`,mts:`typescript`,cts:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,json:`json`,jsonc:`json`,html:`xml`,htm:`xml`,xml:`xml`,svg:`xml`,css:`css`,scss:`scss`,sh:`bash`,bash:`bash`,zsh:`bash`,py:`python`,go:`go`,rs:`rust`,java:`java`,c:`c`,h:`c`,cpp:`cpp`,cc:`cpp`,cxx:`cpp`,hpp:`cpp`,cs:`csharp`,rb:`ruby`,php:`php`,sql:`sql`,yaml:`yaml`,yml:`yaml`,ini:`ini`,toml:`ini`,dockerfile:`dockerfile`,md:`markdown`,markdown:`markdown`};function me(e){let t=e.split(`/`).pop()??e;if(/^dockerfile$/i.test(t))return`dockerfile`;let n=t.lastIndexOf(`.`);if(!(n<0))return pe[t.slice(n+1).toLowerCase()]}function he({code:e,path:t}){let[n,r]=(0,d.useState)(null),i=(0,d.useRef)(e);return i.current=e,(0,d.useEffect)(()=>{let e=!1;return r(null),fe().then(n=>{if(e)return;let a=me(t),o=a&&n.getLanguage(a)?n.highlight(i.current,{language:a}):n.highlightAuto(i.current);r(o.value)}),()=>{e=!0}},[e,t]),n===null?(0,k.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,children:e}):(0,k.jsx)(`pre`,{className:`hljs whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,dangerouslySetInnerHTML:{__html:n}})}var ge=c();function _e(e){if(e==null)return;if(!(e.getRootNode()instanceof ShadowRoot))return globalThis.document.body;let t=e;for(;t.parentElement!==null;)t=t.parentElement;return t}function ve({label:e,open:t,onClose:n,children:r,actions:i,containerRef:a,anchorRef:o,testId:s=`structured-enlarged`}){(0,d.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,n]);let c=(0,d.useRef)(void 0);return c.current=_e(o?.current)??c.current,t?(0,ge.createPortal)((0,k.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`${e}, full size`,"data-testid":s,onClick:n,className:`fixed inset-0 z-[100] flex items-center justify-center overflow-auto bg-black/60 p-6`,children:(0,k.jsxs)(`div`,{onClick:e=>e.stopPropagation(),className:`max-h-full w-auto max-w-[95vw] overflow-auto rounded-lg bg-white p-4 shadow-xl dark:bg-zinc-900`,children:[(0,k.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-4`,children:[(0,k.jsx)(`span`,{className:`text-xs text-zinc-500`,children:e}),(0,k.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i,(0,k.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close`,className:`rounded px-2 py-0.5 text-xs text-zinc-500 hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:`✕`})]})]}),(0,k.jsx)(`div`,{ref:a,className:`[&_svg]:!max-w-none`,children:r})]})}),c.current??globalThis.document.body):null}var ye=null,be=null;async function xe(e){let t=await(ye??=j(()=>import(`./mermaid.core-D3_n2cs6.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])));return be!==e&&(be=e,t.default.initialize({startOnLoad:!1,theme:e,securityLevel:`strict`,suppressErrorRendering:!0})),t}function Se(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 Ce(e){return typeof e==`object`&&e&&`props`in e&&typeof e.props.className==`string`&&/language-mermaid\b/.test(e.props.className)?String(e.props.children??``).trim():null}function we(e){let{children:t,...n}=e,r=Ce(t);return r===null?(0,k.jsx)(`pre`,{...n,children:t}):(0,k.jsx)(Te,{code:r})}function Te({code:e}){let t=(0,d.useId)().replace(/[^a-zA-Z0-9]/g,``),n=m()===`light`?`default`:`dark`,[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(!1),f=(0,d.useRef)(null),p=(0,d.useRef)(e);return p.current=e,(0,d.useEffect)(()=>{let e=!1,r=setTimeout(async()=>{try{let{svg:r}=await(await xe(n)).default.render(`mermaid-${t}`,p.current);e||(i(r),o(null))}catch(t){e||o(t instanceof Error?t.message:String(t))}},300);return()=>{e=!0,clearTimeout(r)}},[e,t,n]),r?(0,k.jsxs)(`div`,{ref:f,className:`group relative my-2 rounded-lg border border-zinc-200 bg-zinc-50 p-3 dark:border-zinc-800 dark:bg-zinc-900`,children:[(0,k.jsx)(`div`,{className:`absolute left-2 top-2 z-10 opacity-0 transition-opacity group-hover:opacity-100`,children:(0,k.jsx)(`button`,{type:`button`,onClick:()=>c(!s),title:s?`Show diagram`:`Show code`,className:`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:s?`⚏ diagram`:`⌗ code`})}),(0,k.jsxs)(`div`,{className:`absolute right-2 top-2 z-10 flex items-center gap-2 opacity-0 transition-opacity group-hover:opacity-100`,children:[!s&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>u(!0),"aria-label":`Show diagram at full size`,className:`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:`⤢ enlarge`}),(0,k.jsx)(se,{text:e})]}),s?(0,k.jsx)(`pre`,{className:`overflow-x-auto font-mono text-xs text-zinc-500 dark:text-zinc-400`,children:e}):(0,k.jsx)(`div`,{className:`flex justify-center overflow-x-auto [&_svg]:max-w-full`,dangerouslySetInnerHTML:{__html:r}}),(0,k.jsx)(ve,{label:`diagram`,testId:`mermaid-enlarged`,open:l,onClose:()=>u(!1),anchorRef:f,children:(0,k.jsx)(`div`,{style:{width:Se(r)},className:`[&_svg]:!h-auto [&_svg]:!max-w-none [&_svg]:!w-full`,dangerouslySetInnerHTML:{__html:r}})})]}):(0,k.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,k.jsx)(`div`,{className:`mt-2 text-red-600 dark:text-red-400`,children:a})]})}function Ee({html:e,className:t=``,as:n=`div`}){return(0,k.jsx)(n,{className:`rendered-ansi overflow-x-auto font-mono text-xs leading-relaxed [&_span]:whitespace-pre-wrap ${t}`,dangerouslySetInnerHTML:{__html:e}})}function De({lines:e,fill:t=!1}){return(0,k.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:S(x(e)).map((e,t)=>e===null?(0,k.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,k.jsxs)(`div`,{className:`grid grid-cols-2`,children:[(0,k.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,k.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 Oe({lines:e}){return(0,k.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded border border-zinc-200 font-mono text-xs leading-relaxed dark:border-zinc-800`,children:C(e).map((e,t)=>e===null?(0,k.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,k.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 ke({item:e,canEdit:t,onEdit:n}){let[r,i]=(0,d.useState)(null),a=(0,d.useRef)(null),o=t&&e.entryId!==void 0,s=r!==null;(0,d.useEffect)(()=>{s&&a.current?.focus()},[s]),(0,d.useEffect)(()=>{i(null)},[e.entryId,e.text]);function c(){let a=r?.trim();if(!(!t||!e.entryId||!a)){if(a===e.text){i(null);return}n(e.entryId,a,e.images),i(null)}}return(0,k.jsxs)(`div`,{className:`group ml-auto flex max-w-[85%] items-start gap-1.5`,children:[o&&!s&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>i(e.text),title:`edit this prompt and ask again (branches the conversation)`,"aria-label":`Edit this prompt`,className:`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`,children:`✎`}),(0,k.jsxs)(`div`,{className:`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`,children:[e.images&&e.images.length>0&&(0,k.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:e.images.map((e,t)=>(0,k.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:``,className:`max-h-48 max-w-full rounded-lg object-contain`},t))}),s?(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`textarea`,{ref:a,value:r,"aria-label":`Edit prompt`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),c()),e.key===`Escape`&&i(null)},rows:Math.min(10,Math.max(2,r.split(`
|
|
16
|
+
… [truncated,`,n=e.includes(t)?e.split(t)[0]:e;try{return JSON.parse(n)}catch{}let r=0,i=-1,a=-1;for(let e=0;e<n.length;e++)if(n[e]===`{`&&r++,n[e]===`}`&&(r--,a=e,r===0)){i=e;break}if(i>0)try{return JSON.parse(n.slice(0,i+1))}catch{return}if(a>0)try{return JSON.parse(n.slice(0,a+1))}catch{return}}function ee(e){let t=E(e);if(typeof t==`string`)return t;if(typeof t!=`object`||!t)return;let n=t.__pi_render;if(n?.text!==void 0&&n.text!==null)return String(n.text)}function D(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith(`//`)}function O(e,t){let n=t.split(/[?#]/)[0],r=n.startsWith(`/`)?n.split(`/`):[...e.split(`/`).slice(0,-1),...n.split(`/`)],i=[];for(let e of r)e!==``&&e!==`.`&&(e===`..`?i.pop():i.push(e));return i.join(`/`)}function te(e){return/\.(png|jpe?g|gif|webp|svg|avif)$/i.test(e)}function ne(e){return/\.pdf$/i.test(e)}function re(e){return/\.(docx|xlsx|pptx)$/i.test(e)}function ie(e,t,n,r){let i=n?`&token=${encodeURIComponent(n)}`:``,a=r===void 0?``:`&v=${encodeURIComponent(String(r))}`;return`${e}/files/raw?path=${encodeURIComponent(t)}${i}${a}`}var ae=n((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),oe=n(((e,t)=>{t.exports=ae()})),k=oe();function se({text:e,className:t}){let[n,r]=(0,d.useState)(!1);async function i(){try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1500)}catch{}}return(0,k.jsx)(`button`,{type:`button`,onClick:i,title:n?`Copied!`:`Copy`,className:t??`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:n?`✓ copied`:`⧉ copy`})}var A=`modulepreload`,ce=function(e){return`/`+e},le={},j=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=ce(t,n),t=s(t),t in le)return;le[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:A,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},ue=null,de={javascript:()=>j(()=>import(`./javascript-8AmHuH5O.js`),[]),typescript:()=>j(()=>import(`./typescript-CxkPLmSc.js`),[]),json:()=>j(()=>import(`./json-PmyKWHmm.js`),[]),xml:()=>j(()=>import(`./xml-COl5yFSC.js`),[]),css:()=>j(()=>import(`./css-D8M8GYaw.js`),[]),scss:()=>j(()=>import(`./scss-gOyOKiXd.js`),[]),bash:()=>j(()=>import(`./bash-LmRjUKlR.js`),[]),python:()=>j(()=>import(`./python-gHmu6VPG.js`),[]),go:()=>j(()=>import(`./go-CYstVVJV.js`),[]),rust:()=>j(()=>import(`./rust-BIKPVoi6.js`),[]),java:()=>j(()=>import(`./java-Dde-Wnb4.js`),[]),c:()=>j(()=>import(`./c-DBVbJFpC.js`),[]),cpp:()=>j(()=>import(`./cpp-N2d8M7Nc.js`),[]),csharp:()=>j(()=>import(`./csharp-yYt0Ikks.js`),[]),ruby:()=>j(()=>import(`./ruby-BGpZ3p4_.js`),[]),php:()=>j(()=>import(`./php-DuZl5e-L.js`),[]),sql:()=>j(()=>import(`./sql-DWRKyvJ-.js`),[]),yaml:()=>j(()=>import(`./yaml-DjOhhVLG.js`),[]),ini:()=>j(()=>import(`./ini-B1CroMsf.js`),[]),dockerfile:()=>j(()=>import(`./dockerfile-C0zufGsU.js`),[]),markdown:()=>j(()=>import(`./markdown-D6FrnlqJ.js`),[]),plaintext:()=>j(()=>import(`./plaintext-YB8mb-y7.js`),[])};async function fe(){return ue||=(async()=>{let{default:e}=await j(async()=>{let{default:e}=await import(`./core-VbNX68N4.js`);return{default:e}},__vite__mapDeps([0,1]));return await Promise.all(Object.entries(de).map(async([t,n])=>{let r=await n();e.registerLanguage(t,r.default)})),e})(),ue}var pe={ts:`typescript`,tsx:`typescript`,mts:`typescript`,cts:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,json:`json`,jsonc:`json`,html:`xml`,htm:`xml`,xml:`xml`,svg:`xml`,css:`css`,scss:`scss`,sh:`bash`,bash:`bash`,zsh:`bash`,py:`python`,go:`go`,rs:`rust`,java:`java`,c:`c`,h:`c`,cpp:`cpp`,cc:`cpp`,cxx:`cpp`,hpp:`cpp`,cs:`csharp`,rb:`ruby`,php:`php`,sql:`sql`,yaml:`yaml`,yml:`yaml`,ini:`ini`,toml:`ini`,dockerfile:`dockerfile`,md:`markdown`,markdown:`markdown`};function me(e){let t=e.split(`/`).pop()??e;if(/^dockerfile$/i.test(t))return`dockerfile`;let n=t.lastIndexOf(`.`);if(!(n<0))return pe[t.slice(n+1).toLowerCase()]}function he({code:e,path:t}){let[n,r]=(0,d.useState)(null),i=(0,d.useRef)(e);return i.current=e,(0,d.useEffect)(()=>{let e=!1;return r(null),fe().then(n=>{if(e)return;let a=me(t),o=a&&n.getLanguage(a)?n.highlight(i.current,{language:a}):n.highlightAuto(i.current);r(o.value)}),()=>{e=!0}},[e,t]),n===null?(0,k.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,children:e}):(0,k.jsx)(`pre`,{className:`hljs whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,dangerouslySetInnerHTML:{__html:n}})}var ge=c();function _e(e){if(e==null)return;if(!(e.getRootNode()instanceof ShadowRoot))return globalThis.document.body;let t=e;for(;t.parentElement!==null;)t=t.parentElement;return t}function ve({label:e,open:t,onClose:n,children:r,actions:i,containerRef:a,anchorRef:o,testId:s=`structured-enlarged`}){(0,d.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,n]);let c=(0,d.useRef)(void 0);return c.current=_e(o?.current)??c.current,t?(0,ge.createPortal)((0,k.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`${e}, full size`,"data-testid":s,onClick:n,className:`fixed inset-0 z-[100] flex items-center justify-center overflow-auto bg-black/60 p-6`,children:(0,k.jsxs)(`div`,{onClick:e=>e.stopPropagation(),className:`max-h-full w-auto max-w-[95vw] overflow-auto rounded-lg bg-white p-4 shadow-xl dark:bg-zinc-900`,children:[(0,k.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-4`,children:[(0,k.jsx)(`span`,{className:`text-xs text-zinc-500`,children:e}),(0,k.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i,(0,k.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close`,className:`rounded px-2 py-0.5 text-xs text-zinc-500 hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:`✕`})]})]}),(0,k.jsx)(`div`,{ref:a,className:`[&_svg]:!max-w-none`,children:r})]})}),c.current??globalThis.document.body):null}var ye=null,be=null;async function xe(e){let t=await(ye??=j(()=>import(`./mermaid.core-Dybj2ZTu.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])));return be!==e&&(be=e,t.default.initialize({startOnLoad:!1,theme:e,securityLevel:`strict`,suppressErrorRendering:!0})),t}function Se(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 Ce(e){return typeof e==`object`&&e&&`props`in e&&typeof e.props.className==`string`&&/language-mermaid\b/.test(e.props.className)?String(e.props.children??``).trim():null}function we(e){let{children:t,...n}=e,r=Ce(t);return r===null?(0,k.jsx)(`pre`,{...n,children:t}):(0,k.jsx)(Te,{code:r})}function Te({code:e}){let t=(0,d.useId)().replace(/[^a-zA-Z0-9]/g,``),n=m()===`light`?`default`:`dark`,[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(!1),f=(0,d.useRef)(null),p=(0,d.useRef)(e);return p.current=e,(0,d.useEffect)(()=>{let e=!1,r=setTimeout(async()=>{try{let{svg:r}=await(await xe(n)).default.render(`mermaid-${t}`,p.current);e||(i(r),o(null))}catch(t){e||o(t instanceof Error?t.message:String(t))}},300);return()=>{e=!0,clearTimeout(r)}},[e,t,n]),r?(0,k.jsxs)(`div`,{ref:f,className:`group relative my-2 rounded-lg border border-zinc-200 bg-zinc-50 p-3 dark:border-zinc-800 dark:bg-zinc-900`,children:[(0,k.jsx)(`div`,{className:`absolute left-2 top-2 z-10 opacity-0 transition-opacity group-hover:opacity-100`,children:(0,k.jsx)(`button`,{type:`button`,onClick:()=>c(!s),title:s?`Show diagram`:`Show code`,className:`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:s?`⚏ diagram`:`⌗ code`})}),(0,k.jsxs)(`div`,{className:`absolute right-2 top-2 z-10 flex items-center gap-2 opacity-0 transition-opacity group-hover:opacity-100`,children:[!s&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>u(!0),"aria-label":`Show diagram at full size`,className:`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:`⤢ enlarge`}),(0,k.jsx)(se,{text:e})]}),s?(0,k.jsx)(`pre`,{className:`overflow-x-auto font-mono text-xs text-zinc-500 dark:text-zinc-400`,children:e}):(0,k.jsx)(`div`,{className:`flex justify-center overflow-x-auto [&_svg]:max-w-full`,dangerouslySetInnerHTML:{__html:r}}),(0,k.jsx)(ve,{label:`diagram`,testId:`mermaid-enlarged`,open:l,onClose:()=>u(!1),anchorRef:f,children:(0,k.jsx)(`div`,{style:{width:Se(r)},className:`[&_svg]:!h-auto [&_svg]:!max-w-none [&_svg]:!w-full`,dangerouslySetInnerHTML:{__html:r}})})]}):(0,k.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,k.jsx)(`div`,{className:`mt-2 text-red-600 dark:text-red-400`,children:a})]})}function Ee({html:e,className:t=``,as:n=`div`}){return(0,k.jsx)(n,{className:`rendered-ansi overflow-x-auto font-mono text-xs leading-relaxed [&_span]:whitespace-pre-wrap ${t}`,dangerouslySetInnerHTML:{__html:e}})}function De({lines:e,fill:t=!1}){return(0,k.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:S(x(e)).map((e,t)=>e===null?(0,k.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,k.jsxs)(`div`,{className:`grid grid-cols-2`,children:[(0,k.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,k.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 Oe({lines:e}){return(0,k.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded border border-zinc-200 font-mono text-xs leading-relaxed dark:border-zinc-800`,children:C(e).map((e,t)=>e===null?(0,k.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,k.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 ke({item:e,canEdit:t,onEdit:n}){let[r,i]=(0,d.useState)(null),a=(0,d.useRef)(null),o=t&&e.entryId!==void 0,s=r!==null;(0,d.useEffect)(()=>{s&&a.current?.focus()},[s]),(0,d.useEffect)(()=>{i(null)},[e.entryId,e.text]);function c(){let a=r?.trim();if(!(!t||!e.entryId||!a)){if(a===e.text){i(null);return}n(e.entryId,a,e.images),i(null)}}return(0,k.jsxs)(`div`,{className:`group ml-auto flex max-w-[85%] items-start gap-1.5`,children:[o&&!s&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>i(e.text),title:`edit this prompt and ask again (branches the conversation)`,"aria-label":`Edit this prompt`,className:`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`,children:`✎`}),(0,k.jsxs)(`div`,{className:`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`,children:[e.images&&e.images.length>0&&(0,k.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:e.images.map((e,t)=>(0,k.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:``,className:`max-h-48 max-w-full rounded-lg object-contain`},t))}),s?(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`textarea`,{ref:a,value:r,"aria-label":`Edit prompt`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),c()),e.key===`Escape`&&i(null)},rows:Math.min(10,Math.max(2,r.split(`
|
|
17
17
|
`).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,k.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-end gap-2 text-xs`,children:[(0,k.jsx)(`span`,{className:`mr-auto text-blue-900/70 dark:text-zinc-400`,children:t?`asks again from here — the current answer moves to its own branch`:`waiting: the agent is running (or the connection dropped)`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>i(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,k.jsx)(`button`,{type:`button`,onClick:c,disabled:!t||!r.trim()||r.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:`send`})]})]}):(0,k.jsx)(`div`,{className:`whitespace-pre-wrap`,children:e.text})]})]})}function Ae(e){let t=[],n=String(e||``),r=n.indexOf(`,`),i=0,a=!1;for(;!a;){r===-1&&(r=n.length,a=!0);let e=n.slice(i,r).trim();(e||!a)&&t.push(e),i=r+1,r=n.indexOf(`,`,i)}return t}function je(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var Me=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ne=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Pe={};function Fe(e,t){return((t||Pe).jsx?Ne:Me).test(e)}var Ie=/[ \t\n\f\r]/g;function Le(e){return typeof e==`object`?e.type===`text`&&Re(e.value):Re(e)}function Re(e){return e.replace(Ie,``)===``}var ze=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};ze.prototype.normal={},ze.prototype.property={},ze.prototype.space=void 0;function Be(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new ze(n,r,t)}function Ve(e){return e.toLowerCase()}var He=class{constructor(e,t){this.attribute=t,this.property=e}};He.prototype.attribute=``,He.prototype.booleanish=!1,He.prototype.boolean=!1,He.prototype.commaOrSpaceSeparated=!1,He.prototype.commaSeparated=!1,He.prototype.defined=!1,He.prototype.mustUseProperty=!1,He.prototype.number=!1,He.prototype.overloadedBoolean=!1,He.prototype.property=``,He.prototype.spaceSeparated=!1,He.prototype.space=void 0;var Ue=e({boolean:()=>M,booleanish:()=>Ge,commaOrSpaceSeparated:()=>Ye,commaSeparated:()=>Je,number:()=>N,overloadedBoolean:()=>Ke,spaceSeparated:()=>qe}),We=0,M=Xe(),Ge=Xe(),Ke=Xe(),N=Xe(),qe=Xe(),Je=Xe(),Ye=Xe();function Xe(){return 2**++We}var Ze=Object.keys(Ue),Qe=class extends He{constructor(e,t,n,r){let i=-1;if(super(e,t),$e(this,`space`,r),typeof n==`number`)for(;++i<Ze.length;){let e=Ze[i];$e(this,Ze[i],(n&Ue[e])===Ue[e])}}};Qe.prototype.defined=!0;function $e(e,t,n){n&&(e[t]=n)}function et(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new Qe(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[Ve(r)]=r,n[Ve(a.attribute)]=r}return new ze(t,n,e.space)}var tt=et({properties:{ariaActiveDescendant:null,ariaAtomic:Ge,ariaAutoComplete:null,ariaBusy:Ge,ariaChecked:Ge,ariaColCount:N,ariaColIndex:N,ariaColSpan:N,ariaControls:qe,ariaCurrent:null,ariaDescribedBy:qe,ariaDetails:null,ariaDisabled:Ge,ariaDropEffect:qe,ariaErrorMessage:null,ariaExpanded:Ge,ariaFlowTo:qe,ariaGrabbed:Ge,ariaHasPopup:null,ariaHidden:Ge,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:qe,ariaLevel:N,ariaLive:null,ariaModal:Ge,ariaMultiLine:Ge,ariaMultiSelectable:Ge,ariaOrientation:null,ariaOwns:qe,ariaPlaceholder:null,ariaPosInSet:N,ariaPressed:Ge,ariaReadOnly:Ge,ariaRelevant:null,ariaRequired:Ge,ariaRoleDescription:qe,ariaRowCount:N,ariaRowIndex:N,ariaRowSpan:N,ariaSelected:Ge,ariaSetSize:N,ariaSort:null,ariaValueMax:N,ariaValueMin:N,ariaValueNow:N,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function nt(e,t){return t in e?e[t]:t}function rt(e,t){return nt(e,t.toLowerCase())}var it=et({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:Je,acceptCharset:qe,accessKey:qe,action:null,allow:null,allowFullScreen:M,allowPaymentRequest:M,allowUserMedia:M,alpha:M,alt:null,as:null,async:M,autoCapitalize:null,autoComplete:qe,autoFocus:M,autoPlay:M,blocking:qe,capture:null,charSet:null,checked:M,cite:null,className:qe,closedBy:null,colorSpace:null,cols:N,colSpan:N,command:null,commandFor:null,content:null,contentEditable:Ge,controls:M,controlsList:qe,coords:N|Je,crossOrigin:null,data:null,dateTime:null,decoding:null,default:M,defer:M,dir:null,dirName:null,disabled:M,download:Ke,draggable:Ge,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:M,formTarget:null,headers:qe,height:N,hidden:Ke,high:N,href:null,hrefLang:null,htmlFor:qe,httpEquiv:qe,id:null,imageSizes:null,imageSrcSet:null,inert:M,inputMode:null,integrity:null,is:null,isMap:M,itemId:null,itemProp:qe,itemRef:qe,itemScope:M,itemType:qe,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:M,low:N,manifest:null,max:null,maxLength:N,media:null,method:null,min:null,minLength:N,multiple:M,muted:M,name:null,nonce:null,noModule:M,noValidate:M,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:M,optimum:N,pattern:null,ping:qe,placeholder:null,playsInline:M,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:M,referrerPolicy:null,rel:qe,required:M,reversed:M,rows:N,rowSpan:N,sandbox:qe,scope:null,scoped:M,seamless:M,selected:M,shadowRootClonable:M,shadowRootCustomElementRegistry:M,shadowRootDelegatesFocus:M,shadowRootMode:null,shadowRootSerializable:M,shape:null,size:N,sizes:null,slot:null,span:N,spellCheck:Ge,src:null,srcDoc:null,srcLang:null,srcSet:null,start:N,step:null,style:null,tabIndex:N,target:null,title:null,translate:null,type:null,typeMustMatch:M,useMap:null,value:Ge,width:N,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:qe,axis:null,background:null,bgColor:null,border:N,borderColor:null,bottomMargin:N,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:M,declare:M,event:null,face:null,frame:null,frameBorder:null,hSpace:N,leftMargin:N,link:null,longDesc:null,lowSrc:null,marginHeight:N,marginWidth:N,noResize:M,noHref:M,noShade:M,noWrap:M,object:null,profile:null,prompt:null,rev:null,rightMargin:N,rules:null,scheme:null,scrolling:Ge,standby:null,summary:null,text:null,topMargin:N,valueType:null,version:null,vAlign:null,vLink:null,vSpace:N,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:M,disablePictureInPicture:M,disableRemotePlayback:M,exportParts:Je,part:qe,prefix:null,property:null,results:N,security:null,unselectable:null},space:`html`,transform:rt}),at=et({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:Ye,accentHeight:N,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:N,amplitude:N,arabicForm:null,ascent:N,attributeName:null,attributeType:null,azimuth:N,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:N,by:null,calcMode:null,capHeight:N,className:qe,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:N,diffuseConstant:N,direction:null,display:null,dur:null,divisor:N,dominantBaseline:null,download:M,dx:null,dy:null,edgeMode:null,editable:null,elevation:N,enableBackground:null,end:null,event:null,exponent:N,externalResourcesRequired:null,fill:null,fillOpacity:N,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Je,g2:Je,glyphName:Je,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:N,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:N,horizOriginX:N,horizOriginY:N,id:null,ideographic:N,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:N,k:N,k1:N,k2:N,k3:N,k4:N,kernelMatrix:Ye,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:N,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:N,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:N,overlineThickness:N,paintOrder:null,panose1:null,path:null,pathLength:N,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:qe,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:N,pointsAtY:N,pointsAtZ:N,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ye,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ye,rev:Ye,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ye,requiredFeatures:Ye,requiredFonts:Ye,requiredFormats:Ye,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:N,specularExponent:N,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:N,strikethroughThickness:N,string:null,stroke:null,strokeDashArray:Ye,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:N,strokeOpacity:N,strokeWidth:null,style:null,surfaceScale:N,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ye,tabIndex:N,tableValues:null,target:null,targetX:N,targetY:N,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ye,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:N,underlineThickness:N,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:N,values:null,vAlphabetic:N,vMathematical:N,vectorEffect:null,vHanging:N,vIdeographic:N,version:null,vertAdvY:N,vertOriginX:N,vertOriginY:N,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:N,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:nt}),ot=et({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),st=et({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:rt}),ct=et({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),lt={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},ut=/[A-Z]/g,dt=/-[a-z]/g,ft=/^data[-\w.:]+$/i;function pt(e,t){let n=Ve(t),r=t,i=He;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&ft.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(dt,ht);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!dt.test(e)){let n=e.replace(ut,mt);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=Qe}return new i(r,t)}function mt(e){return`-`+e.toLowerCase()}function ht(e){return e.charAt(1).toUpperCase()}var gt=Be([tt,it,ot,st,ct],`html`),_t=Be([tt,at,ot,st,ct],`svg`);function vt(e){let t=String(e||``).trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function yt(e){return e.join(` `).trim()}var bt=n(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
|
|
18
18
|
`);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),xt=n((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(bt());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),St=n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),Ct=n(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(xt()),r=St();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),wt=Et(`end`),Tt=Et(`start`);function Et(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function Dt(e){let t=Tt(e),n=wt(e);if(t&&n)return{start:t,end:n}}function Ot(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?At(e.position):`start`in e||`end`in e?At(e):`line`in e||`column`in e?kt(e):``}function kt(e){return jt(e&&e.line)+`:`+jt(e&&e.column)}function At(e){return kt(e&&e.start)+`-`+kt(e&&e.end)}function jt(e){return e&&typeof e==`number`?e:1}var Mt=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=Ot(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};Mt.prototype.file=``,Mt.prototype.name=``,Mt.prototype.reason=``,Mt.prototype.message=``,Mt.prototype.stack=``,Mt.prototype.column=void 0,Mt.prototype.line=void 0,Mt.prototype.ancestors=void 0,Mt.prototype.cause=void 0,Mt.prototype.fatal=void 0,Mt.prototype.place=void 0,Mt.prototype.ruleId=void 0,Mt.prototype.source=void 0;var Nt=t(Ct(),1),Pt={}.hasOwnProperty,Ft=new Map,It=/[A-Z]/g,Lt=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),Rt=new Set([`td`,`th`]),zt=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function Bt(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=Zt(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=Xt(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?_t:gt,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=Vt(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function Vt(e,t,n){if(t.type===`element`)return Ht(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return Ut(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return Gt(e,t,n);if(t.type===`mdxjsEsm`)return Wt(e,t);if(t.type===`root`)return Kt(e,t,n);if(t.type===`text`)return qt(e,t)}function Ht(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=_t,e.schema=i),e.ancestors.push(t);let a=rn(e,t.tagName,!1),o=Qt(e,t),s=en(e,t);return Lt.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!Le(e)})),Jt(e,o,a,t),Yt(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Ut(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}an(e,t.position)}function Wt(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);an(e,t.position)}function Gt(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=_t,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:rn(e,t.name,!0),o=$t(e,t),s=en(e,t);return Jt(e,o,a,t),Yt(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Kt(e,t,n){let r={};return Yt(r,en(e,t)),e.create(t,e.Fragment,r,n)}function qt(e,t){return t.value}function Jt(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Yt(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function Xt(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function Zt(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=Tt(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function Qt(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&Pt.call(t.properties,i)){let a=tn(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&Rt.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function $t(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else an(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else an(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function en(e,t){let n=[],r=-1,i=e.passKeys?new Map:Ft;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=Vt(e,a,o);s!==void 0&&n.push(s)}return n}function tn(e,t,n){let r=pt(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?je(n):yt(n)),r.property===`style`){let t=typeof n==`object`?n:nn(e,String(n));return e.stylePropertyNameCase===`css`&&(t=on(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?lt[r.property]||r.property:r.attribute,n]}}function nn(e,t){try{return(0,Nt.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new Mt("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=zt+`#cannot-parse-style-attribute`,r}}function rn(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=Fe(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=Fe(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return Pt.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);an(e)}function an(e,t){let n=new Mt("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=zt+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function on(e){let t={},n;for(n in e)Pt.call(e,n)&&(t[sn(n)]=e[n]);return t}function sn(e){let t=e.replace(It,cn);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function cn(e){return`-`+e.toLowerCase()}var ln={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},un={};function dn(e,t){let n=t||un;return fn(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function fn(e,t,n){if(mn(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return pn(e.children,t,n)}return Array.isArray(e)?pn(e,t,n):``}function pn(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=fn(e[i],t,n);return r.join(``)}function mn(e){return!!(e&&typeof e==`object`)}var hn=document.createElement(`i`);function gn(e){let t=`&`+e+`;`;hn.innerHTML=t;let n=hn.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function _n(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function vn(e,t){return e.length>0?(_n(e,e.length,0,t),e):t}var yn={}.hasOwnProperty;function bn(e){let t={},n=-1;for(;++n<e.length;)xn(t,e[n]);return t}function xn(e,t){let n;for(n in t){let r=(yn.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){yn.call(r,a)||(r[a]=[]);let e=i[a];Sn(r[a],Array.isArray(e)?e:e?[e]:[])}}}function Sn(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);_n(e,0,0,r)}function Cn(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function wn(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var Tn=In(/[A-Za-z]/),En=In(/[\dA-Za-z]/),Dn=In(/[#-'*+\--9=?A-Z^-~]/);function On(e){return e!==null&&(e<32||e===127)}var kn=In(/\d/),An=In(/[\dA-Fa-f]/),jn=In(/[!-/:-@[-`{-~]/);function P(e){return e!==null&&e<-2}function Mn(e){return e!==null&&(e<0||e===32)}function Nn(e){return e===-2||e===-1||e===32}var Pn=In(/\p{P}|\p{S}/u),Fn=In(/\s/);function In(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function Ln(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&En(e.charCodeAt(n+1))&&En(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function Rn(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return Nn(r)?(e.enter(n),s(r)):t(r)}function s(r){return Nn(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var zn={tokenize:Bn};function Bn(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Rn(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return P(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var Vn={tokenize:Un},Hn={tokenize:Wn};function Un(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return _n(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Hn,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(Hn,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return P(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;_n(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Wn(e,t,n){return Rn(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function Gn(e){if(e===null||Mn(e)||Fn(e))return 1;if(Pn(e))return 2}function Kn(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var qn={name:`attention`,resolveAll:Jn,tokenize:Yn};function Jn(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};Xn(d,-c),Xn(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=vn(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=vn(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=vn(l,Kn(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=vn(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=vn(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,_n(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function Yn(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Gn(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=Gn(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function Xn(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Zn={name:`autolink`,tokenize:Qn};function Qn(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return Tn(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||En(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||En(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||On(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):Dn(t)?(e.consume(t),l):n(t)}function u(e){return En(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||En(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var $n={partial:!0,tokenize:er};function er(e,t,n){return r;function r(t){return Nn(t)?Rn(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||P(e)?t(e):n(e)}}var tr={continuation:{tokenize:rr},exit:ir,name:`blockQuote`,tokenize:nr};function nr(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return Nn(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function rr(e,t,n){let r=this;return i;function i(t){return Nn(t)?Rn(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(tr,t,n)(r)}}function ir(e){e.exit(`blockQuote`)}var ar={name:`characterEscape`,tokenize:or};function or(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return jn(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var sr={name:`characterReference`,tokenize:cr};function cr(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=En,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=An,u):(e.enter(`characterReferenceValue`),a=7,o=kn,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===En&&!gn(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var lr={partial:!0,tokenize:fr},ur={concrete:!0,name:`codeFenced`,tokenize:dr};function dr(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),Nn(t)?Rn(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||P(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(lr,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||P(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):Nn(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),Rn(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||P(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||P(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&Nn(t)?Rn(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||P(t)?e.check(lr,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||P(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),Nn(t)?Rn(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),Nn(t)?Rn(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||P(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function fr(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var pr={name:`codeIndented`,tokenize:hr},mr={partial:!0,tokenize:gr};function hr(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),Rn(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):P(t)?e.attempt(mr,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||P(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function gr(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):P(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):Rn(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):P(e)?i(e):n(e)}}var _r={name:`codeText`,previous:yr,resolve:vr,tokenize:br};function vr(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function yr(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function br(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):P(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||P(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var xr=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&Sr(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),Sr(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Sr(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);Sr(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);Sr(this.left,t.reverse())}}}};function Sr(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Cr(e){let t={},n=-1,r,i,a,o,s,c,l,u=new xr(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,wr(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return _n(e,0,1/0,u.slice(0)),!l}function wr(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var Tr={resolve:Dr,tokenize:Or},Er={partial:!0,tokenize:kr};function Dr(e){return Cr(e),e}function Or(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):P(t)?e.check(Er,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function kr(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),Rn(e,a,`linePrefix`)}function a(i){if(i===null||P(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function Ar(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||On(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||P(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||Mn(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||On(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function jr(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):P(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||P(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!Nn(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function Mr(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):P(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),Rn(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||P(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function Nr(e,t){let n;return r;function r(i){return P(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):Nn(i)?Rn(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var Pr={name:`definition`,tokenize:Ir},Fr={partial:!0,tokenize:Lr};function Ir(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return jr.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=wn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return Mn(t)?Nr(e,l)(t):l(t)}function l(t){return Ar(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(Fr,d,d)(t)}function d(t){return Nn(t)?Rn(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||P(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function Lr(e,t,n){return r;function r(t){return Mn(t)?Nr(e,i)(t):n(t)}function i(t){return Mr(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return Nn(t)?Rn(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||P(e)?t(e):n(e)}}var Rr={name:`hardBreakEscape`,tokenize:zr};function zr(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return P(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var Br={name:`headingAtx`,resolve:Vr,tokenize:Hr};function Vr(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},_n(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Hr(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||Mn(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||P(n)?(e.exit(`atxHeading`),t(n)):Nn(n)?Rn(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||Mn(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Ur=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),Wr=[`pre`,`script`,`style`,`textarea`],Gr={concrete:!0,name:`htmlFlow`,resolveTo:Jr,tokenize:Yr},Kr={partial:!0,tokenize:Zr},qr={partial:!0,tokenize:Xr};function Jr(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Yr(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:k):Tn(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):Tn(a)?(e.consume(a),i=4,r.interrupt?t:k):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:k):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:D:m):n(i)}function h(t){return Tn(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||Mn(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&Wr.includes(l)?(i=1,r.interrupt?t(s):D(s)):Ur.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):D(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||En(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:D):n(i)}function v(t){return Nn(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||Tn(t)?(e.consume(t),b):Nn(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||En(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):Nn(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):Nn(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||P(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||Mn(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||Nn(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),ee):n(t)}function ee(t){return t===null||P(t)?D(t):Nn(t)?(e.consume(t),ee):n(t)}function D(t){return t===45&&i===2?(e.consume(t),re):t===60&&i===1?(e.consume(t),ie):t===62&&i===4?(e.consume(t),se):t===63&&i===3?(e.consume(t),k):t===93&&i===5?(e.consume(t),oe):P(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Kr,A,O)(t)):t===null||P(t)?(e.exit(`htmlFlowData`),O(t)):(e.consume(t),D)}function O(t){return e.check(qr,te,A)(t)}function te(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ne}function ne(t){return t===null||P(t)?O(t):(e.enter(`htmlFlowData`),D(t))}function re(t){return t===45?(e.consume(t),k):D(t)}function ie(t){return t===47?(e.consume(t),o=``,ae):D(t)}function ae(t){if(t===62){let n=o.toLowerCase();return Wr.includes(n)?(e.consume(t),se):D(t)}return Tn(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),ae):D(t)}function oe(t){return t===93?(e.consume(t),k):D(t)}function k(t){return t===62?(e.consume(t),se):t===45&&i===2?(e.consume(t),k):D(t)}function se(t){return t===null||P(t)?(e.exit(`htmlFlowData`),A(t)):(e.consume(t),se)}function A(n){return e.exit(`htmlFlow`),t(n)}}function Xr(e,t,n){let r=this;return i;function i(t){return P(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function Zr(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt($n,t,n)}}var Qr={name:`htmlText`,tokenize:$r};function $r(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):Tn(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):Tn(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):P(t)?(o=d,ie(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?re(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):P(t)?(o=h,ie(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?re(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?re(t):P(t)?(o=v,ie(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):P(t)?(o=y,ie(t)):(e.consume(t),y)}function b(e){return e===62?re(e):y(e)}function x(t){return Tn(t)?(e.consume(t),S):n(t)}function S(t){return t===45||En(t)?(e.consume(t),S):C(t)}function C(t){return P(t)?(o=C,ie(t)):Nn(t)?(e.consume(t),C):re(t)}function w(t){return t===45||En(t)?(e.consume(t),w):t===47||t===62||Mn(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),re):t===58||t===95||Tn(t)?(e.consume(t),E):P(t)?(o=T,ie(t)):Nn(t)?(e.consume(t),T):re(t)}function E(t){return t===45||t===46||t===58||t===95||En(t)?(e.consume(t),E):ee(t)}function ee(t){return t===61?(e.consume(t),D):P(t)?(o=ee,ie(t)):Nn(t)?(e.consume(t),ee):T(t)}function D(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,O):P(t)?(o=D,ie(t)):Nn(t)?(e.consume(t),D):(e.consume(t),te)}function O(t){return t===i?(e.consume(t),i=void 0,ne):t===null?n(t):P(t)?(o=O,ie(t)):(e.consume(t),O)}function te(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||Mn(t)?T(t):(e.consume(t),te)}function ne(e){return e===47||e===62||Mn(e)?T(e):n(e)}function re(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function ie(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ae}function ae(t){return Nn(t)?Rn(e,oe,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):oe(t)}function oe(t){return e.enter(`htmlTextData`),o(t)}}var ei={name:`labelEnd`,resolveAll:ii,resolveTo:ai,tokenize:oi},ti={tokenize:si},ni={tokenize:ci},ri={tokenize:li};function ii(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&_n(e,0,e.length,n),e}function ai(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=vn(s,e.slice(a+1,a+r+3)),s=vn(s,[[`enter`,u,t]]),s=vn(s,Kn(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=vn(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=vn(s,e.slice(o+1)),s=vn(s,[[`exit`,c,t]]),_n(e,a,e.length,s),e}function oi(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(wn(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(ti,u,o?u:d)(t):t===91?e.attempt(ni,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(ri,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function si(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return Mn(t)?Nr(e,a)(t):a(t)}function a(t){return t===41?u(t):Ar(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return Mn(t)?Nr(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?Mr(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return Mn(t)?Nr(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function ci(e,t,n){let r=this;return i;function i(t){return jr.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(wn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function li(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var ui={name:`labelStartImage`,resolveAll:ei.resolveAll,tokenize:di};function di(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var fi={name:`labelStartLink`,resolveAll:ei.resolveAll,tokenize:pi};function pi(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var mi={name:`lineEnding`,tokenize:hi};function hi(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Rn(e,t,`linePrefix`)}}var gi={name:`thematicBreak`,tokenize:_i};function _i(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||P(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),Nn(t)?Rn(e,s,`whitespace`)(t):s(t))}}var vi={continuation:{tokenize:Si},exit:wi,name:`list`,tokenize:xi},yi={partial:!0,tokenize:Ti},bi={partial:!0,tokenize:Ci};function xi(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:kn(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(gi,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return kn(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check($n,r.interrupt?n:u,e.attempt(yi,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return Nn(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function Si(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check($n,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Rn(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!Nn(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(bi,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,Rn(e,e.attempt(vi,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function Ci(e,t,n){let r=this;return Rn(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function wi(e){e.exit(this.containerState.type)}function Ti(e,t,n){let r=this;return Rn(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!Nn(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var Ei={name:`setextUnderline`,resolveTo:Di,tokenize:Oi};function Di(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function Oi(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),Nn(t)?Rn(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||P(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var ki={tokenize:Ai};function Ai(e){let t=this,n=e.attempt($n,r,e.attempt(this.parser.constructs.flowInitial,i,Rn(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Tr,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var ji={resolveAll:Fi()},Mi=Pi(`string`),Ni=Pi(`text`);function Pi(e){return{resolveAll:Fi(e===`text`?Ii:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function Fi(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function Ii(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var Li=e({attentionMarkers:()=>Gi,contentInitial:()=>zi,disable:()=>Ki,document:()=>Ri,flow:()=>Vi,flowInitial:()=>Bi,insideSpan:()=>Wi,string:()=>Hi,text:()=>Ui}),Ri={42:vi,43:vi,45:vi,48:vi,49:vi,50:vi,51:vi,52:vi,53:vi,54:vi,55:vi,56:vi,57:vi,62:tr},zi={91:Pr},Bi={[-2]:pr,[-1]:pr,32:pr},Vi={35:Br,42:gi,45:[Ei,gi],60:Gr,61:Ei,95:gi,96:ur,126:ur},Hi={38:sr,92:ar},Ui={[-5]:mi,[-4]:mi,[-3]:mi,33:ui,38:sr,42:qn,60:[Zn,Qr],91:fi,92:[Rr,ar],93:ei,95:qn,96:_r},Wi={null:[qn,ji]},Gi={null:[42,95]},Ki={null:[]};function qi(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=vn(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=Kn(a,l.events,l),l.events):[]}function f(e,t){return Yi(p(e),t)}function p(e){return Ji(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){P(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&_n(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Ji(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Yi(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
19
19
|
`;break;case-3:o=`\r
|
|
@@ -314,11 +314,11 @@ l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
314
314
|
`)}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 ${IC(e.id)} as "${RC(PC(e))}"`;for(let e of r){n.push(` box ${RC(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(` ${IC(e.from)}->>${IC(e.to)}: ${RC(e.label??``)}`);return n.join(`
|
|
315
315
|
`)}}function IC(e){return`n${[...e].map(e=>e.charCodeAt(0).toString(36)).join(``)}`}var LC={"#":`#35;`,'"':`#quot;`,";":`#59;`,"<":`#60;`,">":`#62;`};function RC(e){return e.replace(/[#";<>]/g,e=>LC[e]).replace(/[\r\n\t\f\v\u0000-\u001f\u2028\u2029]+/g,` `)}function zC(e,t){return`${e}:${t}`}var BC=new Set;function VC(e,t,n){return n===void 0||n===``?!1:e.has(zC(t,n))}var HC=40,UC=22;function WC(e){let t=e.containers??[],n;if(t.length===0)n=e.participants;else{let r=new Set(t.map(e=>e.id)),i=new Set;n=[];for(let t of e.participants){if(i.has(t.id))continue;let a=t.container;if(a===void 0||!r.has(a)){n.push(t),i.add(t.id);continue}for(let t of e.participants)t.container!==a||i.has(t.id)||(n.push(t),i.add(t.id))}}let r=[];n.forEach((e,n)=>{let i=t.find(t=>t.id===e.container);if(i===void 0)return;let a=r.at(-1);a!==void 0&&a.container.id===i.id&&a.to===n-1?a.to=n:r.push({container:i,from:n,to:n})});let i=t.length>0?UC:0,a=new Map(n.map((e,t)=>[e.id,t])),o=Math.max(...e.participants.map(e=>lC([PC(e)],gC(e),110,240)),cC(e.messages.map(e=>e.label??``),110,240)*.8),s=o-14,c=e.participants.reduce((e,t)=>Math.max(e,dC(uC(PC(t),s).length,fC(gC(t),s).length)),dC(1,0))+8;return{columns:n,bands:r,bandHeight:i,lifelineX:o,boxW:s,headerHeight:c,messageGap:HC,width:Math.max(e.participants.length*o,240),height:i+c+(e.messages.length+1)*HC,xOf:e=>(a.get(e)??0)*o+o/2}}function GC(e,t){let n=[PC(e)];t!==`unchanged`&&n.push(`(${_C[t]})`),e.ref!==void 0&&n.push(`[${e.ref}]`);for(let t of gC(e))n.push(pC(t));return n.join(` `)}function KC(e,t){let n=t.cx-e.cx,r=t.cy-e.cy;if(n===0&&r===0)return{x:e.cx,y:e.cy};let i=Math.min(n===0?1/0:e.w/2/Math.abs(n),r===0?1/0:e.h/2/Math.abs(r));return{x:e.cx+n*i,y:e.cy+r*i}}function qC(e,t){if(e.length<3)return e.map((e,t)=>`${t===0?`M`:`L`} ${e.x} ${e.y}`).join(` `);let n=[`M ${e[0].x} ${e[0].y}`];for(let r=1;r<e.length-1;r++){let i=e[r-1],a=e[r],o=e[r+1],s=Math.hypot(a.x-i.x,a.y-i.y),c=Math.hypot(o.x-a.x,o.y-a.y);if(s===0||c===0)continue;let l=((a.x-i.x)*(o.y-a.y)-(a.y-i.y)*(o.x-a.x))/(s*c);if(Math.abs(l)<.02)continue;let u=Math.min(t,s/2,c/2),d={x:a.x-(a.x-i.x)/s*u,y:a.y-(a.y-i.y)/s*u},f={x:a.x+(o.x-a.x)/c*u,y:a.y+(o.y-a.y)/c*u};n.push(`L ${d.x} ${d.y}`,`Q ${a.x} ${a.y} ${f.x} ${f.y}`)}let r=e[e.length-1];return n.push(`L ${r.x} ${r.y}`),n.join(` `)}function JC(e,t,n,r,i){if(e===t){let t=26+r*12,n=e.cx-e.w/4,i=e.cx+e.w/4,a=e.y;return{d:`M ${n} ${a} C ${n} ${a-t}, ${i} ${a-t}, ${i} ${a}`,labelAt:{x:e.cx,y:a-t*.75},span:t*2}}let a=KC(e,t),o=KC(t,e),s=Math.hypot(o.x-a.x,o.y-a.y),c=(n??[]).slice(1,-1),l=i===void 0?c:c.map((e,t)=>{let n=c.length===1?.5:t/(c.length-1);return{x:e.x+i.from.dx*(1-n)+i.to.dx*n,y:e.y+i.from.dy*(1-n)+i.to.dy*n}});if(l.length>0&&r===0){let e=l[Math.floor((l.length-1)/2)];return{d:qC([a,...l,o],12),labelAt:e,span:s}}let u=r===0?0:Math.ceil(r/2)*22*(r%2==1?1:-1),d=(a.x+o.x)/2,f=(a.y+o.y)/2;if(u===0)return{d:`M ${a.x} ${a.y} L ${o.x} ${o.y}`,labelAt:{x:d,y:f},span:s};let p=s===0?0:-(o.y-a.y)/s,m=s===0?0:(o.x-a.x)/s,h=d+p*u*2,g=f+m*u*2;return{d:`M ${a.x} ${a.y} Q ${h} ${g} ${o.x} ${o.y}`,labelAt:{x:d+p*u,y:f+m*u},span:s}}function YC(e){let t=(e.match(/-?\d+(?:\.\d+)?/g)??[]).map(Number);if(t.length<2)return;let n=1/0,r=1/0,i=-1/0,a=-1/0;for(let e=0;e+1<t.length;e+=2)n=Math.min(n,t[e]),i=Math.max(i,t[e]),r=Math.min(r,t[e+1]),a=Math.max(a,t[e+1]);return{minX:n,minY:r,maxX:i,maxY:a}}function XC(e,t,n,r){let i=t=>{let n=e.participants.find(e=>e.id===t);return n===void 0?t:PC(n)},a=t.label===void 0||t.label===``?``:`: ${t.label}`;return[`${n+1}.`,`${i(t.from)} → ${i(t.to)}${a}`,t.from===t.to?`(to itself)`:``,r===`unchanged`?``:`[${_C[r]}]`,gC(t).map(pC).join(`, `)].filter(e=>e!==``).join(` `)}function ZC(e,t,n){let r=t=>{let n=e.nodes.find(e=>e.id===t);return n===void 0?t:PC(n)},i=t.label??t.kind;return[`${r(t.from)} → ${r(t.to)}`,i===void 0?``:`(${i})`,n===`unchanged`?``:`[${_C[n]}]`,gC(t).map(pC).join(`, `)].filter(e=>e!==``).join(` `)}function QC(e){if(e===void 0||e===``)return;let t=Rv(e,vy);return t.valid?{valid:!0,envelope:t.envelope,issues:[]}:t}function $C(e){let t=QC(e);return t?.valid===!0?t.envelope:void 0}function ew(e){return by(e,vy)}var tw=`#ffffff`,nw=`#27272a`,rw=`#71717a`,iw={added:{fill:`#ecfdf5`,stroke:`#059669`,text:`#065f46`},changed:{fill:`#fffbeb`,stroke:`#d97706`,text:`#92400e`},context:{fill:`#fafafa`,stroke:`#d4d4d8`,text:`#71717a`},unchanged:{fill:`#ffffff`,stroke:`#a1a1aa`,text:nw}},aw={added:`#059669`,changed:`#d97706`,context:`#d4d4d8`,unchanged:`#a1a1aa`},ow=[`added`,`changed`,`context`,`unchanged`],sw=[{fill:`#eff6ff`,stroke:`#2563eb`},{fill:`#f5f3ff`,stroke:`#7c3aed`},{fill:`#ecfeff`,stroke:`#0891b2`},{fill:`#fff1f2`,stroke:`#e11d48`},{fill:`#f7fee7`,stroke:`#65a30d`},{fill:`#fff7ed`,stroke:`#ea580c`},{fill:`#f0fdfa`,stroke:`#0d9488`},{fill:`#fdf4ff`,stroke:`#c026d3`},{fill:`#fefce8`,stroke:`#ca8a04`},{fill:`#f8fafc`,stroke:`#475569`},{fill:`#eef2ff`,stroke:`#4f46e5`},{fill:`#fef2f2`,stroke:`#b91c1c`},{fill:`#f0fdf4`,stroke:`#16a34a`},{fill:`#fdf2f8`,stroke:`#db2777`},{fill:`#f5f5f4`,stroke:`#78716c`},{fill:`#f0f9ff`,stroke:`#0369a1`}],cw=[void 0,`7 3`,`2 3`,`9 3 2 3`],lw=sw.length*cw.length;function uw(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return t}sw.length;function dw(e){let t=new Map,n=new Set;for(let r of e){let e=uw(r)%lw;for(let t=0;t<lw&&n.has(e);t++)e=(e+1)%lw;n.add(e);let i=sw[e%sw.length];t.set(r,{...i,dash:cw[Math.floor(e/sw.length)%cw.length]})}return t}function fw(e){let t=[];for(let n of e)n.kind!==void 0&&n.kind!==``&&!t.includes(n.kind)&&t.push(n.kind);return t}var pw=`system-ui, sans-serif`;function mw(e){let t=iw[e.role],n={fill:e.tint?.fill??t.fill,stroke:e.role===`unchanged`?e.tint?.stroke??t.stroke:t.stroke,text:t.text===`#71717a`?rw:nw},r=e.role===`added`||e.role===`changed`?2:1.2,i=e.role===`context`?.62:1,a=e.anchor??`start`,o=uC(e.label,e.width),s=fC(e.changes,e.width),c=o.length+s.length,l=e.y+e.height/2-(c-1)*15/2+4,u=a===`middle`?e.x+e.width/2:e.x+8,d=[{shape:`rect`,x:e.x,y:e.y,width:e.width,height:e.height,rx:5,fill:n.fill,stroke:n.stroke,strokeWidth:r,...e.tint?.dash===void 0?{}:{strokeDasharray:e.tint.dash},opacity:i}];return o.forEach((e,t)=>{d.push({shape:`text`,x:u,y:l+t*15,text:e,fontSize:11,fill:n.text,fontFamily:pw,textAnchor:a,opacity:i})}),s.forEach((e,t)=>{d.push({shape:`text`,x:u,y:l+(o.length+t)*15,text:e,fontSize:9,fontWeight:600,fill:n.text,fontFamily:pw,textAnchor:a,opacity:i,testId:`field-changes`})}),d}var hw=17,gw=18,_w=92,vw=860;function yw(e){return Math.min(e,vw)}function bw(e){return 21+(e.length+9)*5.6+gw}function xw(e,t){let n=yw(t),r=1,i=0;for(let t of e.entries){let e=bw(t.label);i>0&&_w+i+e>n-20&&(r+=1,i=0),i+=e}return r}function Sw(e){let t=e.flatMap(e=>e.entries).reduce((e,t)=>Math.max(e,bw(t.label)),0);return t===0?0:Math.min(_w+t+32,vw)}function Cw(e,t){let n=e.filter(e=>e.entries.length>0);return n.length===0?0:n.reduce((e,n)=>e+xw(n,t),0)*hw+12}function ww(e,t,n,r){let i=e.filter(e=>e.entries.length>0);if(i.length===0)return[];let a=yw(r),o=[],s=0;for(let e of i){let r=s,i=0,c=[];for(let r of e.entries){let o=bw(r.label);i>0&&_w+i+o>a-20&&(s+=1,i=0);let l=t+_w+i,u=n+s*hw;i+=o;let d=e.sample===`line`?{shape:`line`,x1:l,y1:u+5,x2:l+16,y2:u+5,stroke:r.stroke,strokeWidth:1.6,...r.dashed===void 0?{}:{strokeDasharray:r.dashed}}:{shape:`rect`,x:l,y:u,width:16,height:10,rx:2,fill:r.fill,stroke:r.stroke,strokeWidth:1.2,...r.dashed===void 0?{}:{strokeDasharray:r.dashed}};c.push({id:`legend-${r.key??r.label}`,data:{"legend-entry":r.key??r.label,...r.toggles===!0&&r.key!==void 0?{toggles:`true`}:{},...r.faded===!0?{faded:`true`}:{},...r.hidden===!0?{hidden:`true`}:{}},opacity:r.hidden===!0?.45:r.faded===!0?.62:1,primitives:[d,{shape:`text`,x:l+21,y:u+9,text:r.hidden===!0?`${r.label} (hidden)`:r.label,fontSize:9,fill:rw,fontFamily:pw}]})}o.push({id:`legend-title-${e.title}`,primitives:[{shape:`text`,x:t,y:n+r*hw+9,text:e.title,fontSize:9,fontWeight:600,fill:rw,fontFamily:pw,testId:`legend-group`}]}),o.push(...c),s+=1}return[{id:`diagram-legend`,testId:`diagram-legend`,primitives:[],groups:o}]}function Tw(e,t){return`${e}-${t.replace(`#`,``)}`}function Ew(e){let t=lC([PC(e)],gC(e),120,260);return{width:t,height:dC(uC(PC(e),t).length,fC(gC(e),t).length)}}function Dw(e,t){let n=e.nodes.filter(e=>!VC(t,`element`,e.kind)),r=new Set(n.map(e=>e.id));return{nodes:n,edges:e.edges.filter(e=>!VC(t,`relationship`,e.kind)&&r.has(e.from)&&r.has(e.to)),containers:e.containers}}function Ow(e,t){let n=t.hidden??BC,r=t.nudges??new Map,i=t.isProposal,a=Dw(e,n),o=MC(a,Ew),s=new Map(o.nodes.map(e=>[e.id,e])),c=e=>{let t=s.get(e);if(t===void 0)return;let n=r.get(e),i=t.x+(n?.dx??0),a=t.y+(n?.dy??0);return{x:i,y:a,cx:i+t.width/2,cy:a+t.height/2,w:t.width,h:t.height}},l=o.containers.map(e=>{let t=CC(a.nodes.filter(t=>t.container===e.id).flatMap(e=>{let t=c(e.id);return t===void 0?[]:[{x:t.x,y:t.y,width:t.w,height:t.h}]}));return t===void 0?e:{...e,...t}}),u=dw(fw(e.nodes)),d=dw(fw(e.edges)),f=e=>t=>{let r=(e===`element`?u:d).get(t);return{label:t,fill:r.fill,stroke:r.stroke,...r.dash===void 0?{}:{dashed:r.dash},toggles:!0,key:zC(e,t),hidden:n.has(zC(e,t))}},p=[{title:`elements`,sample:`box`,entries:fw(e.nodes).map(f(`element`))},{title:`relationships`,sample:`line`,entries:fw(e.edges).map(f(`relationship`))}];if(i){let e=new Set([...a.nodes.map(e=>mC(e,!0)),...a.edges.map(e=>hC(e,!0))]);p.push({title:`changes`,sample:`box`,entries:ow.filter(t=>t!==`unchanged`&&e.has(t)).map(e=>({label:_C[e],fill:tw,stroke:iw[e].stroke,faded:e===`context`}))})}let m=new Map,h=new Map;for(let e of a.edges){let t=JSON.stringify([e.from,e.to]),n=h.get(t)??0;m.set(e,n),h.set(t,n+1)}let g=new Map(o.edges.map(e=>[e.index,e.points])),_=new Map;a.edges.forEach((e,t)=>{let n=g.get(t);n!==void 0&&_.set(e,n)});let v={dx:0,dy:0},y=a.edges.map(e=>{let t=c(e.from),n=c(e.to);if(t===void 0||n===void 0)return;let i=r.has(e.from)||r.has(e.to);return JC(t,e.from===e.to?t:n,_.get(e),m.get(e)??0,i?{from:r.get(e.from)??v,to:r.get(e.to)??v}:void 0)}),b=o.nodes.map(e=>c(e.id)),x=y.flatMap(e=>{let t=e===void 0?void 0:YC(e.d);return t===void 0?[]:[t]}),S=Math.min(0,...b.map(e=>e.x-12),...x.map(e=>e.minX-12)),C=Math.min(0,...b.map(e=>e.y-12),...x.map(e=>e.minY-14)),w=Math.max(o.width,...b.map(e=>e.x+e.w+12),...x.map(e=>e.maxX+12)),T=Math.max(o.height,...b.map(e=>e.y+e.h+12),...x.map(e=>e.maxY+12)),E=e=>{let t=hC(e,i),n=e.kind===void 0?void 0:d.get(e.kind);return{role:t,stroke:n?.stroke??aw.unchanged,dash:n?.dash,halo:t===`added`||t===`changed`?aw[t]:void 0,width:t===`context`?1:t===`unchanged`?1.5:1.8,opacity:t===`context`?.6:1}},ee=[...new Set(a.edges.map(e=>E(e).stroke))],D=T+4,O=Math.max(w-S,Sw(p)),te=T-C+Cw(p,O),ne=[];for(let e of l)ne.push({id:`container-${e.id}`,data:{container:e.id},primitives:[{shape:`rect`,x:e.x,y:e.y,width:e.width,height:e.height,rx:8,fill:`none`,stroke:rw,strokeDasharray:`5 3`,opacity:.55},{shape:`text`,x:e.x+8,y:e.y+12,text:e.label,fontSize:10,fill:rw}]});a.edges.forEach((t,n)=>{let r=c(t.from),i=c(t.to),a=y[n];if(r===void 0||i===void 0||a===void 0)return;let o=E(t),s=o.stroke,l=gC(t),u=t.label??t.kind,d=e=>e.length*5.2+8<=a.span,f=[];o.halo!==void 0&&f.push({shape:`path`,data:{edge:`role`},d:a.d,fill:`none`,stroke:o.halo,strokeWidth:o.width+4,strokeLinecap:`round`,opacity:.3}),f.push({shape:`path`,data:{edge:`line`},d:a.d,fill:`none`,stroke:s,strokeWidth:o.width,...o.dash===void 0?{}:{strokeDasharray:o.dash},opacity:o.opacity,markerEnd:Tw(`se-arrow`,s)}),u!==void 0&&d(u)&&f.push({shape:`text`,x:a.labelAt.x,y:a.labelAt.y-5,text:u,textAnchor:`middle`,fontSize:9,fill:s,fontFamily:pw,stroke:tw,strokeWidth:3,paintOrder:`stroke`});let p=l.map(pC).join(`, `);l.length>0&&d(p)&&f.push({shape:`text`,x:a.labelAt.x,y:a.labelAt.y+10,text:p,textAnchor:`middle`,fontSize:9,fontWeight:600,fill:s,fontFamily:pw,stroke:tw,strokeWidth:3,paintOrder:`stroke`,testId:`relationship-change`}),ne.push({id:`edge-${n}`,data:{"relationship-role":o.role,"relationship-shape":t.from===t.to?`loop`:`open`},title:ZC(e,t,o.role),primitives:f})});for(let e of a.nodes){let t=c(e.id);if(t===void 0)continue;let n=mC(e,i);ne.push({id:e.id,data:{"element-role":n,"element-id":e.id,draggable:`node`},title:GC(e,n),primitives:mw({x:t.x,y:t.y,width:t.w,height:t.h,role:n,label:PC(e),...e.kind===void 0?{}:{tint:u.get(e.kind)},changes:gC(e)})})}let re=n.size===0?void 0:`Filtered view: ${a.nodes.length} of ${e.nodes.length} elements and ${a.edges.length} of ${e.edges.length} relationships shown.`+(i?` Hidden types are still part of the proposal.`:``);return re!==void 0&&ne.push({id:`filter-note`,primitives:[{shape:`text`,x:S+12,y:D+Cw(p,O)-4,text:re,fontSize:9,fontWeight:600,fill:`#92400e`,fontFamily:pw,testId:`diagram-filter-note`}]}),ne.push(...ww(p,S+12,D,O)),{width:O,height:te,viewBox:`${S} ${C} ${O} ${te}`,ariaLabel:a.nodes.length===e.nodes.length&&a.edges.length===e.edges.length?`Graph of ${e.nodes.length} elements and ${e.edges.length} relationships`:`Graph of ${e.nodes.length} elements and ${e.edges.length} relationships, filtered to ${a.nodes.length} elements and ${a.edges.length} relationships`,background:tw,markers:ee.map(e=>({id:Tw(`se-arrow`,e),paint:e})),groups:ne,...re===void 0?{}:{narrowing:re}}}function kw(e,t){let n=t.isProposal,r=WC(e),{columns:i,bands:a,bandHeight:o,lifelineX:s,boxW:c,headerHeight:l,messageGap:u}=r,d=o,f=r.xOf,p=dw(fw(e.participants)),m=[{title:`participants`,sample:`box`,entries:fw(e.participants).map(e=>{let t=p.get(e);return{label:e,fill:t.fill,stroke:t.stroke,...t.dash===void 0?{}:{dashed:t.dash},key:zC(`element`,e)}})}];if(n){let t=new Set([...e.participants.map(e=>mC(e,!0)),...e.messages.map(e=>hC(e,!0))]);m.push({title:`changes`,sample:`box`,entries:ow.filter(e=>e!==`unchanged`&&t.has(e)).map(e=>({label:_C[e],fill:tw,stroke:iw[e].stroke,faded:e===`context`}))})}let h=r.height+4,g=Math.max(r.width,Sw(m)),_=r.height+Cw(m,g),v=[];for(let e of a){let t=e.from*s+(s-c)/2,n=e.to*s+(s+c)/2;v.push({id:`band-${e.container.id}-${e.from}`,data:{container:e.container.id},primitives:[{shape:`rect`,x:t,y:2,width:n-t,height:d-6,rx:5,fill:`none`,stroke:rw,strokeDasharray:`5 3`,opacity:.55},{shape:`text`,x:(t+n)/2,y:d-9,text:e.container.label,fontSize:10,textAnchor:`middle`,fill:rw}]})}for(let e of i)v.push({id:`life-${e.id}`,primitives:[{shape:`line`,x1:f(e.id),y1:o+l,x2:f(e.id),y2:r.height-6,stroke:`#d4d4d8`,strokeDasharray:`3 3`,strokeWidth:1}]});for(let e of i){let t=mC(e,n);v.push({id:e.id,data:{"element-role":t,"element-id":e.id},title:GC(e,t),primitives:mw({x:f(e.id)-c/2,y:o+4,width:c,height:l-8,role:t,label:PC(e),...e.kind===void 0?{}:{tint:p.get(e.kind)},changes:gC(e),anchor:`middle`})})}return e.messages.forEach((t,r)=>{let i=hC(t,n),a=aw[i],s=o+l+(r+1)*u,c=f(t.from),d=f(t.to),p=t.from===t.to,m=gC(t),h=p?c+26+6:(c+d)/2,g=p?`start`:`middle`,_=[];p?_.push({shape:`path`,d:`M ${c} ${s} h 26 v ${u/2} h -26`,fill:`none`,stroke:a,strokeWidth:1.4,markerEnd:Tw(`se-msg`,a)}):_.push({shape:`line`,x1:c,y1:s,x2:d,y2:s,stroke:a,strokeWidth:1.4,markerEnd:Tw(`se-msg`,a)}),t.label!==void 0&&_.push({shape:`text`,x:h,y:s-5,text:t.label,textAnchor:g,fontSize:10,fill:nw,fontFamily:pw,stroke:tw,strokeWidth:3,paintOrder:`stroke`}),m.length>0&&_.push({shape:`text`,x:h,y:s+11,text:m.map(pC).join(`, `),textAnchor:g,fontSize:9,fontWeight:600,fill:a,fontFamily:pw,stroke:tw,strokeWidth:3,paintOrder:`stroke`,testId:`relationship-change`}),_.push({shape:`text`,x:4,y:s+3,text:String(r+1),fontSize:9,fill:rw,fontFamily:pw}),v.push({id:`message-${r}`,data:{"relationship-role":i,"message-index":String(r),"message-from":t.from,"message-to":t.to},title:XC(e,t,r,i),primitives:_})}),v.push(...ww(m,12,h,g)),{width:g,height:_,viewBox:`0 0 ${g} ${_}`,ariaLabel:`Sequence of ${e.participants.length} participants and ${e.messages.length} messages`,background:tw,markers:ow.map(e=>({id:Tw(`se-msg`,aw[e]),paint:aw[e]})),groups:v}}var Aw=`change`;function jw(e,t){let n=bC(e),r=e.rows.filter(e=>{let r=xC(e,n);return r===void 0||!t.has(zC(`role`,r))});return{columns:n?[...e.columns,Aw]:[...e.columns],rows:r.map(e=>{let t=bv(e).cells,r=xC(e,n);return r===void 0?t:[...t,vC[r]]}),withheld:e.rows.length-r.length}}function Mw(e){if(e===null)return``;let t=String(e);return/[",\n\r]/.test(t)?`"${t.replaceAll(`"`,`""`)}"`:t}function Nw(e){return[e.columns,...e.rows].map(e=>e.map(Mw).join(`,`)).join(`\r
|
|
316
316
|
`)}function Pw(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),URL.revokeObjectURL(n)}function Fw(e,t){Pw(new Blob([``,Nw(e)],{type:`text/csv;charset=utf-8`}),t)}async function Iw(e,t){let{default:n}=await j(async()=>{let{default:e}=await import(`./browser-CB9WaMml.js`);return{default:e}},[]);Pw(await n([e.columns.map(e=>({value:e,fontWeight:`bold`})),...e.rows.map(e=>e.map(e=>e===null?{value:void 0}:typeof e==`number`?{value:e,type:Number}:typeof e==`boolean`?{value:e,type:Boolean}:{value:e,type:String}))]).toBlob(),t)}function Lw({primitive:e}){let t=Object.fromEntries(Object.entries(e.data??{}).map(([e,t])=>[`data-${e}`,t]));switch(e.shape){case`rect`:return(0,k.jsx)(`rect`,{...t,x:e.x,y:e.y,width:e.width,height:e.height,rx:e.rx,fill:e.fill,stroke:e.stroke,strokeWidth:e.strokeWidth,strokeDasharray:e.strokeDasharray,opacity:e.opacity});case`text`:return(0,k.jsx)(`text`,{...t,"data-testid":e.testId,x:e.x,y:e.y,fontSize:e.fontSize,fontFamily:e.fontFamily,fontWeight:e.fontWeight,textAnchor:e.textAnchor,fill:e.fill,stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,opacity:e.opacity,children:e.text});case`line`:return(0,k.jsx)(`line`,{...t,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.stroke,strokeWidth:e.strokeWidth,strokeDasharray:e.strokeDasharray,opacity:e.opacity,markerEnd:e.markerEnd===void 0?void 0:`url(#${e.markerEnd})`});case`path`:return(0,k.jsx)(`path`,{...t,d:e.d,fill:e.fill??`none`,stroke:e.stroke,strokeWidth:e.strokeWidth,strokeDasharray:e.strokeDasharray,strokeLinecap:e.strokeLinecap,opacity:e.opacity,markerEnd:e.markerEnd===void 0?void 0:`url(#${e.markerEnd})`,pointerEvents:`none`})}}function Rw({group:e,interaction:t}){let n=Object.fromEntries(Object.entries(e.data??{}).map(([e,t])=>[`data-${e}`,t])),{extra:r,before:i}=t?.(e)??{};return(0,k.jsxs)(`g`,{...n,"data-testid":e.testId,opacity:e.opacity,...r,children:[e.title===void 0?null:(0,k.jsx)(`title`,{children:e.title}),i,e.primitives.map((e,t)=>(0,k.jsx)(Lw,{primitive:e},t)),(e.groups??[]).map(e=>(0,k.jsx)(Rw,{group:e,interaction:t},e.id))]})}function zw(){let[e,t]=(0,d.useState)(void 0);return{hover:e=>({onPointerEnter:n=>t({text:e,x:n.clientX,y:n.clientY}),onPointerMove:n=>t({text:e,x:n.clientX,y:n.clientY}),onPointerLeave:()=>t(void 0)}),Tooltip:()=>e===void 0?null:(0,k.jsx)(`div`,{"data-testid":`diagram-tooltip`,role:`tooltip`,style:{position:`fixed`,left:e.x+14,top:e.y+14,zIndex:120},className:`pointer-events-none max-w-sm rounded bg-zinc-900 px-2 py-1 text-xs text-white shadow-lg dark:bg-zinc-100 dark:text-zinc-900`,children:e.text})}}function Bw({markers:e}){return(0,k.jsx)(`defs`,{children:e.map(e=>(0,k.jsx)(`marker`,{id:e.id,markerWidth:`7`,markerHeight:`7`,refX:`9`,refY:`5`,viewBox:`0 0 10 10`,markerUnits:`userSpaceOnUse`,orient:`auto`,children:(0,k.jsx)(`path`,{d:`M0,0 L10,5 L0,10 z`,fill:e.paint})},e.id))})}function Vw({data:e,isProposal:t,nudges:n,setNudges:r,hidden:i,setHidden:a}){let o=(0,d.useRef)(null),[s,c]=(0,d.useState)(void 0),[l,u]=(0,d.useState)(!1),{hover:f,Tooltip:p}=zw(),m=(0,d.useRef)(void 0);(0,d.useEffect)(()=>()=>m.current?.(),[]);let h=(0,d.useMemo)(()=>Ow(e,{isProposal:t,hidden:i,nudges:n}),[e,t,i,n]),g=e=>{if(e.button!==0)return;let t=e.target;if(t.closest(`[data-draggable="node"]`)!==null||t.closest(`[data-legend-entry]`)!==null)return;let n=o.current?.parentElement??null;for(;n!==null&&n.scrollWidth<=n.clientWidth&&n.scrollHeight<=n.clientHeight;)n=n.parentElement;if(n===null)return;e.preventDefault();let r=e.clientX,i=e.clientY,a=n.scrollLeft,s=n.scrollTop,c=e.currentTarget;c.setPointerCapture?.(e.pointerId),u(!0);let l=e=>{n.scrollLeft=a-(e.clientX-r),n.scrollTop=s-(e.clientY-i)},d=()=>{m.current=void 0,c.releasePointerCapture?.(e.pointerId),c.removeEventListener(`pointermove`,l),c.removeEventListener(`pointerup`,d),c.removeEventListener(`pointercancel`,d),u(!1)};m.current?.(),m.current=d,c.addEventListener(`pointermove`,l),c.addEventListener(`pointerup`,d),c.addEventListener(`pointercancel`,d)},_=e=>t=>{if(t.button!==0)return;t.preventDefault();let i=o.current,a=i===null?1:(i.getBoundingClientRect().width||h.width)/h.width,s=t.clientX,l=t.clientY,u=n.get(e)??{dx:0,dy:0},d=t.currentTarget;d.setPointerCapture?.(t.pointerId),c(e);let f=t=>{let i=new Map(n);i.set(e,{dx:u.dx+(t.clientX-s)/a,dy:u.dy+(t.clientY-l)/a}),r(i)},p=()=>{m.current=void 0,d.releasePointerCapture?.(t.pointerId),d.removeEventListener(`pointermove`,f),d.removeEventListener(`pointerup`,p),d.removeEventListener(`pointercancel`,p),c(void 0)};m.current?.(),m.current=p,d.addEventListener(`pointermove`,f),d.addEventListener(`pointerup`,p),d.addEventListener(`pointercancel`,p)},v=e=>{let t=new Set(i);t.delete(e)||t.add(e),a(t)},y=e=>{let t=e.data?.[`element-id`];if(e.data?.draggable===`node`&&t!==void 0)return{extra:{onPointerDown:_(t),style:{cursor:s===t?`grabbing`:`grab`},...e.title===void 0?{}:f(e.title)}};if(e.data?.[`relationship-role`]!==void 0){let t=e.primitives.find(e=>e.shape===`path`&&e.data?.edge===`line`);return{extra:e.title===void 0?{}:f(e.title),before:t===void 0||t.shape!==`path`?null:(0,k.jsx)(`path`,{"data-edge":`hit`,"data-hit":`edge`,d:t.d,fill:`none`,stroke:`transparent`,strokeWidth:14,pointerEvents:`stroke`})}}let n=e.data?.[`legend-entry`];if(n!==void 0&&e.data?.toggles===`true`){let t=e.primitives[0],r=t.shape===`rect`?t.x:t.shape===`line`?t.x1:0,i=t.shape===`rect`?t.y:t.shape===`line`?t.y1-5:0,a=e.primitives.find(e=>e.shape===`text`),o=a?.shape===`text`?bw(a.text.replace(` (hidden)`,``))-8:0;return{extra:{onClick:()=>v(n),style:{cursor:`pointer`}},before:(0,k.jsx)(`rect`,{"data-hit":`legend`,x:r-3,y:i-3,width:o,height:16,fill:`transparent`})}}return{}};return(0,k.jsxs)(k.Fragment,{children:[n.size>0&&(0,k.jsx)(`button`,{type:`button`,className:`mb-1 text-xs underline text-neutral-500 hover:text-neutral-800 dark:hover:text-neutral-200`,onClick:()=>r(new Map),children:`reset layout`}),(0,k.jsx)(p,{}),(0,k.jsxs)(`svg`,{ref:o,role:`img`,"aria-label":h.ariaLabel,viewBox:h.viewBox,width:h.width,height:h.height,xmlns:`http://www.w3.org/2000/svg`,onPointerDown:g,style:{cursor:l?`grabbing`:`grab`,touchAction:`none`},children:[(0,k.jsx)(`rect`,{x:Number(h.viewBox.split(` `)[0]),y:Number(h.viewBox.split(` `)[1]),width:h.width,height:h.height,fill:h.background}),(0,k.jsx)(Bw,{markers:h.markers}),h.groups.map(e=>(0,k.jsx)(Rw,{group:e,interaction:y},e.id))]})]})}function Hw({data:e,isProposal:t}){let{hover:n,Tooltip:r}=zw(),i=(0,d.useMemo)(()=>kw(e,{isProposal:t}),[e,t]);return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`svg`,{role:`img`,"aria-label":i.ariaLabel,viewBox:i.viewBox,width:i.width,height:i.height,xmlns:`http://www.w3.org/2000/svg`,children:[(0,k.jsx)(`rect`,{x:0,y:0,width:i.width,height:i.height,fill:i.background}),(0,k.jsx)(Bw,{markers:i.markers}),i.groups.map(e=>(0,k.jsx)(Rw,{group:e,interaction:e=>e.title===void 0?{}:{extra:n(e.title)}},e.id))]}),(0,k.jsx)(r,{})]})}var Uw={added:`bg-emerald-50 dark:bg-emerald-950/40`,changed:`bg-amber-50 dark:bg-amber-950/40`,context:`bg-zinc-50 text-zinc-500 dark:bg-zinc-900/60 dark:text-zinc-400`,removed:`bg-red-50 text-red-800 dark:bg-red-950/40 dark:text-red-200`},Ww=48,Gw=16;function Kw({data:e,hidden:t,setHidden:n}){let[r,i]=(0,d.useState)(null),a=(0,d.useRef)(null),o=(0,d.useCallback)(()=>[...a.current?.querySelectorAll(`th`)??[]].map(e=>Math.max(Ww,Math.round(e.getBoundingClientRect().width))),[]),s=(0,d.useCallback)((e,t)=>i(n=>{let r=n??o(),i=[...r];return i[e]=Math.max(Ww,Math.round(t(r[e]??Ww))),i}),[o]);function c(e,t){e.preventDefault();let n=e.clientX,a=r??o();i(a);let c=e=>{let r=a[t]??Ww;s(t,()=>r+(e.clientX-n))},l=()=>{window.removeEventListener(`pointermove`,c),window.removeEventListener(`pointerup`,l),window.removeEventListener(`pointercancel`,l)};window.addEventListener(`pointermove`,c),window.addEventListener(`pointerup`,l),window.addEventListener(`pointercancel`,l)}let l=r?.reduce((e,t)=>e+t,0),u=(e,t,n)=>(0,k.jsx)(`div`,{role:n?`separator`:`presentation`,"aria-orientation":n?`vertical`:void 0,"aria-label":n?`Resize column ${t}`:void 0,"aria-hidden":!n||void 0,tabIndex:n?0:void 0,onPointerDown:t=>c(t,e),onKeyDown:t=>{if(t.key!==`ArrowLeft`&&t.key!==`ArrowRight`)return;t.preventDefault();let n=t.key===`ArrowRight`?Gw:-16;s(e,e=>e+n)},className:`absolute -right-px top-0 h-full w-1.5 cursor-col-resize touch-none hover:bg-zinc-400 focus:bg-zinc-400 focus:outline-none dark:hover:bg-zinc-500 dark:focus:bg-zinc-500`}),f=bC(e),p=SC(e),m=e.rows.filter(e=>{let n=xC(e,f);return n===void 0||!t.has(zC(`role`,n))}),h=e=>{let r=new Set(t),i=zC(`role`,e);r.has(i)?r.delete(i):r.add(i),n(r)};return(0,k.jsxs)(`div`,{className:`overflow-x-auto`,children:[p.length>0&&(0,k.jsx)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2 text-[11px]`,"data-testid":`table-role-key`,children:p.map(e=>{let n=t.has(zC(`role`,e));return(0,k.jsxs)(`button`,{type:`button`,onClick:()=>h(e),"aria-pressed":!n,className:`flex items-center gap-1 rounded border border-zinc-300 px-1.5 py-0.5 dark:border-zinc-700 ${n?`opacity-50`:``}`,children:[(0,k.jsx)(`span`,{className:`inline-block h-2.5 w-2.5 rounded-sm ${Uw[e].split(` `)[0]}`}),(0,k.jsxs)(`span`,{children:[vC[e],n?` (hidden)`:``]})]},e)})}),(0,k.jsxs)(`table`,{className:`border-collapse text-xs ${r?``:`w-full`}`,style:l===void 0?void 0:{tableLayout:`fixed`,width:l},children:[(0,k.jsx)(`colgroup`,{children:e.columns.map((e,t)=>(0,k.jsx)(`col`,{style:r?{width:r[t]}:void 0},t))}),(0,k.jsx)(`thead`,{children:(0,k.jsx)(`tr`,{ref:a,children:e.columns.map((e,t)=>(0,k.jsxs)(`th`,{className:`relative border border-zinc-300 px-2 py-1 text-left font-medium dark:border-zinc-700`,children:[(0,k.jsx)(`span`,{className:`block truncate`,children:e}),u(t,e,!0)]},t))})}),(0,k.jsx)(`tbody`,{children:m.map((t,n)=>{let{cells:r}=bv(t),i=xC(t,f);return(0,k.jsx)(`tr`,{className:i===void 0?void 0:Uw[i],"data-row-role":i,children:r.map((t,n)=>(0,k.jsxs)(`td`,{className:`relative border border-zinc-200 px-2 py-1 align-top break-words dark:border-zinc-800 ${i===`removed`?`line-through`:``}`,children:[t===null?(0,k.jsx)(`span`,{className:`opacity-40`,children:`—`}):String(t),u(n,e.columns[n]??``,!1)]},n))},n)})})]})]})}function qw(e,t){if(e===void 0)return JSON.stringify(t,null,2);try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Jw(e,t,n=BC){let r=NC(e,t),i=[];if(r.columns!==void 0&&r.rows!==void 0){let e=e=>e!==void 0&&n.has(zC(`role`,e)),t=r.rows.filter(t=>e(t.role));t.length>0&&(i.push(`Filtered view — ${t.length} of ${r.rows.length} rows hidden (${[...new Set(t.map(e=>vC[e.role]))].join(`, `)}).`),i.push(``)),i.push(r.columns.join(` | `));for(let t of r.rows){if(e(t.role))continue;let n=t.cells.map(e=>e===null?``:String(e)).join(` | `);i.push(t.role===void 0?n:`${n} (${vC[t.role]})`)}}else{if(i.push([`${r.things.length} ${r.thingNoun}s`,`${r.links.length} ${r.linkNoun}s`,...r.containers.length>0?[`${r.containers.length} containers`]:[]].join(`, `)),i.push(``),r.containers.length>0){for(let e of r.containers){let t=r.things.filter(t=>t.container===e.id);i.push(`${e.label}: ${t.length===0?`no members`:t.map(e=>e.label).join(`, `)}`)}i.push(``)}let e=new Map(r.containers.map(e=>[e.id,e.label]));for(let t of r.things){let n=t.container===void 0?void 0:e.get(t.container);i.push([t.label,t.kind===void 0?``:` [${t.kind}]`,n===void 0?``:` in ${n}`,t.role===`unchanged`?``:` (${_C[t.role]})`,t.changes.length===0?``:` — ${t.changes.map(pC).join(`, `)}`].join(``))}r.links.length>0&&i.push(``),r.links.forEach((e,t)=>{let n=[e.kind,e.label].filter(e=>e!==void 0&&e!==``),a=n.length===0?`→`:`—${n.join(`: `)}→`;i.push([r.linkNoun===`message`?`${t+1}. `:``,`${e.fromLabel} ${a} ${e.toLabel}`,e.isLoop?` (to itself)`:``,e.role===`unchanged`?``:` (${_C[e.role]})`,e.changes.length===0?``:` — ${e.changes.map(pC).join(`, `)}`].join(``))})}if(r.removals.length>0){i.push(``);for(let e of r.removals)i.push(`removed ${e.type}: ${e.ref}`)}return i.join(`
|
|
317
|
-
`)}function Yw(e,t){let n=e=>{if(e===void 0)return;let n=t.data,r=[...n.nodes??[],...n.participants??[]].find(t=>t.id===e||t.ref===e);return r===void 0?e:PC(r)},r=t.data,i=[...r.nodes??[],...r.participants??[],...r.edges??[],...r.messages??[]].find(t=>`ref`in t&&t.ref===e.ref),a=e.from!==void 0||e.to!==void 0?`${n(e.from)??`?`} → ${n(e.to)??`?`}`:i!==void 0&&`from`in i?`${n(i.from)} → ${n(i.to)}`:void 0,o=e.label??(i===void 0?void 0:i.label),s=e.kind??(i===void 0?void 0:i.kind),c=[o,s===void 0?void 0:`[${s}]`,a].filter(e=>e!==void 0&&e!==``);return c.length===0?e.ref:`${c.join(` `)} (${e.ref})`}var Xw=`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200`;function Zw({envelope:e,source:t,rawOutput:n}){let[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)(!1),[m,h]=(0,d.useState)(null),g=(0,d.useRef)(null),_=(0,d.useRef)(null),[v,y]=(0,d.useState)(new Map),[b,x]=(0,d.useState)(BC),S=(0,d.useMemo)(()=>FC(e),[e]),C=e.target!==void 0,w=e.removals??[],T=e.kind===`graph`?(0,k.jsx)(Vw,{data:e.data,isProposal:C,nudges:v,setNudges:y,hidden:b,setHidden:x}):e.kind===`sequence`?(0,k.jsx)(Hw,{data:e.data,isProposal:C}):(0,k.jsx)(Kw,{data:e.data,hidden:b,setHidden:x}),E=`${e.kind}-${e.target??`diagram`}.svg`.replace(/[^\w.-]+/g,`-`),ee=`${e.kind}-${e.target??`data`}`.replace(/[^\w.-]+/g,`-`),D=()=>jw(e.data,b),O=e.kind===`table`?D().withheld:0;function te(e){let t=e.cloneNode(!0);for(let e of t.querySelectorAll(`[data-hit]`))e.remove();for(let e of[t,...t.querySelectorAll(`[style]`)])e.style.removeProperty(`cursor`),e.style.removeProperty(`touch-action`),e.getAttribute(`style`)===``&&e.removeAttribute(`style`);return t}function ne(){let e=(_.current??g.current)?.querySelector(`svg`);return e?new XMLSerializer().serializeToString(te(e)):void 0}function re(){let e=ne();if(e===void 0)return;let t=URL.createObjectURL(new Blob([e],{type:`image/svg+xml`})),n=document.createElement(`a`);n.href=t,n.download=E,n.click(),URL.revokeObjectURL(t),h(`SVG downloaded`),window.setTimeout(()=>h(null),2500)}async function ie(){let e=ne();if(e!==void 0){try{await navigator.clipboard.writeText(e),h(`SVG markup copied`)}catch{h(`could not copy`)}window.setTimeout(()=>h(null),2500)}}return(0,k.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[C&&(0,k.jsxs)(`p`,{className:`text-xs text-zinc-500`,"data-testid":`structured-proposal-note`,children:[`Proposed changes to `,(0,k.jsx)(`span`,{className:`font-mono`,children:e.target}),`. Anything not mentioned is left as it is; anything shown without a change is here for context.`]}),b.size>0&&(0,k.jsxs)(`p`,{"data-testid":`structured-filtered`,className:`flex flex-wrap items-center gap-2 rounded border border-amber-300 bg-amber-50 px-2 py-1 text-xs text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200`,children:[(0,k.jsxs)(`span`,{children:[`Filtered view — `,[...b].map(e=>e.replace(/^(element|relationship|role):/,``)).join(`, `),` hidden.`,` `,C?`The full proposal still applies.`:``]}),(0,k.jsx)(`button`,{type:`button`,className:`underline`,onClick:()=>x(new Set),children:`show everything`})]}),(0,k.jsx)(`div`,{ref:g,className:`overflow-x-auto`,children:T}),(0,k.jsx)(ve,{label:`${e.kind} view`,open:r,onClose:()=>i(!1),containerRef:_,anchorRef:g,actions:e.kind!==`table`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,onClick:re,className:Xw,children:`⤓ download SVG`}),(0,k.jsx)(`button`,{type:`button`,onClick:ie,className:Xw,children:`copy markup`}),m!==null&&(0,k.jsx)(`span`,{className:`text-xs text-zinc-500`,children:m})]}),children:T}),w.length>0&&(0,k.jsx)(`ul`,{className:`space-y-1`,"data-testid":`structured-removals`,children:w.map((t,n)=>(0,k.jsxs)(`li`,{"data-relationship-role":`removed`,className:`rounded border border-red-300 bg-red-50 px-2 py-1 text-xs text-red-800 dark:border-red-800 dark:bg-red-950/40 dark:text-red-200`,children:[(0,k.jsx)(`span`,{className:`line-through`,children:Yw(t,e)}),Yw(t,e)===t.ref&&(0,k.jsx)(`span`,{className:`ml-2 not-italic opacity-70`,"data-testid":`removal-undescribed`,children:`— the proposal does not say what this is`}),(0,k.jsx)(`span`,{className:`ml-2 font-mono opacity-60`,children:t.type})]},n))}),(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-xs`,children:[(0,k.jsx)(`button`,{type:`button`,className:`text-zinc-500 underline`,"aria-label":`Show ${e.kind} view at full size`,onClick:()=>i(!0),children:`⤢ enlarge`}),e.kind===`table`?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,className:`text-zinc-500 underline`,title:O===0?`Save as .csv — opens in any spreadsheet`:`Save as .csv — ${O} hidden rows are left out`,onClick:()=>Fw(D(),`${ee}.csv`),children:`⤓ download CSV`}),(0,k.jsx)(`button`,{type:`button`,className:`text-zinc-500 underline`,title:O===0?`Save as .xlsx — one sheet, values typed as they are declared`:`Save as .xlsx — ${O} hidden rows are left out`,onClick:()=>void Iw(D(),`${ee}.xlsx`),children:`⤓ download XLSX`}),O>0&&(0,k.jsxs)(`span`,{className:`text-xs text-amber-700 dark:text-amber-300`,"data-testid":`table-export-narrowed`,children:[`exports `,O,` rows fewer than the table declares`]})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,className:`text-zinc-500 underline`,title:`Save as .svg — insert it as a picture in a document`,onClick:re,children:`⤓ download SVG`}),(0,k.jsx)(`button`,{type:`button`,className:`text-zinc-500 underline`,title:`Copy the SVG markup, for somewhere that takes it directly`,onClick:()=>void ie(),children:`copy markup`})]}),(0,k.jsxs)(`button`,{type:`button`,className:`text-zinc-500 underline`,onClick:()=>o(e=>!e),children:[a?`hide`:`show`,` text equivalent`]}),S!==void 0&&(0,k.jsxs)(`button`,{type:`button`,className:`text-zinc-500 underline`,onClick:()=>c(e=>!e),children:[s?`hide`:`show`,` derived diagram syntax`]}),(0,k.jsxs)(`button`,{type:`button`,className:`text-zinc-500 underline`,onClick:()=>p(e=>!e),children:[f?`hide`:`show`,` envelope`]}),n!==void 0&&(0,k.jsxs)(`button`,{type:`button`,className:`text-zinc-500 underline`,onClick:()=>u(e=>!e),children:[l?`hide`:`show`,` original output`]}),m!==null&&(0,k.jsx)(`span`,{role:`status`,className:`text-emerald-600 dark:text-emerald-400`,children:m})]}),a&&(0,k.jsx)(`pre`,{"data-testid":`structured-text-equivalent`,className:`overflow-x-auto rounded bg-zinc-100 p-2 text-xs dark:bg-zinc-800`,children:Jw(e,C,b)}),s&&S!==void 0&&(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`p`,{className:`mb-1 text-[11px] text-zinc-500`,children:`Derived from the structured data above. It is an export, not the source.`}),(0,k.jsx)(`pre`,{"data-testid":`structured-derived-export`,className:`overflow-x-auto rounded bg-zinc-100 p-2 text-xs dark:bg-zinc-800`,children:S})]}),f&&(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`p`,{className:`mb-1 text-[11px] text-zinc-500`,children:`The validated document this view is drawn from. It is not sent to the model.`}),(0,k.jsx)(`pre`,{"data-testid":`structured-envelope`,className:`max-h-80 overflow-auto rounded bg-zinc-100 p-2 text-xs dark:bg-zinc-800`,children:t})]}),l&&n!==void 0&&(0,k.jsx)(`pre`,{"data-testid":`structured-raw-output`,className:`overflow-x-auto rounded bg-zinc-100 p-2 text-xs dark:bg-zinc-800`,children:n})]})}function Qw({item:e}){let t=$C(e.structured);return t===void 0?null:(0,k.jsx)(Zw,{envelope:t,source:qw(e.structured,t),rawOutput:e.output})}var $w=[Z_,{id:`structured-exchange`,match:e=>$C(e.structured)!==void 0,stable:!1,showsRawReveal:!0,startsExpanded:!0,Expanded:Qw},$_,tv,dv,vv,nv,rv,X_];function eT(e){for(let t of $w){let n=!1;try{n=t.match(e)}catch{n=!1}if(n)return t}return X_}function tT(e,t){let n=eT(e);if(t===void 0||t===n.id)return n;let r=$w.find(e=>e.id===t);if(r===void 0||r.id===X_.id||n.extensionOwned===!0)return n;let i=!1;try{i=r.match(e)}catch{i=!1}return i?r:n}function nT(e){if(typeof e!=`object`||!e)return``;let t=e,n=[`command`,`path`,`file_path`,`pattern`,`query`].find(e=>typeof t[e]==`string`);if(n)return t[n];let r=JSON.stringify(t);return r===`{}`?``:r}function rT({item:e,dispatch:t=U_}){let n=(0,d.useRef)(void 0),r=tT(e,n.current);n.current=r.id;let i=r.startsExpanded===!0,[a,o]=(0,d.useState)(i);(0,d.useEffect)(()=>{o(i)},[i]);let[s,c]=(0,d.useState)(!1),l=nT(e.args),u=r.Collapsed,f=!a&&u!==void 0&&(r.hasCollapsed?.(e)??!0);return(0,k.jsxs)(`div`,{className:`rounded-lg border text-sm ${e.isError?`border-red-300 bg-red-50 dark:border-red-900/60 dark:bg-red-950/20`:`border-zinc-200 bg-zinc-50 dark:border-zinc-800 dark:bg-zinc-900/60`}`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>o(!a),className:`flex w-full items-center gap-2 px-3 py-2 text-left`,children:[(0,k.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${e.running?`animate-pulse motion-reduce:animate-none bg-amber-400`:e.isError?`bg-red-500`:`bg-emerald-500`}`}),e.callHtml?(0,k.jsx)(Ee,{as:`span`,html:e.callHtml,className:`min-w-0 flex-1 text-zinc-700 dark:text-zinc-300`}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{className:`font-mono font-medium text-zinc-700 dark:text-zinc-300`,children:e.toolName}),l&&(0,k.jsx)(`span`,{className:`truncate font-mono text-xs text-zinc-500`,children:l})]}),(0,k.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-600`,children:a?`▾`:`▸`})]}),f&&u!==void 0&&(0,k.jsx)(`div`,{className:`border-t border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:(0,k.jsx)(u,{item:e,dispatch:t})}),a&&(0,k.jsxs)(`div`,{className:`border-t border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,k.jsx)(r.Expanded,{item:e,dispatch:t}),r.showsRawReveal===!0&&(0,k.jsxs)(`div`,{className:`mt-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>c(!s),className:`text-xs text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-400`,children:s?`hide raw output`:`raw output`}),s&&(0,k.jsx)(`div`,{className:`mt-1`,children:(0,k.jsx)(Y_,{item:e})})]})]})]})}function iT({item:e}){let[t,n]=(0,d.useState)(!1),r=e.details!==void 0,i=!!e.contentHtml,a=e.contentHtmlCollapsed??e.contentHtml,o=r||i&&!!e.contentHtmlCollapsed;return(0,k.jsxs)(`div`,{className:`rounded-lg border border-violet-200 bg-violet-50 px-3 py-2 text-sm dark:border-violet-900/60 dark:bg-violet-950/30`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(`span`,{className:`font-mono text-xs font-bold text-violet-700 dark:text-violet-300`,children:[`[`,e.customType,`]`]}),o&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>n(!t),title:`Show details`,className:`ml-auto text-xs text-violet-500 hover:text-violet-700 dark:text-violet-500 dark:hover:text-violet-300`,children:t?`▾`:`▸`})]}),i&&a?(0,k.jsx)(Ee,{html:t||!e.contentHtmlCollapsed?e.contentHtml??a:a,className:`mt-1 text-violet-950 dark:text-violet-100`}):(0,k.jsx)(`div`,{className:`prose-chat mt-1 text-violet-950 dark:text-violet-100`,children:(0,k.jsx)(hs,{remarkPlugins:[T_,L_],rehypePlugins:[Tm],children:T(e.text)})}),t&&r&&(0,k.jsx)(`pre`,{className:`mt-2 max-h-96 overflow-auto border-t border-violet-200 pt-2 font-mono text-xs text-violet-600 dark:border-violet-900/60 dark:text-violet-400`,children:JSON.stringify(e.details,null,2)})]})}var aT={cost:0,unpriced:0,turns:0,input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0};function oT(e){let t={...aT};for(let n of e){if(n.kind!==`assistant`||!n.usage)continue;let e=n.usage;t.turns+=1,t.input+=e.input,t.output+=e.output,t.cacheRead+=e.cacheRead,t.cacheWrite+=e.cacheWrite,t.totalTokens+=e.totalTokens,e.cost===void 0?t.unpriced+=1:t.cost+=e.cost}return t}function sT(e){let t=e>0&&e<.01?4:2;return`$${e.toFixed(t)}`}function cT(e){return e<1e3?String(e):e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1)}M`}var lT=80,uT=new WeakMap;function dT(e){let t=typeof e==`object`&&!!e;if(t){let t=uT.get(e);if(t!==void 0)return t}let n=0;try{n=JSON.stringify(e)?.length??0}catch{n=0}return t&&uT.set(e,n),n}function fT(e){let t=e.replace(/\s+/g,` `).trim();return t.length>lT?`${t.slice(0,79)}…`:t}function pT(e,t){return{index:e,title:t,turns:0,toolCalls:0,failedToolCalls:0,input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,unpriced:0}}function mT(e,t){e.turns+=1,e.input+=t.input,e.output+=t.output,e.cacheRead+=t.cacheRead,e.cacheWrite+=t.cacheWrite,e.totalTokens+=t.totalTokens,t.cost===void 0?e.unpriced+=1:e.cost=(e.cost??0)+t.cost}function hT(e){if(e.length===0)return 0;let t=[...e].sort((e,t)=>e-t),n=Math.floor(t.length/2);return t.length%2==1?t[n]:(t[n-1]+t[n])/2}function gT(e){let t=[],n=[],r=[],i=new Map,a=pT(-1,``),o=a;e.forEach((e,a)=>{if(e.kind===`user`){o=pT(a,fT(e.text)),r.push(o);return}if(e.kind===`assistant`){if(!e.usage)return;t.push({index:a,number:t.length+1,requestIndex:o.index,usage:e.usage}),mT(o,e.usage);return}if(e.kind!==`tool`)return;let s={index:a,toolCallId:e.toolCallId,name:e.toolName,inputSize:dT(e.args),outputSize:e.output.length,isError:e.isError===!0,running:e.running===!0,requestIndex:o.index};n.push(s),o.toolCalls+=1,s.isError&&(o.failedToolCalls+=1);let c=i.get(s.name)??{name:s.name,calls:0,failures:0,inputSize:0,outputSize:0};c.calls+=1,s.isError&&(c.failures+=1),c.inputSize+=s.inputSize,c.outputSize+=s.outputSize,i.set(s.name,c)}),(a.turns>0||a.toolCalls>0)&&r.unshift(a);let s=oT(e),c=t.map(e=>e.usage.cost).filter(e=>e!==void 0),l=n.filter(e=>e.isError).length;return{turns:t,requests:r,toolCalls:n,tools:[...i.values()],totals:s,pricedTurns:c.length,averageTurnCost:c.length===0?0:s.cost/c.length,medianTurnCost:hT(c),totalToolCalls:n.length,failedToolCalls:l,toolCallsPerTurn:t.length===0?0:n.length/t.length}}function _T(e,t){let n=[...e];return t===`input`?n.sort((e,t)=>t.inputSize-e.inputSize):t===`failure`?n.sort((e,t)=>Number(t.isError)-Number(e.isError)||t.outputSize-e.outputSize):n.sort((e,t)=>t.outputSize-e.outputSize)}function vT(e){return e.filter(e=>e.index>=0).sort((e,t)=>t.totalTokens-e.totalTokens||(t.cost??0)-(e.cost??0))}function yT(e){return e<1e3?`${e} B`:e<1e6?`${Math.round(e/1e3)} kB`:`${(e/1e6).toFixed(1)} MB`}var bT=768,xT=26,ST=132,CT=12,wT=96,TT=124,ET=[{key:`input`,label:`input`,className:`text-emerald-500`,value:e=>e.usage.input},{key:`output`,label:`output`,className:`text-blue-500`,value:e=>e.usage.output},{key:`cacheRead`,label:`cache read`,className:`text-violet-500`,value:e=>e.usage.cacheRead},{key:`cacheWrite`,label:`cache write`,className:`text-amber-500`,value:e=>e.usage.cacheWrite}],DT=[{key:`cost`,label:`cost`,className:`text-rose-500`,value:e=>e.usage.cost??0}];function OT({title:e,children:t}){return(0,k.jsxs)(`section`,{className:`border-t border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:[(0,k.jsx)(`h3`,{className:`mb-2 font-mono text-[11px] uppercase tracking-wide text-zinc-400 dark:text-zinc-500`,children:e}),t]})}function kT({children:e}){return(0,k.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:e})}function AT({label:e,value:t,hint:n}){return(0,k.jsxs)(`div`,{className:`rounded-md border border-zinc-200 px-2 py-1.5 dark:border-zinc-800`,children:[(0,k.jsx)(`div`,{"aria-label":`${e}: ${t}`,className:`font-mono text-sm text-zinc-700 dark:text-zinc-200`,children:t}),(0,k.jsx)(`div`,{className:`text-[11px] text-zinc-500 dark:text-zinc-400`,children:e}),n&&(0,k.jsx)(`div`,{className:`text-[10px] text-zinc-400 dark:text-zinc-500`,children:n})]})}function jT({turns:e,series:t,format:n,onJump:r,describe:i}){let a=Math.max(1,...e.flatMap(e=>t.map(t=>t.value(e)))),o=Math.max(e.length*xT,xT),s=e=>xT/2+e*xT,c=e=>CT+wT*(1-e/a);return(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`mb-1 flex flex-wrap gap-x-3 gap-y-1`,children:t.map(e=>(0,k.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-zinc-500 dark:text-zinc-400`,children:[(0,k.jsx)(`span`,{className:`inline-block h-0.5 w-3 bg-current ${e.className}`}),e.label]},e.key))}),(0,k.jsxs)(`div`,{className:`flex`,children:[(0,k.jsxs)(`div`,{"aria-hidden":!0,className:`flex w-12 shrink-0 flex-col justify-between py-2 pr-1 text-right font-mono text-[9px] text-zinc-400 dark:text-zinc-600`,style:{height:ST},children:[(0,k.jsx)(`span`,{children:n(a)}),(0,k.jsx)(`span`,{children:`0`})]}),(0,k.jsx)(`div`,{className:`min-w-0 flex-1 overflow-x-auto`,children:(0,k.jsxs)(`svg`,{width:o,height:ST,role:`group`,"aria-label":`Per-turn chart`,children:[(0,k.jsx)(`line`,{x1:0,x2:o,y1:108,y2:108,stroke:`currentColor`,className:`text-zinc-200 dark:text-zinc-800`}),t.map(t=>(0,k.jsx)(`polyline`,{fill:`none`,stroke:`currentColor`,strokeWidth:1.5,className:t.className,points:e.map((e,n)=>`${s(n)},${c(t.value(e))}`).join(` `)},t.key)),e.map((n,a)=>(0,k.jsxs)(`g`,{children:[t.map(e=>(0,k.jsx)(`circle`,{cx:s(a),cy:c(e.value(n)),r:2,fill:`currentColor`,className:e.className},e.key)),(0,k.jsx)(`rect`,{x:s(a)-xT/2,y:0,width:xT,height:ST,fill:`transparent`,role:`button`,tabIndex:0,"aria-label":`Turn ${n.number}: ${i(n)} — jump to it`,className:`cursor-pointer outline-none focus-visible:fill-zinc-500/10`,onClick:()=>r(n.index),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r(n.index))},children:(0,k.jsx)(`title`,{children:`turn ${n.number} · ${i(n)}`})}),(e.length<=12||n.number%5==0)&&(0,k.jsx)(`text`,{x:s(a),y:TT,textAnchor:`middle`,className:`fill-zinc-400 text-[9px] dark:fill-zinc-600`,children:n.number})]},n.index))]})})]})]})}function MT({onJump:e,label:t,children:n}){return(0,k.jsx)(`button`,{type:`button`,onClick:e,"aria-label":t,className:`flex w-full items-baseline gap-2 rounded-md px-2 py-1 text-left text-xs hover:bg-zinc-100 dark:hover:bg-zinc-900`,children:n})}function NT({analysis:e,onJump:t,onClose:n}){let[r,i]=(0,d.useState)(`output`),{totals:a}=e;function o(e){t(e),window.innerWidth<bT&&n()}let s=e.turns.length===0&&e.toolCalls.length===0,c=_T(e.toolCalls,r),l=vT(e.requests);return(0,k.jsxs)(`aside`,{"aria-label":`Session analysis`,className:`absolute inset-y-0 right-0 z-10 w-full overflow-y-auto border-l border-zinc-200 bg-white shadow-xl md:w-[26rem] dark:border-zinc-800 dark:bg-zinc-950`,children:[(0,k.jsxs)(`header`,{className:`sticky top-0 flex items-center gap-2 border-b border-zinc-200 bg-white px-4 py-2 dark:border-zinc-800 dark:bg-zinc-950`,children:[(0,k.jsx)(`h2`,{className:`font-mono text-xs text-zinc-600 dark:text-zinc-300`,children:`session analysis`}),(0,k.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close session analysis`,className:`ml-auto rounded-md px-2 py-1 text-sm text-zinc-500 hover:bg-zinc-100 dark:text-zinc-400 dark:hover:bg-zinc-900`,children:`×`})]}),s?(0,k.jsx)(`div`,{className:`px-4 py-6`,children:(0,k.jsx)(kT,{children:`Nothing to analyse yet — no turn has reported figures and no tool has been called.`})}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(OT,{title:`tokens`,children:(0,k.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,k.jsx)(AT,{label:`total`,value:cT(a.totalTokens)}),(0,k.jsx)(AT,{label:`fresh input`,value:cT(a.input)}),(0,k.jsx)(AT,{label:`output`,value:cT(a.output)}),(0,k.jsx)(AT,{label:`cache read`,value:cT(a.cacheRead)}),(0,k.jsx)(AT,{label:`cache write`,value:cT(a.cacheWrite)}),(0,k.jsx)(AT,{label:`turns`,value:String(e.turns.length)})]})}),(0,k.jsx)(OT,{title:`cost`,children:e.pricedTurns===0?(0,k.jsx)(kT,{children:`No turn was priced — this provider reports tokens only.`}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,k.jsx)(AT,{label:`total`,value:sT(a.cost)}),(0,k.jsx)(AT,{label:`average turn`,value:sT(e.averageTurnCost)}),(0,k.jsx)(AT,{label:`median turn`,value:sT(e.medianTurnCost)})]}),(0,k.jsxs)(`p`,{className:`mt-1 text-[11px] text-zinc-400 dark:text-zinc-500`,children:[`over `,e.pricedTurns,` priced turn`,e.pricedTurns===1?``:`s`,a.unpriced>0&&`, ${a.unpriced} unpriced`]})]})}),(0,k.jsx)(OT,{title:`tool calls`,children:e.totalToolCalls===0?(0,k.jsx)(kT,{children:`No tool call recorded in this session.`}):(0,k.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,k.jsx)(AT,{label:`calls`,value:String(e.totalToolCalls)}),(0,k.jsx)(AT,{label:`per turn`,value:e.toolCallsPerTurn.toFixed(1)}),(0,k.jsx)(AT,{label:`failed`,value:String(e.failedToolCalls)})]})}),(0,k.jsx)(OT,{title:`tokens per turn`,children:e.turns.length===0?(0,k.jsx)(kT,{children:`No turn has reported figures yet.`}):(0,k.jsx)(jT,{turns:e.turns,series:ET,format:cT,onJump:o,describe:e=>`${cT(e.usage.totalTokens)} tokens (input ${e.usage.input}, output ${e.usage.output}, cache read ${e.usage.cacheRead}, cache write ${e.usage.cacheWrite})`})}),(0,k.jsx)(OT,{title:`cost per turn`,children:e.pricedTurns===0?(0,k.jsx)(kT,{children:`No turn was priced, so there is no cost to plot.`}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(jT,{turns:e.turns.filter(e=>e.usage.cost!==void 0),series:DT,format:sT,onJump:o,describe:e=>sT(e.usage.cost??0)}),a.unpriced>0&&(0,k.jsxs)(`p`,{className:`mt-1 text-[10px] text-zinc-400 dark:text-zinc-500`,children:[a.unpriced,` unpriced turn`,a.unpriced===1?``:`s`,` left out — they carry no price to plot`]})]})}),(0,k.jsx)(OT,{title:`costliest tool calls`,children:c.length===0?(0,k.jsx)(kT,{children:`No tool call recorded in this session.`}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`mb-1 flex items-center gap-2`,children:[(0,k.jsx)(`label`,{htmlFor:`tool-ranking`,className:`text-[11px] text-zinc-500 dark:text-zinc-400`,children:`rank by`}),(0,k.jsxs)(`select`,{id:`tool-ranking`,value:r,onChange:e=>i(e.target.value),className:`rounded-md border border-zinc-300 bg-white px-1.5 py-0.5 font-mono text-[11px] text-zinc-600 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-300`,children:[(0,k.jsx)(`option`,{value:`output`,children:`output size`}),(0,k.jsx)(`option`,{value:`input`,children:`input size`}),(0,k.jsx)(`option`,{value:`failure`,children:`failure`})]})]}),(0,k.jsx)(`p`,{className:`mb-1 text-[10px] text-zinc-400 dark:text-zinc-500`,children:`measured content size, not tokens — a tool call carries no price`}),c.slice(0,10).map(e=>(0,k.jsxs)(MT,{onJump:()=>o(e.index),label:`Jump to the ${e.name} call, output ${yT(e.outputSize)}`,children:[(0,k.jsx)(`span`,{className:`font-mono text-zinc-600 dark:text-zinc-300`,children:e.name}),e.isError&&(0,k.jsx)(`span`,{className:`text-red-500`,children:`failed`}),e.running&&(0,k.jsx)(`span`,{className:`text-zinc-400`,children:`running`}),(0,k.jsxs)(`span`,{className:`ml-auto font-mono text-zinc-500 dark:text-zinc-400`,children:[`in `,yT(e.inputSize),` · out `,yT(e.outputSize)]})]},e.toolCallId||`${e.index}`))]})}),(0,k.jsx)(OT,{title:`tools`,children:e.tools.length===0?(0,k.jsx)(kT,{children:`No tool has been called yet.`}):(0,k.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{className:`text-left text-[10px] uppercase text-zinc-400 dark:text-zinc-500`,children:[(0,k.jsx)(`th`,{className:`font-normal`,children:`tool`}),(0,k.jsx)(`th`,{className:`font-normal`,children:`calls`}),(0,k.jsx)(`th`,{className:`font-normal`,children:`failed`}),(0,k.jsx)(`th`,{className:`text-right font-normal`,children:`in / out`})]})}),(0,k.jsx)(`tbody`,{className:`font-mono text-zinc-600 dark:text-zinc-300`,children:[...e.tools].sort((e,t)=>t.outputSize-e.outputSize).map(e=>(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`td`,{children:e.name}),(0,k.jsx)(`td`,{children:e.calls}),(0,k.jsx)(`td`,{className:e.failures>0?`text-red-500`:``,children:e.failures}),(0,k.jsxs)(`td`,{className:`text-right`,children:[yT(e.inputSize),` / `,yT(e.outputSize)]})]},e.name))})]})}),(0,k.jsx)(OT,{title:`costliest requests`,children:l.length===0?(0,k.jsx)(kT,{children:`No request has consumed anything yet.`}):l.slice(0,10).map(e=>(0,k.jsxs)(MT,{onJump:()=>o(e.index),label:`Jump to the request "${e.title}"`,children:[(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-zinc-600 dark:text-zinc-300`,children:e.title}),(0,k.jsxs)(`span`,{className:`shrink-0 font-mono text-zinc-500 dark:text-zinc-400`,children:[cT(e.totalTokens),` tok`,e.cost!==void 0&&` · ${sT(e.cost)}`]}),(0,k.jsxs)(`span`,{className:`shrink-0 text-[10px] text-zinc-400 dark:text-zinc-500`,children:[e.turns,`t / `,e.toolCalls,`c`,e.failedToolCalls>0&&` · ${e.failedToolCalls}✗`]})]},e.index))})]})]})}var PT=2e3;function FT({items:e,scrollerRef:t,hideTools:n,onShowTools:r,stickToBottom:i}){let[a,o]=(0,d.useState)(null),s=(0,d.useRef)(null),[c,l]=(0,d.useState)(0),u=(0,d.useRef)(null);(0,d.useEffect)(()=>()=>{u.current&&clearTimeout(u.current)},[]);let f=(0,d.useCallback)(t=>{let i=e[t];i&&(i.kind===`tool`&&n&&r(),s.current=t,l(e=>e+1))},[e,n,r]);return(0,d.useEffect)(()=>{let e=s.current;if(e===null)return;s.current=null;let n=t.current?.querySelector(`[data-item-index="${e}"]`);n&&(i.current=!1,n.scrollIntoView?.({behavior:`smooth`,block:`center`}),o(e),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>o(null),PT))},[c,n,t,i]),{jumpToItem:f,highlightIndex:a}}var IT=`uploads`,LT=class extends Error{reason;constructor(e,t){super(e),this.name=`UploadError`,this.reason=t}};function RT(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result.split(`,`,2)[1]??``),r.onerror=()=>n(r.error),r.readAsDataURL(e)})}function zT(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function BT(e){return e.type.startsWith(`image/`)?`image`:e.type===`application/pdf`||ne(e.name)||re(e.name)?`extraction-tool`:e.size<=524288?`inline-text`:UT(e)&&e.size<=26214400?`extraction-tool`:`unsupported`}function VT(e){let t=BT(e);return t===`extraction-tool`||t===`image`&&e.size>7340032}var HT=new Set([`application/json`,`application/xml`,`application/javascript`,`application/x-yaml`,`application/yaml`,`application/sql`]);function UT(e){return e.type.startsWith(`text/`)||HT.has(e.type)}function WT(e){return UT(e)?`${e.name}: file too large to upload (max 25 MB)`:`${e.name}: unsupported file type${e.type?` (${e.type})`:``}`}function GT(e,t){return t instanceof LT?t.reason===`denied`?`${e.name}: cannot upload — the workspace is read-only`:t.reason===`too-large`?`${e.name}: file too large to upload (max 25 MB)`:t.reason===`invalid`?`${e.name}: ${t.message}`:`${e.name}: upload failed — ${t.message}`:`${e.name}: upload failed`}async function KT(e){let t;try{t=await e.text()}catch{return{attachments:[],errors:[`${e.name}: could not be read`]}}return t.includes(`\0`)?{attachments:[],errors:[`${e.name}: unsupported binary file`]}:{attachments:[{name:e.name,kind:`text`,data:t,mimeType:e.type||`text/plain`,source:`manual`}],errors:[]}}async function qT(e){try{let t=await RT(e);return{attachments:[{name:e.name,kind:`image`,data:t,mimeType:e.type,source:`manual`}],errors:[]}}catch{return{attachments:[],errors:[`${e.name}: could not be read`]}}}async function JT(e,t){if(e.size>26214400)return{attachments:[],errors:[`${e.name}: file too large to upload (max 25 MB)`]};let n;try{n=await RT(e)}catch{return{attachments:[],errors:[`${e.name}: could not be read`]}}try{return{attachments:[iE(await t(e.name,n))],errors:[]}}catch(t){return{attachments:[],errors:[GT(e,t)]}}}async function YT(e,t){let n=await Promise.all([...e].map(e=>{let n=BT(e);return n===`unsupported`?Promise.resolve({attachments:[],errors:[WT(e)]}):n===`inline-text`?KT(e):n===`image`&&e.size<=7340032?qT(e):JT(e,t)}));return{attachments:n.flatMap(e=>e.attachments),errors:n.flatMap(e=>e.errors)}}function XT(e){return{...iE(e),source:`preview`,previewPath:e}}function ZT(e){return XT(e)}function QT(e,t){let n=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return RegExp(`(^|\\s)@${n}[,.;:!?)\\]]*(\\s|$)`).test(e)}var $T=new Set([`,`,`.`,`;`,`:`,`!`,`?`,`)`,`]`]);function eE(e){let t=e.length;for(;t>0&&$T.has(e[t-1]);)t--;return e.slice(0,t)}function tE(e){return[...e.matchAll(/(?:^|\s)@([^\s@]+)/g)].map(([,e])=>eE(e)).filter(e=>e.length>0)}function nE(e,t){let n=e.trim(),r=e=>{n+=`${n?`
|
|
317
|
+
`)}function Yw(e,t){let n=e=>{if(e===void 0)return;let n=t.data,r=[...n.nodes??[],...n.participants??[]].find(t=>t.id===e||t.ref===e);return r===void 0?e:PC(r)},r=t.data,i=[...r.nodes??[],...r.participants??[],...r.edges??[],...r.messages??[]].find(t=>`ref`in t&&t.ref===e.ref),a=e.from!==void 0||e.to!==void 0?`${n(e.from)??`?`} → ${n(e.to)??`?`}`:i!==void 0&&`from`in i?`${n(i.from)} → ${n(i.to)}`:void 0,o=e.label??(i===void 0?void 0:i.label),s=e.kind??(i===void 0?void 0:i.kind),c=[o,s===void 0?void 0:`[${s}]`,a].filter(e=>e!==void 0&&e!==``);return c.length===0?e.ref:`${c.join(` `)} (${e.ref})`}var Xw=`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200`;function Zw({envelope:e,source:t,rawOutput:n}){let[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)(!1),[m,h]=(0,d.useState)(null),g=(0,d.useRef)(null),_=(0,d.useRef)(null),[v,y]=(0,d.useState)(new Map),[b,x]=(0,d.useState)(BC),S=(0,d.useMemo)(()=>FC(e),[e]),C=e.target!==void 0,w=e.removals??[],T=e.kind===`graph`?(0,k.jsx)(Vw,{data:e.data,isProposal:C,nudges:v,setNudges:y,hidden:b,setHidden:x}):e.kind===`sequence`?(0,k.jsx)(Hw,{data:e.data,isProposal:C}):(0,k.jsx)(Kw,{data:e.data,hidden:b,setHidden:x}),E=`${e.kind}-${e.target??`diagram`}.svg`.replace(/[^\w.-]+/g,`-`),ee=`${e.kind}-${e.target??`data`}`.replace(/[^\w.-]+/g,`-`),D=()=>jw(e.data,b),O=e.kind===`table`?D().withheld:0;function te(e){let t=e.cloneNode(!0);for(let e of t.querySelectorAll(`[data-hit]`))e.remove();for(let e of[t,...t.querySelectorAll(`[style]`)])e.style.removeProperty(`cursor`),e.style.removeProperty(`touch-action`),e.getAttribute(`style`)===``&&e.removeAttribute(`style`);return t}function ne(){let e=(_.current??g.current)?.querySelector(`svg`);return e?new XMLSerializer().serializeToString(te(e)):void 0}function re(){let e=ne();if(e===void 0)return;let t=URL.createObjectURL(new Blob([e],{type:`image/svg+xml`})),n=document.createElement(`a`);n.href=t,n.download=E,n.click(),URL.revokeObjectURL(t),h(`SVG downloaded`),window.setTimeout(()=>h(null),2500)}async function ie(){let e=ne();if(e!==void 0){try{await navigator.clipboard.writeText(e),h(`SVG markup copied`)}catch{h(`could not copy`)}window.setTimeout(()=>h(null),2500)}}return(0,k.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[C&&(0,k.jsxs)(`p`,{className:`text-xs text-zinc-500`,"data-testid":`structured-proposal-note`,children:[`Proposed changes to `,(0,k.jsx)(`span`,{className:`font-mono`,children:e.target}),`. Anything not mentioned is left as it is; anything shown without a change is here for context.`]}),b.size>0&&(0,k.jsxs)(`p`,{"data-testid":`structured-filtered`,className:`flex flex-wrap items-center gap-2 rounded border border-amber-300 bg-amber-50 px-2 py-1 text-xs text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200`,children:[(0,k.jsxs)(`span`,{children:[`Filtered view — `,[...b].map(e=>e.replace(/^(element|relationship|role):/,``)).join(`, `),` hidden.`,` `,C?`The full proposal still applies.`:``]}),(0,k.jsx)(`button`,{type:`button`,className:`underline`,onClick:()=>x(new Set),children:`show everything`})]}),(0,k.jsx)(`div`,{ref:g,className:`overflow-x-auto`,children:T}),(0,k.jsx)(ve,{label:`${e.kind} view`,open:r,onClose:()=>i(!1),containerRef:_,anchorRef:g,actions:e.kind!==`table`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,onClick:re,className:Xw,children:`⤓ download SVG`}),(0,k.jsx)(`button`,{type:`button`,onClick:ie,className:Xw,children:`copy markup`}),m!==null&&(0,k.jsx)(`span`,{className:`text-xs text-zinc-500`,children:m})]}),children:T}),w.length>0&&(0,k.jsx)(`ul`,{className:`space-y-1`,"data-testid":`structured-removals`,children:w.map((t,n)=>(0,k.jsxs)(`li`,{"data-relationship-role":`removed`,className:`rounded border border-red-300 bg-red-50 px-2 py-1 text-xs text-red-800 dark:border-red-800 dark:bg-red-950/40 dark:text-red-200`,children:[(0,k.jsx)(`span`,{className:`line-through`,children:Yw(t,e)}),Yw(t,e)===t.ref&&(0,k.jsx)(`span`,{className:`ml-2 not-italic opacity-70`,"data-testid":`removal-undescribed`,children:`— the proposal does not say what this is`}),(0,k.jsx)(`span`,{className:`ml-2 font-mono opacity-60`,children:t.type})]},n))}),(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-xs`,children:[(0,k.jsx)(`button`,{type:`button`,className:`text-zinc-500 underline`,"aria-label":`Show ${e.kind} view at full size`,onClick:()=>i(!0),children:`⤢ enlarge`}),e.kind===`table`?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,className:`text-zinc-500 underline`,title:O===0?`Save as .csv — opens in any spreadsheet`:`Save as .csv — ${O} hidden rows are left out`,onClick:()=>Fw(D(),`${ee}.csv`),children:`⤓ download CSV`}),(0,k.jsx)(`button`,{type:`button`,className:`text-zinc-500 underline`,title:O===0?`Save as .xlsx — one sheet, values typed as they are declared`:`Save as .xlsx — ${O} hidden rows are left out`,onClick:()=>void Iw(D(),`${ee}.xlsx`),children:`⤓ download XLSX`}),O>0&&(0,k.jsxs)(`span`,{className:`text-xs text-amber-700 dark:text-amber-300`,"data-testid":`table-export-narrowed`,children:[`exports `,O,` rows fewer than the table declares`]})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,className:`text-zinc-500 underline`,title:`Save as .svg — insert it as a picture in a document`,onClick:re,children:`⤓ download SVG`}),(0,k.jsx)(`button`,{type:`button`,className:`text-zinc-500 underline`,title:`Copy the SVG markup, for somewhere that takes it directly`,onClick:()=>void ie(),children:`copy markup`})]}),(0,k.jsxs)(`button`,{type:`button`,className:`text-zinc-500 underline`,onClick:()=>o(e=>!e),children:[a?`hide`:`show`,` text equivalent`]}),S!==void 0&&(0,k.jsxs)(`button`,{type:`button`,className:`text-zinc-500 underline`,onClick:()=>c(e=>!e),children:[s?`hide`:`show`,` derived diagram syntax`]}),(0,k.jsxs)(`button`,{type:`button`,className:`text-zinc-500 underline`,onClick:()=>p(e=>!e),children:[f?`hide`:`show`,` envelope`]}),n!==void 0&&(0,k.jsxs)(`button`,{type:`button`,className:`text-zinc-500 underline`,onClick:()=>u(e=>!e),children:[l?`hide`:`show`,` original output`]}),m!==null&&(0,k.jsx)(`span`,{role:`status`,className:`text-emerald-600 dark:text-emerald-400`,children:m})]}),a&&(0,k.jsx)(`pre`,{"data-testid":`structured-text-equivalent`,className:`overflow-x-auto rounded bg-zinc-100 p-2 text-xs dark:bg-zinc-800`,children:Jw(e,C,b)}),s&&S!==void 0&&(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`p`,{className:`mb-1 text-[11px] text-zinc-500`,children:`Derived from the structured data above. It is an export, not the source.`}),(0,k.jsx)(`pre`,{"data-testid":`structured-derived-export`,className:`overflow-x-auto rounded bg-zinc-100 p-2 text-xs dark:bg-zinc-800`,children:S})]}),f&&(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`p`,{className:`mb-1 text-[11px] text-zinc-500`,children:`The validated document this view is drawn from. It is not sent to the model.`}),(0,k.jsx)(`pre`,{"data-testid":`structured-envelope`,className:`max-h-80 overflow-auto rounded bg-zinc-100 p-2 text-xs dark:bg-zinc-800`,children:t})]}),l&&n!==void 0&&(0,k.jsx)(`pre`,{"data-testid":`structured-raw-output`,className:`overflow-x-auto rounded bg-zinc-100 p-2 text-xs dark:bg-zinc-800`,children:n})]})}function Qw({item:e}){let t=$C(e.structured);return t===void 0?null:(0,k.jsx)(Zw,{envelope:t,source:qw(e.structured,t),rawOutput:e.output})}var $w=[Z_,{id:`structured-exchange`,match:e=>$C(e.structured)!==void 0,stable:!1,showsRawReveal:!0,startsExpanded:!0,Expanded:Qw},$_,tv,dv,vv,nv,rv,X_];function eT(e){for(let t of $w){let n=!1;try{n=t.match(e)}catch{n=!1}if(n)return t}return X_}function tT(e,t){let n=eT(e);if(t===void 0||t===n.id)return n;let r=$w.find(e=>e.id===t);if(r===void 0||r.id===X_.id||n.extensionOwned===!0)return n;let i=!1;try{i=r.match(e)}catch{i=!1}return i?r:n}function nT(e){if(typeof e!=`object`||!e)return``;let t=e,n=[`command`,`path`,`file_path`,`pattern`,`query`].find(e=>typeof t[e]==`string`);if(n)return t[n];let r=JSON.stringify(t);return r===`{}`?``:r}function rT({item:e,dispatch:t=U_}){let n=(0,d.useRef)(void 0),r=tT(e,n.current);n.current=r.id;let i=r.startsExpanded===!0,[a,o]=(0,d.useState)(i);(0,d.useEffect)(()=>{o(i)},[i]);let[s,c]=(0,d.useState)(!1),l=nT(e.args),u=r.Collapsed,f=!a&&u!==void 0&&(r.hasCollapsed?.(e)??!0);return(0,k.jsxs)(`div`,{className:`rounded-lg border text-sm ${e.isError?`border-red-300 bg-red-50 dark:border-red-900/60 dark:bg-red-950/20`:`border-zinc-200 bg-zinc-50 dark:border-zinc-800 dark:bg-zinc-900/60`}`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>o(!a),className:`flex w-full items-center gap-2 px-3 py-2 text-left`,children:[(0,k.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${e.running?`animate-pulse motion-reduce:animate-none bg-amber-400`:e.isError?`bg-red-500`:`bg-emerald-500`}`}),e.callHtml?(0,k.jsx)(Ee,{as:`span`,html:e.callHtml,className:`min-w-0 flex-1 text-zinc-700 dark:text-zinc-300`}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{className:`font-mono font-medium text-zinc-700 dark:text-zinc-300`,children:e.toolName}),l&&(0,k.jsx)(`span`,{className:`truncate font-mono text-xs text-zinc-500`,children:l})]}),(0,k.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-600`,children:a?`▾`:`▸`})]}),f&&u!==void 0&&(0,k.jsx)(`div`,{className:`border-t border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:(0,k.jsx)(u,{item:e,dispatch:t})}),a&&(0,k.jsxs)(`div`,{className:`border-t border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,k.jsx)(r.Expanded,{item:e,dispatch:t}),r.showsRawReveal===!0&&(0,k.jsxs)(`div`,{className:`mt-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>c(!s),className:`text-xs text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-400`,children:s?`hide raw output`:`raw output`}),s&&(0,k.jsx)(`div`,{className:`mt-1`,children:(0,k.jsx)(Y_,{item:e})})]})]})]})}function iT({item:e}){let[t,n]=(0,d.useState)(!1),r=e.details!==void 0,i=!!e.contentHtml,a=e.contentHtmlCollapsed??e.contentHtml,o=r||i&&!!e.contentHtmlCollapsed;return(0,k.jsxs)(`div`,{className:`rounded-lg border border-violet-200 bg-violet-50 px-3 py-2 text-sm dark:border-violet-900/60 dark:bg-violet-950/30`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(`span`,{className:`font-mono text-xs font-bold text-violet-700 dark:text-violet-300`,children:[`[`,e.customType,`]`]}),o&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>n(!t),title:`Show details`,className:`ml-auto text-xs text-violet-500 hover:text-violet-700 dark:text-violet-500 dark:hover:text-violet-300`,children:t?`▾`:`▸`})]}),i&&a?(0,k.jsx)(Ee,{html:t||!e.contentHtmlCollapsed?e.contentHtml??a:a,className:`mt-1 text-violet-950 dark:text-violet-100`}):(0,k.jsx)(`div`,{className:`prose-chat mt-1 text-violet-950 dark:text-violet-100`,children:(0,k.jsx)(hs,{remarkPlugins:[T_,L_],rehypePlugins:[Tm],children:T(e.text)})}),t&&r&&(0,k.jsx)(`pre`,{className:`mt-2 max-h-96 overflow-auto border-t border-violet-200 pt-2 font-mono text-xs text-violet-600 dark:border-violet-900/60 dark:text-violet-400`,children:JSON.stringify(e.details,null,2)})]})}var aT={cost:0,unpriced:0,turns:0,input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0};function oT(e){let t={...aT};for(let n of e){if(n.kind!==`assistant`||!n.usage)continue;let e=n.usage;t.turns+=1,t.input+=e.input,t.output+=e.output,t.cacheRead+=e.cacheRead,t.cacheWrite+=e.cacheWrite,t.totalTokens+=e.totalTokens,e.cost===void 0?t.unpriced+=1:t.cost+=e.cost}return t}function sT(e){let t=e>0&&e<.01?4:2;return`$${e.toFixed(t)}`}function cT(e){return e<1e3?String(e):e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1)}M`}var lT=80,uT=new WeakMap;function dT(e){let t=typeof e==`object`&&!!e;if(t){let t=uT.get(e);if(t!==void 0)return t}let n=0;try{n=JSON.stringify(e)?.length??0}catch{n=0}return t&&uT.set(e,n),n}function fT(e){let t=e.replace(/\s+/g,` `).trim();return t.length>lT?`${t.slice(0,79)}…`:t}function pT(e,t){return{index:e,title:t,turns:0,toolCalls:0,failedToolCalls:0,input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,unpriced:0}}function mT(e,t){e.turns+=1,e.input+=t.input,e.output+=t.output,e.cacheRead+=t.cacheRead,e.cacheWrite+=t.cacheWrite,e.totalTokens+=t.totalTokens,t.cost===void 0?e.unpriced+=1:e.cost=(e.cost??0)+t.cost}function hT(e){if(e.length===0)return 0;let t=[...e].sort((e,t)=>e-t),n=Math.floor(t.length/2);return t.length%2==1?t[n]:(t[n-1]+t[n])/2}function gT(e){let t=[],n=[],r=[],i=new Map,a=pT(-1,``),o=a;e.forEach((e,a)=>{if(e.kind===`user`){o=pT(a,fT(e.text)),r.push(o);return}if(e.kind===`assistant`){if(!e.usage)return;t.push({index:a,number:t.length+1,requestIndex:o.index,usage:e.usage}),mT(o,e.usage);return}if(e.kind!==`tool`)return;let s={index:a,toolCallId:e.toolCallId,name:e.toolName,inputSize:dT(e.args),outputSize:e.output.length,isError:e.isError===!0,running:e.running===!0,requestIndex:o.index};n.push(s),o.toolCalls+=1,s.isError&&(o.failedToolCalls+=1);let c=i.get(s.name)??{name:s.name,calls:0,failures:0,inputSize:0,outputSize:0};c.calls+=1,s.isError&&(c.failures+=1),c.inputSize+=s.inputSize,c.outputSize+=s.outputSize,i.set(s.name,c)}),(a.turns>0||a.toolCalls>0)&&r.unshift(a);let s=oT(e),c=t.map(e=>e.usage.cost).filter(e=>e!==void 0),l=n.filter(e=>e.isError).length;return{turns:t,requests:r,toolCalls:n,tools:[...i.values()],totals:s,pricedTurns:c.length,averageTurnCost:c.length===0?0:s.cost/c.length,medianTurnCost:hT(c),totalToolCalls:n.length,failedToolCalls:l,toolCallsPerTurn:t.length===0?0:n.length/t.length}}function _T(e,t){let n=[...e];return t===`input`?n.sort((e,t)=>t.inputSize-e.inputSize):t===`failure`?n.sort((e,t)=>Number(t.isError)-Number(e.isError)||t.outputSize-e.outputSize):n.sort((e,t)=>t.outputSize-e.outputSize)}function vT(e){return e.filter(e=>e.index>=0).sort((e,t)=>t.totalTokens-e.totalTokens||(t.cost??0)-(e.cost??0))}function yT(e){return e<1e3?`${e} B`:e<1e6?`${Math.round(e/1e3)} kB`:`${(e/1e6).toFixed(1)} MB`}var bT=768,xT=26,ST=132,CT=12,wT=96,TT=124,ET=[{key:`input`,label:`input`,className:`text-emerald-500`,value:e=>e.usage.input},{key:`output`,label:`output`,className:`text-blue-500`,value:e=>e.usage.output},{key:`cacheRead`,label:`cache read`,className:`text-violet-500`,value:e=>e.usage.cacheRead},{key:`cacheWrite`,label:`cache write`,className:`text-amber-500`,value:e=>e.usage.cacheWrite}],DT=[{key:`cost`,label:`cost`,className:`text-rose-500`,value:e=>e.usage.cost??0}];function OT({title:e,children:t}){return(0,k.jsxs)(`section`,{className:`border-t border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:[(0,k.jsx)(`h3`,{className:`mb-2 font-mono text-[11px] uppercase tracking-wide text-zinc-400 dark:text-zinc-500`,children:e}),t]})}function kT({children:e}){return(0,k.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:e})}function AT({label:e,value:t,hint:n}){return(0,k.jsxs)(`div`,{className:`rounded-md border border-zinc-200 px-2 py-1.5 dark:border-zinc-800`,children:[(0,k.jsx)(`div`,{"aria-label":`${e}: ${t}`,className:`font-mono text-sm text-zinc-700 dark:text-zinc-200`,children:t}),(0,k.jsx)(`div`,{className:`text-[11px] text-zinc-500 dark:text-zinc-400`,children:e}),n&&(0,k.jsx)(`div`,{className:`text-[10px] text-zinc-400 dark:text-zinc-500`,children:n})]})}function jT({turns:e,series:t,format:n,onJump:r,describe:i}){let a=Math.max(1,...e.flatMap(e=>t.map(t=>t.value(e)))),o=Math.max(e.length*xT,xT),s=e=>xT/2+e*xT,c=e=>CT+wT*(1-e/a);return(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`mb-1 flex flex-wrap gap-x-3 gap-y-1`,children:t.map(e=>(0,k.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-zinc-500 dark:text-zinc-400`,children:[(0,k.jsx)(`span`,{className:`inline-block h-0.5 w-3 bg-current ${e.className}`}),e.label]},e.key))}),(0,k.jsxs)(`div`,{className:`flex`,children:[(0,k.jsxs)(`div`,{"aria-hidden":!0,className:`flex w-12 shrink-0 flex-col justify-between py-2 pr-1 text-right font-mono text-[9px] text-zinc-400 dark:text-zinc-600`,style:{height:ST},children:[(0,k.jsx)(`span`,{children:n(a)}),(0,k.jsx)(`span`,{children:`0`})]}),(0,k.jsx)(`div`,{className:`min-w-0 flex-1 overflow-x-auto`,children:(0,k.jsxs)(`svg`,{width:o,height:ST,role:`group`,"aria-label":`Per-turn chart`,children:[(0,k.jsx)(`line`,{x1:0,x2:o,y1:108,y2:108,stroke:`currentColor`,className:`text-zinc-200 dark:text-zinc-800`}),t.map(t=>(0,k.jsx)(`polyline`,{fill:`none`,stroke:`currentColor`,strokeWidth:1.5,className:t.className,points:e.map((e,n)=>`${s(n)},${c(t.value(e))}`).join(` `)},t.key)),e.map((n,a)=>(0,k.jsxs)(`g`,{children:[t.map(e=>(0,k.jsx)(`circle`,{cx:s(a),cy:c(e.value(n)),r:2,fill:`currentColor`,className:e.className},e.key)),(0,k.jsx)(`rect`,{x:s(a)-xT/2,y:0,width:xT,height:ST,fill:`transparent`,role:`button`,tabIndex:0,"aria-label":`Turn ${n.number}: ${i(n)} — jump to it`,className:`cursor-pointer outline-none focus-visible:fill-zinc-500/10`,onClick:()=>r(n.index),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r(n.index))},children:(0,k.jsx)(`title`,{children:`turn ${n.number} · ${i(n)}`})}),(e.length<=12||n.number%5==0)&&(0,k.jsx)(`text`,{x:s(a),y:TT,textAnchor:`middle`,className:`fill-zinc-400 text-[9px] dark:fill-zinc-600`,children:n.number})]},n.index))]})})]})]})}function MT({onJump:e,label:t,children:n}){return(0,k.jsx)(`button`,{type:`button`,onClick:e,"aria-label":t,className:`flex w-full items-baseline gap-2 rounded-md px-2 py-1 text-left text-xs hover:bg-zinc-100 dark:hover:bg-zinc-900`,children:n})}function NT({analysis:e,onJump:t,onClose:n}){let[r,i]=(0,d.useState)(`output`),{totals:a}=e;function o(e){t(e),window.innerWidth<bT&&n()}let s=e.turns.length===0&&e.toolCalls.length===0,c=_T(e.toolCalls,r),l=vT(e.requests);return(0,k.jsxs)(`aside`,{"aria-label":`Session analysis`,className:`absolute inset-y-0 right-0 z-10 w-full overflow-y-auto border-l border-zinc-200 bg-white shadow-xl md:w-[26rem] dark:border-zinc-800 dark:bg-zinc-950`,children:[(0,k.jsxs)(`header`,{className:`sticky top-0 flex items-center gap-2 border-b border-zinc-200 bg-white px-4 py-2 dark:border-zinc-800 dark:bg-zinc-950`,children:[(0,k.jsx)(`h2`,{className:`font-mono text-xs text-zinc-600 dark:text-zinc-300`,children:`session analysis`}),(0,k.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close session analysis`,className:`ml-auto rounded-md px-2 py-1 text-sm text-zinc-500 hover:bg-zinc-100 dark:text-zinc-400 dark:hover:bg-zinc-900`,children:`×`})]}),s?(0,k.jsx)(`div`,{className:`px-4 py-6`,children:(0,k.jsx)(kT,{children:`Nothing to analyse yet — no turn has reported figures and no tool has been called.`})}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(OT,{title:`tokens`,children:(0,k.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,k.jsx)(AT,{label:`total`,value:cT(a.totalTokens)}),(0,k.jsx)(AT,{label:`fresh input`,value:cT(a.input)}),(0,k.jsx)(AT,{label:`output`,value:cT(a.output)}),(0,k.jsx)(AT,{label:`cache read`,value:cT(a.cacheRead)}),(0,k.jsx)(AT,{label:`cache write`,value:cT(a.cacheWrite)}),(0,k.jsx)(AT,{label:`turns`,value:String(e.turns.length)})]})}),(0,k.jsx)(OT,{title:`cost`,children:e.pricedTurns===0?(0,k.jsx)(kT,{children:`No turn was priced — this provider reports tokens only.`}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,k.jsx)(AT,{label:`total`,value:sT(a.cost)}),(0,k.jsx)(AT,{label:`average turn`,value:sT(e.averageTurnCost)}),(0,k.jsx)(AT,{label:`median turn`,value:sT(e.medianTurnCost)})]}),(0,k.jsxs)(`p`,{className:`mt-1 text-[11px] text-zinc-400 dark:text-zinc-500`,children:[`over `,e.pricedTurns,` priced turn`,e.pricedTurns===1?``:`s`,a.unpriced>0&&`, ${a.unpriced} unpriced`]})]})}),(0,k.jsx)(OT,{title:`tool calls`,children:e.totalToolCalls===0?(0,k.jsx)(kT,{children:`No tool call recorded in this session.`}):(0,k.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,k.jsx)(AT,{label:`calls`,value:String(e.totalToolCalls)}),(0,k.jsx)(AT,{label:`per turn`,value:e.toolCallsPerTurn.toFixed(1)}),(0,k.jsx)(AT,{label:`failed`,value:String(e.failedToolCalls)})]})}),(0,k.jsx)(OT,{title:`tokens per turn`,children:e.turns.length===0?(0,k.jsx)(kT,{children:`No turn has reported figures yet.`}):(0,k.jsx)(jT,{turns:e.turns,series:ET,format:cT,onJump:o,describe:e=>`${cT(e.usage.totalTokens)} tokens (input ${e.usage.input}, output ${e.usage.output}, cache read ${e.usage.cacheRead}, cache write ${e.usage.cacheWrite})`})}),(0,k.jsx)(OT,{title:`cost per turn`,children:e.pricedTurns===0?(0,k.jsx)(kT,{children:`No turn was priced, so there is no cost to plot.`}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(jT,{turns:e.turns.filter(e=>e.usage.cost!==void 0),series:DT,format:sT,onJump:o,describe:e=>sT(e.usage.cost??0)}),a.unpriced>0&&(0,k.jsxs)(`p`,{className:`mt-1 text-[10px] text-zinc-400 dark:text-zinc-500`,children:[a.unpriced,` unpriced turn`,a.unpriced===1?``:`s`,` left out — they carry no price to plot`]})]})}),(0,k.jsx)(OT,{title:`costliest tool calls`,children:c.length===0?(0,k.jsx)(kT,{children:`No tool call recorded in this session.`}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`mb-1 flex items-center gap-2`,children:[(0,k.jsx)(`label`,{htmlFor:`tool-ranking`,className:`text-[11px] text-zinc-500 dark:text-zinc-400`,children:`rank by`}),(0,k.jsxs)(`select`,{id:`tool-ranking`,value:r,onChange:e=>i(e.target.value),className:`rounded-md border border-zinc-300 bg-white px-1.5 py-0.5 font-mono text-[11px] text-zinc-600 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-300`,children:[(0,k.jsx)(`option`,{value:`output`,children:`output size`}),(0,k.jsx)(`option`,{value:`input`,children:`input size`}),(0,k.jsx)(`option`,{value:`failure`,children:`failure`})]})]}),(0,k.jsx)(`p`,{className:`mb-1 text-[10px] text-zinc-400 dark:text-zinc-500`,children:`measured content size, not tokens — a tool call carries no price`}),c.slice(0,10).map(e=>(0,k.jsxs)(MT,{onJump:()=>o(e.index),label:`Jump to the ${e.name} call, output ${yT(e.outputSize)}`,children:[(0,k.jsx)(`span`,{className:`font-mono text-zinc-600 dark:text-zinc-300`,children:e.name}),e.isError&&(0,k.jsx)(`span`,{className:`text-red-500`,children:`failed`}),e.running&&(0,k.jsx)(`span`,{className:`text-zinc-400`,children:`running`}),(0,k.jsxs)(`span`,{className:`ml-auto font-mono text-zinc-500 dark:text-zinc-400`,children:[`in `,yT(e.inputSize),` · out `,yT(e.outputSize)]})]},e.toolCallId||`${e.index}`))]})}),(0,k.jsx)(OT,{title:`tools`,children:e.tools.length===0?(0,k.jsx)(kT,{children:`No tool has been called yet.`}):(0,k.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{className:`text-left text-[10px] uppercase text-zinc-400 dark:text-zinc-500`,children:[(0,k.jsx)(`th`,{className:`font-normal`,children:`tool`}),(0,k.jsx)(`th`,{className:`font-normal`,children:`calls`}),(0,k.jsx)(`th`,{className:`font-normal`,children:`failed`}),(0,k.jsx)(`th`,{className:`text-right font-normal`,children:`in / out`})]})}),(0,k.jsx)(`tbody`,{className:`font-mono text-zinc-600 dark:text-zinc-300`,children:[...e.tools].sort((e,t)=>t.outputSize-e.outputSize).map(e=>(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`td`,{children:e.name}),(0,k.jsx)(`td`,{children:e.calls}),(0,k.jsx)(`td`,{className:e.failures>0?`text-red-500`:``,children:e.failures}),(0,k.jsxs)(`td`,{className:`text-right`,children:[yT(e.inputSize),` / `,yT(e.outputSize)]})]},e.name))})]})}),(0,k.jsx)(OT,{title:`costliest requests`,children:l.length===0?(0,k.jsx)(kT,{children:`No request has consumed anything yet.`}):l.slice(0,10).map(e=>(0,k.jsxs)(MT,{onJump:()=>o(e.index),label:`Jump to the request "${e.title}"`,children:[(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-zinc-600 dark:text-zinc-300`,children:e.title}),(0,k.jsxs)(`span`,{className:`shrink-0 font-mono text-zinc-500 dark:text-zinc-400`,children:[cT(e.totalTokens),` tok`,e.cost!==void 0&&` · ${sT(e.cost)}`]}),(0,k.jsxs)(`span`,{className:`shrink-0 text-[10px] text-zinc-400 dark:text-zinc-500`,children:[e.turns,`t / `,e.toolCalls,`c`,e.failedToolCalls>0&&` · ${e.failedToolCalls}✗`]})]},e.index))})]})]})}var PT=2e3;function FT({items:e,scrollerRef:t,hideTools:n,onShowTools:r,stickToBottom:i}){let[a,o]=(0,d.useState)(null),s=(0,d.useRef)(null),[c,l]=(0,d.useState)(0),u=(0,d.useRef)(null);(0,d.useEffect)(()=>()=>{u.current&&clearTimeout(u.current)},[]);let f=(0,d.useCallback)(t=>{let i=e[t];i&&(i.kind===`tool`&&n&&r(),s.current=t,l(e=>e+1))},[e,n,r]);return(0,d.useEffect)(()=>{let e=s.current;if(e===null)return;s.current=null;let n=t.current?.querySelector(`[data-item-index="${e}"]`);n&&(i.current=!1,n.scrollIntoView?.({behavior:`smooth`,block:`center`}),o(e),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>o(null),PT))},[c,n,t,i]),{jumpToItem:f,highlightIndex:a}}var IT=/(?:^|\s)@([^\s@]+)/g,LT=new Set([`,`,`.`,`;`,`:`,`!`,`?`,`)`,`]`]);function RT(e){let t=e.length;for(;t>0&<.has(e[t-1]);)t--;return e.slice(0,t)}function zT(e){return[...e.matchAll(IT)].map(([,e])=>RT(e??``)).filter(e=>e.length>0)}var BT=`uploads`,VT=class extends Error{reason;constructor(e,t){super(e),this.name=`UploadError`,this.reason=t}};function HT(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result.split(`,`,2)[1]??``),r.onerror=()=>n(r.error),r.readAsDataURL(e)})}function UT(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function WT(e){return e.type.startsWith(`image/`)?`image`:e.type===`application/pdf`||ne(e.name)||re(e.name)?`extraction-tool`:e.size<=524288?`inline-text`:qT(e)&&e.size<=26214400?`extraction-tool`:`unsupported`}function GT(e){let t=WT(e);return t===`extraction-tool`||t===`image`&&e.size>7340032}var KT=new Set([`application/json`,`application/xml`,`application/javascript`,`application/x-yaml`,`application/yaml`,`application/sql`]);function qT(e){return e.type.startsWith(`text/`)||KT.has(e.type)}function JT(e){return qT(e)?`${e.name}: file too large to upload (max 25 MB)`:`${e.name}: unsupported file type${e.type?` (${e.type})`:``}`}function YT(e,t){return t instanceof VT?t.reason===`denied`?`${e.name}: cannot upload — the workspace is read-only`:t.reason===`too-large`?`${e.name}: file too large to upload (max 25 MB)`:t.reason===`invalid`?`${e.name}: ${t.message}`:`${e.name}: upload failed — ${t.message}`:`${e.name}: upload failed`}async function XT(e){let t;try{t=await e.text()}catch{return{attachments:[],errors:[`${e.name}: could not be read`]}}return t.includes(`\0`)?{attachments:[],errors:[`${e.name}: unsupported binary file`]}:{attachments:[{name:e.name,kind:`text`,data:t,mimeType:e.type||`text/plain`,source:`manual`}],errors:[]}}async function ZT(e){try{let t=await HT(e);return{attachments:[{name:e.name,kind:`image`,data:t,mimeType:e.type,source:`manual`}],errors:[]}}catch{return{attachments:[],errors:[`${e.name}: could not be read`]}}}async function QT(e,t){if(e.size>26214400)return{attachments:[],errors:[`${e.name}: file too large to upload (max 25 MB)`]};let n;try{n=await HT(e)}catch{return{attachments:[],errors:[`${e.name}: could not be read`]}}try{return{attachments:[oE(await t(e.name,n))],errors:[]}}catch(t){return{attachments:[],errors:[YT(e,t)]}}}async function $T(e,t){let n=await Promise.all([...e].map(e=>{let n=WT(e);return n===`unsupported`?Promise.resolve({attachments:[],errors:[JT(e)]}):n===`inline-text`?XT(e):n===`image`&&e.size<=7340032?ZT(e):QT(e,t)}));return{attachments:n.flatMap(e=>e.attachments),errors:n.flatMap(e=>e.errors)}}function eE(e){return{...oE(e),source:`preview`,previewPath:e}}function tE(e){return eE(e)}function nE(e,t){let n=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return RegExp(`(^|\\s)@${n}[,.;:!?)\\]]*(\\s|$)`).test(e)}var rE=zT;function iE(e,t){let n=e.trim(),r=e=>{n+=`${n?`
|
|
318
318
|
|
|
319
|
-
`:``}${e}`};for(let e of t)e.kind===`path`?
|
|
320
|
-
`)]);let O=(0,d.useMemo)(()=>{let e=/^\/(\S*)$/.exec(h);return e?e[1].toLowerCase():null},[h]),te=(0,d.useMemo)(()=>O===null?[]:n.filter(e=>e.name.toLowerCase().startsWith(O)).sort((e,t)=>
|
|
321
|
-
`).length)),className:`flex-1 resize-none 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,k.jsx)(`button`,{type:`button`,onClick:f,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,k.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,className:`h-4 w-4`,children:(0,k.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>E.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,k.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,k.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,k.jsx)(`input`,{ref:E,type:`file`,multiple:!0,hidden:!0,onChange:e=>{e.target.files?.length&&s(Array.from(e.target.files)),e.target.value=``}}),(0,k.jsx)(`button`,{type:`button`,onClick:ce,disabled:!t||oe||!h.trim()&&a.length===0,title:oe?`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,k.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:[(0,k.jsx)(`circle`,{cx:`6`,cy:`19`,r:`3`}),(0,k.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,k.jsx)(`circle`,{cx:`18`,cy:`5`,r:`3`})]}):(0,k.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,k.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
|
|
322
|
-
`);return t===-1?{heading:e,body:``}:{heading:e.slice(0,t),body:e.slice(t+1).trim()}}function
|
|
323
|
-
`)){let t=CE(e);t&&r.push(t)}return r.length<2||r.some((e,t)=>e.index!==t+1)?null:{heading:t,options:r}}function TE({request:e,onRespond:t}){let[n,r]=(0,d.useState)(e.method===`editor`?e.prefill??``:``),[i,a]=(0,d.useState)([]),o=(e.method===`select`||e.method===`confirm`||e.method===`input`)&&e.timeout,[s,c]=(0,d.useState)(o?Math.ceil(o/1e3):null),l=wE(e),{heading:u,body:f}=SE(e.title);function p(){t({id:e.id,cancelled:!0})}function m(e){a(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e].sort((e,t)=>e-t))}function h(){let r=n.trim();t({id:e.id,value:r.length>0?r:i.join(`,`)})}return(0,d.useEffect)(()=>{if(s===null)return;if(s<=0){t({id:e.id,cancelled:!0});return}let n=setTimeout(()=>c(e=>e===null?null:e-1),1e3);return()=>clearTimeout(n)},[s,e.id,t]),(0,k.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,onClick:p,children:(0,k.jsxs)(`div`,{className:`w-full ${f?`max-w-2xl`:`max-w-md`} rounded-xl border border-zinc-200 bg-white p-4 shadow-2xl dark:border-zinc-700 dark:bg-zinc-900`,onClick:e=>e.stopPropagation(),children:[(0,k.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:u}),f&&!l&&(0,k.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,k.jsx)(`div`,{className:`mb-1 flex flex-col gap-1`,children:e.options.map(n=>{let r=CE(n);return(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:`text-left ${gE}`,children:r?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:r.label}),r.description&&(0,k.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:r.description})]}):n},n)})}),e.method===`confirm`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`p`,{className:`mb-4 text-sm text-zinc-600 dark:text-zinc-400`,children:e.message}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!1}),className:gE,children:`No`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!0}),className:_E,children:`Yes`})]})]}),l&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`mb-3 flex flex-col gap-1`,children:l.options.map(e=>(0,k.jsxs)(`label`,{className:`flex 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,k.jsx)(`input`,{type:`checkbox`,checked:i.includes(e.index),onChange:()=>m(e.index),className:`mt-0.5`}),(0,k.jsxs)(`span`,{children:[(0,k.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:e.label}),e.description&&(0,k.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:e.description})]})]},e.index))}),(0,k.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`…or type your own answer`,onKeyDown:e=>{e.key===`Enter`&&h(),e.key===`Escape`&&p()},className:`mb-1 ${vE}`}),(0,k.jsx)(`p`,{className:`mb-4 text-xs text-zinc-400 dark:text-zinc-600`,children:`A typed answer replaces the selection above.`}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:p,className:gE,children:`Cancel`}),(0,k.jsx)(`button`,{type:`button`,onClick:h,className:_E,children:`OK`})]})]}),e.method===`input`&&!l&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`input`,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),placeholder:e.placeholder,onKeyDown:r=>{r.key===`Enter`&&t({id:e.id,value:n}),r.key===`Escape`&&p()},className:yE}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:p,className:gE,children:`Cancel`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:_E,children:`OK`})]})]}),e.method===`editor`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`textarea`,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),rows:8,onKeyDown:e=>{e.key===`Escape`&&p()},className:`resize-none font-mono ${yE}`}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:p,className:gE,children:`Cancel`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:_E,children:`OK`})]})]}),s!==null&&(0,k.jsxs)(`p`,{className:`mt-3 text-right text-xs text-zinc-400 dark:text-zinc-600`,children:[`auto-dismiss in `,s,`s`]})]})})}var EE={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`};function DE({notification:e,onDismiss:t}){return(0,d.useEffect)(()=>{let e=setTimeout(t,6e3);return()=>clearTimeout(e)},[t]),(0,k.jsx)(`div`,{className:`rounded-lg border px-3 py-2 text-sm shadow-lg ${EE[e.notifyType??`info`]}`,children:e.message})}function OE({notifications:e,onDismiss:t}){return e.length===0?null:(0,k.jsx)(`div`,{className:`fixed right-4 top-16 z-40 flex w-80 flex-col gap-2`,children:e.map(e=>(0,k.jsx)(DE,{notification:e,onDismiss:()=>t(e.id)},e.id))})}var kE={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`},AE=/\u001B\[[0-9;:]*[A-Za-z]|\u001B[()][A-Za-z0-9]|\u001B[A-Za-z]/g;function jE(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(kE[r]!==void 0)n.color=kE[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 t[e+1]===5&&(e+=2)}}return n}function ME(e){let t=[],n={},r=0;AE.lastIndex=0;for(let i=AE.exec(e);i!==null;i=AE.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=jE(n,t)}}return r<e.length&&t.push({text:e.slice(r),...n}),t}function NE(e){return e.replace(AE,``)}function PE({line:e}){let t=ME(e);return(0,k.jsx)(k.Fragment,{children:t.map((e,t)=>(0,k.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 FE({widgets:e,placement:t}){let n=Object.entries(e).filter(([,e])=>e.placement===t);return n.length===0?null:(0,k.jsx)(`div`,{className:`mb-2 flex flex-col gap-1`,children:n.map(([e,t])=>(0,k.jsx)(`div`,{className:`whitespace-pre-wrap 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:t.lines.map((e,t)=>(0,k.jsx)(`div`,{children:(0,k.jsx)(PE,{line:e})},t))},e))})}var IE=class extends d.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e,t){console.error(`[pi-outpost] viewer crashed:`,e,t.componentStack)}render(){return this.state.failed?(0,k.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,k.jsxs)(`p`,{className:`max-w-md text-center text-sm text-zinc-600 dark:text-zinc-400`,children:[this.props.label??`This file`,` could not be displayed. Close and reopen it to try again.`]})}):this.props.children}},LE=(0,d.lazy)(()=>j(()=>import(`./PdfViewer-Bg5VXsan.js`),[])),RE=250,zE=`(min-width: 768px)`;function BE(){let[e,t]=(0,d.useState)(()=>window.matchMedia?.(zE).matches??!0);return(0,d.useEffect)(()=>{let e=window.matchMedia?.(zE);if(e===void 0)return;let n=()=>t(e.matches);return n(),e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[]),e}function VE(e,t){let[n,r]=(0,d.useState)(e);return(0,d.useEffect)(()=>{let n=window.setTimeout(()=>r(e),t);return()=>window.clearTimeout(n)},[e,t]),n}function HE(e){let t=ew(e);return t.status===`valid`?t.envelope:void 0}function UE(e){return/\.(md|markdown)$/i.test(e)}function WE(e,t){return t===void 0?!0:t===null?!1:t===``||e===t||e.startsWith(`${t}/`)}function GE({file:e,writableRoot:t,isStreaming:n,onDirtyChange:r,gitState:i,initialShowGitDiff:a=!1,gitDiff:o,onFetchGitDiff:s,onClearGitDiff:c,gitAvailable:l,onOpenGitHistory:u,onClose:f,onReload:p,onSave:m,serverUrl:h=``,token:g=null,onImageLoad:_,onPdfLoad:v,rawRevision:y=0}){let[x,S]=(0,d.useState)(`rendered`),[C,w]=(0,d.useState)(a),[E,ee]=(0,d.useState)(e.status===`loaded`&&e.justCreated?{draft:e.content,baseContent:e.content,baseMtimeMs:e.mtimeMs}:null),[D,re]=(0,d.useState)(`idle`),ae=(0,d.useRef)(null),oe=(0,d.useRef)(null),A=e.status===`loaded`?e:null,ce=A!==null&&UE(e.path),le=te(e.path),j=ne(e.path),ue=(0,d.useMemo)(()=>A===null?void 0:ew(A.content),[A?.content]),de=ue?.status===`valid`,fe=ue?.status===`valid`||ue?.status===`invalid`,pe=fe||ce,me=x===`source`,ge=BE(),_e=WE(e.path,t)&&!j,ve=E!==null&&E.draft!==E.baseContent,ye=A?.pendingSave!==void 0,be=E!==null&&A!==null&&A.mtimeMs!==E.baseMtimeMs,xe=A?.saveError?.conflict===!0||be,Se=E?.draft??A?.content??``,Ce=VE(Se,RE),Te=(0,d.useMemo)(()=>A===null?void 0:ew(Ce),[Ce,A===null]),[Ee,Oe]=(0,d.useState)(()=>e.status===`loaded`?HE(e.content):void 0);(0,d.useEffect)(()=>{Te?.status===`valid`&&Oe(Te.envelope)},[Te]);let ke=Te!==void 0&&Te.status!==`valid`&&Ee!==void 0,Ae=Te?.status===`invalid`?Ce===A?.content&&A.documentIssues!==void 0?A.documentIssues:Te.issues:void 0,je=Te?.status===`not-a-document`?Te.why===`unparseable`?`This is not parseable JSON yet.`:"This no longer declares a structured-exchange `schema`.":Te?.status===`unsupported-version`?`This declares ${Te.schema}, which this version does not render.`:void 0,Me=x===`split`&&pe&&!C&&A!==null&&ge,Ne=E===null?null:(0,k.jsx)(`textarea`,{ref:ae,value:E.draft,onChange:e=>ee({...E,draft:e.target.value}),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),ve&&!ye&&!xe&&Re())},spellCheck:!1,className:`h-full w-full resize-none bg-transparent p-4 font-mono text-[13px] leading-relaxed text-zinc-800 outline-none ring-inset focus-visible:ring-1 focus-visible:ring-zinc-300 dark:text-zinc-200 dark:focus-visible:ring-zinc-700`});function Pe(t){return(0,k.jsx)(`div`,{className:`prose-chat mx-auto max-w-3xl p-4 text-zinc-700 dark:text-zinc-300`,children:(0,k.jsx)(hs,{remarkPlugins:[T_,L_],rehypePlugins:[Tm],components:{pre:we,a:({href:t,children:n,...r})=>!t||/^[a-z][a-z0-9+.-]*:/i.test(t)?(0,k.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,...r,children:n}):t.startsWith(`#`)?(0,k.jsx)(`a`,{href:t,...r,children:n}):(0,k.jsx)(`a`,{href:t,onClick:n=>{n.preventDefault(),p(O(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(`//`)?ie(h,O(e.path,t),g):t;return(0,k.jsx)(`img`,{...r,src:i,alt:n??``,loading:`lazy`,className:`max-w-full rounded-lg`})}},children:T(t)})})}function Fe(e){x===`split`&&e!==`split`&&ve&&!window.confirm(`Discard unsaved changes?`)||(x===`split`&&e!==`split`&&ee(null),S(e))}function Ie(){ve&&!window.confirm(`Discard unsaved changes?`)||f()}function Le(){A&&ee({draft:A.content,baseContent:A.content,baseMtimeMs:A.mtimeMs})}function Re(t=!1){!A||E===null||ye||(oe.current=E.draft,m(e.path,E.draft,E.baseMtimeMs,t))}function ze(){ee(null),p(e.path)}function Be(){let t=!C;w(t),t?s(e.path):c()}return(0,d.useEffect)(()=>{if(E!==null&&A!==null&&oe.current!==null&&A.content===oe.current&&A.mtimeMs!==E.baseMtimeMs){let e=oe.current;oe.current=null,E.draft===e?ee(null):ee({...E,baseContent:A.content,baseMtimeMs:A.mtimeMs})}},[A?.mtimeMs]),(0,d.useEffect)(()=>{function e(e){e.key===`Escape`&&Ie()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),(0,d.useEffect)(()=>{Me&&_e&&E===null&&A!==null&&ee({draft:A.content,baseContent:A.content,baseMtimeMs:A.mtimeMs})},[Me,_e,A?.mtimeMs]),(0,d.useEffect)(()=>{re(n?`streaming`:e=>e===`streaming`?`done`:e)},[n]),(0,d.useEffect)(()=>(r(ve),()=>r(!1)),[ve]),(0,d.useEffect)(()=>(a&&s(e.path),()=>c()),[]),(0,k.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[pe&&!C&&(0,k.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`]].map(([e,t,n])=>(0,k.jsx)(`button`,{type:`button`,onClick:()=>Fe(e),"aria-pressed":x===e,title:n,className:`rounded px-1.5 py-0.5 text-xs ${x===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&&E===null&&(0,k.jsx)(`button`,{type:`button`,onClick:Be,"aria-pressed":C,title:C?`Show file content`:`Show uncommitted changes (vs HEAD)`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs ${C?`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`}),l&&E===null&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>u(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,k.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,ve&&(0,k.jsx)(`span`,{className:`ml-1 text-amber-500`,children:`●`})]}),A&&E===null&&(0,k.jsx)(se,{text:A.content}),A&&E===null&&!C&&_e&&(0,k.jsx)(`button`,{type:`button`,onClick:Le,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`}),A&&E===null&&!_e&&(0,k.jsx)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,title:`Outside the writable zone`,children:`🔒 read-only`}),E!==null&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>Re(),disabled:!ve||ye||xe,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:ye?`saving…`:`save`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>{ve&&!window.confirm(`Discard unsaved changes?`)||ee(Me&&A!==null?{draft:A.content,baseContent:A.content,baseMtimeMs:A.mtimeMs}:null)},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:`cancel`})]}),(0,k.jsx)(`button`,{type:`button`,onClick:Ie,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&&E!==null&&(0,k.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,k.jsx)(`span`,{className:`min-w-0 flex-1`,children:`File changed on disk since you started editing.`}),(0,k.jsx)(`button`,{type:`button`,onClick:ze,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,k.jsx)(`button`,{type:`button`,onClick:()=>Re(!0),disabled:ye,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`})]}),E!==null&&A?.saveError&&!A.saveError.conflict&&(0,k.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:A.saveError.message}),(0,k.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[C&&E===null&&(0,k.jsxs)(`div`,{className:`p-4`,children:[o?.path===e.path&&`error`in o&&(0,k.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,k.jsx)(De,{fill:!0,lines:b(o.before,o.after)}),o?.path!==e.path&&(0,k.jsx)(`div`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`loading diff…`})]}),j&&E===null&&!C&&(0,k.jsx)(IE,{label:`This PDF`,children:(0,k.jsx)(d.Suspense,{fallback:(0,k.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),children:(0,k.jsx)(LE,{path:e.path,serverUrl:h,token:g,revision:y,...v?{onLoaded:v}:{}})})}),le&&E===null&&!C&&(0,k.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,k.jsx)(`img`,{src:ie(h,e.path,g,y),alt:e.path,onLoad:()=>_(e.path),className:`max-h-full max-w-full rounded object-contain`})}),e.status===`loading`&&E===null&&!C&&!le&&!j&&(0,k.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),e.status===`error`&&!le&&!j&&(0,k.jsx)(`div`,{className:`p-4 text-sm text-red-600 dark:text-red-400`,children:e.message}),E!==null&&!Me&&Ne,A&&E===null&&!Me&&!C&&ce&&!me&&Pe(A.content),Me&&(0,k.jsxs)(`div`,{className:`flex h-full min-h-0`,"data-testid":`file-split`,children:[(0,k.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto border-r border-zinc-200 dark:border-zinc-800`,children:Ne??(0,k.jsx)(`div`,{className:`p-4`,children:(0,k.jsx)(he,{code:A.content,path:e.path})})}),(0,k.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto`,"data-testid":`file-split-rendering`,children:ce&&!fe?(0,k.jsx)(`div`,{className:`prose-chat p-4 text-zinc-700 dark:text-zinc-300`,children:Pe(Ce)}):(0,k.jsxs)(k.Fragment,{children:[ke&&(0,k.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,k.jsxs)(`span`,{children:[`Showing the document as it last stood.`,` `,je??`The text beside it does not satisfy the schema it declares.`]})}),Ae!==void 0&&(0,k.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:[Ae.slice(0,6).map((e,t)=>(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),Ae.length>6&&(0,k.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,Ae.length-6,` more`]})]}),Ee===void 0?(0,k.jsxs)(`p`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,"data-testid":`file-split-nothing`,children:[`Nothing to draw yet. `,je??`This document does not satisfy the schema it declares.`]}):(0,k.jsx)(IE,{label:`This diagram`,children:(0,k.jsx)(`div`,{className:`p-4`,"data-testid":`file-structured-exchange`,children:(0,k.jsx)(Zw,{envelope:Ee,source:Se})})})]})})]}),A&&E===null&&!Me&&!C&&de&&!me&&ue?.status===`valid`&&(0,k.jsx)(IE,{label:`This diagram`,children:(0,k.jsx)(`div`,{className:`mx-auto max-w-5xl p-4`,"data-testid":`file-structured-exchange`,children:(0,k.jsx)(Zw,{envelope:ue.envelope,source:A.content})})}),A&&E===null&&!Me&&!C&&ue?.status===`invalid`&&(0,k.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,k.jsx)(`p`,{className:`font-medium`,children:`This declares a structured-exchange document and does not satisfy the schema.`}),(0,k.jsxs)(`ul`,{className:`mt-1 space-y-0.5 text-xs`,children:[(A.documentIssues??ue.issues).slice(0,8).map((e,t)=>(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),(A.documentIssues??ue.issues).length>8&&(0,k.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,(A.documentIssues??ue.issues).length-8,` more`]})]})]}),A&&E===null&&!Me&&!C&&ue?.status===`unsupported-version`&&(0,k.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,k.jsx)(`span`,{className:`font-mono`,children:ue.schema}),`, which this version does not render. Shown as text.`]}),A&&E===null&&!Me&&!C&&(!ce||me)&&(!de||me)&&(0,k.jsx)(`div`,{className:`p-4`,children:(0,k.jsx)(he,{code:A.content,path:e.path})})]}),D!==`idle`&&(0,k.jsxs)(`button`,{type:`button`,onClick:Ie,"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:[D===`streaming`?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 animate-pulse motion-reduce:animate-none rounded-full bg-amber-500`}),(0,k.jsx)(`span`,{className:`text-amber-700 dark:text-amber-400`,children:`π is replying…`})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 rounded-full bg-emerald-500`}),(0,k.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:`π replied`})]}),(0,k.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-500`,children:`show conversation →`})]})]})}function KE(e){return e.split(`
|
|
324
|
-
`).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 qE({show:e,onClose:t}){return(0,d.useEffect)(()=>{function e(e){e.key===`Escape`&&(e.stopImmediatePropagation(),t())}return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t]),(0,k.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,k.jsx)(`span`,{className:`font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,12)}),(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`commit diff`}),(0,k.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,k.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,k.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto p-3 font-mono text-xs leading-relaxed`,children:KE(e.patch).map((e,t)=>(0,k.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 JE=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`],YE=`worktree`,XE={defaultWidth:288,minWidth:224,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.files-sidebar-width.v1`},ZE={defaultWidth:416,minWidth:224,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.history-list-width.v1`};function QE(e,t){return Number.isFinite(e)?Math.min(t.maxWidth,Math.max(t.minWidth,Math.round(e))):t.defaultWidth}function $E(e,t){return e===null||e.trim()===``?t.defaultWidth:QE(Number(e),t)}function eD(e,t){try{return $E((t??window.localStorage).getItem(e.storageKey),e)}catch{return e.defaultWidth}}function tD(e,t,n){try{(n??window.localStorage).setItem(t.storageKey,String(QE(e,t)))}catch{}}function nD(e){let[t,n]=(0,d.useState)(()=>eD(e)),r=(0,d.useRef)(t),i=(0,d.useRef)(null),a=(0,d.useCallback)(t=>{let i=QE(t,e);return r.current=i,n(i),i},[e]),o=(0,d.useCallback)(()=>{i.current!==null&&(i.current=null,tD(r.current,e))},[e]);return{width:t,separatorProps:{onPointerDown:e=>{e.isPrimary!==!1&&(e.button??0)===0&&(e.preventDefault(),e.currentTarget.setPointerCapture?.(e.pointerId),i.current={pointerId:e.pointerId,startX:e.clientX,startWidth:r.current})},onPointerMove:e=>{let t=i.current;t!==null&&t.pointerId===e.pointerId&&a(t.startWidth+e.clientX-t.startX)},onPointerUp:e=>{i.current?.pointerId===e.pointerId&&o()},onPointerCancel:e=>{let t=i.current;t!==null&&t.pointerId===e.pointerId&&(i.current=null,a(t.startWidth))},onLostPointerCapture:o,onKeyDown:t=>{let n=null;t.key===`ArrowLeft`?n=r.current-e.keyboardStep:t.key===`ArrowRight`?n=r.current+e.keyboardStep:t.key===`Home`&&(n=e.defaultWidth),n!==null&&(t.preventDefault(),tD(a(n),e))}}}}function rD({label:e,width:t,config:n,separatorProps:r,className:i=``}){return(0,k.jsx)(`div`,{...r,role:`separator`,"aria-label":e,"aria-orientation":`vertical`,"aria-valuemin":n.minWidth,"aria-valuemax":n.maxWidth,"aria-valuenow":t,tabIndex:0,title:e,className:`group absolute inset-y-0 -right-1 z-20 w-2 cursor-col-resize touch-none outline-none ${i}`,children:(0,k.jsx)(`span`,{className:`pointer-events-none absolute 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 iD=`#10b981`,aD=[`#8b5cf6`,`#f59e0b`,`#0ea5e9`,`#f43f5e`,`#14b8a6`,`#d946ef`];function oD(e){return e===0?iD:aD[(e-1)%aD.length]}function sD(e){return aD[e%aD.length]}function cD(e){return e*14+7+1}function lD(e){return e*14+2}function uD({row:e,laneCount:t,colorOf:n=oD}){let r=lD(t),i=cD(e.lane),a=e.highlight?iD:n(e.lane),o=e.dashed?`3 3`:void 0;return(0,k.jsxs)(`svg`,{width:r,height:36,viewBox:`0 0 ${r} 36`,"aria-hidden":!0,className:`shrink-0`,children:[e.through.map(e=>(0,k.jsx)(`line`,{x1:cD(e),y1:0,x2:cD(e),y2:36,stroke:n(e),strokeWidth:2,opacity:.55},e)),e.lineAbove&&(0,k.jsx)(`line`,{x1:i,y1:0,x2:i,y2:18,stroke:a,strokeWidth:2,strokeDasharray:o}),e.lineBelow&&(0,k.jsx)(`line`,{x1:i,y1:18,x2:i,y2:36,stroke:a,strokeWidth:2,strokeDasharray:o}),e.forkTo.map(e=>(0,k.jsx)(`path`,{d:`M ${i} 18 C ${i} 36, ${cD(e)} 18, ${cD(e)} 36`,fill:`none`,stroke:n(e),strokeWidth:2,opacity:.75},`fork-${e}`)),(e.mergeFrom??[]).map(e=>(0,k.jsx)(`path`,{d:`M ${i} 18 C ${i} 0, ${cD(e)} 18, ${cD(e)} 0`,fill:`none`,stroke:n(e),strokeWidth:2,opacity:.75},`merge-${e}`)),e.emphasis===`current`?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`circle`,{cx:i,cy:18,r:6,fill:`none`,stroke:a,strokeWidth:2}),(0,k.jsx)(`circle`,{cx:i,cy:18,r:2.5,fill:a})]}):(0,k.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 dD(e,t={}){let n=[],r=[],i=0,a=()=>{let e=r.indexOf(null);return e===-1?(r.push(null),i=Math.max(i,r.length),r.length-1):e};for(let t of e){let e=r.reduce((e,n,r)=>n===t.sha?[...e,r]:e,[]),o=e[0]??a(),s=e.slice(1);for(let e of s)r[e]=null;i=Math.max(i,o+1);let[c,...l]=t.parents;r[o]=c??null;let u=l.map(e=>{let t=a();return r[t]=e,t});n.push({rev:t.sha,path:t.path,entry:t,lane:o,through:r.reduce((e,t,n)=>t!==null&&n!==o&&!u.includes(n)?[...e,n]:e,[]),forkTo:u,mergeFrom:s,lineAbove:!0,lineBelow:t.parents.length>0,emphasis:`filled`})}let o=n[0];return n.unshift({rev:YE,path:o?.path??``,lane:o?.lane??0,through:o?.through??[],forkTo:[],mergeFrom:[],lineAbove:!1,lineBelow:n.length>0,emphasis:`current`,dashed:!t.dirty}),n[1]&&(n[1].lineAbove=!0),{rows:n,laneCount:Math.max(i,1)}}var fD=20;function pD(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 mD(e){return e.rev===`worktree`?`working tree`:e.rev.slice(0,7)}function hD(e,t){return e!==null&&t!==null&&e.rev===t.rev&&e.path===t.path}function gD(e){return{rev:e.rev,path:e.path}}function _D({history:e,diff:t,dirty:n,onFetchDiff:r,onClearDiff:i,onClose:a}){let[o,s]=(0,d.useState)({base:null,target:null}),{base:c,target:l}=o,[u,f]=(0,d.useState)(0),p=(0,d.useRef)([]),m=nD(ZE),{rows:h,laneCount:g}=(0,d.useMemo)(()=>dD(e.entries,{dirty:n}),[e.entries,n]),_=(0,d.useRef)({onFetchDiff:r,onClose:a});_.current={onFetchDiff:r,onClose:a},(0,d.useEffect)(()=>{function e(e){e.key===`Escape`&&(e.stopImmediatePropagation(),_.current.onClose())}return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[]),(0,d.useEffect)(()=>{c===null||l===null||hD(c,l)||_.current.onFetchDiff(c,l)},[c,l]);let v=(0,d.useCallback)((e,t)=>{let n=gD(e);s(r=>{if(t===`base`)return{base:n,target:hD(n,r.target)?r.base:r.target};if(t===`target`)return{base:hD(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:h.find(e=>e.rev===t);return{base:r?gD(r):null,target:n}}return{base:hD(n,r.base)?r.target:r.base,target:n}})},[h]),y=(0,d.useCallback)(()=>{s({base:null,target:null}),i()},[i]),b=(0,d.useCallback)(()=>s(e=>({base:e.target,target:e.base})),[]),x=(0,d.useCallback)(e=>{f(t=>{let n=Math.max(0,Math.min(h.length-1,t+e));return p.current[n]?.focus(),n})},[h.length]),S=e=>{let t=gD(e);return hD(t,c)?`base`:hD(t,l)?`target`:null},C=h.findIndex(e=>hD(gD(e),c)),w=h.findIndex(e=>hD(gD(e),l)),T=C>=0&&w>=0?{top:Math.min(C,w)*36+18,height:Math.abs(w-C)*36}:null;return(0,k.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,k.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,k.jsxs)(`span`,{className:`shrink-0 font-mono text-xs text-zinc-500 dark:text-zinc-400`,"aria-label":`Comparing ${mD(c)} to ${mD(l)}`,children:[(0,k.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:mD(c)}),` → `,(0,k.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:mD(l)})]}),c!==null&&l!==null&&(0,k.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,k.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,k.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,k.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,k.jsxs)(`div`,{role:`region`,"aria-label":`Commit history`,style:{"--history-list-width":`${m.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,k.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,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`Reading history…`}),e.status===`error`&&(0,k.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,k.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,k.jsxs)(`div`,{className:`relative`,role:`group`,"aria-label":`Commits`,children:[T&&(0,k.jsx)(vD,{top:T.top,height:T.height,baseFirst:C<w}),h.map((e,t)=>(0,k.jsx)(xD,{ref:e=>{p.current[t]=e},row:e,laneCount:g,role:S(e),isFocused:t===u,onSelect:t=>v(e,t),onFocus:()=>f(t)},e.rev))]})]}),(0,k.jsx)(rD,{label:`Resize History commit list`,width:m.width,config:ZE,separatorProps:m.separatorProps,className:`hidden md:block`})]}),(0,k.jsx)(`div`,{role:`region`,"aria-label":`History diff`,className:`min-h-0 min-w-0 flex-1 overflow-auto p-3`,children:(0,k.jsx)(SD,{diff:t,base:c,target:l})})]})]})}function vD({top:e,height:t,baseFirst:n}){return(0,k.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:fD},children:[(0,k.jsx)(`div`,{className:`absolute inset-y-0 left-2 w-px bg-zinc-400 dark:bg-zinc-500`}),(0,k.jsx)(yD,{label:n?`base`:`target`,className:`top-0`}),(0,k.jsx)(yD,{label:n?`target`:`base`,className:`bottom-0`})]})}function yD({label:e,className:t}){return(0,k.jsx)(`div`,{className:`absolute left-2 flex h-px w-2.5 items-center bg-zinc-400 dark:bg-zinc-500 ${t}`,children:(0,k.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 bD=`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 xD({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,k.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:fD},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,k.jsx)(uD,{row:e,laneCount:t}),s?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:s.sha.slice(0,7)}),(0,k.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,k.jsxs)(`span`,{className:`shrink-0 text-[10px] text-zinc-400 dark:text-zinc-600`,children:[s.author,` · `,pD(s.date)]}),(0,k.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums`,"aria-label":`${s.added} lines added, ${s.deleted} removed`,children:[(0,k.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-500`,children:[`+`,s.added]}),` `,(0,k.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,s.deleted]})]})]}):(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`working tree`}),(0,k.jsxs)(`span`,{className:`flex shrink-0 gap-0.5`,children:[(0,k.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:bD,children:`base`}),(0,k.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:bD,children:`target`})]})]})}function SD({diff:e,base:t,target:n}){return t===null&&n===null?(0,k.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,k.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,k.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,k.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Loading…`}):e.status===`loaded`&&e.beforeText===e.afterText?(0,k.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`These two versions are identical.`}):(0,k.jsx)(`div`,{className:e.status===`loading`?`opacity-40`:void 0,children:(0,k.jsx)(De,{fill:!0,lines:b(e.beforeText,e.afterText)})})}function CD(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 wD({status:e,log:t,onFetchLog:n,onShowCommit:r}){let[i,a]=(0,d.useState)(!1),o=lE(()=>a(!1)),s=e&&(e.ahead>0||e.behind>0)?` ${e.ahead>0?`↑${e.ahead}`:``}${e.behind>0?`↓${e.behind}`:``}`:``;return(0,k.jsxs)(`div`,{className:`relative`,ref:o,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>{a(!i),i||n()},title:`git history`,className:`rounded-md border border-zinc-300 px-2 py-1 font-mono text-xs 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?.branch??`…`,s]}),i&&(0,k.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:[t===null&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),t?.length===0&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no commits`}),t?.map(e=>(0,k.jsxs)(`button`,{type:`button`,onClick:()=>{r(e.sha),a(!1)},className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:[(0,k.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,7)}),(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-zinc-700 dark:text-zinc-300`,title:e.subject,children:e.subject}),(0,k.jsxs)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:[e.author,` · `,CD(e.date)]})]},e.sha))]})]})}function TD({label:e,browse:t,onBrowse:n,onSelect:r,onCancel:i}){let a=t?.path??`/`,o=t?.entries??[],s=t?.status===`loading`;return(0,k.jsxs)(`div`,{className:`rounded-md border border-zinc-300 p-2 dark:border-zinc-700`,"data-testid":`server-path-picker`,children:[(0,k.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,k.jsx)(`span`,{className:`text-xs font-semibold text-zinc-600 dark:text-zinc-300`,children:e}),(0,k.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,k.jsx)(`p`,{className:`mb-2 break-all font-mono text-[11px] text-zinc-500 dark:text-zinc-400`,"data-testid":`picker-path`,children:a}),t?.status===`error`&&(0,k.jsx)(`p`,{role:`alert`,className:`mb-2 text-xs text-red-600 dark:text-red-400`,children:t.error}),(0,k.jsxs)(`div`,{className:`mb-2 flex gap-2`,children:[(0,k.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,k.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,k.jsxs)(`ul`,{className:`max-h-40 overflow-y-auto`,children:[s&&o.length===0&&(0,k.jsx)(`li`,{className:`px-2 py-1 text-xs text-zinc-400`,children:`Loading…`}),!s&&o.length===0&&t?.status!==`error`&&(0,k.jsx)(`li`,{className:`px-2 py-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`No subdirectories`}),o.map(e=>(0,k.jsx)(`li`,{children:(0,k.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 ED({extensionPaths:e,tools:t,commands:n,sandbox:r,userSkillPaths:i,serverBrowse:a,applyState:o,versions:s,onBrowseServerPath:c,onCloseServerBrowser:l,onUpdateConfig:u}){let[f,p]=(0,d.useState)(!1),[m,h]=(0,d.useState)(``),[g,_]=(0,d.useState)(``),[v,y]=(0,d.useState)(!1),[b,x]=(0,d.useState)(!1),[S,C]=(0,d.useState)(i),[w,T]=(0,d.useState)(null),E=lE(()=>ie()),ee=t.filter(e=>e.active),D=t.filter(e=>!e.active),O=n.filter(e=>e.source===`skill`),te=o?.status===`applying`,ne=o?.status===`error`?o.message:null;(0,d.useEffect)(()=>{r&&(h(r.root),_(r.writableRoot??``),y(r.allowWrite),x(r.allowBash))},[r]),(0,d.useEffect)(()=>{C(i)},[i]);let re=(0,d.useRef)(!1);(0,d.useEffect)(()=>{re.current&&o===null&&ie(),re.current=te},[o,te]);function ie(){p(!1),T(null),l()}function ae(e,t){T(e),c(t.trim()||`/`)}function oe(e){w===`root`?h(e):w===`writableRoot`?_(e):w===`skill`&&!S.includes(e)&&C([...S,e]),T(null),l()}function se(){let e=r?{root:m,allowWrite:v,allowBash:b,writableRoot:g.trim()||void 0}:void 0;u({...e?{sandbox:e}:{},userSkillPaths:S})}let A=w!==null&&(0,k.jsx)(TD,{label:w===`skill`?`Choose a skills directory`:w===`root`?`Choose the sandbox root`:`Choose the writable root`,browse:a,onBrowse:c,onSelect:oe,onCancel:()=>{T(null),l()}});return(0,k.jsxs)(`div`,{className:`relative`,ref:E,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>p(!f),title:`Settings`,"aria-label":`Settings`,className:`rounded-md border border-zinc-300 px-2 py-1 text-xs 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:`⚙`}),f&&(0,k.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,k.jsx)(`div`,{className:`border-b border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:(0,k.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Settings`})}),(0,k.jsxs)(`div`,{className:`min-h-0 overflow-y-auto p-4`,children:[(0,k.jsxs)(`section`,{className:`mb-4`,children:[(0,k.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Agent resources`}),t.length===0?(0,k.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`Tool inventory unavailable for this runtime`}):(0,k.jsxs)(`details`,{children:[(0,k.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[ee.length,` tools active`,D.length?` · ${D.length} inactive`:``]}),(0,k.jsx)(`ul`,{className:`mt-2 space-y-1`,children:t.map(e=>(0,k.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,k.jsx)(`span`,{children:e.name}),(0,k.jsx)(`span`,{children:e.active?`active`:`inactive`})]},e.name))})]}),O.length===0?(0,k.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400 dark:text-zinc-500`,children:`No skills loaded`}):(0,k.jsxs)(`details`,{className:`mt-2`,children:[(0,k.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[O.length,` skills loaded`]}),(0,k.jsx)(`ul`,{className:`mt-2 space-y-1`,children:O.map(e=>(0,k.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.name},e.name))})]}),(0,k.jsxs)(`div`,{className:`mt-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,k.jsx)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:`User skill paths`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>ae(`skill`,S[S.length-1]??`/`),className:`rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-600 hover:border-zinc-400 dark:border-zinc-700 dark:text-zinc-300`,children:`Add directory…`})]}),S.length===0?(0,k.jsx)(`p`,{className:`mt-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`No skill directories added`}):(0,k.jsx)(`ul`,{className:`mt-1 space-y-1`,children:S.map(e=>(0,k.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded bg-zinc-50 px-2 py-1 dark:bg-zinc-800`,children:[(0,k.jsx)(`span`,{className:`truncate font-mono text-xs text-zinc-600 dark:text-zinc-400`,title:e,children:e}),(0,k.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e}`,onClick:()=>C(S.filter(t=>t!==e)),className:`shrink-0 text-xs text-zinc-500 hover:text-red-600 dark:text-zinc-400 dark:hover:text-red-400`,children:`Remove`})]},e))}),w===`skill`&&(0,k.jsx)(`div`,{className:`mt-2`,children:A})]})]}),(0,k.jsxs)(`section`,{className:`mb-4`,children:[(0,k.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Extensions`}),e.length===0?(0,k.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No extensions loaded`}):(0,k.jsx)(`ul`,{className:`space-y-1`,children:e.map((e,t)=>(0,k.jsx)(`li`,{className:`rounded bg-zinc-50 px-2 py-1 text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,title:e,children:e},t))})]}),r&&(0,k.jsxs)(`section`,{children:[(0,k.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Sandbox`}),(0,k.jsxs)(`div`,{className:`space-y-3`,children:[(0,k.jsxs)(`label`,{className:`block`,children:[(0,k.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Root `,r.locks?.root?(0,k.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,k.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,k.jsx)(`input`,{type:`text`,value:m,onChange:e=>h(e.target.value),disabled:r.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,k.jsx)(`button`,{type:`button`,"aria-label":`Browse for sandbox root`,disabled:r.locks?.root,onClick:()=>ae(`root`,m),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…`})]})]}),w===`root`&&A,(0,k.jsxs)(`label`,{className:`block`,children:[(0,k.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Writable root (optional) `,r.locks?.writableRoot?(0,k.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,k.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,k.jsx)(`input`,{type:`text`,value:g,onChange:e=>_(e.target.value),disabled:r.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,k.jsx)(`button`,{type:`button`,"aria-label":`Browse for writable root`,disabled:r.locks?.writableRoot,onClick:()=>ae(`writableRoot`,g||m),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…`})]})]}),w===`writableRoot`&&A,(0,k.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:v,onChange:e=>y(e.target.checked),disabled:r.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,k.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow write `,r.locks?.allowWrite?(0,k.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]}),(0,k.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:b,onChange:e=>x(e.target.checked),disabled:r.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,k.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow bash `,r.locks?.allowBash?(0,k.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]})]})]}),!r&&(0,k.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No sandbox configured`}),(0,k.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[ne&&(0,k.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:ne}),(0,k.jsx)(`button`,{type:`button`,disabled:te||r!==null&&!m.trim(),onClick:se,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:te?`Applying…`:`Apply & restart session`}),(0,k.jsx)(`p`,{className:`text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Saved to the server's configuration file, then the session is rebuilt — the change survives a restart.`})]}),s&&(0,k.jsxs)(`section`,{className:`mt-4`,children:[(0,k.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Versions`}),(0,k.jsxs)(`div`,{className:`space-y-1 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,k.jsxs)(`p`,{children:[`pi-outpost: `,(0,k.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:s.piOutpost})]}),s.piSdk&&(0,k.jsxs)(`p`,{children:[`pi SDK: `,(0,k.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:s.piSdk})]}),s.agent&&(0,k.jsxs)(`p`,{children:[`agent: `,(0,k.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:s.agent})]})]})]})]})]})]})}function DD(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);return}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 OD(e){return e.flatMap(e=>[e,...OD(e.children)])}function kD({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,k.jsx)(`span`,{className:`shrink-0 rounded-full border px-1.5 py-px text-[10px] leading-4 ${n}`,children:e})}var AD=`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 jD({row:e,laneCount:t,isStreaming:n,onNavigate:r,onFork:i,onClose:a}){let{node:o}=e,s=o.tipId??o.entryId;return(0,k.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,k.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,k.jsx)(uD,{row:e,laneCount:t,colorOf:sD}),(0,k.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,k.jsxs)(kD,{tone:`branch`,children:[e.forkTo.length+1,` branches`]}),e.branchIndex!==void 0&&(0,k.jsxs)(kD,{tone:`branch`,children:[`branch `,e.branchIndex,o.onPath&&!e.isCurrent?` · current`:``]}),e.isCurrent&&(0,k.jsx)(kD,{tone:`current`,children:`current`}),o.label&&(0,k.jsx)(kD,{tone:`label`,children:o.label})]}),(0,k.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:AD,children:`↺ redo`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>{i(o.entryId),a()},title:`fork a new session from this point`,className:AD,children:`⑂ fork`})]})}function MD({tree:e,isStreaming:t,onListTree:n,onNavigate:r,onFork:i}){let[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(``),l=lE(()=>o(!1));(0,d.useEffect)(()=>{a&&e===null&&n()},[a,e]);let u=(0,d.useMemo)(()=>e&&e.length>0?DD(e):null,[e]),f=(0,d.useMemo)(()=>{if(!e||!s.trim())return null;let t=s.trim().toLowerCase();return OD(e).filter(e=>e.text.toLowerCase().includes(t)||e.label?.toLowerCase().includes(t))},[e,s]);return(0,k.jsxs)(`div`,{className:`relative`,ref:l,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>{o(!a),a||(c(``),n())},title:`conversation tree: go back to an earlier point or fork`,className:`rounded-md border border-zinc-300 px-2 py-1 text-xs 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,k.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,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),e?.length===0&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no messages yet`}),e&&e.length>0&&u&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,k.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,k.jsx)(`span`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Conversation tree`}),(0,k.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,k.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,k.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,k.jsx)(`div`,{className:`min-h-0 overflow-y-auto py-1`,children:f===null?u.rows.map(e=>(0,k.jsx)(jD,{row:e,laneCount:u.laneCount,isStreaming:t,onNavigate:r,onFork:i,onClose:()=>o(!1)},e.node.entryId)):f.length===0?(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no matches`}):f.map(e=>(0,k.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70`,children:[(0,k.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,k.jsx)(`span`,{"aria-hidden":!0,className:e.onPath?`text-emerald-500`:`text-zinc-300 dark:text-zinc-600`,children:`●`}),(0,k.jsx)(`span`,{className:`min-w-0 truncate text-zinc-700 dark:text-zinc-300`,children:e.text||`(empty)`}),e.onPath&&(0,k.jsx)(kD,{tone:`current`,children:`on current branch`}),e.label&&(0,k.jsx)(kD,{tone:`label`,children:e.label})]}),(0,k.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:AD,children:`↺ redo`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>{i(e.entryId),o(!1)},title:`fork a new session from this point`,className:AD,children:`⑂ fork`})]},e.entryId))})]})]})]})}var ND=200;function PD({initial:e,onCommit:t,onCancel:n}){let[r,i]=(0,d.useState)(e);return(0,k.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 FD({session:e,isCurrent:t,renaming:n,onSwitch:r,onDelete:i,onStartRename:a,onRename:o,onCancelRename:s}){return n?(0,k.jsx)(`div`,{className:`px-3 py-2`,children:(0,k.jsx)(PD,{initial:e.name??``,onCommit:o,onCancel:s})}):(0,k.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,k.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 flex-1 px-3 py-2 text-left text-sm`,children:[(0,k.jsx)(`div`,{className:`truncate text-zinc-700 dark:text-zinc-300`,children:e.name||e.firstMessage||`(empty)`}),e.snippet&&(0,k.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-zinc-500 dark:text-zinc-500`,children:e.snippet}),(0,k.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`:``]})]}),(0,k.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&&(0,k.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 ID({sessions:e,sessionSearch:t,sessionId:n,onSwitchSession:r,onDeleteSession:i,onListSessions:a,onRenameSession:o,onSearchSessions:s,onClearSessionSearch:c}){let[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)(``),[m,h]=(0,d.useState)(null),g=lE(()=>u(!1)),_=f.trim(),v=_.length>=2;(0,d.useEffect)(()=>{if(!l)return;if(!v){c();return}let e=setTimeout(()=>s(_),ND);return()=>clearTimeout(e)},[l,_,v]);function y(){u(!1),h(null)}let b=v&&(t?.status!==`loaded`||t.query!==_),x=v?b?null:t?.results??null:e;return(0,k.jsxs)(`div`,{className:`relative`,ref:g,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>{if(l){y();return}u(!0),p(``),h(null),c(),a()},className:`rounded-md border border-zinc-300 px-2 py-1 text-xs 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,k.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,k.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,k.jsx)(`input`,{type:`search`,value:f,onChange:e=>p(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,k.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,k.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[x===null&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),x?.length===0&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:v?`no matches`:`no saved sessions`}),x?.map(e=>(0,k.jsx)(FD,{session:e,isCurrent:e.id===n,renaming:m===e.path,onSwitch:()=>{r(e.path),y()},onDelete:()=>{window.confirm(`Delete this session?`)&&i(e.path)},onStartRename:()=>h(e.path),onRename:t=>{o(e.path,t),h(null),v&&s(f.trim())},onCancelRename:()=>h(null)},e.path))]})]})]})}function LD({theme:e,onToggle:t}){return(0,k.jsx)(`button`,{type:`button`,onClick:t,title:e===`dark`?`Switch to light theme`:`Switch to dark theme`,"aria-label":e===`dark`?`Switch to light theme`:`Switch to dark theme`,className:`rounded-md border border-zinc-300 px-2 py-1 text-xs 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===`dark`?`☀`:`☾`})}function RD(e){let{isStreaming:t,connected:n}=e;return(0,k.jsxs)(`header`,{className:`relative z-30 flex items-center gap-3 border-b border-zinc-200 px-4 py-2.5 dark:border-zinc-800`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:e.onToggleSidebar,title:e.sidebarOpen?`Hide files (panel opens on the left)`:`Show files`,"aria-pressed":e.sidebarOpen,className:`rounded-md border px-2 py-1 text-xs ${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`]}),e.gitAvailable&&(0,k.jsx)(wD,{status:e.gitStatus,log:e.gitLog,onFetchLog:e.onFetchGitLog,onShowCommit:e.onShowCommit}),(0,k.jsx)(`span`,{className:`text-lg font-semibold tracking-tight`,style:{color:`var(--accent, inherit)`},children:e.title??`π`}),Object.entries(e.statuses).map(([e,t])=>(0,k.jsx)(`span`,{className:`rounded-md border border-zinc-200 px-2 py-1 text-xs text-zinc-500 dark:border-zinc-800 dark:text-zinc-400`,children:NE(t)},e)),(0,k.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:e.onToggleHideTools,title:e.hideTools?`Show tool cards in the conversation`:`Hide tool cards (long sessions read better without them)`,"aria-pressed":e.hideTools,className:`rounded-md border px-2 py-1 text-xs ${e.hideTools?`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:`⚒ tools`}),e.showThemeToggle&&(0,k.jsx)(LD,{theme:e.theme,onToggle:e.onToggleTheme}),(0,k.jsx)(`button`,{type:`button`,onClick:e.onNewSession,title:`new session`,className:`rounded-md border border-emerald-300 px-2 py-1 text-xs 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,k.jsx)(MD,{tree:e.tree,isStreaming:t,onListTree:e.onListTree,onNavigate:e.onNavigateTree,onFork:e.onForkSession}),(0,k.jsx)(ID,{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,k.jsx)(ED,{extensionPaths:e.extensionPaths,tools:e.tools??[],commands:e.commands??[],sandbox:e.sandbox,userSkillPaths:e.userSkillPaths,serverBrowse:e.serverBrowse,applyState:e.settingsApply,versions:e.versions,onBrowseServerPath:e.onBrowseServerPath,onCloseServerBrowser:e.onCloseServerBrowser,onUpdateConfig:e.onUpdateConfig}),(0,k.jsx)(`span`,{className:`h-2 w-2 rounded-full ${n?`bg-emerald-500`:`bg-red-500`}`,title:n?`connected`:`disconnected`})]})]})}function zD(e){return!e||e.percent===null?`text-zinc-400 dark:text-zinc-600`:e.percent>=85?`text-red-500`:e.percent>=60?`text-amber-500 dark:text-amber-400`:`text-emerald-500`}function BD({usage:e,analysisOpen:t,onToggleAnalysis:n}){if(e.turns===0)return null;let r=e.turns-e.unpriced,i=[`${e.turns} turn${e.turns===1?``:`s`}`,`input ${e.input.toLocaleString()}`,`output ${e.output.toLocaleString()}`,`cache read ${e.cacheRead.toLocaleString()}`,`cache write ${e.cacheWrite.toLocaleString()}`,...e.unpriced>0&&r>0?[`${e.unpriced} unpriced`]:[]].join(` · `),a=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`span`,{children:[cT(e.totalTokens),` tok`]}),r>0&&(0,k.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-500`,children:[sT(e.cost),e.unpriced>0&&`*`]})]}),o=`flex items-center gap-1.5 rounded-md border px-2 py-1 font-mono text-xs text-zinc-500 dark:text-zinc-400`;return n?(0,k.jsx)(`button`,{type:`button`,onClick:n,title:`${i} — click for the session analysis`,"aria-haspopup":`dialog`,"aria-expanded":t??!1,className:`${o} ${t?`border-zinc-400 dark:border-zinc-600`:`border-zinc-300 hover:border-zinc-400 dark:border-zinc-800 dark:hover:border-zinc-600`}`,children:a}):(0,k.jsx)(`span`,{title:i,className:`${o} border-zinc-300 dark:border-zinc-800`,children:a})}function VD({usage:e}){let t=15.9155,n=2*Math.PI*t,r=e?.percent??0,i=Math.min(100,Math.max(0,r))/100*n;return(0,k.jsxs)(`svg`,{width:18,height:18,viewBox:`0 0 36 36`,className:`-rotate-90 shrink-0`,children:[(0,k.jsx)(`circle`,{cx:`18`,cy:`18`,r:t,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,className:`text-zinc-200 dark:text-zinc-800`}),e&&e.percent!==null&&(0,k.jsx)(`circle`,{cx:`18`,cy:`18`,r:t,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,strokeLinecap:`round`,strokeDasharray:`${i} ${n-i}`,className:zD(e)})]})}function HD({thinkingLevel:e,isStreaming:t,onSetThinking:n}){let[r,i]=(0,d.useState)(!1),a=(0,d.useRef)(null),o=e!==`off`,s=Math.max(0,JE.indexOf(e));return(0,d.useEffect)(()=>{if(!r)return;function e(e){a.current&&!cE(e,a.current)&&i(!1)}function t(e){e.key===`Escape`&&i(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]),(0,k.jsxs)(`div`,{className:`relative`,ref:a,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>i(!r),disabled:t,title:`thinking level`,"aria-haspopup":`true`,"aria-expanded":r,className:`flex items-center gap-1.5 rounded-md border px-2 py-1 font-mono text-xs disabled:opacity-50 ${o?`border-amber-300 text-amber-700 hover:border-amber-400 dark:border-amber-900 dark:text-amber-400 dark:hover:border-amber-700`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600`}`,children:[(0,k.jsx)(`span`,{"aria-hidden":!0,className:`text-sm leading-none ${o?``:`opacity-40 grayscale`}`,children:`🧠`}),e]}),r&&(0,k.jsxs)(`div`,{className:`absolute bottom-full left-0 z-20 mb-1 w-48 rounded-lg border border-zinc-200 bg-white p-3 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,k.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between text-xs`,children:[(0,k.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`thinking`}),(0,k.jsx)(`span`,{className:`font-mono text-zinc-700 dark:text-zinc-200`,children:e})]}),(0,k.jsx)(`input`,{type:`range`,min:0,max:JE.length-1,step:1,value:s,onChange:e=>n(JE[Number(e.target.value)]),"aria-label":`Thinking level`,"aria-valuetext":e,className:`w-full accent-amber-500`}),(0,k.jsxs)(`div`,{className:`mt-0.5 flex justify-between font-mono text-[9px] text-zinc-400 dark:text-zinc-600`,children:[(0,k.jsx)(`span`,{children:JE[0]}),(0,k.jsx)(`span`,{children:JE[JE.length-1]})]})]})]})}function UD(e){let{model:t,models:n,thinkingLevel:r,modelSupportsReasoning:i,isStreaming:a,contextUsage:o,sessionUsage:s,isCompacting:c}=e;return(0,k.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,k.jsxs)(`select`,{value:t,onChange:t=>{let r=n.find(e=>`${e.provider}/${e.id}`===t.target.value);r&&e.onSetModel(r.provider,r.id)},disabled:a,className:`max-w-64 rounded-md border border-zinc-300 bg-white px-2 py-1 font-mono text-xs text-zinc-700 outline-none hover:border-zinc-400 disabled:opacity-50 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-300 dark:hover:border-zinc-600`,children:[!n.some(e=>`${e.provider}/${e.id}`===t)&&(0,k.jsx)(`option`,{value:t,children:t}),n.map(e=>(0,k.jsxs)(`option`,{value:`${e.provider}/${e.id}`,children:[e.provider,`/`,e.id]},`${e.provider}/${e.id}`))]}),i&&(0,k.jsx)(HD,{thinkingLevel:r,isStreaming:a,onSetThinking:e.onSetThinking}),(0,k.jsxs)(`button`,{type:`button`,onClick:e.onCompact,disabled:a||c,title:o?.tokens==null?`Click to compact the conversation context`:`${o.tokens.toLocaleString()} / ${o.contextWindow.toLocaleString()} tokens — click to compact`,className:`ml-auto flex items-center gap-1.5 rounded-md border border-zinc-300 px-2 py-1 font-mono text-xs text-zinc-500 hover:border-zinc-400 disabled:opacity-50 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600`,children:[(0,k.jsx)(VD,{usage:o}),c?`compacting…`:o?.percent==null?`context`:`${Math.round(o.percent)}%`]}),(0,k.jsx)(BD,{usage:s,analysisOpen:e.analysisOpen,onToggleAnalysis:e.onToggleAnalysis})]})}var WD=`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`,GD=`mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400`;function KD({title:e,credentials:t,onSetCredential:n,onDeclareProvider:r,errors:i}){let a=t.providers,[o,s]=(0,d.useState)(a.length>0?`known`:`custom`),[c,l]=(0,d.useState)(a[0]?.id??``),[u,f]=(0,d.useState)(``),[p,m]=(0,d.useState)(``),[h,g]=(0,d.useState)(``),[_,v]=(0,d.useState)(``),[y,b]=(0,d.useState)(!0),[x,S]=(0,d.useState)(!0),C=a.some(e=>e.configured)&&!t.usableModel;function w(e){if(e.preventDefault(),!C){if(o===`known`){c&&u.trim()&&n(c,u.trim());return}!p.trim()||!h.trim()||!u.trim()||!_.trim()||r({provider:p.trim(),baseUrl:h.trim(),apiKey:u.trim(),models:[_.trim()],compat:{supportsDeveloperRole:y,supportsReasoningEffort:x}})}}return(0,k.jsx)(`div`,{className:`flex h-full items-center justify-center overflow-auto p-6`,children:(0,k.jsxs)(`form`,{onSubmit:w,className:`w-full max-w-md rounded-xl border border-zinc-200 p-6 shadow-sm dark:border-zinc-800`,children:[(0,k.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),C?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`h1`,{className:`mb-3 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`No model is available.`}),(0,k.jsxs)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:[`Credentials are configured, so this is not a missing key: `,(0,k.jsx)(`code`,{children:`allowedModels`}),` in your configuration leaves nothing to choose from. Widen it, or remove it, then restart.`]})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`h1`,{className:`mb-4 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`No model provider is set up yet. Add one to start chatting.`}),(0,k.jsx)(`div`,{className:`mb-4 flex gap-1 rounded-lg bg-zinc-100 p-1 text-xs dark:bg-zinc-800`,children:[`known`,`custom`].map(e=>(0,k.jsx)(`button`,{type:`button`,onClick:()=>s(e),className:`flex-1 rounded-md px-2 py-1.5 ${o===e?`bg-white font-medium text-zinc-800 shadow-sm dark:bg-zinc-900 dark:text-zinc-100`:`text-zinc-500 dark:text-zinc-400`}`,children:e===`known`?`Provider API key`:`OpenAI-compatible endpoint`},e))}),o===`known`?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`label`,{htmlFor:`onboarding-provider`,className:GD,children:`Provider`}),(0,k.jsx)(`select`,{id:`onboarding-provider`,value:c,onChange:e=>l(e.target.value),className:`${WD} mb-3`,children:a.map(e=>(0,k.jsxs)(`option`,{value:e.id,children:[e.name,e.configured?` (already configured)`:``]},e.id))})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`label`,{htmlFor:`onboarding-name`,className:GD,children:`Name`}),(0,k.jsx)(`input`,{id:`onboarding-name`,value:p,onChange:e=>m(e.target.value),placeholder:`corp`,className:`${WD} mb-3`}),(0,k.jsx)(`label`,{htmlFor:`onboarding-url`,className:GD,children:`Base URL`}),(0,k.jsx)(`input`,{id:`onboarding-url`,value:h,onChange:e=>g(e.target.value),placeholder:`https://llm.corp.example/v1`,className:`${WD} mb-3`}),(0,k.jsx)(`label`,{htmlFor:`onboarding-model`,className:GD,children:`Model id`}),(0,k.jsx)(`input`,{id:`onboarding-model`,value:_,onChange:e=>v(e.target.value),placeholder:`gpt-oss-120b`,className:`${WD} mb-3`})]}),(0,k.jsx)(`label`,{htmlFor:`onboarding-key`,className:GD,children:`API key`}),(0,k.jsx)(`input`,{id:`onboarding-key`,type:`password`,autoComplete:`off`,value:u,onChange:e=>f(e.target.value),placeholder:`sk-…`,className:WD}),o===`custom`&&(0,k.jsxs)(`fieldset`,{className:`mt-4 rounded-lg border border-zinc-200 p-3 dark:border-zinc-800`,children:[(0,k.jsx)(`legend`,{className:`px-1 text-xs text-zinc-500 dark:text-zinc-400`,children:`Compatibility`}),(0,k.jsxs)(`label`,{className:`flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:y,onChange:e=>b(e.target.checked),className:`mt-0.5`}),(0,k.jsxs)(`span`,{children:[`Server understands the `,(0,k.jsx)(`code`,{children:`developer`}),` role. Uncheck for vLLM, SGLang and most corporate gateways — the system prompt is then sent as a `,(0,k.jsx)(`code`,{children:`system`}),` message.`]})]}),(0,k.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked),className:`mt-0.5`}),(0,k.jsxs)(`span`,{children:[`Server accepts `,(0,k.jsx)(`code`,{children:`reasoning_effort`}),`. Uncheck if it rejects unknown fields.`]})]})]}),(0,k.jsx)(`button`,{type:`submit`,className:`mt-4 w-full rounded-md bg-zinc-800 px-3 py-2 text-sm font-medium text-white hover:bg-zinc-700 dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-white`,children:`Save and start`})]}),i.map((e,t)=>(0,k.jsx)(`p`,{className:`mt-3 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-700 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:e},t)),(0,k.jsxs)(`p`,{className:`mt-4 text-center text-xs text-zinc-400 dark:text-zinc-600`,children:[t.agentDir?`Stored in ${t.agentDir}. `:``,`Provider environment variables work too, as does `,(0,k.jsx)(`code`,{children:`pi-outpost login`}),`.`]})]})})}var qD=`application/x-pi-outpost-file`,JD=`application/x-pi-outpost-read-only-file`,YD=`mr-1 shrink-0 rounded px-1 text-xs text-zinc-400 hover:bg-zinc-200 group-hover:opacity-100 focus-visible:opacity-100 dark:text-zinc-600 dark:hover:bg-zinc-700 [@media(hover:hover)]:opacity-0`,XD={modified:{label:`M`,className:`text-amber-600 dark:text-amber-400`},added:{label:`A`,className:`text-emerald-600 dark:text-emerald-400`},untracked:{label:`U`,className:`text-emerald-600 dark:text-emerald-400`},deleted:{label:`D`,className:`text-red-600 dark:text-red-400`},conflicted:{label:`C`,className:`text-purple-600 dark:text-purple-400`}};function ZD(e,t){return t?Object.keys(t).filter(t=>t.startsWith(`${e}/`)).length:0}function QD(e){return e===`directory`||e===`symlink-directory`}function $D(e,t){return t===void 0?!1:t===null||t!==``&&e!==t&&!e.startsWith(`${t}/`)}function eO({dir:e,depth:t,creation:n}){let[r,i]=(0,d.useState)(``),a=(0,d.useRef)(null),o=n.localError??n.serverError;return(0,d.useEffect)(()=>{a.current?.focus()},[]),(0,k.jsxs)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5`,children:[(0,k.jsx)(`input`,{ref:a,value:r,onChange:e=>i(e.target.value),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),n.submit(e,r)):t.key===`Escape`&&(t.preventDefault(),n.cancel())},onBlur:()=>{o===null&&n.cancel()},placeholder:`name, or name/ for a folder`,"aria-label":`New file or folder in ${e===``?`the workspace root`:e}`,spellCheck:!1,className:`w-full rounded border border-zinc-300 bg-white px-1 py-0.5 text-xs text-zinc-800 outline-none focus:border-zinc-400 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200`}),o!==null&&(0,k.jsx)(`p`,{className:`px-1 pt-0.5 text-xs text-red-600 dark:text-red-400`,children:o})]})}function tO({path:e,name:t,depth:n,rename:r}){let[i,a]=(0,d.useState)(t),o=(0,d.useRef)(null),s=r.localError??r.serverError;return(0,d.useEffect)(()=>{o.current?.focus(),o.current?.select()},[]),(0,k.jsxs)(`div`,{style:{paddingLeft:n*12+16},className:`py-0.5`,children:[(0,k.jsx)(`input`,{ref:o,value:i,disabled:r.pending,onChange:e=>a(e.target.value),onKeyDown:t=>{t.key===`Enter`&&!r.pending?(t.preventDefault(),r.submit(e,i)):t.key===`Escape`&&(t.preventDefault(),r.cancel())},onBlur:()=>{s===null&&r.cancel()},"aria-label":`Rename ${t}`,spellCheck:!1,className:`w-full rounded border border-zinc-300 bg-white px-1 py-0.5 text-xs text-zinc-800 outline-none focus:border-zinc-400 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200`}),s!==null&&(0,k.jsx)(`p`,{className:`px-1 pt-0.5 text-xs text-red-600 dark:text-red-400`,children:s})]})}function nO({path:e,depth:t,...n}){let r=n.tree[e],i=n.creation?.openIn===e?(0,k.jsx)(eO,{dir:e,depth:t,creation:n.creation}):null;return r===void 0?i:r===`loading`?(0,k.jsxs)(k.Fragment,{children:[i,(0,k.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:`loading…`})]}):`error`in r?(0,k.jsxs)(k.Fragment,{children:[i,(0,k.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-red-600 dark:text-red-400`,children:r.error})]}):r.length===0?(0,k.jsxs)(k.Fragment,{children:[i,i===null&&(0,k.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:`empty`})]}):(0,k.jsxs)(k.Fragment,{children:[i,r.map(r=>(0,k.jsx)(rO,{parentPath:e,entry:r,depth:t,...n},r.name))]})}function rO({parentPath:e,entry:t,depth:n,...r}){let[i,a]=(0,d.useState)(!1),[o,s]=(0,d.useState)(!1),c=e?`${e}/${t.name}`:t.name,l=$D(c,r.writableRoot),u=r.fileOperation?.status===`pending`;if(QD(t.type)){let e=!l&&!u,d=e=>e.includes(JD)?r.onCopyFile===void 0?null:`copy`:r.onMoveFile===void 0?null:`move`;return(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:`group flex w-full items-center rounded hover:bg-zinc-100 dark:hover:bg-zinc-800 ${o?`bg-blue-50 ring-1 ring-blue-400 dark:bg-blue-950/40`:``}`,onDragOver:t=>{if(!e||!Array.from(t.dataTransfer.types).includes(qD))return;let n=d(Array.from(t.dataTransfer.types));n!==null&&(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=n,s(!0))},onDragLeave:()=>s(!1),onDrop:t=>{if(!e)return;let n=t.dataTransfer.getData(qD),i=n?d(Array.from(t.dataTransfer.types)):null;i!==null&&(t.preventDefault(),t.stopPropagation(),s(!1),i===`copy`?r.onCopyFile?.(n,c):r.onMoveFile?.(n,c))},children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>{let e=!i;a(e),e&&r.tree[c]===void 0&&r.onExpand(c)},style:{paddingLeft:n*12},className:`flex min-w-0 flex-1 items-center gap-1 rounded py-0.5 text-left`,children:[(0,k.jsx)(`span`,{className:`w-3 shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:i?`▾`:`▸`}),(0,k.jsx)(`span`,{title:t.name,className:`truncate ${l?`text-zinc-400 dark:text-zinc-600`:`text-zinc-700 dark:text-zinc-300`}`,children:t.name}),!i&&ZD(c,r.gitFiles)>0&&(0,k.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-amber-100 px-1 font-mono text-[10px] font-bold text-amber-700 dark:bg-amber-950/60 dark:text-amber-400`,title:`${ZD(c,r.gitFiles)} changed file(s) inside`,children:ZD(c,r.gitFiles)})]}),r.creation&&!l&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>{a(!0),r.tree[c]===void 0&&r.onExpand(c),r.creation?.start(c)},title:`New file or folder here`,"aria-label":`New file or folder in ${t.name}`,className:`mr-1 shrink-0 rounded px-1 font-mono text-xs text-zinc-400 hover:bg-zinc-200 group-hover:opacity-100 focus-visible:opacity-100 dark:text-zinc-600 dark:hover:bg-zinc-700 [@media(hover:hover)]:opacity-0`,children:`+`})]}),i&&(0,k.jsx)(nO,{path:c,depth:n+1,...r})]})}let f=c===r.openFilePath,p=r.gitFiles?.[c],m=r.attachedPaths?.includes(c)??!1,h=t.type===`file`,g=h||t.type===`symlink-file`,_=h&&!l,v=h&&(l?r.onCopyFile!==void 0:r.onMoveFile!==void 0);return r.rename?.path===c?(0,k.jsx)(tO,{path:c,name:t.name,depth:n,rename:r.rename}):(0,k.jsxs)(`div`,{className:`group flex w-full items-center rounded hover:bg-zinc-100 dark:hover:bg-zinc-800 ${f?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:[(0,k.jsx)(`button`,{type:`button`,draggable:v&&!u,onDragStart:e=>{!v||u||(e.dataTransfer.effectAllowed=l?`copy`:`move`,e.dataTransfer.setData(qD,c),l&&e.dataTransfer.setData(JD,`copy`))},onClick:()=>r.onSelectFile(c),style:{paddingLeft:n*12+16},className:`flex min-w-0 flex-1 items-center py-0.5 text-left`,children:(0,k.jsx)(`span`,{title:t.name,className:`truncate ${l?`text-zinc-400 dark:text-zinc-600`:`text-zinc-600 dark:text-zinc-400`}`,children:t.name})}),g&&r.onOpenNative&&(0,k.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>r.onOpenNative?.(c),title:`Open with the associated application`,"aria-label":`Open ${t.name} with the associated application`,className:YD,children:`↗`}),_&&r.onRenameFile&&(0,k.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>r.rename?.start(c),title:`Rename file`,"aria-label":`Rename ${t.name}`,className:YD,children:`✎`}),_&&r.onDeleteFile&&(0,k.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>{window.confirm(`Delete "${t.name}" permanently?`)&&r.onDeleteFile?.(c)},title:`Delete file`,"aria-label":`Delete ${t.name}`,className:`${YD} hover:text-red-600 dark:hover:text-red-400`,children:`×`}),r.onToggleAttachPath&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>r.onToggleAttachPath?.(c),title:m?`Remove this file from the prompt`:`Reference this file in the prompt`,"aria-label":`${m?`Remove`:`Reference`} ${t.name} in the prompt`,"aria-pressed":m,className:`mr-1 shrink-0 rounded px-1 font-mono text-xs hover:bg-zinc-200 group-hover:opacity-100 focus-visible:opacity-100 dark:hover:bg-zinc-700 ${m?`font-bold text-blue-600 dark:text-blue-400`:`text-zinc-400 dark:text-zinc-600 [@media(hover:hover)]:opacity-0`}`,children:`@`}),p&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>(r.onSelectDiff??r.onSelectFile)(c),title:`Show uncommitted diff`,"aria-label":`Show diff of ${t.name}`,className:`mr-1 shrink-0 rounded px-1 font-mono text-xs font-bold hover:bg-zinc-200 dark:hover:bg-zinc-700 ${XD[p].className}`,children:XD[p].label})]})}function iO(e){let t=e.trim();if(t===``)return{error:`A name is required`};let n=t.endsWith(`/`),r=n?t.slice(0,-1).trim():t;return r===``?{error:`A name is required`}:r.includes(`/`)||r.includes(`\\`)?{error:`That is a path, not a name`}:r===`.`||r===`..`?{error:`"${r}" is not a name`}:{kind:n?`directory`:`file`,name:r}}function aO(e){let t=iO(e);return`error`in t?t:t.kind===`directory`?{error:`That is a folder name`}:{name:t.name}}function oO(e){let[t,n]=(0,d.useState)(null),[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(null),[f,p]=(0,d.useState)(null),m=e.onCreateFile!==void 0||e.onCreateDirectory!==void 0,h=e.createError&&a&&e.createError.path===sO(a.dir,a.name)?e.createError.message:null,g=e.created??null;(0,d.useEffect)(()=>{a!==null&&g!==null&&g===sO(a.dir,a.name)&&(n(null),o(null),i(null))},[a,g]);let _=e.fileOperation?.status===`error`&&e.fileOperation.operation===`rename_file`&&f===e.fileOperation.path?e.fileOperation.message:null;(0,d.useEffect)(()=>{let t=e.fileOperation;t?.status===`succeeded`&&t.operation===`rename_file`&&f===t.path&&(c(null),p(null),u(null))},[f,e.fileOperation]);let v=m?{openIn:t,localError:r,serverError:h,start:e=>{n(e),i(null),o(null)},cancel:()=>{n(null),i(null),o(null)},submit:(t,n)=>{let r=iO(n);if(`error`in r){i(r.error);return}i(null),o({dir:t,name:r.name});let a=sO(t,r.name);r.kind===`directory`?e.onCreateDirectory?.(a):e.onCreateFile?.(a)}}:void 0,y=e.onRenameFile?{path:s,pending:f!==null&&e.fileOperation?.status===`pending`&&e.fileOperation.operation===`rename_file`&&e.fileOperation.path===f,localError:l,serverError:_,start:e=>{c(e),p(null),u(null)},cancel:()=>{c(null),p(null),u(null)},submit:(t,n)=>{if(n.trim()===``){c(null),p(null),u(null);return}let r=aO(n);if(`error`in r){u(r.error);return}u(null),p(t),e.onRenameFile?.(t,r.name)}}:void 0,b=!$D(``,e.writableRoot);return(0,k.jsxs)(`div`,{className:`text-sm`,children:[e.fileOperation?.status===`error`&&e.fileOperation.operation!==`rename_file`&&(0,k.jsx)(`p`,{role:`alert`,className:`mb-1 rounded bg-red-50 px-2 py-1 text-xs text-red-700 dark:bg-red-950/40 dark:text-red-300`,children:e.fileOperation.message}),(v&&b||e.onRefresh)&&(0,k.jsxs)(`div`,{className:`mb-1 flex items-center`,children:[v&&b&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>v.start(``),"aria-label":`New file or folder in the workspace root`,className:`rounded px-1 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-600 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-400`,children:`+ new`}),e.onRefresh&&(0,k.jsx)(`button`,{type:`button`,onClick:e.onRefresh,title:`Refresh the file tree`,"aria-label":`Refresh the file tree`,className:`ml-auto rounded px-1 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-600 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-400`,children:`↻`})]}),(0,k.jsx)(nO,{path:``,depth:0,...e,...v?{creation:v}:{},...y?{rename:y}:{}})]})}function sO(e,t){return e===``?t:`${e}/${t}`}function cO({tree:e,openFile:t,writableRoot:n,gitFiles:r,attachedPaths:i,onExpand:a,onRefresh:o,onSelectFile:s,onSelectDiff:c,onToggleAttachPath:l,onCreateFile:u,onCreateDirectory:f,onOpenNative:p,onRenameFile:m,onDeleteFile:h,onMoveFile:g,onCopyFile:_,fileOperation:v,createError:y,created:b}){let x=nD(XE);return(0,d.useEffect)(()=>{e[``]===void 0&&a(``)},[]),(0,k.jsxs)(`aside`,{"aria-label":`Files`,style:{width:x.width},className:`relative flex shrink-0 flex-col border-r border-zinc-200 dark:border-zinc-800`,children:[(0,k.jsx)(`div`,{className:`border-b border-zinc-200 px-3 py-2 text-xs font-semibold uppercase text-zinc-400 dark:border-zinc-800 dark:text-zinc-600`,children:`Files`}),(0,k.jsx)(`div`,{className:`flex-1 overflow-auto p-2`,children:(0,k.jsx)(oO,{tree:e,openFilePath:t?.path,writableRoot:n,gitFiles:r,attachedPaths:i,onExpand:a,onRefresh:o,onSelectFile:s,onSelectDiff:c,onToggleAttachPath:l,onCreateFile:u,onCreateDirectory:f,onOpenNative:p,onRenameFile:m,onDeleteFile:h,onMoveFile:g,onCopyFile:_,fileOperation:v,createError:y,created:b})}),(0,k.jsx)(rD,{label:`Resize Files sidebar`,width:x.width,config:XE,separatorProps:x.separatorProps})]})}function lO({title:e,onSubmit:t}){let[n,r]=(0,d.useState)(``);return(0,k.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,k.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),n.trim()&&t(n.trim())},className:`w-full max-w-sm rounded-xl border border-zinc-200 p-6 shadow-sm dark:border-zinc-800`,children:[(0,k.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),(0,k.jsx)(`h1`,{className:`mb-4 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`This server requires an access token.`}),(0,k.jsx)(`label`,{htmlFor:`pi-outpost-token`,className:`mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400`,children:`Access token`}),(0,k.jsx)(`input`,{id:`pi-outpost-token`,name:`token`,type:`password`,autoComplete:`off`,spellCheck:!1,value:n,onChange:e=>r(e.target.value),placeholder:`paste the token…`,className:`mb-3 w-full rounded-md border border-zinc-300 bg-white px-2 py-1.5 font-mono text-sm outline-none focus:border-zinc-500 dark:border-zinc-700 dark:bg-zinc-950 dark:focus:border-zinc-500`}),(0,k.jsx)(`button`,{type:`submit`,disabled:!n.trim(),className:`w-full rounded-md border border-emerald-300 px-2 py-1.5 text-sm text-emerald-700 hover:border-emerald-500 disabled:opacity-50 dark:border-emerald-900 dark:text-emerald-400 dark:hover:border-emerald-600`,children:`Connect`}),(0,k.jsxs)(`p`,{className:`mt-3 text-center text-xs text-zinc-400 dark:text-zinc-600`,children:[`Ask the operator for the token, or open the link containing `,(0,k.jsx)(`code`,{children:`?token=…`})]})]})})}var uO={todo:{icon:`○`,label:`To do`,className:`text-zinc-500`},in_progress:{icon:`●`,label:`In progress`,className:`text-blue-600 dark:text-blue-400`},done:{icon:`✓`,label:`Done`,className:`text-emerald-600 dark:text-emerald-400`},blocked:{icon:`!`,label:`Blocked`,className:`text-red-600 dark:text-red-400`},needs_review:{icon:`?`,label:`Needs review`,className:`text-amber-600 dark:text-amber-400`}},dO=8;function fO(e){let t=e.uri.startsWith(`workspace:`)?e.uri.slice(10):/^[a-z][a-z0-9+.-]*:/i.test(e.uri)?null:e.uri;return t===null||t===``||/^(?:[\\/]|[a-z]:[\\/])/i.test(t)||t.replaceAll(`\\`,`/`).split(`/`).includes(`..`)?null:t}function pO({plan:e,open:t,onToggle:n,onOpenWorkspace:r}){let i=(0,d.useId)(),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(null);(0,d.useEffect)(()=>{s!==null&&!e.tasks.some(e=>e.id===s)&&c(null)},[e,s]),(0,d.useEffect)(()=>{if(!a)return;let e=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]);let l=(0,d.useMemo)(()=>{let t=new Map;for(let n of e.tasks)t.set(n.parentId,[...t.get(n.parentId)??[],n]);return t},[e.tasks]),u=(0,d.useMemo)(()=>new Map(e.tasks.map(e=>[e.id,e])),[e.tasks]),f=(0,d.useMemo)(()=>{let e=[],t=(n,r)=>{for(let i of l.get(n)??[])e.push({task:i,depth:r}),t(i.id,r+1)};return t(void 0,0),e.slice(0,dO)},[l]),p=s?u.get(s):void 0,m=e.tasks.filter(e=>e.status===`done`).length,h=(e,t=0)=>(l.get(e)??[]).flatMap(e=>{let n=uO[e.status];return[(0,k.jsxs)(`button`,{type:`button`,role:`treeitem`,"aria-level":t+1,"aria-selected":s===e.id,onClick:()=>c(e.id),"aria-current":e.status===`in_progress`?`step`:void 0,className:`flex w-full items-start gap-2 rounded px-2 py-1.5 text-left text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800 ${s===e.id?`bg-zinc-100 dark:bg-zinc-800`:``}`,style:{paddingLeft:`${.5+t*.85}rem`},children:[(0,k.jsx)(`span`,{className:`mt-px w-4 shrink-0 text-center font-semibold ${n.className}`,"aria-label":n.label,children:n.icon}),(0,k.jsx)(`span`,{className:e.status===`done`?`text-zinc-500 line-through`:`text-zinc-800 dark:text-zinc-200`,children:e.title})]},e.id),...h(e.id,t+1)]});return t?(0,k.jsxs)(`aside`,{"aria-label":`Work Plan`,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-[23rem] dark:border-zinc-800 dark:bg-zinc-950/95`,children:[(0,k.jsxs)(`header`,{className:`border-b border-zinc-200 px-3 py-3 dark:border-zinc-800`,children:[(0,k.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-zinc-500`,children:`Work Plan`}),(0,k.jsx)(`h2`,{className:`truncate text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:e.title})]}),(0,k.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`,"aria-label":`Close Work Plan`,children:`×`})]}),(0,k.jsxs)(`div`,{className:`mt-2 text-xs text-zinc-500`,children:[`Progress: `,m,` / `,e.tasks.length]}),(0,k.jsx)(`div`,{className:`mt-1 h-1.5 overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-800`,"aria-hidden":!0,children:(0,k.jsx)(`div`,{className:`h-full bg-emerald-500`,style:{width:`${e.tasks.length===0?0:m/e.tasks.length*100}%`}})})]}),(0,k.jsx)(`div`,{role:`tree`,"aria-label":`Work Plan tasks`,className:`min-h-0 flex-1 overflow-y-auto p-2`,children:h(void 0)}),p&&(0,k.jsxs)(`section`,{"aria-label":`Task details`,className:`max-h-[45%] overflow-y-auto border-t border-zinc-200 p-3 text-xs dark:border-zinc-800`,children:[(0,k.jsx)(`div`,{className:`font-semibold ${uO[p.status].className}`,children:uO[p.status].label}),(0,k.jsx)(`h3`,{className:`mt-1 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:p.title}),p.description&&(0,k.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-zinc-600 dark:text-zinc-300`,children:p.description}),p.statusReason&&(0,k.jsx)(`p`,{className:`mt-2 rounded bg-zinc-100 p-2 text-zinc-700 dark:bg-zinc-900 dark:text-zinc-300`,children:p.statusReason}),p.dependsOn.length>0&&(0,k.jsxs)(`div`,{className:`mt-3`,children:[(0,k.jsx)(`span`,{className:`font-semibold`,children:`Depends on:`}),` `,p.dependsOn.map(e=>u.get(e)?.title??e).join(`, `)]}),p.resources.length>0&&(0,k.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[(0,k.jsx)(`div`,{className:`font-semibold`,children:`Resources`}),p.resources.map(e=>{let t=fO(e),n=e.label??e.uri;return t===null?/^https?:/i.test(e.uri)?(0,k.jsx)(`a`,{href:e.uri,target:`_blank`,rel:`noreferrer`,className:`block truncate text-blue-600 hover:underline dark:text-blue-400`,children:n},e.uri):(0,k.jsx)(`span`,{className:`block truncate text-zinc-500`,title:`No navigator is available for this resource`,children:n},e.uri):(0,k.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left text-blue-600 hover:underline dark:text-blue-400`,onClick:()=>r(t),children:n},e.uri)})]})]})]}):(0,k.jsxs)(`div`,{className:`absolute right-3 top-3 z-20`,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),onFocusCapture:()=>o(!0),onBlurCapture:()=>o(!1),children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>{o(!1),n()},className:`rounded-md border border-zinc-300 bg-white px-2 py-1 text-xs shadow-sm dark:border-zinc-700 dark:bg-zinc-900`,"aria-label":`Open Work Plan`,"aria-describedby":i,children:[`Plan `,m,`/`,e.tasks.length]}),(0,k.jsx)(`div`,{id:i,role:`tooltip`,className:`absolute right-0 top-full w-72 pt-2 ${a?`block`:`hidden`}`,children:(0,k.jsxs)(`div`,{className:`rounded-md border border-zinc-200 bg-white p-2 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,k.jsx)(`ul`,{className:`space-y-1`,children:f.map(({task:e,depth:t})=>(0,k.jsxs)(`li`,{className:`flex min-w-0 items-start gap-1.5 text-xs`,style:{paddingLeft:`${t*.75}rem`},children:[(0,k.jsx)(`span`,{"aria-label":uO[e.status].label,className:`shrink-0 font-semibold ${uO[e.status].className}`,children:e.status===`done`?`☑`:`☐`}),(0,k.jsx)(`span`,{className:`truncate ${e.status===`done`?`text-zinc-500 line-through`:`text-zinc-800 dark:text-zinc-200`}`,children:e.title})]},e.id))}),e.tasks.length>f.length&&(0,k.jsxs)(`div`,{className:`mt-1 text-[11px] text-zinc-500`,children:[`+`,e.tasks.length-f.length,` more`]})]})})]})}var mO=`pi-outpost:token`;function hO(){let e=null;try{let t=new URL(window.location.href);return e=t.searchParams.get(`token`),e&&(localStorage.setItem(mO,e),t.searchParams.delete(`token`),window.history.replaceState(null,``,`${t.pathname}${t.search}${t.hash}`)),localStorage.getItem(mO)}catch{return e}}function gO(){try{return localStorage.getItem(mO)}catch{return null}}function _O(e){try{localStorage.setItem(mO,e)}catch{}}function vO(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}function yO(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}var bO={connected:!1,authRequired:!1,brandingReady:!1,branding:{},sessionId:``,model:``,thinkingLevel:`off`,modelSupportsReasoning:!1,models:[],commands:[],sessions:null,sessionSearch:null,tree:null,isStreaming:!1,items:[],workPlan:null,queue:{steering:[],followUp:[]},errors:[],contextUsage:null,isCompacting:!1,dialogQueue:[],notifications:[],statuses:{},widgets:{},editorPrefill:null,fileTree:{},directoryRequests:{},openFile:null,previewRevision:0,fileSearch:null,createError:null,created:null,fileOperation:null,extensionPaths:[],tools:[],sandbox:null,userSkillPaths:[],serverBrowse:null,settingsApply:null,versions:null,gitAvailable:!1,credentials:null,gitStatus:null,gitDiff:null,gitLog:null,gitShow:null,gitFileHistory:null,gitFileDiff:null};function xO(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 SO(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 CO(e,t){if(t.type!==`hello`&&t.type!==`session_replaced`&&t.type!==`update_config_ack`)return e;let n=t.models.find(e=>`${e.provider}/${e.id}`===t.model);return{...e,connected:!0,brandingReady:!0,branding:t.branding,sessionId:t.sessionId,model:t.model,thinkingLevel:t.thinkingLevel,modelSupportsReasoning:n?.reasoning??!1,models:t.models,commands:t.commands,isStreaming:t.isStreaming,items:t.items,workPlan:t.workPlan??null,queue:{steering:[],followUp:[]},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,gitAvailable:t.gitAvailable===!0,credentials:t.credentials??null,extensionPaths:t.extensionPaths??[],tools:t.tools??[],sandbox:t.sandbox??null,userSkillPaths:t.userSkillPaths??[],serverBrowse:null,settingsApply:null,versions:t.versions??null}}function wO(e,t){if(t.type===`connected`)return{...e,connected:!0,authRequired:!1};if(t.type===`auth_required`)return{...e,connected:!1,authRequired:!0};if(t.type===`auth_retrying`)return{...e,authRequired:!1};if(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;return{...e,connected:!1,openFile:n}}if(t.type===`branding_settled`)return{...e,brandingReady:!0};if(t.type===`branding_loaded`)return{...e,brandingReady:!0,branding:t.branding};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}}}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===`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===`git_diff_started`||t.type===`git_diff_cleared`)return{...e,gitDiff:null};if(t.type===`git_show_cleared`)return{...e,gitShow:null,gitLog:e.gitLog};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`}};let n=t.message;switch(n.type){case`hello`:case`session_replaced`:case`update_config_ack`:return CO(e,n);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};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,credentials:n.credentials}}case`thinking_changed`:return{...e,thinkingLevel:n.level};case`work_plan_changed`:return{...e,workPlan:n.workPlan};case`user`:return{...e,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,queue:{steering:[],followUp:[]},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:xO(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:xO(e.items,()=>n.item)};case`custom_message`:return{...e,items:[...e.items,n.item]};case`tool_start`:return{...e,items:SO(e.items,n.toolCallId,n.toolName,{toolName:n.toolName,args:n.args,running:!0,callHtml:n.callHtml})};case`tool_update`:return{...e,items:SO(e.items,n.toolCallId,`tool`,{output:n.text})};case`tool_end`:return{...e,items:SO(e.items,n.toolCallId,`tool`,{output:n.text,isError:n.isError,running:!1,outputHtml:n.outputHtml,outputHtmlCollapsed:n.outputHtmlCollapsed,structured:n.structured})};case`queue`:return{...e,queue:{steering:n.steering,followUp:n.followUp}};case`context_usage`:return{...e,contextUsage:n.usage};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],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}}}}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;return{...e,openFile:r,gitFileHistory:i?null:e.gitFileHistory,gitFileDiff:i?null:e.gitFileDiff,gitDiff:a?null:e.gitDiff,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`git_status`:{let t={};for(let e of n.files)t[e.path]=e.status;return{...e,gitStatus:{branch:n.branch,ahead:n.ahead,behind:n.behind,files:t}}}case`git_diff`:return{...e,gitDiff:{path:n.path,before:n.before,after:n.after}};case`git_log`:return{...e,gitLog:n.entries};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||!yO(e.gitFileDiff,n)?e:{...e,gitFileDiff:{...e.gitFileDiff,status:`loaded`,beforeText:n.beforeText,afterText:n.afterText}};case`git_error`:return 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}}:{...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 TO(e,t){let n=e?`${e.replace(/^http/,`ws`)}/ws`:`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/ws`;return t?`${n}?token=${encodeURIComponent(t)}`:n}var EO=12e4,DO=4401;function OO(e=``,t,n=!1){let[r,i]=(0,d.useReducer)(wO,bO),a=(0,d.useRef)(null),[o,s]=(0,d.useState)(0),c=(0,d.useRef)(null);o===0&&c.current===null&&(c.current=t??(n?gO():hO()));let l=(0,d.useRef)(r.fileTree),u=(0,d.useRef)(r.openFile);(0,d.useEffect)(()=>{l.current=r.fileTree},[r.fileTree]),(0,d.useEffect)(()=>{u.current=r.openFile},[r.openFile]);let f=(0,d.useRef)(null);(0,d.useEffect)(()=>{f.current=r.gitDiff?.path??null},[r.gitDiff]);let p=(0,d.useRef)(new Map),m=(0,d.useRef)(r.writableRoot);(0,d.useEffect)(()=>{m.current=r.writableRoot},[r.writableRoot]);let h=(0,d.useCallback)(e=>{let t=a.current;t&&t.readyState===WebSocket.OPEN&&t.send(JSON.stringify(e))},[]),g=(0,d.useCallback)((e,t=!1)=>{let n=`dir:${crypto.randomUUID()}`;i({type:`dir_list_started`,path:e,requestId:n,preserveEntries:t}),h({type:`list_directory`,path:e,requestId:n})},[h]),_=(0,d.useRef)(!1),v=(0,d.useRef)(!1),y=(0,d.useRef)(!1),b=(0,d.useCallback)(()=>{if(_.current){if(v.current){y.current=!0;return}v.current=!0,h({type:`git_status`,requestId:`git:${crypto.randomUUID()}`})}},[h]),x=(0,d.useCallback)(()=>{v.current=!1,y.current&&(y.current=!1,b())},[b]),S=(0,d.useCallback)(e=>{l.current[e]!==void 0&&g(e,!0)},[g]),C=(0,d.useCallback)(()=>{for(let e of Object.keys(l.current))S(e)},[S]);return(0,d.useEffect)(()=>{let t=!1;return fetch(`${e}/branding`,{headers:c.current?{Authorization:`Bearer ${c.current}`}:{}}).then(e=>e.ok?e.json():null).then(e=>{t||i(e?{type:`branding_loaded`,branding:e}:{type:`branding_settled`})}).catch(()=>{t||i({type:`branding_settled`})}),()=>{t=!0}},[e,o]),(0,d.useEffect)(()=>{let t,n=!1;function r(){let o=new WebSocket(TO(e,c.current));a.current=o,o.onopen=()=>{a.current===o&&i({type:`connected`})},o.onmessage=e=>{if(a.current!==o)return;let t;try{t=JSON.parse(e.data)}catch{return}if(t.type===`file_uploaded`){let e=p.current.get(t.requestId);e&&(p.current.delete(t.requestId),e.resolve(t.path));return}if(t.type===`file_browser_error`&&p.current.has(t.requestId)){let e=p.current.get(t.requestId);p.current.delete(t.requestId),e.reject(new LT(t.message,t.reason));return}if(t.type===`file_changed`){S(vO(t.path));let e=u.current;if(e?.status===`loaded`&&e.path===t.path){let e=`file:${crypto.randomUUID()}`;i({type:`file_read_started`,path:t.path,requestId:e,preserveContent:!0}),h({type:`read_file`,path:t.path,requestId:e})}f.current===t.path&&h({type:`git_diff`,path:t.path,requestId:`gitdiff:${crypto.randomUUID()}`}),b();return}if(t.type===`directory_changed`){S(t.path);let e=u.current;if(e!==null&&vO(e.path)===t.path){if(te(e.path)||ne(e.path))i({type:`raw_preview_changed`,path:e.path});else if(e.status===`loaded`){let t=`file:${crypto.randomUUID()}`;i({type:`file_read_started`,path:e.path,requestId:t,preserveContent:!0}),h({type:`read_file`,path:e.path,requestId:t})}}let n=f.current;n!==null&&vO(n)===t.path&&h({type:`git_diff`,path:n,requestId:`gitdiff:${crypto.randomUUID()}`}),b();return}if((t.type===`hello`||t.type===`session_replaced`)&&(_.current=t.gitAvailable===!0,t.type===`hello`&&b()),t.type===`agent_end`&&b(),(t.type===`git_status`||t.type===`git_error`&&t.requestId.startsWith(`git:`))&&x(),t.type===`file_operation_result`){let e=t.previousPath??t.path,n=u.current;t.operation===`delete_file`&&n?.path===t.path?u.current=null:n?.path===e&&(u.current={...n,path:t.path})}i({type:`server`,message:t}),t.type===`session_replaced`&&g(``)},o.onclose=e=>{if(a.current===o){v.current=!1,y.current=!1;for(let e of p.current.values())e.reject(new LT(`The connection dropped before the upload finished`));if(p.current.clear(),e.code===DO){i({type:`auth_required`});return}i({type:`disconnected`}),n||(t=window.setTimeout(r,1500))}}}return r(),()=>{n=!0,t!==void 0&&clearTimeout(t);let e=a.current;a.current=null,e?.close()}},[h,e,b,x,S,g,o]),{state:r,authToken:c.current,submitToken:e=>{_O(e),c.current=e,i({type:`auth_retrying`}),s(e=>e+1)},prompt:(e,t)=>h({type:`prompt`,text:e,...t?.length?{images:t}:{}}),abort:()=>h({type:`abort`}),setModel:(e,t)=>h({type:`set_model`,provider:e,id:t}),setThinking:e=>h({type:`set_thinking`,level:e}),newSession:()=>h({type:`new_session`}),switchSession:e=>h({type:`switch_session`,path:e}),deleteSession:e=>h({type:`delete_session`,path:e}),listSessions:()=>h({type:`list_sessions`}),renameSession:(e,t)=>h({type:`rename_session`,path:e,name:t}),searchSessions:e=>{let t=`sessions:${crypto.randomUUID()}`;i({type:`session_search_started`,query:e,requestId:t}),h({type:`search_sessions`,query:e,requestId:t})},clearSessionSearch:()=>i({type:`session_search_cleared`}),listTree:()=>h({type:`list_tree`}),navigateTree:e=>h({type:`navigate_tree`,entryId:e}),forkSession:e=>h({type:`fork_session`,entryId:e}),editPrompt:(e,t,n)=>h({type:`edit_prompt`,entryId:e,text:t,...n?.length?{images:n}:{}}),compact:()=>h({type:`compact`}),respondToDialog:e=>{h({type:`extension_ui_response`,...e}),i({type:`dialog_answered`})},dismissNotification:e=>i({type:`dismiss_notification`,id:e}),listDirectory:e=>g(e),refreshFileTree:C,readFile:e=>{let t=`file:${crypto.randomUUID()}`;i({type:`file_read_started`,path:e,requestId:t}),h({type:`read_file`,path:e,requestId:t})},closeFilePreview:()=>i({type:`close_file_preview`}),writeFile:(e,t,n,r=!1)=>{let a=`write:${crypto.randomUUID()}`;i({type:`file_save_started`,path:e,requestId:a,content:t}),h({type:`write_file`,path:e,content:t,expectedMtimeMs:n,...r?{force:r}:{},requestId:a})},createFile:e=>{i({type:`file_create_started`}),h({type:`create_file`,path:e,requestId:`create:${crypto.randomUUID()}`})},uploadFile:(e,t)=>{let n=m.current;if(n===null)return Promise.reject(new LT(`the workspace is read-only`,`denied`));let r=a.current;if(!r||r.readyState!==WebSocket.OPEN)return Promise.reject(new LT(`not connected to the server`));let i=n?`${n}/${IT}`:IT,o=`upload:${crypto.randomUUID()}`;return new Promise((n,r)=>{let a=window.setTimeout(()=>{p.current.delete(o)&&r(new LT(`the upload timed out`))},EO),s=e=>t=>{clearTimeout(a),e(t)};p.current.set(o,{resolve:s(n),reject:s(r)}),h({type:`upload_file`,destinationDirectory:i,name:e,contentBase64:t,requestId:o})})},createDirectory:e=>{i({type:`file_create_started`}),h({type:`create_directory`,path:e,requestId:`create:${crypto.randomUUID()}`})},openNative:e=>{let t=`fileop:${crypto.randomUUID()}`;i({type:`file_operation_started`,operation:`open_native`,path:e,requestId:t}),h({type:`open_native`,path:e,requestId:t})},renameFile:(e,t)=>{let n=`fileop:${crypto.randomUUID()}`;i({type:`file_operation_started`,operation:`rename_file`,path:e,requestId:n}),h({type:`rename_file`,path:e,name:t,requestId:n})},deleteFile:e=>{let t=`fileop:${crypto.randomUUID()}`;i({type:`file_operation_started`,operation:`delete_file`,path:e,requestId:t}),h({type:`delete_file`,path:e,requestId:t})},moveFile:(e,t)=>{let n=`fileop:${crypto.randomUUID()}`;i({type:`file_operation_started`,operation:`move_file`,path:e,requestId:n}),h({type:`move_file`,path:e,destinationDirectory:t,requestId:n})},copyFile:(e,t)=>{let n=`fileop:${crypto.randomUUID()}`;i({type:`file_operation_started`,operation:`copy_file`,path:e,requestId:n}),h({type:`copy_file`,path:e,destinationDirectory:t,requestId:n})},searchFiles:e=>{let t=`search:${crypto.randomUUID()}`;i({type:`file_search_started`,query:e,requestId:t}),h({type:`search_files`,query:e,requestId:t})},clearFileSearch:()=>i({type:`file_search_cleared`}),fetchGitStatus:b,fetchGitDiff:e=>{let t=`gitdiff:${crypto.randomUUID()}`;i({type:`git_diff_started`,path:e,requestId:t}),h({type:`git_diff`,path:e,requestId:t})},clearGitDiff:()=>i({type:`git_diff_cleared`}),fetchGitLog:e=>h({type:`git_log`,...e?{limit:e}:{},requestId:`gitlog:${crypto.randomUUID()}`}),fetchGitShow:e=>h({type:`git_show`,sha:e,requestId:`gitshow:${crypto.randomUUID()}`}),clearGitShow:()=>i({type:`git_show_cleared`}),fetchGitFileHistory:(e,t)=>{let n=`gitfilelog:${crypto.randomUUID()}`;i({type:`git_file_history_started`,path:e,requestId:n}),h({type:`git_file_log`,path:e,...t?{limit:t}:{},requestId:n})},closeGitFileHistory:()=>i({type:`git_file_history_closed`}),fetchGitFileDiff:(e,t)=>{let n=`gitfilediff:${crypto.randomUUID()}`;i({type:`git_file_diff_started`,base:e,target:t,requestId:n}),h({type:`git_file_diff`,base:e,target:t,requestId:n})},clearGitFileDiff:()=>i({type:`git_file_diff_cleared`}),setCredential:(e,t)=>h({type:`set_credential`,provider:e,apiKey:t}),declareProvider:e=>h({type:`declare_provider`,...e}),browseServerDirectory:e=>{let t=`serverdir:${crypto.randomUUID()}`;i({type:`server_browse_started`,path:e,requestId:t}),h({type:`browse_server_directory`,path:e,requestId:t})},closeServerBrowser:()=>i({type:`server_browse_closed`}),updateConfig:e=>{i({type:`settings_apply_started`}),h({type:`update_config`,...e})}}}var kO=(0,d.forwardRef)(function({serverUrl:e=``,rootElement:t,initialTheme:n,token:r},i){let a=t!==void 0,o=t??document.documentElement,{state:s,authToken:c,submitToken:l,prompt:u,abort:f,setModel:m,setThinking:h,newSession:g,switchSession:_,deleteSession:v,listSessions:b,renameSession:x,searchSessions:S,clearSessionSearch:C,listTree:w,navigateTree:T,forkSession:E,editPrompt:ee,compact:D,respondToDialog:O,dismissNotification:ae,listDirectory:oe,refreshFileTree:se,readFile:A,writeFile:ce,createFile:le,createDirectory:j,uploadFile:ue,openNative:de,renameFile:fe,deleteFile:pe,moveFile:me,copyFile:he,closeFilePreview:ge,searchFiles:_e,clearFileSearch:ve,fetchGitDiff:ye,clearGitDiff:be,fetchGitLog:xe,fetchGitShow:Se,clearGitShow:Ce,fetchGitFileHistory:we,closeGitFileHistory:Te,fetchGitFileDiff:Ee,clearGitFileDiff:De,setCredential:Oe,declareProvider:Ae,updateConfig:je,browseServerDirectory:Me,closeServerBrowser:Ne}=OO(e,r,a),[Pe,Fe]=(0,d.useState)(!1),[Ie,Le]=(0,d.useState)([]),[Re,ze]=(0,d.useState)([]),[Be,Ve]=(0,d.useState)(null),[He,Ue]=(0,d.useState)(null),[We,M]=(0,d.useState)(null),[Ge,Ke]=(0,d.useState)(!1),N=(0,d.useRef)([]),qe=(0,d.useRef)(null),Je=(0,d.useRef)(null),[Ye,Xe]=(0,d.useState)(!1),[Ze,Qe]=(0,d.useState)(()=>{try{return localStorage.getItem(`pi-outpost:hide-tools`)===`1`}catch{return!1}});function $e(){Qe(e=>{try{localStorage.setItem(`pi-outpost:hide-tools`,e?`0`:`1`)}catch{}return!e})}let[et,tt]=(0,d.useState)(!1),[nt,rt]=(0,d.useState)(!0);function it(){let e=!et;tt(e),e&&rt(!1)}function at(){let e=!nt;rt(e),e&&tt(!1)}let[ot,st]=(0,d.useState)([]),[ct,lt]=(0,d.useState)([]),ut=(0,d.useRef)(0),dt=(0,d.useRef)(0),[ft,pt]=(0,d.useState)(0);async function mt(e){let t=[...e],n=t.filter(VT).map(e=>({id:`${ut.current++}`,name:e.name}));n.length>0&<(e=>[...e,...n]),dt.current===0&&st([]),dt.current++;try{let{attachments:e,errors:n}=await YT(t,ue);e.length>0&&Le(t=>[...t,...e]),n.length>0&&st(e=>[...e,...n])}finally{if(dt.current--,n.length>0){let e=new Set(n.map(e=>e.id));lt(t=>t.filter(t=>!e.has(t.id)))}}}(0,d.useEffect)(()=>{N.current=Ie},[Ie]),(0,d.useEffect)(()=>{let t=s.openFile;if(!t)return;let n=t.path,r=t.status===`loaded`,i=t.status===`error`&&t.message===`Binary file — preview not supported`&&re(n);if(qe.current!==n&&(qe.current=n,Je.current=null,Le(e=>e.filter(e=>e.source!==`preview`)),Ve(null),Ue(null),M(null)),Je.current===n)return;(te(n)||ne(n))&&Le(e=>e.filter(e=>e.source!==`preview`));let a=!1;async function o(){let t=te(n)?He===n?await rE(n,ie(e,n,c,s.previewRevision)):null:ne(n)?We?.path===n&&We.revision===s.previewRevision?ZT(n):null:i||r?XT(n):null;if(!(a||t===null||qe.current!==n||Je.current===n)){if(typeof t==`string`){Ve(t);return}Ve(null),Le(e=>oE(e,t))}}return o(),()=>{a=!0}},[s.openFile,s.previewRevision,e,c,He,We]);function ht(){qe.current=null,Je.current=null,ge()}let gt=(0,d.useMemo)(()=>[...Ie.filter(e=>e.kind===`path`).map(e=>e.data),...Re],[Ie,Re]);function _t(e){let t=N.current.findIndex(t=>t.kind===`path`&&t.data===e);t>=0?vt(t):Re.includes(e)||Le(t=>aE(t,e))}function vt(e){let t=N.current[e];t?.source===`preview`&&(Je.current=t.previewPath??qe.current,Ve(null)),Le(t=>sE(t,e))}function yt(e,t){u(e,t),Le([]),st([]),Ve(null),Ge||ht()}function bt(e){e.preventDefault(),pt(0),e.dataTransfer.files.length>0&&mt(Array.from(e.dataTransfer.files))}let{theme:xt,toggle:St,setTheme:Ct}=y(s.branding.defaultTheme??`system`,s.branding.allowThemeToggle!==!1,o,n);(0,d.useImperativeHandle)(i,()=>({setTheme:Ct}),[Ct]);let wt=(0,d.useRef)(null),Tt=(0,d.useRef)(null),Et=(0,d.useRef)(!0);function Dt(){let e=wt.current;e&&(Et.current=e.scrollHeight-e.scrollTop-e.clientHeight<120)}(0,d.useEffect)(()=>{Et.current&&Tt.current?.scrollIntoView({behavior:`smooth`})},[s.items]);let Ot=(0,d.useMemo)(()=>oT(s.items),[s.items]),kt=(0,d.useMemo)(()=>et?gT(s.items):null,[et,s.items]),At=(0,d.useMemo)(()=>H_({readFile:e=>{Xe(!1),A(e)},fetchGitFileHistory:e=>we(e),fetchGitDiff:e=>{Xe(!0),A(e)},searchFiles:e=>_e(e)}),[A,we,_e]),jt=(0,d.useCallback)(()=>Qe(!1),[]),{jumpToItem:Mt,highlightIndex:Nt}=FT({items:s.items,scrollerRef:wt,hideTools:Ze,onShowTools:jt,stickToBottom:Et});return(0,d.useEffect)(()=>{a||(document.title=s.extensionTitle??s.branding.title??`pi`),s.branding.accentColor&&o.style.setProperty(`--accent`,s.branding.accentColor)},[s.branding,s.extensionTitle,a,o]),a&&!s.brandingReady?null:s.authRequired?(0,k.jsx)(p.Provider,{value:xt,children:(0,k.jsx)(lO,{title:s.branding.title,onSubmit:l})}):s.credentials&&!s.credentials.usableModel?(0,k.jsx)(p.Provider,{value:xt,children:(0,k.jsx)(KD,{title:s.branding.title,credentials:s.credentials,onSetCredential:Oe,onDeclareProvider:Ae,errors:s.errors})}):(0,k.jsxs)(p.Provider,{value:xt,children:[(0,k.jsxs)(`div`,{className:`relative flex h-full`,onDragEnter:e=>{e.dataTransfer.types.includes(`Files`)&&pt(e=>e+1)},onDragLeave:()=>pt(e=>Math.max(0,e-1)),onDragOver:e=>e.preventDefault(),onDrop:bt,children:[ft>0&&(0,k.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,k.jsx)(`p`,{className:`text-lg font-medium text-zinc-700 dark:text-zinc-200`,children:`Drop files to attach (images, documents & text)`})}),Pe&&(0,k.jsx)(cO,{tree:s.fileTree,openFile:s.openFile,writableRoot:s.writableRoot,gitFiles:s.gitStatus?.files,attachedPaths:gt,onExpand:oe,onRefresh:se,onSelectFile:e=>{Xe(!1),A(e)},onSelectDiff:e=>{Xe(!0),A(e)},onToggleAttachPath:_t,onCreateFile:e=>{Xe(!1),le(e)},onCreateDirectory:j,onOpenNative:de,onRenameFile:fe,onDeleteFile:pe,onMoveFile:me,onCopyFile:he,fileOperation:s.fileOperation,createError:s.createError,created:s.created}),(0,k.jsxs)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,children:[(0,k.jsx)(RD,{title:s.branding.title,sessions:s.sessions,sessionSearch:s.sessionSearch,sessionId:s.sessionId,tree:s.tree,isStreaming:s.isStreaming,connected:s.connected,theme:xt,showThemeToggle:s.branding.allowThemeToggle!==!1,statuses:s.statuses,sidebarOpen:Pe,hideTools:Ze,onToggleSidebar:()=>Fe(!Pe),onToggleHideTools:$e,onToggleTheme:St,onNewSession:g,onSwitchSession:_,onDeleteSession:v,onListSessions:b,onRenameSession:x,onSearchSessions:S,onClearSessionSearch:C,onListTree:w,onNavigateTree:T,onForkSession:E,gitAvailable:s.gitAvailable,gitStatus:s.gitStatus,gitLog:s.gitLog,extensionPaths:s.extensionPaths,tools:s.tools,commands:s.commands,sandbox:s.sandbox,userSkillPaths:s.userSkillPaths,serverBrowse:s.serverBrowse,settingsApply:s.settingsApply,versions:s.versions,onBrowseServerPath:Me,onCloseServerBrowser:Ne,onUpdateConfig:je,onFetchGitLog:xe,onShowCommit:Se}),(0,k.jsxs)(`div`,{className:`relative z-0 flex min-h-0 flex-1 flex-col`,children:[s.workPlan&&(0,k.jsx)(pO,{plan:s.workPlan,open:nt,onToggle:at,onOpenWorkspace:e=>{Xe(!1),A(e)}}),s.openFile&&(0,k.jsx)(GE,{file:s.openFile,writableRoot:s.writableRoot,isStreaming:s.isStreaming,onDirtyChange:Ke,gitState:s.gitStatus?.files[s.openFile.path],initialShowGitDiff:Ye,gitDiff:s.gitDiff,onFetchGitDiff:ye,onClearGitDiff:be,gitAvailable:s.gitAvailable,onOpenGitHistory:we,onClose:ht,onReload:A,onSave:ce,serverUrl:e,token:c,onImageLoad:Ue,onPdfLoad:e=>M({path:e,revision:s.previewRevision}),rawRevision:s.previewRevision},s.openFile.path),s.gitFileHistory&&(0,k.jsx)(_D,{history:s.gitFileHistory,diff:s.gitFileDiff,dirty:s.gitStatus?.files[s.gitFileHistory.path]!==void 0,onFetchDiff:Ee,onClearDiff:De,onClose:Te}),s.gitShow&&(0,k.jsx)(qE,{show:s.gitShow,onClose:Ce}),kt&&(0,k.jsx)(NT,{analysis:kt,onJump:Mt,onClose:()=>tt(!1)}),(0,k.jsx)(`main`,{ref:wt,onScroll:Dt,className:`flex-1 overflow-y-auto ${et?`md:pr-[26rem]`:s.workPlan&&nt?`md:pr-[23rem]`:``}`,children:(0,k.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-3 px-4 py-6`,children:[s.items.length===0&&(0,k.jsxs)(`div`,{className:`mt-24 text-center text-zinc-500 dark:text-zinc-600`,children:[(0,k.jsx)(`div`,{className:`mb-2 text-4xl`,children:s.branding.title??`π`}),(0,k.jsx)(`p`,{className:`text-sm`,children:s.branding.welcome??`Send a message to start the agent.`})]}),s.items.map((t,n)=>{let r=`${s.sessionId}:${n}`,i=(e,t=r)=>(0,k.jsx)(`div`,{"data-item-index":n,className:`flex flex-col gap-3 rounded-lg transition-shadow ${Nt===n?`ring-2 ring-blue-400 dark:ring-blue-500`:``}`,children:e},t);if(t.kind===`user`){let e=n===s.items.length-1&&s.isStreaming;return i((0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(ke,{item:t,canEdit:!s.isStreaming&&s.connected,onEdit:ee}),e&&(0,k.jsx)(`div`,{className:`flex justify-end px-4`,children:(0,k.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,k.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,k.jsx)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`working…`})]})})]}))}return t.kind===`tool`?Ze?null:i((0,k.jsx)(rT,{item:t,dispatch:At}),t.toolCallId?`${s.sessionId}:${t.toolCallId}`:r):t.kind===`custom`?i((0,k.jsx)(iT,{item:t})):t.blocks.length===0&&!t.errorMessage?(0,k.jsx)(`div`,{"data-item-index":n,className:`sr-only`,"aria-hidden":!0},r):i((0,k.jsx)(z_,{item:t,serverUrl:e,token:c,onOpenFile:e=>{Xe(!1),A(e)}}))}),(s.queue.steering.length>0||s.queue.followUp.length>0)&&(0,k.jsxs)(`div`,{className:`rounded-lg border border-dashed border-zinc-300 px-3 py-2 text-xs text-zinc-500 dark:border-zinc-700`,children:[s.queue.steering.map((e,t)=>(0,k.jsxs)(`div`,{children:[`⏩ steering: `,e]},`s${t}`)),s.queue.followUp.map((e,t)=>(0,k.jsxs)(`div`,{children:[`⏭ follow-up: `,e]},`f${t}`))]}),ot.map((e,t)=>(0,k.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}`)),Be&&(0,k.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:Be}),s.errors.map((e,t)=>(0,k.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,k.jsx)(`div`,{ref:Tt})]})})]}),(0,k.jsx)(`footer`,{className:`border-t border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:(0,k.jsxs)(`div`,{className:`mx-auto max-w-3xl`,children:[(0,k.jsx)(FE,{widgets:s.widgets,placement:`aboveEditor`}),(0,k.jsx)(hE,{isStreaming:s.isStreaming,connected:s.connected,commands:s.commands,fileSearch:s.fileSearch,prefill:s.editorPrefill,attachments:Ie,pendingUploads:ct,onAttach:e=>void mt(e),onMentionPaths:ze,onRemoveAttachment:vt,onSend:yt,onAbort:f,onSearchFiles:_e,onClearFileSearch:ve}),(0,k.jsx)(FE,{widgets:s.widgets,placement:`belowEditor`}),(0,k.jsx)(UD,{model:s.model,models:s.models,thinkingLevel:s.thinkingLevel,modelSupportsReasoning:s.modelSupportsReasoning,isStreaming:s.isStreaming,contextUsage:s.contextUsage,sessionUsage:Ot,analysisOpen:et,onToggleAnalysis:it,isCompacting:s.isCompacting,onSetModel:m,onSetThinking:h,onCompact:D})]})})]})]}),s.dialogQueue[0]&&(0,k.jsx)(TE,{request:s.dialogQueue[0],onRespond:O}),(0,k.jsx)(OE,{notifications:s.notifications,onDismiss:ae})]})});(0,f.createRoot)(document.getElementById(`root`)).render((0,k.jsx)(d.StrictMode,{children:(0,k.jsx)(kO,{})}));export{i,oe as n,ie as r,j as t};
|
|
319
|
+
`:``}${e}`};for(let e of t)e.kind===`path`?nE(n,e.data)||r(`@${e.data}`):e.kind===`text`&&r(`\`\`\`${e.name}\n${e.data}\n\`\`\``);return n}async function aE(e,t){try{let n=await fetch(t);if(!n.ok)return`${e}: unable to read preview image for attachment`;let r=n.headers.get(`Content-Type`)?.split(`;`,1)[0]??``;if(!r.startsWith(`image/`))return`${e}: preview is not a supported image attachment`;let i=new Uint8Array(await n.arrayBuffer());return i.byteLength>7340032?`${e}: image too large (max 7 MB)`:{name:e,kind:`image`,data:UT(i),mimeType:r,source:`preview`,previewPath:e}}catch{return`${e}: unable to read preview image for attachment`}}function oE(e){return{name:e,kind:`path`,data:e,mimeType:`text/plain`,source:`manual`}}function sE(e,t){return e.some(e=>e.kind===`path`&&e.data===t)?e:[...e,oE(t)]}function cE(e,t){return[...e.filter(e=>e.source!==`preview`),t]}function lE(e,t){return e.filter((e,n)=>n!==t)}function uE(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 dE(e){let t=(0,d.useRef)(null);return(0,d.useEffect)(()=>{function n(n){t.current&&!uE(n,t.current)&&e()}return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),t}var fE=100,pE=new Intl.Collator(void 0,{sensitivity:`base`,numeric:!0}),mE={extension:`ext`,prompt:`prompt`,skill:`skill`};function hE(e){return e===`directory`||e===`symlink-directory`}function gE(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 _E({isStreaming:e,connected:t,commands:n,fileSearch:r,prefill:i,attachments:a,pendingUploads:o=[],onAttach:s,onMentionPaths:c,onRemoveAttachment:l,onSend:u,onAbort:f,onSearchFiles:p,onClearFileSearch:m}){let[h,g]=(0,d.useState)(``),[_,v]=(0,d.useState)(0),[y,b]=(0,d.useState)(0),[x,S]=(0,d.useState)(!1),C=(0,d.useRef)(null),w=(0,d.useRef)(null),T=(0,d.useRef)(null),E=(0,d.useRef)(null),ee=(0,d.useRef)(null);(0,d.useEffect)(()=>{i&&g(i.text)},[i?.nonce]),(0,d.useEffect)(()=>{ee.current!==null&&(T.current?.focus(),T.current?.setSelectionRange(ee.current,ee.current),ee.current=null)},[h]);let D=(0,d.useMemo)(()=>rE(h),[h]);(0,d.useEffect)(()=>{c(D)},[D.join(`
|
|
320
|
+
`)]);let O=(0,d.useMemo)(()=>{let e=/^\/(\S*)$/.exec(h);return e?e[1].toLowerCase():null},[h]),te=(0,d.useMemo)(()=>O===null?[]:n.filter(e=>e.name.toLowerCase().startsWith(O)).sort((e,t)=>pE.compare(e.name,t.name)).slice(0,fE),[O,n]),ne=O===null?gE(h,_):null;(0,d.useEffect)(()=>{if(!ne||ne.query.length===0){m();return}let e=window.setTimeout(()=>p(ne.query),150);return()=>clearTimeout(e)},[ne?.query]);let re=(0,d.useMemo)(()=>{if(te.length>0)return{kind:`command`,items:te};let e=ne&&r?.query===ne.query?r.results:[];return e.length>0?{kind:`file`,items:e}:null},[te,ne,r]),ie=re!==null&&!x,ae=O===null?ne?`file:${ne.query}`:null:`cmd:${O}`;(0,d.useEffect)(()=>{b(0)},[ae]),(0,d.useEffect)(()=>{S(!1)},[O===null?ne?`file`:null:`command`]),(0,d.useEffect)(()=>{if(!ie)return;let e=e=>{uE(e,C.current)||S(!0)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e)}},[ie]),(0,d.useEffect)(()=>{w.current?.querySelector(`[data-selected="true"]`)?.scrollIntoView({block:`nearest`})},[y]);let oe=o.length>0,[se,A]=(0,d.useState)(!1);(0,d.useEffect)(()=>{oe||A(!1)},[oe]);function ce(){if(oe){A(!0);return}let e=iE(h,a),t=a.filter(e=>e.kind===`image`).map(e=>({data:e.data,mimeType:e.mimeType})),n=a.every(e=>e.kind===`path`);!h.trim()&&(n||!e)&&t.length===0||(u(e,t.length>0?t:void 0),g(``),m())}function le(e){let t=`/${e.name} `;g(t),ee.current=t.length,v(t.length)}function j(e){if(!ne)return;let t=h.slice(0,ne.start),n=h.slice(_),r=`@${e.path}${hE(e.type)?`/`:` `}`,i=`${t}${r}${n}`;g(i),m();let a=t.length+r.length;ee.current=a,v(a)}function ue(){if(re){if(re.kind===`command`){let e=re.items[y];e&&le(e)}else{let e=re.items[y];e&&j(e)}}}function de(e){if(ie&&re){if(e.key===`ArrowDown`){e.preventDefault(),b(e=>(e+1)%re.items.length);return}if(e.key===`ArrowUp`){e.preventDefault(),b(e=>(e-1+re.items.length)%re.items.length);return}if(e.key===`Tab`||e.key===`Enter`){e.preventDefault(),ue();return}if(e.key===`Escape`){e.preventDefault(),S(!0);return}}e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),ce())}function fe(e){v(e.currentTarget.selectionStart??0)}function pe(e){let t=Array.from(e.clipboardData.files);t.length>0&&(e.preventDefault(),s(t))}return(0,k.jsxs)(`div`,{ref:C,className:`relative`,children:[(a.length>0||oe)&&(0,k.jsxs)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:[o.map(e=>(0,k.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,k.jsx)(`span`,{"aria-hidden":!0,className:`animate-pulse`,children:`⏳`}),(0,k.jsx)(`span`,{className:`max-w-40 truncate`,children:e.name}),(0,k.jsx)(`span`,{className:`sr-only`,children:`uploading`})]},e.id)),se&&(0,k.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,k.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,k.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:e.name,className:`h-8 w-8 rounded object-cover`}):(0,k.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,k.jsx)(`span`,{className:`max-w-40 truncate`,children:e.name}),(0,k.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}`))]}),ie&&re&&(0,k.jsx)(`div`,{ref:w,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,k.jsxs)(`button`,{type:`button`,"data-selected":t===y,onMouseEnter:()=>b(t),onClick:()=>le(e),className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm ${t===y?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:[(0,k.jsxs)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:[`/`,e.name]}),e.argumentHint&&(0,k.jsx)(`span`,{className:`font-mono text-xs text-zinc-500`,children:e.argumentHint}),e.description&&(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-zinc-500`,children:e.description}),(0,k.jsx)(`span`,{className:`ml-auto shrink-0 rounded bg-zinc-200 px-1 text-[10px] uppercase text-zinc-500 dark:bg-zinc-800`,children:mE[e.source]})]},e.name)):re.items.map((e,t)=>(0,k.jsx)(`button`,{type:`button`,"data-selected":t===y,onMouseEnter:()=>b(t),onClick:()=>j(e),className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm ${t===y?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:(0,k.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-zinc-800 dark:text-zinc-200`,children:[e.path,hE(e.type)?`/`:``]})},e.path))}),(0,k.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,k.jsx)(`textarea`,{ref:T,value:h,onChange:e=>{g(e.target.value),v(e.target.selectionStart??e.target.value.length)},onKeyDown:de,onClick:fe,onKeyUp:fe,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:Math.min(6,Math.max(1,h.split(`
|
|
321
|
+
`).length)),className:`flex-1 resize-none 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,k.jsx)(`button`,{type:`button`,onClick:f,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,k.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,className:`h-4 w-4`,children:(0,k.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>E.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,k.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,k.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,k.jsx)(`input`,{ref:E,type:`file`,multiple:!0,hidden:!0,onChange:e=>{e.target.files?.length&&s(Array.from(e.target.files)),e.target.value=``}}),(0,k.jsx)(`button`,{type:`button`,onClick:ce,disabled:!t||oe||!h.trim()&&a.length===0,title:oe?`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,k.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:[(0,k.jsx)(`circle`,{cx:`6`,cy:`19`,r:`3`}),(0,k.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,k.jsx)(`circle`,{cx:`18`,cy:`5`,r:`3`})]}):(0,k.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,k.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 vE=`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`,yE=`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`,bE=`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`,xE=`mb-4 ${bE}`,SE=`1,3`,CE=` — `;function wE(e){let t=e.indexOf(`
|
|
322
|
+
`);return t===-1?{heading:e,body:``}:{heading:e.slice(0,t),body:e.slice(t+1).trim()}}function TE(e){let t=/^(\d+)\.\s+(\S[\s\S]*)$/.exec(e.trim());if(!t)return null;let n=t[2],r=n.indexOf(CE);return{index:Number(t[1]),label:r===-1?n:n.slice(0,r),description:r===-1?``:n.slice(r+3)}}function EE(e){if(e.method!==`input`||e.placeholder!==SE)return null;let{heading:t,body:n}=wE(e.title),r=[];for(let e of n.split(`
|
|
323
|
+
`)){let t=TE(e);t&&r.push(t)}return r.length<2||r.some((e,t)=>e.index!==t+1)?null:{heading:t,options:r}}function DE({request:e,onRespond:t}){let[n,r]=(0,d.useState)(e.method===`editor`?e.prefill??``:``),[i,a]=(0,d.useState)([]),o=(e.method===`select`||e.method===`confirm`||e.method===`input`)&&e.timeout,[s,c]=(0,d.useState)(o?Math.ceil(o/1e3):null),l=EE(e),{heading:u,body:f}=wE(e.title);function p(){t({id:e.id,cancelled:!0})}function m(e){a(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e].sort((e,t)=>e-t))}function h(){let r=n.trim();t({id:e.id,value:r.length>0?r:i.join(`,`)})}return(0,d.useEffect)(()=>{if(s===null)return;if(s<=0){t({id:e.id,cancelled:!0});return}let n=setTimeout(()=>c(e=>e===null?null:e-1),1e3);return()=>clearTimeout(n)},[s,e.id,t]),(0,k.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,onClick:p,children:(0,k.jsxs)(`div`,{className:`w-full ${f?`max-w-2xl`:`max-w-md`} rounded-xl border border-zinc-200 bg-white p-4 shadow-2xl dark:border-zinc-700 dark:bg-zinc-900`,onClick:e=>e.stopPropagation(),children:[(0,k.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:u}),f&&!l&&(0,k.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,k.jsx)(`div`,{className:`mb-1 flex flex-col gap-1`,children:e.options.map(n=>{let r=TE(n);return(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:`text-left ${vE}`,children:r?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:r.label}),r.description&&(0,k.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:r.description})]}):n},n)})}),e.method===`confirm`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`p`,{className:`mb-4 text-sm text-zinc-600 dark:text-zinc-400`,children:e.message}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!1}),className:vE,children:`No`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!0}),className:yE,children:`Yes`})]})]}),l&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`mb-3 flex flex-col gap-1`,children:l.options.map(e=>(0,k.jsxs)(`label`,{className:`flex 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,k.jsx)(`input`,{type:`checkbox`,checked:i.includes(e.index),onChange:()=>m(e.index),className:`mt-0.5`}),(0,k.jsxs)(`span`,{children:[(0,k.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:e.label}),e.description&&(0,k.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:e.description})]})]},e.index))}),(0,k.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`…or type your own answer`,onKeyDown:e=>{e.key===`Enter`&&h(),e.key===`Escape`&&p()},className:`mb-1 ${bE}`}),(0,k.jsx)(`p`,{className:`mb-4 text-xs text-zinc-400 dark:text-zinc-600`,children:`A typed answer replaces the selection above.`}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:p,className:vE,children:`Cancel`}),(0,k.jsx)(`button`,{type:`button`,onClick:h,className:yE,children:`OK`})]})]}),e.method===`input`&&!l&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`input`,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),placeholder:e.placeholder,onKeyDown:r=>{r.key===`Enter`&&t({id:e.id,value:n}),r.key===`Escape`&&p()},className:xE}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:p,className:vE,children:`Cancel`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:yE,children:`OK`})]})]}),e.method===`editor`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`textarea`,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),rows:8,onKeyDown:e=>{e.key===`Escape`&&p()},className:`resize-none font-mono ${xE}`}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:p,className:vE,children:`Cancel`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:yE,children:`OK`})]})]}),s!==null&&(0,k.jsxs)(`p`,{className:`mt-3 text-right text-xs text-zinc-400 dark:text-zinc-600`,children:[`auto-dismiss in `,s,`s`]})]})})}var OE={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`};function kE({notification:e,onDismiss:t}){return(0,d.useEffect)(()=>{let e=setTimeout(t,6e3);return()=>clearTimeout(e)},[t]),(0,k.jsx)(`div`,{className:`rounded-lg border px-3 py-2 text-sm shadow-lg ${OE[e.notifyType??`info`]}`,children:e.message})}function AE({notifications:e,onDismiss:t}){return e.length===0?null:(0,k.jsx)(`div`,{className:`fixed right-4 top-16 z-40 flex w-80 flex-col gap-2`,children:e.map(e=>(0,k.jsx)(kE,{notification:e,onDismiss:()=>t(e.id)},e.id))})}var jE={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`},ME=/\u001B\[[0-9;:]*[A-Za-z]|\u001B[()][A-Za-z0-9]|\u001B[A-Za-z]/g;function NE(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(jE[r]!==void 0)n.color=jE[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 t[e+1]===5&&(e+=2)}}return n}function PE(e){let t=[],n={},r=0;ME.lastIndex=0;for(let i=ME.exec(e);i!==null;i=ME.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=NE(n,t)}}return r<e.length&&t.push({text:e.slice(r),...n}),t}function FE(e){return e.replace(ME,``)}function IE({line:e}){let t=PE(e);return(0,k.jsx)(k.Fragment,{children:t.map((e,t)=>(0,k.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 LE({widgets:e,placement:t}){let n=Object.entries(e).filter(([,e])=>e.placement===t);return n.length===0?null:(0,k.jsx)(`div`,{className:`mb-2 flex flex-col gap-1`,children:n.map(([e,t])=>(0,k.jsx)(`div`,{className:`whitespace-pre-wrap 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:t.lines.map((e,t)=>(0,k.jsx)(`div`,{children:(0,k.jsx)(IE,{line:e})},t))},e))})}var RE=class extends d.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e,t){console.error(`[pi-outpost] viewer crashed:`,e,t.componentStack)}render(){return this.state.failed?(0,k.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,k.jsxs)(`p`,{className:`max-w-md text-center text-sm text-zinc-600 dark:text-zinc-400`,children:[this.props.label??`This file`,` could not be displayed. Close and reopen it to try again.`]})}):this.props.children}},zE=(0,d.lazy)(()=>j(()=>import(`./PdfViewer-BYmPlLvT.js`),[])),BE=250,VE=`(min-width: 768px)`;function HE(){let[e,t]=(0,d.useState)(()=>window.matchMedia?.(VE).matches??!0);return(0,d.useEffect)(()=>{let e=window.matchMedia?.(VE);if(e===void 0)return;let n=()=>t(e.matches);return n(),e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[]),e}function UE(e,t){let[n,r]=(0,d.useState)(e);return(0,d.useEffect)(()=>{let n=window.setTimeout(()=>r(e),t);return()=>window.clearTimeout(n)},[e,t]),n}function WE(e){let t=ew(e);return t.status===`valid`?t.envelope:void 0}function GE(e){return/\.(md|markdown)$/i.test(e)}function KE(e,t){return t===void 0?!0:t===null?!1:t===``||e===t||e.startsWith(`${t}/`)}function qE({file:e,writableRoot:t,isStreaming:n,onDirtyChange:r,gitState:i,initialShowGitDiff:a=!1,gitDiff:o,onFetchGitDiff:s,onClearGitDiff:c,gitAvailable:l,onOpenGitHistory:u,onClose:f,onReload:p,onSave:m,serverUrl:h=``,token:g=null,onImageLoad:_,onPdfLoad:v,rawRevision:y=0}){let[x,S]=(0,d.useState)(`rendered`),[C,w]=(0,d.useState)(a),[E,ee]=(0,d.useState)(e.status===`loaded`&&e.justCreated?{draft:e.content,baseContent:e.content,baseMtimeMs:e.mtimeMs}:null),[D,re]=(0,d.useState)(`idle`),ae=(0,d.useRef)(null),oe=(0,d.useRef)(null),A=e.status===`loaded`?e:null,ce=A!==null&&GE(e.path),le=te(e.path),j=ne(e.path),ue=(0,d.useMemo)(()=>A===null?void 0:ew(A.content),[A?.content]),de=ue?.status===`valid`,fe=ue?.status===`valid`||ue?.status===`invalid`,pe=fe||ce,me=x===`source`,ge=HE(),_e=KE(e.path,t)&&!j,ve=E!==null&&E.draft!==E.baseContent,ye=A?.pendingSave!==void 0,be=E!==null&&A!==null&&A.mtimeMs!==E.baseMtimeMs,xe=A?.saveError?.conflict===!0||be,Se=E?.draft??A?.content??``,Ce=UE(Se,BE),Te=(0,d.useMemo)(()=>A===null?void 0:ew(Ce),[Ce,A===null]),[Ee,Oe]=(0,d.useState)(()=>e.status===`loaded`?WE(e.content):void 0);(0,d.useEffect)(()=>{Te?.status===`valid`&&Oe(Te.envelope)},[Te]);let ke=Te!==void 0&&Te.status!==`valid`&&Ee!==void 0,Ae=Te?.status===`invalid`?Ce===A?.content&&A.documentIssues!==void 0?A.documentIssues:Te.issues:void 0,je=Te?.status===`not-a-document`?Te.why===`unparseable`?`This is not parseable JSON yet.`:"This no longer declares a structured-exchange `schema`.":Te?.status===`unsupported-version`?`This declares ${Te.schema}, which this version does not render.`:void 0,Me=x===`split`&&pe&&!C&&A!==null&&ge,Ne=E===null?null:(0,k.jsx)(`textarea`,{ref:ae,value:E.draft,onChange:e=>ee({...E,draft:e.target.value}),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),ve&&!ye&&!xe&&Re())},spellCheck:!1,className:`h-full w-full resize-none bg-transparent p-4 font-mono text-[13px] leading-relaxed text-zinc-800 outline-none ring-inset focus-visible:ring-1 focus-visible:ring-zinc-300 dark:text-zinc-200 dark:focus-visible:ring-zinc-700`});function Pe(t){return(0,k.jsx)(`div`,{className:`prose-chat mx-auto max-w-3xl p-4 text-zinc-700 dark:text-zinc-300`,children:(0,k.jsx)(hs,{remarkPlugins:[T_,L_],rehypePlugins:[Tm],components:{pre:we,a:({href:t,children:n,...r})=>!t||/^[a-z][a-z0-9+.-]*:/i.test(t)?(0,k.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,...r,children:n}):t.startsWith(`#`)?(0,k.jsx)(`a`,{href:t,...r,children:n}):(0,k.jsx)(`a`,{href:t,onClick:n=>{n.preventDefault(),p(O(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(`//`)?ie(h,O(e.path,t),g):t;return(0,k.jsx)(`img`,{...r,src:i,alt:n??``,loading:`lazy`,className:`max-w-full rounded-lg`})}},children:T(t)})})}function Fe(e){x===`split`&&e!==`split`&&ve&&!window.confirm(`Discard unsaved changes?`)||(x===`split`&&e!==`split`&&ee(null),S(e))}function Ie(){ve&&!window.confirm(`Discard unsaved changes?`)||f()}function Le(){A&&ee({draft:A.content,baseContent:A.content,baseMtimeMs:A.mtimeMs})}function Re(t=!1){!A||E===null||ye||(oe.current=E.draft,m(e.path,E.draft,E.baseMtimeMs,t))}function ze(){ee(null),p(e.path)}function Be(){let t=!C;w(t),t?s(e.path):c()}return(0,d.useEffect)(()=>{if(E!==null&&A!==null&&oe.current!==null&&A.content===oe.current&&A.mtimeMs!==E.baseMtimeMs){let e=oe.current;oe.current=null,E.draft===e?ee(null):ee({...E,baseContent:A.content,baseMtimeMs:A.mtimeMs})}},[A?.mtimeMs]),(0,d.useEffect)(()=>{function e(e){e.key===`Escape`&&Ie()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),(0,d.useEffect)(()=>{Me&&_e&&E===null&&A!==null&&ee({draft:A.content,baseContent:A.content,baseMtimeMs:A.mtimeMs})},[Me,_e,A?.mtimeMs]),(0,d.useEffect)(()=>{re(n?`streaming`:e=>e===`streaming`?`done`:e)},[n]),(0,d.useEffect)(()=>(r(ve),()=>r(!1)),[ve]),(0,d.useEffect)(()=>(a&&s(e.path),()=>c()),[]),(0,k.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[pe&&!C&&(0,k.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`]].map(([e,t,n])=>(0,k.jsx)(`button`,{type:`button`,onClick:()=>Fe(e),"aria-pressed":x===e,title:n,className:`rounded px-1.5 py-0.5 text-xs ${x===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&&E===null&&(0,k.jsx)(`button`,{type:`button`,onClick:Be,"aria-pressed":C,title:C?`Show file content`:`Show uncommitted changes (vs HEAD)`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs ${C?`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`}),l&&E===null&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>u(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,k.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,ve&&(0,k.jsx)(`span`,{className:`ml-1 text-amber-500`,children:`●`})]}),A&&E===null&&(0,k.jsx)(se,{text:A.content}),A&&E===null&&!C&&_e&&(0,k.jsx)(`button`,{type:`button`,onClick:Le,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`}),A&&E===null&&!_e&&(0,k.jsx)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,title:`Outside the writable zone`,children:`🔒 read-only`}),E!==null&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>Re(),disabled:!ve||ye||xe,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:ye?`saving…`:`save`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>{ve&&!window.confirm(`Discard unsaved changes?`)||ee(Me&&A!==null?{draft:A.content,baseContent:A.content,baseMtimeMs:A.mtimeMs}:null)},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:`cancel`})]}),(0,k.jsx)(`button`,{type:`button`,onClick:Ie,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&&E!==null&&(0,k.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,k.jsx)(`span`,{className:`min-w-0 flex-1`,children:`File changed on disk since you started editing.`}),(0,k.jsx)(`button`,{type:`button`,onClick:ze,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,k.jsx)(`button`,{type:`button`,onClick:()=>Re(!0),disabled:ye,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`})]}),E!==null&&A?.saveError&&!A.saveError.conflict&&(0,k.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:A.saveError.message}),(0,k.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[C&&E===null&&(0,k.jsxs)(`div`,{className:`p-4`,children:[o?.path===e.path&&`error`in o&&(0,k.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,k.jsx)(De,{fill:!0,lines:b(o.before,o.after)}),o?.path!==e.path&&(0,k.jsx)(`div`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`loading diff…`})]}),j&&E===null&&!C&&(0,k.jsx)(RE,{label:`This PDF`,children:(0,k.jsx)(d.Suspense,{fallback:(0,k.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),children:(0,k.jsx)(zE,{path:e.path,serverUrl:h,token:g,revision:y,...v?{onLoaded:v}:{}})})}),le&&E===null&&!C&&(0,k.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,k.jsx)(`img`,{src:ie(h,e.path,g,y),alt:e.path,onLoad:()=>_(e.path),className:`max-h-full max-w-full rounded object-contain`})}),e.status===`loading`&&E===null&&!C&&!le&&!j&&(0,k.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),e.status===`error`&&!le&&!j&&(0,k.jsx)(`div`,{className:`p-4 text-sm text-red-600 dark:text-red-400`,children:e.message}),E!==null&&!Me&&Ne,A&&E===null&&!Me&&!C&&ce&&!me&&Pe(A.content),Me&&(0,k.jsxs)(`div`,{className:`flex h-full min-h-0`,"data-testid":`file-split`,children:[(0,k.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto border-r border-zinc-200 dark:border-zinc-800`,children:Ne??(0,k.jsx)(`div`,{className:`p-4`,children:(0,k.jsx)(he,{code:A.content,path:e.path})})}),(0,k.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto`,"data-testid":`file-split-rendering`,children:ce&&!fe?(0,k.jsx)(`div`,{className:`prose-chat p-4 text-zinc-700 dark:text-zinc-300`,children:Pe(Ce)}):(0,k.jsxs)(k.Fragment,{children:[ke&&(0,k.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,k.jsxs)(`span`,{children:[`Showing the document as it last stood.`,` `,je??`The text beside it does not satisfy the schema it declares.`]})}),Ae!==void 0&&(0,k.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:[Ae.slice(0,6).map((e,t)=>(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),Ae.length>6&&(0,k.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,Ae.length-6,` more`]})]}),Ee===void 0?(0,k.jsxs)(`p`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,"data-testid":`file-split-nothing`,children:[`Nothing to draw yet. `,je??`This document does not satisfy the schema it declares.`]}):(0,k.jsx)(RE,{label:`This diagram`,children:(0,k.jsx)(`div`,{className:`p-4`,"data-testid":`file-structured-exchange`,children:(0,k.jsx)(Zw,{envelope:Ee,source:Se})})})]})})]}),A&&E===null&&!Me&&!C&&de&&!me&&ue?.status===`valid`&&(0,k.jsx)(RE,{label:`This diagram`,children:(0,k.jsx)(`div`,{className:`mx-auto max-w-5xl p-4`,"data-testid":`file-structured-exchange`,children:(0,k.jsx)(Zw,{envelope:ue.envelope,source:A.content})})}),A&&E===null&&!Me&&!C&&ue?.status===`invalid`&&(0,k.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,k.jsx)(`p`,{className:`font-medium`,children:`This declares a structured-exchange document and does not satisfy the schema.`}),(0,k.jsxs)(`ul`,{className:`mt-1 space-y-0.5 text-xs`,children:[(A.documentIssues??ue.issues).slice(0,8).map((e,t)=>(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),(A.documentIssues??ue.issues).length>8&&(0,k.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,(A.documentIssues??ue.issues).length-8,` more`]})]})]}),A&&E===null&&!Me&&!C&&ue?.status===`unsupported-version`&&(0,k.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,k.jsx)(`span`,{className:`font-mono`,children:ue.schema}),`, which this version does not render. Shown as text.`]}),A&&E===null&&!Me&&!C&&(!ce||me)&&(!de||me)&&(0,k.jsx)(`div`,{className:`p-4`,children:(0,k.jsx)(he,{code:A.content,path:e.path})})]}),D!==`idle`&&(0,k.jsxs)(`button`,{type:`button`,onClick:Ie,"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:[D===`streaming`?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 animate-pulse motion-reduce:animate-none rounded-full bg-amber-500`}),(0,k.jsx)(`span`,{className:`text-amber-700 dark:text-amber-400`,children:`π is replying…`})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 rounded-full bg-emerald-500`}),(0,k.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:`π replied`})]}),(0,k.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-500`,children:`show conversation →`})]})]})}function JE(e){return e.split(`
|
|
324
|
+
`).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 YE({show:e,onClose:t}){return(0,d.useEffect)(()=>{function e(e){e.key===`Escape`&&(e.stopImmediatePropagation(),t())}return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t]),(0,k.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,k.jsx)(`span`,{className:`font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,12)}),(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`commit diff`}),(0,k.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,k.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,k.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto p-3 font-mono text-xs leading-relaxed`,children:JE(e.patch).map((e,t)=>(0,k.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 XE=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`],ZE=`worktree`,QE={defaultWidth:288,minWidth:224,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.files-sidebar-width.v1`},$E={defaultWidth:416,minWidth:224,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.history-list-width.v1`};function eD(e,t){return Number.isFinite(e)?Math.min(t.maxWidth,Math.max(t.minWidth,Math.round(e))):t.defaultWidth}function tD(e,t){return e===null||e.trim()===``?t.defaultWidth:eD(Number(e),t)}function nD(e,t){try{return tD((t??window.localStorage).getItem(e.storageKey),e)}catch{return e.defaultWidth}}function rD(e,t,n){try{(n??window.localStorage).setItem(t.storageKey,String(eD(e,t)))}catch{}}function iD(e){let[t,n]=(0,d.useState)(()=>nD(e)),r=(0,d.useRef)(t),i=(0,d.useRef)(null),a=(0,d.useCallback)(t=>{let i=eD(t,e);return r.current=i,n(i),i},[e]),o=(0,d.useCallback)(()=>{i.current!==null&&(i.current=null,rD(r.current,e))},[e]);return{width:t,separatorProps:{onPointerDown:e=>{e.isPrimary!==!1&&(e.button??0)===0&&(e.preventDefault(),e.currentTarget.setPointerCapture?.(e.pointerId),i.current={pointerId:e.pointerId,startX:e.clientX,startWidth:r.current})},onPointerMove:e=>{let t=i.current;t!==null&&t.pointerId===e.pointerId&&a(t.startWidth+e.clientX-t.startX)},onPointerUp:e=>{i.current?.pointerId===e.pointerId&&o()},onPointerCancel:e=>{let t=i.current;t!==null&&t.pointerId===e.pointerId&&(i.current=null,a(t.startWidth))},onLostPointerCapture:o,onKeyDown:t=>{let n=null;t.key===`ArrowLeft`?n=r.current-e.keyboardStep:t.key===`ArrowRight`?n=r.current+e.keyboardStep:t.key===`Home`&&(n=e.defaultWidth),n!==null&&(t.preventDefault(),rD(a(n),e))}}}}function aD({label:e,width:t,config:n,separatorProps:r,className:i=``}){return(0,k.jsx)(`div`,{...r,role:`separator`,"aria-label":e,"aria-orientation":`vertical`,"aria-valuemin":n.minWidth,"aria-valuemax":n.maxWidth,"aria-valuenow":t,tabIndex:0,title:e,className:`group absolute inset-y-0 -right-1 z-20 w-2 cursor-col-resize touch-none outline-none ${i}`,children:(0,k.jsx)(`span`,{className:`pointer-events-none absolute 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 oD=`#10b981`,sD=[`#8b5cf6`,`#f59e0b`,`#0ea5e9`,`#f43f5e`,`#14b8a6`,`#d946ef`];function cD(e){return e===0?oD:sD[(e-1)%sD.length]}function lD(e){return sD[e%sD.length]}function uD(e){return e*14+7+1}function dD(e){return e*14+2}function fD({row:e,laneCount:t,colorOf:n=cD}){let r=dD(t),i=uD(e.lane),a=e.highlight?oD:n(e.lane),o=e.dashed?`3 3`:void 0;return(0,k.jsxs)(`svg`,{width:r,height:36,viewBox:`0 0 ${r} 36`,"aria-hidden":!0,className:`shrink-0`,children:[e.through.map(e=>(0,k.jsx)(`line`,{x1:uD(e),y1:0,x2:uD(e),y2:36,stroke:n(e),strokeWidth:2,opacity:.55},e)),e.lineAbove&&(0,k.jsx)(`line`,{x1:i,y1:0,x2:i,y2:18,stroke:a,strokeWidth:2,strokeDasharray:o}),e.lineBelow&&(0,k.jsx)(`line`,{x1:i,y1:18,x2:i,y2:36,stroke:a,strokeWidth:2,strokeDasharray:o}),e.forkTo.map(e=>(0,k.jsx)(`path`,{d:`M ${i} 18 C ${i} 36, ${uD(e)} 18, ${uD(e)} 36`,fill:`none`,stroke:n(e),strokeWidth:2,opacity:.75},`fork-${e}`)),(e.mergeFrom??[]).map(e=>(0,k.jsx)(`path`,{d:`M ${i} 18 C ${i} 0, ${uD(e)} 18, ${uD(e)} 0`,fill:`none`,stroke:n(e),strokeWidth:2,opacity:.75},`merge-${e}`)),e.emphasis===`current`?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`circle`,{cx:i,cy:18,r:6,fill:`none`,stroke:a,strokeWidth:2}),(0,k.jsx)(`circle`,{cx:i,cy:18,r:2.5,fill:a})]}):(0,k.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 pD(e,t={}){let n=[],r=[],i=0,a=()=>{let e=r.indexOf(null);return e===-1?(r.push(null),i=Math.max(i,r.length),r.length-1):e};for(let t of e){let e=r.reduce((e,n,r)=>n===t.sha?[...e,r]:e,[]),o=e[0]??a(),s=e.slice(1);for(let e of s)r[e]=null;i=Math.max(i,o+1);let[c,...l]=t.parents;r[o]=c??null;let u=l.map(e=>{let t=a();return r[t]=e,t});n.push({rev:t.sha,path:t.path,entry:t,lane:o,through:r.reduce((e,t,n)=>t!==null&&n!==o&&!u.includes(n)?[...e,n]:e,[]),forkTo:u,mergeFrom:s,lineAbove:!0,lineBelow:t.parents.length>0,emphasis:`filled`})}let o=n[0];return n.unshift({rev:ZE,path:o?.path??``,lane:o?.lane??0,through:o?.through??[],forkTo:[],mergeFrom:[],lineAbove:!1,lineBelow:n.length>0,emphasis:`current`,dashed:!t.dirty}),n[1]&&(n[1].lineAbove=!0),{rows:n,laneCount:Math.max(i,1)}}var mD=20;function hD(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 gD(e){return e.rev===`worktree`?`working tree`:e.rev.slice(0,7)}function _D(e,t){return e!==null&&t!==null&&e.rev===t.rev&&e.path===t.path}function vD(e){return{rev:e.rev,path:e.path}}function yD({history:e,diff:t,dirty:n,onFetchDiff:r,onClearDiff:i,onClose:a}){let[o,s]=(0,d.useState)({base:null,target:null}),{base:c,target:l}=o,[u,f]=(0,d.useState)(0),p=(0,d.useRef)([]),m=iD($E),{rows:h,laneCount:g}=(0,d.useMemo)(()=>pD(e.entries,{dirty:n}),[e.entries,n]),_=(0,d.useRef)({onFetchDiff:r,onClose:a});_.current={onFetchDiff:r,onClose:a},(0,d.useEffect)(()=>{function e(e){e.key===`Escape`&&(e.stopImmediatePropagation(),_.current.onClose())}return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[]),(0,d.useEffect)(()=>{c===null||l===null||_D(c,l)||_.current.onFetchDiff(c,l)},[c,l]);let v=(0,d.useCallback)((e,t)=>{let n=vD(e);s(r=>{if(t===`base`)return{base:n,target:_D(n,r.target)?r.base:r.target};if(t===`target`)return{base:_D(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:h.find(e=>e.rev===t);return{base:r?vD(r):null,target:n}}return{base:_D(n,r.base)?r.target:r.base,target:n}})},[h]),y=(0,d.useCallback)(()=>{s({base:null,target:null}),i()},[i]),b=(0,d.useCallback)(()=>s(e=>({base:e.target,target:e.base})),[]),x=(0,d.useCallback)(e=>{f(t=>{let n=Math.max(0,Math.min(h.length-1,t+e));return p.current[n]?.focus(),n})},[h.length]),S=e=>{let t=vD(e);return _D(t,c)?`base`:_D(t,l)?`target`:null},C=h.findIndex(e=>_D(vD(e),c)),w=h.findIndex(e=>_D(vD(e),l)),T=C>=0&&w>=0?{top:Math.min(C,w)*36+18,height:Math.abs(w-C)*36}:null;return(0,k.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,k.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,k.jsxs)(`span`,{className:`shrink-0 font-mono text-xs text-zinc-500 dark:text-zinc-400`,"aria-label":`Comparing ${gD(c)} to ${gD(l)}`,children:[(0,k.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:gD(c)}),` → `,(0,k.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:gD(l)})]}),c!==null&&l!==null&&(0,k.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,k.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,k.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,k.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,k.jsxs)(`div`,{role:`region`,"aria-label":`Commit history`,style:{"--history-list-width":`${m.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,k.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,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`Reading history…`}),e.status===`error`&&(0,k.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,k.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,k.jsxs)(`div`,{className:`relative`,role:`group`,"aria-label":`Commits`,children:[T&&(0,k.jsx)(bD,{top:T.top,height:T.height,baseFirst:C<w}),h.map((e,t)=>(0,k.jsx)(CD,{ref:e=>{p.current[t]=e},row:e,laneCount:g,role:S(e),isFocused:t===u,onSelect:t=>v(e,t),onFocus:()=>f(t)},e.rev))]})]}),(0,k.jsx)(aD,{label:`Resize History commit list`,width:m.width,config:$E,separatorProps:m.separatorProps,className:`hidden md:block`})]}),(0,k.jsx)(`div`,{role:`region`,"aria-label":`History diff`,className:`min-h-0 min-w-0 flex-1 overflow-auto p-3`,children:(0,k.jsx)(wD,{diff:t,base:c,target:l})})]})]})}function bD({top:e,height:t,baseFirst:n}){return(0,k.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:mD},children:[(0,k.jsx)(`div`,{className:`absolute inset-y-0 left-2 w-px bg-zinc-400 dark:bg-zinc-500`}),(0,k.jsx)(xD,{label:n?`base`:`target`,className:`top-0`}),(0,k.jsx)(xD,{label:n?`target`:`base`,className:`bottom-0`})]})}function xD({label:e,className:t}){return(0,k.jsx)(`div`,{className:`absolute left-2 flex h-px w-2.5 items-center bg-zinc-400 dark:bg-zinc-500 ${t}`,children:(0,k.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 SD=`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 CD({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,k.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:mD},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,k.jsx)(fD,{row:e,laneCount:t}),s?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:s.sha.slice(0,7)}),(0,k.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,k.jsxs)(`span`,{className:`shrink-0 text-[10px] text-zinc-400 dark:text-zinc-600`,children:[s.author,` · `,hD(s.date)]}),(0,k.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums`,"aria-label":`${s.added} lines added, ${s.deleted} removed`,children:[(0,k.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-500`,children:[`+`,s.added]}),` `,(0,k.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,s.deleted]})]})]}):(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`working tree`}),(0,k.jsxs)(`span`,{className:`flex shrink-0 gap-0.5`,children:[(0,k.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:SD,children:`base`}),(0,k.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:SD,children:`target`})]})]})}function wD({diff:e,base:t,target:n}){return t===null&&n===null?(0,k.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,k.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,k.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,k.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Loading…`}):e.status===`loaded`&&e.beforeText===e.afterText?(0,k.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`These two versions are identical.`}):(0,k.jsx)(`div`,{className:e.status===`loading`?`opacity-40`:void 0,children:(0,k.jsx)(De,{fill:!0,lines:b(e.beforeText,e.afterText)})})}function TD(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 ED({status:e,log:t,onFetchLog:n,onShowCommit:r}){let[i,a]=(0,d.useState)(!1),o=dE(()=>a(!1)),s=e&&(e.ahead>0||e.behind>0)?` ${e.ahead>0?`↑${e.ahead}`:``}${e.behind>0?`↓${e.behind}`:``}`:``;return(0,k.jsxs)(`div`,{className:`relative`,ref:o,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>{a(!i),i||n()},title:`git history`,className:`rounded-md border border-zinc-300 px-2 py-1 font-mono text-xs 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?.branch??`…`,s]}),i&&(0,k.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:[t===null&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),t?.length===0&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no commits`}),t?.map(e=>(0,k.jsxs)(`button`,{type:`button`,onClick:()=>{r(e.sha),a(!1)},className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:[(0,k.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,7)}),(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-zinc-700 dark:text-zinc-300`,title:e.subject,children:e.subject}),(0,k.jsxs)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:[e.author,` · `,TD(e.date)]})]},e.sha))]})]})}function DD({label:e,browse:t,onBrowse:n,onSelect:r,onCancel:i}){let a=t?.path??`/`,o=t?.entries??[],s=t?.status===`loading`;return(0,k.jsxs)(`div`,{className:`rounded-md border border-zinc-300 p-2 dark:border-zinc-700`,"data-testid":`server-path-picker`,children:[(0,k.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,k.jsx)(`span`,{className:`text-xs font-semibold text-zinc-600 dark:text-zinc-300`,children:e}),(0,k.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,k.jsx)(`p`,{className:`mb-2 break-all font-mono text-[11px] text-zinc-500 dark:text-zinc-400`,"data-testid":`picker-path`,children:a}),t?.status===`error`&&(0,k.jsx)(`p`,{role:`alert`,className:`mb-2 text-xs text-red-600 dark:text-red-400`,children:t.error}),(0,k.jsxs)(`div`,{className:`mb-2 flex gap-2`,children:[(0,k.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,k.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,k.jsxs)(`ul`,{className:`max-h-40 overflow-y-auto`,children:[s&&o.length===0&&(0,k.jsx)(`li`,{className:`px-2 py-1 text-xs text-zinc-400`,children:`Loading…`}),!s&&o.length===0&&t?.status!==`error`&&(0,k.jsx)(`li`,{className:`px-2 py-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`No subdirectories`}),o.map(e=>(0,k.jsx)(`li`,{children:(0,k.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 OD({extensionPaths:e,tools:t,commands:n,sandbox:r,userSkillPaths:i,serverBrowse:a,applyState:o,versions:s,onBrowseServerPath:c,onCloseServerBrowser:l,onUpdateConfig:u}){let[f,p]=(0,d.useState)(!1),[m,h]=(0,d.useState)(``),[g,_]=(0,d.useState)(``),[v,y]=(0,d.useState)(!1),[b,x]=(0,d.useState)(!1),[S,C]=(0,d.useState)(i),[w,T]=(0,d.useState)(null),E=dE(()=>ie()),ee=t.filter(e=>e.active),D=t.filter(e=>!e.active),O=n.filter(e=>e.source===`skill`),te=o?.status===`applying`,ne=o?.status===`error`?o.message:null;(0,d.useEffect)(()=>{r&&(h(r.root),_(r.writableRoot??``),y(r.allowWrite),x(r.allowBash))},[r]),(0,d.useEffect)(()=>{C(i)},[i]);let re=(0,d.useRef)(!1);(0,d.useEffect)(()=>{re.current&&o===null&&ie(),re.current=te},[o,te]);function ie(){p(!1),T(null),l()}function ae(e,t){T(e),c(t.trim()||`/`)}function oe(e){w===`root`?h(e):w===`writableRoot`?_(e):w===`skill`&&!S.includes(e)&&C([...S,e]),T(null),l()}function se(){let e=r?{root:m,allowWrite:v,allowBash:b,writableRoot:g.trim()||void 0}:void 0;u({...e?{sandbox:e}:{},userSkillPaths:S})}let A=w!==null&&(0,k.jsx)(DD,{label:w===`skill`?`Choose a skills directory`:w===`root`?`Choose the sandbox root`:`Choose the writable root`,browse:a,onBrowse:c,onSelect:oe,onCancel:()=>{T(null),l()}});return(0,k.jsxs)(`div`,{className:`relative`,ref:E,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>p(!f),title:`Settings`,"aria-label":`Settings`,className:`rounded-md border border-zinc-300 px-2 py-1 text-xs 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:`⚙`}),f&&(0,k.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,k.jsx)(`div`,{className:`border-b border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:(0,k.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Settings`})}),(0,k.jsxs)(`div`,{className:`min-h-0 overflow-y-auto p-4`,children:[(0,k.jsxs)(`section`,{className:`mb-4`,children:[(0,k.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Agent resources`}),t.length===0?(0,k.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`Tool inventory unavailable for this runtime`}):(0,k.jsxs)(`details`,{children:[(0,k.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[ee.length,` tools active`,D.length?` · ${D.length} inactive`:``]}),(0,k.jsx)(`ul`,{className:`mt-2 space-y-1`,children:t.map(e=>(0,k.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,k.jsx)(`span`,{children:e.name}),(0,k.jsx)(`span`,{children:e.active?`active`:`inactive`})]},e.name))})]}),O.length===0?(0,k.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400 dark:text-zinc-500`,children:`No skills loaded`}):(0,k.jsxs)(`details`,{className:`mt-2`,children:[(0,k.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[O.length,` skills loaded`]}),(0,k.jsx)(`ul`,{className:`mt-2 space-y-1`,children:O.map(e=>(0,k.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.name},e.name))})]}),(0,k.jsxs)(`div`,{className:`mt-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,k.jsx)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:`User skill paths`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>ae(`skill`,S[S.length-1]??`/`),className:`rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-600 hover:border-zinc-400 dark:border-zinc-700 dark:text-zinc-300`,children:`Add directory…`})]}),S.length===0?(0,k.jsx)(`p`,{className:`mt-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`No skill directories added`}):(0,k.jsx)(`ul`,{className:`mt-1 space-y-1`,children:S.map(e=>(0,k.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded bg-zinc-50 px-2 py-1 dark:bg-zinc-800`,children:[(0,k.jsx)(`span`,{className:`truncate font-mono text-xs text-zinc-600 dark:text-zinc-400`,title:e,children:e}),(0,k.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e}`,onClick:()=>C(S.filter(t=>t!==e)),className:`shrink-0 text-xs text-zinc-500 hover:text-red-600 dark:text-zinc-400 dark:hover:text-red-400`,children:`Remove`})]},e))}),w===`skill`&&(0,k.jsx)(`div`,{className:`mt-2`,children:A})]})]}),(0,k.jsxs)(`section`,{className:`mb-4`,children:[(0,k.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Extensions`}),e.length===0?(0,k.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No extensions loaded`}):(0,k.jsx)(`ul`,{className:`space-y-1`,children:e.map((e,t)=>(0,k.jsx)(`li`,{className:`rounded bg-zinc-50 px-2 py-1 text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,title:e,children:e},t))})]}),r&&(0,k.jsxs)(`section`,{children:[(0,k.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Sandbox`}),(0,k.jsxs)(`div`,{className:`space-y-3`,children:[(0,k.jsxs)(`label`,{className:`block`,children:[(0,k.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Root `,r.locks?.root?(0,k.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,k.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,k.jsx)(`input`,{type:`text`,value:m,onChange:e=>h(e.target.value),disabled:r.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,k.jsx)(`button`,{type:`button`,"aria-label":`Browse for sandbox root`,disabled:r.locks?.root,onClick:()=>ae(`root`,m),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…`})]})]}),w===`root`&&A,(0,k.jsxs)(`label`,{className:`block`,children:[(0,k.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Writable root (optional) `,r.locks?.writableRoot?(0,k.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,k.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,k.jsx)(`input`,{type:`text`,value:g,onChange:e=>_(e.target.value),disabled:r.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,k.jsx)(`button`,{type:`button`,"aria-label":`Browse for writable root`,disabled:r.locks?.writableRoot,onClick:()=>ae(`writableRoot`,g||m),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…`})]})]}),w===`writableRoot`&&A,(0,k.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:v,onChange:e=>y(e.target.checked),disabled:r.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,k.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow write `,r.locks?.allowWrite?(0,k.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]}),(0,k.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:b,onChange:e=>x(e.target.checked),disabled:r.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,k.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow bash `,r.locks?.allowBash?(0,k.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]})]})]}),!r&&(0,k.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No sandbox configured`}),(0,k.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[ne&&(0,k.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:ne}),(0,k.jsx)(`button`,{type:`button`,disabled:te||r!==null&&!m.trim(),onClick:se,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:te?`Applying…`:`Apply & restart session`}),(0,k.jsx)(`p`,{className:`text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Saved to the server's configuration file, then the session is rebuilt — the change survives a restart.`})]}),s&&(0,k.jsxs)(`section`,{className:`mt-4`,children:[(0,k.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Versions`}),(0,k.jsxs)(`div`,{className:`space-y-1 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,k.jsxs)(`p`,{children:[`pi-outpost: `,(0,k.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:s.piOutpost})]}),s.piSdk&&(0,k.jsxs)(`p`,{children:[`pi SDK: `,(0,k.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:s.piSdk})]}),s.agent&&(0,k.jsxs)(`p`,{children:[`agent: `,(0,k.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:s.agent})]})]})]})]})]})]})}function kD(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);return}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 AD(e){return e.flatMap(e=>[e,...AD(e.children)])}function jD({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,k.jsx)(`span`,{className:`shrink-0 rounded-full border px-1.5 py-px text-[10px] leading-4 ${n}`,children:e})}var MD=`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 ND({row:e,laneCount:t,isStreaming:n,onNavigate:r,onFork:i,onClose:a}){let{node:o}=e,s=o.tipId??o.entryId;return(0,k.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,k.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,k.jsx)(fD,{row:e,laneCount:t,colorOf:lD}),(0,k.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,k.jsxs)(jD,{tone:`branch`,children:[e.forkTo.length+1,` branches`]}),e.branchIndex!==void 0&&(0,k.jsxs)(jD,{tone:`branch`,children:[`branch `,e.branchIndex,o.onPath&&!e.isCurrent?` · current`:``]}),e.isCurrent&&(0,k.jsx)(jD,{tone:`current`,children:`current`}),o.label&&(0,k.jsx)(jD,{tone:`label`,children:o.label})]}),(0,k.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:MD,children:`↺ redo`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>{i(o.entryId),a()},title:`fork a new session from this point`,className:MD,children:`⑂ fork`})]})}function PD({tree:e,isStreaming:t,onListTree:n,onNavigate:r,onFork:i}){let[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(``),l=dE(()=>o(!1));(0,d.useEffect)(()=>{a&&e===null&&n()},[a,e]);let u=(0,d.useMemo)(()=>e&&e.length>0?kD(e):null,[e]),f=(0,d.useMemo)(()=>{if(!e||!s.trim())return null;let t=s.trim().toLowerCase();return AD(e).filter(e=>e.text.toLowerCase().includes(t)||e.label?.toLowerCase().includes(t))},[e,s]);return(0,k.jsxs)(`div`,{className:`relative`,ref:l,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>{o(!a),a||(c(``),n())},title:`conversation tree: go back to an earlier point or fork`,className:`rounded-md border border-zinc-300 px-2 py-1 text-xs 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,k.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,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),e?.length===0&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no messages yet`}),e&&e.length>0&&u&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,k.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,k.jsx)(`span`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Conversation tree`}),(0,k.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,k.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,k.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,k.jsx)(`div`,{className:`min-h-0 overflow-y-auto py-1`,children:f===null?u.rows.map(e=>(0,k.jsx)(ND,{row:e,laneCount:u.laneCount,isStreaming:t,onNavigate:r,onFork:i,onClose:()=>o(!1)},e.node.entryId)):f.length===0?(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no matches`}):f.map(e=>(0,k.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70`,children:[(0,k.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,k.jsx)(`span`,{"aria-hidden":!0,className:e.onPath?`text-emerald-500`:`text-zinc-300 dark:text-zinc-600`,children:`●`}),(0,k.jsx)(`span`,{className:`min-w-0 truncate text-zinc-700 dark:text-zinc-300`,children:e.text||`(empty)`}),e.onPath&&(0,k.jsx)(jD,{tone:`current`,children:`on current branch`}),e.label&&(0,k.jsx)(jD,{tone:`label`,children:e.label})]}),(0,k.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:MD,children:`↺ redo`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>{i(e.entryId),o(!1)},title:`fork a new session from this point`,className:MD,children:`⑂ fork`})]},e.entryId))})]})]})]})}var FD=200;function ID({initial:e,onCommit:t,onCancel:n}){let[r,i]=(0,d.useState)(e);return(0,k.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 LD({session:e,isCurrent:t,renaming:n,onSwitch:r,onDelete:i,onStartRename:a,onRename:o,onCancelRename:s}){return n?(0,k.jsx)(`div`,{className:`px-3 py-2`,children:(0,k.jsx)(ID,{initial:e.name??``,onCommit:o,onCancel:s})}):(0,k.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,k.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 flex-1 px-3 py-2 text-left text-sm`,children:[(0,k.jsx)(`div`,{className:`truncate text-zinc-700 dark:text-zinc-300`,children:e.name||e.firstMessage||`(empty)`}),e.snippet&&(0,k.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-zinc-500 dark:text-zinc-500`,children:e.snippet}),(0,k.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`:``]})]}),(0,k.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&&(0,k.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 RD({sessions:e,sessionSearch:t,sessionId:n,onSwitchSession:r,onDeleteSession:i,onListSessions:a,onRenameSession:o,onSearchSessions:s,onClearSessionSearch:c}){let[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)(``),[m,h]=(0,d.useState)(null),g=dE(()=>u(!1)),_=f.trim(),v=_.length>=2;(0,d.useEffect)(()=>{if(!l)return;if(!v){c();return}let e=setTimeout(()=>s(_),FD);return()=>clearTimeout(e)},[l,_,v]);function y(){u(!1),h(null)}let b=v&&(t?.status!==`loaded`||t.query!==_),x=v?b?null:t?.results??null:e;return(0,k.jsxs)(`div`,{className:`relative`,ref:g,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>{if(l){y();return}u(!0),p(``),h(null),c(),a()},className:`rounded-md border border-zinc-300 px-2 py-1 text-xs 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,k.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,k.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,k.jsx)(`input`,{type:`search`,value:f,onChange:e=>p(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,k.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,k.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[x===null&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),x?.length===0&&(0,k.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:v?`no matches`:`no saved sessions`}),x?.map(e=>(0,k.jsx)(LD,{session:e,isCurrent:e.id===n,renaming:m===e.path,onSwitch:()=>{r(e.path),y()},onDelete:()=>{window.confirm(`Delete this session?`)&&i(e.path)},onStartRename:()=>h(e.path),onRename:t=>{o(e.path,t),h(null),v&&s(f.trim())},onCancelRename:()=>h(null)},e.path))]})]})]})}function zD({theme:e,onToggle:t}){return(0,k.jsx)(`button`,{type:`button`,onClick:t,title:e===`dark`?`Switch to light theme`:`Switch to dark theme`,"aria-label":e===`dark`?`Switch to light theme`:`Switch to dark theme`,className:`rounded-md border border-zinc-300 px-2 py-1 text-xs 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===`dark`?`☀`:`☾`})}function BD(e){let{isStreaming:t,connected:n}=e;return(0,k.jsxs)(`header`,{className:`relative z-30 flex items-center gap-3 border-b border-zinc-200 px-4 py-2.5 dark:border-zinc-800`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:e.onToggleSidebar,title:e.sidebarOpen?`Hide files (panel opens on the left)`:`Show files`,"aria-pressed":e.sidebarOpen,className:`rounded-md border px-2 py-1 text-xs ${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`]}),e.gitAvailable&&(0,k.jsx)(ED,{status:e.gitStatus,log:e.gitLog,onFetchLog:e.onFetchGitLog,onShowCommit:e.onShowCommit}),(0,k.jsx)(`span`,{className:`text-lg font-semibold tracking-tight`,style:{color:`var(--accent, inherit)`},children:e.title??`π`}),Object.entries(e.statuses).map(([e,t])=>(0,k.jsx)(`span`,{className:`rounded-md border border-zinc-200 px-2 py-1 text-xs text-zinc-500 dark:border-zinc-800 dark:text-zinc-400`,children:FE(t)},e)),(0,k.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:e.onToggleHideTools,title:e.hideTools?`Show tool cards in the conversation`:`Hide tool cards (long sessions read better without them)`,"aria-pressed":e.hideTools,className:`rounded-md border px-2 py-1 text-xs ${e.hideTools?`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:`⚒ tools`}),e.showThemeToggle&&(0,k.jsx)(zD,{theme:e.theme,onToggle:e.onToggleTheme}),(0,k.jsx)(`button`,{type:`button`,onClick:e.onNewSession,title:`new session`,className:`rounded-md border border-emerald-300 px-2 py-1 text-xs 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,k.jsx)(PD,{tree:e.tree,isStreaming:t,onListTree:e.onListTree,onNavigate:e.onNavigateTree,onFork:e.onForkSession}),(0,k.jsx)(RD,{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,k.jsx)(OD,{extensionPaths:e.extensionPaths,tools:e.tools??[],commands:e.commands??[],sandbox:e.sandbox,userSkillPaths:e.userSkillPaths,serverBrowse:e.serverBrowse,applyState:e.settingsApply,versions:e.versions,onBrowseServerPath:e.onBrowseServerPath,onCloseServerBrowser:e.onCloseServerBrowser,onUpdateConfig:e.onUpdateConfig}),(0,k.jsx)(`span`,{className:`h-2 w-2 rounded-full ${n?`bg-emerald-500`:`bg-red-500`}`,title:n?`connected`:`disconnected`})]})]})}function VD(e){return!e||e.percent===null?`text-zinc-400 dark:text-zinc-600`:e.percent>=85?`text-red-500`:e.percent>=60?`text-amber-500 dark:text-amber-400`:`text-emerald-500`}function HD({usage:e,analysisOpen:t,onToggleAnalysis:n}){if(e.turns===0)return null;let r=e.turns-e.unpriced,i=[`${e.turns} turn${e.turns===1?``:`s`}`,`input ${e.input.toLocaleString()}`,`output ${e.output.toLocaleString()}`,`cache read ${e.cacheRead.toLocaleString()}`,`cache write ${e.cacheWrite.toLocaleString()}`,...e.unpriced>0&&r>0?[`${e.unpriced} unpriced`]:[]].join(` · `),a=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`span`,{children:[cT(e.totalTokens),` tok`]}),r>0&&(0,k.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-500`,children:[sT(e.cost),e.unpriced>0&&`*`]})]}),o=`flex items-center gap-1.5 rounded-md border px-2 py-1 font-mono text-xs text-zinc-500 dark:text-zinc-400`;return n?(0,k.jsx)(`button`,{type:`button`,onClick:n,title:`${i} — click for the session analysis`,"aria-haspopup":`dialog`,"aria-expanded":t??!1,className:`${o} ${t?`border-zinc-400 dark:border-zinc-600`:`border-zinc-300 hover:border-zinc-400 dark:border-zinc-800 dark:hover:border-zinc-600`}`,children:a}):(0,k.jsx)(`span`,{title:i,className:`${o} border-zinc-300 dark:border-zinc-800`,children:a})}function UD({usage:e}){let t=15.9155,n=2*Math.PI*t,r=e?.percent??0,i=Math.min(100,Math.max(0,r))/100*n;return(0,k.jsxs)(`svg`,{width:18,height:18,viewBox:`0 0 36 36`,className:`-rotate-90 shrink-0`,children:[(0,k.jsx)(`circle`,{cx:`18`,cy:`18`,r:t,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,className:`text-zinc-200 dark:text-zinc-800`}),e&&e.percent!==null&&(0,k.jsx)(`circle`,{cx:`18`,cy:`18`,r:t,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,strokeLinecap:`round`,strokeDasharray:`${i} ${n-i}`,className:VD(e)})]})}function WD({thinkingLevel:e,isStreaming:t,onSetThinking:n}){let[r,i]=(0,d.useState)(!1),a=(0,d.useRef)(null),o=e!==`off`,s=Math.max(0,XE.indexOf(e));return(0,d.useEffect)(()=>{if(!r)return;function e(e){a.current&&!uE(e,a.current)&&i(!1)}function t(e){e.key===`Escape`&&i(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]),(0,k.jsxs)(`div`,{className:`relative`,ref:a,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>i(!r),disabled:t,title:`thinking level`,"aria-haspopup":`true`,"aria-expanded":r,className:`flex items-center gap-1.5 rounded-md border px-2 py-1 font-mono text-xs disabled:opacity-50 ${o?`border-amber-300 text-amber-700 hover:border-amber-400 dark:border-amber-900 dark:text-amber-400 dark:hover:border-amber-700`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600`}`,children:[(0,k.jsx)(`span`,{"aria-hidden":!0,className:`text-sm leading-none ${o?``:`opacity-40 grayscale`}`,children:`🧠`}),e]}),r&&(0,k.jsxs)(`div`,{className:`absolute bottom-full left-0 z-20 mb-1 w-48 rounded-lg border border-zinc-200 bg-white p-3 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,k.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between text-xs`,children:[(0,k.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`thinking`}),(0,k.jsx)(`span`,{className:`font-mono text-zinc-700 dark:text-zinc-200`,children:e})]}),(0,k.jsx)(`input`,{type:`range`,min:0,max:XE.length-1,step:1,value:s,onChange:e=>n(XE[Number(e.target.value)]),"aria-label":`Thinking level`,"aria-valuetext":e,className:`w-full accent-amber-500`}),(0,k.jsxs)(`div`,{className:`mt-0.5 flex justify-between font-mono text-[9px] text-zinc-400 dark:text-zinc-600`,children:[(0,k.jsx)(`span`,{children:XE[0]}),(0,k.jsx)(`span`,{children:XE[XE.length-1]})]})]})]})}function GD(e){let{model:t,models:n,thinkingLevel:r,modelSupportsReasoning:i,isStreaming:a,contextUsage:o,sessionUsage:s,isCompacting:c}=e;return(0,k.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,k.jsxs)(`select`,{value:t,onChange:t=>{let r=n.find(e=>`${e.provider}/${e.id}`===t.target.value);r&&e.onSetModel(r.provider,r.id)},disabled:a,className:`max-w-64 rounded-md border border-zinc-300 bg-white px-2 py-1 font-mono text-xs text-zinc-700 outline-none hover:border-zinc-400 disabled:opacity-50 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-300 dark:hover:border-zinc-600`,children:[!n.some(e=>`${e.provider}/${e.id}`===t)&&(0,k.jsx)(`option`,{value:t,children:t}),n.map(e=>(0,k.jsxs)(`option`,{value:`${e.provider}/${e.id}`,children:[e.provider,`/`,e.id]},`${e.provider}/${e.id}`))]}),i&&(0,k.jsx)(WD,{thinkingLevel:r,isStreaming:a,onSetThinking:e.onSetThinking}),(0,k.jsxs)(`button`,{type:`button`,onClick:e.onCompact,disabled:a||c,title:o?.tokens==null?`Click to compact the conversation context`:`${o.tokens.toLocaleString()} / ${o.contextWindow.toLocaleString()} tokens — click to compact`,className:`ml-auto flex items-center gap-1.5 rounded-md border border-zinc-300 px-2 py-1 font-mono text-xs text-zinc-500 hover:border-zinc-400 disabled:opacity-50 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600`,children:[(0,k.jsx)(UD,{usage:o}),c?`compacting…`:o?.percent==null?`context`:`${Math.round(o.percent)}%`]}),(0,k.jsx)(HD,{usage:s,analysisOpen:e.analysisOpen,onToggleAnalysis:e.onToggleAnalysis})]})}var KD=`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`,qD=`mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400`;function JD({title:e,credentials:t,onSetCredential:n,onDeclareProvider:r,errors:i}){let a=t.providers,[o,s]=(0,d.useState)(a.length>0?`known`:`custom`),[c,l]=(0,d.useState)(a[0]?.id??``),[u,f]=(0,d.useState)(``),[p,m]=(0,d.useState)(``),[h,g]=(0,d.useState)(``),[_,v]=(0,d.useState)(``),[y,b]=(0,d.useState)(!0),[x,S]=(0,d.useState)(!0),C=a.some(e=>e.configured)&&!t.usableModel;function w(e){if(e.preventDefault(),!C){if(o===`known`){c&&u.trim()&&n(c,u.trim());return}!p.trim()||!h.trim()||!u.trim()||!_.trim()||r({provider:p.trim(),baseUrl:h.trim(),apiKey:u.trim(),models:[_.trim()],compat:{supportsDeveloperRole:y,supportsReasoningEffort:x}})}}return(0,k.jsx)(`div`,{className:`flex h-full items-center justify-center overflow-auto p-6`,children:(0,k.jsxs)(`form`,{onSubmit:w,className:`w-full max-w-md rounded-xl border border-zinc-200 p-6 shadow-sm dark:border-zinc-800`,children:[(0,k.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),C?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`h1`,{className:`mb-3 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`No model is available.`}),(0,k.jsxs)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:[`Credentials are configured, so this is not a missing key: `,(0,k.jsx)(`code`,{children:`allowedModels`}),` in your configuration leaves nothing to choose from. Widen it, or remove it, then restart.`]})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`h1`,{className:`mb-4 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`No model provider is set up yet. Add one to start chatting.`}),(0,k.jsx)(`div`,{className:`mb-4 flex gap-1 rounded-lg bg-zinc-100 p-1 text-xs dark:bg-zinc-800`,children:[`known`,`custom`].map(e=>(0,k.jsx)(`button`,{type:`button`,onClick:()=>s(e),className:`flex-1 rounded-md px-2 py-1.5 ${o===e?`bg-white font-medium text-zinc-800 shadow-sm dark:bg-zinc-900 dark:text-zinc-100`:`text-zinc-500 dark:text-zinc-400`}`,children:e===`known`?`Provider API key`:`OpenAI-compatible endpoint`},e))}),o===`known`?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`label`,{htmlFor:`onboarding-provider`,className:qD,children:`Provider`}),(0,k.jsx)(`select`,{id:`onboarding-provider`,value:c,onChange:e=>l(e.target.value),className:`${KD} mb-3`,children:a.map(e=>(0,k.jsxs)(`option`,{value:e.id,children:[e.name,e.configured?` (already configured)`:``]},e.id))})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`label`,{htmlFor:`onboarding-name`,className:qD,children:`Name`}),(0,k.jsx)(`input`,{id:`onboarding-name`,value:p,onChange:e=>m(e.target.value),placeholder:`corp`,className:`${KD} mb-3`}),(0,k.jsx)(`label`,{htmlFor:`onboarding-url`,className:qD,children:`Base URL`}),(0,k.jsx)(`input`,{id:`onboarding-url`,value:h,onChange:e=>g(e.target.value),placeholder:`https://llm.corp.example/v1`,className:`${KD} mb-3`}),(0,k.jsx)(`label`,{htmlFor:`onboarding-model`,className:qD,children:`Model id`}),(0,k.jsx)(`input`,{id:`onboarding-model`,value:_,onChange:e=>v(e.target.value),placeholder:`gpt-oss-120b`,className:`${KD} mb-3`})]}),(0,k.jsx)(`label`,{htmlFor:`onboarding-key`,className:qD,children:`API key`}),(0,k.jsx)(`input`,{id:`onboarding-key`,type:`password`,autoComplete:`off`,value:u,onChange:e=>f(e.target.value),placeholder:`sk-…`,className:KD}),o===`custom`&&(0,k.jsxs)(`fieldset`,{className:`mt-4 rounded-lg border border-zinc-200 p-3 dark:border-zinc-800`,children:[(0,k.jsx)(`legend`,{className:`px-1 text-xs text-zinc-500 dark:text-zinc-400`,children:`Compatibility`}),(0,k.jsxs)(`label`,{className:`flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:y,onChange:e=>b(e.target.checked),className:`mt-0.5`}),(0,k.jsxs)(`span`,{children:[`Server understands the `,(0,k.jsx)(`code`,{children:`developer`}),` role. Uncheck for vLLM, SGLang and most corporate gateways — the system prompt is then sent as a `,(0,k.jsx)(`code`,{children:`system`}),` message.`]})]}),(0,k.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked),className:`mt-0.5`}),(0,k.jsxs)(`span`,{children:[`Server accepts `,(0,k.jsx)(`code`,{children:`reasoning_effort`}),`. Uncheck if it rejects unknown fields.`]})]})]}),(0,k.jsx)(`button`,{type:`submit`,className:`mt-4 w-full rounded-md bg-zinc-800 px-3 py-2 text-sm font-medium text-white hover:bg-zinc-700 dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-white`,children:`Save and start`})]}),i.map((e,t)=>(0,k.jsx)(`p`,{className:`mt-3 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-700 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:e},t)),(0,k.jsxs)(`p`,{className:`mt-4 text-center text-xs text-zinc-400 dark:text-zinc-600`,children:[t.agentDir?`Stored in ${t.agentDir}. `:``,`Provider environment variables work too, as does `,(0,k.jsx)(`code`,{children:`pi-outpost login`}),`.`]})]})})}var YD=`application/x-pi-outpost-file`,XD=`application/x-pi-outpost-read-only-file`,ZD=`mr-1 shrink-0 rounded px-1 text-xs text-zinc-400 hover:bg-zinc-200 group-hover:opacity-100 focus-visible:opacity-100 dark:text-zinc-600 dark:hover:bg-zinc-700 [@media(hover:hover)]:opacity-0`,QD={modified:{label:`M`,className:`text-amber-600 dark:text-amber-400`},added:{label:`A`,className:`text-emerald-600 dark:text-emerald-400`},untracked:{label:`U`,className:`text-emerald-600 dark:text-emerald-400`},deleted:{label:`D`,className:`text-red-600 dark:text-red-400`},conflicted:{label:`C`,className:`text-purple-600 dark:text-purple-400`}};function $D(e,t){return t?Object.keys(t).filter(t=>t.startsWith(`${e}/`)).length:0}function eO(e){return e===`directory`||e===`symlink-directory`}function tO(e,t){return t===void 0?!1:t===null||t!==``&&e!==t&&!e.startsWith(`${t}/`)}function nO({dir:e,depth:t,creation:n}){let[r,i]=(0,d.useState)(``),a=(0,d.useRef)(null),o=n.localError??n.serverError;return(0,d.useEffect)(()=>{a.current?.focus()},[]),(0,k.jsxs)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5`,children:[(0,k.jsx)(`input`,{ref:a,value:r,onChange:e=>i(e.target.value),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),n.submit(e,r)):t.key===`Escape`&&(t.preventDefault(),n.cancel())},onBlur:()=>{o===null&&n.cancel()},placeholder:`name, or name/ for a folder`,"aria-label":`New file or folder in ${e===``?`the workspace root`:e}`,spellCheck:!1,className:`w-full rounded border border-zinc-300 bg-white px-1 py-0.5 text-xs text-zinc-800 outline-none focus:border-zinc-400 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200`}),o!==null&&(0,k.jsx)(`p`,{className:`px-1 pt-0.5 text-xs text-red-600 dark:text-red-400`,children:o})]})}function rO({path:e,name:t,depth:n,rename:r}){let[i,a]=(0,d.useState)(t),o=(0,d.useRef)(null),s=r.localError??r.serverError;return(0,d.useEffect)(()=>{o.current?.focus(),o.current?.select()},[]),(0,k.jsxs)(`div`,{style:{paddingLeft:n*12+16},className:`py-0.5`,children:[(0,k.jsx)(`input`,{ref:o,value:i,disabled:r.pending,onChange:e=>a(e.target.value),onKeyDown:t=>{t.key===`Enter`&&!r.pending?(t.preventDefault(),r.submit(e,i)):t.key===`Escape`&&(t.preventDefault(),r.cancel())},onBlur:()=>{s===null&&r.cancel()},"aria-label":`Rename ${t}`,spellCheck:!1,className:`w-full rounded border border-zinc-300 bg-white px-1 py-0.5 text-xs text-zinc-800 outline-none focus:border-zinc-400 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200`}),s!==null&&(0,k.jsx)(`p`,{className:`px-1 pt-0.5 text-xs text-red-600 dark:text-red-400`,children:s})]})}function iO({path:e,depth:t,...n}){let r=n.tree[e],i=n.creation?.openIn===e?(0,k.jsx)(nO,{dir:e,depth:t,creation:n.creation}):null;return r===void 0?i:r===`loading`?(0,k.jsxs)(k.Fragment,{children:[i,(0,k.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:`loading…`})]}):`error`in r?(0,k.jsxs)(k.Fragment,{children:[i,(0,k.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-red-600 dark:text-red-400`,children:r.error})]}):r.length===0?(0,k.jsxs)(k.Fragment,{children:[i,i===null&&(0,k.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:`empty`})]}):(0,k.jsxs)(k.Fragment,{children:[i,r.map(r=>(0,k.jsx)(aO,{parentPath:e,entry:r,depth:t,...n},r.name))]})}function aO({parentPath:e,entry:t,depth:n,...r}){let[i,a]=(0,d.useState)(!1),[o,s]=(0,d.useState)(!1),c=e?`${e}/${t.name}`:t.name,l=tO(c,r.writableRoot),u=r.fileOperation?.status===`pending`;if(eO(t.type)){let e=!l&&!u,d=e=>e.includes(XD)?r.onCopyFile===void 0?null:`copy`:r.onMoveFile===void 0?null:`move`;return(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:`group flex w-full items-center rounded hover:bg-zinc-100 dark:hover:bg-zinc-800 ${o?`bg-blue-50 ring-1 ring-blue-400 dark:bg-blue-950/40`:``}`,onDragOver:t=>{if(!e||!Array.from(t.dataTransfer.types).includes(YD))return;let n=d(Array.from(t.dataTransfer.types));n!==null&&(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=n,s(!0))},onDragLeave:()=>s(!1),onDrop:t=>{if(!e)return;let n=t.dataTransfer.getData(YD),i=n?d(Array.from(t.dataTransfer.types)):null;i!==null&&(t.preventDefault(),t.stopPropagation(),s(!1),i===`copy`?r.onCopyFile?.(n,c):r.onMoveFile?.(n,c))},children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>{let e=!i;a(e),e&&r.tree[c]===void 0&&r.onExpand(c)},style:{paddingLeft:n*12},className:`flex min-w-0 flex-1 items-center gap-1 rounded py-0.5 text-left`,children:[(0,k.jsx)(`span`,{className:`w-3 shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:i?`▾`:`▸`}),(0,k.jsx)(`span`,{title:t.name,className:`truncate ${l?`text-zinc-400 dark:text-zinc-600`:`text-zinc-700 dark:text-zinc-300`}`,children:t.name}),!i&&$D(c,r.gitFiles)>0&&(0,k.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-amber-100 px-1 font-mono text-[10px] font-bold text-amber-700 dark:bg-amber-950/60 dark:text-amber-400`,title:`${$D(c,r.gitFiles)} changed file(s) inside`,children:$D(c,r.gitFiles)})]}),r.creation&&!l&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>{a(!0),r.tree[c]===void 0&&r.onExpand(c),r.creation?.start(c)},title:`New file or folder here`,"aria-label":`New file or folder in ${t.name}`,className:`mr-1 shrink-0 rounded px-1 font-mono text-xs text-zinc-400 hover:bg-zinc-200 group-hover:opacity-100 focus-visible:opacity-100 dark:text-zinc-600 dark:hover:bg-zinc-700 [@media(hover:hover)]:opacity-0`,children:`+`})]}),i&&(0,k.jsx)(iO,{path:c,depth:n+1,...r})]})}let f=c===r.openFilePath,p=r.gitFiles?.[c],m=r.attachedPaths?.includes(c)??!1,h=t.type===`file`,g=h||t.type===`symlink-file`,_=h&&!l,v=h&&(l?r.onCopyFile!==void 0:r.onMoveFile!==void 0);return r.rename?.path===c?(0,k.jsx)(rO,{path:c,name:t.name,depth:n,rename:r.rename}):(0,k.jsxs)(`div`,{className:`group flex w-full items-center rounded hover:bg-zinc-100 dark:hover:bg-zinc-800 ${f?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:[(0,k.jsx)(`button`,{type:`button`,draggable:v&&!u,onDragStart:e=>{!v||u||(e.dataTransfer.effectAllowed=l?`copy`:`move`,e.dataTransfer.setData(YD,c),l&&e.dataTransfer.setData(XD,`copy`))},onClick:()=>r.onSelectFile(c),style:{paddingLeft:n*12+16},className:`flex min-w-0 flex-1 items-center py-0.5 text-left`,children:(0,k.jsx)(`span`,{title:t.name,className:`truncate ${l?`text-zinc-400 dark:text-zinc-600`:`text-zinc-600 dark:text-zinc-400`}`,children:t.name})}),g&&r.onOpenNative&&(0,k.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>r.onOpenNative?.(c),title:`Open with the associated application`,"aria-label":`Open ${t.name} with the associated application`,className:ZD,children:`↗`}),_&&r.onRenameFile&&(0,k.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>r.rename?.start(c),title:`Rename file`,"aria-label":`Rename ${t.name}`,className:ZD,children:`✎`}),_&&r.onDeleteFile&&(0,k.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>{window.confirm(`Delete "${t.name}" permanently?`)&&r.onDeleteFile?.(c)},title:`Delete file`,"aria-label":`Delete ${t.name}`,className:`${ZD} hover:text-red-600 dark:hover:text-red-400`,children:`×`}),r.onToggleAttachPath&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>r.onToggleAttachPath?.(c),title:m?`Remove this file from the prompt`:`Reference this file in the prompt`,"aria-label":`${m?`Remove`:`Reference`} ${t.name} in the prompt`,"aria-pressed":m,className:`mr-1 shrink-0 rounded px-1 font-mono text-xs hover:bg-zinc-200 group-hover:opacity-100 focus-visible:opacity-100 dark:hover:bg-zinc-700 ${m?`font-bold text-blue-600 dark:text-blue-400`:`text-zinc-400 dark:text-zinc-600 [@media(hover:hover)]:opacity-0`}`,children:`@`}),p&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>(r.onSelectDiff??r.onSelectFile)(c),title:`Show uncommitted diff`,"aria-label":`Show diff of ${t.name}`,className:`mr-1 shrink-0 rounded px-1 font-mono text-xs font-bold hover:bg-zinc-200 dark:hover:bg-zinc-700 ${QD[p].className}`,children:QD[p].label})]})}function oO(e){let t=e.trim();if(t===``)return{error:`A name is required`};let n=t.endsWith(`/`),r=n?t.slice(0,-1).trim():t;return r===``?{error:`A name is required`}:r.includes(`/`)||r.includes(`\\`)?{error:`That is a path, not a name`}:r===`.`||r===`..`?{error:`"${r}" is not a name`}:{kind:n?`directory`:`file`,name:r}}function sO(e){let t=oO(e);return`error`in t?t:t.kind===`directory`?{error:`That is a folder name`}:{name:t.name}}function cO(e){let[t,n]=(0,d.useState)(null),[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(null),[f,p]=(0,d.useState)(null),m=e.onCreateFile!==void 0||e.onCreateDirectory!==void 0,h=e.createError&&a&&e.createError.path===lO(a.dir,a.name)?e.createError.message:null,g=e.created??null;(0,d.useEffect)(()=>{a!==null&&g!==null&&g===lO(a.dir,a.name)&&(n(null),o(null),i(null))},[a,g]);let _=e.fileOperation?.status===`error`&&e.fileOperation.operation===`rename_file`&&f===e.fileOperation.path?e.fileOperation.message:null;(0,d.useEffect)(()=>{let t=e.fileOperation;t?.status===`succeeded`&&t.operation===`rename_file`&&f===t.path&&(c(null),p(null),u(null))},[f,e.fileOperation]);let v=m?{openIn:t,localError:r,serverError:h,start:e=>{n(e),i(null),o(null)},cancel:()=>{n(null),i(null),o(null)},submit:(t,n)=>{let r=oO(n);if(`error`in r){i(r.error);return}i(null),o({dir:t,name:r.name});let a=lO(t,r.name);r.kind===`directory`?e.onCreateDirectory?.(a):e.onCreateFile?.(a)}}:void 0,y=e.onRenameFile?{path:s,pending:f!==null&&e.fileOperation?.status===`pending`&&e.fileOperation.operation===`rename_file`&&e.fileOperation.path===f,localError:l,serverError:_,start:e=>{c(e),p(null),u(null)},cancel:()=>{c(null),p(null),u(null)},submit:(t,n)=>{if(n.trim()===``){c(null),p(null),u(null);return}let r=sO(n);if(`error`in r){u(r.error);return}u(null),p(t),e.onRenameFile?.(t,r.name)}}:void 0,b=!tO(``,e.writableRoot);return(0,k.jsxs)(`div`,{className:`text-sm`,children:[e.fileOperation?.status===`error`&&e.fileOperation.operation!==`rename_file`&&(0,k.jsx)(`p`,{role:`alert`,className:`mb-1 rounded bg-red-50 px-2 py-1 text-xs text-red-700 dark:bg-red-950/40 dark:text-red-300`,children:e.fileOperation.message}),(v&&b||e.onRefresh)&&(0,k.jsxs)(`div`,{className:`mb-1 flex items-center`,children:[v&&b&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>v.start(``),"aria-label":`New file or folder in the workspace root`,className:`rounded px-1 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-600 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-400`,children:`+ new`}),e.onRefresh&&(0,k.jsx)(`button`,{type:`button`,onClick:e.onRefresh,title:`Refresh the file tree`,"aria-label":`Refresh the file tree`,className:`ml-auto rounded px-1 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-600 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-400`,children:`↻`})]}),(0,k.jsx)(iO,{path:``,depth:0,...e,...v?{creation:v}:{},...y?{rename:y}:{}})]})}function lO(e,t){return e===``?t:`${e}/${t}`}function uO({tree:e,openFile:t,writableRoot:n,gitFiles:r,attachedPaths:i,onExpand:a,onRefresh:o,onSelectFile:s,onSelectDiff:c,onToggleAttachPath:l,onCreateFile:u,onCreateDirectory:f,onOpenNative:p,onRenameFile:m,onDeleteFile:h,onMoveFile:g,onCopyFile:_,fileOperation:v,createError:y,created:b}){let x=iD(QE);return(0,d.useEffect)(()=>{e[``]===void 0&&a(``)},[]),(0,k.jsxs)(`aside`,{"aria-label":`Files`,style:{width:x.width},className:`relative flex shrink-0 flex-col border-r border-zinc-200 dark:border-zinc-800`,children:[(0,k.jsx)(`div`,{className:`border-b border-zinc-200 px-3 py-2 text-xs font-semibold uppercase text-zinc-400 dark:border-zinc-800 dark:text-zinc-600`,children:`Files`}),(0,k.jsx)(`div`,{className:`flex-1 overflow-auto p-2`,children:(0,k.jsx)(cO,{tree:e,openFilePath:t?.path,writableRoot:n,gitFiles:r,attachedPaths:i,onExpand:a,onRefresh:o,onSelectFile:s,onSelectDiff:c,onToggleAttachPath:l,onCreateFile:u,onCreateDirectory:f,onOpenNative:p,onRenameFile:m,onDeleteFile:h,onMoveFile:g,onCopyFile:_,fileOperation:v,createError:y,created:b})}),(0,k.jsx)(aD,{label:`Resize Files sidebar`,width:x.width,config:QE,separatorProps:x.separatorProps})]})}function dO({title:e,onSubmit:t}){let[n,r]=(0,d.useState)(``);return(0,k.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,k.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),n.trim()&&t(n.trim())},className:`w-full max-w-sm rounded-xl border border-zinc-200 p-6 shadow-sm dark:border-zinc-800`,children:[(0,k.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),(0,k.jsx)(`h1`,{className:`mb-4 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`This server requires an access token.`}),(0,k.jsx)(`label`,{htmlFor:`pi-outpost-token`,className:`mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400`,children:`Access token`}),(0,k.jsx)(`input`,{id:`pi-outpost-token`,name:`token`,type:`password`,autoComplete:`off`,spellCheck:!1,value:n,onChange:e=>r(e.target.value),placeholder:`paste the token…`,className:`mb-3 w-full rounded-md border border-zinc-300 bg-white px-2 py-1.5 font-mono text-sm outline-none focus:border-zinc-500 dark:border-zinc-700 dark:bg-zinc-950 dark:focus:border-zinc-500`}),(0,k.jsx)(`button`,{type:`submit`,disabled:!n.trim(),className:`w-full rounded-md border border-emerald-300 px-2 py-1.5 text-sm text-emerald-700 hover:border-emerald-500 disabled:opacity-50 dark:border-emerald-900 dark:text-emerald-400 dark:hover:border-emerald-600`,children:`Connect`}),(0,k.jsxs)(`p`,{className:`mt-3 text-center text-xs text-zinc-400 dark:text-zinc-600`,children:[`Ask the operator for the token, or open the link containing `,(0,k.jsx)(`code`,{children:`?token=…`})]})]})})}var fO={todo:{icon:`○`,label:`To do`,className:`text-zinc-500`},in_progress:{icon:`●`,label:`In progress`,className:`text-blue-600 dark:text-blue-400`},done:{icon:`✓`,label:`Done`,className:`text-emerald-600 dark:text-emerald-400`},blocked:{icon:`!`,label:`Blocked`,className:`text-red-600 dark:text-red-400`},needs_review:{icon:`?`,label:`Needs review`,className:`text-amber-600 dark:text-amber-400`}},pO=8;function mO(e){let t=e.uri.startsWith(`workspace:`)?e.uri.slice(10):/^[a-z][a-z0-9+.-]*:/i.test(e.uri)?null:e.uri;return t===null||t===``||/^(?:[\\/]|[a-z]:[\\/])/i.test(t)||t.replaceAll(`\\`,`/`).split(`/`).includes(`..`)?null:t}function hO({plan:e,open:t,onToggle:n,onOpenWorkspace:r}){let i=(0,d.useId)(),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(null);(0,d.useEffect)(()=>{s!==null&&!e.tasks.some(e=>e.id===s)&&c(null)},[e,s]),(0,d.useEffect)(()=>{if(!a)return;let e=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]);let l=(0,d.useMemo)(()=>{let t=new Map;for(let n of e.tasks)t.set(n.parentId,[...t.get(n.parentId)??[],n]);return t},[e.tasks]),u=(0,d.useMemo)(()=>new Map(e.tasks.map(e=>[e.id,e])),[e.tasks]),f=(0,d.useMemo)(()=>{let e=[],t=(n,r)=>{for(let i of l.get(n)??[])e.push({task:i,depth:r}),t(i.id,r+1)};return t(void 0,0),e.slice(0,pO)},[l]),p=s?u.get(s):void 0,m=e.tasks.filter(e=>e.status===`done`).length,h=(e,t=0)=>(l.get(e)??[]).flatMap(e=>{let n=fO[e.status];return[(0,k.jsxs)(`button`,{type:`button`,role:`treeitem`,"aria-level":t+1,"aria-selected":s===e.id,onClick:()=>c(e.id),"aria-current":e.status===`in_progress`?`step`:void 0,className:`flex w-full items-start gap-2 rounded px-2 py-1.5 text-left text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800 ${s===e.id?`bg-zinc-100 dark:bg-zinc-800`:``}`,style:{paddingLeft:`${.5+t*.85}rem`},children:[(0,k.jsx)(`span`,{className:`mt-px w-4 shrink-0 text-center font-semibold ${n.className}`,"aria-label":n.label,children:n.icon}),(0,k.jsx)(`span`,{className:e.status===`done`?`text-zinc-500 line-through`:`text-zinc-800 dark:text-zinc-200`,children:e.title})]},e.id),...h(e.id,t+1)]});return t?(0,k.jsxs)(`aside`,{"aria-label":`Work Plan`,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-[23rem] dark:border-zinc-800 dark:bg-zinc-950/95`,children:[(0,k.jsxs)(`header`,{className:`border-b border-zinc-200 px-3 py-3 dark:border-zinc-800`,children:[(0,k.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-zinc-500`,children:`Work Plan`}),(0,k.jsx)(`h2`,{className:`truncate text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:e.title})]}),(0,k.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`,"aria-label":`Close Work Plan`,children:`×`})]}),(0,k.jsxs)(`div`,{className:`mt-2 text-xs text-zinc-500`,children:[`Progress: `,m,` / `,e.tasks.length]}),(0,k.jsx)(`div`,{className:`mt-1 h-1.5 overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-800`,"aria-hidden":!0,children:(0,k.jsx)(`div`,{className:`h-full bg-emerald-500`,style:{width:`${e.tasks.length===0?0:m/e.tasks.length*100}%`}})})]}),(0,k.jsx)(`div`,{role:`tree`,"aria-label":`Work Plan tasks`,className:`min-h-0 flex-1 overflow-y-auto p-2`,children:h(void 0)}),p&&(0,k.jsxs)(`section`,{"aria-label":`Task details`,className:`max-h-[45%] overflow-y-auto border-t border-zinc-200 p-3 text-xs dark:border-zinc-800`,children:[(0,k.jsx)(`div`,{className:`font-semibold ${fO[p.status].className}`,children:fO[p.status].label}),(0,k.jsx)(`h3`,{className:`mt-1 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:p.title}),p.description&&(0,k.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-zinc-600 dark:text-zinc-300`,children:p.description}),p.statusReason&&(0,k.jsx)(`p`,{className:`mt-2 rounded bg-zinc-100 p-2 text-zinc-700 dark:bg-zinc-900 dark:text-zinc-300`,children:p.statusReason}),p.dependsOn.length>0&&(0,k.jsxs)(`div`,{className:`mt-3`,children:[(0,k.jsx)(`span`,{className:`font-semibold`,children:`Depends on:`}),` `,p.dependsOn.map(e=>u.get(e)?.title??e).join(`, `)]}),p.resources.length>0&&(0,k.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[(0,k.jsx)(`div`,{className:`font-semibold`,children:`Resources`}),p.resources.map(e=>{let t=mO(e),n=e.label??e.uri;return t===null?/^https?:/i.test(e.uri)?(0,k.jsx)(`a`,{href:e.uri,target:`_blank`,rel:`noreferrer`,className:`block truncate text-blue-600 hover:underline dark:text-blue-400`,children:n},e.uri):(0,k.jsx)(`span`,{className:`block truncate text-zinc-500`,title:`No navigator is available for this resource`,children:n},e.uri):(0,k.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left text-blue-600 hover:underline dark:text-blue-400`,onClick:()=>r(t),children:n},e.uri)})]})]})]}):(0,k.jsxs)(`div`,{className:`absolute right-3 top-3 z-20`,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),onFocusCapture:()=>o(!0),onBlurCapture:()=>o(!1),children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>{o(!1),n()},className:`rounded-md border border-zinc-300 bg-white px-2 py-1 text-xs shadow-sm dark:border-zinc-700 dark:bg-zinc-900`,"aria-label":`Open Work Plan`,"aria-describedby":i,children:[`Plan `,m,`/`,e.tasks.length]}),(0,k.jsx)(`div`,{id:i,role:`tooltip`,className:`absolute right-0 top-full w-72 pt-2 ${a?`block`:`hidden`}`,children:(0,k.jsxs)(`div`,{className:`rounded-md border border-zinc-200 bg-white p-2 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,k.jsx)(`ul`,{className:`space-y-1`,children:f.map(({task:e,depth:t})=>(0,k.jsxs)(`li`,{className:`flex min-w-0 items-start gap-1.5 text-xs`,style:{paddingLeft:`${t*.75}rem`},children:[(0,k.jsx)(`span`,{"aria-label":fO[e.status].label,className:`shrink-0 font-semibold ${fO[e.status].className}`,children:e.status===`done`?`☑`:`☐`}),(0,k.jsx)(`span`,{className:`truncate ${e.status===`done`?`text-zinc-500 line-through`:`text-zinc-800 dark:text-zinc-200`}`,children:e.title})]},e.id))}),e.tasks.length>f.length&&(0,k.jsxs)(`div`,{className:`mt-1 text-[11px] text-zinc-500`,children:[`+`,e.tasks.length-f.length,` more`]})]})})]})}var gO=`pi-outpost:token`;function _O(){let e=null;try{let t=new URL(window.location.href);return e=t.searchParams.get(`token`),e&&(localStorage.setItem(gO,e),t.searchParams.delete(`token`),window.history.replaceState(null,``,`${t.pathname}${t.search}${t.hash}`)),localStorage.getItem(gO)}catch{return e}}function vO(){try{return localStorage.getItem(gO)}catch{return null}}function yO(e){try{localStorage.setItem(gO,e)}catch{}}function bO(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}function xO(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}var SO={connected:!1,authRequired:!1,brandingReady:!1,branding:{},sessionId:``,model:``,thinkingLevel:`off`,modelSupportsReasoning:!1,models:[],commands:[],sessions:null,sessionSearch:null,tree:null,isStreaming:!1,items:[],pendingPrompt:null,workPlan:null,queue:{steering:[],followUp:[]},errors:[],contextUsage:null,isCompacting:!1,dialogQueue:[],notifications:[],statuses:{},widgets:{},editorPrefill:null,fileTree:{},directoryRequests:{},openFile:null,previewRevision:0,fileSearch:null,createError:null,created:null,fileOperation:null,extensionPaths:[],tools:[],sandbox:null,userSkillPaths:[],serverBrowse:null,settingsApply:null,versions:null,gitAvailable:!1,credentials:null,gitStatus:null,gitDiff:null,gitLog:null,gitShow:null,gitFileHistory:null,gitFileDiff:null};function CO(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 wO(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 TO(e,t){if(t.type!==`hello`&&t.type!==`session_replaced`&&t.type!==`update_config_ack`)return e;let n=t.models.find(e=>`${e.provider}/${e.id}`===t.model);return{...e,connected:!0,brandingReady:!0,branding:t.branding,sessionId:t.sessionId,model:t.model,thinkingLevel:t.thinkingLevel,modelSupportsReasoning:n?.reasoning??!1,models:t.models,commands:t.commands,isStreaming:t.isStreaming,items:t.items,pendingPrompt:null,workPlan:t.workPlan??null,queue:{steering:[],followUp:[]},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,gitAvailable:t.gitAvailable===!0,credentials:t.credentials??null,extensionPaths:t.extensionPaths??[],tools:t.tools??[],sandbox:t.sandbox??null,userSkillPaths:t.userSkillPaths??[],serverBrowse:null,settingsApply:null,versions:t.versions??null}}function EO(e,t){if(t.type===`connected`)return{...e,connected:!0,authRequired:!1};if(t.type===`auth_required`)return{...e,connected:!1,authRequired:!0};if(t.type===`auth_retrying`)return{...e,authRequired:!1};if(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;return{...e,connected:!1,openFile:n}}if(t.type===`branding_settled`)return{...e,brandingReady:!0};if(t.type===`branding_loaded`)return{...e,brandingReady:!0,branding:t.branding};if(t.type===`prompt_sent`)return{...e,pendingPrompt:{text:t.text,...t.images?.length?{images:t.images}:{}}};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}}}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===`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===`git_diff_started`||t.type===`git_diff_cleared`)return{...e,gitDiff:null};if(t.type===`git_show_cleared`)return{...e,gitShow:null,gitLog:e.gitLog};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`}};let n=t.message;switch(n.type){case`hello`:case`session_replaced`:case`update_config_ack`:return TO(e,n);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};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,credentials:n.credentials}}case`thinking_changed`:return{...e,thinkingLevel:n.level};case`work_plan_changed`:return{...e,workPlan:n.workPlan};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,queue:{steering:[],followUp:[]},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:CO(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:CO(e.items,()=>n.item)};case`custom_message`:return{...e,items:[...e.items,n.item]};case`tool_start`:return{...e,items:wO(e.items,n.toolCallId,n.toolName,{toolName:n.toolName,args:n.args,running:!0,callHtml:n.callHtml})};case`tool_update`:return{...e,items:wO(e.items,n.toolCallId,`tool`,{output:n.text})};case`tool_end`:return{...e,items:wO(e.items,n.toolCallId,`tool`,{output:n.text,isError:n.isError,running:!1,outputHtml:n.outputHtml,outputHtmlCollapsed:n.outputHtmlCollapsed,structured:n.structured})};case`queue`:return{...e,queue:{steering:n.steering,followUp:n.followUp}};case`context_usage`:return{...e,contextUsage:n.usage};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}}}}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;return{...e,openFile:r,gitFileHistory:i?null:e.gitFileHistory,gitFileDiff:i?null:e.gitFileDiff,gitDiff:a?null:e.gitDiff,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`git_status`:{let t={};for(let e of n.files)t[e.path]=e.status;return{...e,gitStatus:{branch:n.branch,ahead:n.ahead,behind:n.behind,files:t}}}case`git_diff`:return{...e,gitDiff:{path:n.path,before:n.before,after:n.after}};case`git_log`:return{...e,gitLog:n.entries};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||!xO(e.gitFileDiff,n)?e:{...e,gitFileDiff:{...e.gitFileDiff,status:`loaded`,beforeText:n.beforeText,afterText:n.afterText}};case`git_error`:return 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}}:{...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 DO(e,t){let n=e?`${e.replace(/^http/,`ws`)}/ws`:`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/ws`;return t?`${n}?token=${encodeURIComponent(t)}`:n}var OO=12e4,kO=4401;function AO(e=``,t,n=!1){let[r,i]=(0,d.useReducer)(EO,SO),a=(0,d.useRef)(null),[o,s]=(0,d.useState)(0),c=(0,d.useRef)(null);o===0&&c.current===null&&(c.current=t??(n?vO():_O()));let l=(0,d.useRef)(r.fileTree),u=(0,d.useRef)(r.openFile);(0,d.useEffect)(()=>{l.current=r.fileTree},[r.fileTree]),(0,d.useEffect)(()=>{u.current=r.openFile},[r.openFile]);let f=(0,d.useRef)(null);(0,d.useEffect)(()=>{f.current=r.gitDiff?.path??null},[r.gitDiff]);let p=(0,d.useRef)(new Map),m=(0,d.useRef)(r.writableRoot);(0,d.useEffect)(()=>{m.current=r.writableRoot},[r.writableRoot]);let h=(0,d.useCallback)(e=>{let t=a.current;t&&t.readyState===WebSocket.OPEN&&t.send(JSON.stringify(e))},[]),g=(0,d.useCallback)((e,t=!1)=>{let n=`dir:${crypto.randomUUID()}`;i({type:`dir_list_started`,path:e,requestId:n,preserveEntries:t}),h({type:`list_directory`,path:e,requestId:n})},[h]),_=(0,d.useRef)(!1),v=(0,d.useRef)(!1),y=(0,d.useRef)(!1),b=(0,d.useCallback)(()=>{if(_.current){if(v.current){y.current=!0;return}v.current=!0,h({type:`git_status`,requestId:`git:${crypto.randomUUID()}`})}},[h]),x=(0,d.useCallback)(()=>{v.current=!1,y.current&&(y.current=!1,b())},[b]),S=(0,d.useCallback)(e=>{l.current[e]!==void 0&&g(e,!0)},[g]),C=(0,d.useCallback)(()=>{for(let e of Object.keys(l.current))S(e)},[S]);return(0,d.useEffect)(()=>{let t=!1;return fetch(`${e}/branding`,{headers:c.current?{Authorization:`Bearer ${c.current}`}:{}}).then(e=>e.ok?e.json():null).then(e=>{t||i(e?{type:`branding_loaded`,branding:e}:{type:`branding_settled`})}).catch(()=>{t||i({type:`branding_settled`})}),()=>{t=!0}},[e,o]),(0,d.useEffect)(()=>{let t,n=!1;function r(){let o=new WebSocket(DO(e,c.current));a.current=o,o.onopen=()=>{a.current===o&&i({type:`connected`})},o.onmessage=e=>{if(a.current!==o)return;let t;try{t=JSON.parse(e.data)}catch{return}if(t.type===`file_uploaded`){let e=p.current.get(t.requestId);e&&(p.current.delete(t.requestId),e.resolve(t.path));return}if(t.type===`file_browser_error`&&p.current.has(t.requestId)){let e=p.current.get(t.requestId);p.current.delete(t.requestId),e.reject(new VT(t.message,t.reason));return}if(t.type===`file_changed`){S(bO(t.path));let e=u.current;if(e?.status===`loaded`&&e.path===t.path){let e=`file:${crypto.randomUUID()}`;i({type:`file_read_started`,path:t.path,requestId:e,preserveContent:!0}),h({type:`read_file`,path:t.path,requestId:e})}f.current===t.path&&h({type:`git_diff`,path:t.path,requestId:`gitdiff:${crypto.randomUUID()}`}),b();return}if(t.type===`directory_changed`){S(t.path);let e=u.current;if(e!==null&&bO(e.path)===t.path){if(te(e.path)||ne(e.path))i({type:`raw_preview_changed`,path:e.path});else if(e.status===`loaded`){let t=`file:${crypto.randomUUID()}`;i({type:`file_read_started`,path:e.path,requestId:t,preserveContent:!0}),h({type:`read_file`,path:e.path,requestId:t})}}let n=f.current;n!==null&&bO(n)===t.path&&h({type:`git_diff`,path:n,requestId:`gitdiff:${crypto.randomUUID()}`}),b();return}if((t.type===`hello`||t.type===`session_replaced`)&&(_.current=t.gitAvailable===!0,t.type===`hello`&&b()),t.type===`agent_end`&&b(),(t.type===`git_status`||t.type===`git_error`&&t.requestId.startsWith(`git:`))&&x(),t.type===`file_operation_result`){let e=t.previousPath??t.path,n=u.current;t.operation===`delete_file`&&n?.path===t.path?u.current=null:n?.path===e&&(u.current={...n,path:t.path})}i({type:`server`,message:t}),t.type===`session_replaced`&&g(``)},o.onclose=e=>{if(a.current===o){v.current=!1,y.current=!1;for(let e of p.current.values())e.reject(new VT(`The connection dropped before the upload finished`));if(p.current.clear(),e.code===kO){i({type:`auth_required`});return}i({type:`disconnected`}),n||(t=window.setTimeout(r,1500))}}}return r(),()=>{n=!0,t!==void 0&&clearTimeout(t);let e=a.current;a.current=null,e?.close()}},[h,e,b,x,S,g,o]),{state:r,authToken:c.current,submitToken:e=>{yO(e),c.current=e,i({type:`auth_retrying`}),s(e=>e+1)},prompt:(e,t)=>{i({type:`prompt_sent`,text:e,...t?.length?{images:t}:{}}),h({type:`prompt`,text:e,...t?.length?{images:t}:{}})},abort:()=>h({type:`abort`}),setModel:(e,t)=>h({type:`set_model`,provider:e,id:t}),setThinking:e=>h({type:`set_thinking`,level:e}),newSession:()=>h({type:`new_session`}),switchSession:e=>h({type:`switch_session`,path:e}),deleteSession:e=>h({type:`delete_session`,path:e}),listSessions:()=>h({type:`list_sessions`}),renameSession:(e,t)=>h({type:`rename_session`,path:e,name:t}),searchSessions:e=>{let t=`sessions:${crypto.randomUUID()}`;i({type:`session_search_started`,query:e,requestId:t}),h({type:`search_sessions`,query:e,requestId:t})},clearSessionSearch:()=>i({type:`session_search_cleared`}),listTree:()=>h({type:`list_tree`}),navigateTree:e=>h({type:`navigate_tree`,entryId:e}),forkSession:e=>h({type:`fork_session`,entryId:e}),editPrompt:(e,t,n)=>h({type:`edit_prompt`,entryId:e,text:t,...n?.length?{images:n}:{}}),compact:()=>h({type:`compact`}),respondToDialog:e=>{h({type:`extension_ui_response`,...e}),i({type:`dialog_answered`})},dismissNotification:e=>i({type:`dismiss_notification`,id:e}),listDirectory:e=>g(e),refreshFileTree:C,readFile:e=>{let t=`file:${crypto.randomUUID()}`;i({type:`file_read_started`,path:e,requestId:t}),h({type:`read_file`,path:e,requestId:t})},closeFilePreview:()=>i({type:`close_file_preview`}),writeFile:(e,t,n,r=!1)=>{let a=`write:${crypto.randomUUID()}`;i({type:`file_save_started`,path:e,requestId:a,content:t}),h({type:`write_file`,path:e,content:t,expectedMtimeMs:n,...r?{force:r}:{},requestId:a})},createFile:e=>{i({type:`file_create_started`}),h({type:`create_file`,path:e,requestId:`create:${crypto.randomUUID()}`})},uploadFile:(e,t)=>{let n=m.current;if(n===null)return Promise.reject(new VT(`the workspace is read-only`,`denied`));let r=a.current;if(!r||r.readyState!==WebSocket.OPEN)return Promise.reject(new VT(`not connected to the server`));let i=n?`${n}/${BT}`:BT,o=`upload:${crypto.randomUUID()}`;return new Promise((n,r)=>{let a=window.setTimeout(()=>{p.current.delete(o)&&r(new VT(`the upload timed out`))},OO),s=e=>t=>{clearTimeout(a),e(t)};p.current.set(o,{resolve:s(n),reject:s(r)}),h({type:`upload_file`,destinationDirectory:i,name:e,contentBase64:t,requestId:o})})},createDirectory:e=>{i({type:`file_create_started`}),h({type:`create_directory`,path:e,requestId:`create:${crypto.randomUUID()}`})},openNative:e=>{let t=`fileop:${crypto.randomUUID()}`;i({type:`file_operation_started`,operation:`open_native`,path:e,requestId:t}),h({type:`open_native`,path:e,requestId:t})},renameFile:(e,t)=>{let n=`fileop:${crypto.randomUUID()}`;i({type:`file_operation_started`,operation:`rename_file`,path:e,requestId:n}),h({type:`rename_file`,path:e,name:t,requestId:n})},deleteFile:e=>{let t=`fileop:${crypto.randomUUID()}`;i({type:`file_operation_started`,operation:`delete_file`,path:e,requestId:t}),h({type:`delete_file`,path:e,requestId:t})},moveFile:(e,t)=>{let n=`fileop:${crypto.randomUUID()}`;i({type:`file_operation_started`,operation:`move_file`,path:e,requestId:n}),h({type:`move_file`,path:e,destinationDirectory:t,requestId:n})},copyFile:(e,t)=>{let n=`fileop:${crypto.randomUUID()}`;i({type:`file_operation_started`,operation:`copy_file`,path:e,requestId:n}),h({type:`copy_file`,path:e,destinationDirectory:t,requestId:n})},searchFiles:e=>{let t=`search:${crypto.randomUUID()}`;i({type:`file_search_started`,query:e,requestId:t}),h({type:`search_files`,query:e,requestId:t})},clearFileSearch:()=>i({type:`file_search_cleared`}),fetchGitStatus:b,fetchGitDiff:e=>{let t=`gitdiff:${crypto.randomUUID()}`;i({type:`git_diff_started`,path:e,requestId:t}),h({type:`git_diff`,path:e,requestId:t})},clearGitDiff:()=>i({type:`git_diff_cleared`}),fetchGitLog:e=>h({type:`git_log`,...e?{limit:e}:{},requestId:`gitlog:${crypto.randomUUID()}`}),fetchGitShow:e=>h({type:`git_show`,sha:e,requestId:`gitshow:${crypto.randomUUID()}`}),clearGitShow:()=>i({type:`git_show_cleared`}),fetchGitFileHistory:(e,t)=>{let n=`gitfilelog:${crypto.randomUUID()}`;i({type:`git_file_history_started`,path:e,requestId:n}),h({type:`git_file_log`,path:e,...t?{limit:t}:{},requestId:n})},closeGitFileHistory:()=>i({type:`git_file_history_closed`}),fetchGitFileDiff:(e,t)=>{let n=`gitfilediff:${crypto.randomUUID()}`;i({type:`git_file_diff_started`,base:e,target:t,requestId:n}),h({type:`git_file_diff`,base:e,target:t,requestId:n})},clearGitFileDiff:()=>i({type:`git_file_diff_cleared`}),setCredential:(e,t)=>h({type:`set_credential`,provider:e,apiKey:t}),declareProvider:e=>h({type:`declare_provider`,...e}),browseServerDirectory:e=>{let t=`serverdir:${crypto.randomUUID()}`;i({type:`server_browse_started`,path:e,requestId:t}),h({type:`browse_server_directory`,path:e,requestId:t})},closeServerBrowser:()=>i({type:`server_browse_closed`}),updateConfig:e=>{i({type:`settings_apply_started`}),h({type:`update_config`,...e})}}}var jO=(0,d.forwardRef)(function({serverUrl:e=``,rootElement:t,initialTheme:n,token:r},i){let a=t!==void 0,o=t??document.documentElement,{state:s,authToken:c,submitToken:l,prompt:u,abort:f,setModel:m,setThinking:h,newSession:g,switchSession:_,deleteSession:v,listSessions:b,renameSession:x,searchSessions:S,clearSessionSearch:C,listTree:w,navigateTree:T,forkSession:E,editPrompt:ee,compact:D,respondToDialog:O,dismissNotification:ae,listDirectory:oe,refreshFileTree:se,readFile:A,writeFile:ce,createFile:le,createDirectory:j,uploadFile:ue,openNative:de,renameFile:fe,deleteFile:pe,moveFile:me,copyFile:he,closeFilePreview:ge,searchFiles:_e,clearFileSearch:ve,fetchGitDiff:ye,clearGitDiff:be,fetchGitLog:xe,fetchGitShow:Se,clearGitShow:Ce,fetchGitFileHistory:we,closeGitFileHistory:Te,fetchGitFileDiff:Ee,clearGitFileDiff:De,setCredential:Oe,declareProvider:Ae,updateConfig:je,browseServerDirectory:Me,closeServerBrowser:Ne}=AO(e,r,a),[Pe,Fe]=(0,d.useState)(!1),[Ie,Le]=(0,d.useState)([]),[Re,ze]=(0,d.useState)([]),[Be,Ve]=(0,d.useState)(null),[He,Ue]=(0,d.useState)(null),[We,M]=(0,d.useState)(null),[Ge,Ke]=(0,d.useState)(!1),N=(0,d.useRef)([]),qe=(0,d.useRef)(null),Je=(0,d.useRef)(null),[Ye,Xe]=(0,d.useState)(!1),[Ze,Qe]=(0,d.useState)(()=>{try{return localStorage.getItem(`pi-outpost:hide-tools`)===`1`}catch{return!1}});function $e(){Qe(e=>{try{localStorage.setItem(`pi-outpost:hide-tools`,e?`0`:`1`)}catch{}return!e})}let[et,tt]=(0,d.useState)(!1),[nt,rt]=(0,d.useState)(!0);function it(){let e=!et;tt(e),e&&rt(!1)}function at(){let e=!nt;rt(e),e&&tt(!1)}let[ot,st]=(0,d.useState)([]),[ct,lt]=(0,d.useState)([]),ut=(0,d.useRef)(0),dt=(0,d.useRef)(0),[ft,pt]=(0,d.useState)(0);async function mt(e){let t=[...e],n=t.filter(GT).map(e=>({id:`${ut.current++}`,name:e.name}));n.length>0&<(e=>[...e,...n]),dt.current===0&&st([]),dt.current++;try{let{attachments:e,errors:n}=await $T(t,ue);e.length>0&&Le(t=>[...t,...e]),n.length>0&&st(e=>[...e,...n])}finally{if(dt.current--,n.length>0){let e=new Set(n.map(e=>e.id));lt(t=>t.filter(t=>!e.has(t.id)))}}}(0,d.useEffect)(()=>{N.current=Ie},[Ie]),(0,d.useEffect)(()=>{let t=s.openFile;if(!t)return;let n=t.path,r=t.status===`loaded`,i=t.status===`error`&&t.message===`Binary file — preview not supported`&&re(n);if(qe.current!==n&&(qe.current=n,Je.current=null,Le(e=>e.filter(e=>e.source!==`preview`)),Ve(null),Ue(null),M(null)),Je.current===n)return;(te(n)||ne(n))&&Le(e=>e.filter(e=>e.source!==`preview`));let a=!1;async function o(){let t=te(n)?He===n?await aE(n,ie(e,n,c,s.previewRevision)):null:ne(n)?We?.path===n&&We.revision===s.previewRevision?tE(n):null:i||r?eE(n):null;if(!(a||t===null||qe.current!==n||Je.current===n)){if(typeof t==`string`){Ve(t);return}Ve(null),Le(e=>cE(e,t))}}return o(),()=>{a=!0}},[s.openFile,s.previewRevision,e,c,He,We]);function ht(){qe.current=null,Je.current=null,ge()}let gt=(0,d.useMemo)(()=>[...Ie.filter(e=>e.kind===`path`).map(e=>e.data),...Re],[Ie,Re]);function _t(e){let t=N.current.findIndex(t=>t.kind===`path`&&t.data===e);t>=0?vt(t):Re.includes(e)||Le(t=>sE(t,e))}function vt(e){let t=N.current[e];t?.source===`preview`&&(Je.current=t.previewPath??qe.current,Ve(null)),Le(t=>lE(t,e))}function yt(e,t){u(e,t),Le([]),st([]),Ve(null),Ge||ht()}function bt(e){e.preventDefault(),pt(0),e.dataTransfer.files.length>0&&mt(Array.from(e.dataTransfer.files))}let{theme:xt,toggle:St,setTheme:Ct}=y(s.branding.defaultTheme??`system`,s.branding.allowThemeToggle!==!1,o,n);(0,d.useImperativeHandle)(i,()=>({setTheme:Ct}),[Ct]);let wt=(0,d.useRef)(null),Tt=(0,d.useRef)(null),Et=(0,d.useRef)(!0);function Dt(){let e=wt.current;e&&(Et.current=e.scrollHeight-e.scrollTop-e.clientHeight<120)}(0,d.useEffect)(()=>{Et.current&&Tt.current?.scrollIntoView({behavior:`smooth`})},[s.items]);let Ot=(0,d.useMemo)(()=>oT(s.items),[s.items]),kt=(0,d.useMemo)(()=>et?gT(s.items):null,[et,s.items]),At=(0,d.useMemo)(()=>H_({readFile:e=>{Xe(!1),A(e)},fetchGitFileHistory:e=>we(e),fetchGitDiff:e=>{Xe(!0),A(e)},searchFiles:e=>_e(e)}),[A,we,_e]),jt=(0,d.useCallback)(()=>Qe(!1),[]),{jumpToItem:Mt,highlightIndex:Nt}=FT({items:s.items,scrollerRef:wt,hideTools:Ze,onShowTools:jt,stickToBottom:Et});return(0,d.useEffect)(()=>{a||(document.title=s.extensionTitle??s.branding.title??`pi`),s.branding.accentColor&&o.style.setProperty(`--accent`,s.branding.accentColor)},[s.branding,s.extensionTitle,a,o]),a&&!s.brandingReady?null:s.authRequired?(0,k.jsx)(p.Provider,{value:xt,children:(0,k.jsx)(dO,{title:s.branding.title,onSubmit:l})}):s.credentials&&!s.credentials.usableModel?(0,k.jsx)(p.Provider,{value:xt,children:(0,k.jsx)(JD,{title:s.branding.title,credentials:s.credentials,onSetCredential:Oe,onDeclareProvider:Ae,errors:s.errors})}):(0,k.jsxs)(p.Provider,{value:xt,children:[(0,k.jsxs)(`div`,{className:`relative flex h-full`,onDragEnter:e=>{e.dataTransfer.types.includes(`Files`)&&pt(e=>e+1)},onDragLeave:()=>pt(e=>Math.max(0,e-1)),onDragOver:e=>e.preventDefault(),onDrop:bt,children:[ft>0&&(0,k.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,k.jsx)(`p`,{className:`text-lg font-medium text-zinc-700 dark:text-zinc-200`,children:`Drop files to attach (images, documents & text)`})}),Pe&&(0,k.jsx)(uO,{tree:s.fileTree,openFile:s.openFile,writableRoot:s.writableRoot,gitFiles:s.gitStatus?.files,attachedPaths:gt,onExpand:oe,onRefresh:se,onSelectFile:e=>{Xe(!1),A(e)},onSelectDiff:e=>{Xe(!0),A(e)},onToggleAttachPath:_t,onCreateFile:e=>{Xe(!1),le(e)},onCreateDirectory:j,onOpenNative:de,onRenameFile:fe,onDeleteFile:pe,onMoveFile:me,onCopyFile:he,fileOperation:s.fileOperation,createError:s.createError,created:s.created}),(0,k.jsxs)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,children:[(0,k.jsx)(BD,{title:s.branding.title,sessions:s.sessions,sessionSearch:s.sessionSearch,sessionId:s.sessionId,tree:s.tree,isStreaming:s.isStreaming,connected:s.connected,theme:xt,showThemeToggle:s.branding.allowThemeToggle!==!1,statuses:s.statuses,sidebarOpen:Pe,hideTools:Ze,onToggleSidebar:()=>Fe(!Pe),onToggleHideTools:$e,onToggleTheme:St,onNewSession:g,onSwitchSession:_,onDeleteSession:v,onListSessions:b,onRenameSession:x,onSearchSessions:S,onClearSessionSearch:C,onListTree:w,onNavigateTree:T,onForkSession:E,gitAvailable:s.gitAvailable,gitStatus:s.gitStatus,gitLog:s.gitLog,extensionPaths:s.extensionPaths,tools:s.tools,commands:s.commands,sandbox:s.sandbox,userSkillPaths:s.userSkillPaths,serverBrowse:s.serverBrowse,settingsApply:s.settingsApply,versions:s.versions,onBrowseServerPath:Me,onCloseServerBrowser:Ne,onUpdateConfig:je,onFetchGitLog:xe,onShowCommit:Se}),(0,k.jsxs)(`div`,{className:`relative z-0 flex min-h-0 flex-1 flex-col`,children:[s.workPlan&&(0,k.jsx)(hO,{plan:s.workPlan,open:nt,onToggle:at,onOpenWorkspace:e=>{Xe(!1),A(e)}}),s.openFile&&(0,k.jsx)(qE,{file:s.openFile,writableRoot:s.writableRoot,isStreaming:s.isStreaming,onDirtyChange:Ke,gitState:s.gitStatus?.files[s.openFile.path],initialShowGitDiff:Ye,gitDiff:s.gitDiff,onFetchGitDiff:ye,onClearGitDiff:be,gitAvailable:s.gitAvailable,onOpenGitHistory:we,onClose:ht,onReload:A,onSave:ce,serverUrl:e,token:c,onImageLoad:Ue,onPdfLoad:e=>M({path:e,revision:s.previewRevision}),rawRevision:s.previewRevision},s.openFile.path),s.gitFileHistory&&(0,k.jsx)(yD,{history:s.gitFileHistory,diff:s.gitFileDiff,dirty:s.gitStatus?.files[s.gitFileHistory.path]!==void 0,onFetchDiff:Ee,onClearDiff:De,onClose:Te}),s.gitShow&&(0,k.jsx)(YE,{show:s.gitShow,onClose:Ce}),kt&&(0,k.jsx)(NT,{analysis:kt,onJump:Mt,onClose:()=>tt(!1)}),(0,k.jsx)(`main`,{ref:wt,onScroll:Dt,className:`flex-1 overflow-y-auto ${et?`md:pr-[26rem]`:s.workPlan&&nt?`md:pr-[23rem]`:``}`,children:(0,k.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-3 px-4 py-6`,children:[s.items.length===0&&(0,k.jsxs)(`div`,{className:`mt-24 text-center text-zinc-500 dark:text-zinc-600`,children:[(0,k.jsx)(`div`,{className:`mb-2 text-4xl`,children:s.branding.title??`π`}),(0,k.jsx)(`p`,{className:`text-sm`,children:s.branding.welcome??`Send a message to start the agent.`})]}),s.items.map((t,n)=>{let r=`${s.sessionId}:${n}`,i=(e,t=r)=>(0,k.jsx)(`div`,{"data-item-index":n,className:`flex flex-col gap-3 rounded-lg transition-shadow ${Nt===n?`ring-2 ring-blue-400 dark:ring-blue-500`:``}`,children:e},t);if(t.kind===`user`){let e=n===s.items.length-1&&s.isStreaming;return i((0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(ke,{item:t,canEdit:!s.isStreaming&&s.connected,onEdit:ee}),e&&(0,k.jsx)(`div`,{className:`flex justify-end px-4`,children:(0,k.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,k.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,k.jsx)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`working…`})]})})]}))}return t.kind===`tool`?Ze?null:i((0,k.jsx)(rT,{item:t,dispatch:At}),t.toolCallId?`${s.sessionId}:${t.toolCallId}`:r):t.kind===`custom`?i((0,k.jsx)(iT,{item:t})):t.blocks.length===0&&!t.errorMessage?(0,k.jsx)(`div`,{"data-item-index":n,className:`sr-only`,"aria-hidden":!0},r):i((0,k.jsx)(z_,{item:t,serverUrl:e,token:c,onOpenFile:e=>{Xe(!1),A(e)}}))}),s.pendingPrompt&&(0,k.jsxs)(`div`,{className:`flex flex-col gap-3 opacity-60`,"data-pending-prompt":!0,children:[(0,k.jsx)(ke,{item:{kind:`user`,...s.pendingPrompt},canEdit:!1,onEdit:()=>{}}),(0,k.jsx)(`div`,{className:`flex justify-end px-4`,children:(0,k.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,k.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,k.jsx)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`sending…`})]})})]}),(s.queue.steering.length>0||s.queue.followUp.length>0)&&(0,k.jsxs)(`div`,{className:`rounded-lg border border-dashed border-zinc-300 px-3 py-2 text-xs text-zinc-500 dark:border-zinc-700`,children:[s.queue.steering.map((e,t)=>(0,k.jsxs)(`div`,{children:[`⏩ steering: `,e]},`s${t}`)),s.queue.followUp.map((e,t)=>(0,k.jsxs)(`div`,{children:[`⏭ follow-up: `,e]},`f${t}`))]}),ot.map((e,t)=>(0,k.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}`)),Be&&(0,k.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:Be}),s.errors.map((e,t)=>(0,k.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,k.jsx)(`div`,{ref:Tt})]})})]}),(0,k.jsx)(`footer`,{className:`border-t border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:(0,k.jsxs)(`div`,{className:`mx-auto max-w-3xl`,children:[(0,k.jsx)(LE,{widgets:s.widgets,placement:`aboveEditor`}),(0,k.jsx)(_E,{isStreaming:s.isStreaming,connected:s.connected,commands:s.commands,fileSearch:s.fileSearch,prefill:s.editorPrefill,attachments:Ie,pendingUploads:ct,onAttach:e=>void mt(e),onMentionPaths:ze,onRemoveAttachment:vt,onSend:yt,onAbort:f,onSearchFiles:_e,onClearFileSearch:ve}),(0,k.jsx)(LE,{widgets:s.widgets,placement:`belowEditor`}),(0,k.jsx)(GD,{model:s.model,models:s.models,thinkingLevel:s.thinkingLevel,modelSupportsReasoning:s.modelSupportsReasoning,isStreaming:s.isStreaming,contextUsage:s.contextUsage,sessionUsage:Ot,analysisOpen:et,onToggleAnalysis:it,isCompacting:s.isCompacting,onSetModel:m,onSetThinking:h,onCompact:D})]})})]})]}),s.dialogQueue[0]&&(0,k.jsx)(DE,{request:s.dialogQueue[0],onRespond:O}),(0,k.jsx)(AE,{notifications:s.notifications,onDismiss:ae})]})});(0,f.createRoot)(document.getElementById(`root`)).render((0,k.jsx)(d.StrictMode,{children:(0,k.jsx)(jO,{})}));export{i,oe as n,ie as r,j as t};
|