pi-outpost 0.2.0 → 0.3.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.
Files changed (98) hide show
  1. package/dist/pi-outpost.mjs +2138 -1873
  2. package/dist/web/assets/{abnfDiagram-VRR7QNED-DyTugtC3.js → abnfDiagram-VRR7QNED-BhfavjEu.js} +1 -1
  3. package/dist/web/assets/{arc-DHt2TUUm.js → arc-DLjX3VI2.js} +1 -1
  4. package/dist/web/assets/architecture-TIHT7OUA-XPnUxZI-.js +1 -0
  5. package/dist/web/assets/{architectureDiagram-ZJ3FMSHR-CFDiqWXU.js → architectureDiagram-ZJ3FMSHR-CmdbEtjW.js} +1 -1
  6. package/dist/web/assets/{blockDiagram-677ZJIJ3-qmfGG5I9.js → blockDiagram-677ZJIJ3-j6l3LcXM.js} +1 -1
  7. package/dist/web/assets/{c4Diagram-LMCZKHZV-CRXEyNLp.js → c4Diagram-LMCZKHZV-D0URUN1V.js} +1 -1
  8. package/dist/web/assets/channel-p4_3NNOk.js +1 -0
  9. package/dist/web/assets/{chunk-32BRIVSS-CapgtnO9.js → chunk-32BRIVSS-DkghKuj9.js} +1 -1
  10. package/dist/web/assets/{chunk-52WLFC77-CqTmO707.js → chunk-52WLFC77-BP6K7b5M.js} +1 -1
  11. package/dist/web/assets/{chunk-C7G6YPKG-DHsdhRRY.js → chunk-C7G6YPKG-NWkQWxWt.js} +1 -1
  12. package/dist/web/assets/{chunk-EX3LRPZG-DkFMWzHW.js → chunk-EX3LRPZG-m-LZ-Ro8.js} +1 -1
  13. package/dist/web/assets/{chunk-FWX5IMBZ-BRLhDQLL.js → chunk-FWX5IMBZ-N3jYudGc.js} +2 -2
  14. package/dist/web/assets/{chunk-HOUHSVGY-DpbDEAYg.js → chunk-HOUHSVGY-Jhw2hKNK.js} +1 -1
  15. package/dist/web/assets/{chunk-ICXQ74PX-RUrz3KPn.js → chunk-ICXQ74PX-CwDcD03G.js} +1 -1
  16. package/dist/web/assets/{chunk-MOJQB5TN-DtQLThmV.js → chunk-MOJQB5TN-BMjCksi0.js} +1 -1
  17. package/dist/web/assets/{chunk-OGEWGWER-lhbXpzry.js → chunk-OGEWGWER-DuJMYljv.js} +1 -1
  18. package/dist/web/assets/{chunk-PUDLZKDR-AsFMjQWN.js → chunk-PUDLZKDR-B_Qbplt0.js} +1 -1
  19. package/dist/web/assets/{chunk-Q4XR5HBZ-B7Ncn-AX.js → chunk-Q4XR5HBZ-DtdWWHaU.js} +1 -1
  20. package/dist/web/assets/{chunk-RYQCIY6F-BsMzOt5q.js → chunk-RYQCIY6F-utMO3_XT.js} +1 -1
  21. package/dist/web/assets/{chunk-V7JOEXUC-pNaL7URz.js → chunk-V7JOEXUC-D6FyidB_.js} +1 -1
  22. package/dist/web/assets/{chunk-VAUOI2AC-DSddyIBF.js → chunk-VAUOI2AC-CgjFnEX7.js} +1 -1
  23. package/dist/web/assets/{chunk-VR4S4FIN-CBdIUmlX.js → chunk-VR4S4FIN-BwuA7L77.js} +1 -1
  24. package/dist/web/assets/{chunk-WYO6CB5R-RxW9XP1F.js → chunk-WYO6CB5R-BtV2xO2Q.js} +3 -3
  25. package/dist/web/assets/{chunk-XXDRQBXY-B0I47CFW.js → chunk-XXDRQBXY-BWHH-gRy.js} +1 -1
  26. package/dist/web/assets/{chunk-ZGVPDNZ5-DYYtoOaY.js → chunk-ZGVPDNZ5-D1Lvtv49.js} +1 -1
  27. package/dist/web/assets/classDiagram-OUVF2IWQ-8t5_YtRr.js +1 -0
  28. package/dist/web/assets/classDiagram-v2-EOCWNBFH-8t5_YtRr.js +1 -0
  29. package/dist/web/assets/{core-BHBAuxkq.js → core-wWNe51ur.js} +1 -1
  30. package/dist/web/assets/{cose-bilkent-JH36ORCC-BFysmSGi.js → cose-bilkent-JH36ORCC-BQZe9Q-i.js} +1 -1
  31. package/dist/web/assets/{cynefin-VYW2F7L2-CtZoUT8E.js → cynefin-VYW2F7L2-DeDUTD7g.js} +1 -1
  32. package/dist/web/assets/{cynefinDiagram-TSTJHNR4-EYIm0-LP.js → cynefinDiagram-TSTJHNR4-DVUV4NfY.js} +1 -1
  33. package/dist/web/assets/{dagre-VKFMJZFB-CPrPbSQs.js → dagre-VKFMJZFB-4XAIuxfA.js} +1 -1
  34. package/dist/web/assets/{diagram-FQU43EPY-DzI5YtBl.js → diagram-FQU43EPY-dTPlQLms.js} +1 -1
  35. package/dist/web/assets/{diagram-G47NLZAW-CVm7yEcb.js → diagram-G47NLZAW-BVb0jmUr.js} +1 -1
  36. package/dist/web/assets/{diagram-NH7WQ7WH-DZDQMOgN.js → diagram-NH7WQ7WH-Dtkm_LgV.js} +1 -1
  37. package/dist/web/assets/{diagram-OA4YK3LP-D6O753w0.js → diagram-OA4YK3LP-CNy5OqL9.js} +1 -1
  38. package/dist/web/assets/{diagram-WEI45ONY-ADgMpfWd.js → diagram-WEI45ONY-BFjHRBl0.js} +1 -1
  39. package/dist/web/assets/{dist-DNR3APKC.js → dist-Cgv8SaeJ.js} +1 -1
  40. package/dist/web/assets/{ebnfDiagram-CCIWWBDH-56NNsTMK.js → ebnfDiagram-CCIWWBDH-D999wIEM.js} +1 -1
  41. package/dist/web/assets/{erDiagram-Q63AITRT-DIOeQwqc.js → erDiagram-Q63AITRT-qYYFWVwG.js} +1 -1
  42. package/dist/web/assets/eventmodeling-45OFAUF4-Dr6FIrRs.js +1 -0
  43. package/dist/web/assets/flowDiagram-23GEKE2U-z48g1jcH.js +1 -0
  44. package/dist/web/assets/{ganttDiagram-NO4QXBWP-CA0OF1Jg.js → ganttDiagram-NO4QXBWP-BoAFL_1F.js} +1 -1
  45. package/dist/web/assets/{gitGraph-TEB2WS4Q-ceD37YlU.js → gitGraph-TEB2WS4Q-C9Mbw7PG.js} +1 -1
  46. package/dist/web/assets/{gitGraphDiagram-IHSO6WYX-D_drA21h.js → gitGraphDiagram-IHSO6WYX-C8IvYsGK.js} +1 -1
  47. package/dist/web/assets/{index-dEwSSQiW.js → index-XP3rLk7n.js} +6 -6
  48. package/dist/web/assets/index-fDajbXRI.css +2 -0
  49. package/dist/web/assets/{info-DKCQHKI2-CVjVV2P5.js → info-DKCQHKI2-Dka7LnI7.js} +1 -1
  50. package/dist/web/assets/{infoDiagram-FWYZ7A6U-BCwxVokG.js → infoDiagram-FWYZ7A6U-D7kKqeDg.js} +1 -1
  51. package/dist/web/assets/{ishikawaDiagram-FXEZZL3T-BQeHZ-yg.js → ishikawaDiagram-FXEZZL3T-C5WAl0pd.js} +1 -1
  52. package/dist/web/assets/{journeyDiagram-5HDEW3XC-BXWA3oPf.js → journeyDiagram-5HDEW3XC-CzAR5nmv.js} +1 -1
  53. package/dist/web/assets/{kanban-definition-HUTT4EX6-Cfqco1PJ.js → kanban-definition-HUTT4EX6-9vPPiBM2.js} +1 -1
  54. package/dist/web/assets/{line-CrvrhSbg.js → line-B8K8XBOo.js} +1 -1
  55. package/dist/web/assets/{linear-DWxORDoa.js → linear-Bc5WxYEm.js} +1 -1
  56. package/dist/web/assets/{mermaid-parser.core-D_NpPT9S.js → mermaid-parser.core-Dz41Srsx.js} +3 -3
  57. package/dist/web/assets/{mermaid.core-NRhrhWN4.js → mermaid.core-BMxZKY0U.js} +3 -3
  58. package/dist/web/assets/{mindmap-definition-LN4V7U3C-B89LbLGT.js → mindmap-definition-LN4V7U3C-XTb-dbox.js} +1 -1
  59. package/dist/web/assets/{packet-7NZHBO7P-jbOvIk5F.js → packet-7NZHBO7P-BaZ2vLSM.js} +1 -1
  60. package/dist/web/assets/{pegDiagram-2B236MQR-DQB7fSG4.js → pegDiagram-2B236MQR-BVoocwf_.js} +1 -1
  61. package/dist/web/assets/{pie-RZYD4A2V-CYLII1P4.js → pie-RZYD4A2V-Dyv85T8M.js} +1 -1
  62. package/dist/web/assets/{pieDiagram-ENE6RG2P-CbWB353C.js → pieDiagram-ENE6RG2P-7iFT_zez.js} +1 -1
  63. package/dist/web/assets/{quadrantDiagram-ABIIQ3AL-D_9jqRk3.js → quadrantDiagram-ABIIQ3AL-CHlGWqOk.js} +1 -1
  64. package/dist/web/assets/{radar-I7S5WNFK-DjU6_iv-.js → radar-I7S5WNFK-DyoUubVI.js} +1 -1
  65. package/dist/web/assets/{railroad-3IZDKUUU-BAihy3Rb.js → railroad-3IZDKUUU-BDILfUxc.js} +1 -1
  66. package/dist/web/assets/railroad-abnf-AHOZXSZD-Dngw_ylY.js +1 -0
  67. package/dist/web/assets/railroad-ebnf-EBAXGLYW-1fBrjH0I.js +1 -0
  68. package/dist/web/assets/railroad-peg-LSFZ7HO6-BYDecUZD.js +1 -0
  69. package/dist/web/assets/{railroadDiagram-RFXS5EU6-DS56z8RW.js → railroadDiagram-RFXS5EU6-BiCGOHbk.js} +1 -1
  70. package/dist/web/assets/{requirementDiagram-TGXJPOKE-D07l8k2C.js → requirementDiagram-TGXJPOKE-CtghB3_m.js} +1 -1
  71. package/dist/web/assets/{sankeyDiagram-HTMAVEWB-05d9dADb.js → sankeyDiagram-HTMAVEWB-Bdf1EJNu.js} +1 -1
  72. package/dist/web/assets/{sequenceDiagram-DBY2YBRQ-BzvusKI9.js → sequenceDiagram-DBY2YBRQ-Dj5IiYEz.js} +1 -1
  73. package/dist/web/assets/{src-GZGxykLV.js → src-CY8AJSRs.js} +1 -1
  74. package/dist/web/assets/{stateDiagram-2N3HPSRC-CSb3kiFC.js → stateDiagram-2N3HPSRC--Qj4NOZR.js} +1 -1
  75. package/dist/web/assets/stateDiagram-v2-6OUMAXLB-DmKE_saV.js +1 -0
  76. package/dist/web/assets/{swimlanes-5IMT3BWC-CBbA1eIT.js → swimlanes-5IMT3BWC-qozSO6gA.js} +1 -1
  77. package/dist/web/assets/swimlanesDiagram-G3AALYLV-CumeKTRn.js +8 -0
  78. package/dist/web/assets/{timeline-definition-FHXFAJF6-V71sYDdF.js → timeline-definition-FHXFAJF6-1uyEGgPJ.js} +1 -1
  79. package/dist/web/assets/{treeView-QDETBFTQ-DyqbAZcr.js → treeView-QDETBFTQ-C1WlQ5Kz.js} +1 -1
  80. package/dist/web/assets/{treemap-6X3UGDF4-BgtupQXG.js → treemap-6X3UGDF4-4gpmZcd4.js} +1 -1
  81. package/dist/web/assets/{vennDiagram-L72KCM5P-BhBfW1jG.js → vennDiagram-L72KCM5P-iKYKPPHC.js} +1 -1
  82. package/dist/web/assets/{wardley-OPB4EBWU-BJ5M-s4O.js → wardley-OPB4EBWU-hjOSu12K.js} +1 -1
  83. package/dist/web/assets/{wardleyDiagram-EHGQE667-DmEqSETC.js → wardleyDiagram-EHGQE667-BfJWpfvQ.js} +1 -1
  84. package/dist/web/assets/{xychartDiagram-FW5EYKEG-DUOmVba-.js → xychartDiagram-FW5EYKEG-BuH9TbPE.js} +1 -1
  85. package/dist/web/index.html +2 -2
  86. package/package.json +1 -1
  87. package/dist/web/assets/architecture-TIHT7OUA-CCp2jxCm.js +0 -1
  88. package/dist/web/assets/channel-BO1tulyH.js +0 -1
  89. package/dist/web/assets/classDiagram-OUVF2IWQ-CvAPo5I5.js +0 -1
  90. package/dist/web/assets/classDiagram-v2-EOCWNBFH-CvAPo5I5.js +0 -1
  91. package/dist/web/assets/eventmodeling-45OFAUF4-tpk0pa4S.js +0 -1
  92. package/dist/web/assets/flowDiagram-23GEKE2U-D8FOAi3P.js +0 -1
  93. package/dist/web/assets/index-DqUCj-Bo.css +0 -2
  94. package/dist/web/assets/railroad-abnf-AHOZXSZD-as7WlUeV.js +0 -1
  95. package/dist/web/assets/railroad-ebnf-EBAXGLYW-BHLEVv5d.js +0 -1
  96. package/dist/web/assets/railroad-peg-LSFZ7HO6-kR8sIYF7.js +0 -1
  97. package/dist/web/assets/stateDiagram-v2-6OUMAXLB-Cuc6o-9-.js +0 -1
  98. package/dist/web/assets/swimlanesDiagram-G3AALYLV-TtCRS4op.js +0 -8
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-NRhrhWN4.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-GZGxykLV.js","assets/chunk-WYO6CB5R-RxW9XP1F.js","assets/chunk-ICXQ74PX-RUrz3KPn.js","assets/dist-DNR3APKC.js","assets/chunk-VAUOI2AC-DSddyIBF.js","assets/chunk-HOUHSVGY-DpbDEAYg.js","assets/chunk-Q4XR5HBZ-B7Ncn-AX.js","assets/chunk-7BUUIJ7U-Bb538aSH.js","assets/chunk-OGEWGWER-lhbXpzry.js","assets/chunk-C7G6YPKG-DHsdhRRY.js","assets/chunk-ZGVPDNZ5-DYYtoOaY.js","assets/rough.esm-CSKSodPl.js","assets/chunk-52WLFC77-CqTmO707.js","assets/line-CrvrhSbg.js","assets/path-BWPyau1x.js","assets/array-BifhSqXX.js","assets/chunk-FWX5IMBZ-BRLhDQLL.js","assets/chunk-ZIRB5QZD-C6fEPe3t.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-BMxZKY0U.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-CY8AJSRs.js","assets/chunk-WYO6CB5R-BtV2xO2Q.js","assets/chunk-ICXQ74PX-CwDcD03G.js","assets/dist-Cgv8SaeJ.js","assets/chunk-VAUOI2AC-CgjFnEX7.js","assets/chunk-HOUHSVGY-Jhw2hKNK.js","assets/chunk-Q4XR5HBZ-DtdWWHaU.js","assets/chunk-7BUUIJ7U-Bb538aSH.js","assets/chunk-OGEWGWER-DuJMYljv.js","assets/chunk-C7G6YPKG-NWkQWxWt.js","assets/chunk-ZGVPDNZ5-D1Lvtv49.js","assets/rough.esm-CSKSodPl.js","assets/chunk-52WLFC77-BP6K7b5M.js","assets/line-B8K8XBOo.js","assets/path-BWPyau1x.js","assets/array-BifhSqXX.js","assets/chunk-FWX5IMBZ-N3jYudGc.js","assets/chunk-ZIRB5QZD-C6fEPe3t.js"])))=>i.map(i=>d[i]);
2
2
  var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));(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),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=o((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 k(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 A=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)},j={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=j,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:k}},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,A)}catch(e){A(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.7`})),d=o(((e,t)=>{t.exports=u()})),f=o((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}}}})),p=o(((e,t)=>{t.exports=f()})),m=o((e=>{var t=d();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.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 o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.7`})),h=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=m()})),g=o((e=>{var t=p(),n=d(),r=h();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){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 s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}var m=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 k=Array.isArray,A=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,j=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,M={pending:!1,data:null,method:null,action:null},oe=[],se=-1;function ce(e){return{current:e}}function le(e){0>se||(e.current=oe[se],oe[se]=null,se--)}function ue(e,t){se++,oe[se]=e.current,e.current=t}var de=ce(null),fe=ce(null),pe=ce(null),me=ce(null);function he(e,t){switch(ue(pe,t),ue(fe,e),ue(de,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}}le(de),ue(de,e)}function ge(){le(de),le(fe),le(pe)}function _e(e){e.memoizedState!==null&&ue(me,e);var t=de.current,n=Ud(t,e.type);t!==n&&(ue(fe,e),ue(de,n))}function ve(e){fe.current===e&&(le(de),le(fe)),me.current===e&&(le(me),Qf._currentValue=M)}var ye,be;function xe(e){if(ye===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ye=t&&t[1]||``,be=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+ye+e+be}var Se=!1;function Ce(e,t){if(!e||Se)return``;Se=!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(`
@@ -297,7 +297,7 @@ l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
297
297
  `,inConstruct:`mathFlowMeta`},{character:`$`,after:t?void 0:`\\$`,inConstruct:`phrasing`},{character:`$`,inConstruct:`mathFlowMeta`},{atBreak:!0,character:`$`,after:`\\$`}],handlers:{math:n,inlineMath:r}};function n(e,t,n,r){let i=e.value||``,a=n.createTracker(r),o=`$`.repeat(Math.max(Hm(i,`$`)+1,2)),s=n.enter(`mathFlow`),c=a.move(o);if(e.meta){let t=n.enter(`mathFlowMeta`);c+=a.move(n.safe(e.meta,{after:`
298
298
  `,before:c,encode:[`$`],...a.current()})),t()}return c+=a.move(`
299
299
  `),i&&(c+=a.move(i+`
300
- `)),c+=a.move(o),s(),c}function r(e,n,r){let i=e.value||``,a=1;for(t||a++;RegExp(`(^|[^$])`+`\\$`.repeat(a)+`([^$]|$)`).test(i);)a++;let o=`$`.repeat(a);/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^\$|\$$/.test(i))&&(i=` `+i+` `);let s=-1;for(;++s<r.unsafe.length;){let e=r.unsafe[s];if(!e.atBreak)continue;let t=r.compilePattern(e),n;for(;n=t.exec(i);){let e=n.index;i.codePointAt(e)===10&&i.codePointAt(e-1)===13&&e--,i=i.slice(0,e)+` `+i.slice(n.index+1)}}return o+i+o}function i(){return`$`}}var Kg={tokenize:Jg,concrete:!0,name:`mathFlow`},qg={tokenize:Yg,partial:!0};function Jg(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){return e.enter(`mathFlow`),e.enter(`mathFlowFence`),e.enter(`mathFlowFenceSequence`),c(t)}function c(t){return t===36?(e.consume(t),o++,c):o<2?n(t):(e.exit(`mathFlowFenceSequence`),Zt(e,l,`whitespace`)(t))}function l(t){return t===null||N(t)?d(t):(e.enter(`mathFlowFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===null||N(t)?(e.exit(`chunkString`),e.exit(`mathFlowFenceMeta`),d(t)):t===36?n(t):(e.consume(t),u)}function d(n){return e.exit(`mathFlowFence`),r.interrupt?t(n):e.attempt(qg,f,g)(n)}function f(t){return e.attempt({tokenize:_,partial:!0},g,p)(t)}function p(t){return(a?Zt(e,m,`linePrefix`,a+1):m)(t)}function m(t){return t===null?g(t):N(t)?e.attempt(qg,f,g)(t):(e.enter(`mathFlowValue`),h(t))}function h(t){return t===null||N(t)?(e.exit(`mathFlowValue`),m(t)):(e.consume(t),h)}function g(n){return e.exit(`mathFlow`),t(n)}function _(e,t,n){let i=0;return Zt(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4);function a(t){return e.enter(`mathFlowFence`),e.enter(`mathFlowFenceSequence`),s(t)}function s(t){return t===36?(i++,e.consume(t),s):i<o?n(t):(e.exit(`mathFlowFenceSequence`),Zt(e,c,`whitespace`)(t))}function c(r){return r===null||N(r)?(e.exit(`mathFlowFence`),t(r)):n(r)}}}function Yg(e,t,n){let r=this;return i;function i(n){return n===null?t(n):(e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function Xg(e){let t=(e||{}).singleDollarTextMath;return t??=!0,{tokenize:n,resolve:Zg,previous:Qg,name:`mathText`};function n(e,n,r){let i=0,a,o;return s;function s(t){return e.enter(`mathText`),e.enter(`mathTextSequence`),c(t)}function c(n){return n===36?(e.consume(n),i++,c):i<2&&!t?r(n):(e.exit(`mathTextSequence`),l(n))}function l(t){return t===null?r(t):t===36?(o=e.enter(`mathTextSequence`),a=0,d(t)):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),l):N(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),l):(e.enter(`mathTextData`),u(t))}function u(t){return t===null||t===32||t===36||N(t)?(e.exit(`mathTextData`),l(t)):(e.consume(t),u)}function d(t){return t===36?(e.consume(t),a++,d):a===i?(e.exit(`mathTextSequence`),e.exit(`mathText`),n(t)):(o.type=`mathTextData`,u(t))}}}function Zg(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===`mathTextData`){e[t][1].type=`mathTextPadding`,e[n][1].type=`mathTextPadding`,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=`mathTextData`,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 Qg(e){return e!==36||this.events[this.events.length-1][1].type===`characterEscape`}function $g(e){return{flow:{36:Kg},text:{36:Xg(e)}}}var e_={};function t_(e){let t=this,n=e||e_,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push($g(n)),a.push(Wg()),o.push(Gg(n))}function n_(e){return!e.includes(`\\(`)&&!e.includes(`\\[`)?e:e.split(/(```[\s\S]*?(?:```|$)|`[^`\n]*`)/).map((e,t)=>t%2==1?e:e.replace(/\\\[([\s\S]+?)\\\]/g,(e,t)=>`$$${t}$$`).replace(/\\\(([\s\S]+?)\\\)/g,(e,t)=>`$${t}$`)).join(``)}function r_(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith(`//`)}function i_(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 a_(e){return/\.(png|jpe?g|gif|webp|svg|avif)$/i.test(e)}function o_(e,t,n){let r=n?`&token=${encodeURIComponent(n)}`:``;return`${e}/files/raw?path=${encodeURIComponent(t)}${r}`}function s_({text:e,className:t}){let[n,r]=(0,v.useState)(!1);async function i(){try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1500)}catch{}}return(0,F.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 c_=(0,v.createContext)(`dark`),l_=()=>(0,v.useContext)(c_),u_=`modulepreload`,d_=function(e){return`/`+e},f_={},p_=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,new URL(`../../../src/node/plugins/importAnalysisBuild.ts`,import.meta.url)).href}r=o(t.map(t=>{if(t=d_(t,n),t=s(t),t in f_)return;f_[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`:u_,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)})},m_=null,h_=null;async function g_(e){let t=await(m_??=p_(()=>import(`./mermaid.core-NRhrhWN4.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])));return h_!==e&&(h_=e,t.default.initialize({startOnLoad:!1,theme:e,securityLevel:`strict`,suppressErrorRendering:!0})),t}function __({code:e}){let t=(0,v.useId)().replace(/[^a-zA-Z0-9]/g,``),n=l_()===`light`?`default`:`dark`,[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(!1),l=(0,v.useRef)(e);return l.current=e,(0,v.useEffect)(()=>{let e=!1,r=setTimeout(async()=>{try{let{svg:r}=await(await g_(n)).default.render(`mermaid-${t}`,l.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,F.jsxs)(`div`,{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,F.jsx)(`div`,{className:`absolute left-2 top-2 z-10 opacity-0 transition-opacity group-hover:opacity-100`,children:(0,F.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,F.jsx)(`div`,{className:`absolute right-2 top-2 z-10 opacity-0 transition-opacity group-hover:opacity-100`,children:(0,F.jsx)(s_,{text:e})}),s?(0,F.jsx)(`pre`,{className:`overflow-x-auto font-mono text-xs text-zinc-500 dark:text-zinc-400`,children:e}):(0,F.jsx)(`div`,{className:`flex justify-center overflow-x-auto [&_svg]:max-w-full`,dangerouslySetInnerHTML:{__html:r}})]}):(0,F.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,F.jsx)(`div`,{className:`mt-2 text-red-600 dark:text-red-400`,children:a})]})}function v_({text:e}){let[t,n]=(0,v.useState)(!1);return(0,F.jsxs)(`div`,{className:`my-1 rounded-lg border border-zinc-200 bg-zinc-50 text-sm dark:border-zinc-800/80 dark:bg-zinc-900/40`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-zinc-500`,children:[(0,F.jsx)(`span`,{className:`italic`,children:`thinking`}),(0,F.jsx)(`span`,{className:`ml-auto`,children:t?`▾`:`▸`})]}),t&&(0,F.jsx)(`div`,{className:`whitespace-pre-wrap border-t border-zinc-200 px-3 py-2 text-xs italic text-zinc-500 dark:border-zinc-800/80`,children:e})]})}function y_(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 b_(e){let{children:t,...n}=e,r=y_(t);return r===null?(0,F.jsx)(`pre`,{...n,children:t}):(0,F.jsx)(__,{code:r})}function x_({item:e,serverUrl:t=``,token:n=null,onOpenFile:r}){let i=e.blocks.filter(e=>e.type===`text`).map(e=>e.text).join(`
300
+ `)),c+=a.move(o),s(),c}function r(e,n,r){let i=e.value||``,a=1;for(t||a++;RegExp(`(^|[^$])`+`\\$`.repeat(a)+`([^$]|$)`).test(i);)a++;let o=`$`.repeat(a);/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^\$|\$$/.test(i))&&(i=` `+i+` `);let s=-1;for(;++s<r.unsafe.length;){let e=r.unsafe[s];if(!e.atBreak)continue;let t=r.compilePattern(e),n;for(;n=t.exec(i);){let e=n.index;i.codePointAt(e)===10&&i.codePointAt(e-1)===13&&e--,i=i.slice(0,e)+` `+i.slice(n.index+1)}}return o+i+o}function i(){return`$`}}var Kg={tokenize:Jg,concrete:!0,name:`mathFlow`},qg={tokenize:Yg,partial:!0};function Jg(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){return e.enter(`mathFlow`),e.enter(`mathFlowFence`),e.enter(`mathFlowFenceSequence`),c(t)}function c(t){return t===36?(e.consume(t),o++,c):o<2?n(t):(e.exit(`mathFlowFenceSequence`),Zt(e,l,`whitespace`)(t))}function l(t){return t===null||N(t)?d(t):(e.enter(`mathFlowFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===null||N(t)?(e.exit(`chunkString`),e.exit(`mathFlowFenceMeta`),d(t)):t===36?n(t):(e.consume(t),u)}function d(n){return e.exit(`mathFlowFence`),r.interrupt?t(n):e.attempt(qg,f,g)(n)}function f(t){return e.attempt({tokenize:_,partial:!0},g,p)(t)}function p(t){return(a?Zt(e,m,`linePrefix`,a+1):m)(t)}function m(t){return t===null?g(t):N(t)?e.attempt(qg,f,g)(t):(e.enter(`mathFlowValue`),h(t))}function h(t){return t===null||N(t)?(e.exit(`mathFlowValue`),m(t)):(e.consume(t),h)}function g(n){return e.exit(`mathFlow`),t(n)}function _(e,t,n){let i=0;return Zt(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4);function a(t){return e.enter(`mathFlowFence`),e.enter(`mathFlowFenceSequence`),s(t)}function s(t){return t===36?(i++,e.consume(t),s):i<o?n(t):(e.exit(`mathFlowFenceSequence`),Zt(e,c,`whitespace`)(t))}function c(r){return r===null||N(r)?(e.exit(`mathFlowFence`),t(r)):n(r)}}}function Yg(e,t,n){let r=this;return i;function i(n){return n===null?t(n):(e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function Xg(e){let t=(e||{}).singleDollarTextMath;return t??=!0,{tokenize:n,resolve:Zg,previous:Qg,name:`mathText`};function n(e,n,r){let i=0,a,o;return s;function s(t){return e.enter(`mathText`),e.enter(`mathTextSequence`),c(t)}function c(n){return n===36?(e.consume(n),i++,c):i<2&&!t?r(n):(e.exit(`mathTextSequence`),l(n))}function l(t){return t===null?r(t):t===36?(o=e.enter(`mathTextSequence`),a=0,d(t)):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),l):N(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),l):(e.enter(`mathTextData`),u(t))}function u(t){return t===null||t===32||t===36||N(t)?(e.exit(`mathTextData`),l(t)):(e.consume(t),u)}function d(t){return t===36?(e.consume(t),a++,d):a===i?(e.exit(`mathTextSequence`),e.exit(`mathText`),n(t)):(o.type=`mathTextData`,u(t))}}}function Zg(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===`mathTextData`){e[t][1].type=`mathTextPadding`,e[n][1].type=`mathTextPadding`,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=`mathTextData`,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 Qg(e){return e!==36||this.events[this.events.length-1][1].type===`characterEscape`}function $g(e){return{flow:{36:Kg},text:{36:Xg(e)}}}var e_={};function t_(e){let t=this,n=e||e_,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push($g(n)),a.push(Wg()),o.push(Gg(n))}function n_(e){return!e.includes(`\\(`)&&!e.includes(`\\[`)?e:e.split(/(```[\s\S]*?(?:```|$)|`[^`\n]*`)/).map((e,t)=>t%2==1?e:e.replace(/\\\[([\s\S]+?)\\\]/g,(e,t)=>`$$${t}$$`).replace(/\\\(([\s\S]+?)\\\)/g,(e,t)=>`$${t}$`)).join(``)}function r_(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith(`//`)}function i_(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 a_(e){return/\.(png|jpe?g|gif|webp|svg|avif)$/i.test(e)}function o_(e,t,n){let r=n?`&token=${encodeURIComponent(n)}`:``;return`${e}/files/raw?path=${encodeURIComponent(t)}${r}`}function s_({text:e,className:t}){let[n,r]=(0,v.useState)(!1);async function i(){try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1500)}catch{}}return(0,F.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 c_=(0,v.createContext)(`dark`),l_=()=>(0,v.useContext)(c_),u_=`modulepreload`,d_=function(e){return`/`+e},f_={},p_=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,new URL(`../../../src/node/plugins/importAnalysisBuild.ts`,import.meta.url)).href}r=o(t.map(t=>{if(t=d_(t,n),t=s(t),t in f_)return;f_[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`:u_,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)})},m_=null,h_=null;async function g_(e){let t=await(m_??=p_(()=>import(`./mermaid.core-BMxZKY0U.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])));return h_!==e&&(h_=e,t.default.initialize({startOnLoad:!1,theme:e,securityLevel:`strict`,suppressErrorRendering:!0})),t}function __({code:e}){let t=(0,v.useId)().replace(/[^a-zA-Z0-9]/g,``),n=l_()===`light`?`default`:`dark`,[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(!1),l=(0,v.useRef)(e);return l.current=e,(0,v.useEffect)(()=>{let e=!1,r=setTimeout(async()=>{try{let{svg:r}=await(await g_(n)).default.render(`mermaid-${t}`,l.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,F.jsxs)(`div`,{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,F.jsx)(`div`,{className:`absolute left-2 top-2 z-10 opacity-0 transition-opacity group-hover:opacity-100`,children:(0,F.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,F.jsx)(`div`,{className:`absolute right-2 top-2 z-10 opacity-0 transition-opacity group-hover:opacity-100`,children:(0,F.jsx)(s_,{text:e})}),s?(0,F.jsx)(`pre`,{className:`overflow-x-auto font-mono text-xs text-zinc-500 dark:text-zinc-400`,children:e}):(0,F.jsx)(`div`,{className:`flex justify-center overflow-x-auto [&_svg]:max-w-full`,dangerouslySetInnerHTML:{__html:r}})]}):(0,F.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,F.jsx)(`div`,{className:`mt-2 text-red-600 dark:text-red-400`,children:a})]})}function v_({text:e}){let[t,n]=(0,v.useState)(!1);return(0,F.jsxs)(`div`,{className:`my-1 rounded-lg border border-zinc-200 bg-zinc-50 text-sm dark:border-zinc-800/80 dark:bg-zinc-900/40`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-zinc-500`,children:[(0,F.jsx)(`span`,{className:`italic`,children:`thinking`}),(0,F.jsx)(`span`,{className:`ml-auto`,children:t?`▾`:`▸`})]}),t&&(0,F.jsx)(`div`,{className:`whitespace-pre-wrap border-t border-zinc-200 px-3 py-2 text-xs italic text-zinc-500 dark:border-zinc-800/80`,children:e})]})}function y_(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 b_(e){let{children:t,...n}=e,r=y_(t);return r===null?(0,F.jsx)(`pre`,{...n,children:t}):(0,F.jsx)(__,{code:r})}function x_({item:e,serverUrl:t=``,token:n=null,onOpenFile:r}){let i=e.blocks.filter(e=>e.type===`text`).map(e=>e.text).join(`
301
301
 
302
302
  `).trim(),a=(0,v.useRef)(r);a.current=r;let o=(0,v.useMemo)(()=>{function e({src:e,alt:r,...i}){let a=typeof e==`string`&&e!==``&&!r_(e)?o_(t,i_(``,e),n):e;return(0,F.jsx)(`img`,{...i,src:a,alt:r??``,loading:`lazy`,className:`max-h-96 max-w-full rounded-lg object-contain`})}function r({href:e,children:t,...n}){if(typeof e==`string`&&e!==``&&!r_(e)&&a.current){let r=i_(``,e);return(0,F.jsx)(`a`,{...n,href:e,onClick:e=>{e.preventDefault(),a.current?.(r)},children:t})}return(0,F.jsx)(`a`,{...n,href:e,target:`_blank`,rel:`noreferrer`,children:t})}return{pre:b_,img:e,a:r}},[t,n]);return(0,F.jsxs)(`div`,{className:`group max-w-none`,children:[i&&!e.streaming&&(0,F.jsx)(`div`,{className:`flex justify-end opacity-0 transition-opacity group-hover:opacity-100`,children:(0,F.jsx)(s_,{text:i})}),e.blocks.map((e,t)=>e.type===`thinking`?(0,F.jsx)(v_,{text:e.text},e.contentIndex??t):(0,F.jsx)(`div`,{className:`prose-chat`,children:(0,F.jsx)(Oo,{remarkPlugins:[Ug,t_],rehypePlugins:[Up],components:o,children:n_(e.text)})},e.contentIndex??t)),e.errorMessage&&(0,F.jsx)(`div`,{className:`mt-2 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.errorMessage})]})}function S_(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 C_(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}async function w_(e){let t=[],n=[];for(let r of e)if(r.type.startsWith(`image/`)){if(r.size>7340032){n.push(`${r.name}: image too large (max 7 MB)`);continue}t.push({name:r.name,kind:`image`,data:await S_(r),mimeType:r.type,source:`manual`})}else if(r.size<=524288){let e=await r.text();e.includes(`\0`)?n.push(`${r.name}: unsupported binary file`):t.push({name:r.name,kind:`text`,data:e,mimeType:r.type||`text/plain`,source:`manual`})}else n.push(`${r.name}: file too large (max 512 KB for text)`);return{attachments:t,errors:n}}function T_(e){return{...A_(e),source:`preview`,previewPath:e}}function E_(e,t){let n=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return RegExp(`(^|\\s)@${n}[,.;:!?)\\]]*(\\s|$)`).test(e)}function D_(e){return[...e.matchAll(/(?:^|\s)@([^\s@]+)/g)].map(([,e])=>e.replace(/[,.;:!?)\]]+$/,``)).filter(e=>e.length>0)}function O_(e,t){let n=e.trim(),r=e=>{n+=`${n?`
303
303
 
@@ -306,7 +306,7 @@ l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
306
306
  `).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,F.jsx)(`button`,{type:`button`,onClick:u,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,F.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,className:`h-4 w-4`,children:(0,F.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>w.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,F.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,F.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,F.jsx)(`input`,{ref:w,type:`file`,multiple:!0,hidden:!0,onChange:e=>{e.target.files?.length&&o(Array.from(e.target.files)),e.target.value=``}}),(0,F.jsx)(`button`,{type:`button`,onClick:ie,disabled:!t||!p.trim()&&a.length===0,title: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,F.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:[(0,F.jsx)(`circle`,{cx:`6`,cy:`19`,r:`3`}),(0,F.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,F.jsx)(`circle`,{cx:`18`,cy:`5`,r:`3`})]}):(0,F.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,F.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`})})})]})]})}function R_({item:e}){let[t,n]=(0,v.useState)(!1),r=e.details!==void 0;return(0,F.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,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsxs)(`span`,{className:`font-mono text-xs font-bold text-violet-700 dark:text-violet-300`,children:[`[`,e.customType,`]`]}),r&&(0,F.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?`▾`:`▸`})]}),(0,F.jsx)(`div`,{className:`prose-chat mt-1 text-violet-950 dark:text-violet-100`,children:(0,F.jsx)(Oo,{remarkPlugins:[Ug,t_],rehypePlugins:[Up],children:n_(e.text)})}),t&&r&&(0,F.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 z_=`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`,B_=`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`,V_=`mb-4 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`;function H_({request:e,onRespond:t}){let[n,r]=(0,v.useState)(e.method===`editor`?e.prefill??``:``),i=(e.method===`select`||e.method===`confirm`||e.method===`input`)&&e.timeout,[a,o]=(0,v.useState)(i?Math.ceil(i/1e3):null);function s(){t({id:e.id,cancelled:!0})}return(0,v.useEffect)(()=>{if(a===null)return;if(a<=0){t({id:e.id,cancelled:!0});return}let n=setTimeout(()=>o(e=>e===null?null:e-1),1e3);return()=>clearTimeout(n)},[a,e.id,t]),(0,F.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,onClick:s,children:(0,F.jsxs)(`div`,{className:`w-full 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,F.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:e.title}),e.method===`select`&&(0,F.jsx)(`div`,{className:`mb-1 flex flex-col gap-1`,children:e.options.map(n=>(0,F.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:`text-left ${z_}`,children:n},n))}),e.method===`confirm`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`p`,{className:`mb-4 text-sm text-zinc-600 dark:text-zinc-400`,children:e.message}),(0,F.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!1}),className:z_,children:`No`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!0}),className:B_,children:`Yes`})]})]}),e.method===`input`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.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`&&s()},className:V_}),(0,F.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:s,className:z_,children:`Cancel`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:B_,children:`OK`})]})]}),e.method===`editor`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`textarea`,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),rows:8,onKeyDown:e=>{e.key===`Escape`&&s()},className:`resize-none font-mono ${V_}`}),(0,F.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:s,className:z_,children:`Cancel`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:B_,children:`OK`})]})]}),a!==null&&(0,F.jsxs)(`p`,{className:`mt-3 text-right text-xs text-zinc-400 dark:text-zinc-600`,children:[`auto-dismiss in `,a,`s`]})]})})}var U_={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 W_({notification:e,onDismiss:t}){return(0,v.useEffect)(()=>{let e=setTimeout(t,6e3);return()=>clearTimeout(e)},[t]),(0,F.jsx)(`div`,{className:`rounded-lg border px-3 py-2 text-sm shadow-lg ${U_[e.notifyType??`info`]}`,children:e.message})}function G_({notifications:e,onDismiss:t}){return e.length===0?null:(0,F.jsx)(`div`,{className:`fixed right-4 top-16 z-40 flex w-80 flex-col gap-2`,children:e.map(e=>(0,F.jsx)(W_,{notification:e,onDismiss:()=>t(e.id)},e.id))})}function K_({widgets:e,placement:t}){let n=Object.entries(e).filter(([,e])=>e.placement===t);return n.length===0?null:(0,F.jsx)(`div`,{className:`mb-2 flex flex-col gap-1`,children:n.map(([e,t])=>(0,F.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.join(`
307
307
  `)},e))})}function q_(e,t){let n=e.split(`
308
308
  `),r=t.split(`
309
- `),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;let a=n.length,o=r.length;for(;a>i&&o>i&&n[a-1]===r[o-1];)a--,o--;let s=n.slice(i,a),c=r.slice(i,o),l=n.slice(0,i).map(e=>({type:`same`,text:e}));if(s.length*c.length>300*300)l.push(...s.map(e=>({type:`del`,text:e}))),l.push(...c.map(e=>({type:`add`,text:e})));else{let e=s.length,t=c.length,n=Array.from({length:e+1},()=>Array(t+1).fill(0));for(let r=e-1;r>=0;r--)for(let e=t-1;e>=0;e--)n[r][e]=s[r]===c[e]?n[r+1][e+1]+1:Math.max(n[r+1][e],n[r][e+1]);let r=0,i=0;for(;r<e&&i<t;)s[r]===c[i]?(l.push({type:`same`,text:s[r]}),r++,i++):n[r+1][i]>=n[r][i+1]?(l.push({type:`del`,text:s[r]}),r++):(l.push({type:`add`,text:c[i]}),i++);for(;r<e;)l.push({type:`del`,text:s[r++]});for(;i<t;)l.push({type:`add`,text:c[i++]})}return l.push(...n.slice(a).map(e=>({type:`same`,text:e}))),l}function J_(e){let t=[],n=0;for(;n<e.length;){if(e[n].type===`same`){t.push({left:e[n].text,right:e[n].text,changed:!1}),n++;continue}let r=[],i=[];for(;n<e.length&&e[n].type===`del`;)r.push(e[n++].text);for(;n<e.length&&e[n].type===`add`;)i.push(e[n++].text);for(let e=0;e<Math.max(r.length,i.length);e++)t.push({left:e<r.length?r[e]:null,right:e<i.length?i[e]:null,changed:!0})}return t}function Y_(e,t=2){let n=Array(e.length).fill(!1);e.forEach((r,i)=>{if(r.changed)for(let r=Math.max(0,i-t);r<=Math.min(e.length-1,i+t);r++)n[r]=!0});let r=[],i=!1;return e.forEach((e,t)=>{n[t]?(r.push(e),i=!1):i||=(r.push(null),!0)}),r}function X_(e,t=2){let n=Array(e.length).fill(!1);e.forEach((r,i)=>{if(r.type!==`same`)for(let r=Math.max(0,i-t);r<=Math.min(e.length-1,i+t);r++)n[r]=!0});let r=[],i=!1;return e.forEach((e,t)=>{n[t]?(r.push(e),i=!1):i||=(r.push(null),!0)}),r}var Z_=null,Q_={javascript:()=>p_(()=>import(`./javascript-w9aIBC1S.js`),[]),typescript:()=>p_(()=>import(`./typescript-CTV1Js34.js`),[]),json:()=>p_(()=>import(`./json-DS4EA3dC.js`),[]),xml:()=>p_(()=>import(`./xml-DasnpDVC.js`),[]),css:()=>p_(()=>import(`./css-D5l_8KUR.js`),[]),scss:()=>p_(()=>import(`./scss-BNjRHcgO.js`),[]),bash:()=>p_(()=>import(`./bash-LmRjUKlR.js`),[]),python:()=>p_(()=>import(`./python-DwhXSSGr.js`),[]),go:()=>p_(()=>import(`./go-B-PCS5zA.js`),[]),rust:()=>p_(()=>import(`./rust-Dk33Kfe-.js`),[]),java:()=>p_(()=>import(`./java-ChVphriW.js`),[]),c:()=>p_(()=>import(`./c-CVYb4e6m.js`),[]),cpp:()=>p_(()=>import(`./cpp-V0F2hNk9.js`),[]),csharp:()=>p_(()=>import(`./csharp-GZmu99Fo.js`),[]),ruby:()=>p_(()=>import(`./ruby-D6zc0cUO.js`),[]),php:()=>p_(()=>import(`./php-5k5YNuRS.js`),[]),sql:()=>p_(()=>import(`./sql-DWRKyvJ-.js`),[]),yaml:()=>p_(()=>import(`./yaml-1XF8XcZB.js`),[]),ini:()=>p_(()=>import(`./ini-B1CroMsf.js`),[]),dockerfile:()=>p_(()=>import(`./dockerfile-C0zufGsU.js`),[]),markdown:()=>p_(()=>import(`./markdown-C8bVcNXx.js`),[]),plaintext:()=>p_(()=>import(`./plaintext-YB8mb-y7.js`),[])};async function $_(){return Z_||=(async()=>{let{default:e}=await p_(async()=>{let{default:e}=await import(`./core-BHBAuxkq.js`);return{default:e}},[]);return await Promise.all(Object.entries(Q_).map(async([t,n])=>{let r=await n();e.registerLanguage(t,r.default)})),e})(),Z_}var ev={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 tv(e){let t=e.split(`/`).pop()??e;if(/^dockerfile$/i.test(t))return`dockerfile`;let n=t.lastIndexOf(`.`);if(!(n<0))return ev[t.slice(n+1).toLowerCase()]}function nv({code:e,path:t}){let[n,r]=(0,v.useState)(null),i=(0,v.useRef)(e);return i.current=e,(0,v.useEffect)(()=>{let e=!1;return r(null),$_().then(n=>{if(e)return;let a=tv(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,F.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,children:e}):(0,F.jsx)(`pre`,{className:`hljs whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,dangerouslySetInnerHTML:{__html:n}})}function rv({lines:e,fill:t=!1}){return(0,F.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:Y_(J_(e)).map((e,t)=>e===null?(0,F.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,F.jsxs)(`div`,{className:`grid grid-cols-2`,children:[(0,F.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,F.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 iv({lines:e}){return(0,F.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded border border-zinc-200 font-mono text-xs leading-relaxed dark:border-zinc-800`,children:X_(e).map((e,t)=>e===null?(0,F.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,F.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 av(e){return/\.(md|markdown)$/i.test(e)}function ov(e,t){return t===void 0?!0:t===null?!1:t===``||e===t||e.startsWith(`${t}/`)}function sv({file:e,writableRoot:t,isStreaming:n,onDirtyChange:r,gitState:i,initialShowGitDiff:a=!1,gitDiff:o,onFetchGitDiff:s,onClearGitDiff:c,onClose:l,onReload:u,onSave:d,serverUrl:f=``,token:p=null,onImageLoad:m}){let[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(a),[b,x]=(0,v.useState)(null),[S,C]=(0,v.useState)(`idle`),w=(0,v.useRef)(null),T=(0,v.useRef)(null),E=e.status===`loaded`?e:null,ee=E!==null&&av(e.path),D=a_(e.path),O=ov(e.path,t),te=b!==null&&b.draft!==b.baseContent,ne=E?.pendingSave!==void 0,re=b!==null&&E!==null&&E.mtimeMs!==b.baseMtimeMs,ie=E?.saveError?.conflict===!0||re;function ae(){te&&!window.confirm(`Discard unsaved changes?`)||l()}function k(){E&&x({draft:E.content,baseContent:E.content,baseMtimeMs:E.mtimeMs})}function A(t=!1){!E||b===null||ne||(T.current=b.draft,d(e.path,b.draft,b.baseMtimeMs,t))}function j(){x(null),u(e.path)}function M(){let t=!_;y(t),t?s(e.path):c()}return(0,v.useEffect)(()=>{if(b!==null&&E!==null&&T.current!==null&&E.content===T.current&&E.mtimeMs!==b.baseMtimeMs){let e=T.current;T.current=null,b.draft===e?x(null):x({...b,baseContent:E.content,baseMtimeMs:E.mtimeMs})}},[E?.mtimeMs]),(0,v.useEffect)(()=>{function e(e){e.key===`Escape`&&ae()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),(0,v.useEffect)(()=>{C(n?`streaming`:e=>e===`streaming`?`done`:e)},[n]),(0,v.useEffect)(()=>(r(te),()=>r(!1)),[te]),(0,v.useEffect)(()=>(a&&s(e.path),()=>c()),[]),(0,F.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[ee&&b===null&&!_&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>g(!h),title:h?`Show rendered`:`Show source`,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:h?`⚏ rendered`:`⌗ source`}),i!==void 0&&b===null&&(0,F.jsx)(`button`,{type:`button`,onClick:M,"aria-pressed":_,title:_?`Show file content`:`Show uncommitted changes (vs HEAD)`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs ${_?`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`}),(0,F.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,te&&(0,F.jsx)(`span`,{className:`ml-1 text-amber-500`,children:`●`})]}),E&&b===null&&(0,F.jsx)(s_,{text:E.content}),E&&b===null&&!_&&O&&(0,F.jsx)(`button`,{type:`button`,onClick:k,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`}),E&&b===null&&!O&&(0,F.jsx)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,title:`Outside the writable zone`,children:`🔒 read-only`}),b!==null&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>A(),disabled:!te||ne||ie,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:ne?`saving…`:`save`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>te?window.confirm(`Discard unsaved changes?`)&&x(null):x(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,F.jsx)(`button`,{type:`button`,onClick:ae,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:`✕`})]}),ie&&b!==null&&(0,F.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,F.jsx)(`span`,{className:`min-w-0 flex-1`,children:`File changed on disk since you started editing.`}),(0,F.jsx)(`button`,{type:`button`,onClick:j,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,F.jsx)(`button`,{type:`button`,onClick:()=>A(!0),disabled:ne,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`})]}),b!==null&&E?.saveError&&!E.saveError.conflict&&(0,F.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:E.saveError.message}),(0,F.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[_&&b===null&&(0,F.jsxs)(`div`,{className:`p-4`,children:[o?.path===e.path&&`error`in o&&(0,F.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,F.jsx)(rv,{fill:!0,lines:q_(o.before,o.after)}),o?.path!==e.path&&(0,F.jsx)(`div`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`loading diff…`})]}),D&&b===null&&!_&&(0,F.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,F.jsx)(`img`,{src:o_(f,e.path,p),alt:e.path,onLoad:()=>m(e.path),className:`max-h-full max-w-full rounded object-contain`})}),e.status===`loading`&&b===null&&!_&&!D&&(0,F.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),e.status===`error`&&!D&&(0,F.jsx)(`div`,{className:`p-4 text-sm text-red-600 dark:text-red-400`,children:e.message}),b!==null&&(0,F.jsx)(`textarea`,{ref:w,value:b.draft,onChange:e=>x({...b,draft:e.target.value}),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),te&&!ne&&!ie&&A())},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`}),E&&b===null&&!_&&ee&&!h&&(0,F.jsx)(`div`,{className:`prose-chat mx-auto max-w-3xl p-4 text-zinc-700 dark:text-zinc-300`,children:(0,F.jsx)(Oo,{remarkPlugins:[Ug,t_],rehypePlugins:[Up],components:{a:({href:t,children:n,...r})=>!t||/^[a-z][a-z0-9+.-]*:/i.test(t)?(0,F.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,...r,children:n}):t.startsWith(`#`)?(0,F.jsx)(`a`,{href:t,...r,children:n}):(0,F.jsx)(`a`,{href:t,onClick:n=>{n.preventDefault(),u(i_(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(`//`)?o_(f,i_(e.path,t),p):t;return(0,F.jsx)(`img`,{...r,src:i,alt:n??``,loading:`lazy`,className:`max-w-full rounded-lg`})}},children:n_(E.content)})}),E&&b===null&&!_&&(!ee||h)&&(0,F.jsx)(`div`,{className:`p-4`,children:(0,F.jsx)(nv,{code:E.content,path:e.path})})]}),S!==`idle`&&(0,F.jsxs)(`button`,{type:`button`,onClick:ae,"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:[S===`streaming`?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 animate-pulse motion-reduce:animate-none rounded-full bg-amber-500`}),(0,F.jsx)(`span`,{className:`text-amber-700 dark:text-amber-400`,children:`π is replying…`})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 rounded-full bg-emerald-500`}),(0,F.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:`π replied`})]}),(0,F.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-500`,children:`show conversation →`})]})]})}function cv(e){return e.split(`
310
- `).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 lv({show:e,onClose:t}){return(0,v.useEffect)(()=>{function e(e){e.key===`Escape`&&(e.stopImmediatePropagation(),t())}return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t]),(0,F.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,F.jsx)(`span`,{className:`font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,12)}),(0,F.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`commit diff`}),(0,F.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,F.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,F.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto p-3 font-mono text-xs leading-relaxed`,children:cv(e.patch).map((e,t)=>(0,F.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 uv=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function dv(e){let t=(0,v.useRef)(null);return(0,v.useEffect)(()=>{function n(n){t.current&&!t.current.contains(n.target)&&e()}return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),t}function fv(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 pv({status:e,log:t,onFetchLog:n,onShowCommit:r}){let[i,a]=(0,v.useState)(!1),o=dv(()=>a(!1)),s=e&&(e.ahead>0||e.behind>0)?` ${e.ahead>0?`↑${e.ahead}`:``}${e.behind>0?`↓${e.behind}`:``}`:``;return(0,F.jsxs)(`div`,{className:`relative`,ref:o,children:[(0,F.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,F.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,F.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),t?.length===0&&(0,F.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no commits`}),t?.map(e=>(0,F.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,F.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,7)}),(0,F.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-zinc-700 dark:text-zinc-300`,children:e.subject}),(0,F.jsxs)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:[e.author,` · `,fv(e.date)]})]},e.sha))]})]})}function mv(e){let t=(0,v.useRef)(null);return(0,v.useEffect)(()=>{function n(n){t.current&&!t.current.contains(n.target)&&e()}return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),t}var hv=`#10b981`,gv=[`#8b5cf6`,`#f59e0b`,`#0ea5e9`,`#f43f5e`,`#14b8a6`,`#d946ef`],_v=14,vv=36;function yv(e){return e===0?hv:gv[(e-1)%gv.length]}function bv(e){let t=[],n=new Set,r=0,i=0;function a(e,o,s,c){let l=[...e.children].sort((e,t)=>Number(t.onPath)-Number(e.onPath)),u=l.slice(1).map(e=>[e,r++]);if(u.length>0&&i++,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:e.onPath&&!l.some(e=>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))}e.length>1&&i++;let o=[...e].sort((e,t)=>Number(t.onPath)-Number(e.onPath));return o.forEach((e,t)=>{let i=r++;n.add(i),a(e,i,!1,o.length>1?t+1:void 0)}),{rows:t,laneCount:r,branchPoints:i}}function xv(e){return e.flatMap(e=>[e,...xv(e.children)])}function Sv({row:e,laneCount:t}){let n=t*_v+2,r=e=>e*_v+_v/2+1,i=r(e.lane),a=vv/2;return(0,F.jsxs)(`svg`,{width:n,height:vv,viewBox:`0 0 ${n} ${vv}`,"aria-hidden":!0,className:`shrink-0`,children:[e.through.map(e=>(0,F.jsx)(`line`,{x1:r(e),y1:0,x2:r(e),y2:vv,stroke:yv(e),strokeWidth:2,opacity:.55},e)),e.lineAbove&&(0,F.jsx)(`line`,{x1:i,y1:0,x2:i,y2:a,stroke:yv(e.lane),strokeWidth:2}),e.lineBelow&&(0,F.jsx)(`line`,{x1:i,y1:a,x2:i,y2:vv,stroke:yv(e.lane),strokeWidth:2}),e.forkTo.map(e=>(0,F.jsx)(`path`,{d:`M ${i} ${a} C ${i} ${vv}, ${r(e)} ${a}, ${r(e)} ${vv}`,fill:`none`,stroke:yv(e),strokeWidth:2,opacity:.75},e)),e.isCurrent?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`circle`,{cx:i,cy:a,r:6,fill:`none`,stroke:yv(e.lane),strokeWidth:2}),(0,F.jsx)(`circle`,{cx:i,cy:a,r:2.5,fill:yv(e.lane)})]}):(0,F.jsx)(`circle`,{cx:i,cy:a,r:4,fill:e.node.onPath?yv(e.lane):`var(--tree-off, #d4d4d8)`,stroke:yv(e.lane),strokeWidth:e.node.onPath?0:1.5})]})}function Cv({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,F.jsx)(`span`,{className:`shrink-0 rounded-full border px-1.5 py-px text-[10px] leading-4 ${n}`,children:e})}var wv=`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 Tv({row:e,laneCount:t,isStreaming:n,onNavigate:r,onFork:i,onClose:a}){let{node:o}=e,s=o.tipId??o.entryId;return(0,F.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:vv},children:[(0,F.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,F.jsx)(Sv,{row:e,laneCount:t}),(0,F.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,F.jsxs)(Cv,{tone:`branch`,children:[e.forkTo.length+1,` branches`]}),e.branchIndex!==void 0&&(0,F.jsxs)(Cv,{tone:`branch`,children:[`branch `,e.branchIndex,o.onPath&&!e.isCurrent?` · current`:``]}),e.isCurrent&&(0,F.jsx)(Cv,{tone:`current`,children:`current`}),o.label&&(0,F.jsx)(Cv,{tone:`label`,children:o.label})]}),(0,F.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:wv,children:`↺ redo`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>{i(o.entryId),a()},title:`fork a new session from this point`,className:wv,children:`⑂ fork`})]})}function Ev({tree:e,isStreaming:t,onListTree:n,onNavigate:r,onFork:i}){let[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``),l=mv(()=>o(!1));(0,v.useEffect)(()=>{a&&e===null&&n()},[a,e]);let u=(0,v.useMemo)(()=>e&&e.length>0?bv(e):null,[e]),d=(0,v.useMemo)(()=>{if(!e||!s.trim())return null;let t=s.trim().toLowerCase();return xv(e).filter(e=>e.text.toLowerCase().includes(t)||e.label?.toLowerCase().includes(t))},[e,s]);return(0,F.jsxs)(`div`,{className:`relative`,ref:l,children:[(0,F.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,F.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,F.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),e?.length===0&&(0,F.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no messages yet`}),e&&e.length>0&&u&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,F.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,F.jsx)(`span`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Conversation tree`}),(0,F.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,F.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,F.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,F.jsx)(`div`,{className:`min-h-0 overflow-y-auto py-1`,children:d===null?u.rows.map(e=>(0,F.jsx)(Tv,{row:e,laneCount:u.laneCount,isStreaming:t,onNavigate:r,onFork:i,onClose:()=>o(!1)},e.node.entryId)):d.length===0?(0,F.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no matches`}):d.map(e=>(0,F.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70`,children:[(0,F.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,F.jsx)(`span`,{"aria-hidden":!0,className:e.onPath?`text-emerald-500`:`text-zinc-300 dark:text-zinc-600`,children:`●`}),(0,F.jsx)(`span`,{className:`min-w-0 truncate text-zinc-700 dark:text-zinc-300`,children:e.text||`(empty)`}),e.onPath&&(0,F.jsx)(Cv,{tone:`current`,children:`on current branch`}),e.label&&(0,F.jsx)(Cv,{tone:`label`,children:e.label})]}),(0,F.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:wv,children:`↺ redo`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>{i(e.entryId),o(!1)},title:`fork a new session from this point`,className:wv,children:`⑂ fork`})]},e.entryId))})]})]})]})}function Dv(e){let t=(0,v.useRef)(null);return(0,v.useEffect)(()=>{function n(n){t.current&&!t.current.contains(n.target)&&e()}return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),t}var Ov=200;function kv({initial:e,onCommit:t,onCancel:n}){let[r,i]=(0,v.useState)(e);return(0,F.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 Av({session:e,isCurrent:t,renaming:n,onSwitch:r,onDelete:i,onStartRename:a,onRename:o,onCancelRename:s}){return n?(0,F.jsx)(`div`,{className:`px-3 py-2`,children:(0,F.jsx)(kv,{initial:e.name??``,onCommit:o,onCancel:s})}):(0,F.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,F.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 flex-1 px-3 py-2 text-left text-sm`,children:[(0,F.jsx)(`div`,{className:`truncate text-zinc-700 dark:text-zinc-300`,children:e.name||e.firstMessage||`(empty)`}),e.snippet&&(0,F.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-zinc-500 dark:text-zinc-500`,children:e.snippet}),(0,F.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,F.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,F.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 jv({sessions:e,sessionSearch:t,sessionId:n,onSwitchSession:r,onDeleteSession:i,onListSessions:a,onRenameSession:o,onSearchSessions:s,onClearSessionSearch:c}){let[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(null),h=Dv(()=>u(!1)),g=d.trim(),_=g.length>=2;(0,v.useEffect)(()=>{if(!l)return;if(!_){c();return}let e=setTimeout(()=>s(g),Ov);return()=>clearTimeout(e)},[l,g,_]);function y(){u(!1),m(null)}let b=_&&!(t?.status===`loaded`&&t.query===g),x=_?b?null:t?.results??null:e;return(0,F.jsxs)(`div`,{className:`relative`,ref:h,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>{if(l){y();return}u(!0),f(``),m(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,F.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,F.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,F.jsx)(`input`,{type:`search`,value:d,onChange:e=>f(e.target.value),placeholder:`Search sessions`,"aria-label":`Search sessions`,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,F.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,F.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[x===null&&(0,F.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),x?.length===0&&(0,F.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:_?`no matches`:`no saved sessions`}),x?.map(e=>(0,F.jsx)(Av,{session:e,isCurrent:e.id===n,renaming:p===e.path,onSwitch:()=>{r(e.path),y()},onDelete:()=>{window.confirm(`Delete this session?`)&&i(e.path)},onStartRename:()=>m(e.path),onRename:t=>{o(e.path,t),m(null),_&&s(d.trim())},onCancelRename:()=>m(null)},e.path))]})]})]})}function Mv({theme:e,onToggle:t}){return(0,F.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 Nv(e){let{isStreaming:t,connected:n}=e;return(0,F.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,F.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,F.jsx)(pv,{status:e.gitStatus,log:e.gitLog,onFetchLog:e.onFetchGitLog,onShowCommit:e.onShowCommit}),(0,F.jsx)(`span`,{className:`text-lg font-semibold tracking-tight`,style:{color:`var(--accent, inherit)`},children:e.title??`π`}),t&&(0,F.jsxs)(`span`,{"aria-live":`polite`,className:`flex items-center gap-1.5 text-xs text-amber-600 dark:text-amber-400`,children:[(0,F.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse motion-reduce:animate-none rounded-full bg-amber-500 dark:bg-amber-400`}),`working`]}),Object.entries(e.statuses).map(([e,t])=>(0,F.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:t},e)),(0,F.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,F.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,F.jsx)(Mv,{theme:e.theme,onToggle:e.onToggleTheme}),(0,F.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,F.jsx)(Ev,{tree:e.tree,isStreaming:t,onListTree:e.onListTree,onNavigate:e.onNavigateTree,onFork:e.onForkSession}),(0,F.jsx)(jv,{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,F.jsx)(`span`,{className:`h-2 w-2 rounded-full ${n?`bg-emerald-500`:`bg-red-500`}`,title:n?`connected`:`disconnected`})]})]})}function Pv(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 Fv({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,F.jsxs)(`svg`,{width:18,height:18,viewBox:`0 0 36 36`,className:`-rotate-90 shrink-0`,children:[(0,F.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,F.jsx)(`circle`,{cx:`18`,cy:`18`,r:t,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,strokeLinecap:`round`,strokeDasharray:`${i} ${n-i}`,className:Pv(e)})]})}function Iv({thinkingLevel:e,isStreaming:t,onSetThinking:n}){let[r,i]=(0,v.useState)(!1),a=(0,v.useRef)(null),o=e!==`off`,s=Math.max(0,uv.indexOf(e));return(0,v.useEffect)(()=>{if(!r)return;function e(e){a.current&&!a.current.contains(e.target)&&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,F.jsxs)(`div`,{className:`relative`,ref:a,children:[(0,F.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,F.jsx)(`span`,{"aria-hidden":!0,className:`text-sm leading-none ${o?``:`opacity-40 grayscale`}`,children:`🧠`}),e]}),r&&(0,F.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,F.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between text-xs`,children:[(0,F.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`thinking`}),(0,F.jsx)(`span`,{className:`font-mono text-zinc-700 dark:text-zinc-200`,children:e})]}),(0,F.jsx)(`input`,{type:`range`,min:0,max:uv.length-1,step:1,value:s,onChange:e=>n(uv[Number(e.target.value)]),"aria-label":`Thinking level`,"aria-valuetext":e,className:`w-full accent-amber-500`}),(0,F.jsxs)(`div`,{className:`mt-0.5 flex justify-between font-mono text-[9px] text-zinc-400 dark:text-zinc-600`,children:[(0,F.jsx)(`span`,{children:uv[0]}),(0,F.jsx)(`span`,{children:uv[uv.length-1]})]})]})]})}function Lv(e){let{model:t,models:n,thinkingLevel:r,modelSupportsReasoning:i,isStreaming:a,contextUsage:o,isCompacting:s}=e;return(0,F.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,F.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,F.jsx)(`option`,{value:t,children:t}),n.map(e=>(0,F.jsxs)(`option`,{value:`${e.provider}/${e.id}`,children:[e.provider,`/`,e.id]},`${e.provider}/${e.id}`))]}),i&&(0,F.jsx)(Iv,{thinkingLevel:r,isStreaming:a,onSetThinking:e.onSetThinking}),(0,F.jsxs)(`button`,{type:`button`,onClick:e.onCompact,disabled:a||s,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,F.jsx)(Fv,{usage:o}),s?`compacting…`:o?.percent==null?`context`:`${Math.round(o.percent)}%`]})]})}var Rv={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 zv(e,t){return t?Object.keys(t).filter(t=>t.startsWith(`${e}/`)).length:0}function Bv(e){return e===`directory`||e===`symlink-directory`}function Vv(e,t){return t===void 0?!1:t===null?!0:t===``?!1:e!==t&&!e.startsWith(`${t}/`)}function Hv({path:e,depth:t,...n}){let r=n.tree[e];return r===void 0?null:r===`loading`?(0,F.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,F.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,F.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:`empty`}):(0,F.jsx)(F.Fragment,{children:r.map(r=>(0,F.jsx)(Uv,{parentPath:e,entry:r,depth:t,...n},r.name))})}function Uv({parentPath:e,entry:t,depth:n,...r}){let[i,a]=(0,v.useState)(!1),o=e?`${e}/${t.name}`:t.name,s=Vv(o,r.writableRoot);if(Bv(t.type))return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>{let e=!i;a(e),e&&r.tree[o]===void 0&&r.onExpand(o)},style:{paddingLeft:n*12},className:`flex w-full items-center gap-1 rounded py-0.5 text-left hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:[(0,F.jsx)(`span`,{className:`w-3 shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:i?`▾`:`▸`}),(0,F.jsx)(`span`,{className:`truncate ${s?`text-zinc-400 dark:text-zinc-600`:`text-zinc-700 dark:text-zinc-300`}`,children:t.name}),!i&&zv(o,r.gitFiles)>0&&(0,F.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:`${zv(o,r.gitFiles)} changed file(s) inside`,children:zv(o,r.gitFiles)})]}),i&&(0,F.jsx)(Hv,{path:o,depth:n+1,...r})]});let c=o===r.openFilePath,l=r.gitFiles?.[o],u=r.attachedPaths?.includes(o)??!1;return(0,F.jsxs)(`div`,{className:`group flex w-full items-center rounded hover:bg-zinc-100 dark:hover:bg-zinc-800 ${c?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>r.onSelectFile(o),style:{paddingLeft:n*12+16},className:`flex min-w-0 flex-1 items-center py-0.5 text-left`,children:(0,F.jsx)(`span`,{className:`truncate ${s?`text-zinc-400 dark:text-zinc-600`:`text-zinc-600 dark:text-zinc-400`}`,children:t.name})}),r.onToggleAttachPath&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>r.onToggleAttachPath?.(o),title:u?`Remove this file from the prompt`:`Reference this file in the prompt`,"aria-label":`${u?`Remove`:`Reference`} ${t.name} in the prompt`,"aria-pressed":u,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 ${u?`font-bold text-blue-600 dark:text-blue-400`:`text-zinc-400 dark:text-zinc-600 [@media(hover:hover)]:opacity-0`}`,children:`@`}),l&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>(r.onSelectDiff??r.onSelectFile)(o),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 ${Rv[l].className}`,children:Rv[l].label})]})}function Wv(e){return(0,F.jsx)(`div`,{className:`text-sm`,children:(0,F.jsx)(Hv,{path:``,depth:0,...e})})}function Gv({tree:e,openFile:t,writableRoot:n,gitFiles:r,attachedPaths:i,onExpand:a,onSelectFile:o,onSelectDiff:s,onToggleAttachPath:c}){return(0,v.useEffect)(()=>{e[``]===void 0&&a(``)},[]),(0,F.jsxs)(`aside`,{className:`flex w-72 shrink-0 flex-col border-r border-zinc-200 dark:border-zinc-800`,children:[(0,F.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,F.jsx)(`div`,{className:`flex-1 overflow-auto p-2`,children:(0,F.jsx)(Wv,{tree:e,openFilePath:t?.path,writableRoot:n,gitFiles:r,attachedPaths:i,onExpand:a,onSelectFile:o,onSelectDiff:s,onToggleAttachPath:c})})]})}function Kv({title:e,onSubmit:t}){let[n,r]=(0,v.useState)(``);return(0,F.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,F.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,F.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),(0,F.jsx)(`h1`,{className:`mb-4 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`This server requires an access token.`}),(0,F.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,F.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,F.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,F.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,F.jsx)(`code`,{children:`?token=…`})]})]})})}function qv(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 Jv(e){if(e.toolName!==`edit`||e.args===null||typeof e.args!=`object`)return null;let t=e.args.edits;if(!Array.isArray(t))return null;let n=t.filter(e=>typeof e==`object`&&!!e&&typeof e.oldText==`string`&&typeof e.newText==`string`);return n.length>0?n:null}function Yv(e){if(e.toolName!==`write`||e.args===null||typeof e.args!=`object`)return null;let t=e.args.content;return typeof t==`string`?t:null}function Xv({item:e}){let t=Jv(e),n=Yv(e),r=t!==null||n!==null,[i,a]=(0,v.useState)(r),o=qv(e.args);return(0,F.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,F.jsxs)(`button`,{type:`button`,onClick:()=>a(!i),className:`flex w-full items-center gap-2 px-3 py-2 text-left`,children:[(0,F.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`}`}),(0,F.jsx)(`span`,{className:`font-mono font-medium text-zinc-700 dark:text-zinc-300`,children:e.toolName}),o&&(0,F.jsx)(`span`,{className:`truncate font-mono text-xs text-zinc-500`,children:o}),(0,F.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-600`,children:i?`▾`:`▸`})]}),i&&(0,F.jsxs)(`div`,{className:`border-t border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[t!==null&&(0,F.jsx)(`div`,{className:`mb-2 flex flex-col gap-2`,children:t.map((e,t)=>(0,F.jsx)(rv,{lines:q_(e.oldText,e.newText)},t))}),n!==null&&(0,F.jsx)(`div`,{className:`mb-2`,children:(0,F.jsx)(iv,{lines:n.split(`
311
- `).map(e=>({type:`add`,text:e}))})}),r||o===``||(0,F.jsx)(`pre`,{className:`mb-2 overflow-x-auto font-mono text-xs text-zinc-500 dark:text-zinc-400`,children:JSON.stringify(e.args,null,2)}),(0,F.jsx)(`pre`,{className:`max-h-96 overflow-auto whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,children:e.output||(e.running?`running…`:`(no output)`)})]})]})}function Zv({item:e,canEdit:t,onEdit:n}){let[r,i]=(0,v.useState)(null),a=(0,v.useRef)(null),o=t&&e.entryId!==void 0,s=r!==null;(0,v.useEffect)(()=>{s&&a.current?.focus()},[s]),(0,v.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,F.jsxs)(`div`,{className:`group ml-auto flex max-w-[85%] items-start gap-1.5`,children:[o&&!s&&(0,F.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,F.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,F.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:e.images.map((e,t)=>(0,F.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:``,className:`max-h-48 max-w-full rounded-lg object-contain`},t))}),s?(0,F.jsxs)(`div`,{children:[(0,F.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(`
312
- `).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,F.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-end gap-2 text-xs`,children:[(0,F.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,F.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,F.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,F.jsx)(`div`,{className:`whitespace-pre-wrap`,children:e.text})]})]})}var Qv=`pi-outpost:token`;function $v(){let e=null;try{let t=new URL(window.location.href);return e=t.searchParams.get(`token`),e&&(localStorage.setItem(Qv,e),t.searchParams.delete(`token`),window.history.replaceState(null,``,`${t.pathname}${t.search}${t.hash}`)),localStorage.getItem(Qv)}catch{return e}}function ey(){try{return localStorage.getItem(Qv)}catch{return null}}function ty(e){try{localStorage.setItem(Qv,e)}catch{}}var ny={connected:!1,authRequired:!1,branding:{},sessionId:``,model:``,thinkingLevel:`off`,modelSupportsReasoning:!1,models:[],commands:[],sessions:null,sessionSearch:null,tree:null,isStreaming:!1,items:[],queue:{steering:[],followUp:[]},errors:[],contextUsage:null,isCompacting:!1,dialogQueue:[],notifications:[],statuses:{},widgets:{},editorPrefill:null,fileTree:{},openFile:null,fileSearch:null,gitAvailable:!1,gitStatus:null,gitDiff:null,gitLog:null,gitShow:null};function ry(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 iy(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 ay(e,t){if(t.type!==`hello`&&t.type!==`session_replaced`)return e;let n=t.models.find(e=>`${e.provider}/${e.id}`===t.model);return{...e,connected:!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,queue:{steering:[],followUp:[]},errors:[],contextUsage:t.contextUsage??null,isCompacting:!1,dialogQueue:[],notifications:[],statuses:{},widgets:{},extensionTitle:void 0,editorPrefill:null,tree:null,writableRoot:t.writableRoot,gitAvailable:t.gitAvailable===!0}}function oy(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_loaded`)return{...e,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`)return{...e,fileTree:{...e.fileTree,[t.path]:`loading`}};if(t.type===`file_read_started`)return{...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===`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};let n=t.message;switch(n.type){case`hello`:case`session_replaced`:return ay(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`thinking_changed`:return{...e,thinkingLevel:n.level};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:ry(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:ry(e.items,()=>n.item)};case`custom_message`:return{...e,items:[...e.items,n.item]};case`tool_start`:return{...e,items:iy(e.items,n.toolCallId,n.toolName,{toolName:n.toolName,args:n.args,running:!0})};case`tool_update`:return{...e,items:iy(e.items,n.toolCallId,`tool`,{output:n.text})};case`tool_end`:return{...e,items:iy(e.items,n.toolCallId,`tool`,{output:n.text,isError:n.isError,running:!1})};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]};case`directory_listing`:return{...e,fileTree:{...e.fileTree,[n.path]:n.entries}};case`file_content`:return e.openFile?.status!==`loading`||e.openFile.requestId!==n.requestId?e:{...e,openFile:{status:`loaded`,path:n.path,content:n.content,size:n.size,mtimeMs:n.mtimeMs}};case`file_written`:{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_browser_error`:if(n.requestId.startsWith(`dir:`))return{...e,fileTree:{...e.fileTree,[n.path]:{error: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 e.openFile?.status!==`loading`||e.openFile.requestId!==n.requestId?e:{...e,openFile:{status:`error`,path:n.path,message:n.message}};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_error`:return n.requestId.startsWith(`gitdiff:`)?{...e,gitDiff:e.openFile?{path:e.openFile.path,error:n.message}:null}:{...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 sy(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 cy=4401;function ly(e=``,t,n=!1){let[r,i]=(0,v.useReducer)(oy,ny),a=(0,v.useRef)(null),[o,s]=(0,v.useState)(0),c=(0,v.useRef)(null);o===0&&c.current===null&&(c.current=t??(n?ey():$v()));let l=(0,v.useRef)(r.fileTree),u=(0,v.useRef)(r.openFile);(0,v.useEffect)(()=>{l.current=r.fileTree},[r.fileTree]),(0,v.useEffect)(()=>{u.current=r.openFile},[r.openFile]);let d=(0,v.useRef)(null);(0,v.useEffect)(()=>{d.current=r.gitDiff?.path??null},[r.gitDiff]);let f=(0,v.useCallback)(e=>{let t=a.current;t&&t.readyState===WebSocket.OPEN&&t.send(JSON.stringify(e))},[]),p=(0,v.useRef)(!1),m=(0,v.useRef)(!1),h=(0,v.useRef)(!1),g=(0,v.useCallback)(()=>{if(p.current){if(m.current){h.current=!0;return}m.current=!0,f({type:`git_status`,requestId:`git:${crypto.randomUUID()}`})}},[f]),_=(0,v.useCallback)(()=>{m.current=!1,h.current&&(h.current=!1,g())},[g]);return(0,v.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&&e&&i({type:`branding_loaded`,branding:e})}).catch(()=>{}),()=>{t=!0}},[e,o]),(0,v.useEffect)(()=>{let t,n=!1;function r(){let o=new WebSocket(sy(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_changed`){let e=t.path.lastIndexOf(`/`),n=e<0?``:t.path.slice(0,e);l.current[n]!==void 0&&(i({type:`dir_list_started`,path:n}),f({type:`list_directory`,path:n,requestId:`dir:${crypto.randomUUID()}`}));let r=u.current;if(r?.status===`loaded`&&r.path===t.path){let e=`file:${crypto.randomUUID()}`;i({type:`file_read_started`,path:t.path,requestId:e}),f({type:`read_file`,path:t.path,requestId:e})}d.current===t.path&&f({type:`git_diff`,path:t.path,requestId:`gitdiff:${crypto.randomUUID()}`}),g();return}(t.type===`hello`||t.type===`session_replaced`)&&(p.current=t.gitAvailable===!0,t.type===`hello`&&g()),t.type===`agent_end`&&g(),(t.type===`git_status`||t.type===`git_error`&&t.requestId.startsWith(`git:`))&&_(),i({type:`server`,message:t})},o.onclose=e=>{if(a.current===o){if(m.current=!1,h.current=!1,e.code===cy){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()}},[f,e,g,_,o]),{state:r,authToken:c.current,submitToken:e=>{ty(e),c.current=e,i({type:`auth_retrying`}),s(e=>e+1)},prompt:(e,t)=>f({type:`prompt`,text:e,...t?.length?{images:t}:{}}),abort:()=>f({type:`abort`}),setModel:(e,t)=>f({type:`set_model`,provider:e,id:t}),setThinking:e=>f({type:`set_thinking`,level:e}),newSession:()=>f({type:`new_session`}),switchSession:e=>f({type:`switch_session`,path:e}),deleteSession:e=>f({type:`delete_session`,path:e}),listSessions:()=>f({type:`list_sessions`}),renameSession:(e,t)=>f({type:`rename_session`,path:e,name:t}),searchSessions:e=>{let t=`sessions:${crypto.randomUUID()}`;i({type:`session_search_started`,query:e,requestId:t}),f({type:`search_sessions`,query:e,requestId:t})},clearSessionSearch:()=>i({type:`session_search_cleared`}),listTree:()=>f({type:`list_tree`}),navigateTree:e=>f({type:`navigate_tree`,entryId:e}),forkSession:e=>f({type:`fork_session`,entryId:e}),editPrompt:(e,t,n)=>f({type:`edit_prompt`,entryId:e,text:t,...n?.length?{images:n}:{}}),compact:()=>f({type:`compact`}),respondToDialog:e=>{f({type:`extension_ui_response`,...e}),i({type:`dialog_answered`})},dismissNotification:e=>i({type:`dismiss_notification`,id:e}),listDirectory:e=>{i({type:`dir_list_started`,path:e}),f({type:`list_directory`,path:e,requestId:`dir:${crypto.randomUUID()}`})},readFile:e=>{let t=`file:${crypto.randomUUID()}`;i({type:`file_read_started`,path:e,requestId:t}),f({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}),f({type:`write_file`,path:e,content:t,expectedMtimeMs:n,...r?{force:r}:{},requestId:a})},searchFiles:e=>{let t=`search:${crypto.randomUUID()}`;i({type:`file_search_started`,query:e,requestId:t}),f({type:`search_files`,query:e,requestId:t})},clearFileSearch:()=>i({type:`file_search_cleared`}),fetchGitStatus:g,fetchGitDiff:e=>{let t=`gitdiff:${crypto.randomUUID()}`;i({type:`git_diff_started`,path:e,requestId:t}),f({type:`git_diff`,path:e,requestId:t})},clearGitDiff:()=>i({type:`git_diff_cleared`}),fetchGitLog:e=>f({type:`git_log`,...e?{limit:e}:{},requestId:`gitlog:${crypto.randomUUID()}`}),fetchGitShow:e=>f({type:`git_show`,sha:e,requestId:`gitshow:${crypto.randomUUID()}`}),clearGitShow:()=>i({type:`git_show_cleared`})}}var uy=`pi-outpost:theme`;function dy(){return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function fy(){let e=localStorage.getItem(uy);return e===`light`||e===`dark`||e===`system`?e:null}function py(e){localStorage.setItem(uy,e)}function my(e,t,n=document.documentElement){let r=t?fy():null,[i,a]=(0,v.useState)(r??e),o=(0,v.useRef)(r!==null);(0,v.useEffect)(()=>{o.current||a(e)},[e]),(0,v.useEffect)(()=>{function e(e){let t=e.data;t?.type===`pi-outpost:set-theme`&&(t.theme!==`light`&&t.theme!==`dark`&&t.theme!==`system`||(o.current=!0,a(t.theme)))}return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[]);let[s,c]=(0,v.useState)(dy);(0,v.useEffect)(()=>{let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>c(e.matches?`dark`:`light`);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let l=i===`system`?s:i;(0,v.useLayoutEffect)(()=>{n.dataset.theme=l},[n,l]);let u=(0,v.useCallback)(e=>{o.current=!0,a(e),t&&py(e)},[t]);return{theme:l,toggle:(0,v.useCallback)(()=>u(l===`dark`?`light`:`dark`),[l,u]),setTheme:u}}var hy=(0,v.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:d,setModel:f,setThinking:p,newSession:m,switchSession:h,deleteSession:g,listSessions:_,renameSession:y,searchSessions:b,clearSessionSearch:x,listTree:S,navigateTree:C,forkSession:w,editPrompt:T,compact:E,respondToDialog:ee,dismissNotification:D,listDirectory:O,readFile:te,writeFile:ne,closeFilePreview:re,searchFiles:ie,clearFileSearch:ae,fetchGitDiff:k,clearGitDiff:A,fetchGitLog:j,fetchGitShow:M,clearGitShow:oe}=ly(e,r,a),[se,ce]=(0,v.useState)(!1),[le,ue]=(0,v.useState)([]),[de,fe]=(0,v.useState)([]),[pe,me]=(0,v.useState)(null),[he,ge]=(0,v.useState)(null),[_e,ve]=(0,v.useState)(!1),ye=(0,v.useRef)([]),be=(0,v.useRef)(null),xe=(0,v.useRef)(null),[Se,Ce]=(0,v.useState)(!1),[we,Te]=(0,v.useState)(()=>{try{return localStorage.getItem(`pi-outpost:hide-tools`)===`1`}catch{return!1}});function Ee(){Te(e=>{try{localStorage.setItem(`pi-outpost:hide-tools`,e?`0`:`1`)}catch{}return!e})}let[De,Oe]=(0,v.useState)([]),[ke,Ae]=(0,v.useState)(0);async function je(e){let{attachments:t,errors:n}=await w_(e);t.length>0&&ue(e=>[...e,...t]),Oe(n)}(0,v.useEffect)(()=>{ye.current=le},[le]),(0,v.useEffect)(()=>{let t=s.openFile;if(!t)return;let n=t.path,r=t.status===`loaded`;if(be.current!==n&&(be.current=n,xe.current=null,ue(e=>e.filter(e=>e.source!==`preview`)),me(null),ge(null)),xe.current===n)return;let i=!1;async function a(){let t=a_(n)?he===n?await k_(n,o_(e,n,c)):null:r?T_(n):null;if(!(i||t===null||be.current!==n||xe.current===n)){if(typeof t==`string`){me(t);return}me(null),ue(e=>M_(e,t))}}return a(),()=>{i=!0}},[s.openFile,e,c,he]);function Me(){be.current=null,xe.current=null,re()}let Ne=(0,v.useMemo)(()=>[...le.filter(e=>e.kind===`path`).map(e=>e.data),...de],[le,de]);function Pe(e){let t=ye.current.findIndex(t=>t.kind===`path`&&t.data===e);t>=0?Fe(t):de.includes(e)||ue(t=>j_(t,e))}function Fe(e){let t=ye.current[e];t?.source===`preview`&&(xe.current=t.previewPath??be.current,me(null)),ue(t=>N_(t,e))}function Ie(e,t){u(e,t),ue([]),Oe([]),me(null),_e||Me()}function Le(e){e.preventDefault(),Ae(0),e.dataTransfer.files.length>0&&je(Array.from(e.dataTransfer.files))}let{theme:Re,toggle:ze,setTheme:Be}=my(n??s.branding.defaultTheme??`system`,s.branding.allowThemeToggle!==!1,o);(0,v.useImperativeHandle)(i,()=>({setTheme:Be}),[Be]);let Ve=(0,v.useRef)(null),He=(0,v.useRef)(null),Ue=(0,v.useRef)(!0);function We(){let e=Ve.current;e&&(Ue.current=e.scrollHeight-e.scrollTop-e.clientHeight<120)}return(0,v.useEffect)(()=>{Ue.current&&He.current?.scrollIntoView({behavior:`smooth`})},[s.items]),(0,v.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]),s.authRequired?(0,F.jsx)(c_.Provider,{value:Re,children:(0,F.jsx)(Kv,{title:s.branding.title,onSubmit:l})}):(0,F.jsxs)(c_.Provider,{value:Re,children:[(0,F.jsxs)(`div`,{className:`relative flex h-full`,onDragEnter:e=>{e.dataTransfer.types.includes(`Files`)&&Ae(e=>e+1)},onDragLeave:()=>Ae(e=>Math.max(0,e-1)),onDragOver:e=>e.preventDefault(),onDrop:Le,children:[ke>0&&(0,F.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,F.jsx)(`p`,{className:`text-lg font-medium text-zinc-700 dark:text-zinc-200`,children:`Drop files to attach (images & text)`})}),se&&(0,F.jsx)(Gv,{tree:s.fileTree,openFile:s.openFile,writableRoot:s.writableRoot,gitFiles:s.gitStatus?.files,attachedPaths:Ne,onExpand:O,onSelectFile:e=>{Ce(!1),te(e)},onSelectDiff:e=>{Ce(!0),te(e)},onToggleAttachPath:Pe}),(0,F.jsxs)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,children:[(0,F.jsx)(Nv,{title:s.branding.title,sessions:s.sessions,sessionSearch:s.sessionSearch,sessionId:s.sessionId,tree:s.tree,isStreaming:s.isStreaming,connected:s.connected,theme:Re,showThemeToggle:s.branding.allowThemeToggle!==!1,statuses:s.statuses,sidebarOpen:se,hideTools:we,onToggleSidebar:()=>ce(!se),onToggleHideTools:Ee,onToggleTheme:ze,onNewSession:m,onSwitchSession:h,onDeleteSession:g,onListSessions:_,onRenameSession:y,onSearchSessions:b,onClearSessionSearch:x,onListTree:S,onNavigateTree:C,onForkSession:w,gitAvailable:s.gitAvailable,gitStatus:s.gitStatus,gitLog:s.gitLog,onFetchGitLog:j,onShowCommit:M}),(0,F.jsxs)(`div`,{className:`relative z-0 flex min-h-0 flex-1 flex-col`,children:[s.openFile&&(0,F.jsx)(sv,{file:s.openFile,writableRoot:s.writableRoot,isStreaming:s.isStreaming,onDirtyChange:ve,gitState:s.gitStatus?.files[s.openFile.path],initialShowGitDiff:Se,gitDiff:s.gitDiff,onFetchGitDiff:k,onClearGitDiff:A,onClose:Me,onReload:te,onSave:ne,serverUrl:e,token:c,onImageLoad:ge},s.openFile.path),s.gitShow&&(0,F.jsx)(lv,{show:s.gitShow,onClose:oe}),(0,F.jsx)(`main`,{ref:Ve,onScroll:We,className:`flex-1 overflow-y-auto`,children:(0,F.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-3 px-4 py-6`,children:[s.items.length===0&&(0,F.jsxs)(`div`,{className:`mt-24 text-center text-zinc-500 dark:text-zinc-600`,children:[(0,F.jsx)(`div`,{className:`mb-2 text-4xl`,children:s.branding.title??`π`}),(0,F.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}`;return t.kind===`user`?(0,F.jsx)(Zv,{item:t,canEdit:!s.isStreaming&&s.connected,onEdit:T},r):t.kind===`tool`?we?null:(0,F.jsx)(Xv,{item:t},t.toolCallId?`${s.sessionId}:${t.toolCallId}`:r):t.kind===`custom`?(0,F.jsx)(R_,{item:t},r):t.blocks.length===0&&!t.errorMessage?null:(0,F.jsx)(x_,{item:t,serverUrl:e,token:c,onOpenFile:e=>{Ce(!1),te(e)}},r)}),(s.queue.steering.length>0||s.queue.followUp.length>0)&&(0,F.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,F.jsxs)(`div`,{children:[`⏩ steering: `,e]},`s${t}`)),s.queue.followUp.map((e,t)=>(0,F.jsxs)(`div`,{children:[`⏭ follow-up: `,e]},`f${t}`))]}),De.map((e,t)=>(0,F.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}`)),pe&&(0,F.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:pe}),s.errors.map((e,t)=>(0,F.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,F.jsx)(`div`,{ref:He})]})})]}),(0,F.jsx)(`footer`,{className:`border-t border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:(0,F.jsxs)(`div`,{className:`mx-auto max-w-3xl`,children:[(0,F.jsx)(K_,{widgets:s.widgets,placement:`aboveEditor`}),(0,F.jsx)(L_,{isStreaming:s.isStreaming,connected:s.connected,commands:s.commands,fileSearch:s.fileSearch,prefill:s.editorPrefill,attachments:le,onAttach:e=>void je(e),onMentionPaths:fe,onRemoveAttachment:Fe,onSend:Ie,onAbort:d,onSearchFiles:ie,onClearFileSearch:ae}),(0,F.jsx)(K_,{widgets:s.widgets,placement:`belowEditor`}),(0,F.jsx)(Lv,{model:s.model,models:s.models,thinkingLevel:s.thinkingLevel,modelSupportsReasoning:s.modelSupportsReasoning,isStreaming:s.isStreaming,contextUsage:s.contextUsage,isCompacting:s.isCompacting,onSetModel:f,onSetThinking:p,onCompact:E})]})})]})]}),s.dialogQueue[0]&&(0,F.jsx)(H_,{request:s.dialogQueue[0],onRespond:ee}),(0,F.jsx)(G_,{notifications:s.notifications,onDismiss:D})]})});(0,y.createRoot)(document.getElementById(`root`)).render((0,F.jsx)(v.StrictMode,{children:(0,F.jsx)(hy,{})}));export{l as i,ks as n,o as r,p_ as t};
309
+ `),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;let a=n.length,o=r.length;for(;a>i&&o>i&&n[a-1]===r[o-1];)a--,o--;let s=n.slice(i,a),c=r.slice(i,o),l=n.slice(0,i).map(e=>({type:`same`,text:e}));if(s.length*c.length>300*300)l.push(...s.map(e=>({type:`del`,text:e}))),l.push(...c.map(e=>({type:`add`,text:e})));else{let e=s.length,t=c.length,n=Array.from({length:e+1},()=>Array(t+1).fill(0));for(let r=e-1;r>=0;r--)for(let e=t-1;e>=0;e--)n[r][e]=s[r]===c[e]?n[r+1][e+1]+1:Math.max(n[r+1][e],n[r][e+1]);let r=0,i=0;for(;r<e&&i<t;)s[r]===c[i]?(l.push({type:`same`,text:s[r]}),r++,i++):n[r+1][i]>=n[r][i+1]?(l.push({type:`del`,text:s[r]}),r++):(l.push({type:`add`,text:c[i]}),i++);for(;r<e;)l.push({type:`del`,text:s[r++]});for(;i<t;)l.push({type:`add`,text:c[i++]})}return l.push(...n.slice(a).map(e=>({type:`same`,text:e}))),l}function J_(e){let t=[],n=0;for(;n<e.length;){if(e[n].type===`same`){t.push({left:e[n].text,right:e[n].text,changed:!1}),n++;continue}let r=[],i=[];for(;n<e.length&&e[n].type===`del`;)r.push(e[n++].text);for(;n<e.length&&e[n].type===`add`;)i.push(e[n++].text);for(let e=0;e<Math.max(r.length,i.length);e++)t.push({left:e<r.length?r[e]:null,right:e<i.length?i[e]:null,changed:!0})}return t}function Y_(e,t=2){let n=Array(e.length).fill(!1);e.forEach((r,i)=>{if(r.changed)for(let r=Math.max(0,i-t);r<=Math.min(e.length-1,i+t);r++)n[r]=!0});let r=[],i=!1;return e.forEach((e,t)=>{n[t]?(r.push(e),i=!1):i||=(r.push(null),!0)}),r}function X_(e,t=2){let n=Array(e.length).fill(!1);e.forEach((r,i)=>{if(r.type!==`same`)for(let r=Math.max(0,i-t);r<=Math.min(e.length-1,i+t);r++)n[r]=!0});let r=[],i=!1;return e.forEach((e,t)=>{n[t]?(r.push(e),i=!1):i||=(r.push(null),!0)}),r}var Z_=null,Q_={javascript:()=>p_(()=>import(`./javascript-w9aIBC1S.js`),[]),typescript:()=>p_(()=>import(`./typescript-CTV1Js34.js`),[]),json:()=>p_(()=>import(`./json-DS4EA3dC.js`),[]),xml:()=>p_(()=>import(`./xml-DasnpDVC.js`),[]),css:()=>p_(()=>import(`./css-D5l_8KUR.js`),[]),scss:()=>p_(()=>import(`./scss-BNjRHcgO.js`),[]),bash:()=>p_(()=>import(`./bash-LmRjUKlR.js`),[]),python:()=>p_(()=>import(`./python-DwhXSSGr.js`),[]),go:()=>p_(()=>import(`./go-B-PCS5zA.js`),[]),rust:()=>p_(()=>import(`./rust-Dk33Kfe-.js`),[]),java:()=>p_(()=>import(`./java-ChVphriW.js`),[]),c:()=>p_(()=>import(`./c-CVYb4e6m.js`),[]),cpp:()=>p_(()=>import(`./cpp-V0F2hNk9.js`),[]),csharp:()=>p_(()=>import(`./csharp-GZmu99Fo.js`),[]),ruby:()=>p_(()=>import(`./ruby-D6zc0cUO.js`),[]),php:()=>p_(()=>import(`./php-5k5YNuRS.js`),[]),sql:()=>p_(()=>import(`./sql-DWRKyvJ-.js`),[]),yaml:()=>p_(()=>import(`./yaml-1XF8XcZB.js`),[]),ini:()=>p_(()=>import(`./ini-B1CroMsf.js`),[]),dockerfile:()=>p_(()=>import(`./dockerfile-C0zufGsU.js`),[]),markdown:()=>p_(()=>import(`./markdown-C8bVcNXx.js`),[]),plaintext:()=>p_(()=>import(`./plaintext-YB8mb-y7.js`),[])};async function $_(){return Z_||=(async()=>{let{default:e}=await p_(async()=>{let{default:e}=await import(`./core-wWNe51ur.js`);return{default:e}},[]);return await Promise.all(Object.entries(Q_).map(async([t,n])=>{let r=await n();e.registerLanguage(t,r.default)})),e})(),Z_}var ev={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 tv(e){let t=e.split(`/`).pop()??e;if(/^dockerfile$/i.test(t))return`dockerfile`;let n=t.lastIndexOf(`.`);if(!(n<0))return ev[t.slice(n+1).toLowerCase()]}function nv({code:e,path:t}){let[n,r]=(0,v.useState)(null),i=(0,v.useRef)(e);return i.current=e,(0,v.useEffect)(()=>{let e=!1;return r(null),$_().then(n=>{if(e)return;let a=tv(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,F.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,children:e}):(0,F.jsx)(`pre`,{className:`hljs whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,dangerouslySetInnerHTML:{__html:n}})}function rv({lines:e,fill:t=!1}){return(0,F.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:Y_(J_(e)).map((e,t)=>e===null?(0,F.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,F.jsxs)(`div`,{className:`grid grid-cols-2`,children:[(0,F.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,F.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 iv({lines:e}){return(0,F.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded border border-zinc-200 font-mono text-xs leading-relaxed dark:border-zinc-800`,children:X_(e).map((e,t)=>e===null?(0,F.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,F.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 av(e){return/\.(md|markdown)$/i.test(e)}function ov(e,t){return t===void 0?!0:t===null?!1:t===``||e===t||e.startsWith(`${t}/`)}function sv({file:e,writableRoot:t,isStreaming:n,onDirtyChange:r,gitState:i,initialShowGitDiff:a=!1,gitDiff:o,onFetchGitDiff:s,onClearGitDiff:c,onClose:l,onReload:u,onSave:d,serverUrl:f=``,token:p=null,onImageLoad:m}){let[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(a),[b,x]=(0,v.useState)(null),[S,C]=(0,v.useState)(`idle`),w=(0,v.useRef)(null),T=(0,v.useRef)(null),E=e.status===`loaded`?e:null,ee=E!==null&&av(e.path),D=a_(e.path),O=ov(e.path,t),te=b!==null&&b.draft!==b.baseContent,ne=E?.pendingSave!==void 0,re=b!==null&&E!==null&&E.mtimeMs!==b.baseMtimeMs,ie=E?.saveError?.conflict===!0||re;function ae(){te&&!window.confirm(`Discard unsaved changes?`)||l()}function k(){E&&x({draft:E.content,baseContent:E.content,baseMtimeMs:E.mtimeMs})}function A(t=!1){!E||b===null||ne||(T.current=b.draft,d(e.path,b.draft,b.baseMtimeMs,t))}function j(){x(null),u(e.path)}function M(){let t=!_;y(t),t?s(e.path):c()}return(0,v.useEffect)(()=>{if(b!==null&&E!==null&&T.current!==null&&E.content===T.current&&E.mtimeMs!==b.baseMtimeMs){let e=T.current;T.current=null,b.draft===e?x(null):x({...b,baseContent:E.content,baseMtimeMs:E.mtimeMs})}},[E?.mtimeMs]),(0,v.useEffect)(()=>{function e(e){e.key===`Escape`&&ae()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),(0,v.useEffect)(()=>{C(n?`streaming`:e=>e===`streaming`?`done`:e)},[n]),(0,v.useEffect)(()=>(r(te),()=>r(!1)),[te]),(0,v.useEffect)(()=>(a&&s(e.path),()=>c()),[]),(0,F.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[ee&&b===null&&!_&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>g(!h),title:h?`Show rendered`:`Show source`,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:h?`⚏ rendered`:`⌗ source`}),i!==void 0&&b===null&&(0,F.jsx)(`button`,{type:`button`,onClick:M,"aria-pressed":_,title:_?`Show file content`:`Show uncommitted changes (vs HEAD)`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs ${_?`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`}),(0,F.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,te&&(0,F.jsx)(`span`,{className:`ml-1 text-amber-500`,children:`●`})]}),E&&b===null&&(0,F.jsx)(s_,{text:E.content}),E&&b===null&&!_&&O&&(0,F.jsx)(`button`,{type:`button`,onClick:k,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`}),E&&b===null&&!O&&(0,F.jsx)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,title:`Outside the writable zone`,children:`🔒 read-only`}),b!==null&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>A(),disabled:!te||ne||ie,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:ne?`saving…`:`save`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>te?window.confirm(`Discard unsaved changes?`)&&x(null):x(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,F.jsx)(`button`,{type:`button`,onClick:ae,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:`✕`})]}),ie&&b!==null&&(0,F.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,F.jsx)(`span`,{className:`min-w-0 flex-1`,children:`File changed on disk since you started editing.`}),(0,F.jsx)(`button`,{type:`button`,onClick:j,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,F.jsx)(`button`,{type:`button`,onClick:()=>A(!0),disabled:ne,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`})]}),b!==null&&E?.saveError&&!E.saveError.conflict&&(0,F.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:E.saveError.message}),(0,F.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[_&&b===null&&(0,F.jsxs)(`div`,{className:`p-4`,children:[o?.path===e.path&&`error`in o&&(0,F.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,F.jsx)(rv,{fill:!0,lines:q_(o.before,o.after)}),o?.path!==e.path&&(0,F.jsx)(`div`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`loading diff…`})]}),D&&b===null&&!_&&(0,F.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,F.jsx)(`img`,{src:o_(f,e.path,p),alt:e.path,onLoad:()=>m(e.path),className:`max-h-full max-w-full rounded object-contain`})}),e.status===`loading`&&b===null&&!_&&!D&&(0,F.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),e.status===`error`&&!D&&(0,F.jsx)(`div`,{className:`p-4 text-sm text-red-600 dark:text-red-400`,children:e.message}),b!==null&&(0,F.jsx)(`textarea`,{ref:w,value:b.draft,onChange:e=>x({...b,draft:e.target.value}),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),te&&!ne&&!ie&&A())},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`}),E&&b===null&&!_&&ee&&!h&&(0,F.jsx)(`div`,{className:`prose-chat mx-auto max-w-3xl p-4 text-zinc-700 dark:text-zinc-300`,children:(0,F.jsx)(Oo,{remarkPlugins:[Ug,t_],rehypePlugins:[Up],components:{a:({href:t,children:n,...r})=>!t||/^[a-z][a-z0-9+.-]*:/i.test(t)?(0,F.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,...r,children:n}):t.startsWith(`#`)?(0,F.jsx)(`a`,{href:t,...r,children:n}):(0,F.jsx)(`a`,{href:t,onClick:n=>{n.preventDefault(),u(i_(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(`//`)?o_(f,i_(e.path,t),p):t;return(0,F.jsx)(`img`,{...r,src:i,alt:n??``,loading:`lazy`,className:`max-w-full rounded-lg`})}},children:n_(E.content)})}),E&&b===null&&!_&&(!ee||h)&&(0,F.jsx)(`div`,{className:`p-4`,children:(0,F.jsx)(nv,{code:E.content,path:e.path})})]}),S!==`idle`&&(0,F.jsxs)(`button`,{type:`button`,onClick:ae,"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:[S===`streaming`?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 animate-pulse motion-reduce:animate-none rounded-full bg-amber-500`}),(0,F.jsx)(`span`,{className:`text-amber-700 dark:text-amber-400`,children:`π is replying…`})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 rounded-full bg-emerald-500`}),(0,F.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:`π replied`})]}),(0,F.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-500`,children:`show conversation →`})]})]})}function cv(e){return e.split(`
310
+ `).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 lv({show:e,onClose:t}){return(0,v.useEffect)(()=>{function e(e){e.key===`Escape`&&(e.stopImmediatePropagation(),t())}return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t]),(0,F.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,F.jsx)(`span`,{className:`font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,12)}),(0,F.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`commit diff`}),(0,F.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,F.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,F.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto p-3 font-mono text-xs leading-relaxed`,children:cv(e.patch).map((e,t)=>(0,F.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 uv=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function dv(e){let t=(0,v.useRef)(null);return(0,v.useEffect)(()=>{function n(n){t.current&&!t.current.contains(n.target)&&e()}return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),t}function fv(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 pv({status:e,log:t,onFetchLog:n,onShowCommit:r}){let[i,a]=(0,v.useState)(!1),o=dv(()=>a(!1)),s=e&&(e.ahead>0||e.behind>0)?` ${e.ahead>0?`↑${e.ahead}`:``}${e.behind>0?`↓${e.behind}`:``}`:``;return(0,F.jsxs)(`div`,{className:`relative`,ref:o,children:[(0,F.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,F.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,F.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),t?.length===0&&(0,F.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no commits`}),t?.map(e=>(0,F.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,F.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,7)}),(0,F.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-zinc-700 dark:text-zinc-300`,children:e.subject}),(0,F.jsxs)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:[e.author,` · `,fv(e.date)]})]},e.sha))]})]})}function mv(e){let t=(0,v.useRef)(null);return(0,v.useEffect)(()=>{function n(n){t.current&&!t.current.contains(n.target)&&e()}return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),t}var hv=`#10b981`,gv=[`#8b5cf6`,`#f59e0b`,`#0ea5e9`,`#f43f5e`,`#14b8a6`,`#d946ef`],_v=14,vv=36;function yv(e){return e===0?hv:gv[(e-1)%gv.length]}function bv(e){let t=[],n=new Set,r=0,i=0;function a(e,o,s,c){let l=[...e.children].sort((e,t)=>Number(t.onPath)-Number(e.onPath)),u=l.slice(1).map(e=>[e,r++]);if(u.length>0&&i++,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:e.onPath&&!l.some(e=>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))}e.length>1&&i++;let o=[...e].sort((e,t)=>Number(t.onPath)-Number(e.onPath));return o.forEach((e,t)=>{let i=r++;n.add(i),a(e,i,!1,o.length>1?t+1:void 0)}),{rows:t,laneCount:r,branchPoints:i}}function xv(e){return e.flatMap(e=>[e,...xv(e.children)])}function Sv({row:e,laneCount:t}){let n=t*_v+2,r=e=>e*_v+_v/2+1,i=r(e.lane),a=vv/2;return(0,F.jsxs)(`svg`,{width:n,height:vv,viewBox:`0 0 ${n} ${vv}`,"aria-hidden":!0,className:`shrink-0`,children:[e.through.map(e=>(0,F.jsx)(`line`,{x1:r(e),y1:0,x2:r(e),y2:vv,stroke:yv(e),strokeWidth:2,opacity:.55},e)),e.lineAbove&&(0,F.jsx)(`line`,{x1:i,y1:0,x2:i,y2:a,stroke:yv(e.lane),strokeWidth:2}),e.lineBelow&&(0,F.jsx)(`line`,{x1:i,y1:a,x2:i,y2:vv,stroke:yv(e.lane),strokeWidth:2}),e.forkTo.map(e=>(0,F.jsx)(`path`,{d:`M ${i} ${a} C ${i} ${vv}, ${r(e)} ${a}, ${r(e)} ${vv}`,fill:`none`,stroke:yv(e),strokeWidth:2,opacity:.75},e)),e.isCurrent?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`circle`,{cx:i,cy:a,r:6,fill:`none`,stroke:yv(e.lane),strokeWidth:2}),(0,F.jsx)(`circle`,{cx:i,cy:a,r:2.5,fill:yv(e.lane)})]}):(0,F.jsx)(`circle`,{cx:i,cy:a,r:4,fill:e.node.onPath?yv(e.lane):`var(--tree-off, #d4d4d8)`,stroke:yv(e.lane),strokeWidth:e.node.onPath?0:1.5})]})}function Cv({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,F.jsx)(`span`,{className:`shrink-0 rounded-full border px-1.5 py-px text-[10px] leading-4 ${n}`,children:e})}var wv=`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 Tv({row:e,laneCount:t,isStreaming:n,onNavigate:r,onFork:i,onClose:a}){let{node:o}=e,s=o.tipId??o.entryId;return(0,F.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:vv},children:[(0,F.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,F.jsx)(Sv,{row:e,laneCount:t}),(0,F.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,F.jsxs)(Cv,{tone:`branch`,children:[e.forkTo.length+1,` branches`]}),e.branchIndex!==void 0&&(0,F.jsxs)(Cv,{tone:`branch`,children:[`branch `,e.branchIndex,o.onPath&&!e.isCurrent?` · current`:``]}),e.isCurrent&&(0,F.jsx)(Cv,{tone:`current`,children:`current`}),o.label&&(0,F.jsx)(Cv,{tone:`label`,children:o.label})]}),(0,F.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:wv,children:`↺ redo`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>{i(o.entryId),a()},title:`fork a new session from this point`,className:wv,children:`⑂ fork`})]})}function Ev({tree:e,isStreaming:t,onListTree:n,onNavigate:r,onFork:i}){let[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``),l=mv(()=>o(!1));(0,v.useEffect)(()=>{a&&e===null&&n()},[a,e]);let u=(0,v.useMemo)(()=>e&&e.length>0?bv(e):null,[e]),d=(0,v.useMemo)(()=>{if(!e||!s.trim())return null;let t=s.trim().toLowerCase();return xv(e).filter(e=>e.text.toLowerCase().includes(t)||e.label?.toLowerCase().includes(t))},[e,s]);return(0,F.jsxs)(`div`,{className:`relative`,ref:l,children:[(0,F.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,F.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,F.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),e?.length===0&&(0,F.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no messages yet`}),e&&e.length>0&&u&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,F.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,F.jsx)(`span`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Conversation tree`}),(0,F.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,F.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,F.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,F.jsx)(`div`,{className:`min-h-0 overflow-y-auto py-1`,children:d===null?u.rows.map(e=>(0,F.jsx)(Tv,{row:e,laneCount:u.laneCount,isStreaming:t,onNavigate:r,onFork:i,onClose:()=>o(!1)},e.node.entryId)):d.length===0?(0,F.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no matches`}):d.map(e=>(0,F.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70`,children:[(0,F.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,F.jsx)(`span`,{"aria-hidden":!0,className:e.onPath?`text-emerald-500`:`text-zinc-300 dark:text-zinc-600`,children:`●`}),(0,F.jsx)(`span`,{className:`min-w-0 truncate text-zinc-700 dark:text-zinc-300`,children:e.text||`(empty)`}),e.onPath&&(0,F.jsx)(Cv,{tone:`current`,children:`on current branch`}),e.label&&(0,F.jsx)(Cv,{tone:`label`,children:e.label})]}),(0,F.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:wv,children:`↺ redo`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>{i(e.entryId),o(!1)},title:`fork a new session from this point`,className:wv,children:`⑂ fork`})]},e.entryId))})]})]})]})}function Dv(e){let t=(0,v.useRef)(null);return(0,v.useEffect)(()=>{function n(n){t.current&&!t.current.contains(n.target)&&e()}return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),t}var Ov=200;function kv({initial:e,onCommit:t,onCancel:n}){let[r,i]=(0,v.useState)(e);return(0,F.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 Av({session:e,isCurrent:t,renaming:n,onSwitch:r,onDelete:i,onStartRename:a,onRename:o,onCancelRename:s}){return n?(0,F.jsx)(`div`,{className:`px-3 py-2`,children:(0,F.jsx)(kv,{initial:e.name??``,onCommit:o,onCancel:s})}):(0,F.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,F.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 flex-1 px-3 py-2 text-left text-sm`,children:[(0,F.jsx)(`div`,{className:`truncate text-zinc-700 dark:text-zinc-300`,children:e.name||e.firstMessage||`(empty)`}),e.snippet&&(0,F.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-zinc-500 dark:text-zinc-500`,children:e.snippet}),(0,F.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,F.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,F.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 jv({sessions:e,sessionSearch:t,sessionId:n,onSwitchSession:r,onDeleteSession:i,onListSessions:a,onRenameSession:o,onSearchSessions:s,onClearSessionSearch:c}){let[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(null),h=Dv(()=>u(!1)),g=d.trim(),_=g.length>=2;(0,v.useEffect)(()=>{if(!l)return;if(!_){c();return}let e=setTimeout(()=>s(g),Ov);return()=>clearTimeout(e)},[l,g,_]);function y(){u(!1),m(null)}let b=_&&!(t?.status===`loaded`&&t.query===g),x=_?b?null:t?.results??null:e;return(0,F.jsxs)(`div`,{className:`relative`,ref:h,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>{if(l){y();return}u(!0),f(``),m(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,F.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,F.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,F.jsx)(`input`,{type:`search`,value:d,onChange:e=>f(e.target.value),placeholder:`Search sessions`,"aria-label":`Search sessions`,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,F.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,F.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[x===null&&(0,F.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),x?.length===0&&(0,F.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:_?`no matches`:`no saved sessions`}),x?.map(e=>(0,F.jsx)(Av,{session:e,isCurrent:e.id===n,renaming:p===e.path,onSwitch:()=>{r(e.path),y()},onDelete:()=>{window.confirm(`Delete this session?`)&&i(e.path)},onStartRename:()=>m(e.path),onRename:t=>{o(e.path,t),m(null),_&&s(d.trim())},onCancelRename:()=>m(null)},e.path))]})]})]})}function Mv({theme:e,onToggle:t}){return(0,F.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 Nv(e){let{isStreaming:t,connected:n}=e;return(0,F.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,F.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,F.jsx)(pv,{status:e.gitStatus,log:e.gitLog,onFetchLog:e.onFetchGitLog,onShowCommit:e.onShowCommit}),(0,F.jsx)(`span`,{className:`text-lg font-semibold tracking-tight`,style:{color:`var(--accent, inherit)`},children:e.title??`π`}),t&&(0,F.jsxs)(`span`,{"aria-live":`polite`,className:`flex items-center gap-1.5 text-xs text-amber-600 dark:text-amber-400`,children:[(0,F.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse motion-reduce:animate-none rounded-full bg-amber-500 dark:bg-amber-400`}),`working`]}),Object.entries(e.statuses).map(([e,t])=>(0,F.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:t},e)),(0,F.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,F.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,F.jsx)(Mv,{theme:e.theme,onToggle:e.onToggleTheme}),(0,F.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,F.jsx)(Ev,{tree:e.tree,isStreaming:t,onListTree:e.onListTree,onNavigate:e.onNavigateTree,onFork:e.onForkSession}),(0,F.jsx)(jv,{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,F.jsx)(`span`,{className:`h-2 w-2 rounded-full ${n?`bg-emerald-500`:`bg-red-500`}`,title:n?`connected`:`disconnected`})]})]})}function Pv(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 Fv({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,F.jsxs)(`svg`,{width:18,height:18,viewBox:`0 0 36 36`,className:`-rotate-90 shrink-0`,children:[(0,F.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,F.jsx)(`circle`,{cx:`18`,cy:`18`,r:t,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,strokeLinecap:`round`,strokeDasharray:`${i} ${n-i}`,className:Pv(e)})]})}function Iv({thinkingLevel:e,isStreaming:t,onSetThinking:n}){let[r,i]=(0,v.useState)(!1),a=(0,v.useRef)(null),o=e!==`off`,s=Math.max(0,uv.indexOf(e));return(0,v.useEffect)(()=>{if(!r)return;function e(e){a.current&&!a.current.contains(e.target)&&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,F.jsxs)(`div`,{className:`relative`,ref:a,children:[(0,F.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,F.jsx)(`span`,{"aria-hidden":!0,className:`text-sm leading-none ${o?``:`opacity-40 grayscale`}`,children:`🧠`}),e]}),r&&(0,F.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,F.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between text-xs`,children:[(0,F.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`thinking`}),(0,F.jsx)(`span`,{className:`font-mono text-zinc-700 dark:text-zinc-200`,children:e})]}),(0,F.jsx)(`input`,{type:`range`,min:0,max:uv.length-1,step:1,value:s,onChange:e=>n(uv[Number(e.target.value)]),"aria-label":`Thinking level`,"aria-valuetext":e,className:`w-full accent-amber-500`}),(0,F.jsxs)(`div`,{className:`mt-0.5 flex justify-between font-mono text-[9px] text-zinc-400 dark:text-zinc-600`,children:[(0,F.jsx)(`span`,{children:uv[0]}),(0,F.jsx)(`span`,{children:uv[uv.length-1]})]})]})]})}function Lv(e){let{model:t,models:n,thinkingLevel:r,modelSupportsReasoning:i,isStreaming:a,contextUsage:o,isCompacting:s}=e;return(0,F.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,F.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,F.jsx)(`option`,{value:t,children:t}),n.map(e=>(0,F.jsxs)(`option`,{value:`${e.provider}/${e.id}`,children:[e.provider,`/`,e.id]},`${e.provider}/${e.id}`))]}),i&&(0,F.jsx)(Iv,{thinkingLevel:r,isStreaming:a,onSetThinking:e.onSetThinking}),(0,F.jsxs)(`button`,{type:`button`,onClick:e.onCompact,disabled:a||s,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,F.jsx)(Fv,{usage:o}),s?`compacting…`:o?.percent==null?`context`:`${Math.round(o.percent)}%`]})]})}var Rv=`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`,zv=`mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400`;function Bv({title:e,credentials:t,onSetCredential:n,onDeclareProvider:r,errors:i}){let a=t.providers,[o,s]=(0,v.useState)(a.length>0?`known`:`custom`),[c,l]=(0,v.useState)(a[0]?.id??``),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(!0),[x,S]=(0,v.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}!f.trim()||!m.trim()||!u.trim()||!g.trim()||r({provider:f.trim(),baseUrl:m.trim(),apiKey:u.trim(),models:[g.trim()],compat:{supportsDeveloperRole:y,supportsReasoningEffort:x}})}}return(0,F.jsx)(`div`,{className:`flex h-full items-center justify-center overflow-auto p-6`,children:(0,F.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,F.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),C?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`h1`,{className:`mb-3 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`No model is available.`}),(0,F.jsxs)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:[`Credentials are configured, so this is not a missing key: `,(0,F.jsx)(`code`,{children:`allowedModels`}),` in your configuration leaves nothing to choose from. Widen it, or remove it, then restart.`]})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.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,F.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,F.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,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`label`,{htmlFor:`onboarding-provider`,className:zv,children:`Provider`}),(0,F.jsx)(`select`,{id:`onboarding-provider`,value:c,onChange:e=>l(e.target.value),className:`${Rv} mb-3`,children:a.map(e=>(0,F.jsxs)(`option`,{value:e.id,children:[e.name,e.configured?` (already configured)`:``]},e.id))})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`label`,{htmlFor:`onboarding-name`,className:zv,children:`Name`}),(0,F.jsx)(`input`,{id:`onboarding-name`,value:f,onChange:e=>p(e.target.value),placeholder:`corp`,className:`${Rv} mb-3`}),(0,F.jsx)(`label`,{htmlFor:`onboarding-url`,className:zv,children:`Base URL`}),(0,F.jsx)(`input`,{id:`onboarding-url`,value:m,onChange:e=>h(e.target.value),placeholder:`https://llm.corp.example/v1`,className:`${Rv} mb-3`}),(0,F.jsx)(`label`,{htmlFor:`onboarding-model`,className:zv,children:`Model id`}),(0,F.jsx)(`input`,{id:`onboarding-model`,value:g,onChange:e=>_(e.target.value),placeholder:`gpt-oss-120b`,className:`${Rv} mb-3`})]}),(0,F.jsx)(`label`,{htmlFor:`onboarding-key`,className:zv,children:`API key`}),(0,F.jsx)(`input`,{id:`onboarding-key`,type:`password`,autoComplete:`off`,value:u,onChange:e=>d(e.target.value),placeholder:`sk-…`,className:Rv}),o===`custom`&&(0,F.jsxs)(`fieldset`,{className:`mt-4 rounded-lg border border-zinc-200 p-3 dark:border-zinc-800`,children:[(0,F.jsx)(`legend`,{className:`px-1 text-xs text-zinc-500 dark:text-zinc-400`,children:`Compatibility`}),(0,F.jsxs)(`label`,{className:`flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:y,onChange:e=>b(e.target.checked),className:`mt-0.5`}),(0,F.jsxs)(`span`,{children:[`Server understands the `,(0,F.jsx)(`code`,{children:`developer`}),` role. Uncheck for vLLM, SGLang and most corporate gateways — the system prompt is then sent as a `,(0,F.jsx)(`code`,{children:`system`}),` message.`]})]}),(0,F.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked),className:`mt-0.5`}),(0,F.jsxs)(`span`,{children:[`Server accepts `,(0,F.jsx)(`code`,{children:`reasoning_effort`}),`. Uncheck if it rejects unknown fields.`]})]})]}),(0,F.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,F.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,F.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,F.jsx)(`code`,{children:`pi-outpost login`}),`.`]})]})})}var Vv={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 Hv(e,t){return t?Object.keys(t).filter(t=>t.startsWith(`${e}/`)).length:0}function Uv(e){return e===`directory`||e===`symlink-directory`}function Wv(e,t){return t===void 0?!1:t===null?!0:t===``?!1:e!==t&&!e.startsWith(`${t}/`)}function Gv({path:e,depth:t,...n}){let r=n.tree[e];return r===void 0?null:r===`loading`?(0,F.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,F.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,F.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:`empty`}):(0,F.jsx)(F.Fragment,{children:r.map(r=>(0,F.jsx)(Kv,{parentPath:e,entry:r,depth:t,...n},r.name))})}function Kv({parentPath:e,entry:t,depth:n,...r}){let[i,a]=(0,v.useState)(!1),o=e?`${e}/${t.name}`:t.name,s=Wv(o,r.writableRoot);if(Uv(t.type))return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>{let e=!i;a(e),e&&r.tree[o]===void 0&&r.onExpand(o)},style:{paddingLeft:n*12},className:`flex w-full items-center gap-1 rounded py-0.5 text-left hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:[(0,F.jsx)(`span`,{className:`w-3 shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:i?`▾`:`▸`}),(0,F.jsx)(`span`,{className:`truncate ${s?`text-zinc-400 dark:text-zinc-600`:`text-zinc-700 dark:text-zinc-300`}`,children:t.name}),!i&&Hv(o,r.gitFiles)>0&&(0,F.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:`${Hv(o,r.gitFiles)} changed file(s) inside`,children:Hv(o,r.gitFiles)})]}),i&&(0,F.jsx)(Gv,{path:o,depth:n+1,...r})]});let c=o===r.openFilePath,l=r.gitFiles?.[o],u=r.attachedPaths?.includes(o)??!1;return(0,F.jsxs)(`div`,{className:`group flex w-full items-center rounded hover:bg-zinc-100 dark:hover:bg-zinc-800 ${c?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>r.onSelectFile(o),style:{paddingLeft:n*12+16},className:`flex min-w-0 flex-1 items-center py-0.5 text-left`,children:(0,F.jsx)(`span`,{className:`truncate ${s?`text-zinc-400 dark:text-zinc-600`:`text-zinc-600 dark:text-zinc-400`}`,children:t.name})}),r.onToggleAttachPath&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>r.onToggleAttachPath?.(o),title:u?`Remove this file from the prompt`:`Reference this file in the prompt`,"aria-label":`${u?`Remove`:`Reference`} ${t.name} in the prompt`,"aria-pressed":u,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 ${u?`font-bold text-blue-600 dark:text-blue-400`:`text-zinc-400 dark:text-zinc-600 [@media(hover:hover)]:opacity-0`}`,children:`@`}),l&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>(r.onSelectDiff??r.onSelectFile)(o),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 ${Vv[l].className}`,children:Vv[l].label})]})}function qv(e){return(0,F.jsx)(`div`,{className:`text-sm`,children:(0,F.jsx)(Gv,{path:``,depth:0,...e})})}function Jv({tree:e,openFile:t,writableRoot:n,gitFiles:r,attachedPaths:i,onExpand:a,onSelectFile:o,onSelectDiff:s,onToggleAttachPath:c}){return(0,v.useEffect)(()=>{e[``]===void 0&&a(``)},[]),(0,F.jsxs)(`aside`,{className:`flex w-72 shrink-0 flex-col border-r border-zinc-200 dark:border-zinc-800`,children:[(0,F.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,F.jsx)(`div`,{className:`flex-1 overflow-auto p-2`,children:(0,F.jsx)(qv,{tree:e,openFilePath:t?.path,writableRoot:n,gitFiles:r,attachedPaths:i,onExpand:a,onSelectFile:o,onSelectDiff:s,onToggleAttachPath:c})})]})}function Yv({title:e,onSubmit:t}){let[n,r]=(0,v.useState)(``);return(0,F.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,F.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,F.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),(0,F.jsx)(`h1`,{className:`mb-4 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`This server requires an access token.`}),(0,F.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,F.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,F.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,F.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,F.jsx)(`code`,{children:`?token=…`})]})]})})}function Xv(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 Zv(e){if(e.toolName!==`edit`||e.args===null||typeof e.args!=`object`)return null;let t=e.args.edits;if(!Array.isArray(t))return null;let n=t.filter(e=>typeof e==`object`&&!!e&&typeof e.oldText==`string`&&typeof e.newText==`string`);return n.length>0?n:null}function Qv(e){if(e.toolName!==`write`||e.args===null||typeof e.args!=`object`)return null;let t=e.args.content;return typeof t==`string`?t:null}function $v({item:e}){let t=Zv(e),n=Qv(e),r=t!==null||n!==null,[i,a]=(0,v.useState)(r),o=Xv(e.args);return(0,F.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,F.jsxs)(`button`,{type:`button`,onClick:()=>a(!i),className:`flex w-full items-center gap-2 px-3 py-2 text-left`,children:[(0,F.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`}`}),(0,F.jsx)(`span`,{className:`font-mono font-medium text-zinc-700 dark:text-zinc-300`,children:e.toolName}),o&&(0,F.jsx)(`span`,{className:`truncate font-mono text-xs text-zinc-500`,children:o}),(0,F.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-600`,children:i?`▾`:`▸`})]}),i&&(0,F.jsxs)(`div`,{className:`border-t border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[t!==null&&(0,F.jsx)(`div`,{className:`mb-2 flex flex-col gap-2`,children:t.map((e,t)=>(0,F.jsx)(rv,{lines:q_(e.oldText,e.newText)},t))}),n!==null&&(0,F.jsx)(`div`,{className:`mb-2`,children:(0,F.jsx)(iv,{lines:n.split(`
311
+ `).map(e=>({type:`add`,text:e}))})}),r||o===``||(0,F.jsx)(`pre`,{className:`mb-2 overflow-x-auto font-mono text-xs text-zinc-500 dark:text-zinc-400`,children:JSON.stringify(e.args,null,2)}),(0,F.jsx)(`pre`,{className:`max-h-96 overflow-auto whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,children:e.output||(e.running?`running…`:`(no output)`)})]})]})}function ey({item:e,canEdit:t,onEdit:n}){let[r,i]=(0,v.useState)(null),a=(0,v.useRef)(null),o=t&&e.entryId!==void 0,s=r!==null;(0,v.useEffect)(()=>{s&&a.current?.focus()},[s]),(0,v.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,F.jsxs)(`div`,{className:`group ml-auto flex max-w-[85%] items-start gap-1.5`,children:[o&&!s&&(0,F.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,F.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,F.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:e.images.map((e,t)=>(0,F.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:``,className:`max-h-48 max-w-full rounded-lg object-contain`},t))}),s?(0,F.jsxs)(`div`,{children:[(0,F.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(`
312
+ `).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,F.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-end gap-2 text-xs`,children:[(0,F.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,F.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,F.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,F.jsx)(`div`,{className:`whitespace-pre-wrap`,children:e.text})]})]})}var ty=`pi-outpost:token`;function ny(){let e=null;try{let t=new URL(window.location.href);return e=t.searchParams.get(`token`),e&&(localStorage.setItem(ty,e),t.searchParams.delete(`token`),window.history.replaceState(null,``,`${t.pathname}${t.search}${t.hash}`)),localStorage.getItem(ty)}catch{return e}}function ry(){try{return localStorage.getItem(ty)}catch{return null}}function iy(e){try{localStorage.setItem(ty,e)}catch{}}var ay={connected:!1,authRequired:!1,branding:{},sessionId:``,model:``,thinkingLevel:`off`,modelSupportsReasoning:!1,models:[],commands:[],sessions:null,sessionSearch:null,tree:null,isStreaming:!1,items:[],queue:{steering:[],followUp:[]},errors:[],contextUsage:null,isCompacting:!1,dialogQueue:[],notifications:[],statuses:{},widgets:{},editorPrefill:null,fileTree:{},openFile:null,fileSearch:null,gitAvailable:!1,credentials:null,gitStatus:null,gitDiff:null,gitLog:null,gitShow:null};function oy(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 sy(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 cy(e,t){if(t.type!==`hello`&&t.type!==`session_replaced`)return e;let n=t.models.find(e=>`${e.provider}/${e.id}`===t.model);return{...e,connected:!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,queue:{steering:[],followUp:[]},errors:[],contextUsage:t.contextUsage??null,isCompacting:!1,dialogQueue:[],notifications:[],statuses:{},widgets:{},extensionTitle:void 0,editorPrefill:null,tree:null,writableRoot:t.writableRoot,gitAvailable:t.gitAvailable===!0,credentials:t.credentials??null}}function ly(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_loaded`)return{...e,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`)return{...e,fileTree:{...e.fileTree,[t.path]:`loading`}};if(t.type===`file_read_started`)return{...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===`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};let n=t.message;switch(n.type){case`hello`:case`session_replaced`:return cy(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`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:oy(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:oy(e.items,()=>n.item)};case`custom_message`:return{...e,items:[...e.items,n.item]};case`tool_start`:return{...e,items:sy(e.items,n.toolCallId,n.toolName,{toolName:n.toolName,args:n.args,running:!0})};case`tool_update`:return{...e,items:sy(e.items,n.toolCallId,`tool`,{output:n.text})};case`tool_end`:return{...e,items:sy(e.items,n.toolCallId,`tool`,{output:n.text,isError:n.isError,running:!1})};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]};case`directory_listing`:return{...e,fileTree:{...e.fileTree,[n.path]:n.entries}};case`file_content`:return e.openFile?.status!==`loading`||e.openFile.requestId!==n.requestId?e:{...e,openFile:{status:`loaded`,path:n.path,content:n.content,size:n.size,mtimeMs:n.mtimeMs}};case`file_written`:{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_browser_error`:if(n.requestId.startsWith(`dir:`))return{...e,fileTree:{...e.fileTree,[n.path]:{error: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 e.openFile?.status!==`loading`||e.openFile.requestId!==n.requestId?e:{...e,openFile:{status:`error`,path:n.path,message:n.message}};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_error`:return n.requestId.startsWith(`gitdiff:`)?{...e,gitDiff:e.openFile?{path:e.openFile.path,error:n.message}:null}:{...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 uy(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 dy=4401;function fy(e=``,t,n=!1){let[r,i]=(0,v.useReducer)(ly,ay),a=(0,v.useRef)(null),[o,s]=(0,v.useState)(0),c=(0,v.useRef)(null);o===0&&c.current===null&&(c.current=t??(n?ry():ny()));let l=(0,v.useRef)(r.fileTree),u=(0,v.useRef)(r.openFile);(0,v.useEffect)(()=>{l.current=r.fileTree},[r.fileTree]),(0,v.useEffect)(()=>{u.current=r.openFile},[r.openFile]);let d=(0,v.useRef)(null);(0,v.useEffect)(()=>{d.current=r.gitDiff?.path??null},[r.gitDiff]);let f=(0,v.useCallback)(e=>{let t=a.current;t&&t.readyState===WebSocket.OPEN&&t.send(JSON.stringify(e))},[]),p=(0,v.useRef)(!1),m=(0,v.useRef)(!1),h=(0,v.useRef)(!1),g=(0,v.useCallback)(()=>{if(p.current){if(m.current){h.current=!0;return}m.current=!0,f({type:`git_status`,requestId:`git:${crypto.randomUUID()}`})}},[f]),_=(0,v.useCallback)(()=>{m.current=!1,h.current&&(h.current=!1,g())},[g]);return(0,v.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&&e&&i({type:`branding_loaded`,branding:e})}).catch(()=>{}),()=>{t=!0}},[e,o]),(0,v.useEffect)(()=>{let t,n=!1;function r(){let o=new WebSocket(uy(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_changed`){let e=t.path.lastIndexOf(`/`),n=e<0?``:t.path.slice(0,e);l.current[n]!==void 0&&(i({type:`dir_list_started`,path:n}),f({type:`list_directory`,path:n,requestId:`dir:${crypto.randomUUID()}`}));let r=u.current;if(r?.status===`loaded`&&r.path===t.path){let e=`file:${crypto.randomUUID()}`;i({type:`file_read_started`,path:t.path,requestId:e}),f({type:`read_file`,path:t.path,requestId:e})}d.current===t.path&&f({type:`git_diff`,path:t.path,requestId:`gitdiff:${crypto.randomUUID()}`}),g();return}(t.type===`hello`||t.type===`session_replaced`)&&(p.current=t.gitAvailable===!0,t.type===`hello`&&g()),t.type===`agent_end`&&g(),(t.type===`git_status`||t.type===`git_error`&&t.requestId.startsWith(`git:`))&&_(),i({type:`server`,message:t})},o.onclose=e=>{if(a.current===o){if(m.current=!1,h.current=!1,e.code===dy){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()}},[f,e,g,_,o]),{state:r,authToken:c.current,submitToken:e=>{iy(e),c.current=e,i({type:`auth_retrying`}),s(e=>e+1)},prompt:(e,t)=>f({type:`prompt`,text:e,...t?.length?{images:t}:{}}),abort:()=>f({type:`abort`}),setModel:(e,t)=>f({type:`set_model`,provider:e,id:t}),setThinking:e=>f({type:`set_thinking`,level:e}),newSession:()=>f({type:`new_session`}),switchSession:e=>f({type:`switch_session`,path:e}),deleteSession:e=>f({type:`delete_session`,path:e}),listSessions:()=>f({type:`list_sessions`}),renameSession:(e,t)=>f({type:`rename_session`,path:e,name:t}),searchSessions:e=>{let t=`sessions:${crypto.randomUUID()}`;i({type:`session_search_started`,query:e,requestId:t}),f({type:`search_sessions`,query:e,requestId:t})},clearSessionSearch:()=>i({type:`session_search_cleared`}),listTree:()=>f({type:`list_tree`}),navigateTree:e=>f({type:`navigate_tree`,entryId:e}),forkSession:e=>f({type:`fork_session`,entryId:e}),editPrompt:(e,t,n)=>f({type:`edit_prompt`,entryId:e,text:t,...n?.length?{images:n}:{}}),compact:()=>f({type:`compact`}),respondToDialog:e=>{f({type:`extension_ui_response`,...e}),i({type:`dialog_answered`})},dismissNotification:e=>i({type:`dismiss_notification`,id:e}),listDirectory:e=>{i({type:`dir_list_started`,path:e}),f({type:`list_directory`,path:e,requestId:`dir:${crypto.randomUUID()}`})},readFile:e=>{let t=`file:${crypto.randomUUID()}`;i({type:`file_read_started`,path:e,requestId:t}),f({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}),f({type:`write_file`,path:e,content:t,expectedMtimeMs:n,...r?{force:r}:{},requestId:a})},searchFiles:e=>{let t=`search:${crypto.randomUUID()}`;i({type:`file_search_started`,query:e,requestId:t}),f({type:`search_files`,query:e,requestId:t})},clearFileSearch:()=>i({type:`file_search_cleared`}),fetchGitStatus:g,fetchGitDiff:e=>{let t=`gitdiff:${crypto.randomUUID()}`;i({type:`git_diff_started`,path:e,requestId:t}),f({type:`git_diff`,path:e,requestId:t})},clearGitDiff:()=>i({type:`git_diff_cleared`}),fetchGitLog:e=>f({type:`git_log`,...e?{limit:e}:{},requestId:`gitlog:${crypto.randomUUID()}`}),fetchGitShow:e=>f({type:`git_show`,sha:e,requestId:`gitshow:${crypto.randomUUID()}`}),clearGitShow:()=>i({type:`git_show_cleared`}),setCredential:(e,t)=>f({type:`set_credential`,provider:e,apiKey:t}),declareProvider:e=>f({type:`declare_provider`,...e})}}var py=`pi-outpost:theme`;function my(){return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function hy(){let e=localStorage.getItem(py);return e===`light`||e===`dark`||e===`system`?e:null}function gy(e){localStorage.setItem(py,e)}function _y(e,t,n=document.documentElement){let r=t?hy():null,[i,a]=(0,v.useState)(r??e),o=(0,v.useRef)(r!==null);(0,v.useEffect)(()=>{o.current||a(e)},[e]),(0,v.useEffect)(()=>{function e(e){let t=e.data;t?.type===`pi-outpost:set-theme`&&(t.theme!==`light`&&t.theme!==`dark`&&t.theme!==`system`||(o.current=!0,a(t.theme)))}return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[]);let[s,c]=(0,v.useState)(my);(0,v.useEffect)(()=>{let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>c(e.matches?`dark`:`light`);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let l=i===`system`?s:i;(0,v.useLayoutEffect)(()=>{n.dataset.theme=l},[n,l]);let u=(0,v.useCallback)(e=>{o.current=!0,a(e),t&&gy(e)},[t]);return{theme:l,toggle:(0,v.useCallback)(()=>u(l===`dark`?`light`:`dark`),[l,u]),setTheme:u}}var vy=(0,v.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:d,setModel:f,setThinking:p,newSession:m,switchSession:h,deleteSession:g,listSessions:_,renameSession:y,searchSessions:b,clearSessionSearch:x,listTree:S,navigateTree:C,forkSession:w,editPrompt:T,compact:E,respondToDialog:ee,dismissNotification:D,listDirectory:O,readFile:te,writeFile:ne,closeFilePreview:re,searchFiles:ie,clearFileSearch:ae,fetchGitDiff:k,clearGitDiff:A,fetchGitLog:j,fetchGitShow:M,clearGitShow:oe,setCredential:se,declareProvider:ce}=fy(e,r,a),[le,ue]=(0,v.useState)(!1),[de,fe]=(0,v.useState)([]),[pe,me]=(0,v.useState)([]),[he,ge]=(0,v.useState)(null),[_e,ve]=(0,v.useState)(null),[ye,be]=(0,v.useState)(!1),xe=(0,v.useRef)([]),Se=(0,v.useRef)(null),Ce=(0,v.useRef)(null),[we,Te]=(0,v.useState)(!1),[Ee,De]=(0,v.useState)(()=>{try{return localStorage.getItem(`pi-outpost:hide-tools`)===`1`}catch{return!1}});function Oe(){De(e=>{try{localStorage.setItem(`pi-outpost:hide-tools`,e?`0`:`1`)}catch{}return!e})}let[ke,Ae]=(0,v.useState)([]),[je,Me]=(0,v.useState)(0);async function Ne(e){let{attachments:t,errors:n}=await w_(e);t.length>0&&fe(e=>[...e,...t]),Ae(n)}(0,v.useEffect)(()=>{xe.current=de},[de]),(0,v.useEffect)(()=>{let t=s.openFile;if(!t)return;let n=t.path,r=t.status===`loaded`;if(Se.current!==n&&(Se.current=n,Ce.current=null,fe(e=>e.filter(e=>e.source!==`preview`)),ge(null),ve(null)),Ce.current===n)return;let i=!1;async function a(){let t=a_(n)?_e===n?await k_(n,o_(e,n,c)):null:r?T_(n):null;if(!(i||t===null||Se.current!==n||Ce.current===n)){if(typeof t==`string`){ge(t);return}ge(null),fe(e=>M_(e,t))}}return a(),()=>{i=!0}},[s.openFile,e,c,_e]);function Pe(){Se.current=null,Ce.current=null,re()}let Fe=(0,v.useMemo)(()=>[...de.filter(e=>e.kind===`path`).map(e=>e.data),...pe],[de,pe]);function Ie(e){let t=xe.current.findIndex(t=>t.kind===`path`&&t.data===e);t>=0?Le(t):pe.includes(e)||fe(t=>j_(t,e))}function Le(e){let t=xe.current[e];t?.source===`preview`&&(Ce.current=t.previewPath??Se.current,ge(null)),fe(t=>N_(t,e))}function Re(e,t){u(e,t),fe([]),Ae([]),ge(null),ye||Pe()}function ze(e){e.preventDefault(),Me(0),e.dataTransfer.files.length>0&&Ne(Array.from(e.dataTransfer.files))}let{theme:Be,toggle:Ve,setTheme:He}=_y(n??s.branding.defaultTheme??`system`,s.branding.allowThemeToggle!==!1,o);(0,v.useImperativeHandle)(i,()=>({setTheme:He}),[He]);let Ue=(0,v.useRef)(null),We=(0,v.useRef)(null),Ge=(0,v.useRef)(!0);function Ke(){let e=Ue.current;e&&(Ge.current=e.scrollHeight-e.scrollTop-e.clientHeight<120)}return(0,v.useEffect)(()=>{Ge.current&&We.current?.scrollIntoView({behavior:`smooth`})},[s.items]),(0,v.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]),s.authRequired?(0,F.jsx)(c_.Provider,{value:Be,children:(0,F.jsx)(Yv,{title:s.branding.title,onSubmit:l})}):s.credentials&&!s.credentials.usableModel?(0,F.jsx)(c_.Provider,{value:Be,children:(0,F.jsx)(Bv,{title:s.branding.title,credentials:s.credentials,onSetCredential:se,onDeclareProvider:ce,errors:s.errors})}):(0,F.jsxs)(c_.Provider,{value:Be,children:[(0,F.jsxs)(`div`,{className:`relative flex h-full`,onDragEnter:e=>{e.dataTransfer.types.includes(`Files`)&&Me(e=>e+1)},onDragLeave:()=>Me(e=>Math.max(0,e-1)),onDragOver:e=>e.preventDefault(),onDrop:ze,children:[je>0&&(0,F.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,F.jsx)(`p`,{className:`text-lg font-medium text-zinc-700 dark:text-zinc-200`,children:`Drop files to attach (images & text)`})}),le&&(0,F.jsx)(Jv,{tree:s.fileTree,openFile:s.openFile,writableRoot:s.writableRoot,gitFiles:s.gitStatus?.files,attachedPaths:Fe,onExpand:O,onSelectFile:e=>{Te(!1),te(e)},onSelectDiff:e=>{Te(!0),te(e)},onToggleAttachPath:Ie}),(0,F.jsxs)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,children:[(0,F.jsx)(Nv,{title:s.branding.title,sessions:s.sessions,sessionSearch:s.sessionSearch,sessionId:s.sessionId,tree:s.tree,isStreaming:s.isStreaming,connected:s.connected,theme:Be,showThemeToggle:s.branding.allowThemeToggle!==!1,statuses:s.statuses,sidebarOpen:le,hideTools:Ee,onToggleSidebar:()=>ue(!le),onToggleHideTools:Oe,onToggleTheme:Ve,onNewSession:m,onSwitchSession:h,onDeleteSession:g,onListSessions:_,onRenameSession:y,onSearchSessions:b,onClearSessionSearch:x,onListTree:S,onNavigateTree:C,onForkSession:w,gitAvailable:s.gitAvailable,gitStatus:s.gitStatus,gitLog:s.gitLog,onFetchGitLog:j,onShowCommit:M}),(0,F.jsxs)(`div`,{className:`relative z-0 flex min-h-0 flex-1 flex-col`,children:[s.openFile&&(0,F.jsx)(sv,{file:s.openFile,writableRoot:s.writableRoot,isStreaming:s.isStreaming,onDirtyChange:be,gitState:s.gitStatus?.files[s.openFile.path],initialShowGitDiff:we,gitDiff:s.gitDiff,onFetchGitDiff:k,onClearGitDiff:A,onClose:Pe,onReload:te,onSave:ne,serverUrl:e,token:c,onImageLoad:ve},s.openFile.path),s.gitShow&&(0,F.jsx)(lv,{show:s.gitShow,onClose:oe}),(0,F.jsx)(`main`,{ref:Ue,onScroll:Ke,className:`flex-1 overflow-y-auto`,children:(0,F.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-3 px-4 py-6`,children:[s.items.length===0&&(0,F.jsxs)(`div`,{className:`mt-24 text-center text-zinc-500 dark:text-zinc-600`,children:[(0,F.jsx)(`div`,{className:`mb-2 text-4xl`,children:s.branding.title??`π`}),(0,F.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}`;return t.kind===`user`?(0,F.jsx)(ey,{item:t,canEdit:!s.isStreaming&&s.connected,onEdit:T},r):t.kind===`tool`?Ee?null:(0,F.jsx)($v,{item:t},t.toolCallId?`${s.sessionId}:${t.toolCallId}`:r):t.kind===`custom`?(0,F.jsx)(R_,{item:t},r):t.blocks.length===0&&!t.errorMessage?null:(0,F.jsx)(x_,{item:t,serverUrl:e,token:c,onOpenFile:e=>{Te(!1),te(e)}},r)}),(s.queue.steering.length>0||s.queue.followUp.length>0)&&(0,F.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,F.jsxs)(`div`,{children:[`⏩ steering: `,e]},`s${t}`)),s.queue.followUp.map((e,t)=>(0,F.jsxs)(`div`,{children:[`⏭ follow-up: `,e]},`f${t}`))]}),ke.map((e,t)=>(0,F.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}`)),he&&(0,F.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:he}),s.errors.map((e,t)=>(0,F.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,F.jsx)(`div`,{ref:We})]})})]}),(0,F.jsx)(`footer`,{className:`border-t border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:(0,F.jsxs)(`div`,{className:`mx-auto max-w-3xl`,children:[(0,F.jsx)(K_,{widgets:s.widgets,placement:`aboveEditor`}),(0,F.jsx)(L_,{isStreaming:s.isStreaming,connected:s.connected,commands:s.commands,fileSearch:s.fileSearch,prefill:s.editorPrefill,attachments:de,onAttach:e=>void Ne(e),onMentionPaths:me,onRemoveAttachment:Le,onSend:Re,onAbort:d,onSearchFiles:ie,onClearFileSearch:ae}),(0,F.jsx)(K_,{widgets:s.widgets,placement:`belowEditor`}),(0,F.jsx)(Lv,{model:s.model,models:s.models,thinkingLevel:s.thinkingLevel,modelSupportsReasoning:s.modelSupportsReasoning,isStreaming:s.isStreaming,contextUsage:s.contextUsage,isCompacting:s.isCompacting,onSetModel:f,onSetThinking:p,onCompact:E})]})})]})]}),s.dialogQueue[0]&&(0,F.jsx)(H_,{request:s.dialogQueue[0],onRespond:ee}),(0,F.jsx)(G_,{notifications:s.notifications,onDismiss:D})]})});(0,y.createRoot)(document.getElementById(`root`)).render((0,F.jsx)(v.StrictMode,{children:(0,F.jsx)(vy,{})}));export{l as i,ks as n,o as r,p_ as t};