pi-outpost 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/dist/pi-outpost.mjs +88 -4
  2. package/dist/pi-outpost.sea.mjs +88 -4
  3. package/dist/sea-prep.blob +0 -0
  4. package/dist/web/assets/{abnfDiagram-VRR7QNED-Ddbaevlx.js → abnfDiagram-VRR7QNED-H5_VO-B1.js} +1 -1
  5. package/dist/web/assets/{arc-DKRCl6TA.js → arc-CE2zETyi.js} +1 -1
  6. package/dist/web/assets/architecture-TIHT7OUA-quq76HPk.js +1 -0
  7. package/dist/web/assets/{architectureDiagram-ZJ3FMSHR-9NxjIUZS.js → architectureDiagram-ZJ3FMSHR-CIvYQchB.js} +1 -1
  8. package/dist/web/assets/{blockDiagram-677ZJIJ3-RZPAuAVe.js → blockDiagram-677ZJIJ3-DGQEZrPB.js} +1 -1
  9. package/dist/web/assets/{c4Diagram-LMCZKHZV-CtnM3Ckx.js → c4Diagram-LMCZKHZV-BirInSYC.js} +1 -1
  10. package/dist/web/assets/channel-CZQNpXwJ.js +1 -0
  11. package/dist/web/assets/{chunk-32BRIVSS-QnUqBdzD.js → chunk-32BRIVSS-B7fJk0ll.js} +1 -1
  12. package/dist/web/assets/{chunk-52WLFC77-EpnBnafN.js → chunk-52WLFC77-C56wZyRg.js} +1 -1
  13. package/dist/web/assets/{chunk-C7G6YPKG--UKrostC.js → chunk-C7G6YPKG-BVEnGhWm.js} +1 -1
  14. package/dist/web/assets/{chunk-EX3LRPZG-Ce4UE9ek.js → chunk-EX3LRPZG-qrTscY2a.js} +1 -1
  15. package/dist/web/assets/{chunk-FWX5IMBZ-CpoeAqxN.js → chunk-FWX5IMBZ-DE1AOCYK.js} +2 -2
  16. package/dist/web/assets/{chunk-HOUHSVGY-C_0OHgvt.js → chunk-HOUHSVGY-ByqVYtdv.js} +1 -1
  17. package/dist/web/assets/{chunk-ICXQ74PX-BuQxyBm4.js → chunk-ICXQ74PX-DXqI_eYD.js} +1 -1
  18. package/dist/web/assets/{chunk-MOJQB5TN-nQbQpJtl.js → chunk-MOJQB5TN-CtF6fAD2.js} +1 -1
  19. package/dist/web/assets/{chunk-OGEWGWER-qmp8nYAi.js → chunk-OGEWGWER-BN9LPPms.js} +1 -1
  20. package/dist/web/assets/{chunk-PUDLZKDR-CfrXFVaP.js → chunk-PUDLZKDR-W3AI4jJR.js} +1 -1
  21. package/dist/web/assets/{chunk-Q4XR5HBZ-B_ZVMZ1_.js → chunk-Q4XR5HBZ-DyN60MoF.js} +1 -1
  22. package/dist/web/assets/{chunk-RYQCIY6F-BNLDnl1E.js → chunk-RYQCIY6F-BasDWW7n.js} +1 -1
  23. package/dist/web/assets/{chunk-V7JOEXUC-CCJ4gaG4.js → chunk-V7JOEXUC-o82vAXi1.js} +1 -1
  24. package/dist/web/assets/{chunk-VAUOI2AC-DH_aJUsJ.js → chunk-VAUOI2AC-C9EyY67a.js} +1 -1
  25. package/dist/web/assets/{chunk-VR4S4FIN-BvhW0AYV.js → chunk-VR4S4FIN-CeQJxF3W.js} +1 -1
  26. package/dist/web/assets/{chunk-WYO6CB5R-BnZu-GH5.js → chunk-WYO6CB5R-krESB1wz.js} +3 -3
  27. package/dist/web/assets/{chunk-XXDRQBXY-CIhKgouH.js → chunk-XXDRQBXY-DwNOw26j.js} +1 -1
  28. package/dist/web/assets/{chunk-ZGVPDNZ5-CG5sR8Hi.js → chunk-ZGVPDNZ5-Ch60IWeh.js} +1 -1
  29. package/dist/web/assets/classDiagram-OUVF2IWQ-cofE0NaO.js +1 -0
  30. package/dist/web/assets/classDiagram-v2-EOCWNBFH-cofE0NaO.js +1 -0
  31. package/dist/web/assets/{core-DY7rIyDC.js → core-BYdjv-3f.js} +1 -1
  32. package/dist/web/assets/{cose-bilkent-JH36ORCC-Dr8iIC07.js → cose-bilkent-JH36ORCC-7oO-5ii0.js} +1 -1
  33. package/dist/web/assets/{cynefin-VYW2F7L2-Csc5Skqi.js → cynefin-VYW2F7L2-BXr0328D.js} +1 -1
  34. package/dist/web/assets/{cynefinDiagram-TSTJHNR4-sGiyDLSd.js → cynefinDiagram-TSTJHNR4-BjcrCkzf.js} +1 -1
  35. package/dist/web/assets/{dagre-VKFMJZFB-C5vxZhtT.js → dagre-VKFMJZFB-C6__cGMT.js} +1 -1
  36. package/dist/web/assets/{diagram-FQU43EPY-8B2nlFf4.js → diagram-FQU43EPY-Cv5jVU9J.js} +1 -1
  37. package/dist/web/assets/{diagram-G47NLZAW-C6vzPEqq.js → diagram-G47NLZAW-Cr471EU0.js} +1 -1
  38. package/dist/web/assets/{diagram-NH7WQ7WH-Cug03yLJ.js → diagram-NH7WQ7WH-goB_dq72.js} +1 -1
  39. package/dist/web/assets/{diagram-OA4YK3LP-CucHVkAE.js → diagram-OA4YK3LP-DmY1Aze_.js} +1 -1
  40. package/dist/web/assets/{diagram-WEI45ONY-CrS4YdfL.js → diagram-WEI45ONY-WkHev95e.js} +1 -1
  41. package/dist/web/assets/{dist-4WHbW7kW.js → dist-eoi0_oI4.js} +1 -1
  42. package/dist/web/assets/{ebnfDiagram-CCIWWBDH-CXGiUUds.js → ebnfDiagram-CCIWWBDH-9LnP4grp.js} +1 -1
  43. package/dist/web/assets/{erDiagram-Q63AITRT-By3BwsLJ.js → erDiagram-Q63AITRT-DLfvk9F1.js} +1 -1
  44. package/dist/web/assets/eventmodeling-45OFAUF4-B5yLU1sh.js +1 -0
  45. package/dist/web/assets/flowDiagram-23GEKE2U-YSOb8q4v.js +1 -0
  46. package/dist/web/assets/{ganttDiagram-NO4QXBWP-7cpdUdRJ.js → ganttDiagram-NO4QXBWP-BmevG3Zb.js} +1 -1
  47. package/dist/web/assets/{gitGraph-TEB2WS4Q-8uES_n1N.js → gitGraph-TEB2WS4Q-DJhMk0an.js} +1 -1
  48. package/dist/web/assets/{gitGraphDiagram-IHSO6WYX-5Ob04v9V.js → gitGraphDiagram-IHSO6WYX-m9L6aHPB.js} +1 -1
  49. package/dist/web/assets/index-B1kaPMNw.css +2 -0
  50. package/dist/web/assets/{index-DpbRLjEE.js → index-CATcFyvk.js} +7 -7
  51. package/dist/web/assets/{info-DKCQHKI2-CwnMgns7.js → info-DKCQHKI2-B4Vc-IRj.js} +1 -1
  52. package/dist/web/assets/{infoDiagram-FWYZ7A6U-ClO-D-F6.js → infoDiagram-FWYZ7A6U-Ba1fhnL8.js} +1 -1
  53. package/dist/web/assets/{ishikawaDiagram-FXEZZL3T-D-Ze2Ql8.js → ishikawaDiagram-FXEZZL3T-ChAwvE3-.js} +1 -1
  54. package/dist/web/assets/{journeyDiagram-5HDEW3XC-Tc3Wdzm9.js → journeyDiagram-5HDEW3XC-BirgNixk.js} +1 -1
  55. package/dist/web/assets/{kanban-definition-HUTT4EX6-CcVQNWZZ.js → kanban-definition-HUTT4EX6-Chp-drog.js} +1 -1
  56. package/dist/web/assets/{line-LCszX-93.js → line-D_9HoxN3.js} +1 -1
  57. package/dist/web/assets/{linear-D4uAB447.js → linear-DgrpbYUZ.js} +1 -1
  58. package/dist/web/assets/{mermaid-parser.core-DEPnbzQd.js → mermaid-parser.core-BqDBKvZM.js} +3 -3
  59. package/dist/web/assets/{mermaid.core-BwWIg80u.js → mermaid.core-BhqnioBn.js} +3 -3
  60. package/dist/web/assets/{mindmap-definition-LN4V7U3C-B0t31b8v.js → mindmap-definition-LN4V7U3C-JRUH2JOn.js} +1 -1
  61. package/dist/web/assets/{packet-7NZHBO7P-Cq4ml33w.js → packet-7NZHBO7P-BgUQPLIU.js} +1 -1
  62. package/dist/web/assets/{pegDiagram-2B236MQR-GehivSub.js → pegDiagram-2B236MQR-VvS6nn8t.js} +1 -1
  63. package/dist/web/assets/{pie-RZYD4A2V-hKQqRwR1.js → pie-RZYD4A2V-B2jlWZgR.js} +1 -1
  64. package/dist/web/assets/{pieDiagram-ENE6RG2P-Di20TWWF.js → pieDiagram-ENE6RG2P-BKW9rLOB.js} +1 -1
  65. package/dist/web/assets/{quadrantDiagram-ABIIQ3AL-BS2DM0o1.js → quadrantDiagram-ABIIQ3AL-VnibnYiD.js} +1 -1
  66. package/dist/web/assets/{radar-I7S5WNFK-DIelC7WS.js → radar-I7S5WNFK-DMqKgGE4.js} +1 -1
  67. package/dist/web/assets/{railroad-3IZDKUUU-BGqOpgb2.js → railroad-3IZDKUUU-CQISkGus.js} +1 -1
  68. package/dist/web/assets/railroad-abnf-AHOZXSZD-Cqb4QybP.js +1 -0
  69. package/dist/web/assets/railroad-ebnf-EBAXGLYW-B2HJhkLZ.js +1 -0
  70. package/dist/web/assets/railroad-peg-LSFZ7HO6-BAkQmUhL.js +1 -0
  71. package/dist/web/assets/{railroadDiagram-RFXS5EU6-JnUSd2SZ.js → railroadDiagram-RFXS5EU6-B2mmn-YE.js} +1 -1
  72. package/dist/web/assets/{requirementDiagram-TGXJPOKE-BOl8gS8C.js → requirementDiagram-TGXJPOKE-Dr95ZcIq.js} +1 -1
  73. package/dist/web/assets/{sankeyDiagram-HTMAVEWB-DcywXXIN.js → sankeyDiagram-HTMAVEWB-BdQaFrYL.js} +1 -1
  74. package/dist/web/assets/{sequenceDiagram-DBY2YBRQ-ONvF5cHm.js → sequenceDiagram-DBY2YBRQ-Bw4pvzkf.js} +1 -1
  75. package/dist/web/assets/{src-BuJdKDww.js → src-D_DMwmBd.js} +1 -1
  76. package/dist/web/assets/{stateDiagram-2N3HPSRC-xg3Onc8v.js → stateDiagram-2N3HPSRC-Q0qvHsf_.js} +1 -1
  77. package/dist/web/assets/stateDiagram-v2-6OUMAXLB-ChUyBpFH.js +1 -0
  78. package/dist/web/assets/{swimlanes-5IMT3BWC-DPJceuSw.js → swimlanes-5IMT3BWC-K22dJ96l.js} +1 -1
  79. package/dist/web/assets/swimlanesDiagram-G3AALYLV-0kss8Lg_.js +8 -0
  80. package/dist/web/assets/{timeline-definition-FHXFAJF6-4Q0cNBZa.js → timeline-definition-FHXFAJF6-DBnf2O5F.js} +1 -1
  81. package/dist/web/assets/{treeView-QDETBFTQ-BFyEFFDW.js → treeView-QDETBFTQ-vEgp8rG6.js} +1 -1
  82. package/dist/web/assets/{treemap-6X3UGDF4-CLak8Uij.js → treemap-6X3UGDF4-DTG5XbMU.js} +1 -1
  83. package/dist/web/assets/{vennDiagram-L72KCM5P-CnMeax8n.js → vennDiagram-L72KCM5P-yvzldEn_.js} +1 -1
  84. package/dist/web/assets/{wardley-OPB4EBWU-CUMtRrUi.js → wardley-OPB4EBWU-CiJqxxnE.js} +1 -1
  85. package/dist/web/assets/{wardleyDiagram-EHGQE667-CzFqvDxe.js → wardleyDiagram-EHGQE667-CGhW5qOc.js} +1 -1
  86. package/dist/web/assets/{xychartDiagram-FW5EYKEG-C86ZCbK8.js → xychartDiagram-FW5EYKEG-DuI96QQ9.js} +1 -1
  87. package/dist/web/index.html +2 -2
  88. package/package.json +1 -1
  89. package/dist/web/assets/architecture-TIHT7OUA-CXs7lqrB.js +0 -1
  90. package/dist/web/assets/channel-BRTsEjH0.js +0 -1
  91. package/dist/web/assets/classDiagram-OUVF2IWQ-oxDyX2ry.js +0 -1
  92. package/dist/web/assets/classDiagram-v2-EOCWNBFH-oxDyX2ry.js +0 -1
  93. package/dist/web/assets/eventmodeling-45OFAUF4-BBqgpOjt.js +0 -1
  94. package/dist/web/assets/flowDiagram-23GEKE2U-DUiF3T5Y.js +0 -1
  95. package/dist/web/assets/index-Bz_82pCM.css +0 -2
  96. package/dist/web/assets/railroad-abnf-AHOZXSZD-CY8YCNrM.js +0 -1
  97. package/dist/web/assets/railroad-ebnf-EBAXGLYW-DK8c1XBp.js +0 -1
  98. package/dist/web/assets/railroad-peg-LSFZ7HO6-3FkEERnx.js +0 -1
  99. package/dist/web/assets/stateDiagram-v2-6OUMAXLB-D1aOFa-9.js +0 -1
  100. package/dist/web/assets/swimlanesDiagram-G3AALYLV-BDD3cg35.js +0 -8
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-BwWIg80u.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-BuJdKDww.js","assets/chunk-WYO6CB5R-BnZu-GH5.js","assets/chunk-ICXQ74PX-BuQxyBm4.js","assets/dist-4WHbW7kW.js","assets/chunk-VAUOI2AC-DH_aJUsJ.js","assets/chunk-HOUHSVGY-C_0OHgvt.js","assets/chunk-Q4XR5HBZ-B_ZVMZ1_.js","assets/chunk-7BUUIJ7U-Bb538aSH.js","assets/chunk-OGEWGWER-qmp8nYAi.js","assets/chunk-C7G6YPKG--UKrostC.js","assets/chunk-ZGVPDNZ5-CG5sR8Hi.js","assets/rough.esm-CSKSodPl.js","assets/chunk-52WLFC77-EpnBnafN.js","assets/line-LCszX-93.js","assets/path-BWPyau1x.js","assets/array-BifhSqXX.js","assets/chunk-FWX5IMBZ-CpoeAqxN.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-BhqnioBn.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-D_DMwmBd.js","assets/chunk-WYO6CB5R-krESB1wz.js","assets/chunk-ICXQ74PX-DXqI_eYD.js","assets/dist-eoi0_oI4.js","assets/chunk-VAUOI2AC-C9EyY67a.js","assets/chunk-HOUHSVGY-ByqVYtdv.js","assets/chunk-Q4XR5HBZ-DyN60MoF.js","assets/chunk-7BUUIJ7U-Bb538aSH.js","assets/chunk-OGEWGWER-BN9LPPms.js","assets/chunk-C7G6YPKG-BVEnGhWm.js","assets/chunk-ZGVPDNZ5-Ch60IWeh.js","assets/rough.esm-CSKSodPl.js","assets/chunk-52WLFC77-C56wZyRg.js","assets/line-D_9HoxN3.js","assets/path-BWPyau1x.js","assets/array-BifhSqXX.js","assets/chunk-FWX5IMBZ-DE1AOCYK.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 te(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var ne=/\/+/g;function re(e,t){return typeof e==`object`&&e&&e.key!=null?te(``+e.key):t.toString(36)}function ie(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 ae(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,ae(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+re(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(ne,`$&/`)+`/`),ae(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(ne,`$&/`)+`/`)+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+re(a,u),c+=ae(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+re(a,u++),c+=ae(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return ae(ie(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 oe(e,t,n){if(e==null)return e;var r=[],i=0;return ae(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function O(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var k=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},A={map:oe,forEach:function(e,t,n){oe(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return oe(e,function(){t++}),t},toArray:function(e){return oe(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=A,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:O}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,k)}catch(e){k(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.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&&re(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&&re(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 te=new MessageChannel,ne=te.port2;te.port1.onmessage=ee,D=function(){ne.postMessage(null)}}else D=function(){_(ee,0)};function re(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,re(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`),te=Symbol.for(`react.activity`),ne=Symbol.for(`react.memo_cache_sentinel`),re=Symbol.iterator;function ie(e){return typeof e!=`object`||!e?null:(e=re&&e[re]||e[`@@iterator`],typeof e==`function`?e:null)}var ae=Symbol.for(`react.client.reference`);function oe(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ae?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 te: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?oe(e.type)||`Memo`:t;case D:t=e._payload,e=e._init;try{return oe(e(t))}catch{}}return null}var O=Array.isArray,k=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,j={pending:!1,data:null,method:null,action:null},se=[],ce=-1;function le(e){return{current:e}}function ue(e){0>ce||(e.current=se[ce],se[ce]=null,ce--)}function de(e,t){ce++,se[ce]=e.current,e.current=t}var fe=le(null),pe=le(null),me=le(null),he=le(null);function ge(e,t){switch(de(me,t),de(pe,e),de(fe,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Hd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Hd(t),e=Ud(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ue(fe),de(fe,e)}function _e(){ue(fe),ue(pe),ue(me)}function ve(e){e.memoizedState!==null&&de(he,e);var t=fe.current,n=Ud(t,e.type);t!==n&&(de(pe,e),de(fe,n))}function ye(e){pe.current===e&&(ue(fe),ue(pe)),he.current===e&&(ue(he),Qf._currentValue=j)}var be,xe;function Se(e){if(be===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);be=t&&t[1]||``,xe=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+be+e+xe}var Ce=!1;function we(e,t){if(!e||Ce)return``;Ce=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
@@ -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`),Qt(e,l,`whitespace`)(t))}function l(t){return t===null||M(t)?d(t):(e.enter(`mathFlowFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===null||M(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?Qt(e,m,`linePrefix`,a+1):m)(t)}function m(t){return t===null?g(t):M(t)?e.attempt(qg,f,g)(t):(e.enter(`mathFlowValue`),h(t))}function h(t){return t===null||M(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 Qt(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`),Qt(e,c,`whitespace`)(t))}function c(r){return r===null||M(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):M(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||M(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,P.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-BwWIg80u.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,P.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,P.jsx)(`div`,{className:`absolute left-2 top-2 z-10 opacity-0 transition-opacity group-hover:opacity-100`,children:(0,P.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,P.jsx)(`div`,{className:`absolute right-2 top-2 z-10 opacity-0 transition-opacity group-hover:opacity-100`,children:(0,P.jsx)(s_,{text:e})}),s?(0,P.jsx)(`pre`,{className:`overflow-x-auto font-mono text-xs text-zinc-500 dark:text-zinc-400`,children:e}):(0,P.jsx)(`div`,{className:`flex justify-center overflow-x-auto [&_svg]:max-w-full`,dangerouslySetInnerHTML:{__html:r}})]}):(0,P.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,P.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,P.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,P.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,P.jsx)(`span`,{className:`italic`,children:`thinking`}),(0,P.jsx)(`span`,{className:`ml-auto`,children:t?`▾`:`▸`})]}),t&&(0,P.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,P.jsx)(`pre`,{...n,children:t}):(0,P.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`),Qt(e,l,`whitespace`)(t))}function l(t){return t===null||M(t)?d(t):(e.enter(`mathFlowFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===null||M(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?Qt(e,m,`linePrefix`,a+1):m)(t)}function m(t){return t===null?g(t):M(t)?e.attempt(qg,f,g)(t):(e.enter(`mathFlowValue`),h(t))}function h(t){return t===null||M(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 Qt(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`),Qt(e,c,`whitespace`)(t))}function c(r){return r===null||M(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):M(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||M(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,P.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-BhqnioBn.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,P.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,P.jsx)(`div`,{className:`absolute left-2 top-2 z-10 opacity-0 transition-opacity group-hover:opacity-100`,children:(0,P.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,P.jsx)(`div`,{className:`absolute right-2 top-2 z-10 opacity-0 transition-opacity group-hover:opacity-100`,children:(0,P.jsx)(s_,{text:e})}),s?(0,P.jsx)(`pre`,{className:`overflow-x-auto font-mono text-xs text-zinc-500 dark:text-zinc-400`,children:e}):(0,P.jsx)(`div`,{className:`flex justify-center overflow-x-auto [&_svg]:max-w-full`,dangerouslySetInnerHTML:{__html:r}})]}):(0,P.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,P.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,P.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,P.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,P.jsx)(`span`,{className:`italic`,children:`thinking`}),(0,P.jsx)(`span`,{className:`ml-auto`,children:t?`▾`:`▸`})]}),t&&(0,P.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,P.jsx)(`pre`,{...n,children:t}):(0,P.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,P.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,P.jsx)(`a`,{...n,href:e,onClick:e=>{e.preventDefault(),a.current?.(r)},children:t})}return(0,P.jsx)(`a`,{...n,href:e,target:`_blank`,rel:`noreferrer`,children:t})}return{pre:b_,img:e,a:r}},[t,n]);return(0,P.jsxs)(`div`,{className:`group max-w-none`,children:[i&&!e.streaming&&(0,P.jsx)(`div`,{className:`flex justify-end opacity-0 transition-opacity group-hover:opacity-100`,children:(0,P.jsx)(s_,{text:i})}),e.blocks.map((e,t)=>e.type===`thinking`?(0,P.jsx)(v_,{text:e.text},e.contentIndex??t):(0,P.jsx)(`div`,{className:`prose-chat`,children:(0,P.jsx)(ko,{remarkPlugins:[Ug,t_],rehypePlugins:[Up],components:o,children:n_(e.text)})},e.contentIndex??t)),e.errorMessage&&(0,P.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,13 +306,13 @@ 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,P.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,P.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,className:`h-4 w-4`,children:(0,P.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}),(0,P.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,P.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,P.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,P.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,P.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,P.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:[(0,P.jsx)(`circle`,{cx:`6`,cy:`19`,r:`3`}),(0,P.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,P.jsx)(`circle`,{cx:`18`,cy:`5`,r:`3`})]}):(0,P.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,P.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_({html:e,className:t=``,as:n=`div`}){return(0,P.jsx)(n,{className:`rendered-ansi overflow-x-auto font-mono text-xs leading-relaxed [&_span]:whitespace-pre-wrap ${t}`,dangerouslySetInnerHTML:{__html:e}})}function z_({item:e}){let[t,n]=(0,v.useState)(!1),r=e.details!==void 0,i=!!e.contentHtml,a=e.contentHtmlCollapsed??e.contentHtml,o=r||i&&!!e.contentHtmlCollapsed;return(0,P.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,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsxs)(`span`,{className:`font-mono text-xs font-bold text-violet-700 dark:text-violet-300`,children:[`[`,e.customType,`]`]}),o&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>n(!t),title:`Show details`,className:`ml-auto text-xs text-violet-500 hover:text-violet-700 dark:text-violet-500 dark:hover:text-violet-300`,children:t?`▾`:`▸`})]}),i&&a?(0,P.jsx)(R_,{html:t||!e.contentHtmlCollapsed?e.contentHtml??a:a,className:`mt-1 text-violet-950 dark:text-violet-100`}):(0,P.jsx)(`div`,{className:`prose-chat mt-1 text-violet-950 dark:text-violet-100`,children:(0,P.jsx)(ko,{remarkPlugins:[Ug,t_],rehypePlugins:[Up],children:n_(e.text)})}),t&&r&&(0,P.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 B_=`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`,V_=`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`,H_=`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 U_({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,P.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,onClick:s,children:(0,P.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,P.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:e.title}),e.method===`select`&&(0,P.jsx)(`div`,{className:`mb-1 flex flex-col gap-1`,children:e.options.map(n=>(0,P.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:`text-left ${B_}`,children:n},n))}),e.method===`confirm`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`p`,{className:`mb-4 text-sm text-zinc-600 dark:text-zinc-400`,children:e.message}),(0,P.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!1}),className:B_,children:`No`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!0}),className:V_,children:`Yes`})]})]}),e.method===`input`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.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:H_}),(0,P.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:s,className:B_,children:`Cancel`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:V_,children:`OK`})]})]}),e.method===`editor`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.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 ${H_}`}),(0,P.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:s,className:B_,children:`Cancel`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:V_,children:`OK`})]})]}),a!==null&&(0,P.jsxs)(`p`,{className:`mt-3 text-right text-xs text-zinc-400 dark:text-zinc-600`,children:[`auto-dismiss in `,a,`s`]})]})})}var W_={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 G_({notification:e,onDismiss:t}){return(0,v.useEffect)(()=>{let e=setTimeout(t,6e3);return()=>clearTimeout(e)},[t]),(0,P.jsx)(`div`,{className:`rounded-lg border px-3 py-2 text-sm shadow-lg ${W_[e.notifyType??`info`]}`,children:e.message})}function K_({notifications:e,onDismiss:t}){return e.length===0?null:(0,P.jsx)(`div`,{className:`fixed right-4 top-16 z-40 flex w-80 flex-col gap-2`,children:e.map(e=>(0,P.jsx)(G_,{notification:e,onDismiss:()=>t(e.id)},e.id))})}function q_({widgets:e,placement:t}){let n=Object.entries(e).filter(([,e])=>e.placement===t);return n.length===0?null:(0,P.jsx)(`div`,{className:`mb-2 flex flex-col gap-1`,children:n.map(([e,t])=>(0,P.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 J_(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 Y_(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 X_(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 Z_(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 Q_=null,$_={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 ev(){return Q_||=(async()=>{let{default:e}=await p_(async()=>{let{default:e}=await import(`./core-DY7rIyDC.js`);return{default:e}},[]);return await Promise.all(Object.entries($_).map(async([t,n])=>{let r=await n();e.registerLanguage(t,r.default)})),e})(),Q_}var tv={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 nv(e){let t=e.split(`/`).pop()??e;if(/^dockerfile$/i.test(t))return`dockerfile`;let n=t.lastIndexOf(`.`);if(!(n<0))return tv[t.slice(n+1).toLowerCase()]}function rv({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),ev().then(n=>{if(e)return;let a=nv(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,P.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,children:e}):(0,P.jsx)(`pre`,{className:`hljs whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,dangerouslySetInnerHTML:{__html:n}})}function iv({lines:e,fill:t=!1}){return(0,P.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:X_(Y_(e)).map((e,t)=>e===null?(0,P.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,P.jsxs)(`div`,{className:`grid grid-cols-2`,children:[(0,P.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,P.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 av({lines:e}){return(0,P.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded border border-zinc-200 font-mono text-xs leading-relaxed dark:border-zinc-800`,children:Z_(e).map((e,t)=>e===null?(0,P.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,P.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 ov(e){return/\.(md|markdown)$/i.test(e)}function sv(e,t){return t===void 0?!0:t===null?!1:t===``||e===t||e.startsWith(`${t}/`)}function cv({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&&ov(e.path),D=a_(e.path),te=sv(e.path,t),ne=b!==null&&b.draft!==b.baseContent,re=E?.pendingSave!==void 0,ie=b!==null&&E!==null&&E.mtimeMs!==b.baseMtimeMs,ae=E?.saveError?.conflict===!0||ie;function oe(){ne&&!window.confirm(`Discard unsaved changes?`)||l()}function O(){E&&x({draft:E.content,baseContent:E.content,baseMtimeMs:E.mtimeMs})}function k(t=!1){!E||b===null||re||(T.current=b.draft,d(e.path,b.draft,b.baseMtimeMs,t))}function A(){x(null),u(e.path)}function j(){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`&&oe()}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(ne),()=>r(!1)),[ne]),(0,v.useEffect)(()=>(a&&s(e.path),()=>c()),[]),(0,P.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,P.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,P.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,P.jsx)(`button`,{type:`button`,onClick:j,"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,P.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,ne&&(0,P.jsx)(`span`,{className:`ml-1 text-amber-500`,children:`●`})]}),E&&b===null&&(0,P.jsx)(s_,{text:E.content}),E&&b===null&&!_&&te&&(0,P.jsx)(`button`,{type:`button`,onClick:O,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&&!te&&(0,P.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,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>k(),disabled:!ne||re||ae,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:re?`saving…`:`save`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>ne?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,P.jsx)(`button`,{type:`button`,onClick:oe,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:`✕`})]}),ae&&b!==null&&(0,P.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,P.jsx)(`span`,{className:`min-w-0 flex-1`,children:`File changed on disk since you started editing.`}),(0,P.jsx)(`button`,{type:`button`,onClick:A,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,P.jsx)(`button`,{type:`button`,onClick:()=>k(!0),disabled:re,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,P.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,P.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[_&&b===null&&(0,P.jsxs)(`div`,{className:`p-4`,children:[o?.path===e.path&&`error`in o&&(0,P.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,P.jsx)(iv,{fill:!0,lines:J_(o.before,o.after)}),o?.path!==e.path&&(0,P.jsx)(`div`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`loading diff…`})]}),D&&b===null&&!_&&(0,P.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,P.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,P.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),e.status===`error`&&!D&&(0,P.jsx)(`div`,{className:`p-4 text-sm text-red-600 dark:text-red-400`,children:e.message}),b!==null&&(0,P.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(),ne&&!re&&!ae&&k())},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,P.jsx)(`div`,{className:`prose-chat mx-auto max-w-3xl p-4 text-zinc-700 dark:text-zinc-300`,children:(0,P.jsx)(ko,{remarkPlugins:[Ug,t_],rehypePlugins:[Up],components:{a:({href:t,children:n,...r})=>!t||/^[a-z][a-z0-9+.-]*:/i.test(t)?(0,P.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,...r,children:n}):t.startsWith(`#`)?(0,P.jsx)(`a`,{href:t,...r,children:n}):(0,P.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,P.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,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(rv,{code:E.content,path:e.path})})]}),S!==`idle`&&(0,P.jsxs)(`button`,{type:`button`,onClick:oe,"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,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 animate-pulse motion-reduce:animate-none rounded-full bg-amber-500`}),(0,P.jsx)(`span`,{className:`text-amber-700 dark:text-amber-400`,children:`π is replying…`})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 rounded-full bg-emerald-500`}),(0,P.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:`π replied`})]}),(0,P.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-500`,children:`show conversation →`})]})]})}function lv(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 uv({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,P.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,P.jsx)(`span`,{className:`font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,12)}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`commit diff`}),(0,P.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,P.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,P.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto p-3 font-mono text-xs leading-relaxed`,children:lv(e.patch).map((e,t)=>(0,P.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 dv=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function fv(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 pv(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 mv({status:e,log:t,onFetchLog:n,onShowCommit:r}){let[i,a]=(0,v.useState)(!1),o=fv(()=>a(!1)),s=e&&(e.ahead>0||e.behind>0)?` ${e.ahead>0?`↑${e.ahead}`:``}${e.behind>0?`↓${e.behind}`:``}`:``;return(0,P.jsxs)(`div`,{className:`relative`,ref:o,children:[(0,P.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,P.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,P.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),t?.length===0&&(0,P.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no commits`}),t?.map(e=>(0,P.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,P.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,7)}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-zinc-700 dark:text-zinc-300`,children:e.subject}),(0,P.jsxs)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:[e.author,` · `,pv(e.date)]})]},e.sha))]})]})}function hv(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 gv=`#10b981`,_v=[`#8b5cf6`,`#f59e0b`,`#0ea5e9`,`#f43f5e`,`#14b8a6`,`#d946ef`],vv=14,yv=36;function bv(e){return e===0?gv:_v[(e-1)%_v.length]}function xv(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 Sv(e){return e.flatMap(e=>[e,...Sv(e.children)])}function Cv({row:e,laneCount:t}){let n=t*vv+2,r=e=>e*vv+vv/2+1,i=r(e.lane),a=yv/2;return(0,P.jsxs)(`svg`,{width:n,height:yv,viewBox:`0 0 ${n} ${yv}`,"aria-hidden":!0,className:`shrink-0`,children:[e.through.map(e=>(0,P.jsx)(`line`,{x1:r(e),y1:0,x2:r(e),y2:yv,stroke:bv(e),strokeWidth:2,opacity:.55},e)),e.lineAbove&&(0,P.jsx)(`line`,{x1:i,y1:0,x2:i,y2:a,stroke:bv(e.lane),strokeWidth:2}),e.lineBelow&&(0,P.jsx)(`line`,{x1:i,y1:a,x2:i,y2:yv,stroke:bv(e.lane),strokeWidth:2}),e.forkTo.map(e=>(0,P.jsx)(`path`,{d:`M ${i} ${a} C ${i} ${yv}, ${r(e)} ${a}, ${r(e)} ${yv}`,fill:`none`,stroke:bv(e),strokeWidth:2,opacity:.75},e)),e.isCurrent?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`circle`,{cx:i,cy:a,r:6,fill:`none`,stroke:bv(e.lane),strokeWidth:2}),(0,P.jsx)(`circle`,{cx:i,cy:a,r:2.5,fill:bv(e.lane)})]}):(0,P.jsx)(`circle`,{cx:i,cy:a,r:4,fill:e.node.onPath?bv(e.lane):`var(--tree-off, #d4d4d8)`,stroke:bv(e.lane),strokeWidth:e.node.onPath?0:1.5})]})}function wv({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,P.jsx)(`span`,{className:`shrink-0 rounded-full border px-1.5 py-px text-[10px] leading-4 ${n}`,children:e})}var Tv=`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 Ev({row:e,laneCount:t,isStreaming:n,onNavigate:r,onFork:i,onClose:a}){let{node:o}=e,s=o.tipId??o.entryId;return(0,P.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:yv},children:[(0,P.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,P.jsx)(Cv,{row:e,laneCount:t}),(0,P.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,P.jsxs)(wv,{tone:`branch`,children:[e.forkTo.length+1,` branches`]}),e.branchIndex!==void 0&&(0,P.jsxs)(wv,{tone:`branch`,children:[`branch `,e.branchIndex,o.onPath&&!e.isCurrent?` · current`:``]}),e.isCurrent&&(0,P.jsx)(wv,{tone:`current`,children:`current`}),o.label&&(0,P.jsx)(wv,{tone:`label`,children:o.label})]}),(0,P.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:Tv,children:`↺ redo`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>{i(o.entryId),a()},title:`fork a new session from this point`,className:Tv,children:`⑂ fork`})]})}function Dv({tree:e,isStreaming:t,onListTree:n,onNavigate:r,onFork:i}){let[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``),l=hv(()=>o(!1));(0,v.useEffect)(()=>{a&&e===null&&n()},[a,e]);let u=(0,v.useMemo)(()=>e&&e.length>0?xv(e):null,[e]),d=(0,v.useMemo)(()=>{if(!e||!s.trim())return null;let t=s.trim().toLowerCase();return Sv(e).filter(e=>e.text.toLowerCase().includes(t)||e.label?.toLowerCase().includes(t))},[e,s]);return(0,P.jsxs)(`div`,{className:`relative`,ref:l,children:[(0,P.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,P.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,P.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),e?.length===0&&(0,P.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no messages yet`}),e&&e.length>0&&u&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,P.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,P.jsx)(`span`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Conversation tree`}),(0,P.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,P.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,P.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,P.jsx)(`div`,{className:`min-h-0 overflow-y-auto py-1`,children:d===null?u.rows.map(e=>(0,P.jsx)(Ev,{row:e,laneCount:u.laneCount,isStreaming:t,onNavigate:r,onFork:i,onClose:()=>o(!1)},e.node.entryId)):d.length===0?(0,P.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no matches`}):d.map(e=>(0,P.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70`,children:[(0,P.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,P.jsx)(`span`,{"aria-hidden":!0,className:e.onPath?`text-emerald-500`:`text-zinc-300 dark:text-zinc-600`,children:`●`}),(0,P.jsx)(`span`,{className:`min-w-0 truncate text-zinc-700 dark:text-zinc-300`,children:e.text||`(empty)`}),e.onPath&&(0,P.jsx)(wv,{tone:`current`,children:`on current branch`}),e.label&&(0,P.jsx)(wv,{tone:`label`,children:e.label})]}),(0,P.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:Tv,children:`↺ redo`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>{i(e.entryId),o(!1)},title:`fork a new session from this point`,className:Tv,children:`⑂ fork`})]},e.entryId))})]})]})]})}function Ov(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 kv=200;function Av({initial:e,onCommit:t,onCancel:n}){let[r,i]=(0,v.useState)(e);return(0,P.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 jv({session:e,isCurrent:t,renaming:n,onSwitch:r,onDelete:i,onStartRename:a,onRename:o,onCancelRename:s}){return n?(0,P.jsx)(`div`,{className:`px-3 py-2`,children:(0,P.jsx)(Av,{initial:e.name??``,onCommit:o,onCancel:s})}):(0,P.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,P.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 flex-1 px-3 py-2 text-left text-sm`,children:[(0,P.jsx)(`div`,{className:`truncate text-zinc-700 dark:text-zinc-300`,children:e.name||e.firstMessage||`(empty)`}),e.snippet&&(0,P.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-zinc-500 dark:text-zinc-500`,children:e.snippet}),(0,P.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,P.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,P.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 Mv({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=Ov(()=>u(!1)),g=d.trim(),_=g.length>=2;(0,v.useEffect)(()=>{if(!l)return;if(!_){c();return}let e=setTimeout(()=>s(g),kv);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,P.jsxs)(`div`,{className:`relative`,ref:h,children:[(0,P.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,P.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,P.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,P.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,P.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,P.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[x===null&&(0,P.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),x?.length===0&&(0,P.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:_?`no matches`:`no saved sessions`}),x?.map(e=>(0,P.jsx)(jv,{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 Nv({theme:e,onToggle:t}){return(0,P.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 Pv(e){let{isStreaming:t,connected:n}=e;return(0,P.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,P.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,P.jsx)(mv,{status:e.gitStatus,log:e.gitLog,onFetchLog:e.onFetchGitLog,onShowCommit:e.onShowCommit}),(0,P.jsx)(`span`,{className:`text-lg font-semibold tracking-tight`,style:{color:`var(--accent, inherit)`},children:e.title??`π`}),Object.entries(e.statuses).map(([e,t])=>(0,P.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,P.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,P.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,P.jsx)(Nv,{theme:e.theme,onToggle:e.onToggleTheme}),(0,P.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,P.jsx)(Dv,{tree:e.tree,isStreaming:t,onListTree:e.onListTree,onNavigate:e.onNavigateTree,onFork:e.onForkSession}),(0,P.jsx)(Mv,{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,P.jsx)(`span`,{className:`h-2 w-2 rounded-full ${n?`bg-emerald-500`:`bg-red-500`}`,title:n?`connected`:`disconnected`})]})]})}function Fv(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 Iv({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,P.jsxs)(`svg`,{width:18,height:18,viewBox:`0 0 36 36`,className:`-rotate-90 shrink-0`,children:[(0,P.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,P.jsx)(`circle`,{cx:`18`,cy:`18`,r:t,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,strokeLinecap:`round`,strokeDasharray:`${i} ${n-i}`,className:Fv(e)})]})}function Lv({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,dv.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,P.jsxs)(`div`,{className:`relative`,ref:a,children:[(0,P.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,P.jsx)(`span`,{"aria-hidden":!0,className:`text-sm leading-none ${o?``:`opacity-40 grayscale`}`,children:`🧠`}),e]}),r&&(0,P.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,P.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between text-xs`,children:[(0,P.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`thinking`}),(0,P.jsx)(`span`,{className:`font-mono text-zinc-700 dark:text-zinc-200`,children:e})]}),(0,P.jsx)(`input`,{type:`range`,min:0,max:dv.length-1,step:1,value:s,onChange:e=>n(dv[Number(e.target.value)]),"aria-label":`Thinking level`,"aria-valuetext":e,className:`w-full accent-amber-500`}),(0,P.jsxs)(`div`,{className:`mt-0.5 flex justify-between font-mono text-[9px] text-zinc-400 dark:text-zinc-600`,children:[(0,P.jsx)(`span`,{children:dv[0]}),(0,P.jsx)(`span`,{children:dv[dv.length-1]})]})]})]})}function Rv(e){let{model:t,models:n,thinkingLevel:r,modelSupportsReasoning:i,isStreaming:a,contextUsage:o,isCompacting:s}=e;return(0,P.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,P.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,P.jsx)(`option`,{value:t,children:t}),n.map(e=>(0,P.jsxs)(`option`,{value:`${e.provider}/${e.id}`,children:[e.provider,`/`,e.id]},`${e.provider}/${e.id}`))]}),i&&(0,P.jsx)(Lv,{thinkingLevel:r,isStreaming:a,onSetThinking:e.onSetThinking}),(0,P.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,P.jsx)(Iv,{usage:o}),s?`compacting…`:o?.percent==null?`context`:`${Math.round(o.percent)}%`]})]})}var zv=`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`,Bv=`mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400`;function Vv({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,P.jsx)(`div`,{className:`flex h-full items-center justify-center overflow-auto p-6`,children:(0,P.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,P.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),C?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`h1`,{className:`mb-3 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`No model is available.`}),(0,P.jsxs)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:[`Credentials are configured, so this is not a missing key: `,(0,P.jsx)(`code`,{children:`allowedModels`}),` in your configuration leaves nothing to choose from. Widen it, or remove it, then restart.`]})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.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,P.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,P.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,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`label`,{htmlFor:`onboarding-provider`,className:Bv,children:`Provider`}),(0,P.jsx)(`select`,{id:`onboarding-provider`,value:c,onChange:e=>l(e.target.value),className:`${zv} mb-3`,children:a.map(e=>(0,P.jsxs)(`option`,{value:e.id,children:[e.name,e.configured?` (already configured)`:``]},e.id))})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`label`,{htmlFor:`onboarding-name`,className:Bv,children:`Name`}),(0,P.jsx)(`input`,{id:`onboarding-name`,value:f,onChange:e=>p(e.target.value),placeholder:`corp`,className:`${zv} mb-3`}),(0,P.jsx)(`label`,{htmlFor:`onboarding-url`,className:Bv,children:`Base URL`}),(0,P.jsx)(`input`,{id:`onboarding-url`,value:m,onChange:e=>h(e.target.value),placeholder:`https://llm.corp.example/v1`,className:`${zv} mb-3`}),(0,P.jsx)(`label`,{htmlFor:`onboarding-model`,className:Bv,children:`Model id`}),(0,P.jsx)(`input`,{id:`onboarding-model`,value:g,onChange:e=>_(e.target.value),placeholder:`gpt-oss-120b`,className:`${zv} mb-3`})]}),(0,P.jsx)(`label`,{htmlFor:`onboarding-key`,className:Bv,children:`API key`}),(0,P.jsx)(`input`,{id:`onboarding-key`,type:`password`,autoComplete:`off`,value:u,onChange:e=>d(e.target.value),placeholder:`sk-…`,className:zv}),o===`custom`&&(0,P.jsxs)(`fieldset`,{className:`mt-4 rounded-lg border border-zinc-200 p-3 dark:border-zinc-800`,children:[(0,P.jsx)(`legend`,{className:`px-1 text-xs text-zinc-500 dark:text-zinc-400`,children:`Compatibility`}),(0,P.jsxs)(`label`,{className:`flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:y,onChange:e=>b(e.target.checked),className:`mt-0.5`}),(0,P.jsxs)(`span`,{children:[`Server understands the `,(0,P.jsx)(`code`,{children:`developer`}),` role. Uncheck for vLLM, SGLang and most corporate gateways — the system prompt is then sent as a `,(0,P.jsx)(`code`,{children:`system`}),` message.`]})]}),(0,P.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked),className:`mt-0.5`}),(0,P.jsxs)(`span`,{children:[`Server accepts `,(0,P.jsx)(`code`,{children:`reasoning_effort`}),`. Uncheck if it rejects unknown fields.`]})]})]}),(0,P.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,P.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,P.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,P.jsx)(`code`,{children:`pi-outpost login`}),`.`]})]})})}var Hv={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 Uv(e,t){return t?Object.keys(t).filter(t=>t.startsWith(`${e}/`)).length:0}function Wv(e){return e===`directory`||e===`symlink-directory`}function Gv(e,t){return t===void 0?!1:t===null?!0:t===``?!1:e!==t&&!e.startsWith(`${t}/`)}function Kv({path:e,depth:t,...n}){let r=n.tree[e];return r===void 0?null:r===`loading`?(0,P.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,P.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,P.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:`empty`}):(0,P.jsx)(P.Fragment,{children:r.map(r=>(0,P.jsx)(qv,{parentPath:e,entry:r,depth:t,...n},r.name))})}function qv({parentPath:e,entry:t,depth:n,...r}){let[i,a]=(0,v.useState)(!1),o=e?`${e}/${t.name}`:t.name,s=Gv(o,r.writableRoot);if(Wv(t.type))return(0,P.jsxs)(`div`,{children:[(0,P.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,P.jsx)(`span`,{className:`w-3 shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:i?`▾`:`▸`}),(0,P.jsx)(`span`,{className:`truncate ${s?`text-zinc-400 dark:text-zinc-600`:`text-zinc-700 dark:text-zinc-300`}`,children:t.name}),!i&&Uv(o,r.gitFiles)>0&&(0,P.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:`${Uv(o,r.gitFiles)} changed file(s) inside`,children:Uv(o,r.gitFiles)})]}),i&&(0,P.jsx)(Kv,{path:o,depth:n+1,...r})]});let c=o===r.openFilePath,l=r.gitFiles?.[o],u=r.attachedPaths?.includes(o)??!1;return(0,P.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,P.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,P.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,P.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,P.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 ${Hv[l].className}`,children:Hv[l].label})]})}function Jv(e){return(0,P.jsx)(`div`,{className:`text-sm`,children:(0,P.jsx)(Kv,{path:``,depth:0,...e})})}function Yv({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,P.jsxs)(`aside`,{className:`flex w-72 shrink-0 flex-col border-r border-zinc-200 dark:border-zinc-800`,children:[(0,P.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,P.jsx)(`div`,{className:`flex-1 overflow-auto p-2`,children:(0,P.jsx)(Jv,{tree:e,openFilePath:t?.path,writableRoot:n,gitFiles:r,attachedPaths:i,onExpand:a,onSelectFile:o,onSelectDiff:s,onToggleAttachPath:c})})]})}function Xv({title:e,onSubmit:t}){let[n,r]=(0,v.useState)(``);return(0,P.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,P.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,P.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),(0,P.jsx)(`h1`,{className:`mb-4 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`This server requires an access token.`}),(0,P.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,P.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,P.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,P.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,P.jsx)(`code`,{children:`?token=…`})]})]})})}function Zv(e){let t=e,n=`
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 Y_(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 X_(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 Z_(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 Q_=null,$_={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 ev(){return Q_||=(async()=>{let{default:e}=await p_(async()=>{let{default:e}=await import(`./core-BYdjv-3f.js`);return{default:e}},[]);return await Promise.all(Object.entries($_).map(async([t,n])=>{let r=await n();e.registerLanguage(t,r.default)})),e})(),Q_}var tv={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 nv(e){let t=e.split(`/`).pop()??e;if(/^dockerfile$/i.test(t))return`dockerfile`;let n=t.lastIndexOf(`.`);if(!(n<0))return tv[t.slice(n+1).toLowerCase()]}function rv({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),ev().then(n=>{if(e)return;let a=nv(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,P.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,children:e}):(0,P.jsx)(`pre`,{className:`hljs whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,dangerouslySetInnerHTML:{__html:n}})}function iv({lines:e,fill:t=!1}){return(0,P.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:X_(Y_(e)).map((e,t)=>e===null?(0,P.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,P.jsxs)(`div`,{className:`grid grid-cols-2`,children:[(0,P.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,P.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 av({lines:e}){return(0,P.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded border border-zinc-200 font-mono text-xs leading-relaxed dark:border-zinc-800`,children:Z_(e).map((e,t)=>e===null?(0,P.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,P.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 ov(e){return/\.(md|markdown)$/i.test(e)}function sv(e,t){return t===void 0?!0:t===null?!1:t===``||e===t||e.startsWith(`${t}/`)}function cv({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&&ov(e.path),D=a_(e.path),te=sv(e.path,t),ne=b!==null&&b.draft!==b.baseContent,re=E?.pendingSave!==void 0,ie=b!==null&&E!==null&&E.mtimeMs!==b.baseMtimeMs,ae=E?.saveError?.conflict===!0||ie;function oe(){ne&&!window.confirm(`Discard unsaved changes?`)||l()}function O(){E&&x({draft:E.content,baseContent:E.content,baseMtimeMs:E.mtimeMs})}function k(t=!1){!E||b===null||re||(T.current=b.draft,d(e.path,b.draft,b.baseMtimeMs,t))}function A(){x(null),u(e.path)}function j(){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`&&oe()}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(ne),()=>r(!1)),[ne]),(0,v.useEffect)(()=>(a&&s(e.path),()=>c()),[]),(0,P.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,P.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,P.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,P.jsx)(`button`,{type:`button`,onClick:j,"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,P.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,ne&&(0,P.jsx)(`span`,{className:`ml-1 text-amber-500`,children:`●`})]}),E&&b===null&&(0,P.jsx)(s_,{text:E.content}),E&&b===null&&!_&&te&&(0,P.jsx)(`button`,{type:`button`,onClick:O,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&&!te&&(0,P.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,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>k(),disabled:!ne||re||ae,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:re?`saving…`:`save`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>ne?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,P.jsx)(`button`,{type:`button`,onClick:oe,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:`✕`})]}),ae&&b!==null&&(0,P.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,P.jsx)(`span`,{className:`min-w-0 flex-1`,children:`File changed on disk since you started editing.`}),(0,P.jsx)(`button`,{type:`button`,onClick:A,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,P.jsx)(`button`,{type:`button`,onClick:()=>k(!0),disabled:re,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,P.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,P.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[_&&b===null&&(0,P.jsxs)(`div`,{className:`p-4`,children:[o?.path===e.path&&`error`in o&&(0,P.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,P.jsx)(iv,{fill:!0,lines:J_(o.before,o.after)}),o?.path!==e.path&&(0,P.jsx)(`div`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`loading diff…`})]}),D&&b===null&&!_&&(0,P.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,P.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,P.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),e.status===`error`&&!D&&(0,P.jsx)(`div`,{className:`p-4 text-sm text-red-600 dark:text-red-400`,children:e.message}),b!==null&&(0,P.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(),ne&&!re&&!ae&&k())},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,P.jsx)(`div`,{className:`prose-chat mx-auto max-w-3xl p-4 text-zinc-700 dark:text-zinc-300`,children:(0,P.jsx)(ko,{remarkPlugins:[Ug,t_],rehypePlugins:[Up],components:{a:({href:t,children:n,...r})=>!t||/^[a-z][a-z0-9+.-]*:/i.test(t)?(0,P.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,...r,children:n}):t.startsWith(`#`)?(0,P.jsx)(`a`,{href:t,...r,children:n}):(0,P.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,P.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,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(rv,{code:E.content,path:e.path})})]}),S!==`idle`&&(0,P.jsxs)(`button`,{type:`button`,onClick:oe,"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,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 animate-pulse motion-reduce:animate-none rounded-full bg-amber-500`}),(0,P.jsx)(`span`,{className:`text-amber-700 dark:text-amber-400`,children:`π is replying…`})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 rounded-full bg-emerald-500`}),(0,P.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:`π replied`})]}),(0,P.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-500`,children:`show conversation →`})]})]})}function lv(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 uv({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,P.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,P.jsx)(`span`,{className:`font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,12)}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`commit diff`}),(0,P.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,P.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,P.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto p-3 font-mono text-xs leading-relaxed`,children:lv(e.patch).map((e,t)=>(0,P.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 dv=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function fv(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 pv(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 mv({status:e,log:t,onFetchLog:n,onShowCommit:r}){let[i,a]=(0,v.useState)(!1),o=fv(()=>a(!1)),s=e&&(e.ahead>0||e.behind>0)?` ${e.ahead>0?`↑${e.ahead}`:``}${e.behind>0?`↓${e.behind}`:``}`:``;return(0,P.jsxs)(`div`,{className:`relative`,ref:o,children:[(0,P.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,P.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,P.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),t?.length===0&&(0,P.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no commits`}),t?.map(e=>(0,P.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,P.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,7)}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-zinc-700 dark:text-zinc-300`,children:e.subject}),(0,P.jsxs)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:[e.author,` · `,pv(e.date)]})]},e.sha))]})]})}function hv(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 gv({extensionPaths:e,sandbox:t,versions:n,onUpdateConfig:r}){let[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(!1),g=hv(()=>a(!1));(0,v.useEffect)(()=>{t&&(s(t.root),l(t.writableRoot??``),d(t.allowWrite),p(t.allowBash))},[t]);function _(){a(!1),h(!1)}function y(){t&&(h(!0),r({root:o,allowWrite:u,allowBash:f,writableRoot:c.trim()||void 0}),_())}return(0,P.jsxs)(`div`,{className:`relative`,ref:g,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>a(!i),title:`Settings`,"aria-label":`Settings`,className:`rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`⚙`}),i&&(0,P.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-[80vh] w-[380px] flex-col rounded-lg border border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,P.jsx)(`div`,{className:`border-b border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:(0,P.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Settings`})}),(0,P.jsxs)(`div`,{className:`min-h-0 overflow-y-auto p-4`,children:[(0,P.jsxs)(`section`,{className:`mb-4`,children:[(0,P.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Extensions`}),e.length===0?(0,P.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No extensions loaded`}):(0,P.jsx)(`ul`,{className:`space-y-1`,children:e.map((e,t)=>(0,P.jsx)(`li`,{className:`rounded bg-zinc-50 px-2 py-1 text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,title:e,children:e},t))})]}),t&&(0,P.jsxs)(`section`,{children:[(0,P.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Sandbox`}),(0,P.jsxs)(`div`,{className:`space-y-3`,children:[(0,P.jsxs)(`label`,{className:`block`,children:[(0,P.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Root `,t.locks?.root?(0,P.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,P.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),disabled:t.locks?.root,className:`mt-1 w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none focus:border-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:focus:border-zinc-500`})]}),(0,P.jsxs)(`label`,{className:`block`,children:[(0,P.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Writable root (optional) `,t.locks?.writableRoot?(0,P.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,P.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),disabled:t.locks?.writableRoot,placeholder:`Same as root`,className:`mt-1 w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`})]}),(0,P.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked),disabled:t.locks?.allowWrite,className:`rounded border-zinc-300 text-zinc-700 focus:ring-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300`}),(0,P.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow write `,t.locks?.allowWrite?(0,P.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]}),(0,P.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:f,onChange:e=>p(e.target.checked),disabled:t.locks?.allowBash,className:`rounded border-zinc-300 text-zinc-700 focus:ring-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300`}),(0,P.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow bash `,t.locks?.allowBash?(0,P.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]}),(0,P.jsx)(`button`,{type:`button`,disabled:m||!o.trim(),onClick:y,className:`w-full rounded-md bg-zinc-800 px-3 py-1.5 text-xs font-medium text-white hover:bg-zinc-700 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-zinc-200 dark:text-zinc-900 dark:hover:bg-zinc-300`,children:m?`Applying…`:`Apply & restart session`}),(0,P.jsx)(`p`,{className:`text-[11px] text-zinc-400 dark:text-zinc-500`,children:`File browser paths update immediately. Agent tools (read/write/bash) use the new sandbox after a server restart.`})]})]}),!t&&(0,P.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No sandbox configured`}),n&&(0,P.jsxs)(`section`,{className:`mt-4`,children:[(0,P.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Versions`}),(0,P.jsxs)(`div`,{className:`space-y-1 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,P.jsxs)(`p`,{children:[`pi-outpost: `,(0,P.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:n.piOutpost})]}),(0,P.jsxs)(`p`,{children:[`pi SDK: `,(0,P.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:n.piSdk})]})]})]})]})]})]})}function _v(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 vv=`#10b981`,yv=[`#8b5cf6`,`#f59e0b`,`#0ea5e9`,`#f43f5e`,`#14b8a6`,`#d946ef`],bv=14,xv=36;function Sv(e){return e===0?vv:yv[(e-1)%yv.length]}function Cv(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 wv(e){return e.flatMap(e=>[e,...wv(e.children)])}function Tv({row:e,laneCount:t}){let n=t*bv+2,r=e=>e*bv+bv/2+1,i=r(e.lane),a=xv/2;return(0,P.jsxs)(`svg`,{width:n,height:xv,viewBox:`0 0 ${n} ${xv}`,"aria-hidden":!0,className:`shrink-0`,children:[e.through.map(e=>(0,P.jsx)(`line`,{x1:r(e),y1:0,x2:r(e),y2:xv,stroke:Sv(e),strokeWidth:2,opacity:.55},e)),e.lineAbove&&(0,P.jsx)(`line`,{x1:i,y1:0,x2:i,y2:a,stroke:Sv(e.lane),strokeWidth:2}),e.lineBelow&&(0,P.jsx)(`line`,{x1:i,y1:a,x2:i,y2:xv,stroke:Sv(e.lane),strokeWidth:2}),e.forkTo.map(e=>(0,P.jsx)(`path`,{d:`M ${i} ${a} C ${i} ${xv}, ${r(e)} ${a}, ${r(e)} ${xv}`,fill:`none`,stroke:Sv(e),strokeWidth:2,opacity:.75},e)),e.isCurrent?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`circle`,{cx:i,cy:a,r:6,fill:`none`,stroke:Sv(e.lane),strokeWidth:2}),(0,P.jsx)(`circle`,{cx:i,cy:a,r:2.5,fill:Sv(e.lane)})]}):(0,P.jsx)(`circle`,{cx:i,cy:a,r:4,fill:e.node.onPath?Sv(e.lane):`var(--tree-off, #d4d4d8)`,stroke:Sv(e.lane),strokeWidth:e.node.onPath?0:1.5})]})}function Ev({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,P.jsx)(`span`,{className:`shrink-0 rounded-full border px-1.5 py-px text-[10px] leading-4 ${n}`,children:e})}var Dv=`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 Ov({row:e,laneCount:t,isStreaming:n,onNavigate:r,onFork:i,onClose:a}){let{node:o}=e,s=o.tipId??o.entryId;return(0,P.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:xv},children:[(0,P.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,P.jsx)(Tv,{row:e,laneCount:t}),(0,P.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,P.jsxs)(Ev,{tone:`branch`,children:[e.forkTo.length+1,` branches`]}),e.branchIndex!==void 0&&(0,P.jsxs)(Ev,{tone:`branch`,children:[`branch `,e.branchIndex,o.onPath&&!e.isCurrent?` · current`:``]}),e.isCurrent&&(0,P.jsx)(Ev,{tone:`current`,children:`current`}),o.label&&(0,P.jsx)(Ev,{tone:`label`,children:o.label})]}),(0,P.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:Dv,children:`↺ redo`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>{i(o.entryId),a()},title:`fork a new session from this point`,className:Dv,children:`⑂ fork`})]})}function kv({tree:e,isStreaming:t,onListTree:n,onNavigate:r,onFork:i}){let[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``),l=_v(()=>o(!1));(0,v.useEffect)(()=>{a&&e===null&&n()},[a,e]);let u=(0,v.useMemo)(()=>e&&e.length>0?Cv(e):null,[e]),d=(0,v.useMemo)(()=>{if(!e||!s.trim())return null;let t=s.trim().toLowerCase();return wv(e).filter(e=>e.text.toLowerCase().includes(t)||e.label?.toLowerCase().includes(t))},[e,s]);return(0,P.jsxs)(`div`,{className:`relative`,ref:l,children:[(0,P.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,P.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,P.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),e?.length===0&&(0,P.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no messages yet`}),e&&e.length>0&&u&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,P.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,P.jsx)(`span`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Conversation tree`}),(0,P.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,P.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,P.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,P.jsx)(`div`,{className:`min-h-0 overflow-y-auto py-1`,children:d===null?u.rows.map(e=>(0,P.jsx)(Ov,{row:e,laneCount:u.laneCount,isStreaming:t,onNavigate:r,onFork:i,onClose:()=>o(!1)},e.node.entryId)):d.length===0?(0,P.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no matches`}):d.map(e=>(0,P.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70`,children:[(0,P.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,P.jsx)(`span`,{"aria-hidden":!0,className:e.onPath?`text-emerald-500`:`text-zinc-300 dark:text-zinc-600`,children:`●`}),(0,P.jsx)(`span`,{className:`min-w-0 truncate text-zinc-700 dark:text-zinc-300`,children:e.text||`(empty)`}),e.onPath&&(0,P.jsx)(Ev,{tone:`current`,children:`on current branch`}),e.label&&(0,P.jsx)(Ev,{tone:`label`,children:e.label})]}),(0,P.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:Dv,children:`↺ redo`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>{i(e.entryId),o(!1)},title:`fork a new session from this point`,className:Dv,children:`⑂ fork`})]},e.entryId))})]})]})]})}function Av(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 jv=200;function Mv({initial:e,onCommit:t,onCancel:n}){let[r,i]=(0,v.useState)(e);return(0,P.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 Nv({session:e,isCurrent:t,renaming:n,onSwitch:r,onDelete:i,onStartRename:a,onRename:o,onCancelRename:s}){return n?(0,P.jsx)(`div`,{className:`px-3 py-2`,children:(0,P.jsx)(Mv,{initial:e.name??``,onCommit:o,onCancel:s})}):(0,P.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,P.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 flex-1 px-3 py-2 text-left text-sm`,children:[(0,P.jsx)(`div`,{className:`truncate text-zinc-700 dark:text-zinc-300`,children:e.name||e.firstMessage||`(empty)`}),e.snippet&&(0,P.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-zinc-500 dark:text-zinc-500`,children:e.snippet}),(0,P.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,P.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,P.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 Pv({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=Av(()=>u(!1)),g=d.trim(),_=g.length>=2;(0,v.useEffect)(()=>{if(!l)return;if(!_){c();return}let e=setTimeout(()=>s(g),jv);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,P.jsxs)(`div`,{className:`relative`,ref:h,children:[(0,P.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,P.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,P.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,P.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,P.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,P.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[x===null&&(0,P.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),x?.length===0&&(0,P.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:_?`no matches`:`no saved sessions`}),x?.map(e=>(0,P.jsx)(Nv,{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 Fv({theme:e,onToggle:t}){return(0,P.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 Iv(e){let{isStreaming:t,connected:n}=e;return(0,P.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,P.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,P.jsx)(mv,{status:e.gitStatus,log:e.gitLog,onFetchLog:e.onFetchGitLog,onShowCommit:e.onShowCommit}),(0,P.jsx)(`span`,{className:`text-lg font-semibold tracking-tight`,style:{color:`var(--accent, inherit)`},children:e.title??`π`}),Object.entries(e.statuses).map(([e,t])=>(0,P.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,P.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,P.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,P.jsx)(Fv,{theme:e.theme,onToggle:e.onToggleTheme}),(0,P.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,P.jsx)(kv,{tree:e.tree,isStreaming:t,onListTree:e.onListTree,onNavigate:e.onNavigateTree,onFork:e.onForkSession}),(0,P.jsx)(Pv,{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,P.jsx)(gv,{extensionPaths:e.extensionPaths,sandbox:e.sandbox,versions:e.versions,onUpdateConfig:e.onUpdateConfig}),(0,P.jsx)(`span`,{className:`h-2 w-2 rounded-full ${n?`bg-emerald-500`:`bg-red-500`}`,title:n?`connected`:`disconnected`})]})]})}function Lv(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 Rv({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,P.jsxs)(`svg`,{width:18,height:18,viewBox:`0 0 36 36`,className:`-rotate-90 shrink-0`,children:[(0,P.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,P.jsx)(`circle`,{cx:`18`,cy:`18`,r:t,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,strokeLinecap:`round`,strokeDasharray:`${i} ${n-i}`,className:Lv(e)})]})}function zv({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,dv.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,P.jsxs)(`div`,{className:`relative`,ref:a,children:[(0,P.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,P.jsx)(`span`,{"aria-hidden":!0,className:`text-sm leading-none ${o?``:`opacity-40 grayscale`}`,children:`🧠`}),e]}),r&&(0,P.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,P.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between text-xs`,children:[(0,P.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`thinking`}),(0,P.jsx)(`span`,{className:`font-mono text-zinc-700 dark:text-zinc-200`,children:e})]}),(0,P.jsx)(`input`,{type:`range`,min:0,max:dv.length-1,step:1,value:s,onChange:e=>n(dv[Number(e.target.value)]),"aria-label":`Thinking level`,"aria-valuetext":e,className:`w-full accent-amber-500`}),(0,P.jsxs)(`div`,{className:`mt-0.5 flex justify-between font-mono text-[9px] text-zinc-400 dark:text-zinc-600`,children:[(0,P.jsx)(`span`,{children:dv[0]}),(0,P.jsx)(`span`,{children:dv[dv.length-1]})]})]})]})}function Bv(e){let{model:t,models:n,thinkingLevel:r,modelSupportsReasoning:i,isStreaming:a,contextUsage:o,isCompacting:s}=e;return(0,P.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,P.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,P.jsx)(`option`,{value:t,children:t}),n.map(e=>(0,P.jsxs)(`option`,{value:`${e.provider}/${e.id}`,children:[e.provider,`/`,e.id]},`${e.provider}/${e.id}`))]}),i&&(0,P.jsx)(zv,{thinkingLevel:r,isStreaming:a,onSetThinking:e.onSetThinking}),(0,P.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,P.jsx)(Rv,{usage:o}),s?`compacting…`:o?.percent==null?`context`:`${Math.round(o.percent)}%`]})]})}var Vv=`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`,Hv=`mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400`;function Uv({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,P.jsx)(`div`,{className:`flex h-full items-center justify-center overflow-auto p-6`,children:(0,P.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,P.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),C?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`h1`,{className:`mb-3 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`No model is available.`}),(0,P.jsxs)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:[`Credentials are configured, so this is not a missing key: `,(0,P.jsx)(`code`,{children:`allowedModels`}),` in your configuration leaves nothing to choose from. Widen it, or remove it, then restart.`]})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.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,P.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,P.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,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`label`,{htmlFor:`onboarding-provider`,className:Hv,children:`Provider`}),(0,P.jsx)(`select`,{id:`onboarding-provider`,value:c,onChange:e=>l(e.target.value),className:`${Vv} mb-3`,children:a.map(e=>(0,P.jsxs)(`option`,{value:e.id,children:[e.name,e.configured?` (already configured)`:``]},e.id))})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`label`,{htmlFor:`onboarding-name`,className:Hv,children:`Name`}),(0,P.jsx)(`input`,{id:`onboarding-name`,value:f,onChange:e=>p(e.target.value),placeholder:`corp`,className:`${Vv} mb-3`}),(0,P.jsx)(`label`,{htmlFor:`onboarding-url`,className:Hv,children:`Base URL`}),(0,P.jsx)(`input`,{id:`onboarding-url`,value:m,onChange:e=>h(e.target.value),placeholder:`https://llm.corp.example/v1`,className:`${Vv} mb-3`}),(0,P.jsx)(`label`,{htmlFor:`onboarding-model`,className:Hv,children:`Model id`}),(0,P.jsx)(`input`,{id:`onboarding-model`,value:g,onChange:e=>_(e.target.value),placeholder:`gpt-oss-120b`,className:`${Vv} mb-3`})]}),(0,P.jsx)(`label`,{htmlFor:`onboarding-key`,className:Hv,children:`API key`}),(0,P.jsx)(`input`,{id:`onboarding-key`,type:`password`,autoComplete:`off`,value:u,onChange:e=>d(e.target.value),placeholder:`sk-…`,className:Vv}),o===`custom`&&(0,P.jsxs)(`fieldset`,{className:`mt-4 rounded-lg border border-zinc-200 p-3 dark:border-zinc-800`,children:[(0,P.jsx)(`legend`,{className:`px-1 text-xs text-zinc-500 dark:text-zinc-400`,children:`Compatibility`}),(0,P.jsxs)(`label`,{className:`flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:y,onChange:e=>b(e.target.checked),className:`mt-0.5`}),(0,P.jsxs)(`span`,{children:[`Server understands the `,(0,P.jsx)(`code`,{children:`developer`}),` role. Uncheck for vLLM, SGLang and most corporate gateways — the system prompt is then sent as a `,(0,P.jsx)(`code`,{children:`system`}),` message.`]})]}),(0,P.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked),className:`mt-0.5`}),(0,P.jsxs)(`span`,{children:[`Server accepts `,(0,P.jsx)(`code`,{children:`reasoning_effort`}),`. Uncheck if it rejects unknown fields.`]})]})]}),(0,P.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,P.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,P.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,P.jsx)(`code`,{children:`pi-outpost login`}),`.`]})]})})}var Wv={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 Gv(e,t){return t?Object.keys(t).filter(t=>t.startsWith(`${e}/`)).length:0}function Kv(e){return e===`directory`||e===`symlink-directory`}function qv(e,t){return t===void 0?!1:t===null?!0:t===``?!1:e!==t&&!e.startsWith(`${t}/`)}function Jv({path:e,depth:t,...n}){let r=n.tree[e];return r===void 0?null:r===`loading`?(0,P.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,P.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,P.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:`empty`}):(0,P.jsx)(P.Fragment,{children:r.map(r=>(0,P.jsx)(Yv,{parentPath:e,entry:r,depth:t,...n},r.name))})}function Yv({parentPath:e,entry:t,depth:n,...r}){let[i,a]=(0,v.useState)(!1),o=e?`${e}/${t.name}`:t.name,s=qv(o,r.writableRoot);if(Kv(t.type))return(0,P.jsxs)(`div`,{children:[(0,P.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,P.jsx)(`span`,{className:`w-3 shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:i?`▾`:`▸`}),(0,P.jsx)(`span`,{className:`truncate ${s?`text-zinc-400 dark:text-zinc-600`:`text-zinc-700 dark:text-zinc-300`}`,children:t.name}),!i&&Gv(o,r.gitFiles)>0&&(0,P.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:`${Gv(o,r.gitFiles)} changed file(s) inside`,children:Gv(o,r.gitFiles)})]}),i&&(0,P.jsx)(Jv,{path:o,depth:n+1,...r})]});let c=o===r.openFilePath,l=r.gitFiles?.[o],u=r.attachedPaths?.includes(o)??!1;return(0,P.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,P.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,P.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,P.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,P.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 ${Wv[l].className}`,children:Wv[l].label})]})}function Xv(e){return(0,P.jsx)(`div`,{className:`text-sm`,children:(0,P.jsx)(Jv,{path:``,depth:0,...e})})}function Zv({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,P.jsxs)(`aside`,{className:`flex w-72 shrink-0 flex-col border-r border-zinc-200 dark:border-zinc-800`,children:[(0,P.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,P.jsx)(`div`,{className:`flex-1 overflow-auto p-2`,children:(0,P.jsx)(Xv,{tree:e,openFilePath:t?.path,writableRoot:n,gitFiles:r,attachedPaths:i,onExpand:a,onSelectFile:o,onSelectDiff:s,onToggleAttachPath:c})})]})}function Qv({title:e,onSubmit:t}){let[n,r]=(0,v.useState)(``);return(0,P.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,P.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,P.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),(0,P.jsx)(`h1`,{className:`mb-4 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`This server requires an access token.`}),(0,P.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,P.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,P.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,P.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,P.jsx)(`code`,{children:`?token=…`})]})]})})}function $v(e){let t=e,n=`
311
311
  … [truncated,`;e.includes(n)&&(t=e.split(n)[0]);let r=e=>{let t=[];if(e.task&&t.push(`**${String(e.task)}**`),e.searchMode&&t.push(`Mode: ${String(e.searchMode)}`),e.title&&t.push(`**${String(e.title)}**`),e.summary&&t.push(String(e.summary)),Array.isArray(e.relevantFiles)&&e.relevantFiles.length>0){t.push(`
312
312
  Relevant files:`);for(let n of e.relevantFiles.slice(0,5))t.push(`- ${n}`)}if(Array.isArray(e.relevantFunctions)&&e.relevantFunctions.length>0){t.push(`
313
313
  Relevant functions:`);for(let n of e.relevantFunctions.slice(0,5))n&&n.name?t.push(`- ${n.name} (${n.filePath??n.file??`unknown`})`):t.push(`- ${String(n)}`)}if(Array.isArray(e.nextSteps)&&e.nextSteps.length>0){t.push(`
314
314
  Next steps:`);for(let n of e.nextSteps.slice(0,5))t.push(`- ${n}`)}if(Array.isArray(e.nextStepsText)&&e.nextStepsText.length>0){t.push(`
315
315
  Next steps:`);for(let n of e.nextStepsText.slice(0,5))t.push(`- ${n}`)}let n=t.join(`
316
- `).trim();if(n)return n};try{let e=JSON.parse(t);if(e&&typeof e==`object`)return e.__pi_render?.text?String(e.__pi_render.text):r(e);if(typeof e==`string`)return e}catch{}try{let e=0,n=-1,i=-1;for(let r=0;r<t.length;r++)if(t[r]===`{`&&e++,t[r]===`}`&&(e--,i=r,e===0)){n=r;break}if(n>0){let e=t.slice(0,n+1),i=JSON.parse(e);if(i&&typeof i==`object`)return r(i)}if(i>0&&n===-1){let e=t.slice(0,i+1);try{let t=JSON.parse(e);if(t&&typeof t==`object`)return r(t)}catch{}}}catch{}}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 $v(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 ey(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 ty({item:e}){let t=!!e.outputHtml,n=t?null:$v(e),r=t?null:ey(e),i=n!==null||r!==null,a=e.output?Zv(e.output):void 0,o=!!a,s=(0,v.useMemo)(()=>[Ug,t_],[]),c=(0,v.useMemo)(()=>[Up],[]),[l,u]=(0,v.useState)(i);(0,v.useEffect)(()=>{u(i)},[i]);let d=Qv(e.args),f=!l&&o;return(0,P.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,P.jsxs)(`button`,{type:`button`,onClick:()=>u(!l),className:`flex w-full items-center gap-2 px-3 py-2 text-left`,children:[(0,P.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${e.running?`animate-pulse motion-reduce:animate-none bg-amber-400`:e.isError?`bg-red-500`:`bg-emerald-500`}`}),e.callHtml?(0,P.jsx)(R_,{as:`span`,html:e.callHtml,className:`min-w-0 flex-1 text-zinc-700 dark:text-zinc-300`}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{className:`font-mono font-medium text-zinc-700 dark:text-zinc-300`,children:e.toolName}),d&&(0,P.jsx)(`span`,{className:`truncate font-mono text-xs text-zinc-500`,children:d})]}),(0,P.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-600`,children:l?`▾`:`▸`})]}),f&&a&&(0,P.jsx)(`div`,{className:`border-t border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:(0,P.jsx)(`div`,{className:`prose-chat max-h-96 overflow-auto text-zinc-700 dark:text-zinc-300`,children:(0,P.jsx)(ko,{remarkPlugins:s,rehypePlugins:c,children:n_(a)})})}),l&&(0,P.jsxs)(`div`,{className:`border-t border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[n!==null&&(0,P.jsx)(`div`,{className:`mb-2 flex flex-col gap-2`,children:n.map((e,t)=>(0,P.jsx)(iv,{lines:J_(e.oldText,e.newText)},t))}),r!==null&&(0,P.jsx)(`div`,{className:`mb-2`,children:(0,P.jsx)(av,{lines:r.split(`
317
- `).map(e=>({type:`add`,text:e}))})}),e.outputHtml?(0,P.jsx)(R_,{html:e.outputHtml,className:`max-h-96 text-zinc-700 dark:text-zinc-300`}):e.output?(0,P.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}):(0,P.jsx)(`pre`,{className:`max-h-96 overflow-auto whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,children:e.running?`running…`:`(no output)`})]})]})}function ny({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,P.jsxs)(`div`,{className:`group ml-auto flex max-w-[85%] items-start gap-1.5`,children:[o&&!s&&(0,P.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,P.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,P.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:e.images.map((e,t)=>(0,P.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:``,className:`max-h-48 max-w-full rounded-lg object-contain`},t))}),s?(0,P.jsxs)(`div`,{children:[(0,P.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(`
318
- `).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,P.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-end gap-2 text-xs`,children:[(0,P.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,P.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,P.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,P.jsx)(`div`,{className:`whitespace-pre-wrap`,children:e.text})]})]})}var ry=`pi-outpost:token`;function iy(){let e=null;try{let t=new URL(window.location.href);return e=t.searchParams.get(`token`),e&&(localStorage.setItem(ry,e),t.searchParams.delete(`token`),window.history.replaceState(null,``,`${t.pathname}${t.search}${t.hash}`)),localStorage.getItem(ry)}catch{return e}}function ay(){try{return localStorage.getItem(ry)}catch{return null}}function oy(e){try{localStorage.setItem(ry,e)}catch{}}var sy={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 cy(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 ly(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 uy(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 dy(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 uy(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:cy(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:cy(e.items,()=>n.item)};case`custom_message`:return{...e,items:[...e.items,n.item]};case`tool_start`:return{...e,items:ly(e.items,n.toolCallId,n.toolName,{toolName:n.toolName,args:n.args,running:!0,callHtml:n.callHtml})};case`tool_update`:return{...e,items:ly(e.items,n.toolCallId,`tool`,{output:n.text})};case`tool_end`:return{...e,items:ly(e.items,n.toolCallId,`tool`,{output:n.text,isError:n.isError,running:!1,outputHtml:n.outputHtml,outputHtmlCollapsed:n.outputHtmlCollapsed})};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 fy(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 py=4401;function my(e=``,t,n=!1){let[r,i]=(0,v.useReducer)(dy,sy),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?ay():iy()));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(fy(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===py){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=>{oy(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 hy=`pi-outpost:theme`;function gy(){return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function _y(){let e=localStorage.getItem(hy);return e===`light`||e===`dark`||e===`system`?e:null}function vy(e){localStorage.setItem(hy,e)}function yy(e,t,n=document.documentElement){let r=t?_y():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)(gy);(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&&vy(e)},[t]);return{theme:l,toggle:(0,v.useCallback)(()=>u(l===`dark`?`light`:`dark`),[l,u]),setTheme:u}}var by=(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:te,readFile:ne,writeFile:re,closeFilePreview:ie,searchFiles:ae,clearFileSearch:oe,fetchGitDiff:O,clearGitDiff:k,fetchGitLog:A,fetchGitShow:j,clearGitShow:se,setCredential:ce,declareProvider:le}=my(e,r,a),[ue,de]=(0,v.useState)(!1),[fe,pe]=(0,v.useState)([]),[me,he]=(0,v.useState)([]),[ge,_e]=(0,v.useState)(null),[ve,ye]=(0,v.useState)(null),[be,xe]=(0,v.useState)(!1),Se=(0,v.useRef)([]),Ce=(0,v.useRef)(null),we=(0,v.useRef)(null),[Te,Ee]=(0,v.useState)(!1),[De,Oe]=(0,v.useState)(()=>{try{return localStorage.getItem(`pi-outpost:hide-tools`)===`1`}catch{return!1}});function ke(){Oe(e=>{try{localStorage.setItem(`pi-outpost:hide-tools`,e?`0`:`1`)}catch{}return!e})}let[Ae,je]=(0,v.useState)([]),[Me,Ne]=(0,v.useState)(0);async function Pe(e){let{attachments:t,errors:n}=await w_(e);t.length>0&&pe(e=>[...e,...t]),je(n)}(0,v.useEffect)(()=>{Se.current=fe},[fe]),(0,v.useEffect)(()=>{let t=s.openFile;if(!t)return;let n=t.path,r=t.status===`loaded`;if(Ce.current!==n&&(Ce.current=n,we.current=null,pe(e=>e.filter(e=>e.source!==`preview`)),_e(null),ye(null)),we.current===n)return;let i=!1;async function a(){let t=a_(n)?ve===n?await k_(n,o_(e,n,c)):null:r?T_(n):null;if(!(i||t===null||Ce.current!==n||we.current===n)){if(typeof t==`string`){_e(t);return}_e(null),pe(e=>M_(e,t))}}return a(),()=>{i=!0}},[s.openFile,e,c,ve]);function Fe(){Ce.current=null,we.current=null,ie()}let Ie=(0,v.useMemo)(()=>[...fe.filter(e=>e.kind===`path`).map(e=>e.data),...me],[fe,me]);function Le(e){let t=Se.current.findIndex(t=>t.kind===`path`&&t.data===e);t>=0?Re(t):me.includes(e)||pe(t=>j_(t,e))}function Re(e){let t=Se.current[e];t?.source===`preview`&&(we.current=t.previewPath??Ce.current,_e(null)),pe(t=>N_(t,e))}function ze(e,t){u(e,t),pe([]),je([]),_e(null),be||Fe()}function Be(e){e.preventDefault(),Ne(0),e.dataTransfer.files.length>0&&Pe(Array.from(e.dataTransfer.files))}let{theme:Ve,toggle:He,setTheme:Ue}=yy(n??s.branding.defaultTheme??`system`,s.branding.allowThemeToggle!==!1,o);(0,v.useImperativeHandle)(i,()=>({setTheme:Ue}),[Ue]);let We=(0,v.useRef)(null),Ge=(0,v.useRef)(null),Ke=(0,v.useRef)(!0);function qe(){let e=We.current;e&&(Ke.current=e.scrollHeight-e.scrollTop-e.clientHeight<120)}return(0,v.useEffect)(()=>{Ke.current&&Ge.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,P.jsx)(c_.Provider,{value:Ve,children:(0,P.jsx)(Xv,{title:s.branding.title,onSubmit:l})}):s.credentials&&!s.credentials.usableModel?(0,P.jsx)(c_.Provider,{value:Ve,children:(0,P.jsx)(Vv,{title:s.branding.title,credentials:s.credentials,onSetCredential:ce,onDeclareProvider:le,errors:s.errors})}):(0,P.jsxs)(c_.Provider,{value:Ve,children:[(0,P.jsxs)(`div`,{className:`relative flex h-full`,onDragEnter:e=>{e.dataTransfer.types.includes(`Files`)&&Ne(e=>e+1)},onDragLeave:()=>Ne(e=>Math.max(0,e-1)),onDragOver:e=>e.preventDefault(),onDrop:Be,children:[Me>0&&(0,P.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,P.jsx)(`p`,{className:`text-lg font-medium text-zinc-700 dark:text-zinc-200`,children:`Drop files to attach (images & text)`})}),ue&&(0,P.jsx)(Yv,{tree:s.fileTree,openFile:s.openFile,writableRoot:s.writableRoot,gitFiles:s.gitStatus?.files,attachedPaths:Ie,onExpand:te,onSelectFile:e=>{Ee(!1),ne(e)},onSelectDiff:e=>{Ee(!0),ne(e)},onToggleAttachPath:Le}),(0,P.jsxs)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,children:[(0,P.jsx)(Pv,{title:s.branding.title,sessions:s.sessions,sessionSearch:s.sessionSearch,sessionId:s.sessionId,tree:s.tree,isStreaming:s.isStreaming,connected:s.connected,theme:Ve,showThemeToggle:s.branding.allowThemeToggle!==!1,statuses:s.statuses,sidebarOpen:ue,hideTools:De,onToggleSidebar:()=>de(!ue),onToggleHideTools:ke,onToggleTheme:He,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:A,onShowCommit:j}),(0,P.jsxs)(`div`,{className:`relative z-0 flex min-h-0 flex-1 flex-col`,children:[s.openFile&&(0,P.jsx)(cv,{file:s.openFile,writableRoot:s.writableRoot,isStreaming:s.isStreaming,onDirtyChange:xe,gitState:s.gitStatus?.files[s.openFile.path],initialShowGitDiff:Te,gitDiff:s.gitDiff,onFetchGitDiff:O,onClearGitDiff:k,onClose:Fe,onReload:ne,onSave:re,serverUrl:e,token:c,onImageLoad:ye},s.openFile.path),s.gitShow&&(0,P.jsx)(uv,{show:s.gitShow,onClose:se}),(0,P.jsx)(`main`,{ref:We,onScroll:qe,className:`flex-1 overflow-y-auto`,children:(0,P.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-3 px-4 py-6`,children:[s.items.length===0&&(0,P.jsxs)(`div`,{className:`mt-24 text-center text-zinc-500 dark:text-zinc-600`,children:[(0,P.jsx)(`div`,{className:`mb-2 text-4xl`,children:s.branding.title??`π`}),(0,P.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}`;if(t.kind===`user`){let e=n===s.items.length-1&&s.isStreaming;return(0,P.jsxs)(v.Fragment,{children:[(0,P.jsx)(ny,{item:t,canEdit:!s.isStreaming&&s.connected,onEdit:T}),e&&(0,P.jsx)(`div`,{className:`flex justify-end px-4`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,P.jsx)(`span`,{className:`inline-block h-4 w-4 animate-spin rounded-full border-[3px] border-zinc-300 border-t-blue-500 dark:border-zinc-600 dark:border-t-blue-400 motion-reduce:animate-pulse`}),(0,P.jsx)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`working…`})]})})]},r)}return t.kind===`tool`?De?null:(0,P.jsx)(ty,{item:t},t.toolCallId?`${s.sessionId}:${t.toolCallId}`:r):t.kind===`custom`?(0,P.jsx)(z_,{item:t},r):t.blocks.length===0&&!t.errorMessage?null:(0,P.jsx)(x_,{item:t,serverUrl:e,token:c,onOpenFile:e=>{Ee(!1),ne(e)}},r)}),(s.queue.steering.length>0||s.queue.followUp.length>0)&&(0,P.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,P.jsxs)(`div`,{children:[`⏩ steering: `,e]},`s${t}`)),s.queue.followUp.map((e,t)=>(0,P.jsxs)(`div`,{children:[`⏭ follow-up: `,e]},`f${t}`))]}),Ae.map((e,t)=>(0,P.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}`)),ge&&(0,P.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:ge}),s.errors.map((e,t)=>(0,P.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,P.jsx)(`div`,{ref:Ge})]})})]}),(0,P.jsx)(`footer`,{className:`border-t border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:(0,P.jsxs)(`div`,{className:`mx-auto max-w-3xl`,children:[(0,P.jsx)(q_,{widgets:s.widgets,placement:`aboveEditor`}),(0,P.jsx)(L_,{isStreaming:s.isStreaming,connected:s.connected,commands:s.commands,fileSearch:s.fileSearch,prefill:s.editorPrefill,attachments:fe,onAttach:e=>void Pe(e),onMentionPaths:he,onRemoveAttachment:Re,onSend:ze,onAbort:d,onSearchFiles:ae,onClearFileSearch:oe}),(0,P.jsx)(q_,{widgets:s.widgets,placement:`belowEditor`}),(0,P.jsx)(Rv,{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,P.jsx)(U_,{request:s.dialogQueue[0],onRespond:ee}),(0,P.jsx)(K_,{notifications:s.notifications,onDismiss:D})]})});(0,y.createRoot)(document.getElementById(`root`)).render((0,P.jsx)(v.StrictMode,{children:(0,P.jsx)(by,{})}));export{l as i,As as n,o as r,p_ as t};
316
+ `).trim();if(n)return n};try{let e=JSON.parse(t);if(e&&typeof e==`object`)return e.__pi_render?.text?String(e.__pi_render.text):r(e);if(typeof e==`string`)return e}catch{}try{let e=0,n=-1,i=-1;for(let r=0;r<t.length;r++)if(t[r]===`{`&&e++,t[r]===`}`&&(e--,i=r,e===0)){n=r;break}if(n>0){let e=t.slice(0,n+1),i=JSON.parse(e);if(i&&typeof i==`object`)return r(i)}if(i>0&&n===-1){let e=t.slice(0,i+1);try{let t=JSON.parse(e);if(t&&typeof t==`object`)return r(t)}catch{}}}catch{}}function ey(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 ty(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 ny(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 ry({item:e}){let t=!!e.outputHtml,n=t?null:ty(e),r=t?null:ny(e),i=n!==null||r!==null,a=e.output?$v(e.output):void 0,o=!!a,s=(0,v.useMemo)(()=>[Ug,t_],[]),c=(0,v.useMemo)(()=>[Up],[]),[l,u]=(0,v.useState)(i);(0,v.useEffect)(()=>{u(i)},[i]);let d=ey(e.args),f=!l&&o;return(0,P.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,P.jsxs)(`button`,{type:`button`,onClick:()=>u(!l),className:`flex w-full items-center gap-2 px-3 py-2 text-left`,children:[(0,P.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${e.running?`animate-pulse motion-reduce:animate-none bg-amber-400`:e.isError?`bg-red-500`:`bg-emerald-500`}`}),e.callHtml?(0,P.jsx)(R_,{as:`span`,html:e.callHtml,className:`min-w-0 flex-1 text-zinc-700 dark:text-zinc-300`}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{className:`font-mono font-medium text-zinc-700 dark:text-zinc-300`,children:e.toolName}),d&&(0,P.jsx)(`span`,{className:`truncate font-mono text-xs text-zinc-500`,children:d})]}),(0,P.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-600`,children:l?`▾`:`▸`})]}),f&&a&&(0,P.jsx)(`div`,{className:`border-t border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:(0,P.jsx)(`div`,{className:`prose-chat max-h-96 overflow-auto text-zinc-700 dark:text-zinc-300`,children:(0,P.jsx)(ko,{remarkPlugins:s,rehypePlugins:c,children:n_(a)})})}),l&&(0,P.jsxs)(`div`,{className:`border-t border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[n!==null&&(0,P.jsx)(`div`,{className:`mb-2 flex flex-col gap-2`,children:n.map((e,t)=>(0,P.jsx)(iv,{lines:J_(e.oldText,e.newText)},t))}),r!==null&&(0,P.jsx)(`div`,{className:`mb-2`,children:(0,P.jsx)(av,{lines:r.split(`
317
+ `).map(e=>({type:`add`,text:e}))})}),e.outputHtml?(0,P.jsx)(R_,{html:e.outputHtml,className:`max-h-96 text-zinc-700 dark:text-zinc-300`}):e.output?(0,P.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}):(0,P.jsx)(`pre`,{className:`max-h-96 overflow-auto whitespace-pre-wrap font-mono text-xs text-zinc-700 dark:text-zinc-300`,children:e.running?`running…`:`(no output)`})]})]})}function iy({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,P.jsxs)(`div`,{className:`group ml-auto flex max-w-[85%] items-start gap-1.5`,children:[o&&!s&&(0,P.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,P.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,P.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:e.images.map((e,t)=>(0,P.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:``,className:`max-h-48 max-w-full rounded-lg object-contain`},t))}),s?(0,P.jsxs)(`div`,{children:[(0,P.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(`
318
+ `).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,P.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-end gap-2 text-xs`,children:[(0,P.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,P.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,P.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,P.jsx)(`div`,{className:`whitespace-pre-wrap`,children:e.text})]})]})}var ay=`pi-outpost:token`;function oy(){let e=null;try{let t=new URL(window.location.href);return e=t.searchParams.get(`token`),e&&(localStorage.setItem(ay,e),t.searchParams.delete(`token`),window.history.replaceState(null,``,`${t.pathname}${t.search}${t.hash}`)),localStorage.getItem(ay)}catch{return e}}function sy(){try{return localStorage.getItem(ay)}catch{return null}}function cy(e){try{localStorage.setItem(ay,e)}catch{}}var ly={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,extensionPaths:[],sandbox:null,versions:null,gitAvailable:!1,credentials:null,gitStatus:null,gitDiff:null,gitLog:null,gitShow:null};function uy(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 dy(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 fy(e,t){if(t.type!==`hello`&&t.type!==`session_replaced`&&t.type!==`update_config_ack`)return e;console.log(`[applySnapshot] sandbox from message:`,t.sandbox,`type:`,t.type,`sessionId:`,t.sessionId,`fileTree keys:`,Object.keys(e.fileTree).join(`,`)||`(empty)`);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,fileTree:{},writableRoot:t.writableRoot,gitAvailable:t.gitAvailable===!0,credentials:t.credentials??null,extensionPaths:t.extensionPaths??[],sandbox:t.sandbox??null,versions:t.versions??null}}function py(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`:case`update_config_ack`:return fy(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:uy(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:uy(e.items,()=>n.item)};case`custom_message`:return{...e,items:[...e.items,n.item]};case`tool_start`:return{...e,items:dy(e.items,n.toolCallId,n.toolName,{toolName:n.toolName,args:n.args,running:!0,callHtml:n.callHtml})};case`tool_update`:return{...e,items:dy(e.items,n.toolCallId,`tool`,{output:n.text})};case`tool_end`:return{...e,items:dy(e.items,n.toolCallId,`tool`,{output:n.text,isError:n.isError,running:!1,outputHtml:n.outputHtml,outputHtmlCollapsed:n.outputHtmlCollapsed})};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 my(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 hy=4401;function gy(e=``,t,n=!1){let[r,i]=(0,v.useReducer)(py,ly),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?sy():oy()));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(my(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);console.log(`[file_changed] path=`,t.path,`parentPath=`,n,`fileTree keys=`,Object.keys(l.current).join(`,`)),l.current[n]===void 0?console.log(`[file_changed] parent NOT in fileTree, skipping refresh`):(console.log(`[file_changed] parent found in fileTree, refreshing`),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}if((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}),t.type===`session_replaced`){let e=`dir:${crypto.randomUUID()}`;i({type:`dir_list_started`,path:``}),f({type:`list_directory`,path:``,requestId:e})}},o.onclose=e=>{if(a.current===o){if(m.current=!1,h.current=!1,e.code===hy){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=>{cy(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}),updateConfig:e=>f({type:`update_config`,sandbox:e})}}var _y=`pi-outpost:theme`;function vy(){return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function yy(){let e=localStorage.getItem(_y);return e===`light`||e===`dark`||e===`system`?e:null}function by(e){localStorage.setItem(_y,e)}function xy(e,t,n=document.documentElement){let r=t?yy():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)(vy);(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&&by(e)},[t]);return{theme:l,toggle:(0,v.useCallback)(()=>u(l===`dark`?`light`:`dark`),[l,u]),setTheme:u}}var Sy=(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:te,readFile:ne,writeFile:re,closeFilePreview:ie,searchFiles:ae,clearFileSearch:oe,fetchGitDiff:O,clearGitDiff:k,fetchGitLog:A,fetchGitShow:j,clearGitShow:se,setCredential:ce,declareProvider:le,updateConfig:ue}=gy(e,r,a),[de,fe]=(0,v.useState)(!1),[pe,me]=(0,v.useState)([]),[he,ge]=(0,v.useState)([]),[_e,ve]=(0,v.useState)(null),[ye,be]=(0,v.useState)(null),[xe,Se]=(0,v.useState)(!1),Ce=(0,v.useRef)([]),we=(0,v.useRef)(null),Te=(0,v.useRef)(null),[Ee,De]=(0,v.useState)(!1),[Oe,ke]=(0,v.useState)(()=>{try{return localStorage.getItem(`pi-outpost:hide-tools`)===`1`}catch{return!1}});function Ae(){ke(e=>{try{localStorage.setItem(`pi-outpost:hide-tools`,e?`0`:`1`)}catch{}return!e})}let[je,Me]=(0,v.useState)([]),[Ne,Pe]=(0,v.useState)(0);async function Fe(e){let{attachments:t,errors:n}=await w_(e);t.length>0&&me(e=>[...e,...t]),Me(n)}(0,v.useEffect)(()=>{Ce.current=pe},[pe]),(0,v.useEffect)(()=>{let t=s.openFile;if(!t)return;let n=t.path,r=t.status===`loaded`;if(we.current!==n&&(we.current=n,Te.current=null,me(e=>e.filter(e=>e.source!==`preview`)),ve(null),be(null)),Te.current===n)return;let i=!1;async function a(){let t=a_(n)?ye===n?await k_(n,o_(e,n,c)):null:r?T_(n):null;if(!(i||t===null||we.current!==n||Te.current===n)){if(typeof t==`string`){ve(t);return}ve(null),me(e=>M_(e,t))}}return a(),()=>{i=!0}},[s.openFile,e,c,ye]);function Ie(){we.current=null,Te.current=null,ie()}let Le=(0,v.useMemo)(()=>[...pe.filter(e=>e.kind===`path`).map(e=>e.data),...he],[pe,he]);function Re(e){let t=Ce.current.findIndex(t=>t.kind===`path`&&t.data===e);t>=0?ze(t):he.includes(e)||me(t=>j_(t,e))}function ze(e){let t=Ce.current[e];t?.source===`preview`&&(Te.current=t.previewPath??we.current,ve(null)),me(t=>N_(t,e))}function Be(e,t){u(e,t),me([]),Me([]),ve(null),xe||Ie()}function Ve(e){e.preventDefault(),Pe(0),e.dataTransfer.files.length>0&&Fe(Array.from(e.dataTransfer.files))}let{theme:He,toggle:Ue,setTheme:We}=xy(n??s.branding.defaultTheme??`system`,s.branding.allowThemeToggle!==!1,o);(0,v.useImperativeHandle)(i,()=>({setTheme:We}),[We]);let Ge=(0,v.useRef)(null),Ke=(0,v.useRef)(null),qe=(0,v.useRef)(!0);function Je(){let e=Ge.current;e&&(qe.current=e.scrollHeight-e.scrollTop-e.clientHeight<120)}return(0,v.useEffect)(()=>{qe.current&&Ke.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,P.jsx)(c_.Provider,{value:He,children:(0,P.jsx)(Qv,{title:s.branding.title,onSubmit:l})}):s.credentials&&!s.credentials.usableModel?(0,P.jsx)(c_.Provider,{value:He,children:(0,P.jsx)(Uv,{title:s.branding.title,credentials:s.credentials,onSetCredential:ce,onDeclareProvider:le,errors:s.errors})}):(0,P.jsxs)(c_.Provider,{value:He,children:[(0,P.jsxs)(`div`,{className:`relative flex h-full`,onDragEnter:e=>{e.dataTransfer.types.includes(`Files`)&&Pe(e=>e+1)},onDragLeave:()=>Pe(e=>Math.max(0,e-1)),onDragOver:e=>e.preventDefault(),onDrop:Ve,children:[Ne>0&&(0,P.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,P.jsx)(`p`,{className:`text-lg font-medium text-zinc-700 dark:text-zinc-200`,children:`Drop files to attach (images & text)`})}),de&&(0,P.jsx)(Zv,{tree:s.fileTree,openFile:s.openFile,writableRoot:s.writableRoot,gitFiles:s.gitStatus?.files,attachedPaths:Le,onExpand:te,onSelectFile:e=>{De(!1),ne(e)},onSelectDiff:e=>{De(!0),ne(e)},onToggleAttachPath:Re}),(0,P.jsxs)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,children:[(0,P.jsx)(Iv,{title:s.branding.title,sessions:s.sessions,sessionSearch:s.sessionSearch,sessionId:s.sessionId,tree:s.tree,isStreaming:s.isStreaming,connected:s.connected,theme:He,showThemeToggle:s.branding.allowThemeToggle!==!1,statuses:s.statuses,sidebarOpen:de,hideTools:Oe,onToggleSidebar:()=>fe(!de),onToggleHideTools:Ae,onToggleTheme:Ue,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,extensionPaths:s.extensionPaths,sandbox:s.sandbox,versions:s.versions,onUpdateConfig:ue,onFetchGitLog:A,onShowCommit:j}),(0,P.jsxs)(`div`,{className:`relative z-0 flex min-h-0 flex-1 flex-col`,children:[s.openFile&&(0,P.jsx)(cv,{file:s.openFile,writableRoot:s.writableRoot,isStreaming:s.isStreaming,onDirtyChange:Se,gitState:s.gitStatus?.files[s.openFile.path],initialShowGitDiff:Ee,gitDiff:s.gitDiff,onFetchGitDiff:O,onClearGitDiff:k,onClose:Ie,onReload:ne,onSave:re,serverUrl:e,token:c,onImageLoad:be},s.openFile.path),s.gitShow&&(0,P.jsx)(uv,{show:s.gitShow,onClose:se}),(0,P.jsx)(`main`,{ref:Ge,onScroll:Je,className:`flex-1 overflow-y-auto`,children:(0,P.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-3 px-4 py-6`,children:[s.items.length===0&&(0,P.jsxs)(`div`,{className:`mt-24 text-center text-zinc-500 dark:text-zinc-600`,children:[(0,P.jsx)(`div`,{className:`mb-2 text-4xl`,children:s.branding.title??`π`}),(0,P.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}`;if(t.kind===`user`){let e=n===s.items.length-1&&s.isStreaming;return(0,P.jsxs)(v.Fragment,{children:[(0,P.jsx)(iy,{item:t,canEdit:!s.isStreaming&&s.connected,onEdit:T}),e&&(0,P.jsx)(`div`,{className:`flex justify-end px-4`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,P.jsx)(`span`,{className:`inline-block h-4 w-4 animate-spin rounded-full border-[3px] border-zinc-300 border-t-blue-500 dark:border-zinc-600 dark:border-t-blue-400 motion-reduce:animate-pulse`}),(0,P.jsx)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`working…`})]})})]},r)}return t.kind===`tool`?Oe?null:(0,P.jsx)(ry,{item:t},t.toolCallId?`${s.sessionId}:${t.toolCallId}`:r):t.kind===`custom`?(0,P.jsx)(z_,{item:t},r):t.blocks.length===0&&!t.errorMessage?null:(0,P.jsx)(x_,{item:t,serverUrl:e,token:c,onOpenFile:e=>{De(!1),ne(e)}},r)}),(s.queue.steering.length>0||s.queue.followUp.length>0)&&(0,P.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,P.jsxs)(`div`,{children:[`⏩ steering: `,e]},`s${t}`)),s.queue.followUp.map((e,t)=>(0,P.jsxs)(`div`,{children:[`⏭ follow-up: `,e]},`f${t}`))]}),je.map((e,t)=>(0,P.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}`)),_e&&(0,P.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}),s.errors.map((e,t)=>(0,P.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,P.jsx)(`div`,{ref:Ke})]})})]}),(0,P.jsx)(`footer`,{className:`border-t border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:(0,P.jsxs)(`div`,{className:`mx-auto max-w-3xl`,children:[(0,P.jsx)(q_,{widgets:s.widgets,placement:`aboveEditor`}),(0,P.jsx)(L_,{isStreaming:s.isStreaming,connected:s.connected,commands:s.commands,fileSearch:s.fileSearch,prefill:s.editorPrefill,attachments:pe,onAttach:e=>void Fe(e),onMentionPaths:ge,onRemoveAttachment:ze,onSend:Be,onAbort:d,onSearchFiles:ae,onClearFileSearch:oe}),(0,P.jsx)(q_,{widgets:s.widgets,placement:`belowEditor`}),(0,P.jsx)(Bv,{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,P.jsx)(U_,{request:s.dialogQueue[0],onRespond:ee}),(0,P.jsx)(K_,{notifications:s.notifications,onDismiss:D})]})});(0,y.createRoot)(document.getElementById(`root`)).render((0,P.jsx)(v.StrictMode,{children:(0,P.jsx)(Sy,{})}));export{l as i,As as n,o as r,p_ as t};
@@ -1 +1 @@
1
- import"./chunk-KEIR6QF5-BfrZ3jm6.js";import{w as e}from"./mermaid-parser.core-DEPnbzQd.js";export{e as createInfoServices};
1
+ import"./chunk-KEIR6QF5-BfrZ3jm6.js";import{w as e}from"./mermaid-parser.core-BqDBKvZM.js";export{e as createInfoServices};
@@ -1,2 +1,2 @@
1
- import{n as e}from"./mermaid-parser.core-DEPnbzQd.js";import{n as t}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{m as n}from"./src-BuJdKDww.js";import{c as r}from"./chunk-WYO6CB5R-BnZu-GH5.js";import{t as i}from"./chunk-VAUOI2AC-DH_aJUsJ.js";var a={parse:t(async t=>{let r=await e(`info`,t);n.debug(r)},`parse`)},o={version:`11.16.0`},s={parser:a,db:{getVersion:t(()=>o.version,`getVersion`)},renderer:{draw:t((e,t,a)=>{n.debug(`rendering info diagram
1
+ import{n as e}from"./mermaid-parser.core-BqDBKvZM.js";import{n as t}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{m as n}from"./src-D_DMwmBd.js";import{c as r}from"./chunk-WYO6CB5R-krESB1wz.js";import{t as i}from"./chunk-VAUOI2AC-C9EyY67a.js";var a={parse:t(async t=>{let r=await e(`info`,t);n.debug(r)},`parse`)},o={version:`11.16.0`},s={parser:a,db:{getVersion:t(()=>o.version,`getVersion`)},renderer:{draw:t((e,t,a)=>{n.debug(`rendering info diagram
2
2
  `+e);let o=i(t);r(o,100,400,!0),o.append(`g`).append(`text`).attr(`x`,100).attr(`y`,40).attr(`class`,`version`).attr(`font-size`,32).style(`text-anchor`,`middle`).text(`v${a}`)},`draw`)}};export{s as diagram};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import"./src-BuJdKDww.js";import{H as t,K as n,U as r,a as i,c as a,s as o,v as s,w as c,x as l,y as u}from"./chunk-WYO6CB5R-BnZu-GH5.js";import{p as d}from"./chunk-ICXQ74PX-BuQxyBm4.js";import{t as f}from"./chunk-VAUOI2AC-DH_aJUsJ.js";import{t as p}from"./rough.esm-CSKSodPl.js";var m=(function(){var t=e(function(e,t,n,r){for(n||={},r=e.length;r--;n[e[r]]=t);return n},`o`),n=[1,4],r=[1,14],i=[1,12],a=[1,13],o=[6,7,8],s=[1,20],c=[1,18],l=[1,19],u=[6,7,11],d=[1,6,13,14],f=[1,23],p=[1,24],m=[1,6,7,11,13,14],h={trace:e(function(){},`trace`),yy:{},symbols_:{error:2,start:3,ishikawa:4,spaceLines:5,SPACELINE:6,NL:7,ISHIKAWA:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,TEXT:14,$accept:0,$end:1},terminals_:{2:`error`,6:`SPACELINE`,7:`NL`,8:`ISHIKAWA`,11:`EOF`,13:`SPACELIST`,14:`TEXT`},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,2],[12,1],[12,1],[12,1]],performAction:e(function(e,t,n,r,i,a,o){var s=a.length-1;switch(i){case 6:case 7:return r;case 15:r.addNode(a[s-1].length,a[s].trim());break;case 16:r.addNode(0,a[s].trim());break}},`anonymous`),table:[{3:1,4:2,5:3,6:[1,5],8:n},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:n},{6:r,7:[1,10],9:9,12:11,13:i,14:a},t(o,[2,3]),{1:[2,2]},t(o,[2,4]),t(o,[2,5]),{1:[2,6],6:r,12:15,13:i,14:a},{6:r,9:16,12:11,13:i,14:a},{6:s,7:c,10:17,11:l},t(u,[2,18],{14:[1,21]}),t(u,[2,16]),t(u,[2,17]),{6:s,7:c,10:22,11:l},{1:[2,7],6:r,12:15,13:i,14:a},t(d,[2,14],{7:f,11:p}),t(m,[2,8]),t(m,[2,9]),t(m,[2,10]),t(u,[2,15]),t(d,[2,13],{7:f,11:p}),t(m,[2,11]),t(m,[2,12])],defaultActions:{2:[2,1],6:[2,2]},parseError:e(function(e,t){if(t.recoverable)this.trace(e);else{var n=Error(e);throw n.hash=t,n}},`parseError`),parse:e(function(t){var n=this,r=[0],i=[],a=[null],o=[],s=this.table,c=``,l=0,u=0,d=0,f=2,p=1,m=o.slice.call(arguments,1),h=Object.create(this.lexer),g={yy:{}};for(var _ in this.yy)Object.prototype.hasOwnProperty.call(this.yy,_)&&(g.yy[_]=this.yy[_]);h.setInput(t,g.yy),g.yy.lexer=h,g.yy.parser=this,h.yylloc===void 0&&(h.yylloc={});var v=h.yylloc;o.push(v);var y=h.options&&h.options.ranges;typeof g.yy.parseError==`function`?this.parseError=g.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function b(e){r.length-=2*e,a.length-=e,o.length-=e}e(b,`popStack`);function x(){var e=i.pop()||h.lex()||p;return typeof e!=`number`&&(e instanceof Array&&(i=e,e=i.pop()),e=n.symbols_[e]||e),e}e(x,`lex`);for(var S,C,w,T,E,D={},O,k,A,j;;){if(w=r[r.length-1],this.defaultActions[w]?T=this.defaultActions[w]:(S??=x(),T=s[w]&&s[w][S]),T===void 0||!T.length||!T[0]){var M=``;for(O in j=[],s[w])this.terminals_[O]&&O>f&&j.push(`'`+this.terminals_[O]+`'`);M=h.showPosition?`Parse error on line `+(l+1)+`:
1
+ import{n as e}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import"./src-D_DMwmBd.js";import{H as t,K as n,U as r,a as i,c as a,s as o,v as s,w as c,x as l,y as u}from"./chunk-WYO6CB5R-krESB1wz.js";import{p as d}from"./chunk-ICXQ74PX-DXqI_eYD.js";import{t as f}from"./chunk-VAUOI2AC-C9EyY67a.js";import{t as p}from"./rough.esm-CSKSodPl.js";var m=(function(){var t=e(function(e,t,n,r){for(n||={},r=e.length;r--;n[e[r]]=t);return n},`o`),n=[1,4],r=[1,14],i=[1,12],a=[1,13],o=[6,7,8],s=[1,20],c=[1,18],l=[1,19],u=[6,7,11],d=[1,6,13,14],f=[1,23],p=[1,24],m=[1,6,7,11,13,14],h={trace:e(function(){},`trace`),yy:{},symbols_:{error:2,start:3,ishikawa:4,spaceLines:5,SPACELINE:6,NL:7,ISHIKAWA:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,TEXT:14,$accept:0,$end:1},terminals_:{2:`error`,6:`SPACELINE`,7:`NL`,8:`ISHIKAWA`,11:`EOF`,13:`SPACELIST`,14:`TEXT`},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,2],[12,1],[12,1],[12,1]],performAction:e(function(e,t,n,r,i,a,o){var s=a.length-1;switch(i){case 6:case 7:return r;case 15:r.addNode(a[s-1].length,a[s].trim());break;case 16:r.addNode(0,a[s].trim());break}},`anonymous`),table:[{3:1,4:2,5:3,6:[1,5],8:n},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:n},{6:r,7:[1,10],9:9,12:11,13:i,14:a},t(o,[2,3]),{1:[2,2]},t(o,[2,4]),t(o,[2,5]),{1:[2,6],6:r,12:15,13:i,14:a},{6:r,9:16,12:11,13:i,14:a},{6:s,7:c,10:17,11:l},t(u,[2,18],{14:[1,21]}),t(u,[2,16]),t(u,[2,17]),{6:s,7:c,10:22,11:l},{1:[2,7],6:r,12:15,13:i,14:a},t(d,[2,14],{7:f,11:p}),t(m,[2,8]),t(m,[2,9]),t(m,[2,10]),t(u,[2,15]),t(d,[2,13],{7:f,11:p}),t(m,[2,11]),t(m,[2,12])],defaultActions:{2:[2,1],6:[2,2]},parseError:e(function(e,t){if(t.recoverable)this.trace(e);else{var n=Error(e);throw n.hash=t,n}},`parseError`),parse:e(function(t){var n=this,r=[0],i=[],a=[null],o=[],s=this.table,c=``,l=0,u=0,d=0,f=2,p=1,m=o.slice.call(arguments,1),h=Object.create(this.lexer),g={yy:{}};for(var _ in this.yy)Object.prototype.hasOwnProperty.call(this.yy,_)&&(g.yy[_]=this.yy[_]);h.setInput(t,g.yy),g.yy.lexer=h,g.yy.parser=this,h.yylloc===void 0&&(h.yylloc={});var v=h.yylloc;o.push(v);var y=h.options&&h.options.ranges;typeof g.yy.parseError==`function`?this.parseError=g.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function b(e){r.length-=2*e,a.length-=e,o.length-=e}e(b,`popStack`);function x(){var e=i.pop()||h.lex()||p;return typeof e!=`number`&&(e instanceof Array&&(i=e,e=i.pop()),e=n.symbols_[e]||e),e}e(x,`lex`);for(var S,C,w,T,E,D={},O,k,A,j;;){if(w=r[r.length-1],this.defaultActions[w]?T=this.defaultActions[w]:(S??=x(),T=s[w]&&s[w][S]),T===void 0||!T.length||!T[0]){var M=``;for(O in j=[],s[w])this.terminals_[O]&&O>f&&j.push(`'`+this.terminals_[O]+`'`);M=h.showPosition?`Parse error on line `+(l+1)+`:
2
2
  `+h.showPosition()+`
3
3
  Expecting `+j.join(`, `)+`, got '`+(this.terminals_[S]||S)+`'`:`Parse error on line `+(l+1)+`: Unexpected `+(S==p?`end of input`:`'`+(this.terminals_[S]||S)+`'`),this.parseError(M,{text:h.match,token:this.terminals_[S]||S,line:h.yylineno,loc:v,expected:j})}if(T[0]instanceof Array&&T.length>1)throw Error(`Parse Error: multiple actions possible at state: `+w+`, token: `+S);switch(T[0]){case 1:r.push(S),a.push(h.yytext),o.push(h.yylloc),r.push(T[1]),S=null,C?(S=C,C=null):(u=h.yyleng,c=h.yytext,l=h.yylineno,v=h.yylloc,d>0&&d--);break;case 2:if(k=this.productions_[T[1]][1],D.$=a[a.length-k],D._$={first_line:o[o.length-(k||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(k||1)].first_column,last_column:o[o.length-1].last_column},y&&(D._$.range=[o[o.length-(k||1)].range[0],o[o.length-1].range[1]]),E=this.performAction.apply(D,[c,u,l,g.yy,T[1],a,o].concat(m)),E!==void 0)return E;k&&(r=r.slice(0,-1*k*2),a=a.slice(0,-1*k),o=o.slice(0,-1*k)),r.push(this.productions_[T[1]][0]),a.push(D.$),o.push(D._$),A=s[r[r.length-2]][r[r.length-1]],r.push(A);break;case 3:return!0}}return!0},`parse`)};h.lexer=(function(){return{EOF:1,parseError:e(function(e,t){if(this.yy.parser)this.yy.parser.parseError(e,t);else throw Error(e)},`parseError`),setInput:e(function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match=``,this.conditionStack=[`INITIAL`],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},`setInput`),input:e(function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},`input`),unput:e(function(e){var t=e.length,n=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},`unput`),more:e(function(){return this._more=!0,this},`more`),reject:e(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError(`Lexical error on line `+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
4
4
  `+this.showPosition(),{text:``,token:null,line:this.yylineno});return this},`reject`),less:e(function(e){this.unput(this.match.slice(e))},`less`),pastInput:e(function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?`...`:``)+e.substr(-20).replace(/\n/g,``)},`pastInput`),upcomingInput:e(function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?`...`:``)).replace(/\n/g,``)},`upcomingInput`),showPosition:e(function(){var e=this.pastInput(),t=Array(e.length+1).join(`-`);return e+this.upcomingInput()+`